[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 2/4] Use PutString to manage short WriteFile
From: Owen Smith <owen.smith@xxxxxxxxxx> PutString will now deal in UCHARs, so the calculated lengths need to be translated into byte counts. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- msbuild.bat | 0 src/monitor/monitor.c | 69 +++++++++++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 38 deletions(-) mode change 100644 => 100755 msbuild.bat diff --git a/msbuild.bat b/msbuild.bat old mode 100644 new mode 100755 diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 112ce65..6068f5c 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -399,6 +399,32 @@ __RemoveEntryList( ListEntry->Blink = ListEntry; } +static VOID +PutString( + IN HANDLE Handle, + IN PUCHAR Buffer, + IN DWORD Length + ) +{ + DWORD Offset; + + Offset = 0; + while (Offset < Length) { + DWORD Written; + BOOL Success; + + Success = WriteFile(Handle, + &Buffer[Offset], + Length - Offset, + &Written, + NULL); + if (!Success) + break; + + Offset += Written; + } +} + DWORD WINAPI PipeThread( IN LPVOID Argument @@ -432,8 +458,6 @@ PipeThread( LeaveCriticalSection(&Context->CriticalSection); for (;;) { - DWORD Written; - (VOID) ReadFile(Pipe->Pipe, Buffer, sizeof(Buffer), @@ -455,11 +479,9 @@ PipeThread( ResetEvent(Overlapped.hEvent); - WriteFile(Context->Device, + PutString(Context->Device, Buffer, - Length, - &Written, - NULL); + Length); } EnterCriticalSection(&Context->CriticalSection); @@ -752,15 +774,12 @@ DeviceThread( ListEntry != &Context->ListHead; ListEntry = ListEntry->Flink) { PMONITOR_PIPE Instance; - DWORD Written; Instance = CONTAINING_RECORD(ListEntry, MONITOR_PIPE, ListEntry); - WriteFile(Instance->Pipe, + PutString(Instance->Pipe, Buffer, - Length, - &Written, - NULL); + Length); } LeaveCriticalSection(&Context->CriticalSection); } @@ -791,34 +810,8 @@ fail1: return 1; } -static VOID -PutString( - IN HANDLE Handle, - IN PTCHAR Buffer, - IN DWORD Length - ) -{ - DWORD Offset; - - Offset = 0; - while (Offset < Length) { - DWORD Written; - BOOL Success; - - Success = WriteFile(Handle, - &Buffer[Offset], - Length - Offset, - &Written, - NULL); - if (!Success) - break; - - Offset += Written; - } -} - #define ECHO(_Handle, _Buffer) \ - PutString((_Handle), TEXT(_Buffer), (DWORD)_tcslen(_Buffer)) + PutString((_Handle), (PUCHAR)TEXT(_Buffer), (DWORD)_tcslen((_Buffer)) * sizeof(TCHAR)) static VOID MonitorAdd( -- 2.8.3 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |