当文件不存在时,NSIS 回调函数会使安装程序崩溃

发布于 2024-08-19 00:05:37 字数 905 浏览 5 评论 0原文

我被困在这个问题上。 我在下标(.nsh)文件的底部有这个回调函数。 (正如你所看到的,我正在使用 LogicLib):

Function InstallFoo
MessageBox MB_OK "Within InstallFoo function"
${If} ${FileExists} "$EXEDIR\Modules\foo.zip" 
MessageBox MB_OK "foo.zip found, do install it!"
nsisunz::Unzip "$EXEDIR\Modules\foo.zip" "$INSTDIR\Foo"
${Else}
MessageBox MB_OK "No foo.zip found. Do nothing"
${EndIf}

MessageBox MB_OK "End reached"
FunctionEnd

当“foo.zip”存在时,一切都按照我想要的方式工作,但是当“foo.zip”不存在时,安装程​​序就会崩溃,我真的不明白为什么。

我希望它也能够在找不到“foo.zip”时处理,即什么都不做。现在发生的情况是安装程序崩溃了 “setup.exe - 应用程序错误,“某个地址”处的指令引用了“某个其他地址”处的内存。无法“读取”内存。

我的脚本中的部分中有相同类型的代码,并且它 回调函数有关。

无论是否存在 zip 文件,它都可以正常工作,只是在这个回调函数中不起作用,所以我开始认为它与“foo.zip 文件”中的 不存在' - 我收到以下消息框:“在 InstallFoo 函数中”“未找到 foo.zip。不执行任何操作”“到达终点”

然后崩溃。我在调用回调的部分中有一个 MessageBox 打印输出,也就是说,从回调函数返回后发生的第一件事,但它永远不会到达那里。 请注意,一旦 foo.zip 出现,一切就正常了!

有谁知道我在这里可能做错了什么?

I'm stuck on this.
I have this callback function at the bottom of a subscript (.nsh) file.
(As you can see I'm using LogicLib):

Function InstallFoo
MessageBox MB_OK "Within InstallFoo function"
${If} ${FileExists} "$EXEDIR\Modules\foo.zip" 
MessageBox MB_OK "foo.zip found, do install it!"
nsisunz::Unzip "$EXEDIR\Modules\foo.zip" "$INSTDIR\Foo"
${Else}
MessageBox MB_OK "No foo.zip found. Do nothing"
${EndIf}

MessageBox MB_OK "End reached"
FunctionEnd

Everything works exactly as I want it to when the 'foo.zip' is present, but when it isn't, the installer crashes, and I really can't understand why.

I would expect it to also be able to handle when the 'foo.zip' is not found, that is by doing nothing. What happens now is that the installer crashes with
"setup.exe - Application Error, The instruction at "some-address" referenced memory at "some-other-address". The memory could not be "read".

I have the same type of code within sections in my scripts and it works fine there, whether zip-files present or not. It's just in this callback function it doesn't work, so I'm starting to think it has something to do with it being a callback function.

In the 'foo.zip file not present' - case I get the following MessageBoxes: "Within InstallFoo function" "No foo.zip found. Do nothing" "End reached"

And then the crash. I have a MessageBox printout within the section where the callback was called from also, that is, the first thing to happen after the return from the callback function, but it never gets there.
Note, as soon as the foo.zip is there everything works just fine!

Does anyone have any idea of what I might be doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺孤伤于心 2024-08-26 00:05:37

在我看来,只要回调函数中没有执行任何操作,我就会崩溃。

NSIS 是否为回调函数分配了一些内存,如果不使用它,我们就会崩溃..?诡异的。

It seems to me I get the crash whenever nothing's done within the callback function.

Is it that NSIS allocates some memory for the callback function, and if it's not used we get the crash..?? Weird.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文