Hello again,
Error 87, commonly known as ERROR_INVALID_PARAMETER and described as The parameter is incorrect.
A possible cause for the failure is that the Offset and OffsetHigh members of the OVERLAPPED structure are not set to zero.
In many cases, the function calls may succeed if you do not explicitly set OVERLAPPED.Offset and OVERLAPPED.OffsetHigh to zero. However, this is usually either because the OVERLAPPED structure is static or global and therefore is initialized to zero, or the OVERLAPPED structure is automatic (local) and the contents of that location on the stack are already zero. You should explicitly set the OVERLAPPED.Offset and OVERLAPPED.OffsetHigh structure members to zero.
Hope this answers all your queries, if not please do repost back.
If an Answer is helpful, please click "Accept Answer" and upvote it : )
Regards,