DirectX Hooking Example, Along With Drawing Text On DirectX
-
- Posts: 11
- Joined: Sat Apr 12, 2008 7:09 pm
DirectX Hooking Example, Along With Drawing Text On DirectX
This Is an example Project Showing You How To Hook DirectX Games And Draw Custom Text Onto The Games Screen.
Original Code By Madshi. Direct3DHooking Example
Edited By Ultimation To Include Drawing Text Onto DirectX Screens
http://rapidshare.com/files/106970336/M ... k.rar.html
More Examples
Drawing Text Ingame Via DLL Injection
Drawing Text Ingame Without DLL Injection (Proxying d3d9.dll)
Drawing Images Ingame Via DLL Injection
Drawing Images Ingame Without DLL Injection( Proxying d3d9.dll)
Download From Below!
http://rapidshare.com/files/115982431/D ... s.rar.html
Original Code By Madshi. Direct3DHooking Example
Edited By Ultimation To Include Drawing Text Onto DirectX Screens
http://rapidshare.com/files/106970336/M ... k.rar.html
More Examples
Drawing Text Ingame Via DLL Injection
Drawing Text Ingame Without DLL Injection (Proxying d3d9.dll)
Drawing Images Ingame Via DLL Injection
Drawing Images Ingame Without DLL Injection( Proxying d3d9.dll)
Download From Below!
http://rapidshare.com/files/115982431/D ... s.rar.html
Last edited by Ultimation on Sun May 25, 2008 10:32 pm, edited 1 time in total.
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
I might be wrong
I might be wrong, but should not the code be like this:
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Font: D3DX9.ID3DXFont;
rec: ^TRect;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateFontA(Self, 15, 0, FW_BOLD, 1, False, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH or FF_DONTCARE, 'Arial', Font);
GetMem(rec, 16);
SetRect(rec^, 200, 0, 900, 900);
Font.DrawTextA(nil, 'DirectX Drawing Text Example',
Length('DirectX Drawing Text Example'), rec^, DT_LEFT, $FFFFFFFF);
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
?
And how do i get ridd of that annoying "need d3dx9.dll thingy" thing
Cause i asume you use the Direct3D9 and d3d9 libs from Jedi right?
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Font: D3DX9.ID3DXFont;
rec: ^TRect;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateFontA(Self, 15, 0, FW_BOLD, 1, False, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH or FF_DONTCARE, 'Arial', Font);
GetMem(rec, 16);
SetRect(rec^, 200, 0, 900, 900);
Font.DrawTextA(nil, 'DirectX Drawing Text Example',
Length('DirectX Drawing Text Example'), rec^, DT_LEFT, $FFFFFFFF);
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
?
And how do i get ridd of that annoying "need d3dx9.dll thingy" thing
Cause i asume you use the Direct3D9 and d3d9 libs from Jedi right?
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
-
- Posts: 3
- Joined: Wed Nov 21, 2007 11:37 am
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
Hm
Madshi
See anything weird in this code? I get General Protection errors with it
See anything weird in this code? I get General Protection errors with it
Code: Select all
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Sprite: D3DX9.ID3DXSprite;
//dxVector: D3DX9.TD3DXVector2;
Texture: Direct3D9.IDirect3DTexture9;
rec: PRect;
Vector: D3DX9.PD3DXVector3;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateSprite(Self, Sprite);
//D3DXCreateTexture(Self,200,200,nil,nil,nil,nil,nil,nil,nil,Texture);
D3DXCreateTextureFromFile(Self,pchar('bitmap.bmp'),Texture);
GetMem(rec, 32);
SetRect(rec^, 1, 1, 200, 200);
//Sprite._Begin(D3DXSPRITE_ALPHABLEND or D3DXSPRITE_BILLBOARD or
//D3DXSPRITE_SORT_DEPTH_FRONTTOBACK);
Vector.x := 1;
Vector.y := 1;
Vector.z := 0;
Sprite.Draw(Texture,rec,nil,nil, D3DCOLOR_ARGB(255,255,255,0));
//Font.DrawTextA(nil, 'This is text tra la la la',
//Length('This is text tra la la la'), rec, DT_LEFT, $FFFFEF55);
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
Re: Hm
On a quick check I see 3 things which look wrong to me:Calandoriel wrote:See anything weird in this code? I get General Protection errors with it
(1) You're not freeing that "rec" that you allocated -> memory leak.
(2) "TRect" is only 16 bytes long and not 32, I think?
(3) Vector looks like a pointer, but you're not allocating it. Try "Vector: D3DX9.D3DXVector3" instead. Or however the non-point type is named.
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
hm
Well
Sprite.Draw(Texture,rec,nil,nil, D3DCOLOR_ARGB(255,255,255,0));
Requires a PD3DXVector3 as argument.
If you are gonna use it.
Anyhow, i tried to take what you said into consideration and made this:
It does not crash, but it does not show a picture either.
Sprite.Draw(Texture,rec,nil,nil, D3DCOLOR_ARGB(255,255,255,0));
Requires a PD3DXVector3 as argument.
If you are gonna use it.
Anyhow, i tried to take what you said into consideration and made this:
Code: Select all
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Sprite: D3DX9.ID3DXSprite;
//dxVector: D3DX9.TD3DXVector2;
Texture: Direct3D9.IDirect3DTexture9;
rec: PRect;
Vector: D3DX9.PD3DXVector3;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateSprite(Self, Sprite);
D3DXCreateTextureFromFile(Self,pchar('bitmap.bmp'),Texture);
GetMem(rec, 16);
SetRect(rec^, 1, 1, 200, 200);
GetMem(Vector,16);
Vector.x := 1;
Vector.y := 1;
Vector.z := 1;
Sprite.Draw(Texture,rec,Vector,Vector, D3DCOLOR_ARGB(255,255,255,0));
//Free
FreeMem(rec);
FreeMem(Vector);
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
It does not crash, but it does not show a picture either.
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
Solved the pussle
Thanks for your help Madshi.
Will draw a sprite
If you just want it to draw everything "as it is" do:
Thanks for your help Madshi.
Code: Select all
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Sprite: D3DX9.ID3DXSprite;
Texture: Direct3D9.IDirect3DTexture9;
rec: PRect;
Vector: D3DX9.PD3DXVector3;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateSprite(Self, Sprite);
//D3DXCreateTexture(Self,200,200,nil,nil,nil,nil,nil,nil,nil,Texture);
D3DXCreateTextureFromFile(Self,'bitmap.bmp',Texture);
GetMem(rec, 16);
SetRect(rec^, 1, 1, 200, 200);
GetMem(Vector,16);
Vector.x := 1;
Vector.y := 1;
Vector.z := 1;
Self.BeginScene;
Sprite._Begin(0);
Sprite.Draw(Texture,rec,Vector,Vector, D3DCOLOR_ARGB(255,255,255,0));
Sprite._End;
Self.EndScene;
FreeMem(rec);
FreeMem(Vector);
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
If you just want it to draw everything "as it is" do:
Code: Select all
function PresentCallback(const Self: IDirect3DDevice9;
const SourceRect, DestRect: PRect;
const DestWindowOverride: HWND;
DirtyRegion: PRgnData): HResult; stdcall;
var
Sprite: D3DX9.ID3DXSprite;
Texture: Direct3D9.IDirect3DTexture9;
begin
//Your Drawing Code Here. This Function Gets Called Everytime The Surface Needs Refreshing
D3DXCreateSprite(Self, Sprite);
D3DXCreateTextureFromFile(Self,'sprite.jpg',Texture);
Self.BeginScene;
Sprite._Begin(0);
Sprite.Draw(Texture,nil,nil,nil, $AAFFFFFF);
Sprite._End;
Self.EndScene;
Result := PresentNext(self, SourceRect, DestRect, DestWindowOverride, DirtyRegion);
end;
-
- Posts: 11
- Joined: Sat Apr 12, 2008 7:09 pm
i didnt mean to add the drawing texture part that was me messing around, and yes i 4got freememory and the rect is only 16 bytes! sorry.
yes you may use this in demos. i have recently made some progress and built a ingame msn messenger! wich will soon be avaliable for people to use.
here is its progress!
yes you may use this in demos. i have recently made some progress and built a ingame msn messenger! wich will soon be avaliable for people to use.
here is its progress!
-
- Posts: 25
- Joined: Sun Oct 01, 2006 11:43 pm
- Location: www.ipconfig.se
Cool!
Cool dude, if you want to, i'd like to work on some theories with you.
PM me if you could possible come around adding me to your msn.
PM me if you could possible come around adding me to your msn.
-
- Posts: 11
- Joined: Sat Apr 12, 2008 7:09 pm
-
- Posts: 11
- Joined: Sat Apr 12, 2008 7:09 pm
you will find when drawing textures ingame you and you minimize the game your game will fail to restore and most likely crash. to correct this you need to add 2 more hooks to the directx device one on the OnLostDevices and antoher on OnRestoreDevices
in the OnLostDevices hook, do mysprite._LostDevice()
and on the RestoreDevice hook do mysprite._OnRestore()
Update------
Something Else Came To My Attention. Please make sure you are using the correct header files for your delphi version, otherwise you may need useless dll files like d3dx9.dll
here are the appropriate header files.
Delphi 4 And Delphi 5
http://rapidshare.com/files/114333479/B ... 5.rar.html
Delphi 6 And Delphi 7
http://rapidshare.com/files/114333666/B ... 7.rar.html
Delphi 2005 - 2007
http://rapidshare.com/files/114333985/B ... 0.rar.html
Regards
Ultimation
in the OnLostDevices hook, do mysprite._LostDevice()
and on the RestoreDevice hook do mysprite._OnRestore()
Update------
Something Else Came To My Attention. Please make sure you are using the correct header files for your delphi version, otherwise you may need useless dll files like d3dx9.dll
here are the appropriate header files.
Delphi 4 And Delphi 5
http://rapidshare.com/files/114333479/B ... 5.rar.html
Delphi 6 And Delphi 7
http://rapidshare.com/files/114333666/B ... 7.rar.html
Delphi 2005 - 2007
http://rapidshare.com/files/114333985/B ... 0.rar.html
Regards
Ultimation
-
- Posts: 3
- Joined: Wed Nov 21, 2007 11:37 am