1
0
Fork 0

DBG: resolved issue #221 (crashes because of race conditions)

This commit is contained in:
Mr. eXoDia 2014-12-09 01:29:08 +01:00
parent 4d469f3742
commit a883544e52
7 changed files with 120 additions and 14 deletions

View File

@ -94,11 +94,21 @@ void dbload()
void dbclose()
{
dbsave();
CriticalSectionLocker commentLocker(LockComments);
CommentsInfo().swap(comments);
CriticalSectionLocker labelLocker(LockLabels);
LabelsInfo().swap(labels);
CriticalSectionLocker bookmarkLocker(LockBookmarks);
BookmarksInfo().swap(bookmarks);
CriticalSectionLocker functionLocker(LockFunctions);
FunctionsInfo().swap(functions);
CriticalSectionLocker loopLocker(LockLoops);
LoopsInfo().swap(loops);
bpclear();
patchclear();
}
@ -201,6 +211,7 @@ bool modload(uint base, uint size, const char* fullpath)
}
//add module to list
CriticalSectionLocker locker(LockModules);
modinfo.insert(std::make_pair(Range(base, base + size - 1), info));
symupdatemodulelist();
return true;
@ -208,6 +219,7 @@ bool modload(uint base, uint size, const char* fullpath)
bool modunload(uint base)
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(base, base));
if(found == modinfo.end()) //not found
return false;
@ -218,6 +230,7 @@ bool modunload(uint base)
void modclear()
{
CriticalSectionLocker locker(LockModules);
ModulesInfo().swap(modinfo);
symupdatemodulelist();
}
@ -227,6 +240,7 @@ bool modnamefromaddr(uint addr, char* modname, bool extension)
if(!modname)
return false;
*modname = '\0';
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return false;
@ -238,6 +252,7 @@ bool modnamefromaddr(uint addr, char* modname, bool extension)
uint modbasefromaddr(uint addr)
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return 0;
@ -246,6 +261,7 @@ uint modbasefromaddr(uint addr)
uint modhashfromva(uint va) //return a unique hash from a VA
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(va, va));
if(found == modinfo.end()) //not found
return va;
@ -264,6 +280,7 @@ uint modbasefromname(const char* modname)
{
if(!modname or strlen(modname) >= MAX_MODULE_SIZE)
return 0;
CriticalSectionLocker locker(LockModules);
for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i)
{
MODINFO* curMod = &i->second;
@ -279,6 +296,7 @@ uint modbasefromname(const char* modname)
uint modsizefromaddr(uint addr)
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return 0;
@ -287,6 +305,7 @@ uint modsizefromaddr(uint addr)
bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return false;
@ -296,6 +315,7 @@ bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
uint modentryfromaddr(uint addr)
{
CriticalSectionLocker locker(LockModules);
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
if(found == modinfo.end()) //not found
return 0;
@ -390,6 +410,7 @@ bool commentset(uint addr, const char* text, bool manual)
modnamefromaddr(addr, comment.mod, true);
comment.addr = addr - modbasefromaddr(addr);
const uint key = modhashfromva(addr);
CriticalSectionLocker locker(LockComments);
if(!comments.insert(std::make_pair(key, comment)).second) //key already present
comments[key] = comment;
return true;
@ -399,6 +420,7 @@ bool commentget(uint addr, char* text)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockComments);
const CommentsInfo::iterator found = comments.find(modhashfromva(addr));
if(found == comments.end()) //not found
return false;
@ -410,6 +432,7 @@ bool commentdel(uint addr)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockComments);
return (comments.erase(modhashfromva(addr)) == 1);
}
@ -423,6 +446,7 @@ void commentdelrange(uint start, uint end)
return;
start -= modbase;
end -= modbase;
CriticalSectionLocker locker(LockComments);
CommentsInfo::iterator i = comments.begin();
while(i != comments.end())
{
@ -440,6 +464,7 @@ void commentdelrange(uint start, uint end)
void commentcachesave(JSON root)
{
CriticalSectionLocker locker(LockComments);
const JSON jsoncomments = json_array();
const JSON jsonautocomments = json_array();
for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i)
@ -464,6 +489,7 @@ void commentcachesave(JSON root)
void commentcacheload(JSON root)
{
CriticalSectionLocker locker(LockComments);
comments.clear();
const JSON jsoncomments = json_object_get(root, "comments");
if(jsoncomments)
@ -521,6 +547,7 @@ bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize)
return false;
if(!commentlist && !cbsize)
return false;
CriticalSectionLocker locker(LockComments);
if(!commentlist && cbsize)
{
*cbsize = comments.size() * sizeof(COMMENTSINFO);
@ -551,6 +578,7 @@ bool labelset(uint addr, const char* text, bool manual)
modnamefromaddr(addr, label.mod, true);
label.addr = addr - modbasefromaddr(addr);
uint key = modhashfromva(addr);
CriticalSectionLocker locker(LockLabels);
if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present
labels[key] = label;
return true;
@ -560,6 +588,7 @@ bool labelfromstring(const char* text, uint* addr)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockLabels);
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
{
if(!strcmp(i->second.text, text))
@ -576,6 +605,7 @@ bool labelget(uint addr, char* text)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockLabels);
const LabelsInfo::iterator found = labels.find(modhashfromva(addr));
if(found == labels.end()) //not found
return false;
@ -588,6 +618,7 @@ bool labeldel(uint addr)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockLabels);
return (labels.erase(modhashfromva(addr)) > 0);
}
@ -601,6 +632,7 @@ void labeldelrange(uint start, uint end)
return;
start -= modbase;
end -= modbase;
CriticalSectionLocker locker(LockLabels);
LabelsInfo::iterator i = labels.begin();
while(i != labels.end())
{
@ -618,6 +650,7 @@ void labeldelrange(uint start, uint end)
void labelcachesave(JSON root)
{
CriticalSectionLocker locker(LockLabels);
const JSON jsonlabels = json_array();
const JSON jsonautolabels = json_array();
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
@ -642,6 +675,7 @@ void labelcachesave(JSON root)
void labelcacheload(JSON root)
{
CriticalSectionLocker locker(LockLabels);
labels.clear();
const JSON jsonlabels = json_object_get(root, "labels");
if(jsonlabels)
@ -703,6 +737,7 @@ bool labelenum(LABELSINFO* labellist, size_t* cbsize)
return false;
if(!labellist && !cbsize)
return false;
CriticalSectionLocker locker(LockLabels);
if(!labellist && cbsize)
{
*cbsize = labels.size() * sizeof(LABELSINFO);
@ -726,6 +761,7 @@ bool bookmarkset(uint addr, bool manual)
modnamefromaddr(addr, bookmark.mod, true);
bookmark.addr = addr - modbasefromaddr(addr);
bookmark.manual = manual;
CriticalSectionLocker locker(LockBookmarks);
if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second)
return bookmarkdel(addr);
return true;
@ -735,6 +771,7 @@ bool bookmarkget(uint addr)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBookmarks);
if(bookmarks.count(modhashfromva(addr)))
return true;
return false;
@ -744,6 +781,7 @@ bool bookmarkdel(uint addr)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBookmarks);
return (bookmarks.erase(modhashfromva(addr)) > 0);
}
@ -757,6 +795,7 @@ void bookmarkdelrange(uint start, uint end)
return;
start -= modbase;
end -= modbase;
CriticalSectionLocker locker(LockBookmarks);
BookmarksInfo::iterator i = bookmarks.begin();
while(i != bookmarks.end())
{
@ -774,6 +813,7 @@ void bookmarkdelrange(uint start, uint end)
void bookmarkcachesave(JSON root)
{
CriticalSectionLocker locker(LockBookmarks);
const JSON jsonbookmarks = json_array();
const JSON jsonautobookmarks = json_array();
for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i)
@ -797,6 +837,7 @@ void bookmarkcachesave(JSON root)
void bookmarkcacheload(JSON root)
{
CriticalSectionLocker locker(LockBookmarks);
bookmarks.clear();
const JSON jsonbookmarks = json_object_get(root, "bookmarks");
if(jsonbookmarks)
@ -844,6 +885,7 @@ bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize)
return false;
if(!bookmarklist && !cbsize)
return false;
CriticalSectionLocker locker(LockBookmarks);
if(!bookmarklist && cbsize)
{
*cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO);
@ -873,6 +915,7 @@ bool functionadd(uint start, uint end, bool manual)
function.start = start - modbase;
function.end = end - modbase;
function.manual = manual;
CriticalSectionLocker locker(LockFunctions);
functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function));
return true;
}
@ -882,6 +925,7 @@ bool functionget(uint addr, uint* start, uint* end)
if(!DbgIsDebugging())
return false;
uint modbase = modbasefromaddr(addr);
CriticalSectionLocker locker(LockFunctions);
const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)));
if(found == functions.end()) //not found
return false;
@ -897,6 +941,7 @@ bool functionoverlaps(uint start, uint end)
if(!DbgIsDebugging() or end < start)
return false;
const uint modbase = modbasefromaddr(start);
CriticalSectionLocker locker(LockFunctions);
return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0);
}
@ -905,6 +950,7 @@ bool functiondel(uint addr)
if(!DbgIsDebugging())
return false;
const uint modbase = modbasefromaddr(addr);
CriticalSectionLocker locker(LockFunctions);
return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0);
}
@ -918,6 +964,7 @@ void functiondelrange(uint start, uint end)
return;
start -= modbase;
end -= modbase;
CriticalSectionLocker locker(LockFunctions);
FunctionsInfo::iterator i = functions.begin();
while(i != functions.end())
{
@ -935,6 +982,7 @@ void functiondelrange(uint start, uint end)
void functioncachesave(JSON root)
{
CriticalSectionLocker locker(LockFunctions);
const JSON jsonfunctions = json_array();
const JSON jsonautofunctions = json_array();
for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i)
@ -959,6 +1007,7 @@ void functioncachesave(JSON root)
void functioncacheload(JSON root)
{
CriticalSectionLocker locker(LockFunctions);
functions.clear();
const JSON jsonfunctions = json_object_get(root, "functions");
if(jsonfunctions)
@ -1012,6 +1061,7 @@ bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize)
return false;
if(!functionlist && !cbsize)
return false;
CriticalSectionLocker locker(LockFunctions);
if(!functionlist && cbsize)
{
*cbsize = functions.size() * sizeof(FUNCTIONSINFO);
@ -1049,6 +1099,7 @@ bool loopadd(uint start, uint end, bool manual)
else
loop.parent = 0;
loop.manual = manual;
CriticalSectionLocker locker(LockLoops);
loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop));
return true;
}
@ -1059,6 +1110,7 @@ bool loopget(int depth, uint addr, uint* start, uint* end)
if(!DbgIsDebugging())
return false;
const uint modbase = modbasefromaddr(addr);
CriticalSectionLocker locker(LockLoops);
LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))));
if(found == loops.end()) //not found
return false;
@ -1080,6 +1132,8 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth)
uint curEnd = end - modbase;
const uint key = modhashfromva(modbase);
CriticalSectionLocker locker(LockLoops);
//check if the new loop fits in the old loop
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
{
@ -1113,6 +1167,7 @@ bool loopdel(int depth, uint addr)
void loopcachesave(JSON root)
{
CriticalSectionLocker locker(LockLoops);
const JSON jsonloops = json_array();
const JSON jsonautoloops = json_array();
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
@ -1139,6 +1194,7 @@ void loopcachesave(JSON root)
void loopcacheload(JSON root)
{
CriticalSectionLocker locker(LockLoops);
loops.clear();
const JSON jsonloops = json_object_get(root, "loops");
if(jsonloops)
@ -1194,6 +1250,7 @@ bool loopenum(LOOPSINFO* looplist, size_t* cbsize)
return false;
if(!looplist && !cbsize)
return false;
CriticalSectionLocker locker(LockLoops);
if(!looplist && cbsize)
{
*cbsize = loops.size() * sizeof(LOOPSINFO);

View File

@ -13,6 +13,7 @@ int bpgetlist(std::vector<BREAKPOINT>* list)
return false;
BREAKPOINT curBp;
int count = 0;
CriticalSectionLocker locker(LockBreakpoints);
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
curBp = i->second;
@ -43,6 +44,7 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty
bp.singleshoot = singleshoot;
bp.titantype = titantype;
bp.type = type;
CriticalSectionLocker locker(LockBreakpoints);
breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp));
return true;
}
@ -52,6 +54,7 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
if(!DbgIsDebugging())
return false;
BREAKPOINT curBp;
CriticalSectionLocker locker(LockBreakpoints);
if(!name)
{
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
@ -89,6 +92,7 @@ bool bpdel(uint addr, BP_TYPE type)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
}
@ -96,6 +100,7 @@ bool bpenable(uint addr, BP_TYPE type, bool enable)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
@ -107,6 +112,7 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
{
if(!DbgIsDebugging() or !name or !*name)
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
@ -118,6 +124,7 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
if(found == breakpoints.end()) //not found
return false;
@ -131,6 +138,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
return false;
bool retval = true;
BREAKPOINT curBp;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator i = breakpoints.begin();
while(i != breakpoints.end())
{
@ -164,6 +172,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum)
int bpgetcount(BP_TYPE type, bool enabledonly)
{
int count = 0;
CriticalSectionLocker locker(LockBreakpoints);
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
if(i->first.first == type && (!enabledonly || i->second.enabled))
@ -202,6 +211,7 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
void bpcachesave(JSON root)
{
CriticalSectionLocker locker(LockBreakpoints);
const JSON jsonbreakpoints = json_array();
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
@ -226,6 +236,7 @@ void bpcachesave(JSON root)
void bpcacheload(JSON root)
{
CriticalSectionLocker locker(LockBreakpoints);
breakpoints.clear();
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
if(jsonbreakpoints)
@ -256,5 +267,6 @@ void bpcacheload(JSON root)
void bpclear()
{
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo().swap(breakpoints);
}

View File

@ -3,8 +3,9 @@
#include "memory.h"
#include "debugger.h"
#include "console.h"
#include "threading.h"
PatchesInfo patches;
static PatchesInfo patches;
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
{
@ -18,6 +19,7 @@ bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
newPatch.oldbyte = oldbyte;
newPatch.newbyte = newbyte;
uint key = modhashfromva(addr);
CriticalSectionLocker locker(LockPatches);
PatchesInfo::iterator found = patches.find(key);
if(found != patches.end()) //we found a patch on the specified address
{
@ -41,6 +43,7 @@ bool patchget(uint addr, PATCHINFO* patch)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockPatches);
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
if(found == patches.end()) //not found
return false;
@ -57,6 +60,7 @@ bool patchdel(uint addr, bool restore)
{
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockPatches);
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
if(found == patches.end()) //not found
return false;
@ -76,6 +80,7 @@ void patchdelrange(uint start, uint end, bool restore)
return;
start -= modbase;
end -= modbase;
CriticalSectionLocker locker(LockPatches);
PatchesInfo::iterator i = patches.begin();
while(i != patches.end())
{
@ -92,6 +97,7 @@ void patchdelrange(uint start, uint end, bool restore)
void patchclear(const char* mod)
{
CriticalSectionLocker locker(LockPatches);
if(!mod or !*mod)
patches.clear();
else
@ -113,6 +119,7 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
return false;
if(!patcheslist && !cbsize)
return false;
CriticalSectionLocker locker(LockPatches);
if(!patcheslist && cbsize)
{
*cbsize = patches.size() * sizeof(LOOPSINFO);

View File

@ -2,6 +2,7 @@
#include "console.h"
#include "undocumented.h"
#include "memory.h"
#include "threading.h"
static std::vector<THREADINFO> threadList;
static int threadNum;
@ -18,26 +19,32 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
*curInfo.threadName = '\0';
if(!threadNum)
strcpy(curInfo.threadName, "Main Thread");
CriticalSectionLocker locker(LockThreads);
threadList.push_back(curInfo);
threadNum++;
locker.unlock(); //prevent possible deadlocks
GuiUpdateThreadView();
}
void threadexit(DWORD dwThreadId)
{
CriticalSectionLocker locker(LockThreads);
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
{
threadList.erase(threadList.begin() + i);
break;
}
locker.unlock(); //prevent possible deadlocks
GuiUpdateThreadView();
}
void threadclear()
{
threadNum = 0;
CriticalSectionLocker locker(LockThreads);
std::vector<THREADINFO>().swap(threadList);
locker.unlock(); //prevent possible deadlocks
GuiUpdateThreadView();
}
@ -57,6 +64,7 @@ static DWORD GetThreadLastError(uint tebAddress)
void threadgetlist(THREADLIST* list)
{
CriticalSectionLocker locker(LockThreads);
int count = (int)threadList.size();
list->count = count;
if(!count)
@ -81,6 +89,7 @@ void threadgetlist(THREADLIST* list)
bool threadisvalid(DWORD dwThreadId)
{
CriticalSectionLocker locker(LockThreads);
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
return true;
@ -89,6 +98,7 @@ bool threadisvalid(DWORD dwThreadId)
bool threadsetname(DWORD dwThreadId, const char* name)
{
CriticalSectionLocker locker(LockThreads);
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
{
@ -102,6 +112,7 @@ bool threadsetname(DWORD dwThreadId, const char* name)
HANDLE threadgethandle(DWORD dwThreadId)
{
CriticalSectionLocker locker(LockThreads);
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).dwThreadId == dwThreadId)
return threadList.at(i).hThread;
@ -110,6 +121,7 @@ HANDLE threadgethandle(DWORD dwThreadId)
DWORD threadgetid(HANDLE hThread)
{
CriticalSectionLocker locker(LockThreads);
for(unsigned int i = 0; i < threadList.size(); i++)
if(threadList.at(i).hThread == hThread)
return threadList.at(i).dwThreadId;

View File

@ -21,6 +21,16 @@ bool waitislocked(WAIT_ID id);
enum CriticalSectionLock
{
LockMemoryPages,
LockVariables,
LockModules,
LockComments,
LockLabels,
LockBookmarks,
LockFunctions,
LockLoops,
LockBreakpoints,
LockPatches,
LockThreads,
LockLast
};

View File

@ -1,4 +1,5 @@
#include "variable.h"
#include "threading.h"
static VariableMap variables;
static VAR* vars;
@ -19,6 +20,7 @@ static void varsetvalue(VAR* var, VAR_VALUE* value)
static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
{
CriticalSectionLocker locker(LockVariables);
String name_;
if(*name != '$')
name_ = "$";
@ -36,7 +38,7 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
void varinit()
{
variables.clear();
varfree();
//General variables
varnew("$result\1$res", 0, VAR_SYSTEM);
varnew("$result1\1$res1", 0, VAR_SYSTEM);
@ -56,6 +58,7 @@ void varinit()
void varfree()
{
CriticalSectionLocker locker(LockVariables);
variables.clear();
}
@ -66,6 +69,7 @@ VAR* vargetptr()
bool varnew(const char* name, uint value, VAR_TYPE type)
{
CriticalSectionLocker locker(LockVariables);
if(!name)
return false;
std::vector<String> names = StringUtils::Split(name, '\1');
@ -96,6 +100,7 @@ bool varnew(const char* name, uint value, VAR_TYPE type)
static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type)
{
CriticalSectionLocker locker(LockVariables);
String name_;
if(*name != '$')
name_ = "$";
@ -179,6 +184,7 @@ bool varset(const char* name, const char* string, bool setreadonly)
bool vardel(const char* name, bool delsystem)
{
CriticalSectionLocker locker(LockVariables);
String name_;
if(*name != '$')
name_ = "$";
@ -203,6 +209,7 @@ bool vardel(const char* name, bool delsystem)
bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
{
CriticalSectionLocker locker(LockVariables);
String name_;
if(*name != '$')
name_ = "$";
@ -221,6 +228,7 @@ bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
bool varenum(VAR* entries, size_t* cbsize)
{
CriticalSectionLocker locker(LockVariables);
if(!entries && !cbsize || !variables.size())
return false;
if(!entries && cbsize)

View File

@ -99,12 +99,6 @@
<ClCompile Include="math.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="murmurhash.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="msgqueue.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="threading.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
@ -168,6 +162,12 @@
<ClCompile Include="stringutils.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="murmurhash.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="msgqueue.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="x64_dbg.h">
@ -227,9 +227,6 @@
<ClInclude Include="math.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
<ClInclude Include="msgqueue.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
<ClInclude Include="threading.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
@ -242,9 +239,6 @@
<ClInclude Include="plugin_loader.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
<ClInclude Include="murmurhash.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
<ClInclude Include="debugger.h">
<Filter>Header Files\Debugger Core</Filter>
</ClInclude>
@ -317,5 +311,11 @@
<ClInclude Include="stringutils.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
<ClInclude Include="murmurhash.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
<ClInclude Include="msgqueue.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
</ItemGroup>
</Project>