Last active
August 31, 2025 14:45
-
-
Save ThomasJClark/25472790efc19501fc0e94403a45a040 to your computer and use it in GitHub Desktop.
c0000unlimiter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Pattern16.h> | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <span> | |
| using Pattern16::scan; | |
| using namespace std; | |
| constexpr int8_t new_player_game_data_limit = 127; | |
| bool WINAPI DllMain(HINSTANCE dll_instance, uint32_t reason, void *reserved) { | |
| if (reason == DLL_PROCESS_ATTACH) { | |
| DisableThreadLibraryCalls(dll_instance); | |
| HMODULE module_handle = GetModuleHandleA("eldenring.exe"); | |
| if (!module_handle) { | |
| return false; | |
| } | |
| MEMORY_BASIC_INFORMATION memory_info; | |
| VirtualQuery(module_handle, &memory_info, sizeof(memory_info)); | |
| auto data = reinterpret_cast<uint8_t *>(memory_info.AllocationBase); | |
| auto dos_header = reinterpret_cast<IMAGE_DOS_HEADER *>(module_handle); | |
| auto nt_headers = reinterpret_cast<IMAGE_NT_HEADERS *>(&data[dos_header->e_lfanew]); | |
| auto size = nt_headers->OptionalHeader.SizeOfImage; | |
| auto patch = [&]<typename T>(void *addr, ptrdiff_t offset, T value) { | |
| if (addr) { | |
| reinterpret_cast<uintptr_t &>(addr) += offset; | |
| uint32_t protection; | |
| VirtualProtect(addr, sizeof(T), PAGE_EXECUTE_READWRITE, (PDWORD)&protection); | |
| *reinterpret_cast<T *>(addr) = value; | |
| FlushInstructionCache(module_handle, addr, sizeof(T)); | |
| VirtualProtect(addr, sizeof(T), protection, (PDWORD)&protection); | |
| } | |
| }; | |
| // Patch the GameDataMan constructor to allocate space for more PlayerGameData pointers | |
| auto player_game_data_alloc_addr = scan(data, size, | |
| "ba 40 01 00 00" // mov edx, 0x140 | |
| "ff 50 ??" // call allocate | |
| "48 89 43 28" // mov [rbx + 0x28], rax | |
| "?? ??" // ? | |
| "41 b8 40 01 00 00" // mov r8d, 0x140 | |
| "?? ?? ??" // ? | |
| "e8 ?? ?? ?? ??" // call memset | |
| ); | |
| patch(player_game_data_alloc_addr, 1, | |
| (uint32_t)(new_player_game_data_limit * sizeof(void *))); | |
| patch(player_game_data_alloc_addr, 16, | |
| (uint32_t)(new_player_game_data_limit * sizeof(void *))); | |
| // Patch the GameDataMan destructor to free all the new PlayerGameData pointers | |
| auto player_game_data_dealloc_addr = scan(data, size, | |
| "48 83 c7 08" // add rdi, 0x8 | |
| "48 81 ff 40 01 00 00" // cmp rdi, 0x140 | |
| ); | |
| patch(player_game_data_dealloc_addr, 7, | |
| (uint32_t)(new_player_game_data_limit * sizeof(void *))); | |
| // Patch the lookup for the first empty PlayerGameData slot to iterate over the full | |
| // new array | |
| auto player_game_data_loop_addr = scan(data, size, | |
| "ff c3" // inc ebx | |
| "49 ff c0" // inc r8 | |
| "48 83 c2 08" // add rdx, 0x8 | |
| "49 83 f8 28" // cmp r8, 0x28 | |
| ); | |
| patch(player_game_data_loop_addr, 12, (int8_t)new_player_game_data_limit); | |
| } | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.28.1) | |
| set(CMAKE_GENERATOR_PLATFORM x64) | |
| set(CMAKE_CXX_STANDARD 23) | |
| set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) | |
| project(c0000unlimiter VERSION "1.0.0" LANGUAGES CXX) | |
| include(FetchContent) | |
| FetchContent_Declare(pattern16 | |
| GIT_REPOSITORY https://github.com/Dasaav-dsv/Pattern16.git | |
| GIT_TAG 728eac543cee7e7bf6fda445d7db06e3dc8a61d0 | |
| CONFIGURE_COMMAND "" | |
| BUILD_COMMAND "") | |
| FetchContent_MakeAvailable(pattern16) | |
| add_library(pattern16 INTERFACE) | |
| target_include_directories(pattern16 INTERFACE ${pattern16_SOURCE_DIR}/include) | |
| add_library(${PROJECT_NAME} SHARED c0000unlimiter.cpp) | |
| set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) | |
| target_link_libraries(${PROJECT_NAME} PRIVATE pattern16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Copyright 2025 Tom Clark | |
| 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment