Solved

WinVerifyTrust API

Posted on 1997-03-08
1
895 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
ID: 1300224
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

895 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

17 Experts available now in Live!

Get 1:1 Help Now