Exemplo n.º 1
0
// ******************************************************************
// * func: EmuXGWriteSurfaceOrTextureToXPR
// ******************************************************************
HRESULT WINAPI XTL::EmuXGWriteSurfaceOrTextureToXPR
( 
	LPVOID			pResource,
	const char*		cPath,
	BOOL			bWriteSurfaceAsTexture
)
{
	EmuSwapFS();	// Win2k/XP FS

	DbgPrintf("EmuXapi (0x%X): EmuXGWriteSurfaceOrTextureToXPR\n"
           "(\n"
           "   pResource              : 0x%.08X\n"
		   "   cPath                  : 0x%.08X\n"
		   "   bWriteSurfaceAsTexture : 0x%.08X\n"
		   ");\n",
		   GetCurrentThreadId(), pResource, cPath, bWriteSurfaceAsTexture);

	// TODO: If necessary, either reverse the .xbx and .xpr file formats
	// and write the surface/texture to a file, or output a generic .xbx
	// file and be done with it.

	EmuWarning("(Temporarily) ignoring EmuXGWriteSurfaceOrTextureToXPR. Need file specs.");

	EmuSwapFS();	// Xbox FS

	return S_OK;
}
Exemplo n.º 2
0
giant newgiant(int numshorts)
{
	int 		size;
	giant 		thegiant;

	if (numshorts > MAX_SHORTS) {
		EmuWarning("Requested giant too big.");
	}
	if (numshorts <= 0)
		numshorts = MAX_SHORTS;
	size = numshorts * sizeof(short) + sizeof(int);
	thegiant = (giant)malloc(size);
	thegiant->sign = 0;

	if (newmin(2 * numshorts, MAX_SHORTS) > current_max_size)
		current_max_size = newmin(2 * numshorts, MAX_SHORTS);

	/* If newgiant() is being called for the first time, set the
	* size of the stack giants. */
	if (stack_glen == 0) stack_glen = current_max_size;

	return(thegiant);
}
Exemplo n.º 3
0
void CallSoftwareInterrupt(const xboxkrnl::KIRQL SoftwareIrql)
{
	switch (SoftwareIrql) {
	case PASSIVE_LEVEL:
		KiUnexpectedInterrupt();
		break;
	case APC_LEVEL: // = 1 // HalpApcInterrupt        
		EmuWarning("Unimplemented Software Interrupt (APC)"); // TODO : ExecuteApcQueue();
		break;
	case DISPATCH_LEVEL: // = 2
		ExecuteDpcQueue();
		break;
	case APC_LEVEL | DISPATCH_LEVEL: // = 3
		KiUnexpectedInterrupt();
		break;
	default:
		// Software Interrupts > 3 map to Hardware Interrupts [4 = IRQ0]
		// This is used to trigger hardware interrupt routines from software
		if (EmuInterruptList[SoftwareIrql - 4]->Connected) {
			HalSystemInterrupts[SoftwareIrql - 4].Trigger(EmuInterruptList[SoftwareIrql - 4]);
		}
		break;
	}
}
Exemplo n.º 4
0
// ******************************************************************
// * 0x0042 - IoCreateFile()
// ******************************************************************
XBSYSAPI EXPORTNUM(66) xboxkrnl::NTSTATUS NTAPI xboxkrnl::IoCreateFile
(
	OUT PHANDLE             FileHandle,
	IN  ACCESS_MASK         DesiredAccess,
	IN  POBJECT_ATTRIBUTES  ObjectAttributes,
	OUT PIO_STATUS_BLOCK    IoStatusBlock,
	IN  PLARGE_INTEGER      AllocationSize OPTIONAL,
	IN  ULONG               FileAttributes,
	IN  ULONG               ShareAccess,
	IN  ULONG               Disposition,
	IN  ULONG               CreateOptions,
	IN  ULONG               Options
)
{
	LOG_FUNC_BEGIN
		LOG_FUNC_ARG_OUT(FileHandle)
		LOG_FUNC_ARG(DesiredAccess)
		LOG_FUNC_ARG(ObjectAttributes)
		LOG_FUNC_ARG_OUT(IoStatusBlock)
		LOG_FUNC_ARG(AllocationSize)
		LOG_FUNC_ARG(FileAttributes)
		LOG_FUNC_ARG(ShareAccess)
		LOG_FUNC_ARG_TYPE(CREATE_DISPOSITION, Disposition)
		LOG_FUNC_ARG_TYPE(CREATE_OPTION, CreateOptions)
		LOG_FUNC_ARG(Options)
		LOG_FUNC_END;

	NativeObjectAttributes nativeObjectAttributes;

	// If we are NOT accessing a directory, and we match a partition path, we need to redirect to a partition.bin file
	bool isDirectPartitionAccess = false;
	std::string objectName = std::string(ObjectAttributes->ObjectName->Buffer, ObjectAttributes->ObjectName->Length);
	if ((CreateOptions & FILE_DIRECTORY_FILE) == 0 && _strnicmp(objectName.c_str(), DeviceHarddisk0PartitionPrefix.c_str(), DeviceHarddisk0PartitionPrefix.length()) == 0 && objectName.length() <= DeviceHarddisk0PartitionPrefix.length() + 2) {
		isDirectPartitionAccess = true;
	}

	NTSTATUS ret = CxbxObjectAttributesToNT(ObjectAttributes, /*OUT*/nativeObjectAttributes, "IoCreateFile", isDirectPartitionAccess);

	// When a Synchronous CreateOption is specified, DesiredAccess must have SYNCHRONIZE set
	if ((CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT) != 0 ||
		(CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) != 0) {
		DesiredAccess |= SYNCHRONIZE;
	}

	// Force ShareAccess to all 
	ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;

    if (SUCCEEDED(ret))
    {
        // redirect to NtCreateFile
        ret = NtDll::NtCreateFile(
            FileHandle,
            DesiredAccess | GENERIC_READ,
            nativeObjectAttributes.NtObjAttrPtr,
            NtDll::PIO_STATUS_BLOCK(IoStatusBlock),
            NtDll::PLARGE_INTEGER(AllocationSize),
            FileAttributes,
            ShareAccess,
            Disposition,
            CreateOptions,
            NULL,
            0);
        
        if (CxbxDebugger::CanReport())
        {
            CxbxDebugger::ReportFileOpened(*FileHandle, nativeObjectAttributes.NtUnicodeString.Buffer, SUCCEEDED(ret));
        }
    }

	if (FAILED(ret))
	{
		EmuWarning("KRNL: IoCreateFile Failed! (%s)\n", NtStatusToString(ret));
	}
	else
	{
		DbgPrintf("KRNL: IoCreateFile = 0x%.8X\n", *FileHandle);
	}

	RETURN(ret);
}