4
0
mirror of https://github.com/QuasarApp/pe-parse.git synced 2025-04-29 05:44:32 +00:00

Put all of peparse in the peparse namespace. ()

* Put all of peparse in the peparse namespace.
* Fixes dupicate symbol problems when using the library inside other applications, namely Python
* Closes 
This commit is contained in:
artemdinaburg 2017-03-03 14:41:14 -05:00 committed by GitHub
parent 6d1b49b74a
commit a8ccfb9df3
7 changed files with 16 additions and 0 deletions

@ -28,6 +28,7 @@ THE SOFTWARE.
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace peparse;
int printExps(void *N, VA funcAddr, std::string &mod, std::string &func) { int printExps(void *N, VA funcAddr, std::string &mod, std::string &func) {
cout << "EXP: "; cout << "EXP: ";

@ -38,6 +38,8 @@ THE SOFTWARE.
using namespace boost; using namespace boost;
using namespace std; using namespace std;
namespace peparse {
extern ::uint32_t err; extern ::uint32_t err;
extern ::string err_loc; extern ::string err_loc;
@ -266,3 +268,4 @@ void deleteBuffer(bounded_buffer *b) {
uint64_t bufLen(bounded_buffer *b) { uint64_t bufLen(bounded_buffer *b) {
return b->bufLen; return b->bufLen;
} }
} // namespace peparse

@ -31,6 +31,7 @@ THE SOFTWARE.
//need to pack these structure definitions //need to pack these structure definitions
//some constant definitions //some constant definitions
namespace peparse {
const boost::uint16_t MZ_MAGIC = 0x5A4D; const boost::uint16_t MZ_MAGIC = 0x5A4D;
const boost::uint32_t NT_MAGIC = 0x00004550; const boost::uint32_t NT_MAGIC = 0x00004550;
const boost::uint16_t NUM_DIR_ENTRIES = 16; const boost::uint16_t NUM_DIR_ENTRIES = 16;
@ -307,5 +308,6 @@ struct reloc_block {
boost::uint32_t PageRVA; boost::uint32_t PageRVA;
boost::uint32_t BlockSize; boost::uint32_t BlockSize;
}; };
} // namespace peparse
#endif #endif

@ -34,6 +34,8 @@ THE SOFTWARE.
using namespace std; using namespace std;
using namespace boost; using namespace boost;
namespace peparse {
struct section { struct section {
string sectionName; string sectionName;
::uint64_t sectionBase; ::uint64_t sectionBase;
@ -1489,3 +1491,4 @@ bool GetEntryPoint(parsed_pe *pe, VA &v) {
return false; return false;
} }
} // namespace peparse

@ -72,6 +72,8 @@ if(readDword(b, o+_offset(__typeof__(inst), member), inst.member) == false) { \
return NULL; \ return NULL; \
} }
namespace peparse {
typedef boost::uint32_t RVA; typedef boost::uint32_t RVA;
typedef boost::uint64_t VA; typedef boost::uint64_t VA;
@ -197,5 +199,6 @@ bool ReadByteAtVA(parsed_pe *pe, VA v, boost::uint8_t &b);
//get entry point into PE //get entry point into PE
bool GetEntryPoint(parsed_pe *pe, VA &v); bool GetEntryPoint(parsed_pe *pe, VA &v);
} // namespace peparse
#endif #endif

@ -2,6 +2,7 @@
#define _TO_STRING_H #define _TO_STRING_H
#include <sstream> #include <sstream>
namespace peparse {
template <class T> template <class T>
static static
std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)) { std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)) {
@ -9,4 +10,5 @@ std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)) {
oss << f << t; oss << f << t;
return oss.str(); return oss.str();
} }
}
#endif #endif

@ -29,6 +29,8 @@
#include <structmember.h> #include <structmember.h>
#include "parse.h" #include "parse.h"
using namespace peparse;
#define PEPY_VERSION "0.2" #define PEPY_VERSION "0.2"
/* These are used to across multiple objects. */ /* These are used to across multiple objects. */