void CreateAndFillin_Curvar(const char *type, variable *curvar) { listname *newvar; if ( !strcasecmp(type, "character") && strcasecmp(CharacterSize, "") ) { strcpy(curvar->v_dimchar, CharacterSize); } /* On donne la precision de la variable si elle a ete donnee */ curvar->v_c_star = 0; if ( c_star == 1 ) curvar->v_c_star = 1; strcpy(curvar->v_vallengspec,""); if ( strcasecmp(vallengspec,"") ) { strcpy(curvar->v_vallengspec,vallengspec); Save_Length(vallengspec,8); } strcpy(curvar->v_precision,""); if ( strcasecmp(NamePrecision,"") ) { strcpy(curvar->v_precision,NamePrecision); addprecision_derivedfromkind(curvar); Save_Length(NamePrecision,12); } /* Si cette variable a ete declaree dans un module on met curvar->module=1 */ if ( inmoduledeclare == 1 || SaveDeclare == 1 ) { curvar->v_module = 1; } /* Puis on donne le nom du module dans curvar->v_modulename */ strcpy(curvar->v_modulename,curmodulename); /* Si cette variable a ete initialisee */ if (InitialValueGiven == 1 ) { curvar->v_initialvalue=Insertname(curvar->v_initialvalue,InitValue,0); // strcpy(curvar->v_initialvalue,InitValue); Save_Length(InitValue,14); } /* Si cette variable est declaree en save */ if (SaveDeclare == 1 && !strcasecmp(curvar->v_typevar,"type")) curvar->v_save = 1; /* Si cette variable est v_allocatable */ if (Allocatabledeclare == 1 ) curvar->v_allocatable=1; /* Si cette variable est v_target */ if (Targetdeclare == 1 ) curvar->v_target=1; /* if INTENT spec has been given */ if ( strcasecmp(IntentSpec,"") ) { strcpy(curvar->v_IntentSpec,IntentSpec); Save_Length(IntentSpec,13); } }
//prompt user for name/label and push it out to the server void insert_name(t_dump *pd) { char buf [MAXSTR+128]; char text [MAXSTR+128]; if (connector->is_connected()) // && origin==PM_DISASM) --> do we need this? { Findname(pd->sel0,NM_LABEL,text); //get existing name if (-1 == Gettext("Enter "PLUGIN_NAME" label(name):", text, 0x00, NM_LABEL, FIXEDFONT)) return; //cancelled by user Insertname(pd->sel0, NM_LABEL, text); Redrawdisassembler(); sprintf(buf, "%d:::%08x:::%s", IDA_SYNC_COMMAND_NAME, pd->sel0, // our current selected address text); if (connector_push(buf)) Message(pd->sel0, "[*] "PLUGIN_NAME"> Successfully pushed name/label at address 0x%08x to server.", pd->sel0); }//if connected }
int CALLBACK NewWindowProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam ) { HDC hdc,khdc; HBITMAP oldbmp,newbmp; RECT rect; POINT p; HMENU hmenu; DWORD addr,index,i,count; switch(Msg) { case WM_ERASEBKGND: hdc=(HDC)wParam; newbmp = LoadBitmap(hin,MAKEINTRESOURCE(IDB_BITMAP1)); GetClientRect(hWnd,&rect); khdc = CreateCompatibleDC( hdc ); oldbmp = (HBITMAP)SelectObject(khdc,(HGDIOBJ)newbmp); BitBlt(hdc,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,khdc,rect.left,rect.top,SRCCOPY); SelectObject(khdc,(HGDIOBJ)oldbmp); DeleteObject(khdc); DeleteObject((HGDIOBJ)newbmp); FlashListBox(hWnd); return TRUE; case WM_KEYDOWN: if(wParam == VK_RETURN) ShowDisasmAddr(hWnd); else if(wParam == VK_F2) { index = SendMessage(hWnd,LB_GETCURSEL,0,0); addr = SendMessage(hWnd,LB_GETITEMDATA,index,0); addr ^= 0x80000000; SendMessage(hWnd,LB_SETITEMDATA,index,addr); Manualbreakpoint(addr&0x7fffffff,VK_F2,0,0,FIXEDFONT); } break; case WM_RBUTTONDOWN: p.x = lParam&0x0000ffff; p.y = lParam>>16; ClientToScreen(hWnd,&p); hmenu = MyCreatMenu(); TrackPopupMenu(hmenu,TPM_RIGHTBUTTON,p.x,p.y,0,hWnd,NULL); DestroyMenu(hmenu); break; case WM_LBUTTONDBLCLK: ShowDisasmAddr(hWnd); break; case WM_COMMAND: switch(LOWORD(wParam)) { case 200: ShowOriAddr(hWnd); break; case 201: ShowDisasmAddr(hWnd); break; case 203: MySetBreakpoint(hWnd,TRUE); break; case 204: index = SendMessage(hWnd,LB_GETCURSEL,0,0); addr = SendMessage(hWnd,LB_GETITEMDATA,index,0); if(DialogBox(hin,MAKEINTRESOURCE(IDD_DIALOG4),NULL,NameDlgProc)==1) { Insertname(addr&0x7fffffff,NM_COMMENT,note); } break; case 205: MyDeleteBreakpoint(hWnd,TRUE); break; case 206: index = SendMessage(hWnd,LB_GETCURSEL,0,0); addr = SendMessage(hWnd,LB_GETITEMDATA,index,0); Zero_Memory(note, 64); Insertname(addr&0x7fffffff,NM_COMMENT,note); break; case 207: MySetBreakpoint(hWnd,FALSE); break; case 208: count = SendMessage(hWnd,LB_GETCOUNT,0,0); if(DialogBox(hin,MAKEINTRESOURCE(IDD_DIALOG4),NULL,NameDlgProc)==1) { for(i=0;i<count;i++) { addr = SendMessage(hWnd,LB_GETITEMDATA,i,0); Insertname(addr&0x7fffffff,NM_COMMENT,note); } } break; case 209: MyDeleteBreakpoint(hWnd,FALSE); break; case 210: count = SendMessage(hWnd,LB_GETCOUNT,0,0); Zero_Memory(note, 64); for(i=0;i<count;i++) { addr = SendMessage(hWnd,LB_GETITEMDATA,i,0); Insertname(addr&0x7fffffff,NM_COMMENT,note); } break; } case WM_LBUTTONUP: case WM_VSCROLL: case WM_MOUSEWHEEL: InvalidateRect(hWnd,NULL,TRUE); } return CallWindowProc(OldListProc,hWnd,Msg,wParam,lParam); }
void mapfile_apply(list_t* names) { TCHAR* undecorated; ULONG total = 0, filtered = 0, applied = 0, addr; int err, result; name_t* nm, *nm_last; list_t* rmtable; module_t* module = module_info(&err); if (!err) { Addtolist(0, 0, "Applying names from map file to module '%s'", module->name); if (!g_Config->collisionchecks) { rmtable = list_create(); } nm = (name_t*)names->first; while (nm) { if (nm->segment < module->nseg) { if (g_Config->demangle) { undecorated = (TCHAR*)malloc(2 * nm->size * sizeof(TCHAR)); if (result = Demanglename(nm->buffer, NM_LIBRARY, undecorated)) { free(nm->buffer); nm->size = result + 1; nm->buffer = undecorated; } else { free(undecorated); } } addr = module->base + module->segments[nm->segment] + nm->offset; if (g_Config->usemasks) { if (result = mask_filter(nm)) { filtered++; if ((result & FILTER_SKIP) && !g_Config->collisionchecks && /* Findname for NM_ANYNAME fails everytime, dunno why */ (Findname(addr, NM_COMMENT, NULL) || Findname(addr, NM_LABEL, NULL))) { list_addname(rmtable, NULL, 0, nm->segment, nm->offset); total++; nm = nm->next; continue; } } } if (g_Config->comments) { if (g_Config->collisionchecks) { if (!Findname(addr, NM_COMMENT, NULL) && !Quickinsertname(addr, NM_COMMENT, nm->buffer)) { applied++; } } else if (!Quickinsertname(addr, NM_COMMENT, nm->buffer)) { applied++; } } if (g_Config->labels) { if (g_Config->collisionchecks) { if (!Findlabel(addr, NULL) && !Quickinsertname(addr, NM_LABEL, nm->buffer)) { applied++; } } else if (!Quickinsertname(addr, NM_LABEL, nm->buffer)) { applied++; } } } total++; Progress(total * 1000 / names->count, "Inserting names"); nm = nm->next; } Progress(0, ""); Infoline("Merging names"); Mergequicknames(); if (!g_Config->collisionchecks) { Infoline("Cleaning skipped entries"); nm = (name_t*)rmtable->first; while (nm) { addr = module->base + module->segments[nm->segment] + nm->offset; if (g_Config->comments) { Insertname(addr, NM_COMMENT, ""); } if (g_Config->labels) { Insertname(addr, NM_LABEL, ""); } nm_last = nm; nm = nm->next; /* Manual list_freenames expansion to speed it up somehow */ free(nm_last); } } Infoline("Total loaded: %d, Names applied: %d, Names filtered: %d", total, applied, filtered); Addtolist(0, -1, " Total loaded: %d, Names applied: %d, Names filtered: %d", total, applied, filtered); module_free(module); } else { module_error(err); } }
bool connector_pull (void) { int len; char buf [1024]; char data [1024]; int command; //ea_t address; ulong address; SOCKET connection; memset(buf, 0, sizeof(buf)); memset(data, 0, sizeof(data)); // grab the socket we wil be reading from. connection = connector->get_connection(); len = recv(connection, buf, sizeof(buf), 0); // connection closed. if (len == 0 || len == SOCKET_ERROR) { connector->cleanup(); //TODO: perhaps change to a MessageBox(): Message(0, "[!] "PLUGIN_NAME"> Socket read failed. Connection closed."); return false; } // null terminate the string. buf[len] = 0; // parse the inbound request. if we can't extract the correct fields, return. if (sscanf(buf, "%d:::%08x:::%1023[^\0]", &command, &address, data) != 3) return true; // // handle the received command appropriately // switch(command) { case IDA_SYNC_COMMAND_JUMPTO: Setdisasm(address, 0, 0); Redrawdisassembler(); break; case IDA_SYNC_COMMAND_NAME: Message(address, "[*] "PLUGIN_NAME"> Received new name (label) @%08x: %s", address, data); Insertname(address, NM_LABEL, data); Redrawdisassembler(); break; case IDA_SYNC_COMMAND_REG_COMMENT: case IDA_SYNC_COMMAND_REP_COMMENT: Message(address, "[*] "PLUGIN_NAME"> Received comment @%08x: %s", address, data); Insertname(address, NM_COMMENT, data); Redrawdisassembler(); break; default: Message(0, "[*] "PLUGIN_NAME"> Received unknown command code: %d, ignoring.", command); } // ping pong. let the server know we're alive? send(connection, "1", 1, 0); return true; }