bool SerialData::SerialStringMap(STRINGMAP &strmap,FILE *pf) { STRINGMAP::iterator it; while(strmap.findnext(it)) { fprintf(pf,"%s=%s\r\n",(*it).getkey().getword(),(*it).getvalue().getword()); } return true; }
// Import module name enumeration callback static int idaapi importNameCallback(ea_t ea, const char *name, uval_t ord, void *param) { // Skip the ordinal ones if(name) { // Insert it if it doesn't exist apiMap.insert(name); //msg(" \"%s\"\n", name); } return(1); }
bool Groups::FromTextMap(STRINGMAP &strmap) { svutil::word *pstr=NULL; if((pstr=strmap.find("seid"))!=NULL) { if(strlen(pstr->getword())>=10) return false; strcpy(m_SEID,pstr->getword()); } int n=0; if((pstr=strmap.find("GroupListSize"))==NULL) { return false; } n=atoi(pstr->getword()); int i=0; char bkey[256]={0}; GroupsItem *pitem=NULL; for(i=0;i<n;i++) { pitem=new GroupsItem(); if(pitem==NULL) return false; sprintf(bkey,"Groups_Item_GroupID_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pitem; return false; } pitem->SetGroupID(pstr->getword()); sprintf(bkey,"Groups_Item_ParentID_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pitem; return false; } pitem->SetParentID(pstr->getword()); sprintf(bkey,"Groups_Item_DependSon_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pitem; return false; } pitem->SetDepedSon(pstr->getword()); sprintf(bkey,"Groups_Item_DependsCondition_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pitem; return false; } pitem->SetDependsCondition(atoi(pstr->getword())); m_GroupsList.push_back(pitem); } if((pstr=strmap.find("EntityListSize"))==NULL) { return false; } n=atoi(pstr->getword()); memset(bkey,0,256); Entity *pentity=NULL; for(i=0;i<n;i++) { pentity= new Entity(); sprintf(bkey,"Entitys_Item_MonitorTypeCount_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetMonitorTypeCount(atoi(pstr->getword())); sprintf(bkey,"Entitys_Item_EntityID_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetEntityID(pstr->getword()); sprintf(bkey,"Entitys_Item_SystemType_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetSystemType(pstr->getword()); sprintf(bkey,"Entitys_Item_IPAdress_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetIPAdress(pstr->getword()); sprintf(bkey,"Entitys_Item_Depend_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetDepend(pstr->getword()); sprintf(bkey,"Entitys_Item_DependsCondition_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete pentity; return false; } pentity->SetDependsCondition(atoi(pstr->getword())); m_EntityList.push_back(pentity); } return true; }
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; }
int Monitor::FromTextMap(STRINGMAP &strmap) { svutil::word *pstr=NULL; pstr=strmap.find("MonitorID"); if(pstr==NULL) return false; strcpy(m_MonitorID,(*pstr).getword()); pstr=strmap.find("RunInProcess"); if(pstr!=NULL) { m_isRunInProcess=strcmp((*pstr).getword(),"true")==0; } pstr=strmap.find("TaskType"); if(pstr!=NULL) { m_TaskType=atoi((*pstr).getword()); } pstr=strmap.find("LastState"); if(pstr!=NULL) { m_LastState=atoi((*pstr).getword()); } pstr=strmap.find("beginTDTime"); time_t tm=0; if(pstr!=NULL) { tm=(time_t)_atoi64((*pstr).getword()); m_beginTDTime=svutil::TTime(tm); } pstr=strmap.find("endTDTime"); if(pstr!=NULL) { tm=(time_t)_atoi64((*pstr).getword()); m_endTDTime=svutil::TTime(tm); } pstr=strmap.find("isTempDisable"); if(pstr!=NULL) { m_isTempDisable=strcmp((*pstr).getword(),"true")==0; } pstr=strmap.find("isDisable"); if(pstr!=NULL) { m_isDisable=strcmp((*pstr).getword(),"true")==0; } pstr=strmap.find("NextRunTime"); if(pstr!=NULL) { tm=(time_t)_atoi64((*pstr).getword()); m_NextRunTime=svutil::TTime(tm); } pstr=strmap.find("MonitorType"); if(pstr!=NULL) { m_MonitorType=atoi((*pstr).getword()); } pstr=strmap.find("Library"); if(pstr==NULL) { return false; } m_Library=(*pstr).getword(); pstr=strmap.find("Process"); if(pstr==NULL) { return false; } m_Process=(*pstr).getword(); pstr=strmap.find("EntityType"); if(pstr==NULL) { return false; } strcpy(m_EntityType,(*pstr).getword()); pstr=strmap.find("Frequency"); if(pstr==NULL) { return false; } m_Frequency=atoi((*pstr).getword()); pstr=strmap.find("ErrorFreq"); if(pstr!=NULL) { m_ErrorFreq=atoi((*pstr).getword()); } pstr=strmap.find("CheckError"); if(pstr!=NULL) { m_CheckError=strcmp((*pstr).getword(),"true")==0; } pstr=strmap.find("MonitorClass"); if(pstr==NULL) { return false; } m_MonitorClass=(*pstr).getword(); pstr=strmap.find("TaskName"); if(pstr!=NULL) { m_TaskName=(*pstr).getword(); } if(m_StateConditions[0]!=NULL) delete m_StateConditions[0]; StateCondition *psc=new StateCondition(); if(psc==NULL) return false; if((pstr=strmap.find("StateCondition_Error_Type"))==NULL) { delete psc; return false; } psc->m_Type=(StateCondition::econ)atoi((*pstr).getword()); if((pstr=strmap.find("StateCondition_Error_Expression"))==NULL) { delete psc; return false; } psc->m_Expression=(*pstr).getword(); int n=0; if((pstr=strmap.find("StateCondition_Error_ItemSize"))==NULL) { delete psc; return false; } n=atoi((*pstr).getword()); int i=0; StateConditionItem *psct=NULL; char bkey[250]={0}; if(n>0) { for(i=0;i<n;i++) { psct=new StateConditionItem(); sprintf(bkey,"StateCondition_Error_Item_%d_ItemID",i); if((pstr=strmap.find(bkey))==NULL) { delete psct; delete psc; return false; } psct->m_ItemID=atoi((*pstr).getword()); sprintf(bkey,"StateCondition_Error_Item_%d_ParamName",i); if((pstr=strmap.find(bkey))==NULL) { delete psct; delete psc; return false; } psct->m_ParamName=(*pstr).getword(); sprintf(bkey,"StateCondition_Error_Item_%d_Operator",i); if((pstr=strmap.find(bkey))==NULL) { delete psct; delete psc; return false; } strcpy(psct->m_Operator,(*pstr).getword()); sprintf(bkey,"StateCondition_Error_Item_%d_ParamValue",i); if((pstr=strmap.find(bkey))==NULL) { delete psct; delete psc; return false; } psct->m_ParamValue=(*pstr).getword(); psc->m_ConditionList.push_back(psct); } } m_StateConditions[0]=psc; if(m_StateConditions[1]!=NULL) delete m_StateConditions[1]; psc=new StateCondition(); if(psc==NULL) return false; if((pstr=strmap.find("StateCondition_Warning_Type"))==NULL) { delete psc; return false; } psc->m_Type=(StateCondition::econ)atoi((*pstr).getword()); if((pstr=strmap.find("StateCondition_Warning_Expression"))==NULL) { delete psc; return false; } psc->m_Expression=(*pstr).getword(); n=0; if((pstr=strmap.find("StateCondition_Warning_ItemSize"))==NULL) { delete psc; return false; } n=atoi((*pstr).getword()); i=0; psct=NULL; memset(bkey,0,250); if(n>0) { for(i=0;i<n;i++) { psct=new StateConditionItem(); sprintf(bkey,"StateCondition_Warning_Item_%d_ItemID",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete psct; delete psc; return false; } psct->m_ItemID=atoi((*pstr).getword()); sprintf(bkey,"StateCondition_Warning_Item_%d_ParamName",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete psct; delete psc; return false; } psct->m_ParamName=(*pstr).getword(); sprintf(bkey,"StateCondition_Warning_Item_%d_Operator",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete psct; delete psc; return false; } strcpy(psct->m_Operator,(*pstr).getword()); sprintf(bkey,"StateCondition_Warning_Item_%d_ParamValue",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete psct; delete psc; return false; } psct->m_ParamValue=(*pstr).getword(); psc->m_ConditionList.push_back(psct); } } m_StateConditions[1]=psc; if(m_StateConditions[2]!=NULL) delete m_StateConditions[2]; psc=new StateCondition(); if(psc==NULL) return false; if((pstr=strmap.find("StateCondition_Normal_Type"))==NULL) { delete psc; return false; } psc->m_Type=(StateCondition::econ)atoi((*pstr).getword()); if((pstr=strmap.find("StateCondition_Normal_Expression"))==NULL) { delete psc; return false; } psc->m_Expression=(*pstr).getword(); n=0; if((pstr=strmap.find("StateCondition_Normal_ItemSize"))==NULL) { delete psc; return false; } n=atoi((*pstr).getword()); i=0; psct=NULL; memset(bkey,0,250); if(n>0) { for(i=0;i<n;i++) { psct=new StateConditionItem(); sprintf(bkey,"StateCondition_Normal_Item_%d_ItemID",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete psct; delete psc; return false; } psct->m_ItemID=atoi((*pstr).getword()); sprintf(bkey,"StateCondition_Normal_Item_%d_ParamName",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete psct; delete psc; return false; } psct->m_ParamName=(*pstr).getword(); sprintf(bkey,"StateCondition_Normal_Item_%d_Operator",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete psct; delete psc; return false; } strcpy(psct->m_Operator,(*pstr).getword()); sprintf(bkey,"StateCondition_Normal_Item_%d_ParamValue",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete psct; delete psc; return false; } psct->m_ParamValue=(*pstr).getword(); psc->m_ConditionList.push_back(psct); } } m_StateConditions[2]=psc; if((pstr=strmap.find("ReturnList_Size"))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; return false; } n=atoi((*pstr).getword()); if(n<=0) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; return false; } ReturnData *prd=NULL; memset(bkey,0,250); for(i=0;i<n;i++) { prd=new ReturnData(); sprintf(bkey,"ReturnItem_%d_Type",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; delete prd; return false; } strcpy(prd->m_Type,(*pstr).getword()); sprintf(bkey,"ReturnItem_%d_Unit",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; delete prd; return false; } strcpy(prd->m_Unit,(*pstr).getword()); sprintf(bkey,"ReturnItem_%d_Name",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; delete prd; return false; } prd->m_Name=(*pstr).getword(); sprintf(bkey,"ReturnItem_%d_Label",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; delete prd; return false; } prd->m_Label=(*pstr).getword(); m_ReturnList.push_back(prd); } if((pstr=strmap.find("ParamList_Size"))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; return false; } n=atoi((*pstr).getword()); string str=""; memset(bkey,0,250); for(i=0;i<n;i++) { sprintf(bkey,"ParamList_Item_%d",i); if((pstr=strmap.find(bkey))==NULL) { delete m_StateConditions[0]; delete m_StateConditions[1]; delete m_StateConditions[2]; return false; } m_ParamList.push_back((*pstr).getword()); } return true; }
// 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() }
// Uninitialize void CORE_Exit() { apiMap.clear(); }
// Process function void processFunction(func_t *f) { // Skip tiny functions if(f->size() >= 5) { // Don't add comments to API wrappers char name[MAXNAMELEN]; name[0] = name[SIZESTR(name)] = 0; if(!apiMap.empty()) { if(get_short_name(BADADDR, f->startEA, name, SIZESTR(name))) { if(apiMap.find(name) != apiMap.end()) return; } } // Iterate function body STRLIST importLstTmp; LPSTR commentPtr = NULL; char comment[MAXSTR]; comment[0] = comment[SIZESTR(comment)] = 0; UINT commentLen = 0; #define ADDNM(_str) { UINT l = strlen(_str); memcpy(comment + commentLen, _str, l); commentLen += l; _ASSERT(commentLen < MAXSTR); } func_item_iterator_t it(f); do { ea_t currentEA = it.current(); // Will be a "to" xref xrefblk_t xb; if(xb.first_from(currentEA, XREF_FAR)) { BOOL isImpFunc = FALSE; name[0] = 0; // If in import segment // ============================================================================================ ea_t refAdrEa = xb.to; if(isInImportSeg(refAdrEa)) { flags_t flags = get_flags_novalue(refAdrEa); if(has_name(flags) && hasRef(flags) && isDwrd(flags)) { if(get_short_name(BADADDR, refAdrEa, name, SIZESTR(name))) { // Nix the imp prefix if there is one if(strncmp(name, "__imp_", SIZESTR("__imp_")) == 0) memmove(name, name + SIZESTR("__imp_"), ((strlen(name) - SIZESTR("__imp_")) + 1)); isImpFunc = TRUE; } else msg(EAFORMAT" *** Failed to get import name! ***\n", refAdrEa); } } // Else, check for import wrapper // ============================================================================================ else if(!apiMap.empty()) { // Reference is a function entry? flags_t flags = get_flags_novalue(refAdrEa); if(isCode(flags) && has_name(flags) && hasRef(flags)) { if(func_t *refFuncPtr = get_func(refAdrEa)) { if(refFuncPtr->startEA == refAdrEa) { if(get_short_name(BADADDR, refAdrEa, name, SIZESTR(name))) { // Skip common unwanted types "sub_.." or "unknown_libname_.." if( // not "sub_.. /*"sub_"*/ (*((PUINT) name) != 0x5F627573) && // not "unknown_libname_.. /*"unknown_"*/ ((*((PUINT64) name) != 0x5F6E776F6E6B6E75) && (*((PUINT64) (name + 8)) != /*"libname_"*/ 0x5F656D616E62696C)) && // not nullsub_.. /*"nullsub_"*/ (*((PUINT64) name) != 0x5F6275736C6C756E) ) { // Nix the import prefixes if(strncmp(name, "__imp_", SIZESTR("__imp_")) == 0) memmove(name, name + SIZESTR("__imp_"), ((strlen(name) - SIZESTR("__imp_")) + 1)); // Assumed to be a wrapped import if it's in the list isImpFunc = (apiMap.find(name) != apiMap.end()); } } else msg(EAFORMAT" *** Failed to get function name! ***\n", refAdrEa); } } } } // Found import function to add list if(isImpFunc) { // Skip those large common STL names if(strncmp(name, "std::", SIZESTR("std::")) != 0) { // Skip if already seen in this function BOOL known = FALSE; for(STRLIST::iterator ji = importLstTmp.begin(); ji != importLstTmp.end(); ji++) { if(strcmp(ji->c_str(), name) == 0) { known = TRUE; break; } } // Not seen if(!known) { importLstTmp.push_front(name); // Append to existing comments w/line feed if(!commentLen && !commentPtr) { commentPtr = get_func_cmt(f, true); if(!commentPtr) get_func_cmt(f, false); if(commentPtr) { commentLen = strlen(commentPtr); // Bail out not enough comment space if(commentLen >= (MAXSTR - 20)) { qfree(commentPtr); return; } memcpy(comment, commentPtr, commentLen); ADDNM("\n"MYTAG); } } if(!commentLen) ADDNM(MYTAG); // Append a "..." (continuation) and bail out if name hits max comment length if((commentLen + strlen(name) + SIZESTR("()") + sizeof(", ")) >= (MAXSTR - sizeof("..."))) { ADDNM(" ..."); break; } // Append this function name else { if(importLstTmp.size() != 1) ADDNM(", "); ADDNM(name); ADDNM("()"); } } } else { //msg("%s\n", szName); } } } }while(it.next_addr()); if(!importLstTmp.empty() && commentLen) { // Add comment comment[commentLen] = 0; set_func_cmt(f, comment, true); commentCount++; } if(commentPtr) qfree(commentPtr); } }