How to get the original size of a pe file
-
I just want to know how to get a pe file's size through the PE file its self.That is no API is used,just look up the data structure of the pe. I have checked the winnt.h and can't find a useful data member to show the size of the pe file.
Don't look at me in that way!
-
I just want to know how to get a pe file's size through the PE file its self.That is no API is used,just look up the data structure of the pe. I have checked the winnt.h and can't find a useful data member to show the size of the pe file.
Don't look at me in that way!
Hey, I consider you must be using MFC Use a CFile object to get the length of the file and that length would be the size of file in bytes like this.. CFile obj; double len; CString sLen; if(obj.Open("C:\\a\\a.exe",CFile::modeRead)) { len = obj.GetLength(); len /= 1024; sLen.Format("%10f",len); AfxMessageBox(sLen); } obj.Close(); This code will give you the size of PE file in kilobytes Regards, Pankaj Sachdeva
-
Hey, I consider you must be using MFC Use a CFile object to get the length of the file and that length would be the size of file in bytes like this.. CFile obj; double len; CString sLen; if(obj.Open("C:\\a\\a.exe",CFile::modeRead)) { len = obj.GetLength(); len /= 1024; sLen.Format("%10f",len); AfxMessageBox(sLen); } obj.Close(); This code will give you the size of PE file in kilobytes Regards, Pankaj Sachdeva
But if I have a pe file and then I append some data to the file,I want to get the original pe file size,not the size after modified! I skim the winnt.h and find that I must sum all the section size and directory size to count the size of pe file.I want to if there is a structure member in the pe file that can show me the size directly! Thanks for help!
---------- Don't look at me in that way!
-
But if I have a pe file and then I append some data to the file,I want to get the original pe file size,not the size after modified! I skim the winnt.h and find that I must sum all the section size and directory size to count the size of pe file.I want to if there is a structure member in the pe file that can show me the size directly! Thanks for help!
---------- Don't look at me in that way!
tell me exactly what are you creating then may be i'll be able to help you Regards, Pankaj Sachdeva
-
tell me exactly what are you creating then may be i'll be able to help you Regards, Pankaj Sachdeva
At first!Thank you for help! I just want to get the orginal pe file's size,maybe the pe file was modified by some other program(ex.Append some data to the end of the orginal pe file).So the size I get from API is not the size of the original file. I want to get the original pe file size ,so I have to follow the pe format and sum all it's section size and directory size. Can you help me on getting a easy way to find out the original file size! Thank you very much! ---------- Don't look at me in that way!