Code:
;====================================================;
; Warcraft Source Module (Hooks.inc) ;
;====================================================;
; This is where all of our memory hooks jump to, in ;
; appropriately crafted custom functions. This allows;
; us a lot of flexibility in manipulating various ;
; parts of the function while maintaining a low ;
; impact overall on Warcraft's address space. ;
;====================================================;
.code
;===================================;
; Main Map Hooks ;
;===================================;
mainmap_Draw proc
;//Remove main map fog of war.
.data
mainmap_Draw1 dd 6F40AA86h
.code
or ebx, 0000F000h
and ebx, esi
test bx, bx
je continue
mov ecx, dword ptr [ecx]
jmp dword ptr [mainmap_Draw1]
continue:
mov eax, dword ptr [eax+2Ch]
movzx edx, word ptr [eax+2*edx]
xor eax, eax
mov ax, si
and edx, 0FFFh
not edx
test eax, edx
je explored
mov ecx, dword ptr ds:[ecx+4]
jmp finish
explored:
mov ecx, dword ptr ds:[ecx+8]
finish:
mov cl, byte ptr ds:[ecx+6F833DB4h]
.if stateMap == 02h
xor ecx, ecx
.endif
jmp dword ptr [fxnMainmapRetn]
mainmap_Draw endp
mainmap_Players proc
;//View player vision limitations on main map.
mov esi, dword ptr [ebp-08h]
mov eax, dword ptr [esi+0000099Ch]
xor ecx, ecx
cmp eax, ecx
je continue
.if stateMap == 01h
mov dx, 0FFFh
.else
mov dx, word ptr ds:[eax+3Ch]
.endif
mov word ptr ss:[ebp-1Ch], dx
jmp finish
continue:
mov dword ptr ss:[ebp-1Ch], ecx
finish:
mov edx, dword ptr ds:[esi+9D0h]
xor eax, eax
jmp dword ptr [fxnMainmapPlayersRetn]
mainmap_Players endp
mainmap_Units proc
;//Reveal enemy and neutral units on main map.
mov dword ptr ss:[ebp-28h], eax
mov dword ptr ss:[ebp-24h], eax
mov dword ptr ss:[ebp-1Ch], eax
mov eax, dword ptr ds:[edx+14h]
mov edx, dword ptr ds:[edx+10h]
.if stateMap != 00h
xor eax, eax
xor edx, edx
.endif
lea edx, dword ptr ds:[edx+eax*2]
and ecx, edi
jmp dword ptr [fxnUnitsRetn]
mainmap_Units endp
mainmap_Invisible proc
;//Reveal invisible units on main map.
.data
mainmap_Invisible1 dd 6F2A3D30h
.code
mov edx, dword ptr ds:[edi+198h]
mov ecx, dword ptr ds:[edi+178h]
xor eax, eax
mov ax, word ptr ds:[edi+edx*2+218h]
.if stateMap != 00h
mov eax, 00000001h
.else
push 0
push eax
push esi
call dword ptr [mainmap_Invisible1]
.endif
and ebx, eax
jmp dword ptr [fxnInvisibleRetn]
mainmap_Invisible endp
mainmap_Footprints proc
;//Reveal unit footprints on main map.
mov dword ptr ss:[ebp-30h], edi
mov dword ptr ss:[ebp-18h], edi
mov edi, dword ptr ds:[eax+10h]
mov dword ptr ss:[ebp-1Ch], ecx
mov ecx, dword ptr ds:[eax+14h]
.if stateMap != 00h
xor edi, edi
xor ecx, ecx
.endif
lea ecx, dword ptr ds:[edi+ecx*2]
mov edi, dword ptr ds:[eax+30h]
jmp dword ptr [fxnFootprintsRetn]
mainmap_Footprints endp
mainmap_Specular proc
;//Reveal specular effects on main map.
mov dword ptr ss:[ebp-44h], ebx
mov dword ptr ss:[ebp-2Ch], ebx
mov ebx, dword ptr ss:[esi+10h]
mov dword ptr ss:[ebp-30h], edx
mov edx, dword ptr ds:[esi+14h]
.if stateMap != 00h
xor ebx, ebx
xor edx, edx
.endif
lea edx, dword ptr ds:[ebx+edx*2]
mov ebx, dword ptr ds:[esi+30h]
jmp dword ptr [fxnSpecularRetn]
mainmap_Specular endp
mainmap_Corpses proc
;//Reveal corpses on main map.
mov dword ptr ss:[ebp-40h], edx
mov dword ptr ss:[ebp-28h], edx
mov edx, dword ptr ds:[esi+10h]
mov dword ptr ss:[ebp-38h], eax
mov dword ptr ss:[ebp-34h], eax
mov dword ptr ss:[ebp-2Ch], eax
mov eax, dword ptr ds:[esi+14h]
.if stateMap != 00h
xor eax, eax
xor edx, edx
.endif
lea eax, dword ptr ds:[edx+eax*2]
mov edx, dword ptr ds:[esi+30h]
jmp dword ptr [fxnCorpsesRetn]
mainmap_Corpses endp
mainmap_StaticSprites proc
;//Reveal trees and static sprites on main map.
mov dword ptr ss:[ebp-28h], ebx
mov dword ptr ss:[ebp-24h], ebx
mov dword ptr ss:[ebp-1Ch], ebx
mov ebx, dword ptr ds:[ecx+14h]
mov ecx, dword ptr ds:[ecx+10h]
.if stateMap != 00h
xor ebx, ebx
xor ecx, ecx
.endif
lea ecx, dword ptr ds:[ecx+ebx*2]
and eax, edi
jmp dword ptr [fxnStaticSpritesRetn]
mainmap_StaticSprites endp
mainmap_Sound proc
;//Play out of range sounds on main map.
mov dword ptr ss:[ebp-38h], ecx
mov dword ptr ss:[ebp-34h], ecx
mov dword ptr ss:[ebp-30h], ecx
mov dword ptr ss:[ebp-2Ch], ecx
mov dword ptr ss:[ebp-28h], ecx
mov dword ptr ss:[ebp-20h], ecx
mov dword ptr ss:[ebp-14h], ecx
mov ecx, dword ptr ds:[esi+14h]
.if stateMap != 00h
xor ecx, ecx
xor edx, edx
.endif
lea ecx, dword ptr ds:[edx+ecx*2]
mov edx, dword ptr ds:[esi+30h]
add eax, edi
jmp dword ptr [fxnSoundRetn]
mainmap_Sound endp
mainmap_Blight proc
;//Reveal undead blight animation on main map.
sub eax, edx
xor edx, edx
shl edx, cl
mov ecx, dword ptr [esi+34h]
sar eax, 1
mov dword ptr [ebp-18h], esi
add edx, edi
mov edi, dword ptr [esi+30h]
lea edx, dword ptr [edx+edx+02h]
add ecx, edx
add edi, edx
mov edx, dword ptr ds:[esi+24h]
and edx, 1
mov dword ptr ss:[ebp-0Ch], ecx
mov dword ptr ss:[ebp-10h], edi
xor edx, edx
jmp dword ptr [fxnBlightRetn]
mainmap_Blight endp
mainmap_Illusions proc
;//Reveal Blademaster illusions on main map.
mov edx, 00000001h
shl edx, cl
pop edi
pop esi
and edx, eax
neg edx
sbb edx, edx
neg edx
mov eax, edx
inc eax
ret
mainmap_Illusions endp
mainmap_ShowRally proc
;//Show enemy building rally points on main map.
.data
mainmap_ShowRally1 dd 6F2A2E60h
mainmap_ShowRally2 dd 6F463051h
.code
push eax
mov ecx, esi
call dword ptr [mainmap_ShowRally1]
.if stateMap != 0
@skip:
jmp dword ptr [fxnShowRallyRetn]
.else
test eax, eax
jne @skip
jmp dword ptr [mainmap_ShowRally2]
.endif
mainmap_ShowRally endp
mainmap_PaidStructure proc
;//Reveal structure placement of unbuilt buildings.
.data
mainmap_PaidStructure1 dd 6F563D5Ch
mainmap_PaidStructure2 dd 6F1C2C60h
.code
call dword ptr [mainmap_PaidStructure2]
test eax, eax
je @skip
jmp dword ptr [fxnPaidStructureRetn]
@skip:
.if stateMap != 00h
jmp dword ptr [fxnPaidStructureRetn]
.else
jmp dword ptr [mainmap_PaidStructure1]
.endif
mainmap_PaidStructure endp
mainmap_Placement proc
;//Same as above.
.data
mainmap_Placement1 dd 6F15C60Ah
mainmap_Placement2 dd 6F1C2C60h
.code
mov ecx, edi
call dword ptr [mainmap_Placement2]
test eax, eax
je @skip
jmp dword ptr [fxnPlacementRetn]
@skip:
.if stateMap != 00h
jmp dword ptr [fxnPlacementRetn]
.else
jmp dword ptr [mainmap_Placement1]
.endif
mainmap_Placement endp
;===================================;
; Minimap Hooks ;
;===================================;
minimap_Draw proc
;//Remove fog of war on minimap.
mov ebx, dword ptr ds:[6F873334h]
mov esi, dword ptr ds:[ebx+34h]
mov eax, dword ptr ds:[esi+14h]
.if stateMap == 02h
xor ecx, ecx
xor eax, eax
.else
mov ecx, dword ptr ds:[esi+10]
.endif
test eax, eax
jmp dword ptr [fxnMinimapRetn]
minimap_Draw endp
minimap_Players proc
;//Show player vision limitations on minimap.
.data
minimap_Players1 dd 6F2A4080h
.code
mov edx, dword ptr [edi+00000228h]
mov ebx, dword ptr [edi+00000224h]
sub esi, ecx
mov ecx, dword ptr [ebp-30h]
sub ebx, edx
movzx edx, word ptr ds:[ecx+28h]
push edx
call dword ptr [minimap_Players1]
mov eax, dword ptr ss:[ebp-20h]
.if stateMap == 01h
mov cx, 0FFFh
.else
mov cx, word ptr ds:[eax+3Ch]
.endif
mov eax, dword ptr ds:[edi+218h]
mov word ptr ss:[ebp-28h], cx
jmp dword ptr [fxnMinimapPlayersRetn]
minimap_Players endp
minimap_Locations proc
;//Show shops and gold mines on minimap.
.data
minimap_Locations1 dd 6F148769h
minimap_Locations2 dd 6F293B00h
.code
call dword ptr [minimap_Locations2]
test eax, eax
jz continue
mov ecx, dword ptr [ebp-14h]
mov edx, dword ptr [ecx+24h]
and edx, 00000001h
cmp dl, 01h
jne continue
jmp dword ptr [minimap_Locations1]
continue:
lea ecx, dword ptr [edi+000000F0h]
call dword ptr [WC3FXN_Ownership]
test eax, eax
jne @End
xor ecx, ecx
@End:
jmp dword ptr [fxnLocationsRetn]
minimap_Locations endp
minimap_Ping proc
;//Show opponent pings on minimap.
.data
minimap_Ping1 dd 6F088E10h
minimap_Ping2 dd 6F325ECAh
minimap_Ping3 dd 6F325E4Bh
minimap_Ping4 dd 6F2A2C70h
.code
push eax
push ecx
mov ecx, esi
call dword ptr [minimap_Ping4]
test eax, eax
je @continue
jmp dword ptr [minimap_Ping3]
@continue:
lea ecx, dword ptr ds:[edi+0F0h]
call dword ptr [minimap_Ping1]
cmp eax, eax
jz continue
jmp dword ptr [minimap_Ping2]
continue:
xor edx, edx
mov ecx, 1
jmp dword ptr [fxnMinimapPingRetn]
minimap_Ping endp
;===================================;
; Selection Hooks ;
;===================================;
select_EnemySelect proc
;//Allow selection of enemy units.
.data
select_EnemySelect1 dd 6F088E10h
.code
mov edx, dword ptr [ebp-08h]
lea ecx, dword ptr [edx+000000F0h]
call dword ptr [select_EnemySelect1]
push 0
mov eax, dword ptr ss:[ebp+0Ch]
push eax
push edi
mov edi, dword ptr ss:[ebp-04h]
push edi
mov ecx, esi
call dword ptr [WC3FXN_Select]
jmp dword ptr [fxnSelectRetn]
select_EnemySelect endp
select_ShowResources proc
;//Show resources of enemies in the unit HUD.
.data
select_ShowResources1 dd 6F3186F0h
select_ShowResources2 dd 6F088E10h
select_ShowResources3 dd 6F1B8770h
.code
mov ecx, dword ptr [esi+00000124h]
mov dword ptr [ebp-08h], eax
call dword ptr [select_ShowResources3]
mov edi, eax
mov ecx, edi
call dword ptr [select_ShowResources1]
mov ecx, dword ptr [ebp-08h]
movzx edx, byte ptr [ecx+30h]
lea ecx, dword ptr [eax+00000088h]
mov dword ptr [ebp-10h], edx
call dword ptr [select_ShowResources2]
mov ecx, dword ptr [ebp-10h]
mov edx, 00000001h
shl edx, cl
jmp dword ptr [fxnShowResourcesRetn]
select_ShowResources endp
select_ShowHealth proc
;//Permanently display health bars.
.data
select_ShowHealth1 dd 6F081330h
.code
mov edx, 6F17D770h
mov ecx, eax
call dword ptr [select_ShowHealth1]
mov ecx, 00000002h
call dword ptr [WC3FXN_War3D2]
mov edi, eax
cmp edi, ebx
jne @Show1
mov ecx, 00000112h
call dword ptr [WC3FXN_War3D2]
.if stateHealth == 01h
mov eax, 00000001h
.else
test eax, eax
je @NoShow1
@Show1:
mov eax, 00000001h
.endif
@NoShow1:
cmp edi, ebx
mov dword ptr [esi+00000180h], eax
jne @Show2
mov ecx, 00000113h
call dword ptr [WC3FXN_War3D2]
.if stateHealth == 01h
mov eax, 00000001h
.else
test eax, eax
je @End
@Show2:
mov eax, 00000001h
.endif
@End:
jmp dword ptr [fxnShowHealthRetn]
select_ShowHealth endp
select_ShowCooldowns proc
;//Reveal enemy cooldowns.
pop esi
mov eax, 1
ret
select_ShowCooldowns endp
select_ShowSkills1 proc
;//Show hero skills.
call dword ptr [WC3FXN_DrawIcon]
jmp dword ptr [fxnShowSkills1Retn]
select_ShowSkills1 endp
select_ShowSkills2 proc
call dword ptr [WC3FXN_DrawIcon]
jmp dword ptr [fxnShowSkills2Retn]
select_ShowSkills2 endp
select_HeroPortraits proc
;//Displays allied hero portraits in the top left.
.data
select_HeroPortraits1 dd 6F137EB4h
select_HeroPortraits2 dd 6F137BE1h
select_HeroPortraits3 dd 6F2A2C70h
select_HeroPortraits4 dd 6F2A2E60h
.code
mov eax, dword ptr [ebp-1Ch]
mov ecx, dword ptr [ebp+08h]
mov edx, dword ptr [ecx]
push eax
call dword ptr [edx+000000ECh]
mov ecx, dword ptr [ebp-20h]
push eax
.if stateMap == 02h
call dword ptr [select_HeroPortraits3]
test eax, eax
jne @skip
jmp dword ptr [select_HeroPortraits1]
@skip:
jmp dword ptr [select_HeroPortraits2]
.else
call dword ptr [select_HeroPortraits4]
test eax, eax
jne @end
jmp dword ptr [select_HeroPortraits1]
@end:
jmp dword ptr [fxnHeroPortraitsRetn]
.endif
select_HeroPortraits endp