diff --git a/src/AsmResolver.DotNet/Builder/DotNetDirectoryBuffer.cs b/src/AsmResolver.DotNet/Builder/DotNetDirectoryBuffer.cs index 3b0e5ad60..60fe3f5af 100644 --- a/src/AsmResolver.DotNet/Builder/DotNetDirectoryBuffer.cs +++ b/src/AsmResolver.DotNet/Builder/DotNetDirectoryBuffer.cs @@ -143,7 +143,7 @@ public DotNetDirectoryBuildResult CreateDirectory() { Metadata = Metadata.CreateMetadata(), DotNetResources = Resources.Size > 0 ? Resources.CreateDirectory() : null, - Entrypoint = GetEntrypoint(), + EntryPoint = GetEntryPoint(), Flags = Module.Attributes, StrongName = StrongNameSize > 0 ? new DataSegment(new byte[StrongNameSize]) : null, VTableFixups = VTableFixups.Directory.Count > 0 ? VTableFixups.Directory : null @@ -152,29 +152,29 @@ public DotNetDirectoryBuildResult CreateDirectory() return new DotNetDirectoryBuildResult(directory, _tokenMapping); } - private uint GetEntrypoint() + private uint GetEntryPoint() { - if (Module.ManagedEntrypoint is null) + if (Module.ManagedEntryPoint is null) return 0; - var entrypointToken = MetadataToken.Zero; + var entryPointToken = MetadataToken.Zero; - switch (Module.ManagedEntrypoint.MetadataToken.Table) + switch (Module.ManagedEntryPoint.MetadataToken.Table) { case TableIndex.Method: - entrypointToken = GetMethodDefinitionToken(Module.ManagedEntrypointMethod!); + entryPointToken = GetMethodDefinitionToken(Module.ManagedEntryPointMethod!); break; case TableIndex.File: - entrypointToken = AddFileReference((FileReference) Module.ManagedEntrypoint); + entryPointToken = AddFileReference((FileReference) Module.ManagedEntryPoint); break; default: - ErrorListener.MetadataBuilder($"Invalid managed entrypoint {Module.ManagedEntrypoint.SafeToString()}."); + ErrorListener.MetadataBuilder($"Invalid managed entry point {Module.ManagedEntryPoint.SafeToString()}."); break; } - return entrypointToken.ToUInt32(); + return entryPointToken.ToUInt32(); } private void AddMethodSemantics(MetadataToken ownerToken, IHasSemantics provider) diff --git a/src/AsmResolver.DotNet/FileReference.cs b/src/AsmResolver.DotNet/FileReference.cs index 8de6ba74a..8f6078e0e 100644 --- a/src/AsmResolver.DotNet/FileReference.cs +++ b/src/AsmResolver.DotNet/FileReference.cs @@ -12,7 +12,7 @@ namespace AsmResolver.DotNet public class FileReference : MetadataMember, IImplementation, - IManagedEntrypoint, + IManagedEntryPoint, IOwnedCollectionElement { private readonly LazyVariable _name; diff --git a/src/AsmResolver.DotNet/IManagedEntrypoint.cs b/src/AsmResolver.DotNet/IManagedEntryPoint.cs similarity index 62% rename from src/AsmResolver.DotNet/IManagedEntrypoint.cs rename to src/AsmResolver.DotNet/IManagedEntryPoint.cs index 9b0c3fb27..3b23ab1bd 100644 --- a/src/AsmResolver.DotNet/IManagedEntrypoint.cs +++ b/src/AsmResolver.DotNet/IManagedEntryPoint.cs @@ -2,9 +2,9 @@ { /// /// Represents a member that is either a method definition or a reference to an external file, that can be used to - /// indicate the managed entrypoint of a .NET module. + /// indicate the managed entry point of a .NET module. /// - public interface IManagedEntrypoint : IMetadataMember + public interface IManagedEntryPoint : IMetadataMember { } -} \ No newline at end of file +} diff --git a/src/AsmResolver.DotNet/MethodDefinition.cs b/src/AsmResolver.DotNet/MethodDefinition.cs index 4a32048be..a65658523 100644 --- a/src/AsmResolver.DotNet/MethodDefinition.cs +++ b/src/AsmResolver.DotNet/MethodDefinition.cs @@ -26,7 +26,7 @@ public class MethodDefinition : IHasGenericParameters, IMemberForwarded, IHasSecurityDeclaration, - IManagedEntrypoint + IManagedEntryPoint { private readonly LazyVariable _name; private readonly LazyVariable _declaringType; diff --git a/src/AsmResolver.DotNet/ModuleDefinition.cs b/src/AsmResolver.DotNet/ModuleDefinition.cs index 3e693c258..1bab39caf 100644 --- a/src/AsmResolver.DotNet/ModuleDefinition.cs +++ b/src/AsmResolver.DotNet/ModuleDefinition.cs @@ -44,7 +44,7 @@ public class ModuleDefinition : private IList? _assemblyReferences; private IList? _customAttributes; - private readonly LazyVariable _managedEntrypoint; + private readonly LazyVariable _managedEntryPoint; private IList? _moduleReferences; private IList? _fileReferences; private IList? _resources; @@ -269,7 +269,7 @@ protected ModuleDefinition(MetadataToken token) _mvid = new LazyVariable(GetMvid); _encId = new LazyVariable(GetEncId); _encBaseId = new LazyVariable(GetEncBaseId); - _managedEntrypoint = new LazyVariable(GetManagedEntrypoint); + _managedEntryPoint = new LazyVariable(GetManagedEntryPoint); _runtimeVersion = new LazyVariable(GetRuntimeVersion); _nativeResources = new LazyVariable(GetNativeResources); Attributes = DotNetDirectoryFlags.ILOnly; @@ -494,13 +494,13 @@ public bool IsStrongNameSigned } /// - /// Gets or sets a value indicating whether the .NET module has a native entrypoint or not. + /// Gets or sets a value indicating whether the .NET module has a native entry point or not. /// - public bool HasNativeEntrypoint + public bool HasNativeEntryPoint { - get => (Attributes & DotNetDirectoryFlags.NativeEntrypoint) != 0; - set => Attributes = (Attributes & ~DotNetDirectoryFlags.NativeEntrypoint) - | (value ? DotNetDirectoryFlags.NativeEntrypoint : 0); + get => (Attributes & DotNetDirectoryFlags.NativeEntryPoint) != 0; + set => Attributes = (Attributes & ~DotNetDirectoryFlags.NativeEntryPoint) + | (value ? DotNetDirectoryFlags.NativeEntryPoint : 0); } /// @@ -744,22 +744,22 @@ public IMetadataResolver MetadataResolver } /// - /// Gets or sets the managed method that is invoked when the .NET module is initialized. + /// Gets or sets the managed method that is invoked after the .NET module is loaded and initialized. /// - public MethodDefinition? ManagedEntrypointMethod + public MethodDefinition? ManagedEntryPointMethod { - get => ManagedEntrypoint as MethodDefinition; - set => ManagedEntrypoint = value; + get => ManagedEntryPoint as MethodDefinition; + set => ManagedEntryPoint = value; } /// - /// Gets or sets the managed entrypoint that is invoked when the .NET module is initialized. This is either a - /// method, or a reference to a secondary module containing the entrypoint method. + /// Gets or sets the managed entry point that is invoked when the .NET module is initialized. This is either a + /// method, or a reference to a secondary module containing the entry point method. /// - public IManagedEntrypoint? ManagedEntrypoint + public IManagedEntryPoint? ManagedEntryPoint { - get => _managedEntrypoint.Value; - set => _managedEntrypoint.Value = value; + get => _managedEntryPoint.Value; + set => _managedEntryPoint.Value = value; } /// @@ -1036,13 +1036,13 @@ protected virtual IList GetCustomAttributes() => protected virtual string GetRuntimeVersion() => KnownRuntimeVersions.Clr40; /// - /// Obtains the managed entrypoint of this module. + /// Obtains the managed entry point of this module. /// - /// The entrypoint. + /// The entry point. /// - /// This method is called upon initialization of the property. + /// This method is called upon initialization of the property. /// - protected virtual IManagedEntrypoint? GetManagedEntrypoint() => null; + protected virtual IManagedEntryPoint? GetManagedEntryPoint() => null; /// /// Obtains the native win32 resources directory of the underlying PE image (if available). diff --git a/src/AsmResolver.DotNet/Serialized/SerializedModuleDefinition.cs b/src/AsmResolver.DotNet/Serialized/SerializedModuleDefinition.cs index bacbaffea..9b7866ab4 100644 --- a/src/AsmResolver.DotNet/Serialized/SerializedModuleDefinition.cs +++ b/src/AsmResolver.DotNet/Serialized/SerializedModuleDefinition.cs @@ -288,16 +288,16 @@ protected override IList GetExportedTypes() protected override string GetRuntimeVersion() => ReaderContext.Metadata!.VersionString; /// - protected override IManagedEntrypoint? GetManagedEntrypoint() + protected override IManagedEntryPoint? GetManagedEntryPoint() { - if ((DotNetDirectory.Flags & DotNetDirectoryFlags.NativeEntrypoint) != 0) + if ((DotNetDirectory.Flags & DotNetDirectoryFlags.NativeEntryPoint) != 0) { - // TODO: native entrypoints. + // TODO: native entry points. return null; } - if (DotNetDirectory.Entrypoint != 0) - return LookupMember(DotNetDirectory.Entrypoint) as IManagedEntrypoint; + if (DotNetDirectory.EntryPoint != 0) + return LookupMember(DotNetDirectory.EntryPoint) as IManagedEntryPoint; return null; } diff --git a/src/AsmResolver.PE.File/Headers/OptionalHeader.cs b/src/AsmResolver.PE.File/Headers/OptionalHeader.cs index 917865b82..7da148153 100644 --- a/src/AsmResolver.PE.File/Headers/OptionalHeader.cs +++ b/src/AsmResolver.PE.File/Headers/OptionalHeader.cs @@ -52,7 +52,7 @@ public static OptionalHeader FromReader(ref BinaryStreamReader reader, bool igno SizeOfCode = reader.ReadUInt32(), SizeOfInitializedData = reader.ReadUInt32(), SizeOfUninitializedData = reader.ReadUInt32(), - AddressOfEntrypoint = reader.ReadUInt32(), + AddressOfEntryPoint = reader.ReadUInt32(), BaseOfCode = reader.ReadUInt32() }; @@ -168,9 +168,9 @@ public uint SizeOfUninitializedData } /// - /// Gets or sets the relative virtual address to the entrypoint of the portable executable (PE) file. + /// Gets or sets the relative virtual address to the entry point of the portable executable (PE) file. /// - public uint AddressOfEntrypoint + public uint AddressOfEntryPoint { get; set; @@ -417,7 +417,7 @@ public override void Write(IBinaryStreamWriter writer) writer.WriteUInt32(SizeOfCode); writer.WriteUInt32(SizeOfInitializedData); writer.WriteUInt32(SizeOfUninitializedData); - writer.WriteUInt32(AddressOfEntrypoint); + writer.WriteUInt32(AddressOfEntryPoint); writer.WriteUInt32(BaseOfCode); switch (Magic) diff --git a/src/AsmResolver.PE/Builder/PEFileBuilderBase.cs b/src/AsmResolver.PE/Builder/PEFileBuilderBase.cs index 7ce12829a..4f6730ac2 100644 --- a/src/AsmResolver.PE/Builder/PEFileBuilderBase.cs +++ b/src/AsmResolver.PE/Builder/PEFileBuilderBase.cs @@ -51,13 +51,13 @@ public virtual PEFile CreateFile(IPEImage image) protected abstract IEnumerable CreateDataDirectories(PEFile peFile, IPEImage image, TContext context); /// - /// Gets the relative virtual address (RVA) to the entrypoint of the PE file. + /// Gets the relative virtual address (RVA) to the entry point of the PE file. /// - /// The (incomplete) PE file containing the entrypoint. + /// The (incomplete) PE file containing the entry point. /// The image that the PE file was based on. /// The object containing the intermediate values used during the PE file construction. - /// The relative virtual address to the entrypoin. - protected abstract uint GetEntrypointAddress(PEFile peFile, IPEImage image, TContext context); + /// The relative virtual address to the entry point. + protected abstract uint GetEntryPointAddress(PEFile peFile, IPEImage image, TContext context); /// /// Gets the file alignment for the new PE file. @@ -144,7 +144,7 @@ protected virtual void ComputeOptionalHeaderFields(PEFile peFile, IPEImage image header.SizeOfImage += section.GetVirtualSize(); } - header.AddressOfEntrypoint = GetEntrypointAddress(peFile, image, context); + header.AddressOfEntryPoint = GetEntryPointAddress(peFile, image, context); header.BaseOfCode = peFile.Sections.FirstOrDefault(s => s.IsContentCode)?.Rva ?? 0; header.BaseOfData = peFile.Sections.FirstOrDefault(s => s.IsContentInitializedData)?.Rva ?? 0; diff --git a/src/AsmResolver.PE/DotNet/Builder/ManagedPEFileBuilder.cs b/src/AsmResolver.PE/DotNet/Builder/ManagedPEFileBuilder.cs index 56fb4fb7d..d4883b951 100644 --- a/src/AsmResolver.PE/DotNet/Builder/ManagedPEFileBuilder.cs +++ b/src/AsmResolver.PE/DotNet/Builder/ManagedPEFileBuilder.cs @@ -134,7 +134,7 @@ public Platform Platform } /// - /// Gets the code segment used as a native entrypoint of the resulting PE file. + /// Gets the code segment used as a native entry point of the resulting PE file. /// /// /// This property might be null if no bootstrapper is to be emitted. For example, since the @@ -246,23 +246,23 @@ protected virtual PESection CreateTextSection(IPEImage image, ManagedPEBuilderCo private static void CreateImportDirectory(IPEImage image, ManagedPEBuilderContext context) { - bool importEntrypointRequired = context.Platform.IsClrBootstrapperRequired + bool importEntryPointRequired = context.Platform.IsClrBootstrapperRequired || (image.DotNetDirectory!.Flags & DotNetDirectoryFlags.ILOnly) == 0; - string entrypointName = (image.Characteristics & Characteristics.Dll) != 0 + string entryPointName = (image.Characteristics & Characteristics.Dll) != 0 ? "_CorDllMain" : "_CorExeMain"; - var modules = CollectImportedModules(image, importEntrypointRequired, entrypointName, out var entrypointSymbol); + var modules = CollectImportedModules(image, importEntryPointRequired, entryPointName, out var entryPointSymbol); foreach (var module in modules) context.ImportDirectory.AddModule(module); - if (importEntrypointRequired) + if (importEntryPointRequired) { - if (entrypointSymbol is null) - throw new InvalidOperationException("Entrypoint symbol was required but not imported."); + if (entryPointSymbol is null) + throw new InvalidOperationException("Entry point symbol was required but not imported."); - context.Bootstrapper = context.Platform.CreateThunkStub(entrypointSymbol); + context.Bootstrapper = context.Platform.CreateThunkStub(entryPointSymbol); } } @@ -270,23 +270,23 @@ private static List CollectImportedModules( IPEImage image, bool entryRequired, string mscoreeEntryName, - out ImportedSymbol? entrypointSymbol) + out ImportedSymbol? entryPointSymbol) { var modules = new List(); IImportedModule? mscoreeModule = null; - entrypointSymbol = null; + entryPointSymbol = null; foreach (var module in image.Imports) { - // Check if the CLR entrypoint is already imported. + // Check if the CLR entry point is already imported. if (module.Name == "mscoree.dll") { mscoreeModule = module; - // Find entrypoint in this imported module. + // Find entry point in this imported module. if (entryRequired) - entrypointSymbol = mscoreeModule.Symbols.FirstOrDefault(s => s.Name == mscoreeEntryName); + entryPointSymbol = mscoreeModule.Symbols.FirstOrDefault(s => s.Name == mscoreeEntryName); // Only include mscoree.dll if necessary. if (entryRequired || module.Symbols.Count > 1) @@ -308,11 +308,11 @@ private static List CollectImportedModules( modules.Add(mscoreeModule); } - // Add entrypoint sumbol if it wasn't imported yet. - if (entrypointSymbol is null) + // Add entry point sumbol if it wasn't imported yet. + if (entryPointSymbol is null) { - entrypointSymbol = new ImportedSymbol(0, mscoreeEntryName); - mscoreeModule.Symbols.Add(entrypointSymbol); + entryPointSymbol = new ImportedSymbol(0, mscoreeEntryName); + mscoreeModule.Symbols.Add(entryPointSymbol); } } @@ -423,7 +423,7 @@ protected override IEnumerable CreateDataDirectories(PEFile peFil } /// - protected override uint GetEntrypointAddress(PEFile peFile, IPEImage image, ManagedPEBuilderContext context) + protected override uint GetEntryPointAddress(PEFile peFile, IPEImage image, ManagedPEBuilderContext context) => context.Bootstrapper?.Segment.Rva ?? 0; /// diff --git a/src/AsmResolver.PE/DotNet/DotNetDirectory.cs b/src/AsmResolver.PE/DotNet/DotNetDirectory.cs index 30e6b4c58..b6f7e21ca 100644 --- a/src/AsmResolver.PE/DotNet/DotNetDirectory.cs +++ b/src/AsmResolver.PE/DotNet/DotNetDirectory.cs @@ -62,7 +62,7 @@ public DotNetDirectoryFlags Flags } /// - public uint Entrypoint + public uint EntryPoint { get; set; @@ -116,7 +116,7 @@ public override uint GetPhysicalSize() => + 2 * sizeof(ushort) // version + DataDirectory.DataDirectorySize // metadata + sizeof(uint) // flags - + sizeof(uint) // entrypoint + + sizeof(uint) // entry point + 6 * DataDirectory.DataDirectorySize; // data directories. /// @@ -127,7 +127,7 @@ public override void Write(IBinaryStreamWriter writer) writer.WriteUInt16(MinorRuntimeVersion); CreateDataDirectoryHeader(Metadata).Write(writer); writer.WriteUInt32((uint) Flags); - writer.WriteUInt32(Entrypoint); + writer.WriteUInt32(EntryPoint); CreateDataDirectoryHeader(DotNetResources).Write(writer); CreateDataDirectoryHeader(StrongName).Write(writer); CreateDataDirectoryHeader(CodeManagerTable).Write(writer); diff --git a/src/AsmResolver.PE/DotNet/DotNetDirectoryFlags.cs b/src/AsmResolver.PE/DotNet/DotNetDirectoryFlags.cs index 9e5b3074b..9d3bbc045 100644 --- a/src/AsmResolver.PE/DotNet/DotNetDirectoryFlags.cs +++ b/src/AsmResolver.PE/DotNet/DotNetDirectoryFlags.cs @@ -15,36 +15,36 @@ public enum DotNetDirectoryFlags /// Mixed-mode applications should set this flag to zero. /// ILOnly = 0x00000001, - + /// /// Indicates the .NET image requires a 32-bit architecture to run on. /// Bit32Required = 0x00000002, - + /// /// Indicates the .NET image is a .NET library. /// ILLibrary = 0x00000004, - + /// /// Indicates the .NET image is signed with a strong name. /// StrongNameSigned = 0x00000008, - + /// - /// Indicates the entrypoint defined in is a relative virtual address + /// Indicates the entry point defined in is a relative virtual address /// to a native function. /// - NativeEntrypoint = 0x00000010, - + NativeEntryPoint = 0x00000010, + /// /// Indicates the debug data is tracked. /// TrackDebugData = 0x00010000, - + /// /// Indicates the application will run in an 32-bit environment if it is possible. /// Bit32Preferred = 0x00020000 } -} \ No newline at end of file +} diff --git a/src/AsmResolver.PE/DotNet/IDotNetDirectory.cs b/src/AsmResolver.PE/DotNet/IDotNetDirectory.cs index b832628d1..0e808191e 100644 --- a/src/AsmResolver.PE/DotNet/IDotNetDirectory.cs +++ b/src/AsmResolver.PE/DotNet/IDotNetDirectory.cs @@ -52,10 +52,10 @@ DotNetDirectoryFlags Flags } /// - /// Gets or sets the metadata token or entrypoint virtual address, depending on whether - /// is set in . + /// Gets or sets the metadata token or entry point virtual address, depending on whether + /// is set in . /// - uint Entrypoint + uint EntryPoint { get; set; diff --git a/src/AsmResolver.PE/DotNet/SerializedDotNetDirectory.cs b/src/AsmResolver.PE/DotNet/SerializedDotNetDirectory.cs index 6ab56fa40..203c6e485 100644 --- a/src/AsmResolver.PE/DotNet/SerializedDotNetDirectory.cs +++ b/src/AsmResolver.PE/DotNet/SerializedDotNetDirectory.cs @@ -39,7 +39,7 @@ public SerializedDotNetDirectory(PEReaderContext context, ref BinaryStreamReader MinorRuntimeVersion = reader.ReadUInt16(); _metadataDirectory = DataDirectory.FromReader(ref reader); Flags = (DotNetDirectoryFlags) reader.ReadUInt32(); - Entrypoint = reader.ReadUInt32(); + EntryPoint = reader.ReadUInt32(); _resourcesDirectory = DataDirectory.FromReader(ref reader); _strongNameDirectory = DataDirectory.FromReader(ref reader); _codeManagerDirectory = DataDirectory.FromReader(ref reader); diff --git a/src/AsmResolver.PE/Platforms/Amd64Platform.cs b/src/AsmResolver.PE/Platforms/Amd64Platform.cs index f0257da2f..895e39c9d 100644 --- a/src/AsmResolver.PE/Platforms/Amd64Platform.cs +++ b/src/AsmResolver.PE/Platforms/Amd64Platform.cs @@ -25,14 +25,14 @@ public static Amd64Platform Instance public override bool IsClrBootstrapperRequired => false; /// - public override RelocatableSegment CreateThunkStub(ISymbol entrypoint) + public override RelocatableSegment CreateThunkStub(ISymbol entryPoint) { var segment = new CodeSegment(new byte[] { 0x48, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // rex.w rex.b mov rax, [&symbol] 0xFF, 0xE0 // jmp [rax] }); - segment.AddressFixups.Add(new AddressFixup(2, AddressFixupType.Absolute64BitAddress, entrypoint)); + segment.AddressFixups.Add(new AddressFixup(2, AddressFixupType.Absolute64BitAddress, entryPoint)); return new RelocatableSegment(segment, new[] { diff --git a/src/AsmResolver.PE/Platforms/I386Platform.cs b/src/AsmResolver.PE/Platforms/I386Platform.cs index e5b6b0c4b..87c431ae0 100644 --- a/src/AsmResolver.PE/Platforms/I386Platform.cs +++ b/src/AsmResolver.PE/Platforms/I386Platform.cs @@ -25,13 +25,13 @@ public static I386Platform Instance public override bool IsClrBootstrapperRequired => true; /// - public override RelocatableSegment CreateThunkStub(ISymbol entrypoint) + public override RelocatableSegment CreateThunkStub(ISymbol entryPoint) { var segment = new CodeSegment(new byte[] { 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 // jmp [&symbol] }); - segment.AddressFixups.Add(new AddressFixup(2, AddressFixupType.Absolute32BitAddress, entrypoint)); + segment.AddressFixups.Add(new AddressFixup(2, AddressFixupType.Absolute32BitAddress, entryPoint)); return new RelocatableSegment(segment, new[] { diff --git a/src/AsmResolver.PE/Platforms/Platform.cs b/src/AsmResolver.PE/Platforms/Platform.cs index 554525644..151b4da02 100644 --- a/src/AsmResolver.PE/Platforms/Platform.cs +++ b/src/AsmResolver.PE/Platforms/Platform.cs @@ -69,9 +69,9 @@ public abstract bool IsClrBootstrapperRequired /// /// Creates a new thunk stub that transfers control to the provided symbol. /// - /// The symbol to jump to. + /// The symbol to jump to. /// The created stub. - public abstract RelocatableSegment CreateThunkStub(ISymbol entrypoint); + public abstract RelocatableSegment CreateThunkStub(ISymbol entryPoint); /// /// Attempts to extract the original RVA from the code at the provided thunk address reader. diff --git a/test/AsmResolver.DotNet.Tests/Builder/CilMethodBodySerializerTest.cs b/test/AsmResolver.DotNet.Tests/Builder/CilMethodBodySerializerTest.cs index 3dbf54fcf..92ea0f77b 100644 --- a/test/AsmResolver.DotNet.Tests/Builder/CilMethodBodySerializerTest.cs +++ b/test/AsmResolver.DotNet.Tests/Builder/CilMethodBodySerializerTest.cs @@ -35,7 +35,7 @@ public void ComputeMaxStackOnBuildOverride(bool computeMaxStack, bool? computeMa }; module.GetOrCreateModuleType().Methods.Add(main); - module.ManagedEntrypoint = main; + module.ManagedEntryPoint = main; var builder = new ManagedPEImageBuilder(new DotNetDirectoryFactory { @@ -48,7 +48,7 @@ public void ComputeMaxStackOnBuildOverride(bool computeMaxStack, bool? computeMa var newImage = builder.CreateImage(module).ConstructedImage; var newModule = ModuleDefinition.FromImage(newImage); - Assert.Equal(expectedMaxStack, newModule.ManagedEntrypointMethod.CilMethodBody.MaxStack); + Assert.Equal(expectedMaxStack, newModule.ManagedEntryPointMethod.CilMethodBody.MaxStack); } } } \ No newline at end of file diff --git a/test/AsmResolver.DotNet.Tests/Builder/TokenMappingTest.cs b/test/AsmResolver.DotNet.Tests/Builder/TokenMappingTest.cs index af428c6a4..514950b96 100644 --- a/test/AsmResolver.DotNet.Tests/Builder/TokenMappingTest.cs +++ b/test/AsmResolver.DotNet.Tests/Builder/TokenMappingTest.cs @@ -74,7 +74,7 @@ public void NewMethodDefinition() module.GetOrCreateModuleType().Methods.Add(method); // Get existing main method. - var main = module.ManagedEntrypointMethod; + var main = module.ManagedEntryPointMethod; // Rebuild. var builder = new ManagedPEImageBuilder(); @@ -134,7 +134,7 @@ public void NewMemberReference() var reference = importer.ImportMethod(typeof(MemoryStream).GetConstructor(Type.EmptyTypes)); // Ensure method reference is added to the module by referencing it in main. - var instructions = module.ManagedEntrypointMethod.CilMethodBody.Instructions; + var instructions = module.ManagedEntryPointMethod.CilMethodBody.Instructions; instructions.Insert(0, CilOpCodes.Newobj, reference); instructions.Insert(1, CilOpCodes.Pop); @@ -162,7 +162,7 @@ public void NewTypeSpecification() var specification = importer.ImportType(typeof(List)); // Ensure method reference is added to the module by referencing it in main. - var instructions = module.ManagedEntrypointMethod.CilMethodBody.Instructions; + var instructions = module.ManagedEntryPointMethod.CilMethodBody.Instructions; instructions.Insert(0, CilOpCodes.Ldtoken, specification); instructions.Insert(1, CilOpCodes.Pop); @@ -190,7 +190,7 @@ public void NewMethodSpecification() var reference = importer.ImportMethod(typeof(Array).GetMethod("Empty").MakeGenericMethod(typeof(object))); // Ensure method reference is added to the module by referencing it in main. - var instructions = module.ManagedEntrypointMethod.CilMethodBody.Instructions; + var instructions = module.ManagedEntryPointMethod.CilMethodBody.Instructions; instructions.Insert(0, CilOpCodes.Call, reference); instructions.Insert(1, CilOpCodes.Pop); @@ -219,7 +219,7 @@ public void NewStandaloneSignature() importer.ImportMethodSignature(MethodSignature.CreateStatic(module.CorLibTypeFactory.Void))); // Ensure reference is added to the module by referencing it in main. - var instructions = module.ManagedEntrypointMethod.CilMethodBody.Instructions; + var instructions = module.ManagedEntryPointMethod.CilMethodBody.Instructions; instructions.Insert(0, CilOpCodes.Ldnull); instructions.Insert(0, CilOpCodes.Calli, signature); diff --git a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/AssemblyRefTokenPreservationTest.cs b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/AssemblyRefTokenPreservationTest.cs index 5f9c79830..8c8d51208 100644 --- a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/AssemblyRefTokenPreservationTest.cs +++ b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/AssemblyRefTokenPreservationTest.cs @@ -30,7 +30,7 @@ public void PreserveAssemblyRefsWithTypeRefRemovedShouldAtLeastHaveOriginalAssem var module = ModuleDefinition.FromBytes(Properties.Resources.HelloWorld_NetCore); var originalAssemblyRefs = GetMembers(module, TableIndex.AssemblyRef); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.Clear(); instructions.Add(CilOpCodes.Ret); @@ -49,7 +49,7 @@ public void PreserveAssemblyRefsWithExtraImportShouldAtLeastHaveOriginalAssembly var importer = new ReferenceImporter(module); var exists = importer.ImportMethod(typeof(File).GetMethod("Exists", new[] {typeof(string)})!); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.RemoveAt(instructions.Count - 1); instructions.Add(CilOpCodes.Ldstr, "file.txt"); instructions.Add(CilOpCodes.Call, exists); diff --git a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/MemberRefTokenPreservationTest.cs b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/MemberRefTokenPreservationTest.cs index 7d7665510..7eff9300e 100644 --- a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/MemberRefTokenPreservationTest.cs +++ b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/MemberRefTokenPreservationTest.cs @@ -30,7 +30,7 @@ public void PreserveMemberRefsWithTypeRefRemovedShouldAtLeastHaveOriginalMemberR var module = ModuleDefinition.FromBytes(Properties.Resources.HelloWorld_NetCore); var originalMemberRefs = GetMembers(module, TableIndex.MemberRef); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.Clear(); instructions.Add(CilOpCodes.Ret); @@ -49,7 +49,7 @@ public void PreserveMemberRefsWithExtraImportShouldAtLeastHaveOriginalMemberRefs var importer = new ReferenceImporter(module); var readKey = importer.ImportMethod(typeof(Console).GetMethod("ReadKey", Type.EmptyTypes)!); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.RemoveAt(instructions.Count - 1); instructions.Add(CilOpCodes.Call, readKey); instructions.Add(CilOpCodes.Pop); diff --git a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/TypeRefTokenPreservationTest.cs b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/TypeRefTokenPreservationTest.cs index fa233b1e8..45eabbd0d 100644 --- a/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/TypeRefTokenPreservationTest.cs +++ b/test/AsmResolver.DotNet.Tests/Builder/TokenPreservation/TypeRefTokenPreservationTest.cs @@ -31,7 +31,7 @@ public void PreserveTypeRefsWithTypeRefRemovedShouldAtLeastHaveOriginalTypeRefs( var module = ModuleDefinition.FromBytes(Properties.Resources.HelloWorld_NetCore); var originalTypeRefs = GetMembers(module, TableIndex.TypeRef); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.Clear(); instructions.Add(CilOpCodes.Ret); @@ -50,7 +50,7 @@ public void PreserveTypeRefsWithExtraImportShouldAtLeastHaveOriginalTypeRefs() var importer = new ReferenceImporter(module); var readKey = importer.ImportMethod(typeof(Console).GetMethod("ReadKey", Type.EmptyTypes)!); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.RemoveAt(instructions.Count - 1); instructions.Add(CilOpCodes.Call, readKey); instructions.Add(CilOpCodes.Pop); diff --git a/test/AsmResolver.DotNet.Tests/Cloning/MetadataClonerTest.cs b/test/AsmResolver.DotNet.Tests/Cloning/MetadataClonerTest.cs index 9a8e72d2e..c21dab1fc 100644 --- a/test/AsmResolver.DotNet.Tests/Cloning/MetadataClonerTest.cs +++ b/test/AsmResolver.DotNet.Tests/Cloning/MetadataClonerTest.cs @@ -123,7 +123,7 @@ public void CloneHelloWorldProgramType() foreach (var type in result.ClonedTopLevelTypes) targetModule.TopLevelTypes.Add(type); - targetModule.ManagedEntrypointMethod = (MethodDefinition) result.ClonedMembers.First(m => m.Name == "Main"); + targetModule.ManagedEntryPointMethod = (MethodDefinition) result.ClonedMembers.First(m => m.Name == "Main"); _fixture .GetRunner() .RebuildAndRun(targetModule, "HelloWorld.exe", "Hello World!" + Environment.NewLine); diff --git a/test/AsmResolver.DotNet.Tests/Code/Cil/CilMethodBodyTest.cs b/test/AsmResolver.DotNet.Tests/Code/Cil/CilMethodBodyTest.cs index 717853367..8d4953085 100644 --- a/test/AsmResolver.DotNet.Tests/Code/Cil/CilMethodBodyTest.cs +++ b/test/AsmResolver.DotNet.Tests/Code/Cil/CilMethodBodyTest.cs @@ -401,7 +401,7 @@ public void ReadInvalidMethodBodyErrorShouldAppearInDiagnostics() public void ExceptionHandlerWithHandlerEndOutsideOfMethodShouldResultInEndLabel() { var module = ModuleDefinition.FromBytes(Properties.Resources.HandlerEndAtEndOfMethodBody); - var body = module.ManagedEntrypointMethod.CilMethodBody; + var body = module.ManagedEntryPointMethod.CilMethodBody; Assert.Same(body.Instructions.EndLabel, body.ExceptionHandlers[0].HandlerEnd); body.VerifyLabels(); } @@ -602,7 +602,7 @@ public void SmallTryBlockStartingOnLargeOffsetShouldResultInFatFormat() public void ReadUserStringFromNormalMetadata() { var module = ModuleDefinition.FromBytes(Properties.Resources.HelloWorld_DoubleUserStringsStream); - var instruction = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions + var instruction = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions .First(i => i.OpCode.Code == CilCode.Ldstr); Assert.Equal("Hello Mars!!", instruction.Operand); @@ -612,7 +612,7 @@ public void ReadUserStringFromNormalMetadata() public void ReadUserStringFromEnCMetadata() { var module = ModuleDefinition.FromBytes(Properties.Resources.HelloWorld_DoubleUserStringsStream_EnC); - var instruction = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions + var instruction = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions .First(i => i.OpCode.Code == CilCode.Ldstr); Assert.Equal("Hello World!", instruction.Operand); diff --git a/test/AsmResolver.DotNet.Tests/Code/Native/NativeMethodBodyTest.cs b/test/AsmResolver.DotNet.Tests/Code/Native/NativeMethodBodyTest.cs index a41eae6e8..73918cb62 100644 --- a/test/AsmResolver.DotNet.Tests/Code/Native/NativeMethodBodyTest.cs +++ b/test/AsmResolver.DotNet.Tests/Code/Native/NativeMethodBodyTest.cs @@ -310,7 +310,7 @@ public void NativeBodyWithLocalSymbols(bool is32Bit, byte[] movInstruction, uint module.CorLibTypeFactory.String) ); - var instructions = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions; + var instructions = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions; instructions.Clear(); instructions.Add(CilOpCodes.Call, body.Owner); instructions.Add(CilOpCodes.Newobj, stringConstructor); diff --git a/test/AsmResolver.DotNet.Tests/ImplementationMapTest.cs b/test/AsmResolver.DotNet.Tests/ImplementationMapTest.cs index 38308f37f..d51d3aee7 100644 --- a/test/AsmResolver.DotNet.Tests/ImplementationMapTest.cs +++ b/test/AsmResolver.DotNet.Tests/ImplementationMapTest.cs @@ -28,17 +28,17 @@ private ImplementationMap RebuildAndLookup(ImplementationMap implementationMap) { using var stream = new MemoryStream(); implementationMap.MemberForwarded.Module.Write(stream); - + var newModule = ModuleDefinition.FromBytes(stream.ToArray()); var t = newModule.TopLevelTypes.First(t => t.Name == nameof(PlatformInvoke)); return t.Methods.First(m => m.Name == implementationMap.MemberForwarded.Name).ImplementationMap; } - + [Fact] public void ReadName() { var map = Lookup(nameof(PlatformInvoke.ExternalMethod)); - Assert.Equal("SomeEntrypoint", map.Name); + Assert.Equal("SomeEntryPoint", map.Name); } [Fact] @@ -49,27 +49,27 @@ public void PersistentName() var newMap = RebuildAndLookup(map); Assert.Equal(map.Name, newMap.Name); } - + [Fact] public void ReadScope() { var map = Lookup(nameof(PlatformInvoke.ExternalMethod)); Assert.Equal("SomeDll.dll", map.Scope.Name); } - + [Fact] public void PersistentScope() { var map = Lookup(nameof(PlatformInvoke.ExternalMethod)); - + var newModule = new ModuleReference("SomeOtherDll.dll"); map.MemberForwarded.Module.ModuleReferences.Add(newModule); map.Scope = newModule; - + var newMap = RebuildAndLookup(map); Assert.Equal(newModule.Name, newMap.Scope.Name); } - + [Fact] public void ReadMemberForwarded() { @@ -100,11 +100,11 @@ public void AddingAlreadyAddedMapToAnotherMemberShouldThrow() public void PersistentMemberForwarded() { var map = Lookup(nameof(PlatformInvoke.ExternalMethod)); - + var declaringType = (TypeDefinition) map.MemberForwarded.DeclaringType; var otherMethod = declaringType.Methods.First(m => m.Name == nameof(PlatformInvoke.NonImplementationMapMethod)); - + map.MemberForwarded.ImplementationMap = null; otherMethod.ImplementationMap = map; @@ -113,4 +113,4 @@ public void PersistentMemberForwarded() } } -} \ No newline at end of file +} diff --git a/test/AsmResolver.DotNet.Tests/MetadataResolverTest.cs b/test/AsmResolver.DotNet.Tests/MetadataResolverTest.cs index 48de4c707..06d4d5ca7 100644 --- a/test/AsmResolver.DotNet.Tests/MetadataResolverTest.cs +++ b/test/AsmResolver.DotNet.Tests/MetadataResolverTest.cs @@ -192,7 +192,7 @@ public void ResolveExportedMemberReference() resolver.AddToCache(assembly2, assembly2); // Resolve - var instructions = module.ManagedEntrypointMethod.CilMethodBody.Instructions; + var instructions = module.ManagedEntryPointMethod.CilMethodBody.Instructions; Assert.NotNull(((IMethodDescriptor) instructions[0].Operand).Resolve()); } @@ -238,7 +238,7 @@ public void ResolveToOlderNetVersion() .TopLevelTypes.First(t => t.Name == "MyClass") .Methods.First(m => m.Name == "ThrowMe"); - var reference = (IMethodDescriptor) mainApp.ManagedEntrypointMethod!.CilMethodBody!.Instructions.First( + var reference = (IMethodDescriptor) mainApp.ManagedEntryPointMethod!.CilMethodBody!.Instructions.First( i => i.OpCode == CilOpCodes.Callvirt && ((IMethodDescriptor) i.Operand)?.Name == "ThrowMe") .Operand!; @@ -260,7 +260,7 @@ public void ResolveMethodWithoutHideBySig() .ToArray(); var helloWorld = ModuleDefinition.FromFile(typeof(HelloWorldVB.Program).Assembly.Location); - var resolved = helloWorld.ManagedEntrypointMethod!.CilMethodBody!.Instructions + var resolved = helloWorld.ManagedEntryPointMethod!.CilMethodBody!.Instructions .Where(x => x.OpCode == CilOpCodes.Call) .Select(x => ((IMethodDescriptor) x.Operand!).Resolve()) .ToArray(); diff --git a/test/AsmResolver.DotNet.Tests/Signatures/SignatureComparerTest.cs b/test/AsmResolver.DotNet.Tests/Signatures/SignatureComparerTest.cs index 5ae715869..bbe5cd367 100644 --- a/test/AsmResolver.DotNet.Tests/Signatures/SignatureComparerTest.cs +++ b/test/AsmResolver.DotNet.Tests/Signatures/SignatureComparerTest.cs @@ -145,7 +145,7 @@ public void MatchForwardedNestedTypes() module.MetadataResolver.AssemblyResolver.AddToCache(library, library); forwarder.ManifestModule!.MetadataResolver.AssemblyResolver.AddToCache(library, library); - var referencedTypes = module.ManagedEntrypointMethod!.CilMethodBody!.Instructions + var referencedTypes = module.ManagedEntryPointMethod!.CilMethodBody!.Instructions .Where(i => i.OpCode.Code == CilCode.Call) .Select(i => ((IMethodDefOrRef) i.Operand!).DeclaringType) .Where(t => t.Name == "MyNestedClass") diff --git a/test/TestBinaries/DotNet/AsmResolver.DotNet.TestCases.Methods/PlatformInvoke.cs b/test/TestBinaries/DotNet/AsmResolver.DotNet.TestCases.Methods/PlatformInvoke.cs index 46641b2aa..755903da3 100644 --- a/test/TestBinaries/DotNet/AsmResolver.DotNet.TestCases.Methods/PlatformInvoke.cs +++ b/test/TestBinaries/DotNet/AsmResolver.DotNet.TestCases.Methods/PlatformInvoke.cs @@ -5,21 +5,21 @@ namespace AsmResolver.DotNet.TestCases.Methods { public class PlatformInvoke { - [DllImport("SomeDll.dll", EntryPoint = "SomeEntrypoint")] + [DllImport("SomeDll.dll", EntryPoint = "SomeEntryPoint")] public static extern void ExternalMethod(); - + [DllImport("SomeDll.dll")] public static extern void SimpleMarshaller([MarshalAs(UnmanagedType.Bool)] bool b); - + [DllImport("SomeDll.dll")] public static extern void LPArrayFixedSizeMarshaller([MarshalAs(UnmanagedType.LPArray, SizeConst = 10)] byte[] array); - + [DllImport("SomeDll.dll")] public static extern void LPArrayVariableSizeMarshaller([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] array, int count); - + [DllImport("SomeDll.dll")] public static extern void SafeArrayMarshaller([MarshalAs(UnmanagedType.SafeArray)] byte[] array); - + [DllImport("SomeDll.dll")] public static extern void SafeArrayMarshallerWithSubType([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UI1)] byte[] array); @@ -44,4 +44,4 @@ public static void NonImplementationMapMethod() { } } -} \ No newline at end of file +}