EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   Client Hooking with CDetours: Console Logging (https://www.eqemulator.org/forums/showthread.php?t=32909)

Secrets 01-17-2011 09:21 PM

Client Hooking with CDetours: Console Logging
 
Wrote this small bunch of code using the CDetours library. It hooks the EQ Client and outputs the dbg.txt stuff in a console instead of a file. Included here is the dbg.txt logging address for SoD clients, the CDetours library, and the source that logs to a console.

Instructions:

1) DLL is an empty win32 DLL project. Copy + Paste the the source into an empty cpp file.

2) Add CDetours to the windows path like you would with the includes for MySQL/Perl/Zlib.

2a) Compile the DLL

3) Use a DLL injector like InjeX or Injec-TOR to inject the DLL into eqgame.exe

4) Enjoy your console in eqgame.

Source:

Code:

#include <windows.h>
#include <stdio.h>
#include <string>
#include <CDetour.h>
#pragma comment( lib, "detours.lib" )

DWORD LogAddr = 0x006B0BB0;

CDetour LogDet;


void LogHook(const char* two, ...)
{

char val[256] = "{0}";
HANDLE stdoutthing = GetStdHandle(STD_OUTPUT_HANDLE);
const char* sep = "\n";
unsigned long stufftowrite = 0;
va_list va;
va_start(va, two);
_vsnprintf_s(val, 255, two, va);
WriteConsoleA(stdoutthing,val, strlen(val), &stufftowrite, 0);
va_end(va);
stufftowrite = 0;
WriteConsoleA(stdoutthing,sep, strlen(sep), &stufftowrite, 0);
LogDet.Ret(false);
}

int WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID)
{
        if(dwReason == DLL_PROCESS_ATTACH)
        {
                LogDet.Detour((PBYTE)LogAddr, ( PBYTE )LogHook);

                if(!AllocConsole())
                {
                        return 0;
                }
                SetConsoleTitle(TEXT("EQ Console"));
                LogDet.Apply();
        }
        else if(dwReason == DLL_PROCESS_DETACH)
        {
                LogDet.Remove();
        }
        return 1;
}

CDetours:

Code:

http://ilikekitti.es/CDetour.rar

Any questions about this, post it in this thread.


All times are GMT -4. The time now is 06:37 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.