The following code is supposed to print out the names of all the sections in the specified exe (c:\linked list.exe in this case), but it produces some bizzare output. Can someone please help me figure out whats wrong??
Code:#include<Windows.h> #include<stdio.h> #include<WinNT.h> int main() { FILE *fp; int i; if((fp = fopen("c:\\Linked List.exe","rb"))==NULL) printf("unable to open"); IMAGE_DOS_HEADER imdh; fread(&imdh,sizeof(imdh),1,fp); IMAGE_NT_HEADERS imnth; fread(&imnth,sizeof(imnth),1,fp); IMAGE_SECTION_HEADER *pimsh; pimsh = (IMAGE_SECTION_HEADER *)malloc(sizeof(IMAGE_SECTION_HEADER) * imnth.FileHeader.NumberOfSections); fread(pimsh,sizeof(IMAGE_SECTION_HEADER),imnth.FileHeader.NumberOfSections,fp); for(i=0;i<imnth.FileHeader.NumberOfSections;i++) { printf("%s\n",pimsh->Name); pimsh++; } }



LinkBack URL
About LinkBacks



