Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Ноя 2020
- Сообщения
- 17
- Реакции
- 2
C++:
--creds 2 uwukson4800
local ffi = require 'ffi'
local cast = ffi.cast
local menu_group = ui.create("Color Correction")
local menu = {
sat = menu_group:slider('Saturation', 0, 200, 0, 1, '%'),
mono = menu_group:slider('Monochrome', 0, 100, 0, 1, '%'),
ghost = menu_group:slider('Ghost', 0, 100, 0, 1, '%'),
red = menu_group:slider('Red', 0, 200, 0, 1, '%'),
green = menu_group:slider('Green', 0, 200, 0, 1, '%'),
blue = menu_group:slider('Blue', 0, 200, 0, 1, '%'),
yellow = menu_group:slider('Yellow', 0, 200, 0, 1, '%')
}
do
local UpdateColorCorrectionWeights_t = ffi.typeof('void(__thiscall*)(void*)')
local ibase_client_dll = utils.create_interface('client.dll', 'VClient018')
if ibase_client_dll == nil then
error('Failed to get VClient018 interface')
end
local client_vmt = cast('uintptr_t**', ibase_client_dll)[0]
local hud_process_input_fn = client_vmt[10]
local iclient_mode_ptr = cast('uintptr_t**', hud_process_input_fn + 0x5)[0][0]
if iclient_mode_ptr == 0 then
error('Failed to find IClientMode 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
local original_vtable = vtable
local function hkUpdateColorCorrectionWeights(thisptr)
cast('float*', cast('uintptr_t', thisptr) + 0x4B4)[0] = menu.sat:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4AC)[0] = menu.mono:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4C4)[0] = menu.ghost:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4A4)[0] = menu.red:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4CC)[0] = menu.green:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x49C)[0] = menu.blue:get() / 100
cast('float*', cast('uintptr_t', thisptr) + 0x4D4)[0] = menu.yellow:get() / 100
end
events.shutdown:set(function()
hooked_vtable[58] = original_vtable[58]
client_mode[0] = original_vtable
end)
hooked_vtable[58] = ffi.cast('uintptr_t', ffi.cast(UpdateColorCorrectionWeights_t, hkUpdateColorCorrectionWeights))
client_mode[0] = hooked_vtable
end