[CPU] Rename ImportLibrary fields to follow naming conventions
This commit is contained in:
parent
6e74ba93d6
commit
7443b7e61f
|
@ -1231,10 +1231,10 @@ bool XexModule::SetupLibraryImports(const char* name,
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportLibrary library_info;
|
ImportLibrary library_info;
|
||||||
library_info.Name = libbasename;
|
library_info.name = libbasename;
|
||||||
library_info.ID = library->id;
|
library_info.id = library->id;
|
||||||
library_info.Version.value = library->version.value;
|
library_info.version.value = library->version.value;
|
||||||
library_info.MinVersion.value = library->version_min.value;
|
library_info.min_version.value = library->version_min.value;
|
||||||
|
|
||||||
// Imports are stored as {import descriptor, thunk addr, import desc, ...}
|
// Imports are stored as {import descriptor, thunk addr, import desc, ...}
|
||||||
// Even thunks have an import descriptor (albeit unused/useless)
|
// Even thunks have an import descriptor (albeit unused/useless)
|
||||||
|
@ -1271,9 +1271,9 @@ bool XexModule::SetupLibraryImports(const char* name,
|
||||||
// Variable.
|
// Variable.
|
||||||
|
|
||||||
ImportLibraryFn import_info;
|
ImportLibraryFn import_info;
|
||||||
import_info.Ordinal = ordinal;
|
import_info.ordinal = ordinal;
|
||||||
import_info.ValueAddress = record_addr;
|
import_info.value_address = record_addr;
|
||||||
library_info.Imports.push_back(import_info);
|
library_info.imports.push_back(import_info);
|
||||||
|
|
||||||
import_name.AppendFormat("__imp__");
|
import_name.AppendFormat("__imp__");
|
||||||
if (kernel_export) {
|
if (kernel_export) {
|
||||||
|
@ -1314,10 +1314,10 @@ bool XexModule::SetupLibraryImports(const char* name,
|
||||||
var_info->set_status(Symbol::Status::kDefined);
|
var_info->set_status(Symbol::Status::kDefined);
|
||||||
} else if (record_type == 1) {
|
} else if (record_type == 1) {
|
||||||
// Thunk.
|
// Thunk.
|
||||||
assert_true(library_info.Imports.size() > 0);
|
assert_true(library_info.imports.size() > 0);
|
||||||
auto& prev_import = library_info.Imports[library_info.Imports.size() - 1];
|
auto& prev_import = library_info.imports[library_info.imports.size() - 1];
|
||||||
assert_true(prev_import.Ordinal == ordinal);
|
assert_true(prev_import.ordinal == ordinal);
|
||||||
prev_import.ThunkAddress = record_addr;
|
prev_import.thunk_address = record_addr;
|
||||||
|
|
||||||
if (kernel_export) {
|
if (kernel_export) {
|
||||||
import_name.AppendFormat("%s", kernel_export->name);
|
import_name.AppendFormat("%s", kernel_export->name);
|
||||||
|
|
|
@ -31,17 +31,17 @@ class XexModule : public xe::cpu::Module {
|
||||||
public:
|
public:
|
||||||
struct ImportLibraryFn {
|
struct ImportLibraryFn {
|
||||||
public:
|
public:
|
||||||
uint32_t Ordinal;
|
uint32_t ordinal;
|
||||||
uint32_t ValueAddress;
|
uint32_t value_address;
|
||||||
uint32_t ThunkAddress;
|
uint32_t thunk_address;
|
||||||
};
|
};
|
||||||
struct ImportLibrary {
|
struct ImportLibrary {
|
||||||
public:
|
public:
|
||||||
std::string Name;
|
std::string name;
|
||||||
uint32_t ID;
|
uint32_t id;
|
||||||
xe_xex2_version_t Version;
|
xe_xex2_version_t version;
|
||||||
xe_xex2_version_t MinVersion;
|
xe_xex2_version_t min_version;
|
||||||
std::vector<ImportLibraryFn> Imports;
|
std::vector<ImportLibraryFn> imports;
|
||||||
};
|
};
|
||||||
|
|
||||||
XexModule(Processor* processor, kernel::KernelState* kernel_state);
|
XexModule(Processor* processor, kernel::KernelState* kernel_state);
|
||||||
|
|
|
@ -695,15 +695,15 @@ void UserModule::Dump() {
|
||||||
for (std::vector<cpu::XexModule::ImportLibrary>::const_iterator library =
|
for (std::vector<cpu::XexModule::ImportLibrary>::const_iterator library =
|
||||||
import_libs->begin();
|
import_libs->begin();
|
||||||
library != import_libs->end(); ++library) {
|
library != import_libs->end(); ++library) {
|
||||||
if (library->Imports.size() > 0) {
|
if (library->imports.size() > 0) {
|
||||||
sb.AppendFormat(" %s - %lld imports\n", library->Name.c_str(),
|
sb.AppendFormat(" %s - %lld imports\n", library->name.c_str(),
|
||||||
library->Imports.size());
|
library->imports.size());
|
||||||
sb.AppendFormat(" Version: %d.%d.%d.%d\n", library->Version.major,
|
sb.AppendFormat(" Version: %d.%d.%d.%d\n", library->version.major,
|
||||||
library->Version.minor, library->Version.build,
|
library->version.minor, library->version.build,
|
||||||
library->Version.qfe);
|
library->version.qfe);
|
||||||
sb.AppendFormat(" Min Version: %d.%d.%d.%d\n",
|
sb.AppendFormat(" Min Version: %d.%d.%d.%d\n",
|
||||||
library->MinVersion.major, library->MinVersion.minor,
|
library->min_version.major, library->min_version.minor,
|
||||||
library->MinVersion.build, library->MinVersion.qfe);
|
library->min_version.build, library->min_version.qfe);
|
||||||
sb.AppendFormat("\n");
|
sb.AppendFormat("\n");
|
||||||
|
|
||||||
// Counts.
|
// Counts.
|
||||||
|
@ -713,11 +713,11 @@ void UserModule::Dump() {
|
||||||
int unimpl_count = 0;
|
int unimpl_count = 0;
|
||||||
|
|
||||||
for (std::vector<cpu::XexModule::ImportLibraryFn>::const_iterator info =
|
for (std::vector<cpu::XexModule::ImportLibraryFn>::const_iterator info =
|
||||||
library->Imports.begin();
|
library->imports.begin();
|
||||||
info != library->Imports.end(); ++info) {
|
info != library->imports.end(); ++info) {
|
||||||
if (kernel_state_->IsKernelModule(library->Name.c_str())) {
|
if (kernel_state_->IsKernelModule(library->name.c_str())) {
|
||||||
auto kernel_export = export_resolver->GetExportByOrdinal(
|
auto kernel_export = export_resolver->GetExportByOrdinal(
|
||||||
library->Name.c_str(), info->Ordinal);
|
library->name.c_str(), info->ordinal);
|
||||||
if (kernel_export) {
|
if (kernel_export) {
|
||||||
known_count++;
|
known_count++;
|
||||||
if (kernel_export->is_implemented()) {
|
if (kernel_export->is_implemented()) {
|
||||||
|
@ -730,10 +730,10 @@ void UserModule::Dump() {
|
||||||
unimpl_count++;
|
unimpl_count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto module = kernel_state_->GetModule(library->Name.c_str());
|
auto module = kernel_state_->GetModule(library->name.c_str());
|
||||||
if (module) {
|
if (module) {
|
||||||
uint32_t export_addr =
|
uint32_t export_addr =
|
||||||
module->GetProcAddressByOrdinal(info->Ordinal);
|
module->GetProcAddressByOrdinal(info->ordinal);
|
||||||
if (export_addr) {
|
if (export_addr) {
|
||||||
impl_count++;
|
impl_count++;
|
||||||
known_count++;
|
known_count++;
|
||||||
|
@ -747,8 +747,8 @@ void UserModule::Dump() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float total_count = static_cast<float>(library->Imports.size()) / 100.0f;
|
float total_count = static_cast<float>(library->imports.size()) / 100.0f;
|
||||||
sb.AppendFormat(" Total: %4llu\n", library->Imports.size());
|
sb.AppendFormat(" Total: %4llu\n", library->imports.size());
|
||||||
sb.AppendFormat(" Known: %3d%% (%d known, %d unknown)\n",
|
sb.AppendFormat(" Known: %3d%% (%d known, %d unknown)\n",
|
||||||
static_cast<int>(known_count / total_count), known_count,
|
static_cast<int>(known_count / total_count), known_count,
|
||||||
unknown_count);
|
unknown_count);
|
||||||
|
@ -759,22 +759,22 @@ void UserModule::Dump() {
|
||||||
|
|
||||||
// Listing.
|
// Listing.
|
||||||
for (std::vector<cpu::XexModule::ImportLibraryFn>::const_iterator info =
|
for (std::vector<cpu::XexModule::ImportLibraryFn>::const_iterator info =
|
||||||
library->Imports.begin();
|
library->imports.begin();
|
||||||
info != library->Imports.end(); ++info) {
|
info != library->imports.end(); ++info) {
|
||||||
const char* name = "UNKNOWN";
|
const char* name = "UNKNOWN";
|
||||||
bool implemented = false;
|
bool implemented = false;
|
||||||
|
|
||||||
cpu::Export* kernel_export = nullptr;
|
cpu::Export* kernel_export = nullptr;
|
||||||
if (kernel_state_->IsKernelModule(library->Name.c_str())) {
|
if (kernel_state_->IsKernelModule(library->name.c_str())) {
|
||||||
kernel_export = export_resolver->GetExportByOrdinal(
|
kernel_export = export_resolver->GetExportByOrdinal(
|
||||||
library->Name.c_str(), info->Ordinal);
|
library->name.c_str(), info->ordinal);
|
||||||
if (kernel_export) {
|
if (kernel_export) {
|
||||||
name = kernel_export->name;
|
name = kernel_export->name;
|
||||||
implemented = kernel_export->is_implemented();
|
implemented = kernel_export->is_implemented();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto module = kernel_state_->GetModule(library->Name.c_str());
|
auto module = kernel_state_->GetModule(library->name.c_str());
|
||||||
if (module && module->GetProcAddressByOrdinal(info->Ordinal)) {
|
if (module && module->GetProcAddressByOrdinal(info->ordinal)) {
|
||||||
// TODO(benvanik): name lookup.
|
// TODO(benvanik): name lookup.
|
||||||
implemented = true;
|
implemented = true;
|
||||||
}
|
}
|
||||||
|
@ -782,12 +782,12 @@ void UserModule::Dump() {
|
||||||
if (kernel_export &&
|
if (kernel_export &&
|
||||||
kernel_export->type == cpu::Export::Type::kVariable) {
|
kernel_export->type == cpu::Export::Type::kVariable) {
|
||||||
sb.AppendFormat(" V %.8X %.3X (%3d) %s %s\n",
|
sb.AppendFormat(" V %.8X %.3X (%3d) %s %s\n",
|
||||||
info->ValueAddress, info->Ordinal, info->Ordinal,
|
info->value_address, info->ordinal, info->ordinal,
|
||||||
implemented ? " " : "!!", name);
|
implemented ? " " : "!!", name);
|
||||||
} else if (info->ThunkAddress) {
|
} else if (info->thunk_address) {
|
||||||
sb.AppendFormat(" F %.8X %.8X %.3X (%3d) %s %s\n",
|
sb.AppendFormat(" F %.8X %.8X %.3X (%3d) %s %s\n",
|
||||||
info->ValueAddress, info->ThunkAddress, info->Ordinal,
|
info->value_address, info->thunk_address, info->ordinal,
|
||||||
info->Ordinal, implemented ? " " : "!!", name);
|
info->ordinal, implemented ? " " : "!!", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue