Jungo WinDriver  
Official Documentation

◆ WDU_StreamWrite()

DWORD DLLCALLCONV WDU_StreamWrite ( _In_ HANDLE  hStream,
_In_ const PVOID  pBuffer,
_In_ DWORD  bytes,
_Outptr_ DWORD *  pdwBytesWritten 
)

Writes data from the application to a write stream.

For a blocking stream (fBlocking=TRUE - see WDU_StreamOpen()), the call to this function is blocked until the entire data (*pBuffer) is written to the stream's data buffer, or until the stream's attempt to write to the device times out (i.e the timeout period for transfers between the stream and the device, as set in the dwRxTxTimeout WDU_StreamOpen() parameter, expires). For a non-blocking stream (fBlocking=FALSE), the function writes as much of the write data as currently possible to the stream's data buffer, and returns immediately. For both blocking and non-blocking transfers, the function returns the amount of bytes that were actually written to the stream within the pdwBytesWritten parameter.

Parameters
[in]hStreamA unique identifier for the stream, as returned by WDU_StreamOpen().
[in]pBufferPointer to a data buffer containing the data to write to the stream.
[in]bytesNumber of bytes to write to the stream.
[out]pdwBytesWrittenPointer to a value indicating the number of bytes actually written to the stream.
Returns
WinDriver Error Code
DWORD dwStatus;
DWORD dwPipeNum, dwSize, dwBytesTransferred, cmd = MENU_RW_READ_PIPE;
VOID *pBuffer = NULL;
DWORD dwBufferSize = 0x20000;
dwStatus = WDU_StreamOpen(hDevice, dwPipeNum, dwBufferSize,
dwSize, TRUE, 0, TRANSFER_TIMEOUT, &stream);
if (dwStatus)
{
ERR("ReadWritePipesMenu: WDU_StreamOpen() failed. "
"error 0x%lx (\"%s\")\n", dwStatus, Stat2Str(dwStatus));
goto End_transfer;
}
dwStatus = WDU_StreamStart(stream);
if (dwStatus)
{
ERR("ReadWritePipesMenu: WDU_StreamStart() failed. error "
"0x%lx (\"%s\")\n", dwStatus, Stat2Str(dwStatus));
goto End_transfer;
}
if (cmd == MENU_RW_READ_PIPE)
{
dwStatus = WDU_StreamRead(stream, pBuffer, dwSize,
&dwBytesTransferred);
}
else
{
dwStatus = WDU_StreamWrite(stream, pBuffer, dwSize,
&dwBytesTransferred);
}
if (dwStatus)
{
BOOL fIsRunning;
DWORD dwLastError;
DWORD dwBytesInBuffer;
dwStatus = WDU_StreamGetStatus(stream, &fIsRunning,
&dwLastError, &dwBytesInBuffer);
if (!dwStatus)
dwStatus = dwLastError;
}
#define NULL
Definition: kpstdlib.h:268
#define TRUE
Definition: kpstdlib.h:264
const char *DLLCALLCONV Stat2Str(_In_ DWORD dwStatus)
Retrieves the status string that corresponds to a status code.
DWORD DLLCALLCONV WDU_StreamClose(_In_ WDU_STREAM_HANDLE hStream)
Closes an open stream.
DWORD DLLCALLCONV WDU_StreamGetStatus(_In_ WDU_STREAM_HANDLE hStream, _Outptr_ BOOL *pfIsRunning, _Outptr_ DWORD *pdwLastError, _Outptr_ DWORD *pdwBytesInBuffer)
Returns a stream's current status.
DWORD DLLCALLCONV WDU_StreamWrite(_In_ HANDLE hStream, _In_ const PVOID pBuffer, _In_ DWORD bytes, _Outptr_ DWORD *pdwBytesWritten)
Writes data from the application to a write stream.
DWORD DLLCALLCONV WDU_StreamRead(_In_ HANDLE hStream, _Outptr_ PVOID pBuffer, _In_ DWORD bytes, _Outptr_ DWORD *pdwBytesRead)
Reads data from a read stream to the application.
DWORD DLLCALLCONV WDU_StreamStart(_In_ WDU_STREAM_HANDLE hStream)
Starts a stream, i.e starts transfers between the stream and the device.
DWORD DLLCALLCONV WDU_StreamOpen(_In_ WDU_DEVICE_HANDLE hDevice, _In_ DWORD dwPipeNum, _In_ DWORD dwBufferSize, _In_ DWORD dwRxSize, _In_ BOOL fBlocking, _In_ DWORD dwOptions, _In_ DWORD dwRxTxTimeout, _Outptr_ WDU_STREAM_HANDLE *phStream)
Opens a new data stream for the specified pipe.
PVOID WDU_STREAM_HANDLE
Definition: wdu_lib.h:14