ReactOS 0.4.15-dev-8393-g61b7fb9
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

◆ H2I

#define H2I (   Port)    PtrToUshort(Port)

Definition at line 24 of file exintrin.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file exintrin.c.

Function Documentation

◆ InterlockedCompareExchange()

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:3016

◆ InterlockedDecrement()

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:25
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)

◆ InterlockedExchange()

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)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ InterlockedExchangeAdd()

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 IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:46
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)

◆ InterlockedIncrement()

LONG FASTCALL InterlockedIncrement ( IN LONG volatile Addend)

Definition at line 33 of file exintrin.c.

34{
35 //
36 // Call the intrinsic
37 //
39}
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)

◆ ProbeForRead()

VOID NTAPI ProbeForRead ( IN CONST VOID Address,
IN SIZE_T  Length,
IN ULONG  Alignment 
)

Definition at line 102 of file exintrin.c.

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}
#define PAGED_CODE()
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI ExRaiseAccessViolation(VOID)
Definition: harderr.c:308
VOID NTAPI ExRaiseDatatypeMisalignment(VOID)
Definition: harderr.c:330
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
ULONG MmUserProbeAddress
Definition: init.c:50
static WCHAR Address[46]
Definition: ping.c:68
uint32_t ULONG_PTR
Definition: typedefs.h:65

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

◆ ProbeForWrite()

VOID NTAPI ProbeForWrite ( IN PVOID  Address,
IN SIZE_T  Length,
IN ULONG  Alignment 
)

Definition at line 143 of file exintrin.c.

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}
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
char CHAR
Definition: xmlstorage.h:175

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