Buffer bugs fixed, should work better. Hopefully it won't crash anymore.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@945 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a1275ada05
commit
5c627b632c
5 changed files with 64 additions and 55 deletions
|
@ -75,6 +75,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
g_hwnd=hwndDlg;
|
g_hwnd=hwndDlg;
|
||||||
|
g_output_exe = (char *)GlobalAlloc(GPTR, 1);
|
||||||
|
g_input_script = (char *)GlobalAlloc(GPTR, 1);
|
||||||
HICON hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON));
|
HICON hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON));
|
||||||
SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
|
SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
|
||||||
HFONT hFont = CreateFont(14,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,"Courier New");
|
HFONT hFont = CreateFont(14,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,"Courier New");
|
||||||
|
@ -133,6 +135,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
CloseHandle(g_hThread);
|
CloseHandle(g_hThread);
|
||||||
g_hThread=0;
|
g_hThread=0;
|
||||||
}
|
}
|
||||||
|
EnableItems(g_hwnd);
|
||||||
if (g_retcode==0) {
|
if (g_retcode==0) {
|
||||||
MessageBeep(MB_ICONASTERISK);
|
MessageBeep(MB_ICONASTERISK);
|
||||||
if (g_warnings) SetTitle(g_hwnd,"Finished with Warnings");
|
if (g_warnings) SetTitle(g_hwnd,"Finished with Warnings");
|
||||||
|
@ -142,7 +145,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
MessageBeep(MB_ICONEXCLAMATION);
|
MessageBeep(MB_ICONEXCLAMATION);
|
||||||
SetTitle(g_hwnd,"Compile Error: See Log for Details");
|
SetTitle(g_hwnd,"Compile Error: See Log for Details");
|
||||||
}
|
}
|
||||||
EnableItems(g_hwnd);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
@ -220,7 +222,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
l.hwndOwner = hwndDlg;
|
l.hwndOwner = hwndDlg;
|
||||||
l.lpstrFilter = "Log Files (*.log)\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
|
l.lpstrFilter = "Log Files (*.log)\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
|
||||||
l.lpstrFile = buf;
|
l.lpstrFile = buf;
|
||||||
l.nMaxFile = 1023;
|
l.nMaxFile = MAX_STRING-1;
|
||||||
l.lpstrTitle = "Save Output";
|
l.lpstrTitle = "Save Output";
|
||||||
l.lpstrDefExt = "log";
|
l.lpstrDefExt = "log";
|
||||||
l.lpstrInitialDir = NULL;
|
l.lpstrInitialDir = NULL;
|
||||||
|
|
|
@ -51,8 +51,8 @@ extern const char *NSISW_VERSION;
|
||||||
extern char *g_script;
|
extern char *g_script;
|
||||||
extern HWND g_hwnd;
|
extern HWND g_hwnd;
|
||||||
extern HANDLE g_hThread;
|
extern HANDLE g_hThread;
|
||||||
extern char g_output_exe[1024];
|
extern char *g_output_exe;
|
||||||
extern char g_input_script[1024];
|
extern char *g_input_script;
|
||||||
|
|
||||||
// makensisw
|
// makensisw
|
||||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow);
|
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow);
|
||||||
|
|
|
@ -35,19 +35,4 @@ char *my_strrchr(const char *string, int c) {
|
||||||
void *my_memset(void *dest, int c, size_t count) {
|
void *my_memset(void *dest, int c, size_t count) {
|
||||||
for (size_t i = 0; i < count; i++) ((char*)dest)[i]=c;
|
for (size_t i = 0; i < count; i++) ((char*)dest)[i]=c;
|
||||||
return dest;
|
return dest;
|
||||||
}
|
|
||||||
|
|
||||||
char *my_strstr(const char *string, const char *strCharSet) {
|
|
||||||
if (!*strCharSet) return (char*)string;
|
|
||||||
if (lstrlen(string) < lstrlen(strCharSet)) return 0;
|
|
||||||
size_t chklen=lstrlen(string)-lstrlen(strCharSet);
|
|
||||||
char *s1, *s2;
|
|
||||||
for (size_t i = 0; i < chklen; i++) {
|
|
||||||
s1=&((char*)string)[i];
|
|
||||||
s2=(char*)strCharSet;
|
|
||||||
while (*s1++ == *s2++)
|
|
||||||
if (!*s2)
|
|
||||||
return &((char*)string)[i];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -27,6 +27,5 @@ Contribution by kickik
|
||||||
|
|
||||||
char *my_strrchr(const char *string, int c);
|
char *my_strrchr(const char *string, int c);
|
||||||
void *my_memset(void *dest, int c, size_t count);
|
void *my_memset(void *dest, int c, size_t count);
|
||||||
char *my_strstr(const char *string, const char *strCharSet);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -51,8 +51,8 @@ void ClearLog(HWND hwnd) {
|
||||||
SetDlgItemText(hwnd, IDC_LOGWIN, "");
|
SetDlgItemText(hwnd, IDC_LOGWIN, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
char g_output_exe[1024];
|
char *g_output_exe;
|
||||||
char g_input_script[1024];
|
char *g_input_script;
|
||||||
extern BOOL g_warnings;
|
extern BOOL g_warnings;
|
||||||
|
|
||||||
void LogMessage(HWND hwnd,const char *str) {
|
void LogMessage(HWND hwnd,const char *str) {
|
||||||
|
@ -83,37 +83,58 @@ void DisableItems(HWND hwnd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnableItems(HWND hwnd) {
|
void EnableItems(HWND hwnd) {
|
||||||
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
|
#define MSG(a) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,0,0)
|
||||||
if (len>0) {
|
#define MSG1(a,b) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,0)
|
||||||
HGLOBAL memory;
|
#define MSG2(a,b,c) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,c)
|
||||||
char *existing_text;
|
|
||||||
memory = GlobalAlloc(GMEM_MOVEABLE,len+1);
|
static char *outputExeBuf, *inputScriptBuf;
|
||||||
existing_text = (char *)GlobalLock(memory);
|
|
||||||
if (!existing_text) return;
|
if (inputScriptBuf) {
|
||||||
existing_text[0]=0;
|
GlobalFree(inputScriptBuf);
|
||||||
GetDlgItemText(hwnd, IDC_LOGWIN, existing_text, len);
|
g_input_script = inputScriptBuf = 0;
|
||||||
char *p=existing_text;
|
}
|
||||||
char *p2;
|
if (outputExeBuf) {
|
||||||
char *p3;
|
GlobalFree(outputExeBuf);
|
||||||
if ((p2=my_strstr(p,"\r\nOutput: \""))) {
|
g_output_exe = outputExeBuf = 0;
|
||||||
while (*p2 != '\"') p2++;
|
}
|
||||||
p2++;
|
|
||||||
if ((p3=my_strstr(p2,"\"\r\n")) && p3 < my_strstr(p2,"\r\n")) {
|
if (g_input_script) GlobalFree(g_input_script);
|
||||||
*p3=0;
|
if (g_output_exe) GlobalFree(g_output_exe);
|
||||||
lstrcpy(g_output_exe,p2);
|
|
||||||
}
|
FINDTEXT ft;
|
||||||
}
|
ft.chrg.cpMin = 0;
|
||||||
p=my_strstr(existing_text,"\r\nProcessing script file: \"");
|
ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH);
|
||||||
if (p) {
|
ft.lpstrText = "Processing script file: \"";
|
||||||
while (*p++ != '"');
|
long charPos = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
|
||||||
char *p2=my_strstr(p,"\r\n");
|
long lineNum = MSG2(EM_EXLINEFROMCHAR, 0, charPos);
|
||||||
lstrcpyn(g_input_script,p,p2-p);
|
long lineLength = MSG1(EM_LINELENGTH, charPos);
|
||||||
}
|
inputScriptBuf = (char *)GlobalAlloc(GPTR, lineLength+1);
|
||||||
if (my_strstr(existing_text, " warning:") || my_strstr(existing_text, " warnings:")) {
|
*(WORD *)inputScriptBuf = (WORD)lineLength+1;
|
||||||
g_warnings = TRUE;
|
MSG2(EM_GETLINE, lineNum, (WPARAM)inputScriptBuf);
|
||||||
}
|
g_input_script = inputScriptBuf+lstrlen("Processing script file: \"");
|
||||||
GlobalUnlock(memory);
|
char *p = g_input_script;
|
||||||
}
|
while (*p && *p != '"') p++;
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
ft.lpstrText = "Output: \"";
|
||||||
|
charPos = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
|
||||||
|
lineNum = MSG2(EM_EXLINEFROMCHAR, 0, charPos);
|
||||||
|
lineLength = MSG1(EM_LINELENGTH, charPos);
|
||||||
|
outputExeBuf = (char *)GlobalAlloc(GPTR, lineLength+1);
|
||||||
|
*(WORD *)outputExeBuf = (WORD)lineLength+1;
|
||||||
|
MSG2(EM_GETLINE, lineNum, (WPARAM)outputExeBuf);
|
||||||
|
g_output_exe = outputExeBuf+lstrlen("Output: \"");
|
||||||
|
p = g_output_exe;
|
||||||
|
while (*p && *p != '"') p++;
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
g_warnings = FALSE;
|
||||||
|
|
||||||
|
ft.lpstrText = "warning:";
|
||||||
|
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++;
|
||||||
|
ft.lpstrText = "warnings:";
|
||||||
|
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++;
|
||||||
|
|
||||||
HMENU m = GetMenu(hwnd);
|
HMENU m = GetMenu(hwnd);
|
||||||
if (g_output_exe[0]) {
|
if (g_output_exe[0]) {
|
||||||
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
|
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
|
||||||
|
@ -130,7 +151,7 @@ void EnableItems(HWND hwnd) {
|
||||||
|
|
||||||
static BOOL g_appended = FALSE;
|
static BOOL g_appended = FALSE;
|
||||||
void CompileNSISScript() {
|
void CompileNSISScript() {
|
||||||
char s[MAX_PATH];
|
static char *s;
|
||||||
ClearLog(g_hwnd);
|
ClearLog(g_hwnd);
|
||||||
SetTitle(g_hwnd,NULL);
|
SetTitle(g_hwnd,NULL);
|
||||||
SetBranding(g_hwnd);
|
SetBranding(g_hwnd);
|
||||||
|
@ -144,8 +165,10 @@ void CompileNSISScript() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!g_appended) {
|
if (!g_appended) {
|
||||||
|
if (s) GlobalFree(s);
|
||||||
|
s = (char *)GlobalAlloc(GPTR, lstrlen(g_script)+lstrlen(EXENAME)+1);
|
||||||
wsprintf(s,"%s %s",EXENAME,g_script);
|
wsprintf(s,"%s %s",EXENAME,g_script);
|
||||||
lstrcpy(g_script,s);
|
g_script = s;
|
||||||
g_appended = TRUE;
|
g_appended = TRUE;
|
||||||
}
|
}
|
||||||
// Disable buttons during compile
|
// Disable buttons during compile
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue