yara: Actually fixed reading data
This commit is contained in:
parent
c61e807f13
commit
f325d50ab8
@ -59,6 +59,7 @@ namespace hex::plugin::builtin::prv {
|
||||
size_t m_fileSize = 0;
|
||||
|
||||
bool m_fileStatsValid = false;
|
||||
bool m_emptyFile = false;
|
||||
struct stat m_fileStats = { 0 };
|
||||
|
||||
bool m_readable = false, m_writable = false;
|
||||
|
@ -221,8 +221,11 @@ namespace hex::plugin::builtin::prv {
|
||||
mappingCleanup.release();
|
||||
|
||||
ProjectFile::setFilePath(this->m_path);
|
||||
} else {
|
||||
} else if (!this->m_emptyFile) {
|
||||
this->m_emptyFile = true;
|
||||
this->resize(1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
fileCleanup.release();
|
||||
|
@ -203,16 +203,18 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
context.buffer.resize(std::min<u64>(0xF'FFFF, provider->getSize() - context.currBlock.base));
|
||||
context.buffer.resize(context.currBlock.size);
|
||||
|
||||
if (context.buffer.empty()) return nullptr;
|
||||
|
||||
block->size = context.currBlock.size;
|
||||
|
||||
provider->read(context.currBlock.base + provider->getBaseAddress(), context.buffer.data(), context.buffer.size());
|
||||
|
||||
return context.buffer.data();
|
||||
};
|
||||
iterator.file_size = [](auto *iterator) -> u64 {
|
||||
return ImHexApi::Provider::get()->getSize();
|
||||
return ImHexApi::Provider::get()->getActualSize();
|
||||
};
|
||||
|
||||
iterator.context = &context;
|
||||
@ -233,7 +235,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
iterator->last_error = ERROR_SUCCESS;
|
||||
context.currBlock.base = address;
|
||||
context.currBlock.size = std::min<u64>(0xF'FFFF, ImHexApi::Provider::get()->getSize() - address);
|
||||
context.currBlock.size = ImHexApi::Provider::get()->getActualSize() - address;
|
||||
context.currBlock.context = &context;
|
||||
|
||||
if (context.currBlock.size == 0) return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user