mirror of https://github.com/AxioDL/metaforce.git
DataSpec: Use std::search instead of memmem
This commit is contained in:
parent
2d74575267
commit
2874a48166
|
@ -220,9 +220,10 @@ struct SpecMP1 : SpecBase {
|
|||
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
|
||||
nod::IPartition* partition = disc.getDataPartition();
|
||||
m_dolBuf = partition->getDOLBuf();
|
||||
const char* start = reinterpret_cast<const char*>(m_dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
static_cast<char*>(memmem(m_dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
|
||||
|
||||
std::search(start, start + partition->getDOLSize(), match, match + strlen(match)) + 19;
|
||||
if (buildInfo == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -278,7 +279,10 @@ struct SpecMP1 : SpecBase {
|
|||
}
|
||||
|
||||
m_dolBuf = dolIt->getBuf();
|
||||
const char* buildInfo = static_cast<char*>(memmem(m_dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16)) + 19;
|
||||
const char* start = reinterpret_cast<const char*>(m_dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + dolIt->size(), match, match + strlen(match)) + 19;
|
||||
|
||||
/* Root Report */
|
||||
ExtractReport& rep = reps.emplace_back();
|
||||
|
|
|
@ -185,7 +185,10 @@ struct SpecMP2 : SpecBase {
|
|||
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
|
||||
nod::IPartition* partition = disc.getDataPartition();
|
||||
std::unique_ptr<uint8_t[]> dolBuf = partition->getDOLBuf();
|
||||
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
|
||||
const char* start = reinterpret_cast<const char*>(dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + partition->getDOLSize(), match, match + strlen(match)) + 19;
|
||||
if (buildInfo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -240,7 +243,10 @@ struct SpecMP2 : SpecBase {
|
|||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> dolBuf = dolIt->getBuf();
|
||||
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16)) + 19;
|
||||
const char* start = reinterpret_cast<const char*>(dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + dolIt->size(), match, match + strlen(match)) + 19;
|
||||
|
||||
/* Root Report */
|
||||
ExtractReport& rep = reps.emplace_back();
|
||||
|
|
|
@ -223,7 +223,10 @@ struct SpecMP3 : SpecBase {
|
|||
doMP3 = true;
|
||||
nod::IPartition* partition = disc.getDataPartition();
|
||||
std::unique_ptr<uint8_t[]> dolBuf = partition->getDOLBuf();
|
||||
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
|
||||
const char* start = reinterpret_cast<const char*>(dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + partition->getDOLSize(), match, match + strlen(match)) + 19;
|
||||
if (buildInfo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -301,8 +304,10 @@ struct SpecMP3 : SpecBase {
|
|||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> dolBuf = dolIt->getBuf();
|
||||
const char* buildInfo = (char*)memmem(dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16) + 19;
|
||||
|
||||
const char* start = reinterpret_cast<const char*>(dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + dolIt->size(), match, match + strlen(match)) + 19;
|
||||
if (!buildInfo) {
|
||||
doMP3 = false;
|
||||
break;
|
||||
|
@ -342,7 +347,10 @@ struct SpecMP3 : SpecBase {
|
|||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> dolBuf = dolIt->getBuf();
|
||||
const char* buildInfo = (char*)memmem(dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16) + 19;
|
||||
const char* start = reinterpret_cast<const char*>(dolBuf.get());
|
||||
constexpr const char* match = "MetroidBuildInfo";
|
||||
const char* buildInfo =
|
||||
std::search(start, start + dolIt->size(), match, match + strlen(match)) + 19;
|
||||
|
||||
/* Root Report */
|
||||
ExtractReport& rep = reps.emplace_back();
|
||||
|
|
Loading…
Reference in New Issue