Warcraft III Game Start Notifier + Source Code

This is a discussion on Warcraft III Game Start Notifier + Source Code within the Warcraft 3 Hacks, bots and tools board part of the Warcraft 3 forum category; Well you should know this is an AutoIt script that will play a sound when the game started (Loading finished), ...

Results 1 to 4 of 4
  1. #1
    Farid.Agl's Avatar
    Farid.Agl is offline Advanced Hacker

    Array
    Join Date
    Sep 2011
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    322

    Warcraft III Game Start Notifier 1.1 + Source Code

    Well you should know this is an AutoIt script that will play a sound when the game started (Loading finished), no matter you are host or not. It's working on 1.24x - 1.25x - 1.26x.
    Feel free to use this codes on your own projects and i will be happy to see some credits over there!
    You can directly copy paste the codes from here and compile it with AutoIt compiler, also you can download the zip package that i attached (Include source code + Icon + Wav file).
    Game Start Notifier 1.1.zip
    Or you can download the compiled file :
    Game Start Notifier 1.1.exe



    Code:
    #RequireAdmin
    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Version=beta
    #AutoIt3Wrapper_Icon=Icon.ico
    #AutoIt3Wrapper_Compression=4
    #AutoIt3Wrapper_Res_Fileversion=1.1.0.0
    #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    
    #cs ----------------------------------------------------------------------------
    	AutoIt Version:		3.3.7.20 (beta)
    	Author:				D4RK.ON3 - [email protected]
    
    
    	Script Function:	Warcraft III Game Start Notifier
    	Supported Patches:	1.24x - 1.25x - 1.26x
    	Tested On:			Windows 7 Ultimate x86 - Patch 1.24b & 1.24e & 1.25b & 1.26a
    #ce ----------------------------------------------------------------------------
    
    
    Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle"
    _Singleton("Game Start Notifier")
    AutoItSetOption("TrayAutoPause", 0)
    TraySetToolTip("Warcraft III Game Start Notifier")
    
    
    Global $ImSafe = 0, $Process, $Game_dll
    Local $PID, $Location, $Patch, $Value, $GameState = 0
    
    
    _SetPrivilege("SeDebugPrivilege", 1)
    
    
    OnAutoItExitRegister("_Close")
    Func _Close()
    	_MemoryClose($Process)
    	If @Compiled Then
    		FileDelete(@ScriptDir & "\GameStarted.mp3")
    	EndIf
    EndFunc   ;==>_Close
    
    
    FileInstall("GameStarted.mp3", @ScriptDir & "\GameStarted.mp3", 1)
    
    
    While 1
    	If WinExists("[CLASS:Warcraft III]") Then
    		_MainFunction()
    	Else
    		$ImSafe = 0
    	EndIf
    	Sleep(1000)
    WEnd
    
    
    Func _MainFunction()
    	If $ImSafe = 0 Then
    		$PID = WinGetProcess("[CLASS:Warcraft III]")
    		$Process = _MemoryOpen($PID)
    		$Game_dll = _MemoryModuleGetBaseAddress($PID, "Game.dll")
    		$Location = _ProcessGetLocation($PID)
    		$Patch = FileGetVersion($Location)
    		$ImSafe = 1
    	EndIf
    
    
    	Select
    		Case StringTrimRight($Patch, 7) = "1.24"
    			_Patch1_24x()
    		Case StringTrimRight($Patch, 7) = "1.25" Or StringTrimRight($Patch, 7) = "1.26"
    			_Patch1_25_26x()
    	EndSelect
    EndFunc   ;==>_MainFunction
    
    
    ;~ -----------------------------------------------------------------------------
    
    
    Func _Patch1_24x()
    	$Value = _MemoryRead($Game_dll + 0xAE64D8, $Process)
    	If $Value = 1 Then
    		If $GameState = 0 Then
    			SoundPlay(@ScriptDir & "\GameStarted.mp3")
    			$GameState = 1
    		EndIf
    	EndIf
    	If $Value = 0 Then
    		If $GameState = 1 Then
    			$GameState = 0
    		EndIf
    	EndIf
    EndFunc   ;==>_Patch1_24x
    
    
    Func _Patch1_25_26x()
    	$Value = _MemoryRead($Game_dll + 0xACF678, $Process)
    	If $Value = 1 Then
    		If $GameState = 0 Then
    			SoundPlay(@ScriptDir & "\GameStarted.mp3")
    			$GameState = 1
    		EndIf
    	EndIf
    	If $Value = 0 Then
    		If $GameState = 1 Then
    			$GameState = 0
    		EndIf
    	EndIf
    EndFunc   ;==>_Patch1_25_26x
    
    
    ;~ -----------------------------------------------------------------------------
    
    
    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", "GetCurrentProcess")
    	$SP_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "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", "LookupPrivilegeValue", "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, DllStructGetData($LUID, 1), (3 * ($nTokenIndex - 1)) + 1)
    				DllStructSetData($TOKEN_PRIVILEGES, 2, DllStructGetData($LUID, 2), (3 * ($nTokenIndex - 1)) + 2)
    				DllStructSetData($LUID, 1, 0)
    				DllStructSetData($LUID, 2, 0)
    			EndIf
    			$nTokenIndex += 1
    		WEnd
    		$ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $hToken, "int", 0, _
    				"ptr", DllStructGetPtr($TOKEN_PRIVILEGES), "int", DllStructGetSize($NEWTOKEN_PRIVILEGES), _
    				"ptr", DllStructGetPtr($NEWTOKEN_PRIVILEGES), "int*", 0)
    		$f = DllCall("kernel32.dll", "int", "GetLastError")
    	EndIf
    	$NEWTOKEN_PRIVILEGES = 0
    	$TOKEN_PRIVILEGES = 0
    	$LUID = 0
    	If $SP_auxret[0] = 0 Then Return 0
    	$SP_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hToken)
    	If Not $ret[0] And Not $SP_auxret[0] Then Return 0
    	Return $ret[0]
    EndFunc   ;==>_SetPrivilege
    
    
    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   ;==>_MemoryOpen
    
    
    Func _MemoryModuleGetBaseAddress($iPID, $sModule)
    	If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
    
    
    	If Not IsString($sModule) Then Return SetError(2, 0, 0)
    
    
    	Local $PSAPI = DllOpen("psapi.dll")
    
    
    	Local $hProcess
    	Local $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020)
    
    
    	If $iPID > 0 Then
    		Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
    		If $hProcess[0] Then
    			$hProcess = $hProcess[0]
    		EndIf
    	EndIf
    
    
    	Local $Modules = DllStructCreate("ptr[1024]")
    	Local $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
    	If $aCall[4] > 0 Then
    		Local $iModnum = $aCall[4] / 4
    		Local $aTemp
    		For $i = 1 To $iModnum
    			$aTemp = DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
    			If $aTemp[3] = $sModule Then
    				DllClose($PSAPI)
    				Return Ptr(DllStructGetData($Modules, 1, $i))
    			EndIf
    		Next
    	EndIf
    
    
    	DllClose($PSAPI)
    	Return SetError(-1, 0, 0)
    EndFunc   ;==>_MemoryModuleGetBaseAddress
    
    
    Func _MemoryRead($iv_Address, $ah_Handle, $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
    	EndIf
    
    
    	DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
    
    
    	If Not @error Then
    		Local $v_Value = DllStructGetData($v_Buffer, 1)
    		Return $v_Value
    	Else
    		SetError(6)
    		Return 0
    	EndIf
    EndFunc   ;==>_MemoryRead
    
    
    Func _ProcessGetLocation($iPID)
    	Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
    	Local $vStruct = DllStructCreate('int[1024]')
    	DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
    	Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
    	Return $aReturn[3]
    EndFunc   ;==>_ProcessGetLocation
    
    
    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   ;==>_MemoryClose
    
    
    Func _Singleton($sOccurenceName, $iFlag = 0)
    	Local Const $ERROR_ALREADY_EXISTS = 183
    	Local Const $SECURITY_DESCRIPTOR_REVISION = 1
    	Local $pSecurityAttributes = 0
    
    
    	If BitAND($iFlag, 2) Then
    		Local $tSecurityDescriptor = DllStructCreate("dword[5]")
    		Local $pSecurityDescriptor = DllStructGetPtr($tSecurityDescriptor)
    		Local $aRet = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _
    				"ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
    		If @error Then Return SetError(@error, @extended, 0)
    		If $aRet[0] Then
    			$aRet = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _
    					"ptr", $pSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0)
    			If @error Then Return SetError(@error, @extended, 0)
    			If $aRet[0] Then
    				Local $structSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES)
    				DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes))
    				DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor)
    				DllStructSetData($structSecurityAttributes, 3, 0)
    				$pSecurityAttributes = DllStructGetPtr($structSecurityAttributes)
    			EndIf
    		EndIf
    	EndIf
    
    
    	Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", $pSecurityAttributes, "bool", 1, "wstr", $sOccurenceName)
    	If @error Then Return SetError(@error, @extended, 0)
    	Local $lastError = DllCall("kernel32.dll", "dword", "GetLastError")
    	If @error Then Return SetError(@error, @extended, 0)
    	If $lastError[0] = $ERROR_ALREADY_EXISTS Then
    		If BitAND($iFlag, 1) Then
    			Return SetError($lastError[0], $lastError[0], 0)
    		Else
    			Exit -1
    		EndIf
    	EndIf
    	Return $handle[0]
    EndFunc   ;==>_Singleton
    Last edited by Farid.Agl; 11-07-2011 at 11:17 AM. Reason: Updated to version 1.1.0.0

  2. The Following 4 Users Say Thank You to Farid.Agl For This Useful Post:


  3. #2
    AmpFlorian's Avatar
    AmpFlorian is offline I'm Back

    Array
    Join Date
    Jun 2009
    Location
    127.0.0.1
    Posts
    1,579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    12
    Reputation
    664
    Good work, even though I think I've seen this somewhere before. >.> No matter.

  4. #3
    Farid.Agl's Avatar
    Farid.Agl is offline Advanced Hacker

    Array
    Join Date
    Sep 2011
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    322
    Thanks.
    I wrote this for learning purposes and i didn't see any source code for this tool.

  5. #4
    AmpFlorian's Avatar
    AmpFlorian is offline I'm Back

    Array
    Join Date
    Jun 2009
    Location
    127.0.0.1
    Posts
    1,579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    12
    Reputation
    664
    Quote Originally Posted by GoDLiKe.ON3 View Post
    Thanks.
    I wrote this for learning purposes and i didn't see any source code for this tool.
    Oh, it might have been my imagination, I was thinking it had been awhile since I saw it anyways.. Unsure. Good work though.

Similar Threads

  1. Replies: 14
    Last Post: 05-21-2014, 05:18 AM
  2. [1.26] Minitool Game start notifier
    By hahahafr in forum Warcraft 3 Hacks, bots and tools
    Replies: 12
    Last Post: 07-17-2011, 11:26 PM
  3. Replies: 0
    Last Post: 12-14-2010, 06:16 AM
  4. Replies: 4
    Last Post: 04-22-2009, 12:30 PM
  5. Replies: 1
    Last Post: 09-04-2007, 01:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •