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.

393 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. XsProcsP.h
  5. Abstract:
  6. This header file contains private procedure prototypes for XACTSRV.
  7. Author:
  8. David Treadwell (davidtr) 05-Jan-1991
  9. Shanku Niyogi (w-shanku)
  10. Revision History:
  11. --*/
  12. #ifndef _XSPROCSP_
  13. #define _XSPROCSP_
  14. //
  15. // This header file is full of expressions that are always false. These
  16. // expressions manifest themselves in macros that take unsigned values
  17. // and make tests, for example, of greater than or equal to zero.
  18. //
  19. // Turn off these warnings until the authors fix this code.
  20. //
  21. #pragma warning(disable:4296)
  22. //
  23. // Helper subroutines.
  24. //
  25. //
  26. // XsAddVarString(
  27. // IN OUT LPSTR StringLocation,
  28. // IN LPTSTR String,
  29. // IN OUT LPBYTE *Pointer,
  30. // IN LPBYTE OffsetBegin
  31. // )
  32. //
  33. // Copy string to location, put the offset of location from OffsetBegin
  34. // in Pointer, and update location to point past string.
  35. //
  36. // !!UNICODE!! - Changed strcpy to NetpCopyTStrToStr. Fix WKSTA.H to use this!
  37. #define XsAddVarString( StringLocation, String, Pointer, OffsetBegin ) \
  38. NetpCopyWStrToStrDBCS((StringLocation), (String)); \
  39. SmbPutUlong((LPDWORD)(Pointer), \
  40. (ULONG)((LPBYTE)(StringLocation)-(LPBYTE)(OffsetBegin))); \
  41. StringLocation += (strlen((LPSTR)StringLocation) + 1)
  42. //
  43. // XsAuxiliaryDescriptor - return second argument if 'N' character is present
  44. // in first argument (an LPDESC), or NULL otherwise.
  45. //
  46. // !!UNICODE!! - Descriptor strings are always Ascii. No conversion.
  47. #define XsAuxiliaryDescriptor( DataDescriptor, EndOfParameters ) \
  48. (( strchr(( DataDescriptor ), REM_AUX_NUM ) != NULL ) \
  49. ? (EndOfParameters) : NULL )
  50. //
  51. // BOOL
  52. // XsApiSuccess(
  53. // IN NET_API_STATUS Status
  54. // )
  55. //
  56. // XsApiSuccess - check if status is one of three allowable ones.
  57. //
  58. #define XsApiSuccess( Status ) \
  59. (( (Status) == NERR_Success ) || ( (Status) == ERROR_MORE_DATA ) || \
  60. ( (Status) == NERR_BufTooSmall ))
  61. //
  62. // WORD
  63. // XsDwordToWord(
  64. // IN DWORD d
  65. // )
  66. //
  67. // Returns the WORD which is closest in value to the supplied DWORD.
  68. //
  69. #define XsDwordToWord(d) \
  70. ( (WORD) ( (DWORD) (d) > 0xffff ? 0xffff : (d) ) )
  71. //
  72. // BYTE
  73. // XsDwordToByte(
  74. // IN DWORD d
  75. // )
  76. //
  77. // Returns the BYTE which is closest in value to the supplied DWORD.
  78. //
  79. #define XsDwordToByte(d) \
  80. ( (BYTE) ( (DWORD) (d) > 0xff ? 0xff : (d) ) )
  81. //
  82. // BYTE
  83. // XsBoolToDigit(
  84. // IN BOOL b
  85. // )
  86. //
  87. // Returns '1' if the supplied boolean is true, or '0' if it is false.
  88. //
  89. #define XsBoolToDigit(b) \
  90. ( (BYTE) ( (BOOL)(b) ? '0' : '1' ) )
  91. DWORD
  92. XsBytesForConvertedStructure (
  93. IN LPBYTE InStructure,
  94. IN LPDESC InStructureDesc,
  95. IN LPDESC OutStructureDesc,
  96. IN RAP_CONVERSION_MODE Mode,
  97. IN BOOL MeaninglessInputPointers
  98. );
  99. BOOL
  100. XsCheckBufferSize (
  101. IN WORD BufferLength,
  102. IN LPDESC Descriptor,
  103. IN BOOL NativeFormat
  104. );
  105. //
  106. // XsDwordParamOutOfRange(
  107. // IN DWORD Field,
  108. // IN DWORD Min,
  109. // IN DWORD Max
  110. // )
  111. //
  112. // Check if parameter is out of range.
  113. //
  114. #define XsDwordParamOutOfRange( Field, Min, Max ) \
  115. (((DWORD)SmbGetUlong( &( Field )) < ( Min )) || \
  116. ((DWORD)SmbGetUlong( &( Field )) > ( Max )))
  117. // !!UNICODE!! - Validation on ASCII string - leave as LPSTR
  118. NET_API_STATUS
  119. XsValidateShareName(
  120. IN LPSTR ShareName
  121. );
  122. NET_API_STATUS
  123. XsConvertSetInfoBuffer(
  124. IN LPBYTE InBuffer,
  125. IN WORD BufferLength,
  126. IN WORD ParmNum,
  127. IN BOOL ConvertStrings,
  128. IN BOOL MeaninglessInputPointers,
  129. IN LPDESC InStructureDesc,
  130. IN LPDESC OutStructureDesc,
  131. IN LPDESC InSetInfoDesc,
  132. IN LPDESC OutSetInfoDesc,
  133. OUT LPBYTE * OutBuffer,
  134. OUT LPDWORD OutBufferLength OPTIONAL
  135. );
  136. //
  137. // BOOL
  138. // XsDigitToBool(
  139. // IN BYTE b
  140. // )
  141. //
  142. // Returns false if the supplied digit is '0', true otherwise.
  143. //
  144. #define XsDigitToBool(b) \
  145. (BOOL)((( b ) == '0' ) ? FALSE : TRUE )
  146. VOID
  147. XsFillAuxEnumBuffer (
  148. IN LPBYTE InBuffer,
  149. IN DWORD NumberOfEntries,
  150. IN LPDESC InStructureDesc,
  151. IN LPDESC InAuxStructureDesc,
  152. IN OUT LPBYTE OutBuffer,
  153. IN LPBYTE OutBufferStart,
  154. IN DWORD OutBufferLength,
  155. IN LPDESC OutStructureDesc,
  156. IN LPDESC OutAuxStructureDesc,
  157. IN PXACTSRV_ENUM_VERIFY_FUNCTION VerifyFunction OPTIONAL,
  158. OUT LPDWORD BytesRequired,
  159. OUT LPDWORD EntriesFilled,
  160. OUT LPDWORD InvalidEntries OPTIONAL
  161. );
  162. VOID
  163. XsFillEnumBuffer (
  164. IN LPBYTE InBuffer,
  165. IN DWORD NumberOfEntries,
  166. IN LPDESC InStructureDesc,
  167. IN OUT LPBYTE OutBuffer,
  168. IN LPBYTE OutBufferStart,
  169. IN DWORD OutBufferLength,
  170. IN LPDESC OutStructureDesc,
  171. IN PXACTSRV_ENUM_VERIFY_FUNCTION VerifyFunction OPTIONAL,
  172. OUT LPDWORD BytesRequired,
  173. OUT LPDWORD EntriesFilled,
  174. OUT LPDWORD InvalidEntries OPTIONAL
  175. );
  176. LPBYTE
  177. XsFindParameters (
  178. IN LPTRANSACTION Transaction
  179. );
  180. //
  181. // DWORD
  182. // XsLevelFromParmNum(
  183. // WORD Level,
  184. // WORD ParmNum
  185. // )
  186. //
  187. // Translate an old parmnum to an info level. If parmnum is PARMNUM_ALL,
  188. // this is just the old level, otherwise it is the old parmnum plus
  189. // PARMNUM_BASE_INFOLEVEL.
  190. //
  191. #define XsLevelFromParmNum( Level, ParmNum ) \
  192. ((( ParmNum ) == PARMNUM_ALL ) ? (DWORD)( Level ) \
  193. : (DWORD)( ParmNum ) \
  194. + PARMNUM_BASE_INFOLEVEL )
  195. //
  196. // Maps downlevel service names to nt service names
  197. //
  198. #define XS_MAP_SERVICE_NAME( ServiceName ) \
  199. (!STRICMP( ServiceName, SERVICE_LM20_SERVER ) ? SERVICE_SERVER : \
  200. !STRICMP( ServiceName, SERVICE_LM20_WORKSTATION ) ? SERVICE_WORKSTATION : \
  201. ServiceName )
  202. //
  203. // DWORD
  204. // XsNativeBufferSize(
  205. // IN WORD Size
  206. // )
  207. //
  208. // Uses XS_BUFFER_SCALE constant to calculate a reasonable maximum for the host
  209. // buffer, and rounds it to an even number for alignment.
  210. //
  211. #define XsNativeBufferSize( Size ) \
  212. ( (( XS_BUFFER_SCALE * (DWORD)( Size )) + 1) & (~1) )
  213. WORD
  214. XsPackReturnData (
  215. IN LPVOID Buffer,
  216. IN WORD BufferLength,
  217. IN LPDESC Descriptor,
  218. IN DWORD EntriesRead
  219. );
  220. VOID
  221. XsSetDataCount(
  222. IN OUT LPWORD DataCount,
  223. IN LPDESC Descriptor,
  224. IN WORD Converter,
  225. IN DWORD EntriesRead,
  226. IN WORD ReturnStatus
  227. );
  228. //
  229. // XsWordParamOutOfRange(
  230. // IN WORD Field,
  231. // IN WORD Min,
  232. // IN WORD Max
  233. // )
  234. //
  235. // Check if parameter is out of range.
  236. //
  237. // N.B. If Min is zero, then the first part of the following expression is
  238. // always FALSE.
  239. //
  240. #define XsWordParamOutOfRange( Field, Min, Max ) \
  241. (((DWORD)SmbGetUshort( &( Field )) < ( (DWORD)Min )) || \
  242. ((DWORD)SmbGetUshort( &( Field )) > ( (DWORD)Max )))
  243. VOID
  244. XsAnnounceServiceStatus( VOID );
  245. //
  246. // API bogus stub.
  247. //
  248. NTSTATUS
  249. XsNetUnsupportedApi (
  250. API_HANDLER_PARAMETERS
  251. );
  252. //
  253. // Convert an NT style server info array into a packed
  254. // RAP server info array
  255. //
  256. typedef
  257. USHORT
  258. (XS_CONVERT_SERVER_ENUM_BUFFER_FUNCTION)(
  259. IN LPVOID ServerEnumBuffer,
  260. IN DWORD EntriesRead,
  261. IN OUT PDWORD TotalEntries,
  262. IN USHORT Level,
  263. OUT LPBYTE ClientBuffer,
  264. IN USHORT BufferLength,
  265. OUT PDWORD EntriesFilled,
  266. OUT PUSHORT Converter
  267. );
  268. extern XS_CONVERT_SERVER_ENUM_BUFFER_FUNCTION XsConvertServerEnumBuffer;
  269. //++
  270. //
  271. // ULONG
  272. // XsSmbGetPointer (
  273. // IN PSMB_ULONG SrcAddress
  274. // )
  275. //
  276. // Routine Description:
  277. //
  278. // This macro retrieves a ULONG value from the possibly misaligned
  279. // source address, avoiding alignment faults.
  280. // This also takes into account the fact that pointers are 8-bytes on 64-bit.
  281. //
  282. // Arguments:
  283. //
  284. // SrcAddress - where to retrieve ULONG value from
  285. //
  286. // Return Value:
  287. //
  288. // ULONG - the value retrieved. The target must be aligned.
  289. //
  290. //--
  291. #if defined (_WIN64)
  292. #define XsSmbGetPointer(SrcAddress) ((LPBYTE)( ((__int64)SmbGetUlong((LPVOID)SrcAddress)) + (((__int64)SmbGetUlong( ( ((LPBYTE)SrcAddress) + 4 ) ) ) << 32) ))
  293. #else
  294. #define XsSmbGetPointer SmbGetUlong
  295. #endif
  296. //++
  297. //
  298. // VOID
  299. // XsSmbPutPointer (
  300. // OUT PSMB_ULONG DestAddress,
  301. // IN LPVOID Value
  302. // )
  303. //
  304. // Routine Description:
  305. //
  306. // This macro stores a POINTER value at the possibly misaligned
  307. // destination address, avoiding alignment faults.
  308. // This also takes into account the fact that 64-bit pointers are 8-bytes
  309. //
  310. // Arguments:
  311. //
  312. // DestAddress - where to store ULONG value
  313. //
  314. // Value - ULONG to store. Value must be a constant or an aligned
  315. // field.
  316. //
  317. // Return Value:
  318. //
  319. // None.
  320. //
  321. //--
  322. #if defined (_WIN64)
  323. #define XsSmbPutPointer(DestAddress64,Value) \
  324. { \
  325. LPDWORD Source = (LPDWORD)(&Value); \
  326. LPDWORD Dest = (LPDWORD)DestAddress64; \
  327. SmbPutUlong( Dest, SmbGetUlong(Source) ); \
  328. SmbPutUlong( Dest+1, SmbGetUlong(Source+1) ); \
  329. }
  330. #else
  331. #define XsSmbPutPointer(DEST,VAL) SmbPutUlong(DEST, (ULONG)VAL)
  332. #endif
  333. #endif // ndef _XSPROCSP_