0

Hello everyone I am messing around with some DLL injection stuff. Therefore I downloaded a simple Direct3D 9 sample application (it shows only a cube), which I want to manipulate.

I already managed to hook the EndScene and Reset function of this application, and now simply want to add more light to the current drawn frame.

Here is my EndScene function:

HRESULT WINAPI myEndScene(LPDIRECT3DDEVICE9 pDevice) {
    lightHackTest2(pDevice);
    auto ret = origEndScene(pDevice);
    placeHooks();
    return ret;
}

and here is my lightHackTest2 function:

void lightHackTest2(LPDIRECT3DDEVICE9 pDevice) {
    pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(100, 100, 100));
}

void lightHackTest(LPDIRECT3DDEVICE9 pDevice) {
    D3DLIGHT9 light;
    ZeroMemory(&light, sizeof(light));
    light.Type = D3DLIGHT_DIRECTIONAL;
    light.Diffuse.r = 0.5f;
    light.Diffuse.g = 0.5f;
    light.Diffuse.b = 0.5f;
    light.Diffuse.a = 1.0f;
    light.Direction.x = -1.0f;
    light.Direction.y = -0.5f;
    light.Direction.z = -1.0f;

    pDevice->SetLight(0, &light);
    pDevice->LightEnable(0, TRUE);
}

These functions do actually get called (checked it with some MessageBoxes) but everything does stay the same in the scene.

Am I applying the light wrong?

user143366
  • 11
  • 2
  • Given the complexity of the D3D pipeline, I don't think just setting light before end scene in some random application is guaranteed to yield any changes. You probably want to add light way earlier in the pipeline. – djgandy Apr 21 '17 at 12:30
  • But I am following a tutorial series, where the author did it exactly like this and succeeded with it. – user143366 Apr 21 '17 at 12:47

0 Answers0