diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-22 18:24:33 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-24 00:12:24 +0100 |
commit | fc41f439f573fce3efdd37017f072f86cb7828ff (patch) | |
tree | 1889c42f4a4dc5190c88c87ec2a05d172a396459 /version/wintrust/zsyscall_windows.go | |
parent | embeddable-dll-service: add more robust example for .NET 5 (diff) | |
download | wireguard-windows-fc41f439f573fce3efdd37017f072f86cb7828ff.tar.xz wireguard-windows-fc41f439f573fce3efdd37017f072f86cb7828ff.zip |
global: move certain win32 APIs to x/sys/windows
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | version/wintrust/zsyscall_windows.go | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/version/wintrust/zsyscall_windows.go b/version/wintrust/zsyscall_windows.go deleted file mode 100644 index 67daccb1..00000000 --- a/version/wintrust/zsyscall_windows.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by 'go generate'; DO NOT EDIT. - -package wintrust - -import ( - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) - errERROR_EINVAL error = syscall.EINVAL -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return errERROR_EINVAL - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - modcrypt32 = windows.NewLazySystemDLL("crypt32.dll") - modwintrust = windows.NewLazySystemDLL("wintrust.dll") - - procCertFindExtension = modcrypt32.NewProc("CertFindExtension") - procCertGetNameStringW = modcrypt32.NewProc("CertGetNameStringW") - procCryptDecodeObject = modcrypt32.NewProc("CryptDecodeObject") - procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject") - procWinVerifyTrust = modwintrust.NewProc("WinVerifyTrust") -) - -func certFindExtension(objId *byte, countExtensions uint32, extensions *certExtension) (ret *certExtension) { - r0, _, _ := syscall.Syscall(procCertFindExtension.Addr(), 3, uintptr(unsafe.Pointer(objId)), uintptr(countExtensions), uintptr(unsafe.Pointer(extensions))) - ret = (*certExtension)(unsafe.Pointer(r0)) - return -} - -func certGetNameString(certContext *windows.CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) { - r0, _, _ := syscall.Syscall6(procCertGetNameStringW.Addr(), 6, uintptr(unsafe.Pointer(certContext)), uintptr(nameType), uintptr(flags), uintptr(typePara), uintptr(unsafe.Pointer(name)), uintptr(size)) - chars = uint32(r0) - return -} - -func cryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procCryptDecodeObject.Addr(), 7, uintptr(encodingType), uintptr(unsafe.Pointer(structType)), uintptr(unsafe.Pointer(encodedBytes)), uintptr(lenEncodedBytes), uintptr(flags), uintptr(decoded), uintptr(unsafe.Pointer(decodedLen)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func cryptQueryObject(objectType uint32, object uintptr, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *windows.Handle, msg *windows.Handle, context *uintptr) (err error) { - r1, _, e1 := syscall.Syscall12(procCryptQueryObject.Addr(), 11, uintptr(objectType), uintptr(object), uintptr(expectedContentTypeFlags), uintptr(expectedFormatTypeFlags), uintptr(flags), uintptr(unsafe.Pointer(msgAndCertEncodingType)), uintptr(unsafe.Pointer(contentType)), uintptr(unsafe.Pointer(formatType)), uintptr(unsafe.Pointer(certStore)), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(context)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func WinVerifyTrust(hWnd windows.Handle, actionId *windows.GUID, data *WinTrustData) (err error) { - r1, _, e1 := syscall.Syscall(procWinVerifyTrust.Addr(), 3, uintptr(hWnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data))) - if r1 != 0 { - err = errnoErr(e1) - } - return -} |