Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Hooking glColor3f proc of Items on Map floor

Joined
Oct 29, 2007
Messages
1,290
Reaction score
1,311
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 [B][COLOR=#ff8c00](this is added by me, but you can put any item of: 12, 13 and 14 types)[/COLOR][/B]
        JE Set_Add_New
Set_Socket:
        PUSH 0x[COLOR=#3366ff]3F800000[/COLOR]
        PUSH 0x[COLOR=#00cc00]3ECCCCCD[/COLOR]
        PUSH 0x[COLOR=#ff0000]3F333333[/COLOR]
        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;
}
Screenshots of my tests with this:

kx3Knl1 - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


5VRxzW0 - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


hEProQS - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


KUuW6r7 - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


qPlrWjA - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


Complete Source Code Download:



Credits:
Webzen (for create main.exe xD)
SmallHabit (for teach me a good form to re-write asm parts of code of main.exe)
-=DarkSim=- (for teach me a good form to make hooks in some important functions)
Brain (for his Item Smoke Effect info about convertion FLOAT -> 16-decimal number)
mauro07 (for research in main.exe the function and correctly re-write in asm)​
 

Attachments

You must be registered for see attachments list
Last edited:
Newbie Spellweaver
Joined
Feb 4, 2009
Messages
71
Reaction score
14
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);
 
Last edited:
Joined
Oct 29, 2007
Messages
1,290
Reaction score
1,311
Here
pobrinho form adapted source for works on: 1.03.15 eng

Code:
DWORD dwItem;
Code:
#define ITEM_INTER 833
#define ITEM(x, y) ((x * 512) + y)
#define ITEM2(x, y) ((x * 512) + y + ITEM_INTER)
[COLOR=#33559C]
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);
}
[/COLOR]

Test screen:

Z1tuLPQ - Hooking glColor3f proc of Items on Map floor - RaGEZONE Forums


 

Attachments

You must be registered for see attachments list
Last edited:
Joined
Oct 29, 2007
Messages
1,290
Reaction score
1,311
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)
 
Kingdom of Shadows
Loyal Member
Joined
Jul 13, 2007
Messages
923
Reaction score
320
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.
 
Newbie Spellweaver
Joined
Apr 6, 2013
Messages
35
Reaction score
62
And possibly glColor3f is used not only for item name color, so maybe you can change the text color somewhere and elsewhere.
 
Back
Top