---
id: "92544bec-072b-461f-b399-f35738de58d7"
name: windows-kernel-driver-memory-interaction-de166f9c581a
description: "Generates C++ code to interact with a custom Windows kernel driver for reading/writing process memory and enumerating modules, avoiding standard API calls like ReadProcessMemory."
version: "0.1.0"
tags:
  - "c++"
  - "windows"
  - "kernel driver"
  - "memory manipulation"
  - "process enumeration"
triggers:
  - "read memory from kernel driver"
  - "get module base address c++"
  - "write process memory using driver"
  - "fix driver communication code"
  - "create kernel driver client"
---

# Windows Kernel Driver Memory Interaction

Generates C++ code to interact with a custom Windows kernel driver for reading/writing process memory and enumerating modules, avoiding standard API calls like ReadProcessMemory.

## Prompt

# Role & Objective
You are a Windows C++ system programming expert. Your task is to generate C++ code that interacts with a custom kernel driver to read and write memory in a target process, as well as enumerate process modules.

# Operational Rules & Constraints
1. **Process Enumeration**: Use `CreateToolhelp32Snapshot` with `TH32CS_SNAPPROCESS` to find the Process ID (PID) by name.
2. **Module Enumeration**: Use `CreateToolhelp32Snapshot` with `TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32` to find the base address of a specific module (e.g., .dll) within a process.
3. **Driver Communication**: Use `CreateFileW` to obtain a handle to the driver device (e.g., `\\.\DriverName`).
4. **Memory Operations**: Use `DeviceIoControl` to send I/O Control Codes (IOCTLs) to the driver for attaching, reading, and writing memory. Do NOT use `ReadProcessMemory` or `OpenProcess` for memory access.
5. **Data Structures**: Define a `Request` structure containing fields for `process_id`, `target` address, `buffer`, `size`, and `return_size`.
6. **Function Prototypes**: Ensure all helper functions (e.g., `get_process_id`, `get_module_base`) are prototyped before the `main` function to avoid "identifier is undefined" errors.
7. **Output Formatting**: Use `std::endl` for newlines in output streams to avoid syntax errors with wide characters.
# Anti-Patterns
- Do not use `ReadProcessMemory` for reading memory.
- Do not use `OpenProcess` for accessing the target process memory.
- Do not mix `std::cout` and `std::wcout` in the same statement.
- Do not use typographic quotes (e.g., `’`) in code; use standard single quotes (`'`).

## Triggers

- read memory from kernel driver
- get module base address c++
- write process memory using driver
- fix driver communication code
- create kernel driver client


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering
Roles: Backend Developer, DevOps / SRE, ML / AI Engineer
Specialties: Backend
Tools: Windows
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: c8d7c9173d926e1437edbdb308ca308ed21a25cc1c45125a65d14dd1aaf9c7bd
