HyperDbg Documentation
CommunityDownloadResearchTutorialhwdbg
  • HyperDbg
  • Getting Started
    • Quick Start
    • FAQ
    • Build & Install
    • Attach to HyperDbg
      • Attach to a remote machine
      • Attach to local machine
      • Start a new process
      • Attach to a running process
  • Using HyperDbg
    • Prerequisites
      • Operation Modes
      • How to create a condition?
      • How to create an action?
      • Signatures
    • User-mode Debugging
      • Principles
      • Examples
        • basics
        • events
          • Getting Results of a System-call
    • Kernel-mode Debugging
      • Principles
      • Examples
        • beginning
          • Connecting To HyperDbg
          • Configuring Symbol Server/Path
        • basics
          • Setting Breakpoints & Stepping Instructions
          • Displaying & Editing & Searching Memory
          • Showing & Modifying Registers and Flags
          • Switching to a Specific Process or Thread
          • Mapping Data & Create Structures, and Enums From Symbols
        • events
          • Managing Events
          • Hooking Any Function
          • Intercepting All SYSCALLs
          • Monitoring Accesses To Structures
          • Triggering Special Instructions
          • Identifying System Behavior
        • Scripting Language Examples
    • Software Development Kit (SDK)
      • Events
        • Conditions
        • Actions
      • IOCTL
        • Event Registration
  • Commands
    • Debugging Commands
      • ? (evaluate and execute expressions and scripts in debuggee)
      • ~ (display and change the current operating core)
      • a (assemble virtual address)
      • load (load the kernel modules)
      • unload (unload the kernel modules)
      • status (show the debuggee status)
      • events (show and modify active/disabled events)
      • p (step-over)
      • t (step-in)
      • i (instrumentation step-in)
      • gu (step-out or go up)
      • r (read or modify registers)
      • bp (set breakpoint)
      • bl (list breakpoints)
      • be (enable breakpoints)
      • bd (disable breakpoints)
      • bc (clear and remove breakpoints)
      • g (continue debuggee or processing kernel packets)
      • x (examine symbols and find functions and variables address)
      • db, dc, dd, dq (read virtual memory)
      • eb, ed, eq (edit virtual memory)
      • sb, sd, sq (search virtual memory)
      • u, u64, u2, u32 (disassemble virtual address)
      • k, kd, kq (display stack backtrace)
      • dt (display and map virtual memory to structures)
      • struct (make structures, enums, data types from symbols)
      • sleep (wait for specific time in the .script command)
      • pause (break to the debugger and pause processing kernel packets)
      • print (evaluate and print expression in debuggee)
      • lm (view loaded modules)
      • cpu (check cpu supported technologies)
      • rdmsr (read model-specific register)
      • wrmsr (write model-specific register)
      • flush (remove pending kernel buffers and messages)
      • prealloc (reserve pre-allocated pools)
      • preactivate (pre-activate special functionalities)
      • output (create output source for event forwarding)
      • test (test functionalities)
      • settings (configures different options and preferences)
      • exit (exit from the debugger)
    • Meta Commands
      • .help (show the help of commands)
      • .debug (prepare and connect to debugger)
      • .connect (connect to a session)
      • .disconnect (disconnect from a session)
      • .listen (listen on a port and wait for the debugger to connect)
      • .status (show the debugger status)
      • .start (start a new process)
      • .restart (restart the process)
      • .attach (attach to a process)
      • .detach (detach from the process)
      • .switch (show the list and switch between active debugging processes)
      • .kill (terminate the process)
      • .process, .process2 (show the current process and switch to another process)
      • .thread, .thread2 (show the current thread and switch to another thread)
      • .pagein (bring the page into the RAM)
      • .dump (save the virtual memory into a file)
      • .formats (show number formats)
      • .script (run batch script commands)
      • .sympath (set the symbol server)
      • .sym (load pdb symbols)
      • .pe (parse PE file)
      • .logopen (open log file)
      • .logclose (close log file)
      • .cls (clear the screen)
    • Extension Commands
      • !a (assemble physical address)
      • !pte (display page-level address and entries)
      • !db, !dc, !dd, !dq (read physical memory)
      • !eb, !ed, !eq (edit physical memory)
      • !sb, !sd, !sq (search physical memory)
      • !u, !u64, !u2, !u32 (disassemble physical address)
      • !dt (display and map physical memory to structures)
      • !track (track and map function calls and returns to the symbols)
      • !epthook (hidden hook with EPT - stealth breakpoints)
      • !epthook2 (hidden hook with EPT - detours)
      • !monitor (monitor read/write/execute to a range of memory)
      • !syscall, !syscall2 (hook system-calls)
      • !sysret, !sysret2 (hook SYSRET instruction execution)
      • !mode (detect kernel-to-user and user-to-kernel transitions)
      • !cpuid (hook CPUID instruction execution)
      • !msrread (hook RDMSR instruction execution)
      • !msrwrite (hook WRMSR instruction execution)
      • !tsc (hook RDTSC/RDTSCP instruction execution)
      • !pmc (hook RDPMC instruction execution)
      • !vmcall (hook hypercalls)
      • !exception (hook first 32 entries of IDT)
      • !interrupt (hook external device interrupts)
      • !dr (hook access to debug registers)
      • !ioin (hook IN instruction execution)
      • !ioout (hook OUT instruction execution)
      • !hide (enable transparent-mode)
      • !unhide (disable transparent-mode)
      • !measure (measuring and providing details for transparent-mode)
      • !va2pa (convert a virtual address to physical address)
      • !pa2va (convert physical address to virtual address)
      • !dump (save the physical memory into a file)
      • !pcitree (show PCI/PCIe device tree)
      • !pcicam (dump the PCI/PCIe configuration space)
      • !idt (show Interrupt Descriptor Table entries)
      • !apic (dump local APIC entries in XAPIC and X2APIC modes)
      • !ioapic (dump I/O APIC)
    • Scripting Language
      • Assumptions & Evaluations
      • Variables & Assignments
      • Casting & Type-awareness
      • Conditionals & Loops
      • Constants & Functions
      • Debugger Script (DS)
      • Examples
        • view system state (registers, memory, variables)
        • change system state (registers, memory, variables)
        • trace function calls
        • pause the debugger conditionally
        • conditional breakpoints and events
        • patch the normal sequence of execution
        • access to a shared variable from different cores
        • count occurrences of events
      • Functions
        • debugger
          • pause
        • events
          • event_enable
          • event_disable
          • event_clear
          • event_sc
          • event_inject
          • event_inject_error_code
          • flush
        • exports
          • print
          • printf
        • interlocked
          • interlocked_compare_exchange
          • interlocked_decrement
          • interlocked_exchange
          • interlocked_exchange_add
          • interlocked_increment
        • memory
          • check_address
          • eb, ed, eq
          • eb_pa, ed_pa, eq_pa
          • memcpy
          • memcpy_pa
          • memcmp
          • virtual_to_physical
          • physical_to_virtual
        • diassembler
          • disassemble_len
          • disassemble_len32
        • spinlocks
          • spinlock_lock
          • spinlock_lock_custom_wait
          • spinlock_unlock
        • strings
          • strlen
          • wcslen
          • strcmp
          • strncmp
          • wcscmp
          • wcsncmp
    • Commands Map
  • Tips & Tricks
    • Considerations
      • Basic concepts in Intel VT-x
      • VMX root-mode vs VMX non-root mode
      • The "unsafe" behavior
      • Script engine in VMX non-root mode
      • Difference between process and thread switching commands
      • Accessing Invalid Address
      • Transparent Mode
    • Nested-Virtualization Environments
      • Supported Virtual Machines
      • Run HyperDbg on VMware
      • Run HyperDbg on Hyper-V
      • Supporting VMware/Hyper-V
      • VMware backdoor I/O ports
    • Misc
      • Event forwarding
      • Event short-circuiting
      • Event calling stage
      • Instant events
      • Message overflow
      • Customize build
        • Increase Communication Buffer Size
        • Number of EPT Hooks in One Page
        • Change Script Engine Limitations
      • Enable and disable events in Debugger Mode
      • Switch to New Process Layout
  • Contribution
    • Style Guide
      • Coding style
      • Command style
      • Doxygen style
    • Logo & Artworks
  • Design
    • Features
      • VMM (Module)
        • Control over NMIs
        • VMX root-mode compatible message tracing
        • Design of !epthook
        • Design of !epthook2
        • Design of !monitor
        • Design of !syscall & !sysret
        • Design of !exception & !interrupt
    • Debugger Internals
      • Events
      • Conditions
      • Actions
      • Kernel Debugger
        • Design Perspective
        • Connection
  • Links
    • Twitter
    • Telegram
    • Discord
    • Matrix
    • Mastodon
    • YouTube
    • hwdbg (Chip Debugger)
    • Doxygen
    • Contribution
Powered by GitBook
On this page
  • Description
  • Keywords
  • Operators
  • Operators Precedence/Priority (Expressions)
  • Operator Precedence/Priority (Boolean Expressions)
  • Registers
  • Pseudo-registers
  • Number Prefixes
  • Comments
  • Strings
  • Escape Characters
  • Functions
Edit on GitHub
  1. Commands
  2. Scripting Language

Assumptions & Evaluations

Description of keywords, operators, pseudo-registers, number prefixes, and pre-defined functions

Description

HyperDbg uses a MASM-like (Windbg) syntax to evaluate script expressions.

HyperDbg script engine is case-sensitive.

Keywords

The following keywords are valid in Script Engine.

Keyword
Description

poi

Pointer-sized data from the specified address (dereference)

poi_pa

Pointer-sized data from the specified address (dereference) from the physical address (added starting from v0.13)

ref

Reference address of the specified variable

db

Low 8 bits (dereference)

db_pa

Low 8 bits (dereference) from the physical address (added starting from v0.13)

hi

High 16 bits (dereference)

hi_pa

High 16 bits (dereference) from the physical address (added starting from v0.13)

low

Low 16 bits (dereference)

low_pa

Low 16 bits (dereference) from the physical address (added starting from v0.13)

dw

Low 16 bits (dereference)

dw_pa

Low 16 bits (dereference) from the physical address (added starting from v0.13)

dd

Low 32 bits (dereference)

dd_pa

Low 32 bits (dereference) from the physical address (added starting from v0.13)

dq

64 bits (dereference)

dq_pa

64 bits (dereference) from the physical address (added starting from v0.13)

not

Flip each and every bit

neg

True/False logic flipping

Operators

The following operators are supported on the script engine.

Operators Precedence/Priority (Expressions)

Operator
Description

( )

Parentheses

- + ~ * &

Unary Operators (Unary negative, Unary positive, Bitwise not, Reference, Address of)

/ % *

Arithmetic Operators (Division, Modulo, Multiplication)

+ -

Arithmetic Operators (Addition, Subtration)

<< >>

Shift Operators (Right shift, Left shift)

&

Bitwise AND Operator

^

Bitwise XOR Operator (exclusive OR)

|

Bitwise OR Operator

Operator Precedence/Priority (Boolean Expressions)

Operator
Description

( )

Parentheses

- + ~ * &

Unary Operators (Unary negative, Unary positive, Bitwise not, Reference, Address of)

/ % *

Arithmetic Operators (Division, Modulo, Multiplication)

+ -

Arithmetic Operators (Addition, Subtration)

<< >>

Shift Operators (Right shift, Left shift)

>= < > <= == !=

Comparison operators

&

Bitwise AND Operator

^

Bitwise XOR Operator (exclusive OR)

|

Bitwise OR Operator

&&

Logical AND

||

Logical OR

Registers

The following registers are supported by HyperDbg.

Registers
Description

@rax @eax @ax @ah @al @rcx @ecx @cx @ch @cl @rdx @edx @dx @dh @dl @rbx @ebx @bx @bh @bl @rsi @esi @si @sil @rdi @edi @di @dil

General-purpose registers

@r8 @r8d @r8w @r8h @r8l @r9 @r9d @r9w @r9h @r9l @r10 @r10d @r10w @r10h @r10l @r11 @r11d @r11w @r11h @r11l @r12 @r12d @r12w @r12h @r12l @r13 @r13d @r13w @r13h @r13l @r14 @r14d @r14w @r14h @r14l @r15 @r15d @r15w @r15h @r15l

64-bit mode registers

@rsp @esp @sp @spl @rbp @ebp @bp @bpl

Stack management registers

@rip @eip @ip

Program counter (Instruction pointer)

@rflags @eflags @flags

Flags register

@ds @es @cs @ss

Segment registers

@fs @gs

Segment registers (80386)

@cr0 @cr2 @cr3 @cr4 @cr8

Control registers

@gdtr @ldtr @tr

Memory management registers

@idtr

Interrupt descriptor register

@dr0 @dr1 @dr2 @dr3 @dr6 @dr7

Debug registers

Model-/machine-specific registers (MSRs)

Each flag of RFLAGS is also supported in HyperDbg.

Bit #

Mask

Register Abbreviation

Description

Category

FLAGS

0

0x0001

@cf

Carry flag

Status

1

0x0002

_

Reserved, always 1 in EFLAGS

_

2

0x0004

@pf

Parity flag

Status

3

0x0008

_

Reserved

_

4

0x0010

@af

Adjust flag

Status

5

0x0020

_

Reserved

_

6

0x0040

@zf

Zero flag

Status

7

0x0080

@sf

Sign flag

Status

8

0x0100

@tf

Trap flag (single step)

Control

9

0x0200

@if

Interrupt enable flag

Control

10

0x0400

@df

Direction flag

Control

11

0x0800

@of

Overflow flag

Status

12-13

0x3000

@iopl

I/O privilege level (286+ only), always 1 on 8086 and 186

System

14

0x4000

@nt

Nested task flag (286+ only), always 1 on 8086 and 186

System

15

0x8000

_

Reserved, always 1 on 8086 and 186, always 0 on later models

_

EFLAGS

16

0x0001 0000

@rf

Resume flag (386+ only)

System

17

0x0002 0000

@vm

Virtual 8086 mode flag (386+ only)

System

18

0x0004 0000

@ac

Alignment check (486SX+ only)

System

19

0x0008 0000

@vif

Virtual interrupt flag (Pentium+)

System

20

0x0010 0000

@vip

Virtual interrupt pending (Pentium+)

System

21

0x0020 0000

@id

Able to use CPUID instruction (Pentium+)

System

22‑31

0xFFC0 0000

_

Reserved

System

RFLAGS

32‑63

0xFFFF FFFF… 0000 0000

Reserved

_

_

Pseudo-registers

Here are the currently supported pseudo-registers supported by the script engine.

Pseudo-register
Description

$pid

The process ID (PID) of the current process.

$proc

The address of the current process (that is, the address of the nt!_EPROCESS block).

$pname

A pointer to the character array of the process name. (It is a 16-byte long array in kernel-mode).

$tid

The thread ID for the current thread.

$core

The core ID for the current core.

$thread

The address of the current thread. In kernel-mode debugging, this address is the address of the nt!_ETHREAD block.

$peb

The address of the process environment block (PEB) of the current process.

$teb

The address of the thread environment block (TEB) of the current thread.

$ip

The instruction pointer register (rip).

$buffer

The pre-allocated buffer if the user requests a safe buffer.

$context

The context of the triggered event (It has a different meaning in each event).

$event_id

The event ID of the triggered event (Only in the case of events). [Added from v0.3]

$event_tag

The event tag of the triggered event (Only in the case of events). [Added from v0.3]

$event_stage

The calling stage of the triggered event (Only in the case of events). [Added from v0.5]

$date

A pointer to a buffer that holds the current date (to be used with printf with %s format string identifier). [Added from v0.9.1]

$time

A pointer to a buffer that holds the current time (to be used with printf with %s format string identifier). [Added from v0.9.1]

Some of the above pseudo-registers are not supported either in kernel-mode or user-mode. If you use these registers, then it returns NULL.

Number Prefixes

By default, HyperDbg interprets the numbers as hex (base 16). If you want to specify other forms of a number, you should use MASM prefixes. In all MASM expressions, numeric values are interpreted as numbers in the current radix (16, 10, or 8). You can override the default radix by specifying the 0x prefix (hexadecimal), the 0n prefix (decimal), the 0t prefix (octal), or the 0y prefix (binary).

Comments

HyperDbg's comments are like C comments.

A comment starts with a slash asterisk /* and ends with an asterisk slash */ and can be anywhere in your program. Comments can span several lines within your C program.

/* comment goes here */

OR

/*
 * comment goes here
 */

You can create a comment on a single line.

// comment goes here

Strings

Escape Characters

Special characters such as \n and \t, are used to represent special characters like newline and tab within strings. Additionally, hexadecimal representations between strings, like "\x41\x42\x43", enable the inclusion of specific byte values in a character sequence.

Functions

PreviousScripting LanguageNextVariables & Assignments

Last updated 2 months ago

If you want to read strings or Unicode strings, you can use the function.

See the '' and '' commands for more information.

There are C-like for performing string and wide-character string comparisons. Regular strings are enclosed in double quotations (e.g., "This is a string"), while wide-character strings begin with an 'L' followed by double quotations (e.g., L"This is a wide-character string").

HyperDbg supports multiple pre-defined .

printf
functions
functions
rdmsr
wrmsr