📄 control.cpp
字号:
DoInterrupt();
}
return FALSE;
}
static void RecordPaint( HWND hwnd )
/**********************************/
{
int i;
for( i = 0; i < NumInvalid; ++i ) {
if( InvalidHWNDs[i] == hwnd ) return;
}
if( NumInvalid == MAX_HWNDS ) return;
InvalidHWNDs[NumInvalid] = hwnd;
++NumInvalid;
}
void SignalEvent( void )
/**********************/
{
if( DebuggerWindow == NULL ) {
ReleaseSemaphore( EventSem, 1, NULL );
} else {
PostMessage( DebuggerWindow, WM_QUIT, 0, 0 );
}
}
static void WaitForEvent( void )
/********************************/
{
MSG msg;
HWND hwnd;
BOOL is_dbg_wnd;
int num_paints;
if( !IsWindow( DebuggerWindow ) ) DebuggerWindow = NULL;
if( DebuggerWindow == NULL ) {
#if 1
while( WaitForSingleObject( EventSem, 10 ) == WAIT_TIMEOUT ) {
while( PeekMessage( &msg, NULL, 0, -1, PM_REMOVE ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
#else
WaitForSingleObject( EventSem, INFINITE );
#endif
} else {
num_paints = 0;
while( GetMessage( &msg, NULL, 0, 0 ) ) {
hwnd = msg.hwnd;
is_dbg_wnd = FALSE;
if( DebuggerWindow != NULL ) {
while( hwnd ) {
if( hwnd == DebuggerWindow ) {
is_dbg_wnd = TRUE;
break;
}
hwnd = GetParent( hwnd );
}
}
if( !is_dbg_wnd ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
} else {
switch( msg.message ) {
case WM_KEYDOWN:
if( msg.wParam == VK_CANCEL ) {
DoInterrupt();
}
break;
case WM_COMMAND:
CantDoIt();
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
RecordPaint( msg.hwnd );
BeginPaint( msg.hwnd, &ps );
EndPaint( msg.hwnd, &ps );
break;
}
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
CantDoIt();
break;
case WM_MOUSEMOVE:
break;
default:
DefWindowProc( DebuggerWindow, msg.message, msg.wParam,
msg.lParam );
}
}
}
ProcessQueuedRepaints();
}
Process.waiting = FALSE;
Process.interrupting = FALSE;
}
HRESULT __stdcall WDbgMgrCallback::QueryInterface( REFIID id, void **object )
/***************************************************************************/
{
HRESULT retval;
if( id == IID_IRemoteDebugManagerCallback || id == IID_IUnknown ) {
AddRef();
*object = (void *) this;
retval = S_OK;
} else {
*object = NULL;
retval = E_NOINTERFACE;
}
return retval;
}
ULONG __stdcall WDbgMgrCallback::AddRef( void )
/**********************************************/
// these are only ever going to be instantiated as static objects
{
refcount++;
return refcount;
}
ULONG __stdcall WDbgMgrCallback::Release( void )
/**********************************************/
{
refcount--;
return refcount;
}
HRESULT __stdcall WDbgMgrCallback::ProcessCreateEvent( IRemoteProcess * newproc,
IRemoteProcess * parent )
/******************************************************************************/
{
newproc->AddRef();
Process.curr = newproc;
newproc->RegisterCallback( &ProcessCB );
return S_FALSE;
}
//---------------------------------------------------------------------------
HRESULT __stdcall WProcessCallback::QueryInterface( REFIID id, void **object )
/****************************************************************************/
{
HRESULT retval;
if( id == IID_IRemoteProcessCallback || id == IID_IUnknown ) {
AddRef();
*object = (void *) this;
retval = S_OK;
} else {
*object = NULL;
retval = E_NOINTERFACE;
}
return retval;
}
ULONG __stdcall WProcessCallback::AddRef( void )
/************************************************/
// these are only ever going to be instantiated as static objects
{
refcount++;
return refcount;
}
ULONG __stdcall WProcessCallback::Release( void )
/************************************************/
// these are only ever going to be instantiated as static objects
{
refcount--;
return refcount;
}
HRESULT __stdcall WProcessCallback::DebugStringEvent( IRemoteThread *,
LPCOLESTR )
/********************************************************************/
{
return S_FALSE; // care not about these.
}
HRESULT __stdcall WProcessCallback::CodeBreakpointEvent( IRemoteThread *thread )
/******************************************************************************/
{
HandleEvent( thread, COND_BREAK );
return S_OK; // S_OK == suspend execution
}
HRESULT __stdcall WProcessCallback::DataBreakpointEvent( IRemoteThread *thread,
IRemoteObject *data )
/*****************************************************************************/
{
HandleEvent( thread, COND_WATCH );
return S_OK;
}
HRESULT __stdcall WProcessCallback::ExceptionEvent( IRemoteThread *,
IRemoteClassField *,
EXCEPTIONKIND )
/**********************************************************************/
{
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::StepEvent( IRemoteThread *thread )
/********************************************************************/
{
HandleEvent( thread, COND_TRACE );
return S_OK;
}
HRESULT __stdcall WProcessCallback::CanStopEvent( IRemoteThread *thread )
/*****************************************************************/
{
if( thread == TraceThread ) {
HandleEvent( thread, COND_TRACE );
return S_OK;
}
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::BreakEvent( IRemoteThread *thread )
/*********************************************************************/
{
HandleEvent( thread, COND_USER );
return S_OK;
}
HRESULT __stdcall WProcessCallback::ThreadCreateEvent( IRemoteThread *thread )
/****************************************************************************/
{
threadlist *newthread;
wchar_t * name;
newthread = (threadlist *) MSJAlloc( sizeof(threadlist) );
newthread->next = Process.threadtable;
Process.threadtable = newthread;
newthread->handle = thread;
thread->GetName( &name );
newthread->name = UnicodeToASCII( name );
thread->AddRef();
CoTaskMemFree( name );
Process.flags |= COND_THREAD;
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::ThreadDestroyEvent( IRemoteThread *thread )
/*****************************************************************************/
{
threadlist **curr;
threadlist * victim;
curr = &Process.threadtable;
while( *curr != NULL ) {
if( (*curr)->handle == thread ) break;
curr = &(*curr)->next;
}
if( *curr != NULL ) {
victim = *curr;
*curr = victim->next;
MSJFree( victim->name );
MSJFree( victim );
thread->Release();
}
Process.flags |= COND_THREAD;
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::ThreadGroupCreateEvent( IRemoteThread *,
IRemoteThreadGroup * )
/******************************************************************************/
{
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::ThreadGroupDestroyEvent( IRemoteThread *,
IRemoteThreadGroup * )
/******************************************************************************/
{
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::ClassLoadEvent( IRemoteThread *thread,
IRemoteClassField *cls )
/***********************************************************************/
{
ImageEntry *image;
wchar_t *uname;
char *aname;
char name[256]; // nyi - real length!
cls->AddRef();
image = &ImageMap[GrowImageMap()];
image->cls = cls;
image->newly_loaded = 1;
image->newly_unloaded = 0;
image->num_cues = 0;
image->cues = NULL;
image->num_methods = 0;
image->methods = NULL;
image->pEnum = NULL;
image->addrinfo_loaded = FALSE;
image->modinfo_loaded = FALSE;
image->cues_loaded = FALSE;
uname = NULL;
cls->GetName( &uname );
if( uname == NULL ) {
strcpy( name, "unknown class" );
} else {
aname = UnicodeToASCII( uname );
strcpy( name, aname );
strcat( name, CLASSNAME_SUFFIX );
MSJFree( (void*)aname );
}
image->className = (char*)MSJAlloc( strlen( name ) + 1 );
strcpy( image->className, name );
AddAddressInfo( ImageMapTop-1 );
if( !Process.task_loading ) {
HandleEvent( thread, COND_LIBRARIES );
return S_OK; // S_OK == suspend execution
} else {
return S_FALSE;
}
}
HRESULT __stdcall WProcessCallback::ClassUnloadEvent( IRemoteThread *,
IRemoteClassField *cls )
/*************************************************************************/
{
int i,j;
ImageEntry *image;
image = ImageMap;
for( i = 0; i < ImageMapTop; ++i ) {
if( image->cls == cls ) {
image->newly_unloaded = 1;
cls->Release();
for( j = 0; j < image->num_methods; ++j ) {
image->methods[j]->Release();
image->methods[j] = NULL;
}
if( image->methods ) MSJFree( image->methods );
image->methods = NULL;
image->num_methods = 0;
if( image->cues ) MSJFree( image->cues );
image->cues = NULL;
image->num_cues = 0;
if( image->pEnum ) image->pEnum->Release();
image->pEnum = NULL;
break;
}
++image;
}
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::ProcessDestroyEvent( IRemoteThread *thread )
/******************************************************************************/
{
HandleEvent( thread, COND_TERMINATE );
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::TraceEvent( IRemoteThread *)
/**************************************************************/
{
return S_FALSE;
}
HRESULT __stdcall WProcessCallback::LoadCompleteEvent( IRemoteThread *thread )
/****************************************************************************/
{
if( Process.task_loading ) {
Process.task_loading = FALSE;
HandleEvent( thread, COND_BREAK );
ReadFlags();
return S_OK;
}
return S_FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -