Beispiel #1
0
// Plug-in process
void CORE_Process(int iArg)
{
    try
    {
        char version[16];
        sprintf(version, "%u.%u", HIBYTE(MY_VERSION), LOBYTE(MY_VERSION));
        msg("\n>> WhatAPIs: v: %s, built: %s, By Sirmabus\n", version, __DATE__);
        if (!autoIsOk())
        {
            msg("** Must wait for IDA to finish processing before starting plug-in! **\n*** Aborted ***\n\n");
            return;
        }

        // Show UI
        refreshUI();
        int uiResult = AskUsingForm_c(mainDialog, version, doHyperlink);
        if (!uiResult)
        {
            msg(" - Canceled -\n");
            return;
        }

        WaitBox::show();
        TIMESTAMP startTime = getTimeStamp();

        // Build import segment bounds table
        {
            msg("Import segments:\n");
            refreshUI();
            SEGLIST segList;
            for (int i = 0; i < get_segm_qty(); i++)
            {
                if (segment_t *s = getnseg(i))
                {
                    if (s->type == SEG_XTRN)
                    {
                        char buffer[64] = { "unknown" }; buffer[SIZESTR(buffer)] = 0;
                        get_true_segm_name(s, buffer, SIZESTR(buffer));
                        msg(" [%d] \"%s\" "EAFORMAT" - "EAFORMAT"\n", segmentCount, buffer, s->startEA, s->endEA);
                        BOUNDS b = { s->startEA, s->endEA };
                        segList.push_back(b);
                        segmentCount++;
                    }
                }
            }
            refreshUI();

            // Flatten list into an array for speed
            if (segmentCount)
            {
                UINT size = (segmentCount * sizeof(BOUNDS));
                if (segmentPtr = (BOUNDS *)_aligned_malloc(size, 16))
                {
                    BOUNDS *b = segmentPtr;
                    for (SEGLIST::iterator i = segList.begin(); i != segList.end(); i++, b++)
                    {
                        b->startEA = i->startEA;
                        b->endEA   = i->endEA;
                    }
                }
                else
                {
                    msg("\n*** Allocation failure of %u bytes! ***\n", size);
                    refreshUI();
                }
            }
        }

        if (segmentCount)
        {
            // Make a list of all import names
            if (int moduleCount = get_import_module_qty())
            {
                for (int i = 0; i < moduleCount; i++)
                    enum_import_names(i, importNameCallback);

                char buffer[32];
                msg("Parsed %s module imports.\n", prettyNumberString(moduleCount, buffer));
                refreshUI();
            }

            // Iterate through all functions..
            BOOL aborted = FALSE;
            UINT functionCount = get_func_qty();
            char buffer[32];
            msg("Processing %s functions.\n", prettyNumberString(functionCount, buffer));
            refreshUI();

            for (UINT n = 0; n < functionCount; n++)
            {
                processFunction(getn_func(n));

                if (WaitBox::isUpdateTime())
                {
                    if (WaitBox::updateAndCancelCheck((int)(((float)n / (float)functionCount) * 100.0f)))
                    {
                        msg("* Aborted *\n");
                        break;
                    }
                }
            }

            refresh_idaview_anyway();
            WaitBox::hide();
            msg("\n");
            msg("Done. %s comments add/appended in %s.\n", prettyNumberString(commentCount, buffer), timeString(getTimeStamp() - startTime));
            msg("-------------------------------------------------------------\n");
        }
        else
            msg("\n*** No import segments! ***\n");

        if (segmentPtr)
        {
            _aligned_free(segmentPtr);
            segmentPtr = NULL;
        }
        apiMap.clear();
    }
    CATCH()
}
Beispiel #2
0
int SerialData::Serial(FILE *pf,CMonitorList &MonitorList,Groups *pGroups,Subsequent *pSubsequent,TASKMAP &TaskMap,bool out)
{
	if(pf==NULL)
		return -2;

	STRINGMAP strmap;

	if(out)
	{
		fputs("//****SiteView ECC serial data file****\r\n",pf);
		fputs("//****Data version 7.01****\r\n",pf);
		fputs("[MonitorList_Begin]\r\n",pf);

		CMonitorList::iterator it;
		for(it=MonitorList.begin();it!=MonitorList.end();it++)
		{
			strmap.clear();
			if(!(*it)->ToTextMap(strmap))
				continue;
			fputs("[Monitor_Begin]\r\n",pf);
			SerialStringMap(strmap,pf);
			fputs("[Monitor_End]\r\n",pf);
		}
		fputs("[MonitorList_End]\r\n",pf);

		strmap.clear();
		if(!pGroups->ToTextMap(strmap))
		{
			fclose(pf);
			return -3;
		}

		fputs("[Groups_Begin]\r\n",pf);
		SerialStringMap(strmap,pf);
		fputs("[Groups_End]\r\n",pf);

		strmap.clear();
		if(!pSubsequent->ToTextMap(strmap))
		{
			fclose(pf);
			return -4;
		}

		fputs("[Subsequent_Begin]\r\n",pf);
		SerialStringMap(strmap,pf);
		fputs("[Subsequent_End]\r\n",pf);

		fputs("[TaskMap_Begin]\r\n",pf);

		TASKMAP::iterator tit;
		Task *ptask=NULL;
		while(TaskMap.findnext(tit))
		{
	    	strmap.clear();
			if((ptask=(*tit).getvalue())==NULL)
				continue;
			if(!ptask->ToTextMap(strmap))
				continue;
			fputs("[Task_Begin]\r\n",pf);
			SerialStringMap(strmap,pf);
			fputs("[Task_End]\r\n",pf);

		}

		fputs("[TaskMap_End]\r\n",pf);

		fclose(pf);


	}else
	{
		string sline;
		char line[2048]={0};
		char *pc=NULL;
		pc=fgets(line,2048,pf);
		if(pc==NULL)
			return -5;
		sline=line;
		int pos=0;
		if((pos=(int)sline.find("//"))!=0)
			return -6;
		if((pos=(int)sline.find("SiteView ECC serial data file"))<0)
			return -7;
		pc=fgets(line,2048,pf);
		if(pc==NULL)
			return -10;

		sline=line;
		if((pos=(int)sline.find("//"))!=0)
			return -8;
		if((pos=(int)sline.find("Data version 7.01"))<0)
			return -9;

		int i=0;
		bool flag=false;

		while(fgets(line,2048,pf)!=NULL)
		{
			sline=line;
			switch(i)
			{
			case	0:
				if((pos=(int)sline.find("[MonitorList_Begin]"))!=0)
				{
					continue;
				}
				else
				{
					flag=true;
					while(true)
					{
						bool mflag=false;
						strmap.clear();
						while((pc=fgets(line,2048,pf))!=NULL)
						{
							sline=line;
							if((pos=(int)sline.find("[Monitor_Begin]"))!=0)
							{
								if((pos=(int)sline.find("[MonitorList_End]"))==0)
								{
									flag=false;
									i++;
									break;
								}
								continue;
							}
							else
								break;
						}
						if(pc==NULL)
							return -11;
						if(!flag)
							break;

						while((pc=fgets(line,2048,pf))!=NULL)
						{
							sline=line;
							if((pos=(int)sline.find("[Monitor_End]"))==0)
							{
								mflag=true;
								break;
							}
							CovertStringToMap(sline,strmap);
						}
						if(pc==NULL)
							return -12;
						if(mflag)
						{
							Monitor *pm=new Monitor();
							if(Univ::seid!=1)
								pm->m_isRefresh= true;
							if(pm->FromTextMap(strmap))
								MonitorList.push_back(pm);
						}
					}
				}
				break;
			case		1:
				if((pos=(int)sline.find("[Groups_Begin]"))!=0)
				{
					continue;
				}else
				{
					strmap.clear();
					flag=false;
					while((pc=fgets(line,2048,pf))!=NULL)
					{
						sline=line;
						if((pos=(int)sline.find("[Groups_End]"))==0)
						{
							i++;
							flag=true;
							break;
						}
						CovertStringToMap(sline,strmap);
					}
					if(pc==NULL)
						return -13;
					if(flag)
						pGroups->FromTextMap(strmap);

				}
				break;
			case	2:
				if((pos=(int)sline.find("[Subsequent_Begin]"))!=0)
				{
					continue;
				}else
				{
					strmap.clear();
					flag=false;
					while((pc=fgets(line,2048,pf))!=NULL)
					{
						sline=line;
						if((pos=(int)sline.find("[Subsequent_End]"))==0)
						{
							i++;
							flag=true;
							break;
						}
						CovertStringToMap(sline,strmap);
					}
					if(pc==NULL)
						return -13;
					if(flag)
						pSubsequent->FromTextMap(strmap);
				}
				break;
			case	3:
				if((pos=(int)sline.find("[TaskMap_Begin]"))!=0)
				{
					continue;
				}else
				{
					flag=true;
					while(true)
					{
						bool mflag=false;
						strmap.clear();
						while((pc=fgets(line,2048,pf))!=NULL)
						{
							sline=line;
							if((pos=(int)sline.find("[Task_Begin]"))!=0)
							{
								if((pos=(int)sline.find("[TaskMap_End]"))==0)
								{
									flag=false;
									i++;
									break;
								}
								continue;
							}
							else
								break;
						}
						if(pc==NULL)
							return -11;
						if(!flag)
						{
							return 0;
						}

						while((pc=fgets(line,2048,pf))!=NULL)
						{
							sline=line;
							if((pos=(int)sline.find("[Task_End]"))==0)
							{
								mflag=true;
								break;
							}
							CovertStringToMap(sline,strmap);
						}
						if(pc==NULL)
							return -12;
						if(mflag)
						{
							Task *pm=new Task();
							if(pm->FromTextMap(strmap))
								TaskMap[pm->m_taskname.c_str()]=pm;
						}


					}
				}
				break;
			case	4:
				return 0;
			default :break;
			}

		}

	}

	return 0;

}
Beispiel #3
0
// Uninitialize
void CORE_Exit()
{
    apiMap.clear();
}