HyperDbg Debugger
Loading...
Searching...
No Matches
hardware.c File Reference

Hardware (chip debugger) related functions. More...

#include "pch.h"

Functions

VOID HardwareScriptInterpreterShowScriptCapabilities (HWDBG_INSTANCE_INFORMATION *InstanceInfo)
 Shows the script capabilities of the target debuggee.
BOOLEAN HardwareScriptInterpreterCheckScriptBufferWithScriptCapabilities (HWDBG_INSTANCE_INFORMATION *InstanceInfo, PVOID ScriptBuffer, UINT32 CountOfScriptSymbolChunks, UINT32 *NumberOfStages, UINT32 *NumberOfOperands, UINT32 *NumberOfOperandsImplemented)
 Check the script capabilities with the target script buffer.
BOOLEAN HardwareScriptInterpreterCompressBuffer (UINT64 *Buffer, size_t BufferLength, UINT32 ScriptVariableLength, UINT32 BramDataWidth, size_t *NewBufferSize, size_t *NumberOfBytesPerChunk)
 Function to compress the buffer.
BOOLEAN HardwareScriptInterpreterConvertSymbolToHwdbgShortSymbolBuffer (HWDBG_INSTANCE_INFORMATION *InstanceInfo, SYMBOL *SymbolBuffer, size_t SymbolBufferLength, UINT32 NumberOfStages, HWDBG_SHORT_SYMBOL **NewShortSymbolBuffer, size_t *NewBufferSize)
 Function to compress the buffer.
VOID HardwareScriptInterpreterFreeHwdbgShortSymbolBuffer (HWDBG_SHORT_SYMBOL *NewShortSymbolBuffer)
 Function free the short symbol buffer.

Detailed Description

Hardware (chip debugger) related functions.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.11
Date
2024-09-25

Function Documentation

◆ HardwareScriptInterpreterCheckScriptBufferWithScriptCapabilities()

BOOLEAN HardwareScriptInterpreterCheckScriptBufferWithScriptCapabilities ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
PVOID ScriptBuffer,
UINT32 CountOfScriptSymbolChunks,
UINT32 * NumberOfStages,
UINT32 * NumberOfOperands,
UINT32 * NumberOfOperandsImplemented )

Check the script capabilities with the target script buffer.

Parameters
InstanceInfo
ScriptBuffer
CountOfScriptSymbolChunks
NumberOfStages
NumberOfOperands
NumberOfOperandsImplemented
Returns
BOOLEAN TRUE if the script capabilities support the script, otherwise FALSE
88{
89 BOOLEAN NotSupported = FALSE;
90 SYMBOL * SymbolArray = (SYMBOL *)ScriptBuffer;
91
92 UINT32 Stages = 0;
93 UINT32 Operands = 0;
94 UINT32 NumberOfGetOperands = 0;
95 UINT32 NumberOfSetOperands = 0;
96
97 for (size_t i = 0; i < CountOfScriptSymbolChunks; i++)
98 {
99 if (SymbolArray[i].Type != SYMBOL_SEMANTIC_RULE_TYPE)
100 {
101 //
102 // *** For operands ***
103 //
104 Operands++;
105 ShowMessages(" \t%lld. found a non-semnatic rule (operand) | type: 0x%llx, value: 0x%llx\n", i, SymbolArray[i].Type, SymbolArray[i].Value);
106
107 //
108 // Validate the operand
109 //
110 switch (SymbolArray[i].Type)
111 {
114
116 {
117 NotSupported = TRUE;
118 ShowMessages("err, global/local variable assignment is not supported\n");
119 }
120
121 if (SymbolArray[i].Value >= InstanceInfo->numberOfSupportedLocalAndGlobalVariables)
122 {
123 NotSupported = TRUE;
124 ShowMessages("err, global/local variable index is out of range of supported by this instance of hwdbg\n");
125 }
126
127 break;
128
129 case SYMBOL_UNDEFINED:
130 case SYMBOL_NUM_TYPE:
131
132 //
133 // No need to check
134 //
135 break;
136
138
139 if (!InstanceInfo->scriptCapabilities.assign_registers)
140 {
141 NotSupported = TRUE;
142 ShowMessages("err, register assignment is not supported\n");
143 }
144 break;
145
147
149 {
150 NotSupported = TRUE;
151 ShowMessages("err, pseudo register index is not supported\n");
152 }
153 break;
154
155 case SYMBOL_TEMP_TYPE:
156
158 {
159 NotSupported = TRUE;
160 ShowMessages("err, temporary variables (for conditional statement) is not supported\n");
161 }
162
163 if (SymbolArray[i].Value >= InstanceInfo->numberOfSupportedTemporaryVariables)
164 {
165 NotSupported = TRUE;
166 ShowMessages("err, temp variable index (number of operands for conditional statements) is out of range of supported by this instance of hwdbg\n");
167 }
168
169 break;
170
172
173 if (!InstanceInfo->scriptCapabilities.stack_assignments)
174 {
175 NotSupported = TRUE;
176 ShowMessages("err, temporary variables (for conditional statement) is not supported\n");
177 }
178
179 break;
180
181 default:
182
183 NotSupported = TRUE;
184 ShowMessages("err, unknown operand type: %lld (0x%llx)\n", SymbolArray[i].Type, SymbolArray[i].Type);
185 break;
186 }
187 }
188 else
189 {
190 //
191 // *** For operators ***
192 //
193 Stages++;
194 ShowMessages("- %lld. found a semnatic rule (operator) | type: 0x%llx, value: 0x%llx\n", i, SymbolArray[i].Type, SymbolArray[i].Value);
195
196 if (FuncGetNumberOfOperands(SymbolArray[i].Type, &NumberOfGetOperands, &NumberOfSetOperands) == FALSE)
197 {
198 NotSupported = TRUE;
199 ShowMessages("err, unknown operand type for the operator (0x%llx)\n",
200 SymbolArray[i].Type);
201
202 return FALSE;
203 }
204
205 //
206 // Validate the operator
207 //
208 switch (SymbolArray[i].Value)
209 {
210 case FUNC_OR:
211 if (!InstanceInfo->scriptCapabilities.func_or)
212 {
213 NotSupported = TRUE;
214 ShowMessages("err, OR is not supported by the debuggee\n");
215 }
216 break;
217
218 case FUNC_XOR:
219 if (!InstanceInfo->scriptCapabilities.func_xor)
220 {
221 NotSupported = TRUE;
222 ShowMessages("err, XOR is not supported by the debuggee\n");
223 }
224 break;
225
226 case FUNC_AND:
227 if (!InstanceInfo->scriptCapabilities.func_and)
228 {
229 NotSupported = TRUE;
230 ShowMessages("err, AND is not supported by the debuggee\n");
231 }
232 break;
233
234 case FUNC_ASR:
235 if (!InstanceInfo->scriptCapabilities.func_asr)
236 {
237 NotSupported = TRUE;
238 ShowMessages("err, arithmetic shift right is not supported by the debuggee\n");
239 }
240 break;
241
242 case FUNC_ASL:
243 if (!InstanceInfo->scriptCapabilities.func_asl)
244 {
245 NotSupported = TRUE;
246 ShowMessages("err, arithmetic shift left is not supported by the debuggee\n");
247 }
248 break;
249
250 case FUNC_ADD:
251 if (!InstanceInfo->scriptCapabilities.func_add)
252 {
253 NotSupported = TRUE;
254 ShowMessages("err, addition is not supported by the debuggee\n");
255 }
256 break;
257
258 case FUNC_SUB:
259 if (!InstanceInfo->scriptCapabilities.func_sub)
260 {
261 NotSupported = TRUE;
262 ShowMessages("err, subtraction is not supported by the debuggee\n");
263 }
264 break;
265
266 case FUNC_MUL:
267 if (!InstanceInfo->scriptCapabilities.func_mul)
268 {
269 NotSupported = TRUE;
270 ShowMessages("err, multiplication is not supported by the debuggee\n");
271 }
272 break;
273
274 case FUNC_DIV:
275 if (!InstanceInfo->scriptCapabilities.func_div)
276 {
277 NotSupported = TRUE;
278 ShowMessages("err, division is not supported by the debuggee\n");
279 }
280 break;
281
282 case FUNC_MOD:
283 if (!InstanceInfo->scriptCapabilities.func_mod)
284 {
285 NotSupported = TRUE;
286 ShowMessages("err, modulus is not supported by the debuggee\n");
287 }
288 break;
289
290 case FUNC_GT:
291
292 if (!InstanceInfo->scriptCapabilities.func_gt ||
294 {
295 NotSupported = TRUE;
296 ShowMessages("err, greater than is not supported by the debuggee\n");
297 }
298 break;
299
300 case FUNC_LT:
301 if (!InstanceInfo->scriptCapabilities.func_lt ||
303 {
304 NotSupported = TRUE;
305 ShowMessages("err, less than is not supported by the debuggee\n");
306 }
307 break;
308
309 case FUNC_EGT:
310 if (!InstanceInfo->scriptCapabilities.func_egt ||
312 {
313 NotSupported = TRUE;
314 ShowMessages("err, greater than or equal to is not supported by the debuggee\n");
315 }
316 break;
317
318 case FUNC_ELT:
319 if (!InstanceInfo->scriptCapabilities.func_elt ||
321 {
322 NotSupported = TRUE;
323 ShowMessages("err, less than or equal to is not supported by the debuggee\n");
324 }
325 break;
326
327 case FUNC_EQUAL:
328 if (!InstanceInfo->scriptCapabilities.func_equal ||
330 {
331 NotSupported = TRUE;
332 ShowMessages("err, equal is not supported by the debuggee\n");
333 }
334 break;
335
336 case FUNC_NEQ:
337 if (!InstanceInfo->scriptCapabilities.func_neq ||
339 {
340 NotSupported = TRUE;
341 ShowMessages("err, not equal is not supported by the debuggee\n");
342 }
343 break;
344
345 case FUNC_JMP:
346 if (!InstanceInfo->scriptCapabilities.func_jmp ||
348 {
349 NotSupported = TRUE;
350 ShowMessages("err, jump is not supported by the debuggee\n");
351 }
352 break;
353
354 case FUNC_JZ:
355 if (!InstanceInfo->scriptCapabilities.func_jz ||
357 {
358 NotSupported = TRUE;
359 ShowMessages("err, jump if zero is not supported by the debuggee\n");
360 }
361 break;
362
363 case FUNC_JNZ:
364 if (!InstanceInfo->scriptCapabilities.func_jnz ||
366 {
367 NotSupported = TRUE;
368 ShowMessages("err, jump if not zero is not supported by the debuggee\n");
369 }
370 break;
371
372 case FUNC_MOV:
373 if (!InstanceInfo->scriptCapabilities.func_mov)
374 {
375 NotSupported = TRUE;
376 ShowMessages("err, move is not supported by the debuggee\n");
377 }
378 break;
379
380 case FUNC_PRINTF:
381 if (!InstanceInfo->scriptCapabilities.func_printf)
382 {
383 NotSupported = TRUE;
384 ShowMessages("err, printf is not supported by the debuggee\n");
385 }
386 break;
387
388 default:
389
390 NotSupported = TRUE;
391 ShowMessages("err, undefined operator for hwdbg: %lld (0x%llx)\n",
392 SymbolArray[i].Type,
393 SymbolArray[i].Type);
394
395 break;
396 }
397 }
398 }
399
400 //
401 // Set the number of stages
402 //
403 *NumberOfStages = Stages;
404
405 //
406 // Set the number of operands
407 //
408 *NumberOfOperands = Operands;
409
410 //
411 // Set the number of operands implemented
412 //
413 *NumberOfOperandsImplemented = *NumberOfStages * (InstanceInfo->maximumNumberOfSupportedGetScriptOperators + InstanceInfo->maximumNumberOfSupportedSetScriptOperators);
414
415 //
416 // Script capabilities support this buffer
417 //
418 if (NotSupported)
419 {
420 return FALSE;
421 }
422 else
423 {
424 return TRUE;
425 }
426}
UCHAR BOOLEAN
Definition BasicTypes.h:35
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
#define SYMBOL_STACK_INDEX_TYPE
Definition ScriptEngineCommonDefinitions.h:58
#define SYMBOL_REGISTER_TYPE
Definition ScriptEngineCommonDefinitions.h:47
#define FUNC_MUL
Definition ScriptEngineCommonDefinitions.h:108
#define SYMBOL_TEMP_TYPE
Definition ScriptEngineCommonDefinitions.h:50
#define SYMBOL_GLOBAL_ID_TYPE
Definition ScriptEngineCommonDefinitions.h:44
#define SYMBOL_LOCAL_ID_TYPE
Definition ScriptEngineCommonDefinitions.h:45
#define FUNC_JMP
Definition ScriptEngineCommonDefinitions.h:117
#define FUNC_GT
Definition ScriptEngineCommonDefinitions.h:111
#define FUNC_MOV
Definition ScriptEngineCommonDefinitions.h:120
#define FUNC_EGT
Definition ScriptEngineCommonDefinitions.h:113
#define FUNC_SUB
Definition ScriptEngineCommonDefinitions.h:107
#define FUNC_PRINTF
Definition ScriptEngineCommonDefinitions.h:143
#define FUNC_ASR
Definition ScriptEngineCommonDefinitions.h:104
#define FUNC_ASL
Definition ScriptEngineCommonDefinitions.h:105
#define FUNC_ELT
Definition ScriptEngineCommonDefinitions.h:114
#define FUNC_OR
Definition ScriptEngineCommonDefinitions.h:101
#define FUNC_XOR
Definition ScriptEngineCommonDefinitions.h:102
#define SYMBOL_UNDEFINED
Definition ScriptEngineCommonDefinitions.h:43
#define FUNC_ADD
Definition ScriptEngineCommonDefinitions.h:106
#define FUNC_NEQ
Definition ScriptEngineCommonDefinitions.h:116
#define FUNC_JZ
Definition ScriptEngineCommonDefinitions.h:118
#define FUNC_EQUAL
Definition ScriptEngineCommonDefinitions.h:115
#define FUNC_LT
Definition ScriptEngineCommonDefinitions.h:112
#define SYMBOL_SEMANTIC_RULE_TYPE
Definition ScriptEngineCommonDefinitions.h:49
#define FUNC_DIV
Definition ScriptEngineCommonDefinitions.h:109
#define SYMBOL_PSEUDO_REG_TYPE
Definition ScriptEngineCommonDefinitions.h:48
#define FUNC_AND
Definition ScriptEngineCommonDefinitions.h:103
#define SYMBOL_NUM_TYPE
Definition ScriptEngineCommonDefinitions.h:46
#define FUNC_MOD
Definition ScriptEngineCommonDefinitions.h:110
#define FUNC_JNZ
Definition ScriptEngineCommonDefinitions.h:119
RequestedActionOfThePacket Value(0x1) 00000000
BOOLEAN FuncGetNumberOfOperands(UINT64 FuncType, UINT32 *NumberOfGetOperands, UINT32 *NumberOfSetOperands)
Script Engine get number of operands.
Definition script-engine.c:4688
UINT64 func_or
Definition HardwareDebugger.h:149
UINT64 func_mov
Definition HardwareDebugger.h:168
UINT64 func_div
Definition HardwareDebugger.h:157
UINT64 assign_registers
Definition HardwareDebugger.h:144
UINT64 assign_local_global_var
Definition HardwareDebugger.h:143
UINT64 func_printf
Definition HardwareDebugger.h:169
UINT64 func_sub
Definition HardwareDebugger.h:155
UINT64 assign_pseudo_registers
Definition HardwareDebugger.h:145
UINT64 func_mul
Definition HardwareDebugger.h:156
UINT64 func_elt
Definition HardwareDebugger.h:162
UINT64 func_and
Definition HardwareDebugger.h:151
UINT64 func_gt
Definition HardwareDebugger.h:159
UINT64 func_jnz
Definition HardwareDebugger.h:167
UINT64 stack_assignments
Definition HardwareDebugger.h:147
UINT64 func_equal
Definition HardwareDebugger.h:163
UINT64 func_neq
Definition HardwareDebugger.h:164
UINT64 conditional_statements_and_comparison_operators
Definition HardwareDebugger.h:146
UINT64 func_jmp
Definition HardwareDebugger.h:165
UINT64 func_lt
Definition HardwareDebugger.h:160
UINT64 func_xor
Definition HardwareDebugger.h:150
UINT64 func_add
Definition HardwareDebugger.h:154
UINT64 func_asl
Definition HardwareDebugger.h:153
UINT64 func_egt
Definition HardwareDebugger.h:161
UINT64 func_mod
Definition HardwareDebugger.h:158
UINT64 func_jz
Definition HardwareDebugger.h:166
UINT64 func_asr
Definition HardwareDebugger.h:152
UINT32 maximumNumberOfSupportedGetScriptOperators
Definition HardwareDebugger.h:125
UINT32 numberOfSupportedLocalAndGlobalVariables
Definition HardwareDebugger.h:123
struct _HWDBG_INSTANCE_INFORMATION::_HWDBG_SCRIPT_CAPABILITIES scriptCapabilities
UINT32 numberOfSupportedTemporaryVariables
Definition HardwareDebugger.h:124
UINT32 maximumNumberOfSupportedSetScriptOperators
Definition HardwareDebugger.h:126
Definition ScriptEngineCommonDefinitions.h:6

◆ HardwareScriptInterpreterCompressBuffer()

BOOLEAN HardwareScriptInterpreterCompressBuffer ( UINT64 * Buffer,
size_t BufferLength,
UINT32 ScriptVariableLength,
UINT32 BramDataWidth,
size_t * NewBufferSize,
size_t * NumberOfBytesPerChunk )

Function to compress the buffer.

Parameters
Buffer
BufferLength
ScriptVariableLength
BramDataWidth
NewBufferSize
NumberOfBytesPerChunk
Returns
BOOLEAN
447{
448 if (ScriptVariableLength <= 7 || ScriptVariableLength > 64)
449 {
450 ShowMessages("err, invalid bit size, it should be between 7 and 64\n");
451 return FALSE;
452 }
453
454 if (ScriptVariableLength > BramDataWidth)
455 {
456 ShowMessages("err, script variable length cannot be more than the BRAM data width\n");
457 return FALSE;
458 }
459
460 //
461 // Calculate the number of 64-bit chunks
462 //
463 size_t NumberOfChunks = BufferLength / sizeof(UINT64);
464
465 //
466 // Calculate the number of bytes needed for the new compressed buffer
467 //
468 size_t NewBytesPerChunk = (BramDataWidth + 7) / 8; // ceil(BramDataWidth / 8)
469 *NumberOfBytesPerChunk = NewBytesPerChunk;
470
471 *NewBufferSize = NumberOfChunks * NewBytesPerChunk;
472
473 //
474 // Create a temporary buffer to hold the compressed data
475 //
476 UINT8 * TempBuffer = (UINT8 *)malloc(*NewBufferSize);
477
478 if (TempBuffer == NULL)
479 {
480 ShowMessages("err, memory allocation failed\n");
481 return FALSE;
482 }
483
484 //
485 // Compress each chunk and store it in the temporary buffer
486 //
487 for (size_t i = 0; i < NumberOfChunks; ++i)
488 {
489 uint64_t Chunk = Buffer[i];
490 for (size_t j = 0; j < NewBytesPerChunk; ++j)
491 {
492 TempBuffer[i * NewBytesPerChunk + j] = (uint8_t)((Chunk >> (j * 8)) & 0xFF);
493 }
494 }
495
496 //
497 // Copy the compressed data back to the original buffer
498 //
499 RtlZeroMemory(Buffer, BufferLength);
500 memcpy(Buffer, TempBuffer, *NewBufferSize);
501
502 //
503 // Free the temporary buffer
504 //
505 free(TempBuffer);
506
507 return TRUE;
508}
unsigned char UINT8
Definition BasicTypes.h:52

◆ HardwareScriptInterpreterConvertSymbolToHwdbgShortSymbolBuffer()

BOOLEAN HardwareScriptInterpreterConvertSymbolToHwdbgShortSymbolBuffer ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
SYMBOL * SymbolBuffer,
size_t SymbolBufferLength,
UINT32 NumberOfStages,
HWDBG_SHORT_SYMBOL ** NewShortSymbolBuffer,
size_t * NewBufferSize )

Function to compress the buffer.

Parameters
InstanceInfo
SymbolBuffer
SymbolBufferLength
NumberOfStages
NewShortSymbolBuffer
NewBufferSize
Returns
BOOLEAN
531{
532 //
533 // Check if the instance info is valid
534 //
536 {
537 ShowMessages("err, instance info is not valid\n");
538 return FALSE;
539 }
540
541 //
542 // Compute the number of symbol operators
543 //
545
546 SIZE_T NumberOfSymbols = SymbolBufferLength / sizeof(SymbolBuffer[0]);
547
548 *NewBufferSize = NumberOfStages * (NumberOfOperands + 1) * sizeof(HWDBG_SHORT_SYMBOL); // number of stage + maximum number of operands
549
550 //
551 // Create a temporary buffer to hold the compressed data
552 //
553 HWDBG_SHORT_SYMBOL * HwdbgShortSymbolBuffer = (HWDBG_SHORT_SYMBOL *)malloc(*NewBufferSize);
554
555 if (!HwdbgShortSymbolBuffer)
556 {
557 ShowMessages("err, could not allocate compression buffer\n");
558 return FALSE;
559 }
560
561 //
562 // Zeroing the short symbol buffer
563 //
564 RtlZeroMemory(HwdbgShortSymbolBuffer, *NewBufferSize);
565
566 //
567 // Filling the short symbol buffer from original buffer
568 //
569 UINT32 IndexOfShortSymbolBuffer = 0;
570
571 for (UINT32 i = 0; i < NumberOfSymbols; i++)
572 {
573 if (SymbolBuffer[i].Type == SYMBOL_SEMANTIC_RULE_TYPE)
574 {
575 //
576 // *** This is an operator ***
577 //
578
579 //
580 // Move the symbol buffer into a short symbol buffer
581 //
582 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Type = SymbolBuffer[i].Type;
583 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Value = SymbolBuffer[i].Value;
584
585 //
586 // Now we read the number of operands (SET and GET)
587 //
588 UINT32 NumberOfGetOperands = 0;
589 UINT32 NumberOfSetOperands = 0;
590
591 if (!FuncGetNumberOfOperands(SymbolBuffer[i].Value, &NumberOfGetOperands, &NumberOfSetOperands))
592 {
593 ShowMessages("err, unknown operand type for the operator (0x%llx)\n",
594 SymbolBuffer[i].Value);
595
596 free(HwdbgShortSymbolBuffer);
597 return FALSE;
598 }
599
600 //
601 // Check if the number of GET operands is more than the maximum supported GET operands
602 //
603 if (NumberOfGetOperands > InstanceInfo->maximumNumberOfSupportedGetScriptOperators)
604 {
605 ShowMessages("err, the number of get operands is more than the maximum supported get operands\n");
606 free(HwdbgShortSymbolBuffer);
607 return FALSE;
608 }
609
610 //
611 // Check if the number of SET operands is more than the maximum supported SET operands
612 //
613 if (NumberOfSetOperands > InstanceInfo->maximumNumberOfSupportedSetScriptOperators)
614 {
615 ShowMessages("err, the number of set operands is more than the maximum supported set operands\n");
616 free(HwdbgShortSymbolBuffer);
617 return FALSE;
618 }
619
620 //
621 // *** Now we need to fill operands (GET) ***
622 //
623 for (size_t j = 0; j < NumberOfGetOperands; j++)
624 {
625 i++;
626 IndexOfShortSymbolBuffer++;
627
628 if (SymbolBuffer[i].Type == SYMBOL_SEMANTIC_RULE_TYPE)
629 {
630 ShowMessages("err, not expecting a semantic rule at operand: %llx\n", SymbolBuffer[i].Value);
631 free(HwdbgShortSymbolBuffer);
632 return FALSE;
633 }
634
635 //
636 // Move the symbol buffer into a short symbol buffer
637 //
638 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Type = SymbolBuffer[i].Type;
639 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Value = SymbolBuffer[i].Value;
640 }
641
642 //
643 // Leave empty space for GET operands that are not used for this operator
644 //
645 IndexOfShortSymbolBuffer = IndexOfShortSymbolBuffer + InstanceInfo->maximumNumberOfSupportedGetScriptOperators - NumberOfGetOperands;
646
647 //
648 // *** Now we need to fill operands (SET) ***
649 //
650 for (size_t j = 0; j < NumberOfSetOperands; j++)
651 {
652 i++;
653 IndexOfShortSymbolBuffer++;
654
655 if (SymbolBuffer[i].Type == SYMBOL_SEMANTIC_RULE_TYPE)
656 {
657 ShowMessages("err, not expecting a semantic rule at operand: %llx\n", SymbolBuffer[i].Value);
658 free(HwdbgShortSymbolBuffer);
659 return FALSE;
660 }
661
662 //
663 // Move the symbol buffer into a short symbol buffer
664 //
665 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Type = SymbolBuffer[i].Type;
666 HwdbgShortSymbolBuffer[IndexOfShortSymbolBuffer].Value = SymbolBuffer[i].Value;
667 }
668
669 //
670 // Leave empty space for SET operands that are not used for this operator
671 //
672 IndexOfShortSymbolBuffer = IndexOfShortSymbolBuffer + InstanceInfo->maximumNumberOfSupportedSetScriptOperators - NumberOfSetOperands;
673
674 //
675 // Increment the index of the short symbol buffer
676 //
677 IndexOfShortSymbolBuffer++;
678 }
679 else
680 {
681 //
682 // Error, we are not expecting a non-semantic rule here
683 //
684 ShowMessages("err, not expecting a non-semantic rule at: %llx\n", SymbolBuffer[i].Type);
685 free(HwdbgShortSymbolBuffer);
686 return FALSE;
687 }
688 }
689
690 //
691 // Set the new short symbol buffer address
692 //
693 *NewShortSymbolBuffer = (HWDBG_SHORT_SYMBOL *)HwdbgShortSymbolBuffer;
694
695 return TRUE;
696}
BOOLEAN g_HwdbgInstanceInfoIsValid
Shows whether the instance info is valid (received) or not.
Definition globals.h:697
Definition ScriptEngineCommonDefinitions.h:16
long long unsigned Type
Definition ScriptEngineCommonDefinitions.h:17
long long unsigned Value
Definition ScriptEngineCommonDefinitions.h:18
long long unsigned Value
Definition ScriptEngineCommonDefinitions.h:9
long long unsigned Type
Definition ScriptEngineCommonDefinitions.h:7

◆ HardwareScriptInterpreterFreeHwdbgShortSymbolBuffer()

VOID HardwareScriptInterpreterFreeHwdbgShortSymbolBuffer ( HWDBG_SHORT_SYMBOL * NewShortSymbolBuffer)

Function free the short symbol buffer.

Parameters
NewShortSymbolBuffer
Returns
VOID
707{
708 if (NewShortSymbolBuffer)
709 {
710 free(NewShortSymbolBuffer);
711 }
712}

◆ HardwareScriptInterpreterShowScriptCapabilities()

VOID HardwareScriptInterpreterShowScriptCapabilities ( HWDBG_INSTANCE_INFORMATION * InstanceInfo)

Shows the script capabilities of the target debuggee.

Parameters
InstanceInfo
Returns
VOID
23{
24 ShowMessages("\nThis debuggee supports the following operators:\n");
25 ShowMessages("\tlocal and global variable assignments: %s (maximum number of var: %d) \n",
26 InstanceInfo->scriptCapabilities.assign_local_global_var ? "supported" : "not supported",
28 ShowMessages("\tregisters (pin/ports) assignment: %s \n",
29 InstanceInfo->scriptCapabilities.assign_registers ? "supported" : "not supported");
30 ShowMessages("\tpseudo-registers assignment: %s \n",
31 InstanceInfo->scriptCapabilities.assign_pseudo_registers ? "supported" : "not supported");
32 ShowMessages("\tconditional statements and comparison operators: %s \n",
33 InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators ? "supported" : "not supported");
34
35 ShowMessages("\tor: %s \n", InstanceInfo->scriptCapabilities.func_or ? "supported" : "not supported");
36 ShowMessages("\txor: %s \n", InstanceInfo->scriptCapabilities.func_xor ? "supported" : "not supported");
37 ShowMessages("\tand: %s \n", InstanceInfo->scriptCapabilities.func_and ? "supported" : "not supported");
38 ShowMessages("\tarithmetic shift right: %s \n", InstanceInfo->scriptCapabilities.func_asr ? "supported" : "not supported");
39 ShowMessages("\tarithmetic shift left: %s \n", InstanceInfo->scriptCapabilities.func_asl ? "supported" : "not supported");
40 ShowMessages("\taddition: %s \n", InstanceInfo->scriptCapabilities.func_add ? "supported" : "not supported");
41 ShowMessages("\tsubtraction: %s \n", InstanceInfo->scriptCapabilities.func_sub ? "supported" : "not supported");
42 ShowMessages("\tmultiplication: %s \n", InstanceInfo->scriptCapabilities.func_mul ? "supported" : "not supported");
43 ShowMessages("\tdivision: %s \n", InstanceInfo->scriptCapabilities.func_div ? "supported" : "not supported");
44 ShowMessages("\tmodulus: %s \n", InstanceInfo->scriptCapabilities.func_mod ? "supported" : "not supported");
45
46 ShowMessages("\tgreater than: %s \n",
47 (InstanceInfo->scriptCapabilities.func_gt && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
48 ShowMessages("\tless than: %s \n",
49 (InstanceInfo->scriptCapabilities.func_lt && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
50 ShowMessages("\tgreater than or equal to: %s \n",
51 (InstanceInfo->scriptCapabilities.func_egt && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
52 ShowMessages("\tless than or equal to: %s \n",
53 (InstanceInfo->scriptCapabilities.func_elt && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
54 ShowMessages("\tequal: %s \n",
55 (InstanceInfo->scriptCapabilities.func_equal && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
56 ShowMessages("\tnot equal: %s \n",
57 (InstanceInfo->scriptCapabilities.func_neq && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
58 ShowMessages("\tjump: %s \n",
59 (InstanceInfo->scriptCapabilities.func_jmp && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
60 ShowMessages("\tjump if zero: %s \n",
61 (InstanceInfo->scriptCapabilities.func_jz && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
62 ShowMessages("\tjump if not zero: %s \n",
63 (InstanceInfo->scriptCapabilities.func_jnz && InstanceInfo->scriptCapabilities.conditional_statements_and_comparison_operators) ? "supported" : "not supported");
64 ShowMessages("\tmove: %s \n", InstanceInfo->scriptCapabilities.func_mov ? "supported" : "not supported");
65 ShowMessages("\tprintf: %s \n", InstanceInfo->scriptCapabilities.func_printf ? "supported" : "not supported");
66 ShowMessages("\n");
67}