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.

96 lines
3.0 KiB

  1. #ifdef WIN32
  2. // These things have direct equivalents.
  3. // Shouldn't be using these things.
  4. #define WINCAPI __cdecl
  5. #define _huge
  6. #define _export
  7. #define _loadds
  8. #define SELECTOROF(x) ((WPARAM)(x))
  9. #define OFFSETOF(x) ((WPARAM)(x))
  10. #define ISLPTR(pv) ((BOOL)pv)
  11. #define MAKELP(hmem,off) ((LPVOID)((LPBYTE)hmem+off))
  12. #define MAKELRESULTFROMUINT(i) ((LRESULT)i)
  13. #define ISVALIDHINSTANCE(hinst) BOOLFROMPTR(hinst)
  14. // HIWORD is typically used to detect whether a pointer parameter
  15. // is a real pointer or is a MAKEINTATOM. HIWORD64 is the Win64-compatible
  16. // version of this usage. It does *NOT* return the top word of a 64-bit value.
  17. // Rather, it returns the top 48 bits of the 64-bit value.
  18. //
  19. // Yes, the name isn't very good. Any better ideas?
  20. //
  21. // BOOLFROMPTR is used when you have a pointer or a ULONG_PTR
  22. // and you want to turn it into a BOOL. In Win32,
  23. // sizeof(BOOL) == sizeof(LPVOID) so a straight cast works.
  24. // In Win64, you have to do it the slow way because pointers are 64-bit.
  25. //
  26. #ifdef _WIN64
  27. #define HIWORD64(p) ((ULONG_PTR)(p) >> 16)
  28. #define BOOLFROMPTR(p) ((p) != 0)
  29. #define SPRINTF_PTR "%016I64x"
  30. #else
  31. #define HIWORD64 HIWORD
  32. #define BOOLFROMPTR(p) ((BOOL)(p))
  33. #define SPRINTF_PTR "%08x"
  34. #endif
  35. #define IntToPtr_(T, i) ((T)IntToPtr(i))
  36. #define DATASEG_READONLY ".text" // don't use this, compiler does this for you
  37. #define DATASEG_PERINSTANCE "INSTDATA" // per instance data (per process)
  38. #ifdef WINNT
  39. #define DATASEG_SHARED
  40. #else
  41. #define DATASEG_SHARED "SHARED" // global global data (shared across process)
  42. #endif
  43. #define CODESEG_INIT ".text"
  44. #define GetWindowInt GetWindowLongPtr
  45. #define SetWindowInt SetWindowLongPtr
  46. #define SetWindowID(hwnd,id) SetWindowLongPtr(hwnd, GWLP_ID, id)
  47. #define GetClassCursor(hwnd) ((HCURSOR)GetClassLongPtr(hwnd, GCLP_HCURSOR))
  48. #define GetClassIcon(hwnd) ((HICON)GetClassLongPtr(hwnd, GCLP_HICON))
  49. #define BOOL_PTR INT_PTR
  50. #ifdef WINNT
  51. #else
  52. typedef TBYTE TUCHAR;
  53. #endif
  54. #else // !WIN32
  55. typedef LPCSTR LPCTSTR;
  56. typedef LPSTR LPTSTR;
  57. typedef const short far *LPCWSTR;
  58. #define TEXT(x) (x)
  59. #define ISLPTR(pv) (SELECTOROF(pv))
  60. #define MAKELRESULTFROMUINT(i) MAKELRESULT(i,0)
  61. #define ISVALIDHINSTANCE(hinst) ((UINT)hinst>=(UINT)HINSTANCE_ERROR)
  62. #define DATASEG_READONLY "_TEXT"
  63. #define DATASEG_PERINSTANCE
  64. #define DATASEG_SHARED
  65. #define CODESEG_INIT "_INIT"
  66. #define GetWindowInt GetWindowWord
  67. #define SetWindowInt SetWindowWord
  68. #define SetWindowID(hwnd,id) SetWindowWord(hwnd, GWW_ID, id)
  69. #define GetClassCursor(hwnd) ((HCURSOR)GetClassWord(hwnd, GCW_HCURSOR))
  70. #define GetClassIcon(hwnd) ((HICON)GetClassWord(hwnd, GCW_HICON))
  71. #define MAKEPOINTS(l) (*((POINTS FAR*)&(l)))
  72. #define GlobalAlloc16(f, s) GlobalAlloc(f, s)
  73. #define GlobalLock16(h) GlobalLock(h)
  74. #define GlobalUnlock16(h) GlobalUnlock(h)
  75. #define GlobalFree16(h) GlobalFree(h)
  76. #define GlobalSize16(h) GlobalSize(h)
  77. #endif // WIN32