Skip to content

Help with a new GUI Element Hook #9

@WizzardMaker

Description

@WizzardMaker

I want to hook a new function, that draws the GUI Elements (as defined in the Menu/GUISetXXX.DAT files)

.text:0027240D                 mov     edx, [esp+508h+objectA] ; objectA (?)
.text:00272411                 mov     ecx, [esp+508h+objectB] ; objectB (?)
.text:00272415                 push    ebx             ; guiElement 
.text:00272416                 push    eax             ; surfaceHeight
.text:00272417                 movzx   eax, word ptr [esi+6] ; Move with Zero-Extend
.text:0027241B                 push    eax             ; surfaceWidth
.text:0027241C                 call    DrawGUIElement  ; <-- this function needs the hook (Original Address is 0x272600)
.text:00272421                 movzx   eax, byte ptr [ebx+18h] ; Move with Zero-Extend
.text:00272425                 add     esp, 0Ch        ; Add
.text:00272428                 add     eax, 0FFFFFFFCh ; switch 18 cases

But I can't quite figure out how to implement a hook in the style of the S4ModApi. Could you help me with that?

[The game does not render any GUI Elements when nop'ing that function call: ]
image

For reference, ebx points to the GUI Element

A GUI Element looks like this:

struct GUIElement
{
  WORD x;
  WORD y;
  WORD width;
  WORD height;
  WORD mainTexture;
  WORD valueLink;
  WORD unknown;
  WORD buttonPressedTexture;
  WORD unknown1;
  WORD unknown2;
  WORD tooltipLink;
  WORD tooltipLinkExtra;
  WORD currentEffects; //enum where the first 4 bits define which font style to use and last 4 bits define effects (Like pressed etc)
  WORD unknownData[5]
  //sizeof == 36
};

And what would be the easiest way to get the value of a static address?
The current .gfx file of the GUI Engine is located at [S4_Main.exe+0xE94814]+0xC98 - how should I retrieve that value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions