Hooking glColor3f proc of Items on Map floor
Well, I made 1 form of hooking main.exe glColor3f proc's call for create Unique colors on Items Name text on the Map Floor, this can be used for make new Items states on client side (like excellent, divine, socket, ancient, etc)... well I like share with Rz Comunity.
all offsets are for 1.03.15 eng main.exe
Item.cpp:
Code:
#include "Stdafx.h"
#include "Utils.h"
#include "Item.h"
void __declspec(naked) gObjItemNameColor3f()
{
_asm
{
CMP EAX,ITEM2(12, 60) //Seed (Fire)
JL Exit
CMP EAX,ITEM2(12, 65) //Seed (Earth)
JLE Set_Socket
CMP EAX,ITEM2(12, 70) //Sphere (Mono)
JL Exit
CMP EAX,ITEM2(12, 74) //Sphere (Penta)
JLE Set_Socket
CMP EAX,ITEM2(12, 100) //Seed Sphere (Fire) [Level: 1]
JL Exit
CMP EAX,ITEM2(12, 129) //Seed Sphere (Earth) [Level: 5]
JLE Set_Socket
// ---
CMP EAX,ITEM2(14, 170) //Crystal Feather (this is added by me, but you can put any item of: 12, 13 and 14 types)
JE Set_Add_New
Set_Socket:
PUSH 0x3F800000
PUSH 0x3ECCCCCD
PUSH 0x3F333333
CALL DWORD PTR DS:[0x88D3C0] // CALL DWORD PTR DS:[<&OPENGL32.glColor3f>]
MOV EAX,DWORD PTR DS:[ESI+0x30]
SUB EAX,0x341
LEA ECX,[EAX*0x8]
SUB ECX,EAX
LEA EDX,[ECX+ECX*0x2]
MOV ItemColorNameFloor_Buff, 0x0059D4AD
JMP ItemColorNameFloor_Buff
Set_Add_New:
PUSH 0x3F308312 //Blue
PUSH 0x3F1E147B //Green
PUSH 0x3F733333 //Red
CALL DWORD PTR DS:[0x88D3C0] // CALL DWORD PTR DS:[<&OPENGL32.glColor3f>]
MOV EAX,DWORD PTR DS:[ESI+0x30]
SUB EAX,0x341
LEA ECX,[EAX*0x8]
SUB ECX,EAX
LEA EDX,[ECX+ECX*0x2]
MOV ItemColorNameFloor_Buff, 0x0059D4AD
JMP ItemColorNameFloor_Buff
Exit:
MOV ItemColorNameFloor_Buff, 0x0059D4DE //return case of switch
JMP ItemColorNameFloor_Buff
}
}
void cItemNameColor3f()
{
Utils.SetRange((LPVOID)0x0059D45D, 29, ASM::NOP);
Utils.SetJmp((LPVOID)0x0059D45D, gObjItemNameColor3f);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
{
cItemNameColor3f();
}
break;
case DLL_PROCESS_DETACH:
{
}
break;
}
return true;
}
Re: Hooking glColor3f proc of Items on Map floor
wow, too much work just to change font color.
:scared:
Re: Hooking glColor3f proc of Items on Map floor
Quote:
Originally Posted by
GM-Andromeda
wow, too much work just to change font color.
:scared:
yes, maybe.. but in this form is more easy to understand for me :): (asm re-write main.exe code is more easy, that decompile with ida and re-construct code xD for me).
Re: Hooking glColor3f proc of Items on Map floor
my function in 1.02c main season 2.
Code:
float RR = 0.0f;
float GG = 0.0f;
float BB = 0.0f;
__declspec(naked) void gObjItemColorDrop()
{
_asm
{
mov item_ID, ax
}
if(item_ID == ITEM_GET(14,13)) // jewel of bless
{
RR = 1.000000f;
GG = 0.800000f;
BB = 0.100000f;
}
else if(item_ID == ITEM_GET(14,63)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,64)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,65)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,66)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,67)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,68)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,69)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
//add new items
else
{
_asm // return function
{
mov edx, 0x00606456
jmp edx
}
}
_asm // função das cores
{
mov edx,dword ptr ds:[0x5841E44]
mov eax,dword ptr ds:[0x5841DD8]
push edx
push eax
call ebx
push BB
push GG
push RR
call dword ptr ds:[0x78337C]
mov edx, 0x006075B2
jmp edx
}
}
hook:
hook_extended(0x0060644C, (DWORD)(&gObjItemColorDrop));
func_nop(0x0060644C+5, 5);
Re: Hooking glColor3f proc of Items on Map floor
Here pobrinho form adapted source for works on: 1.03.15 eng
Code:
#define ITEM_INTER 833
#define ITEM(x, y) ((x * 512) + y)
#define ITEM2(x, y) ((x * 512) + y + ITEM_INTER)
float RR = 0.0f;
float GG = 0.0f;
float BB = 0.0f;
void __declspec(naked) gObjItemColorDrop()
{
_asm
{
mov dwItem, eax
}
if(dwItem == ITEM2(14, 13))
{
RR = 1.000000f;
GG = 0.800000f;
BB = 0.100000f;
}
else if(dwItem == ITEM2(14, 170))
{
RR = 1.000000f;
GG = 0.000000f;
BB = 0.000000f;
}
else if(dwItem == ITEM2(2, 20))
{
RR = 1.000000f;
GG = 0.000000f;
BB = 0.000000f;
}
else
{
_asm
{
MOV ECX,0x0059BBAC
JMP ECX
}
}
_asm
{
MOV ECX,DWORD PTR DS:[0x80A70E0]
PUSH ECX
MOV EDI,0x0041FFA8
CALL EDI
MOV ECX,EAX
MOV EDI,0x0042023C
CALL EDI
PUSH BB
PUSH GG
PUSH RR
CALL DWORD PTR DS:[0x88D3C0]
MOV ECX,0x0059DA5C
JMP ECX
}
}
void gObjItemHooks()
{
Utils.SetRange((LPVOID)0x0059BBA1, 5, ASM::NOP);
Utils.SetJmp((LPVOID)0x0059BBA1, gObjItemColorDrop);
}
Test screen:
http://i.imgur.com/Z1tuLPQ.jpg
Re: Hooking glColor3f proc of Items on Map floor
I like create 1 function like pobrinho style programming.. of this but to change item text colors on inventory using: glColor3f function (like on the floor map) but in Inventory Player.. in inventory player not direct call to glColor3f function... yet! :(: (for 1.03.15 eng)
Re: Hooking glColor3f proc of Items on Map floor
Quote:
Originally Posted by
pobrinho
my function in 1.02c main season 2.
Code:
float RR = 0.0f;
float GG = 0.0f;
float BB = 0.0f;
__declspec(naked) void gObjItemColorDrop()
{
_asm
{
mov item_ID, ax
}
if(item_ID == ITEM_GET(14,13)) // jewel of bless
{
RR = 1.000000f;
GG = 0.800000f;
BB = 0.100000f;
}
else if(item_ID == ITEM_GET(14,63)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,64)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,65)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,66)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,67)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,68)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
else if(item_ID == ITEM_GET(14,69)) // jewel
{
RR = 0.95f;
GG = 0.1425f;
BB = 0.1425f;
}
//add new items
else
{
_asm // return function
{
mov edx, 0x00606456
jmp edx
}
}
_asm // função das cores
{
mov edx,dword ptr ds:[0x5841E44]
mov eax,dword ptr ds:[0x5841DD8]
push edx
push eax
call ebx
push BB
push GG
push RR
call dword ptr ds:[0x78337C]
mov edx, 0x006075B2
jmp edx
}
}
hook:
hook_extended(0x0060644C, (DWORD)(&gObjItemColorDrop));
func_nop(0x0060644C+5, 5);
It looks like your code may produce stack overflow because you don't restore the stack after calls. After each call you need to increase esp by arg_number * 4 or pop the registers you passed as args.
Re: Hooking glColor3f proc of Items on Map floor
Quote:
Originally Posted by
[RCZ]ShadowKing
It looks like your code may produce stack overflow because you don't restore the stack after calls. After each call you need to increase esp by arg_number * 4 or pop the registers you passed as args.
Properly it should be called: "stack corruption".
And all depends on function's calling convention.
Re: Hooking glColor3f proc of Items on Map floor
Re: Hooking glColor3f proc of Items on Map floor
And possibly glColor3f is used not only for item name color, so maybe you can change the text color somewhere and elsewhere.