| View previous topic :: View next topic |
| Author |
Message |
Matherz Newbie cheater
Reputation: 0
Joined: 25 Aug 2012 Posts: 15
|
Posted: Wed Dec 26, 2012 7:46 am Post subject: Direct Hook - Own code ? |
|
|
Hi,
I made in C++ DirectX injection from tutorial. I successfuly compiled project (DLL and Injector). Everyting works fine (I hope), but I have any idea in which part code I should put my own code. I wanna make a code to Direct hook which will draw to screen some text.
Any sugestion? (Sorry for my sh*tty english).
Here's link tutorial (thx to Wiccaan)
forum.cheatengine.org/viewtopic.php?t=161045
thaks for help[/url] |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Dec 26, 2012 8:41 am Post subject: |
|
|
Typically anything drawn by the hook should be done in EndScene before the actual EndScene call is made, mainly to ensure that your stuff is drawn over the entire scene and is visible.
Keep in mind you need to handle initialization of your objects as well as handling if the device has reset called. If you don't your hook will crash the game. _________________
- Retired. |
|
| Back to top |
|
 |
Matherz Newbie cheater
Reputation: 0
Joined: 25 Aug 2012 Posts: 15
|
Posted: Wed Dec 26, 2012 9:12 am Post subject: |
|
|
| Wiccaan wrote: | Typically anything drawn by the hook should be done in EndScene before the actual EndScene call is made, mainly to ensure that your stuff is drawn over the entire scene and is visible.
Keep in mind you need to handle initialization of your objects as well as handling if the device has reset called. If you don't your hook will crash the game. |
Thaks for help, but I'am still don't know where exactly I can write code... (I already know C++).
Someting like this?:
| Code: |
HRESULT Direct3DDevice9Wrapper::BeginScene()
{
// my own code
return Direct3DDevice9->BeginScene();
}
|
I noob in hooking ... |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Dec 26, 2012 7:18 pm Post subject: |
|
|
Yes but do that in EndScene, not BeginScene. _________________
- Retired. |
|
| Back to top |
|
 |
Matherz Newbie cheater
Reputation: 0
Joined: 25 Aug 2012 Posts: 15
|
Posted: Thu Dec 27, 2012 6:09 am Post subject: |
|
|
| Wiccaan wrote: | | Yes but do that in EndScene, not BeginScene. |
Thanks much again for reply.
But I have still problem . Im trying someting like this in EndScene but still with no success.
| Code: |
...
//STDMETHOD(EndScene)(THIS);
HRESULT Direct3DDevice9Wrapper::EndScene()
{
HDC hdc;
hdc = CreateCompatibleDC(NULL);
D3DCOLOR fontColor = D3DCOLOR_ARGB(255,0,0,255);
// Create a rectangle to indicate where on the screen it should be drawn
RECT rct;
rct.left=2;
rct.right=780;
rct.top=10;
rct.bottom=rct.top+20;
// Draw some text
DrawText(hdc, L"Hello World", -1, &rct, 0);
return Direct3DDevice9->EndScene();
}
....
|
| Quote: | | This tutorial is going to explain how to do the basics, create the hook, show an example wrapper, and explain a few small things along with the hook. I will include a full example as well that I will find some random free program to show you how it works and such in as well. I will add wireframe mode to a toggle key to show you how to add some of your own code into the hook as well. |
(Quote from TUT). Is there any example stuff for my learning how do that?
[/code] |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Dec 28, 2012 8:40 am Post subject: |
|
|
Firstly, your EndScene wrapper should look like this:
| Code: |
// STDMETHOD(EndScene)(THIS);
HRESULT __stdcall Direct3DDevice9Wrapper::EndScene()
{
// draw stuff here..
return Direct3DDevice9->EndScene();
}
|
The calling convention of the functions are important.
Next, 'DrawText' is not a Direct3D method of rendering text. You can use it and all, but you are missing a lot more work that is needed to make it work properly with Direct3D.
Check out things like this:
http://www.two-kings.de/tutorials/dxgraphics/dxgraphics09.html
http://www.drunkenhyena.com/cgi-bin/view_cpp_article.pl?chapter=3;article=17
Mainly look into:
- ID3DXFont
- CD3DFont
Or any other wrapper that another person has made. _________________
- Retired. |
|
| Back to top |
|
 |
Matherz Newbie cheater
Reputation: 0
Joined: 25 Aug 2012 Posts: 15
|
Posted: Sun Dec 30, 2012 4:33 pm Post subject: |
|
|
Ok thanks again very much for your answers. I've got last question (or I hope).
Where is a pointer to Direct3D device. (I tried Direct3D9 )
FontPosition.right = Direct3D9?.GetWidth(); // Err for sure
That was the reason why I used DrawText function. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Dec 30, 2012 5:50 pm Post subject: |
|
|
The position is where you choose to put it, it doesn't have to be bound to the windows size. But if you do need to get the size you can get the view port info using IDirect3DDevice9::GetViewport. _________________
- Retired. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25830 Location: The netherlands
|
Posted: Sun Dec 30, 2012 6:15 pm Post subject: |
|
|
I recommend getting a simple direct3d9 tutorial from somewhere that you are capable of compiling, and then experiment with that by adding your own drawing code.
Once you get the grasp of it, turn it into a hook _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Matherz Newbie cheater
Reputation: 0
Joined: 25 Aug 2012 Posts: 15
|
Posted: Mon Dec 31, 2012 4:17 am Post subject: |
|
|
I don't need get half size of screen that was only example. I just need a pointer to D3D device because I can't use lot of D3D API function.
D3DXCreateFontIndirect(XXX.GetDevice(),&FontDesc,&g_Font);
LPDIRECT3DDEVICE9 pDevice
Or I should use NULL?
(Thanks again much and sorry for my english).
| Dark Byte wrote: | I recommend getting a simple direct3d9 tutorial from somewhere that you are capable of compiling, and then experiment with that by adding your own drawing code.
Once you get the grasp of it, turn it into a hook |
I compile a DLL into a process with launcher with no problem. But I just want to know how add to hook some own stuff that's all.
EDIT: THankx for help !!!
Last edited by Matherz on Fri Jan 04, 2013 2:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Dec 31, 2012 10:17 am Post subject: |
|
|
The device pointer it wants is the device pointer you already have:
Direct3DDevice9 _________________
- Retired. |
|
| Back to top |
|
 |
|