Put all of peparse in the peparse namespace. (#26)

* Put all of peparse in the peparse namespace.
* Fixes dupicate symbol problems when using the library inside other applications, namely Python
* Closes #25
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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,6 +72,8 @@ if(readDword(b, o+_offset(__typeof__(inst), member), inst.member) == false) { \
return NULL; \
}
namespace peparse {
typedef boost::uint32_t RVA;
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
bool GetEntryPoint(parsed_pe *pe, VA &v);
} // namespace peparse
#endif

View File

@ -2,6 +2,7 @@
#define _TO_STRING_H
#include <sstream>
namespace peparse {
template <class T>
static
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;
return oss.str();
}
}
#endif

View File

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