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

Added possible support for MacOS. Completely untested.

Relevant: #32
This commit is contained in:
WerWolv 2020-12-06 13:48:56 +01:00
parent 68f93c5e3d
commit 4720cf9fbe
9 changed files with 26 additions and 26 deletions

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/HexEditor.iml" filepath="$PROJECT_DIR$/.idea/HexEditor.iml" />
</modules>
</component>
</project>

View File

@ -227,7 +227,7 @@ struct MemoryEditor
footer_height += height_separator + ImGui::GetFrameHeightWithSpacing() * 1;
ImGui::BeginChild("offset", ImVec2(0, s.LineHeight), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
ImGui::Text("% *c ", s.AddrDigitsCount, ' ');
ImGui::Text("%*c ", s.AddrDigitsCount, ' ');
for (int i = 0; i < Cols; i++) {
float byte_pos_x = s.PosHexStart + s.HexCellWidth * i;
if (OptMidColsCount > 0)

View File

@ -41,7 +41,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; offset < size; offset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
for (size_t i = 0; i < readSize; i++) {
@ -74,7 +74,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; offset < size; offset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
for (size_t i = 0; i < readSize; i++) {
@ -94,7 +94,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
MD4_Update(&ctx, buffer.data(), readSize);
}
@ -113,7 +113,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
MD5_Update(&ctx, buffer.data(), readSize);
}
@ -131,7 +131,7 @@ namespace hex {
SHA1_Init(&ctx);
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
SHA1_Update(&ctx, buffer.data(), readSize);
}
@ -150,7 +150,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
SHA224_Update(&ctx, buffer.data(), readSize);
}
@ -169,7 +169,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
SHA256_Update(&ctx, buffer.data(), readSize);
}
@ -188,7 +188,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
SHA384_Update(&ctx, buffer.data(), readSize);
}
@ -207,7 +207,7 @@ namespace hex {
std::array<u8, 512> buffer = { 0 };
for (u64 bufferOffset = 0; bufferOffset < size; bufferOffset += buffer.size()) {
const u64 readSize = std::min(buffer.size(), size - bufferOffset);
const u64 readSize = std::min(u64(buffer.size()), size - bufferOffset);
data->read(offset + bufferOffset, buffer.data(), readSize);
SHA512_Update(&ctx, buffer.data(), readSize);
}

View File

@ -231,7 +231,7 @@ namespace hex::lang {
char *end = nullptr;
std::strtoull(&code[offset], &end, 0);
auto integer = parseInt(std::string_view(&code[offset], end));
auto integer = parseInt(std::string_view(&code[offset], end - &code[offset]));
if (!integer.has_value()) {
this->m_error = { lineNumber, "Invalid integer literal" };

View File

@ -9,18 +9,26 @@
#include "helpers/utils.hpp"
#include "helpers/project_file_handler.hpp"
#ifdef __APPLE__
#define off64_t off_t
#define fopen64 fopen
#define fseeko64 fseek
#define ftello64 ftell
#endif
namespace hex::prv {
FileProvider::FileProvider(std::string_view path) : Provider(), m_path(path) {
this->m_fileStatsValid = stat(path.data(), &this->m_fileStats) == 0;
this->m_file = fopen(path.data(), "r+b");
this->m_file = fopen64(path.data(), "r+b");
this->m_readable = true;
this->m_writable = true;
if (this->m_file == nullptr) {
this->m_file = fopen(path.data(), "rb");
this->m_file = fopen64(path.data(), "rb");
this->m_writable = false;
}

View File

@ -13,7 +13,7 @@ namespace hex {
View::subscribeEvent(Events::RegionSelected, [this](const void* userData){
Region region = *static_cast<const Region*>(userData);
this->m_validBytes = std::min(this->m_dataProvider->getSize() - region.address, sizeof(PreviewData));
this->m_validBytes = std::min(u64(this->m_dataProvider->getSize() - region.address), u64(sizeof(PreviewData)));
std::memset(&this->m_previewData, 0x00, sizeof(PreviewData));
this->m_dataProvider->read(region.address, &this->m_previewData, this->m_validBytes);

View File

@ -748,7 +748,7 @@ R"(
std::vector<u8> buffer(1024, 0x00);
size_t dataSize = provider->getSize();
for (u64 offset = 0; offset < dataSize; offset += 1024) {
size_t usedBufferSize = std::min(buffer.size(), dataSize - offset);
size_t usedBufferSize = std::min(u64(buffer.size()), dataSize - offset);
provider->read(offset, buffer.data(), usedBufferSize);
for (u64 i = 0; i < usedBufferSize; i++) {
@ -786,7 +786,7 @@ R"(
std::vector<u8> buffer(1024, 0x00);
size_t dataSize = provider->getSize();
for (u64 offset = 0; offset < dataSize; offset += 1024) {
size_t usedBufferSize = std::min(buffer.size(), dataSize - offset);
size_t usedBufferSize = std::min(u64(buffer.size()), dataSize - offset);
provider->read(offset, buffer.data(), usedBufferSize);
for (u64 i = 0; i < usedBufferSize; i++) {

View File

@ -63,7 +63,7 @@ namespace hex {
for (u64 i = 0; i < this->m_dataProvider->getSize(); i += this->m_blockSize) {
std::array<float, 256> blockValueCounts = { 0 };
this->m_dataProvider->read(i, buffer.data(), std::min(size_t(this->m_blockSize), this->m_dataProvider->getSize() - i));
this->m_dataProvider->read(i, buffer.data(), std::min(u64(this->m_blockSize), this->m_dataProvider->getSize() - i));
for (size_t j = 0; j < this->m_blockSize; j++) {
blockValueCounts[buffer[j]]++;

View File

@ -55,7 +55,7 @@ namespace hex {
std::vector<u8> buffer(1024, 0x00);
u32 foundCharacters = 0;
for (u64 offset = 0; offset < this->m_dataProvider->getSize(); offset += buffer.size()) {
size_t readSize = std::min(buffer.size(), this->m_dataProvider->getSize() - offset);
size_t readSize = std::min(u64(buffer.size()), this->m_dataProvider->getSize() - offset);
this->m_dataProvider->read(offset, buffer.data(), readSize);
for (u32 i = 0; i < readSize; i++) {