Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsmResolver __arglist #413

Closed
sunnamed434 opened this issue Feb 10, 2023 · 6 comments
Closed

AsmResolver __arglist #413

sunnamed434 opened this issue Feb 10, 2023 · 6 comments
Labels
bug dotnet Issues related to AsmResolver.DotNet
Milestone

Comments

@sunnamed434
Copy link
Contributor

sunnamed434 commented Feb 10, 2023

AsmResolver Version

5.1.0

.NET Version

.NET Framework 462

Operating System

Windows

Describe the Bug

If I'll try to feed this into the AsmResolver and do zero changes in assembly, and just write/save the module I'm getting a weird error

static void Main()
{
// VERY important to call this method
  DrawArgList(__arglist("Hello world!"))
}
public static void DrawArgList(__arglist)
{
    ArgIterator argIterator = new ArgIterator(__arglist);
    object[] array = new object[argIterator.GetRemainingCount()];
    int num = 0;
    while (argIterator.GetRemainingCount() > 0)
    {
        array[num++] = TypedReference.ToObject(argIterator.GetNextArg());
    }
    Console.WriteLine(array[0]);
}

How To Reproduce

  1. Create .NET Framework app (executable)
  2. Add the code that I wrote upper (Main + DrawArgList, very important to call DrawArgList somewhere in code)
  3. Compile
  4. Feed to AsmResolver
  5. Build/write
  6. Error

Expected Behavior

No error

Actual Behavior

Throws an error

ArgumentException
System.ArgumentException: Table is not supported by this encoder.
Parameter name: token
   at AsmResolver.PE.DotNet.Metadata.Tables.IndexEncoder.EncodeToken(MetadataToken token)
   at AsmResolver.DotNet.Builder.DotNetDirectoryBuffer.AddMemberRefParent(IMemberRefParent parent)
   at AsmResolver.DotNet.Builder.DotNetDirectoryBuffer.AddMemberReference(MemberReference member, Boolean allowDuplicates)
   at AsmResolver.DotNet.Builder.DotNetDirectoryFactory.ImportTables[TMember](ModuleDefinition module, TableIndex tableIndex, Func`2 importAction)
   at AsmResolver.DotNet.Builder.DotNetDirectoryFactory.ImportTypeSpecsAndMemberRefsIfSpecified(ModuleDefinition module, DotNetDirectoryBuffer buffer)
   at AsmResolver.DotNet.Builder.DotNetDirectoryFactory.CreateDotNetDirectory(ModuleDefinition module, INativeSymbolsProvider symbolsProvider, DiagnosticBag diagnosticBag)
   at AsmResolver.DotNet.Builder.ManagedPEImageBuilder.CreateImage(ModuleDefinition module)

Additional Context

No response

@Washi1337 Washi1337 added the dotnet Issues related to AsmResolver.DotNet label Feb 11, 2023
@Washi1337 Washi1337 added this to the 5.2.0 milestone Feb 11, 2023
@Washi1337
Copy link
Owner

Potential fix is implemented in #414. Could you verify this indeed solves your issue?

@sunnamed434
Copy link
Contributor Author

Yes sure, do you have binaries with fixes otherwise I could compile it then

@Washi1337
Copy link
Owner

You can find the latest build on AppVeyor

@sunnamed434
Copy link
Contributor Author

Oh, cool, thanks, I didn't know that, I'll check today

@sunnamed434
Copy link
Contributor Author

Checked now with the latest version, now there's no errors anymore

@Washi1337
Copy link
Owner

Perfect, closing this as fixed then. This will be available in 5.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dotnet Issues related to AsmResolver.DotNet
Projects
None yet
Development

No branches or pull requests

2 participants