diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-09-23 14:54:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-09-23 15:29:18 +0200 |
commit | f2c1f2a478a36cf94d54c6eee4c9addc34f10457 (patch) | |
tree | 29a07822f3ffea086b03a5bcb0d0c9a6954b7cff /version/wintrust/zsyscall_windows.go | |
parent | updater: use winhttp to reduce filesize (diff) | |
download | wireguard-windows-f2c1f2a478a36cf94d54c6eee4c9addc34f10457.tar.xz wireguard-windows-f2c1f2a478a36cf94d54c6eee4c9addc34f10457.zip |
version: use crypt32 instead of go x509 for cn extraction for file size
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | version/wintrust/zsyscall_windows.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/version/wintrust/zsyscall_windows.go b/version/wintrust/zsyscall_windows.go index 8aa315c0..7c742938 100644 --- a/version/wintrust/zsyscall_windows.go +++ b/version/wintrust/zsyscall_windows.go @@ -40,8 +40,9 @@ var ( modwintrust = windows.NewLazySystemDLL("wintrust.dll") modcrypt32 = windows.NewLazySystemDLL("crypt32.dll") - procWinVerifyTrust = modwintrust.NewProc("WinVerifyTrust") - procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject") + procWinVerifyTrust = modwintrust.NewProc("WinVerifyTrust") + procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject") + procCertGetNameStringW = modcrypt32.NewProc("CertGetNameStringW") ) func WinVerifyTrust(hWnd windows.Handle, actionId *windows.GUID, data *WinTrustData) (err error) { @@ -56,7 +57,7 @@ func WinVerifyTrust(hWnd windows.Handle, actionId *windows.GUID, data *WinTrustD 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) { +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 { if e1 != 0 { @@ -67,3 +68,9 @@ func CryptQueryObject(objectType uint32, object uintptr, expectedContentTypeFlag } return } + +func certGetNameString(certContext *windows.CertContext, nameType uint32, flags uint32, typePara uintptr, 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 +} |