bool CEsmScriptOptions::WriteRegCharFormat (void) {
  CWinApp*	pApp = AfxGetApp();
  CString	RegName;
  BOOL		Result = TRUE;
  int		Index;

	/* Output all the script formats */
  for (Index = 0; Index < ESMSCRIPT_NUMFORMATS; Index++) {
    RegName.Format(_T("%s%d"), ESMSCR_REGENTRY_CHARFORMAT, Index);
    Result &= pApp->WriteProfileBinary(ESMSCR_REGSEC_SCRIPT, RegName, (BYTE *) &m_Formats[Index], sizeof(m_Formats[Index]));
   }

  return (Result != 0);
 }
Пример #2
0
void CUIforETWDlg::TransferSettings(bool saving)
{
	CWinApp* pApp = AfxGetApp();

	NameToBoolSetting bools[] =
	{
		{ L"CompressTraces", &bCompress_ },
		{ L"CswitchStacks", &bCswitchStacks_ },
		{ L"SampledStacks", &bSampledStacks_ },
		{ L"FastSampling", &bFastSampling_ },
		{ L"GPUTracing", &bGPUTracing_ },
		{ L"CLRTracing", &bCLRTracing_ },
		{ L"ShowCommands", &bShowCommands_ },
		{ L"UseOtherKernelLogger", &bUseOtherKernelLogger_ },
		{ L"BackgroundMonitoring", &bBackgroundMonitoring_ },
		{ L"ChromeDeveloper", &bChromeDeveloper_ },
		{ L"IdentifyChromeProcessesCPU", &bIdentifyChromeProcessesCPU_ },
		{ L"AutoViewTraces", &bAutoViewTraces_ },
		{ L"RecordPreTrace", &bRecordPreTrace_ },
		{ L"HeapStacks", &bHeapStacks_ },
		{ L"VirtualAllocStacks", &bVirtualAllocStacks_ },
		{ L"VersionChecks", &bVersionChecks_ },
	};

	for (auto& m : bools)
	{
		if (saving)
			pApp->WriteProfileInt(pSettings, m.pName, *m.pSetting);
		else
			*m.pSetting = pApp->GetProfileIntW(pSettings, m.pName, *m.pSetting) != false;
	}

	NameToRangedInt ints[] =
	{
		// Note that a setting of kKeyLoggerFull cannot be restored from
		// settings, to avoid privacy problems.
		{ L"InputTracing", (int*)&InputTracing_, kKeyLoggerOff, kKeyLoggerAnonymized },
		{ L"TracingMode", (int*)&tracingMode_, kTracingToMemory, kHeapTracingToFile },
        { L"GpuMode", (int*)&gpuMode_, kGPUDefault, kGPUVerbose },
	};

	for (auto& m : ints)
	{
		if (saving)
			pApp->WriteProfileInt(pSettings, m.pName, *m.pSetting);
		else
		{
			int temp = pApp->GetProfileIntW(pSettings, m.pName, *m.pSetting);
			if (temp < m.min)
				temp = m.min;
			if (temp > m.max)
				temp = m.max;
			*m.pSetting = temp;
		}
	}

	NameToUInt64 bigInts[] =
	{
		{ L"ChromeKeywords", &chromeKeywords_ },
	};

	for (auto& m : bigInts)
	{
		if (saving)
		{
			pApp->WriteProfileBinary(pSettings, m.pName, (LPBYTE)m.pSetting, sizeof(*m.pSetting));
		}
		else
		{
			LPBYTE temp = 0;
			UINT byteCount = sizeof(temp);
			pApp->GetProfileBinary(pSettings, m.pName, &temp, &byteCount);
			if (byteCount == sizeof(temp))
				*m.pSetting = *(uint64_t*)temp;
			delete [] temp;
		}
	}

	NameToString strings[] =
	{
		{ L"HeapProfiledProcess", &heapTracingExes_ },
		{ L"WSMonitoredProcesses", &WSMonitoredProcesses_ },
		{ L"ExtraKernelFlags", &extraKernelFlags_ },
		{ L"ExtraStackWalks", &extraKernelStacks_ },
		{ L"ExtraUserProviders", &extraUserProviders_ },
		{ L"PerfCounters", &perfCounters_ },
	};

	for (auto& m : strings)
	{
		if (saving)
			pApp->WriteProfileStringW(pSettings, m.pName, m.pSetting->c_str());
		else
		{
			CString result = pApp->GetProfileStringW(pSettings, m.pName, m.pSetting->c_str());
			*m.pSetting = result;
		}
	}
}