Quantcast
Channel: D3Scene
Viewing all articles
Browse latest Browse all 21080

[Help] Convert from structure Unit to Unit handle

$
0
0
I have this code,
Code:

UINT hUnit = ...;
GetUnitName(hUnit);  // It works fine
char* GetUnitName(UINT hUnit)
{
    char* retaddr = "No Unit";

    __asm
    {
        mov ecx, hUnit;
        mov eax, GameDll;
        lea eax, dword ptr ds:[eax + 0x3BDCB0];
        call eax;
        test eax,eax
        je NoUnit;
       
        mov ecx,[eax + 0x30]
        xor edx,edx
        mov eax, GameDll;
        lea eax, dword ptr ds:[eax + 0x32DBE0];
        call eax
        mov retaddr, eax;
NoUnit:
    }
    return retaddr;
}

but when I pass structure Unit to the function, wc3 crash or it return "No Unit"
Code:

struct Unit
{
    DWORD dwDummy[3];
    DWORD dwID1;
    DWORD dwID2;
    BYTE _1[0x1C];
    DWORD dwClassId;
    BYTE _2[0x1C];
    DWORD HealthBar;
    DWORD UNK;
    DWORD dwOwnerSlot;
};

Unit* unit = ..;
GetUnitName((DWORD)unit); // return "No Unit"

// Or I change from char* GetUnitName(UINT hUnit) to char* GetUnitName(Unit* hUnit)
GetUnitName(unit); // WC3 crash...

Can anyone help me?

Viewing all articles
Browse latest Browse all 21080

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>