Fix trailing whitespaces in all files where some were added

This commit is contained in:
Pierre Bourdon 2013-08-25 02:49:58 +02:00
parent 987f4945b5
commit 73be79f4e0
20 changed files with 395 additions and 398 deletions

View File

@ -569,11 +569,8 @@ endif()
include(FindLibUSB OPTIONAL) include(FindLibUSB OPTIONAL)
if(LIBUSB_FOUND) if(LIBUSB_FOUND)
message("Using shared LibUSB") message("Using shared LibUSB")
add_definitions(-D__LIBUSB__) add_definitions(-D__LIBUSB__)
include_directories(${LIBUSB_INCLUDE_DIR}) include_directories(${LIBUSB_INCLUDE_DIR})
else(LIBUSB_FOUND)
endif(LIBUSB_FOUND) endif(LIBUSB_FOUND)
set(SFML_FIND_VERSION TRUE) set(SFML_FIND_VERSION TRUE)
@ -665,7 +662,7 @@ if(NOT DISABLE_WX AND NOT ANDROID)
FIND_PACKAGE(wxWidgets COMPONENTS core aui adv) FIND_PACKAGE(wxWidgets COMPONENTS core aui adv)
if(wxWidgets_FOUND) if(wxWidgets_FOUND)
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
${wxWidgets_CONFIG_OPTIONS} --version ${wxWidgets_CONFIG_OPTIONS} --version
OUTPUT_VARIABLE wxWidgets_VERSION OUTPUT_VARIABLE wxWidgets_VERSION
@ -772,7 +769,7 @@ if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
endif() endif()
include(FindGettext) include(FindGettext)
if(GETTEXT_FOUND AND NOT DISABLE_WX) if(GETTEXT_FOUND AND NOT DISABLE_WX)
file(GLOB LINGUAS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Languages/po/*.po) file(GLOB LINGUAS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Languages/po/*.po)
GETTEXT_CREATE_TRANSLATIONS(Languages/po/dolphin-emu.pot ALL ${LINGUAS}) GETTEXT_CREATE_TRANSLATIONS(Languages/po/dolphin-emu.pot ALL ${LINGUAS})
endif() endif()
if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|Darwin")) if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|Darwin"))

View File

@ -75,7 +75,7 @@ void SettingsHandler::Decrypt()
{ {
const u8 *str = m_buffer; const u8 *str = m_buffer;
while (*str != 0) while (*str != 0)
{ {
if (m_position >= SETTINGS_SIZE) if (m_position >= SETTINGS_SIZE)
return; return;
decoded.push_back((u8)(m_buffer[m_position] ^ m_key)); decoded.push_back((u8)(m_buffer[m_position] ^ m_key));

View File

@ -35,7 +35,7 @@ void CBoot::RunFunction(u32 _iAddr)
} }
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// GameCube Bootstrap 2 HLE: // GameCube Bootstrap 2 HLE:
// copy the apploader to 0x81200000 // copy the apploader to 0x81200000
// execute the apploader, function by function, using the above utility. // execute the apploader, function by function, using the above utility.
bool CBoot::EmulatedBS2_GC() bool CBoot::EmulatedBS2_GC()
@ -119,7 +119,7 @@ bool CBoot::EmulatedBS2_GC()
DEBUG_LOG(MASTER_LOG, "Call iAppLoaderInit"); DEBUG_LOG(MASTER_LOG, "Call iAppLoaderInit");
PowerPC::ppcState.gpr[3] = 0x81300000; PowerPC::ppcState.gpr[3] = 0x81300000;
RunFunction(iAppLoaderInit); RunFunction(iAppLoaderInit);
// iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem). // iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem).
// To give you an idea about where the stuff is located on the disc take a look at yagcd // To give you an idea about where the stuff is located on the disc take a look at yagcd
// ch 13. // ch 13.
@ -135,7 +135,7 @@ bool CBoot::EmulatedBS2_GC()
u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004);
u32 iLength = Memory::ReadUnchecked_U32(0x81300008); u32 iLength = Memory::ReadUnchecked_U32(0x81300008);
u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c); u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c);
INFO_LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset, iRamAddress, iLength); INFO_LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset, iRamAddress, iLength);
DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength);
@ -151,7 +151,7 @@ bool CBoot::EmulatedBS2_GC()
// Load patches // Load patches
std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); std::string gameID = VolumeHandler::GetVolume()->GetUniqueID();
PatchEngine::LoadPatches(gameID.c_str()); PatchEngine::LoadPatches(gameID.c_str());
PowerPC::ppcState.DebugCount = 0; PowerPC::ppcState.DebugCount = 0;
// If we have any patches that need to be applied very early, here's a good place // If we have any patches that need to be applied very early, here's a good place
@ -167,7 +167,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
// Write the 256 byte setting.txt to memory. // Write the 256 byte setting.txt to memory.
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING); std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
std::string area, model, code, video, game; std::string area, model, code, video, game;
switch((DiscIO::IVolume::ECountry)_CountryCode) switch((DiscIO::IVolume::ECountry)_CountryCode)
{ {
@ -176,8 +176,8 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
video = "NTSC"; video = "NTSC";
game = "KR"; game = "KR";
code = "LKH"; code = "LKH";
break; break;
case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_TAIWAN:
// TODO: Determine if Taiwan have their own specific settings. // TODO: Determine if Taiwan have their own specific settings.
case DiscIO::IVolume::COUNTRY_JAPAN: case DiscIO::IVolume::COUNTRY_JAPAN:
area = "JPN"; area = "JPN";
@ -221,7 +221,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
} }
File::Delete(settings_Filename); File::Delete(settings_Filename);
} }
if (serno.empty() || serno == "000000000") if (serno.empty() || serno == "000000000")
{ {
serno = gen.generateSerialNumber(); serno = gen.generateSerialNumber();
@ -246,10 +246,10 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
{ {
File::IOFile settingsFileHandle(settings_Filename, "wb"); File::IOFile settingsFileHandle(settings_Filename, "wb");
if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE)) if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
{ {
PanicAlertT("SetupWiiMem: Cant create setting file"); PanicAlertT("SetupWiiMem: Cant create setting file");
return false; return false;
} }
Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE); Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
@ -310,7 +310,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
Memory::Write_U16(0x0000, 0x000030e0); // PADInit Memory::Write_U16(0x0000, 0x000030e0); // PADInit
Memory::Write_U32(0x80000000, 0x00003184); // GameID Address Memory::Write_U32(0x80000000, 0x00003184); // GameID Address
// Fake the VI Init of the IPL // Fake the VI Init of the IPL
Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC); Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC);
// Clear exception handler. Why? Don't we begin with only zeros? // Clear exception handler. Why? Don't we begin with only zeros?
@ -322,7 +322,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
} }
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// Wii Bootstrap 2 HLE: // Wii Bootstrap 2 HLE:
// copy the apploader to 0x81200000 // copy the apploader to 0x81200000
// execute the apploader // execute the apploader
bool CBoot::EmulatedBS2_Wii() bool CBoot::EmulatedBS2_Wii()
@ -339,12 +339,12 @@ bool CBoot::EmulatedBS2_Wii()
// This is some kind of consistency check that is compared to the 0x00 // This is some kind of consistency check that is compared to the 0x00
// values as the game boots. This location keep the 4 byte ID for as long // values as the game boots. This location keep the 4 byte ID for as long
// as the game is running. The 6 byte ID at 0x00 is overwritten sometime // as the game is running. The 6 byte ID at 0x00 is overwritten sometime
// after this check during booting. // after this check during booting.
VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4); VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4);
// Execute the apploader // Execute the apploader
bool apploaderRan = false; bool apploaderRan = false;
if (VolumeHandler::IsValid() && VolumeHandler::IsWii()) if (VolumeHandler::IsValid() && VolumeHandler::IsWii())
{ {
UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr);
m_MSR.FP = 1; m_MSR.FP = 1;
@ -362,7 +362,7 @@ bool CBoot::EmulatedBS2_Wii()
// Load Apploader to Memory // Load Apploader to Memory
u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10);
u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14);
if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1))
{ {
ERROR_LOG(BOOT, "Invalid apploader. Probably your image is corrupted."); ERROR_LOG(BOOT, "Invalid apploader. Probably your image is corrupted.");
return false; return false;
@ -375,7 +375,7 @@ bool CBoot::EmulatedBS2_Wii()
u32 iAppLoaderFuncAddr = 0x80004000; u32 iAppLoaderFuncAddr = 0x80004000;
PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0;
PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4;
PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8;
RunFunction(iAppLoaderEntry); RunFunction(iAppLoaderEntry);
u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0);
u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4);
@ -383,14 +383,14 @@ bool CBoot::EmulatedBS2_Wii()
// iAppLoaderInit // iAppLoaderInit
DEBUG_LOG(BOOT, "Run iAppLoaderInit"); DEBUG_LOG(BOOT, "Run iAppLoaderInit");
PowerPC::ppcState.gpr[3] = 0x81300000; PowerPC::ppcState.gpr[3] = 0x81300000;
RunFunction(iAppLoaderInit); RunFunction(iAppLoaderInit);
// Let the apploader load the exe to memory. At this point I get an unknown IPC command // Let the apploader load the exe to memory. At this point I get an unknown IPC command
// (command zero) when I load Wii Sports or other games a second time. I don't notice // (command zero) when I load Wii Sports or other games a second time. I don't notice
// any side effects however. It's a little disconcerting however that Start after Stop // any side effects however. It's a little disconcerting however that Start after Stop
// behaves differently than the first Start after starting Dolphin. It means something // behaves differently than the first Start after starting Dolphin. It means something
// was not reset correctly. // was not reset correctly.
DEBUG_LOG(BOOT, "Run iAppLoaderMain"); DEBUG_LOG(BOOT, "Run iAppLoaderMain");
do do
{ {

View File

@ -105,7 +105,7 @@ std::string StopMessage(bool bMainThread, std::string Message)
bMainThread ? "Main Thread" : "Video Thread", Common::CurrentThreadId(), MemUsage().c_str(), Message.c_str()); bMainThread ? "Main Thread" : "Video Thread", Common::CurrentThreadId(), MemUsage().c_str(), Message.c_str());
} }
// //
bool PanicAlertToVideo(const char* text, bool yes_no) bool PanicAlertToVideo(const char* text, bool yes_no)
{ {
DisplayMessage(text, 3000); DisplayMessage(text, 3000);
@ -123,7 +123,7 @@ void DisplayMessage(const char *message, int time_in_ms)
return; return;
g_video_backend->Video_AddMessage(message, time_in_ms); g_video_backend->Video_AddMessage(message, time_in_ms);
if (_CoreParameter.bRenderToMain && if (_CoreParameter.bRenderToMain &&
SConfig::GetInstance().m_InterfaceStatusbar) SConfig::GetInstance().m_InterfaceStatusbar)
{ {
@ -202,7 +202,7 @@ bool Init()
Host_UpdateMainFrame(); // Disable any menus or buttons at boot Host_UpdateMainFrame(); // Disable any menus or buttons at boot
g_aspect_wide = _CoreParameter.bWii; g_aspect_wide = _CoreParameter.bWii;
if (g_aspect_wide) if (g_aspect_wide)
{ {
IniFile gameIni; IniFile gameIni;
gameIni.Load(_CoreParameter.m_strGameIni.c_str()); gameIni.Load(_CoreParameter.m_strGameIni.c_str());
@ -216,7 +216,7 @@ bool Init()
// within g_video_backend->Initialize() // within g_video_backend->Initialize()
g_pWindowHandle = Host_GetRenderHandle(); g_pWindowHandle = Host_GetRenderHandle();
// Start the emu thread // Start the emu thread
g_EmuThread = std::thread(EmuThread); g_EmuThread = std::thread(EmuThread);
return true; return true;
@ -254,12 +254,12 @@ void Stop() // - Hammertime!
// will continue concurrently with the rest of the commands // will continue concurrently with the rest of the commands
// in this function. We no longer rely on Postmessage. // in this function. We no longer rely on Postmessage.
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Wait for Video Loop to exit ...").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "Wait for Video Loop to exit ...").c_str());
g_video_backend->Video_ExitLoop(); g_video_backend->Video_ExitLoop();
} }
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping Emu thread ...").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping Emu thread ...").c_str());
g_EmuThread.join(); // Wait for emuthread to close. g_EmuThread.join(); // Wait for emuthread to close.
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Main Emu thread stopped").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "Main Emu thread stopped").c_str());
@ -273,7 +273,7 @@ void Stop() // - Hammertime!
// Close the trace file // Close the trace file
Core::StopTrace(); Core::StopTrace();
// Reload sysconf file in order to see changes committed during emulation // Reload sysconf file in order to see changes committed during emulation
if (_CoreParameter.bWii) if (_CoreParameter.bWii)
SConfig::GetInstance().m_SYSCONF->Reload(); SConfig::GetInstance().m_SYSCONF->Reload();
@ -311,7 +311,7 @@ void CpuThread()
g_bStarted = true; g_bStarted = true;
#ifdef USE_GDBSTUB #ifdef USE_GDBSTUB
if(_CoreParameter.iGDBPort > 0) if(_CoreParameter.iGDBPort > 0)
{ {
@ -320,12 +320,12 @@ void CpuThread()
gdb_break(); gdb_break();
} }
#endif #endif
// Enter CPU run loop. When we leave it - we are done. // Enter CPU run loop. When we leave it - we are done.
CCPU::Run(); CCPU::Run();
g_bStarted = false; g_bStarted = false;
if (!_CoreParameter.bCPUThread) if (!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup(); g_video_backend->Video_Cleanup();
@ -356,7 +356,7 @@ void FifoPlayerThread()
} }
g_bStarted = false; g_bStarted = false;
if(!_CoreParameter.bCPUThread) if(!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup(); g_video_backend->Video_Cleanup();
@ -379,7 +379,7 @@ void EmuThread()
Movie::Init(); Movie::Init();
HW::Init(); HW::Init();
if (!g_video_backend->Initialize(g_pWindowHandle)) if (!g_video_backend->Initialize(g_pWindowHandle))
{ {
@ -401,7 +401,7 @@ void EmuThread()
} }
Pad::Initialize(g_pWindowHandle); Pad::Initialize(g_pWindowHandle);
// Load and Init Wiimotes - only if we are booting in wii mode // Load and Init Wiimotes - only if we are booting in wii mode
if (g_CoreStartupParameter.bWii) if (g_CoreStartupParameter.bWii)
{ {
Wiimote::Initialize(g_pWindowHandle, !g_stateFileName.empty()); Wiimote::Initialize(g_pWindowHandle, !g_stateFileName.empty());
@ -410,7 +410,7 @@ void EmuThread()
for (unsigned int i = 0; i != MAX_BBMOTES; ++i) for (unsigned int i = 0; i != MAX_BBMOTES; ++i)
if (g_wiimote_sources[i]) if (g_wiimote_sources[i])
GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(true); GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(true);
} }
// The hardware is initialized. // The hardware is initialized.
@ -441,7 +441,7 @@ void EmuThread()
cpuThreadFunc = FifoPlayerThread; cpuThreadFunc = FifoPlayerThread;
else else
cpuThreadFunc = CpuThread; cpuThreadFunc = CpuThread;
// ENTER THE VIDEO THREAD LOOP // ENTER THE VIDEO THREAD LOOP
if (_CoreParameter.bCPUThread) if (_CoreParameter.bCPUThread)
{ {
@ -481,17 +481,17 @@ void EmuThread()
// Wait for g_cpu_thread to exit // Wait for g_cpu_thread to exit
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping CPU-GPU thread ...").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping CPU-GPU thread ...").c_str());
#ifdef USE_GDBSTUB #ifdef USE_GDBSTUB
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB ...").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB ...").c_str());
gdb_deinit(); gdb_deinit();
INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB stopped.").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB stopped.").c_str());
#endif #endif
g_cpu_thread.join(); g_cpu_thread.join();
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
if(_CoreParameter.bCPUThread) if(_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup(); g_video_backend->Video_Cleanup();
@ -501,7 +501,7 @@ void EmuThread()
// Stop audio thread - Actually this does nothing when using HLE // Stop audio thread - Actually this does nothing when using HLE
// emulation, but stops the DSP Interpreter when using LLE emulation. // emulation, but stops the DSP Interpreter when using LLE emulation.
DSP::GetDSPEmulator()->DSP_StopSoundStream(); DSP::GetDSPEmulator()->DSP_StopSoundStream();
// We must set up this flag before executing HW::Shutdown() // We must set up this flag before executing HW::Shutdown()
g_bHwInit = false; g_bHwInit = false;
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str()); INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
@ -576,7 +576,7 @@ void SaveScreenShot()
SetState(CORE_PAUSE); SetState(CORE_PAUSE);
g_video_backend->Video_Screenshot(GenerateScreenshotName().c_str()); g_video_backend->Video_Screenshot(GenerateScreenshotName().c_str());
if (!bPaused) if (!bPaused)
SetState(CORE_RUN); SetState(CORE_RUN);
} }
@ -698,7 +698,7 @@ void UpdateTitle()
u32 Speed = DrawnVideo * (100 * 1000) / (VideoInterface::TargetRefreshRate * ElapseTime); u32 Speed = DrawnVideo * (100 * 1000) / (VideoInterface::TargetRefreshRate * ElapseTime);
// Settings are shown the same for both extended and summary info // Settings are shown the same for both extended and summary info
std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC", std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC",
g_video_backend->GetName().c_str(), _CoreParameter.bDSPHLE ? "HLE" : "LLE"); g_video_backend->GetName().c_str(), _CoreParameter.bDSPHLE ? "HLE" : "LLE");
// Use extended or summary information. The summary information does not print the ticks data, // Use extended or summary information. The summary information does not print the ticks data,

View File

@ -30,7 +30,7 @@ SCoreStartupParameter::SCoreStartupParameter()
bJITPairedOff(false), bJITSystemRegistersOff(false), bJITPairedOff(false), bJITSystemRegistersOff(false),
bJITBranchOff(false), bJITProfiledReJIT(false), bJITBranchOff(false), bJITProfiledReJIT(false),
bJITILTimeProfiling(false), bJITILOutputIR(false), bJITILTimeProfiling(false), bJITILOutputIR(false),
bEnableFPRF(false), bEnableFPRF(false),
bCPUThread(true), bDSPThread(false), bDSPHLE(true), bCPUThread(true), bDSPThread(false), bDSPHLE(true),
bSkipIdle(true), bNTSC(false), bForceNTSCJ(false), bSkipIdle(true), bNTSC(false), bForceNTSCJ(false),
bHLE_BS2(true), bEnableCheats(false), bHLE_BS2(true), bEnableCheats(false),
@ -105,26 +105,26 @@ void SCoreStartupParameter::LoadDefaults()
m_strUniqueID = "00000000"; m_strUniqueID = "00000000";
} }
bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{ {
std::string Region(EUR_DIR); std::string Region(EUR_DIR);
switch (_BootBS2) switch (_BootBS2)
{ {
case BOOT_DEFAULT: case BOOT_DEFAULT:
{ {
bool bootDrive = cdio_is_cdrom(m_strFilename); bool bootDrive = cdio_is_cdrom(m_strFilename);
// Check if the file exist, we may have gotten it from a --elf command line // Check if the file exist, we may have gotten it from a --elf command line
// that gave an incorrect file name // that gave an incorrect file name
if (!bootDrive && !File::Exists(m_strFilename)) if (!bootDrive && !File::Exists(m_strFilename))
{ {
PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str()); PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str());
return false; return false;
} }
std::string Extension; std::string Extension;
SplitPath(m_strFilename, NULL, NULL, &Extension); SplitPath(m_strFilename, NULL, NULL, &Extension);
if (!strcasecmp(Extension.c_str(), ".gcm") || if (!strcasecmp(Extension.c_str(), ".gcm") ||
!strcasecmp(Extension.c_str(), ".iso") || !strcasecmp(Extension.c_str(), ".iso") ||
!strcasecmp(Extension.c_str(), ".wbfs") || !strcasecmp(Extension.c_str(), ".wbfs") ||
!strcasecmp(Extension.c_str(), ".ciso") || !strcasecmp(Extension.c_str(), ".ciso") ||
@ -147,48 +147,48 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
} }
m_strName = pVolume->GetName(); m_strName = pVolume->GetName();
m_strUniqueID = pVolume->GetUniqueID(); m_strUniqueID = pVolume->GetUniqueID();
// Check if we have a Wii disc // Check if we have a Wii disc
bWii = DiscIO::IsVolumeWiiDisc(pVolume); bWii = DiscIO::IsVolumeWiiDisc(pVolume);
switch (pVolume->GetCountry()) switch (pVolume->GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
bNTSC = true; bNTSC = true;
Region = USA_DIR; Region = USA_DIR;
break; break;
case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_KOREA: case DiscIO::IVolume::COUNTRY_KOREA:
// TODO: Should these have their own Region Dir? // TODO: Should these have their own Region Dir?
case DiscIO::IVolume::COUNTRY_JAPAN: case DiscIO::IVolume::COUNTRY_JAPAN:
bNTSC = true; bNTSC = true;
Region = JAP_DIR; Region = JAP_DIR;
break; break;
case DiscIO::IVolume::COUNTRY_EUROPE: case DiscIO::IVolume::COUNTRY_EUROPE:
case DiscIO::IVolume::COUNTRY_FRANCE: case DiscIO::IVolume::COUNTRY_FRANCE:
case DiscIO::IVolume::COUNTRY_ITALY: case DiscIO::IVolume::COUNTRY_ITALY:
case DiscIO::IVolume::COUNTRY_RUSSIA: case DiscIO::IVolume::COUNTRY_RUSSIA:
bNTSC = false; bNTSC = false;
Region = EUR_DIR; Region = EUR_DIR;
break; break;
default: default:
if (PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)." if (PanicYesNoT("Your GCM/ISO file seems to be invalid (invalid country)."
"\nContinue with PAL region?")) "\nContinue with PAL region?"))
{ {
bNTSC = false; bNTSC = false;
Region = EUR_DIR; Region = EUR_DIR;
break; break;
}else return false; }else return false;
} }
delete pVolume; delete pVolume;
} }
else if (!strcasecmp(Extension.c_str(), ".elf")) else if (!strcasecmp(Extension.c_str(), ".elf"))
{ {
bWii = CBoot::IsElfWii(m_strFilename.c_str()); bWii = CBoot::IsElfWii(m_strFilename.c_str());
Region = USA_DIR; Region = USA_DIR;
m_BootType = BOOT_ELF; m_BootType = BOOT_ELF;
bNTSC = true; bNTSC = true;
} }
@ -196,7 +196,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{ {
CDolLoader dolfile(m_strFilename.c_str()); CDolLoader dolfile(m_strFilename.c_str());
bWii = dolfile.IsWii(); bWii = dolfile.IsWii();
Region = USA_DIR; Region = USA_DIR;
m_BootType = BOOT_DOL; m_BootType = BOOT_DOL;
bNTSC = true; bNTSC = true;
} }
@ -219,7 +219,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{ {
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str()); const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str());
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename); const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL) if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL)
{ {
//WAD is valid yet cannot be booted. Install instead. //WAD is valid yet cannot be booted. Install instead.
@ -233,9 +233,9 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{ {
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
bNTSC = true; bNTSC = true;
Region = USA_DIR; Region = USA_DIR;
break; break;
case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_KOREA: case DiscIO::IVolume::COUNTRY_KOREA:
// TODO: Should these have their own Region Dir? // TODO: Should these have their own Region Dir?
@ -243,15 +243,15 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bNTSC = true; bNTSC = true;
Region = JAP_DIR; Region = JAP_DIR;
break; break;
case DiscIO::IVolume::COUNTRY_EUROPE: case DiscIO::IVolume::COUNTRY_EUROPE:
case DiscIO::IVolume::COUNTRY_FRANCE: case DiscIO::IVolume::COUNTRY_FRANCE:
case DiscIO::IVolume::COUNTRY_ITALY: case DiscIO::IVolume::COUNTRY_ITALY:
case DiscIO::IVolume::COUNTRY_RUSSIA: case DiscIO::IVolume::COUNTRY_RUSSIA:
bNTSC = false; bNTSC = false;
Region = EUR_DIR; Region = EUR_DIR;
break; break;
default: default:
bNTSC = false; bNTSC = false;
Region = EUR_DIR; Region = EUR_DIR;
@ -278,7 +278,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
// or if it is not ascii characters (specifically sysmenu could potentially apply to other things) // or if it is not ascii characters (specifically sysmenu could potentially apply to other things)
char titleidstr[17]; char titleidstr[17];
snprintf(titleidstr, 17, "%016llx", ContentLoader.GetTitleID()); snprintf(titleidstr, 17, "%016llx", ContentLoader.GetTitleID());
if (!m_strName.length()) if (!m_strName.length())
{ {
m_strName = titleidstr; m_strName = titleidstr;
@ -309,7 +309,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bNTSC = true; bNTSC = true;
break; break;
case BOOT_BS2_EUR: case BOOT_BS2_EUR:
Region = EUR_DIR; Region = EUR_DIR;
m_strFilename.clear(); m_strFilename.clear();
bNTSC = false; bNTSC = false;

View File

@ -40,7 +40,7 @@ void HLE_GeneralDebugPrint()
NPC = LR; NPC = LR;
//PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str());
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str());
} }
void HLE_VPrintf() void HLE_VPrintf()
@ -53,13 +53,13 @@ void HLE_VPrintf()
for(int i = 4; i<= 10; i++){ for(int i = 4; i<= 10; i++){
GPR(i) = Memory::Read_U32(offset+(i-(check == 0x01000000? 3 : 2))*4); GPR(i) = Memory::Read_U32(offset+(i-(check == 0x01000000? 3 : 2))*4);
//NOTICE_LOG(OSREPORT, "r%d: %08X",i, GPR(i)); //NOTICE_LOG(OSREPORT, "r%d: %08X",i, GPR(i));
} }
GetStringVA(ReportMessage); GetStringVA(ReportMessage);
NPC = LR; NPC = LR;
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str());
} }
// Generalized func for just printing string pointed to by r3. // Generalized func for just printing string pointed to by r3.
void HLE_GeneralDebugPrintWithInt() void HLE_GeneralDebugPrintWithInt()
@ -69,7 +69,7 @@ void HLE_GeneralDebugPrintWithInt()
NPC = LR; NPC = LR;
//PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str());
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str());
} }
// __write_console is slightly abnormal // __write_console is slightly abnormal
@ -80,14 +80,14 @@ void HLE_write_console()
NPC = LR; NPC = LR;
//PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str()); //PanicAlert("(%08x->%08x) %s", LR, PC, ReportMessage.c_str());
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str()); NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, ReportMessage.c_str());
} }
void GetStringVA(std::string& _rOutBuffer, u32 strReg) void GetStringVA(std::string& _rOutBuffer, u32 strReg)
{ {
_rOutBuffer = ""; _rOutBuffer = "";
char ArgumentBuffer[256]; char ArgumentBuffer[256];
u32 ParameterCounter = strReg+1; u32 ParameterCounter = strReg+1;
u32 FloatingParameterCounter = 1; u32 FloatingParameterCounter = 1;
char *pString = (char*)Memory::GetPointer(GPR(strReg)); char *pString = (char*)Memory::GetPointer(GPR(strReg));
if (!pString) if (!pString)
@ -143,10 +143,10 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
_rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter); _rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter);
break; break;
} }
case 'f': case 'f':
{ {
_rOutBuffer += StringFromFormat(ArgumentBuffer, _rOutBuffer += StringFromFormat(ArgumentBuffer,
rPS0(FloatingParameterCounter)); rPS0(FloatingParameterCounter));
FloatingParameterCounter++; FloatingParameterCounter++;
ParameterCounter--; ParameterCounter--;
@ -166,7 +166,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
} }
else else
{ {
_rOutBuffer += StringFromFormat("%c", *pString); _rOutBuffer += StringFromFormat("%c", *pString);
pString++; pString++;
} }
} }

View File

@ -14,7 +14,7 @@ enum
#pragma pack(push, 1) #pragma pack(push, 1)
struct icmp_hdr struct icmp_hdr
{ {
u8 type; u8 type;
u8 code; u8 code;
u16 checksum; u16 checksum;

View File

@ -88,7 +88,7 @@ void EnqueReplyCallback(u64 userdata, int)
void Init() void Init()
{ {
_dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init"); _dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init");
CWII_IPC_HLE_Device_es::m_ContentFile = ""; CWII_IPC_HLE_Device_es::m_ContentFile = "";
u32 i; u32 i;
@ -129,15 +129,15 @@ void Init()
#endif #endif
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/usb/oh1")); i++; g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/usb/oh1")); i++;
g_DeviceMap[i] = new IWII_IPC_HLE_Device(i, std::string("_Unimplemented_Device_")); i++; g_DeviceMap[i] = new IWII_IPC_HLE_Device(i, std::string("_Unimplemented_Device_")); i++;
enque_reply = CoreTiming::RegisterEvent("IPCReply", EnqueReplyCallback); enque_reply = CoreTiming::RegisterEvent("IPCReply", EnqueReplyCallback);
} }
void Reset(bool _bHard) void Reset(bool _bHard)
{ {
CoreTiming::RemoveAllEvents(enque_reply); CoreTiming::RemoveAllEvents(enque_reply);
u32 i; u32 i;
for (i=0; i<IPC_MAX_FDS; i++) for (i=0; i<IPC_MAX_FDS; i++)
{ {
@ -168,7 +168,7 @@ void Reset(bool _bHard)
g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end()); g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end());
} }
request_queue.clear(); request_queue.clear();
// lock due to using reply_queue // lock due to using reply_queue
{ {
std::lock_guard<std::mutex> lk(s_reply_queue); std::lock_guard<std::mutex> lk(s_reply_queue);
@ -257,7 +257,7 @@ IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
std::lock_guard<std::mutex> lk(s_reply_queue); std::lock_guard<std::mutex> lk(s_reply_queue);
p.Do(request_queue); p.Do(request_queue);
p.Do(reply_queue); p.Do(reply_queue);
p.Do(last_reply_time); p.Do(last_reply_time);
@ -359,11 +359,11 @@ void ExecuteCommand(u32 _Address)
{ {
u32 Mode = Memory::Read_U32(_Address + 0x10); u32 Mode = Memory::Read_U32(_Address + 0x10);
DeviceID = getFreeDeviceId(); DeviceID = getFreeDeviceId();
std::string DeviceName; std::string DeviceName;
Memory::GetString(DeviceName, Memory::Read_U32(_Address + 0xC)); Memory::GetString(DeviceName, Memory::Read_U32(_Address + 0xC));
WARN_LOG(WII_IPC_HLE, "Trying to open %s as %d", DeviceName.c_str(), DeviceID); WARN_LOG(WII_IPC_HLE, "Trying to open %s as %d", DeviceName.c_str(), DeviceID);
if (DeviceID >= 0) if (DeviceID >= 0)
{ {
@ -529,7 +529,7 @@ void ExecuteCommand(u32 _Address)
if (CmdSuccess) if (CmdSuccess)
{ {
// It seems that the original hardware overwrites the command after it has been // It seems that the original hardware overwrites the command after it has been
// executed. We write 8 which is not any valid command, and what IOS does // executed. We write 8 which is not any valid command, and what IOS does
Memory::Write_U32(8, _Address); Memory::Write_U32(8, _Address);
// IOS seems to write back the command that was responded to // IOS seems to write back the command that was responded to
Memory::Write_U32(Command, _Address + 8); Memory::Write_U32(Command, _Address + 8);
@ -537,14 +537,14 @@ void ExecuteCommand(u32 _Address)
// Ensure replies happen in order, fairly ugly // Ensure replies happen in order, fairly ugly
// Without this, tons of games fail now that DI commands have different reply delays // Without this, tons of games fail now that DI commands have different reply delays
int reply_delay = pDevice ? pDevice->GetCmdDelay(_Address) : 0; int reply_delay = pDevice ? pDevice->GetCmdDelay(_Address) : 0;
const s64 ticks_til_last_reply = last_reply_time - CoreTiming::GetTicks(); const s64 ticks_til_last_reply = last_reply_time - CoreTiming::GetTicks();
if (ticks_til_last_reply > 0) if (ticks_til_last_reply > 0)
reply_delay = ticks_til_last_reply; reply_delay = ticks_til_last_reply;
last_reply_time = CoreTiming::GetTicks() + reply_delay; last_reply_time = CoreTiming::GetTicks() + reply_delay;
// Generate a reply to the IPC command // Generate a reply to the IPC command
EnqReply(_Address, reply_delay); EnqReply(_Address, reply_delay);
} }
@ -594,7 +594,7 @@ void Update()
Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG); Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG);
#endif #endif
} }
// lock due to using reply_queue // lock due to using reply_queue
{ {
std::lock_guard<std::mutex> lk(s_reply_queue); std::lock_guard<std::mutex> lk(s_reply_queue);

View File

@ -46,20 +46,20 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
tv.tv_usec = 500; tv.tv_usec = 500;
while (hid->usb_thread_running) while (hid->usb_thread_running)
{ {
static u16 timeToFill = 0; static u16 timeToFill = 0;
if (timeToFill == 0) if (timeToFill == 0)
{ {
if (hid->deviceCommandAddress != 0){ if (hid->deviceCommandAddress != 0){
hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C)); hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C));
Memory::Write_U32(8, hid->deviceCommandAddress); Memory::Write_U32(8, hid->deviceCommandAddress);
// IOS seems to write back the command that was responded to // IOS seems to write back the command that was responded to
Memory::Write_U32(/*COMMAND_IOCTL*/ 6, hid->deviceCommandAddress + 8); Memory::Write_U32(/*COMMAND_IOCTL*/ 6, hid->deviceCommandAddress + 8);
// Return value // Return value
Memory::Write_U32(0, hid->deviceCommandAddress + 4); Memory::Write_U32(0, hid->deviceCommandAddress + 4);
WII_IPC_HLE_Interface::EnqueReplyCallback(hid->deviceCommandAddress); WII_IPC_HLE_Interface::EnqueReplyCallback(hid->deviceCommandAddress);
hid->deviceCommandAddress = 0; hid->deviceCommandAddress = 0;
} }
@ -67,7 +67,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
timeToFill+=8; timeToFill+=8;
libusb_handle_events_timeout(NULL, &tv); libusb_handle_events_timeout(NULL, &tv);
} }
return; return;
} }
@ -79,16 +79,16 @@ void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer *transfer)
{ {
ret = transfer->length; ret = transfer->length;
} }
Memory::Write_U32(8, replyAddress); Memory::Write_U32(8, replyAddress);
// IOS seems to write back the command that was responded to // IOS seems to write back the command that was responded to
Memory::Write_U32(/*COMMAND_IOCTL*/ 6, replyAddress + 8); Memory::Write_U32(/*COMMAND_IOCTL*/ 6, replyAddress + 8);
// Return value // Return value
Memory::Write_U32(ret, replyAddress + 4); Memory::Write_U32(ret, replyAddress + 4);
WII_IPC_HLE_Interface::EnqueReplyCallback(replyAddress); WII_IPC_HLE_Interface::EnqueReplyCallback(replyAddress);
//DEBUG_LOG(WII_IPC_HID, "OMG OMG OMG I GOT A CALLBACK, IMMA BE FAMOUS %d %d %d", transfer->actual_length, transfer->length, transfer->status); //DEBUG_LOG(WII_IPC_HID, "OMG OMG OMG I GOT A CALLBACK, IMMA BE FAMOUS %d %d %d", transfer->actual_length, transfer->length, transfer->status);
} }
@ -98,7 +98,7 @@ CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::strin
deviceCommandAddress = 0; deviceCommandAddress = 0;
memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases)); memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases));
libusb_init(NULL); libusb_init(NULL);
usb_thread_running = true; usb_thread_running = true;
usb_thread = std::thread(checkUsbUpdates, this); usb_thread = std::thread(checkUsbUpdates, this);
} }
@ -107,14 +107,14 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid()
{ {
usb_thread_running = false; usb_thread_running = false;
usb_thread.join(); usb_thread.join();
for ( std::map<u32,libusb_device_handle*>::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter ) for ( std::map<u32,libusb_device_handle*>::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter )
{ {
libusb_close(iter->second); libusb_close(iter->second);
} }
open_devices.clear(); open_devices.clear();
libusb_exit(NULL); libusb_exit(NULL);
} }
@ -137,7 +137,7 @@ bool CWII_IPC_HLE_Device_hid::Close(u32 _CommandAddress, bool _bForce)
u32 CWII_IPC_HLE_Device_hid::Update() u32 CWII_IPC_HLE_Device_hid::Update()
{ {
u32 work_done = 0; u32 work_done = 0;
return work_done; return work_done;
} }
@ -148,7 +148,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
u32 ReturnValue = 0; u32 ReturnValue = 0;
switch (Parameter) switch (Parameter)
@ -191,7 +191,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
ERROR CODES: ERROR CODES:
-4 Cant find device specified -4 Cant find device specified
*/ */
u32 dev_num = Memory::Read_U32(BufferIn+0x10); u32 dev_num = Memory::Read_U32(BufferIn+0x10);
u8 bmRequestType = Memory::Read_U8(BufferIn+0x14); u8 bmRequestType = Memory::Read_U8(BufferIn+0x14);
u8 bRequest = Memory::Read_U8(BufferIn+0x15); u8 bRequest = Memory::Read_U8(BufferIn+0x15);
@ -199,11 +199,11 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
u16 wIndex = Memory::Read_U16(BufferIn+0x18); u16 wIndex = Memory::Read_U16(BufferIn+0x18);
u16 wLength = Memory::Read_U16(BufferIn+0x1A); u16 wLength = Memory::Read_U16(BufferIn+0x1A);
u32 data = Memory::Read_U32(BufferIn+0x1C); u32 data = Memory::Read_U32(BufferIn+0x1C);
ReturnValue = HIDERR_NO_DEVICE_FOUND; ReturnValue = HIDERR_NO_DEVICE_FOUND;
libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num); libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num);
if (dev_handle == NULL) if (dev_handle == NULL)
{ {
DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num);
@ -211,7 +211,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
} }
struct libusb_transfer *transfer = libusb_alloc_transfer(0); struct libusb_transfer *transfer = libusb_alloc_transfer(0);
transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER; transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER;
u8 * buffer = (u8*)malloc(wLength + LIBUSB_CONTROL_SETUP_SIZE); u8 * buffer = (u8*)malloc(wLength + LIBUSB_CONTROL_SETUP_SIZE);
libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, wLength); libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, wLength);
memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, Memory::GetPointer(data), wLength); memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, Memory::GetPointer(data), wLength);
@ -220,7 +220,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
//DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Control)(%02X, %02X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", //DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Control)(%02X, %02X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
// bmRequestType, bRequest, BufferIn, BufferInSize, BufferOut, BufferOutSize); // bmRequestType, bRequest, BufferIn, BufferInSize, BufferOut, BufferOutSize);
// It's the async way! // It's the async way!
return false; return false;
break; break;
@ -233,17 +233,17 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
u32 length = Memory::Read_U32(BufferIn+0x18); u32 length = Memory::Read_U32(BufferIn+0x18);
u32 data = Memory::Read_U32(BufferIn+0x1C); u32 data = Memory::Read_U32(BufferIn+0x1C);
ReturnValue = HIDERR_NO_DEVICE_FOUND; ReturnValue = HIDERR_NO_DEVICE_FOUND;
libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num); libusb_device_handle * dev_handle = GetDeviceByDevNum(dev_num);
if (dev_handle == NULL) if (dev_handle == NULL)
{ {
DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); DEBUG_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num);
break; break;
} }
struct libusb_transfer *transfer = libusb_alloc_transfer(0); struct libusb_transfer *transfer = libusb_alloc_transfer(0);
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
libusb_fill_interrupt_transfer(transfer, dev_handle, endpoint, Memory::GetPointer(data), length, libusb_fill_interrupt_transfer(transfer, dev_handle, endpoint, Memory::GetPointer(data), length,
@ -252,7 +252,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
//DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", //DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Interrupt %s)(%d,%d,%X) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
// Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, BufferIn, BufferInSize, BufferOut, BufferOutSize); // Parameter == IOCTL_HID_INTERRUPT_IN ? "In" : "Out", endpoint, length, data, BufferIn, BufferInSize, BufferOut, BufferOutSize);
// It's the async way! // It's the async way!
return false; return false;
break; break;
@ -287,19 +287,19 @@ bool CWII_IPC_HLE_Device_hid::ClaimDevice(libusb_device_handle * dev)
DEBUG_LOG(WII_IPC_HID, "libusb_kernel_driver_active error ret = %d", ret); DEBUG_LOG(WII_IPC_HID, "libusb_kernel_driver_active error ret = %d", ret);
return false; return false;
} }
if ((ret = libusb_claim_interface(dev, 0))) if ((ret = libusb_claim_interface(dev, 0)))
{ {
DEBUG_LOG(WII_IPC_HID, "libusb_claim_interface failed with error: %d", ret); DEBUG_LOG(WII_IPC_HID, "libusb_claim_interface failed with error: %d", ret);
return false; return false;
} }
return true; return true;
} }
bool CWII_IPC_HLE_Device_hid::IOCtlV(u32 _CommandAddress) bool CWII_IPC_HLE_Device_hid::IOCtlV(u32 _CommandAddress)
{ {
Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HID, LogTypes::LWARNING); Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HID, LogTypes::LWARNING);
u32 ReturnValue = 0; u32 ReturnValue = 0;
SIOCtlVBuffer CommandBuffer(_CommandAddress); SIOCtlVBuffer CommandBuffer(_CommandAddress);
@ -320,7 +320,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtlV(u32 _CommandAddress)
} }
void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src) void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src)
{ {
memcpy(dest,src,sizeof(WiiHIDDeviceDescriptor)); memcpy(dest,src,sizeof(WiiHIDDeviceDescriptor));
@ -354,7 +354,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
int OffsetStart = 0; int OffsetStart = 0;
//int OffsetDevice = 0; //int OffsetDevice = 0;
int d,c,ic,i,e; /* config, interface container, interface, endpoint */ int d,c,ic,i,e; /* config, interface container, interface, endpoint */
libusb_device **list; libusb_device **list;
//libusb_device *found = NULL; //libusb_device *found = NULL;
ssize_t cnt = libusb_get_device_list(NULL, &list); ssize_t cnt = libusb_get_device_list(NULL, &list);
@ -380,12 +380,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
Memory::WriteBigEData((const u8*)&wii_device, OffsetBuffer, Align(wii_device.bLength, 4)); Memory::WriteBigEData((const u8*)&wii_device, OffsetBuffer, Align(wii_device.bLength, 4));
OffsetBuffer += Align(wii_device.bLength, 4); OffsetBuffer += Align(wii_device.bLength, 4);
bool deviceValid = true; bool deviceValid = true;
for (c = 0; deviceValid && c < desc.bNumConfigurations; c++) for (c = 0; deviceValid && c < desc.bNumConfigurations; c++)
{ {
struct libusb_config_descriptor *config = NULL; struct libusb_config_descriptor *config = NULL;
int cRet = libusb_get_config_descriptor(device, c, &config); int cRet = libusb_get_config_descriptor(device, c, &config);
// do not try to use usb devices with more than one interface, games can crash // do not try to use usb devices with more than one interface, games can crash
if(cRet == 0 && config->bNumInterfaces <= MAX_HID_INTERFACES) if(cRet == 0 && config->bNumInterfaces <= MAX_HID_INTERFACES)
{ {
@ -393,7 +393,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
ConvertConfigToWii(&wii_config, config); ConvertConfigToWii(&wii_config, config);
Memory::WriteBigEData((const u8*)&wii_config, OffsetBuffer, Align(wii_config.bLength, 4)); Memory::WriteBigEData((const u8*)&wii_config, OffsetBuffer, Align(wii_config.bLength, 4));
OffsetBuffer += Align(wii_config.bLength, 4); OffsetBuffer += Align(wii_config.bLength, 4);
for (ic = 0; ic < config->bNumInterfaces; ic++) for (ic = 0; ic < config->bNumInterfaces; ic++)
{ {
const struct libusb_interface *interfaceContainer = &config->interface[ic]; const struct libusb_interface *interfaceContainer = &config->interface[ic];
@ -414,7 +414,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
ConvertEndpointToWii(&wii_endpoint, endpoint); ConvertEndpointToWii(&wii_endpoint, endpoint);
Memory::WriteBigEData((const u8*)&wii_endpoint, OffsetBuffer, Align(wii_endpoint.bLength, 4)); Memory::WriteBigEData((const u8*)&wii_endpoint, OffsetBuffer, Align(wii_endpoint.bLength, 4));
OffsetBuffer += Align(wii_endpoint.bLength, 4); OffsetBuffer += Align(wii_endpoint.bLength, 4);
} //endpoints } //endpoints
} // interfaces } // interfaces
} // interface containters } // interface containters
@ -429,11 +429,11 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
OffsetBuffer = OffsetStart; OffsetBuffer = OffsetStart;
} }
} // configs } // configs
if (deviceValid) if (deviceValid)
{ {
Memory::Write_U32(OffsetBuffer-OffsetStart, OffsetStart); // fill in length Memory::Write_U32(OffsetBuffer-OffsetStart, OffsetStart); // fill in length
int devNum = GetAvaiableDevNum(desc.idVendor, int devNum = GetAvaiableDevNum(desc.idVendor,
desc.idProduct, desc.idProduct,
libusb_get_bus_number (device), libusb_get_bus_number (device),
@ -447,13 +447,13 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
OffsetBuffer = OffsetStart; OffsetBuffer = OffsetStart;
continue; continue;
} }
DEBUG_LOG(WII_IPC_HID, "Found device with Vendor: %X Product: %X Devnum: %d", desc.idVendor, desc.idProduct, devNum); DEBUG_LOG(WII_IPC_HID, "Found device with Vendor: %X Product: %X Devnum: %d", desc.idVendor, desc.idProduct, devNum);
Memory::Write_U32(devNum , OffsetStart+4); //write device num Memory::Write_U32(devNum , OffsetStart+4); //write device num
} }
} }
// Find devices that no longer exists and free them // Find devices that no longer exists and free them
for (i=0; i<MAX_DEVICE_DEVNUM; i++) for (i=0; i<MAX_DEVICE_DEVNUM; i++)
{ {
@ -472,14 +472,14 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
} }
} }
check++; check++;
libusb_free_device_list(list, 1); libusb_free_device_list(list, 1);
Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices
} }
int CWII_IPC_HLE_Device_hid::Align(int num, int alignment) int CWII_IPC_HLE_Device_hid::Align(int num, int alignment)
{ {
return (num + (alignment-1)) & ~(alignment-1); return (num + (alignment-1)) & ~(alignment-1);
@ -492,13 +492,13 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
libusb_device **list; libusb_device **list;
libusb_device_handle *handle = NULL; libusb_device_handle *handle = NULL;
ssize_t cnt; ssize_t cnt;
if(devNum >= MAX_DEVICE_DEVNUM) if(devNum >= MAX_DEVICE_DEVNUM)
return NULL; return NULL;
std::lock_guard<std::mutex> lk(s_open_devices); std::lock_guard<std::mutex> lk(s_open_devices);
if (open_devices.find(devNum) != open_devices.end()) if (open_devices.find(devNum) != open_devices.end())
{ {
handle = open_devices[devNum]; handle = open_devices[devNum];
@ -510,14 +510,14 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
{ {
libusb_close(handle); libusb_close(handle);
open_devices.erase(devNum); open_devices.erase(devNum);
} }
} }
cnt = libusb_get_device_list(NULL, &list); cnt = libusb_get_device_list(NULL, &list);
if (cnt < 0) if (cnt < 0)
return NULL; return NULL;
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
libusb_device *device = list[i]; libusb_device *device = list[i];
struct libusb_device_descriptor desc; struct libusb_device_descriptor desc;
@ -534,14 +534,14 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
{ {
if( dRet ) if( dRet )
{ {
ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID ????:???? (couldn't get id).", ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID ????:???? (couldn't get id).",
bus, bus,
port port
); );
} }
else{ else{
ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.", ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.",
bus, bus,
port, port,
desc.idVendor, desc.idVendor,
desc.idProduct desc.idProduct
@ -560,15 +560,15 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
} }
continue; continue;
} }
if (!ClaimDevice(handle)) if (!ClaimDevice(handle))
{ {
ERROR_LOG(WII_IPC_HID, "Could not claim the device for handle: %X", devNum); ERROR_LOG(WII_IPC_HID, "Could not claim the device for handle: %X", devNum);
libusb_close(handle); libusb_close(handle);
continue; continue;
} }
open_devices[devNum] = handle; open_devices[devNum] = handle;
break; break;
} }
@ -577,7 +577,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
handle = NULL; handle = NULL;
} }
} }
libusb_free_device_list(list, 1); libusb_free_device_list(list, 1);

View File

@ -28,7 +28,7 @@
#define HIDERR_NO_DEVICE_FOUND -4 #define HIDERR_NO_DEVICE_FOUND -4
/* Connection timed out */ /* Connection timed out */
class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
{ {
@ -131,21 +131,21 @@ private:
int Align(int num, int alignment); int Align(int num, int alignment);
static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid); static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid);
static void LIBUSB_CALL handleUsbUpdates(struct libusb_transfer *transfer); static void LIBUSB_CALL handleUsbUpdates(struct libusb_transfer *transfer);
struct libusb_device_handle * GetDeviceByDevNum(u32 devNum); struct libusb_device_handle * GetDeviceByDevNum(u32 devNum);
std::map<u32,libusb_device_handle*> open_devices; std::map<u32,libusb_device_handle*> open_devices;
std::mutex s_open_devices; std::mutex s_open_devices;
std::map<std::string,int> device_identifiers; std::map<std::string,int> device_identifiers;
std::thread usb_thread; std::thread usb_thread;
bool usb_thread_running; bool usb_thread_running;
typedef struct typedef struct
{ {
u32 enq_address; u32 enq_address;
u32 type; u32 type;
void * context; void * context;
} _hidevent; } _hidevent;
std::list<_hidevent> event_list; std::list<_hidevent> event_list;
}; };

View File

@ -46,7 +46,7 @@ it failed)
#include <iphlpapi.h> #include <iphlpapi.h>
#include "fakepoll.h" #include "fakepoll.h"
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
#elif defined(__linux__) or defined(__APPLE__) #elif defined(__linux__) or defined(__APPLE__)
@ -74,7 +74,7 @@ const u8 default_address[] = { 0x00, 0x17, 0xAB, 0x99, 0x99, 0x99 };
// ********************************************************************************** // **********************************************************************************
// Handle /dev/net/kd/request requests // Handle /dev/net/kd/request requests
CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{ {
} }
@ -100,19 +100,19 @@ bool CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress, bool _bForce
return true; return true;
} }
bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
{ {
u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC); u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
u32 ReturnValue = 0; u32 ReturnValue = 0;
switch (Parameter) switch (Parameter)
{ {
case IOCTL_NWC24_SUSPEND_SCHEDULAR: case IOCTL_NWC24_SUSPEND_SCHEDULAR:
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
Memory::Write_U32(0, BufferOut); // no error Memory::Write_U32(0, BufferOut); // no error
break; break;
@ -158,7 +158,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
SettingsHandler gen; SettingsHandler gen;
std::string area, model; std::string area, model;
bool _GotSettings = false; bool _GotSettings = false;
if (File::Exists(settings_Filename)) if (File::Exists(settings_Filename))
{ {
File::IOFile settingsFileHandle(settings_Filename, "rb"); File::IOFile settingsFileHandle(settings_Filename, "rb");
@ -169,31 +169,31 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
model = gen.GetValue("MODEL"); model = gen.GetValue("MODEL");
_GotSettings = true; _GotSettings = true;
} }
} }
if (_GotSettings) if (_GotSettings)
{ {
u8 area_code = GetAreaCode(area.c_str()); u8 area_code = GetAreaCode(area.c_str());
u8 id_ctr = config.IdGen(); u8 id_ctr = config.IdGen();
u8 hardware_model = GetHardwareModel(model.c_str()); u8 hardware_model = GetHardwareModel(model.c_str());
EcWii &ec = EcWii::GetInstance(); EcWii &ec = EcWii::GetInstance();
u32 HollywoodID = ec.getNgId(); u32 HollywoodID = ec.getNgId();
u64 UserID = 0; u64 UserID = 0;
s32 ret = NWC24MakeUserID(&UserID, HollywoodID, id_ctr, hardware_model, area_code); s32 ret = NWC24MakeUserID(&UserID, HollywoodID, id_ctr, hardware_model, area_code);
config.SetId(UserID); config.SetId(UserID);
config.IncrementIdGen(); config.IncrementIdGen();
config.SetCreationStage(nwc24_config_t::NWC24_IDCS_GENERATED); config.SetCreationStage(nwc24_config_t::NWC24_IDCS_GENERATED);
config.WriteConfig(); config.WriteConfig();
Memory::Write_U32(ret, BufferOut); Memory::Write_U32(ret, BufferOut);
} }
else else
{ {
Memory::Write_U32(WC24_ERR_FATAL, BufferOut); Memory::Write_U32(WC24_ERR_FATAL, BufferOut);
} }
} }
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED) else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED)
{ {
@ -228,7 +228,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
// g_ReplyQueueLater.push(std::pair<u32, std::string>(_CommandAddress, GetDeviceName())); // g_ReplyQueueLater.push(std::pair<u32, std::string>(_CommandAddress, GetDeviceName()));
Memory::Write_U32(ReturnValue, _CommandAddress + 4); Memory::Write_U32(ReturnValue, _CommandAddress + 4);
return true; return true;
} }
@ -244,7 +244,7 @@ u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode( const char * area )
return regions_[i]; return regions_[i];
} }
} }
return 7; return 7;
} }
@ -286,10 +286,10 @@ s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 holly
{ {
const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7}; const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7};
const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, 0xC, 0x2, 0x6, 0xE, 0x8, 0x0, 0xA, 0x5}; const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, 0xC, 0x2, 0x6, 0xE, 0x8, 0x0, 0xA, 0x5};
u64 mix_id = ((u64)area_code<<50) | ((u64)hardware_model<<47) | ((u64)hollywood_id<<15) | ((u64)id_ctr<<10); u64 mix_id = ((u64)area_code<<50) | ((u64)hardware_model<<47) | ((u64)hollywood_id<<15) | ((u64)id_ctr<<10);
u64 mix_id_copy1 = mix_id; u64 mix_id_copy1 = mix_id;
int ctr = 0; int ctr = 0;
for (ctr = 0; ctr <= 42; ctr++) for (ctr = 0; ctr <= 42; ctr++)
{ {
@ -300,46 +300,46 @@ s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 holly
mix_id ^= value; mix_id ^= value;
} }
} }
mix_id = (mix_id_copy1 | (mix_id & 0xFFFFFFFFUL)) ^ 0x0000B3B3B3B3B3B3ULL; mix_id = (mix_id_copy1 | (mix_id & 0xFFFFFFFFUL)) ^ 0x0000B3B3B3B3B3B3ULL;
mix_id = (mix_id >> 10) | ((mix_id & 0x3FF) << (11+32)); mix_id = (mix_id >> 10) | ((mix_id & 0x3FF) << (11+32));
for (ctr = 0; ctr <= 5; ctr++) for (ctr = 0; ctr <= 5; ctr++)
{ {
u8 ret = u64_get_byte(mix_id, ctr); u8 ret = u64_get_byte(mix_id, ctr);
u8 foobar = ((table1[(ret>>4)&0xF])<<4) | (table1[ret&0xF]); u8 foobar = ((table1[(ret>>4)&0xF])<<4) | (table1[ret&0xF]);
mix_id = u64_insert_byte(mix_id, ctr, foobar & 0xff); mix_id = u64_insert_byte(mix_id, ctr, foobar & 0xff);
} }
u64 mix_id_copy2 = mix_id; u64 mix_id_copy2 = mix_id;
for (ctr = 0; ctr <= 5; ctr++) for (ctr = 0; ctr <= 5; ctr++)
{ {
u8 ret = u64_get_byte(mix_id_copy2, ctr); u8 ret = u64_get_byte(mix_id_copy2, ctr);
mix_id = u64_insert_byte(mix_id, table2[ctr], ret); mix_id = u64_insert_byte(mix_id, table2[ctr], ret);
} }
mix_id &= 0x001FFFFFFFFFFFFFULL; mix_id &= 0x001FFFFFFFFFFFFFULL;
mix_id = (mix_id << 1) | ((mix_id >> 52) & 1); mix_id = (mix_id << 1) | ((mix_id >> 52) & 1);
mix_id ^= 0x00005E5E5E5E5E5EULL; mix_id ^= 0x00005E5E5E5E5E5EULL;
mix_id &= 0x001FFFFFFFFFFFFFULL; mix_id &= 0x001FFFFFFFFFFFFFULL;
*nwc24_id = mix_id; *nwc24_id = mix_id;
if (mix_id > 9999999999999999ULL) if (mix_id > 9999999999999999ULL)
return WC24_ERR_FATAL; return WC24_ERR_FATAL;
return WC24_OK; return WC24_OK;
} }
// ********************************************************************************** // **********************************************************************************
// Handle /dev/net/ncd/manage requests // Handle /dev/net/ncd/manage requests
CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{ {
} }
CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage() CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage()
{ {
} }
@ -458,12 +458,12 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
// ********************************************************************************** // **********************************************************************************
// Handle /dev/net/wd/command requests // Handle /dev/net/wd/command requests
CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName) CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName)
: IWII_IPC_HLE_Device(DeviceID, DeviceName) : IWII_IPC_HLE_Device(DeviceID, DeviceName)
{ {
} }
CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command() CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command()
{ {
} }
@ -556,7 +556,7 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
{ {
WARN_LOG(WII_IPC_NET, "in %i addr %x size %i", i, WARN_LOG(WII_IPC_NET, "in %i addr %x size %i", i,
CommandBuffer.InBuffer.at(i).m_Address, CommandBuffer.InBuffer.at(i).m_Size); CommandBuffer.InBuffer.at(i).m_Address, CommandBuffer.InBuffer.at(i).m_Size);
WARN_LOG(WII_IPC_NET, "%s", WARN_LOG(WII_IPC_NET, "%s",
ArrayToString( ArrayToString(
Memory::GetPointer(CommandBuffer.InBuffer.at(i).m_Address), Memory::GetPointer(CommandBuffer.InBuffer.at(i).m_Address),
CommandBuffer.InBuffer.at(i).m_Size).c_str() CommandBuffer.InBuffer.at(i).m_Size).c_str()
@ -576,7 +576,7 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
// ********************************************************************************** // **********************************************************************************
// Handle /dev/net/ip/top requests // Handle /dev/net/ip/top requests
CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -585,7 +585,7 @@ CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, co
#endif #endif
} }
CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top()
{ {
#ifdef _WIN32 #ifdef _WIN32
WSACleanup(); WSACleanup();
@ -658,8 +658,8 @@ static unsigned int opt_name_mapping[][2] = {
{ SO_ERROR, 0x1009 } { SO_ERROR, 0x1009 }
}; };
bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
{ {
u32 Command = Memory::Read_U32(_CommandAddress + 0x0C); u32 Command = Memory::Read_U32(_CommandAddress + 0x0C);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
@ -673,7 +673,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
{ {
WARN_LOG(WII_IPC_NET, "IOCTL_SO_STARTUP " WARN_LOG(WII_IPC_NET, "IOCTL_SO_STARTUP "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
BufferIn, BufferInSize, BufferOut, BufferOutSize); BufferIn, BufferInSize, BufferOut, BufferOutSize);
break; break;
} }
case IOCTL_SO_SOCKET: case IOCTL_SO_SOCKET:
@ -692,7 +692,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_CLOSE: case IOCTL_SO_CLOSE:
{ {
u32 sock = Memory::Read_U32(BufferIn); u32 sock = Memory::Read_U32(BufferIn);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::getInstance();
ReturnValue = sm.delSocket(sock); ReturnValue = sm.delSocket(sock);
@ -746,7 +746,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
WARN_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT " WARN_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
BufferIn, BufferInSize, BufferOut, BufferOutSize); BufferIn, BufferInSize, BufferOut, BufferOutSize);
u32 sock = Memory::Read_U32(BufferIn); u32 sock = Memory::Read_U32(BufferIn);
socklen_t addrlen; socklen_t addrlen;
@ -762,7 +762,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// TODO: ALL BELOW // // TODO: ALL BELOW //
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
case IOCTL_SO_SHUTDOWN: case IOCTL_SO_SHUTDOWN:
{ {
@ -903,7 +903,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
Memory::Write_U8(BufferOutSize, BufferOut); Memory::Write_U8(BufferOutSize, BufferOut);
Memory::Write_U8(AF_INET, BufferOut + 1); Memory::Write_U8(AF_INET, BufferOut + 1);
Memory::WriteBigEData((u8*)&sa.sa_data, BufferOut + 2, BufferOutSize - 2); Memory::WriteBigEData((u8*)&sa.sa_data, BufferOut + 2, BufferOutSize - 2);
WARN_LOG(WII_IPC_NET, "IOCTL_SO_GETPEERNAME(%x)", sock); WARN_LOG(WII_IPC_NET, "IOCTL_SO_GETPEERNAME(%x)", sock);
ReturnValue = ret; ReturnValue = ret;
@ -1015,7 +1015,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
for (int i = 0; i<nfds; i++) for (int i = 0; i<nfds; i++)
{ {
// Translate native to Wii events // Translate native to Wii events
int revents = 0; int revents = 0;
for (unsigned int j = 0; j < sizeof (mapping) / sizeof (mapping[0]); ++j) for (unsigned int j = 0; j < sizeof (mapping) / sizeof (mapping[0]); ++j)
@ -1023,16 +1023,16 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (ufds[i].revents & mapping[j][0]) if (ufds[i].revents & mapping[j][0])
revents |= mapping[j][1]; revents |= mapping[j][1];
} }
// No need to change fd or events as they are input only. // No need to change fd or events as they are input only.
//Memory::Write_U32(ufds[i].fd, BufferOut + 0xc*i); //fd //Memory::Write_U32(ufds[i].fd, BufferOut + 0xc*i); //fd
//Memory::Write_U32(events, BufferOut + 0xc*i + 4); //events //Memory::Write_U32(events, BufferOut + 0xc*i + 4); //events
Memory::Write_U32(revents, BufferOut + 0xc*i + 8); //revents Memory::Write_U32(revents, BufferOut + 0xc*i + 8); //revents
DEBUG_LOG(WII_IPC_NET, "IOCTL_SO_POLL socket %d revents %08X events %08X", i, revents, ufds[i].events); DEBUG_LOG(WII_IPC_NET, "IOCTL_SO_POLL socket %d revents %08X events %08X", i, revents, ufds[i].events);
} }
free(ufds); free(ufds);
ReturnValue = ret; ReturnValue = ret;
break; break;
} }
@ -1126,7 +1126,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (BufferInSize) if (BufferInSize)
{ {
ERROR_LOG(WII_IPC_NET, "in addr %x size %x", BufferIn, BufferInSize); ERROR_LOG(WII_IPC_NET, "in addr %x size %x", BufferIn, BufferInSize);
ERROR_LOG(WII_IPC_NET, "\n%s", ERROR_LOG(WII_IPC_NET, "\n%s",
ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str() ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str()
); );
} }
@ -1144,8 +1144,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
} }
bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress) bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
{ {
SIOCtlVBuffer CommandBuffer(CommandAddress); SIOCtlVBuffer CommandBuffer(CommandAddress);
s32 ReturnValue = 0; s32 ReturnValue = 0;
@ -1237,10 +1237,10 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
RetVal = GetAdaptersAddresses( RetVal = GetAdaptersAddresses(
AF_INET, AF_INET,
0, 0,
NULL, NULL,
AdapterAddresses, AdapterAddresses,
&OutBufferLength); &OutBufferLength);
if (RetVal != ERROR_BUFFER_OVERFLOW) { if (RetVal != ERROR_BUFFER_OVERFLOW) {
@ -1260,7 +1260,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
if (RetVal == NO_ERROR) if (RetVal == NO_ERROR)
{ {
unsigned long dwBestIfIndex = 0; unsigned long dwBestIfIndex = 0;
IPAddr dwDestAddr = (IPAddr)0x08080808; IPAddr dwDestAddr = (IPAddr)0x08080808;
// If successful, output some information from the data we received // If successful, output some information from the data we received
PIP_ADAPTER_ADDRESSES AdapterList = AdapterAddresses; PIP_ADAPTER_ADDRESSES AdapterList = AdapterAddresses;
if (GetBestInterface(dwDestAddr,&dwBestIfIndex) == NO_ERROR) if (GetBestInterface(dwDestAddr,&dwBestIfIndex) == NO_ERROR)
@ -1440,7 +1440,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
} }
DEBUG_LOG(WII_IPC_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip); DEBUG_LOG(WII_IPC_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip);
sockaddr_in addr; sockaddr_in addr;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr.s_addr = Common::swap32(ip_info.ip); addr.sin_addr.s_addr = Common::swap32(ip_info.ip);
@ -1460,7 +1460,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
((u16 *)data)[0] = Common::swap16(ip_info.icmp_id); ((u16 *)data)[0] = Common::swap16(ip_info.icmp_id);
icmp_length = 22; icmp_length = 22;
} }
int ret = icmp_echo_req(sock, &addr, data, icmp_length); int ret = icmp_echo_req(sock, &addr, data, icmp_length);
if (ret == icmp_length) if (ret == icmp_length)
{ {
@ -1478,7 +1478,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
{ {
ERROR_LOG(WII_IPC_NET, "in %i addr %x size %x", i, ERROR_LOG(WII_IPC_NET, "in %i addr %x size %x", i,
CommandBuffer.InBuffer.at(i).m_Address, CommandBuffer.InBuffer.at(i).m_Size); CommandBuffer.InBuffer.at(i).m_Address, CommandBuffer.InBuffer.at(i).m_Size);
ERROR_LOG(WII_IPC_NET, "\n%s", ERROR_LOG(WII_IPC_NET, "\n%s",
ArrayToString( ArrayToString(
Memory::GetPointer(CommandBuffer.InBuffer.at(i).m_Address), Memory::GetPointer(CommandBuffer.InBuffer.at(i).m_Address),
CommandBuffer.InBuffer.at(i).m_Size, 4).c_str() CommandBuffer.InBuffer.at(i).m_Size, 4).c_str()
@ -1493,7 +1493,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
} }
Memory::Write_U32(ReturnValue, CommandAddress + 4); Memory::Write_U32(ReturnValue, CommandAddress + 4);
return true; return true;
} }
u32 CWII_IPC_HLE_Device_net_ip_top::Update() u32 CWII_IPC_HLE_Device_net_ip_top::Update()
{ {

View File

@ -276,7 +276,7 @@ public:
return -27; return -27;
return 0; return 0;
} }
u32 Magic(){return Common::swap32(config.magic);} u32 Magic(){return Common::swap32(config.magic);}
void SetMagic(u32 magic){config.magic = Common::swap32(magic);} void SetMagic(u32 magic){config.magic = Common::swap32(magic);}
@ -308,7 +308,7 @@ public:
const char * Email(){return config.email;} const char * Email(){return config.email;}
void SetEmail(const char * email) void SetEmail(const char * email)
{ {
strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH); strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH);
config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0'; config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0';
} }
@ -471,7 +471,7 @@ public:
return true; return true;
} }
virtual bool IOCtl(u32 _CommandAddress) virtual bool IOCtl(u32 _CommandAddress)
{ {
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C); u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
@ -591,7 +591,7 @@ enum NET_IOCTL
IOCTL_SO_GETPEERNAME, IOCTL_SO_GETPEERNAME,
IOCTL_SO_GETSOCKNAME, IOCTL_SO_GETSOCKNAME,
IOCTL_SO_GETSOCKOPT, IOCTL_SO_GETSOCKOPT,
IOCTL_SO_SETSOCKOPT, IOCTL_SO_SETSOCKOPT,
IOCTL_SO_LISTEN, IOCTL_SO_LISTEN,
IOCTL_SO_POLL, IOCTL_SO_POLL,
IOCTLV_SO_RECVFROM, IOCTLV_SO_RECVFROM,

View File

@ -22,16 +22,16 @@
WII_SSL CWII_IPC_HLE_Device_net_ssl::_SSL[NET_SSL_MAXINSTANCES]; WII_SSL CWII_IPC_HLE_Device_net_ssl::_SSL[NET_SSL_MAXINSTANCES];
CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{ {
for (int i = 0; i < NET_SSL_MAXINSTANCES; ++i) for (int i = 0; i < NET_SSL_MAXINSTANCES; ++i)
{ {
memset(&_SSL[i], 0, sizeof(WII_SSL)); memset(&_SSL[i], 0, sizeof(WII_SSL));
} }
} }
CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl() CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
{ {
// Cleanup sessions // Cleanup sessions
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++) for (int i = 0; i < NET_SSL_MAXINSTANCES; i++)
@ -84,15 +84,15 @@ bool CWII_IPC_HLE_Device_net_ssl::Close(u32 _CommandAddress, bool _bForce)
return true; return true;
} }
bool CWII_IPC_HLE_Device_net_ssl::IOCtl(u32 _CommandAddress) bool CWII_IPC_HLE_Device_net_ssl::IOCtl(u32 _CommandAddress)
{ {
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
u32 Command = Memory::Read_U32(_CommandAddress + 0x0C); u32 Command = Memory::Read_U32(_CommandAddress + 0x0C);
u32 ReturnValue = ExecuteCommand(Command, BufferIn, BufferInSize, BufferOut, BufferOutSize); u32 ReturnValue = ExecuteCommand(Command, BufferIn, BufferInSize, BufferOut, BufferOutSize);
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
return true; return true;
} }
@ -139,11 +139,11 @@ _verify_certificate_callback (void *data, x509_cert *crt, int depth, int *flags)
return( 0 ); return( 0 );
} }
bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress) bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
{ {
u32 ReturnValue = 0; u32 ReturnValue = 0;
SIOCtlVBuffer CommandBuffer(_CommandAddress); SIOCtlVBuffer CommandBuffer(_CommandAddress);
s32 returnValue = 0; s32 returnValue = 0;
u32 _BufferIn = 0, _BufferIn2 = 0, _BufferIn3 = 0; u32 _BufferIn = 0, _BufferIn2 = 0, _BufferIn3 = 0;
@ -183,14 +183,14 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
BufferOut3 = CommandBuffer.PayloadBuffer.at(2).m_Address; BufferOut3 = CommandBuffer.PayloadBuffer.at(2).m_Address;
BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size; BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size;
} }
switch (CommandBuffer.Parameter) switch (CommandBuffer.Parameter)
{ {
case IOCTLV_NET_SSL_NEW: case IOCTLV_NET_SSL_NEW:
{ {
int verifyOption = Memory::Read_U32(BufferOut); int verifyOption = Memory::Read_U32(BufferOut);
const char * hostname = (const char*) Memory::GetPointer(BufferOut2); const char * hostname = (const char*) Memory::GetPointer(BufferOut2);
int freeSSL = this->getSSLFreeID(); int freeSSL = this->getSSLFreeID();
if (freeSSL) if (freeSSL)
{ {
@ -202,7 +202,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context)); memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context));
goto _SSL_NEW_ERROR; goto _SSL_NEW_ERROR;
} }
havege_init(&_SSL[sslID].hs); havege_init(&_SSL[sslID].hs);
ssl_set_rng(&_SSL[sslID].ctx, havege_random, &_SSL[sslID].hs); ssl_set_rng(&_SSL[sslID].ctx, havege_random, &_SSL[sslID].hs);
@ -213,7 +213,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
ssl_set_session(&_SSL[sslID].ctx, &_SSL[sslID].session); ssl_set_session(&_SSL[sslID].ctx, &_SSL[sslID].session);
ssl_set_verify(&_SSL[sslID].ctx, _verify_certificate_callback, NULL); ssl_set_verify(&_SSL[sslID].ctx, _verify_certificate_callback, NULL);
ssl_set_endpoint(&_SSL[sslID].ctx, SSL_IS_CLIENT); ssl_set_endpoint(&_SSL[sslID].ctx, SSL_IS_CLIENT);
ssl_set_authmode(&_SSL[sslID].ctx, SSL_VERIFY_NONE); ssl_set_authmode(&_SSL[sslID].ctx, SSL_VERIFY_NONE);
ssl_set_renegotiation(&_SSL[sslID].ctx, SSL_RENEGOTIATION_ENABLED); ssl_set_renegotiation(&_SSL[sslID].ctx, SSL_RENEGOTIATION_ENABLED);
@ -257,7 +257,7 @@ _SSL_NEW_ERROR:
memset(&_SSL[sslID].session, 0, sizeof(ssl_session)); memset(&_SSL[sslID].session, 0, sizeof(ssl_session));
memset(&_SSL[sslID].hs, 0, sizeof(havege_state)); memset(&_SSL[sslID].hs, 0, sizeof(havege_state));
memset(_SSL[sslID].hostname, 0, NET_SSL_MAX_HOSTNAME_LEN); memset(_SSL[sslID].hostname, 0, NET_SSL_MAX_HOSTNAME_LEN);
_SSL[sslID].active = false; _SSL[sslID].active = false;
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
@ -284,13 +284,13 @@ _SSL_NEW_ERROR:
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferIn3, BufferInSize3, BufferOut, BufferOutSize, _BufferIn3, BufferInSize3, BufferOut, BufferOutSize,
BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
int ret = x509parse_crt_der( int ret = x509parse_crt_der(
&_SSL[sslID].cacert, &_SSL[sslID].cacert,
Memory::GetPointer(BufferOut2), Memory::GetPointer(BufferOut2),
BufferOutSize2); BufferOutSize2);
@ -304,7 +304,7 @@ _SSL_NEW_ERROR:
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
} }
else else
{ {
@ -341,7 +341,7 @@ _SSL_NEW_ERROR:
ssl_set_own_cert(&_SSL[sslID].ctx, &_SSL[sslID].clicert, &_SSL[sslID].rsa); ssl_set_own_cert(&_SSL[sslID].ctx, &_SSL[sslID].clicert, &_SSL[sslID].rsa);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, rsa_ret); WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, rsa_ret);
} }
else else
@ -385,7 +385,7 @@ _SSL_NEW_ERROR:
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX)); std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
int ret = x509parse_crtfile(&_SSL[sslID].cacert, (cert_base_path + "rootca.pem").c_str()); int ret = x509parse_crtfile(&_SSL[sslID].cacert, (cert_base_path + "rootca.pem").c_str());
if (ret) if (ret)
{ {
@ -475,7 +475,7 @@ _SSL_NEW_ERROR:
} }
case IOCTLV_NET_SSL_READ: case IOCTLV_NET_SSL_READ:
{ {
int ret = 0; int ret = 0;
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
@ -551,9 +551,9 @@ _SSL_NEW_ERROR:
BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
break; break;
} }
Memory::Write_U32(ReturnValue, _CommandAddress+4); Memory::Write_U32(ReturnValue, _CommandAddress+4);
return true; return true;
} }
u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command, u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command,

View File

@ -44,7 +44,7 @@ enum ssl_err_t
SSL_ERR_VCHAIN = -11, // verify failed: certificate chain SSL_ERR_VCHAIN = -11, // verify failed: certificate chain
SSL_ERR_VDATE = -12, // verify failed: date invalid SSL_ERR_VDATE = -12, // verify failed: date invalid
SSL_ERR_SERVER_CERT = -13, // certificate cert invalid SSL_ERR_SERVER_CERT = -13, // certificate cert invalid
}; };
enum SSL_IOCTL enum SSL_IOCTL
{ {
@ -83,7 +83,7 @@ class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device
{ {
public: public:
CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName); CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName);
virtual ~CWII_IPC_HLE_Device_net_ssl(); virtual ~CWII_IPC_HLE_Device_net_ssl();

View File

@ -12,7 +12,7 @@
#include <iphlpapi.h> #include <iphlpapi.h>
#include "fakepoll.h" #include "fakepoll.h"
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
#elif defined(__linux__) or defined(__APPLE__) #elif defined(__linux__) or defined(__APPLE__)
@ -170,7 +170,7 @@ public:
WiiSocket() : fd(-1), nonBlock(false) {} WiiSocket() : fd(-1), nonBlock(false) {}
~WiiSocket(); ~WiiSocket();
void operator=(WiiSocket const&); // Don't implement void operator=(WiiSocket const&); // Don't implement
}; };
class WiiSockMan class WiiSockMan
@ -196,7 +196,7 @@ public:
{ {
if (WiiSockets.find(sock) == WiiSockets.end()) if (WiiSockets.find(sock) == WiiSockets.end())
{ {
ERROR_LOG(WII_IPC_NET, ERROR_LOG(WII_IPC_NET,
"doSock: Error, fd not found (%08x, %08X, %08X)", "doSock: Error, fd not found (%08x, %08X, %08X)",
sock, CommandAddress, type); sock, CommandAddress, type);
EnqueueReply(CommandAddress, -SO_EBADF); EnqueueReply(CommandAddress, -SO_EBADF);

View File

@ -6,13 +6,13 @@
// Warning: a call to this poll() takes about 4K of stack space. // Warning: a call to this poll() takes about 4K of stack space.
// Greg Parker gparker-web@sealiesoftware.com December 2000 // Greg Parker gparker-web@sealiesoftware.com December 2000
// This code is in the public domain and may be copied or modified without // This code is in the public domain and may be copied or modified without
// permission. // permission.
// Updated May 2002: // Updated May 2002:
// * fix crash when an fd is less than 0 // * fix crash when an fd is less than 0
// * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE // * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
// * don't set POLLIN or POLLOUT in revents if it wasn't requested // * don't set POLLIN or POLLOUT in revents if it wasn't requested
// in events (only happens when an fd is in the poll set twice) // in events (only happens when an fd is in the poll set twice)
#if (_WIN32_WINNT < _WIN32_WINNT_VISTA) #if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
@ -70,7 +70,7 @@ inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
writep = NULL; writep = NULL;
exceptp = NULL; exceptp = NULL;
maxFD = 0; maxFD = 0;
} }
else { else {
pollEnd = pollSet + pollCount; pollEnd = pollSet + pollCount;
readp = &readFDs; readp = &readFDs;
@ -119,11 +119,11 @@ inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
if (selected < 0) { if (selected < 0) {
// Error during select // Error during select
result = -1; result = -1;
} }
else if (selected > 0) { else if (selected > 0) {
// Select found something // Select found something
// Transcribe result from fd sets to poll set. // Transcribe result from fd sets to poll set.
// Also count the number of selected fds. poll returns the // Also count the number of selected fds. poll returns the
// number of ready fds; select returns the number of bits set. // number of ready fds; select returns the number of bits set.
int polled = 0; int polled = 0;
for (p = pollSet; p < pollEnd; p++) { for (p = pollSet; p < pollEnd; p++) {

View File

@ -76,7 +76,7 @@ static u8 hex2char(u8 hex)
return hex - 'a' + 0xa; return hex - 'a' + 0xa;
else if (hex >= 'A' && hex <= 'F') else if (hex >= 'A' && hex <= 'F')
return hex - 'A' + 0xa; return hex - 'A' + 0xa;
ERROR_LOG(GDB_STUB, "Invalid nibble: %c (%02x)\n", hex, hex); ERROR_LOG(GDB_STUB, "Invalid nibble: %c (%02x)\n", hex, hex);
return 0; return 0;
} }
@ -93,7 +93,7 @@ static u8 nibble2hex(u8 n)
static void mem2hex(u8 *dst, u8 *src, u32 len) static void mem2hex(u8 *dst, u8 *src, u32 len)
{ {
u8 tmp; u8 tmp;
while (len-- > 0) { while (len-- > 0) {
tmp = *src++; tmp = *src++;
*dst++ = nibble2hex(tmp>>4); *dst++ = nibble2hex(tmp>>4);
@ -113,14 +113,14 @@ static u8 gdb_read_byte()
{ {
ssize_t res; ssize_t res;
u8 c = '+'; u8 c = '+';
res = recv(sock, &c, 1, MSG_WAITALL); res = recv(sock, &c, 1, MSG_WAITALL);
if (res != 1) if (res != 1)
{ {
ERROR_LOG(GDB_STUB, "recv failed : %ld", res); ERROR_LOG(GDB_STUB, "recv failed : %ld", res);
gdb_deinit(); gdb_deinit();
} }
return c; return c;
} }
@ -129,10 +129,10 @@ static u8 gdb_calc_chksum()
u32 len = cmd_len; u32 len = cmd_len;
u8 *ptr = cmd_bfr; u8 *ptr = cmd_bfr;
u8 c = 0; u8 c = 0;
while(len-- > 0) while(len-- > 0)
c += *ptr++; c += *ptr++;
return c; return c;
} }
@ -156,16 +156,16 @@ static gdb_bp_t *gdb_bp_empty_slot(u32 type)
{ {
gdb_bp_t *p; gdb_bp_t *p;
u32 i; u32 i;
p = gdb_bp_ptr(type); p = gdb_bp_ptr(type);
if (p == NULL) if (p == NULL)
return NULL; return NULL;
for (i = 0; i < GDB_MAX_BP; i++) { for (i = 0; i < GDB_MAX_BP; i++) {
if (p[i].active == 0) if (p[i].active == 0)
return &p[i]; return &p[i];
} }
return NULL; return NULL;
} }
@ -173,25 +173,25 @@ static gdb_bp_t *gdb_bp_find(u32 type, u32 addr, u32 len)
{ {
gdb_bp_t *p; gdb_bp_t *p;
u32 i; u32 i;
p = gdb_bp_ptr(type); p = gdb_bp_ptr(type);
if (p == NULL) if (p == NULL)
return NULL; return NULL;
for (i = 0; i < GDB_MAX_BP; i++) { for (i = 0; i < GDB_MAX_BP; i++) {
if (p[i].active == 1 && if (p[i].active == 1 &&
p[i].addr == addr && p[i].addr == addr &&
p[i].len == len) p[i].len == len)
return &p[i]; return &p[i];
} }
return NULL; return NULL;
} }
static void gdb_bp_remove(u32 type, u32 addr, u32 len) static void gdb_bp_remove(u32 type, u32 addr, u32 len)
{ {
gdb_bp_t *p; gdb_bp_t *p;
do { do {
p = gdb_bp_find(type, addr, len); p = gdb_bp_find(type, addr, len);
if (p != NULL) { if (p != NULL) {
@ -206,17 +206,17 @@ static int gdb_bp_check(u32 addr, u32 type)
{ {
gdb_bp_t *p; gdb_bp_t *p;
u32 i; u32 i;
p = gdb_bp_ptr(type); p = gdb_bp_ptr(type);
if (p == NULL) if (p == NULL)
return 0; return 0;
for (i = 0; i < GDB_MAX_BP; i++) { for (i = 0; i < GDB_MAX_BP; i++) {
if (p[i].active == 1 && if (p[i].active == 1 &&
(addr >= p[i].addr && addr < p[i].addr + p[i].len)) (addr >= p[i].addr && addr < p[i].addr + p[i].len))
return 1; return 1;
} }
return 0; return 0;
} }
@ -224,7 +224,7 @@ static void gdb_nak()
{ {
const char nak = GDB_STUB_NAK; const char nak = GDB_STUB_NAK;
ssize_t res; ssize_t res;
res = send(sock, &nak, 1, 0); res = send(sock, &nak, 1, 0);
if (res != 1) if (res != 1)
ERROR_LOG(GDB_STUB, "send failed"); ERROR_LOG(GDB_STUB, "send failed");
@ -234,7 +234,7 @@ static void gdb_ack()
{ {
const char ack = GDB_STUB_ACK; const char ack = GDB_STUB_ACK;
ssize_t res; ssize_t res;
res = send(sock, &ack, 1, 0); res = send(sock, &ack, 1, 0);
if (res != 1) if (res != 1)
ERROR_LOG(GDB_STUB, "send failed"); ERROR_LOG(GDB_STUB, "send failed");
@ -244,10 +244,10 @@ static void gdb_read_command()
{ {
u8 c; u8 c;
u8 chk_read, chk_calc; u8 chk_read, chk_calc;
cmd_len = 0; cmd_len = 0;
memset(cmd_bfr, 0, sizeof cmd_bfr); memset(cmd_bfr, 0, sizeof cmd_bfr);
c = gdb_read_byte(); c = gdb_read_byte();
if (c == '+') if (c == '+')
{ {
@ -264,7 +264,7 @@ static void gdb_read_command()
DEBUG_LOG(GDB_STUB, "gdb: read invalid byte %02x\n", c); DEBUG_LOG(GDB_STUB, "gdb: read invalid byte %02x\n", c);
return; return;
} }
while ((c = gdb_read_byte()) != GDB_STUB_END) { while ((c = gdb_read_byte()) != GDB_STUB_END) {
cmd_bfr[cmd_len++] = c; cmd_bfr[cmd_len++] = c;
if (cmd_len == sizeof cmd_bfr) if (cmd_len == sizeof cmd_bfr)
@ -274,20 +274,20 @@ static void gdb_read_command()
return; return;
} }
} }
chk_read = hex2char(gdb_read_byte()) << 4; chk_read = hex2char(gdb_read_byte()) << 4;
chk_read |= hex2char(gdb_read_byte()); chk_read |= hex2char(gdb_read_byte());
chk_calc = gdb_calc_chksum(); chk_calc = gdb_calc_chksum();
if (chk_calc != chk_read) { if (chk_calc != chk_read) {
ERROR_LOG(GDB_STUB, "gdb: invalid checksum: calculated %02x and read %02x for $%s# (length: %d)\n", chk_calc, chk_read, cmd_bfr, cmd_len); ERROR_LOG(GDB_STUB, "gdb: invalid checksum: calculated %02x and read %02x for $%s# (length: %d)\n", chk_calc, chk_read, cmd_bfr, cmd_len);
cmd_len = 0; cmd_len = 0;
gdb_nak(); gdb_nak();
return; return;
} }
DEBUG_LOG(GDB_STUB, "gdb: read command %c with a length of %d: %s\n", cmd_bfr[0], cmd_len, cmd_bfr); DEBUG_LOG(GDB_STUB, "gdb: read command %c with a length of %d: %s\n", cmd_bfr[0], cmd_len, cmd_bfr);
gdb_ack(); gdb_ack();
} }
@ -295,19 +295,19 @@ static void gdb_read_command()
static int gdb_data_available() { static int gdb_data_available() {
struct timeval t; struct timeval t;
fd_set _fds, *fds = &_fds; fd_set _fds, *fds = &_fds;
FD_ZERO(fds); FD_ZERO(fds);
FD_SET(sock, fds); FD_SET(sock, fds);
t.tv_sec = 0; t.tv_sec = 0;
t.tv_usec = 20; t.tv_usec = 20;
if (select(sock + 1, fds, NULL, NULL, &t) < 0) if (select(sock + 1, fds, NULL, NULL, &t) < 0)
{ {
ERROR_LOG(GDB_STUB, "select failed"); ERROR_LOG(GDB_STUB, "select failed");
return 0; return 0;
} }
if (FD_ISSET(sock, fds)) if (FD_ISSET(sock, fds))
return 1; return 1;
return 0; return 0;
@ -319,18 +319,18 @@ static void gdb_reply(const char *reply)
u32 left; u32 left;
u8 *ptr; u8 *ptr;
int n; int n;
if(!gdb_active()) if(!gdb_active())
return; return;
memset(cmd_bfr, 0, sizeof cmd_bfr); memset(cmd_bfr, 0, sizeof cmd_bfr);
cmd_len = strlen(reply); cmd_len = strlen(reply);
if (cmd_len + 4 > sizeof cmd_bfr) if (cmd_len + 4 > sizeof cmd_bfr)
ERROR_LOG(GDB_STUB, "cmd_bfr overflow in gdb_reply"); ERROR_LOG(GDB_STUB, "cmd_bfr overflow in gdb_reply");
memcpy(cmd_bfr + 1, reply, cmd_len); memcpy(cmd_bfr + 1, reply, cmd_len);
cmd_len++; cmd_len++;
chk = gdb_calc_chksum(); chk = gdb_calc_chksum();
cmd_len--; cmd_len--;
@ -338,9 +338,9 @@ static void gdb_reply(const char *reply)
cmd_bfr[cmd_len + 1] = GDB_STUB_END; cmd_bfr[cmd_len + 1] = GDB_STUB_END;
cmd_bfr[cmd_len + 2] = nibble2hex(chk >> 4); cmd_bfr[cmd_len + 2] = nibble2hex(chk >> 4);
cmd_bfr[cmd_len + 3] = nibble2hex(chk); cmd_bfr[cmd_len + 3] = nibble2hex(chk);
DEBUG_LOG(GDB_STUB, "gdb: reply (len: %d): %s\n", cmd_len, cmd_bfr); DEBUG_LOG(GDB_STUB, "gdb: reply (len: %d): %s\n", cmd_len, cmd_bfr);
ptr = cmd_bfr; ptr = cmd_bfr;
left = cmd_len + 4; left = cmd_len + 4;
while (left > 0) { while (left > 0) {
@ -358,12 +358,12 @@ static void gdb_reply(const char *reply)
static void gdb_handle_query() static void gdb_handle_query()
{ {
DEBUG_LOG(GDB_STUB, "gdb: query '%s'\n", cmd_bfr+1); DEBUG_LOG(GDB_STUB, "gdb: query '%s'\n", cmd_bfr+1);
if (!strcmp((const char *)(cmd_bfr+1), "TStatus")) if (!strcmp((const char *)(cmd_bfr+1), "TStatus"))
{ {
return gdb_reply("T0"); return gdb_reply("T0");
} }
gdb_reply(""); gdb_reply("");
} }
@ -403,10 +403,10 @@ static u32 re32hex(u8 *p)
{ {
u32 i; u32 i;
u32 res = 0; u32 res = 0;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
res = (res << 4) | hex2char(p[i]); res = (res << 4) | hex2char(p[i]);
return res; return res;
} }
@ -414,10 +414,10 @@ static u64 re64hex(u8 *p)
{ {
u32 i; u32 i;
u64 res = 0; u64 res = 0;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
res = (res << 4) | hex2char(p[i]); res = (res << 4) | hex2char(p[i]);
return res; return res;
} }
@ -425,7 +425,7 @@ static void gdb_read_register()
{ {
static u8 reply[64]; static u8 reply[64];
u32 id; u32 id;
memset(reply, 0, sizeof reply); memset(reply, 0, sizeof reply);
id = hex2char(cmd_bfr[1]); id = hex2char(cmd_bfr[1]);
if (cmd_bfr[2] != '\0') if (cmd_bfr[2] != '\0')
@ -433,8 +433,8 @@ static void gdb_read_register()
id <<= 4; id <<= 4;
id |= hex2char(cmd_bfr[2]); id |= hex2char(cmd_bfr[2]);
} }
switch (id) { switch (id) {
case 0 ... 31: case 0 ... 31:
wbe32hex(reply, GPR(id)); wbe32hex(reply, GPR(id));
@ -470,7 +470,7 @@ static void gdb_read_register()
return gdb_reply("E01"); return gdb_reply("E01");
break; break;
} }
gdb_reply((char *)reply); gdb_reply((char *)reply);
} }
@ -479,14 +479,14 @@ static void gdb_read_registers()
static u8 bfr[GDB_BFR_MAX - 4]; static u8 bfr[GDB_BFR_MAX - 4];
u8 * bufptr = bfr; u8 * bufptr = bfr;
u32 i; u32 i;
memset(bfr, 0, sizeof bfr); memset(bfr, 0, sizeof bfr);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
wbe32hex(bufptr + i*8, GPR(i)); wbe32hex(bufptr + i*8, GPR(i));
} }
bufptr += 32 * 8; bufptr += 32 * 8;
/* /*
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
wbe32hex(bufptr + i*8, riPS0(i)); wbe32hex(bufptr + i*8, riPS0(i));
@ -496,15 +496,15 @@ static void gdb_read_registers()
wbe32hex(bufptr, MSR); bufptr += 4; wbe32hex(bufptr, MSR); bufptr += 4;
wbe32hex(bufptr, GetCR()); bufptr += 4; wbe32hex(bufptr, GetCR()); bufptr += 4;
wbe32hex(bufptr, LR); bufptr += 4; wbe32hex(bufptr, LR); bufptr += 4;
wbe32hex(bufptr, CTR); bufptr += 4; wbe32hex(bufptr, CTR); bufptr += 4;
wbe32hex(bufptr, PowerPC::ppcState.spr[SPR_XER]); bufptr += 4; wbe32hex(bufptr, PowerPC::ppcState.spr[SPR_XER]); bufptr += 4;
// MQ register not used. // MQ register not used.
wbe32hex(bufptr, 0x0BADC0DE); bufptr += 4; wbe32hex(bufptr, 0x0BADC0DE); bufptr += 4;
*/ */
gdb_reply((char *)bfr); gdb_reply((char *)bfr);
} }
@ -512,21 +512,21 @@ static void gdb_write_registers()
{ {
u32 i; u32 i;
u8 * bufptr = cmd_bfr; u8 * bufptr = cmd_bfr;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
GPR(i) = re32hex(bufptr + i*8); GPR(i) = re32hex(bufptr + i*8);
} }
bufptr += 32 * 8; bufptr += 32 * 8;
gdb_reply("OK"); gdb_reply("OK");
} }
static void gdb_write_register() static void gdb_write_register()
{ {
u32 id; u32 id;
u8 * bufptr = cmd_bfr + 3; u8 * bufptr = cmd_bfr + 3;
id = hex2char(cmd_bfr[1]); id = hex2char(cmd_bfr[1]);
if (cmd_bfr[2] != '=') if (cmd_bfr[2] != '=')
{ {
@ -534,7 +534,7 @@ static void gdb_write_register()
id <<= 4; id <<= 4;
id |= hex2char(cmd_bfr[2]); id |= hex2char(cmd_bfr[2]);
} }
switch (id) { switch (id) {
case 0 ... 31: case 0 ... 31:
GPR(id) = re32hex(bufptr); GPR(id) = re32hex(bufptr);
@ -570,7 +570,7 @@ static void gdb_write_register()
return gdb_reply("E01"); return gdb_reply("E01");
break; break;
} }
gdb_reply("OK"); gdb_reply("OK");
} }
@ -579,18 +579,18 @@ static void gdb_read_mem()
static u8 reply[GDB_BFR_MAX - 4]; static u8 reply[GDB_BFR_MAX - 4];
u32 addr, len; u32 addr, len;
u32 i; u32 i;
i = 1; i = 1;
addr = 0; addr = 0;
while (cmd_bfr[i] != ',') while (cmd_bfr[i] != ',')
addr = (addr << 4) | hex2char(cmd_bfr[i++]); addr = (addr << 4) | hex2char(cmd_bfr[i++]);
i++; i++;
len = 0; len = 0;
while (i < cmd_len) while (i < cmd_len)
len = (len << 4) | hex2char(cmd_bfr[i++]); len = (len << 4) | hex2char(cmd_bfr[i++]);
DEBUG_LOG(GDB_STUB, "gdb: read memory: %08x bytes from %08x\n", len, addr); DEBUG_LOG(GDB_STUB, "gdb: read memory: %08x bytes from %08x\n", len, addr);
if (len*2 > sizeof reply) if (len*2 > sizeof reply)
gdb_reply("E01"); gdb_reply("E01");
u8 * data = Memory::GetPointer(addr); u8 * data = Memory::GetPointer(addr);
@ -598,25 +598,25 @@ static void gdb_read_mem()
return gdb_reply("E0"); return gdb_reply("E0");
mem2hex(reply, data, len); mem2hex(reply, data, len);
reply[len*2] = '\0'; reply[len*2] = '\0';
gdb_reply((char *)reply); gdb_reply((char *)reply);
} }
static void gdb_write_mem() static void gdb_write_mem()
{ {
u32 addr, len; u32 addr, len;
u32 i; u32 i;
i = 1; i = 1;
addr = 0; addr = 0;
while (cmd_bfr[i] != ',') while (cmd_bfr[i] != ',')
addr = (addr << 4) | hex2char(cmd_bfr[i++]); addr = (addr << 4) | hex2char(cmd_bfr[i++]);
i++; i++;
len = 0; len = 0;
while (cmd_bfr[i] != ':') while (cmd_bfr[i] != ':')
len = (len << 4) | hex2char(cmd_bfr[i++]); len = (len << 4) | hex2char(cmd_bfr[i++]);
DEBUG_LOG(GDB_STUB, "gdb: write memory: %08x bytes to %08x\n", len, addr); DEBUG_LOG(GDB_STUB, "gdb: write memory: %08x bytes to %08x\n", len, addr);
u8 * dst = Memory::GetPointer(addr); u8 * dst = Memory::GetPointer(addr);
if (!dst) if (!dst)
return gdb_reply("E00"); return gdb_reply("E00");
@ -647,11 +647,11 @@ bool gdb_add_bp(u32 type, u32 addr, u32 len)
bp = gdb_bp_empty_slot(type); bp = gdb_bp_empty_slot(type);
if (bp == NULL) if (bp == NULL)
return false; return false;
bp->active = 1; bp->active = 1;
bp->addr = addr; bp->addr = addr;
bp->len = len; bp->len = len;
DEBUG_LOG(GDB_STUB, "gdb: added %d breakpoint: %08x bytes at %08x\n", type, bp->len, bp->addr); DEBUG_LOG(GDB_STUB, "gdb: added %d breakpoint: %08x bytes at %08x\n", type, bp->len, bp->addr);
return true; return true;
} }
@ -660,7 +660,7 @@ static void _gdb_add_bp()
{ {
u32 type; u32 type;
u32 i, addr = 0, len = 0; u32 i, addr = 0, len = 0;
type = hex2char(cmd_bfr[1]); type = hex2char(cmd_bfr[1]);
switch (type) { switch (type) {
case 0: case 0:
@ -679,15 +679,15 @@ static void _gdb_add_bp()
default: default:
return gdb_reply("E01"); return gdb_reply("E01");
} }
i = 3; i = 3;
while (cmd_bfr[i] != ',') while (cmd_bfr[i] != ',')
addr = addr << 4 | hex2char(cmd_bfr[i++]); addr = addr << 4 | hex2char(cmd_bfr[i++]);
i++; i++;
while (i < cmd_len) while (i < cmd_len)
len = len << 4 | hex2char(cmd_bfr[i++]); len = len << 4 | hex2char(cmd_bfr[i++]);
if (!gdb_add_bp(type, addr, len)) if (!gdb_add_bp(type, addr, len))
return gdb_reply("E02"); return gdb_reply("E02");
gdb_reply("OK"); gdb_reply("OK");
@ -696,7 +696,7 @@ static void _gdb_add_bp()
static void gdb_remove_bp() static void gdb_remove_bp()
{ {
u32 type, addr, len, i; u32 type, addr, len, i;
type = hex2char(cmd_bfr[1]); type = hex2char(cmd_bfr[1]);
switch (type) { switch (type) {
case 0: case 0:
@ -715,18 +715,18 @@ static void gdb_remove_bp()
default: default:
return gdb_reply("E01"); return gdb_reply("E01");
} }
addr = 0; addr = 0;
len = 0; len = 0;
i = 3; i = 3;
while (cmd_bfr[i] != ',') while (cmd_bfr[i] != ',')
addr = (addr << 4) | hex2char(cmd_bfr[i++]); addr = (addr << 4) | hex2char(cmd_bfr[i++]);
i++; i++;
while (i < cmd_len) while (i < cmd_len)
len = (len << 4) | hex2char(cmd_bfr[i++]); len = (len << 4) | hex2char(cmd_bfr[i++]);
gdb_bp_remove(type, addr, len); gdb_bp_remove(type, addr, len);
gdb_reply("OK"); gdb_reply("OK");
} }
@ -739,7 +739,7 @@ void gdb_handle_exception()
gdb_read_command(); gdb_read_command();
if (cmd_len == 0) if (cmd_len == 0)
continue; continue;
switch(cmd_bfr[0]) { switch(cmd_bfr[0]) {
case 'q': case 'q':
gdb_handle_query(); gdb_handle_query();
@ -807,38 +807,38 @@ void gdb_init(u32 port)
#ifdef _WIN32 #ifdef _WIN32
WSAStartup(MAKEWORD(2,2), &InitData); WSAStartup(MAKEWORD(2,2), &InitData);
#endif #endif
memset(bp_x, 0, sizeof bp_x); memset(bp_x, 0, sizeof bp_x);
memset(bp_r, 0, sizeof bp_r); memset(bp_r, 0, sizeof bp_r);
memset(bp_w, 0, sizeof bp_w); memset(bp_w, 0, sizeof bp_w);
memset(bp_a, 0, sizeof bp_a); memset(bp_a, 0, sizeof bp_a);
tmpsock = socket(AF_INET, SOCK_STREAM, 0); tmpsock = socket(AF_INET, SOCK_STREAM, 0);
if (tmpsock == -1) if (tmpsock == -1)
ERROR_LOG(GDB_STUB, "Failed to create gdb socket"); ERROR_LOG(GDB_STUB, "Failed to create gdb socket");
on = 1; on = 1;
if (setsockopt(tmpsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on) < 0) if (setsockopt(tmpsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on) < 0)
ERROR_LOG(GDB_STUB, "Failed to setsockopt"); ERROR_LOG(GDB_STUB, "Failed to setsockopt");
memset(&saddr_server, 0, sizeof saddr_server); memset(&saddr_server, 0, sizeof saddr_server);
saddr_server.sin_family = AF_INET; saddr_server.sin_family = AF_INET;
saddr_server.sin_port = htons(port); saddr_server.sin_port = htons(port);
saddr_server.sin_addr.s_addr = INADDR_ANY; saddr_server.sin_addr.s_addr = INADDR_ANY;
if (bind(tmpsock, (struct sockaddr *)&saddr_server, sizeof saddr_server) < 0) if (bind(tmpsock, (struct sockaddr *)&saddr_server, sizeof saddr_server) < 0)
ERROR_LOG(GDB_STUB, "Failed to bind gdb socket"); ERROR_LOG(GDB_STUB, "Failed to bind gdb socket");
if (listen(tmpsock, 1) < 0) if (listen(tmpsock, 1) < 0)
ERROR_LOG(GDB_STUB, "Failed to listen to gdb socket"); ERROR_LOG(GDB_STUB, "Failed to listen to gdb socket");
INFO_LOG(GDB_STUB, "Waiting for gdb to connect...\n"); INFO_LOG(GDB_STUB, "Waiting for gdb to connect...\n");
sock = accept(tmpsock, (struct sockaddr *)&saddr_client, &len); sock = accept(tmpsock, (struct sockaddr *)&saddr_client, &len);
if (sock < 0) if (sock < 0)
ERROR_LOG(GDB_STUB, "Failed to accept gdb client"); ERROR_LOG(GDB_STUB, "Failed to accept gdb client");
INFO_LOG(GDB_STUB, "Client connected.\n"); INFO_LOG(GDB_STUB, "Client connected.\n");
saddr_client.sin_addr.s_addr = ntohl(saddr_client.sin_addr.s_addr); saddr_client.sin_addr.s_addr = ntohl(saddr_client.sin_addr.s_addr);
/*if (((saddr_client.sin_addr.s_addr >> 24) & 0xff) != 127 || /*if (((saddr_client.sin_addr.s_addr >> 24) & 0xff) != 127 ||
* ((saddr_client.sin_addr.s_addr >> 16) & 0xff) != 0 || * ((saddr_client.sin_addr.s_addr >> 16) & 0xff) != 0 ||
@ -863,7 +863,7 @@ void gdb_deinit()
shutdown(sock, SHUT_RDWR); shutdown(sock, SHUT_RDWR);
sock = -1; sock = -1;
} }
#ifdef _WIN32 #ifdef _WIN32
WSACleanup(); WSACleanup();
#endif #endif
@ -878,14 +878,14 @@ int gdb_signal(u32 s)
{ {
if (sock == -1) if (sock == -1)
return 1; return 1;
sig = s; sig = s;
if (send_signal) { if (send_signal) {
gdb_handle_signal(); gdb_handle_signal();
send_signal = 0; send_signal = 0;
} }
return 0; return 0;
} }
@ -893,15 +893,15 @@ int gdb_bp_x(u32 addr)
{ {
if (sock == -1) if (sock == -1)
return 0; return 0;
if (step_break) if (step_break)
{ {
step_break = 0; step_break = 0;
DEBUG_LOG(GDB_STUB, "Step was successful."); DEBUG_LOG(GDB_STUB, "Step was successful.");
return 1; return 1;
} }
return gdb_bp_check(addr, GDB_BP_TYPE_X); return gdb_bp_check(addr, GDB_BP_TYPE_X);
} }
@ -909,7 +909,7 @@ int gdb_bp_r(u32 addr)
{ {
if (sock == -1) if (sock == -1)
return 0; return 0;
return gdb_bp_check(addr, GDB_BP_TYPE_R); return gdb_bp_check(addr, GDB_BP_TYPE_R);
} }
@ -917,7 +917,7 @@ int gdb_bp_w(u32 addr)
{ {
if (sock == -1) if (sock == -1)
return 0; return 0;
return gdb_bp_check(addr, GDB_BP_TYPE_W); return gdb_bp_check(addr, GDB_BP_TYPE_W);
} }
@ -925,6 +925,6 @@ int gdb_bp_a(u32 addr)
{ {
if (sock == -1) if (sock == -1)
return 0; return 0;
return gdb_bp_check(addr, GDB_BP_TYPE_A); return gdb_bp_check(addr, GDB_BP_TYPE_A);
} }

View File

@ -113,28 +113,28 @@ int Interpreter::SingleStepInner(void)
{ {
#ifdef USE_GDBSTUB #ifdef USE_GDBSTUB
if (gdb_active() && gdb_bp_x(PC)) { if (gdb_active() && gdb_bp_x(PC)) {
Host_UpdateDisasmDialog(); Host_UpdateDisasmDialog();
gdb_signal(SIGTRAP); gdb_signal(SIGTRAP);
gdb_handle_exception(); gdb_handle_exception();
} }
#endif #endif
NPC = PC + sizeof(UGeckoInstruction); NPC = PC + sizeof(UGeckoInstruction);
instCode.hex = Memory::Read_Opcode(PC); instCode.hex = Memory::Read_Opcode(PC);
// Uncomment to trace the interpreter // Uncomment to trace the interpreter
//if ((PC & 0xffffff)>=0x0ab54c && (PC & 0xffffff)<=0x0ab624) //if ((PC & 0xffffff)>=0x0ab54c && (PC & 0xffffff)<=0x0ab624)
// startTrace = 1; // startTrace = 1;
//else //else
// startTrace = 0; // startTrace = 0;
if (startTrace) if (startTrace)
{ {
Trace(instCode); Trace(instCode);
} }
if (instCode.hex != 0) if (instCode.hex != 0)
{ {
UReg_MSR& msr = (UReg_MSR&)MSR; UReg_MSR& msr = (UReg_MSR&)MSR;
@ -176,7 +176,7 @@ int Interpreter::SingleStepInner(void)
} }
last_pc = PC; last_pc = PC;
PC = NPC; PC = NPC;
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)
if (PowerPC::ppcState.gpr[1] == 0) if (PowerPC::ppcState.gpr[1] == 0)
{ {
@ -191,9 +191,9 @@ int Interpreter::SingleStepInner(void)
} }
void Interpreter::SingleStep() void Interpreter::SingleStep()
{ {
SingleStepInner(); SingleStepInner();
CoreTiming::slicelength = 1; CoreTiming::slicelength = 1;
CoreTiming::downcount = 0; CoreTiming::downcount = 0;
CoreTiming::Advance(); CoreTiming::Advance();
@ -240,8 +240,8 @@ void Interpreter::Run()
if (PCVec.size() > ShowSteps) if (PCVec.size() > ShowSteps)
PCVec.erase(PCVec.begin()); PCVec.erase(PCVec.begin());
#endif #endif
//2: check for breakpoint //2: check for breakpoint
if (PowerPC::breakpoints.IsAddressBreakPoint(PC)) if (PowerPC::breakpoints.IsAddressBreakPoint(PC))
{ {

View File

@ -48,7 +48,7 @@ void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, c
NG_priv = default_NG_priv; NG_priv = default_NG_priv;
NG_sig = default_NG_sig; NG_sig = default_NG_sig;
} }
sprintf(name, "NG%08x", NG_id); sprintf(name, "NG%08x", NG_id);
make_blanksig_ec_cert(ng_cert_out, "Root-CA00000001-MS00000002", name, NG_priv, NG_key_id); make_blanksig_ec_cert(ng_cert_out, "Root-CA00000001-MS00000002", name, NG_priv, NG_key_id);
memcpy(ng_cert_out + 4, NG_sig, 60); memcpy(ng_cert_out + 4, NG_sig, 60);
@ -71,29 +71,29 @@ void get_ap_sig_and_cert(u8 *sig_out, u8 *ap_cert_out, u64 title_id, u8 *data, u
u8 ap_priv[30]; u8 ap_priv[30];
char signer[64]; char signer[64];
char name[64]; char name[64];
if((NG_id==0)||(NG_priv == NULL)) if((NG_id==0)||(NG_priv == NULL))
{ {
NG_priv = default_NG_priv; NG_priv = default_NG_priv;
NG_id = default_NG_id; NG_id = default_NG_id;
} }
memset(ap_priv, 0, 0x1e); memset(ap_priv, 0, 0x1e);
ap_priv[0x1d] = 1; ap_priv[0x1d] = 1;
// setup random ap_priv here if desired // setup random ap_priv here if desired
// get_rand_bytes(ap_priv, 0x1e); // get_rand_bytes(ap_priv, 0x1e);
// ap_priv[0] &= 1; // ap_priv[0] &= 1;
memset(ap_cert_out+4, 0, 60); memset(ap_cert_out+4, 0, 60);
sprintf(signer, "Root-CA00000001-MS00000002-NG%08x", NG_id); sprintf(signer, "Root-CA00000001-MS00000002-NG%08x", NG_id);
sprintf(name, "AP%08x%08x", (u32)(title_id>>32), (u32)(title_id&0xffffffff)); sprintf(name, "AP%08x%08x", (u32)(title_id>>32), (u32)(title_id&0xffffffff));
make_blanksig_ec_cert(ap_cert_out, signer, name, ap_priv, 0); make_blanksig_ec_cert(ap_cert_out, signer, name, ap_priv, 0);
sha1(ap_cert_out + 0x80, 0x100, hash); sha1(ap_cert_out + 0x80, 0x100, hash);
generate_ecdsa(ap_cert_out+4, ap_cert_out+34, NG_priv, hash); generate_ecdsa(ap_cert_out+4, ap_cert_out+34, NG_priv, hash);
sha1(data, data_size, hash); sha1(data, data_size, hash);
generate_ecdsa(sig_out, sig_out + 30, ap_priv, hash); generate_ecdsa(sig_out, sig_out + 30, ap_priv, hash);
} }
@ -102,7 +102,7 @@ void make_blanksig_ec_cert(u8 *cert_out, const char *signer, const char *name, c
{ {
memset(cert_out, 0, 0x180); memset(cert_out, 0, 0x180);
*(u32*)cert_out = Common::swap32(0x10002); *(u32*)cert_out = Common::swap32(0x10002);
strncpy((char*)cert_out + 0x80, signer, 0x40); strncpy((char*)cert_out + 0x80, signer, 0x40);
*(u32*)(cert_out + 0xc0) = Common::swap32(2); *(u32*)(cert_out + 0xc0) = Common::swap32(2);
strncpy((char*)cert_out + 0xc4, name, 0x40); strncpy((char*)cert_out + 0xc4, name, 0x40);
@ -123,12 +123,12 @@ void get_shared_secret(u8* shared_secret_out, u8* remote_public_key, u8* NG_priv
{ {
NG_priv = default_NG_priv; NG_priv = default_NG_priv;
} }
// required point_mul in Source/Core/Common/Src/Crypto/ec.cpp // required point_mul in Source/Core/Common/Src/Crypto/ec.cpp
// to be made non-static // to be made non-static
point_mul(shared_secret_out, NG_priv, remote_public_key); point_mul(shared_secret_out, NG_priv, remote_public_key);
} }
EcWii::EcWii() EcWii::EcWii()
@ -143,7 +143,7 @@ EcWii::EcWii()
if(keys_f.ReadBytes(&BootMiiKeysBin, sizeof(BootMiiKeysBin))) if(keys_f.ReadBytes(&BootMiiKeysBin, sizeof(BootMiiKeysBin)))
{ {
init = false; init = false;
INFO_LOG(WII_IPC_ES, "Successfully loaded keys.bin created by: %s", BootMiiKeysBin.creator); INFO_LOG(WII_IPC_ES, "Successfully loaded keys.bin created by: %s", BootMiiKeysBin.creator);
} }
else else
@ -159,8 +159,8 @@ EcWii::EcWii()
else else
{ {
ERROR_LOG(WII_IPC_ES, "%s could not be found. Using default values. We recommend you grab keys.bin from BootMii.", keys_path.c_str()); ERROR_LOG(WII_IPC_ES, "%s could not be found. Using default values. We recommend you grab keys.bin from BootMii.", keys_path.c_str());
} }
if(init) if(init)
InitDefaults(); InitDefaults();
} }
@ -172,10 +172,10 @@ EcWii::~EcWii()
void EcWii::InitDefaults() void EcWii::InitDefaults()
{ {
memset(&BootMiiKeysBin, 0, sizeof(BootMiiKeysBin)); memset(&BootMiiKeysBin, 0, sizeof(BootMiiKeysBin));
BootMiiKeysBin.ng_id = Common::swap32(default_NG_id); BootMiiKeysBin.ng_id = Common::swap32(default_NG_id);
BootMiiKeysBin.ng_key_id = Common::swap32(default_NG_key_id); BootMiiKeysBin.ng_key_id = Common::swap32(default_NG_key_id);
memcpy(BootMiiKeysBin.ng_priv, default_NG_priv, sizeof(BootMiiKeysBin.ng_priv)); memcpy(BootMiiKeysBin.ng_priv, default_NG_priv, sizeof(BootMiiKeysBin.ng_priv));
memcpy(BootMiiKeysBin.ng_sig, default_NG_sig, sizeof(BootMiiKeysBin.ng_sig)); memcpy(BootMiiKeysBin.ng_sig, default_NG_sig, sizeof(BootMiiKeysBin.ng_sig));
} }

View File

@ -4,16 +4,16 @@
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
/* /*
* *
* Structs for keys.bin taken from: * Structs for keys.bin taken from:
* *
* mini - a Free Software replacement for the Nintendo/BroadOn IOS. * mini - a Free Software replacement for the Nintendo/BroadOn IOS.
* crypto hardware support * crypto hardware support
* *
* Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com> * Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
* Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com> * Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
* Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com> * Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
* *
* # This code is licensed to you under the terms of the GNU GPL, version 2; * # This code is licensed to you under the terms of the GNU GPL, version 2;
* # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*/ */
@ -43,7 +43,7 @@ public:
const u8* getNgSig() {return BootMiiKeysBin.ng_sig;}; const u8* getNgSig() {return BootMiiKeysBin.ng_sig;};
private: private:
void InitDefaults(); void InitDefaults();
#pragma pack(push,1) #pragma pack(push,1)
typedef struct typedef struct
{ {
@ -55,11 +55,11 @@ private:
u16 checksum; u16 checksum;
} }
#ifndef _WIN32 #ifndef _WIN32
__attribute__((packed)) __attribute__((packed))
#endif #endif
eep_ctr_t; eep_ctr_t;
struct struct
{ {
u8 creator [0x100]; // 0x000 u8 creator [0x100]; // 0x000
u8 boot1_hash [ 0x14]; // 0x100 u8 boot1_hash [ 0x14]; // 0x100
@ -68,7 +68,7 @@ private:
union { union {
struct { struct {
u8 ng_priv [ 0x1e]; // 0x128 u8 ng_priv [ 0x1e]; // 0x128
u8 pad1 [ 0x12]; u8 pad1 [ 0x12];
}; };
struct { struct {
u8 pad2 [ 0x1c]; u8 pad2 [ 0x1c];
@ -80,7 +80,7 @@ private:
u32 unk1; //0x178 u32 unk1; //0x178
u32 unk2; //0x17C u32 unk2; //0x17C
u8 eeprom_pad [ 0x80]; //0x180 u8 eeprom_pad [ 0x80]; //0x180
u32 ms_id; //0x200 u32 ms_id; //0x200
u32 ca_id; //0x204 u32 ca_id; //0x204
u32 ng_key_id; //0x208 u32 ng_key_id; //0x208
@ -91,19 +91,19 @@ private:
u8 pad3 [ 0x74]; //0x284 u8 pad3 [ 0x74]; //0x284
u16 prng_seed [ 0x02]; //0x2F8 u16 prng_seed [ 0x02]; //0x2F8
u8 pad4 [ 0x04]; //0x2FC u8 pad4 [ 0x04]; //0x2FC
u8 crack_pad [0x100]; //0x300 u8 crack_pad [0x100]; //0x300
} }
#ifndef _WIN32 #ifndef _WIN32
__attribute__((packed)) __attribute__((packed))
#endif #endif
BootMiiKeysBin; BootMiiKeysBin;
#pragma pack(pop) #pragma pack(pop)
}; };
#endif #endif