Windows 95 (OSR2)/98/ME no longer see drive free space capped to 2GB.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3507 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2004-03-06 12:31:26 +00:00
parent e90fe421d6
commit ca9582c925
5 changed files with 54 additions and 39 deletions

View file

@ -97,9 +97,9 @@ static void NSISCALL EnableNext(BOOL e)
EnableWindow(m_hwndOK, e); EnableWindow(m_hwndOK, e);
} }
static void NSISCALL SetActiveCtl(HWND hDlg, HWND hCtl) static void NSISCALL SetActiveCtl(HWND hCtl)
{ {
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM) hCtl, TRUE); SendMessage(g_hwnd, WM_NEXTDLGCTL, (WPARAM) hCtl, TRUE);
} }
static void NSISCALL NotifyCurWnd(UINT uNotifyCode) static void NSISCALL NotifyCurWnd(UINT uNotifyCode)
@ -276,19 +276,20 @@ __forceinline int NSISCALL ui_doinstall(void)
#ifdef NSIS_SUPPORT_BGBG #ifdef NSIS_SUPPORT_BGBG
if (header->bg_color1 != -1) if (header->bg_color1 != -1)
{ {
DWORD cn = CHAR4_TO_DWORD('_', 'N', 'b', 0);
RECT vp; RECT vp;
extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM);
wc.lpfnWndProc = BG_WndProc; wc.lpfnWndProc = BG_WndProc;
wc.hInstance = g_hInstance; wc.hInstance = g_hInstance;
wc.hIcon = g_hIcon; wc.hIcon = g_hIcon;
//wc.hCursor = LoadCursor(NULL,IDC_ARROW); //wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.lpszClassName = "_Nb"; wc.lpszClassName = (LPCSTR)&cn;
if (!RegisterClass(&wc)) return 0; if (!RegisterClass(&wc)) return 0;
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);
m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,"_Nb",0,WS_POPUP, m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,(LPCSTR)&cn,0,WS_POPUP,
vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL);
} }
@ -491,11 +492,11 @@ nextPage:
if (g_exec_flags.abort) if (g_exec_flags.abort)
{ {
SendMessage(hwndDlg, DM_SETDEFID, IDCANCEL, 0); SendMessage(hwndDlg, DM_SETDEFID, IDCANCEL, 0);
SetActiveCtl(hwndDlg, m_hwndCancel); SetActiveCtl(m_hwndCancel);
} }
else else
{ {
SetActiveCtl(hwndDlg, m_hwndOK); SetActiveCtl(m_hwndOK);
} }
mystrcpy(g_tmp,g_caption); mystrcpy(g_tmp,g_caption);
@ -677,7 +678,7 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
EnableNext(selected); EnableNext(selected);
hwLicense=GetUIItem(IDC_EDIT1); hwLicense=GetUIItem(IDC_EDIT1);
SetActiveCtl(hwndDlg, hwLicense); SetActiveCtl(hwLicense);
SendMessage(hwLicense,EM_AUTOURLDETECT,TRUE,0); SendMessage(hwLicense,EM_AUTOURLDETECT,TRUE,0);
#define lbg g_header->license_bg #define lbg g_header->license_bg
SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,lbg>=0?lbg:GetSysColor(-lbg)); SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,lbg>=0?lbg:GetSysColor(-lbg));
@ -768,19 +769,16 @@ static char * NSISCALL inttosizestr(int kb, char *str)
{ {
char scalestr[32], byte[32]; char scalestr[32], byte[32];
char sh=20; char sh=20;
char s=0;
int scale=LANG_GIGA; int scale=LANG_GIGA;
if (kb < 1024) { sh=0; scale=LANG_KILO; } if (kb < 1024) { sh=0; scale=LANG_KILO; }
else if (kb < 1024*1024) { sh=10; scale=LANG_MEGA; } else if (kb < 1024*1024) { sh=10; scale=LANG_MEGA; }
else if (GetVersion()&0x80000000) s='+';//only display the + on GB shown on win9x.
wsprintf( wsprintf(
str+mystrlen(str), str+mystrlen(str),
"%d.%d%s%s%c", "%d.%d%s%s",
kb>>sh, kb>>sh,
((kb*10)>>sh)%10, ((kb*10)>>sh)%10,
GetNSISString(scalestr,scale), GetNSISString(scalestr,scale),
GetNSISString(byte,LANG_BYTE), GetNSISString(byte,LANG_BYTE)
s
); );
return str; return str;
} }
@ -833,7 +831,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
SetUITextNT(IDC_DIR,dir); SetUITextNT(IDC_DIR,dir);
SetUITextFromLang(IDC_BROWSE,this_page->parms[2]); SetUITextFromLang(IDC_BROWSE,this_page->parms[2]);
SetUITextFromLang(IDC_SELDIRTEXT,this_page->parms[1]); SetUITextFromLang(IDC_SELDIRTEXT,this_page->parms[1]);
SetActiveCtl(hwndDlg, GetUIItem(IDC_DIR)); SetActiveCtl(GetUIItem(IDC_DIR));
} }
if (uMsg == WM_COMMAND) if (uMsg == WM_COMMAND)
{ {
@ -880,7 +878,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
char *p; char *p;
int error = 0; int error = 0;
int total, available=-1; int total, available=-1;
DWORD spc,bps,fc,tc; HMODULE hLib;
GetUIText(IDC_DIR,dir); GetUIText(IDC_DIR,dir);
if (!is_valid_instpath(dir)) if (!is_valid_instpath(dir))
@ -891,11 +889,27 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (p) if (p)
*p=0; *p=0;
if (GetDiskFreeSpace(s,&spc,&bps,&fc,&tc)) // Test for and use the GetDiskFreeSpaceEx API
hLib = GetModuleHandle("KERNEL32.dll");
if (hLib)
{ {
DWORD r=MulDiv(bps*spc,fc,1<<10); BOOL (WINAPI *GDFSE)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
if (r > 0x7fffffff) r=0x7fffffff; (void*)GetProcAddress(hLib, "GetDiskFreeSpaceExA");
available=(int)r; if (GDFSE)
{
ULARGE_INTEGER available64;
if (GDFSE(s, &available64, NULL, NULL))
available = (int)(available64.QuadPart >> 10);
}
}
if (available == -1)
{
// GetDiskFreeSpaceEx is not available
DWORD spc, bps, fc, tc;
if (GetDiskFreeSpace(s, &spc, &bps, &fc, &tc))
available = (int)MulDiv(bps * spc, fc, 1 << 10);
} }
total = sumsecsfield(size_kb); total = sumsecsfield(size_kb);
@ -905,7 +919,8 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (LANG_STR_TAB(LANG_SPACE_REQ)) { if (LANG_STR_TAB(LANG_SPACE_REQ)) {
SetUITextNT(IDC_SPACEREQUIRED,inttosizestr(total,GetNSISString(s,LANG_SPACE_REQ))); SetUITextNT(IDC_SPACEREQUIRED,inttosizestr(total,GetNSISString(s,LANG_SPACE_REQ)));
if (available != -1) // Did we get a usable value above?
if (available >= 0)
SetUITextNT(IDC_SPACEAVAILABLE,inttosizestr(available,GetNSISString(s,LANG_SPACE_AVAIL))); SetUITextNT(IDC_SPACEAVAILABLE,inttosizestr(available,GetNSISString(s,LANG_SPACE_AVAIL)));
else else
SetUITextNT(IDC_SPACEAVAILABLE,""); SetUITextNT(IDC_SPACEAVAILABLE,"");
@ -1204,10 +1219,10 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (!noCombo) if (!noCombo)
{ {
ShowWindow(hwndCombo1, SW_SHOW); ShowWindow(hwndCombo1, SW_SHOW);
SetActiveCtl(hwndDlg, hwndCombo1); SetActiveCtl(hwndCombo1);
} }
else else
SetActiveCtl(hwndDlg, hwndTree1); SetActiveCtl(hwndTree1);
uMsg = g_exec_flags.insttype_changed ? WM_NOTIFY_INSTTYPE_CHANGE : WM_IN_UPDATEMSG; uMsg = g_exec_flags.insttype_changed ? WM_NOTIFY_INSTTYPE_CHANGE : WM_IN_UPDATEMSG;
} }

View file

@ -1068,7 +1068,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
} }
g_exec_flags.exec_error++; g_exec_flags.exec_error++;
{ {
HANDLE h=LoadLibrary("advapi32.dll"); HANDLE h=LoadLibrary("ADVAPI32.dll");
if (h) if (h)
{ {
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE); BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
@ -1089,6 +1089,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
} }
} }
FreeLibrary(h);
} }
if (ExitWindowsEx(EWX_REBOOT,0)) if (ExitWindowsEx(EWX_REBOOT,0))
@ -1097,8 +1098,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
PostQuitMessage(0); PostQuitMessage(0);
return EXEC_ERROR; return EXEC_ERROR;
} }
FreeLibrary(h);
} }
break; break;
#endif//NSIS_SUPPORT_REBOOT #endif//NSIS_SUPPORT_REBOOT
@ -1129,13 +1128,13 @@ static int NSISCALL ExecuteEntry(entry *entry_)
break; break;
case EW_READINISTR: case EW_READINISTR:
{ {
const char *errstr="!N~"; DWORD errstr = CHAR4_TO_DWORD('!', 'N', '~', 0);
char *p=var0; char *p=var0;
char *buf0=GetStringFromParm(0x01); char *buf0=GetStringFromParm(0x01);
char *buf1=GetStringFromParm(0x12); char *buf1=GetStringFromParm(0x12);
char *buf2=GetStringFromParm(-0x23); char *buf2=GetStringFromParm(-0x23);
GetPrivateProfileString(buf0,buf1,errstr,p,NSIS_MAX_STRLEN-1,buf2); GetPrivateProfileString(buf0,buf1,(LPCSTR)&errstr,p,NSIS_MAX_STRLEN-1,buf2);
if (*((int*)errstr) == *((int*)p)) if (*(DWORD*)p == errstr)
{ {
exec_error++; exec_error++;
p[0]=0; p[0]=0;

View file

@ -4,14 +4,14 @@
// generic startup strings (these will never be overridable) // generic startup strings (these will never be overridable)
#ifdef NSIS_CONFIG_CRC_SUPPORT #ifdef NSIS_CONFIG_CRC_SUPPORT
#define _LANG_INVALIDCRC "The installer you are trying to use is corrupted or incomplete.\r\n" \ #define _LANG_INVALIDCRC "The installer you are trying to use is corrupted or incomplete.\n" \
"This could be the result of a damaged disk, a failed download or a virus.\r\n\r\n" \ "This could be the result of a damaged disk, a failed download or a virus.\n\n" \
"You may want to contact the author of this installer to obtain a new copy.\r\n\r\n" \ "You may want to contact the author of this installer to obtain a new copy.\n\n" \
"It may be possible to skip this check using the /NCRC command line switch\r\n" \ "It may be possible to skip this check using the /NCRC command line switch\n" \
"(NOT RECOMMENDED)." "(NOT RECOMMENDED)."
#else #else
#define _LANG_INVALIDCRC "The installer you are trying to use is corrupted or incomplete.\r\n" \ #define _LANG_INVALIDCRC "The installer you are trying to use is corrupted or incomplete.\n" \
"This could be the result of a damaged disk, a failed download or a virus.\r\n\r\n" \ "This could be the result of a damaged disk, a failed download or a virus.\n\n" \
"You may want to contact the author of this installer to obtain a new copy." "You may want to contact the author of this installer to obtain a new copy."
#endif #endif

View file

@ -61,13 +61,14 @@ HANDLE NSISCALL myCreateProcess(char *cmd, char *dir)
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val) BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val)
{ {
return SetDlgItemText(dlg,idx,val); return SetDlgItemText(dlg,idx,val);
//return my_SetWindowText(GetDlgItem(dlg,idx),val); // return my_SetWindowText(GetDlgItem(dlg, idx), val);
} }
int NSISCALL my_GetDialogItemText(UINT idx, char *val) int NSISCALL my_GetDialogItemText(UINT idx, char *val)
{ {
extern HWND m_curwnd; extern HWND m_curwnd;
return GetDlgItemText(m_curwnd, idx, val, NSIS_MAX_STRLEN); return GetDlgItemText(m_curwnd, idx, val, NSIS_MAX_STRLEN);
// return my_GetWindowText(GetDlgItem(m_curwnd, idx), val, NSIS_MAX_STRLEN);
} }
int NSISCALL my_MessageBox(const char *text, UINT type) { int NSISCALL my_MessageBox(const char *text, UINT type) {
@ -188,7 +189,7 @@ int NSISCALL is_valid_instpath(char *s)
{ {
static char tmp[NSIS_MAX_STRLEN]; static char tmp[NSIS_MAX_STRLEN];
char *root; char *root;
mystrcpy(tmp, s); mystrcpy(tmp, s);
root = skip_root(tmp); root = skip_root(tmp);
@ -280,7 +281,7 @@ char * NSISCALL my_GetTempFileName(char *buf, const char *dir)
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
{ {
BOOL fOk = 0; BOOL fOk = 0;
HMODULE hLib=GetModuleHandle("kernel32.dll"); HMODULE hLib=GetModuleHandle("KERNEL32.dll");
if (hLib) if (hLib)
{ {
typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags); typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags);
@ -304,7 +305,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
int spn; int spn;
*((int *)tmpbuf) = *((int *)"NUL"); *(DWORD*)tmpbuf = CHAR4_TO_DWORD('N', 'U', 'L', 0);
if (pszNew) { if (pszNew) {
// create the file if it's not already there to prevent GetShortPathName from failing // create the file if it's not already there to prevent GetShortPathName from failing

View file

@ -367,7 +367,7 @@ int inflate(z_streamp z)
static uIntf c[288]; /* length list for huft_build */ static uIntf c[288]; /* length list for huft_build */
/* literal table */ /* literal table */
for (_k = 0; _k < 288; _k++) for (_k = 0; _k < 288; _k++)
{ {
char v=8; char v=8;
if (_k > 143) if (_k > 143)
@ -491,7 +491,7 @@ int inflate(z_streamp z)
if (c == 18) if (c == 18)
{ {
i=7; i=7;
j=11; j=11;
} }
else else
{ {