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.

41 lines
1.1 KiB

  1. #include "windows.h"
  2. #include <stdio.h>
  3. #define FOUR_K 0x1000
  4. int __cdecl wmain(int argc, wchar_t** argv)
  5. {
  6. WCHAR Buffer[2] = {0};
  7. HANDLE Dll;
  8. int i;
  9. int LoadLibraryError;
  10. int LoadStringError;
  11. int Error;
  12. for (i = 0 ; i < 2 ; ++i)
  13. {
  14. // steal the address to force a collision on the next load
  15. if (i == 1)
  16. {
  17. fprintf(stderr, "VirtualAlloc:%p\n", VirtualAlloc(Dll, 1, MEM_RESERVE, PAGE_READONLY));
  18. fprintf(stderr, "Error:%d\n", Error = GetLastError());
  19. }
  20. Dll = LoadLibraryW(L"Dll");
  21. LoadLibraryError = GetLastError();
  22. Buffer[0] = 0;
  23. LoadStringW(Dll, 1, Buffer, sizeof(Buffer)/sizeof(Buffer[0]));
  24. LoadStringError = GetLastError();
  25. FreeLibrary(Dll);
  26. //ZeroMemory(Dll, FOUR_K);
  27. fprintf(stderr,
  28. "%ls: Dll:%p, String:%ls, LoadLibraryError:%d, LoadStringError:%d.\n",
  29. argv[0],
  30. Dll,
  31. Buffer,
  32. LoadLibraryError,
  33. LoadStringError);
  34. }
  35. return 0;
  36. }