ReactOS  0.4.15-dev-1397-g19779b3
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  /* This is a LOAD_LIBRARY_AS_DATAFILE module, check if it's a valid one */
468  NtHeaders = RtlImageNtHeader((PVOID)((ULONG_PTR)hLibModule & ~1));
469 
470  if (NtHeaders)
471  {
472  /* Unmap view */
474 
475  /* Unload alternate resource module */
477  }
478  else
480  }
481  else
482  {
483  /* Just unload it */
485  }
486 
487  /* Check what kind of status we got */
488  if (!NT_SUCCESS(Status))
489  {
490  /* Set last error */
492 
493  /* Return failure */
494  return FALSE;
495  }
496 
497  /* Return success */
498  return TRUE;
499 }
500 
501 
502 /*
503  * @implemented
504  */
505 VOID
506 WINAPI
508  DWORD dwExitCode)
509 {
510 
512  {
513  /* This is a LOAD_LIBRARY_AS_DATAFILE module */
515  {
516  /* Unmap view */
518 
519  /* Unload alternate resource module */
521  }
522  }
523  else
524  {
525  /* Just unload it */
527  }
528 
529  /* Exit thread */
530  ExitThread(dwExitCode);
531 }
532 
533 
534 /*
535  * @implemented
536  */
537 DWORD
538 WINAPI
540  LPSTR lpFilename,
541  DWORD nSize)
542 {
543  UNICODE_STRING FilenameW;
544  ANSI_STRING FilenameA;
546  DWORD Length = 0, LengthToCopy;
547 
548  /* Allocate a unicode buffer */
549  FilenameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, nSize * sizeof(WCHAR));
550  if (!FilenameW.Buffer)
551  {
553  return 0;
554  }
555 
556  /* Call unicode API */
557  FilenameW.Length = (USHORT)GetModuleFileNameW(hModule, FilenameW.Buffer, nSize) * sizeof(WCHAR);
558  FilenameW.MaximumLength = FilenameW.Length + sizeof(WCHAR);
559 
560  if (FilenameW.Length)
561  {
562  /* Convert to ansi string */
563  Status = BasepUnicodeStringTo8BitString(&FilenameA, &FilenameW, TRUE);
564  if (!NT_SUCCESS(Status))
565  {
566  /* Set last error, free string and return failure */
568  RtlFreeUnicodeString(&FilenameW);
569  return 0;
570  }
571 
572  /* Calculate size to copy */
573  Length = min(nSize, FilenameA.Length);
574 
575  /* Include terminating zero */
576  if (nSize > Length)
577  LengthToCopy = Length + 1;
578  else
579  LengthToCopy = nSize;
580 
581  /* Now copy back to the caller amount he asked */
582  RtlMoveMemory(lpFilename, FilenameA.Buffer, LengthToCopy);
583 
584  /* Free ansi filename */
585  RtlFreeAnsiString(&FilenameA);
586  }
587 
588  /* Free unicode filename */
589  RtlFreeHeap(RtlGetProcessHeap(), 0, FilenameW.Buffer);
590 
591  /* Return length copied */
592  return Length;
593 }
594 
595 /*
596  * @implemented
597  */
598 DWORD
599 WINAPI
601  LPWSTR lpFilename,
602  DWORD nSize)
603 {
605  PLDR_DATA_TABLE_ENTRY Module;
606  ULONG Length = 0;
608  PPEB Peb;
609 
611 
612  /* Upscale nSize from chars to bytes */
613  nSize *= sizeof(WCHAR);
614 
615  _SEH2_TRY
616  {
617  /* We don't use per-thread cur dir now */
618  //PRTL_PERTHREAD_CURDIR PerThreadCurdir = (PRTL_PERTHREAD_CURDIR)teb->NtTib.SubSystemTib;
619 
620  Peb = NtCurrentPeb ();
621 
622  /* Acquire a loader lock */
624 
625  /* Traverse the module list */
628  while (Entry != ModuleListHead)
629  {
630  Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
631 
632  /* Check if this is the requested module */
633  if (Module->DllBase == (PVOID)hModule)
634  {
635  /* Calculate size to copy */
637 
638  /* Copy contents */
639  RtlMoveMemory(lpFilename, Module->FullDllName.Buffer, Length);
640 
641  /* Subtract a terminating zero */
642  if (Length == Module->FullDllName.MaximumLength)
643  Length -= sizeof(WCHAR);
644 
645  /* Break out of the loop */
646  break;
647  }
648 
649  /* Advance to the next entry */
650  Entry = Entry->Flink;
651  }
652  }
654  {
656  Length = 0;
657  } _SEH2_END
658 
659  /* Release the loader lock */
661 
662  return Length / sizeof(WCHAR);
663 }
664 
665 HMODULE
666 WINAPI
668 {
670  PVOID Module;
671  LPWSTR DllPath;
672 
673  /* Try to get a handle with a magic value of 1 for DllPath */
674  Status = LdrGetDllHandle((LPWSTR)1, NULL, ModuleName, &Module);
675 
676  /* If that succeeded - we're done */
677  if (NT_SUCCESS(Status)) return Module;
678 
679  /* If not, then the path should be computed */
681  if (!DllPath)
682  {
684  }
685  else
686  {
687  _SEH2_TRY
688  {
690  }
692  {
693  /* Fail with the SEH error */
695  }
696  _SEH2_END;
697  }
698 
699  /* Free the DllPath */
700  RtlFreeHeap(RtlGetProcessHeap(), 0, DllPath);
701 
702  /* In case of error set last win32 error and return NULL */
703  if (!NT_SUCCESS(Status))
704  {
705  DPRINT("Failure acquiring DLL module '%wZ' handle, Status 0x%08X\n", ModuleName, Status);
707  Module = 0;
708  }
709 
710  /* Return module */
711  return (HMODULE)Module;
712 }
713 
714 BOOLEAN
715 WINAPI
716 BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName, HMODULE *phModule)
717 {
719  NTSTATUS Status = STATUS_SUCCESS, Status2;
720  HANDLE hModule = NULL;
721  UNICODE_STRING ModuleNameU;
722  DWORD dwValid;
723  BOOLEAN Redirected = FALSE; // FIXME
724 
725  /* Validate parameters */
726  dwValid = BasepGetModuleHandleExParameterValidation(dwPublicFlags, lpwModuleName, phModule);
728 
729  /* Acquire lock if necessary */
730  if (!NoLock)
731  {
733  if (!NT_SUCCESS(Status))
734  {
735  /* Fail */
737  if (phModule) *phModule = NULL;
738  return NT_SUCCESS(Status);
739  }
740  }
741 
742  if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
743  {
744  /* Create a unicode string out of module name */
745  RtlInitUnicodeString(&ModuleNameU, lpwModuleName);
746 
747  // FIXME: Do some redirected DLL stuff?
748  if (Redirected)
749  {
751  }
752 
753  if (!hModule)
754  {
756  if (!hModule)
757  {
758  /* Last error is already set, so just return failure by setting status */
760  goto quickie;
761  }
762  }
763  }
764  else
765  {
766  /* Perform Pc to file header to get module instance */
767  hModule = (HMODULE)RtlPcToFileHeader((PVOID)lpwModuleName,
768  (PVOID*)&hModule);
769 
770  /* Check if it succeeded */
771  if (!hModule)
772  {
773  /* Set "dll not found" status and quit */
775  goto quickie;
776  }
777  }
778 
779  /* Check if changing reference is not forbidden */
780  if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
781  {
782  /* Add reference to this DLL */
783  Status = LdrAddRefDll((dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_PIN) ? LDR_ADDREF_DLL_PIN : 0,
784  hModule);
785  }
786 
787 quickie:
788  /* Set last error in case of failure */
789  if (!NT_SUCCESS(Status))
791 
792  /* Unlock loader lock if it was acquired */
793  if (!NoLock)
794  {
795  Status2 = LdrUnlockLoaderLock(0, Cookie);
796  ASSERT(NT_SUCCESS(Status2));
797  }
798 
799  /* Set the module handle to the caller */
800  if (phModule) *phModule = hModule;
801 
802  /* Return TRUE on success and FALSE otherwise */
803  return NT_SUCCESS(Status);
804 }
805 
806 /*
807  * @implemented
808  */
809 HMODULE
810 WINAPI
813 {
814  PUNICODE_STRING ModuleNameW;
815  PTEB pTeb = NtCurrentTeb();
816 
817  /* Check if we have no name to convert */
818  if (!lpModuleName)
820 
821  /* Convert module name to unicode */
822  ModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName);
823 
824  /* Call W version if conversion was successful */
825  if (ModuleNameW)
826  return GetModuleHandleW(ModuleNameW->Buffer);
827 
828  /* Return failure */
829  return 0;
830 }
831 
832 
833 /*
834  * @implemented
835  */
836 HMODULE
837 WINAPI
839 {
842 
843  /* If current module is requested - return it right away */
844  if (!lpModuleName)
845  return ((HMODULE)NtCurrentPeb()->ImageBaseAddress);
846 
847  /* Use common helper routine */
849  GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
850  lpModuleName,
851  &hModule);
852 
853  /* If it wasn't successful - return NULL */
854  if (!Success) hModule = NULL;
855 
856  /* Return the handle */
857  return hModule;
858 }
859 
860 
861 /*
862  * @implemented
863  */
864 BOOL
865 WINAPI
867  IN LPCWSTR lpwModuleName OPTIONAL,
868  OUT HMODULE* phModule)
869 {
870  DWORD dwValid;
871  BOOL Ret;
872 
873  /* Validate parameters */
874  dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, lpwModuleName, phModule);
875 
876  /* If result is invalid parameter - return failure */
878 
879  /* If result is 2, there is no need to do anything - return success. */
881 
882  /* Use common helper routine */
884  dwFlags,
885  lpwModuleName,
886  phModule);
887 
888  return Ret;
889 }
890 
891 /*
892  * @implemented
893  */
894 BOOL
895 WINAPI
897  IN LPCSTR lpModuleName OPTIONAL,
898  OUT HMODULE* phModule)
899 {
900  PUNICODE_STRING lpModuleNameW;
901  DWORD dwValid;
902  BOOL Ret;
903 
904  /* Validate parameters */
905  dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, (LPCWSTR)lpModuleName, phModule);
906 
907  /* If result is invalid parameter - return failure */
909 
910  /* If result is 2, there is no need to do anything - return success. */
912 
913  /* Check if we don't need to convert the name */
914  if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
915  {
916  /* Call the extended version of the API without conversion */
918  dwFlags,
919  (LPCWSTR)lpModuleName,
920  phModule);
921  }
922  else
923  {
924  /* Convert module name to unicode */
925  lpModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName);
926 
927  /* Return FALSE if conversion failed */
928  if (!lpModuleNameW) return FALSE;
929 
930  /* Call the extended version of the API */
932  dwFlags,
933  lpModuleNameW->Buffer,
934  phModule);
935  }
936 
937  /* Return result */
938  return Ret;
939 }
940 
941 
942 /*
943  * @implemented
944  */
945 DWORD
946 WINAPI
947 LoadModule(LPCSTR lpModuleName,
948  LPVOID lpParameterBlock)
949 {
950  STARTUPINFOA StartupInfo;
951  PROCESS_INFORMATION ProcessInformation;
952  LOADPARMS32 *LoadParams;
953  char FileName[MAX_PATH];
954  LPSTR CommandLine;
955  DWORD Length, Error;
956  BOOL ProcessStatus;
957  ANSI_STRING AnsiStr;
958  UNICODE_STRING UnicStr;
960  HANDLE Handle;
961 
962  LoadParams = (LOADPARMS32*)lpParameterBlock;
963 
964  /* Check load parameters */
965  if (LoadParams->dwReserved || LoadParams->wMagicValue != 2)
966  {
967  /* Fail with invalid param error */
969  return 0;
970  }
971 
972  /* Search path */
973  Length = SearchPathA(NULL, lpModuleName, ".exe", MAX_PATH, FileName, NULL);
974 
975  /* Check if path was found */
976  if (Length && Length < MAX_PATH)
977  {
978  /* Build StartupInfo */
979  RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
980 
981  StartupInfo.cb = sizeof(STARTUPINFOA);
982  StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
983  StartupInfo.wShowWindow = LoadParams->wCmdShow;
984 
985  /* Allocate command line buffer */
986  CommandLine = RtlAllocateHeap(RtlGetProcessHeap(),
988  (ULONG)LoadParams->lpCmdLine[0] + Length + 2);
989 
990  /* Put module name there, then a space, and then copy provided command line,
991  and null-terminate it */
992  RtlCopyMemory(CommandLine, FileName, Length);
993  CommandLine[Length] = ' ';
994  RtlCopyMemory(&CommandLine[Length + 1], &LoadParams->lpCmdLine[1], (ULONG)LoadParams->lpCmdLine[0]);
995  CommandLine[Length + 1 + (ULONG)LoadParams->lpCmdLine[0]] = 0;
996 
997  /* Create the process */
998  ProcessStatus = CreateProcessA(FileName,
999  CommandLine,
1000  NULL,
1001  NULL,
1002  FALSE,
1003  0,
1004  LoadParams->lpEnvAddress,
1005  NULL,
1006  &StartupInfo,
1007  &ProcessInformation);
1008 
1009  /* Free the command line buffer */
1010  RtlFreeHeap(RtlGetProcessHeap(), 0, CommandLine);
1011 
1012  if (!ProcessStatus)
1013  {
1014  /* Creating process failed, return right error code */
1015  Error = GetLastError();
1016  switch(Error)
1017  {
1018  case ERROR_BAD_EXE_FORMAT:
1019  return ERROR_BAD_FORMAT;
1020 
1021  case ERROR_FILE_NOT_FOUND:
1022  case ERROR_PATH_NOT_FOUND:
1023  return Error;
1024  }
1025 
1026  /* Return 0 otherwise */
1027  return 0;
1028  }
1029 
1030  /* Wait up to 30 seconds for the process to become idle */
1032  {
1033  UserWaitForInputIdleRoutine(ProcessInformation.hProcess, 30000);
1034  }
1035 
1036  /* Close handles */
1037  NtClose(ProcessInformation.hThread);
1038  NtClose(ProcessInformation.hProcess);
1039 
1040  /* Return magic success value (33) */
1041  return 33;
1042  }
1043 
1044  /* The path was not found, create an ansi string from
1045  the module name and convert it to unicode */
1046  RtlInitAnsiString(&AnsiStr, lpModuleName);
1047  if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(&UnicStr,&AnsiStr,TRUE)))
1048  return ERROR_FILE_NOT_FOUND;
1049 
1050  /* Determine path type */
1052 
1053  /* Free the unicode module name */
1054  RtlFreeUnicodeString(&UnicStr);
1055 
1056  /* If it's a relative path, return file not found */
1058  return ERROR_FILE_NOT_FOUND;
1059 
1060  /* If not, try to open it */
1061  Handle = CreateFile(lpModuleName,
1062  GENERIC_READ,
1064  NULL,
1065  OPEN_EXISTING,
1067  NULL);
1068 
1070  {
1071  /* Opening file succeeded for some reason, close the handle and return file not found anyway */
1073  return ERROR_FILE_NOT_FOUND;
1074  }
1075 
1076  /* Return last error which CreateFile set during an attempt to open it */
1077  return GetLastError();
1078 }
1079 
1080 /*
1081  * @unimplemented
1082  */
1084 {
1085  STUB;
1086  return NULL;
1087 }
1088 
1089 /*
1090  * @unimplemented
1091  */
1093  LPSTR lpszInitName, LPSTR lpszProcName,
1094  FARPROC *ppfn32Thunk, FARPROC pfnUT32CallBack,
1095  LPVOID lpBuff )
1096 {
1097  STUB;
1098  return 0;
1099 }
1100 
1101 /*
1102  * @unimplemented
1103  */
1105 {
1106  STUB;
1107 }
1108 
1109 /*
1110  * @unimplemented
1111  */
1112 BOOL
1113 WINAPI
1115  IN LPSTR Unknown,
1116  IN PVOID Unknown2,
1117  IN PVOID Unknown3,
1118  IN PVOID Unknown4)
1119 {
1120  DPRINT1("BaseQueryModuleData called: %s %s %p %p %p\n",
1121  ModuleName,
1122  Unknown,
1123  Unknown2,
1124  Unknown3,
1125  Unknown4);
1126  return FALSE;
1127 }
1128 
1129 /*
1130  * @implemented
1131  */
1132 NTSTATUS
1133 WINAPI
1135 {
1136  DPRINT("Post-init called\n");
1137 
1138  /* Check if this is a terminal server */
1139  if (SharedUserData->SuiteMask & VER_SUITE_TERMINAL)
1140  {
1141  /* Initialize TS pointers */
1142  return BasepInitializeTermsrvFpns();
1143  }
1144 
1145  /* FIXME: Initialize TS pointers */
1146  return STATUS_SUCCESS;
1147 }
1148 
1149 /* 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:600
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:39
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 CloseHandle
Definition: compat.h:598
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_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:716
struct _Entry Entry
Definition: kefuncs.h:627
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
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
#define TRUE
Definition: types.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:56
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:2037
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:1092
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:590
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD dwFlags
Definition: winbase.h:820
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:1274
#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:659
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:539
#define FILE_SHARE_READ
Definition: compat.h:136
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define SearchPath
Definition: winbase.h:3740
_SEH2_TRY
Definition: create.c:4226
VOID WINAPI UTUnRegister(HMODULE hModule)
Definition: loader.c:1104
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:507
PVOID DllBase
Definition: btrfs_drv.h:1926
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:1083
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
#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:667
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
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
_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:634
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:246
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI LdrUnloadAlternateResourceModule(IN PVOID BaseAddress)
Definition: ldrapi.c:1629
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
DWORD cb
Definition: winbase.h:809
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define ASSERT(a)
Definition: mode.c:45
__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:603
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:4744
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:13
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
#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
BOOL WINAPI BaseQueryModuleData(IN LPSTR ModuleName, IN LPSTR Unknown, IN PVOID Unknown2, IN PVOID Unknown3, IN PVOID Unknown4)
Definition: loader.c:1114
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#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:896
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#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:475
Definition: btrfs_drv.h:1922
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
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:135
Definition: typedefs.h:119
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
NTSTATUS WINAPI BaseProcessInitPostImport(VOID)
Definition: loader.c:1134
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:548
HANDLE HMODULE
Definition: typedefs.h:77
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:80
Definition: compat.h:694
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:866
_SEH2_END
Definition: create.c:4400
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:913
#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:545
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:1958
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1928
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WORD wShowWindow
Definition: winbase.h:821
#define PAGE_READONLY
Definition: compat.h:138
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define MAXUSHORT
Definition: typedefs.h:83
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:665
#define CreateFileW
Definition: compat.h:600
DWORD WINAPI LoadModule(LPCSTR lpModuleName, LPVOID lpParameterBlock)
Definition: loader.c:947
#define STATUS_ENTRYPOINT_NOT_FOUND
Definition: ntstatus.h:549
_In_ HANDLE Handle
Definition: extypes.h:390
#define OUT
Definition: typedefs.h:40
_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:247
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define STATUS_SUCCESS
Definition: shellext.h:65
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)
#define UnmapViewOfFile
Definition: compat.h:605
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:36
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