Skip to content

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.
uint IsJailbrokenDevice();
uint HerculesIsJailbrokenDevice();
  • 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.
uint IsRootedDevice();
uint HerculesIsRootedDevice();
  • 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.
uint IsEmulator();
uint HerculesIsEmulator();
  • 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.
uint IsUnofficialBuild();
uint HerculesIsUnofficialBuild();
  • 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.
string GetFunnels();
const char* HerculesGetFunnels();
  • 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.
string GetCertDesc();
const char* HerculesGetCertDesc();
  • 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.
string GetTeamId();
const char* HerculesGetTeamId();
  • 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.
string GetCertHash();
const char* HerculesGetCertHash();
  • 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.
int GetProxyStatus();
int HerculesGetProxyStatus();
  • 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.
int GetVPNStatus();
int HerculesGetVPNStatus();
  • 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.
int GetInt(string key, int defaultValue = 0);
float GetFloat(string key, float defaultValue = 0.0f);
string GetString(string key, string defaultValue = "");
int HerculesPrefsGetInt(const char *key, int defaultValue = 0);
float HerculesPrefsGetFloat(const char *key, float defaultValue = 0);
char* HerculesPrefsGetString(const char *key, const char *defaultValue = "");
  • 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.
void SetInt(string key, int value);
void SetFloat(string key, float value);
void SetString(string key, string value);
void HerculesPrefsSetInt(const char *key, int value);
void HerculesPrefsSetFloat(const char *key, float value);
void HerculesPrefsSetString(const char *key, const char *value);
  • 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.
bool HasKey(string key);
uint HerculesPrefsHasKey(const char *key);
  • Parameters: The key to be tested.
  • Return Value: Returns true(C#) or 1(C++) if there’s a key.

DeleteKey

  • Deletes the key.
void DeleteKey(string key);
void HerculesPrefsDeleteKey(const char *key);
  • Parameters: The key to be deleted.
  • Return Value: None

DeleteAll

  • Deletes all keys.
void DeleteAll();
void HerculesPrefsDeleteAll();
  • 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.
void Save();
void HerculesPrefsSave();
  • 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)
HERCULES HerculesAddString(const char *str); 
  • Parameters: The pointer for the original string.
  • Return Value: the ID of the created secure variable.

AddVar

  • Adds Hercules secure variable. (Allocated)
HERCULES HerculesAddVar(const void *data, uint length);
  • 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.
void HerculesFreeMem(void *ptr);
  • 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.
char* HerculesGetString(HERCULES seq);
  • 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.)
int HerculesGetVar(HERCULES seq, void *data); 
  • 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.
void HerculesSetVar(HERCULES seq, const void *data);
  • 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.
void HerculesRemoveVar(HERCULES seq);
  • Parameters: the ID of the variable to be released.
  • Return Value: None