JNCreateUnitHook proc playerid:DWORD, unitid:DWORD, x:DWORD, y:DWORD
LOCAL buf[400h]:BYTE
pushad
GetBase
.if !(DWORD ptr RLC(dwStatus))
mov DWORD ptr RLC(dwStatus), 1
lea eax, RLC(T("欢迎使用Proton制作的 DotA“辅助”工具!"))
invoke DisplayText, eax, 10
.endif
.if !(DWORD ptr RLC(hTimer))
; 游戏开始了
lea eax, RLC(MainProc)
RLCInvoke SetTimer, 0, 0, 1000, eax
mov RLC(hTimer), eax
mov ecx, 1
GameCall PGetCurrentJassEnv
mov DWORD ptr RLC(dwLastJassEnv), eax
call AddNativeHooks
.endif
mov eax, unitid
.if eax == 'n00L'
lea eax, RLC(T("肉山大魔王又复活啦!!!"))
invoke DisplayText, eax, 10
jmp _end
.endif
_end:
;因为这个函数是通过DRx Hook住的,所以不能直接跳到原地址,否则会重复触发
Hook的
popad
leave
GetBase eax
push ecx
push esi
GetGameAddr 6F3B3430h, eax, eax
call eax
GetBase eax
GetGameAddr JNCreateUnit+07h, eax, eax
jmp eax
JNCreateUnitHook endp
;在小地图上发信号的函数,只是简单的封装
PingMiniMapEx proc uses ebx x:DWORD, y:DWORD, duration:DWORD, color:DWORD,
extraEffects:DWORD
;native PingMinimapEx takes real x, real y, real duration, integer red, integer
green, integer blue, boolean extraEffects returns nothing
push extraEffects
mov edx, color
mov eax, edx
and eax, 0ffh
push eax ; blue
mov eax, edx
shr eax, 8
and eax, 0ffh
push eax ; green
mov eax, edx
shr eax, 16
and eax, 0ffh
push eax ; red
lea eax, duration
push eax
lea eax, y
push eax
lea eax, x
push eax
GetBase
GameCall JNPingMinimapEx
add esp, 28
ret
PingMiniMapEx endp
;根据dwHeroIds中的 unit值,在小地图上提示,上文的MainProc函数调用的
PingHeros proc
pushad
GetBase
lea esi, RLC(dwHeroIds)
.while 1
mov eax, [esi]
.break .if !eax
mov edi, eax
GameCall JNGetLocalPlayer
push eax
push DWORD ptr [esi]
GameCall JNIsUnitVisible
not eax
add esp, 8
mov edi, eax
push 0 ; life
push DWORD ptr [esi]
GameCall JNGetUnitState
add esp, 8
push eax
fld DWORD ptr [esp]
pop eax
ftst
fstsw ax
sahf
setg al
movzx eax, al
fstp st
and edi, eax ; !IsUnitVisible and GetUnitState(life) > 0
.if edi
push DWORD ptr [esi]
GameCall JNGetOwningPlayer
pop edx
push eax
GameCall JNGetPlayerColor
pop edx
mov eax, DWORD ptr RLC(dwColors)[4*eax]
push 0 ; extraEffects
push eax ; color
push 3F000000h ; duration, float 0.5
push DWORD ptr [esi] ; unit id
GameCall JNGetUnitY
mov edi, eax
GameCall JNGetUnitX
mov edx, eax
pop eax
push edi ; y
push edx ; x
call PingMiniMapEx
.endif
add esi, 4
.endw
popad
ret
PingHeros endp
;用来初始化外挂状态
PInitNativesHook proc
pushad
GetBase
lea eax, RLC(dwHeroIds)
RLCInvoke RtlZeroMemory, eax, sizeof dwHeroIds
.if DWORD ptr RLC(hTimer)
RLCInvoke KillTimer, 0, RLC(hTimer)
mov DWORD ptr RLC(dwStatus), 0
mov DWORD ptr RLC(hTimer), 0
.endif
push_offset_RLC @F
GameCall 6F454710h ; hook overwritten code
GetGameAddr 6F95D93Ch
push eax
GetGameAddr PInitNatives+0Ah
jmp eax
@@:
call AddNativeHooks
popad
ret
PInitNativesHook endp |