20
20
static const char kKernelImageName [] = " xboxkrnl.exe" ;
21
21
static uint32 CountNonKernelImportTableEntries (class Exe *x_Exe, uint32_t *extra_bytes);
22
22
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
+
23
34
// 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)
25
37
{
26
38
ConstructorInit ();
27
39
@@ -30,6 +42,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
30
42
time (&CurrentTime);
31
43
32
44
printf (" Xbe::Xbe: Pass 1 (Simple Pass)..." );
45
+ std::string debug_path = x_szDebugPath;
33
46
34
47
// pass 1
35
48
{
@@ -159,12 +172,17 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
159
172
160
173
// make room for debug path / debug file names
161
174
{
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 );
163
180
m_Header.dwDebugUnicodeFilenameAddr = mrc;
164
- m_Header.dwDebugPathnameAddr = mrc;
165
- m_Header.dwDebugFilenameAddr = mrc;
181
+ mrc = RoundUp (mrc + filename_bytes * 2 , 0x04 );
166
182
167
- mrc += 2 ;
183
+ m_Header.dwDebugPathnameAddr = mrc;
184
+ m_Header.dwDebugFilenameAddr = m_Header.dwDebugPathnameAddr + sep_offset;
185
+ mrc += path_bytes;
168
186
}
169
187
170
188
// 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
238
256
uint32 ExSize = RoundUp (m_Header.dwSizeofHeaders - sizeof (m_Header), 0x1000 );
239
257
240
258
m_HeaderEx = new char [ExSize];
259
+ memset (m_HeaderEx, 0 , ExSize);
241
260
242
261
printf (" OK\n " );
243
262
}
@@ -478,10 +497,17 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec
478
497
479
498
// write debug path / debug file names
480
499
{
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);
482
503
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);
485
511
}
486
512
487
513
{
@@ -894,7 +920,7 @@ void Xbe::DumpInformation(FILE *x_file)
894
920
fprintf (x_file, " \n " );
895
921
}
896
922
897
- char AsciiFilename[40 ];
923
+ char AsciiFilename[40 ] = { 0 } ;
898
924
899
925
setlocale (LC_ALL, " English" );
900
926
0 commit comments