Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. #pragma once
  2. // Our primary client is kernel32.dll. Because we use APIs exported
  3. // by kernel32.dll, we need to build this static library as if we
  4. // are kernel32.dll. If we don't we get link warnings like:
  5. // warning LNK4049: locally defined symbol "_OutputDebugStringA@4" imported
  6. // warning LNK4049: locally defined symbol "_SetLastError@4" imported
  7. //
  8. // Other clients of this library will just go through the import thunk
  9. // instead of doing a call indirect for these APIs.
  10. //
  11. #define _KERNEL32_
  12. // "Build as if we are advapi32.dll. If we don't we get" compiler errors like:
  13. // advapi.c : error C2491: 'RegCreateKeyExW' : definition of dllimport function not allowed
  14. #define _ADVAPI32_
  15. // same problem..
  16. #define _RPCRT4_
  17. #define _USER32_
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <windows.h>
  22. #include <delayimp.h>
  23. #include <stdio.h>
  24. #include <wtypes.h>
  25. #include <dloaddef.h>
  26. #if DBG
  27. //
  28. // DelayLoadAssertFailed/MYASSERT used instead of RtlAssert/ASSERT
  29. // as dload is also compiled to run on Win95
  30. //
  31. VOID
  32. WINAPI
  33. DelayLoadAssertFailed(
  34. IN PCSTR FailedAssertion,
  35. IN PVOID FileName,
  36. IN ULONG LineNumber,
  37. IN PCSTR Message OPTIONAL
  38. );
  39. VOID
  40. WINAPI
  41. AssertDelayLoadFailureMapsAreSorted(
  42. VOID
  43. );
  44. #define MYASSERT(x) if(!(x)) { DelayLoadAssertFailed(#x,__FILE__,__LINE__,NULL); }
  45. #else
  46. #define MYASSERT(x)
  47. #endif
  48. extern const LONG g_lDelayLoad_NtStatus;
  49. extern const ULONG g_ulDelayLoad_Win32Error;
  50. #define DelayLoad_GetNtStatus() (g_lDelayLoad_NtStatus)
  51. #define DelayLoad_GetWin32Error() (g_ulDelayLoad_Win32Error)
  52. VOID
  53. WINAPI
  54. DelayLoad_SetLastNtStatusAndWin32Error(
  55. );