Getting the hStdOutput from CreateProcess.hStdOutput [modified]
-
Hi, Having some trouble getting a char* from the Stupinfo.hStdOutput which is a HANDLE. STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; HANDLE h; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); char* tesst="test"; tesst=Stupinfo.hStdOutput; send(AcceptSocket, tesst, strlen(tesst), 0); I know its not going to be easy unless there is simple convesion. but ive seen methods which output to .txt file for some reason.. but i dont see why you couldn't get the char* Please Help -- modified at 17:31 Monday 31st July, 2006
-
Hi, Having some trouble getting a char* from the Stupinfo.hStdOutput which is a HANDLE. STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; HANDLE h; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); char* tesst="test"; tesst=Stupinfo.hStdOutput; send(AcceptSocket, tesst, strlen(tesst), 0); I know its not going to be easy unless there is simple convesion. but ive seen methods which output to .txt file for some reason.. but i dont see why you couldn't get the char* Please Help -- modified at 17:31 Monday 31st July, 2006
You have to create a HANDLE *before* calling CreateProcess. Usually people use CreatePipe, but you can also pass socket handles as well. Then you ReadFile/WriteFile to the handle to read/write data.
-
You have to create a HANDLE *before* calling CreateProcess. Usually people use CreatePipe, but you can also pass socket handles as well. Then you ReadFile/WriteFile to the handle to read/write data.
Could you please show me some code? STARTUPINFO Stupinfo; PROCESS_INFORMATION ProcessInfo; char* procnm="Test.exe"; char* tesst; BOOL readIntoMemory; HANDLE h, hWritePipe; LPSECURITY_ATTRIBUTES lpPipeAttributes; DWORD nSize; LPWSTR lpwString = L""; lpwString = (LPWSTR)procnm; LPVOID inBuffer; DWORD nBytesToRead; LPDWORD nBytesRead, lpNumberOfBytesWritten; DWORD bytestowrite; IntPtr StdOutput; Stupinfo.dwX=0; Stupinfo.dwY=0; Stupinfo.hStdOutput=h; CreateProcess(NULL, lpwString, NULL, NULL, FALSE, 0, NULL, NULL, &Stupinfo, &ProcessInfo); ReadFile( h, inBuffer, nBytesToRead, nBytesRead, NULL); WriteFile( (HANDLE)AcceptSocket, inBuffer, bytestowrite, lpNumberOfBytesWritten, NULL); how to use the WriteFile to get a char*?? and do i have it setup correctly? -- modified at 19:25 Monday 31st July, 2006