Hercules API
HerculesPlugin¶
This is the list of basic Class and APIs.
All APIs can be used after the Hive SDK is initialized.
IsJailbrokenDevice¶
- Supported platform: iOS
- Checks if the iOS device is jailbroken.
- Parameters: None
- Return Value: Returns 0 if it is in the original firmware state, and non-zero if it is a jailbroken device.
IsRootedDevice¶
- Supported platform: Android
- Checks if the Android device is rooted.
- Parameters: None
- Return Value: Returns 0 if not rooted, non-zero if the device is rooted.
IsEmulator¶
- Supported platform: Android
- Checks if the Android device is an emulator.
- Parameters: None
- Return Value
- Returns 0 for mobile devices, non-zero for emulators.
- Emulators disguise themselves as mobile devices, so 0 may be returned for some emulators.
IsUnofficialBuild¶
- Supported platform: iOS
- Checks whether the iOS build is an unofficial build (a build not downloaded from the App Store)
- It checks that the build is Fairplay encrypted and signed. The builds downloaded from AppStore and TestFlight are assumed to be the official builds.
- Parameters: None
- Return Value: 0 for the official builds, 1 for the externally installed builds. Returns 2 or higher value if it failed to check the build.
GetFunnels¶
- Supported platform: Android
- Gets the funnel where the app is installed.
- Parameters: None
- Return Value: A value such as ADB, Google Play Store, or Amazon Appstore is returned as the path where the app is installed, or the package name of the installed app is returned if it was installed via another market or file explorer app.
GetCertDesc¶
- Supported platform: Android, iOS
- Gets the signed app's certificate information.
- Parameters: None
- Return Value
- Android: Returns the Common Name of the APK keystore.
- iOS: Returns the certificate information associated with the provisioning profile. Builds downloaded from the App Store will return an empty value. If the app is cracked, the name of the crack developer's certificate or the user's personal certificate name is displayed depending on the installation method.
GetTeamId¶
- Supported platform: iOS
- Gets the team ID of the provisioning profile owner account.
- Parameters: None
- Return Value
- The team ID of the Apple developer account that signed the app. A combination of alphabets and numbers.
- If the app is cracked, it may be re-signed with a different account and may differ from the values shown in bold below.
GetCertHash¶
- Supported platform: Android
- Get the signature hash applied to the APK.
- Parameters: None
- Return Value
- APK signature hash value. SHA1 hash, a 40-digit string in hexadecimal format.
- The signing key may change after uploading to Google Play Store or Amazon. After checking the hash values of the signature keys used, you can compare them. If they differ from the previously checked hashes, this can be regarded as repackaging.
GetProxyStatus¶
- Supported platform: Android, iOS
- Checks if the device has proxy settings and returns the result.
- Parameters: None
- Return Value: Returns non-zero if proxy settings are applied.
GetVPNStatus¶
- Supported platform: Android, iOS
- Checks if the device is connected to a VPN and returns the result.
- Parameters: None
- Return Value: Returns non-zero if a VPN connection is active.
HerculesPrefs¶
An encrypted version of the Unity engine's PlayerPrefs class.
Unlike Unity, it is not automatically saved when you exit the game, so you must call the Save function.
If you move game data to another device after backing up your device, encrypted data may be copied as well.
Reference URL: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
GetInt, GetFloat, GetString¶
- Gets the value stored in the encrypted setting file.
-
Parameters
- key: The key of the value to be retrieved.
- defaultValue: Default value to be returned if there is no value.
-
Return Value
- The stored value. If there is no stored value or the value has been tampered with, defaultValue is returned.
- Buffers returned by C++'s HerculesPrefsGetString API must be freed with HerculesFreeMem API.
SetInt, SetFloat, SetString¶
- Encrypts and stores the key and value.
- If you exit the app without calling the Save API, the settings will be lost.
- Parameters
- key: The key of the value to be stored.
- value: The value to be stored.
- Return Value: None
HasKey¶
- Checks if there’s a key.
- Parameters: The key to be tested.
- Return Value: Returns true(C#) or 1(C++) if there’s a key.
DeleteKey¶
- Deletes the key.
- Parameters: The key to be deleted.
- Return Value: None
DeleteAll¶
- Deletes all keys.
- Parameters: None
- Return Value: None
Save¶
- The changed content is encrypted again and saved as a file. The saved contents are loaded when the module is initialized.
- Parameters: None
- Return Value: None
Secure Variable (C/C++)¶
This is a secure variable API that can only be used in C/C++.
In C#, it is called internally when using the secure variable class (HerculesVar).
It is recommended to refer to the security variable guide for how to use it.
AddString¶
- Adds Hercules secure variable of string form. (Allocated)
- Parameters: The pointer for the original string.
- Return Value: the ID of the created secure variable.
AddVar¶
- Adds Hercules secure variable. (Allocated)
- Parameters
- data: The address of the initial value to be referred when creating a variable.
- length: The size of the variable to be created. Sets the size of the data parameter.
- Return Value: the ID of the created secure variable.
FreeMem¶
- Free the buffer allocated by the HerculesGetString API.
- Parameters: Address of a buffer allocated by some APIs.
- Return Value: None
GetString¶
- Reads the value of the Hercules secure string. (Read)
- In C++ template classes, it is automatically called when the value of a variable is referenced.
- If the tampering of a value is detected when the string is read, the callback function which was set during initialization is called.
- Return Value
- Returns a string buffer if the value is read successfully, or returns nullptr if unsuccessful.
- The returned buffer must be freed via the HerculesFreeMem API
- Parameters: the ID of the secure variable.
GetVar¶
- Reads the value of the Hercules secure variable. (Read)
- In C++ template classes, it is automatically called when the value of a variable is referenced.
- When a variable is read, if the tampering of its value is detected, the callback function which was set during initialization is called. (This depends on the policy.)
- Parameters
- seq: the ID of the secure variable.
- data: the address of the data buffer to be read. You must set a buffer with the same size as the size set when creating the variable.
- Return Value
- Returns 0 if the value is read successfully, a positive number for invalid parameters, and a negative number if tampering is detected.
- If you did not set a callback function at the initialization stage, you can refer to this return value.
SetVar¶
- Sets the value of the Hercules secure variable. (Write)
- In C++ template classes, it is automatically called when assigning a value to a variable.
- Parameters
- seq: the ID of the secure variable.
- data: the address of the data buffer to be set. You must set a buffer with the same size as the size set when creating the variable.
- Return Value: None
RemoveVar¶
- Removes the Hercules secure variable. (Release)
- In C++ template classes, it is automatically called when a variable is freed.
- Parameters: the ID of the variable to be released.
- Return Value: None