void idaapi term(void) { msg(PLUGIN_NAME": collabREate is being unloaded\n"); authenticated = false; if (is_connected()) { msg(PLUGIN_NAME": calling cleanup\n"); cleanup(); msg(PLUGIN_NAME": back from cleanup\n"); } msg(PLUGIN_NAME": closing status form\n"); close_chooser("Collab form:1"); msg(PLUGIN_NAME": status form closed\n"); if (msgHistory.size() > 0) { qstring temp; for (unsigned int i = 0; i < msgHistory.size(); i++) { temp += msgHistory[i]; temp += '\n'; } cnn.setblob(temp.c_str(), temp.length() + 1, 1, COLLABREATE_MSGHISTORY_TAG); msgHistory.clear(); } if (changeCache != NULL && changeCache->length() > 0) { cnn.setblob(changeCache->c_str(), changeCache->length() + 1, 1, COLLABREATE_CACHE_TAG); delete changeCache; changeCache = NULL; } unhookAll(); }
void on_get_line(int lineno, char * const *line_arr) { // Called from s_getl, which itself can be called from the kernel. Ensure GIL PYW_GIL_GET; // Get headers? if ( lineno == 0 ) { // Copy the pre-parsed columns for ( size_t i=0; i < cols.size(); i++ ) qstrncpy(line_arr[i], cols[i].c_str(), MAXSTR); return; } // Clear buffer int ncols = int(cols.size()); for ( int i=ncols-1; i>=0; i-- ) line_arr[i][0] = '\0'; // Call Python PYW_GIL_CHECK_LOCKED_SCOPE(); newref_t list(PyObject_CallMethod(self, (char *)S_ON_GET_LINE, "i", lineno - 1)); if ( list == NULL ) return; // Go over the List returned by Python and convert to C strings for ( int i=ncols-1; i>=0; i-- ) { borref_t item(PyList_GetItem(list.o, Py_ssize_t(i))); if ( item == NULL ) continue; const char *str = PyString_AsString(item.o); if ( str != NULL ) qstrncpy(line_arr[i], str, MAXSTR); } }
//-------------------------------------------------------------------------- // // Initialize. // // IDA will call this function only once. // If this function returns PLGUIN_SKIP, IDA will never load it again. // If this function returns PLUGIN_OK, IDA will unload the plugin but // remember that the plugin agreed to work with the database. // The plugin will be loaded again if the user invokes it by // pressing the hotkey or selecting it from the menu. // After the second load the plugin will stay on memory. // If this function returns PLUGIN_KEEP, IDA will keep the plugin // in the memory. In this case the initialization function can hook // into the processor module and user interface notification points. // See the hook_to_notification_point() function. // // In this example we check the input file format and make the decision. // You may or may not check any other conditions to decide what you do: // whether you agree to work with the database or not. // int idaapi init(void) { unsigned char md5[MD5_LEN]; msg(PLUGIN_NAME": collabREate has been loaded\n"); //while the md5 is not used here, it has the side effect of ensuring //that the md5 is taken at the earliest opportunity for storage in //the database in the event that the original binary is deleted getFileMd5(md5, sizeof(md5)); unsigned char gpid[GPID_SIZE]; ssize_t sz = getGpid(gpid, sizeof(gpid)); if (sz > 0) { msg(PLUGIN_NAME": Operating in caching mode until connected.\n"); if (changeCache == NULL) { size_t sz = 0; void *tcache = cnn.getblob(NULL, &sz, 1, COLLABREATE_CACHE_TAG); if (tcache != NULL && sz > 0) { changeCache = new qstring((char*)tcache); } else { changeCache = new qstring(); } qfree(tcache); hookAll(); } } if (msgHistory.size() == 0) { size_t sz = 0; void *thist = cnn.getblob(NULL, &sz, 1, COLLABREATE_MSGHISTORY_TAG); if (thist != NULL && sz > 1) { char *sptr, *endp; sptr = (char*)thist; while ((endp = strchr(sptr, '\n')) != NULL) { msgHistory.push_back(qstring(sptr, endp - sptr)); sptr = endp + 1; } } qfree(thist); } build_handler_map(); if (init_network()) { return PLUGIN_KEEP; } else { return PLUGIN_SKIP; } }