mirror of
https://github.com/x64dbg/x64dbg.git
synced 2025-02-21 13:33:29 +00:00
Save module party
This commit is contained in:
parent
b683fc6a59
commit
e30a70ad4d
@ -71,6 +71,7 @@ void DbSave(DbLoadSaveType saveType, const char* dbfile, bool disablecompression
|
||||
EncodeMapCacheSave(root);
|
||||
TraceRecord.saveToDb(root);
|
||||
BpCacheSave(root);
|
||||
ModCacheSave(root);
|
||||
WatchCacheSave(root);
|
||||
|
||||
//save notes
|
||||
@ -283,6 +284,7 @@ void DbLoad(DbLoadSaveType loadType, const char* dbfile)
|
||||
EncodeMapCacheLoad(root);
|
||||
TraceRecord.loadFromDb(root);
|
||||
BpCacheLoad(root, migrateBreakpoints);
|
||||
ModCacheLoad(root);
|
||||
WatchCacheLoad(root);
|
||||
|
||||
// Load notes
|
||||
@ -340,6 +342,7 @@ void DbClear(bool terminating)
|
||||
EncodeMapClear();
|
||||
TraceRecord.clear();
|
||||
BpClear();
|
||||
ModCacheClear();
|
||||
WatchClear();
|
||||
GuiSetDebuggeeNotes("");
|
||||
|
||||
|
@ -701,6 +701,58 @@ static bool GetUnsafeModuleInfoImpl(MODINFO & Info, ULONG_PTR FileMapVA, void(*f
|
||||
return true;
|
||||
}
|
||||
|
||||
// User/system module
|
||||
static auto GetDefaultParty(const MODINFO & Info)
|
||||
{
|
||||
if(Info.isVirtual)
|
||||
return mod_user;
|
||||
// Determine whether the module is located in system
|
||||
wchar_t szWindowsDir[MAX_PATH];
|
||||
GetWindowsDirectoryW(szWindowsDir, _countof(szWindowsDir));
|
||||
String Utf8Sysdir = StringUtils::Utf16ToUtf8(szWindowsDir);
|
||||
Utf8Sysdir.append("\\");
|
||||
if(_memicmp(Utf8Sysdir.c_str(), Info.path, Utf8Sysdir.size()) == 0)
|
||||
{
|
||||
return mod_system;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mod_user;
|
||||
}
|
||||
}
|
||||
|
||||
struct MODULEPARTYINFO : AddrInfo
|
||||
{
|
||||
MODULEPARTY party;
|
||||
};
|
||||
|
||||
struct ModuleSerializer : AddrInfoSerializer<MODULEPARTYINFO>
|
||||
{
|
||||
bool Save(const MODULEPARTYINFO & value) override
|
||||
{
|
||||
setHex("hash", value.modhash);
|
||||
setInt("party", value.party);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Load(MODULEPARTYINFO & value) override
|
||||
{
|
||||
value.addr = 0;
|
||||
value.manual = true;
|
||||
return getHex("hash", value.modhash) && getInt("party", value.party);
|
||||
}
|
||||
};
|
||||
|
||||
struct ModulePartyInfo : AddrInfoHashMap<LockModuleHashes, MODULEPARTYINFO, ModuleSerializer>
|
||||
{
|
||||
const char* jsonKey() const override
|
||||
{
|
||||
return "modules";
|
||||
}
|
||||
};
|
||||
|
||||
static ModulePartyInfo modulePartyInfo;
|
||||
|
||||
void GetModuleInfo(MODINFO & Info, ULONG_PTR FileMapVA)
|
||||
{
|
||||
// Get the PE headers
|
||||
@ -840,23 +892,15 @@ bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols)
|
||||
info.fileMap = nullptr;
|
||||
info.fileMapVA = 0;
|
||||
|
||||
// Determine whether the module is located in system
|
||||
wchar_t szWindowsDir[MAX_PATH];
|
||||
GetWindowsDirectoryW(szWindowsDir, _countof(szWindowsDir));
|
||||
String Utf8Sysdir = StringUtils::Utf16ToUtf8(szWindowsDir);
|
||||
Utf8Sysdir.append("\\");
|
||||
if(_memicmp(Utf8Sysdir.c_str(), FullPath, Utf8Sysdir.size()) == 0)
|
||||
{
|
||||
info.party = mod_system;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.party = mod_user;
|
||||
}
|
||||
|
||||
// Load module data
|
||||
info.isVirtual = strstr(FullPath, "virtual:\\") == FullPath;
|
||||
|
||||
MODULEPARTYINFO modParty;
|
||||
if(modulePartyInfo.Get(info.hash, modParty))
|
||||
info.party = modParty.party;
|
||||
else
|
||||
info.party = GetDefaultParty(info);
|
||||
|
||||
if(!info.isVirtual)
|
||||
{
|
||||
auto wszFullPath = StringUtils::Utf8ToUtf16(FullPath);
|
||||
@ -1188,6 +1232,34 @@ void ModSetParty(duint Address, MODULEPARTY Party)
|
||||
return;
|
||||
|
||||
module->party = Party;
|
||||
|
||||
// DB
|
||||
MODULEPARTYINFO DBEntry;
|
||||
if(Party != GetDefaultParty(module[0])) // Save non-default party settings
|
||||
{
|
||||
DBEntry.addr = 0;
|
||||
DBEntry.modhash = module->hash;
|
||||
DBEntry.party = Party;
|
||||
DBEntry.manual = true;
|
||||
modulePartyInfo.Add(DBEntry);
|
||||
}
|
||||
else
|
||||
modulePartyInfo.Delete(module->hash); // Don't need to save the default party
|
||||
}
|
||||
|
||||
void ModCacheSave(JSON root)
|
||||
{
|
||||
modulePartyInfo.CacheSave(root);
|
||||
}
|
||||
|
||||
void ModCacheLoad(JSON root)
|
||||
{
|
||||
modulePartyInfo.CacheLoad(root);
|
||||
}
|
||||
|
||||
void ModCacheClear()
|
||||
{
|
||||
modulePartyInfo.Clear();
|
||||
}
|
||||
|
||||
bool ModRelocationsFromAddr(duint Address, std::vector<MODRELOCATIONINFO> & Relocations)
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define _MODULE_H
|
||||
|
||||
#include "_global.h"
|
||||
#include "jansson/jansson_x64dbg.h" // addrinfo.h and serializablemap.h use functions defined here so can't be included
|
||||
#include <functional>
|
||||
|
||||
#include "symbolsourcebase.h"
|
||||
@ -173,6 +174,9 @@ void ModEnum(const std::function<void(const MODINFO &)> & cbEnum);
|
||||
|
||||
MODULEPARTY ModGetParty(duint Address);
|
||||
void ModSetParty(duint Address, MODULEPARTY Party);
|
||||
void ModCacheSave(JSON root);
|
||||
void ModCacheLoad(JSON root);
|
||||
void ModCacheClear();
|
||||
bool ModRelocationsFromAddr(duint Address, std::vector<MODRELOCATIONINFO> & Relocations);
|
||||
bool ModRelocationAtAddr(duint Address, MODRELOCATIONINFO* Relocation);
|
||||
bool ModRelocationsInRange(duint Address, duint Size, std::vector<MODRELOCATIONINFO> & Relocations);
|
||||
|
Loading…
x
Reference in New Issue
Block a user