Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
869 B

  1. //+-------------------------------------------------------------------------
  2. // File: hashexample.cpp
  3. //
  4. // Contents: An example calling WTHelperGetFileHash to get the hash
  5. // of a signed file
  6. //--------------------------------------------------------------------------
  7. #include <windows.h>
  8. #include <wincrypt.h>
  9. #include <wintrust.h>
  10. #include <wintrustp.h>
  11. #define MAX_HASH_LEN 20
  12. // Returns ERROR_SUCCESS if the file has a valid signed hash
  13. LONG GetSignedFileHashExample(
  14. IN LPCWSTR pwszFilename,
  15. OUT BYTE rgbFileHash[MAX_HASH_LEN],
  16. OUT DWORD *pcbFileHash,
  17. OUT ALG_ID *pHashAlgid
  18. )
  19. {
  20. return WTHelperGetFileHash(
  21. pwszFilename,
  22. 0, // dwFlags
  23. NULL, // pvReserved
  24. rgbFileHash,
  25. pcbFileHash,
  26. pHashAlgid
  27. );
  28. }