Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


getInstructionSize for C#

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Sun Jan 31, 2016 7:37 pm    Post subject: getInstructionSize for C# Reply with quote

As a practice, I've made/stolen a little csharp function. This is stolen from a non-open-source software, original is in a Lua dialect. I'm not sure the original is error free nor this conversion.

It should work like ce lua function getInstructionSize:
Code:
getInstructionSize(address): Returns the size of an instruction

but the function is named as getCodeSize, and the input parameter is different.
Code:
int getCodeSize(byte[] b,int idxBegin) ; //or
int getCodeSize(LikeByteArray b,int idxBegin) ;

In the later case, it is a delegate with int input and byte output. It may be adapted to read process memory.

If there is error, like the op code bytes is not well-formed, or index out of array range, the function return -1. Other function using this function should check if the returned code size is valid.

The CSharp source is in the table file of the attached CT, it can be save to disk.

Related topic in stackoverflow : http://stackoverflow.com/questions/23788236/get-size-of-assembly-instructions
bye~



x86codesize_csharp.CT
 Description:

Download
 Filename:  x86codesize_csharp.CT
 Filesize:  9.93 KB
 Downloaded:  688 Time(s)


_________________
- Retarded.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Jan 31, 2016 9:26 pm    Post subject: Reply with quote

If you need a full-on C# disassembler, you can check out the SharpDisasm project here:
https://sharpdisasm.codeplex.com/

I use it in a project of mine for removing the Steam DRM from exe's. Works well.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Mon Feb 01, 2016 1:30 am    Post subject: Reply with quote

Thank you~
Is there a 64bit runtime Assembler suggestion?
That's something like FASM.dll but FASM.dll seems 32bit only.

_________________
- Retarded.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Feb 01, 2016 1:48 pm    Post subject: Reply with quote

panraven wrote:
Thank you~
Is there a 64bit runtime Assembler suggestion?
That's something like FASM.dll but FASM.dll seems 32bit only.


Don't know of any off-hand. I rarely touch 64bit stuff since I do not need it.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Mon Feb 01, 2016 3:39 pm    Post subject: Reply with quote

FASM.DLL can generate 64bit or 32bit Assembler binary with the 'use' directive, only that the *.dll is 32bit only, which means says, a 64bit Trainer cannot simply link and use this dll. Google says that there is IPC method for a 64bit trainer app to use a 32bit dll, but seems complicated.
Thanks anyway~

_________________
- Retarded.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites