Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteFile to fail is that you are passing NULL as the fourth parameter, which is not allowed for older Windows vision. #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ BOOLEAN BufferBytes(HANDLE File, void* Buf, unsigned long BufSize)

if (BufSize > CurSpace && CurSpace < WRITEBUF_SIZE) {
// Flush write buffer to make space for the new bytes.
if (!WriteFile(File, WriteBuf, WriteBufNext, NULL, NULL)) {
DWORD at;
if (!WriteFile(File, WriteBuf, WriteBufNext, &at, NULL)) {
return FALSE;
}
WriteBufNext = 0;
Expand All @@ -70,7 +71,8 @@ BOOLEAN BufferBytes(HANDLE File, void* Buf, unsigned long BufSize)
if (BufSize > CurSpace) {
// The buffer is empty and we still don't have enough space.
// Bypass the buffer and write directly to the file.
if (!WriteFile(File, Buf, BufSize, NULL, NULL)) {
DWORD at;
if (!WriteFile(File, Buf, BufSize, &at, NULL)) {
return FALSE;
}
} else {
Expand All @@ -83,7 +85,8 @@ BOOLEAN BufferBytes(HANDLE File, void* Buf, unsigned long BufSize)

BOOLEAN FlushBufferBytes(HANDLE File)
{
if (!WriteFile(File, WriteBuf, WriteBufNext, NULL, NULL)) {
DWORD at;
if (!WriteFile(File, WriteBuf, WriteBufNext, &at, NULL)) {
return FALSE;
}
WriteBufNext = 0;
Expand Down