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.

410 lines
13 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. RxP.h
  5. Abstract:
  6. This is the private header file for the NT version of RpcXlate.
  7. Author:
  8. John Rogers (JohnRo) 25-Mar-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 25-Mar-1991 JohnRo
  14. Created.
  15. 03-May-1991 JohnRo
  16. RxpStartBuildingTransaction's data descriptor is SMB version (no Q's
  17. or U's). RxpConvertBlock needs 2 versions of data descriptor.
  18. RcvDataPtrPtr and RcvDataPresent are redundant for RxpConvertArguments
  19. and RxpConvertBlock. RxpTransactSmb now gets UNC server name.
  20. Fixed receive buffer size problem. Use LPTSTR.
  21. Added stuff to allow runtime debug on/off changes.
  22. Clarify that RxpStartBuildingTransaction uses buffer as OUT.
  23. Reduced recompile hits from header files.
  24. 06-May-1991 JohnRo
  25. Added RxpComputeRequestBufferSize().
  26. 13-May-1991 JohnRo
  27. Added print Q and print job APIs support.
  28. 14-May-1991 JohnRo
  29. Pass 2 aux descriptors to RxpConvertBlock. Clarify other types of
  30. aux descriptors.
  31. 18-May-1991 JohnRo
  32. Handle array of aux structs.
  33. 19-May-1991 JohnRo
  34. Added DBGSTATIC definition. Pass ResourceName to RxpSetField().
  35. Fixed RxpAddAscii().
  36. 20-May-1991 JohnRo
  37. Make data descriptors OPTIONAL for RxpConvertBlock.
  38. 29-May-1991 JohnRo
  39. RxpConvertArgs must return SendDataPtr16 and SendDataSize16.
  40. 05-Jun-1991 JohnRo
  41. Added setfield debug output.
  42. 11-Jun-1991 rfirth
  43. Added SmbRcvByteLen parameter to RxpConvertBlock
  44. Changed RetDataSize parameter to RxpTransactSmb to IN OUT LPDWORD
  45. 12-Jun-1991 JohnRo
  46. Moved DBGSTATIC to <NetDebug.h>.
  47. 13-Jun-1991 JohnRo
  48. RxpPackSendBuffer and RxpConvertArgs both need DataDesc16.
  49. 15-Jul-1991 JohnRo
  50. Added FieldIndex parameter to RxpSetField.
  51. Changed RxpConvertDataStructures to allow ERROR_MORE_DATA, e.g. for
  52. print APIs. Added debug flag for the same routine.
  53. 16-Jul-1991 JohnRo
  54. Estimate bytes needed for print APIs.
  55. 17-Jul-1991 JohnRo
  56. Extracted RxpDebug.h from Rxp.h.
  57. 19-Aug-1991 rfirth
  58. Added Flags parameter to RxpConvert{Args|Block}
  59. 04-Oct-1991 JohnRo
  60. Handle ERROR_BAD_NET_NAME (e.g. IPC$ not shared) to fix NetShareEnum.
  61. More work toward UNICODE. (Added RxpAddTStr().)
  62. 07-Oct-1991 JohnRo
  63. Made changes suggested by PC-LINT.
  64. 24-Oct-1991 JohnRo
  65. Added RxpCopyStrArrayToTStrArray for remote config and disk enum.
  66. 29-Oct-1991 JohnRo
  67. RxpFatalErrorCode() should be paranoid.
  68. 13-Nov-1991 JohnRo
  69. OK, RxpFatalErrorCode() was too paranoid. It should allow
  70. ERROR_MORE_DATA or all the enum APIs break.
  71. 31-Mar-1992 JohnRo
  72. Prevent too large size requests.
  73. 05-Jun-1992 JohnRo
  74. RAID 11253: NetConfigGetAll fails when remoted to downlevel.
  75. 26-Jun-1992 JohnRo
  76. RAID 9933: ALIGN_WORST should be 8 for x86 builds.
  77. 04-May-1993 JohnRo
  78. RAID 6167: avoid access violation or assert with WFW print server.
  79. Made changes suggested by PC-LINT 5.0
  80. 18-May-1993 JohnRo
  81. DosPrintQGetInfoW underestimates number of bytes needed.
  82. --*/
  83. #ifndef _RXP_
  84. #define _RXP_
  85. // These must be included first:
  86. #include <windef.h> // IN, LPTSTR, LPVOID, etc.
  87. #include <lmcons.h> // NET_API_STATUS.
  88. // These may be included in any order:
  89. #include <rap.h> // LPDESC, RapStructureSize(), etc.
  90. // Don't complain about "unneeded" includes of these files:
  91. /*lint -efile(764,rxp.h,smbgtpt.h,stdarg.h,tstr.h,tstring.h) */
  92. /*lint -efile(766,rxp.h,smbgtpt.h,stdarg.h,tstr.h,tstring.h) */
  93. #include <smbgtpt.h> // SmbPutUshort() (needed by macros below).
  94. #include <stdarg.h> // va_list, etc.
  95. #include <tstring.h> // NetpCopyTStrToStr().
  96. // Maximum sizes (in bytes) supported by the transact SMB.
  97. #define MAX_TRANSACT_RET_DATA_SIZE ((DWORD) 0x0000FFFF)
  98. #define MAX_TRANSACT_RET_PARM_SIZE ((DWORD) 0x0000FFFF)
  99. #define MAX_TRANSACT_SEND_DATA_SIZE ((DWORD) 0x0000FFFF)
  100. #define MAX_TRANSACT_SEND_PARM_SIZE ((DWORD) 0x0000FFFF)
  101. // Note: IF_DEBUG() and so on are now in Net/Inc/RxpDebug.h.
  102. DWORD
  103. RxpComputeRequestBufferSize(
  104. IN LPDESC ParmDesc,
  105. IN LPDESC DataDescSmb OPTIONAL,
  106. IN DWORD DataSize
  107. );
  108. NET_API_STATUS
  109. RxpConvertArgs(
  110. IN LPDESC ParmDescriptorString,
  111. IN LPDESC DataDesc16 OPTIONAL,
  112. IN LPDESC DataDesc32 OPTIONAL,
  113. IN LPDESC DataDescSmb OPTIONAL,
  114. IN LPDESC AuxDesc16 OPTIONAL,
  115. IN LPDESC AuxDesc32 OPTIONAL,
  116. IN LPDESC AuxDescSmb OPTIONAL,
  117. IN DWORD MaximumInputBlockSize,
  118. IN DWORD MaximumOutputBlockSize,
  119. IN OUT LPDWORD CurrentInputBlockSizePtr,
  120. IN OUT LPDWORD CurrentOutputBlockSizePtr,
  121. IN OUT LPBYTE * CurrentOutputBlockPtrPtr,
  122. IN va_list * FirstArgumentPtr, // rest of API's arguments (after
  123. // server name)
  124. OUT LPDWORD SendDataSizePtr16,
  125. OUT LPBYTE * SendDataPtrPtr16,
  126. OUT LPDWORD RcvDataSizePtr,
  127. OUT LPBYTE * RcvDataPtrPtr,
  128. IN DWORD Flags
  129. );
  130. NET_API_STATUS
  131. RxpConvertBlock(
  132. IN DWORD ApiNumber,
  133. IN LPBYTE ResponseBlockPtr,
  134. IN LPDESC ParmDescriptorString,
  135. IN LPDESC DataDescriptor16 OPTIONAL,
  136. IN LPDESC DataDescriptor32 OPTIONAL,
  137. IN LPDESC AuxDesc16 OPTIONAL,
  138. IN LPDESC AuxDesc32 OPTIONAL,
  139. IN va_list* FirstArgumentPtr, // rest of API's arguments
  140. IN LPBYTE SmbRcvBuffer OPTIONAL,
  141. IN DWORD SmbRcvByteLen,
  142. OUT LPBYTE RcvDataPtr OPTIONAL,
  143. IN DWORD RcvDataSize,
  144. IN DWORD Flags
  145. );
  146. // DWORD
  147. // RxpEstimateBytesNeeded(
  148. // IN DWORD BytesNeeded16
  149. // );
  150. //
  151. // Worst case: BOOL or CHAR might be padded to DWORD.
  152. #define RxpEstimateBytesNeeded(Size16) \
  153. ( (Size16) * 4 )
  154. //
  155. // Estimate bytes needed for an audit log or error log array.
  156. //
  157. NET_API_STATUS
  158. RxpEstimateLogSize(
  159. IN DWORD DownlevelFixedEntrySize,
  160. IN DWORD InputArraySize,
  161. IN BOOL DoingErrorLog, // TRUE for error log, FALSE for audit log
  162. OUT LPDWORD OutputArraySize
  163. );
  164. // BOOL
  165. // RxpFatalErrorCode(
  166. // IN NET_API_STATUS Status
  167. // );
  168. //
  169. #define RxpFatalErrorCode( Status ) \
  170. ( ( ((Status) != NERR_Success) \
  171. && ((Status) != ERROR_MORE_DATA) ) \
  172. ? TRUE : FALSE )
  173. NET_API_STATUS
  174. RxpPackSendBuffer(
  175. IN OUT LPVOID * SendBufferPtrPtr,
  176. IN OUT LPDWORD SendBufferSizePtr,
  177. OUT LPBOOL AllocFlagPtr,
  178. IN LPDESC DataDesc16,
  179. IN LPDESC AuxDesc16,
  180. IN DWORD FixedSize16,
  181. IN DWORD AuxOffset,
  182. IN DWORD AuxSize,
  183. IN BOOL SetInfo
  184. );
  185. NET_API_STATUS
  186. RxpReceiveBufferConvert(
  187. IN OUT LPVOID RcvDataPtr,
  188. IN DWORD RcvDataSize,
  189. IN DWORD Converter,
  190. IN DWORD NumberOfStructures,
  191. IN LPDESC DataDescriptorString,
  192. IN LPDESC AuxDescriptorString,
  193. OUT LPDWORD NumAuxStructs
  194. );
  195. NET_API_STATUS
  196. RxpSetField (
  197. IN DWORD ApiNumber,
  198. IN LPTSTR UncServerName,
  199. IN LPDESC ObjectDesc OPTIONAL,
  200. IN LPVOID ObjectToSet OPTIONAL,
  201. IN LPDESC ParmDesc,
  202. IN LPDESC DataDesc16,
  203. IN LPDESC DataDesc32,
  204. IN LPDESC DataDescSmb,
  205. IN LPVOID NativeInfoBuffer,
  206. IN DWORD ParmNumToSend,
  207. IN DWORD FieldIndex,
  208. IN DWORD Level
  209. );
  210. NET_API_STATUS
  211. RxpStartBuildingTransaction(
  212. OUT LPVOID Buffer,
  213. IN DWORD BufferSize,
  214. IN DWORD ApiNumber,
  215. IN LPDESC ParmDesc,
  216. IN LPDESC DataDescSmb OPTIONAL,
  217. OUT LPVOID * RovingOutputPtr,
  218. OUT LPDWORD SizeSoFarPtr,
  219. OUT LPVOID * LastStringPtr OPTIONAL,
  220. OUT LPDESC * ParmDescCopyPtr OPTIONAL
  221. );
  222. NET_API_STATUS
  223. RxpTransactSmb(
  224. IN LPTSTR UncServerName,
  225. IN LPTSTR TransportName,
  226. IN LPVOID SendParmPtr,
  227. IN DWORD SendParmSize,
  228. IN LPVOID SendDataPtr OPTIONAL,
  229. IN DWORD SendDataSize,
  230. OUT LPVOID RetParmPtr OPTIONAL,
  231. IN DWORD RetParmSize,
  232. OUT LPVOID RetDataPtr OPTIONAL,
  233. IN OUT LPDWORD RetDataSize,
  234. IN BOOL NoPermissionRequired
  235. );
  236. NET_API_STATUS
  237. RxpConvertDataStructures(
  238. IN LPDESC InputDescriptor,
  239. IN LPDESC OutputDescriptor,
  240. IN LPDESC InputAuxDescriptor OPTIONAL,
  241. IN LPDESC OutputAuxDescriptor OPTIONAL,
  242. IN LPBYTE InputBuffer,
  243. OUT LPBYTE OutputBuffer,
  244. IN DWORD OutputBufferSize,
  245. IN DWORD PrimaryCount,
  246. OUT LPDWORD EntriesConverted OPTIONAL,
  247. IN RAP_TRANSMISSION_MODE TransmissionMode,
  248. IN RAP_CONVERSION_MODE ConversionMode
  249. );
  250. // VOID
  251. // RxpAddPointer(
  252. // IN LPVOID Input,
  253. // IN OUT LPBYTE * CurPtrPtr,
  254. // IN OUT LPDWORD CurSizePtr
  255. // );
  256. //
  257. #if defined(_WIN64)
  258. #define RxpAddPointer(Input,CurPtrPtr,CurSizePtr) \
  259. { \
  260. *((PVOID UNALIGNED *)(*(CurPtrPtr))) = (Input); \
  261. *(CurPtrPtr) += sizeof(LPBYTE); \
  262. *(CurSizePtr) = (*(CurSizePtr)) + sizeof(LPBYTE); \
  263. }
  264. #else
  265. #define RxpAddPointer(Input,CurPtrPtr,CurSizePtr) \
  266. { \
  267. SmbPutUlong( (LPDWORD) *(CurPtrPtr), (DWORD) (Input)); \
  268. *(CurPtrPtr) += sizeof(LPBYTE); \
  269. *(CurSizePtr) = (*(CurSizePtr)) + sizeof(LPBYTE); \
  270. }
  271. #endif
  272. // RxpAddVariableSize: Add a variable length item to string space at end of
  273. // buffer. Store pointer to it in buffer; update current buffer pointer and
  274. // Size; update string space pointer.
  275. //
  276. // VOID
  277. // RxpAddVariableSize(
  278. // IN LPBYTE Input,
  279. // IN DWORD InputSize,
  280. // IN OUT LPBYTE * CurPtrPtr,
  281. // IN OUT LPBYTE * StrPtrPtr,
  282. // IN OUT LPDWORD CurSizePtr
  283. // );
  284. //
  285. #define RxpAddVariableSize(Input,InputSize,CurPtrPtr,StrPtrPtr,CurSizePtr) \
  286. { \
  287. *(StrPtrPtr) -= (InputSize); \
  288. RxpAddPointer( *(StrPtrPtr), (CurPtrPtr), (CurSizePtr)); \
  289. NetpMoveMemory( *((StrPtrPtr)), (Input), (InputSize)); \
  290. }
  291. // RxpAddAscii: Add an ASCII string to string space at end of buffer;
  292. // store pointer to it in buffer; update current buffer pointer and Size;
  293. // update string space pointer.
  294. //
  295. // VOID
  296. // RxpAddAscii(
  297. // IN LPTSTR Input,
  298. // IN OUT LPBYTE * CurPtrPtr,
  299. // IN OUT LPBYTE * StrPtrPtr,
  300. // IN OUT LPDWORD CurSizePtr
  301. // );
  302. //
  303. #define RxpAddAscii(Input,CurPtrPtr,StrPtrPtr,CurSizePtr) \
  304. { \
  305. DWORD len = strlen((Input))+1; \
  306. RxpAddVariableSize( \
  307. (Input), len, \
  308. (CurPtrPtr), (StrPtrPtr), (CurSizePtr)); \
  309. }
  310. // RxpAddTStr: Add a LPTSTR string to string space at end of buffer;
  311. // store pointer to it in buffer; update current buffer pointer and Size;
  312. // update string space pointer.
  313. //
  314. // VOID
  315. // RxpAddTStr(
  316. // IN LPTSTR Input,
  317. // IN OUT LPBYTE * CurPtrPtr,
  318. // IN OUT LPBYTE * StrPtrPtr,
  319. // IN OUT LPDWORD CurSizePtr
  320. // );
  321. //
  322. #define RxpAddTStr(Input,CurPtrPtr,StrPtrPtr,CurSizePtr) \
  323. { \
  324. DWORD size = STRLEN((Input))+1; \
  325. *(StrPtrPtr) -= size; \
  326. RxpAddPointer( *(StrPtrPtr), (CurPtrPtr), (CurSizePtr)); \
  327. NetpCopyWStrToStrDBCS( *((StrPtrPtr)), (Input) ); \
  328. }
  329. // VOID
  330. // RxpAddWord(
  331. // IN WORD Input,
  332. // IN OUT LPBYTE * CurPtrPtr,
  333. // IN OUT LPDWORD CurSizePtr
  334. // );
  335. //
  336. #define RxpAddWord(Input,CurPtrPtr,CurSizePtr) \
  337. { \
  338. SmbPutUshort( (LPWORD) (*(CurPtrPtr)), (WORD) (Input)); \
  339. *(CurPtrPtr) += sizeof(WORD); \
  340. *(CurSizePtr) = (*(CurSizePtr)) + sizeof(WORD); \
  341. }
  342. //
  343. // MAKE_PARMNUM_PAIR() - packs a parmnum and a field index into a DWORD. We
  344. // have to do this because there are (many) cases where we cannot assume
  345. // correspondence between a parmnum and a field index
  346. //
  347. #define MAKE_PARMNUM_PAIR(parmnum, field_index) ((DWORD)((((DWORD)(field_index)) << 16) | (DWORD)(parmnum)))
  348. //
  349. // FIELD_INDEX_FROM_PARMNUM_PAIR() - retrieve the field index from the pair
  350. // conjoined by MAKE_PARMNUM_PAIR()
  351. //
  352. #define FIELD_INDEX_FROM_PARMNUM_PAIR(pair) ((DWORD)((pair) >> 16))
  353. //
  354. // PARMNUM_FROM_PARMNUM_PAIR() - retrieve the parmnum from the pair conjoined
  355. // by MAKE_PARMNUM_PAIR()
  356. //
  357. #define PARMNUM_FROM_PARMNUM_PAIR(pair) ((DWORD)((pair) & 0x0000ffff))
  358. #endif // ndef _RXP_