Code:
;;====================================== ======================================== ==
;; Includes
;;====================================== ======================================== ==
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#RequireAdmin
#NoTrayIcon
;;====================================== ======================================== ==
;; Main
;;====================================== ======================================== ==
Opt("WinTitleMatchMode", 4)
SetPrivilege("SeDebugPrivilege", 1)
Global $ProcessID = WinGetProcess("Just Cause 2 Demo", "")
Dim $ProcessFound = 0
While $ProcessFound = 0
If $ProcessID = -1 Then
MsgBox(4096, "Error", "No process found.")
Exit(1)
EndIf
$ProcessFound = 1
WEnd
WinActivate("Just Cause 2 Demo")
$wc = WinGetPos("Just Cause 2 Demo")
$x = $wc[0] + ($wc[2] / 2) - 149/2
$y = $wc[1] + ($wc[3] / 2) - 42/2
GUICreate("BOLOPatch", 149, 42, $x, $y, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP, $WS_POPUPWINDOW,$WS_BORDER))
GUICtrlCreateLabel("Status:", 0, 0, 37, 17, $SS_CENTER)
$status = GUICtrlCreateLabel("", 40, 0, 107, 17, $SS_CENTER, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Coding by G&H Productions", 0, 24, 148, 17, BitOR($SS_CENTER,$SS_NOPREFIX), $WS_EX_CLIENTEDGE)
GUISetState()
Patch()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
;;====================================== ======================================== ==
;; Patch
;;====================================== ======================================== ==
Func Patch()
$DLL = _MemoryOpen($ProcessID)
If @Error Then
GUICtrlSetData($status, "Patching failure.")
EndIf
_MemoryWrite(0x004FE17D, $DLL, 0x90, "byte");;;
_MemoryWrite(0x004FE17E, $DLL, 0x90, "byte");;; TIME LIMIT DISABLE
_MemoryWrite(0x004FE17F, $DLL, 0x90, "byte");;;
_MemoryWrite(0x007F2C95, $DLL, 0x90, "byte");;;
_MemoryWrite(0x007F2C96, $DLL, 0x90, "byte");;;
_MemoryWrite(0x007F2C97, $DLL, 0x90, "byte");;; MAP LIMIT DISABLE
_MemoryWrite(0x007F2C98, $DLL, 0x90, "byte");;;
_MemoryWrite(0x007F2C99, $DLL, 0x90, "byte");;;
_MemoryClose($DLL)
GUICtrlSetData($status, "Patching success!")
EndFunc
;;;
;; NOMADMEMORY EXTRACT
;;;
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $iv_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', $iv_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
Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
Else
DllStructSetData($v_Buffer, 1, $v_Data)
If @Error Then
SetError(6)
Return 0
EndIf
EndIf
DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Return 1
Else
SetError(7)
Return 0
EndIf
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 SetPrivilege( $privilege, $bEnable )
Const $MY_TOKEN_ADJUST_PRIVILEGES = 0x0020
Const $MY_TOKEN_QUERY = 0x0008
Const $MY_SE_PRIVILEGE_ENABLED = 0x0002
Local $hToken, $SP_auxret, $SP_ret, $hCurrProcess, $nTokens, $nTokenIndex, $priv
$nTokens = 1
$LUID = DLLStructCreate("dword;int")
If IsArray($privilege) Then $nTokens = UBound($privilege)
$TOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
$NEWTOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
$hCurrProcess = DLLCall("kernel32.dll","hwnd","GetCurren tProcess")
$SP_auxret = DLLCall("advapi32.dll","int","OpenProces sToken","hwnd",$hCurrProcess[0], _
"int",BitOR($MY_TOKEN_ADJUST_PRIVILEGES, $MY_TOKEN_QUERY),"int*",0)
If $SP_auxret[0] Then
$hToken = $SP_auxret[3]
DLLStructSetData($TOKEN_PRIVILEGES,1,1)
$nTokenIndex = 1
While $nTokenIndex <= $nTokens
If IsArray($privilege) Then
$priv = $privilege[$nTokenIndex-1]
Else
$priv = $privilege
EndIf
$ret = DLLCall("advapi32.dll","int","LookupPriv ilegeValue","str","","str",$priv, _
"ptr",DLLStructGetPtr($LUID))
If $ret[0] Then
If $bEnable Then
DLLStructSetData($TOKEN_PRIVILEGES,2,$MY _SE_PRIVILEGE_ENABLED,(3 * $nTokenIndex))
Else
DLLStructSetData($TOKEN_PRIVILEGES,2,0,( 3 * $nTokenIndex))
EndIf
DLLStructSetData($TOKEN_PRIVILEGES,2,Dll StructGetData($LUID,1),(3 * ($nTokenIndex-1)) + 1)
DLLStructSetData($TOKEN_PRIVILEGES,2,Dll StructGetData($LUID,2),(3 * ($nTokenIndex-1)) + 2)
DLLStructSetData($LUID,1,0)
DLLStructSetData($LUID,2,0)
EndIf
$nTokenIndex += 1
WEnd
$ret = DLLCall("advapi32.dll","int","AdjustToke nPrivileges","hwnd",$hToken,"int",0, _
"ptr",DllStructGetPtr($TOKEN_PRIVILEGES) ,"int",DllStructGetSize($NEWTOKEN_PRIVIL EGES), _
"ptr",DllStructGetPtr($NEWTOKEN_PRIVILEG ES),"int*",0)
$f = DLLCall("kernel32.dll","int","GetLastErr or")
EndIf
$NEWTOKEN_PRIVILEGES=0
$TOKEN_PRIVILEGES=0
$LUID=0
If $SP_auxret[0] = 0 Then Return 0
$SP_auxret = DLLCall("kernel32.dll","int","CloseHandl e","hwnd",$hToken)
If Not $ret[0] And Not $SP_auxret[0] Then Return 0
return $ret[0]
EndFunc