DBG+BRIDGE+GUI: resolved a possible race condition on the lock initialization
This commit is contained in:
parent
5634206e85
commit
4505f9f652
|
@ -802,6 +802,11 @@ BRIDGE_IMPEXP bool DbgIsRunning()
|
|||
return !DbgIsRunLocked();
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void DbgInitializeLocks()
|
||||
{
|
||||
_dbg_sendmessage(DBG_INITIALIZE_LOCKS, nullptr, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip)
|
||||
{
|
||||
_gui_sendmessage(GUI_DISASSEMBLE_AT, (void*)addr, (void*)cip);
|
||||
|
|
|
@ -169,7 +169,8 @@ typedef enum
|
|||
DBG_GET_STRING_AT, // param1=duint addr, param2=unused
|
||||
DBG_GET_FUNCTIONS, // param1=unused, param2=unused
|
||||
DBG_WIN_EVENT, // param1=MSG* message, param2=long* result
|
||||
DBG_WIN_EVENT_GLOBAL // param1=MSG* message, param2=unused
|
||||
DBG_WIN_EVENT_GLOBAL, // param1=MSG* message, param2=unused
|
||||
DBG_INITIALIZE_LOCKS // paraam1=unused, param2=unused
|
||||
} DBGMSG;
|
||||
|
||||
typedef enum
|
||||
|
@ -686,6 +687,7 @@ BRIDGE_IMPEXP const DBGFUNCTIONS* DbgFunctions();
|
|||
BRIDGE_IMPEXP bool DbgWinEvent(MSG* message, long* result);
|
||||
BRIDGE_IMPEXP bool DbgWinEventGlobal(MSG* message);
|
||||
BRIDGE_IMPEXP bool DbgIsRunning();
|
||||
BRIDGE_IMPEXP void DbgInitializeLocks();
|
||||
|
||||
//Gui defines
|
||||
#define GUI_PLUGIN_MENU 0
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "loop.h"
|
||||
#include "error.h"
|
||||
#include "x64_dbg.h"
|
||||
#include "threading.h"
|
||||
|
||||
static bool bOnlyCipAutoComments = false;
|
||||
|
||||
|
@ -649,9 +650,15 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
{
|
||||
switch(type) //ignore win events
|
||||
{
|
||||
//these functions are safe to call when we did not initialize yet
|
||||
case DBG_INITIALIZE_LOCKS:
|
||||
case DBG_GET_FUNCTIONS:
|
||||
case DBG_SETTINGS_UPDATED:
|
||||
case DBG_GET_THREAD_LIST:
|
||||
case DBG_WIN_EVENT:
|
||||
case DBG_WIN_EVENT_GLOBAL:
|
||||
return 0;
|
||||
break;
|
||||
//the rest is unsafe -> throw an exception when people try to call them
|
||||
default:
|
||||
__debugbreak(); //we cannot process messages when the debugger is stopped, this must be a bug
|
||||
}
|
||||
|
@ -981,6 +988,12 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
return (uint)pluginwineventglobal((MSG*)param1);
|
||||
}
|
||||
break;
|
||||
|
||||
case DBG_INITIALIZE_LOCKS:
|
||||
{
|
||||
SectionLockerGlobal::Initialize();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ public:
|
|||
|
||||
static inline void AcquireLock(SectionLock LockIndex, bool Shared)
|
||||
{
|
||||
Initialize(); // Locks can be accessed before we know when to initialize
|
||||
if(m_SRWLocks)
|
||||
{
|
||||
if(Shared)
|
||||
|
|
|
@ -25,7 +25,7 @@ static COMMAND* command_list = 0;
|
|||
static HANDLE hCommandLoopThread = 0;
|
||||
static bool bStopCommandLoopThread = false;
|
||||
static char alloctrace[MAX_PATH] = "";
|
||||
static bool bIsStopped = false;
|
||||
static bool bIsStopped = true;
|
||||
|
||||
static CMDRESULT cbStrLen(int argc, char* argv[])
|
||||
{
|
||||
|
@ -335,7 +335,8 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
|||
}
|
||||
LocalFree(argv);
|
||||
dputs("Initialization successful!");
|
||||
return 0;
|
||||
bIsStopped = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
|
||||
|
|
|
@ -45,6 +45,8 @@ static Configuration* mConfiguration;
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
DbgInitializeLocks();
|
||||
|
||||
MyApplication application(argc, argv);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
QAbstractEventDispatcher::instance(application.thread())->setEventFilter(MyApplication::globalEventFilter);
|
||||
|
|
Loading…
Reference in New Issue