Wiimote: Ignored faulty L2CAP packets, allowing libogc's demo to run unaltered. Found raw data representing pointing to the screen.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@588 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
masken
2008-09-20 15:34:20 +00:00
parent ae948f1a23
commit 66011849cd
9 changed files with 82 additions and 16 deletions

View File

@ -64,17 +64,24 @@ protected:
for (u32 i=0; i<NumberInBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
//restore cached address, mauled by emulatee's ioctl functions.
Memory::Write_U32(Buffer.m_Address | 0x80000000, BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
LOG(WII_IPC_HLE, "SIOCtlVBuffer in%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
InBuffer.push_back(Buffer);
}
for (u32 i=0; i<NumberPayloadBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
Memory::Write_U32(Buffer.m_Address | 0x80000000, BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
LOG(WII_IPC_HLE, "SIOCtlVBuffer io%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
PayloadBuffer.push_back(Buffer);
}
}
}
// STATE_TO_SAVE

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "WII_IPC_HLE_Device_usb.h"
#include "../Plugins/Plugin_Wiimote.h"
#include <vector>
CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName)
@ -24,6 +25,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
, m_pACLBuffer(NULL)
, m_pHCIBuffer(NULL)
, m_State(STATE_NONE)
, m_UpdateWaitCount(0)
, scan_enable(0)
, m_DelayedEvent(EVENT_NONE)
{
@ -190,8 +192,6 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress)
return true;
}
extern void SendFrame(CWII_IPC_HLE_Device_usb_oh1_57e_305* _pDevice, u16 _ConnectionHandle, u8* _pData, u32 _Size);
void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size)
{
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_ConnectionHandle);
@ -234,6 +234,15 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame(u16 _ConnectionHandle, u8
u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
{
#if 0
if(m_UpdateWaitCount < 5) {
m_UpdateWaitCount++;
return 0;
} else {
m_UpdateWaitCount = 0;
}
#endif
//LOG(WIIMOTE, "Update() %i 0x%08x",
//m_HCICommandMessageQueue.size(), m_pHCIBuffer);
// check state machine
@ -366,6 +375,8 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
return Addr;
}
PluginWiimote::Wiimote_Update();
return 0;
}

View File

@ -162,6 +162,7 @@ private:
};
EState m_State;
u32 m_UpdateWaitCount;
bdaddr_t m_StateTempBD;
u16 m_StateTempConnectionHandle;

View File

@ -177,10 +177,13 @@ void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size)
u8* pData = _pData + sizeof(SL2CAP_Header);
u32 DataSize = _Size - sizeof(SL2CAP_Header);
LOG(WIIMOTE, "L2Cap-SendFrame: Len 0x%x, Channel 0x%04x",
pHeader->Length, pHeader->CID);
LOG(WIIMOTE, "L2Cap-SendFrame: Channel 0x%04x, Len 0x%x, DataSize 0x%x",
pHeader->CID, pHeader->Length, DataSize);
_dbg_assert_(WIIMOTE, pHeader->Length == DataSize);
if(pHeader->Length != DataSize) {
LOG(WIIMOTE, "Faulty packet. It is dropped.");
return;
}
switch (pHeader->CID)
{

View File

@ -29,6 +29,7 @@ namespace PluginWiimote
TWiimote_Initialize Wiimote_Initialize = 0;
TWiimote_Shutdown Wiimote_Shutdown = 0;
TWiimote_Output Wiimote_Output = 0;
TWiimote_Update Wiimote_Update = 0;
TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers = 0;
TWiimote_DoState Wiimote_DoState = 0;
@ -51,6 +52,7 @@ namespace PluginWiimote
Wiimote_Initialize = 0;
Wiimote_Shutdown = 0;
Wiimote_Output = 0;
Wiimote_Update = 0;
Wiimote_GetAttachedControllers = 0;
Wiimote_DoState = 0;
}
@ -66,6 +68,7 @@ namespace PluginWiimote
Wiimote_Initialize = reinterpret_cast<TWiimote_Initialize> (plugin.Get("Wiimote_Initialize"));
Wiimote_Shutdown = reinterpret_cast<TWiimote_Shutdown> (plugin.Get("Wiimote_Shutdown"));
Wiimote_Output = reinterpret_cast<TWiimote_Output> (plugin.Get("Wiimote_Output"));
Wiimote_Update = reinterpret_cast<TWiimote_Update> (plugin.Get("Wiimote_Update"));
Wiimote_GetAttachedControllers = reinterpret_cast<TWiimote_GetAttachedControllers> (plugin.Get("Wiimote_GetAttachedControllers"));
Wiimote_DoState = reinterpret_cast<TWiimote_DoState> (plugin.Get("Wiimote_DoState"));
@ -75,12 +78,14 @@ namespace PluginWiimote
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Initialize", Wiimote_Initialize);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Shutdown", Wiimote_Shutdown);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Output", Wiimote_Output);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Update", Wiimote_Update);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_GetAttachedControllers", Wiimote_GetAttachedControllers);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_DoState", Wiimote_DoState);
if ((GetDllInfo != 0) &&
(Wiimote_Initialize != 0) &&
(Wiimote_Shutdown != 0) &&
(Wiimote_Output != 0) &&
(Wiimote_Update != 0) &&
(Wiimote_GetAttachedControllers != 0) &&
(Wiimote_DoState != 0))
{

View File

@ -32,6 +32,7 @@ typedef void (__cdecl* TDllAbout)(HWND);
typedef void (__cdecl* TDllConfig)(HWND);
typedef void (__cdecl* TWiimote_Initialize)(SWiimoteInitialize);
typedef void (__cdecl* TWiimote_Shutdown)();
typedef void (__cdecl* TWiimote_Update)();
typedef void (__cdecl* TWiimote_Output)(const void* _pData, u32 _Size);
typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)();
typedef void (__cdecl* TWiimote_DoState)(void *ptr, int mode);
@ -43,6 +44,7 @@ extern TDllConfig DllConfig;
extern TWiimote_Initialize Wiimote_Initialize;
extern TWiimote_Shutdown Wiimote_Shutdown;
extern TWiimote_Output Wiimote_Output;
extern TWiimote_Update Wiimote_Update;
extern TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;
extern TWiimote_DoState Wiimote_DoState;