1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| VOID InitSectionView(HWND hwndDlg) { LV_COLUMN lv; HWND hListSection;
memset(&lv,0,sizeof(LV_COLUMN)); hListSection = GetDlgItem(hwndDlg,IDC_LIST_SECTION); SendMessage(hListSection,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT);
lv.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; lv.pszText = _T("节名"); lv.cx = 50; lv.iSubItem = 0; ListView_InsertColumn(hListSection, 0, &lv); lv.pszText = _T("文件偏移"); lv.cx = 100; lv.iSubItem = 1; ListView_InsertColumn(hListSection, 1, &lv); lv.pszText = _T("文件大小"); lv.cx = 100; lv.iSubItem = 2; ListView_InsertColumn(hListSection, 2, &lv); lv.pszText = _T("内存偏移"); lv.cx = 100; lv.iSubItem = 3; ListView_InsertColumn(hListSection, 3, &lv); lv.pszText = _T("内存大小"); lv.cx = 100; lv.iSubItem = 4; ListView_InsertColumn(hListSection, 4, &lv); lv.pszText = _T("节区属性"); lv.cx = 100; lv.iSubItem = 4; ListView_InsertColumn(hListSection, 5, &lv);
ReadPEFile(szFileName, &pFileBuffer); pDosHeader = (PIMAGE_DOS_HEADER) pFileBuffer; pNTHeader = (PIMAGE_NT_HEADERS) ((DWORD) pFileBuffer + pDosHeader->e_lfanew); PIMAGE_SECTION_HEADER pSectionHeader = IMAGE_FIRST_SECTION(pNTHeader);
LPSTR sectionData[6] = {0}; TCHAR name[0x40]; TCHAR virtualAddress[0x40]; TCHAR sizeOfRawData[0x40]; TCHAR pointerToRawData[0x40]; TCHAR virtualSize[0x40]; TCHAR characteristics[0x40];
for (int i = 0; i < pFileHeader->NumberOfSections; i++) { sprintf(name, _T("%s"), pSectionHeader[i].Name); sectionData[0] = name;
sprintf(virtualAddress, _T("0x%X"), pSectionHeader[i].VirtualAddress); sectionData[1] = virtualAddress;
sprintf(sizeOfRawData, _T("0x%X"), pSectionHeader[i].SizeOfRawData); sectionData[2] = sizeOfRawData;
sprintf(pointerToRawData, _T("0x%X"), pSectionHeader[i].PointerToRawData); sectionData[3] = pointerToRawData;
sprintf(virtualSize, _T("0x%X"), pSectionHeader[i].Misc.VirtualSize); sectionData[4] = virtualSize;
sprintf(characteristics, _T("0x%08X"), pSectionHeader[i].Characteristics); sectionData[5] = characteristics;
InsertRow(hListSection,sectionData); }
free(pFileBuffer); }
|