Fix (for win64) and avoid duplicating base address

develop
lethosor 2016-07-27 20:10:03 -04:00
parent 50144b60ea
commit ddd56d7825
5 changed files with 30 additions and 9 deletions

@ -41,6 +41,7 @@ using namespace std;
#include <md5wrapper.h>
#include "MemAccess.h"
#include "Memory.h"
#include "VersionInfoFactory.h"
#include "VersionInfo.h"
#include "Error.h"
@ -241,7 +242,7 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
uintptr_t Process::getBase()
{
return 0x1000;
return DEFAULT_BASE_ADDR; // Memory.h
}
int Process::adjustOffset(int offset, bool /*to_file*/)

@ -39,6 +39,7 @@ using namespace std;
#include <md5wrapper.h>
#include "MemAccess.h"
#include "Memory.h"
#include "VersionInfoFactory.h"
#include "VersionInfo.h"
#include "Error.h"
@ -167,7 +168,7 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
uintptr_t Process::getBase()
{
return 0x8048000;
return DEFAULT_BASE_ADDR; // Memory.h
}
int Process::adjustOffset(int offset, bool /*to_file*/)

@ -43,6 +43,7 @@ using namespace std;
#include "VersionInfoFactory.h"
#include "Error.h"
#include "MemAccess.h"
#include "Memory.h"
using namespace DFHack;
namespace DFHack
{
@ -306,7 +307,7 @@ uintptr_t Process::getBase()
{
if(d)
return (uintptr_t) d->base;
return 0x400000;
return DEFAULT_BASE_ADDR; // Memory.h
}
int Process::adjustOffset(int offset, bool to_file)

@ -34,6 +34,7 @@ using namespace std;
#include "VersionInfoFactory.h"
#include "VersionInfo.h"
#include "Error.h"
#include "Memory.h"
using namespace DFHack;
#include <tinyxml.h>
@ -98,25 +99,20 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
if(os == "windows")
{
mem->setOS(OS_WINDOWS);
// set default image base. this is fixed for base relocation later
mem->setBase(0x400000);
}
else if(os == "linux")
{
mem->setOS(OS_LINUX);
// this is wrong... I'm not going to do base image relocation on linux though.
mem->setBase(0x8048000);
}
else if(os == "darwin")
{
mem->setOS(OS_APPLE);
// this is wrong... I'm not going to do base image relocation on linux though.
mem->setBase(0x1000);
}
else
{
return; // ignore it if it's invalid
}
mem->setBase(DEFAULT_BASE_ADDR); // Memory.h
// process additional entries
//cout << "Entry " << cstr_version << " " << cstr_os << endl;

@ -0,0 +1,22 @@
// Default base address
#if defined(_WIN32)
#ifdef DFHACK64
#define DEFAULT_BASE_ADDR 0x140000000
#else
#define DEFAULT_BASE_ADDR 0x400000
#endif
#elif defined(_DARWIN)
#ifdef DFHACK64
#define DEFAULT_BASE_ADDR 0x1000
#else
#define DEFAULT_BASE_ADDR 0x1000
#endif
#elif defined(_LINUX)
#ifdef DFHACK64
#define DEFAULT_BASE_ADDR 0x8048000
#else
#define DEFAULT_BASE_ADDR 0x8048000
#endif
#else
#error Unknown OS
#endif