Important
AI-assisted development disclosure
AI assistance was used during the development of Daydream. ChatGPT Sol was the primary model and main development module used for the project. Claude Opus 4.8 and Fable were also tried, but failed to perform adequately for the project's development needs. Grok was used purely for research and prototyping.
Windows x64 PE and process-memory triage for defensive reverse engineering.
Warning
Daydream is still under active development. Interfaces, collectors, output schemas, and behavior may change without backward-compatibility guarantees.
This project is intended only for defensive security, malware analysis, education, research, and inspection of software or systems you own or are explicitly authorized to analyze.
- Overview
- How Daydream works
- Project status
- Intended usage
- Current capabilities
- Requirements
- Dependency roles
- Build and test
- Usage
- Output structure
- Extending and integrating
- Project layout
- Accuracy and limitations
- Development principles
- Contributing
Daydream is a Windows-only, x86-64 Rust application for collecting structured triage data from a running process and its mapped main image.
The project is designed to give malware analysts, reverse engineers, security researchers, students, and defenders a useful first-pass view before deeper analysis in a debugger or disassembler. It collects PE structure, imports, debug metadata, process structures, and exact location metadata.
Daydream is a triage tool. It is not intended to automatically declare that a file or process is malicious. Collected values should be treated as analyst evidence and correlated with surrounding code, provenance, behavior, and other tooling.
Daydream currently has no dynamically loaded plug-in system. In this document, a component "plugs in" by being declared in the binary's module tree, called by the appropriate orchestration layer, represented in its collection type, and serialized by the matching output layer. The exact extension points are documented below.
The process pipeline validates the target's identity and collects one snapshot of its mapped main image. It validates the on-disk executable separately for the report hash.
src/main.rs
|
-p <pid> / no arguments
|
process_target(...)
|
open + verify handle access
|
validate PEB + mapped main image
|
snapshot once + run collectors
|
save versioned JSON
src/main.rs calls process_ops::process_processing::process_target with the PID
supplied by -p <pid>. With no arguments, it passes std::process::id() so Daydream
analyzes its own running image. Unknown options, missing values, extra arguments,
and non-numeric PIDs fail before analysis.
This is a binary crate, not a library crate. Most reusable-looking functions are
pub(crate) and are wired together internally; there is currently no stable Rust API
for another crate to import.
OpenProcessrequests onlyPROCESS_QUERY_INFORMATION | PROCESS_VM_READ.HandleGuardrejects invalid handles, uses Rust'sOwnedHandlefor automatic closing, and confirms the granted access mask throughNtQueryObjectbefore returning.validate_process_pebcross-checks the process ID from the handle and native process information, locates and validates the PEB, readsBeingDebuggedand the main-image base, validates the mapped x64 PE, and compares its base/size with the first Toolhelp module entry. Live image validation- Daydream tries to validate the executable reported by Toolhelp and hashes its bytes for report identity. If this fails, collection continues with the mapped image.
read_validated_imagecreates one bounded, sparse-awareValidatedPeSnapshot. Its PE identity must still match the earlier validation. Loader-discarded ranges that cannot be read are retained as explicit unavailable ranges. The complete validation stages and invariants are documented invalidate_pe/README.md.collect_process_triageshares the snapshot with the PE section, PDB, and import/IAT collectors. It collects TEBs through the validated process handle and returns all outcomes in oneProcessTriageCollection.save_process_triagewrites process schema version 4 JSON. The progress display uses one updating stderr line; detailed evidence goes to the output files.
Daydream keeps location systems explicit instead of treating them as interchangeable:
| Location | Meaning | Availability |
|---|---|---|
| File offset | Byte position in the raw executable | Only for raw-backed bytes |
| RVA | Offset from the PE image base | Primary shared PE coordinate |
| Process address | module_base + RVA in the target |
When the addition is valid |
| Section | PE section containing the RVA | When a validated section covers it |
Process output roots prefer the SHA-256 of the validated backing file. If that file is
unavailable or invalid, Daydream hashes the mapped snapshot for the output identity and
records the source of the hash in sha256_source.
Import scans cap descriptor and thunk visits, name processing, RVA mapping work, and cross-reference work. Reports identify an exceeded limit as a typed import error while other collectors continue.
Failures before a trustworthy analysis base exists are fatal. Examples include failing to open a process, insufficient handle access, a process/PE identity mismatch, inability to create the mapped-image snapshot, or failure to save the final output.
Collector-local problems are retained where the collection model supports them. Missing PDB data, an unavailable import range, or a thread that exits during enumeration can therefore appear as typed status/error data beside the successful results. A completed command means the orchestration and save succeeded; it does not imply that every target byte was readable.
| Area | Current state |
|---|---|
| Development stage | Active development / prototype |
| Supported operating system | Windows only |
| Supported architecture | x86-64 / PE32+ |
| Rust toolchain | Stable x86_64-pc-windows-msvc |
| Process output schema | Version 4 |
| Public API stability | Not guaranteed |
| Primary interface | Command-line application |
Do not treat the current output format, module boundaries, or collector behavior as a stable public API yet.
Daydream is intended for legitimate defensive work such as:
- Inspecting malware samples inside a controlled analysis environment.
- Collecting indicators and structural evidence for incident response.
- Examining binaries during an authorized security assessment.
- Investigating software you own or have permission to reverse engineer.
- Learning Windows process structures, PE internals, imports, PDB records, and x64 code patterns.
- Producing JSON artifacts for later review, comparison, or integration into a defensive analysis pipeline.
Daydream must not be used to access systems or processes without authorization, deploy payloads, evade defenders, or cause harm. Process-memory inspection is a dual-use capability; responsibility for lawful and ethical use remains with the operator.
Daydream opens a target with query and memory-read access, validates its identity, and reuses one validated main-image snapshot across its collectors.
- Process identity, executable path, handle access, and PEB validation.
- Main-module base address, image size, entry-point RVA, and section table.
- Sparse mapped-image reads with explicit unavailable-range tracking.
- Standard PE imports and direct RIP-relative IAT call/jump references. The
collection flow and supported encodings are documented in
imports/README.md. - CodeView PDB discovery for supported
RSDSandNB10records. - Per-thread TEB collection with identity and PEB-pointer checks.
- RVA, process address, section, and raw-file offset metadata where applicable.
Process mode keeps the terminal quiet during normal collection. It displays one updating progress line containing the current phase and overall percentage, while detailed results are written to JSON.
- Windows x64.
- Rust through rustup.
- The stable Rust toolchain.
- The
x86_64-pc-windows-msvctarget. - Microsoft Visual Studio Build Tools with the MSVC linker and Windows SDK.
- Sufficient rights to open the selected process with query and virtual-memory read access.
The repository's rust-toolchain.toml selects:
[toolchain]
channel = "stable"
targets = ["x86_64-pc-windows-msvc"]
components = ["rustfmt", "clippy"]Some protected, elevated, cross-session, security-sensitive, or architecture-mismatched processes may remain inaccessible even when Daydream itself runs correctly.
The dependency set is intentionally small:
| Dependency | Role in Daydream |
|---|---|
ms-pdb |
Read-only parsing of explicitly supplied local PDB files and their DBI substreams |
windows-sys |
Low-level Win32 types, constants, process/thread APIs, Toolhelp snapshots, memory information, file access, console behavior, and Windows cryptography |
serde_json |
Construction and pretty serialization of analyst-facing JSON artifacts |
| Rust standard library | CLI parsing, paths/files, collections, checked arithmetic, owned buffers, and RAII |
The small native declarations in core/internal/imports.rs link directly to
ntdll for NtOpenThread, NtQueryObject, NtQueryInformationProcess,
NtQueryInformationThread, NtReadVirtualMemory, and NtQueryVirtualMemory.
core/internal/handles.rs opens process handles through OpenProcess, thread
handles through NtOpenThread, validates granted access, and delegates automatic closing
to Rust's standard OwnedHandle.
Clone or open the repository from a Windows terminal and run:
cargo build
cargo testFor an optimized build:
cargo build --releaseThe release binary will be located at:
target\release\daydream.exe
Useful development checks include:
cargo check
cargo test
cargo clippyRunning without arguments falls back to process analysis of Daydream itself:
cargo runOr with a built binary:
.\target\release\daydream.execargo run -- -p 1234.\target\release\daydream.exe -p 1234The target must be a process Daydream is permitted to query and read. Running an elevated terminal may be necessary for an authorized elevated target, but elevation does not bypass Windows security boundaries or protected-process restrictions.
usage: daydream [-p <process id>]
Output is created under the terminal's current working directory. JSON files are written in pretty-printed form.
Process roots use the target executable's file stem and SHA-256 identity:
<process-name>_procdmp_<sha256>/
├── PE/
│ ├── image.json
│ ├── sections.json
│ └── pdb.json
├── Imports/
│ └── imports.json
└── PEB/
├── peb.json
└── tebs.json
Process JSON preserves typed failure or partial-read information instead of silently dismissing unavailable data. Reusing the same process output root updates retained JSON and removes known outputs from the deleted pattern, opcode, and string collectors.
- Place the collector under
src/core/process_ops/and declare it in that module'smod.rs. Reuse&ValidatedProcessPefor identity and&ValidatedPeSnapshotfor mapped-image data. - Extend
ProcessTriageCollectionand call the collector fromprocess_ops/data.rs. Connect expensive phases to the existing progress callback. - Preserve unavailable ranges and collector-local failures in typed results.
Use
process_ops/memory/for any additional target reads. - Add the JSON representation in
process_ops/outputs/json.rs. Define names and version changes in itsconfig.rs. IncrementPROCESS_TRIAGE_SCHEMA_VERSIONfor breaking schema changes. - Document access requirements, data ownership, and snapshot limits in the component's guide. Run the checks in Build and test.
PDB-content helpers live in process_ops/debuginfo/.
The separate DBI helper accepts an explicit local PDB path and preserves path
order and repeated occurrences.
The supported integration point today is the command plus its JSON output:
$daydream = ".\target\release\daydream.exe"
& $daydream -p 1234
if ($LASTEXITCODE -ne 0)
{
throw "Daydream analysis failed"
}Use the content-addressed output directory to associate results with a target. Check
schema_version before relying on field shapes. Many locations include a formatted
hexadecimal string for display and a numeric field for automation.
Embedding Daydream as a Rust dependency would require a library target and a supported public API. The internal collector types can be reused within the current binary crate.
src/main.rs dispatches the CLI. core/mod.rs declares the
top-level modules. Process triage gathers a typed collection in data.rs and passes
it to the output module. Process components expose their entry points through mod.rs
and keep their helpers and constants in the component.
| Area | Collector or guide | Components |
|---|---|---|
| Backing-file PE validation | Validated executable bytes for the process report hash | validate_target_file |
| Process triage | ProcessTriageCollection |
identity and PEB, mapped PE, memory, imports, PDB and DBI, TEBs, JSON |
| Mapped PE parsing | Bounded header collection and structural validation | parser entry point, header collection, checked readers, constants |
| Native calls and errors | Owned handles, typed ntdll bindings, and shared diagnostics |
handles.rs, imports.rs, error_handles.rs |
| Shared helpers | Checked byte reads, CodeView GUIDs, digests, and output utilities | bytes.rs, codeview.rs, digest.rs, output.rs |
- File offsets may be unavailable for mapped bytes that do not correspond to raw-backed file data.
- Process memory can change while collection is running. Threads may exit, stacks may change, and pages may become inaccessible.
- Loader-discarded, guarded, reserved, protected, or unreadable ranges can produce partial results. Daydream records these conditions when its collector shape supports them.
- Direct IAT xref collection currently focuses on supported x64 RIP-relative call and jump forms; it is not a complete disassembler or control-flow engine.
- Daydream does not replace a debugger, disassembler, sandbox, YARA engine, EDR product, or analyst judgment.
- Validate once and reuse structured PE/process state.
- Preserve RVA, process address, file offset, section, and completeness metadata.
- Keep backing-file validation separate from mapped-image validation.
- Retain typed partial failures instead of treating every unavailable page as a total scan failure.
- Restrict process access to the rights required for query and memory inspection.
- Prefer exact, contextual evidence over generic byte fragments.
- Keep large scans bounded and report progress for expensive phases.
- Use
// SAFETY NOTE - {reason}for comments that explainunsafeblocks. Document caller requirements for unsafe functions in their Rustdoc. - Assume Windows x64 directly; the project intentionally does not provide cross-platform fallback stubs.
Daydream is evolving quickly. Before making changes:
-
Read
AGENTS.mdand the relevant component instructions for repository-specific rules. -
Keep process-memory collectors under
process_ops. -
Reuse the validated process snapshot for mapped-image collection.
-
Add focused tests for matching, range, parser, or output behavior.
-
Run at least:
cargo check cargo test cargo build
-
Treat detections as evidence and document known false-positive conditions.
Contributions must remain within the project's defensive, authorized malware-analysis and reverse-engineering purpose.
