Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
ListBox1: TListBox;
Button1: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
PLAYER_ID =$5C684C;
BATTLELIST_Start=$5C68B4 + 4;
BATTLELIST_END=$5CC248;
Distance_ID= 0;
Distance_Type = -1;
Distance_Name= -0;
Distance_X = 32;
Distance_Y = 36;
Distance_Z = 40;
Distance_HorizScreenOffset = 44;
Distance_VertScreenOffset = 48;
Distance_Chameleon = 60;
Distance_Chameleon2 = 92;
Distance_IsWalking = 72;
Distance_Direction = 76;
Distance_Outfit = 92;
Distance_OutfitHead = 96;
Distance_OutfitBody = 100;
Distance_OutfitLegs = 104;
Distance_OutfitFeet = 108;
Distance_OutfitAddon = 112;
Distance_LightColor1 = 121;
Distance_LightColor2 = 122;
Distance_LightPattern = 123;
Distance_BlackSquare = 128;
Distance_HP = 132;
Distance_WalkSpeed = 136;
Distance_IsVisible = 140;
Distance_Skull = 144;
Distance_Duel = 148;
Target_ID=$00613B3C;
DISTANCE_LIGHT= $74;
DISTANCE_LIGHTCOLOR= $78;
STATUS_TEXT_TIMER= $71DBDC;
STATUS_TEXT= $71DBE0;
Backpack_Start=$5CEDD8;
Backpack_Name=16;
Backpack_Size=48;
Backpack_Amount=56;
Backpack_ItemID=60;
Backpack_ItemCount=64;
Backpack_StepSlot=12;
Backpack_StepContainer=492;
implementation
{$R *.dfm}
procedure SendPacket(ProcessID: Cardinal; Packet: Pointer; Encrypt: Boolean; SafeArray: Boolean); stdcall; external 'packet.dll';
//////////////////////////////////////////////
//////////////////////////////////////////////
//////////funkcje czytania///////////////////
////////////////////////////////////////////
///////////////////////////////////////////
procedure MemWriteInteger(Address: Integer; buf: Integer; Length: DWORD);
var ProcID, THandle: Integer;
e: DWORD;
begin
GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcID);
THandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcID);
WriteProcessMemory(THandle, Ptr(Address), @buf, Length, e);
CloseHandle(THandle);
end;
procedure MemWriteString(Address: Integer; buf: String; Length: DWORD);
var ProcID: Integer;
THandle: hWnd;
e: DWORD;
begin
GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcID);
THandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcID);
WriteProcessMemory(THandle, Pointer(Address), PChar(buf), Length, e);
CloseHandle(THandle);
end;
function MemReadInteger(Address: Cardinal): Cardinal; //Read adress:value
var
ProcId: Cardinal;
tProc: THandle;
NBR: Cardinal;
value:integer;
begin
GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcId);
tProc:= OpenProcess(PROCESS_ALL_ACCESS, False, ProcId);
ReadProcessMemory(tProc, Ptr(Address), @value, 4, NBR);
CloseHandle(tProc);
Result:=value;
end;
function MemReadString(Address: Integer): String;
var
NB : LongWord;
Temp : ARRAY [1..255] OF Byte;
I : Byte;
IDProcess, proc_ID : Cardinal;
begin
GetWindowThreadProcessID(FindWindow('TibiaClient', nil), @proc_ID);
IDProcess := OpenProcess(PROCESS_ALL_ACCESS, false, proc_ID);
Result := '';
ReadProcessMemory(IDProcess, Ptr(Address), @Temp[1], 255, NB);
for I := 1 to 255 do
begin
if ((Temp[i] = 0) or (Temp[i] = $0F)) then
Break;
Result := Result + Chr(Temp[i]);
end;
end;
///////////////////////////////////////////////
//////////////////////////////////////////////
//////////koniec/////////////////////////////
////////////////////////////////////////////
///////////////////////////////////////////
function pozycja:integer;
var
i,id_battle,id:integer;
begin
ID:=memreadinteger(Player_id); //odczytanie naszego id z adresu
for i:=1 to 149 do //przeszukanie wszystkich pozycji na battle list (minimalna 1 maxymanlna 149
Begin
id_battle:=memreadinteger(Battlelist_start + i*168);
if id_battle=ID then //jezeli id z battle list zgadza sie z id z adresu
Begin
Result :=i; //wtedy wynikiem funkcji jest nasza pozycja na battle
exit;
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
///////////////////////pozycja koniec////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
listbox1.items.Clear;
for i:=1 to 149 do
Listbox1.Items.Add(memreadstring(Battlelist_start + (i*156)-4));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(MemReadString(BattleList_Start+pozycja*160+Distance_name));
end;
end.
If you have some ideas or if you know what's wrong with this code please tell me or give me some advices.