Add support of standard streams redirection in dbgshim
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 404
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 35
Description
Currently it's impossible to redirect input/output streams of the process created with `CreateProcessForLaunch()`. Such feature can be useful for debugger implementation for Unix.
However PAL version of `CreateProcessW` supports stream redirection.
I propose to extend the API of the `dbgshim` library with something like this:
```c++
EXTERN_C HRESULT
CreateProcessForLaunchEx(
__in LPWSTR lpCommandLine,
__in BOOL bSuspendProcess,
__in LPVOID lpEnvironment,
__in LPCWSTR lpCurrentDirectory,
__out PDWORD pProcessId,
__out HANDLE *pResumeHandle,
__out HANDLE *pStdInHandle,
__out HANDLE *pStdOutHandle,
__out HANDLE *pStdErrHandle);
```
Also a special portable API for `HANDLE` reading and writing will be added:
```c++
typedef VOID (*PREADHANDLE_CALLBACK)(PVOID pBuffer, DWORD dwBufferSizeInBytes, PVOID parameter);
EXTERN_C HRESULT
RegisterForStandardOutput(
__in HANDLE hStdOutHandle,
__in PREADHANDLE_CALLBACK pfnOutCallback,
__in HANDLE hStdErrHandle,
__in PREADHANDLE_CALLBACK pfnErrCallback,
__in PVOID parameter,
__out PVOID *ppListenerToken);
EXTERN_C HRESULT
WriteStandardHandle(
__in HANDLE hStdInHandle,
__in LPCVOID lpBuffer,
__in DWORD dwNumberOfBytesToWrite,
__out DWORD *pdwNumberOfBytesWritten
);
EXTERN_C HRESULT
CloseStandardHandle(
__in HANDLE hStandardHandle);
```
In such case debugger can handle input/output of the newly created process in a portable way.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.