ReactOS 0.4.17-dev-934-g091855f
fusionpriv.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winver.h"
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for fusionpriv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  METADATAHDR
 
struct  METADATASTREAMHDR
 
struct  METADATATABLESHDR
 
struct  MODULETABLE
 
struct  TYPEDEFTABLE
 
struct  TYPEREFTABLE
 
struct  FIELDTABLE
 
struct  ASSEMBLYTABLE
 
struct  MANIFESTRESTABLE
 
struct  METHODDEFTABLE
 
struct  PARAMTABLE
 
struct  INTERFACEIMPLTABLE
 
struct  MEMBERREFTABLE
 
struct  CONSTANTTABLE
 
struct  CUSTOMATTRIBUTETABLE
 
struct  FIELDMARSHALTABLE
 
struct  DECLSECURITYTABLE
 
struct  CLASSLAYOUTTABLE
 
struct  FIELDLAYOUTTABLE
 
struct  STANDALONESIGTABLE
 
struct  EVENTMAPTABLE
 
struct  EVENTTABLE
 
struct  PROPERTYMAPTABLE
 
struct  PROPERTYTABLE
 
struct  METHODSEMANTICSTABLE
 
struct  METHODIMPLTABLE
 
struct  MODULEREFTABLE
 
struct  TYPESPECTABLE
 
struct  IMPLMAPTABLE
 
struct  FIELDRVATABLE
 
struct  ASSEMBLYPROCESSORTABLE
 
struct  ASSEMBLYOSTABLE
 
struct  ASSEMBLYREFTABLE
 
struct  ASSEMBLYREFPROCESSORTABLE
 
struct  ASSEMBLYREFOSTABLE
 
struct  FILETABLE
 
struct  EXPORTEDTYPETABLE
 
struct  NESTEDCLASSTABLE
 
struct  GENERICPARAMTABLE
 
struct  METHODSPECTABLE
 
struct  GENERICPARAMCONSTRAINTTABLE
 
struct  IMPORTTABLE
 
struct  IMPORTLOOKUPTABLE
 
struct  HINTNAMETABLE
 
struct  RELOCATION
 
struct  VS_VERSIONINFO
 
struct  VARFILEINFO
 
struct  VAR
 
struct  STRINGFILEINFO
 
struct  STRINGTABLE
 
struct  STRINGHDR
 
struct  RESOURCE
 

Macros

#define BYTES_PER_TOKEN   8
 
#define CHARS_PER_BYTE   2
 
#define TOKEN_LENGTH   (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)
 

Typedefs

typedef struct tagASSEMBLY ASSEMBLY
 

Functions

HRESULT assembly_create (ASSEMBLY **out, LPCWSTR file)
 
HRESULT assembly_release (ASSEMBLY *assembly)
 
HRESULT assembly_get_name (ASSEMBLY *assembly, LPWSTR *name)
 
HRESULT assembly_get_path (const ASSEMBLY *assembly, LPWSTR *path)
 
HRESULT assembly_get_version (ASSEMBLY *assembly, LPWSTR *version)
 
PEKIND assembly_get_architecture (ASSEMBLY *assembly)
 
HRESULT assembly_get_pubkey_token (ASSEMBLY *assembly, LPWSTR *token)
 
HRESULT assembly_get_runtime_version (ASSEMBLY *assembly, LPSTR *version)
 
HRESULT assembly_get_external_files (ASSEMBLY *assembly, LPWSTR **files, DWORD *count)
 
HRESULT IAssemblyName_SetPath (IAssemblyName *iface, LPCWSTR path)
 
HRESULT IAssemblyName_GetPath (IAssemblyName *iface, LPWSTR buf, ULONG *len)
 
static void token_to_str (BYTE *bytes, LPWSTR str)
 

Macro Definition Documentation

◆ BYTES_PER_TOKEN

#define BYTES_PER_TOKEN   8

Definition at line 449 of file fusionpriv.h.

◆ CHARS_PER_BYTE

#define CHARS_PER_BYTE   2

Definition at line 450 of file fusionpriv.h.

◆ TOKEN_LENGTH

#define TOKEN_LENGTH   (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)

Definition at line 451 of file fusionpriv.h.

Typedef Documentation

◆ ASSEMBLY

Definition at line 434 of file fusionpriv.h.

Function Documentation

◆ assembly_create()

HRESULT assembly_create ( ASSEMBLY **  out,
LPCWSTR  file 
)

Definition at line 641 of file assembly.c.

642{
644 HRESULT hr;
645
646 *out = NULL;
647
648 if (!(assembly = calloc(1, sizeof(*assembly)))) return E_OUTOFMEMORY;
649
650 assembly->path = wcsdup(file);
651 if (!assembly->path)
652 {
654 goto failed;
655 }
656
659 if (assembly->hfile == INVALID_HANDLE_VALUE)
660 {
662 goto failed;
663 }
664
666 0, 0, NULL);
667 if (!assembly->hmap)
668 {
670 goto failed;
671 }
672
673 assembly->data = MapViewOfFile(assembly->hmap, FILE_MAP_READ, 0, 0, 0);
674 if (!assembly->data)
675 {
677 goto failed;
678 }
679
681 if (FAILED(hr)) goto failed;
682
684 if (FAILED(hr)) goto failed;
685
686 *out = assembly;
687 return S_OK;
688
689failed:
691 return hr;
692}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
HRESULT assembly_release(ASSEMBLY *assembly)
Definition: assembly.c:694
static HRESULT parse_pe_header(ASSEMBLY *assembly)
Definition: assembly.c:603
static HRESULT parse_clr_metadata(ASSEMBLY *assembly)
Definition: assembly.c:560
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define calloc
Definition: rosglue.h:14
Definition: fci.c:123
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ assembly_get_architecture()

PEKIND assembly_get_architecture ( ASSEMBLY *  assembly)

Definition at line 788 of file assembly.c.

789{
790 if ((assembly->corhdr->MajorRuntimeVersion == 2) && (assembly->corhdr->MinorRuntimeVersion == 0))
791 return peNone; /* .NET 1.x assembly */
792
793 if (assembly->nthdr->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
794 return peAMD64; /* AMD64/IA64 assembly */
795
796 if ((assembly->corhdr->Flags & COMIMAGE_FLAGS_ILONLY) && !(assembly->corhdr->Flags & COMIMAGE_FLAGS_32BITREQUIRED))
797 return peMSIL; /* MSIL assembly */
798
799 return peI386; /* x86 assembly */
800}
@ peMSIL
Definition: fusion.idl:38
@ peI386
Definition: fusion.idl:39
@ peNone
Definition: fusion.idl:37
@ peAMD64
Definition: fusion.idl:41
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
@ COMIMAGE_FLAGS_ILONLY
Definition: winnt_old.h:3503
@ COMIMAGE_FLAGS_32BITREQUIRED
Definition: winnt_old.h:3504

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_external_files()

HRESULT assembly_get_external_files ( ASSEMBLY *  assembly,
LPWSTR **  files,
DWORD *  count 
)

Definition at line 856 of file assembly.c.

857{
858 LONG offset;
859 INT i, num_rows;
860 WCHAR **ret;
861 BYTE *ptr;
862 DWORD idx;
863
864 *count = 0;
865
866 offset = assembly->tables[TableFromToken(mdtFile)].offset;
867 if (offset == -1)
868 return S_OK;
869
871 if (!ptr)
872 return S_OK;
873
874 num_rows = assembly->tables[TableFromToken(mdtFile)].rows;
875 if (num_rows <= 0)
876 return S_OK;
877
878 if (!(ret = malloc(num_rows * sizeof(WCHAR *)))) return E_OUTOFMEMORY;
879
880 for (i = 0; i < num_rows; i++)
881 {
882 ptr += sizeof(DWORD); /* skip Flags field */
883 if (assembly->stringsz == sizeof(DWORD))
884 idx = *(DWORD *)ptr;
885 else
886 idx = *(WORD *)ptr;
887
889 if (!ret[i])
890 {
891 for (; i >= 0; i--) free(ret[i]);
892 free(ret);
893 return E_OUTOFMEMORY;
894 }
895 ptr += assembly->stringsz; /* skip Name field */
896 ptr += assembly->blobsz; /* skip Hash field */
897 }
898 *count = num_rows;
899 *files = ret;
900 return S_OK;
901}
@ mdtFile
Definition: corhdr.h:41
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
unsigned int idx
Definition: utils.c:40
return ret
Definition: mutex.c:147
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TableFromToken(tk)
Definition: assembly.c:39
static VOID * assembly_data_offset(ASSEMBLY *assembly, ULONG offset)
Definition: assembly.c:139
static LPWSTR assembly_dup_str(const ASSEMBLY *assembly, DWORD index)
Definition: assembly.c:709
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
JSAMPARRAY int num_rows
Definition: jpegint.h:420
static PVOID ptr
Definition: dispmode.c:27
#define DWORD
Definition: nt_native.h:44
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
int32_t INT
Definition: typedefs.h:58
unsigned char BYTE
Definition: xxhash.c:193

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_name()

HRESULT assembly_get_name ( ASSEMBLY *  assembly,
LPWSTR *  name 
)

Definition at line 723 of file assembly.c.

724{
725 BYTE *ptr;
726 LONG offset;
727 DWORD stridx;
728
729 offset = assembly->tables[TableFromToken(mdtAssembly)].offset;
730 if (offset == -1)
731 return E_FAIL;
732
734 if (!ptr)
735 return E_FAIL;
736
737 ptr += FIELD_OFFSET(ASSEMBLYTABLE, PublicKey) + assembly->blobsz;
738 if (assembly->stringsz == sizeof(DWORD))
739 stridx = *(DWORD *)ptr;
740 else
741 stridx = *(WORD *)ptr;
742
743 *name = assembly_dup_str(assembly, stridx);
744 if (!*name)
745 return E_OUTOFMEMORY;
746
747 return S_OK;
748}
@ mdtAssembly
Definition: corhdr.h:39
#define E_FAIL
Definition: ddrawi.h:102
Definition: name.c:39
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_path()

HRESULT assembly_get_path ( const ASSEMBLY *  assembly,
LPWSTR *  path 
)

Definition at line 750 of file assembly.c.

751{
752 WCHAR *cpy = malloc((lstrlenW(assembly->path) + 1) * sizeof(WCHAR));
753 *path = cpy;
754 if (cpy)
755 lstrcpyW(cpy, assembly->path);
756 else
757 return E_OUTOFMEMORY;
758
759 return S_OK;
760}
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_pubkey_token()

HRESULT assembly_get_pubkey_token ( ASSEMBLY *  assembly,
LPWSTR *  token 
)

Definition at line 807 of file assembly.c.

808{
809 ULONG i, size;
810 LONG offset;
811 BYTE hashdata[20], *pubkey, *ptr;
812 BYTE tokbytes[BYTES_PER_TOKEN];
813 WCHAR *tok;
814 DWORD idx;
815
816 *token = NULL;
817
818 offset = assembly->tables[TableFromToken(mdtAssembly)].offset;
819 if (offset == -1)
820 return E_FAIL;
821
823 if (!ptr)
824 return E_FAIL;
825
826 ptr += FIELD_OFFSET(ASSEMBLYTABLE, PublicKey);
827 if (assembly->blobsz == sizeof(DWORD))
828 idx = *(DWORD *)ptr;
829 else
830 idx = *(WORD *)ptr;
831
833
834 if (BCryptHash(BCRYPT_SHA1_ALG_HANDLE, NULL, 0, pubkey, size, hashdata, sizeof(hashdata)) != STATUS_SUCCESS)
835 return E_FAIL;
836
837 size = sizeof(hashdata);
838 for (i = size - 1; i >= size - 8; i--)
839 tokbytes[size - i - 1] = hashdata[i];
840
841 if (!(tok = malloc((TOKEN_LENGTH + 1) * sizeof(WCHAR))))
842 return E_OUTOFMEMORY;
843
844 token_to_str(tokbytes, tok);
845
846 *token = tok;
847 return S_OK;
848}
#define BCRYPT_SHA1_ALG_HANDLE
Definition: bcrypt.h:380
NTSTATUS WINAPI BCryptHash(BCRYPT_ALG_HANDLE handle, UCHAR *secret, ULONG secret_len, UCHAR *input, ULONG input_len, UCHAR *output, ULONG output_len)
Definition: bcrypt_main.c:1091
static const WCHAR pubkey[]
Definition: asmname.c:68
static BYTE * assembly_get_blob(ASSEMBLY *assembly, DWORD index, ULONG *size)
Definition: assembly.c:802
#define TOKEN_LENGTH
Definition: fusionpriv.h:451
#define BYTES_PER_TOKEN
Definition: fusionpriv.h:449
static void token_to_str(BYTE *bytes, LPWSTR str)
Definition: fusionpriv.h:453
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_runtime_version()

HRESULT assembly_get_runtime_version ( ASSEMBLY *  assembly,
LPSTR *  version 
)

Definition at line 850 of file assembly.c.

851{
852 *version = assembly->metadatahdr->Version;
853 return S_OK;
854}
static const WCHAR version[]
Definition: asmname.c:66

◆ assembly_get_version()

HRESULT assembly_get_version ( ASSEMBLY *  assembly,
LPWSTR *  version 
)

Definition at line 762 of file assembly.c.

763{
764 static const WCHAR format[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
765
766 ASSEMBLYTABLE *asmtbl;
767 LONG offset;
768
769 *version = NULL;
770
771 offset = assembly->tables[TableFromToken(mdtAssembly)].offset;
772 if (offset == -1)
773 return E_FAIL;
774
776 if (!asmtbl)
777 return E_FAIL;
778
779 if (!(*version = malloc(24 * sizeof(WCHAR))))
780 return E_OUTOFMEMORY;
781
782 swprintf(*version, 24, format, asmtbl->MajorVersion, asmtbl->MinorVersion,
783 asmtbl->BuildNumber, asmtbl->RevisionNumber);
784
785 return S_OK;
786}
#define swprintf
Definition: precomp.h:40
WORD RevisionNumber
Definition: fusionpriv.h:106
WORD BuildNumber
Definition: fusionpriv.h:105
WORD MinorVersion
Definition: fusionpriv.h:104
WORD MajorVersion
Definition: fusionpriv.h:103

Referenced by IAssemblyCacheImpl_InstallAssembly().

◆ assembly_release()

HRESULT assembly_release ( ASSEMBLY *  assembly)

Definition at line 694 of file assembly.c.

695{
696 if (!assembly)
697 return S_OK;
698
699 free(assembly->metadatahdr);
700 free(assembly->path);
702 CloseHandle(assembly->hmap);
703 CloseHandle(assembly->hfile);
704 free(assembly);
705
706 return S_OK;
707}
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746

◆ IAssemblyName_GetPath()

HRESULT IAssemblyName_GetPath ( IAssemblyName *  iface,
LPWSTR  buf,
ULONG *  len 
)

Definition at line 534 of file asmname.c.

535{
538
539 if (!name->path)
540 return S_OK;
541
542 if (!buf)
543 buffer_size = 0;
544
545 *len = lstrlenW(name->path) + 1;
546
547 if (*len <= buffer_size)
548 lstrcpyW(buf, name->path);
549 else
551
552 return S_OK;
553}
static IAssemblyNameImpl * unsafe_impl_from_IAssemblyName(IAssemblyName *iface)
Definition: asmname.c:516
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437

Referenced by IAssemblyCacheImpl_QueryAssemblyInfo(), and IAssemblyCacheImpl_UninstallAssembly().

◆ IAssemblyName_SetPath()

HRESULT IAssemblyName_SetPath ( IAssemblyName *  iface,
LPCWSTR  path 
)

Definition at line 523 of file asmname.c.

524{
526
527 name->path = wcsdup(path);
528 if (!name->path)
529 return E_OUTOFMEMORY;
530
531 return S_OK;
532}

Referenced by enum_gac_assemblies().

◆ token_to_str()

static void token_to_str ( BYTE *  bytes,
LPWSTR  str 
)
inlinestatic

Definition at line 453 of file fusionpriv.h.

454{
455 DWORD i;
456
457 static const WCHAR hexval[] = {
458 '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
459 };
460
461 for(i = 0; i < BYTES_PER_TOKEN; i++)
462 {
463 str[i * 2] = hexval[((bytes[i] >> 4) & 0xF)];
464 str[i * 2 + 1] = hexval[(bytes[i]) & 0x0F];
465 }
466 str[i * 2] = 0;
467}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
const WCHAR * str

Referenced by assembly_get_pubkey_token(), build_file_mask(), and compare_assembly_names().