I recently used mkwinsyscall for the functions around creating 
AppContainers 
(e.g. 
https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-createappcontainerprofile)

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

-- 
*This electronic message contains information from Ava Security/Ava 
federal, which may be privileged or confidential. The information is 
intended for use only by the individual(s) or entity named above. If you 
are not the intended recipient, be aware that any disclosure, copying, 
distribution or use of the contents of this information is strictly 
prohibited. If you have received this electronic message in error, please 
notify the sender. Activity and use of the Ava Security Limited/Ava Federal 
email system is monitored to secure its effective operation and for other 
lawful business purposes. Communications using this system will also be 
monitored and may be recorded to secure effective operation and for other 
lawful business purposes. *

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/42c90497-41a0-4470-80ed-5d45b502e10bn%40googlegroups.com.

Reply via email to