**共享如下,在win2k sp4/winxp sp2上除錯通過。
bool checkfiletrust( lpcwstr lpfilename );
wintrust_file_info wfi
= ;wintrust_catalog_info wci
= ;catalog_info ci
= ;hcatadmin hcatadmin
= null
;if
( !cryptcatadminacquirecontext
( &hcatadmin
, null
, 0
) )handle hfile
= createfilew
( lpfilename
, generic_read
, file_share_read
,null
, open_existing, 0
, null
);if
( invalid_handle_value
== hfile
)dword dwcnt
= 100
;byte byhash
[100
];cryptcatadmincalchashfromfilehandle
( hfile
, &dwcnt
, byhash
, 0
);closehandle
( hfile
);lpwstr pszmembertag
= new
wchar
[dwcnt
* 2 + 1
];for
( dword dw = 0
; dw
<
dwcnt
; ++
dw )
hcatinfo hcatinfo
= cryptcatadminenumcatalogfromhash
( hcatadmin
,byhash
, dwcnt, 0
, null
);if
( null
== hcatinfo
)else
guid action
= wintrust_action_generic_verify_v2
;hresult hr
= winverifytrust
( null
, &action
, &wd
);bret
= succeeded
( hr
);if
( null
!= hcatinfo
)cryptcatadminreleasecontext
( hcatadmin
, 0
); delete
pszmembertag
;return
bret;}
這段**是在乙個老外的論壇上不經意搜尋到的,乙個貌似德國人(因為他的注釋不是英文寫的,德國亦僅猜測爾,西班牙、葡萄牙、法蘭西、俄羅斯亦都有可能)寫的delphi**,其中使用了wintrust.dll中的匯出函式。使用vs2005的朋友們可以包含wintrust.h、softpub.h和mscat.h,並新增導入庫wintrust.lib;使用vc6的朋友們可以參考msdn上的函式及結構體宣告,並用函式指標進行呼叫。
本人補充一下一些型別,方便翻譯成別的語言
:typedef struct
_wintrust_data
;dword dwstateaction
;handle hwvtstatedata
;wchar
* pwszurlreference;
dword dwprovflags
;dword dwuicontext;}
wintrust_data
, *pwintrust_data
;typedef struct
wintrust_file_info_
wintrust_file_info
, *pwintruct_file_info
;typedef struct
wintrust_catalog_info_
wintrust_catalog_info
, *pwintrust_catalog_info
;typedef struct
catalog_info_
catalog_info
;本人再補充一下用到的api宣告
:long winapi winverifytrust
(__in hwnd hwnd
,__in guid
* pgactionid
,__in lpvoid pwvtdata
);
C 驗證微軟數字簽名
bool checkfiletrust lpcwstr lpfilename wintrust file info wfi wintrust catalog info wci catalog info ci hcatadmin hcatadmin null if cryptcatadminacqui...
驗證微軟數字簽名
bool checkfiletrust lpcwstr lpfilename wintrust file info wfi wintrust catalog info wci catalog info ci hcatadmin hcatadmin null if cryptcatadminacqui...
數字簽名的驗證
通常的我們在軟體發布前要對binary dll,exe 進行數字簽名,數字簽名可以標識軟體的發布商,也可以通過數字簽名來檢查此軟體是否被修改或受病毒影響。sigcheck是來自sysinternals的數字簽名驗證工具,可以檢視指定的檔案或目錄下的哪些檔案沒有數字簽名。此工具是命令列工具,可以用來批...