revert @W and make api follow ms doc

This commit is contained in:
Boshi LIAN
2020-12-23 19:10:18 -08:00
parent bb7f2100fe
commit c68e05bdae
3 changed files with 12 additions and 32 deletions

View File

@@ -344,14 +344,13 @@ func (r *Rets) SetErrorCode() string {
// Fn describes syscall function.
type Fn struct {
Name string
Params []*Param
Rets *Rets
PrintTrace bool
WideCharStringParam bool
dllname string
dllfuncname string
src string
Name string
Params []*Param
Rets *Rets
PrintTrace bool
dllname string
dllfuncname string
src string
// TODO: get rid of this field and just use parameter index instead
curTmpVarIdx int // insure tmp variables have uniq names
}
@@ -480,10 +479,6 @@ func newFn(s string) (*Fn, error) {
f.dllfuncname = n[:len(n)-1]
f.Rets.fnMaybeAbsent = true
}
if n := f.dllfuncname; strings.HasSuffix(n, "@W") {
f.dllfuncname = n[:len(n)-2]
f.WideCharStringParam = true
}
return f, nil
}
@@ -601,9 +596,6 @@ func (p *Fn) MaybeAbsent() string {
// IsUTF16 is true, if f is W (utf16) function. It is false
// for all A (ascii) functions.
func (f *Fn) IsUTF16() bool {
if f.WideCharStringParam {
return true
}
s := f.DLLFuncName()
return s[len(s)-1] == 'W'
}

View File

@@ -265,8 +265,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore
//sys CertDeleteCertificateFromStore(certContext *CertContext) (err error) = crypt32.CertDeleteCertificateFromStore
//sys CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext, err error) [failretval==nil] = crypt32.CertDuplicateCertificateContext
//sys PFXImportCertStore(pfx *CryptDataBlob, password string, flags uint32) (store Handle, err error) = crypt32.PFXImportCertStore@W
//sys CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) = crypt32.CertDuplicateCertificateContext
//sys PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) = crypt32.PFXImportCertStore
//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain
//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain
//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext

View File

@@ -1165,12 +1165,9 @@ func CertDeleteCertificateFromStore(certContext *CertContext) (err error) {
return
}
func CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext, err error) {
r0, _, e1 := syscall.Syscall(procCertDuplicateCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
func CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) {
r0, _, _ := syscall.Syscall(procCertDuplicateCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
dupContext = (*CertContext)(unsafe.Pointer(r0))
if dupContext == nil {
err = errnoErr(e1)
}
return
}
@@ -1230,16 +1227,7 @@ func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext
return
}
func PFXImportCertStore(pfx *CryptDataBlob, password string, flags uint32) (store Handle, err error) {
var _p0 *uint16
_p0, err = syscall.UTF16PtrFromString(password)
if err != nil {
return
}
return _PFXImportCertStore(pfx, _p0, flags)
}
func _PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) {
func PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) {
r0, _, e1 := syscall.Syscall(procPFXImportCertStore.Addr(), 3, uintptr(unsafe.Pointer(pfx)), uintptr(unsafe.Pointer(password)), uintptr(flags))
store = Handle(r0)
if store == 0 {