Get ASM Code For IDA Pro Source Code

代码链接:http://code.google.com/p/get-asm-code/

☆版权☆

* 网站名称:obaby@mars
* 网址:https://obaby.org.cn/
* 个性:https://oba.by/
* 本文标题: 《Get ASM Code For IDA Pro Source Code》
* 本文链接:https://obaby.org.cn/2012/11/4781
* 短链接:https://oba.by/?p=4781
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


You may also like

1 comment

  1. 公主 Queen 
    Google Chrome 86 Google Chrome 86 Windows 10 Windows 10 cn中国–山东–青岛 联通

    代码:

    ///////////////////////////////////////////////////////////////////////////////
    //
    //  File     : Get AsmCode.cpp
    //  Author   : obaby
    //  Date     : 14/06/2012
    //  Homepage : http://www.h4ck.ws
    //  
    //  License  : Copyright ?2012 obaby@mars
    //
    //  This software is provided 'as-is', without any express or
    //  implied warranty. In no event will the authors be held liable
    //  for any damages arising from the use of this software.
    //
    ///////////////////////////////////////////////////////////////////////////////
    
    //-----------------------------------------------------------------------------
    
    #include "Get AsmCode.h"
    
    
    // Global Variables:
    int gSdkVersion;
    char gszVersion[]      = "1.0.0.1";
    // Plugin name listed in (Edit | Plugins)
    char gszWantedName[]   = "Get AsmCode";
    // plug-in hotkey
    char gszWantedHotKey[] = "Shift+A";
    
    char *gszPluginHelp;
    char *gszPluginComment;
    
    
    
    bool GetKernelVersion(char *szBuf, int bufSize)
    {
    	int major, minor, len;
    	get_kernel_version(szBuf, bufSize);
    	if ( qsscanf(szBuf, "%d.%n%d", &major, &len, &minor) != 2 )
    		return false;
    	if ( isdigit(szBuf[len + 1]) )
    		gSdkVersion = 100*major + minor;
    	else
    		gSdkVersion = 10 * (10*major + minor);
    	return true;
    }
    
    bool GenerateAsmLines(ea_t saddr,ea_t eaddr)
    {
    	int max_lines = 100;
    	char **myLines= new char *[max_lines];
    	int lnnum;
    	// Buffer that will hold the disassembly text
    	char buffer[MAXSTR];
    	// Store the disassembled text in buf
    	//generate_disasm_line(saddr, buffer, sizeof(buffer)-1);
    
    	// This will appear as colour-tagged text (which will
    	// be mostly unreadable in IDA's Log window)
    
    	/*for (ea_t i = saddr;i <= eaddr; i += get_item_size(i))
    	{
    		char clean_buf[MAXSTR];
    		
    		generate_disasm_line(i, buffer, sizeof(buffer)-1);
    		tag_remove(buffer,clean_buf,sizeof(clean_buf)-1);
    		msg("Line %0.2d: %s \n",i,clean_buf);
    	}*/
    	
    	for (ea_t i = saddr;i <= eaddr; i += get_item_size(i))
    	{
    		char clean_buf[MAXSTR];
    		int nlines = generate_disassembly(i,myLines,max_lines,&lnnum,MAKELINE_STACK);
    		for ( int j=0; jendEA;
    	saddr = func->startEA;
    	
    	get_func_name(saddr,funcName,sizeof(funcName)-1);
    
    	msg("Function %s start at 0x%0.8X ,end at 0x%0.8X .\n",funcName,saddr,eaddr);
    
    	if (eaddr == BADADDR || saddr == BADADDR)
    	{
    		warning("Can't Get Function start or end address,plz check ur selection!\n");
    		goto __Faild;
    	}
    	idbpath = database_idb;
    	asmfile = strcat(idbpath,"_part.asm");
    	fp = qfopen(asmfile, "w");
    	gen_file(OFILE_ASM,fp,saddr,eaddr,0); //����asm�ļ�
    	//gen_file(OFILE_ASM,fp,saddr,eaddr,GENFLG_ASMTYPE);
    	qfclose(fp);
    	msg("File is saved to :\n %s.\n",asmfile);
    
    __Faild:
    	msg("Generate Asmfile Finished.\n");
    	msg("--------------------------------------------------------------------------------------\n");
    //	msg("All returned lines %d!\n",nlines);
    //  Uncomment the following code to allow plugin unloading.
    //  This allows the editing/building of the plugin without
    //  restarting IDA.
    //
    //  1. to unload the plugin execute the following IDC statement:
    //        RunPlugin("Get AsmCode", 415);
    //  2. Make changes to source code and rebuild within Visual Studio
    //  3. Copy plugin to IDA plugin dir
    //     (may be automatic if option was selected within wizard)
    //  4. Run plugin via the menu, hotkey, or IDC statement
    //
    // 	if (arg == 415)
    // 	{
    // 		PLUGIN.flags |= PLUGIN_UNL;
    // 		msg("Unloading Get AsmCode plugin...\n");
    // 	}
    }
    
    ///////////////////////////////////////////////////////////////////////////////
    //
    //                         PLUGIN DESCRIPTION BLOCK
    //
    ///////////////////////////////////////////////////////////////////////////////
    plugin_t PLUGIN =
    {
      IDP_INTERFACE_VERSION,
      0,              // plugin flags
      initPlugin,           // initialize
      termPlugin,           // terminate. this pointer may be NULL.
      runPlugin,            // invoke plugin
      gszPluginComment,     // comment about the plugin
      gszPluginHelp,        // multiline help about the plugin
      gszWantedName,        // the preferred short name of the plugin
      gszWantedHotKey       // the preferred hotkey to run the plugin
    };
    
    
    

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注