Exemple #1
0
FCIMPLEND

/// "parse" tells us to parse the simple name of the assembly as if it was the full name
/// almost never the right thing to do, but needed for compat
/* static */
FCIMPL3(FC_BOOL_RET, AssemblyNameNative::ReferenceMatchesDefinition, AssemblyNameBaseObject* refUNSAFE, AssemblyNameBaseObject* defUNSAFE, CLR_BOOL fParse)
{
    FCALL_CONTRACT;

    struct _gc
    {
        ASSEMBLYNAMEREF pRef;
        ASSEMBLYNAMEREF pDef;
    } gc;
    gc.pRef = (ASSEMBLYNAMEREF)ObjectToOBJECTREF (refUNSAFE);
    gc.pDef = (ASSEMBLYNAMEREF)ObjectToOBJECTREF (defUNSAFE);

    BOOL result = FALSE;
    HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);

    Thread *pThread = GetThread();

    CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease

    if (gc.pRef == NULL)
        COMPlusThrow(kArgumentNullException, W("ArgumentNull_AssemblyName"));
    if (gc.pDef == NULL)
        COMPlusThrow(kArgumentNullException, W("ArgumentNull_AssemblyName"));

    AssemblySpec refSpec;
    refSpec.InitializeSpec(&(pThread->m_MarshalAlloc), (ASSEMBLYNAMEREF*) &gc.pRef, fParse, FALSE);

    AssemblySpec defSpec;
    defSpec.InitializeSpec(&(pThread->m_MarshalAlloc), (ASSEMBLYNAMEREF*) &gc.pDef, fParse, FALSE);

#ifdef FEATURE_FUSION
    SafeComHolder<IAssemblyName> pRefName (NULL);
    IfFailThrow(refSpec.CreateFusionName(&pRefName, FALSE));

    SafeComHolder <IAssemblyName> pDefName (NULL);
    IfFailThrow(defSpec.CreateFusionName(&pDefName, FALSE));

    // Order matters: Ref->IsEqual(Def)
    result = (S_OK == pRefName->IsEqual(pDefName, ASM_CMPF_IL_ALL));
#else
    result=AssemblySpec::RefMatchesDef(&refSpec,&defSpec);
#endif
    HELPER_METHOD_FRAME_END();
    FC_RETURN_BOOL(result);
}
Exemple #2
0
/*============================DefineProperty============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::DefineProperty(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, INT32 attr, LPCBYTE pSignature, INT32 sigLength)
{
    QCALL_CONTRACT;
    
    mdProperty      pr = mdTokenNil; 
    
    BEGIN_QCALL;
    
    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Define the Property
    IfFailThrow(pRCW->GetEmitter()->DefineProperty(
            tkParent,                       // ParentTypeDef
            wszName,                        // Name of Member
            attr,                     // property Attributes (prDefaultProperty, etc);
            (PCCOR_SIGNATURE)pSignature,    // Blob value of a COM+ signature
            sigLength,                // Size of the signature blob
            ELEMENT_TYPE_VOID,              // don't specify the default value
            0,                              // no default value
            (ULONG) -1,                     // optional length
            mdMethodDefNil,                 // no setter
            mdMethodDefNil,                 // no getter
            NULL,                           // no other methods
            &pr));

    END_QCALL;

    return (INT32)pr;
}
Exemple #3
0
/*============================SetParamInfo============================
**Action: Helper to set parameter information
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::SetParamInfo(QCall::ModuleHandle pModule, UINT32 tkMethod, UINT32 iSequence, UINT32 iAttributes, LPCWSTR wszParamName)
{
    QCALL_CONTRACT;
    
    mdParamDef retVal = 0;

    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Set the methodimpl flags
    IfFailThrow(pRCW->GetEmitter()->DefineParam(
            tkMethod,
            iSequence,            // sequence of the parameter
            wszParamName, 
            iAttributes,          // change the impl flags
            ELEMENT_TYPE_VOID,
            0,
            (ULONG) -1,
            &retVal));

    END_QCALL;

    return (INT32)retVal;
}
Exemple #4
0
INT32 QCALLTYPE COMDynamicWrite::DefineMethod(QCall::ModuleHandle pModule, INT32 tkParent, LPCWSTR wszName, LPCBYTE pSignature, INT32 sigLength, INT32 attributes)
{
    QCALL_CONTRACT;
    
    mdMethodDef memberE = mdTokenNil;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Define the Method    
    IfFailThrow( pRCW->GetEmitter()->DefineMethod(tkParent,        //ParentTypeDef
                                                  wszName,         //Name of Member
                                                  attributes,               //Member Attributes (public, etc);
                                                  (PCCOR_SIGNATURE)pSignature,  //Blob value of a COM+ signature
                                                  sigLength,            //Size of the signature blob
                                                  0,                        //Code RVA
                                                  miIL | miManaged,         //Implementation Flags is default to managed IL
                                                  &memberE) );              //[OUT]methodToken

    END_QCALL;

    return (INT32) memberE;
}
Exemple #5
0
//---------------------------------------------------------------------------
//AddNewTPIndex adds and returns a per-appdomain TP entry whenever a new appdomain 
//is created. Our list count should be equal to the max number of appdomains created 
//in the system.
//
//Assumptions:
//This function needs to be called under the SystemDomain lock. 
//The ArrayListStatic data dtructure allows traversing of the counts without a 
//lock, but addition to the list requires synchronization.
//
TPIndex PerAppDomainTPCountList::AddNewTPIndex()
{
    STANDARD_VM_CONTRACT;

    DWORD count = s_appDomainIndexList.GetCount();
    DWORD i = FindFirstFreeTpEntry();
    
    if (i == UNUSED_THREADPOOL_INDEX)
        i = count;

    TPIndex index(i+1);
    if(count > i) 
    {

        IPerAppDomainTPCount * pAdCount = dac_cast<PTR_IPerAppDomainTPCount>(s_appDomainIndexList.Get(i));
        pAdCount->SetTPIndex(index);
        return index;
    }

#ifdef _MSC_VER
    // Disable this warning - we intentionally want __declspec(align()) to insert trailing padding for us
#pragma warning(disable:4316)  // Object allocated on the heap may not be aligned for this type.
#endif
    ManagedPerAppDomainTPCount * pAdCount = new ManagedPerAppDomainTPCount(index);
#ifdef _MSC_VER
#pragma warning(default:4316)  // Object allocated on the heap may not be aligned for this type.
#endif
    pAdCount->ResetState();

    IfFailThrow(s_appDomainIndexList.Append(pAdCount));

    return index;
}
Exemple #6
0
HRESULT CordbAppDomain::EnumerateThreads(ICorDebugThreadEnum **ppThreads)
{
    // @TODO E_NOIMPL this
    //
    // (use Process::EnumerateThreads and let users filter their own data)
    HRESULT hr = S_OK;
    PUBLIC_API_BEGIN(this);
    {
        ValidateOrThrow(ppThreads);

        RSInitHolder<CordbEnumFilter> pThreadEnum(
                new CordbEnumFilter(GetProcess(), GetProcess()->GetContinueNeuterList()));

        GetProcess()->PrepopulateThreadsOrThrow();

        RSInitHolder<CordbHashTableEnum> pEnum;
        GetProcess()->BuildThreadEnum(this, NULL, pEnum.GetAddr());

        // This builds up auxillary list. don't need pEnum after this.
        hr = pThreadEnum->Init(pEnum, this);
        IfFailThrow(hr);
    
        pThreadEnum.TransferOwnershipExternal(ppThreads);
    }
    PUBLIC_API_END(hr);
    return hr;
}
Exemple #7
0
/*
 * EnumerateModules enumerates all modules in the assembly
 */
HRESULT CordbAssembly::EnumerateModules(ICorDebugModuleEnum **ppModules)
{
    HRESULT hr = S_OK;
    PUBLIC_API_BEGIN(this);
    {
        ValidateOrThrow(ppModules);
        *ppModules = NULL;

        m_pAppDomain->PrepopulateModules();

        RSInitHolder<CordbEnumFilter> pModEnum(
            new CordbEnumFilter(GetProcess(), GetProcess()->GetContinueNeuterList()));
        
        RSInitHolder<CordbHashTableEnum> pEnum;
        
        CordbHashTableEnum::BuildOrThrow(
            this, 
            NULL,  // ownership
            &m_pAppDomain->m_modules,
            IID_ICorDebugModuleEnum,
            pEnum.GetAddr());
        
        // this will build up an auxillary list. Don't need pEnum after this.
        hr = pModEnum->Init(pEnum, this);
        IfFailThrow(hr);    

        pModEnum.TransferOwnershipExternal(ppModules);
       
    } 
    PUBLIC_API_END(hr);

    return hr;
}
Exemple #8
0
// Gets a CordbModule that has the given metadata interface
//
// Arguments:
//     pIMetaData - metadata interface
//
// Returns:
//     CordbModule whose associated metadata matches the metadata interface provided here
//     Throws on error. Returns non-null
//
CordbModule * CordbAppDomain::GetModuleFromMetaDataInterface(IUnknown *pIMetaData)
{
    HRESULT hr = S_OK;
        
    RSExtSmartPtr<IMetaDataImport> pImport;
    RSLockHolder lockHolder(GetProcess()->GetProcessLock());  // need for module enumeration      

    // Grab the interface we need...
    hr = pIMetaData->QueryInterface(IID_IMetaDataImport, (void**)&pImport);
    if (FAILED(hr))
    {
        ThrowHR(E_INVALIDARG);
    }

    // Get the mvid of the given module.
    GUID matchMVID;
    hr = pImport->GetScopeProps(NULL, 0, 0, &matchMVID);
    IfFailThrow(hr);

    CordbModule* pModule;
    HASHFIND findmodule;

    PrepopulateModules();

    for (pModule =  m_modules.FindFirst(&findmodule);
         pModule != NULL;
         pModule =  m_modules.FindNext(&findmodule))
    {
        IMetaDataImport * pImportCurrent = pModule->GetMetaDataImporter(); // throws
        _ASSERTE(pImportCurrent != NULL);
        
        // Get the mvid of this module
        GUID MVID;
        hr = pImportCurrent->GetScopeProps(NULL, 0, 0, &MVID);
        IfFailThrow(hr);

        if (MVID == matchMVID)
        {
            return pModule;
        }        
    }

    ThrowHR(E_INVALIDARG);
}
Exemple #9
0
/*============================SetPInvokeData============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetPInvokeData(QCall::ModuleHandle pModule, LPCWSTR wszDllName, LPCWSTR wszFunctionName, INT32 token, INT32 linkFlags)
{
    QCALL_CONTRACT;

    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 

    mdModuleRef mrImportDll = mdTokenNil;
    IfFailThrow(pRCW->GetEmitter()->DefineModuleRef(wszDllName, &mrImportDll));

    IfFailThrow(pRCW->GetEmitter()->DefinePinvokeMap(
        token,                        // the method token 
        linkFlags,                      // the mapping flags
        wszFunctionName,                // function name
        mrImportDll));

    IfFailThrow(pRCW->GetEmitter()->SetMethodProps(token, (DWORD) -1, 0x0, miIL));

    END_QCALL;
}
Exemple #10
0
// This function will add another interface impl
void QCALLTYPE COMDynamicWrite::AddInterfaceImpl(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkInterface)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    IfFailThrow( pRCW->GetEmitHelper()->AddInterfaceImpl(tdType, tkInterface) );

    END_QCALL;
}
Exemple #11
0
// This function will reset the parent class in metadata
void QCALLTYPE COMDynamicWrite::SetParentType(QCall::ModuleHandle pModule, INT32 tdType, INT32 tkParent)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    IfFailThrow( pRCW->GetEmitHelper()->SetTypeParent(tdType, tkParent) );

    END_QCALL;
}
int GetVersionResilientTypeHashCode(TypeHandle type)
{
    if (!type.IsTypeDesc())
    {
        MethodTable *pMT = type.AsMethodTable();

        _ASSERTE(!pMT->IsArray());
        _ASSERTE(!IsNilToken(pMT->GetCl()));

        LPCUTF8 szNamespace;
        LPCUTF8 szName;
        IfFailThrow(pMT->GetMDImport()->GetNameOfTypeDef(pMT->GetCl(), &szName, &szNamespace));
        int hashcode = ComputeNameHashCode(szNamespace, szName);

        MethodTable *pMTEnclosing = pMT->LoadEnclosingMethodTable(CLASS_LOAD_UNRESTOREDTYPEKEY);
        if (pMTEnclosing != NULL)
        {
            hashcode = ComputeNestedTypeHashCode(GetVersionResilientTypeHashCode(TypeHandle(pMTEnclosing)), hashcode);
        }

        if (!pMT->IsGenericTypeDefinition() && pMT->HasInstantiation())
        {
            return ComputeGenericInstanceHashCode(hashcode,
                pMT->GetInstantiation().GetNumArgs(), pMT->GetInstantiation(), GetVersionResilientTypeHashCode);
        }
        else
        {
            return hashcode;
        }
    }
    else
    if (type.IsArray())
    {
        ArrayTypeDesc *pArray = type.AsArray();
        return ComputeArrayTypeHashCode(GetVersionResilientTypeHashCode(pArray->GetArrayElementTypeHandle()), pArray->GetRank());
    }
    else
    if (type.IsPointer())
    {
        return ComputePointerTypeHashCode(GetVersionResilientTypeHashCode(type.AsTypeDesc()->GetTypeParam()));
    }
    else
    if (type.IsByRef())
    {
        return ComputeByrefTypeHashCode(GetVersionResilientTypeHashCode(type.AsTypeDesc()->GetTypeParam()));
    }

    assert(false);
    return 0;
}
Exemple #13
0
FCIMPLEND

//**************************************************
// LoadInMemoryTypeByName
// Explicitly loading an in memory type
// <TODO>@todo: this function is not dealing with nested type correctly yet.
// We will need to parse the full name by finding "+" for enclosing type, etc.</TODO>
//**************************************************
void QCALLTYPE COMModule::LoadInMemoryTypeByName(QCall::ModuleHandle pModule, LPCWSTR wszFullName)
{
    QCALL_CONTRACT;
    
    TypeHandle      typeHnd;

    BEGIN_QCALL;

    if (!pModule->IsReflection())  
        COMPlusThrow(kNotSupportedException, W("NotSupported_NonReflectedType"));   

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
    _ASSERTE(pRCW);

    // it is ok to use public import API because this is a dynamic module anyway. We are also receiving Unicode full name as
    // parameter.
    IMetaDataImport * pImport = pRCW->GetRWImporter();

    if (wszFullName == NULL)
        IfFailThrow( E_FAIL );

    // look up the handle
    mdTypeDef  td;
    HRESULT hr = pImport->FindTypeDefByName(wszFullName, mdTokenNil, &td);
    if (FAILED(hr))
    {
        if (hr != CLDB_E_RECORD_NOTFOUND)
            COMPlusThrowHR(hr);

        // Get the UTF8 version of strFullName
        MAKE_UTF8PTR_FROMWIDE(szFullName, wszFullName);
        pModule->GetAssembly()->ThrowTypeLoadException(szFullName, IDS_CLASSLOAD_GENERAL);
    }

    TypeKey typeKey(pModule, td);
    typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());

    END_QCALL;

    return;
}
Exemple #14
0
/*============================SetFieldLayoutOffset============================
**Action: set fieldlayout of a field
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetFieldLayoutOffset(QCall::ModuleHandle pModule, INT32 tkField, INT32 iOffset)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
    _ASSERTE(pRCW); 
    
    // Set the field layout
    IfFailThrow(pRCW->GetEmitHelper()->SetFieldLayoutHelper(
            tkField,                  // field 
            iOffset));                // layout offset

    END_QCALL;
}
Exemple #15
0
/*============================SetMethodImpl============================
** To set a Method's Implementation flags
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetMethodImpl(QCall::ModuleHandle pModule, INT32 tkMethod, INT32 attr)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Set the methodimpl flags
    IfFailThrow(pRCW->GetEmitter()->SetMethodImplFlags(
            tkMethod,
            attr));                // change the impl flags

    END_QCALL;
}
Exemple #16
0
static IUnknown* GetDomainsExposedObjectWorker(Thread* pThread, AppDomain* pDomain)
{
    HRESULT hr = S_OK;
    IUnknown* punk = NULL;
    OBJECTREF ref = NULL;
    GCPROTECT_BEGIN(ref);
    DECLARE_ALLOCA_CONTEXT_TRANSITION_FRAME(pFrame);
    // ok to do this here as we are just grabbing a wrapper. No managed code will run
    pThread->EnterContextRestricted(pDomain->GetDefaultContext(), pFrame, TRUE);
    ref = pDomain->GetExposedObject();
    IfFailThrow(QuickCOMStartup());   
    punk = GetComIPFromObjectRef(&ref);
    pThread->ReturnToContext(pFrame, TRUE);
    GCPROTECT_END();
    return punk;
}
Exemple #17
0
/*============================DefineMethodSemantics============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::DefineMethodSemantics(QCall::ModuleHandle pModule, INT32 tkAssociation, INT32 attr, INT32 tkMethod)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
    _ASSERTE(pRCW); 
    
    // Define the MethodSemantics
    IfFailThrow(pRCW->GetEmitHelper()->DefineMethodSemanticsHelper(
            tkAssociation,
            attr,
            tkMethod));

    END_QCALL;
}
Exemple #18
0
/*============================DefineMethodImpl============================
** Define a MethodImpl record
==============================================================================*/
void QCALLTYPE COMDynamicWrite::DefineMethodImpl(QCall::ModuleHandle pModule, UINT32 tkType, UINT32 tkBody, UINT32 tkDecl)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Set the methodimpl flags
    IfFailThrow(pRCW->GetEmitter()->DefineMethodImpl(
            tkType,
            tkBody,
            tkDecl));                  // change the impl flags

    END_QCALL;
}
Exemple #19
0
/*============================SetClassLayout============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
void QCALLTYPE COMDynamicWrite::SetClassLayout(QCall::ModuleHandle pModule, INT32 tk, INT32 iPackSize, UINT32 iTotalSize)
{
    QCALL_CONTRACT;
    
    BEGIN_QCALL;

    RefClassWriter* pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Define the packing size and total size of a class
    IfFailThrow(pRCW->GetEmitter()->SetClassLayout(
            tk,                     // Typedef
            iPackSize,                // packing size
            NULL,                     // no field layout 
            iTotalSize));           // total size for the type

    END_QCALL;
}
Exemple #20
0
HRESULT CorHost::CreateEvidence(IUnknown **pEvidence)
{
    HRESULT hr = S_OK;
    if (!pEvidence)
        return E_POINTER;

    BEGINCANNOTTHROWCOMPLUSEXCEPTION();
    // Create the domain. 
    Thread* pThread = GetThread();
    if (!pThread)
        IfFailGo(E_UNEXPECTED);

    IfFailGo(QuickCOMStartup());

    BOOL fWasGCEnabled;
    fWasGCEnabled = !pThread->PreemptiveGCDisabled();
    if (fWasGCEnabled)
        pThread->DisablePreemptiveGC();

    COMPLUS_TRY {
        struct _gc {
            OBJECTREF pEvidence;
        } gc;
        ZeroMemory(&gc, sizeof(gc));

        MethodTable* pMT = g_Mscorlib.GetClass(CLASS__EVIDENCE);
        GCPROTECT_BEGIN(gc);
        gc.pEvidence = AllocateObject(pMT);
        IfFailThrow(QuickCOMStartup());   
        *pEvidence = GetComIPFromObjectRef((OBJECTREF*) &gc.pEvidence);
        GCPROTECT_END();
    } COMPLUS_CATCH {
        hr = SecurityHelper::MapToHR(GETTHROWABLE());
    } COMPLUS_END_CATCH
          
    if (fWasGCEnabled)
        pThread->EnablePreemptiveGC();

ErrExit:
    ENDCANNOTTHROWCOMPLUSEXCEPTION();
    return hr;
}
HRESULT CLRTestHookManager::NextFileLoadLevel(DWORD adid, LPVOID domainfile,DWORD newlevel)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook* hook=m_pHooks[i].v1();
            if(hook)
            {
                HRESULT hr2=hook->NextFileLoadLevel( adid,  domainfile, newlevel);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }
    IfFailThrow(hr);
    return hr;
}
HRESULT CLRTestHookManager::LeftAppDomain(DWORD adid)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook* hook=m_pHooks[i].v1();
            if(hook)
            {
                HRESULT hr2=hook->LeftAppDomain(adid);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }
    IfFailThrow(hr);   
    return hr;
}
HRESULT CLRTestHookManager::StartingNativeImageBind(LPCWSTR wszAsmName, BOOL bIsCompilationProcess)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook3* hook=m_pHooks[i].v3();
            if(hook)
            {
                HRESULT hr2=hook->StartingNativeImageBind(wszAsmName, bIsCompilationProcess);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }

    IfFailThrow(hr);
    return hr;
}
HRESULT CLRTestHookManager::CompletedNativeImageBind(LPVOID pFile,LPCUTF8 simpleName, BOOL hasNativeImage)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook3* hook=m_pHooks[i].v3();
            if(hook)
            {
                HRESULT hr2=hook->CompletedNativeImageBind(pFile, simpleName, hasNativeImage);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }

    IfFailThrow(hr);
    return hr;
}
HRESULT CLRTestHookManager::AboutToLockImage(LPCWSTR wszPath, BOOL bIsCompilationProcess)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook3* hook=m_pHooks[i].v3();
            if(hook)
            {
                HRESULT hr2=hook->AboutToLockImage(wszPath, bIsCompilationProcess);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }

    IfFailThrow(hr);
    return hr;
}
Exemple #26
0
// This function will create a method within the class
INT32 QCALLTYPE COMDynamicWrite::DefineMethodSpec(QCall::ModuleHandle pModule, INT32 tkParent, LPCBYTE pSignature, INT32 sigLength)
{
    QCALL_CONTRACT;
    
    mdMethodDef memberE = mdTokenNil;
    
    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    // Define the Method    
    IfFailThrow( pRCW->GetEmitter()->DefineMethodSpec(tkParent,         //ParentTypeDef
                                                      (PCCOR_SIGNATURE)pSignature, //Blob value of a COM+ signature
                                                      sigLength,            //Size of the signature blob
                                                      &memberE) );              //[OUT]methodToken

    END_QCALL;

    return (INT32) memberE;
}
HRESULT CLRTestHookManager::AppDomainCanBeUnloaded(DWORD adid, BOOL bUnsafePoint)
{
    STATIC_CONTRACT_THROWS;
    HRESULT hr=S_OK;
    {
        if (!ThreadCanBeAborted())
            return S_OK;
        for (LONG i=0;i<m_nHooks;i++)
        {
            ICLRTestHook* hook=m_pHooks[i].v1();
            if(hook)
            {
                HRESULT hr2=hook->AppDomainCanBeUnloaded(adid,bUnsafePoint);
                _ASSERTE(SUCCEEDED(hr)||SUCCEEDED(hr2));
                if (SUCCEEDED(hr))
                    hr=hr2;
            }
        }
    }
    IfFailThrow(hr);
    return hr;
}
JsValueRef InvokeConsole(const wchar_t* kind, JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
#ifdef _DEBUG

    wchar_t buff[56];
    swprintf(buff, 56, L"[JS {%s}] ", kind);
    OutputDebugStringW(buff);

    // First argument is this-context, ignore...
    for (USHORT i = 1; i < argumentCount; i++)
    {
        std::set<JsValueRef> values;
        IfFailThrow(StringifyJsValue(arguments[i], 0, values), L"Failed to convert object to string");
        OutputDebugStringW(L" ");
    }

    OutputDebugStringW(L"\n");

#endif

    return JS_INVALID_REFERENCE;
};
Exemple #29
0
HRESULT CorHost::CreateDomainSetup(IUnknown **pAppDomainSetup)
{
    HRESULT hr = S_OK;

    if (!pAppDomainSetup)
        return E_POINTER;

    BEGINCANNOTTHROWCOMPLUSEXCEPTION();
    // Create the domain. 
    Thread* pThread = GetThread();
    if (!pThread)
        IfFailGo(E_UNEXPECTED);

    IfFailGo(QuickCOMStartup());

    BEGIN_ENSURE_COOPERATIVE_GC();

    COMPLUS_TRY {
        struct _gc {
            OBJECTREF pSetup;
        } gc;
        ZeroMemory(&gc, sizeof(gc));

        MethodTable* pMT = g_Mscorlib.GetClass(CLASS__APPDOMAIN_SETUP);
        GCPROTECT_BEGIN(gc);
        gc.pSetup = AllocateObject(pMT);
        IfFailThrow(QuickCOMStartup());   
        *pAppDomainSetup = GetComIPFromObjectRef((OBJECTREF*) &gc.pSetup);
        GCPROTECT_END();
    } COMPLUS_CATCH {
        hr = SecurityHelper::MapToHR(GETTHROWABLE());
    } COMPLUS_END_CATCH
          
    END_ENSURE_COOPERATIVE_GC();

 ErrExit:
    ENDCANNOTTHROWCOMPLUSEXCEPTION();
    return hr;
}
Exemple #30
0
/*============================GetTokenFromSig============================
**Action:
**Returns:
**Arguments:
**Exceptions:
==============================================================================*/
INT32 QCALLTYPE COMDynamicWrite::GetTokenFromSig(QCall::ModuleHandle pModule, LPCBYTE pSignature, INT32 sigLength)
{
    QCALL_CONTRACT;
    
    mdSignature retVal = 0;

    BEGIN_QCALL;

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter(); 
    _ASSERTE(pRCW); 
    
    _ASSERTE(pSignature);

    // Define the signature
    IfFailThrow(pRCW->GetEmitter()->GetTokenFromSig(
            pSignature,                     // Signature blob
            sigLength,                      // blob length
            &retVal));                      // returned token

    END_QCALL;

    return (INT32)retVal;
}