HyperDbg Debugger
Loading...
Searching...
No Matches
hw_clk.cpp File Reference

!hw_clk command More...

#include "pch.h"

Functions

VOID CommandHwClkHelp ()
 help of the !hw_clk command
BOOLEAN CommandHwClkPerformTest (vector< CommandToken > CommandTokens, const TCHAR *InstanceFilePathToRead, const TCHAR *InstanceFilePathToSave, const TCHAR *HardwareScriptFilePathToSave, UINT32 InitialBramBufferSize)
 !hw_clk perform test
VOID CommandHwClk (vector< CommandToken > CommandTokens, string Command)
 !hw_clk command handler

Variables

HWDBG_INSTANCE_INFORMATION g_HwdbgInstanceInfo
 Instance information of the current hwdbg debuggee.

Detailed Description

!hw_clk command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.9
Date
2024-05-29

Function Documentation

◆ CommandHwClk()

VOID CommandHwClk ( vector< CommandToken > CommandTokens,
string Command )

!hw_clk command handler

Parameters
CommandTokens
Command
Returns
VOID
155{
156 if (CommandTokens.size() >= 2)
157 {
158 //
159 // Perform test with default file path and initial BRAM buffer size
160 //
161 CommandHwClkPerformTest(CommandTokens,
166 }
167 else
168 {
169 ShowMessages("incorrect use of the '%s'\n\n",
170 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
172 return;
173 }
174}
#define HWDBG_TEST_WRITE_SCRIPT_BUFFER_PATH
Path to write the sample of the script buffer.
Definition HardwareDebugger.h:48
#define HWDBG_TEST_READ_INSTANCE_INFO_PATH
Path to read the sample of the instance info.
Definition HardwareDebugger.h:42
#define HWDBG_TEST_WRITE_INSTANCE_INFO_PATH
Path to write the sample of the instance info requests.
Definition HardwareDebugger.h:54
#define DEFAULT_INITIAL_BRAM_BUFFER_SIZE
Initial default buffer size (BRAN Size).
Definition HardwareDebugger.h:36
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
VOID CommandHwClkHelp()
help of the !hw_clk command
Definition hw_clk.cpp:25
BOOLEAN CommandHwClkPerformTest(vector< CommandToken > CommandTokens, const TCHAR *InstanceFilePathToRead, const TCHAR *InstanceFilePathToSave, const TCHAR *HardwareScriptFilePathToSave, UINT32 InitialBramBufferSize)
!hw_clk perform test
Definition hw_clk.cpp:47

◆ CommandHwClkHelp()

VOID CommandHwClkHelp ( )

help of the !hw_clk command

Returns
VOID
26{
27 ShowMessages("!hw_clk : performs actions related to hwdbg hardware debugging events for each clock cycle.\n\n");
28
29 ShowMessages("syntax : \t!hw_clk [script { Script (string) }]\n");
30
31 ShowMessages("\n");
32 ShowMessages("\t\te.g : !hw_clk script { @hw_pin1 = 0; }\n");
33}

◆ CommandHwClkPerformTest()

BOOLEAN CommandHwClkPerformTest ( vector< CommandToken > CommandTokens,
const TCHAR * InstanceFilePathToRead,
const TCHAR * InstanceFilePathToSave,
const TCHAR * HardwareScriptFilePathToSave,
UINT32 InitialBramBufferSize )

!hw_clk perform test

Parameters
CommandTokens
InstanceFilePathToRead
InstanceFilePathToSave
HardwareScriptFilePathToSave
InitialBramBufferSize
Returns
BOOLEAN
52{
53 UINT32 EventLength;
54 DEBUGGER_EVENT_PARSING_ERROR_CAUSE EventParsingErrorCause;
56 PDEBUGGER_GENERAL_ACTION ActionBreakToDebugger = NULL;
57 PDEBUGGER_GENERAL_ACTION ActionCustomCode = NULL;
58 PDEBUGGER_GENERAL_ACTION ActionScript = NULL;
59 UINT32 ActionBreakToDebuggerLength = 0;
60 UINT32 ActionCustomCodeLength = 0;
61 UINT32 ActionScriptLength = 0;
62 CHAR * ScriptBuffer = NULL;
63 BOOLEAN Result = FALSE;
64
65 //
66 // Load the instance info
67 //
68 if (!HwdbgLoadInstanceInfo(InstanceFilePathToRead, InitialBramBufferSize))
69 {
70 //
71 // No need for freeing memory so return directly
72 //
73 return FALSE;
74 }
75
76 //
77 // Interpret and fill the general event and action fields for the target script
78 //
80 &CommandTokens,
81 (VMM_EVENT_TYPE_ENUM)NULL, // not an event
82 &Event,
83 &EventLength,
84 &ActionBreakToDebugger,
85 &ActionBreakToDebuggerLength,
86 &ActionCustomCode,
87 &ActionCustomCodeLength,
88 &ActionScript,
89 &ActionScriptLength,
90 &EventParsingErrorCause))
91 {
92 //
93 // No need for freeing memory so return directly
94 //
95 return FALSE;
96 }
97
98 //
99 // Print the actual script
100 //
101 ScriptBuffer = (CHAR *)((UINT64)ActionScript + sizeof(DEBUGGER_GENERAL_ACTION));
102 HwdbgScriptPrintScriptBuffer(ScriptBuffer, ActionScript->ScriptBufferSize);
103
104 //
105 // Create hwdbg script
106 //
107 if (!HwdbgScriptCreateHwdbgScript(ScriptBuffer,
108 ActionScript->ScriptBufferSize,
109 HardwareScriptFilePathToSave))
110 {
111 ShowMessages("err, unable to create hwdbg script\n");
112 Result = FALSE;
113 goto FreeAndReturnResult;
114 }
115
116 //
117 // Write an additional updated test instance info request into a file
118 //
120 InstanceFilePathToSave))
121 {
122 ShowMessages("err, unable to write instance info request\n");
123 Result = FALSE;
124 goto FreeAndReturnResult;
125 }
126
127 //
128 // The test is performed successfully
129 //
130 Result = TRUE;
131
132FreeAndReturnResult:
133
134 //
135 // Free the allocated memory
136 //
137 FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
138
139 //
140 // Return the result
141 //
142 return Result;
143}
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
char CHAR
Definition BasicTypes.h:33
struct _DEBUGGER_GENERAL_EVENT_DETAIL * PDEBUGGER_GENERAL_EVENT_DETAIL
enum _VMM_EVENT_TYPE_ENUM VMM_EVENT_TYPE_ENUM
enum to show type of all HyperDbg events
struct _DEBUGGER_GENERAL_ACTION DEBUGGER_GENERAL_ACTION
Each event can have multiple actions.
struct _DEBUGGER_GENERAL_ACTION * PDEBUGGER_GENERAL_ACTION
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:1688
BOOLEAN InterpretGeneralEventAndActionsFields(vector< CommandToken > *CommandTokens, 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:1736
HWDBG_INSTANCE_INFORMATION g_HwdbgInstanceInfo
Instance information of the current hwdbg debuggee.
Definition globals.h:691
BOOLEAN HwdbgWriteTestInstanceInfoRequestIntoFile(HWDBG_INSTANCE_INFORMATION *InstanceInfo, const CHAR *FileName)
Write test instance info request into a file.
Definition hwdbg-interpreter.cpp:612
BOOLEAN HwdbgLoadInstanceInfo(const TCHAR *InstanceFilePathToRead, UINT32 InitialBramBufferSize)
Load the instance info.
Definition hwdbg-interpreter.cpp:648
VOID HwdbgScriptPrintScriptBuffer(CHAR *ScriptBuffer, UINT32 ScriptBufferSize)
Print the actual script.
Definition hwdbg-scripts.cpp:29
BOOLEAN HwdbgScriptCreateHwdbgScript(CHAR *ScriptBuffer, UINT32 ScriptBufferSize, const TCHAR *HardwareScriptFilePathToSave)
Create hwdbg script.
Definition hwdbg-scripts.cpp:233
enum _DEBUGGER_EVENT_PARSING_ERROR_CAUSE DEBUGGER_EVENT_PARSING_ERROR_CAUSE
Reason for error in parsing commands.
NULL()
Definition test-case-generator.py:530
UINT32 ScriptBufferSize
Definition Events.h:420

Variable Documentation

◆ g_HwdbgInstanceInfo

HWDBG_INSTANCE_INFORMATION g_HwdbgInstanceInfo
extern

Instance information of the current hwdbg debuggee.