Merge branch 'main' into nac-spice22x
Merge official spice2x 'main', up tob53447bNotes:dc82c98is where the nixac fork starts. - Upstream's OBJECT-library + forbidden-static-DLL-import build refactor merged with nixAC's blob/dsdmo resources - SPICE_XP / runtime large-address-aware detection builds have been integrated from upstream - README.md grabs from upstream; .gitignore keeps nixAC's fork-specific entries
This commit is contained in:
@@ -177,20 +177,21 @@ intptr_t replace_pattern_from(HMODULE module, const std::string &signature,
|
||||
strreplace(pattern_str, "??", "00");
|
||||
auto pattern_bin = std::make_unique<uint8_t[]>(signature.length() / 2);
|
||||
if (!hex2bin(pattern_str.c_str(), pattern_bin.get())) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// build signature mask
|
||||
std::ostringstream signature_mask;
|
||||
std::string signature_mask;
|
||||
signature_mask.reserve(signature.size() / 2);
|
||||
for (size_t i = 0; i < signature.length(); i += 2) {
|
||||
if (signature[i] == '?') {
|
||||
if (signature[i + 1] == '?') {
|
||||
signature_mask << '?';
|
||||
signature_mask += '?';
|
||||
} else {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
signature_mask << 'X';
|
||||
signature_mask += 'X';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,20 +200,21 @@ intptr_t replace_pattern_from(HMODULE module, const std::string &signature,
|
||||
strreplace(replace_data_str, "??", "00");
|
||||
auto replace_data_bin = std::make_unique<uint8_t[]>(replacement.length() / 2);
|
||||
if (!hex2bin(replace_data_str.c_str(), replace_data_bin.get())) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// build replace mask
|
||||
std::ostringstream replace_mask;
|
||||
std::string replace_mask;
|
||||
replace_mask.reserve(replacement.size() / 2);
|
||||
for (size_t i = 0; i < replacement.length(); i += 2) {
|
||||
if (replacement[i] == '?') {
|
||||
if (replacement[i + 1] == '?') {
|
||||
replace_mask << '?';
|
||||
replace_mask += '?';
|
||||
} else {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
replace_mask << 'X';
|
||||
replace_mask += 'X';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,12 +222,12 @@ intptr_t replace_pattern_from(HMODULE module, const std::string &signature,
|
||||
return replace_pattern_from(
|
||||
module,
|
||||
pattern_bin.get(),
|
||||
signature_mask.str().c_str(),
|
||||
signature_mask.c_str(),
|
||||
offset,
|
||||
usage,
|
||||
start_from,
|
||||
replace_data_bin.get(),
|
||||
replace_mask.str().c_str(),
|
||||
replace_mask.c_str(),
|
||||
reverse
|
||||
);
|
||||
}
|
||||
@@ -245,7 +247,7 @@ intptr_t replace_pattern(HMODULE module, const uint8_t *pattern, const char *mas
|
||||
bool get_pe_identifier(const std::filesystem::path& dll_path, uint32_t* time_date_stamp, uint32_t* address_of_entry_point) {
|
||||
std::ifstream file(dll_path, std::ios::binary);
|
||||
if (!file) {
|
||||
log_warning("sigscan", "Failed to open file: {}", dll_path.string().c_str());
|
||||
log_warning("sigscan", "Failed to open file: {}", dll_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -253,7 +255,7 @@ bool get_pe_identifier(const std::filesystem::path& dll_path, uint32_t* time_dat
|
||||
IMAGE_DOS_HEADER dos_header;
|
||||
file.read(reinterpret_cast<char*>(&dos_header), sizeof(dos_header));
|
||||
if (dos_header.e_magic != IMAGE_DOS_SIGNATURE) {
|
||||
log_warning("sigscan", "Invalid DOS signature: {}", dll_path.string().c_str());
|
||||
log_warning("sigscan", "Invalid DOS signature: {}", dll_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -264,7 +266,7 @@ bool get_pe_identifier(const std::filesystem::path& dll_path, uint32_t* time_dat
|
||||
IMAGE_NT_HEADERS nt_headers;
|
||||
file.read(reinterpret_cast<char*>(&nt_headers), sizeof(nt_headers));
|
||||
if (nt_headers.Signature != IMAGE_NT_SIGNATURE) {
|
||||
log_warning("sigscan", "Invalid NT signature: {}", dll_path.string().c_str());
|
||||
log_warning("sigscan", "Invalid NT signature: {}", dll_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user