guest.

Check for new replies
Users browsing this thread: 1 Guest(s)

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
1 0
D3d hook on XBox360
#1
first of all I really like to say thank you to all the admins for letting me come back
okay recently I've been working on reversing the D3D on the Xbox 360 I haven't gotten very far because I was trying to do it in halo and I couldn't find the proper function this current setup works with Titanfall and can work with the battlefield series on Xbox
anybody has any other research or would like to help me please post in this thread


Code:
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" HRESULT APIENTRY XuiRenderEnd(IDirect3DDevice9* pDevice);
/////////////////////////////////////////////////////////////////////////////////////////
IDirect3DDevice9* RenderFunc(IDirect3DDevice9* pDevice) {
    if(pDevice){
        XINPUT_STATE xstate;
        if (XInputGetState(0, &xstate) == ERROR_SUCCESS) {
            if(xstate.Gamepad.wButtons == (XINPUT_GAMEPAD_LEFT_SHOULDER | XINPUT_GAMEPAD_RIGHT_SHOULDER | XINPUT_GAMEPAD_A)) {
                pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
                printf("pDevice 0x%X\n", pDevice);
            }
        }
    }
    return pDevice;
}
/////////////////////////////////////////////////////////////////////////////////////////
HRESULT __declspec(naked) APIENTRY XuiRenderEnd_Detour(IDirect3DDevice9* pDevice) {
    __asm {
        bl    RenderFunc
        cmplwi      cr6, r3, 0
        bne      cr6, loc_81779BF4
        lis      r3, -0x7FF9  // 0x80070057
        ori      r3, r3, 0x57 // 0x80070057
        blr
loc_81779BF4:    
        lwz      r11, 0(r3)
        lwz      r11, 0x4C(r11)
        mtspr    CTR, r11
        bctr
    }
}
/////////////////////////////////////////////////////////////////////////////////////////
void wftfunct(){
    PatchInJump((DWORD*)0x8177A768, (DWORD)XuiRenderEnd_Detour, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
void wftD3D(){
    HANDLE hThread;
    DWORD threadId;
    ExCreateThread(&hThread, 0, &threadId, (VOID*)XapiThreadStartup, (LPTHREAD_START_ROUTINE)wftfunct, NULL, 0x2 | CREATE_SUSPENDED);
    XSetThreadProcessor(hThread, 4);
    SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL);
    ResumeThread(hThread);
}
/////////////////////////////////////////////////////////////////////////////////////////



Code:
void DrawFilledRect(IDirect3DDevice9* pDevice, float x0, float y0, float width, float height) {
    D3DCOLOR rectColor = D3DCOLOR_XRGB(255, 255, 255);
    D3DRECT BarRect = { x0, y0, x0 + width, y0 + height };
    pDevice->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, rectColor, 0, 0);
}

void DrawBorderedRect(IDirect3DDevice9* pDevice, float X, float Y, float W, float H) {
    DrawFilledRect(pDevice, X, Y, W, 1);
    DrawFilledRect(pDevice, X, Y, 1, H);
    DrawFilledRect(pDevice, X + W - 1, Y, 1, H);
    DrawFilledRect(pDevice, X, Y + H - 1, W, 1);
}

void PresentDetour(IDirect3DDevice9* pDevice) {
    if (pDevice) {
        DrawFilledRect(pDevice, 60, 60, 100, 100);
    }
}

D3DVOID __declspec(naked) WINAPI Present_Hook(IDirect3DDevice9* pDevice) {
    __asm {
        addi  r4, r3, 0x32E0
        addi  r3, r1, 0x90
        li   r5, 0x1C
        bl   memcpy

        mr   r3, r31
        bl   PresentDetour

        lis   r11, 0x8184
        ori   r11, r11, 0x10D0
        mtctr  r11
        bctr
    }
}

void HookD3D(){
    PatchInJump((PDWORD)0x818410C0, (DWORD)Present_Hook, FALSE);
}
[Image: FiHzeWA.jpg]

Check for new replies

Forum Jump: