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

Conversation

mkurkute
Copy link

@mkurkute mkurkute commented Mar 5, 2024

Please check the link.

4th parameter (lpNumberOfBytesWritten) is expecting pointer to DWORD value when you pass NULL to that parameter it attempts to write DWORD to null pointer which causes exception.

To fix this problem, you need to declare a DWORD variable and pass its address as the fourth parameter, like this:

DWORD at;
iWriteFile(File, WriteBuf, WriteBufNext, &at, NULL)

This way, you can also check the value of 'at' after the function returns to see if it matches the expected number of bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant