OperatingSystem::OperatingSystem()
{
	lastProcessId_ = 0;

	addLibrary("kernel32.dll");
	addLibrary("openAL32.dll");
	addLibrary("foundation.dll");

	addProcess("explorer.exe");
	addProcess("winlogon.exe");
	addProcess("taskeng.exe");
	addProcess("test.exe");

	/*auto proc = processes_[1];
	proc->createNewThread();
	proc->createNewThread();
	proc->loadLibrary(getLibraryByName("kernel32.dll"));
	
	proc->killThread(2);
	if (!proc->killThread(0)) {
		delete proc;
		processes_.erase(1);
	}

	killProcess("test.exe");*/ // <--- ето работаит

	auto proc = processes_[0];
	proc->loadLibrary(getLibraryByName("kernel32.dll"));
	deleteLibrary("kernel32.dll");
}
void LIB_MANAGER_ADAPTER::Sync( bool aForce, std::function<void(int, int, const wxString&)> aProgressCallback )
{
    wxLongLong nextUpdate = wxGetUTCTimeMillis() + (PROGRESS_INTERVAL_MILLIS / 2);

    int libMgrHash = m_libMgr->GetHash();

    if( !aForce && m_lastSyncHash == libMgrHash )
        return;

    m_lastSyncHash = libMgrHash;
    int i = 0, max = GetLibrariesCount();

    // Process already stored libraries
    for( auto it = m_tree.Children.begin(); it != m_tree.Children.end(); /* iteration inside */ )
    {
        const wxString& name = it->get()->Name;

        if( wxGetUTCTimeMillis() > nextUpdate )
        {
            aProgressCallback( i, max, name );
            nextUpdate = wxGetUTCTimeMillis() + PROGRESS_INTERVAL_MILLIS;
        }

        if( !m_libMgr->LibraryExists( name, true ) )
        {
            it = deleteLibrary( it );
            continue;
        }
        else if( m_libMgr->GetLibraryHash( name ) != m_libHashes[name] )
        {
            updateLibrary( *(CMP_TREE_NODE_LIB*) it->get() );
        }

        ++it;
        ++i;
    }

    // Look for new libraries
    for( const auto& libName : m_libMgr->GetLibraryNames() )
    {
        if( m_libHashes.count( libName ) == 0 )
        {
            if( wxGetUTCTimeMillis() > nextUpdate )
            {
                aProgressCallback( i++, max, libName );
                nextUpdate = wxGetUTCTimeMillis() + PROGRESS_INTERVAL_MILLIS;
            }

            SYMBOL_LIB_TABLE_ROW* library = m_libMgr->GetLibrary( libName );

            auto& lib_node = m_tree.AddLib( libName, library->GetDescr() );
            updateLibrary( lib_node );
            m_tree.AssignIntrinsicRanks();
        }
    }
}