I figured it out, though I am no windows programmer. It's running rather slowly I think in part because there's no event handler, so I'm pretty sure my process is hoggin the processor time. If anyone has suggestions, they'd be appreciated.
Code: Select all
#include <windows.h>
HWND windowname;
typedef struct _CHARACTER { //there's a reason for the buffer as seperate from a normal int
short int might;
short int buffer0;
short int agility;
short int buffer1;
short int fortitute;
short int buffer2;
short int intellect;
short int buffer3;
short int insight;
short int buffer4;
short int personality;
short int buffer5;
} CHARACTER;
struct _offset{
long might;
long agility;
long fortitude;
long intellect;
long insight;
long personality;
} offset = {0x7392b80,0x7392b84,0x7392b88,0x7392b8C,0x7392b90,0x7392b94};
void messbox (char* mess)
{
static char caption[]="Process Patcher Error";
MessageBox (windowname,mess, caption,MB_OK|MB_ICONERROR|MB_DEFBUTTON4|MB_APPLMODAL);
}
void main ()
{
CHARACTER i,j,result;
static char program[] = "d:\\forg\\fw.exe";
static char command[] = "";
static char path[] = "d:\\forg";
STARTUPINFO si;
PROCESS_INFORMATION pi;
char debuginfo[80] = "";
static char name[] = "ForgottenWorld";
unsigned long procid;
HANDLE FWhandle;
ZeroMemory(&result,sizeof(result));
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
windowname=FindWindow(NULL,&name);
GetWindowThreadProcessId(windowname,&procid);
FWhandle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,procid);
while(result.might<16 || result.agility<18 || result.fortitute<18 || result.insight<18)
{
ZeroMemory(&i,sizeof(i));
ZeroMemory(&j,sizeof(j));
if(ReadProcessMemory(FWhandle,offset.might,&i,sizeof(i),NULL)==FALSE) messbox("cannot read memory");
PostMessage(windowname,WM_KEYDOWN,VK_RETURN,0);
Loop:
if(ReadProcessMemory(FWhandle,offset.might,&j,sizeof(j),NULL)==FALSE) messbox("cannot read memory");
if(i.agility==j.agility&&i.fortitute==j.fortitute&&i.insight==j.insight&&i.intellect==j.intellect&&i.might==j.might&&i.personality==j.personality) goto Loop;
if(ReadProcessMemory(FWhandle,offset.might,&result,sizeof(result),NULL)==FALSE) messbox("cannot read memory");
PostMessage(windowname,WM_KEYUP,VK_RETURN,1);
}
PostMessage(windowname,WM_KEYUP,VK_RETURN,1);
CloseHandle(FWhandle);
}