ReactOS  r76032
exintrin.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for exintrin.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define H2I(Port)   PtrToUshort(Port)
 

Functions

LONG FASTCALL InterlockedIncrement (IN LONG volatile *Addend)
 
LONG FASTCALL InterlockedDecrement (IN LONG volatile *Addend)
 
LONG FASTCALL InterlockedCompareExchange (IN OUT LONG volatile *Destination, IN LONG Exchange, IN LONG Comperand)
 
LONG FASTCALL InterlockedExchange (IN OUT LONG volatile *Destination, IN LONG Value)
 
LONG FASTCALL InterlockedExchangeAdd (IN OUT LONG volatile *Addend, IN LONG Increment)
 
VOID NTAPI ProbeForRead (IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
 
VOID NTAPI ProbeForWrite (IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
 

Macro Definition Documentation

#define H2I (   Port)    PtrToUshort(Port)

Definition at line 24 of file exintrin.c.

#define NDEBUG

Definition at line 12 of file exintrin.c.

Function Documentation

LONG FASTCALL InterlockedCompareExchange ( IN OUT LONG volatile Destination,
IN LONG  Exchange,
IN LONG  Comperand 
)

Definition at line 59 of file exintrin.c.

62 {
63  //
64  // Call the intrinsic
65  //
66  return _InterlockedCompareExchange(Destination, Exchange, Comperand);
67 }
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
LONG FASTCALL InterlockedDecrement ( IN LONG volatile Addend)

Definition at line 46 of file exintrin.c.

47 {
48  //
49  // Call the intrinsic
50  //
52 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
LONG FASTCALL InterlockedExchange ( IN OUT LONG volatile Destination,
IN LONG  Value 
)

Definition at line 74 of file exintrin.c.

76 {
77  //
78  // Call the intrinsic
79  //
81 }
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
UINTN UINT8 Value
Definition: acefiex.h:751
LONG FASTCALL InterlockedExchangeAdd ( IN OUT LONG volatile Addend,
IN LONG  Increment 
)

Definition at line 88 of file exintrin.c.

90 {
91  //
92  // Call the intrinsic
93  //
95 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
LONG FASTCALL InterlockedIncrement ( IN LONG volatile Addend)

Definition at line 33 of file exintrin.c.

34 {
35  //
36  // Call the intrinsic
37  //
39 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
VOID NTAPI ProbeForRead ( IN CONST VOID Address,
IN SIZE_T  Length,
IN ULONG  Alignment 
)

Definition at line 102 of file exintrin.c.

Referenced by _IRQL_requires_max_(), _Success_(), AcpiOsReadable(), ApphelpValidateData(), BuildAndSubmitIrp(), co_IntCallDebugHook(), co_IntClientLoadLibrary(), co_IntLoadSysMenuTemplate(), co_UserCallNextHookEx(), DbgkpPostFakeModuleMessages(), DefaultSetInfoBufferCheck(), DetermineACLSize(), DetermineSIDSize(), EngSecureMemForRead(), Ext2GetRetrievalPointers(), GetVolumeBitmap(), IntDefWindowProc(), IopCaptureUnicodeString(), IopCreateFile(), IopDeviceFsIoControl(), IopGetInterfaceDeviceList(), KdpPrint(), KdpPrompt(), KiContinuePreviousModeUser(), KiRaiseException(), KiTrap0EHandler(), KsAcquireResetValue(), KsFastMethodHandler(), KsFastPropertyHandler(), KspEnableEvent(), KspPropertyHandler(), KsProbeStreamIrp(), KsSetInformationFile(), KsWriteFile(), LpcpCopyRequestData(), LpcpCreatePort(), MiDoMappedCopy(), MiDoPoolCopy(), MmCreatePeb(), NpTransceive(), NtAcceptConnectPort(), NtAccessCheck(), NtAddAtom(), NtAdjustPrivilegesToken(), NtCreateKey(), NtCreateSymbolicLinkObject(), NtCreateThread(), NtCreateToken(), NtDebugContinue(), NtFindAtom(), NtGdiAddFontMemResourceEx(), NtGdiAddFontResourceW(), NtGdiCombineTransform(), NtGdiCreateBitmap(), NtGdiCreateColorSpace(), NtGdiCreateDIBBrush(), NtGdiCreateDIBitmapInternal(), NtGdiCreateDIBSection(), NtGdiCreatePaletteInternal(), NtGdiDoPalette(), NtGdiEngAlphaBlend(), NtGdiEngBitBlt(), NtGdiEngStretchBlt(), NtGdiExtCreatePen(), NtGdiExtCreateRegion(), NtGdiExtEscape(), NtGdiExtTextOutW(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtGdiGetFontData(), NtGdiGetFontResourceInfoInternalW(), NtGdiGetGlyphIndicesW(), NtGdiGradientFill(), NtGdiHfontCreate(), NtGdiModifyWorldTransform(), NtGdiOpenDCW(), NtGdiPolyPatBlt(), NtGdiPolyPolyDraw(), NtGdiRectInRegion(), NtGdiRectVisible(), NtGdiSetBitmapBits(), NtGdiSetBoundsRect(), NtGdiSetDeviceGammaRamp(), NtGdiSetDIBitsToDeviceInternal(), NtGdiStretchDIBitsInternal(), NtGdiTransformPoints(), NtImpersonateClientOfPort(), NtImpersonateThread(), NtLockProductActivationKeys(), NtOpenKey(), NtOpenObjectAuditAlarm(), NtOpenProcess(), NtOpenThread(), NtPowerInformation(), NtPrivilegedServiceAuditAlarm(), NtQueryDirectoryFile(), NtQueryInformationProcess(), NtQueryOpenSubKeys(), NtQuerySystemEnvironmentValue(), NtRaiseHardError(), NtReplyPort(), NtReplyWaitReceivePortEx(), NtRequestPort(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtSetInformationFile(), NtSetInformationObject(), NtSetInformationToken(), NtSetSystemInformation(), NtSetValueKey(), NtSetVolumeInformationFile(), NtUnloadKey2(), NtUserCallMsgFilter(), NtUserChangeDisplaySettings(), NtUserClipCursor(), NtUserConsoleControl(), NtUserConvertMemHandle(), NtUserCreateAcceleratorTable(), NtUserCreateWindowStation(), NtUserDefSetText(), NtUserDispatchMessage(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), NtUserEndPaint(), NtUserEnumDisplayDevices(), NtUserEnumDisplaySettings(), NtUserFindExistingCursorIcon(), NtUserFindWindowEx(), NtUserFlashWindowEx(), NtUserGetMenuBarInfo(), NtUserGetMouseMovePointsEx(), NtUserGetPriorityClipboardFormat(), NtUserGetTitleBarInfo(), NtUserInitializeClientPfnArrays(), NtUserLoadKeyboardLayoutEx(), NtUserMessageCall(), NtUserRedrawWindow(), NtUserRegisterClassExWOW(), NtUserScrollDC(), NtUserScrollWindowEx(), NtUserSetClassLong(), NtUserSetClipboardData(), NtUserSetCursorIconData(), NtUserSetInformationThread(), NtUserSetInternalWindowPos(), NtUserSetKeyboardState(), NtUserSetSysColors(), NtUserSetWindowPlacement(), NtUserSetWindowStationUser(), NtUserToUnicodeEx(), NtUserTrackMouseEvent(), NtUserTrackPopupMenuEx(), NtUserTranslateAccelerator(), NtUserTranslateMessage(), NtUserUpdateLayeredWindow(), NtWaitForMultipleObjects(), NtWriteFile(), ObpCaptureObjectCreateInformation(), ObpCaptureObjectName(), ProbeAndCaptureLargeString(), ProbeAndCaptureUnicodeString(), ProbeAndCaptureUnicodeStringOrAtom(), PspSetQuotaLimits(), PsSetContextThread(), RtlWalkFrameChain(), SeCaptureLuidAndAttributesArray(), SeCaptureObjectTypeList(), SeCaptureSecurityDescriptor(), SeCaptureSidAndAttributesArray(), SepAccessCheckAndAuditAlarm(), SepCaptureAcl(), SepCaptureSecurityQualityOfService(), SepCaptureSid(), SpiGetSetProbeBuffer(), SSI_DEF(), UDFGetRetrievalPointers(), UserLoadImage(), and WmipCaptureGuidObjectAttributes().

105 {
106  ULONG_PTR Last, Current = (ULONG_PTR)Address;
107  PAGED_CODE();
108 
109  /* Only probe if we have a valid length */
110  if (Length != 0)
111  {
112  /* Sanity check */
113  ASSERT((Alignment == 1) ||
114  (Alignment == 2) ||
115  (Alignment == 4) ||
116  (Alignment == 8) ||
117  (Alignment == 16));
118 
119  /* Check the alignment */
120  if ((Current & (Alignment - 1)) != 0)
121  {
122  /* Incorrect alignment */
124  }
125 
126  /* Get the end address */
127  Last = Current + Length - 1;
128  if ((Last < Current) || (Last >= (ULONG_PTR)MmUserProbeAddress))
129  {
130  /* Raise an access violation */
132  }
133 
134  /* ProbeForRead doesn't check if memory pages are readable! */
135  }
136 }
ULONG MmUserProbeAddress
Definition: init.c:50
PVOID ULONG Address
Definition: oprghdlr.h:14
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ExRaiseAccessViolation(VOID)
Definition: harderr.c:284
VOID NTAPI ExRaiseDatatypeMisalignment(VOID)
Definition: harderr.c:306
VOID UINTN Length
Definition: acefiex.h:744
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI ProbeForWrite ( IN PVOID  Address,
IN SIZE_T  Length,
IN ULONG  Alignment 
)

Definition at line 143 of file exintrin.c.

Referenced by _IRQL_requires_max_(), _Success_(), AcpiOsWritable(), co_UserCallNextHookEx(), DefaultQueryInfoBufferCheck(), DoQuery(), EngSecureMem(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), GetVolumeBitmap(), IopDeviceFsIoControl(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetInterfaceDeviceList(), IopGetRelatedDevice(), IopQueryAttributesFile(), KdpPrompt(), KeUserModeCallback(), KiDispatchException(), KiDispatchExceptionToUser(), KiInitializeUserApc(), KspPropertyHandler(), KsProbeStreamIrp(), KsReadFile(), MiDoMappedCopy(), MiDoPoolCopy(), NpTransceive(), NtAcceptConnectPort(), NtAccessCheck(), NtAdjustPrivilegesToken(), NtAllocateLocallyUniqueId(), NtCreateProfile(), NtCreateThread(), NtEnumerateKey(), NtEnumerateValueKey(), NtGdiAddFontMemResourceEx(), NtGdiCombineTransform(), NtGdiDoPalette(), NtGdiExtEscape(), NtGdiExtGetObjectW(), NtGdiGetBitmapBits(), NtGdiGetBitmapDimension(), NtGdiGetBoundsRect(), NtGdiGetDCDword(), NtGdiGetDCPoint(), NtGdiGetDeviceGammaRamp(), NtGdiGetFontResourceInfoInternalW(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphIndicesW(), NtGdiGetGlyphOutline(), NtGdiGetKerningPairs(), NtGdiGetObjectBitmapHandle(), NtGdiGetOutlineTextMetricsInternalW(), NtGdiGetRasterizerCaps(), NtGdiGetRealizationInfo(), NtGdiGetRgnBox(), NtGdiGetTextCharsetInfo(), NtGdiGetTextMetricsW(), NtGdiGetTransform(), NtGdiOffsetViewportOrgEx(), NtGdiOffsetWindowOrgEx(), NtGdiOpenDCW(), NtGdiScaleViewportExtEx(), NtGdiScaleWindowExtEx(), NtGdiSetBitmapDimension(), NtGdiSetMiterLimit(), NtGdiSetViewportOrgEx(), NtGdiSetWindowOrgEx(), NtGdiTransformPoints(), NtGetPlugPlayEvent(), NtGetWriteWatch(), NtNotifyChangeDirectoryFile(), NtOpenObjectAuditAlarm(), NtPlugPlayControl(), NtPowerInformation(), NtPrivilegeCheck(), NtQueryDirectoryFile(), NtQueryDirectoryObject(), NtQueryInformationAtom(), NtQueryInformationFile(), NtQueryInformationThread(), NtQueryKey(), NtQueryObject(), NtQuerySection(), NtQuerySecurityObject(), NtQuerySymbolicLinkObject(), NtQuerySystemEnvironmentValue(), NtQuerySystemInformation(), NtQueryValueKey(), NtQueryVirtualMemory(), NtQueryVolumeInformationFile(), NtReadFile(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtUserBuildHwndList(), NtUserCallMsgFilter(), NtUserCallOneParam(), NtUserConsoleControl(), NtUserCopyAcceleratorTable(), NtUserCreateLocalMemHandle(), NtUserEnumDisplayDevices(), NtUserEnumDisplaySettings(), NtUserGetClassInfo(), NtUserGetClipboardData(), NtUserGetClipboardFormatName(), NtUserGetComboBoxInfo(), NtUserGetCursorFrameInfo(), NtUserGetCursorInfo(), NtUserGetIconSize(), NtUserGetInternalWindowPos(), NtUserGetKeyboardLayoutList(), NtUserGetKeyboardLayoutName(), NtUserGetKeyboardState(), NtUserGetKeyNameText(), NtUserGetLayeredWindowAttributes(), NtUserGetMenuBarInfo(), NtUserGetMessage(), NtUserGetMouseMovePointsEx(), NtUserGetObjectInformation(), NtUserGetTitleBarInfo(), NtUserMessageCall(), NtUserPeekMessage(), NtUserProcessConnect(), NtUserScrollDC(), NtUserScrollWindowEx(), NtUserSetInformationThread(), NtUserTrackMouseEvent(), NtWaitForDebugEvent(), PsGetContextThread(), SepAccessCheckAndAuditAlarm(), SpiGetSetProbeBuffer(), and UDFGetRetrievalPointers().

146 {
147  ULONG_PTR Last, Current = (ULONG_PTR)Address;
148  PAGED_CODE();
149 
150  /* Only probe if we have a valid length */
151  if (Length != 0)
152  {
153  /* Sanity check */
154  ASSERT((Alignment == 1) ||
155  (Alignment == 2) ||
156  (Alignment == 4) ||
157  (Alignment == 8) ||
158  (Alignment == 16));
159 
160  /* Check the alignment */
161  if ((Current & (Alignment - 1)) != 0)
162  {
163  /* Incorrect alignment */
165  }
166 
167  /* Get the end address */
168  Last = Current + Length - 1;
169  if ((Last < Current) || (Last >= (ULONG_PTR)MmUserProbeAddress))
170  {
171  /* Raise an access violation */
173  }
174 
175  /* Round down to the last page */
176  Last = PAGE_ROUND_DOWN(Last) + PAGE_SIZE;
177  do
178  {
179  /* Attempt a write */
180  *(volatile CHAR*)Current = *(volatile CHAR*)Current;
181 
182  /* Go to the next address */
183  Current = PAGE_ROUND_DOWN(Current) + PAGE_SIZE;
184  } while (Current != Last);
185  }
186 }
ULONG MmUserProbeAddress
Definition: init.c:50
PVOID ULONG Address
Definition: oprghdlr.h:14
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
char CHAR
Definition: xmlstorage.h:175
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ExRaiseAccessViolation(VOID)
Definition: harderr.c:284
VOID NTAPI ExRaiseDatatypeMisalignment(VOID)
Definition: harderr.c:306
VOID UINTN Length
Definition: acefiex.h:744
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ULONG_PTR
Definition: config.h:101