Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


problem on DX hook with Detour

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Maddy25
How do I cheat?
Reputation: 0

Joined: 06 Nov 2010
Posts: 5

PostPosted: Sat Nov 06, 2010 8:37 pm    Post subject: problem on DX hook with Detour Reply with quote

hi all,

ive done that dx hook tutorial. after fixing some lib bugs i can now compile it successfully but when i want to start the launcher, it finds the dll and the settings.ini but somehow cant start the process

DetourCreateProcessWithDll returns 0 when i debug it Sad

the games pathname is correct also

what could i have done wrong?

ill probably have to debug into the function itself, ill do that when i have more time, except some of you guys can help me before
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Nov 06, 2010 9:33 pm    Post subject: Reply with quote

If DetourCreateProcessWithDll is returning with 0, that means it failed. If you have Detours you have the source code to it, meaning you can walk into the source file and debug it.

Alternatively you can try calling GetLastError and see if an error code was set due to the issue, in case an actual API call failed internally.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Maddy25
How do I cheat?
Reputation: 0

Joined: 06 Nov 2010
Posts: 5

PostPosted: Fri Nov 12, 2010 5:44 pm    Post subject: Reply with quote

somehow i cant manage to solve my problem ... i fail at debugging into the function. well, i probably did a mistake copying something from the tutorial somewhere, although i checked everything about 20 times :/ can you maybe send me the complete version of the tutorial code? now as i actually understood the principle of the code thx to this good tutorial, i dont need snippets anymore ^^
that would be really nice.
greez, Maddy

ps: damn i cant do pm's Sad

EDIT: ok i found the problem. the game exe string in was wrong. now it starts the game. but i dont see any overlay, probably cause i havent done one yet, but where do i do the actual drawing of vertices in the dll ?
Back to top
View user's profile Send private message
Maddy25
How do I cheat?
Reputation: 0

Joined: 06 Nov 2010
Posts: 5

PostPosted: Sun Nov 14, 2010 2:38 pm    Post subject: Reply with quote

ok little update:
now ive put some code into the endscene function of the device class (pasted from some other tutorial)

Code:
struct TLVertex
      {
         float x, y, z, rhw;
         DWORD color;
      };

      TLVertex vertices[] =
      {
         { -0.5f, -0.5f, 0.0f, 1.0f, 0xffff0000 },
         { 99.5f, -0.5f, 0.0f, 1.0f, 0xff00ff00 },
         { -0.5f, 99.5f, 0.0f, 1.0f, 0xff0000ff },
         { 99.5f, 99.5f, 0.0f, 1.0f, 0xffff0000 }
      };

      SetVertexShader(0);
      SetPixelShader(0);
      SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
      SetRenderState(D3DRS_ZENABLE, false);
      SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
      SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
      SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
      SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
      SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
      DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(TLVertex));
      SetRenderState(D3DRS_ZENABLE, true);
      return Direct3DDevice9->EndScene();


its meant to draw a colered rectangle into the top left corner of the screen

now ive tried with some games. some games dont start, they crash instantly. other games start as normal but theres no overlay at ALL. and ONE game i finally managed to see the overlay. the game is called FlatOut2. although the overlay makes the menu buggy (i cant see anything in the menu) when i spam Enter, the game starts and i see everything including the supposed overlay. so somehow its proven that the hook works in some way but only at a rare number of games and still pretty buggy .
sooo... any ideas, Wiccan? (or other dudes)

thanks for help !!

greez, Maddy
Back to top
View user's profile Send private message
Maddy25
How do I cheat?
Reputation: 0

Joined: 06 Nov 2010
Posts: 5

PostPosted: Wed Nov 17, 2010 4:40 pm    Post subject: Reply with quote

please, anyone has an idea? Sad
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Nov 17, 2010 6:10 pm    Post subject: Reply with quote

switch to the d3d debug runtime and step through the code.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Nov 17, 2010 7:52 pm    Post subject: Reply with quote

Maddy25 wrote:
ok little update:
now ive put some code into the endscene function of the device class (pasted from some other tutorial)

Code:
struct TLVertex
      {
         float x, y, z, rhw;
         DWORD color;
      };

      TLVertex vertices[] =
      {
         { -0.5f, -0.5f, 0.0f, 1.0f, 0xffff0000 },
         { 99.5f, -0.5f, 0.0f, 1.0f, 0xff00ff00 },
         { -0.5f, 99.5f, 0.0f, 1.0f, 0xff0000ff },
         { 99.5f, 99.5f, 0.0f, 1.0f, 0xffff0000 }
      };

      SetVertexShader(0);
      SetPixelShader(0);
      SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
      SetRenderState(D3DRS_ZENABLE, false);
      SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
      SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
      SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
      SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
      SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
      DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(TLVertex));
      SetRenderState(D3DRS_ZENABLE, true);
      return Direct3DDevice9->EndScene();


its meant to draw a colered rectangle into the top left corner of the screen

now ive tried with some games. some games dont start, they crash instantly. other games start as normal but theres no overlay at ALL. and ONE game i finally managed to see the overlay. the game is called FlatOut2. although the overlay makes the menu buggy (i cant see anything in the menu) when i spam Enter, the game starts and i see everything including the supposed overlay. so somehow its proven that the hook works in some way but only at a rare number of games and still pretty buggy .
sooo... any ideas, Wiccan? (or other dudes)

thanks for help !!

greez, Maddy


You typically need to save the current state information before doing any additional drawing to ensure the text is drawing with correct properties and render states. Check out:

CreateStateBlock
BeginStateBlock
EndStateBlock

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Maddy25
How do I cheat?
Reputation: 0

Joined: 06 Nov 2010
Posts: 5

PostPosted: Fri Nov 19, 2010 12:14 pm    Post subject: Reply with quote

thx for the reply.

i have tried out create-/begin/-endstateblock. but this only disables the hook even for flatout2 too ! no colored box in the cornor Sad
some how i did something wrong ?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Nov 19, 2010 8:55 pm    Post subject: Reply with quote

Each game adjusts render flags and such per-frame differently based on what is being drawn at the time. The last to be drawn is typically the cause to something being messed up before you can draw properly. After you create your state block and store it, you may need to fully adjust every render state manually til you find which ones are being troublesome.

You can dump the state block as well and manually look through it to find which ones you know off-hand need to be altered.

You may also need to adjust texture stage states too, you can adjust those using:
SetTextureStageState

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites