43{
53
54 if (SplitCommand.size() >= 6)
55 {
58 return;
59 }
60
61 for (auto Section : SplitCommand)
62 {
63 if (IsFirstCommand ==
TRUE)
64 {
65 IsFirstCommand =
FALSE;
66 continue;
67 }
68
69 if (IsNextCoreId)
70 {
72 {
73 ShowMessages(
"please specify a correct hex value for core id\n\n");
75 return;
76 }
77
79 continue;
80 }
81
82 if (!Section.compare("core"))
83 {
85 continue;
86 }
87
88 if (!SetMsr)
89 {
91 {
92 ShowMessages(
"please specify a correct hex value to be read\n\n");
94 return;
95 }
96 else
97 {
98
99
100
102 continue;
103 }
104 }
105
106 if (SetMsr)
107 {
109 {
111 "please specify a correct hex value or an expression to put on the msr\n\n");
113 return;
114 }
115 else
116 {
118 continue;
119 }
120 }
121 }
122
123
124
125
126 if (!SetMsr)
127 {
128 ShowMessages(
"please specify a correct hex value to write\n\n");
130 return;
131 }
132
134 {
135 ShowMessages(
"please specify a correct hex value to put on msr\n\n");
137 return;
138 }
139
140 if (IsNextCoreId)
141 {
142 ShowMessages(
"please specify a correct hex value for core\n\n");
144 return;
145 }
146
148
150 MsrWriteRequest.
Msr = Msr;
153
154 Status = DeviceIoControl(
157 &MsrWriteRequest,
159 NULL,
160 NULL,
161 NULL,
162 NULL
163 );
164
165 if (!Status)
166 {
167 ShowMessages(
"ioctl failed with code (%x), either msr index or core id is invalid\n",
168 GetLastError());
169 return;
170 }
171
173}
int BOOL
Definition BasicTypes.h:23
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
#define DEBUGGER_READ_AND_WRITE_ON_MSR_APPLY_ALL_CORES
Read and write MSRs to all cores.
Definition Constants.h:599
#define IOCTL_DEBUGGER_READ_OR_WRITE_MSR
ioctl, request to read or write on a special MSR
Definition Ioctls.h:92
#define SIZEOF_DEBUGGER_READ_AND_WRITE_ON_MSR
Definition RequestStructures.h:422
@ DEBUGGER_MSR_WRITE
Definition RequestStructures.h:432
VOID SetValue(PGUEST_REGS GuestRegs, SCRIPT_ENGINE_VARIABLES_LIST *VariablesList, PSYMBOL Symbol, UINT64 Value, SYMBOL_BUFFER *StackBuffer, UINT64 *StackIndx, UINT64 *StackBaseIndx, UINT64 *ReturnValue)
Set the value.
Definition ScriptEngineEval.c:184
BOOLEAN ConvertStringToUInt64(string TextToConvert, PUINT64 Result)
check and convert string to a 64 bit unsigned integer and also check for special notations like 0x,...
Definition common.cpp:240
BOOLEAN ConvertStringToUInt32(string TextToConvert, PUINT32 Result)
check and convert string to a 32 bit unsigned it and also check for special notations like 0x etc.
Definition common.cpp:347
RequestedActionOfThePacket Value(0x1) 00000000
HANDLE g_DeviceHandle
Holds the global handle of device which is used to send the request to the kernel by IOCTL,...
Definition globals.h:471
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
request to read or write on MSRs
Definition RequestStructures.h:440
UINT32 CoreNumber
Definition RequestStructures.h:442
DEBUGGER_MSR_ACTION_TYPE ActionType
Definition RequestStructures.h:446
UINT64 Msr
Definition RequestStructures.h:441
UINT64 Value
Definition RequestStructures.h:447
BOOLEAN SymbolConvertNameOrExprToAddress(const string &TextToConvert, PUINT64 Result)
check and convert string to a 64 bit unsigned integer and also check for symbol object names and eval...
Definition symbol.cpp:360
VOID CommandWrmsrHelp()
help of the wrmsr command
Definition wrmsr.cpp:20