﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3697	_WinAPI_GetOverlappedResult fails to set the [out] parameter $iBytes in some cases	AlanParry	Jpm	"_WinAPI_GetOverlappedResult does not set the $iBytes [out] parameter in the case where GetOverlappedResult() returns False.

However the $iBytes has a meaningful value in the case when it returns False and GetLastError()==ERROR_MORE_DATA
which can occur when using Named Pipes in message mode (see here if you wish to read about named pipes:[ https://docs.microsoft.com/en-us/windows/desktop/ipc/named-pipe-client]).

Note though that it should return the value for all cases regardless of the reason for the error.

The code back 3.3.8.1 was correct
In at least the following versions it isn't: 3.3.9.22, 3.3.12.0, 3.3.13.19, 3.3.14.5, 3.3.15.0, 3.3.15.1

The incorrect code is

{{{
Func _WinAPI_GetOverlappedResult($hFile, $tOverlapped, ByRef $iBytes, $bWait = False)
	Local $aResult = DllCall(""kernel32.dll"", ""bool"", ""GetOverlappedResult"", ""handle"", $hFile, ""struct*"", $tOverlapped, ""dword*"", 0, _
			""bool"", $bWait)
	If @error Or Not $aResult[0] Then Return SetError(@error, @extended, False)

	$iBytes = $aResult[3]
	Return $aResult[0]
EndFunc   ;==>_WinAPI_GetOverlappedResult
}}}


The old 3.3.8.1 CORRECT code (though missing the struct* change) was

{{{
Func _WinAPI_GetOverlappedResult($hFile, $pOverlapped, ByRef $iBytes, $fWait = False)
	Local $aResult = DllCall(""kernel32.dll"", ""bool"", ""GetOverlappedResult"", ""handle"", $hFile, ""ptr"", $pOverlapped, ""dword*"", 0, ""bool"", $fWait)
	If @error Then Return SetError(@error, @extended, False)
	$iBytes = $aResult[3]
	Return $aResult[0]
EndFunc   ;==>_WinAPI_GetOverlappedResult
}}}

Regards
Alan Parry
"	Bug	closed	3.3.15.3	Standard UDFs	3.3.14.5	None	Fixed	_WinAPI_GetOverlappedResult  $ERROR_MORE_DATA	
