use ilhook::x64::Registers;

use super::{ModuleInitError, NapModule, NapModuleContext};

const SET_DITHER_CONFIG: usize = 0x95BCFF0;

pub struct CensorshipPatch;

impl NapModule for NapModuleContext<CensorshipPatch> {
    unsafe fn init(&mut self) -> Result<(), ModuleInitError> {
        self.interceptor.attach(
            self.base.wrapping_add(SET_DITHER_CONFIG),
            CensorshipPatch::on_set_dither_config,
        )?;

        Ok(())
    }
}

impl CensorshipPatch {
    pub unsafe extern "win64" fn on_set_dither_config(reg: *mut Registers, _: usize) {
        println!("SetDitherConfig()");
        (*reg).rdx = 0;
    }
}