summaryrefslogtreecommitdiff
path: root/src/vm/corhost.cpp
diff options
context:
space:
mode:
authorSteve MacLean <Steve.MacLean@microsoft.com>2018-10-10 12:50:30 -0400
committerSteve MacLean <stmaclea@microsoft.com>2018-10-25 13:21:48 -0400
commitacf316089c3e600987ae94fa1750a7dc3029a284 (patch)
tree59adba3dca11b5d6a162653e391025fffaad7d2e /src/vm/corhost.cpp
parentc99e2dd5ebe9068db16d5273d080601368503039 (diff)
downloadcoreclr-acf316089c3e600987ae94fa1750a7dc3029a284.tar.gz
coreclr-acf316089c3e600987ae94fa1750a7dc3029a284.tar.bz2
coreclr-acf316089c3e600987ae94fa1750a7dc3029a284.zip
Restore ExecuteInDefaultAppDomain implementation
Restore deleted ExecuteInDefaultAppDomain implentation Enable for CoreCLR Cleanup for CoreCLR
Diffstat (limited to 'src/vm/corhost.cpp')
-rw-r--r--src/vm/corhost.cpp82
1 files changed, 79 insertions, 3 deletions
diff --git a/src/vm/corhost.cpp b/src/vm/corhost.cpp
index 03fbdb9df8..463f6f68fd 100644
--- a/src/vm/corhost.cpp
+++ b/src/vm/corhost.cpp
@@ -520,9 +520,85 @@ HRESULT CorHost2::ExecuteInDefaultAppDomain(LPCWSTR pwzAssemblyPath,
return HOST_E_CLRNOTAVAILABLE;
}
-
- // Ensure that code is not loaded in the Default AppDomain
- return HOST_E_INVALIDOPERATION;
+ if(! (pwzAssemblyPath && pwzTypeName && pwzMethodName) )
+ return E_POINTER;
+
+ HRESULT hr = S_OK;
+
+ BEGIN_ENTRYPOINT_NOTHROW;
+
+ Thread *pThread = GetThread();
+ if (pThread == NULL)
+ {
+ pThread = SetupThreadNoThrow(&hr);
+ if (pThread == NULL)
+ {
+ goto ErrExit;
+ }
+ }
+
+ _ASSERTE (!pThread->PreemptiveGCDisabled());
+
+ _ASSERTE (SystemDomain::GetCurrentDomain()->GetId().m_dwId == DefaultADID);
+
+ INSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP;
+ INSTALL_UNWIND_AND_CONTINUE_HANDLER;
+
+ EX_TRY
+ {
+ Assembly *pAssembly = AssemblySpec::LoadAssembly(pwzAssemblyPath);
+
+ SString szTypeName(pwzTypeName);
+ StackScratchBuffer buff1;
+ const char* szTypeNameUTF8 = szTypeName.GetUTF8(buff1);
+ MethodTable *pMT = ClassLoader::LoadTypeByNameThrowing(pAssembly,
+ NULL,
+ szTypeNameUTF8).AsMethodTable();
+
+ SString szMethodName(pwzMethodName);
+ StackScratchBuffer buff;
+ const char* szMethodNameUTF8 = szMethodName.GetUTF8(buff);
+ MethodDesc *pMethodMD = MemberLoader::FindMethod(pMT, szMethodNameUTF8, &gsig_SM_Str_RetInt);
+
+ if (!pMethodMD)
+ {
+ hr = COR_E_MISSINGMETHOD;
+ }
+ else
+ {
+ GCX_COOP();
+
+ MethodDescCallSite method(pMethodMD);
+
+ STRINGREF sref = NULL;
+ GCPROTECT_BEGIN(sref);
+
+ if (pwzArgument)
+ sref = StringObject::NewString(pwzArgument);
+
+ ARG_SLOT MethodArgs[] =
+ {
+ ObjToArgSlot(sref)
+ };
+ DWORD retval = method.Call_RetI4(MethodArgs);
+ if (pReturnValue)
+ {
+ *pReturnValue = retval;
+ }
+
+ GCPROTECT_END();
+ }
+ }
+ EX_CATCH_HRESULT(hr);
+
+ UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;
+ UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP;
+
+ErrExit:
+
+ END_ENTRYPOINT_NOTHROW;
+
+ return hr;
}
HRESULT ExecuteInAppDomainHelper(FExecuteInAppDomainCallback pCallback,