# HG changeset patch # User arpi # Date 1002162107 0 # Node ID ce45cce7f7a54b5e62ea7ab9cca380badeccc5ef # Parent 3189c317dfc13cc469a707ac4483364409779d98 sync with avifile diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/Makefile --- a/loader/Makefile Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/Makefile Thu Oct 04 02:21:47 2001 +0000 @@ -4,7 +4,7 @@ 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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/afl.c --- a/loader/afl.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/afl.c Thu Oct 04 02:21:47 2001 +0000 @@ -19,7 +19,7 @@ ***************************************************************************/ -#include +#include "config.h" #include #include @@ -27,17 +27,18 @@ #include "win32.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/driver.h --- a/loader/driver.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/driver.h Thu Oct 04 02:21:47 2001 +0000 @@ -2,8 +2,8 @@ #ifndef loader_driver_h #define loader_driver_h -#include -#include +//#include "wine/windef.h" +//#include "wine/vfw.h" extern HDRVR VFWAPI DrvOpen(LPARAM lParam2); extern void DrvClose(HDRVR hdrvr); diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/DS_AudioDecoder.c --- a/loader/dshow/DS_AudioDecoder.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/DS_AudioDecoder.c Thu Oct 04 02:21:47 2001 +0000 @@ -4,12 +4,13 @@ Copyright 2001 Eugene Kuznetsov (divx@euro.ru) *********************************************************/ -#include "DS_AudioDecoder.h" -#include -#include -#include -#include +#include "DS_AudioDecoder.h" +#include +#include + +// using namespace std; + #define __MODULE__ "DirectShow audio decoder" const GUID FORMAT_WaveFormatEx = { 0x05589f81, 0xc356, 0x11CE, @@ -24,17 +25,16 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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"< -#include +#include "libwin32.h" +//#include #include #include @@ -213,7 +213,10 @@ 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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/DS_VideoDecoder.c --- a/loader/dshow/DS_VideoDecoder.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/DS_VideoDecoder.c Thu Oct 04 02:21:47 2001 +0000 @@ -9,9 +9,9 @@ #include "interfaces.h" #include "DS_VideoDecoder.h" -#include -#include -//#include +#include "wine/winerror.h" +#include "ldt_keeper.h" +//#include #include #include @@ -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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/allocator.c --- a/loader/dshow/allocator.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/allocator.c Thu Oct 04 02:21:47 2001 +0000 @@ -1,6 +1,6 @@ #include "allocator.h" -#include -#include +#include "com.h" +#include "wine/winerror.h" #include //#undef Debug diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/cmediasample.c --- a/loader/dshow/cmediasample.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/cmediasample.c Thu Oct 04 02:21:47 2001 +0000 @@ -1,5 +1,5 @@ #include "cmediasample.h" -#include +#include "wine/winerror.h" #include #include diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/guids.h --- a/loader/dshow/guids.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/guids.h Thu Oct 04 02:21:47 2001 +0000 @@ -1,12 +1,12 @@ #ifndef GUIDS_H #define GUIDS_H -#include -#include -#include -#include -#include -//#include +#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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/inputpin.c --- a/loader/dshow/inputpin.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/inputpin.c Thu Oct 04 02:21:47 2001 +0000 @@ -1,5 +1,5 @@ #include "inputpin.h" -#include +#include "wine/winerror.h" #include #include #include @@ -49,24 +49,17 @@ 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 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 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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/interfaces.h --- a/loader/dshow/interfaces.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/interfaces.h Thu Oct 04 02:21:47 2001 +0000 @@ -9,7 +9,7 @@ */ -#include +#include "com.h" #include "guids.h" #ifndef STDCALL diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/libwin32.h --- a/loader/dshow/libwin32.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/libwin32.h Thu Oct 04 02:21:47 2001 +0000 @@ -36,6 +36,8 @@ #include #include +typedef unsigned int uint_t; // use as generic type - + typedef unsigned int fourcc_t; struct FatalError diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/dshow/outputpin.c --- a/loader/dshow/outputpin.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/dshow/outputpin.c Thu Oct 04 02:21:47 2001 +0000 @@ -1,7 +1,7 @@ #include "outputpin.h" #include "allocator.h" #include "iunk.h" -#include +#include "wine/winerror.h" #include #include diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/elfdll.c --- a/loader/elfdll.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/elfdll.c Thu Oct 04 02:21:47 2001 +0000 @@ -7,10 +7,10 @@ #ifdef HAVE_LIBDL +#include +#include #include #include -#include -#include #include //#include diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/ext.c --- a/loader/ext.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/ext.c Thu Oct 04 02:21:47 2001 +0000 @@ -67,7 +67,7 @@ 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 @@ 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 @@ { return strncpy(dest,src,num); } -int WINAPI lstrlenA(const char* s) +INT WINAPI lstrlenA(LPCSTR s) { return strlen(s); } @@ -114,7 +114,7 @@ } 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 @@ 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 @@ { 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 @@ { 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 @@ 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 @@ if(anon) close(hFile); - return answer; + return (HANDLE)answer; } return (HANDLE)0; } @@ -395,10 +397,10 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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; iname==0) continue; if(strcmp(p->name, name)==0) - return p->handle; + return (HANDLE)p->handle; } return 0; } diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/ldt_keeper.c --- a/loader/ldt_keeper.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/ldt_keeper.c Thu Oct 04 02:21:47 2001 +0000 @@ -72,6 +72,8 @@ #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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/module.c --- a/loader/module.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/module.c Thu Oct 04 02:21:47 2001 +0000 @@ -12,14 +12,8 @@ #include #include #include - #include #include -#ifdef HAVE_LIBDL -#include -#include -#endif - /* #ifdef __linux__ #include @@ -53,6 +47,10 @@ #include #include #include +#ifdef HAVE_LIBDL +#include +#include +#endif #include "win32.h" struct modref_list_t; @@ -61,13 +59,15 @@ { 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 @@ 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 @@ return; } } -} - +} + WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m) { modref_list* list=local_wm; @@ -128,10 +128,10 @@ 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 @@ { 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 @@ /************************************************************************* * 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 @@ * * 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 @@ 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 @@ /************************************************************************* * 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 @@ */ 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(); - + + 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; - wm = MODULE_LoadLibraryExA( libname, hfile, flags ); + 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 @@ } } + if (!wm) + printf("Win32 LoadLibrary failed to load: %s\n", checked); + + return wm ? wm->module : 0; } @@ -331,7 +376,6 @@ 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 @@ { 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 @@ return pwm; } - + WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError()); return NULL; } @@ -384,10 +428,10 @@ { SetLastError( ERROR_INVALID_HANDLE ); return 0; - } + } else retv = MODULE_FreeLibrary( wm ); - + MODULE_RemoveFromList(wm); /* garbage... */ @@ -459,13 +503,13 @@ /*********************************************************************** * 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 @@ 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 -r 3189c317dfc1 -r ce45cce7f7a5 loader/pe_image.c --- a/loader/pe_image.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/pe_image.c Thu Oct 04 02:21:47 2001 +0000 @@ -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 +#include "config.h" +//#include #include #include @@ -44,9 +45,6 @@ #include #include #include -#ifdef HAVE_ALLOCA_H -#include -#endif #ifdef HAVE_SYS_MMAN_H #include #endif @@ -57,8 +55,7 @@ #include #include #include -#include - +#include "ext.h" #include "win32.h" #define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x))) @@ -179,7 +176,7 @@ 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 @@ } } + load_addr = nt->OptionalHeader.ImageBase; vma_size = calc_vma_size( hModule ); @@ -884,6 +882,7 @@ * due to the PROCESS_Create stuff. */ + /* * This is a dirty hack. * The win32 DLLs contain an alloca routine, that first probes the soon @@ -898,11 +897,12 @@ */ static void extend_stack_for_dll_alloca(void) { +#ifndef __FreeBSD__ 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 diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/registry.h --- a/loader/registry.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/registry.h Thu Oct 04 02:21:47 2001 +0000 @@ -1,24 +1,33 @@ -/******************************************************** - - Declaration of registry access functions - Copyright 2000 Eugene Smith (divx@euro.ru) +#ifndef AVIFILE_REGISTRY_H +#define AVIFILE_REGISTRY_H -*********************************************************/ - +/******************************************************** + * + * Declaration of registry access functions + * Copyright 2000 Eugene Kuznetsov (divx@euro.ru) + * + ********************************************************/ -#ifndef REGISTRY_H -#define REGISTRY_H #ifdef __cplusplus extern "C" { #endif -long RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey); + +long RegOpenKeyExA(long key, const char* subkey, long reserved, + long access, int* newkey); long RegCloseKey(long key); -long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count); +long RegQueryValueExA(long key, const char* value, int* reserved, + int* type, int* data, int* count); long RegCreateKeyExA(long key, const char* name, long reserved, - void* classs, long options, long security, - void* sec_attr, int* newkey, int* status); -long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size); + void* classs, long options, long security, + void* sec_attr, int* newkey, int* status); +long RegSetValueExA(long key, const char* name, long v1, long v2, + const void* data, long size); +#ifdef __WINE_WINERROR_H +long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, + LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count); +#endif #ifdef __cplusplus }; #endif -#endif + +#endif // AVIFILE_REGISTRY_H diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/vfl.c --- a/loader/vfl.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/vfl.c Thu Oct 04 02:21:47 2001 +0000 @@ -351,6 +351,8 @@ WINE_HIC *whic = (WINE_HIC*)hic; char qw[200]; +// printf("ICSendMessage.whic=%p\n",whic); + #if 0 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); #endif diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/win32.c --- a/loader/win32.c Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/win32.c Thu Oct 04 02:21:47 2001 +0000 @@ -11,14 +11,21 @@ ************************************************************/ -#include +#include "config.h" +#include "wine/winbase.h" +#include "wine/winreg.h" +#include "wine/winnt.h" +#include "wine/winerror.h" +#include "wine/debugtools.h" +#include "wine/module.h" #include "win32.h" + #include +#include +#include #include #include -#include -#include #ifdef HAVE_MALLOC_H #include #endif @@ -28,38 +35,29 @@ #include #include #include -#if HAVE_LIBKSTAT +#ifdef HAVE_KSTAT #include #endif -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, - LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count); +#include "registry.h" +#include "loader.h" +#include "com.h" char* def_path=WIN32_PATH; static void do_cpuid(unsigned int ax, unsigned int *regs) { - __asm__ __volatile__( - "pushl %%ebx; pushl %%ecx; pushl %%edx; " - ".byte 0x0f, 0xa2;" - "movl %%eax, (%2);" - "movl %%ebx, 4(%2);" - "movl %%ecx, 8(%2);" - "movl %%edx, 12(%2);" - "popl %%edx; popl %%ecx; popl %%ebx; " - : "=a" (ax) - : "0" (ax), "S" (regs)); + __asm__ __volatile__( + "pushl %%ebx; pushl %%ecx; pushl %%edx;" + ".byte 0x0f, 0xa2;" + "movl %%eax, (%2);" + "movl %%ebx, 4(%2);" + "movl %%ecx, 8(%2);" + "movl %%edx, 12(%2);" + "popl %%edx; popl %%ecx; popl %%ebx;" + : "=a" (ax) + : "0" (ax), "S" (regs) + ); } static unsigned int c_localcount_tsc() { @@ -102,9 +100,8 @@ result+=limit*tv.tv_usec; *z=result; } - static unsigned int localcount_stub(void); -static void longcount_stub(long long* z); +static void longcount_stub(long long*); static unsigned int (*localcount)()=localcount_stub; static void (*longcount)(long long*)=longcount_stub; @@ -141,7 +138,7 @@ longcount(z); } -int LOADER_DEBUG=1; +int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT static inline void dbgprintf(char* fmt, ...) { #ifdef DETAILED_OUT @@ -171,7 +168,7 @@ static unsigned char* heap=NULL; static int heap_counter=0; -static void test_heap() +static void test_heap(void) { int offset=0; if(heap==0) @@ -224,11 +221,11 @@ if(to_zero) memset(heap+heap_counter, 0, size); else - memset(heap+heap_counter, 0xcc, size); + memset(heap+heap_counter, 0xcc, size); // make crash reprocable heap_counter+=size; return heap+heap_counter-size; } -int my_release(void* memory) +int my_release(char* memory) { // test_heap(); if(memory==NULL) @@ -299,7 +296,7 @@ } else { for(;pp;pp=pp->prev) { - if (pp->addr == memory-4) { + if (pp->addr == (char*)memory-4) { if (pp->prev) pp->prev->next=pp->next; if (pp->next) @@ -312,26 +309,48 @@ } } if (pp == NULL) { - printf("Not Found %p %d\n",memory-4,alccnt); + printf("Not Found %p %d\n",(char*)memory-4,alccnt); return 0; } } } #endif - free(memory-4); + free((char*)memory-4); return 0; } #endif -int my_size(char* memory) +int my_size(void* memory) +{ + return *(int*)((char*)memory-4); +} +void* my_realloc(void* memory,int size) { - return *(int*)(memory-4); -} + void *ans; +#ifdef GARBAGE + alc_list* pp; + if(memory == NULL)return 0; + pp=alclist; + if(pp == NULL) return 0; + ans=NULL; + for(;pp;pp=pp->prev) { + if (pp->addr == (char*)memory-4) { + ans = realloc(memory-4,size+4); + if (ans == 0) return 0; + pp->size = size; + pp->addr = ans; + } + } +#else + ans = realloc(memory-4,size+4); +#endif + return ans; +} extern int unk_exp1; char extcode[20000];// place for 200 unresolved exports int pos=0; -int WINAPI ext_unknown(void) +int WINAPI ext_unknown() { printf("Unknown func called\n"); return 0; @@ -408,21 +427,23 @@ return 0; } -void* WINAPI expGetDriverModuleHandle(DRVR* pdrv) +HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv) { - void* result; - if (pdrv==NULL) - result=NULL; + HMODULE result; + if (pdrv==NULL) + result=0; else - result=(void*) pdrv->hDriverModule; - dbgprintf("GetDriverModuleHandle(0x%x) => 0x%x\n", pdrv, result); + result=pdrv->hDriverModule; + dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result); return result; } -void* WINAPI expGetModuleHandleA(const char* name) +#define MODULE_HANDLE_kernel32 ((HMODULE)0x120) + +HMODULE WINAPI expGetModuleHandleA(const char* name) { WINE_MODREF* wm; - void* result; + HMODULE result; if(!name) result=0; else @@ -430,12 +451,12 @@ wm=MODULE_FindModule(name); if(wm==0)result=0; else - result=(void*)(wm->module); + result=(HMODULE)(wm->module); } if(!result) { if(strcasecmp(name, "kernel32")==0) - result=(void *) 0x120; + result=MODULE_HANDLE_kernel32; } dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result); return result; @@ -515,7 +536,7 @@ pSecAttr, bManualReset, bInitialState, name, name, pp->pm); return pp->pm; } - }while((pp=pp->prev)); + }while((pp=pp->prev) != NULL); } pm=my_mreq(sizeof(pthread_mutex_t), 0); pthread_mutex_init(pm, NULL); @@ -584,18 +605,20 @@ void* WINAPI expWaitForSingleObject(void* object, int duration) { mutex_list *ml = (mutex_list *)object; - int ret=WAIT_FAILED; // fixed by Zdenek Kabelac + // FIXME FIXME FIXME - this value is sometime unititialize !!! + int ret = WAIT_FAILED; mutex_list* pp=mlist; -// dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration); + dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration); + // loop below was slightly fixed - its used just for checking if // this object really exists in our list if (!ml) return (void*) ret; while (pp && (pp->pm != ml->pm)) - pp = pp->prev; + pp = pp->prev; if (!pp) { - //dbgprintf("WaitForSingleObject: NotFound\n"); - return (void*)ret; + dbgprintf("WaitForSingleObject: NotFound\n"); + return (void*)ret; } pthread_mutex_lock(ml->pm); @@ -679,8 +702,7 @@ static int cache = 0; static SYSTEM_INFO cachedsi; unsigned int regs[4]; - HKEY xhkey=0,hkey; - dbgprintf("GetSystemInfo(0x%d) =>\n"); + dbgprintf("GetSystemInfo(%p) =>\n", si); if (cache) { memcpy(si,&cachedsi,sizeof(*si)); @@ -735,7 +757,6 @@ if (!f) return; - xhkey = 0; while (fgets(line,200,f)!=NULL) { char *s,*value; @@ -771,7 +792,7 @@ } } /* set the CPU type of the current processor */ - snprintf(buf,20,"CPU %ld",cachedsi.dwProcessorType); + sprintf(buf,"CPU %ld",cachedsi.dwProcessorType); continue; } /* old 2.0 method */ @@ -798,7 +819,7 @@ } } /* set the CPU type of the current processor */ - snprintf(buf,20,"CPU %ld",cachedsi.dwProcessorType); + sprintf(buf,"CPU %ld",cachedsi.dwProcessorType); continue; } if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) { @@ -824,7 +845,7 @@ /* Create a new processor subkey on a multiprocessor * system */ - snprintf(buf,20,"%d",x); + sprintf(buf,"%d",x); } if (!lstrncmpiA(line,"stepping",strlen("stepping"))) { int x; @@ -853,6 +874,7 @@ cachedsi.dwNumberOfProcessors=1; } #endif /* __FreeBSD__ */ + cache = 1; memcpy(si,&cachedsi,sizeof(*si)); DumpSystemInfo(si); } @@ -908,6 +930,19 @@ dbgprintf("HeapSize(heap 0x%x, flags 0x%x, pointer 0x%x) => %d\n", heap, flags, pointer, result); return result; } +void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void *lpMem,int size) +{ + long orgsize; + void *newp; + orgsize = my_size(lpMem); + dbgprintf("HeapReAlloc() Size %ld org %d\n",orgsize,size); + if (size < orgsize) + return lpMem; + newp=my_mreq(size, flags & 8); + memcpy(newp, lpMem, orgsize); + my_release(lpMem); + return newp; +} long WINAPI expGetProcessHeap(void) { dbgprintf("GetProcessHeap() => 1\n"); @@ -934,6 +969,7 @@ pthread_mutex_t mutex; int locked; }; + void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c) { struct CRITSECT cs; @@ -955,6 +991,12 @@ { struct CRITSECT* cs=*(struct CRITSECT**)c; dbgprintf("EnterCriticalSection(0x%x)\n",c); + if (!cs) + { + expInitializeCriticalSection(c); + cs=*(struct CRITSECT**)c; + printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c); + } // cs.id=pthread_self(); if(cs->locked) if(cs->id==pthread_self()) @@ -969,6 +1011,11 @@ struct CRITSECT* cs=*(struct CRITSECT**)c; // struct CRITSECT* cs=(struct CRITSECT*)c; dbgprintf("LeaveCriticalSection(0x%x)\n",c); + if (!cs) + { + printf("Win32 Warning: Leaving noninitialized Critical Section %p!!\n", c); + return; + } cs->locked=0; pthread_mutex_unlock(&(cs->mutex)); return; @@ -993,13 +1040,13 @@ return getpid(); } -struct tls_s -{ +struct tls_s { void* value; int used; struct tls_s* prev; struct tls_s* next; }; + tls_t* g_tls=NULL; void* WINAPI expTlsAlloc() @@ -1017,6 +1064,7 @@ g_tls=g_tls->next; } dbgprintf("TlsAlloc() => 0x%x\n", g_tls); + g_tls->value=0; /* XXX For Divx.dll */ return g_tls; } @@ -1072,6 +1120,30 @@ dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z); return z; } + +void* WINAPI expLocalReAlloc(int handle,int size, int flags) +{ + void *newpointer; + int oldsize; + + newpointer=NULL; + if (flags & LMEM_MODIFY) { + dbgprintf("LocalReAlloc MODIFY\n"); + return (void *)handle; + } + oldsize = my_size((void *)handle); + if (size > oldsize) { + newpointer=my_realloc((void *)handle,size); + } + else { + newpointer=(void *)handle; + } + dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer); + + return newpointer; + +} + void* WINAPI expLocalLock(void* z) { dbgprintf("LocalLock(0x%x) => 0x%x\n", z, z); @@ -1130,12 +1202,12 @@ result=i; } if(s1) - dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s', " - "size %d, dest buffer 0x%x, dest size %d) => %d\n", + dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s', + size %d, dest buffer 0x%x, dest size %d) => %d\n", v1, v2, s1, s1, siz1, s2, siz2, result); else - dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL, " - "size %d, dest buffer 0x%x, dest size %d) =>\n", + dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL, + size %d, dest buffer 0x%x, dest size %d) =>\n", v1, v2, siz1, s2, siz2, result); return result; } @@ -1152,7 +1224,7 @@ "dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3); result=WideCharToMultiByte(v1, v2, s1, siz1, s2, siz2, c3, siz3); dbgprintf("=> %d\n", result); - if(s1)wch_print(s1); + //if(s1)wch_print(s1); if(s2)dbgprintf(" dest: %s\n", s2); return result; } @@ -1163,10 +1235,16 @@ c->dwMajorVersion=4; c->dwMinorVersion=0; c->dwBuildNumber=0x4000457; +#if 0 + // leave it here for testing win9x-only codecs c->dwPlatformId=VER_PLATFORM_WIN32_WINDOWS; strcpy(c->szCSDVersion, " B"); +#else + c->dwPlatformId=VER_PLATFORM_WIN32_NT; // let's not make DLL assume that it can read CR* registers + strcpy(c->szCSDVersion, "Service Pack 3"); +#endif dbgprintf(" Major version: 4\n Minor version: 0\n Build number: 0x4000457\n" - " Platform Id: VER_PLATFORM_WIN32_WINDOWS\n Version string: ' B'\n"); + " Platform Id: VER_PLATFORM_WIN32_NT\n Version string: 'Service Pack 3'\n"); return 1; } HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, char* name) @@ -1185,7 +1263,7 @@ v1, init_count, max_count, name, name, mlist); return (HANDLE)mlist; } - }while((pp=pp->prev)); + }while((pp=pp->prev) != NULL); } pm=my_mreq(sizeof(pthread_mutex_t), 0); pthread_mutex_init(pm, NULL); @@ -1297,6 +1375,13 @@ return result; } +DWORD WINAPI expRegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, + LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count) +{ + return RegEnumValueA(hkey, index, value, val_count, + reserved, type, data, count); +} + long WINAPI expQueryPerformanceCounter(long long* z) { longcount(z); @@ -1641,17 +1726,18 @@ dbgprintf("SetUnhandledExceptionFilter(0x%x) => 1\n", filter); return 1;//unsupported and probably won't ever be supported } -extern char* def_path; + int WINAPI expLoadLibraryA(char* name) { - char qq[256]; - int result; + int result = 0; char* lastbc; + int i; if (!name) return -1; // we skip to the last backslash // this is effectively eliminating weird characters in // the text output windows + lastbc = strrchr(name, '\\'); if (lastbc) { @@ -1664,52 +1750,43 @@ break; } } -// printf("LoadLibrary wants: %s/%s\n", def_path, name); - - if(strncmp(name, "c:\\windows\\", 11)==0)name+=11; + if(strncmp(name, "c:\\windows\\", 11)==0) name += 11; if(strncmp(name, ".\\", 2)==0) name += 2; - if(name[0]!='/') - { - strcpy(qq, def_path); - strcat(qq, "/"); - strcat(qq, name); - } - printf("Loading DLL: %s", qq);fflush(stdout); -// printf("Entering LoadLibraryA(%s)\n", name); - result=LoadLibraryA(qq); - if(!result) printf(" FAILED!\n"); else printf(" OK\n"); -// printf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result); + + dbgprintf("Entering LoadLibraryA(%s)\n", name); + result=LoadLibraryA(name); + dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result); + return result; -} +} int WINAPI expFreeLibrary(int module) { int result=FreeLibrary(module); dbgprintf("FreeLibrary(0x%x) => %d\n", module, result); return result; } -void* LookupExternalByName(const char* library, const char* name); void* WINAPI expGetProcAddress(HMODULE mod, char* name) { - void *result; - if(mod!=0x120) + void* result; + if(mod!=MODULE_HANDLE_kernel32) result=GetProcAddress(mod, name); else result=LookupExternalByName("kernel32.dll", name); dbgprintf("GetProcAddress(0x%x, '%s') => 0x%x\n", mod, name, result); return result; -} +} long WINAPI expCreateFileMappingA(int hFile, void* lpAttr, long flProtect, long dwMaxHigh, long dwMaxLow, const char* name) { long result=CreateFileMappingA(hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name); if(!name) - dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, " - "flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0) => %d\n", + dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, + flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0) => %d\n", hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, result); else - dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, " - "flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0x%x='%s') => %d\n", + dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x, + flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0x%x='%s') => %d\n", hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name, name, result); return result; } @@ -1741,7 +1818,9 @@ void* WINAPI expSleep(int time) { +// extern int avm_usleep(int); dbgprintf("Sleep(%d) => 0\n", time); +// avm_usleep(time); usleep(time); return 0; } @@ -1986,10 +2065,12 @@ int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax) { - int result=snprintf(str, cbMax, "%.8lx-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", - guid->f1, guid->f2, guid->f3, - (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], - (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]); + int result=snprintf(str, cbMax, "%.8x-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", + guid->f1, guid->f2, guid->f3, + (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], + (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], + (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], + (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]); dbgprintf("StringFromGUID2(0x%x, 0x%x='%s', %d) => %d\n", guid, str, str, cbMax, result); return result; } @@ -2009,16 +2090,6 @@ if(string)wch_print(string); return result; } - -int WINAPI expIsBadStringPtrA(const char* string, int nchars) -{ - int result=0; -// if(string==0)result=1; else result=0; -// dbgprintf("IsBadStringPtrW(0x%x, %d) => %d", string, nchars, result); -// if(string)wch_print(string); - return result; -} - extern long WINAPI InterlockedExchangeAdd( long* dest, long incr ) { long ret; @@ -2075,6 +2146,54 @@ dbgprintf("SetCursor(0x%x) => 0x%x\n", cursor, cursor); return (int)cursor; } +int WINAPI expGetCursorPos(void *cursor) +{ + dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor); + return 1; +} +int WINAPI expRegisterWindowMessageA(char *message) +{ + dbgprintf("RegisterWindowMessageA(%s)\n", message); + return 1; +} +int WINAPI expGetProcessVersion(int pid) +{ + dbgprintf("GetProcessVersion(%d)\n", pid); + return 1; +} +int WINAPI expGetCurrentThread(void) +{ + dbgprintf("GetCurrentThread()\n"); + return 1; +} +int WINAPI expGetOEMCP(void) +{ + dbgprintf("GetOEMCP()\n"); + return 1; +} +int WINAPI expGetCPInfo(int cp,void *info) +{ + dbgprintf("GetCPInfo()\n"); + return 0; +} +int WINAPI expGetSystemMetrics(int index) +{ + dbgprintf("GetSystemMetrics(%d)\n", index); + return 1; +} +int WINAPI expGetSysColor(int index) +{ + dbgprintf("GetSysColor(%d)\n", index); + return 1; +} +int WINAPI expGetSysColorBrush(int index) +{ + dbgprintf("GetSysColorBrush(%d)\n", index); + return 1; +} + + + int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe) { dbgprintf("GetSystemPaletteEntries(0x%x, 0x%x, 0x%x, 0x%x) => 0\n", @@ -2166,6 +2285,7 @@ " Milliseconds: %d\n", systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay, systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds); + return 0; } int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size) @@ -2205,14 +2325,51 @@ static int com_object_size=0; int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs) { - if(!clsid)return -1; - if(!gcs)return -1; + if(!clsid || !gcs) + return -1; com_object_table=realloc(com_object_table, sizeof(struct COM_OBJECT_INFO)*(++com_object_size)); com_object_table[com_object_size-1].clsid=*clsid; com_object_table[com_object_size-1].GetClassObject=gcs; return 0; } +int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs) +{ + int found = 0; + int i = 0; + if(!clsid || !gcs) + return -1; + + if (com_object_table == 0) + printf("Warning: UnregisterComClass() called without any registered class\n"); + while (i < com_object_size) + { + if (found && i > 0) + { + memcpy(&com_object_table[i - 1].clsid, + &com_object_table[i].clsid, sizeof(GUID)); + com_object_table[i - 1].GetClassObject = + com_object_table[i].GetClassObject; + } + else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0 + && com_object_table[i].GetClassObject == gcs) + { + found++; + } + i++; + } + if (found) + { + if (--com_object_size == 0) + { + free(com_object_table); + com_object_table = 0; + } + } + return 0; +} + + GUID IID_IUnknown={0x00000000, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; GUID IID_IClassFactory={0x00000001, 0x0000, 0x0000, @@ -2442,31 +2599,6 @@ return 1; } - -/****************************************************************************** - * RegEnumValueA [ADVAPI32.@] - */ - DWORD WINAPI expRegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, - LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count ) -{ - -// printf("RegEnumValueA(%x,%ld,%p,%p,%p,%p,%p,%p)\n", -// hkey, index, value, val_count, reserved, type, data, count ); -// return -1; - - return RegEnumValueA(hkey, index, value, val_count, - reserved, type, data, count); - -} - - -#if 0 -INT WINAPI expMulDiv(int nNumber,int nNumerator,int nDenominator) -{ - return ((long long)nNumber * (long long)nNumerator) / nDenominator; -} -#endif - int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator) { static const long long max_int=0x7FFFFFFFLL; @@ -2499,6 +2631,23 @@ dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); return result; } +LONG WINAPI explstrcpynA(char* str1, const char* str2,int len) +{ + int result; + if (strlen(str2)>len) + result = (int) strncpy(str1, str2,len); + else + result = (int) strcpy(str1,str2); + dbgprintf("strncpy(0x%x, 0x%x='%s' len %d strlen %d) => %x\n", str1, str2, str2,len, strlen(str2),result); + return result; +} +LONG WINAPI explstrcatA(char* str1, const char* str2) +{ + int result= (int) strcat(str1, str2); + dbgprintf("strcat(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); + return result; +} + LONG WINAPI expInterlockedExchange(long *dest, long l) { @@ -2508,57 +2657,12 @@ return retval; } -int WINAPI expUnknownMFC42_1176() /* exact number of arguments unknown */ -{ - dbgprintf("MFC42:1176\n"); - return 0; -} - -int WINAPI expUnknownMFC42_1243() /* exact number of arguments unknown */ -{ - dbgprintf("MFC42:1243\n"); - return 0; -} - -int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs) +void WINAPI expInitCommonControls() { - int found = 0; - int i = 0; - if(!clsid || !gcs) - return -1; - - if (com_object_table == 0) - printf("Warning: UnregisterComClass() called without any registered class\n"); - while (i < com_object_size) - { - if (found && i > 0) - { - memcpy(&com_object_table[i - 1].clsid, - &com_object_table[i].clsid, sizeof(GUID)); - com_object_table[i - 1].GetClassObject = - com_object_table[i].GetClassObject; - } - else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0 - && com_object_table[i].GetClassObject == gcs) - { - found++; - } - i++; - } - if (found) - { - if (--com_object_size == 0) - { - free(com_object_table); - com_object_table = 0; - } - } - return 0; + printf("InitCommonControls called!\n"); + return; } - - - struct exports { char name[64]; @@ -2579,7 +2683,6 @@ FF(IsBadWritePtr, 357) FF(IsBadReadPtr, 354) FF(IsBadStringPtrW, -1) -FF(IsBadStringPtrA, -1) FF(DisableThreadLibraryCalls, -1) FF(CreateThread, -1) FF(CreateEventA, -1) @@ -2593,6 +2696,7 @@ FF(HeapDestroy, -1) FF(HeapFree, -1) FF(HeapSize, -1) +FF(HeapReAlloc,-1) FF(GetProcessHeap, -1) FF(VirtualAlloc, -1) FF(VirtualFree, -1) @@ -2607,6 +2711,7 @@ FF(GetCurrentThreadId, -1) FF(GetCurrentProcess, -1) FF(LocalAlloc, -1) +FF(LocalReAlloc,-1) FF(LocalLock, -1) FF(GlobalAlloc, -1) FF(GlobalReAlloc, -1) @@ -2688,6 +2793,12 @@ FF(lstrcmpiA, -1) FF(lstrlenA, -1) FF(lstrcpyA, -1) +FF(lstrcatA, -1) +FF(GetProcessVersion,-1) +FF(GetCurrentThread,-1) +FF(GetOEMCP,-1) +FF(GetCPInfo,-1) +FF(lstrcpynA,-1) }; struct exports exp_msvcrt[]={ @@ -2724,6 +2835,12 @@ FF(IsRectEmpty, -1) FF(LoadCursorA,-1) FF(SetCursor,-1) +FF(GetCursorPos,-1) +FF(GetCursorPos,-1) +FF(RegisterWindowMessageA,-1) +FF(GetSystemMetrics,-1) +FF(GetSysColor,-1) +FF(GetSysColorBrush,-1) }; struct exports exp_advapi32[]={ FF(RegOpenKeyA, -1) @@ -2732,7 +2849,7 @@ FF(RegQueryValueExA, -1) FF(RegSetValueExA, -1) FF(RegCloseKey, -1) -//FF(RegEnumValueA, -1) +FF(RegEnumValueA, -1) }; struct exports exp_gdi32[]={ FF(CreateCompatibleDC, -1) @@ -2749,13 +2866,13 @@ FF(CoCreateInstance, -1) FF(StringFromGUID2, -1) }; -struct exports exp_mfc42[]={ -FF(UnknownMFC42_1176, 1176) -FF(UnknownMFC42_1243, 1243) -}; struct exports exp_crtdll[]={ FF(memcpy, -1) }; +struct exports exp_comctl32[]={ +FF(StringFromGUID2, -1) +FF(InitCommonControls, 17) +}; #define LL(X) \ {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X}, @@ -2769,10 +2886,11 @@ LL(gdi32) LL(version) LL(ole32) -LL(mfc42) LL(crtdll) +LL(comctl32) }; + void* LookupExternal(const char* library, int ordinal) { char* answ; @@ -2793,7 +2911,7 @@ { if(ordinal!=libraries[i].exps[j].id) continue; - printf("Hit: 0x%08X\n", libraries[i].exps[j].func); + printf("Hit: 0x%p\n", libraries[i].exps[j].func); return libraries[i].exps[j].func; } } @@ -2851,7 +2969,7 @@ // return (void*)ext_unknown; } -int my_garbagecollection(void) +void my_garbagecollection(void) { #ifdef GARBAGE alc_list* pp,*ppsv; @@ -2877,7 +2995,7 @@ } } - if (alclist==NULL) return 0; + if (alclist==NULL) return; pp=alclist; unfree=unfreecnt=0; diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/win32.h --- a/loader/win32.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/win32.h Thu Oct 04 02:21:47 2001 +0000 @@ -9,8 +9,9 @@ extern void* my_mreq(int size, int to_zero); extern int my_release(void* memory); -extern int my_size(char* memory); -extern int my_garbagecollection(void); +extern int my_size(void* memory); +extern void* my_realloc(void *memory,int size); +extern void my_garbagecollection(void); typedef struct { @@ -31,8 +32,8 @@ extern int WINAPI expIsBadWritePtr(void* ptr, unsigned int count); extern int WINAPI expIsBadReadPtr(void* ptr, unsigned int count); extern int WINAPI expDisableThreadLibraryCalls(int module); -extern void* WINAPI expGetDriverModuleHandle(DRVR* pdrv); -extern void* WINAPI expGetModuleHandleA(const char* name); +extern HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv); +extern HMODULE WINAPI expGetModuleHandleA(const char* name); extern void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress, void* lpParameter, long dwFlags, long* dwThreadId); extern void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset, @@ -48,6 +49,7 @@ extern void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size); extern long WINAPI expHeapDestroy(void* heap); extern long WINAPI expHeapFree(int arg1, int arg2, void* ptr); +extern void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void* lpMem,int size); extern long WINAPI expHeapSize(int heap, int flags, void* pointer); extern long WINAPI expGetProcessHeap(void); extern void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4); @@ -63,6 +65,7 @@ extern void* WINAPI expTlsGetValue(tls_t* index); extern int WINAPI expTlsFree(tls_t* index); extern void* WINAPI expLocalAlloc(int flags, int size); +extern void* WINAPI expLocalReAlloc(int handle,int size,int flags); extern void* WINAPI expLocalLock(void* z); extern void* WINAPI expGlobalAlloc(int flags, int size); extern void* WINAPI expGlobalLock(void* z); @@ -147,6 +150,15 @@ extern int WINAPI expReleaseDC(int hwnd, int hdc); extern int WINAPI expLoadCursorA(int handle,LPCSTR name); extern int WINAPI expSetCursor(void *cursor); +extern int WINAPI expGetCursorPos(void *cursor); +extern int WINAPI expRegisterWindowMessageA(char *message); +extern int WINAPI expGetProcessVersion(int pid); +extern int WINAPI expGetCurrentThread(void); +extern int WINAPI expGetOEMCP(void); +extern int WINAPI expGetCPInfo(int cp,void *info); +extern int WINAPI expGetSysColor(int pid); +extern int WINAPI expGetSysColorBrush(int pid); +extern int WINAPI expGetSystemMetrics(int index); extern int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe); extern int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation); extern void WINAPI expGetLocalTime(SYSTEMTIME* systime); @@ -185,6 +197,8 @@ extern LONG WINAPI explstrcmpiA(const char* str1, const char* str2); extern LONG WINAPI explstrlenA(const char* str1); extern LONG WINAPI explstrcpyA(char* str1, const char* str2); +extern LONG WINAPI explstrcpynA(char* str1, const char* str2,int len); +extern LONG WINAPI explstrcatA(char* str1, const char* str2); extern LONG WINAPI expInterlockedExchange(long *dest, long l); extern void* CDECL expmalloc(int size); @@ -206,5 +220,6 @@ extern void *expmemcpy(void* dest, void* src, int n) ; extern time_t exptime(time_t* t); extern void* LookupExternal(const char* library, int ordinal); +extern void* LookupExternalByName(const char* library, const char* name); #endif diff -r 3189c317dfc1 -r ce45cce7f7a5 loader/wineacm.h --- a/loader/wineacm.h Thu Oct 04 00:24:05 2001 +0000 +++ b/loader/wineacm.h Thu Oct 04 02:21:47 2001 +0000 @@ -43,9 +43,9 @@ extern HANDLE MSACM_hHeap; extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID; extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID; -PWINE_ACMDRIVERID MSACM_RegisterDriver( - LPSTR pszDriverAlias, LPSTR pszFileName, - HINSTANCE hinstModule); +PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, + LPSTR pszFileName, + HINSTANCE hinstModule); void MSACM_RegisterAllDrivers(void); PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p); void MSACM_UnregisterAllDrivers(void);