|
// AssemblyInfo.h : Declaration of the CAssemblyInfo
#pragma once
#include "resource.h" // main symbols
#include "AsmShell.h"
#include <atlfile.h>
#include "rgsmap.h"
#include "Modules.h"
// Relative offsets in the FileType enumeration.
#define OFFSET_DOTNET 2
#define OFFSET_IA64 5
#define OFFSET_X64 10
// CAssemblyInfo
class ATL_NO_VTABLE CAssemblyInfo :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CAssemblyInfo, &CLSID_AssemblyInfo>,
public ISupportErrorInfoImpl<&IID_IAssemblyInfo>,
public IDispatchImpl<IAssemblyInfo, &IID_IAssemblyInfo, &LIBID_AsmShellLib, 1, 2>
{
public:
CAssemblyInfo()
{
}
DECLARE_REGISTRY_RESOURCEID_EX(IDR_ASSEMBLYINFO)
BEGIN_REGISTRY_MAP(CAssemblyInfo)
REGISTRY_GUID("CLSID", CLSID_AssemblyInfo)
REGISTRY_GUID("LIBID", LIBID_AsmShellLib)
END_REGISTRY_MAP()
BEGIN_COM_MAP(CAssemblyInfo)
COM_INTERFACE_ENTRY(IAssemblyInfo)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY2(IDispatch, IAssemblyInfo)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
// IAssemblyInfo
STDMETHOD(IsAssembly)(BSTR path, VARIANT_BOOL* retVal);
STDMETHOD(GetFileType)(BSTR path, FileType* retVal);
STDMETHOD(GetPublicKeyToken)(BSTR path, BSTR* retVal);
STDMETHOD(GetPublicKey)(BSTR path, SAFEARRAY** retVal);
private:
// Declare a flagged enumeration and struct to hold information
// for GetFileInfo().
enum FILEINFOTYPE
{
FILEINFOTYPE_CORHEADER = 1,
FILEINFOTYPE_MACHINEARCH = 2
};
typedef struct FILEINFO
{
FILEINFOTYPE fit;
VARIANT_BOOL varfCorHeader;
WORD wMachineArch;
} FILEINFO, *LPFILEINFO;
HRESULT GetFileInfo(BSTR path, LPFILEINFO pFileInfo);
HRESULT GetComDirectory(PIMAGE_NT_HEADERS pNtHeaders, PIMAGE_DATA_DIRECTORY pComDirectory);
HRESULT GetMachineArch(LPVOID pFile, LPWORD pwMachine);
HRESULT GetNtHeaders(LPVOID pFile, PIMAGE_NT_HEADERS* ppNtHeaders);
HRESULT HasCorHeader(LPVOID pFile);
};
OBJECT_ENTRY_AUTO(__uuidof(AssemblyInfo), CAssemblyInfo)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Principal Software Engineer currently working on Azure SDKs at Microsoft. My opinions are my own. I work on a number of OSS projects for work and personally in numerous languages including C++, C#, JavaScript, Go, Rust, et. al. See a problem, fix a problem (or at least create an issue)!
Avid outdoor adventurer 🏔️❄️👞🚴♂️, husband, father.