Skip to content

Commit acc22ee

Browse files
Call RoInitialize
1 parent e58b722 commit acc22ee

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

lib/Runtime/Base/DelayLoadLibrary.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,32 @@ namespace Js
209209
return E_NOTIMPL;
210210
}
211211

212+
HRESULT DelayLoadWinRtFoundation::RoInitialize(
213+
_In_ DelayLoadWinRtFoundation::RO_INIT_TYPE initType
214+
)
215+
{
216+
if (m_hModule)
217+
{
218+
if (m_pfnRoInitialize == nullptr)
219+
{
220+
m_pfnRoInitialize = (PFNRoInitialize)GetFunction("RoInitialize");
221+
if (m_pfnRoInitialize == nullptr)
222+
{
223+
return E_UNEXPECTED;
224+
}
225+
}
226+
Assert(m_pfnRoInitialize != nullptr);
227+
return m_pfnRoInitialize(initType);
228+
}
229+
return E_NOTIMPL;
230+
}
231+
212232
#ifdef INTL_WINGLOB
213-
void DelayLoadWindowsGlobalization::Ensure(Js::DelayLoadWinRtString *winRTStringLibrary)
233+
void DelayLoadWindowsGlobalization::Ensure(Js::DelayLoadWinRtFoundation *winRTFoundationLibrary, Js::DelayLoadWinRtString *winRTStringLibrary)
214234
{
215235
if (!this->m_isInit)
216236
{
237+
winRTFoundationLibrary->RoInitialize(DelayLoadWinRtFoundation::RO_INIT_TYPE::RO_INIT_MULTITHREADED);
217238
DelayLoadLibrary::EnsureFromSystemDirOnly();
218239

219240
#if DBG
@@ -234,6 +255,7 @@ namespace Js
234255
hasGlobalizationDllLoaded = true;
235256
}
236257
this->winRTStringLibrary = winRTStringLibrary;
258+
this->winRTFoundationLibrary = winRTFoundationLibrary;
237259
this->winRTStringsPresent = GetFunction("WindowsDuplicateString") != nullptr;
238260
}
239261
}

lib/Runtime/Base/DelayLoadLibrary.h

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//-------------------------------------------------------------------------------------------------------
66
#pragma once
77

8-
//#include <roapi.h>
98
#include "activation.h"
109
#include <winstring.h>
1110

@@ -63,6 +62,8 @@ namespace Js
6362
};
6463

6564
#ifdef INTL_WINGLOB
65+
class DelayLoadWinRtFoundation;
66+
6667
class DelayLoadWindowsGlobalization sealed : public DelayLoadWinRtString
6768
{
6869
private:
@@ -72,13 +73,15 @@ namespace Js
7273
PFNCWDllGetActivationFactory m_pfnFNCWDllGetActivationFactory;
7374

7475
Js::DelayLoadWinRtString *winRTStringLibrary;
76+
Js::DelayLoadWinRtFoundation *winRTFoundationLibrary;
7577
bool winRTStringsPresent;
7678
bool hasGlobalizationDllLoaded;
7779

7880
public:
7981
DelayLoadWindowsGlobalization() : DelayLoadWinRtString(),
8082
m_pfnFNCWDllGetActivationFactory(nullptr),
8183
winRTStringLibrary(nullptr),
84+
winRTFoundationLibrary(nullptr),
8285
winRTStringsPresent(false),
8386
hasGlobalizationDllLoaded(false) { }
8487

@@ -92,7 +95,7 @@ namespace Js
9295
{
9396
return _u("jsIntl.dll");
9497
}
95-
void Ensure(Js::DelayLoadWinRtString *winRTStringLibrary);
98+
void Ensure(Js::DelayLoadWinRtFoundation *winRTFoundationLibrary, Js::DelayLoadWinRtString *winRTStringLibrary);
9699

97100
HRESULT DllGetActivationFactory(_In_ HSTRING activatibleClassId, _Out_ IActivationFactory** factory);
98101
bool HasGlobalizationDllLoaded();
@@ -108,6 +111,12 @@ namespace Js
108111

109112
class DelayLoadWinRtFoundation sealed : public DelayLoadLibrary
110113
{
114+
public:
115+
enum class RO_INIT_TYPE {
116+
// COM calls objects on any thread.
117+
RO_INIT_MULTITHREADED = 1
118+
};
119+
111120
private:
112121

113122
// DelayLoadWindowsFoundation specific functions
@@ -116,14 +125,22 @@ namespace Js
116125
typedef FNCWRoGetActivationFactory* PFNCWRoGetActivationFactory;
117126
PFNCWRoGetActivationFactory m_pfnFNCWRoGetActivationFactory;
118127

128+
typedef HRESULT(*PFNRoInitialize)(RO_INIT_TYPE);
129+
PFNRoInitialize m_pfnRoInitialize;
130+
119131
public:
120-
DelayLoadWinRtFoundation() : DelayLoadLibrary(),
121-
m_pfnFNCWRoGetActivationFactory(nullptr) { }
132+
DelayLoadWinRtFoundation()
133+
: DelayLoadLibrary(),
134+
m_pfnFNCWRoGetActivationFactory(nullptr),
135+
m_pfnRoInitialize(nullptr)
136+
{
137+
}
122138

123-
virtual ~DelayLoadWinRtFoundation() { }
139+
virtual ~DelayLoadWinRtFoundation() {}
124140

125141
LPCTSTR GetLibraryName() const { return _u("api-ms-win-core-winrt-l1-1-0.dll"); }
126142

143+
HRESULT RoInitialize(_In_ RO_INIT_TYPE initType);
127144
HRESULT RoGetActivationFactory(
128145
_In_ HSTRING activatibleClassId,
129146
_In_ REFIID iid,

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,7 +4595,7 @@ Js::WindowsGlobalizationAdapter* ThreadContext::GetWindowsGlobalizationAdapter()
45954595

45964596
Js::DelayLoadWindowsGlobalization* ThreadContext::GetWindowsGlobalizationLibrary()
45974597
{
4598-
delayLoadWindowsGlobalizationLibrary.Ensure(this->GetWinRTStringLibrary());
4598+
delayLoadWindowsGlobalizationLibrary.Ensure(this->GetWinRtFoundationLibrary(), this->GetWinRTStringLibrary());
45994599

46004600
return &delayLoadWindowsGlobalizationLibrary;
46014601
}
@@ -4607,7 +4607,8 @@ Js::WindowsFoundationAdapter* ThreadContext::GetWindowsFoundationAdapter()
46074607
{
46084608
return &windowsFoundationAdapter;
46094609
}
4610-
4610+
#endif
4611+
#if defined(ENABLE_FOUNDATION_OBJECT) || defined(INTL_WINGLOB)
46114612
Js::DelayLoadWinRtFoundation* ThreadContext::GetWinRtFoundationLibrary()
46124613
{
46134614
delayLoadWinRtFoundationLibrary.EnsureFromSystemDirOnly();

lib/Runtime/Base/ThreadContext.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,10 @@ class ThreadContext sealed :
779779
Js::WindowsGlobalizationAdapter windowsGlobalizationAdapter;
780780
#endif
781781
#endif
782-
#ifdef ENABLE_FOUNDATION_OBJECT
782+
#if defined(ENABLE_FOUNDATION_OBJECT) || defined(ENABLE_GLOBALIZATION)
783783
Js::DelayLoadWinRtFoundation delayLoadWinRtFoundationLibrary;
784+
#endif
785+
#ifdef ENABLE_FOUNDATION_OBJECT
784786
Js::WindowsFoundationAdapter windowsFoundationAdapter;
785787
#endif
786788
#endif
@@ -892,8 +894,10 @@ class ThreadContext sealed :
892894
Js::WindowsGlobalizationAdapter *GetWindowsGlobalizationAdapter();
893895
#endif
894896
#endif
895-
#ifdef ENABLE_FOUNDATION_OBJECT
897+
#if defined(ENABLE_FOUNDATION_OBJECT) || defined(ENABLE_GLOBALIZATION)
896898
Js::DelayLoadWinRtFoundation *GetWinRtFoundationLibrary();
899+
#endif
900+
#ifdef ENABLE_FOUNDATION_OBJECT
897901
Js::WindowsFoundationAdapter *GetWindowsFoundationAdapter();
898902
#endif
899903
#endif

0 commit comments

Comments
 (0)