acer20006 Posted September 26, 2009 Share Posted September 26, 2009 hii all after many research at the forum & internet.. finally i make my first script but there is some problem i found at it expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 413, 145, 301, 243) $cur_range = GUICtrlCreateLabel("Your Curent Range", 16, 24, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $new_cur = GUICtrlCreateLabel("New Range", 16, 68, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Cur_read = GUICtrlCreateInput("", 212, 24, 175, 21) $new_range = GUICtrlCreateInput("", 212, 70, 175, 21) $C_B = GUICtrlCreateButton("Change", 90, 104, 233, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; $address = 0xD35FDO3 $pHandle = _OpenProcess(WinGetHandle("Game_id")) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $cur_range GUICtrlSetData($Cur_read,$address) Case $msg = $C_B Func _OpenProcess($hWnd, $use_pid=0) If $use_pid = 0 Then Local $pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hWnd, "int*", 0) If IsArray($pid) Then $pid = $pid[2] Else SetError(-1) Return EndIf Else Local $pid = $hWnd EndIf Local $pHandle = DllCall("kernel32.dll", "long", "OpenProcess", "int", 0x001f0fff, "int", 0, "int", $pid) If IsArray($pHandle) And $pHandle[0] > 0 Then $pHandle = $pHandle[0] Else SetError(-2) Return EndIf Return $pHandle DllCall("kernel32.dll", "int", "CloseHandle", "int", $pHandle) EndFunc Func _ReadFloat($pHandle, $Address) Local $floatReturn = 0 Local $float = DllStructCreate("float") Local $ret = DllCall("kernel32.dll", "int", "ReadProcessMemory", "int", $pHandle, "int", $Address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] = 1 Then $floatReturn = DllStructGetData($float, 1) Else SetError(-1) EndIf Else SetError(-2) EndIf Return $floatReturn EndFunc Func _WriteFloat($pHandle, $Address, $value) Local $float = DllStructCreate("float") DllStructSetData($float, 1, $value) ; Need to make the memory writeable first! You should really restore the page protection afterwards though, but this is to make it work $outDw = 1 DllCall("kernel32.dll", "int", "VirtualProtectEx", "int", $pHandle, "ptr", $Address, "int", 4, "dword", 0x40, "dword*", $outDw) Local $ret = DllCall("kernel32.dll", "int", "WriteProcessMemory", "int", $pHandle, "int", $Address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] <> 0 Then Return True Else SetError(-2) Return False EndIf Else SetError(-1) Return False EndIf EndFunc _ReadFloat($pHandle, $address) _WriteFloat($pHandle, $address, "") _ReadFloat($pHandle, $address) _CloseHandle($pHandle) EndSelect WEnd >>>>><<<<script function>>>>> this script expose to find the the range at the game and allowed me to change it <<<<< but i cant find the bug at this script so if any one can help me i will be grateful for him .... and i think if there's other way with <NomadMemory> i can use it to read & write the float _ that's will be great Link to comment Share on other sites More sharing options...
Skrip Posted September 26, 2009 Share Posted September 26, 2009 (edited) hii all after many research at the forum & internet.. finally i make my first script but there is some problem i found at it expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 413, 145, 301, 243) $cur_range = GUICtrlCreateLabel("Your Curent Range", 16, 24, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $new_cur = GUICtrlCreateLabel("New Range", 16, 68, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Cur_read = GUICtrlCreateInput("", 212, 24, 175, 21) $new_range = GUICtrlCreateInput("", 212, 70, 175, 21) $C_B = GUICtrlCreateButton("Change", 90, 104, 233, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; $address = 0xD35FDO3 $pHandle = _OpenProcess(WinGetHandle("Game_id")) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $cur_range GUICtrlSetData($Cur_read,$address) Case $msg = $C_B Func _OpenProcess($hWnd, $use_pid=0) If $use_pid = 0 Then Local $pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hWnd, "int*", 0) If IsArray($pid) Then $pid = $pid[2] Else SetError(-1) Return EndIf Else Local $pid = $hWnd EndIf Local $pHandle = DllCall("kernel32.dll", "long", "OpenProcess", "int", 0x001f0fff, "int", 0, "int", $pid) If IsArray($pHandle) And $pHandle[0] > 0 Then $pHandle = $pHandle[0] Else SetError(-2) Return EndIf Return $pHandle DllCall("kernel32.dll", "int", "CloseHandle", "int", $pHandle) EndFunc Func _ReadFloat($pHandle, $Address) Local $floatReturn = 0 Local $float = DllStructCreate("float") Local $ret = DllCall("kernel32.dll", "int", "ReadProcessMemory", "int", $pHandle, "int", $Address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] = 1 Then $floatReturn = DllStructGetData($float, 1) Else SetError(-1) EndIf Else SetError(-2) EndIf Return $floatReturn EndFunc Func _WriteFloat($pHandle, $Address, $value) Local $float = DllStructCreate("float") DllStructSetData($float, 1, $value) ; Need to make the memory writeable first! You should really restore the page protection afterwards though, but this is to make it work $outDw = 1 DllCall("kernel32.dll", "int", "VirtualProtectEx", "int", $pHandle, "ptr", $Address, "int", 4, "dword", 0x40, "dword*", $outDw) Local $ret = DllCall("kernel32.dll", "int", "WriteProcessMemory", "int", $pHandle, "int", $Address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] <> 0 Then Return True Else SetError(-2) Return False EndIf Else SetError(-1) Return False EndIf EndFunc _ReadFloat($pHandle, $address) _WriteFloat($pHandle, $address, "") _ReadFloat($pHandle, $address) _CloseHandle($pHandle) EndSelect WEnd >>>>><<<<script function>>>>> this script expose to find the the range at the game and allowed me to change it <<<<< but i cant find the bug at this script so if any one can help me i will be grateful for him .... and i think if there's other way with <NomadMemory> i can use it to read & write the float _ that's will be great Uhh, why are your functions within your While() Loop? Place those at the end, after the loop. Doesn't answer your question, but fixes one problem at least. EDIT: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 413, 145, 301, 243) $cur_range = GUICtrlCreateLabel("Your Curent Range", 16, 24, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $new_cur = GUICtrlCreateLabel("New Range", 16, 68, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Cur_read = GUICtrlCreateInput("", 212, 24, 175, 21) $new_range = GUICtrlCreateInput("", 212, 70, 175, 21) $C_B = GUICtrlCreateButton("Change", 90, 104, 233, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; $address = 0xD35FD03 $pHandle = _OpenProcess(WinGetHandle("Game_id")) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $cur_range GUICtrlSetData($Cur_read, $address) Case $msg = $C_B _ReadFloat($pHandle, $address) _WriteFloat($pHandle, $address, "") _ReadFloat($pHandle, $address) ;~ _CloseHandle($pHandle); Undefined. EndSelect WEnd Func _OpenProcess($hWnd, $use_pid = 0) If $use_pid = 0 Then Local $pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hWnd, "int*", 0) If IsArray($pid) Then $pid = $pid[2] Else SetError(-1) Return EndIf Else Local $pid = $hWnd EndIf Local $pHandle = DllCall("kernel32.dll", "long", "OpenProcess", "int", 0x001f0fff, "int", 0, "int", $pid) If IsArray($pHandle) And $pHandle[0] > 0 Then $pHandle = $pHandle[0] Else SetError(-2) Return EndIf Return $pHandle DllCall("kernel32.dll", "int", "CloseHandle", "int", $pHandle) EndFunc ;==>_OpenProcess Func _WriteFloat($pHandle, $address, $value) Local $float = DllStructCreate("float") DllStructSetData($float, 1, $value) ; Need to make the memory writeable first! You should really restore the page protection afterwards though, but this is to make it work $outDw = 1 DllCall("kernel32.dll", "int", "VirtualProtectEx", "int", $pHandle, "ptr", $address, "int", 4, "dword", 0x40, "dword*", $outDw) Local $ret = DllCall("kernel32.dll", "int", "WriteProcessMemory", "int", $pHandle, "int", $address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] <> 0 Then Return True Else SetError(-2) Return False EndIf Else SetError(-1) Return False EndIf EndFunc ;==>_WriteFloat Func _ReadFloat($pHandle, $address) Local $floatReturn = 0 Local $float = DllStructCreate("float") Local $ret = DllCall("kernel32.dll", "int", "ReadProcessMemory", "int", $pHandle, "int", $address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] = 1 Then $floatReturn = DllStructGetData($float, 1) Else SetError(-1) EndIf Else SetError(-2) EndIf Return $floatReturn EndFunc ;==>_ReadFloat Did it for ya. I cleaned out all the errors for you, except _CloseHandle is an undefined func, so I commented it out. Edited September 26, 2009 by Skrip [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
acer20006 Posted September 26, 2009 Author Share Posted September 26, 2009 Uhh, why are your functions within your While() Loop? Place those at the end, after the loop. Doesn't answer your question, but fixes one problem at least. EDIT: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 413, 145, 301, 243) $cur_range = GUICtrlCreateLabel("Your Curent Range", 16, 24, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $new_cur = GUICtrlCreateLabel("New Range", 16, 68, 175, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Cur_read = GUICtrlCreateInput("", 212, 24, 175, 21) $new_range = GUICtrlCreateInput("", 212, 70, 175, 21) $C_B = GUICtrlCreateButton("Change", 90, 104, 233, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; $address = 0xD35FD03 $pHandle = _OpenProcess(WinGetHandle("Game_id")) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $cur_range GUICtrlSetData($Cur_read, $address) Case $msg = $C_B _ReadFloat($pHandle, $address) _WriteFloat($pHandle, $address, "") _ReadFloat($pHandle, $address) ;~ _CloseHandle($pHandle); Undefined. EndSelect WEnd Func _OpenProcess($hWnd, $use_pid = 0) If $use_pid = 0 Then Local $pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hWnd, "int*", 0) If IsArray($pid) Then $pid = $pid[2] Else SetError(-1) Return EndIf Else Local $pid = $hWnd EndIf Local $pHandle = DllCall("kernel32.dll", "long", "OpenProcess", "int", 0x001f0fff, "int", 0, "int", $pid) If IsArray($pHandle) And $pHandle[0] > 0 Then $pHandle = $pHandle[0] Else SetError(-2) Return EndIf Return $pHandle DllCall("kernel32.dll", "int", "CloseHandle", "int", $pHandle) EndFunc ;==>_OpenProcess Func _WriteFloat($pHandle, $address, $value) Local $float = DllStructCreate("float") DllStructSetData($float, 1, $value) ; Need to make the memory writeable first! You should really restore the page protection afterwards though, but this is to make it work $outDw = 1 DllCall("kernel32.dll", "int", "VirtualProtectEx", "int", $pHandle, "ptr", $address, "int", 4, "dword", 0x40, "dword*", $outDw) Local $ret = DllCall("kernel32.dll", "int", "WriteProcessMemory", "int", $pHandle, "int", $address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] <> 0 Then Return True Else SetError(-2) Return False EndIf Else SetError(-1) Return False EndIf EndFunc ;==>_WriteFloat Func _ReadFloat($pHandle, $address) Local $floatReturn = 0 Local $float = DllStructCreate("float") Local $ret = DllCall("kernel32.dll", "int", "ReadProcessMemory", "int", $pHandle, "int", $address, "ptr", DllStructGetPtr($float), "int", 4, "int", 0) If IsArray($ret) Then If $ret[0] = 1 Then $floatReturn = DllStructGetData($float, 1) Else SetError(-1) EndIf Else SetError(-2) EndIf Return $floatReturn EndFunc ;==>_ReadFloat Did it for ya. I cleaned out all the errors for you, except _CloseHandle is an undefined func, so I commented it out. thanks for you help but it's still problem at this part While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $C_B $cr_rg = _ReadFloat($pHandle, $address) _WriteFloat($pHandle, $address,"80") _ReadFloat($pHandle, $address) GUICtrlSetData($Cur_read, $cr_rg ) ;~ _CloseHandle($pHandle); Undefined. EndSelect WEnd i add this part to allowed reading from memory <<<< GUICtrlSetData($Cur_read, $cr_rg )>>>> but the problem is how to make memory to read $new_range value and write it at float in _WriteFloat($pHandle, $address,"80") _ i try this _WriteFloat($pHandle, $address,"$new_range") but when i check the rang at cheatengin i found the value = 6 --- so i need code to allowed read $new_range and write it at _writefloat Link to comment Share on other sites More sharing options...
acer20006 Posted September 26, 2009 Author Share Posted September 26, 2009 34 enter my topic and no one can help me !!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now