Skip to content

Commit 2016fda

Browse files
committed
support oop jit descriptor on win8+
1 parent cafc256 commit 2016fda

File tree

7 files changed

+121
-36
lines changed

7 files changed

+121
-36
lines changed

bin/GCStress/GCStress.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
$(ChakraRuntimePlatformAgnostic);
3333
$(ChakraCommonLinkDependencies);
3434
Ole32.lib;
35+
Rpcrt4.lib;
3536
Advapi32.lib;
3637
%(AdditionalDependencies)
3738
</AdditionalDependencies>

bin/ch/JITProcessManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ HRESULT JITProcessManager::CreateServerProcess(int argc, __in_ecount(argc) LPWST
6868

6969
#pragma warning(suppress: 6386) // buffer overrun
7070
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS
71-
hr = StringCchCopyW(cmdLine, cmdLineSize, _u("ch.exe -OOPCFGRegistration- -CheckOpHelpers -jitserver:"));
71+
hr = StringCchCopyW(cmdLine, cmdLineSize, _u("ch.exe -CheckOpHelpers -jitserver:"));
7272
#else
7373
hr = StringCchCopyW(cmdLine, cmdLineSize, _u("ch.exe -jitserver:"));
7474
#endif

bin/ch/ch.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,6 @@ HRESULT ExecuteTest(const char* fileName)
913913
#ifdef DEBUG
914914
ChakraRTInterface::SetCheckOpHelpersFlag(true);
915915
#endif
916-
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS
917-
ChakraRTInterface::SetOOPCFGRegistrationFlag(false);
918-
#endif
919916

920917
if (!WScriptJsrt::Initialize())
921918
{

lib/Common/Core/DelayLoadLibrary.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,41 @@ NtdllLibrary::NTSTATUS NtdllLibrary::UnlockVirtualMemory(
392392
#endif
393393
}
394394

395+
static RPCLibrary RPCLibraryObject;
396+
RPCLibrary* RPCLibrary::Instance = &RPCLibraryObject;
397+
398+
LPCTSTR RPCLibrary::GetLibraryName() const
399+
{
400+
return _u("rpcrt4.dll");
401+
}
402+
403+
RPC_STATUS RPCLibrary::RpcServerRegisterIf3(
404+
_In_ RPC_IF_HANDLE IfSpec,
405+
_In_opt_ UUID* MgrTypeUuid,
406+
_In_opt_ RPC_MGR_EPV* MgrEpv,
407+
_In_ unsigned int Flags,
408+
_In_ unsigned int MaxCalls,
409+
_In_ unsigned int MaxRpcSize,
410+
_In_opt_ RPC_IF_CALLBACK_FN* IfCallback,
411+
_In_opt_ void* SecurityDescriptor)
412+
{
413+
#if !(NTDDI_VERSION >= NTDDI_WIN8)
414+
if (m_hModule)
415+
{
416+
if (serverRegister == nullptr)
417+
{
418+
serverRegister = (PFnRpcServerRegisterIf3)GetFunction("RpcServerRegisterIf3");
419+
if (serverRegister == nullptr)
420+
{
421+
Assert(false);
422+
return -1;
423+
}
424+
}
425+
return serverRegister(IfSpec, MgrTypeUuid, MgrEpv, Flags, MaxCalls, MaxRpcSize, IfCallback, SecurityDescriptor);
426+
}
427+
return -1;
428+
#else
429+
return ::RpcServerRegisterIf3(IfSpec, MgrTypeUuid, MgrEpv, Flags, MaxCalls, MaxRpcSize, IfCallback, SecurityDescriptor);
430+
#endif
431+
}
395432
#endif // _WIN32

lib/Common/Core/DelayLoadLibrary.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,45 @@ class NtdllLibrary : protected DelayLoadLibrary
222222
_In_ ULONG MapType
223223
);
224224
};
225+
226+
// This needs to be delay loaded because RpcServerRegisterIf3 is available only
227+
// on Win8+
228+
class RPCLibrary : protected DelayLoadLibrary
229+
{
230+
private:
231+
typedef RPC_STATUS(NTAPI* PFnRpcServerRegisterIf3)(
232+
_In_ RPC_IF_HANDLE IfSpec,
233+
_In_opt_ UUID* MgrTypeUuid,
234+
_In_opt_ RPC_MGR_EPV* MgrEpv,
235+
_In_ unsigned int Flags,
236+
_In_ unsigned int MaxCalls,
237+
_In_ unsigned int MaxRpcSize,
238+
_In_opt_ RPC_IF_CALLBACK_FN* IfCallback,
239+
_In_opt_ void* SecurityDescriptor);
240+
241+
PFnRpcServerRegisterIf3 serverRegister;
242+
243+
public:
244+
static RPCLibrary* Instance;
245+
246+
RPCLibrary() : DelayLoadLibrary(),
247+
serverRegister(nullptr)
248+
{
249+
this->EnsureFromSystemDirOnly();
250+
}
251+
252+
LPCTSTR GetLibraryName() const;
253+
254+
RPC_STATUS RpcServerRegisterIf3(
255+
_In_ RPC_IF_HANDLE IfSpec,
256+
_In_opt_ UUID* MgrTypeUuid,
257+
_In_opt_ RPC_MGR_EPV* MgrEpv,
258+
_In_ unsigned int Flags,
259+
_In_ unsigned int MaxCalls,
260+
_In_ unsigned int MaxRpcSize,
261+
_In_opt_ RPC_IF_CALLBACK_FN* IfCallback,
262+
_In_opt_ void* SecurityDescriptor
263+
);
264+
};
265+
225266
#endif

lib/JITClient/JITManager.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ JITManager::GetJITManager()
5050
return &s_jitManager;
5151
}
5252

53+
typedef struct _CHAKRA_RPC_SECURITY_QOS_V5 {
54+
unsigned long Version;
55+
unsigned long Capabilities;
56+
unsigned long IdentityTracking;
57+
unsigned long ImpersonationType;
58+
unsigned long AdditionalSecurityInfoType;
59+
union
60+
{
61+
RPC_HTTP_TRANSPORT_CREDENTIALS_W* HttpCredentials;
62+
} u;
63+
void* Sid;
64+
unsigned int EffectiveOnly;
65+
void* ServerSecurityDescriptor;
66+
} CHAKRA_RPC_SECURITY_QOS_V5;
67+
5368
// This routine creates a binding with the server.
5469
HRESULT
5570
JITManager::CreateBinding(
@@ -67,22 +82,13 @@ JITManager::CreateBinding(
6782
RPC_BINDING_HANDLE_TEMPLATE_V1 bindingTemplate;
6883
RPC_BINDING_HANDLE_SECURITY_V1_W bindingSecurity;
6984

70-
#if (NTDDI_VERSION >= NTDDI_WIN8)
71-
RPC_SECURITY_QOS_V5 securityQOS;
72-
ZeroMemory(&securityQOS, sizeof(RPC_SECURITY_QOS_V5));
85+
CHAKRA_RPC_SECURITY_QOS_V5 securityQOS;
86+
ZeroMemory(&securityQOS, sizeof(CHAKRA_RPC_SECURITY_QOS_V5));
7387
securityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
7488
securityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
7589
securityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IDENTIFY;
76-
securityQOS.Version = 5;
90+
securityQOS.Version = AutoSystemInfo::Data.IsWin8OrLater() ? 5 : 4;
7791
securityQOS.ServerSecurityDescriptor = serverSecurityDescriptor;
78-
#else
79-
RPC_SECURITY_QOS_V4 securityQOS;
80-
ZeroMemory(&securityQOS, sizeof(RPC_SECURITY_QOS_V4));
81-
securityQOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
82-
securityQOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
83-
securityQOS.ImpersonationType = RPC_C_IMP_LEVEL_IDENTIFY;
84-
securityQOS.Version = 4;
85-
#endif
8692

8793
ZeroMemory(&bindingTemplate, sizeof(bindingTemplate));
8894
bindingTemplate.Version = 1;

lib/JITServer/JITServer.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ HRESULT JsInitializeJITServer(
2727
return status;
2828
}
2929

30-
#if (NTDDI_VERSION >= NTDDI_WIN8)
31-
status = RpcServerRegisterIf3(
32-
ServerIChakraJIT_v0_0_s_ifspec,
33-
NULL,
34-
NULL,
35-
RPC_IF_AUTOLISTEN,
36-
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
37-
(ULONG)-1,
38-
NULL,
39-
securityDescriptor);
40-
#else
41-
status = RpcServerRegisterIf2(
42-
ServerIChakraJIT_v0_0_s_ifspec,
43-
NULL,
44-
NULL,
45-
RPC_IF_AUTOLISTEN,
46-
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
47-
(ULONG)-1,
48-
NULL);
49-
#endif
30+
if (AutoSystemInfo::Data.IsWin8OrLater())
31+
{
32+
status = RPCLibrary::Instance->RpcServerRegisterIf3(
33+
ServerIChakraJIT_v0_0_s_ifspec,
34+
NULL,
35+
NULL,
36+
RPC_IF_AUTOLISTEN,
37+
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
38+
(ULONG)-1,
39+
NULL,
40+
securityDescriptor);
41+
}
42+
else
43+
{
44+
status = RpcServerRegisterIf2(
45+
ServerIChakraJIT_v0_0_s_ifspec,
46+
NULL,
47+
NULL,
48+
RPC_IF_AUTOLISTEN,
49+
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
50+
(ULONG)-1,
51+
NULL);
52+
}
5053
if (status != RPC_S_OK)
5154
{
5255
return status;

0 commit comments

Comments
 (0)