#include
#include "stdafx.h"
#include "Windows.H "
#include
DWord Readpefile (in LPSTR LPSZFILE, OUT LPVOID* pfilebuffer)
{
file* pf = null;
dword filesize = 0;
lpvoid pfilebuffer = null;
PF = FOPEN (lpszfile, "rb");
if (!!Pf)
{
Printf ("government \ n");
fclose (pf);
Return 0;
}
FSEEK (PF, 0, Seek_end);
Filesize = ftell (pf);
FSeek (PF, 0, Seek_Set);
pfilebuffer = malloc (filesize);
if (! PFileBuffer)
{
Printf ("%D \ NApplication Space failed \ n", pfilebuffer);
FREE (pfilebuffer);
FClose (pf);
Return 0;
}
size_t n = FREAD (pfilebuffer, filesize, 1, pf);
if (! n)
{
Printf ("%D \ NApplication Space failed \ n", n);
Free (pfilebuffer);
FClose (PF);
Return 0;
}
// Close the file
*pfilebuffer = pfilebuffer;
pfilebuffer = null;
FClose (PF);
Return filesize;
}
Int main (int ARGC, Char * ARGV [])
{
SIZE_T BufferadDress = Readpefile ("C: \\ Users \\ Administrator \\ desktop \\ notepad1.exe", 0); // The second parameter is to return the first address of the PE. How to create space for himIntersection
Return 0;
}
+5Votes
Readpefil blocks you. If your second parameter of your main E is a two -dimensional pointer, it does not need to create space.(Filesize);
This to apply for space, and*pfilebuffer = pfilebuffer; is to point the address of the space to its
The address can be used as a parameter:
C worker graduation Har *pbuff;
S duties of duty youths with the child’s month Ize_t buffradress = Readpefile (“T.Exe”, (LPVoi groupShisuke attacked Huang to rush to d *) &pbuff last season; // For some compilers, forced conversion, otherwise the warning
explains that your program structure is not very reasonableYou apply for memory in the sub -function and release it in the main function. In this way, the structure is more chaotic and easy to produce grass and mountains.0 Call the function, return the file length, and the second bottom can bring a pointer to apply for the memory in the main function to store the data content (this to modify your ReadpeFile function).