2002-11-24 18:50:31 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include "../exdll/exdll.h"
|
|
|
|
#include "../../Source/exehead/resource.h"
|
|
|
|
|
2003-01-27 15:44:13 +00:00
|
|
|
// Turn a pair of chars into a word
|
|
|
|
// Turn four chars into a dword
|
|
|
|
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
|
|
|
#define CHAR2_TO_WORD(a,b) (((WORD)(b))|((a)<<8))
|
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16))
|
|
|
|
#else
|
|
|
|
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
|
|
|
#endif
|
|
|
|
|
2002-11-24 18:50:31 +00:00
|
|
|
HINSTANCE hInstance;
|
|
|
|
HWND hwBanner;
|
2003-09-12 16:45:22 +00:00
|
|
|
HANDLE hThread;
|
2004-10-01 13:14:13 +00:00
|
|
|
BOOL bFailed;
|
2002-11-24 18:50:31 +00:00
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
|
2003-01-27 15:44:13 +00:00
|
|
|
unsigned int myatoi(char *s);
|
|
|
|
|
2003-09-12 16:45:22 +00:00
|
|
|
BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2002-11-24 18:50:31 +00:00
|
|
|
{
|
|
|
|
if (uMsg == WM_INITDIALOG)
|
|
|
|
{
|
2003-09-12 16:45:22 +00:00
|
|
|
int iMainStringSet = 0;
|
|
|
|
|
2002-11-24 18:50:31 +00:00
|
|
|
popstring(buf);
|
2003-09-12 16:45:22 +00:00
|
|
|
while (*(int*)buf == CHAR4_TO_DWORD('/','s','e','t') && !buf[4])
|
|
|
|
{
|
2003-01-27 15:44:13 +00:00
|
|
|
unsigned int id;
|
|
|
|
popstring(buf);
|
|
|
|
id = myatoi(buf);
|
|
|
|
popstring(buf);
|
2003-09-12 16:45:22 +00:00
|
|
|
SetDlgItemText(hwndDlg, id, buf);
|
2003-01-27 15:44:13 +00:00
|
|
|
popstring(buf);
|
2003-09-12 16:45:22 +00:00
|
|
|
|
|
|
|
if (id == IDC_STR)
|
|
|
|
iMainStringSet++;
|
2003-01-27 15:44:13 +00:00
|
|
|
}
|
2003-09-12 16:45:22 +00:00
|
|
|
|
|
|
|
SetWindowText(hwndDlg, buf);
|
|
|
|
if (!iMainStringSet)
|
|
|
|
SetDlgItemText(hwndDlg, IDC_STR, buf);
|
|
|
|
|
|
|
|
if (!*buf)
|
|
|
|
SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
|
|
|
|
}
|
|
|
|
if (uMsg == WM_CLOSE)
|
|
|
|
{
|
|
|
|
DestroyWindow(hwndDlg);
|
2002-11-24 18:50:31 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-09-12 16:45:22 +00:00
|
|
|
DWORD WINAPI BannerThread(LPVOID lpParameter)
|
2002-11-24 18:50:31 +00:00
|
|
|
{
|
2003-09-12 16:45:22 +00:00
|
|
|
HWND hwndParent = (HWND) lpParameter;
|
|
|
|
HWND lhwBanner;
|
|
|
|
MSG msg;
|
2002-11-24 18:50:31 +00:00
|
|
|
|
2003-09-12 16:45:22 +00:00
|
|
|
lhwBanner = CreateDialog(
|
2002-11-24 18:50:31 +00:00
|
|
|
GetModuleHandle(0),
|
|
|
|
MAKEINTRESOURCE(IDD_VERIFY),
|
2003-09-05 19:26:45 +00:00
|
|
|
hwndParent,
|
2003-09-12 16:45:22 +00:00
|
|
|
BannerProc
|
2002-11-24 18:50:31 +00:00
|
|
|
);
|
2004-10-01 13:14:13 +00:00
|
|
|
if (!lhwBanner)
|
|
|
|
{
|
|
|
|
bFailed = TRUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetForegroundWindow(lhwBanner);
|
2003-09-12 16:45:22 +00:00
|
|
|
|
|
|
|
while (IsWindow(lhwBanner))
|
|
|
|
{
|
|
|
|
if (PeekMessage(&msg, lhwBanner, 0, 0, PM_REMOVE))
|
|
|
|
{
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hwBanner = lhwBanner;
|
|
|
|
WaitMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hwBanner = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
|
|
|
{
|
|
|
|
EXDLL_INIT();
|
|
|
|
|
|
|
|
{
|
|
|
|
DWORD dwThreadId;
|
|
|
|
|
|
|
|
hwBanner = NULL;
|
|
|
|
|
2004-10-01 13:14:13 +00:00
|
|
|
if (!IsWindowVisible(hwndParent))
|
|
|
|
hwndParent = 0;
|
|
|
|
|
|
|
|
bFailed = FALSE;
|
|
|
|
|
2003-09-12 16:45:22 +00:00
|
|
|
hThread = CreateThread(0, 0, BannerThread, (LPVOID) hwndParent, 0, &dwThreadId);
|
|
|
|
|
|
|
|
// wait for the window to initalize and for the stack operations to finish
|
2004-10-01 13:14:13 +00:00
|
|
|
while (hThread && !hwBanner && !bFailed)
|
2003-09-12 16:45:22 +00:00
|
|
|
{
|
|
|
|
Sleep(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hThread);
|
|
|
|
|
|
|
|
ShowWindow(hwBanner, SW_SHOW);
|
|
|
|
}
|
2002-11-24 18:50:31 +00:00
|
|
|
}
|
|
|
|
|
2004-06-17 17:54:48 +00:00
|
|
|
void __declspec(dllexport) getWindow(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
|
|
|
{
|
|
|
|
wsprintf(buf, "%u", hwBanner);
|
|
|
|
pushstring(buf);
|
|
|
|
}
|
|
|
|
|
2002-11-24 18:50:31 +00:00
|
|
|
void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
|
|
|
{
|
2003-09-12 16:45:22 +00:00
|
|
|
if (!hwBanner)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PostMessage(hwBanner, WM_CLOSE, 0, 0);
|
|
|
|
|
|
|
|
if (!hwndParent)
|
|
|
|
{
|
2004-10-01 13:14:13 +00:00
|
|
|
// reset the thread that called banner::Show to be the foreground thread.
|
|
|
|
// if banner was called from .onInit, this will make sure the NSIS dialog
|
|
|
|
// will still be created on the foreground
|
2003-09-12 16:45:22 +00:00
|
|
|
HWND hwTemp;
|
|
|
|
|
|
|
|
hwTemp = CreateWindowEx(
|
|
|
|
WS_EX_TOOLWINDOW,
|
|
|
|
"STATIC",
|
|
|
|
"",
|
|
|
|
WS_VISIBLE | WS_POPUP,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
hInstance,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
SetForegroundWindow(hwTemp);
|
|
|
|
DestroyWindow(hwTemp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for the thread to finish
|
|
|
|
while (hwBanner)
|
|
|
|
Sleep(25);
|
2002-11-24 18:50:31 +00:00
|
|
|
}
|
|
|
|
|
2003-11-12 20:24:53 +00:00
|
|
|
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
2002-11-24 18:50:31 +00:00
|
|
|
{
|
2003-09-12 16:45:22 +00:00
|
|
|
hInstance = hInst;
|
|
|
|
if (hwBanner && ul_reason_for_call == DLL_PROCESS_DETACH)
|
|
|
|
{
|
|
|
|
destroy(0, 0, 0, 0);
|
|
|
|
}
|
2002-11-24 18:50:31 +00:00
|
|
|
return TRUE;
|
2003-01-27 15:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int myatoi(char *s)
|
|
|
|
{
|
|
|
|
unsigned int v=0;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
unsigned int c=*s++;
|
|
|
|
if (c >= '0' && c <= '9') c-='0';
|
|
|
|
else break;
|
|
|
|
v*=10;
|
|
|
|
v+=c;
|
|
|
|
}
|
|
|
|
return v;
|
2002-11-24 18:50:31 +00:00
|
|
|
}
|