xboxscene.org forums

Author Topic: Runxbe();  (Read 36 times)

forahobby

  • Archived User
  • Newbie
  • *
  • Posts: 6
Runxbe();
« on: December 11, 2004, 12:35:00 PM »

CODE
#include "launch.h"

#include // sprintf(..)
/*
Description: Launch another XBE by unmounting then remounting D:

Detail:
If you want to launch another XBE (say you have a menu program) - you
have to first map the D: drive to the location of the XBE you are launching
or else it won't be able to find its media files.

You have to first unmount the D: drive, then re-mount it to the correct
device and subdirectory. Then simply call your XBE.
*/


#ifdef _XBOX

// Hidden Kernal Functions
#define IN
typedef struct _UNICODE_STRING {unsigned short Length; unsigned short MaximumLength; PSTR Buffer;} UNICODE_STRING,*PUNICODE_STRING;
extern "C" XBOXAPI DWORD WINAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,IN PUNICODE_STRING DeviceName);
extern "C" XBOXAPI DWORD WINAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName);
extern "C" XBOXAPI DWORD WINAPI XapiMapLetterToDirectory(IN LPCSTR pcDriveString,IN LPCSTR pcPathString,IN DWORD pcszTitleId,IN bool fCreateDirectory,IN LPCSTR pcszTitleName,IN bool fUpdateTimestamp);

// Unmount the old D: drive
static void UnmountD()
{
   char szDestinationDrive[16];
   strcpy(szDestinationDrive,"\\??\\D:");

   UNICODE_STRING LinkName = {
   strlen(szDestinationDrive),
   strlen(szDestinationDrive) + 1,
   szDestinationDrive};

   IoDeleteSymbolicLink(&LinkName);
}

// Mount the D: drive to a given device and directory
// szDevice = "Cdrom0" or "Harddisk0\Partition6"
// szDir = "" or "Game1"
static void MountD(char* szDevice, char* szDir)
{
   char szSourceDevice[256];
   char szDestinationDrive[16];

   strcpy(szDestinationDrive,"\\??\\D:");
   sprintf(szSourceDevice,"\\Device\\%s",szDevice);
   if (*szDir != 0x00 && *szDir != '\\')
   {
 strcat(szSourceDevice, "\\");
 strcat(szSourceDevice, szDir);
   }

   UNICODE_STRING LinkName = {
 strlen(szDestinationDrive),
 strlen(szDestinationDrive) + 1,
 szDestinationDrive
 };
   UNICODE_STRING DeviceName = {
 strlen(szSourceDevice),
 strlen(szSourceDevice) + 1,
 szSourceDevice
 };

   IoCreateSymbolicLink(&LinkName, &DeviceName);
}

// szDevice = the device where the XBE is "Cdrom0"
// szDir = the subdirectory where your xbe is "Games\Game1"
// szFile = the name of your XBE (without the path) - "Game1.xbe"
void RunXbe (char* szDevice, char* szDir, char* szFile)
{
   char szXbePath[64];
   wsprintf(szXbePath,"D:\\",szFile);

   UnmountD();
   MountD(szDevice, szDir);
   XLaunchNewImage(szXbePath, NULL );
}


#else

void RunXbe (char* szDevice, char* szDir, char* szFile)
{
   //Start a standard exe here for pc version :)
}

#endif //_XBOX


and heres the launch.h:
CODE
#pragma once



#ifdef _XBOX

#include

#else

// Where using DirectX
#pragma comment(lib, "D3d8.lib") // DirectX 8
#pragma comment(lib, "D3dx8.lib")
#include

#endif //_XBOX



// szDevice = the device where the XBE is "Cdrom0"
// szDir = the subdirectory where your xbe is "Games\Game1"
// szFile = the name of your XBE (without the path) - "Game1.xbe"
void RunXbe (char* szDevice, char* szDir, char* szFile);




Now i call the function no problems at all and can pass my variables accross but i get a error. .xbe could not be booted..  I know its something so small.. any whizzes around?? Im not that bad a coder on xbox but this ones got me stumped..

My app is nearly finished too but i need to get this working!!   mad.gif

Heres how i call it:
CODE
RunXbe ("Cdrom0", "", "install.xbe"); // lets launch ourself
   
   // szDevice = "Cdrom0" or "Harddisk0\Partition6" (where xbe is)
// szDir = the subdirectory where your xbe is "Games\Game1"
// szFile = the name of your XBE (without the path) - "Game1.xbe"


Im just trying to call another xbe for a test.. Its really the same app at the moment!

anyway, thanks for any help guys,

l8r

forahobby
http://www.xbox-hq.com
Logged

forahobby

  • Archived User
  • Newbie
  • *
  • Posts: 6
Runxbe();
« Reply #1 on: December 12, 2004, 04:08:00 PM »

Hi guys,

All sorted out.. There were some typos in the RUNXBE function and after Xport shot me a email i decided to do like he said and go right through checking it is calling the .xbe.. Its works perfectly now..

You can see the intro in action on the NEW AUTO INSTALLER DELUXE which was released yesterday:
http://xbox-hq.com/h...thread-1-0.html

With a content count of 25 Apps, 6 Dashboards, and 30 Emulators, it's the most packed auto-installer made to this day...

Get into it guys and support the xbox scene.


l8r
Logged