// -
//? Copyright? (3)? Microsoft? Company. ? All of them? Right? Keep.
//? For example? Yes? Verification? That? Embedded? Signature? Yes? Answer? PE? Documents? By who? Use?
//? That? WinVerifyTrust? Function.
# Definition? _UNICODE? 1
# Definition? UNICODE? 1
# Contains? & lttchar.h & gt
# Contains? & ltstdio.h & gt
# Contains? & ltstdlib.h & gt
# Contains? & ltwindows.h & gt
# Contains? & ltSoftpub.h & gt
# Contains? & ltwincrypt.h & gt
# Contains? & ltwintrust.h & gt
//? Link? With what? That? Wintrust.lib? Documents.
#pragma? Comments? (lib,? “wintrust”)
Bull? verify embedded signature(LPCWSTR? pwszSourceFile)
{
Dragon? lStatus
DWORD? dwLastError
//? Initialize? That? WINTRUST_FILE_INFO? Structure.
WINTRUST_FILE_INFO? FileData
memset(& amp; FileData,? 0,? sizeof(FileData));
FileData.cbStruct? =? sizeof(WINTRUST _ FILE _ INFO);
FileData.pcwszFilePath? =? pwszSourceFile
FileData.hFile? =? NULL
FileData.pgKnownSubject? =? NULL
/*
WVTPolicyGUID? Designate? That? Policy? Where to? Apply? Open? That? document
WINTRUST _ ACTION _ GENERIC _ VERIFY _ V2? Policy? Check:
1)? That? Certificate? Used? Where to? Sign? That? Documents? Chains? Up? Where to? Answer? Root?
Certificate? Located? Are you online? That? Is it credible? Root? Certificate? Shops. ? This?
Hint? That? That? Identity? Yes? That? Publisher? Really? Have you been there? Verified? By who?
Answer? Certification? Authority.
2)? Are you online? Case? Where is it? User? Interface? Is it? Display? (which one? This? example
Is it? Isn't it? do),? WinVerifyTrust? Will. Check? For what? Is it? That?
End? Entity? Certificate? Is it? Storage? Are you online? That? Is it credible? Publisher? Shop?
Hint? That? That? User? Trust? Content? From where? This? Publishers
3)? That? End? Entity? Certificate? Really? Enough? Permission Where to? Sign?
Code? As? Show? By who? That? A sense of existence? Yes? Answer? Code? Sign a contract? EKU? Or? No?
EKU。
*/
GUID? WVTPolicyGUID? =? WINTRUST _ ACTION _ GENERIC _ VERIFY _ V2;
WINTRUST_DATA? WinTrustData
//? Initialize? That? WinVerifyTrust? Input? Data? Structure.
//? Default? All of them? Fields? Where to? 0.
memset(& amp; WinTrustData,? 0,? sizeof(WinTrustData));
WinTrustData.cbStruct? =? sizeof(WinTrustData);
//? Use? Default? Code? Sign a contract? EKU。
wintrustdata . ppolicycallbackdata? =? NULL
//? No? Data? Where to? Pass? Where to? Sip.
WinTrustData.pSIPClientData? =? NULL
//? Disabled? WVT? UI。
WinTrustData.dwUIChoice? =? WTD _ UI _ none;
//? No? Revocation? Checking.
wintrustdata . fdwrevocationchecks? =? WTD _ Revocation _ None; ?
//? Verification? Ann? Embedded? Signature? Open? Answer? Documents.
WinTrustData.dwUnionChoice? =? WTD _ Select _ File;
//? Default? Verification.
WinTrustData.dwStateAction? =? 0;
//? Isn't it? Applicable? For what? Default? Verification? Yes? Embedded? Sign.
WinTrustData.hWVTStateData? =? NULL
//? Isn't it? Used.
WinTrustData.pwszURLReference? =? NULL
//? By default.
WinTrustData.dwProvFlags? =? WTD _ Safer _ Flag;
//? This? Is it? Isn't it? Applicable? What if? There? Is it? No? UI? Because? It? Change?
//? That? UI? Where to? Accommodation? Running? Application? Instead? Yes?
//? Installing? Applications.
WinTrustData.dwUIContext? =? 0;
//? Settings? pFile。
WinTrustData.pFile? =? & ampFileData
//? WinVerifyTrust? Verification? Signature? As? Designated? By who? That? GUID?
//? And then what? Wintrust_Data。
Istace. =? WinVerifyTrust(
Empty,
& ampWVTPolicyGUID,
& ampWinTrustData);
Switch? (lStatus)?
{
Case? Error _ Success:
/*
Signed it? File:
-? Hash? That? Represents? That? Theme? Is it? Trustworthy.
-? Is it credible? Publisher? No? Really? Verification? Mistake.
-? UI? Used to be. Disability? Are you online? dwUIChoice。 ? No? Publisher? Or?
Time? Stamp? Chain? Mistake.
-? UI? Used to be. Enable? Are you online? dwUIChoice? And then what? That? User? Click?
Is it? What time? Ask? Where to? Installation? And then what? Run? That? Signed it?
Theme.
*/
wprintf_s(L"The? Documents? \"%s\ "? Is it? Signed it? And then what? That? Signature? "
I "was? It has been verified. \n ",
pwsz source file);
Break;
Case? Trust signature:
//? That? Documents? Used to be. Isn't it? Signed it? Or? Had it? Answer? Signature?
//? That? Used to be. Isn't it? Effective.
//? Get? That? Why? For what? No? Sign.
dwLastError? =? GetLastError();
What if? (TRUST_E_NOSIGNATURE? ==? dwLastError? ||
TRUST _ E _ SUBJECT _ FORM _ unknown? ==? dwLastError? ||
TRUST _ E _ PROVIDER _ unknown? ==? dwLastError)?
{
//? That? Documents? Used to be. Isn't it? Signed it.
wprintf_s(L"The? Documents? \"%s\ "? Is it? Isn't it? Signed it. \n ",
pwsz source file);
}?
Or what?
{
//? That? Signature? Used to be. Isn't it? Is it effective? Or? There? Used to be. Ann? Mistakes?
//? Opening? That? Documents.
wprintf_s(L"An? Unknown? Mistakes? It happened? Try? Arrive? "
L "verification? That? Signature? Yes? That? \"%s\ "? Documents. \n ",
pwsz source file);
}
Break;
Case? TRUST _ E _ EXPLICIT _ DISTRUST:
//? That? Hash? That? Represents? That? Theme? Or? That? Publisher?
//? Is it? Isn't it? Is it allowed? By who? That? admin? Or? Users.
wprintf_s(L"The? Signature? Is it? At present,? But? Specific? "
L "not allowed. \ n ");
Break;
Case? Trust _ Electronic _ Subject _ Distrust:
//? That? User? Click? "No"? What time? Ask? Where to? Installation? And then what? Run.
wprintf_s(L"The? Signature? Is it? At present,? But? No? "
I believe. \ n ");
Break;
Case? CRYPT _ E _ SECURITY _ settings:
/*
That? Hash? That? Represents? That? Theme? Or? That? Publisher?
Used to be. Isn't it? Specifically? Is it credible? By who? That? admin? And then what? That?
admin? Policy? Really? Disability? User? Trust. ? No? Signature?
Publisher? Or? Time? Stamp? Mistake.
*/
wprintf _ s(L " CRYPT _ E _ SECURITY _ SETTINGS? -? That? Hash? "
What does l stand for? That? Theme? Or? That? Publisher? Isn't it? "
L "definitely? Is it credible? By who? That? admin? And then what? admin? Policy? "
L "yes? Disability? User? Trust. ? No? Signature? Publisher? "
L "or? Time stamp? Mistake. \ n ");
Break;
Default value:
//? That? UI? Used to be. Disability? Are you online? dwUIChoice? Or? That? admin? Policy?
//? Really? Disability? User? Trust. ? Istace. Contain? That?
//? Publisher? Or? Time? Stamp? Chain? Mistake.
Wprintf_s(L "error? Is:? 0x%x,\n ",
lStatus);
Break;
}
Return? True;
}
int? _tmain(int? argc,? _TCHAR*? argv[])
{
If (argc? & gt? 1)
{
verify embedded signature(argv[ 1]);
}
Return? 0;
}