{"id":24180071,"url":"https://github.com/an-autodidact/kernel-memory-reading-writing","last_synced_at":"2026-04-18T14:04:00.868Z","repository":{"id":271975992,"uuid":"915158647","full_name":"an-autodidact/Kernel-Memory-Reading-Writing","owner":"an-autodidact","description":" 🔍 Code to read / write the Process Memory from the Kernel 🔧","archived":false,"fork":false,"pushed_at":"2025-01-11T05:57:36.000Z","size":363,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T19:16:46.968Z","etag":null,"topics":["c","easy-to-use","kernel","kernel-driver","kernel-functions","kernelmode","memory","process","read","simple","termplate","thread","windows","windows-kernel","write"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/an-autodidact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-11T05:47:59.000Z","updated_at":"2025-01-11T05:57:39.000Z","dependencies_parsed_at":"2025-01-11T06:26:34.770Z","dependency_job_id":"391885d2-7d3b-4050-a07d-7e001be2b863","html_url":"https://github.com/an-autodidact/Kernel-Memory-Reading-Writing","commit_stats":null,"previous_names":["an-autodidact/kernel-memory-reading-writing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-autodidact%2FKernel-Memory-Reading-Writing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-autodidact%2FKernel-Memory-Reading-Writing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-autodidact%2FKernel-Memory-Reading-Writing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-autodidact%2FKernel-Memory-Reading-Writing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/an-autodidact","download_url":"https://codeload.github.com/an-autodidact/Kernel-Memory-Reading-Writing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241557174,"owners_count":19981881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","easy-to-use","kernel","kernel-driver","kernel-functions","kernelmode","memory","process","read","simple","termplate","thread","windows","windows-kernel","write"],"created_at":"2025-01-13T06:11:41.637Z","updated_at":"2026-04-18T14:03:56.773Z","avatar_url":"https://github.com/an-autodidact.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔍 Kernel Memory Reading Writing 🔧\n🔍 Template to read / write the Process Memory from the **Kernel** (kernelmode) 🔧\n\n**How does it Work?**\u003c/br\u003e\n**A: It uses the undocumented NT API \"MmCopyVirtualMemory\" function in ntoskrnl.exe (Windows NT operating system kernel)**\n\n## 📝 KernelReadWriteMemory.c 📝\n\n```\n#include \u003cntdef.h\u003e\n#include \u003cntifs.h\u003e\n\nDRIVER_INITIALIZE DriverEntry;\n#pragma alloc_text(INIT, DriverEntry)\n\n// API function from ntoskrnl.exe which we use\n// to copy memory to and from an user process.\nNTSTATUS NTAPI MmCopyVirtualMemory\n(\n\tPEPROCESS SourceProcess,\n\tPVOID SourceAddress,\n\tPEPROCESS TargetProcess,\n\tPVOID TargetAddress,\n\tSIZE_T BufferSize,\n\tKPROCESSOR_MODE PreviousMode,\n\tPSIZE_T ReturnSize\n);\n\nNTKERNELAPI\nNTSTATUS\nPsLookupProcessByProcessId(\n\t_In_ HANDLE ProcessId,\n\t_Outptr_ PEPROCESS* Process\n);\n\nNTSTATUS KeReadProcessMemory(PEPROCESS Process, PVOID SourceAddress, PVOID TargetAddress, SIZE_T Size) {\n\t// Since the process we are reading from is the input process, we set\n\t// the source process variable for that.\n\tPEPROCESS SourceProcess = Process;\n\t// Since the \"process\" we read the output to is this driver\n\t// we set the target process as the current module.\n\tPEPROCESS TargetProcess = PsGetCurrentProcess();\n\tSIZE_T Result;\n\tif (NT_SUCCESS(MmCopyVirtualMemory(SourceProcess, SourceAddress, TargetProcess, TargetAddress, Size, KernelMode, \u0026Result)))\n\t\treturn STATUS_SUCCESS; // operation was successful\n\telse\n\t\treturn STATUS_ACCESS_DENIED;\n}\n\nNTSTATUS KeWriteProcessMemory(PEPROCESS Process, PVOID SourceAddress, PVOID TargetAddress, SIZE_T Size) {\n\t// This write func is just like the read func, except vice versa.\n\n\t// Since the process writing from is our module\n\t// change the source process variable for that.\n\tPEPROCESS SourceProcess = PsGetCurrentProcess();\n\t// Since the process we write to is the input process\n\t// we set the target process as the argument\n\tPEPROCESS TargetProcess = Process;\n\tSIZE_T Result;\n\n\tif (NT_SUCCESS(MmCopyVirtualMemory(SourceProcess, SourceAddress, TargetProcess, TargetAddress, Size, KernelMode, \u0026Result)))\n\t\treturn STATUS_SUCCESS; // operation was successful\n\telse\n\t\treturn STATUS_ACCESS_DENIED;\n}\n\nNTSTATUS DriverEntry(_In_  struct _DRIVER_OBJECT* DriverObject, _In_  PUNICODE_STRING RegistryPath)\n{\n\tint Writeval = 666;\n\n\tPEPROCESS Process; // our target process\n\t// enter your process ID here.\n\tPsLookupProcessByProcessId(4872, \u0026Process); //lookup the process by it's id;\n\n\tKeWriteProcessMemory(Process, \u0026Writeval, 0x010F29B0, sizeof(__int32));\n\n\tDbgPrint(\"Value of int i: %d\", Writeval);\n\n\treturn STATUS_SUCCESS;\n}\n```\n\n![Binance Ready to give crypto a try ? buy bitcoin and other cryptocurrencies on binance](Images/binance.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan-autodidact%2Fkernel-memory-reading-writing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fan-autodidact%2Fkernel-memory-reading-writing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan-autodidact%2Fkernel-memory-reading-writing/lists"}