So I'm about 90% complete w/my reversing on isOutdoors (you just pass the baseAddress of the object), but I'm running into one tiny snag, and I think it's just due to my understanding.
This function passes &v5 as the key, which obviously isn't defined in the below code (but it's stated the value is [stack pointer+24h]. Can someone shed some light on this?
Code:
void *__cdecl GetWMOAreaRec(int a1, int a2, int a3)
{
int v3; // ecx@1
char v5; // [sp+24h] [bp-44h]@3
int v6; // [sp+28h] [bp-40h]@1
int v7; // [sp+2Ch] [bp-3Ch]@1
int v8; // [sp+30h] [bp-38h]@1
v3 = 0;
v6 = a1;
v7 = a2;
v8 = a3;
if ( g_WMOAreaTableDB.numRows > 0 )
v3 = g_WMOAreaTableDB.FirstRow;
return bsearch(&v5, (const void *)v3, g_WMOAreaTableDB.numRows, 0x3Cu, BattleNetLogin__vFunc48);
}
I understand the concept of pushing values on the stack, but I'm a bit confused as to how the key was pushed on the stack in the first place. if I move up the call chain, I go from:
- GetWMOAreaRec(int a1, int a2, int a3)
- CWorldMap__QueryOutdoors(int a1)
- World__QueryOutdoors(int a1)
How is this actually set? Sooo close to having this done OOP. Can it not be done?
Thanks!
Note: The function names are from the mac build 13850 (all function names are given)
PS. If you want to see everything I've done, it's here: [Objective C] int CMapObj__GetGroup(int a1, int a2, int a3){ log(LOG_MEMORY, @" CMapObj__G - Pastebin.com
Edit: And the assembly (Note: addresses are from the 4.0.6 binary and off_12635A4 is a pointer to g_WMOAreaTableDB):
Code:
__text:002541B0 GetWMOAreaRec proc near ; CODE XREF: sub_AEF700+8Dp
__text:002541B0 ; sub_AEF7B0+7Dp ...
__text:002541B0
__text:002541B0 var_44 = byte ptr -44h
__text:002541B0 var_40 = dword ptr -40h
__text:002541B0 var_3C = dword ptr -3Ch
__text:002541B0 var_38 = dword ptr -38h
__text:002541B0 arg_0 = dword ptr 8
__text:002541B0 arg_4 = dword ptr 0Ch
__text:002541B0 arg_8 = dword ptr 10h
__text:002541B0
__text:002541B0 55 push ebp
__text:002541B1 31 C9 xor ecx, ecx
__text:002541B3 89 E5 mov ebp, esp
__text:002541B5 83 EC 68 sub esp, 68h
__text:002541B8 8B 15 A4 35 26 01 mov edx, ds:off_12635A4
__text:002541BE 8B 45 08 mov eax, [ebp+arg_0]
__text:002541C1 89 45 C0 mov [ebp+var_40], eax
__text:002541C4 8B 45 0C mov eax, [ebp+arg_4]
__text:002541C7 89 45 C4 mov [ebp+var_3C], eax
__text:002541CA 8B 45 10 mov eax, [ebp+arg_8]
__text:002541CD 89 45 C8 mov [ebp+var_38], eax
__text:002541D0 8B 42 04 mov eax, [edx+4]
__text:002541D3 85 C0 test eax, eax
__text:002541D5 7E 03 jle short loc_2541DA
__text:002541D7 8B 4A 14 mov ecx, [edx+14h]
__text:002541DA
__text:002541DA loc_2541DA: ; CODE XREF: GetWMOAreaRec+25j
__text:002541DA 89 44 24 08 mov [esp+8], eax ; size_t
__text:002541DE 8D 45 BC lea eax, [ebp+var_44]
__text:002541E1 C7 44 24 10 80 41 25 00 mov dword ptr [esp+10h], offset BattleNetLogin__vFunc48 ; int (*)(const void *, const void *)
__text:002541E9 C7 44 24 0C 3C 00 00 00 mov dword ptr [esp+0Ch], 3Ch ; size_t
__text:002541F1 89 4C 24 04 mov [esp+4], ecx ; void *
__text:002541F5 89 04 24 mov [esp], eax ; void *
__text:002541F8 E8 CC 1E 01 01 call _bsearch
__text:002541FD C9 leave
__text:002541FE C3 retn
__text:002541FE GetWMOAreaRec endp