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!

HookDBConn,Support all GMTool,Now you can config your dbconn(src)

Newbie Spellweaver
Joined
Aug 15, 2010
Messages
31
Reaction score
34
1.build a release ver dll.
2.use loadpe, import the dll by the HookAPI to your gmtool's exe.
3.edit config.ini
4,run your gmtool.
sorry my bad english,good luck!
/////////////////////////////////////////////////config.ini/////////////////////////////////////////////////
[DB]
ip=xxx
port=xxx
acc=xxx
pwd=xxx
dbname=atum2_db_1
////////////////////////////////////////////////src////////////////////////////////////////////////////////
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <sqlext.h>

#pragma warning(disable:4731)

DWORD pHookAddr;

__declspec(naked) SQLRETURN SQL_API NewSQLDriverConnectAProxy(SQLHDBC hdbc,
SQLHWND hwnd,
SQLCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut,
SQLUSMALLINT fDriverCompletion)
{


_asm
{
mov edi, edi;
push ebp;
mov ebp, esp;
jmp pHookAddr;
}
}

SQLRETURN SQL_API MySQLDriverConnectA( SQLHDBC hdbc,
SQLHWND hwnd,
SQLCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut,
SQLUSMALLINT fDriverCompletion)
{
char szIp[20],szPort[20],szAcc[20],szPwd[20],szDbName[20];
GetPrivateProfileStringA("DB","ip","127.0.0.1",szIp, 20, "./config.ini");
GetPrivateProfileStringA("DB","port","1433",szPort, 20, "./config.ini");
GetPrivateProfileStringA("DB","acc","atum",szAcc, 20, "./config.ini");
GetPrivateProfileStringA("DB","pwd","callweb",szPwd, 20, "./config.ini");
GetPrivateProfileStringA("DB","dbname","atum2_db_1",szDbName, 20, "./config.ini");
sprintf((char*)szConnStrIn,"DRIVER={SQL Server};SERVER=%s;ADDRESS=%s,%s;NETWORK=DBMSSOCN;UID=%s;PWD=%s;DATABASE=%s",szIp,szIp,szPort,szAcc,szPwd,szDbName);
return NewSQLDriverConnectAProxy(hdbc,hwnd,szConnStrIn,cbConnStrIn,szConnStrOut,cbConnStrOutMax,pcbConnStrOut,fDriverCompletion);
}

void WINAPI HookAPI()
{
pHookAddr = *(DWORD*)(*(DWORD*)((DWORD)SQLDriverConnectA+2));
DWORD dwOld;
VirtualProtect((LPVOID)pHookAddr,5,PAGE_EXECUTE_READWRITE,&dwOld);
*(BYTE*)pHookAddr = 0xE9;
*(DWORD*)(pHookAddr+1)=(DWORD)MySQLDriverConnectA-((DWORD)pHookAddr+5);
pHookAddr +=5;

}

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
DisableThreadLibraryCalls(hModule);
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
HookAPI();
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
 

Attachments

You must be registered for see attachments list
Back
Top