Jump to content
BadCase

How to check if a device is ARMv 6,7 or 8 in a lua script

Recommended Posts

Can someone help me out and tell me how to check the ARM version on a device in a script?

Share this post


Link to post
Share on other sites

arm32 or arm64: getTargetInfo - field "x64".

If you need more specific - you can check by loaded ELF libs type.

1. Get ELF code location by getRangesList.

2. Read ELF header here.

3. Check e_machine field in this header.

_______________________________________________
added 1 minute later

Also you can even check info from getTargetInfo - x32 or x64 has been different size for memory address.

Share this post


Link to post
Share on other sites

Check e_machine from specific lib using GameGuardian.

function GetLibraryTextBase(lib)
	for _, __ in pairs(gg.getRangesList(lib)) do
		--print(string.format("%s | Start: 0x%08x | End: 0x%08x | Size: 0x%x | State: %s | Protection: %s", lib, __["start"], __["end"], __["end"] - __["start"], __["state"], __["type"]))
		if __["state"] == "Xa" or __["state"] == "Xs" then return __["start"], __["end"] end
	end
	return nil
end

function GetLibraryArch(LibName)
	e_machine = GetLibraryTextBase(LibName) + 0x12 -- e_machine offset
	_ = {{address = e_machine, flags = gg.TYPE_WORD }}
	return gg.getValues(_)[1].value & 0xFFFF -- Format
end

Arch = GetLibraryArch("libc.so")

-- http://www.sco.com/developers/gabi/2000-07-17/ch4.eheader.html
if Arch == 40 then 
	ArchName = "Advanced RISC Machines ARM: "
else 
	ArchName = "Unknown" 
end

gg.alert(string.format("libc.so\n\nArchitecture: %s (0x%02X)", ArchName, Arch))


References: http://www.sco.com/developers/gabi/2000-07-17/ch4.eheader.html

Share this post


Link to post
Share on other sites

TY both

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...