#include "platform/amactivator.h" #include "platform/es3sec.h" #include #include #include #include #include "hook/table.h" #include "util/dprintf.h" HANDLE amactivator_handle; static HANDLE my_AMActivator_Create(); static uint64_t my_AMActivator_SetUSBSerialID(HANDLE amactivator, char* serial, size_t len); static uint64_t my_AMActivator_SetUSBProductID(HANDLE amactivator, char* product_id, size_t len); static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id, size_t len); static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password, size_t len); static void my_AMActivator_SetDevelopmentMode(HANDLE amactivator); static bool my_AMActivator_BitLockerUnlock(HANDLE amactivator); static bool my_AMActivator_RequestSignature(HANDLE amactivator); static void my_AMActivator_Update(HANDLE amactivator); static bool my_AMActivator_IsBusy(HANDLE amactivator); static bool my_AMActivator_RequestOneTimeKey(HANDLE amactivator); static bool my_AMActivator_Restore(HANDLE amactivator); static int my_AMActivator_GetSignatureGeneration(HANDLE amactivator); static int my_AMActivator_GetSignatureLastStatus(HANDLE amactivator); static int my_AMActivator_GetOneTimeKey(HANDLE amactivator); static int my_AMActivator_GetOneTimeKeyExpiration(HANDLE amactivator); static int my_AMActivator_GetOneTimeKeyLastStatus(HANDLE amactivator); static HANDLE (*next_AMActivator_Create)(); static uint64_t (*next_AMActivator_SetUSBSerialID)(HANDLE amactivator, char* serial, size_t len); static uint64_t (*next_AMActivator_SetUSBProductID)(HANDLE amactivator, char* product_id, size_t len); static uint64_t (*next_AMActivator_SetUSBVendorID)(HANDLE amactivator, char* vendor_id, size_t len); static uint64_t (*next_AMActivator_SetUSBBitLockerPassword)(HANDLE amactivator, char* password, size_t len); static void (*next_AMActivator_SetDevelopmentMode)(HANDLE amactivator); static bool (*next_AMActivator_BitLockerUnlock)(HANDLE amactivator); static bool (*next_AMActivator_RequestSignature)(HANDLE amactivator); static void (*next_AMActivator_Update)(HANDLE amactivator); static bool (*next_AMActivator_IsBusy)(HANDLE amactivator); static bool (*next_AMActivator_RequestOneTimeKey)(HANDLE amactivator); static bool (*next_AMActivator_Restore)(HANDLE amactivator); static int (*next_AMActivator_GetSignatureGeneration)(HANDLE amactivator); static int (*next_AMActivator_GetSignatureLastStatus)(HANDLE amactivator); static int (*next_AMActivator_GetOneTimeKey)(HANDLE amactivator); static int (*next_AMActivator_GetOneTimeKeyExpiration)(HANDLE amactivator); static int (*next_AMActivator_GetOneTimeKeyLastStatus)(HANDLE amactivator); static const struct hook_symbol activator_syms[] = { { .name = "AMActivator_Create", .patch = my_AMActivator_Create, .link = (void **) &next_AMActivator_Create, }, { .name = "AMActivator_SetUSBSerialID", .patch = my_AMActivator_SetUSBSerialID, .link = (void **) &next_AMActivator_SetUSBSerialID, }, { .name = "AMActivator_SetUSBProductID", .patch = my_AMActivator_SetUSBProductID, .link = (void **) &next_AMActivator_SetUSBProductID, }, { .name = "AMActivator_SetUSBVendorID", .patch = my_AMActivator_SetUSBVendorID, .link = (void **) &next_AMActivator_SetUSBVendorID, }, { .name = "AMActivator_SetUSBBitLockerPassword", .patch = my_AMActivator_SetUSBBitLockerPassword, .link = (void **) &next_AMActivator_SetUSBBitLockerPassword, }, { .name = "AMActivator_SetDevelopmentMode", .patch = my_AMActivator_SetDevelopmentMode, .link = (void **) &next_AMActivator_SetDevelopmentMode, }, { .name = "AMActivator_BitLockerUnlock", .patch = my_AMActivator_BitLockerUnlock, .link = (void **) &next_AMActivator_BitLockerUnlock, }, { .name = "AMActivator_RequestSignature", .patch = my_AMActivator_RequestSignature, .link = (void **) &next_AMActivator_RequestSignature, }, { .name = "AMActivator_Update", .patch = my_AMActivator_Update, .link = (void **) &next_AMActivator_Update, }, { .name = "AMActivator_IsBusy", .patch = my_AMActivator_IsBusy, .link = (void **) &next_AMActivator_IsBusy, }, { .name = "AMActivator_RequestOneTimeKey", .patch = my_AMActivator_RequestOneTimeKey, .link = (void **) &next_AMActivator_RequestOneTimeKey, }, { .name = "AMActivator_Restore", .patch = my_AMActivator_Restore, .link = (void **) &next_AMActivator_Restore, }, { .name = "AMActivator_GetSignatureGeneration", .patch = my_AMActivator_GetSignatureGeneration, .link = (void **) &next_AMActivator_GetSignatureGeneration, }, { .name = "AMActivator_GetSignatureLastStatus", .patch = my_AMActivator_GetSignatureLastStatus, .link = (void **) &next_AMActivator_GetSignatureLastStatus, }, { .name = "AMActivator_GetOneTimeKey", .patch = my_AMActivator_GetOneTimeKey, .link = (void **) &next_AMActivator_GetOneTimeKey, }, { .name = "AMActivator_GetOneTimeKeyExpiration", .patch = my_AMActivator_GetOneTimeKeyExpiration, .link = (void **) &next_AMActivator_GetOneTimeKeyExpiration, }, { .name = "AMActivator_GetOneTimeKeyLastStatus", .patch = my_AMActivator_GetOneTimeKeyLastStatus, .link = (void **) &next_AMActivator_GetOneTimeKeyLastStatus, } }; HRESULT amactivator_hook_init(const struct amactivator_config* cfg, const struct es3sec_config* dong_cfg) { if (!cfg->enable) { return S_OK; } dprintf("AMActivator: init\n"); hook_table_apply( NULL, "amactivator.dll", activator_syms, _countof(activator_syms)); return S_OK; } static HANDLE my_AMActivator_Create() { dprintf("AMActivator: Create\n"); amactivator_handle = (HANDLE)malloc(0x3E8); return amactivator_handle; } static uint64_t my_AMActivator_SetUSBSerialID(HANDLE amactivator, char* serial, size_t len) { dprintf("AMActivator: SetUSBSerialID %s\n", serial); //return next_AMActivator_SetUSBSerialID(amactivator, serial); return 0; } static uint64_t my_AMActivator_SetUSBProductID(HANDLE amactivator, char* product_id, size_t len) { dprintf("AMActivator: SetUSBProductID %s\n", product_id); //return next_AMActivator_SetUSBProductID(amactivator, product_id); return 0; } static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id, size_t len) { dprintf("AMActivator: SetUSBVendorID %s\n", vendor_id); //return next_AMActivator_SetUSBVendorID(amactivator, vendor_id); return 0; } static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password, size_t len) { dprintf("AMActivator: SetUSBBitLockerPassword %s\n", password); //return next_AMActivator_SetUSBBitLockerPassword(amactivator, password); return 0; } static void my_AMActivator_SetDevelopmentMode(HANDLE amactivator) { dprintf("AMActivator: Enable Dev mode\n"); } static bool my_AMActivator_BitLockerUnlock(HANDLE amactivator) { return true; } static bool my_AMActivator_RequestSignature(HANDLE amactivator) { return true; } static void my_AMActivator_Update(HANDLE amactivator) { return; } static bool my_AMActivator_IsBusy(HANDLE amactivator) { return false; } static bool my_AMActivator_RequestOneTimeKey(HANDLE amactivator) { return true; } static bool my_AMActivator_Restore(HANDLE amactivator) { return true; } static int my_AMActivator_GetSignatureGeneration(HANDLE amactivator) { return 1; } static int my_AMActivator_GetSignatureLastStatus(HANDLE amactivator) { return 3; } static int my_AMActivator_GetOneTimeKey(HANDLE amactivator) { return 99999999; } static int my_AMActivator_GetOneTimeKeyExpiration(HANDLE amactivator) { return 4294967295; } static int my_AMActivator_GetOneTimeKeyLastStatus(HANDLE amactivator) { return 3; }