xboxscene.org forums

Author Topic: Where's The Bug  (Read 94 times)

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« on: July 31, 2003, 05:17:00 PM »

CODE

void __cdecl main()

{
   HANDLE fsearch;
   WIN32_FIND_DATA trash;
   char strFind[] = "E:\\install.lok";
   fsearch = FindFirstFile(strFind,&trash);

   if (fsearch == INVALID_HANDLE_VALUE)
   {
 CopyFile("E:\\UDATA\\4d530017\\62D648EBF155\\evox.ini","e:\\evox.ini",FALSE);
   }
   LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
   XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );

   Sleep( INFINITE );
}
Logged

CaicedoLuis

  • Archived User
  • Full Member
  • *
  • Posts: 129
Where's The Bug
« Reply #1 on: July 31, 2003, 07:11:00 PM »

i think u should use \\device\\harddisk0\\partition1\\ instead of e:
Im not sure tho
Logged

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« Reply #2 on: July 31, 2003, 07:24:00 PM »

mad.gif  

So I got two issues here:

First, the check for the file fails
Then, the copy fails

What's up with this?
Logged

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« Reply #3 on: August 01, 2003, 01:35:00 PM »

Ok, need some help here...

I have tried:

1. The original code posted above.
2. The Unmount/Mount d:\ code in the above post, and from XFactorDev.net.
3. Directly using \Device\Harddisk0\Partition1 in the copyfile and FindFirstFile commands.
4. A bunch of other tweaks and prods....

It still doesn't work!

I know the FindFirstFile is returning INVALID_HANDLE_VALUE, even if the file I'm checking for exists!

So, my code, in any way I try it, doesn't do squat.

Anyone got any ideas?

BTW - What is the best way to debug this stuff without a debug XBox? Do I have to put in a bunch of DirectX stuff to print debug output to the screen or is there a better way?

I'm gone all weekend, so we all have some time to mull this over.... Perhaps i will DL MXM's source and pick it apart!

Morden.
Logged

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« Reply #4 on: August 01, 2003, 02:05:00 PM »

Thanks!

And thanks for the other method to check for the file!!!!!

I will give it a try and see what happens!
Logged

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« Reply #5 on: August 01, 2003, 02:42:00 PM »

Ok, The debug log lets me know i have mounted E: as D: correctly. And the CopyFile command now works....

But..


The code to detect the file you posted above always seems to return a non NULL value even if the file exists.

Any ideas?

Thanks for all your help so far, I'm sure once I get the hang of C I should be ok... See this is what comes of taking the easy path of VB and Delphi!

Morden.
Logged

Wishi

  • Archived User
  • Full Member
  • *
  • Posts: 191
Where's The Bug
« Reply #6 on: August 01, 2003, 03:49:00 PM »

CODE
// Comment the below line if you don't have a debug bios
#define DEBUG_BIOS

void debug( char *szDebugString )
{
#ifdef _DEBUG
#ifdef DEBUG_BIOS
   char szBuffer[2048];
   sprintf(szBuffer, "%sn", szDebugString);
   OutputDebugString(szBuffer);
#else
   FILE *fp;
   fp = fopen("D:\\DebugInfo.txt", "a+");
   fprintf(fp, "%sn", szDebugString);
   fclose(fp);
#endif
#endif
}

int debugf ( char *szFormat, ... )
{
#ifdef _DEBUG
   va_list args;
   int ret;

   va_start(args, szFormat);

   char szDebugString[2048];
   ret = vsprintf (szDebugString, szFormat, args);

#ifdef DEBUG_BIOS
   OutputDebugString(szDebugString);
#else
   FILE *fp;
   fp = fopen( "D:\\DebugInfo.txt", "a+" );
   fputs(szDebugString, fp);
   fclose(fp);
#endif

   va_end(args);
   return ret;

#endif
}


Edit: Someone should edit the forum code so that it actually displays code properly.
Logged

Mordenkainen

  • Archived User
  • Sr. Member
  • *
  • Posts: 447
Where's The Bug
« Reply #7 on: August 03, 2003, 04:00:00 PM »

sad.gif

Anyway, one thing about the code you posted, it should be noted that if you fopen a handle, you should close it with fclose.... But fclose hangs the xbox if you pass it a NULL handle, so make sure it's real before calling the function!

Morden.
Logged