vlc: do not load kernel32.dll
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 18 Nov 2016 18:10:25 +0000 (20:10 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 18 Nov 2016 18:14:43 +0000 (20:14 +0200)
vlc.exe already depends on kernel32.dll, so there is no need to load it
explicitly. It can simply be looked up.

bin/winvlc.c

index 327ae07..dfe8878 100644 (file)
@@ -102,8 +102,8 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
 
     /* SetProcessDEPPolicy */
-    HINSTANCE h_Kernel32 = LoadLibraryW(L"kernel32.dll");
-    if(h_Kernel32)
+    HINSTANCE h_Kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
+    if (h_Kernel32 != NULL)
     {
         BOOL (WINAPI * mySetProcessDEPPolicy)( DWORD dwFlags);
         BOOL (WINAPI * mySetDllDirectoryA)(const char* lpPathName);
@@ -119,8 +119,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                             GetProcAddress(h_Kernel32, "SetDllDirectoryA");
         if(mySetDllDirectoryA)
             mySetDllDirectoryA("");
-
-        FreeLibrary(h_Kernel32);
     }
 
     SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);