void WhoUsesModule( LPCTSTR lpFileName, BOOL bFullPathCheck ) { CString processName; BOOL bShow = FALSE; SystemProcessInformation::SYSTEM_PROCESS_INFORMATION* p; SystemProcessInformation pi; SystemModuleInformation mi; if ( !mi.Refresh() ) { _tprintf( _T("SystemModulesInformation::Refresh() failed.\n") ); return; } if ( mi.m_ModuleInfos.GetHeadPosition() == NULL ) { _tprintf( _T("No module information\n") ); return; } pi.Refresh(); _tprintf( _T("%-6s %-20s %s\n"), _T("PID"), _T("Name"), _T("Path") ); _tprintf( _T("------------------------------------------------------------------\n") ); for ( POSITION pos = mi.m_ModuleInfos.GetHeadPosition(); pos != NULL; ) { SystemModuleInformation::MODULE_INFO& m = mi.m_ModuleInfos.GetNext(pos); if ( bFullPathCheck ) bShow = _tcsicmp( m.FullPath, lpFileName ) == 0; else bShow = _tcsicmp( GetFileNamePosition(m.FullPath), lpFileName ) == 0; if ( bShow ) { if ( pi.m_ProcessInfos.Lookup( m.ProcessId, p ) ) { SystemInfoUtils::Unicode2CString( &p->usName, processName ); } else processName = ""; _tprintf( _T("0x%04X %-20s %s\n"), m.ProcessId, processName, m.FullPath ); } } }
bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() ); // Ignore the sheet file name if searching to replace. if( !(aSearchData.GetFlags() & FR_SEARCH_REPLACE) && SCH_ITEM::Matches( m_fileName, aSearchData ) ) { if( aFindLocation ) *aFindLocation = GetFileNamePosition(); return true; } if( SCH_ITEM::Matches( m_name, aSearchData ) ) { if( aFindLocation ) *aFindLocation = GetSheetNamePosition(); return true; } return false; }
void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor ) { COLOR4D txtcolor; wxString Text; COLOR4D color; int name_orientation; wxPoint pos_sheetname,pos_filename; wxPoint pos = m_pos + aOffset; int lineWidth = GetPenSize(); EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; if( aColor != COLOR4D::UNSPECIFIED ) color = aColor; else color = GetLayerColor( m_Layer ); GRSetDrawMode( aDC, aDrawMode ); GRRect( clipbox, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); pos_sheetname = GetSheetNamePosition() + aOffset; pos_filename = GetFileNamePosition() + aOffset; if( IsVerticalOrientation() ) name_orientation = TEXT_ANGLE_VERT; else name_orientation = TEXT_ANGLE_HORIZ; /* Draw text : SheetName */ if( aColor != COLOR4D::UNSPECIFIED ) txtcolor = aColor; else txtcolor = GetLayerColor( LAYER_SHEETNAME ); Text = wxT( "Sheet: " ) + m_name; DrawGraphicText( clipbox, aDC, pos_sheetname, txtcolor, Text, name_orientation, wxSize( m_sheetNameSize, m_sheetNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, lineWidth, false, false ); /* Draw text : FileName */ if( aColor != COLOR4D::UNSPECIFIED ) txtcolor = aColor; else txtcolor = GetLayerColor( LAYER_SHEETFILENAME ); Text = wxT( "File: " ) + m_fileName; DrawGraphicText( clipbox, aDC, pos_filename, txtcolor, Text, name_orientation, wxSize( m_fileNameSize, m_fileNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, lineWidth, false, false ); /* Draw text : SheetLabel */ for( SCH_SHEET_PIN& sheetPin : m_pins ) { if( !sheetPin.IsMoving() ) sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); } #if 0 // Only for testing purposes, draw the component bounding box EDA_RECT boundingBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN ); GRFilledCircle( aPanel->GetClipBox(), aDC, m_pos.x, m_pos.y, 10, 0, color, color ); #endif }
void WhoUsesFile( LPCTSTR lpFileName, BOOL bFullPathCheck ) { BOOL bShow = FALSE; CString name; CString processName; CString deviceFileName; CString fsFilePath; SystemProcessInformation::SYSTEM_PROCESS_INFORMATION* p; SystemProcessInformation pi; SystemHandleInformation hi; if ( bFullPathCheck ) { if ( !SystemInfoUtils::GetDeviceFileName( lpFileName, deviceFileName ) ) { _tprintf( _T("GetDeviceFileName() failed.\n") ); return; } } hi.SetFilter( _T("File"), TRUE ); if ( hi.m_HandleInfos.GetHeadPosition() == NULL ) { _tprintf( _T("No handle information\n") ); return; } pi.Refresh(); _tprintf( _T("%-6s %-20s %s\n"), _T("PID"), _T("Name"), _T("Path") ); _tprintf( _T("------------------------------------------------------\n") ); for ( POSITION pos = hi.m_HandleInfos.GetHeadPosition(); pos != NULL; ) { SystemHandleInformation::SYSTEM_HANDLE& h = hi.m_HandleInfos.GetNext(pos); if ( pi.m_ProcessInfos.Lookup( h.ProcessID, p ) ) { SystemInfoUtils::Unicode2CString( &p->usName, processName ); } else processName = ""; //NT4 Stupid thing if it is the services.exe and I call GetName :(( if ( INtDll::dwNTMajorVersion == 4 && _tcsicmp( processName, _T("services.exe" ) ) == 0 ) continue; hi.GetName( (HANDLE)h.HandleNumber, name, h.ProcessID ); if ( bFullPathCheck ) bShow = _tcsicmp( name, deviceFileName ) == 0; else bShow = _tcsicmp( GetFileNamePosition(name), lpFileName ) == 0; if ( bShow ) { if ( !bFullPathCheck ) { fsFilePath = ""; SystemInfoUtils::GetFsFileName( name, fsFilePath ); } _tprintf( _T("0x%04X %-20s %s\n"), h.ProcessID, processName, !bFullPathCheck ? fsFilePath : lpFileName ); } } }
int _tmain(int argc, TCHAR* argv[]) { ULONG nonSwitchCount = 0; BOOL bModule = FALSE; LPCTSTR lpPath = NULL; BOOL bFullPathCheck = FALSE; BOOL bUsage = TRUE; TCHAR lpFilePath[_MAX_PATH]; for ( int i = 1; i < argc; i++ ) { if ( _tcsicmp( argv[i], _T("/?" ) ) == 0 || _tcsicmp( argv[i], _T("-?" ) ) == 0 ) { bUsage = TRUE; break; } else if ( _tcsicmp( argv[i], _T("/m" ) ) == 0 || _tcsicmp( argv[i], _T("-m" ) ) == 0 ) { bModule = TRUE; } else { if ( nonSwitchCount != 0 ) { bUsage = TRUE; break; } lpPath = argv[i]; bUsage = FALSE; nonSwitchCount++; } } if ( bUsage ) { ShowUsage(); return -1; } EnableDebugPriv(); bFullPathCheck = GetFileNamePosition( lpPath ) != lpPath ; if ( bFullPathCheck ) { if ( GetFullPathName( lpPath, _MAX_PATH, lpFilePath, NULL ) == 0 ) { _tprintf( _T("GetFullPathName() failed. Error = %d\n"), GetLastError() ); return -2; } } else _tcscpy( lpFilePath, GetFileNamePosition( lpPath ) ); if ( bModule ) WhoUsesModule( lpFilePath, bFullPathCheck ); else WhoUsesFile( lpFilePath, bFullPathCheck ); return 0; }