iDroid-Project/openiBoot — Issue #19: Cannot use windows oibc to receive a file
Author: jbry
Created: 2011-11-20 06:33:46+00:00
State: open

ReceiveFile on the window oibc will deadlock.

The function is written in a way that appears to always make that happen (that or a lucky race condition before stopped it).

There are several issues:
1) After using ReadFile with the overlapped flag set, GetOverlappedResult should be used to check how many bytes were read, as the parameter will always come back 0. (This can also be used instead of WaitForSingleObject)
2) EnterCriticalSection for gReadSection seems to be entered before WriteFile is called. The gReadSection is locked by waiting for the device to output some information, this of course won't happen as it is sitting idly. The EnterCriticalSection should be moved after the WriteFile
3) WriteFile and ReadFile in receiveFile both need to have the &rfOverlapped parameter added to them, otherwise you will get an error
4) sprintf when building the receivefile command, %ul is not a valid token (VS2010 C++ express at least)

The rest of it seems to work fine