Hello,
I'm currently in need of a program that will restart Glider when it stops. In my situation, I am gliding Alterac Valley with a nice PPather task file. But as any of you Glider Eliter's out there know, Glider stops running when it changes zone. So, I thought I make a program that would click the Start Glide button everytime it enters or leave AV. I could just have it click the Start Glide button every 10 seconds but then I'd run into the problem where it will shrink the game and then enlarge it when it's not stopped. I'm trying to find out when it joins and leaves AV by reading the process memory.
I've been using Delphi for a few years and was pleased when I found Delphi sniplets here on the forums. However, I don't like how some people use libraries in order to port their program to an OS that doesn't have Windows NT API files.
To click the button, I'd simpy do the following:
Code:
SetCursorPos(X,Y); //X,Y = coordinates of the Start Glide button
Mouse_Event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Sleep(150);
Mouse_Event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Reading the memory is where I'm having troubles. After analyzing WoW.exe with IDA really quickly, I've gotten the following value for TlsIndex: $E8AA84
I started off by trying to just read one chunk of memory (size 1000), but got a return read value of 0.
Code:
I have a standard form with a memo box renamed to "status" and a button named Button1 with the following OnClick code:
procedure TForm1.Button1Click(Sender: TObject);
var
processid,threadid: integer;
buf: pchar;
hwindow, wname: integer;
read: cardinal;
begin
wname := FindWindow(nil, 'World of Warcraft');
if wname = 0 then begin
status.Lines.Add('Failed to get window handle.');
exit;
end;
status.lines.add('Window handle: ' + inttostr(wname));
threadid := getwindowthreadprocessid(wname, @processid);
hwindow := openprocess(PROCESS_ALL_ACCESS, false, processid);
if processid = 0 then begin
status.lines.Add('Failed to get process id.');
exit;
end;
status.lines.add('PID: ' + inttostr(processid));
status.lines.add('beginning to read memory...');
getmem(buf, 1000);
readprocessmemory(processid, Pointer($E8AA84), buf, 1000, read); //note the TLSINDEX
status.lines.Add(inttostr(read));
freemem(buf);
closehandle(hwindow);
end;
Can anyone with experience please help me out? Also, I hope this code becomes useful for anyone else in my situation. If I get it working, given that someone provides me with help of knowing when I leave/join AV, I will make the complete source/program available to all. Thank you in advanced.