Code:
void GetActualGraphicEngine()
{
int actualGraphicEngine = *(int*)Address::GRAPHIC_ENGINE_MODE_ADDR;
switch(actualGraphicEngine)
{
case 0:
DrawRectAddress = Address::DRAW_RECT_DX5_FUNC_ADDR;
break;
case 1:
DrawRectAddress = Address::DRAW_RECT_OGL_FUNC_ADDR;
break;
case 2:
DrawRectAddress = Address::DRAW_RECT_DX9_FUNC_ADDR;
break;
}
}
DWORD PrepareDrawRectAddress = Address::PREPARE_DRAW_RECT_FUNC_ADDR;
void DrawRectangle(int nSurface, int X, int Y, int W, int H, int nRed, int nGreen, int nBlue)
{
asm("mov %0, %%eax": /*no output opperand*/ : "r" (PrepareDrawRectAddress)); //We call the function that will prepare the registers for the DrawRect function
asm("call *%eax");
asm("mov %%eax, %%ecx": /*no output opperand*/ : /*no input operand*/ : "%ecx" /*we tell the compiler not to touch ecx anymore!*/);
asm("push %0": /*no output opperand*/ : "g" (nBlue)); //We push all the parameters
asm("push %0": /*no output opperand*/ : "g" (nGreen));
asm("push %0": /*no output opperand*/ : "g" (nRed));
asm("push %0": /*no output opperand*/ : "g" (H));
asm("push %0": /*no output opperand*/ : "g" (W));
asm("push %0": /*no output opperand*/ : "g" (Y));
asm("push %0": /*no output opperand*/ : "g" (X));
asm("push %0": /*no output opperand*/ : "g" (nSurface));
asm("mov %0, %%eax": /*no output opperand*/ : "r" (DrawRectAddress)); //We call the DrawRect function
asm("call *%eax");
}
void DrawRect(int nSurface, int X, int Y, int W, int H, int nRed, int nGreen, int nBlue) //Thanks to DarkStar and Farsa for the DrawRect Function
{
GetActualGraphicEngine();
DrawRectangle(nSurface, X, Y, W, H, nRed, nGreen, nBlue);
}
void __stdcall DrawBlackBarPatched(int nSurface, int X, int Y, int W, int H, int nRed, int nGreen, int nBlue)
{
asm("movl %SS:-130(%ebp),%ecx");
DWORD creaturePointer = *(DWORD*)Address::CURRENT_HP_BAR_DRAWING_CREATURE;
DWORD creatureID = *(DWORD*)(creaturePointer);
if(SendDlgItemMessage(mainWindow, IDC_MANABAR, BM_GETCHECK, 0, 0) == BST_CHECKED)
{
if(player.getID() == creatureID)
DrawRect(nSurface, X, Y-6, W, H, nRed, nGreen, nBlue);
}
DrawRect(nSurface, X, Y, W, H, nRed, nGreen, nBlue);
}
void __stdcall DrawColorBarPatched(int nSurface, int X, int Y, int W, int H, int nRed, int nGreen, int nBlue)
{
asm("movl %SS:-0x19C(%ebp),%ecx");
DWORD creaturePointer = *(DWORD*)Address::CURRENT_HP_BAR_DRAWING_CREATURE;
DWORD creatureID = *(DWORD*)creaturePointer;
DrawRect(nSurface, X, Y, W, H, nRed, nGreen, nBlue);
if(SendDlgItemMessage(mainWindow, IDC_MANABAR, BM_GETCHECK, 0, 0) == BST_CHECKED)
{
if(player.getID() == creatureID)
{
DrawRect(nSurface, X, Y, W, H, 0, 0, 0);
DrawRect(nSurface, X, Y-6, W, H, nRed, nGreen, nBlue);
DWORD width = (25 * player.getMP()) / player.getMPMax();
DWORD percent = (100 * player.getMP()) / player.getMPMax();
if(percent >= 80)
DrawRect(nSurface, X, Y, width, H, 39, 64, 139);
else if(percent >= 60 && percent < 80)
DrawRect(nSurface, X, Y, width, H, 58, 95, 205);
else if(percent >= 40 && percent < 60)
DrawRect(nSurface, X, Y, width, H, 72, 118, 255);
else if(percent < 40)
DrawRect(nSurface, X, Y, width, H, 100, 149, 237);
}
}
}
I don't know well ASM to find what's going on.