equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <emulator.h> |
|
20 |
|
21 |
|
22 extern "C" { |
|
23 |
|
24 #include "cryptography_stubs.h" |
|
25 |
|
26 FARPROC vector[MAX_ORDINAL+1]; |
|
27 |
|
28 void fill_vector(HINSTANCE aDll) |
|
29 { |
|
30 int i; |
|
31 for (i=1;i<=MAX_ORDINAL;i++) |
|
32 { |
|
33 vector[i] = GetProcAddress(aDll, (LPCSTR)i); |
|
34 } |
|
35 vector[0] = (FARPROC)1; // initialised |
|
36 } |
|
37 |
|
38 void init_vector() |
|
39 { |
|
40 __LOCK_HOST; // prevent deadlock with EKA2 scheduler |
|
41 |
|
42 HINSTANCE instance; |
|
43 |
|
44 // Try for strong cryptography |
|
45 // |
|
46 instance = LoadLibraryA("strong_cryptography.dll"); |
|
47 if (instance != NULL) |
|
48 { |
|
49 fill_vector(instance); |
|
50 return; |
|
51 } |
|
52 |
|
53 // Try for weak cryptography |
|
54 // |
|
55 instance = LoadLibraryA("weak_cryptography.dll"); |
|
56 if (instance != NULL) |
|
57 { |
|
58 fill_vector(instance); |
|
59 return; |
|
60 } |
|
61 |
|
62 // die |
|
63 // |
|
64 OutputDebugStringA("Unable to load cryptography implementation"); |
|
65 _asm int 3; |
|
66 } |
|
67 |
|
68 __declspec(naked) void common_dispatch() |
|
69 { |
|
70 _asm cmp dword ptr vector,0 // initialised? |
|
71 _asm jne call_though_vector |
|
72 _asm push eax |
|
73 _asm push ecx |
|
74 _asm push edx |
|
75 _asm call init_vector |
|
76 _asm pop edx |
|
77 _asm pop ecx |
|
78 _asm pop eax |
|
79 call_though_vector: |
|
80 _asm jmp [vector+eax*4] |
|
81 } |
|
82 |
|
83 } |