The server creates two anonymous uni-directional pipes and maps them to stdin and stdout during the CreateProcess call. According to Microsoft Developer Network documentation, if a standard handle has been redirected to refer to a file or a pipe, the handle can only be used by the ReadFile and WriteFile functions. This precludes normal C functions such as gets or printf. Since the server will never terminate the external program process, it is imperative that the external program recognize a read or write failure on the pipes and exit the process. In addition, the external program should exit the process if it reads an unrecognized command.
The external program may obtain values for the read and write handles using the following calls:
readPipe=GetStdHandle(STD_INPUT-HANDLE) and writePipe=GetStdHandle(STD_OUTPUT_HANDLE)