Jump to content


Photo

Dev's Need For A Xpr Extractor


  • Please log in to reply
3 replies to this topic

#1 Nigma

Nigma

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 13 July 2002 - 08:05 PM

Looking around in a few programs it seems an XPR ripper/re-packer is badly need. XPR being a XBox Binary Resource File optimized for the XBox to read the contents right into memory. This is where much of the texture/vertex/other data is stored for many a game.

Anyone up to the challenge?

The function to read the XPR should look something like this:

//-----------------------------------------------------------------------------
// Name: LoadPackedResource()
// Desc: Loads all the texture resources from the given XPR.
//-----------------------------------------------------------------------------
HRESULT LoadPackedResource()
{
// Open the file to read the XPR headers
FILE* file = fopen( "D:\\media\\Resource.xpr", "rb" );
if( NULL == file )
return E_FAIL;

// Read in and verify the XPR magic header
XPR_HEADER xprh;
if(fread( &xprh, sizeof(XPR_HEADER), 1, file) != 1)
{
fclose(file);
return E_FAIL;
}

if( xprh.dwMagic != XPR_MAGIC_VALUE )
{
OutputDebugStringA( "ERROR: Invalid Xbox Packed Resource (.xpr) file" );
fclose( file );
return E_INVALIDARG;
}

// Compute memory requirements
DWORD dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
DWORD dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;

// Allocate memory
g_pResourceSysMemData = new BYTE[dwSysMemDataSize];
g_pResourceVidMemData = (BYTE*)D3D_AllocContiguousMemory( dwVidMemDataSize, D3DTEXTURE_ALIGNMENT );

// Read in the data from the file
if(fread( g_pResourceSysMemData, dwSysMemDataSize, 1, file ) != 1 ||
fread( g_pResourceVidMemData, dwVidMemDataSize, 1, file ) != 1 )

{
delete [] g_pResourceSysMemData;
D3D_FreeContiguousMemory(g_pResourceVidMemData);
fclose(file);
return E_FAIL;
}

// Done with the file
fclose( file );

// Loop over resources, then call a function to save it to HDD
BYTE* pData = g_pResourceSysMemData;

for( DWORD i = 0; i < resource_NUM_RESOURCES; i++ )
{
// Get the resource
LPDIRECT3DRESOURCE8 pResource = (LPDIRECT3DRESOURCE8)pData;

// Save in appropriate format to HDD
pResource->SaveToHD( g_pResourceVidMemData );

// Advance the pointer
switch( pResource->GetType() )
{
case D3DRTYPE_TEXTURE: pData += sizeof(D3DTexture); break;
case D3DRTYPE_VOLUMETEXTURE: pData += sizeof(D3DVolumeTexture); break;
case D3DRTYPE_CUBETEXTURE: pData += sizeof(D3DCubeTexture); break;
case D3DRTYPE_VERTEXBUFFER: pData += sizeof(D3DVertexBuffer); break;
case D3DRTYPE_INDEXBUFFER: pData += sizeof(D3DIndexBuffer); break;
case D3DRTYPE_PALETTE: pData += sizeof(D3DPalette); break;
default: return E_FAIL;
}
}

return S_OK;
}

You'd need to add some code to convert textures to .bmp's (with volume and cube writing multiple .bmp's), the vertices and indices can be text (I think).

Do a search on XPR in the DK docs for the specs that the bundler uses to create the files in the first place. PM me if you interesting working on this.



#2 Nigma

Nigma

    X-S Young Member

  • Members
  • Pip
  • 31 posts

Posted 16 July 2002 - 02:05 PM

Anyone, anyone? Bueller? Bueller?

#3 OllieD

OllieD

    X-S Young Member

  • Members
  • Pip
  • 33 posts
  • Location:UK
  • Xbox Version:v1.2
  • 360 version:v1 (xenon)

Posted 14 November 2007 - 12:52 PM

I Made One A While Ago.

See This Thread...

-=] XPR-Ripper [=-

#4 Jezz_X

Jezz_X

    X-S Knowledgebase

  • Moderator
  • PipPipPipPipPipPipPipPip
  • 4,531 posts
  • Location:Australia
  • Xbox Version:v1.1
  • 360 version:none

Posted 14 November 2007 - 10:41 PM

Way to drag up a 5 year old post for shameless self promotion




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users