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 


Help with the DX9 hook and wrapper

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

Joined: 06 Feb 2011
Posts: 6

PostPosted: Sun Feb 06, 2011 9:35 pm    Post subject: Help with the DX9 hook and wrapper Reply with quote

I followed wiccaan's tutorial and I have made everything, but at the time to compile i get this error:

ID3D9Wrapper_Device.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __stdcall Direct3DDevice9Wrapper::GetAvailableTextureMem(void)" (?GetAvailableTextureMem@Direct3DDevice9Wrapper@@UAGIXZ)
1>C:\Users\ivan\Desktop\DX_Hook\Debug\DX_Hook.dll : fatal error LNK1120: 1 unresolved externals

I know it's the linker but i have no idea on how to fix it. Help would be greatly appreciated.

I couldn't reply on the thread because it said i needed some kind of special permission. And also it wouldn't let me send you a pm.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Feb 06, 2011 11:53 pm    Post subject: Reply with quote

Are you linking against d3d9.lib?
Back to top
View user's profile Send private message
Ivanxpm
How do I cheat?
Reputation: 0

Joined: 06 Feb 2011
Posts: 6

PostPosted: Mon Feb 07, 2011 12:17 am    Post subject: Reply with quote

I did include all the lib files i was supposed to include. I even linked the detours too after following the instruction of the detours just to be sure.

C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86

Maybe it's cuz i have the newest DX SDK? but it does have the d3d9.lib
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: Mon Feb 07, 2011 8:37 am    Post subject: Reply with quote

Make sure you have recreated the function GetAvailableTextureMem in your wrapped device as well. You have to 'proxy' all the functions or you will get errors.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Ivanxpm
How do I cheat?
Reputation: 0

Joined: 06 Feb 2011
Posts: 6

PostPosted: Mon Feb 07, 2011 12:22 pm    Post subject: Reply with quote

OMG, thx man. That was stupid of me. I totally didn't see that i didn't recreate that function. Thank you very much I was just missing that Very Happy.

Although i get this warnings:

Creating library C:\Users\ivan\Desktop\DX_Hook\Debug\DX_Hook.lib and object C:\Users\ivan\Desktop\DX_Hook\Debug\DX_Hook.exp
1>detours.lib(detours.obj) : warning LNK4099: PDB 'detours.pdb' was not found with 'Detours/detours.lib' or at 'c:\Users\ivan\Desktop\DX_Hook\debug\detours.pdb'; linking object as if no debug info
1>detours.lib(disasm.obj) : warning LNK4099: PDB 'detours.pdb' was not found with 'Detours/detours.lib' or at 'c:\Users\ivan\Desktop\DX_Hook\debug\detours.pdb'; linking object as if no debug info
1>Embedding manifest...
1> Creating library C:\Users\ivan\Desktop\DX_Hook\Debug\DX_Hook.lib and object C:\Users\ivan\Desktop\DX_Hook\Debug\DX_Hook.exp
1>detours.lib(detours.obj) : warning LNK4099: PDB 'detours.pdb' was not found with 'Detours/detours.lib' or at 'c:\Users\ivan\Desktop\DX_Hook\debug\detours.pdb'; linking object as if no debug info
1>detours.lib(disasm.obj) : warning LNK4099: PDB 'detours.pdb' was not found with 'Detours/detours.lib' or at 'c:\Users\ivan\Desktop\DX_Hook\debug\detours.pdb'; linking object as if no debug info

BTW, is there any other forum with the results like:

Results of using this tutorial can be such as:
extalia[.]com/forums/viewtopic.php?f=45&t=2597

or better yet, if you could help me with making the models wire-framed.

I did find another tutorial that says:

To run the game in wireframe add:
m_pD3Ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
m_pD3Ddev->DrawIndexedPrimitive(Type,BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
m_pD3Ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);

where would i add it or what will i have to change in order for that to work on wiccaan's tutorial wrapper.
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: Mon Feb 07, 2011 6:09 pm    Post subject: Reply with quote

The Extalia link is dead because the site is gone. I wrote the tutorial, the copy of it in the Programing+ section is the same as what it was posted on Extalia. I never wrote the 2nd part since I didn't have the time to when I first wrote the tutorial.

If you want the whole game to go into wireframe just set D3DRS_FILLMODE to D3DFILL_WIREFRAME with SetRenderState.

If you are trying to do it per-specific texture or object you will have to filter them out one way or another. Most cases you will monitor and alter them inside of DrawIndexedPrimitive.

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

Joined: 06 Feb 2011
Posts: 6

PostPosted: Mon Feb 07, 2011 6:17 pm    Post subject: Reply with quote

Should i just ignore the warnings?

I saw in a microsoft forum that it doesn't affect anything except debugging.

And about the wireframe thing:

There's no D3DRS_FILLMODE in the project so should i put it in the ID3D9Wrapper_Device.cpp

like this:

HRESULT Direct3DDevice9Wrapper::SetRenderState(D3DRENDERSTATETYPE State,DWORD Value)
{
Direct3DDevice9->SetRenderState(D3DRS_FILLMODE);
return Direct3DDevice9->SetRenderState(State, Value);
}

I'm sorry i'm just learning and i got no idea Sad
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: Mon Feb 07, 2011 8:09 pm    Post subject: Reply with quote

The Detours warnings, yea you can ignore them. D3DRS_FILLMODE is a render state, which is part of the Direct3D runtime, it's not part of the hook.

Inside of SetRenderState you can check if the incoming state is for D3DRS_FILLMODE and force it to a different value, or you can monitor for a hotkey in a thread elsewhere and toggle it etc.

Like this:

Code:
HRESULT   __stdcall newIDirect3DDevice9::SetRenderState( D3DRENDERSTATETYPE State, DWORD Value )
{
   if( State == D3DRS_FILLMODE )
      Value = D3DFILL_WIREFRAME;
   return this->m_vOrigDirect3DDevice9->SetRenderState( State, Value );
}

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

Joined: 06 Feb 2011
Posts: 6

PostPosted: Mon Feb 07, 2011 8:29 pm    Post subject: Reply with quote

The code you gave me had errors when i tried to compile so i changed it to this:

Code:
HRESULT   __stdcall Direct3DDevice9Wrapper::SetRenderState( D3DRENDERSTATETYPE State, DWORD Value )
{
   if( State == D3DRS_FILLMODE )
      Value = D3DFILL_WIREFRAME;
   return this->Direct3DDevice9->SetRenderState( State, Value );
}


and it did build well. Just wondering if it still does what it is supposed to.

I dont think it does because im injecting it to hl2 and it wont do anything ;[

The errors your code gives me are:

1>c:\users\ivan\desktop\dx_hook\dx_hook\id3d9wrapper_device.cpp(307) : error C2039: 'm_vOrigDirect3DDevice9' : is not a member of 'Direct3DDevice9Wrapper'
1> c:\users\ivan\desktop\dx_hook\dx_hook\id3d9wrapper_device.h(4) : see declaration of 'Direct3DDevice9Wrapper'
1>c:\users\ivan\desktop\dx_hook\dx_hook\id3d9wrapper_device.cpp(307) : error C2227: left of '->SetRenderState' must point to class/struct/union/generic type
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: Tue Feb 08, 2011 10:28 am    Post subject: Reply with quote

The errors are because my objects were named differently. It's fine, you just had to change them to match your object names and class names etc.

The engine might not call SetRenderState specifically with D3DRS_FILLMODE so you may need to do it manually yourself from another spot in your hook.

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

Joined: 06 Feb 2011
Posts: 6

PostPosted: Tue Feb 08, 2011 2:18 pm    Post subject: Reply with quote

Cant i just remove the if so that it will always set the value to wireframe?

Just removing the if line
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: Tue Feb 08, 2011 4:46 pm    Post subject: Reply with quote

You'd want to let the original call go through first before you alter the params any. You can also just call SetRenderState twice like this:

Code:
HRESULT   __stdcall Direct3DDevice9Wrapper::SetRenderState( D3DRENDERSTATETYPE State, DWORD Value )
{
   this->Direct3DDevice9->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
   return this->Direct3DDevice9->SetRenderState( State, Value );
}


Keep in mind though, like I said above, this is setting the entire engine to render in wireframe. Forcing it will make the game unplayable (at least in an enjoyable sense..).

_________________
- 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