ReactOS  0.4.15-dev-2771-g6d441f7
delayimp.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Tests for delayload
5  * PROGRAMMER: Mark Jansen
6  */
7 
8 #include <apitest.h>
9 
10 #include <apitest.h>
11 #include <strsafe.h>
12 #include <delayimp.h>
13 
14 /* Some libraries to test against */
15 #include <mmsystem.h>
16 #include <winver.h>
17 #include <shlwapi.h>
18 #include <intshcut.h>
19 #include <sfc.h>
20 #include <imagehlp.h>
21 #include <mmddk.h>
22 
23 #include <pseh/pseh2.h>
24 
25 /* Compatibility with the MS defines */
26 
27 #ifndef FACILITY_VISUALCPP
28 #define FACILITY_VISUALCPP ((LONG)0x6d)
29 #endif
30 
31 #ifndef VcppException
32 #define VcppException(sev,err) ((sev) | (FACILITY_VISUALCPP<<16) | err)
33 #endif
34 
35 #ifdef __REACTOS__
36 #define WINMM_DLLNAME "winmm.dll"
37 #else
38 #define WINMM_DLLNAME "WINMM.dll"
39 #endif
40 
41 bool g_BreakFunctionName = false;
42 bool g_BrokenFunctionName = false;
43 bool g_BypassMost = false;
44 bool g_ExceptionIsModule = false;
45 bool g_ImportByName = true;
46 const char* g_ExpectedDll = NULL;
47 const char* g_ExpectedName = NULL;
48 char g_Target[100] = { 0 };
49 
51 {
52  if (g_Target[0] == '\0' && pdli)
53  {
54  if (pdli->dlp.fImportByName)
55  sprintf(g_Target, "%s!%s", pdli->szDll, pdli->dlp.szProcName);
56  else
57  sprintf(g_Target, "%s!#%lu", pdli->szDll, pdli->dlp.dwOrdinal);
58  }
59  return g_Target;
60 }
61 
62 
63 struct UnProtect
64 {
66  :mAddr(NULL), mProt(0)
67  {
68  if (IsBadWritePtr(addr, 1))
69  {
70  mAddr = addr;
72  }
73  }
75  {
76  DWORD dwOld;
77  if (mAddr)
78  VirtualProtect(mAddr, 1, mProt, &dwOld);
79  }
80 
83 };
84 
85 
86 unsigned* g_DliHookExpected = NULL;
87 size_t g_DliHookIndex = 0;
88 #define LAST_DLI 333
89 
90 static void SetExpectedDli(unsigned* order)
91 {
93  g_DliHookIndex = 0;
94  g_Target[0] = '\0';
95 }
96 
97 static void CheckDli_imp(unsigned dliNotify, PDelayLoadInfo pdli, BOOL ErrorHandler)
98 {
99  if (!g_DliHookExpected) return;
100 
101  winetest_ok(dliNotify == g_DliHookExpected[g_DliHookIndex], "Expected dliNotify to be %u, was: %u for %s\n",
102  g_DliHookExpected[g_DliHookIndex], dliNotify, target(pdli));
103  if (ErrorHandler)
104  {
105  winetest_ok(dliNotify == dliFailGetProc || dliNotify == dliFailLoadLib,
106  "Expected code %u to be processed by the Hook, not the ErrorHandler for %s\n", dliNotify, target(pdli));
107  }
108  else
109  {
110  winetest_ok(dliNotify == dliStartProcessing || dliNotify == dliNotePreLoadLibrary ||
111  dliNotify == dliNotePreGetProcAddress || dliNotify == dliNoteEndProcessing,
112  "Expected code %u to be processed by the ErrorHandler, not the Hook for %s\n", dliNotify, target(pdli));
113  }
115  g_DliHookIndex++;
116 }
117 
118 static void CheckDliDone_imp()
119 {
120  if (!g_DliHookExpected) return;
122  "Expected g_DliHookExpected[g_DliHookIndex] to be %u, was: %u for %s\n",
125  g_Target[0] = '\0';
126 }
127 
128 #define CheckDli (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : CheckDli_imp
129 #define CheckDliDone (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : CheckDliDone_imp
130 
131 
132 /* Replacement functions */
134 {
135  return 123;
136 }
137 
139 {
140  return 12345;
141 }
142 
143 
145 FARPROC WINAPI DliHook(unsigned dliNotify, PDelayLoadInfo pdli)
146 {
147  ok(pdli && pdli->cb >= 36, "Expected a valid pointer with a struct that is big enough: %p, %lu\n",
148  pdli, pdli ? pdli->cb : 0u);
149  if (!pdli || pdli->cb < 36) return NULL;
150 
151  CheckDli(dliNotify, pdli, FALSE);
152 
154  {
155  g_BreakFunctionName = false;
156  g_BrokenFunctionName = true;
157  char* procname = (char*)pdli->dlp.szProcName;
158  UnProtect prot(procname);
159  char c = procname[0];
160  procname[0] = isupper(c) ? tolower(c) : toupper(c);
161  }
162 
163  /* Validate dll name when required */
165  {
166  ok(!strcmp(g_ExpectedDll, pdli->szDll), "Expected szDll to be '%s', but was: '%s'\n", g_ExpectedDll, pdli->szDll);
167  ok(pdli->dlp.fImportByName, "Expected import by name (%s!%s)\n", g_ExpectedDll, g_ExpectedName);
168  if (pdli->dlp.fImportByName)
169  {
170  ok(!strcmp(g_ExpectedName, pdli->dlp.szProcName), "Expected szProcName to be '%s', but was: '%s'\n",
171  g_ExpectedName, pdli->dlp.szProcName);
172  }
173  }
174 
175 
176  if (dliNotify == dliStartProcessing)
177  {
178  /* Test loadlib fail */
179  if (!_stricmp(pdli->szDll, "sfc_os.dll"))
180  {
181  char* dll = (char*)pdli->szDll;
182  UnProtect u(dll);
183  dll[0] = 'l'; dll[1] = '_'; dll[2] = 'm';
184  }
185  if (!_stricmp(pdli->szDll, "imagehlp.dll"))
186  {
187  char* dll = (char*)pdli->szDll;
188  UnProtect u(dll);
189  dll[0] = 'x'; dll[1] = 'x'; dll[2] = 'x'; dll[3] = 'x'; dll[4] = 'x';
190  }
191  /* Test bypass */
192  if (!_stricmp(pdli->szDll, "dbghelp.dll"))
193  return MyFunction;
194  }
195  else if (dliNotify == dliNotePreLoadLibrary)
196  {
197  /* Show that this value is actually used! */
198  if (!_stricmp(pdli->szDll, "version.dll"))
199  {
200  g_VersionDll = LoadLibraryA("version.dll");
201  return (FARPROC)1;
202  }
203 
204  }
205  else if (dliNotify == dliNotePreGetProcAddress)
206  {
207  if (pdli->dlp.fImportByName && !strcmp(pdli->dlp.szProcName, "SfcIsKeyProtected"))
208  {
210  }
211  }
212 
213  /* Parameter validation */
214  ok(pdli->ppfn != NULL, "Expected ppfn to be valid, was NULL for %s\n", target(pdli));
215  ok(pdli->szDll != NULL, "Expected szDll to be valid, was NULL for %s\n", target(pdli));
216  ok(pdli->dwLastError == ERROR_SUCCESS,
217  "Expected dwLastError to be ERROR_SUCCESS, was: %lu for %s\n", pdli->dwLastError, target(pdli));
218  ok(g_ImportByName == !!pdli->dlp.fImportByName, "Expected pdli->dlp.fImportByName to equal g_ImportByname\n");
219  if (pdli->dlp.fImportByName)
220  ok(pdli->dlp.szProcName != NULL, "Expected szProcName to be valid, was NULL for %s\n", target(pdli));
221  else
222  ok(pdli->dlp.dwOrdinal != 0, "Expected dwOrdinal to be valid, was NULL for %s\n", target(pdli));
223  switch(dliNotify)
224  {
225  case dliStartProcessing:
226  ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
227  ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
228  break;
230  ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
231  ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
232  break;
234  ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
235  ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
236  break;
238  if (!g_BypassMost)
239  ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
240  ok(pdli->pfnCur != NULL, "Expected pfnCur to be a valid pointer, was NULL for %s\n", target(pdli));
242  {
244  ok(targetProc != NULL, "This should not happen, the function i need is unavail! (%s!%s)\n",
246  ok(targetProc == pdli->pfnCur, "Expected pfnCur to be %p, was %p for %s\n", targetProc, pdli->pfnCur, target(pdli));
247  ok(pdli->ppfn && targetProc == *pdli->ppfn,
248  "Expected ppfn to be valid and to result in %p, was: %p(%p) for %s\n",
249  target, pdli->ppfn, pdli->ppfn ? *pdli->ppfn : NULL, target(pdli));
250  }
251  break;
252  default:
253  break;
254  }
255  return NULL;
256 }
257 
258 FARPROC WINAPI DliFailHook(unsigned dliNotify, PDelayLoadInfo pdli)
259 {
260  ok(pdli && pdli->cb >= 36,
261  "Expected a valid pointer with a struct that is big enough: %p, %lu\n", pdli, pdli ? pdli->cb : 0u);
262  if (!pdli || pdli->cb < 36) return NULL;
263 
264  CheckDli(dliNotify, pdli, TRUE);
265 
266  /* Redirections / fixes */
267  if (dliNotify == dliFailLoadLib)
268  {
269  if (!_stricmp(pdli->szDll, "l_m_os.dll"))
270  return (FARPROC)LoadLibraryA("sfc_os.dll");
271  }
272  else if (dliNotify == dliFailGetProc)
273  {
274  if (pdli->dlp.fImportByName && pdli->hmodCur == (HMODULE)1)
275  {
276  return GetProcAddress(g_VersionDll, pdli->dlp.szProcName);
277  }
278  }
279 
280  /* Parameter validation */
281  ok(pdli->ppfn != NULL, "Expected ppfn to be valid, was NULL for %s\n", target(pdli));
282  ok(pdli->szDll != NULL, "Expected szDll to be valid, was NULL for %s\n", target(pdli));
283  if (pdli->dlp.fImportByName)
284  ok(pdli->dlp.szProcName != NULL, "Expected szProcName to be valid, was NULL for %s\n", target(pdli));
285  else
286  ok(pdli->dlp.dwOrdinal != 0, "Expected dwOrdinal to be valid, was NULL for %s\n", target(pdli));
287  switch(dliNotify)
288  {
289  case dliFailLoadLib:
290  ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
291  ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
293  "Expected dwLastError to be ERROR_MOD_NOT_FOUND, was: %lu for %s\n", pdli->dwLastError, target(pdli));
294  break;
295  case dliFailGetProc:
296  ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
297  ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
299  "Expected dwLastError to be ERROR_PROC_NOT_FOUND, was: %lu for %s\n", pdli->dwLastError, target(pdli));
300  break;
301  }
302 
303  return NULL;
304 }
305 
306 
308 {
310  ok(ExceptionCode == expected, "Expected code to be 0x%lx, was: 0x%lx\n", expected, ExceptionCode);
311  ok(ExceptionInfo != NULL, "Expected to get exception info\n");
312  ok(ExceptionInfo->ExceptionRecord != NULL, "Expected to get a valid record info\n");
313 
314  if (ExceptionCode != expected)
315  {
316  skip("Skipping other checks, this was not the exception we expected!\n");
318  }
319 
320  if (ExceptionInfo && ExceptionInfo->ExceptionRecord)
321  {
322  PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord;
323  ok(ExceptionRecord->ExceptionCode == expected, "Expected ExceptionCode to be 0x%lx, was 0x%lx\n",
324  expected, ExceptionRecord->ExceptionCode);
325  /* We can still continue. */
326  ok(ExceptionRecord->ExceptionFlags == 0, "Expected ExceptionFlags to be 0, was: 0x%lx\n",
327  ExceptionRecord->ExceptionFlags);
328  ok(ExceptionRecord->NumberParameters == 1, "Expected 1 parameter, got %lu\n",
329  ExceptionRecord->NumberParameters);
330  if (ExceptionRecord->NumberParameters == 1)
331  {
332  PDelayLoadInfo LoadInfo = (PDelayLoadInfo)ExceptionRecord->ExceptionInformation[0];
333  ok(LoadInfo && LoadInfo->cb >= 36, "Expected a valid pointer with a struct that is big enough: %p, %lu\n",
334  LoadInfo, LoadInfo ? LoadInfo->cb : 0);
335 
336  if (g_ExpectedDll)
337  ok(!strcmp(g_ExpectedDll, LoadInfo->szDll), "Expected szDll to be '%s', but was: '%s'\n",
338  g_ExpectedDll, LoadInfo->szDll);
339  if (g_ExpectedName)
340  {
341  ok(LoadInfo->dlp.fImportByName, "Expected import by name\n");
342  if (LoadInfo->dlp.fImportByName)
343  {
344  ok(!strcmp(g_ExpectedName, LoadInfo->dlp.szProcName),
345  "Expected szProcName to be '%s', but was: '%s'\n", g_ExpectedName, LoadInfo->dlp.szProcName);
346 
348  {
349  HMODULE mod = LoadLibraryA("imagehlp.dll");
350  LoadInfo->pfnCur = GetProcAddress(mod, g_ExpectedName);
351  }
352  else
353  {
354  char buf[100];
356  sprintf(buf, "%c%s", first, g_ExpectedName + 1);
358  }
360  }
361  }
362  }
363  }
364 
366 }
367 
368 /* We register one hook the 'default' way and one manually,
369 so that we can check that both fallback and registration work*/
370 extern "C"
371 {
373  //PfnDliHook __pfnDliFailureHook2 = DliFailHook;
374 }
375 
376 
377 bool g_UsePointers = false;
378 
379 template<typename PTR>
381 {
382  /* Old delayload type */
383  if (g_UsePointers)
384  return reinterpret_cast<PTR>(rva);
385  return reinterpret_cast<PTR>((reinterpret_cast<PBYTE>(dos) + rva));
386 }
387 
388 
398 unsigned g_imagehlp[] = { dliStartProcessing, dliNotePreLoadLibrary, dliFailLoadLib, LAST_DLI }; /* This exception does not fire EndProcessing! */
399 
400 
401 //#define DELAYLOAD_SUPPORTS_UNLOADING
402 START_TEST(delayimp)
403 {
404  /* Verify that both scenario's work */
405  ok(__pfnDliNotifyHook2 == DliHook, "Expected __pfnDliNotifyHook2 to be DliHook(%p), but was: %p\n",
407  ok(__pfnDliFailureHook2 == NULL, "Expected __pfnDliFailureHook2 to be NULL, but was: %p\n",
409 
411 
412 
414 
415  ok(dos->e_magic == IMAGE_DOS_SIGNATURE, "Expected a DOS header\n");
417  return;
418 
421 
422  /* Test some advanced features (loading / unloading) */
423  if (delaydir->Size != 0)
424  {
425 #if defined(_DELAY_IMP_VER) && _DELAY_IMP_VER == 2 && defined(DELAYLOAD_SUPPORTS_UNLOADING)
426  /* First, before mangling the delayload stuff, let's try some v2 functions */
428  ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
429  /* Now, a mistyped module (case sensitive!) */
430  HRESULT hr = __HrLoadAllImportsForDll("WiNmM.DlL");
431  ok(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), "Expected hr to be HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), was %lu\n", hr);
433  ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
434 
435  /* Let's load it */
436  hr = __HrLoadAllImportsForDll(WINMM_DLLNAME);
437  ok(hr == S_OK, "Expected hr to be S_OK, was %lu\n", hr);
439  ok(mod != NULL, "Expected mod to be valid, was NULL\n");
440 
441  BOOL status = __FUnloadDelayLoadedDLL2(WINMM_DLLNAME);
442  ok(status == TRUE, "Expected __FUnloadDelayLoadedDLL2 to succeed\n");
444  ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
445 #else
446  trace("Binary compiled without support for unloading\n");
447 #endif
448  }
449  else
450  {
451  skip("No IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT found, some advanced features might not work!\n");
452  }
453 
454  /* Test the normal flow without a dll loaded */
457  g_ExpectedName = "mmGetCurrentTask";
458  DWORD task = mmGetCurrentTask();
459  ok(task == GetCurrentThreadId(), "Expected ret to be current thread id (0x%lx), was 0x%lx\n", GetCurrentThreadId(), task);
460  CheckDliDone();
461 
462  /* Test the normal flow with a dll loaded */
465  g_ExpectedName = "midiOutClose";
466  DWORD err = midiOutClose((HMIDIOUT)(ULONG_PTR)0xdeadbeef);
467  ok(err == MMSYSERR_INVALHANDLE, "Expected err to be MMSYSERR_INVALHANDLE, was 0x%lx\n", err);
468  CheckDliDone();
469 
470  /* Make sure GetProcAddress fails, also ignore the Failure hook, use the exception to set the address */
473  g_ExpectedName = "MixerClose";
474  g_BreakFunctionName = true;
475  _SEH2_TRY
476  {
477  err = mixerClose((HMIXER)(ULONG_PTR)0xdeadbeef);
478  }
480  {
482  }
483  _SEH2_END;
484  ok(err == MMSYSERR_INVALHANDLE, "Expected err to be MMSYSERR_INVALHANDLE, was 0x%lx\n", err);
485  CheckDliDone();
486  ok(g_BreakFunctionName == false, "Expected the functionname to be changed\n");
487 
488  /* Make the LoadLib fail, manually load the library in the Failure Hook,
489  Respond to the dliNotePreGetProcAddress with an alternate function address */
492  ok(ret == 12345, "Expected ret to be 12345, was %u\n", ret); /* The original function returns FALSE! */
493  CheckDliDone();
494 
495  /* Show that it works with the manually returned dll */
498  ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
499  CheckDliDone();
500 
501  /* Return a fake dll handle, so that we can see when it is being used, and manually return a function in the Failure Hook */
504  ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
505  CheckDliDone();
506 
507  /* Manually return a function in the failure hook, when the module is the previously set bad one */
510  ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
511  CheckDliDone();
512 
513  if (HIWORD(SymGetOptions) == NULL)
514  {
515  skip("SymGetOptions until CORE-6504 is fixed\n");
516  }
517  else
518  {
519  /* Completely bypass most hooks, by directly replying with a function address */
521  g_BypassMost = true;
522  DWORD opt = SymGetOptions();
523  g_BypassMost = false;
524  ok(opt == 123, "Expected opt to be 123, was %lu\n", opt); /* The original function returns ERROR_INVALID_HANDLE */
525  CheckDliDone();
526  }
527 
528  /* Import by ordinal */
529  g_ImportByName = false;
531  PARSEDURLA pua = { sizeof(pua), 0 };
532  HRESULT hr = ParseURLA("", &pua);
533  ok(hr == URL_E_INVALID_SYNTAX, "Expected tmp to be URL_E_INVALID_SYNTAX, was %lx\n", hr);
534  CheckDliDone();
535  g_ImportByName = true;
536 
537  /* Handle LoadLib failure with an exception handler */
538  if (HIWORD(MapAndLoad) == NULL)
539  {
540  skip("MapAndLoad until CORE-6504 is fixed\n");
541  }
542  else
543  {
545  LOADED_IMAGE img = {0};
546  ret = 123;
547  g_ExceptionIsModule = true;
548  g_ExpectedDll = "xxxxxhlp.dll";
549  g_ExpectedName = "MapAndLoad";
550  _SEH2_TRY
551  {
552  ret = MapAndLoad("some_not_existing_file.aabbcc", NULL, &img, FALSE, TRUE);
553  }
555  {
556  ;
557  }
558  _SEH2_END;
559  g_ExceptionIsModule = false;
560  ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
561  CheckDliDone();
562  }
563 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
FARPROC pfnCur
Definition: delayimp.h:73
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1772
#define IN
Definition: typedefs.h:39
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
BOOL WINAPI MySfcIsKeyProtected(HKEY KeyHandle, LPCWSTR SubKeyName, REGSAM KeySam)
Definition: delayimp.cpp:138
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
UnProtect(PVOID addr)
Definition: delayimp.cpp:65
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4723
unsigned g_winmm_get_cur_task[]
Definition: delayimp.cpp:389
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
static void SetExpectedDli(unsigned *order)
Definition: delayimp.cpp:90
unsigned g_imagehlp[]
Definition: delayimp.cpp:398
char g_Target[100]
Definition: delayimp.cpp:48
const GLint * first
Definition: glext.h:5794
size_t g_DliHookIndex
Definition: delayimp.cpp:87
#define CheckDliDone
Definition: delayimp.cpp:129
PVOID mAddr
Definition: delayimp.cpp:81
UINT WINAPI mixerClose(HMIXER hMix)
Definition: winmm.c:389
HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
Definition: url.c:161
#define WINMM_DLLNAME
Definition: delayimp.cpp:38
bool g_BypassMost
Definition: delayimp.cpp:43
struct DelayLoadInfo * PDelayLoadInfo
unsigned g_winmm_mide_in_close[]
Definition: delayimp.cpp:391
unsigned g_sfc_key[]
Definition: delayimp.cpp:392
START_TEST(delayimp)
Definition: delayimp.cpp:402
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
BOOL fImportByName
Definition: delayimp.h:57
int32_t INT_PTR
Definition: typedefs.h:64
unsigned g_version_w[]
Definition: delayimp.cpp:395
FARPROC(WINAPI * PfnDliHook)(unsigned, PDelayLoadInfo)
Definition: delayimp.h:77
#define _stricmp
Definition: cat.c:22
IMAGE_NT_HEADERS nt
Definition: module.c:50
BOOL WINAPI MapAndLoad(PCSTR pszImageName, PCSTR pszDllPath, PLOADED_IMAGE pLoadedImage, BOOL bDotDll, BOOL bReadOnly)
Definition: access.c:131
unsigned g_version_a[]
Definition: delayimp.cpp:394
FARPROC WINAPI DliFailHook(unsigned dliNotify, PDelayLoadInfo pdli)
Definition: delayimp.cpp:258
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define EXCEPTION_CONTINUE_EXECUTION
Definition: excpt.h:87
bool g_ExceptionIsModule
Definition: delayimp.cpp:44
static void CheckDliDone_imp()
Definition: delayimp.cpp:118
unsigned g_sfc_file[]
Definition: delayimp.cpp:393
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
LONG ExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo, ULONG ExceptionCode)
Definition: delayimp.cpp:307
static HMODULE dll
Definition: str.c:188
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD ExceptionCode
Definition: compat.h:208
unsigned g_shlwapi[]
Definition: delayimp.cpp:397
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_SEVERITY_ERROR
Definition: ntbasedef.h:596
~UnProtect()
Definition: delayimp.cpp:74
#define FALSE
Definition: types.h:117
#define CheckDli
Definition: delayimp.cpp:128
bool g_ImportByName
Definition: delayimp.cpp:45
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
INT_PTR WINAPI MyFunction()
Definition: delayimp.cpp:133
LPCSTR szProcName
Definition: delayimp.h:60
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
DelayLoadProc dlp
Definition: delayimp.h:71
DWORD dwLastError
Definition: delayimp.h:74
HMODULE hmodCur
Definition: delayimp.h:72
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
bool g_UsePointers
Definition: delayimp.cpp:377
#define URL_E_INVALID_SYNTAX
Definition: intshcut.h:32
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
unsigned g_scard[]
Definition: delayimp.cpp:396
int toupper(int c)
Definition: utclib.c:881
DWORD mProt
Definition: delayimp.cpp:82
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
#define trace
Definition: atltest.h:70
#define isupper(c)
Definition: acclib.h:71
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
GLint GLvoid * img
Definition: gl.h:1956
LONG HRESULT
Definition: typedefs.h:79
UINT WINAPI midiOutClose(HMIDIOUT hMidiOut)
Definition: winmm.c:981
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
bool g_BrokenFunctionName
Definition: delayimp.cpp:42
#define WINAPI
Definition: msvc.h:6
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:144
BOOL WINAPI SfcIsKeyProtected(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired)
Definition: sfc_os.c:117
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT
Definition: ntimage.h:488
unsigned g_winmm_midi_out_close[]
Definition: delayimp.cpp:390
BOOL WINAPI GetFileVersionInfoA(LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:853
int ret
IMAGE_DOS_HEADER dos
Definition: module.c:49
GLenum const GLvoid * addr
Definition: glext.h:9621
DWORD cb
Definition: delayimp.h:67
LPCSTR szDll
Definition: delayimp.h:70
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define err(...)
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
FARPROC WINAPI DliHook(unsigned dliNotify, PDelayLoadInfo pdli)
Definition: delayimp.cpp:145
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
PfnDliHook __pfnDliNotifyHook2
Definition: delayimp.cpp:372
PfnDliHook __pfnDliFailureHook2
Definition: pdb.c:221
#define S_OK
Definition: intsafe.h:51
_SEH2_END
Definition: create.c:4400
DWORD dwOrdinal
Definition: delayimp.h:61
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
#define GetModuleHandle
Definition: winbase.h:3683
DWORD WINAPI SymGetOptions(void)
Definition: dbghelp.c:574
#define ok(value,...)
Definition: atltest.h:57
PTR Rva2Addr(PIMAGE_DOS_HEADER dos, RVA rva)
Definition: delayimp.cpp:380
#define LAST_DLI
Definition: delayimp.cpp:88
ACCESS_MASK REGSAM
Definition: winreg.h:69
bool g_BreakFunctionName
Definition: delayimp.cpp:41
#define NULL
Definition: types.h:112
BOOL WINAPI SfcGetNextProtectedFile(HANDLE RpcHandle, PPROTECTED_FILE_DATA ProtFileData)
Definition: sfc_os.c:142
unsigned * g_DliHookExpected
Definition: delayimp.cpp:86
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
#define skip(...)
Definition: atltest.h:64
FARPROC * ppfn
Definition: delayimp.h:69
DWORD RVA
Definition: compat.h:1121
const char * g_ExpectedName
Definition: delayimp.cpp:47
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
#define HIWORD(l)
Definition: typedefs.h:247
unsigned int ULONG
Definition: retypes.h:1
GLenum target
Definition: glext.h:7315
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
DWORD ExceptionFlags
Definition: compat.h:209
#define GetProcAddress(x, y)
Definition: compat.h:612
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define VcppException(sev, err)
Definition: delayimp.cpp:32
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
char * target(PDelayLoadInfo pdli)
Definition: delayimp.cpp:50
DWORD APIENTRY mmGetCurrentTask(VOID)
Definition: winmm.c:2915
DWORD NumberParameters
Definition: compat.h:212
const char * g_ExpectedDll
Definition: delayimp.cpp:46
static HMODULE g_VersionDll
Definition: delayimp.cpp:144
int tolower(int c)
Definition: utclib.c:902
BYTE * PBYTE
Definition: pedump.c:66
static void CheckDli_imp(unsigned dliNotify, PDelayLoadInfo pdli, BOOL ErrorHandler)
Definition: delayimp.cpp:97
int(* FARPROC)()
Definition: compat.h:36
static int mod
Definition: i386-dis.c:1281
BOOL expected
Definition: store.c:2063
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
Definition: ps.c:97