manually use LoadLibrary and GetProcAddress instead of /DELAYLOAD

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3962 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2005-04-16 16:37:07 +00:00
parent f0fbbb390a
commit 0a717481f2

View file

@ -4,57 +4,123 @@
#include "../ExDLL/exdll.h"
#define NSISFunction(funcname) void __declspec(dllexport) funcname(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
HMODULE hWinInet;
#define NSISFunction(funcname) void __declspec(dllexport) funcname(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
return TRUE;
}
/*************\
* LOADER *
\*************/
HMODULE hWinInet = NULL;
FARPROC GetWinInetFunc(char *func) {
hWinInet = LoadLibrary("wininet.dll");
if (hWinInet)
return GetProcAddress(hWinInet, func);
return NULL;
}
void FreeWinInet() {
if (hWinInet)
FreeLibrary(hWinInet);
hWinInet = NULL;
}
/*************\
* FUNCTIONS *
\*************/
NSISFunction(AutodialOnline) {
typedef BOOL (WINAPI *fInternetAutodial)(DWORD, HWND);
fInternetAutodial pInternetAutodial = (fInternetAutodial) GetWinInetFunc("InternetAutodial");
if (!pInternetAutodial) {
extra->exec_flags->exec_error++;
return;
}
EXDLL_INIT();
if (InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0))
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0))
pushstring("online");
else
pushstring("offline");
FreeWinInet();
}
NSISFunction(AutodialUnattended) {
typedef BOOL (WINAPI *fInternetAutodial)(DWORD, HWND);
fInternetAutodial pInternetAutodial = (fInternetAutodial) GetWinInetFunc("InternetAutodial");
if (!pInternetAutodial) {
extra->exec_flags->exec_error++;
return;
}
EXDLL_INIT();
if (InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED , 0))
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED , 0))
pushstring("online");
else
pushstring("offline");
FreeWinInet();
}
NSISFunction(AttemptConnect) {
EXDLL_INIT();
if (InternetAttemptConnect(0) == ERROR_SUCCESS)
typedef DWORD (WINAPI *fAttemptConn)(DWORD);
fAttemptConn pInternetAttemptConnect = (fAttemptConn) GetWinInetFunc("InternetAttemptConnect");
if (!pInternetAttemptConnect) {
extra->exec_flags->exec_error++;
return;
}
EXDLL_INIT();
if (pInternetAttemptConnect(0) == ERROR_SUCCESS)
pushstring("online");
else
pushstring("offline");
FreeWinInet();
}
NSISFunction(GetConnectedState) {
DWORD dwState;
typedef BOOL (WINAPI *fGetConState)(LPDWORD, DWORD);
fGetConState pInternetGetConnectedState = (fGetConState) GetWinInetFunc("InternetGetConnectedState");
if (!pInternetGetConnectedState) {
extra->exec_flags->exec_error++;
return;
}
EXDLL_INIT();
if (InternetGetConnectedState(&dwState, 0))
if (pInternetGetConnectedState(&dwState, 0))
pushstring("online");
else
pushstring("offline");
FreeWinInet();
}
NSISFunction(AutodialHangup) {
typedef BOOL (WINAPI *fAutodial)(DWORD);
fAutodial pInternetAutodialHangup = (fAutodial) GetWinInetFunc("InternetAutodialHangup");
if (!pInternetAutodialHangup) {
extra->exec_flags->exec_error++;
return;
}
EXDLL_INIT();
if (InternetAutodialHangup(0))
if (pInternetAutodialHangup(0))
pushstring("success");
else
pushstring("failure");
FreeWinInet();
}