# jmclaren7/ntpwedit architecture

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

- Interactive diagram: https://gitdiagram.com/jmclaren7/ntpwedit
- Repository: https://github.com/jmclaren7/ntpwedit

## Overview

NTPWEdit is a Windows utility for editing account passwords and unlock state directly in an offline Windows SAM file. The principal workflow is to select and open a SAM file, enumerate its users, apply an unlock or password change, and save the modified hive. The graph also includes the registry-hive and cryptographic layers, plus the documented password-dialog, hibernation, and informational UI branches. Source excerpts are partial, so some internal calls and optional behavior are not shown.

Main entry points: [`main.c`](https://github.com/jmclaren7/ntpwedit/blob/main/main.c) (Main window workflow), [`libntpw/ntpw.c`](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/ntpw.c) (Account operations), [`libdlg/dialogs.c`](https://github.com/jmclaren7/ntpwedit/blob/main/libdlg/dialogs.c) (Dialog framework), [`libntpw/libsam.c`](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/libsam.c) (SAM account parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application workflow"]
  node_main["Main window workflow<br/>[main.c]"]
  node_logging["Logging<br/>[log.c]"]
end

subgraph group_ui["Windows interface"]
  node_dialogs["Dialog framework<br/>[dialogs.c]"]
  node_controls["Dialog controls"]
  node_password_dialog["Password prompt<br/>[dlgpass.c]"]
  node_hibernation_dialog["Hibernation prompt<br/>[dlghiber.c]"]
  node_about_dialog["About window<br/>[dlgabout.c]"]
  node_messages["Message dialogs<br/>[message.c]"]
  node_unicode["Unicode helpers<br/>[unicode.c]"]
end

subgraph group_sam["SAM and registry"]
  node_samfile[("SAM hive file")]
  node_account_ops["Account operations<br/>[ntpw.c]"]
  node_sam_parser["SAM account parser<br/>[libsam.c]"]
  node_hive["Registry hive access<br/>[ntreg.c]"]
end

subgraph group_crypto["Cryptography"]
  node_crypto_impl["DES and MD4"]
end

node_operator(("Offline operator"))

node_operator -->|"uses"| node_main
node_main -->|"selects path"| node_samfile
node_main -->|"opens and edits"| node_account_ops
node_main -->|"requests password"| node_password_dialog
node_main -.->|"checks hibernation"| node_hibernation_dialog
node_main -->|"opens about"| node_about_dialog
node_main -->|"shows messages"| node_messages
node_main -->|"builds dialogs"| node_dialogs
node_dialogs -->|"creates controls"| node_controls
node_dialogs -->|"uses helpers"| node_unicode
node_account_ops -->|"reads account data"| node_sam_parser
node_account_ops -->|"edits hive"| node_hive
node_sam_parser -->|"reads hive"| node_hive
node_account_ops -->|"uses crypto"| node_crypto_impl
node_account_ops -.->|"logs operations"| node_logging
node_main -->|"saves changes"| node_samfile

click node_main "https://github.com/jmclaren7/ntpwedit/blob/main/main.c"
click node_account_ops "https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/ntpw.c"
click node_sam_parser "https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/libsam.c"
click node_hive "https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/ntreg.c"
click node_crypto_impl "https://github.com/jmclaren7/ntpwedit/tree/main/libntpw/libtomcrypt/src"
click node_dialogs "https://github.com/jmclaren7/ntpwedit/blob/main/libdlg/dialogs.c"
click node_controls "https://github.com/jmclaren7/ntpwedit/tree/main/libdlg"
click node_password_dialog "https://github.com/jmclaren7/ntpwedit/blob/main/dlgpass.c"
click node_hibernation_dialog "https://github.com/jmclaren7/ntpwedit/blob/main/dlghiber.c"
click node_about_dialog "https://github.com/jmclaren7/ntpwedit/blob/main/dlgabout.c"
click node_messages "https://github.com/jmclaren7/ntpwedit/blob/main/message.c"
click node_unicode "https://github.com/jmclaren7/ntpwedit/blob/main/libdlg/unicode.c"
click node_logging "https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/log.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_main,node_logging toneBlue
class node_dialogs,node_controls,node_password_dialog,node_hibernation_dialog,node_about_dialog,node_messages,node_unicode toneAmber
class node_samfile,node_account_ops,node_sam_parser,node_hive toneMint
class node_crypto_impl toneRose
class node_operator toneIndigo
```

## Components

### Application workflow

- [Main window workflow](https://github.com/jmclaren7/ntpwedit/blob/main/main.c): `main.c`
- [Logging](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/log.c): `libntpw/log.c`

### Windows interface

- [Dialog framework](https://github.com/jmclaren7/ntpwedit/blob/main/libdlg/dialogs.c): `libdlg/dialogs.c`
- [Dialog controls](https://github.com/jmclaren7/ntpwedit/tree/main/libdlg): `libdlg`
- [Password prompt](https://github.com/jmclaren7/ntpwedit/blob/main/dlgpass.c): `dlgpass.c`
- [Hibernation prompt](https://github.com/jmclaren7/ntpwedit/blob/main/dlghiber.c): `dlghiber.c`
- [About window](https://github.com/jmclaren7/ntpwedit/blob/main/dlgabout.c): `dlgabout.c`
- [Message dialogs](https://github.com/jmclaren7/ntpwedit/blob/main/message.c): `message.c`
- [Unicode helpers](https://github.com/jmclaren7/ntpwedit/blob/main/libdlg/unicode.c): `libdlg/unicode.c`

### SAM and registry

- **SAM hive file**
- [Account operations](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/ntpw.c): `libntpw/ntpw.c`
- [SAM account parser](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/libsam.c): `libntpw/libsam.c`
- [Registry hive access](https://github.com/jmclaren7/ntpwedit/blob/main/libntpw/ntreg.c): `libntpw/ntreg.c`

### Cryptography

- [DES and MD4](https://github.com/jmclaren7/ntpwedit/tree/main/libntpw/libtomcrypt/src): `libntpw/libtomcrypt/src`

### Other components

- **Offline operator**

## Connections

- Offline operator → Main window workflow: uses
- Main window workflow → SAM hive file: selects path (evidence: `main.c`)
- Main window workflow → Account operations: opens and edits (evidence: `main.c`)
- Main window workflow → Password prompt: requests password (evidence: `main.c`)
- Main window workflow → Hibernation prompt: checks hibernation
- Main window workflow → About window: opens about (evidence: `main.c`)
- Main window workflow → Message dialogs: shows messages (evidence: `main.c`)
- Main window workflow → Dialog framework: builds dialogs (evidence: `main.c`)
- Dialog framework → Dialog controls: creates controls (evidence: `libdlg/dialogs.c`)
- Dialog framework → Unicode helpers: uses helpers (evidence: `libdlg/dialogs.c`)
- Account operations → SAM account parser: reads account data (evidence: `libntpw/ntpw.c`)
- Account operations → Registry hive access: edits hive (evidence: `libntpw/ntpw.c`)
- SAM account parser → Registry hive access: reads hive (evidence: `libntpw/libsam.c`)
- Account operations → DES and MD4: uses crypto (evidence: `libntpw/ntpw.c`)
- Account operations → Logging: logs operations
- Main window workflow → SAM hive file: saves changes
