2004-01-30 22:04:10 +00:00
|
|
|
#include "../Platform.h"
|
2002-12-03 20:33:17 +00:00
|
|
|
#include <shellapi.h>
|
2002-08-02 10:01:35 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "state.h"
|
|
|
|
#include "config.h"
|
2002-08-08 15:04:45 +00:00
|
|
|
#include "lang.h"
|
2002-08-02 10:01:35 +00:00
|
|
|
#include "fileform.h"
|
2004-03-29 20:21:00 +00:00
|
|
|
#include "exec.h"
|
2002-08-02 10:01:35 +00:00
|
|
|
#include "ui.h"
|
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_LOG
|
2003-11-24 14:22:50 +00:00
|
|
|
#ifndef NSIS_CONFIG_LOG_ODS
|
2002-08-02 10:01:35 +00:00
|
|
|
char g_log_file[1024];
|
|
|
|
#endif
|
2003-11-24 14:22:50 +00:00
|
|
|
#endif
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2003-12-22 00:28:30 +00:00
|
|
|
// *** DO NOT DECLARE MORE VARIABLES INSIDE THIS PRAGMAS ***
|
|
|
|
// This will produce a special section called ".ndata" (stands for nsis data)
|
|
|
|
// this way makensis during build time, can search for this section by name
|
|
|
|
// and change the virtual size of this section
|
|
|
|
// which result in extra memory for extra variables without code to do allocation :)
|
|
|
|
// nsis then removes the "DISCARDABLE" style from section (for safe)
|
2004-03-12 20:43:54 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma bss_seg(VARS_SECTION_NAME)
|
2004-01-04 17:05:03 +00:00
|
|
|
NSIS_STRING g_usrvars[1];
|
2004-03-12 20:43:54 +00:00
|
|
|
# pragma bss_seg()
|
|
|
|
# pragma comment(linker, "/section:" VARS_SECTION_NAME ",rwd")
|
|
|
|
#else
|
|
|
|
# ifdef __GNUC__
|
|
|
|
NSIS_STRING g_usrvars[1] __attribute__((section (VARS_SECTION_NAME)));
|
|
|
|
# else
|
|
|
|
# error Unknown compiler. You must implement the seperate PE section yourself.
|
|
|
|
# endif
|
|
|
|
#endif
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2004-02-06 22:37:46 +00:00
|
|
|
void NSISCALL FreePIDL(LPITEMIDLIST idl)
|
2003-12-22 00:28:30 +00:00
|
|
|
{
|
|
|
|
IMalloc *m;
|
|
|
|
SHGetMalloc(&m);
|
2003-12-22 18:50:47 +00:00
|
|
|
if (m)
|
2003-12-22 00:28:30 +00:00
|
|
|
{
|
2003-12-22 18:50:47 +00:00
|
|
|
m->lpVtbl->Free(m, idl);
|
2003-12-22 00:28:30 +00:00
|
|
|
m->lpVtbl->Release(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
HANDLE NSISCALL myCreateProcess(char *cmd, char *dir)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-11-22 15:46:33 +00:00
|
|
|
DWORD d;
|
2004-01-04 17:05:03 +00:00
|
|
|
PROCESS_INFORMATION ProcInfo;
|
|
|
|
static STARTUPINFO StartUp;
|
|
|
|
StartUp.cb=sizeof(StartUp);
|
2002-11-22 15:46:33 +00:00
|
|
|
d=GetFileAttributes(dir);
|
2004-01-04 17:05:03 +00:00
|
|
|
if (d == INVALID_FILE_ATTRIBUTES || !(d&FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
dir=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, dir, &StartUp, &ProcInfo))
|
|
|
|
return NULL;
|
2003-03-30 15:08:24 +00:00
|
|
|
CloseHandle(ProcInfo.hThread);
|
2002-08-02 10:01:35 +00:00
|
|
|
return ProcInfo.hProcess;
|
|
|
|
}
|
|
|
|
|
2003-12-29 14:27:33 +00:00
|
|
|
/*BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val)
|
2002-12-02 23:08:10 +00:00
|
|
|
{
|
|
|
|
return SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)val);
|
2003-12-29 14:27:33 +00:00
|
|
|
}*/
|
2002-12-02 23:08:10 +00:00
|
|
|
|
2002-09-21 02:34:34 +00:00
|
|
|
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val)
|
|
|
|
{
|
2003-02-07 23:04:25 +00:00
|
|
|
return SetDlgItemText(dlg,idx,val);
|
2004-03-06 12:31:26 +00:00
|
|
|
// return my_SetWindowText(GetDlgItem(dlg, idx), val);
|
2002-12-02 23:08:10 +00:00
|
|
|
}
|
|
|
|
|
2004-01-04 17:05:03 +00:00
|
|
|
int NSISCALL my_GetDialogItemText(UINT idx, char *val)
|
2002-12-02 23:08:10 +00:00
|
|
|
{
|
2004-01-04 17:05:03 +00:00
|
|
|
extern HWND m_curwnd;
|
|
|
|
return GetDlgItemText(m_curwnd, idx, val, NSIS_MAX_STRLEN);
|
2004-03-06 12:31:26 +00:00
|
|
|
// return my_GetWindowText(GetDlgItem(m_curwnd, idx), val, NSIS_MAX_STRLEN);
|
2002-12-02 23:08:10 +00:00
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL my_MessageBox(const char *text, UINT type) {
|
2004-01-04 17:05:03 +00:00
|
|
|
int _type = type & 0x000FFFFF;
|
2004-01-29 01:23:24 +00:00
|
|
|
#ifdef NSIS_CONFIG_SILENT_SUPPORT
|
2003-11-25 17:07:40 +00:00
|
|
|
// default for silent installers
|
|
|
|
if (g_exec_flags.silent && type >> 20)
|
|
|
|
return type >> 20;
|
2004-01-29 01:23:24 +00:00
|
|
|
#endif
|
2003-11-25 17:07:40 +00:00
|
|
|
// no silent or no default, just show
|
2004-01-04 17:05:03 +00:00
|
|
|
if (g_exec_flags.rtl)
|
|
|
|
_type ^= MB_RIGHT | MB_RTLREADING;
|
|
|
|
return MessageBox(g_hwnd, text, g_caption, _type);
|
2002-08-09 14:21:45 +00:00
|
|
|
}
|
|
|
|
|
2002-09-07 20:49:18 +00:00
|
|
|
void * NSISCALL my_GlobalAlloc(DWORD dwBytes) {
|
2002-08-31 10:26:39 +00:00
|
|
|
return (void *)GlobalAlloc(GPTR, dwBytes);
|
|
|
|
}
|
|
|
|
|
2004-08-06 17:03:07 +00:00
|
|
|
void NSISCALL myDelete(char *buf, int flags)
|
2002-08-08 15:04:45 +00:00
|
|
|
{
|
2004-08-06 17:03:07 +00:00
|
|
|
static char lbuf[NSIS_MAX_STRLEN];
|
|
|
|
|
|
|
|
HANDLE h;
|
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
char *fn;
|
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
if (!(flags & DEL_DIR) || (is_valid_instpath(buf) && (flags & DEL_RECURSE)))
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
2002-08-08 15:04:45 +00:00
|
|
|
{
|
2004-08-06 17:03:07 +00:00
|
|
|
mystrcpy(lbuf,buf);
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
if (flags & DEL_DIR)
|
|
|
|
lstrcat(lbuf,"\\*.*");
|
|
|
|
else
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
|
|
|
trimslashtoend(buf);
|
2002-12-03 20:33:17 +00:00
|
|
|
|
2004-08-06 17:03:07 +00:00
|
|
|
lstrcat(buf,"\\");
|
2002-12-03 20:33:17 +00:00
|
|
|
|
2004-08-06 17:03:07 +00:00
|
|
|
fn=buf+mystrlen(buf);
|
2002-12-03 20:33:17 +00:00
|
|
|
|
2004-08-06 17:03:07 +00:00
|
|
|
h = FindFirstFile(lbuf,&fd);
|
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
if (fd.cFileName[0] != '.' ||
|
|
|
|
(fd.cFileName[1] != '.' && fd.cFileName[1]))
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
|
|
|
{
|
|
|
|
mystrcpy(fn,fd.cFileName);
|
|
|
|
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
2004-08-14 17:35:05 +00:00
|
|
|
if ((flags & (DEL_DIR | DEL_RECURSE)) == (DEL_DIR | DEL_RECURSE))
|
2004-08-06 17:03:07 +00:00
|
|
|
{
|
|
|
|
myDelete(buf,flags);
|
|
|
|
}
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
log_printf2("Delete: DeleteFile(\"%s\")",buf);
|
|
|
|
SetFileAttributes(buf,fd.dwFileAttributes&(~FILE_ATTRIBUTE_READONLY));
|
|
|
|
if (!DeleteFile(buf))
|
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
|
|
|
if (flags & DEL_REBOOT)
|
|
|
|
{
|
|
|
|
log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf);
|
|
|
|
update_status_text(LANG_DELETEONREBOOT,buf);
|
|
|
|
MoveFileOnReboot(buf,NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
|
|
|
{
|
|
|
|
log_printf2("Delete: DeleteFile failed(\"%s\")",buf);
|
|
|
|
g_exec_flags.exec_error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
update_status_text(LANG_DELETEFILE,buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (FindNextFile(h,&fd));
|
|
|
|
FindClose(h);
|
2002-08-08 15:04:45 +00:00
|
|
|
}
|
2004-08-06 17:03:07 +00:00
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
if (flags & DEL_DIR)
|
|
|
|
fn[-1]=0;
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
if (flags & DEL_DIR)
|
|
|
|
{
|
|
|
|
addtrailingslash(buf);
|
|
|
|
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
|
|
|
|
if (!RemoveDirectory(buf))
|
|
|
|
{
|
2003-03-29 11:45:22 +00:00
|
|
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
2004-08-06 17:03:07 +00:00
|
|
|
if (flags & DEL_REBOOT)
|
|
|
|
{
|
|
|
|
log_printf2("RMDir: RemoveDirectory on Reboot(\"%s\")",buf);
|
|
|
|
update_status_text(LANG_DELETEONREBOOT,buf);
|
|
|
|
MoveFileOnReboot(buf,NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
|
|
|
{
|
|
|
|
log_printf2("RMDir: RemoveDirectory failed(\"%s\")",buf);
|
|
|
|
g_exec_flags.exec_error++;
|
|
|
|
}
|
2003-03-29 11:45:22 +00:00
|
|
|
}
|
2004-08-06 17:03:07 +00:00
|
|
|
else
|
|
|
|
update_status_text(LANG_REMOVEDIR,buf);
|
2002-08-08 15:04:45 +00:00
|
|
|
}
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
2004-08-06 17:03:07 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-25 02:13:38 +00:00
|
|
|
char *NSISCALL addtrailingslash(char *str)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
if (lastchar(str)!='\\') lstrcat(str,"\\");
|
2002-09-25 02:13:38 +00:00
|
|
|
return str;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-20 18:47:58 +00:00
|
|
|
/*char NSISCALL lastchar(const char *str)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
return *CharPrev(str,str+mystrlen(str));
|
2003-02-20 18:47:58 +00:00
|
|
|
}*/
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2004-02-04 20:03:30 +00:00
|
|
|
char * NSISCALL findchar(char *str, char c)
|
|
|
|
{
|
|
|
|
while (*str && *str != c)
|
|
|
|
{
|
|
|
|
str = CharNext(str);
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
void NSISCALL trimslashtoend(char *buf)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-11-25 17:07:40 +00:00
|
|
|
char *p = buf + mystrlen(buf);
|
2003-09-23 19:01:19 +00:00
|
|
|
do
|
2003-07-12 15:19:49 +00:00
|
|
|
{
|
2003-09-23 19:01:19 +00:00
|
|
|
if (*p == '\\')
|
|
|
|
break;
|
|
|
|
p = CharPrev(buf, p);
|
|
|
|
} while (p > buf);
|
2003-09-28 12:14:10 +00:00
|
|
|
|
2003-09-23 19:01:19 +00:00
|
|
|
*p = 0;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL validpathspec(char *ubuf)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-11-28 17:57:59 +00:00
|
|
|
char dl = ubuf[0] | 0x20; // convert alleged drive letter to lower case
|
2004-03-12 20:43:54 +00:00
|
|
|
return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (dl >= 'a' && dl <= 'z' && ubuf[1]==':'));
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 19:01:19 +00:00
|
|
|
char * NSISCALL skip_root(char *path)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-23 19:01:19 +00:00
|
|
|
char *p = CharNext(path);
|
|
|
|
char *p2 = CharNext(p);
|
|
|
|
|
|
|
|
if (*path && *(WORD*)p == CHAR2_TO_WORD(':', '\\'))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-23 19:01:19 +00:00
|
|
|
return CharNext(p2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2003-09-23 19:01:19 +00:00
|
|
|
else if (*(WORD*)path == CHAR2_TO_WORD('\\','\\'))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-23 19:01:19 +00:00
|
|
|
// skip host and share name
|
|
|
|
int x = 2;
|
|
|
|
while (x--)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-02-04 20:03:30 +00:00
|
|
|
p2 = findchar(p2, '\\');
|
|
|
|
if (!*p2)
|
|
|
|
return NULL;
|
2004-03-12 20:43:54 +00:00
|
|
|
p2++; // skip backslash
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2003-09-23 19:01:19 +00:00
|
|
|
|
|
|
|
return p2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int NSISCALL is_valid_instpath(char *s)
|
|
|
|
{
|
2003-11-14 21:08:51 +00:00
|
|
|
static char tmp[NSIS_MAX_STRLEN];
|
|
|
|
char *root;
|
2004-03-06 12:31:26 +00:00
|
|
|
|
2003-11-14 21:08:51 +00:00
|
|
|
mystrcpy(tmp, s);
|
|
|
|
|
|
|
|
root = skip_root(tmp);
|
|
|
|
|
|
|
|
if (!root)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((g_flags & CH_FLAGS_NO_ROOT_DIR) && (!*root || *root == '\\'))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (mystrlen(tmp) > root - tmp)
|
2003-09-23 19:01:19 +00:00
|
|
|
{
|
2003-11-14 21:08:51 +00:00
|
|
|
WIN32_FIND_DATA *fd = file_exists(tmp);
|
|
|
|
// if the directory bit not set then it's a file, which is not a valid inst dir...
|
|
|
|
// GetFileAttributes is not used because it doesn't work with certain files (error 32)
|
2004-04-09 12:47:33 +00:00
|
|
|
// as for concerns of the user using * or ?, that's invalid anyway...
|
2003-11-14 21:08:51 +00:00
|
|
|
if (fd && !(fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
return 0;
|
|
|
|
trimslashtoend(tmp);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2003-11-14 21:08:51 +00:00
|
|
|
|
|
|
|
// if the root drive exists
|
2004-04-09 12:47:33 +00:00
|
|
|
addtrailingslash(tmp); // don't check the current directory, check the root directory
|
2004-01-30 23:51:31 +00:00
|
|
|
if (GetFileAttributes(tmp) == INVALID_FILE_ATTRIBUTES)
|
2003-11-14 21:08:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 23:51:31 +00:00
|
|
|
char * NSISCALL mystrstri(char *a, char *b)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
int l = mystrlen(b);
|
|
|
|
while (mystrlen(a) >= l)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
char c = a[l];
|
|
|
|
a[l] = 0;
|
|
|
|
if (!lstrcmpi(a, b))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
a[l] = c;
|
|
|
|
return a;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2004-01-30 23:51:31 +00:00
|
|
|
a[l] = c;
|
|
|
|
a = CharNext(a);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-05-08 16:07:22 +00:00
|
|
|
void NSISCALL mini_memcpy(void *out, const void *in, int len)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
char *c_out=(char*)out;
|
|
|
|
char *c_in=(char *)in;
|
|
|
|
while (len-- > 0)
|
|
|
|
{
|
|
|
|
*c_out++=*c_in++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-09 14:25:16 +00:00
|
|
|
int attr = GetFileAttributes(fn);
|
|
|
|
return CreateFile(
|
|
|
|
fn,
|
|
|
|
da,
|
|
|
|
FILE_SHARE_READ,
|
|
|
|
NULL,
|
|
|
|
cd,
|
|
|
|
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
|
|
|
|
NULL
|
|
|
|
);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2003-07-18 14:22:17 +00:00
|
|
|
char * NSISCALL my_GetTempFileName(char *buf, const char *dir)
|
|
|
|
{
|
|
|
|
int n = 100;
|
|
|
|
while (n--)
|
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
char prefix[4];
|
|
|
|
*(LPDWORD)prefix = CHAR4_TO_DWORD('n', 's', 'a', 0);
|
2003-11-28 17:57:59 +00:00
|
|
|
prefix[2] += (char)(GetTickCount() % 26);
|
2003-07-18 14:22:17 +00:00
|
|
|
if (GetTempFileName(dir, prefix, 0, buf))
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
*buf = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
2003-09-09 14:25:16 +00:00
|
|
|
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
BOOL fOk = 0;
|
2004-03-06 12:31:26 +00:00
|
|
|
HMODULE hLib=GetModuleHandle("KERNEL32.dll");
|
2002-08-02 10:01:35 +00:00
|
|
|
if (hLib)
|
|
|
|
{
|
|
|
|
typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags);
|
|
|
|
mfea_t mfea;
|
|
|
|
mfea=(mfea_t) GetProcAddress(hLib,"MoveFileExA");
|
|
|
|
if (mfea)
|
|
|
|
{
|
|
|
|
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fOk)
|
|
|
|
{
|
|
|
|
static char szRenameLine[1024];
|
|
|
|
static char wininit[1024];
|
|
|
|
static char tmpbuf[1024];
|
|
|
|
int cchRenameLine;
|
|
|
|
char *szRenameSec = "[Rename]\r\n";
|
|
|
|
HANDLE hfile, hfilemap;
|
|
|
|
DWORD dwFileSize, dwRenameLinePos;
|
2003-03-29 17:16:09 +00:00
|
|
|
|
2003-12-18 19:19:19 +00:00
|
|
|
int spn;
|
|
|
|
|
2004-03-06 12:31:26 +00:00
|
|
|
*(DWORD*)tmpbuf = CHAR4_TO_DWORD('N', 'U', 'L', 0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-12-10 17:19:57 +00:00
|
|
|
if (pszNew) {
|
|
|
|
// create the file if it's not already there to prevent GetShortPathName from failing
|
2003-09-04 18:25:57 +00:00
|
|
|
CloseHandle(myOpenFile(pszNew,0,CREATE_NEW));
|
2003-12-18 19:19:19 +00:00
|
|
|
spn = GetShortPathName(pszNew,tmpbuf,1024);
|
|
|
|
if (!spn || spn > 1024)
|
|
|
|
return;
|
2002-12-10 17:19:57 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
// wininit is used as a temporary here
|
2003-12-18 19:19:19 +00:00
|
|
|
spn = GetShortPathName(pszExisting,wininit,1024);
|
|
|
|
if (!spn || spn > 1024)
|
|
|
|
return;
|
2002-08-02 10:01:35 +00:00
|
|
|
cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit);
|
2002-08-11 18:56:30 +00:00
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
GetWindowsDirectory(wininit, 1024-16);
|
|
|
|
lstrcat(wininit, "\\wininit.ini");
|
2002-08-11 18:56:30 +00:00
|
|
|
hfile = CreateFile(wininit,
|
|
|
|
GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
|
2002-08-02 10:01:35 +00:00
|
|
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
|
|
|
|
2002-08-11 18:56:30 +00:00
|
|
|
if (hfile != INVALID_HANDLE_VALUE)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
dwFileSize = GetFileSize(hfile, NULL);
|
|
|
|
hfilemap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, 0, dwFileSize + cchRenameLine + 10, NULL);
|
|
|
|
|
2002-08-11 18:56:30 +00:00
|
|
|
if (hfilemap != NULL)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
LPSTR pszWinInit = (LPSTR) MapViewOfFile(hfilemap, FILE_MAP_WRITE, 0, 0, 0);
|
|
|
|
|
2002-08-11 18:56:30 +00:00
|
|
|
if (pszWinInit != NULL)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
LPSTR pszRenameSecInFile = mystrstri(pszWinInit, szRenameSec);
|
2002-08-11 18:56:30 +00:00
|
|
|
if (pszRenameSecInFile == NULL)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
mystrcpy(pszWinInit+dwFileSize, szRenameSec);
|
2002-08-02 10:01:35 +00:00
|
|
|
dwFileSize += 10;
|
|
|
|
dwRenameLinePos = dwFileSize;
|
2002-08-11 18:56:30 +00:00
|
|
|
}
|
|
|
|
else
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-04 05:40:02 +00:00
|
|
|
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
2004-01-30 23:51:31 +00:00
|
|
|
char *pszNextSec = mystrstri(pszFirstRenameLine,"\n[");
|
2002-09-04 05:40:02 +00:00
|
|
|
if (pszNextSec)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-04 18:25:57 +00:00
|
|
|
char *p = ++pszNextSec;
|
|
|
|
while (p < pszWinInit + dwFileSize) {
|
|
|
|
p[cchRenameLine] = *p;
|
|
|
|
p++;
|
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-04 05:40:02 +00:00
|
|
|
dwRenameLinePos = pszNextSec - pszWinInit;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-04 05:40:02 +00:00
|
|
|
// rename section is last, stick item at end of file
|
|
|
|
else dwRenameLinePos = dwFileSize;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2003-09-09 14:25:16 +00:00
|
|
|
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
|
2002-09-04 05:40:02 +00:00
|
|
|
dwFileSize += cchRenameLine;
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
UnmapViewOfFile(pszWinInit);
|
|
|
|
|
2003-09-09 14:25:16 +00:00
|
|
|
//fOk++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
CloseHandle(hfilemap);
|
|
|
|
}
|
|
|
|
SetFilePointer(hfile, dwFileSize, NULL, FILE_BEGIN);
|
|
|
|
SetEndOfFile(hfile);
|
|
|
|
CloseHandle(hfile);
|
|
|
|
}
|
|
|
|
}
|
2003-09-09 14:25:16 +00:00
|
|
|
//return fOk;
|
2003-12-18 19:19:19 +00:00
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_REBOOT
|
|
|
|
g_exec_flags.exec_reboot++;
|
|
|
|
#endif
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-07-12 15:19:49 +00:00
|
|
|
HKEY hKey;
|
2002-08-02 10:01:35 +00:00
|
|
|
*out=0;
|
|
|
|
if (RegOpenKeyEx(root,sub,0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
2003-07-12 15:19:49 +00:00
|
|
|
DWORD l = NSIS_MAX_STRLEN;
|
|
|
|
DWORD t;
|
2003-05-09 12:25:32 +00:00
|
|
|
if (RegQueryValueEx(hKey,name,NULL,&t,out,&l ) != ERROR_SUCCESS || (t != REG_SZ && t != REG_EXPAND_SZ)) *out=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
out[NSIS_MAX_STRLEN-1]=0;
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-04 18:25:57 +00:00
|
|
|
void NSISCALL myitoa(char *s, int d)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-04 18:25:57 +00:00
|
|
|
wsprintf(s,"%d",d);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL myatoi(char *s)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
unsigned int v=0;
|
2003-03-28 18:41:15 +00:00
|
|
|
int sign=1; // sign of positive
|
2002-09-25 02:36:30 +00:00
|
|
|
char m=10; // base of 0
|
|
|
|
char t='9'; // cap top of numbers at 9
|
|
|
|
|
2003-09-28 12:14:10 +00:00
|
|
|
if (*s == '-')
|
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
s++; //skip over -
|
2003-03-28 18:41:15 +00:00
|
|
|
sign=-1; // sign flip
|
2002-09-25 02:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*s == '0')
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
s++; // skip over 0
|
|
|
|
if (s[0] >= '0' && s[0] <= '7')
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
m=8; // base of 8
|
|
|
|
t='7'; // cap top at 7
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2003-11-28 17:57:59 +00:00
|
|
|
if ((s[0] & ~0x20) == 'X')
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
m=16; // base of 16
|
|
|
|
s++; // advance over 'x'
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-25 02:36:30 +00:00
|
|
|
|
|
|
|
for (;;)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
int c=*s++;
|
|
|
|
if (c >= '0' && c <= t) c-='0';
|
|
|
|
else if (m==16 && (c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') c = (c & 7) + 9;
|
|
|
|
else break;
|
|
|
|
v*=m;
|
|
|
|
v+=c;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2003-03-28 18:41:15 +00:00
|
|
|
return ((int)v)*sign;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2002-08-19 21:24:44 +00:00
|
|
|
// Straight copies of selected shell functions. Calling local functions
|
|
|
|
// requires less code than DLL functions. For the savings to outweigh the cost
|
|
|
|
// of a new function there should be about a couple of dozen or so calls.
|
2002-08-19 23:18:19 +00:00
|
|
|
char * NSISCALL mystrcpy(char *out, const char *in)
|
2002-08-19 21:24:44 +00:00
|
|
|
{
|
|
|
|
return lstrcpy(out, in);
|
|
|
|
}
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL mystrlen(const char *in)
|
2002-08-19 21:24:44 +00:00
|
|
|
{
|
|
|
|
return lstrlen(in);
|
|
|
|
}
|
|
|
|
|
2003-09-04 18:25:57 +00:00
|
|
|
char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
|
|
|
|
2003-12-22 18:50:47 +00:00
|
|
|
#define SYSREGKEY "Software\\Microsoft\\Windows\\CurrentVersion"
|
|
|
|
|
2003-09-04 18:25:57 +00:00
|
|
|
// Based on Dave Laundon's simplified process_string
|
|
|
|
char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2003-09-04 18:25:57 +00:00
|
|
|
char *in = (char*)GetNSISStringNP(GetNSISTab(strtab));
|
2003-12-22 18:50:47 +00:00
|
|
|
char *out = ps_tmpbuf;
|
|
|
|
if ((unsigned int) (outbuf - ps_tmpbuf) < sizeof(ps_tmpbuf))
|
2003-09-04 18:25:57 +00:00
|
|
|
{
|
|
|
|
out = outbuf;
|
|
|
|
outbuf = 0;
|
|
|
|
}
|
2003-02-07 23:04:25 +00:00
|
|
|
while (*in && out - ps_tmpbuf < NSIS_MAX_STRLEN)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2004-01-04 17:05:03 +00:00
|
|
|
unsigned char nVarIdx = (unsigned char)*in++;
|
|
|
|
int nData;
|
|
|
|
int fldrs[4];
|
2004-03-12 20:43:54 +00:00
|
|
|
if (nVarIdx > NS_CODES_START)
|
2004-01-04 17:05:03 +00:00
|
|
|
{
|
|
|
|
nData = ((in[1] & 0x7F) << 7) | (in[0] & 0x7F);
|
|
|
|
fldrs[0] = in[0]; // current user
|
|
|
|
fldrs[1] = in[0] | CSIDL_FLAG_CREATE;
|
|
|
|
fldrs[2] = in[1]; // all users
|
|
|
|
fldrs[3] = in[1] | CSIDL_FLAG_CREATE;
|
|
|
|
in += 2;
|
2003-12-22 18:50:47 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
if (nVarIdx == NS_SHELL_CODE)
|
|
|
|
{
|
|
|
|
// NOTE 1: the code CSIDL_PRINTERS, is used for QUICKLAUNCH
|
|
|
|
// NOTE 2: the code CSIDL_BITBUCKET is used for COMMONFILES
|
|
|
|
// NOTE 3: the code CSIDL_CONTROLS is used for PROGRAMFILES
|
|
|
|
LPITEMIDLIST idl;
|
|
|
|
char *append = 0;
|
2003-12-22 18:50:47 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
int x = 0;
|
2003-12-22 18:50:47 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
*out = 0;
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
if (fldrs[2] == CSIDL_PRINTERS) // QUICKLAUNCH
|
|
|
|
{
|
|
|
|
append = "\\Microsoft\\Internet Explorer\\Quick Launch";
|
2003-12-22 18:50:47 +00:00
|
|
|
x = 2;
|
2004-06-19 12:42:41 +00:00
|
|
|
}
|
|
|
|
if (fldrs[0] == CSIDL_PROGRAM_FILES_COMMON)
|
|
|
|
{
|
|
|
|
myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "CommonFilesDir", out);
|
|
|
|
}
|
|
|
|
if (fldrs[0] == CSIDL_PROGRAM_FILES)
|
|
|
|
{
|
|
|
|
myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "ProgramFilesDir", out);
|
|
|
|
if (!*out)
|
|
|
|
mystrcpy(out, "C:\\Program Files");
|
|
|
|
}
|
|
|
|
if (fldrs[0] == CSIDL_SYSTEM)
|
|
|
|
{
|
|
|
|
GetSystemDirectory(out, NSIS_MAX_STRLEN);
|
|
|
|
}
|
|
|
|
if (fldrs[0] == CSIDL_WINDOWS)
|
|
|
|
{
|
|
|
|
GetWindowsDirectory(out, NSIS_MAX_STRLEN);
|
|
|
|
}
|
2003-02-08 14:30:46 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
if (!*out)
|
2003-12-22 14:34:05 +00:00
|
|
|
{
|
2004-06-19 12:42:41 +00:00
|
|
|
x = 4;
|
|
|
|
if (!g_exec_flags.all_user_var)
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (x--)
|
|
|
|
{
|
|
|
|
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))
|
2003-12-22 00:28:30 +00:00
|
|
|
{
|
2004-06-19 12:42:41 +00:00
|
|
|
BOOL res = SHGetPathFromIDList(idl, out);
|
|
|
|
FreePIDL(idl);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2003-12-22 14:34:05 +00:00
|
|
|
}
|
2004-06-19 12:42:41 +00:00
|
|
|
else
|
|
|
|
*out=0;
|
2003-12-22 14:34:05 +00:00
|
|
|
}
|
2003-12-22 18:50:47 +00:00
|
|
|
|
2004-06-19 12:42:41 +00:00
|
|
|
if (*out && append)
|
|
|
|
{
|
|
|
|
lstrcat(out, append);
|
|
|
|
}
|
2003-06-12 00:06:23 +00:00
|
|
|
|
|
|
|
validate_filename(out);
|
2004-06-19 12:42:41 +00:00
|
|
|
out += mystrlen(out);
|
2003-06-12 00:06:23 +00:00
|
|
|
}
|
2004-06-19 12:42:41 +00:00
|
|
|
else if (nVarIdx == NS_VAR_CODE)
|
|
|
|
{
|
|
|
|
if (nData == 27) // HWNDPARENT
|
|
|
|
myitoa(out, (unsigned int) g_hwnd);
|
|
|
|
else
|
|
|
|
mystrcpy(out, g_usrvars[nData]);
|
|
|
|
// validate the directory name
|
|
|
|
if ((unsigned int)(nData - 21) < 6) {
|
|
|
|
// validate paths for $INSTDIR, $OUTDIR, $EXEDIR, $LANGUAGE, $TEMP and $PLUGINSDIR
|
|
|
|
// $LANGUAGE is just a number anyway...
|
|
|
|
validate_filename(out);
|
|
|
|
}
|
|
|
|
out += mystrlen(out);
|
|
|
|
} // == VAR_CODES_START
|
|
|
|
else if (nVarIdx == NS_LANG_CODE)
|
|
|
|
{
|
|
|
|
GetNSISString(out, -nData-1);
|
|
|
|
out += mystrlen(out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nVarIdx == NS_SKIP_CODE)
|
2003-06-16 19:58:29 +00:00
|
|
|
{
|
2004-06-19 12:42:41 +00:00
|
|
|
*out++ = *in++;
|
2003-06-16 19:58:29 +00:00
|
|
|
}
|
|
|
|
else // Normal char
|
|
|
|
{
|
2003-07-12 15:19:49 +00:00
|
|
|
*out++ = nVarIdx;
|
2003-06-16 19:58:29 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
} // while
|
|
|
|
*out = 0;
|
2003-09-04 18:25:57 +00:00
|
|
|
if (outbuf)
|
|
|
|
return lstrcpyn(outbuf, ps_tmpbuf, NSIS_MAX_STRLEN);
|
2003-02-07 23:04:25 +00:00
|
|
|
return ps_tmpbuf;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-07 23:04:25 +00:00
|
|
|
char * NSISCALL validate_filename(char *in) {
|
|
|
|
char *nono = "*?|<>/\":";
|
2003-02-18 19:58:16 +00:00
|
|
|
char *out;
|
|
|
|
char *out_save;
|
2004-01-30 23:51:31 +00:00
|
|
|
while (*in == ' ') in = CharNext(in);
|
2004-02-04 20:03:30 +00:00
|
|
|
if (in[0] == '\\' && in[1] == '\\' && in[2] == '?' && in[3] == '\\')
|
|
|
|
{
|
2003-02-18 19:58:16 +00:00
|
|
|
// at least four bytes
|
2003-09-23 19:01:19 +00:00
|
|
|
in += 4;
|
2003-02-18 19:58:16 +00:00
|
|
|
}
|
2004-02-04 20:03:30 +00:00
|
|
|
if (*in)
|
|
|
|
{
|
2003-02-18 19:58:16 +00:00
|
|
|
// at least two bytes
|
2003-09-23 19:01:19 +00:00
|
|
|
if (validpathspec(in)) in += 2;
|
2003-02-18 19:58:16 +00:00
|
|
|
}
|
2003-02-19 20:36:20 +00:00
|
|
|
out = out_save = in;
|
2004-02-04 20:03:30 +00:00
|
|
|
while (*in)
|
|
|
|
{
|
2004-02-07 14:24:51 +00:00
|
|
|
if ((unsigned char)*in > 31 && !*findchar(nono, *in))
|
2004-02-04 20:03:30 +00:00
|
|
|
{
|
2003-02-19 20:36:20 +00:00
|
|
|
mini_memcpy(out, in, CharNext(in) - in);
|
2003-06-16 12:40:53 +00:00
|
|
|
out = CharNext(out);
|
|
|
|
}
|
2003-02-19 20:36:20 +00:00
|
|
|
in = CharNext(in);
|
2003-02-07 23:04:25 +00:00
|
|
|
}
|
2004-01-30 23:51:31 +00:00
|
|
|
*out = 0;
|
2004-02-04 20:03:30 +00:00
|
|
|
do
|
|
|
|
{
|
2004-01-30 23:51:31 +00:00
|
|
|
out = CharPrev(out_save, out);
|
|
|
|
if (*out == ' ' || *out == '\\')
|
|
|
|
*out = 0;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} while (out_save < out);
|
2003-02-07 23:04:25 +00:00
|
|
|
return out_save;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_LOG
|
2002-08-02 10:01:35 +00:00
|
|
|
int log_dolog;
|
2003-11-24 14:22:50 +00:00
|
|
|
char log_text[NSIS_MAX_STRLEN*4];
|
|
|
|
|
|
|
|
#ifndef NSIS_CONFIG_LOG_ODS
|
2002-08-19 23:18:19 +00:00
|
|
|
void NSISCALL log_write(int close)
|
2002-08-11 18:56:30 +00:00
|
|
|
{
|
2002-08-02 10:01:35 +00:00
|
|
|
static HANDLE fp=INVALID_HANDLE_VALUE;
|
|
|
|
if (close)
|
|
|
|
{
|
2002-08-11 18:56:30 +00:00
|
|
|
if (fp!=INVALID_HANDLE_VALUE)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
CloseHandle(fp);
|
|
|
|
}
|
|
|
|
fp=INVALID_HANDLE_VALUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (log_dolog)
|
|
|
|
{
|
|
|
|
if (g_log_file[0] && fp==INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
fp = myOpenFile(g_log_file,GENERIC_WRITE,OPEN_ALWAYS);
|
2002-08-11 18:56:30 +00:00
|
|
|
if (fp!=INVALID_HANDLE_VALUE)
|
2002-08-02 10:01:35 +00:00
|
|
|
SetFilePointer(fp,0,NULL,FILE_END);
|
|
|
|
}
|
|
|
|
if (fp!=INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
DWORD d;
|
|
|
|
lstrcat(log_text,"\r\n");
|
2002-08-19 21:24:44 +00:00
|
|
|
WriteFile(fp,log_text,mystrlen(log_text),&d,NULL);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-24 14:22:50 +00:00
|
|
|
#endif//!NSIS_CONFIG_LOG_ODS
|
|
|
|
|
|
|
|
void log_printf(char *format, ...)
|
|
|
|
{
|
|
|
|
va_list val;
|
|
|
|
va_start(val,format);
|
|
|
|
wvsprintf(log_text,format,val);
|
|
|
|
va_end(val);
|
|
|
|
#ifdef NSIS_CONFIG_LOG_ODS
|
|
|
|
if (log_dolog)
|
|
|
|
OutputDebugString(log_text);
|
|
|
|
#else
|
|
|
|
log_write(0);
|
2003-06-12 00:06:23 +00:00
|
|
|
#endif
|
2003-11-24 14:22:50 +00:00
|
|
|
}
|
|
|
|
#endif//NSIS_CONFIG_LOG
|
2003-07-08 23:18:47 +00:00
|
|
|
|
|
|
|
WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
|
|
|
|
{
|
|
|
|
HANDLE h;
|
|
|
|
static WIN32_FIND_DATA fd;
|
2003-09-28 12:14:10 +00:00
|
|
|
// Avoid a "There is no disk in the drive" error box on empty removable drives
|
|
|
|
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
2003-07-08 23:18:47 +00:00
|
|
|
h = FindFirstFile(buf,&fd);
|
2003-09-28 12:14:10 +00:00
|
|
|
SetErrorMode(0);
|
2003-07-08 23:18:47 +00:00
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
FindClose(h);
|
|
|
|
return &fd;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|