NtCreateFile will now fallback to parent directory if a regular file is being opened as a directory. This fixes Xapi FindFirstFile, although wildcard handling may need more work. Removed HLE for FindFirstFileA/FindNextFileA.

Temporary HLE for Xapi GetTimeZoneInformation to satisfy _stat(...) while support for EEPROM queries is missing. OOVPAs for XDK 3911 and re-used for 5233.

Fixed weak XDK 5558 D3D IDirect3DDevice8::BlockOnFence OOVPA by adding Xref to D3D::BlockOnTime. Backported to 5233.

Sanitized EmuD3D8 function parameter debug trace formatting.
This commit is contained in:
Daniel Stien 2008-09-21 00:54:09 +00:00
parent 5bed305918
commit 26861248d2
11 changed files with 224 additions and 251 deletions

View File

@ -7732,9 +7732,9 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_GetVertexShader
EmuSwapFS();
// debug trace
DbgPrintf( "EmuD3D8 (0x%.08X): EmuIDirect3DDevice8_GetVertexShader\n"
DbgPrintf( "EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetVertexShader\n"
"(\n"
" pHandle : 0x%.08X\n"
" pHandle : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pHandle);
@ -8037,8 +8037,8 @@ PVOID WINAPI XTL::EmuIDirect3D8_AllocContiguousMemory
// debug trace
DbgPrintf( "EmuD3D8 (0x%X): EmuIDirect3D8_AllocContiguousMemory\n"
"(\n"
" dwSize : 0x%.08X\n"
" dwAllocAttributes : 0x%.08X\n"
" dwSize : 0x%.08X\n"
" dwAllocAttributes : 0x%.08X\n"
");\n",
GetCurrentThreadId(), dwSize,dwAllocAttributes);
@ -8083,8 +8083,8 @@ HRESULT WINAPI XTL::EmuIDirect3DTexture8_GetLevelDesc
// debug trace
DbgPrintf( "EmuD3D8 (0x%X): EmuIDirect3DTexture8_GetLevelDesc\n"
"(\n"
" Level : 0x%.08X\n"
" pDesc : 0x%.08X\n"
" Level : 0x%.08X\n"
" pDesc : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Level,pDesc);
@ -8109,11 +8109,11 @@ HRESULT WINAPI XTL::EmuIDirect3D8_CheckDeviceMultiSampleType
DbgPrintf( "EmuD3D8 (0x%X): EmuIDirect3D8_CheckDeviceMultiSampleType\n"
"(\n"
" Adapter : 0x%.08X\n"
" DeviceType : 0x%.08X\n"
" SurfaceFormat : 0x%.08X\n"
" Windowed : 0x%.08X\n"
" MultiSampleType : 0x%.08X\n"
" Adapter : 0x%.08X\n"
" DeviceType : 0x%.08X\n"
" SurfaceFormat : 0x%.08X\n"
" Windowed : 0x%.08X\n"
" MultiSampleType : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType);
@ -8184,9 +8184,9 @@ HRESULT WINAPI XTL::EmuIDirect3D8_GetDeviceCaps
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3D8_GetDeviceCaps\n"
"(\n"
" Adapter : 0x%.08X\n"
" DeviceType : 0x%.08X\n"
" pCaps : 0x%.08X\n"
" Adapter : 0x%.08X\n"
" DeviceType : 0x%.08X\n"
" pCaps : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Adapter, DeviceType, pCaps);
@ -8210,8 +8210,8 @@ HRESULT WINAPI XTL::EmuIDirect3D8_SetPushBufferSize
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3D8_SetPushBufferSize\n"
"(\n"
" PushBufferSize : 0x%.08X\n"
" KickOffSize : 0x%.08X\n"
" PushBufferSize : 0x%.08X\n"
" KickOffSize : 0x%.08X\n"
");\n",
GetCurrentThreadId(), PushBufferSize, KickOffSize);
@ -8253,7 +8253,7 @@ BOOL WINAPI XTL::EmuIDirect3DDevice8_IsFencePending
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_IsFencePending\n"
"(\n"
" Fence : 0x%.08X\n"
" Fence : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Fence);
@ -8276,7 +8276,7 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_BlockOnFence
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_BlockOnFence\n"
"(\n"
" Fence : 0x%.08X\n"
" Fence : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Fence);
@ -8297,7 +8297,7 @@ VOID WINAPI XTL::EmuIDirect3DResource8_BlockUntilNotBusy
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DResource8_BlockUntilNotBusy\n"
"(\n"
" pThis : 0x%.08X\n"
" pThis : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pThis);
@ -8319,8 +8319,8 @@ VOID WINAPI XTL::EmuIDirect3DVertexBuffer8_GetDesc
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DVertexBuffer8_GetDesc\n"
"(\n"
" pThis : 0x%.08X\n"
" pDesc : 0x%.08X\n"
" pThis : 0x%.08X\n"
" pDesc : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pThis, pDesc);
@ -8343,9 +8343,9 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SetScissors
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetScissors\n"
"(\n"
" Count : 0x%.08X\n"
" Exclusive : 0x%.08X\n"
" pRects : 0x%.08X\n"
" Count : 0x%.08X\n"
" Exclusive : 0x%.08X\n"
" pRects : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Count, Exclusive, pRects);
@ -8369,8 +8369,8 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SetScreenSpaceOffset
DbgPrintf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetScreenSpaceOffset\n"
"(\n"
" x : %f\n"
" y : %f\n"
" x : %f\n"
" y : %f\n"
");\n",
GetCurrentThreadId(), x, y);

View File

@ -59,6 +59,10 @@ namespace NtDll
#include "EmuXTL.h"
#include "ResourceTracker.h"
#pragma warning(disable:4005) // Ignore redefined status values
#include <ntstatus.h>
#pragma warning(default:4005)
// PsCreateSystemThread proxy parameters
typedef struct _PCSTProxyParam
{
@ -328,6 +332,14 @@ XBSYSAPI EXPORTNUM(24) xboxkrnl::NTSTATUS NTAPI xboxkrnl::ExQueryNonVolatileSett
}
break;
/* Timezone info
case 0x0FF:
{
_asm int 3;
}
break;
//*/
default:
EmuWarning("ExQueryNonVolatileSetting unknown ValueIndex (%d)", ValueIndex);
break;
@ -1368,17 +1380,17 @@ XBSYSAPI EXPORTNUM(190) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateFile
DbgPrintf(" New:\"$CxbxPath\\EmuDisk\\Z\\%s\"\n", szBuffer);
}
//
// TODO: Wildcards are not allowed??
//
// Ignore wildcards. Xapi FindFirstFile uses the same path buffer for
// NtOpenFile and NtQueryDirectoryFile. Wildcards are only parsed by
// the latter.
{
for(int v=0;szBuffer[v] != '\0';v++)
{
// FIXME: Fallback to parent directory if wildcard is found.
if(szBuffer[v] == '*')
{
if(v > 0) { ReplaceIndex = v-1; }
else { ReplaceIndex = v; }
ReplaceIndex = v;
break;
}
}
}
@ -1419,6 +1431,48 @@ XBSYSAPI EXPORTNUM(190) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateFile
(NtDll::LARGE_INTEGER*)AllocationSize, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, NULL, NULL
);
// If we're trying to open a regular file as a directory, fallback to
// parent directory. This behavior is required by Xapi FindFirstFile.
if(ret == STATUS_NOT_A_DIRECTORY)
{
DbgPrintf("EmuKrnl (0x%X): NtCreateFile fallback to parent directory\n", GetCurrentThreadId());
// Restore original buffer.
if(ReplaceIndex != -1)
{
szBuffer[ReplaceIndex] = ReplaceChar;
}
// Strip filename from path.
int CurIndex = strlen(szBuffer);
while(CurIndex--)
{
if(szBuffer[CurIndex] == '\\')
{
ReplaceIndex = CurIndex;
break;
}
}
if(CurIndex == -1)
{
ReplaceIndex = 0;
}
// Modify buffer again.
ReplaceChar = szBuffer[ReplaceIndex];
szBuffer[ReplaceIndex] = '\0';
DbgPrintf(" New:\"$CurRoot\\%s\"\n", szBuffer);
mbstowcs(wszObjectName, szBuffer, 160);
NtDll::RtlInitUnicodeString(&NtUnicodeString, wszObjectName);
ret = NtDll::NtCreateFile
(
FileHandle, DesiredAccess, &NtObjAttr, (NtDll::IO_STATUS_BLOCK*)IoStatusBlock,
(NtDll::LARGE_INTEGER*)AllocationSize, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, NULL, NULL
);
}
if(FAILED(ret))
{
DbgPrintf("EmuKrnl (0x%X): NtCreateFile Failed! (0x%.08X)\n", GetCurrentThreadId(), ret);

View File

@ -91,146 +91,29 @@ BOOL WINAPI XTL::EmuXFormatUtilityDrive()
return TRUE;
}
//* ended up not fixing anything in panzer dragoon!
// ******************************************************************
// * func: EmuFindFirstFileA
// * func: EmuGetTimeZoneInformation
// ******************************************************************
HANDLE WINAPI XTL::EmuFindFirstFileA
DWORD WINAPI XTL::EmuGetTimeZoneInformation
(
IN LPCSTR lpFileName,
OUT LPWIN32_FIND_DATA lpFindFileData
OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation
)
{
EmuSwapFS(); // Win2k/XP FS
DbgPrintf("EmuXapi (0x%X): EmuFindFirstFileA\n"
DbgPrintf("EmuXapi (0x%X): EmuGetTimeZoneInformation\n"
"(\n"
" lpFileName : 0x%.08X (%s)\n"
" lpFindFileData : 0x%.08X\n"
" lpTimeZoneInformation : 0x%.08X\n"
");\n",
GetCurrentThreadId(), lpFileName, lpFileName, lpFindFileData);
GetCurrentThreadId(), lpTimeZoneInformation);
//
// TODO: this code is replicated in NtCreateFile. make this a function
//
//
// TODO: replace full directories with their shorthand (D:\, etc)
//
char *szBuffer = (char*)lpFileName;
char *szRoot = g_strCurDrive;
//printf("bef : %s\n", lpFileName);
if(szBuffer != NULL)
{
// trim this off
if(szBuffer[0] == '\\' && szBuffer[1] == '?' && szBuffer[2] == '?' && szBuffer[3] == '\\')
{
szBuffer += 4;
}
// D:\ should map to current directory
if( (szBuffer[0] == 'D' || szBuffer[0] == 'd') && szBuffer[1] == ':' && szBuffer[2] == '\\')
{
szBuffer += 3;
}
else if( (szBuffer[0] == 'T' || szBuffer[0] == 't') && szBuffer[1] == ':' && szBuffer[2] == '\\')
{
szBuffer += 3;
szRoot = g_strTDrive;
}
else if( (szBuffer[0] == 'U' || szBuffer[0] == 'u') && szBuffer[1] == ':' && szBuffer[2] == '\\')
{
szBuffer += 3;
szRoot = g_strUDrive;
}
else if( (szBuffer[0] == 'Z' || szBuffer[0] == 'z') && szBuffer[1] == ':' && szBuffer[2] == '\\')
{
szBuffer += 3;
szRoot = g_strZDrive;
}
}
//printf("af1 : %s\n", szRoot);
//printf("af2 : %s\n", szBuffer);
//char szOldDir[MAX_PATH];
//GetCurrentDirectory(MAX_PATH, szOldDir);
SetCurrentDirectory(szRoot);
HANDLE hRet = FindFirstFile(szBuffer, lpFindFileData);
if(!FAILED(hRet))
{
do
{
BOOL bRet = FindNextFile(hRet, lpFindFileData);
if(!bRet) { hRet = INVALID_HANDLE_VALUE; break; }
if( (strcmp(lpFindFileData->cFileName, ".") != 0) && (strcmp(lpFindFileData->cFileName, "..") != 0) )
break;
}
while(true);
}
//SetCurrentDirectory(szOldDir);
DWORD dwRet = GetTimeZoneInformation(lpTimeZoneInformation);
EmuSwapFS(); // XBox FS
return hRet;
return dwRet;
}
// ******************************************************************
// * func: EmuFindNextFileA
// ******************************************************************
BOOL WINAPI XTL::EmuFindNextFileA
(
IN HANDLE hFindFile,
OUT LPWIN32_FIND_DATA lpFindFileData
)
{
EmuSwapFS(); // Win2k/XP FS
DbgPrintf("EmuXapi (0x%X): EmuFindNextFileA\n"
"(\n"
" hFindFile : 0x%.08X\n"
" lpFindFileData : 0x%.08X\n"
");\n",
GetCurrentThreadId(), hFindFile, lpFindFileData);
//
// TODO: replace full directories with their shorthand (D:\, etc)
//
BOOL bRet;
do
{
bRet = FindNextFile(hFindFile, lpFindFileData);
if(!bRet) { break; }
if( (strcmp(lpFindFileData->cFileName, ".") != 0) && (strcmp(lpFindFileData->cFileName, "..") != 0) )
break;
}
while(true);
//printf("Found : %s\n", lpFindFileData->cFileName);
EmuSwapFS(); // XBox FS
return bRet;
}
//*/
// ******************************************************************
// * func: EmuRtlCreateHeap
// ******************************************************************

View File

@ -302,21 +302,11 @@ VOID WINAPI EmuXapiApplyKernelPatches();
BOOL WINAPI EmuXFormatUtilityDrive();
// ******************************************************************
// * func: EmuFindFirstFileA
// * func: EmuGetTimeZoneInformation
// ******************************************************************
HANDLE WINAPI EmuFindFirstFileA
DWORD WINAPI EmuGetTimeZoneInformation
(
IN LPCSTR lpFileName,
OUT LPWIN32_FIND_DATA lpFindFileData
);
// ******************************************************************
// * func: EmuFindNextFileA
// ******************************************************************
BOOL WINAPI EmuFindNextFileA
(
IN HANDLE hFindFile,
OUT LPWIN32_FIND_DATA lpFindFileData
OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation
);
// ******************************************************************

View File

@ -317,6 +317,7 @@ extern uint32 XRefDataBase[] =
-1, // XREF_D3DRS_DONOTCULLUNCOMPRESSED
-1, // XREF_D3DRS_STENCILCULLENABLE
-1, // XREF_D3DCD_LAZYSETSTATEVB
-1, // XREF_D3D_BLOCKONTIME
-1, // XREF_D3D_SETFENCE
-1, // XREF_XNINIT
-1, // XREF_FCLOSEDEVICE

View File

@ -121,6 +121,7 @@ enum XRefDataBaseOffset
XREF_D3DRS_DONOTCULLUNCOMPRESSED,
XREF_D3DRS_STENCILCULLENABLE,
XREF_D3DCD_LAZYSETSTATEVB,
XREF_D3D_BLOCKONTIME,
XREF_D3D_SETFENCE,
XREF_XNINIT,
XREF_FCLOSEDEVICE,

View File

@ -1254,6 +1254,49 @@ SOOVPA<6> IDirect3DDevice8_IsFencePending_1_0_5233 =
}
};
// ******************************************************************
// * D3D::BlockOnTime
// ******************************************************************
SOOVPA<6> D3D_BlockOnTime_1_0_5233 =
{
0, // Large == 0
6, // Count == 6
XREF_D3D_BLOCKONTIME, // Xref Is Saved
0, // Xref Not Used
{
{ 0x09, 0x30 },
{ 0x27, 0x07 },
{ 0x55, 0x7E },
{ 0x7B, 0x58 },
{ 0xE3, 0x80 },
{ 0xF5, 0x2C },
}
};
// ******************************************************************
// * IDirect3DDevice8_BlockOnFence
// ******************************************************************
SOOVPA<6> IDirect3DDevice8_BlockOnFence_1_0_5233 =
{
0, // Large == 0
6, // Count == 6
-1, // Xref Not Saved
1, // Xref Is Used
{
{ 0x08, XREF_D3D_BLOCKONTIME },
{ 0x00, 0x8B },
{ 0x02, 0x24 },
{ 0x04, 0x6A },
{ 0x06, 0x50 },
{ 0x0D, 0x04 },
}
};
// ******************************************************************
// * D3D8_1_0_5233
// ******************************************************************
@ -2284,6 +2327,24 @@ OOVPATable D3D8_1_0_5233[] =
"EmuIDirect3DDevice8_IsFencePending"
#endif
},
// D3D::BlockOnTime (XREF)
{
(OOVPA*)&D3D_BlockOnTime_1_0_5233, 0,
#ifdef _DEBUG_TRACE
"D3D::BlockOnTime (XREF)"
#endif
},
// IDirect3DDevice8::BlockOnFence
{
(OOVPA*)&IDirect3DDevice8_BlockOnFence_1_0_5233,
XTL::EmuIDirect3DDevice8_BlockOnFence,
#ifdef _DEBUG_TRACE
"EmuIDirect3DDevice8_BlockOnFence"
#endif
},
};
// ******************************************************************

View File

@ -691,24 +691,23 @@ SOOVPA<14> D3D_SetFence_1_0_5558 =
};
// ******************************************************************
// * IDirect3DDevice8_BlockOnFence
// * D3D::BlockOnTime
// ******************************************************************
SOOVPA<7> IDirect3DDevice8_BlockOnFence_1_0_5558 =
SOOVPA<6> D3D_BlockOnTime_1_0_5558 =
{
0, // Large == 0
7, // Count == 7
6, // Count == 6
-1, // Xref Not Saved
0, // Xref Not Used
XREF_D3D_BLOCKONTIME, // Xref Is Saved
0, // Xref Not Used
{
{ 0x00, 0x8B }, // FIXME: Very weak.
{ 0x02, 0x24 },
{ 0x04, 0x6A },
{ 0x06, 0x50 },
{ 0x0C, 0xC2 },
{ 0x0D, 0x04 },
{ 0x0E, 0x00 },
{ 0x09, 0x30 },
{ 0x27, 0x07 },
{ 0x7E, 0x25 },
{ 0x9F, 0x20 },
{ 0xD3, 0x56 },
{ 0xE9, 0x57 },
}
};
@ -1525,9 +1524,17 @@ OOVPATable D3D8_1_0_5558[] =
"EmuIDirect3DDevice8_InsertFence"
#endif
},
// IDirect3DDevice8::BlockOnFence
// D3D::BlockOnTime (XREF)
{
(OOVPA*)&IDirect3DDevice8_BlockOnFence_1_0_5558,
(OOVPA*)&D3D_BlockOnTime_1_0_5558, 0,
#ifdef _DEBUG_TRACE
"D3D::BlockOnTime (XREF)"
#endif
},
// IDirect3DDevice8::BlockOnFence (* unchanged since 5233 *)
{
(OOVPA*)&IDirect3DDevice8_BlockOnFence_1_0_5233,
XTL::EmuIDirect3DDevice8_BlockOnFence,

View File

@ -390,6 +390,29 @@ SOOVPA<11> XRegisterThreadNotifyRoutine_1_0_3911 =
{ 0x47, 0x08 }, // (Offset,Value)-Pair #11
}
};
// ******************************************************************
// * GetTimeZoneInformation
// ******************************************************************
SOOVPA<7> GetTimeZoneInformation_1_0_3911 =
{
0, // Large == 0
7, // Count == 7
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x05, 0x28 },
{ 0x2E, 0x28 },
{ 0x4F, 0x59 },
{ 0x56, 0xAB },
{ 0x8C, 0xC0 },
{ 0xB9, 0x80 },
{ 0xF7, 0x99 },
}
};
/* not necessary?
// ******************************************************************
// * XCalculateSignatureBegin
@ -663,6 +686,16 @@ OOVPATable XAPI_1_0_3911[] =
#endif
},
//*/
// GetTimeZoneInformation
{
(OOVPA*)&GetTimeZoneInformation_1_0_3911,
XTL::EmuGetTimeZoneInformation,
#ifdef _DEBUG_TRACE
"GetTimeZoneInformation"
#endif
},
// XapiBootToDash
{
(OOVPA*)&XapiBootDash_1_0_3911,

View File

@ -100,51 +100,6 @@ SOOVPA<7> XFormatUtilityDrive_1_0_4627 =
}
};
// ******************************************************************
// * FindFirstFileA
// ******************************************************************
SOOVPA<8> FindFirstFileA_1_0_4627 =
{
0, // Large == 0
8, // Count == 8
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x1E, 0x89 },
{ 0x3E, 0x74 },
{ 0x5E, 0x45 },
{ 0x7E, 0x75 },
{ 0x9E, 0x8D },
{ 0xBE, 0xFE },
{ 0xE1, 0x56 },
{ 0xFE, 0x57 },
}
};
// ******************************************************************
// * FindNextFileA
// ******************************************************************
SOOVPA<7> FindNextFileA_1_0_4627 =
{
0, // Large == 0
7, // Count == 7
-1, // Xref Not Saved
0, // Xref Not Used
{
{ 0x09, 0x56 },
{ 0x14, 0x00 },
{ 0x1F, 0x50 },
{ 0x2C, 0x3B },
{ 0x37, 0x33 },
{ 0x40, 0xB0 },
{ 0x4B, 0xC0 },
}
};
// ******************************************************************
// * SetThreadPriorityBoost
// ******************************************************************
@ -452,28 +407,6 @@ OOVPATable XAPI_1_0_4627[] =
"EmuXFormatUtilityDrive"
#endif
},
/* ended up not fixing anything in panzer dragoon!
// FindFirstFileA
{
(OOVPA*)&FindFirstFileA_1_0_4627,
XTL::EmuFindFirstFileA,
#ifdef _DEBUG_TRACE
"EmuFindFirstFileA"
#endif
},
// FindNextFileA
{
(OOVPA*)&FindNextFileA_1_0_4627,
XTL::EmuFindNextFileA,
#ifdef _DEBUG_TRACE
"EmuFindNextFileA"
#endif
},
//*/
// SetThreadPriorityBoost
{
(OOVPA*)&SetThreadPriorityBoost_1_0_4627,

View File

@ -200,6 +200,16 @@ OOVPATable XAPI_1_0_5233[] =
"EmuXapiInitProcess"
#endif
},
// GetTimeZoneInformation (* unchanged since 3911 *)
{
(OOVPA*)&GetTimeZoneInformation_1_0_3911,
XTL::EmuGetTimeZoneInformation,
#ifdef _DEBUG_TRACE
"GetTimeZoneInformation"
#endif
},
// SetThreadPriority (* unchanged since 3911 *)
{
(OOVPA*)&SetThreadPriority_1_0_3911,