Fix a bug introduced by me when I thought I was fixing something.

Thanks skidau.
Fixes Mario Kart Wii not being able to write.
This was caused by reuse of a buffer containing an error code.
This commit is contained in:
Matthew Parlane 2013-01-14 00:16:10 +13:00
parent 6e58c50065
commit 20b43ac1c5
2 changed files with 19 additions and 16 deletions

View File

@ -182,20 +182,20 @@ void CWII_IPC_HLE_Device_FileIO::CloseFile()
bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
{
u32 ReturnValue = FS_RESULT_FATAL;
const u32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC);
const u32 Mode = Memory::Read_U32(_CommandAddress + 0x10);
const s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC);
const s32 Mode = Memory::Read_U32(_CommandAddress + 0x10);
if (OpenFile())
{
ReturnValue = FS_RESULT_FATAL;
const u64 fileSize = m_pFileHandle.GetSize();
INFO_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08llx)", SeekPosition, Mode, m_Name.c_str(), fileSize);
const s64 fileSize = m_pFileHandle.GetSize();
INFO_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08llx) (%08X)", SeekPosition, Mode, m_Name.c_str(), fileSize, m_DeviceID);
switch (Mode){
case 0:
{
if (SeekPosition <= fileSize)
if ((SeekPosition >=0) && (SeekPosition <= fileSize))
{
m_SeekPos = SeekPosition;
ReturnValue = m_SeekPos;
@ -204,8 +204,8 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
}
case 1:
{
u32 wantedPos = SeekPosition+m_SeekPos;
if (wantedPos <= fileSize)
s32 wantedPos = SeekPosition+m_SeekPos;
if (wantedPos >=0 && wantedPos <= fileSize)
{
m_SeekPos = wantedPos;
ReturnValue = m_SeekPos;
@ -214,8 +214,8 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
}
case 2:
{
u64 wantedPos = fileSize+m_SeekPos;
if (wantedPos <= fileSize)
s32 wantedPos = fileSize+m_SeekPos;
if (wantedPos >=0 && wantedPos <= fileSize)
{
m_SeekPos = wantedPos;
ReturnValue = m_SeekPos;
@ -328,12 +328,12 @@ bool CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
{
case ISFS_IOCTL_GETFILESTATS:
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: ISFS_IOCTL_GETFILESTATS");
if (OpenFile())
{
u32 m_FileLength = (u32)m_pFileHandle.GetSize();
const u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
INFO_LOG(WII_IPC_FILEIO, "FileIO: ISFS_IOCTL_GETFILESTATS");
INFO_LOG(WII_IPC_FILEIO, " File: %s, Length: %i, Pos: %i", m_Name.c_str(), m_FileLength, m_SeekPos);
Memory::Write_U32(m_FileLength, BufferOut);

View File

@ -133,6 +133,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
Memory::Write_U32(0, BufferOut); // no error
break;
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
@ -141,6 +142,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR : // NWC24iResumeForCloseLib
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
Memory::Write_U32(0, BufferOut); // no error
break;
case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket
@ -169,7 +171,6 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_INITIAL)
{
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
@ -212,14 +213,16 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
}
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED)
{
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_GENERATED, BufferOut);
}
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_REGISTERED)
{
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_REGISTERED, BufferOut);
}
Memory::Write_U64(config.Id(), BufferOut + 4);
Memory::Write_U32(config.CreationStage(), BufferOut + 0xC);
break;
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
break;
@ -1656,9 +1659,9 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
hints.ai_socktype = Memory::Read_U32(_BufferIn3 + 0x8);
hints.ai_protocol = Memory::Read_U32(_BufferIn3 + 0xC);
hints.ai_addrlen = Memory::Read_U32(_BufferIn3 + 0x10);
hints.ai_canonname = (char*)Memory::GetPointer(Memory::Read_U32(_BufferIn3 + 0x14));
hints.ai_addr = (sockaddr *)Memory::GetPointer(Memory::Read_U32(_BufferIn3 + 0x18));
hints.ai_next = (addrinfo *)Memory::GetPointer(Memory::Read_U32(_BufferIn3 + 0x1C));
hints.ai_canonname = (char*)Memory::Read_U32(_BufferIn3 + 0x14);
hints.ai_addr = (sockaddr *)Memory::Read_U32(_BufferIn3 + 0x18);
hints.ai_next = (addrinfo *)Memory::Read_U32(_BufferIn3 + 0x1C);
}
char* pNodeName = NULL;