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 


How to get the size of an assembly instruction with C ++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Filipe_Br
Expert Cheater
Reputation: 2

Joined: 07 Jan 2016
Posts: 230
Location: My house

PostPosted: Sun Sep 03, 2017 3:08 pm    Post subject: How to get the size of an assembly instruction with C ++ Reply with quote

Does anyone know any function to get the size of an assembly instruction?
Let's assume that address 07310000, contains the following instruction: mov eax, edi.
This instruction is formed by 2 bytes (8B, C7).
I would need to get the size of the instruction that is in a given address.

_________________
...
Back to top
View user's profile Send private message
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 52

Joined: 06 Jul 2014
Posts: 1774
Location: Arcadian Suburbia

PostPosted: Sun Sep 03, 2017 3:25 pm    Post subject: Reply with quote

celua.txt:
Quote:
getInstructionSize(address): Returns the size of an instruction (basically it disassembles the instruction and returns the number of bytes for you)


Edit: didn't see C++, but you can still look at CE's source and see what it's doing.

Writing this on your own isn't terribly hard. Look at Intel's software developer's manual volume 2A chapter 2 "Instruction Format" for most of the information you'll need.

_________________
I don't know where I'm going, but I'll figure it out when I get there.


Last edited by ParkourPenguin on Mon Sep 04, 2017 8:46 am; edited 1 time in total
Back to top
View user's profile Send private message
dl748
Advanced Cheater
Reputation: 0

Joined: 05 Mar 2016
Posts: 54

PostPosted: Sun Sep 03, 2017 11:47 pm    Post subject: Reply with quote

C++ doesn't have the capabilities.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 341

Joined: 09 May 2003
Posts: 19984
Location: The netherlands

PostPosted: Mon Sep 04, 2017 1:12 am    Post subject: Reply with quote

write a basic disassembler that just gets the instruction size (prefixes, multibyte opcodes, modrm, sib, ...)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Filipe_Br
Expert Cheater
Reputation: 2

Joined: 07 Jan 2016
Posts: 230
Location: My house

PostPosted: Mon Sep 04, 2017 5:54 am    Post subject: Reply with quote

Dark Byte wrote:
write a basic disassembler that just gets the instruction size (prefixes, multibyte opcodes, modrm, sib, ...)

So there are no ready-made libraries that can do this?
CE disassembly, you should either create it from the beginning, or some library aided in it.

_________________
...
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 10

Joined: 09 Aug 2013
Posts: 302

PostPosted: Mon Sep 04, 2017 6:12 am    Post subject: Reply with quote

Filipe_Br wrote:
So there are no ready-made libraries that can do this?
of course there are, just google disassembly library. Of course you'd probably learn more and it may be smaller than a full disassembly library to create your own if all you need to do is determine the size (disclaimer: I don't know how the disassembly works, it may be very dependent on the data requiring nearly a full disassembly to determine the size, for CISC architectures anyhow, but maybe it doesn't)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 137

Joined: 25 Jan 2006
Posts: 7258
Location: 127.0.0.1

PostPosted: Tue Sep 05, 2017 9:45 pm    Post subject: Reply with quote

There are a handful of disassembler libraries available to do this.

- ADE32/64
- HDE32/64
- LDE32/64
- BeaEngine
- Capstone
- Distorm
- Zyan Disassembler Engine
- etc.

Or pulling out Cheat Engines engine and using it in an external dll would work too.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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