const char* WMFDecoderDllNameFor(CodecType aCodec) { if (aCodec == H264) { // For H.264 decoding, we need msmpeg2vdec.dll on Win 7 & 8, // and mfh264dec.dll on Vista. if (IsWindows7OrGreater()) { return "msmpeg2vdec.dll"; } else { return "mfh264dec.dll"; } } else if (aCodec == AAC) { // For AAC decoding, we need to use msauddecmft.dll on Win8, // msmpeg2adec.dll on Win7, and msheaacdec.dll on Vista. if (IsWindows8OrGreater()) { return "msauddecmft.dll"; } else if (IsWindows7OrGreater()) { return "msmpeg2adec.dll"; } else { return "mfheaacdec.dll"; } } else { return ""; } }
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> /// 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; }
//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> /// 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; }
bool CMainWindow::Initialize() { m_hWndEdit = ::CreateWindow( L"Scintilla", L"Source", WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, *this, 0, hResource, 0); if (m_hWndEdit == NULL) return false; RECT rect; GetClientRect(*this, &rect); ::SetWindowPos(m_hWndEdit, HWND_TOP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW); m_directFunction = SendMessage(m_hWndEdit, SCI_GETDIRECTFUNCTION, 0, 0); m_directPointer = SendMessage(m_hWndEdit, SCI_GETDIRECTPOINTER, 0, 0); // Set up the global default style. These attributes are used wherever no explicit choices are made. CRegStdDWORD used2d(L"Software\\TortoiseSVN\\ScintillaDirect2D", TRUE); bool enabled2d = false; if (IsWindows7OrGreater() && DWORD(used2d)) enabled2d = true; std::wstring fontNameW = CRegStdString(L"Software\\TortoiseSVN\\UDiffFontName", L"Consolas"); std::string fontName; fontName = CUnicodeUtils::StdGetUTF8(fontNameW); SetAStyle(STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffFontSize", 10), fontName.c_str()); SendEditor(SCI_SETTABWIDTH, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffTabSize", 4)); SendEditor(SCI_SETREADONLY, TRUE); LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"_99999"); SendEditor(SCI_SETMARGINWIDTHN, 0, pix); SendEditor(SCI_SETMARGINWIDTHN, 1); SendEditor(SCI_SETMARGINWIDTHN, 2); //Set the default windows colors for edit controls SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW)); SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT)); SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT)); SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT)); if (enabled2d) { SendEditor(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITERETAIN); SendEditor(SCI_SETBUFFEREDDRAW, 0); } SendEditor(SCI_SETVIEWWS, 1); SendEditor(SCI_SETWHITESPACESIZE, 2); SendEditor(SCI_SETWHITESPACEFORE, true, ::GetSysColor(COLOR_3DSHADOW)); SendEditor(SCI_STYLESETVISIBLE, STYLE_CONTROLCHAR, TRUE); return true; }
// Windows Vista doesn't support the NO_REPEAT_FLAG UINT Timer::getNoRepeatFlag() const { UINT flag = 0x0000; if (IsWindows7OrGreater()) { flag = 0x4000; } return flag; }
/// <summary> /// Execute code in context of our worker thread /// </summary> /// <param name="pCode">Cde to execute</param> /// <param name="size">Code size.</param> /// <param name="callResult">Execution result</param> /// <returns>Status</returns> NTSTATUS RemoteExec::ExecInWorkerThread( PVOID pCode, size_t size, uint64_t& callResult ) { NTSTATUS dwResult = STATUS_SUCCESS; // Create thread if needed CreateRPCEnvironment(); // Write code dwResult = CopyCode( pCode, size ); if (dwResult != STATUS_SUCCESS) return dwResult; if (_hWaitEvent) ResetEvent( _hWaitEvent ); // Patch KiUserApcDispatcher #ifdef USE64 if (!_apcPatched && IsWindows7OrGreater() && !IsWindows8OrGreater()) { if (_proc.core().native()->GetWow64Barrier().type == wow_64_32) { auto patchBase = _proc.nativeLdr().APC64PatchAddress(); if (patchBase != 0) { DWORD flOld = 0; _memory.Protect(patchBase, 6, PAGE_EXECUTE_READWRITE, &flOld); _memory.Write(patchBase + 0x2, (uint8_t)0x0C); _memory.Write( patchBase + 0x4, (uint8_t)0x90 ); _memory.Protect( patchBase, 6, flOld, nullptr ); } _apcPatched = true; } else _apcPatched = true; } #endif // Execute code in thread context if (QueueUserAPC( _userCode.ptr<PAPCFUNC>(), _hWorkThd.handle(), _userCode.ptr<ULONG_PTR>() )) { dwResult = WaitForSingleObject( _hWaitEvent, INFINITE ); callResult = _userData.Read<uint64_t>( RET_OFFSET, 0 ); } else return LastNtStatus(); // Ensure APC function fully returns Sleep( 1 ); return dwResult; }
void UI_DoCreation() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (IsWindows7OrGreater()) { CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&g_uui.tbList)); } UI_RegisterClass(); UI_CreateWindow(); }
/// <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; }
HANDLE DllInjector::attachToProcess(DWORD procID) { SetDebugPrivileges(); if (IsWindows7OrGreater()) { return OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, procID); } else { if (_logger) _logger->error("get version ex Failed (probably bad win version!)! [%d]", GetLastError()); } /* if (osver.dwMajorVersion == 5) { return OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, 0, procID); }*/ return NULL; }
/// <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 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; }
bool CanvasD2D::Initialize() { ++c_Instances; if (c_Instances == 1) { if (!IsWindows7OrGreater()) return false; D2D1_FACTORY_OPTIONS fo = {}; #ifdef _DEBUG fo.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; #endif HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, fo, c_D2DFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = CoCreateInstance( CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)c_WICFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(c_DWFactory), (IUnknown**)c_DWFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = c_DWFactory->GetGdiInterop(c_DWGDIInterop.GetAddressOf()); if (FAILED(hr)) return false; hr = c_DWFactory->RegisterFontCollectionLoader(Util::DWriteFontCollectionLoader::GetInstance()); if (FAILED(hr)) return false; } return true; }
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")); /*------------------------------------------------------------------------------------*/ }
PoeditListCtrl::PoeditListCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, bool dispIDs, const wxValidator& validator, const wxString &name) : wxListView(parent, id, pos, size, style | wxLC_VIRTUAL, validator, name) { #ifdef __WXMSW__ if (wxApp::GetComCtl32Version() >= 600) { ::SendMessage(GetHwnd(), LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER); } #endif m_displayIDs = dispIDs; m_isRTL = false; m_appIsRTL = (wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft); sortOrder = SortOrder::Default(); CreateColumns(); wxImageList *list = new wxImageList(PX(16), PX(16)); // IMG_XXX: #ifndef __WXMSW__ list->Add(wxArtProvider::GetBitmap("poedit-status-nothing")); #endif list->Add(wxArtProvider::GetBitmap("poedit-status-automatic")); list->Add(wxArtProvider::GetBitmap("poedit-status-comment")); list->Add(wxArtProvider::GetBitmap("poedit-status-bookmark")); AssignImageList(list, wxIMAGE_LIST_SMALL); // configure items colors & fonts: wxVisualAttributes visual = GetDefaultAttributes(); wxColour shaded = visual.colBg; #ifdef __WXMSW__ // On Windows 7, shaded list items make it impossible to see the selection, // so use different color for it (see bug #336). if (IsWindows7OrGreater()) { shaded.Set(int(0.99 * shaded.Red()), int(0.99 * shaded.Green()), shaded.Blue()); } else #endif // __WXMSW__ #ifdef __WXOSX__ if ( shaded == *wxWHITE ) { // use standard shaded color from finder/databrowser: shaded.Set("#f0f5fd"); } else #endif // __WXOSX__ { shaded.Set(int(DARKEN_FACTOR * shaded.Red()), int(DARKEN_FACTOR * shaded.Green()), int(DARKEN_FACTOR * shaded.Blue())); } m_attrNormal[1].SetBackgroundColour(shaded); m_attrUntranslated[1].SetBackgroundColour(shaded); m_attrFuzzy[1].SetBackgroundColour(shaded); m_attrInvalid[1].SetBackgroundColour(shaded); // FIXME: make this user-configurable if ( IsAlmostWhite(visual.colBg) ) { m_attrUntranslated[0].SetTextColour(gs_UntranslatedForWhite); m_attrUntranslated[1].SetTextColour(gs_UntranslatedForWhite); m_attrFuzzy[0].SetTextColour(gs_FuzzyForWhite); m_attrFuzzy[1].SetTextColour(gs_FuzzyForWhite); } else if ( IsAlmostBlack(visual.colBg) ) { m_attrUntranslated[0].SetTextColour(gs_UntranslatedForBlack); m_attrUntranslated[1].SetTextColour(gs_UntranslatedForBlack); m_attrFuzzy[0].SetTextColour(gs_FuzzyForBlack); m_attrFuzzy[1].SetTextColour(gs_FuzzyForBlack); } // else: we don't know if the default colors would be well-visible on // user's background color, so play it safe and don't highlight // anything // FIXME: todo; use appropriate font for fuzzy/trans/untrans m_attrInvalid[0].SetBackgroundColour(gs_ErrorColor); m_attrInvalid[1].SetBackgroundColour(gs_ErrorColor); // Use gray for IDs if ( IsAlmostBlack(visual.colFg) ) m_attrId.SetTextColour(wxColour("#A1A1A1")); SetCustomFont(wxNullFont); }
bool InitDDrawCapture() { bool versionSupported = false; HMODULE hDDrawLib = NULL; if (hDDrawLib = GetModuleHandle(TEXT("ddraw.dll"))) { bool isWinVistaMin = IsWindowsVistaOrGreater(); bool isWin7min = IsWindows7OrGreater(); bool isWin8min = IsWindows8OrGreater(); UPARAM libBaseAddr = UPARAM(hDDrawLib); UPARAM surfCreateOffset; UPARAM surfUnlockOffset; UPARAM surfReleaseOffset; UPARAM surfRestoreOffset; UPARAM surfBltOffset; UPARAM surfFlipOffset; UPARAM surfSetPaletteOffset; UPARAM palSetEntriesOffset; if (isWinVistaMin) { if (!isWin7min) { RUNEVERYRESET logOutput << CurrentTimeString() << "Windows Vista not supported yet" << endl; } else if (isWin7min && !isWin8min) { surfCreateOffset = 0x617E; surfUnlockOffset = 0x4C40; surfReleaseOffset = 0x3239; surfRestoreOffset = 0x3E9CB; surfBltOffset = surfCreateOffset + 0x44F63; surfFlipOffset = surfCreateOffset + 0x37789; surfSetPaletteOffset = surfCreateOffset + 0x4D2D3; palSetEntriesOffset = surfCreateOffset + 0x4CE68; versionSupported = true; } else if (isWin8min) { surfCreateOffset = 0x9530 + 0xC00; surfUnlockOffset = surfCreateOffset + 0x2A1D0; surfReleaseOffset = surfCreateOffset - 0x1A80; surfRestoreOffset = surfCreateOffset + 0x36000; surfBltOffset = surfCreateOffset + 0x438DC; surfFlipOffset = surfCreateOffset + 0x33EF3; surfSetPaletteOffset = surfCreateOffset + 0x4D3B8; palSetEntriesOffset = surfCreateOffset + 0x4CF4C; versionSupported = false; // some crash bugs remaining RUNEVERYRESET logOutput << CurrentTimeString() << "Windows 8 not supported yet" << endl; } else { RUNEVERYRESET logOutput << CurrentTimeString() << "Unknown OS version" << endl; } } else { RUNEVERYRESET logOutput << CurrentTimeString() << "OS version not supported" << endl; } if (versionSupported) { ddrawSurfaceCreate.Hook((FARPROC)(libBaseAddr + surfCreateOffset), (FARPROC)CreateSurface); ddrawSurfaceRestore.Hook((FARPROC)(libBaseAddr + surfRestoreOffset), (FARPROC)Restore); ddrawSurfaceRelease.Hook((FARPROC)(libBaseAddr + surfReleaseOffset), (FARPROC)Release); ddrawSurfaceUnlock.Hook((FARPROC)(libBaseAddr + surfUnlockOffset), (FARPROC)Unlock); ddrawSurfaceBlt.Hook((FARPROC)(libBaseAddr + surfBltOffset), (FARPROC)Blt); ddrawSurfaceFlip.Hook((FARPROC)(libBaseAddr + surfFlipOffset), (FARPROC)Flip); ddrawSurfaceSetPalette.Hook((FARPROC)(libBaseAddr + surfSetPaletteOffset), (FARPROC)SetPalette); ddrawPaletteSetEntries.Hook((FARPROC)(libBaseAddr + palSetEntriesOffset), (FARPROC)PaletteSetEntries); ddrawSurfaceUnlock.Rehook(); ddrawSurfaceFlip.Rehook(); ddrawSurfaceBlt.Rehook(); /* ddrawSurfaceCreate.Rehook(); ddrawSurfaceRestore.Rehook(); ddrawSurfaceRelease.Rehook(); ddrawSurfaceSetPalette.Rehook(); ddrawPaletteSetEntries.Rehook(); */ } } return versionSupported; }
bool IsWindowsVistaOrLesser() { return !IsWindows7OrGreater(); }
void FileList::ReadFileNames(int KeepSelection, int UpdateEvenIfPanelInvisible, int DrawMessage) { SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<FileListPreRedrawItem>()); SCOPED_ACTION(TaskBar)(false); strOriginalCurDir = strCurDir; if (!IsVisible() && !UpdateEvenIfPanelInvisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } UpdateRequired=FALSE; AccessTimeUpdateRequired=FALSE; DizRead=FALSE; api::FAR_FIND_DATA fdata; decltype(ListData) OldData; string strCurName, strNextCurName; StopFSWatcher(); if (this!=Global->CtrlObject->Cp()->LeftPanel && this!=Global->CtrlObject->Cp()->RightPanel) return; string strSaveDir; api::GetCurrentDirectory(strSaveDir); { string strOldCurDir(strCurDir); if (!SetCurPath()) { FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте... if (strCurDir == strOldCurDir) //?? i?? { GetPathRoot(strOldCurDir,strOldCurDir); if (!api::IsDiskInDrive(strOldCurDir)) IfGoHome(strOldCurDir.front()); /* При смене каталога путь не изменился */ } return; } } SortGroupsRead=FALSE; if (GetFocus()) Global->CtrlObject->CmdLine->SetCurDir(strCurDir); LastCurFile=-1; Panel *AnotherPanel=Global->CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->QViewDelTempName(); size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; FreeDiskSize = -1; if (Global->Opt->ShowPanelFree) { api::GetDiskSize(strCurDir, nullptr, nullptr, &FreeDiskSize); } if (!ListData.empty()) { strCurName = ListData[CurFile].strName; if (ListData[CurFile].Selected && !ReturnCurrentFile) { for (size_t i=CurFile+1; i < ListData.size(); i++) { if (!ListData[i].Selected) { strNextCurName = ListData[i].strName; break; } } } } if (KeepSelection || PrevSelFileCount>0) { OldData.swap(ListData); } else DeleteListData(ListData); DWORD FileSystemFlags = 0; string PathRoot; GetPathRoot(strCurDir, PathRoot); api::GetVolumeInformation(PathRoot, nullptr, nullptr, nullptr, &FileSystemFlags, nullptr); ListData.clear(); bool ReadOwners = IsColumnDisplayed(OWNER_COLUMN); bool ReadNumLinks = IsColumnDisplayed(NUMLINK_COLUMN); bool ReadNumStreams = IsColumnDisplayed(NUMSTREAMS_COLUMN); bool ReadStreamsSize = IsColumnDisplayed(STREAMSSIZE_COLUMN); if (!(FileSystemFlags&FILE_SUPPORTS_HARD_LINKS) && IsWindows7OrGreater()) { ReadNumLinks = false; } if(!(FileSystemFlags&FILE_NAMED_STREAMS)) { ReadNumStreams = false; ReadStreamsSize = false; } string strComputerName; if (ReadOwners) { string strTemp; CurPath2ComputerName(strCurDir, strComputerName, strTemp); } SetLastError(ERROR_SUCCESS); // сформируем заголовок вне цикла string Title = MakeSeparator(X2-X1-1, 9, nullptr); BOOL IsShowTitle=FALSE; BOOL NeedHighlight=Global->Opt->Highlight && PanelMode != PLUGIN_PANEL; if (!Filter) Filter = std::make_unique<FileFilter>(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); Global->CtrlObject->HiFiles->UpdateCurrentTime(); bool bCurDirRoot = false; ParsePath(strCurDir, nullptr, &bCurDirRoot); PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot); bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC); string strFind(strCurDir); AddEndSlash(strFind); strFind+=L'*'; api::FindFile Find(strFind, true); DWORD FindErrorCode = ERROR_SUCCESS; bool UseFilter=Filter->IsEnabledOnPanel(); bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0; DWORD StartTime = GetTickCount(); std::all_of(CONST_RANGE(Find, fdata) -> bool { Global->CatchError(); FindErrorCode = Global->CaughtError(); if ((Global->Opt->ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName))) { if (ListData.size() == ListData.capacity()) ListData.reserve(ListData.size() + 4096); ListData.emplace_back(VALUE_TYPE(ListData)()); auto& NewItem = ListData.back(); NewItem.FileAttr = fdata.dwFileAttributes; NewItem.CreationTime = fdata.ftCreationTime; NewItem.AccessTime = fdata.ftLastAccessTime; NewItem.WriteTime = fdata.ftLastWriteTime; NewItem.ChangeTime = fdata.ftChangeTime; NewItem.FileSize = fdata.nFileSize; NewItem.AllocationSize = fdata.nAllocationSize; NewItem.strName = fdata.strFileName; NewItem.strShortName = fdata.strAlternateFileName; NewItem.Position = ListData.size() - 1; NewItem.NumberOfLinks=1; if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { NewItem.ReparseTag=fdata.dwReserved0; //MSDN } if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileSize += NewItem.FileSize; if (ReadNumLinks) NewItem.NumberOfLinks = GetNumberOfLinks(fdata.strFileName, true); } else { NewItem.AllocationSize = 0; } NewItem.SortGroup=DEFAULT_SORT_GROUP; if (ReadOwners) { string strOwner; GetFileOwner(strComputerName, NewItem.strName,strOwner); NewItem.strOwner = strOwner; } NewItem.NumberOfStreams=NewItem.FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1; NewItem.StreamsSize=NewItem.FileSize; if (ReadNumStreams||ReadStreamsSize) { EnumStreams(TestParentFolderName(fdata.strFileName)? strCurDir : fdata.strFileName, NewItem.StreamsSize, NewItem.NumberOfStreams); } if (ReadCustomData) NewItem.strCustomData = Global->CtrlObject->Plugins->GetCustomData(NewItem.strName); if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; DWORD CurTime = GetTickCount(); if (CurTime - StartTime > (DWORD)Global->Opt->RedrawTimeout) { StartTime = CurTime; if (IsVisible()) { if (!IsShowTitle) { if (!DrawMessage) { Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title); IsShowTitle=TRUE; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); } } LangString strReadMsg(MReadingFiles); strReadMsg << ListData.size(); if (DrawMessage) { ReadFileNamesMsg(strReadMsg); } else { TruncStr(strReadMsg,static_cast<int>(Title.size())-2); int MsgLength=(int)strReadMsg.size(); GotoXY(X1+1+(static_cast<int>(Title.size())-MsgLength-1)/2,Y1); Global->FS << L" "<<strReadMsg<<L" "; } } Global->CtrlObject->Macro.SuspendMacros(true); bool check = CheckForEsc(); Global->CtrlObject->Macro.SuspendMacros(false); if (check) { // break loop return false; } } } return true; });
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; }
BOOL CSetMainPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); EnableToolTips(); m_sTempExtensions = m_regExtensions; m_dwLanguage = m_regLanguage; m_bUseAero = m_regUseAero; HIGHCONTRAST hc = { sizeof(HIGHCONTRAST) }; SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hc, FALSE); BOOL bEnabled = FALSE; DialogEnableWindow(IDC_AERODWM, ((hc.dwFlags & HCF_HIGHCONTRASTON) == 0) && SUCCEEDED(DwmIsCompositionEnabled(&bEnabled)) && bEnabled); if (IsWindows10OrGreater()) GetDlgItem(IDC_AERODWM)->ShowWindow(SW_HIDE); CString temp; temp = m_regLastCommitTime; m_bLastCommitTime = (temp.CompareNoCase(L"yes")==0); m_tooltips.AddTool(IDC_TEMPEXTENSIONSLABEL, IDS_SETTINGS_TEMPEXTENSIONS_TT); m_tooltips.AddTool(IDC_TEMPEXTENSIONS, IDS_SETTINGS_TEMPEXTENSIONS_TT); m_tooltips.AddTool(IDC_COMMITFILETIMES, IDS_SETTINGS_COMMITFILETIMES_TT); m_tooltips.AddTool(IDC_CREATELIB, IDS_SETTINGS_CREATELIB_TT); DialogEnableWindow(IDC_CREATELIB, IsWindows7OrGreater()); // set up the language selecting combobox TCHAR buf[MAX_PATH] = { 0 }; GetLocaleInfo(1033, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); m_LanguageCombo.AddString(buf); m_LanguageCombo.SetItemData(0, 1033); CString path = CPathUtils::GetAppParentDirectory(); path = path + L"Languages\\"; CSimpleFileFind finder(path, L"*.dll"); int langcount = 1; while (finder.FindNextFileNoDirectories()) { CString file = finder.GetFilePath(); CString filename = finder.GetFileName(); if (filename.Left(12).CompareNoCase(L"TortoiseProc")==0) { CString sVer = _T(STRPRODUCTVER); sVer = sVer.Left(sVer.ReverseFind('.')); CString sFileVer = CPathUtils::GetVersionFromFile(file); sFileVer = sFileVer.Left(sFileVer.ReverseFind('.')); if (sFileVer.Compare(sVer)!=0) continue; CString sLoc = filename.Mid(12); sLoc = sLoc.Left(sLoc.GetLength()-4); // cut off ".dll" if ((sLoc.Left(2) == L"32")&&(sLoc.GetLength() > 5)) continue; DWORD loc = _tstoi(filename.Mid(12)); GetLocaleInfo(loc, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); CString sLang = buf; GetLocaleInfo(loc, LOCALE_SNATIVECTRYNAME, buf, _countof(buf)); if (buf[0]) { sLang += L" ("; sLang += buf; sLang += L")"; } m_LanguageCombo.AddString(sLang); m_LanguageCombo.SetItemData(langcount++, loc); } } for (int i=0; i<m_LanguageCombo.GetCount(); i++) { if (m_LanguageCombo.GetItemData(i) == m_dwLanguage) m_LanguageCombo.SetCurSel(i); } UpdateData(FALSE); return TRUE; }
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; }