@@ -302,35 +302,55 @@ HRESULT
302
302
JITManager::ConnectProcess (RPC_BINDING_HANDLE rpcBindingHandle)
303
303
{
304
304
Assert (IsOOPJITEnabled ());
305
+ HRESULT hr = E_FAIL;
305
306
306
- #ifdef USE_RPC_HANDLE_MARSHALLING
307
- HANDLE processHandle;
308
- if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), GetCurrentProcess (), &processHandle, 0 , false , DUPLICATE_SAME_ACCESS))
307
+ if (AutoSystemInfo::Data.IsWin8Point1OrLater ())
309
308
{
310
- return HRESULT_FROM_WIN32 (GetLastError ());
311
- }
312
- #endif
309
+ HANDLE processHandle = nullptr ;
310
+ // RPC handle marshalling is only available on 8.1+
311
+ if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), GetCurrentProcess (), &processHandle, 0 , false , DUPLICATE_SAME_ACCESS))
312
+ {
313
+ return HRESULT_FROM_WIN32 (GetLastError ());
314
+ }
313
315
314
- HRESULT hr = E_FAIL;
315
- RpcTryExcept
316
- {
317
- hr = ClientConnectProcess (
318
- rpcBindingHandle,
319
- #ifdef USE_RPC_HANDLE_MARSHALLING
320
- processHandle,
321
- #endif
322
- (intptr_t )AutoSystemInfo::Data.GetChakraBaseAddr (),
323
- (intptr_t )AutoSystemInfo::Data.GetCRTHandle ());
316
+ RpcTryExcept
317
+ {
318
+ hr = ClientConnectProcessWithProcessHandle (
319
+ rpcBindingHandle,
320
+ processHandle,
321
+ (intptr_t )AutoSystemInfo::Data.GetChakraBaseAddr (),
322
+ (intptr_t )AutoSystemInfo::Data.GetCRTHandle ());
323
+ }
324
+ RpcExcept (RpcExceptionFilter (RpcExceptionCode ()))
325
+ {
326
+ hr = HRESULT_FROM_WIN32 (RpcExceptionCode ());
327
+ }
328
+ RpcEndExcept;
329
+
330
+ if (processHandle)
331
+ {
332
+ CloseHandle (processHandle);
333
+ }
324
334
}
325
- RpcExcept ( RpcExceptionFilter ( RpcExceptionCode ()))
335
+ else
326
336
{
327
- hr = HRESULT_FROM_WIN32 (RpcExceptionCode ());
328
- }
329
- RpcEndExcept;
330
-
331
- #ifdef USE_RPC_HANDLE_MARSHALLING
332
- CloseHandle (processHandle);
337
+ #if (WINVER >= _WIN32_WINNT_WINBLUE)
338
+ AssertOrFailFast (UNREACHED);
339
+ #else
340
+ RpcTryExcept
341
+ {
342
+ hr = ClientConnectProcess (
343
+ rpcBindingHandle,
344
+ (intptr_t )AutoSystemInfo::Data.GetChakraBaseAddr (),
345
+ (intptr_t )AutoSystemInfo::Data.GetCRTHandle ());
346
+ }
347
+ RpcExcept (RpcExceptionFilter (RpcExceptionCode ()))
348
+ {
349
+ hr = HRESULT_FROM_WIN32 (RpcExceptionCode ());
350
+ }
351
+ RpcEndExcept;
333
352
#endif
353
+ }
334
354
335
355
return hr;
336
356
}
0 commit comments