Skip to content

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

Open
mkurkute wants to merge 1 commit into
microsoft:mainfrom
mkurkute:WinServerR2Fix_branch
Open

WriteFile to fail is that you are passing NULL as the fourth parameter, which is not allowed for older Windows vision.#78
mkurkute wants to merge 1 commit into
microsoft:mainfrom
mkurkute:WinServerR2Fix_branch

Conversation

@mkurkute

@mkurkute mkurkute commented Mar 5, 2024

Copy link
Copy Markdown

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