HyperDbg Debugger
Loading...
Searching...
No Matches
hwdbg-interpreter.h File Reference

Headers for the interpreter of hwdbg packets and requests. More...

Go to the source code of this file.

Functions

VOID HwdbgShowIntanceInfo (HWDBG_INSTANCE_INFORMATION *InstanceInfo)
 Show instance info details.
BOOLEAN HwdbgInterpretPacket (PVOID BufferReceived, UINT32 LengthReceived)
 Interpret packets of hwdbg.
BOOLEAN HwdbgInterpreterFillFileFromMemory (HWDBG_INSTANCE_INFORMATION *InstanceInfo, const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize, HWDBG_ACTION_ENUMS RequestedAction)
 Function to write the memory buffer to a file in the specified format.
BOOLEAN HwdbgInterpreterFillMemoryFromFile (const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize)
 Function to read the file and fill the memory buffer.
SIZE_T HwdbgComputeNumberOfFlipFlopsNeeded (HWDBG_INSTANCE_INFORMATION *InstanceInfo, UINT32 NumberOfStages)
 Function to compute number of flip-flops needed in the target device.
BOOLEAN HwdbgInterpreterSendPacketAndBufferToHwdbg (HWDBG_INSTANCE_INFORMATION *InstanceInfo, const TCHAR *FileName, DEBUGGER_REMOTE_PACKET_TYPE PacketType, HWDBG_ACTION_ENUMS RequestedAction, CHAR *Buffer, UINT32 BufferLength)
 Sends a HyperDbg packet + a buffer to the hwdbg.
BOOLEAN HwdbgReadInstanceInfoFromFile (const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize)
 Read the instance info from the file.
BOOLEAN HwdbgWriteTestInstanceInfoRequestIntoFile (HWDBG_INSTANCE_INFORMATION *InstanceInfo, const CHAR *FileName)
 Write test instance info request into a file.
BOOLEAN HwdbgLoadInstanceInfo (const TCHAR *InstanceFilePathToRead, UINT32 InitialBramBufferSize)
 Load the instance info.

Detailed Description

Headers for the interpreter of hwdbg packets and requests.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.10
Date
2024-06-11

Function Documentation

◆ HwdbgComputeNumberOfFlipFlopsNeeded()

SIZE_T HwdbgComputeNumberOfFlipFlopsNeeded ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
UINT32 NumberOfStages )

Function to compute number of flip-flops needed in the target device.

Parameters
InstanceInfo
NumberOfStages
Returns
SIZE_T
333{
334 //
335 // Calculate the number of flip-flops needed in the target device
336 // + operator symbol itself which only contains value (type is always equal to SYMBOL_SEMANTIC_RULE_TYPE)
337 // so, it is not counted as a flip-flop
338 //
339 SIZE_T NumberOfNeededFlipFlopsInTargetDevice = 0;
340
341 //
342 // size of operator (GET and SET)
343 //
344 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages *
345 (g_HwdbgInstanceInfo.maximumNumberOfSupportedGetScriptOperators + g_HwdbgInstanceInfo.maximumNumberOfSupportedSetScriptOperators) *
346 g_HwdbgInstanceInfo.scriptVariableLength *
347 sizeof(HWDBG_SHORT_SYMBOL) / sizeof(UINT64));
348
349 //
350 // size of main operator (/ 2 is because Type is not inferred)
351 //
352 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages * g_HwdbgInstanceInfo.scriptVariableLength * (sizeof(HWDBG_SHORT_SYMBOL) / sizeof(UINT64)) / 2);
353
354 //
355 // size of local (and global) variables
356 //
357 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages * g_HwdbgInstanceInfo.numberOfSupportedLocalAndGlobalVariables * g_HwdbgInstanceInfo.scriptVariableLength);
358
359 //
360 // size of temporary variables
361 //
362 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages * g_HwdbgInstanceInfo.numberOfSupportedTemporaryVariables * g_HwdbgInstanceInfo.scriptVariableLength);
363
364 //
365 // size of stage index register + targetStage (* 2)
366 //
367 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages * Log2Ceil(g_HwdbgInstanceInfo.maximumNumberOfStages * (g_HwdbgInstanceInfo.maximumNumberOfSupportedGetScriptOperators + g_HwdbgInstanceInfo.maximumNumberOfSupportedSetScriptOperators + 1)) * 2);
368
369 //
370 // stage enable flip-flop
371 //
372 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages);
373
374 //
375 // input => output flip-flop
376 //
377 NumberOfNeededFlipFlopsInTargetDevice += (NumberOfStages * g_HwdbgInstanceInfo.numberOfPins);
378
379 //
380 // return the number of flip-flops needed in the target device
381 //
382 return NumberOfNeededFlipFlopsInTargetDevice;
383}
UINT32 Log2Ceil(UINT32 n)
Function to compute log2Ceil.
Definition common.cpp:1263
HWDBG_INSTANCE_INFORMATION g_HwdbgInstanceInfo
Instance information of the current hwdbg debuggee.
Definition globals.h:691
Definition ScriptEngineCommonDefinitions.h:16

◆ HwdbgInterpreterFillFileFromMemory()

BOOLEAN HwdbgInterpreterFillFileFromMemory ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
const TCHAR * FileName,
UINT32 * MemoryBuffer,
SIZE_T BufferSize,
HWDBG_ACTION_ENUMS RequestedAction )

Function to write the memory buffer to a file in the specified format.

Parameters
InstanceInfo
FileName
MemoryBuffer
BufferSize
RequestedAction
Returns
BOOLEAN
248{
249 std::ofstream File(FileName);
250
251 if (!File.is_open())
252 {
253 printf("err, unable to open file %s\n", FileName);
254 return FALSE;
255 }
256
257 SIZE_T Address = 0;
258 for (SIZE_T I = 0; I < BufferSize / sizeof(UINT32); ++I)
259 {
260 File << std::hex << std::setw(8) << std::setfill('0') << MemoryBuffer[I];
261 File << " ; +0x" << std::hex << std::setw(1) << std::setfill('0') << Address;
262
263 if (I == 0)
264 {
265 File << " | Checksum";
266 }
267 else if (I == 1)
268 {
269 File << " | Checksum";
270 }
271 else if (I == 2)
272 {
273 File << " | Indicator";
274 }
275 else if (I == 3)
276 {
277 File << " | Indicator";
278 }
279 else if (I == 4)
280 {
281 File << " | TypeOfThePacket - DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL (0x4)";
282 }
283 else if (I == 5)
284 {
285 File << " | RequestedActionOfThePacket - Value" << " (0x" << std::hex << std::setw(1) << std::setfill('0') << RequestedAction << ")";
286 }
287 else if (I == 6)
288 {
289 File << " | Start of Optional Data";
290 }
291
292 File << "\n";
293 Address += 4;
294 }
295
296 //
297 // Add zeros to the end of the file to fill the shared memory
298 //
300 {
301 while (Address < InstanceInfo->sharedMemorySize)
302 {
303 File << "00000000 ; +0x" << std::hex << std::setw(1) << std::setfill('0') << Address;
304 Address += 4;
305
306 if (Address < InstanceInfo->sharedMemorySize)
307 {
308 File << "\n";
309 }
310 }
311 }
312
313 //
314 // Close the file
315 //
316 File.close();
317
318 return TRUE;
319}
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
printf("ho")
BOOLEAN g_HwdbgInstanceInfoIsValid
Shows whether the instance info is valid (received) or not.
Definition globals.h:697

◆ HwdbgInterpreterFillMemoryFromFile()

BOOLEAN HwdbgInterpreterFillMemoryFromFile ( const TCHAR * FileName,
UINT32 * MemoryBuffer,
SIZE_T BufferSize )

Function to read the file and fill the memory buffer.

Parameters
FileName
MemoryBuffer
BufferSize
Returns
BOOLEAN
188{
189 std::ifstream File(FileName);
190 std::string Line;
191 BOOLEAN Result = TRUE;
192 SIZE_T Index = 0;
193
194 if (!File.is_open())
195 {
196 ShowMessages("err, unable to open file %s\n", FileName);
197 return FALSE;
198 }
199
200 while (getline(File, Line))
201 {
202 if (Index >= BufferSize)
203 {
204 Result = FALSE;
205 ShowMessages("err, buffer overflow, file contains more data than buffer can hold\n");
206 break;
207 }
208
209 vector<UINT32> Values = HwdbgParseStringMemoryLine(Line);
210
211 for (UINT32 Value : Values)
212 {
213 if (Index < BufferSize)
214 {
215 MemoryBuffer[Index++] = Value;
216 }
217 else
218 {
219 ShowMessages("err, buffer overflow, file contains more data than buffer can hold\n");
220 File.close();
221 return FALSE;
222 }
223 }
224 }
225
226 File.close();
227 return Result;
228}
UCHAR BOOLEAN
Definition BasicTypes.h:35
std::vector< UINT32 > HwdbgParseStringMemoryLine(const std::string &Line)
Function to parse a single line of the memory content.
Definition hwdbg-interpreter.cpp:154
RequestedActionOfThePacket Value(0x1) 00000000

◆ HwdbgInterpreterSendPacketAndBufferToHwdbg()

BOOLEAN HwdbgInterpreterSendPacketAndBufferToHwdbg ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
const TCHAR * FileName,
DEBUGGER_REMOTE_PACKET_TYPE PacketType,
HWDBG_ACTION_ENUMS RequestedAction,
CHAR * Buffer,
UINT32 BufferLength )

Sends a HyperDbg packet + a buffer to the hwdbg.

Parameters
InstanceInfo
FileName
PacketType
RequestedAction
Buffer
BufferLength
Returns
BOOLEAN
404{
405 DEBUGGER_REMOTE_PACKET Packet = {0};
406 SIZE_T CommandMaxSize = 0;
407 SIZE_T FinalBufferSize = 0;
408
410 {
411 CommandMaxSize = InstanceInfo->debuggeeAreaOffset - InstanceInfo->debuggerAreaOffset;
412 }
413 else
414 {
415 //
416 // Use default limitation
417 //
419 }
420
421 //
422 // If buffer is not available, then the length is zero
423 //
424 if (Buffer == NULL)
425 {
426 BufferLength = 0;
427 }
428
429 //
430 // Compute the final buffer size
431 //
432 FinalBufferSize = sizeof(DEBUGGER_REMOTE_PACKET) + BufferLength;
433
434 //
435 // Check if buffer not pass the boundary
436 //
437 if (FinalBufferSize > CommandMaxSize)
438 {
439 ShowMessages("err, buffer is above the maximum buffer size that can be sent to hwdbg (%d > %d)\n",
440 FinalBufferSize,
441 CommandMaxSize);
442
443 return FALSE;
444 }
445
446 //
447 // Make the packet's structure
448 //
450 Packet.TypeOfThePacket = PacketType;
451
452 //
453 // Set the requested action
454 //
456
457 //
458 // calculate checksum of the packet
459 //
460 Packet.Checksum =
461 KdComputeDataChecksum((PVOID)((UINT64)&Packet + 1),
462 sizeof(DEBUGGER_REMOTE_PACKET) - sizeof(BYTE));
463
464 if (Buffer != NULL)
465 {
466 Packet.Checksum += KdComputeDataChecksum((PVOID)Buffer, BufferLength);
467 }
468
469 //
470 // If there is an offset for debugger to debuggee command, we'll apply it here
471 //
473 {
474 FinalBufferSize += InstanceInfo->debuggerAreaOffset;
475 }
476 else
477 {
479 }
480
481 //
482 // Allocate a buffer for storing the header packet + buffer (if not empty)
483 //
484 CHAR * FinalBuffer = (CHAR *)malloc(FinalBufferSize);
485
486 if (!FinalBuffer)
487 {
488 return FALSE;
489 }
490
491 RtlZeroMemory(FinalBuffer, FinalBufferSize);
492
493 //
494 // Leave the offset
495 //
497
498 //
499 // Copy the packet into the FinalBuffer
500 //
501 memcpy(FinalBuffer + Offset, &Packet, sizeof(DEBUGGER_REMOTE_PACKET));
502
503 //
504 // Copy the buffer (if available) into the FinalBuffer
505 //
506 if (Buffer != NULL)
507 {
508 memcpy(FinalBuffer + Offset + sizeof(DEBUGGER_REMOTE_PACKET), Buffer, BufferLength);
509 }
510
511 //
512 // Here you would send FinalBuffer to the hardware debugger
513 //
514 HwdbgInterpreterFillFileFromMemory(InstanceInfo, FileName, (UINT32 *)FinalBuffer, FinalBufferSize, RequestedAction);
515
516 //
517 // Free the allocated memory after use
518 //
519 free(FinalBuffer);
520
521 return TRUE;
522}
_Use_decl_annotations_ BYTE KdComputeDataChecksum(PVOID Buffer, UINT32 Length)
calculate the checksum of received buffer from debugger
Definition Kd.c:275
void * PVOID
Definition BasicTypes.h:56
unsigned char BYTE
Definition BasicTypes.h:40
char CHAR
Definition BasicTypes.h:33
enum _DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION
enum for requested action for HyperDbg packet
struct _DEBUGGER_REMOTE_PACKET DEBUGGER_REMOTE_PACKET
The structure of remote packets in HyperDbg.
#define INDICATOR_OF_HYPERDBG_PACKET
constant indicator of a HyperDbg packet
Definition Constants.h:504
#define DEFAULT_INITIAL_DEBUGGEE_TO_DEBUGGER_OFFSET
Initial debuggee to debugger offset.
Definition HardwareDebugger.h:23
#define DEFAULT_INITIAL_DEBUGGER_TO_DEBUGGEE_OFFSET
Initial debugger to debuggee offset.
Definition HardwareDebugger.h:29
BOOLEAN HwdbgInterpreterFillFileFromMemory(HWDBG_INSTANCE_INFORMATION *InstanceInfo, const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize, HWDBG_ACTION_ENUMS RequestedAction)
Function to write the memory buffer to a file in the specified format.
Definition hwdbg-interpreter.cpp:242
DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket
Definition Connection.h:201
DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket
Definition Connection.h:200
BYTE Checksum
Definition Connection.h:198
UINT64 Indicator
Definition Connection.h:199
UINT32 debuggeeAreaOffset
Definition HardwareDebugger.h:129
UINT32 debuggerAreaOffset
Definition HardwareDebugger.h:128

◆ HwdbgInterpretPacket()

BOOLEAN HwdbgInterpretPacket ( PVOID BufferReceived,
UINT32 LengthReceived )

Interpret packets of hwdbg.

Parameters
BufferReceived
LengthReceived
Returns
BOOLEAN
30{
31 PHWDBG_INSTANCE_INFORMATION InstanceInfoPacket;
32 PUINT32 InstanceInfoPorts;
33 DEBUGGER_REMOTE_PACKET * TheActualPacket = NULL;
34 BOOLEAN Result = FALSE;
35
36 //
37 // Apply the initial offset
38 //
40 {
41 //
42 // Use the debuggee's preferred offset (area) since the instance info
43 // already received and interpreted
44 //
45 TheActualPacket = (DEBUGGER_REMOTE_PACKET *)(((CHAR *)BufferReceived) + g_HwdbgInstanceInfo.debuggeeAreaOffset);
46 }
47 else
48 {
49 //
50 // Use default initial offset as there is no information (instance info)
51 // from debuggee
52 //
53 TheActualPacket = (DEBUGGER_REMOTE_PACKET *)(((CHAR *)BufferReceived) + DEFAULT_INITIAL_DEBUGGEE_TO_DEBUGGER_OFFSET);
54 }
55
56 if (TheActualPacket->Indicator == INDICATOR_OF_HYPERDBG_PACKET)
57 {
58 //
59 // Check checksum (for hwdbg, checksum is ignored)
60 //
61 // if (KdComputeDataChecksum((PVOID)&TheActualPacket->Indicator,
62 // LengthReceived - sizeof(BYTE)) != TheActualPacket->Checksum)
63 // {
64 // ShowMessages("err, checksum is invalid\n");
65 // return FALSE;
66 // }
67
68 //
69 // Check if the packet type is correct
70 //
72 {
73 //
74 // sth wrong happened, the packet is not belonging to use
75 // for hwdbg interpreter
76 //
77 ShowMessages("err, unknown packet received from the debuggee\n");
78 return FALSE;
79 }
80
81 //
82 // It's a HyperDbg packet (for hwdbg)
83 //
84 switch (TheActualPacket->RequestedActionOfThePacket)
85 {
87
88 Result = TRUE;
89
90 //
91 // Todo: implement it
92 //
93
94 break;
95
97
98 Result = TRUE;
99 InstanceInfoPacket = (HWDBG_INSTANCE_INFORMATION *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
100 InstanceInfoPorts = (UINT32 *)(((CHAR *)InstanceInfoPacket) + sizeof(HWDBG_INSTANCE_INFORMATION));
101
102 //
103 // Copy the instance info into the global hwdbg instance info
104 //
105 RtlCopyMemory(&g_HwdbgInstanceInfo, InstanceInfoPacket, sizeof(HWDBG_INSTANCE_INFORMATION));
106
107 //
108 // Reset previous port configurations (if any)
109 //
111
112 //
113 // Instance info is valid from now
114 //
116
117 //
118 // Read port arrangements
119 //
120 for (SIZE_T i = 0; i < g_HwdbgInstanceInfo.numberOfPorts; i++)
121 {
122 g_HwdbgPortConfiguration.push_back(InstanceInfoPorts[i]);
123 }
124
125 //
126 // Infom the script engine about the instance info
127 //
129
130 break;
131
132 default:
133
134 Result = FALSE;
135 ShowMessages("err, unknown packet request received from the debuggee\n");
136
137 break;
138 }
139 }
140
141 //
142 // Packet handled successfully
143 //
144 return Result;
145}
unsigned int * PUINT32
Definition BasicTypes.h:54
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER_HARDWARE_LEVEL
Definition Connection.h:188
struct _HWDBG_INSTANCE_INFORMATION HWDBG_INSTANCE_INFORMATION
The structure of script capabilities information in hwdbg.
struct _HWDBG_INSTANCE_INFORMATION * PHWDBG_INSTANCE_INFORMATION
@ hwdbgResponseSuccessOrErrorMessage
Definition HardwareDebugger.h:79
@ hwdbgResponseInstanceInfo
Definition HardwareDebugger.h:80
IMPORT_EXPORT_HYPERDBG_SCRIPT_ENGINE BOOLEAN ScriptEngineSetHwdbgInstanceInfo(HWDBG_INSTANCE_INFORMATION *InstancInfo)
Set hwdbg instance info for the script engine.
Definition script-engine.c:4664
std::vector< UINT32 > g_HwdbgPortConfiguration
Ports configuration of hwdbg.
Definition globals.h:703
NULL()
Definition test-case-generator.py:530

◆ HwdbgLoadInstanceInfo()

BOOLEAN HwdbgLoadInstanceInfo ( const TCHAR * InstanceFilePathToRead,
UINT32 InitialBramBufferSize )

Load the instance info.

Parameters
InstanceFilePathToRead
InitialBramBufferSize
Returns
BOOLEAN
649{
650 UINT32 * MemoryBuffer = NULL;
651
652 //
653 // Allocate memory buffer to read the instance info
654 //
655 MemoryBuffer = (UINT32 *)malloc(InitialBramBufferSize * sizeof(UINT32));
656
657 if (MemoryBuffer == NULL)
658 {
659 //
660 // Memory allocation failed
661 //
662 ShowMessages("err, unable to allocate memory for the instance info packet of the debuggee");
663 return FALSE;
664 }
665
666 //
667 // *** Read the instance info from the file ***
668 //
669 if (HwdbgReadInstanceInfoFromFile(InstanceFilePathToRead, MemoryBuffer, InitialBramBufferSize))
670 {
671 ShowMessages("instance info read successfully\n");
672 }
673 else
674 {
675 ShowMessages("err, unable to read instance info packet of the debuggee");
676 free(MemoryBuffer);
677 return FALSE;
678 }
679
680 //
681 // *** Interpret instance info packet ***
682 //
683 if (HwdbgInterpretPacket(MemoryBuffer, InitialBramBufferSize))
684 {
685 ShowMessages("instance info interpreted successfully\n");
687 }
688 else
689 {
690 ShowMessages("err, unable to interpret instance info packet of the debuggee");
691 free(MemoryBuffer);
692 return FALSE;
693 }
694
695 //
696 // The instance info is loaded successfully
697 //
698 free(MemoryBuffer);
699 return TRUE;
700}
BOOLEAN HwdbgReadInstanceInfoFromFile(const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize)
Read the instance info from the file.
Definition hwdbg-interpreter.cpp:575
BOOLEAN HwdbgInterpretPacket(PVOID BufferReceived, UINT32 LengthReceived)
Interpret packets of hwdbg.
Definition hwdbg-interpreter.cpp:29
VOID HwdbgShowIntanceInfo(HWDBG_INSTANCE_INFORMATION *InstanceInfo)
Show instance info details.
Definition hwdbg-interpreter.cpp:532

◆ HwdbgReadInstanceInfoFromFile()

BOOLEAN HwdbgReadInstanceInfoFromFile ( const TCHAR * FileName,
UINT32 * MemoryBuffer,
SIZE_T BufferSize )

Read the instance info from the file.

Parameters
FileName
MemoryBuffer
BufferSize
Returns
BOOLEAN
576{
577 TCHAR TestFilePath[MAX_PATH] = {0};
578
579 if (SetupPathForFileName(HWDBG_TEST_READ_INSTANCE_INFO_PATH, TestFilePath, sizeof(TestFilePath), TRUE) &&
580 HwdbgInterpreterFillMemoryFromFile(TestFilePath, MemoryBuffer, BufferSize))
581 {
582 //
583 // Print the content of MemoryBuffer for verification
584 //
585 for (SIZE_T I = 0; I < BufferSize; ++I)
586 {
587 ShowMessages("%08x ", MemoryBuffer[I]);
588 ShowMessages("\n");
589 }
590
591 //
592 // the instance info packet is read successfully
593 //
594 return TRUE;
595 }
596
597 //
598 // the instance info packet is not read successfully
599 //
600 return FALSE;
601}
#define HWDBG_TEST_READ_INSTANCE_INFO_PATH
Path to read the sample of the instance info.
Definition HardwareDebugger.h:42
BOOLEAN HwdbgInterpreterFillMemoryFromFile(const TCHAR *FileName, UINT32 *MemoryBuffer, SIZE_T BufferSize)
Function to read the file and fill the memory buffer.
Definition hwdbg-interpreter.cpp:184
BOOLEAN SetupPathForFileName(const CHAR *FileName, _Inout_updates_bytes_all_(BufferLength) PCHAR FileLocation, ULONG BufferLength, BOOLEAN CheckFileExists)
Setup file name.
Definition install.cpp:472

◆ HwdbgShowIntanceInfo()

VOID HwdbgShowIntanceInfo ( HWDBG_INSTANCE_INFORMATION * InstanceInfo)

Show instance info details.

Parameters
InstanceInfo
Returns
VOID
533{
534 UINT32 PortNum = 0;
535
536 ShowMessages("Debuggee Version: 0x%x\n", InstanceInfo->version);
537 ShowMessages("Debuggee Maximum Number Of Stages: 0x%x\n", InstanceInfo->maximumNumberOfStages);
538 ShowMessages("Debuggee Script Variable Length: 0x%x\n", InstanceInfo->scriptVariableLength);
539 ShowMessages("Debuggee Number of Supported Local (and global) Variables: 0x%x\n", InstanceInfo->numberOfSupportedLocalAndGlobalVariables);
540 ShowMessages("Debuggee Number of Supported Temporary Variables: 0x%x\n", InstanceInfo->numberOfSupportedTemporaryVariables);
541 ShowMessages("Debuggee Maximum Number Of Supported GET Script Operators: 0x%x\n", InstanceInfo->maximumNumberOfSupportedGetScriptOperators);
542 ShowMessages("Debuggee Maximum Number Of Supported SET Script Operators: 0x%x\n", InstanceInfo->maximumNumberOfSupportedSetScriptOperators);
543 ShowMessages("Debuggee Shared Memory Size: 0x%x\n", InstanceInfo->sharedMemorySize);
544 ShowMessages("Debuggee Debugger Area Offset: 0x%x\n", InstanceInfo->debuggerAreaOffset);
545 ShowMessages("Debuggee Debuggee Area Offset: 0x%x\n", InstanceInfo->debuggeeAreaOffset);
546 ShowMessages("Debuggee Script Capabilities Mask: 0x%llx\n", InstanceInfo->scriptCapabilities);
547
548 //
549 // Show script capabilities
550 //
552
553 ShowMessages("Debuggee Number Of Pins: 0x%x\n", InstanceInfo->numberOfPins);
554 ShowMessages("Debuggee Number Of Ports: 0x%x\n", InstanceInfo->numberOfPorts);
555
556 ShowMessages("Debuggee BRAM Address Width: 0x%x\n", InstanceInfo->bramAddrWidth);
557 ShowMessages("Debuggee BRAM Data Width: 0x%x (%d bit)\n", InstanceInfo->bramDataWidth, InstanceInfo->bramDataWidth);
558
559 for (auto item : g_HwdbgPortConfiguration)
560 {
561 ShowMessages("Port number %d ($hw_port%d): 0x%x\n", PortNum, PortNum, item);
562 PortNum++;
563 }
564}
IMPORT_EXPORT_HYPERDBG_SCRIPT_ENGINE VOID HardwareScriptInterpreterShowScriptCapabilities(HWDBG_INSTANCE_INFORMATION *InstanceInfo)
Shows the script capabilities of the target debuggee.
Definition hardware.c:22
UINT32 version
Definition HardwareDebugger.h:120
UINT32 sharedMemorySize
Definition HardwareDebugger.h:127
UINT32 maximumNumberOfSupportedGetScriptOperators
Definition HardwareDebugger.h:125
UINT32 numberOfSupportedLocalAndGlobalVariables
Definition HardwareDebugger.h:123
struct _HWDBG_INSTANCE_INFORMATION::_HWDBG_SCRIPT_CAPABILITIES scriptCapabilities
UINT32 maximumNumberOfStages
Definition HardwareDebugger.h:121
UINT32 numberOfSupportedTemporaryVariables
Definition HardwareDebugger.h:124
UINT32 numberOfPorts
Definition HardwareDebugger.h:131
UINT32 bramAddrWidth
Definition HardwareDebugger.h:178
UINT32 maximumNumberOfSupportedSetScriptOperators
Definition HardwareDebugger.h:126
UINT32 bramDataWidth
Definition HardwareDebugger.h:179
UINT32 numberOfPins
Definition HardwareDebugger.h:130
UINT32 scriptVariableLength
Definition HardwareDebugger.h:122

◆ HwdbgWriteTestInstanceInfoRequestIntoFile()

BOOLEAN HwdbgWriteTestInstanceInfoRequestIntoFile ( HWDBG_INSTANCE_INFORMATION * InstanceInfo,
const CHAR * FileName )

Write test instance info request into a file.

Parameters
InstanceInfo
FileName
Returns
BOOLEAN
614{
615 TCHAR TestFilePath[MAX_PATH] = {0};
616
617 //
618 // Write test instance info request into a file
619 //
620 if (SetupPathForFileName(FileName, TestFilePath, sizeof(TestFilePath), FALSE) &&
622 InstanceInfo,
623 TestFilePath,
626 NULL,
627 NULL_ZERO))
628 {
629 ShowMessages("[*] instance info successfully written into file: %s\n", TestFilePath);
630 return TRUE;
631 }
632
633 //
634 // Unable to write instance info request into a file
635 //
636 return FALSE;
637}
#define NULL_ZERO
Definition BasicTypes.h:110
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL
Definition Connection.h:183
@ hwdbgActionSendInstanceInfo
Definition HardwareDebugger.h:67
BOOLEAN HwdbgInterpreterSendPacketAndBufferToHwdbg(HWDBG_INSTANCE_INFORMATION *InstanceInfo, const TCHAR *FileName, DEBUGGER_REMOTE_PACKET_TYPE PacketType, HWDBG_ACTION_ENUMS RequestedAction, CHAR *Buffer, UINT32 BufferLength)
Sends a HyperDbg packet + a buffer to the hwdbg.
Definition hwdbg-interpreter.cpp:398