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 


Android UUID-like

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Tue Oct 05, 2021 3:40 am    Post subject: Android UUID-like Reply with quote

Code:
function all_trim(s)
  return s:match"^%s*(.*)":match"(.-)%s*$"
end

local fh = assert(io.popen'wmic csproduct get uuid')
result = fh:read'*a'
fh:close()
result = string.gsub(result,'UUID',"")
result = all_trim(result)
--print(result)


Is there a way to get unique id from phone with Lua code?

Like a command similar to the code above! There were some Java examples, but I couldn't get them to work with lua.

Thanks in advance for the answers.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Oct 05, 2021 6:28 pm    Post subject: Reply with quote

WMIC is deprecated so you should be avoiding that to begin with.

As for the Android question, you'd need to use the USB API that Windows offers to properly iterate through the connected devices and read their descriptors. The structure of interest you'd want is this:
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/usbspec/ns-usbspec-_usb_device_descriptor

Which contains the 'iSerialNumber' field that holds the device's serial number.

This would be done using the 'DeviceIoControl' API.

The source code to the USBView tool is available from Microsoft that shows how to do this as well which can be found here:
https://docs.microsoft.com/en-us/samples/microsoft/windows-driver-samples/usbview-sample-application/
https://github.com/microsoft/windows-driver-samples/tree/master/usb/usbview

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Oct 06, 2021 2:52 am    Post subject: Reply with quote

The above code still works fine. "WMIC" print(results)

How can I run this command in lua?

Code:
String unique_id = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);


Ref : https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID

I'm looking for a way to run the above code inside the lua code to get the ID on the phone for the first time (with the app that will activate a lua directory).

---------------------------------------
There are many masters with lua knowledge in CE and I know this as the most active lua forum.
---------------------------------------
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Oct 06, 2021 3:19 am    Post subject: Reply with quote

You can't run that specific code from CE at all. That has to be executed on the actual phone using the Java Android SDK. It's not for pulling remote info from the phone on other platforms.

ByTransient wrote:
The above code still works fine. "WMIC" print(results)


While it may work fine on your system, it is marked deprecated and can be disabled on various OEM systems by default. (HP, Dell, etc. have been known to have WMI disabled on their copies of Windows.)

It being deprecated as well means that it is marked for removal at a later point in time with Windows. And may be fully removed/disabled in a future update.

If you are relying on it for system information, there is a chance it will fail to poll anything.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Oct 06, 2021 7:31 am    Post subject: Reply with quote

Thanks @atom0s. Your attention to detail is admirable.

What I'm trying to do is find a way to use the VIP member test code on android phone as well as on PC.

I think I can do this with the Android ID that Google Play created on the first installation.

Or it could be another unique ID that I can access with the Lua code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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