bool GSDeviceDX::LoadD3DCompiler() { // Windows 8.1 and later come with the latest d3dcompiler_47.dll, but // Windows 7 devs might also have the dll available for use (which will // have to be placed in the application directory) s_d3d_compiler_dll = LoadLibraryEx(D3DCOMPILER_DLL, nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); // Windows Vista and 7 can use the older version. If the previous LoadLibrary // call fails on Windows 8.1 and later, then the user's system is likely // broken. if (s_d3d_compiler_dll) { s_old_d3d_compiler_dll = false; } else { if (!IsWindows8Point1OrGreater()) // Use LoadLibrary instead of LoadLibraryEx, some Windows 7 systems // have issues with it. s_d3d_compiler_dll = LoadLibrary("D3DCompiler_43.dll"); if (s_d3d_compiler_dll == nullptr) return false; s_old_d3d_compiler_dll = true; } s_pD3DCompile = reinterpret_cast<decltype(&D3DCompile)>(GetProcAddress(s_d3d_compiler_dll, "D3DCompile")); if (s_pD3DCompile) return true; FreeLibrary(s_d3d_compiler_dll); s_d3d_compiler_dll = nullptr; return false; }
//Returns true on success (and sets majorVersion and minorVersion). Returns false on failure. bool GetOSVersion(DWORD* majorVersion, DWORD* minorVersion) { bool success = false; if (IsWindowsVistaOrGreater()) { success = true; *majorVersion = 6; *minorVersion = 0; } if (IsWindows7OrGreater()) { *minorVersion = 1; } if (IsWindows8OrGreater()) { *minorVersion = 2; } if (IsWindows8Point1OrGreater()) { *minorVersion = 3; } return success; }
/// <summary> /// Gets VadPurge handle. /// </summary> /// <returns>Driver object handle, INVALID_HANDLE_VALUE if failed</returns> HANDLE MMap::GetDriverHandle() { HANDLE hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL ); // Load missing driver if (hFile == INVALID_HANDLE_VALUE) { std::wstring drvPath = Utils::GetExeDirectory() + L"\\"; if (IsWindows8Point1OrGreater()) drvPath += L"VadPurge81.sys"; else if (IsWindows8OrGreater()) drvPath += L"VadPurge8.sys"; else if (IsWindows7OrGreater()) drvPath += L"VadPurge7.sys"; NTSTATUS status = Utils::LoadDriver( L"VadPurge", drvPath ); if (status != ERROR_SUCCESS && status != STATUS_IMAGE_ALREADY_LOADED) return false; hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL ); } return hFile; }
int _glfwPlatformInit(void) { // To make SetForegroundWindow work as we want, we need to fiddle // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early // as possible in the hope of still being the foreground process) SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &_glfw.win32.foregroundLockTimeout, 0); SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0), SPIF_SENDCHANGE); if (!loadLibraries()) return GLFW_FALSE; createKeyTables(); _glfwUpdateKeyNamesWin32(); if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); else if (IsWindows8Point1OrGreater()) SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); else if (IsWindowsVistaOrGreater()) SetProcessDPIAware(); if (!_glfwRegisterWindowClassWin32()) return GLFW_FALSE; if (!createHelperWindow()) return GLFW_FALSE; _glfwInitTimerWin32(); _glfwInitJoysticksWin32(); _glfwPollMonitorsWin32(); return GLFW_TRUE; }
static XnStatus GetOSName(xnOSInfo* pOSInfo) { if (IsWindows8Point1OrGreater()) sprintf(pOSInfo->csOSName, "%s", "Windows8Point1OrGreater\n"); else if (IsWindows8OrGreater()) sprintf(pOSInfo->csOSName, "%s", "Windows8\n"); else if (IsWindows7SP1OrGreater()) sprintf(pOSInfo->csOSName, "%s", "Windows7SP1\n"); else if (IsWindows7OrGreater()) sprintf(pOSInfo->csOSName, "%s", "Windows7\n"); else if (IsWindowsVistaSP2OrGreater()) sprintf(pOSInfo->csOSName, "%s", "VistaSP2\n"); else if (IsWindowsVistaSP1OrGreater()) sprintf(pOSInfo->csOSName, "%s", "VistaSP1\n"); else if (IsWindowsVistaOrGreater()) sprintf(pOSInfo->csOSName, "%s", "Vista\n"); else if (IsWindowsXPSP3OrGreater()) sprintf(pOSInfo->csOSName, "%s", "XPSP3\n"); else if (IsWindowsXPSP2OrGreater()) sprintf(pOSInfo->csOSName, "%s", "XPSP2\n"); else if (IsWindowsXPSP1OrGreater()) sprintf(pOSInfo->csOSName, "%s", "XPSP1\n"); else if (IsWindowsXPOrGreater()) sprintf(pOSInfo->csOSName, "%s", "XP\n"); else sprintf(pOSInfo->csOSName, "%s", "Unknown win version\n"); return (XN_STATUS_OK); }
/// <summary> /// Unlink memory VAD node /// </summary> /// <param name="imageMem">Image to purge</param> /// <returns>bool on success</returns> bool MMap::UnlinkVad( const MemBlock& imageMem ) { HANDLE hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL ); // Load missing driver if (hFile == INVALID_HANDLE_VALUE) { std::wstring drvPath = Utils::GetExeDirectory() + L"\\"; if (IsWindows8Point1OrGreater()) drvPath += L"VadPurge81.sys"; else if(IsWindows8OrGreater()) drvPath += L"VadPurge8.sys"; else if(IsWindows7OrGreater()) drvPath += L"VadPurge7.sys"; NTSTATUS status = Utils::LoadDriver( L"VadPurge", drvPath ); if (status != ERROR_SUCCESS && status != STATUS_IMAGE_ALREADY_LOADED) return false; hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL ); } // // Lock pages in working set before unlinking // UserMode page faults can't be resolved without VAD record // if (hFile != INVALID_HANDLE_VALUE) { // // Adjust working set and lock pages // SIZE_T sizeMin = 0, sizeMax = 0; BOOL ret = FALSE; GetProcessWorkingSetSize( _process.core().handle(), &sizeMin, &sizeMax ); SetProcessWorkingSetSize( _process.core().handle(), sizeMin + imageMem.size(), sizeMax + imageMem.size() ); PVOID pBase = imageMem.ptr<PVOID>(); ULONG size = static_cast<ULONG>(imageMem.size()); NTSTATUS status = GET_IMPORT( NtLockVirtualMemory )(_process.core().handle(), &pBase, &size, 1); // Continue only if pages are locked if (status == STATUS_SUCCESS) { PURGE_DATA data = { _process.core().pid(), 1, { imageMem.ptr<ULONGLONG>(), imageMem.size() } }; DWORD junk = 0; ret = DeviceIoControl( hFile, static_cast<DWORD>(IOCTL_VADPURGE_PURGE), &data, sizeof(data), NULL, 0, &junk, NULL ); } CloseHandle( hFile ); return (status == STATUS_SUCCESS && ret == TRUE) ? true : false; } return false; }
/// <summary> /// Reload driver /// </summary> /// <param name="path">Path to the driver file</param> /// <returns>Status code</returns> NTSTATUS DriverControl::Reload( std::wstring path /*= L"" */ ) { NTSTATUS status = STATUS_SUCCESS; Unload(); // Use default path if (path.empty()) { const wchar_t* filename = nullptr; if (IsWindows10OrGreater()) filename = L"BlackBoneDrv10.sys"; else if (IsWindows8Point1OrGreater()) filename = L"BlackBoneDrv81.sys"; else if (IsWindows8OrGreater()) filename = L"BlackBoneDrv8.sys"; else if (IsWindows7OrGreater()) filename = L"BlackBoneDrv7.sys"; else filename = L"BlackBoneDrv.sys"; path = Utils::GetExeDirectory() + L"\\" + filename; } status = _loadStatus = LoadDriver( DRIVER_SVC_NAME, path ); if (!NT_SUCCESS( status )) { BLACBONE_TRACE( L"Failed to load driver %ls. Status 0x%X", path.c_str(), status ); return LastNtStatus( status ); } _hDriver = CreateFileW( BLACKBONE_DEVICE_FILE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); if (_hDriver == INVALID_HANDLE_VALUE) { status = LastNtStatus(); BLACBONE_TRACE( L"Failed to open driver handle. Status 0x%X", status ); return status; } return status; }
PROCESS_DPI_AWARENESS CDPI::GetDPIAwareness() { if (IsWindows8Point1OrGreater()) { HMODULE hModule =::LoadLibrary(_T("Shcore.dll")); if(hModule != NULL) { LPGetProcessDpiAwareness GetProcessDpiAwareness = (LPGetProcessDpiAwareness)GetProcAddress(hModule, "GetProcessDpiAwareness"); if(GetProcessDpiAwareness != NULL) { HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessId()); if(GetProcessDpiAwareness(hProcess, &m_Awareness) == S_OK) { } } } } return m_Awareness; }
/// <summary> /// Reload driver /// </summary> /// <param name="path">Path to the driver file</param> /// <returns>Status code</returns> NTSTATUS DriverControl::Reload( std::wstring path /*= L"" */ ) { Unload(); // Use default path if (path.empty()) { const wchar_t* filename = nullptr; if (IsWindows10OrGreater()) filename = BLACKBONE_FILE_NAME_10; else if (IsWindows8Point1OrGreater()) filename = BLACKBONE_FILE_NAME_81; else if (IsWindows8OrGreater()) filename = BLACKBONE_FILE_NAME_8; else if (IsWindows7OrGreater()) filename = BLACKBONE_FILE_NAME_7; else filename = BLACKBONE_FILE_NAME; path = Utils::GetExeDirectory() + L"\\" + filename; } _loadStatus = LoadDriver( DRIVER_SVC_NAME, path ); if (!NT_SUCCESS( _loadStatus )) { BLACKBONE_TRACE( L"Failed to load driver %ls. Status 0x%X", path.c_str(), _loadStatus ); return _loadStatus; } _hDriver = CreateFileW( BLACKBONE_DEVICE_FILE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); if (!_hDriver) { _loadStatus = LastNtStatus(); BLACKBONE_TRACE( L"Failed to open driver handle. Status 0x%X", _loadStatus ); return _loadStatus; } return _loadStatus; }
void dectectOS() //TODO:Fix this as it doesn't know how to check version { char *osVersion; //if(IsWindows10OrGreater()) osVersion = "Windows 10"; if(IsWindows8Point1OrGreater()) osVersion = "Windows 8.1"; else if(IsWindows8OrGreater()) osVersion = "Windows 8"; else if(IsWindows7SP1OrGreater()) osVersion = "Windows 7 Service Pack 1"; else if(IsWindowsVistaSP2OrGreater()) osVersion = "Windows Vista Service Pack 2"; else if(IsWindowsVistaSP1OrGreater()) osVersion = "Windows Vista Service Pack 1"; else if(IsWindowsVistaOrGreater()) osVersion = "Windows Vista"; else if(IsWindowsXPSP3OrGreater()) osVersion = "Windows XP Service Pack 3"; else if(IsWindowsXPSP2OrGreater()) osVersion = "Windows XP Service Pack 2"; else if(IsWindowsXPSP1OrGreater()) osVersion = "Windows XP Service Pack 1"; else if(IsWindowsXPOrGreater()) osVersion = "Windows XP"; else if(IsWindowsServer()) osVersion = "Windows Server"; printf("\nOS Version : %s", osVersion); }
BOOL CDPI::SetDPIAwareness(PROCESS_DPI_AWARENESS Awareness) { BOOL bRet = FALSE; if (IsWindows8Point1OrGreater()) { HMODULE hModule =::LoadLibrary(_T("Shcore.dll")); if(hModule != NULL) { LPSetProcessDpiAwareness SetProcessDpiAwareness = (LPSetProcessDpiAwareness)GetProcAddress(hModule, "SetProcessDpiAwareness"); if (SetProcessDpiAwareness != NULL && SetProcessDpiAwareness(Awareness) == S_OK) { m_Awareness = Awareness; bRet = TRUE; } } } else { m_Awareness = Awareness; } return bRet; }
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale) { UINT xdpi, ydpi; if (IsWindows8Point1OrGreater()) GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); else { const HDC dc = GetDC(NULL); xdpi = GetDeviceCaps(dc, LOGPIXELSX); ydpi = GetDeviceCaps(dc, LOGPIXELSY); ReleaseDC(NULL, dc); } if (xscale) *xscale = xdpi / (float) USER_DEFAULT_SCREEN_DPI; if (yscale) *yscale = ydpi / (float) USER_DEFAULT_SCREEN_DPI; }
void Host::initOS() { #ifdef NUCLEUS_TARGET_ANDROID os.name = "Android"; #endif #ifdef NUCLEUS_TARGET_IOS os.name = "iOS"; #endif #ifdef NUCLEUS_TARGET_LINUX os.name = "Linux"; #endif #ifdef NUCLEUS_TARGET_OSX os.name = "OSX"; #endif #ifdef NUCLEUS_TARGET_UWP os.name = "Windows"; #endif #ifdef NUCLEUS_TARGET_WINDOWS if (IsWindows10OrGreater()) { os.name = "Windows 10"; } else if (IsWindows8Point1OrGreater()) { os.name = "Windows 8.1"; } else if (IsWindows8OrGreater()) { os.name = "Windows 8"; } else if (IsWindows7OrGreater()) { os.name = "Windows 7"; } else if (IsWindowsVistaSP2OrGreater()) { os.name = "Windows Vista SP2"; } else if (IsWindowsVistaSP1OrGreater()) { os.name = "Windows Vista SP1"; } else if (IsWindowsVistaOrGreater()) { os.name = "Windows Vista"; } else if (IsWindowsXPSP3OrGreater()) { os.name = "Windows XP SP3"; } else if (IsWindowsXPSP2OrGreater()) { os.name = "Windows XP SP2"; } else if (IsWindowsXPSP1OrGreater()) { os.name = "Windows XP SP1"; } else if (IsWindowsXPOrGreater()) { os.name = "Windows XP"; } #endif }
int wmain(void) { //if (IsWindows10OrGreater()) { // wprintf(L"This is Windows 10+"); // } if (IsWindows8Point1OrGreater()) { wprintf(L"This is Windows 8.1+\n"); } else if (IsWindows8OrGreater()) { wprintf(L"This is Windows 8\n"); } else if (IsWindows7OrGreater ()) { wprintf(L"This is Windows 7\n"); } else if (IsWindowsVistaOrGreater ()) { wprintf(L"This is Windows Vista\n"); } else if (IsWindowsXPOrGreater()) { wprintf(L"This is Windows XP\n"); } return 0; }
int CDPI::GetDPIOfMonitor(HMONITOR hMonitor) { UINT dpix = 96, dpiy = 96; if (IsWindows8Point1OrGreater()) { HRESULT hr = E_FAIL; HMODULE hModule =::LoadLibrary(_T("Shcore.dll")); if(hModule != NULL) { LPGetDpiForMonitor GetDpiForMonitor = (LPGetDpiForMonitor)GetProcAddress(hModule, "GetDpiForMonitor"); if (GetDpiForMonitor != NULL && GetDpiForMonitor(hMonitor,MDT_EFFECTIVE_DPI, &dpix, &dpiy) != S_OK) { MessageBox(NULL, _T("GetDpiForMonitor failed"), _T("Notification"), MB_OK); return 96; } } } else { HDC screen = GetDC(0); dpix = GetDeviceCaps(screen, LOGPIXELSX); ReleaseDC(0, screen); } return dpix; }
void MachineInfo::make_info() { //FunctionHooks* FH = new FunctionHooks; DWORD size; size = MAX_COMPUTERNAME_LENGTH + 1; GetComputerNameA(this->PC_Name, &size); // Wpisanie nazwy komputera size = UNLEN + 1; GetUserNameA(this->Username, &size); // Wpisanie nazwy u¿ytkownika /*----------------Wpisanie informacji o maksymalnym taktowaniu CPU--------------------*/ SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); size = sysInfo.dwNumberOfProcessors * sizeof(PROCESSOR_POWER_INFORMATION); LPBYTE buf = new BYTE[size]; CallNtPowerInformation(ProcessorInformation, NULL, 0, buf, size); PPROCESSOR_POWER_INFORMATION cpuinfo = (PPROCESSOR_POWER_INFORMATION)buf; std::string full_cpu_ratio = intToStr(cpuinfo->MaxMhz) + "GHz"; full_cpu_ratio.erase(3, 1); full_cpu_ratio.insert(1, "."); memcpy(this->CPU_clock, full_cpu_ratio.c_str(), sizeof(full_cpu_ratio)); /*------------------------------------------------------------------------------------*/ /*-----------------------Sprawdzenie wersji systemu Windows---------------------------*/ if (IsWindows8Point1OrGreater())memcpy(this->OS, "Windows 8.1", sizeof("Windows 8.1")); else if (IsWindows7OrGreater())memcpy(this->OS, "Windows 7", sizeof("Windows 7")); else if (IsWindowsVistaOrGreater())memcpy(this->OS, "Windows Vista", sizeof("Windows Vista")); else if (IsWindowsXPOrGreater())memcpy(this->OS, "Windows XP", sizeof("Windows XP")); /*------------------------------------------------------------------------------------*/ }
version get_version() { #if (_MSC_VER >= oVS2015_VER) bool is_server = IsWindowsServer(); //if (IsWindows10OrGreater()) return is_server ? windows::version::win10 : windows::version::win10; if (IsWindows8Point1OrGreater()) return is_server ? windows::version::server_2012_sp1 : windows::version::win8_1; if (IsWindows8OrGreater()) return is_server ? windows::version::server_2012 : windows::version::win8; if (IsWindows7SP1OrGreater()) return is_server ? windows::version::server_2008r2_sp1 : windows::version::win7_sp1; if (IsWindows7OrGreater()) return is_server ? windows::version::server_2008r2 : windows::version::win7; if (IsWindowsVistaSP2OrGreater()) return is_server ? windows::version::server_2008_sp2 : windows::version::vista_sp2; if (IsWindowsVistaSP1OrGreater()) return is_server ? windows::version::server_2008_sp1 : windows::version::vista_sp1; if (IsWindowsVistaOrGreater()) return is_server ? windows::version::server_2008 : windows::version::vista; if (IsWindowsXPSP3OrGreater()) return is_server ? windows::version::xp : windows::version::xp; if (IsWindowsXPSP2OrGreater()) return is_server ? windows::version::xp_sp1 : windows::version::xp_sp1; if (IsWindowsXPSP1OrGreater()) return is_server ? windows::version::xp_sp2 : windows::version::xp_sp2; if (IsWindowsXPOrGreater()) return is_server ? windows::version::xp_sp3 : windows::version::xp_sp3; if (IsWindowsVersionOrGreater(5, 2, 0)) return is_server ? windows::version::server_2003 : windows::version::xp_pro_64bit; if (IsWindowsVersionOrGreater(5, 0, 0)) return is_server ? windows::version::win2000 : windows::version::win2000; #else OSVERSIONINFOEX osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (GetVersionEx((OSVERSIONINFO*)&osvi)) { if (osvi.dwMajorVersion == 6) { if (osvi.dwMinorVersion == 2) { if (osvi.wServicePackMajor == 1) return osvi.wProductType == VER_NT_WORKSTATION ? version::win8_1 : version::server_2012_sp1; else if (osvi.wServicePackMajor == 0) return osvi.wProductType == VER_NT_WORKSTATION ? version::win8 : version::server_2012; } else if (osvi.dwMinorVersion == 1) { if (osvi.wServicePackMajor == 0) return osvi.wProductType == VER_NT_WORKSTATION ? version::win7 : version::server_2008r2; else if (osvi.wServicePackMajor == 1) return osvi.wProductType == VER_NT_WORKSTATION ? version::win7_sp1 : version::server_2008r2_sp1; } else if (osvi.dwMinorVersion == 0) { if (osvi.wServicePackMajor == 2) return osvi.wProductType == VER_NT_WORKSTATION ? version::vista_sp2 : version::server_2008_sp2; else if (osvi.wServicePackMajor == 1) return osvi.wProductType == VER_NT_WORKSTATION ? version::vista_sp1 : version::server_2008_sp1; else if (osvi.wServicePackMajor == 0) return osvi.wProductType == VER_NT_WORKSTATION ? version::vista : version::server_2008; } } else if (osvi.dwMajorVersion == 5) { if (osvi.dwMinorVersion == 2) { SYSTEM_INFO si; GetSystemInfo(&si); if ((osvi.wProductType == VER_NT_WORKSTATION) && (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)) return version::xp_pro_64bit; else if (osvi.wSuiteMask & 0x00008000 /*VER_SUITE_WH_SERVER*/) return version::home_server; else return GetSystemMetrics(SM_SERVERR2) ? version::server_2003r2 : version::server_2003; } else if (osvi.dwMinorVersion == 1) return version::xp; else if (osvi.dwMinorVersion == 0) return version::win2000; } } #endif return version::unknown; }
// Create monitor from an adapter and (optionally) a display // static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter, DISPLAY_DEVICEW* display) { _GLFWmonitor* monitor; int widthMM, heightMM; char* name; HDC dc; DEVMODEW dm; RECT rect; if (display) name = _glfwCreateUTF8FromWideStringWin32(display->DeviceString); else name = _glfwCreateUTF8FromWideStringWin32(adapter->DeviceString); if (!name) return NULL; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &dm); dc = CreateDCW(L"DISPLAY", adapter->DeviceName, NULL, NULL); if (IsWindows8Point1OrGreater()) { widthMM = GetDeviceCaps(dc, HORZSIZE); heightMM = GetDeviceCaps(dc, VERTSIZE); } else { widthMM = (int) (dm.dmPelsWidth * 25.4f / GetDeviceCaps(dc, LOGPIXELSX)); heightMM = (int) (dm.dmPelsHeight * 25.4f / GetDeviceCaps(dc, LOGPIXELSY)); } DeleteDC(dc); monitor = _glfwAllocMonitor(name, widthMM, heightMM); free(name); if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED) monitor->win32.modesPruned = GLFW_TRUE; wcscpy(monitor->win32.adapterName, adapter->DeviceName); WideCharToMultiByte(CP_UTF8, 0, adapter->DeviceName, -1, monitor->win32.publicAdapterName, sizeof(monitor->win32.publicAdapterName), NULL, NULL); if (display) { wcscpy(monitor->win32.displayName, display->DeviceName); WideCharToMultiByte(CP_UTF8, 0, display->DeviceName, -1, monitor->win32.publicDisplayName, sizeof(monitor->win32.publicDisplayName), NULL, NULL); } rect.left = dm.dmPosition.x; rect.top = dm.dmPosition.y; rect.right = dm.dmPosition.x + dm.dmPelsWidth; rect.bottom = dm.dmPosition.y + dm.dmPelsHeight; EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor); return monitor; }
bool SFSystemInfo::InitializeOSInfo() { // 2014.07.02 최흥배 GetVersionEx를 MS에서 비추천 API로 지정되어서 새 API로 OS의 간단한 정보만 얻었습니다. // MSDN의 OS 버전 번호 http://msdn.microsoft.com/en-us/library/ms724832(v=vs.85).aspx if (IsWindowsServer()) { m_OSInfo.isServer = true; } if (IsWindows8Point1OrGreater()) { if (m_OSInfo.isServer) m_OSInfo.szOperatingSystem = "Windows Server 2012 R2 or Grater"; else m_OSInfo.szOperatingSystem = "Windows 8.1 or Grater"; m_OSInfo.majorVer = 6; m_OSInfo.minorVer = 3; } else if (IsWindows8OrGreater()) { if (m_OSInfo.isServer) m_OSInfo.szOperatingSystem = "Windows Server 2012"; else m_OSInfo.szOperatingSystem = "Windows 8"; m_OSInfo.majorVer = 6; m_OSInfo.minorVer = 2; } else if (IsWindows7OrGreater()) { if (m_OSInfo.isServer) m_OSInfo.szOperatingSystem = "Windows Server 2008 R2"; else m_OSInfo.szOperatingSystem = "Windows 7"; m_OSInfo.majorVer = 6; m_OSInfo.minorVer = 1; } else if (IsWindowsVistaOrGreater()) { if (m_OSInfo.isServer) m_OSInfo.szOperatingSystem = "Windows Server 2008"; else m_OSInfo.szOperatingSystem = "Windows Vista"; m_OSInfo.majorVer = 6; m_OSInfo.minorVer = 0; } else if (IsWindowsXPOrGreater()) { if (m_OSInfo.isServer) m_OSInfo.szOperatingSystem = "Windows Server 2003"; else m_OSInfo.szOperatingSystem = "Windows XP"; m_OSInfo.majorVer = 5; m_OSInfo.minorVer = 1; } return true; }
BOOL CSettings::OnInitDialog() { CDialog::OnInitDialog(); SetDlgItemText(IDC_HEAPEXE, heapTracingExes_.c_str()); CheckDlgButton(IDC_USE_OTHER_KERNEL_LOGGER, bUseOtherKernelLogger_); CheckDlgButton(IDC_BACKGROUND_MONITORING, bBackgroundTracing_); CheckDlgButton(IDC_CHROMEDEVELOPER, bChromeDeveloper_); CheckDlgButton(IDC_IDENTIFY_CHROME_CPU, bIdentifyChromeProcessesCPU_); CheckDlgButton(IDC_AUTOVIEWTRACES, bAutoViewTraces_); CheckDlgButton(IDC_RECORD_PRE_TRACE, bRecordPreTrace_); CheckDlgButton(IDC_HEAPSTACKS, bHeapStacks_); CheckDlgButton(IDC_VIRTUALALLOCSTACKS, bVirtualAllocStacks_); CheckDlgButton(IDC_CHECKFORNEWVERSIONS, bVersionChecks_); btIdentifyChromeProcessesCPU_.EnableWindow(bChromeDeveloper_); if (IsWindows8Point1OrGreater()) { // The working set monitoring is not needed on Windows 8.1 and above because // of the Microsoft-Windows-Kernel-Memory provider. btWSMonitoredProcesses_.EnableWindow(FALSE); btExpensiveWSMonitoring_.EnableWindow(FALSE); GetDlgItem(IDC_WS_MONITOR_STATIC)->EnableWindow(FALSE); } else { // A 32-bit process on 64-bit Windows will not be able to read the // full working set of 64-bit processes, so don't even try. if (Is64BitWindows() && !Is64BitBuild()) btWSMonitoredProcesses_.EnableWindow(FALSE); else SetDlgItemText(IDC_WSMONITOREDPROCESSES, WSMonitoredProcesses_.c_str()); CheckDlgButton(IDC_EXPENSIVEWS, bExpensiveWSMonitoring_); } btExtraKernelFlags_.SetWindowTextW(extraKernelFlags_.c_str()); btExtraStackwalks_.SetWindowTextW(extraKernelStacks_.c_str()); btExtraUserProviders_.SetWindowTextW(extraUserProviders_.c_str()); btPerfCounters_.SetWindowTextW(perfCounters_.c_str()); if (toolTip_.Create(this)) { toolTip_.SetMaxTipWidth(400); toolTip_.Activate(TRUE); toolTip_.AddTool(&btHeapTracingExe_, L"Specify which processes to heap trace when using " L"heap-tracing-to-file mode. Three different methods can be used to specify the processes:\n" L"1) A semi-colon separated list of process names, such as 'chrome.exe;notepad.exe'. " L"The processes must be launched after this is set and heap-tracing-to-file is selected.\n" L"2) A semi-colon separated list of process IDs (PIDs) - maximum of two - such as '1234;5678'.\n" L"3) A fully specified path to an executable that will be launched by ETW when heap tracing is " L"started."); toolTip_.AddTool(&btExtraKernelFlags_, L"Extra kernel flags, separated by '+', such as " L"\"REGISTRY+PERF_COUNTER\". See \"xperf -providers k\" for the full list. " L"Note that incorrect kernel flags will cause tracing to fail to start."); toolTip_.AddTool(&btExtraStackwalks_, L"List of extra stacks to collect from the kernel " L"kernel provider. For example, \n\"DiskReadInit+DiskWriteInit+DiskFlushInit\". " L"Run \"xperf -help stackwalk\" to see the full list. Note that incorrect stack " L"walk flags will cause tracing to fail to start. Note also that stack walk flags " L"are ignored if the corresponding kernel flag is not enabled."); toolTip_.AddTool(&btExtraUserProviders_, L"Extra user providers, separated by '+', such as " L"\n\"Microsoft-Windows-Audio+Microsoft-Windows-HttpLog\". See \"xperf -providers\" " L"for the full list. " L"TraceLogging and EventSource providers must be prefixed by '*'. " L"Note that incorrect user providers will cause tracing to fail to start."); toolTip_.AddTool(&btPerfCounters_, L"Arbitrary performance counters to be logged occasionally."); toolTip_.AddTool(&btWSMonitoredProcesses_, L"Names of processes whose working sets will be " L"monitored, separated by semi-colons. An empty string means no monitoring. A '*' means " L"that all processes will be monitored. For instance 'chrome.exe;notepad.exe'"); toolTip_.AddTool(&btExpensiveWSMonitoring_, L"Check this to have private working set and PSS " L"(proportional set size) calculated for monitored processes. This may consume " L"dozens or hundreds of ms each time. Without this checked only full working " L"set is calculated, which is cheap."); toolTip_.AddTool(&btCopyStartupProfile_, L"Copies startup.wpaProfile files for WPA 8.1 and " L"10 to the appropriate destinations so that the next time WPA starts up it will have " L"reasonable analysis defaults."); toolTip_.AddTool(&btUseOtherKernelLogger_, L"Check this to have UIforETW use the alternate kernel " L"logger. This is needed on some machines where the main kernel logger is in use."); toolTip_.AddTool(&btChromeDeveloper_, L"Check this to enable Chrome specific behavior such as " L"setting the Chrome symbol server path, and identifying Chrome processes."); toolTip_.AddTool(&btAutoViewTraces_, L"Check this to have UIforETW launch the trace viewer " L"immediately after a trace is recorded."); toolTip_.AddTool(&btRecordPreTrace_, L"Check this to enable recording of a startup trace " L"to grab a snapshot of module version and symbol information. This allows analyzing " L"traces across upgrades, such as chrome restart upgrades."); toolTip_.AddTool(&btHeapStacks_, L"Check this to record call stacks on HeapAlloc, HeapRealloc, " L"and similar calls, when doing heap traces."); toolTip_.AddTool(&btVirtualAllocStacks_, L"Check this to record call stacks on VirtualAlloc on all " L"traces instead of just heap traces."); toolTip_.AddTool(&btVersionChecks_, L"Check this to have UIforETW check for new versions at startup."); toolTip_.AddTool(&btChromeCategories_, L"Check the chrome tracing categories that you want Chrome " L"to emit ETW events for. This requires running Chrome version 46 or later, and " L"using chrome://flags/ to \"Enable exporting of tracing events to ETW\" - search for " L"trace-export on the chrome://flags/ page."); toolTip_.AddTool(&btIdentifyChromeProcessesCPU_, L"If this is checked and \"Chrome developer\" is " L"checked then CPU usage details of Chrome processes will be added to the trace information " L"file when traces are recorded. Calculating the CPU usage details can take a while."); toolTip_.AddTool(&btBackgroundMonitoring_, L"When this is checked background threads will periodically " L"(a few times per second) record information about system performance to the trace being " L"recorded. This can be helpful in understanding performance problems but may affect " L"power consumption."); } // Initialize the list of check boxes with all of the Chrome categories which // we can enable individually. btChromeCategories_.SetCheckStyle(BS_AUTOCHECKBOX); int index = 0; for (auto category : filtered_event_group_names) { btChromeCategories_.AddString(category); btChromeCategories_.SetCheck(index, (chromeKeywords_ & (1LL << index)) != 0); ++index; } // Manually add the two special Chrome category options. btChromeCategories_.AddString(other_events_group_name); btChromeCategories_.SetCheck(index, (chromeKeywords_ & other_events_keyword_bit) != 0); ++index; btChromeCategories_.AddString(disabled_other_events_group_name); btChromeCategories_.SetCheck(index, (chromeKeywords_ & disabled_other_events_keyword_bit) != 0); return TRUE; // return TRUE unless you set the focus to a control }
BOOL CSettings::OnInitDialog() { CDialog::OnInitDialog(); SetDlgItemText(IDC_HEAPEXE, heapTracingExes_.c_str()); CheckDlgButton(IDC_CHROMEDEVELOPER, bChromeDeveloper_); CheckDlgButton(IDC_AUTOVIEWTRACES, bAutoViewTraces_); CheckDlgButton(IDC_HEAPSTACKS, bHeapStacks_); CheckDlgButton(IDC_VIRTUALALLOCSTACKS, bVirtualAllocStacks_); CheckDlgButton(IDC_CHECKFORNEWVERSIONS, bVersionChecks_); btBufferSizes_.EnableWindow(FALSE); if (IsWindows8Point1OrGreater()) { // The working set monitoring is not needed on Windows 8.1 and above because // of the Microsoft-Windows-Kernel-Memory provider. btWSMonitoredProcesses_.EnableWindow(FALSE); btExpensiveWSMonitoring_.EnableWindow(FALSE); GetDlgItem(IDC_WS_MONITOR_STATIC)->EnableWindow(FALSE); } else { // A 32-bit process on 64-bit Windows will not be able to read the // full working set of 64-bit processes, so don't even try. if (Is64BitWindows() && !Is64BitBuild()) btWSMonitoredProcesses_.EnableWindow(FALSE); else SetDlgItemText(IDC_WSMONITOREDPROCESSES, WSMonitoredProcesses_.c_str()); CheckDlgButton(IDC_EXPENSIVEWS, bExpensiveWSMonitoring_); } btExtraKernelFlags_.SetWindowTextW(extraKernelFlags_.c_str()); btExtraStackwalks_.SetWindowTextW(extraKernelStacks_.c_str()); if (toolTip_.Create(this)) { toolTip_.SetMaxTipWidth(400); toolTip_.Activate(TRUE); toolTip_.AddTool(&btHeapTracingExe_, L"Specify the file names of the exes to be heap traced, " L"separated by semi-colons. " L"Enter just the file parts (with the .exe extension) not a full path. For example, " L"'chrome.exe;notepad.exe'. This is for use with the heap-tracing-to-file mode."); toolTip_.AddTool(&btExtraKernelFlags_, L"Extra kernel flags, separated by '+', such as " L"\"REGISTRY+PERF_COUNTER\". See \"xperf -providers k\" for the full list. " L"Note that incorrect kernel flags will cause tracing to fail to start."); toolTip_.AddTool(&btExtraStackwalks_, L"List of extra stacks to collect from the kernel " L"kernel provider. For example, \"DiskReadInit+DiskWriteInit+DiskFlushInit\". " L"Run \"xperf -help stackwalk\" to see the full list. Note that incorrect stack " L"walk flags will cause tracing to fail to start. Note also that stack walk flags " L"are ignored if the corresponding kernel flag is not enabled."); toolTip_.AddTool(&btWSMonitoredProcesses_, L"Names of processes whose working sets will be " L"monitored, separated by semi-colons. An empty string means no monitoring. A '*' means " L"that all processes will be monitored. For instance 'chrome.exe;notepad.exe'"); toolTip_.AddTool(&btExpensiveWSMonitoring_, L"Check this to have private working set and PSS " L"(proportional set size) calculated for monitored processes. This may consume " L"dozens or hundreds of ms each time. Without this checked only full working " L"set is calculated, which is cheap."); toolTip_.AddTool(&btCopyStartupProfile_, L"Copies startup.wpaProfile files for WPA 8.1 and " L"10 to the appropriate destinations so that the next time WPA starts up it will have " L"reasonable analysis defaults."); toolTip_.AddTool(&btCopySymbolDLLs_, L"Copy dbghelp.dll and symsrv.dll to the xperf directory to " L"try to resolve slow or failed symbol loading in WPA. See " L"https://randomascii.wordpress.com/2012/10/04/xperf-symbol-loading-pitfalls/ " L"for details."); toolTip_.AddTool(&btChromeDeveloper_, L"Check this to enable Chrome specific behavior such as " L"setting the Chrome symbol server path, and preprocessing of Chrome symbols and " L"traces."); toolTip_.AddTool(&btAutoViewTraces_, L"Check this to have UIforETW launch the trace viewer " L"immediately after a trace is recorded."); toolTip_.AddTool(&btHeapStacks_, L"Check this to record call stacks on HeapAlloc, HeapRealloc, " L"and similar calls, when doing heap traces."); toolTip_.AddTool(&btVirtualAllocStacks_, L"Check this to record call stacks on VirtualAlloc on all " L"traces instead of just heap traces."); toolTip_.AddTool(&btVersionChecks_, L"Check this to have UIforETW check for new versions at startup."); toolTip_.AddTool(&btChromeCategories_, L"Check the chrome tracing categories that you want Chrome " L"to emit ETW events for. This requires running Chrome version 46 or later, and " L"using chrome://flags/ to \"Enable exporting of tracing events to ETW\" - search for " L"trace-export on the chrome://flags/ page."); } // Initialize the list of check boxes with all of the Chrome categories which // we can enable individually. btChromeCategories_.SetCheckStyle(BS_AUTOCHECKBOX); int index = 0; for (auto category : filtered_event_group_names) { btChromeCategories_.AddString(category); btChromeCategories_.SetCheck(index, (chromeKeywords_ & (1LL << index)) != 0); ++index; } // Manually add the two special Chrome category options. btChromeCategories_.AddString(other_events_group_name); btChromeCategories_.SetCheck(index, (chromeKeywords_ & other_events_keyword_bit) != 0); ++index; btChromeCategories_.AddString(disabled_other_events_group_name); btChromeCategories_.SetCheck(index, (chromeKeywords_ & disabled_other_events_keyword_bit) != 0); return TRUE; // return TRUE unless you set the focus to a control }