/* * FormatSpyMessage - make a spy message string */ void FormatSpyMessage( char *msg, LPMSG pmsg, char *res ) { memset( res,' ', SPYOUT_LENGTH ); strcpy( res, msg ); res[strlen( msg )] = ' '; GetHexStr( &res[SPYOUT_HWND], (DWORD) pmsg->hwnd, SPYOUT_HWND_LEN ); GetHexStr( &res[SPYOUT_MSG], pmsg->message, SPYOUT_MSG_LEN ); GetHexStr( &res[SPYOUT_WPARAM], pmsg->wParam, SPYOUT_WPARAM_LEN ); GetHexStr( &res[SPYOUT_LPARAM], pmsg->lParam, SPYOUT_LPARAM_LEN ); res[SPYOUT_LENGTH] = 0; } /* FormatSpyMessage */
/* * GetWindowStyleString - get string corrosponding to window style bits */ void GetWindowStyleString( HWND hwnd, char *str, char *sstr ) { UINT id; DWORD style; DWORD exstyle; char tmp[40]; int len; char *rcstr; int i; int j; style = GetWindowLong( hwnd, GWL_STYLE ); exstyle = GetWindowLong( hwnd, GWL_EXSTYLE ); GetHexStr( str, style, 8 ); str[8] = 0; sstr[0] = 0; if( style & WS_CHILD ) { id = GET_ID( hwnd ); rcstr = GetRCString( STR_CHILD_ID ); sprintf( tmp, rcstr, id, UINT_STR_LEN, id ); strcat( str, tmp ); } for( i = 0; i < StyleArraySize; i++ ) { if( (style & StyleArray[i].mask) == StyleArray[i].flags ) { strcat( sstr, StyleArray[i].name ); strcat( sstr, " " ); } } len = GetClassName( hwnd, tmp, sizeof( tmp ) ); tmp[len] = 0; for( i = 0; i < ClassStylesSize; i++ ) { if( !stricmp( tmp, ClassStyles[i].class_name ) ) { for( j = 0; j < *ClassStyles[i].style_array_size; j++ ) { if( (style & ClassStyles[i].style_array[j].mask) == ClassStyles[i].style_array[j].flags ) { strcat( sstr, ClassStyles[i].style_array[j].name ); strcat( sstr, " " ); } } } } for( i = 0; i < ExStyleArraySize; i++ ) { if( (exstyle & ExStyleArray[i].mask) == ExStyleArray[i].flags ) { strcat( sstr, ExStyleArray[i].name ); strcat( sstr, " " ); } } } /* GetWindowStyleString */
/* * GetClassStyleString - get a string corrosponding to class style bits */ void GetClassStyleString( HWND hwnd, char *str, char *sstr ) { STYLE_TYPE style; int i; style = GET_CLASS_STYLE( hwnd ); GetHexStr( str, style, STYLE_HEX_LEN ); str[STYLE_HEX_LEN] = 0; sstr[0] = 0; for( i = 0; i < ClassStyleArraySize; i++ ) { if( (style & ClassStyleArray[i].mask) == ClassStyleArray[i].flags ) { strcat( sstr, ClassStyleArray[i].name ); strcat( sstr, " " ); } } } /* GetClassStyleString */
/* * GetWindowName - set up a window name string */ void GetWindowName( HWND hwnd, char *str ) { int len; char name[64]; if( hwnd == NULL ) { strcpy( str, GetRCString( STR_NONE ) ); return; } len = GetWindowText( hwnd, name, sizeof( name ) ); name[len] = 0; if( len == 0 ) { GetHexStr( str, (UINT)hwnd, 4 ); str[4] = 0; } else { sprintf( str, "%0*x: %s", UINT_STR_LEN, (UINT)hwnd, name ); } } /* GetWindowName */
/* * SpyOut - display spy message */ void SpyOut( char *msg, LPMSG pmsg ) { static int i; char res[SPYOUT_LENGTH + 1]; #ifdef __NT__ LVITEM lvi; char hwnd_str[SPYOUT_HWND_LEN + 1]; char msg_str[SPYOUT_MSG_LEN + 1]; char wparam_str[SPYOUT_WPARAM_LEN + 1]; char lparam_str[SPYOUT_LPARAM_LEN + 1]; #endif if( SpyMessagesPaused ) { return; } if( pmsg != NULL ) { FormatSpyMessage( msg, pmsg, res ); } else { strcpy( res, msg ); } SpyLogOut( res ); #ifdef __NT__ if( IsCommCtrlLoaded() ) { lvi.mask = LVIF_TEXT; lvi.iItem = SendMessage( SpyListBox, LVM_GETITEMCOUNT, 0, 0L ); lvi.iSubItem = 0; lvi.pszText = msg; SendMessage( SpyListBox, LVM_INSERTITEM, 0, (LPARAM)&lvi ); if( pmsg != NULL ) { GetHexStr( hwnd_str, (DWORD)(pointer_int)pmsg->hwnd, SPYOUT_HWND_LEN ); hwnd_str[SPYOUT_HWND_LEN] = '\0'; GetHexStr( msg_str, pmsg->message, SPYOUT_MSG_LEN ); msg_str[SPYOUT_MSG_LEN] = '\0'; GetHexStr( wparam_str, pmsg->wParam, SPYOUT_WPARAM_LEN ); wparam_str[SPYOUT_WPARAM_LEN] = '\0'; GetHexStr( lparam_str, pmsg->lParam, SPYOUT_LPARAM_LEN ); lparam_str[SPYOUT_LPARAM_LEN] = '\0'; lvi.iSubItem = 1; lvi.pszText = hwnd_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 2; lvi.pszText = msg_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 3; lvi.pszText = wparam_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 4; lvi.pszText = lparam_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); } if( SpyMessagesAutoScroll ) { SendMessage( SpyListBox, LVM_ENSUREVISIBLE, lvi.iItem, FALSE ); } } else { #endif i = (int)SendMessage( SpyListBox, LB_ADDSTRING, 0, (LPARAM)(LPSTR)res ); if( SpyMessagesAutoScroll ) { SendMessage( SpyListBox, LB_SETCURSEL, i, 0L ); } #ifdef __NT__ } #endif } /* SpyOut */
/* * ProcessIncomingMessage - get a string associated with a message id */ void ProcessIncomingMessage( UINT msgid, char *class_name, char *res ) { message *msg; const char *fmtstr; char buf[256]; char hexstr[20]; res[0] = '\0'; msg = GetMessageDataFromID( msgid, class_name ); if( msg != NULL ) { if( msg->watch ) { strcpy( res, msg->str ); } if( msg->stopon ) { SetSpyState( OFF ); RCsprintf( buf, STR_SPYING_STOPPED, msg->str ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } msg->count++; } else if( msgid >= WM_USER && msgid < WM_APP ) { userMsg->count++; if( userMsg->watch ) { fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); } if( userMsg->stopon ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } else if( msgid >= WM_APP && msgid < 0xC000 ) { appMsg->count++; if( appMsg->watch ) { fmtstr = GetRCString( STR_WM_APP_PLUS ); sprintf( res, fmtstr, msgid - WM_APP ); } if( appMsg->stopon ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_WM_APP_PLUS ); sprintf( res, fmtstr, msgid - WM_APP ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } else { if( Filters[MC_UNKNOWN].watch ) { GetHexStr( hexstr, msgid, 0 ); fmtstr = GetRCString( STR_UNKNOWN_MSG ); sprintf( res, fmtstr, hexstr ); } if( Filters[MC_UNKNOWN].stopon ) { SetSpyState( OFF ); GetHexStr( hexstr, msgid, 0 ); fmtstr = GetRCString( STR_UNKNOWN_MSG ); sprintf( res, fmtstr, hexstr ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } } /* ProcessIncomingMessage */