Source code of Windows XP (NT5)
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.

59 lines
1.4 KiB

  1. #define MERGE2(x,y,z) x##_##y##_##z
  2. #define MERGE(x,y,z) MERGE2(x,y,z)
  3. #define FAILMERGE2(x,y) x##y
  4. #define FAILMERGE(x,y) FAILMERGE2(x,y)
  5. #define MAKESTRING2(x,y) #x#y
  6. #define MAKESTRING(x,y) MAKESTRING2(x,y)
  7. #define MAKESTRING2x(x) #x
  8. #define MAKESTRINGx(x) MAKESTRING2x(x)
  9. #define DLLNAME_STR MAKESTRING(_DLLNAME_,_DLLEXT_)
  10. #define APINAME_STR MAKESTRINGx(_APINAME_)
  11. #define THUNKPTR MERGE(_DLLNAME_, _APINAME_, Ptr)
  12. #define THUNKNAME MERGE(_DLLNAME_, _APINAME_, Thunk)
  13. #define FAILPTR FAILMERGE(GodotFail, _APINAME_)
  14. #define DIRECTAPI FAILMERGE(DirectCall_, _APINAME_)
  15. void __stdcall ResolveThunk(char *,
  16. char *,
  17. void (__stdcall **)(void),
  18. void (__stdcall *)(void),
  19. void (__stdcall *)(void));
  20. #define API_OVERRIDE FAILMERGE(Unicows_, _APINAME_)
  21. void (__stdcall *API_OVERRIDE)(void);
  22. void (__stdcall *THUNKPTR)(void);
  23. __declspec(naked)
  24. void
  25. __stdcall
  26. THUNKNAME (void)
  27. {
  28. ResolveThunk(DLLNAME_STR,
  29. APINAME_STR,
  30. &THUNKPTR,
  31. (void (__stdcall *)(void))API_OVERRIDE,
  32. (void (__stdcall *)(void))FAILPTR);
  33. __asm jmp THUNKPTR;
  34. }
  35. __declspec(naked)
  36. void
  37. __stdcall
  38. DIRECTAPI (void)
  39. {
  40. __asm jmp THUNKPTR;
  41. }
  42. #pragma data_seg(MAKESTRINGx(MERGE(.data$,_DLLNAME_,_APINAME_)))
  43. void (__stdcall *THUNKPTR)(void) = THUNKNAME;
  44. #pragma data_seg()