Files
Mergen/lifter/core/CommandLineHelpers.hpp
T
yusufcanislek 1ed00cc67e Refactor: reorganize lifter/ into subdirectories with PascalCase naming
Directory structure:
  lifter/core/       - LifterClass, pipeline, drivers, application, utils
  lifter/semantics/  - Semantics*.ipp, OperandUtils.ipp, opcodes
  lifter/disasm/     - Disassembler backends, mnemonic/register mappings
  lifter/memory/     - GEPTracker, MemoryPolicy, FileReader
  lifter/analysis/   - PathSolver, CustomPasses
  lifter/test/       - TestInstructions, Tester, test_vectors/

Naming convention standardized to PascalCase:
  fileReader.hpp     -> FileReader.hpp
  lifterClass.hpp    -> LifterClass.hpp
  icedDisassembler*  -> IcedDisassembler*
  utils.h/cpp        -> Utils.h/cpp
  includes.h         -> Includes.h
  pp_macros.hpp      -> PPMacros.hpp
  test_instructions* -> TestInstructions*
  tester.hpp         -> Tester.hpp

Include resolution uses cmake include-directories so no
path prefixes needed in #include directives. All script
paths updated for new test_vectors and opcodes locations.
2026-03-06 18:07:26 +03:00

50 lines
1.4 KiB
C++

#pragma once
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
inline void printLifterUsage(const char* executableName) {
std::cerr << "Usage: " << executableName << " <filename> <startAddr>"
<< std::endl;
}
inline bool parseStartAddressArg(const std::string& rawStartAddress,
uint64_t& outStartAddress) {
try {
size_t parsedLength = 0;
outStartAddress = stoull(rawStartAddress, &parsedLength, 0);
return parsedLength == rawStartAddress.size();
} catch (const std::exception& ex) {
std::cerr << "Failed to parse start address '" << rawStartAddress
<< "': " << ex.what() << std::endl;
return false;
}
}
inline bool readBinaryFile(const std::string& filename,
std::vector<uint8_t>& outFileData) {
std::ifstream ifs(filename, std::ios::binary | std::ios::ate);
if (!ifs.is_open()) {
std::cerr << "Failed to open file: " << filename << std::endl;
return false;
}
const std::streamsize fileSize = ifs.tellg();
if (fileSize <= 0) {
std::cerr << "Input file is empty or unreadable: " << filename << std::endl;
return false;
}
outFileData.resize(static_cast<size_t>(fileSize));
ifs.seekg(0, std::ios::beg);
if (!ifs.read(reinterpret_cast<char*>(outFileData.data()), fileSize)) {
std::cerr << "Failed to read file bytes: " << filename << std::endl;
return false;
}
return true;
}