diff jet-symbols/src/JetBrains.CommandLine.Symbols/DumpBinaryFileSignCommand.cs @ 102:0e927b14ccf1

restored jet-symbols native tool sources
author Evgeniy.Koshkin@unit-519.Labs.IntelliJ.Net
date Mon, 16 May 2016 19:40:51 +0300
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/DumpBinaryFileSignCommand.cs	Mon May 16 19:40:51 2016 +0300
@@ -0,0 +1,42 @@
+// Decompiled with JetBrains decompiler
+// Type: JetBrains.CommandLine.Symbols.DumpBinaryFileSignCommand
+// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325
+// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853
+// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe
+
+using JetBrains.Metadata.Utils;
+using JetBrains.Metadata.Utils.PE;
+using JetBrains.Util;
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace JetBrains.CommandLine.Symbols
+{
+  public class DumpBinaryFileSignCommand : DumpFilesSignCommandBase
+  {
+    public const string CMD_NAME = "dumpBinSign";
+
+    public DumpBinaryFileSignCommand(FileSystemPath outputFilePath, IEnumerable<FileSystemPath> targetFilePaths)
+      : base(outputFilePath, targetFilePaths)
+    {
+    }
+
+    protected override string GetFileSignature(FileSystemPath targetFilePath)
+    {
+      try
+      {
+        using (Stream stream = targetFilePath.OpenFileForReading())
+        {
+          PEFile peFile = new PEFile((IBinaryReader) new StreamBinaryReader(stream));
+          return string.Format("{0:X}{1:X}", (object) peFile.COFFheader.TimeStamp, (object) peFile.NTHeader.ImageSize);
+        }
+      }
+      catch (Exception ex)
+      {
+        Console.Error.WriteLine(ex.Message);
+        return (string) null;
+      }
+    }
+  }
+}