Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
fixed bug with uninitialized structure usage
Browse files Browse the repository at this point in the history
changed resources layout
added unlimited zoom patch
working around rendering process
  • Loading branch information
DiaLight committed Jan 11, 2023
1 parent f27adc3 commit fbbe361
Show file tree
Hide file tree
Showing 23 changed files with 1,917 additions and 675 deletions.
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Submodule lodepng updated from 000000 to 997936
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ set(SOURCES
patches/hires_textures/redirect_load_cached_textures.cpp
patches/hires_textures/upscale_texture_buffer.cpp
patches/hires_textures/expand_size_hash_table.cpp
patches/fix_usage_unitialized_structure.cpp
patches/unlimited_zoom_hack.cpp
reimpl/SurfHashList__probablySort.cpp
reimpl/draw3dScene.cpp
tools/unpack_texture_cache.cpp
Expand All @@ -145,7 +147,7 @@ target_include_directories(bootstrap_patcher PRIVATE include)
target_link_libraries(bootstrap_patcher PRIVATE Dbghelp Shcore Comctl32 win32_gui_layout)
target_compile_definitions(bootstrap_patcher PRIVATE DIRECTINPUT_VERSION=0x0500 DIRECT3D_VERSION=0x0600)

add_subdirectory(vendor)
add_subdirectory(3rdparty)
target_link_libraries(bootstrap_patcher PRIVATE lodepng)

set_target_properties(bootstrap_patcher PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BIN_DIR}")
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ As dll has `export table`, you can generate lib file with Visual Studio tool `li
I've collected all the `esp register modification instruction locations`, so you can walk the stack based on this mapping(`mappings/stack.map`).
- Launcher with gui. (Planned for the future) users can enable/disable/configure patches in launcher

Usage:
- Download zip archive from [releases](https://github.com/DiaLight/Ember/releases/latest)
- Unpack wherever you like. Consider it a separate program with its own folder
- Run `launcher.exe`
- First you need to find the `Dungeon Keeper 2` directory using launcher. The program looks for the `DKII.exe` file and determines its version. Currently only version `1.70` is supported.
- Then you can configure resolution, etc
- Start the game with the big `start` button

The program does not modify existing game files.
For a complete removal, you must remove launcher's and `Dungeon Keeper 2\resources` directories and remove `HKEY_CURRENT_USER\SOFTWARE\Ember Launcher` registry key

Requirements:
- Python 3
- Visual Studio 2022
Expand Down
8 changes: 5 additions & 3 deletions api/patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ void PatchBuilder::writeAsm(void (*asmFun)()) {
write(pos, size);
}

void write_jump(uint8_t *pos, void *to) {
void write_jump(uint8_t *pos, void *to, size_t orig_size) {
DWORD oldProtect;
VirtualProtect(pos, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
pos[0] = 0xE9;
*((uint32_t *) (pos + 1)) = (uint8_t *) to - (pos + 5);
for (int i = 5; i < orig_size; ++i) pos[i] = 0x90;
VirtualProtect(pos, 5, oldProtect, NULL);
}
void write_call(uint8_t *pos, void *to) {
void write_call(uint8_t *pos, void *to, size_t orig_size) {
DWORD oldProtect;
VirtualProtect(pos, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
pos[0] = 0xE8;
*((uint32_t *) (pos + 1)) = (uint8_t *) to - (pos + 5);
for (int i = 5; i < orig_size; ++i) pos[i] = 0x90;
VirtualProtect(pos, 5, oldProtect, NULL);
}

Expand Down Expand Up @@ -172,7 +174,7 @@ HookHandle *HookHandle::_create(uint8_t *orig_addr, size_t orig_size, size_t rel
}

// jump proxy
write_jump(orig_addr, handle->code);
write_jump(orig_addr, handle->code, orig_size);
return handle;
}
HookHandle *HookHandle::create(uint8_t *orig_addr, size_t orig_size, size_t reloc_offs) {
Expand Down
4 changes: 2 additions & 2 deletions include/api/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <vector>
#include <functional>

void write_jump(uint8_t *pos, void *to);
void write_call(uint8_t *pos, void *to);
void write_jump(uint8_t *pos, void *to, size_t orig_size = 0);
void write_call(uint8_t *pos, void *to, size_t orig_size = 0);

class PatchBuilder {
std::vector<uint8_t> proxy;
Expand Down
Loading

0 comments on commit fbbe361

Please sign in to comment.