Code:
;~ Description: Injects GWA˛ into the game client.
Func Initialize($aGW, $bChangeTitle = True, $aUseStringLog = False, $aUseEventSystem = True)
Local $lWinList, $lWinList2, $mGWProcessId
$mUseStringLog = $aUseStringLog
$mUseEventSystem = $aUseEventSystem
If IsString($aGW) Then
Local $lProcessList = ProcessList("gw.exe")
For $i = 1 To $lProcessList[0][0]
$mGWProcessId = $lProcessList[$i][1]
$mGWWindowHandle = GetHwnd($mGWProcessId)
MemoryOpen($mGWProcessId)
If $mGWProcHandle Then
If StringRegExp(ScanForCharname(), $aGW) = 1 Then ExitLoop
EndIf
MemoryClose()
$mGWProcHandle = 0
Next
Else
$mGWProcessId = $aGW
$mGWWindowHandle = GetHwnd($mGWProcessId)
MemoryOpen($aGW)
ScanForCharname()
EndIf
If $mGWProcHandle = 0 Then Return 0
Scan()
Local $lTemp
$mBasePointer = MemoryRead(GetScannedAddress('ScanBasePointer', 8)) ;-3
SetValue('BasePointer', '0x' & Hex($mBasePointer, 8))
$mAgentBase = GetScannedAddress('ScanAgentBase', -15) + 0x1E
$mAgentBase = $mAgentBase + MemoryRead($mAgentBase) + 4
$mAgentBase += 0x13
$mAgentBase = MemoryRead($mAgentBase)
SetValue('AgentBase', '0x' & Hex($mAgentBase, 8))
$mMaxAgents = $mAgentBase + 8
SetValue('MaxAgents', '0x' & Hex($mMaxAgents, 8))
$mMyID = MemoryRead(GetScannedAddress('ScanMyID', -3));$mMyID = $mAgentBase - 84
SetValue('MyID', '0x' & Hex($mMyID, 8))
$mCurrentTarget = MemoryRead(GetScannedAddress('ScanCurrentTarget', -14)) ;$mAgentBase - 1280
SetValue('PacketLocation', '0x' & Hex(MemoryRead(GetScannedAddress('ScanBaseOffset', 11)), 8))
$mPing = MemoryRead(GetScannedAddress('ScanPing', -8))
$mMapID = MemoryRead(GetScannedAddress('ScanMapID', 28))
$mMapLoading = MemoryRead(GetScannedAddress('ScanMapLoading', 44))
$mLoggedIn = MemoryRead(GetScannedAddress('ScanLoggedIn', -3)) - 0x198
$mLanguage = MemoryRead(GetScannedAddress('ScanMapInfo', 11)) + 0xC
$mRegion = $mLanguage + 4
$mSkillBase = MemoryRead(GetScannedAddress('ScanSkillBase', 8))
$mSkillTimer = MemoryRead(GetScannedAddress('ScanSkillTimer', -3))
$lTemp = GetScannedAddress('ScanBuildNumber', 0x2C)
$mBuildNumber = MemoryRead($lTemp + MemoryRead($lTemp) + 5)
$mZoomStill = GetScannedAddress("ScanZoomStill", 0x33)
$mZoomMoving = GetScannedAddress("ScanZoomMoving", 0x21)
$mCurrentStatus = MemoryRead(GetScannedAddress('ScanChangeStatusFunction', 35))
$lTemp = GetScannedAddress('ScanEngine', -0x6E) ;-16
SetValue('MainStart', '0x' & Hex($lTemp, 8))
SetValue('MainReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanRenderFunc', -0x67)
SetValue('RenderingMod', '0x' & Hex($lTemp, 8))
SetValue('RenderingModReturn', '0x' & Hex($lTemp + 10, 8))
$lTemp = GetScannedAddress('ScanTargetLog', 1)
SetValue('TargetLogStart', '0x' & Hex($lTemp, 8))
SetValue('TargetLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillLog', 1)
SetValue('SkillLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillCompleteLog', -4)
SetValue('SkillCompleteLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillCompleteLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanSkillCancelLog', 5)
SetValue('SkillCancelLogStart', '0x' & Hex($lTemp, 8))
SetValue('SkillCancelLogReturn', '0x' & Hex($lTemp + 6, 8))
$lTemp = GetScannedAddress('ScanChatLog', 18)
SetValue('ChatLogStart', '0x' & Hex($lTemp, 8))
SetValue('ChatLogReturn', '0x' & Hex($lTemp + 6, 8))
$lTemp = GetScannedAddress('ScanTraderHook', -7)
SetValue('TraderHookStart', '0x' & Hex($lTemp, 8))
SetValue('TraderHookReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanDialogLog', -4)
SetValue('DialogLogStart', '0x' & Hex($lTemp, 8))
SetValue('DialogLogReturn', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanStringFilter1', -5); was -0x23
SetValue('StringFilter1Start', '0x' & Hex($lTemp, 8))
SetValue('StringFilter1Return', '0x' & Hex($lTemp + 5, 8))
$lTemp = GetScannedAddress('ScanStringFilter2', 0x16); was 0x61
SetValue('StringFilter2Start', '0x' & Hex($lTemp, 8))
SetValue('StringFilter2Return', '0x' & Hex($lTemp + 5, 8))
SetValue('StringLogStart', '0x' & Hex(GetScannedAddress('ScanStringLog', 0x16), 8))
SetValue('LoadFinishedStart', '0x' & Hex(GetScannedAddress('ScanLoadFinished', 1), 8))
SetValue('LoadFinishedReturn', '0x' & Hex(GetScannedAddress('ScanLoadFinished', 6), 8))
SetValue('PostMessage', '0x' & Hex(MemoryRead(GetScannedAddress('ScanPostMessage', 11)), 8))
SetValue('Sleep', MemoryRead(MemoryRead(GetValue('ScanSleep') + 8) + 3))
SetValue('SalvageFunction', MemoryRead(GetValue('ScanSalvageFunction') + 8) - 18)
SetValue('SalvageGlobal', MemoryRead(MemoryRead(GetValue('ScanSalvageGlobal') + 8) + 1))
SetValue('IncreaseAttributeFunction', '0x' & Hex(GetScannedAddress('ScanIncreaseAttributeFunction', -0x5A), 8))
SetValue("DecreaseAttributeFunction", "0x" & Hex(GetScannedAddress("ScanDecreaseAttributeFunction", 25), 8))
SetValue('MoveFunction', '0x' & Hex(GetScannedAddress('ScanMoveFunction', 1), 8))
SetValue('UseSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseSkillFunction', -0x125), 8))
SetValue('ChangeTargetFunction', '0x' & Hex(GetScannedAddress('ScanChangeTargetFunction', -15), 8))
SetValue('WriteChatFunction', '0x' & Hex(GetScannedAddress('ScanWriteChatFunction', -0x3D), 8))
SetValue('SellItemFunction', '0x' & Hex(GetScannedAddress('ScanSellItemFunction', -85), 8))
SetValue('PacketSendFunction', '0x' & Hex(GetScannedAddress('ScanPacketSendFunction', -0xC2), 8))
SetValue('ActionBase', '0x' & Hex(MemoryRead(GetScannedAddress('ScanActionBase', -3)), 8))
SetValue('ActionFunction', '0x' & Hex(GetScannedAddress('ScanActionFunction', -3), 8))
SetValue('UseHeroSkillFunction', '0x' & Hex(GetScannedAddress('ScanUseHeroSkillFunction', -0xA1), 8))
SetValue('BuyItemBase', '0x' & Hex(MemoryRead(GetScannedAddress('ScanBuyItemBase', 15)), 8))
SetValue('TransactionFunction', '0x' & Hex(GetScannedAddress('ScanTransactionFunction', -0x7E), 8))
SetValue('RequestQuoteFunction', '0x' & Hex(GetScannedAddress('ScanRequestQuoteFunction', -0x34), 8)) ;-2
SetValue('TraderFunction', '0x' & Hex(GetScannedAddress('ScanTraderFunction', -71), 8))
SetValue('ClickToMoveFix', '0x' & Hex(GetScannedAddress("ScanClickToMoveFix", 1), 8))
SetValue('ChangeStatusFunction', '0x' & Hex(GetScannedAddress("ScanChangeStatusFunction", 1), 8))
SetValue('QueueSize', '0x00000010')
SetValue('SkillLogSize', '0x00000010')
SetValue('ChatLogSize', '0x00000010')
SetValue('TargetLogSize', '0x00000200')
SetValue('StringLogSize', '0x00000200')
SetValue('CallbackEvent', '0x00000501')
$MTradeHackAddress = GetScannedAddress("ScanTradeHack", 0)
ModifyMemory()
$mQueueCounter = MemoryRead(GetValue('QueueCounter'))
$mQueueSize = GetValue('QueueSize') - 1
$mQueueBase = GetValue('QueueBase')
$mTargetLogBase = GetValue('TargetLogBase')
$mStringLogBase = GetValue('StringLogBase')
$mMapIsLoaded = GetValue('MapIsLoaded')
$mEnsureEnglish = GetValue('EnsureEnglish')
$mTraderQuoteID = GetValue('TraderQuoteID')
$mTraderCostID = GetValue('TraderCostID')
$mTraderCostValue = GetValue('TraderCostValue')
$mDisableRendering = GetValue('DisableRendering')
$mAgentCopyCount = GetValue('AgentCopyCount')
$mAgentCopyBase = GetValue('AgentCopyBase')
$mLastDialogID = GetValue('LastDialogID')
If $mUseEventSystem Then MemoryWrite(GetValue('CallbackHandle'), $mGUI)
DllStructSetData($mInviteGuild, 1, GetValue('CommandPacketSend'))
DllStructSetData($mInviteGuild, 2, 0x4C)
DllStructSetData($mUseSkill, 1, GetValue('CommandUseSkill'))
DllStructSetData($mMove, 1, GetValue('CommandMove'))
DllStructSetData($mChangeTarget, 1, GetValue('CommandChangeTarget'))
DllStructSetData($mPacket, 1, GetValue('CommandPacketSend'))
DllStructSetData($mSellItem, 1, GetValue('CommandSellItem'))
DllStructSetData($mAction, 1, GetValue('CommandAction'))
DllStructSetData($mToggleLanguage, 1, GetValue('CommandToggleLanguage'))
DllStructSetData($mUseHeroSkill, 1, GetValue('CommandUseHeroSkill'))
DllStructSetData($mBuyItem, 1, GetValue('CommandBuyItem'))
DllStructSetData($mSendChat, 1, GetValue('CommandSendChat'))
DllStructSetData($mSendChat, 2, $HEADER_SEND_CHAT)
DllStructSetData($mWriteChat, 1, GetValue('CommandWriteChat'))
DllStructSetData($mRequestQuote, 1, GetValue('CommandRequestQuote'))
DllStructSetData($mRequestQuoteSell, 1, GetValue('CommandRequestQuoteSell'))
DllStructSetData($mTraderBuy, 1, GetValue('CommandTraderBuy'))
DllStructSetData($mTraderSell, 1, GetValue('CommandTraderSell'))
DllStructSetData($mSalvage, 1, GetValue('CommandSalvage'))
DllStructSetData($mIncreaseAttribute, 1, GetValue('CommandIncreaseAttribute'))
DllStructSetData($mDecreaseAttribute, 1, GetValue('CommandDecreaseAttribute'))
DllStructSetData($mMakeAgentArray, 1, GetValue('CommandMakeAgentArray'))
DllStructSetData($mChangeStatus, 1, GetValue('CommandChangeStatus'))
If $bChangeTitle Then WinSetTitle($mGWWindowHandle, '', 'Guild Wars - ' & GetCharname())
Return $mGWWindowHandle
EndFunc ;==>Initialize
I have tried using it either inside an EventHandler func or in the beginning of the script. Any time the script tries to inject, it crashes my GW client. The character name functions seem to work OK as the correct names appear in my gui, so perhaps it is something with the modifymemory() func...