summaryrefslogtreecommitdiff
path: root/src/vm/commodule.h
blob: 255b22dfbfe1f4cc8b40bb5d79753ad2b3b427cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
////////////////////////////////////////////////////////////////////////////////



#ifndef _COMModule_H_
#define _COMModule_H_

#include "invokeutil.h"

class Module;

class COMModule
{
public:
    // Attaches an unmanaged symwriter to a newly created dynamic module.
    static FCDECL2(LPVOID, nCreateISymWriterForDynamicModule, ReflectModuleBaseObject* reflectionModuleUNSAFE, StringObject* filenameUNSAFE);

#ifdef  FEATURE_MULTIMODULE_ASSEMBLIES
    // DefineDynamicModule
    // This method will create a dynamic module given an assembly
    static
    void QCALLTYPE DefineDynamicModule(QCall::AssemblyHandle pContainingAssembly, BOOL emitSymbolInfo, LPCWSTR pModuleName, LPCWSTR pFilename, QCall::StackCrawlMarkHandle stackMark, LPVOID* ppInternalSymWriter, QCall::ObjectHandleOnStack retModule, BOOL fIsTransient, INT32* ptkFile);
#endif // FEATURE_MULTIMODULE_ASSEMBLIES

    // IsTransient
    // Determine if a Module is transient
    static 
    BOOL QCALLTYPE IsTransient(QCall::ModuleHandle pModule);

    // GetTypeRef
    // This function will return the class token for the named element.
    static 
    mdTypeRef QCALLTYPE GetTypeRef(QCall::ModuleHandle pModule,
                                   LPCWSTR wszFullName,
                                   QCall::ModuleHandle pRefedModule,
                                   LPCWSTR wszRefedModuleFileName,
                                   INT32 tkResolution);

    // LoadInMemoryTypeByName
    // This function will return the class token for the named element.
    static
    void QCALLTYPE LoadInMemoryTypeByName(QCall::ModuleHandle pModule, LPCWSTR wszFullName);


    // SetFieldRVAContent
    // This function is used to set the FieldRVA with the content data
    static
    void QCALLTYPE SetFieldRVAContent(QCall::ModuleHandle pModule, INT32 tkField, LPCBYTE pContent, INT32 length);


    //GetArrayMethodToken
    static 
    INT32 QCALLTYPE GetArrayMethodToken(QCall::ModuleHandle pModule,
                                        INT32 tkTypeSpec, 
                                        LPCWSTR wszMethodName,
                                        LPCBYTE pSignature,
                                        INT32 sigLength);

    // GetMemberRefToken
    // This function will return the MemberRef token 
    static
    INT32 QCALLTYPE GetMemberRef(QCall::ModuleHandle pModule, QCall::ModuleHandle pRefedModule, INT32 tr, INT32 token);

    // This function return a MemberRef token given a MethodInfo describing a array method
    static
    INT32 QCALLTYPE GetMemberRefOfMethodInfo(QCall::ModuleHandle pModule, INT32 tr, MethodDesc * method);


    // GetMemberRefOfFieldInfo
    // This function will return a memberRef token given a FieldInfo
    static
    mdMemberRef QCALLTYPE GetMemberRefOfFieldInfo(QCall::ModuleHandle pModule, mdTypeDef tr, EnregisteredTypeHandle th, mdFieldDef tkField);

    // GetMemberRefFromSignature
    // This function will return the MemberRef token given the signature from managed code
    static
    INT32 QCALLTYPE GetMemberRefFromSignature(QCall::ModuleHandle pModule, 
                                              INT32 tr,
                                              LPCWSTR wszMemberName,
                                              LPCBYTE pSignature,
                                              INT32 sigLength);

    // GetTokenFromTypeSpec
    static
    mdTypeSpec QCALLTYPE GetTokenFromTypeSpec(QCall::ModuleHandle pModule, LPCBYTE pSignature, INT32 sigLength);

    // GetType
    // Given a class type, this method will look for that type
    //  with in the module.
    static
    void QCALLTYPE GetType(QCall::ModuleHandle pModule, LPCWSTR wszName, BOOL bThrowOnError, BOOL bIgnoreCase, QCall::ObjectHandleOnStack retType, QCall::ObjectHandleOnStack keepAlive);

    // Get class will return an array contain all of the classes
    //  that are defined within this Module.
    static FCDECL1(Object*, GetTypes,  ReflectModuleBaseObject* pModuleUNSAFE);

    // GetStringConstant
    // If this is a dynamic module, this routine will define a new 
    //  string constant or return the token of an existing constant.
    static
    mdString QCALLTYPE GetStringConstant(QCall::ModuleHandle pModule, LPCWSTR pwzValue, INT32 iLength);

#if defined(FEATURE_X509) && defined(FEATURE_CAS_POLICY)
    /*X509Certificate*/
    static
    void QCALLTYPE GetSignerCertificate(QCall::ModuleHandle pModule, QCall::ObjectHandleOnStack retData);
#endif // #if defined(FEATURE_X509) && defined(FEATURE_CAS_POLICY)

    static
    void QCALLTYPE SetModuleName(QCall::ModuleHandle pModule, LPCWSTR wszModuleName);

    static FCDECL1(FC_BOOL_RET, IsResource, ReflectModuleBaseObject* pModuleUNSAFE);

    static FCDECL1(Object*,     GetMethods,             ReflectModuleBaseObject* refThisUNSAFE);

    static
    void QCALLTYPE GetScopeName(QCall::ModuleHandle pModule, QCall::StringHandleOnStack retString);

    static 
    void QCALLTYPE GetFullyQualifiedName(QCall::ModuleHandle pModule, QCall::StringHandleOnStack retString);

    static
    HINSTANCE QCALLTYPE GetHINSTANCE(QCall::ModuleHandle pModule);

    static void DefineTypeRefHelper(
        IMetaDataEmit       *pEmit,         // given emit scope
        mdTypeDef           td,             // given typedef in the emit scope
        mdTypeRef           *ptr);          // return typeref

};

class COMPunkSafeHandle
{
  public:
#ifdef FEATURE_CORECLR
    static FCDECL0(void*, nGetDReleaseTarget);
#endif
};

#endif