Questions tagged [dnlib]

dnlib is a library that can read, write and create .NET assemblies and modules.

dnlib is a library that can read, write and create .NET assemblies and modules.

See:

38 questions
0
votes
0 answers

How i write MessageBox using dnlib

When i write code to show messagebox in Entry point it will not run but if i replace the messagebox to file write it will run without problem. And if i make compile in dnspy and save the assembly again it will run!. Code ** i used dnlib ** : …
0
votes
0 answers

Add a DLL reference using dnlib

There is a nice example at (https://github.com/0xd4d/dnlib/blob/master/Examples/Example3.cs) where an assembly is created using dnlib. How do I add a DLL reference in this example? What I've failed so far is that I need to create an AssemblyRef, but…
Entry
  • 1
0
votes
0 answers

Library Dnlib - Values are not replaced

Need to replace a constant of another application with a new value using the dnlib library, so that when you run the application the new value will be displayed in place of the old (default) Stub class: StubDnlib namespace { using System; …
r3xq1
  • 26
  • 4
0
votes
0 answers

How to use Dnlib to Import a runtime types and method from a specific dotnet framework like 4.8

My project is using .NET core "7.0" and the targeted module is "4.8" and when I try to import "GetString" method and inject it to the module using Dnlib, it references the higher version "7.0" instead of "4.8" and the output exe will crash because…
Wael
  • 3
  • 4
0
votes
0 answers

How to force a .NET tests project to use System.Net.Http.dll from bin folder instead of from the shared folder?

I have a .NET tests project that uses HttpClient from System.Net.Http.dll that is loaded from shared folder: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\System.Net.Http.dll (example for netcoreapp3.1 tests project target framework). I need…
Andrii
  • 689
  • 1
  • 6
  • 12
0
votes
1 answer

dnlib after ModuleDefMD.Write(file, options) Assembly attributes are deleted

Module Creation process var file = Console.ReadLine(); var moduleContext = ModuleDef.CreateModuleContext(); var moduleCreationOptions = new ModuleCreationOptions(moduleContext, CLRRuntimeReaderKind.Mono); var buffer = File.ReadAllBytes(file); var…
sunnamed
  • 96
  • 1
  • 10
0
votes
0 answers

Replacing the manifest via the dnlib library

How you can change the manifest of another application using the dnlib library. I couldn't find any examples. So I tried looking for methods manually (and there were none), the most I figured out was that it could be done somehow with a class:…
r3xq1
  • 26
  • 4
0
votes
0 answers

Is there a way to evaluate individual Msil instructions?

Background: I am using dnlib to build a deobfuscator for an unknown custom done Obfuscator in c#. The obfuscated code has large amount of mathematical expressions that define constants for things such as a switch statement, if statements, numbers…
0
votes
0 answers

How to replace a string with a function using dnlib?

i'm trying to replace a string to call a function but send the string as param (the function will return something) Result.Append(b.ToString("AnyString")); i'm trying to replace to something like…
Gil13
  • 1
  • 1
0
votes
1 answer

dnLib-Generated Assembly - TypeLoadException Thrown at Runtime

I am using dnLib to generate MSIL assemblies dynamically from a custom language I'm writing, named CSASM: string absolute = Path.Combine(Directory.GetCurrentDirectory(), forceOutput ?? $"{asmName}.exe"); ModuleDefUser mod = new…
absoluteAquarian
  • 510
  • 3
  • 12
0
votes
0 answers

How to identify members returning and or accepting the dynamic type

Is there any possibility to figure out whether a return or argument type of a member is dynamic? The issue is that is compiles down to System.Object. I've observed that if a member accepting arguments has a dynamic type present in its signature, an…
0
votes
0 answers

Parent Does not Exist Error while Injecting a type and method using dnlib

I've been trying to inject a type and method for a good day now lol. Um. Here is some of the code: I'm basically just trying to replace System.Convert.FromBase64String with Simpy.Simp but I can't seem to get it to work... (I used InjectHelper.cs…
0
votes
0 answers

dnlib - how change application .NetFramework version

Can you tell me whether it is possible to change the .NetFramework version of another application using the dnlib library? // Properties.Resources.MyExeFile - Binary file located in application resources using var module =…
r3xq1
  • 26
  • 4
0
votes
1 answer

Getting argument value with Mono.Cecil or dnlib

I want to get first argument value (it's a string). For instance, I have the following instruction: I have a list of instructions, sometimes there can be other arguments, and there might be other strings. How can I get the first argument only? I…
misticos
  • 718
  • 5
  • 22
0
votes
1 answer

Inject a class with a method using dnlib

I'm trying to inject a class with a method in a file. I'm aware that there is a working solution in ConfuserEx's source code but it kinda requires editing dnlib's code which I want to avoid. ModuleDef manifestModule =…
nop
  • 4,711
  • 6
  • 32
  • 93