xboxscene.org forums

Author Topic: Iocreatesymboliclink And My Menu Program  (Read 88 times)

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Iocreatesymboliclink And My Menu Program
« on: October 30, 2002, 08:59:00 PM »

As I'd like to avoid the need for absolute paths, I find myself in a quandry...

Is anybody here aware of a means for me to discover the TRUE path my application was launched from?

When an app is launched, M$ internally does a Iocreatesymboliclink() to make that directory "D:\" - but my menu app may be run from the hard drive! Is there a function to check the mapping to the true drive/partition used in the symbolic link?

My alternative is for the INI file to contain absolute paths to the applications, but I hoped to avoid doing that, for a number of reasons.

I currently have most everything done in a rough function, and I also have the code needed to launch an app, once I know it's absolute path (thanks to the xboxhacker guys for sorting that out).

The functionality currently supercedes Complex Menu, with a title screen, screen shots (png and bmp), and a screen saver, all running with INI files. It still has some tidying up to do, though.

I have compiled the CxImage for the Xbox, but having a few issues with that yet, as is the video player code.

Thanks in advance for any help you guys might lend.
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Iocreatesymboliclink And My Menu Program
« Reply #1 on: October 31, 2002, 01:51:00 PM »

cool.gif
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Iocreatesymboliclink And My Menu Program
« Reply #2 on: October 31, 2002, 05:57:00 PM »

Well, InitializeObjectAttributes is strictly a DDK thing, but more importantly, NtOpenSymbolicLinkObject doesn't seem to exist. I get a link error.

This isn't the finished function, obviously, just something I did to see if it would link:

void GetRealCDROMPath( void )
{
   HANDLE hObject;
   OBJECT_NAME_INFORMATION objName;
   DWORD lLength;

   NtOpenSymbolicLinkObject( &hObject, 0, &DDriveObject );
   NtQuerySymbolicLinkObject( hObject, &objName, &lLength );

}

I was going to extract the real device name after the fact and dump it to the screen, but it won't link.

error LNK2019: unresolved external symbol _NtOpenSymbolicLinkObject@12 referenced in function "void __cdecl GetRealCDROMPath(void)" (?GetRealCDROMPath@@YAXXZ)
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Iocreatesymboliclink And My Menu Program
« Reply #3 on: October 31, 2002, 07:10:00 PM »

sad.gif  No joy.... I get an empty string.

CStdString is a replacement CString clone I am using (and it's working fine, so that wouldn't be the problem.
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Iocreatesymboliclink And My Menu Program
« Reply #4 on: October 31, 2002, 07:21:00 PM »

blink.gif

This is my 'debugging' version:

CStdString GetRealCDROMPath( void )
{
   HANDLE hObject;
   OBJECT_NAME_INFORMATION objName;
   DWORD lLength;
   CStdString sReturn;
   DWORD dwStatus;

   dwStatus = NtOpenSymbolicLinkObject( &hObject, &DDriveObject );
   if ( hObject )
   {
      dwStatus = NtQuerySymbolicLinkObject( hObject, &objName, &lLength );
      if ( objName.Name.Buffer && lLength )
      {
         sReturn = (char *)objName.Name.Buffer;
      }
      else
      {
         sReturn.Format( _T("Path failed. Length=%ld dwStatus =%ld"), lLength, dwStatus );
      }
   }
   else
   {
      sReturn.Format( _T("Path failed. dwStatus=%ld"), dwStatus );
   }
   return sReturn;
}

Perhaps it wants a Root handle? I'm goingto try another tack, using an attribute OBJ_OPENIF.
Logged