Last active
July 4, 2024 18:20
-
-
Save alexhude/182af7ed66f7e7a6b6b5969165cf15ae to your computer and use it in GitHub Desktop.
Build ImHex for macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It is a pretty dirty hack, but it works. | |
In the attached diff: | |
- fixed type mismatch for min/max | |
- replaced ftello64/fseeko64 | |
- disabled llvm::demangle to fix link error due to llvm lib mismatch on my machine | |
First exported GCC 10.2 before CMake | |
export CC=/usr/local/bin/gcc-10 | |
export CXX=/usr/local/bin/g++-10 | |
Then just built with frameworks and lib paths (proper way would be to fix CMakeLists.txt :P ) | |
-L/usr/local/lib/ | |
-L/usr/local/Cellar/[email protected]/1.1.1h/lib/ | |
-L/usr/local/Cellar/llvm/11.0.0/lib/ | |
-framework Foundation | |
-framework Cocoa | |
-framework IOKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/source/helpers/crypto.cpp b/source/helpers/crypto.cpp | |
index fa23428..e0ef3ad 100644 | |
--- a/source/helpers/crypto.cpp | |
+++ b/source/helpers/crypto.cpp | |
@@ -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); | |
} | |
diff --git a/source/lang/evaluator.cpp b/source/lang/evaluator.cpp | |
index f5241c6..b1fab50 100644 | |
--- a/source/lang/evaluator.cpp | |
+++ b/source/lang/evaluator.cpp | |
@@ -179,7 +179,7 @@ namespace hex::lang { | |
} | |
else { | |
members.push_back(pattern); | |
- unionSize = std::max(memberSize, unionSize); | |
+ unionSize = std::max(memberSize, (u64)unionSize); | |
} | |
} | |
diff --git a/source/providers/file_provider.cpp b/source/providers/file_provider.cpp | |
index a6deb2a..73503d5 100644 | |
--- a/source/providers/file_provider.cpp | |
+++ b/source/providers/file_provider.cpp | |
@@ -51,7 +51,7 @@ namespace hex::prv { | |
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0) | |
return; | |
- fseeko64(this->m_file, this->getCurrentPage() * PageSize + offset, SEEK_SET); | |
+ fseeko(this->m_file, this->getCurrentPage() * PageSize + offset, SEEK_SET); | |
size_t readSize = fread(buffer, 1, size, this->m_file); | |
@@ -75,7 +75,7 @@ namespace hex::prv { | |
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0) | |
return; | |
- fseeko64(this->m_file, this->getCurrentPage() * PageSize + offset, SEEK_SET); | |
+ fseeko(this->m_file, this->getCurrentPage() * PageSize + offset, SEEK_SET); | |
fread(buffer, 1, size, this->m_file); | |
} | |
@@ -83,12 +83,12 @@ namespace hex::prv { | |
if (buffer == nullptr || size == 0) | |
return; | |
- fseeko64(this->m_file, offset, SEEK_SET); | |
+ fseeko(this->m_file, offset, SEEK_SET); | |
fwrite(buffer, 1, size, this->m_file); | |
} | |
size_t FileProvider::getActualSize() { | |
- fseeko64(this->m_file, 0, SEEK_END); | |
- return ftello64(this->m_file); | |
+ fseeko(this->m_file, 0, SEEK_END); | |
+ return ftello(this->m_file); | |
} | |
std::vector<std::pair<std::string, std::string>> FileProvider::getDataInformation() { | |
diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp | |
index 4f23f8b..2c3c293 100644 | |
--- a/source/views/view_data_inspector.cpp | |
+++ b/source/views/view_data_inspector.cpp | |
@@ -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(sizeof(this->m_dataProvider->getSize() - region.address), sizeof(PreviewData)); | |
std::memset(&this->m_previewData, 0x00, sizeof(PreviewData)); | |
this->m_dataProvider->read(region.address, &this->m_previewData, sizeof(PreviewData)); | |
diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp | |
index cc4f7e8..bc985b8 100644 | |
--- a/source/views/view_hexeditor.cpp | |
+++ b/source/views/view_hexeditor.cpp | |
@@ -490,7 +490,7 @@ namespace hex { | |
return false; | |
fseek(file, 0, SEEK_END); | |
- size_t size = ftello64(file); | |
+ size_t size = ftello(file); | |
rewind(file); | |
data.resize(size); | |
@@ -746,7 +746,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++) { | |
@@ -784,7 +784,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++) { | |
diff --git a/source/views/view_information.cpp b/source/views/view_information.cpp | |
index 0386b2e..bf9439d 100644 | |
--- a/source/views/view_information.cpp | |
+++ b/source/views/view_information.cpp | |
@@ -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]]++; | |
diff --git a/source/views/view_strings.cpp b/source/views/view_strings.cpp | |
index 0e09cfc..e5a25da 100644 | |
--- a/source/views/view_strings.cpp | |
+++ b/source/views/view_strings.cpp | |
@@ -37,7 +37,8 @@ namespace hex { | |
} | |
ImGui::Separator(); | |
if (ImGui::MenuItem("Demangle")) { | |
- this->m_demangledName = llvm::demangle(this->m_selectedString); | |
+ //this->m_demangledName = llvm::demangle(this->m_selectedString); | |
+ this->m_demangledName = this->m_selectedString; | |
if (!this->m_demangledName.empty()) | |
View::doLater([]{ ImGui::OpenPopup("Demangled Name"); }); | |
} | |
@@ -55,7 +56,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++) { | |
diff --git a/source/views/view_tools.cpp b/source/views/view_tools.cpp | |
index a0d4c0d..dcde3cb 100644 | |
--- a/source/views/view_tools.cpp | |
+++ b/source/views/view_tools.cpp | |
@@ -76,7 +76,7 @@ namespace hex { | |
void ViewTools::drawDemangler() { | |
if (ImGui::CollapsingHeader("Itanium/MSVC demangler")) { | |
if (ImGui::InputText("Mangled name", this->m_mangledBuffer, 0xF'FFFF)) { | |
- this->m_demangledName = llvm::demangle(this->m_mangledBuffer); | |
+ //this->m_demangledName = llvm::demangle(this->m_mangledBuffer); | |
} | |
ImGui::InputText("Demangled name", this->m_demangledName.data(), this->m_demangledName.size(), ImGuiInputTextFlags_ReadOnly); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hehe, sweeeeeeet!
I wish someone make changes to CMakeLists as well :D