Пример #1
0
static inline uint32_t get_winver(void)
{
	if (!winver) {
		struct win_version_info ver;
		get_win_ver(&ver);
		winver = (ver.major << 16) | ver.minor;
	}

	return winver;
}
Пример #2
0
bool obs_module_load(void)
{
	struct win_version_info ver;
	bool win8_or_above = false;
	char *config_dir;

	config_dir = obs_module_config_path(NULL);
	if (config_dir) {
		os_mkdirs(config_dir);
		bfree(config_dir);
	}

	get_win_ver(&ver);

	win8_or_above = ver.major > 6 || (ver.major == 6 && ver.minor >= 2);

	obs_enter_graphics();

	if (win8_or_above && gs_get_device_type() == GS_DEVICE_DIRECT3D_11)
		obs_register_source(&duplicator_capture_info);
	else
		obs_register_source(&monitor_capture_info);

	obs_leave_graphics();

	obs_register_source(&window_capture_info);

	if (/*cached_versions_match() &&*/ load_cached_graphics_offsets(IS32BIT)) {
		load_cached_graphics_offsets(!IS32BIT);
		obs_register_source(&game_capture_info);

	} else if (load_graphics_offsets(IS32BIT)) {
		load_graphics_offsets(!IS32BIT);
		obs_register_source(&game_capture_info);
	}

	return true;
}
static inline void init_version_info(struct exception_handler_data *data)
{
	get_win_ver(&data->win_version);
}
int main()
#endif
{
#if defined(PRINT_INFO)
	const DWORD dwWinVer = get_win_ver();
	const BYTE  WinVerMaj = (BYTE)dwWinVer;
	const BYTE  WinVerMin = HIBYTE(LOWORD(dwWinVer));
#endif // PRINT_INFO

	DirComponents cd;
	char szTmp[512];

#ifndef COMPILE_AS_ROSTEST
	InitFunctionPointer();
#endif

	InitDirComponents(&cd);

#if defined(PRINT_INFO)
	printf("WinVer: %d.%d\n", WinVerMaj, WinVerMin);
	printf("pszLastCDComponent     \"%s\"\n", cd.pszLastCDComponent);
	printf("pszNextLastCDComponent \"%s\"\n", cd.pszNextLastCDComponent);
	printf("pszParentDir           \"%s\"\n", cd.pszPD);
	printf("pszParentDirPlusSlash  \"%s\"\n", cd.pszPDPlusSlash);
#endif

#define PREP0            /* The normal Win32 namespace. Fully parsed. */
#define PREP1 "\\\\.\\"  /* The Win32 Device Namespace. Only partially parsed. */
#define PREP2 "\\\\?\\"  /* The Win32 File Namespace. Only partially parsed. */

	//         input name        NtName              PartName
	// volume-absolute paths
	test(PREP1 "C:"            , "C:"              , "C:");
	test(PREP2 "C:"            , "C:"              , "C:");
	test(PREP0 "C:\\"          , "C:\\"            , NULL);
	test(PREP1 "C:\\"          , "C:\\"            , NULL);
	test(PREP2 "C:\\"          , "C:\\"            , NULL);
	test(PREP0 "C:\\foo"       , "C:\\foo"         , "foo");
	test(PREP1 "C:\\foo"       , "C:\\foo"         , "foo");
	test(PREP2 "C:\\foo"       , "C:\\foo"         , "foo");
	test(PREP0 "C:\\foo\\"     , "C:\\foo\\"       , NULL);
	test(PREP1 "C:\\foo\\"     , "C:\\foo\\"       , NULL);
	test(PREP2 "C:\\foo\\"     , "C:\\foo\\"       , NULL);
	test(PREP0 "C:\\foo\\bar"  , "C:\\foo\\bar"    , "bar");
	test(PREP1 "C:\\foo\\bar"  , "C:\\foo\\bar"    , "bar");
	test(PREP2 "C:\\foo\\bar"  , "C:\\foo\\bar"    , "bar");
	test(PREP0 "C:\\foo\\bar\\", "C:\\foo\\bar\\"  , NULL);
	test(PREP1 "C:\\foo\\bar\\", "C:\\foo\\bar\\"  , NULL);
	test(PREP2 "C:\\foo\\bar\\", "C:\\foo\\bar\\"  , NULL);
	test(PREP0 "C:\\foo\\.."   , "C:\\"            , NULL);
	test(PREP1 "C:\\foo\\.."   , "C:"              , "C:");
	test(PREP2 "C:\\foo\\.."   , "C:\\foo\\.."     , "..");
	test(PREP0 "C:\\foo\\..\\" , "C:\\"            , NULL);
	test(PREP1 "C:\\foo\\..\\" , "C:\\"            , NULL);
	test(PREP2 "C:\\foo\\..\\" , "C:\\foo\\..\\"   , NULL);
	test(PREP0 "C:\\foo."      , "C:\\foo"         , "foo");
	test(PREP1 "C:\\foo."      , "C:\\foo"         , "foo");
	test(PREP2 "C:\\foo."      , "C:\\foo."        , "foo.");

	test(PREP0 "C:\\f\\b\\.."  , "C:\\f"           , "f");
	test(PREP1 "C:\\f\\b\\.."  , "C:\\f"           , "f");
	test(PREP2 "C:\\f\\b\\.."  , "C:\\f\\b\\.."    , "..");
	test(PREP0 "C:\\f\\b\\..\\", "C:\\f\\"         , NULL);
	test(PREP1 "C:\\f\\b\\..\\", "C:\\f\\"         , NULL);
	test(PREP2 "C:\\f\\b\\..\\", "C:\\f\\b\\..\\"  , NULL);

	// CD-relative paths

	// RtlDosPathNameToNtPathName_U makes no distinction for
	// special device names, such as "PhysicalDisk0", "HarddiskVolume0"
	// or "Global??". They all follow the same pattern as a named
	// filesystem entry, why they implicitly tested by the following
	// "foo" and "foo\" cases.
	sprintf(szTmp, "%s%s", cd.szCDPlusSlash, "foo");
	test(PREP0 "foo"           , szTmp             , "foo");
	test(PREP1 "foo"           , "foo"             , "foo");
	test(PREP2 "foo"           , "foo"             , "foo");

	sprintf(szTmp, "%s%s", cd.szCDPlusSlash        , "foo\\");
	test(PREP0 "foo\\"         , szTmp             , NULL);
	test(PREP1 "foo\\"         , "foo\\"           , NULL);
	test(PREP2 "foo\\"         , "foo\\"           , NULL);

	test(PREP0 "."             , cd.szCD           , cd.pszLastCDComponent);
	test(PREP1 "."             , ""                , NULL);
	test(PREP2 "."             , "."               , ".");
	test(PREP0 ".\\"           , cd.szCDPlusSlash  , NULL);
	test(PREP1 ".\\"           , ""                , NULL);
	test(PREP2 ".\\"           , ".\\"             , NULL);
	test(PREP0 ".\\."          , cd.szCD           , cd.pszLastCDComponent);
	test(PREP1 ".\\."          , ""                , NULL);
	test(PREP2 ".\\."          , ".\\."            , ".");
	test(PREP0 ".\\.."         , cd.pszPD          , cd.pszNextLastCDComponent);
	test(PREP1 ".\\.."         , ""                , NULL);
	test(PREP2 ".\\.."         , ".\\.."           , "..");
	test(PREP0 ".."            , cd.pszPD          , cd.pszNextLastCDComponent);
	test(PREP1 ".."            , ""                , NULL);
	test(PREP2 ".."            , ".."              , "..");
	test(PREP0 "..\\"          , cd.pszPDPlusSlash , NULL);
	test(PREP1 "..\\"          , ""                , NULL);
	test(PREP2 "..\\"          , "..\\"            , NULL);
	// malformed
	test(PREP0 "..."           , cd.szCDPlusSlash  , NULL);
	test(PREP1 "..."           , ""                , NULL);
	test(PREP2 "..."           , "..."             , "...");

	// Test well-known "special" DOS device names.
	test(PREP0 "NUL"           , "NUL"             , NULL);
	test(PREP1 "NUL"           , "NUL"             , "NUL");
	test(PREP2 "NUL"           , "NUL"             , "NUL");
	test(PREP0 "NUL:"          , "NUL"             , NULL);
	test(PREP1 "NUL:"          , "NUL:"            , "NUL:");
	test(PREP2 "NUL:"          , "NUL:"            , "NUL:");
	test(PREP0 "CON"           , "CON"             , NULL);
	// NOTE: RtlDosPathNameToNtPathName_U (as currently tested) fails for
	// the input "\\.\CON" on two widely different Windows versions.
//	test(PREP1 "CON"           , "CON"             , "CON");
	test(PREP2 "CON"           , "CON"             , "CON");
	test(PREP0 "CON:"          , "CON"             , NULL);
	test(PREP1 "CON:"          , "CON:"            , "CON:");
	test(PREP2 "CON:"          , "CON:"            , "CON:");

	sprintf(szTmp, "%s\\%s", cd.szCD, "NUL:\\");
	test(PREP0 "NUL:\\"        , szTmp             , NULL);
	test(PREP1 "NUL:\\"        , "NUL:\\"          , NULL);
	test(PREP2 "NUL:\\"        , "NUL:\\"          , NULL);
	test(PREP0 "C:NUL"         , "NUL"             , NULL);
	test(PREP1 "C:NUL"         , "C:NUL"           , "C:NUL");
	test(PREP2 "C:NUL"         , "C:NUL"           , "C:NUL");
	test(PREP0 "C:\\NUL"       , "NUL"             , NULL);
	test(PREP1 "C:\\NUL"       , "C:\\NUL"         , "NUL");
	test(PREP2 "C:\\NUL"       , "C:\\NUL"         , "NUL");
	test(PREP0 "C:\\NUL\\"     , "C:\\NUL\\"       , NULL);
	test(PREP1 "C:\\NUL\\"     , "C:\\NUL\\"       , NULL);
	test(PREP2 "C:\\NUL\\"     , "C:\\NUL\\"       , NULL);

	// root-paths
	test(PREP0 "\\"            , cd.szCurDriveSlash, NULL);
	test(PREP1 "\\"            , ""                , NULL);
	test(PREP2 "\\"            , "\\"              , NULL);

	test(PREP0 "\\."           , cd.szCurDriveSlash, NULL);
	test(PREP1 "\\."           , ""                , NULL);
	test(PREP2 "\\."           , "\\."             , ".");

	test(PREP0 "\\.."          , cd.szCurDriveSlash, NULL);
	test(PREP1 "\\.."          , ""                , NULL);
	test(PREP2 "\\.."          , "\\.."            , "..");

	test(PREP0 "\\..."         , cd.szCurDriveSlash, NULL);
	test(PREP1 "\\..."         , ""                , NULL);
	test(PREP2 "\\..."         , "\\..."           , "...");

	// malformed
	sprintf(szTmp, "%s%s", cd.szCurDrive, "\\C:");
	test(PREP0 "\\C:"          , szTmp              , "C:");
	test(PREP1 "\\C:"          , "C:"               , "C:");
	test(PREP2 "\\C:"          , "\\C:"             , "C:");

	sprintf(szTmp, "%s%s", cd.szCurDrive, "\\C:\\");
	test(PREP0 "\\C:\\"        , szTmp             , NULL);
	test(PREP1 "\\C:\\"        , "C:\\"            , NULL);
	test(PREP2 "\\C:\\"        , "\\C:\\"          , NULL);

	// UNC paths
	test(PREP0 "\\\\"          , "UNC\\"           , NULL);
	test(PREP1 "\\\\"          , ""                , NULL);
	test(PREP2 "\\\\"          , "\\\\"            , NULL);
	test(PREP0 "\\\\\\"        , "UNC\\\\"         , NULL);
	test(PREP1 "\\\\\\"        , ""                , NULL);
	test(PREP2 "\\\\\\"        , "\\\\\\"          , NULL);
	test(PREP0 "\\\\foo"       , "UNC\\foo"        , NULL);
	test(PREP1 "\\\\foo"       , "foo"             , "foo");
	test(PREP2 "\\\\foo"       , "\\\\foo"         , "foo");

	test(PREP0 "\\\\foo\\.."   , "UNC\\foo\\"      , NULL);
	test(PREP1 "\\\\foo\\.."   , ""                , NULL);
	test(PREP2 "\\\\foo\\.."   , "\\\\foo\\.."     , "..");

	test(PREP0 "\\\\foo\\"     , "UNC\\foo\\"      , NULL);
	test(PREP1 "\\\\foo\\"     , "foo\\"           , NULL);
	test(PREP2 "\\\\foo\\"     , "\\\\foo\\"       , NULL);
	test(PREP0 "\\\\f\\b"      , "UNC\\f\\b"       , NULL);
	test(PREP1 "\\\\f\\b"      , "f\\b"            , "b");
	test(PREP2 "\\\\f\\b"      , "\\\\f\\b"        , "b");
	test(PREP0 "\\\\f\\b\\"    , "UNC\\f\\b\\"     , NULL);
	test(PREP1 "\\\\f\\b\\"    , "f\\b\\"          , NULL);
	test(PREP2 "\\\\f\\b\\"    , "\\\\f\\b\\"      , NULL);

	test(PREP0 "\\\\f\\b\\.."  , "UNC\\f\\b"       , NULL);
	test(PREP1 "\\\\f\\b\\.."  , "f"               , "f");
	test(PREP2 "\\\\f\\b\\.."  , "\\\\f\\b\\.."    , "..");

	// strange UNC-paths
	test(PREP0 "\\\\C:"        , "UNC\\C:"         , NULL);
	test(PREP1 "\\\\C:"        , "C:"              , "C:");
	test(PREP2 "\\\\C:"        , "\\\\C:"          , "C:");
	test(PREP0 "\\\\C:\\"      , "UNC\\C:\\"       , NULL);
	test(PREP1 "\\\\C:\\"      , "C:\\"            , NULL);
	test(PREP2 "\\\\C:\\"      , "\\\\C:\\"        , NULL);
	test(PREP0 "\\\\NUL"       , "UNC\\NUL"        , NULL);
	test(PREP1 "\\\\NUL"       , "NUL"             , "NUL");
	test(PREP2 "\\\\NUL"       , "\\\\NUL"         , "NUL");
	test(PREP0 "\\\\NUL:"      , "UNC\\NUL:"       , NULL);
	test(PREP1 "\\\\NUL:"      , "NUL:"            , "NUL:");
	test(PREP2 "\\\\NUL:"      , "\\\\NUL:"        , "NUL:");
	test(PREP0 "\\\\NUL:\\"    , "UNC\\NUL:\\"     , NULL);
	test(PREP1 "\\\\NUL:\\"    , "NUL:\\"          , NULL);
	test(PREP2 "\\\\NUL:\\"    , "\\\\NUL:\\"      , NULL);

	// UNC + forward slashes
	test(PREP0 "//"            , "UNC\\"           , NULL);
	test(PREP1 "//"            , ""                , NULL);
	test(PREP2 "//"            , "//"              , "//");
	test(PREP0 "//C:"          , "UNC\\C:"         , NULL);
	test(PREP1 "//C:"          , "C:"              , "C:");
	test(PREP2 "//C:"          , "//C:"            , "//C:");
	test(PREP0 "//C:/"         , "UNC\\C:\\"       , NULL);
	test(PREP1 "//C:/"         , "C:\\"            , NULL);
	test(PREP2 "//C:/"         , "//C:/"           , "//C:/");
	test(PREP0 "//."           , ""                , NULL);
	test(PREP1 "//."           , ""                , NULL);
	test(PREP2 "//."           , "//."             , "//.");
	test(PREP0 "//.."          , "UNC\\"           , NULL);
	test(PREP1 "//.."          , ""                , NULL);
	test(PREP2 "//.."          , "//.."            , "//..");
	test(PREP0 "/./"           , cd.szCurDriveSlash, NULL);
	test(PREP1 "/./"           , ""                , NULL);
	test(PREP2 "/./"           , "/./"             , "/./");
	test(PREP0 "//./"          , ""                , NULL);
	test(PREP1 "//./"          , ""                , NULL);
	test(PREP2 "//./"          , "//./"            , "//./");

	test(cd.szCD               , cd.szCD           , cd.pszLastCDComponent);
	test(cd.szCDPlusSlash      , cd.szCDPlusSlash  , NULL);

#if 0
	// The following tests are "problematic", as they return results based on
	// what your CD on C: is, whether or not you actually run the program
	// from C:. For that reason, they are currently disabled.
	test(PREP0 "C:"            , "C:\\"+C_curdir         , C_curdir);
	test(PREP0 "C:NUL\\"       , "C:\\"+C_curdir+"\\NUL\\" , NULL);
#endif

#if 0 // Disabled due to... see the comment inside the block.
	{
		char szExp[32];
		BOOL bValid = FALSE;
		char szPrepend[32];
		szPrepend[0] = 0;
		// Strictly speaking, this "Should Never Happen(tm)", calling
		// RtlDosPathNameToNtPathName_U with a source already formed as
		// a full NT name ("\??\"), why it's not the end of the world
		// that this test is currently disabled.
		//
		// Some versions of Windows prepends driveletter + colon
		// for the process' current volume.
		// Prepending curdrive is most likely a bug that got fixed in
		// later versions of Windows, but for compatibility it may
		// become a requirement to "shim" this.
		//
		// Known operating systems prepending "Z:\??\" (assuming the
		// process' CD is on the volume Z:):
		// - XP sp2.
		//
		// Known operating systems not prepending:
		// - Win7 64 (as 32-bit)
		if (WinVerMaj == 5) {
			sprintf(szPrepend, "%s\\??\\", cd.szCurDrive);
		}

		sprintf(szExp, "%s%s", szPrepend, "C:");
		test("\\??\\C:", szExp, "C:");

		sprintf(szExp, "%s%s", szPrepend, "C:\\");
		test("\\??\\C:\\", szExp, NULL);

}
#endif

#ifndef COMPILE_AS_ROSTEST
	return 0;
#endif
}