- Статус
- Оффлайн
- Регистрация
- 1 Фев 2020
- Сообщения
- 1,326
- Реакции
- 523
C++:
local ffi = require 'ffi'
local cast = ffi.cast
local menu = {
sat = ui.new_slider('LUA', 'A', 'Saturation', 0, 200, 0, true, '%'),
mono = ui.new_slider('LUA', 'A', 'Monochrome', 0, 100, 0, true, '%'),
ghost = ui.new_slider('LUA', 'A', 'Ghost', 0, 100, 0, true, '%'),
red = ui.new_slider('LUA', 'A', 'Red', 0, 200, 0, true, '%'),
green = ui.new_slider('LUA', 'A', 'Green', 0, 200, 0, true, '%'),
blue = ui.new_slider('LUA', 'A', 'Blue', 0, 200, 0, true, '%'),
yellow = ui.new_slider('LUA', 'A', 'Yellow', 0, 200, 0, true, '%')
}
do
local UpdateColorCorrectionWeights_t = ffi.typeof('void(__thiscall*)(void*)')
-- CHLClient
local ibase_client_dll = client.create_interface('client.dll', 'VClient018')
local client_vmt = cast('uintptr_t**', ibase_client_dll)[0]
local hud_process_input_fn = client_vmt[10] -- CHLClient::HudProcessInput
local iclient_mode_ptr = cast('uintptr_t**', hud_process_input_fn + 0x5)[0][0]
if iclient_mode_ptr == 0 then
error('failed to find pointer')
end
local client_mode = ffi.cast('uintptr_t**', iclient_mode_ptr)
local vtable = ffi.cast('uintptr_t*', client_mode[0])
local size = 0
while vtable[size] ~= 0x0 do
size = size + 1
end
local hooked_vtable = ffi.new('uintptr_t[?]', size)
for i = 0, size - 1 do
hooked_vtable[i] = vtable[i]
end
client_mode[0] = hooked_vtable
local function hkUpdateColorCorrectionWeights(thisptr)
-- note: don't call original func
cast('float*', cast('uintptr_t', thisptr) + 0x4B4)[0] = ui.get(menu.sat) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4AC)[0] = ui.get(menu.mono) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4C4)[0] = ui.get(menu.ghost) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4A4)[0] = ui.get(menu.red) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4CC)[0] = ui.get(menu.green) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x49C)[0] = ui.get(menu.blue) / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4D4)[0] = ui.get(menu.yellow) / 100
end
client.set_event_callback('shutdown', function()
hooked_vtable[58] = vtable[58]
client_mode[0] = vtable
end)
hooked_vtable[58] = ffi.cast('uintptr_t', ffi.cast(UpdateColorCorrectionWeights_t, hkUpdateColorCorrectionWeights))
end