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 


DirectDraw

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

Joined: 29 Jul 2009
Posts: 3

PostPosted: Wed Jul 29, 2009 5:35 pm    Post subject: DirectDraw Reply with quote

Greetings.

I have been trying to create a directdraw overlay for an FPS game so that I could draw my ESP over it (I have been using GDI and it flickers...)

The ESP values are obtained using ReadProcessMemory windows API function.

I would appreciate it if you could give me an example usage of directdraw overlay that you have made. There are some examples I have found but they are not for overlaying windows only full screen and they don't really work.

Thank you for your time.

PS: Thats how it looks like with GDI

turboimagehost [DOT] com/p/1924398/money_esp.JPG [DOT ]html


Last edited by bio777 on Wed Jul 29, 2009 8:16 pm; edited 1 time in total
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 Jul 29, 2009 6:06 pm    Post subject: Reply with quote

It's possible to use GDI and not get flicker, it flickers because it has no notion of synchronizing with the frames the game is drawing.

You can probably just hijack part of the games render loop, jump to a code cave where you draw your stuff, then go back.



Or you may just find it easier to hook the games DX / OGL interface and handle all your drawing like that.
Back to top
View user's profile Send private message
karmah
Newbie cheater
Reputation: 0

Joined: 28 Jul 2009
Posts: 19
Location: Edinburgh UK

PostPosted: Wed Jul 29, 2009 6:13 pm    Post subject: Reply with quote

I think this might be what you're looking for (assuming you do mean direct3d and not directdraw)

http://www.gamedev.net/community/forums/topic.asp?topic_id=359794

You know what to do with the URL...


Instead of hooking the direct3create9, i've also seen a few mods with a wrapper d3d9.dll file, so once you have the juicy guts of the canvas, you can again do what you want with a few code hooks Smile

Hope it helps!

_________________
//todo : sig :\
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Jul 29, 2009 6:29 pm    Post subject: Reply with quote

karmah wrote:
I think this might be what you're looking for (assuming you do mean direct3d and not directdraw)

http://www.gamedev.net/community/forums/topic.asp?topic_id=359794

You know what to do with the URL...


Instead of hooking the direct3create9, i've also seen a few mods with a wrapper d3d9.dll file, so once you have the juicy guts of the canvas, you can again do what you want with a few code hooks Smile

Hope it helps!


That's the place where it got me started.
I nearly fell off of my chair when I saw DirectDraw and FPS...
Back to top
View user's profile Send private message
bio777
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 3

PostPosted: Wed Jul 29, 2009 8:02 pm    Post subject: Reply with quote

Excuse me but no, the whole idea behind my cheat is to make it silent, it doesn't alter the game process in any way. Also the reason why I inquired about DirectDraw is because I saw what it does, it draws on top of anything at a hardware level, all screenshots come clean and it doesn't flicker.

So if anyone can help me with a simple example how to draw inside a window using a HWND I will greatly appreciate it.

In case you wonder why I use GDI in a d3d game, I have my own world to screen functions that the do the job beautifully.
Back to top
View user's profile Send private message
karmah
Newbie cheater
Reputation: 0

Joined: 28 Jul 2009
Posts: 19
Location: Edinburgh UK

PostPosted: Thu Jul 30, 2009 2:49 am    Post subject: Reply with quote

Without any sort of modification.. it might be hard to get either a synchronous paint with the GDI or even add directdraw capabilities to the window since... Im sure if you evn managed to overlay with D3D, when the buffer's painted to the screen you'd probably get all the pixels surrounting your image blanking out the rest of the screen..

You seen this done for real before?

An alternative without any modification:
You said you're playing windowed? You can get away with reshaping an alwaysontop window over your app I suppose.. just take into account the size of the draw window's titlebar and border?

_________________
//todo : sig :\
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Thu Jul 30, 2009 6:06 am    Post subject: Reply with quote

This is a part of my directdraw overlay code. You'll need to alter some stuff to make it work for you:

Code:

   if( FAILED(DirectDrawCreate(0, &lpDD, 0)) )
      return MessageBox(0, _T("DirectDrawCreate() failed!"), Caption, MB_ICONERROR);

   if( FAILED(lpDD->SetCooperativeLevel(0, DDSCL_NORMAL)) ){
      CleanUp();
      return MessageBox(0, _T("SetCooperativeLevel() failed!"), Caption, MB_ICONERROR);
   }

   DDSURFACEDESC ddsd;
   ZeroMemory(&ddsd, sizeof(ddsd));
   ddsd.dwSize = sizeof(ddsd);
   ddsd.dwFlags = DDSD_CAPS;
   ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
   if( FAILED(lpDD->CreateSurface(&ddsd, &lpPrimary, 0)) ){
      CleanUp();
      return MessageBox(0, _T("CreateSurface(Primary) failed!"), Caption, MB_ICONERROR);
   }
   ZeroMemory(&ddsd, sizeof(ddsd));
   ddsd.dwSize = sizeof(ddsd);
   ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
   ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY;
   ddsd.dwWidth = OVERLAY_WIDTH;
   ddsd.dwHeight = OVERLAY_HEIGHT;
   if( FAILED(lpDD->CreateSurface(&ddsd, &lpOverlay, 0)) ){
      CleanUp();
      return MessageBox(0, _T("CreateSurface(Overlay) failed!"), Caption, MB_ICONERROR);
   }
   ZeroMemory(&ddsd, sizeof(ddsd));
   ddsd.dwSize = sizeof(ddsd);
   ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
   ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
   ddsd.dwWidth = OVERLAY_WIDTH;
   ddsd.dwHeight = OVERLAY_HEIGHT;
   if( FAILED(lpDD->CreateSurface(&ddsd, &lpSource, 0)) ){
      CleanUp();
      return MessageBox(0, _T("CreateSurface(Source) failed!"), Caption, MB_ICONERROR);
   }


   HANDLE hBitmap = LoadImage(hInst, _T("dream.bmp"), IMAGE_BITMAP, OVERLAY_WIDTH, OVERLAY_HEIGHT, LR_LOADFROMFILE);
   if( !hBitmap ){
      CleanUp();
      return MessageBox(0, _T("LoadImage() failed!"), Caption, MB_ICONERROR);
   }

   HDC hdcSource;
   if( FAILED(lpSource->GetDC(&hdcSource)) ){
      CleanUp();
      return MessageBox(0, _T("GetDC() failed!"), Caption, MB_ICONERROR);
   }

   HDC hdcImage = CreateCompatibleDC(hdcSource);
   if( !hdcImage ){
      CleanUp();
      return MessageBox(0, _T("CreateCompatibleDC() failed!"), Caption, MB_ICONERROR);
   }

   if( SelectObject(hdcImage, hBitmap) ){
      BitBlt(hdcSource, 0, 0, OVERLAY_WIDTH, OVERLAY_HEIGHT, hdcImage, 0, 0, SRCCOPY);
   }
   lpSource->ReleaseDC(hdcSource);
   
   DeleteObject(hBitmap);

   DDCOLORKEY ColorKey;
   ColorKey.dwColorSpaceLowValue = 0;
   ColorKey.dwColorSpaceLowValue = 0xffffffff;
   lpSource->SetColorKey(DDCKEY_SRCBLT, &ColorKey);

   //Put the image on the overlay. DirectDraw will take care of the color formats
   lpOverlay->Blt(0, lpSource, 0, DDBLT_WAIT | DDBLT_KEYSRC, 0);

   //Enable the overlay on certain part of the screen:
   RECT DestRect;
   DestRect.left = 100;
   DestRect.top = 100;
   DestRect.right = DestRect.left + OVERLAY_WIDTH;
   DestRect.bottom = DestRect.top + OVERLAY_HEIGHT;
   DDOVERLAYFX fx = {0};
   fx.dwSize = sizeof(fx);
   fx.dckDestColorkey.dwColorSpaceLowValue  = 0;
   fx.dckDestColorkey.dwColorSpaceHighValue = 0xffffffff;
   lpOverlay->UpdateOverlay(0, lpPrimary, &DestRect, DDOVER_SHOW | DDOVER_DDFX | DDOVER_KEYSRCOVERRIDE, &fx);


//If you would want to hide the overlay:
//lpOverlay->UpdateOverlay(0, lpPrimary, 0, DDOVER_HIDE, 0);
Back to top
View user's profile Send private message
bio777
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 3

PostPosted: Thu Jul 30, 2009 9:18 am    Post subject: Reply with quote

tombana wrote:
This is a part of my directdraw overlay code. You'll need to alter some stuff to make it work for you:


Thank you, I have went over the code and learned some things about directdraw.

I will try to implement it.

Edit: After some modifications I keep getting "CreateSurface(Overlay) failed!"
Just to clarify, which version are you using? It's not 7 because of the DDSURFACEDESC ddsd;
Back to top
View user's profile Send private message
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