Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2011, 09:21 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,447
Default 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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:31 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3