Assembly to byte[]?

05/27/2014 16:07 AmazingTurtle#1
I wanted to get all loaded .NET assemblies as byte[] to check that. I know, I could load the Assembly File into byte[] using a FileStream or something equivalent. But [Only registered and activated users can see links. Click Here To Register...] is how to modify .NET Code during runtime (without touching the File itself). Result: Assembly File Data doesn't match runtime code. Any idea how to 'serialize' an assembly to an byte array?
05/28/2014 12:05 Mostey#2
[Only registered and activated users can see links. Click Here To Register...]
05/29/2014 23:34 AmazingTurtle#3
Quote:
Originally Posted by Mostey View Post
[Only registered and activated users can see links. Click Here To Register...]
I think you got me wrong. This is how to create an assembly instance by loading a file, creating an instance and invoking members of it.

But i wanted the opposite. Enumerate all loaded assemblies and get their byte[] code at runtime. Kinda like an dissambler. But without generating human readable code. All i want is to get the byte[] code, make a hash of that and check it.
05/29/2014 23:40 'Heaven.#4
Code:
byte[] bytes = File.ReadAllBytes(assembly.Location);
Code:
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
06/05/2014 10:23 AmazingTurtle#5
Quote:
Originally Posted by 'Heaven. View Post
Code:
byte[] bytes = File.ReadAllBytes(assembly.Location);
Code:
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
You actually did not read my whole post.
Im aware of the method to load the file from an assemblies location.
Imagine: I fucking load an Assembly by .Load(), Byte Array given. How to get These Bytes ONLY from Memory.?!
06/05/2014 13:11 tolio#6
[Only registered and activated users can see links. Click Here To Register...]
Quote:
Gets the assembly that contains the code that is currently executing.
[Only registered and activated users can see links. Click Here To Register...]
Quote:
Returns the MSIL for the method body, as an array of bytes.
ive never tested if these methods return their information from ram or disk, so you have to check it out by yourself
06/07/2014 08:36 »jD«#7
Quote:
Originally Posted by /bin/cat View Post
I wanted to get all loaded .NET assemblies as byte[] to check that. I know, I could load the Assembly File into byte[] using a FileStream or something equivalent. But [Only registered and activated users can see links. Click Here To Register...] is how to modify .NET Code during runtime (without touching the File itself). Result: Assembly File Data doesn't match runtime code. Any idea how to 'serialize' an assembly to an byte array?
I think you're better off using Mono.Cecil or something.

-jD