2020static const char kKernelImageName [] = " xboxkrnl.exe" ;
2121static uint32 CountNonKernelImportTableEntries (class Exe *x_Exe, uint32_t *extra_bytes);
2222
23+ static size_t BasenameOffset (const std::string &path)
24+ {
25+ size_t sep_offset = path.find_last_of (" /\\ " );
26+ if (sep_offset == std::string::npos)
27+ {
28+ return 0 ;
29+ }
30+
31+ return sep_offset + 1 ;
32+ }
33+
2334// construct via Exe file object
24- Xbe::Xbe (class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vector<uint08> *logo)
35+ Xbe::Xbe (class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vector<uint08> *logo,
36+ const char *x_szDebugPath)
2537{
2638 ConstructorInit ();
2739
@@ -30,6 +42,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
3042 time (&CurrentTime);
3143
3244 printf (" Xbe::Xbe: Pass 1 (Simple Pass)..." );
45+ std::string debug_path = x_szDebugPath;
3346
3447 // pass 1
3548 {
@@ -159,12 +172,17 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
159172
160173 // make room for debug path / debug file names
161174 {
162- // TODO: allow this to be configured, right now we will just null out these values
175+ uint32 path_bytes = debug_path.size () + 1 ;
176+ size_t sep_offset = BasenameOffset (debug_path);
177+ uint32 filename_bytes = path_bytes - sep_offset;
178+
179+ mrc = RoundUp (mrc, 0x04 );
163180 m_Header.dwDebugUnicodeFilenameAddr = mrc;
164- m_Header.dwDebugPathnameAddr = mrc;
165- m_Header.dwDebugFilenameAddr = mrc;
181+ mrc = RoundUp (mrc + filename_bytes * 2 , 0x04 );
166182
167- mrc += 2 ;
183+ m_Header.dwDebugPathnameAddr = mrc;
184+ m_Header.dwDebugFilenameAddr = m_Header.dwDebugPathnameAddr + sep_offset;
185+ mrc += path_bytes;
168186 }
169187
170188 // make room for largest possible logo bitmap
@@ -238,6 +256,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
238256 uint32 ExSize = RoundUp (m_Header.dwSizeofHeaders - sizeof (m_Header), 0x1000 );
239257
240258 m_HeaderEx = new char [ExSize];
259+ memset (m_HeaderEx, 0 , ExSize);
241260
242261 printf (" OK\n " );
243262 }
@@ -478,10 +497,17 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
478497
479498 // write debug path / debug file names
480499 {
481- *(uint16 *)szBuffer = 0x0000 ;
500+ uint08 *debug_path_field = GetAddr (m_Header.dwDebugPathnameAddr );
501+ uint32 path_size_with_terminator = debug_path.size () + 1 ;
502+ memcpy (debug_path_field, debug_path.c_str (), path_size_with_terminator);
482503
483- szBuffer += 2 ;
484- hwc += 2 ;
504+ uint08 *unicode_filename = GetAddr (m_Header.dwDebugUnicodeFilenameAddr );
505+ uint08 *filename = GetAddr (m_Header.dwDebugFilenameAddr );
506+ do
507+ {
508+ *unicode_filename++ = *filename++;
509+ *unicode_filename++ = 0 ;
510+ } while (*filename);
485511 }
486512
487513 {
@@ -894,7 +920,7 @@ void Xbe::DumpInformation(FILE *x_file)
894920 fprintf (x_file, " \n " );
895921 }
896922
897- char AsciiFilename[40 ];
923+ char AsciiFilename[40 ] = { 0 } ;
898924
899925 setlocale (LC_ALL, " English" );
900926
0 commit comments