Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2022-01-20 13:00:40 +0300
committerMarek Safar <marek.safar@gmail.com>2022-01-20 13:00:40 +0300
commit03aabb40d2a5d9b22c94bfc6e4fe5a5b85badb8f (patch)
tree32aeeb50545c5596235f6215c45b9b2e49bf0366 /Mono.Cecil
parent9fd4a5ca53cfc8baee82abe0ca1f46d489625913 (diff)
Revert "Fix deterministic MVID and add PdbChecksum (#31)"
This reverts commit ff616bf90e3aff2292a0b1536f7af13cd8810276.
Diffstat (limited to 'Mono.Cecil')
-rw-r--r--Mono.Cecil/AssemblyWriter.cs49
1 files changed, 22 insertions, 27 deletions
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs
index e60ab1d..c83f997 100644
--- a/Mono.Cecil/AssemblyWriter.cs
+++ b/Mono.Cecil/AssemblyWriter.cs
@@ -118,17 +118,13 @@ namespace Mono.Cecil {
metadata.SetSymbolWriter (symbol_writer);
BuildMetadata (module, metadata);
- ImageDebugHeader debugHeader = null;
- if (symbol_writer != null)
- debugHeader = symbol_writer.GetDebugHeader ();
+ if (parameters.DeterministicMvid)
+ metadata.ComputeDeterministicMvid ();
- var writer = ImageWriter.CreateWriter (module, metadata, stream, debugHeader);
+ var writer = ImageWriter.CreateWriter (module, metadata, stream);
stream.value.SetLength (0);
writer.WriteImage ();
- if (parameters.DeterministicMvid)
- ComputeDeterministicMvid (writer, module);
-
if (parameters.HasStrongNameKey)
CryptoService.StrongName (stream.value, writer, parameters);
}
@@ -160,26 +156,6 @@ namespace Mono.Cecil {
return symbol_writer_provider.GetSymbolWriter (module, fq_name);
}
-
- static void ComputeDeterministicMvid (ImageWriter writer, ModuleDefinition module)
- {
- long previousPosition = writer.BaseStream.Position;
- writer.BaseStream.Seek(0, SeekOrigin.Begin);
-
- // The hash should be computed with the MVID set to all zeroes
- // which it is - we explicitly write all zeroes GUID into the heap
- // as the MVID.
- // Same goes for strong name signature, which also already in the image but all zeroes right now.
- Guid guid = CryptoService.ComputeGuid (CryptoService.ComputeHash (writer.BaseStream));
-
- // The MVID GUID is always the first GUID in the GUID heap
- writer.MoveToRVA (TextSegment.GuidHeap);
- writer.WriteBytes (guid.ToByteArray ());
- writer.Flush ();
- module.Mvid = guid;
-
- writer.BaseStream.Seek(previousPosition, SeekOrigin.Begin);
- }
}
abstract class MetadataTable {
@@ -2666,6 +2642,25 @@ namespace Mono.Cecil {
method_debug_information_table.rows [rid - 1].Col2 = GetBlobIndex (signature);
}
+
+ public void ComputeDeterministicMvid ()
+ {
+ var guid = CryptoService.ComputeGuid (CryptoService.ComputeHash (
+ data,
+ resources,
+ string_heap,
+ user_string_heap,
+ blob_heap,
+ table_heap,
+ code));
+
+ var position = guid_heap.position;
+ guid_heap.position = 0;
+ guid_heap.WriteBytes (guid.ToByteArray ());
+ guid_heap.position = position;
+
+ module.Mvid = guid;
+ }
}
sealed class SignatureWriter : ByteBuffer {