Esempio n. 1
0
COORD MyGetLargestConsoleWindowSize(HANDLE hConsoleOutput)
{
	// Fails in Wine
	COORD crMax = hkFunc.getLargestConsoleWindowSize(hConsoleOutput);
	DWORD dwErr = (crMax.X && crMax.Y) ? 0 : GetLastError();
	UNREFERENCED_PARAMETER(dwErr);

	// Wine BUG
	//if (!crMax.X || !crMax.Y)
	if ((crMax.X == 80 && crMax.Y == 24) && IsWine())
	{
		crMax.X = 999;
		crMax.Y = 999;
	}
	#ifdef _DEBUG
	else if (IsWin10())
	{
		CONSOLE_SCREEN_BUFFER_INFO csbi = {};
		GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);

		// Windows 10 Preview had a new bug in GetLargestConsoleWindowSize
		_ASSERTE((crMax.X > (csbi.srWindow.Right-csbi.srWindow.Left+1)) && (crMax.Y > (csbi.srWindow.Bottom-csbi.srWindow.Top+1)));
		//crMax.X = max(crMax.X,555);
		//crMax.Y = max(crMax.Y,555);
	}
	#endif

	return crMax;
}
Esempio n. 2
0
COORD WINAPI OnGetLargestConsoleWindowSize(HANDLE hConsoleOutput)
{
	//typedef COORD (WINAPI* OnGetLargestConsoleWindowSize_t)(HANDLE hConsoleOutput);
	ORIGINALFAST(GetLargestConsoleWindowSize);
	COORD cr = {80,25}, crLocked = {0,0};

	if (ghConEmuWndDC && IsVisibleRectLocked(crLocked))
	{
		cr = crLocked;
	}
	else
	{
		if (F(GetLargestConsoleWindowSize))
		{
			cr = F(GetLargestConsoleWindowSize)(hConsoleOutput);
		}

		// Wine BUG
		//if (!cr.X || !cr.Y)
		if ((cr.X == 80 && cr.Y == 24) && IsWine())
		{
			cr.X = 255;
			cr.Y = 255;
		}
	}

	return cr;
}
Esempio n. 3
0
// 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);
}
Esempio n. 4
0
UnicodeString GetPersonalFolder()
{
  UnicodeString Result;
  SpecialFolderLocation(CSIDL_PERSONAL, Result);

  if (IsWine())
  {
    UnicodeString WineHostHome;
    int Len = ::GetEnvironmentVariable(L"WINE_HOST_HOME", nullptr, 0);
    if (Len > 0)
    {
      WineHostHome.SetLength(Len - 1);
      ::GetEnvironmentVariable(L"WINE_HOST_HOME", const_cast<LPWSTR>(WineHostHome.c_str()), Len);
    }
    if (!WineHostHome.IsEmpty())
    {
      UnicodeString WineHome = L"Z:" + core::ToUnixPath(WineHostHome);
      if (::DirectoryExists(WineHome))
      {
        Result = WineHome;
      }
    }
    else
    {
      // Should we use WinAPI GetUserName() instead?
      UnicodeString UserName;
      int Len = ::GetEnvironmentVariable(L"USERNAME", nullptr, 0);
      if (Len > 0)
      {
        UserName.SetLength(Len - 1);
        ::GetEnvironmentVariable(L"USERNAME", const_cast<LPWSTR>(UserName.c_str()), Len);
      }
      if (!UserName.IsEmpty())
      {
        UnicodeString WineHome = L"Z:\\home\\" + UserName;
        if (::DirectoryExists(WineHome))
        {
          Result = WineHome;
        }
      }
    }
  }
  return Result;
}
char *platform_get_windows_runtime_os(void)
{
    int found = 0;
    int i;
    VGPI ViceGetProductInfo;
    VGNSI ViceGetNativeSystemInfo;
    SYSTEM_INFO systeminfo;
    DWORD PT;
    int sp;
    int exinfo_valid = 0;

    ZeroMemory(&os_version_info, sizeof(os_version_info));
    os_version_info.dwOSVersionInfoSize = sizeof(os_version_info);

    ZeroMemory(&os_version_ex_info, sizeof(os_version_ex_info));
    os_version_ex_info.dwOSVersionInfoSize = sizeof(os_version_ex_info);

    GetVersionEx(&os_version_info);

    windows_versions[0].platformid = (DWORD)os_version_info.dwPlatformId;
    windows_versions[0].majorver = (DWORD)os_version_info.dwMajorVersion;
    windows_versions[0].minorver = (DWORD)os_version_info.dwMinorVersion;
    windows_versions[0].realos = GetRealOS();

    if (windows_versions[0].platformid == VER_PLATFORM_WIN32_NT) {
        if (GetVersionEx(&os_version_ex_info)) {
            if (os_version_ex_info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
                windows_versions[0].producttype = (BYTE)VER_NT_SERVER;
            } else {
                windows_versions[0].producttype = (BYTE)os_version_ex_info.wProductType;
            }
            windows_versions[0].suite = (WORD)os_version_ex_info.wSuiteMask;
            exinfo_valid = 1;
        } else {
            switch (get_product_type_from_reg()) {
                case 0:
                default:
                    windows_versions[0].producttype = 0;
                    windows_versions[0].suite = 0;
                    break;
                case 1:
                    windows_versions[0].producttype = VER_NT_WORKSTATION;
                    windows_versions[0].suite = 0;
                    break;
                case 2:
                    windows_versions[0].producttype = VER_NT_SERVER;
                    windows_versions[0].suite = 0;
                    break;
                case 3:
                    windows_versions[0].producttype = VER_NT_SERVER;
                    windows_versions[0].suite = VER_SUITE_ENTERPRISE;
                    break;
                case 4:
                    windows_versions[0].producttype = VER_NT_SERVER;
                    windows_versions[0].suite = VER_SUITE_TERMINAL;
                    break;
                case 5:
                    windows_versions[0].producttype = VER_NT_SERVER;
                    windows_versions[0].suite = VER_SUITE_SMALLBUSINESS;
                    break;
            }
        }
        if (windows_versions[0].majorver >= 6) {
            ViceGetProductInfo = (VGPI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo");
            ViceGetProductInfo(os_version_ex_info.dwMajorVersion, os_version_ex_info.dwMinorVersion, 0, 0, &PT);
            windows_versions[0].pt6 = PT;
        } else {
            windows_versions[0].pt6 = -1;
        }
    } else {
		windows_versions[0].producttype = -1;
		windows_versions[0].suite = -1;
    }

/* Metrics: 0000RMST
   R: Windows Server 2003 R2			SM_SERVERR2
   M: Windows XP Media Center Edition		SM_MEDIACENTER
   S: Windows XP Starter Edition		SM_STARTER
   T: Windows XP Tablet PC Edition		SM_TABLETPC
*/
    windows_versions[0].metrics = 0;
    if (GetSystemMetrics(SM_TABLETPC)) {
        windows_versions[0].metrics |= 1;
    }
    if (GetSystemMetrics(SM_STARTER)) {
        windows_versions[0].metrics |= 2;
    }
    if (GetSystemMetrics(SM_MEDIACENTER)) {
        windows_versions[0].metrics |= 4;
    }
    if (GetSystemMetrics(SM_SERVERR2)) {
        windows_versions[0].metrics |= 8;
    }

    if (windows_versions[0].suite == (VER_SUITE_EMBEDDEDNT | VER_SUITE_SINGLEUSERTS)) {
        if (is_flp() == 0) {
            windows_versions[0].suite = VER_SUITE_EMBEDDEDNT;
        }
    }

    if (is_pe_builder() && windows_versions[0].majorver == 5 && windows_versions[0].minorver == 2) {
        windows_versions[0].producttype = VER_NT_SERVER;
    }

    if (is_cluster()) {
        windows_versions[0].suite |= VER_SUITE_COMPUTE_SERVER;
    }

    for (i = 1; found == 0 && windows_versions[i].name != NULL; i++) {
        if (windows_versions[0].platformid == windows_versions[i].platformid) {
            if (windows_versions[0].majorver == windows_versions[i].majorver) {
                if (windows_versions[0].minorver == windows_versions[i].minorver) {
                    if (windows_versions[0].realos > windows_versions[i].realos) {
                        windows_versions[0].producttype = -1;
                        windows_versions[0].suite = 0;
                        windows_versions[0].pt6 = 0;
                        windows_versions[0].metrics = 0;
                    }
                    if (windows_versions[0].producttype == windows_versions[i].producttype) {
                        if (optional_mask_compare(windows_versions[0].suite, windows_versions[i].suite)) {
                            if (optional_compare(windows_versions[0].pt6, windows_versions[i].pt6)) {
                                if (optional_mask_compare(windows_versions[0].metrics, windows_versions[i].metrics)) {
                                    found = 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    if (found) {
        sprintf(windows_version, "%s", windows_versions[i - 1].name);
        if (windows_versions[0].platformid == VER_PLATFORM_WIN32_WINDOWS) {
            if (windows_versions[0].minorver == 0) {
                sprintf(windows_version, "%s%s", windows_version, get_win95_version());
            }
            if (windows_versions[0].minorver == 10) {
                sprintf(windows_version, "%s%s", windows_version, get_win98_version());
            }
        } else {
            if (exinfo_valid) {
                sp = os_version_ex_info.wServicePackMajor;
            } else {
                sp = get_sp_from_reg();
            }
            if (sp) {
                if (sp == 6) {
                    if (sp_is_nt4_6a()) {
                        sprintf(windows_version, "%s SP6A", windows_version);
                    } else {
                        sprintf(windows_version, "%s SP6", windows_version);
                    }
                } else {
                    sprintf(windows_version, "%s SP%d", windows_version, sp);
                }
            }
        }
        if (is_pe_builder()) {
            sprintf(windows_version, "%s (PE)", windows_version);
        }
        if (windows_versions[0].realos > windows_versions[i - 1].realos) {
            sprintf(windows_version, "%s (compatibility mode)", windows_version);
        }
        if (IsWow64()) {
            ViceGetNativeSystemInfo = (VGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
            ViceGetNativeSystemInfo(&systeminfo);
            if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
                sprintf(windows_version, "%s (WOW64 X64)", windows_version);
            } else {
                sprintf(windows_version, "%s (WOW64 IA64)", windows_version);
            }
        } else {
            if (windows_versions[0].majorver >= 5) {
                GetSystemInfo(&systeminfo);
                if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
                    sprintf(windows_version, "%s (64bit IA64)", windows_version);
                } else if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
                    sprintf(windows_version, "%s (64bit X64)", windows_version);
                } else if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_MIPS) {
                    sprintf(windows_version, "%s (32bit MIPS)", windows_version);
                } else if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ALPHA) {
                    sprintf(windows_version, "%s (32bit AXP)", windows_version);
                } else if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ALPHA64) {
                    sprintf(windows_version, "%s (32bit AXP64)", windows_version);
                } else if (systeminfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_PPC) {
                    sprintf(windows_version, "%s (32bit PPC)", windows_version);
                } else {
                    sprintf(windows_version, "%s (32bit X86)", windows_version);
                }
            }
        }
        if (IsReactOS()) {
            sprintf(windows_version, "%s (ReactOS)", windows_version);
        }
        if (IsWine()) {
            sprintf(windows_version, "%s (Wine)", windows_version);
        }
        if (IsOdin32()) {
            sprintf(windows_version, "%s (Odin32)", windows_version);
        }
        if (IsHxDos()) {
            sprintf(windows_version, "%s (HXDOS)", windows_version);
        }
    } else {
        sprintf(windows_version, "%s (%d %d %d %d %d %d)", "Unknown Windows version",
                                                            windows_versions[0].platformid,
                                                            windows_versions[0].majorver,
                                                            windows_versions[0].minorver,
                                                            windows_versions[0].realos,
                                                            windows_versions[0].producttype,
                                                            windows_versions[0].suite);
    }
    return windows_version;
}