Exemple #1
0
        private void AssembleStub()
        {
            try
            {
                string intermediateOutputFileName = GetIntermediateBinaryPath(Path.GetFileName(OutputFileName));
                int    exitCode = Helper.FasmCompile
                                  (
                    GetIntermediateSourcePath("Stub.asm"),
                    intermediateOutputFileName,
                    out string fasmOutput
                                  );

                if (exitCode == 0)
                {
                    Helper.AppendEofData(intermediateOutputFileName);
                    File.Copy(intermediateOutputFileName, OutputFileName, true);
                }
                else
                {
                    Errors.Add(ErrorSource.Assembly, ErrorSeverity.Error, "FASM.exe returned status code " + exitCode + ".", fasmOutput.Trim());
                }
            }
            catch (ErrorException ex)
            {
                Errors.Add(ErrorSource.Assembly, ErrorSeverity.Error, ex.Message, ex.Details);
            }
            catch (Exception ex)
            {
                Errors.Add(ErrorSource.Assembly, ErrorSeverity.Error, "Unhandled " + ex.GetType() + " while assembling stage2.", ex.GetFullStackTrace());
            }
        }
Exemple #2
0
        private void AssembleStub()
        {
            try
            {
                string intermediateOutputFileName = GetIntermediateBinaryPath(Project.VersionInfo.OriginalFilename.ToNullIfEmpty() ?? Path.GetFileName(OutputFileName));

                string manifestFileName;
                if (Project.Manifest.Template != null)
                {
                    manifestFileName = GetIntermediateSourcePath(@"Resources\" + Project.Manifest.Template.GetDescription() + ".manifest");
                }
                else if (Project.Manifest.Path != null)
                {
                    manifestFileName = GetIntermediateSourcePath(@"Resources\" + Path.GetFileNameWithoutExtension(Project.Manifest.Path) + ".manifest");
                    File.Copy(Project.Manifest.Path, manifestFileName);
                }
                else
                {
                    manifestFileName = null;
                }

                string iconFileName;
                if (Project.Stub.IconPath != null)
                {
                    iconFileName = GetIntermediateSourcePath(@"Resources\icon.ico");

                    Icon icon = IconExtractor.FromFile(Project.Stub.IconPath);
                    if (icon == null)
                    {
                        throw new ErrorException("Could not read icon from file '" + Path.GetFileName(Project.Stub.IconPath) + "'.");
                    }

                    icon.Save(iconFileName);
                }
                else
                {
                    iconFileName = null;
                }

                bool success = Helper.DotNetCompile
                               (
                    StubSourceCodeFiles.Select(file => GetIntermediateSourcePath(file)).ToArray(),
                    new[]
                {
                    "mscorlib.dll",
                    "System.dll",
                    "System.Core.dll",
                    "System.Windows.Forms.dll"
                },
                    new[]
                {
                    GetIntermediateSourcePath(@"Resources\" + StubResourcesFileName)
                },
                    manifestFileName,
                    iconFileName,
                    intermediateOutputFileName,
                    Is64Bit,
                    out string[] errors
                               );

                if (success)
                {
                    Helper.AppendEofData(intermediateOutputFileName);
                    File.Copy(intermediateOutputFileName, OutputFileName, true);
                }
                else
                {
                    Errors.AddRange(errors.Select(error => new Error(ErrorSource.Assembly, ErrorSeverity.Error, error)));
                }
            }
            catch (ErrorException ex)
            {
                Errors.Add(ErrorSource.Assembly, ErrorSeverity.Error, ex.Message, ex.Details);
            }
            catch (Exception ex)
            {
                Errors.Add(ErrorSource.Assembly, ErrorSeverity.Error, "Unhandled " + ex.GetType() + " while assembling stub.", ex.GetFullStackTrace());
            }
        }