News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Buffer alignment

Started by sinsi, December 18, 2024, 03:16:28 PM

Previous topic - Next topic

sinsi

I was looking at ReadDirectoryChangesW and came across something I've not seen in the MS documentation.
Quote[out] lpBuffer
A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned.
I thought Windows was pretty relaxed about buffer alignment, but later
QuoteReadDirectoryChangesW fails with ERROR_NOACCESS when the buffer is not aligned on a DWORD boundary.

Wonder why align 4 is so important?


Greenhorn

The alignment is important because the FILE_NOTIFY_INFORMATION structure is variable in length, because of it's last member FileName.

The other structure members are DWORDs, so you must align at 4 bytes (at least?).

8 byte and 16 byte alignment should also work ?! But this is just a guess by myself.
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.