# es3n1n/defendnot architecture

> Architecture diagram of the GitHub repository es3n1n/defendnot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/es3n1n/defendnot
- Repository: https://github.com/es3n1n/defendnot

## Overview

##### Project type and purpose
- defendnot is a low-level Windows system utility / CLI tool whose goal is to disable Windows Defender by directly interacting with the undocumented WSC (Windows Security Center) API.
- It’s not a web app or full-stack service, but a command-line launcher plus a DLL payload that hooks into Windows internals.

##### File structure
Top-level modules:
- cxx-shared/…
– A Git submodule containing headers (ctx.hpp, defer.hpp, ipc.hpp, names.hpp, util.hpp) used by multiple components for shared utilities (context handling, IPC abstractions, common names, defer macros, etc.).
- defendnot-loader/…
– A console app (“defendnot-loader”) whose main responsibility is:
- parsing CLI args
- optionally registering itself in autorun on Windows (to persist after reboot)
- injecting or invoking the defendnot DLL to talk to WSC
- defendnot/…
– The actual DLL payload (dllmain.cpp) plus “bootstrap” and “core” code:
- bootstrap/bootstrap.cpp/.hpp: entry point that sets up the payload environment
- core/com.hpp: wrappers for interacting with undocumented COM interfaces of WSC
- core/log.hpp: logging support
- wsc-binary-check/…
– A small CLI tool to verify whether a binary is correctly registered in WSC.

Supporting files:
- .gitmodules, cxx-shared.vcxitems → manage the shared submodule
- Multiple Visual Studio project files (.vcxproj, .sln) → build, link, and dependency graph

##### README for additional insights
- Confirmed the high-level workflow: loader registers in WSC via direct API calls, persists via autorun, and can disable itself.
- No network or DB; pure Windows API interactions.

##### Final advice
- Be exhaustive: break the payload into “bootstrap” vs. “core/com” blocks.
- Sequential data flow for the disable operation.
- Build artifacts (VS projects) only if the engineer needs to understand build dependencies—otherwise focus on runtime components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Project Binaries
    subgraph "Project Binaries" 
        direction TB
        subgraph "defendnot-loader CLI" 
            direction TB
            Loader_Main["main.cpp"]:::binaries
            Loader_Autorun["autorun.cpp"]:::binaries
            Loader_CoreH["core.hpp"]:::binaries
            Loader_Inject["inject.cpp"]:::binaries
            Loader_VC["defendnot-loader.vcxproj"]:::binaries
        end
        subgraph "defendnot DLL Payload" 
            direction TB
            subgraph "Bootstrap"
                direction TB
                Bootstrap_CPP["bootstrap.cpp"]:::binaries
                Bootstrap_H["bootstrap.hpp"]:::binaries
            end
            subgraph "Core"
                direction TB
                Core_COM["com.hpp"]:::binaries
                Core_LOG["log.hpp"]:::binaries
            end
            DllMain["dllmain.cpp"]:::binaries
            Dll_VC["defendnot.vcxproj"]:::binaries
        end
        subgraph "wsc-binary-check CLI"
            direction TB
            Validator_Main["main.cpp"]:::binaries
            Validator_VC["wsc-binary-check.vcxproj"]:::binaries
        end
    end

    %% Shared Library
    subgraph "Shared Library" 
        direction TB
        Ctx["ctx.hpp"]:::shared
        Defer["defer.hpp"]:::shared
        IPC["ipc.hpp"]:::shared
        Names["names.hpp"]:::shared
        Util["util.hpp"]:::shared
        Shared_VC["cxx-shared.vcxitems"]:::shared
    end

    %% OS Subsystems
    subgraph "Windows OS Subsystems" 
        direction TB
        Registry["Windows Registry"]:::os
        WSC["WSC COM Service"]:::os
    end

    %% Relationships
    Ctx -->|used by| Loader_Main
    Defer -->|used by| Loader_Main
    IPC -->|used by| Loader_Main
    Names -->|used by| Loader_Main
    Util -->|used by| Loader_Main
    Loader_Main -->|"writes autorun key"| Registry
    Loader_Autorun -->|uses| Registry
    Loader_Inject -->|injects DLL| DllMain
    Loader_Inject -->|or CoCreateInstance| WSC
    Bootstrap_CPP -->|initializes payload| Core_COM
    Core_COM -->|calls COM APIs| WSC
    Core_LOG -->|logs events| Core_COM
    DllMain -->|entry point| Bootstrap_CPP
    Validator_Main -->|queries| WSC

    %% Click Events
    click Ctx "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/shared/ctx.hpp"
    click Defer "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/shared/defer.hpp"
    click IPC "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/shared/ipc.hpp"
    click Names "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/shared/names.hpp"
    click Util "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/shared/util.hpp"
    click Shared_VC "https://github.com/es3n1n/defendnot/blob/master/cxx-shared/cxx-shared.vcxitems"
    click Loader_Main "https://github.com/es3n1n/defendnot/blob/master/defendnot-loader/main.cpp"
    click Loader_Autorun "https://github.com/es3n1n/defendnot/blob/master/defendnot-loader/core/autorun.cpp"
    click Loader_CoreH "https://github.com/es3n1n/defendnot/blob/master/defendnot-loader/core/core.hpp"
    click Loader_Inject "https://github.com/es3n1n/defendnot/blob/master/defendnot-loader/core/inject.cpp"
    click Loader_VC "https://github.com/es3n1n/defendnot/blob/master/defendnot-loader/defendnot-loader.vcxproj"
    click Bootstrap_CPP "https://github.com/es3n1n/defendnot/blob/master/defendnot/bootstrap/bootstrap.cpp"
    click Bootstrap_H "https://github.com/es3n1n/defendnot/blob/master/defendnot/bootstrap/bootstrap.hpp"
    click Core_COM "https://github.com/es3n1n/defendnot/blob/master/defendnot/core/com.hpp"
    click Core_LOG "https://github.com/es3n1n/defendnot/blob/master/defendnot/core/log.hpp"
    click DllMain "https://github.com/es3n1n/defendnot/blob/master/defendnot/dllmain.cpp"
    click Dll_VC "https://github.com/es3n1n/defendnot/blob/master/defendnot/defendnot.vcxproj"
    click Validator_Main "https://github.com/es3n1n/defendnot/blob/master/wsc-binary-check/main.cpp"
    click Validator_VC "https://github.com/es3n1n/defendnot/blob/master/wsc-binary-check/wsc-binary-check.vcxproj"

    %% Styles
    classDef binaries fill:#f9f,stroke:#333,stroke-width:1px
    classDef shared fill:#9ff,stroke:#333,stroke-width:1px
    classDef os fill:#ff9,stroke:#333,stroke-width:1px
```
