equal
deleted
inserted
replaced
42 #include "egl_stubs.h" |
42 #include "egl_stubs.h" |
43 |
43 |
44 FARPROC vector[MAX_ORDINAL+1]; // 1 additional entry: vector[0] to set the initialised state |
44 FARPROC vector[MAX_ORDINAL+1]; // 1 additional entry: vector[0] to set the initialised state |
45 |
45 |
46 |
46 |
|
47 #ifdef _DEBUG |
47 void Stop(char* aErrorMessage) |
48 void Stop(char* aErrorMessage) |
|
49 #else |
|
50 void Stop(char* /*aErrorMessage*/) |
|
51 #endif |
48 { |
52 { |
49 int err = GetLastError(); |
53 int err = GetLastError(); |
|
54 #ifdef _DEBUG |
50 RDebug::Printf("%S, (last error = %i)", aErrorMessage, err); |
55 RDebug::Printf("%S, (last error = %i)", aErrorMessage, err); |
|
56 #endif |
51 _asm int 3; |
57 _asm int 3; |
52 } |
58 } |
53 |
59 |
54 void fill_vector(HINSTANCE aDll) |
60 void fill_vector(HINSTANCE aDll) |
55 { |
61 { |
69 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+1)); |
75 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+1)); |
70 if (address == NULL) |
76 if (address == NULL) |
71 { |
77 { |
72 Stop("... has too few exported functions"); |
78 Stop("... has too few exported functions"); |
73 } |
79 } |
74 |
80 |
75 // next position should be empty |
81 // next position should be empty |
76 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+2)); |
82 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+2)); |
77 if (address != NULL) |
83 if (address != NULL) |
78 { |
84 { |
79 Stop("... has too many exported functions"); |
85 Stop("... has too many exported functions"); |
80 } |
86 } |
81 |
|
82 // Set initialised |
87 // Set initialised |
83 vector[0] = (FARPROC)1; |
88 vector[0] = (FARPROC)1; |
84 } |
89 } |
85 |
90 |
86 // redirects DLL calls to GCE or non-GCE implementation |
91 // redirects DLL calls to GCE or non-GCE implementation |
100 else |
105 else |
101 { |
106 { |
102 library = "libegl_nongce.dll"; |
107 library = "libegl_nongce.dll"; |
103 } |
108 } |
104 |
109 |
|
110 #ifdef _DEBUG |
105 RDebug::Printf("Redirecting libEGL.dll to \"%s\" ...\n", library); |
111 RDebug::Printf("Redirecting libEGL.dll to \"%s\" ...\n", library); |
106 |
112 #endif |
|
113 |
107 Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel |
114 Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel |
108 // try to load selected DLL |
115 // try to load selected DLL |
109 HINSTANCE instance = LoadLibraryA(library); |
116 HINSTANCE instance = LoadLibraryA(library); |
110 Emulator::Reenter(); |
117 Emulator::Reenter(); |
111 |
118 |
114 Stop("... unable to load"); |
121 Stop("... unable to load"); |
115 } |
122 } |
116 else |
123 else |
117 { |
124 { |
118 fill_vector(instance); |
125 fill_vector(instance); |
|
126 #ifdef _DEBUG |
119 RDebug::Printf("... DLL loaded successfully"); |
127 RDebug::Printf("... DLL loaded successfully"); |
|
128 #endif |
120 } |
129 } |
121 } |
130 } |
122 |
131 |
123 __declspec(naked) void common_dispatch() |
132 __declspec(naked) void common_dispatch() |
124 { |
133 { |