xref: /reactos/sdk/include/ddk/ntrxdef.h (revision 8a978a17)
1 #ifndef _RX_NTDEFS_DEFINED_
2 #define _RX_NTDEFS_DEFINED_
3 
4 #define INLINE __inline
5 #ifndef INVALID_HANDLE_VALUE
6 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
7 #endif
8 
9 #ifndef MINIRDR__NAME
10 #define RxCaptureFcb PFCB __C_Fcb = (PFCB)(RxContext->pFcb)
11 #define RxCaptureFobx PFOBX __C_Fobx = (PFOBX)(RxContext->pFobx)
12 #else
13 #define RxCaptureFcb PMRX_FCB __C_Fcb = (RxContext->pFcb)
14 #define RxCaptureFobx PMRX_FOBX __C_Fobx = (RxContext->pFobx)
15 #endif
16 
17 #define RxCaptureParamBlock PIO_STACK_LOCATION __C_IrpSp = RxContext->CurrentIrpSp
18 #define RxCaptureFileObject PFILE_OBJECT __C_FileObject = __C_IrpSp-> FileObject
19 
20 #define capFcb __C_Fcb
21 #define capFobx __C_Fobx
22 #define capPARAMS __C_IrpSp
23 #define capFileObject __C_FileObject
24 
25 #define RxAllocatePoolWithTag ExAllocatePoolWithTag
26 #define RxFreePool ExFreePool
27 
28 #define RxIsResourceOwnershipStateExclusive(Resource) (FlagOn((Resource)->Flag, ResourceOwnedExclusive))
29 
30 #define RxMdlIsLocked(Mdl) ((Mdl)->MdlFlags & MDL_PAGES_LOCKED)
31 #define RxMdlSourceIsNonPaged(Mdl) ((Mdl)->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL)
32 
33 #define RxGetRequestorProcess(RxContext) IoGetRequestorProcess(RxContext->CurrentIrp)
34 
35 #define RxAdjustAllocationSizeforCC(Fcb)                                                       \
36 {                                                                                              \
37     if ((Fcb)->Header.FileSize.QuadPart > (Fcb)->Header.AllocationSize.QuadPart)               \
38     {                                                                                          \
39         PMRX_NET_ROOT NetRoot = (Fcb)->pNetRoot;                                               \
40         ULONGLONG ClusterSize = NetRoot->DiskParameters.ClusterSize;                           \
41         ULONGLONG FileSize = (Fcb)->Header.FileSize.QuadPart;                                  \
42         ASSERT(ClusterSize != 0);                                                              \
43         (Fcb)->Header.AllocationSize.QuadPart = (FileSize + ClusterSize) &~ (ClusterSize - 1); \
44     }                                                                                          \
45     ASSERT ((Fcb)->Header.ValidDataLength.QuadPart <= (Fcb)->Header.FileSize.QuadPart);        \
46 }
47 
48 #endif
49