HyperDbg Debugger
Loading...
Searching...
No Matches
PlatformIntrinsics.h File Reference

Cross platform APIs for intrinsic functions (x86 instructions). More...

Go to the source code of this file.

Functions

ULONG_PTR CpuReadCr0 (VOID)
 Read CR0.
VOID CpuWriteCr0 (ULONG_PTR Cr0Value)
 Write CR0.
ULONG_PTR CpuReadCr2 (VOID)
 Read CR2.
VOID CpuWriteCr2 (ULONG_PTR Cr2Value)
 Write CR2.
ULONG_PTR CpuReadCr3 (VOID)
 Read CR3.
VOID CpuWriteCr3 (ULONG_PTR Cr3Value)
 Write CR3.
ULONG_PTR CpuReadCr4 (VOID)
 Read CR4.
VOID CpuWriteCr4 (ULONG_PTR Cr4Value)
 Write CR4.
ULONG_PTR CpuReadCr8 (VOID)
 Read CR8.
VOID CpuWriteCr8 (ULONG_PTR Cr8Value)
 Write CR8.
UINT64 CpuReadMsr (ULONG MsrAddress)
 Read an MSR.
VOID CpuWriteMsr (ULONG MsrAddress, UINT64 MsrValue)
 Write an MSR.
VOID CpuCpuId (INT32 *CpuInfo, INT32 FunctionId)
 Execute CPUID.
VOID CpuCpuIdEx (INT32 *CpuInfo, INT32 FunctionId, INT32 SubFunctionId)
 Execute CPUID with sub-leaf.
UINT64 CpuReadTsc (VOID)
 Read Time-Stamp Counter.
UINT64 CpuReadTscp (UINT32 *Aux)
 Read Time-Stamp Counter and Processor ID.
INT64 CpuInterlockedExchange64 (INT64 volatile *Target, INT64 Value)
 Atomic 64-bit exchange.
INT64 CpuInterlockedExchangeAdd64 (INT64 volatile *Addend, INT64 Value)
 Atomic 64-bit exchange-add.
INT64 CpuInterlockedIncrement64 (INT64 volatile *Addend)
 Atomic 64-bit increment.
INT64 CpuInterlockedDecrement64 (INT64 volatile *Addend)
 Atomic 64-bit decrement.
INT64 CpuInterlockedCompareExchange64 (INT64 volatile *Destination, INT64 ExChange, INT64 Comparand)
 Atomic 64-bit compare-exchange.
VOID CpuSidt (VOID *Idtr)
 Store Interrupt Descriptor Table Register.
VOID CpuInvlpg (VOID *Address)
 Invalidate TLB entry for a virtual address.
VOID CpuStosQ (UINT64 *Destination, UINT64 Value, SIZE_T Count)
 Store UINT64 value to memory Count times.
UCHAR CpuBitScanForward64 (ULONG *Index, UINT64 Mask)
 Bit scan forward (64-bit).
VOID CpuNop (VOID)
 Execute NOP.
VOID CpuPause (VOID)
 Execute PAUSE (spin-wait hint).
ULONG CpuSegmentLimit (UINT32 Selector)
 Return the segment limit for a selector.
UINT8 CpuIoInByte (UINT16 Port)
 Read a byte from an I/O port.
UINT16 CpuIoInWord (UINT16 Port)
 Read a word from an I/O port.
UINT32 CpuIoInDword (UINT16 Port)
 Read a dword from an I/O port.
VOID CpuIoInByteString (UINT16 Port, UINT8 *Data, UINT32 Size)
 Read a byte string from an I/O port.
VOID CpuIoInWordString (UINT16 Port, UINT16 *Data, UINT32 Size)
 Read a word string from an I/O port.
VOID CpuIoInDwordString (UINT16 Port, UINT32 *Data, UINT32 Size)
 Read a dword string from an I/O port.
VOID CpuIoOutByte (UINT16 Port, UINT8 Value)
 Write a byte to an I/O port.
VOID CpuIoOutWord (UINT16 Port, UINT16 Value)
 Write a word to an I/O port.
VOID CpuIoOutDword (UINT16 Port, UINT32 Value)
 Write a dword to an I/O port.
VOID CpuIoOutByteString (UINT16 Port, UINT8 *Data, UINT32 Count)
 Write a byte string to an I/O port.
VOID CpuIoOutWordString (UINT16 Port, UINT16 *Data, UINT32 Count)
 Write a word string to an I/O port.
VOID CpuIoOutDwordString (UINT16 Port, UINT32 *Data, UINT32 Count)
 Write a dword string to an I/O port.

Detailed Description

Cross platform APIs for intrinsic functions (x86 instructions).

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.19
Date
2026-05-05

Function Documentation

◆ CpuBitScanForward64()

UCHAR CpuBitScanForward64 ( ULONG * Index,
UINT64 Mask )
externinline

Bit scan forward (64-bit).

Parameters
Index
Mask
Returns
UCHAR
487{
488#if defined(_WIN32) || defined(_WIN64)
489 return (UCHAR)_BitScanForward64((unsigned long *)Index, Mask);
490#elif defined(__linux__)
491 if (!Mask)
492 return 0;
493 *Index = (ULONG)__builtin_ctzll(Mask);
494 return 1;
495#else
496# error "Unsupported platform"
497#endif
498}
unsigned char UCHAR
Definition BasicTypes.h:34
unsigned long ULONG
Definition BasicTypes.h:31

◆ CpuCpuId()

VOID CpuCpuId ( INT32 * CpuInfo,
INT32 FunctionId )
externinline

Execute CPUID.

Parameters
CpuInfo
FunctionId
256{
257#if defined(_WIN32) || defined(_WIN64)
258 __cpuid(CpuInfo, FunctionId);
259#elif defined(__linux__)
260 __asm__ __volatile__("cpuid" : "=a"(CpuInfo[0]), "=b"(CpuInfo[1]), "=c"(CpuInfo[2]), "=d"(CpuInfo[3]) : "a"(FunctionId), "c"(0));
261#else
262# error "Unsupported platform"
263#endif
264}

◆ CpuCpuIdEx()

VOID CpuCpuIdEx ( INT32 * CpuInfo,
INT32 FunctionId,
INT32 SubFunctionId )
externinline

Execute CPUID with sub-leaf.

Parameters
CpuInfo
FunctionId
SubFunctionId
275{
276#if defined(_WIN32) || defined(_WIN64)
277 __cpuidex(CpuInfo, FunctionId, SubFunctionId);
278#elif defined(__linux__)
279 __asm__ __volatile__("cpuid" : "=a"(CpuInfo[0]), "=b"(CpuInfo[1]), "=c"(CpuInfo[2]), "=d"(CpuInfo[3]) : "a"(FunctionId), "c"(SubFunctionId));
280#else
281# error "Unsupported platform"
282#endif
283}

◆ CpuInterlockedCompareExchange64()

INT64 CpuInterlockedCompareExchange64 ( INT64 volatile * Destination,
INT64 ExChange,
INT64 Comparand )
externinline

Atomic 64-bit compare-exchange.

397{
398#if defined(_WIN32) || defined(_WIN64)
399 return InterlockedCompareExchange64(Destination, ExChange, Comparand);
400#elif defined(__linux__)
401 INT64 Expected = Comparand;
402 __atomic_compare_exchange_n(Destination, &Expected, ExChange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
403 return Expected;
404#else
405# error "Unsupported platform"
406#endif
407}

◆ CpuInterlockedDecrement64()

INT64 CpuInterlockedDecrement64 ( INT64 volatile * Addend)
externinline

Atomic 64-bit decrement.

382{
383#if defined(_WIN32) || defined(_WIN64)
384 return InterlockedDecrement64(Addend);
385#elif defined(__linux__)
386 return __atomic_sub_fetch(Addend, 1LL, __ATOMIC_SEQ_CST);
387#else
388# error "Unsupported platform"
389#endif
390}

◆ CpuInterlockedExchange64()

INT64 CpuInterlockedExchange64 ( INT64 volatile * Target,
INT64 Value )
externinline

Atomic 64-bit exchange.

337{
338#if defined(_WIN32) || defined(_WIN64)
339 return InterlockedExchange64(Target, Value);
340#elif defined(__linux__)
341 return __atomic_exchange_n(Target, Value, __ATOMIC_SEQ_CST);
342#else
343# error "Unsupported platform"
344#endif
345}
RequestedActionOfThePacket Value(0x1) 00000000

◆ CpuInterlockedExchangeAdd64()

INT64 CpuInterlockedExchangeAdd64 ( INT64 volatile * Addend,
INT64 Value )
externinline

Atomic 64-bit exchange-add.

352{
353#if defined(_WIN32) || defined(_WIN64)
354 return InterlockedExchangeAdd64(Addend, Value);
355#elif defined(__linux__)
356 return __atomic_fetch_add(Addend, Value, __ATOMIC_SEQ_CST);
357#else
358# error "Unsupported platform"
359#endif
360}

◆ CpuInterlockedIncrement64()

INT64 CpuInterlockedIncrement64 ( INT64 volatile * Addend)
externinline

Atomic 64-bit increment.

367{
368#if defined(_WIN32) || defined(_WIN64)
369 return InterlockedIncrement64(Addend);
370#elif defined(__linux__)
371 return __atomic_add_fetch(Addend, 1LL, __ATOMIC_SEQ_CST);
372#else
373# error "Unsupported platform"
374#endif
375}

◆ CpuInvlpg()

VOID CpuInvlpg ( VOID * Address)
externinline

Invalidate TLB entry for a virtual address.

Parameters
Address
441{
442#if defined(_WIN32) || defined(_WIN64)
443 __invlpg(Address);
444#elif defined(__linux__)
445 __asm__ __volatile__("invlpg (%0)" : : "r"(Address) : "memory");
446#else
447# error "Unsupported platform"
448#endif
449}

◆ CpuIoInByte()

UINT8 CpuIoInByte ( UINT16 Port)
externinline

Read a byte from an I/O port.

Parameters
Port
Returns
UINT8
574{
575#if defined(_WIN32) || defined(_WIN64)
576 return __inbyte(Port);
577#elif defined(__linux__)
578 UINT8 __val;
579 __asm__ __volatile__("inb %1, %0" : "=a"(__val) : "Nd"(Port));
580 return __val;
581#else
582# error "Unsupported platform"
583#endif
584}
unsigned char UINT8
Definition BasicTypes.h:52

◆ CpuIoInByteString()

VOID CpuIoInByteString ( UINT16 Port,
UINT8 * Data,
UINT32 Size )
externinline

Read a byte string from an I/O port.

Parameters
Port
Data
Size
635{
636#if defined(_WIN32) || defined(_WIN64)
637 __inbytestring(Port, Data, Size);
638#elif defined(__linux__)
639 __asm__ __volatile__("rep insb" : "+D"(Data), "+c"(Size) : "d"(Port) : "memory");
640#else
641# error "Unsupported platform"
642#endif
643}
Start of Optional Data
Definition script_buffer.hex.txt:8

◆ CpuIoInDword()

UINT32 CpuIoInDword ( UINT16 Port)
externinline

Read a dword from an I/O port.

Parameters
Port
Returns
UINT32
614{
615#if defined(_WIN32) || defined(_WIN64)
616 return __indword(Port);
617#elif defined(__linux__)
618 UINT32 __val;
619 __asm__ __volatile__("inl %1, %0" : "=a"(__val) : "Nd"(Port));
620 return __val;
621#else
622# error "Unsupported platform"
623#endif
624}
unsigned int UINT32
Definition BasicTypes.h:54

◆ CpuIoInDwordString()

VOID CpuIoInDwordString ( UINT16 Port,
UINT32 * Data,
UINT32 Size )
externinline

Read a dword string from an I/O port.

Parameters
Port
Data
Size
673{
674#if defined(_WIN32) || defined(_WIN64)
675 __indwordstring(Port, (unsigned long *)Data, Size);
676#elif defined(__linux__)
677 __asm__ __volatile__("rep insl" : "+D"(Data), "+c"(Size) : "d"(Port) : "memory");
678#else
679# error "Unsupported platform"
680#endif
681}

◆ CpuIoInWord()

UINT16 CpuIoInWord ( UINT16 Port)
externinline

Read a word from an I/O port.

Parameters
Port
Returns
UINT16
594{
595#if defined(_WIN32) || defined(_WIN64)
596 return __inword(Port);
597#elif defined(__linux__)
598 UINT16 __val;
599 __asm__ __volatile__("inw %1, %0" : "=a"(__val) : "Nd"(Port));
600 return __val;
601#else
602# error "Unsupported platform"
603#endif
604}
unsigned short UINT16
Definition BasicTypes.h:53

◆ CpuIoInWordString()

VOID CpuIoInWordString ( UINT16 Port,
UINT16 * Data,
UINT32 Size )
externinline

Read a word string from an I/O port.

Parameters
Port
Data
Size
654{
655#if defined(_WIN32) || defined(_WIN64)
656 __inwordstring(Port, Data, Size);
657#elif defined(__linux__)
658 __asm__ __volatile__("rep insw" : "+D"(Data), "+c"(Size) : "d"(Port) : "memory");
659#else
660# error "Unsupported platform"
661#endif
662}

◆ CpuIoOutByte()

VOID CpuIoOutByte ( UINT16 Port,
UINT8 Value )
externinline

Write a byte to an I/O port.

Parameters
Port
Value
691{
692#if defined(_WIN32) || defined(_WIN64)
693 __outbyte(Port, Value);
694#elif defined(__linux__)
695 __asm__ __volatile__("outb %0, %1" : : "a"(Value), "Nd"(Port));
696#else
697# error "Unsupported platform"
698#endif
699}

◆ CpuIoOutByteString()

VOID CpuIoOutByteString ( UINT16 Port,
UINT8 * Data,
UINT32 Count )
externinline

Write a byte string to an I/O port.

Parameters
Port
Data
Count
746{
747#if defined(_WIN32) || defined(_WIN64)
748 __outbytestring(Port, Data, Count);
749#elif defined(__linux__)
750 __asm__ __volatile__("rep outsb" : "+S"(Data), "+c"(Count) : "d"(Port) : "memory");
751#else
752# error "Unsupported platform"
753#endif
754}

◆ CpuIoOutDword()

VOID CpuIoOutDword ( UINT16 Port,
UINT32 Value )
externinline

Write a dword to an I/O port.

Parameters
Port
Value
727{
728#if defined(_WIN32) || defined(_WIN64)
729 __outdword(Port, Value);
730#elif defined(__linux__)
731 __asm__ __volatile__("outl %0, %1" : : "a"(Value), "Nd"(Port));
732#else
733# error "Unsupported platform"
734#endif
735}

◆ CpuIoOutDwordString()

VOID CpuIoOutDwordString ( UINT16 Port,
UINT32 * Data,
UINT32 Count )
externinline

Write a dword string to an I/O port.

Parameters
Port
Data
Count
784{
785#if defined(_WIN32) || defined(_WIN64)
786 __outdwordstring(Port, (unsigned long *)Data, Count);
787#elif defined(__linux__)
788 __asm__ __volatile__("rep outsl" : "+S"(Data), "+c"(Count) : "d"(Port) : "memory");
789#else
790# error "Unsupported platform"
791#endif
792}

◆ CpuIoOutWord()

VOID CpuIoOutWord ( UINT16 Port,
UINT16 Value )
externinline

Write a word to an I/O port.

Parameters
Port
Value
709{
710#if defined(_WIN32) || defined(_WIN64)
711 __outword(Port, Value);
712#elif defined(__linux__)
713 __asm__ __volatile__("outw %0, %1" : : "a"(Value), "Nd"(Port));
714#else
715# error "Unsupported platform"
716#endif
717}

◆ CpuIoOutWordString()

VOID CpuIoOutWordString ( UINT16 Port,
UINT16 * Data,
UINT32 Count )
externinline

Write a word string to an I/O port.

Parameters
Port
Data
Count
765{
766#if defined(_WIN32) || defined(_WIN64)
767 __outwordstring(Port, Data, Count);
768#elif defined(__linux__)
769 __asm__ __volatile__("rep outsw" : "+S"(Data), "+c"(Count) : "d"(Port) : "memory");
770#else
771# error "Unsupported platform"
772#endif
773}

◆ CpuNop()

VOID CpuNop ( VOID )
externinline

Execute NOP.

509{
510#if defined(_WIN32) || defined(_WIN64)
511 __nop();
512#elif defined(__linux__)
513 __asm__ __volatile__("nop");
514#else
515# error "Unsupported platform"
516#endif
517}

◆ CpuPause()

VOID CpuPause ( VOID )
externinline

Execute PAUSE (spin-wait hint).

524{
525#if defined(_WIN32) || defined(_WIN64)
526 _mm_pause();
527#elif defined(__linux__)
528 __asm__ __volatile__("pause");
529#else
530# error "Unsupported platform"
531#endif
532}

◆ CpuReadCr0()

ULONG_PTR CpuReadCr0 ( VOID )
externinline

Read CR0.

Returns
ULONG_PTR
29{
30#if defined(_WIN32) || defined(_WIN64)
31 return __readcr0();
32#elif defined(__linux__)
33 ULONG_PTR __val;
34 __asm__ __volatile__("mov %%cr0, %0" : "=r"(__val));
35 return __val;
36#else
37# error "Unsupported platform"
38#endif
39}

◆ CpuReadCr2()

ULONG_PTR CpuReadCr2 ( VOID )
externinline

Read CR2.

Returns
ULONG_PTR
65{
66#if defined(_WIN32) || defined(_WIN64)
67 return __readcr2();
68#elif defined(__linux__)
69 ULONG_PTR __val;
70 __asm__ __volatile__("mov %%cr2, %0" : "=r"(__val));
71 return __val;
72#else
73# error "Unsupported platform"
74#endif
75}

◆ CpuReadCr3()

ULONG_PTR CpuReadCr3 ( VOID )
externinline

Read CR3.

Returns
ULONG_PTR
101{
102#if defined(_WIN32) || defined(_WIN64)
103 return __readcr3();
104#elif defined(__linux__)
105 ULONG_PTR __val;
106 __asm__ __volatile__("mov %%cr3, %0" : "=r"(__val));
107 return __val;
108#else
109# error "Unsupported platform"
110#endif
111}

◆ CpuReadCr4()

ULONG_PTR CpuReadCr4 ( VOID )
externinline

Read CR4.

Returns
ULONG_PTR
137{
138#if defined(_WIN32) || defined(_WIN64)
139 return __readcr4();
140#elif defined(__linux__)
141 ULONG_PTR __val;
142 __asm__ __volatile__("mov %%cr4, %0" : "=r"(__val));
143 return __val;
144#else
145# error "Unsupported platform"
146#endif
147}

◆ CpuReadCr8()

ULONG_PTR CpuReadCr8 ( VOID )
externinline

Read CR8.

Returns
ULONG_PTR
173{
174#if defined(_WIN32) || defined(_WIN64)
175 return __readcr8();
176#elif defined(__linux__)
177 ULONG_PTR __val;
178 __asm__ __volatile__("mov %%cr8, %0" : "=r"(__val));
179 return __val;
180#else
181# error "Unsupported platform"
182#endif
183}

◆ CpuReadMsr()

UINT64 CpuReadMsr ( ULONG MsrAddress)
externinline

Read an MSR.

Parameters
MsrAddress
Returns
UINT64
214{
215#if defined(_WIN32) || defined(_WIN64)
216 return __readmsr(MsrAddress);
217#elif defined(__linux__)
218 UINT32 __lo, __hi;
219 __asm__ __volatile__("rdmsr" : "=a"(__lo), "=d"(__hi) : "c"(MsrAddress));
220 return ((UINT64)__hi << 32) | __lo;
221#else
222# error "Unsupported platform"
223#endif
224}

◆ CpuReadTsc()

UINT64 CpuReadTsc ( VOID )
externinline

Read Time-Stamp Counter.

Returns
UINT64
296{
297#if defined(_WIN32) || defined(_WIN64)
298 return __rdtsc();
299#elif defined(__linux__)
300 UINT32 __lo, __hi;
301 __asm__ __volatile__("rdtsc" : "=a"(__lo), "=d"(__hi));
302 return ((UINT64)__hi << 32) | __lo;
303#else
304# error "Unsupported platform"
305#endif
306}

◆ CpuReadTscp()

UINT64 CpuReadTscp ( UINT32 * Aux)
externinline

Read Time-Stamp Counter and Processor ID.

Parameters
Aux
Returns
UINT64
316{
317#if defined(_WIN32) || defined(_WIN64)
318 return __rdtscp(Aux);
319#elif defined(__linux__)
320 UINT32 __lo, __hi;
321 __asm__ __volatile__("rdtscp" : "=a"(__lo), "=d"(__hi), "=c"(*Aux));
322 return ((UINT64)__hi << 32) | __lo;
323#else
324# error "Unsupported platform"
325#endif
326}

◆ CpuSegmentLimit()

ULONG CpuSegmentLimit ( UINT32 Selector)
externinline

Return the segment limit for a selector.

Parameters
Selector
Returns
ULONG
542{
543#if defined(_WIN32) || defined(_WIN64)
544 return __segmentlimit(Selector);
545#elif defined(__linux__)
546
547 UINT32 Limit;
548
549 __asm__ __volatile__(
550 "lsl %1, %0"
551 : "=r"(Limit)
552 : "rm"(Selector)
553 : "cc");
554
555 return Limit;
556
557#else
558# error "Unsupported platform"
559#endif
560}
_In_ UINT16 Selector
Definition Segmentation.h:50

◆ CpuSidt()

VOID CpuSidt ( VOID * Idtr)
externinline

Store Interrupt Descriptor Table Register.

Parameters
Idtr
420{
421#if defined(_WIN32) || defined(_WIN64)
422 __sidt(Idtr);
423#elif defined(__linux__)
424 __asm__ __volatile__("sidt %0" : "=m"(*(char *)Idtr) : : "memory");
425#else
426# error "Unsupported platform"
427#endif
428}

◆ CpuStosQ()

VOID CpuStosQ ( UINT64 * Destination,
UINT64 Value,
SIZE_T Count )
externinline

Store UINT64 value to memory Count times.

Parameters
Destination
Value
Count
464{
465#if defined(_WIN32) || defined(_WIN64)
466 __stosq((unsigned __int64 *)Destination, Value, Count);
467#elif defined(__linux__)
468 __asm__ __volatile__("rep stosq" : "+D"(Destination), "+c"(Count) : "a"(Value) : "memory");
469#else
470# error "Unsupported platform"
471#endif
472}

◆ CpuWriteCr0()

VOID CpuWriteCr0 ( ULONG_PTR Cr0Value)
externinline

Write CR0.

Parameters
Cr0Value
48{
49#if defined(_WIN32) || defined(_WIN64)
50 __writecr0(Cr0Value);
51#elif defined(__linux__)
52 __asm__ __volatile__("mov %0, %%cr0" : : "r"(Cr0Value) : "memory");
53#else
54# error "Unsupported platform"
55#endif
56}

◆ CpuWriteCr2()

VOID CpuWriteCr2 ( ULONG_PTR Cr2Value)
externinline

Write CR2.

Parameters
Cr2Value
84{
85#if defined(_WIN32) || defined(_WIN64)
86 __writecr2(Cr2Value);
87#elif defined(__linux__)
88 __asm__ __volatile__("mov %0, %%cr2" : : "r"(Cr2Value) : "memory");
89#else
90# error "Unsupported platform"
91#endif
92}

◆ CpuWriteCr3()

VOID CpuWriteCr3 ( ULONG_PTR Cr3Value)
externinline

Write CR3.

Parameters
Cr3Value
120{
121#if defined(_WIN32) || defined(_WIN64)
122 __writecr3(Cr3Value);
123#elif defined(__linux__)
124 __asm__ __volatile__("mov %0, %%cr3" : : "r"(Cr3Value) : "memory");
125#else
126# error "Unsupported platform"
127#endif
128}

◆ CpuWriteCr4()

VOID CpuWriteCr4 ( ULONG_PTR Cr4Value)
externinline

Write CR4.

Parameters
Cr4Value
156{
157#if defined(_WIN32) || defined(_WIN64)
158 __writecr4(Cr4Value);
159#elif defined(__linux__)
160 __asm__ __volatile__("mov %0, %%cr4" : : "r"(Cr4Value) : "memory");
161#else
162# error "Unsupported platform"
163#endif
164}

◆ CpuWriteCr8()

VOID CpuWriteCr8 ( ULONG_PTR Cr8Value)
externinline

Write CR8.

Parameters
Cr8Value
192{
193#if defined(_WIN32) || defined(_WIN64)
194 __writecr8(Cr8Value);
195#elif defined(__linux__)
196 __asm__ __volatile__("mov %0, %%cr8" : : "r"(Cr8Value) : "memory");
197#else
198# error "Unsupported platform"
199#endif
200}

◆ CpuWriteMsr()

VOID CpuWriteMsr ( ULONG MsrAddress,
UINT64 MsrValue )
externinline

Write an MSR.

Parameters
MsrAddress
MsrValue
234{
235#if defined(_WIN32) || defined(_WIN64)
236 __writemsr(MsrAddress, MsrValue);
237#elif defined(__linux__)
238 __asm__ __volatile__("wrmsr" : : "c"(MsrAddress), "a"((UINT32)MsrValue), "d"((UINT32)(MsrValue >> 32)));
239#else
240# error "Unsupported platform"
241#endif
242}