ReactOS 0.4.16-dev-2491-g3dc6630
delayimp.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Tests for delayload
5 * COPYRIGHT: Copyright 2023-2025 Mark Jansen <mark.jansen@reactos.org>
6 * Copyright 2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
7 */
8
9#define STANDALONE
10#include <apitest.h>
11
12#include <strsafe.h>
13#include <delayimp.h>
14
15/* See CMakeLists.txt */
16#define DELAYIMP_NOHOOK 0
17#define DELAYIMP_GLOBALHOOK 1
18#define DELAYIMP_RUNTIMEHOOK 2
19
20/* Some libraries to test against */
21#include <mmsystem.h>
22#include <winver.h>
23#include <shlwapi.h>
24#include <intshcut.h>
25#include <sfc.h>
26#include <imagehlp.h>
27#include <mmddk.h>
28
29#include <pseh/pseh2.h>
30
31/* Compatibility with the MS defines */
32
33#ifndef FACILITY_VISUALCPP
34#define FACILITY_VISUALCPP ((LONG)0x6d)
35#endif
36
37#ifndef VcppException
38#define VcppException(sev,err) ((sev) | (FACILITY_VISUALCPP<<16) | err)
39#endif
40
41#ifdef __REACTOS__
42#define WINMM_DLLNAME "winmm.dll"
43#else
44#define WINMM_DLLNAME "WINMM.dll"
45#endif
46
49bool g_BypassMost = false;
51bool g_ImportByName = true;
52const char* g_ExpectedDll = NULL;
53const char* g_ExpectedName = NULL;
54char g_Target[100] = { 0 };
55
56static char* target(PDelayLoadInfo pdli)
57{
58 if (g_Target[0] == '\0' && pdli)
59 {
60 if (pdli->dlp.fImportByName)
61 sprintf(g_Target, "%s!%s", pdli->szDll, pdli->dlp.szProcName);
62 else
63 sprintf(g_Target, "%s!#%lu", pdli->szDll, pdli->dlp.dwOrdinal);
64 }
65 return g_Target;
66}
67
68
70{
72 :mAddr(NULL), mProt(0)
73 {
74 if (IsBadWritePtr(addr, 1))
75 {
76 mAddr = addr;
78 }
79 }
81 {
82 DWORD dwOld;
83 if (mAddr)
84 VirtualProtect(mAddr, 1, mProt, &dwOld);
85 }
86
89};
90
91
93size_t g_DliHookIndex = 0;
94#define LAST_DLI 333
95
96static void SetExpectedDli(unsigned* order)
97{
100 g_Target[0] = '\0';
101}
102
103static void CheckDli_imp(unsigned dliNotify, PDelayLoadInfo pdli, BOOL ErrorHandler)
104{
105 if (!g_DliHookExpected) return;
106
107 winetest_ok(dliNotify == g_DliHookExpected[g_DliHookIndex], "Expected dliNotify to be %u, was: %u for %s\n",
108 g_DliHookExpected[g_DliHookIndex], dliNotify, target(pdli));
109 if (ErrorHandler)
110 {
111 winetest_ok(dliNotify == dliFailGetProc || dliNotify == dliFailLoadLib,
112 "Expected code %u to be processed by the Hook, not the ErrorHandler for %s\n", dliNotify, target(pdli));
113 }
114 else
115 {
116 winetest_ok(dliNotify == dliStartProcessing || dliNotify == dliNotePreLoadLibrary ||
117 dliNotify == dliNotePreGetProcAddress || dliNotify == dliNoteEndProcessing,
118 "Expected code %u to be processed by the ErrorHandler, not the Hook for %s\n", dliNotify, target(pdli));
119 }
122}
123
124static void CheckDliDone_imp()
125{
126 if (!g_DliHookExpected) return;
127#if (DELAYIMP_TEST == DELAYIMP_NOHOOK)
128 unsigned lastDli = 0;
129#else
130 unsigned lastDli = LAST_DLI;
131#endif
133 "Expected g_DliHookExpected[g_DliHookIndex] to be %u, was: %u for %s\n",
136 g_Target[0] = '\0';
137}
138
139#define CheckDli (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : CheckDli_imp
140#define CheckDliDone (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : CheckDliDone_imp
141
142
143/* Replacement functions */
145{
146 return 123;
147}
148
150{
151 return 12345;
152}
153
154
156FARPROC WINAPI DliHook(unsigned dliNotify, PDelayLoadInfo pdli)
157{
158 ok(pdli && pdli->cb >= 36, "Expected a valid pointer with a struct that is big enough: %p, %lu\n",
159 pdli, pdli ? pdli->cb : 0u);
160 if (!pdli || pdli->cb < 36) return NULL;
161
162 CheckDli(dliNotify, pdli, FALSE);
163
165 {
166 g_BreakFunctionName = false;
168 char* procname = (char*)pdli->dlp.szProcName;
169 UnProtect prot(procname);
170 char c = procname[0];
171 procname[0] = isupper(c) ? tolower(c) : toupper(c);
172 }
173
174 /* Validate dll name when required */
176 {
177 ok(!strcmp(g_ExpectedDll, pdli->szDll), "Expected szDll to be '%s', but was: '%s'\n", g_ExpectedDll, pdli->szDll);
178 ok(pdli->dlp.fImportByName, "Expected import by name (%s!%s)\n", g_ExpectedDll, g_ExpectedName);
179 if (pdli->dlp.fImportByName)
180 {
181 ok(!strcmp(g_ExpectedName, pdli->dlp.szProcName), "Expected szProcName to be '%s', but was: '%s'\n",
183 }
184 }
185
186 if (dliNotify == dliStartProcessing)
187 {
188 /* Test loadlib fail */
189 if (!_stricmp(pdli->szDll, "sfc_os.dll"))
190 {
191 char* dll = (char*)pdli->szDll;
192 UnProtect u(dll);
193 dll[0] = 'l'; dll[1] = '_'; dll[2] = 'm';
194 }
195 if (!_stricmp(pdli->szDll, "imagehlp.dll"))
196 {
197 char* dll = (char*)pdli->szDll;
198 UnProtect u(dll);
199 dll[0] = 'x'; dll[1] = 'x'; dll[2] = 'x'; dll[3] = 'x'; dll[4] = 'x';
200 }
201 /* Test bypass */
202 if (!_stricmp(pdli->szDll, "dbghelp.dll"))
203 return MyFunction;
204 }
205 else if (dliNotify == dliNotePreLoadLibrary)
206 {
207 /* Show that this value is actually used! */
208 if (!_stricmp(pdli->szDll, "version.dll"))
209 {
210 g_VersionDll = LoadLibraryA("version.dll");
211 return (FARPROC)1;
212 }
213 }
214 else if (dliNotify == dliNotePreGetProcAddress)
215 {
216 if (pdli->dlp.fImportByName && !strcmp(pdli->dlp.szProcName, "SfcIsKeyProtected"))
217 {
219 }
220 }
221
222 /* Parameter validation */
223 ok(pdli->ppfn != NULL, "Expected ppfn to be valid, was NULL for %s\n", target(pdli));
224 ok(pdli->szDll != NULL, "Expected szDll to be valid, was NULL for %s\n", target(pdli));
226 "Expected dwLastError to be ERROR_SUCCESS, was: %lu for %s\n", pdli->dwLastError, target(pdli));
227 ok(g_ImportByName == !!pdli->dlp.fImportByName, "Expected pdli->dlp.fImportByName to equal g_ImportByname\n");
228 if (pdli->dlp.fImportByName)
229 ok(pdli->dlp.szProcName != NULL, "Expected szProcName to be valid, was NULL for %s\n", target(pdli));
230 else
231 ok(pdli->dlp.dwOrdinal != 0, "Expected dwOrdinal to be valid, was NULL for %s\n", target(pdli));
232 switch (dliNotify)
233 {
235 ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
236 ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
237 break;
239 ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
240 ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
241 break;
243 ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
244 ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
245 break;
247 if (!g_BypassMost)
248 ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
249 ok(pdli->pfnCur != NULL, "Expected pfnCur to be a valid pointer, was NULL for %s\n", target(pdli));
251 {
253 ok(targetProc != NULL, "This should not happen, the function i need is unavail! (%s!%s)\n",
255 ok(targetProc == pdli->pfnCur, "Expected pfnCur to be %p, was %p for %s\n", targetProc, pdli->pfnCur, target(pdli));
256 ok(pdli->ppfn && targetProc == *pdli->ppfn,
257 "Expected ppfn to be valid and to result in %p, was: %p(%p) for %s\n",
258 target, pdli->ppfn, pdli->ppfn ? *pdli->ppfn : NULL, target(pdli));
259 }
260 break;
261 default:
262 break;
263 }
264 return NULL;
265}
266
267FARPROC WINAPI DliFailHook(unsigned dliNotify, PDelayLoadInfo pdli)
268{
269 ok(pdli && pdli->cb >= 36,
270 "Expected a valid pointer with a struct that is big enough: %p, %lu\n", pdli, pdli ? pdli->cb : 0u);
271 if (!pdli || pdli->cb < 36) return NULL;
272
273 CheckDli(dliNotify, pdli, TRUE);
274
275 /* Redirections / fixes */
276 if (dliNotify == dliFailLoadLib)
277 {
278 if (!_stricmp(pdli->szDll, "l_m_os.dll"))
279 return (FARPROC)LoadLibraryA("sfc_os.dll");
280 }
281 else if (dliNotify == dliFailGetProc)
282 {
283 if (pdli->dlp.fImportByName && pdli->hmodCur == (HMODULE)1)
284 {
286 }
287 }
288
289 /* Parameter validation */
290 ok(pdli->ppfn != NULL, "Expected ppfn to be valid, was NULL for %s\n", target(pdli));
291 ok(pdli->szDll != NULL, "Expected szDll to be valid, was NULL for %s\n", target(pdli));
292 if (pdli->dlp.fImportByName)
293 ok(pdli->dlp.szProcName != NULL, "Expected szProcName to be valid, was NULL for %s\n", target(pdli));
294 else
295 ok(pdli->dlp.dwOrdinal != 0, "Expected dwOrdinal to be valid, was NULL for %s\n", target(pdli));
296 switch (dliNotify)
297 {
298 case dliFailLoadLib:
299 ok(pdli->hmodCur == NULL, "Expected hmodCur to be NULL, was: %p for %s\n", pdli->hmodCur, target(pdli));
300 ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
302 "Expected dwLastError to be ERROR_MOD_NOT_FOUND, was: %lu for %s\n", pdli->dwLastError, target(pdli));
303 break;
304 case dliFailGetProc:
305 ok(pdli->hmodCur != NULL, "Expected hmodCur to be valid, was NULL for %s\n", target(pdli));
306 ok(pdli->pfnCur == NULL, "Expected pfnCur to be NULL, was: %p for %s\n", pdli->pfnCur, target(pdli));
308 "Expected dwLastError to be ERROR_PROC_NOT_FOUND, was: %lu for %s\n", pdli->dwLastError, target(pdli));
309 break;
310 }
311
312 return NULL;
313}
314
315
317{
319 ok(ExceptionCode == expected, "Expected code to be 0x%lx, was: 0x%lx\n", expected, ExceptionCode);
320 ok(ExceptionInfo != NULL, "Expected to get exception info\n");
321 ok(ExceptionInfo->ExceptionRecord != NULL, "Expected to get a valid record info\n");
322
323 if (ExceptionCode != expected)
324 {
325 skip("Skipping other checks, this was not the exception we expected!\n");
327 }
328
329 if (ExceptionInfo && ExceptionInfo->ExceptionRecord)
330 {
331 PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord;
332 ok(ExceptionRecord->ExceptionCode == expected, "Expected ExceptionCode to be 0x%lx, was 0x%lx\n",
333 expected, ExceptionRecord->ExceptionCode);
334 /* We can still continue. */
335 ok(ExceptionRecord->ExceptionFlags == 0, "Expected ExceptionFlags to be 0, was: 0x%lx\n",
336 ExceptionRecord->ExceptionFlags);
337 ok(ExceptionRecord->NumberParameters == 1, "Expected 1 parameter, got %lu\n",
338 ExceptionRecord->NumberParameters);
339 if (ExceptionRecord->NumberParameters == 1)
340 {
341 PDelayLoadInfo LoadInfo = (PDelayLoadInfo)ExceptionRecord->ExceptionInformation[0];
342 ok(LoadInfo && LoadInfo->cb >= 36, "Expected a valid pointer with a struct that is big enough: %p, %lu\n",
343 LoadInfo, LoadInfo ? LoadInfo->cb : 0);
344
345 if (g_ExpectedDll)
346 ok(!strcmp(g_ExpectedDll, LoadInfo->szDll), "Expected szDll to be '%s', but was: '%s'\n",
347 g_ExpectedDll, LoadInfo->szDll);
348 if (g_ExpectedName)
349 {
350 ok(LoadInfo->dlp.fImportByName, "Expected import by name\n");
351 if (LoadInfo->dlp.fImportByName)
352 {
354 "Expected szProcName to be '%s', but was: '%s'\n", g_ExpectedName, LoadInfo->dlp.szProcName);
355
357 {
358 HMODULE mod = LoadLibraryA("imagehlp.dll");
360 }
361 else
362 {
363 char buf[100];
365 sprintf(buf, "%c%s", first, g_ExpectedName + 1);
367 }
369 }
370 }
371 }
372 }
373
375}
376
377#if (DELAYIMP_TEST == DELAYIMP_GLOBALHOOK)
378/* Register static hooks */
380{
383}
384#endif
385
386bool g_UsePointers = false;
387
388template<typename PTR>
390{
391 /* Old delayload type */
392 if (g_UsePointers)
393 return reinterpret_cast<PTR>(rva);
394 return reinterpret_cast<PTR>((reinterpret_cast<PBYTE>(dos) + rva));
395}
396
397
407unsigned g_imagehlp[] = { dliStartProcessing, dliNotePreLoadLibrary, dliFailLoadLib, LAST_DLI }; /* This exception does not fire EndProcessing! */
408
409
410//#define DELAYLOAD_SUPPORTS_UNLOADING
411#if (DELAYIMP_TEST == DELAYIMP_NOHOOK)
412START_TEST(delayimp_nohook)
413#elif (DELAYIMP_TEST == DELAYIMP_GLOBALHOOK)
414START_TEST(delayimp_globalhook)
415#else // (DELAYIMP_TEST == DELAYIMP_RUNTIMEHOOK)
416START_TEST(delayimp_runtimehook)
417#endif
418{
419 /* We register hooks either the 'default' (static) way or at runtime,
420 * so that we can check that both fallback and registration work */
421#if (DELAYIMP_TEST == DELAYIMP_GLOBALHOOK)
422 ok(__pfnDliNotifyHook2 == DliHook, "Expected __pfnDliNotifyHook2 to be DliHook(%p), but was: %p\n",
424 ok(__pfnDliFailureHook2 == DliFailHook, "Expected __pfnDliFailureHook2 to be DliFailHook(%p), but was: %p\n",
426#elif (DELAYIMP_TEST == DELAYIMP_RUNTIMEHOOK)
427 ok(__pfnDliNotifyHook2 == NULL, "Expected __pfnDliNotifyHook2 to be NULL, but was: %p\n",
429 ok(__pfnDliFailureHook2 == NULL, "Expected __pfnDliFailureHook2 to be NULL, but was: %p\n",
431
432 /* Register hooks at runtime */
435#else // (DELAYIMP_TEST == DELAYIMP_NOHOOK)
436 /* No hook is defined */
437#endif
438
440
441 ok(dos->e_magic == IMAGE_DOS_SIGNATURE, "Expected a DOS header\n");
443 return;
444
447
448 /* Test some advanced features (loading / unloading) */
449 if (delaydir->Size != 0)
450 {
451#if defined(_DELAY_IMP_VER) && _DELAY_IMP_VER == 2 && defined(DELAYLOAD_SUPPORTS_UNLOADING)
452 /* First, before mangling the delayload stuff, let's try some v2 functions */
454 ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
455 /* Now, a mistyped module (case sensitive!) */
456 HRESULT hr = __HrLoadAllImportsForDll("WiNmM.DlL");
457 ok(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), "Expected hr to be HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), was %lu\n", hr);
459 ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
460
461 /* Let's load it */
462 hr = __HrLoadAllImportsForDll(WINMM_DLLNAME);
463 ok(hr == S_OK, "Expected hr to be S_OK, was %lu\n", hr);
465 ok(mod != NULL, "Expected mod to be valid, was NULL\n");
466
467 BOOL status = __FUnloadDelayLoadedDLL2(WINMM_DLLNAME);
468 ok(status == TRUE, "Expected __FUnloadDelayLoadedDLL2 to succeed\n");
470 ok(mod == NULL, "Expected mod to be NULL, was %p\n", mod);
471#else
472 trace("Binary compiled without support for unloading\n");
473#endif
474 }
475 else
476 {
477 skip("No IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT found, some advanced features might not work!\n");
478 }
479
480 /* Test the normal flow without a dll loaded */
483 g_ExpectedName = "mmGetCurrentTask";
485 ok(task == GetCurrentThreadId(), "Expected ret to be current thread id (0x%lx), was 0x%lx\n", GetCurrentThreadId(), task);
486 CheckDliDone();
487
488 /* Test the normal flow with a dll loaded */
491 g_ExpectedName = "midiOutClose";
492 DWORD err = midiOutClose((HMIDIOUT)(ULONG_PTR)0xdeadbeef);
493 ok(err == MMSYSERR_INVALHANDLE, "Expected err to be MMSYSERR_INVALHANDLE, was 0x%lx\n", err);
494 CheckDliDone();
495
496 /* Make sure GetProcAddress fails, also ignore the Failure hook, use the exception to set the address */
499 g_ExpectedName = "MixerClose";
500 g_BreakFunctionName = true;
502 {
503 err = mixerClose((HMIXER)(ULONG_PTR)0xdeadbeef);
504 }
506 {
508 }
510 ok(err == MMSYSERR_INVALHANDLE, "Expected err to be MMSYSERR_INVALHANDLE, was 0x%lx\n", err);
511 CheckDliDone();
512#if (DELAYIMP_TEST == DELAYIMP_NOHOOK)
513 ok(g_BreakFunctionName == true, "Expected the function name to not be changed\n");
514#else
515 ok(g_BreakFunctionName == false, "Expected the function name to be changed\n");
516#endif
517
519#if (DELAYIMP_TEST == DELAYIMP_NOHOOK)
520 /* We cannot run this test with hooks disabled. The reason is that in this case,
521 * sfc_os.dll may not export SfcIsKeyProtected() (e.g. on Windows <= 2003) and
522 * without the delay-loading hooks, we wouldn't resolve SfcIsKeyProtected(). */
523#else
524 /* Make the LoadLib fail, manually load the library in the Failure Hook,
525 respond to the dliNotePreGetProcAddress with an alternate function address */
528 ok(ret == 12345, "Expected ret to be 12345, was %u\n", ret); /* The original function returns FALSE! */
529 CheckDliDone();
530#endif // DELAYIMP_NOHOOK
531
532 /* Show that it works with the manually returned dll */
535 ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
536 CheckDliDone();
537
538 /* Return a fake dll handle, so that we can see when it is being used, and manually return a function in the Failure Hook */
541 ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
542 CheckDliDone();
543
544 /* Manually return a function in the failure hook, when the module is the previously set bad one */
547 ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
548 CheckDliDone();
549
550#if (DELAYIMP_TEST == DELAYIMP_NOHOOK)
551 /* This test won't run with hooks disabled */
552#else
553 if (HIWORD(SymGetOptions) == NULL)
554 {
555 skip("SymGetOptions until CORE-6504 is fixed\n");
556 }
557 else
558 {
559 /* Completely bypass most hooks, by directly replying with a function address */
561 g_BypassMost = true;
562 DWORD opt = SymGetOptions();
563 g_BypassMost = false;
564 ok(opt == 123, "Expected opt to be 123, was %lu\n", opt); /* The original function returns ERROR_INVALID_HANDLE */
565 CheckDliDone();
566 }
567#endif // DELAYIMP_NOHOOK
568
569 /* Import by ordinal */
570 g_ImportByName = false;
572 PARSEDURLA pua = { sizeof(pua), 0 };
574 ok(hr == URL_E_INVALID_SYNTAX, "Expected tmp to be URL_E_INVALID_SYNTAX, was %lx\n", hr);
575 CheckDliDone();
576 g_ImportByName = true;
577
578 /* Handle LoadLib failure with an exception handler */
580 {
581 skip("MapAndLoad until CORE-6504 is fixed\n");
582 }
583 else
584 {
587 ret = 123;
588 g_ExceptionIsModule = true;
589 g_ExpectedDll = "xxxxxhlp.dll";
590 g_ExpectedName = "MapAndLoad";
592 {
593 ret = MapAndLoad("some_not_existing_file.aabbcc", NULL, &img, FALSE, TRUE);
594 }
596 {
597 ;
598 }
599 _SEH2_END;
600 g_ExceptionIsModule = false;
601 ok(ret == FALSE, "Expected ret to be FALSE, was %u\n", ret);
602 CheckDliDone();
603 }
604}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
#define isupper(c)
Definition: acclib.h:71
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
PfnDliHook __pfnDliFailureHook2
Definition: reactos.c:2964
PfnDliHook __pfnDliNotifyHook2
Custom delay-loading hooks for loading the Setup DLLs from a suitable path.
Definition: reactos.c:2963
#define _stricmp
Definition: cat.c:22
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
#define VcppException(sev, err)
Definition: delayimp.cpp:38
_SEH2_END
Definition: delayimp.cpp:509
bool g_BreakFunctionName
Definition: delayimp.cpp:47
unsigned g_winmm_midi_out_close[]
Definition: delayimp.cpp:399
DWORD task
Definition: delayimp.cpp:484
static void CheckDli_imp(unsigned dliNotify, PDelayLoadInfo pdli, BOOL ErrorHandler)
Definition: delayimp.cpp:103
unsigned g_sfc_file[]
Definition: delayimp.cpp:402
static void SetExpectedDli(unsigned *order)
Definition: delayimp.cpp:96
const char * g_ExpectedDll
Definition: delayimp.cpp:52
size_t g_DliHookIndex
Definition: delayimp.cpp:93
PIMAGE_DATA_DIRECTORY delaydir
Definition: delayimp.cpp:446
unsigned * g_DliHookExpected
Definition: delayimp.cpp:92
PIMAGE_NT_HEADERS nt
Definition: delayimp.cpp:445
bool g_BypassMost
Definition: delayimp.cpp:49
static void CheckDliDone_imp()
Definition: delayimp.cpp:124
unsigned g_sfc_key[]
Definition: delayimp.cpp:401
#define LAST_DLI
Definition: delayimp.cpp:94
bool g_UsePointers
Definition: delayimp.cpp:386
HRESULT hr
Definition: delayimp.cpp:573
unsigned g_winmm_get_cur_task[]
Definition: delayimp.cpp:398
unsigned g_version_a[]
Definition: delayimp.cpp:403
unsigned g_winmm_mide_in_close[]
Definition: delayimp.cpp:400
#define WINMM_DLLNAME
Definition: delayimp.cpp:44
LONG ExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo, ULONG ExceptionCode)
Definition: delayimp.cpp:316
unsigned g_version_w[]
Definition: delayimp.cpp:404
bool g_ExceptionIsModule
Definition: delayimp.cpp:50
FARPROC WINAPI DliFailHook(unsigned dliNotify, PDelayLoadInfo pdli)
Definition: delayimp.cpp:267
unsigned g_imagehlp[]
Definition: delayimp.cpp:407
unsigned g_scard[]
Definition: delayimp.cpp:405
static HMODULE g_VersionDll
Definition: delayimp.cpp:155
INT_PTR WINAPI MyFunction()
Definition: delayimp.cpp:144
bool g_BrokenFunctionName
Definition: delayimp.cpp:48
BOOL WINAPI MySfcIsKeyProtected(HKEY KeyHandle, LPCWSTR SubKeyName, REGSAM KeySam)
Definition: delayimp.cpp:149
char g_Target[100]
Definition: delayimp.cpp:54
unsigned g_shlwapi[]
Definition: delayimp.cpp:406
bool g_ImportByName
Definition: delayimp.cpp:51
FARPROC WINAPI DliHook(unsigned dliNotify, PDelayLoadInfo pdli)
Definition: delayimp.cpp:156
PTR Rva2Addr(PIMAGE_DOS_HEADER dos, RVA rva)
Definition: delayimp.cpp:389
#define CheckDli
Definition: delayimp.cpp:139
const char * g_ExpectedName
Definition: delayimp.cpp:53
#define CheckDliDone
Definition: delayimp.cpp:140
DWORD err
Definition: delayimp.cpp:492
PARSEDURLA pua
Definition: delayimp.cpp:572
BOOL ret
Definition: delayimp.cpp:518
_SEH2_TRY
Definition: delayimp.cpp:502
@ dliNoteEndProcessing
Definition: delayimp.h:39
@ dliFailLoadLib
Definition: delayimp.h:37
@ dliNotePreGetProcAddress
Definition: delayimp.h:36
@ dliNotePreLoadLibrary
Definition: delayimp.h:35
@ dliFailGetProc
Definition: delayimp.h:38
@ dliStartProcessing
Definition: delayimp.h:34
struct DelayLoadInfo * PDelayLoadInfo
#define ExternC
Definition: delayimp.h:12
FARPROC(WINAPI * PfnDliHook)(unsigned, PDelayLoadInfo)
Definition: delayimp.h:77
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
int(* FARPROC)()
Definition: compat.h:36
DWORD RVA
Definition: compat.h:1262
#define GetProcAddress(x, y)
Definition: compat.h:753
DWORD WINAPI SymGetOptions(void)
Definition: dbghelp.c:600
BOOL WINAPI MapAndLoad(PCSTR pszImageName, PCSTR pszDllPath, PLOADED_IMAGE pLoadedImage, BOOL bDotDll, BOOL bReadOnly)
Definition: access.c:131
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:883
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HRESULT WINAPI ParseURLA(const char *url, PARSEDURLA *result)
Definition: path.c:2800
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:967
BOOL WINAPI GetFileVersionInfoA(LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:975
int CDECL tolower(int c)
Definition: ctype.c:572
int CDECL toupper(int c)
Definition: ctype.c:514
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
GLint GLvoid * img
Definition: gl.h:1956
const GLubyte * c
Definition: glext.h:8905
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const GLint * first
Definition: glext.h:5794
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
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
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define EXCEPTION_CONTINUE_EXECUTION
Definition: excpt.h:92
#define S_OK
Definition: intsafe.h:52
#define URL_E_INVALID_SYNTAX
Definition: intshcut.h:32
void __cdecl winetest_ok(int condition, const char *msg,...) __WINE_PRINTF_ATTR(2
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define sprintf
Definition: sprintf.c:45
BOOL expected
Definition: store.c:2000
IMAGE_DOS_HEADER dos
Definition: module.c:67
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4725
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1311
#define ERROR_SEVERITY_ERROR
Definition: ntbasedef.h:608
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT
Definition: ntimage.h:488
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:203
DWORD WINAPI mmGetCurrentTask(void)
Definition: winmm.c:2912
BOOL WINAPI SfcGetNextProtectedFile(HANDLE RpcHandle, PPROTECTED_FILE_DATA ProtFileData)
Definition: sfc_os.c:142
BOOL WINAPI SfcIsKeyProtected(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired)
Definition: sfc_os.c:117
HMODULE hmodCur
Definition: delayimp.h:72
DWORD cb
Definition: delayimp.h:67
FARPROC pfnCur
Definition: delayimp.h:73
LPCSTR szDll
Definition: delayimp.h:70
DelayLoadProc dlp
Definition: delayimp.h:71
FARPROC * ppfn
Definition: delayimp.h:69
DWORD dwLastError
Definition: delayimp.h:74
BOOL fImportByName
Definition: delayimp.h:57
DWORD dwOrdinal
Definition: delayimp.h:61
LPCSTR szProcName
Definition: delayimp.h:60
~UnProtect()
Definition: delayimp.cpp:80
UnProtect(PVOID addr)
Definition: delayimp.cpp:71
DWORD mProt
Definition: delayimp.cpp:88
PVOID mAddr
Definition: delayimp.cpp:87
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
Definition: ps.c:97
Definition: tools.h:99
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define GetModuleHandle
Definition: winbase.h:3576
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:321
UINT WINAPI mixerClose(HMIXER hMix)
Definition: winmm.c:386
UINT WINAPI midiOutClose(HMIDIOUT hMidiOut)
Definition: winmm.c:978
ACCESS_MASK REGSAM
Definition: winreg.h:76
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185