Jump to content
  • 0

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


BadCase

Question

3 answers to this question

Recommended Posts

  • Administrators

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.

Link to comment
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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.