-
Автор темы
- #1
pseudocode
Reversed code ready to past
C++:
bool __fastcall Hooks::hkWriteUsercmdDeltaToBuffer(void *m_pBaseClient, void *s, int m_nSlot, CBufWrite *m_pBuffer, int m_nFrom, int m_nTo, bool m_bIsNewCmd)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
v22 = (CBufWrite *)&savedregs;
m_nTickbase = *(_DWORD *)(((dword_43419B94 - 343576241) ^ 0x3EB1B31F) + 0x30);
if ( m_nTickbase >= 0 || *(_BYTE *)(((dword_43419B94 - 343576241) ^ 0x3EB1B31F) + 0x37) )
return Hooks::o_WriteUsercmdDeltaToBuffer(m_pBaseClient, s, m_nSlot, m_pBuffer, m_nFrom, m_nTo, m_bIsNewCmd);
if ( m_nFrom != -1 )
return 1;
m_pBuffer = v22;
*(_DWORD *)(((dword_43419B94 - 343576241) ^ 0x3EB1B31F) + 0x30) = 0;
m_pBuffer->m_nBackupCmds = 0;
m_nNewCmds = m_pBuffer->m_nNewCmds;
m_nTotalNewCmds = abs(m_nTickbase) + m_nNewCmds;
if ( m_nTotalNewCmds > 62 )
m_nTotalNewCmds = 62;
m_nFrom = -1;
m_pBuffer->m_nNewCmds = m_nTotalNewCmds;
m_nNextCmd = *(_DWORD *)((g_pClientState ^ HIDWORD(g_pClientState1)) + 0x4D28)
+ *(_DWORD *)((g_pClientState ^ HIDWORD(g_pClientState1)) + 0x4D24)
+ 1;
m_nTo = m_nNextCmd - m_nNewCmds + 1;
if ( m_nTo > m_nNextCmd )
{
LABEL_11:
m_fnGetUserCmd = (int (__stdcall *)(int, int))Utils::GetConvUsercmd((void *)(HIDWORD(g_pInput) ^ DWORD2(g_pInput)));
m_pRealCmd = m_fnGetUserCmd(m_nSlot, v15);
if ( m_pRealCmd )
{
Utils::TranslateCmd(&m_nFromCmd, m_pRealCmd);
Utils::TranslateCmd(&m_nToCmd, m_pRealCmd);
++m_nToCmd.command_number;
m_nToCmd.tick_count += Globals::Game::g_iTickrate + 2 * Globals::Game::g_iTickrate;
if ( m_nNewCmds <= m_nTotalNewCmds )
{
m_nShift = m_nTotalNewCmds - m_nNewCmds + 1;
do
{
MEMORY[0x50ADA960](m_pBuffer, &m_nToCmd, &m_nFromCmd);
m_nFromCmd.buttons = m_nToCmd.buttons;
*(_OWORD *)&m_nFromCmd.viewangles.x = *(_OWORD *)&m_nToCmd.viewangles.x;
m_nFromCmd.impulse = m_nToCmd.impulse;
m_nFromCmd.weaponselect = m_nToCmd.weaponselect;
*(_OWORD *)&m_nFromCmd.aimdirection.y = *(_OWORD *)&m_nToCmd.aimdirection.y;
m_nFromCmd.weaponsubtype = m_nToCmd.weaponsubtype;
m_nFromCmd.upmove = m_nToCmd.upmove;
m_nFromCmd.random_seed = m_nToCmd.random_seed;
m_nFromCmd.mousedx = m_nToCmd.mousedx;
*(_OWORD *)&m_nFromCmd.pad_0x4C[3] = *(_OWORD *)&m_nToCmd.pad_0x4C[3];
m_nFromCmd.command_number = m_nToCmd.command_number;
m_nFromCmd.tick_count = m_nToCmd.tick_count;
m_nFromCmd.mousedy = m_nToCmd.mousedy;
*(_DWORD *)&m_nFromCmd.pad_0x4C[19] = *(_DWORD *)&m_nToCmd.pad_0x4C[19];
m_nFromCmd.hasbeenpredicted = m_nToCmd.hasbeenpredicted;
*(_DWORD *)&m_nFromCmd.pad_0x4C[23] = *(_DWORD *)&m_nToCmd.pad_0x4C[23];
++m_nToCmd.command_number;
++m_nToCmd.tick_count;
--m_nShift;
}
while ( m_nShift );
}
}
result = 1;
}
else
{
while ( (unsigned __int8)Hooks::o_WriteUsercmdDeltaToBuffer(m_pBaseClient, s, m_nSlot, m_pBuffer, m_nFrom, m_nTo, 1) )
{
m_nFrom = m_nTo++;
if ( m_nTo > m_nNextCmd )
goto LABEL_11;
}
result = 0;
}
return result;
}
C++:
bool __fastcall hooks::hkWriteUsercmdDeltaToBuffer(void* m_pBaseClient, void* s, int m_nSlot, bf_write* m_pBuffer, int m_nFrom, int m_nTo, bool m_bNewCmd)
{
static auto sendmovecall = (void*)sig("engine.dll", "84 C0 74 04 B0 01 EB 02 32 C0 8B FE 46 3B F3 7E C9 84 C0 0F 84");
if (_ReturnAddress() != sendmovecall || m_ticks_to_shift <= 0)
return orig_write_user_cmd_delta_to_buffer(g_pClient, s, m_nSlot, m_pBuffer, m_nFrom, m_nTo, m_bNewCmd);
if (m_nFrom != -1)
return true;
uintptr_t stackbase;
__asm mov stackbase, ebp;
CCLCMsg_Move_t* msg = reinterpret_cast<CCLCMsg_Move_t*>(stackbase + 0xFCC);
int32_t m_nNewCmds = msg->m_nNewCommands;
int m_nTotalNewCmds = abs(m_ticks_to_shift) + m_nNewCmds;
if (m_nTotalNewCmds > 62)
m_nTotalNewCmds = 62;
m_nFrom = -1;
msg->m_nNewCommands = m_nTotalNewCmds;
msg->m_nBackupCommands = 0;
int m_nNextCmd = g_pClientState->m_nLastOutgoingCommand + g_pClientState->m_nChokedCommands + 1;
m_nTo = m_nNextCmd - m_nNewCmds + 1;
if (m_nTo > m_nNextCmd)
{
Run:
CUserCmd* m_pCmd = g_pInput->GetUserCmd(m_nSlot, m_nFrom);
if (m_pCmd)
{
CUserCmd m_nToCmd = *m_pCmd, m_nFromCmd = *m_pCmd;
m_nToCmd.command_number++;
m_nToCmd.tick_count += g_pGameGlobals->m_flTickcount + 2 * g_pGameGlobals->m_flTickcount;
if (m_nNewCmds <= m_nTotalNewCmds)
{
int m_shift = m_nTotalNewCmds - m_nNewCmds + 1;
do
{
WriteUsercmd(m_pBuffer, &m_nToCmd, &m_nFromCmd);
m_nFromCmd.buttons = m_nToCmd.buttons;
m_nFromCmd.viewangles.x = m_nToCmd.viewangles.x;
m_nFromCmd.impulse = m_nToCmd.impulse;
m_nFromCmd.weaponselect = m_nToCmd.weaponselect;
m_nFromCmd.aimdirection.y = m_nToCmd.aimdirection.y;
m_nFromCmd.weaponsubtype = m_nToCmd.weaponsubtype;
m_nFromCmd.upmove = m_nToCmd.upmove;
m_nFromCmd.random_seed = m_nToCmd.random_seed;
m_nFromCmd.mousedx = m_nToCmd.mousedx;
m_nFromCmd.pad_0x4C[3] = m_nToCmd.pad_0x4C[3];
m_nFromCmd.command_number = m_nToCmd.command_number;
m_nFromCmd.tick_count = m_nToCmd.tick_count;
m_nFromCmd.mousedy = m_nToCmd.mousedy;
m_nFromCmd.pad_0x4C[19] = m_nToCmd.pad_0x4C[19];
m_nFromCmd.hasbeenpredicted = m_nToCmd.hasbeenpredicted;
m_nFromCmd.pad_0x4C[23] = m_nToCmd.pad_0x4C[23];
m_nToCmd.command_number++;
m_nToCmd.tick_count++;
--m_shift;
} while (m_shift);
}
}
return true;
}
else
{
while (orig_write_user_cmd_delta_to_buffer(g_pClient, s, m_nSlot, m_pBuffer, m_nFrom, m_nTo, true))
{
m_nFrom = m_nTo++;
if (m_nTo > m_nNextCmd)
goto Run;
}
return false;
}
return true;
}
Последнее редактирование: