Talk:Get localised font name: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Probably there is a bug in the code)
 
No edit summary
Line 23: Line 23:


Alex Che Korotkin
Alex Che Korotkin
System::Call *(&w${NSIS_MAX_STRLEN})i.R2 is probably a better alternative (You can verify this with System::Call kernel32::GlobalSize(iR2)i.r1 ).
NSIS_CHAR_SIZE is defined as 2 in the unicode build (There might be a NSIS_MAX_STRLEN as bytes define, I don't remember)
--[[User:Anders|Anders]] 17:40, 5 May 2011 (UTC)
----

Revision as of 17:40, 5 May 2011

Hi,

Probably there is a bug in the code. The code first allocates a block of ${NSIS_MAX_STRLEN} bytes, but then copies it to $R0 as a WCHAR string of ${NSIS_MAX_STRLEN} characters, which are actually ${NSIS_MAX_STRLEN} * 2 bytes.

With the Unicode NSIS I have the code crashing from time to time on the line:

 System::Call *$R2(&w${NSIS_MAX_STRLEN}.R0)

I fixed the code by replacing the following lines:

 System::Call *(i${NSIS_MAX_STRLEN})i.R1
 System::Alloc ${NSIS_MAX_STRLEN}
 Pop $R2

with the new lines:

 IntOp $R1 ${NSIS_MAX_STRLEN} * 2 ; number of bytes in WCHAR string of NSIS_MAX_STRLEN length
 System::Call *(i$R1)i.R1
 System::StrAlloc ${NSIS_MAX_STRLEN}
 Pop $R2

I am not a NSIS expert, so the code may be not the most efficient. If my assumption is correct, please, update the code in case everyone else needs it. Thanks.

Alex Che Korotkin


System::Call *(&w${NSIS_MAX_STRLEN})i.R2 is probably a better alternative (You can verify this with System::Call kernel32::GlobalSize(iR2)i.r1 ).

NSIS_CHAR_SIZE is defined as 2 in the unicode build (There might be a NSIS_MAX_STRLEN as bytes define, I don't remember)

--Anders 17:40, 5 May 2011 (UTC)