[Lua]AOB counter

Upload *YOUR* gamehacking tools/helpers here
Post Reply
User avatar
LeFiXER
LeFixer
LeFixer
Posts: 479
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 242

[Lua]AOB counter

Post by LeFiXER »

This will count the amount of bytes in a given AOB. Useful for readmem function and perhaps others. I felt that the process could be more simplified without having to manually count the bytes for a given AOB so made this.

Installation
Copy byteCounter.lua to X:\Program Files\Cheat Engine 7.2\autorun folder, where X is your main drive and restart Cheat Engine.

Usage
Step 1.
[Link]
Step 2.
[Link]
Step 3.
[Link]
Step 4.
[Link]

If this helped in any way, I would appreciate it if you could rate this post.

Thanks to all here that have shared their knowledge with this community. Without it, I would not have been able to accomplish this extension.

Thank you :)
Attachments
byteCounterv1.1.zip
Update: Added byte count in hex
PW: fearlessrevolution
(581 Bytes) Downloaded 223 times
byteCounter.zip
PW: fearlessrevolution
(534 Bytes) Downloaded 142 times
Last edited by LeFiXER on Sun Jul 25, 2021 10:42 pm, edited 1 time in total.

User avatar
EpicBirdi
Fearless Donors
Fearless Donors
Posts: 64
Joined: Sat Jul 21, 2018 2:22 pm
Reputation: 58

Re: [Lua]AOB counter

Post by EpicBirdi »

This was something I wanted/wondered about not even 12h ago lol
Thanks!

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 19

Re: [Lua]AOB counter

Post by ShyTwig16 »

Might I suggest having the output show both decimal and hex. So it can be used to calculate offsets for AOBs scripts as well.

User avatar
LeFiXER
LeFixer
LeFixer
Posts: 479
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 242

Re: [Lua]AOB counter

Post by LeFiXER »

Thanks for the suggestion. I've updated to reflect that :).

User avatar
YoucefHam
Expert Cheater
Expert Cheater
Posts: 92
Joined: Sun Jan 21, 2018 10:21 pm
Reputation: 202

Re: [Lua]AOB counter

Post by YoucefHam »

LeFiXER wrote:
Sun Jul 25, 2021 6:24 pm
This will count the amount of bytes in a given AOB. Useful for readmem function and perhaps others. I felt that the process could be more simplified without having to manually count the bytes for a given AOB so made this.
....................
Hi :D,
so I was just browsing the tools topics, and I saw AOB SIGNATURE GENERATOR AND SCANNER by ShyTwig16, and there was a way to determine how many AOBs in the selection so I tried to use those functions with your code, here the results.
CODE

Code: Select all

function countBytes()
	local dv_address1 = getMemoryViewForm().DisassemblerView.SelectedAddress
	local dv_address2 = getMemoryViewForm().DisassemblerView.SelectedAddress2
	local startAddress = math.min(dv_address1, dv_address2)
	local startAddressBytes = getInstructionSize(startAddress)
	local endAddress = math.max(dv_address1, dv_address2)
	local endAddressBytes = getInstructionSize(endAddress)
	local length = endAddress + endAddressBytes - startAddress
	
	if length > startAddressBytes then
		ShowMessage('Bytes at Start: 		' .. startAddressBytes .. '  		(0x'.. string.format("%X", startAddressBytes) .. ')\nBytes at End:  		' .. endAddressBytes .. '  		(0x'.. string.format("%X", endAddressBytes) .. ')\nAOB Length:  		' .. length .. '  		(0x'.. string.format("%X", length) .. ')')
		return
	else
		local sBytes = inputQuery('Count bytes in AOB', 'Selected Address has: ' .. startAddressBytes .. '  (0x' .. string.format("%X", startAddressBytes) .. ') Bytes\n\nEnter bytes to count: ', readFromClipboard())
		if sBytes ~= nil then
			_,count = sBytes:gsub("%S+","")
			local hex = string.format("%X", count)
			ShowMessage('The AOB has '..count..' bytes.' .. '\nDec : ' .. count .. '\nHex : ' .. hex)
		end
	end
end

function addByteCountMenu()
	local parent = getMemoryViewForm().Component[113].Items
	byteMenu = createMenuItem(parent)
	parent.add(byteMenu)
	byteMenu.Caption = 'Byte Counter'
	byteMenu.ImageIndex = 74
	byteMenu.OnClick = countBytes
end

addByteCountMenu()
if you select multiple lines
Image

if you select only one line
Image

Post Reply

Who is online

Users browsing this forum: griddled