Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf49406 committed Jan 10, 2025
1 parent 88965df commit 69c2133
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CDOTACamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CDOTACamera {
if (camera_base_address == -1)
return false;

printf("[+] CDOTA_Camera: %p\n", reinterpret_cast<void*>(camera_base_address));
printf("[+] CDOTA_Camera: %p\n", (void*)camera_base_address);
camera_base_ = camera_base_address;
return true;
}
Expand Down
13 changes: 7 additions & 6 deletions Dota2Patcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,31 @@ int main(int argc, char* argv[]) {

// PATCHES

Patches ptch;
Patches patch;

ptch.add_patch({
patch.add_patch({
"sv_cheats",
"engine2.dll",
Patches::Patterns::sv_cheats,
"EB"
});

ptch.add_patch({
patch.add_patch({
"fog_enable",
"engine2.dll",
Patches::Patterns::fog_enable,
"EB"
});

ptch.add_patch({
patch.add_patch({
"set_rendering_enabled",
"particles.dll",
Patches::Patterns::set_rendering_enabled,
"85",
1
});

for (const auto& patch : ptch.patches) {
for (const auto& patch : patch.patches) {
uintptr_t patch_addr = memory.pattern_scan(process.get(), memory.loaded_modules[patch.module], patch.pattern);
if (patch_addr == -1) {
printf("[!] Pattern for \"%s\" not found!\n", patch.name.c_str());
Expand All @@ -125,6 +125,7 @@ int main(int argc, char* argv[]) {
printf("[+] \"%s\" patched successfully\n", patch.name.c_str());
}

printf("[+] Done!\n");
printf("[+] Done! Will close in 5 seconds...\n");
Sleep(5000);
return 0;
}
2 changes: 1 addition & 1 deletion Dota2Patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Patches {
std::string module;
std::string pattern;
std::string patch_bytes;
int offset;
int offset = 0;
};

void add_patch(const PatchInfo& patch) {
Expand Down
10 changes: 7 additions & 3 deletions Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
#include <sstream>

std::vector<BYTE> parse_pattern(const std::string& pattern) {
static std::vector<BYTE> parse_pattern(const std::string& pattern) {
std::vector<BYTE> parsed_pattern;
std::stringstream ss(pattern);
std::string byte_str;
Expand All @@ -19,7 +19,7 @@ std::vector<BYTE> parse_pattern(const std::string& pattern) {
return parsed_pattern;
}

std::string WCharToString(const WCHAR* wcharStr) {
static std::string wchar_to_string(const WCHAR* wcharStr) {
int bufferSize = WideCharToMultiByte(CP_UTF8, 0, wcharStr, -1, nullptr, 0, nullptr, nullptr);
if (bufferSize <= 0)
return "";
Expand Down Expand Up @@ -51,8 +51,12 @@ uintptr_t Memory::pattern_scan(const HANDLE hProc, const ModuleInfo target_modul
return target_module.start_address + first_match;
}

// Retarder visual studio
#pragma warning(push)
#pragma warning(disable : 6385)
const unsigned char pattern_current = *reinterpret_cast<const unsigned char*>(pattern);
const unsigned char memory_current = buffer[i];
#pragma warning(pop)

if (pattern_current == '\?' || memory_current == getByte(pattern)) {
if (!first_match) {
Expand Down Expand Up @@ -95,7 +99,7 @@ bool Memory::load_modules(HANDLE hProc) {
info.start_address = reinterpret_cast<uintptr_t>(module_entry.modBaseAddr);
info.end_address = info.start_address + module_entry.modBaseSize;
info.region_size = info.end_address - info.start_address;
modules[WCharToString(module_entry.szModule)] = info;
modules[wchar_to_string(module_entry.szModule)] = info;
} while (Module32Next(snapshot, &module_entry));
}

Expand Down
2 changes: 1 addition & 1 deletion Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Memory {

bool load_modules(HANDLE hProc);
uintptr_t pattern_scan(const HANDLE hProc, const ModuleInfo target_module, const std::string target_pattern);
bool patch(const HANDLE hProc, const uintptr_t patch_addr, const std::string& replace_str, int patch_offset = 0);
bool patch(const HANDLE hProc, const uintptr_t patch_addr, const std::string& replace_str, int patch_offset);
uintptr_t absolute_address(HANDLE hProc, uintptr_t instruction_ptr, ptrdiff_t offset, std::optional<uint32_t> size);
uintptr_t get_pointer(HANDLE hProc, uintptr_t base_address, uintptr_t offset);

Expand Down

0 comments on commit 69c2133

Please sign in to comment.