Merge remote-tracking branch 'suokko/dlsym_libgraphics' into develop

develop
lethosor 2018-07-10 12:24:13 -04:00
commit fa8c6724f6
7 changed files with 24 additions and 61 deletions

@ -53,6 +53,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Internals
- Added documentation for all RPC functions and a build-time check
- Use ``dlsym(3)`` to find vtables from libgraphics.so
## Structures
- Added ``start_dwarf_count`` on 64-bit Linux again and fixed scanning script

@ -1581,8 +1581,6 @@ std::string Core::getHackPath()
#endif
}
void init_screen_module(Core *);
bool Core::Init()
{
if(started)
@ -1729,7 +1727,6 @@ bool Core::Init()
*/
// initialize data defs
virtual_identity::Init(this);
init_screen_module(this);
// copy over default config files if necessary
std::vector<std::string> config_files;

@ -23,6 +23,7 @@
*/
namespace DFHack
{
DFLibrary* GLOBAL_NAMES = (DFLibrary*)RTLD_DEFAULT;
DFLibrary * OpenPlugin (const char * filename)
{
dlerror();

@ -41,6 +41,7 @@ distribution.
*/
namespace DFHack
{
DFLibrary* GLOBAL_NAMES = (DFLibrary*)GetModuleHandle(nullptr);
DFLibrary * OpenPlugin (const char * filename)
{
return (DFLibrary *) LoadLibrary(filename);

@ -35,6 +35,7 @@ using namespace std;
#include "VersionInfo.h"
#include "Error.h"
#include "Memory.h"
#include "PluginManager.h"
using namespace DFHack;
#include <tinyxml.h>
@ -133,18 +134,30 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
if(!cstr_key)
throw Error::SymbolsXmlUnderspecifiedEntry(cstr_name);
const char *cstr_value = pMemEntry->Attribute("value");
if(!cstr_value)
const char *cstr_mangled = pMemEntry->Attribute("mangled");
if(!cstr_value && !cstr_mangled)
{
cerr << "Dummy symbol table entry: " << cstr_key << endl;
continue;
}
if ((is_vtable && no_vtables) || (!is_vtable && no_globals))
continue;
#ifdef DFHACK64
uintptr_t addr = strtoull(cstr_value, 0, 0);
#else
uintptr_t addr = strtol(cstr_value, 0, 0);
#endif
uintptr_t addr;
if (cstr_value) {
if (sizeof(addr) == sizeof(unsigned long))
addr = strtoul(cstr_value, 0, 0);
else
addr = strtoull(cstr_value, 0, 0);
} else {
addr = (uintptr_t)DFHack::LookupPlugin(DFHack::GLOBAL_NAMES, cstr_mangled);
if (!addr)
continue;
const char *cstr_offset = pMemEntry->Attribute("offset");
if (cstr_offset) {
unsigned long offset = strtoul(cstr_offset, 0, 0);
addr += offset;
}
}
if (is_vtable)
mem->setVTable(cstr_key, addr);
else

@ -67,6 +67,8 @@ namespace DFHack
// anon type, pretty much
struct DFLibrary;
// DFLibrary* that can be used to resolve global names
extern DFLibrary* GLOBAL_NAMES;
// Open a plugin library
DFHACK_EXPORT DFLibrary * OpenPlugin (const char * filename);
// find a symbol inside plugin

@ -412,58 +412,6 @@ void Hide::merge(df::viewscreen* a)
}
} }
#ifdef _LINUX
class DFHACK_EXPORT renderer {
unsigned char *screen;
long *screentexpos;
char *screentexpos_addcolor;
unsigned char *screentexpos_grayscale;
unsigned char *screentexpos_cf;
unsigned char *screentexpos_cbr;
// For partial printing:
unsigned char *screen_old;
long *screentexpos_old;
char *screentexpos_addcolor_old;
unsigned char *screentexpos_grayscale_old;
unsigned char *screentexpos_cf_old;
unsigned char *screentexpos_cbr_old;
public:
virtual void update_tile(int x, int y) {};
virtual void update_all() {};
virtual void render() {};
virtual void set_fullscreen();
virtual void zoom(df::zoom_commands cmd);
virtual void resize(int w, int h) {};
virtual void grid_resize(int w, int h) {};
renderer() {
screen = NULL;
screentexpos = NULL;
screentexpos_addcolor = NULL;
screentexpos_grayscale = NULL;
screentexpos_cf = NULL;
screentexpos_cbr = NULL;
screen_old = NULL;
screentexpos_old = NULL;
screentexpos_addcolor_old = NULL;
screentexpos_grayscale_old = NULL;
screentexpos_cf_old = NULL;
screentexpos_cbr_old = NULL;
}
virtual ~renderer();
virtual bool get_mouse_coords(int &x, int &y) { return false; }
virtual bool uses_opengl();
};
#endif
void init_screen_module(Core *core)
{
#ifdef _LINUX
renderer tmp;
if (!strict_virtual_cast<df::renderer>((virtual_ptr)&tmp))
cerr << "Could not fetch the renderer vtable." << std::endl;
#endif
}
string Screen::getKeyDisplay(df::interface_key key)
{
if (enabler)