diff --git a/src/common/PySocExplorer.h b/src/common/PySocExplorer.h --- a/src/common/PySocExplorer.h +++ b/src/common/PySocExplorer.h @@ -1,11 +1,12 @@ -#include -#include +#include +#include #include "qhexspinbox.h" #include "memsizewdgt.h" #include "qhexedit/qhexedit.h" #include "SocExplorerPlot.h" #include "tcp_terminal_client.h" #include "elf/elfparser.h" -#include "elf/abstractexecfile.h" +#include "abstractexecfile.h" #include "elf/elffile.h" #include "elf/elffilewidget.h" +#include "elf/elfinfowdgt.h" diff --git a/src/common/abstractexecfile.cpp b/src/common/abstractexecfile.cpp --- a/src/common/abstractexecfile.cpp +++ b/src/common/abstractexecfile.cpp @@ -21,17 +21,10 @@ ----------------------------------------------------------------------------*/ #include "abstractexecfile.h" -abstractExecFile::abstractExecFile() -{ -} - -abstractExecFile::abstractExecFile(const QString &File) -{ - -} - codeFragment::codeFragment() { - + data = NULL; + size = 0; + address = 0; } diff --git a/src/common/abstractexecfile.h b/src/common/abstractexecfile.h --- a/src/common/abstractexecfile.h +++ b/src/common/abstractexecfile.h @@ -22,26 +22,27 @@ #ifndef ABSTRACTEXECFILE_H #define ABSTRACTEXECFILE_H -#include +#include class codeFragment { public: codeFragment(); + codeFragment(char* data, quint32 size, quint32 address):data(data),size(size),address(address){} char* data; quint32 size; quint32 address; }; -class abstractExecFile +class abstractExecFile : public QObject { + Q_OBJECT public: - abstractExecFile(); - abstractExecFile(const QString& File); +// virtual abstractExecFile()=0; virtual bool openFile(const QString& File)=0; virtual bool isopened()=0; virtual int closeFile()=0; - virtual QList getFragments()=0; + virtual QList getFragments()=0; protected: QString p_fileName; diff --git a/src/common/common.pro b/src/common/common.pro --- a/src/common/common.pro +++ b/src/common/common.pro @@ -109,6 +109,9 @@ SOURCES += \ FORMS += \ elf/elffilewidget.ui +OTHER_FILES += \ + ./pythongenerator.sh \ + ./pythonQtgeneratorCfg.txt diff --git a/src/common/elf/elffile.cpp b/src/common/elf/elffile.cpp --- a/src/common/elf/elffile.cpp +++ b/src/common/elf/elffile.cpp @@ -23,38 +23,71 @@ ----------------------------------------------------------------------------*/ #include "elffile.h" -ElfFile::ElfFile(QObject *parent) - :QObject(parent),abstractExecFile(),elfparser() +ElfFile::ElfFile() + :abstractExecFile() { + this->opened = false; + this->type_elf = false; + this->elfFile = NULL; + this->e = NULL; } -ElfFile::ElfFile(const QString &File, QObject *parent) - :QObject(parent),abstractExecFile(),elfparser() +ElfFile::ElfFile(const QString &File) + :abstractExecFile() { + this->opened = false; + this->type_elf = false; + this->elfFile = NULL; + this->e = NULL; this->p_fileName = File; - setFilename(File); + openFile(File); } bool ElfFile::openFile(const QString &File) { this->p_fileName = File; - return setFilename(File); + this->closeFile(); + if(elf_version(EV_CURRENT)==EV_NONE)return 0; +#ifdef _ELF_WINDOWS_ + this->elfFile = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0); +#else + this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0); +#endif + if(this->elfFile==NULL)return 0; + this->e = elf_begin(this->elfFile,ELF_C_READ,NULL); + if(this->e==NULL)return 0; + this->ek = elf_kind(this->e); + gelf_getehdr (this->e, &this->ehdr ); + elf_getshdrstrndx (this->e, &this->shstrndx); + this->updateSegments(); + this->updateSections(); + return 1; } bool ElfFile::isopened() { - return elfparser::isopened(); + return this->opened; } int ElfFile::closeFile() { - return elfparser::closeFile(); + if(this->elfFile!=NULL) + { + if(this->e!=NULL) + { + elf_end(this->e); + this->e = NULL; + } + close(this->elfFile); + this->elfFile = NULL; + } + return 0; } -QList ElfFile::getFragments(QStringList fragmentList) +QList ElfFile::getFragments(QStringList fragmentList) { - QList fragments; + QList fragments; if (isopened()) { for(int i =0;i ElfFile::getFragment return fragments; } -QList ElfFile::getFragments() +QList ElfFile::getFragments() { return getFragments(QStringList()<<".data"<<".text"); } -codeFragment ElfFile::getFragment(const QString &name) +codeFragment *ElfFile::getFragment(const QString &name) { - codeFragment fragment; + codeFragment* fragment= new codeFragment(); for(int i=0;idata =NULL; + fragment->size = getSectionDatasz(i); + fragment->address = getSectionPaddr(i); + getSectionData(i,&fragment->data); } } @@ -92,10 +125,687 @@ codeFragment ElfFile::getFragment(const +QString elfresolveMachine(Elf64_Half e_machine) +{ + QString machineName; + //Update from with bash script don't write it by yourself! + switch(e_machine) + { + case EM_NONE: + machineName = " No machine "; + break; + case EM_M32: + machineName = " AT&T WE 32100 "; + break; + case EM_SPARC: + machineName = " SUN SPARC "; + break; + case EM_386: + machineName = " Intel 80386 "; + break; + case EM_68K: + machineName = " Motorola m68k family "; + break; + case EM_88K: + machineName = " Motorola m88k family "; + break; + case EM_860: + machineName = " Intel 80860 "; + break; + case EM_MIPS: + machineName = " MIPS R3000 big-endian "; + break; + case EM_S370: + machineName = " IBM System/370 "; + break; + case EM_MIPS_RS3_LE: + machineName = " MIPS R3000 little-endian "; + break; + case EM_PARISC: + machineName = " HPPA "; + break; + case EM_VPP500: + machineName = " Fujitsu VPP500 "; + break; + case EM_SPARC32PLUS: + machineName = " Sun's \"v8plus\" "; + break; + case EM_960: + machineName = " Intel 80960 "; + break; + case EM_PPC: + machineName = " PowerPC "; + break; + case EM_PPC64: + machineName = " PowerPC 64-bit "; + break; + case EM_S390: + machineName = " IBM S390 "; + break; + case EM_V800: + machineName = " NEC V800 series "; + break; + case EM_FR20: + machineName = " Fujitsu FR20 "; + break; + case EM_RH32: + machineName = " TRW RH-32 "; + break; + case EM_RCE: + machineName = " Motorola RCE "; + break; + case EM_ARM: + machineName = " ARM "; + break; + case EM_FAKE_ALPHA: + machineName = " Digital Alpha "; + break; + case EM_SH: + machineName = " Hitachi SH "; + break; + case EM_SPARCV9: + machineName = " SPARC v9 64-bit "; + break; + case EM_TRICORE: + machineName = " Siemens Tricore "; + break; + case EM_ARC: + machineName = " Argonaut RISC Core "; + break; + case EM_H8_300: + machineName = " Hitachi H8/300 "; + break; + case EM_H8_300H: + machineName = " Hitachi H8/300H "; + break; + case EM_H8S: + machineName = " Hitachi H8S "; + break; + case EM_H8_500: + machineName = " Hitachi H8/500 "; + break; + case EM_IA_64: + machineName = " Intel Merced "; + break; + case EM_MIPS_X: + machineName = " Stanford MIPS-X "; + break; + case EM_COLDFIRE: + machineName = " Motorola Coldfire "; + break; + case EM_68HC12: + machineName = " Motorola M68HC12 "; + break; + case EM_MMA: + machineName = " Fujitsu MMA Multimedia Accelerator"; + break; + case EM_PCP: + machineName = " Siemens PCP "; + break; + case EM_NCPU: + machineName = " Sony nCPU embeeded RISC "; + break; + case EM_NDR1: + machineName = " Denso NDR1 microprocessor "; + break; + case EM_STARCORE: + machineName = " Motorola Start*Core processor "; + break; + case EM_ME16: + machineName = " Toyota ME16 processor "; + break; + case EM_ST100: + machineName = " STMicroelectronic ST100 processor "; + break; + case EM_TINYJ: + machineName = " Advanced Logic Corp. Tinyj emb.fam"; + break; + case EM_X86_64: + machineName = " AMD x86-64 architecture "; + break; + case EM_PDSP: + machineName = " Sony DSP Processor "; + break; + case EM_FX66: + machineName = " Siemens FX66 microcontroller "; + break; + case EM_ST9PLUS: + machineName = " STMicroelectronics ST9+ 8/16 mc "; + break; + case EM_ST7: + machineName = " STmicroelectronics ST7 8 bit mc "; + break; + case EM_68HC16: + machineName = " Motorola MC68HC16 microcontroller "; + break; + case EM_68HC11: + machineName = " Motorola MC68HC11 microcontroller "; + break; + case EM_68HC08: + machineName = " Motorola MC68HC08 microcontroller "; + break; + case EM_68HC05: + machineName = " Motorola MC68HC05 microcontroller "; + break; + case EM_SVX: + machineName = " Silicon Graphics SVx "; + break; + case EM_ST19: + machineName = " STMicroelectronics ST19 8 bit mc "; + break; + case EM_VAX: + machineName = " Digital VAX "; + break; + case EM_CRIS: + machineName = " Axis Communications 32-bit embedded processor "; + break; + case EM_JAVELIN: + machineName = " Infineon Technologies 32-bit embedded processor "; + break; + case EM_FIREPATH: + machineName = " Element 14 64-bit DSP Processor "; + break; + case EM_ZSP: + machineName = " LSI Logic 16-bit DSP Processor "; + break; + case EM_MMIX: + machineName = " Donald Knuth's educational 64-bit processor "; + break; + case EM_HUANY: + machineName = " Harvard University machine-independent object files "; + break; + case EM_PRISM: + machineName = " SiTera Prism "; + break; + case EM_AVR: + machineName = " Atmel AVR 8-bit microcontroller "; + break; + case EM_FR30: + machineName = " Fujitsu FR30 "; + break; + case EM_D10V: + machineName = " Mitsubishi D10V "; + break; + case EM_D30V: + machineName = " Mitsubishi D30V "; + break; + case EM_V850: + machineName = " NEC v850 "; + break; + case EM_M32R: + machineName = " Mitsubishi M32R "; + break; + case EM_MN10300: + machineName = " Matsushita MN10300 "; + break; + case EM_MN10200: + machineName = " Matsushita MN10200 "; + break; + case EM_PJ: + machineName = " picoJava "; + break; + case EM_OPENRISC: + machineName = " OpenRISC 32-bit embedded processor "; + break; + case EM_ARC_A5: + machineName = " ARC Cores Tangent-A5 "; + break; + case EM_XTENSA: + machineName = " Tensilica Xtensa Architecture "; + break; + case EM_AARCH64: + machineName = " ARM AARCH64 "; + break; + case EM_TILEPRO: + machineName = " Tilera TILEPro "; + break; + case EM_MICROBLAZE: + machineName = " Xilinx MicroBlaze "; + break; + case EM_TILEGX: + machineName = " Tilera TILE-Gx "; + break; + case EM_NUM: + machineName = ""; + break; + default: + machineName ="Unknow Machine"; + break; + } + return machineName; +} + + + + +QString ElfFile::getClass() +{ + if(this->e!=NULL) + { + int eclass = gelf_getclass(this->e); + if(eclass==ELFCLASS32)return "ELF32"; + if(eclass==ELFCLASS64)return "ELF64"; + } + return "none"; +} + + +bool ElfFile::iself() +{ + return this->type_elf; +} + +QString ElfFile::getArchitecture() +{ + if(this->e!=NULL) + { + return elfresolveMachine(this->ehdr.e_machine); + } + return ""; +} + + +QString ElfFile::getType() +{ + QString kind(""); + if(this->e!=NULL) + { + switch(this->ek) + { + case ELF_K_AR: + kind = "Archive"; + break; + case ELF_K_ELF: + kind = "Elf"; + break; + case ELF_K_COFF: + kind = "COFF"; + break; + case ELF_K_NUM: + kind = "NUM"; + break; + case ELF_K_NONE: + kind = "Data"; + break; + default: + kind = "Unknow"; + break; + } + } + return kind; +} + +QString ElfFile::getEndianness() +{ + if(this->e!=NULL) + { + if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian"; + if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian"; + } + return "none"; +} + +QString ElfFile::getABI() +{ + if(this->e!=NULL) + { + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application"; + } + return "none"; +} + + +qint64 ElfFile::getVersion() +{ + if(this->e!=NULL) + { + return this->ehdr.e_version; + } +} + +qint64 ElfFile::getEntryPointAddress() +{ + if(this->e!=NULL) + { + return this->ehdr.e_entry; + } +} + + +int ElfFile::getSectioncount() +{ + return (int)this->SectionCount; +} + + +int ElfFile::getSegmentcount() +{ + return (int)this->SegmentCount; +} + + +QString ElfFile::getSegmentType(int index) +{ + QString type(""); + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + switch(this->Segments.at(index)->p_type) + { + case PT_NULL: + type = "Program header table entry unused"; + break; + case PT_LOAD: + type = "Loadable program segment"; + break; + case PT_DYNAMIC : + type = "Dynamic linking information"; + break; + case PT_INTERP: + type ="Program interpreter"; + break; + case PT_NOTE: + type = "Auxiliary information"; + break; + case PT_SHLIB: + type = "Reserved"; + break; + case PT_PHDR: + type = "Entry for header table itself"; + break; + case PT_TLS: + type = "Thread-local storage segment"; + break; + case PT_NUM: + type = "Number of defined types"; + break; + case PT_LOOS: + type = "Start of OS-specific"; + break; + case PT_SUNWSTACK: + type = "Stack segment"; + break; + case PT_LOPROC: + type = "Start of processor-specific"; + break; + case PT_HIPROC: + type = "End of processor-specific"; + break; + default: + type = "Unknow Section Type"; + break; + } + } + } + + return type; +} + + +qint64 ElfFile::getSegmentOffset(int index) +{ + int64_t Offset; + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + Offset = (int64_t)this->Segments.at(index)->p_offset; + } + } + return Offset; +} + + +qint64 ElfFile::getSegmentVaddr(int index) +{ + int64_t Vaddr = 0; + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + Vaddr = (int64_t)this->Segments.at(index)->p_vaddr; + } + } + return Vaddr; +} + + +qint64 ElfFile::getSegmentPaddr(int index) +{ + int64_t Paddr=0; + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + Paddr = (int64_t)this->Segments.at(index)->p_paddr; + } + } + return Paddr; +} + +qint64 ElfFile::getSectionPaddr(int index) +{ + int64_t Paddr=0; + if(this->e!=NULL) + { + if(index < this->sections.count()) + { + Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr; + } + } + return Paddr; +} + + +qint64 ElfFile::getSegmentFilesz(int index) +{ + int64_t FileSz=0; + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + FileSz = (int64_t)this->Segments.at(index)->p_filesz; + } + } + return FileSz; +} + +qint64 ElfFile::getSectionDatasz(int index) +{ + int64_t DataSz=0; + if(this->e!=NULL) + { + if(index < this->sections.count()) + { + DataSz = (int64_t)this->sections.at(index)->data->d_size; + } + } + return DataSz; +} + +bool ElfFile::getSectionData(int index, char **buffer) +{ + if(this->e!=NULL) + { + if(index < this->sections.count()) + { + *buffer = (char *)this->sections.at(index)->data->d_buf; + return true; + } + } + return false; +} + + +qint64 ElfFile::getSegmentMemsz(int index) +{ + int64_t MemSz=0; + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + MemSz = (int64_t)this->Segments.at(index)->p_memsz; + } + } + return MemSz; +} + +qint64 ElfFile::getSectionMemsz(int index) +{ + int64_t MemSz=0; + if(this->e!=NULL) + { + if(index < this->sections.count()) + { + MemSz = (int64_t)this->sections.at(index)->section_header->sh_size; + } + } + return MemSz; +} + + +QString ElfFile::getSegmentFlags(int index) +{ + QString flags(""); + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x"; + if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w"; + if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r"; + if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific"; + if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific"; + } + } + return flags; +} + + +QString ElfFile::getSectionName(int index) +{ + char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name); + return QString(nameChr); +} + + +void ElfFile::updateSections() +{ + for(int i=0;isections.count();i++) + { + delete this->sections.at(i); + } + this->sections.clear(); + this->scn = elf_nextscn (this->e , NULL ); + this->SectionCount = 0; + while( this->scn != NULL ) + { + GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr)); + gelf_getshdr ( this->scn , shdr ); + Elf_Data* data = elf_getdata(this->scn, NULL); + this->sections.append(new Elf_Section(data,shdr)); + this->SectionCount+=1; + this->scn = elf_nextscn(e , scn); + } +} + + +void ElfFile::updateSegments() +{ + elf_getphdrnum (this->e , &this->SegmentCount); + for(int i=0;iSegments.count();i++) + { + free(this->Segments.at(i)); + } + this->Segments.clear(); + for(int i=0;iSegmentCount;i++) + { + GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr)); + gelf_getphdr (this->e , i , header ); + this->Segments.append(header); + } +} +QString ElfFile::getSectionType(int index) +{ + QString type(""); + if(this->e!=NULL) + { + if(index < this->Segments.count()) + { + switch(this->Segments.at(index)->p_type) + { + case SHT_NULL : type = "Section header table entry unused"; break; + case SHT_PROGBITS : type = "Program data"; break; + case SHT_SYMTAB : type = "Symbol table"; break; + case SHT_STRTAB : type = "String table"; break; + case SHT_RELA : type = "Relocation entries with addends"; break; + case SHT_HASH : type = "Symbol hash table"; break; + case SHT_DYNAMIC : type = "Dynamic linking information"; break; + case SHT_NOTE : type = "Notes"; break; + case SHT_NOBITS :type = "Program space with no data (bss)"; break; + case SHT_REL :type = "Relocation entries, no addends"; break; + case SHT_SHLIB : type = "Reserved"; break; + case SHT_DYNSYM : type = "Dynamic linker symbol table"; break; + case SHT_INIT_ARRAY : type = "Array of constructors"; break; + case SHT_FINI_ARRAY : type = "Array of destructors"; break; + case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break; + case SHT_GROUP : type = "Section group"; break; + case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break; + case SHT_NUM : type = "Number of defined types. "; break; + case SHT_LOOS : type = "Start OS-specific. "; break; + case SHT_LOSUNW : type = "Sun-specific low bound. "; break; + case SHT_SUNW_COMDAT : type = " "; break; + case SHT_SUNW_syminfo : type = " "; break; + case SHT_GNU_verdef : type = "Version definition section. "; break; + case SHT_GNU_verneed : type = "Version needs section. "; break; + case SHT_GNU_versym : type = "Version symbol table. "; break; + case SHT_LOPROC : type = "Start of processor-specific"; break; + case SHT_HIPROC : type = "End of processor-specific"; break; + case SHT_HIUSER : type = "End of application-specific"; break; + } + } + } + return type; +} - +bool ElfFile::isElf(const QString &File) +{ + int file =0; +#ifdef _ELF_WINDOWS_ + file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0); +#else + file = open(File.toStdString().c_str(),O_RDONLY ,0); +#endif + char Magic[4]; + if(file!=-1) + { + read(file,Magic,4); + close(file); + if(Magic[0]==0x7f && Magic[1]==0x45 && Magic[2]==0x4c && Magic[3]==0x46) + { + return true; + } + } + return false; +} diff --git a/src/common/elf/elffile.h b/src/common/elf/elffile.h --- a/src/common/elf/elffile.h +++ b/src/common/elf/elffile.h @@ -20,31 +20,82 @@ -- Mail : alexis.jeandet@member.fsf.org ----------------------------------------------------------------------------*/ #include -#include -#include "elfparser.h" -#include - +#include +#include +#include +#include +#include +#include +#include +#include #ifndef ELFFILE_H #define ELFFILE_H -class ElfFile :public QObject, public abstractExecFile, public elfparser +class Elf_Section { - Q_OBJECT public: - ElfFile(QObject *parent = 0); - ElfFile(const QString& File,QObject *parent = 0); + Elf_Section(){} + Elf_Section(Elf_Data* data,GElf_Shdr* section_header) + { + this->data = data; + this->section_header = section_header; + } + Elf_Data* data; + GElf_Shdr* section_header; +}; + +class ElfFile : public abstractExecFile +{ + Q_OBJECT +public: + ElfFile(); + ElfFile(const QString& File); bool openFile(const QString& File); bool isopened(); int closeFile(); - QList getFragments(); - QList getFragments(QStringList fragmentList); -// elfparser parser; + QList getFragments(); + QList getFragments(QStringList fragmentList); -signals: + QString getClass(); + QString getArchitecture(); + QString getType(); + QString getEndianness(); + QString getABI(); + qint64 getVersion(); + qint64 getEntryPointAddress(); + int getSectioncount(); + int getSegmentcount(); + QString getSegmentType(int index); + qint64 getSegmentOffset(int index); + qint64 getSegmentVaddr(int index); + qint64 getSegmentPaddr(int index); + qint64 getSectionPaddr(int index); + qint64 getSegmentFilesz(int index); + qint64 getSectionDatasz(int index); + bool getSectionData(int index, char **buffer); + qint64 getSegmentMemsz(int index); + qint64 getSectionMemsz(int index); + QString getSegmentFlags(int index); + QString getSectionName(int index); + QString getSectionType(int index); + bool iself(); + static bool isElf(const QString& File); -public slots: private: - codeFragment getFragment(const QString& name); + codeFragment* getFragment(const QString& name); + void updateSections(); + void updateSegments(); + int elfFile; + bool opened; + bool type_elf; + Elf* e; + Elf_Kind ek; + GElf_Ehdr ehdr; + Elf_Scn * scn; + Elf_Data * data; + size_t SectionCount,SegmentCount, shstrndx; + QList Segments; + QList sections; }; diff --git a/src/common/elf/elffilewidget.h b/src/common/elf/elffilewidget.h --- a/src/common/elf/elffilewidget.h +++ b/src/common/elf/elffilewidget.h @@ -1,7 +1,7 @@ #ifndef ELFFILEWIDGET_H #define ELFFILEWIDGET_H -#include +#include #include "elffile.h" namespace Ui { @@ -13,8 +13,9 @@ class elfFileWidget : public QWidget Q_OBJECT public: - explicit elfFileWidget(QWidget *parent = 0); + elfFileWidget(QWidget *parent = 0); ~elfFileWidget(); + public slots: void updateElfFile(ElfFile* file); diff --git a/src/common/elf/elfparser.cpp b/src/common/elf/elfparser.cpp --- a/src/common/elf/elfparser.cpp +++ b/src/common/elf/elfparser.cpp @@ -25,255 +25,7 @@ #include #include -QString elfresolveMachine(Elf64_Half e_machine) -{ - QString machineName; - //Update from with bash script don't write it by yourself! - switch(e_machine) - { - case EM_NONE: - machineName = " No machine "; - break; - case EM_M32: - machineName = " AT&T WE 32100 "; - break; - case EM_SPARC: - machineName = " SUN SPARC "; - break; - case EM_386: - machineName = " Intel 80386 "; - break; - case EM_68K: - machineName = " Motorola m68k family "; - break; - case EM_88K: - machineName = " Motorola m88k family "; - break; - case EM_860: - machineName = " Intel 80860 "; - break; - case EM_MIPS: - machineName = " MIPS R3000 big-endian "; - break; - case EM_S370: - machineName = " IBM System/370 "; - break; - case EM_MIPS_RS3_LE: - machineName = " MIPS R3000 little-endian "; - break; - case EM_PARISC: - machineName = " HPPA "; - break; - case EM_VPP500: - machineName = " Fujitsu VPP500 "; - break; - case EM_SPARC32PLUS: - machineName = " Sun's \"v8plus\" "; - break; - case EM_960: - machineName = " Intel 80960 "; - break; - case EM_PPC: - machineName = " PowerPC "; - break; - case EM_PPC64: - machineName = " PowerPC 64-bit "; - break; - case EM_S390: - machineName = " IBM S390 "; - break; - case EM_V800: - machineName = " NEC V800 series "; - break; - case EM_FR20: - machineName = " Fujitsu FR20 "; - break; - case EM_RH32: - machineName = " TRW RH-32 "; - break; - case EM_RCE: - machineName = " Motorola RCE "; - break; - case EM_ARM: - machineName = " ARM "; - break; - case EM_FAKE_ALPHA: - machineName = " Digital Alpha "; - break; - case EM_SH: - machineName = " Hitachi SH "; - break; - case EM_SPARCV9: - machineName = " SPARC v9 64-bit "; - break; - case EM_TRICORE: - machineName = " Siemens Tricore "; - break; - case EM_ARC: - machineName = " Argonaut RISC Core "; - break; - case EM_H8_300: - machineName = " Hitachi H8/300 "; - break; - case EM_H8_300H: - machineName = " Hitachi H8/300H "; - break; - case EM_H8S: - machineName = " Hitachi H8S "; - break; - case EM_H8_500: - machineName = " Hitachi H8/500 "; - break; - case EM_IA_64: - machineName = " Intel Merced "; - break; - case EM_MIPS_X: - machineName = " Stanford MIPS-X "; - break; - case EM_COLDFIRE: - machineName = " Motorola Coldfire "; - break; - case EM_68HC12: - machineName = " Motorola M68HC12 "; - break; - case EM_MMA: - machineName = " Fujitsu MMA Multimedia Accelerator"; - break; - case EM_PCP: - machineName = " Siemens PCP "; - break; - case EM_NCPU: - machineName = " Sony nCPU embeeded RISC "; - break; - case EM_NDR1: - machineName = " Denso NDR1 microprocessor "; - break; - case EM_STARCORE: - machineName = " Motorola Start*Core processor "; - break; - case EM_ME16: - machineName = " Toyota ME16 processor "; - break; - case EM_ST100: - machineName = " STMicroelectronic ST100 processor "; - break; - case EM_TINYJ: - machineName = " Advanced Logic Corp. Tinyj emb.fam"; - break; - case EM_X86_64: - machineName = " AMD x86-64 architecture "; - break; - case EM_PDSP: - machineName = " Sony DSP Processor "; - break; - case EM_FX66: - machineName = " Siemens FX66 microcontroller "; - break; - case EM_ST9PLUS: - machineName = " STMicroelectronics ST9+ 8/16 mc "; - break; - case EM_ST7: - machineName = " STmicroelectronics ST7 8 bit mc "; - break; - case EM_68HC16: - machineName = " Motorola MC68HC16 microcontroller "; - break; - case EM_68HC11: - machineName = " Motorola MC68HC11 microcontroller "; - break; - case EM_68HC08: - machineName = " Motorola MC68HC08 microcontroller "; - break; - case EM_68HC05: - machineName = " Motorola MC68HC05 microcontroller "; - break; - case EM_SVX: - machineName = " Silicon Graphics SVx "; - break; - case EM_ST19: - machineName = " STMicroelectronics ST19 8 bit mc "; - break; - case EM_VAX: - machineName = " Digital VAX "; - break; - case EM_CRIS: - machineName = " Axis Communications 32-bit embedded processor "; - break; - case EM_JAVELIN: - machineName = " Infineon Technologies 32-bit embedded processor "; - break; - case EM_FIREPATH: - machineName = " Element 14 64-bit DSP Processor "; - break; - case EM_ZSP: - machineName = " LSI Logic 16-bit DSP Processor "; - break; - case EM_MMIX: - machineName = " Donald Knuth's educational 64-bit processor "; - break; - case EM_HUANY: - machineName = " Harvard University machine-independent object files "; - break; - case EM_PRISM: - machineName = " SiTera Prism "; - break; - case EM_AVR: - machineName = " Atmel AVR 8-bit microcontroller "; - break; - case EM_FR30: - machineName = " Fujitsu FR30 "; - break; - case EM_D10V: - machineName = " Mitsubishi D10V "; - break; - case EM_D30V: - machineName = " Mitsubishi D30V "; - break; - case EM_V850: - machineName = " NEC v850 "; - break; - case EM_M32R: - machineName = " Mitsubishi M32R "; - break; - case EM_MN10300: - machineName = " Matsushita MN10300 "; - break; - case EM_MN10200: - machineName = " Matsushita MN10200 "; - break; - case EM_PJ: - machineName = " picoJava "; - break; - case EM_OPENRISC: - machineName = " OpenRISC 32-bit embedded processor "; - break; - case EM_ARC_A5: - machineName = " ARC Cores Tangent-A5 "; - break; - case EM_XTENSA: - machineName = " Tensilica Xtensa Architecture "; - break; - case EM_AARCH64: - machineName = " ARM AARCH64 "; - break; - case EM_TILEPRO: - machineName = " Tilera TILEPro "; - break; - case EM_MICROBLAZE: - machineName = " Xilinx MicroBlaze "; - break; - case EM_TILEGX: - machineName = " Tilera TILE-Gx "; - break; - case EM_NUM: - machineName = ""; - break; - default: - machineName ="Unknow Machine"; - break; - } - return machineName; -} +extern QString elfresolveMachine(Elf64_Half e_machine); elfparser::elfparser() @@ -420,7 +172,7 @@ QString elfparser::getABI() } -qint32 elfparser::getVersion() +qint64 elfparser::getVersion() { if(this->e!=NULL) { diff --git a/src/common/elf/elfparser.h b/src/common/elf/elfparser.h --- a/src/common/elf/elfparser.h +++ b/src/common/elf/elfparser.h @@ -27,19 +27,7 @@ #include #include #include - -class Elf_Section -{ -public: - Elf_Section(){} - Elf_Section(Elf_Data* data,GElf_Shdr* section_header) - { - this->data = data; - this->section_header = section_header; - } - Elf_Data* data; - GElf_Shdr* section_header; -}; +#include "elffile.h" class elfparser { @@ -54,7 +42,7 @@ public: QString getType(); QString getEndianness(); QString getABI(); - qint32 getVersion(); + qint64 getVersion(); qint64 getEntryPointAddress(); int getSectioncount(); int getSegmentcount(); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp @@ -3,29 +3,277 @@ #include #include #include +#include #include +#include -ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(QObject* parent) +PythonQtShell_ElfFile::~PythonQtShell_ElfFile() { + PythonQtPrivate* priv = PythonQt::priv(); + if (priv) { priv->shellClassDeleted(this); } +} +int PythonQtShell_ElfFile::closeFile() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "closeFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"int"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + int returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("closeFile", methodInfo, result); + } else { + returnValue = *((int*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return ElfFile::closeFile(); +} +QList PythonQtShell_ElfFile::getFragments() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "getFragments"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"QList"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + QList returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("getFragments", methodInfo, result); + } else { + returnValue = *((QList*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return ElfFile::getFragments(); +} +bool PythonQtShell_ElfFile::isopened() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "isopened"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + bool returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("isopened", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return ElfFile::isopened(); +} +bool PythonQtShell_ElfFile::openFile(const QString& File) +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "openFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool" , "const QString&"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList); + bool returnValue; + void* args[2] = {NULL, (void*)&File}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("openFile", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return ElfFile::openFile(File); +} +ElfFile* PythonQtWrapper_ElfFile::new_ElfFile() { -return new ElfFile(parent); } +return new PythonQtShell_ElfFile(); } -ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(const QString& File, QObject* parent) +ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(const QString& File) { -return new ElfFile(File, parent); } +return new PythonQtShell_ElfFile(File); } int PythonQtWrapper_ElfFile::closeFile(ElfFile* theWrappedObject) { - return ( theWrappedObject->closeFile()); + return ( ((PythonQtPublicPromoter_ElfFile*)theWrappedObject)->promoted_closeFile()); +} + +QString PythonQtWrapper_ElfFile::getABI(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getABI()); +} + +QString PythonQtWrapper_ElfFile::getArchitecture(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getArchitecture()); +} + +QString PythonQtWrapper_ElfFile::getClass(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getClass()); +} + +QString PythonQtWrapper_ElfFile::getEndianness(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getEndianness()); +} + +qint64 PythonQtWrapper_ElfFile::getEntryPointAddress(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getEntryPointAddress()); +} + +QList PythonQtWrapper_ElfFile::getFragments(ElfFile* theWrappedObject) +{ + return ( ((PythonQtPublicPromoter_ElfFile*)theWrappedObject)->promoted_getFragments()); +} + +QList PythonQtWrapper_ElfFile::getFragments(ElfFile* theWrappedObject, QStringList fragmentList) +{ + return ( theWrappedObject->getFragments(fragmentList)); +} + +bool PythonQtWrapper_ElfFile::getSectionData(ElfFile* theWrappedObject, int index, char** buffer) +{ + return ( theWrappedObject->getSectionData(index, buffer)); +} + +qint64 PythonQtWrapper_ElfFile::getSectionDatasz(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionDatasz(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSectionMemsz(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionMemsz(index)); +} + +QString PythonQtWrapper_ElfFile::getSectionName(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionName(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSectionPaddr(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionPaddr(index)); +} + +QString PythonQtWrapper_ElfFile::getSectionType(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionType(index)); +} + +int PythonQtWrapper_ElfFile::getSectioncount(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getSectioncount()); +} + +qint64 PythonQtWrapper_ElfFile::getSegmentFilesz(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentFilesz(index)); +} + +QString PythonQtWrapper_ElfFile::getSegmentFlags(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentFlags(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSegmentMemsz(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentMemsz(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSegmentOffset(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentOffset(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSegmentPaddr(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentPaddr(index)); +} + +QString PythonQtWrapper_ElfFile::getSegmentType(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentType(index)); +} + +qint64 PythonQtWrapper_ElfFile::getSegmentVaddr(ElfFile* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentVaddr(index)); +} + +int PythonQtWrapper_ElfFile::getSegmentcount(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getSegmentcount()); +} + +QString PythonQtWrapper_ElfFile::getType(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getType()); +} + +qint64 PythonQtWrapper_ElfFile::getVersion(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->getVersion()); +} + +bool PythonQtWrapper_ElfFile::static_ElfFile_isElf(const QString& File) +{ + return (ElfFile::isElf(File)); +} + +bool PythonQtWrapper_ElfFile::iself(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->iself()); } bool PythonQtWrapper_ElfFile::isopened(ElfFile* theWrappedObject) { - return ( theWrappedObject->isopened()); + return ( ((PythonQtPublicPromoter_ElfFile*)theWrappedObject)->promoted_isopened()); } bool PythonQtWrapper_ElfFile::openFile(ElfFile* theWrappedObject, const QString& File) { - return ( theWrappedObject->openFile(File)); + return ( ((PythonQtPublicPromoter_ElfFile*)theWrappedObject)->promoted_openFile(File)); } @@ -473,12 +721,150 @@ QString PythonQtWrapper_XByteArray::toR +PythonQtShell_abstractExecFile::~PythonQtShell_abstractExecFile() { + PythonQtPrivate* priv = PythonQt::priv(); + if (priv) { priv->shellClassDeleted(this); } +} +int PythonQtShell_abstractExecFile::closeFile() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "closeFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"int"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + int returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("closeFile", methodInfo, result); + } else { + returnValue = *((int*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return int(); +} +QList PythonQtShell_abstractExecFile::getFragments() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "getFragments"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"QList"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + QList returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("getFragments", methodInfo, result); + } else { + returnValue = *((QList*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return QList(); +} +bool PythonQtShell_abstractExecFile::isopened() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "isopened"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + bool returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("isopened", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return bool(); +} +bool PythonQtShell_abstractExecFile::openFile(const QString& File) +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "openFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool" , "const QString&"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList); + bool returnValue; + void* args[2] = {NULL, (void*)&File}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("openFile", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return bool(); +} +abstractExecFile* PythonQtWrapper_abstractExecFile::new_abstractExecFile() +{ +return new PythonQtShell_abstractExecFile(); } + + + +PythonQtShell_codeFragment::~PythonQtShell_codeFragment() { + PythonQtPrivate* priv = PythonQt::priv(); + if (priv) { priv->shellClassDeleted(this); } +} +codeFragment* PythonQtWrapper_codeFragment::new_codeFragment() +{ +return new PythonQtShell_codeFragment(); } + + + elfFileWidget* PythonQtWrapper_elfFileWidget::new_elfFileWidget(QWidget* parent) { return new elfFileWidget(parent); } +elfInfoWdgt* PythonQtWrapper_elfInfoWdgt::new_elfInfoWdgt(QWidget* parent) +{ +return new elfInfoWdgt(parent); } + + + elfparser* PythonQtWrapper_elfparser::new_elfparser() { return new elfparser(); } @@ -508,16 +894,36 @@ QString PythonQtWrapper_elfparser::getE return ( theWrappedObject->getEndianness()); } +qint64 PythonQtWrapper_elfparser::getEntryPointAddress(elfparser* theWrappedObject) +{ + return ( theWrappedObject->getEntryPointAddress()); +} + bool PythonQtWrapper_elfparser::getSectionData(elfparser* theWrappedObject, int index, char** buffer) { return ( theWrappedObject->getSectionData(index, buffer)); } +qint64 PythonQtWrapper_elfparser::getSectionDatasz(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionDatasz(index)); +} + +qint64 PythonQtWrapper_elfparser::getSectionMemsz(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionMemsz(index)); +} + QString PythonQtWrapper_elfparser::getSectionName(elfparser* theWrappedObject, int index) { return ( theWrappedObject->getSectionName(index)); } +qint64 PythonQtWrapper_elfparser::getSectionPaddr(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSectionPaddr(index)); +} + QString PythonQtWrapper_elfparser::getSectionType(elfparser* theWrappedObject, int index) { return ( theWrappedObject->getSectionType(index)); @@ -528,16 +934,41 @@ int PythonQtWrapper_elfparser::getSecti return ( theWrappedObject->getSectioncount()); } +qint64 PythonQtWrapper_elfparser::getSegmentFilesz(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentFilesz(index)); +} + QString PythonQtWrapper_elfparser::getSegmentFlags(elfparser* theWrappedObject, int index) { return ( theWrappedObject->getSegmentFlags(index)); } +qint64 PythonQtWrapper_elfparser::getSegmentMemsz(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentMemsz(index)); +} + +qint64 PythonQtWrapper_elfparser::getSegmentOffset(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentOffset(index)); +} + +qint64 PythonQtWrapper_elfparser::getSegmentPaddr(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentPaddr(index)); +} + QString PythonQtWrapper_elfparser::getSegmentType(elfparser* theWrappedObject, int index) { return ( theWrappedObject->getSegmentType(index)); } +qint64 PythonQtWrapper_elfparser::getSegmentVaddr(elfparser* theWrappedObject, int index) +{ + return ( theWrappedObject->getSegmentVaddr(index)); +} + int PythonQtWrapper_elfparser::getSegmentcount(elfparser* theWrappedObject) { return ( theWrappedObject->getSegmentcount()); @@ -548,6 +979,11 @@ QString PythonQtWrapper_elfparser::getT return ( theWrappedObject->getType()); } +qint64 PythonQtWrapper_elfparser::getVersion(elfparser* theWrappedObject) +{ + return ( theWrappedObject->getVersion()); +} + bool PythonQtWrapper_elfparser::static_elfparser_isElf(const QString& File) { return (elfparser::isElf(File)); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h @@ -2,8 +2,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -13,14 +15,64 @@ +class PythonQtShell_ElfFile : public ElfFile +{ +public: + PythonQtShell_ElfFile():ElfFile(),_wrapper(NULL) {}; + PythonQtShell_ElfFile(const QString& File):ElfFile(File),_wrapper(NULL) {}; + + ~PythonQtShell_ElfFile(); + +virtual int closeFile(); +virtual QList getFragments(); +virtual bool isopened(); +virtual bool openFile(const QString& File); + + PythonQtInstanceWrapper* _wrapper; +}; + +class PythonQtPublicPromoter_ElfFile : public ElfFile +{ public: +inline int promoted_closeFile() { return ElfFile::closeFile(); } +inline QList promoted_getFragments() { return ElfFile::getFragments(); } +inline bool promoted_isopened() { return ElfFile::isopened(); } +inline bool promoted_openFile(const QString& File) { return ElfFile::openFile(File); } +}; + class PythonQtWrapper_ElfFile : public QObject { Q_OBJECT public: public slots: -ElfFile* new_ElfFile(QObject* parent = 0); -ElfFile* new_ElfFile(const QString& File, QObject* parent = 0); +ElfFile* new_ElfFile(); +ElfFile* new_ElfFile(const QString& File); void delete_ElfFile(ElfFile* obj) { delete obj; } int closeFile(ElfFile* theWrappedObject); + QString getABI(ElfFile* theWrappedObject); + QString getArchitecture(ElfFile* theWrappedObject); + QString getClass(ElfFile* theWrappedObject); + QString getEndianness(ElfFile* theWrappedObject); + qint64 getEntryPointAddress(ElfFile* theWrappedObject); + QList getFragments(ElfFile* theWrappedObject); + QList getFragments(ElfFile* theWrappedObject, QStringList fragmentList); + bool getSectionData(ElfFile* theWrappedObject, int index, char** buffer); + qint64 getSectionDatasz(ElfFile* theWrappedObject, int index); + qint64 getSectionMemsz(ElfFile* theWrappedObject, int index); + QString getSectionName(ElfFile* theWrappedObject, int index); + qint64 getSectionPaddr(ElfFile* theWrappedObject, int index); + QString getSectionType(ElfFile* theWrappedObject, int index); + int getSectioncount(ElfFile* theWrappedObject); + qint64 getSegmentFilesz(ElfFile* theWrappedObject, int index); + QString getSegmentFlags(ElfFile* theWrappedObject, int index); + qint64 getSegmentMemsz(ElfFile* theWrappedObject, int index); + qint64 getSegmentOffset(ElfFile* theWrappedObject, int index); + qint64 getSegmentPaddr(ElfFile* theWrappedObject, int index); + QString getSegmentType(ElfFile* theWrappedObject, int index); + qint64 getSegmentVaddr(ElfFile* theWrappedObject, int index); + int getSegmentcount(ElfFile* theWrappedObject); + QString getType(ElfFile* theWrappedObject); + qint64 getVersion(ElfFile* theWrappedObject); + bool static_ElfFile_isElf(const QString& File); + bool iself(ElfFile* theWrappedObject); bool isopened(ElfFile* theWrappedObject); bool openFile(ElfFile* theWrappedObject, const QString& File); }; @@ -203,6 +255,58 @@ void delete_XByteArray(XByteArray* obj) +class PythonQtShell_abstractExecFile : public abstractExecFile +{ +public: + PythonQtShell_abstractExecFile():abstractExecFile(),_wrapper(NULL) {}; + + ~PythonQtShell_abstractExecFile(); + +virtual int closeFile(); +virtual QList getFragments(); +virtual bool isopened(); +virtual bool openFile(const QString& File); + + PythonQtInstanceWrapper* _wrapper; +}; + +class PythonQtWrapper_abstractExecFile : public QObject +{ Q_OBJECT +public: +public slots: +abstractExecFile* new_abstractExecFile(); +void delete_abstractExecFile(abstractExecFile* obj) { delete obj; } +}; + + + + + +class PythonQtShell_codeFragment : public codeFragment +{ +public: + PythonQtShell_codeFragment():codeFragment(),_wrapper(NULL) {}; + + ~PythonQtShell_codeFragment(); + + + PythonQtInstanceWrapper* _wrapper; +}; + +class PythonQtWrapper_codeFragment : public QObject +{ Q_OBJECT +public: +public slots: +codeFragment* new_codeFragment(); +void delete_codeFragment(codeFragment* obj) { delete obj; } +void py_set_data(codeFragment* theWrappedObject, char* data){ theWrappedObject->data = data; } +char* py_get_data(codeFragment* theWrappedObject){ return theWrappedObject->data; } +}; + + + + + class PythonQtWrapper_elfFileWidget : public QObject { Q_OBJECT public: @@ -215,6 +319,18 @@ void delete_elfFileWidget(elfFileWidget* +class PythonQtWrapper_elfInfoWdgt : public QObject +{ Q_OBJECT +public: +public slots: +elfInfoWdgt* new_elfInfoWdgt(QWidget* parent = 0); +void delete_elfInfoWdgt(elfInfoWdgt* obj) { delete obj; } +}; + + + + + class PythonQtWrapper_elfparser : public QObject { Q_OBJECT public: @@ -226,14 +342,24 @@ void delete_elfparser(elfparser* obj) { QString getArchitecture(elfparser* theWrappedObject); QString getClass(elfparser* theWrappedObject); QString getEndianness(elfparser* theWrappedObject); + qint64 getEntryPointAddress(elfparser* theWrappedObject); bool getSectionData(elfparser* theWrappedObject, int index, char** buffer); + qint64 getSectionDatasz(elfparser* theWrappedObject, int index); + qint64 getSectionMemsz(elfparser* theWrappedObject, int index); QString getSectionName(elfparser* theWrappedObject, int index); + qint64 getSectionPaddr(elfparser* theWrappedObject, int index); QString getSectionType(elfparser* theWrappedObject, int index); int getSectioncount(elfparser* theWrappedObject); + qint64 getSegmentFilesz(elfparser* theWrappedObject, int index); QString getSegmentFlags(elfparser* theWrappedObject, int index); + qint64 getSegmentMemsz(elfparser* theWrappedObject, int index); + qint64 getSegmentOffset(elfparser* theWrappedObject, int index); + qint64 getSegmentPaddr(elfparser* theWrappedObject, int index); QString getSegmentType(elfparser* theWrappedObject, int index); + qint64 getSegmentVaddr(elfparser* theWrappedObject, int index); int getSegmentcount(elfparser* theWrappedObject); QString getType(elfparser* theWrappedObject); + qint64 getVersion(elfparser* theWrappedObject); bool static_elfparser_isElf(const QString& File); bool iself(elfparser* theWrappedObject); bool isopened(elfparser* theWrappedObject); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp @@ -3,14 +3,18 @@ void PythonQt_init_PySocExplorer(PyObject* module) { -PythonQt::priv()->registerClass(&ElfFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerClass(&ElfFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); +PythonQt::self()->addParentClass("ElfFile", "abstractExecFile",PythonQtUpcastingOffset()); PythonQt::priv()->registerCPPClass("MemSizeWdgt", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("QHexEdit", "", "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerCPPClass("QHexSpinBox", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("SocExplorerPlot", "", "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&TCP_Terminal_Client::staticMetaObject, "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("XByteArray", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerClass(&abstractExecFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); +PythonQt::priv()->registerCPPClass("codeFragment", "", "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerCPPClass("elfFileWidget", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerCPPClass("elfInfoWdgt", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); } diff --git a/src/common/pythonQtgeneratorCfg.txt b/src/common/pythonQtgeneratorCfg.txt --- a/src/common/pythonQtgeneratorCfg.txt +++ b/src/common/pythonQtgeneratorCfg.txt @@ -1,16 +1,8 @@ - - - - - + + - - - - - @@ -18,10 +10,13 @@ + + - + - + + diff --git a/src/common/pythongenerator.sh b/src/common/pythongenerator.sh --- a/src/common/pythongenerator.sh +++ b/src/common/pythongenerator.sh @@ -1,6 +1,6 @@ #!/bin/bash #export QTDIR=/usr/include -export QTDIR=/usr/include/qt5 +#export QTDIR=/usr/include/qt5 -pythonqt_generator --dump-object-tree --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt +pythonqt_generator -include-paths="./elf /usr/include/qt5 /usr/include/qt5/QtWidgets" --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt