11#include < cassert>
2+ #include < iterator>
23#include < file.h>
34#include < disasm.h>
45#include < image.h>
5- #include " function.h"
6- #include < print>
76#include < xbox.h>
7+ #include < fmt/core.h>
8+ #include " function.h"
89
910#define SWITCH_ABSOLUTE 0
1011#define SWITCH_COMPUTED 1
@@ -139,7 +140,7 @@ void MakeMask(const uint32_t* instructions, size_t count)
139140 for (size_t i = 0 ; i < count; i++)
140141 {
141142 ppc::Disassemble (&instructions[i], 0 , insn);
142- std ::println (" 0x{:X}, // {}" , std::byteswap (insn.opcode ->opcode | (insn.instruction & insn.opcode ->mask )), insn.opcode ->name );
143+ fmt ::println (" 0x{:X}, // {}" , ByteSwap (insn.opcode ->opcode | (insn.instruction & insn.opcode ->mask )), insn.opcode ->name );
143144 }
144145}
145146
@@ -173,13 +174,13 @@ void* SearchMask(const void* source, const uint32_t* compare, size_t compareCoun
173174
174175int main ()
175176{
176- const auto file = LoadFile (" private/default.xex" ). value () ;
177- auto image = Image::ParseImage (file.data (), file.size ()). value () ;
177+ const auto file = LoadFile (" private/default.xex" );
178+ auto image = Image::ParseImage (file.data (), file.size ());
178179
179180 std::string out;
180- auto println = [&]<class ... Args>(std ::format_string<Args...> fmt, Args&&... args)
181+ auto println = [&]<class ... Args>(fmt ::format_string<Args...> fmt, Args&&... args)
181182 {
182- std ::vformat_to (std::back_inserter (out), fmt.get (), std ::make_format_args (args...));
183+ fmt ::vformat_to (std::back_inserter (out), fmt.get (), fmt ::make_format_args (args...));
183184 out += ' \n ' ;
184185 };
185186 // for (const auto& section : image.sections)
@@ -190,7 +191,7 @@ int main()
190191 // MakeMask((uint32_t*)image.Find(0x82C40D84), 6);
191192
192193 // auto data = "\x4D\x99\x00\x20";
193- // auto data2 = std::byteswap ((2129));
194+ // auto data2 = ByteSwap ((2129));
194195 // ppc_insn insn;
195196 // ppc_insn insn2;
196197 // ppc::Disassemble(data, 0, insn);
@@ -261,7 +262,7 @@ int main()
261262 table.type = type;
262263 ScanTable ((uint32_t *)data, base + (data - dataStart), table);
263264
264- // std ::println("{:X} ; jmptable - {}", base + (data - dataStart), table.labels.size());
265+ // fmt ::println("{:X} ; jmptable - {}", base + (data - dataStart), table.labels.size());
265266 if (table.base != 0 )
266267 {
267268 ReadTable (image, table);
@@ -335,15 +336,15 @@ int main()
335336 fwrite (out.data (), 1 , out.size (), f);
336337 fclose (f);
337338
338- uint32_t cxxFrameHandler = std::byteswap (0x831B1C90 );
339- uint32_t cSpecificFrameHandler = std::byteswap (0x8324B3BC );
339+ uint32_t cxxFrameHandler = ByteSwap (0x831B1C90 );
340+ uint32_t cSpecificFrameHandler = ByteSwap (0x8324B3BC );
340341 image.symbols .emplace (" __CxxFrameHandler" , 0x831B1C90 , 0x38 , Symbol_Function);
341342 image.symbols .emplace (" __C_specific_handler" , 0x8324B3BC , 0x38 , Symbol_Function);
342343 image.symbols .emplace (" memcpy" , 0x831B0ED0 , 0x488 , Symbol_Function);
343344 image.symbols .emplace (" memset" , 0x831B0BA0 , 0xA0 , Symbol_Function);
344345 image.symbols .emplace (" blkmov" , 0x831B1358 , 0xA8 , Symbol_Function);
345346
346- image.symbols .emplace (std ::format (" sub_{:X}" , 0x82EF5D78 ), 0x82EF5D78 , 0x3F8 , Symbol_Function);
347+ image.symbols .emplace (fmt ::format (" sub_{:X}" , 0x82EF5D78 ), 0x82EF5D78 , 0x3F8 , Symbol_Function);
347348
348349 // auto fnd = Function::Analyze(image.Find(0x82C40D58), image.size, 0x82C40D58);
349350
@@ -354,8 +355,8 @@ int main()
354355 for (size_t i = 0 ; i < count; i++)
355356 {
356357 auto fn = pf[i];
357- fn.BeginAddress = std::byteswap (fn.BeginAddress );
358- fn.Data = std::byteswap (fn.Data );
358+ fn.BeginAddress = ByteSwap (fn.BeginAddress );
359+ fn.Data = ByteSwap (fn.Data );
359360
360361 auto & f = functions.emplace_back ();
361362 f.base = fn.BeginAddress ;
@@ -366,7 +367,7 @@ int main()
366367 __debugbreak ();
367368 }
368369
369- image.symbols .emplace (std ::format (" sub_{:X}" , f.base ), f.base , f.size , Symbol_Function);
370+ image.symbols .emplace (fmt ::format (" sub_{:X}" , f.base ), f.base , f.size , Symbol_Function);
370371 }
371372
372373 auto sym = image.symbols .find (0x82BD7420 );
@@ -413,15 +414,15 @@ int main()
413414 base += missingFn.size ;
414415 data += missingFn.size ;
415416
416- std ::println (" sub_{:X}" , missingFn.base );
417+ fmt ::println (" sub_{:X}" , missingFn.base );
417418 }
418419 }
419420 }
420421
421422 // ppc_insn insn;
422423 // uint8_t c[4] = { 0x10, 0x00, 0x59, 0xC3 };
423424 // ppc::Disassemble(c, 0x831D6C64, insn);
424- // std ::println("{:20}{}", insn.opcode->name, insn.op_str);
425+ // fmt ::println("{:20}{}", insn.opcode->name, insn.op_str);
425426
426427
427428 const auto entrySymbol = image.symbols .find (image.entry_point );
@@ -432,21 +433,21 @@ int main()
432433
433434 image.symbols .emplace (" _start" , image.entry_point , entrySize, Symbol_Function);
434435
435- std ::println (" FUNCTIONS" );
436+ fmt ::println (" FUNCTIONS" );
436437 for (const auto & fn : functions)
437438 {
438- std ::println (" \t sub_{:X}" , fn.base );
439+ fmt ::println (" \t sub_{:X}" , fn.base );
439440 }
440- std ::println (" " );
441+ fmt ::println (" " );
441442
442443
443- std ::println (" SECTIONS" );
444+ fmt ::println (" SECTIONS" );
444445 for (const auto & section : image.sections )
445446 {
446- std:: printf (" Section %.8s\n " , section.name .c_str ());
447- std:: printf (" \t %X-%X\n " , section.base , section.base + section.size );
447+ printf (" Section %.8s\n " , section.name .c_str ());
448+ printf (" \t %X-%X\n " , section.base , section.base + section.size );
448449 }
449450
450- std ::println (" " );
451+ fmt ::println (" " );
451452 return 0 ;
452453}
0 commit comments