Re: Allocating console

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Slava M. Usov (stripit.slough_at_gmx.net)
Date: 03/01/04


Date: Mon, 1 Mar 2004 14:55:39 +0100


"qfel" <as_in_nick@astercity.net> wrote in message
news:c1v8i4$2v84$1@mamut.aster.pl...
> I'm injecting my DLL which uses console into some process, which runs in
> GUI subsystem. I can use AllocConsole in DLL, but CRTL's stdin/out/err and
> STL's cin/cout/cerr aren't reinitialized, so I cannot use them. I thought
> I could inject the DLL, alloc console, free the DLL and inject it again,
> but it should work only with static linked libraries (target process can
> use msvcr70 etc so initialization won't be performed each time my DLL is
> loaded). Or is there any way to re-init cin/cout/cerr?

stdin, stdout and stderr are simply pointers to the FILE structure that
represents the standard streams. So you can simply overwrite that structure
with whatever other stream you have. Notice you cannot just overwrite the
pointers, because they may be cached somewhere.

So: *stdout = *fopen();

S



Relevant Pages

  • Re: SetWindowsHookEx
    ... automatically inject into all programs. ... It sets the global hook on the ... DLL injecting - in all likelyhook SetWindowsHook returns before the DLL has ... with your shared-section, then the gHook variable (which contains ...
    (microsoft.public.vc.language)
  • Re: undestroyable process
    ... hooking SSDT does not seem to be the task he is able to handle ... program as dll and attach it to some running critical system ... will eventually learn some basic Windows concepts while trying to ... And to inject a dll he would need to run an executable that injects the code, so your objections to b)point would still apply. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateRemoteThread in DLL
    ... Why is it you think that the pAddr is the first executable address of the function you ... I am trying to inject some code into a foreign process with the aid of a DLL. ...
    (microsoft.public.vc.mfc)
  • Re: MS Detours system wide / global hook
    ... There are also registry keys which allows you to register your DLLs ... Then I remember you can inject an arbitrary ... DLL into every process by using some undocumented features of the ... I can't see to find an explanation of how detours can be used to hook ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateRemoteThread in DLL
    ... I am trying to inject some code into a foreign process with the aid of a DLL. ... You can instrument Test with OutputDebugString and view the output with the ...
    (microsoft.public.vc.mfc)