TILicenseCheck
bool TILicenseCheck(const char *packageID);
Parameters
| Name | Type | Description |
|---|---|---|
packageID | const char * |
Your reverse-DNS package identifier, exactly as it appears in the control file. |
Returns
true when a receipt exists for that identifier, its signature
verifies, it was issued for this Mac, and it has not expired.
false in every other case, including a missing or unreadable file.
Discussion
Reads
/Library/TweakInject/Receipts/Entries/<packageID>.receipt,
verifies its P-256 ECDSA signature against the public key compiled into your
tweak, compares the recorded machine hash against this Mac's
IOPlatformUUID, and checks the expiry.
The call is cheap to repeat. The machine hash is computed once and cached for the life of the process, so the cost of calling it in several places is reading and parsing a small file, not a Mach round trip each time.
It fails closed. If the receipt cannot be read, or the JSON does not parse,
or the signature check errors, the answer is false.
Example
#import "TILicense.h"
__attribute__((constructor))
static void init(void) {
if (!TILicenseCheck("com.example.mytweak")) return;
install_my_hooks();
}
See also
This is the readable form of the check, and it is also the easiest to patch out. Dispatch Macros and Pointer Guards spread the same decision through your code instead of concentrating it in one branch, and Licensing explains when that matters.