Skip to content
WHotsPublic

About

Daydream is a Windows x64 process analysis tool built in Rust for inspecting running applications, validating PE structures, analyzing memory, extracting strings, identifying imports, and collecting low-level process data for security research and malware analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

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.

Daydream project banner

Daydream

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.

Table of contents

Overview

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.

How Daydream works

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

Command dispatch

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.

Process pipeline

  1. OpenProcess requests only PROCESS_QUERY_INFORMATION | PROCESS_VM_READ. HandleGuard rejects invalid handles, uses Rust's OwnedHandle for automatic closing, and confirms the granted access mask through NtQueryObject before returning.
  2. validate_process_peb cross-checks the process ID from the handle and native process information, locates and validates the PEB, reads BeingDebugged and the main-image base, validates the mapped x64 PE, and compares its base/size with the first Toolhelp module entry. Live image validation
  3. 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.
  4. read_validated_image creates one bounded, sparse-aware ValidatedPeSnapshot. 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 in validate_pe/README.md.
  5. collect_process_triage shares the snapshot with the PE section, PDB, and import/IAT collectors. It collects TEBs through the validated process handle and returns all outcomes in one ProcessTriageCollection.
  6. save_process_triage writes process schema version 4 JSON. The progress display uses one updating stderr line; detailed evidence goes to the output files.

Locations and identity

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.

Fatal and partial failures

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.

Project status

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.

Intended usage

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.

Current capabilities

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 RSDS and NB10 records.
  • 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.

Requirements

  • Windows x64.
  • Rust through rustup.
  • The stable Rust toolchain.
  • The x86_64-pc-windows-msvc target.
  • 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.

Dependency roles

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.

Build and test

Clone or open the repository from a Windows terminal and run:

cargo build
cargo test

For an optimized build:

cargo build --release

The release binary will be located at:

target\release\daydream.exe

Useful development checks include:

cargo check
cargo test
cargo clippy

Usage

Analyze the current Daydream process

Running without arguments falls back to process analysis of Daydream itself:

cargo run

Or with a built binary:

.\target\release\daydream.exe

Analyze a running process by PID

cargo run -- -p 1234
.\target\release\daydream.exe -p 1234

The 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 structure

Output is created under the terminal's current working directory. JSON files are written in pretty-printed form.

Process output

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.

Extending and integrating

Add a process collector

  1. Place the collector under src/core/process_ops/ and declare it in that module's mod.rs. Reuse &ValidatedProcessPe for identity and &ValidatedPeSnapshot for mapped-image data.
  2. Extend ProcessTriageCollection and call the collector from process_ops/data.rs. Connect expensive phases to the existing progress callback.
  3. Preserve unavailable ranges and collector-local failures in typed results. Use process_ops/memory/ for any additional target reads.
  4. Add the JSON representation in process_ops/outputs/json.rs. Define names and version changes in its config.rs. Increment PROCESS_TRIAGE_SCHEMA_VERSION for breaking schema changes.
  5. 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.

Consume Daydream from another tool

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.

Project layout

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

Accuracy and limitations

  • 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.

Development principles

  • 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 explain unsafe blocks. Document caller requirements for unsafe functions in their Rustdoc.
  • Assume Windows x64 directly; the project intentionally does not provide cross-platform fallback stubs.

Contributing

Daydream is evolving quickly. Before making changes:

  1. Read AGENTS.md and the relevant component instructions for repository-specific rules.

  2. Keep process-memory collectors under process_ops.

  3. Reuse the validated process snapshot for mapped-image collection.

  4. Add focused tests for matching, range, parser, or output behavior.

  5. Run at least:

    cargo check
    cargo test
    cargo build
  6. 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.

About

Daydream is a Windows x64 process analysis tool built in Rust for inspecting running applications, validating PE structures, analyzing memory, extracting strings, identifying imports, and collecting low-level process data for security research and malware analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages