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.

146 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. RapGtPt.h
  5. Abstract:
  6. This header file contains the Remote Admin Protocol (RAP) get and put
  7. macros. These encapsulate handling of alignment differences and byte
  8. order differences between the native machine and the RAP protocol.
  9. Author:
  10. John Rogers (JohnRo) 14-Jul-1991
  11. Environment:
  12. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  13. Requires ANSI C extensions: slash-slash comments, long external names.
  14. Revision History:
  15. 14-Jul-1991 JohnRo
  16. Created this header file.
  17. --*/
  18. #ifndef _RAPGTPT_
  19. #define _RAPGTPT_
  20. // These must be included first:
  21. #include <windef.h> // BOOL, CHAR, DWORD, IN, LPBYTE, etc.
  22. // These may be included in any order:
  23. #include <smbgtpt.h> // SmbPutUshort(), etc.
  24. //
  25. // DWORD
  26. // RapGetDword(
  27. // IN LPBYTE Ptr, // Assumed aligned if Native is true.
  28. // IN BOOL Native
  29. // );
  30. //
  31. #define RapGetDword(Ptr,Native) \
  32. ( (Native) \
  33. ? ( * (LPDWORD) (LPVOID) (Ptr) ) \
  34. : (SmbGetUlong( (LPDWORD) (Ptr) ) ) )
  35. //
  36. // WORD
  37. // RapGetWord(
  38. // IN LPBYTE Ptr, // Assumed aligned if Native is true.
  39. // IN BOOL Native
  40. // );
  41. //
  42. #define RapGetWord(Ptr,Native) \
  43. ( (Native) \
  44. ? ( * (LPWORD) (LPVOID) (Ptr) ) \
  45. : (SmbGetUshort( (LPWORD) (Ptr) ) ) )
  46. //
  47. // VOID
  48. // RapPutDword(
  49. // OUT LPBYTE Ptr, // Assumed aligned if Native is true.
  50. // IN DWORD Value,
  51. // IN BOOL Native
  52. // );
  53. //
  54. #define RapPutDword(Ptr,Value,Native) \
  55. { \
  56. if (Native) { \
  57. * (LPDWORD) (LPVOID) (Ptr) = (DWORD) (Value); \
  58. } else { \
  59. SmbPutUlong( (LPDWORD) (Ptr), (DWORD) (Value) ); \
  60. } \
  61. }
  62. //
  63. // VOID
  64. // RapPutWord(
  65. // OUT LPBYTE Ptr, // Assumed aligned if Native is true.
  66. // IN WORD Value,
  67. // IN BOOL Native
  68. // );
  69. //
  70. #define RapPutWord(Ptr,Value,Native) \
  71. { \
  72. if (Native) { \
  73. * (LPWORD) (LPVOID) (Ptr) = (WORD) (Value); \
  74. } else { \
  75. SmbPutUshort( (LPWORD) (Ptr), (WORD) (Value) ); \
  76. } \
  77. }
  78. //
  79. // DWORD_PTR
  80. // RapGetDword_Ptr(
  81. // IN LPBYTE Ptr, // Assumed aligned if Native is true.
  82. // IN BOOL Native
  83. // );
  84. //
  85. #ifdef _WIN64
  86. #define RapGetDword_Ptr(Ptr,Native) \
  87. ( (Native) \
  88. ? ( * (PDWORD_PTR) (LPVOID) (Ptr) ) \
  89. : (((DWORD_PTR) SmbGetUlong( (LPDWORD) (Ptr) )) \
  90. | (((DWORD_PTR) SmbGetUlong( (LPDWORD) (Ptr) )) << 32) \
  91. ) )
  92. #else
  93. #define RapGetDword_Ptr(Ptr,Native) \
  94. ( (Native) \
  95. ? ( * (PDWORD_PTR) (LPVOID) (Ptr) ) \
  96. : (((DWORD_PTR) SmbGetUlong( (LPDWORD) (Ptr) )) \
  97. ) )
  98. #endif
  99. //
  100. // VOID
  101. // RapPutDword_Ptr(
  102. // OUT LPBYTE Ptr, // Assumed aligned if Native is true.
  103. // IN DWORD_PTR Value,
  104. // IN BOOL Native
  105. // );
  106. //
  107. #ifdef _WIN64
  108. #define RapPutDword_Ptr(Ptr,Value,Native) \
  109. { \
  110. RapPutDword(Ptr, (DWORD)(DWORD_PTR) Value, Native); \
  111. RapPutDword( ((LPDWORD) Ptr + 1), (DWORD)((DWORD_PTR) Value >> 32), Native); \
  112. }
  113. #else
  114. #define RapPutDword_Ptr(Ptr,Value,Native) \
  115. { \
  116. RapPutDword(Ptr, (DWORD)(DWORD_PTR) Value, Native); \
  117. }
  118. #endif
  119. #endif // ndef _RAPGTPT_