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.

915 lines
19 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. smbgtpt.h
  5. Abstract:
  6. This module defines macros for retrieving and storing SMB data.
  7. The macros account for the misaligned nature of the SMB protocol.
  8. They also translate from the little-endian SMB format into
  9. big-endian format, when necessary.
  10. Author:
  11. Chuck Lenzmeier (chuckl) 2-Mar-90
  12. David Treadwell (davditr)
  13. Revision History:
  14. 15-Apr-1991 JohnRo
  15. Include <smbtypes.h>, to define SMBDBG etc.
  16. --*/
  17. #ifndef _SMBGTPT_
  18. #define _SMBGTPT_
  19. #include <smbtypes.h>
  20. //#include <smb.h>
  21. //
  22. // The following macros store and retrieve USHORTS and ULONGS from
  23. // potentially unaligned addresses, avoiding alignment faults. They
  24. // would best be written as inline assembly code.
  25. //
  26. // The macros are designed to be used for accessing SMB fields. Such
  27. // fields are always stored in little-endian byte order, so these macros
  28. // do byte swapping when compiled for a big-endian machine.
  29. //
  30. // !!! Not yet.
  31. //
  32. #if !SMBDBG
  33. #define BYTE_0_MASK 0xFF
  34. #define BYTE_0(Value) (UCHAR)( (Value) & BYTE_0_MASK)
  35. #define BYTE_1(Value) (UCHAR)( ((Value) >> 8) & BYTE_0_MASK)
  36. #define BYTE_2(Value) (UCHAR)( ((Value) >> 16) & BYTE_0_MASK)
  37. #define BYTE_3(Value) (UCHAR)( ((Value) >> 24) & BYTE_0_MASK)
  38. #endif
  39. //++
  40. //
  41. // USHORT
  42. // SmbGetUshort (
  43. // IN PSMB_USHORT SrcAddress
  44. // )
  45. //
  46. // Routine Description:
  47. //
  48. // This macro retrieves a USHORT value from the possibly misaligned
  49. // source address, avoiding alignment faults.
  50. //
  51. // Arguments:
  52. //
  53. // SrcAddress - where to retrieve USHORT value from
  54. //
  55. // Return Value:
  56. //
  57. // USHORT - the value retrieved. The target must be aligned.
  58. //
  59. //--
  60. #if !SMBDBG
  61. #if !SMBDBG1
  62. #if SMB_USE_UNALIGNED
  63. #define SmbGetUshort(SrcAddress) *(PSMB_USHORT)(SrcAddress)
  64. #else
  65. #define SmbGetUshort(SrcAddress) (USHORT)( \
  66. ( ( (PUCHAR)(SrcAddress) )[0] ) | \
  67. ( ( (PUCHAR)(SrcAddress) )[1] << 8 ) \
  68. )
  69. #endif
  70. #else
  71. #define SmbGetUshort(SrcAddress) (USHORT)( \
  72. ( ( (PUCHAR)(SrcAddress ## S) )[0] ) | \
  73. ( ( (PUCHAR)(SrcAddress ## S) )[1] << 8 ) \
  74. )
  75. #endif
  76. #else
  77. USHORT
  78. SmbGetUshort (
  79. IN PSMB_USHORT SrcAddress
  80. );
  81. #endif
  82. //++
  83. //
  84. // USHORT
  85. // SmbGetAlignedUshort (
  86. // IN PUSHORT SrcAddress
  87. // )
  88. //
  89. // Routine Description:
  90. //
  91. // This macro retrieves a USHORT value from the source address,
  92. // correcting for the endian characteristics of the server if
  93. // necessary.
  94. //
  95. // Arguments:
  96. //
  97. // SrcAddress - where to retrieve USHORT value from; must be aligned.
  98. //
  99. // Return Value:
  100. //
  101. // USHORT - the value retrieved. The target must be aligned.
  102. //
  103. //--
  104. #if !SMBDBG
  105. #if !SMBDBG1
  106. #define SmbGetAlignedUshort(SrcAddress) *(SrcAddress)
  107. #else
  108. #define SmbGetAlignedUshort(SrcAddress) *(SrcAddress ## S)
  109. #endif
  110. #else
  111. USHORT
  112. SmbGetAlignedUshort (
  113. IN PUSHORT SrcAddress
  114. );
  115. #endif
  116. //++
  117. //
  118. // VOID
  119. // SmbPutUshort (
  120. // OUT PSMB_USHORT DestAddress,
  121. // IN USHORT Value
  122. // )
  123. //
  124. // Routine Description:
  125. //
  126. // This macro stores a USHORT value at the possibly misaligned
  127. // destination address, avoiding alignment faults.
  128. //
  129. // Arguments:
  130. //
  131. // DestAddress - where to store USHORT value. Address may be
  132. // misaligned.
  133. //
  134. // Value - USHORT to store. Value must be a constant or an aligned
  135. // field.
  136. //
  137. // Return Value:
  138. //
  139. // None.
  140. //
  141. //--
  142. #if !SMBDBG
  143. #if !SMBDBG1
  144. #if SMB_USE_UNALIGNED
  145. #define SmbPutUshort(SrcAddress, Value) \
  146. *(PSMB_USHORT)(SrcAddress) = (Value)
  147. #else
  148. #define SmbPutUshort(DestAddress,Value) { \
  149. ( (PUCHAR)(DestAddress) )[0] = BYTE_0(Value); \
  150. ( (PUCHAR)(DestAddress) )[1] = BYTE_1(Value); \
  151. }
  152. #endif
  153. #else
  154. #define SmbPutUshort(DestAddress,Value) { \
  155. ( (PUCHAR)(DestAddress ## S) )[0] = BYTE_0(Value); \
  156. ( (PUCHAR)(DestAddress ## S) )[1] = BYTE_1(Value); \
  157. }
  158. #endif
  159. #else
  160. VOID
  161. SmbPutUshort (
  162. OUT PSMB_USHORT DestAddress,
  163. IN USHORT Value
  164. );
  165. #endif
  166. //++
  167. //
  168. // VOID
  169. // SmbPutAlignedUshort (
  170. // OUT PUSHORT DestAddres,
  171. // IN USHORT Value
  172. // )
  173. //
  174. // Routine Description:
  175. //
  176. // This macro stores a USHORT value from the source address,
  177. // correcting for the endian characteristics of the server if
  178. // necessary.
  179. //
  180. // Arguments:
  181. //
  182. // DestAddress - where to store USHORT value. Address may not be
  183. // misaligned.
  184. //
  185. // Value - USHORT to store. Value must be a constant or an aligned
  186. // field.
  187. //
  188. // Return Value:
  189. //
  190. // None.
  191. //
  192. //--
  193. #if !SMBDBG
  194. #if !SMBDBG1
  195. #define SmbPutAlignedUshort(DestAddress,Value) *(DestAddress) = (Value)
  196. #else
  197. #define SmbPutAlignedUshort(DestAddress,Value) *(DestAddress ## S) = (Value)
  198. #endif
  199. #else
  200. VOID
  201. SmbPutAlignedUshort (
  202. OUT PUSHORT DestAddress,
  203. IN USHORT Value
  204. );
  205. #endif
  206. //++
  207. //
  208. // VOID
  209. // SmbMoveUshort (
  210. // OUT PSMB_USHORT DestAddress
  211. // IN PSMB_USHORT SrcAddress
  212. // )
  213. //
  214. // Routine Description:
  215. //
  216. // This macro moves a USHORT value from the possibly misaligned
  217. // source address to the possibly misaligned destination address,
  218. // avoiding alignment faults.
  219. //
  220. // Arguments:
  221. //
  222. // DestAddress - where to store USHORT value
  223. //
  224. // SrcAddress - where to retrieve USHORT value from
  225. //
  226. // Return Value:
  227. //
  228. // None.
  229. //
  230. //--
  231. #if !SMBDBG
  232. #if !SMBDBG1
  233. #if SMB_USE_UNALIGNED
  234. #define SmbMoveUshort(DestAddress, SrcAddress) \
  235. *(PSMB_USHORT)(DestAddress) = *(PSMB_USHORT)(SrcAddress)
  236. #else
  237. #define SmbMoveUshort(DestAddress,SrcAddress) { \
  238. ( (PUCHAR)(DestAddress) )[0] = ( (PUCHAR)(SrcAddress) )[0]; \
  239. ( (PUCHAR)(DestAddress) )[1] = ( (PUCHAR)(SrcAddress) )[1]; \
  240. }
  241. #endif
  242. #else
  243. #define SmbMoveUshort(DestAddress,SrcAddress) { \
  244. ( (PUCHAR)(DestAddress ## S) )[0] = ( (PUCHAR)(SrcAddress ## S) )[0]; \
  245. ( (PUCHAR)(DestAddress ## S) )[1] = ( (PUCHAR)(SrcAddress ## S) )[1]; \
  246. }
  247. #endif
  248. #else
  249. VOID
  250. SmbMoveUshort (
  251. OUT PSMB_USHORT DestAddress,
  252. IN PSMB_USHORT SrcAddress
  253. );
  254. #endif
  255. //++
  256. //
  257. // ULONG
  258. // SmbGetUlong (
  259. // IN PSMB_ULONG SrcAddress
  260. // )
  261. //
  262. // Routine Description:
  263. //
  264. // This macro retrieves a ULONG value from the possibly misaligned
  265. // source address, avoiding alignment faults.
  266. //
  267. // Arguments:
  268. //
  269. // SrcAddress - where to retrieve ULONG value from
  270. //
  271. // Return Value:
  272. //
  273. // ULONG - the value retrieved. The target must be aligned.
  274. //
  275. //--
  276. #if !SMBDBG
  277. #if !SMBDBG1
  278. #if SMB_USE_UNALIGNED
  279. #define SmbGetUlong(SrcAddress) *(PSMB_ULONG)(SrcAddress)
  280. #else
  281. #define SmbGetUlong(SrcAddress) (ULONG)( \
  282. ( ( (PUCHAR)(SrcAddress) )[0] ) | \
  283. ( ( (PUCHAR)(SrcAddress) )[1] << 8 ) | \
  284. ( ( (PUCHAR)(SrcAddress) )[2] << 16 ) | \
  285. ( ( (PUCHAR)(SrcAddress) )[3] << 24 ) \
  286. )
  287. #endif
  288. #else
  289. #define SmbGetUlong(SrcAddress) (ULONG)( \
  290. ( ( (PUCHAR)(SrcAddress ## L) )[0] ) | \
  291. ( ( (PUCHAR)(SrcAddress ## L) )[1] << 8 ) | \
  292. ( ( (PUCHAR)(SrcAddress ## L) )[2] << 16 ) | \
  293. ( ( (PUCHAR)(SrcAddress ## L) )[3] << 24 ) \
  294. )
  295. #endif
  296. #else
  297. ULONG
  298. SmbGetUlong (
  299. IN PSMB_ULONG SrcAddress
  300. );
  301. #endif
  302. //++
  303. //
  304. // USHORT
  305. // SmbGetAlignedUlong (
  306. // IN PULONG SrcAddress
  307. // )
  308. //
  309. // Routine Description:
  310. //
  311. // This macro retrieves a ULONG value from the source address,
  312. // correcting for the endian characteristics of the server if
  313. // necessary.
  314. //
  315. // Arguments:
  316. //
  317. // SrcAddress - where to retrieve ULONG value from; must be aligned.
  318. //
  319. // Return Value:
  320. //
  321. // ULONG - the value retrieved. The target must be aligned.
  322. //
  323. //--
  324. #if !SMBDBG
  325. #if !SMBDBG1
  326. #define SmbGetAlignedUlong(SrcAddress) *(SrcAddress)
  327. #else
  328. #define SmbGetAlignedUlong(SrcAddress) *(SrcAddress ## L)
  329. #endif
  330. #else
  331. ULONG
  332. SmbGetAlignedUlong (
  333. IN PULONG SrcAddress
  334. );
  335. #endif
  336. //++
  337. //
  338. // VOID
  339. // SmbPutUlong (
  340. // OUT PSMB_ULONG DestAddress,
  341. // IN ULONG Value
  342. // )
  343. //
  344. // Routine Description:
  345. //
  346. // This macro stores a ULONG value at the possibly misaligned
  347. // destination address, avoiding alignment faults.
  348. //
  349. // Arguments:
  350. //
  351. // DestAddress - where to store ULONG value
  352. //
  353. // Value - ULONG to store. Value must be a constant or an aligned
  354. // field.
  355. //
  356. // Return Value:
  357. //
  358. // None.
  359. //
  360. //--
  361. #if !SMBDBG
  362. #if !SMBDBG1
  363. #if SMB_USE_UNALIGNED
  364. #define SmbPutUlong(SrcAddress, Value) *(PSMB_ULONG)(SrcAddress) = Value
  365. #else
  366. #define SmbPutUlong(DestAddress,Value) { \
  367. ( (PUCHAR)(DestAddress) )[0] = BYTE_0(Value); \
  368. ( (PUCHAR)(DestAddress) )[1] = BYTE_1(Value); \
  369. ( (PUCHAR)(DestAddress) )[2] = BYTE_2(Value); \
  370. ( (PUCHAR)(DestAddress) )[3] = BYTE_3(Value); \
  371. }
  372. #endif
  373. #else
  374. #define SmbPutUlong(DestAddress,Value) { \
  375. ( (PUCHAR)(DestAddress ## L) )[0] = BYTE_0(Value); \
  376. ( (PUCHAR)(DestAddress ## L) )[1] = BYTE_1(Value); \
  377. ( (PUCHAR)(DestAddress ## L) )[2] = BYTE_2(Value); \
  378. ( (PUCHAR)(DestAddress ## L) )[3] = BYTE_3(Value); \
  379. }
  380. #endif
  381. #else
  382. VOID
  383. SmbPutUlong (
  384. OUT PSMB_ULONG DestAddress,
  385. IN ULONG Value
  386. );
  387. #endif
  388. //++
  389. //
  390. // VOID
  391. // SmbPutAlignedUlong (
  392. // OUT PULONG DestAddres,
  393. // IN ULONG Value
  394. // )
  395. //
  396. // Routine Description:
  397. //
  398. // This macro stores a ULONG value from the source address,
  399. // correcting for the endian characteristics of the server if
  400. // necessary.
  401. //
  402. // Arguments:
  403. //
  404. // DestAddress - where to store ULONG value. Address may not be
  405. // misaligned.
  406. //
  407. // Value - ULONG to store. Value must be a constant or an aligned
  408. // field.
  409. //
  410. // Return Value:
  411. //
  412. // None.
  413. //
  414. //--
  415. #if !SMBDBG
  416. #if !SMBDBG1
  417. #define SmbPutAlignedUlong(DestAddress,Value) *(DestAddress) = (Value)
  418. #else
  419. #define SmbPutAlignedUlong(DestAddress,Value) *(DestAddress ## L) = (Value)
  420. #endif
  421. #else
  422. VOID
  423. SmbPutAlignedUlong (
  424. OUT PULONG DestAddress,
  425. IN ULONG Value
  426. );
  427. #endif
  428. //++
  429. //
  430. // VOID
  431. // SmbMoveUlong (
  432. // OUT PSMB_ULONG DestAddress,
  433. // IN PSMB_ULONG SrcAddress
  434. // )
  435. //
  436. // Routine Description:
  437. //
  438. // This macro moves a ULONG value from the possibly misaligned
  439. // source address to the possible misaligned destination address,
  440. // avoiding alignment faults.
  441. //
  442. // Arguments:
  443. //
  444. // DestAddress - where to store ULONG value
  445. //
  446. // SrcAddress - where to retrieve ULONG value from
  447. //
  448. // Return Value:
  449. //
  450. // None.
  451. //
  452. //--
  453. #if !SMBDBG
  454. #if !SMBDBG1
  455. #if SMB_USE_UNALIGNED
  456. #define SmbMoveUlong(DestAddress,SrcAddress) \
  457. *(PSMB_ULONG)(DestAddress) = *(PSMB_ULONG)(SrcAddress)
  458. #else
  459. #define SmbMoveUlong(DestAddress,SrcAddress) { \
  460. ( (PUCHAR)(DestAddress) )[0] = ( (PUCHAR)(SrcAddress) )[0]; \
  461. ( (PUCHAR)(DestAddress) )[1] = ( (PUCHAR)(SrcAddress) )[1]; \
  462. ( (PUCHAR)(DestAddress) )[2] = ( (PUCHAR)(SrcAddress) )[2]; \
  463. ( (PUCHAR)(DestAddress) )[3] = ( (PUCHAR)(SrcAddress) )[3]; \
  464. }
  465. #endif
  466. #else
  467. #define SmbMoveUlong(DestAddress,SrcAddress) { \
  468. ( (PUCHAR)(DestAddress ## L) )[0] = ( (PUCHAR)(SrcAddress ## L) )[0]; \
  469. ( (PUCHAR)(DestAddress ## L) )[1] = ( (PUCHAR)(SrcAddress ## L) )[1]; \
  470. ( (PUCHAR)(DestAddress ## L) )[2] = ( (PUCHAR)(SrcAddress ## L) )[2]; \
  471. ( (PUCHAR)(DestAddress ## L) )[3] = ( (PUCHAR)(SrcAddress ## L) )[3]; \
  472. }
  473. #endif
  474. #else
  475. VOID
  476. SmbMoveUlong (
  477. OUT PSMB_ULONG DestAddress,
  478. IN PSMB_ULONG SrcAddress
  479. );
  480. #endif
  481. //++
  482. //
  483. // VOID
  484. // SmbPutDate (
  485. // OUT PSMB_DATE DestAddress,
  486. // IN SMB_DATE Value
  487. // )
  488. //
  489. // Routine Description:
  490. //
  491. // This macro stores an SMB_DATE value at the possibly misaligned
  492. // destination address, avoiding alignment faults. This macro
  493. // is different from SmbPutUshort in order to be able to handle
  494. // funny bitfield / big-endian interactions.
  495. //
  496. // Arguments:
  497. //
  498. // DestAddress - where to store SMB_DATE value
  499. //
  500. // Value - SMB_DATE to store. Value must be a constant or an
  501. // aligned field.
  502. //
  503. // Return Value:
  504. //
  505. // None.
  506. //
  507. //--
  508. #if !SMBDBG
  509. #if SMB_USE_UNALIGNED
  510. #define SmbPutDate(DestAddress,Value) (DestAddress)->Ushort = (Value).Ushort
  511. #else
  512. #define SmbPutDate(DestAddress,Value) { \
  513. ( (PUCHAR)&(DestAddress)->Ushort )[0] = BYTE_0((Value).Ushort); \
  514. ( (PUCHAR)&(DestAddress)->Ushort )[1] = BYTE_1((Value).Ushort); \
  515. }
  516. #endif
  517. #else
  518. VOID
  519. SmbPutDate (
  520. OUT PSMB_DATE DestAddress,
  521. IN SMB_DATE Value
  522. );
  523. #endif
  524. //++
  525. //
  526. // VOID
  527. // SmbMoveDate (
  528. // OUT PSMB_DATE DestAddress,
  529. // IN PSMB_DATE SrcAddress
  530. // )
  531. //
  532. // Routine Description:
  533. //
  534. // This macro copies an SMB_DATE value from the possibly misaligned
  535. // source address, avoiding alignment faults. This macro is
  536. // different from SmbGetUshort in order to be able to handle funny
  537. // bitfield / big-endian interactions.
  538. //
  539. // Note that there is no SmbGetDate because of the way SMB_DATE is
  540. // defined. It is a union containing a USHORT and a bitfield
  541. // struct. The caller of an SmbGetDate macro would have to
  542. // explicitly use one part of the union.
  543. //
  544. // Arguments:
  545. //
  546. // DestAddress - where to store SMB_DATE value. MUST BE ALIGNED!
  547. //
  548. // SrcAddress - where to retrieve SMB_DATE value from
  549. //
  550. // Return Value:
  551. //
  552. // None.
  553. //
  554. //--
  555. #if !SMBDBG
  556. #if SMB_USE_UNALIGNED
  557. #define SmbMoveDate(DestAddress,SrcAddress) \
  558. (DestAddress)->Ushort = (SrcAddress)->Ushort
  559. #else
  560. #define SmbMoveDate(DestAddress,SrcAddress) \
  561. (DestAddress)->Ushort = \
  562. ( ( (PUCHAR)&(SrcAddress)->Ushort )[0] ) | \
  563. ( ( (PUCHAR)&(SrcAddress)->Ushort )[1] << 8 )
  564. #endif
  565. #else
  566. VOID
  567. SmbMoveDate (
  568. OUT PSMB_DATE DestAddress,
  569. IN PSMB_DATE SrcAddress
  570. );
  571. #endif
  572. //++
  573. //
  574. // VOID
  575. // SmbZeroDate (
  576. // IN PSMB_DATE Date
  577. // )
  578. //
  579. // Routine Description:
  580. //
  581. // This macro zeroes a possibly misaligned SMB_DATE field.
  582. //
  583. // Arguments:
  584. //
  585. // Date - Pointer to SMB_DATE field to zero.
  586. //
  587. // Return Value:
  588. //
  589. // None.
  590. //
  591. //--
  592. #if !SMBDBG
  593. #if SMB_USE_UNALIGNED
  594. #define SmbZeroDate(Date) (Date)->Ushort = 0
  595. #else
  596. #define SmbZeroDate(Date) { \
  597. ( (PUCHAR)&(Date)->Ushort )[0] = 0; \
  598. ( (PUCHAR)&(Date)->Ushort )[1] = 0; \
  599. }
  600. #endif
  601. #else
  602. VOID
  603. SmbZeroDate (
  604. IN PSMB_DATE Date
  605. );
  606. #endif
  607. //++
  608. //
  609. // BOOLEAN
  610. // SmbIsDateZero (
  611. // IN PSMB_DATE Date
  612. // )
  613. //
  614. // Routine Description:
  615. //
  616. // This macro returns TRUE if the supplied SMB_DATE value is zero.
  617. //
  618. // Arguments:
  619. //
  620. // Date - Pointer to SMB_DATE value to check. MUST BE ALIGNED!
  621. //
  622. // Return Value:
  623. //
  624. // BOOLEAN - TRUE if Date is zero, else FALSE.
  625. //
  626. //--
  627. #if !SMBDBG
  628. #define SmbIsDateZero(Date) ( (Date)->Ushort == 0 )
  629. #else
  630. BOOLEAN
  631. SmbIsDateZero (
  632. IN PSMB_DATE Date
  633. );
  634. #endif
  635. //++
  636. //
  637. // VOID
  638. // SmbPutTime (
  639. // OUT PSMB_TIME DestAddress,
  640. // IN SMB_TIME Value
  641. // )
  642. //
  643. // Routine Description:
  644. //
  645. // This macro stores an SMB_TIME value at the possibly misaligned
  646. // destination address, avoiding alignment faults. This macro
  647. // is different from SmbPutUshort in order to be able to handle
  648. // funny bitfield / big-endian interactions.
  649. //
  650. // Arguments:
  651. //
  652. // DestAddress - where to store SMB_TIME value
  653. //
  654. // Value - SMB_TIME to store. Value must be a constant or an
  655. // aligned field.
  656. //
  657. // Return Value:
  658. //
  659. // None.
  660. //
  661. //--
  662. #if !SMBDBG
  663. #if SMB_USE_UNALIGNED
  664. #define SmbPutTime(DestAddress,Value) (DestAddress)->Ushort = (Value).Ushort
  665. #else
  666. #define SmbPutTime(DestAddress,Value) { \
  667. ( (PUCHAR)&(DestAddress)->Ushort )[0] = BYTE_0((Value).Ushort); \
  668. ( (PUCHAR)&(DestAddress)->Ushort )[1] = BYTE_1((Value).Ushort); \
  669. }
  670. #endif
  671. #else
  672. VOID
  673. SmbPutTime (
  674. OUT PSMB_TIME DestAddress,
  675. IN SMB_TIME Value
  676. );
  677. #endif
  678. //++
  679. //
  680. // VOID
  681. // SmbMoveTime (
  682. // OUT PSMB_TIME DestAddress,
  683. // IN PSMB_TIME SrcAddress
  684. // )
  685. //
  686. // Routine Description:
  687. //
  688. // This macro copies an SMB_TIME value from the possibly
  689. // misaligned source address, avoiding alignment faults. This macro
  690. // is different from SmbGetUshort in order to be able to handle
  691. // funny bitfield / big-endian interactions.
  692. //
  693. // Note that there is no SmbGetTime because of the way SMB_TIME is
  694. // defined. It is a union containing a USHORT and a bitfield
  695. // struct. The caller of an SmbGetTime macro would have to
  696. // explicitly use one part of the union.
  697. //
  698. // Arguments:
  699. //
  700. // DestAddress - where to store SMB_TIME value. MUST BE ALIGNED!
  701. //
  702. // SrcAddress - where to retrieve SMB_TIME value from
  703. //
  704. // Return Value:
  705. //
  706. // None.
  707. //
  708. //--
  709. #if !SMBDBG
  710. #if SMB_USE_UNALIGNED
  711. #define SmbMoveTime(DestAddress,SrcAddress) \
  712. (DestAddress)->Ushort = (SrcAddress)->Ushort
  713. #else
  714. #define SmbMoveTime(DestAddress,SrcAddress) \
  715. (DestAddress)->Ushort = \
  716. ( ( (PUCHAR)&(SrcAddress)->Ushort )[0] ) | \
  717. ( ( (PUCHAR)&(SrcAddress)->Ushort )[1] << 8 )
  718. #endif
  719. #else
  720. VOID
  721. SmbMoveTime (
  722. OUT PSMB_TIME DestAddress,
  723. IN PSMB_TIME SrcAddress
  724. );
  725. #endif
  726. //++
  727. //
  728. // VOID
  729. // SmbZeroTime (
  730. // IN PSMB_TIME Time
  731. // )
  732. //
  733. // Routine Description:
  734. //
  735. // This macro zeroes a possibly misaligned SMB_TIME field.
  736. //
  737. // Arguments:
  738. //
  739. // Time - Pointer to SMB_TIME field to zero.
  740. //
  741. // Return Value:
  742. //
  743. // None.
  744. //
  745. //--
  746. #if !SMBDBG
  747. #if SMB_USE_UNALIGNED
  748. #define SmbZeroTime(Time) (Time)->Ushort = 0
  749. #else
  750. #define SmbZeroTime(Time) { \
  751. ( (PUCHAR)&(Time)->Ushort )[0] = 0; \
  752. ( (PUCHAR)&(Time)->Ushort )[1] = 0; \
  753. }
  754. #endif
  755. #else
  756. VOID
  757. SmbZeroTime (
  758. IN PSMB_TIME Time
  759. );
  760. #endif
  761. //++
  762. //
  763. // BOOLEAN
  764. // SmbIsTimeZero (
  765. // IN PSMB_TIME Time
  766. // )
  767. //
  768. // Routine Description:
  769. //
  770. // This macro returns TRUE if the supplied SMB_TIME value is zero.
  771. //
  772. // Arguments:
  773. //
  774. // Time - Pointer to SMB_TIME value to check. Must be aligned and
  775. // in native format!
  776. //
  777. // Return Value:
  778. //
  779. // BOOLEAN - TRUE if Time is zero, else FALSE.
  780. //
  781. //--
  782. #if !SMBDBG
  783. #define SmbIsTimeZero(Time) ( (Time)->Ushort == 0 )
  784. #else
  785. BOOLEAN
  786. SmbIsTimeZero (
  787. IN PSMB_TIME Time
  788. );
  789. #endif
  790. #endif // def _SMBGTPT_