48{
50 UINT64 Msr;
59
60 if (CommandTokens.size() >= 6)
61 {
62 ShowMessages("incorrect use of the '%s'\n\n",
65 return;
66 }
67
68 for (auto Section : CommandTokens)
69 {
70 if (IsFirstCommand ==
TRUE)
71 {
72 IsFirstCommand =
FALSE;
73 continue;
74 }
75
76 if (IsNextCoreId)
77 {
79 {
80 ShowMessages("please specify a correct hex value for core id\n\n");
82 return;
83 }
84
86 continue;
87 }
88
90 {
92 continue;
93 }
94
95 if (!SetMsr)
96 {
98 {
99 ShowMessages("please specify a correct hex value to be read\n\n");
101 return;
102 }
103 else
104 {
105
106
107
109 continue;
110 }
111 }
112
113 if (SetMsr)
114 {
116 {
117 ShowMessages(
118 "please specify a correct hex value or an expression to put on the msr\n\n");
120 return;
121 }
122 else
123 {
125 continue;
126 }
127 }
128 }
129
130
131
132
133 if (!SetMsr)
134 {
135 ShowMessages("please specify a correct hex value to write\n\n");
137 return;
138 }
139
141 {
142 ShowMessages("please specify a correct hex value to put on msr\n\n");
144 return;
145 }
146
147 if (IsNextCoreId)
148 {
149 ShowMessages("please specify a correct hex value for core\n\n");
151 return;
152 }
153
155
157 MsrWriteRequest.
Msr = Msr;
160
161 Status = DeviceIoControl(
164 &MsrWriteRequest,
166 &MsrWriteRequest,
168 &ReturnedLength,
169 NULL
170 );
171
172 if (!Status)
173 {
174 ShowMessages("ioctl failed with code (%x), either msr index or core id is invalid\n",
175 GetLastError());
176 return;
177 }
178
179 ShowMessages("\n");
180}
VOID SetValue(PGUEST_REGS GuestRegs, SCRIPT_ENGINE_GENERAL_REGISTERS *ScriptGeneralRegisters, PSYMBOL Symbol, UINT64 Value)
Set the value.
Definition ScriptEngineEval.c:185
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN CompareLowerCaseStrings(CommandToken TargetToken, const CHAR *StringToCompare)
Compare lower case strings.
Definition common.cpp:503
BOOLEAN ConvertTokenToUInt64(CommandToken TargetToken, PUINT64 Result)
add ` between 64 bit values and convert them to string
Definition common.cpp:447
BOOLEAN ConvertTokenToUInt32(CommandToken TargetToken, PUINT32 Result)
check and convert command token to a 32 bit unsigned integer
Definition common.cpp:546
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:481
BOOLEAN g_IsKdModuleLoaded
shows whether the kernel debugger (KD) module is loaded or not
Definition globals.h:22
UINT32 CoreNumber
Definition RequestStructures.h:461
DEBUGGER_MSR_ACTION_TYPE ActionType
Definition RequestStructures.h:464
UINT64 Msr
Definition RequestStructures.h:460
UINT64 Value
Definition RequestStructures.h:465
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:359
VOID CommandWrmsrHelp()
help of the wrmsr command
Definition wrmsr.cpp:25