1
0
mirror of synced 2024-11-28 09:30:51 +01:00

impr: More size_t -> u64

This commit is contained in:
WerWolv 2023-12-07 13:02:12 +01:00
parent 3a016da549
commit 7f69f8bcdb
6 changed files with 12 additions and 12 deletions

View File

@ -37,7 +37,7 @@ namespace hex {
return (byte & pattern.mask) == pattern.value;
}
[[nodiscard]] size_t getSize() const {
[[nodiscard]] u64 getSize() const {
return this->m_patterns.size();
}

View File

@ -182,7 +182,7 @@ namespace hex::prv {
virtual void setBaseAddress(u64 address);
[[nodiscard]] virtual u64 getBaseAddress() const;
[[nodiscard]] virtual u64 getCurrentPageAddress() const;
[[nodiscard]] virtual size_t getSize() const;
[[nodiscard]] virtual u64 getSize() const;
[[nodiscard]] virtual std::optional<u32> getPageOfAddress(u64 address) const;
[[nodiscard]] virtual std::vector<Description> getDataDescription() const;

View File

@ -112,7 +112,7 @@ namespace hex::magic {
}
std::string getDescription(prv::Provider *provider, size_t size) {
std::vector<u8> buffer(std::min(provider->getSize(), size), 0x00);
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress(), buffer.data(), buffer.size());
return getDescription(buffer);
@ -135,7 +135,7 @@ namespace hex::magic {
}
std::string getMIMEType(prv::Provider *provider, size_t size) {
std::vector<u8> buffer(std::min(provider->getSize(), size), 0x00);
std::vector<u8> buffer(std::min<u64>(provider->getSize(), size), 0x00);
provider->read(provider->getBaseAddress(), buffer.data(), buffer.size());
return getMIMEType(buffer);

View File

@ -160,8 +160,8 @@ namespace hex::prv {
return this->getPageSize() * this->getCurrentPage();
}
size_t Provider::getSize() const {
return std::min(this->getActualSize() - this->getPageSize() * this->m_currPage, this->getPageSize());
u64 Provider::getSize() const {
return std::min<u64>(this->getActualSize() - this->getPageSize() * this->m_currPage, this->getPageSize());
}
std::optional<u32> Provider::getPageOfAddress(u64 address) const {

View File

@ -250,7 +250,7 @@ namespace hex::plugin::builtin {
this->m_sectorBufferAddress = seekPosition.QuadPart;
}
std::memcpy(static_cast<u8 *>(buffer) + (offset - startOffset), this->m_sectorBuffer.data() + (offset & (this->m_sectorSize - 1)), std::min(this->m_sectorSize, size));
std::memcpy(static_cast<u8 *>(buffer) + (offset - startOffset), this->m_sectorBuffer.data() + (offset & (this->m_sectorSize - 1)), std::min<u64>(this->m_sectorSize, size));
size = std::max<ssize_t>(static_cast<ssize_t>(size) - this->m_sectorSize, 0);
offset += this->m_sectorSize;
@ -273,7 +273,7 @@ namespace hex::plugin::builtin {
std::memcpy(reinterpret_cast<u8 *>(buffer) + (offset - startOffset),
this->m_sectorBuffer.data() + (offset & (this->m_sectorSize - 1)),
std::min(this->m_sectorSize, size));
std::min<u64>(this->m_sectorSize, size));
size = std::max<ssize_t>(static_cast<ssize_t>(size) - this->m_sectorSize, 0);
offset += this->m_sectorSize;
@ -294,7 +294,7 @@ namespace hex::plugin::builtin {
while (size > 0) {
u64 sectorBase = offset - (offset % this->m_sectorSize);
size_t currSize = std::min(size, this->m_sectorSize);
size_t currSize = std::min<u64>(size, this->m_sectorSize);
this->readRaw(sectorBase, modifiedSectorBuffer.data(), modifiedSectorBuffer.size());
std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % this->m_sectorSize), reinterpret_cast<const u8 *>(buffer) + (startOffset - offset), currSize);
@ -319,7 +319,7 @@ namespace hex::plugin::builtin {
while (size > 0) {
u64 sectorBase = offset - (offset % this->m_sectorSize);
size_t currSize = std::min(size, this->m_sectorSize);
size_t currSize = std::min<u64>(size, this->m_sectorSize);
this->readRaw(sectorBase, modifiedSectorBuffer.data(), modifiedSectorBuffer.size());
std::memcpy(modifiedSectorBuffer.data() + ((offset - sectorBase) % this->m_sectorSize), reinterpret_cast<const u8 *>(buffer) + (startOffset - offset), currSize);

View File

@ -171,10 +171,10 @@ namespace hex::plugin::builtin {
}
if (cacheLine != this->m_cache.end())
std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), std::min(size, cacheLine->data.size()));
std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), std::min<u64>(size, cacheLine->data.size()));
} else {
while (size > 0) {
size_t readSize = std::min(size, CacheLineSize);
size_t readSize = std::min<u64>(size, CacheLineSize);
auto data = gdb::readMemory(this->m_socket, offset, size);
if (!data.empty())