FDICopy is incorrectly declared
See original GitHub issueDescribe the bug
FDICopy
inside the Cabinet declarations is not working right now, as the PFNFDINOTIFY
does not correspond to what Windows accepts.
What code is involved
Fdi.cs, FDICopy
and PFNFDINOTIFY
.
Expected behavior
The function expects two pointers, PFNFDINOTIFY
and PFNFDIDECRYPT
. As can be seen here, the declaration of the first pointer should actually be something like this:
public delegate IntPtr PFNFDINOTIFY(int fdint, ref FDINOTIFICATION pfdin);
(the first parameter could be an enum FDINOTIFICATIONTYPE
).
Right now, PFNFDINOTIFY
is actually declared to match PFNFDIDECRYPT
which is not named anywhere in Fdi.cs except the docs. Together, the rest should look like this:
public delegate int PFNFDIDECRYPT(ref FDIDECRYPT pfdid);
[DllImport("cabinet.dll", SetLastError = false, ExactSpelling = true, CharSet = CharSet.Ansi)]
public static extern bool FDICopy(HFDI hfdi, string pszCabinet, string pszCabPath, int flags, PFNFDINOTIFY pfnfdin, PFNFDIDECRYPT pfnfdid, IntPtr pvUser);
Edit: More issues have cropped up as I tried to use the API, so I have added them as separate comments. Frankly, I am not surprised there are so many of them, as cabinet.dll is like nothing I have ever seen in WinAPI before.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
Thanks for validating it. I’ll get it pushed shortly.
@IllidanS4 I think I’ve addressed all your issues and then fixed a few other things while in there.
long
fields toint
and allHFILE
references toIntPtr
FDINOTIFICATION.psz2
to anIntPtr
. Please let me know if your testing shows I need to attribute all delegates to explicitly be called as__cdecl
.ERF
now require aref
instance and the marshaledbool
field now usesBOOL
– a blittable structure defined in my lib that auto converts tobool
in use.