TakeCommandIPC( "START", args )

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,376
39
Albuquerque, NM
prospero.unm.edu
#1
I want to attach a console window programatically. TakeCommandIPC() supports this, but I suspect the docs for the START command need revision or clarification. According to the help file, pszArguments should be the PID, in hex, of the process to attach. Well....

A hex PID with a leading 0X does nothing; the function returns 2 (not found?)

A decimal PID also does nothing and returns 2.

A hex PID with no leading 0X crashes Take Command, leaving TCC stranded....

A hex PID with no leading 0X, followed by a space and another number (e.g. just a zero) works! ...but still returns 2. Still not right, but close enough for Take Command to fudge it?

So: I think there is a second numeric argument, not explained in the docs, which is required but not critical. But what? And in what format?
 
#2
Hmmm! I tried it with a simple TakeCommandIPC(L"START", L"A08"). The console of that target process changed its font to the (new) hidden console font and did not disappear. Then TCMD crashed.
Code:
TCMD  16.02.48
Module=G:\TC16\TakeCmd.dll
Address=1004337D
Exception=C0000005
EAX=06851E8C  EBX=7633BDE8  ECX=00000000  EDX=77B370F4
ESI=06824C58  EDI=00000000  EBP=01BBE3FC  ESP=01BBE198
CS=0000001B  DS=00000023  ES=00000023  SS=00000023
Flags=00010246

Stack:
1 : TakeCmd.dll 0001:0004237d
 
#3
Then, after noticing that the docs say "Attach a hidden console window whose hex PID is in pszArguments", I hid the console in question first and tried again ... with the same result.

When I tried L"0XA08", TCMD opened a new tab with a **new** instance of TCC.

The results are the same with TCMDv15.

Since, in my first experiment, with the arg L"A08", TCMD managed to change the console's font, I suppose it correctly identified the console. But something went wrong after that.
 
#4
Thinking TCMD might need to write to those strings, I tried again like this, with the same result.

Code:
WCHAR szCommand[4096] = L"START", szArgs[4096] = L"884";
TakeCommandIPC(szCommand, szArgs));