Hooking glColor3f proc of Items on Map floor

Results 1 to 10 of 10
  1. #1
    Darkness Member Kiosani is offline
    MemberRank
    Oct 2007 Join Date
    ArgentinaLocation
    1,276Posts

    config 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;
    }
    Screenshots of my tests with this:











    Complete Source Code Download:

    http://www.mediafire.com/download/gm...989v0/Item.rar

    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)
    Last edited by Kiosani; 13-02-14 at 04:51 PM.


  2. #2
    el gordito tetas caidas GM-Andromeda is offline
    MemberRank
    Jun 2006 Join Date
    Complex plane.Location
    202Posts

    Re: Hooking glColor3f proc of Items on Map floor

    wow, too much work just to change font color.


  3. #3
    Darkness Member Kiosani is offline
    MemberRank
    Oct 2007 Join Date
    ArgentinaLocation
    1,276Posts

    Re: Hooking glColor3f proc of Items on Map floor

    Quote Originally Posted by GM-Andromeda View Post
    wow, too much work just to change font color.

    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).

  4. #4
    Member pobrinho is offline
    MemberRank
    Feb 2009 Join Date
    72Posts

    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);
    Last edited by pobrinho; 14-02-14 at 12:22 AM.

  5. #5
    Darkness Member Kiosani is offline
    MemberRank
    Oct 2007 Join Date
    ArgentinaLocation
    1,276Posts

    Re: Hooking glColor3f proc of Items on Map floor

    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)
    
    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:



    Last edited by Kiosani; 14-02-14 at 03:39 AM.

  6. #6
    Darkness Member Kiosani is offline
    MemberRank
    Oct 2007 Join Date
    ArgentinaLocation
    1,276Posts

    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)

  7. #7
    Kingdom of Shadows [RCZ]ShadowKing is offline
    MemberRank
    Jul 2007 Join Date
    1,644Posts

    Re: Hooking glColor3f proc of Items on Map floor

    Quote Originally Posted by pobrinho View Post
    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.

  8. #8
    Hybrid Gembrid is offline
    MemberRank
    Mar 2006 Join Date
    1,121Posts

    Re: Hooking glColor3f proc of Items on Map floor

    Quote Originally Posted by [RCZ]ShadowKing View Post
    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.

  9. #9
    Enthusiast IonGames is offline
    MemberRank
    Jun 2012 Join Date
    47Posts

    Re: Hooking glColor3f proc of Items on Map floor

    season 6 eps3 ? 1.04D

  10. #10
    Enthusiast Kernighan is offline
    MemberRank
    Apr 2013 Join Date
    MoldovaLocation
    35Posts

    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.



Advertisement