47{
53 UINT32 ActionBreakToDebuggerLength = 0;
54 UINT32 ActionCustomCodeLength = 0;
55 UINT32 ActionScriptLength = 0;
57 UINT64 MaskRegister = 0xFFFFFFFFFFFFFFFF;
60 vector<string> SplitCommandCaseSensitive {
Split(Command,
' ')};
62
63 if (SplitCommand.size() < 2)
64 {
67 return;
68 }
69
70
71
72
73
75 &SplitCommand,
76 &SplitCommandCaseSensitive,
78 &Event,
79 &EventLength,
80 &ActionBreakToDebugger,
81 &ActionBreakToDebuggerLength,
82 &ActionCustomCode,
83 &ActionCustomCodeLength,
84 &ActionScript,
85 &ActionScriptLength,
86 &EventParsingErrorCause))
87 {
88 return;
89 }
90
91
92
93
94 for (auto Section : SplitCommand)
95 {
96 if (!Section.compare("!crwrite"))
97 {
98 continue;
99 }
100 else if (!GetRegister)
101 {
102
103
104
106 {
107
108
109
110 ShowMessages(
"unknown parameter '%s'\n\n", Section.c_str());
112
114 return;
115 }
116 else
117 {
119 }
120 }
121 else if (!GetMask)
122 {
124 {
125
126
127
128 ShowMessages(
"unknown parameter '%s'\n\n", Section.c_str());
130
132 return;
133 }
134 else
135 {
137 }
138 }
139 else
140 {
141
142
143
144 ShowMessages(
"unknown parameter '%s'\n\n", Section.c_str());
146
148 return;
149 }
150 }
151
152 if (TargetRegister != VMX_EXIT_QUALIFICATION_REGISTER_CR0 && TargetRegister != VMX_EXIT_QUALIFICATION_REGISTER_CR4)
153 {
154 ShowMessages(
"please choose either 0 for cr0 or 4 for cr4\n");
156
158 return;
159 }
160
161
162
163
165
166
167
168
170
171
172
173
175 {
176
177
178
179
180
182 return;
183 }
184
185
186
187
189 ActionBreakToDebugger,
190 ActionBreakToDebuggerLength,
191 ActionCustomCode,
192 ActionCustomCodeLength,
193 ActionScript,
194 ActionScriptLength))
195 {
196
197
198
200 return;
201 }
202}
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
const vector< string > Split(const string &s, const char &c)
general split command
Definition common.cpp:117
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
VOID CommandCrwriteHelp()
help of the !crwrite command
Definition crwrite.cpp:20
VOID FreeEventsAndActionsMemory(PDEBUGGER_GENERAL_EVENT_DETAIL Event, PDEBUGGER_GENERAL_ACTION ActionBreakToDebugger, PDEBUGGER_GENERAL_ACTION ActionCustomCode, PDEBUGGER_GENERAL_ACTION ActionScript)
Deallocate buffers relating to events and actions.
Definition debugger.cpp:2292
BOOLEAN InterpretGeneralEventAndActionsFields(vector< string > *SplitCommand, vector< string > *SplitCommandCaseSensitive, VMM_EVENT_TYPE_ENUM EventType, PDEBUGGER_GENERAL_EVENT_DETAIL *EventDetailsToFill, PUINT32 EventBufferLength, PDEBUGGER_GENERAL_ACTION *ActionDetailsToFillBreakToDebugger, PUINT32 ActionBufferLengthBreakToDebugger, PDEBUGGER_GENERAL_ACTION *ActionDetailsToFillCustomCode, PUINT32 ActionBufferLengthCustomCode, PDEBUGGER_GENERAL_ACTION *ActionDetailsToFillScript, PUINT32 ActionBufferLengthScript, PDEBUGGER_EVENT_PARSING_ERROR_CAUSE ReasonForErrorInParsing)
Interpret general event fields.
Definition debugger.cpp:2342
BOOLEAN SendEventToKernel(PDEBUGGER_GENERAL_EVENT_DETAIL Event, UINT32 EventBufferLength)
Register the event to the kernel.
Definition debugger.cpp:1969
BOOLEAN RegisterActionToEvent(PDEBUGGER_GENERAL_EVENT_DETAIL Event, PDEBUGGER_GENERAL_ACTION ActionBreakToDebugger, UINT32 ActionBreakToDebuggerLength, PDEBUGGER_GENERAL_ACTION ActionCustomCode, UINT32 ActionCustomCodeLength, PDEBUGGER_GENERAL_ACTION ActionScript, UINT32 ActionScriptLength)
Register the action to the event.
Definition debugger.cpp:2086
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
NULL()
Definition test-case-generator.py:530
UINT64 OptionalParam2
Definition Events.h:273
UINT64 OptionalParam1
Definition Events.h:272
Each event can have multiple actions.
Definition Events.h:406
Each command is like the following struct, it also used for tracing works in user mode and sending it...
Definition Events.h:350
DEBUGGER_EVENT_OPTIONS Options
Definition Events.h:391