kernel level HLE

This commit is contained in:
Aaron Robinson 2003-04-05 09:03:02 +00:00
parent ee86b41aa1
commit 66e0d7d6d1
14 changed files with 296 additions and 215 deletions

View File

@ -5,19 +5,23 @@ version: 0.7.0 (??/??/??)
- Added Controller Input and Configuration!
- __declspec(thread) style TLS is working!!
- Added Recent Xbe/Exe file menus
- Fixed GUI color issues
- Massive code re-organization.
- Lots of random optimizations
- Went lower level with certain components of
emulation. This should allow progress to move
faster, ironically.
- Some Xbe parsing and debug output fixes.
You should now be able to deal with the
slightly odd Linux Xbe files.
- __declspec(thread) style TLS is working!!
- Massive code re-organization.
- Lots of random optimizations
- Fixed GUI color issues
version: 0.6.0-pre12 (02/23/03)
--------------------------------

View File

@ -211,34 +211,18 @@ typedef struct _STRING
STRING, ANSI_STRING, *PSTRING, *PANSI_STRING;
// ******************************************************************
// * KeDelayExecutionThread
// * RTL_CRITICAL_SECTION
// ******************************************************************
NTSYSAPI NTSTATUS NTAPI KeDelayExecutionThread
(
IN KPROCESSOR_MODE WaitMode,
IN BOOLEAN Alertable,
IN PLARGE_INTEGER Interval
);
// ******************************************************************
// * NtSetLdtEntries
// ******************************************************************
NTSYSAPI NTSTATUS NTAPI NtSetLdtEntries
(
IN USHORT Selector1,
IN LDT_ENTRY Descriptor1,
IN USHORT Selector2,
IN LDT_ENTRY Descriptor2
);
// ******************************************************************
// * 0x0121 - RtlInitAnsiString
// ******************************************************************
typedef VOID (NTAPI *FPTR_RtlInitAnsiString)
(
IN OUT PANSI_STRING DestinationString,
IN PCSZ SourceString
);
typedef struct _RTL_CRITICAL_SECTION
{
DWORD Unknown[4]; // 0x00
LONG LockCount; // 0x10
LONG RecursionCount; // 0x14
HANDLE OwningThread; // 0x18
HANDLE LockSemaphore;
DWORD Reserved;
}
RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
// ******************************************************************
// * Valid values for the Attributes field
@ -336,6 +320,86 @@ NTSYSAPI NTSTATUS NTAPI ZwOpenFile
IN ULONG OpenOptions
);
// ******************************************************************
// * KeDelayExecutionThread
// ******************************************************************
NTSYSAPI NTSTATUS NTAPI KeDelayExecutionThread
(
IN KPROCESSOR_MODE WaitMode,
IN BOOLEAN Alertable,
IN PLARGE_INTEGER Interval
);
// ******************************************************************
// * NtSetLdtEntries
// ******************************************************************
NTSYSAPI NTSTATUS NTAPI NtSetLdtEntries
(
IN USHORT Selector1,
IN LDT_ENTRY Descriptor1,
IN USHORT Selector2,
IN LDT_ENTRY Descriptor2
);
// ******************************************************************
// * RtlNtStatusToDosError
// ******************************************************************
typedef ULONG (NTAPI *FPTR_RtlNtStatusToDosError)(NTSTATUS Status);
// ******************************************************************
// * RtlInitAnsiString
// ******************************************************************
typedef VOID (NTAPI *FPTR_RtlInitAnsiString)
(
IN OUT PANSI_STRING DestinationString,
IN PCSZ SourceString
);
// ******************************************************************
// * NtAllocateVirtualMemory
// ******************************************************************
typedef NTSTATUS (NTAPI *FPTR_NtAllocateVirtualMemory)
(
IN HANDLE ProcessHandle,
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
IN OUT PULONG RegionSize,
IN ULONG AllocationType,
IN ULONG Protect
);
// ******************************************************************
// * NtClose
// ******************************************************************
typedef NTSTATUS (NTAPI *FPTR_NtClose)
(
IN HANDLE Handle
);
// ******************************************************************
// * RtlInitializeCriticalSection
// ******************************************************************
typedef VOID (NTAPI *FPTR_RtlInitializeCriticalSection)
(
IN PRTL_CRITICAL_SECTION CriticalSection
);
// ******************************************************************
// * RtlEnterCriticalSection
// ******************************************************************
typedef VOID (NTAPI *FPTR_RtlEnterCriticalSection)
(
IN PRTL_CRITICAL_SECTION CriticalSection
);
// ******************************************************************
// * RtlLeaveCriticalSection
// ******************************************************************
typedef VOID (NTAPI *FPTR_RtlLeaveCriticalSection)
(
IN PRTL_CRITICAL_SECTION CriticalSection
);
#if defined(__cplusplus)
}
#endif

View File

@ -34,6 +34,8 @@
#ifndef INPUTCONFIG_H
#define INPUTCONFIG_H
#include <string.h>
// ******************************************************************
// * Input Device Component IDs
// ******************************************************************
@ -125,9 +127,10 @@ class InputConfig
void Get(InputDeviceComponent idc, int *dwDevice, int *dwInfo, int *dwFlags);
// ******************************************************************
// * To enumerate device names
// * To enumerate and set device names
// ******************************************************************
const char *GetDeviceName(int offset) { return (const char*)m_DeviceName[offset]; }
void SetDeviceName(int offset, const char *device_name) { strncpy(m_DeviceName[offset], device_name, 259); }
private:
// ******************************************************************
@ -138,7 +141,7 @@ class InputConfig
// ******************************************************************
// * Devices used by one or more input mappings
// ******************************************************************
char m_DeviceName[260][MAX_INPUT_DEVICES];
char m_DeviceName[MAX_INPUT_DEVICES][260];
// ******************************************************************
// * Input Device Components

View File

@ -371,6 +371,8 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
int b=0;
dwFlags = INPUT_MAPPING_JOYSTICK;
if(abs(InputState.lX) > JOYSTICK_DETECT_SENSITIVITY)
{
dwHow = FIELD_OFFSET(DIJOYSTATE, lX);
@ -425,7 +427,7 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
g_InputConfig.Map(idc, DeviceInstance.tszInstanceName, ObjectInstance.dwType, dwFlags);
printf("Cxbx: Detected %s on %s (dwType : %.08X)\n", ObjectInstance.tszName, DeviceInstance.tszInstanceName, ObjectInstance.dwType);
printf("Cxbx: Detected %s on %s\n", ObjectInstance.tszName, DeviceInstance.tszInstanceName, ObjectInstance.dwType);
sprintf(szNewText, "%s Successfully Mapped To %s On %s!", szOrgText, ObjectInstance.tszName, DeviceInstance.tszInstanceName);
}
@ -439,6 +441,8 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
g_pInputDev[v]->GetDeviceState(256, InputState);
dwFlags = INPUT_MAPPING_KEYBOARD;
for(int v=0;v<256;v++)
{
if(InputState[v] != 0)
@ -466,13 +470,15 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
g_pInputDev[v]->GetDeviceState(sizeof(DIMOUSESTATE2), &InputState);
dwFlags = INPUT_MAPPING_MOUSE;
// detect button changes
for(int b=0;b<8;b++)
{
if(InputState.rgbButtons[b] & 0x80)
{
dwHow = b;
dwFlags &= INPUT_MAPPING_MOUSE_CLICK;
dwFlags |= INPUT_MAPPING_MOUSE_CLICK;
break;
}
}
@ -492,7 +498,7 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
LONG delta_lX=0, delta_lY=0, delta_lZ=0;
LONG absd_lX=0, absd_lY=0, absd_lZ=0;
if(InputState.lX == -1 || InputState.lY == -1 || InputState.lZ == -1)
if(LastMouse_lY == -1 || LastMouse_lY == -1 || LastMouse_lZ == -1)
delta_lX = delta_lY = delta_lZ = 0;
else
{
@ -509,37 +515,43 @@ void ConfigureInput(HWND hWndDlg, HWND hWndButton, InputDeviceComponent idc)
max = (max > absd_lZ) ? max : absd_lZ;
LastMouse_lX = InputState.lX;
LastMouse_lY = InputState.lY;
LastMouse_lZ = InputState.lZ;
if(max > MOUSE_DETECT_SENSITIVITY)
{
if(max == absd_lX && absd_lX > MOUSE_DETECT_SENSITIVITY)
{
dwHow = FIELD_OFFSET(DIMOUSESTATE2, lX);
dwHow = DIMOFS_X;
dwFlags |= (delta_lX > 0) ? INPUT_MAPPING_AXIS_POSITIVE : INPUT_MAPPING_AXIS_NEGATIVE;
}
else if(max == absd_lY && absd_lY > MOUSE_DETECT_SENSITIVITY)
{
dwHow = FIELD_OFFSET(DIMOUSESTATE2, lY);
dwHow = DIMOFS_Y;
dwFlags |= (delta_lY > 0) ? INPUT_MAPPING_AXIS_POSITIVE : INPUT_MAPPING_AXIS_NEGATIVE;
}
else if(max == absd_lZ && absd_lZ > MOUSE_DETECT_SENSITIVITY)
{
dwHow = FIELD_OFFSET(DIMOUSESTATE2, lZ);
dwHow = DIMOFS_Z;
dwFlags |= (delta_lZ > 0) ? INPUT_MAPPING_AXIS_POSITIVE : INPUT_MAPPING_AXIS_NEGATIVE;
}
LastMouse_lX = InputState.lX;
LastMouse_lY = InputState.lY;
LastMouse_lZ = InputState.lZ;
if(dwHow != -1)
{
g_pInputDev[v]->GetObjectInfo(&ObjectInstance, dwHow, DIPH_BYOFFSET);
g_InputConfig.Map(idc, "SysMouse", dwHow, dwFlags);
printf("Cxbx: Detected Movement on the %s %s on SysMouse\n", (dwFlags & INPUT_MAPPING_AXIS_POSITIVE) ? "Positive" : "Negative", ObjectInstance.tszName);
ObjectInstance.dwSize = sizeof(ObjectInstance);
sprintf(szNewText, "%s Successfully Mapped To %s %s On %s!", szOrgText, (dwFlags & INPUT_MAPPING_AXIS_POSITIVE) ? "Positive" : "Negative", ObjectInstance.tszName, "SysMouse");
char *szDirection = (dwFlags & INPUT_MAPPING_AXIS_POSITIVE) ? "Positive" : "Negative";
char *szObjName = "Unknown";
if(g_pInputDev[v]->GetObjectInfo(&ObjectInstance, dwHow, DIPH_BYOFFSET) == DI_OK)
szObjName = ObjectInstance.tszName;
printf("Cxbx: Detected Movement on the %s %s on SysMouse\n", szDirection, szObjName);
sprintf(szNewText, "%s Successfully Mapped To %s %s On %s!", szOrgText, szDirection, szObjName, "SysMouse");
}
}
}

View File

@ -123,6 +123,8 @@ void EmuGenerateFS()
// HACK: This converts from XBE stack form to Windows form (I guess?!)
TLSPtr = (void*)((uint32)TLSPtr+20 + (2*8));
NewPcr->PrcbData.CurrentThread->TlsData = TLSPtr;
}
// ******************************************************************
@ -142,10 +144,12 @@ void EmuGenerateFS()
// ******************************************************************
// * Save "TLSPtr" inside NewFS.StackBase
// ******************************************************************
__asm
{
mov eax, TLSPtr
mov fs:[0x04], eax
__asm
{
mov eax, TLSPtr
mov fs:[0x04], eax
}
}
// ******************************************************************

View File

@ -58,36 +58,43 @@ namespace xntdll
// ******************************************************************
// * Loaded at run-time to avoid linker conflicts
// ******************************************************************
xntdll::FPTR_RtlInitAnsiString NT_RtlInitAnsiString = (xntdll::FPTR_RtlInitAnsiString)GetProcAddress(GetModuleHandle("ntdll"), "RtlInitAnsiString");
HMODULE hNtDll = GetModuleHandle("ntdll");
xntdll::FPTR_RtlInitAnsiString NT_RtlInitAnsiString = (xntdll::FPTR_RtlInitAnsiString)GetProcAddress(hNtDll, "RtlInitAnsiString");
xntdll::FPTR_RtlNtStatusToDosError NT_RtlNtStatusToDosError = (xntdll::FPTR_RtlNtStatusToDosError)GetProcAddress(hNtDll, "RtlNtStatusToDosError");
xntdll::FPTR_NtAllocateVirtualMemory NT_NtAllocateVirtualMemory = (xntdll::FPTR_NtAllocateVirtualMemory)GetProcAddress(hNtDll, "NtAllocateVirtualMemory");
xntdll::FPTR_NtClose NT_NtClose = (xntdll::FPTR_NtClose)GetProcAddress(hNtDll, "NtClose");
xntdll::FPTR_RtlInitializeCriticalSection NT_RtlInitializeCriticalSection = (xntdll::FPTR_RtlInitializeCriticalSection)GetProcAddress(hNtDll, "RtlInitializeCriticalSection");
xntdll::FPTR_RtlEnterCriticalSection NT_RtlEnterCriticalSection = (xntdll::FPTR_RtlEnterCriticalSection)GetProcAddress(hNtDll, "RtlEnterCriticalSection");
xntdll::FPTR_RtlLeaveCriticalSection NT_RtlLeaveCriticalSection = (xntdll::FPTR_RtlLeaveCriticalSection)GetProcAddress(hNtDll, "RtlLeaveCriticalSection");
// ******************************************************************
// * (HELPER) PsCreateSystemThreadExProxyParam
// * (Helper) PCSTProxyParam
// ******************************************************************
typedef struct _PsCreateSystemThreadExProxyParam
typedef struct _PCSTProxyParam
{
IN PVOID StartContext1;
IN PVOID StartContext2;
IN PVOID StartRoutine;
}
PsCreateSystemThreadExProxyParam;
PCSTProxyParam;
// ******************************************************************
// * PsCreateSystemThreadExProxy
// * (Helper) PCSTProxy
// ******************************************************************
#pragma warning(push)
#pragma warning(disable: 4731) // disable ebp modification warning
DWORD WINAPI PsCreateSystemThreadExProxy
DWORD WINAPI PCSTProxy
(
IN PVOID Parameter
)
{
PsCreateSystemThreadExProxyParam *iPsCreateSystemThreadExProxyParam = (PsCreateSystemThreadExProxyParam*)Parameter;
PCSTProxyParam *iPCSTProxyParam = (PCSTProxyParam*)Parameter;
uint32 StartContext1 = (uint32)iPsCreateSystemThreadExProxyParam->StartContext1;
uint32 StartContext2 = (uint32)iPsCreateSystemThreadExProxyParam->StartContext2;
uint32 StartRoutine = (uint32)iPsCreateSystemThreadExProxyParam->StartRoutine;
uint32 StartContext1 = (uint32)iPCSTProxyParam->StartContext1;
uint32 StartContext2 = (uint32)iPCSTProxyParam->StartContext2;
uint32 StartRoutine = (uint32)iPCSTProxyParam->StartRoutine;
delete iPsCreateSystemThreadExProxyParam;
delete iPCSTProxyParam;
EmuGenerateFS();
@ -96,7 +103,7 @@ DWORD WINAPI PsCreateSystemThreadExProxy
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuKrnl (0x%.08X): PsCreateSystemThreadExProxy\n"
printf("EmuKrnl (0x%.08X): PCSTProxy\n"
"(\n"
" StartContext1 : 0x%.08X\n"
" StartContext2 : 0x%.08X\n"
@ -108,6 +115,9 @@ DWORD WINAPI PsCreateSystemThreadExProxy
EmuSwapFS(); // Xbox FS
// ******************************************************************
// * use the special calling convention
// ******************************************************************
__asm
{
mov esi, StartRoutine
@ -122,8 +132,6 @@ callComplete:
nop
}
// EmuSwapFS();
return 0;
}
#pragma warning(pop)
@ -214,19 +222,10 @@ XBSYSAPI EXPORTNUM(49) VOID DECLSPEC_NORETURN xboxkrnl::HalReturnToFirmware
}
#endif
MessageBox(NULL, "HalReturnToFirmware()", "EmuKrnl", MB_OK);
MessageBox(NULL, "Warning: XBE is quitting (HalReturnToFirmware).\n\nThis process may not terminate elegantly.", "Cxbx", MB_OK);
ExitProcess(0);
/*
ReturnFirmwareHalt = 0x0,
ReturnFirmwareReboot = 0x1,
ReturnFirmwareQuickReboot = 0x2,
ReturnFirmwareHard = 0x3,
ReturnFirmwareFatal = 0x4,
ReturnFirmwareAll = 0x5
*/
EmuSwapFS(); // Xbox FS
}
@ -375,9 +374,14 @@ XBSYSAPI EXPORTNUM(149) xboxkrnl::BOOLEAN NTAPI xboxkrnl::KeSetTimer
EmuSwapFS(); // Xbox FS
return FALSE;
return TRUE;
}
// ******************************************************************
// * 0x00A4 - LaunchDataPage (actually a pointer)
// ******************************************************************
XBSYSAPI EXPORTNUM(164) xboxkrnl::DWORD xboxkrnl::LaunchDataPage = 0;
// ******************************************************************
// * 0x00B8 - NtAllocateVirtualMemory
// ******************************************************************
@ -385,7 +389,7 @@ XBSYSAPI EXPORTNUM(184) NTSTATUS xboxkrnl::NtAllocateVirtualMemory
(
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
IN OUT SIZE_T AllocationSize,
IN OUT PULONG AllocationSize,
IN DWORD AllocationType,
IN DWORD Protect
)
@ -409,11 +413,11 @@ XBSYSAPI EXPORTNUM(184) NTSTATUS xboxkrnl::NtAllocateVirtualMemory
}
#endif
*BaseAddress = VirtualAlloc(*BaseAddress, AllocationSize, AllocationType, Protect);
NTSTATUS ret = NT_NtAllocateVirtualMemory(GetCurrentProcess(), BaseAddress, ZeroBits, AllocationSize, AllocationType, Protect);
EmuSwapFS(); // Xbox FS
return STATUS_SUCCESS;
return ret;
}
// ******************************************************************
@ -439,12 +443,11 @@ XBSYSAPI EXPORTNUM(187) NTSTATUS NTAPI xboxkrnl::NtClose
}
#endif
if(CloseHandle(Handle) != TRUE)
return STATUS_UNSUCCESSFUL;
NTSTATUS ret = NT_NtClose(Handle);
EmuSwapFS(); // Xbox FS
return STATUS_SUCCESS;
return ret;
}
// ******************************************************************
@ -565,19 +568,24 @@ XBSYSAPI EXPORTNUM(255) NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadEx
}
#endif
DWORD dwThreadId = NULL;
// ******************************************************************
// * create thread, using our special proxy technique
// ******************************************************************
{
DWORD dwThreadId;
// PsCreateSystemThreadExProxy is responsible for cleaning up this pointer
::PsCreateSystemThreadExProxyParam *iPsCreateSystemThreadProxyParam = new ::PsCreateSystemThreadExProxyParam();
// PCSTProxy is responsible for cleaning up this pointer
::PCSTProxyParam *iPCSTProxyParam = new ::PCSTProxyParam();
iPsCreateSystemThreadProxyParam->StartContext1 = StartContext1;
iPsCreateSystemThreadProxyParam->StartContext2 = StartContext2;
iPsCreateSystemThreadProxyParam->StartRoutine = StartRoutine;
iPCSTProxyParam->StartContext1 = StartContext1;
iPCSTProxyParam->StartContext2 = StartContext2;
iPCSTProxyParam->StartRoutine = StartRoutine;
*ThreadHandle = CreateThread(NULL, NULL, &PsCreateSystemThreadExProxy, iPsCreateSystemThreadProxyParam, NULL, &dwThreadId);
*ThreadHandle = CreateThread(NULL, NULL, &PCSTProxy, iPCSTProxyParam, NULL, &dwThreadId);
if(ThreadId != NULL)
*ThreadId = dwThreadId;
if(ThreadId != NULL)
*ThreadId = dwThreadId;
}
EmuSwapFS(); // Xbox FS
@ -607,13 +615,14 @@ XBSYSAPI EXPORTNUM(277) VOID NTAPI xboxkrnl::RtlEnterCriticalSection
}
#endif
// We have to initialize this because the Xbox software doesn't seem
// to always do it. Redundant initializations seem to be ok :/
InitializeCriticalSection((::PRTL_CRITICAL_SECTION)CriticalSection);
// This seems redundant, but xbox software doesn't always do it
NT_RtlInitializeCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
EnterCriticalSection((::PRTL_CRITICAL_SECTION)CriticalSection);
NT_RtlEnterCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
EmuSwapFS(); // Xbox FS
return;
}
// ******************************************************************
@ -671,7 +680,7 @@ XBSYSAPI EXPORTNUM(291) VOID NTAPI xboxkrnl::RtlInitializeCriticalSection
}
#endif
InitializeCriticalSection((::PRTL_CRITICAL_SECTION)CriticalSection);
NT_RtlInitializeCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
EmuSwapFS(); // Xbox FS
@ -688,6 +697,9 @@ XBSYSAPI EXPORTNUM(294) VOID NTAPI xboxkrnl::RtlLeaveCriticalSection
{
EmuSwapFS(); // Win2k/XP FS
// Note: We need to execute this before debug output to avoid trouble
NT_RtlLeaveCriticalSection((xntdll::_RTL_CRITICAL_SECTION*)CriticalSection);
// ******************************************************************
// * debug trace
// ******************************************************************
@ -701,9 +713,9 @@ XBSYSAPI EXPORTNUM(294) VOID NTAPI xboxkrnl::RtlLeaveCriticalSection
}
#endif
LeaveCriticalSection((::PRTL_CRITICAL_SECTION)CriticalSection);
EmuSwapFS(); // Xbox FS
return;
}
// ******************************************************************
@ -729,7 +741,9 @@ XBSYSAPI EXPORTNUM(301) xboxkrnl::ULONG NTAPI xboxkrnl::RtlNtStatusToDosError
}
#endif
ULONG ret = NT_RtlNtStatusToDosError(Status);
EmuSwapFS(); // Xbox FS
return 0;
return ret;
}

View File

@ -337,6 +337,8 @@ HANDLE WINAPI xapi::EmuCreateThread
lpThreadId
);
printf("Returned : %d\n", RetHandle);
EmuSwapFS(); // XBox FS
return RetHandle;
@ -418,8 +420,9 @@ VOID WINAPI xapi::EmuXapiBootDash(DWORD UnknownA, DWORD UnknownB, DWORD UnknownC
}
#endif
// TODO: Cleanly "Boot Dash" :-)
exit(0);
MessageBox(NULL, "Warning: XBE has done a bad bad thing.\n\nThis process may not terminate elegantly.", "Cxbx", MB_OK);
ExitProcess(0);
EmuSwapFS(); // XBox FS

View File

@ -228,7 +228,7 @@ extern "C" CXBXKRNL_API uint32 KernelThunkTable[367] =
(uint32)PANIC(0x00A1), // 0x00A1 (161)
(uint32)PANIC(0x00A2), // 0x00A2 (162)
(uint32)PANIC(0x00A3), // 0x00A3 (163)
(uint32)PANIC(0x00A4), // 0x00A4 (164)
(uint32)&xboxkrnl::LaunchDataPage, // 0x00A4 (164)
(uint32)PANIC(0x00A5), // 0x00A5 (165)
(uint32)PANIC(0x00A6), // 0x00A6 (166)
(uint32)PANIC(0x00A7), // 0x00A7 (167)

View File

@ -177,6 +177,7 @@ SOOVPA<9> __cinit_1_0_3911 =
// ******************************************************************
OOVPATable XAPI_1_0_3911[] =
{
/* Too High Level
// CreateThread
{
(OOVPA*)&CreateThread_1_0_3911,
@ -187,6 +188,8 @@ OOVPATable XAPI_1_0_3911[] =
"EmuCreateThread"
#endif
},
*/
/* Too High Level
// XapiInitProcess
{
(OOVPA*)&XapiInitProcess_1_0_3911,
@ -197,6 +200,7 @@ OOVPATable XAPI_1_0_3911[] =
"EmuXapiInitProcess"
#endif
},
*/
// XapiBootToDash
{
(OOVPA*)&XapiBootDash_1_0_3911,
@ -207,6 +211,7 @@ OOVPATable XAPI_1_0_3911[] =
"EmuXapiBootDash"
#endif
},
/* Too High Level
// __rtinit
{
(OOVPA*)&__rtinit_1_0_3911,
@ -216,7 +221,8 @@ OOVPATable XAPI_1_0_3911[] =
#ifdef _DEBUG_TRACE
"Emu__rtinit",
#endif
},
},*/
/* Too High Level
// __cinit
{
(OOVPA*)&__cinit_1_0_3911,
@ -226,7 +232,7 @@ OOVPATable XAPI_1_0_3911[] =
#ifdef _DEBUG_TRACE
"Emu__cinit",
#endif
},
},*/
};
// ******************************************************************

View File

@ -31,14 +31,14 @@
// * All rights reserved
// *
// ******************************************************************
/*
// ******************************************************************
// * XInitDevices
// ******************************************************************
// * NOTE: We are actually intercepting USBD_Init, because XInitDevices
// * Simply redirects to that function
// * NOTE: We are actually intercepting USBD_Init, because
// * XInitDevices Simply redirects to that function
// ******************************************************************
SOOVPA<10> XInitDevices_1_0_4361 =
SOOVPA<10> XInitDevices_1_0_4034 =
{
0, // Large == 0
10, // Count == 10
@ -67,7 +67,7 @@ SOOVPA<10> XInitDevices_1_0_4361 =
// ******************************************************************
// * XGetDevices
// ******************************************************************
SOOVPA<14> XGetDevices_1_0_4361 =
SOOVPA<14> XGetDevices_1_0_4034 =
{
0, // Large == 0
14, // Count == 14
@ -98,11 +98,11 @@ SOOVPA<14> XGetDevices_1_0_4361 =
{ 0x20, 0x04 }, // (Offset,Value)-Pair #14
}
};
/*
// ******************************************************************
// * XInputOpen
// ******************************************************************
SOOVPA<12> XInputOpen_1_0_4361 =
SOOVPA<12> XInputOpen_1_0_4034 =
{
0, // Large == 0
12, // Count == 12
@ -287,10 +287,9 @@ SOOVPA<7> XapiInitProcess_1_0_4361 =
// ******************************************************************
OOVPATable XAPI_1_0_4034[] =
{
/*
// XInitDevices
{
(OOVPA*)&XInitDevices_1_0_4361,
(OOVPA*)&XInitDevices_1_0_4034,
xapi::EmuXInitDevices,
@ -300,7 +299,7 @@ OOVPATable XAPI_1_0_4034[] =
},
// XGetDevices
{
(OOVPA*)&XGetDevices_1_0_4361,
(OOVPA*)&XGetDevices_1_0_4034,
xapi::EmuXGetDevices,
@ -308,9 +307,10 @@ OOVPATable XAPI_1_0_4034[] =
"EmuXGetDevices"
#endif
},
/* These functions havent been rev'd yet (may be same as new/old)
// XInputOpen
{
(OOVPA*)&XInputOpen_1_0_4361,
(OOVPA*)&XInputOpen_1_0_4034,
xapi::EmuXInputOpen,
@ -339,6 +339,7 @@ OOVPATable XAPI_1_0_4034[] =
#endif
},
*/
/* Too High Level
// CreateThread (* unchanged since 1.0.3911 *)
{
(OOVPA*)&CreateThread_1_0_3911,
@ -349,6 +350,7 @@ OOVPATable XAPI_1_0_4034[] =
"EmuCreateThread"
#endif
},
*/
/*
// CloseHandle (*???*)
{
@ -361,6 +363,7 @@ OOVPATable XAPI_1_0_4034[] =
#endif
},
*/
/* Too High Level
// XapiInitProcess (* unchanged since 1.0.3911 *)
{
(OOVPA*)&XapiInitProcess_1_0_3911,
@ -371,6 +374,7 @@ OOVPATable XAPI_1_0_4034[] =
"EmuXapiInitProcess"
#endif
},
*/
// XapiBootToDash (* unchanged since 1.0.3911 *)
{
(OOVPA*)&XapiBootDash_1_0_3911,
@ -381,6 +385,7 @@ OOVPATable XAPI_1_0_4034[] =
"EmuXapiBootDash"
#endif
},
/* Too High Level
// __rtinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__rtinit_1_0_3911,
@ -390,7 +395,8 @@ OOVPATable XAPI_1_0_4034[] =
#ifdef _DEBUG_TRACE
"Emu__rtinit",
#endif
},
},*/
/* Too High Level
// __cinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__cinit_1_0_3911,
@ -400,7 +406,7 @@ OOVPATable XAPI_1_0_4034[] =
#ifdef _DEBUG_TRACE
"Emu__cinit",
#endif
},
},*/
};
// ******************************************************************

View File

@ -32,38 +32,6 @@
// *
// ******************************************************************
// ******************************************************************
// * XInitDevices
// ******************************************************************
// * NOTE: We are actually intercepting USBD_Init, because XInitDevices
// * Simply redirects to that function
// ******************************************************************
SOOVPA<10> XInitDevices_1_0_4361 =
{
0, // Large == 0
10, // Count == 10
{
// XInitDevices+0x03 : push 0xB4
{ 0x03, 0x68 }, // (Offset,Value)-Pair #1
{ 0x04, 0xB4 }, // (Offset,Value)-Pair #2
// XInitDevices+0x10 : jmp +0x13
{ 0x10, 0x74 }, // (Offset,Value)-Pair #3
{ 0x11, 0x13 }, // (Offset,Value)-Pair #4
// XInitDevices+0x5B : movzx eax, byte ptr [esi+0xA1]
{ 0x5B, 0x0F }, // (Offset,Value)-Pair #5
{ 0x5C, 0xB6 }, // (Offset,Value)-Pair #6
{ 0x5D, 0x86 }, // (Offset,Value)-Pair #7
{ 0x5E, 0xA1 }, // (Offset,Value)-Pair #8
// XInitDevices+0x8B : retn 8
{ 0x8B, 0xC2 }, // (Offset,Value)-Pair #9
{ 0x8C, 0x08 }, // (Offset,Value)-Pair #10
}
};
// ******************************************************************
// * XGetDevices
// ******************************************************************
@ -287,9 +255,9 @@ SOOVPA<7> XapiInitProcess_1_0_4361 =
// ******************************************************************
OOVPATable XAPI_1_0_4361[] =
{
// XInitDevices
// XInitDevices (* unchanged since 1.0.4034 *)
{
(OOVPA*)&XInitDevices_1_0_4361,
(OOVPA*)&XInitDevices_1_0_4034,
xapi::EmuXInitDevices,
@ -337,6 +305,7 @@ OOVPATable XAPI_1_0_4361[] =
"EmuXInputGetState"
#endif
},
/* Too High Level
// CreateThread
{
(OOVPA*)&CreateThread_1_0_4361,
@ -347,6 +316,8 @@ OOVPATable XAPI_1_0_4361[] =
"EmuCreateThread"
#endif
},
*/
/* Too High Level
// CloseHandle
{
(OOVPA*)&CloseHandle_1_0_4361,
@ -357,6 +328,8 @@ OOVPATable XAPI_1_0_4361[] =
"EmuCloseHandle"
#endif
},
*/
/* Too High Level
// XapiInitProcess
{
(OOVPA*)&XapiInitProcess_1_0_4361,
@ -367,6 +340,7 @@ OOVPATable XAPI_1_0_4361[] =
"EmuXapiInitProcess"
#endif
},
*/
// XapiBootToDash (* unchanged since 1.0.3911 *)
{
(OOVPA*)&XapiBootDash_1_0_3911,
@ -377,6 +351,7 @@ OOVPATable XAPI_1_0_4361[] =
"EmuXapiBootDash"
#endif
},
/* Too High Level
// __rtinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__rtinit_1_0_3911,
@ -386,7 +361,8 @@ OOVPATable XAPI_1_0_4361[] =
#ifdef _DEBUG_TRACE
"Emu__rtinit",
#endif
},
},*/
/* Too High Level
// __cinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__cinit_1_0_3911,
@ -396,7 +372,7 @@ OOVPATable XAPI_1_0_4361[] =
#ifdef _DEBUG_TRACE
"Emu__cinit",
#endif
},
},*/
};
// ******************************************************************

View File

@ -37,9 +37,9 @@
// ******************************************************************
OOVPATable XAPI_1_0_4627[] =
{
// XInitDevices (* unchanged since 1.0.4361 *)
// XInitDevices (* unchanged since 1.0.4034 *)
{
(OOVPA*)&XInitDevices_1_0_4361,
(OOVPA*)&XInitDevices_1_0_4034,
xapi::EmuXInitDevices,
@ -87,6 +87,7 @@ OOVPATable XAPI_1_0_4627[] =
"EmuXInputGetState"
#endif
},
/* Too High Level
// CreateThread (* unchanged since 1.0.4361 *)
{
(OOVPA*)&CreateThread_1_0_4361,
@ -97,6 +98,8 @@ OOVPATable XAPI_1_0_4627[] =
"EmuCreateThread"
#endif
},
*/
/* Too High Level
// CloseHandle (* unchanged since 1.0.4361 *)
{
(OOVPA*)&CloseHandle_1_0_4361,
@ -107,6 +110,8 @@ OOVPATable XAPI_1_0_4627[] =
"EmuCloseHandle"
#endif
},
*/
/* Too High Level
// XapiInitProcess (* unchanged since 1.0.4361 *)
{
(OOVPA*)&XapiInitProcess_1_0_4361,
@ -117,6 +122,7 @@ OOVPATable XAPI_1_0_4627[] =
"EmuXapiInitProcess"
#endif
},
*/
// XapiBootToDash (* unchanged since 1.0.3911 *)
{
(OOVPA*)&XapiBootDash_1_0_3911,
@ -127,6 +133,7 @@ OOVPATable XAPI_1_0_4627[] =
"EmuXapiBootDash"
#endif
},
/* Too High Level
// __rtinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__rtinit_1_0_3911,
@ -136,7 +143,8 @@ OOVPATable XAPI_1_0_4627[] =
#ifdef _DEBUG_TRACE
"Emu__rtinit",
#endif
},
},*/
/* Too High Level
// __cinit (* unchanged since 1.0.3911 *)
{
(OOVPA*)&__cinit_1_0_3911,
@ -147,6 +155,7 @@ OOVPATable XAPI_1_0_4627[] =
"Emu__cinit",
#endif
},
*/
};
// ******************************************************************

View File

@ -103,8 +103,8 @@ CXBXKRNL_API void EmuShared::Init()
// ******************************************************************
if(init)
{
g_EmuShared->LoadInputConfiguration();
g_EmuShared->InitInputConfiguration();
g_EmuShared->LoadInputConfiguration();
}
}
@ -157,66 +157,44 @@ CXBXKRNL_API void EmuShared::LoadInputConfiguration()
// * Load configuration from registry
// ******************************************************************
{
/*
DWORD dwDisposition, dwType, dwSize;
HKEY hKey;
if(RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Cxbx\\Input", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
{
for(int v=0;v<MAX_INPUT_DEVICES;v++)
char szBuffer[128];
char szDeviceName[260] = "";
for(int d=0;d<MAX_INPUT_DEVICES;d++)
{
const char *szCur = m_InputConfig.GetDeviceName(d);
if(szCur[0] == '\0')
continue;
sprintf(szBuffer, "Device Name #%d", d);
dwType = REG_SZ; dwSize = 260;
RegQueryValueEx(hKey, szBuffer, NULL, &dwType, (PBYTE)szDeviceName, &dwSize);
m_InputConfig.SetDeviceName(d, szDeviceName);
}
for(int c=0;c<INPUT_DEVICE_COMPONENT_COUNT;c++)
{
int RawData[3] = {-1, -1, 0}; // dwDevice, dwInfo, dwFlags
sprintf(szBuffer, "Component : %s", g_InputDeviceTitle[c]);
dwType = REG_BINARY; dwSize = sizeof(RawData);
RegQueryValueEx(hKey, szBuffer, NULL, &dwType, (PBYTE)&RawData[0], &dwSize);
if(RawData[0] != -1)
m_InputConfig.Map((InputDeviceComponent)c, m_InputConfig.GetDeviceName(RawData[0]), RawData[1], RawData[2]);
}
RegCloseKey(hKey);
/*
dwType = REG_DWORD; dwSize = sizeof(DWORD);
RegQueryValueEx(hKey, "CxbxDebug", NULL, &dwType, (PBYTE)&m_CxbxDebug, &dwSize);
dwType = REG_DWORD; dwSize = sizeof(DWORD);
RegQueryValueEx(hKey, "KrnlDebug", NULL, &dwType, (PBYTE)&m_KrnlDebug, &dwSize);
dwType = REG_DWORD; dwSize = sizeof(DWORD);
RegQueryValueEx(hKey, "RecentXbe", NULL, &dwType, (PBYTE)&m_dwRecentXbe, &dwSize);
dwType = REG_DWORD; dwSize = sizeof(DWORD);
RegQueryValueEx(hKey, "RecentExe", NULL, &dwType, (PBYTE)&m_dwRecentExe, &dwSize);
dwType = REG_DWORD; dwSize = sizeof(DWORD);
RegQueryValueEx(hKey, "AutoConvertToExe", NULL, &dwType, (PBYTE)&m_bAutoConvertToExe, &dwSize);
dwType = REG_SZ; dwSize = 260;
RegQueryValueEx(hKey, "CxbxDebugFilename", NULL, &dwType, (PBYTE)m_CxbxDebugFilename, &dwSize);
dwType = REG_SZ; dwSize = 260;
RegQueryValueEx(hKey, "KrnlDebugFilename", NULL, &dwType, (PBYTE)m_KrnlDebugFilename, &dwSize);
int v=0;
for(v=0;v<m_dwRecentXbe;v++)
{
char buffer[32];
sprintf(buffer, "RecentXbe%d", v);
m_szRecentXbe[v] = (char*)calloc(1, 260);
dwType = REG_SZ; dwSize = 260;
RegQueryValueEx(hKey, buffer, NULL, &dwType, (PBYTE)m_szRecentXbe[v], &dwSize);
}
for(v=0;v<m_dwRecentExe;v++)
{
char buffer[32];
sprintf(buffer, "RecentExe%d", v);
m_szRecentExe[v] = (char*)calloc(1, 260);
dwType = REG_SZ; dwSize = 260;
RegQueryValueEx(hKey, buffer, NULL, &dwType, (PBYTE)m_szRecentExe[v], &dwSize);
}
}
*/
}
Unlock();
@ -246,18 +224,20 @@ CXBXKRNL_API void EmuShared::SaveInputConfiguration()
{
const char *szCur = m_InputConfig.GetDeviceName(d);
if(szCur[0] == '\0')
continue;
sprintf(szBuffer, "Device Name #%d", d);
dwType = REG_SZ; dwSize = 260;
RegSetValueEx(hKey, szBuffer, 0, dwType, (PBYTE)szCur, dwSize);
if(szCur[0] == '\0')
RegDeleteValue(hKey, szBuffer);
else
{
dwType = REG_SZ; dwSize = 260;
RegSetValueEx(hKey, szBuffer, 0, dwType, (PBYTE)szCur, dwSize);
}
}
for(int c=0;c<INPUT_DEVICE_COMPONENT_COUNT;c++)
{
int RawData[3] = {-1, -1, 0};
int RawData[3] = {-1, -1, 0}; // dwDevice, dwInfo, dwFlags
m_InputConfig.Get((InputDeviceComponent)c, &RawData[0], &RawData[1], &RawData[2]);

View File

@ -132,7 +132,7 @@ int InputConfig::Insert(const char *DeviceName)
int v=0;
for(v=0;v<MAX_INPUT_DEVICES;v++)
if(strcmp(DeviceName, m_DeviceName[v]) == 0)
if(strcmp(m_DeviceName[v], DeviceName) == 0)
return v;
for(v=0;v<MAX_INPUT_DEVICES;v++)