Fix exehead unicode compil warnings
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6048 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
64a0f32e52
commit
f5df185ba2
4 changed files with 56 additions and 17 deletions
|
@ -716,8 +716,8 @@ skipPage:
|
||||||
static DWORD dwRead;
|
static DWORD dwRead;
|
||||||
DWORD CALLBACK StreamLicense(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
|
DWORD CALLBACK StreamLicense(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
|
||||||
{
|
{
|
||||||
lstrcpyn(pbBuff,(TCHAR*)dwCookie+dwRead,cb);
|
lstrcpynA(pbBuff,(char*)dwCookie+dwRead,cb);
|
||||||
*pcb=mystrlen(pbBuff);
|
*pcb=lstrlenA(pbBuff);
|
||||||
dwRead+=*pcb;
|
dwRead+=*pcb;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -983,7 +983,10 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
h=LoadLibraryEx(buf1, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
h=LoadLibraryEx(buf1, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||||
if (h)
|
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)
|
if (funke)
|
||||||
{
|
{
|
||||||
exec_error--;
|
exec_error--;
|
||||||
|
@ -1281,10 +1284,12 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
p[0]=0;
|
p[0]=0;
|
||||||
if (hKey)
|
if (hKey)
|
||||||
{
|
{
|
||||||
DWORD l = NSIS_MAX_STRLEN - 1;
|
DWORD l = NSIS_MAX_STRLEN*sizeof(TCHAR);
|
||||||
DWORD t;
|
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))
|
(t != REG_DWORD && t != REG_SZ && t != REG_EXPAND_SZ))
|
||||||
{
|
{
|
||||||
p[0]=0;
|
p[0]=0;
|
||||||
|
@ -1300,7 +1305,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exec_error += parm4;
|
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);
|
RegCloseKey(hKey);
|
||||||
|
@ -1360,16 +1365,16 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
DWORD dw;
|
DWORD dw;
|
||||||
int l;
|
int l;
|
||||||
TCHAR *t=var0;
|
TCHAR *t=var0;
|
||||||
if (parm2) // WriteByte
|
if (parm2)
|
||||||
{
|
{
|
||||||
((unsigned char *)buf1)[0]=GetIntFromParm(1)&0xff;
|
((_TUCHAR *)buf1)[0]=(_TUCHAR) GetIntFromParm(1);
|
||||||
l=1;
|
l=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
l=mystrlen(GetStringFromParm(0x11));
|
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++;
|
exec_error++;
|
||||||
}
|
}
|
||||||
|
@ -1377,29 +1382,29 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
break;
|
break;
|
||||||
case EW_FGETS:
|
case EW_FGETS:
|
||||||
{
|
{
|
||||||
char *textout=var1;
|
TCHAR *textout=var1;
|
||||||
DWORD dw;
|
DWORD dw;
|
||||||
int rpos=0;
|
int rpos=0;
|
||||||
char *hptr=var0;
|
TCHAR *hptr=var0;
|
||||||
int maxlen=GetIntFromParm(2);
|
int maxlen=GetIntFromParm(2);
|
||||||
if (maxlen<1) break;
|
if (maxlen<1) break;
|
||||||
if (maxlen > NSIS_MAX_STRLEN-1) maxlen=NSIS_MAX_STRLEN-1;
|
if (maxlen > NSIS_MAX_STRLEN-1) maxlen=NSIS_MAX_STRLEN-1;
|
||||||
if (*hptr)
|
if (*hptr)
|
||||||
{
|
{
|
||||||
char lc=0;
|
TCHAR lc=0;
|
||||||
HANDLE h=(HANDLE)myatoi(hptr);
|
HANDLE h=(HANDLE)myatoi(hptr);
|
||||||
while (rpos<maxlen)
|
while (rpos<maxlen)
|
||||||
{
|
{
|
||||||
char c;
|
TCHAR c;
|
||||||
if (!ReadFile(h,&c,sizeof(c),&dw,NULL) || dw != sizeof(c)) break;
|
if (!ReadFile(h,&c,sizeof(c),&dw,NULL) || dw != sizeof(c)) break;
|
||||||
if (parm3)
|
if (parm3)
|
||||||
{
|
{
|
||||||
myitoa(textout,(unsigned int)(unsigned char)c);
|
myitoa(textout,(unsigned int)(_TUCHAR)c);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (lc == '\r' || lc == '\n')
|
if (lc == _T('\r') || lc == _T('\n'))
|
||||||
{
|
{
|
||||||
if (lc == c || (c != '\r' && c != '\n')) SetFilePointer(h,-((int)(sizeof(c))),NULL,FILE_CURRENT);
|
if (lc == c || (c != _T('\r') && c != _T('\n'))) SetFilePointer(h,-((int)(sizeof(c))),NULL,FILE_CURRENT);
|
||||||
else textout[rpos++]=c;
|
else textout[rpos++]=c;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,7 +492,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||||
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
char *pszNextSec = mystrstriA(pszFirstRenameLine,"\n[");
|
||||||
if (pszNextSec)
|
if (pszNextSec)
|
||||||
{
|
{
|
||||||
TCHAR *p = ++pszNextSec;
|
char *p = ++pszNextSec;
|
||||||
while (p < pszWinInit + dwFileSize) {
|
while (p < pszWinInit + dwFileSize) {
|
||||||
p[cchRenameLine] = *p;
|
p[cchRenameLine] = *p;
|
||||||
p++;
|
p++;
|
||||||
|
@ -1031,3 +1031,25 @@ void NSISCALL MessageLoop(UINT uCheckedMsg)
|
||||||
while (PeekMessage(&msg, NULL, uCheckedMsg, uCheckedMsg, PM_REMOVE))
|
while (PeekMessage(&msg, NULL, uCheckedMsg, uCheckedMsg, PM_REMOVE))
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is useful for Unicode support. Since the Windows
|
||||||
|
* GetProcAddress function always takes a char*, this function wraps
|
||||||
|
* the windows call and does the appropriate translation when
|
||||||
|
* appropriate.
|
||||||
|
*
|
||||||
|
* @param dllHandle Handle to the DLL loaded by LoadLibraryEx.
|
||||||
|
* @param funcName The name of the function to get the address of.
|
||||||
|
* @return The pointer to the function. Null if failure.
|
||||||
|
*/
|
||||||
|
void * NSISCALL NSISGetProcAddress(HANDLE dllHandle, TCHAR* funcName)
|
||||||
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
char ansiName[NSIS_MAX_STRLEN];
|
||||||
|
if (WideCharToMultiByte(CP_ACP, 0, funcName, -1, ansiName, NSIS_MAX_STRLEN, NULL, NULL) != 0)
|
||||||
|
return GetProcAddress(dllHandle, ansiName);
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
return GetProcAddress(dllHandle, funcName);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -124,6 +124,18 @@ enum myGetProcAddressFunctions {
|
||||||
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
||||||
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is useful for Unicode support. Since the Windows
|
||||||
|
* GetProcAddress function always takes a char*, this function wraps
|
||||||
|
* the windows call and does the appropriate translation when
|
||||||
|
* appropriate.
|
||||||
|
*
|
||||||
|
* @param dllHandle Handle to the DLL loaded by LoadLibraryEx.
|
||||||
|
* @param funcName The name of the function to get the address of.
|
||||||
|
* @return The pointer to the function. Null if failure.
|
||||||
|
*/
|
||||||
|
void * NSISCALL NSISGetProcAddress(HANDLE dllHandle, TCHAR* funcName);
|
||||||
|
|
||||||
// Turn a pair of chars into a word
|
// Turn a pair of chars into a word
|
||||||
// Turn four chars into a dword
|
// Turn four chars into a dword
|
||||||
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue