read player gold
This commit is contained in:
parent
7e7c0ed18a
commit
b50ea072e6
3 changed files with 95 additions and 20 deletions
|
@ -17,7 +17,6 @@
|
|||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
|
@ -53,27 +52,24 @@
|
|||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared" >
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
@ -130,9 +126,10 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<ItemGroup></ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -14,4 +14,9 @@
|
|||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
73
main.cpp
Normal file
73
main.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
#include <Psapi.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tchar.h>
|
||||
#include <TlHelp32.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// https://stackoverflow.com/questions/26572459/c-get-module-base-address-for-64bit-application
|
||||
DWORD_PTR GetProcessBaseAddress(DWORD processID)
|
||||
{
|
||||
DWORD_PTR baseAddress = 0;
|
||||
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
|
||||
HMODULE* moduleArray;
|
||||
LPBYTE moduleArrayBytes;
|
||||
DWORD bytesRequired;
|
||||
|
||||
if (processHandle)
|
||||
{
|
||||
if (EnumProcessModules(processHandle, NULL, 0, &bytesRequired))
|
||||
{
|
||||
if (bytesRequired)
|
||||
{
|
||||
moduleArrayBytes = (LPBYTE)LocalAlloc(LPTR, bytesRequired);
|
||||
|
||||
if (moduleArrayBytes)
|
||||
{
|
||||
unsigned int moduleCount;
|
||||
|
||||
moduleCount = bytesRequired / sizeof(HMODULE);
|
||||
moduleArray = (HMODULE*)moduleArrayBytes;
|
||||
|
||||
if (EnumProcessModules(processHandle, moduleArray, bytesRequired, &bytesRequired))
|
||||
{
|
||||
baseAddress = (DWORD_PTR)moduleArray[0];
|
||||
}
|
||||
|
||||
LocalFree(moduleArrayBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(processHandle);
|
||||
}
|
||||
|
||||
return baseAddress;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
DWORD pid = 0;
|
||||
HWND hwnd = FindWindowA(NULL, "DevilutionX");
|
||||
GetWindowThreadProcessId(hwnd, &pid);
|
||||
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, NULL, pid);
|
||||
if (hProc == NULL) {
|
||||
cout << "kys" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uintptr_t base = (uintptr_t)GetProcessBaseAddress(pid);
|
||||
uintptr_t plrA = base + 0x0058E470;
|
||||
uintptr_t plr;
|
||||
ReadProcessMemory(hProc, (LPCVOID)plrA, &plr, sizeof(plr), 0);
|
||||
uintptr_t goldA = plr + 0x3FE4;
|
||||
int gold = 0;
|
||||
ReadProcessMemory(hProc, (LPCVOID)goldA, &gold, sizeof(gold), 0);
|
||||
|
||||
cout << gold;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue