Skip to content

Game crashes when moving units #82

Description

@xezon

Game crashes when moving units in a certain way. I will not describe Repro Steps here.

GenTool fixes it by injecting naked function at address 0x5517C9 taking 7 bytes.

game.dat

// CPU Disasm (Zero Hour 1.04)
// Address   Hex dump              Command                                  Comments
// 005517C9  |.  F686 10010000 08  TEST BYTE PTR DS:[ESI+110],08
// 005517D0  |.  0F85 00030000     JNE 00551AD6
// 005517D6  |.  3BEF              CMP EBP,EDI
// 005517D8  |.  8B8E 64020000     MOV ECX,DWORD PTR DS:[ESI+264]
// 005517DE  |.  8B96 68020000     MOV EDX,DWORD PTR DS:[ESI+268]
// 005517E4  |.  8B9E 7C010000     MOV EBX,DWORD PTR DS:[ESI+17C]           crash, EBX is 0
// 005517EA  |.  894C24 38         MOV DWORD PTR SS:[ESP+38],ECX
// 005517EE  |.  895424 3C         MOV DWORD PTR SS:[ESP+3C],EDX
// 005517F2  |.  0F84 10030000     JE 00551B08

DWORD ccFixRet;

__declspec(naked) void CC_FixCrash_ZH()
{
	__asm pop [ccFixRet]
	__asm TEST BYTE PTR DS:[ESI+0x110],0x08
	__asm jne Continue
	__asm mov ebx,dword ptr ds:[esi+0x17C]
	__asm test ebx,ebx
	__asm je Abort
	__asm jmp Continue

Abort:
	__asm cmp ebx,1
	__asm push [ccFixRet]
	__asm ret

Continue:
	__asm TEST BYTE PTR DS:[ESI+0x110],0x08
	__asm push [ccFixRet]
	__asm ret
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working right, typically is user facingCriticalSeverity: Minor < Major < Critical < BlockerGenToolRelates to GenToolZHRelates to Zero Hour

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions