2006-10-28 19:45:02 +00:00
|
|
|
/*
|
|
|
|
* util.h
|
|
|
|
*
|
|
|
|
* This file is a part of NSIS.
|
|
|
|
*
|
2009-02-01 14:44:30 +00:00
|
|
|
* Copyright (C) 1999-2009 Nullsoft and Contributors
|
2006-10-28 19:45:02 +00:00
|
|
|
*
|
|
|
|
* Licensed under the zlib/libpng license (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty.
|
2010-03-24 17:22:56 +00:00
|
|
|
*
|
|
|
|
* Unicode support by Jim Park -- 07/23/2007
|
2006-10-28 19:45:02 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-20 20:32:04 +00:00
|
|
|
#ifndef ___NSIS_UTIL_H___
|
|
|
|
#define ___NSIS_UTIL_H___
|
|
|
|
|
2004-03-12 20:43:54 +00:00
|
|
|
#include "../Platform.h"
|
2002-08-02 10:01:35 +00:00
|
|
|
#include "config.h"
|
2003-12-22 00:28:30 +00:00
|
|
|
#include <shlobj.h>
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
extern TCHAR ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
|
|
|
TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab);
|
2003-09-04 18:25:57 +00:00
|
|
|
#define GetNSISStringTT(strtab) GetNSISString(0, (strtab))
|
2010-03-24 17:22:56 +00:00
|
|
|
#define GetNSISStringNP(strtab) ((const TCHAR *)g_blocks[NB_STRINGS].offset+(strtab))
|
|
|
|
|
|
|
|
// A negative string table index means it's a language string table, so we
|
|
|
|
// use the LANG_STR_TAB() macro to decode it.
|
2003-09-04 18:25:57 +00:00
|
|
|
#define GetNSISTab(strtab) (strtab < 0 ? LANG_STR_TAB(strtab) : strtab)
|
2010-03-24 17:22:56 +00:00
|
|
|
|
|
|
|
void NSISCALL myRegGetStr(HKEY root, const TCHAR *sub, const TCHAR *name, TCHAR *out, int x64);
|
|
|
|
int NSISCALL myatoi(TCHAR *s);
|
|
|
|
void NSISCALL myitoa(TCHAR *s, int d);
|
|
|
|
TCHAR * NSISCALL mystrcpy(TCHAR *out, const TCHAR *in);
|
|
|
|
int NSISCALL mystrlen(const TCHAR *in);
|
|
|
|
TCHAR * NSISCALL mystrcat(TCHAR *out, const TCHAR *concat);
|
|
|
|
TCHAR * NSISCALL mystrstr(TCHAR *a, TCHAR *b);
|
|
|
|
WIN32_FIND_DATA * NSISCALL file_exists(TCHAR *buf);
|
|
|
|
TCHAR * NSISCALL my_GetTempFileName(TCHAR *buf, const TCHAR *dir);
|
|
|
|
|
|
|
|
//BOOL NSISCALL my_SetWindowText(HWND hWnd, const TCHAR *val);
|
2003-12-29 14:27:33 +00:00
|
|
|
#define my_SetWindowText SetWindowText
|
2010-03-24 17:22:56 +00:00
|
|
|
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const TCHAR *val);
|
2004-01-04 17:05:03 +00:00
|
|
|
//#define my_SetDialogItemText SetDlgItemText
|
2010-03-24 17:22:56 +00:00
|
|
|
//int NSISCALL my_GetWindowText(HWND hWnd, TCHAR *val, int size);
|
2003-02-07 23:04:25 +00:00
|
|
|
#define my_GetWindowText GetWindowText
|
2010-03-24 17:22:56 +00:00
|
|
|
int NSISCALL my_GetDialogItemText(UINT idx, TCHAR *val);
|
2004-01-04 17:05:03 +00:00
|
|
|
//#define my_GetDialogItemText GetDlgItemText
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_LOG
|
2010-03-24 17:22:56 +00:00
|
|
|
extern TCHAR log_text[2048];
|
2002-08-19 23:18:19 +00:00
|
|
|
void NSISCALL log_write(int close);
|
2010-03-24 17:22:56 +00:00
|
|
|
const TCHAR * _RegKeyHandleToName(HKEY hKey);
|
|
|
|
void _LogData2Hex(TCHAR *buf, size_t buflen, BYTE *data, size_t datalen);
|
|
|
|
void log_printf(TCHAR *format, ...);
|
2004-01-27 18:44:31 +00:00
|
|
|
#define log_printf2(x1,x2) log_printf(x1,x2);
|
|
|
|
#define log_printf3(x1,x2,x3) log_printf(x1,x2,x3);
|
|
|
|
#define log_printf4(x1,x2,x3,x4) log_printf(x1,x2,x3,x4);
|
|
|
|
#define log_printf5(x1,x2,x3,x4,x5) log_printf(x1,x2,x3,x4,x5);
|
|
|
|
#define log_printf6(x1,x2,x3,x4,x5,x6) log_printf(x1,x2,x3,x4,x5,x6);
|
|
|
|
#define log_printf7(x1,x2,x3,x4,x5,x6,x7) log_printf(x1,x2,x3,x4,x5,x6,x7);
|
|
|
|
#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8) log_printf(x1,x2,x3,x4,x5,x6,x7,x8);
|
2005-11-24 16:45:04 +00:00
|
|
|
#define RegKeyHandleToName(x1) _RegKeyHandleToName(x1);
|
|
|
|
#define LogData2Hex(x1,x2,x3,x4) _LogData2Hex(x1,x2,x3,x4);
|
2002-08-02 10:01:35 +00:00
|
|
|
extern int log_dolog;
|
2010-03-24 17:22:56 +00:00
|
|
|
extern TCHAR g_log_file[1024];
|
2002-08-02 10:01:35 +00:00
|
|
|
#else
|
|
|
|
#define log_printf(x1)
|
|
|
|
#define log_printf2(x1,x2)
|
|
|
|
#define log_printf3(x1,x2,x3)
|
|
|
|
#define log_printf4(x1,x2,x3,x4)
|
|
|
|
#define log_printf5(x1,x2,x3,x4,x5)
|
|
|
|
#define log_printf6(x1,x2,x3,x4,x5,x6)
|
2004-01-27 18:44:31 +00:00
|
|
|
#define log_printf7(x1,x2,x3,x4,x5,x6,x7)
|
2002-08-02 10:01:35 +00:00
|
|
|
#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8)
|
2005-11-24 16:45:04 +00:00
|
|
|
#define RegKeyHandleToName(x1) NULL
|
|
|
|
#define LogData2Hex(x1,x2,x3,x4)
|
2002-08-02 10:01:35 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
HANDLE NSISCALL myCreateProcess(TCHAR *cmd);
|
|
|
|
int NSISCALL my_MessageBox(const TCHAR *text, UINT type);
|
2002-08-08 15:04:45 +00:00
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
void NSISCALL myDelete(TCHAR *buf, int flags);
|
2002-08-11 18:56:30 +00:00
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
HANDLE NSISCALL myOpenFile(const TCHAR *fn, DWORD da, DWORD cd);
|
|
|
|
int NSISCALL validpathspec(TCHAR *ubuf);
|
|
|
|
TCHAR * NSISCALL addtrailingslash(TCHAR *str);
|
|
|
|
//TCHAR NSISCALL lastchar(const TCHAR *str);
|
2003-02-20 18:47:58 +00:00
|
|
|
#define lastchar(str) *CharPrev(str,str+mystrlen(str))
|
2010-03-24 17:22:56 +00:00
|
|
|
TCHAR * NSISCALL findchar(TCHAR *str, TCHAR c);
|
|
|
|
TCHAR * NSISCALL trimslashtoend(TCHAR *buf);
|
|
|
|
TCHAR * NSISCALL skip_root(TCHAR *path);
|
|
|
|
int NSISCALL is_valid_instpath(TCHAR *s);
|
|
|
|
void NSISCALL validate_filename(TCHAR *fn);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MoveFileOnReboot tries to move a file by the name of pszExisting to the
|
|
|
|
* name pszNew.
|
|
|
|
*
|
|
|
|
* @param pszExisting The old name of the file.
|
|
|
|
* @param pszNew The new name of the file.
|
|
|
|
*/
|
2003-09-09 14:25:16 +00:00
|
|
|
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
2010-03-24 17:22:56 +00:00
|
|
|
|
2004-05-08 16:07:22 +00:00
|
|
|
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
2010-03-24 17:22:56 +00:00
|
|
|
void NSISCALL remove_ro_attr(TCHAR *file);
|
2002-09-22 19:05:43 +00:00
|
|
|
|
2007-04-20 20:32:04 +00:00
|
|
|
enum myGetProcAddressFunctions {
|
2010-03-24 17:22:56 +00:00
|
|
|
MGA_GetDiskFreeSpaceEx,
|
|
|
|
MGA_MoveFileEx,
|
|
|
|
MGA_RegDeleteKeyEx,
|
2007-04-20 20:32:04 +00:00
|
|
|
MGA_OpenProcessToken,
|
2010-03-24 17:22:56 +00:00
|
|
|
MGA_LookupPrivilegeValue,
|
2007-04-20 20:32:04 +00:00
|
|
|
MGA_AdjustTokenPrivileges,
|
|
|
|
MGA_GetUserDefaultUILanguage,
|
2007-07-10 21:33:06 +00:00
|
|
|
MGA_SHAutoComplete,
|
2010-03-24 17:22:56 +00:00
|
|
|
MGA_SHGetFolderPath
|
2007-04-20 20:32:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
2005-09-09 15:21:45 +00:00
|
|
|
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
2005-09-02 11:35:45 +00:00
|
|
|
|
2002-09-22 19:05:43 +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))
|
2003-07-12 15:19:49 +00:00
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16))
|
2002-09-22 19:05:43 +00:00
|
|
|
#else
|
|
|
|
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
2003-07-12 15:19:49 +00:00
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
2002-09-22 19:05:43 +00:00
|
|
|
#endif
|
2007-04-20 20:32:04 +00:00
|
|
|
|
|
|
|
#endif//!___NSIS_UTIL_H___
|