Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 23:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Assembly to byte[]?

Discussion on Assembly to byte[]? within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
AmazingTurtle's Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 422
Received Thanks: 324
Assembly to byte[]?

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 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?
AmazingTurtle is offline  
Old 05/28/2014, 12:05   #2


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
Mostey is offline  
Old 05/29/2014, 23:34   #3
 
AmazingTurtle's Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 422
Received Thanks: 324
Quote:
Originally Posted by Mostey View Post
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.
AmazingTurtle is offline  
Old 05/29/2014, 23:40   #4
 
'Heaven.'s Avatar
 
elite*gold: 1
The Black Market: 331/0/0
Join Date: Jun 2012
Posts: 5,819
Received Thanks: 3,200
Code:
byte[] bytes = File.ReadAllBytes(assembly.Location);
Code:
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
'Heaven. is offline  
Old 06/05/2014, 10:23   #5
 
AmazingTurtle's Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 422
Received Thanks: 324
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 ******* load an Assembly by .Load(), Byte Array given. How to get These Bytes ONLY from Memory.?!
AmazingTurtle is offline  
Old 06/05/2014, 13:11   #6
 
tolio's Avatar
 
elite*gold: 2932
The Black Market: 169/1/0
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097

Quote:
Gets the assembly that contains the code that is currently executing.

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
tolio is offline  
Old 06/07/2014, 08:36   #7
 
»jD«'s Avatar
 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,152
Received Thanks: 4,910
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 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
»jD« is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
TWSRO DC Bug Assembly
08/07/2013 - SRO Private Server - 1 Replies
hello, about twsro files the DC button doesnt work. I do not know what i have to search in sro client to fix it. Need the professional assembly guys :D And yeah the lightstone crash too if anyone knows it.
Assembly
01/18/2011 - CO2 Programming - 5 Replies
Well, I really want to learn assembly. I've already read some guides, but I want to be good at it. I understand only less asm. Is there any good guides for learning it?
Assembly Help
08/19/2009 - Dekaron - 8 Replies
I am still trying to learn assembly, but I'm getting better. I found a tut that looked really promising (by Lela or something), but it was all about cracking registration things and such, which doesn't really help me with 2Moons. So if anybody has a tut that is more guided to game hacking, a link would be greatly appreciated. Anyway, here is what I need help with. Here is the part of the code I'm looking at: http://i221.photobucket.com/albums/dd193/sachamo5 12/Olly1.jpg What I need...
[Release] Assembly in C#
10/29/2008 - CO2 Programming - 7 Replies
Hello, With this .cs (C# Class) file, you can perform BASIC asm commands, such as mov ebp, esp <-- asm.Mov_EBP_ESP(); call dword ptr ds: <-- asm.Call_DWORD_Ptr(0x00873A1F); ret <-- asm.Ret(); Assembly in C# is NOT my creation, however, I have modified the source to enable Call's that are not 'Dword Ptr's (this was difficult because to figure out the opcode for jmp ADDY, you have to perform a math sequence on the ADDY (intTohex(((TargetCall - OldAddress) - 10), 8) due to the jmp TARGET...



All times are GMT +1. The time now is 23:47.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.