I'm using a sample script to read ini files, especially to read section names, to determine if a section exist before try to delete it.
The problem is that the installer crashes randomically, I could check that the size of section is always right, but when the error shows, it is at below call:
System::Call `kernel32::lstrlen(i $pNextSection)i.r5`$NOMESECTION is defined on another macro that calls this func, removing the callback gives the same error, so I choose put complete code here.
I dont know much about pointers, but I think it is all ok with the calls.
My function:
!define GSN_BufferSize 1024
VAR /GLOBAL lpszReturnBuffer
VAR /GLOBAL fncAddr
VAR /GLOBAL nSize
VAR /GLOBAL pNextSection
VAR /GLOBAL IniPath
VAR /GLOBAL iniSecSize
VAR /GLOBAL PTR_FNC
!define GetSectionNames `!insertmacro GetSectionNamesCall`
!macro GetSectionNamesCall _FILE _FUNC
StrCpy `$IniPath` `${_FILE}`
GetFunctionAddress $fncAddr `${_FUNC}`
Call GetSectionNames
!macroend
Function GetSectionNames
System::Call `*(&t${GSN_BufferSize})i.r2`
StrCpy $PTR_FNC $2
StrCpy $lpszReturnBuffer $2
System::Call `kernel32::GetPrivateProfileSectionNames(i,i,t) ($lpszReturnBuffer, ${GSN_BufferSize}, '$IniPath')`
StrCpy $pNextSection $lpszReturnBuffer
${Do}
System::Call `kernel32::lstrlen(i $pNextSection)i.r5`
StrCpy $iniSecSize $5
System::Call `*$pNextSection(&m${GSN_BufferSize} .r9)`
Call $fncAddr
${If} $9 == 'StopGetSectionName'
${ExitDo}
${Endif}
IntOp $pNextSection $pNextSection + $iniSecSize
IntOp $pNextSection $pNextSection + 1
System::Call `kernel32::lstrlen(i $pNextSection)i.r5`
StrCpy $iniSecSize $5
${LoopWhile} $iniSecSize != 0
System::Free $PTR_FNC
FunctionEnd
Function LISTASECTIONCALLBACK
${If} $9 == $NOMESECTION
StrCpy $9 'StopGetSectionName'
${Endif}
FunctionEnd