@@ -302,35 +302,55 @@ HRESULT
302302JITManager::ConnectProcess (RPC_BINDING_HANDLE rpcBindingHandle)
303303{
304304 Assert (IsOOPJITEnabled ());
305+ HRESULT hr = E_FAIL;
305306
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 ())
309308 {
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+ }
313315
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+ }
324334 }
325- RpcExcept ( RpcExceptionFilter ( RpcExceptionCode ()))
335+ else
326336 {
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;
333352#endif
353+ }
334354
335355 return hr;
336356}
0 commit comments