Skip to content

Commit

Permalink
Update ProcManager
Browse files Browse the repository at this point in the history
- Fix some variables name
- Fix WriteValueToMemory
  • Loading branch information
faceslog committed Jun 15, 2021
1 parent 5057aa8 commit 98a5813
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions D3D9Hook/ProcManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ DWORD ProcManager::GetProcId(const wchar_t* procName)
return procId;
}

uintptr_t ProcManager::GetModuleBaseAddress(DWORD procId, const wchar_t* modNamme)
uintptr_t ProcManager::GetModuleBaseAddress(DWORD procId, const wchar_t* modName)
{
uintptr_t modBaseAdrr = 0;
uintptr_t modBaseAddr = 0;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);

if (hSnap != INVALID_HANDLE_VALUE)
Expand All @@ -45,9 +45,9 @@ uintptr_t ProcManager::GetModuleBaseAddress(DWORD procId, const wchar_t* modNamm
{
do
{
if (!_wcsicmp(modEntry.szModule, modNamme))
if (!_wcsicmp(modEntry.szModule, modName))
{
modBaseAdrr = (uintptr_t)modEntry.modBaseAddr;
modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
break;
}

Expand All @@ -56,7 +56,7 @@ uintptr_t ProcManager::GetModuleBaseAddress(DWORD procId, const wchar_t* modNamm
}

CloseHandle(hSnap);
return modBaseAdrr;
return modBaseAddr;
}

// Find Dynamic Memory Allocation
Expand Down Expand Up @@ -89,4 +89,3 @@ uintptr_t ProcManager::GetResolvedPointerChain(const unsigned int& relative_offs
{
return FindDMAAddy(hProcess, GetDynamicBaseAddress(relative_offset), offsets);
}

10 changes: 5 additions & 5 deletions D3D9Hook/ProcManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <Windows.h>
#include <TlHelp32.h>

class ProcManager
class ProcManager
{

public:
Expand All @@ -18,7 +18,7 @@ class ProcManager
uintptr_t GetDynamicBaseAddress(const unsigned int& relative_offset);
// Resolve our pointer chain from offsets
uintptr_t GetResolvedPointerChain(const unsigned int& relative_offset, std::vector<unsigned int> offsets);

// Read a Process Memory value
template<typename T>
void ReadValueFromMemory(T& value, uintptr_t address)
Expand All @@ -36,19 +36,19 @@ class ProcManager

// Write to a Process Memory Address
template<typename T>
void WriteValueToMemory(T& value, uintptr_t address)
void WriteValueToMemory(T value, uintptr_t address)
{
WriteProcessMemory(hProcess, (BYTE*)address, &value, sizeof(value), nullptr);
}

// Write to a Process Memory Address Redefinition using offsets is gonna call Get Resolved Pointer Chain
template<typename T>
void WriteValueToMemory(T& value, const unsigned int& relative_offset, std::vector<unsigned int> offsets)
void WriteValueToMemory(T value, const unsigned int& relative_offset, std::vector<unsigned int> offsets)
{
uintptr_t address = GetResolvedPointerChain(relative_offset, offsets);
WriteProcessMemory(hProcess, (BYTE*)address, &value, sizeof(value), nullptr);
}

private:
DWORD procId;
HANDLE hProcess;
Expand Down

0 comments on commit 98a5813

Please sign in to comment.