• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Semei

Help me understand how to hook DX application, to copy screen buffer

5 posts in this topic

I'm developing application in C#, and i'm currently strugling in finding the general correct steps required to sucessfully hook DX function in order to send screen buffer to my main application for some processing.

Here is a list of what i think i should be doing so far:

1. Attach a custom C++ dll into target application, from my main application (written in C#)
2. DLL hooks some (Device Present and Reset) functions in d3d9.dll that is loaded in target application.
3. After even occurs, i need to send a callback event from the custom dll to my main application, containing the screen data

Can someone please correct me where i could have gone wrong and help me with point 3? I'm not expirerenced in dll callbacks, let alone not a C++ interop guru and im having a trouble understanding how i could possibly have a callback to my main application from a C++ dll loaded in another application.
-1

Share this post


Link to post
Share on other sites
[quote name='DevLiquidKnight' timestamp='1341269391' post='4955091']
Why don't you simply use [url="http://research.microsoft.com/en-us/projects/detours/"]detours[/url].
[/quote]

Why would i use complete library only to install a hook to 2 functions? Its also not free for commercial and limited in express edition, lets not be ridicilous here.
-1

Share this post


Link to post
Share on other sites
[quote name='Shuun' timestamp='1341380037' post='4955533']
Why would i use complete library only to install a hook to 2 functions? Its also not free for commercial and limited in express edition, lets not be ridicilous here.
[/quote]
Because its a lot simpler and safer then doing it manually. If your doing this for a commercial reason, I see no reason why you wouldn't benefit from buying it, and I am pretty sure the express version is all your going to need for what you specified. I also would question why your trying to do this? Typically this is the type of thing game hacks do, which I am willing to guess is exactly what your trying to do.

But a quick google search produced the following: [url="http://spazzarama.com/2010/03/29/screen-capture-with-direct3d-api-hooks/"]http://spazzarama.co...ct3d-api-hooks/[/url] Edited by DevLiquidKnight
-1

Share this post


Link to post
Share on other sites
[quote name='DevLiquidKnight' timestamp='1341381233' post='4955536']
I also would question why your trying to do this? Typically this is the type of thing game hacks do, which I am willing to guess is exactly what your trying to do.

But a quick google search produced the following: [url="http://spazzarama.com/2010/03/29/screen-capture-with-direct3d-api-hooks/"]http://spazzarama.co...ct3d-api-hooks/[/url]
[/quote]

Copying screen buffer is not a hack, it does not change or automate any of the behaviour of the software, if doing that would be considered hack, then using things like fraps or any other screen recording software would be bannable offense.

I know about that spazzarma api hook, but its overly bloated with extra threads, and probably even changes running application by running CLR runtime host on it, and i dont want that. Also requires your assembly to be installed in GAC.
-1

Share this post


Link to post
Share on other sites
You can't callback from a DLL located in separate process, they belong in different memory spaces. Your callback will be located in your own process's memory space, whereas the DLL hooked into the game will be in the game's process's memory space. They can't communicate via native function pointers (callbacks).

You will need to use OS-provided functions to achieve inter-process communication at this point. An interesting solution is to use Windows messages to send "I have a frame ready" events (remember to use RegisterWindowMessage to get a system-wide message ID), and use a suitably sized shared memory section to dump the frame buffer in. Then in your main application, you monitor your message queue, and when you receive a message like that, you read the shared memory to get the screen data!

You will need to add synchronization however, or you might end up skipping frames. Obviously you can't send back messages to the game without hooking into its message loop, so instead you want to write some kind of header to shared memory, something along the lines of "ok I'm ready, dump the next frame" with the DLL hook waiting until it reads this. Or you might be happy with skipping frames (depending on what kind of post-processing you are doing, you may not be able to keep up with the game anyway).

Or just ditch messages altogether and use pipes+shared memory to communicate, etc... look up IPC (inter-process communication) and find something that can be done in the hook without too much hassle and overhead.
1

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  
Followers 0