{"id":15647684,"url":"https://github.com/idouble/kernel-memory-reading-writing","last_synced_at":"2025-04-30T11:33:36.765Z","repository":{"id":130708634,"uuid":"201869489","full_name":"IDouble/Kernel-Memory-Reading-Writing","owner":"IDouble","description":"🔍 Code to read / write the Process Memory from the Kernel 🔧","archived":false,"fork":false,"pushed_at":"2024-02-29T17:05:34.000Z","size":694,"stargazers_count":74,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-26T07:15:55.047Z","etag":null,"topics":["c","easy-to-use","kernel","kernel-driver","kernel-functions","kernelmode","memory","process","read","simple","template","thread","windows","windows-kernel","write"],"latest_commit_sha":null,"homepage":"","language":"C","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/IDouble.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}},"created_at":"2019-08-12T06:18:57.000Z","updated_at":"2025-04-01T16:26:15.000Z","dependencies_parsed_at":"2024-04-08T23:02:36.375Z","dependency_job_id":"598dcdca-a578-43a8-8c13-71af1f2acd42","html_url":"https://github.com/IDouble/Kernel-Memory-Reading-Writing","commit_stats":null,"previous_names":["idouble/kernel-memory-reading-writing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FKernel-Memory-Reading-Writing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FKernel-Memory-Reading-Writing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FKernel-Memory-Reading-Writing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FKernel-Memory-Reading-Writing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IDouble","download_url":"https://codeload.github.com/IDouble/Kernel-Memory-Reading-Writing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251691668,"owners_count":21628367,"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","template","thread","windows","windows-kernel","write"],"created_at":"2024-10-03T12:20:36.150Z","updated_at":"2025-04-30T11:33:36.728Z","avatar_url":"https://github.com/IDouble.png","language":"C","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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidouble%2Fkernel-memory-reading-writing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidouble%2Fkernel-memory-reading-writing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidouble%2Fkernel-memory-reading-writing/lists"}