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

Results 1 to 1 of 1
  1. #1
    Enthusiast niling is offline
    MemberRank
    Aug 2010 Join Date
    31Posts

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

    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;
    }
    Attached Files Attached Files




Advertisement