From db1838e746d31d318a749b551d1e35e87d6ca533 Mon Sep 17 00:00:00 2001 From: anders_k Date: Wed, 5 Jun 2013 09:47:39 +0000 Subject: [PATCH] Try to handle Unicode mode changes after !include git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6372 212acab6-be3b-0410-9dea-997c60f758d6 --- Include/Win/COM.nsh | 6 +++++- Include/WinVer.nsh | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Include/Win/COM.nsh b/Include/Win/COM.nsh index 386d3a23..a0e86408 100644 --- a/Include/Win/COM.nsh +++ b/Include/Win/COM.nsh @@ -43,7 +43,7 @@ ${EndIf} !ifndef __WIN_COM__INC -!define __WIN_COM__INC +!define __WIN_COM__INC ${NSIS_CHAR_SIZE} !verbose push !verbose 3 @@ -57,6 +57,10 @@ ${EndIf} !define NSISCOMCALL "!insertmacro NSISCOMCALL " !macro NSISCOMCALL vtblidx decl ptr params +!if ${NSIS_CHAR_SIZE} <> ${__WIN_COM__INC} +; Warn if QueryInterface() for IID_IShellLink etc will return the wrong interface +!warning "NSIS_CHAR_SIZE changed, existing defines and macros might not work correctly!" +!endif System::Call `${ptr}->${vtblidx}${decl}${params}` !macroend !define NSISCOMIFACEDECL "!insertmacro NSISCOMIFACEDECL " diff --git a/Include/WinVer.nsh b/Include/WinVer.nsh index 4fe9b03e..09753912 100644 --- a/Include/WinVer.nsh +++ b/Include/WinVer.nsh @@ -149,21 +149,15 @@ # use this to make all nt > 9x !ifdef WINVER_NT4_OVER_W95 - !define __WINVERTMP ${WINVER_NT4} - !undef WINVER_NT4 - !define /math WINVER_NT4 ${__WINVERTMP} | ${_WINVER_VERXBIT} - !undef __WINVERTMP + !define /redef /math WINVER_NT4 ${WINVER_NT4} | ${_WINVER_VERXBIT} !endif # some definitions from header files -!ifdef NSIS_UNICODE -!define OSVERSIONINFO_SIZE 276 ; OSVERSIONINFOW -!define OSVERSIONINFOEX_SIZE 284 ; OSVERSIONINFOEXW -!else -!define OSVERSIONINFO_SIZE 148 ; OSVERSIONINFOA -!define OSVERSIONINFOEX_SIZE 156 ; OSVERSIONINFOEXA -!endif +!define OSVERSIONINFOW_SIZE 276 +!define OSVERSIONINFOEXW_SIZE 284 +!define OSVERSIONINFOA_SIZE 148 +!define OSVERSIONINFOEXA_SIZE 156 !define /ifndef VER_PLATFORM_WIN32_NT 2 !define /ifndef VER_NT_WORKSTATION 1 @@ -216,9 +210,17 @@ Push $3 ;bld Push $R0 ;temp + # a plugin call will lock the Unicode mode, it is now safe to set the struct size + !ifdef NSIS_UNICODE + !define /redef OSVERSIONINFO_SIZE ${OSVERSIONINFOW_SIZE} + !define /redef OSVERSIONINFOEX_SIZE ${OSVERSIONINFOEXW_SIZE} + !else + !define /redef OSVERSIONINFO_SIZE ${OSVERSIONINFOA_SIZE} + !define /redef OSVERSIONINFOEX_SIZE ${OSVERSIONINFOEXA_SIZE} + !endif + # allocate memory - System::Alloc ${OSVERSIONINFOEX_SIZE} - Pop $0 + System::Call '*(&i${OSVERSIONINFOEX_SIZE})p.r0' # use OSVERSIONINFOEX !insertmacro __WinVer_Call_GetVersionEx ${OSVERSIONINFOEX_SIZE}