Figure 2

Figure 2 Signed Hello World Program
WScript.Echo "Hello world"

'' SIG '' Begin signature block
'' SIG '' MIIDKQYJKoZIhvcNAQcCoIIDGjCCAxYCAQExDjAMBggq
'' SIG '' hkiG9w0CBQUAMGYGCisGAQQBgjcCAQSgWDBWMDIGCisG
'' SIG '' AQQBgjcCAR4wJAIBAQQQTvApFpkntU2P5azhDxfrqwIB
'' SIG '' AAIBAAIBAAIBAAIBADAgMAwGCCqGSIb3DQIFBQAEEA0F
'' SIG '' XJYLd0k8EhI/etuA3SGgggGTMIIBjzCCATmgAwIBAgIQ
'' SIG '' kFDTSxAAoaIR1DKaQiUeEDANBgkqhkiG9w0BAQQFADAX
'' SIG '' MRUwEwYDVQQDEwxFcmljIExpcHBlcnQwHhcNMDAwMTAx
'' SIG '' MDcwMDAwWhcNMDYwMTAxMDcwMDAwWjAXMRUwEwYDVQQD
'' SIG '' EwxFcmljIExpcHBlcnQwXDANBgkqhkiG9w0BAQEFAANL
'' SIG '' ADBIAkEA3VIzvDbRfyssTEP+KJ1tO8e2/4Et3ZKK23gH
'' SIG '' GlIBlUJ6ss3Ro7GyILOWZCL+33NGpYQKL7mYZ+p5xSjc
'' SIG '' tQNYPwIDAQABo2EwXzATBgNVHSUEDDAKBggrBgEFBQcD
'' SIG '' AzBIBgNVHQEEQTA/gBAOsjyOexvxG/OkX9N6F8eMoRkw
'' SIG '' FzEVMBMGA1UEAxMMRXJpYyBMaXBwZXJ0ghCQUNNLEACh
'' SIG '' ohHUMppCJR4QMA0GCSqGSIb3DQEBBAUAA0EAYhQpLNPx
'' SIG '' ab25g+3RdIKkSYiRKTUSeSpOVSsCEFVzZON8D93HYCAN
'' SIG '' Wc+5ZhsKvs/U2/J50yXsxdLeRBqGWstuqDGCAQAwgf0C
'' SIG '' AQEwKzAXMRUwEwYDVQQDEwxFcmljIExpcHBlcnQCEJBQ
'' SIG '' 00sQAKGiEdQymkIlHhAwDAYIKoZIhvcNAgUFAKBsMBAG
'' SIG '' CisGAQQBgjcCAQwxAjAAMBkGCSqGSIb3DQEJAzEMBgor
'' SIG '' BgEEAYI3AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEE
'' SIG '' AYI3AgEVMB8GCSqGSIb3DQEJBDESBBDKAv0x3ULOrAx+
'' SIG '' Uo3S9F8cMA0GCSqGSIb3DQEBAQUABEDF2tdMhRr8xzKi
'' SIG '' cFi45A+xB2/zRLtmVXCywfR42J29m6ybYP+CjIQtNxS0
'' SIG '' naHd+wxLsLJwDXGq9BjGpuUPtuz9
'' SIG '' End signature block
Figure 4 VerifyTrust
/* This function verifies the trust of a particular file.    */
/* FALSE is returned if the file is not trusted.             */
/* If you want user interface to be generated for untrusted  */
/* documents, set fUseUI to TRUE.                            */
/*                                                           */

#include <softpub.h>

BOOL MyVerifyTrust(const WCHAR * pwszFilePath, BOOL fUseUI)
{
    BOOL fRet = FALSE;
    HRESULT hr;
    GUID guidPublishedSoftware = WINTRUST_ACTION_GENERIC_VERIFY_V2;
    WINTRUST_DATA wintrustdata;
    WINTRUST_FILE_INFO fileinfo;
    HINSTANCE hinstWinTrustDll = NULL;
    typedef BOOL (__stdcall * PFnWinVerifyTrust)(HWND hwnd, GUID * 
                 pguidAction, LPVOID pvData);
    PFnWinVerifyTrust pfnWinVerifyTrust;
    DWORD cb;

    memset(&wintrustdata, 0x00, sizeof wintrustdata);

    wintrustdata.cbStruct            = sizeof wintrustdata;
    wintrustdata.fdwRevocationChecks = WTD_REVOKE_NONE;
    wintrustdata.dwStateAction       = WTD_STATEACTION_IGNORE;
    wintrustdata.hWVTStateData       = NULL;
    wintrustdata.pwszURLReference    = NULL;
    wintrustdata.dwUIChoice          = fUseUI ? WTD_UI_ALL : WTD_UI_NONE;
    wintrustdata.dwProvFlags         = 0;
    wintrustdata.dwUnionChoice       = WTD_CHOICE_FILE;
    wintrustdata.pFile               = &fileinfo;

    // Valid dwProvFlags are:
    // WTD_USE_IE4_TRUST_FLAG
    // WTD_NO_IE4_CHAIN_FLAG 
    // WTD_NO_POLICY_USAGE_FL
    // WTD_REVOCATION_CHECK_NONE
    // WTD_REVOCATION_CHECK_END_CERT
    // WTD_REVOCATION_CHECK_CHAIN
    // WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT

    memset(&fileinfo, 0x00, sizeof fileinfo);
    fileinfo.cbStruct          = sizeof fileinfo;
    fileinfo.pcwszFilePath     = pwszFilePath;
    fileinfo.pgKnownSubject    = NULL;
    fileinfo.hFile             = NULL;

    hinstWinTrustDll = ::LoadLibraryA("wintrust.dll");
    if (NULL == hinstWinTrustDll)
        goto LError;

    pfnWinVerifyTrust = (PFnWinVerifyTrust) 
        ::GetProcAddress(hinstWinTrustDll, "WinVerifyTrust");
    if (NULL == pfnWinVerifyTrust)
        goto LError;

    hr = pfnWinVerifyTrust(0, &guidPublishedSoftware, &wintrustdata);
    if (FAILED(hr))
        goto LError;

    fRet = TRUE;

LError:

    if (NULL != hinstWinTrustDll)
        ::FreeLibrary(hinstWinTrustDll);

    return fRet;
}