Repository navigation
[Memhack] Debug Module
DasKeifer edited this page Feb 26, 2026
·
2 revisions
memhack provides debugging utilities for memory inspection and hex conversion. These functions are useful for reverse engineering, verifying struct layouts, and troubleshooting memory related issues.
- Hex Conversion
- Memory Inspection
- Memory Analyzer (separate page)
-
intmemhack.debug.hexToInt(hexstr)
| Argument name | Type | Description |
|---|---|---|
hexstr |
string | Hex string to convert (supports "0x1A" or "1A" format) |
Converts a hex string to an integer. Supports both "0x" prefixed and plain hex strings.
Example:
local value = memhack.debug.hexToInt("0x1A") -- Returns 26
local value2 = memhack.debug.hexToInt("1A") -- Also returns 26-
stringmemhack.debug.intToHex(num)
| Argument name | Type | Description |
|---|---|---|
num |
int | Integer to convert to hex string |
Converts an integer to a hex string with "0x" prefix.
Example:
local hexStr = memhack.debug.intToHex(26) -- Returns "0x1A"
LOG("Address: " .. memhack.debug.intToHex(pilot:getAddress()))-
stringmemhack.debug.bytesToHex(bytes, bytesPerGroup)
| Argument name | Type | Description |
|---|---|---|
bytes |
string | Binary data string |
bytesPerGroup |
int | Optional. Number of bytes before space separator (default: 0, space between each byte) |
Converts a byte array (binary string) to a hex string representation with optional grouping.
Example:
local bytes = "\x01\x02\x03\x04"
local hex = memhack.debug.bytesToHex(bytes) -- "01 02 03 04"
local hex2 = memhack.debug.bytesToHex(bytes, 2) -- "0102 0304"
local hex3 = memhack.debug.bytesToHex(bytes, 4) -- "01020304"-
stringmemhack.debug.hexToBytes(hexStr)
| Argument name | Type | Description |
|---|---|---|
hexStr |
string | Hex string (spaces and "0x" prefix are automatically stripped) |
Converts a hex string to binary data. Handles spaces and "0x" prefix automatically.
Example:
local bytes = memhack.debug.hexToBytes("01020304") -- 4 bytes
local bytes2 = memhack.debug.hexToBytes("01 02 03 04") -- Also 4 bytes (spaces ignored)
local bytes3 = memhack.debug.hexToBytes("0x01020304") -- Also 4 bytes (0x ignored)-
voidmemhack.debug.logFromMemory(address, numBytes, bytesPerLine, bytesPerGroup)
| Argument name | Type | Description |
|---|---|---|
address |
int | Memory address to start reading from |
numBytes |
int | Number of bytes to read |
bytesPerLine |
int | Optional. Bytes per line (default: 64) |
bytesPerGroup |
int | Optional. Bytes per group with space separator (default: 4) |
Logs a formatted hex dump of memory contents starting at the specified address. This is useful for inspecting raw memory structures and verifying struct layouts.
Example:
local pilot = pawn:GetPilot()
local address = pilot:getAddress()
-- Dump 256 bytes starting at pilot address
memhack.debug.logFromMemory(address, 256)
-- Custom formatting: 32 bytes per line, grouped by 8
memhack.debug.logFromMemory(address, 128, 32, 8)Output format:
Memory dump from 0x12345678 (256 bytes)
0x12345678: 01020304 05060708 090A0B0C 0D0E0F10 ...
0x12345688: 11121314 15161718 191A1B1C 1D1E1F20 ...
...