Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

probe.c File Reference

#include "exp.h"

Go to the source code of this file.

Functions

VOID ProbeForWrite (IN PVOID Address, IN ULONG Length, IN ULONG Alignment)
NTKERNELAPI VOID NTAPI ProbeForRead (IN CONST VOID *Address, IN ULONG Length, IN ULONG Alignment)


Function Documentation

NTKERNELAPI VOID NTAPI ProbeForRead IN CONST VOID *  Address,
IN ULONG  Length,
IN ULONG  Alignment
 

Definition at line 148 of file probe.c.

References ASSERT, ExRaiseAccessViolation(), ExRaiseDatatypeMisalignment(), and PAGED_CODE.

00156 : 00157 00158 This function probes a structure for read accessibility and ensures 00159 correct alignment of the structure. If the structure is not accessible 00160 or has incorrect alignment, then an exception is raised. 00161 00162 Arguments: 00163 00164 Address - Supplies a pointer to the structure to be probed. 00165 00166 Length - Supplies the length of the structure. 00167 00168 Alignment - Supplies the required alignment of the structure expressed 00169 as the number of bytes in the primitive datatype (e.g., 1 for char, 00170 2 for short, 4 for long, and 8 for quad). 00171 00172 Return Value: 00173 00174 None. 00175 00176 --*/ 00177 { 00178 PAGED_CODE(); 00179 00180 ASSERT(((Alignment) == 1) || ((Alignment) == 2) || 00181 ((Alignment) == 4) || ((Alignment) == 8) || 00182 ((Alignment) == 16)); 00183 00184 if ((Length) != 0) { 00185 if (((ULONG_PTR)(Address) & ((Alignment) - 1)) != 0) { 00186 ExRaiseDatatypeMisalignment(); 00187 00188 } else if ((((ULONG_PTR)(Address) + (Length)) < (ULONG_PTR)(Address)) || 00189 (((ULONG_PTR)(Address) + (Length)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { 00190 ExRaiseAccessViolation(); 00191 } 00192 } 00193 }

VOID ProbeForWrite IN PVOID  Address,
IN ULONG  Length,
IN ULONG  Alignment
 

Definition at line 34 of file probe.c.

References ASSERT, CHAR, ExRaiseAccessViolation(), ExRaiseDatatypeMisalignment(), and PAGE_SIZE.

Referenced by _GetWinStationInfo(), BuildQueryDirectoryIrp(), GetHDevName(), IopXxxControlFile(), KdpTrap(), KeRaiseUserException(), KeUserModeCallback(), KiDispatchException(), KiEmulateByteWord(), KiEmulateReference(), KiInitializeUserApc(), LpcpCopyRequestData(), MESSAGECALL(), MiDoMappedCopy(), MiDoPoolCopy(), MmSecureVirtualMemory(), NtAcceptConnectPort(), NtAdjustGroupsToken(), NtAdjustPrivilegesToken(), NtAllocateLocallyUniqueId(), NtAllocateUserPhysicalPages(), NtAllocateUuids(), NtCreateProfile(), NtCreateThread(), NtEnumerateKey(), NtEnumerateValueKey(), NtExtendSection(), NtGetContextThread(), NtMapViewOfSection(), NtMapViewOfSuperSection(), NtNotifyChangeDirectoryFile(), NtNotifyChangeMultipleKeys(), NtPrivilegeCheck(), NtQueryAttributesFile(), NtQueryDirectoryObject(), NtQueryEaFile(), NtQueryEvent(), NtQueryFullAttributesFile(), NtQueryInformationAtom(), NtQueryInformationFile(), NtQueryInformationJobObject(), NtQueryInformationPort(), NtQueryInformationProcess(), NtQueryInformationThread(), NtQueryInformationToken(), NtQueryIoCompletion(), NtQueryKey(), NtQueryMultipleValueKey(), NtQueryMutant(), NtQueryObject(), NtQueryPerformanceCounter(), NtQueryQuotaInformationFile(), NtQuerySection(), NtQuerySecurityObject(), NtQuerySemaphore(), NtQuerySymbolicLinkObject(), NtQuerySystemEnvironmentValue(), NtQuerySystemInformation(), NtQueryTimer(), NtQueryVirtualMemory(), NtQueryVolumeInformationFile(), NtReadFile(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtReplyWaitReplyPort(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtSystemDebugControl(), NtUserBuildNameList(), NtUserConsoleControl(), NtUserCreateLocalMemHandle(), NtUserDdeGetQualityOfService(), NtUserDdeSetQualityOfService(), NtUserDrawIconEx(), NtUserGetAltTabInfo(), NtUserGetClassInfo(), NtUserGetClassName(), NtUserGetComboBoxInfo(), NtUserGetCursorInfo(), NtUserGetGUIThreadInfo(), NtUserGetIconInfo(), NtUserGetImeInfoEx(), NtUserGetKeyboardLayoutName(), NtUserGetKeyboardState(), NtUserGetMenuBarInfo(), NtUserGetObjectInformation(), NtUserGetScrollBarInfo(), NtUserGetTitleBarInfo(), NtUserHardErrorControl(), NtUserOpenWindowStation(), NtUserProcessConnect(), NtUserQueryInformationThread(), NtUserQueryUserCounters(), NtUserSetInformationThread(), NtUserSystemParametersInfo(), NtUserWin32PoolAllocationStats(), SeAccessCheckByType(), SepAccessCheckAndAuditAlarm(), VdmDispatchInterrupts(), VdmpInitialize(), VdmpPrinterDirectIoClose(), VdmpPrinterInitialize(), VdmQueryDirectoryFile(), xxxCreateDefaultImeWindow(), and xxxSendMessageEx().

00042 : 00043 00044 This function probes a structure for write accessibility and ensures 00045 correct alignment of the structure. If the structure is not accessible 00046 or has incorrect alignment, then an exception is raised. 00047 00048 Arguments: 00049 00050 Address - Supplies a pointer to the structure to be probed. 00051 00052 Length - Supplies the length of the structure. 00053 00054 Alignment - Supplies the required alignment of the structure expressed 00055 as the number of bytes in the primitive datatype (e.g., 1 for char, 00056 2 for short, 4 for long, and 8 for quad). 00057 00058 Return Value: 00059 00060 None. 00061 00062 --*/ 00063 00064 { 00065 00066 ULONG_PTR EndAddress; 00067 ULONG_PTR StartAddress; 00068 00069 // 00070 // If the structure has zero length, then do not probe the structure for 00071 // write accessibility or alignment. 00072 // 00073 00074 if (Length != 0) { 00075 00076 // 00077 // If the structure is not properly aligned, then raise a data 00078 // misalignment exception. 00079 // 00080 00081 ASSERT((Alignment == 1) || (Alignment == 2) || 00082 (Alignment == 4) || (Alignment == 8) || 00083 (Alignment == 16)); 00084 00085 StartAddress = (ULONG_PTR)Address; 00086 if ((StartAddress & (Alignment - 1)) == 0) { 00087 00088 // 00089 // Compute the ending address of the structure and probe for 00090 // write accessibility. 00091 // 00092 00093 EndAddress = StartAddress + Length - 1; 00094 if ((StartAddress <= EndAddress) && 00095 (EndAddress < MM_USER_PROBE_ADDRESS)) { 00096 00097 // 00098 // N.B. Only the contents of the buffer may be probed. 00099 // Therefore the starting byte is probed for the 00100 // first page, and then the first byte in the page 00101 // for each succeeding page. 00102 // 00103 00104 EndAddress = (EndAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00105 00106 #if defined(_ALPHA_) 00107 00108 // 00109 // N.B. The address is truncated to a longword aligned 00110 // address since Alpha has no load or store byte 00111 // instructions. 00112 // 00113 00114 StartAddress &= ~((ULONG_PTR)sizeof(LONG) - 1); 00115 00116 do { 00117 *(volatile LONG *)StartAddress = *(volatile LONG *)StartAddress; 00118 StartAddress = (StartAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00119 } while (StartAddress != EndAddress); 00120 00121 #else 00122 00123 do { 00124 *(volatile CHAR *)StartAddress = *(volatile CHAR *)StartAddress; 00125 00126 StartAddress = (StartAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00127 } while (StartAddress != EndAddress); 00128 #endif 00129 00130 return; 00131 00132 } else { 00133 ExRaiseAccessViolation(); 00134 } 00135 00136 } else { 00137 ExRaiseDatatypeMisalignment(); 00138 } 00139 } 00140 00141 return; 00142 }


Generated on Sat May 15 19:45:18 2004 for test by doxygen 1.3.7