// ConEmuC -OsVerInfo int OsVerInfo() { OSVERSIONINFOEX osv = {sizeof(osv)}; GetOsVersionInformational((OSVERSIONINFO*)&osv); UINT DBCS = IsDbcs(); UINT HWFS = IsHwFullScreenAvailable(); UINT W5fam = IsWin5family(); UINT WXPSP1 = IsWinXPSP1(); UINT W6 = IsWin6(); UINT W7 = IsWin7(); UINT W10 = IsWin10(); UINT Wx64 = IsWindows64(); UINT WINE = IsWine(); UINT WPE = IsWinPE(); UINT TELNET = isTerminalMode(); wchar_t szInfo[200]; _wsprintf(szInfo, SKIPCOUNT(szInfo) L"OS version information\n" L"%u.%u build %u SP%u.%u suite=x%04X type=%u\n" L"W5fam=%u WXPSP1=%u W6=%u W7=%u W10=%u Wx64=%u\n" L"HWFS=%u DBCS=%u WINE=%u WPE=%u TELNET=%u\n", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osv.wServicePackMajor, osv.wServicePackMinor, osv.wSuiteMask, osv.wProductType, W5fam, WXPSP1, W6, W7, W10, Wx64, HWFS, DBCS, WINE, WPE, TELNET); _wprintf(szInfo); return MAKEWORD(osv.dwMinorVersion, osv.dwMajorVersion); }
CString CUtils::GetOsName( void ) { static CString szOsName; if (szOsName.IsEmpty()) { if (IsXP()) { szOsName = L"windowsxp"; } if (IsVista()) { szOsName = L"windowsvista"; } if (IsWin7()) { szOsName = L"windows7"; } if (IsWin8()) { szOsName = L"windows8"; } if (IsWin8_1()) { szOsName = L"windows81"; } if (IsWin10()) { szOsName = L"windows10"; } } return szOsName; }
bool InitHooksCmdExe() { if (!gbIsCmdProcess) return true; HLOG1("InitHooksCmdExe",0); bool lbRc = false; HookItem HooksCmdOnly[] = { // Vista and below: AdvApi32.dll // **NB** In WinXP this module is not linked statically HOOK_ITEM_BY_NAME(RegQueryValueExW, IsWin7() ? kernel32 : advapi32), {0, 0, 0} }; if (InitHooks(HooksCmdOnly) < 0) goto wrap; lbRc = true; wrap: HLOGEND1(); return lbRc; }
/* メインダイアログ用 WM_INITDIALOG 処理ルーチン */ BOOL TLaunchDlg::EvCreate(LPARAM lParam) { SetDlgItemText(MESSAGE_STATIC, msg); if (IsWin7()) { ::ShowWindow(GetDlgItem(LAUNCH_BUTTON), SW_SHOW); } Show(); return TRUE; }
void Ctrl::InitWin32(HINSTANCE hInstance) { GuiLock __; LLOG("InitWin32"); InstallPanicMessageBox(&Win32PanicMessageBox); // RLOGBLOCK("Ctrl::InitWin32"); sMainThreadId = GetCurrentThreadId(); #define ILOG(x) // RLOG(x) Ctrl::hInstance = hInstance; ILOG("RegisterClassW"); #ifndef PLATFORM_WINCE if(IsWinNT()) #endif { WNDCLASSW wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L"UPP-CLASS-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-DS-W"; RegisterClassW(&wc); wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-SB-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L"UPP-CLASS-SB-DS-W"; RegisterClassW(&wc); } ILOG("RegisterClassA"); WNDCLASS wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L_("UPP-CLASS-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-DS-A"); RegisterClass(&wc); } wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-SB-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L_("UPP-CLASS-SB-DS-A"); RegisterClass(&wc); } wc.style = 0; wc.lpszClassName = L_("UPP-TIMER"); wc.hCursor = NULL; wc.lpfnWndProc = &Ctrl::UtilityProc; RegisterClass(&wc); ILOG("InitTimer"); InitTimer(); ILOG("SetTimer"); utilityHWND = CreateWindow(L_("UPP-TIMER"), L_(""), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); SetTimer(utilityHWND, 1, 10, NULL); ILOG("Windows"); Windows(); //?? TRC: what's the use of this? ReSkin(); OleInitialize(NULL); /* TRC 05/11/14: moved to GuiSleep to avoid thread creation in OCX DllMain DWORD dummy; OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy); ExitLoopEvent().Wait(); */ // TRC 05/11/18: pSetLayeredWindowAttributes moved to GLOBAL_VAR (see below) to make OCX initialization simpler Csizeinit(); #undef ILOG if(IsWin7()) GlobalBackPaint(); }
BOOL TInstDlg::Install(void) { char buf[MAX_PATH], setupDir[MAX_PATH], setupPath[MAX_PATH]; BOOL is_delay_copy = FALSE; int len; // インストールパス設定 len = GetDlgItemText(FILE_EDIT, setupDir, sizeof(setupDir)); if (GetChar(setupDir, len-1) == '\\') SetChar(setupDir, len-1, 0); Wstr w_setup(setupDir); if (IsWinVista() && TIsVirtualizedDirV(w_setup.Buf())) { if (!TIsUserAnAdmin()) { return RunAsAdmin(TRUE); } else if (cfg.runImme && cfg.setupDir && lstrcmpiV(w_setup.Buf(), cfg.setupDir)) { return MessageBox(GetLoadStr(IDS_ADMINCHANGE)), FALSE; } } CreateDirectory(setupDir, NULL); DWORD attr = GetFileAttributes(setupDir); if (attr == 0xffffffff || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0) return MessageBox(GetLoadStr(IDS_NOTCREATEDIR)), FALSE; MakePath(setupPath, setupDir, FASTCOPY_EXE); if (MessageBox(GetLoadStr(IDS_START), INSTALL_STR, MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return FALSE; // ファイルコピー if (cfg.mode == SETUP_MODE) { char installPath[MAX_PATH], orgDir[MAX_PATH]; ::GetModuleFileName(NULL, orgDir, sizeof(orgDir)); GetParentDir(orgDir, orgDir); for (int cnt=0; SetupFiles[cnt] != NULL; cnt++) { MakePath(buf, orgDir, SetupFiles[cnt]); MakePath(installPath, setupDir, SetupFiles[cnt]); if (MiniCopy(buf, installPath) || IsSameFile(buf, installPath)) continue; if ((strcmp(SetupFiles[cnt], CURRENT_SHEXTDLL_EX) == 0 || strcmp(SetupFiles[cnt], CURRENT_SHEXTDLL) == 0) && DelayCopy(buf, installPath)) { is_delay_copy = TRUE; continue; } return MessageBox(installPath, GetLoadStr(IDS_NOTCREATEFILE)), FALSE; } } // スタートメニュー&デスクトップに登録 char *linkPath[] = { toA(cfg.startMenu, TRUE), toA(cfg.deskTop, TRUE), NULL }; BOOL execFlg[] = { cfg.programLink, cfg.desktopLink, NULL }; for (int cnt=0; linkPath[cnt]; cnt++) { strcpy(buf, linkPath[cnt]); if (cnt != 0 || RemoveSameLink(linkPath[cnt], buf) == FALSE) { ::wsprintf(buf + strlen(buf), "\\%s", FASTCOPY_SHORTCUT); } if (execFlg[cnt]) { if (IS_WINNT_V) { Wstr w_setup(setupPath, BY_MBCS); Wstr w_buf(buf, BY_MBCS); SymLinkV(w_setup.Buf(), w_buf.Buf()); } else { SymLinkV(setupPath, buf); } } else { if (IS_WINNT_V) { Wstr w_buf(buf, BY_MBCS); DeleteLinkV(w_buf.Buf()); } else { DeleteLinkV(buf); } } } #if 0 // レジストリにアンインストール情報を登録 if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) { if (reg.CreateKey(FASTCOPY)) { MakePath(buf, setupDir, INSTALL_EXE); strcat(buf, " /r"); reg.SetStr(REGSTR_VAL_UNINSTALLER_DISPLAYNAME, FASTCOPY); reg.SetStr(REGSTR_VAL_UNINSTALLER_COMMANDLINE, buf); reg.CloseKey(); } reg.CloseKey(); } #endif if (IsWinVista() && TIsVirtualizedDirV(w_setup.Buf())) { WCHAR wbuf[MAX_PATH] = L"", old_path[MAX_PATH] = L"", usr_path[MAX_PATH] = L""; WCHAR fastcopy_dir[MAX_PATH], *fastcopy_dirname = NULL; GetFullPathNameW(w_setup.Buf(), MAX_PATH, fastcopy_dir, &fastcopy_dirname); if (cfg.appData) { strcpyV(usr_path, cfg.appData); } else { TSHGetSpecialFolderPathV(NULL, wbuf, CSIDL_APPDATA, FALSE); MakePathV(usr_path, wbuf, fastcopy_dirname); } ConvertVirtualStoreConf(w_setup.Buf(), usr_path, cfg.virtualDir); } // コピーしたアプリケーションを起動 const char *msg = GetLoadStr(is_delay_copy ? IDS_DELAYSETUPCOMPLETE : IDS_SETUPCOMPLETE); int flg = MB_OKCANCEL|MB_ICONINFORMATION; if (IsWin7()) { msg = Fmt("%s%s", msg, GetLoadStr(IDS_COMPLETE_WIN7)); } TLaunchDlg dlg(msg, this); UINT id; if ((id = dlg.Exec()) == IDOK || id == LAUNCH_BUTTON) { char *arg = (id == LAUNCH_BUTTON) ? "/install" : ""; ShellExecute(NULL, "open", setupPath, arg, setupDir, SW_SHOW); } ::PostQuitMessage(0); return TRUE; }
/* ************************ */ bool InitHooksDefTerm() { HLOG1("InitHooksDefTerm",0); bool lbRc = false; // These functions are required for seizing console and behave as Default Terminal HookItem HooksCommon[] = { HOOK_ITEM_BY_NAME(CreateProcessW, kernel32), // Need to "hook" OnCreateProcessA because it is used in "OnWinExec" HOOK_ITEM_BY_NAME(CreateProcessA, kernel32), // Used in some programs, Issue 853 HOOK_ITEM_BY_NAME(WinExec, kernel32), // Need for hook "Run as administrator" HOOK_ITEM_BY_NAME(ShellExecuteExW, shell32), {0} }; HookItem HooksAllocConsole[] = { // gh-888, gh-55: Allow to use ConEmu as default console in third-party applications HOOK_ITEM_BY_NAME(AllocConsole, kernel32), // Only for "*.vshost.exe"? {0} }; HookItem HooksCmdLine[] = { // Issue 1125: "Run as administrator" too. Must be last export HOOK_ITEM_BY_ORDN(ShellExecCmdLine, shell32, 265), {0} }; HookItem HooksVshost[] = { // Issue 1312: .Net applications runs in "*.vshost.exe" helper GUI application when debugging // AllocConsole moved to HooksCommon HOOK_ITEM_BY_NAME(ShowWindow, user32), /* ************************ */ {0} }; // Required in VisualStudio and CodeBlocks (gdb) debuggers // Don't restrict to them, other Dev Envs may behave in similar way HookItem HooksDevStudio[] = { HOOK_ITEM_BY_NAME(ResumeThread, kernel32), /* ************************ */ {0} }; // Required for hooking in OS // bool check if (!InitHooksLibrary()) goto wrap; // Start our functions if (InitHooks(HooksCommon) < 0) goto wrap; if (gbIsNetVsHost || gbPrepareDefaultTerminal) { if (InitHooks(HooksAllocConsole) < 0) goto wrap; } // Windows 7. There is new undocumented function "ShellExecCmdLine" used by Explorer if (IsWin7()) { if (InitHooks(HooksCmdLine) < 0) goto wrap; } // "*.vshost.exe" uses special helper if (gbIsNetVsHost) { if (InitHooks(HooksVshost) < 0) goto wrap; } // Required in VisualStudio and CodeBlocks (gdb) debuggers // Don't restrict to them, other Dev Envs may behave in similar way { if (InitHooks(HooksDevStudio) < 0) goto wrap; } gnDllState |= ds_HooksDefTerm; lbRc = true; wrap: HLOGEND1(); return lbRc; }