mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-28 13:24:32 +00:00
Remove some exceptions in Mach-O and ELF utils
This commit is contained in:
parent
4cb7ba46c7
commit
6b2ac0cc2a
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "LIEF/exception.hpp"
|
||||
#include "LIEF/logging++.hpp"
|
||||
|
||||
#include "LIEF/ELF/utils.hpp"
|
||||
#include "LIEF/ELF/Structures.hpp"
|
||||
@ -30,7 +31,8 @@ namespace ELF {
|
||||
bool is_elf(const std::string& file) {
|
||||
std::ifstream binary(file, std::ios::in | std::ios::binary);
|
||||
if (not binary) {
|
||||
throw bad_file("Unable to open the file");
|
||||
LOG(ERROR) << "Unable to open the file";
|
||||
return false;
|
||||
}
|
||||
char magic[sizeof(ElfMagic)];
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "LIEF/MachO/Structures.hpp"
|
||||
|
||||
#include "LIEF/exception.hpp"
|
||||
#include "LIEF/logging++.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
@ -30,7 +31,8 @@ namespace MachO {
|
||||
bool is_macho(const std::string& file) {
|
||||
std::ifstream binary(file, std::ios::in | std::ios::binary);
|
||||
if (not binary) {
|
||||
throw LIEF::bad_file("Unable to open the '" + file + "'");
|
||||
LOG(ERROR) << "Unable to open the '" << file << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
MACHO_TYPES magic;
|
||||
@ -76,13 +78,15 @@ bool is_macho(const std::vector<uint8_t>& raw) {
|
||||
|
||||
bool is_fat(const std::string& file) {
|
||||
if (not is_macho(file)) {
|
||||
throw LIEF::bad_format("'" + file + "' is not a MachO");
|
||||
LOG(ERROR) << "'" << file << "' is not a MachO";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream binary(file, std::ios::in | std::ios::binary);
|
||||
|
||||
if (not binary) {
|
||||
throw LIEF::bad_file("Unable to open the '" + file + "'");
|
||||
LOG(ERROR) << "Unable to open the '" << file << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
MACHO_TYPES magic;
|
||||
@ -100,13 +104,15 @@ bool is_fat(const std::string& file) {
|
||||
|
||||
bool is_64(const std::string& file) {
|
||||
if (not is_macho(file)) {
|
||||
throw LIEF::bad_format("'" + file + "' is not a MachO");
|
||||
LOG(ERROR) << "'" << file << "' is not a MachO";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream binary(file, std::ios::in | std::ios::binary);
|
||||
|
||||
if (not binary) {
|
||||
throw LIEF::bad_file("Unable to open the '" + file + "'");
|
||||
LOG(ERROR) << "Unable to open the '" << file << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
MACHO_TYPES magic;
|
||||
|
Loading…
x
Reference in New Issue
Block a user