Sign in to follow this  
zzz822163

OpenGL how to steal texture from directdraw application?

Recommended Posts

Write a proxy ddraw.dll file that intercepts all DirectDraw calls, then passes them off to the real ddraw.dll.
Or hook an application as it starts up.

Nitpick: There's no such thing as a texture in a DirectDraw application, just surfaces. A texture is a collection of surfaces, and only exists in D3D.

Share this post


Link to post
Share on other sites
Quote:
Original post by zzz822163
thanks Evil Steve .
do as you tell me ,i can capture screen.
but can i get the image resource?
Well, you'll be able to accept all calls to DDraw, so when you get a surface unlock call you can just read the contents of the surface.

However, remember that there's about 5 different DirectDraw versions; you'll need to support all of them if you want your DLL to work for all apps that use DirectDraw.

Share this post


Link to post
Share on other sites
to Evil Steve
read the contents of the surface after surface unlock call,i can get screen,
but i cannot get the image resource.
i want to get the bitmap the application load.

Share this post


Link to post
Share on other sites
Quote:
Original post by zzz822163
i want to get the bitmap the application load.
Short answer: You can't.
Long answer: How do you know it's a bitmap that the application is loading and not a code-generated resource, or some other file format?
Assuming it is actually an image in a file of some sort, the code will load the file, decompress / decrypt it, then create a DirectDraw surface and copy the bits in. That means that there doesn't have to be a source file for the image.

Share this post


Link to post
Share on other sites
This sort of code is very low level, and you will have no knowledge of where the image came from. It could come from a local file, over the web or be noise generated from a microphone.

If you're wanting to intercept calls to DirectDraw and work it back to which bitmap the game/application originally loaded the data from you're out of luck.

However, if you're wanting to save the data to a disk so that you can load it up in a graphics program you follow Steve's advice and simply write the data to a file yourself. The bitmap format is easy enough to follow and documented in numerous places online. Try wotsit.org.


hth
Jack

EDIT: Too slow!

Share this post


Link to post
Share on other sites
Quote:
Original post by zzz822163
I am appreciated for your Enthusiastic help .
In fact,i want to replace the picture in the game.
Is this an impossible mission?
If you want to replace it, then you don't need to know where it came from. When the application locks the surface and puts data into it, you can just put your own data in. The application presumably creates the resources in the same order each time it runs, and if it doesn't you can always check the bit data going in to see if it's the one you want to replace.

Share this post


Link to post
Share on other sites
When the application locks the surface and puts data into it, you can just put your own data in.

Well,I just don't know how to check the bit data if it's the one i want to replace on the surface ,because there is lots of bit data .
I only want to replace some content of the surface,not all content.

Share this post


Link to post
Share on other sites
Quote:
Original post by zzz822163
Well,I just don't know how to check the bit data if it's the one i want to replace on the surface ,because there is lots of bit data .
I only want to replace some content of the surface,not all content.
There's two steps:
1. Recognise that this is the surface you're interested in
2. Replace the data you need

First, you'll want to save the surface to a BMP file every time it's Unlock()ed, and then you can see what surface you need, and what it looks like after it's been unlocked.

You now know the dimensions and the bit data of the surface you're interested in, so your code can ignore any surfaces that aren't the correct dimensions (At Lock() to save you buffering the data to check in Unlock()).
Then, each time a surface of the correct size is Unlock()ed, you can check the surface bit data to see if it's what you're looking for. You can probably get away with only checking some parts of the surface, I doubt you'll have to check the whole thing.

Once you've identified that this is the surface you want to update, you can update it in your proxy Unlock() function and then call the real DDraw surface Unlock() function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this