Compare commits

..

1 Commits

Author SHA1 Message Date
coah
4ba78e8929 cleanup(BS2Mach): promote lbl_* aliases to real names
Replace address labels with the existing #define names (DvdReadPending,
TicketViews, CoverBlock, etc.) and drop the macros.

DOL sha1 unchanged.
2026-10-01 18:53:48 -05:00
13 changed files with 239 additions and 611 deletions

View File

@@ -83,9 +83,9 @@ usbapNickname = .bss:0x810BD480; // type:object size:0x18
m_allocator__Q23ipl5scene = .bss:0x810BD498; // type:object size:0x10
AOSSi_NcdIfConfig = .bss:0x810BD4A8; // type:object size:0x160 data:byte
AOSSi_NcdIpConfig = .bss:0x810BD608; // type:object size:0x7C8 data:4byte
sRakuAllocator = .bss:0x810BDDD0; // type:object size:0x10
sRakuStatus = .bss:0x810BDDE0; // type:object size:0xF4 data:4byte
sRakuMsgQueue = .bss:0x810BDED4; // type:object size:0x24
RakuRakuThread_810BDDD0 = .bss:0x810BDDD0; // type:object size:0x10
RakuRakuThread_810BDDE0 = .bss:0x810BDDE0; // type:object size:0xF4 data:4byte
RakuRakuThread_810BDED4 = .bss:0x810BDED4; // type:object size:0x24
AOSS_810BDEF8 = .bss:0x810BDEF8; // type:object size:0x20 data:4byte
AOSS_810BDF18 = .bss:0x810BDF18; // type:object size:0x6A0
AOSS_810BE5B8 = .bss:0x810BE5B8; // type:object size:0x280
@@ -5146,62 +5146,62 @@ AOSSi_WLANConnect = .text:0x813FD72C; // type:function size:0x26C
AOSSi_Sleep = .text:0x813FD998; // type:function size:0x4
AOSSi_Status = .text:0x813FD99C; // type:function size:0x34
AOSS_SetCallback = .text:0x813FD9D0; // type:function size:0x34
syncRakuProgress__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDA04; // type:function size:0x6C scope:local
RakuRakuThread_813FDA04__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDA04; // type:function size:0x6C scope:local
__ct__Q33ipl5scene14RakuRakuThreadFPQ23EGG4Heap = .text:0x813FDA70; // type:function size:0xD8
__dt__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDB48; // type:function size:0xA4
destroy__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDBEC; // type:function size:0xD8
start__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDCC4; // type:function size:0x180
Run__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDE44; // type:function size:0xAC
RakuSocketAlloc = .text:0x813FDEF0; // type:function size:0xC scope:local
RakuSocketFree = .text:0x813FDEFC; // type:function size:0xC scope:local
RakuAtermAlloc = .text:0x813FDF08; // type:function size:0x10 scope:local
RakuAtermFree = .text:0x813FDF18; // type:function size:0x10 scope:local
RakuRakuThread_813FDEF0 = .text:0x813FDEF0; // type:function size:0xC scope:local
RakuRakuThread_813FDEFC = .text:0x813FDEFC; // type:function size:0xC scope:local
RakuRakuThread_813FDF08 = .text:0x813FDF08; // type:function size:0x10 scope:local
RakuRakuThread_813FDF18 = .text:0x813FDF18; // type:function size:0x10 scope:local
getState__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDF28; // type:function size:0x128
cancel__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FE050; // type:function size:0x14
finish__Q33ipl5scene14RakuRakuThreadFP11NCDApConfigPi = .text:0x813FE064; // type:function size:0x214
printInfo__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FE278; // type:function size:0x4
AOSSi_Init = .text:0x813FE27C; // type:function size:0x22C
AOSS_Init_old = .text:0x813FE4A8; // type:function size:0x18C0
AOSSValidateInitConfig = .text:0x813FFD68; // type:function size:0x36C
AOSS_813FFD68 = .text:0x813FFD68; // type:function size:0x36C
AOSS_CheckAP = .text:0x814000D4; // type:function size:0xE0
AOSSDispatchReceiveState = .text:0x814001B4; // type:function size:0x13C
AOSSHandleDiscoverReply = .text:0x814002F0; // type:function size:0x1E0
AOSSHandleAuthReply = .text:0x814004D0; // type:function size:0x1D4
AOSSHandleFinalReply = .text:0x814006A4; // type:function size:0x18C
AOSS_814001B4 = .text:0x814001B4; // type:function size:0x13C
AOSS_814002F0 = .text:0x814002F0; // type:function size:0x1E0
AOSS_814004D0 = .text:0x814004D0; // type:function size:0x1D4
AOSS_814006A4 = .text:0x814006A4; // type:function size:0x18C
AOSSDecryptMessage = .text:0x81400830; // type:function size:0x504
AOSSCheckAccessPointName = .text:0x81400D34; // type:function size:0xD8
AOSSParseNetworkSettings = .text:0x81400E0C; // type:function size:0x2F8
AOSSParseWepConfig = .text:0x81401104; // type:function size:0x180
AOSSParsePskConfig = .text:0x81401284; // type:function size:0x128
AOSSApplyAuthOptions = .text:0x814013AC; // type:function size:0x1C8
AOSSSendDiscoveryRequest = .text:0x81401574; // type:function size:0x204
AOSSSendHelloRequest = .text:0x81401778; // type:function size:0x444
AOSS_81400D34 = .text:0x81400D34; // type:function size:0xD8
AOSS_81400E0C = .text:0x81400E0C; // type:function size:0x2F8
AOSS_81401104 = .text:0x81401104; // type:function size:0x180
AOSS_81401284 = .text:0x81401284; // type:function size:0x128
AOSS_814013AC = .text:0x814013AC; // type:function size:0x1C8
AOSS_81401574 = .text:0x81401574; // type:function size:0x204
AOSS_81401778 = .text:0x81401778; // type:function size:0x444
AOSSBuildInterfaceOption = .text:0x81401BBC; // type:function size:0xE0
AOSSInitKeySchedule = .text:0x81401C9C; // type:function size:0x124
AOSSInitCrc32Table = .text:0x81401DC0; // type:function size:0xC0
AOSSXorBufferWithKey = .text:0x81401E80; // type:function size:0x24C
AOSSConnectAndAwaitHost = .text:0x814020CC; // type:function size:0xF0
ATERMStartNetworkStack = .text:0x814021BC; // type:function size:0x268
ATERMScanAccessPoints = .text:0x81402424; // type:function size:0x348
ATERMFindChangedApRecord = .text:0x8140276C; // type:function size:0x2B8
ATERMDiscoverAccessPoints = .text:0x81402A24; // type:function size:0x41C
ATERMBuildEncryptedMessage = .text:0x81402E40; // type:function size:0x180
ATERMParsePacket = .text:0x81402FC0; // type:function size:0x21C
ATERMBuildAssociationRequest = .text:0x814031DC; // type:function size:0x214
ATERMParseAssociationResponse = .text:0x814033F0; // type:function size:0x224
ATERMParseHexBytes = .text:0x81403614; // type:function size:0xC4
ATERMApplyScanSecuritySettings = .text:0x814036D8; // type:function size:0x1F0
ATERMRunConfigProtocol = .text:0x814038C8; // type:function size:0xEDC
ATERM_814021BC = .text:0x814021BC; // type:function size:0x268
ATERM_81402424 = .text:0x81402424; // type:function size:0x348
ATERM_8140276C = .text:0x8140276C; // type:function size:0x2B8
ATERM_81402A24 = .text:0x81402A24; // type:function size:0x41C
ATERM_81402E40 = .text:0x81402E40; // type:function size:0x180
ATERM_81402FC0 = .text:0x81402FC0; // type:function size:0x21C
ATERM_814031DC = .text:0x814031DC; // type:function size:0x214
ATERM_814033F0 = .text:0x814033F0; // type:function size:0x224
ATERM_81403614 = .text:0x81403614; // type:function size:0xC4
ATERM_814036D8 = .text:0x814036D8; // type:function size:0x1F0
ATERM_814038C8 = .text:0x814038C8; // type:function size:0xEDC
ATERMi_AutoConfigThread = .text:0x814047A4; // type:function size:0xA0
ATERMAesKeyWrap = .text:0x81404844; // type:function size:0x1D4
ATERMAesKeyUnwrap = .text:0x81404A18; // type:function size:0x1E4
ATERMAesExpandEncryptKey = .text:0x81404BFC; // type:function size:0x430
ATERMAesExpandDecryptKey = .text:0x8140502C; // type:function size:0x228
ATERMAesEncryptBlock = .text:0x81405254; // type:function size:0x43C
ATERMAesDecryptBlock = .text:0x81405690; // type:function size:0x43C
ATERMMd5Update = .text:0x81405ACC; // type:function size:0x240
ATERMMd5Transform = .text:0x81405D0C; // type:function size:0xB40
ATERMAlarmWakeQueue = .text:0x8140684C; // type:function size:0x10
ATERM_81404844 = .text:0x81404844; // type:function size:0x1D4
ATERM_81404A18 = .text:0x81404A18; // type:function size:0x1E4
ATERM_81404BFC = .text:0x81404BFC; // type:function size:0x430
ATERM_8140502C = .text:0x8140502C; // type:function size:0x228
ATERM_81405254 = .text:0x81405254; // type:function size:0x43C
ATERM_81405690 = .text:0x81405690; // type:function size:0x43C
ATERM_81405ACC = .text:0x81405ACC; // type:function size:0x240
ATERM_81405D0C = .text:0x81405D0C; // type:function size:0xB40
ATERM_8140684C = .text:0x8140684C; // type:function size:0x10
ATERMi_ApConfigStart = .text:0x8140685C; // type:function size:0x19C
ATERMi_ApConfigEnd = .text:0x814069F8; // type:function size:0x204
ATERMi_ApConfigGetState = .text:0x81406BFC; // type:function size:0x8C

View File

@@ -162,14 +162,14 @@ namespace ipl {
class {
public:
void init() {
mAngleIdx = -1;
unk_0x0C = -1;
pos.x = 0.0f;
pos.y = 0.0f;
}
math::VEC2 pos; // pos
int mStep;
int mAngleIdx;
int unk_0x08;
int unk_0x0C;
} mStandData; // 0xE4
picture mPicture; // 0xF4

View File

@@ -16,8 +16,8 @@ typedef s32 CXStreamingResult;
#define CX_STREAMING_ERR_BAD_FILE_TABLE -5
typedef struct CXUncompContextRL {
u8* outData; // 0x00
int outDataLen; // 0x04
u8* unk_0x00; // 0x00
int unk_0x04; // 0x04
u32 size; // 0x08
u16 unk_0x0C; // 0x0C
u8 unk_0x0e; // 0x0E
@@ -25,8 +25,8 @@ typedef struct CXUncompContextRL {
} CXUncompContextRL;
typedef struct CXUncompContextLZ {
u8* outData; // 0x00
int outDataLen; // 0x04
u8* unk_0x00; // 0x00
int unk_0x04; // 0x04
u32 size; // 0x08
int unk_0x0C; // 0x0C
u8 unk_0x10; // 0x10

View File

@@ -20,8 +20,8 @@ typedef void (*USBKBDEventCallback)(void*, char*);
typedef void (*USBKBDCmdLEDCallback)(BOOL success, void* cbarg);
typedef struct USBKBDCmdLED {
vu32 device; // 0x00
vu8 ledBits; // 0x04
vu32 unk_0x00;
vu8 unk_0x04;
} USBKBDCmdLED;
typedef struct USBKBDCmdLEDAsync {

View File

@@ -5,8 +5,8 @@ static inline int CXiReadHeader(u8*, int*, const u8*, int, int);
static inline CXHuffmanDecodeTableEntry* GetNextNode(CXHuffmanDecodeTableEntry*, int);
void CXInitUncompContextRL(CXUncompContextRL* context, u8* data) {
context->outData = data;
context->outDataLen = 0;
context->unk_0x00 = data;
context->unk_0x04 = 0;
context->unk_0x0e = 0;
context->unk_0x0C = 0;
context->unk_0x0f = 8;
@@ -14,8 +14,8 @@ void CXInitUncompContextRL(CXUncompContextRL* context, u8* data) {
}
void CXInitUncompContextLZ(CXUncompContextLZ* context, u8* data) {
context->outData = data;
context->outDataLen = 0;
context->unk_0x00 = data;
context->unk_0x04 = 0;
context->unk_0x11 = 0;
context->unk_0x12 = 0;
context->unk_0x0C = 0;
@@ -54,27 +54,27 @@ CXStreamingResult CXReadUncompRL(CXUncompContextRL* context, const void* src, u3
}
}
a = CXiReadHeader(&context->unk_0x0f, &context->outDataLen, pSrc, size, context->size);
a = CXiReadHeader(&context->unk_0x0f, &context->unk_0x04, pSrc, size, context->size);
pSrc += a;
size -= a;
if (!size) {
return !context->unk_0x0f ? context->outDataLen : CX_STREAMING_ERR_BAD_FILE_TYPE;
return !context->unk_0x0f ? context->unk_0x04 : CX_STREAMING_ERR_BAD_FILE_TYPE;
}
}
while (context->outDataLen > 0) {
while (context->unk_0x04 > 0) {
if (!(context->unk_0x0e & 0x80)) {
while (context->unk_0x0C) {
*context->outData++ = *pSrc++;
*context->unk_0x00++ = *pSrc++;
context->unk_0x0C--;
context->outDataLen--;
context->unk_0x04--;
size--;
if (!size) {
return context->outDataLen;
return context->unk_0x04;
}
}
} else if (context->unk_0x0C) {
@@ -82,14 +82,14 @@ CXStreamingResult CXReadUncompRL(CXUncompContextRL* context, const void* src, u3
size--;
while (context->unk_0x0C) {
*context->outData++ = b;
*context->unk_0x00++ = b;
context->unk_0x0C--;
context->outDataLen--;
context->unk_0x04--;
}
if (!size) {
return context->outDataLen;
return context->unk_0x04;
}
}
@@ -103,19 +103,19 @@ CXStreamingResult CXReadUncompRL(CXUncompContextRL* context, const void* src, u3
context->unk_0x0C += 1;
}
if (context->unk_0x0C > context->outDataLen) {
if (context->unk_0x0C > context->unk_0x04) {
if (!context->size) {
return CX_STREAMING_ERR_BAD_FILE_SIZE;
}
context->unk_0x0C = context->outDataLen;
context->unk_0x0C = context->unk_0x04;
}
if (size) {
continue;
}
return context->outDataLen;
return context->unk_0x04;
}
if (!context->size && size > 32) {
@@ -174,27 +174,27 @@ CXStreamingResult CXReadUncompLZ(CXUncompContextLZ* context, const void* src, u3
}
}
a = CXiReadHeader(&context->unk_0x13, &context->outDataLen, pSrc, size, context->size);
a = CXiReadHeader(&context->unk_0x13, &context->unk_0x04, pSrc, size, context->size);
pSrc += a;
size -= a;
if (!size) {
return !context->unk_0x13 ? context->outDataLen : CX_STREAMING_ERR_BAD_FILE_TYPE;
return !context->unk_0x13 ? context->unk_0x04 : CX_STREAMING_ERR_BAD_FILE_TYPE;
}
}
while (context->outDataLen > 0) {
while (context->unk_0x04 > 0) {
while (context->unk_0x12) {
s32 a;
if (!size) {
return context->outDataLen;
return context->unk_0x04;
}
if (!(context->unk_0x11 & 0x80)) {
*context->outData++ = *pSrc++;
context->outDataLen--;
*context->unk_0x00++ = *pSrc++;
context->unk_0x04--;
size--;
@@ -240,7 +240,7 @@ CXStreamingResult CXReadUncompLZ(CXUncompContextLZ* context, const void* src, u3
size--;
if (!size) {
return context->outDataLen;
return context->unk_0x04;
}
}
@@ -251,23 +251,23 @@ CXStreamingResult CXReadUncompLZ(CXUncompContextLZ* context, const void* src, u3
size--;
context->unk_0x10 = 3;
if (context->unk_0x0C > context->outDataLen) {
if (context->unk_0x0C > context->unk_0x04) {
if (!context->size) {
return CX_STREAMING_ERR_BAD_FILE_SIZE;
}
context->unk_0x0C = context->outDataLen;
context->unk_0x0C = context->unk_0x04;
}
while (context->unk_0x0C > 0) {
*context->outData = context->outData[-a];
context->outData++;
context->outDataLen--;
*context->unk_0x00 = context->unk_0x00[-a];
context->unk_0x00++;
context->unk_0x04--;
context->unk_0x0C--;
}
there:
if (!context->outDataLen) {
if (!context->unk_0x04) {
goto out;
}
@@ -276,7 +276,7 @@ CXStreamingResult CXReadUncompLZ(CXUncompContextLZ* context, const void* src, u3
}
if (!size) {
return context->outDataLen;
return context->unk_0x04;
}
context->unk_0x11 = *pSrc++;

View File

@@ -43,7 +43,7 @@ typedef struct __sdCbArg {
SDCallbackFunc cb; // 0x00
void* cbArg; // 0x04
SDDev* dev; // 0x08
u32 cmd; // 0x0C
u32 unk_0x0C;
u32 SDDevRca;
u32* resp; // 0x14
u8* SDSectorSize;
@@ -70,7 +70,7 @@ ISD_Error ISD_GetCardSize(SDDev* dev, u32* outSize, u32* outSize2, u32* outSecto
IOSError __sdCb(s32 result, void* arg) {
__sdCbArg* data = (__sdCbArg*)arg;
switch (data->cmd) {
switch (data->unk_0x0C) {
case 4: {
if (result != 0) {
OSReport(__sdPathData, result);
@@ -196,7 +196,7 @@ static IOSError sduCommandv(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
data->cb = cb;
data->cbArg = cbArg;
data->resp = resp;
data->cmd = cmd;
data->unk_0x0C = cmd;
data->SDSectorSize = (u8*)sdCmd;
ret = IOS_IoctlvAsync(fd, 7, readCount, writeCount, __sdVect, __sdCb, data);
@@ -243,7 +243,7 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
data->cb = cb;
data->cbArg = cbArg;
data->resp = resp;
data->cmd = cmd;
data->unk_0x0C = cmd;
data->SDDevRca = 1;
data->SDSectorSize = (u8*)sdCmd;

View File

@@ -101,8 +101,8 @@ USBKBDErr USBKBDSetLED(u32 device, u8 ledBits, USBKBDCmdLED* cmd) {
return USB_KBD_ERR_NOT_INIT;
}
cmd->ledBits = ledBits;
cmd->device = device;
cmd->unk_0x04 = ledBits;
cmd->unk_0x00 = device;
return IOS_Write(usbKbdFd, cmd, sizeof(USBKBDCmdLED)) != IPC_RESULT_OK ? USB_KBD_ERR_FATAL : USB_KBD_ERR_OK;
}
@@ -118,8 +118,8 @@ USBKBDErr USBKBDSetLEDAsync(u32 device, u8 ledBits, USBKBDCmdLEDAsync* cmd, USBK
if (usbKbdFd < 0) {
return USB_KBD_ERR_NOT_INIT;
}
cmd->base.device = device;
cmd->base.ledBits = ledBits;
cmd->base.unk_0x00 = device;
cmd->base.unk_0x04 = ledBits;
cmd->cb = cb;
cmd->cbArg = cbArg;

View File

@@ -485,16 +485,16 @@ namespace ipl {
}
void BoardObject::stt_stand() {
f32 degrees = mStandData.mAngleIdx * 30.0f + 30.0f;
f32 degrees = mStandData.unk_0x0C * 30.0f + 30.0f;
f32 cosF = nw4r::math::CosFIdx(degrees * 0.7111111f);
degrees = mStandData.mAngleIdx * 30.0f + 30.0f;
degrees = mStandData.unk_0x0C * 30.0f + 30.0f;
f32 sinF = nw4r::math::SinFIdx(degrees * 0.7111111f);
math::VEC2 standPos;
__ct__Q33ipl4math4VEC2Fff(&standPos, sinF * 160.0f, cosF * 160.0f);
mBoardPos = (((mStandData.pos * (f32)(10 - mStandData.mStep)) + (standPos * mStandData.mStep)) / 10.0f);
mBoardPos = (((mStandData.pos * (f32)(10 - mStandData.unk_0x08)) + (standPos * mStandData.unk_0x08)) / 10.0f);
if ((mStandData.mStep += 1) > 10) {
if ((mStandData.unk_0x08 += 1) > 10) {
mStandData.init();
mState = STATE_NORMAL;
}

View File

@@ -290,25 +290,25 @@ extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* add
extern int SOSendTo(int socket, const void* buffer, int length, int flags, const void* address);
extern int SOBind(int socket, const void* address);
int AOSSValidateInitConfig(AOSSInitInput* input);
int AOSS_813FFD68(AOSSInitInput* input);
int AOSS_CheckAP(AOSSAccessPointRecord* list);
int AOSSDispatchReceiveState(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request, int socket);
int AOSSHandleDiscoverReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSSHandleAuthReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSSHandleFinalReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSS_814001B4(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request, int socket);
int AOSS_814002F0(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSS_814004D0(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSS_814006A4(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request);
int AOSSDecryptMessage(AOSSDecryptionMessage* message);
int AOSSCheckAccessPointName(u16 command, const u8* manufacturerAddress);
int AOSSParseWepConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config);
int AOSSParsePskConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config);
int AOSS_81400D34(u16 command, const u8* manufacturerAddress);
int AOSS_81401104(const AOSSOptionRecord* packet, AOSSStoredConfig* config);
int AOSS_81401284(const AOSSOptionRecord* packet, AOSSStoredConfig* config);
void AOSSInitKeySchedule(AOSSKeySchedule* schedule, const u8* key, u32 keyLength, u32 stateLength);
void AOSSInitCrc32Table(u32 seed, u32* table);
s16 AOSSBuildInterfaceOption(void* buffer);
int AOSSSendDiscoveryRequest(void* packet, AOSSRequestRecords* request, int socket);
int AOSSSendHelloRequest(void* packet, void* request, int socket);
int AOSS_81401574(void* packet, AOSSRequestRecords* request, int socket);
int AOSS_81401778(void* packet, void* request, int socket);
int AOSSXorBufferWithKey(void* packet, s32 length, char* key, int keyLength);
int AOSSConnectAndAwaitHost(void* settings, void* config);
int AOSSParseNetworkSettings(const AOSSOptionRecord* packet, u8* settings);
int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int responseLength, void* config, void* networkData);
int AOSS_81400E0C(const AOSSOptionRecord* packet, u8* settings);
int AOSS_814013AC(int state, const AOSSReplyOption* response, int responseLength, void* config, void* networkData);
int AOSSi_Init(AOSSInitInput* input) {
int result;
@@ -950,14 +950,14 @@ request_socket_cleanup_complete:
s_operationState = 2;
AOSSi_Status(2);
}
requestResult = AOSSSendDiscoveryRequest(networkAddresses,&requestRecords,requestResult);
requestResult = AOSS_81401574(networkAddresses,&requestRecords,requestResult);
break;
case 1:
if (s_operationState != 3) {
s_operationState = 3;
AOSSi_Status(3);
}
requestResult = AOSSSendHelloRequest(networkAddresses,&requestRecords,requestResult);
requestResult = AOSS_81401778(networkAddresses,&requestRecords,requestResult);
break;
case 2:
@@ -1089,7 +1089,7 @@ process_received_packet:
packetBuffer->socket = s_socket;
retryWait = SONtoHs(receivedLength);
packetBuffer->length = retryWait & 0xffff;
requestResult = AOSSDispatchReceiveState(protocolState,packetBuffer,&receivedPackets,&requestRecords,s_socket);
requestResult = AOSS_814001B4(protocolState,packetBuffer,&receivedPackets,&requestRecords,s_socket);
if (requestResult == 100) {
protocolResult = 0;
}
@@ -1391,7 +1391,7 @@ protocol_socket_cleanup_complete:
resultCode = 0xffffffff;
goto finish_initialization;
} else {
protocolResult = AOSSValidateInitConfig(input);
protocolResult = AOSS_813FFD68(input);
if (protocolResult == 0) goto configuration_success;
{
input->status = 6;
@@ -1414,7 +1414,7 @@ finish_initialization:
return (int)resultCode;
}
int AOSSValidateInitConfig(AOSSInitInput* input) {
int AOSS_813FFD68(AOSSInitInput* input) {
AOSSConfigRecord* config;
u8* output;
u8* cursor;
@@ -1599,7 +1599,7 @@ int AOSS_CheckAP(AOSSAccessPointRecord* list) {
return result;
}
int AOSSDispatchReceiveState(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request, int socket) {
int AOSS_814001B4(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request, int socket) {
u16 messageLength = SONtoHs(packet->message.messageLength);
u16 opcode;
@@ -1618,19 +1618,19 @@ int AOSSDispatchReceiveState(int state, AOSSReceiveBuffer* packet, int* count, A
opcode = SONtoHs(packet->message.opcode);
switch (opcode) {
case 0x1010:
state = AOSSHandleDiscoverReply(state, packet, count, request);
state = AOSS_814002F0(state, packet, count, request);
break;
case 0x2010:
state = AOSSHandleAuthReply(state, packet, count, request);
state = AOSS_814004D0(state, packet, count, request);
break;
case 0x3010:
state = AOSSHandleFinalReply(state, packet, count, request);
state = AOSS_814006A4(state, packet, count, request);
break;
}
return state;
}
int AOSSHandleDiscoverReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
int AOSS_814002F0(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
AOSSReplyPayload* reply;
AOSSRequestRecord* requestRecord;
size_t manufacturerLength;
@@ -1686,7 +1686,7 @@ int AOSSHandleDiscoverReply(int state, AOSSReceiveBuffer* packet, int* count, AO
(*count)++;
return state;
}
parserResult = AOSSParseNetworkSettings(&reply->data.optionRecord, s_networkBuffer);
parserResult = AOSS_81400E0C(&reply->data.optionRecord, s_networkBuffer);
if (parserResult < 0) {
if (parserResult == -2) {
s_errorCode = 0x16;
@@ -1705,7 +1705,7 @@ int AOSSHandleDiscoverReply(int state, AOSSReceiveBuffer* packet, int* count, AO
return 1;
}
int AOSSHandleAuthReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
int AOSS_814004D0(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
size_t manufacturerLength;
int compareResult;
u16 packetSequence;
@@ -1756,7 +1756,7 @@ int AOSSHandleAuthReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRe
} else {
memset(&s_configData, 0, sizeof(s_configData));
authType = SONtoHs(packet->message.authType);
operationResult = AOSSApplyAuthOptions(0, (const AOSSReplyOption*)reply, authType, &s_configData,
operationResult = AOSS_814013AC(0, (const AOSSReplyOption*)reply, authType, &s_configData,
s_networkBuffer);
if (operationResult < 0) {
*count = *count + 1;
@@ -1772,7 +1772,7 @@ int AOSSHandleAuthReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRe
return state;
}
int AOSSHandleFinalReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
int AOSS_814006A4(int state, AOSSReceiveBuffer* packet, int* count, AOSSRequestRecords* request) {
int result = state;
size_t manufacturerLength;
int compareResult;
@@ -1857,7 +1857,7 @@ int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
return -100;
}
result = AOSSCheckAccessPointName(SONtoHs(message->command), manufacturerAddress);
result = AOSS_81400D34(SONtoHs(message->command), manufacturerAddress);
if (result != 0) {
return result;
}
@@ -1931,7 +1931,7 @@ int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
return 0;
}
int AOSSCheckAccessPointName(u16 command, const u8* manufacturerAddress) {
int AOSS_81400D34(u16 command, const u8* manufacturerAddress) {
u8* storedAddress = s_accessPointName;
int result = 0;
int hasAddress = 0;
@@ -1961,7 +1961,7 @@ int AOSSCheckAccessPointName(u16 command, const u8* manufacturerAddress) {
return result;
}
int AOSSParseNetworkSettings(const AOSSOptionRecord* packet, u8* settings) {
int AOSS_81400E0C(const AOSSOptionRecord* packet, u8* settings) {
const u8* packetBytes = (const u8*)packet;
const AOSSOptionRecord* record;
s32 length;
@@ -2027,7 +2027,7 @@ int AOSSParseNetworkSettings(const AOSSOptionRecord* packet, u8* settings) {
return 0;
}
int AOSSParseWepConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config) {
int AOSS_81401104(const AOSSOptionRecord* packet, AOSSStoredConfig* config) {
const u8* packetBytes = (const u8*)packet;
const AOSSOptionRecord* record = (const AOSSOptionRecord*)(packetBytes + 6);
u32 length;
@@ -2099,7 +2099,7 @@ int AOSSParseWepConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config)
return 0;
}
int AOSSParsePskConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config) {
int AOSS_81401284(const AOSSOptionRecord* packet, AOSSStoredConfig* config) {
const u8* packetBytes = (const u8*)packet;
const AOSSOptionRecord* record = (const AOSSOptionRecord*)(packetBytes + 6);
u32 length;
@@ -2146,7 +2146,7 @@ int AOSSParsePskConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config)
return 0;
}
int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int responseLength, void* config, void* networkData) {
int AOSS_814013AC(int state, const AOSSReplyOption* response, int responseLength, void* config, void* networkData) {
u32 flags = 0;
const AOSSReplyOption* responseRecord;
AOSSConfigRecord* configRecord;
@@ -2190,19 +2190,19 @@ int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int respons
do {
switch (option->fields.type) {
case 3:
result = AOSSParseWepConfig((const AOSSOptionRecord*)option, wep40Config);
result = AOSS_81401104((const AOSSOptionRecord*)option, wep40Config);
flags |= 1;
break;
case 4:
result = AOSSParseWepConfig((const AOSSOptionRecord*)option, wep104Config);
result = AOSS_81401104((const AOSSOptionRecord*)option, wep104Config);
flags |= 2;
break;
case 5:
result = AOSSParsePskConfig((const AOSSOptionRecord*)option, tkipConfig);
result = AOSS_81401284((const AOSSOptionRecord*)option, tkipConfig);
flags |= 4;
break;
case 6:
result = AOSSParsePskConfig((const AOSSOptionRecord*)option, aesConfig);
result = AOSS_81401284((const AOSSOptionRecord*)option, aesConfig);
flags |= 8;
break;
case 10:
@@ -2234,7 +2234,7 @@ int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int respons
return 0;
}
int AOSSSendDiscoveryRequest(void* packet, AOSSRequestRecords* request, int socket) {
int AOSS_81401574(void* packet, AOSSRequestRecords* request, int socket) {
u8* responsePayload;
u8 accessPointName[8];
AOSSSocketAddress destination;
@@ -2302,7 +2302,7 @@ int AOSSSendDiscoveryRequest(void* packet, AOSSRequestRecords* request, int sock
return result;
}
int AOSSSendHelloRequest(void* packet, void* request, int socket) {
int AOSS_81401778(void* packet, void* request, int socket) {
AOSSHelloPacket* response = (AOSSHelloPacket*)s_responseBuffer;
AOSSHelloPayload* payload;
AOSSRequestRecords* requestRecords = (AOSSRequestRecords*)request;

View File

@@ -540,20 +540,20 @@ AtermProgressCallback gAtermProgressCallback;
u32 gAtermResult;
s32 gAtermState;
void ATERMAlarmWakeQueue(OSAlarm* alarm, OSContext* context);
s32 ATERMRunConfigProtocol(void);
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length);
void ATERM_8140684C(OSAlarm* alarm, OSContext* context);
s32 ATERM_814038C8(void);
void ATERM_81405ACC(AtermMd5Context* context, void* input, u32 length);
extern u8 gAtermDigestFill[64];
extern u8* gAtermRequestOptions;
int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
int ATERMAesKeyUnwrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
int ATERMAesExpandEncryptKey(u32* expandedKey, const void* key, u32 keyBits);
int ATERMAesExpandDecryptKey(u32* expandedKey, const void* key, u32 keyBits);
void ATERMAesEncryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u8* output);
void ATERMAesDecryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u8* output);
int ATERMParseAssociationResponse(u16* response);
int ATERM_81404844(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
int ATERM_81404A18(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
int ATERM_81404BFC(u32* expandedKey, const void* key, u32 keyBits);
int ATERM_8140502C(u32* expandedKey, const void* key, u32 keyBits);
void ATERM_81405254(const u32* expandedKey, u32 rounds, const u8* input, u8* output);
void ATERM_81405690(const u32* expandedKey, u32 rounds, const u8* input, u8* output);
int ATERM_814033F0(u16* response);
int ATERMStartNetworkStack(void) {
int ATERM_814021BC(void) {
int status;
int waitCount = 0;
u32 convertedHost;
@@ -605,7 +605,7 @@ int ATERMStartNetworkStack(void) {
OSCreateAlarm(&interfaceAlarm);
OSSetAlarmTag(&interfaceAlarm, (u32)&interfaceQueue);
timeoutTicks = (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10;
OSSetAlarm(&interfaceAlarm, timeoutTicks, ATERMAlarmWakeQueue);
OSSetAlarm(&interfaceAlarm, timeoutTicks, ATERM_8140684C);
OSReceiveMessage(&interfaceQueue, &interfaceMessage, 1);
}
@@ -621,7 +621,7 @@ int ATERMStartNetworkStack(void) {
OSCreateAlarm(&hostAlarm);
OSSetAlarmTag(&hostAlarm, (u32)&hostQueue);
timeoutTicks = (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10;
OSSetAlarm(&hostAlarm, timeoutTicks, ATERMAlarmWakeQueue);
OSSetAlarm(&hostAlarm, timeoutTicks, ATERM_8140684C);
OSReceiveMessage(&hostQueue, &hostMessage, 1);
}
} else {
@@ -631,7 +631,7 @@ int ATERMStartNetworkStack(void) {
return waitCount;
}
int ATERMScanAccessPoints(u16* resultBuffer, u32 resultBufferLength) {
int ATERM_81402424(u16* resultBuffer, u32 resultBufferLength) {
int lockId;
int result = -2;
u16* scanBuffer = resultBuffer;
@@ -678,7 +678,7 @@ int ATERMScanAccessPoints(u16* resultBuffer, u32 resultBufferLength) {
OSCreateAlarm(&startupAlarm);
OSSetAlarmTag(&startupAlarm, (u32)&startupQueue);
OSSetAlarm(&startupAlarm, (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10,
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&startupQueue, &startupMessage, 1);
} while (1);
@@ -719,7 +719,7 @@ int ATERMScanAccessPoints(u16* resultBuffer, u32 resultBufferLength) {
OSCreateAlarm(&scanAlarm);
OSSetAlarmTag(&scanAlarm, (u32)&scanQueue);
OSSetAlarm(&scanAlarm, (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10,
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&scanQueue, &scanMessage, 1);
}
@@ -737,7 +737,7 @@ cleanup_driver:
OSCreateAlarm(&cleanupAlarm);
OSSetAlarmTag(&cleanupAlarm, (u32)&cleanupQueue);
OSSetAlarm(&cleanupAlarm, (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10,
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&cleanupQueue, &cleanupMessage, 1);
}
@@ -752,7 +752,7 @@ unlock_driver:
OSCreateAlarm(&unlockAlarm);
OSSetAlarmTag(&unlockAlarm, (u32)&unlockQueue);
OSSetAlarm(&unlockAlarm, (__mulhwu(0x10624DD3, *(u32*)0x800000F8 >> 2) >> 6) * 10,
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&unlockQueue, &unlockMessage, 1);
}
}
@@ -760,7 +760,7 @@ unlock_driver:
return result;
}
int ATERMFindChangedApRecord(AtermApRecordSet* currentRecords, AtermApRecordSet* previousRecords,
int ATERM_8140276C(AtermApRecordSet* currentRecords, AtermApRecordSet* previousRecords,
u32* changedIndex) {
u32 previousIndex;
u32 currentIndex = 0;
@@ -869,7 +869,7 @@ int ATERMFindChangedApRecord(AtermApRecordSet* currentRecords, AtermApRecordSet*
return result;
}
int ATERMDiscoverAccessPoints(void) {
int ATERM_81402A24(void) {
s32 result = -1;
u32 scanBufferBytes;
u32 recordIndex;
@@ -912,7 +912,7 @@ int ATERMDiscoverAccessPoints(void) {
break;
}
result = ATERMScanAccessPoints((u16*)scanBuffer, scanBufferBytes);
result = ATERM_81402424((u16*)scanBuffer, scanBufferBytes);
if (result < 0) {
goto cleanup;
}
@@ -954,7 +954,7 @@ int ATERMDiscoverAccessPoints(void) {
currentRecords->count = result;
if (gAtermState != 1 &&
ATERMFindChangedApRecord(currentRecords, previousRecords, (u32*)&progressInfo[0])) {
ATERM_8140276C(currentRecords, previousRecords, (u32*)&progressInfo[0])) {
AtermApRecord* selectedRecord;
gAtermSelectedRecordIndex = progressInfo[0];
selectedRecord = &currentRecords->entries[progressInfo[0]];
@@ -1036,7 +1036,7 @@ cleanup:
return result;
}
int ATERMBuildEncryptedMessage(u16* messageBuffer, u32 sequence, u16* payload, size_t payloadLength,
int ATERM_81402E40(u16* messageBuffer, u32 sequence, u16* payload, size_t payloadLength,
void* encryptionKey) {
u8* end;
u8* cursor;
@@ -1045,7 +1045,7 @@ int ATERMBuildEncryptedMessage(u16* messageBuffer, u32 sequence, u16* payload, s
memset(payload, 0, 8);
payload[0] = SOHtoNs((payloadLength - 8) & 0xFFFF);
if (encryptionKey != NULL) {
ATERMAesKeyWrap(messageBuffer + 3, payload, payloadLength, encryptionKey, 0x10);
ATERM_81404844(messageBuffer + 3, payload, payloadLength, encryptionKey, 0x10);
payloadLength += 8;
} else {
memcpy(messageBuffer + 3, payload, payloadLength);
@@ -1064,7 +1064,7 @@ int ATERMBuildEncryptedMessage(u16* messageBuffer, u32 sequence, u16* payload, s
return (int)(end + sizeof(u16) - (u8*)messageBuffer);
}
int ATERMParsePacket(AtermPacket* packet, u32* setupType) {
int ATERM_81402FC0(AtermPacket* packet, u32* setupType) {
u8* cursor;
u8* end;
u8* payload;
@@ -1142,7 +1142,7 @@ int ATERMParsePacket(AtermPacket* packet, u32* setupType) {
return 0;
}
int ATERMBuildAssociationRequest(AtermAssociationRequest* request) {
int ATERM_814031DC(AtermAssociationRequest* request) {
u8 scanAddress[8];
u8 interfaceMacAddress[8];
char interfaceMacText[32];
@@ -1227,7 +1227,7 @@ int ATERMBuildAssociationRequest(AtermAssociationRequest* request) {
return 1;
}
int ATERMParseAssociationResponse(u16* response) {
int ATERM_814033F0(u16* response) {
u16* optionCursor = response + 4;
u8* optionValue;
u16* responseEnd;
@@ -1317,7 +1317,7 @@ int ATERMParseAssociationResponse(u16* response) {
return result;
}
int ATERMParseHexBytes(u8* destination, const char* source, s32 length) {
int ATERM_81403614(u8* destination, const char* source, s32 length) {
s32 value = 0;
s32 characterIndex = 0;
@@ -1349,7 +1349,7 @@ int ATERMParseHexBytes(u8* destination, const char* source, s32 length) {
return 1;
}
int ATERMApplyScanSecuritySettings(void) {
int ATERM_814036D8(void) {
s32 result = 1;
char* sourceKey;
char* outputKey;
@@ -1389,7 +1389,7 @@ int ATERMApplyScanSecuritySettings(void) {
break;
case 10:
gAtermConfigurationResult.setupMode = 1;
ATERMParseHexBytes((u8*)outputKey, keyString, 10);
ATERM_81403614((u8*)outputKey, keyString, 10);
break;
case 13:
gAtermConfigurationResult.setupMode = 2;
@@ -1397,7 +1397,7 @@ int ATERMApplyScanSecuritySettings(void) {
break;
case 26:
gAtermConfigurationResult.setupMode = 2;
ATERMParseHexBytes((u8*)outputKey, keyString, 0x1A);
ATERM_81403614((u8*)outputKey, keyString, 0x1A);
break;
case 16:
gAtermConfigurationResult.setupMode = 3;
@@ -1405,7 +1405,7 @@ int ATERMApplyScanSecuritySettings(void) {
break;
case 32:
gAtermConfigurationResult.setupMode = 3;
ATERMParseHexBytes((u8*)outputKey, keyString, 0x20);
ATERM_81403614((u8*)outputKey, keyString, 0x20);
break;
default:
result = -7;
@@ -1432,7 +1432,7 @@ int ATERMApplyScanSecuritySettings(void) {
return result;
}
s32 ATERMRunConfigProtocol(void) {
s32 ATERM_814038C8(void) {
OSMessageQueue waitQueue;
OSMessage waitBuffer[1];
OSMessage waitMessage;
@@ -1459,7 +1459,7 @@ s32 ATERMRunConfigProtocol(void) {
OSSetAlarmTag(&waitAlarm, (u32)&waitQueue);
OSSetAlarm(&waitAlarm,
(__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6) * 500,
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&waitQueue, &waitMessage, 1);
switch (gAtermProtocolState) {
case 0:
@@ -1467,7 +1467,7 @@ s32 ATERMRunConfigProtocol(void) {
case 1:
{
AtermProgress progress;
result = ATERMDiscoverAccessPoints();
result = ATERM_81402A24();
if (result != 1) {
failed = 1;
break;
@@ -1485,7 +1485,7 @@ s32 ATERMRunConfigProtocol(void) {
break;
}
case 2:
result = ATERMStartNetworkStack();
result = ATERM_814021BC();
if (result != 1) {
failed = 1;
break;
@@ -1525,11 +1525,11 @@ s32 ATERMRunConfigProtocol(void) {
break;
}
peerAddress.length = 8;
ATERMBuildAssociationRequest((AtermAssociationRequest*)gAtermConfigurationResult.connectionPrefix);
ATERM_814031DC((AtermAssociationRequest*)gAtermConfigurationResult.connectionPrefix);
receivedLength = SORecvFrom(socket, gAtermConfigurationResult.packetBuffer,
sizeof(gAtermConfigurationResult.packetBuffer), 4, &peerAddress);
if (receivedLength > 0 &&
ATERMParsePacket((AtermPacket*)gAtermConfigurationResult.packetBuffer, &gAtermResponseMode)) {
ATERM_81402FC0((AtermPacket*)gAtermConfigurationResult.packetBuffer, &gAtermResponseMode)) {
AtermProgress progress;
gAtermDeadline = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6)) + 30000;
gAtermProtocolState = 5;
@@ -1588,7 +1588,7 @@ s32 ATERMRunConfigProtocol(void) {
longOption++;
}
optionEnd = (u8*)longOption;
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 2,
gAtermMessageLength = ATERM_81402E40((u16*)gAtermConfigurationResult.packetBuffer, 2,
(u16*)response->data, optionEnd - gAtermRequestOptions + 8, NULL);
sendAddress.length = 8;
sendAddress.family = 2;
@@ -1628,7 +1628,7 @@ s32 ATERMRunConfigProtocol(void) {
} else if (sequence != 3) {
payloadLength = 0;
} else if (gAtermConfigurationResult.connectionPrefix != NULL) {
ATERMAesKeyUnwrap((u16*)response->authentication.payload, (u16*)payload,
ATERM_81404A18((u16*)response->authentication.payload, (u16*)payload,
payloadLength, gAtermConfigurationResult.connectionPrefix, 16);
payloadLength -= 8;
} else {
@@ -1660,7 +1660,7 @@ s32 ATERMRunConfigProtocol(void) {
digestContext.state[1] = 0xEFCDAB89;
digestContext.state[2] = 0x98BADCFE;
digestContext.state[3] = 0x10325476;
ATERMMd5Update(&digestContext, &authenticationTime, sizeof(authenticationTime));
ATERM_81405ACC(&digestContext, &authenticationTime, sizeof(authenticationTime));
digestLength[0] = digestContext.bitCountLow;
digestLength[1] = digestContext.bitCountLow >> 8;
digestLength[2] = digestContext.bitCountLow >> 16;
@@ -1670,9 +1670,9 @@ s32 ATERMRunConfigProtocol(void) {
digestLength[6] = digestContext.bitCountHigh >> 16;
digestLength[7] = digestContext.bitCountHigh >> 24;
digestBytes = (digestContext.bitCountLow >> 3) & 0x3F;
ATERMMd5Update(&digestContext, gAtermDigestFill,
ATERM_81405ACC(&digestContext, gAtermDigestFill,
digestBytes < 56 ? 56 - digestBytes : 120 - digestBytes);
ATERMMd5Update(&digestContext, digestLength, sizeof(digestLength));
ATERM_81405ACC(&digestContext, digestLength, sizeof(digestLength));
response->authentication.digest[0] = digestContext.state[0];
response->authentication.digest[1] = digestContext.state[0] >> 8;
response->authentication.digest[2] = digestContext.state[0] >> 16;
@@ -1724,7 +1724,7 @@ s32 ATERMRunConfigProtocol(void) {
memcpy(option->value, response->authentication.digest, 8);
gAtermReplyLength = (u8*)(option + 1) - response->data;
response->authentication.decoded.length = gAtermReplyLength - 8;
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 4,
gAtermMessageLength = ATERM_81402E40((u16*)gAtermConfigurationResult.packetBuffer, 4,
(u16*)response->data, gAtermReplyLength, gAtermConfigurationResult.connectionPrefix);
sendAddress.length = 8;
sendAddress.family = 2;
@@ -1758,14 +1758,14 @@ s32 ATERMRunConfigProtocol(void) {
} else if (sequence != 5) {
payloadLength = 0;
} else if (sessionKey != NULL) {
ATERMAesKeyUnwrap((u16*)response->authentication.payload, (u16*)payload,
ATERM_81404A18((u16*)response->authentication.payload, (u16*)payload,
payloadLength, sessionKey, 16);
payloadLength -= 8;
} else {
memcpy(response->authentication.payload, payload, payloadLength);
}
gAtermReplyLength = payloadLength;
if (payloadLength != 0 && ATERMParseAssociationResponse((u16*)response->data)) {
if (payloadLength != 0 && ATERM_814033F0((u16*)response->data)) {
gAtermProtocolState = 9;
retries = 0;
gAtermMode = gScanSettings.ssid[0] != 0;
@@ -1795,7 +1795,7 @@ s32 ATERMRunConfigProtocol(void) {
memcpy(option->value, &gAtermMode, 1);
gAtermReplyLength = (u8*)(option + 1) - response->data;
response->authentication.decoded.length = gAtermReplyLength - 8;
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 6,
gAtermMessageLength = ATERM_81402E40((u16*)gAtermConfigurationResult.packetBuffer, 6,
(u16*)response->data, gAtermReplyLength, sessionKey);
if (NCDGetLinkStatus() != 5) {
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6)) + 1000;
@@ -1817,7 +1817,7 @@ s32 ATERMRunConfigProtocol(void) {
if (now >= lastSendTime + 1000) {
if (++retries >= 10) {
failed = 1;
result = ATERMApplyScanSecuritySettings();
result = ATERM_814036D8();
} else {
gAtermProtocolState = 9;
}
@@ -1840,7 +1840,7 @@ s32 ATERMRunConfigProtocol(void) {
u8 gAtermDigestFill[64] = { 0x80 };
s32 ATERMi_AutoConfigThread(void) {
s32 result = ATERMRunConfigProtocol();
s32 result = ATERM_814038C8();
AtermProgress progress;
u32 equalityMask;
s32 completedState;
@@ -1864,7 +1864,7 @@ s32 ATERMi_AutoConfigThread(void) {
return 0;
}
int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength) {
int ATERM_81404844(u16* destination, u16* source, u32 length, void* key, u32 keyLength) {
u32 expandedKey[80];
union { u32 words[4]; u8 bytes[16]; } block;
union { u64 value; u8 bytes[8]; } counter;
@@ -1889,7 +1889,7 @@ int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 ke
return 0;
}
rounds = ATERMAesExpandEncryptKey(expandedKey, key, keyLength << 3);
rounds = ATERM_81404BFC(expandedKey, key, keyLength << 3);
destinationBytes = (u8*)destination;
sourceBytes = (const u8*)source;
memcpy(destinationBytes + 8, sourceBytes, length);
@@ -1901,7 +1901,7 @@ int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 ke
outputBlock = destinationBytes + blockOffset;
memcpy(stateBytes + 8, outputBlock, 8);
ATERMAesEncryptBlock(expandedKey, rounds, stateBytes, stateBytes);
ATERM_81405254(expandedKey, rounds, stateBytes, stateBytes);
counter.value = (u64)(s64)blockIndex + passBase;
stateBytes[0] ^= counter.bytes[0];
stateBytes[1] ^= counter.bytes[1];
@@ -1918,7 +1918,7 @@ int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 ke
return 1;
}
int ATERMAesKeyUnwrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength) {
int ATERM_81404A18(u16* destination, u16* source, u32 length, void* key, u32 keyLength) {
u32 expandedKey[80];
union { u32 words[4]; u8 bytes[16]; } block;
union { u64 value; u8 bytes[8]; } counter;
@@ -1942,7 +1942,7 @@ int ATERMAesKeyUnwrap(u16* destination, u16* source, u32 length, void* key, u32
return 0;
}
rounds = ATERMAesExpandDecryptKey(expandedKey, key, keyLength << 3);
rounds = ATERM_8140502C(expandedKey, key, keyLength << 3);
destinationBytes = (u8*)destination;
sourceBytes = (const u8*)source;
memcpy(block.words, sourceBytes, 8);
@@ -1963,7 +1963,7 @@ int ATERMAesKeyUnwrap(u16* destination, u16* source, u32 length, void* key, u32
stateBytes[6] ^= counter.bytes[6];
stateBytes[7] ^= counter.bytes[7];
memcpy(stateBytes + 8, outputBlock, 8);
ATERMAesDecryptBlock(expandedKey, rounds, stateBytes, stateBytes);
ATERM_81405690(expandedKey, rounds, stateBytes, stateBytes);
memcpy(outputBlock, stateBytes + 8, 8);
}
}
@@ -1986,7 +1986,7 @@ int ATERMAesKeyUnwrap(u16* destination, u16* source, u32 length, void* key, u32
((u32)keyBytes[(index) * 4 + 2] << 8) ^ \
keyBytes[(index) * 4 + 3])
int ATERMAesExpandEncryptKey(u32* expandedKey, const void* key, u32 keyBits) {
int ATERM_81404BFC(u32* expandedKey, const void* key, u32 keyBits) {
const u8* keyBytes = (const u8*)key;
u32* roundKey = expandedKey;
@@ -2096,8 +2096,8 @@ int ATERMAesExpandEncryptKey(u32* expandedKey, const void* key, u32 keyBits) {
(inverseTable0[byte0] ^ inverseTable1[byte1]); \
}
int ATERMAesExpandDecryptKey(u32* expandedKey, const void* key, u32 keyBits) {
int rounds = ATERMAesExpandEncryptKey(expandedKey, key, keyBits);
int ATERM_8140502C(u32* expandedKey, const void* key, u32 keyBits) {
int rounds = ATERM_81404BFC(expandedKey, key, keyBits);
u32* roundKey;
s32 roundCount;
s32 firstIndex;
@@ -2145,7 +2145,7 @@ int ATERMAesExpandDecryptKey(u32* expandedKey, const void* key, u32 keyBits) {
#undef ATERM_AES_TRANSFORM_KEY
void ATERMAesEncryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u8* output) {
void ATERM_81405254(const u32* expandedKey, u32 rounds, const u8* input, u8* output) {
u32 state0, state1, state2, state3;
u32 next0, next1, next2, next3;
s32 roundPairs;
@@ -2232,7 +2232,7 @@ void ATERMAesEncryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u
output[15] = state3;
}
void ATERMAesDecryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u8* output) {
void ATERM_81405690(const u32* expandedKey, u32 rounds, const u8* input, u8* output) {
u32 state0, state1, state2, state3;
u32 next0, next1, next2, next3;
s32 roundPairs;
@@ -2319,9 +2319,9 @@ void ATERMAesDecryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u
output[15] = state3;
}
void ATERMMd5Transform(u32 state[4], const u8 block[64]);
void ATERM_81405D0C(u32 state[4], const u8 block[64]);
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
void ATERM_81405ACC(AtermMd5Context* context, void* input, u32 length) {
u8* data = (u8*)input;
u32 bufferIndex = (context->bitCountLow >> 3) & 0x3F;
u32 bytesToFill;
@@ -2338,9 +2338,9 @@ void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
for (copiedBytes = 0; copiedBytes < bytesToFill; copiedBytes++) {
context->buffer8[bufferIndex + copiedBytes] = data[copiedBytes];
}
ATERMMd5Transform(context->state, context->buffer8);
ATERM_81405D0C(context->state, context->buffer8);
for (copiedBytes = bytesToFill; copiedBytes + 63 < length; copiedBytes += 64) {
ATERMMd5Transform(context->state, data + copiedBytes);
ATERM_81405D0C(context->state, data + copiedBytes);
}
bufferIndex = 0;
} else {
@@ -2358,7 +2358,7 @@ void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
(A) += (B); \
} while (0)
void ATERMMd5Transform(u32 state[4], const u8 block[64]) {
void ATERM_81405D0C(u32 state[4], const u8 block[64]) {
u32 byteIndex;
u32 index;
const u8* inputWord;
@@ -2452,7 +2452,7 @@ void ATERMMd5Transform(u32 state[4], const u8 block[64]) {
}
#undef ATERM_MD5_STEP
void ATERMAlarmWakeQueue(OSAlarm* alarm, OSContext* context) {
void ATERM_8140684C(OSAlarm* alarm, OSContext* context) {
OSMessageQueue* queue = (OSMessageQueue*)alarm->tag;
OSSendMessage(queue, NULL, 0);
}
@@ -2525,7 +2525,7 @@ int ATERMi_ApConfigEnd(void) {
OSSetAlarmTag(&cancelAlarm, (u32)&cancelQueue);
OSSetAlarm(&cancelAlarm,
OSMillisecondsToTicks(100),
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&cancelQueue, &cancelMessage, 1);
}
@@ -2534,7 +2534,7 @@ int ATERMi_ApConfigEnd(void) {
OSSetAlarmTag(&joinAlarm, (u32)&joinQueue);
OSSetAlarm(&joinAlarm,
OSMillisecondsToTicks(500),
ATERMAlarmWakeQueue);
ATERM_8140684C);
OSReceiveMessage(&joinQueue, &joinMessage, 1);
while (OSIsThreadTerminated(&sAtermThread) == 0) {
OSJoinThread(&sAtermThread, NULL);

View File

@@ -28,26 +28,26 @@ int ATERMi_ApConfigEnd();
namespace ipl {
namespace scene {
extern "C" MEMAllocator sRakuAllocator;
MEMAllocator sRakuAllocator;
extern "C" MEMAllocator RakuRakuThread_810BDDD0;
MEMAllocator RakuRakuThread_810BDDD0;
struct RakuStatus {
RakuProgress progress;
RakuConfiguration configuration;
};
extern "C" RakuStatus sRakuStatus;
RakuStatus sRakuStatus;
extern "C" OSMessageQueue sRakuMsgQueue;
OSMessageQueue sRakuMsgQueue;
extern "C" RakuStatus RakuRakuThread_810BDDE0;
RakuStatus RakuRakuThread_810BDDE0;
extern "C" OSMessageQueue RakuRakuThread_810BDED4;
OSMessageQueue RakuRakuThread_810BDED4;
static OSTime startTime;
static bool active;
static OSMessage messageSlot;
static int displayState = 1;
extern "C" {
static void* RakuSocketAlloc(u32, s32 size);
static void RakuSocketFree(u32, void* block, s32);
static void* RakuAtermAlloc(u32 size);
static void RakuAtermFree(void* block);
static void* RakuRakuThread_813FDEF0(u32, s32 size);
static void RakuRakuThread_813FDEFC(u32, void* block, s32);
static void* RakuRakuThread_813FDF08(u32 size);
static void RakuRakuThread_813FDF18(void* block);
}
struct RakuStack {
@@ -60,7 +60,7 @@ public:
virtual ~RakuRakuThread();
virtual void* Run();
virtual void unk_0x2C() = 0;
void syncRakuProgress();
void RakuRakuThread_813FDA04();
static void progressCallback(RakuProgress* progress);
void destroy();
int start();
@@ -78,15 +78,15 @@ private:
MEMHeapHandle mHeap;
};
void RakuRakuThread::syncRakuProgress() {
void RakuRakuThread::RakuRakuThread_813FDA04() {
BOOL interrupts = OSDisableInterrupts();
sRakuStatus.progress = *(RakuProgress*)this;
RakuRakuThread_810BDDE0.progress = *(RakuProgress*)this;
startTime = OSGetTime();
OSRestoreInterrupts(interrupts);
}
void RakuRakuThread::progressCallback(RakuProgress* progress) {
((RakuRakuThread*)progress)->syncRakuProgress();
((RakuRakuThread*)progress)->RakuRakuThread_813FDA04();
}
RakuRakuThread::RakuRakuThread(EGG::Heap* heap) : utility::ut_thread() {
@@ -101,12 +101,12 @@ RakuRakuThread::RakuRakuThread(EGG::Heap* heap) : utility::ut_thread() {
active = false;
mFinished = 0;
mRunning = 0;
OSInitMessageQueue(&sRakuMsgQueue, &messageSlot, 1);
OSInitMessageQueue(&RakuRakuThread_810BDED4, &messageSlot, 1);
}
RakuRakuThread::~RakuRakuThread() {
if (mRunning) {
OSJamMessage(&sRakuMsgQueue, (OSMessage)2, 1);
OSJamMessage(&RakuRakuThread_810BDED4, (OSMessage)2, 1);
WaitForThreadExit();
}
destroy();
@@ -114,7 +114,7 @@ RakuRakuThread::~RakuRakuThread() {
void RakuRakuThread::destroy() {
if (active) {
OSSendMessage(&sRakuMsgQueue, (OSMessage)1, 0);
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
u32 start = OSGetTick();
while ((u32)(OSGetTick() - start) / (OS_TIMER_CLOCK / 1000) < 2000) {
RakuProgress progress;
@@ -127,7 +127,7 @@ void RakuRakuThread::destroy() {
}
if (mHeap != NULL) {
MEMDestroyExpHeap(mHeap);
memset(&sRakuAllocator, 0, sizeof(MEMAllocator));
memset(&RakuRakuThread_810BDDD0, 0, sizeof(MEMAllocator));
mHeap = NULL;
}
}
@@ -139,19 +139,19 @@ int RakuRakuThread::start() {
BOOL interrupts = OSDisableInterrupts();
startTime = OSGetTime();
mHeap = MEMCreateExpHeapEx(mHeapBuffer, 0x40000, 2);
MEMInitAllocatorForExpHeap(&sRakuAllocator, mHeap, 32);
MEMInitAllocatorForExpHeap(&RakuRakuThread_810BDDD0, mHeap, 32);
mPriority = OSGetThreadPriority(OSGetCurrentThread()) - 1;
active = true;
mFinished = 0;
memset(&sRakuStatus.configuration, 0, sizeof(RakuConfiguration));
memset(&sRakuStatus.progress, 0, sizeof(RakuProgress));
memset(&RakuRakuThread_810BDDE0.configuration, 0, sizeof(RakuConfiguration));
memset(&RakuRakuThread_810BDDE0.progress, 0, sizeof(RakuProgress));
SOLibraryConfig socketConfig;
socketConfig.alloc = RakuSocketAlloc;
socketConfig.free = RakuSocketFree;
socketConfig.alloc = RakuRakuThread_813FDEF0;
socketConfig.free = RakuRakuThread_813FDEFC;
SOInit(&socketConfig);
ATERMi_ApConfigStart(mPriority, 200,
progressCallback,
RakuAtermAlloc, RakuAtermFree, 4096);
RakuRakuThread_813FDF08, RakuRakuThread_813FDF18, 4096);
if (!mRunning) {
mRunning = 1;
memset(mStack, 0, 4);
@@ -165,12 +165,12 @@ int RakuRakuThread::start() {
void* RakuRakuThread::Run() {
OSMessage message;
while (true) {
while (OSReceiveMessage(&sRakuMsgQueue, &message, 0)) {
while (OSReceiveMessage(&RakuRakuThread_810BDED4, &message, 0)) {
if ((s32)message == 2) {
return this;
}
}
OSReceiveMessage(&sRakuMsgQueue, &message, 1);
OSReceiveMessage(&RakuRakuThread_810BDED4, &message, 1);
if ((s32)message == 2) {
break;
}
@@ -184,17 +184,17 @@ void* RakuRakuThread::Run() {
return this;
}
static void* RakuSocketAlloc(u32, s32 size) {
return MEMAllocFromAllocator(&sRakuAllocator, size);
static void* RakuRakuThread_813FDEF0(u32, s32 size) {
return MEMAllocFromAllocator(&RakuRakuThread_810BDDD0, size);
}
static void RakuSocketFree(u32, void* block, s32) {
MEMFreeToAllocator(&sRakuAllocator, block);
static void RakuRakuThread_813FDEFC(u32, void* block, s32) {
MEMFreeToAllocator(&RakuRakuThread_810BDDD0, block);
}
static void* RakuAtermAlloc(u32 size) {
return MEMAllocFromAllocator(&sRakuAllocator, size);
static void* RakuRakuThread_813FDF08(u32 size) {
return MEMAllocFromAllocator(&RakuRakuThread_810BDDD0, size);
}
static void RakuAtermFree(void* block) {
MEMFreeToAllocator(&sRakuAllocator, block);
static void RakuRakuThread_813FDF18(void* block) {
MEMFreeToAllocator(&RakuRakuThread_810BDDD0, block);
}
int RakuRakuThread::getState() {
@@ -202,7 +202,7 @@ int RakuRakuThread::getState() {
return 0;
}
BOOL interrupts = OSDisableInterrupts();
switch (sRakuStatus.progress.state) {
switch (RakuRakuThread_810BDDE0.progress.state) {
case 1: displayState = 1; break;
case 2: displayState = 2; break;
case 3: displayState = 2; break;
@@ -214,14 +214,14 @@ int RakuRakuThread::getState() {
}
if (displayState != 6 && displayState != 7 &&
((u32)OSGetTime() - (u32)startTime) / (OS_TIMER_CLOCK / 1000) >= 90000) {
OSSendMessage(&sRakuMsgQueue, (OSMessage)1, 0);
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
}
OSRestoreInterrupts(interrupts);
return displayState;
}
int RakuRakuThread::cancel() {
return OSSendMessage(&sRakuMsgQueue, (OSMessage)1, 0);
return OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
}
int RakuRakuThread::finish(NCDApConfig* config, int* result) {
@@ -231,23 +231,23 @@ int RakuRakuThread::finish(NCDApConfig* config, int* result) {
}
return 1;
}
s32 state = sRakuStatus.progress.state;
s32 state = RakuRakuThread_810BDDE0.progress.state;
if ((u32)(state - 6) > 1) {
return 0;
}
if (!mFinished) {
if (state == 6) {
ATERMi_ApConfigGetResult(&sRakuStatus.configuration);
ATERMi_ApConfigGetResult(&RakuRakuThread_810BDDE0.configuration);
printInfo();
}
OSSendMessage(&sRakuMsgQueue, (OSMessage)1, 0);
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
return 0;
}
SOFinish();
active = false;
destroy();
if (config != NULL) {
RakuConfiguration* settings = &sRakuStatus.configuration;
RakuConfiguration* settings = &RakuRakuThread_810BDDE0.configuration;
memcpy(config->ssid, settings->ssid, 32);
config->ssidLength = strlen(settings->ssid);
if (settings->security == 1) {
@@ -273,7 +273,7 @@ int RakuRakuThread::finish(NCDApConfig* config, int* result) {
}
}
if (result != NULL) {
*result = sRakuStatus.progress.result;
*result = RakuRakuThread_810BDDE0.progress.result;
}
return 1;
}

View File

@@ -1,213 +0,0 @@
"""Compare relocated switch destinations after checking instructions with ctxdiff.
Usage: python jump_table_diff.py <unit> <function> [--table <reference-symbol>]
Paths follow ctxdiff.py: build/43U/{src,obj}/<unit>.o. Requires pyelftools.
Exit 0: all selected tables match (or no tables); 1: mismatch; 2: invalid or
ambiguous input. This checks relative destinations, not behavioral equivalence.
Automatic selection covers local jumptable_* symbols whose R_PPC_ADDR32 entries
all target the selected function. External callback tables/vtables are not
covered. Source locations are inferred from corresponding function relocations,
never from an assumption that both data sections have the same layout.
"""
import argparse
from dataclasses import dataclass
from pathlib import Path
import sys
from elftools.common.exceptions import ELFError
from elftools.elf.elffile import ELFFile
@dataclass(frozen=True)
class Symbol:
name: str
section: object
value: int
size: int
kind: str = "STT_OBJECT"
@dataclass(frozen=True)
class Relocation:
offset: int
kind: int
symbol: int
addend: int
@dataclass
class ObjectInfo:
sections: dict
symbols: list
relocations: dict
def symbol(self, name):
found = [s for s in self.symbols if s.name == name
and isinstance(s.section, int) and s.size]
if len(found) != 1:
raise ValueError("expected one defined symbol: " + name)
symbol = found[0]
if (symbol.section not in self.sections or symbol.value < 0
or symbol.size <= 0
or symbol.value + symbol.size > self.sections[symbol.section][1]):
raise ValueError("symbol is outside its section: " + name)
return symbol
def location(self, relocation):
if not 0 <= relocation.symbol < len(self.symbols):
raise ValueError("relocation symbol index is out of range")
symbol = self.symbols[relocation.symbol]
if not isinstance(symbol.section, int):
return None
if symbol.section not in self.sections:
raise ValueError("relocation symbol has an invalid section")
return symbol.section, symbol.value + relocation.addend
def relocs(self, section):
return self.relocations.get(section, {})
def read_object(path):
with open(path, "rb") as stream:
elf = ELFFile(stream)
if (elf.elfclass != 32 or elf.little_endian
or elf["e_machine"] != "EM_PPC" or elf["e_type"] != "ET_REL"):
raise ValueError("expected a relocatable big-endian ELF32 PowerPC object")
symtab = elf.get_section_by_name(".symtab")
if symtab is None:
raise ValueError("object has no .symtab")
symbols = [Symbol(s.name, s["st_shndx"], s["st_value"], s["st_size"],
s["st_info"]["type"]) for s in symtab.iter_symbols()]
sections = {}
relocations = {}
for index, section in enumerate(elf.iter_sections()):
sections[index] = (section.name, section["sh_size"])
if section["sh_type"] == "SHT_REL":
raise ValueError("REL relocations are unsupported; expected RELA")
if section["sh_type"] != "SHT_RELA":
continue
if elf.get_section(section["sh_link"]).name != ".symtab":
raise ValueError("relocation uses a different symbol table")
entries = relocations.setdefault(section["sh_info"], {})
for r in section.iter_relocations():
if r["r_offset"] in entries:
raise ValueError("multiple relocations at the same offset")
entries[r["r_offset"]] = Relocation(
r["r_offset"], r["r_info_type"], r["r_info_sym"], r["r_addend"])
return ObjectInfo(sections, symbols, relocations)
def jump_target(obj, relocation, function):
if relocation is None or relocation.kind != 1: # R_PPC_ADDR32
return None
location = obj.location(relocation)
if location is None or location[0] != function.section:
return None
offset = location[1] - function.value
if offset < 0 or offset >= function.size or offset % 4:
return None
return offset
def reference_tables(obj, function, name=None):
candidates = [obj.symbol(name)] if name else [
s for s in obj.symbols if s.name.startswith("jumptable_") and s.size]
result = []
for table in candidates:
if not isinstance(table.section, int) or table.size % 4:
if name:
raise ValueError("invalid reference table extent")
continue
section_size = obj.sections[table.section][1]
if table.value < 0 or table.value + table.size > section_size:
raise ValueError("reference table is outside its section")
targets = [jump_target(obj, obj.relocs(table.section).get(offset), function)
for offset in range(table.value, table.value + table.size, 4)]
if targets and all(target is not None for target in targets):
result.append((table, targets))
elif name:
raise ValueError("reference table does not target the selected function")
return result
def source_table_location(source, reference, source_fn, reference_fn, table):
if source_fn.size != reference_fn.size:
raise ValueError("function sizes differ; check ctxdiff before table matching")
locations = set()
for relocation in reference.relocs(reference_fn.section).values():
if not reference_fn.value <= relocation.offset < reference_fn.value + reference_fn.size:
continue
if reference.location(relocation) != (table.section, table.value):
continue
offset = source_fn.value + relocation.offset - reference_fn.value
other = source.relocs(source_fn.section).get(offset)
if other is None or other.kind != relocation.kind:
raise ValueError("table-reference relocations differ; check ctxdiff")
location = source.location(other)
if location is None:
raise ValueError("source table reference is undefined")
if source.sections[location[0]][0] != reference.sections[table.section][0]:
raise ValueError("source table resolves to a different section")
locations.add(location)
if len(locations) != 1:
raise ValueError("cannot infer one source table from function relocations")
section, offset = next(iter(locations))
sizes = {s.size for s in source.symbols if s.section == section
and s.value == offset and s.size and s.kind != "STT_SECTION"}
if len(sizes) != 1:
raise ValueError("source table extent is missing or ambiguous")
size = next(iter(sizes))
if size % 4 or offset < 0 or offset + size > source.sections[section][1]:
raise ValueError("invalid source table extent")
return section, offset, size
def compare_table(source, reference, source_fn, reference_fn, table, expected):
section, offset, size = source_table_location(
source, reference, source_fn, reference_fn, table)
actual = [jump_target(source, source.relocs(section).get(i), source_fn)
for i in range(offset, offset + size, 4)]
differences = []
for i in range(max(len(actual), len(expected))):
src = actual[i] if i < len(actual) else None
ref = expected[i] if i < len(expected) else None
if i >= min(len(actual), len(expected)) or src != ref:
differences.append((i, src, ref))
return actual, differences
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("unit", help="e.g. src/scene/sdChannelSelect/iplSDChannelSelect")
parser.add_argument("function", help="exact function symbol used by ctxdiff")
parser.add_argument("--table", help="optional exact reference jump-table symbol")
args = parser.parse_args(argv)
try:
source = read_object(Path("build/43U/src") / (args.unit + ".o"))
reference = read_object(Path("build/43U/obj") / (args.unit + ".o"))
source_fn = source.symbol(args.function)
reference_fn = reference.symbol(args.function)
tables = reference_tables(reference, reference_fn, args.table)
mismatch = False
for table, expected in tables:
actual, differences = compare_table(
source, reference, source_fn, reference_fn, table, expected)
matched = sum(a == b for a, b in zip(actual, expected))
print("%s: %d/%d entries match (source=%d reference=%d)" %
(table.name, matched, len(expected), len(actual), len(expected)))
for index, src, ref in differences:
src_text = "unresolved/missing" if src is None else "+0x%X" % src
ref_text = "missing" if ref is None else "+0x%X" % ref
print(" [%d] source %s; reference %s" % (index, src_text, ref_text))
mismatch |= bool(differences)
print("Compared %d jump table(s); instruction correctness requires ctxdiff." % len(tables))
return 1 if mismatch else 0
except (OSError, ValueError, ELFError) as error:
print("ERROR: %s" % error, file=sys.stderr)
return 2
if __name__ == "__main__":
sys.exit(main())

View File

@@ -1,159 +0,0 @@
import contextlib
from dataclasses import replace
import io
import unittest
from unittest.mock import patch
import jump_table_diff as tool
def fixture(entries=(0x10, 0x20, 0x30), function_offset=0x100,
table_offset=0x40, source=False, section_ids=(1, 2)):
text, data = section_ids
symbols = [
tool.Symbol("dispatch", text, function_offset, 0x80, "STT_FUNC"),
tool.Symbol("@123" if source else "jumptable_test", data,
table_offset, len(entries) * 4),
]
references = {
text: {
function_offset + 2: tool.Relocation(function_offset + 2, 6, 1, 0),
function_offset + 6: tool.Relocation(function_offset + 6, 4, 1, 0),
},
data: {table_offset + i * 4: tool.Relocation(table_offset + i * 4, 1, 0, value)
for i, value in enumerate(entries)},
}
return tool.ObjectInfo({text: (".text", 0x1000), data: (".data", 0x1000)},
symbols, references)
def compare(source, reference=None):
reference = reference or fixture()
src_fn = source.symbol("dispatch")
ref_fn = reference.symbol("dispatch")
table, expected = tool.reference_tables(reference, ref_fn, "jumptable_test")[0]
return tool.compare_table(source, reference, src_fn, ref_fn, table, expected)
class JumpTableTests(unittest.TestCase):
def test_infers_shifted_source_table_and_function(self):
source = fixture(source=True, function_offset=0x200, table_offset=0x90,
section_ids=(3, 4))
self.assertEqual(compare(source), ([0x10, 0x20, 0x30], []))
def test_detects_swapped_destinations_despite_same_function_size(self):
actual, differences = compare(fixture((0x20, 0x10, 0x30), source=True))
self.assertEqual(actual, [0x20, 0x10, 0x30])
self.assertEqual(differences, [(0, 0x20, 0x10), (1, 0x10, 0x20)])
def test_section_relative_code_reference(self):
source = fixture(source=True, table_offset=0x90)
source.symbols.append(tool.Symbol("", 2, 0, 0, "STT_SECTION"))
for offset, relocation in list(source.relocations[1].items()):
source.relocations[1][offset] = replace(relocation, symbol=2, addend=0x90)
self.assertEqual(compare(source)[1], [])
def test_section_relative_table_entries(self):
source = fixture(source=True)
source.symbols.append(tool.Symbol("", 1, 0, 0, "STT_SECTION"))
for offset, relocation in list(source.relocations[2].items()):
source.relocations[2][offset] = replace(
relocation, symbol=2, addend=0x100 + relocation.addend)
self.assertEqual(compare(source)[1], [])
def test_missing_entry_is_mismatch(self):
source = fixture(source=True)
del source.relocations[2][0x44]
self.assertEqual(compare(source)[1], [(1, None, 0x20)])
def test_wrong_relocation_kind_is_mismatch(self):
source = fixture(source=True)
source.relocations[2][0x44] = replace(source.relocations[2][0x44], kind=10)
self.assertEqual(compare(source)[1], [(1, None, 0x20)])
def test_out_of_function_destination_is_mismatch(self):
source = fixture(source=True)
source.relocations[2][0x44] = replace(source.relocations[2][0x44], addend=0x80)
self.assertEqual(compare(source)[1], [(1, None, 0x20)])
def test_extra_source_entry_is_not_a_pass(self):
self.assertEqual(compare(fixture((0x10, 0x20, 0x30, 0x40), source=True))[1],
[(3, 0x40, None)])
def test_short_source_table_is_not_a_pass(self):
self.assertEqual(compare(fixture((0x10, 0x20), source=True))[1],
[(2, None, 0x30)])
def test_different_function_sizes_reject_inference(self):
source = fixture(source=True)
source.symbols[0] = replace(source.symbols[0], size=0x84)
with self.assertRaisesRegex(ValueError, "function sizes differ"):
compare(source)
def test_disagreeing_code_references_reject_inference(self):
source = fixture(source=True)
source.relocations[1][0x106] = replace(source.relocations[1][0x106], addend=4)
with self.assertRaisesRegex(ValueError, "infer one source table"):
compare(source)
def test_missing_code_reference_rejects_inference(self):
source = fixture(source=True)
del source.relocations[1][0x106]
with self.assertRaisesRegex(ValueError, "table-reference relocations differ"):
compare(source)
def test_ambiguous_source_extent_rejects_inference(self):
source = fixture(source=True)
source.symbols.append(tool.Symbol("alias", 2, 0x40, 16))
with self.assertRaisesRegex(ValueError, "extent is missing or ambiguous"):
compare(source)
def test_different_source_section_rejects_inference(self):
source = fixture(source=True)
source.sections[2] = (".rodata", 0x1000)
with self.assertRaisesRegex(ValueError, "different section"):
compare(source)
def test_undefined_source_reference_rejects_inference(self):
source = fixture(source=True)
source.symbols[1] = replace(source.symbols[1], section="SHN_UNDEF")
with self.assertRaisesRegex(ValueError, "reference is undefined"):
compare(source)
def test_invalid_relocation_symbol_rejected(self):
source = fixture(source=True)
source.relocations[2][0x44] = replace(source.relocations[2][0x44], symbol=999)
with self.assertRaisesRegex(ValueError, "symbol index is out of range"):
compare(source)
def test_duplicate_function_rejected(self):
source = fixture(source=True)
source.symbols.append(source.symbols[0])
with self.assertRaisesRegex(ValueError, "one defined symbol"):
compare(source)
def test_out_of_section_symbol_rejected(self):
source = fixture(source=True)
source.symbols[0] = replace(source.symbols[0], size=0x2000)
with self.assertRaisesRegex(ValueError, "outside its section"):
compare(source)
def test_unrelated_reference_table_is_not_selected(self):
reference = fixture((0x80, 0x84, 0x88))
self.assertEqual(tool.reference_tables(reference, reference.symbol("dispatch")), [])
with self.assertRaisesRegex(ValueError, "does not target"):
tool.reference_tables(reference, reference.symbol("dispatch"), "jumptable_test")
def test_cli_exit_codes(self):
for source, expected_status in [(fixture(source=True), 0),
(fixture((0x20, 0x10, 0x30), source=True), 1)]:
with patch.object(tool, "read_object", side_effect=[source, fixture()]):
with contextlib.redirect_stdout(io.StringIO()):
self.assertEqual(tool.main(["unused", "dispatch"]), expected_status)
with patch.object(tool, "read_object", side_effect=ValueError("bad object")):
with contextlib.redirect_stderr(io.StringIO()):
self.assertEqual(tool.main(["unused", "dispatch"]), 2)
if __name__ == "__main__":
unittest.main()