+/*
+ * win32_common.c - Windows code common to applying and capturing images, as
+ * well as replacements for various functions not available on Windows, such as
+ * fsync().
+ */
+
+/*
+ * Copyright (C) 2013 Eric Biggers
+ *
+ * This file is part of wimlib, a library for working with WIM files.
+ *
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ */
+
#ifdef __WIN32__
#include <shlwapi.h> /* for PathMatchSpecW() */
BOOL (WINAPI *win32func_FindNextStreamW)(HANDLE hFindStream,
LPVOID lpFindStreamData) = NULL;
+static OSVERSIONINFO windows_version_info = {
+ .dwOSVersionInfoSize = sizeof(OSVERSIONINFO),
+};
+
static HMODULE hKernel32 = NULL;
+bool
+windows_version_is_at_least(unsigned major, unsigned minor)
+{
+ return windows_version_info.dwMajorVersion > major ||
+ (windows_version_info.dwMajorVersion == major &&
+ windows_version_info.dwMinorVersion >= minor);
+}
+
/* Try to dynamically load some functions */
void
win32_global_init()
err = GetLastError();
WARNING("Can't load Kernel32.dll");
win32_error(err);
- return;
}
}
- DEBUG("Looking for FindFirstStreamW");
- win32func_FindFirstStreamW = (void*)GetProcAddress(hKernel32, "FindFirstStreamW");
- if (!win32func_FindFirstStreamW) {
- WARNING("Could not find function FindFirstStreamW() in Kernel32.dll!");
- WARNING("Capturing alternate data streams will not be supported.");
- return;
+ if (hKernel32) {
+ win32func_FindFirstStreamW = (void*)GetProcAddress(hKernel32,
+ "FindFirstStreamW");
+ if (win32func_FindFirstStreamW) {
+ win32func_FindNextStreamW = (void*)GetProcAddress(hKernel32,
+ "FindNextStreamW");
+ if (!win32func_FindNextStreamW)
+ win32func_FindFirstStreamW = NULL;
+ }
}
- DEBUG("Looking for FindNextStreamW");
- win32func_FindNextStreamW = (void*)GetProcAddress(hKernel32, "FindNextStreamW");
- if (!win32func_FindNextStreamW) {
- WARNING("Could not find function FindNextStreamW() in Kernel32.dll!");
- WARNING("Capturing alternate data streams will not be supported.");
- win32func_FindFirstStreamW = NULL;
- }
+ GetVersionEx(&windows_version_info);
}
void