SDL Input in an existing window

I’d like to use SDL’s input handling in an existing window. Is this possible? Using 1.3.

I have the hWnd and any other things I might need. Essentially all that’s different is that I want to pass a handle or an instance rather than have SDL create me a widthXheight window.

SDL_CreateWindowFrom IIRC------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

Sounds promising but it causes the parent application to crash.
It specifically breaks on the line: SDL_Window *w = SDL_CreateWindowFrom(hWnd);
Dump file tells me the exception:
The thread tried to read from or write to a virtual address for which it does not have appropriate access.

Code:

HWND hWnd;
hWnd = FindWindow(NULL, TEXT("Test Window"));

SDL_Init(SDL_INIT_VIDEO);

SDL_Window *w = SDL_CreateWindowFrom(hWnd);

SDL_ShowWindow(w);

SDL_EnableKeyRepeat(500, 30);

Is this window in another application? If that’s the case, then I am fairly confident I know the root of the issue but am unaware of a work-around that would not require modifying SDL (SDL modifies storage reserved for the window, since this is in another process it would cause an access violation); but I’m unsure as to why you’d be attempting this if that were the case.------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

Nathaniel J Fries wrote:

Is this window in another application? If that’s the case, then I am fairly confident I know the root of the issue but am unaware of a work-around that would not require modifying SDL (SDL modifies storage reserved for the window, since this is in another process it would cause an access violation); but I’m unsure as to why you’d be attempting this if that were the case.

It is a seperate application of which I’m injecting into.

I’m using it to try and learn about modifying existing application functionality.
There’s no specific end goal project, I’m just interested in learning it.
An example would be the various mods for roguelikes.
Such as a dwarf fortress mod that reads the base game data from the application and provides isometric or 3d graphics over the standard display.

I can get CEGUI to draw over the existing window on an external application with a DLL hook, and was hoping to use SDL’s simple yet effective input management to pass the input to CEGUI from the same window.

If you are trying to hook into an existing window in a different app and
have the hWnd of the window, try CreateRemoveThread() and
AttachThreadInput(). You may need to hook into an existing DLL to allow for
code injection. After that, you can simply send messages from that thread to
your app. Not quite as straightforward, but could work.

PatrickOn Thu, Jun 2, 2011 at 3:46 AM, Section wrote:

Nathaniel J Fries wrote:

Is this window in another application? If that’s the case, then I am
fairly confident I know the root of the issue but am unaware of a
work-around that would not require modifying SDL (SDL modifies storage
reserved for the window, since this is in another process it would cause an
access violation); but I’m unsure as to why you’d be attempting this if that
were the case.

It is a seperate application of which I’m injecting into.

I’m using it to try and learn about modifying existing application
functionality.
There’s no specific end goal project, I’m just interested in learning it.
An example would be the various mods for roguelikes.
Such as a dwarf fortress mod that reads the base game data from the
application and provides isometric or 3d graphics over the standard display.

I can get CEGUI to draw over the existing window on an external application
with a DLL hook, and was hoping to use SDL’s simple yet effective input
management to pass the input to CEGUI from the same window.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Patrick Baggett wrote:

If you are trying to hook into an existing window in a different app and have the hWnd of the window, try?CreateRemoveThread() and AttachThreadInput(). You may need to hook into an existing DLL to allow for code injection. After that, you can simply send messages from that thread to your app. Not quite as straightforward, but could work.

Patrick

That would work fine if he were using windows API directly.
In the case of SDL, this will still cause problems because of SDL’s use of GetWindowWord/Long/LongPtr------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/