# notrequiem/antidbg architecture

> Architecture diagram of the GitHub repository notrequiem/antidbg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/notrequiem/antidbg
- Repository: https://github.com/notrequiem/antidbg

## Overview

AntiDBG is a Windows x64 user-mode anti-debugging library. A host process invokes its single public protection entry point; that entry point runs detection routines, which inspect process state, exceptions, memory, handles, timing, and debugger artifacts. On a detected violation, the documented response is to terminate the protected process. The README describes the broad checks and protections; the sampled source confirms selected implementations and the syscall interface, but most detection-to-check wiring is not visible in the excerpts, so those links rely on the README rather than inferred calls.

Main entry points: [`antidebug/adbg.c`](https://github.com/notrequiem/antidbg/blob/main/antidebug/adbg.c) (Protection entry), [`antidebug/core/syscall.h`](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/syscall.h) (Direct syscall interface), [`antidebug/object/dbgobj.c`](https://github.com/notrequiem/antidbg/blob/main/antidebug/object/dbgobj.c) (Debug objects), [`antidebug/memory`](https://github.com/notrequiem/antidbg/tree/main/antidebug/memory) (Memory probes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Protection entry"]
  node_entrypoint["Protection entry<br/>[adbg.c]"]
end

subgraph group_detection["Detection checks"]
  node_state_checks["Process state"]
  node_exception_checks["Exception probes"]
  node_kernel_checks["Kernel/debug queries"]
  node_object_checks["Debug objects<br/>[dbgobj.c]"]
  node_handle_checks["Handle and job checks"]
  node_memory_checks["Memory probes"]
  node_page_checks["Page exception checks<br/>[pgexcbp.c]"]
  node_timing_checks["Timing checks"]
  node_window_checks["Debugger UI checks"]
end

subgraph group_hardening["Runtime hardening"]
  node_code_integrity["Code integrity monitor<br/>[handler.c]"]
  node_protection_guard["Process protections<br/>[guard.c]"]
  node_thread_monitor["Thread monitoring<br/>[monitor.c]"]
  node_exception_handler["Global exception handler<br/>[handler.c]"]
end

subgraph group_internal["Internal primitives"]
  node_syscall_api["Direct syscall interface<br/>[syscall.h]"]
  node_syscall_impl["Syscall implementation<br/>[syscall.c]"]
  node_randomization["Check randomization<br/>[random.c]"]
end

subgraph group_response["Violation response"]
  node_terminate["Fail-fast termination<br/>[adbg.c]"]
end

node_host(("Protected host"))
node_protected_process(("Protected process"))
node_debugger(("Potential debugger"))

node_host -->|"invokes"| node_entrypoint
node_entrypoint -->|"runs checks"| node_state_checks
node_entrypoint -->|"runs checks"| node_exception_checks
node_entrypoint -->|"runs checks"| node_kernel_checks
node_entrypoint -->|"runs checks"| node_object_checks
node_entrypoint -->|"runs checks"| node_handle_checks
node_entrypoint -->|"runs checks"| node_memory_checks
node_entrypoint -->|"runs checks"| node_page_checks
node_entrypoint -->|"runs checks"| node_timing_checks
node_entrypoint -->|"runs checks"| node_window_checks
node_entrypoint -->|"starts protection"| node_code_integrity
node_entrypoint -->|"enforces policies"| node_protection_guard
node_entrypoint -->|"starts monitoring"| node_thread_monitor
node_entrypoint -->|"registers handler"| node_exception_handler
node_code_integrity -->|"compares code"| node_debugger
node_exception_handler -.->|"handles exceptions"| node_exception_checks
node_entrypoint -->|"randomizes checks"| node_randomization
node_memory_checks -->|"calls syscall interface"| node_syscall_api
node_page_checks -->|"queries memory"| node_syscall_api
node_object_checks -->|"queries objects"| node_syscall_api
node_syscall_api -.->|"dispatches syscalls"| node_syscall_impl
node_entrypoint -->|"fails on violation"| node_terminate
node_terminate -->|"terminates"| node_protected_process
node_debugger -->|"may intercept"| node_protected_process

click node_entrypoint "https://github.com/notrequiem/antidbg/blob/main/antidebug/adbg.c"
click node_state_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/api"
click node_exception_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/asm"
click node_kernel_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/api"
click node_object_checks "https://github.com/notrequiem/antidbg/blob/main/antidebug/object/dbgobj.c"
click node_handle_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/flags"
click node_memory_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/memory"
click node_page_checks "https://github.com/notrequiem/antidbg/blob/main/antidebug/exceptions/pgexcbp.c"
click node_timing_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/flags"
click node_window_checks "https://github.com/notrequiem/antidbg/tree/main/antidebug/flags"
click node_code_integrity "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/handler.c"
click node_protection_guard "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/guard.c"
click node_thread_monitor "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/monitor.c"
click node_exception_handler "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/handler.c"
click node_syscall_api "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/syscall.h"
click node_syscall_impl "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/syscall.c"
click node_randomization "https://github.com/notrequiem/antidbg/blob/main/antidebug/core/random.c"
click node_terminate "https://github.com/notrequiem/antidbg/blob/main/antidebug/adbg.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entrypoint toneBlue
class node_state_checks,node_exception_checks,node_kernel_checks,node_object_checks,node_handle_checks,node_memory_checks,node_page_checks,node_timing_checks,node_window_checks toneAmber
class node_code_integrity,node_protection_guard,node_thread_monitor,node_exception_handler toneMint
class node_syscall_api,node_syscall_impl,node_randomization toneRose
class node_terminate,node_host,node_protected_process,node_debugger toneIndigo
```

## Components

### Protection entry

- [Protection entry](https://github.com/notrequiem/antidbg/blob/main/antidebug/adbg.c): `antidebug/adbg.c`

### Detection checks

- [Process state](https://github.com/notrequiem/antidbg/tree/main/antidebug/api): `antidebug/api`
- [Exception probes](https://github.com/notrequiem/antidbg/tree/main/antidebug/asm): `antidebug/asm`
- [Kernel/debug queries](https://github.com/notrequiem/antidbg/tree/main/antidebug/api): `antidebug/api`
- [Debug objects](https://github.com/notrequiem/antidbg/blob/main/antidebug/object/dbgobj.c): `antidebug/object/dbgobj.c`
- [Handle and job checks](https://github.com/notrequiem/antidbg/tree/main/antidebug/flags): `antidebug/flags`
- [Memory probes](https://github.com/notrequiem/antidbg/tree/main/antidebug/memory): `antidebug/memory`
- [Page exception checks](https://github.com/notrequiem/antidbg/blob/main/antidebug/exceptions/pgexcbp.c): `antidebug/exceptions/pgexcbp.c`
- [Timing checks](https://github.com/notrequiem/antidbg/tree/main/antidebug/flags): `antidebug/flags`
- [Debugger UI checks](https://github.com/notrequiem/antidbg/tree/main/antidebug/flags): `antidebug/flags`

### Runtime hardening

- [Code integrity monitor](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/handler.c): `antidebug/core/handler.c`
- [Process protections](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/guard.c): `antidebug/core/guard.c`
- [Thread monitoring](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/monitor.c): `antidebug/core/monitor.c`
- [Global exception handler](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/handler.c): `antidebug/core/handler.c`

### Internal primitives

- [Direct syscall interface](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/syscall.h): `antidebug/core/syscall.h`
- [Syscall implementation](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/syscall.c): `antidebug/core/syscall.c`
- [Check randomization](https://github.com/notrequiem/antidbg/blob/main/antidebug/core/random.c): `antidebug/core/random.c`

### Violation response

- [Fail-fast termination](https://github.com/notrequiem/antidbg/blob/main/antidebug/adbg.c): `antidebug/adbg.c`

### Other components

- **Protected host**
- **Protected process**
- **Potential debugger**

## Connections

- Protected host → Protection entry: invokes (evidence: `README.md`)
- Protection entry → Process state: runs checks (evidence: `README.md`)
- Protection entry → Exception probes: runs checks (evidence: `README.md`)
- Protection entry → Kernel/debug queries: runs checks (evidence: `README.md`)
- Protection entry → Debug objects: runs checks (evidence: `README.md`)
- Protection entry → Handle and job checks: runs checks (evidence: `README.md`)
- Protection entry → Memory probes: runs checks (evidence: `README.md`)
- Protection entry → Page exception checks: runs checks (evidence: `README.md`)
- Protection entry → Timing checks: runs checks (evidence: `README.md`)
- Protection entry → Debugger UI checks: runs checks (evidence: `README.md`)
- Protection entry → Code integrity monitor: starts protection (evidence: `README.md`)
- Protection entry → Process protections: enforces policies (evidence: `README.md`)
- Protection entry → Thread monitoring: starts monitoring (evidence: `README.md`)
- Protection entry → Global exception handler: registers handler (evidence: `README.md`)
- Code integrity monitor → Potential debugger: compares code (evidence: `antidebug/core/handler.c`)
- Global exception handler → Exception probes: handles exceptions
- Protection entry → Check randomization: randomizes checks (evidence: `README.md`)
- Memory probes → Direct syscall interface: calls syscall interface (evidence: `antidebug/memory/vrtalloc.c`)
- Page exception checks → Direct syscall interface: queries memory (evidence: `antidebug/exceptions/pgexcbp.c`)
- Debug objects → Direct syscall interface: queries objects (evidence: `antidebug/object/dbgobj.c`)
- Direct syscall interface → Syscall implementation: dispatches syscalls
- Protection entry → Fail-fast termination: fails on violation (evidence: `README.md`)
- Fail-fast termination → Protected process: terminates (evidence: `README.md`)
- Potential debugger → Protected process: may intercept (evidence: `README.md`)
