|
|
@ -24,6 +24,7 @@ distribution.
|
|
|
|
|
|
|
|
|
|
|
|
#define DFhackCExport extern "C" __declspec(dllexport)
|
|
|
|
#define DFhackCExport extern "C" __declspec(dllexport)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NOMINMAX
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
@ -35,6 +36,7 @@ distribution.
|
|
|
|
|
|
|
|
|
|
|
|
#include "tinythread.h"
|
|
|
|
#include "tinythread.h"
|
|
|
|
#include "modules/Graphic.h"
|
|
|
|
#include "modules/Graphic.h"
|
|
|
|
|
|
|
|
#include "../plugins/uicommon.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Plugin loading functions
|
|
|
|
* Plugin loading functions
|
|
|
@ -44,7 +46,22 @@ namespace DFHack
|
|
|
|
DFLibrary* GLOBAL_NAMES = (DFLibrary*)GetModuleHandle(nullptr);
|
|
|
|
DFLibrary* GLOBAL_NAMES = (DFLibrary*)GetModuleHandle(nullptr);
|
|
|
|
DFLibrary * OpenPlugin (const char * filename)
|
|
|
|
DFLibrary * OpenPlugin (const char * filename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (DFLibrary *) LoadLibrary(filename);
|
|
|
|
DFLibrary *ret = (DFLibrary *) LoadLibrary(filename);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
|
|
|
|
DWORD error = GetLastError();
|
|
|
|
|
|
|
|
LPSTR buf = NULL;
|
|
|
|
|
|
|
|
DWORD len = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
|
|
|
|
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL);
|
|
|
|
|
|
|
|
if (len > 0) {
|
|
|
|
|
|
|
|
std::string message = buf;
|
|
|
|
|
|
|
|
std::cerr << "LoadLibrary " << filename << ": " << rtrim(message) << " (" << error << ")" << std::endl;
|
|
|
|
|
|
|
|
LocalFree(buf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
std::cerr << "LoadLibrary " << filename << ": unknown error " << error << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void * LookupPlugin (DFLibrary * plugin ,const char * function)
|
|
|
|
void * LookupPlugin (DFLibrary * plugin ,const char * function)
|
|
|
|
{
|
|
|
|
{
|
|
|
|