|
From: Christian W. <Chr...@vo...> - 2003-02-18 12:58:51
|
Hi List,
I try to play around with the PE file format and can't get it running ...
What is lpFile for a type ???
To what should i cast it, so that it works ?
My last Test was:
lpFile = fopen(...);
(The MSDN doesn't help much...)
Here the stuff from the MSDN:
/* DOS header identifies the NT PEFile signature dword
the PEFILE header exists just after that dword */
#define PEFHDROFFSET(a) ((LPVOID)((BYTE *)a + \
((PIMAGE_DOS_HEADER)a)->e_lfanew + \
SIZE_OF_NT_SIGNATURE))
LPVOID lpFile;
int n = ((int)((PIMAGE_FILE_HEADER)PEFHDROFFSET
(lpFile))->NumberOfSections);
Here the declaration from WinNT.h:
//
// File header format.
//
typedef struct _IMAGE_FILE_HEADER
{
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
|