Example #1
0
void
Log(const wchar_t *fmt, ...)
{
#if !defined(SHOW_CONSOLE)
  DWORD dwRes = 0;
  if (!GetDWORDRegKey(cehDumpDebugStrings, dwRes) || !dwRes) {
    return;
  }
#endif
  va_list a = nullptr;
  wchar_t szDebugString[1024];
  if(!lstrlenW(fmt))
    return;
  va_start(a,fmt);
  vswprintf(szDebugString, 1024, fmt, a);
  va_end(a);
  if(!lstrlenW(szDebugString))
    return;

  DWORD len;
  WriteConsoleW(sCon, szDebugString, lstrlenW(szDebugString), &len, nullptr);
  WriteConsoleW(sCon, L"\n", 1, &len, nullptr);

  OutputDebugStringW(szDebugString);
  OutputDebugStringW(L"\n");
}
char* sanatizeRfidReading(char* read){
	
	char* out = new char[strlen(read)];
	memset(out, '\0', strlen(read));

	bool hasTransmissionStarted = false;

	HKEY hKey;
	if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, s2ws("SOFTWARE\\Tyler Menezes\\Rfid Login").c_str(), 0, KEY_READ, &hKey) != ERROR_SUCCESS){
		delete hKey;
		return new char;
	}

	char start = 0x00;
	DWORD dStart;
	LONG sError = GetDWORDRegKey(hKey, L"Message Start", dStart, 0x00);
	start = (char)dStart;

	char end = 0x00;
	DWORD dEnd;
	GetDWORDRegKey(hKey, L"Message End", dEnd, 0x00);
	end = (char)dEnd;

	if(sError == 2){
		hasTransmissionStarted = true;
	}

	int c = 0;
	for(int i = 0; i < strlen(read); i++){
		if(read[i] == start){
			hasTransmissionStarted = true;
			continue;
		}

		if(!hasTransmissionStarted){
			continue;
		}

		if(read[i] == end){
			break;
		}

		out[c++] = read[i];
	}

	return out;
}
LONG ServiceRegistry::GetDWORDRegKey(String hKey, String strValueName, DWORD &nValue, DWORD nDefaultValue)
{
	HKEY key;
	LONG l = GetKey(hKey, key);
	if (l == ERROR_SUCCESS)
		return GetDWORDRegKey(key, strValueName,  nValue, nDefaultValue);
	return l;
}
Example #4
0
/*
 * Retrieve the last front end ui we launched so we can target it
 * again. This value is updated down in nsAppRunner when the browser
 * starts up.
 */
AHE_TYPE
GetLastAHE()
{
  DWORD ahe;
  if (GetDWORDRegKey(metroLastAHE, ahe)) {
    return (AHE_TYPE) ahe;
  }
  return AHE_DESKTOP;
}
Example #5
0
File: main.cpp Project: dy-dev/Muse
LONG GetBoolRegKey(HKEY hKey, const std::wstring &strValueName, bool &bValue, bool bDefaultValue)
{
	DWORD nDefValue((bDefaultValue) ? 1 : 0);
	DWORD nResult(nDefValue);
	LONG nError = GetDWORDRegKey(hKey, strValueName.c_str(), nResult, nDefValue);
	if (ERROR_SUCCESS == nError)
	{
		bValue = (nResult != 0) ? true : false;
	}
	return nError;
}
Example #6
0
bool
IsDX10Available()
{
  DWORD isDX10Available;
  if (GetDWORDRegKey(metroDX10Available, isDX10Available)) {
    return isDX10Available;
  }
  bool check = D3DFeatureLevelCheck();
  SetDWORDRegKey(metroDX10Available, check);
  return check;
}
LONG ServiceRegistry::GetBoolRegKey(HKEY hKey, String strValueName, bool &bValue, bool bDefaultValue)
{
	DWORD nDefValue((bDefaultValue) ? 1 : 0);
	DWORD nResult(nDefValue);
	LONG nError = GetDWORDRegKey(hKey, strValueName.lpcwstr(), nResult, nDefValue);
	if (ERROR_SUCCESS == nError)
	{
		bValue = (nResult != 0) ? true : false;
	}
	return nError;
}
Example #8
0
bool
IsDX10Available()
{
  DWORD isDX10Available;
  if (GetDWORDRegKey(metroDX10Available, isDX10Available)) {
    return isDX10Available;
  }

  HMODULE dxgiModule = LoadLibraryA("dxgi.dll");
  if (!dxgiModule) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }
  CreateDXGIFactory1Func createDXGIFactory1 =
    (CreateDXGIFactory1Func) GetProcAddress(dxgiModule, "CreateDXGIFactory1");
  if (!createDXGIFactory1) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }

  HMODULE d3d10module = LoadLibraryA("d3d10_1.dll");
  if (!d3d10module) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }
  D3D10CreateDevice1Func createD3DDevice =
    (D3D10CreateDevice1Func) GetProcAddress(d3d10module,
                                            "D3D10CreateDevice1");
  if (!createD3DDevice) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }

  CComPtr<IDXGIFactory1> factory1;
  if (FAILED(createDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory1))) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }

  CComPtr<IDXGIAdapter1> adapter1;
  if (FAILED(factory1->EnumAdapters1(0, &adapter1))) {
    SetDWORDRegKey(metroDX10Available, 0);
    return false;
  }

  CComPtr<ID3D10Device1> device;
  // Try for DX10.1
  if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
                             D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                             D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                             D3D10_FEATURE_LEVEL_10_1,
                             D3D10_1_SDK_VERSION, &device))) {
    // Try for DX10
    if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
                               D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                               D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                               D3D10_FEATURE_LEVEL_10_0,
                               D3D10_1_SDK_VERSION, &device))) {
      // Try for DX9.3 (we fall back to cairo and cairo has support for D3D 9.3)
      if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
                                 D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                                 D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                                 D3D10_FEATURE_LEVEL_9_3,
                                 D3D10_1_SDK_VERSION, &device))) {

        SetDWORDRegKey(metroDX10Available, 0);
        return false;
      }
    }
  }
  

  SetDWORDRegKey(metroDX10Available, 1);
  return true;
}