react-native-windows 0.71.16 → 0.71.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/Directory.Build.props +5 -0
  2. package/Microsoft.ReactNative/IReactDispatcher.cpp +4 -0
  3. package/Microsoft.ReactNative/IReactDispatcher.h +1 -0
  4. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -4
  5. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +31 -11
  6. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +0 -2
  7. package/Microsoft.ReactNative/Views/DevMenu.cpp +3 -3
  8. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +16 -0
  9. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +43 -12
  10. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +17 -6
  11. package/Microsoft.ReactNative.Managed/packages.lock.json +8 -8
  12. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  13. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  14. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +1 -1
  15. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  16. package/PropertySheets/JSEngine.props +4 -4
  17. package/PropertySheets/React.Cpp.props +1 -0
  18. package/PropertySheets/Warnings.props +6 -0
  19. package/ReactCommon/ReactCommon.vcxproj +53 -1
  20. package/ReactCommon/cgmanifest.json +15 -0
  21. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +36 -0
  22. package/Shared/DevSupportManager.cpp +2 -9
  23. package/Shared/DevSupportManager.h +2 -6
  24. package/Shared/HermesRuntimeHolder.cpp +344 -84
  25. package/Shared/HermesRuntimeHolder.h +32 -21
  26. package/Shared/HermesSamplingProfiler.cpp +66 -14
  27. package/Shared/HermesSamplingProfiler.h +5 -3
  28. package/Shared/InspectorPackagerConnection.cpp +62 -108
  29. package/Shared/InspectorPackagerConnection.h +9 -21
  30. package/Shared/JSI/RuntimeHolder.h +2 -2
  31. package/Shared/JSI/ScriptStore.h +18 -20
  32. package/Shared/JSI/V8RuntimeHolder.cpp +262 -0
  33. package/Shared/JSI/V8RuntimeHolder.h +37 -0
  34. package/Shared/OInstance.cpp +17 -33
  35. package/Shared/SafeLoadLibrary.cpp +41 -0
  36. package/Shared/SafeLoadLibrary.h +15 -0
  37. package/Shared/Shared.vcxitems +19 -8
  38. package/Shared/Shared.vcxitems.filters +23 -30
  39. package/package.json +3 -3
  40. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
  41. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +0 -2103
  42. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +0 -73
  43. package/Shared/HermesShim.cpp +0 -118
  44. package/Shared/HermesShim.h +0 -21
  45. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +0 -209
  46. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +0 -44
  47. package/Shared/V8JSIRuntimeHolder.cpp +0 -70
  48. package/Shared/V8JSIRuntimeHolder.h +0 -53
@@ -0,0 +1,262 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "V8RuntimeHolder.h"
5
+ #include <ApiLoaders/V8Api.h>
6
+ #include <NodeApiJsiRuntime.h>
7
+ #include <crash/verifyElseCrash.h>
8
+ #include "SafeLoadLibrary.h"
9
+
10
+ using namespace Microsoft::NodeApiJsi;
11
+
12
+ #define CRASH_ON_ERROR(result) VerifyElseCrash(result == napi_ok);
13
+
14
+ namespace Microsoft::ReactNative {
15
+ namespace {
16
+
17
+ class V8FuncResolver : public IFuncResolver {
18
+ public:
19
+ V8FuncResolver() : libHandle_(SafeLoadLibrary(L"v8jsi.dll")) {}
20
+
21
+ FuncPtr getFuncPtr(const char *funcName) override {
22
+ return reinterpret_cast<FuncPtr>(GetProcAddress(libHandle_, funcName));
23
+ }
24
+
25
+ private:
26
+ HMODULE libHandle_;
27
+ };
28
+
29
+ V8Api &initV8Api() noexcept {
30
+ static V8FuncResolver funcResolver;
31
+ static V8Api s_v8Api(&funcResolver);
32
+ V8Api::setCurrent(&s_v8Api);
33
+ return s_v8Api;
34
+ }
35
+
36
+ V8Api &getV8Api() noexcept {
37
+ static V8Api &s_v8Api = initV8Api();
38
+ return s_v8Api;
39
+ }
40
+
41
+ class V8Task {
42
+ public:
43
+ V8Task(void *taskData, jsr_task_run_cb taskRunCallback, jsr_data_delete_cb taskDataDeleteCallback, void *deleterData)
44
+ : taskData_(taskData),
45
+ taskRunCallback_(taskRunCallback),
46
+ taskDataDeleteCallback_(taskDataDeleteCallback),
47
+ deleterData_(deleterData) {}
48
+
49
+ V8Task(const V8Task &other) = delete;
50
+ V8Task &operator=(const V8Task &other) = delete;
51
+
52
+ ~V8Task() {
53
+ if (taskDataDeleteCallback_ != nullptr) {
54
+ taskDataDeleteCallback_(taskData_, deleterData_);
55
+ }
56
+ }
57
+
58
+ void Run() const {
59
+ if (taskRunCallback_ != nullptr) {
60
+ taskRunCallback_(taskData_);
61
+ }
62
+ }
63
+
64
+ private:
65
+ void *taskData_;
66
+ jsr_task_run_cb taskRunCallback_;
67
+ jsr_data_delete_cb taskDataDeleteCallback_;
68
+ void *deleterData_;
69
+ };
70
+
71
+ class V8TaskRunner {
72
+ public:
73
+ static void Create(jsr_config config, std::shared_ptr<facebook::react::MessageQueueThread> queue) {
74
+ CRASH_ON_ERROR(
75
+ getV8Api().jsr_config_set_task_runner(config, new V8TaskRunner(std::move(queue)), &PostTask, &Delete, nullptr));
76
+ }
77
+
78
+ private:
79
+ V8TaskRunner(std::shared_ptr<facebook::react::MessageQueueThread> queue) : queue_(std::move(queue)) {}
80
+
81
+ static void NAPI_CDECL PostTask(
82
+ void *taskRunnerData,
83
+ void *taskData,
84
+ jsr_task_run_cb taskRunCallback,
85
+ jsr_data_delete_cb taskDataDeleteCallback,
86
+ void *deleterData) {
87
+ auto task = std::make_shared<V8Task>(taskData, taskRunCallback, taskDataDeleteCallback, deleterData);
88
+ reinterpret_cast<V8TaskRunner *>(taskRunnerData)->queue_->runOnQueue([task = std::move(task)] { task->Run(); });
89
+ }
90
+
91
+ static void NAPI_CDECL Delete(void *taskRunner, void * /*deleterData*/) {
92
+ delete reinterpret_cast<V8TaskRunner *>(taskRunner);
93
+ }
94
+
95
+ private:
96
+ std::shared_ptr<facebook::react::MessageQueueThread> queue_;
97
+ };
98
+
99
+ struct V8JsiBuffer : facebook::jsi::Buffer {
100
+ static std::shared_ptr<const facebook::jsi::Buffer>
101
+ Create(const uint8_t *buffer, size_t bufferSize, jsr_data_delete_cb bufferDeleteCallback, void *deleterData) {
102
+ return std::shared_ptr<const facebook::jsi::Buffer>(
103
+ new V8JsiBuffer(buffer, bufferSize, bufferDeleteCallback, deleterData));
104
+ }
105
+
106
+ V8JsiBuffer(
107
+ const uint8_t *buffer,
108
+ size_t bufferSize,
109
+ jsr_data_delete_cb bufferDeleteCallback,
110
+ void *deleterData) noexcept
111
+ : buffer_(buffer),
112
+ bufferSize_(bufferSize),
113
+ bufferDeleteCallback_(bufferDeleteCallback),
114
+ deleterData_(deleterData) {}
115
+
116
+ ~V8JsiBuffer() override {
117
+ if (bufferDeleteCallback_) {
118
+ bufferDeleteCallback_(const_cast<uint8_t *>(buffer_), deleterData_);
119
+ }
120
+ }
121
+
122
+ const uint8_t *data() const override {
123
+ return buffer_;
124
+ }
125
+
126
+ size_t size() const override {
127
+ return bufferSize_;
128
+ }
129
+
130
+ private:
131
+ const uint8_t *buffer_;
132
+ size_t bufferSize_;
133
+ jsr_data_delete_cb bufferDeleteCallback_;
134
+ void *deleterData_;
135
+ };
136
+
137
+ class V8ScriptCache {
138
+ public:
139
+ static void Create(jsr_config config, std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore) {
140
+ CRASH_ON_ERROR(getV8Api().jsr_config_set_script_cache(
141
+ config, new V8ScriptCache(std::move(scriptStore)), &LoadScript, &StoreScript, &Delete, nullptr));
142
+ }
143
+
144
+ private:
145
+ V8ScriptCache(std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore)
146
+ : scriptStore_(std::move(scriptStore)) {}
147
+
148
+ static void NAPI_CDECL LoadScript(
149
+ void *scriptCache,
150
+ const char *sourceUrl,
151
+ uint64_t sourceHash,
152
+ const char *runtimeName,
153
+ uint64_t runtimeVersion,
154
+ const char *cacheTag,
155
+ const uint8_t **buffer,
156
+ size_t *bufferSize,
157
+ jsr_data_delete_cb *bufferDeleteCallback,
158
+ void **deleterData) {
159
+ auto &scriptStore = reinterpret_cast<V8ScriptCache *>(scriptCache)->scriptStore_;
160
+ std::shared_ptr<const facebook::jsi::Buffer> preparedScript = scriptStore->tryGetPreparedScript(
161
+ facebook::jsi::ScriptSignature{sourceUrl, sourceHash},
162
+ facebook::jsi::JSRuntimeSignature{runtimeName, runtimeVersion},
163
+ cacheTag);
164
+ if (preparedScript) {
165
+ *buffer = preparedScript->data();
166
+ *bufferSize = preparedScript->size();
167
+ *bufferDeleteCallback = [](void * /*data*/, void *deleterData) noexcept {
168
+ delete reinterpret_cast<std::shared_ptr<const facebook::jsi::Buffer> *>(deleterData);
169
+ };
170
+ *deleterData = new std::shared_ptr<const facebook::jsi::Buffer>(std::move(preparedScript));
171
+ } else {
172
+ *buffer = nullptr;
173
+ *bufferSize = 0;
174
+ *bufferDeleteCallback = nullptr;
175
+ *deleterData = nullptr;
176
+ }
177
+ }
178
+
179
+ static void NAPI_CDECL StoreScript(
180
+ void *scriptCache,
181
+ const char *sourceUrl,
182
+ uint64_t sourceHash,
183
+ const char *runtimeName,
184
+ uint64_t runtimeVersion,
185
+ const char *cacheTag,
186
+ const uint8_t *buffer,
187
+ size_t bufferSize,
188
+ jsr_data_delete_cb bufferDeleteCallback,
189
+ void *deleterData) {
190
+ auto &scriptStore = reinterpret_cast<V8ScriptCache *>(scriptCache)->scriptStore_;
191
+ scriptStore->persistPreparedScript(
192
+ V8JsiBuffer::Create(buffer, bufferSize, bufferDeleteCallback, deleterData),
193
+ facebook::jsi::ScriptSignature{sourceUrl, sourceHash},
194
+ facebook::jsi::JSRuntimeSignature{runtimeName, runtimeVersion},
195
+ cacheTag);
196
+ }
197
+
198
+ static void NAPI_CDECL Delete(void *scriptCache, void * /*deleterData*/) {
199
+ delete reinterpret_cast<V8ScriptCache *>(scriptCache);
200
+ }
201
+
202
+ private:
203
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore_;
204
+ };
205
+
206
+ } // namespace
207
+
208
+ V8RuntimeHolder::V8RuntimeHolder(
209
+ std::shared_ptr<facebook::react::DevSettings> devSettings,
210
+ std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
211
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore,
212
+ bool enableMultiThreadingSupport) noexcept
213
+ : m_weakDevSettings(devSettings),
214
+ m_jsQueue(std::move(jsQueue)),
215
+ m_preparedScriptStore(std::move(preparedScriptStore)),
216
+ m_enableMultiThreadingSupport(enableMultiThreadingSupport) {}
217
+
218
+ void V8RuntimeHolder::initRuntime() noexcept {
219
+ std::shared_ptr<facebook::react::DevSettings> devSettings = m_weakDevSettings.lock();
220
+ VerifyElseCrash(devSettings);
221
+
222
+ V8Api &api = getV8Api();
223
+ V8Api::setCurrent(&api);
224
+ jsr_config config{};
225
+ CRASH_ON_ERROR(api.jsr_create_config(&config));
226
+ CRASH_ON_ERROR(api.jsr_config_enable_inspector(config, devSettings->useDirectDebugger));
227
+ CRASH_ON_ERROR(api.jsr_config_set_inspector_runtime_name(config, devSettings->debuggerRuntimeName.c_str()));
228
+ CRASH_ON_ERROR(api.jsr_config_set_inspector_port(config, devSettings->debuggerPort));
229
+ CRASH_ON_ERROR(api.jsr_config_set_inspector_break_on_start(config, devSettings->debuggerBreakOnNextLine));
230
+ CRASH_ON_ERROR(api.v8_config_enable_multithreading(config, m_enableMultiThreadingSupport));
231
+
232
+ if (m_jsQueue) {
233
+ V8TaskRunner::Create(config, m_jsQueue);
234
+ }
235
+ if (m_preparedScriptStore) {
236
+ V8ScriptCache::Create(config, m_preparedScriptStore);
237
+ }
238
+ jsr_runtime runtime{};
239
+ CRASH_ON_ERROR(api.jsr_create_runtime(config, &runtime));
240
+ CRASH_ON_ERROR(api.jsr_delete_config(config));
241
+
242
+ CRASH_ON_ERROR(api.jsr_create_runtime(config, &runtime));
243
+
244
+ napi_env env{};
245
+ CRASH_ON_ERROR(api.jsr_runtime_get_node_api_env(runtime, &env));
246
+
247
+ m_jsiRuntime =
248
+ makeNodeApiJsiRuntime(env, &api, [runtime]() { CRASH_ON_ERROR(V8Api::current()->jsr_delete_runtime(runtime)); });
249
+ m_ownThreadId = std::this_thread::get_id();
250
+ }
251
+
252
+ facebook::react::JSIEngineOverride V8RuntimeHolder::getRuntimeType() noexcept {
253
+ return facebook::react::JSIEngineOverride::V8NodeApi;
254
+ }
255
+
256
+ std::shared_ptr<facebook::jsi::Runtime> V8RuntimeHolder::getRuntime() noexcept {
257
+ std::call_once(m_onceFlag, [this]() { initRuntime(); });
258
+ VerifyElseCrash(m_jsiRuntime);
259
+ return m_jsiRuntime;
260
+ }
261
+
262
+ } // namespace Microsoft::ReactNative
@@ -0,0 +1,37 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include "RuntimeHolder.h"
7
+ #include "ScriptStore.h"
8
+
9
+ #include <cxxreact/MessageQueueThread.h>
10
+
11
+ namespace Microsoft::ReactNative {
12
+
13
+ class V8RuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
14
+ public: // RuntimeHolderLazyInit implementation.
15
+ std::shared_ptr<facebook::jsi::Runtime> getRuntime() noexcept override;
16
+ facebook::react::JSIEngineOverride getRuntimeType() noexcept override;
17
+
18
+ V8RuntimeHolder(
19
+ std::shared_ptr<facebook::react::DevSettings> devSettings,
20
+ std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
21
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore,
22
+ bool enableMultiThreadingSupport) noexcept;
23
+
24
+ private:
25
+ void initRuntime() noexcept;
26
+
27
+ private:
28
+ std::shared_ptr<facebook::jsi::Runtime> m_jsiRuntime;
29
+ std::once_flag m_onceFlag{};
30
+ std::thread::id m_ownThreadId{};
31
+ std::weak_ptr<facebook::react::DevSettings> m_weakDevSettings;
32
+ std::shared_ptr<facebook::react::MessageQueueThread> m_jsQueue;
33
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> m_preparedScriptStore;
34
+ bool m_enableMultiThreadingSupport;
35
+ };
36
+
37
+ } // namespace Microsoft::ReactNative
@@ -52,13 +52,11 @@
52
52
  #include "HermesRuntimeHolder.h"
53
53
 
54
54
  #if defined(USE_V8)
55
- #include <JSI/NapiJsiV8RuntimeHolder.h>
56
-
57
- #include "BaseScriptStoreImpl.h"
58
- #include "V8JSIRuntimeHolder.h"
55
+ #include <JSI/V8RuntimeHolder.h>
59
56
  #endif
60
57
  #include <ReactCommon/CallInvoker.h>
61
58
  #include <ReactCommon/TurboModuleBinding.h>
59
+ #include "BaseScriptStoreImpl.h"
62
60
  #include "ChakraRuntimeHolder.h"
63
61
 
64
62
  #include <tracing/tracing.h>
@@ -318,46 +316,32 @@ InstanceImpl::InstanceImpl(
318
316
  } else {
319
317
  assert(m_devSettings->jsiEngineOverride != JSIEngineOverride::Default);
320
318
  switch (m_devSettings->jsiEngineOverride) {
321
- case JSIEngineOverride::Hermes:
322
- m_devSettings->jsiRuntimeHolder = std::make_shared<HermesRuntimeHolder>(m_devSettings, m_jsThread);
323
- break;
324
- case JSIEngineOverride::V8: {
325
- #if defined(USE_V8)
326
- std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
327
- std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
319
+ case JSIEngineOverride::Hermes: {
320
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
328
321
 
329
- char tempPath[MAX_PATH];
330
- if (GetTempPathA(MAX_PATH, tempPath)) {
331
- preparedScriptStore = std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(tempPath);
322
+ wchar_t tempPath[MAX_PATH];
323
+ if (GetTempPathW(MAX_PATH, tempPath)) {
324
+ preparedScriptStore =
325
+ std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
332
326
  }
333
327
 
334
- m_devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
335
- m_devSettings, m_jsThread, std::move(scriptStore), std::move(preparedScriptStore));
328
+ m_devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::ReactNative::HermesRuntimeHolder>(
329
+ m_devSettings, m_jsThread, std::move(preparedScriptStore));
336
330
  break;
337
- #else
338
- assert(false); // V8 is not available in this build, fallthrough
339
- [[fallthrough]];
340
- #endif
341
331
  }
332
+ case JSIEngineOverride::V8:
342
333
  case JSIEngineOverride::V8NodeApi: {
343
334
  #if defined(USE_V8)
344
- std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
335
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
345
336
 
346
337
  wchar_t tempPath[MAX_PATH];
347
- if (GetTempPathW(static_cast<DWORD>(std::size(tempPath)), tempPath)) {
338
+ if (GetTempPathW(MAX_PATH, tempPath)) {
348
339
  preparedScriptStore =
349
- std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
350
- }
351
-
352
- if (!preparedScriptStore) {
353
- if (m_devSettings->errorCallback)
354
- m_devSettings->errorCallback("Could not initialize prepared script store");
355
-
356
- break;
340
+ std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
357
341
  }
358
342
 
359
- m_devSettings->jsiRuntimeHolder = make_shared<NapiJsiV8RuntimeHolder>(
360
- m_devSettings, m_jsThread, nullptr /*scriptStore*/, std::move(preparedScriptStore));
343
+ m_devSettings->jsiRuntimeHolder = make_shared<Microsoft::ReactNative::V8RuntimeHolder>(
344
+ m_devSettings, m_jsThread, std::move(preparedScriptStore), false);
361
345
  break;
362
346
  #else
363
347
  if (m_devSettings->errorCallback)
@@ -637,7 +621,7 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
637
621
  nativeQueue));
638
622
 
639
623
  // These modules are instantiated separately in MSRN (Universal Windows).
640
- // When there are module name colisions, the last one registered is used.
624
+ // When there are module name collisions, the last one registered is used.
641
625
  // If this code is enabled, we will have unused module instances.
642
626
  // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable.
643
627
  #if (defined(_MSC_VER) && !defined(WINRT))
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "SafeLoadLibrary.h"
5
+
6
+ namespace Microsoft::ReactNative {
7
+
8
+ // Unsafe calls to LoadLibrary/LoadLibraryEx.
9
+ // The default behavior of LoadLibrary, or LoadLibraryEx without flags, is to try and find the dependency by iterating
10
+ // through a search order. This search order contains the current working directory. In the classic attack, a malicious
11
+ // DLL is dropped in the likely - controllable current working directory. The malicious DLL has the same name as a
12
+ // missing dependency or dependency that is not in the same directory as the executable. When the call to LoadLibrary
13
+ // is reached, the malicious DLL is loaded preferentially, and code execution occurs.
14
+ //
15
+ // The SafeLoadLibrary is the preferred ways to manually load dependencies.
16
+ // The API does not search the current working directory when resolving dependencies.
17
+ // The implementation is "borrowed" from Office MsoSafeLoadLibrary.
18
+
19
+ /**
20
+ List of new flags that control where to search for DLLs. Requires KB2533623.
21
+ */
22
+ const DWORD SafeLoadLibraryFlags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
23
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_SEARCH_USER_DIRS;
24
+
25
+ HMODULE SafeLoadLibrary(const wchar_t *wzFileName, HANDLE hFile, DWORD dwFlags) noexcept {
26
+ // When calling LoadLibrary, OR in LOAD_LIBRARY_SEARCH_DEFAULT_DIRS which enables all of the
27
+ // safe behaviors. Note that this flag is not compatible with LOAD_WITH_ALTERED_SEARCH_PATH.
28
+ HMODULE module =
29
+ LoadLibraryExW(wzFileName, hFile, (dwFlags | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) & ~LOAD_WITH_ALTERED_SEARCH_PATH);
30
+ if (module == nullptr && GetLastError() == ERROR_INVALID_PARAMETER) {
31
+ // Could have failed with actual bad parameters or an unpatched OS without KB2533623.
32
+ if (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "AddDllDirectory") == nullptr) {
33
+ // Unpatched OS, remove all new flags.
34
+ module = LoadLibraryExW(wzFileName, hFile, dwFlags & ~SafeLoadLibraryFlags);
35
+ }
36
+ }
37
+
38
+ return module;
39
+ }
40
+
41
+ } // namespace Microsoft::ReactNative
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #ifndef WIN32_LEAN_AND_MEAN
5
+ #define WIN32_LEAN_AND_MEAN
6
+ #endif
7
+
8
+ #include <windows.h>
9
+
10
+ namespace Microsoft::ReactNative {
11
+
12
+ // Safe LoadLibraryEx wrapper that must be used instead of LoadLibrary.
13
+ extern HMODULE SafeLoadLibrary(const wchar_t *wzFileName, HANDLE hFile = nullptr, DWORD dwFlags = 0) noexcept;
14
+
15
+ } // namespace Microsoft::ReactNative
@@ -27,14 +27,13 @@
27
27
  <ClCompile Include="$(MSBuildThisFileDirectory)Executors\WebSocketJSExecutorFactory.cpp" />
28
28
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp" />
29
29
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp" />
30
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp" />
31
30
  <ClCompile Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.cpp" />
32
31
  <ClCompile Include="$(MSBuildThisFileDirectory)InstanceManager.cpp" />
33
32
  <ClCompile Include="$(MSBuildThisFileDirectory)JSBigAbiString.cpp" />
34
33
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraApi.cpp" />
35
34
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraJsiRuntime_edgemode.cpp" />
36
35
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.cpp" />
37
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.cpp">
36
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp">
38
37
  <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
39
38
  </ClCompile>
40
39
  <ClCompile Include="$(MSBuildThisFileDirectory)LayoutAnimation.cpp" />
@@ -64,6 +63,7 @@
64
63
  <ClCompile Include="$(MSBuildThisFileDirectory)OInstance.cpp" />
65
64
  <ClCompile Include="$(MSBuildThisFileDirectory)PackagerConnection.cpp" />
66
65
  <ClCompile Include="$(MSBuildThisFileDirectory)RuntimeOptions.cpp" />
66
+ <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
67
67
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\BatchingQueueThread.cpp" />
68
68
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageDispatchQueue.cpp" />
69
69
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageQueueThreadFactory.cpp" />
@@ -71,12 +71,10 @@
71
71
  <ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleManager.cpp" />
72
72
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp" />
73
73
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.cpp" />
74
- <ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
75
- <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
76
- </ClCompile>
77
74
  </ItemGroup>
78
75
  <ItemGroup>
79
76
  <ClInclude Include="$(MSBuildThisFileDirectory)..\include\Shared\cdebug.h" />
77
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
80
78
  <ClInclude Include="$(MSBuildThisFileDirectory)AbiSafe.h" />
81
79
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorageModule.h" />
82
80
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\AsyncStorageManager.h" />
@@ -84,13 +82,12 @@
84
82
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\KeyValueStorage.h" />
85
83
  <ClInclude Include="$(MSBuildThisFileDirectory)CppRuntimeOptions.h" />
86
84
  <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h" />
87
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h" />
88
85
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ByteArrayBuffer.h" />
89
86
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraApi.h" />
90
87
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.h" />
91
88
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeArgs.h" />
92
89
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeFactory.h" />
93
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h" />
90
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
94
91
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\RuntimeHolder.h" />
95
92
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ScriptStore.h" />
96
93
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h" />
@@ -145,6 +142,7 @@
145
142
  <ClInclude Include="$(MSBuildThisFileDirectory)NativeModuleProvider.h" />
146
143
  <ClInclude Include="$(MSBuildThisFileDirectory)OInstance.h" />
147
144
  <ClInclude Include="$(MSBuildThisFileDirectory)Pch\pch.h" />
145
+ <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
148
146
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNode.h" />
149
147
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNodeRegistry.h" />
150
148
  <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
@@ -159,7 +157,6 @@
159
157
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
160
158
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
161
159
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
162
- <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
163
160
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
164
161
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />
165
162
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
@@ -306,4 +303,18 @@
306
303
  <SubType>Code</SubType>
307
304
  </ClCompile>
308
305
  </ItemGroup>
306
+ <ItemGroup>
307
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
308
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
309
+ <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp">
310
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
311
+ </ClCompile>
312
+ </ItemGroup>
313
+ <ItemGroup Condition="'$(UseV8)' == 'true'">
314
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.h" />
315
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.inc" />
316
+ <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.cpp">
317
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
318
+ </ClCompile>
319
+ </ItemGroup>
309
320
  </Project>
@@ -43,9 +43,6 @@
43
43
  <ClCompile Include="$(MSBuildThisFileDirectory)CxxMessageQueue.cpp">
44
44
  <Filter>Source Files</Filter>
45
45
  </ClCompile>
46
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp">
47
- <Filter>Source Files</Filter>
48
- </ClCompile>
49
46
  <ClCompile Include="$(MSBuildThisFileDirectory)JSBigAbiString.cpp">
50
47
  <Filter>Source Files</Filter>
51
48
  </ClCompile>
@@ -58,9 +55,6 @@
58
55
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp">
59
56
  <Filter>Source Files</Filter>
60
57
  </ClCompile>
61
- <ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
62
- <Filter>Source Files</Filter>
63
- </ClCompile>
64
58
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\AsyncStorageModuleWin32.cpp">
65
59
  <Filter>Source Files\Modules</Filter>
66
60
  </ClCompile>
@@ -118,15 +112,6 @@
118
112
  <ClCompile Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.cpp">
119
113
  <Filter>Source Files</Filter>
120
114
  </ClCompile>
121
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.cpp">
122
- <Filter>Source Files\JSI</Filter>
123
- </ClCompile>
124
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp">
125
- <Filter>Source Files</Filter>
126
- </ClCompile>
127
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp">
128
- <Filter>Source Files</Filter>
129
- </ClCompile>
130
115
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\HttpModule.cpp">
131
116
  <Filter>Source Files\Modules</Filter>
132
117
  </ClCompile>
@@ -156,6 +141,15 @@
156
141
  <Filter>Source Files\Modules</Filter>
157
142
  </ClCompile>
158
143
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
144
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp">
145
+ <Filter>Hermes</Filter>
146
+ </ClCompile>
147
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp">
148
+ <Filter>Hermes</Filter>
149
+ </ClCompile>
150
+ <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp" />
151
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp" />
152
+ <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
159
153
  </ItemGroup>
160
154
  <ItemGroup>
161
155
  <Filter Include="Source Files">
@@ -215,6 +209,9 @@
215
209
  <Filter Include="Source Files\Networking">
216
210
  <UniqueIdentifier>{71196e04-aca0-48d6-99e4-f418c957b50f}</UniqueIdentifier>
217
211
  </Filter>
212
+ <Filter Include="Hermes">
213
+ <UniqueIdentifier>{b32590e6-ae3d-4388-ab98-767345ce38c9}</UniqueIdentifier>
214
+ </Filter>
218
215
  </ItemGroup>
219
216
  <ItemGroup>
220
217
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\StorageFileIO.h">
@@ -280,9 +277,6 @@
280
277
  <ClInclude Include="$(MSBuildThisFileDirectory)DevSettings.h">
281
278
  <Filter>Header Files</Filter>
282
279
  </ClInclude>
283
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
284
- <Filter>Header Files</Filter>
285
- </ClInclude>
286
280
  <ClInclude Include="$(MSBuildThisFileDirectory)IDevSupportManager.h">
287
281
  <Filter>Header Files</Filter>
288
282
  </ClInclude>
@@ -334,9 +328,6 @@
334
328
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h">
335
329
  <Filter>Header Files</Filter>
336
330
  </ClInclude>
337
- <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h">
338
- <Filter>Header Files</Filter>
339
- </ClInclude>
340
331
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h">
341
332
  <Filter>Header Files</Filter>
342
333
  </ClInclude>
@@ -392,15 +383,6 @@
392
383
  <ClInclude Include="$(MSBuildThisFileDirectory)tracing\tracing.h">
393
384
  <Filter>Header Files\tracing</Filter>
394
385
  </ClInclude>
395
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h">
396
- <Filter>Header Files\JSI</Filter>
397
- </ClInclude>
398
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
399
- <Filter>Header Files</Filter>
400
- </ClInclude>
401
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h">
402
- <Filter>Header Files</Filter>
403
- </ClInclude>
404
386
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h">
405
387
  <Filter>Header Files\Modules</Filter>
406
388
  </ClInclude>
@@ -470,6 +452,17 @@
470
452
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleContentHandler.h">
471
453
  <Filter>Header Files\Modules</Filter>
472
454
  </ClInclude>
455
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
456
+ <Filter>Hermes</Filter>
457
+ </ClInclude>
458
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
459
+ <Filter>Hermes</Filter>
460
+ </ClInclude>
461
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
462
+ <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
463
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
464
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
465
+ <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
473
466
  </ItemGroup>
474
467
  <ItemGroup>
475
468
  <None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.71.16",
3
+ "version": "0.71.18",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "@react-native-community/cli": "10.2.2",
27
27
  "@react-native-community/cli-platform-android": "10.2.0",
28
28
  "@react-native-community/cli-platform-ios": "10.2.1",
29
- "@react-native-windows/cli": "0.71.6",
29
+ "@react-native-windows/cli": "0.71.8",
30
30
  "@react-native/assets": "1.0.0",
31
31
  "@react-native/normalize-color": "2.1.0",
32
32
  "@react-native/polyfills": "2.0.0",
@@ -58,7 +58,7 @@
58
58
  "ws": "^6.2.2"
59
59
  },
60
60
  "devDependencies": {
61
- "@react-native-windows/codegen": "0.71.3",
61
+ "@react-native-windows/codegen": "0.71.4",
62
62
  "@rnw-scripts/babel-react-native-config": "0.0.0",
63
63
  "@rnw-scripts/eslint-config": "1.1.14",
64
64
  "@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.1.0",