Untitled
unknown
c_cpp
a year ago
15 kB
24
Indexable
undefined4 __thiscall BMD::LoadBMD(BMD *this,CHAR *folder,char *fileName,char param_3)
{
short sVar1;
longlong lVar2;
char cVar3;
undefined4 uVar4;
FILE *_File;
BYTE *itemTempVar;
undefined4 *puVar5;
int iVar6;
uint uVar7;
void *pvVar8;
undefined LEA_KEY [772];
char local_170 [64];
undefined4 local_130;
void *idk;
void *local_128;
undefined4 local_124;
undefined4 local_120;
undefined4 local_11c;
undefined4 local_118;
undefined4 local_114;
undefined4 local_110;
int local_10c;
undefined4 local_108;
undefined4 local_104;
undefined4 local_100;
undefined4 local_fc;
undefined4 local_f8;
int numMeshsBuffer;
BYTE *local_f0;
BYTE *local_ec;
BYTE *local_e8;
BYTE *actionsBuffer;
BYTE *bonesBuffer;
BYTE *local_dc;
void *local_d8;
void *decryptedBuffer;
void *local_d0;
void *local_cc;
undefined4 local_c8;
void *local_c4;
void *local_c0;
undefined local_bc [8];
void *local_b4;
undefined4 local_b0;
void *local_ac;
int local_a8;
uint local_a4;
uint local_a0;
uint local_9c;
uint actionsCount;
uint bonesCount;
BYTE *local_90;
uint local_8c;
uint meshsCount;
void *local_84;
undefined4 decryptedSize;
void *local_7c;
undefined4 local_78;
undefined4 local_74;
size_t LENGHT;
BYTE *meshsBuffer;
byte mk [32];
int local_44;
int local_40;
int x;
int i;
void *encryptedBuffer;
int readOffset;
void *local_10;
undefined *puStack_c;
undefined4 local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_01a28514;
local_10 = ExceptionList;
if (param_3 == 1) {
ExceptionList = &local_10;
FUN_013df841();
FUN_0199d8d0(local_170,folder);
FUN_0199d8e0(local_170,fileName);
_File = _fopen(local_170,"rb");
if (_File == (FILE *)0x0) {
uVar4 = 0;
}
else {
_fseek(_File,0,2);
LENGHT = len(_File);
_fseek(_File,0,0);
encryptedBuffer = (void *)malloc(LENGHT);
idk = encryptedBuffer;
_fread(encryptedBuffer,1,LENGHT,_File);
_fclose(_File);
this->Version = *(BYTE *)((int)encryptedBuffer + 3);
readOffset = 4;
if (this->Version == 12) {
local_74 = *(undefined4 *)((int)encryptedBuffer + 4);
local_130 = FUN_00997e52(0,(int)encryptedBuffer + 8,local_74);
local_c0 = (void *)malloc(local_130);
local_b4 = local_c0;
FUN_00997e52(local_c0,(int)encryptedBuffer + 8,local_74);
local_c4 = encryptedBuffer;
FID_conflict:_free(encryptedBuffer);
encryptedBuffer = local_b4;
readOffset = 0;
}
else if (this->Version == 14) {
local_78 = *(undefined4 *)((int)encryptedBuffer + 4);
local_c8 = FUN_017711fa(0,(int)encryptedBuffer + 8,local_78);
local_cc = (void *)malloc(local_c8);
local_7c = local_cc;
FUN_017711fa(local_cc,(int)encryptedBuffer + 8,local_78);
local_d0 = encryptedBuffer;
FID_conflict:_free(encryptedBuffer);
encryptedBuffer = local_7c;
readOffset = 0;
}
else if (this->Version == 15) {
mk[0] = 0xcc;
mk[1] = 0x50;
mk[2] = 0x45;
mk[3] = 0x13;
mk[4] = 0xc2;
mk[5] = 0xa6;
mk[6] = 0x57;
mk[7] = 0x4e;
mk[8] = 0xd6;
mk[9] = 0x9a;
mk[10] = 0x45;
mk[0xb] = 0x89;
mk[0xc] = 0xbf;
mk[0xd] = 0x2f;
mk[0xe] = 0xbc;
mk[0xf] = 0xd9;
mk[0x10] = 0x39;
mk[0x11] = 0xb3;
mk[0x12] = 0xb3;
mk[0x13] = 0xbd;
mk[0x14] = 0x50;
mk[0x15] = 0xbd;
mk[0x16] = 0xcc;
mk[0x17] = 0xb6;
mk[0x18] = 0x85;
mk[0x19] = 0x46;
mk[0x1a] = 0xd1;
mk[0x1b] = 0xd6;
mk[0x1c] = 0x16;
mk[0x1d] = 0x54;
mk[0x1e] = 0xe0;
mk[0x1f] = 0x87;
LEA_roundkeyGen(LEA_KEY,mk,0x20);
decryptedSize = *(undefined4 *)((int)encryptedBuffer + 4);
decryptedBuffer = (void *)malloc(decryptedSize);
local_84 = decryptedBuffer;
DecryptWIthLea(decryptedBuffer,(int)encryptedBuffer + 8,decryptedSize,LEA_KEY);
if (encryptedBuffer != (void *)0x0) {
local_d8 = encryptedBuffer;
FID_conflict:_free(encryptedBuffer);
}
encryptedBuffer = local_84;
readOffset = 0;
}
memcpy(this,(int)encryptedBuffer + readOffset,32);
this->NumMeshs = *(short *)((int)encryptedBuffer + readOffset + 0x20);
this->NumBones = *(short *)((int)encryptedBuffer + readOffset + 0x22);
this->NumActions = *(short *)((int)encryptedBuffer + readOffset + 0x24);
readOffset = readOffset + 38;
if (this->NumMeshs < 1) {
meshsCount = 1;
}
else {
meshsCount = (uint)this->NumMeshs;
}
local_8c = meshsCount;
meshsBuffer = (BYTE *)malloc(-(uint)((int)((ulonglong)meshsCount * 32 >> 0x20) != 0) |
(uint)((ulonglong)meshsCount * 32));
local_8 = 0;
if (meshsBuffer == (BYTE *)0x0) {
local_90 = (BYTE *)0x0;
}
else {
FUN_009915cb(meshsBuffer,0x20,local_8c,FUN_011567c9);
local_90 = meshsBuffer;
}
local_dc = local_90;
local_8 = 0xffffffff;
this->Meshs = local_90;
if (this->NumBones < 1) {
bonesCount = 1;
}
else {
bonesCount = (uint)this->NumBones;
}
bonesBuffer = (BYTE *)malloc(-(uint)((int)((ulonglong)bonesCount * 140 >> 0x20) != 0) |
(uint)((ulonglong)bonesCount * 140));
this->Bones = bonesBuffer;
if (this->NumActions < 1) {
actionsCount = 1;
}
else {
actionsCount = (uint)this->NumActions;
}
actionsBuffer =
(BYTE *)malloc(-(uint)((int)((ulonglong)actionsCount * 16 >> 0x20) != 0) |
(uint)((ulonglong)actionsCount * 16));
this->Actions = actionsBuffer;
if (this->NumMeshs < 1) {
local_9c = 1;
}
else {
local_9c = (uint)this->NumMeshs;
}
local_e8 = (BYTE *)malloc(-(uint)((int)((ulonglong)local_9c * 32 >> 0x20) != 0) |
(uint)((ulonglong)local_9c * 32));
this->ptr1 = local_e8;
if (this->NumMeshs < 1) {
local_a0 = 1;
}
else {
local_a0 = (uint)this->NumMeshs;
}
local_ec = (BYTE *)malloc(-(uint)((int)((ulonglong)local_a0 * 4 >> 0x20) != 0) |
(uint)((ulonglong)local_a0 * 4));
this->ptr2 = local_ec;
if (this->NumMeshs < 1) {
local_a4 = 1;
}
else {
local_a4 = (uint)this->NumMeshs;
}
local_f0 = (BYTE *)malloc(-(uint)((int)((ulonglong)local_a4 * 4 >> 0x20) != 0) |
(uint)((ulonglong)local_a4 * 4));
this->ptr3 = local_f0;
this->field12_0x40 = 0;
if (this->NumMeshs < 1) {
local_a8 = 1;
}
else {
local_a8 = (int)this->NumMeshs;
}
numMeshsBuffer = local_a8;
local_f8 = 0;
/* this basically is zeroing the entire object
*/
FUN_0115674d(this->ptr3,&local_f8,&numMeshsBuffer);
for (i = 0; i < this->NumMeshs; i = i + 1) {
itemTempVar = this->Meshs + i * 0x20;
*(undefined2 *)(itemTempVar + 4) = *(undefined2 *)((int)encryptedBuffer + readOffset);
*(undefined2 *)(itemTempVar + 6) = *(undefined2 *)((int)encryptedBuffer + readOffset + 2);
*(undefined2 *)(itemTempVar + 8) = *(undefined2 *)((int)encryptedBuffer + readOffset + 4);
*(undefined2 *)(itemTempVar + 10) = *(undefined2 *)((int)encryptedBuffer + readOffset + 6);
*(undefined2 *)(itemTempVar + 2) = *(undefined2 *)((int)encryptedBuffer + readOffset + 8);
*itemTempVar = 0;
local_fc = malloc(-(uint)((int)((ulonglong)(uint)(int)*(short *)(itemTempVar + 4) * 0x10 >>
0x20) != 0) |
(uint)((ulonglong)(uint)(int)*(short *)(itemTempVar + 4) * 0x10));
*(undefined4 *)(itemTempVar + 0xc) = local_fc;
local_100 = malloc(-(uint)((int)((ulonglong)(uint)(int)*(short *)(itemTempVar + 6) * 0x14 >>
0x20) != 0) |
(uint)((ulonglong)(uint)(int)*(short *)(itemTempVar + 6) * 0x14));
*(undefined4 *)(itemTempVar + 0x10) = local_100;
local_104 = malloc(-(uint)((int)((ulonglong)(uint)(int)*(short *)(itemTempVar + 8) * 8 >>
0x20) != 0) |
(uint)((ulonglong)(uint)(int)*(short *)(itemTempVar + 8) * 8));
*(undefined4 *)(itemTempVar + 0x14) = local_104;
local_108 = malloc(-(uint)((int)((ulonglong)(uint)(int)*(short *)(itemTempVar + 10) * 0x24
>> 0x20) != 0) |
(uint)((ulonglong)(uint)(int)*(short *)(itemTempVar + 10) * 0x24));
*(undefined4 *)(itemTempVar + 0x18) = local_108;
sVar1 = *(short *)(itemTempVar + 4);
memcpy(*(undefined4 *)(itemTempVar + 0xc),(int)encryptedBuffer + readOffset + 10,
sVar1 * 0x10);
readOffset = readOffset + 10 + sVar1 * 0x10;
sVar1 = *(short *)(itemTempVar + 6);
memcpy(*(undefined4 *)(itemTempVar + 0x10),(int)encryptedBuffer + readOffset,sVar1 * 0x14);
readOffset = readOffset + sVar1 * 0x14;
sVar1 = *(short *)(itemTempVar + 8);
memcpy(*(undefined4 *)(itemTempVar + 0x14),(int)encryptedBuffer + readOffset,sVar1 * 8);
readOffset = readOffset + sVar1 * 8;
local_10c = 0x40;
for (local_44 = 0; local_44 < *(short *)(itemTempVar + 10); local_44 = local_44 + 1) {
memcpy(local_44 * 0x24 + *(int *)(itemTempVar + 0x18),(int)encryptedBuffer + readOffset,
0x24);
readOffset = readOffset + local_10c;
}
memcpy(this->ptr1 + i * 0x20,(int)encryptedBuffer + readOffset,0x20);
readOffset = readOffset + 0x20;
FUN_011567ac();
local_8 = 1;
cVar3 = FUN_012a4ea8(this->ptr1 + i * 0x20);
if (cVar3 == '\0') {
*(undefined4 *)(itemTempVar + 0x1c) = 0;
}
else {
local_ac = operator_new(5);
local_8._0_1_ = 2;
if (local_ac == (void *)0x0) {
local_b0 = 0;
}
else {
local_b0 = FUN_0115677c();
}
local_110 = local_b0;
local_8 = CONCAT31(local_8._1_3_,1);
*(undefined4 *)(itemTempVar + 0x1c) = local_b0;
FUN_012a4e61(local_bc);
}
local_8 = 0xffffffff;
FUN_01156838();
}
for (i = 0; i < this->NumActions; i = i + 1) {
itemTempVar = this->Actions + i * 16;
*itemTempVar = '\0';
*(undefined2 *)(itemTempVar + 8) = *(undefined2 *)((int)encryptedBuffer + readOffset);
itemTempVar[10] = *(BYTE *)((int)encryptedBuffer + readOffset + 2);
readOffset = readOffset + 3;
if (itemTempVar[10] == '\0') {
*(undefined4 *)(itemTempVar + 0xc) = 0;
}
else {
lVar2 = (ulonglong)
(-(uint)((int)((ulonglong)(uint)(int)*(short *)(itemTempVar + 8) * 3 >> 0x20) != 0
) | (uint)((ulonglong)(uint)(int)*(short *)(itemTempVar + 8) * 3)) * 4;
local_114 = malloc(-(uint)((int)((ulonglong)lVar2 >> 0x20) != 0) | (uint)lVar2);
*(undefined4 *)(itemTempVar + 0xc) = local_114;
sVar1 = *(short *)(itemTempVar + 8);
memcpy(*(undefined4 *)(itemTempVar + 0xc),(int)encryptedBuffer + readOffset,sVar1 * 0xc);
readOffset = readOffset + sVar1 * 0xc;
}
}
for (i = 0; i < this->NumBones; i = i + 1) {
itemTempVar = this->Bones + i * 140;
itemTempVar[0x22] = *(BYTE *)((int)encryptedBuffer + readOffset);
iVar6 = readOffset + 1;
if (itemTempVar[0x22] == '\0') {
memcpy(itemTempVar,(int)encryptedBuffer + readOffset + 1,0x20);
*(undefined2 *)(itemTempVar + 0x20) =
*(undefined2 *)((int)encryptedBuffer + readOffset + 0x21);
readOffset = readOffset + 0x23;
lVar2 = (ulonglong)(uint)(int)this->NumActions * 0xc;
local_118 = malloc(-(uint)((int)((ulonglong)lVar2 >> 0x20) != 0) | (uint)lVar2);
*(undefined4 *)(itemTempVar + 0x24) = local_118;
for (x = 0; iVar6 = readOffset, x < this->NumActions; x = x + 1) {
puVar5 = (undefined4 *)(x * 0xc + *(int *)(itemTempVar + 0x24));
iVar6 = *(short *)(this->Actions + x * 0x10 + 8) * 0xc;
uVar7 = (uint)*(short *)(this->Actions + x * 0x10 + 8);
lVar2 = (ulonglong)
(-(uint)((int)((ulonglong)uVar7 * 3 >> 0x20) != 0) |
(uint)((ulonglong)uVar7 * 3)) * 4;
local_11c = malloc(-(uint)((int)((ulonglong)lVar2 >> 0x20) != 0) | (uint)lVar2);
*puVar5 = local_11c;
lVar2 = (ulonglong)
(-(uint)((int)((ulonglong)uVar7 * 3 >> 0x20) != 0) |
(uint)((ulonglong)uVar7 * 3)) * 4;
local_120 = malloc(-(uint)((int)((ulonglong)lVar2 >> 0x20) != 0) | (uint)lVar2);
puVar5[1] = local_120;
lVar2 = (ulonglong)
(-(uint)((int)((ulonglong)uVar7 * 4 >> 0x20) != 0) |
(uint)((ulonglong)uVar7 * 4)) * 4;
local_124 = malloc(-(uint)((int)((ulonglong)lVar2 >> 0x20) != 0) | (uint)lVar2);
puVar5[2] = local_124;
memcpy(*puVar5,(int)encryptedBuffer + readOffset,iVar6);
memcpy(puVar5[1],(int)encryptedBuffer + readOffset + iVar6,iVar6);
readOffset = readOffset + iVar6 + iVar6;
for (local_40 = 0; local_40 < (int)uVar7; local_40 = local_40 + 1) {
FUN_00d8899c(local_40 * 0xc + puVar5[1],local_40 * 0x10 + puVar5[2]);
}
}
}
readOffset = iVar6;
}
local_128 = encryptedBuffer;
FID_conflict:_free(encryptedBuffer);
FUN_013de12a(0);
pvVar8 = _memset(this->field82_0xb6,-1,20);
uVar4 = CONCAT31((int3)((uint)pvVar8 >> 8),1);
}
}
else {
uVar4 = 1;
}
ExceptionList = local_10;
return uVar4;
}
Editor is loading...
Leave a Comment