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);
|
||||
#else
|
||||
// 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);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,368 +1,380 @@
|
|||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#ifndef _CRT_STRINGIZE
|
||||
#define __CRT_STRINGIZE(_Value) #_Value
|
||||
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
|
||||
#endif /* _CRT_STRINGIZE */
|
||||
|
||||
#define STR_SIZE 1024
|
||||
|
||||
void RegFile(TCHAR cmd, TCHAR *file, int x64);
|
||||
void RegDll(TCHAR *file);
|
||||
void RegTypeLib(TCHAR *file);
|
||||
void DeleteFileOnReboot(TCHAR *pszFile);
|
||||
|
||||
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
TCHAR *cmdline;
|
||||
TCHAR seekchar = _T(' ');
|
||||
|
||||
cmdline = GetCommandLine();
|
||||
if (*cmdline == _T('\"'))
|
||||
seekchar = *cmdline++;
|
||||
|
||||
while (*cmdline && *cmdline != seekchar)
|
||||
cmdline = CharNext(cmdline);
|
||||
cmdline = CharNext(cmdline);
|
||||
while (*cmdline == _T(' '))
|
||||
cmdline++;
|
||||
|
||||
if (*cmdline++ != _T('/'))
|
||||
{
|
||||
ExitProcess(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*cmdline == _T('S'))
|
||||
{
|
||||
HKEY rootkey;
|
||||
|
||||
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"), 0, KEY_READ, &rootkey)))
|
||||
{
|
||||
TCHAR keyname[STR_SIZE];
|
||||
|
||||
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
|
||||
{
|
||||
HKEY key;
|
||||
|
||||
if (SUCCEEDED(RegOpenKeyEx(rootkey, keyname, 0, KEY_READ, &key)))
|
||||
{
|
||||
DWORD t, count, l = sizeof(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];
|
||||
|
||||
for (j = 1; j <= count; j++)
|
||||
{
|
||||
wsprintf(valname, _T("%u.mode"), j);
|
||||
l = sizeof(mode);
|
||||
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);
|
||||
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.
|
||||
RegFile(mode[0], file, mode[1] == 'X');
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
RegDeleteKey(rootkey, keyname);
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(rootkey);
|
||||
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
|
||||
}
|
||||
|
||||
{
|
||||
TCHAR file[STR_SIZE];
|
||||
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
||||
{
|
||||
DeleteFileOnReboot(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
OleInitialize(NULL);
|
||||
|
||||
if (*cmdline == _T('D'))
|
||||
{
|
||||
RegDll(cmdline + 1);
|
||||
}
|
||||
else if (*cmdline == _T('T'))
|
||||
{
|
||||
RegTypeLib(cmdline + 1);
|
||||
}
|
||||
|
||||
OleUninitialize();
|
||||
SetErrorMode(0);
|
||||
}
|
||||
|
||||
ExitProcess(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
||||
{
|
||||
HMODULE kernel = GetModuleHandle(_T("kernel32"));
|
||||
if (kernel)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
||||
if (proc)
|
||||
{
|
||||
typedef BOOL (WINAPI *Wow64EnableWow64FsRedirectionPtr)(BOOL);
|
||||
Wow64EnableWow64FsRedirectionPtr Wow64EnableWow64FsRedirectionFunc =
|
||||
(Wow64EnableWow64FsRedirectionPtr) proc;
|
||||
|
||||
Wow64EnableWow64FsRedirectionFunc(Wow64FsEnableRedirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegFile(TCHAR cmd, TCHAR *file, int x64)
|
||||
{
|
||||
TCHAR self[STR_SIZE];
|
||||
TCHAR cmdline[STR_SIZE];
|
||||
|
||||
int ready = 0;
|
||||
|
||||
if (!*file || (cmd != _T('D') && cmd != _T('T') && cmd != _T('E')))
|
||||
return;
|
||||
|
||||
if (cmd == _T('E'))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\" /regserver"), file);
|
||||
ready++;
|
||||
}
|
||||
else if (!x64)
|
||||
{
|
||||
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\" /%c%s"), self, cmd, file);
|
||||
ready++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetSystemDirectory(self, STR_SIZE))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\\regsvr32.exe\" /s \"%s\""), self, file);
|
||||
ready++;
|
||||
|
||||
SafeWow64EnableWow64FsRedirection(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (ready)
|
||||
{
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
||||
|
||||
if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
|
||||
if (x64)
|
||||
{
|
||||
SafeWow64EnableWow64FsRedirection(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegDll(TCHAR *file)
|
||||
{
|
||||
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (mod)
|
||||
{
|
||||
FARPROC regfunc = GetProcAddress(mod, "DllRegisterServer");
|
||||
if (regfunc)
|
||||
regfunc();
|
||||
FreeLibrary(mod);
|
||||
}
|
||||
}
|
||||
|
||||
void RegTypeLib(TCHAR *file)
|
||||
{
|
||||
WCHAR wfile[STR_SIZE];
|
||||
|
||||
if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) != 0)
|
||||
{
|
||||
ITypeLib* tlib;
|
||||
if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
|
||||
RegisterTypeLib(tlib, wfile, NULL);
|
||||
tlib->lpVtbl->Release(tlib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *mystrstriA(char *a, const char *b)
|
||||
{
|
||||
int l = lstrlenA(b);
|
||||
while (lstrlenA(a) >= l)
|
||||
{
|
||||
char c = a[l];
|
||||
a[l] = 0;
|
||||
if (!lstrcmpiA(a, b))
|
||||
{
|
||||
a[l] = c;
|
||||
return a;
|
||||
}
|
||||
a[l] = c;
|
||||
a = CharNextA(a);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mini_memcpy(void *out, const void *in, int len)
|
||||
{
|
||||
char *c_out=(char*)out;
|
||||
char *c_in=(char *)in;
|
||||
while (len-- > 0)
|
||||
{
|
||||
*c_out++=*c_in++;
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
|
||||
{
|
||||
int attr = GetFileAttributes(fn);
|
||||
return CreateFile(
|
||||
fn,
|
||||
da,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
cd,
|
||||
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
/** Modifies the wininit.ini file to rename / delete a file.
|
||||
*
|
||||
* @param prevName The previous / current name of the file.
|
||||
* @param newName The new name to move the file to. If NULL, the current file
|
||||
* will be deleted.
|
||||
*/
|
||||
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||
{
|
||||
static char szRenameLine[1024];
|
||||
static TCHAR wininit[1024];
|
||||
static TCHAR tmpbuf[1024];
|
||||
|
||||
int cchRenameLine;
|
||||
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
|
||||
HANDLE hfile;
|
||||
DWORD dwFileSize;
|
||||
DWORD dwBytes;
|
||||
DWORD dwRenameLinePos;
|
||||
char *pszWinInit; // Contains the file contents of wininit.ini
|
||||
|
||||
int spn; // length of the short path name in TCHARs.
|
||||
|
||||
lstrcpy(tmpbuf, _T("NUL"));
|
||||
|
||||
if (newName) {
|
||||
// create the file if it's not already there to prevent GetShortPathName from failing
|
||||
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
|
||||
spn = GetShortPathName(newName,tmpbuf,1024);
|
||||
if (!spn || spn > 1024)
|
||||
return;
|
||||
}
|
||||
// wininit is used as a temporary here
|
||||
spn = GetShortPathName(prevName,wininit,1024);
|
||||
if (!spn || spn > 1024)
|
||||
return;
|
||||
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
|
||||
// Get the path to the wininit.ini file.
|
||||
GetWindowsDirectory(wininit, 1024-16);
|
||||
lstrcat(wininit, _T("\\wininit.ini"));
|
||||
|
||||
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
||||
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// We are now working on the Windows wininit file
|
||||
dwFileSize = GetFileSize(hfile, NULL);
|
||||
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
|
||||
|
||||
if (pszWinInit != NULL)
|
||||
{
|
||||
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
|
||||
{
|
||||
// Look for the rename section in the current file.
|
||||
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
|
||||
if (pszRenameSecInFile == NULL)
|
||||
{
|
||||
// No rename section. So we add it to the end of file.
|
||||
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
|
||||
dwFileSize += 10;
|
||||
dwRenameLinePos = dwFileSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is a rename section, but is there another section after it?
|
||||
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
||||
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
||||
if (pszNextSec)
|
||||
{
|
||||
TCHAR *p = ++pszNextSec;
|
||||
while (p < pszWinInit + dwFileSize) {
|
||||
p[cchRenameLine] = *p;
|
||||
p++;
|
||||
}
|
||||
|
||||
dwRenameLinePos = pszNextSec - pszWinInit;
|
||||
}
|
||||
// rename section is last, stick item at end of file
|
||||
else dwRenameLinePos = dwFileSize;
|
||||
}
|
||||
|
||||
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
|
||||
dwFileSize += cchRenameLine;
|
||||
|
||||
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
|
||||
|
||||
GlobalFree(pszWinInit);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(hfile);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteFileOnReboot(TCHAR *pszFile)
|
||||
{
|
||||
BOOL fOk = 0;
|
||||
HMODULE hLib=GetModuleHandle(_T("KERNEL32.dll"));
|
||||
if (hLib)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#ifndef _CRT_STRINGIZE
|
||||
#define __CRT_STRINGIZE(_Value) #_Value
|
||||
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
|
||||
#endif /* _CRT_STRINGIZE */
|
||||
|
||||
#define STR_SIZE 1024
|
||||
|
||||
void RegFile(TCHAR cmd, TCHAR *file, int x64);
|
||||
void RegDll(TCHAR *file);
|
||||
void RegTypeLib(TCHAR *file);
|
||||
void DeleteFileOnReboot(TCHAR *pszFile);
|
||||
|
||||
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
TCHAR *cmdline;
|
||||
TCHAR seekchar = _T(' ');
|
||||
|
||||
cmdline = GetCommandLine();
|
||||
if (*cmdline == _T('\"'))
|
||||
seekchar = *cmdline++;
|
||||
|
||||
while (*cmdline && *cmdline != seekchar)
|
||||
cmdline = CharNext(cmdline);
|
||||
cmdline = CharNext(cmdline);
|
||||
while (*cmdline == _T(' '))
|
||||
cmdline++;
|
||||
|
||||
if (*cmdline++ != _T('/'))
|
||||
{
|
||||
ExitProcess(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*cmdline == _T('S'))
|
||||
{
|
||||
HKEY rootkey;
|
||||
TCHAR *keyname, *file; // These are turned into heap memory to avoid _chkstk
|
||||
keyname = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
|
||||
file = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
|
||||
|
||||
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)
|
||||
{
|
||||
HKEY key;
|
||||
|
||||
if (SUCCEEDED(RegOpenKeyEx(rootkey, keyname, 0, KEY_READ, &key)))
|
||||
{
|
||||
DWORD t, count, l = sizeof(DWORD);
|
||||
|
||||
if (SUCCEEDED(RegQueryValueEx(key, _T("count"), NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
|
||||
{
|
||||
DWORD j;
|
||||
TCHAR valname[128], mode[3];
|
||||
|
||||
for (j = 1; j <= count; j++)
|
||||
{
|
||||
wsprintf(valname, _T("%u.mode"), j);
|
||||
l = sizeof(mode);
|
||||
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);
|
||||
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.
|
||||
RegFile(mode[0], file, mode[1] == 'X');
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
RegDeleteKey(rootkey, keyname);
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(rootkey);
|
||||
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
|
||||
}
|
||||
|
||||
{
|
||||
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
||||
{
|
||||
DeleteFileOnReboot(file);
|
||||
}
|
||||
}
|
||||
GlobalFree(keyname);
|
||||
GlobalFree(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
OleInitialize(NULL);
|
||||
|
||||
if (*cmdline == _T('D'))
|
||||
{
|
||||
RegDll(cmdline + 1);
|
||||
}
|
||||
else if (*cmdline == _T('T'))
|
||||
{
|
||||
RegTypeLib(cmdline + 1);
|
||||
}
|
||||
|
||||
OleUninitialize();
|
||||
SetErrorMode(0);
|
||||
}
|
||||
|
||||
ExitProcess(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
||||
{
|
||||
HMODULE kernel = GetModuleHandle(_T("kernel32"));
|
||||
if (kernel)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
||||
if (proc)
|
||||
{
|
||||
typedef BOOL (WINAPI *Wow64EnableWow64FsRedirectionPtr)(BOOL);
|
||||
Wow64EnableWow64FsRedirectionPtr Wow64EnableWow64FsRedirectionFunc =
|
||||
(Wow64EnableWow64FsRedirectionPtr) proc;
|
||||
|
||||
Wow64EnableWow64FsRedirectionFunc(Wow64FsEnableRedirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegFile(TCHAR cmd, TCHAR *file, int x64)
|
||||
{
|
||||
TCHAR* self; // These are turned into heap memory to avoid _chkstk
|
||||
TCHAR* cmdline;
|
||||
|
||||
int ready = 0;
|
||||
|
||||
if (!*file || (cmd != _T('D') && cmd != _T('T') && cmd != _T('E')))
|
||||
return;
|
||||
|
||||
self = (TCHAR*) GlobalAlloc(GPTR, sizeof(TCHAR)*STR_SIZE);
|
||||
cmdline = (TCHAR*) GlobalAlloc(GPTR, sizeof(TCHAR)*STR_SIZE);
|
||||
|
||||
if (cmd == _T('E'))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\" /regserver"), file);
|
||||
ready++;
|
||||
}
|
||||
else if (!x64)
|
||||
{
|
||||
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\" /%c%s"), self, cmd, file);
|
||||
ready++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetSystemDirectory(self, STR_SIZE))
|
||||
{
|
||||
wsprintf(cmdline, _T("\"%s\\regsvr32.exe\" /s \"%s\""), self, file);
|
||||
ready++;
|
||||
|
||||
SafeWow64EnableWow64FsRedirection(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (ready)
|
||||
{
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
||||
|
||||
if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
|
||||
if (x64)
|
||||
{
|
||||
SafeWow64EnableWow64FsRedirection(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalFree(self);
|
||||
GlobalFree(cmdline);
|
||||
}
|
||||
|
||||
void RegDll(TCHAR *file)
|
||||
{
|
||||
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (mod)
|
||||
{
|
||||
FARPROC regfunc = GetProcAddress(mod, "DllRegisterServer");
|
||||
if (regfunc)
|
||||
regfunc();
|
||||
FreeLibrary(mod);
|
||||
}
|
||||
}
|
||||
|
||||
void RegTypeLib(TCHAR *file)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WCHAR* wfile = file;
|
||||
#else
|
||||
WCHAR wfile[STR_SIZE];
|
||||
if (MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, STR_SIZE) == 0)
|
||||
return;
|
||||
#endif
|
||||
{
|
||||
ITypeLib* tlib;
|
||||
if (SUCCEEDED(LoadTypeLib(wfile, &tlib))) {
|
||||
RegisterTypeLib(tlib, wfile, NULL);
|
||||
tlib->lpVtbl->Release(tlib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *mystrstriA(char *a, const char *b)
|
||||
{
|
||||
int l = lstrlenA(b);
|
||||
while (lstrlenA(a) >= l)
|
||||
{
|
||||
char c = a[l];
|
||||
a[l] = 0;
|
||||
if (!lstrcmpiA(a, b))
|
||||
{
|
||||
a[l] = c;
|
||||
return a;
|
||||
}
|
||||
a[l] = c;
|
||||
a = CharNextA(a);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mini_memcpy(void *out, const void *in, int len)
|
||||
{
|
||||
char *c_out=(char*)out;
|
||||
char *c_in=(char *)in;
|
||||
while (len-- > 0)
|
||||
{
|
||||
*c_out++=*c_in++;
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
|
||||
{
|
||||
int attr = GetFileAttributes(fn);
|
||||
return CreateFile(
|
||||
fn,
|
||||
da,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
cd,
|
||||
attr == INVALID_FILE_ATTRIBUTES ? 0 : attr,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
/** Modifies the wininit.ini file to rename / delete a file.
|
||||
*
|
||||
* @param prevName The previous / current name of the file.
|
||||
* @param newName The new name to move the file to. If NULL, the current file
|
||||
* will be deleted.
|
||||
*/
|
||||
void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||
{
|
||||
static char szRenameLine[1024];
|
||||
static TCHAR wininit[1024];
|
||||
static TCHAR tmpbuf[1024];
|
||||
|
||||
int cchRenameLine;
|
||||
LPCSTR szRenameSec = "[Rename]\r\n"; // rename section marker
|
||||
HANDLE hfile;
|
||||
DWORD dwFileSize;
|
||||
DWORD dwBytes;
|
||||
DWORD dwRenameLinePos;
|
||||
char *pszWinInit; // Contains the file contents of wininit.ini
|
||||
|
||||
int spn; // length of the short path name in TCHARs.
|
||||
|
||||
lstrcpy(tmpbuf, _T("NUL"));
|
||||
|
||||
if (newName) {
|
||||
// create the file if it's not already there to prevent GetShortPathName from failing
|
||||
CloseHandle(myOpenFile(newName,0,CREATE_NEW));
|
||||
spn = GetShortPathName(newName,tmpbuf,1024);
|
||||
if (!spn || spn > 1024)
|
||||
return;
|
||||
}
|
||||
// wininit is used as a temporary here
|
||||
spn = GetShortPathName(prevName,wininit,1024);
|
||||
if (!spn || spn > 1024)
|
||||
return;
|
||||
cchRenameLine = wsprintfA(szRenameLine, "%s=%s\r\n", tmpbuf, wininit);
|
||||
// Get the path to the wininit.ini file.
|
||||
GetWindowsDirectory(wininit, 1024-16);
|
||||
lstrcat(wininit, _T("\\wininit.ini"));
|
||||
|
||||
hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
|
||||
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// We are now working on the Windows wininit file
|
||||
dwFileSize = GetFileSize(hfile, NULL);
|
||||
pszWinInit = (char*) GlobalAlloc(GPTR, dwFileSize + cchRenameLine + 10);
|
||||
|
||||
if (pszWinInit != NULL)
|
||||
{
|
||||
if (ReadFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL) && dwFileSize == dwBytes)
|
||||
{
|
||||
// Look for the rename section in the current file.
|
||||
LPSTR pszRenameSecInFile = mystrstriA(pszWinInit, szRenameSec);
|
||||
if (pszRenameSecInFile == NULL)
|
||||
{
|
||||
// No rename section. So we add it to the end of file.
|
||||
lstrcpyA(pszWinInit+dwFileSize, szRenameSec);
|
||||
dwFileSize += 10;
|
||||
dwRenameLinePos = dwFileSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is a rename section, but is there another section after it?
|
||||
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
||||
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
||||
if (pszNextSec)
|
||||
{
|
||||
char *p = ++pszNextSec;
|
||||
while (p < pszWinInit + dwFileSize) {
|
||||
p[cchRenameLine] = *p;
|
||||
p++;
|
||||
}
|
||||
|
||||
dwRenameLinePos = pszNextSec - pszWinInit;
|
||||
}
|
||||
// rename section is last, stick item at end of file
|
||||
else dwRenameLinePos = dwFileSize;
|
||||
}
|
||||
|
||||
mini_memcpy(&pszWinInit[dwRenameLinePos], szRenameLine, cchRenameLine);
|
||||
dwFileSize += cchRenameLine;
|
||||
|
||||
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(hfile, pszWinInit, dwFileSize, &dwBytes, NULL);
|
||||
|
||||
GlobalFree(pszWinInit);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(hfile);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteFileOnReboot(TCHAR *pszFile)
|
||||
{
|
||||
BOOL fOk = 0;
|
||||
HMODULE hLib=GetModuleHandle(_T("KERNEL32.dll"));
|
||||
if (hLib)
|
||||
{
|
||||
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('_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('_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("""
|
||||
makensisw.cpp
|
||||
noclib.cpp
|
||||
toolbar.cpp
|
||||
utils.cpp
|
||||
version.cpp
|
||||
|
@ -34,6 +33,7 @@ libs = Split("""
|
|||
user32
|
||||
gdi32
|
||||
shell32
|
||||
shlwapi
|
||||
comdlg32
|
||||
comctl32
|
||||
wsock32
|
||||
|
@ -45,6 +45,7 @@ docs = Split("""
|
|||
""")
|
||||
|
||||
Import('BuildUtil')
|
||||
Import('_tWinMain')
|
||||
|
||||
BuildUtil(
|
||||
target,
|
||||
|
@ -52,7 +53,7 @@ BuildUtil(
|
|||
libs,
|
||||
res = res,
|
||||
resources = resources,
|
||||
entry = 'WinMain',
|
||||
entry = _tWinMain,
|
||||
defines = ['RELEASE=2.3'],
|
||||
docs = docs,
|
||||
root_util = True
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
#include "makensisw.h"
|
||||
#include <windowsx.h>
|
||||
#include <shlwapi.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "noclib.h"
|
||||
#include "toolbar.h"
|
||||
#include "update.h"
|
||||
|
||||
|
@ -41,9 +41,9 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int
|
|||
int status;
|
||||
HACCEL haccel;
|
||||
|
||||
my_memset(&g_sdata,0,sizeof(NSCRIPTDATA));
|
||||
my_memset(&g_resize,0,sizeof(NRESIZEDATA));
|
||||
my_memset(&g_find,0,sizeof(NFINDREPLACE));
|
||||
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
|
||||
memset(&g_resize,0,sizeof(NRESIZEDATA));
|
||||
memset(&g_find,0,sizeof(NFINDREPLACE));
|
||||
g_sdata.hInstance=GetModuleHandle(0);
|
||||
g_sdata.symbols = NULL;
|
||||
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, _T("makensis win32 signint event"));
|
||||
|
@ -130,10 +130,10 @@ void ProcessCommandLine()
|
|||
if (argc > 1) {
|
||||
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 "));
|
||||
if(!lstrncmpi(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
|
||||
if(!StrCmpNI(p,_T("/FINAL "), 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) {
|
||||
TCHAR str[MAX_PATH],*str2;
|
||||
lstrcpy(str,g_sdata.input_script);
|
||||
str2=my_strrchr(str,_T('\\'));
|
||||
str2=_tcsrchr(str,_T('\\'));
|
||||
if(str2!=NULL) *(str2+1)=0;
|
||||
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:
|
||||
{
|
||||
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.hwndOwner = hwndDlg;
|
||||
g_find.fr.Flags = FR_NOUPDOWN;
|
||||
|
@ -743,7 +743,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||
return 1;
|
||||
}
|
||||
char szBuf[1024];
|
||||
TCHAR szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
DWORD dwExit = !STILL_ACTIVE;
|
||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||
|
@ -986,7 +986,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
if(n > 0) {
|
||||
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
||||
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);
|
||||
GlobalFree(buf);
|
||||
break;
|
||||
|
@ -1028,7 +1028,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
if(n > 0) {
|
||||
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
||||
TCHAR *p = my_strstr(buf,_T("="));
|
||||
TCHAR *p = _tcsstr(buf,_T("="));
|
||||
if(p) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
||||
*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 "resource.h"
|
||||
#include "noclib.h"
|
||||
#include "toolbar.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.
|
||||
TOOLINFO ti;
|
||||
|
||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
||||
memset(&ti, 0, sizeof(TOOLINFO));
|
||||
|
||||
if(g_sdata.compressor >= COMPRESSOR_SCRIPT && g_sdata.compressor <= COMPRESSOR_BEST) {
|
||||
iBitmap = compressor_bitmaps[(int)g_sdata.compressor];
|
||||
|
@ -146,7 +145,7 @@ void UpdateToolBarCompressorButton()
|
|||
IDS_COMPRESSOR,
|
||||
temp,
|
||||
COUNTOF(temp));
|
||||
my_memset(szBuffer, 0, sizeof(szBuffer));
|
||||
memset(szBuffer, 0, sizeof(szBuffer));
|
||||
lstrcat(szBuffer,temp);
|
||||
lstrcat(szBuffer,_T(" ["));
|
||||
LoadString(g_sdata.hInstance,
|
||||
|
@ -174,7 +173,7 @@ void AddToolBarButtonTooltip(int id, int iString)
|
|||
TCHAR szBuffer[64];
|
||||
RECT rect;
|
||||
|
||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
||||
memset(&ti, 0, sizeof(TOOLINFO));
|
||||
|
||||
SendMessage(g_toolbar.hwnd, TB_GETITEMRECT, id, (LPARAM) (LPRECT) &rect);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "makensisw.h"
|
||||
#include "update.h"
|
||||
#include "noclib.h"
|
||||
|
||||
#include "jnetlib/httpget.h"
|
||||
#include "../ExDLL/nsis_tchar.h"
|
||||
|
@ -62,14 +61,14 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
|||
|
||||
if (getProxyInfo(pbuf))
|
||||
{
|
||||
p=my_strstr(pbuf,"http=");
|
||||
p=strstr(pbuf,"http=");
|
||||
if (!p) p=pbuf;
|
||||
else {
|
||||
p+=5;
|
||||
}
|
||||
char *tp=my_strstr(p,";");
|
||||
char *tp=strstr(p,";");
|
||||
if (tp) *tp=0;
|
||||
char *p2=my_strstr(p,"=");
|
||||
char *p2=strstr(p,"=");
|
||||
if (p2) p=0; // we found the wrong proxy
|
||||
}
|
||||
|
||||
|
@ -140,7 +139,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
|||
void Update() {
|
||||
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);
|
||||
return;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "makensisw.h"
|
||||
#include "resource.h"
|
||||
#include "toolbar.h"
|
||||
#include "noclib.h"
|
||||
#include <shlwapi.h>
|
||||
|
||||
#ifdef _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);
|
||||
if (!argSpace)
|
||||
return 0;
|
||||
|
||||
*argv = (TCHAR **) argSpace;
|
||||
argSpace += size * sizeof(TCHAR *);
|
||||
argSpace = (TCHAR *) ((*argv)+size);
|
||||
size--;
|
||||
|
||||
p = cmdLine;
|
||||
|
@ -241,13 +241,13 @@ void SetCompressorStats()
|
|||
DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT);
|
||||
lstrcat(g_sdata.compressor_stats,buf);
|
||||
|
||||
if(!lstrncmp(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
|
||||
if(!StrCmpN(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
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;
|
||||
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
|
||||
lstrcat(g_sdata.compressor_stats,buf);
|
||||
|
@ -622,7 +622,7 @@ int InitBranding() {
|
|||
|
||||
void InitTooltips(HWND h) {
|
||||
if (h == NULL) return;
|
||||
my_memset(&g_tip,0,sizeof(NTOOLTIP));
|
||||
memset(&g_tip,0,sizeof(NTOOLTIP));
|
||||
g_tip.tip_p = h;
|
||||
INITCOMMONCONTROLSEX icx;
|
||||
icx.dwSize = sizeof(icx);
|
||||
|
@ -668,7 +668,7 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
|||
void ShowDocs() {
|
||||
TCHAR pathf[MAX_PATH],*path;
|
||||
GetModuleFileName(NULL,pathf,sizeof(pathf));
|
||||
path=my_strrchr(pathf,_T('\\'));
|
||||
path=_tcsrchr(pathf,_T('\\'));
|
||||
if(path!=NULL) *path=0;
|
||||
lstrcat(pathf,LOCALDOCS);
|
||||
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
||||
|
@ -749,7 +749,7 @@ void PushMRUFile(TCHAR* fname)
|
|||
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);
|
||||
if (rv == 0) {
|
||||
return;
|
||||
|
@ -783,19 +783,19 @@ void BuildMRUMenus()
|
|||
|
||||
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
||||
if(g_mru_list[i][0]) {
|
||||
my_memset(buf,0,sizeof(buf));
|
||||
my_memset(&mii, 0, sizeof(mii));
|
||||
memset(buf,0,sizeof(buf));
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
||||
mii.wID = IDM_MRU_FILE+i;
|
||||
mii.fType = MFT_STRING;
|
||||
wsprintf(buf, _T("&%d "), i + 1);
|
||||
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) {
|
||||
p++;
|
||||
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);
|
||||
lstrcat(buf2,_T("..."));
|
||||
|
||||
|
@ -833,7 +833,7 @@ void BuildMRUMenus()
|
|||
}
|
||||
|
||||
hMenu = g_sdata.toolsSubmenu;
|
||||
my_memset(&mii, 0, sizeof(mii));
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
|
||||
Unicode support by Jim Park -- 08/17/2007
|
||||
*/
|
||||
#include "makensisw.h"
|
||||
#define REALSTR(x) #x
|
||||
#define STR(x) REALSTR(x)
|
||||
|
||||
#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
|
||||
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
|
||||
const TCHAR *NSISW_VERSION = _T("MakeNSISW ") __TDATE__;
|
||||
#endif
|
||||
|
|
|
@ -18,9 +18,10 @@ libs = Split("""
|
|||
""")
|
||||
|
||||
Import('BuildUtil env')
|
||||
Import('_tWinMain')
|
||||
|
||||
code = env.Object(code)
|
||||
|
||||
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)
|
||||
|
|
|
@ -188,17 +188,30 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn)
|
|||
int nf=0, nkb=0;
|
||||
g_extracting=1;
|
||||
do {
|
||||
TCHAR filename[MAX_PATH];
|
||||
char filenameA[MAX_PATH];
|
||||
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?
|
||||
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] &&
|
||||
filename[_tcsclen(filename)-1] != _T('\\') &&
|
||||
filename[_tcsclen(filename)-1] != _T('/'))
|
||||
|
@ -485,7 +498,11 @@ void makeEXE(HWND hwndDlg)
|
|||
TCHAR buf[2048];
|
||||
GetTempPath(MAX_PATH,buf);
|
||||
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)
|
||||
{
|
||||
MessageBox(hwndDlg,_T("Error writing .NSI file"),g_errcaption,MB_OK|MB_ICONSTOP);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
#include "../../ExDLL/nsis_tchar.h"
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue