winelib file format
Jia L Wu
jwu at cc.helsinki.fi
Thu Nov 11 10:37:29 CST 2004
hi,
What is the difference between winelib executable format and win32 PE file
format? Isn't winelib executable just the wrapper of the windows
executable?
I have a win32 function which can read an executable file and determine
all the dependent dlls. I want to port it to Linux and build it using
winelib. Hence the same functunalities can be achieved (i.e determine if
the file is winelib file and all its dependent winelib dlls). Can
somebody tell me how the following code be modified so that it works for
winelib application? Thanks a lot.
Wu
//call CreateFileA() to create a file handle
HANDLE hFile = CreateFileA(fName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0);
//call CreateFileMappingA() to create a file mapping
HANDLE hFileMapping = CreateFileMappingA(hFile,NULL, PAGE_READONLY, 0,
0,NULL);
//call MapViewOfFile()
PVOID pMemoryMappedFileBase = (PCHAR)MapViewOfFile( hFileMapping,
FILE_MAP_READ, 0, 0, 0);
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)pMemoryMappedFileBase;
if ( IMAGE_DOS_SIGNATURE != pDosHdr->e_magic )
{
//not a DOS "MZ" file
reurn;
}
// Make a pointer to the secondary header
DWORD secondaryHeaderOffset = pDosHdr->e_lfanew;
PWORD pSecondHdr = (PWORD)((DWORD) pMemoryMappedFileBase +
(DWORD)secondaryHeaderOffset );
// Decide what type of EXE, based on the start of the secondary header
switch ( *pSecondHdr )
{
case IMAGE_OS2_SIGNATURE:
exeType = exeType_NE;
break;
case IMAGE_VXD_SIGNATURE:
exeType = exeType_VXD;
break;
case 0x4558:
exeType = exeType_LX;
break; // OS/2 2.X
}
if ( *(PDWORD)pSecondHdr == IMAGE_NT_SIGNATURE )
{
exeType = exeType_PE;
}
......
More information about the wine-devel
mailing list