How to read/execute NSIS script from memory in VB program

时间:2015-07-31 19:18:35

标签: vb.net nsis

I have a VB.NET application that is essentially a front end for a NSIS script. The script is called with all of the files and variables given on the commandline. The purpose of the application is to search and find these files on a persons computer, then format the commandline and call the NSIS script to create the installer.

I want to be able to distribute this program and protect NSIS script source code. What I was looking for is a way to "read" the script from memory within the application. My idea is that the contents of the script would be saved inside of the application, then whenever it is needed the script could be loaded and called without ever having to actually write it to the users computer.

Is this possible? If so what should I look for to accomplish it. I don't need step by step (not that you could provide one with such a skeletal outline) just what is the major concept or functions inside VB that would allow me to do this.

1 个答案:

答案 0 :(得分:1)

我假设您使用的是官方NSIS编译器而不是自定义.dll版本?如果是这种情况,则有人可以将makensis.exe替换为将stdin写入文件的内容。 NSIS 3还支持将预处理脚本转储到stdout或文件,因此如果您允许用户修改传递给makensis的开关,那么这将是一种简单的方法来恢复大部分脚本。

即使我们将NSIS排除在等式之外,您也会遇到难以解决的问题。我建议您只使用简单的XOR密码加密脚本,这应该可以阻止大多数人在十六进制编辑器中查看.exe。如果需要,您当然可以使用stronger encryption

当您打算调用makensis时,您将retrieve加密的脚本资源作为内存流或数组,对其进行解密,然后将其作为stdin传递给makensis使用ProcessStartInfo.RedirectStandardInput ...