sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: sl@0: sl@0: extern "C" { sl@0: sl@0: #include "cryptography_stubs.h" sl@0: sl@0: FARPROC vector[MAX_ORDINAL+1]; sl@0: sl@0: void fill_vector(HINSTANCE aDll) sl@0: { sl@0: int i; sl@0: for (i=1;i<=MAX_ORDINAL;i++) sl@0: { sl@0: vector[i] = GetProcAddress(aDll, (LPCSTR)i); sl@0: } sl@0: vector[0] = (FARPROC)1; // initialised sl@0: } sl@0: sl@0: void init_vector() sl@0: { sl@0: __LOCK_HOST; // prevent deadlock with EKA2 scheduler sl@0: sl@0: HINSTANCE instance; sl@0: sl@0: // Try for strong cryptography sl@0: // sl@0: instance = LoadLibraryA("strong_cryptography.dll"); sl@0: if (instance != NULL) sl@0: { sl@0: fill_vector(instance); sl@0: return; sl@0: } sl@0: sl@0: // Try for weak cryptography sl@0: // sl@0: instance = LoadLibraryA("weak_cryptography.dll"); sl@0: if (instance != NULL) sl@0: { sl@0: fill_vector(instance); sl@0: return; sl@0: } sl@0: sl@0: // die sl@0: // sl@0: OutputDebugStringA("Unable to load cryptography implementation"); sl@0: _asm int 3; sl@0: } sl@0: sl@0: __declspec(naked) void common_dispatch() sl@0: { sl@0: _asm cmp dword ptr vector,0 // initialised? sl@0: _asm jne call_though_vector sl@0: _asm push eax sl@0: _asm push ecx sl@0: _asm push edx sl@0: _asm call init_vector sl@0: _asm pop edx sl@0: _asm pop ecx sl@0: _asm pop eax sl@0: call_though_vector: sl@0: _asm jmp [vector+eax*4] sl@0: } sl@0: sl@0: }