Extract layout bootstrap and thin NodeCanvas startup shells
This commit is contained in:
195
src/main.cpp
195
src/main.cpp
@@ -16,7 +16,6 @@
|
||||
#include "platform_windows/windows_vr_shell.h"
|
||||
#include "../resource.h"
|
||||
|
||||
#include <WbemCli.h>
|
||||
#include "wacom.h"
|
||||
#include "abr.h"
|
||||
|
||||
@@ -75,198 +74,6 @@ void win32_update_fps(int frames)
|
||||
}));
|
||||
}
|
||||
|
||||
int read_WMI_info()
|
||||
{
|
||||
// see: http://win32easy.blogspot.co.uk/2011/03/wmi-in-c-query-everyting-from-your-os.html
|
||||
|
||||
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if (FAILED(hRes))
|
||||
{
|
||||
LOG("Unable to launch COM: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((FAILED(hRes = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0))))
|
||||
{
|
||||
LOG("Unable to initialize security: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemLocator* pLocator = NULL;
|
||||
if (FAILED(hRes = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pLocator))))
|
||||
{
|
||||
LOG("Unable to create a WbemLocator: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemServices* pService = NULL;
|
||||
if (FAILED(hRes = pLocator->ConnectServer(BSTR(L"root\\CIMV2"), NULL, NULL, NULL, WBEM_FLAG_CONNECT_USE_MAX_WAIT, NULL, NULL, &pService)))
|
||||
{
|
||||
pLocator->Release();
|
||||
LOG("Unable to connect to \"CIMV2\": %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto log_field = [](const wchar_t* section, IWbemClassObject* clsObj, const wchar_t* field) {
|
||||
VARIANT vRet;
|
||||
CIMTYPE pType;
|
||||
VariantInit(&vRet);
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, &pType, NULL)))
|
||||
{
|
||||
if (pType == CIM_STRING && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
{
|
||||
LOGW(L"%s %s: %s", section, field, vRet.bstrVal);
|
||||
}
|
||||
else if (pType == CIM_UINT32 && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
{
|
||||
LOGW(L"%s %s: %d", section, field, vRet.uintVal);
|
||||
}
|
||||
|
||||
VariantClear(&vRet);
|
||||
}
|
||||
};
|
||||
|
||||
auto get_int = [](IWbemClassObject* clsObj, const wchar_t* field) {
|
||||
VARIANT vRet;
|
||||
CIMTYPE pType;
|
||||
VariantInit(&vRet);
|
||||
int ret = 0;
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, &pType, NULL)))
|
||||
{
|
||||
if (pType == CIM_UINT32 && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
ret = vRet.uintVal;
|
||||
VariantClear(&vRet);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// GET DEVICE INFO
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(BSTR(L"WQL"), BSTR(L"SELECT * FROM Win32_ComputerSystem"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
log_field(L"Machine", clsObj, L"Name");
|
||||
log_field(L"Machine", clsObj, L"Model");
|
||||
log_field(L"Machine", clsObj, L"Manufacturer");
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
// GET OS INFO
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(BSTR(L"WQL"), BSTR(L"SELECT * FROM Win32_OperatingSystem"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
log_field(L"OS", clsObj, L"Name");
|
||||
log_field(L"OS", clsObj, L"Version");
|
||||
log_field(L"OS", clsObj, L"Locale");
|
||||
log_field(L"OS", clsObj, L"OSProductSuite");
|
||||
log_field(L"OS", clsObj, L"Manufacturer");
|
||||
log_field(L"OS", clsObj, L"Description");
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
|
||||
pService->Release();
|
||||
pService = NULL;
|
||||
if (FAILED(hRes = pLocator->ConnectServer(BSTR(L"root\\Microsoft\\Windows\\DeviceGuard"), NULL, NULL, NULL, WBEM_FLAG_CONNECT_USE_MAX_WAIT, NULL, NULL, &pService)))
|
||||
{
|
||||
pLocator->Release();
|
||||
LOG("Unable to connect to \"DeviceGuard\": %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GET DEVICE GUARD
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(BSTR(L"WQL"), BSTR(L"SELECT * FROM Win32_DeviceGuard"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
if (get_int(clsObj, L"CodeIntegrityPolicyEnforcementStatus") > 0)
|
||||
{
|
||||
LOG("SANDBOX DETECTED");
|
||||
retained_state().sandboxed = true;
|
||||
}
|
||||
|
||||
SAFEARRAY *psaNames = NULL;
|
||||
if (SUCCEEDED(clsObj->GetNames(0, WBEM_FLAG_ALWAYS | WBEM_FLAG_NONSYSTEM_ONLY, 0, &psaNames)))
|
||||
{
|
||||
// Get the number of properties.
|
||||
long lLower, lUpper;
|
||||
BSTR PropName = NULL;
|
||||
SafeArrayGetLBound(psaNames, 1, &lLower);
|
||||
SafeArrayGetUBound(psaNames, 1, &lUpper);
|
||||
|
||||
for (long i = lLower; i <= lUpper; i++)
|
||||
{
|
||||
// Get this property.
|
||||
SafeArrayGetElement(psaNames, &i, &PropName);
|
||||
|
||||
LOGW(L"Prop: %s", PropName);
|
||||
log_field(L"DeviceGuard", clsObj, PropName);
|
||||
|
||||
SysFreeString(PropName);
|
||||
}
|
||||
|
||||
SafeArrayDestroy(psaNames);
|
||||
}
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
|
||||
pLocator->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create a reverse map from kKey to VK_XXX
|
||||
void init_vk_map()
|
||||
{
|
||||
@@ -329,7 +136,7 @@ int main(int argc, char** argv)
|
||||
|
||||
pp::platform::windows::setup_exception_handler();
|
||||
|
||||
read_WMI_info();
|
||||
pp::platform::windows::read_WMI_info();
|
||||
|
||||
App::I->create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user