Does ${GetDrives} from FileFunc.nsh clear the stack values created from within the callback?

StackOverflow https://stackoverflow.com/questions/21562661

  •  07-10-2022
  •  | 
  •  

Question

Why is it that when the stack_test function is called by ${GetDrives} the stack doesn't retain "Hello", but when using Call stack_test, "Hello" is there on the stack?

I expect to see this:

$0 = Hello
$0 = Hello

but instead I see this:

$0 = Goodbye
$0 = Hello

Here's the test case I'm using:

!include FileFunc.nsh

Name stack_test
OutFile stack_test.exe
ShowInstDetails show

Page instfiles


Function stack_test
    Push "Hello"
FunctionEnd

Section section1
    Push "Goodbye"
    ${GetDrives} "HDD" stack_test
    Pop $0
    DetailPrint "$$0 = $0"

    Push "Goodbye"
    Call stack_test
    Pop $0
    DetailPrint "$$0 = $0"
SectionEnd
Was it helpful?

Solution

GetDrives requires the callback function to push something to the stack and will pop after your callback returns. If you push "StopGetDrives" then the drive enumeration is aborted, otherwise it continues if there are more drives.

You should not expect your stack changes to survive if they are in a callback function like this and the number of pushes depends on how many drives the end-user has in this case...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top