diff options
Diffstat (limited to 'src/ext/Bal/dnchost/dncutil.cpp')
-rw-r--r-- | src/ext/Bal/dnchost/dncutil.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/ext/Bal/dnchost/dncutil.cpp b/src/ext/Bal/dnchost/dncutil.cpp index 34d14911..6486e6e9 100644 --- a/src/ext/Bal/dnchost/dncutil.cpp +++ b/src/ext/Bal/dnchost/dncutil.cpp | |||
@@ -2,6 +2,12 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | #define DNC_ENTRY_TYPE "WixToolset.Dnc.Host.BootstrapperApplicationFactory" | ||
6 | #define DNC_ENTRY_TYPEW L"WixToolset.Dnc.Host.BootstrapperApplicationFactory" | ||
7 | #define DNC_STATIC_ENTRY_METHOD "CreateBAFactory" | ||
8 | #define DNC_STATIC_ENTRY_METHODW L"CreateBAFactory" | ||
9 | #define DNC_STATIC_ENTRY_DELEGATEW L"WixToolset.Dnc.Host.StaticEntryDelegate" | ||
10 | |||
5 | // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h | 11 | // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h |
6 | #define InvalidArgFailure 0x80008081 | 12 | #define InvalidArgFailure 0x80008081 |
7 | #define HostApiBufferTooSmall 0x80008098 | 13 | #define HostApiBufferTooSmall 0x80008098 |
@@ -74,19 +80,28 @@ LExit: | |||
74 | HRESULT DnchostCreateFactory( | 80 | HRESULT DnchostCreateFactory( |
75 | __in HOSTFXR_STATE* pState, | 81 | __in HOSTFXR_STATE* pState, |
76 | __in LPCWSTR wzBaFactoryAssemblyName, | 82 | __in LPCWSTR wzBaFactoryAssemblyName, |
77 | __in LPCWSTR wzBaFactoryAssemblyPath, | 83 | __in LPCWSTR /*wzBaFactoryAssemblyPath*/, |
78 | __out IBootstrapperApplicationFactory** ppAppFactory | 84 | __out IBootstrapperApplicationFactory** ppAppFactory |
79 | ) | 85 | ) |
80 | { | 86 | { |
81 | HRESULT hr = S_OK; | 87 | HRESULT hr = S_OK; |
82 | PFNCREATEBAFACTORY pfnCreateBAFactory = NULL; | 88 | PFNCREATEBAFACTORY pfnCreateBAFactory = NULL; |
89 | LPWSTR sczEntryType = NULL; | ||
90 | LPWSTR sczEntryDelegate = NULL; | ||
91 | LPSTR sczBaFactoryAssemblyName = NULL; | ||
83 | 92 | ||
84 | if (pState->pfnGetFunctionPointer) | 93 | if (pState->pfnGetFunctionPointer) |
85 | { | 94 | { |
95 | hr = StrAllocFormatted(&sczEntryType, L"%ls,%ls", DNC_ENTRY_TYPEW, wzBaFactoryAssemblyName); | ||
96 | BalExitOnFailure(hr, "Failed to format entry type."); | ||
97 | |||
98 | hr = StrAllocFormatted(&sczEntryDelegate, L"%ls,%ls", DNC_STATIC_ENTRY_DELEGATEW, wzBaFactoryAssemblyName); | ||
99 | BalExitOnFailure(hr, "Failed to format entry delegate."); | ||
100 | |||
86 | hr = pState->pfnGetFunctionPointer( | 101 | hr = pState->pfnGetFunctionPointer( |
87 | DNC_ENTRY_TYPEW, | 102 | sczEntryType, |
88 | DNC_STATIC_ENTRY_METHODW, | 103 | DNC_STATIC_ENTRY_METHODW, |
89 | DNC_STATIC_ENTRY_DELEGATEW, | 104 | sczEntryDelegate, |
90 | NULL, | 105 | NULL, |
91 | NULL, | 106 | NULL, |
92 | reinterpret_cast<void**>(&pfnCreateBAFactory)); | 107 | reinterpret_cast<void**>(&pfnCreateBAFactory)); |
@@ -94,19 +109,26 @@ HRESULT DnchostCreateFactory( | |||
94 | } | 109 | } |
95 | else | 110 | else |
96 | { | 111 | { |
112 | hr = StrAnsiAllocString(&sczBaFactoryAssemblyName, wzBaFactoryAssemblyName, 0, CP_UTF8); | ||
113 | BalExitOnFailure(hr, "Failed to convert assembly name to UTF8: %ls", wzBaFactoryAssemblyName); | ||
114 | |||
97 | hr = pState->pfnCoreclrCreateDelegate( | 115 | hr = pState->pfnCoreclrCreateDelegate( |
98 | pState->pClrHandle, | 116 | pState->pClrHandle, |
99 | pState->dwDomainId, | 117 | pState->dwDomainId, |
100 | DNC_ASSEMBLY_FULL_NAME, | 118 | sczBaFactoryAssemblyName, |
101 | DNC_ENTRY_TYPE, | 119 | DNC_ENTRY_TYPE, |
102 | DNC_STATIC_ENTRY_METHOD, | 120 | DNC_STATIC_ENTRY_METHOD, |
103 | reinterpret_cast<void**>(&pfnCreateBAFactory)); | 121 | reinterpret_cast<void**>(&pfnCreateBAFactory)); |
104 | BalExitOnFailure(hr, "Failed to create delegate in app domain."); | 122 | BalExitOnFailure(hr, "Failed to create delegate in app domain."); |
105 | } | 123 | } |
106 | 124 | ||
107 | *ppAppFactory = pfnCreateBAFactory(wzBaFactoryAssemblyName, wzBaFactoryAssemblyPath); | 125 | *ppAppFactory = pfnCreateBAFactory(); |
108 | 126 | ||
109 | LExit: | 127 | LExit: |
128 | ReleaseStr(sczEntryType); | ||
129 | ReleaseStr(sczEntryDelegate); | ||
130 | ReleaseStr(sczBaFactoryAssemblyName); | ||
131 | |||
110 | return hr; | 132 | return hr; |
111 | } | 133 | } |
112 | 134 | ||
@@ -233,7 +255,7 @@ static HRESULT InitializeCoreClr( | |||
233 | } | 255 | } |
234 | else | 256 | else |
235 | { | 257 | { |
236 | ExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); | 258 | BalExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); |
237 | } | 259 | } |
238 | 260 | ||
239 | LExit: | 261 | LExit: |
@@ -295,6 +317,8 @@ static HRESULT InitializeCoreClrPre5( | |||
295 | 317 | ||
296 | for (DWORD i = 0; i < cDirectories; ++i) | 318 | for (DWORD i = 0; i < cDirectories; ++i) |
297 | { | 319 | { |
320 | Assert(rgDirectories); | ||
321 | |||
298 | hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath); | 322 | hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath); |
299 | BalExitOnFailure(hr, "Failed to allocate path to coreclr."); | 323 | BalExitOnFailure(hr, "Failed to allocate path to coreclr."); |
300 | 324 | ||
@@ -324,9 +348,9 @@ static HRESULT InitializeCoreClrPre5( | |||
324 | BalExitOnFailure(hr, "Failed to start coreclr."); | 348 | BalExitOnFailure(hr, "Failed to start coreclr."); |
325 | 349 | ||
326 | LExit: | 350 | LExit: |
327 | MemFree(rgDirectories); | 351 | ReleaseMem(rgDirectories); |
328 | MemFree(rgPropertyValues); | 352 | ReleaseMem(rgPropertyValues); |
329 | MemFree(rgPropertyKeys); | 353 | ReleaseMem(rgPropertyKeys); |
330 | ReleaseStr(sczCoreClrPath); | 354 | ReleaseStr(sczCoreClrPath); |
331 | 355 | ||
332 | return hr; | 356 | return hr; |