{"id":15550307,"url":"https://github.com/etra0/memory-rs","last_synced_at":"2025-09-10T23:32:42.737Z","repository":{"id":45216998,"uuid":"257174236","full_name":"etra0/memory-rs","owner":"etra0","description":"A little library to make memory injections more easy.","archived":false,"fork":false,"pushed_at":"2023-03-24T16:15:41.000Z","size":147,"stargazers_count":43,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T01:01:20.680Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/etra0.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":"2020-04-20T04:49:14.000Z","updated_at":"2024-10-10T03:07:47.000Z","dependencies_parsed_at":"2024-10-28T09:07:07.143Z","dependency_job_id":"411472a9-c33f-4e72-9bff-24923b2de28d","html_url":"https://github.com/etra0/memory-rs","commit_stats":{"total_commits":102,"total_committers":5,"mean_commits":20.4,"dds":"0.33333333333333337","last_synced_commit":"66483423f19e665f1bfecf1657362766f58584a7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etra0%2Fmemory-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etra0%2Fmemory-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etra0%2Fmemory-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etra0%2Fmemory-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etra0","download_url":"https://codeload.github.com/etra0/memory-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232577437,"owners_count":18544803,"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":[],"created_at":"2024-10-02T13:54:51.413Z","updated_at":"2025-01-05T11:25:25.516Z","avatar_url":"https://github.com/etra0.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memory-rs\n**This is a work in progress.**\n\nA library written to facilitate game modding with Rust.\n\nThis library has the basics for making code injections, aobscan and code\npatching.\n\n# Usage\nThe example is a little bit extensive but hopefully makes it clear on how\nto use it.\n\n```rust\nuse memory_rs::generate_aob_pattern;\nuse memory_rs::internal::process_info::ProcessInfo;\nuse memory_rs::internal::injections::*;\n\nmemory_rs::scoped_no_mangle! {\n    // In reality, this `my_function_in_assembly` should be an extern to  an\n    // asm label which exposes the start of a shellcode, that you'd inject in\n    // the future.\n    my_function_in_assembly: u8 =  0x0;\n    my_function_in_assembly_jmp_back_addr: usize = 0x0;\n}\n\n\n// function wrapper to be called by DllMain\npub unsafe extern \"system\" fn wrapper(lib: *mut std::ffi::c_void) -\u003e u32 {\n  // ...\n  match patch() {\n    Ok(_) =\u003e println!(\"Everything is OK\"),\n    Err(e) =\u003e println!(\"Error: {}\", e),\n  };\n\n  0\n}\n\nfn patch() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Get some basic information of the process (like base address and binary\n    // size)\n    let proc_inf = ProcessInfo::new(Some(\"RDR2.exe\"))?;\n\n    let mut enable_hots_addr = {\n        // Scan for a pattern on the game's memory to get the address of\n        // where you want to do some injections\n        let memory_pattern = generate_aob_pattern![\n            0xFF, 0x90, _, 0x01, 0x00, 0x00, 0x84, 0xC0, 0x74, 0x05, 0x4D,\n            0x85, 0xE4\n        ];\n        let region = \u0026proc_inf.region;\n        region.scan_aob(\u0026memory_pattern)?\n            .ok_or(\"Couldn't find enable_hots_addr\")? - 0xA\n    };\n\n    // We use Detour since it's scope sensitive (if it fails it will deinject\n    // automatically\n    let mut enable_hots_det = unsafe { Detour::new(\n        enable_hots_addr,\n        16,\n        \u0026my_function_in_assembly as *const u8 as usize,\n        Some(\u0026mut my_function_in_assembly_jmp_back_addr))\n    };\n\n    enable_hots_det.inject();\n\n    let black_bars_addr = {\n        let memory_pattern = generate_aob_pattern![\n            0x0F, 0x86, _, _, 0xAA, 0xBB\n        ];\n        let region = \u0026proc_inf.region;\n        region.scan_aob(\u0026memory_pattern)?\n            .ok_or(\"Couldn't find black_bars_addr\")?\n    };\n\n    // nop 5 bytes, when Injection goes out of scope, it will reinject\n    // the original bytes.\n    let mut remove_black_bars = Injection::new(black_bars_addr, vec![0x90; 5]);\n\n    remove_black_bars.inject();\n\n    loop {}\n}\n\n// This will generate the DllMain required to create a DLL in Windows.\nmemory_rs::main_dll!(wrapper);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetra0%2Fmemory-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetra0%2Fmemory-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetra0%2Fmemory-rs/lists"}