mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04: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:
|
public:
|
||||||
|
|
||||||
|
static HRESULT Start();
|
||||||
|
static void Stop();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
// may generate HRESULT exception if not registered
|
// may generate HRESULT exception if not registered
|
||||||
DbgEventCallbacks();
|
DbgEventCallbacks();
|
||||||
void Deregister();
|
void Deregister();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
// IUnknown interface implementation
|
// IUnknown interface implementation
|
||||||
|
|
||||||
@ -42,11 +45,11 @@ private:
|
|||||||
|
|
||||||
IDebugClient *m_dbgClient;
|
IDebugClient *m_dbgClient;
|
||||||
IDebugSymbols3 *m_dbgSymbols3;
|
IDebugSymbols3 *m_dbgSymbols3;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// global singleton
|
||||||
|
|
||||||
|
static DbgEventCallbacks *dbgEventCallbacks;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// global singleton
|
|
||||||
|
|
||||||
extern DbgEventCallbacks *dbgEventCallbacks;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -227,7 +227,7 @@ VOID
|
|||||||
CALLBACK
|
CALLBACK
|
||||||
DebugExtensionUninitialize()
|
DebugExtensionUninitialize()
|
||||||
{
|
{
|
||||||
stopDbgEventMonotoring();
|
DbgEventCallbacks::Stop();
|
||||||
|
|
||||||
delete windbgGlobalSession;
|
delete windbgGlobalSession;
|
||||||
windbgGlobalSession = NULL;
|
windbgGlobalSession = NULL;
|
||||||
|
@ -6,29 +6,9 @@ dbgCreateSession();
|
|||||||
extern
|
extern
|
||||||
bool dbgSessionStarted;
|
bool dbgSessionStarted;
|
||||||
|
|
||||||
inline void stopDbgEventMonotoring()
|
|
||||||
{
|
|
||||||
if (dbgEventCallbacks)
|
|
||||||
dbgEventCallbacks->Deregister();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HRESULT setDbgSessionStarted()
|
inline HRESULT setDbgSessionStarted()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres = DbgEventCallbacks::Start();
|
||||||
try
|
|
||||||
{
|
|
||||||
stopDbgEventMonotoring();
|
|
||||||
dbgEventCallbacks = new DbgEventCallbacks;
|
|
||||||
hres = S_OK;
|
|
||||||
}
|
|
||||||
catch (HRESULT _hres)
|
|
||||||
{
|
|
||||||
hres = _hres;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
hres = E_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
if (SUCCEEDED(hres))
|
if (SUCCEEDED(hres))
|
||||||
dbgSessionStarted = true;
|
dbgSessionStarted = true;
|
||||||
return hres;
|
return hres;
|
||||||
|
Loading…
Reference in New Issue
Block a user