JwaAccCtrl uses enum size 1 instead of 4
Original Reporter info from Mantis: sternenseemann
-
Reporter name: Lukas
Original Reporter info from Mantis: sternenseemann
- Reporter name: Lukas
Description:
JwaAccCtrl contains various records and enums for interfacing with the WinApi. The C++ WinApi assumes that all enums are 4 bytes in size which also influences its assumptions about record size/alignment. However, JwaAccCtrl's Enums are of size 1 which breaks interfacing with certain WinApi functions, like SetEntriesInAclA.
Steps to reproduce:
I used the latest Windows i386 fpc (ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/i386-win32/fpc-3.3.1.i386-win32.zip), but I was also able to reproduce this bug on x86_64 fpc and the latest stable release.
To demonstrate the issue I use the attached test.pas and compile it using: C:\Users\Administrator\Downloads\fpc-3.3.1.i386-win32\bin\i386-win32\fpc.exe -Fu"C:\Users\Administrator\Downloads\fpc-3.3.1.i386-win32\units\i386-win32*" test.pas
When running it I get the following output:
test.exe
EXPLICIT_ACCESS_A size: 20 ENUM SIZE: 1
I would expect EXPLICIT_ACCESS_A to be of size 32 on i386 because all Enums inside of it should be of size 4. This breaks interfacing with WinApi functions like in this case SetEntriesInAclA (https://docs.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-setentriesinacla) which assumes a size of 32. Using this function with a JwaAccCtrl record will always result in Error 87 (Invalid Parameter). I also attached an example function which is affected by this issue in acltest.pas:
C:\Users\Administrator\Downloads\fpc-3.3.1.i386-win32\bin\i386-win32\fpc.exe -Fu"C:\Users\Administrator\Downloads\fpc-3.3.1.i386-win32\units\i386-win32*" acltest.pas
acltest.exe
Error in SetEntriesInAcl: 87
Fail
EXPLICIT_ACCESS_A size: 20
Mantis conversion info:
- Mantis ID: 36368
- OS: Windows 10
- Version: 3.3.1
- Fixed in revision: 43608 (#4715c947)
- Monitored by: » sternenseemann (Lukas)