mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-22 05:13:22 +08:00
[~] singleton dbgEventCallbacks and work with him moved into a class DbgEventCallbacks
git-svn-id: https://pykd.svn.codeplex.com/svn@62103 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
b73ccc1a37
commit
bb0e8328e3
@ -10,7 +10,37 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DbgEventCallbacks *dbgEventCallbacks = NULL;
|
||||
DbgEventCallbacks *DbgEventCallbacks::dbgEventCallbacks = NULL;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HRESULT DbgEventCallbacks::Start()
|
||||
{
|
||||
HRESULT hres;
|
||||
try
|
||||
{
|
||||
Stop();
|
||||
dbgEventCallbacks = new DbgEventCallbacks;
|
||||
hres = S_OK;
|
||||
}
|
||||
catch (HRESULT _hres)
|
||||
{
|
||||
hres = _hres;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
hres = E_OUTOFMEMORY;
|
||||
}
|
||||
return hres;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DbgEventCallbacks::Stop()
|
||||
{
|
||||
if (dbgEventCallbacks)
|
||||
dbgEventCallbacks->Deregister();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -6,12 +6,15 @@ class DbgEventCallbacks : public DebugBaseEventCallbacks
|
||||
{
|
||||
public:
|
||||
|
||||
static HRESULT Start();
|
||||
static void Stop();
|
||||
|
||||
private:
|
||||
|
||||
// may generate HRESULT exception if not registered
|
||||
DbgEventCallbacks();
|
||||
void Deregister();
|
||||
|
||||
private:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// IUnknown interface implementation
|
||||
|
||||
@ -42,11 +45,11 @@ private:
|
||||
|
||||
IDebugClient *m_dbgClient;
|
||||
IDebugSymbols3 *m_dbgSymbols3;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// global singleton
|
||||
|
||||
static DbgEventCallbacks *dbgEventCallbacks;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// global singleton
|
||||
|
||||
extern DbgEventCallbacks *dbgEventCallbacks;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -227,7 +227,7 @@ VOID
|
||||
CALLBACK
|
||||
DebugExtensionUninitialize()
|
||||
{
|
||||
stopDbgEventMonotoring();
|
||||
DbgEventCallbacks::Stop();
|
||||
|
||||
delete windbgGlobalSession;
|
||||
windbgGlobalSession = NULL;
|
||||
|
@ -6,29 +6,9 @@ dbgCreateSession();
|
||||
extern
|
||||
bool dbgSessionStarted;
|
||||
|
||||
inline void stopDbgEventMonotoring()
|
||||
{
|
||||
if (dbgEventCallbacks)
|
||||
dbgEventCallbacks->Deregister();
|
||||
}
|
||||
|
||||
inline HRESULT setDbgSessionStarted()
|
||||
{
|
||||
HRESULT hres;
|
||||
try
|
||||
{
|
||||
stopDbgEventMonotoring();
|
||||
dbgEventCallbacks = new DbgEventCallbacks;
|
||||
hres = S_OK;
|
||||
}
|
||||
catch (HRESULT _hres)
|
||||
{
|
||||
hres = _hres;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
hres = E_OUTOFMEMORY;
|
||||
}
|
||||
HRESULT hres = DbgEventCallbacks::Start();
|
||||
if (SUCCEEDED(hres))
|
||||
dbgSessionStarted = true;
|
||||
return hres;
|
||||
|
Loading…
Reference in New Issue
Block a user