summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-07-12 15:27:48 +0000
committerjkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-07-12 15:27:48 +0000
commita26b39974fb992cb400c6e9aff0a02737c2f4f59 (patch)
treebd6802ff279bb9ed79a9dec7f367861309741686 /loader
parent009d2b0dc7ce5d7089bdb4136d1b575b115981d0 (diff)
downloadmpv-a26b39974fb992cb400c6e9aff0a02737c2f4f59.tar.bz2
mpv-a26b39974fb992cb400c6e9aff0a02737c2f4f59.tar.xz
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
attribute mismatch between caller/caller. wine/loader is less sensitive to optimization now. (now that avifile-0.6 has the same patch installed, we're a bit closer to their CVS tree) Speed up win32 "QueryPerformanceFrequency" emulation on solaris. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1308 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/Makefile15
-rw-r--r--loader/afl.c13
-rw-r--r--loader/config.h74
-rw-r--r--loader/driver.c47
-rw-r--r--loader/driver.h11
-rw-r--r--loader/elfdll.c2
-rw-r--r--loader/ext.c78
-rw-r--r--loader/ext.h15
-rw-r--r--loader/loader.h3
-rw-r--r--loader/module.c10
-rw-r--r--loader/pe_image.c32
-rw-r--r--loader/pe_resource.c1
-rw-r--r--loader/registry.c20
-rw-r--r--loader/resource.c3
-rw-r--r--loader/setup_FS.c11
-rw-r--r--loader/setup_FS.h10
-rw-r--r--loader/vfl.c49
-rw-r--r--loader/win32.c181
-rw-r--r--loader/win32.h211
-rw-r--r--loader/wine/config.h442
-rw-r--r--loader/wine/vfw.h2
21 files changed, 533 insertions, 697 deletions
diff --git a/loader/Makefile b/loader/Makefile
index c04ec0a4ec..1b5ea406ec 100644
--- a/loader/Makefile
+++ b/loader/Makefile
@@ -1,18 +1,25 @@
include ../config.mak
# Generated automatically from Makefile.in by configure.
-DEFINES=-rdynamic -fPIC $(WIN32_PATH) $(CDOPT) -D__WINE__ -Ddbg_printf=__vprintf \
+DEFINES=$(WIN32_PATH) -D__WINE__ -Ddbg_printf=__vprintf \
-DTRACE=__vprintf # -DDETAILED_OUT
LIB_OBJECTS= setup_FS.o pe_image.o module.o \
ext.o win32.o driver.o pe_resource.o \
resource.o registry.o elfdll.o afl.o vfl.o
-CFLAGS=-g -I.
+# gcc-3.0 produces buggy code for acmStreamOpen() with
+# "-O3 -fomit-frame-pointer" or "-O2 -fomit-frame-pointer
+# -finline-functions -frename-registers" (code is OK with sole -O2),
+# the bad code accesses parameters via %ebp without setting up a
+# propper %ebp first!
+# -fno-omit-frame-pointer works around this gcc-3.0 bug. gcc-2.95.2 is OK.
+WARN_FLAGS = -Wmissing-prototypes -Wimplicit-function-declaration
+CFLAGS=-I. -I.. $(OPTFLAGS) $(EXTRA_INC) $(WARN_FLAGS) -fno-omit-frame-pointer
+#CFLAGS=-I. -I.. -O $(WARN_FLAGS) -g #-fno-omit-frame-pointer
-CDOPT=-g
all: libloader.a
-
+
clean:
-rm -f *.o libloader.a
diff --git a/loader/afl.c b/loader/afl.c
index 7816a3f139..bf79e75f27 100644
--- a/loader/afl.c
+++ b/loader/afl.c
@@ -22,8 +22,11 @@
#include <config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include "win32.h"
+
#include <wine/winbase.h>
#include <wine/windef.h>
#include <wine/winuser.h>
@@ -34,11 +37,13 @@
#include <wine/msacm.h>
#include <wine/msacmdrv.h>
#include "wineacm.h"
-#pragma pack(1)
+#include "ext.h"
+#include "driver.h"
+
#define OpenDriverA DrvOpen
-extern HDRVR VFWAPI DrvOpen(long);
#define CloseDriver DrvClose
-extern HDRVR VFWAPI DrvClose(long);
+
+#pragma pack(1)
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
{
@@ -394,6 +399,8 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
int wfxSrcSize;
int wfxDstSize;
+ //printf("gcc-3.0 bug, pwfxSrc=%p, pwfxSrc->cbSize=%d\n", pwfxSrc, pwfxSrc->cbSize);
+
TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
diff --git a/loader/config.h b/loader/config.h
deleted file mode 100644
index 15ff49d602..0000000000
--- a/loader/config.h
+++ /dev/null
@@ -1,74 +0,0 @@
-
-/* include/config.h. Generated automatically by configure. */
-/* include/config.h.in. Generated automatically from configure.in by autoheader. */
-#define USE_SDL 1
-/* #undef QUIET */
-/* #undef TIMING */
-/* #undef DETAILED_OUT */
-#define MMX 1
-#define HAVE_LIBXXF86DGA 1
-#define HAVE_LIBXXF86VM 1
-#define USE_TSC 1
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define as __inline if that's what the C compiler calls it. */
-/* #undef inline */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define if you have the ftime function. */
-#define HAVE_FTIME 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the gettimeofday function. */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the strdup function. */
-#define HAVE_STRDUP 1
-
-/* Define if you have the strstr function. */
-#define HAVE_STRSTR 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <malloc.h> header file. */
-#define HAVE_MALLOC_H 1
-
-/* Define if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the dl library (-ldl). */
-#define HAVE_LIBDL 1
-
-/* Define if you have the jpeg library (-ljpeg). */
-#define HAVE_LIBJPEG 1
diff --git a/loader/driver.c b/loader/driver.c
index 6133409680..e7b870402d 100644
--- a/loader/driver.c
+++ b/loader/driver.c
@@ -1,29 +1,38 @@
#include <config.h>
#include <stdio.h>
-
#ifdef HAVE_MALLOC_H
#include <malloc.h>
-#else
+#endif
#include <stdlib.h>
+#ifdef __FreeBSD__
+#include <sys/time.h>
#endif
+#include <win32.h>
#include <wine/driver.h>
#include <wine/pe_image.h>
#include <wine/winreg.h>
#include <wine/vfw.h>
#include <registry.h>
-
-//#include "com.h"
-//typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
-
-
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
+#include <setup_FS.h>
+#include "driver.h"
+#if 1
+/*
+ * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
+ * WINAPI/no-WINAPI bustage.
+ *
+ * There should be no need for the STORE_ALL/REST_ALL hack once all
+ * function definitions agree with their prototypes (WINAPI-wise) and
+ * we make sure, that we do not call these functions without a proper
+ * prototype in scope.
+ */
+#define STORE_ALL /**/
+#define REST_ALL /**/
+#else
#define STORE_ALL \
- __asm__ ( \
+ __asm__( \
"push %%ebx\n\t" \
"push %%ecx\n\t" \
"push %%edx\n\t" \
@@ -31,25 +40,16 @@
"push %%edi\n\t"::)
#define REST_ALL \
- __asm__ ( \
+ __asm__( \
"pop %%edi\n\t" \
"pop %%esi\n\t" \
"pop %%edx\n\t" \
"pop %%ecx\n\t" \
"pop %%ebx\n\t"::)
+#endif
-typedef struct {
- UINT uDriverSignature;
- HINSTANCE hDriverModule;
- DRIVERPROC DriverProc;
- DWORD dwDriverID;
-} DRVR;
-
-typedef DRVR *PDRVR;
-typedef DRVR *NPDRVR;
-typedef DRVR *LPDRVR;
static DWORD dwDrvID = 0;
@@ -119,10 +119,9 @@ void DrvClose(HDRVR hdrvr)
}
-extern char* def_path; //=WIN32_PATH; // path to codecs
char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!!
-HDRVR
+HDRVR VFWAPI
DrvOpen(LPARAM lParam2)
{
ICOPEN *icopen=(ICOPEN *) lParam2;
diff --git a/loader/driver.h b/loader/driver.h
new file mode 100644
index 0000000000..5f055fef43
--- /dev/null
+++ b/loader/driver.h
@@ -0,0 +1,11 @@
+
+#ifndef loader_driver_h
+#define loader_driver_h
+
+#include <wine/windef.h>
+#include <wine/vfw.h>
+
+extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
+extern void DrvClose(HDRVR hdrvr);
+
+#endif
diff --git a/loader/elfdll.c b/loader/elfdll.c
index b4cf623995..840868c6b7 100644
--- a/loader/elfdll.c
+++ b/loader/elfdll.c
@@ -9,9 +9,9 @@
#include <string.h>
#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <wine/config.h>
#include <wine/windef.h>
//#include <wine/global.h>
//#include <wine/process.h>
diff --git a/loader/ext.c b/loader/ext.c
index 1b27f9bda2..8fec3951d1 100644
--- a/loader/ext.c
+++ b/loader/ext.c
@@ -6,10 +6,10 @@
*
********************************************************/
#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
-#else
-#include <stdlib.h>
#endif
#include <unistd.h>
#include <sys/mman.h>
@@ -18,7 +18,11 @@
#include <string.h>
#include <stdarg.h>
#include <wine/windef.h>
-//#include <wine/winbase.h>
+#include <wine/winbase.h>
+#include <wine/debugtools.h>
+#include <wine/heap.h>
+#include "ext.h"
+
int dbg_header_err( const char *dbg_channel, const char *func )
{
return 0;
@@ -35,7 +39,7 @@ int dbg_header_trace( const char *dbg_channel, const char *func )
{
return 0;
}
-int dbg_vprintf( const char *format, ... )
+int dbg_vprintf( const char *format, va_list args )
{
return 0;
}
@@ -50,12 +54,12 @@ int __vprintf( const char *format, ... )
return 0;
}
-int GetProcessHeap()
+HANDLE WINAPI GetProcessHeap(void)
{
return 1;
}
-void* HeapAlloc(int heap, int flags, int size)
+LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
{
if(flags & 0x8)
return calloc(size, 1);
@@ -63,7 +67,7 @@ void* HeapAlloc(int heap, int flags, int size)
return malloc(size);
}
-int HeapFree(int heap, int flags, void* mem)
+WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags,LPVOID mem)
{
if (mem) free(mem);
return 1;
@@ -71,34 +75,34 @@ int HeapFree(int heap, int flags, void* mem)
static int last_error;
-int GetLastError()
+DWORD WINAPI GetLastError(void)
{
return last_error;
}
-int SetLastError(int error)
+VOID WINAPI SetLastError(DWORD error)
{
- return last_error=error;
+ last_error = error;
}
-int ReadFile(int handle, void* mem, unsigned long size, long* result, long flags)
+WIN_BOOL WINAPI ReadFile(HANDLE handle,LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
{
*result=read(handle, mem, size);
return *result;
}
-int lstrcmpiA(const char* c1, const char* c2)
+int WINAPI lstrcmpiA(const char* c1, const char* c2)
{
return strcasecmp(c1,c2);
}
-int lstrcpynA(char* dest, const char* src, int num)
+LPSTR WINAPI lstrcpynA(LPSTR dest, LPCSTR src, INT num)
{
- return strncmp(dest,src,num);
+ return strncpy(dest,src,num);
}
-int lstrlenA(const char* s)
+int WINAPI lstrlenA(const char* s)
{
return strlen(s);
}
-int lstrlenW(const short* s)
+INT WINAPI lstrlenW(LPCWSTR s)
{
int l;
if(!s)
@@ -108,8 +112,9 @@ int lstrlenW(const short* s)
l++;
return l;
}
-int lstrcpynWtoA(char* dest, const char* src, int count)
+LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
{
+ LPSTR rval = dest;
int moved=0;
if((dest==0) || (src==0))
return 0;
@@ -118,10 +123,11 @@ int lstrcpynWtoA(char* dest, const char* src, int count)
*dest=*src;
moved++;
if(*src==0)
- return moved;
+ break;
src++;
dest++;
}
+ return rval;
}
int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
{
@@ -147,7 +153,7 @@ int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
}
-int IsBadReadPtr(void* data, int size)
+WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size)
{
if(size==0)
return 0;
@@ -155,14 +161,14 @@ int IsBadReadPtr(void* data, int size)
return 1;
return 0;
}
-char* HEAP_strdupA(const char* string)
+LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string)
{
// return strdup(string);
char* answ=malloc(strlen(string)+1);
strcpy(answ, string);
return answ;
}
-short* HEAP_strdupAtoW(void* heap, void* hz, const char* string)
+LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string)
{
int size, i;
short* answer;
@@ -174,7 +180,7 @@ short* HEAP_strdupAtoW(void* heap, void* hz, const char* string)
answer[i]=(short)string[i];
return answer;
}
-char* HEAP_strdupWtoA(void* heap, void* hz, const short* string)
+LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
{
int size, i;
char* answer;
@@ -322,9 +328,12 @@ static file_mapping* fm=0;
#define PAGE_GUARD 0x100
#define PAGE_NOCACHE 0x200
-HANDLE CreateFileMappingA(int hFile, void* lpAttr,
-DWORD flProtect, DWORD dwMaxHigh, DWORD dwMaxLow, const char* name)
+HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
+ DWORD flProtect,
+ DWORD dwMaxHigh, DWORD dwMaxLow,
+ LPCSTR name)
{
+ int hFile = (int)handle;
unsigned int len;
HANDLE answer;
int anon=0;
@@ -381,7 +390,7 @@ DWORD flProtect, DWORD dwMaxHigh, DWORD dwMaxLow, const char* name)
}
return (HANDLE)0;
}
-int UnmapViewOfFile(HANDLE handle)
+WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
{
file_mapping* p;
int result;
@@ -389,7 +398,7 @@ int UnmapViewOfFile(HANDLE handle)
return (HANDLE)0;
for(p=fm; p; p=p->next)
{
- if(p->handle==handle)
+ if(p->handle==(HANDLE)handle)
{
result=munmap((void*)handle, p->mapping_size);
if(p->next)p->next->prev=p->prev;
@@ -418,7 +427,7 @@ static virt_alloc* vm=0;
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
-void* VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protection)
+void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protection)
{
void* answer;
int fd=open("/dev/zero", O_RDWR);
@@ -488,7 +497,7 @@ void* VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protection)
return answer;
}
}
-int VirtualFree(void* address, int t1, int t2)//not sure
+WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
{
virt_alloc* str=vm;
int answer;
@@ -509,8 +518,10 @@ int VirtualFree(void* address, int t1, int t2)//not sure
return -1;
}
-int WideCharToMultiByte(unsigned int codepage, long flags, const short* src,
- int srclen,char* dest, int destlen, const char* defch, int* used_defch)
+INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags,
+ LPCWSTR src, INT srclen,
+ LPSTR dest, INT destlen,
+ LPCSTR defch, WIN_BOOL*used_defch)
{
int i;
if(src==0)
@@ -541,12 +552,13 @@ int WideCharToMultiByte(unsigned int codepage, long flags, const short* src,
}
return min(srclen, destlen);
}
-int MultiByteToWideChar(unsigned int codepage,long flags, const char* src, int srclen,
- short* dest, int destlen)
+INT WINAPI MultiByteToWideChar(UINT codepage, DWORD flags,
+ LPCSTR src, INT srclen,
+ LPWSTR dest, INT destlen)
{
return 0;
}
-HANDLE OpenFileMappingA(long access, long prot, char* name)
+HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name)
{
file_mapping* p;
if(fm==0)
diff --git a/loader/ext.h b/loader/ext.h
new file mode 100644
index 0000000000..f6b121e9b7
--- /dev/null
+++ b/loader/ext.h
@@ -0,0 +1,15 @@
+
+#ifndef loader_ext_h
+#define loader_ext_h
+
+#include <wine/windef.h>
+
+extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
+ DWORD size_high, DWORD size_low,
+ DWORD offset_high, DWORD offset_low,
+ int prot, int flags );
+extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
+extern int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n);
+extern int __vprintf( const char *format, ... );
+
+#endif
diff --git a/loader/loader.h b/loader/loader.h
index 6b758d0217..e2b1207be8 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -279,7 +279,8 @@ MMRESULT WINAPI acmStreamUnprepareHeader(
);
void MSACM_RegisterAllDrivers(void);
-int WINAPI LoadStringA(long instance, long id, void* buf, long size);
+INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
+ LPSTR buffer, INT buflen );
#ifdef __cplusplus
}
diff --git a/loader/module.c b/loader/module.c
index 61a886d025..e2eb306cc2 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -15,6 +15,11 @@
#include <sys/mman.h>
#include <sys/types.h>
+#ifdef HAVE_LIBDL
+#include <wine/elfdll.h>
+#include <dlfcn.h>
+#endif
+
/*
#ifdef __linux__
#include <asm/unistd.h>
@@ -48,6 +53,7 @@ struct modify_ldt_ldt_s {
#include <wine/module.h>
#include <wine/pe_image.h>
#include <wine/debugtools.h>
+#include "win32.h"
struct modref_list_t;
@@ -79,7 +85,7 @@ WINE_MODREF *MODULE_FindModule(LPCSTR m)
return list->wm;
}
-void MODULE_RemoveFromList(WINE_MODREF *mod)
+static void MODULE_RemoveFromList(WINE_MODREF *mod)
{
modref_list* list=local_wm;
if(list==0)
@@ -478,7 +484,7 @@ FARPROC MODULE_GetProcAddress(
return retproc;
#ifdef HAVE_LIBDL
case MODULE32_ELF:
- retproc = (FARPROC) dlsym( wm->module, function);
+ retproc = (FARPROC) dlsym( (void*)wm->module, function);
if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
return retproc;
#endif
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 51af59bd0b..55d8ef34dd 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -34,16 +34,19 @@
* to 4096 byte boundaries on disk.
*/
#include <config.h>
-#include <wine/config.h>
#include <errno.h>
#include <assert.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
@@ -54,6 +57,7 @@
#include <wine/pe_image.h>
#include <wine/module.h>
#include <wine/debugtools.h>
+#include <ext.h>
#include "win32.h"
@@ -64,7 +68,7 @@
extern void* LookupExternal(const char* library, int ordinal);
extern void* LookupExternalByName(const char* library, const char* name);
-void dump_exports( HMODULE hModule )
+static void dump_exports( HMODULE hModule )
{
char *Module;
int i, j;
@@ -236,7 +240,7 @@ FARPROC PE_FindExportedFunction(
}
}
-DWORD fixup_imports( WINE_MODREF *wm )
+static DWORD fixup_imports( WINE_MODREF *wm )
{
IMAGE_IMPORT_DESCRIPTOR *pe_imp;
PE_MODREF *pem;
@@ -561,7 +565,6 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
}
}
-
load_addr = nt->OptionalHeader.ImageBase;
vma_size = calc_vma_size( hModule );
@@ -881,17 +884,26 @@ void PE_UnloadLibrary(WINE_MODREF *wm)
* due to the PROCESS_Create stuff.
*/
-/* Called if the library is loaded or freed.
- * NOTE: if a thread attaches a DLL, the current thread will only do
- * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH
- * (SDK)
+#if 0
+/*
+ * so this is a dirty hack.
+ * Why do we need it?
+ *
+ * Disable it for now, let's see if it breaks something
*/
-extern void This_Is_Dirty_Hack()
+static void This_Is_Dirty_Hack(void)
{
void* mem=alloca(0x20000);
*(int*)mem=0x1234;
}
+#endif
+
+/* Called if the library is loaded or freed.
+ * NOTE: if a thread attaches a DLL, the current thread will only do
+ * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH
+ * (SDK)
+ */
WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
{
WIN_BOOL retv = TRUE;
@@ -927,7 +939,9 @@ WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
break;
}
TRACE("for %s\n", wm->filename);
+#if 0
This_Is_Dirty_Hack();
+#endif
retv = entry( wm->module, type, lpReserved );
}
diff --git a/loader/pe_resource.c b/loader/pe_resource.c
index 7edfac614b..e0dc60bd3c 100644
--- a/loader/pe_resource.c
+++ b/loader/pe_resource.c
@@ -22,6 +22,7 @@
//#include "process.h"
//#include "stackframe.h"
#include <wine/debugtools.h>
+#include <ext.h>
/**********************************************************************
* HMODULE32toPE_MODREF
diff --git a/loader/registry.c b/loader/registry.c
index c9b0f11676..9c6b0a6450 100644
--- a/loader/registry.c
+++ b/loader/registry.c
@@ -1,7 +1,9 @@
#include <config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <fcntl.h>
+#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>
@@ -11,6 +13,8 @@
#include <wine/winerror.h>
#include <registry.h>
+#include <ext.h>
+
//#undef TRACE
//#define TRACE printf
struct reg_value
@@ -40,14 +44,14 @@ static reg_handle_t* head=0;
extern char *get_path(char *);
-static void create_registry();
-static void open_registry();
-static void save_registry();
+static void create_registry(void);
+static void open_registry(void);
+static void save_registry(void);
-static void create_registry(){
+static void create_registry(void){
if(regs)
{
printf("Logic error: create_registry() called with existing registry\n");
@@ -65,7 +69,7 @@ static void create_registry(){
reg_size=2;
save_registry();
}
-static void open_registry()
+static void open_registry(void)
{
int fd;
int i;
@@ -120,7 +124,7 @@ error:
return;
}
-static void save_registry()
+static void save_registry(void)
{
int fd, i, len;
// struct passwd* pwent;
@@ -227,7 +231,7 @@ static char* build_keyname(long key, const char* subkey)
strcat(full_name, subkey);
return full_name;
}
-struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
+static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
{
reg_handle_t* t;
struct reg_value* v;
@@ -263,7 +267,7 @@ struct reg_value* insert_reg_value(int handle, const char* name, int type, const
return v;
}
-static void init_registry()
+static void init_registry(void)
{
#ifdef DETAILED_OUT
printf("Initializing registry\n");
diff --git a/loader/resource.c b/loader/resource.c
index 1c5b4654d8..aea0948784 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -7,6 +7,7 @@
#include <config.h>
#include <assert.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -20,6 +21,8 @@
#include <wine/module.h>
#include <wine/debugtools.h>
#include <wine/winerror.h>
+#include <loader.h>
+
#define CP_ACP 0
WORD WINE_LanguageId=0x409;//english
diff --git a/loader/setup_FS.c b/loader/setup_FS.c
index 588d4f2a1c..8bab360ceb 100644
--- a/loader/setup_FS.c
+++ b/loader/setup_FS.c
@@ -10,7 +10,7 @@
#ifdef __linux__
#include <asm/unistd.h>
#include <asm/ldt.h>
-#else
+#else /* !__linux__ */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <machine/sysarch.h>
@@ -22,7 +22,9 @@
/* solaris x86: add missing prototype for sysi86() */
extern int sysi86(int, void*);
#define TEB_SEL_IDX NUMSYSLDTS
-#endif
+#endif /* __svr4__ */
+
+
#define LDT_ENTRIES 8192
#define LDT_ENTRY_SIZE 8
@@ -42,7 +44,10 @@ struct modify_ldt_ldt_s {
#define MODIFY_LDT_CONTENTS_DATA 0
#define MODIFY_LDT_CONTENTS_STACK 1
#define MODIFY_LDT_CONTENTS_CODE 2
-#endif
+#endif /* !__linux__ */
+
+#include "setup_FS.h"
+
/* user level (privilege level: 3) ldt (1<<2) segment selector */
diff --git a/loader/setup_FS.h b/loader/setup_FS.h
new file mode 100644
index 0000000000..616af1d210
--- /dev/null
+++ b/loader/setup_FS.h
@@ -0,0 +1,10 @@
+
+#ifndef setup_FS_h
+#define setup_FS_h
+
+extern void setup_FS_Segment(void);
+extern void Setup_LDT_Keeper(void);
+extern void Restore_LDT_Keeper(void);
+
+
+#endif
diff --git a/loader/vfl.c b/loader/vfl.c
index a16986aa33..d15518c35e 100644
--- a/loader/vfl.c
+++ b/loader/vfl.c
@@ -6,6 +6,9 @@
#include <stdio.h>
#include <string.h>
+#include "win32.h"
+#include "loader.h"
+
#include "wine/winbase.h"
#include "wine/windef.h"
#include "wine/winuser.h"
@@ -13,29 +16,31 @@
#include "wine/winestring.h"
#include "wine/driver.h"
#include "wine/avifmt.h"
+#include "driver.h"
+
#define FIXME_(X) printf
#define FIXME printf
-long VFWAPI VideoForWindowsVersion(void);
-
-extern void* my_mreq(int size, int to_zero);
-extern void DrvClose(HDRVR hdrvr);
-extern int my_release(void* memory);
-
-long VFWAPIV ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits);
+#define OpenDriverA DrvOpen
+#define CloseDriver DrvClose
-WIN_BOOL VFWAPI ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
-LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo, long cb);
-HIC VFWAPI ICOpen(long fccType, long fccHandler, UINT wMode);
-HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
+long VFWAPI VideoForWindowsVersion(void);
-LRESULT VFWAPI ICClose(HIC hic);
-LRESULT VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2);
-HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
-#define OpenDriverA DrvOpen
-extern HDRVR VFWAPI DrvOpen(long);
+#if 1
+/*
+ * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
+ * WINAPI/no-WINAPI bustage.
+ *
+ * There should be no need for the STORE_ALL/REST_ALL hack once all
+ * function definitions agree with their prototypes (WINAPI-wise) and
+ * we make sure, that we do not call these functions without a proper
+ * prototype in scope.
+ */
+#define STORE_ALL /**/
+#define REST_ALL /**/
+#else
#define STORE_ALL \
__asm__ ( \
"push %%ebx\n\t" \
@@ -51,15 +56,9 @@ extern HDRVR VFWAPI DrvOpen(long);
"pop %%edx\n\t" \
"pop %%ecx\n\t" \
"pop %%ebx\n\t"::)
+#endif
-typedef struct {
- unsigned int uDriverSignature;
- void* hDriverModule;
- DRIVERPROC DriverProc;
- long dwDriverID;
-} DRVR;
-
/***********************************************************************
* VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
* Returns the version in major.minor form.
@@ -351,7 +350,9 @@ ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
WINE_HIC *whic = (WINE_HIC*)hic;
char qw[200];
+#if 0
__asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
+#endif
STORE_ALL;
/*__asm__
(
@@ -362,7 +363,9 @@ ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
);*/
ret = whic->driverproc(whic->private,1,msg,lParam1,lParam2);
REST_ALL;
+#if 0
__asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
+#endif
// } else
// ret = SendDriverMessage(whic->