|
|
@ -22,29 +22,28 @@ must not be misrepresented as being the original software.
|
|
|
|
distribution.
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "Internal.h"
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <md5wrapper.h>
|
|
|
|
#include "Error.h"
|
|
|
|
|
|
|
|
#include "Internal.h"
|
|
|
|
|
|
|
|
#include "md5wrapper.h"
|
|
|
|
#include "MemAccess.h"
|
|
|
|
#include "MemAccess.h"
|
|
|
|
#include "Memory.h"
|
|
|
|
#include "Memory.h"
|
|
|
|
#include "VersionInfoFactory.h"
|
|
|
|
#include "modules/Filesystem.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "Error.h"
|
|
|
|
#include "VersionInfoFactory.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
|
|
Process::Process(const VersionInfoFactory& known_versions) : identified(false), my_pe(0)
|
|
|
|
Process::Process(const VersionInfoFactory& known_versions) : identified(false), my_pe(0)
|
|
|
@ -181,28 +180,7 @@ uint32_t Process::getTickCount()
|
|
|
|
|
|
|
|
|
|
|
|
string Process::getPath()
|
|
|
|
string Process::getPath()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static string cached_path;
|
|
|
|
return Filesystem::get_initial_cwd();
|
|
|
|
if (cached_path.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *exe_name = "/proc/self/exe";
|
|
|
|
|
|
|
|
char exe_path[1024];
|
|
|
|
|
|
|
|
int length = readlink(exe_name, exe_path, sizeof(exe_path));
|
|
|
|
|
|
|
|
if (length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
exe_path[length] = '\0';
|
|
|
|
|
|
|
|
string path_string = exe_path;
|
|
|
|
|
|
|
|
// DF lives in libs, so move up a folder
|
|
|
|
|
|
|
|
cached_path = path_string.substr(0, path_string.find_last_of("/", path_string.find_last_of("/") - 1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
perror("readlink(/proc/self/exe) failed");
|
|
|
|
|
|
|
|
fprintf(stderr, " length=%i\n", length);
|
|
|
|
|
|
|
|
cached_path = ".";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "Resolved DF root to %s\n", cached_path.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cached_path;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Process::getPID()
|
|
|
|
int Process::getPID()
|
|
|
|