Win32 Thread Handles - Switching to Binary Mode

I use CreatePipe to create descriptors, which I then pass when the child process starts.

The child process writes binary information to the standard version, which is redirected to the channel I created.

However, when it comes to writing the number "10", everything is hard and I get too many output characters. I assume this is because the stream is open in text mode and it automatically adds 13.

Is there a way in Win32 that I can take the HANDLE returned from CreatePipe and change the stream mode to binary, just as I could with the _setmode function if I had FILE *? Or is there a way to translate it to FILE *, so I can use _setmode?

Code example:

HANDLE hOutputReadTmp,hInputWriteTmp; SECURITY_ATTRIBUTES sa; bool Binary = true; // Set up the security attributes struct. sa.nLength= sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; if (!CreatePipe(&hInputRead,&hInputWriteTmp,&sa,0)) { Error = "Unable to Create Input Pipe"; return false; }; if (Binary == true) { //Put a magic something here to change the hInputRead stream to Binary. //_setmode(_fileno(hInputRead,_O_BINARY); } 

EDIT

This is probably more related to writing CHILD PROCESS to stdout as a text stream. Give me a minute to take a look at this, and I could go back and delete this whole post!

+2
source share

Source: https://habr.com/ru/post/1497626/


All Articles