I recently used mkwinsyscall for the functions around creating AppContainers (e.g.
e.g. Something like:
//sys CreateAppContainerProfile(name *uint16, displayName *uint16, description *uint16, caps *windows.SIDAndAttributes, capsCount uint32, outSid **windows.SID) (hres error) = Userenv.CreateAppContainerProfile
(N.B. I would rather have used string type rather than *uint16 but there was no way to signal that this is a UTF-16 function prototype as the function name doesn't end in W, so the generated code used *uint8 - not the point of this discussion but I wonder if an annotation to //sys lines can be added to indicate generate UTF-16)
The error that is returned is an HRESULT, though mkwinsyscall treats it as a syscall.Errno. This works fine for printing the error, but I had hoped to use errors.Is(err, os.ErrExist) to handle the already exists case. This picks up ERROR_ALREADY_EXISTS (0xB7) but unfortunately because
CreateAppContainerProfile returns an HRESULT, it returns 0x800700B7, so
errors.Is(err, os.ErrExist) returns false
So I suppose my question is, what is the best way to handle this?
- Should a hack be added to Errno functions (or even a wrapper around Errno creation?) to mask off the first word if it's 0x8007?
- Should HRESULT be a different type to Errno much like I noticed someone recently added NTSTATUS (along with a way to mark an error as so in mkwinsyscall)? Can begin to implement Errors.Is for the Win32 facility at least.
Hope I've made this clear..
Thanks,
Alex