Skip to content

Instantly share code, notes, and snippets.

@goaaats
Last active June 3, 2019 16:40
Show Gist options
  • Save goaaats/9ee30362c70c7d87cb4de5db6507f329 to your computer and use it in GitHub Desktop.
Save goaaats/9ee30362c70c7d87cb4de5db6507f329 to your computer and use it in GitHub Desktop.
/*
--- for reference: 4.58 ---
.text:00000001406443D0 ; =============== S U B R O U T I N E =======================================
.text:00000001406443D0
.text:00000001406443D0
.text:00000001406443D0 ; __int64 __fastcall PopulateItemLinkObject(__int64 linkObject, itemInfoStructure *itemStructure)
.text:00000001406443D0 PopulateItemLinkObject proc near ; CODE XREF: sub_140203D00+5AE↑p
.text:00000001406443D0 ; sub_140203D00+77E↑p ...
.text:00000001406443D0
.text:00000001406443D0 arg_0 = qword ptr 8
.text:00000001406443D0
.text:00000001406443D0 mov [rsp+arg_0], rbx
.text:00000001406443D5 push rdi
.text:00000001406443D6 sub rsp, 20h
.text:00000001406443DA cmp byte ptr [rdx+6], 0
.text:00000001406443DE mov rbx, rdx
.text:00000001406443E1 mov rdi, rcx
.text:00000001406443E4 jz short loc_1406443FA
.text:00000001406443E6 mov rcx, rdx
.text:00000001406443E9 call sub_140644720
.text:00000001406443EE mov rcx, rax
.text:00000001406443F1 call sub_140160880
.text:00000001406443F6 mov ecx, eax
.text:00000001406443F8 jmp short loc_140644417
*/
__int64 __fastcall PopulateItemLinkObject(__int64 linkObject, itemInfoStructure *itemStructure)
{
itemInfoStructure *thisItemInfoStructure; // rbx
__int64 thisLinkObject; // rdi
signed __int64 v4; // rax
int thisItemId; // ecx
char itemFlags; // al
bool v7; // zf
signed __int64 v8; // rax
__int64 v9; // rax
signed __int64 v10; // rax
__int16 v11; // ax
signed __int64 v12; // rax
__int16 v13; // ax
signed __int64 v14; // rax
char v15; // al
signed __int64 v16; // rax
int v17; // eax
__int64 result; // rax
thisItemInfoStructure = itemStructure;
thisLinkObject = linkObject;
if ( itemStructure->byte6 )
{
v4 = sub_140644720((signed __int64)itemStructure);
thisItemId = sub_140160880(v4);
}
else
{
itemFlags = itemStructure->flags;
thisItemId = itemStructure->itemId;
if ( itemFlags & 1 )
{
thisItemId += 1000000;
}
else if ( itemFlags & 8 )
{
thisItemId += 500000;
}
}
v7 = *(_BYTE *)(thisLinkObject + 6) == 0;
*(_DWORD *)(thisLinkObject + 8) = thisItemId;
if ( v7 && (unsigned int)(thisItemId - 2000000) > 0x9D8 )
{
if ( (unsigned int)(thisItemId - 1000001) > 0xF423E )
{
if ( (unsigned int)(thisItemId - 500001) > 0x7A11E )
{
*(_BYTE *)(thisLinkObject + 20) &= 0xFEu;
}
else
{
*(_BYTE *)(thisLinkObject + 20) |= 8u;
*(_DWORD *)(thisLinkObject + 8) = thisItemId - 500000;
}
}
else
{
*(_BYTE *)(thisLinkObject + 20) |= 1u;
*(_DWORD *)(thisLinkObject + 8) = thisItemId - 1000000;
}
}
*(_DWORD *)(thisLinkObject + 12) = sub_140644B10((__int64)thisItemInfoStructure);
if ( thisItemInfoStructure->byte6 && sub_140644720((signed __int64)thisItemInfoStructure) )
{
v8 = sub_140644720((signed __int64)thisItemInfoStructure);
v9 = sub_140670BC0(v8);
}
else
{
v9 = *(_QWORD *)&thisItemInfoStructure[1].gap0[3];
}
*(_QWORD *)(thisLinkObject + 24) = v9;
*(_BYTE *)(thisLinkObject + 20) = thisItemInfoStructure->flags;
if ( thisItemInfoStructure->byte6 && sub_140644720((signed __int64)thisItemInfoStructure) )
{
v10 = sub_140644720((signed __int64)thisItemInfoStructure);
v11 = sub_140160910(v10);
}
else
{
v11 = *(_WORD *)&thisItemInfoStructure->gapC[6];
}
*(_WORD *)(thisLinkObject + 18) = v11;
if ( thisItemInfoStructure->byte6 && sub_140644720((signed __int64)thisItemInfoStructure) )
{
v12 = sub_140644720((signed __int64)thisItemInfoStructure);
v13 = sub_1401609F0(v12);
}
else
{
v13 = *(_WORD *)&thisItemInfoStructure->gapC[4];
}
*(_WORD *)(thisLinkObject + 16) = v13;
if ( thisItemInfoStructure->byte6 && sub_140644720((signed __int64)thisItemInfoStructure) )
{
v14 = sub_140644720((signed __int64)thisItemInfoStructure);
v15 = sub_140160A50(v14);
}
else
{
v15 = thisItemInfoStructure[2].gap0[5];
}
*(_BYTE *)(thisLinkObject + 47) = v15;
if ( thisItemInfoStructure->byte6 && sub_140644720((signed __int64)thisItemInfoStructure) )
{
v16 = sub_140644720((signed __int64)thisItemInfoStructure);
v17 = sub_1401609B0(v16);
}
else
{
v17 = *(_DWORD *)&thisItemInfoStructure[2].byte6;
}
*(_DWORD *)(thisLinkObject + 48) = v17;
*(_BYTE *)(thisLinkObject + 6) = thisItemInfoStructure->byte6;
*(_QWORD *)(thisLinkObject + 32) = *(_QWORD *)((char *)&thisItemInfoStructure[1].itemId + 3);
*(_WORD *)(thisLinkObject + 40) = *(_WORD *)&thisItemInfoStructure[1].gapC[7];
*(_DWORD *)(thisLinkObject + 42) = *(_DWORD *)thisItemInfoStructure[2].gap0;
result = (unsigned __int8)thisItemInfoStructure[2].gap0[4];
*(_BYTE *)(thisLinkObject + 46) = result;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment