summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-01-07 02:17:10 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-01-07 02:17:10 +0000
commit0adff4cf87927e281295acdecc099c4c12084f80 (patch)
tree7f0defbcc4f66bd38b76ec3e4f543c8a825d2a4f /src
parent2d0d8c1d7c76a3537ed9bfa4509560c2749877d9 (diff)
downloadxine-lib-0adff4cf87927e281295acdecc099c4c12084f80.tar.gz
xine-lib-0adff4cf87927e281295acdecc099c4c12084f80.tar.bz2
acelpnet should work now (some files updated from mplayer cvs)
CVS patchset: 1360 CVS date: 2002/01/07 02:17:10
Diffstat (limited to 'src')
-rw-r--r--src/libw32dll/w32codec.c3
-rw-r--r--src/libw32dll/wine/Makefile.am6
-rw-r--r--src/libw32dll/wine/avifmt.h490
-rw-r--r--src/libw32dll/wine/driver.c254
-rw-r--r--src/libw32dll/wine/elfdll.c18
-rw-r--r--src/libw32dll/wine/ext.c67
-rw-r--r--src/libw32dll/wine/ext.h3
-rw-r--r--src/libw32dll/wine/loader.h24
-rw-r--r--src/libw32dll/wine/module.c191
-rw-r--r--src/libw32dll/wine/pe_image.c15
-rw-r--r--src/libw32dll/wine/pe_resource.c16
-rw-r--r--src/libw32dll/wine/registry.c223
-rw-r--r--src/libw32dll/wine/registry.h7
-rw-r--r--src/libw32dll/wine/resource.c18
-rw-r--r--src/libw32dll/wine/vfl.c108
-rw-r--r--src/libw32dll/wine/win32.c3162
-rw-r--r--src/libw32dll/wine/win32.h219
-rw-r--r--src/libw32dll/wine/winbase.h3
-rw-r--r--src/libw32dll/wine/winnt.h5
19 files changed, 2744 insertions, 2088 deletions
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index 8facc1c54..e57d32ef2 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: w32codec.c,v 1.54 2002/01/06 18:56:19 miguelfreitas Exp $
+ * $Id: w32codec.c,v 1.55 2002/01/07 02:17:10 miguelfreitas Exp $
*
* routines for using w32 codecs
* DirectShow support by Miguel Freitas (Nov/2001)
@@ -771,7 +771,6 @@ static char* get_auds_codec_name(w32a_decoder_t *this, int buf_type) {
this->guid=&CLSID_Voxware;
return "voxmsdec.ax";
case BUF_AUDIO_ACELPNET:
- /* acelpnet is not working yet */
this->ds_driver=1;
this->guid=&CLSID_Acelp;
return "acelpdec.ax";
diff --git a/src/libw32dll/wine/Makefile.am b/src/libw32dll/wine/Makefile.am
index ac7f113ea..3c9f9999f 100644
--- a/src/libw32dll/wine/Makefile.am
+++ b/src/libw32dll/wine/Makefile.am
@@ -6,11 +6,13 @@ noinst_LTLIBRARIES = $(wine_lib)
##
CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \
-Wmissing-prototypes -Wimplicit-function-declaration \
- -DWIN32_PATH=\"@w32_path@\"
+ -DWIN32_PATH=\"@w32_path@\" -I.. -D__WINE__ \
+ -Ddbg_printf=__vprintf -DTRACE=__vprintf -fno-omit-frame-pointer
DEBUG_CFLAGS = @DEBUG_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \
-Wmissing-prototypes -Wimplicit-function-declaration \
- -DWIN32_PATH=\\\"@w32_path@\\\"
+ -DWIN32_PATH=\\\"@w32_path@\\\" -I.. -D__WINE__ \
+ -Ddbg_printf=__vprintf -DTRACE=__vprintf -fno-omit-frame-pointer
if HAVE_W32DLL
diff --git a/src/libw32dll/wine/avifmt.h b/src/libw32dll/wine/avifmt.h
index 904d55bca..a703dc967 100644
--- a/src/libw32dll/wine/avifmt.h
+++ b/src/libw32dll/wine/avifmt.h
@@ -1,244 +1,246 @@
-/****************************************************************************
- *
- * AVIFMT - AVI file format definitions
- *
- ****************************************************************************/
-#ifndef AVIFMT
-#define AVIFMT
-
-#ifndef NOAVIFMT
-
-#ifndef __WINE_WINDEF_H
-#include "windef.h"
-#endif
-
-#ifndef __WINE_MMSYSTEM_H
-#ifndef __WINE_MSACM_H
-typedef DWORD FOURCC;
-#endif
-#endif
-
-
-#ifdef _MSC_VER
-#pragma warning(disable:4200)
-#endif
-
-/* The following is a short description of the AVI file format. Please
- * see the accompanying documentation for a full explanation.
- *
- * An AVI file is the following RIFF form:
- *
- * RIFF('AVI'
- * LIST('hdrl'
- * avih(<MainAVIHeader>)
- * LIST ('strl'
- * strh(<Stream header>)
- * strf(<Stream format>)
- * ... additional header data
- * LIST('movi'
- * { LIST('rec'
- * SubChunk...
- * )
- * | SubChunk } ....
- * )
- * [ <AVIIndex> ]
- * )
- *
- * The main file header specifies how many streams are present. For
- * each one, there must be a stream header chunk and a stream format
- * chunk, enlosed in a 'strl' LIST chunk. The 'strf' chunk contains
- * type-specific format information; for a video stream, this should
- * be a BITMAPINFO structure, including palette. For an audio stream,
- * this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
- *
- * The actual data is contained in subchunks within the 'movi' LIST
- * chunk. The first two characters of each data chunk are the
- * stream number with which that data is associated.
- *
- * Some defined chunk types:
- * Video Streams:
- * ##db: RGB DIB bits
- * ##dc: RLE8 compressed DIB bits
- * ##pc: Palette Change
- *
- * Audio Streams:
- * ##wb: waveform audio bytes
- *
- * The grouping into LIST 'rec' chunks implies only that the contents of
- * the chunk should be read into memory at the same time. This
- * grouping is used for files specifically intended to be played from
- * CD-ROM.
- *
- * The index chunk at the end of the file should contain one entry for
- * each data chunk in the file.
- *
- * Limitations for the current software:
- * Only one video stream and one audio stream are allowed.
- * The streams must start at the beginning of the file.
- *
- *
- * To register codec types please obtain a copy of the Multimedia
- * Developer Registration Kit from:
- *
- * Microsoft Corporation
- * Multimedia Systems Group
- * Product Marketing
- * One Microsoft Way
- * Redmond, WA 98052-6399
- *
- */
-
-#ifndef mmioFOURCC
-#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
- ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
- ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
-#endif
-
-/* Macro to make a TWOCC out of two characters */
-#ifndef aviTWOCC
-#define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
-#endif
-
-typedef WORD TWOCC;
-
-/* form types, list types, and chunk types */
-#define formtypeAVI mmioFOURCC('A', 'V', 'I', ' ')
-#define listtypeAVIHEADER mmioFOURCC('h', 'd', 'r', 'l')
-#define ckidAVIMAINHDR mmioFOURCC('a', 'v', 'i', 'h')
-#define listtypeSTREAMHEADER mmioFOURCC('s', 't', 'r', 'l')
-#define ckidSTREAMHEADER mmioFOURCC('s', 't', 'r', 'h')
-#define ckidSTREAMFORMAT mmioFOURCC('s', 't', 'r', 'f')
-#define ckidSTREAMHANDLERDATA mmioFOURCC('s', 't', 'r', 'd')
-#define ckidSTREAMNAME mmioFOURCC('s', 't', 'r', 'n')
-
-#define listtypeAVIMOVIE mmioFOURCC('m', 'o', 'v', 'i')
-#define listtypeAVIRECORD mmioFOURCC('r', 'e', 'c', ' ')
-
-#define ckidAVINEWINDEX mmioFOURCC('i', 'd', 'x', '1')
-
-/*
-** Stream types for the <fccType> field of the stream header.
-*/
-#define streamtypeVIDEO mmioFOURCC('v', 'i', 'd', 's')
-#define streamtypeAUDIO mmioFOURCC('a', 'u', 'd', 's')
-#define streamtypeMIDI mmioFOURCC('m', 'i', 'd', 's')
-#define streamtypeTEXT mmioFOURCC('t', 'x', 't', 's')
-
-/* Basic chunk types */
-#define cktypeDIBbits aviTWOCC('d', 'b')
-#define cktypeDIBcompressed aviTWOCC('d', 'c')
-#define cktypePALchange aviTWOCC('p', 'c')
-#define cktypeWAVEbytes aviTWOCC('w', 'b')
-
-/* Chunk id to use for extra chunks for padding. */
-#define ckidAVIPADDING mmioFOURCC('J', 'U', 'N', 'K')
-
-/*
-** Useful macros
-**
-** Warning: These are nasty macro, and MS C 6.0 compiles some of them
-** incorrectly if optimizations are on. Ack.
-*/
-
-/* Macro to get stream number out of a FOURCC ckid */
-#define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
-#define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
- (FromHex(HIBYTE(LOWORD(fcc))))))
-
-/* Macro to get TWOCC chunk type out of a FOURCC ckid */
-#define TWOCCFromFOURCC(fcc) HIWORD(fcc)
-
-/* Macro to make a ckid for a chunk out of a TWOCC and a stream number
-** from 0-255.
-*/
-#define ToHex(n) ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
-#define MAKEAVICKID(tcc, stream) \
- MAKELONG((ToHex((stream) & 0x0f) << 8) | \
- (ToHex(((stream) & 0xf0) >> 4)), tcc)
-
-/*
-** Main AVI File Header
-*/
-
-/* flags for use in <dwFlags> in AVIFileHdr */
-#define AVIF_HASINDEX 0x00000010 // Index at end of file?
-#define AVIF_MUSTUSEINDEX 0x00000020
-#define AVIF_ISINTERLEAVED 0x00000100
-#define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
-#define AVIF_WASCAPTUREFILE 0x00010000
-#define AVIF_COPYRIGHTED 0x00020000
-
-/* The AVI File Header LIST chunk should be padded to this size */
-#define AVI_HEADERSIZE 2048 // size of AVI header list
-
-typedef struct
-{
- DWORD dwMicroSecPerFrame; // frame display rate (or 0L)
- DWORD dwMaxBytesPerSec; // max. transfer rate
- DWORD dwPaddingGranularity; // pad to multiples of this
- // size; normally 2K.
- DWORD dwFlags; // the ever-present flags
- DWORD dwTotalFrames; // # frames in file
- DWORD dwInitialFrames;
- DWORD dwStreams;
- DWORD dwSuggestedBufferSize;
-
- DWORD dwWidth;
- DWORD dwHeight;
-
- DWORD dwReserved[4];
-} MainAVIHeader;
-
-/*
-** Stream header
-*/
-
-#define AVISF_DISABLED 0x00000001
-
-#define AVISF_VIDEO_PALCHANGES 0x00010000
-
-
-typedef struct {
- FOURCC fccType;
- FOURCC fccHandler;
- DWORD dwFlags; /* Contains AVITF_* flags */
- WORD wPriority;
- WORD wLanguage;
- DWORD dwInitialFrames;
- DWORD dwScale;
- DWORD dwRate; /* dwRate / dwScale == samples/second */
- DWORD dwStart;
- DWORD dwLength; /* In units above... */
- DWORD dwSuggestedBufferSize;
- DWORD dwQuality;
- DWORD dwSampleSize;
- RECT rcFrame;
-} AVIStreamHeader;
-
-/* Flags for index */
-#define AVIIF_LIST 0x00000001L // chunk is a 'LIST'
-#define AVIIF_KEYFRAME 0x00000010L // this frame is a key frame.
-
-#define AVIIF_NOTIME 0x00000100L // this frame doesn't take any time
-#define AVIIF_COMPUSE 0x0FFF0000L // these bits are for compressor use
-
-#define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F')
-#define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T')
-
-typedef struct
-{
- DWORD ckid;
- DWORD dwFlags;
- DWORD dwChunkOffset; // Position of chunk
- DWORD dwChunkLength; // Length of chunk
-} AVIINDEXENTRY;
-
-#define AVISTREAMREAD_CONVENIENT (-1L)
-
-/*
-** Palette change chunk
-**
-** Used in video streams.
-*/
-#endif /* NOAVIFMT */
-#endif
+/****************************************************************************
+ *
+ * AVIFMT - AVI file format definitions
+ *
+ ****************************************************************************/
+#ifndef AVIFMT
+
+#define AVIFMT
+
+#ifndef NOAVIFMT
+
+
+#ifndef __WINE_WINDEF_H
+#include "windef.h"
+#endif
+
+#ifndef __WINE_MMSYSTEM_H
+#ifndef __WINE_MSACM_H
+typedef DWORD FOURCC;
+#endif
+#endif
+
+
+#ifdef _MSC_VER
+#pragma warning(disable:4200)
+#endif
+
+/* The following is a short description of the AVI file format. Please
+ * see the accompanying documentation for a full explanation.
+ *
+ * An AVI file is the following RIFF form:
+ *
+ * RIFF('AVI'
+ * LIST('hdrl'
+ * avih(<MainAVIHeader>)
+ * LIST ('strl'
+ * strh(<Stream header>)
+ * strf(<Stream format>)
+ * ... additional header data
+ * LIST('movi'
+ * { LIST('rec'
+ * SubChunk...
+ * )
+ * | SubChunk } ....
+ * )
+ * [ <AVIIndex> ]
+ * )
+ *
+ * The main file header specifies how many streams are present. For
+ * each one, there must be a stream header chunk and a stream format
+ * chunk, enlosed in a 'strl' LIST chunk. The 'strf' chunk contains
+ * type-specific format information; for a video stream, this should
+ * be a BITMAPINFO structure, including palette. For an audio stream,
+ * this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
+ *
+ * The actual data is contained in subchunks within the 'movi' LIST
+ * chunk. The first two characters of each data chunk are the
+ * stream number with which that data is associated.
+ *
+ * Some defined chunk types:
+ * Video Streams:
+ * ##db: RGB DIB bits
+ * ##dc: RLE8 compressed DIB bits
+ * ##pc: Palette Change
+ *
+ * Audio Streams:
+ * ##wb: waveform audio bytes
+ *
+ * The grouping into LIST 'rec' chunks implies only that the contents of
+ * the chunk should be read into memory at the same time. This
+ * grouping is used for files specifically intended to be played from
+ * CD-ROM.
+ *
+ * The index chunk at the end of the file should contain one entry for
+ * each data chunk in the file.
+ *
+ * Limitations for the current software:
+ * Only one video stream and one audio stream are allowed.
+ * The streams must start at the beginning of the file.
+ *
+ *
+ * To register codec types please obtain a copy of the Multimedia
+ * Developer Registration Kit from:
+ *
+ * Microsoft Corporation
+ * Multimedia Systems Group
+ * Product Marketing
+ * One Microsoft Way
+ * Redmond, WA 98052-6399
+ *
+ */
+
+#ifndef mmioFOURCC
+#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
+ ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
+ ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
+#endif
+
+/* Macro to make a TWOCC out of two characters */
+#ifndef aviTWOCC
+#define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
+#endif
+
+typedef WORD TWOCC;
+
+/* form types, list types, and chunk types */
+#define formtypeAVI mmioFOURCC('A', 'V', 'I', ' ')
+#define listtypeAVIHEADER mmioFOURCC('h', 'd', 'r', 'l')
+#define ckidAVIMAINHDR mmioFOURCC('a', 'v', 'i', 'h')
+#define listtypeSTREAMHEADER mmioFOURCC('s', 't', 'r', 'l')
+#define ckidSTREAMHEADER mmioFOURCC('s', 't', 'r', 'h')
+#define ckidSTREAMFORMAT mmioFOURCC('s', 't', 'r', 'f')
+#define ckidSTREAMHANDLERDATA mmioFOURCC('s', 't', 'r', 'd')
+#define ckidSTREAMNAME mmioFOURCC('s', 't', 'r', 'n')
+
+#define listtypeAVIMOVIE mmioFOURCC('m', 'o', 'v', 'i')
+#define listtypeAVIRECORD mmioFOURCC('r', 'e', 'c', ' ')
+
+#define ckidAVINEWINDEX mmioFOURCC('i', 'd', 'x', '1')
+
+/*
+** Stream types for the <fccType> field of the stream header.
+*/
+#define streamtypeVIDEO mmioFOURCC('v', 'i', 'd', 's')
+#define streamtypeAUDIO mmioFOURCC('a', 'u', 'd', 's')
+#define streamtypeMIDI mmioFOURCC('m', 'i', 'd', 's')
+#define streamtypeTEXT mmioFOURCC('t', 'x', 't', 's')
+
+/* Basic chunk types */
+#define cktypeDIBbits aviTWOCC('d', 'b')
+#define cktypeDIBcompressed aviTWOCC('d', 'c')
+#define cktypePALchange aviTWOCC('p', 'c')
+#define cktypeWAVEbytes aviTWOCC('w', 'b')
+
+/* Chunk id to use for extra chunks for padding. */
+#define ckidAVIPADDING mmioFOURCC('J', 'U', 'N', 'K')
+
+/*
+** Useful macros
+**
+** Warning: These are nasty macro, and MS C 6.0 compiles some of them
+** incorrectly if optimizations are on. Ack.
+*/
+
+/* Macro to get stream number out of a FOURCC ckid */
+#define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
+#define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
+ (FromHex(HIBYTE(LOWORD(fcc))))))
+
+/* Macro to get TWOCC chunk type out of a FOURCC ckid */
+#define TWOCCFromFOURCC(fcc) HIWORD(fcc)
+
+/* Macro to make a ckid for a chunk out of a TWOCC and a stream number
+** from 0-255.
+*/
+#define ToHex(n) ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
+#define MAKEAVICKID(tcc, stream) \
+ MAKELONG((ToHex((stream) & 0x0f) << 8) | \
+ (ToHex(((stream) & 0xf0) >> 4)), tcc)
+
+/*
+** Main AVI File Header
+*/
+
+/* flags for use in <dwFlags> in AVIFileHdr */
+#define AVIF_HASINDEX 0x00000010 // Index at end of file?
+#define AVIF_MUSTUSEINDEX 0x00000020
+#define AVIF_ISINTERLEAVED 0x00000100
+#define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
+#define AVIF_WASCAPTUREFILE 0x00010000
+#define AVIF_COPYRIGHTED 0x00020000
+
+/* The AVI File Header LIST chunk should be padded to this size */
+#define AVI_HEADERSIZE 2048 // size of AVI header list
+
+typedef struct
+{
+ DWORD dwMicroSecPerFrame; // frame display rate (or 0L)
+ DWORD dwMaxBytesPerSec; // max. transfer rate
+ DWORD dwPaddingGranularity; // pad to multiples of this
+ // size; normally 2K.
+ DWORD dwFlags; // the ever-present flags
+ DWORD dwTotalFrames; // # frames in file
+ DWORD dwInitialFrames;
+ DWORD dwStreams;
+ DWORD dwSuggestedBufferSize;
+
+ DWORD dwWidth;
+ DWORD dwHeight;
+
+ DWORD dwReserved[4];
+} MainAVIHeader;
+
+/*
+** Stream header
+*/
+
+#define AVISF_DISABLED 0x00000001
+
+#define AVISF_VIDEO_PALCHANGES 0x00010000
+
+
+typedef struct {
+ FOURCC fccType;
+ FOURCC fccHandler;
+ DWORD dwFlags; /* Contains AVITF_* flags */
+ WORD wPriority;
+ WORD wLanguage;
+ DWORD dwInitialFrames;
+ DWORD dwScale;
+ DWORD dwRate; /* dwRate / dwScale == samples/second */
+ DWORD dwStart;
+ DWORD dwLength; /* In units above... */
+ DWORD dwSuggestedBufferSize;
+ DWORD dwQuality;
+ DWORD dwSampleSize;
+ RECT rcFrame;
+} AVIStreamHeader;
+
+/* Flags for index */
+#define AVIIF_LIST 0x00000001L // chunk is a 'LIST'
+#define AVIIF_KEYFRAME 0x00000010L // this frame is a key frame.
+
+#define AVIIF_NOTIME 0x00000100L // this frame doesn't take any time
+#define AVIIF_COMPUSE 0x0FFF0000L // these bits are for compressor use
+
+#define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F')
+#define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T')
+
+typedef struct
+{
+ DWORD ckid;
+ DWORD dwFlags;
+ DWORD dwChunkOffset; // Position of chunk
+ DWORD dwChunkLength; // Length of chunk
+} AVIINDEXENTRY;
+
+#define AVISTREAMREAD_CONVENIENT (-1L)
+
+/*
+** Palette change chunk
+**
+** Used in video streams.
+*/
+#endif /* NOAVIFMT */
+#endif
diff --git a/src/libw32dll/wine/driver.c b/src/libw32dll/wine/driver.c
index 4a67fb343..f3a6ecb04 100644
--- a/src/libw32dll/wine/driver.c
+++ b/src/libw32dll/wine/driver.c
@@ -1,46 +1,38 @@
-#include "config.h"
-
-#include "driver.h"
-#include "pe_image.h"
-#include "winreg.h"
-#include "vfw.h"
-#include "registry.h"
-#include "ldt_keeper.h"
-#include "ext.h"
-#include "win32.h"
-#include "driver.h"
-#include "debugtools.h"
-
+#include <config.h>
#include <stdio.h>
-#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
+#include <stdlib.h>
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#endif
-// #define DETAILED_OUT
+#include "win32.h"
+#include "wine/driver.h"
+#include "wine/pe_image.h"
+#include "wine/winreg.h"
+#include "wine/vfw.h"
+#include "registry.h"
+#include "ldt_keeper.h"
+#include "driver.h"
-char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!!
-char* win32_def_path =NULL; // must be set before calling DrvOpen() !!!
#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
+ * 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
+#define STORE_ALL /**/
+#define REST_ALL /**/
#else
-// this asm code doesn't work - why ???
-// kabi@i.am
#define STORE_ALL \
- __asm__ ( \
+ __asm__( \
"push %%ebx\n\t" \
"push %%ecx\n\t" \
"push %%edx\n\t" \
@@ -48,7 +40,7 @@ char* win32_def_path =NULL; // must be set before calling DrvOpen() !!!
"push %%edi\n\t"::)
#define REST_ALL \
- __asm__ ( \
+ __asm__( \
"pop %%edi\n\t" \
"pop %%esi\n\t" \
"pop %%edx\n\t" \
@@ -56,14 +48,18 @@ char* win32_def_path =NULL; // must be set before calling DrvOpen() !!!
"pop %%ebx\n\t"::)
#endif
+
+
+
static DWORD dwDrvID = 0;
+
LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
- LPARAM lParam1, LPARAM lParam2 )
+ LPARAM lParam1, LPARAM lParam2 )
{
DRVR* module=(DRVR*)hDriver;
int result;
-#ifdef DETAILED_OUT
+#ifdef DETAILED_OUT
printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
#endif
if(module==0)return -1;
@@ -72,134 +68,160 @@ LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
STORE_ALL;
result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
REST_ALL;
-#ifdef DETAILED_OUT
+#ifdef DETAILED_OUT
printf("\t\tResult: %X\n", result);
-#endif
+#endif
return result;
-}
+}
-static NPDRVR DrvAlloc(HDRVR* lpDriver, LPUINT lpDrvResult)
+static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
{
+ NPDRVR npDriver;
/* allocate and lock handle */
- *lpDrvResult = MMSYSERR_INVALPARAM;
if (lpDriver)
{
- if ((*lpDriver = (HDRVR) malloc(sizeof(DRVR))) != 0 )
- {
- memset((void*)*lpDriver, 0, sizeof(DRVR));
- *lpDrvResult = MMSYSERR_NOERROR;
- return (NPDRVR) *lpDriver;
- }
- *lpDrvResult = MMSYSERR_NOMEM;
- }
- return (NPDRVR) 0;
-}
-
-static int needs_free=0;
-void SetCodecPath(const char* path)
-{
- if(needs_free)free(win32_def_path);
- if(path==0)
- {
- win32_def_path=WIN32_PATH;
- needs_free=0;
- return;
+ if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) )
+ {
+ if ((npDriver = (NPDRVR) *lpDriver))
+ {
+ *lpDrvResult = MMSYSERR_NOERROR;
+ return (npDriver);
+ }
+ free((NPDRVR)*lpDriver);
+ }
+ return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
}
- win32_def_path=malloc(strlen(path)+1);
- strcpy(win32_def_path, path);
- needs_free=1;
+ return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
}
+
static void DrvFree(HDRVR hDriver)
{
int i;
-
Setup_FS_Segment();
-
- if (hDriver)
- {
- if (((DRVR*)hDriver)->hDriverModule)
- {
- if (((DRVR*)hDriver)->DriverProc)
- {
- (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
- (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
- }
- FreeLibrary(((DRVR*)hDriver)->hDriverModule);
- }
- free((NPDRVR)hDriver);
+ if(hDriver)
+ if(((DRVR*)hDriver)->hDriverModule)
+ if(((DRVR*)hDriver)->DriverProc)
+ (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
+ if(hDriver) {
+ if(((DRVR*)hDriver)->hDriverModule)
+ if(((DRVR*)hDriver)->DriverProc)
+ (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
+ FreeLibrary(((DRVR*)hDriver)->hDriverModule);
+ free((NPDRVR)hDriver);
+ return;
}
- return;
}
void DrvClose(HDRVR hdrvr)
{
DrvFree(hdrvr);
- CodecRelease();
}
-//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
-HDRVR DrvOpen(LPARAM lParam2)
+
+char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!!
+
+HDRVR VFWAPI
+DrvOpen(LPARAM lParam2)
{
+ ICOPEN *icopen=(ICOPEN *) lParam2;
UINT uDrvResult;
HDRVR hDriver;
NPDRVR npDriver;
- char unknown[0x124];
- const char* filename = win32_codec_name;
-
- npDriver = DrvAlloc(&hDriver, &uDrvResult);
- if (!npDriver)
- return (HDRVR) 0;
+ char unknown[0x24];
+// char* codec_name=icopen->fccHandler;
- if (uDrvResult)
- {
- DrvFree(hDriver);
- return (HDRVR) 0;
- }
-
- npDriver->hDriverModule = LoadLibraryA(filename);
+ //Setup_LDT_Keeper();
- if (!npDriver->hDriverModule)
- {
- printf("Can't open library %s\n", filename);
- DrvFree(hDriver);
+ if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult)))
return ((HDRVR) 0);
+
+ if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) {
+ printf("Can't open library %s\n", win32_codec_name);
+ DrvFree(hDriver);
+ return ((HDRVR) 0);
}
- npDriver->DriverProc = (DRIVERPROC) GetProcAddress(npDriver->hDriverModule,
- "DriverProc");
- if (!npDriver->DriverProc)
+#if 0
{
- printf("Library %s is not a valid VfW/ACM codec\n", filename);
- DrvFree(hDriver);
- return ((HDRVR) 0);
+ unsigned char *p=((char*)npDriver->hDriverModule);
+ double *dp;
+ int i;
+ p+=0x14c0;
+ for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n");
+ dp=(double*)p;
+ printf("divx bitrate = %f\n",(float)(*dp));
+// *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate;
}
+#endif
+
+ if (!(npDriver->DriverProc = (DRIVERPROC)
+ GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
+#if 1
+ printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
+#else
+ // Try DirectShow...
+ GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject");
+ if(!func)
+ printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name);
+ else {
+ HRESULT result;
+ struct IClassFactory* factory=0;
+ struct IUnknown* object=0;
+ GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1,
+ {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}};
+ GUID* id=&CLSID_Voxware;
+
+ result=func(id, &IID_IClassFactory, (void**)&factory);
+ if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n");
+
+ printf("Calling factory->vt->CreateInstance()\n");
+ printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance);
+ result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
+ printf("Calling factory->vt->Release()\n");
+ factory->vt->Release((struct IUnknown*)factory);
+ if(result || (!object)) printf("Class factory failure\n");
+
+ printf("DirectShow codecs not yet supported...\n");
+ }
+#endif
- TRACE("DriverProc == %X\n", npDriver->DriverProc);
- npDriver->dwDriverID = ++dwDrvID;
+ FreeLibrary(npDriver->hDriverModule);
+ DrvFree(hDriver);
+ return ((HDRVR) 0);
- printf("Loaded DLL driver %s\n", filename);
+ }
- Setup_FS_Segment();
+ //TRACE("DriverProc == %X\n", npDriver->DriverProc);
+ npDriver->dwDriverID = ++dwDrvID;
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
- REST_ALL;
- TRACE("DRV_LOAD Ok!\n");
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
- REST_ALL;
- TRACE("DRV_ENABLE Ok!\n");
+ Setup_FS_Segment();
- // open driver
+ STORE_ALL;
+ (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
+ REST_ALL;
+ //TRACE("DRV_LOAD Ok!\n");
+ STORE_ALL;
+ (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
+ REST_ALL;
+ //TRACE("DRV_ENABLE Ok!\n");
+
+ // open driver
STORE_ALL;
- npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver,
- DRV_OPEN, (LPARAM) (LPSTR) unknown,
- lParam2);
+ npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN,
+ (LPARAM) (LPSTR) unknown, lParam2);
REST_ALL;
- TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);
+ //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);
- CodecAlloc();
- return hDriver;
+ if (uDrvResult)
+ {
+ DrvFree(hDriver);
+ hDriver = (HDRVR) 0;
+ }
+
+// printf("Successfully loaded codec %s\n",win32_codec_name);
+
+ return (hDriver);
}
+
diff --git a/src/libw32dll/wine/elfdll.c b/src/libw32dll/wine/elfdll.c
index cc1e9099d..5902502ba 100644
--- a/src/libw32dll/wine/elfdll.c
+++ b/src/libw32dll/wine/elfdll.c
@@ -3,16 +3,16 @@
*
* Copyright 1999 Bertho A. Stultiens
*/
-#include "config.h"
+#include <config.h>
#ifdef HAVE_LIBDL
-#include "windef.h"
-#include "module.h"
-#include "heap.h"
-#include "elfdll.h"
-#include "debugtools.h"
-#include "winerror.h"
+#include <wine/windef.h>
+#include <wine/module.h>
+#include <wine/heap.h>
+#include <wine/elfdll.h>
+#include <wine/debugtools.h>
+#include <wine/winerror.h>
//DEFAULT_DEBUG_CHANNEL(elfdll)
@@ -43,7 +43,7 @@ extern void dump_exports(HMODULE hModule);
/*---------------- END HACKS ---------------*/
//char *extra_ld_library_path = "/usr/lib/win32";
-extern char* def_path;
+extern char* win32_def_path;
struct elfdll_image
{
@@ -73,7 +73,7 @@ void *ELFDLL_dlopen(const char *libname, int flags)
/* Now try to construct searches through our extra search-path */
namelen = strlen(libname);
- ldpath = def_path;
+ ldpath = win32_def_path;
while(ldpath && *ldpath)
{
int len;
diff --git a/src/libw32dll/wine/ext.c b/src/libw32dll/wine/ext.c
index 5c7576a18..eb56db147 100644
--- a/src/libw32dll/wine/ext.c
+++ b/src/libw32dll/wine/ext.c
@@ -17,10 +17,11 @@
#include <fcntl.h>
#include <string.h>
#include <stdarg.h>
-#include "windef.h"
-#include "winbase.h"
-#include "debugtools.h"
-#include "heap.h"
+#include <ctype.h>
+#include <wine/windef.h>
+#include <wine/winbase.h>
+#include <wine/debugtools.h>
+#include <wine/heap.h>
#include "ext.h"
#if 0
@@ -73,7 +74,7 @@ HANDLE WINAPI GetProcessHeap(void)
LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
{
- //static int i = 5;
+ static int i = 5;
void* m = (flags & 0x8) ? calloc(size, 1) : malloc(size);
//printf("HeapAlloc %p %d (%d)\n", m, size, flags);
//if (--i == 0)
@@ -146,6 +147,7 @@ LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
}
return result;
}
+/* i stands here for ignore case! */
int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
{
/*
@@ -156,17 +158,21 @@ int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
*/
while(n>0)
{
- if(*s1<*s2)
- return -1;
- else
- if(*s1>*s2)
- return 1;
+ if (((*s1 | *s2) & 0xff00) || toupper((char)*s1) != toupper((char)*s2))
+ {
+
+ if(*s1<*s2)
+ return -1;
else
- if(*s1==0)
- return 0;
- s1++;
- s2++;
- n--;
+ if(*s1>*s2)
+ return 1;
+ else
+ if(*s1==0)
+ return 0;
+ }
+ s1++;
+ s2++;
+ n--;
}
return 0;
}
@@ -244,7 +250,7 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
{
if ((fdzero = open( "/dev/zero", O_RDONLY )) == -1)
{
- perror( "/dev/zero: open" );
+ perror( "Cannot open /dev/zero for READ. Check permissions! error: " );
exit(1);
}
}
@@ -360,8 +366,10 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
{
anon=1;
hFile=open("/dev/zero", O_RDWR);
- if(hFile<0)
+ if(hFile<0){
+ perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
return 0;
+ }
}
if(!anon)
{
@@ -449,8 +457,12 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protec
{
void* answer;
int fd=open("/dev/zero", O_RDWR);
+ if(fd<0){
+ perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
+ return NULL;
+ }
size=(size+0xffff)&(~0xffff);
-// printf("VirtualAlloc(0x%08X, %d)\n", address
+ //printf("VirtualAlloc(0x%08X, %d)\n", address, size);
if(address!=0)
{
//check whether we can allow to allocate this
@@ -481,14 +493,14 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protec
return NULL;
}
answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_FIXED | MAP_PRIVATE, fd, 0);
+ MAP_FIXED | MAP_PRIVATE, fd, 0);
}
else
- answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE, fd, 0);
+ answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE, fd, 0);
// answer=FILE_dommap(-1, address, 0, size, 0, 0,
// PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
- close(fd);
+ close(fd);
if(answer==(void*)-1)
{
printf("Error no %d\n", errno);
@@ -509,13 +521,13 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protec
vm->next=new_vm;
vm=new_vm;
vm->next=0;
-// if(va_size!=0)
-// printf("Multiple VirtualAlloc!\n");
-// printf("answer=0x%08x\n", answer);
+ //if(va_size!=0)
+ // printf("Multiple VirtualAlloc!\n");
+ //printf("answer=0x%08x\n", answer);
return answer;
}
}
-WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
+WIN_BOOL WINAPI VirtualFree(LPVOID address, SIZE_T dwSize, DWORD dwFreeType)//not sure
{
virt_alloc* str=vm;
int answer;
@@ -526,10 +538,11 @@ WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure
str=str->prev;
continue;
}
+ //printf("VirtualFree(0x%08X, %d - %d)\n", str->address, dwSize, str->mapping_size);
answer=munmap(str->address, str->mapping_size);
if(str->next)str->next->prev=str->prev;
if(str->prev)str->prev->next=str->next;
- if(vm==str)vm=0;
+ if(vm==str)vm=str->prev;
free(str);
return 0;
}
diff --git a/src/libw32dll/wine/ext.h b/src/libw32dll/wine/ext.h
index 8cbea2a1b..fa4f52d43 100644
--- a/src/libw32dll/wine/ext.h
+++ b/src/libw32dll/wine/ext.h
@@ -1,8 +1,7 @@
-
#ifndef loader_ext_h
#define loader_ext_h
-#include "windef.h"
+#include <wine/windef.h>
extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low,
diff --git a/src/libw32dll/wine/loader.h b/src/libw32dll/wine/loader.h
index 172808ce4..8f5ffae9b 100644
--- a/src/libw32dll/wine/loader.h
+++ b/src/libw32dll/wine/loader.h
@@ -8,16 +8,17 @@
#ifndef _LOADER_H
#define _LOADER_H
-#include "windef.h"
-#include "driver.h"
-#include "mmreg.h"
-#include "vfw.h"
-#include "msacm.h"
-
+#include <wine/windef.h>
+#include <wine/driver.h>
+#include <wine/mmreg.h>
+#include <wine/vfw.h>
+#include <wine/msacm.h>
#ifdef __cplusplus
extern "C" {
#endif
+extern char* win32_codec_name; // must be set before calling DrvOpen() !!!
+
unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename);
int _GetPrivateProfileStringA(const char* appname, const char* keyname,
const char* def_val, char* dest, unsigned int len, const char* filename);
@@ -30,7 +31,7 @@ int _WritePrivateProfileStringA(const char* appname, const char* keyname,
MS VFW ( Video For Windows ) interface
**********************************************/
-#if D_VFW
+
long VFWAPIV ICCompress(
HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
@@ -40,7 +41,7 @@ long VFWAPIV ICCompress(
long VFWAPIV ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits);
-WIN_BOOL VFWAPI ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
+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);
@@ -50,7 +51,7 @@ 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);
int VFWAPI ICDoSomething();
-#endif // D_VFW
+
#define ICCompressGetFormat(hic, lpbiInput, lpbiOutput) \
ICSendMessage( \
hic,ICM_COMPRESS_GET_FORMAT,(long)(void*)(lpbiInput), \
@@ -137,7 +138,7 @@ int VFWAPI ICDoSomething();
******************************************************/
-#ifdef D_MSACM
+
MMRESULT WINAPI acmDriverAddA(
PHACMDRIVERID phadid, HINSTANCE hinstModule,
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd
@@ -277,7 +278,7 @@ MMRESULT WINAPI acmStreamSize(
MMRESULT WINAPI acmStreamUnprepareHeader(
HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare
);
-#endif // D_MSACM
+void MSACM_RegisterAllDrivers(void);
INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
LPSTR buffer, INT buflen );
@@ -286,3 +287,4 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
}
#endif
#endif /* __LOADER_H */
+
diff --git a/src/libw32dll/wine/module.c b/src/libw32dll/wine/module.c
index e0495b11b..aa15c8139 100644
--- a/src/libw32dll/wine/module.c
+++ b/src/libw32dll/wine/module.c
@@ -14,45 +14,20 @@
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
-/*
-#ifdef __linux__
-#include <asm/unistd.h>
-#include <asm/ldt.h>
-#else
-#define LDT_ENTRIES 8192
-#define LDT_ENTRY_SIZE 8
-
-struct modify_ldt_ldt_s {
- unsigned int entry_number;
- unsigned long base_addr;
- unsigned int limit;
- unsigned int seg_32bit:1;
- unsigned int contents:2;
- unsigned int read_exec_only:1;
- unsigned int limit_in_pages:1;
- unsigned int seg_not_present:1;
- unsigned int useable:1;
-};
-
-#define MODIFY_LDT_CONTENTS_DATA 0
-#define MODIFY_LDT_CONTENTS_STACK 1
-#define MODIFY_LDT_CONTENTS_CODE 2
-#define __NR_modify_ldt 123
-#endif
-*/
-#include "windef.h"
-#include "winerror.h"
-#include "heap.h"
-#include "module.h"
-#include "pe_image.h"
-#include "debugtools.h"
+
+#include <wine/windef.h>
+#include <wine/winerror.h>
+#include <wine/heap.h>
+#include <wine/module.h>
+#include <wine/pe_image.h>
+#include <wine/debugtools.h>
#ifdef HAVE_LIBDL
#include <dlfcn.h>
-#include "elfdll.h"
+#include <wine/elfdll.h>
#endif
#include "win32.h"
-#include "driver.h"
+//#include "driver.h"
//#undef TRACE
//#define TRACE printf
@@ -71,7 +46,7 @@ modref_list* local_wm=NULL;
HANDLE SegptrHeap;
-WINE_MODREF *MODULE_FindModule(LPCSTR m)
+WINE_MODREF* MODULE_FindModule(LPCSTR m)
{
modref_list* list=local_wm;
TRACE("Module %s request\n", m);
@@ -215,7 +190,7 @@ static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
* NOTE: Assumes that the process critical section is held!
*
*/
-WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
+static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
{
WIN_BOOL retv = TRUE;
int i;
@@ -276,7 +251,7 @@ WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
* sequence at MODULE_DllProcessAttach. Unless the bForceDetach flag
* is set, only DLLs with zero refcount are notified.
*/
-void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
+static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
{
// WINE_MODREF *wm=local_wm;
modref_list* l = local_wm;
@@ -291,6 +266,74 @@ void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpR
local_wm = 0;*/
}
+/***********************************************************************
+ * MODULE_LoadLibraryExA (internal)
+ *
+ * Load a PE style module according to the load order.
+ *
+ * The HFILE parameter is not used and marked reserved in the SDK. I can
+ * only guess that it should force a file to be mapped, but I rather
+ * ignore the parameter because it would be extremely difficult to
+ * integrate this with different types of module represenations.
+ *
+ */
+static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
+{
+ DWORD err = GetLastError();
+ WINE_MODREF *pwm;
+ int i;
+// module_loadorder_t *plo;
+
+ SetLastError( ERROR_FILE_NOT_FOUND );
+ TRACE("Trying native dll '%s'\n", libname);
+ pwm = PE_LoadLibraryExA(libname, flags);
+#ifdef HAVE_LIBDL
+ if(!pwm)
+ {
+ TRACE("Trying ELF dll '%s'\n", libname);
+ pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
+ }
+#endif
+// printf("0x%08x\n", pwm);
+// break;
+ if(pwm)
+ {
+ /* Initialize DLL just loaded */
+ TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
+ /* Set the refCount here so that an attach failure will */
+ /* decrement the dependencies through the MODULE_FreeLibrary call. */
+ pwm->refCount++;
+
+ SetLastError( err ); /* restore last error */
+ return pwm;
+ }
+
+
+ WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
+ return NULL;
+}
+
+/***********************************************************************
+ * MODULE_FreeLibrary
+ *
+ * NOTE: Assumes that the process critical section is held!
+ */
+static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
+{
+ TRACE("(%s) - START\n", wm->modname );
+
+ /* Recursively decrement reference counts */
+ //MODULE_DecRefCount( wm );
+
+ /* Call process detach notifications */
+ MODULE_DllProcessDetach( wm, FALSE, NULL );
+
+ PE_UnloadLibrary(wm);
+
+ TRACE("END\n");
+
+ return TRUE;
+}
/***********************************************************************
* LoadLibraryExA (KERNEL32)
@@ -310,6 +353,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
+ printf("Loading DLL: '%s'\n", libname);
// if(fs_installed==0)
// install_fs();
@@ -368,60 +412,12 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
/***********************************************************************
- * MODULE_LoadLibraryExA (internal)
- *
- * Load a PE style module according to the load order.
- *
- * The HFILE parameter is not used and marked reserved in the SDK. I can
- * only guess that it should force a file to be mapped, but I rather
- * ignore the parameter because it would be extremely difficult to
- * integrate this with different types of module represenations.
- *
- */
-WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
-{
- DWORD err = GetLastError();
- WINE_MODREF *pwm;
- int i;
-// module_loadorder_t *plo;
-
- SetLastError( ERROR_FILE_NOT_FOUND );
- TRACE("Trying native dll '%s'\n", libname);
- pwm = PE_LoadLibraryExA(libname, flags);
-#ifdef HAVE_LIBDL
- if(!pwm)
- {
- TRACE("Trying ELF dll '%s'\n", libname);
- pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
- }
-#endif
-// printf("0x%08x\n", pwm);
-// break;
- if(pwm)
- {
- /* Initialize DLL just loaded */
- TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
- /* Set the refCount here so that an attach failure will */
- /* decrement the dependencies through the MODULE_FreeLibrary call. */
- pwm->refCount++;
-
- SetLastError( err ); /* restore last error */
- return pwm;
- }
-
-
- WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
- return NULL;
-}
-
-/***********************************************************************
* LoadLibraryA (KERNEL32)
*/
HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
return LoadLibraryExA(libname,0,0);
}
-
/***********************************************************************
* FreeLibrary
*/
@@ -431,7 +427,6 @@ WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
WINE_MODREF *wm;
wm=MODULE32_LookupHMODULE(hLibModule);
-// wm=local_wm;
if ( !wm || !hLibModule )
{
@@ -480,28 +475,6 @@ static void MODULE_DecRefCount( WINE_MODREF *wm )
}
/***********************************************************************
- * MODULE_FreeLibrary
- *
- * NOTE: Assumes that the process critical section is held!
- */
-WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
-{
- TRACE("(%s) - START\n", wm->modname );
-
- /* Recursively decrement reference counts */
- //MODULE_DecRefCount( wm );
-
- /* Call process detach notifications */
- MODULE_DllProcessDetach( wm, FALSE, NULL );
-
- PE_UnloadLibrary(wm);
-
- TRACE("END\n");
-
- return TRUE;
-}
-
-/***********************************************************************
* GetProcAddress (KERNEL32.257)
*/
FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
@@ -552,11 +525,13 @@ static int acounter = 0;
void CodecAlloc(void)
{
acounter++;
+ //printf("**************CODEC ALLOC %d\n", acounter);
}
void CodecRelease(void)
{
acounter--;
+ //printf("**************CODEC RELEASE %d\n", acounter);
if (acounter == 0)
{
for (;;)
diff --git a/src/libw32dll/wine/pe_image.c b/src/libw32dll/wine/pe_image.c
index d30b5f2bc..30e7c34da 100644
--- a/src/libw32dll/wine/pe_image.c
+++ b/src/libw32dll/wine/pe_image.c
@@ -34,6 +34,7 @@
* to 4096 byte boundaries on disk.
*/
#include "config.h"
+//#include <wine/config.h>
#include <errno.h>
#include <assert.h>
@@ -47,13 +48,13 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
-#include "heap.h"
-#include "pe_image.h"
-#include "module.h"
-#include "debugtools.h"
+#include <wine/windef.h>
+#include <wine/winbase.h>
+#include <wine/winerror.h>
+#include <wine/heap.h>
+#include <wine/pe_image.h>
+#include <wine/module.h>
+#include <wine/debugtools.h>
#include "ext.h"
#include "win32.h"
diff --git a/src/libw32dll/wine/pe_resource.c b/src/libw32dll/wine/pe_resource.c
index 6d9bbb7e8..e0dc60bd3 100644
--- a/src/libw32dll/wine/pe_resource.c
+++ b/src/libw32dll/wine/pe_resource.c
@@ -9,20 +9,20 @@
* Copyright 1995 Alexandre Julliard
* Copyright 1997 Marcus Meissner
*/
-#include "config.h"
+#include <config.h>
#include <stdlib.h>
#include <sys/types.h>
-#include "winestring.h"
-#include "windef.h"
-#include "pe_image.h"
-#include "module.h"
-#include "heap.h"
+#include <wine/winestring.h>
+#include <wine/windef.h>
+#include <wine/pe_image.h>
+#include <wine/module.h>
+#include <wine/heap.h>
//#include "task.h"
//#include "process.h"
//#include "stackframe.h"
-#include "debugtools.h"
-#include "ext.h"
+#include <wine/debugtools.h>
+#include <ext.h>
/**********************************************************************
* HMODULE32toPE_MODREF
diff --git a/src/libw32dll/wine/registry.c b/src/libw32dll/wine/registry.c
index 0ca6b2cab..26fd76817 100644
--- a/src/libw32dll/wine/registry.c
+++ b/src/libw32dll/wine/registry.c
@@ -7,33 +7,23 @@
#include <pwd.h>
#include <sys/types.h>
-#include "winbase.h"
-#include "winreg.h"
-#include "winnt.h"
-#include "winerror.h"
-#include "debugtools.h"
+#include <wine/winbase.h>
+#include <wine/winreg.h>
+#include <wine/winnt.h>
+#include <wine/winerror.h>
-#include <ext.h>
-#include <registry.h>
+#include "ext.h"
+#include "registry.h"
//#undef TRACE
//#define TRACE printf
-struct reg_value
-{
- int type;
- char* name;
- int len;
- char* value;
-};
-
// ...can be set before init_registry() call
char* regpathname = 0;
-static int reg_size=0;
-static struct reg_value* regs = 0;
-struct reg_handle_s;
+static char* localregpathname = 0;
+
typedef struct reg_handle_s
{
int handle;
@@ -41,8 +31,18 @@ typedef struct reg_handle_s
struct reg_handle_s* next;
struct reg_handle_s* prev;
} reg_handle_t;
-
-static reg_handle_t* head=0;
+
+struct reg_value
+{
+ int type;
+ char* name;
+ int len;
+ char* value;
+};
+
+static struct reg_value* regs = NULL;
+static int reg_size;
+static reg_handle_t* head = NULL;
#define DIR -25
@@ -52,15 +52,13 @@ static void save_registry(void);
static void init_registry(void);
-
-
static void create_registry(void){
if(regs)
{
printf("Logic error: create_registry() called with existing registry\n");
save_registry();
return;
- }
+ }
regs=(struct reg_value*)malloc(3*sizeof(struct reg_value));
regs[0].type=regs[1].type=DIR;
regs[0].name=(char*)malloc(5);
@@ -70,8 +68,10 @@ static void create_registry(void){
regs[0].value=regs[1].value=NULL;
regs[0].len=regs[1].len=0;
reg_size=2;
+ head = 0;
save_registry();
}
+
static void open_registry(void)
{
int fd;
@@ -82,15 +82,16 @@ static void open_registry(void)
printf("Multiple open_registry(>\n");
return;
}
- fd = open(regpathname, O_RDONLY);
+ fd = open(localregpathname, O_RDONLY);
if (fd == -1)
{
printf("Creating new registry\n");
create_registry();
return;
- }
+ }
read(fd, &reg_size, 4);
regs=(struct reg_value*)malloc(reg_size*sizeof(struct reg_value));
+ head = 0;
for(i=0; i<reg_size; i++)
{
read(fd,&regs[i].type,4);
@@ -107,7 +108,7 @@ static void open_registry(void)
regs[i].value=(char*)malloc(regs[i].len+1);
if(regs[i].value==0)
{
- free(regs[i].name);
+ free(regs[i].name);
reg_size=i+1;
goto error;
}
@@ -124,11 +125,11 @@ static void save_registry(void)
int fd, i;
if (!regs)
init_registry();
- fd = open(regpathname, O_WRONLY | O_CREAT, 00666);
+ fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
if (fd == -1)
{
printf("Failed to open registry file '%s' for writing.\n",
- regpathname);
+ localregpathname);
return;
}
write(fd, &reg_size, 4);
@@ -143,6 +144,37 @@ static void save_registry(void)
}
close(fd);
}
+
+void free_registry(void)
+{
+ reg_handle_t* t = head;
+ while (t)
+ {
+ reg_handle_t* f = t;
+ if (t->name)
+ free(t->name);
+ t=t->prev;
+ free(f);
+ }
+ head = 0;
+ if (regs)
+ {
+ int i;
+ for(i=0; i<reg_size; i++)
+ {
+ free(regs[i].name);
+ free(regs[i].value);
+ }
+ free(regs);
+ regs = 0;
+ }
+
+ if (localregpathname && localregpathname != regpathname)
+ free(localregpathname);
+ localregpathname = 0;
+}
+
+
static reg_handle_t* find_handle_by_name(const char* name)
{
reg_handle_t* t;
@@ -174,7 +206,7 @@ static reg_handle_t* find_handle(int handle)
}
}
return 0;
-}
+}
static int generate_handle()
{
static int zz=249;
@@ -238,14 +270,15 @@ static struct reg_value* insert_reg_value(int handle, const char* name, int type
if(regs==0)
create_registry();
regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
+ //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
v=regs+reg_size;
reg_size++;
}
else
//replacing old one
{
- free(v->value);
- free(v->name);
+ free(v->value);
+ free(v->name);
}
v->type=type;
v->len=len;
@@ -253,24 +286,42 @@ static struct reg_value* insert_reg_value(int handle, const char* name, int type
memcpy(v->value, value, len);
v->name=(char*)malloc(strlen(fullname)+1);
strcpy(v->name, fullname);
+ free(fullname);
save_registry();
return v;
}
static void init_registry(void)
{
- struct passwd* pwent;
TRACE("Initializing registry\n");
- pwent = getpwuid(geteuid());
// can't be free-ed - it's static and probably thread
// unsafe structure which is stored in glibc
- if (regpathname == 0)
+#ifdef MPLAYER
+ regpathname = get_path("registry");
+ localregpathname = regpathname;
+#else
+ // regpathname is an external pointer
+ //
+ // registry.c is holding it's own internal pointer
+ // localregpathname - which is being allocate/deallocated
+
+ if (localregpathname == 0)
{
- regpathname = (char*)malloc(strlen(pwent->pw_dir)+20);
- strcpy(regpathname, pwent->pw_dir);
- strcat(regpathname, "/.registry");
+ const char* pthn = regpathname;
+ if (!regpathname)
+ {
+ // avifile - for now reading data from user's home
+ struct passwd* pwent;
+ pwent = getpwuid(geteuid());
+ pthn = pwent->pw_dir;
+ }
+
+ localregpathname = (char*)malloc(strlen(pthn)+20);
+ strcpy(localregpathname, pthn);
+ strcat(localregpathname, "/.registry");
}
+#endif
open_registry();
insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
@@ -303,12 +354,12 @@ long RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int
reg_handle_t* t;
struct reg_value* v;
TRACE("Opening key %s\n", subkey);
-
+
if(!regs)
init_registry()
-;
+;
/* t=find_handle_2(key, subkey);
-
+
if(t==0)
return -1;
@@ -319,14 +370,14 @@ long RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int
if(!full_name)
return -1;
TRACE("Opening key Fullname %s\n", full_name);
- v=find_value_by_name(full_name);
+ v=find_value_by_name(full_name);
t=insert_handle(generate_handle(), full_name);
*newkey=t->handle;
free(full_name);
-
+
return 0;
-}
+}
long RegCloseKey(long key)
{
reg_handle_t *handle;
@@ -347,31 +398,30 @@ long RegCloseKey(long key)
head=head->prev;
free(handle);
return 1;
-}
+}
+
long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
{
struct reg_value* t;
char* c;
TRACE("Querying value %s\n", value);
if(!regs)
- init_registry()
-;
- c=build_keyname(key, value);
+ init_registry();
+
+ c=build_keyname(key, value);
if(c==NULL)
- return 1;
- if((t=find_value_by_name(c))==0)
- {
- free(c);
- return 2;
- }
+ return 1;
+ t=find_value_by_name(c);
free(c);
+ if(t==0)
+ return 2;
if(type)
*type=t->type;
if(data)
{
memcpy(data, t->value, (t->len<*count)?t->len:*count);
TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
- }
+ }
if(*count<t->len)
{
*count=t->len;
@@ -382,7 +432,7 @@ long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int
*count=t->len;
}
return 0;
-}
+}
long RegCreateKeyExA(long key, const char* name, long reserved,
void* classs, long options, long security,
void* sec_attr, int* newkey, int* status)
@@ -393,8 +443,8 @@ long RegCreateKeyExA(long key, const char* name, long reserved,
// TRACE("Creating/Opening key %s\n", name);
TRACE("Creating/Opening key %s\n", name);
if(!regs)
- init_registry()
-;
+ init_registry();
+
fullname=build_keyname(key, name);
if(fullname==NULL)
return 1;
@@ -406,13 +456,6 @@ long RegCreateKeyExA(long key, const char* name, long reserved,
if (status) *status=REG_CREATED_NEW_KEY;
// return 0;
}
- else
- {
- // this is a hack as I don't know how RegEnumValueA works
- if (strstr(fullname, "zlib") || strstr(fullname, "mszh"))
- return 1;
- if (status) *status=REG_OPENED_EXISTING_KEY;
- }
t=insert_handle(generate_handle(), fullname);
*newkey=t->handle;
@@ -420,28 +463,41 @@ long RegCreateKeyExA(long key, const char* name, long reserved,
return 0;
}
+/*
+LONG RegEnumValue(
+ HKEY hKey, // handle to key to query
+ DWORD dwIndex, // index of value to query
+ LPTSTR lpValueName, // address of buffer for value string
+ LPDWORD lpcbValueName, // address for size of value buffer
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpType, // address of buffer for type code
+ LPBYTE lpData, // address of buffer for value data
+ LPDWORD lpcbData // address for size of data buffer
+);
+*/
+
long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
{
- // have no idea how this should work
- //printf("Reg Enum 0x%x %d %p %d data: %p %d %d >%s<\n", hkey, index, value, *val_count, data, *count, reg_size, data);
+ // currenly just made to support MSZH & ZLIB
+ //printf("Reg Enum 0x%x %d %s %d data: %p %d %d >%s<\n", hkey, index,
+ // value, *val_count, data, *count, reg_size, data);
+ reg_handle_t* t = find_handle(hkey);
+ if (t && index < 10)
{
- reg_handle_t* t = find_handle(hkey);
- if (t)
+ struct reg_value* v=find_value_by_name(t->name);
+ if (v)
{
- struct reg_value* v=find_value_by_name(t->name);
- *count = v->len;
- memcpy(data, v->value, *count);
- *val_count = v->len;
- memcpy(value, v->value, *val_count);
- if (type)
+ memcpy(data, v->value, (v->len < *count) ? v->len : *count);
+ if(*count < v->len)
+ *count = v->len;
+ if (type)
*type = v->type;
//printf("Found handle %s\n", v->name);
- return 0;
+ return 0;
}
}
-
- return -1;
+ return ERROR_NO_MORE_ITEMS;
}
long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
@@ -450,12 +506,19 @@ long RegSetValueExA(long key, const char* name, long v1, long v2, const void* da
char* c;
TRACE("Request to set value %s\n", name);
if(!regs)
- init_registry()
-;
+ init_registry();
+
c=build_keyname(key, name);
if(c==NULL)
return 1;
insert_reg_value(key, name, v2, data, size);
free(c);
return 0;
-}
+}
+
+long RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
+ LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
+ LPFILETIME lpftLastWriteTime)
+{
+ return ERROR_NO_MORE_ITEMS;
+}
diff --git a/src/libw32dll/wine/registry.h b/src/libw32dll/wine/registry.h
index 9c94043c4..45a6be692 100644
--- a/src/libw32dll/wine/registry.h
+++ b/src/libw32dll/wine/registry.h
@@ -12,6 +12,8 @@
extern "C" {
#endif
+void free_registry(void);
+
long RegOpenKeyExA(long key, const char* subkey, long reserved,
long access, int* newkey);
long RegCloseKey(long key);
@@ -22,7 +24,12 @@ long RegCreateKeyExA(long key, const char* name, long reserved,
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 RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
+ LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
+ LPFILETIME lpftLastWriteTime);
long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
#endif
diff --git a/src/libw32dll/wine/resource.c b/src/libw32dll/wine/resource.c
index 0169a07fd..aea094878 100644
--- a/src/libw32dll/wine/resource.c
+++ b/src/libw32dll/wine/resource.c
@@ -4,7 +4,7 @@
* Copyright 1993 Robert J. Amstadt
* Copyright 1995 Alexandre Julliard
*/
-#include "config.h"
+#include <config.h>
#include <assert.h>
#include <stdio.h>
@@ -14,14 +14,14 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include "winbase.h"
-#include "windef.h"
-#include "winuser.h"
-#include "heap.h"
-#include "module.h"
-#include "debugtools.h"
-#include "winerror.h"
-#include "loader.h"
+#include <wine/winbase.h>
+#include <wine/windef.h>
+#include <wine/winuser.h>
+#include <wine/heap.h>
+#include <wine/module.h>
+#include <wine/debugtools.h>
+#include <wine/winerror.h>
+#include <loader.h>
#define CP_ACP 0
diff --git a/src/libw32dll/wine/vfl.c b/src/libw32dll/wine/vfl.c
index 13353d1ad..703fffb4b 100644
--- a/src/libw32dll/wine/vfl.c
+++ b/src/libw32dll/wine/vfl.c
@@ -1,31 +1,46 @@
/*
* Copyright 1998 Marcus Meissner
*/
-#include "config.h"
+#include <config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include "winbase.h"
-#include "windef.h"
-#include "winuser.h"
-#include "vfw.h"
-#include "winestring.h"
-#include "driver.h"
#include "win32.h"
#include "loader.h"
-#include "avifmt.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/avifmt.h"
+#include "driver.h"
+
#define FIXME_(X) printf
#define FIXME printf
+#define OpenDriverA DrvOpen
+#define CloseDriver DrvClose
+
long VFWAPI VideoForWindowsVersion(void);
-#define OpenDriverA DrvOpen
#if 1
-#define STORE_ALL /**/
-#define REST_ALL /**/
+/*
+ * 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__ ( \
@@ -45,7 +60,6 @@ long VFWAPI VideoForWindowsVersion(void);
#endif
-
/***********************************************************************
* VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
* Returns the version in major.minor form.
@@ -107,7 +121,7 @@ ICOpen(long fccType,long fccHandler,unsigned int wMode) {
memcpy(type,&fccType,4);type[4]=0;
memcpy(handler,&fccHandler,4);handler[4]=0;
- sprintf(codecname,"%s.%s",type,handler);
+ snprintf(codecname,20,"%s.%s",type,handler);
/* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
* same layout as ICOPEN
@@ -122,7 +136,7 @@ ICOpen(long fccType,long fccHandler,unsigned int wMode) {
/*
if (!hdrv) {
if (!strcasecmp(type,"vids")) {
- sprintf(codecname,"vidc.%s",handler);
+ snprintf(codecname,20,"vidc.%s",handler);
fccType = mmioFOURCC('v','i','d','c');
}
// hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen);
@@ -269,15 +283,77 @@ ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPB
}
/***********************************************************************
+ * ICDecompressEx [MSVFW.26]
+ */
+long VFWAPIV
+ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits) {
+ ICDECOMPRESSEX icd;
+ int result;
+
+ icd.dwFlags = dwFlags;
+
+ icd.lpbiSrc = lpbiFormat;
+ icd.lpSrc = lpData;
+
+ icd.lpbiDst = lpbi;
+ icd.lpDst = lpBits;
+
+ icd.xSrc=icd.ySrc=0;
+ icd.dxSrc=lpbiFormat->biWidth;
+ icd.dySrc=abs(lpbiFormat->biHeight);
+
+ icd.xDst=icd.yDst=0;
+ icd.dxDst=lpbi->biWidth;
+ icd.dyDst=abs(lpbi->biHeight);
+
+ //icd.ckid = 0;
+ STORE_ALL;
+ result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd));
+ REST_ALL;
+ return result;
+}
+
+long VFWAPIV
+ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEADER lpbi) {
+ ICDECOMPRESSEX icd;
+ int result;
+
+ icd.dwFlags = 0;
+
+ icd.lpbiSrc = lpbiFormat;
+ icd.lpSrc = 0;
+
+ icd.lpbiDst = lpbi;
+ icd.lpDst = 0;
+
+ icd.xSrc=icd.ySrc=0;
+ icd.dxSrc=lpbiFormat->biWidth;
+ icd.dySrc=abs(lpbiFormat->biHeight);
+
+ icd.xDst=icd.yDst=0;
+ icd.dxDst=lpbi->biWidth;
+ icd.dyDst=abs(lpbi->biHeight);
+
+ //icd.ckid = 0;
+ STORE_ALL;
+ result=ICSendMessage(hic,command,(long)&icd,sizeof(icd));
+ REST_ALL;
+ return result;
+}
+
+
+/***********************************************************************
* ICSendMessage [MSVFW.40]
*/
LRESULT VFWAPI
ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
LRESULT ret;
WINE_HIC *whic = (WINE_HIC*)hic;
+ char qw[200];
+
+// printf("ICSendMessage.whic=%p\n",whic);
#if 0
- char qw[200];
__asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
#endif
STORE_ALL;
@@ -313,7 +389,7 @@ LRESULT VFWAPI ICClose(HIC hic) {
my_release(whic);
return 0;
}
-int VFWAPI ICDoSomething(void)
+int VFWAPI ICDoSomething()
{
return 0;
}
diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c
index 0d1793087..077642989 100644
--- a/src/libw32dll/wine/win32.c
+++ b/src/libw32dll/wine/win32.c
@@ -1,24 +1,24 @@
/***********************************************************
- Win32 emulation code. Functions that emulate
- responses from corresponding Win32 API calls.
- Since we are not going to be able to load
- virtually any DLL, we can only implement this
- much, adding needed functions with each new codec.
+Win32 emulation code. Functions that emulate
+responses from corresponding Win32 API calls.
+Since we are not going to be able to load
+virtually any DLL, we can only implement this
+much, adding needed functions with each new codec.
- Basic principle of implementation: it's not good
- for DLL to know too much about its environment.
+Basic principle of implementation: it's not good
+for DLL to know too much about its environment.
************************************************************/
#include "config.h"
-#include "winbase.h"
-#include "winreg.h"
-#include "winnt.h"
-#include "winerror.h"
-#include "debugtools.h"
-#include "module.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 <stdio.h>
#include "win32.h"
@@ -47,43 +47,62 @@
#include <kstat.h>
#endif
+#if HAVE_VSSCANF
int vsscanf( const char *str, const char *format, va_list ap);
+#else
+/* system has no vsscanf. try to provide one */
+static int vsscanf( const char *str, const char *format, va_list ap)
+{
+ long p1 = va_arg(ap, long);
+ long p2 = va_arg(ap, long);
+ long p3 = va_arg(ap, long);
+ long p4 = va_arg(ap, long);
+ long p5 = va_arg(ap, long);
+ return sscanf(str, format, p1, p2, p3, p4, p5);
+}
+#endif
-extern char* win32_def_path;
+char* win32_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()
{
int a;
- __asm__ __volatile__("rdtsc\n\t"
- :"=a"(a)
- :
- :"edx");
+ __asm__ __volatile__
+ (
+ "rdtsc\n\t"
+ :"=a"(a)
+ :
+ :"edx"
+ );
return a;
}
static void c_longcount_tsc(long long* z)
{
- __asm__ __volatile__(
- "pushl %%ebx\n\t"
- "movl %%eax, %%ebx\n\t"
- "rdtsc\n\t"
- "movl %%eax, 0(%%ebx)\n\t"
- "movl %%edx, 4(%%ebx)\n\t"
- "popl %%ebx\n\t"
- ::"a"(z));
+ __asm__ __volatile__
+ (
+ "pushl %%ebx\n\t"
+ "movl %%eax, %%ebx\n\t"
+ "rdtsc\n\t"
+ "movl %%eax, 0(%%ebx)\n\t"
+ "movl %%edx, 4(%%ebx)\n\t"
+ "popl %%ebx\n\t"
+ ::"a"(z)
+ );
}
static unsigned int c_localcount_notsc()
{
@@ -124,7 +143,7 @@ static unsigned int localcount_stub(void)
}
else
{
- localcount=c_localcount_notsc;
+ localcount=c_localcount_notsc;
longcount=c_longcount_notsc;
}
return localcount();
@@ -140,13 +159,14 @@ static void longcount_stub(long long* z)
}
else
{
- localcount=c_localcount_notsc;
+ localcount=c_localcount_notsc;
longcount=c_longcount_notsc;
}
longcount(z);
}
int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT
+//#define DETAILED_OUT
static inline void dbgprintf(char* fmt, ...)
{
#ifdef DETAILED_OUT
@@ -154,30 +174,60 @@ static inline void dbgprintf(char* fmt, ...)
{
FILE* f;
va_list va;
- va_start(va, fmt);
+ va_start(va, fmt);
f=fopen("./log", "a");
- vprintf(fmt, va);
- if(f)
+ vprintf(fmt, va);
+ fflush(stdout);
+ if(f)
{
vfprintf(f, fmt, va);
fsync(fileno(f));
- fclose(f);
+ fclose(f);
}
va_end(va);
}
#endif
+#if 0
+// al3x: it break divx audio. btw it should be if(verbose>2){ ... } anyway...
+// #ifdef MPLAYER
+ #include "../mp_msg.h"
+ {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, fmt);
+ vsnprintf((char *)&buf[0], 1023, fmt, va);
+ mp_dbg(MSGT_WIN32, MSGL_DBG3, (char *)&buf[0]);
+ va_end(va);
+ }
+#endif
}
-char export_names[500][30]={
-"name1",
-//"name2",
-//"name3"
+
+
+char export_names[300][32]={
+ "name1",
+ //"name2",
+ //"name3"
};
//#define min(x,y) ((x)<(y)?(x):(y))
void destroy_event(void* event);
+struct th_list_t;
+typedef struct th_list_t{
+ int id;
+ void* thread;
+ struct th_list_t* next;
+ struct th_list_t* prev;
+} th_list;
+
+
+// have to be cleared by GARBAGE COLLECTOR
static unsigned char* heap=NULL;
static int heap_counter=0;
+static tls_t* g_tls=NULL;
+static th_list* list=NULL;
+
static void test_heap(void)
{
int offset=0;
@@ -194,8 +244,8 @@ static void test_heap(void)
}
for(;offset<min(offset+1000, 20000000); offset++)
if(heap[offset]!=0xCC)
- {
- printf("Free heap corruption at address %d\n", offset);
+ {
+ printf("Free heap corruption at address %d\n", offset);
}
}
#undef MEMORY_DEBUG
@@ -207,7 +257,7 @@ void* my_mreq(int size, int to_zero)
static int test=0;
test++;
if(test%10==0)printf("Memory: %d bytes allocated\n", heap_counter);
-// test_heap();
+ // test_heap();
if(heap==NULL)
{
heap=malloc(20000000);
@@ -229,7 +279,7 @@ void* my_mreq(int size, int to_zero)
heap_counter+=4;
printf("Allocated %d bytes of memory: sys %d, user %d-%d\n", size, heap_counter-8, heap_counter, heap_counter+size);
if(to_zero)
- memset(heap+heap_counter, 0, size);
+ memset(heap+heap_counter, 0, size);
else
memset(heap+heap_counter, 0xcc, size); // make crash reproducable
heap_counter+=size;
@@ -237,7 +287,7 @@ void* my_mreq(int size, int to_zero)
}
int my_release(char* memory)
{
-// test_heap();
+ // test_heap();
if(memory==NULL)
{
printf("ERROR: free(0)\n");
@@ -249,7 +299,7 @@ int my_release(char* memory)
return 0;
}
printf("Freed %d bytes of memory\n", *(int*)(memory-4));
-// memset(memory-8, *(int*)(memory-4), 0xCC);
+ // memset(memory-8, *(int*)(memory-4), 0xCC);
return 0;
}
@@ -258,7 +308,7 @@ int my_release(char* memory)
typedef struct alloc_header_t alloc_header;
struct alloc_header_t
{
-// let's keep allocated data 16 byte aligned
+ // let's keep allocated data 16 byte aligned
alloc_header* prev;
alloc_header* next;
long deadbeef;
@@ -278,15 +328,25 @@ static int alccnt = 0;
#define AREATYPE_EVENT 1
#define AREATYPE_MUTEX 2
#define AREATYPE_COND 3
+#define AREATYPE_CRITSECT 4
+
+/* -- critical sections -- */
+struct CRITSECT
+{
+ pthread_t id;
+ pthread_mutex_t mutex;
+ int locked;
+};
void* mreq_private(int size, int to_zero, int type);
void* mreq_private(int size, int to_zero, int type)
{
- alloc_header* header;
+ int nsize = size + sizeof(alloc_header);
+ alloc_header* header = malloc(nsize);
+ if (!header)
+ return 0;
if (to_zero)
- header=calloc(size + sizeof(alloc_header), 1);
- else
- header=malloc(size + sizeof(alloc_header));
+ memset(header, 0, nsize);
#ifdef GARBAGE
if (!last_alloc)
{
@@ -295,7 +355,7 @@ void* mreq_private(int size, int to_zero, int type)
}
else
{
- pthread_mutex_lock(&memmut);
+ pthread_mutex_lock(&memmut);
last_alloc->next = header; /* set next */
}
@@ -309,33 +369,28 @@ void* mreq_private(int size, int to_zero, int type)
header->size = size;
header->type = type;
- //if (alccnt < 400) printf("MY_REQ: %p\t%d (%d)\n", answer, size, alccnt);
+ //if (alccnt < 40000) printf("MY_REQ: %p\t%d t:%d (cnt:%d)\n", header, size, type, alccnt);
return header + 1;
}
-void* my_mreq(int size, int to_zero)
-{
- return mreq_private(size, to_zero, AREATYPE_CLIENT);
-}
-
-
int my_release(void* memory)
{
alloc_header* header = (alloc_header*) memory - 1;
#ifdef GARBAGE
alloc_header* prevmem;
alloc_header* nextmem;
+
if (memory == 0)
return 0;
- pthread_mutex_lock(&memmut);
-
if (header->deadbeef != 0xdeadbeef)
{
- printf("FATAL releasing corrupted memory!\n");
+ printf("FATAL releasing corrupted memory! %p 0x%lx (%d)\n", header, header->deadbeef, alccnt);
return 0;
}
+ pthread_mutex_lock(&memmut);
+
switch(header->type)
{
case AREATYPE_EVENT:
@@ -347,8 +402,14 @@ int my_release(void* memory)
case AREATYPE_MUTEX:
pthread_mutex_destroy((pthread_mutex_t*)memory);
break;
+ case AREATYPE_CRITSECT:
+ pthread_mutex_destroy(&((struct CRITSECT*)memory)->mutex);
+ break;
+ default:
+ //memset(memory, 0xcc, header->size);
}
-
+
+ header->deadbeef = 0;
prevmem = header->prev;
nextmem = header->next;
@@ -367,22 +428,28 @@ int my_release(void* memory)
else
pthread_mutex_destroy(&memmut);
- //if (alccnt < 400) printf("MY_RELEASE: %p\t%ld (%d)\n", mem, mem[3], alccnt);
+ //if (alccnt < 40000) printf("MY_RELEASE: %p\t%ld (%d)\n", header, header->size, alccnt);
#else
if (memory == 0)
return 0;
#endif
+ //memset(header + 1, 0xcc, header->size);
free(header);
return 0;
}
#endif
+inline void* my_mreq(int size, int to_zero)
+{
+ return mreq_private(size, to_zero, AREATYPE_CLIENT);
+}
+
static inline int my_size(void* memory)
{
return ((alloc_header*)memory)[-1].size;
}
-void* my_realloc(void* memory, int size)
+static void* my_realloc(void* memory, int size)
{
void *ans = memory;
int osize = my_size(memory);
@@ -397,142 +464,78 @@ void* my_realloc(void* memory, int size)
return ans;
}
-extern int unk_exp1;
-char extcode[20000];// place for 200 unresolved exports
-int pos=0;
+/*
+ *
+ * WINE API - native implementation for several win32 libraries
+ *
+ */
-int WINAPI ext_unknown()
+static int WINAPI ext_unknown()
{
printf("Unknown func called\n");
return 0;
}
-int WINAPI expIsBadWritePtr(void* ptr, unsigned int count)
+
+static int WINAPI expIsBadWritePtr(void* ptr, unsigned int count)
{
- int result;
- if(count==0)
- result=0;
- else
- if(ptr==0)
- result=1;
- else
- result=0;
+ int result = (count == 0 || ptr != 0) ? 0 : 1;
dbgprintf("IsBadWritePtr(0x%x, 0x%x) => %d\n", ptr, count, result);
return result;
}
-int WINAPI expIsBadReadPtr(void* ptr, unsigned int count)
+static int WINAPI expIsBadReadPtr(void* ptr, unsigned int count)
{
- int result;
- if(count==0)
- result=0;
- else
- if(ptr==0)
- result=1;
- else
- result=0;
+ int result = (count == 0 || ptr != 0) ? 0 : 1;
dbgprintf("IsBadReadPtr(0x%x, 0x%x) => %d\n", ptr, count, result);
return result;
}
-void* CDECL expmalloc(int size)
-{
-//printf("malloc");
-// return malloc(size);
- void* result=my_mreq(size,0);
- dbgprintf("malloc(0x%x) => 0x%x\n", size,result);
- if(result==0)
- printf("WARNING: malloc() failed\n");
- return result;
-}
-void CDECL expfree(void* mem)
-{
-// return free(mem);
- dbgprintf("free(0x%x)\n", mem);
- my_release(mem);
-}
-void* CDECL expnew(int size)
-{
-// printf("NEW:: Call from address %08x\n STACK DUMP:\n", *(-1+(int*)&size));
-// printf("%08x %08x %08x %08x\n",
-// size, *(1+(int*)&size),
- // *(2+(int*)&size),*(3+(int*)&size));
- void* result = 0;
- assert(size >= 0);
-
- result=my_mreq(size,0);
- dbgprintf("new(0x%x) => 0x%x\n", size, result);
- if (result==0)
- printf("WARNING: new() failed\n");
- return result;
-
-}
-int CDECL expdelete(void* memory)
-{
- dbgprintf("delete(0x%x)\n", memory);
- my_release(memory);
- return 0;
-}
-int WINAPI expDisableThreadLibraryCalls(int module)
+static int WINAPI expDisableThreadLibraryCalls(int module)
{
dbgprintf("DisableThreadLibraryCalls(0x%x) => 0\n", module);
return 0;
}
-int CDECL exp_initterm(int v1, int v2)
-{
- dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2);
- return 0;
-}
-HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
+static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
{
HMODULE result;
if (pdrv==NULL)
result=0;
else
- result=pdrv->hDriverModule;
+ result=pdrv->hDriverModule;
dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result);
return result;
}
#define MODULE_HANDLE_kernel32 ((HMODULE)0x120)
-HMODULE WINAPI expGetModuleHandleA(const char* name)
+static HMODULE WINAPI expGetModuleHandleA(const char* name)
{
- WINE_MODREF* wm;
- HMODULE result;
- if(!name)
- result=0;
+ WINE_MODREF* wm;
+ HMODULE result;
+ if(!name)
+ result=0;
+ else
+ {
+ wm=MODULE_FindModule(name);
+ if(wm==0)result=0;
else
- {
- wm=MODULE_FindModule(name);
- if(wm==0)result=0;
- else
- result=(HMODULE)(wm->module);
- }
- if(!result)
- {
- if(strcasecmp(name, "kernel32")==0)
- result=MODULE_HANDLE_kernel32;
- }
- dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
- return result;
+ result=(HMODULE)(wm->module);
+ }
+ if(!result)
+ {
+ if(name && strcasecmp(name, "kernel32")==0)
+ result=MODULE_HANDLE_kernel32;
+ }
+ dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
+ return result;
}
-struct th_list_t;
-typedef struct th_list_t{
-int id;
-void* thread;
-struct th_list_t* next;
-struct th_list_t* prev;
-}th_list;
-
-static th_list* list=NULL;
-
-
-void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress,
- void* lpParameter, long dwFlags, long* dwThreadId)
+static void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize,
+ void* lpStartAddress, void* lpParameter,
+ long dwFlags, long* dwThreadId)
{
pthread_t *pth;
-// printf("CreateThread:");
+ // printf("CreateThread:");
pth=my_mreq(sizeof(pthread_t), 0);
pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter);
if(dwFlags)
@@ -553,7 +556,7 @@ void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddr
}
list->thread=pth;
dbgprintf("CreateThread(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0x%x\n",
- pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth);
+ pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth);
return pth;
}
@@ -577,7 +580,7 @@ static mutex_list* mlist=NULL;
void destroy_event(void* event)
{
mutex_list* pp=mlist;
-// printf("garbage collector: destroy_event(%x)\n", event);
+ // printf("garbage collector: destroy_event(%x)\n", event);
while(pp)
{
if(pp==(mutex_list*)event)
@@ -588,46 +591,46 @@ void destroy_event(void* event)
pp->prev->next=pp->next;
if(mlist==(mutex_list*)event)
mlist=mlist->prev;
-/*
- pp=mlist;
- while(pp)
- {
- printf("%x => ", pp);
- pp=pp->prev;
- }
- printf("0\n");
-*/
+ /*
+ pp=mlist;
+ while(pp)
+ {
+ printf("%x => ", pp);
+ pp=pp->prev;
+ }
+ printf("0\n");
+ */
return;
}
pp=pp->prev;
}
}
-void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
- char bInitialState, const char* name)
+static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
+ char bInitialState, const char* name)
{
pthread_mutex_t *pm;
pthread_cond_t *pc;
-/*
- mutex_list* pp;
- pp=mlist;
- while(pp)
- {
- printf("%x => ", pp);
- pp=pp->prev;
- }
- printf("0\n");
-*/
+ /*
+ mutex_list* pp;
+ pp=mlist;
+ while(pp)
+ {
+ printf("%x => ", pp);
+ pp=pp->prev;
+ }
+ printf("0\n");
+ */
if(mlist!=NULL)
{
mutex_list* pp=mlist;
if(name!=NULL)
- do
+ do
{
if((strcmp(pp->name, name)==0) && (pp->type==0))
{
dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
- pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
+ pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
return pp->pm;
}
}while((pp=pp->prev) != NULL);
@@ -654,25 +657,25 @@ void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
mlist->state=bInitialState;
mlist->reset=bManualReset;
if(name)
- strncpy(mlist->name, name, 127);
+ strncpy(mlist->name, name, 127);
else
mlist->name[0]=0;
if(pm==NULL)
dbgprintf("ERROR::: CreateEventA failure\n");
-/*
- if(bInitialState)
- pthread_mutex_lock(pm);
-*/
+ /*
+ if(bInitialState)
+ pthread_mutex_lock(pm);
+ */
if(name)
- dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
- pSecAttr, bManualReset, bInitialState, name, name, mlist);
+ dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
+ pSecAttr, bManualReset, bInitialState, name, name, mlist);
else
- dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
- pSecAttr, bManualReset, bInitialState, mlist);
+ dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
+ pSecAttr, bManualReset, bInitialState, mlist);
return mlist;
}
-void* WINAPI expSetEvent(void* event)
+static void* WINAPI expSetEvent(void* event)
{
mutex_list *ml = (mutex_list *)event;
dbgprintf("SetEvent(%x) => 0x1\n", event);
@@ -685,7 +688,7 @@ void* WINAPI expSetEvent(void* event)
return (void *)1;
}
-void* WINAPI expResetEvent(void* event)
+static void* WINAPI expResetEvent(void* event)
{
mutex_list *ml = (mutex_list *)event;
dbgprintf("ResetEvent(0x%x) => 0x1\n", event);
@@ -696,18 +699,31 @@ void* WINAPI expResetEvent(void* event)
return (void *)1;
}
-void* WINAPI expWaitForSingleObject(void* object, int duration)
+static void* WINAPI expWaitForSingleObject(void* object, int duration)
{
mutex_list *ml = (mutex_list *)object;
// FIXME FIXME FIXME - this value is sometime unititialize !!!
int ret = WAIT_FAILED;
mutex_list* pp=mlist;
+ if(object == (void*)0xcfcf9898)
+ {
+ /**
+ From GetCurrentThread() documentation:
+ A pseudo handle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required. Pseudo handles are not inherited by child processes.
+
+ This handle has the maximum possible access to the thread object. For systems that support security descriptors, this is the maximum access allowed by the security descriptor for the calling process. For systems that do not support security descriptors, this is THREAD_ALL_ACCESS.
+
+ The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a "real" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function.
+ **/
+ dbgprintf("WaitForSingleObject(thread_handle) called\n");
+ return (void*)WAIT_FAILED;
+ }
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;
+ return (void*) ret;
while (pp && (pp->pm != ml->pm))
pp = pp->prev;
if (!pp) {
@@ -718,46 +734,46 @@ void* WINAPI expWaitForSingleObject(void* object, int duration)
pthread_mutex_lock(ml->pm);
switch(ml->type) {
- case 0: /* Event */
+ case 0: /* Event */
if (duration == 0) { /* Check Only */
- if (ml->state == 1) ret = WAIT_FAILED;
- else ret = WAIT_OBJECT_0;
+ if (ml->state == 1) ret = WAIT_FAILED;
+ else ret = WAIT_OBJECT_0;
}
if (duration == -1) { /* INFINITE */
- if (ml->state == 0)
- pthread_cond_wait(ml->pc,ml->pm);
- if (ml->reset)
- ml->state = 0;
- ret = WAIT_OBJECT_0;
+ if (ml->state == 0)
+ pthread_cond_wait(ml->pc,ml->pm);
+ if (ml->reset)
+ ml->state = 0;
+ ret = WAIT_OBJECT_0;
}
if (duration > 0) { /* Timed Wait */
- struct timespec abstime;
- struct timeval now;
- gettimeofday(&now, 0);
- abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000;
- abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000;
- if (ml->state == 0)
- ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime);
- if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT;
- else ret = WAIT_OBJECT_0;
- if (ml->reset)
- ml->state = 0;
+ struct timespec abstime;
+ struct timeval now;
+ gettimeofday(&now, 0);
+ abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000;
+ abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000;
+ if (ml->state == 0)
+ ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime);
+ if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT;
+ else ret = WAIT_OBJECT_0;
+ if (ml->reset)
+ ml->state = 0;
+ }
+ break;
+ case 1: /* Semaphore */
+ if (duration == 0) {
+ if(ml->semaphore==0) ret = WAIT_FAILED;
+ else {
+ ml->semaphore++;
+ ret = WAIT_OBJECT_0;
+ }
}
- break;
- case 1: /* Semaphore */
- if (duration == 0) {
- if(ml->semaphore==0) ret = WAIT_FAILED;
- else {
- ml->semaphore++;
- ret = WAIT_OBJECT_0;
- }
- }
if (duration == -1) {
- if (ml->semaphore==0)
- pthread_cond_wait(ml->pc,ml->pm);
- ml->semaphore--;
+ if (ml->semaphore==0)
+ pthread_cond_wait(ml->pc,ml->pm);
+ ml->semaphore--;
}
- break;
+ break;
}
pthread_mutex_unlock(ml->pm);
@@ -767,7 +783,7 @@ void* WINAPI expWaitForSingleObject(void* object, int duration)
static BYTE PF[64] = {0,};
-WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
+static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
{
WIN_BOOL result;
if(v>63)result=0;
@@ -790,303 +806,450 @@ static void DumpSystemInfo(const SYSTEM_INFO* si)
dbgprintf(" Processor revision: 0x%x\n", si->wProcessorRevision);
}
-void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
+static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
{
- /* FIXME: better values for the two entries below... */
- static int cache = 0;
- static SYSTEM_INFO cachedsi;
- unsigned int regs[4];
- dbgprintf("GetSystemInfo(%p) =>\n", si);
+ /* FIXME: better values for the two entries below... */
+ static int cache = 0;
+ static SYSTEM_INFO cachedsi;
+ unsigned int regs[4];
+ dbgprintf("GetSystemInfo(%p) =>\n", si);
- if (cache) {
- memcpy(si,&cachedsi,sizeof(*si));
- DumpSystemInfo(si);
- return;
- }
- memset(PF,0,sizeof(PF));
+ if (cache) {
+ memcpy(si,&cachedsi,sizeof(*si));
+ DumpSystemInfo(si);
+ return;
+ }
+ memset(PF,0,sizeof(PF));
+
+ cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
+ cachedsi.dwPageSize = getpagesize();
+
+ /* FIXME: better values for the two entries below... */
+ cachedsi.lpMinimumApplicationAddress = (void *)0x00000000;
+ cachedsi.lpMaximumApplicationAddress = (void *)0x7FFFFFFF;
+ cachedsi.dwActiveProcessorMask = 1;
+ cachedsi.dwNumberOfProcessors = 1;
+ cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+ cachedsi.dwAllocationGranularity = 0x10000;
+ cachedsi.wProcessorLevel = 5; /* pentium */
+ cachedsi.wProcessorRevision = 0x0101;
+
+#ifdef MPLAYER
+ /* mplayer's way to detect PF's */
+ {
+#include "../cpudetect.h"
+ extern CpuCaps gCpuCaps;
+
+ if (gCpuCaps.hasMMX)
+ PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (gCpuCaps.hasSSE)
+ PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (gCpuCaps.has3DNow)
+ PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
- cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
- cachedsi.dwPageSize = getpagesize();
+ switch(gCpuCaps.cpuType)
+ {
+ case CPUTYPE_I686:
+ case CPUTYPE_I586:
+ cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel = 5;
+ break;
+ case CPUTYPE_I486:
+ cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+ cachedsi.wProcessorLevel = 4;
+ break;
+ case CPUTYPE_I386:
+ default:
+ cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+ cachedsi.wProcessorLevel = 3;
+ break;
+ }
+ cachedsi.wProcessorRevision = gCpuCaps.cpuStepping;
+ cachedsi.dwNumberOfProcessors = 1; /* hardcoded */
- /* FIXME: better values for the two entries below... */
- cachedsi.lpMinimumApplicationAddress = (void *)0x00000000;
- cachedsi.lpMaximumApplicationAddress = (void *)0x7FFFFFFF;
- cachedsi.dwActiveProcessorMask = 1;
- cachedsi.dwNumberOfProcessors = 1;
- cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
- cachedsi.dwAllocationGranularity = 0x10000;
- cachedsi.wProcessorLevel = 5; /* pentium */
- cachedsi.wProcessorRevision = 0x0101;
+ }
+#endif
+/* disable cpuid based detection (mplayer's cpudetect.c does this - see above) */
+#ifndef MPLAYER
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__)
- do_cpuid(1, regs);
- switch ((regs[0] >> 8) & 0xf) { // cpu family
- case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
- cachedsi.wProcessorLevel= 3;
- break;
- case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
- cachedsi.wProcessorLevel= 4;
- break;
- case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- }
- cachedsi.wProcessorRevision = regs[0] & 0xf; // stepping
- if (regs[3] & (1 << 8))
- PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
- if (regs[3] & (1 << 23))
- PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
- cachedsi.dwNumberOfProcessors=1;
-#else
- {
+ do_cpuid(1, regs);
+ switch ((regs[0] >> 8) & 0xf) { // cpu family
+ case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+ cachedsi.wProcessorLevel= 3;
+ break;
+ case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+ cachedsi.wProcessorLevel= 4;
+ break;
+ case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ }
+ cachedsi.wProcessorRevision = regs[0] & 0xf; // stepping
+ if (regs[3] & (1 << 8))
+ PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
+ if (regs[3] & (1 << 23))
+ PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (regs[3] & (1 << 25))
+ PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (regs[3] & (1 << 31))
+ PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
+ cachedsi.dwNumberOfProcessors=1;
+#endif
+#endif /* MPLAYER */
+
+/* MPlayer: linux detection enabled (based on proc/cpuinfo) for checking
+ fdiv_bug and fpu emulation flags -- alex/MPlayer */
+#ifdef __linux__
+ {
char buf[20];
char line[200];
FILE *f = fopen ("/proc/cpuinfo", "r");
if (!f)
- return;
+ return;
while (fgets(line,200,f)!=NULL) {
- char *s,*value;
-
- /* NOTE: the ':' is the only character we can rely on */
- if (!(value = strchr(line,':')))
- continue;
- /* terminate the valuename */
- *value++ = '\0';
- /* skip any leading spaces */
- while (*value==' ') value++;
- if ((s=strchr(value,'\n')))
- *s='\0';
-
- /* 2.1 method */
- if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
- if (isdigit (value[0])) {
- switch (value[0] - '0') {
- case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
- cachedsi.wProcessorLevel= 3;
- break;
- case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
- cachedsi.wProcessorLevel= 4;
- break;
- case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- }
- }
- /* set the CPU type of the current processor */
- sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
- continue;
- }
- /* old 2.0 method */
- if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
- if ( isdigit (value[0]) && value[1] == '8' &&
- value[2] == '6' && value[3] == 0
- ) {
- switch (value[0] - '0') {
- case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
- cachedsi.wProcessorLevel= 3;
- break;
- case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
- cachedsi.wProcessorLevel= 4;
- break;
- case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
- cachedsi.wProcessorLevel= 5;
- break;
- }
- }
- /* set the CPU type of the current processor */
- sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
- continue;
- }
- if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
- if (!lstrncmpiA(value,"yes",3))
- PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
+ char *s,*value;
- continue;
- }
- if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
- if (!lstrncmpiA(value,"no",2))
- PF[PF_FLOATING_POINT_EMULATED] = TRUE;
+ /* NOTE: the ':' is the only character we can rely on */
+ if (!(value = strchr(line,':')))
+ continue;
+ /* terminate the valuename */
+ *value++ = '\0';
+ /* skip any leading spaces */
+ while (*value==' ') value++;
+ if ((s=strchr(value,'\n')))
+ *s='\0';
- continue;
+ /* 2.1 method */
+ if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
+ if (isdigit (value[0])) {
+ switch (value[0] - '0') {
+ case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+ cachedsi.wProcessorLevel= 3;
+ break;
+ case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+ cachedsi.wProcessorLevel= 4;
+ break;
+ case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ }
}
- if (!lstrncmpiA(line,"processor",strlen("processor"))) {
- /* processor number counts up...*/
- int x;
-
- if (sscanf(value,"%d",&x))
- if (x+1>cachedsi.dwNumberOfProcessors)
- cachedsi.dwNumberOfProcessors=x+1;
-
- /* Create a new processor subkey on a multiprocessor
- * system
- */
- sprintf(buf,"%d",x);
+ /* set the CPU type of the current processor */
+ sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
+ continue;
+ }
+ /* old 2.0 method */
+ if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
+ if ( isdigit (value[0]) && value[1] == '8' &&
+ value[2] == '6' && value[3] == 0
+ ) {
+ switch (value[0] - '0') {
+ case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+ cachedsi.wProcessorLevel= 3;
+ break;
+ case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+ cachedsi.wProcessorLevel= 4;
+ break;
+ case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+ cachedsi.wProcessorLevel= 5;
+ break;
+ }
}
- if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
- int x;
+ /* set the CPU type of the current processor */
+ sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
+ continue;
+ }
+ if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
+ if (!lstrncmpiA(value,"yes",3))
+ PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
- if (sscanf(value,"%d",&x))
- cachedsi.wProcessorRevision = x;
- }
- if
- ( (!lstrncmpiA(line,"flags",strlen("flags")))
- || (!lstrncmpiA(line,"features",strlen("features"))) )
- {
- if (strstr(value,"cx8"))
- PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
- if (strstr(value,"mmx"))
- PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+ continue;
+ }
+ if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
+ if (!lstrncmpiA(value,"no",2))
+ PF[PF_FLOATING_POINT_EMULATED] = TRUE;
- }
+ continue;
+ }
+ if (!lstrncmpiA(line,"processor",strlen("processor"))) {
+ /* processor number counts up...*/
+ int x;
+
+ if (sscanf(value,"%d",&x))
+ if (x+1>cachedsi.dwNumberOfProcessors)
+ cachedsi.dwNumberOfProcessors=x+1;
+
+ /* Create a new processor subkey on a multiprocessor
+ * system
+ */
+ sprintf(buf,"%d",x);
+ }
+ if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
+ int x;
+
+ if (sscanf(value,"%d",&x))
+ cachedsi.wProcessorRevision = x;
+ }
+ if
+ ( (!lstrncmpiA(line,"flags",strlen("flags")))
+ || (!lstrncmpiA(line,"features",strlen("features"))) )
+ {
+ if (strstr(value,"cx8"))
+ PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
+ if (strstr(value,"mmx"))
+ PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (strstr(value,"tsc"))
+ PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
+ if (strstr(value,"xmm"))
+ PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+ if (strstr(value,"3dnow"))
+ PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
+ }
}
fclose (f);
-/*
- * ad hoc fix for smp machines.
- * some problems on WaitForSingleObject,CreateEvent,SetEvent
- * CreateThread ...etc..
- *
- */
- cachedsi.dwNumberOfProcessors=1;
- }
-#endif /* __FreeBSD__ */
- cache = 1;
- memcpy(si,&cachedsi,sizeof(*si));
- DumpSystemInfo(si);
+ /*
+ * ad hoc fix for smp machines.
+ * some problems on WaitForSingleObject,CreateEvent,SetEvent
+ * CreateThread ...etc..
+ *
+ */
+ cachedsi.dwNumberOfProcessors=1;
+ }
+#endif /* __linux__ */
+ cache = 1;
+ memcpy(si,&cachedsi,sizeof(*si));
+ DumpSystemInfo(si);
}
-long WINAPI expGetVersion()
+static long WINAPI expGetVersion()
{
dbgprintf("GetVersion() => 0xC0000004\n");
return 0xC0000004;//Windows 95
}
-HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size)
+static HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size)
{
-// printf("HeapCreate:");
+ // printf("HeapCreate:");
HANDLE result;
if(init_size==0)
- result=(HANDLE)my_mreq(0x110000, 0);
+ result=(HANDLE)my_mreq(0x110000, 0);
else
- result=(HANDLE)my_mreq(init_size, 0);
+ result=(HANDLE)my_mreq((init_size + 0xfff) & 0x7ffff000 , 0);
dbgprintf("HeapCreate(flags 0x%x, initial size %d, maximum size %d) => 0x%x\n", flags, init_size, max_size, result);
return result;
}
-void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size)
+
+// this is another dirty hack
+// VP31 is releasing one allocated Heap chunk twice
+// we will silently ignore this second call...
+static void* heapfreehack = 0;
+static int heapfreehackshown = 0;
+//extern void trapbug(void);
+static void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size)
{
void* z;
-// printf("HeapAlloc:");
-/**
- Morgan's m3jpeg32.dll v. 2.0 encoder expects that request for
- HeapAlloc returns area larger than size argument :-/
-**/
- z=my_mreq(((size+4095)/4096)*4096, flags&8);
-// z=HeapAlloc(heap,flags,size);
+ /**
+ Morgan's m3jpeg32.dll v. 2.0 encoder expects that request for
+ HeapAlloc returns area larger than size argument :-/
+
+ actually according to M$ Doc HeapCreate size should be rounded
+ to page boundaries thus we should simulate this
+ **/
+ //if (size == 22276) trapbug();
+ z=my_mreq((size + 0xfff) & 0x7ffff000, (flags & HEAP_ZERO_MEMORY));
if(z==0)
printf("HeapAlloc failure\n");
- dbgprintf("HeapAlloc(heap 0x%x, flags 0x%x, size 0x%x) => 0x%x\n", heap, flags, size, z);
+ dbgprintf("HeapAlloc(heap 0x%x, flags 0x%x, size %d) => 0x%x\n", heap, flags, size, z);
+ heapfreehack = 0; // reset
return z;
}
-long WINAPI expHeapDestroy(void* heap)
+static long WINAPI expHeapDestroy(void* heap)
{
dbgprintf("HeapDestroy(heap 0x%x) => 1\n", heap);
my_release(heap);
return 1;
}
-long WINAPI expHeapFree(int arg1, int arg2, void* ptr)
+static long WINAPI expHeapFree(int arg1, int arg2, void* ptr)
{
dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", arg1, arg2, ptr);
- my_release(ptr);
+ if (heapfreehack != ptr && ptr != (void*)0xffffffff)
+ my_release(ptr);
+ else
+ {
+ if (!heapfreehackshown++)
+ printf("Info: HeapFree deallocating same memory twice! (%p)\n", ptr);
+ }
+ heapfreehack = ptr;
return 1;
}
-long WINAPI expHeapSize(int heap, int flags, void* pointer)
+static long WINAPI expHeapSize(int heap, int flags, void* pointer)
{
long result=my_size(pointer);
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)
+static void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void *lpMem,int size)
{
- long orgsize;
- void *newp;
- orgsize = my_size(lpMem);
+ long orgsize = my_size(lpMem);
dbgprintf("HeapReAlloc() Size %ld org %d\n",orgsize,size);
return my_realloc(lpMem, size);
}
-long WINAPI expGetProcessHeap(void)
+static long WINAPI expGetProcessHeap(void)
{
dbgprintf("GetProcessHeap() => 1\n");
return 1;
}
-void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4)
+static void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4)
{
- void* z;
- z=VirtualAlloc(v1, v2, v3, v4);
+ void* z = VirtualAlloc(v1, v2, v3, v4);
if(z==0)
printf("VirtualAlloc failure\n");
dbgprintf("VirtualAlloc(0x%x, %d, %d, %d) => 0x%x \n",v1,v2,v3,v4, z);
return z;
}
-int WINAPI expVirtualFree(void* v1, int v2, int v3)
+static int WINAPI expVirtualFree(void* v1, int v2, int v3)
{
- int result=VirtualFree(v1,v2,v3);
+ int result = VirtualFree(v1,v2,v3);
dbgprintf("VirtualFree(0x%x, %d, %d) => %d\n",v1,v2,v3, result);
return result;
}
-struct CRITSECT
+
+/* we're building a table of critical sections. cs_win pointer uses the DLL
+ cs_unix is the real structure, we're using cs_win only to identifying cs_unix */
+struct critsecs_list_t
{
- pthread_t id;
- pthread_mutex_t mutex;
- int locked;
+ CRITICAL_SECTION *cs_win;
+ struct CRITSECT *cs_unix;
};
-void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
+/* 'NEWTYPE' is working with VIVO and 3ivX dll (no more segfaults) -- alex */
+#undef CRITSECS_NEWTYPE
+//#define CRITSECS_NEWTYPE 1
+
+#ifdef CRITSECS_NEWTYPE
+#define CRITSECS_LIST_MAX 20
+static struct critsecs_list_t critsecs_list[CRITSECS_LIST_MAX];
+
+static int critsecs_get_pos(CRITICAL_SECTION *cs_win)
+{
+ int i;
+
+ for (i=0; i < CRITSECS_LIST_MAX; i++)
+ if (critsecs_list[i].cs_win == cs_win)
+ return(i);
+ return(-1);
+}
+
+static int critsecs_get_unused(void)
+{
+ int i;
+
+ for (i=0; i < CRITSECS_LIST_MAX; i++)
+ if (critsecs_list[i].cs_win == NULL)
+ return(i);
+ return(-1);
+}
+
+#if 0
+#define critsecs_get_unix(cs_win) (critsecs_list[critsecs_get_pos(cs_win)].cs_win)
+#else
+struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win)
+{
+ int i;
+
+ for (i=0; i < CRITSECS_LIST_MAX; i++)
+ if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix)
+ return(critsecs_list[i].cs_unix);
+ return(NULL);
+}
+#endif
+#endif
+
+static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
{
- struct CRITSECT cs;
dbgprintf("InitializeCriticalSection(0x%x)\n", c);
-/* if(sizeof(pthread_mutex_t)>sizeof(CRITICAL_SECTION))
+ /* if(sizeof(pthread_mutex_t)>sizeof(CRITICAL_SECTION))
+ {
+ printf(" ERROR:::: sizeof(pthread_mutex_t) is %d, expected <=%d!\n",
+ sizeof(pthread_mutex_t), sizeof(CRITICAL_SECTION));
+ return;
+ }*/
+ /* pthread_mutex_init((pthread_mutex_t*)c, NULL); */
+#ifdef CRITSECS_NEWTYPE
{
- printf(" ERROR:::: sizeof(pthread_mutex_t) is %d, expected <=%d!\n",
- sizeof(pthread_mutex_t), sizeof(CRITICAL_SECTION));
- return;
- }*/
-/* pthread_mutex_init((pthread_mutex_t*)c, NULL); */
- pthread_mutex_init(&cs.mutex, NULL);
- cs.locked=0;
- *(void**)c=malloc(sizeof cs);
- memcpy(*(void**)c, &cs, sizeof cs);
+ struct CRITSECT *cs;
+ int i = critsecs_get_unused();
+
+ if (i < 0)
+ {
+ printf("InitializeCriticalSection(%p) - no more space in list\n", c);
+ return;
+ }
+ printf("got unused space at %d\n", i);
+ cs = expmalloc(sizeof(struct CRITSECT));
+ if (!cs)
+ {
+ printf("InitializeCriticalSection(%p) - out of memory\n", c);
+ return;
+ }
+ pthread_mutex_init(&cs->mutex, NULL);
+ cs->locked = 0;
+ critsecs_list[i].cs_win = c;
+ critsecs_list[i].cs_unix = cs;
+ dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n",
+ i, c, cs);
+ }
+#else
+ {
+ struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT), 0, AREATYPE_CRITSECT);
+ pthread_mutex_init(&cs->mutex, NULL);
+ cs->locked=0;
+ *(void**)c = cs;
+ }
+#endif
return;
}
-void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
+
+static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
{
+#ifdef CRITSECS_NEWTYPE
+ struct CRITSECT* cs = critsecs_get_unix(c);
+#else
struct CRITSECT* cs=*(struct CRITSECT**)c;
+#endif
dbgprintf("EnterCriticalSection(0x%x)\n",c);
if (!cs)
{
+ printf("entered uninitialized critisec!\n");
expInitializeCriticalSection(c);
+#ifdef CRITSECS_NEWTYPE
+ cs=critsecs_get_unix(c);
+#else
cs=*(struct CRITSECT**)c;
+#endif
printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
}
-// cs.id=pthread_self();
if(cs->locked)
if(cs->id==pthread_self())
return;
@@ -1095,10 +1258,14 @@ void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
cs->id=pthread_self();
return;
}
-void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
+static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
{
+#ifdef CRITSECS_NEWTYPE
+ struct CRITSECT* cs = critsecs_get_unix(c);
+#else
struct CRITSECT* cs=*(struct CRITSECT**)c;
-// struct CRITSECT* cs=(struct CRITSECT*)c;
+#endif
+ // struct CRITSECT* cs=(struct CRITSECT*)c;
dbgprintf("LeaveCriticalSection(0x%x)\n",c);
if (!cs)
{
@@ -1109,26 +1276,97 @@ void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
pthread_mutex_unlock(&(cs->mutex));
return;
}
-void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
+static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
{
+#ifdef CRITSECS_NEWTYPE
+ struct CRITSECT* cs = critsecs_get_unix(c);
+#else
struct CRITSECT* cs=*(struct CRITSECT**)c;
-// struct CRITSECT* cs=(struct CRITSECT*)c;
+#endif
+ // struct CRITSECT* cs=(struct CRITSECT*)c;
dbgprintf("DeleteCriticalSection(0x%x)\n",c);
+
+#ifndef GARBAGE
pthread_mutex_destroy(&(cs->mutex));
- free(cs);
+ // released by GarbageCollector in my_relase otherwise
+#endif
+ my_release(cs);
+#ifdef CRITSECS_NEWTYPE
+ {
+ int i = critsecs_get_pos(c);
+
+ if (i < 0)
+ {
+ printf("DeleteCriticalSection(%p) error (critsec not found)\n", c);
+ return;
+ }
+
+ critsecs_list[i].cs_win = NULL;
+ expfree(critsecs_list[i].cs_unix);
+ critsecs_list[i].cs_unix = NULL;
+ dbgprintf("DeleteCriticalSection -> itemno=%d\n", i);
+ }
+#endif
return;
}
-int WINAPI expGetCurrentThreadId()
+static int WINAPI expGetCurrentThreadId()
{
dbgprintf("GetCurrentThreadId() => %d\n", getpid());
return getpid();
}
-int WINAPI expGetCurrentProcess()
+static int WINAPI expGetCurrentProcess()
{
dbgprintf("GetCurrentProcess() => %d\n", getpid());
return getpid();
}
+extern void* fs_seg;
+
+#if 0
+// this version is required for Quicktime codecs (.qtx/.qts) to work.
+// (they assume some pointers at FS: segment)
+
+//static int tls_count;
+static int tls_use_map[64];
+static int WINAPI expTlsAlloc()
+{
+ int i;
+ for(i=0; i<64; i++)
+ if(tls_use_map[i]==0)
+ {
+ tls_use_map[i]=1;
+ return i;
+ }
+ return -1;
+}
+
+static int WINAPI expTlsSetValue(void idx, void* value)
+{
+ int index = (int) idx;
+ if((index<0) || (index>64))
+ return 0;
+ *(void**)((char*)fs_seg+0x88+4*index) = value;
+ return 1;
+}
+
+static void* WINAPI expTlsGetValue(int idx)
+{
+ int index = (int) idx;
+ if((index<0) || (index>64))
+ return 0;
+ return *(void**)((char*)fs_seg+0x88+index);
+}
+
+static int WINAPI expTlsFree(int idx)
+{
+ int index = (int) idx;
+ if((index<0) || (index>64))
+ return 0;
+ tls_use_map[index]=0;
+ return 1;
+}
+
+#else
struct tls_s {
void* value;
int used;
@@ -1136,9 +1374,7 @@ struct tls_s {
struct tls_s* next;
};
-tls_t* g_tls=NULL;
-
-void* WINAPI expTlsAlloc()
+static void* WINAPI expTlsAlloc()
{
if(g_tls==NULL)
{
@@ -1153,16 +1389,14 @@ void* WINAPI expTlsAlloc()
g_tls=g_tls->next;
}
dbgprintf("TlsAlloc() => 0x%x\n", g_tls);
- if( g_tls )
- g_tls->value=0; /* XXX For Divx.dll */
- else
- printf("WIN32: g_tls is null!!!\n");
-
+ if (g_tls)
+ g_tls->value=0; /* XXX For Divx.dll */
return g_tls;
}
-int WINAPI expTlsSetValue(tls_t* index, void* value)
+static int WINAPI expTlsSetValue(void* idx, void* value)
{
+ tls_t* index = (tls_t*) idx;
int result;
if(index==0)
result=0;
@@ -1174,8 +1408,9 @@ int WINAPI expTlsSetValue(tls_t* index, void* value)
dbgprintf("TlsSetValue(index 0x%x, value 0x%x) => %d \n", index, value, result );
return result;
}
-void* WINAPI expTlsGetValue(tls_t* index)
+static void* WINAPI expTlsGetValue(void* idx)
{
+ tls_t* index = (tls_t*) idx;
void* result;
if(index==0)
result=0;
@@ -1184,8 +1419,9 @@ void* WINAPI expTlsGetValue(tls_t* index)
dbgprintf("TlsGetValue(index 0x%x) => 0x%x\n", index, result);
return result;
}
-int WINAPI expTlsFree(tls_t* index)
+static int WINAPI expTlsFree(void* idx)
{
+ tls_t* index = (tls_t*) idx;
int result;
if(index==0)
result=0;
@@ -1194,99 +1430,127 @@ int WINAPI expTlsFree(tls_t* index)
if(index->next)
index->next->prev=index->prev;
if(index->prev)
- index->prev->next=index->next;
+ index->prev->next=index->next;
my_release((void*)index);
result=1;
}
dbgprintf("TlsFree(index 0x%x) => %d\n", index, result);
return result;
}
-void* WINAPI expLocalAlloc(int flags, int size)
+#endif
+
+static void* WINAPI expLocalAlloc(int flags, int size)
{
- void* z;
- if(flags&GMEM_ZEROINIT)
- z=my_mreq(size, 1);
- else
- z=my_mreq(size, 0);
- if(z==0)
+ void* z = my_mreq(size, (flags & GMEM_ZEROINIT));
+ if (z == 0)
printf("LocalAlloc() failed\n");
dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
return z;
}
-void* WINAPI expLocalReAlloc(int handle,int size, int flags)
+static void* WINAPI expLocalReAlloc(int handle,int size, int flags)
{
- void *newpointer;
- int oldsize;
+ void *newpointer;
+ int oldsize;
- newpointer=NULL;
- if (flags & LMEM_MODIFY) {
- dbgprintf("LocalReAlloc MODIFY\n");
- return (void *)handle;
- }
- oldsize = my_size((void *)handle);
- newpointer = my_realloc((void *)handle,size);
- dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer);
+ newpointer=NULL;
+ if (flags & LMEM_MODIFY) {
+ dbgprintf("LocalReAlloc MODIFY\n");
+ return (void *)handle;
+ }
+ oldsize = my_size((void *)handle);
+ newpointer = my_realloc((void *)handle,size);
+ dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer);
- return newpointer;
+ return newpointer;
}
-void* WINAPI expLocalLock(void* z)
+static void* WINAPI expLocalLock(void* z)
{
dbgprintf("LocalLock(0x%x) => 0x%x\n", z, z);
return z;
}
-void* WINAPI expGlobalAlloc(int flags, int size)
+static void* WINAPI expGlobalAlloc(int flags, int size)
{
void* z;
dbgprintf("GlobalAlloc(%d, flags 0x%X)\n", size, flags);
- if(flags&GMEM_ZEROINIT)
- z=my_mreq(size, 1);
- //z=calloc(size, 1);
- else
- z=my_mreq(size, 0);
- //z=malloc(size);
+
+ z=my_mreq(size, (flags & GMEM_ZEROINIT));
+ //z=calloc(size, 1);
+ //z=malloc(size);
if(z==0)
printf("GlobalAlloc() failed\n");
dbgprintf("GlobalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
return z;
}
-void* WINAPI expGlobalLock(void* z)
+static void* WINAPI expGlobalLock(void* z)
{
dbgprintf("GlobalLock(0x%x) => 0x%x\n", z, z);
return z;
}
-int WINAPI expLoadStringA(long instance, long id, void* buf, long size)
+// pvmjpg20 - but doesn't work anyway
+static int WINAPI expGlobalSize(void* amem)
+{
+ int size = 100000;
+#ifdef GARBAGE
+ alloc_header* header = last_alloc;
+ alloc_header* mem = (alloc_header*) amem - 1;
+ if (amem == 0)
+ return 0;
+ pthread_mutex_lock(&memmut);
+ while (header)
+ {
+ if (header->deadbeef != 0xdeadbeef)
+ {
+ printf("FATAL found corrupted memory! %p 0x%lx (%d)\n", header, header->deadbeef, alccnt);
+ break;
+ }
+
+ if (header == mem)
+ {
+ size = header->size;
+ break;
+ }
+
+ header = header->prev;
+ }
+ pthread_mutex_unlock(&memmut);
+#endif
+
+ dbgprintf("GlobalSize(0x%x)\n", amem);
+ return size;
+}
+static int WINAPI expLoadStringA(long instance, long id, void* buf, long size)
{
int result=LoadStringA(instance, id, buf, size);
-// if(buf)
+ // if(buf)
dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d ( %s )\n",
- instance, id, buf, size, result, buf);
-// else
-// dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d\n",
-// instance, id, buf, size, result);
+ instance, id, buf, size, result, buf);
+ // else
+ // dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d\n",
+ // instance, id, buf, size, result);
return result;
}
-long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, short* s2, int siz2)
+static long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, short* s2, int siz2)
{
#warning FIXME
int i;
int result;
if(s2==0)
- result=1;
+ result=1;
else
{
- if(siz1>siz2/2)siz1=siz2/2;
- for(i=1; i<=siz1; i++)
- {
- *s2=*s1;
- if(!*s1)break;
- s2++;
- s1++;
- }
- result=i;
+ if(siz1>siz2/2)siz1=siz2/2;
+ for(i=1; i<=siz1; i++)
+ {
+ *s2=*s1;
+ if(!*s1)break;
+ s2++;
+ s1++;
+ }
+ result=i;
}
if(s1)
dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s',"
@@ -1304,18 +1568,19 @@ static void wch_print(const short* str)
while(*str)dbgprintf("%c", *str++);
dbgprintf("\n");
}
-long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1, char* s2, int siz2, char* c3, int* siz3)
+static long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1,
+ char* s2, int siz2, char* c3, int* siz3)
{
int result;
dbgprintf("WideCharToMultiByte(codepage %d, flags 0x%x, src 0x%x, src size %d, "
- "dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3);
+ "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(s2)dbgprintf(" dest: %s\n", s2);
return result;
}
-long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
+static long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
{
dbgprintf("GetVersionExA(0x%x) => 1\n");
c->dwOSVersionInfoSize=sizeof(*c);
@@ -1331,34 +1596,35 @@ long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
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_NT\n Version string: 'Service Pack 3'\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)
+static HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count,
+ long max_count, char* name)
{
pthread_mutex_t *pm;
pthread_cond_t *pc;
mutex_list* pp;
-/*
- printf("CreateSemaphoreA(%p = %s)\n", name, (name ? name : "<null>"));
- pp=mlist;
- while(pp)
- {
- printf("%p => ", pp);
- pp=pp->prev;
- }
- printf("0\n");
-*/
+ /*
+ printf("CreateSemaphoreA(%p = %s)\n", name, (name ? name : "<null>"));
+ pp=mlist;
+ while(pp)
+ {
+ printf("%p => ", pp);
+ pp=pp->prev;
+ }
+ printf("0\n");
+ */
if(mlist!=NULL)
{
mutex_list* pp=mlist;
if(name!=NULL)
- do
+ do
{
if((strcmp(pp->name, name)==0) && (pp->type==1))
{
- dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x",
- v1, init_count, max_count, name, name, mlist);
+ dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
+ v1, init_count, max_count, name, name, mlist);
return (HANDLE)mlist;
}
}while((pp=pp->prev) != NULL);
@@ -1378,7 +1644,7 @@ HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, cha
mlist->next->prev=mlist;
mlist->next->next=NULL;
mlist=mlist->next;
-// printf("new semaphore %p\n", mlist);
+ // printf("new semaphore %p\n", mlist);
}
mlist->type=1; /* Type Semaphore */
mlist->pm=pm;
@@ -1387,26 +1653,26 @@ HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, cha
mlist->reset=0;
mlist->semaphore=init_count;
if(name!=NULL)
- strncpy(mlist->name, name, 64);
+ strncpy(mlist->name, name, 64);
else
mlist->name[0]=0;
if(pm==NULL)
dbgprintf("ERROR::: CreateSemaphoreA failure\n");
if(name)
- dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x",
- v1, init_count, max_count, name, name, mlist);
+ dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
+ v1, init_count, max_count, name, name, mlist);
else
- dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0) => 0x%x",
- v1, init_count, max_count, mlist);
+ dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0) => 0x%x\n",
+ v1, init_count, max_count, mlist);
return (HANDLE)mlist;
}
-long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)
+static long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)
{
-// The state of a semaphore object is signaled when its count
-// is greater than zero and nonsignaled when its count is equal to zero
-// Each time a waiting thread is released because of the semaphore's signaled
-// state, the count of the semaphore is decreased by one.
+ // The state of a semaphore object is signaled when its count
+ // is greater than zero and nonsignaled when its count is equal to zero
+ // Each time a waiting thread is released because of the semaphore's signaled
+ // state, the count of the semaphore is decreased by one.
mutex_list *ml = (mutex_list *)hsem;
pthread_mutex_lock(ml->pm);
@@ -1415,73 +1681,78 @@ long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)
ml->semaphore += increment;
pthread_mutex_unlock(ml->pm);
dbgprintf("ReleaseSemaphore(semaphore 0x%x, increment %d, prev_count 0x%x) => 1\n",
- hsem, increment, prev_count);
+ hsem, increment, prev_count);
return 1;
}
-long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
+static long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
{
long result=RegOpenKeyExA(key, subkey, reserved, access, newkey);
dbgprintf("RegOpenKeyExA(key 0x%x, subkey %s, reserved %d, access 0x%x, pnewkey 0x%x) => %d\n",
- key, subkey, reserved, access, newkey, result);
+ key, subkey, reserved, access, newkey, result);
if(newkey)dbgprintf(" New key: 0x%x\n", *newkey);
return result;
}
-long WINAPI expRegCloseKey(long key)
+static long WINAPI expRegCloseKey(long key)
{
long result=RegCloseKey(key);
dbgprintf("RegCloseKey(0x%x) => %d\n", key, result);
return result;
}
-long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
+static long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
{
long result=RegQueryValueExA(key, value, reserved, type, data, count);
dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)"
- " => 0x%x\n", key, value, reserved, data, count, result);
+ " => 0x%x\n", key, value, reserved, data, count, result);
if(data && count)dbgprintf(" read %d bytes: '%s'\n", *count, data);
return result;
}
-long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved,
- void* classs, long options, long security,
- void* sec_attr, int* newkey, int* status)
+static long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved,
+ void* classs, long options, long security,
+ void* sec_attr, int* newkey, int* status)
{
long result=RegCreateKeyExA(key, name, reserved, classs, options, security, sec_attr, newkey, status);
dbgprintf("RegCreateKeyExA(key 0x%x, name 0x%x='%s', reserved=0x%x,"
- " 0x%x, 0x%x, 0x%x, newkey=0x%x, status=0x%x) => %d\n",
- key, name, name, reserved, classs, options, security, sec_attr, newkey, status, result);
+ " 0x%x, 0x%x, 0x%x, newkey=0x%x, status=0x%x) => %d\n",
+ key, name, name, reserved, classs, options, security, sec_attr, newkey, status, result);
if(!result && newkey) dbgprintf(" New key: 0x%x\n", *newkey);
if(!result && status) dbgprintf(" New key status: 0x%x\n", *status);
return result;
}
-long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size)
+static long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size)
{
long result=RegSetValueExA(key, name, v1, v2, data, size);
dbgprintf("RegSetValueExA(key 0x%x, name '%s', 0x%x, 0x%x, data 0x%x -> 0x%x '%s', size=%d) => %d",
- key, name, v1, v2, data, *(int*)data, data, size, result);
+ key, name, v1, v2, data, *(int*)data, data, size, result);
return result;
}
-long WINAPI expRegOpenKeyA (
-long hKey,
- LPCSTR lpSubKey,
- int* phkResult
-){
+static long WINAPI expRegOpenKeyA (long hKey, LPCSTR lpSubKey, int* phkResult)
+{
long result=RegOpenKeyExA(hKey, lpSubKey, 0, 0, phkResult);
dbgprintf("RegOpenKeyExA(key 0x%x, subkey '%s', 0x%x) => %d\n",
- hKey, lpSubKey, phkResult, result);
+ hKey, lpSubKey, phkResult, result);
if(!result && phkResult) dbgprintf(" New key: 0x%x\n", *phkResult);
return result;
}
-DWORD WINAPI expRegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
- LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
+static 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)
+static DWORD WINAPI expRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
+ LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
+ LPFILETIME lpftLastWriteTime)
+{
+ return RegEnumKeyExA(hKey, dwIndex, lpName, lpcbName, lpReserved, lpClass,
+ lpcbClass, lpftLastWriteTime);
+}
+
+static long WINAPI expQueryPerformanceCounter(long long* z)
{
longcount(z);
dbgprintf("QueryPerformanceCounter(0x%x) => 1 ( %Ld )\n", z, *z);
@@ -1523,8 +1794,7 @@ static double linux_cpuinfo_freq()
}
-static double
-solaris_kstat_freq()
+static double solaris_kstat_freq()
{
#if defined(HAVE_LIBKSTAT) && defined(KSTAT_DATA_INT32)
/*
@@ -1596,13 +1866,13 @@ static double CPU_Freq()
return tsc_freq();
}
-long WINAPI expQueryPerformanceFrequency(long long* z)
+static long WINAPI expQueryPerformanceFrequency(long long* z)
{
*z=(long long)CPU_Freq();
dbgprintf("QueryPerformanceFrequency(0x%x) => 1 ( %Ld )\n", z, *z);
return 1;
}
-long WINAPI exptimeGetTime()
+static long WINAPI exptimeGetTime()
{
struct timeval t;
long result;
@@ -1611,23 +1881,23 @@ long WINAPI exptimeGetTime()
dbgprintf("timeGetTime() => %d\n", result);
return result;
}
-void* WINAPI expLocalHandle(void* v)
+static void* WINAPI expLocalHandle(void* v)
{
dbgprintf("LocalHandle(0x%x) => 0x%x\n", v, v);
return v;
}
-void* WINAPI expGlobalHandle(void* v)
+static void* WINAPI expGlobalHandle(void* v)
{
dbgprintf("GlobalHandle(0x%x) => 0x%x\n", v, v);
return v;
}
-int WINAPI expGlobalUnlock(void* v)
+static int WINAPI expGlobalUnlock(void* v)
{
dbgprintf("GlobalUnlock(0x%x) => 1\n", v);
return 1;
}
-void* WINAPI expGlobalFree(void* v)
+static void* WINAPI expGlobalFree(void* v)
{
dbgprintf("GlobalFree(0x%x) => 0\n", v);
my_release(v);
@@ -1635,7 +1905,7 @@ void* WINAPI expGlobalFree(void* v)
return 0;
}
-void* WINAPI expGlobalReAlloc(void* v, int size, int flags)
+static void* WINAPI expGlobalReAlloc(void* v, int size, int flags)
{
void* result=my_realloc(v, size);
//void* result=realloc(v, size);
@@ -1643,38 +1913,41 @@ void* WINAPI expGlobalReAlloc(void* v, int size, int flags)
return result;
}
-int WINAPI expLocalUnlock(void* v)
+static int WINAPI expLocalUnlock(void* v)
{
dbgprintf("LocalUnlock(0x%x) => 1\n", v);
return 1;
}
- //
-void* WINAPI expLocalFree(void* v)
+//
+static void* WINAPI expLocalFree(void* v)
{
dbgprintf("LocalFree(0x%x) => 0\n", v);
my_release(v);
return 0;
}
-HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type)
+static HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type)
{
- HRSRC result=FindResourceA(module, name, type);
- dbgprintf("FindResourceA(module 0x%x, name 0x%x, type 0x%x) => 0x%x\n", module, name, type, result);
+ HRSRC result;
+
+ result=FindResourceA(module, name, type);
+ dbgprintf("FindResourceA(module 0x%x, name 0x%x(%s), type 0x%x(%s)) => 0x%x\n", module, HIWORD(name) ? name : "UNICODE", HIWORD(type) ? type : "UNICODE", result);
return result;
}
+
extern HRSRC WINAPI LoadResource(HMODULE, HRSRC);
-HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res)
+static HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res)
{
HGLOBAL result=LoadResource(module, res);
dbgprintf("LoadResource(module 0x%x, resource 0x%x) => 0x%x\n", module, res, result);
return result;
}
-void* WINAPI expLockResource(long res)
+static void* WINAPI expLockResource(long res)
{
void* result=LockResource(res);
dbgprintf("LockResource(0x%x) => 0x%x\n", res, result);
return result;
}
-int WINAPI expFreeResource(long res)
+static int WINAPI expFreeResource(long res)
{
int result=FreeResource(res);
dbgprintf("FreeResource(0x%x) => %d\n", res, result);
@@ -1682,151 +1955,152 @@ int WINAPI expFreeResource(long res)
}
//bool fun(HANDLE)
//!0 on success
-int WINAPI expCloseHandle(long v1)
+static int WINAPI expCloseHandle(long v1)
{
dbgprintf("CloseHandle(0x%x) => 1\n", v1);
return 1;
}
-const char* WINAPI expGetCommandLineA()
+static const char* WINAPI expGetCommandLineA()
{
dbgprintf("GetCommandLineA() => \"c:\\aviplay.exe\"\n");
return "c:\\aviplay.exe";
}
static short envs[]={'p', 'a', 't', 'h', ' ', 'c', ':', '\\', 0, 0};
-LPWSTR WINAPI expGetEnvironmentStringsW()
+static LPWSTR WINAPI expGetEnvironmentStringsW()
{
- dbgprintf("GetEnvironmentStringsW() => 0\n", envs);
- return 0;
+ dbgprintf("GetEnvironmentStringsW() => 0\n", envs);
+ return 0;
}
-void * WINAPI expRtlZeroMemory(void *p, size_t len)
+static void * WINAPI expRtlZeroMemory(void *p, size_t len)
{
void* result=memset(p,0,len);
dbgprintf("RtlZeroMemory(0x%x, len %d) => 0x%x\n",p,len,result);
return result;
}
-void * WINAPI expRtlMoveMemory(void *dst, void *src, size_t len)
+static void * WINAPI expRtlMoveMemory(void *dst, void *src, size_t len)
{
void* result=memmove(dst,src,len);
dbgprintf("RtlMoveMemory (dest 0x%x, src 0x%x, len %d) => 0x%x\n",dst,src,len,result);
return result;
}
-void * WINAPI expRtlFillMemory(void *p, int ch, size_t len)
+static void * WINAPI expRtlFillMemory(void *p, int ch, size_t len)
{
void* result=memset(p,ch,len);
dbgprintf("RtlFillMemory(0x%x, char 0x%x, len %d) => 0x%x\n",p,ch,len,result);
return result;
}
-int WINAPI expFreeEnvironmentStringsW(short* strings)
+static int WINAPI expFreeEnvironmentStringsW(short* strings)
{
dbgprintf("FreeEnvironmentStringsW(0x%x) => 1\n", strings);
return 1;
}
-int WINAPI expFreeEnvironmentStringsA(char* strings)
+static int WINAPI expFreeEnvironmentStringsA(char* strings)
{
- dbgprintf("FreeEnvironmentStringsA(0x%x) => 1\n", strings);
- return 1;
+ dbgprintf("FreeEnvironmentStringsA(0x%x) => 1\n", strings);
+ return 1;
}
+
static const char ch_envs[]=
- "__MSVCRT_HEAP_SELECT=__GLOBAL_HEAP_SELECTED,1\r\n"
- "PATH=C:\\;C:\\windows\\;C:\\windows\\system\r\n";
-LPCSTR WINAPI expGetEnvironmentStrings()
+"__MSVCRT_HEAP_SELECT=__GLOBAL_HEAP_SELECTED,1\r\n"
+"PATH=C:\\;C:\\windows\\;C:\\windows\\system\r\n";
+static LPCSTR WINAPI expGetEnvironmentStrings()
{
dbgprintf("GetEnvironmentStrings() => 0x%x\n", ch_envs);
return (LPCSTR)ch_envs;
-// dbgprintf("GetEnvironmentStrings() => 0\n");
-// return 0;
+ // dbgprintf("GetEnvironmentStrings() => 0\n");
+ // return 0;
}
-int WINAPI expGetStartupInfoA(STARTUPINFOA *s)
+static int WINAPI expGetStartupInfoA(STARTUPINFOA *s)
{
int i;
dbgprintf("GetStartupInfoA(0x%x) => 1\n");
memset(s, 0, sizeof(*s));
s->cb=sizeof(*s);
-// s->lpReserved="Reserved";
-// s->lpDesktop="Desktop";
-// s->lpTitle="Title";
-// s->dwX=s->dwY=0;
-// s->dwXSize=s->dwYSize=200;
- s->dwFlags=s->wShowWindow=1;
-// s->hStdInput=s->hStdOutput=s->hStdError=0x1234;
+ // s->lpReserved="Reserved";
+ // s->lpDesktop="Desktop";
+ // s->lpTitle="Title";
+ // s->dwX=s->dwY=0;
+ // s->dwXSize=s->dwYSize=200;
+ s->dwFlags=s->wShowWindow=1;
+ // s->hStdInput=s->hStdOutput=s->hStdError=0x1234;
dbgprintf(" cb=%d\n", s->cb);
dbgprintf(" lpReserved='%s'\n", s->lpReserved);
dbgprintf(" lpDesktop='%s'\n", s->lpDesktop);
dbgprintf(" lpTitle='%s'\n", s->lpTitle);
dbgprintf(" dwX=%d dwY=%d dwXSize=%d dwYSize=%d\n",
- s->dwX, s->dwY, s->dwXSize, s->dwYSize);
+ s->dwX, s->dwY, s->dwXSize, s->dwYSize);
dbgprintf(" dwXCountChars=%d dwYCountChars=%d dwFillAttribute=%d\n",
- s->dwXCountChars, s->dwYCountChars, s->dwFillAttribute);
+ s->dwXCountChars, s->dwYCountChars, s->dwFillAttribute);
dbgprintf(" dwFlags=0x%x wShowWindow=0x%x cbReserved2=0x%x\n",
- s->dwFlags, s->wShowWindow, s->cbReserved2);
+ s->dwFlags, s->wShowWindow, s->cbReserved2);
dbgprintf(" lpReserved2=0x%x hStdInput=0x%x hStdOutput=0x%x hStdError=0x%x\n",
- s->lpReserved2, s->hStdInput, s->hStdOutput, s->hStdError);
+ s->lpReserved2, s->hStdInput, s->hStdOutput, s->hStdError);
return 1;
}
-int WINAPI expGetStdHandle(int z)
+static int WINAPI expGetStdHandle(int z)
{
- dbgprintf("GetStdHandle(0x%x) => 0x%x\n", z+0x1234);
- return z+0x1234;
+ dbgprintf("GetStdHandle(0x%x) => 0x%x\n", z+0x1234);
+ return z+0x1234;
}
-int WINAPI expGetFileType(int handle)
+static int WINAPI expGetFileType(int handle)
{
- dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle);
- return 0x3;
+ dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle);
+ return 0x3;
}
-int WINAPI expSetHandleCount(int count)
+static int WINAPI expSetHandleCount(int count)
{
dbgprintf("SetHandleCount(0x%x) => 1\n", count);
return 1;
}
-int WINAPI expGetACP()
+static int WINAPI expGetACP()
{
dbgprintf("GetACP() => 0\n");
return 0;
}
extern WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m);
-int WINAPI expGetModuleFileNameA(int module, char* s, int len)
+static int WINAPI expGetModuleFileNameA(int module, char* s, int len)
{
WINE_MODREF *mr;
int result;
-// printf("File name of module %X requested\n", module);
+ // printf("File name of module %X requested\n", module);
if(s==0)
result=0;
else
- if(len<35)
- result=0;
- else
- {
- result=1;
- strcpy(s, "c:\\windows\\system\\");
- mr=MODULE32_LookupHMODULE(module);
- if(mr==0)//oops
- strcat(s, "aviplay.dll");
- else
- if(strrchr(mr->filename, '/')==NULL)
- strcat(s, mr->filename);
+ if(len<35)
+ result=0;
else
- strcat(s, strrchr(mr->filename, '/')+1);
- }
+ {
+ result=1;
+ strcpy(s, "c:\\windows\\system\\");
+ mr=MODULE32_LookupHMODULE(module);
+ if(mr==0)//oops
+ strcat(s, "aviplay.dll");
+ else
+ if(strrchr(mr->filename, '/')==NULL)
+ strcat(s, mr->filename);
+ else
+ strcat(s, strrchr(mr->filename, '/')+1);
+ }
if(!s)
- dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d\n",
- module, s, len, result);
+ dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d\n",
+ module, s, len, result);
else
- dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d ( '%s' )",
- module, s, len, result, s);
+ dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d ( '%s' )\n",
+ module, s, len, result, s);
return result;
}
-int WINAPI expSetUnhandledExceptionFilter(void* filter)
+static int WINAPI expSetUnhandledExceptionFilter(void* filter)
{
dbgprintf("SetUnhandledExceptionFilter(0x%x) => 1\n", filter);
return 1;//unsupported and probably won't ever be supported
}
-int WINAPI expLoadLibraryA(char* name)
+static int WINAPI expLoadLibraryA(char* name)
{
int result = 0;
char* lastbc;
@@ -1840,8 +2114,8 @@ int WINAPI expLoadLibraryA(char* name)
lastbc = strrchr(name, '\\');
if (lastbc)
{
- int i;
- lastbc++;
+ int i;
+ lastbc++;
for (i = 0; 1 ;i++)
{
name[i] = *lastbc++;
@@ -1853,22 +2127,25 @@ int WINAPI expLoadLibraryA(char* name)
if(strncmp(name, ".\\", 2)==0) name += 2;
dbgprintf("Entering LoadLibraryA(%s)\n", name);
- // PIMJ is loading kernel32.dll
- if (strcasecmp(name, "kernel32.dll") == 1)
- return (int) LookupExternal(name, 0);
+
+ // PIMJ and VIVO audio are loading kernel32.dll
+ if (strcasecmp(name, "kernel32.dll") == 0 || strcasecmp(name, "kernel32") == 0)
+// return MODULE_HANDLE_kernel32;
+ return ERROR_SUCCESS; /* yeah, we have also the kernel32 calls */
+ /* exported -> do not return failed! */
result=LoadLibraryA(name);
- dbgprintf("Returned LoadLibraryA(0x%x='%s'), win32_def_path=%s => 0x%x\n", name, name, win32_def_path, result);
+ dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, win32_def_path, result);
return result;
}
-int WINAPI expFreeLibrary(int module)
+static int WINAPI expFreeLibrary(int module)
{
int result=FreeLibrary(module);
dbgprintf("FreeLibrary(0x%x) => %d\n", module, result);
return result;
}
-void* WINAPI expGetProcAddress(HMODULE mod, char* name)
+static void* WINAPI expGetProcAddress(HMODULE mod, char* name)
{
void* result;
if(mod!=MODULE_HANDLE_kernel32)
@@ -1879,8 +2156,9 @@ void* WINAPI expGetProcAddress(HMODULE mod, char* name)
return result;
}
-long WINAPI expCreateFileMappingA(int hFile, void* lpAttr,
- long flProtect, long dwMaxHigh, long dwMaxLow, const char* name)
+static 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)
@@ -1894,70 +2172,121 @@ long WINAPI expCreateFileMappingA(int hFile, void* lpAttr,
return result;
}
-long WINAPI expOpenFileMappingA(long hFile, long hz, const char* name)
+static long WINAPI expOpenFileMappingA(long hFile, long hz, const char* name)
{
long result=OpenFileMappingA(hFile, hz, name);
if(!name)
dbgprintf("OpenFileMappingA(0x%x, 0x%x, 0) => %d\n",
- hFile, hz, result);
+ hFile, hz, result);
else
dbgprintf("OpenFileMappingA(0x%x, 0x%x, 0x%x='%s') => %d\n",
- hFile, hz, name, name, result);
+ hFile, hz, name, name, result);
return result;
}
-void* WINAPI expMapViewOfFile(HANDLE file, DWORD mode, DWORD offHigh, DWORD offLow, DWORD size)
+static void* WINAPI expMapViewOfFile(HANDLE file, DWORD mode, DWORD offHigh,
+ DWORD offLow, DWORD size)
{
dbgprintf("MapViewOfFile(0x%x, 0x%x, 0x%x, 0x%x, size %d) => 0x%x\n",
- file,mode,offHigh,offLow,size,(char*)file+offLow);
+ file,mode,offHigh,offLow,size,(char*)file+offLow);
return (char*)file+offLow;
}
-void* WINAPI expUnmapViewOfFile(void* view)
+static void* WINAPI expUnmapViewOfFile(void* view)
{
dbgprintf("UnmapViewOfFile(0x%x) => 0\n", view);
return 0;
}
-void* WINAPI expSleep(int time)
+static void* WINAPI expSleep(int time)
{
-// extern int avm_usleep(int);
- dbgprintf("Sleep(%d) => 0\n", time);
-// avm_usleep(time);
+#if HAVE_NANOSLEEP
+ /* solaris doesn't have thread safe usleep */
+ struct timespec tsp;
+ tsp.tv_sec = time / 1000000;
+ tsp.tv_nsec = (time % 1000000) * 1000;
+ nanosleep(&tsp, NULL);
+#else
usleep(time);
+#endif
+ dbgprintf("Sleep(%d) => 0\n", time);
return 0;
}
- // why does IV32 codec want to call this? I don't know ...
-void* WINAPI expCreateCompatibleDC(int hdc)
+// why does IV32 codec want to call this? I don't know ...
+static int WINAPI expCreateCompatibleDC(int hdc)
{
- dbgprintf("CreateCompatibleDC(%d) => 0x81\n", hdc);
- return (void*)0x81;
+ int dc = 0;//0x81;
+ //dbgprintf("CreateCompatibleDC(%d) => 0x81\n", hdc);
+ dbgprintf("CreateCompatibleDC(%d) => %d\n", hdc, dc);
+ return dc;
}
-int WINAPI expGetDeviceCaps(int hdc, int unk)
+static int WINAPI expGetDeviceCaps(int hdc, int unk)
{
- dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk);
- return 0;
+ dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk);
+ return 0;
}
-WIN_BOOL WINAPI expDeleteDC(int hdc)
+static WIN_BOOL WINAPI expDeleteDC(int hdc)
{
- dbgprintf("DeleteDC(0x%x) => 0\n", hdc);
- return 0;
+ dbgprintf("DeleteDC(0x%x) => 0\n", hdc);
+ if (hdc == 0x81)
+ return 1;
+ return 0;
}
-int expwsprintfA(char* string, char* format, ...)
+static WIN_BOOL WINAPI expDeleteObject(int hdc)
{
- va_list va;
- int result;
- va_start(va, format);
- result=vsprintf(string, format, va);
- dbgprintf("wsprintfA(0x%x, '%s', ...) => %d\n", string, format, result);
- va_end(va);
- return result;
+ dbgprintf("DeleteObject(0x%x) => 1\n", hdc);
+ /* FIXME - implement code here */
+ return 1;
+}
+
+/* btvvc32.drv wants this one */
+static void* WINAPI expGetWindowDC(int hdc)
+{
+ dbgprintf("GetWindowDC(%d) => 0x0\n", hdc);
+ return 0;
+}
+
+/*
+ * Returns the number of milliseconds, modulo 2^32, since the start
+ * of the wineserver.
+ */
+static int WINAPI expGetTickCount(void)
+{
+ static int tcstart = 0;
+ struct timeval t;
+ int tc;
+ gettimeofday( &t, NULL );
+ tc = ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - tcstart;
+ if (tcstart == 0)
+ {
+ tcstart = 0;
+ tc = 0;
+ }
+ dbgprintf("GetTickCount() => %d\n", tc);
+ return tc;
+}
+
+static int WINAPI expCreateFontA(void)
+{
+ dbgprintf("CreateFontA() => 0x0\n");
+ return 1;
+}
+
+/* tried to get pvmjpg work in a different way - no success */
+static int WINAPI expDrawTextA(int hDC, char* lpString, int nCount,
+ LPRECT lpRect, unsigned int uFormat)
+{
+ dbgprintf("expDrawTextA(%p,...) => 8\n", hDC);
+ return 8;
}
-int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename)
+static int WINAPI expGetPrivateProfileIntA(const char* appname,
+ const char* keyname,
+ int default_value,
+ const char* filename)
{
int size=255;
char buffer[256];
@@ -1967,7 +2296,7 @@ int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, in
buffer[255]=0;
if(!(appname && keyname && filename) )
{
- dbgprintf("GetPrivateProfileIntA('%s', '%s', %d, '%s') => %d\n", appname, keyname, default_value, filename, default_value );
+ dbgprintf("GetPrivateProfileIntA('%s', '%s', %d, '%s') => %d\n", appname, keyname, default_value, filename, default_value );
return default_value;
}
fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename));
@@ -1980,7 +2309,7 @@ int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, in
result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)buffer, &size);
if((size>=0)&&(size<256))
buffer[size]=0;
-// printf("GetPrivateProfileIntA(%s, %s, %s) -> %s\n", appname, keyname, filename, buffer);
+ // printf("GetPrivateProfileIntA(%s, %s, %s) -> %s\n", appname, keyname, filename, buffer);
free(fullname);
if(result)
result=default_value;
@@ -1989,15 +2318,19 @@ int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, in
dbgprintf("GetPrivateProfileIntA('%s', '%s', %d, '%s') => %d\n", appname, keyname, default_value, filename, result);
return result;
}
-int WINAPI expGetProfileIntA(const char* appname, const char* keyname, int default_value)
+static int WINAPI expGetProfileIntA(const char* appname,
+ const char* keyname,
+ int default_value)
{
dbgprintf("GetProfileIntA -> ");
-// dbgprintf("GetProfileIntA(%s, %s, %d)\n", appname, keyname, default_value);
return expGetPrivateProfileIntA(appname, keyname, default_value, "default");
}
-int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname,
- const char* def_val, char* dest, unsigned int len, const char* filename)
+static int WINAPI expGetPrivateProfileStringA(const char* appname,
+ const char* keyname,
+ const char* def_val,
+ char* dest, unsigned int len,
+ const char* filename)
{
int result;
int size;
@@ -2013,7 +2346,6 @@ int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname,
strcat(fullname, filename);
size=len;
result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)dest, &size);
-// printf("GetPrivateProfileStringA(%s, %s, %s, %X, %X, %s)\n", appname, keyname, def_val, dest, len, filename );
free(fullname);
if(result)
{
@@ -2023,8 +2355,10 @@ int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname,
dbgprintf(" => %d ( '%s' )\n", size, dest);
return size;
}
-int WINAPI expWritePrivateProfileStringA(const char* appname, const char* keyname,
- const char* string, const char* filename)
+static int WINAPI expWritePrivateProfileStringA(const char* appname,
+ const char* keyname,
+ const char* string,
+ const char* filename)
{
int size=256;
char* fullname;
@@ -2042,217 +2376,57 @@ int WINAPI expWritePrivateProfileStringA(const char* appname, const char* keynam
strcat(fullname, "\\");
strcat(fullname, filename);
RegSetValueExA(HKEY_LOCAL_MACHINE, fullname, 0, REG_SZ, (int*)string, strlen(string));
-// printf("RegSetValueExA(%s,%d)\n", string, strlen(string));
-// printf("WritePrivateProfileStringA(%s, %s, %s, %s)\n", appname, keyname, string, filename );
+ // printf("RegSetValueExA(%s,%d)\n", string, strlen(string));
+ // printf("WritePrivateProfileStringA(%s, %s, %s, %s)\n", appname, keyname, string, filename );
free(fullname);
dbgprintf(" => 0\n");
return 0;
}
-int expsprintf(char* str, const char* format, ...)
-{
- va_list args;
- int r;
- dbgprintf("sprintf(%s, %s)\n", str, format);
- va_start(args, format);
- r = vsprintf(str, format, args);
- va_end(args);
- return r;
-}
-int expsscanf(const char* str, const char* format, ...)
-{
- va_list args;
- int r;
- dbgprintf("sscanf(%s, %s)\n", str, format);
- va_start(args, format);
- r = vsscanf(str, format, args);
- va_end(args);
- return r;
-}
-void* expfopen(const char* path, const char* mode)
-{
- printf("fopen: \"%s\" mode:%s\n", path, mode);
- //return fopen(path, mode);
- return fdopen(0, mode); // everything on screen
-}
-int expfprintf(void* stream, const char* format, ...)
-{
- va_list args;
- int r = 0;
-#if 1
- va_start(args, format);
- r = vfprintf((FILE*) stream, format, args);
- va_end(args);
-#endif
- return r;
-}
-
-int expprintf(const char* format, ...)
-{
- va_list args;
- int r;
- va_start(args, format);
- r = vprintf(format, args);
- va_end(args);
- return r;
-}
-
-void* expwcscpy(WCHAR* dst, const WCHAR* src)
-{
- WCHAR* p = dst;
- while ((*p++ = *src++))
- ;
- return dst;
-}
-
unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, INT default_value, const char* filename)
{
return expGetPrivateProfileIntA(appname, keyname, default_value, filename);
}
int _GetPrivateProfileStringA(const char* appname, const char* keyname,
- const char* def_val, char* dest, unsigned int len, const char* filename)
+ const char* def_val, char* dest, unsigned int len, const char* filename)
{
return expGetPrivateProfileStringA(appname, keyname, def_val, dest, len, filename);
}
int _WritePrivateProfileStringA(const char* appname, const char* keyname,
- const char* string, const char* filename)
+ const char* string, const char* filename)
{
return expWritePrivateProfileStringA(appname, keyname, string, filename);
}
-int WINAPI expDefDriverProc(int _private, int id, int msg, int arg1, int arg2)
+static int WINAPI expDefDriverProc(int _private, int id, int msg, int arg1, int arg2)
{
dbgprintf("DefDriverProc(0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0\n", _private, id, msg, arg1, arg2);
return 0;
}
-int WINAPI expSizeofResource(int v1, int v2)
+static int WINAPI expSizeofResource(int v1, int v2)
{
int result=SizeofResource(v1, v2);
dbgprintf("SizeofResource(0x%x, 0x%x) => %d\n", v1, v2, result);
return result;
}
-int WINAPI expGetLastError()
+static int WINAPI expGetLastError()
{
int result=GetLastError();
dbgprintf("GetLastError() => 0x%x\n", result);
return result;
}
-void WINAPI expSetLastError(int error)
+static void WINAPI expSetLastError(int error)
{
dbgprintf("SetLastError(0x%x)\n", error);
SetLastError(error);
}
-char* expstrrchr(char* string, int value)
-{
- char* result=strrchr(string, value);
- if(result)
- dbgprintf("strrchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result);
- else
- dbgprintf("strrchr(0x%x='%s', %d) => 0", string, string, value);
- return result;
-}
-
-char* expstrchr(char* string, int value)
-{
- char* result=strchr(string, value);
- if(result)
- dbgprintf("strchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result);
- else
- dbgprintf("strchr(0x%x='%s', %d) => 0", string, string, value);
- return result;
-}
-int expstrlen(char* str)
-{
- int result=strlen(str);
- dbgprintf("strlen(0x%x='%s') => %d\n", str, str, result);
- return result;
-}
-int expstrcpy(char* str1, const char* str2)
-{
- int result= (int) strcpy(str1, str2);
- dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result);
- return result;
-}
-int expstrcmp(const char* str1, const char* str2)
-{
- int result=strcmp(str1, str2);
- dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
- return result;
-}
-int expstrcat(char* str1, const char* str2)
-{
- int result= (int) strcat(str1, str2);
- dbgprintf("strcat(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
- return result;
-}
-int expisalnum(int c)
-{
- int result= (int) isalnum(c);
- dbgprintf("isalnum(0x%x='%c' => %d\n", c, c, result);
- return result;
-}
-int expmemmove(void* dest, void* src, int n)
-{
- int result= (int) memmove(dest, src, n);
- dbgprintf("memmove(0x%x, 0x%x, %d) => %d\n", dest, src, n, result);
- return result;
-}
-int expmemcmp(void* dest, void* src, int n)
-{
- int result=memcmp(dest, src, n);
- dbgprintf("memcmp(0x%x, 0x%x, %d) => %d\n", dest, src, n, result);
- return result;
-}
-void *expmemcpy(void* dest, void* src, int n)
-{
- void *result=memcpy(dest, src, n);
- dbgprintf("memcpy(0x%x, 0x%x, %d) => %p\n", dest, src, n, result);
- return result;
-}
-time_t exptime(time_t* t)
-{
- time_t result=time(t);
- dbgprintf("time(0x%x) => %d\n", t, result);
- return result;
-}
-
-int exprand(void)
-{
- return rand();
-}
-
-double explog10(double x)
-{
- return log10(x);
-}
-
-double expcos(double x)
-{
- return cos(x);
-}
-
-double exppow(double x, double y)
-{
- return pow(x, y);
-}
-
-void expsrand(int seed)
-{
- srand(seed);
-}
-
-int exp_ftol(float f)
-{
- return (int)(f+.5);
-}
-
-int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax)
+static int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax)
{
int result=snprintf(str, cbMax, "%.8x-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",
guid->f1, guid->f2, guid->f3,
@@ -2265,13 +2439,13 @@ int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax)
}
-int WINAPI expGetFileVersionInfoSizeA(const char* name, int* lpHandle)
+static int WINAPI expGetFileVersionInfoSizeA(const char* name, int* lpHandle)
{
dbgprintf("GetFileVersionInfoSizeA(0x%x='%s', 0x%X) => 0\n", name, name, lpHandle);
return 0;
}
-int WINAPI expIsBadStringPtrW(const short* string, int nchars)
+static int WINAPI expIsBadStringPtrW(const short* string, int nchars)
{
int result;
if(string==0)result=1; else result=0;
@@ -2279,103 +2453,114 @@ int WINAPI expIsBadStringPtrW(const short* string, int nchars)
if(string)wch_print(string);
return result;
}
-extern long WINAPI InterlockedExchangeAdd( long* dest, long incr )
+static int WINAPI expIsBadStringPtrA(const char* string, int nchars)
+{
+ return expIsBadStringPtrW((const short*)string, nchars);
+}
+static long WINAPI expInterlockedExchangeAdd( long* dest, long incr )
{
long ret;
- __asm__ __volatile__( "lock; xaddl %0,(%1)"
- : "=r" (ret) : "r" (dest), "0" (incr) : "memory" );
+ __asm__ __volatile__
+ (
+ "lock; xaddl %0,(%1)"
+ : "=r" (ret)
+ : "r" (dest), "0" (incr)
+ : "memory"
+ );
return ret;
}
-extern long WINAPI expInterlockedIncrement( long* dest )
+static long WINAPI expInterlockedIncrement( long* dest )
{
- long result=InterlockedExchangeAdd( dest, 1 ) + 1;
+ long result=expInterlockedExchangeAdd( dest, 1 ) + 1;
dbgprintf("InterlockedIncrement(0x%x => %d) => %d\n", dest, *dest, result);
return result;
}
-extern long WINAPI expInterlockedDecrement( long* dest )
+static long WINAPI expInterlockedDecrement( long* dest )
{
- long result=InterlockedExchangeAdd( dest, -1 ) - 1;
+ long result=expInterlockedExchangeAdd( dest, -1 ) - 1;
dbgprintf("InterlockedDecrement(0x%x => %d) => %d\n", dest, *dest, result);
return result;
}
-extern void WINAPI expOutputDebugStringA( const char* string )
+static void WINAPI expOutputDebugStringA( const char* string )
{
dbgprintf("OutputDebugStringA(0x%x='%s')\n", string);
fprintf(stderr, "DEBUG: %s\n", string);
}
-int WINAPI expGetDC(int hwnd)
+static int WINAPI expGetDC(int hwnd)
{
dbgprintf("GetDC(0x%x) => 0\n", hwnd);
return 0;
}
-int WINAPI expGetDesktopWindow()
+static int WINAPI expReleaseDC(int hwnd, int hdc)
{
- dbgprintf("GetDesktopWindow() => 0\n");
+ dbgprintf("ReleaseDC(0x%x, 0x%x) => 0\n", hwnd, hdc);
return 0;
}
-int WINAPI expReleaseDC(int hwnd, int hdc)
+static int WINAPI expGetDesktopWindow()
{
- dbgprintf("ReleaseDC(0x%x, 0x%x) => 0\n", hwnd, hdc);
+ dbgprintf("GetDesktopWindow() => 0\n");
return 0;
}
+
static int cursor[100];
-int WINAPI expLoadCursorA(int handle,LPCSTR name)
+static int WINAPI expLoadCursorA(int handle,LPCSTR name)
{
- dbgprintf("LoadCursorA(%d, 0x%x='%s') => 0x%x\n", handle, name, (int)&cursor[0]);
- return (int)&cursor[0];
+ dbgprintf("LoadCursorA(%d, 0x%x='%s') => 0x%x\n", handle, name, (int)&cursor[0]);
+ return (int)&cursor[0];
}
-int WINAPI expSetCursor(void *cursor)
+static int WINAPI expSetCursor(void *cursor)
{
dbgprintf("SetCursor(0x%x) => 0x%x\n", cursor, cursor);
return (int)cursor;
}
-int WINAPI expGetCursorPos(void *cursor)
+static int WINAPI expGetCursorPos(void *cursor)
{
dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor);
return 1;
}
-int WINAPI expRegisterWindowMessageA(char *message)
+static int WINAPI expRegisterWindowMessageA(char *message)
{
dbgprintf("RegisterWindowMessageA(%s)\n", message);
return 1;
}
-int WINAPI expGetProcessVersion(int pid)
+static int WINAPI expGetProcessVersion(int pid)
{
dbgprintf("GetProcessVersion(%d)\n", pid);
return 1;
}
-int WINAPI expGetCurrentThread(void)
+static int WINAPI expGetCurrentThread(void)
{
- dbgprintf("GetCurrentThread()\n");
- return 1;
+#warning FIXME!
+ dbgprintf("GetCurrentThread() => %x\n", 0xcfcf9898);
+ return 0xcfcf9898;
}
-int WINAPI expGetOEMCP(void)
+static int WINAPI expGetOEMCP(void)
{
dbgprintf("GetOEMCP()\n");
return 1;
}
-int WINAPI expGetCPInfo(int cp,void *info)
+static int WINAPI expGetCPInfo(int cp,void *info)
{
dbgprintf("GetCPInfo()\n");
return 0;
}
-int WINAPI expGetSystemMetrics(int index)
+static int WINAPI expGetSystemMetrics(int index)
{
dbgprintf("GetSystemMetrics(%d)\n", index);
return 1;
}
-int WINAPI expGetSysColor(int index)
+static int WINAPI expGetSysColor(int index)
{
dbgprintf("GetSysColor(%d)\n", index);
return 1;
}
-int WINAPI expGetSysColorBrush(int index)
+static int WINAPI expGetSysColorBrush(int index)
{
dbgprintf("GetSysColorBrush(%d)\n", index);
return 1;
@@ -2383,26 +2568,26 @@ int WINAPI expGetSysColorBrush(int index)
-int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe)
+static int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe)
{
dbgprintf("GetSystemPaletteEntries(0x%x, 0x%x, 0x%x, 0x%x) => 0\n",
- hdc, iStartIndex, nEntries, lppe);
+ hdc, iStartIndex, nEntries, lppe);
return 0;
}
/*
-typedef struct _TIME_ZONE_INFORMATION {
- long Bias;
- char StandardName[32];
- SYSTEMTIME StandardDate;
- long StandardBias;
- char DaylightName[32];
- SYSTEMTIME DaylightDate;
- long DaylightBias;
-} TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
-*/
-
-int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
+ typedef struct _TIME_ZONE_INFORMATION {
+ long Bias;
+ char StandardName[32];
+ SYSTEMTIME StandardDate;
+ long StandardBias;
+ char DaylightName[32];
+ SYSTEMTIME DaylightDate;
+ long DaylightBias;
+ } TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
+ */
+
+static int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
{
const short name[]={'C', 'e', 'n', 't', 'r', 'a', 'l', ' ', 'S', 't', 'a',
'n', 'd', 'a', 'r', 'd', ' ', 'T', 'i', 'm', 'e', 0};
@@ -2424,7 +2609,7 @@ int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformati
return TIME_ZONE_ID_STANDARD;
}
-void WINAPI expGetLocalTime(SYSTEMTIME* systime)
+static void WINAPI expGetLocalTime(SYSTEMTIME* systime)
{
time_t local_time;
struct tm *local_tm;
@@ -2444,13 +2629,13 @@ void WINAPI expGetLocalTime(SYSTEMTIME* systime)
systime->wSecond = local_tm->tm_sec;
systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
dbgprintf(" Year: %d\n Month: %d\n Day of week: %d\n"
- " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n"
- " Milliseconds: %d\n",
- systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay,
- systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds);
+ " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n"
+ " Milliseconds: %d\n",
+ systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay,
+ systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds);
}
-int WINAPI expGetSystemTime(SYSTEMTIME* systime)
+static int WINAPI expGetSystemTime(SYSTEMTIME* systime)
{
time_t local_time;
struct tm *local_tm;
@@ -2470,39 +2655,48 @@ int WINAPI expGetSystemTime(SYSTEMTIME* systime)
systime->wSecond = local_tm->tm_sec;
systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
dbgprintf(" Year: %d\n Month: %d\n Day of week: %d\n"
- " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n"
- " Milliseconds: %d\n",
- systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay,
- systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds);
+ " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n"
+ " 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)
+static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
{
char *p;
-// printf("%s %x %x\n", name, field, size);
+ // printf("%s %x %x\n", name, field, size);
if(field)field[0]=0;
-/*
- p = getenv(name);
- if (p) strncpy(field,p,size);
-*/
+ /*
+ p = getenv(name);
+ if (p) strncpy(field,p,size);
+ */
if (strcmp(name,"__MSVCRT_HEAP_SELECT")==0)
- strcpy(field,"__GLOBAL_HEAP_SELECTED,1");
+ strcpy(field,"__GLOBAL_HEAP_SELECTED,1");
dbgprintf("GetEnvironmentVariableA(0x%x='%s', 0x%x, %d) => %d\n", name, name, field, size, strlen(field));
return strlen(field);
}
-void* WINAPI expCoTaskMemAlloc(ULONG cb)
+static void* WINAPI expCoTaskMemAlloc(ULONG cb)
{
return my_mreq(cb, 0);
}
-void WINAPI expCoTaskMemFree(void* cb)
+static void WINAPI expCoTaskMemFree(void* cb)
{
my_release(cb);
}
-void* CoTaskMemAlloc(ULONG cb){return expCoTaskMemAlloc(cb);}
-void CoTaskMemFree(void* cb){expCoTaskMemFree(cb);}
+
+
+
+void* CoTaskMemAlloc(unsigned long cb)
+{
+ return expCoTaskMemAlloc(cb);
+}
+void CoTaskMemFree(void* cb)
+{
+ expCoTaskMemFree(cb);
+}
struct COM_OBJECT_INFO
{
@@ -2543,7 +2737,7 @@ int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0
&& com_object_table[i].GetClassObject == gcs)
{
- found++;
+ found++;
}
i++;
}
@@ -2552,58 +2746,57 @@ int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs)
if (--com_object_size == 0)
{
free(com_object_table);
- com_object_table = 0;
+ 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,
- {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
+GUID IID_IUnknown =
+{
+ 0x00000000, 0x0000, 0x0000,
+ {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
+};
+GUID IID_IClassFactory =
+{
+ 0x00000001, 0x0000, 0x0000,
+ {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
+};
-long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv)
+static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
+ long dwClsContext, GUID* riid, void** ppv)
{
int i;
struct COM_OBJECT_INFO* ci=0;
for(i=0; i<com_object_size; i++)
if(!memcmp(rclsid, &com_object_table[i].clsid, sizeof(GUID)))
ci=&com_object_table[i];
- if(!ci)return 0x80040154;
+ if(!ci)return REGDB_E_CLASSNOTREG;
// in 'real' world we should mess with IClassFactory here
i=ci->GetClassObject(rclsid, riid, ppv);
return i;
}
long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv)
+ long dwClsContext, GUID* riid, void** ppv)
{
return expCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}
-int WINAPI
- expIsRectEmpty(
-CONST RECT *lprc)
+static int WINAPI expIsRectEmpty(CONST RECT *lprc)
{
- dbgprintf("IsRectEmpty(0x%x)");
- if((!lprc) || (lprc->right==lprc->left) || (lprc->top==lprc->bottom))
- {
- dbgprintf(" => TRUE\n");
- return TRUE;
- }
- dbgprintf(" => FALSE\n");
- return FALSE;
+ int r = (!lprc || (lprc->right == lprc->left) || (lprc->top == lprc->bottom));
+ dbgprintf("IsRectEmpty(%p) => %s\n", lprc, (r) ? "TRUE" : "FALSE");
+ return r;
}
-int _adjust_fdiv=0; //what's this?
+static int _adjust_fdiv=0; //what's this? - used to adjust division
-unsigned int WINAPI expGetTempPathA(unsigned int len, char* path)
+static unsigned int WINAPI expGetTempPathA(unsigned int len, char* path)
{
dbgprintf("GetTempPathA(%d, 0x%x)", len, path);
if(len<5)
@@ -2616,45 +2809,45 @@ unsigned int WINAPI expGetTempPathA(unsigned int len, char* path)
return 5;
}
/*
-FYI:
-typedef struct
-{
- DWORD dwFileAttributes;
- FILETIME ftCreationTime;
- FILETIME ftLastAccessTime;
- FILETIME ftLastWriteTime;
- DWORD nFileSizeHigh;
- DWORD nFileSizeLow;
- DWORD dwReserved0;
- DWORD dwReserved1;
- CHAR cFileName[260];
- CHAR cAlternateFileName[14];
-} WIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
-*/
-
-HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd)
+ FYI:
+ typedef struct
+ {
+ DWORD dwFileAttributes;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ FILETIME ftLastWriteTime;
+ DWORD nFileSizeHigh;
+ DWORD nFileSizeLow;
+ DWORD dwReserved0;
+ DWORD dwReserved1;
+ CHAR cFileName[260];
+ CHAR cAlternateFileName[14];
+ } WIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
+ */
+
+static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd)
{
dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => 0\n", s, s, lpfd);
strcpy(lpfd->cFileName, "msms001.vwp");
strcpy(lpfd->cAlternateFileName, "msms001.vwp");
return (HANDLE)0;
}
-WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p)
+static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p)
{
dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, p);
return 0;
}
-WIN_BOOL WINAPI expFindClose(HANDLE h)
+static WIN_BOOL WINAPI expFindClose(HANDLE h)
{
dbgprintf("FindClose(0x%x) => 0\n", h);
return 0;
}
-UINT WINAPI expSetErrorMode(UINT i)
+static UINT WINAPI expSetErrorMode(UINT i)
{
dbgprintf("SetErrorMode(%d) => 0\n", i);
return 0;
}
-UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c)
+static UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c)
{
char windir[]="c:\\windows";
int result;
@@ -2664,18 +2857,18 @@ UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c)
return result;
}
-WIN_BOOL WINAPI expDeleteFileA(LPCSTR s)
+static WIN_BOOL WINAPI expDeleteFileA(LPCSTR s)
{
dbgprintf("DeleteFileA(0x%x='%s') => 0\n", s, s);
return 0;
}
-WIN_BOOL WINAPI expFileTimeToLocalFileTime(const FILETIME* cpf, LPFILETIME pf)
+static WIN_BOOL WINAPI expFileTimeToLocalFileTime(const FILETIME* cpf, LPFILETIME pf)
{
dbgprintf("FileTimeToLocalFileTime(0x%x, 0x%x) => 0\n", cpf, pf);
return 0;
}
-UINT WINAPI expGetTempFileNameA(LPCSTR cs1,LPCSTR cs2,UINT i,LPSTR ps)
+static UINT WINAPI expGetTempFileNameA(LPCSTR cs1,LPCSTR cs2,UINT i,LPSTR ps)
{
char mask[16]="/tmp/AP_XXXXXX";
int result;
@@ -2695,13 +2888,14 @@ UINT WINAPI expGetTempFileNameA(LPCSTR cs1,LPCSTR cs2,UINT i,LPSTR ps)
// They try to open APmpeg4v1.apl with it.
// DLL will close opened file with CloseHandle().
//
-HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
- LPSECURITY_ATTRIBUTES p1, DWORD i3,DWORD i4,HANDLE i5)
+static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
+ LPSECURITY_ATTRIBUTES p1, DWORD i3,DWORD i4,HANDLE i5)
{
dbgprintf("CreateFileA(0x%x='%s', %d, %d, 0x%x, %d, %d, 0x%x)\n", cs1, cs1, i1,
- i2, p1, i3, i4, i5);
+ i2, p1, i3, i4, i5);
if((!cs1) || (strlen(cs1)<2))return -1;
- if(strncmp(cs1, "AP", 2))
+
+ if(strncmp(cs1, "AP", 2) == 0)
{
int result;
char* tmp=(char*)malloc(strlen(win32_def_path)+50);
@@ -2711,16 +2905,42 @@ HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
result=open(tmp, O_RDONLY);
free(tmp);
return result;
- };
+ }
+ if (strstr(cs1, "vp3"))
+ {
+ int r;
+ int flg = 0;
+ char* tmp=(char*)malloc(20 + strlen(cs1));
+ strcpy(tmp, "/tmp/");
+ strcat(tmp, cs1);
+ r = 4;
+ while (tmp[r])
+ {
+ if (tmp[r] == ':' || tmp[r] == '\\')
+ tmp[r] = '_';
+ r++;
+ }
+ if (GENERIC_READ & i1)
+ flg |= O_RDONLY;
+ else if (GENERIC_WRITE & i1)
+ {
+ flg |= O_WRONLY;
+ printf("Warning: openning filename %s %d (flags; 0x%x) for write\n", tmp, r, flg);
+ }
+ r=open(tmp, flg);
+ free(tmp);
+ return r;
+ }
+
return atoi(cs1+2);
}
static char sysdir[]=".";
-LPCSTR WINAPI expGetSystemDirectoryA()
+static LPCSTR WINAPI expGetSystemDirectoryA()
{
dbgprintf("GetSystemDirectoryA() => 0x%x='%s'\n", sysdir, sysdir);
return sysdir;
}
-WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused)
+static WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused)
{
int result;
dbgprintf("ReadFile(%d, 0x%x, %d -> 0x%x)\n", h, pv, size, rd);
@@ -2730,7 +2950,7 @@ WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPE
return 1;
}
-WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LPOVERLAPPED unused)
+static WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LPOVERLAPPED unused)
{
int result;
dbgprintf("WriteFile(%d, 0x%x, %d -> 0x%x)\n", h, pv, size, wr);
@@ -2740,11 +2960,11 @@ WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LPOVERLAP
if(!result)return 0;
return 1;
}
-DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence)
+static DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence)
{
int wh;
dbgprintf("SetFilePointer(%d, %d, 0x%x, %d)\n", h, val, ext, whence);
-//why would DLL want temporary file with >2Gb size?
+ //why would DLL want temporary file with >2Gb size?
switch(whence)
{
case FILE_BEGIN:
@@ -2759,40 +2979,37 @@ DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence)
return lseek(h, val, wh);
}
-HDRVR WINAPI expOpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName,
- LPARAM lParam2)
+static HDRVR WINAPI expOpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName,
+ LPARAM lParam2)
{
dbgprintf("OpenDriverA(0x%x='%s', 0x%x='%s', 0x%x) => -1\n", szDriverName, szDriverName, szSectionName, szSectionName, lParam2);
return -1;
}
-HDRVR WINAPI expOpenDriver(LPCSTR szDriverName, LPCSTR szSectionName,
- LPARAM lParam2)
+static HDRVR WINAPI expOpenDriver(LPCSTR szDriverName, LPCSTR szSectionName,
+ LPARAM lParam2)
{
dbgprintf("OpenDriver(0x%x='%s', 0x%x='%s', 0x%x) => -1\n", szDriverName, szDriverName, szSectionName, szSectionName, lParam2);
return -1;
}
-WIN_BOOL
- WINAPI
- expGetProcessAffinityMask(
- HANDLE hProcess,
- LPDWORD lpProcessAffinityMask,
- LPDWORD lpSystemAffinityMask
- )
+static WIN_BOOL WINAPI expGetProcessAffinityMask(HANDLE hProcess,
+ LPDWORD lpProcessAffinityMask,
+ LPDWORD lpSystemAffinityMask)
{
dbgprintf("GetProcessAffinityMask(0x%x, 0x%x, 0x%x) => 1\n",
- hProcess, lpProcessAffinityMask, lpSystemAffinityMask);
+ hProcess, lpProcessAffinityMask, lpSystemAffinityMask);
if(lpProcessAffinityMask)*lpProcessAffinityMask=1;
if(lpSystemAffinityMask)*lpSystemAffinityMask=1;
return 1;
}
-int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator)
+static int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator)
{
static const long long max_int=0x7FFFFFFFLL;
static const long long min_int=-0x80000000LL;
long long tmp=(long long)nNumber*(long long)nNumerator;
+ dbgprintf("expMulDiv %d * %d / %d\n", nNumber, nNumerator, nDenominator);
if(!nDenominator)return 1;
tmp/=nDenominator;
if(tmp<min_int) return 1;
@@ -2800,37 +3017,37 @@ int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator)
return (int)tmp;
}
-LONG WINAPI explstrcmpiA(const char* str1, const char* str2)
+static LONG WINAPI explstrcmpiA(const char* str1, const char* str2)
{
LONG result=strcasecmp(str1, str2);
dbgprintf("strcmpi(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
return result;
}
-LONG WINAPI explstrlenA(const char* str1)
+static LONG WINAPI explstrlenA(const char* str1)
{
LONG result=strlen(str1);
- dbgprintf("strlen(0x%x='%s') => %d\n", str1, str1, result);
+ dbgprintf("strlen(0x%x='%.50s') => %d\n", str1, str1, result);
return result;
}
-LONG WINAPI explstrcpyA(char* str1, const char* str2)
+static LONG WINAPI explstrcpyA(char* str1, const char* str2)
{
int result= (int) strcpy(str1, str2);
- dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result);
+ dbgprintf("strcpy(0x%.50x, 0x%.50x='%.50s') => %d\n", str1, str2, str2, result);
return result;
}
-LONG WINAPI explstrcpynA(char* str1, const char* str2,int len)
+static LONG WINAPI explstrcpynA(char* str1, const char* str2,int len)
{
int result;
if (strlen(str2)>len)
- result = (int) strncpy(str1, str2,len);
+ result = (int) strncpy(str1, str2,len);
else
- result = (int) strcpy(str1,str2);
+ 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)
+static 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);
@@ -2838,20 +3055,440 @@ LONG WINAPI explstrcatA(char* str1, const char* str2)
}
-LONG WINAPI expInterlockedExchange(long *dest, long l)
+static LONG WINAPI expInterlockedExchange(long *dest, long l)
{
- long retval;
- retval = *dest;
- *dest = l;
- return retval;
+ long retval = *dest;
+ *dest = l;
+ return retval;
}
-void WINAPI expInitCommonControls(void)
+static void WINAPI expInitCommonControls(void)
{
printf("InitCommonControls called!\n");
return;
}
+/* alex: implement this call! needed for 3ivx */
+static HRESULT WINAPI expCoCreateFreeThreadedMarshaler(void *pUnkOuter, void **ppUnkInner)
+{
+ printf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n",
+ pUnkOuter, ppUnkInner);
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+
+static int WINAPI expDuplicateHandle(HANDLE hSourceProcessHandle, // handle to source process
+ HANDLE hSourceHandle, // handle to duplicate
+ HANDLE hTargetProcessHandle, // handle to target process
+ HANDLE* lpTargetHandle, // duplicate handle
+ DWORD dwDesiredAccess, // requested access
+ int bInheritHandle, // handle inheritance option
+ DWORD dwOptions // optional actions
+ )
+{
+ dbgprintf("DuplicateHandle(%p, %p, %p, %p, 0x%x, %d, %d) called\n",
+ hSourceProcessHandle, hSourceHandle, hTargetProcessHandle,
+ lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions);
+ *lpTargetHandle = hSourceHandle;
+ return 1;
+}
+
+// required by PIM1 codec (used by win98 PCTV Studio capture sw)
+static HRESULT WINAPI expCoInitialize(
+ LPVOID lpReserved /* [in] pointer to win32 malloc interface
+ (obsolete, should be NULL) */
+ )
+{
+ /*
+ * Just delegate to the newer method.
+ */
+ return 0; //CoInitializeEx(lpReserved, COINIT_APARTMENTTHREADED);
+}
+
+static DWORD WINAPI expSetThreadAffinityMask
+(
+ HANDLE hThread,
+ DWORD dwThreadAffinityMask
+){
+ return 0;
+};
+
+/*
+ * no WINAPI functions - CDECL
+ */
+static void* expmalloc(int size)
+{
+ //printf("malloc");
+ // return malloc(size);
+ void* result=my_mreq(size,0);
+ dbgprintf("malloc(0x%x) => 0x%x\n", size,result);
+ if(result==0)
+ printf("WARNING: malloc() failed\n");
+ return result;
+}
+static void expfree(void* mem)
+{
+ // return free(mem);
+ dbgprintf("free(%p)\n", mem);
+ my_release(mem);
+}
+static void* expnew(int size)
+{
+ // printf("NEW:: Call from address %08x\n STACK DUMP:\n", *(-1+(int*)&size));
+ // printf("%08x %08x %08x %08x\n",
+ // size, *(1+(int*)&size),
+ // *(2+(int*)&size),*(3+(int*)&size));
+ void* result;
+ assert(size >= 0);
+
+ result=my_mreq(size,0);
+ dbgprintf("new(%d) => %p\n", size, result);
+ if (result==0)
+ printf("WARNING: new() failed\n");
+ return result;
+
+}
+static int expdelete(void* memory)
+{
+ dbgprintf("delete(%p)\n", memory);
+ my_release(memory);
+ return 0;
+}
+static int exp_initterm(int v1, int v2)
+{
+ dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2);
+ return 0;
+}
+
+static int expwsprintfA(char* string, char* format, ...)
+{
+ va_list va;
+ int result;
+ va_start(va, format);
+ result = vsprintf(string, format, va);
+ dbgprintf("wsprintfA(0x%x, '%s', ...) => %d\n", string, format, result);
+ va_end(va);
+ return result;
+}
+
+static int expsprintf(char* str, const char* format, ...)
+{
+ va_list args;
+ int r;
+ dbgprintf("sprintf(%s, %s)\n", str, format);
+ va_start(args, format);
+ r = vsprintf(str, format, args);
+ va_end(args);
+ return r;
+}
+static int expsscanf(const char* str, const char* format, ...)
+{
+ va_list args;
+ int r;
+ dbgprintf("sscanf(%s, %s)\n", str, format);
+ va_start(args, format);
+ r = vsscanf(str, format, args);
+ va_end(args);
+ return r;
+}
+static void* expfopen(const char* path, const char* mode)
+{
+ printf("fopen: \"%s\" mode:%s\n", path, mode);
+ //return fopen(path, mode);
+ return fdopen(0, mode); // everything on screen
+}
+static int expfprintf(void* stream, const char* format, ...)
+{
+ va_list args;
+ int r = 0;
+ dbgprintf("fprintf(%p, %s, ...)\n", stream, format);
+#if 1
+ va_start(args, format);
+ r = vfprintf((FILE*) stream, format, args);
+ va_end(args);
+#endif
+ return r;
+}
+
+static int expprintf(const char* format, ...)
+{
+ va_list args;
+ int r;
+ dbgprintf("printf(%s, ...)\n", format);
+ va_start(args, format);
+ r = vprintf(format, args);
+ va_end(args);
+ return r;
+}
+
+static char* expgetenv(const char* varname)
+{
+ char* v = getenv(varname);
+ dbgprintf("getenv(%s) => %s\n", varname, v);
+ return v;
+}
+
+static void* expwcscpy(WCHAR* dst, const WCHAR* src)
+{
+ WCHAR* p = dst;
+ while ((*p++ = *src++))
+ ;
+ return dst;
+}
+
+static char* expstrrchr(char* string, int value)
+{
+ char* result=strrchr(string, value);
+ if(result)
+ dbgprintf("strrchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result);
+ else
+ dbgprintf("strrchr(0x%x='%s', %d) => 0", string, string, value);
+ return result;
+}
+
+static char* expstrchr(char* string, int value)
+{
+ char* result=strchr(string, value);
+ if(result)
+ dbgprintf("strchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result);
+ else
+ dbgprintf("strchr(0x%x='%s', %d) => 0", string, string, value);
+ return result;
+}
+static int expstrlen(char* str)
+{
+ int result=strlen(str);
+ dbgprintf("strlen(0x%x='%s') => %d\n", str, str, result);
+ return result;
+}
+static char* expstrcpy(char* str1, const char* str2)
+{
+ char* result= strcpy(str1, str2);
+ dbgprintf("strcpy(0x%x, 0x%x='%s') => %p\n", str1, str2, str2, result);
+ return result;
+}
+static int expstrcmp(const char* str1, const char* str2)
+{
+ int result=strcmp(str1, str2);
+ dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
+ return result;
+}
+static int expstrncmp(const char* str1, const char* str2,int x)
+{
+ int result=strncmp(str1, str2,x);
+ dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
+ return result;
+}
+static char* expstrcat(char* str1, const char* str2)
+{
+ char* result = strcat(str1, str2);
+ dbgprintf("strcat(0x%x='%s', 0x%x='%s') => %p\n", str1, str1, str2, str2, result);
+ return result;
+}
+static char* exp_strdup(const char* str1)
+{
+ int l = strlen(str1);
+ char* result = my_mreq(l + 1,0);
+ if (result)
+ strcpy(result, str1);
+ dbgprintf("_strdup(0x%x='%s') => %p\n", str1, str1, result);
+ return result;
+}
+static int expisalnum(int c)
+{
+ int result= (int) isalnum(c);
+ dbgprintf("isalnum(0x%x='%c' => %d\n", c, c, result);
+ return result;
+}
+static int expisspace(int c)
+{
+ int result= (int) isspace(c);
+ dbgprintf("isspace(0x%x='%c' => %d\n", c, c, result);
+ return result;
+}
+static int expisalpha(int c)
+{
+ int result= (int) isalpha(c);
+ dbgprintf("isalpha(0x%x='%c' => %d\n", c, c, result);
+ return result;
+}
+static int expisdigit(int c)
+{
+ int result= (int) isdigit(c);
+ dbgprintf("isdigit(0x%x='%c' => %d\n", c, c, result);
+ return result;
+}
+static void* expmemmove(void* dest, void* src, int n)
+{
+ void* result = memmove(dest, src, n);
+ dbgprintf("memmove(0x%x, 0x%x, %d) => %p\n", dest, src, n, result);
+ return result;
+}
+static int expmemcmp(void* dest, void* src, int n)
+{
+ int result = memcmp(dest, src, n);
+ dbgprintf("memcmp(0x%x, 0x%x, %d) => %d\n", dest, src, n, result);
+ return result;
+}
+static void* expmemcpy(void* dest, void* src, int n)
+{
+ void *result = memcpy(dest, src, n);
+ dbgprintf("memcpy(0x%x, 0x%x, %d) => %p\n", dest, src, n, result);
+ return result;
+}
+static void* expmemset(void* dest, int c, size_t n)
+{
+ void *result = memset(dest, c, n);
+ dbgprintf("memset(0x%x, %d, %d) => %p\n", dest, c, n, result);
+ return result;
+}
+static time_t exptime(time_t* t)
+{
+ time_t result = time(t);
+ dbgprintf("time(0x%x) => %d\n", t, result);
+ return result;
+}
+
+static int exprand(void)
+{
+ return rand();
+}
+
+static void expsrand(int seed)
+{
+ srand(seed);
+}
+
+#if 1
+
+// prefered compilation with -O2 -ffast-math !
+
+static double explog10(double x)
+{
+ /*printf("Log10 %f => %f 0x%Lx\n", x, log10(x), *((int64_t*)&x));*/
+ return log10(x);
+}
+
+static double expcos(double x)
+{
+ /*printf("Cos %f => %f 0x%Lx\n", x, cos(x), *((int64_t*)&x));*/
+ return cos(x);
+}
+
+/* doens't work */
+static long exp_ftol_wrong(double x)
+{
+ return (long) x;
+}
+
+#else
+
+static void explog10(void)
+{
+ __asm__ __volatile__
+ (
+ "fldl 8(%esp) \n\t"
+ "fldln2 \n\t"
+ "fxch %st(1) \n\t"
+ "fyl2x \n\t"
+ );
+}
+
+static void expcos(void)
+{
+ __asm__ __volatile__
+ (
+ "fldl 8(%esp) \n\t"
+ "fcos \n\t"
+ );
+}
+
+#endif
+
+// this seem to be the only how to make this function working properly
+// ok - I've spent tremendous amount of time (many many many hours
+// of debuging fixing & testing - it's almost unimaginable - kabi
+
+// _ftol - operated on the float value which is already on the FPU stack
+
+static void exp_ftol(void)
+{
+ __asm__ __volatile__
+ (
+ "sub $12, %esp \n\t"
+ "fstcw -2(%ebp) \n\t"
+ "wait \n\t"
+ "movw -2(%ebp), %ax \n\t"
+ "orb $0x0C, %ah \n\t"
+ "movw %ax, -4(%ebp) \n\t"
+ "fldcw -4(%ebp) \n\t"
+ "fistpl -12(%ebp) \n\t"
+ "fldcw -2(%ebp) \n\t"
+ "movl -12(%ebp), %eax \n\t"
+ //Note: gcc 3.03 does not do the following op if it
+ // knows that ebp=esp
+ "movl %ebp, %esp \n\t"
+ );
+}
+
+static double exppow(double x, double y)
+{
+ /*printf("Pow %f %f 0x%Lx 0x%Lx => %f\n", x, y, *((int64_t*)&x), *((int64_t*)&y), pow(x, y));*/
+ return pow(x, y);
+}
+
+
+
+static int exp_stricmp(const char* s1, const char* s2)
+{
+ return strcasecmp(s1, s2);
+}
+
+/* from declaration taken from Wine sources - this fountion seems to be
+ * undocumented in any M$ doc */
+static int exp_setjmp3(void* jmpbuf, int x)
+{
+ //dbgprintf("!!!!UNIMPLEMENTED: setjmp3(%p, %d) => 0\n", jmpbuf, x);
+ //return 0;
+ __asm__ __volatile__
+ (
+ //"mov 4(%%esp), %%edx \n\t"
+ "mov (%%esp), %%eax \n\t"
+ "mov %%eax, (%%edx) \n\t" // store ebp
+
+ //"mov %%ebp, (%%edx) \n\t"
+ "mov %%ebx, 4(%%edx) \n\t"
+ "mov %%edi, 8(%%edx) \n\t"
+ "mov %%esi, 12(%%edx) \n\t"
+ "mov %%esp, 16(%%edx) \n\t"
+
+ "mov 4(%%esp), %%eax \n\t"
+ "mov %%eax, 20(%%edx) \n\t"
+
+ "movl $0x56433230, 32(%%edx) \n\t" // VC20 ??
+ "movl $0, 36(%%edx) \n\t"
+ : // output
+ : "d"(jmpbuf) // input
+ );
+#if 1
+ __asm__ __volatile__
+ (
+ "mov %%fs:0, %%eax \n\t" // unsure
+ "mov %%eax, 24(%%edx) \n\t"
+ "cmp $0xffffffff, %%eax \n\t"
+ "jnz l1 \n\t"
+ "mov %%eax, 28(%%edx) \n\t"
+ "l1: \n\t"
+ :
+ :
+ );
+#endif
+
+ return 0;
+}
+
+
+
struct exports
{
char name[64];
@@ -2865,241 +3502,317 @@ struct libs
struct exports* exps;
};
-#define FF(X,Y) {#X, Y, (void*)exp##X},
-
-struct exports exp_kernel32[]={
-FF(IsBadWritePtr, 357)
-FF(IsBadReadPtr, 354)
-FF(IsBadStringPtrW, -1)
-FF(DisableThreadLibraryCalls, -1)
-FF(CreateThread, -1)
-FF(CreateEventA, -1)
-FF(SetEvent, -1)
-FF(ResetEvent, -1)
-FF(WaitForSingleObject, -1)
-FF(GetSystemInfo, -1)
-FF(GetVersion, 332)
-FF(HeapCreate, 461)
-FF(HeapAlloc, -1)
-FF(HeapDestroy, -1)
-FF(HeapFree, -1)
-FF(HeapSize, -1)
-FF(HeapReAlloc,-1)
-FF(GetProcessHeap, -1)
-FF(VirtualAlloc, -1)
-FF(VirtualFree, -1)
-FF(InitializeCriticalSection, -1)
-FF(EnterCriticalSection, -1)
-FF(LeaveCriticalSection, -1)
-FF(DeleteCriticalSection, -1)
-FF(TlsAlloc, -1)
-FF(TlsFree, -1)
-FF(TlsGetValue, -1)
-FF(TlsSetValue, -1)
-FF(GetCurrentThreadId, -1)
-FF(GetCurrentProcess, -1)
-FF(LocalAlloc, -1)
-FF(LocalReAlloc,-1)
-FF(LocalLock, -1)
-FF(GlobalAlloc, -1)
-FF(GlobalReAlloc, -1)
-FF(GlobalLock, -1)
-FF(MultiByteToWideChar, 427)
-FF(WideCharToMultiByte, -1)
-FF(GetVersionExA, -1)
-FF(CreateSemaphoreA, -1)
-FF(QueryPerformanceCounter, -1)
-FF(QueryPerformanceFrequency, -1)
-FF(LocalHandle, -1)
-FF(LocalUnlock, -1)
-FF(LocalFree, -1)
-FF(GlobalHandle, -1)
-FF(GlobalUnlock, -1)
-FF(GlobalFree, -1)
-FF(LoadResource, -1)
-FF(ReleaseSemaphore, -1)
-FF(FindResourceA, -1)
-FF(LockResource, -1)
-FF(FreeResource, -1)
-FF(SizeofResource, -1)
-FF(CloseHandle, -1)
-FF(GetCommandLineA, -1)
-FF(GetEnvironmentStringsW, -1)
-FF(FreeEnvironmentStringsW, -1)
-FF(FreeEnvironmentStringsA, -1)
-FF(GetEnvironmentStrings, -1)
-FF(GetStartupInfoA, -1)
-FF(GetStdHandle, -1)
-FF(GetFileType, -1)
-FF(SetHandleCount, -1)
-FF(GetACP, -1)
-FF(GetModuleFileNameA, -1)
-FF(SetUnhandledExceptionFilter, -1)
-FF(LoadLibraryA, -1)
-FF(GetProcAddress, -1)
-FF(FreeLibrary, -1)
-FF(CreateFileMappingA, -1)
-FF(OpenFileMappingA, -1)
-FF(MapViewOfFile, -1)
-FF(UnmapViewOfFile, -1)
-FF(Sleep, -1)
-FF(GetModuleHandleA, -1)
-FF(GetProfileIntA, -1)
-FF(GetPrivateProfileIntA, -1)
-FF(GetPrivateProfileStringA, -1)
-FF(WritePrivateProfileStringA, -1)
-FF(GetLastError, -1)
-FF(SetLastError, -1)
-FF(InterlockedIncrement, -1)
-FF(InterlockedDecrement, -1)
-FF(GetTimeZoneInformation, -1)
-FF(OutputDebugStringA, -1)
-FF(GetLocalTime, -1)
-FF(GetSystemTime, -1)
-FF(GetEnvironmentVariableA, -1)
-FF(RtlZeroMemory,-1)
-FF(RtlMoveMemory,-1)
-FF(RtlFillMemory,-1)
-FF(GetTempPathA,-1)
-FF(FindFirstFileA,-1)
-FF(FindNextFileA,-1)
-FF(FindClose,-1)
-FF(FileTimeToLocalFileTime,-1)
-FF(DeleteFileA,-1)
-FF(ReadFile,-1)
-FF(WriteFile,-1)
-FF(SetFilePointer,-1)
-FF(GetTempFileNameA,-1)
-FF(CreateFileA,-1)
-FF(GetSystemDirectoryA,-1)
-FF(GetWindowsDirectoryA,-1)
-FF(SetErrorMode, -1)
-FF(IsProcessorFeaturePresent, -1)
-FF(GetProcessAffinityMask, -1)
-FF(InterlockedExchange, -1)
-FF(MulDiv, -1)
-FF(lstrcmpiA, -1)
-FF(lstrlenA, -1)
-FF(lstrcpyA, -1)
-FF(lstrcatA, -1)
-FF(lstrcpynA,-1)
-FF(GetProcessVersion,-1)
-FF(GetCurrentThread,-1)
-FF(GetOEMCP,-1)
-FF(GetCPInfo,-1)
+#define FF(X,Y) \
+ {#X, Y, (void*)exp##X},
+
+struct exports exp_kernel32[]=
+{
+ FF(IsBadWritePtr, 357)
+ FF(IsBadReadPtr, 354)
+ FF(IsBadStringPtrW, -1)
+ FF(IsBadStringPtrA, -1)
+ FF(DisableThreadLibraryCalls, -1)
+ FF(CreateThread, -1)
+ FF(CreateEventA, -1)
+ FF(SetEvent, -1)
+ FF(ResetEvent, -1)
+ FF(WaitForSingleObject, -1)
+ FF(GetSystemInfo, -1)
+ FF(GetVersion, 332)
+ FF(HeapCreate, 461)
+ FF(HeapAlloc, -1)
+ FF(HeapDestroy, -1)
+ FF(HeapFree, -1)
+ FF(HeapSize, -1)
+ FF(HeapReAlloc,-1)
+ FF(GetProcessHeap, -1)
+ FF(VirtualAlloc, -1)
+ FF(VirtualFree, -1)
+ FF(InitializeCriticalSection, -1)
+ FF(EnterCriticalSection, -1)
+ FF(LeaveCriticalSection, -1)
+ FF(DeleteCriticalSection, -1)
+ FF(TlsAlloc, -1)
+ FF(TlsFree, -1)
+ FF(TlsGetValue, -1)
+ FF(TlsSetValue, -1)
+ FF(GetCurrentThreadId, -1)
+ FF(GetCurrentProcess, -1)
+ FF(LocalAlloc, -1)
+ FF(LocalReAlloc,-1)
+ FF(LocalLock, -1)
+ FF(GlobalAlloc, -1)
+ FF(GlobalReAlloc, -1)
+ FF(GlobalLock, -1)
+ FF(GlobalSize, -1)
+ FF(MultiByteToWideChar, 427)
+ FF(WideCharToMultiByte, -1)
+ FF(GetVersionExA, -1)
+ FF(CreateSemaphoreA, -1)
+ FF(QueryPerformanceCounter, -1)
+ FF(QueryPerformanceFrequency, -1)
+ FF(LocalHandle, -1)
+ FF(LocalUnlock, -1)
+ FF(LocalFree, -1)
+ FF(GlobalHandle, -1)
+ FF(GlobalUnlock, -1)
+ FF(GlobalFree, -1)
+ FF(LoadResource, -1)
+ FF(ReleaseSemaphore, -1)
+ FF(FindResourceA, -1)
+ FF(LockResource, -1)
+ FF(FreeResource, -1)
+ FF(SizeofResource, -1)
+ FF(CloseHandle, -1)
+ FF(GetCommandLineA, -1)
+ FF(GetEnvironmentStringsW, -1)
+ FF(FreeEnvironmentStringsW, -1)
+ FF(FreeEnvironmentStringsA, -1)
+ FF(GetEnvironmentStrings, -1)
+ FF(GetStartupInfoA, -1)
+ FF(GetStdHandle, -1)
+ FF(GetFileType, -1)
+ FF(SetHandleCount, -1)
+ FF(GetACP, -1)
+ FF(GetModuleFileNameA, -1)
+ FF(SetUnhandledExceptionFilter, -1)
+ FF(LoadLibraryA, -1)
+ FF(GetProcAddress, -1)
+ FF(FreeLibrary, -1)
+ FF(CreateFileMappingA, -1)
+ FF(OpenFileMappingA, -1)
+ FF(MapViewOfFile, -1)
+ FF(UnmapViewOfFile, -1)
+ FF(Sleep, -1)
+ FF(GetModuleHandleA, -1)
+ FF(GetProfileIntA, -1)
+ FF(GetPrivateProfileIntA, -1)
+ FF(GetPrivateProfileStringA, -1)
+ FF(WritePrivateProfileStringA, -1)
+ FF(GetLastError, -1)
+ FF(SetLastError, -1)
+ FF(InterlockedIncrement, -1)
+ FF(InterlockedDecrement, -1)
+ FF(GetTimeZoneInformation, -1)
+ FF(OutputDebugStringA, -1)
+ FF(GetLocalTime, -1)
+ FF(GetSystemTime, -1)
+ FF(GetEnvironmentVariableA, -1)
+ FF(RtlZeroMemory,-1)
+ FF(RtlMoveMemory,-1)
+ FF(RtlFillMemory,-1)
+ FF(GetTempPathA,-1)
+ FF(FindFirstFileA,-1)
+ FF(FindNextFileA,-1)
+ FF(FindClose,-1)
+ FF(FileTimeToLocalFileTime,-1)
+ FF(DeleteFileA,-1)
+ FF(ReadFile,-1)
+ FF(WriteFile,-1)
+ FF(SetFilePointer,-1)
+ FF(GetTempFileNameA,-1)
+ FF(CreateFileA,-1)
+ FF(GetSystemDirectoryA,-1)
+ FF(GetWindowsDirectoryA,-1)
+ FF(SetErrorMode, -1)
+ FF(IsProcessorFeaturePresent, -1)
+ FF(GetProcessAffinityMask, -1)
+ FF(InterlockedExchange, -1)
+ FF(MulDiv, -1)
+ FF(lstrcmpiA, -1)
+ FF(lstrlenA, -1)
+ FF(lstrcpyA, -1)
+ FF(lstrcatA, -1)
+ FF(lstrcpynA,-1)
+ FF(GetProcessVersion,-1)
+ FF(GetCurrentThread,-1)
+ FF(GetOEMCP,-1)
+ FF(GetCPInfo,-1)
+ FF(DuplicateHandle,-1)
+ FF(GetTickCount, -1)
+ FF(SetThreadAffinityMask,-1)
};
struct exports exp_msvcrt[]={
-FF(malloc, -1)
-FF(_initterm, -1)
-FF(free, -1)
-{"??3@YAXPAX@Z", -1, expdelete},
-{"??2@YAPAXI@Z", -1, expnew},
-{"_adjust_fdiv", -1, (void*)&_adjust_fdiv},
-FF(strrchr, -1)
-FF(strchr, -1)
-FF(strlen, -1)
-FF(strcpy, -1)
-FF(strcmp, -1)
-FF(strcat, -1)
-FF(isalnum, -1)
-FF(memmove, -1)
-FF(memcmp, -1)
-FF(time, -1)
-FF(_ftol,-1)
-FF(rand, -1)
-FF(log10, -1)
-FF(pow, -1)
-FF(cos, -1)
-FF(srand, -1)
-FF(sprintf,-1)
-FF(sscanf,-1)
-FF(fopen,-1)
-FF(fprintf,-1)
-FF(printf,-1)
+ FF(malloc, -1)
+ FF(_initterm, -1)
+ FF(free, -1)
+ {"??3@YAXPAX@Z", -1, expdelete},
+ {"??2@YAPAXI@Z", -1, expnew},
+ {"_adjust_fdiv", -1, (void*)&_adjust_fdiv},
+ FF(strrchr, -1)
+ FF(strchr, -1)
+ FF(strlen, -1)
+ FF(strcpy, -1)
+ FF(wcscpy, -1)
+ FF(strcmp, -1)
+ FF(strncmp, -1)
+ FF(strcat, -1)
+ FF(_stricmp,-1)
+ FF(_strdup,-1)
+ FF(_setjmp3,-1)
+ FF(isalnum, -1)
+ FF(isspace, -1)
+ FF(isalpha, -1)
+ FF(isdigit, -1)
+ FF(memmove, -1)
+ FF(memcmp, -1)
+ FF(memset, -1)
+ FF(memcpy, -1)
+ FF(time, -1)
+ FF(rand, -1)
+ FF(srand, -1)
+ FF(log10, -1)
+ FF(pow, -1)
+ FF(cos, -1)
+ FF(_ftol,-1)
+ FF(sprintf,-1)
+ FF(sscanf,-1)
+ FF(fopen,-1)
+ FF(fprintf,-1)
+ FF(printf,-1)
+ FF(getenv,-1)
};
struct exports exp_winmm[]={
-FF(GetDriverModuleHandle, -1)
-FF(timeGetTime, -1)
-FF(DefDriverProc, -1)
-FF(OpenDriverA, -1)
-FF(OpenDriver, -1)
+ FF(GetDriverModuleHandle, -1)
+ FF(timeGetTime, -1)
+ FF(DefDriverProc, -1)
+ FF(OpenDriverA, -1)
+ FF(OpenDriver, -1)
};
struct exports exp_user32[]={
-FF(LoadStringA, -1)
-FF(wsprintfA, -1)
-FF(GetDC, -1)
-FF(GetDesktopWindow, -1)
-FF(ReleaseDC, -1)
-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)
+ FF(LoadStringA, -1)
+ FF(wsprintfA, -1)
+ FF(GetDC, -1)
+ FF(GetDesktopWindow, -1)
+ FF(ReleaseDC, -1)
+ 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)
+ FF(GetWindowDC, -1)
+ FF(DrawTextA, -1)
};
struct exports exp_advapi32[]={
-FF(RegOpenKeyA, -1)
-FF(RegOpenKeyExA, -1)
-FF(RegCreateKeyExA, -1)
-FF(RegQueryValueExA, -1)
-FF(RegSetValueExA, -1)
-FF(RegCloseKey, -1)
-FF(RegEnumValueA, -1)
+ FF(RegCloseKey, -1)
+ FF(RegCreateKeyExA, -1)
+ FF(RegEnumKeyExA, -1)
+ FF(RegEnumValueA, -1)
+ FF(RegOpenKeyA, -1)
+ FF(RegOpenKeyExA, -1)
+ FF(RegQueryValueExA, -1)
+ FF(RegSetValueExA, -1)
};
struct exports exp_gdi32[]={
-FF(CreateCompatibleDC, -1)
-FF(GetDeviceCaps, -1)
-FF(DeleteDC, -1)
-FF(GetSystemPaletteEntries, -1)
+ FF(CreateCompatibleDC, -1)
+ FF(CreateFontA, -1)
+ FF(DeleteDC, -1)
+ FF(DeleteObject, -1)
+ FF(GetDeviceCaps, -1)
+ FF(GetSystemPaletteEntries, -1)
};
struct exports exp_version[]={
-FF(GetFileVersionInfoSizeA, -1)
+ FF(GetFileVersionInfoSizeA, -1)
};
struct exports exp_ole32[]={
-FF(CoTaskMemAlloc, -1)
-FF(CoTaskMemFree, -1)
-FF(CoCreateInstance, -1)
-FF(StringFromGUID2, -1)
+ FF(CoCreateFreeThreadedMarshaler,-1)
+ FF(CoCreateInstance, -1)
+ FF(CoInitialize, -1)
+ FF(CoTaskMemAlloc, -1)
+ FF(CoTaskMemFree, -1)
+ FF(StringFromGUID2, -1)
};
+// do we really need crtdll ???
+// msvcrt is the correct place probably...
struct exports exp_crtdll[]={
-FF(memcpy, -1)
-FF(wcscpy, -1)
+ FF(memcpy, -1)
+ FF(wcscpy, -1)
};
struct exports exp_comctl32[]={
-FF(StringFromGUID2, -1)
-FF(InitCommonControls, 17)
+ FF(StringFromGUID2, -1)
+ FF(InitCommonControls, 17)
};
-#define LL(X) {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
+struct exports exp_msdmo[]={
+ FF(memcpy, -1) // just test
+};
+
+#define LL(X) \
+ {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
struct libs libraries[]={
-LL(kernel32)
-LL(msvcrt)
-LL(winmm)
-LL(user32)
-LL(advapi32)
-LL(gdi32)
-LL(version)
-LL(ole32)
-LL(crtdll)
-LL(comctl32)
+ LL(kernel32)
+ LL(msvcrt)
+ LL(winmm)
+ LL(user32)
+ LL(advapi32)
+ LL(gdi32)
+ LL(version)
+ LL(ole32)
+ LL(crtdll)
+ LL(comctl32)
+ LL(msdmo)
};
+static char* called_unk = "Called unk_%s\n";
+static void ext_stubs(void)
+{
+ // expects:
+ // ax position index
+ // cx address of printf function
+ __asm__ __volatile__
+ (
+ "push %edx \n\t"
+ "movl $0, %eax \n\t"
+ "movl $0, %edx \n\t"
+ "shl $5,%eax \n\t" // ax * 32
+ "addl $export_names,%eax \n\t"
+ "pushl %eax \n\t"
+ "pushl called_unk \n\t"
+ "call *%edx \n\t" // printf (via dx)
+ "addl $8,%esp \n\t"
+ "xorl %eax,%eax \n\t"
+ "pop %edx \n\t"
+ );
+}
+
+//static void add_stub(int pos)
+
+extern int unk_exp1;
+static char extcode[20000];// place for 200 unresolved exports
+static int pos=0;
+
+static void* add_stub()
+{
+ char* answ = (char*)extcode+pos*0x30;
+#if 0
+ memcpy(answ, &unk_exp1, 0x64);
+ *(int*)(answ+9)=pos;
+ *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
+#endif
+ memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size
+ //answ[0] = 0xb8; // movl $0, eax (0xb8 0x00000000)
+ *((int*) (answ + 5)) = pos;
+ //answ[5] = 0xb9; // movl $0, edx (0xb9 0x00000000)
+ *((int*) (answ + 10)) = (int) printf;
+ pos++;
+ return (void*)answ;
+}
void* LookupExternal(const char* library, int ordinal)
{
- char* answ;
int i,j;
if(library==0)
{
printf("ERROR: library=0\n");
return (void*)ext_unknown;
}
-// printf("%x %x\n", &unk_exp1, &unk_exp2);
+ // printf("%x %x\n", &unk_exp1, &unk_exp2);
for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++)
{
@@ -3115,20 +3828,15 @@ void* LookupExternal(const char* library, int ordinal)
}
printf("External func %s:%d\n", library, ordinal);
if(pos>150)return 0;
- answ=(char*)extcode+pos*0x64;
- memcpy(answ, &unk_exp1, 0x64);
- *(int*)(answ+9)=pos;
- *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
sprintf(export_names[pos], "%s:%d", library, ordinal);
- pos++;
- return (void*)answ;
+ return add_stub(pos);
}
void* LookupExternalByName(const char* library, const char* name)
{
char* answ;
int i,j;
-// return (void*)ext_unknown;
+ // return (void*)ext_unknown;
if(library==0)
{
printf("ERROR: library=0\n");
@@ -3148,24 +3856,13 @@ void* LookupExternalByName(const char* library, const char* name)
{
if(strcmp(name, libraries[i].exps[j].name))
continue;
-// printf("Hit: 0x%08X\n", libraries[i].exps[j].func);
+ // printf("Hit: 0x%08X\n", libraries[i].exps[j].func);
return libraries[i].exps[j].func;
}
}
-// printf("%s %s\n", library, name);
- if(pos>150)return 0;
+ if(pos>150)return 0;// to many symbols
strcpy(export_names[pos], name);
- answ=(char*)extcode+pos*0x64;
- memcpy(answ, &unk_exp1, 0x64);
- *(int*)(answ+9)=pos;
- *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
- pos++;
- return (void*)answ;
-// memcpy(extcode, &unk_exp1, 0x64);
-// *(int*)(extcode+52)-=((int)extcode-(int)&unk_exp1);
-// return (void*)extcode;
-// printf("Unknown func %s:%s\n", library, name);
-// return (void*)ext_unknown;
+ return add_stub(pos);
}
void my_garbagecollection(void)
@@ -3173,13 +3870,16 @@ void my_garbagecollection(void)
#ifdef GARBAGE
int unfree = 0, unfreecnt = 0;
+ free_registry();
while (last_alloc)
{
alloc_header* mem = last_alloc + 1;
unfree += my_size(mem);
- unfreecnt++;
+ unfreecnt++;
my_release(mem);
}
printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt);
#endif
+ g_tls = NULL;
+ list = NULL;
}
diff --git a/src/libw32dll/wine/win32.h b/src/libw32dll/wine/win32.h
index 4ffe31050..246bdc149 100644
--- a/src/libw32dll/wine/win32.h
+++ b/src/libw32dll/wine/win32.h
@@ -3,16 +3,12 @@
#include <time.h>
-#include "windef.h"
-#include "winbase.h"
-#include "com.h"
+#include <wine/windef.h>
+#include <wine/winbase.h>
+#include <com.h>
-extern void* my_mreq(int size, int to_zero);
-extern int my_release(void* memory);
-extern void* my_realloc(void *memory,int size);
extern void my_garbagecollection(void);
-
typedef struct {
UINT uDriverSignature;
HINSTANCE hDriverModule;
@@ -26,215 +22,12 @@ typedef DRVR *LPDRVR;
typedef struct tls_s tls_t;
-extern int WINAPI ext_unknown(void);
-
-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 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,
- char bInitialState, const char* name);
-extern void* WINAPI expSetEvent(void* event);
-extern void* WINAPI expResetEvent(void* event);
-extern void* WINAPI expWaitForSingleObject(void* object, int duration);
-extern WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v);
-extern void WINAPI expGetSystemInfo(SYSTEM_INFO* si);
-extern long WINAPI expGetVersion(void);
-long WINAPI expGetVersionExA(OSVERSIONINFOA* c);
-extern HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size);
-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);
-extern int WINAPI expVirtualFree(void* v1, int v2, int v3);
-extern void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c);
-extern void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c);
-extern void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c);
-extern void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c);
-extern int WINAPI expGetCurrentThreadId(void);
-extern int WINAPI expGetCurrentProcess(void);
-extern void* WINAPI expTlsAlloc(void);
-extern int WINAPI expTlsSetValue(tls_t* index, void* value);
-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);
-extern int WINAPI expLoadStringA(long instance, long id, void* buf, long size);
-extern long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, short* s2, int siz2);
-extern long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1, char* s2, int siz2, char* c3, int* siz3);
-extern long WINAPI expGetVersionExA(OSVERSIONINFOA* c);
-extern HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, char* name);
-extern long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count);
-extern long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey);
-extern long WINAPI expRegCloseKey(long key);
-
-extern long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count);
-extern long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved,
- void* classs, long options, long security,
- void* sec_attr, int* newkey, int* status);
-extern long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size);
-extern long WINAPI expRegOpenKeyA (long hKey, LPCSTR lpSubKey, int* phkResult);
-extern long WINAPI expQueryPerformanceCounter(long long* z);
-extern long WINAPI expQueryPerformanceFrequency(long long* z);
-extern long WINAPI exptimeGetTime(void);
-extern void* WINAPI expLocalHandle(void* v);
-extern void* WINAPI expGlobalHandle(void* v);
-extern int WINAPI expGlobalUnlock(void* v);
-extern void* WINAPI expGlobalFree(void* v);
-extern void* WINAPI expGlobalReAlloc(void* v, int size, int flags);
-extern int WINAPI expLocalUnlock(void* v);
-extern void* WINAPI expLocalFree(void* v);
-extern HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type);
-extern HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res);
-extern void* WINAPI expLockResource(long res);
-extern int WINAPI expFreeResource(long res);
-extern int WINAPI expCloseHandle(long v1);
-extern const char* WINAPI expGetCommandLineA(void);
-extern LPWSTR WINAPI expGetEnvironmentStringsW(void);
-extern void * WINAPI expRtlZeroMemory(void *p, size_t len);
-extern void * WINAPI expRtlMoveMemory(void *dst, void *src, size_t len);
-extern void * WINAPI expRtlFillMemory(void *p, int ch, size_t len);
-extern int WINAPI expFreeEnvironmentStringsW(short* strings);
-extern int WINAPI expFreeEnvironmentStringsA(char* strings);
-extern LPWSTR WINAPI expGetEnvironmentStringsW(void);
-LPCSTR WINAPI expGetEnvironmentStrings(void);
-extern int WINAPI expGetStartupInfoA(STARTUPINFOA *s);
-extern int WINAPI expGetStdHandle(int z);
-extern int WINAPI expGetFileType(int handle);
-extern int WINAPI expSetHandleCount(int count);
-extern int WINAPI expGetACP(void);
-extern int WINAPI expGetModuleFileNameA(int module, char* s, int len);
-extern int WINAPI expSetUnhandledExceptionFilter(void* filter);
-extern int WINAPI expLoadLibraryA(char* name);
-extern int WINAPI expFreeLibrary(int module);
-extern void* WINAPI expGetProcAddress(HMODULE mod, char* name);
-extern long WINAPI expCreateFileMappingA(int hFile, void* lpAttr,
- long flProtect, long dwMaxHigh, long dwMaxLow, const char* name);
-extern long WINAPI expOpenFileMappingA(long hFile, long hz, const char* name);
-extern void* WINAPI expMapViewOfFile(HANDLE file, DWORD mode, DWORD offHigh, DWORD offLow, DWORD size);
-extern void* WINAPI expUnmapViewOfFile(void* view);
-extern void* WINAPI expSleep(int time);
-extern void* WINAPI expCreateCompatibleDC(int hdc);
-extern int WINAPI expGetDeviceCaps(int hdc, int unk);
-extern WIN_BOOL WINAPI expDeleteDC(int hdc);
-extern int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename);
-extern int WINAPI expGetProfileIntA(const char* appname, const char* keyname, int default_value);
-extern int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname,
- const char* def_val, char* dest, unsigned int len, const char* filename);
-extern int WINAPI expWritePrivateProfileStringA(const char* appname, const char* keyname,
- const char* string, const char* filename);
-extern int WINAPI expDefDriverProc(int _private, int id, int msg, int arg1, int arg2);
-extern int WINAPI expSizeofResource(int v1, int v2);
-extern int WINAPI expGetLastError(void);
-extern void WINAPI expSetLastError(int error);
-extern long WINAPI exptimeGetTime(void);
-extern int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax);
-extern int WINAPI expGetFileVersionInfoSizeA(const char* name, int* lpHandle);
-extern int WINAPI expIsBadStringPtrW(const short* string, int nchars);
-extern int WINAPI expIsBadStringPtrA(const char* string, int nchars);
-extern long WINAPI expInterlockedIncrement( long* dest );
-extern long WINAPI expInterlockedDecrement( long* dest );
-extern void WINAPI expOutputDebugStringA( const char* string );
-extern int WINAPI expGetDC(int hwnd);
-extern int WINAPI expGetDesktopWindow(void);
-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);
-extern int WINAPI expGetSystemTime(SYSTEMTIME* systime);
-extern int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size);
-extern void* WINAPI expCoTaskMemAlloc(ULONG cb);
-extern void WINAPI expCoTaskMemFree(void* cb);
-extern long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv);
-extern int WINAPI expIsRectEmpty(CONST RECT *lprc);
-extern unsigned int WINAPI expGetTempPathA(unsigned int len, char* path);
-extern HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd);
-extern WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p);
-extern WIN_BOOL WINAPI expFindClose(HANDLE h);
-extern UINT WINAPI expSetErrorMode(UINT i);
-extern UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c);
-extern WIN_BOOL WINAPI expDeleteFileA(LPCSTR s);
-extern WIN_BOOL WINAPI expFileTimeToLocalFileTime(const FILETIME* cpf, LPFILETIME pf);
-extern UINT WINAPI expGetTempFileNameA(LPCSTR cs1,LPCSTR cs2,UINT i,LPSTR ps);
-extern HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
- LPSECURITY_ATTRIBUTES p1, DWORD i3,DWORD i4,HANDLE i5);
-extern LPCSTR WINAPI expGetSystemDirectoryA(void);
-extern WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused);
-extern WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LPOVERLAPPED unused);
-extern DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence);
-extern HDRVR WINAPI expOpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName,
- LPARAM lParam2);
-HDRVR WINAPI expOpenDriver(LPCSTR szDriverName, LPCSTR szSectionName,
- LPARAM lParam2) ;
-extern WIN_BOOL WINAPI expGetProcessAffinityMask(HANDLE hProcess,
- LPDWORD lpProcessAffinityMask,
- LPDWORD lpSystemAffinityMask);
-extern DWORD WINAPI expRegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
- LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count );
-extern INT WINAPI expMulDiv(int nNumber,int nNumerator,int nDenominator);
-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);
-void WINAPI expInitCommonControls(void);
-
-
-extern void* CDECL expmalloc(int size);
-extern void CDECL expfree(void* mem);
-extern void* CDECL expnew(int size);
-extern int CDECL expdelete(void* memory);
-extern int CDECL exp_initterm(int v1, int v2);
-
-extern int expwsprintfA(char* string, char* format, ...);
-extern char* expstrrchr(char* string, int value);
-extern char* expstrchr(char* string, int value);
-extern int expstrlen(char* str);
-extern int expstrcpy(char* str1, const char* str2);
-extern int expstrcmp(const char* str1, const char* str2);
-extern int expstrcat(char* str1, const char* str2);
-extern int expisalnum(int c);
-extern int expmemmove(void* dest, void* src, int n);
-extern int expmemcmp(void* dest, void* src, int n);
-extern void *expmemcpy(void* dest, void* src, int n) ;
-extern time_t exptime(time_t* t);
-extern int exprand(void);
-extern void expsrand(int seed);
-extern int exp_ftol(float f);
-extern int expsprintf(char* str, const char* format, ...);
-extern double explog10(double x);
-extern double expcos(double x);
-extern double exppow(double x, double y);
-extern int expsscanf(const char* str, const char* format, ...);
-extern void* expfopen(const char* path, const char* mode);
-extern int expfprintf(void* stream, const char* format, ...);
-extern int expprintf(const char* format, ...);
-extern void* expwcscpy(WCHAR* dst, const WCHAR* src);
extern void* LookupExternal(const char* library, int ordinal);
extern void* LookupExternalByName(const char* library, const char* name);
+extern void* my_mreq(int size, int to_zero);
+extern int my_release(void* memory);
+
#endif
diff --git a/src/libw32dll/wine/winbase.h b/src/libw32dll/wine/winbase.h
index 4be1595d8..8746da891 100644
--- a/src/libw32dll/wine/winbase.h
+++ b/src/libw32dll/wine/winbase.h
@@ -6,7 +6,6 @@
#include "winestring.h"
#include "pshpack1.h"
-#define __WINE__
#ifdef __cplusplus
extern "C" {
@@ -1496,7 +1495,7 @@ VOID WINAPI UnMapLS(SEGPTR);
WIN_BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD);
WIN_BOOL WINAPI UnmapViewOfFile(LPVOID);
LPVOID WINAPI VirtualAlloc(LPVOID,DWORD,DWORD,DWORD);
-WIN_BOOL WINAPI VirtualFree(LPVOID,DWORD,DWORD);
+WIN_BOOL WINAPI VirtualFree(LPVOID,SIZE_T,DWORD);
WIN_BOOL WINAPI VirtualLock(LPVOID,DWORD);
WIN_BOOL WINAPI VirtualProtect(LPVOID,DWORD,DWORD,LPDWORD);
WIN_BOOL WINAPI VirtualProtectEx(HANDLE,LPVOID,DWORD,DWORD,LPDWORD);
diff --git a/src/libw32dll/wine/winnt.h b/src/libw32dll/wine/winnt.h
index 03f4a777b..478f8b78f 100644
--- a/src/libw32dll/wine/winnt.h
+++ b/src/libw32dll/wine/winnt.h
@@ -132,7 +132,10 @@ typedef struct _SINGLE_LIST_ENTRY {
#define PF_MMX_INSTRUCTIONS_AVAILABLE 3
#define PF_PPC_MOVEMEM_64BIT_OK 4
#define PF_ALPHA_BYTE_INSTRUCTIONS 5
-
+/* based on wine-20010510 -- alex */
+#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
+#define PF_AMD3D_INSTRUCTIONS_AVAILABLE 7
+#define PF_RDTSC_INSTRUCTION_AVAILABLE 8
/* The Win32 register context */