bool IopSimHooks::hook(SharedStruct<GNSIntf>*  pShared)
{

    bool res = true;
    int i;


    m_pShared = pShared;
    m_pData = pShared->get();

    HMODULE hiop_sim_sim = GetModuleHandle("IOP_SIM.dll");

    SDLLHook krnlsimHook = 
    {
        "krnlsim.dll",
        false, NULL, // Default hook disabled, NULL function pointer.
        {
            { "TSK_pvg_send_msg_ex", my_TSK_pvg_send_msg_ex},
            { "reg_read", my_reg_read},
            { "reg_write", my_reg_write},
            { "SYS_pvg_var_ctrl" , my_SYS_pvg_var_ctrl},
            { NULL, NULL }
        }
    };



    i=0;
    HookAPICallsMod(&krnlsimHook, hiop_sim_sim);
    m_TSK_pvg_send_msg_ex_fn = (TSK_pvg_send_msg_ex_t)krnlsimHook.Functions[i++].OrigFn;
    m_reg_read_fn = (reg_read_t)krnlsimHook.Functions[i++].OrigFn;
    m_reg_write_fn = (reg_write_t)krnlsimHook.Functions[i++].OrigFn;
    m_SYS_pvg_var_ctrl_fn = (SYS_pvg_var_ctrl_t)krnlsimHook.Functions[i++].OrigFn;



    return res;
}
bool TestHooks::hook(SharedStruct<GNSIntf>*  pShared)
{

    bool res = true;
    int i;


    m_pShared = pShared;
    m_pData = pShared->get();

    HMODULE hMod;
    //hMod = GetModuleHandle("cdp_com_box_sim.dll");
    //hMod = GetModuleHandle("cdp_vloc_box_sim.dll");
    //hMod = GetModuleHandle("cdp_annun_box_sim.dll");
    //hMod = GetModuleHandle("sys_resource.dll");
    hMod = GetModuleHandle("IOP_B.dll");

//#pragma warning FIXME
    SDLLHook krnlsimHook = 
    {
        "krnlsim.dll",
        //false, NULL, // Default hook disabled, NULL function pointer.
        true, DefaultHook,
        {

            { "HWM_pvg_get_obs", my_HWM_pvg_get_obs},
            { "TSK_pvg_wait_evnt", my_TSK_pvg_wait_evnt},
            { "TSK_pvg_get_timer", my_TSK_pvg_get_timer},
            { "TSK_pvg_send_msg_ex", my_TSK_pvg_send_msg_ex},
            { "TSK_pvg_get_msg", my_TSK_pvg_get_msg},
            { "TSK_pvg_proc_status", my_TSK_pvg_proc_status},
            { "reg_read", my_reg_read},
            { "reg_write", my_reg_write},
            { "SYS_pvg_var_ctrl" , my_SYS_pvg_var_ctrl},
            { "FIL_vfs_open" , my_FIL_vfs_open},
            { "FIL_vfs_mmap" , my_FIL_vfs_mmap},
            { "mem_unmap" , my_mem_unmap},
            { "FIL_vfs_seek" , my_FIL_vfs_seek},
            { "FIL_vfs_close" , my_FIL_vfs_close},
            { "FIL_vfs_rename" , my_FIL_vfs_rename},
            { "FIL_vfs_write" , my_FIL_vfs_write},
            
            { NULL, NULL }
        }
    };

    i=0;
    HookAPICallsMod(&krnlsimHook, hMod);
    
    m_HWM_pvg_get_obs_fn = (HWM_pvg_get_obs_t)krnlsimHook.Functions[i++].OrigFn;
    m_TSK_pvg_wait_evnt_fn = (TSK_pvg_wait_evnt_t)krnlsimHook.Functions[i++].OrigFn;
    m_TSK_pvg_get_timer_fn = (TSK_pvg_get_timer_t)krnlsimHook.Functions[i++].OrigFn;
    m_TSK_pvg_send_msg_ex_fn = (TSK_pvg_send_msg_ex_t)krnlsimHook.Functions[i++].OrigFn;
    m_TSK_pvg_get_msg_fn = (TSK_pvg_get_msg_t)krnlsimHook.Functions[i++].OrigFn;
    m_TSK_pvg_proc_status_fn = (TSK_pvg_proc_status_t)krnlsimHook.Functions[i++].OrigFn;
    m_reg_read_fn = (reg_read_t)krnlsimHook.Functions[i++].OrigFn;
    m_reg_write_fn = (reg_write_t)krnlsimHook.Functions[i++].OrigFn;
    m_SYS_pvg_var_ctrl_fn = (SYS_pvg_var_ctrl_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_open_fn = (FIL_vfs_open_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_mmap_fn = (FIL_vfs_mmap_t)krnlsimHook.Functions[i++].OrigFn;
    m_mem_unmap_fn = (mem_unmap_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_seek_fn = (FIL_vfs_seek_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_close_fn = (FIL_vfs_close_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_rename_fn = (FIL_vfs_rename_t)krnlsimHook.Functions[i++].OrigFn;
    m_FIL_vfs_write_fn = (FIL_vfs_write_t)krnlsimHook.Functions[i++].OrigFn;

    SDLLHook sysresourcesHook = 
    {
        "sys_resource.dll",
        false, NULL, // Default hook disabled, NULL function pointer.
        //true, DefaultHook,
        {
            { "TXT_get_string", my_TXT_get_string},
            { NULL, NULL }
        }
    };
    i=0;
    HookAPICallsMod(&sysresourcesHook, hMod);
    m_TXT_get_string_fn = (TXT_get_string_t)sysresourcesHook.Functions[i++].OrigFn;

    return res;
}