1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Magic information querying being wrong with non-zero base address

This commit is contained in:
WerWolv 2024-02-24 23:53:34 +01:00
parent b57eaca365
commit 752a2d2e8d

View File

@ -115,7 +115,7 @@ namespace hex::magic {
std::string getDescription(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) { std::string getDescription(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) {
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00); std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress() + address, buffer.data(), buffer.size()); provider->read(address, buffer.data(), buffer.size());
return getDescription(buffer, firstEntryOnly); return getDescription(buffer, firstEntryOnly);
} }
@ -140,14 +140,14 @@ namespace hex::magic {
std::string getMIMEType(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) { std::string getMIMEType(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) {
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00); std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress() + address, buffer.data(), buffer.size()); provider->read(address, buffer.data(), buffer.size());
return getMIMEType(buffer, firstEntryOnly); return getMIMEType(buffer, firstEntryOnly);
} }
std::string getExtensions(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) { std::string getExtensions(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) {
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00); std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress() + address, buffer.data(), buffer.size()); provider->read(address, buffer.data(), buffer.size());
return getExtensions(buffer, firstEntryOnly); return getExtensions(buffer, firstEntryOnly);
} }
@ -172,7 +172,7 @@ namespace hex::magic {
std::string getAppleCreatorType(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) { std::string getAppleCreatorType(prv::Provider *provider, u64 address, size_t size, bool firstEntryOnly) {
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00); std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress() + address, buffer.data(), buffer.size()); provider->read(address, buffer.data(), buffer.size());
return getAppleCreatorType(buffer, firstEntryOnly); return getAppleCreatorType(buffer, firstEntryOnly);
} }