C++ Shift dt for (lw)

Забаненный
Статус
Оффлайн
Регистрация
30 Май 2022
Сообщения
9
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
I don't know why - the code is only the shift itself.
credit - miracl3 https://yougame.biz/threads/252496/
Thanks to opai for the reverse
Код:
//nemesis - technology

using WriteUsercmdDeltaToBuffer_t = bool(__thiscall*)(void*, int, void*, int, int, bool);
void WriteUserСmd(void* buf, CUserCmd* incmd, CUserCmd* outcmd)
{
    using WriteUserCmd_t = void(__fastcall*)(void*, CUserCmd*, CUserCmd*);

    static auto Fn = util::FindSignature(crypt_str("client.dll"), crypt_str("55 8B EC 83 E4 F8 51 53 56 8B D9"));

    __asm
    {
        mov     ecx, buf
        mov     edx, incmd
        push    outcmd
        call    Fn
        add     esp, 4
    }
}

bool __fastcall hooks::ShiftCmd(int* new_commands, int* backup_commands, void* ecx, int slot, bf_write* buf, int unk, bool real_cmd)
{
    static auto original_fn = hooks::client_hook->get_func_address <WriteUsercmdDeltaToBuffer_t>(24);

    auto new_from = -1;
    auto shift_amount = g_ctx.globals.tickbase_shift;

    g_ctx.globals.tickbase_shift = 0;

    auto commands = *new_commands;
    auto shift_commands = std::clamp(commands + shift_amount, 1, 62);
    *new_commands = shift_commands;
    *backup_commands = 0;

    auto next_cmd_nr = m_clientstate()->iChokedCommands + m_clientstate()->nLastOutgoingCommand + 1;
    auto new_to = next_cmd_nr - commands + 1;
    if (new_to <= next_cmd_nr)
    {
        while (original_fn(ecx, slot, buf, new_from, new_to, true))
        {
            new_from = new_to++;

            if (new_to > next_cmd_nr)
                goto next_cmd;
        }
        return false;
    }
next_cmd:
    *(int*)((uintptr_t)m_prediction() + 0x34C) = 0; //0x1C g_ctx.globals.send_pacet = 0;
    *(int*)((uintptr_t)m_prediction() + 0xC) = -1;

    auto fake_cmd = m_input()->GGetUserCmd(slot, new_from);

    if (!fake_cmd)
        return true;

    CUserCmd to_cmd;
    CUserCmd from_cmd;

    from_cmd = *fake_cmd;
    to_cmd = from_cmd;

    ++to_cmd.m_command_number;

    if (real_cmd)
    {
        int iterator = 0;

        do
        {
            m_prediction()->Update(m_clientstate()->iDeltaTick, m_clientstate()->iDeltaTick > 0, m_clientstate()->nLastCommandAck, m_clientstate()->nLastOutgoingCommand + m_clientstate()->iChokedCommands);

            to_cmd.m_buttons &= ~0xFFBEFFF9;

            auto new_cmd = m_input()->GetUserCmd(to_cmd.m_command_number);
            auto verified_cmd = m_input()->GetVerifiedUserCmd(to_cmd.m_command_number);

            std::memcpy(new_cmd, &to_cmd, sizeof(CUserCmd));
            std::memcpy(&verified_cmd->m_cmd, &to_cmd, sizeof(CUserCmd));
            verified_cmd->m_crc = new_cmd->GetChecksum();
            WriteUserСmd(buf, &to_cmd, &from_cmd);

            ++iterator;
            if (iterator >= shift_amount)
            {
                auto& out = g_ctx.globals.commands.rbegin();

                out->is_outgoing = true;
                out->is_used = false;
                out->command_number = m_clientstate()->nLastOutgoingCommand + m_clientstate()->iChokedCommands + 1;
                out->previous_command_number = 0;
            }
            else
            {
                auto net_chan = m_clientstate()->pNetChannel;
                if (net_chan)
                {
                    ++net_chan->m_nOutSequenceNr;
                    ++net_chan->m_nChokedPackets;
                }
                ++m_clientstate()->iChokedCommands;
            }

            from_cmd = to_cmd;
            ++to_cmd.m_command_number;

        } while (iterator < shift_amount);
    }
    else
    {
        to_cmd.m_tickcount = INT_MAX;
        do
        {
            WriteUserСmd(buf, &to_cmd, &from_cmd);

            ++to_cmd.m_command_number;
            shift_amount--;
        } while (shift_amount > 0);
    }
}

bool __fastcall hooks::hooked_writeusercmddeltatobuffer(void* ecx, void* edx, int slot, bf_write* buf, int from, int to, bool is_new_command)
{
    static auto original_fn = client_hook->get_func_address <WriteUsercmdDeltaToBuffer_t>(24);

    if (!g_ctx.local() || !g_ctx.get_command() || !g_ctx.local()->is_alive() || g_ctx.local()->m_flSimulationTime() || g_ctx.local()->m_bGunGameImmunity() || g_ctx.local()->m_fFlags() & FL_FROZEN)
        return original_fn(ecx, slot, buf, from, to, is_new_command);

    if (g_ctx.globals.should_recharge || !g_ctx.globals.tickbase_shift)
        return original_fn(ecx, slot, buf, from, to, is_new_command);

    if (from != -1)
        return true;

    uintptr_t frame_ptr = 0;
    __asm mov frame_ptr, ebp;

    auto backup_commands = reinterpret_cast <int*> (frame_ptr + 0xFD8);
    auto new_commands = reinterpret_cast <int*> (frame_ptr + 0xFDC);

    return ShiftCmd(new_commands, backup_commands, ecx, slot, buf, -1, !g_ctx.globals.break_lc);
}
 
Последнее редактирование:
Сверху Снизу