.版本 2
.程序集 程序集1
.子程序 _启动子程序, 整数型, , 本子程序在程序启动后最先执行
' https://msdn.microsoft.com/zh-cn/library/windows/desktop/aa382384
VerifyEmbeddedSignature (A2W (“C:\Users\Richard\Desktop\QQ群签到1.exe”))
标准输入 ()
返回 (0) ' 可以根据您的需要返回任意数值
.子程序 VerifyEmbeddedSignature, 逻辑型
.参数 pwszSourceFile, 字节集, , Unicode
.局部变量 lStatus, 整数型
.局部变量 dwLastError, 整数型
.局部变量 FileData, WINTRUST_FILE_INFO
.局部变量 WVTPolicyGUID, 字节集, , , GUID
.局部变量 WinTrustData, WINTRUST_DATA
' Initialize the WINTRUST_FILE_INFO structure.
' memset(&FileData, 0, sizeof(FileData));
FileData.cbStruct = 16
FileData.pcwszFilePath = pwszSourceFile
FileData.hFile = #NULL
FileData.pgKnownSubject = #NULL
' WVTPolicyGUID specifies the policy to apply on the file
' WINTRUST_ACTION_GENERIC_VERIFY_V2 policy checks:
' 1) The certificate used to sign the file chains up to a root
' certificate located in the trusted root certificate store. This
' implies that the identity of the publisher has been verified by
' a certification authority.
' 2) In cases where user interface is displayed (which this example
' does not do), WinVerifyTrust will check for whether the
' end entity certificate is stored in the trusted publisher store,
' implying that the user trusts content from this publisher.
' 3) The end entity certificate has sufficient permission to sign
' code, as indicated by the presence of a code signing EKU or no
' EKU.
WVTPolicyGUID = #WINTRUST_ACTION_GENERIC_VERIFY_V2
' Initialize the WinVerifyTrust input data structure.
' Default all fields to 0.
' memset(&WinTrustData, 0, sizeof(WinTrustData));
WinTrustData.cbStruct = 48
' Use default code signing EKU.
WinTrustData.pPolicyCallbackData = #NULL
' No data to pass to SIP.
WinTrustData.pSIPClientData = #NULL
' Disable WVT UI.
WinTrustData.dwUIChoice = #WTD_UI_NONE
' No revocation checking.
WinTrustData.fdwRevocationChecks = #WTD_REVOKE_NONE
' Verify an embedded signature on a file.
WinTrustData.dwUnionChoice = #WTD_CHOICE_FILE
' Verify action.
WinTrustData.dwStateAction = #WTD_STATEACTION_VERIFY
' Verification sets this value.
WinTrustData.hWVTStateData = #NULL
' Not used.
WinTrustData.pwszURLReference = #NULL
' This is not applicable if there is no UI because it changes
' the UI to accommodate running applications instead of
' installing applications.
WinTrustData.dwUIContext = 0
' Set pFile.
WinTrustData.pFile = FileData
' WinVerifyTrust verifies signatures as specified by the GUID
' and Wintrust_Data.
lStatus = WinVerifyTrust (#NULL, WVTPolicyGUID, WinTrustData)
.判断开始 (lStatus = #ERROR_SUCCESS)
标准输出 (, “The file is signed and the signature was verified.” + #换行符)
.默认
' 此处代码略过
.判断结束
' Any hWVTStateData must be released by a call with close.
WinTrustData.dwStateAction = #WTD_STATEACTION_CLOSE
lStatus = WinVerifyTrust (#NULL, WVTPolicyGUID, WinTrustData)
返回 (真)
.子程序 A2W, 字节集
.参数 ByteStr, 文本型, 参考
.局部变量 len, 整数型
.局部变量 Returned, 字节集
len = MultiByteToWideChar (0, 0, ByteStr, -1, { }, 0)
Returned = 取空白字节集 (len × 2)
MultiByteToWideChar (0, 0, ByteStr, -1, Returned, 取字节集长度 (Returned))
返回 (Returned)
易语言签名验证错误
易语言 签名文件
易语言文件签名