view loader/wine/pe_image.h @ 34266:a6a1c973de4e

vo direct3d: fix crash in osd drawing code The crash occurred when the video window was minimized and the OSD should be drawn. This caused the OSD textures creation to fail and later the OSD drawing code would assume they exist and cause the crash. When the video window is minimized a size change event with the new size 0x0 is reported. This is now handled by deferring the textures recreation. If the OSD should be drawn in the meantime it will be checked if the OSD textures have been allocated. This commit is done with the permission of the vo direct3d maintainer. This is based on patches from Roger Pack (rogerdpack2 (gmail)) and Patrick Dinh (patrickdinh33 (yahoo)).
author al
date Sat, 19 Nov 2011 14:04:11 +0000
parents 437b251e4194
children
line wrap: on
line source

#ifndef MPLAYER_PE_IMAGE_H
#define MPLAYER_PE_IMAGE_H

#include "winnt.h"
#include "winbase.h"

#define PE_HEADER(module) \
    ((IMAGE_NT_HEADERS*)((LPBYTE)(module) + \
                         (((IMAGE_DOS_HEADER*)(module))->e_lfanew)))

#define PE_SECTIONS(module) \
    ((IMAGE_SECTION_HEADER*)((LPBYTE)&PE_HEADER(module)->OptionalHeader + \
                           PE_HEADER(module)->FileHeader.SizeOfOptionalHeader))

#define RVA_PTR(module,field) ((LPBYTE)(module) + PE_HEADER(module)->field)

/* modreference used for attached processes
 * all section are calculated here, relocations etc.
 */
typedef struct {
	PIMAGE_IMPORT_DESCRIPTOR	pe_import;
	PIMAGE_EXPORT_DIRECTORY	pe_export;
	PIMAGE_RESOURCE_DIRECTORY	pe_resource;
	int				tlsindex;
} PE_MODREF;

struct wine_modref;
int PE_unloadImage(HMODULE hModule);
FARPROC PE_FindExportedFunction(struct wine_modref *wm, LPCSTR funcName, WIN_BOOL snoop);
WIN_BOOL PE_EnumResourceTypesA(HMODULE, ENUMRESTYPEPROCA, LONG);
WIN_BOOL PE_EnumResourceTypesW(HMODULE, ENUMRESTYPEPROCW, LONG);
WIN_BOOL PE_EnumResourceNamesA(HMODULE, LPCSTR, ENUMRESNAMEPROCA, LONG);
WIN_BOOL PE_EnumResourceNamesW(HMODULE, LPCWSTR, ENUMRESNAMEPROCW, LONG);
WIN_BOOL PE_EnumResourceLanguagesA(HMODULE, LPCSTR, LPCSTR, ENUMRESLANGPROCA, LONG);
WIN_BOOL PE_EnumResourceLanguagesW(HMODULE, LPCWSTR, LPCWSTR, ENUMRESLANGPROCW, LONG);
HRSRC PE_FindResourceExW(struct wine_modref*, LPCWSTR, LPCWSTR, WORD);
DWORD PE_SizeofResource(HMODULE, HRSRC);
struct wine_modref *PE_LoadLibraryExA(LPCSTR, DWORD);
void PE_UnloadLibrary(struct wine_modref *);
HGLOBAL PE_LoadResource(struct wine_modref *wm, HRSRC);
HMODULE PE_LoadImage(int hFile, LPCSTR filename, WORD *version);
struct wine_modref *PE_CreateModule(HMODULE hModule, LPCSTR filename,
                                    DWORD flags, WIN_BOOL builtin);
WIN_BOOL PE_CreateProcess(HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR env,
                          LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
                          WIN_BOOL inherit, DWORD flags, LPSTARTUPINFOA startup,
                          LPPROCESS_INFORMATION info);

void PE_InitTls(void);
WIN_BOOL PE_InitDLL(struct wine_modref *wm, DWORD type, LPVOID lpReserved);

PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA(PIMAGE_RESOURCE_DIRECTORY, LPCSTR, DWORD, WIN_BOOL);
PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY, LPCWSTR, DWORD, WIN_BOOL);

typedef DWORD CALLBACK (*DLLENTRYPROC)(HMODULE,DWORD,LPVOID);

typedef struct WINE_PACKED {
	WORD	popl;		/* 0x8f 0x05 */
	DWORD	addr_popped;	/* ...  */
	BYTE	pushl1;		/* 0x68 */
	DWORD	newret;		/* ...  */
	BYTE	pushl2;		/* 0x68 */
	DWORD	origfun;	/* original function */
	BYTE	ret1;		/* 0xc3 */
	WORD	addesp;		/* 0x83 0xc4 */
	BYTE	nrofargs;	/* nr of arguments to add esp, */
	BYTE	pushl3;		/* 0x68 */
	DWORD	oldret;		/* Filled out from popl above  */
	BYTE	ret2;		/* 0xc3 */
} ELF_STDCALL_STUB;

typedef struct {
	void*			dlhandle;
	ELF_STDCALL_STUB	*stubs;
} ELF_MODREF;

struct wine_modref *ELF_LoadLibraryExA( LPCSTR libname, DWORD flags);
void ELF_UnloadLibrary(struct wine_modref *);
FARPROC ELF_FindExportedFunction(struct wine_modref *wm, LPCSTR funcName);

#endif /* MPLAYER_PE_IMAGE_H */