zoukankan      html  css  js  c++  java
  • 记录QT片断1(痛苦的win32)

    qt对QMenu的封装 没有SystemMenu   
            QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));

        HMENU systemMenu = GetSystemMenu(this->winId(),false);
        QString aa = tr("自定义系统菜单");
        AppendMenu(systemMenu,0,MYMENU,aa.toStdWString().c_str());
    qtceator对win32的太差 
      QString filename = QFileDialog::getOpenFileName(this,tr("请选择要加壳的文件 ----By satng"),"/","File(*.exe *.dll)");
        Q_ASSERT(filename.length()>0);
        ui->lineEditFileName->setText(filename);
        if(filename.isEmpty() || ui->lineEditFileName->text().isEmpty())
            return;
        MAP_FILE_STRUCT map_file;
        map_file.hFile = CreateFile(filename.toStdWString().c_str(),
                   GENERIC_READ | GENERIC_WRITE,
                   FILE_SHARE_READ | FILE_SHARE_WRITE,
                   NULL,
                   OPEN_EXISTING,
                   FILE_ATTRIBUTE_NORMAL,
                   NULL
                   );
        if(map_file.hFile == INVALID_HANDLE_VALUE)
        {
            qDebug() << "could not open file!";
            return;
        }
        qDebug() << "open file ok!";
        map_file.hMapping = CreateFileMapping(map_file.hFile,
                                              NULL,
                                              PAGE_READWRITE,
                                              0,
                                              0,
                                              NULL
                                              );
        if(map_file.hMapping == NULL)
        {
            qDebug() << "could not open file mapping!";
            CloseHandle(map_file.hFile);
            return;
        }
        qDebug() << "mapping ok!";
        map_file.ImageBase = MapViewOfFile(map_file.hMapping,
                                           FILE_MAP_ALL_ACCESS,
                                           0,
                                           0,
                                           0
                                           );
        if(map_file.ImageBase == NULL)
        {
            qDebug() << "not viewoffile!";
            CloseHandle(map_file.hFile);
            CloseHandle(map_file.hMapping);
            return;
        }
         qDebug() << "view of file ok!";
        QPeEntry *pe = new QPeEntry;
        pe->pheader_dos = (PIMAGE_DOS_HEADER)map_file.ImageBase;
        pe->pheader_nt = (PIMAGE_NT_HEADERS32)((DWORD)pe->pheader_dos + pe->pheader_dos->e_lfanew);
        if(pe->isPEFile())
        {
          qDebug() << "ok";
        }
        pe->pheader_file = &pe->pheader_nt->FileHeader;
        pe->pheader_option = &pe->pheader_nt->OptionalHeader;
        pe->sectionNumber = pe->pheader_nt->FileHeader.NumberOfSections;
        pe->get_header_section_first();
        //pe->pheader_section_new =  pe->pheader_section_first + pe->sectionNumber;
        //memcpy(pe->pheader_section_new->Name,".myname",8);
        //pe->pheader_file->NumberOfSections ++;
        //e->pheader_section_new->SizeOfRawData = (DWORD)pe->pheader_option->FileAlignment;
    /******************************************
      增加新节
    ******************************************/
    //    pe->fileSize = GetFileSize(map_file.hFile,NULL);
    //    pe->addSection();
    //    void *code = malloc(0x1000);
    //    memset(code,2,0x1000);
    //    SetFilePointer(map_file.hFile,pe->pheader_section_new->PointerToRawData,NULL,FILE_BEGIN);
    //    qDebug() << pe-> pheader_option->ImageBase;
    //    DWORD size_o = 0;
    //    WriteFile(map_file.hFile,code,0x1000,&size_o,NULL);
    //    qDebug() << sizeof(code);
        DWORD v_addr = pe->pheader_option->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
       PIMAGE_IMPORT_DESCRIPTOR iid = (PIMAGE_IMPORT_DESCRIPTOR)ImageRvaToVa(pe->pheader_nt,(LPVOID)map_file.ImageBase,v_addr,NULL);
       while(iid->Name !=0)
       {
           qDebug() << (char *)ImageRvaToVa(pe->pheader_nt,(LPVOID)map_file.ImageBase,iid->Name,NULL);
           iid++;
       }
    .....
    .....
    .....


  • 相关阅读:
    虚函数和纯虚函数
    函数指针
    const成员函数
    随笔
    Myeclipse/eclipse的Web project改写成Maven项目
    Maven项目配置不接文件名
    Tomcat需要更改三个端口,才能在一台机器上搭载多个tomcat
    maven错误:Project configuration is not up-to-date with pom.xml
    Failed to execute goal on project MakeFriends: Could not resolve dependencie The POM for .chengpai.jtd:jtd-service-api:jar:1.0-SNAPSHOT is missing, no dependency information available
    编译器问题:运行maven,报错-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
  • 原文地址:https://www.cnblogs.com/mokliu/p/2138871.html
Copyright © 2011-2022 走看看