static void LoadPlugin (SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type) { if (plugin != NULL) { return; } FileName = g_Settings->LoadStringVal(PluginSettingID); CPath PluginFileName(PluginDir,FileName.c_str()); plugin = new plugin_type(); if (plugin) { WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading (%s): Starting",type,(LPCTSTR)PluginFileName); if (plugin->Load(PluginFileName)) { WriteTraceF(TraceLevel,__FUNCTION__ ": %s Current Ver: %s",type,plugin->PluginName()); g_Settings->SaveString(PluginVerSettingID,plugin->PluginName()); } else { WriteTraceF(TraceError,__FUNCTION__ ": Failed to load %s",(LPCTSTR)PluginFileName); delete plugin; plugin = NULL; } WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading Done",type); } else { WriteTraceF(TraceError,__FUNCTION__ ": Failed to allocate %s plugin",type); } }
void CPlugin::RomClose() { if (!m_RomOpen) return; WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Close",PluginType()); RomClosed(); m_RomOpen = false; WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Close",PluginType()); }
void CPlugin::Close() { WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Start",PluginType()); RomClose(); if (m_Initialized) { CloseDLL(); m_Initialized = false; } WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Done",PluginType()); }
DWORD CAudio::GetLength() { WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff); DWORD TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0; if (TimeLeft > 0) { Res = (TimeLeft / m_CountsPerByte); } WriteTraceF(TraceAudio,__FUNCTION__ ": Done (res = %d, TimeLeft = %d)",Res, TimeLeft); return (Res+3)&~3; }
void CPlugin::RomOpened() { if (m_RomOpen) return; if(RomOpen != NULL){ WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Open",PluginType()); RomOpen(); WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Open",PluginType()); } m_RomOpen = true; }
bool CSettingTypeRDBYesNo::Load ( int Index, bool & Value ) const { stdstr strValue; bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); if (!bRes) { LoadDefault(Index,Value); return false; } const char * String = strValue.c_str(); if (_stricmp(String,"Yes") == 0) { Value = true; } else if (_stricmp(String,"No") == 0) { Value = false; } else if (_stricmp(String,"default") == 0) { LoadDefault(Index,Value); return false; } else { WriteTraceF(TraceError,__FUNCTION__ ": Invalid Yes/No setting value (Section: %s Key: %s Value: %s)",m_SectionIdent->c_str(),String,m_KeyName.c_str(),strValue.c_str()); LoadDefault(Index,Value); return false; } return true; }
void CEeprom::LoadEeprom() { CPath FileName; DWORD dwRead; memset(m_EEPROM,0xFF,sizeof(m_EEPROM)); FileName.SetDriveDirectory( g_Settings->LoadStringVal(Directory_NativeSave).c_str()); FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str()); FileName.SetExtension("eep"); if (!FileName.DirectoryExists()) { FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError()); g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM)); return; } SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL); }
void CAudio::SetFrequency (DWORD Dacrate, DWORD System) { WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,g_Reg->AI_BITRATE_REG); DWORD Frequency; switch (System) { case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break; case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break; default: Frequency = 48681812 / (Dacrate + 1); break; } //nBlockAlign = 16 / 8 * 2; m_BytesPerSecond = Frequency * 4; m_BytesPerSecond = 194532; m_BytesPerSecond = 128024; m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60; }
void CAudio::InterruptTimerDone ( void ) { WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff); if (m_SecondBuff != 0) { g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false); m_SecondBuff = 0; } else { if (g_Reg->m_AudioIntrReg == 0) { g_System->SyncToAudio(); } g_Reg->MI_INTR_REG |= MI_INTR_AI; g_Reg->CheckInterrupts(); m_Status &= ~ai_full; } WriteTrace(TraceAudio,__FUNCTION__ ": Done"); }
void CPlugin::UnloadPlugin() { WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): unloading",PluginType()); memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); if (m_hDll != NULL) { UnloadPluginDetails(); FreeLibrary((HMODULE)m_hDll); m_hDll = NULL; } DllAbout = NULL; CloseDLL = NULL; RomOpen = NULL; RomClosed = NULL; PluginOpened = NULL; DllConfig = NULL; SetSettingInfo = NULL; SetSettingInfo2 = NULL; SetSettingInfo3 = NULL; }
void CAudio::LenChanged() { WriteTraceF(TraceAudio,__FUNCTION__ ": Start (g_Reg->AI_LEN_REG = %d)",g_Reg->AI_LEN_REG); if (g_Reg->AI_LEN_REG != 0) { if (g_Reg->AI_LEN_REG >= 0x40000) { WriteTraceF(TraceAudio,__FUNCTION__ ": *** Ignoring Write, To Large (%X)",g_Reg->AI_LEN_REG); } else { m_Status |= ai_busy; DWORD AudioLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt); if (m_SecondBuff == 0) { if (AudioLeft == 0) { WriteTraceF(TraceAudio, __FUNCTION__ ": Set Timer AI_LEN_REG: %d m_CountsPerByte: %d", g_Reg->AI_LEN_REG, m_CountsPerByte); g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt, g_Reg->AI_LEN_REG * m_CountsPerByte, false); } else { WriteTraceF(TraceAudio, __FUNCTION__ ": Increasing Second Buffer (m_SecondBuff %d Increase: %d)", m_SecondBuff, g_Reg->AI_LEN_REG); m_SecondBuff += g_Reg->AI_LEN_REG; m_Status |= ai_full; } } else { g_Notify->BreakPoint(__FILEW__, __LINE__); } } } else { WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0"); g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy); g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt); m_SecondBuff = 0; m_Status = 0; } if (g_Plugins->Audio()->AiLenChanged != NULL) { g_Plugins->Audio()->AiLenChanged(); } WriteTraceF(TraceAudio,__FUNCTION__ ": Done"); }
bool CSram::LoadSram() { CPath FileName; FileName.SetDriveDirectory( g_Settings->LoadString(Directory_NativeSave).c_str()); FileName.SetName(g_Settings->LoadString(Game_GameName).c_str()); FileName.SetExtension("sra"); if (!FileName.DirectoryExists()) { FileName.CreateDirectory(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError()); return false; } SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); return true; }
void CTLB::WriteEntry (int index, bool Random) { int FastIndx; WriteTraceF(TraceTLB,__FUNCTION__ ": %02d %d %08X %08X %08X %08X ",index,Random,g_Reg->PAGE_MASK_REGISTER,g_Reg->ENTRYHI_REGISTER,g_Reg->ENTRYLO0_REGISTER,g_Reg->ENTRYLO1_REGISTER); //Check to see if entry is unmapping it self if (m_tlb[index].EntryDefined) { FastIndx = index << 1; if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART && *_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND && m_FastTlb[FastIndx].ValidEntry && m_FastTlb[FastIndx].VALID) { WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].VEND); return; } if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx + 1].VSTART && *_PROGRAM_COUNTER < m_FastTlb[FastIndx + 1].VEND && m_FastTlb[FastIndx + 1].ValidEntry && m_FastTlb[FastIndx + 1].VALID) { WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx + 1].VSTART,m_FastTlb[FastIndx + 1].VEND); return; } } //Reset old addresses if (m_tlb[index].EntryDefined) { for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { if (!m_FastTlb[FastIndx].ValidEntry) { continue; } if (!m_FastTlb[FastIndx].VALID) { continue; } if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER && m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_REGISTER) { if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER) { continue; } if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER) { continue; } } m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); } } //fill in m_tlb entry m_tlb[index].PageMask.Value = g_Reg->PAGE_MASK_REGISTER; m_tlb[index].EntryHi.Value = g_Reg->ENTRYHI_REGISTER; m_tlb[index].EntryLo0.Value = g_Reg->ENTRYLO0_REGISTER; m_tlb[index].EntryLo1.Value = g_Reg->ENTRYLO1_REGISTER; m_tlb[index].EntryDefined = true; SetupTLB_Entry(index,Random); m_CB->TLB_Changed(); }
DWORD CAudio::GetStatus() { WriteTraceF(TraceAudio,__FUNCTION__ ": m_Status = %X",m_Status); return m_Status; }
void CPlugins::CreatePlugins( void ) { if (m_Gfx == NULL) { m_GfxFile = g_Settings->LoadString(Game_Plugin_Gfx); CPath GfxPluginFile(m_PluginDir.c_str(),m_GfxFile.c_str()); WriteTraceF(TraceGfxPlugin,__FUNCTION__ ": GFX Loading (%s): Starting",(LPCTSTR)GfxPluginFile); m_Gfx = new CGfxPlugin(GfxPluginFile); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": GFX Loading Done"); WriteTraceF(TraceGfxPlugin,__FUNCTION__ ": GFX Current Ver: %s",m_Gfx->PluginName().c_str()); g_Settings->SaveString(Plugin_GFX_CurVer,m_Gfx->PluginName().c_str()); } if (m_Audio == NULL) { m_AudioFile = g_Settings->LoadString(Game_Plugin_Audio); CPath PluginFile(m_PluginDir.c_str(),m_AudioFile.c_str()); WriteTraceF(TraceDebug,__FUNCTION__ ": Loading Audio Plugin (%s): Starting",(LPCTSTR)PluginFile); m_Audio = new CAudioPlugin(PluginFile); WriteTrace(TraceDebug,__FUNCTION__ ": Loading Audio Plugin Done"); g_Settings->SaveString(Plugin_AUDIO_CurVer,m_Audio->PluginName().c_str()); } if (m_RSP == NULL) { m_RSPFile = g_Settings->LoadString(Game_Plugin_RSP); CPath RspPluginFile(m_PluginDir.c_str(),m_RSPFile.c_str()); WriteTraceF(TraceRSP,__FUNCTION__ "(%s): RSP Loading",(LPCTSTR)RspPluginFile); m_RSP = new CRSP_Plugin(RspPluginFile); WriteTrace(TraceRSP,__FUNCTION__ ": RSP Loading Done"); WriteTraceF(TraceRSP,__FUNCTION__ ": RSP Current Ver: %s",m_RSP->PluginName().c_str()); g_Settings->SaveString(Plugin_RSP_CurVer,m_RSP->PluginName().c_str()); //Enable debugger if (m_RSP->EnableDebugging) { WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging starting"); m_RSP->EnableDebugging(bHaveDebugger()); WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging done"); } } if (m_Control == NULL) { m_ControlFile = g_Settings->LoadString(Game_Plugin_Controller); CPath PluginFile(m_PluginDir.c_str(),m_ControlFile.c_str()); WriteTraceF(TraceDebug,__FUNCTION__ ": Loading (%s): Starting",(LPCTSTR)PluginFile); m_Control = new CControl_Plugin(PluginFile); WriteTrace(TraceDebug,__FUNCTION__ ": Loading Done"); g_Settings->SaveString(Plugin_CONT_CurVer,m_Control->PluginName().c_str()); } /* Reset(PLUGIN_TYPE_GFX); Reset(PLUGIN_TYPE_AUDIO); Reset(PLUGIN_TYPE_RSP); Reset(PLUGIN_TYPE_CONTROLLER); */ if (bHaveDebugger()) { g_Notify->RefreshMenu(); } }
void CAudio::BusyTimerDone() { WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff); g_Notify->BreakPoint(__FILEW__,__LINE__); m_Status &= ~ai_busy; }
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 (!CPluginList::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 *)(DWORD)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); DllAbout = (void (__cdecl *)(HWND)) 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 = (unsigned int (*)( 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 *, DWORD))&CSettings::RegisterSetting; info.GetSetting = (unsigned int(*)(void *, int))&CSettings::GetSetting; info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz; info.SetSetting = (void(*)(void *, int, unsigned int))&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; } WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Functions loaded",PluginType()); if (PluginOpened) { WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Plugin Opened",PluginType()); PluginOpened(); WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Plugin Opened",PluginType()); } return true; }
void LoadMempak (int Control) { CPath FileName; DWORD dwRead; stdstr MempakName; bool bFormatMempak = false; MempakName.Format("%s_Cont_%d", g_Settings->LoadString(Game_GameName).c_str(), Control + 1); FileName.SetDriveDirectory(g_Settings->LoadString(Directory_NativeSave).c_str()); FileName.SetName(MempakName.c_str()); FileName.SetExtension("mpk"); if (!FileName.Exists()) { bFormatMempak = true; if (!FileName.DirectoryExists()) { FileName.CreateDirectory(); } BYTE Initialize[] = { 0x81,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B, 0x1C,0x1D,0x1E,0x1F, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x71,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, }; memcpy(&Mempaks[Control][0], Initialize, 0x110); for (int count = 0x110; count < 0x8000; count += 2) { Mempaks[Control][count] = 0x00; Mempaks[Control][count + 1] = 0x03; } } hMempakFile[Control] = CreateFile(FileName, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (hMempakFile[Control] == INVALID_HANDLE_VALUE) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), lastError = %X",(LPCTSTR)FileName, GetLastError()); return; } SetFilePointer(hMempakFile[Control], 0, NULL, FILE_BEGIN); if (bFormatMempak) { WriteFile(hMempakFile[Control], Mempaks[Control], 0x8000, &dwRead, NULL); } else { ReadFile(hMempakFile[Control], Mempaks[Control], 0x8000, &dwRead, NULL); } }
bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuID) { switch (MenuID) { case ID_FILE_OPEN_ROM: { stdstr File = g_BaseSystem->ChooseFileToOpen(hWnd); if (File.length() > 0) { g_BaseSystem->RunFileImage(File.c_str()); } } break; case ID_FILE_ROM_INFO: { g_BaseSystem->DisplayRomInfo(hWnd); } break; case ID_FILE_STARTEMULATION: _Gui->SaveWindowLoc(); //Before we go and create the new system, ensure the previous one has been closed CN64System::CloseSystem(); //Ok now g_BaseSystem should definitely be clean for initialization g_BaseSystem = new CN64System(g_Plugins, false); //Now we have created again, we can start up emulation g_BaseSystem->StartEmulation(true); break; case ID_FILE_ENDEMULATION: WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ENDEMULATION"); CN64System::CloseSystem(); _Gui->SaveWindowLoc(); break; case ID_FILE_ROMDIRECTORY: WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 1"); _Gui->SelectRomDir(); WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 2"); _Gui->RefreshMenu(); WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 3"); break; case ID_FILE_REFRESHROMLIST: _Gui->RefreshRomBrowser(); break; case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; case ID_SYSTEM_RESET_SOFT: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESET_SOFT"); g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Soft); break; case ID_SYSTEM_RESET_HARD: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESET_HARD"); g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Hard); break; case ID_SYSTEM_PAUSE: _Gui->SaveWindowLoc(); WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_PAUSE"); if (g_Settings->LoadBool(GameRunning_CPU_Paused)) { g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); } else { g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); } WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_PAUSE 1"); break; case ID_SYSTEM_BITMAP: { stdstr Dir(g_Settings->LoadString(Directory_SnapShot)); WriteTraceF(TraceGfxPlugin,__FUNCTION__ ": CaptureScreen(%s): Starting",Dir.c_str()); g_Plugins->Gfx()->CaptureScreen(Dir.c_str()); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": CaptureScreen: Done"); } break; case ID_SYSTEM_LIMITFPS: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_LIMITFPS"); g_Settings->SaveBool(GameRunning_LimitFPS,!g_Settings->LoadBool(GameRunning_LimitFPS)); WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_LIMITFPS 1"); break; case ID_SYSTEM_SAVE: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_SAVE"); g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); break; case ID_SYSTEM_SAVEAS: { char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; char Directory[255], SaveFile[255]; OPENFILENAME openfilename; memset(&SaveFile, 0, sizeof(SaveFile)); memset(&openfilename, 0, sizeof(openfilename)); g_Settings->LoadString(Directory_LastSave, Directory,sizeof(Directory)); openfilename.lStructSize = sizeof( openfilename ); openfilename.hwndOwner = (HWND)hWnd; openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; openfilename.lpstrFile = SaveFile; openfilename.lpstrInitialDir = Directory; openfilename.nMaxFile = MAX_PATH; openfilename.Flags = OFN_HIDEREADONLY; g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame); if (GetSaveFileName (&openfilename)) { _splitpath( SaveFile, drive, dir, fname, ext ); if (_stricmp(ext, ".pj") == 0 || _stricmp(ext, ".zip") == 0) { _makepath( SaveFile, drive, dir, fname, NULL ); _splitpath( SaveFile, drive, dir, fname, ext ); if (_stricmp(ext, ".pj") == 0) { _makepath( SaveFile, drive, dir, fname, NULL ); } } g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); char SaveDir[MAX_PATH]; _makepath( SaveDir, drive, dir, NULL, NULL ); g_Settings->SaveString(Directory_LastSave,SaveDir); g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); } g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SaveGame); } break; case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESTORE"); g_BaseSystem->ExternalEvent(SysEvent_LoadMachineState); break; case ID_SYSTEM_LOAD: { char Directory[255], SaveFile[255]; OPENFILENAME openfilename; memset(&SaveFile, 0, sizeof(SaveFile)); memset(&openfilename, 0, sizeof(openfilename)); g_Settings->LoadString(Directory_LastSave, Directory,sizeof(Directory)); openfilename.lStructSize = sizeof( openfilename ); openfilename.hwndOwner = (HWND)hWnd; openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; openfilename.lpstrFile = SaveFile; openfilename.lpstrInitialDir = Directory; openfilename.nMaxFile = MAX_PATH; openfilename.Flags = OFN_HIDEREADONLY; g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); if (GetOpenFileName (&openfilename)) { g_Settings->SaveString(GameRunning_InstantSaveFile,SaveFile); char SaveDir[MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; _splitpath( SaveFile, drive, dir, fname, ext ); _makepath( SaveDir, drive, dir, NULL, NULL ); g_Settings->SaveString(Directory_LastSave,SaveDir); g_System->LoadState(); } g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_LoadGame); } break; case ID_SYSTEM_CHEAT: { g_BaseSystem->SelectCheats(hWnd); } break; case ID_SYSTEM_GSBUTTON: g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed); break; case ID_OPTIONS_DISPLAY_FR: g_Settings->SaveBool(UserInterface_DisplayFrameRate,!g_Settings->LoadBool(UserInterface_DisplayFrameRate)); break; case ID_OPTIONS_CHANGE_FR: switch (g_Settings->LoadDword(UserInterface_FrameDisplayType)) { case FR_VIs: g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_DLs); break; case FR_DLs: g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_PERCENT); break; default: g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_VIs); } break; case ID_OPTIONS_INCREASE_SPEED: g_BaseSystem->IncreaseSpeed(); break; case ID_OPTIONS_DECREASE_SPEED: g_BaseSystem->DecreaeSpeed(); break; case ID_OPTIONS_FULLSCREEN: g_BaseSystem->ExternalEvent(SysEvent_ChangingFullScreen); break; case ID_OPTIONS_FULLSCREEN2: if (g_Settings->LoadBool(UserInterface_InFullScreen)) { WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN a"); _Gui->MakeWindowOnTop(false); Notify().SetGfxPlugin(NULL); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Starting"); g_Plugins->Gfx()->ChangeWindow(); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Done"); ShowCursor(true); _Gui->ShowStatusBar(true); _Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); g_Settings->SaveBool(UserInterface_InFullScreen,(DWORD)false); } else { WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b"); ShowCursor(false); WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1"); _Gui->ShowStatusBar(false); WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2"); try { WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Starting"); g_Plugins->Gfx()->ChangeWindow(); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Done"); } catch (...) { WriteTrace(TraceError,__FUNCTION__ ": Exception when going to full screen"); char Message[600]; sprintf(Message,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); MessageBox(NULL,Message,"Exception",MB_OK); } WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 4"); _Gui->MakeWindowOnTop(false); WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 5"); Notify().SetGfxPlugin(g_Plugins->Gfx()); WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 3"); g_Settings->SaveBool(UserInterface_InFullScreen,true); WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 6"); } WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN 1"); break; case ID_OPTIONS_ALWAYSONTOP: if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { g_Settings->SaveBool(UserInterface_AlwaysOnTop,false); _Gui->MakeWindowOnTop(false); } else { g_Settings->SaveBool(UserInterface_AlwaysOnTop,true); _Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); } break; case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_RSP); break; case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_GFX"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_GFX); break; case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_AUDIO"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_AUDIO); break; case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_CONT"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_CONTROLLER); break; case ID_OPTIONS_CPU_USAGE: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CPU_USAGE"); if (g_Settings->LoadBool(UserInterface_ShowCPUPer)) { g_Settings->SaveBool(UserInterface_ShowCPUPer,false); g_Notify->DisplayMessage(0,L""); } else { g_Settings->SaveBool(UserInterface_ShowCPUPer,true); } break; case ID_OPTIONS_SETTINGS: { CSettingConfig SettingConfig; SettingConfig.Display(hWnd); } break; case ID_PROFILE_PROFILE: g_Settings->SaveBool(Debugger_ProfileCode,!g_Settings->LoadBool(Debugger_ProfileCode)); g_BaseSystem->ExternalEvent(SysEvent_Profile_StartStop); break; case ID_PROFILE_RESETCOUNTER: g_BaseSystem->ExternalEvent(SysEvent_Profile_ResetLogs); break; case ID_PROFILE_GENERATELOG: g_BaseSystem->ExternalEvent(SysEvent_Profile_GenerateLogs); break; case ID_DEBUG_SHOW_TLB_MISSES: g_Settings->SaveBool(Debugger_ShowTLBMisses,!g_Settings->LoadBool(Debugger_ShowTLBMisses)); break; case ID_DEBUG_SHOW_UNHANDLED_MEM: g_Settings->SaveBool(Debugger_ShowUnhandledMemory,!g_Settings->LoadBool(Debugger_ShowUnhandledMemory)); break; case ID_DEBUG_SHOW_PIF_ERRORS: g_Settings->SaveBool(Debugger_ShowPifErrors,!g_Settings->LoadBool(Debugger_ShowPifErrors)); break; case ID_DEBUG_SHOW_DLIST_COUNT: g_Notify->DisplayMessage(0,L""); g_Settings->SaveBool(Debugger_ShowDListAListCount,!g_Settings->LoadBool(Debugger_ShowDListAListCount)); break; case ID_DEBUG_SHOW_RECOMP_MEM_SIZE: g_Notify->DisplayMessage(0,L""); g_Settings->SaveBool(Debugger_ShowRecompMemSize,!g_Settings->LoadBool(Debugger_ShowRecompMemSize)); break; case ID_DEBUG_SHOW_DIV_BY_ZERO: g_Settings->SaveBool(Debugger_ShowDivByZero,!g_Settings->LoadBool(Debugger_ShowDivByZero)); break; case ID_DEBUG_GENERATE_LOG_FILES: g_Settings->SaveBool(Debugger_GenerateLogFiles,!g_Settings->LoadBool(Debugger_GenerateLogFiles)); break; case ID_DEBUG_DISABLE_GAMEFIX: g_Settings->SaveBool(Debugger_DisableGameFixes,!g_Settings->LoadBool(Debugger_DisableGameFixes)); break; case ID_DEBUGGER_APPLOG_ERRORS: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceError) != 0) { LogLevel &= ~TraceError; } else { LogLevel |= TraceError; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_SETTINGS: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceSettings) != 0) { LogLevel &= ~TraceSettings; } else { LogLevel |= TraceSettings; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_RECOMPILER: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceRecompiler) != 0) { LogLevel &= ~TraceRecompiler; } else { LogLevel |= TraceRecompiler; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_RSP: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceRSP) != 0) { LogLevel &= ~TraceRSP; } else { LogLevel |= TraceRSP; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_TLB: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceTLB) != 0) { LogLevel &= ~TraceTLB; } else { LogLevel |= TraceTLB; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_GFX_PLUGIN: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceGfxPlugin) != 0) { LogLevel &= ~TraceGfxPlugin; } else { LogLevel |= TraceGfxPlugin; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_DEBUG: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceDebug) != 0) { LogLevel &= ~TraceDebug; } else { LogLevel |= TraceDebug; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_AUDIO_EMU: { DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); if ((LogLevel & TraceAudio) != 0) { LogLevel &= ~TraceAudio; } else { LogLevel |= TraceAudio; } g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); } break; case ID_DEBUGGER_APPLOG_FLUSH: g_Settings->SaveBool(Debugger_AppLogFlush,!g_Settings->LoadBool(Debugger_AppLogFlush)); break; case ID_DEBUGGER_LOGOPTIONS: _Gui->EnterLogOptions(); break; case ID_DEBUGGER_GENERATELOG: g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog)); break; case ID_DEBUGGER_DUMPMEMORY: g_BaseSystem->Debug_ShowMemoryDump(); break; case ID_DEBUGGER_SEARCHMEMORY: g_BaseSystem->Debug_ShowMemorySearch(); break; case ID_DEBUGGER_MEMORY: g_BaseSystem->Debug_ShowMemoryWindow(); break; case ID_DEBUGGER_TLBENTRIES: g_BaseSystem->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; case ID_DEBUGGER_INTERRUPT_VI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_VI); break; case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_CURRENT_SAVE_DEFAULT: Notify().DisplayMessage(3,L"Save Slot (%s) selected",GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); g_Settings->SaveDword(Game_CurrentSaveState,(DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); break; case ID_CURRENT_SAVE_1: case ID_CURRENT_SAVE_2: case ID_CURRENT_SAVE_3: case ID_CURRENT_SAVE_4: case ID_CURRENT_SAVE_5: case ID_CURRENT_SAVE_6: case ID_CURRENT_SAVE_7: case ID_CURRENT_SAVE_8: case ID_CURRENT_SAVE_9: case ID_CURRENT_SAVE_10: Notify().DisplayMessage(3,L"Save Slot (%s) selected",GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()); g_Settings->SaveDword(Game_CurrentSaveState,(DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); break; case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; case ID_HELP_HOMEPAGE: ShellExecute(NULL, "open", "http://www.pj64-emu.com", NULL, NULL, SW_SHOWMAXIMIZED); break; case ID_HELP_ABOUT: _Gui->AboutBox(); break; case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break; default: if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END) { stdstr FileName; if (g_Settings->LoadStringIndex(File_RecentGameFileIndex,MenuID - ID_RECENT_ROM_START,FileName) && FileName.length() > 0) { g_BaseSystem->RunFileImage(FileName.c_str()); } } if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) { int Offset = MenuID - ID_RECENT_DIR_START; stdstr Dir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex,Offset); if (Dir.length() > 0) { g_Settings->SaveString(Directory_Game,Dir.c_str()); g_Notify->AddRecentDir(Dir.c_str()); _Gui->RefreshMenu(); if (_Gui->RomBrowserVisible()) { _Gui->RefreshRomBrowser(); } } } if (MenuID >= ID_LANG_START && MenuID < ID_LANG_END) { MENUITEMINFOW menuinfo; wchar_t String[300]; menuinfo.cbSize = sizeof(MENUITEMINFO); menuinfo.fMask = MIIM_TYPE; menuinfo.fType = MFT_STRING; menuinfo.dwTypeData = String; menuinfo.cch = sizeof(String); GetMenuItemInfoW((HMENU)m_MenuHandle,MenuID,FALSE,&menuinfo); //See if the language has changed, if not do nothing //Set the language g_Lang->SetLanguage(String); _Gui->ResetRomBrowserColomuns(); break; } return false; } return true; }
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; } } }
LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR ) { CListNotify *pListNotify = reinterpret_cast<CListNotify *>( lpNMHDR ); int LineNumber = pListNotify->m_nItem; int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) { Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); } if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) { Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); } if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) { Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); } LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem); int Finish = strlen(strValue); if (Finish > 8) { Finish = 8; } DWORD Value = 0; for (int i = 0; i < Finish; i++) { Value = (Value << 4); if (strValue[i] <= '9' && strValue[i] >= '0') { Value |= strValue[i] - '0'; } else if (strValue[i] <= 'f' && strValue[i] >= 'a') { Value |= strValue[i] - 'a' + 10; } else if (strValue[i] <= 'F' && strValue[i] >= 'A') { Value |= strValue[i] - 'A' + 10; } } if (m_CurrentData[Pos] == Value) { return 0; } if (m_CompareStartLoc != m_DataStartLoc || m_CompareVAddrr != m_DataVAddrr) { // copy current data for change comparison m_CompareStartLoc = m_DataStartLoc; m_CompareVAddrr = m_DataVAddrr; memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); } m_CompareData[Pos] = m_CurrentData[Pos]; m_CurrentData[Pos] = (BYTE)Value; //sb if ( m_DataVAddrr ) { if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value)) { WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); } } else { if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value)) { WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); } } Insert_MemoryLineDump(LineNumber); return 0; }
stdstr FileVersionInfo( LPCTSTR Info, LPCTSTR FileName ) { stdstr Result; if(FileName) { if(_tcslen(FileName) != 0) { DWORD dwHandle = 0; DWORD Size = GetFileVersionInfoSize((LPSTR)FileName,&dwHandle); if ( Size == 0) { //WriteTraceF(TraceError,_T("FileVersionInfo(%s, %s): GetFileVersionInfoSize failed, error (%s)"),Info,FileName,BaseException::GetLastErrorDescription(GetLastError()).c_str()); return TEXT(""); } BYTE * Array = new BYTE [Size+(1*sizeof(TCHAR))]; if(Array) { memset(Array, 0, Size+(1*sizeof(TCHAR))); try { if (!GetFileVersionInfo((LPSTR)FileName,0,Size,Array)) { //WriteTraceF(TraceError,_T("FileVersionInfo(%s, %s): GetFileVersionInfo(%d) failed, error (%s)"),Info,FileName,Size,BaseException::GetLastErrorDescription(GetLastError()).c_str()); delete [] Array; return _T(""); } } catch (...) { WriteTrace(TraceError,_T("Unhandled exception in FileVersionInfo (1)")); delete [] Array; return _T(""); } try { Result = ReadVersionInfo(Array,Info); if(!Result.empty()) { if (strcmp(Info,VERSION_PRODUCT_VERSION) == 0) { Result.Replace(" ",""); } } else { WriteTraceF(TraceError,_T("FileVersionInfo(%s), ReadVersionInfo() failed"), FileName); } } catch (...) { WriteTrace(TraceError,_T("Unhandled exception in FileVersionInfo (2)")); delete [] Array; return _T(""); } delete [] Array; } else { WriteTraceF(TraceError,_T("Failed to allocate %d bytes"), Size+(1*sizeof(TCHAR))); } } else { WriteTraceF(TraceError,_T("FileVersionInfo received a pointer to an empty string")); } } else { WriteTraceF(TraceError,_T("FileVersionInfo received NULL pointer")); } return Result; }