From 4beaf120e736ca4f5864d74a8021d35a462e7f6f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Mar 2015 00:09:20 +0000 Subject: [PATCH] [DDK/XDK] - Fix some prototypes in wdm.h (PMDLX -> PMDL) - Fix annotations for ExFreePool(WithTag) svn path=/trunk/; revision=66636 --- reactos/include/ddk/wdm.h | 22 +++++++++++----------- reactos/include/xdk/exfuncs.h | 4 ++-- reactos/include/xdk/mmfuncs.h | 18 +++++++++--------- reactos/win32ss/gdi/eng/mem.c | 26 +++++++++++++++++--------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 74aac33f7cb..4b2108a474e 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -11593,7 +11593,7 @@ NTKERNELAPI VOID NTAPI MmBuildMdlForNonPagedPool( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); //DECLSPEC_DEPRECATED_DDK NTKERNELAPI @@ -11626,7 +11626,7 @@ NTKERNELAPI VOID NTAPI MmFreePagesFromMdl( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_(PASSIVE_LEVEL) NTKERNELAPI @@ -11681,7 +11681,7 @@ NTKERNELAPI PVOID NTAPI MmMapLockedPagesSpecifyCache( - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ __drv_strictType(KPROCESSOR_MODE/enum _MODE,__drv_typeConst) KPROCESSOR_MODE AccessMode, _In_ __drv_strictTypeMatch(__drv_typeCond) MEMORY_CACHING_TYPE CacheType, @@ -11703,7 +11703,7 @@ NTKERNELAPI VOID NTAPI MmProbeAndLockPages( - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ KPROCESSOR_MODE AccessMode, _In_ LOCK_OPERATION Operation); @@ -11738,7 +11738,7 @@ NTKERNELAPI VOID NTAPI MmUnlockPages( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_(DISPATCH_LEVEL) NTKERNELAPI @@ -11789,7 +11789,7 @@ NTKERNELAPI NTSTATUS NTAPI MmAdvanceMdl( - _Inout_ PMDLX Mdl, + _Inout_ PMDL Mdl, _In_ ULONG NumberOfBytes); _Must_inspect_result_ @@ -11829,7 +11829,7 @@ NTAPI MmMapLockedPagesWithReservedMapping( _In_ PVOID MappingAddress, _In_ ULONG PoolTag, - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ __drv_strictTypeMatch(__drv_typeCond) MEMORY_CACHING_TYPE CacheType); @@ -11839,7 +11839,7 @@ NTKERNELAPI NTSTATUS NTAPI MmProtectMdlSystemAddress( - _In_ PMDLX MemoryDescriptorList, + _In_ PMDL MemoryDescriptorList, _In_ ULONG NewProtect); _IRQL_requires_max_(DISPATCH_LEVEL) @@ -11849,7 +11849,7 @@ NTAPI MmUnmapReservedMapping( _In_ PVOID BaseAddress, _In_ ULONG PoolTag, - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_ (APC_LEVEL) NTKERNELAPI @@ -14799,14 +14799,14 @@ NTKERNELAPI VOID NTAPI ExFreePool( - _In_ __drv_freesMem(Mem) PVOID P); + _Pre_notnull_ __drv_freesMem(Mem) PVOID P); _IRQL_requires_max_(DISPATCH_LEVEL) NTKERNELAPI VOID NTAPI ExFreePoolWithTag( - _In_ __drv_freesMem(Mem) PVOID P, + _Pre_notnull_ __drv_freesMem(Mem) PVOID P, _In_ ULONG Tag); _IRQL_requires_max_(DISPATCH_LEVEL) diff --git a/reactos/include/xdk/exfuncs.h b/reactos/include/xdk/exfuncs.h index 503c07a7145..86b8335d820 100644 --- a/reactos/include/xdk/exfuncs.h +++ b/reactos/include/xdk/exfuncs.h @@ -606,14 +606,14 @@ NTKERNELAPI VOID NTAPI ExFreePool( - _In_ __drv_freesMem(Mem) PVOID P); + _Pre_not __drv_freesMem(Mem) PVOID P); _IRQL_requires_max_(DISPATCH_LEVEL) NTKERNELAPI VOID NTAPI ExFreePoolWithTag( - _In_ __drv_freesMem(Mem) PVOID P, + _Pre_not __drv_freesMem(Mem) PVOID P, _In_ ULONG Tag); _IRQL_requires_max_(DISPATCH_LEVEL) diff --git a/reactos/include/xdk/mmfuncs.h b/reactos/include/xdk/mmfuncs.h index 9a2fd1ecccb..d8a18fb9a42 100644 --- a/reactos/include/xdk/mmfuncs.h +++ b/reactos/include/xdk/mmfuncs.h @@ -232,7 +232,7 @@ NTKERNELAPI VOID NTAPI MmBuildMdlForNonPagedPool( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); //DECLSPEC_DEPRECATED_DDK NTKERNELAPI @@ -265,7 +265,7 @@ NTKERNELAPI VOID NTAPI MmFreePagesFromMdl( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_(PASSIVE_LEVEL) NTKERNELAPI @@ -320,7 +320,7 @@ NTKERNELAPI PVOID NTAPI MmMapLockedPagesSpecifyCache( - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ __drv_strictType(KPROCESSOR_MODE/enum _MODE,__drv_typeConst) KPROCESSOR_MODE AccessMode, _In_ __drv_strictTypeMatch(__drv_typeCond) MEMORY_CACHING_TYPE CacheType, @@ -342,7 +342,7 @@ NTKERNELAPI VOID NTAPI MmProbeAndLockPages( - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ KPROCESSOR_MODE AccessMode, _In_ LOCK_OPERATION Operation); @@ -377,7 +377,7 @@ NTKERNELAPI VOID NTAPI MmUnlockPages( - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_(DISPATCH_LEVEL) NTKERNELAPI @@ -629,7 +629,7 @@ NTKERNELAPI NTSTATUS NTAPI MmAdvanceMdl( - _Inout_ PMDLX Mdl, + _Inout_ PMDL Mdl, _In_ ULONG NumberOfBytes); _Must_inspect_result_ @@ -669,7 +669,7 @@ NTAPI MmMapLockedPagesWithReservedMapping( _In_ PVOID MappingAddress, _In_ ULONG PoolTag, - _Inout_ PMDLX MemoryDescriptorList, + _Inout_ PMDL MemoryDescriptorList, _In_ __drv_strictTypeMatch(__drv_typeCond) MEMORY_CACHING_TYPE CacheType); @@ -679,7 +679,7 @@ NTKERNELAPI NTSTATUS NTAPI MmProtectMdlSystemAddress( - _In_ PMDLX MemoryDescriptorList, + _In_ PMDL MemoryDescriptorList, _In_ ULONG NewProtect); _IRQL_requires_max_(DISPATCH_LEVEL) @@ -689,7 +689,7 @@ NTAPI MmUnmapReservedMapping( _In_ PVOID BaseAddress, _In_ ULONG PoolTag, - _Inout_ PMDLX MemoryDescriptorList); + _Inout_ PMDL MemoryDescriptorList); _IRQL_requires_max_ (APC_LEVEL) NTKERNELAPI diff --git a/reactos/win32ss/gdi/eng/mem.c b/reactos/win32ss/gdi/eng/mem.c index 26f9aec6fc1..ce4dee7c751 100644 --- a/reactos/win32ss/gdi/eng/mem.c +++ b/reactos/win32ss/gdi/eng/mem.c @@ -14,16 +14,20 @@ /* * @implemented */ +_Must_inspect_result_ +_When_(fl & FL_ZERO_MEMORY, _Ret_opt_bytecount_(cjMemSize)) +_When_(!(fl & FL_ZERO_MEMORY), _Ret_opt_bytecap_(cjMemSize)) +ENGAPI PVOID APIENTRY EngAllocMem( - ULONG Flags, - ULONG cjMemSize, - ULONG ulTag) + _In_ ULONG fl, + _In_ ULONG cjMemSize, + _In_ ULONG ulTag) { PVOID pvBaseAddress; - pvBaseAddress = ExAllocatePoolWithTag((Flags & FL_NONPAGED_MEMORY) ? + pvBaseAddress = ExAllocatePoolWithTag((fl & FL_NONPAGED_MEMORY) ? NonPagedPool : PagedPool, cjMemSize, ulTag); @@ -31,7 +35,7 @@ EngAllocMem( if (pvBaseAddress == NULL) return NULL; - if (Flags & FL_ZERO_MEMORY) + if (fl & FL_ZERO_MEMORY) RtlZeroMemory(pvBaseAddress, cjMemSize); return pvBaseAddress; @@ -55,9 +59,14 @@ EngFreeMem(PVOID pvBaseAddress) /* * @implemented */ +_Must_inspect_result_ +_Ret_opt_bytecount_(cjMemSize) +ENGAPI PVOID APIENTRY -EngAllocUserMem(SIZE_T cjSize, ULONG ulTag) +EngAllocUserMem( + _In_ SIZE_T cjMemSize, + _In_ ULONG ulTag) { PVOID pvBaseAddress = NULL; NTSTATUS Status; @@ -65,7 +74,7 @@ EngAllocUserMem(SIZE_T cjSize, ULONG ulTag) Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &pvBaseAddress, 0, - &cjSize, + &cjMemSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); @@ -77,7 +86,7 @@ EngAllocUserMem(SIZE_T cjSize, ULONG ulTag) /* TODO: Add allocation info to AVL tree (stored inside W32PROCESS structure) */ //hSecure = EngSecureMem(pvBaseAddress, cj); - return pvBaseAddress; + return pvBaseAddress; } /* @@ -97,7 +106,6 @@ EngFreeUserMem(PVOID pvBaseAddress) /* TODO: Remove allocation info from AVL tree */ } - PVOID APIENTRY HackSecureVirtualMemory(