FEATURE-EXPERIMENTAL : add /f flag to force loading for unsupported runtimes

This commit is contained in:
TogDu 2018-02-12 21:54:18 +01:00
parent e71f79cfb1
commit 23fa0b517d
5 changed files with 39 additions and 17 deletions

View File

@ -52,7 +52,7 @@ typedef BOOL (WINAPI* EnumSimpleDictCallbackFn_T)(HANDLE hProcess, UINT Index, V
BOOL WINAPI EnumSimpleDict(HANDLE hProcess, SIMPLE_DICT_T* pSimpleDict, EnumSimpleDictCallbackFn_T EnumSimpleDictCallbackFn, VOID* pContext);
// RpcCore
VOID* __fastcall RpcCoreInit(); //returns a private context for the RpcCoreEngine
VOID* __fastcall RpcCoreInit(BOOL bForce); //returns a private context for the RpcCoreEngine
VOID __fastcall RpcCoreUninit(VOID* pRpcCoreCtxt);
RpcProcessInfo_T* __fastcall RpcCoreGetProcessInfo(void* pRpcCoreCtxt,DWORD Pid,DWORD Ppid,ULONG ProcessInfoMask);
VOID __fastcall RpcCoreFreeProcessInfo(void* pRpcCoreCtxt,RpcProcessInfo_T* pRpcProcessInfo);
@ -73,6 +73,7 @@ RpcCore_T RpcCoreHelper =
{
RPC_CORE_RUNTIME_VERSION,
RPC_CORE_IS_WOW64,
FALSE,
&RpcCoreInit,
&RpcCoreUninit,
&RpcCoreGetProcessInfo,
@ -270,7 +271,7 @@ End:
//------------------------------------------------------------------------------
VOID* __fastcall RpcCoreInit()
VOID* __fastcall RpcCoreInit(BOOL bForce)
{
UINT64 RuntimVersion;
RpcCoreInternalCtxt_T* pRpcCoreInternalCtxt=NULL;
@ -290,6 +291,11 @@ VOID* __fastcall RpcCoreInit()
RuntimVersion=GetModuleVersion(RpcRuntimePath);
for (i = 0; i < sizeof(RPC_CORE_RUNTIME_VERSION); i++)
{
if (bForce && ((RuntimVersion & 0xFFFFFFFF00000000) == (RPC_CORE_RUNTIME_VERSION[i] & 0xFFFFFFFF00000000)))
{
bFound = TRUE;
break;
}
if (RuntimVersion == RPC_CORE_RUNTIME_VERSION[i])
{
bFound = TRUE;

View File

@ -178,7 +178,7 @@ typedef BOOL (__fastcall* RpcCoreEnumProcessAuthInfoCallbackFn_T)(DWORD Pid, Rpc
// Type definitions
////////////////////////////////////////////////////////////////////////////////
typedef VOID* (__fastcall* RpcCoreInitFn_T)();
typedef VOID* (__fastcall* RpcCoreInitFn_T)(BOOL bForce);
typedef VOID (__fastcall* RpcCoreUninitFn_T)(VOID* pRpcCoreCtxt);
typedef RpcProcessInfo_T* (__fastcall* RpcCoreGetProcessInfoFn_T)(void* pRpcCoreCtxt, DWORD Pid, DWORD Ppid,ULONG ProcessInfoMask);
typedef VOID (__fastcall* RpcCoreFreeProcessInfoFn_T)(void* pRpcCoreCtxt, RpcProcessInfo_T* pRpcProcessInfo);
@ -193,6 +193,7 @@ typedef struct _RpcCore_T{
UINT64* RuntimeVersion; //the supported version (forx example 0x600011DB04001LL (6.1.7600.16385) for Windows 7 64bits )
//const char* pDescription;
BOOL bWow64Helper;
BOOL bForceLoading;
RpcCoreInitFn_T RpcCoreInitFn;
RpcCoreUninitFn_T RpcCoreUninitFn;
RpcCoreGetProcessInfoFn_T RpcCoreGetProcessInfoFn;

View File

@ -34,7 +34,7 @@ InitViewsVisitor_C::InitViewsVisitor_C(RpcCore_T* pRpcCore,void** ppRpcCoreCtxt)
this->pRpcCore= pRpcCore;
this->NbOfInterfaces = 0;
this->pRpcCoreCtxt = pRpcCore->RpcCoreInitFn();
this->pRpcCoreCtxt = pRpcCore->RpcCoreInitFn(pRpcCore->bForceLoading);
if (this->pRpcCoreCtxt==NULL) goto End;
*ppRpcCoreCtxt = this->pRpcCoreCtxt;

View File

@ -13,7 +13,7 @@ typedef struct _RpcCoreManager_T{
}RpcCoreManager_T;
// RpcCore
VOID* __fastcall RpcCoreInit(); //returns a private context for the RpcCoreEngine
VOID* __fastcall RpcCoreInit(BOOL bForce); //returns a private context for the RpcCoreEngine
VOID __fastcall RpcCoreUninit(VOID* pRpcCoreCtxt);
RpcProcessInfo_T* __fastcall RpcCoreGetProcessInfo(void* pRpcCoreCtxt, DWORD Pid, DWORD Ppid, ULONG ProcessInfoMask);
VOID __fastcall RpcCoreFreeProcessInfo(void* pRpcCoreCtxt, RpcProcessInfo_T* pRpcProcessInfo);
@ -29,6 +29,7 @@ RpcCore_T gRpcCoreManager =
0,
//"Generic RpcCore Manager",
FALSE,
FALSE,
&RpcCoreInit,
&RpcCoreUninit,
&RpcCoreGetProcessInfo,
@ -41,7 +42,7 @@ RpcCore_T gRpcCoreManager =
};
//------------------------------------------------------------------------------
BOOL NTAPI LoadCoreEngine(RpcCore_T** ppRpcCoreHelper, void** ppRpcCoreCtxt, BOOL bWow64Helper)
BOOL NTAPI LoadCoreEngine(RpcCore_T** ppRpcCoreHelper, void** ppRpcCoreCtxt, BOOL bWow64Helper, BOOL bForce)
{
WIN32_FIND_DATAA Win32FindData;
HMODULE hLib;
@ -60,7 +61,7 @@ BOOL NTAPI LoadCoreEngine(RpcCore_T** ppRpcCoreHelper, void** ppRpcCoreCtxt, BOO
pRpcCoreHelper = (RpcCore_T*)(ULONG_PTR)GetProcAddress(hLib, RPC_CORE_EXPORT_SYMBOL);
if (pRpcCoreHelper != NULL)
{
*ppRpcCoreCtxt = pRpcCoreHelper->RpcCoreInitFn();
*ppRpcCoreCtxt = pRpcCoreHelper->RpcCoreInitFn(bForce);
if (*ppRpcCoreCtxt != NULL)
{
pRpcCoreHelper->RpcCoreUninitFn(*ppRpcCoreCtxt);
@ -86,13 +87,13 @@ End:
//-----------------------------------------------------------------------------
VOID* __fastcall RpcCoreInit()
VOID* __fastcall RpcCoreInit(BOOL bForce)
{
RpcCoreManager_T* pRpcCoreManager;
pRpcCoreManager = (RpcCoreManager_T*)OS_ALLOC(sizeof(RpcCoreManager_T));
if (!LoadCoreEngine(&pRpcCoreManager->pNativeCore, &pRpcCoreManager->pNativeCoreCtxt, FALSE))
if (!LoadCoreEngine(&pRpcCoreManager->pNativeCore, &pRpcCoreManager->pNativeCoreCtxt, FALSE, bForce))
{
const char Caption[] = "Unsupported runtime version";
#ifdef _WIN64
@ -107,14 +108,14 @@ VOID* __fastcall RpcCoreInit()
#endif
ExitProcess(0);
}
pRpcCoreManager->pNativeCoreCtxt = pRpcCoreManager->pNativeCore->RpcCoreInitFn();
pRpcCoreManager->pNativeCoreCtxt = pRpcCoreManager->pNativeCore->RpcCoreInitFn(bForce);
#ifdef _WIN64
if (!LoadCoreEngine(&pRpcCoreManager->pWow64Core, &pRpcCoreManager->pWow64CoreCtxt, TRUE))
if (!LoadCoreEngine(&pRpcCoreManager->pWow64Core, &pRpcCoreManager->pWow64CoreCtxt, TRUE,bForce))
{
OS_FREE(pRpcCoreManager);
return NULL;
}
pRpcCoreManager->pWow64CoreCtxt = pRpcCoreManager->pWow64Core->RpcCoreInitFn();
pRpcCoreManager->pWow64CoreCtxt = pRpcCoreManager->pWow64Core->RpcCoreInitFn(bForce);
#endif
return (pRpcCoreManager);
}

View File

@ -333,15 +333,16 @@ End:
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
#else
int argc = 1;
char* pCmdLineA = NULL;
char** argv = &pCmdLineA;
int argc = 0;
//char* pCmdLineA = NULL;
char* argv[100] = { 0 };
UNREFERENCED_PARAMETER(pCmdLine);
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(nCmdShow);
pCmdLineA = GetCommandLineA();
pCmdLine = GetCommandLineW();
LPWSTR* argvw = CommandLineToArgvW(pCmdLine, &argc);
#endif
QApplication app(argc, argv);
QSettings Settings(RPC_VIEW_ORGANIZATION_NAME, RPC_VIEW_APPLICATION_NAME);
@ -371,8 +372,21 @@ End:
_CrtDumpMemoryLeaks();
return 0;
}
#else
//argc is corrupted ?
//if (argc>1)
{
if (argvw[1] && !wcsncmp(argvw[1], L"/f", 2))
{
gRpcCoreManager.bForceLoading = TRUE;
}
else
{
_cprintf("Usage %s: [/f]\n", argv[0]);
_cprintf(" /f : force loading for unsupported runtime versions \n");
}
}
#endif
pMainWindow = new MainWindow_C(&gRpcCoreManager);
hMainIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_MAIN_ICON));