Как сделать? Предполагаю, что без CSP не обойтись, но что делать, хз. Надо срочно, подскажите плз. Короче чет типа sigverif Решается все WINTRUST.dll. Он эспортирует нужные функции. Но при верификации используйте проверку не файла, а каталога...там понадобится хеш и пр.
А вот пример в своих архивах нашел: Код (Text): //------------------------------------------------------------------------------ // Link with the Wintrust.lib file. //#pragma comment (lib, "wintrust") typedef LONG (WINAPI *TpWinVerifyTrust)(HWND hwnd, GUID *pgActionID, LPVOID pWintrustData); TpWinVerifyTrust pWinVerifyTrust = NULL; BOOL InitWinTrustAPI() { HINSTANCE hLib=::LoadLibrary(L"wintrust.dll"); if(!hLib) return FALSE; // pWinVerifyTrust = (TpWinVerifyTrust)GetProcAddress((HMODULE)hLib, "WinVerifyTrust"); // if(!pWinVerifyTrust) return FALSE; // return TRUE; } //------------------------------------------------------------------------------ // Helper function to display an error message LPCTSTR GetErrorStrMessage(DWORD dwError) { static TCHAR strMessage[512]; LPTSTR lpBuffer = NULL; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpBuffer, 0, NULL ); wcscpy(strMessage,lpBuffer);//,sizeof(strMessage)); LocalFree( lpBuffer ); return strMessage; } ////////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////// // // WINTRUST_ACTION_GENERIC_VERIFY_V2 Guid (Authenticode) //---------------------------------------------------------------------------- // Assigned to the pgActionID parameter of WinVerifyTrust to verify the // authenticity of a file/object using the Microsoft Authenticode // Policy Provider, // // {00AAC56B-CD44-11d0-8CC2-00C04FC295EE} // #define WINTRUST_ACTION_GENERIC_VERIFY_V2 \ { 0xaac56b, \ 0xcd44, \ 0x11d0, \ { 0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee } \ } ////////////////////////////////////////////////////////////////////////////// // // WINTRUST_ACTION_GENERIC_CERT_VERIFY //---------------------------------------------------------------------------- // Assigned to the pgActionID parameter of WinVerifyTrust to verify // a certificate chain only. This is only valid when passing in a // certificate context in the WinVerifyTrust input structures. // // {189A3842-3041-11d1-85E1-00C04FC295EE} // #define WINTRUST_ACTION_GENERIC_CERT_VERIFY \ { 0x189a3842, \ 0x3041, \ 0x11d1, \ { 0x85, 0xe1, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee } \ } typedef struct WINTRUST_FILE_INFO_1 { DWORD cbStruct; LPCWSTR pcwszFilePath; HANDLE hFile; GUID* pgKnownSubject; } WINTRUST_FILE_INFO1, *PWINTRUST_FILE_INFO1; typedef struct _WINTRUST_DATA1 { DWORD cbStruct; LPVOID pPolicyCallbackData; LPVOID pSIPClientData; DWORD dwUIChoice; DWORD fdwRevocationChecks; DWORD dwUnionChoice; union { struct WINTRUST_FILE_INFO_* pFile; struct WINTRUST_CATALOG_INFO_* pCatalog; struct WINTRUST_BLOB_INFO_* pBlob; struct WINTRUST_SGNR_INFO_* pSgnr; struct WINTRUST_CERT_INFO_* pCert; }; DWORD dwStateAction; HANDLE hWVTStateData; WCHAR* pwszURLReference; DWORD dwProvFlags; DWORD dwUIContext; } WINTRUST_DATA1, *PWINTRUST_DATA1; BOOL VerifyEmbeddedSignature(LPCWSTR pwszSourceFile) { BOOL bRet = FALSE; LONG lStatus; //DWORD dwLastError; // Initialize the WINTRUST_FILE_INFO structure. WINTRUST_FILE_INFO1 FileData; memset(&FileData, 0, sizeof(FileData)); FileData.cbStruct = sizeof(FileData); 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. */ GUID WVTPolicyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_DATA1 WinTrustData; // Initialize the WinVerifyTrust input data structure. // Default all fields to 0. memset(&WinTrustData, 0, sizeof(WinTrustData)); WinTrustData.cbStruct = sizeof(WinTrustData); // 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; // Default verification. WinTrustData.dwStateAction = 0; // Not applicable for default verification of embedded signature. 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 = (PWINTRUST_FILE_INFO)&FileData; //#ifndef TRUST_E_EXPLICIT_DISTRUST //#define TRUST_E_EXPLICIT_DISTRUST 0x800B0111 //#endif wprintf(L"File '%s'\n",pwszSourceFile); // WinVerifyTrust verifies signatures as specified by the GUID // and Wintrust_Data. if(pWinVerifyTrust) lStatus = pWinVerifyTrust( (HWND)INVALID_HANDLE_VALUE,//NULL, &WVTPolicyGUID, &WinTrustData); else return FALSE; // switch (lStatus) { case ERROR_SUCCESS: /* Signed file: - Hash that represents the subject is trusted. - Trusted publisher without any verification errors. - UI was disabled in dwUIChoice. No publisher or time stamp chain errors. - UI was enabled in dwUIChoice and the user clicked "Yes" when asked to install and run the signed subject. */ wprintf(L"The file \"%s\" is signed and the signature " L"was verified.\n", pwszSourceFile); bRet = TRUE; break; /* case TRUST_E_NOSIGNATURE: // The file was not signed or had a signature // that was not valid. // Get the reason for no signature. dwLastError = GetLastError(); if (TRUST_E_NOSIGNATURE == dwLastError || TRUST_E_SUBJECT_FORM_UNKNOWN == dwLastError || TRUST_E_PROVIDER_UNKNOWN == dwLastError) { // The file was not signed. wprintf(L"The file \"%s\" is not signed.\n", pwszSourceFile); } else { // The signature was not valid or there was an error // opening the file. wprintf(L"An unknown error occurred trying to " L"verify the signature of the \"%s\" file.\n", pwszSourceFile); } break; case TRUST_E_EXPLICIT_DISTRUST: // The hash that represents the subject or the publisher // is not allowed by the admin or user. wprintf(L"The signature is present, but specifically " L"disallowed.\n"); break; case TRUST_E_SUBJECT_NOT_TRUSTED: // The user clicked "No" when asked to install and run. wprintf(L"The signature is present, but not " L"trusted.\n"); break; case CRYPT_E_SECURITY_SETTINGS: //The hash that represents the subject or the publisher //was not explicitly trusted by the admin and the //admin policy has disabled user trust. No signature, //publisher or time stamp errors. wprintf(L"CRYPT_E_SECURITY_SETTINGS - The hash " L"representing the subject or the publisher wasn't " L"explicitly trusted by the admin and admin policy " L"has disabled user trust. No signature, publisher " L"or timestamp errors.\n"); break; //*/ default: // The UI was disabled in dwUIChoice or the admin policy // has disabled user trust. lStatus contains the // publisher or time stamp chain error. wprintf(L"Error is: 0x%x.\n", lStatus); // LPCTSTR ptr = GetErrorStrMessage(lStatus); if(ptr && ptr[0]) wprintf(L"%s\n",ptr); break; } return bRet; } int _tmain(int argc, _TCHAR* argv[]) { if(!InitWinTrustAPI()) { wprintf(L"InitWinTrustAPI - FALSE\n"); return 0; } // if(argc > 1) { VerifyEmbeddedSignature(argv[1]); } else VerifyEmbeddedSignature(argv[0]); return 0; }
Указанная ссылка ( http://pr0mix.freehostia.com/src/fakeds.zip ) нерабочая. Работает вот эта: http://eof-project.net/sources/pr0m1x/vx/src/etc/fakeds.zip