Esempio n. 1
0
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PRIVATE FUNCTIONS ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
int mwFillList(MW_LIST *middlewaretList)
{
	int iReturnCode = DIAGLIB_OK;

	if(middlewaretList == NULL)
	{
		return RETURN_LOG_BAD_FUNCTION_CALL;
	}

	middlewaretList->clear();

	progressInit(MW_DEFINITION_COUNT);
	
	MW_ID id;

	Soft_LIST softList;

	for(int i=0;i<MW_DEFINITION_COUNT;i++)
	{
		if( DIAGLIB_OK != (iReturnCode = softwareGetIDs(g_MW_Definition[i].Guid, &softList)))
		{
			LOG_ERROR(L"softwareGetIDs failed");
			break;
		}

		Soft_LIST::const_iterator itrSoft;
		for(itrSoft=softList.begin();itrSoft!=softList.end();itrSoft++)
		{
			id=*itrSoft;
			
			//The maching patern can include a Middleware that has already been added to the list,
			//so we check the existence in the middleware list first
			bool bFound=false;
			MW_LIST::const_iterator itrMw;
			for(itrMw=middlewaretList->begin();itrMw!=middlewaretList->end();itrMw++)
			{
				if(id.Guid.compare(itrMw->Guid)==0 && id.Type==itrMw->Type)
				{
					bFound=true;
					break;
				}
			}

			if(!bFound)
			{
				middlewaretList->push_back(id);
			}
		}

		progressIncrement();
	}

	progressRelease();

	return iReturnCode;

}
Esempio n. 2
0
int main(void)
{
    char key;

    timerInitTOD();
    screenInit();
    progressInit();

    g_strFileName[0] = '\0';
    g_nDrive = *(uint8_t*)0xba;
    if (g_nDrive < 8)
        g_nDrive = 8;

    internalCartType = INTERNAL_CART_TYPE_NONE;

    g_bFastLoaderEnabled = 1;
    updateFastLoaderText();

    refreshMainScreen();
    showAbout();
    refreshMainScreen();
    screenBing();

    // this also makes visible 16kByte of flash memory
    checkFlashType();

    checkRAM();

    for (;;)
    {
        setStatus("Ready. Press <m> for Menu.");

        key = cgetc();
        switch (key)
        {
        case 'm':
            execMenu(&menuMain);
            break;

        case 'o':
            execMenu(&menuOptions);
            break;

        case 'e':
            execMenu(&menuExpert);
            break;

        case 'h':
            execMenu(&menuHelp);
            break;
        }
    }
    return 0;
}
Esempio n. 3
0
int mwReportList(Report_TYPE type, const MW_LIST &middlewareList, const wchar_t *TitleIn)
{
	int iReturnCode = DIAGLIB_OK;

	std::wstring Title;

	if(TitleIn!=NULL)
		Title=TitleIn;
	else
		Title=L"Middleware list";
	
	Title.append(L" (#");
	wchar_t buf[10];
	if(-1==swprintf_s(buf,10,L"%ld",middlewareList.size()))
	{
		Title.append(L"???");
		LOG_ERROR(L"swprintf_s failed");
	}
	else
	{
		Title.append(buf);
	}
	Title.append(L")");

	reportPrintHeader2(type, Title.c_str(), REPORT_MW_SEPARATOR);

	MW_INFO info;

	progressInit((int)middlewareList.size());

	MW_LIST::const_iterator itr;
	for(itr=middlewareList.begin();itr!=middlewareList.end();itr++)
	{
		if(DIAGLIB_OK == mwGetInfo(*itr,&info))
		{
			mwReportInfo(type,info);
			mwContributeInfo(info);
		}
		progressIncrement();
	}
	
	progressRelease();

	return iReturnCode;
}
Esempio n. 4
0
int moduleReportList(Report_TYPE type, const Proc_LIST &processList, const wchar_t *TitleIn)
{
    int				iReturnCode=DIAGLIB_OK;
    std::wstring	Title;
    ModuleMap		modules;

    if(TitleIn!=NULL)
        Title=TitleIn;
    else
        Title=L"Module list";

    reportPrintHeader2(type, Title.c_str(), REPORT_PROCESS_SEPARATOR);

    progressInit(processList.size());

    Proc_INFO info;
    Proc_LIST::const_iterator itr;
    for(itr=processList.begin(); itr!=processList.end(); itr++)
    {
        if(DIAGLIB_OK == processGetInfo(*itr,&info))
        {
            for(ModuleSet::const_iterator i=info.modulesLoaded.begin(); i!=info.modulesLoaded.end(); i++)
                modules[*i].insert(info.Name);
        }
        progressIncrement();
    }

    for(ModuleMap::const_iterator i=modules.begin(); i!=modules.end(); i++)
    {
        moduleReportInfo(type,i->first,i->second);
        moduleContributeInfo(i->first,i->second);
    }

    progressRelease();

    return iReturnCode;
}
Esempio n. 5
0
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PRIVATE FUNCTIONS ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
int softwareFillList(Soft_LIST *softList, const wchar_t *guid, const Soft_TYPE *type)
{
	int iReturnCode = DIAGLIB_OK;

	if(softList == NULL)
	{
		return RETURN_LOG_BAD_FUNCTION_CALL;
	}

	softList->clear();

	Reg_ID UninstallKey;
	UninstallKey.Key=REG_UNINSTALL_KEY;

	Soft_ID id;

	Reg_LIST subkeyList;

	progressInit(4);	//First loop (2*2)

	for(int i=0;i<2;i++)
	{
		if(type) 
		{
			id.Type=*type;
		}
		else
		{
			if(i==0)
				id.Type=PER_USER_SOFT_TYPE;
			else
				id.Type=PER_MACHINE_SOFT_TYPE;
		}
		UninstallKey.Type=getRegistryType(id.Type);
			
		if( DIAGLIB_OK != (iReturnCode = registryGetSubKey(UninstallKey,&subkeyList,guid)))
		{
			if(iReturnCode != DIAGLIB_ERR_REGISTRY_NOT_FOUND)
			{
				LOG_ERROR(L"registryGetSubKey failed");
			}
			else
			{
				iReturnCode = DIAGLIB_OK;
			}

			progressIncrement();			//First loop 1
		}
		else
		{
			progressIncrement();			//First loop 1

			progressInit(subkeyList.size()); //Second loop

			Reg_LIST::const_iterator itr;
			for(itr=subkeyList.begin();itr!=subkeyList.end();itr++)
			{
				id.Guid=itr->Key.substr(wcslen(REG_UNINSTALL_KEY)+1);

				softList->push_back(id);
				progressIncrement();	//Second loop
			}
			progressRelease();			//Second loop
		}

		progressIncrement();		//First loop 2

		if(type) //if a special type is requested,
			break;
	}

	progressRelease();				//First loop

	return iReturnCode;

}
Esempio n. 6
0
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PUBLIC FUNCTIONS /////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
int processUsingLibrary(Lib_ID library, Proc_LIST *processList)
{
	int iReturnCode = DIAGLIB_OK;

	if(library.empty() || processList==NULL)
	{
		return RETURN_LOG_BAD_FUNCTION_CALL;
	}

	LOG_TIME(L"Check for use of library '%ls' --> ",library.c_str());

	processList->clear();

	HANDLE hProcessSnap;
    HANDLE hProcess;
    PROCESSENTRY32 pe32;
	bool bUsed=false;

	if(INVALID_HANDLE_VALUE == ( hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)))
	{
		LOG_LASTERROR(L"CreateToolhelp32Snapshot failed");
		return RETURN_LOG_INTERNAL_ERROR;
	}

    pe32.dwSize = sizeof(PROCESSENTRY32);

	//Get progressMax if request
	int progressMax = 0;
	if (!Process32First(hProcessSnap, &pe32))
	{
		LOG_LASTERROR(L"Process32First failed");
		if(!CloseHandle( hProcessSnap ))
		{
			LOG_LASTERROR(L"CloseHandle failed");
		}
		return RETURN_LOG_INTERNAL_ERROR;
	}

	do
	{
		progressMax++;
	} while (Process32Next(hProcessSnap, &pe32));


    if (!Process32First(hProcessSnap, &pe32))
    {
 		LOG_LASTERROR(L"Process32First failed");
		if(!CloseHandle( hProcessSnap ))
		{
			LOG_LASTERROR(L"CloseHandle failed");
		}
		return RETURN_LOG_INTERNAL_ERROR;
    }

	progressInit(progressMax);

	int count=0;
    do
    {
		//We avoid the process System because the isModuleUsedByProcess return an error
		if ( 0 != lstrcmpi(L"System", pe32.szExeFile))
		{
			hProcess = AdvanceOpenProcess(pe32.th32ProcessID, PROCESS_ALL_ACCESS);
			//If we need the exe name, we need pe32.szExeFile
			if(DIAGLIB_OK != isModuleUsedByProcess(pe32.th32ProcessID, library.c_str(),&bUsed))
			{
				LOG(L"isModuleUsedByProcess failed with Process '%ls' (pid=%ld)\n",pe32.szExeFile,pe32.th32ProcessID);
			}
			else
			{
				if(bUsed)
				{
					processList->push_back(pe32.th32ProcessID);
					LOG(L"FOUND Process '%ls' (pid=%ld)\n",pe32.szExeFile,pe32.th32ProcessID);
				}
			}
		}
		progressIncrement();

    } while (Process32Next(hProcessSnap, &pe32));

	progressRelease();

	if(!CloseHandle( hProcessSnap ))
	{
		LOG_LASTERROR(L"CloseHandle failed");
	}

	if(!bUsed) LOG(L"NOT USED\n");

	return iReturnCode;
} 
Esempio n. 7
0
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PRIVATE FUNCTIONS ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
int processFillList(Proc_LIST *processList, const wchar_t *processName)
{
	int iReturnCode = DIAGLIB_OK;

	if(processList == NULL)
	{
		return RETURN_LOG_BAD_FUNCTION_CALL;
	}

	if(processName)
	{
		LOG_TIME(L"Ask for process list (with name = %ls) --> ",processName);
	}
	else
	{
		LOG_TIME(L"Ask for list of all process --> ");
	}

	processList->clear();

	EnablePrivilege(SE_DEBUG_NAME);
	HANDLE hndl;
	if(INVALID_HANDLE_VALUE == ( hndl=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)))
	{
		LOG_LASTERROR(L"CreateToolhelp32Snapshot failed");
		return RETURN_LOG_INTERNAL_ERROR;
	}

	PROCESSENTRY32  procEntry={0};
	procEntry.dwSize = sizeof( PROCESSENTRY32 );

	//Get progressMax if request
	int progressMax = 0;
	if (!Process32First(hndl, &procEntry))
	{
		LOG_LASTERROR(L"Process32First failed");
		if(!CloseHandle( hndl ))
		{
			LOG_LASTERROR(L"CloseHandle failed");
		}
		return RETURN_LOG_INTERNAL_ERROR;
	}
	do
	{
		progressMax++;
	} while (Process32Next(hndl, &procEntry));

	if(!Process32First(hndl,&procEntry))
	{
		LOG_LASTERROR(L"Process32First failed");
		if(!CloseHandle( hndl ))
		{
			LOG_LASTERROR(L"CloseHandle failed");
		}
		return RETURN_LOG_INTERNAL_ERROR;
	}

	progressInit(progressMax);

	do 
	{
		if(procEntry.th32ProcessID != 0)
		{
			if(processName == NULL)
			{
				processList->push_back(procEntry.th32ProcessID);
			}
			else if(0 == _wcsicmp(procEntry.szExeFile,processName))	
			{
				processList->push_back(procEntry.th32ProcessID);
			}
		}

		progressIncrement();

	} while(Process32Next(hndl,&procEntry));

	progressRelease();

	if(!CloseHandle( hndl ))
	{
		LOG_LASTERROR(L"CloseHandle failed");
	}

	if(processList->size() == 0)
	{
		LOG(L"NO PROCESS FOUND\n");
	}
	else
	{
		LOG(L"pid=");
		for (unsigned long i=0; i < processList->size() ; i++)
		{
			LOG(L"%ld,",processList->at(i));
		}
		LOG(L"DONE\n");
	}

	return iReturnCode;
}