DBG: resolved issue #221 (crashes because of race conditions)
This commit is contained in:
parent
4d469f3742
commit
a883544e52
|
@ -94,11 +94,21 @@ void dbload()
|
||||||
void dbclose()
|
void dbclose()
|
||||||
{
|
{
|
||||||
dbsave();
|
dbsave();
|
||||||
|
CriticalSectionLocker commentLocker(LockComments);
|
||||||
CommentsInfo().swap(comments);
|
CommentsInfo().swap(comments);
|
||||||
|
|
||||||
|
CriticalSectionLocker labelLocker(LockLabels);
|
||||||
LabelsInfo().swap(labels);
|
LabelsInfo().swap(labels);
|
||||||
|
|
||||||
|
CriticalSectionLocker bookmarkLocker(LockBookmarks);
|
||||||
BookmarksInfo().swap(bookmarks);
|
BookmarksInfo().swap(bookmarks);
|
||||||
|
|
||||||
|
CriticalSectionLocker functionLocker(LockFunctions);
|
||||||
FunctionsInfo().swap(functions);
|
FunctionsInfo().swap(functions);
|
||||||
|
|
||||||
|
CriticalSectionLocker loopLocker(LockLoops);
|
||||||
LoopsInfo().swap(loops);
|
LoopsInfo().swap(loops);
|
||||||
|
|
||||||
bpclear();
|
bpclear();
|
||||||
patchclear();
|
patchclear();
|
||||||
}
|
}
|
||||||
|
@ -201,6 +211,7 @@ bool modload(uint base, uint size, const char* fullpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
//add module to list
|
//add module to list
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
modinfo.insert(std::make_pair(Range(base, base + size - 1), info));
|
modinfo.insert(std::make_pair(Range(base, base + size - 1), info));
|
||||||
symupdatemodulelist();
|
symupdatemodulelist();
|
||||||
return true;
|
return true;
|
||||||
|
@ -208,6 +219,7 @@ bool modload(uint base, uint size, const char* fullpath)
|
||||||
|
|
||||||
bool modunload(uint base)
|
bool modunload(uint base)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(base, base));
|
const ModulesInfo::iterator found = modinfo.find(Range(base, base));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -218,6 +230,7 @@ bool modunload(uint base)
|
||||||
|
|
||||||
void modclear()
|
void modclear()
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
ModulesInfo().swap(modinfo);
|
ModulesInfo().swap(modinfo);
|
||||||
symupdatemodulelist();
|
symupdatemodulelist();
|
||||||
}
|
}
|
||||||
|
@ -227,6 +240,7 @@ bool modnamefromaddr(uint addr, char* modname, bool extension)
|
||||||
if(!modname)
|
if(!modname)
|
||||||
return false;
|
return false;
|
||||||
*modname = '\0';
|
*modname = '\0';
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -238,6 +252,7 @@ bool modnamefromaddr(uint addr, char* modname, bool extension)
|
||||||
|
|
||||||
uint modbasefromaddr(uint addr)
|
uint modbasefromaddr(uint addr)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -246,6 +261,7 @@ uint modbasefromaddr(uint addr)
|
||||||
|
|
||||||
uint modhashfromva(uint va) //return a unique hash from a VA
|
uint modhashfromva(uint va) //return a unique hash from a VA
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(va, va));
|
const ModulesInfo::iterator found = modinfo.find(Range(va, va));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return va;
|
return va;
|
||||||
|
@ -264,6 +280,7 @@ uint modbasefromname(const char* modname)
|
||||||
{
|
{
|
||||||
if(!modname or strlen(modname) >= MAX_MODULE_SIZE)
|
if(!modname or strlen(modname) >= MAX_MODULE_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i)
|
for(ModulesInfo::iterator i = modinfo.begin(); i != modinfo.end(); ++i)
|
||||||
{
|
{
|
||||||
MODINFO* curMod = &i->second;
|
MODINFO* curMod = &i->second;
|
||||||
|
@ -279,6 +296,7 @@ uint modbasefromname(const char* modname)
|
||||||
|
|
||||||
uint modsizefromaddr(uint addr)
|
uint modsizefromaddr(uint addr)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -287,6 +305,7 @@ uint modsizefromaddr(uint addr)
|
||||||
|
|
||||||
bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
|
bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -296,6 +315,7 @@ bool modsectionsfromaddr(uint addr, std::vector<MODSECTIONINFO>* sections)
|
||||||
|
|
||||||
uint modentryfromaddr(uint addr)
|
uint modentryfromaddr(uint addr)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockModules);
|
||||||
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
const ModulesInfo::iterator found = modinfo.find(Range(addr, addr));
|
||||||
if(found == modinfo.end()) //not found
|
if(found == modinfo.end()) //not found
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -390,6 +410,7 @@ bool commentset(uint addr, const char* text, bool manual)
|
||||||
modnamefromaddr(addr, comment.mod, true);
|
modnamefromaddr(addr, comment.mod, true);
|
||||||
comment.addr = addr - modbasefromaddr(addr);
|
comment.addr = addr - modbasefromaddr(addr);
|
||||||
const uint key = modhashfromva(addr);
|
const uint key = modhashfromva(addr);
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
if(!comments.insert(std::make_pair(key, comment)).second) //key already present
|
if(!comments.insert(std::make_pair(key, comment)).second) //key already present
|
||||||
comments[key] = comment;
|
comments[key] = comment;
|
||||||
return true;
|
return true;
|
||||||
|
@ -399,6 +420,7 @@ bool commentget(uint addr, char* text)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
const CommentsInfo::iterator found = comments.find(modhashfromva(addr));
|
const CommentsInfo::iterator found = comments.find(modhashfromva(addr));
|
||||||
if(found == comments.end()) //not found
|
if(found == comments.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -410,6 +432,7 @@ bool commentdel(uint addr)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
return (comments.erase(modhashfromva(addr)) == 1);
|
return (comments.erase(modhashfromva(addr)) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,6 +446,7 @@ void commentdelrange(uint start, uint end)
|
||||||
return;
|
return;
|
||||||
start -= modbase;
|
start -= modbase;
|
||||||
end -= modbase;
|
end -= modbase;
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
CommentsInfo::iterator i = comments.begin();
|
CommentsInfo::iterator i = comments.begin();
|
||||||
while(i != comments.end())
|
while(i != comments.end())
|
||||||
{
|
{
|
||||||
|
@ -440,6 +464,7 @@ void commentdelrange(uint start, uint end)
|
||||||
|
|
||||||
void commentcachesave(JSON root)
|
void commentcachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
const JSON jsoncomments = json_array();
|
const JSON jsoncomments = json_array();
|
||||||
const JSON jsonautocomments = json_array();
|
const JSON jsonautocomments = json_array();
|
||||||
for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i)
|
for(CommentsInfo::iterator i = comments.begin(); i != comments.end(); ++i)
|
||||||
|
@ -464,6 +489,7 @@ void commentcachesave(JSON root)
|
||||||
|
|
||||||
void commentcacheload(JSON root)
|
void commentcacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
comments.clear();
|
comments.clear();
|
||||||
const JSON jsoncomments = json_object_get(root, "comments");
|
const JSON jsoncomments = json_object_get(root, "comments");
|
||||||
if(jsoncomments)
|
if(jsoncomments)
|
||||||
|
@ -521,6 +547,7 @@ bool commentenum(COMMENTSINFO* commentlist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!commentlist && !cbsize)
|
if(!commentlist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockComments);
|
||||||
if(!commentlist && cbsize)
|
if(!commentlist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = comments.size() * sizeof(COMMENTSINFO);
|
*cbsize = comments.size() * sizeof(COMMENTSINFO);
|
||||||
|
@ -551,6 +578,7 @@ bool labelset(uint addr, const char* text, bool manual)
|
||||||
modnamefromaddr(addr, label.mod, true);
|
modnamefromaddr(addr, label.mod, true);
|
||||||
label.addr = addr - modbasefromaddr(addr);
|
label.addr = addr - modbasefromaddr(addr);
|
||||||
uint key = modhashfromva(addr);
|
uint key = modhashfromva(addr);
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present
|
if(!labels.insert(std::make_pair(modhashfromva(key), label)).second) //already present
|
||||||
labels[key] = label;
|
labels[key] = label;
|
||||||
return true;
|
return true;
|
||||||
|
@ -560,6 +588,7 @@ bool labelfromstring(const char* text, uint* addr)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
|
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
|
||||||
{
|
{
|
||||||
if(!strcmp(i->second.text, text))
|
if(!strcmp(i->second.text, text))
|
||||||
|
@ -576,6 +605,7 @@ bool labelget(uint addr, char* text)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
const LabelsInfo::iterator found = labels.find(modhashfromva(addr));
|
const LabelsInfo::iterator found = labels.find(modhashfromva(addr));
|
||||||
if(found == labels.end()) //not found
|
if(found == labels.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -588,6 +618,7 @@ bool labeldel(uint addr)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
return (labels.erase(modhashfromva(addr)) > 0);
|
return (labels.erase(modhashfromva(addr)) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,6 +632,7 @@ void labeldelrange(uint start, uint end)
|
||||||
return;
|
return;
|
||||||
start -= modbase;
|
start -= modbase;
|
||||||
end -= modbase;
|
end -= modbase;
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
LabelsInfo::iterator i = labels.begin();
|
LabelsInfo::iterator i = labels.begin();
|
||||||
while(i != labels.end())
|
while(i != labels.end())
|
||||||
{
|
{
|
||||||
|
@ -618,6 +650,7 @@ void labeldelrange(uint start, uint end)
|
||||||
|
|
||||||
void labelcachesave(JSON root)
|
void labelcachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
const JSON jsonlabels = json_array();
|
const JSON jsonlabels = json_array();
|
||||||
const JSON jsonautolabels = json_array();
|
const JSON jsonautolabels = json_array();
|
||||||
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
|
for(LabelsInfo::iterator i = labels.begin(); i != labels.end(); ++i)
|
||||||
|
@ -642,6 +675,7 @@ void labelcachesave(JSON root)
|
||||||
|
|
||||||
void labelcacheload(JSON root)
|
void labelcacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
labels.clear();
|
labels.clear();
|
||||||
const JSON jsonlabels = json_object_get(root, "labels");
|
const JSON jsonlabels = json_object_get(root, "labels");
|
||||||
if(jsonlabels)
|
if(jsonlabels)
|
||||||
|
@ -703,6 +737,7 @@ bool labelenum(LABELSINFO* labellist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!labellist && !cbsize)
|
if(!labellist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockLabels);
|
||||||
if(!labellist && cbsize)
|
if(!labellist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = labels.size() * sizeof(LABELSINFO);
|
*cbsize = labels.size() * sizeof(LABELSINFO);
|
||||||
|
@ -726,6 +761,7 @@ bool bookmarkset(uint addr, bool manual)
|
||||||
modnamefromaddr(addr, bookmark.mod, true);
|
modnamefromaddr(addr, bookmark.mod, true);
|
||||||
bookmark.addr = addr - modbasefromaddr(addr);
|
bookmark.addr = addr - modbasefromaddr(addr);
|
||||||
bookmark.manual = manual;
|
bookmark.manual = manual;
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second)
|
if(!bookmarks.insert(std::make_pair(modhashfromva(addr), bookmark)).second)
|
||||||
return bookmarkdel(addr);
|
return bookmarkdel(addr);
|
||||||
return true;
|
return true;
|
||||||
|
@ -735,6 +771,7 @@ bool bookmarkget(uint addr)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
if(bookmarks.count(modhashfromva(addr)))
|
if(bookmarks.count(modhashfromva(addr)))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -744,6 +781,7 @@ bool bookmarkdel(uint addr)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
return (bookmarks.erase(modhashfromva(addr)) > 0);
|
return (bookmarks.erase(modhashfromva(addr)) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,6 +795,7 @@ void bookmarkdelrange(uint start, uint end)
|
||||||
return;
|
return;
|
||||||
start -= modbase;
|
start -= modbase;
|
||||||
end -= modbase;
|
end -= modbase;
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
BookmarksInfo::iterator i = bookmarks.begin();
|
BookmarksInfo::iterator i = bookmarks.begin();
|
||||||
while(i != bookmarks.end())
|
while(i != bookmarks.end())
|
||||||
{
|
{
|
||||||
|
@ -774,6 +813,7 @@ void bookmarkdelrange(uint start, uint end)
|
||||||
|
|
||||||
void bookmarkcachesave(JSON root)
|
void bookmarkcachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
const JSON jsonbookmarks = json_array();
|
const JSON jsonbookmarks = json_array();
|
||||||
const JSON jsonautobookmarks = json_array();
|
const JSON jsonautobookmarks = json_array();
|
||||||
for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i)
|
for(BookmarksInfo::iterator i = bookmarks.begin(); i != bookmarks.end(); ++i)
|
||||||
|
@ -797,6 +837,7 @@ void bookmarkcachesave(JSON root)
|
||||||
|
|
||||||
void bookmarkcacheload(JSON root)
|
void bookmarkcacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
bookmarks.clear();
|
bookmarks.clear();
|
||||||
const JSON jsonbookmarks = json_object_get(root, "bookmarks");
|
const JSON jsonbookmarks = json_object_get(root, "bookmarks");
|
||||||
if(jsonbookmarks)
|
if(jsonbookmarks)
|
||||||
|
@ -844,6 +885,7 @@ bool bookmarkenum(BOOKMARKSINFO* bookmarklist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!bookmarklist && !cbsize)
|
if(!bookmarklist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBookmarks);
|
||||||
if(!bookmarklist && cbsize)
|
if(!bookmarklist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO);
|
*cbsize = bookmarks.size() * sizeof(BOOKMARKSINFO);
|
||||||
|
@ -873,6 +915,7 @@ bool functionadd(uint start, uint end, bool manual)
|
||||||
function.start = start - modbase;
|
function.start = start - modbase;
|
||||||
function.end = end - modbase;
|
function.end = end - modbase;
|
||||||
function.manual = manual;
|
function.manual = manual;
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function));
|
functions.insert(std::make_pair(ModuleRange(modhashfromva(modbase), Range(function.start, function.end)), function));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -882,6 +925,7 @@ bool functionget(uint addr, uint* start, uint* end)
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
uint modbase = modbasefromaddr(addr);
|
uint modbase = modbasefromaddr(addr);
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)));
|
const FunctionsInfo::iterator found = functions.find(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase)));
|
||||||
if(found == functions.end()) //not found
|
if(found == functions.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -897,6 +941,7 @@ bool functionoverlaps(uint start, uint end)
|
||||||
if(!DbgIsDebugging() or end < start)
|
if(!DbgIsDebugging() or end < start)
|
||||||
return false;
|
return false;
|
||||||
const uint modbase = modbasefromaddr(start);
|
const uint modbase = modbasefromaddr(start);
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0);
|
return (functions.count(ModuleRange(modhashfromva(modbase), Range(start - modbase, end - modbase))) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,6 +950,7 @@ bool functiondel(uint addr)
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
const uint modbase = modbasefromaddr(addr);
|
const uint modbase = modbasefromaddr(addr);
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0);
|
return (functions.erase(ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,6 +964,7 @@ void functiondelrange(uint start, uint end)
|
||||||
return;
|
return;
|
||||||
start -= modbase;
|
start -= modbase;
|
||||||
end -= modbase;
|
end -= modbase;
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
FunctionsInfo::iterator i = functions.begin();
|
FunctionsInfo::iterator i = functions.begin();
|
||||||
while(i != functions.end())
|
while(i != functions.end())
|
||||||
{
|
{
|
||||||
|
@ -935,6 +982,7 @@ void functiondelrange(uint start, uint end)
|
||||||
|
|
||||||
void functioncachesave(JSON root)
|
void functioncachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
const JSON jsonfunctions = json_array();
|
const JSON jsonfunctions = json_array();
|
||||||
const JSON jsonautofunctions = json_array();
|
const JSON jsonautofunctions = json_array();
|
||||||
for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i)
|
for(FunctionsInfo::iterator i = functions.begin(); i != functions.end(); ++i)
|
||||||
|
@ -959,6 +1007,7 @@ void functioncachesave(JSON root)
|
||||||
|
|
||||||
void functioncacheload(JSON root)
|
void functioncacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
functions.clear();
|
functions.clear();
|
||||||
const JSON jsonfunctions = json_object_get(root, "functions");
|
const JSON jsonfunctions = json_object_get(root, "functions");
|
||||||
if(jsonfunctions)
|
if(jsonfunctions)
|
||||||
|
@ -1012,6 +1061,7 @@ bool functionenum(FUNCTIONSINFO* functionlist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!functionlist && !cbsize)
|
if(!functionlist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockFunctions);
|
||||||
if(!functionlist && cbsize)
|
if(!functionlist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = functions.size() * sizeof(FUNCTIONSINFO);
|
*cbsize = functions.size() * sizeof(FUNCTIONSINFO);
|
||||||
|
@ -1049,6 +1099,7 @@ bool loopadd(uint start, uint end, bool manual)
|
||||||
else
|
else
|
||||||
loop.parent = 0;
|
loop.parent = 0;
|
||||||
loop.manual = manual;
|
loop.manual = manual;
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop));
|
loops.insert(std::make_pair(DepthModuleRange(finaldepth, ModuleRange(modhashfromva(modbase), Range(loop.start, loop.end))), loop));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1059,6 +1110,7 @@ bool loopget(int depth, uint addr, uint* start, uint* end)
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
const uint modbase = modbasefromaddr(addr);
|
const uint modbase = modbasefromaddr(addr);
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))));
|
LoopsInfo::iterator found = loops.find(DepthModuleRange(depth, ModuleRange(modhashfromva(modbase), Range(addr - modbase, addr - modbase))));
|
||||||
if(found == loops.end()) //not found
|
if(found == loops.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -1080,6 +1132,8 @@ bool loopoverlaps(int depth, uint start, uint end, int* finaldepth)
|
||||||
uint curEnd = end - modbase;
|
uint curEnd = end - modbase;
|
||||||
const uint key = modhashfromva(modbase);
|
const uint key = modhashfromva(modbase);
|
||||||
|
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
|
|
||||||
//check if the new loop fits in the old loop
|
//check if the new loop fits in the old loop
|
||||||
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
|
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1113,6 +1167,7 @@ bool loopdel(int depth, uint addr)
|
||||||
|
|
||||||
void loopcachesave(JSON root)
|
void loopcachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
const JSON jsonloops = json_array();
|
const JSON jsonloops = json_array();
|
||||||
const JSON jsonautoloops = json_array();
|
const JSON jsonautoloops = json_array();
|
||||||
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
|
for(LoopsInfo::iterator i = loops.begin(); i != loops.end(); ++i)
|
||||||
|
@ -1139,6 +1194,7 @@ void loopcachesave(JSON root)
|
||||||
|
|
||||||
void loopcacheload(JSON root)
|
void loopcacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
loops.clear();
|
loops.clear();
|
||||||
const JSON jsonloops = json_object_get(root, "loops");
|
const JSON jsonloops = json_object_get(root, "loops");
|
||||||
if(jsonloops)
|
if(jsonloops)
|
||||||
|
@ -1194,6 +1250,7 @@ bool loopenum(LOOPSINFO* looplist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!looplist && !cbsize)
|
if(!looplist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockLoops);
|
||||||
if(!looplist && cbsize)
|
if(!looplist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = loops.size() * sizeof(LOOPSINFO);
|
*cbsize = loops.size() * sizeof(LOOPSINFO);
|
||||||
|
|
|
@ -13,6 +13,7 @@ int bpgetlist(std::vector<BREAKPOINT>* list)
|
||||||
return false;
|
return false;
|
||||||
BREAKPOINT curBp;
|
BREAKPOINT curBp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||||
{
|
{
|
||||||
curBp = i->second;
|
curBp = i->second;
|
||||||
|
@ -43,6 +44,7 @@ bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE ty
|
||||||
bp.singleshoot = singleshoot;
|
bp.singleshoot = singleshoot;
|
||||||
bp.titantype = titantype;
|
bp.titantype = titantype;
|
||||||
bp.type = type;
|
bp.type = type;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp));
|
breakpoints.insert(std::make_pair(BreakpointKey(type, modhashfromva(addr)), bp));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +54,7 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
BREAKPOINT curBp;
|
BREAKPOINT curBp;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
if(!name)
|
if(!name)
|
||||||
{
|
{
|
||||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||||
|
@ -89,6 +92,7 @@ bool bpdel(uint addr, BP_TYPE type)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
|
return (breakpoints.erase(BreakpointKey(type, modhashfromva(addr))) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +100,7 @@ bool bpenable(uint addr, BP_TYPE type, bool enable)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||||
if(found == breakpoints.end()) //not found
|
if(found == breakpoints.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -107,6 +112,7 @@ bool bpsetname(uint addr, BP_TYPE type, const char* name)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging() or !name or !*name)
|
if(!DbgIsDebugging() or !name or !*name)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||||
if(found == breakpoints.end()) //not found
|
if(found == breakpoints.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,6 +124,7 @@ bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, modhashfromva(addr)));
|
||||||
if(found == breakpoints.end()) //not found
|
if(found == breakpoints.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -131,6 +138,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
|
||||||
return false;
|
return false;
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
BREAKPOINT curBp;
|
BREAKPOINT curBp;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
BreakpointsInfo::iterator i = breakpoints.begin();
|
BreakpointsInfo::iterator i = breakpoints.begin();
|
||||||
while(i != breakpoints.end())
|
while(i != breakpoints.end())
|
||||||
{
|
{
|
||||||
|
@ -164,6 +172,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum)
|
||||||
int bpgetcount(BP_TYPE type, bool enabledonly)
|
int bpgetcount(BP_TYPE type, bool enabledonly)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||||
{
|
{
|
||||||
if(i->first.first == type && (!enabledonly || i->second.enabled))
|
if(i->first.first == type && (!enabledonly || i->second.enabled))
|
||||||
|
@ -202,6 +211,7 @@ void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
|
||||||
|
|
||||||
void bpcachesave(JSON root)
|
void bpcachesave(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
const JSON jsonbreakpoints = json_array();
|
const JSON jsonbreakpoints = json_array();
|
||||||
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -226,6 +236,7 @@ void bpcachesave(JSON root)
|
||||||
|
|
||||||
void bpcacheload(JSON root)
|
void bpcacheload(JSON root)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
breakpoints.clear();
|
breakpoints.clear();
|
||||||
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
|
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
|
||||||
if(jsonbreakpoints)
|
if(jsonbreakpoints)
|
||||||
|
@ -256,5 +267,6 @@ void bpcacheload(JSON root)
|
||||||
|
|
||||||
void bpclear()
|
void bpclear()
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockBreakpoints);
|
||||||
BreakpointsInfo().swap(breakpoints);
|
BreakpointsInfo().swap(breakpoints);
|
||||||
}
|
}
|
|
@ -3,8 +3,9 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "threading.h"
|
||||||
|
|
||||||
PatchesInfo patches;
|
static PatchesInfo patches;
|
||||||
|
|
||||||
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
|
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.oldbyte = oldbyte;
|
||||||
newPatch.newbyte = newbyte;
|
newPatch.newbyte = newbyte;
|
||||||
uint key = modhashfromva(addr);
|
uint key = modhashfromva(addr);
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
PatchesInfo::iterator found = patches.find(key);
|
PatchesInfo::iterator found = patches.find(key);
|
||||||
if(found != patches.end()) //we found a patch on the specified address
|
if(found != patches.end()) //we found a patch on the specified address
|
||||||
{
|
{
|
||||||
|
@ -41,6 +43,7 @@ bool patchget(uint addr, PATCHINFO* patch)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
|
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
|
||||||
if(found == patches.end()) //not found
|
if(found == patches.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -57,6 +60,7 @@ bool patchdel(uint addr, bool restore)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
|
PatchesInfo::iterator found = patches.find(modhashfromva(addr));
|
||||||
if(found == patches.end()) //not found
|
if(found == patches.end()) //not found
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,6 +80,7 @@ void patchdelrange(uint start, uint end, bool restore)
|
||||||
return;
|
return;
|
||||||
start -= modbase;
|
start -= modbase;
|
||||||
end -= modbase;
|
end -= modbase;
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
PatchesInfo::iterator i = patches.begin();
|
PatchesInfo::iterator i = patches.begin();
|
||||||
while(i != patches.end())
|
while(i != patches.end())
|
||||||
{
|
{
|
||||||
|
@ -92,6 +97,7 @@ void patchdelrange(uint start, uint end, bool restore)
|
||||||
|
|
||||||
void patchclear(const char* mod)
|
void patchclear(const char* mod)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
if(!mod or !*mod)
|
if(!mod or !*mod)
|
||||||
patches.clear();
|
patches.clear();
|
||||||
else
|
else
|
||||||
|
@ -113,6 +119,7 @@ bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
|
||||||
return false;
|
return false;
|
||||||
if(!patcheslist && !cbsize)
|
if(!patcheslist && !cbsize)
|
||||||
return false;
|
return false;
|
||||||
|
CriticalSectionLocker locker(LockPatches);
|
||||||
if(!patcheslist && cbsize)
|
if(!patcheslist && cbsize)
|
||||||
{
|
{
|
||||||
*cbsize = patches.size() * sizeof(LOOPSINFO);
|
*cbsize = patches.size() * sizeof(LOOPSINFO);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "undocumented.h"
|
#include "undocumented.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "threading.h"
|
||||||
|
|
||||||
static std::vector<THREADINFO> threadList;
|
static std::vector<THREADINFO> threadList;
|
||||||
static int threadNum;
|
static int threadNum;
|
||||||
|
@ -18,26 +19,32 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
|
||||||
*curInfo.threadName = '\0';
|
*curInfo.threadName = '\0';
|
||||||
if(!threadNum)
|
if(!threadNum)
|
||||||
strcpy(curInfo.threadName, "Main Thread");
|
strcpy(curInfo.threadName, "Main Thread");
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
threadList.push_back(curInfo);
|
threadList.push_back(curInfo);
|
||||||
threadNum++;
|
threadNum++;
|
||||||
|
locker.unlock(); //prevent possible deadlocks
|
||||||
GuiUpdateThreadView();
|
GuiUpdateThreadView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void threadexit(DWORD dwThreadId)
|
void threadexit(DWORD dwThreadId)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
for(unsigned int i = 0; i < threadList.size(); i++)
|
for(unsigned int i = 0; i < threadList.size(); i++)
|
||||||
if(threadList.at(i).dwThreadId == dwThreadId)
|
if(threadList.at(i).dwThreadId == dwThreadId)
|
||||||
{
|
{
|
||||||
threadList.erase(threadList.begin() + i);
|
threadList.erase(threadList.begin() + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
locker.unlock(); //prevent possible deadlocks
|
||||||
GuiUpdateThreadView();
|
GuiUpdateThreadView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void threadclear()
|
void threadclear()
|
||||||
{
|
{
|
||||||
threadNum = 0;
|
threadNum = 0;
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
std::vector<THREADINFO>().swap(threadList);
|
std::vector<THREADINFO>().swap(threadList);
|
||||||
|
locker.unlock(); //prevent possible deadlocks
|
||||||
GuiUpdateThreadView();
|
GuiUpdateThreadView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +64,7 @@ static DWORD GetThreadLastError(uint tebAddress)
|
||||||
|
|
||||||
void threadgetlist(THREADLIST* list)
|
void threadgetlist(THREADLIST* list)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
int count = (int)threadList.size();
|
int count = (int)threadList.size();
|
||||||
list->count = count;
|
list->count = count;
|
||||||
if(!count)
|
if(!count)
|
||||||
|
@ -81,6 +89,7 @@ void threadgetlist(THREADLIST* list)
|
||||||
|
|
||||||
bool threadisvalid(DWORD dwThreadId)
|
bool threadisvalid(DWORD dwThreadId)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
for(unsigned int i = 0; i < threadList.size(); i++)
|
for(unsigned int i = 0; i < threadList.size(); i++)
|
||||||
if(threadList.at(i).dwThreadId == dwThreadId)
|
if(threadList.at(i).dwThreadId == dwThreadId)
|
||||||
return true;
|
return true;
|
||||||
|
@ -89,6 +98,7 @@ bool threadisvalid(DWORD dwThreadId)
|
||||||
|
|
||||||
bool threadsetname(DWORD dwThreadId, const char* name)
|
bool threadsetname(DWORD dwThreadId, const char* name)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
for(unsigned int i = 0; i < threadList.size(); i++)
|
for(unsigned int i = 0; i < threadList.size(); i++)
|
||||||
if(threadList.at(i).dwThreadId == dwThreadId)
|
if(threadList.at(i).dwThreadId == dwThreadId)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +112,7 @@ bool threadsetname(DWORD dwThreadId, const char* name)
|
||||||
|
|
||||||
HANDLE threadgethandle(DWORD dwThreadId)
|
HANDLE threadgethandle(DWORD dwThreadId)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
for(unsigned int i = 0; i < threadList.size(); i++)
|
for(unsigned int i = 0; i < threadList.size(); i++)
|
||||||
if(threadList.at(i).dwThreadId == dwThreadId)
|
if(threadList.at(i).dwThreadId == dwThreadId)
|
||||||
return threadList.at(i).hThread;
|
return threadList.at(i).hThread;
|
||||||
|
@ -110,6 +121,7 @@ HANDLE threadgethandle(DWORD dwThreadId)
|
||||||
|
|
||||||
DWORD threadgetid(HANDLE hThread)
|
DWORD threadgetid(HANDLE hThread)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockThreads);
|
||||||
for(unsigned int i = 0; i < threadList.size(); i++)
|
for(unsigned int i = 0; i < threadList.size(); i++)
|
||||||
if(threadList.at(i).hThread == hThread)
|
if(threadList.at(i).hThread == hThread)
|
||||||
return threadList.at(i).dwThreadId;
|
return threadList.at(i).dwThreadId;
|
||||||
|
|
|
@ -21,6 +21,16 @@ bool waitislocked(WAIT_ID id);
|
||||||
enum CriticalSectionLock
|
enum CriticalSectionLock
|
||||||
{
|
{
|
||||||
LockMemoryPages,
|
LockMemoryPages,
|
||||||
|
LockVariables,
|
||||||
|
LockModules,
|
||||||
|
LockComments,
|
||||||
|
LockLabels,
|
||||||
|
LockBookmarks,
|
||||||
|
LockFunctions,
|
||||||
|
LockLoops,
|
||||||
|
LockBreakpoints,
|
||||||
|
LockPatches,
|
||||||
|
LockThreads,
|
||||||
LockLast
|
LockLast
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
|
#include "threading.h"
|
||||||
|
|
||||||
static VariableMap variables;
|
static VariableMap variables;
|
||||||
static VAR* vars;
|
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)
|
static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
String name_;
|
String name_;
|
||||||
if(*name != '$')
|
if(*name != '$')
|
||||||
name_ = "$";
|
name_ = "$";
|
||||||
|
@ -36,7 +38,7 @@ static bool varset(const char* name, VAR_VALUE* value, bool setreadonly)
|
||||||
|
|
||||||
void varinit()
|
void varinit()
|
||||||
{
|
{
|
||||||
variables.clear();
|
varfree();
|
||||||
//General variables
|
//General variables
|
||||||
varnew("$result\1$res", 0, VAR_SYSTEM);
|
varnew("$result\1$res", 0, VAR_SYSTEM);
|
||||||
varnew("$result1\1$res1", 0, VAR_SYSTEM);
|
varnew("$result1\1$res1", 0, VAR_SYSTEM);
|
||||||
|
@ -56,6 +58,7 @@ void varinit()
|
||||||
|
|
||||||
void varfree()
|
void varfree()
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
variables.clear();
|
variables.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +69,7 @@ VAR* vargetptr()
|
||||||
|
|
||||||
bool varnew(const char* name, uint value, VAR_TYPE type)
|
bool varnew(const char* name, uint value, VAR_TYPE type)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
if(!name)
|
if(!name)
|
||||||
return false;
|
return false;
|
||||||
std::vector<String> names = StringUtils::Split(name, '\1');
|
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)
|
static bool varget(const char* name, VAR_VALUE* value, int* size, VAR_TYPE* type)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
String name_;
|
String name_;
|
||||||
if(*name != '$')
|
if(*name != '$')
|
||||||
name_ = "$";
|
name_ = "$";
|
||||||
|
@ -179,6 +184,7 @@ bool varset(const char* name, const char* string, bool setreadonly)
|
||||||
|
|
||||||
bool vardel(const char* name, bool delsystem)
|
bool vardel(const char* name, bool delsystem)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
String name_;
|
String name_;
|
||||||
if(*name != '$')
|
if(*name != '$')
|
||||||
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)
|
bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
String name_;
|
String name_;
|
||||||
if(*name != '$')
|
if(*name != '$')
|
||||||
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)
|
bool varenum(VAR* entries, size_t* cbsize)
|
||||||
{
|
{
|
||||||
|
CriticalSectionLocker locker(LockVariables);
|
||||||
if(!entries && !cbsize || !variables.size())
|
if(!entries && !cbsize || !variables.size())
|
||||||
return false;
|
return false;
|
||||||
if(!entries && cbsize)
|
if(!entries && cbsize)
|
||||||
|
|
|
@ -99,12 +99,6 @@
|
||||||
<ClCompile Include="math.cpp">
|
<ClCompile Include="math.cpp">
|
||||||
<Filter>Source Files\Core</Filter>
|
<Filter>Source Files\Core</Filter>
|
||||||
</ClCompile>
|
</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">
|
<ClCompile Include="threading.cpp">
|
||||||
<Filter>Source Files\Core</Filter>
|
<Filter>Source Files\Core</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -168,6 +162,12 @@
|
||||||
<ClCompile Include="stringutils.cpp">
|
<ClCompile Include="stringutils.cpp">
|
||||||
<Filter>Source Files\Utilities</Filter>
|
<Filter>Source Files\Utilities</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="murmurhash.cpp">
|
||||||
|
<Filter>Source Files\Utilities</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="msgqueue.cpp">
|
||||||
|
<Filter>Source Files\Utilities</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="x64_dbg.h">
|
<ClInclude Include="x64_dbg.h">
|
||||||
|
@ -227,9 +227,6 @@
|
||||||
<ClInclude Include="math.h">
|
<ClInclude Include="math.h">
|
||||||
<Filter>Header Files\Core</Filter>
|
<Filter>Header Files\Core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="msgqueue.h">
|
|
||||||
<Filter>Header Files\Core</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="threading.h">
|
<ClInclude Include="threading.h">
|
||||||
<Filter>Header Files\Core</Filter>
|
<Filter>Header Files\Core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -242,9 +239,6 @@
|
||||||
<ClInclude Include="plugin_loader.h">
|
<ClInclude Include="plugin_loader.h">
|
||||||
<Filter>Header Files\Core</Filter>
|
<Filter>Header Files\Core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="murmurhash.h">
|
|
||||||
<Filter>Header Files\Core</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="debugger.h">
|
<ClInclude Include="debugger.h">
|
||||||
<Filter>Header Files\Debugger Core</Filter>
|
<Filter>Header Files\Debugger Core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -317,5 +311,11 @@
|
||||||
<ClInclude Include="stringutils.h">
|
<ClInclude Include="stringutils.h">
|
||||||
<Filter>Header Files\Utilities</Filter>
|
<Filter>Header Files\Utilities</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="murmurhash.h">
|
||||||
|
<Filter>Header Files\Utilities</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="msgqueue.h">
|
||||||
|
<Filter>Header Files\Utilities</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue