• Advertisement
Sign in to follow this  

Console Attachment problem

This topic is 2333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what im doing is injecting a dll into my program. This dll is then allocating a console and outputting debug information. The problem is when im done with my console and i close it the program also closes with it. it's almost like the console becomes one with the program. Any help on how to resolve this issue? i am using the following code to make and write to my console




AllocConsole();
freopen("CONOUT{:content:}quot;, "wb", stdout);

printf(" DEBUG CONSOLE YAY ");


fclose(stdout);
FreeConsole();

Share this post


Link to post
Share on other sites
Advertisement
if i use createprocess() then it will have it's own address space. I still want access to the program im wanting to debug's addresspace as well. Will this still work? Also createprocess won't work with a dll correct? the debug console code would need to be in a .exe?

Share this post


Link to post
Share on other sites
You have two options with consoles. One is to create one yourself in the process. When the process dies, so will the console. A second option is to attach to the parent console, if any. If you then run the program from the command line, it will attach to that console, which will persist when the program ends.

I believe Seraph was advocating the latter, except with a stub executable that would call CreateProcess() on the executable you want to inject. I do not believe Seraph was not suggesting you invoke CreateProcess() inside the injected process, so I won't try to address your questions (I don't know the answers anyway).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement