【问题标题】:How can I reverse-engineer an installer that was written with ghost-installer?如何对使用 ghost-installer 编写的安装程序进行反向工程?
【发布时间】:2010-11-09 13:22:05
【问题描述】:

我有一个安装程序,但我没有任何源代码。我需要“包装”此安装程序或对其进行编辑以添加更多文件。最好的方法是什么?如标题所述,安装程序是使用 ghost 安装程序编写的。

【问题讨论】:

    标签: reverse-engineering


    【解决方案1】:

    由于它不是 MSI,因此您不能使用 Orca to edit the installer itself。我之前也为我的 MSI 安装程序写过 custom install actions

    由于您对 Ghost 安装程序没有太多控制(如果有的话),我可能会编写一个自定义可执行文件来补充安装程序,它可以在安装程序之前或之后运行。这将创建一些额外的文件以分发给您的客户,但您可以将整个文件以 zip 存档的形式分发。

    首先,如果您想像 Visual Studio 一样创建非托管引导程序以确保安装先决条件,您可以通过 MSBuild 使用如下脚本来完成:

    <Project ToolsVersion="3.5" DefaultTargets="BuildBootstrapper" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <ItemGroup>
        <BootstrapperFile Include="Microsoft.Net.Framework.2.0">
          <ProductName>Microsoft .NET Framework 2.0</ProductName>
        </BootstrapperFile>
      </ItemGroup>
    
      <Target Name="BuildBootstrapper">
        <GenerateBootstrapper
          ApplicationFile="CustomInstallerExecutable.exe"
          ApplicationName="Pretty Title of Application Goes Here"
          BootstrapperItems="@(BootstrapperFile)"
          ComponentsLocation="Relative" />
      </Target>
    
    </Project>
    

    这将生成一个“setup.exe”,它是安装程序的任何引导程序的实际文件名。事实上,如果您想确保用户不会意外跳过引导程序并直接进入安装程序,您可以将 Ghost 安装程序隐藏在“bin”文件夹或远离 zip 存档根目录的地方。这样,他们唯一直观的选择就是“setup.exe”。如果您为了客户的缘故需要非常清楚,也包括“README.txt”。

    此引导程序还可以确保客户端具有 .NET 2.0 框架作为先决条件,以便您的“CustomInstallerExecutable.exe”可以用 .NET 而不是非托管语言编写。事实上,这个 MSBuild 脚本会在新创建的引导程序旁边弹出 .NET 2.0 Framework 安装程序(因为“ComponentsLocation”属性的“Relative”值)。如果您担心将 Ghost 安装程序下载的原始下载大小膨胀给客户,您可以使用其他属性值来帮助用户通过 Web 获取 .NET Framework。

    现在,您的“CustomInstallerExecutable.exe”(用漂亮的托管 C# 编写)可以在运行 Ghost 安装程序之前(或之后)将额外文件放到机器上。我之前编写了一些代码来从 .NET 可执行文件运行 MSI:

    string msiString = "blahBlah.msi";
    
    // Kick off Update installer
    ProcessStartInfo startInfo = new ProcessStartInfo(
        "cmd.exe",
        "/c start /wait msiexec.exe /i " + msiString);
    startInfo.WorkingDirectory = "bin";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    
    Process process = new Process
    {
        StartInfo = startInfo,
        EnableRaisingEvents = true
    };
    process.Exited += new EventHandler(process_Exited);
    
    process.Start();
    

    我认为你可以做一些非常类似的事情来调用你的 Ghost 安装程序而不是 MSI。如果您在 Ghost 安装程序之前运行此 .NET 可执行文件,您可以只调用 Ghost 安装程序进程,然后退出“CustomInstallerExecutable.exe”进程,而不是等待 process.Exited 事件触发。此事件等待将更多用于运行“安装后”逻辑。

    祝你好运,希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-20
      • 1970-01-01
      • 1970-01-01
      • 2017-04-18
      • 2013-01-25
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      相关资源
      最近更新 更多