Solved

WinVerifyTrust API

Posted on 1997-03-08
1
892 Views
Last Modified: 2013-11-19
What do you need in your development environment to
use the WinVerifyTrust() API? When I use the API it
gives an error 'linked to missing export ADVAPI32.DLL:
WinVerifyTrust'.

The following sample code is used in a simple
dialog box app to test the API. I have a personal
and private key to digitally sign code with. I have
tested the keys out using the tools in the ActiveX
SDK. The error happens when I run the test app,
not when the API is being invoked.

// Test the Win Veriy Trust API
void CWinVerifyDlg::OnTestButton()
{
   HRESULT hResult;
   GUID ActionID;
   GUID SubjectType = WIN_TRUST_SUBJTYPE_PE_IMAGE;
   WIN_TRUST_ACTDATA_SUBJECT_ONLY ActionData;
   WIN_TRUST_SUBJECT_FILE SubjectFile;

   SubjectFile.hFile = 0;
   SubjectFile.lpPath = (LPCWSTR)"\\Test\\Authent\\SwUpdate.exe";
   ActionData.SubjectType = &SubjectType;
   ActionData.Subject = &SubjectFile;
   
   hResult = ::WinVerifyTrust      (this->GetSafeHwnd (), &ActionID, &ActionData);
   switch (hResult)
   {
      case ERROR_SUCCESS:
         AfxMessageBox ("Trusted Code!");
         break;
      case TRUST_E_SUBJECT_NOT_TRUSTED:
         AfxMessageBox ("Not Trusted Code!");
         break;
      case TRUST_E_PROVIDER_UNKNOWN:
         AfxMessageBox ("Provider Unknown!");
         break;
      case TRUST_E_ACTION_UNKNOWN:
         AfxMessageBox ("Action Unknown!");
         break;
      case TRUST_E_SUBJECT_FORM_UNKNOWN:
         AfxMessageBox ("Form Unknown!");
         break;
      default:
         AfxMessageBox ("Error Unknown!");
         break;
   }
}
0
Comment
Question by:mreha
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 70 total points
Comment Utility
It sounds like you're using a beta version of the ActiveX SDK.  You should upgrade to a supported version.

The WinVerifyTrust() function isn't implemented by ADVAPI32.DLL.  It is, instead, implemented by WINTRUST.DLL.  From the symptoms you describe, it sounds like you've got a bad version of ADVAPI32.LIB, and you need to find a copy of WINTRUST.LIB (and, at runtime, WINTRUST.DLL) that has the function exported.

This line of code, by the way:

   SubjectFile.lpPath = (LPCWSTR)"\\Test\\Authent\\SwUpdate.exe";

includes an invalid cast. You should have coded:

   SubjectFile.lpPath = L"\\Test\\Authent\\SwUpdate.exe";

.B ekiM

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
lucky13 challenge 11 111
modThree challenge 4 64
Modbus - whats the maximum I can store in one register? 4 74
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now