From f5df185ba26711eccb237b623cae9ff19f8c72b3 Mon Sep 17 00:00:00 2001 From: wizou Date: Tue, 13 Apr 2010 15:01:14 +0000 Subject: [PATCH] Fix exehead unicode compil warnings git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6048 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Ui.c | 4 ++-- Source/exehead/exec.c | 33 +++++++++++++++++++-------------- Source/exehead/util.c | 24 +++++++++++++++++++++++- Source/exehead/util.h | 12 ++++++++++++ 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index a7e5e87e..f5b20e7f 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -716,8 +716,8 @@ skipPage: static DWORD dwRead; DWORD CALLBACK StreamLicense(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - lstrcpyn(pbBuff,(TCHAR*)dwCookie+dwRead,cb); - *pcb=mystrlen(pbBuff); + lstrcpynA(pbBuff,(char*)dwCookie+dwRead,cb); + *pcb=lstrlenA(pbBuff); dwRead+=*pcb; return 0; } diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index d92f824f..c3fb8e86 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -983,7 +983,10 @@ static int NSISCALL ExecuteEntry(entry *entry_) h=LoadLibraryEx(buf1, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (h) { - FARPROC funke = GetProcAddress(h,buf0); + // Jim Park: Need to use our special NSISGetProcAddress to convert + // buf0 to char before calling GetProcAddress() which only takes + // chars. + FARPROC funke = NSISGetProcAddress(h,buf0); if (funke) { exec_error--; @@ -1281,10 +1284,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) p[0]=0; if (hKey) { - DWORD l = NSIS_MAX_STRLEN - 1; + DWORD l = NSIS_MAX_STRLEN*sizeof(TCHAR); DWORD t; - if (RegQueryValueEx(hKey,buf3,NULL,&t,p,&l) != ERROR_SUCCESS || + // Jim Park: If plain text in p or binary data in p, + // user must be careful in accessing p correctly. + if (RegQueryValueEx(hKey,buf3,NULL,&t,(LPBYTE)p,&l) != ERROR_SUCCESS || (t != REG_DWORD && t != REG_SZ && t != REG_EXPAND_SZ)) { p[0]=0; @@ -1300,7 +1305,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) else { exec_error += parm4; - p[l]=0; + p[NSIS_MAX_STRLEN-1]=0; // RegQueryValueEx adds a null terminator, UNLESS the value is NSIS_MAX_STRLEN long } } RegCloseKey(hKey); @@ -1360,16 +1365,16 @@ static int NSISCALL ExecuteEntry(entry *entry_) DWORD dw; int l; TCHAR *t=var0; - if (parm2) // WriteByte + if (parm2) { - ((unsigned char *)buf1)[0]=GetIntFromParm(1)&0xff; + ((_TUCHAR *)buf1)[0]=(_TUCHAR) GetIntFromParm(1); l=1; } else { l=mystrlen(GetStringFromParm(0x11)); } - if (!*t || !WriteFile((HANDLE)myatoi(t),buf1,l,&dw,NULL)) + if (!*t || !WriteFile((HANDLE)myatoi(t),buf1,l*sizeof(TCHAR),&dw,NULL)) { exec_error++; } @@ -1377,29 +1382,29 @@ static int NSISCALL ExecuteEntry(entry *entry_) break; case EW_FGETS: { - char *textout=var1; + TCHAR *textout=var1; DWORD dw; int rpos=0; - char *hptr=var0; + TCHAR *hptr=var0; int maxlen=GetIntFromParm(2); if (maxlen<1) break; if (maxlen > NSIS_MAX_STRLEN-1) maxlen=NSIS_MAX_STRLEN-1; if (*hptr) { - char lc=0; + TCHAR lc=0; HANDLE h=(HANDLE)myatoi(hptr); while (rpos