more simple TCHARs fixes
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6047 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a92fad7347
commit
64a0f32e52
38 changed files with 1831 additions and 1961 deletions
|
@ -47,7 +47,7 @@ int GetTLBVersion(tstring& filepath, DWORD& high, DWORD & low)
|
||||||
hr = LoadTypeLib(fullpath, &typeLib);
|
hr = LoadTypeLib(fullpath, &typeLib);
|
||||||
#else
|
#else
|
||||||
// If built without UNICODE, we still need to convert this string to a Unicode string.
|
// If built without UNICODE, we still need to convert this string to a Unicode string.
|
||||||
WCHAR *ole_filename = winchar_fromansi(fullpath);
|
WCHAR *ole_filename = winchar_fromTchar(fullpath);
|
||||||
hr = LoadTypeLib(ole_filename, &typeLib);
|
hr = LoadTypeLib(ole_filename, &typeLib);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,368 +1,380 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
#ifndef _CRT_STRINGIZE
|
#ifndef _CRT_STRINGIZE
|
||||||
#define __CRT_STRINGIZE(_Value) #_Value
|
#define __CRT_STRINGIZE(_Value) #_Value
|
||||||
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
|
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
|
||||||
#endif /* _CRT_STRINGIZE */
|
#endif /* _CRT_STRINGIZE */
|
||||||
|
|
||||||
#define STR_SIZE 1024
|
#define STR_SIZE 1024
|
||||||
|
|
||||||
void RegFile(TCHAR cmd, TCHAR *file, int x64);
|
void RegFile(TCHAR cmd, TCHAR *file, int x64);
|
||||||
void RegDll(TCHAR *file);
|
void RegDll(TCHAR *file);
|
||||||
void RegTypeLib(TCHAR *file);
|
void RegTypeLib(TCHAR *file);
|
||||||
void DeleteFileOnReboot(TCHAR *pszFile);
|
void DeleteFileOnReboot(TCHAR *pszFile);
|
||||||
|
|
||||||
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
TCHAR *cmdline;
|
TCHAR *cmdline;
|
||||||
TCHAR seekchar = _T(' ');
|
TCHAR seekchar = _T(' ');
|
||||||
|
|
||||||
cmdline = GetCommandLine();
|
cmdline = GetCommandLine();
|
||||||
if (*cmdline == _T('\"'))
|
if (*cmdline == _T('\"'))
|
||||||
seekchar = *cmdline++;
|
seekchar = *cmdline++;
|
||||||
|
|
||||||
while (*cmdline && *cmdline != seekchar)
|
while (*cmdline && *cmdline != seekchar)
|
||||||
cmdline = CharNext(cmdline);
|
cmdline = CharNext(cmdline);
|
||||||
cmdline = CharNext(cmdline);
|
cmdline = CharNext(cmdline);
|
||||||
while (*cmdline == _T(' '))
|
while (*cmdline == _T(' '))
|
||||||
cmdline++;
|
cmdline++;
|
||||||
|
|
||||||
if (*cmdline++ != _T('/'))
|
if (*cmdline++ != _T('/'))
|
||||||
{
|
{
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*cmdline == _T('S'))
|
if (*cmdline == _T('S'))
|
||||||
{
|
{
|
||||||
HKEY rootkey;
|
HKEY rootkey;
|
||||||
|
TCHAR *keyname, *file; // These are turned into heap memory to avoid _chkstk
|
||||||
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"), 0, KEY_READ, &rootkey)))
|
keyname = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
|
||||||
{
|
file = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
|
||||||
TCHAR keyname[STR_SIZE];
|
|
||||||
|
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"), 0, KEY_READ, &rootkey)))
|
||||||
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
|
{
|
||||||
{
|
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
|
||||||
HKEY key;
|
{
|
||||||
|
HKEY key;
|
||||||
if (SUCCEEDED(RegOpenKeyEx(rootkey, keyname, 0, KEY_READ, &key)))
|
|
||||||
{
|
if (SUCCEEDED(RegOpenKeyEx(rootkey, keyname, 0, KEY_READ, &key)))
|
||||||
DWORD t, count, l = sizeof(DWORD);
|
{
|
||||||
|
DWORD t, count, l = sizeof(DWORD);
|
||||||
if (SUCCEEDED(RegQueryValueEx(key, _T("count"), NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
|
|
||||||
{
|
if (SUCCEEDED(RegQueryValueEx(key, _T("count"), NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
|
||||||
DWORD j;
|
{
|
||||||
TCHAR valname[128], mode[3], file[STR_SIZE];
|
DWORD j;
|
||||||
|
TCHAR valname[128], mode[3];
|
||||||
for (j = 1; j <= count; j++)
|
|
||||||
{
|
for (j = 1; j <= count; j++)
|
||||||
wsprintf(valname, _T("%u.mode"), j);
|
{
|
||||||
l = sizeof(mode);
|
wsprintf(valname, _T("%u.mode"), j);
|
||||||
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) mode, &l)) || t != REG_SZ)
|
l = sizeof(mode);
|
||||||
continue;
|
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) mode, &l)) || t != REG_SZ)
|
||||||
|
continue;
|
||||||
wsprintf(valname, _T("%u.file"), j);
|
|
||||||
l = (lstrlen(file)+1)*sizeof(TCHAR);
|
wsprintf(valname, _T("%u.file"), j);
|
||||||
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
|
l = (lstrlen(file)+1)*sizeof(TCHAR);
|
||||||
continue;
|
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
|
||||||
|
continue;
|
||||||
// JP: Note, if this mode[1] is used as anything but a boolean later on,
|
|
||||||
// we'll need to consider the next line carefully.
|
// JP: Note, if this mode[1] is used as anything but a boolean later on,
|
||||||
RegFile(mode[0], file, mode[1] == 'X');
|
// we'll need to consider the next line carefully.
|
||||||
}
|
RegFile(mode[0], file, mode[1] == 'X');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
RegCloseKey(key);
|
|
||||||
RegDeleteKey(rootkey, keyname);
|
RegCloseKey(key);
|
||||||
}
|
RegDeleteKey(rootkey, keyname);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
RegCloseKey(rootkey);
|
|
||||||
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
|
RegCloseKey(rootkey);
|
||||||
}
|
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
|
||||||
|
}
|
||||||
{
|
|
||||||
TCHAR file[STR_SIZE];
|
{
|
||||||
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
||||||
{
|
{
|
||||||
DeleteFileOnReboot(file);
|
DeleteFileOnReboot(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
GlobalFree(keyname);
|
||||||
else
|
GlobalFree(file);
|
||||||
{
|
}
|
||||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
else
|
||||||
OleInitialize(NULL);
|
{
|
||||||
|
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||||
if (*cmdline == _T('D'))
|
OleInitialize(NULL);
|
||||||
{
|
|
||||||
RegDll(cmdline + 1);
|
if (*cmdline == _T('D'))
|
||||||
}
|
{
|
||||||
else if (*cmdline == _T('T'))
|
RegDll(cmdline + 1);
|
||||||
{
|
}
|
||||||
RegTypeLib(cmdline + 1);
|
else if (*cmdline == _T('T'))
|
||||||
}
|
{
|
||||||
|
RegTypeLib(cmdline + 1);
|
||||||
OleUninitialize();
|
}
|
||||||
SetErrorMode(0);
|
|
||||||
}
|
OleUninitialize();
|
||||||
|
SetErrorMode(0);
|
||||||
ExitProcess(0);
|
}
|
||||||
return 0;
|
|
||||||
}
|
ExitProcess(0);
|
||||||
|
return 0;
|
||||||
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
}
|
||||||
{
|
|
||||||
HMODULE kernel = GetModuleHandle(_T("kernel32"));
|
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
||||||
if (kernel)
|
{
|
||||||
{
|
HMODULE kernel = GetModuleHandle(_T("kernel32"));
|
||||||
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
if (kernel)
|
||||||
if (proc)
|
{
|
||||||
{
|
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
||||||
typedef BOOL (WINAPI *Wow64EnableWow64FsRedirectionPtr)(BOOL);
|
if (proc)
|
||||||
Wow64EnableWow64FsRedirectionPtr Wow64EnableWow64FsRedirectionFunc =
|
{
|
||||||
(Wow64EnableWow64FsRedirectionPtr) proc;
|
typedef BOOL (WINAPI *Wow64EnableWow64FsRedirectionPtr)(BOOL);
|
||||||
|
Wow64EnableWow64FsRedirectionPtr Wow64EnableWow64FsRedirectionFunc =
|
||||||
Wow64EnableWow64FsRedirectionFunc(Wow64FsEnableRedirection);
|
(Wow64EnableWow64FsRedirectionPtr) proc;
|
||||||
}
|
|
||||||
}
|
Wow64EnableWow64FsRedirectionFunc(Wow64FsEnableRedirection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void RegFile(TCHAR cmd, TCHAR *file, int x64)
|
}
|
||||||
{
|
|
||||||
TCHAR self[STR_SIZE];
|
void RegFile(TCHAR cmd, TCHAR *file, int x64)
|
||||||
TCHAR cmdline[STR_SIZE];
|
{
|
||||||
|
TCHAR* self; // These are turned into heap memory to avoid _chkstk
|
||||||
int ready = 0;
|
TCHAR* cmdline;
|
||||||
|
|
||||||
if (!*file || (cmd != _T('D') && cmd != _T('T') && cmd != _T('E')))
|
int ready = 0;
|
||||||
return;
|
|
||||||
|
if (!*file || (cmd != _T('D') && cmd != _T('T') && cmd != _T('E')))
|
||||||
if (cmd == _T('E'))
|
return;
|
||||||
{
|
|
||||||
wsprintf(cmdline, _T("\"%s\" /regserver"), file);
|
self = (TCHAR*) GlobalAlloc(GPTR, sizeof(TCHAR)*STR_SIZE);
|
||||||
ready++;
|
cmdline = (TCHAR*) GlobalAlloc(GPTR, sizeof(TCHAR)*STR_SIZE);
|
||||||
}
|
|
||||||
else if (!x64)
|
if (cmd == _T('E'))
|
||||||
{
|
{
|
||||||
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
wsprintf(cmdline, _T("\"%s\" /regserver"), file);
|
||||||
{
|
ready++;
|
||||||
wsprintf(cmdline, _T("\"%s\" /%c%s"), self, cmd, file);
|
}
|
||||||
ready++;
|
else if (!x64)
|
||||||
}
|
{
|
||||||
}
|
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
||||||
else
|
{
|
||||||
{
|
wsprintf(cmdline, _T("\"%s\" /%c%s"), self, cmd, file);
|
||||||
if (GetSystemDirectory(self, STR_SIZE))
|
ready++;
|
||||||
{
|
}
|
||||||
wsprintf(cmdline, _T("\"%s\\regsvr32.exe\" /s \"%s\""), self, file);
|
}
|
||||||
ready++;
|
else
|
||||||
|
{
|
||||||
SafeWow64EnableWow64FsRedirection(FALSE);
|
if (GetSystemDirectory(self, STR_SIZE))
|
||||||
}
|
{
|
||||||
}
|
wsprintf(cmdline, _T("\"%s\\regsvr32.exe\" /s \"%s\""), self, file);
|
||||||
|
ready++;
|
||||||
if (ready)
|
|
||||||
{
|
SafeWow64EnableWow64FsRedirection(FALSE);
|
||||||
PROCESS_INFORMATION pi;
|
}
|
||||||
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
}
|
||||||
|
|
||||||
if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
if (ready)
|
||||||
{
|
{
|
||||||
CloseHandle(pi.hThread);
|
PROCESS_INFORMATION pi;
|
||||||
|
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
||||||
|
if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||||
CloseHandle(pi.hProcess);
|
{
|
||||||
}
|
CloseHandle(pi.hThread);
|
||||||
|
|
||||||
if (x64)
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||||
{
|
|
||||||
SafeWow64EnableWow64FsRedirection(TRUE);
|
CloseHandle(pi.hProcess);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (x64)
|
||||||
|
{
|
||||||
void RegDll(TCHAR *file)
|
SafeWow64EnableWow64FsRedirection(TRUE);
|
||||||
{
|
}
|
||||||
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
}
|
||||||
if (mod)
|
|
||||||
{
|
GlobalFree(self);
|
||||||
FARPROC regfunc = GetProcAddress(mod, "DllRegisterServer");
|
GlobalFree(cmdline);
|
||||||
if (regfunc)
|
}
|
||||||
regfunc();
|
|
||||||
FreeLibrary(mod);
|
void RegDll(TCHAR *file)
|
||||||
}
|
{
|
||||||
}
|
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||||
|
if (mod)
|
||||||
void RegTypeLib(TCHAR *file)
|
{
|
||||||
{
|
FARPROC regfunc = GetProcAddress(mod, "DllRegisterServer");
|
||||||
WCHAR wfile[STR_SIZE];
|
if (regfunc)
|
||||||
|
regfunc();
|
||||||
if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) != 0)
|
FreeLibrary(mod);
|
||||||
{
|
}
|
||||||
ITypeLib* tlib;
|
}
|
||||||
if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
|
|
||||||
RegisterTypeLib(tlib, wfile, NULL);
|
void RegTypeLib(TCHAR *file)
|
||||||
tlib->lpVtbl->Release(tlib);
|
{
|
||||||
}
|
#ifdef _UNICODE
|
||||||
}
|
WCHAR* wfile = file;
|
||||||
}
|
#else
|
||||||
|
WCHAR wfile[STR_SIZE];
|
||||||
char *mystrstriA(char *a, const char *b)
|
if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) == 0)
|
||||||
{
|
return;
|
||||||
int l = lstrlenA(b);
|
#endif
|
||||||
while (lstrlenA(a) >= l)
|
{
|
||||||
{
|
ITypeLib* tlib;
|
||||||
char c = a[l];
|
if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
|
||||||
a[l] = 0;
|
RegisterTypeLib(tlib, wfile, NULL);
|
||||||
if (!lstrcmpiA(a, b))
|
tlib->lpVtbl->Release(tlib);
|
||||||
{
|
}
|
||||||
a[l] = c;
|
}
|
||||||
return a;
|
}
|
||||||
}
|
|
||||||
a[l] = c;
|
char *mystrstriA(char *a, const char *b)
|
||||||
a = CharNextA(a);
|
{
|
||||||
}
|
int l = lstrlenA(b);
|
||||||
return NULL;
|
while (lstrlenA(a) >= l)
|
||||||
}
|
{
|
||||||
|
char c = a[l];
|
||||||
void mini_memcpy(void *out, const void *in, int len)
|
a[l] = 0;
|
||||||
{
|
if (!lstrcmpiA(a, b))
|
||||||
char *c_out=(char*)out;
|
{
|
||||||
char *c_in=(char *)in;
|
a[l] = c;
|
||||||
while (len-- > 0)
|
return a;
|
||||||
{
|
}
|
||||||
*c_out++=*c_in++;
|
a[l] = c;
|
||||||
}
|
a = CharNextA(a);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
|
}
|
||||||
{
|
|
||||||
int attr = GetFileAttributes(fn);
|
void mini_memcpy(void *out, const void *in, int len)
|
||||||
return CreateFile(
|
{
|
||||||
fn,
|
char *c_out=(char*)out;
|
||||||
da,
|
char *c_in=(char *)in;
|
||||||
FILE_SHARE_READ,
|
while (len-- > 0)
|
||||||
NULL,
|
{
|
||||||
cd,
|
*c_out++=*c_in++;
|
||||||
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
|
}
|
||||||
NULL
|
}
|
||||||
);
|
|
||||||
}
|
HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
|
||||||
|
{
|
||||||
/** Modifies the wininit.ini file to rename / delete a file.
|
int attr = GetFileAttributes(fn);
|
||||||
*
|
return CreateFile(
|
||||||
* @param prevName The previous / current name of the file.
|
fn,
|
||||||
* @param newName The new name to move the file to. If NULL, the current file
|
da,
|
||||||
* will be deleted.
|
FILE_SHARE_READ,
|
||||||
*/
|
NULL,
|
||||||
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
cd,
|
||||||
{
|
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
|
||||||
static char szRenameLine[1024];
|
NULL
|
||||||
static TCHAR wininit[1024];
|
);
|
||||||
static TCHAR tmpbuf[1024];
|
}
|
||||||
|
|
||||||
int cchRenameLine;
|
/** Modifies the wininit.ini file to rename / delete a file.
|
||||||
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
|
*
|
||||||
HANDLE hfile;
|
* @param prevName The previous / current name of the file.
|
||||||
DWORD dwFileSize;
|
* @param newName The new name to move the file to. If NULL, the current file
|
||||||
DWORD dwBytes;
|
* will be deleted.
|
||||||
DWORD dwRenameLinePos;
|
*/
|
||||||
char *pszWinInit; // Contains the file contents of wininit.ini
|
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||||
|
{
|
||||||
int spn; // length of the short path name in TCHARs.
|
static char szRenameLine[1024];
|
||||||
|
static TCHAR wininit[1024];
|
||||||
lstrcpy(tmpbuf, _T("NUL"));
|
static TCHAR tmpbuf[1024];
|
||||||
|
|
||||||
if (newName) {
|
int cchRenameLine;
|
||||||
// create the file if it's not already there to prevent GetShortPathName from failing
|
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
|
||||||
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
|
HANDLE hfile;
|
||||||
spn = GetShortPathName(newName,tmpbuf,1024);
|
DWORD dwFileSize;
|
||||||
if (!spn || spn > 1024)
|
DWORD dwBytes;
|
||||||
return;
|
DWORD dwRenameLinePos;
|
||||||
}
|
char *pszWinInit; // Contains the file contents of wininit.ini
|
||||||
// wininit is used as a temporary here
|
|
||||||
spn = GetShortPathName(prevName,wininit,1024);
|
int spn; // length of the short path name in TCHARs.
|
||||||
if (!spn || spn > 1024)
|
|
||||||
return;
|
lstrcpy(tmpbuf, _T("NUL"));
|
||||||
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
|
|
||||||
// Get the path to the wininit.ini file.
|
if (newName) {
|
||||||
GetWindowsDirectory(wininit, 1024-16);
|
// create the file if it's not already there to prevent GetShortPathName from failing
|
||||||
lstrcat(wininit, _T("\\wininit.ini"));
|
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
|
||||||
|
spn = GetShortPathName(newName,tmpbuf,1024);
|
||||||
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
if (!spn || spn > 1024)
|
||||||
|
return;
|
||||||
if (hfile != INVALID_HANDLE_VALUE)
|
}
|
||||||
{
|
// wininit is used as a temporary here
|
||||||
// We are now working on the Windows wininit file
|
spn = GetShortPathName(prevName,wininit,1024);
|
||||||
dwFileSize = GetFileSize(hfile, NULL);
|
if (!spn || spn > 1024)
|
||||||
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
|
return;
|
||||||
|
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
|
||||||
if (pszWinInit != NULL)
|
// Get the path to the wininit.ini file.
|
||||||
{
|
GetWindowsDirectory(wininit, 1024-16);
|
||||||
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
|
lstrcat(wininit, _T("\\wininit.ini"));
|
||||||
{
|
|
||||||
// Look for the rename section in the current file.
|
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
||||||
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
|
|
||||||
if (pszRenameSecInFile == NULL)
|
if (hfile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
// No rename section. So we add it to the end of file.
|
// We are now working on the Windows wininit file
|
||||||
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
|
dwFileSize = GetFileSize(hfile, NULL);
|
||||||
dwFileSize += 10;
|
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
|
||||||
dwRenameLinePos = dwFileSize;
|
|
||||||
}
|
if (pszWinInit != NULL)
|
||||||
else
|
{
|
||||||
{
|
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
|
||||||
// There is a rename section, but is there another section after it?
|
{
|
||||||
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
// Look for the rename section in the current file.
|
||||||
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
|
||||||
if (pszNextSec)
|
if (pszRenameSecInFile == NULL)
|
||||||
{
|
{
|
||||||
TCHAR *p = ++pszNextSec;
|
// No rename section. So we add it to the end of file.
|
||||||
while (p < pszWinInit + dwFileSize) {
|
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
|
||||||
p[cchRenameLine] = *p;
|
dwFileSize += 10;
|
||||||
p++;
|
dwRenameLinePos = dwFileSize;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
dwRenameLinePos = pszNextSec - pszWinInit;
|
{
|
||||||
}
|
// There is a rename section, but is there another section after it?
|
||||||
// rename section is last, stick item at end of file
|
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
||||||
else dwRenameLinePos = dwFileSize;
|
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
||||||
}
|
if (pszNextSec)
|
||||||
|
{
|
||||||
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
|
char *p = ++pszNextSec;
|
||||||
dwFileSize += cchRenameLine;
|
while (p < pszWinInit + dwFileSize) {
|
||||||
|
p[cchRenameLine] = *p;
|
||||||
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
|
p++;
|
||||||
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
|
}
|
||||||
|
|
||||||
GlobalFree(pszWinInit);
|
dwRenameLinePos = pszNextSec - pszWinInit;
|
||||||
}
|
}
|
||||||
}
|
// rename section is last, stick item at end of file
|
||||||
|
else dwRenameLinePos = dwFileSize;
|
||||||
CloseHandle(hfile);
|
}
|
||||||
}
|
|
||||||
}
|
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
|
||||||
|
dwFileSize += cchRenameLine;
|
||||||
void DeleteFileOnReboot(TCHAR *pszFile)
|
|
||||||
{
|
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
|
||||||
BOOL fOk = 0;
|
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
|
||||||
HMODULE hLib=GetModuleHandle(_T("KERNEL32.dll"));
|
|
||||||
if (hLib)
|
GlobalFree(pszWinInit);
|
||||||
{
|
}
|
||||||
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
}
|
||||||
mfea_t mfea;
|
|
||||||
mfea=(mfea_t) GetProcAddress(hLib,_CRT_STRINGIZE(MoveFileEx));
|
CloseHandle(hfile);
|
||||||
if (mfea)
|
}
|
||||||
{
|
}
|
||||||
fOk=mfea(pszFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
|
||||||
}
|
void DeleteFileOnReboot(TCHAR *pszFile)
|
||||||
}
|
{
|
||||||
|
BOOL fOk = 0;
|
||||||
if (!fOk)
|
HMODULE hLib=GetModuleHandle(_T("KERNEL32.dll"));
|
||||||
{
|
if (hLib)
|
||||||
RenameViaWininit(pszFile, NULL);
|
{
|
||||||
}
|
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
||||||
}
|
mfea_t mfea;
|
||||||
|
mfea=(mfea_t) GetProcAddress(hLib,_CRT_STRINGIZE(MoveFileEx));
|
||||||
|
if (mfea)
|
||||||
|
{
|
||||||
|
fOk=mfea(pszFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fOk)
|
||||||
|
{
|
||||||
|
RenameViaWininit(pszFile, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,5 +13,6 @@ libs = Split("""
|
||||||
""")
|
""")
|
||||||
|
|
||||||
Import('BuildUtil')
|
Import('BuildUtil')
|
||||||
|
Import('_tWinMain')
|
||||||
|
|
||||||
BuildUtil(target, files, libs, entry = 'WinMain', nodeflib = True, file_name = 'RegTool.bin')
|
BuildUtil(target, files, libs, entry = _tWinMain, nodeflib = True, file_name = 'RegTool.bin')
|
||||||
|
|
|
@ -19,6 +19,7 @@ libs = Split("""
|
||||||
""")
|
""")
|
||||||
|
|
||||||
Import('BuildUtil')
|
Import('BuildUtil')
|
||||||
|
Import('_tWinMain')
|
||||||
|
|
||||||
BuildUtil(target, files, libs, res = res, resources = resources, entry = 'WinMain')
|
BuildUtil(target, files, libs, res = res, resources = resources, entry = _tWinMain)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ target = 'makensisw'
|
||||||
|
|
||||||
files = Split("""
|
files = Split("""
|
||||||
makensisw.cpp
|
makensisw.cpp
|
||||||
noclib.cpp
|
|
||||||
toolbar.cpp
|
toolbar.cpp
|
||||||
utils.cpp
|
utils.cpp
|
||||||
version.cpp
|
version.cpp
|
||||||
|
@ -34,6 +33,7 @@ libs = Split("""
|
||||||
user32
|
user32
|
||||||
gdi32
|
gdi32
|
||||||
shell32
|
shell32
|
||||||
|
shlwapi
|
||||||
comdlg32
|
comdlg32
|
||||||
comctl32
|
comctl32
|
||||||
wsock32
|
wsock32
|
||||||
|
@ -45,6 +45,7 @@ docs = Split("""
|
||||||
""")
|
""")
|
||||||
|
|
||||||
Import('BuildUtil')
|
Import('BuildUtil')
|
||||||
|
Import('_tWinMain')
|
||||||
|
|
||||||
BuildUtil(
|
BuildUtil(
|
||||||
target,
|
target,
|
||||||
|
@ -52,7 +53,7 @@ BuildUtil(
|
||||||
libs,
|
libs,
|
||||||
res = res,
|
res = res,
|
||||||
resources = resources,
|
resources = resources,
|
||||||
entry = 'WinMain',
|
entry = _tWinMain,
|
||||||
defines = ['RELEASE=2.3'],
|
defines = ['RELEASE=2.3'],
|
||||||
docs = docs,
|
docs = docs,
|
||||||
root_util = True
|
root_util = True
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "noclib.h"
|
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int
|
||||||
int status;
|
int status;
|
||||||
HACCEL haccel;
|
HACCEL haccel;
|
||||||
|
|
||||||
my_memset(&g_sdata,0,sizeof(NSCRIPTDATA));
|
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
|
||||||
my_memset(&g_resize,0,sizeof(NRESIZEDATA));
|
memset(&g_resize,0,sizeof(NRESIZEDATA));
|
||||||
my_memset(&g_find,0,sizeof(NFINDREPLACE));
|
memset(&g_find,0,sizeof(NFINDREPLACE));
|
||||||
g_sdata.hInstance=GetModuleHandle(0);
|
g_sdata.hInstance=GetModuleHandle(0);
|
||||||
g_sdata.symbols = NULL;
|
g_sdata.symbols = NULL;
|
||||||
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, _T("makensis win32 signint event"));
|
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, _T("makensis win32 signint event"));
|
||||||
|
@ -130,10 +130,10 @@ void ProcessCommandLine()
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (!lstrncmpi(argv[i], _T("/XSetCompressor "), lstrlen(_T("/XSetCompressor "))))
|
if (!StrCmpNI(argv[i], _T("/XSetCompressor "), lstrlen(_T("/XSetCompressor "))))
|
||||||
{
|
{
|
||||||
TCHAR *p = argv[i] + lstrlen(_T("/XSetCompressor "));
|
TCHAR *p = argv[i] + lstrlen(_T("/XSetCompressor "));
|
||||||
if(!lstrncmpi(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
|
if(!StrCmpNI(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
|
||||||
{
|
{
|
||||||
p += lstrlen(_T("/FINAL "));
|
p += lstrlen(_T("/FINAL "));
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
if (g_sdata.input_script) {
|
if (g_sdata.input_script) {
|
||||||
TCHAR str[MAX_PATH],*str2;
|
TCHAR str[MAX_PATH],*str2;
|
||||||
lstrcpy(str,g_sdata.input_script);
|
lstrcpy(str,g_sdata.input_script);
|
||||||
str2=my_strrchr(str,_T('\\'));
|
str2=_tcsrchr(str,_T('\\'));
|
||||||
if(str2!=NULL) *(str2+1)=0;
|
if(str2!=NULL) *(str2+1)=0;
|
||||||
ShellExecute(g_sdata.hwnd,_T("open"),str,NULL,NULL,SW_SHOWNORMAL);
|
ShellExecute(g_sdata.hwnd,_T("open"),str,NULL,NULL,SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
@ -656,7 +656,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
case IDM_FIND:
|
case IDM_FIND:
|
||||||
{
|
{
|
||||||
if (!g_find.uFindReplaceMsg) g_find.uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
|
if (!g_find.uFindReplaceMsg) g_find.uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
|
||||||
my_memset(&g_find.fr, 0, sizeof(FINDREPLACE));
|
memset(&g_find.fr, 0, sizeof(FINDREPLACE));
|
||||||
g_find.fr.lStructSize = sizeof(FINDREPLACE);
|
g_find.fr.lStructSize = sizeof(FINDREPLACE);
|
||||||
g_find.fr.hwndOwner = hwndDlg;
|
g_find.fr.hwndOwner = hwndDlg;
|
||||||
g_find.fr.Flags = FR_NOUPDOWN;
|
g_find.fr.Flags = FR_NOUPDOWN;
|
||||||
|
@ -743,7 +743,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char szBuf[1024];
|
TCHAR szBuf[1024];
|
||||||
DWORD dwRead = 1;
|
DWORD dwRead = 1;
|
||||||
DWORD dwExit = !STILL_ACTIVE;
|
DWORD dwExit = !STILL_ACTIVE;
|
||||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||||
|
@ -986,7 +986,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if(n > 0) {
|
if(n > 0) {
|
||||||
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
||||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
|
||||||
if(my_strstr(buf,_T(" ")) || my_strstr(buf,_T("\t"))) {
|
if(_tcsstr(buf,_T(" ")) || _tcsstr(buf,_T("\t"))) {
|
||||||
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
|
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
|
||||||
GlobalFree(buf);
|
GlobalFree(buf);
|
||||||
break;
|
break;
|
||||||
|
@ -1028,7 +1028,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if(n > 0) {
|
if(n > 0) {
|
||||||
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
||||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
||||||
TCHAR *p = my_strstr(buf,_T("="));
|
TCHAR *p = _tcsstr(buf,_T("="));
|
||||||
if(p) {
|
if(p) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
||||||
*p=0;
|
*p=0;
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2002 Robert Rainwater
|
|
||||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include <windows.h>
|
|
||||||
#include "noclib.h"
|
|
||||||
|
|
||||||
// kickik's clib methods
|
|
||||||
char *my_strrchr(const char *string, int c) {
|
|
||||||
for (int i=lstrlen(string); i>=0; i--)
|
|
||||||
if (string[i]==c) return (char*)&string[i];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *my_strstr(char *i, char *s) {
|
|
||||||
if (lstrlen(i)>=lstrlen(s)) while (i[lstrlen(s)-1]) {
|
|
||||||
int l=lstrlen(s)+1;
|
|
||||||
char *ii=i;
|
|
||||||
char *is=s;
|
|
||||||
while (--l>0) {
|
|
||||||
if (*ii != *is) break;
|
|
||||||
ii++;
|
|
||||||
is++;
|
|
||||||
}
|
|
||||||
if (l==0) return i;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *my_memset(void *dest, int c, size_t count) {
|
|
||||||
for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
// iceman_k's clib methods
|
|
||||||
int lstrncmp(char *s1, const char *s2, int chars)
|
|
||||||
{
|
|
||||||
while ((chars > 0) && (*s1) && (*s2) && (*(s1) == *(s2))) chars--, s1++, s2++;
|
|
||||||
if ((chars == 0) || (*s1 == *s2)) return 0;
|
|
||||||
return (*s1 - *s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int lstrncmpi(char *s1, const char *s2, int chars)
|
|
||||||
{
|
|
||||||
while (chars-- && *s1 && *s2)
|
|
||||||
{
|
|
||||||
char ss1=*s1++;
|
|
||||||
char ss2=*s2++;
|
|
||||||
if (ss1>='a' && ss1 <= 'z') ss1+='A'-'a';
|
|
||||||
if (ss2>='a' && ss2 <= 'z') ss2+='A'-'a';
|
|
||||||
if (ss1 != ss2) return ss1-ss2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2002 Robert Rainwater
|
|
||||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#ifndef NOCLIB_H
|
|
||||||
#define NOCLIB_H
|
|
||||||
|
|
||||||
// kickik's clib methods
|
|
||||||
char *my_strstr(char *i, char *s);
|
|
||||||
char *my_strrchr(const char *string, int c);
|
|
||||||
void *my_memset(void *dest, int c, size_t count);
|
|
||||||
|
|
||||||
// iceman_k's clib methods
|
|
||||||
int lstrncmp(char *s1, const char *s2, int chars);
|
|
||||||
int lstrncmpi(char *s1, const char *s2, int chars);
|
|
||||||
#endif
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "noclib.h"
|
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
#include "../ExDLL/nsis_tchar.h"
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
|
|
||||||
|
@ -133,7 +132,7 @@ void UpdateToolBarCompressorButton()
|
||||||
TCHAR temp[64]; // increased to 64. Hit limit 08/20/2007 -- Jim Park.
|
TCHAR temp[64]; // increased to 64. Hit limit 08/20/2007 -- Jim Park.
|
||||||
TOOLINFO ti;
|
TOOLINFO ti;
|
||||||
|
|
||||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
memset(&ti, 0, sizeof(TOOLINFO));
|
||||||
|
|
||||||
if(g_sdata.compressor >= COMPRESSOR_SCRIPT && g_sdata.compressor <= COMPRESSOR_BEST) {
|
if(g_sdata.compressor >= COMPRESSOR_SCRIPT && g_sdata.compressor <= COMPRESSOR_BEST) {
|
||||||
iBitmap = compressor_bitmaps[(int)g_sdata.compressor];
|
iBitmap = compressor_bitmaps[(int)g_sdata.compressor];
|
||||||
|
@ -146,7 +145,7 @@ void UpdateToolBarCompressorButton()
|
||||||
IDS_COMPRESSOR,
|
IDS_COMPRESSOR,
|
||||||
temp,
|
temp,
|
||||||
COUNTOF(temp));
|
COUNTOF(temp));
|
||||||
my_memset(szBuffer, 0, sizeof(szBuffer));
|
memset(szBuffer, 0, sizeof(szBuffer));
|
||||||
lstrcat(szBuffer,temp);
|
lstrcat(szBuffer,temp);
|
||||||
lstrcat(szBuffer,_T(" ["));
|
lstrcat(szBuffer,_T(" ["));
|
||||||
LoadString(g_sdata.hInstance,
|
LoadString(g_sdata.hInstance,
|
||||||
|
@ -174,7 +173,7 @@ void AddToolBarButtonTooltip(int id, int iString)
|
||||||
TCHAR szBuffer[64];
|
TCHAR szBuffer[64];
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
memset(&ti, 0, sizeof(TOOLINFO));
|
||||||
|
|
||||||
SendMessage(g_toolbar.hwnd, TB_GETITEMRECT, id, (LPARAM) (LPRECT) &rect);
|
SendMessage(g_toolbar.hwnd, TB_GETITEMRECT, id, (LPARAM) (LPRECT) &rect);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "noclib.h"
|
|
||||||
|
|
||||||
#include "jnetlib/httpget.h"
|
#include "jnetlib/httpget.h"
|
||||||
#include "../ExDLL/nsis_tchar.h"
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
|
@ -62,14 +61,14 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
|
|
||||||
if (getProxyInfo(pbuf))
|
if (getProxyInfo(pbuf))
|
||||||
{
|
{
|
||||||
p=my_strstr(pbuf,"http=");
|
p=strstr(pbuf,"http=");
|
||||||
if (!p) p=pbuf;
|
if (!p) p=pbuf;
|
||||||
else {
|
else {
|
||||||
p+=5;
|
p+=5;
|
||||||
}
|
}
|
||||||
char *tp=my_strstr(p,";");
|
char *tp=strstr(p,";");
|
||||||
if (tp) *tp=0;
|
if (tp) *tp=0;
|
||||||
char *p2=my_strstr(p,"=");
|
char *p2=strstr(p,"=");
|
||||||
if (p2) p=0; // we found the wrong proxy
|
if (p2) p=0; // we found the wrong proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
void Update() {
|
void Update() {
|
||||||
DWORD dwThreadId;
|
DWORD dwThreadId;
|
||||||
|
|
||||||
if (my_strstr(g_sdata.brandingv,_T("cvs")))
|
if (_tcsstr(g_sdata.brandingv,_T("cvs")))
|
||||||
{
|
{
|
||||||
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
|
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
#include "noclib.h"
|
#include <shlwapi.h>
|
||||||
|
|
||||||
#ifdef _countof
|
#ifdef _countof
|
||||||
#define COUNTOF _countof
|
#define COUNTOF _countof
|
||||||
|
@ -60,13 +60,13 @@ int SetArgv(const TCHAR *cmdLine, int *argc, TCHAR ***argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argSpaceSize = size * sizeof(TCHAR *) + lstrlen(cmdLine) + 1;
|
argSpaceSize = size * sizeof(TCHAR *) + (lstrlen(cmdLine) + 1) * sizeof(TCHAR);
|
||||||
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
|
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
|
||||||
if (!argSpace)
|
if (!argSpace)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*argv = (TCHAR **) argSpace;
|
*argv = (TCHAR **) argSpace;
|
||||||
argSpace += size * sizeof(TCHAR *);
|
argSpace = (TCHAR *) ((*argv)+size);
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
p = cmdLine;
|
p = cmdLine;
|
||||||
|
@ -241,13 +241,13 @@ void SetCompressorStats()
|
||||||
DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT);
|
DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT);
|
||||||
lstrcat(g_sdata.compressor_stats,buf);
|
lstrcat(g_sdata.compressor_stats,buf);
|
||||||
|
|
||||||
if(!lstrncmp(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
|
if(!StrCmpN(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT);
|
DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT);
|
||||||
if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
|
if(!StrCmpN(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
|
||||||
found = true;
|
found = true;
|
||||||
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
|
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
|
||||||
lstrcat(g_sdata.compressor_stats,buf);
|
lstrcat(g_sdata.compressor_stats,buf);
|
||||||
|
@ -622,7 +622,7 @@ int InitBranding() {
|
||||||
|
|
||||||
void InitTooltips(HWND h) {
|
void InitTooltips(HWND h) {
|
||||||
if (h == NULL) return;
|
if (h == NULL) return;
|
||||||
my_memset(&g_tip,0,sizeof(NTOOLTIP));
|
memset(&g_tip,0,sizeof(NTOOLTIP));
|
||||||
g_tip.tip_p = h;
|
g_tip.tip_p = h;
|
||||||
INITCOMMONCONTROLSEX icx;
|
INITCOMMONCONTROLSEX icx;
|
||||||
icx.dwSize = sizeof(icx);
|
icx.dwSize = sizeof(icx);
|
||||||
|
@ -668,7 +668,7 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
void ShowDocs() {
|
void ShowDocs() {
|
||||||
TCHAR pathf[MAX_PATH],*path;
|
TCHAR pathf[MAX_PATH],*path;
|
||||||
GetModuleFileName(NULL,pathf,sizeof(pathf));
|
GetModuleFileName(NULL,pathf,sizeof(pathf));
|
||||||
path=my_strrchr(pathf,_T('\\'));
|
path=_tcsrchr(pathf,_T('\\'));
|
||||||
if(path!=NULL) *path=0;
|
if(path!=NULL) *path=0;
|
||||||
lstrcat(pathf,LOCALDOCS);
|
lstrcat(pathf,LOCALDOCS);
|
||||||
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
||||||
|
@ -749,7 +749,7 @@ void PushMRUFile(TCHAR* fname)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_memset(full_file_name,0,sizeof(full_file_name));
|
memset(full_file_name,0,sizeof(full_file_name));
|
||||||
rv = GetFullPathName(fname,COUNTOF(full_file_name),full_file_name,NULL);
|
rv = GetFullPathName(fname,COUNTOF(full_file_name),full_file_name,NULL);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -783,19 +783,19 @@ void BuildMRUMenus()
|
||||||
|
|
||||||
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
||||||
if(g_mru_list[i][0]) {
|
if(g_mru_list[i][0]) {
|
||||||
my_memset(buf,0,sizeof(buf));
|
memset(buf,0,sizeof(buf));
|
||||||
my_memset(&mii, 0, sizeof(mii));
|
memset(&mii, 0, sizeof(mii));
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
||||||
mii.wID = IDM_MRU_FILE+i;
|
mii.wID = IDM_MRU_FILE+i;
|
||||||
mii.fType = MFT_STRING;
|
mii.fType = MFT_STRING;
|
||||||
wsprintf(buf, _T("&%d "), i + 1);
|
wsprintf(buf, _T("&%d "), i + 1);
|
||||||
if(lstrlen(g_mru_list[i]) > MRU_DISPLAY_LENGTH) {
|
if(lstrlen(g_mru_list[i]) > MRU_DISPLAY_LENGTH) {
|
||||||
TCHAR *p = my_strrchr(g_mru_list[i],_T('\\'));
|
TCHAR *p = _tcsrchr(g_mru_list[i],_T('\\'));
|
||||||
if(p) {
|
if(p) {
|
||||||
p++;
|
p++;
|
||||||
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
|
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
|
||||||
my_memset(buf2,0,sizeof(buf2));
|
memset(buf2,0,sizeof(buf2));
|
||||||
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
|
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
|
||||||
lstrcat(buf2,_T("..."));
|
lstrcat(buf2,_T("..."));
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ void BuildMRUMenus()
|
||||||
}
|
}
|
||||||
|
|
||||||
hMenu = g_sdata.toolsSubmenu;
|
hMenu = g_sdata.toolsSubmenu;
|
||||||
my_memset(&mii, 0, sizeof(mii));
|
memset(&mii, 0, sizeof(mii));
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_STATE;
|
mii.fMask = MIIM_STATE;
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,12 @@
|
||||||
|
|
||||||
Unicode support by Jim Park -- 08/17/2007
|
Unicode support by Jim Park -- 08/17/2007
|
||||||
*/
|
*/
|
||||||
|
#include "makensisw.h"
|
||||||
#define REALSTR(x) #x
|
#define REALSTR(x) #x
|
||||||
#define STR(x) REALSTR(x)
|
#define STR(x) REALSTR(x)
|
||||||
|
|
||||||
#ifdef RELEASE
|
#ifdef RELEASE
|
||||||
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
|
const TCHAR *NSISW_VERSION = _T("MakeNSISW ") _T(STR(RELEASE)) _T(" (NSIS Compiler Interface)");
|
||||||
#else
|
#else
|
||||||
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
|
const TCHAR *NSISW_VERSION = _T("MakeNSISW ") __TDATE__;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,9 +18,10 @@ libs = Split("""
|
||||||
""")
|
""")
|
||||||
|
|
||||||
Import('BuildUtil env')
|
Import('BuildUtil env')
|
||||||
|
Import('_tWinMain')
|
||||||
|
|
||||||
code = env.Object(code)
|
code = env.Object(code)
|
||||||
|
|
||||||
for ui in uis:
|
for ui in uis:
|
||||||
ui = BuildUtil(ui, [code], libs, entry = 'WinMain', res = ui + '.rc', contrib = True, path = 'UIs')
|
ui = BuildUtil(ui, [code], libs, entry = _tWinMain, res = ui + '.rc', contrib = True, path = 'UIs')
|
||||||
env.Alias('UIs', ui)
|
env.Alias('UIs', ui)
|
||||||
|
|
|
@ -188,17 +188,30 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn)
|
||||||
int nf=0, nkb=0;
|
int nf=0, nkb=0;
|
||||||
g_extracting=1;
|
g_extracting=1;
|
||||||
do {
|
do {
|
||||||
TCHAR filename[MAX_PATH];
|
char filenameA[MAX_PATH];
|
||||||
unz_file_info info;
|
unz_file_info info;
|
||||||
|
|
||||||
unzGetCurrentFileInfo(f,&info,filename,sizeof(filename),NULL,0,NULL,0);
|
// ZREAD uses byte size, not TCHAR length.
|
||||||
|
unzGetCurrentFileInfo(f,&info,filenameA,sizeof(filenameA),NULL,0,NULL,0);
|
||||||
|
|
||||||
// was zip created on MS-DOS/Windows?
|
// was zip created on MS-DOS/Windows?
|
||||||
if ((info.version & 0xFF00) == 0)
|
if ((info.version & 0xFF00) == 0)
|
||||||
{
|
{
|
||||||
OemToCharBuff(filename, filename, strlen(filename));
|
OemToCharBuffA(filenameA, filenameA, strlen(filenameA));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
TCHAR filename[MAX_PATH];
|
||||||
|
if (MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH) == 0)
|
||||||
|
{
|
||||||
|
if (f) unzClose(f);
|
||||||
|
MessageBox(hwndDlg,_T("Error converting filename to Unicode"), g_errcaption, MB_OK|MB_ICONSTOP);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
char* filename = filenameA;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (filename[0] &&
|
if (filename[0] &&
|
||||||
filename[_tcsclen(filename)-1] != _T('\\') &&
|
filename[_tcsclen(filename)-1] != _T('\\') &&
|
||||||
filename[_tcsclen(filename)-1] != _T('/'))
|
filename[_tcsclen(filename)-1] != _T('/'))
|
||||||
|
@ -485,7 +498,11 @@ void makeEXE(HWND hwndDlg)
|
||||||
TCHAR buf[2048];
|
TCHAR buf[2048];
|
||||||
GetTempPath(MAX_PATH,buf);
|
GetTempPath(MAX_PATH,buf);
|
||||||
GetTempFileName(buf,_T("zne"),0,nsifilename);
|
GetTempFileName(buf,_T("zne"),0,nsifilename);
|
||||||
FILE *fp=fopen(nsifilename,_T("w"));
|
#ifdef _UNICODE
|
||||||
|
FILE *fp=_tfopen(nsifilename,_T("w, ccs=UNICODE")); // generate a Unicode .NSI file
|
||||||
|
#else
|
||||||
|
FILE *fp=_tfopen(nsifilename,_T("w"));
|
||||||
|
#endif
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
MessageBox(hwndDlg,_T("Error writing .NSI file"),g_errcaption,MB_OK|MB_ICONSTOP);
|
MessageBox(hwndDlg,_T("Error writing .NSI file"),g_errcaption,MB_OK|MB_ICONSTOP);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef _ZLIBIOAPI_H
|
#ifndef _ZLIBIOAPI_H
|
||||||
#define _ZLIBIOAPI_H
|
#define _ZLIBIOAPI_H
|
||||||
|
|
||||||
#include "../../ExDLL/nsis_tchar.h"
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||||
|
|
|
@ -94,7 +94,7 @@ To compile the documentation as a CHM file, hhc.exe must be in the PATH. It is a
|
||||||
|
|
||||||
To build NSIS Menu, install \W{http://www.wxwidgets.org/}{wxWidgets 2.8}, create an environment variable named \c{WXWIN} containing the path to the installation directory of wxWidgets, run \c{Contrib\\NSIS Menu\\wx\\wxbuild.bat} and build NSIS as usual.
|
To build NSIS Menu, install \W{http://www.wxwidgets.org/}{wxWidgets 2.8}, create an environment variable named \c{WXWIN} containing the path to the installation directory of wxWidgets, run \c{Contrib\\NSIS Menu\\wx\\wxbuild.bat} and build NSIS as usual.
|
||||||
|
|
||||||
\\<b\\>Important notes for Microsoft Visual C++ 6.0 users:\\</b\\> The latest \W{http://www.microsoft.com/msdownload/platformsdk/sdkupdate/}{Platform SDK} must be installed before building. Because of flaws in the libraries distributed with Microsoft Visual C++ 6.0, not installing the Platform SDK will result in crashes when using the \R{copyfiles}{CopyFiles} command. See \W{http://forums.winamp.com/showthread.php?s=&threadid=131964}{this forum topic} for more information. Installing the \W{http://msdn.microsoft.com/vstudio/aa718349.aspx}{Processor Pack} is highly recommended xto decrease the size of the installer overhead.
|
\\<b\\>Important notes for Microsoft Visual C++ 6.0 users:\\</b\\> The latest \W{http://www.microsoft.com/msdownload/platformsdk/sdkupdate/}{Platform SDK} must be installed before building. Because of flaws in the libraries distributed with Microsoft Visual C++ 6.0, not installing the Platform SDK will result in crashes when using the \R{copyfiles}{CopyFiles} command. See \W{http://forums.winamp.com/showthread.php?s=&threadid=131964}{this forum topic} for more information. Installing the \W{http://msdn.microsoft.com/vstudio/aa718349.aspx}{Processor Pack} is highly recommended to decrease the size of the installer overhead.
|
||||||
|
|
||||||
\H{build_posix} Building on POSIX
|
\H{build_posix} Building on POSIX
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ def generate(env):
|
||||||
env['REGSVRFLAGS'] = '/s '
|
env['REGSVRFLAGS'] = '/s '
|
||||||
env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS $TARGET'
|
env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS $TARGET'
|
||||||
|
|
||||||
env['MSVS_VERSION'] = '8.0'
|
env['MSVS_VERSION'] = '7.1'
|
||||||
|
|
||||||
|
|
||||||
def exists(env):
|
def exists(env):
|
||||||
|
|
16
SConstruct
16
SConstruct
|
@ -185,11 +185,13 @@ if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']:
|
||||||
# Need this early for the config header files to be placed in
|
# Need this early for the config header files to be placed in
|
||||||
|
|
||||||
if defenv['UNICODE']:
|
if defenv['UNICODE']:
|
||||||
|
_tWinMain = 'wWinMain'
|
||||||
if defenv['DEBUG']:
|
if defenv['DEBUG']:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/udebug')
|
defenv.Replace(BUILD_PREFIX = 'build/udebug')
|
||||||
else:
|
else:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/urelease')
|
defenv.Replace(BUILD_PREFIX = 'build/urelease')
|
||||||
else:
|
else:
|
||||||
|
_tWinMain = 'WinMain'
|
||||||
if defenv['DEBUG']:
|
if defenv['DEBUG']:
|
||||||
defenv.Replace(BUILD_PREFIX = 'build/debug')
|
defenv.Replace(BUILD_PREFIX = 'build/debug')
|
||||||
else:
|
else:
|
||||||
|
@ -454,7 +456,7 @@ def build_installer(target, source, env):
|
||||||
AlwaysBuild(cmd)
|
AlwaysBuild(cmd)
|
||||||
# Comment out the following if you want to see the installation directory
|
# Comment out the following if you want to see the installation directory
|
||||||
# after the build is finished.
|
# after the build is finished.
|
||||||
AlwaysBuild(env.AddPostAction(cmd, Delete('$INSTDISTDIR')))
|
#AlwaysBuild(env.AddPostAction(cmd, Delete('$INSTDISTDIR')))
|
||||||
env.Alias('dist-installer', cmd)
|
env.Alias('dist-installer', cmd)
|
||||||
|
|
||||||
installer_target = defenv.Command('nsis-${VERSION}-setup${DISTSUFFIX}.exe',
|
installer_target = defenv.Command('nsis-${VERSION}-setup${DISTSUFFIX}.exe',
|
||||||
|
@ -474,15 +476,9 @@ defenv.Alias('dist', ['dist-zip', 'dist-installer'])
|
||||||
for d in doc:
|
for d in doc:
|
||||||
if d in defenv['SKIPDOC']:
|
if d in defenv['SKIPDOC']:
|
||||||
continue
|
continue
|
||||||
if defenv['UNICODE']:
|
defenv.DistributeDoc(d)
|
||||||
defenv.DistributeDoc('Unicode/' + d)
|
|
||||||
else:
|
|
||||||
defenv.DistributeDoc(d)
|
|
||||||
|
|
||||||
if defenv['UNICODE']:
|
defenv.DistributeConf('nsisconf.nsh')
|
||||||
defenv.DistributeConf('Unicode/nsisconf.nsh')
|
|
||||||
else:
|
|
||||||
defenv.DistributeConf('nsisconf.nsh')
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
####### Stubs ###
|
####### Stubs ###
|
||||||
|
@ -678,7 +674,7 @@ for util in utils:
|
||||||
|
|
||||||
path = 'Contrib/' + util
|
path = 'Contrib/' + util
|
||||||
build_dir = '$BUILD_PREFIX/' + util
|
build_dir = '$BUILD_PREFIX/' + util
|
||||||
exports = {'BuildUtil' : BuildUtil, 'BuildUtilEnv' : BuildUtilEnv, 'env' : util_env}
|
exports = {'BuildUtil' : BuildUtil, 'BuildUtilEnv' : BuildUtilEnv, 'env' : util_env, '_tWinMain' : _tWinMain}
|
||||||
|
|
||||||
defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports)
|
defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports)
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,7 @@ void CDialogTemplate::SetFont(TCHAR* szFaceName, WORD wFontSize) {
|
||||||
m_bCharset = DEFAULT_CHARSET;
|
m_bCharset = DEFAULT_CHARSET;
|
||||||
m_dwStyle |= DS_SETFONT;
|
m_dwStyle |= DS_SETFONT;
|
||||||
if (m_szFont) delete [] m_szFont;
|
if (m_szFont) delete [] m_szFont;
|
||||||
m_szFont = winchar_fromansi(szFaceName, m_uCodePage);
|
m_szFont = winchar_fromTchar(szFaceName, m_uCodePage);
|
||||||
m_sFontSize = wFontSize;
|
m_sFontSize = wFontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void Plugins::FindCommands(const tstring &path, bool displayInfo)
|
||||||
|
|
||||||
struct NSISException : public std::runtime_error
|
struct NSISException : public std::runtime_error
|
||||||
{
|
{
|
||||||
NSISException(const string& msg) : std::runtime_error(msg) {}
|
NSISException(const tstring& msg) : std::runtime_error(string(TtoCString(msg))) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -82,7 +82,7 @@ void read_file(const tstring& filename, vector<unsigned char>& data) {
|
||||||
ifstream file(filename.c_str(), ios::binary);
|
ifstream file(filename.c_str(), ios::binary);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw NSISException("Can't open file '" + filename + "'");
|
throw NSISException(_T("Can't open file '") + filename + _T("'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the file size
|
// get the file size
|
||||||
|
@ -93,7 +93,7 @@ void read_file(const tstring& filename, vector<unsigned char>& data) {
|
||||||
file.read(reinterpret_cast<char*>(&data[0]), filesize);
|
file.read(reinterpret_cast<char*>(&data[0]), filesize);
|
||||||
|
|
||||||
if (size_t(file.tellg()) != filesize) { // ifstream::eof doesn't return true here
|
if (size_t(file.tellg()) != filesize) { // ifstream::eof doesn't return true here
|
||||||
throw NSISException("Couldn't read entire file '" + filename + "'");
|
throw NSISException(_T("Couldn't read entire file '") + filename + _T("'"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void Plugins::GetExports(const tstring &pathToDll, bool displayInfo)
|
||||||
for (DWORD j = 0; j < FIX_ENDIAN_INT32(exports->NumberOfNames); j++)
|
for (DWORD j = 0; j < FIX_ENDIAN_INT32(exports->NumberOfNames); j++)
|
||||||
{
|
{
|
||||||
const string name = string((char*)exports + FIX_ENDIAN_INT32(names[j]) - ExportDirVA);
|
const string name = string((char*)exports + FIX_ENDIAN_INT32(names[j]) - ExportDirVA);
|
||||||
const tstring signature = dllName + _T("::") + name;
|
const tstring signature = dllName + _T("::") + tstring(CtoTString(name));
|
||||||
const tstring lcsig = lowercase(signature);
|
const tstring lcsig = lowercase(signature);
|
||||||
m_command_to_path[lcsig] = pathToDll;
|
m_command_to_path[lcsig] = pathToDll;
|
||||||
m_command_lowercase_to_command[lcsig] = signature;
|
m_command_lowercase_to_command[lcsig] = signature;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -114,19 +114,10 @@ public:
|
||||||
CResourceEditor(BYTE* pbPE, int iSize, bool bKeepData = true);
|
CResourceEditor(BYTE* pbPE, int iSize, bool bKeepData = true);
|
||||||
virtual ~CResourceEditor();
|
virtual ~CResourceEditor();
|
||||||
|
|
||||||
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource (TCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
bool UpdateResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
BYTE* GetResource (TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
bool UpdateResourceW(WORD szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
int GetResourceSize (TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
bool UpdateResourceW(WCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
DWORD GetResourceOffset(TCHAR* szType, WORD szName, LANGID wLanguage);
|
||||||
bool UpdateResourceA(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
|
||||||
bool UpdateResourceA(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
|
||||||
bool UpdateResourceA(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
|
||||||
BYTE* GetResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
|
||||||
BYTE* GetResourceA(char* szType, char* szName, LANGID wLanguage);
|
|
||||||
int GetResourceSizeW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
|
||||||
int GetResourceSizeA(char* szType, char* szName, LANGID wLanguage);
|
|
||||||
DWORD GetResourceOffsetW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
|
||||||
DWORD GetResourceOffsetA(char* szType, char* szName, LANGID wLanguage);
|
|
||||||
void FreeResource(BYTE* pbResource);
|
void FreeResource(BYTE* pbResource);
|
||||||
|
|
||||||
// The section name must be in ASCII.
|
// The section name must be in ASCII.
|
||||||
|
@ -143,6 +134,11 @@ public:
|
||||||
DWORD *pdwResSecVA = NULL,
|
DWORD *pdwResSecVA = NULL,
|
||||||
DWORD *pdwSectionIndex = NULL
|
DWORD *pdwSectionIndex = NULL
|
||||||
);
|
);
|
||||||
|
private:
|
||||||
|
bool UpdateResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
|
BYTE* GetResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
||||||
|
int GetResourceSizeW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
||||||
|
DWORD GetResourceOffsetW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BYTE* m_pbPE;
|
BYTE* m_pbPE;
|
||||||
|
|
|
@ -57,7 +57,7 @@ CVersionStrigList::~CVersionStrigList()
|
||||||
int CVersionStrigList::add(LANGID langid, int codepage)
|
int CVersionStrigList::add(LANGID langid, int codepage)
|
||||||
{
|
{
|
||||||
TCHAR Buff[10];
|
TCHAR Buff[10];
|
||||||
sprintf(Buff, _T("%04x"), langid);
|
_stprintf(Buff, _T("%04x"), langid);
|
||||||
int pos = SortedStringListND<struct version_string_list>::add(Buff);
|
int pos = SortedStringListND<struct version_string_list>::add(Buff);
|
||||||
if (pos == -1) return false;
|
if (pos == -1) return false;
|
||||||
((struct version_string_list*)gr.get())[pos].pChildStrings = new DefineList;
|
((struct version_string_list*)gr.get())[pos].pChildStrings = new DefineList;
|
||||||
|
@ -87,7 +87,7 @@ DefineList* CVersionStrigList::get_strings(int idx)
|
||||||
int CVersionStrigList::find(LANGID lang_id, int codepage)
|
int CVersionStrigList::find(LANGID lang_id, int codepage)
|
||||||
{
|
{
|
||||||
TCHAR Buff[10];
|
TCHAR Buff[10];
|
||||||
sprintf(Buff, _T("%04x"), lang_id);
|
_stprintf(Buff, _T("%04x"), lang_id);
|
||||||
return SortedStringListND<struct version_string_list>::find(Buff);
|
return SortedStringListND<struct version_string_list>::find(Buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +218,8 @@ void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
|
||||||
PadStream (stringInfoStream);
|
PadStream (stringInfoStream);
|
||||||
|
|
||||||
p = stringInfoStream.getlen();
|
p = stringInfoStream.getlen();
|
||||||
KeyName = winchar_fromansi(pChildStrings->getname(i), codepage);
|
KeyName = winchar_fromTchar(pChildStrings->getname(i), codepage);
|
||||||
KeyValue = winchar_fromansi(pChildStrings->getvalue(i), codepage);
|
KeyValue = winchar_fromTchar(pChildStrings->getvalue(i), codepage);
|
||||||
SaveVersionHeader (stringInfoStream, 0, WORD(winchar_strlen(KeyValue) + 1), 1, KeyName, (void*)KeyValue);
|
SaveVersionHeader (stringInfoStream, 0, WORD(winchar_strlen(KeyValue) + 1), 1, KeyName, (void*)KeyValue);
|
||||||
delete [] KeyName;
|
delete [] KeyName;
|
||||||
delete [] KeyValue;
|
delete [] KeyValue;
|
||||||
|
|
|
@ -11,35 +11,24 @@
|
||||||
class WinCharTest : public CppUnit::TestFixture {
|
class WinCharTest : public CppUnit::TestFixture {
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE( WinCharTest );
|
CPPUNIT_TEST_SUITE( WinCharTest );
|
||||||
CPPUNIT_TEST( testFromAnsi );
|
CPPUNIT_TEST( testFromTchar );
|
||||||
CPPUNIT_TEST( testToAnsi );
|
|
||||||
CPPUNIT_TEST( testStrCpy );
|
CPPUNIT_TEST( testStrCpy );
|
||||||
CPPUNIT_TEST( testStrNCpy );
|
CPPUNIT_TEST( testStrNCpy );
|
||||||
CPPUNIT_TEST( testStrLen );
|
CPPUNIT_TEST( testStrLen );
|
||||||
CPPUNIT_TEST( testStrCmp );
|
CPPUNIT_TEST( testStrCmp );
|
||||||
CPPUNIT_TEST( testStrDup );
|
CPPUNIT_TEST( testStrDup );
|
||||||
CPPUNIT_TEST( testStoi );
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void testFromAnsi() {
|
void testFromTchar() {
|
||||||
WCHAR test[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
|
WCHAR test[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
|
||||||
WCHAR *dyn = winchar_fromansi("test");
|
WCHAR *dyn = winchar_fromTchar("test");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL( 0, memcmp(test, dyn, 5) );
|
CPPUNIT_ASSERT_EQUAL( 0, memcmp(test, dyn, 5) );
|
||||||
|
|
||||||
delete [] dyn;
|
delete [] dyn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testToAnsi() {
|
|
||||||
WCHAR test[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
|
|
||||||
char *dyn = winchar_toansi(test);
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL( 0, strcmp("test", dyn) );
|
|
||||||
|
|
||||||
delete [] dyn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void testStrCpy() {
|
void testStrCpy() {
|
||||||
WCHAR a[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
|
WCHAR a[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
|
||||||
WCHAR b[5];
|
WCHAR b[5];
|
||||||
|
@ -111,20 +100,6 @@ public:
|
||||||
delete [] b;
|
delete [] b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testStoi() {
|
|
||||||
srand(time(0));
|
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
{
|
|
||||||
int r = rand();
|
|
||||||
char s[128];
|
|
||||||
sprintf(s, "%d", r);
|
|
||||||
WCHAR *ws = winchar_fromansi(s);
|
|
||||||
CPPUNIT_ASSERT_EQUAL( r, winchar_stoi(ws) );
|
|
||||||
delete [] ws;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( WinCharTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( WinCharTest );
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ int CEXEBuild::AddVersionInfo()
|
||||||
warning(_T("Generating version information for language \"%04d-%s\" without standard key \"LegalCopyright\""), lang_id, lang_name);
|
warning(_T("Generating version information for language \"%04d-%s\" without standard key \"LegalCopyright\""), lang_id, lang_name);
|
||||||
|
|
||||||
rVersionInfo.ExportToStream(VerInfoStream, i);
|
rVersionInfo.ExportToStream(VerInfoStream, i);
|
||||||
res_editor->UpdateResourceA(RT_VERSION, 1, lang_id, (BYTE*)VerInfoStream.get(), VerInfoStream.getlen());
|
res_editor->UpdateResource(RT_VERSION, 1, lang_id, (BYTE*)VerInfoStream.get(), VerInfoStream.getlen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
|
@ -2073,7 +2073,7 @@ again:
|
||||||
SCRIPT_MSG(_T("Done!\n"));
|
SCRIPT_MSG(_T("Done!\n"));
|
||||||
|
|
||||||
#define REMOVE_ICON(id) if (disable_window_icon) { \
|
#define REMOVE_ICON(id) if (disable_window_icon) { \
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, id, NSIS_DEFAULT_LANG); \
|
||||||
if (dlg) { \
|
if (dlg) { \
|
||||||
CDialogTemplate dt(dlg,uDefCodePage); \
|
CDialogTemplate dt(dlg,uDefCodePage); \
|
||||||
res_editor->FreeResource(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
|
@ -2091,7 +2091,7 @@ again:
|
||||||
\
|
\
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = dt.Save(dwSize); \
|
dlg = dt.Save(dwSize); \
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||||
delete [] dlg; \
|
delete [] dlg; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -2102,43 +2102,43 @@ again:
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
#ifdef NSIS_CONFIG_LICENSEPAGE
|
#ifdef NSIS_CONFIG_LICENSEPAGE
|
||||||
if (!license_normal) {
|
if (!license_normal) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_LICENSE);
|
else REMOVE_ICON(IDD_LICENSE);
|
||||||
if (!license_fsrb) {
|
if (!license_fsrb) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE_FSRB, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE_FSRB, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_LICENSE_FSRB);
|
else REMOVE_ICON(IDD_LICENSE_FSRB);
|
||||||
if (!license_fscb) {
|
if (!license_fscb) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE_FSCB, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE_FSCB, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_LICENSE_FSCB);
|
else REMOVE_ICON(IDD_LICENSE_FSCB);
|
||||||
#endif // NSIS_CONFIG_LICENSEPAGE
|
#endif // NSIS_CONFIG_LICENSEPAGE
|
||||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||||
if (!selcom) {
|
if (!selcom) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_SELCOM, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_SELCOM, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
res_editor->UpdateResourceA(RT_BITMAP, IDB_BITMAP1, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_BITMAP, IDB_BITMAP1, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_SELCOM);
|
else REMOVE_ICON(IDD_SELCOM);
|
||||||
#endif // NSIS_CONFIG_COMPONENTPAGE
|
#endif // NSIS_CONFIG_COMPONENTPAGE
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_DIR, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_DIR, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_DIR);
|
else REMOVE_ICON(IDD_DIR);
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
if (!uninstconfirm) {
|
if (!uninstconfirm) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_UNINST, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_UNINST, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_UNINST);
|
else REMOVE_ICON(IDD_UNINST);
|
||||||
#endif // NSIS_CONFIG_UNINSTALL_SUPPORT
|
#endif // NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
if (!instlog) {
|
if (!instlog) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
else REMOVE_ICON(IDD_INSTFILES);
|
else REMOVE_ICON(IDD_INSTFILES);
|
||||||
if (!main) {
|
if (!main) {
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
if (!build_compress_whole && !build_crcchk)
|
if (!build_compress_whole && !build_crcchk)
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_VERIFY, NSIS_DEFAULT_LANG, 0, 0);
|
res_editor->UpdateResource(RT_DIALOG, IDD_VERIFY, NSIS_DEFAULT_LANG, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_MSG(_T("Done!\n"));
|
SCRIPT_MSG(_T("Done!\n"));
|
||||||
|
@ -2279,7 +2279,7 @@ int CEXEBuild::SetManifest()
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
|
||||||
// Saved directly as binary into the exe.
|
// Saved directly as binary into the exe.
|
||||||
res_editor->UpdateResourceA(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("Error setting manifest: %s\n"), CtoTString(err.what()));
|
ERROR_MSG(_T("Error setting manifest: %s\n"), CtoTString(err.what()));
|
||||||
|
|
|
@ -1174,13 +1174,13 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
break;
|
break;
|
||||||
case EW_READINISTR:
|
case EW_READINISTR:
|
||||||
{
|
{
|
||||||
DWORD errstr = CHAR4_TO_DWORD(_T('!'), _T('N'), _T('~'), 0);
|
TCHAR errstr[] = _T("!N~");
|
||||||
TCHAR *p=var0;
|
TCHAR *p=var0;
|
||||||
TCHAR *buf0=GetStringFromParm(0x01);
|
TCHAR *buf0=GetStringFromParm(0x01);
|
||||||
TCHAR *buf1=GetStringFromParm(0x12);
|
TCHAR *buf1=GetStringFromParm(0x12);
|
||||||
TCHAR *buf2=GetStringFromParm(-0x23);
|
TCHAR *buf2=GetStringFromParm(-0x23);
|
||||||
GetPrivateProfileString(buf0,buf1,(LPCTSTR)&errstr,p,NSIS_MAX_STRLEN-1,buf2);
|
GetPrivateProfileString(buf0,buf1,errstr,p,NSIS_MAX_STRLEN-1,buf2);
|
||||||
if (*(DWORD*)p == errstr)
|
if (lstrcmp(p, errstr) == 0)
|
||||||
{
|
{
|
||||||
exec_error++;
|
exec_error++;
|
||||||
p[0]=0;
|
p[0]=0;
|
||||||
|
|
|
@ -272,7 +272,6 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
// nsis strings
|
// nsis strings
|
||||||
|
|
||||||
typedef TCHAR NSIS_STRING[NSIS_MAX_STRLEN];
|
typedef TCHAR NSIS_STRING[NSIS_MAX_STRLEN];
|
||||||
|
|
||||||
// Settings common to both installers and uninstallers
|
// Settings common to both installers and uninstallers
|
||||||
|
|
|
@ -49,8 +49,8 @@ IconGroup load_icon_res(CResourceEditor* re, WORD id)
|
||||||
IconGroupHeader* header;
|
IconGroupHeader* header;
|
||||||
IconGroup result;
|
IconGroup result;
|
||||||
|
|
||||||
LPBYTE group = re->GetResourceA(
|
LPBYTE group = re->GetResource(
|
||||||
RT_GROUP_ICON, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG);
|
RT_GROUP_ICON, id, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
if (!group)
|
if (!group)
|
||||||
throw runtime_error("can't find icon group");
|
throw runtime_error("can't find icon group");
|
||||||
|
@ -69,7 +69,7 @@ IconGroup load_icon_res(CResourceEditor* re, WORD id)
|
||||||
|
|
||||||
WORD rsrc_id = FIX_ENDIAN_INT16(entry->wRsrcId);
|
WORD rsrc_id = FIX_ENDIAN_INT16(entry->wRsrcId);
|
||||||
|
|
||||||
icon.data = re->GetResourceA(RT_ICON, MAKEINTRESOURCE(rsrc_id), NSIS_DEFAULT_LANG);
|
icon.data = re->GetResource(RT_ICON, rsrc_id, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
if (!icon.data)
|
if (!icon.data)
|
||||||
{
|
{
|
||||||
|
@ -276,17 +276,17 @@ void set_icon(CResourceEditor* re, WORD wIconId, IconGroup icon1, IconGroup icon
|
||||||
size_t group_size = sizeof(IconGroupHeader) // header
|
size_t group_size = sizeof(IconGroupHeader) // header
|
||||||
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
||||||
|
|
||||||
re->UpdateResourceA(RT_GROUP_ICON, MAKEINTRESOURCE(wIconId), NSIS_DEFAULT_LANG, group1, group_size);
|
re->UpdateResource(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG, group1, group_size);
|
||||||
|
|
||||||
// delete old icons
|
// delete old icons
|
||||||
unsigned i = 1;
|
unsigned i = 1;
|
||||||
while (re->UpdateResourceA(RT_ICON, MAKEINTRESOURCE(i++), NSIS_DEFAULT_LANG, 0, 0));
|
while (re->UpdateResource(RT_ICON, i++, NSIS_DEFAULT_LANG, 0, 0));
|
||||||
|
|
||||||
// set new icons
|
// set new icons
|
||||||
IconGroup::size_type order_index;
|
IconGroup::size_type order_index;
|
||||||
for (order_index = 0; order_index < order.size(); order_index++)
|
for (order_index = 0; order_index < order.size(); order_index++)
|
||||||
{
|
{
|
||||||
DWORD size_index = order[order_index].size_index;
|
WORD size_index = order[order_index].size_index;
|
||||||
DWORD size = order[order_index].size;
|
DWORD size = order[order_index].size;
|
||||||
LPBYTE data = new BYTE[size];
|
LPBYTE data = new BYTE[size];
|
||||||
memset(data, 0, size);
|
memset(data, 0, size);
|
||||||
|
@ -297,7 +297,7 @@ void set_icon(CResourceEditor* re, WORD wIconId, IconGroup icon1, IconGroup icon
|
||||||
memcpy(data, icon->data, FIX_ENDIAN_INT32(icon->meta.dwRawSize));
|
memcpy(data, icon->data, FIX_ENDIAN_INT32(icon->meta.dwRawSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
re->UpdateResourceA(RT_ICON, MAKEINTRESOURCE(size_index + 1), NSIS_DEFAULT_LANG, data, size);
|
re->UpdateResource(RT_ICON, size_index + 1, NSIS_DEFAULT_LANG, data, size);
|
||||||
|
|
||||||
delete [] data;
|
delete [] data;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ int generate_unicons_offsets(LPBYTE exeHeader, size_t exeHeaderSize, LPBYTE unin
|
||||||
|
|
||||||
LPBYTE seeker = uninstIconData;
|
LPBYTE seeker = uninstIconData;
|
||||||
|
|
||||||
offset = re.GetResourceOffsetA(RT_GROUP_ICON, MAKEINTRESOURCE(wIconId), NSIS_DEFAULT_LANG);
|
offset = re.GetResourceOffset(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
size = FIX_ENDIAN_INT32(*(LPDWORD)seeker);
|
size = FIX_ENDIAN_INT32(*(LPDWORD)seeker);
|
||||||
seeker += sizeof(DWORD);
|
seeker += sizeof(DWORD);
|
||||||
|
@ -388,14 +388,14 @@ int generate_unicons_offsets(LPBYTE exeHeader, size_t exeHeaderSize, LPBYTE unin
|
||||||
|
|
||||||
while (*(LPDWORD)seeker)
|
while (*(LPDWORD)seeker)
|
||||||
{
|
{
|
||||||
offset = re.GetResourceOffsetA(RT_ICON, MAKEINTRESOURCE(icon_index), NSIS_DEFAULT_LANG);
|
offset = re.GetResourceOffset(RT_ICON, icon_index, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
if (offset > exeHeaderSize)
|
if (offset > exeHeaderSize)
|
||||||
{
|
{
|
||||||
throw runtime_error(_T("invalid icon offset (possibly compressed icon)"));
|
throw runtime_error("invalid icon offset (possibly compressed icon)");
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD real_size = re.GetResourceSizeA(RT_ICON, MAKEINTRESOURCE(icon_index), NSIS_DEFAULT_LANG);
|
DWORD real_size = re.GetResourceSize(RT_ICON, icon_index, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
size = FIX_ENDIAN_INT32(*(LPDWORD)seeker);
|
size = FIX_ENDIAN_INT32(*(LPDWORD)seeker);
|
||||||
seeker += sizeof(DWORD);
|
seeker += sizeof(DWORD);
|
||||||
|
|
|
@ -286,7 +286,7 @@ int StringsArray::set(int idx, const TCHAR *str)
|
||||||
|
|
||||||
int old = ((int*)offsets.get())[idx];
|
int old = ((int*)offsets.get())[idx];
|
||||||
|
|
||||||
((int*)offsets.get())[idx] = strings.add(str, strlen(str) + 1);
|
((int*)offsets.get())[idx] = strings.add(str, (_tcsclen(str)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
@ -696,14 +696,14 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
|
|
||||||
#define ADD_FONT(id) { \
|
#define ADD_FONT(id) { \
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, id, NSIS_DEFAULT_LANG); \
|
||||||
if (dlg) { \
|
if (dlg) { \
|
||||||
CDialogTemplate td(dlg); \
|
CDialogTemplate td(dlg); \
|
||||||
res_editor->FreeResource(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
td.SetFont(build_font, (WORD) build_font_size); \
|
td.SetFont(build_font, (WORD) build_font_size); \
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, id, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||||
delete [] dlg; \
|
delete [] dlg; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
|
|
||||||
#define ADD_FONT(id) { \
|
#define ADD_FONT(id) { \
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, id, NSIS_DEFAULT_LANG); \
|
||||||
if (dlg) { \
|
if (dlg) { \
|
||||||
CDialogTemplate td(dlg,lt[i].nlf.m_uCodePage); \
|
CDialogTemplate td(dlg,lt[i].nlf.m_uCodePage); \
|
||||||
res_editor->FreeResource(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
|
@ -766,7 +766,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
} \
|
} \
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id+cur_offset), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, id+cur_offset, NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||||
delete [] dlg; \
|
delete [] dlg; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
|
@ -2157,7 +2157,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
try {
|
try {
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
|
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG);
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG);
|
||||||
if (!dlg) throw runtime_error("IDD_INSTFILES doesn't exist!");
|
if (!dlg) throw runtime_error("IDD_INSTFILES doesn't exist!");
|
||||||
CDialogTemplate dt(dlg,uDefCodePage);
|
CDialogTemplate dt(dlg,uDefCodePage);
|
||||||
free(dlg);
|
free(dlg);
|
||||||
|
@ -2173,7 +2173,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
|
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
dlg = dt.Save(dwSize);
|
dlg = dt.Save(dwSize);
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG, dlg, dwSize);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||||
delete [] dlg;
|
delete [] dlg;
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
|
@ -2452,9 +2452,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
|
|
||||||
// Search for required items
|
// Search for required items
|
||||||
#define GET(x) dlg = uire->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(x), 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, uDefCodePage);
|
#define GET(x) dlg = uire->GetResource(RT_DIALOG, x, 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, uDefCodePage);
|
||||||
#define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);delete [] dlg;delete uire;return PS_ERROR;}
|
#define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG(_T("Error: Can't find %s (%u) in the custom UI!\n"), _T(#x), x);delete [] dlg;delete uire;return PS_ERROR;}
|
||||||
#define SAVE(x) dwSize = UIDlg.GetSize(); res_editor->UpdateResourceA(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); delete [] dlg;
|
#define SAVE(x) dwSize = UIDlg.GetSize(); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); delete [] dlg;
|
||||||
|
|
||||||
LPBYTE dlg = NULL;
|
LPBYTE dlg = NULL;
|
||||||
|
|
||||||
|
@ -2570,7 +2570,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
padding = line.gettoken_int(3);
|
padding = line.gettoken_int(3);
|
||||||
|
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG);
|
||||||
|
|
||||||
CDialogTemplate dt(dlg, uDefCodePage);
|
CDialogTemplate dt(dlg, uDefCodePage);
|
||||||
|
|
||||||
|
@ -2618,7 +2618,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
DWORD dwDlgSize;
|
DWORD dwDlgSize;
|
||||||
dlg = dt.Save(dwDlgSize);
|
dlg = dt.Save(dwDlgSize);
|
||||||
|
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize);
|
||||||
|
|
||||||
delete [] dlg;
|
delete [] dlg;
|
||||||
|
|
||||||
|
@ -2846,7 +2846,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
TCHAR *p=str;
|
TCHAR *p=str;
|
||||||
*p=0;
|
*p=0;
|
||||||
fgets(str,MAX_LINELENGTH,fp);
|
_fgetts(str,MAX_LINELENGTH,fp);
|
||||||
linecnt++;
|
linecnt++;
|
||||||
if (feof(fp)&&!str[0]) break;
|
if (feof(fp)&&!str[0]) break;
|
||||||
|
|
||||||
|
@ -3668,7 +3668,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
if (trim) try {
|
if (trim) try {
|
||||||
init_res_editor();
|
init_res_editor();
|
||||||
|
|
||||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
BYTE* dlg = res_editor->GetResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG);
|
||||||
CDialogTemplate td(dlg,uDefCodePage);
|
CDialogTemplate td(dlg,uDefCodePage);
|
||||||
free(dlg);
|
free(dlg);
|
||||||
|
|
||||||
|
@ -3695,7 +3695,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
|
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
dlg = td.Save(dwSize);
|
dlg = td.Save(dwSize);
|
||||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG, dlg, dwSize);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||||
res_editor->FreeResource(dlg);
|
res_editor->FreeResource(dlg);
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
|
|
|
@ -1,204 +1,205 @@
|
||||||
/*
|
/*
|
||||||
* strlist.cpp: Implementation of the StringList class.
|
* strlist.cpp: Implementation of the StringList class.
|
||||||
*
|
*
|
||||||
* This file is a part of NSIS.
|
* This file is a part of NSIS.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2009 Nullsoft and Contributors
|
* Copyright (C) 1999-2009 Nullsoft and Contributors
|
||||||
*
|
*
|
||||||
* Licensed under the zlib/libpng license (the "License");
|
* Licensed under the zlib/libpng license (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
*
|
*
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty.
|
* warranty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
|
||||||
int StringList::add(const TCHAR *str, int case_sensitive)
|
int StringList::add(const TCHAR *str, int case_sensitive)
|
||||||
{
|
{
|
||||||
int a=find(str,case_sensitive);
|
int a=find(str,case_sensitive);
|
||||||
if (a >= 0 && case_sensitive!=-1) return a;
|
if (a >= 0 && case_sensitive!=-1) return a;
|
||||||
return gr.add(str,strlen(str)+1);
|
return gr.add(str,(_tcsclen(str)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use 2 for case sensitive end-of-string matches too
|
// use 2 for case sensitive end-of-string matches too
|
||||||
int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) const // returns -1 if not found
|
int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) const // returns -1 if not found
|
||||||
{
|
{
|
||||||
const TCHAR *s=get();
|
const TCHAR *s=get();
|
||||||
int ml=getlen();
|
int ml=getlen();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
if (idx) *idx=0;
|
if (idx) *idx=0;
|
||||||
while (offs < ml)
|
while (offs < ml)
|
||||||
{
|
{
|
||||||
if ((case_sensitive && !strcmp(s+offs,str)) ||
|
if ((case_sensitive && !_tcscmp(s+offs,str)) ||
|
||||||
(!case_sensitive && !stricmp(s+offs,str)))
|
(!case_sensitive && !_tcsicmp(s+offs,str)))
|
||||||
{
|
{
|
||||||
return offs;
|
return offs;
|
||||||
}
|
}
|
||||||
if (case_sensitive==2 &&
|
if (case_sensitive==2 &&
|
||||||
strlen(str) < strlen(s+offs) && // check for end of string
|
_tcslen(str) < _tcslen(s+offs) && // check for end of string
|
||||||
!strcmp(s+offs+strlen(s+offs)-strlen(str),str))
|
!_tcscmp(s+offs+_tcslen(s+offs)-_tcslen(str),str))
|
||||||
{
|
{
|
||||||
return offs+strlen(s+offs)-strlen(str);
|
return offs+_tcslen(s+offs)-_tcslen(str);
|
||||||
}
|
}
|
||||||
offs+=strlen(s+offs)+1;
|
offs+=_tcslen(s+offs)+1;
|
||||||
if (idx) (*idx)++;
|
if (idx) (*idx)++;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringList::delbypos(int pos)
|
void StringList::delbypos(int pos)
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*)gr.get();
|
TCHAR *s=(TCHAR*)gr.get();
|
||||||
int len=strlen(s+pos)+1;
|
int len=_tcslen(s+pos)+1;
|
||||||
if (pos+len < gr.getlen()) memcpy(s+pos,s+pos+len,gr.getlen()-(pos+len));
|
if (pos+len < gr.getlen()) memcpy(s+pos,s+pos+len,gr.getlen()-(pos+len));
|
||||||
gr.resize(gr.getlen()-len);
|
gr.resize(gr.getlen()-len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringList::idx2pos(int idx) const
|
int StringList::idx2pos(int idx) const
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*)gr.get();
|
TCHAR *s=(TCHAR*)gr.get();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
if (idx>=0) while (offs < gr.getlen())
|
if (idx>=0) while (offs < gr.getlen())
|
||||||
{
|
{
|
||||||
if (cnt++ == idx) return offs;
|
if (cnt++ == idx) return offs;
|
||||||
offs+=strlen(s+offs)+1;
|
offs+=_tcslen(s+offs)+1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringList::getnum() const
|
int StringList::getnum() const
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*)gr.get();
|
TCHAR *s=(TCHAR*)gr.get();
|
||||||
int ml=gr.getlen();
|
int ml=gr.getlen();
|
||||||
int offs=0;
|
int offs=0;
|
||||||
int idx=0;
|
int idx=0;
|
||||||
while (offs < ml)
|
while (offs < ml)
|
||||||
{
|
{
|
||||||
offs+=strlen(s+offs)+1;
|
offs+=_tcslen(s+offs)+1;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TCHAR *StringList::get() const
|
const TCHAR *StringList::get() const
|
||||||
{
|
{
|
||||||
return (const TCHAR*)gr.get();
|
return (const TCHAR*)gr.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringList::getlen() const
|
int StringList::getlen() const
|
||||||
{
|
{
|
||||||
return gr.getlen();
|
return gr.getlen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==========
|
// ==========
|
||||||
// DefineList
|
// DefineList
|
||||||
// ==========
|
// ==========
|
||||||
|
|
||||||
DefineList::~DefineList()
|
DefineList::~DefineList()
|
||||||
{
|
{
|
||||||
struct define *s=(struct define*)gr.get();
|
struct define *s=(struct define*)gr.get();
|
||||||
int num=gr.getlen()/sizeof(struct define);
|
int num=gr.getlen()/sizeof(struct define);
|
||||||
|
|
||||||
for (int i=0; i<num; i++) {
|
for (int i=0; i<num; i++) {
|
||||||
free(s[i].value);
|
free(s[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefineList::add(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
int DefineList::add(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
||||||
{
|
{
|
||||||
int pos=SortedStringList<struct define>::add(name);
|
int pos=SortedStringList<struct define>::add(name);
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCHAR **newvalue=&(((struct define*)gr.get())[pos].value);
|
TCHAR **newvalue=&(((struct define*)gr.get())[pos].value);
|
||||||
*newvalue=(TCHAR*)malloc(strlen(value)+1);
|
size_t size_in_bytes = (_tcslen(value) + 1) * sizeof(TCHAR);
|
||||||
if (!(*newvalue))
|
*newvalue=(TCHAR*)malloc(size_in_bytes);
|
||||||
{
|
if (!(*newvalue))
|
||||||
extern FILE *g_output;
|
{
|
||||||
extern int g_display_errors;
|
extern FILE *g_output;
|
||||||
extern void quit();
|
extern int g_display_errors;
|
||||||
if (g_display_errors)
|
extern void quit();
|
||||||
{
|
if (g_display_errors)
|
||||||
fprintf(g_output,_T("\nInternal compiler error #12345: GrowBuf realloc/malloc(%lu) failed.\n"),(unsigned long)strlen(value)+1);
|
{
|
||||||
fflush(g_output);
|
_ftprintf(g_output,_T("\nInternal compiler error #12345: GrowBuf realloc/malloc(%lu) failed.\n"), (unsigned long) size_in_bytes);
|
||||||
}
|
fflush(g_output);
|
||||||
quit();
|
}
|
||||||
}
|
quit();
|
||||||
strcpy(*newvalue,value);
|
}
|
||||||
return 0;
|
_tcscpy(*newvalue,value);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
TCHAR *DefineList::find(const TCHAR *name)
|
|
||||||
{
|
TCHAR *DefineList::find(const TCHAR *name)
|
||||||
int v=SortedStringList<struct define>::find(name);
|
{
|
||||||
if (v==-1)
|
int v=SortedStringList<struct define>::find(name);
|
||||||
{
|
if (v==-1)
|
||||||
return NULL;
|
{
|
||||||
}
|
return NULL;
|
||||||
return ((struct define*)gr.get())[v].value;
|
}
|
||||||
}
|
return ((struct define*)gr.get())[v].value;
|
||||||
|
}
|
||||||
// returns 0 on success, 1 otherwise
|
|
||||||
int DefineList::del(const TCHAR *str)
|
// returns 0 on success, 1 otherwise
|
||||||
{
|
int DefineList::del(const TCHAR *str)
|
||||||
int pos=SortedStringList<struct define>::find(str);
|
{
|
||||||
if (pos==-1) return 1;
|
int pos=SortedStringList<struct define>::find(str);
|
||||||
|
if (pos==-1) return 1;
|
||||||
struct define *db=(struct define *)gr.get();
|
|
||||||
free(db[pos].value);
|
struct define *db=(struct define *)gr.get();
|
||||||
delbypos(pos);
|
free(db[pos].value);
|
||||||
|
delbypos(pos);
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
int DefineList::getnum()
|
|
||||||
{
|
int DefineList::getnum()
|
||||||
return gr.getlen()/sizeof(define);
|
{
|
||||||
}
|
return gr.getlen()/sizeof(define);
|
||||||
|
}
|
||||||
TCHAR *DefineList::getname(int num)
|
|
||||||
{
|
TCHAR *DefineList::getname(int num)
|
||||||
if ((unsigned int)getnum() <= (unsigned int)num)
|
{
|
||||||
return 0;
|
if ((unsigned int)getnum() <= (unsigned int)num)
|
||||||
return ((struct define*)gr.get())[num].name;
|
return 0;
|
||||||
}
|
return ((struct define*)gr.get())[num].name;
|
||||||
|
}
|
||||||
TCHAR *DefineList::getvalue(int num)
|
|
||||||
{
|
TCHAR *DefineList::getvalue(int num)
|
||||||
if ((unsigned int)getnum() <= (unsigned int)num)
|
{
|
||||||
return 0;
|
if ((unsigned int)getnum() <= (unsigned int)num)
|
||||||
return ((struct define*)gr.get())[num].value;
|
return 0;
|
||||||
}
|
return ((struct define*)gr.get())[num].value;
|
||||||
|
}
|
||||||
// ==============
|
|
||||||
// FastStringList
|
// ==============
|
||||||
// ==============
|
// FastStringList
|
||||||
|
// ==============
|
||||||
int FastStringList::add(const TCHAR *name, int case_sensitive/*=0*/)
|
|
||||||
{
|
int FastStringList::add(const TCHAR *name, int case_sensitive/*=0*/)
|
||||||
int pos = SortedStringListND<struct string_t>::add(name, case_sensitive);
|
{
|
||||||
if (pos == -1) return -1;
|
int pos = SortedStringListND<struct string_t>::add(name, case_sensitive);
|
||||||
return ((struct string_t*)gr.get())[pos].name;
|
if (pos == -1) return -1;
|
||||||
}
|
return ((struct string_t*)gr.get())[pos].name;
|
||||||
|
}
|
||||||
TCHAR *FastStringList::get() const
|
|
||||||
{
|
TCHAR *FastStringList::get() const
|
||||||
return (TCHAR*)strings.get();
|
{
|
||||||
}
|
return (TCHAR*)strings.get();
|
||||||
|
}
|
||||||
int FastStringList::getlen() const
|
|
||||||
{
|
int FastStringList::getlen() const
|
||||||
return strings.getlen();
|
{
|
||||||
}
|
return strings.getlen();
|
||||||
|
}
|
||||||
int FastStringList::getnum() const
|
|
||||||
{
|
int FastStringList::getnum() const
|
||||||
return gr.getlen()/sizeof(struct string_t);
|
{
|
||||||
}
|
return gr.getlen()/sizeof(struct string_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ class SortedStringList
|
||||||
if (case_sensitive)
|
if (case_sensitive)
|
||||||
res=_tcscmp(str, data[nextpos].name);
|
res=_tcscmp(str, data[nextpos].name);
|
||||||
else
|
else
|
||||||
res=stricmp(str, data[nextpos].name);
|
res=_tcsicmp(str, data[nextpos].name);
|
||||||
if (res==0) return returnbestpos ? -1 : nextpos;
|
if (res==0) return returnbestpos ? -1 : nextpos;
|
||||||
if (res<0) ul=nextpos;
|
if (res<0) ul=nextpos;
|
||||||
else ll=nextpos+1;
|
else ll=nextpos+1;
|
||||||
|
@ -302,7 +302,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
if (pos==-1) return alwaysreturnpos ? where : -1;
|
if (pos==-1) return alwaysreturnpos ? where : -1;
|
||||||
|
|
||||||
// Note that .name is set with the TCHAR* offset into m_strings.
|
// Note that .name is set with the TCHAR* offset into m_strings.
|
||||||
newstruct.name=strings.add(name,strlen(name)+1);
|
newstruct.name=strings.add(name,(_tcsclen(name)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
||||||
|
|
||||||
gr.add(&newstruct,sizeof(T));
|
gr.add(&newstruct,sizeof(T));
|
||||||
T *s=(T*)gr.get();
|
T *s=(T*)gr.get();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#ifndef _TSTRING_
|
#ifndef _TSTRING_
|
||||||
#define _TSTRING_
|
#define _TSTRING_
|
||||||
|
|
||||||
|
#include "Platform.h"
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -28,9 +29,7 @@ typedef std::wstring tstring;
|
||||||
typedef std::wofstream tofstream;
|
typedef std::wofstream tofstream;
|
||||||
typedef std::wifstream tifstream;
|
typedef std::wifstream tifstream;
|
||||||
// Use the following macros to open text files.
|
// Use the following macros to open text files.
|
||||||
// #define FOPENTEXT(file, mode) _wfopen(file, mode ## L", ccs=Unicode")
|
#define FOPENTEXT(file, mode) _wfopen(file, mode)
|
||||||
FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode);
|
|
||||||
#define FOPENTEXT(file, mode) FileOpenUnicodeText(file, mode)
|
|
||||||
#else
|
#else
|
||||||
typedef std::string tstring;
|
typedef std::string tstring;
|
||||||
typedef std::ofstream tofstream;
|
typedef std::ofstream tofstream;
|
||||||
|
@ -56,10 +55,16 @@ public:
|
||||||
m_wStr = (wchar_t*) GlobalAlloc(GPTR, len*sizeof(wchar_t));
|
m_wStr = (wchar_t*) GlobalAlloc(GPTR, len*sizeof(wchar_t));
|
||||||
MultiByteToWideChar(CP_ACP, 0, str, -1, m_wStr, len);
|
MultiByteToWideChar(CP_ACP, 0, str, -1, m_wStr, len);
|
||||||
}
|
}
|
||||||
|
CtoTString(const std::string& str)
|
||||||
|
{
|
||||||
|
int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length()+1, NULL, 0);
|
||||||
|
m_wStr = (wchar_t*) GlobalAlloc(GPTR, len*sizeof(wchar_t));
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length()+1, m_wStr, len);
|
||||||
|
}
|
||||||
|
|
||||||
~CtoTString() { GlobalFree(m_wStr); m_wStr = 0; }
|
~CtoTString() { GlobalFree(m_wStr); m_wStr = 0; }
|
||||||
|
|
||||||
operator const wchar_t* tstr() { return m_wStr; }
|
operator const wchar_t*() { return m_wStr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wchar_t* m_wStr;
|
wchar_t* m_wStr;
|
||||||
|
@ -76,6 +81,12 @@ public:
|
||||||
m_cStr = (char*) GlobalAlloc(GPTR, len);
|
m_cStr = (char*) GlobalAlloc(GPTR, len);
|
||||||
WideCharToMultiByte(CP_ACP, 0, wStr, -1, m_cStr, len, 0, 0);
|
WideCharToMultiByte(CP_ACP, 0, wStr, -1, m_cStr, len, 0, 0);
|
||||||
}
|
}
|
||||||
|
TtoCString(const tstring& wStr)
|
||||||
|
{
|
||||||
|
int len = WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), wStr.length()+1, NULL, 0, 0, 0);
|
||||||
|
m_cStr = (char*) GlobalAlloc(GPTR, len);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), wStr.length()+1, m_cStr, len, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
~TtoCString() { GlobalFree(m_cStr); m_cStr = 0; }
|
~TtoCString() { GlobalFree(m_cStr); m_cStr = 0; }
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ int update_bitmap(CResourceEditor* re, WORD id, const TCHAR* filename, int width
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
re->UpdateResourceA(RT_BITMAP, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, bitmap, dwSize);
|
re->UpdateResource(RT_BITMAP, id, NSIS_DEFAULT_LANG, bitmap, dwSize);
|
||||||
|
|
||||||
free(bitmap);
|
free(bitmap);
|
||||||
|
|
||||||
|
@ -537,8 +537,8 @@ static bool GetDLLVersionUsingRE(const tstring& filepath, DWORD& high, DWORD & l
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
||||||
LPBYTE ver = dllre->GetResourceA(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
LPBYTE ver = dllre->GetResource(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
||||||
int versize = dllre->GetResourceSizeA(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
int versize = dllre->GetResourceSize(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
||||||
|
|
||||||
if (ver)
|
if (ver)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,11 @@
|
||||||
|
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
|
|
||||||
WCHAR *winchar_fromansi(const char* s, unsigned int codepage/*=CP_ACP*/)
|
WCHAR *winchar_fromTchar(const TCHAR* s, unsigned int codepage/*=CP_ACP*/)
|
||||||
{
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
return _wcsdup(s); // codepage is not used in this mode
|
||||||
|
#else
|
||||||
int l = MultiByteToWideChar(codepage, 0, s, -1, 0, 0);
|
int l = MultiByteToWideChar(codepage, 0, s, -1, 0, 0);
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
throw runtime_error("Unicode conversion failed");
|
throw runtime_error("Unicode conversion failed");
|
||||||
|
@ -36,20 +39,7 @@ WCHAR *winchar_fromansi(const char* s, unsigned int codepage/*=CP_ACP*/)
|
||||||
throw runtime_error("Unicode conversion failed");
|
throw runtime_error("Unicode conversion failed");
|
||||||
|
|
||||||
return ws;
|
return ws;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
char *winchar_toansi(const WCHAR* ws, unsigned int codepage/*=CP_ACP*/)
|
|
||||||
{
|
|
||||||
int l = WideCharToMultiByte(codepage, 0, ws, -1, 0, 0, 0, 0);
|
|
||||||
if (l == 0)
|
|
||||||
throw runtime_error("Unicode conversion failed");
|
|
||||||
|
|
||||||
char *s = new char[l + 1];
|
|
||||||
|
|
||||||
if (WideCharToMultiByte(codepage, 0, ws, -1, s, l + 1, 0, 0) == 0)
|
|
||||||
throw runtime_error("Unicode conversion failed");
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2)
|
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2)
|
||||||
|
@ -115,14 +105,3 @@ int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2)
|
||||||
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int winchar_stoi(const WCHAR *ws)
|
|
||||||
{
|
|
||||||
char *s = winchar_toansi(ws);
|
|
||||||
|
|
||||||
int ret = atoi(s);
|
|
||||||
|
|
||||||
delete [] s;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,11 +18,9 @@
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
WCHAR *winchar_fromansi(const char* s, unsigned int codepage = CP_ACP);
|
WCHAR *winchar_fromTchar(const TCHAR* s, unsigned int codepage = CP_ACP);
|
||||||
char *winchar_toansi(const WCHAR* ws, unsigned int codepage = CP_ACP);
|
|
||||||
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2);
|
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2);
|
||||||
WCHAR *winchar_strncpy(WCHAR *ws1, const WCHAR *ws2, size_t n);
|
WCHAR *winchar_strncpy(WCHAR *ws1, const WCHAR *ws2, size_t n);
|
||||||
size_t winchar_strlen(const WCHAR *ws);
|
size_t winchar_strlen(const WCHAR *ws);
|
||||||
WCHAR *winchar_strdup(const WCHAR *ws);
|
WCHAR *winchar_strdup(const WCHAR *ws);
|
||||||
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2);
|
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2);
|
||||||
int winchar_stoi(const WCHAR *ws);
|
|
||||||
|
|
|
@ -50,19 +50,29 @@ void writer_sink::write_int_array(const int i[], const size_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writer_sink::write_string(const char *s)
|
|
||||||
{
|
|
||||||
write_data(s, strlen(s) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// size in this case is the length of the string to write.
|
// size in this case is the length of the string to write.
|
||||||
void writer_sink::write_string(const char *s, const size_t size)
|
void writer_sink::write_string(const TCHAR *s, size_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
bool strEnd = false;
|
||||||
|
TCHAR ch;
|
||||||
|
for (; size ; size--)
|
||||||
|
{
|
||||||
|
if (!strEnd)
|
||||||
|
{
|
||||||
|
ch = *s++;
|
||||||
|
if (ch == _T('\0'))
|
||||||
|
strEnd = true;
|
||||||
|
}
|
||||||
|
write_short(ch);
|
||||||
|
}
|
||||||
|
#else
|
||||||
char *wb = new char[size];
|
char *wb = new char[size];
|
||||||
memset(wb, 0, size);
|
memset(wb, 0, size);
|
||||||
strncpy(wb, s, size);
|
strncpy(wb, s, size);
|
||||||
write_data(wb, size);
|
write_data(wb, size);
|
||||||
delete [] wb;
|
delete [] wb;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void writer_sink::write_growbuf(const IGrowBuf *b)
|
void writer_sink::write_growbuf(const IGrowBuf *b)
|
||||||
|
|
|
@ -34,8 +34,7 @@ public:
|
||||||
virtual void write_short(const short s);
|
virtual void write_short(const short s);
|
||||||
virtual void write_int(const int i);
|
virtual void write_int(const int i);
|
||||||
virtual void write_int_array(const int i[], const size_t len);
|
virtual void write_int_array(const int i[], const size_t len);
|
||||||
virtual void write_string(const TCHAR *s);
|
virtual void write_string(const TCHAR *s, size_t size);
|
||||||
virtual void write_string(const TCHAR *s, const size_t size);
|
|
||||||
virtual void write_growbuf(const IGrowBuf *b);
|
virtual void write_growbuf(const IGrowBuf *b);
|
||||||
|
|
||||||
virtual void write_data(const void *data, const size_t size) = 0;
|
virtual void write_data(const void *data, const size_t size) = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue