Code:
///////////////////////////////////////////////////////////////////////////
// AutoPotsR1.cpp : Defines the entry point for the console application.//
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//INCLUDES
#include "stdafx.h"
#include <windows.h>
#include <TlHelp32.h>
#include <iostream>
/////////////////////////////////////////////////////////////////////////
using namespace std;
////////////////////////////////////////////////////////////////////////
//NEEDED FUNCTIONS
DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
DWORD dwModuleBaseAddress = 0;
if(hSnapshot != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 ModuleEntry32 = {0};
ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
if(Module32First(hSnapshot, &ModuleEntry32))
{
do
{
if(_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
{
dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
break;
}
}
while(Module32Next(hSnapshot, &ModuleEntry32));
}
CloseHandle(hSnapshot);
}
return dwModuleBaseAddress;
}
float GetValue(HANDLE phandle,DWORD Address) {
float value = 0;
ReadProcessMemory(phandle,(LPCVOID)Address,&value,sizeof(value),NULL);
return value;
}
///////////////////////////////////////////////////////////////////////////
//MAIN FUNCTION
///////////////////////////////////////////////////////////////////////////
int main()
{
HWND window = FindWindow(0, _T("Diablo III"));
if( window == 0 ){
printf("Diablo III not found!\n");
char f;
cin >> f;
return 0;
}
int threshold;
char keybind;
cout << " \n";
Sleep(300);
cout << "=========================================================\n";
Sleep(100);
cout << "==== ===================================================\n";
Sleep(100);
cout << "=== ==================================================\n";
Sleep(100);
cout << "== == =========== ========================= =========\n";
Sleep(100);
cout << "= ==== == = == === === ==== === === ==\n";
Sleep(100);
cout << "= ==== == = === === == = == === === = =\n";
Sleep(100);
cout << "= == = === === = == = == = === ==== ===\n";
Sleep(100);
cout << "= ==== == = === === = == === = === ===== ==\n";
Sleep(100);
cout << "= ==== == = === === = == ===== = === === = =\n";
Sleep(100);
cout << "= ==== === === === === ====== ==== === ==\n";
Sleep(100);
cout << "=========================================================\n";
Sleep(300);
cout << " release: 1.5\n";
cout << " by: zewt @ ownedcore\n";
Sleep(300);
cout << " \n";
Sleep(300);
cout << "/////////////////////////////////////////////////////\n";
cout << "please enter an HP threshold: ";
cin >> threshold;
cout << "threshold set: " << threshold << "\n\n";
cout << "please enter your key bind (a-z): ";
cin >> keybind;
cout << "key bind set: " << keybind << "\n\n\n";
cout << "initializing...\n\n";
Sleep(500);
cout << "ready!\n\n";
Sleep(500);
SetWindowPos(window, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE );
DWORD pID = 0;
GetWindowThreadProcessId(window, &pID);
DWORD baseAddr = dwGetModuleBaseAddress(pID, _T("Diablo III.exe"));
DWORD staticOffset = 0xFE31CC;
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
float hp = 0;
DWORD value;
DWORD numBytesRead;
ReadProcessMemory(handle, (LPCVOID)(baseAddr+staticOffset), &value, sizeof(DWORD), &numBytesRead);
value+=0x18;
ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
value+=0xC8;
ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
value+=0xC;
ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
value+=0x2A0;
ReadProcessMemory(handle, (LPCVOID)value, &value, sizeof(DWORD), &numBytesRead);
value+=0x14;
while(1) {
ReadProcessMemory(handle, (LPCVOID)value, &hp, sizeof(DWORD), &numBytesRead);
//cout << hp << "\n\n";
//DWORD ADRESS = printf("%#x",value);
if(hp <= threshold) {
cout << "HP: " << hp << " < " << "Threshold: " << threshold << "\n" ;
cout << "Utilizing Potions...\n\n";
keybd_event(VkKeyScan(keybind),0,0,0);
keybd_event(VkKeyScan(keybind),0,0,0);
}
Sleep(100);
}
CloseHandle(handle);
char f;
cin >> f;
return 0;
}