Fixing most clang-format errors.

This commit is contained in:
Ben Vanik
2015-05-03 10:27:50 -07:00
parent 6b22d35bfc
commit d1ee1512b9
39 changed files with 540 additions and 550 deletions

View File

@@ -16,21 +16,19 @@ namespace tools {
void apiscanner_logger::operator()(const LogType type, const char* szMessage) {
switch (type) {
case LT_WARNING:
fprintf(stderr, "[W] %s\n", szMessage);
break;
case LT_ERROR:
fprintf(stderr, "[!] %s\n", szMessage);
break;
default:
break;
case LT_WARNING:
fprintf(stderr, "[W] %s\n", szMessage);
break;
case LT_ERROR:
fprintf(stderr, "[!] %s\n", szMessage);
break;
default:
break;
}
}
apiscanner_loader::apiscanner_loader()
: export_resolver(nullptr)
, memory_(nullptr)
{
: export_resolver(nullptr), memory_(nullptr) {
export_resolver = std::make_unique<xe::cpu::ExportResolver>();
kernel::XamModule::RegisterExportTable(export_resolver.get());
@@ -40,8 +38,7 @@ apiscanner_loader::apiscanner_loader()
memory_->Initialize();
}
apiscanner_loader::~apiscanner_loader()
{
apiscanner_loader::~apiscanner_loader() {
if (export_resolver != nullptr) {
export_resolver.reset();
}
@@ -62,7 +59,6 @@ bool apiscanner_loader::LoadTitleImports(const std::wstring& target) {
return ReadTarget();
}
bool apiscanner_loader::ReadTarget() {
// XXX Do a wildcard search for all xex files?
const char path[] = "game:\\default.xex";
@@ -91,8 +87,7 @@ bool apiscanner_loader::ReadTarget() {
if (read_result) {
loaded_titles.push_back(res);
}
}
else {
} else {
kernel::XFileInfo file_info;
if (fs_entry->QueryInfo(&file_info)) {
if (file) {
@@ -107,7 +102,7 @@ bool apiscanner_loader::ReadTarget() {
// XXX No kernel state again
int result = file_system.Open(std::move(fs_entry), nullptr,
kernel::fs::Mode::READ, false, &file);
kernel::fs::Mode::READ, false, &file);
if (result) {
if (file) {
file->Release();
@@ -141,10 +136,9 @@ bool apiscanner_loader::ReadTarget() {
}
bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
title& info)
{
title& info) {
// Load the XEX into memory and decrypt.
xe_xex2_options_t xex_options = { 0 };
xe_xex2_options_t xex_options = {0};
xe_xex2_ref xex_(xe_xex2_load(memory_.get(), addr, length, xex_options));
if (!xex_) {
log(log.LT_ERROR, "Failed to parse xex file");
@@ -154,7 +148,7 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
info.title_id = header->execution_info.title_id;
// XXX Copy out library versions?
for (size_t n = 0; n < header->import_library_count; n++) {
const xe_xex2_import_library_t* library = &header->import_libraries[n];
@@ -162,8 +156,7 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
xe_xex2_import_info_t* import_infos;
size_t import_info_count;
if (!xe_xex2_get_import_infos(xex_, library, &import_infos,
&import_info_count)) {
&import_info_count)) {
for (size_t m = 0; m < import_info_count; m++) {
const xe_xex2_import_info_t* import_info = &import_infos[m];
@@ -186,5 +179,5 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
return true;
}
} // tools
} // xe
} // tools
} // xe

View File

@@ -22,46 +22,39 @@
namespace xe {
namespace tools {
class apiscanner_logger
{
public:
enum LogType {
LT_WARNING,
LT_ERROR
};
class apiscanner_logger {
public:
enum LogType { LT_WARNING, LT_ERROR };
void operator()(const LogType type, const char* szMessage);
void operator()(const LogType type, const char* szMessage);
};
class apiscanner_loader {
private:
kernel::fs::FileSystem file_system;
apiscanner_logger log;
std::unique_ptr<Memory> memory_;
std::unique_ptr<xe::cpu::ExportResolver> export_resolver;
public:
apiscanner_loader();
~apiscanner_loader();
bool LoadTitleImports(const std::wstring& target);
struct title {
uint32_t title_id;
std::vector<std::string> imports;
};
class apiscanner_loader
{
private:
kernel::fs::FileSystem file_system;
apiscanner_logger log;
std::unique_ptr<Memory> memory_;
std::unique_ptr<xe::cpu::ExportResolver> export_resolver;
const std::vector<title>& GetAllTitles() const { return loaded_titles; }
public:
apiscanner_loader();
~apiscanner_loader();
private:
std::vector<title> loaded_titles;
bool LoadTitleImports(const std::wstring& target);
struct title
{
uint32_t title_id;
std::vector<std::string> imports;
};
const std::vector<title>& GetAllTitles() const { return loaded_titles; }
private:
std::vector<title> loaded_titles;
bool ReadTarget();
bool ExtractImports(const void* addr, const size_t length, title& info);
};
} // tools
} // xe
bool ReadTarget();
bool ExtractImports(const void* addr, const size_t length, title& info);
};
} // tools
} // xe

View File

@@ -16,7 +16,6 @@ namespace tools {
DEFINE_string(target, "", "List of file to extract imports from");
int api_scanner_main(std::vector<std::wstring>& args) {
// XXX we need gflags to split multiple flags into arrays for us
if (args.size() == 2 || !FLAGS_target.empty()) {
@@ -44,4 +43,4 @@ int api_scanner_main(std::vector<std::wstring>& args) {
} // namespace xe
DEFINE_ENTRY_POINT(L"api-scanner", L"api-scanner --target=<target file>",
xe::tools::api_scanner_main);
xe::tools::api_scanner_main);