Sign in to follow this  
Followers 0
cyberbear

Bot with pointer problem

4 posts in this topic

#1 ·  Posted (edited)

Hello to all,

I am currently working a pointer based (WOKF) bot, i think i am on a good start.

Now my problem is that i want $CurrentHealth and $CurrentMana to be refreshed,

on a label and globally.

Please GranHolyCoders help me get unstucked.

CODE
#include <GuiConstants.au3>

$ProcessID = WinGetProcess("Kungfu Client")

$Address = 0x005FE608

Dim $CurrentHealthOffset[2]

$CurrentHealthOffset[0] = 'NULL' ;not used, doesn't matter, won't read anything here

$CurrentHealthOffset[1] = 192

Dim $CurrentManaOffset[2]

$CurrentManaOffset[1] = 200

Dim $CurrentHealth[2], $CurrentMana[2]

$Handle = _MemoryOpen($ProcessID)

$CurrentHealth = _MemoryPointerRead($Address, $Handle, $CurrentHealthOffset)

$CurrentMana = _MemoryPointerRead($Address, $Handle, $CurrentManaOffset)

$Config = GUICreate("Configuration", 188, 250, 0 + 100, 1 + 100, -1, -1)

GUICtrlCreateTab(0, 0, 250, 280)

GUICtrlCreateTabItem("General")

GUICtrlCreateLabel("HP : " & $CurrentHealth[1] , 10, 35, 50, 25)

GUICtrlCreateLabel("MP : " & $CurrentMana[1] , 10, 55, 50, 25)

GUICtrlCreateTabItem("Attack")

GUICtrlCreateTabItem("Buffs")

GUICtrlCreateTabItem(" Heal ")

GUISetState(@SW_SHOW)

_Main()

_MemoryClose($Handle)

Func _config()

$check = WinActive ("Configuration")

If $check = 1 Then

GUISetState(@SW_HIDE)

EndIf

If $check = 0 Then

GUISetState(@SW_SHOW)

EndIf

EndFunc

Func _Main()

HotKeySet("{HOME}", "_Config")

While 1

$msg1 = GUIGetMsg(1)

Select

Case $msg1[0] = $GUI_EVENT_CLOSE

If $msg1[1] = $Config Then

GUIDelete()

Exit

EndIf

EndSelect

WEnd

EndFunc

Func _MemoryPointerRead ($iv_Address, $ah_Handle, $av_Offset, $sv_Type = 'dword')

If IsArray($av_Offset) Then

If IsArray($ah_Handle) Then

Local $iv_PointerCount = UBound($av_Offset) - 1

Else

SetError(2)

Return 0

EndIf

Else

SetError(1)

Return 0

EndIf

Local $iv_Data[2], $i

Local $v_Buffer = DllStructCreate('dword')

For $i = 0 to $iv_PointerCount

If $i = $iv_PointerCount Then

$v_Buffer = DllStructCreate($sv_Type)

If @Error Then

SetError(@Error + 2)

Return 0

EndIf

$iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])

DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If @Error Then

SetError(7)

Return 0

EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

ElseIf $i = 0 Then

DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If @Error Then

SetError(7)

Return 0

EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

Else

$iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])

DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If @Error Then

SetError(7)

Return 0

EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

EndIf

Next

$iv_Data[0] = $iv_Address

Return $iv_Data

EndFunc

Func _MemoryClose($ah_Handle)

If Not IsArray($ah_Handle) Then

SetError(1)

Return 0

EndIf

DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])

If Not @Error Then

DllClose($ah_Handle[0])

Return 1

Else

DllClose($ah_Handle[0])

SetError(2)

Return 0

EndIf

EndFunc

Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)

If Not ProcessExists($iv_Pid) Then

SetError(1)

Return 0

EndIf

Local $ah_Handle[2] = [DllOpen('kernel32.dll')]

If @Error Then

SetError(2)

Return 0

EndIf

Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)

If @Error Then

DllClose($ah_Handle[0])

SetError(3)

Return 0

EndIf

$ah_Handle[1] = $av_OpenProcess[0]

Return $ah_Handle

EndFunc

This script runs great,

but the value do not refresh, i think my error is in red.

Anyway ty.

Edited by cyberbear

Share this post


Link to post
Share on other sites

Problem solved by myself to the one who cares :

test.au3

Share this post


Link to post
Share on other sites

Problem solved by myself to the one who cares :

test.au3

FYI... Autoit will only read that address until you reboot. There is something called an 'Allocation Base' address that is changed when your computer is restarted(Normally).

$StaticOffset = Dec("B05FC") ; "Inkball.exe+B05FC" - CheatEngine formatted static address.oÝ÷ Ù«­¢+ØÀÌØíÍHô}5µ½ÉåÑ    ÍÉÍÌ ÀÌØí½Á¹µ´°Ä¤ìÅÕ½Ðí%¹­±°¹á­ÀÕÅÕ½Ðì´ÑÌÝ¡ÐÅÕ½Ðí%¹­±°¹áÅÕ½ÐìÅձ̸(ÀÌØí¥¹±HôÅÕ½ÐìÁàÅÕ½ÐìµÀì!à ÀÌØíÍH¬ÀÌØíMÑÑ¥=ÍФì
ÉÑÌÑ¡¥¹°ÍÑÑ¥ÉÍÌå½ÔÉɽ´¸

Click the link in my sig for more info. :)

Share this post


Link to post
Share on other sites

FYI... Autoit will only read that address until you reboot. There is something called an 'Allocation Base' address that is changed when your computer is restarted(Normally).

$StaticOffset = Dec("B05FC") ; "Inkball.exe+B05FC" - CheatEngine formatted static address.oÝ÷ Ù«­¢+ØÀÌØíÍHô}5µ½ÉåÑ    ÍÉÍÌ ÀÌØí½Á¹µ´°Ä¤ìÅÕ½Ðí%¹­±°¹á­ÀÕÅÕ½Ðì´ÑÌÝ¡ÐÅÕ½Ðí%¹­±°¹áÅÕ½ÐìÅձ̸(ÀÌØí¥¹±HôÅÕ½ÐìÁàÅÕ½ÐìµÀì!à ÀÌØíÍH¬ÀÌØíMÑÑ¥=ÍФì
ÉÑÌÑ¡¥¹°ÍÑÑ¥ÉÍÌå½ÔÉɽ´¸

Click the link in my sig for more info. :)

pointers r used at each start up to point where is the new addresses. Rebooting wont affect it.

These pointers arent good anymore, not planning on renewing them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0