Skip to content

Commit

Permalink
Now patching all calls to trampolines
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Dec 13, 2020
1 parent e056796 commit 3efe5eb
Show file tree
Hide file tree
Showing 12 changed files with 14,141 additions and 487 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.user
x64/
Win32/
cyberpunk_amd_patch/vsxmake2019/*
31 changes: 0 additions & 31 deletions cyberpunk_amd_patch/amd_patch.sln

This file was deleted.

163 changes: 0 additions & 163 deletions cyberpunk_amd_patch/amd_patch.vcxproj

This file was deleted.

44 changes: 44 additions & 0 deletions cyberpunk_amd_patch/src/Image.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "Image.h"
#include <windows.h>
#include <zlib.h>
#include <spdlog/spdlog.h>
#include <dbghelp.h>
#include <sstream>

Image::Image()
{
auto* pImage = GetModuleHandleA(nullptr);

IMAGE_NT_HEADERS* pHeader = ImageNtHeader(pImage);
auto* pSectionHeaders = reinterpret_cast<IMAGE_SECTION_HEADER*>(pHeader + 1);

base_address = reinterpret_cast<uintptr_t>(pImage);

for (auto count = 0u; count < pHeader->FileHeader.NumberOfSections; ++count)
{
if (memcmp(pSectionHeaders->Name, ".text", 5) == 0)
{
pTextStart = reinterpret_cast<uint8_t*>(base_address + pSectionHeaders->VirtualAddress);
pTextEnd = reinterpret_cast<uint8_t*>(base_address + pSectionHeaders->VirtualAddress + pSectionHeaders->Misc.VirtualSize);
}

++pSectionHeaders;
}

uint32_t crc = crc32(0, pTextStart, pTextEnd - pTextStart);
std::ostringstream oss;
oss << crc;

spdlog::info("Computed .text crc: {:X}", crc);

switch(crc)
{
case 3622375216:
spdlog::info("\tResolved to version: 1.04");
version = MakeVersion(1,4);
break;
default:
spdlog::error("\tUnknown version, please update the mod");
break;
}
}
18 changes: 18 additions & 0 deletions cyberpunk_amd_patch/src/Image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <cstdint>

struct Image
{
Image();

static uint64_t MakeVersion(uint64_t aMajor, uint64_t aMinor)
{
return aMajor << 32 | aMinor << 16;
}

uint64_t version;
uintptr_t base_address;
uint8_t* pTextStart;
uint8_t* pTextEnd;
};
43 changes: 0 additions & 43 deletions cyberpunk_amd_patch/src/MinHook.cpp

This file was deleted.

Loading

0 comments on commit 3efe5eb

Please sign in to comment.