[vlc-commits] win32: do not load wininet.dll on startup, it's not a Known DLL
Steve Lhomme
git at videolan.org
Fri Mar 10 19:05:21 CET 2017
vlc/vlc-2.2 | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Fri Mar 10 14:20:00 2017 +0100| [52e4b740ad47574bdff7b80aba4949311e1b88f1] | committer: Jean-Baptiste Kempf
win32: do not load wininet.dll on startup, it's not a Known DLL
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 681866b760332b41948e663b696fe4547133e537)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=52e4b740ad47574bdff7b80aba4949311e1b88f1
---
bin/Makefile.am | 2 +-
bin/winvlc.c | 36 +++++++++++++++++++++++++++++++-----
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/bin/Makefile.am b/bin/Makefile.am
index dbb72ca..869ac56 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,7 +48,7 @@ vlc_static_LDADD = $(vlc_LDADD)
vlc_static_LDFLAGS = $(vlc_LDFLAGS)
if HAVE_WIN32
-vlc_LDADD += -lpsapi -lwininet vlc_win32_rc.$(OBJEXT)
+vlc_LDADD += -lpsapi vlc_win32_rc.$(OBJEXT)
vlc_DEPENDENCIES = vlc_win32_rc.$(OBJEXT)
else
vlc_LDADD += $(LIBDL)
diff --git a/bin/winvlc.c b/bin/winvlc.c
index 0fe050b..6644ab3 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.c
@@ -245,11 +245,34 @@ static void check_crashdump(void)
if(answer == IDYES)
{
- HINTERNET Hint = InternetOpen(L"VLC Crash Reporter",
+ HMODULE hWininet = LoadLibrary(TEXT("wininet.dll"));
+ if (hWininet == NULL)
+ {
+ fprintf(stderr, "There was an error loading the network"
+ " 0x%08lx\n", (unsigned long)GetLastError());
+ goto done;
+ }
+
+ HINTERNET (WINAPI *InternetOpenW_)(LPCWSTR ,DWORD dwAccessType,LPCWSTR lpszProxy,LPCWSTR lpszProxyBypass,DWORD dwFlags);
+ HINTERNET (WINAPI *InternetConnectW_)(HINTERNET hInternet,LPCWSTR lpszServerName,INTERNET_PORT nServerPort,LPCWSTR lpszUserName,LPCWSTR lpszPassword,DWORD dwService,DWORD dwFlags,DWORD_PTR dwContext);
+ BOOL (WINAPI *InternetCloseHandle_)(HINTERNET hInternet);
+ BOOL (WINAPI *FtpPutFileW_)(HINTERNET hConnect,LPCWSTR lpszLocalFile,LPCWSTR lpszNewRemoteFile,DWORD dwFlags,DWORD_PTR dwContext);
+ InternetOpenW_ = (void*)GetProcAddress(hWininet, "InternetOpenW");
+ InternetConnectW_ = (void*)GetProcAddress(hWininet, "InternetConnectW");
+ InternetCloseHandle_ = (void*)GetProcAddress(hWininet, "InternetCloseHandle");
+ FtpPutFileW_ = (void*)GetProcAddress(hWininet, "FtpPutFileW");
+ if (!InternetOpenW_ || !InternetConnectW_ || !InternetCloseHandle_ || !FtpPutFileW_)
+ {
+ fprintf(stderr, "There was an error loading the network API entries"
+ " 0x%08lx\n", (unsigned long)GetLastError());
+ goto done;
+ }
+
+ HINTERNET Hint = InternetOpenW_(L"VLC Crash Reporter",
INTERNET_OPEN_TYPE_PRECONFIG, NULL,NULL,0);
if(Hint)
{
- HINTERNET ftp = InternetConnect(Hint, L"crash.videolan.org",
+ HINTERNET ftp = InternetConnectW_(Hint, L"crash.videolan.org",
INTERNET_DEFAULT_FTP_PORT, NULL, NULL,
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
if(ftp)
@@ -262,7 +285,7 @@ static void check_crashdump(void)
now.wYear, now.wMonth, now.wDay, now.wHour,
now.wMinute, now.wSecond );
- if( FtpPutFile( ftp, mv_crashdump_path, remote_file,
+ if( FtpPutFileW_( ftp, mv_crashdump_path, remote_file,
FTP_TRANSFER_TYPE_BINARY, 0) )
fprintf(stderr, "Report sent correctly to FTP.\n");
else
@@ -270,7 +293,7 @@ static void check_crashdump(void)
"transferring the data to the FTP server.\n"\
"Thanks a lot for the help.",
L"Report sending failed", MB_OK);
- InternetCloseHandle(ftp);
+ InternetCloseHandle_(ftp);
}
else
{
@@ -281,7 +304,7 @@ static void check_crashdump(void)
fprintf(stderr,"Can't connect to FTP server 0x%08lu\n",
(unsigned long)GetLastError());
}
- InternetCloseHandle(Hint);
+ InternetCloseHandle_(Hint);
}
else
{
@@ -289,6 +312,9 @@ static void check_crashdump(void)
"Thanks a lot for the help anyway.",
L"Report sending failed", MB_OK);
}
+done:
+ if (hWininet != NULL)
+ FreeLibrary(hWininet);
MessageBox( NULL, L"Thanks a lot for helping improving VLC!",
L"VLC crash report" , MB_OK);
}
More information about the vlc-commits
mailing list