dimanche 23 février 2014

[Help] Finding device pointer + offset topic




Hello guys!

Im currently trying to do a hook using the vtable (replacing it with a manipulated one) of the d3d device.

so i need to find the d3d device in memory.

i already tried using following code:


Code:


struct fakeD3DINFO
{
        LPVOID ModuleBase;
        DWORD* VTable;
}FAKED3DINFO;

BOOL SetupFakeDevice()
{
        // This function sets up a new device, obtaining and saving the address from the old one.
       
        IDirect3D9* fakeInfo = Direct3DCreate9(D3D_SDK_VERSION);
        if(!fakeInfo)
        {
                MessageBoxA(NULL, "Couldnt create fakeInfo!", "Info", 0);
                FAKED3DINFO.ModuleBase = 0;
                FAKED3DINFO.VTable = 0;
                return FALSE;
        }
        IDirect3DDevice9* fakeDevice;
        UINT fakeAdapter = D3DADAPTER_DEFAULT;
        D3DDEVTYPE fakeDeviceType = D3DDEVTYPE_HAL;
        HWND fakeWindow;
        if((fakeWindow = FindWindow(NULL, L"EmptyProject")) == NULL)
        {
                MessageBoxA(NULL, "Couldnt find window!", "INFO", 0);
        }
        D3DPRESENT_PARAMETERS fakeParams;
        ZeroMemory(&fakeParams,sizeof(fakeParams));
        fakeParams.Windowed = TRUE;
        fakeParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
        DWORD fakeBehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;

        if(fakeInfo->CreateDevice(fakeAdapter, fakeDeviceType, fakeWindow, fakeBehaviorFlags, &fakeParams, &fakeDevice) != S_OK)
        {
                char sBuffer[100];
                sprintf(sBuffer, "Failed to create FakeDevice!");
                MessageBoxA(NULL, sBuffer, "Info", 0);
                return FALSE;
        }

        FAKED3DINFO.ModuleBase = (void*)GetModuleHandle(L"d3d9.dll");
        FAKED3DINFO.VTable = (DWORD*)*(DWORD*)fakeDevice;

        char sBuffer[100];
        sprintf(sBuffer, "Success! Created FakeDevice :-)\nGrabbing vtAddress...\n\nPOSSIBLE VTABLE ADDRESS: %x", FAKED3DINFO.VTable);
        MessageBoxA(NULL, sBuffer, "Info", 0);
        return TRUE;
}


but i always get a dynamic address and no offset or static address :(
i dont know what im doing wrong..

is there another solution finding the d3d object? (except the one with olly)

Thanks in advance!
mac





Aucun commentaire:

Enregistrer un commentaire