+
+
+/* Pointers to functions that are not available on all targetted versions of
+ * Windows (XP and later). NOTE: The WINAPI annotations seem to be important; I
+ * assume it specifies a certain calling convention. */
+
+/* Vista and later */
+static HANDLE (WINAPI *win32func_FindFirstStreamW)(LPCWSTR lpFileName,
+ STREAM_INFO_LEVELS InfoLevel,
+ LPVOID lpFindStreamData,
+ DWORD dwFlags) = NULL;
+
+/* Vista and later */
+static BOOL (WINAPI *win32func_FindNextStreamW)(HANDLE hFindStream,
+ LPVOID lpFindStreamData) = NULL;
+
+/* Try to dynamically load some functions */
+void
+win32_global_init()
+{
+ DWORD err;
+ bool warned;
+
+ DEBUG("Loading Kernel32.dll");
+
+ HMODULE lib = LoadLibraryA("Kernel32.dll");
+ if (lib == NULL) {
+ err = GetLastError();
+ WARNING("Can't load Kernel32.dll");
+ win32_error(err);
+ return;
+ }
+
+ DEBUG("Looking for FindFirstStreamW");
+ win32func_FindFirstStreamW = (void*)GetProcAddress(lib, "FindFirstStreamW");
+ if (!win32func_FindFirstStreamW) {
+ WARNING("Could not find function FindFirstStreamW() in Kernel32.dll!");
+ WARNING("Capturing alternate data streams will not be supported.");
+ goto out_free_lib;
+ }
+
+ DEBUG("Looking for FindNextStreamW");
+ win32func_FindNextStreamW = (void*)GetProcAddress(lib, "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;
+ }
+out_free_lib:
+ DEBUG("Closing Kernel32.dll");
+ FreeLibrary(lib);
+}
+