Skip to content

Image Certificate Directory

AFP edited this page Apr 1, 2023 · 1 revision

How to Access Image Certificate Directory

after initialize the PE class you can get access the Image Certificate structure by calling GetImageCertificateDirectory() method. by calling this function, you get the object of ImageCertificateDirectory class, so you can retrieve the fields, change or modify them.

#include <iostream>
#include <POEX.h> // include POEX header

int main()
{
    auto pe = POEX::PE(L"1.exe");

    // Access to Image Certificate Directory
    auto certificateDirectory = pe.GetImageCertificateDirectory();

    // other stuff in here

    return 0;
}

With calling GetImageCertificateDirectory method, you can access the structure and method in bellow:

        /// <summary>
	/// Length of the certificate.
	/// </summary>
	/// <returns>Length of the certificate.</returns>
	auto DwLength() const -> unsigned int;

	/// <summary>
	/// Length of the certificate.
	/// </summary>
	/// <param name="length">Length of the certificate.</param>
	/// <returns></returns>
	auto DwLength(const unsigned int& length) -> void;

	/// <summary>
	/// Revision.
	/// </summary>
	/// <returns>Revision.</returns>
	auto WRevision() const -> unsigned short;

	/// <summary>
	/// Revision.
	/// </summary>
	/// <param name="revision">Revision.</param>
	/// <returns></returns>
	auto WRevision(const unsigned short& revision) -> void;

	/// <summary>
	/// The certificate type.
	/// </summary>
	/// <returns>The certificate type.</returns>
	auto WCertificateType() const -> WinCertificateType;

	/// <summary>
	/// The certificate type.
	/// </summary>
	/// <param name="type">The certificate type.</param>
	/// <returns></returns>
	auto WCertificateType(const WinCertificateType& type) -> void;

	/// <summary>
	/// The certificate.
	/// </summary>
	/// <returns>The certificate.</returns>
	auto BCertificate() const -> std::vector<byte>;