summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-10-04 02:21:47 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-10-04 02:21:47 +0000
commit4f3776f018ba2b7d07180da5500ba7dd55567637 (patch)
tree0272ecded470c78c9b8d00a4d4128a79abf55d16
parentd60f718c2e4ebc7be2c8eb7fa933eff83bb8570b (diff)
downloadmpv-4f3776f018ba2b7d07180da5500ba7dd55567637.tar.bz2
mpv-4f3776f018ba2b7d07180da5500ba7dd55567637.tar.xz
sync with avifile
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2070 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--loader/Makefile2
-rw-r--r--loader/afl.c21
-rw-r--r--loader/driver.h4
-rw-r--r--loader/dshow/DS_AudioDecoder.c38
-rw-r--r--loader/dshow/DS_Filter.c9
-rw-r--r--loader/dshow/DS_VideoDecoder.c10
-rw-r--r--loader/dshow/allocator.c4
-rw-r--r--loader/dshow/cmediasample.c2
-rw-r--r--loader/dshow/guids.h12
-rw-r--r--loader/dshow/inputpin.c29
-rw-r--r--loader/dshow/interfaces.h2
-rw-r--r--loader/dshow/libwin32.h2
-rw-r--r--loader/dshow/outputpin.c2
-rw-r--r--loader/elfdll.c4
-rw-r--r--loader/ext.c50
-rw-r--r--loader/ldt_keeper.c2
-rw-r--r--loader/module.c116
-rw-r--r--loader/pe_image.c16
-rw-r--r--loader/registry.h37
-rw-r--r--loader/vfl.c2
-rw-r--r--loader/win32.c510
-rw-r--r--loader/win32.h23
-rw-r--r--loader/wineacm.h6
23 files changed, 544 insertions, 359 deletions
diff --git a/loader/Makefile b/loader/Makefile
index 1b5ea406ec..446c895f20 100644
--- a/loader/Makefile
+++ b/loader/Makefile
@@ -4,7 +4,7 @@ include ../config.mak
DEFINES=$(WIN32_PATH) -D__WINE__ -Ddbg_printf=__vprintf \
-DTRACE=__vprintf # -DDETAILED_OUT
-LIB_OBJECTS= setup_FS.o pe_image.o module.o \
+LIB_OBJECTS= ldt_keeper.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
diff --git a/loader/afl.c b/loader/afl.c
index bf79e75f27..d80ffbd6f1 100644
--- a/loader/afl.c
+++ b/loader/afl.c
@@ -19,7 +19,7 @@
***************************************************************************/
-#include <config.h>
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
@@ -27,17 +27,18 @@
#include "win32.h"
-#include <wine/winbase.h>
-#include <wine/windef.h>
-#include <wine/winuser.h>
-#include <wine/vfw.h>
-#include <wine/winestring.h>
-#include <wine/driver.h>
-#include <wine/winerror.h>
-#include <wine/msacm.h>
-#include <wine/msacmdrv.h>
+#include "wine/winbase.h"
+#include "wine/windef.h"
+#include "wine/winuser.h"
+#include "wine/vfw.h"
+#include "wine/winestring.h"
+#include "wine/driver.h"
+#include "wine/winerror.h"
+#include "wine/msacm.h"
+#include "wine/msacmdrv.h"
#include "wineacm.h"
#include "ext.h"
+
#include "driver.h"
#define OpenDriverA DrvOpen
diff --git a/loader/driver.h b/loader/driver.h
index 5f055fef43..59a7753353 100644
--- a/loader/driver.h
+++ b/loader/driver.h
@@ -2,8 +2,8 @@
#ifndef loader_driver_h
#define loader_driver_h
-#include <wine/windef.h>
-#include <wine/vfw.h>
+//#include "wine/windef.h"
+//#include "wine/vfw.h"
extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
extern void DrvClose(HDRVR hdrvr);
diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c
index cb6cb47d9e..26ad1406e1 100644
--- a/loader/dshow/DS_AudioDecoder.c
+++ b/loader/dshow/DS_AudioDecoder.c
@@ -4,12 +4,13 @@
Copyright 2001 Eugene Kuznetsov (divx@euro.ru)
*********************************************************/
+
#include "DS_AudioDecoder.h"
+#include <string.h>
+#include <stdio.h>
+
+// using namespace std;
-#include <cstdio>
-#include <cstring>
-#include <string>
-#include <iostream>
#define __MODULE__ "DirectShow audio decoder"
const GUID FORMAT_WaveFormatEx = {
0x05589f81, 0xc356, 0x11CE,
@@ -24,17 +25,16 @@ const GUID MEDIASUBTYPE_PCM = {
{ 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
};
-using namespace std;
-
typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
DS_AudioDecoder::DS_AudioDecoder(const CodecInfo& info, const WAVEFORMATEX* wf)
: IAudioDecoder(info, wf), m_pDS_Filter(0), m_sVhdr(0), m_sVhdr2(0)
{
- m_sVhdr=new char[18 + wf->cbSize];
- memcpy(m_sVhdr, wf, 18 + wf->cbSize);
- m_sVhdr2=new char[18 + wf->cbSize];
- memcpy(m_sVhdr2, m_sVhdr, 18 + wf->cbSize);
+ int sz = 18 + wf->cbSize;
+ m_sVhdr=new char[sz];
+ memcpy(m_sVhdr, wf, sz);
+ m_sVhdr2=new char[sz];
+ memcpy(m_sVhdr2, m_sVhdr, sz);
WAVEFORMATEX* pWF=(WAVEFORMATEX*)m_sVhdr2;
pWF->wFormatTag=1;
pWF->wBitsPerSample=16;
@@ -51,7 +51,7 @@ DS_AudioDecoder::DS_AudioDecoder(const CodecInfo& info, const WAVEFORMATEX* wf)
m_sOurType.bFixedSizeSamples=true;
m_sOurType.bTemporalCompression=false;
m_sOurType.pUnk=0;
- m_sOurType.cbFormat=18+wf->cbSize;
+ m_sOurType.cbFormat=sz;
m_sOurType.pbFormat=m_sVhdr;
memset(&m_sDestType, 0, sizeof(m_sDestType));
@@ -62,7 +62,7 @@ DS_AudioDecoder::DS_AudioDecoder(const CodecInfo& info, const WAVEFORMATEX* wf)
m_sDestType.bTemporalCompression=false;
m_sDestType.lSampleSize=2*wf->nChannels;
m_sDestType.pUnk=0;
- m_sDestType.cbFormat=18;
+ m_sDestType.cbFormat=pWF->cbSize;
m_sDestType.pbFormat=m_sVhdr2;
try
@@ -95,19 +95,19 @@ DS_AudioDecoder::~DS_AudioDecoder()
delete m_pDS_Filter;
}
-int DS_AudioDecoder::Convert(const void* in_data, size_t in_size,
- void* out_data, size_t out_size,
- size_t* size_read, size_t* size_written)
+int DS_AudioDecoder::Convert(const void* in_data, uint_t in_size,
+ void* out_data, uint_t out_size,
+ uint_t* size_read, uint_t* size_written)
{
if (!in_data || !out_data)
return -1;
- size_t written = 0;
- size_t read = 0;
+ uint_t written = 0;
+ uint_t read = 0;
in_size -= in_size%in_fmt.nBlockAlign;
while (in_size>0)
{
- size_t frame_size=0;
+ uint_t frame_size=0;
char* frame_pointer;
// m_pOurOutput->SetFramePointer(out_data+written);
m_pDS_Filter->m_pOurOutput->SetFramePointer(&frame_pointer);
@@ -116,7 +116,7 @@ int DS_AudioDecoder::Convert(const void* in_data, size_t in_size,
m_pDS_Filter->m_pAll->vt->GetBuffer(m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
if(!sample)
{
- Debug cerr<<"DS_AudioDecoder::Convert() Error: null sample"<<endl;
+ Debug printf("DS_AudioDecoder::Convert() Error: null sample\n");
break;
}
char* ptr;
diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c
index a057dd2cec..f625b74b87 100644
--- a/loader/dshow/DS_Filter.c
+++ b/loader/dshow/DS_Filter.c
@@ -1,7 +1,7 @@
#include "DS_Filter.h"
//#include "../loader/loader.h"
-#include <libwin32.h>
-#include <string>
+#include "libwin32.h"
+//#include <string>
#include <stdio.h>
#include <string.h>
@@ -213,7 +213,10 @@ void DS_Filter::Stop()
if (m_iState == 2)
{
m_pAll->vt->Release((IUnknown*)m_pAll);
- m_pFilter->vt->Stop(m_pFilter); // causes weird crash ??? FIXME
+ if (m_pFilter)
+ m_pFilter->vt->Stop(m_pFilter); // causes weird crash ??? FIXME
+ else
+ printf("m_pFilter is NULL!\n");
m_pAll = 0;
m_iState = 1;
}
diff --git a/loader/dshow/DS_VideoDecoder.c b/loader/dshow/DS_VideoDecoder.c
index c91eb70f77..a04817c495 100644
--- a/loader/dshow/DS_VideoDecoder.c
+++ b/loader/dshow/DS_VideoDecoder.c
@@ -9,9 +9,9 @@
#include "interfaces.h"
#include "DS_VideoDecoder.h"
-#include <wine/winerror.h>
-#include <libwin32.h>
-//#include <cpuinfo.h>
+#include "wine/winerror.h"
+#include "ldt_keeper.h"
+//#include <wine/winerror.h>
#include <unistd.h>
#include <fcntl.h>
@@ -24,10 +24,6 @@
#define __MODULE__ "DirectShow_VideoDecoder"
-#include "ldt_keeper.h"
-
-extern "C" char* def_path;
-
using namespace std;
DS_VideoDecoder::DS_VideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format, int flip)
diff --git a/loader/dshow/allocator.c b/loader/dshow/allocator.c
index 73b75b6fde..ce30e615d2 100644
--- a/loader/dshow/allocator.c
+++ b/loader/dshow/allocator.c
@@ -1,6 +1,6 @@
#include "allocator.h"
-#include <com.h>
-#include <wine/winerror.h>
+#include "com.h"
+#include "wine/winerror.h"
#include <stdio.h>
//#undef Debug
diff --git a/loader/dshow/cmediasample.c b/loader/dshow/cmediasample.c
index 1fdb9995e5..983ddbaeea 100644
--- a/loader/dshow/cmediasample.c
+++ b/loader/dshow/cmediasample.c
@@ -1,5 +1,5 @@
#include "cmediasample.h"
-#include <wine/winerror.h>
+#include "wine/winerror.h"
#include <stdio.h>
#include <string.h>
diff --git a/loader/dshow/guids.h b/loader/dshow/guids.h
index 9c08a0f86e..f29c6a6e15 100644
--- a/loader/dshow/guids.h
+++ b/loader/dshow/guids.h
@@ -1,12 +1,12 @@
#ifndef GUIDS_H
#define GUIDS_H
-#include <com.h>
-#include <wine/winbase.h>
-#include <wine/windef.h>
-#include <wine/winuser.h>
-#include <wine/vfw.h>
-//#include <formats.h>
+#include "com.h"
+#include "wine/winbase.h"
+#include "wine/windef.h"
+#include "wine/winuser.h"
+#include "wine/vfw.h"
+
extern int DSHOW_DEBUG;
#define Debug if(DSHOW_DEBUG)
diff --git a/loader/dshow/inputpin.c b/loader/dshow/inputpin.c
index 9f0c50322b..9578674ada 100644
--- a/loader/dshow/inputpin.c
+++ b/loader/dshow/inputpin.c
@@ -1,5 +1,5 @@
#include "inputpin.h"
-#include <wine/winerror.h>
+#include "wine/winerror.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -49,24 +49,17 @@ class CEnumPins: public IEnumPins
public:
CEnumPins(IPin*, IPin* =0);
~CEnumPins(){delete vt;}
- static long STDCALL Next (
- IEnumPins * This,
- /* [in] */ unsigned long cMediaTypes,
- /* [size_is][out] */ IPin **ppMediaTypes,
- /* [out] */ unsigned long *pcFetched);
-
- static long STDCALL Skip (
- IEnumPins * This,
- /* [in] */ unsigned long cMediaTypes);
-
- static long STDCALL Reset (
- IEnumPins * This);
-
- static long STDCALL Clone (
- IEnumPins * This,
- /* [out] */ IEnumPins **ppEnum);
-
+ static long STDCALL Next (IEnumPins * This,
+ /* [in] */ unsigned long cMediaTypes,
+ /* [size_is][out] */ IPin **ppMediaTypes,
+ /* [out] */ unsigned long *pcFetched);
+ static long STDCALL Skip (IEnumPins * This,
+ /* [in] */ unsigned long cMediaTypes);
+ static long STDCALL Reset (IEnumPins * This);
+ static long STDCALL Clone (IEnumPins * This,
+ /* [out] */ IEnumPins **ppEnum);
};
+
GUID CEnumPins::interfaces[]=
{
IID_IUnknown,
diff --git a/loader/dshow/interfaces.h b/loader/dshow/interfaces.h
index 4708bee233..4f299ee2b4 100644
--- a/loader/dshow/interfaces.h
+++ b/loader/dshow/interfaces.h
@@ -9,7 +9,7 @@ Created using freely-available DirectX 8.0 SDK
*/
-#include <com.h>
+#include "com.h"
#include "guids.h"
#ifndef STDCALL
diff --git a/loader/dshow/libwin32.h b/loader/dshow/libwin32.h
index 592fe9d454..038002fca9 100644
--- a/loader/dshow/libwin32.h
+++ b/loader/dshow/libwin32.h
@@ -36,6 +36,8 @@
#include <string>
#include <stdio.h>
+typedef unsigned int uint_t; // use as generic type -
+
typedef unsigned int fourcc_t;
struct FatalError
diff --git a/loader/dshow/outputpin.c b/loader/dshow/outputpin.c
index e9c3382981..22311d77dc 100644
--- a/loader/dshow/outputpin.c
+++ b/loader/dshow/outputpin.c
@@ -1,7 +1,7 @@
#include "outputpin.h"
#include "allocator.h"
#include "iunk.h"
-#include <wine/winerror.h>
+#include "wine/winerror.h"
#include <cstdio>
#include <cstring>
diff --git a/loader/elfdll.c b/loader/elfdll.c
index 840868c6b7..8b8c7656c8 100644
--- a/loader/elfdll.c
+++ b/loader/elfdll.c
@@ -7,10 +7,10 @@
#ifdef HAVE_LIBDL
-#include <string.h>
-#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include <wine/windef.h>
//#include <wine/global.h>
diff --git a/loader/ext.c b/loader/ext.c
index 8fec3951d1..b6368f0dfd 100644
--- a/loader/ext.c
+++ b/loader/ext.c
@@ -67,7 +67,7 @@ LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
return malloc(size);
}
-WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags,LPVOID mem)
+WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags, LPVOID mem)
{
if (mem) free(mem);
return 1;
@@ -82,15 +82,15 @@ DWORD WINAPI GetLastError(void)
VOID WINAPI SetLastError(DWORD error)
{
- last_error = error;
+ last_error=error;
}
-WIN_BOOL WINAPI ReadFile(HANDLE handle,LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
+WIN_BOOL WINAPI ReadFile(HANDLE handle, LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
{
*result=read(handle, mem, size);
return *result;
}
-int WINAPI lstrcmpiA(const char* c1, const char* c2)
+INT WINAPI lstrcmpiA(LPCSTR c1, LPCSTR c2)
{
return strcasecmp(c1,c2);
}
@@ -98,7 +98,7 @@ LPSTR WINAPI lstrcpynA(LPSTR dest, LPCSTR src, INT num)
{
return strncpy(dest,src,num);
}
-int WINAPI lstrlenA(const char* s)
+INT WINAPI lstrlenA(LPCSTR s)
{
return strlen(s);
}
@@ -114,7 +114,7 @@ INT WINAPI lstrlenW(LPCWSTR s)
}
LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
{
- LPSTR rval = dest;
+ LPSTR result = dest;
int moved=0;
if((dest==0) || (src==0))
return 0;
@@ -127,14 +127,16 @@ LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
src++;
dest++;
}
- return rval;
+ return result;
}
int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
{
+ /*
if(s1==0)
return;
if(s2==0)
return;
+ */
while(n>0)
{
if(*s1<*s2)
@@ -309,7 +311,7 @@ typedef struct file_mapping_s
{
int mapping_size;
char* name;
- HANDLE handle;
+ LPVOID handle;
struct file_mapping_s* next;
struct file_mapping_s* prev;
}file_mapping;
@@ -335,7 +337,7 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
{
int hFile = (int)handle;
unsigned int len;
- HANDLE answer;
+ LPVOID answer;
int anon=0;
int mmap_access=0;
if(hFile<0)
@@ -357,10 +359,10 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
else
mmap_access |=PROT_READ|PROT_WRITE;
- answer=(HANDLE)mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
+ answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
if(anon)
close(hFile);
- if(answer!=(HANDLE)-1)
+ if(answer!=(LPVOID)-1)
{
if(fm==0)
{
@@ -386,7 +388,7 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
if(anon)
close(hFile);
- return answer;
+ return (HANDLE)answer;
}
return (HANDLE)0;
}
@@ -395,10 +397,10 @@ WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
file_mapping* p;
int result;
if(fm==0)
- return (HANDLE)0;
+ return 0;
for(p=fm; p; p=p->next)
{
- if(p->handle==(HANDLE)handle)
+ if(p->handle==handle)
{
result=munmap((void*)handle, p->mapping_size);
if(p->next)p->next->prev=p->prev;
@@ -427,7 +429,7 @@ static virt_alloc* vm=0;
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
-void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protection)
+LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protection)
{
void* answer;
int fd=open("/dev/zero", O_RDWR);
@@ -474,7 +476,7 @@ void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protecti
if(answer==(void*)-1)
{
printf("Error no %d\n", errno);
- printf("VirtualAlloc(0x%08X, %d) failed\n", address, size);
+ printf("VirtualAlloc(0x%p, %ld) failed\n", address, size);
return NULL;
}
else
@@ -497,7 +499,7 @@ void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protecti
return answer;
}
}
-WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
+WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
{
virt_alloc* str=vm;
int answer;
@@ -518,14 +520,13 @@ WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
return -1;
}
-INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags,
- LPCWSTR src, INT srclen,
- LPSTR dest, INT destlen,
- LPCSTR defch, WIN_BOOL*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)
return 0;
+ if ((srclen==-1)&&(dest==0)) return 0;
if(srclen==-1){srclen=0; while(src[srclen++]);}
// for(i=0; i<srclen; i++)
// printf("%c", src[i]);
@@ -552,9 +553,8 @@ INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags,
}
return min(srclen, destlen);
}
-INT WINAPI MultiByteToWideChar(UINT codepage, DWORD flags,
- LPCSTR src, INT srclen,
- LPWSTR dest, INT destlen)
+INT WINAPI MultiByteToWideChar(UINT codepage,DWORD flags, LPCSTR src, INT srclen,
+ LPWSTR dest, INT destlen)
{
return 0;
}
@@ -570,7 +570,7 @@ HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name)
if(p->name==0)
continue;
if(strcmp(p->name, name)==0)
- return p->handle;
+ return (HANDLE)p->handle;
}
return 0;
}
diff --git a/loader/ldt_keeper.c b/loader/ldt_keeper.c
index 2ddbcb77b7..c1a909eacf 100644
--- a/loader/ldt_keeper.c
+++ b/loader/ldt_keeper.c
@@ -72,6 +72,8 @@ struct modify_ldt_ldt_s {
#endif
#define TEB_SEL LDT_SEL(TEB_SEL_IDX)
+#include "ldt_keeper.h"
+
/**
*
* This should be performed before we create first thread. See remarks
diff --git a/loader/module.c b/loader/module.c
index e2eb306cc2..c2c88bb74d 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -12,14 +12,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-
#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>
@@ -53,6 +47,10 @@ struct modify_ldt_ldt_s {
#include <wine/module.h>
#include <wine/pe_image.h>
#include <wine/debugtools.h>
+#ifdef HAVE_LIBDL
+#include <dlfcn.h>
+#include <wine/elfdll.h>
+#endif
#include "win32.h"
struct modref_list_t;
@@ -61,13 +59,15 @@ typedef struct modref_list_t
{
WINE_MODREF* wm;
struct modref_list_t *next;
- struct modref_list_t *prev;
+ struct modref_list_t *prev;
}
modref_list;
//WINE_MODREF *local_wm=NULL;
modref_list* local_wm=NULL;
+//HANDLE SegptrHeap; // unused?
+
WINE_MODREF *MODULE_FindModule(LPCSTR m)
{
modref_list* list=local_wm;
@@ -80,10 +80,10 @@ WINE_MODREF *MODULE_FindModule(LPCSTR m)
list=list->prev;
if(list==NULL)
return NULL;
- }
+ }
TRACE("Resolved to %s\n", list->wm->filename);
return list->wm;
-}
+}
static void MODULE_RemoveFromList(WINE_MODREF *mod)
{
@@ -113,8 +113,8 @@ static void MODULE_RemoveFromList(WINE_MODREF *mod)
return;
}
}
-}
-
+}
+
WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
{
modref_list* list=local_wm;
@@ -128,10 +128,10 @@ WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
list=list->prev;
if(list==NULL)
return NULL;
- }
- TRACE("LookupHMODULE hit %X\n", list->wm);
+ }
+ TRACE("LookupHMODULE hit %p\n", list->wm);
return list->wm;
-}
+}
/*************************************************************************
* MODULE_InitDll
@@ -140,7 +140,7 @@ static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
{
WIN_BOOL retv = TRUE;
- static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
+ static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
"THREAD_ATTACH", "THREAD_DETACH" };
assert( wm );
@@ -181,14 +181,14 @@ static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
/*************************************************************************
* MODULE_DllProcessAttach
- *
+ *
* Send the process attach notification to all DLLs the given module
* depends on (recursively). This is somewhat complicated due to the fact that
*
* - we have to respect the module dependencies, i.e. modules implicitly
* referenced by another module have to be initialized before the module
* itself can be initialized
- *
+ *
* - the initialization routine of a DLL can itself call LoadLibrary,
* thereby introducing a whole new set of dependencies (even involving
* the 'old' modules) at any time during the whole process
@@ -199,7 +199,7 @@ static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
*
* Furthermore, we need to rearrange the main WINE_MODREF list to allow
* the process *detach* notifications to be sent in the correct order.
- * This must not only take into account module dependencies, but also
+ * This must not only take into account module dependencies, but also
* 'hidden' dependencies created by modules calling LoadLibrary in their
* attach notification routine.
*
@@ -248,10 +248,10 @@ WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
local_wm=malloc(sizeof(modref_list));
local_wm->next=local_wm->prev=NULL;
local_wm->wm=wm;
- }
+ }
/* Remove recursion flag */
wm->flags &= ~WINE_MODREF_MARKER;
-
+
if ( retv )
{
retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved );
@@ -267,8 +267,8 @@ WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
/*************************************************************************
* MODULE_DllProcessDetach
- *
- * Send DLL process detach notifications. See the comment about calling
+ *
+ * Send DLL process detach notifications. See the comment about calling
* sequence at MODULE_DllProcessAttach. Unless the bForceDetach flag
* is set, only DLLs with zero refcount are notified.
*/
@@ -285,18 +285,59 @@ void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpR
*/
HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
{
- WINE_MODREF *wm;
-
+ WINE_MODREF *wm = 0;
+ char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
+ extern char* def_path;
+ char path[512];
+ char checked[2000];
+ int i = -1;
+
+ checked[0] = 0;
if(!libname)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
+
+ printf("Loading DLL: '%s'\n", libname);
+
// if(fs_installed==0)
// install_fs();
-
- wm = MODULE_LoadLibraryExA( libname, hfile, flags );
+ while (wm == 0 && listpath[++i])
+ {
+ if (i < 2)
+ {
+ if (i == 0)
+ /* check just original file name */
+ strncpy(path, libname, 511);
+ else
+ /* check default user path */
+ strncpy(path, def_path, 300);
+ }
+ else if (strcmp(def_path, listpath[i]))
+ /* path from the list */
+ strncpy(path, listpath[i], 300);
+ else
+ continue;
+
+ if (i > 0)
+ {
+ strcat(path, "/");
+ strncat(path, libname, 100);
+ }
+ path[511] = 0;
+ wm = MODULE_LoadLibraryExA( path, hfile, flags );
+
+ if (!wm)
+ {
+ if (checked[0])
+ strcat(checked, ", ");
+ strcat(checked, path);
+ checked[1500] = 0;
+
+ }
+ }
if ( wm )
{
if ( !MODULE_DllProcessAttach( wm, NULL ) )
@@ -309,6 +350,10 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
}
}
+ if (!wm)
+ printf("Win32 LoadLibrary failed to load: %s\n", checked);
+
+
return wm ? wm->module : 0;
}
@@ -331,7 +376,6 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
int i;
// module_loadorder_t *plo;
-
SetLastError( ERROR_FILE_NOT_FOUND );
TRACE("Trying native dll '%s'\n", libname);
pwm = PE_LoadLibraryExA(libname, flags);
@@ -340,8 +384,8 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
{
TRACE("Trying ELF dll '%s'\n", libname);
pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
- }
-#endif
+ }
+#endif
// printf("0x%08x\n", pwm);
// break;
if(pwm)
@@ -356,7 +400,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
return pwm;
}
-
+
WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
return NULL;
}
@@ -384,10 +428,10 @@ WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
{
SetLastError( ERROR_INVALID_HANDLE );
return 0;
- }
+ }
else
retv = MODULE_FreeLibrary( wm );
-
+
MODULE_RemoveFromList(wm);
/* garbage... */
@@ -459,13 +503,13 @@ FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
/***********************************************************************
* MODULE_GetProcAddress (internal)
*/
-FARPROC MODULE_GetProcAddress(
+FARPROC MODULE_GetProcAddress(
HMODULE hModule, /* [in] current module handle */
LPCSTR function, /* [in] function to be looked up */
WIN_BOOL snoop )
{
WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
-// WINE_MODREF *wm=local_wm;
+// WINE_MODREF *wm=local_wm;
FARPROC retproc;
if (HIWORD(function))
@@ -482,9 +526,9 @@ FARPROC MODULE_GetProcAddress(
retproc = PE_FindExportedFunction( wm, function, snoop );
if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
return retproc;
-#ifdef HAVE_LIBDL
+#ifdef HAVE_LIBDL
case MODULE32_ELF:
- retproc = (FARPROC) dlsym( (void*)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 5d383c3d29..498e4eeeee 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -33,7 +33,8 @@
* newer pe binaries produced by MSVC 5 and later, since they are also aligned
* to 4096 byte boundaries on disk.
*/
-#include <config.h>
+#include "config.h"
+//#include <wine/config.h>
#include <errno.h>
#include <assert.h>
@@ -44,9 +45,6 @@
#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
@@ -57,8 +55,7 @@
#include <wine/pe_image.h>
#include <wine/module.h>
#include <wine/debugtools.h>
-#include <ext.h>
-
+#include "ext.h"
#include "win32.h"
#define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x)))
@@ -179,7 +176,7 @@ FARPROC PE_FindExportedFunction(
ename = RVA(name[i]);
if (!strcmp( ename, funcName ))
{
- ERR( "%s.%s required a linear search\n", wm->modname, funcName );
+ ERR( "%s.%s required a linear search\n", wm->modname, funcName );
ordinal = ordinals[i];
goto found;
}
@@ -565,6 +562,7 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
}
}
+
load_addr = nt->OptionalHeader.ImageBase;
vma_size = calc_vma_size( hModule );
@@ -884,6 +882,7 @@ void PE_UnloadLibrary(WINE_MODREF *wm)
* due to the PROCESS_Creat