Files
bananatools/platform/amactivator.c

180 lines
6.6 KiB
C

#include "platform/amactivator.h"
#include "platform/es3sec.h"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#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);
static uint64_t my_AMActivator_SetUSBProductID(HANDLE amactivator, char* product_id);
static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id);
static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password);
/*static uint64_t my_AMActivator_SetDevelopmentMode();
static uint64_t my_AMActivator_BitLockerUnlock();
static uint64_t my_AMActivator_RequestSignature();
static uint64_t my_AMActivator_Update();
static uint64_t my_AMActivator_IsBusy();
static uint64_t my_AMActivator_RequestOneTimeKey();
static uint64_t my_AMActivator_Restore();
static uint64_t my_AMActivator_GetSignatureGeneration();
static uint64_t my_AMActivator_GetSignatureLastStatus();
static uint64_t my_AMActivator_GetOneTimeKey();
static uint64_t my_AMActivator_GetOneTimeKeyExpiration();
static uint64_t my_AMActivator_GetOneTimeKeyLastStatus();*/
static HANDLE (*next_AMActivator_Create)();
static uint64_t (*next_AMActivator_SetUSBSerialID)(HANDLE amactivator, char* serial);
static uint64_t (*next_AMActivator_SetUSBProductID)(HANDLE amactivator, char* product_id);
static uint64_t (*next_AMActivator_SetUSBVendorID)(HANDLE amactivator, char* vendor_id);
static uint64_t (*next_AMActivator_SetUSBBitLockerPassword)(HANDLE amactivator, char* password);
/*static uint64_t (*next_AMActivator_SetDevelopmentMode)();
static uint64_t (*next_AMActivator_BitLockerUnlock)();
static uint64_t (*next_AMActivator_RequestSignature)();
static uint64_t (*next_AMActivator_Update)();
static uint64_t (*next_AMActivator_IsBusy)();
static uint64_t (*next_AMActivator_RequestOneTimeKey)();
static uint64_t (*next_AMActivator_Restore)();
static uint64_t (*next_AMActivator_GetSignatureGeneration)();
static uint64_t (*next_AMActivator_GetSignatureLastStatus)();
static uint64_t (*next_AMActivator_GetOneTimeKey)();
static uint64_t (*next_AMActivator_GetOneTimeKeyExpiration)();
static uint64_t (*next_AMActivator_GetOneTimeKeyLastStatus)();*/
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 = next_AMActivator_Create();
return amactivator_handle;
}
static uint64_t my_AMActivator_SetUSBSerialID(HANDLE amactivator, char* serial) {
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) {
dprintf("AMActivator: SetUSBProductID %s\n", product_id);
return next_AMActivator_SetUSBProductID(amactivator, product_id);
}
static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id) {
dprintf("AMActivator: SetUSBVendorID %s\n", vendor_id);
return next_AMActivator_SetUSBVendorID(amactivator, vendor_id);
}
static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password) {
dprintf("AMActivator: SetUSBBitLockerPassword %s\n", password);
return next_AMActivator_SetUSBBitLockerPassword(amactivator, password);
}