ReactOS  0.4.14-dev-49-gfb4591c
loader.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT : ReactOS system libraries
4  * MODULE : kernel32.dll
5  * FILE : reactos/dll/win32/kernel32/misc/ldr.c
6  * AUTHOR : Aleksey Bragin <aleksey@reactos.org>
7  */
8 
9 #include <k32.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 /* FUNCTIONS ****************************************************************/
15 
17 WINAPI
19 {
22 }
23 
24 DWORD
25 WINAPI
27  LPCWSTR lpwModuleName,
28  HMODULE *phModule)
29 {
30  /* Set phModule to 0 if it's not a NULL pointer */
31  if (phModule) *phModule = 0;
32 
33  /* Check for invalid flags combination */
34  if (dwFlags & ~(GET_MODULE_HANDLE_EX_FLAG_PIN |
35  GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
36  GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) ||
37  ((dwFlags & GET_MODULE_HANDLE_EX_FLAG_PIN) &&
38  (dwFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) ||
39  (!lpwModuleName && (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
40  )
41  {
44  }
45 
46  /* Check 2nd parameter */
47  if (!phModule)
48  {
51  }
52 
53  /* Return what we have according to the module name */
54  if (lpwModuleName)
55  {
57  }
58 
59  /* No name given, so put ImageBaseAddress there */
60  *phModule = (HMODULE)NtCurrentPeb()->ImageBaseAddress;
61 
63 }
64 
65 PVOID
66 WINAPI
68 {
69  /* If no handle is provided - use current image base address */
70  if (!hModule) return NtCurrentPeb()->ImageBaseAddress;
71 
72  /* Check if it's a normal or a datafile one */
73  if (LDR_IS_DATAFILE(hModule) && !AsDataFile)
74  return NULL;
75 
76  /* It's a normal DLL, just return its handle */
77  return hModule;
78 }
79 
80 /*
81  * @implemented
82  */
83 BOOL
84 WINAPI
87 {
89 
90  /* Disable thread library calls */
92 
93  /* If it wasn't success - set last error and return failure */
94  if (!NT_SUCCESS(Status))
95  {
97  return FALSE;
98  }
99 
100  /* Return success */
101  return TRUE;
102 }
103 
104 
105 /*
106  * @implemented
107  */
108 HINSTANCE
109 WINAPI
111 LoadLibraryA(LPCSTR lpLibFileName)
112 {
113  static const CHAR TwainDllName[] = "twain_32.dll";
114  LPSTR PathBuffer;
115  UINT Len;
117 
118  /* Treat twain_32.dll in a special way (what a surprise...) */
119  if (lpLibFileName && !_strcmpi(lpLibFileName, TwainDllName))
120  {
121  /* Allocate space for the buffer */
122  PathBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, MAX_PATH + sizeof(ANSI_NULL));
123  if (PathBuffer)
124  {
125  /* Get windows dir in this buffer */
126  Len = GetWindowsDirectoryA(PathBuffer, MAX_PATH);
127  if ((Len != 0) && (Len < (MAX_PATH - sizeof(TwainDllName) - sizeof('\\'))))
128  {
129  /* We successfully got windows directory. Concatenate twain_32.dll to it */
130  PathBuffer[Len] = '\\';
131  strcpy(&PathBuffer[Len + 1], TwainDllName);
132 
133  /* And recursively call ourselves with a new string */
134  Result = LoadLibraryA(PathBuffer);
135 
136  /* If it was successful - free memory and return result */
137  if (Result)
138  {
139  RtlFreeHeap(RtlGetProcessHeap(), 0, PathBuffer);
140  return Result;
141  }
142  }
143 
144  /* Free allocated buffer */
145  RtlFreeHeap(RtlGetProcessHeap(), 0, PathBuffer);
146  }
147  }
148 
149  /* Call the Ex version of the API */
150  return LoadLibraryExA(lpLibFileName, 0, 0);
151 }
152 
153 /*
154  * @implemented
155  */
156 HINSTANCE
157 WINAPI
159 LoadLibraryExA(LPCSTR lpLibFileName,
160  HANDLE hFile,
161  DWORD dwFlags)
162 {
163  PUNICODE_STRING FileNameW;
164 
165  /* Convert file name to unicode */
166  if (!(FileNameW = Basep8BitStringToStaticUnicodeString(lpLibFileName)))
167  return NULL;
168 
169  /* And call W version of the API */
170  return LoadLibraryExW(FileNameW->Buffer, hFile, dwFlags);
171 }
172 
173 /*
174  * @implemented
175  */
176 HINSTANCE
177 WINAPI
179 LoadLibraryW(LPCWSTR lpLibFileName)
180 {
181  /* Call Ex version of the API */
182  return LoadLibraryExW(lpLibFileName, 0, 0);
183 }
184 
185 
186 static
187 NTSTATUS
189 {
190  WCHAR FilenameW[MAX_PATH];
192  HANDLE hMapping;
194  PVOID lpBaseAddress = NULL;
195  SIZE_T ViewSize = 0;
196  //PUNICODE_STRING OriginalName;
197  //UNICODE_STRING dotDLL = RTL_CONSTANT_STRING(L".DLL");
198 
199  /* Zero out handle value */
200  *hModule = 0;
201 
202  DPRINT("BasepLoadLibraryAsDatafile(%S %S %p)\n", Path, Name, hModule);
203 
204  /*Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
205  Name,
206  &dotDLL,
207  RedirName,
208  RedirName2,
209  &OriginalName2,
210  NULL,
211  NULL,
212  NULL);*/
213 
214  /* Try to search for it */
215  if (!SearchPathW(Path,
216  Name,
217  L".DLL",
218  sizeof(FilenameW) / sizeof(FilenameW[0]),
219  FilenameW,
220  NULL))
221  {
222  /* Return last status value directly */
223  return NtCurrentTeb()->LastStatusValue;
224  }
225 
226  /* Open this file we found */
227  hFile = CreateFileW(FilenameW,
228  GENERIC_READ,
230  NULL,
232  0,
233  0);
234 
235  /* If opening failed - return last status value */
236  if (hFile == INVALID_HANDLE_VALUE) return NtCurrentTeb()->LastStatusValue;
237 
238  /* Create file mapping */
239  hMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
240 
241  /* Close the file handle */
243 
244  /* If creating file mapping failed - return last status value */
245  if (!hMapping) return NtCurrentTeb()->LastStatusValue;
246 
247  /* Map view of section */
248  Status = NtMapViewOfSection(hMapping,
250  &lpBaseAddress,
251  0,
252  0,
253  0,
254  &ViewSize,
255  ViewShare,
256  0,
257  PAGE_READONLY);
258 
259  /* Close handle to the section */
260  CloseHandle(hMapping);
261 
262  /* If mapping view of section failed - return last status value */
263  if (!NT_SUCCESS(Status)) return NtCurrentTeb()->LastStatusValue;
264 
265  /* Make sure it's a valid PE file */
266  if (!RtlImageNtHeader(lpBaseAddress))
267  {
268  /* Unmap the view and return failure status */
269  UnmapViewOfFile(lpBaseAddress);
271  }
272 
273  /* Set low bit of handle to indicate datafile module */
274  *hModule = (HMODULE)((ULONG_PTR)lpBaseAddress | 1);
275 
276  /* Load alternate resource module */
277  //LdrLoadAlternateResourceModule(*hModule, FilenameW);
278 
279  return STATUS_SUCCESS;
280 }
281 
282 /*
283  * @implemented
284  */
285 HINSTANCE
286 WINAPI
288 LoadLibraryExW(LPCWSTR lpLibFileName,
289  HANDLE hFile,
290  DWORD dwFlags)
291 {
292  UNICODE_STRING DllName;
296  ULONG DllCharacteristics = 0;
297  BOOL FreeString = FALSE;
298 
299  /* Check for any flags LdrLoadDll might be interested in */
301  {
302  /* Tell LDR to treat it as an EXE */
303  DllCharacteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
304  }
305 
306  /* Build up a unicode dll name from null-terminated string */
307  RtlInitUnicodeString(&DllName, (LPWSTR)lpLibFileName);
308 
309  /* Lazy-initialize BasepExeLdrEntry */
310  if (!BasepExeLdrEntry)
312 
313  /* Check if that module is our exe*/
316  {
317  /* Lengths match and it's not a datafile, so perform name comparison */
319  {
320  /* That's us! */
321  return BasepExeLdrEntry->DllBase;
322  }
323  }
324 
325  /* Check for trailing spaces and remove them if necessary */
326  if (DllName.Buffer[DllName.Length/sizeof(WCHAR) - 1] == L' ')
327  {
328  RtlCreateUnicodeString(&DllName, (LPWSTR)lpLibFileName);
329  while (DllName.Length > sizeof(WCHAR) &&
330  DllName.Buffer[DllName.Length/sizeof(WCHAR) - 1] == L' ')
331  {
332  DllName.Length -= sizeof(WCHAR);
333  }
334  DllName.Buffer[DllName.Length/sizeof(WCHAR)] = UNICODE_NULL;
335  FreeString = TRUE;
336  }
337 
338  /* Compute the load path */
340  DllName.Buffer : NULL,
341  NULL);
342  if (!SearchPath)
343  {
344  /* Getting DLL path failed, so set last error, free mem and return */
346  if (FreeString) RtlFreeUnicodeString(&DllName);
347  return NULL;
348  }
349 
350  _SEH2_TRY
351  {
353  {
354  /* If the image is loaded as a datafile, try to get its handle */
355  Status = LdrGetDllHandleEx(0, SearchPath, NULL, &DllName, (PVOID*)&hInst);
356  if (!NT_SUCCESS(Status))
357  {
358  /* It's not loaded yet - so load it up */
360  }
361  _SEH2_YIELD(goto done;)
362  }
363 
364  /* Call the API Properly */
366  &DllCharacteristics,
367  &DllName,
368  (PVOID*)&hInst);
369  }
371  {
373  } _SEH2_END;
374 
375 
376 done:
377  /* Free SearchPath buffer */
378  RtlFreeHeap(RtlGetProcessHeap(), 0, SearchPath);
379 
380  /* Free DllName string if it was dynamically allocated */
381  if (FreeString) RtlFreeUnicodeString(&DllName);
382 
383  /* Set last error in failure case */
384  if (!NT_SUCCESS(Status))
385  {
386  DPRINT1("LoadLibraryExW(%ls) failing with status %lx\n", lpLibFileName, Status);
388  return NULL;
389  }
390 
391  /* Return loaded module handle */
392  return hInst;
393 }
394 
395 
396 /*
397  * @implemented
398  */
399 FARPROC
400 WINAPI
402 {
403  ANSI_STRING ProcedureName, *ProcNamePtr = NULL;
404  FARPROC fnExp = NULL;
406  PVOID hMapped;
407  ULONG Ordinal = 0;
408 
409  if ((ULONG_PTR)lpProcName > MAXUSHORT)
410  {
411  /* Look up by name */
412  RtlInitAnsiString(&ProcedureName, (LPSTR)lpProcName);
413  ProcNamePtr = &ProcedureName;
414  }
415  else
416  {
417  /* Look up by ordinal */
418  Ordinal = PtrToUlong(lpProcName);
419  }
420 
421  /* Map provided handle */
422  hMapped = BasepMapModuleHandle(hModule, FALSE);
423 
424  /* Get the proc address */
425  Status = LdrGetProcedureAddress(hMapped,
426  ProcNamePtr,
427  Ordinal,
428  (PVOID*)&fnExp);
429 
430  if (!NT_SUCCESS(Status))
431  {
433  return NULL;
434  }
435 
436  /* Check for a special case when returned pointer is
437  the same as image's base address */
438  if (fnExp == hMapped)
439  {
440  /* Set correct error code */
441  if (HIWORD(lpProcName) != 0)
443  else
445 
446  return NULL;
447  }
448 
449  /* All good, return procedure pointer */
450  return fnExp;
451 }
452 
453 
454 /*
455  * @implemented
456  */
457 BOOL
458 WINAPI
461 {
463  PIMAGE_NT_HEADERS NtHeaders;
464 
466  {
467  // FIXME: This SEH should go inside RtlImageNtHeader instead
468  // See https://jira.reactos.org/browse/CORE-14857
469  _SEH2_TRY
470  {
471  /* This is a LOAD_LIBRARY_AS_DATAFILE module, check if it's a valid one */
472  NtHeaders = RtlImageNtHeader((PVOID)((ULONG_PTR)hLibModule & ~1));
473  }
475  {
476  NtHeaders = NULL;
477  } _SEH2_END
478 
479  if (NtHeaders)
480  {
481  /* Unmap view */
483 
484  /* Unload alternate resource module */
486  }
487  else
489  }
490  else
491  {
492  /* Just unload it */
494  }
495 
496  /* Check what kind of status we got */
497  if (!NT_SUCCESS(Status))
498  {
499  /* Set last error */
501 
502  /* Return failure */
503  return FALSE;
504  }
505 
506  /* Return success */
507  return TRUE;
508 }
509 
510 
511 /*
512  * @implemented
513  */
514 VOID
515 WINAPI
517  DWORD dwExitCode)
518 {
519 
521  {
522  /* This is a LOAD_LIBRARY_AS_DATAFILE module */
524  {
525  /* Unmap view */
527 
528  /* Unload alternate resource module */
530  }
531  }
532  else
533  {
534  /* Just unload it */
536  }
537 
538  /* Exit thread */
539  ExitThread(dwExitCode);
540 }
541 
542 
543 /*
544  * @implemented
545  */
546 DWORD
547 WINAPI
549  LPSTR lpFilename,
550  DWORD nSize)
551 {
552  UNICODE_STRING FilenameW;
553  ANSI_STRING FilenameA;
555  DWORD Length = 0, LengthToCopy;
556 
557  /* Allocate a unicode buffer */
558  FilenameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, nSize * sizeof(WCHAR));
559  if (!FilenameW.Buffer)
560  {
562  return 0;
563  }
564 
565  /* Call unicode API */
566  FilenameW.Length = (USHORT)GetModuleFileNameW(hModule, FilenameW.Buffer, nSize) * sizeof(WCHAR);
567  FilenameW.MaximumLength = FilenameW.Length + sizeof(WCHAR);
568 
569  if (FilenameW.Length)
570  {
571  /* Convert to ansi string */
572  Status = BasepUnicodeStringTo8BitString(&FilenameA, &FilenameW, TRUE);
573  if (!NT_SUCCESS(Status))
574  {
575  /* Set last error, free string and return failure */
577  RtlFreeUnicodeString(&FilenameW);
578  return 0;
579  }
580 
581  /* Calculate size to copy */
582  Length = min(nSize, FilenameA.Length);
583 
584  /* Include terminating zero */
585  if (nSize > Length)
586  LengthToCopy = Length + 1;
587  else
588  LengthToCopy = nSize;
589 
590  /* Now copy back to the caller amount he asked */
591  RtlMoveMemory(lpFilename, FilenameA.Buffer, LengthToCopy);
592 
593  /* Free ansi filename */
594  RtlFreeAnsiString(&FilenameA);
595  }
596 
597  /* Free unicode filename */
598  RtlFreeHeap(RtlGetProcessHeap(), 0, FilenameW.Buffer);
599 
600  /* Return length copied */
601  return Length;
602 }
603 
604 /*
605  * @implemented
606  */
607 DWORD
608 WINAPI
610  LPWSTR lpFilename,
611  DWORD nSize)
612 {
614  PLDR_DATA_TABLE_ENTRY Module;
615  ULONG Length = 0;
617  PPEB Peb;
618 
620 
621  /* Upscale nSize from chars to bytes */
622  nSize *= sizeof(WCHAR);
623 
624  _SEH2_TRY
625  {
626  /* We don't use per-thread cur dir now */
627  //PRTL_PERTHREAD_CURDIR PerThreadCurdir = (PRTL_PERTHREAD_CURDIR)teb->NtTib.SubSystemTib;
628 
629  Peb = NtCurrentPeb ();
630 
631  /* Acquire a loader lock */
633 
634  /* Traverse the module list */
637  while (Entry != ModuleListHead)
638  {
639  Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
640 
641  /* Check if this is the requested module */
642  if (Module->DllBase == (PVOID)hModule)
643  {
644  /* Calculate size to copy */
646 
647  /* Copy contents */
648  RtlMoveMemory(lpFilename, Module->FullDllName.Buffer, Length);
649 
650  /* Subtract a terminating zero */
651  if (Length == Module->FullDllName.MaximumLength)
652  Length -= sizeof(WCHAR);
653 
654  /* Break out of the loop */
655  break;
656  }
657 
658  /* Advance to the next entry */
659  Entry = Entry->Flink;
660  }
661  }
663  {
665  Length = 0;
666  } _SEH2_END
667 
668  /* Release the loader lock */
670 
671  return Length / sizeof(WCHAR);
672 }
673 
674 HMODULE
675 WINAPI
677 {
679  PVOID Module;
680  LPWSTR DllPath;
681 
682  /* Try to get a handle with a magic value of 1 for DllPath */
683  Status = LdrGetDllHandle((LPWSTR)1, NULL, ModuleName, &Module);
684 
685  /* If that succeeded - we're done */
686  if (NT_SUCCESS(Status)) return Module;
687 
688  /* If not, then the path should be computed */
690  if (!DllPath)
691  {
693  }
694  else
695  {
696  _SEH2_TRY
697  {
699  }
701  {
702  /* Fail with the SEH error */
704  }
705  _SEH2_END;
706  }
707 
708  /* Free the DllPath */
709  RtlFreeHeap(RtlGetProcessHeap(), 0, DllPath);
710 
711  /* In case of error set last win32 error and return NULL */
712  if (!NT_SUCCESS(Status))
713  {
714  DPRINT("Failure acquiring DLL module '%wZ' handle, Status 0x%08X\n", ModuleName, Status);
716  Module = 0;
717  }
718 
719  /* Return module */
720  return (HMODULE)Module;
721 }
722 
723 BOOLEAN
724 WINAPI
725 BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName, HMODULE *phModule)
726 {
728  NTSTATUS Status = STATUS_SUCCESS, Status2;
729  HANDLE hModule = NULL;
730  UNICODE_STRING ModuleNameU;
731  DWORD dwValid;
732  BOOLEAN Redirected = FALSE; // FIXME
733 
734  /* Validate parameters */
735  dwValid = BasepGetModuleHandleExParameterValidation(dwPublicFlags, lpwModuleName, phModule);
737 
738  /* Acquire lock if necessary */
739  if (!NoLock)
740  {
742  if (!NT_SUCCESS(Status))
743  {
744  /* Fail */
746  if (phModule) *phModule = NULL;
747  return NT_SUCCESS(Status);
748  }
749  }
750 
751  if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
752  {
753  /* Create a unicode string out of module name */
754  RtlInitUnicodeString(&ModuleNameU, lpwModuleName);
755 
756  // FIXME: Do some redirected DLL stuff?
757  if (Redirected)
758  {
760  }
761 
762  if (!hModule)
763  {
765  if (!hModule)
766  {
767  /* Last error is already set, so just return failure by setting status */
769  goto quickie;
770  }
771  }
772  }
773  else
774  {
775  /* Perform Pc to file header to get module instance */
776  hModule = (HMODULE)RtlPcToFileHeader((PVOID)lpwModuleName,
777  (PVOID*)&hModule);
778 
779  /* Check if it succeeded */
780  if (!hModule)
781  {
782  /* Set "dll not found" status and quit */
784  goto quickie;
785  }
786  }
787 
788  /* Check if changing reference is not forbidden */
789  if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
790  {
791  /* Add reference to this DLL */
792  Status = LdrAddRefDll((dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_PIN) ? LDR_ADDREF_DLL_PIN : 0,
793  hModule);
794  }
795 
796 quickie:
797  /* Set last error in case of failure */
798  if (!NT_SUCCESS(Status))
800 
801  /* Unlock loader lock if it was acquired */
802  if (!NoLock)
803  {
804  Status2 = LdrUnlockLoaderLock(0, Cookie);
805  ASSERT(NT_SUCCESS(Status2));
806  }
807 
808  /* Set the module handle to the caller */
809  if (phModule) *phModule = hModule;
810 
811  /* Return TRUE on success and FALSE otherwise */
812  return NT_SUCCESS(Status);
813 }
814 
815 /*
816  * @implemented
817  */
818 HMODULE
819 WINAPI
822 {
823  PUNICODE_STRING ModuleNameW;
824  PTEB pTeb = NtCurrentTeb();
825 
826  /* Check if we have no name to convert */
827  if (!lpModuleName)
829 
830  /* Convert module name to unicode */
831  ModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName);
832 
833  /* Call W version if conversion was successful */
834  if (ModuleNameW)
835  return GetModuleHandleW(ModuleNameW->Buffer);
836 
837  /* Return failure */
838  return 0;
839 }
840 
841 
842 /*
843  * @implemented
844  */
845 HMODULE
846 WINAPI
848 {
851 
852  /* If current module is requested - return it right away */
853  if (!lpModuleName)
854  return ((HMODULE)NtCurrentPeb()->ImageBaseAddress);
855 
856  /* Use common helper routine */
858  GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
859  lpModuleName,
860  &hModule);
861 
862  /* If it wasn't successful - return NULL */
863  if (!Success) hModule = NULL;
864 
865  /* Return the handle */
866  return hModule;
867 }
868 
869 
870 /*
871  * @implemented
872  */
873 BOOL
874 WINAPI
876  IN LPCWSTR lpwModuleName OPTIONAL,
877  OUT HMODULE* phModule)
878 {
879  DWORD dwValid;
880  BOOL Ret;
881 
882  /* Validate parameters */
883  dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, lpwModuleName, phModule);
884 
885  /* If result is invalid parameter - return failure */
887 
888  /* If result is 2, there is no need to do anything - return success. */
890 
891  /* Use common helper routine */
893  dwFlags,
894  lpwModuleName,
895  phModule);
896 
897  return Ret;
898 }
899 
900 /*
901  * @implemented
902  */
903 BOOL
904 WINAPI
906  IN LPCSTR lpModuleName OPTIONAL,
907  OUT HMODULE* phModule)
908 {
909  PUNICODE_STRING lpModuleNameW;
910  DWORD dwValid;
911  BOOL Ret;
912 
913  /* Validate parameters */
914  dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, (LPCWSTR)lpModuleName, phModule);
915 
916  /* If result is invalid parameter - return failure */
918 
919  /* If result is 2, there is no need to do anything - return success. */
921 
922  /* Check if we don't need to convert the name */
923  if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
924  {
925  /* Call the extended version of the API without conversion */
927  dwFlags,
928  (LPCWSTR)lpModuleName,
929  phModule);
930  }
931  else
932  {
933  /* Convert module name to unicode */
934  lpModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName);
935 
936  /* Return FALSE if conversion failed */
937  if (!lpModuleNameW) return FALSE;
938 
939  /* Call the extended version of the API */
941  dwFlags,
942  lpModuleNameW->Buffer,
943  phModule);
944  }
945 
946  /* Return result */
947  return Ret;
948 }
949 
950 
951 /*
952  * @implemented
953  */
954 DWORD
955 WINAPI
956 LoadModule(LPCSTR lpModuleName,
957  LPVOID lpParameterBlock)
958 {
959  STARTUPINFOA StartupInfo;
960  PROCESS_INFORMATION ProcessInformation;
961  LOADPARMS32 *LoadParams;
962  char FileName[MAX_PATH];
963  LPSTR CommandLine;
964  DWORD Length, Error;
965  BOOL ProcessStatus;
966  ANSI_STRING AnsiStr;
967  UNICODE_STRING UnicStr;
969  HANDLE Handle;
970 
971  LoadParams = (LOADPARMS32*)lpParameterBlock;
972 
973  /* Check load parameters */
974  if (LoadParams->dwReserved || LoadParams->wMagicValue != 2)
975  {
976  /* Fail with invalid param error */
978  return 0;
979  }
980 
981  /* Search path */
982  Length = SearchPathA(NULL, lpModuleName, ".exe", MAX_PATH, FileName, NULL);
983 
984  /* Check if path was found */
985  if (Length && Length < MAX_PATH)
986  {
987  /* Build StartupInfo */
988  RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
989 
990  StartupInfo.cb = sizeof(STARTUPINFOA);
991  StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
992  StartupInfo.wShowWindow = LoadParams->wCmdShow;
993 
994  /* Allocate command line buffer */
995  CommandLine = RtlAllocateHeap(RtlGetProcessHeap(),
997  (ULONG)LoadParams->lpCmdLine[0] + Length + 2);
998 
999  /* Put module name there, then a space, and then copy provided command line,
1000  and null-terminate it */
1001  RtlCopyMemory(CommandLine, FileName, Length);
1002  CommandLine[Length] = ' ';
1003  RtlCopyMemory(&CommandLine[Length + 1], &LoadParams->lpCmdLine[1], (ULONG)LoadParams->lpCmdLine[0]);
1004  CommandLine[Length + 1 + (ULONG)LoadParams->lpCmdLine[0]] = 0;
1005 
1006  /* Create the process */
1007  ProcessStatus = CreateProcessA(FileName,
1008  CommandLine,
1009  NULL,
1010  NULL,
1011  FALSE,
1012  0,
1013  LoadParams->lpEnvAddress,
1014  NULL,
1015  &StartupInfo,
1016  &ProcessInformation);
1017 
1018  /* Free the command line buffer */
1019  RtlFreeHeap(RtlGetProcessHeap(), 0, CommandLine);
1020 
1021  if (!ProcessStatus)
1022  {
1023  /* Creating process failed, return right error code */
1024  Error = GetLastError();
1025  switch(Error)
1026  {
1027  case ERROR_BAD_EXE_FORMAT:
1028  return ERROR_BAD_FORMAT;
1029 
1030  case ERROR_FILE_NOT_FOUND:
1031  case ERROR_PATH_NOT_FOUND:
1032  return Error;
1033  }
1034 
1035  /* Return 0 otherwise */
1036  return 0;
1037  }
1038 
1039  /* Wait up to 30 seconds for the process to become idle */
1041  {
1042  UserWaitForInputIdleRoutine(ProcessInformation.hProcess, 30000);
1043  }
1044 
1045  /* Close handles */
1046  NtClose(ProcessInformation.hThread);
1047  NtClose(ProcessInformation.hProcess);
1048 
1049  /* Return magic success value (33) */
1050  return 33;
1051  }
1052 
1053  /* The path was not found, create an ansi string from
1054  the module name and convert it to unicode */
1055  RtlInitAnsiString(&AnsiStr, lpModuleName);
1056  if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(&UnicStr,&AnsiStr,TRUE)))
1057  return ERROR_FILE_NOT_FOUND;
1058 
1059  /* Determine path type */
1061 
1062  /* Free the unicode module name */
1063  RtlFreeUnicodeString(&UnicStr);
1064 
1065  /* If it's a relative path, return file not found */
1067  return ERROR_FILE_NOT_FOUND;
1068 
1069  /* If not, try to open it */
1070  Handle = CreateFile(lpModuleName,
1071  GENERIC_READ,
1073  NULL,
1074  OPEN_EXISTING,
1076  NULL);
1077 
1079  {
1080  /* Opening file succeeded for some reason, close the handle and return file not found anyway */
1082  return ERROR_FILE_NOT_FOUND;
1083  }
1084 
1085  /* Return last error which CreateFile set during an attempt to open it */
1086  return GetLastError();
1087 }
1088 
1089 /*
1090  * @unimplemented
1091  */
1093 {
1094  STUB;
1095  return NULL;
1096 }
1097 
1098 /*
1099  * @unimplemented
1100  */
1102  LPSTR lpszInitName, LPSTR lpszProcName,
1103  FARPROC *ppfn32Thunk, FARPROC pfnUT32CallBack,
1104  LPVOID lpBuff )
1105 {
1106  STUB;
1107  return 0;
1108 }
1109 
1110 /*
1111  * @unimplemented
1112  */
1114 {
1115  STUB;
1116 }
1117 
1118 /*
1119  * @unimplemented
1120  */
1121 BOOL
1122 WINAPI
1124  IN LPSTR Unknown,
1125  IN PVOID Unknown2,
1126  IN PVOID Unknown3,
1127  IN PVOID Unknown4)
1128 {
1129  DPRINT1("BaseQueryModuleData called: %s %s %p %p %p\n",
1130  ModuleName,
1131  Unknown,
1132  Unknown2,
1133  Unknown3,
1134  Unknown4);
1135  return FALSE;
1136 }
1137 
1138 /*
1139  * @implemented
1140  */
1141 NTSTATUS
1142 WINAPI
1144 {
1145  DPRINT("Post-init called\n");
1146 
1147  /* Check if this is a terminal server */
1148  if (SharedUserData->SuiteMask & VER_SUITE_TERMINAL)
1149  {
1150  /* Initialize TS pointers */
1151  return BasepInitializeTermsrvFpns();
1152  }
1153 
1154  /* FIXME: Initialize TS pointers */
1155  return STATUS_SUCCESS;
1156 }
1157 
1158 /* EOF */
#define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS
Definition: ldrtypes.h:76
struct _STARTUPINFOA STARTUPINFOA
#define ERROR_BAD_FORMAT
Definition: winerror.h:114
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
enum _RTL_PATH_TYPE RTL_PATH_TYPE
NTSTATUS NTAPI LdrGetDllHandleEx(IN ULONG Flags, IN PWSTR DllPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *DllHandle OPTIONAL)
Definition: ldrapi.c:522
#define IN
Definition: typedefs.h:38
HINSTANCE hLibModule
Definition: sfc.c:23
PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString(IN LPCSTR String)
Definition: utils.c:188
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryW(LPCWSTR lpLibFileName)
Definition: loader.c:179
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3782
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:398
NTSTATUS NTAPI LdrGetDllHandle(IN PWSTR DllPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *DllHandle)
Definition: ldrapi.c:805
PPEB Peb
Definition: dllmain.c:27
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:35
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR
Definition: kernel32.h:107
BOOLEAN WINAPI BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName, HMODULE *phModule)
Definition: loader.c:725
struct _Entry Entry
Definition: kefuncs.h:640
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
NTSTATUS NTAPI LdrUnlockLoaderLock(IN ULONG Flags, IN ULONG Cookie OPTIONAL)
Definition: ldrapi.c:101
USHORT MaximumLength
Definition: env_spec_w32.h:370
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:120
PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString
Definition: utils.c:27
LPSTR lpCmdLine
Definition: kernel32.h:74
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LPSTR lpEnvAddress
Definition: kernel32.h:73
uint16_t * PWSTR
Definition: typedefs.h:54
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
char CHAR
Definition: xmlstorage.h:175
NTSTATUS NTAPI LdrAddRefDll(IN ULONG Flags, IN PVOID BaseAddress)
Definition: ldrapi.c:1237
#define LDR_IS_DATAFILE(handle)
Definition: ldrtypes.h:103
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2024
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI UTRegister(HMODULE hModule, LPSTR lpsz16BITDLL, LPSTR lpszInitName, LPSTR lpszProcName, FARPROC *ppfn32Thunk, FARPROC pfnUT32CallBack, LPVOID lpBuff)
Definition: loader.c:1101
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSTATUS NTAPI LdrLockLoaderLock(IN ULONG Flags, OUT PULONG Disposition OPTIONAL, OUT PULONG_PTR Cookie OPTIONAL)
Definition: ldrapi.c:173
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD dwFlags
Definition: winbase.h:807
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1264
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:339
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define VER_SUITE_TERMINAL
PVOID NTAPI RtlPcToFileHeader(IN PVOID PcValue, PVOID *BaseOfImage)
Definition: libsupp.c:616
char * LPSTR
Definition: xmlstorage.h:182
WORD wMagicValue
Definition: kernel32.h:75
NTSTATUS WINAPI BasepInitializeTermsrvFpns(VOID)
Definition: loader.c:18
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
#define FILE_SHARE_READ
Definition: compat.h:125
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define SearchPath
Definition: winbase.h:3717
_SEH2_TRY
Definition: create.c:4250
VOID WINAPI UTUnRegister(HMODULE hModule)
Definition: loader.c:1113
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:516
PVOID DllBase
Definition: btrfs_drv.h:1784
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
static IN ULONG IN PWSTR OUT PCWSTR OUT PBOOLEAN OUT PATH_TYPE_AND_UNKNOWN * PathType
FARPROC WINAPI DelayLoadFailureHook(LPCSTR pszDllName, LPCSTR pszProcName)
Definition: loader.c:1092
#define UNICODE_NULL
#define ANSI_NULL
DWORD WINAPI SearchPathA(IN LPCSTR lpPath OPTIONAL, IN LPCSTR lpFileName, IN LPCSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart OPTIONAL)
Definition: path.c:1122
unsigned int BOOL
Definition: ntddk_ex.h:94
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HMODULE WINAPI GetModuleHandleForUnicodeString(PUNICODE_STRING ModuleName)
Definition: loader.c:676
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3554
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID BaseAddress, IN PANSI_STRING Name, IN ULONG Ordinal, OUT PVOID *ProcedureAddress)
Definition: ldrapi.c:823
unsigned char BOOLEAN
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void DPRINT(...)
Definition: polytest.cpp:61
WaitForInputIdleType UserWaitForInputIdleRoutine
Definition: proc.c:20
static const OBJECT_ATTRIBUTES const LARGE_INTEGER ULONG
Definition: loader.c:57
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
const char * LPCSTR
Definition: xmlstorage.h:183
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry
Definition: proc.c:25
#define OPEN_EXISTING
Definition: compat.h:426
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define PtrToUlong(u)
Definition: config.h:107
#define NtCurrentProcess()
Definition: nt_native.h:1657
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
BOOLEAN NTAPI LdrUnloadAlternateResourceModule(IN PVOID BaseAddress)
Definition: ldrapi.c:1630
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
DWORD cb
Definition: winbase.h:796
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:345
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4742
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:13
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
unsigned long DWORD
Definition: ntddk_ex.h:95
FARPROC WINAPI GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
Definition: loader.c:401
#define Len
Definition: deflate.h:82
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
BOOL Error
Definition: chkdsk.c:66
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOL WINAPI BaseQueryModuleData(IN LPSTR ModuleName, IN LPSTR Unknown, IN PVOID Unknown2, IN PVOID Unknown3, IN PVOID Unknown4)
Definition: loader.c:1123
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DONT_RESOLVE_DLL_REFERENCES
Definition: winbase.h:337
#define SharedUserData
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:905
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
Definition: btrfs_drv.h:1780
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(IN PWSTR SearchPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *BaseAddress)
Definition: ldrapi.c:310
static NTSTATUS BasepLoadLibraryAsDatafile(PWSTR Path, LPCWSTR Name, HMODULE *hModule)
Definition: loader.c:188
#define GENERIC_READ
Definition: compat.h:124
Definition: typedefs.h:117
NTSTATUS NTAPI LdrEnumerateLoadedModules(IN BOOLEAN ReservedFlag, IN PLDR_ENUM_CALLBACK EnumProc, IN PVOID Context)
Definition: ldrapi.c:1120
VOID NTAPI BasepLocateExeLdrEntry(IN PLDR_DATA_TABLE_ENTRY Entry, IN PVOID Context, OUT BOOLEAN *StopEnumeration)
Definition: utils.c:156
_In_ HANDLE hFile
Definition: mswsock.h:90
WORD wCmdShow
Definition: kernel32.h:76
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1297
Status
Definition: gdiplustypes.h:24
NTSTATUS WINAPI BaseProcessInitPostImport(VOID)
Definition: loader.c:1143
NTSTATUS NTAPI LdrDisableThreadCalloutsForDll(IN PVOID BaseAddress)
Definition: ldrapi.c:1187
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define STATUS_ORDINAL_NOT_FOUND
Definition: ntstatus.h:534
HANDLE HMODULE
Definition: typedefs.h:75
DWORD WINAPI BasepGetModuleHandleExParameterValidation(DWORD dwFlags, LPCWSTR lpwModuleName, HMODULE *phModule)
Definition: loader.c:26
LPWSTR WINAPI BaseComputeProcessDllPath(IN LPWSTR FullPath, IN PVOID Environment)
Definition: path.c:420
ULONG_PTR SIZE_T
Definition: typedefs.h:78
Definition: compat.h:484
NTSTATUS NTAPI LdrUnloadDll(IN PVOID BaseAddress)
Definition: ldrapi.c:1322
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:875
_SEH2_END
Definition: create.c:4424
HINSTANCE hInst
Definition: dxdiag.c:13
PRTL_UNICODE_STRING_BUFFER Path
BOOL WINAPI DECLSPEC_HOTPATCH FreeLibrary(HINSTANCE hLibModule)
Definition: loader.c:460
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define NtCurrentPeb()
Definition: FLS.c:20
#define STUB
Definition: kernel32.h:27
unsigned short USHORT
Definition: pedump.c:61
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS
Definition: kernel32.h:108
#define STATUS_DLL_NOT_FOUND
Definition: ntstatus.h:531
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
static const char const char * DllPath
Definition: image.c:34
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1816
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1786
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
WORD wShowWindow
Definition: winbase.h:808
#define PAGE_READONLY
Definition: compat.h:127
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MAXUSHORT
Definition: typedefs.h:81
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:457
#define CreateFileW
Definition: compat.h:400
DWORD WINAPI LoadModule(LPCSTR lpModuleName, LPVOID lpParameterBlock)
Definition: loader.c:956
#define STATUS_ENTRYPOINT_NOT_FOUND
Definition: ntstatus.h:535
#define OUT
Definition: typedefs.h:39
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
#define LDR_ADDREF_DLL_PIN
Definition: ldrtypes.h:71
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
char * pszDllName
Definition: spec2def.c:72
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Check_return_ _CRTIMP int __cdecl _strcmpi(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define UnmapViewOfFile
Definition: compat.h:403
DWORD dwReserved
Definition: kernel32.h:77
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
LIST_ENTRY * ModuleListHead
Definition: kdpacket.c:23
base of all file and directory entries
Definition: entries.h:82
int(* FARPROC)()
Definition: compat.h:28
PVOID WINAPI BasepMapModuleHandle(HMODULE hModule, BOOLEAN AsDataFile)
Definition: loader.c:67
HMODULE hModule
Definition: animate.c:44
NTSYSAPI RTL_PATH_TYPE NTAPI RtlDetermineDosPathNameType_U(_In_ PCWSTR Path)
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE
Definition: kernel32.h:109
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68