Exemple #1
0
//---------------------------------------------------------------------------
int __fastcall DebuggeeCheckThread::HandleDllUnload( DEBUG_EVENT& debug )
{
    std::string dllname;
    if( GetDllInfo( debug.u.UnloadDll.lpBaseOfDll, dllname ) ) {
        debug_string_ = AnsiString( dllname.c_str() );
        debug_string_ += AnsiString( "がアンロードされました" );
        Synchronize(&SetDebugString);
    }
    return 1;
}
Exemple #2
0
BOOL LoadGFXDll(char * RspDll) {

    if(hGfxDll != NULL)
        CloseGfxPlugin();

    PLUGIN_INFO PluginInfo;
    char DllName[300];

    GetPluginDir(DllName);
    strcat(DllName,GfxDLL);

    hGfxDll = LoadLibrary(DllName);
    if (hGfxDll == NULL)
        return FALSE;

    GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( hGfxDll, "GetDllInfo" );
    if (GetDllInfo == NULL)
        return FALSE;

    GetDllInfo(&PluginInfo);
    //if (!ValidPluginVersion(&PluginInfo) || PluginInfo.MemoryBswaped == FALSE) { return FALSE; }

    _GFXCloseDLL = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "CloseDLL" );
    _ChangeWindow = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ChangeWindow" );
    _GFXDllAbout = (void (__cdecl *)(HWND))GetProcAddress( hGfxDll, "DllAbout" );
    _GFXDllConfig = (void (__cdecl *)(HWND))GetProcAddress( hGfxDll, "DllConfig" );
    _DrawScreen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "DrawScreen" );
    _InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( hGfxDll, "InitiateGFX" );
    _MoveScreen = (void (__cdecl *)(int, int))GetProcAddress( hGfxDll, "MoveScreen" );
    _ProcessDList = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ProcessDList" );
    _GfxRomClosed = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "RomClosed" );
    _GfxRomOpen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "RomOpen" );
    _UpdateScreen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "UpdateScreen" );
    _ViStatusChanged = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ViStatusChanged" );
    _ViWidthChanged = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ViWidthChanged" );

    _ProcessRDPList = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ProcessRDPList" );
    _CaptureScreen = (void (__cdecl *)(char *))GetProcAddress( hGfxDll, "CaptureScreen" );
    _ShowCFB = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ShowCFB" );

#ifdef CFB_READ
    FrameBufferRead = (void (__cdecl *)(DWORD))GetProcAddress( hGfxDll, "FBRead" );
    FrameBufferWrite = (void (__cdecl *)(DWORD, DWORD))GetProcAddress( hGfxDll, "FBWrite" );
#endif
    return TRUE;
}
Exemple #3
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_LibHandle != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
    if (m_LibHandle == NULL)
    {
        return false;
    }

    // Get DLL information
    void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    LoadFunction(CloseDLL);
    LoadFunction(RomOpen);
    LoadFunction(RomClosed);
    _LoadFunction("PluginLoaded", PluginOpened);
    LoadFunction(DllConfig);
    LoadFunction(DllAbout);

    LoadFunction(SetSettingInfo3);
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    LoadFunction(SetSettingInfo2);
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    LoadFunction(SetSettingInfo);
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
    {
        return false;
    }

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}
Exemple #4
0
void CPluginList::AddPluginFromDir(CPath Dir)
{
    Dir.SetNameExtension("*.*");
    if (Dir.FindFirst(_A_SUBDIR))
    {
        do {
            AddPluginFromDir(Dir);
        } while (Dir.FindNext());
        Dir.UpDirectory();
    }

    Dir.SetNameExtension("*.dll");
    if (Dir.FindFirst())
    {
        HMODULE hLib = NULL;
        do {
            if (hLib)
            {
                FreeLibrary(hLib);
                hLib = NULL;
            }

            //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
            WriteTraceF(TraceDebug, __FUNCTION__ ": loading %s", (LPCSTR)Dir);
            hLib = LoadLibrary(Dir);
            //SetErrorMode(LastErrorMode);

            if (hLib == NULL)
            {
                DWORD LoadError = GetLastError();
                WriteTraceF(TraceDebug, __FUNCTION__ ": failed to loadi %s (error: %d)", (LPCSTR)Dir, LoadError);
                continue;
            }

            void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
            GetDllInfo = (void(__cdecl *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo");
            if (GetDllInfo == NULL)
            {
                continue;
            }

            PLUGIN Plugin = { 0 };
            Plugin.Info.MemoryBswaped = true;
            GetDllInfo(&Plugin.Info);
            if (!CPlugin::ValidPluginVersion(Plugin.Info))
            {
                continue;
            }

            Plugin.FullPath = Dir;
            Plugin.FileName = stdstr((const char *)Dir).substr(strlen(m_PluginDir));

            if (GetProcAddress(hLib, "DllAbout") != NULL)
            {
                Plugin.AboutFunction = true;
            }
            m_PluginList.push_back(Plugin);
        } while (Dir.FindNext());

        if (hLib)
        {
            FreeLibrary(hLib);
            hLib = NULL;
        }
    }
}
Exemple #5
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_hDll != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    if (bHaveDebugger())
    {
        m_hDll = LoadLibrary(FileName);
    }
    else
    {
        UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
        m_hDll = LoadLibrary(FileName);
        SetErrorMode(LastErrorMode);
    }

    if (m_hDll == NULL)
    {
        return false;
    }

    // Get DLL information
    void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    CloseDLL = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "CloseDLL");
    RomOpen = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomOpen");
    RomClosed = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomClosed");
    PluginOpened = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "PluginLoaded");
    DllConfig = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllConfig");
    DllAbout = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllAbout");

    SetSettingInfo3 = (void(__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo3");
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    SetSettingInfo2 = (void(__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo2");
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    SetSettingInfo = (void(__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo");
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
        return false;

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}
Exemple #6
0
OPStatus InputPlugin::initialize(Bus* bus, PluginContainer* plugins, void* renderWindow, void* statusBar)
{
    Bus::state.controllers[0].Present = 0;
    Bus::state.controllers[0].RawData = 0;
    Bus::state.controllers[0].Plugin = PLUGIN_NONE;

    Bus::state.controllers[1].Present = 0;
    Bus::state.controllers[1].RawData = 0;
    Bus::state.controllers[1].Plugin = PLUGIN_NONE;

    Bus::state.controllers[2].Present = 0;
    Bus::state.controllers[2].RawData = 0;
    Bus::state.controllers[2].Plugin = PLUGIN_NONE;

    Bus::state.controllers[3].Present = 0;
    Bus::state.controllers[3].RawData = 0;
    Bus::state.controllers[3].Plugin = PLUGIN_NONE;

    //Get DLL information
    void (*GetDllInfo)(PLUGIN_INFO* PluginInfo);

    getPluginFunction(_libHandle, "GetDllInfo", GetDllInfo);
    if (GetDllInfo == nullptr)
    {
        LOG_ERROR(InputPlugin) << "GetDllInfo not found";
        return OP_ERROR;
    }

    PLUGIN_INFO PluginInfo;
    GetDllInfo(&PluginInfo);

    //Test Plugin version
    if (PluginInfo.Version == 0x0100) {
        //Get Function from DLL
        void (*InitiateControllers_1_0)(void* hMainWindow, CONTROL Controls[4]);

        getPluginFunction(_libHandle, "InitiateControllers", InitiateControllers_1_0);
        if (InitiateControllers_1_0 == nullptr)
        {
            LOG_ERROR(InputPlugin) << "InitiateControllers v1.0 not found";
            return OP_ERROR;
        }

        InitiateControllers_1_0(renderWindow, Bus::state.controllers);
        _initialized = true;
    }

    if (PluginInfo.Version >= 0x0101) {
        typedef struct {
            void* hMainWindow;
            void* hinst;

            int MemoryBswaped;
            uint8_t* HEADER;
            CONTROL* Controls;
        } CONTROL_INFO;

        //Get Function from DLL		
        void (*InitiateControllers_1_1)(CONTROL_INFO ControlInfo);

        getPluginFunction(_libHandle, "InitiateControllers", InitiateControllers_1_1);
        if (InitiateControllers_1_1 == nullptr)
        {
            LOG_ERROR(InputPlugin) << "InitiateControllers v1.1 not found";
            return OP_ERROR;
        }

        CONTROL_INFO ControlInfo;
        ControlInfo.Controls = Bus::state.controllers;
        if (bus && bus->rom)
        {
            ControlInfo.HEADER = bus->rom->getImage();
        }
        else
        {
            uint8_t buf[100];
            ControlInfo.HEADER = buf;
        }
        ControlInfo.hinst = opLibGetMainHandle();
        ControlInfo.hMainWindow = renderWindow;
        ControlInfo.MemoryBswaped = 1;
        InitiateControllers_1_1(ControlInfo);
        _initialized = true;
    }

    return OP_OK;
}