Solved

WinVerifyTrust API

Posted on 1997-03-08
1
898 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 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