1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 ProbeAndLock.c 8 9 Abstract: 10 11 This module contains C routines for probing and locking 12 down memory buffers. 13 14 15 Author: 16 17 18 19 Environment: 20 21 Kernel mode only 22 23 Revision History: 24 25 --*/ 26 27 // 28 // These routines must be implemented in a C file to avoid problems 29 // with C++ exception handling errors. 30 // 31 32 #include <ntddk.h> 33 #include <pseh/pseh2.h> // __REACTOS__ 34 35 NTSTATUS 36 FxProbeAndLockForRead( 37 __in PMDL Mdl, 38 __in KPROCESSOR_MODE AccessMode 39 ) 40 { 41 _SEH2_TRY 42 { 43 MmProbeAndLockPages(Mdl, AccessMode, IoReadAccess); 44 } 45 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 46 { 47 _SEH2_YIELD(return _SEH2_GetExceptionCode()); 48 } 49 _SEH2_END; 50 51 return STATUS_SUCCESS; 52 } 53 54 NTSTATUS 55 FxProbeAndLockForWrite( 56 __in PMDL Mdl, 57 __in KPROCESSOR_MODE AccessMode 58 ) 59 { 60 _SEH2_TRY 61 { 62 MmProbeAndLockPages(Mdl, AccessMode, IoWriteAccess); 63 } 64 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 65 { 66 _SEH2_YIELD(return _SEH2_GetExceptionCode()); 67 } 68 _SEH2_END; 69 70 return STATUS_SUCCESS; 71 } 72 73 NTSTATUS 74 FxProbeAndLockWithAccess( 75 __in PMDL Mdl, 76 __in KPROCESSOR_MODE AccessMode, 77 __in LOCK_OPERATION Operation 78 ) 79 { 80 _SEH2_TRY 81 { 82 MmProbeAndLockPages(Mdl, AccessMode, Operation); 83 } 84 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 85 { 86 _SEH2_YIELD(return _SEH2_GetExceptionCode()); 87 } 88 _SEH2_END; 89 90 return STATUS_SUCCESS; 91 } 92