diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-12-18 04:00:45 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-12-18 04:00:45 +0000 |
commit | 85632e5177760e08d3d40dcfe9456bef54fcdc2d (patch) | |
tree | 23fe16c5ebbc032f620ac5d97706a539982426a2 /src | |
parent | 54e7d3ecdb73fbbe09025c7f8b3bdbbe8ea87690 (diff) | |
download | xine-lib-85632e5177760e08d3d40dcfe9456bef54fcdc2d.tar.gz xine-lib-85632e5177760e08d3d40dcfe9456bef54fcdc2d.tar.bz2 |
first draft of quicktime binary-only codec support
CVS patchset: 3580
CVS date: 2002/12/18 04:00:45
Diffstat (limited to 'src')
-rw-r--r-- | src/libw32dll/Makefile.am | 13 | ||||
-rw-r--r-- | src/libw32dll/qt_decoder.c | 1183 | ||||
-rw-r--r-- | src/libw32dll/qtx/Makefile.am | 13 | ||||
-rw-r--r-- | src/libw32dll/qtx/qtxsdk/Makefile.am | 18 | ||||
-rw-r--r-- | src/libw32dll/qtx/qtxsdk/components.h | 720 | ||||
-rw-r--r-- | src/libw32dll/qtx/qtxsdk/select.h | 68 | ||||
-rw-r--r-- | src/libw32dll/w32codec.c | 8 | ||||
-rw-r--r-- | src/libw32dll/wine/Makefile.am | 10 | ||||
-rw-r--r-- | src/libw32dll/wine/afl.c | 65 | ||||
-rw-r--r-- | src/libw32dll/wine/com.h | 18 | ||||
-rw-r--r-- | src/libw32dll/wine/driver.c | 246 | ||||
-rw-r--r-- | src/libw32dll/wine/elfdll.c | 10 | ||||
-rw-r--r-- | src/libw32dll/wine/ldt_keeper.c | 9 | ||||
-rw-r--r-- | src/libw32dll/wine/module.c | 480 | ||||
-rw-r--r-- | src/libw32dll/wine/module.h | 10 | ||||
-rw-r--r-- | src/libw32dll/wine/registry.c | 98 | ||||
-rw-r--r-- | src/libw32dll/wine/vfl.c | 190 | ||||
-rw-r--r-- | src/libw32dll/wine/vfw.h | 23 | ||||
-rw-r--r-- | src/libw32dll/wine/win32.c | 1138 | ||||
-rw-r--r-- | src/libw32dll/wine/win32.h | 6 | ||||
-rw-r--r-- | src/libw32dll/wine/wineacm.h | 25 | ||||
-rw-r--r-- | src/libw32dll/wine/wrapper.S | 83 | ||||
-rw-r--r-- | src/libw32dll/wine/wrapper.h | 20 |
23 files changed, 3829 insertions, 625 deletions
diff --git a/src/libw32dll/Makefile.am b/src/libw32dll/Makefile.am index b5f3fbc17..7e7dec90e 100644 --- a/src/libw32dll/Makefile.am +++ b/src/libw32dll/Makefile.am @@ -2,10 +2,11 @@ AM_CFLAGS = -I$(srcdir)/wine #DEBUG_CFLAGS = @DEBUG_CFLAGS@ -I$(srcdir)/wine -SUBDIRS = wine DirectShow +SUBDIRS = wine DirectShow qtx if HAVE_W32DLL w32dll_codec = xineplug_decode_w32dll.la +qt_codec = xineplug_decode_qt.la endif LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic @@ -17,7 +18,7 @@ libdir = $(XINE_PLUGINDIR) # --------- # All of xine codecs should be named like the scheme "xineplug_decode_" # -lib_LTLIBRARIES = $(w32dll_codec) +lib_LTLIBRARIES = $(w32dll_codec) $(qt_codec) xineplug_decode_w32dll_la_SOURCES = w32codec.c xineplug_decode_w32dll_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@ @@ -27,6 +28,14 @@ xineplug_decode_w32dll_la_LIBADD = \ $(top_builddir)/src/libw32dll/DirectShow/libds_filter.la \ @KSTAT_LIBS@ +xineplug_decode_qt_la_SOURCES = qt_decoder.c +xineplug_decode_qt_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@ +xineplug_decode_qt_la_LIBADD = \ + $(top_builddir)/src/libw32dll/wine/libwine.la \ + $(XINE_LIB) \ + $(top_builddir)/src/libw32dll/DirectShow/libds_filter.la \ + @KSTAT_LIBS@ + noinst_HEADERS = libwin32.h w32codec.h $(XINE_LIB): diff --git a/src/libw32dll/qt_decoder.c b/src/libw32dll/qt_decoder.c new file mode 100644 index 000000000..aefed740f --- /dev/null +++ b/src/libw32dll/qt_decoder.c @@ -0,0 +1,1183 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: qt_decoder.c,v 1.1 2002/12/18 04:00:49 guenter Exp $ + * + * quicktime video/audio decoder plugin, using win32 dlls + * most of this code comes directly from MPlayer + * authors: A'rpi and Sascha Sommer + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#include "bswap.h" +#include "xine_internal.h" +#include "audio_out.h" +#include "buffer.h" + +#include "qtx/qtxsdk/components.h" +#include "wine/windef.h" +#include "wine/ldt_keeper.h" + +/* +#define LOG +*/ + +/* + * + * part 0: common wine stuff + * ========================= + * + */ + +HMODULE WINAPI LoadLibraryA(LPCSTR); +FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); +int WINAPI FreeLibrary(HMODULE); + +/* some data is shared inside wine loader. + * this mutex seems to avoid some segfaults + */ +static pthread_once_t once_control = PTHREAD_ONCE_INIT; +static pthread_mutex_t win32_codec_mutex; +extern char *win32_def_path; + +static void init_routine(void) { + +#ifdef LOG + printf ("qt_decoder: init_routine\n"); +#endif + + pthread_mutex_init (&win32_codec_mutex, NULL); + +#ifdef LOG + printf ("qt_decoder: init_routine completed\n"); +#endif +} + +#define BUFSIZE 1024*1024 + +/* + * + * part 1: audio decoder + * ===================== + * + */ + +typedef struct OpaqueSoundConverter* SoundConverter; +typedef unsigned long UnsignedFixed; +typedef uint8_t Byte; +typedef struct SoundComponentData { + long flags; + OSType format; + short numChannels; + short sampleSize; + UnsignedFixed sampleRate; + long sampleCount; + Byte * buffer; + long reserved; +}SoundComponentData; + + +typedef int (__cdecl* LPFUNC1)(long flag); +typedef int (__cdecl* LPFUNC2)(const SoundComponentData *, + const SoundComponentData *, + SoundConverter *); +typedef int (__cdecl* LPFUNC3)(SoundConverter sc); +typedef int (__cdecl* LPFUNC4)(void); +typedef int (__cdecl* LPFUNC5)(SoundConverter sc, OSType selector,void * infoPtr); +typedef int (__cdecl* LPFUNC6)(SoundConverter sc, + unsigned long inputBytesTarget, + unsigned long *inputFrames, + unsigned long *inputBytes, + unsigned long *outputBytes ); +typedef int (__cdecl* LPFUNC7)(SoundConverter sc, + const void *inputPtr, + unsigned long inputFrames, + void *outputPtr, + unsigned long *outputFrames, + unsigned long *outputBytes ); +typedef int (__cdecl* LPFUNC8)(SoundConverter sc, + void *outputPtr, + unsigned long *outputFrames, + unsigned long *outputBytes); +typedef int (__cdecl* LPFUNC9)(SoundConverter sc) ; + +#define siDecompressionParams 2002876005 /* siDecompressionParams = FOUR_CHAR_CODE('wave') */ + +typedef struct { + audio_decoder_class_t decoder_class; +} qta_class_t; + +typedef struct qta_decoder_s { + audio_decoder_t audio_decoder; + + int codec_initialized; + int output_open; + + xine_stream_t *stream; + + HINSTANCE qtml_dll; + + xine_waveformatex wave; + uint8_t out_buf[1000000]; + + LPFUNC1 InitializeQTML; + LPFUNC2 SoundConverterOpen; + LPFUNC3 SoundConverterClose; + LPFUNC4 TerminateQTML; + LPFUNC5 SoundConverterSetInfo; + LPFUNC6 SoundConverterGetBufferSizes; + LPFUNC7 SoundConverterConvertBuffer; + LPFUNC8 SoundConverterEndConversion; + LPFUNC9 SoundConverterBeginConversion; + + SoundConverter myConverter; + SoundComponentData InputFormatInfo, OutputFormatInfo; + + int InFrameSize; + int OutFrameSize; + int FramesToGet; + + int frame_size; + + uint8_t data[BUFSIZE]; + int data_len; + int num_frames; + +} qta_decoder_t; + +#ifdef LOG +static void qta_hexdump (char *buf, int length) { + + int i; + + printf ("qt_audio: ascii contents>"); + for (i = 0; i < length; i++) { + unsigned char c = buf[i]; + + if ((c >= 32) && (c <= 128)) + printf ("%c", c); + else + printf ("."); + } + printf ("\n"); + + printf ("qt_audio: complete hexdump of package follows:\nqt_audio: 0x0000: "); + for (i = 0; i < length; i++) { + unsigned char c = buf[i]; + + printf ("%02x", c); + + if ((i % 16) == 15) + printf ("\nqt_audio: 0x%04x: ", i+1); + + if ((i % 2) == 1) + printf (" "); + + } + printf ("\n"); +} +#endif + +static void qta_init_driver (qta_decoder_t *this, buf_element_t *buf) { + + int error; + unsigned long InputBufferSize=0; /* size of the input buffer */ + unsigned long OutputBufferSize=0; /* size of the output buffer */ + unsigned long WantedBufferSize=0; /* the size you want your buffers to be */ + int mode; + + this->FramesToGet = 0; + +#ifdef LOG + printf ("qt_audio: init_driver... (trying to lock mutex...)\n"); +#endif + + pthread_mutex_lock(&win32_codec_mutex); + +#ifdef LOG + printf ("qt_audio: init_driver... (mutex locked)\n"); +#endif + + Setup_LDT_Keeper(); + + this->qtml_dll = LoadLibraryA("qtmlClient.dll"); + + if (this->qtml_dll == NULL ) { + printf ("qt_audio: failed to load dll\n" ); + return; + } + + this->InitializeQTML = (LPFUNC1)GetProcAddress (this->qtml_dll, "InitializeQTML"); + if ( this->InitializeQTML == NULL ) { + printf ("qt_audio: failed geting proc address InitializeQTML\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterOpen = (LPFUNC2)GetProcAddress (this->qtml_dll, "SoundConverterOpen"); + if ( this->SoundConverterOpen == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterOpen\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterClose = (LPFUNC3)GetProcAddress (this->qtml_dll, "SoundConverterClose"); + if ( this->SoundConverterClose == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterClose\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->TerminateQTML = (LPFUNC4)GetProcAddress (this->qtml_dll, "TerminateQTML"); + if ( this->TerminateQTML == NULL ) { + printf ("qt_audio: failed getting proc address TerminateQTML\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterSetInfo = (LPFUNC5)GetProcAddress (this->qtml_dll, "SoundConverterSetInfo"); + if ( this->SoundConverterSetInfo == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterSetInfo\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterGetBufferSizes = (LPFUNC6)GetProcAddress (this->qtml_dll, "SoundConverterGetBufferSizes"); + if ( this->SoundConverterGetBufferSizes == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterGetBufferSizes\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterConvertBuffer = (LPFUNC7)GetProcAddress (this->qtml_dll, "SoundConverterConvertBuffer"); + if ( this->SoundConverterConvertBuffer == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterConvertBuffer1\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterEndConversion = (LPFUNC8)GetProcAddress (this->qtml_dll, "SoundConverterEndConversion"); + if ( this->SoundConverterEndConversion == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterEndConversion\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + this->SoundConverterBeginConversion = (LPFUNC9)GetProcAddress (this->qtml_dll, "SoundConverterBeginConversion"); + if ( this->SoundConverterBeginConversion == NULL ) { + printf ("qt_audio: failed getting proc address SoundConverterBeginConversion\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } +#ifdef LOG + printf ("qt_audio: Standard init done you may now call supported functions\n"); +#endif + + error = this->InitializeQTML(6+16); +#ifdef LOG + printf ("qt_audio: InitializeQTML:%i\n",error); +#endif + if (error) { + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + + this->OutputFormatInfo.flags = this->InputFormatInfo.flags = 0; + this->OutputFormatInfo.sampleCount = this->InputFormatInfo.sampleCount = 0; + this->OutputFormatInfo.buffer = this->InputFormatInfo.buffer = NULL; + this->OutputFormatInfo.reserved = this->InputFormatInfo.reserved = 0; + this->OutputFormatInfo.numChannels = this->InputFormatInfo.numChannels = this->wave.nChannels; + this->InputFormatInfo.sampleSize = this->wave.wBitsPerSample; + this->OutputFormatInfo.sampleSize = 16; + this->OutputFormatInfo.sampleRate = this->InputFormatInfo.sampleRate = this->wave.nSamplesPerSec; + + switch (buf->type) { + case BUF_AUDIO_QDESIGN1: + this->InputFormatInfo.format = FOUR_CHAR_CODE('QDM1'); + break; + case BUF_AUDIO_QDESIGN2: + this->InputFormatInfo.format = FOUR_CHAR_CODE('QDM2'); + break; + default: + printf ("qt_audio: fourcc for buftype %08x ?\n", buf->type); + abort (); + } + + this->OutputFormatInfo.format = 1313820229; /* FOUR_CHAR_CODE('NONE'); */ + +#ifdef LOG + printf ("qt_audio: input format:\n"); + qta_hexdump (&this->InputFormatInfo, sizeof (SoundComponentData)); + printf ("qt_audio: output format:\n"); + qta_hexdump (&this->OutputFormatInfo, sizeof (SoundComponentData)); + printf ("qt_audio: stsd atom: \n"); + qta_hexdump (buf->content, buf->size); +#endif + + error = this->SoundConverterOpen (&this->InputFormatInfo, + &this->OutputFormatInfo, + &this->myConverter); +#ifdef LOG + printf ("qt_audio: SoundConverterOpen:%i\n",error); +#endif + if (error) { + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + + if (buf->size > 0x48) { + error = this->SoundConverterSetInfo (this->myConverter, + siDecompressionParams, + buf->content + 0x48); +#ifdef LOG + printf ("qt_audio: SoundConverterSetInfo:%i\n",error); +#endif + if (error) { + pthread_mutex_unlock(&win32_codec_mutex); + + return; + } + } + + WantedBufferSize = this->OutputFormatInfo.numChannels*this->OutputFormatInfo.sampleRate*2; + error = this->SoundConverterGetBufferSizes (this->myConverter, + WantedBufferSize, &this->FramesToGet, + &InputBufferSize, &OutputBufferSize); +#ifdef LOG + printf ("qt_audio: SoundConverterGetBufferSizes:%i\n", error); + printf ("qt_audio: WantedBufferSize = %li\n", WantedBufferSize); + printf ("qt_audio: InputBufferSize = %li\n", InputBufferSize); + printf ("qt_audio: OutputBufferSize = %li\n", OutputBufferSize); + printf ("qt_audio: this->FramesToGet = %li\n", this->FramesToGet); +#endif + + this->InFrameSize = (InputBufferSize+this->FramesToGet-1)/this->FramesToGet; + this->OutFrameSize = OutputBufferSize/this->FramesToGet; + +#ifdef LOG + printf ("qt_audio: FrameSize: %i -> %i\n", this->InFrameSize, this->OutFrameSize); +#endif + + error = this->SoundConverterBeginConversion (this->myConverter); +#ifdef LOG + printf ("qt_audio: SoundConverterBeginConversion:%i\n",error); +#endif + if (error) { + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + +#ifdef LOG + printf ("qt_audio: opening output.\n"); +#endif + + switch (this->wave.nChannels) { + case 1: + mode = AO_CAP_MODE_MONO; + break; + case 2: + mode = AO_CAP_MODE_STEREO; + break; + case 4: + mode = AO_CAP_MODE_4CHANNEL; + break; + case 5: + mode = AO_CAP_MODE_5CHANNEL; + break; + case 6: + mode = AO_CAP_MODE_5_1CHANNEL; + break; + default: + printf ("qt_audio: help, %d channels ?!\n", + this->wave.nChannels); + abort (); + } + + this->frame_size = this->wave.nChannels * this->wave.wBitsPerSample / 8; + + this->output_open = this->stream->audio_out->open(this->stream->audio_out, + this->stream, + this->wave.wBitsPerSample, + this->wave.nSamplesPerSec, + mode) ; + + this->codec_initialized = 1; + +#ifdef LOG + printf ("qt_audio: mutex unlock\n"); +#endif + + pthread_mutex_unlock(&win32_codec_mutex); +} + +static void qta_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { + + qta_decoder_t *this = (qta_decoder_t *) this_gen; + +#ifdef LOG + printf ("qt_audio: decode buf=%08x %d bytes flags=%08x pts=%lld\n", + buf, buf->size, buf->decoder_flags, buf->pts); +#endif + + if (buf->decoder_flags & BUF_FLAG_HEADER) { + + memcpy (&this->wave, buf->content, sizeof (xine_waveformatex)); + + this->wave.nChannels = buf->decoder_info[3]; + this->wave.wBitsPerSample = buf->decoder_info[2]; + this->wave.nSamplesPerSec = buf->decoder_info[1]; + +#ifdef LOG + printf ("qt_audio: header copied\n"); +#endif + + } else if (buf->decoder_flags & BUF_FLAG_SPECIAL) { +#ifdef LOG + printf ("qt_audio: special buffer\n"); +#endif + + if (buf->decoder_info[0] == BUF_SPECIAL_STSD_ATOM) { + +#ifdef LOG + printf ("qt_audio: got stsd atom -> init codec\n"); +#endif + + if (!this->codec_initialized) { + qta_init_driver (this, buf); + } + } + } else { + + memcpy (&this->data[this->data_len], buf->content, buf->size); + this->data_len += buf->size; + + if (this->data_len> this->InFrameSize) { + + int num_frames = this->data_len / this->InFrameSize; + int out_frames, out_bytes; + int error, frames_left, bytes_sent; + + pthread_mutex_lock(&win32_codec_mutex); + error = this->SoundConverterConvertBuffer (this->myConverter, + this->data, + num_frames, + this->out_buf, + &out_frames, &out_bytes); + pthread_mutex_unlock(&win32_codec_mutex); + +#ifdef LOG + printf ("qt_audio: decoded %d frames => %d frames (error %d)\n", + num_frames, out_frames, error); +#endif + + this->data_len -= this->InFrameSize * num_frames; + if (this->data_len>0) + memmove (this->data, this->data+num_frames*this->InFrameSize, this->data_len); + + + frames_left = out_frames; + bytes_sent = 0; + while (frames_left>0) { + + audio_buffer_t *audio_buffer; + int nframes; + + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); + + nframes = audio_buffer->mem_size / this->frame_size; + + if (nframes > frames_left) + nframes = frames_left; + + memcpy (audio_buffer->mem, this->out_buf+bytes_sent, nframes * this->frame_size); + + /* audio_buffer->vpts = buf->pts; */ + audio_buffer->vpts = 0; + audio_buffer->num_frames = nframes; + +#ifdef LOG + printf ("qt_audio: sending %d frames, %d frames left\n", + nframes, frames_left); +#endif + + this->stream->audio_out->put_buffer (this->stream->audio_out, + audio_buffer, this->stream); + + bytes_sent += nframes*this->frame_size; + frames_left -= nframes; + } + + } + + } +} + +static void qta_reset (audio_decoder_t *this_gen) { +} + + +static void qta_discontinuity (audio_decoder_t *this_gen) { +} + +static void qta_dispose (audio_decoder_t *this_gen) { + + qta_decoder_t *this = (qta_decoder_t *) this_gen; + int error; + unsigned long ConvertedFrames=0; + unsigned long ConvertedBytes=0; + error = this->SoundConverterEndConversion (this->myConverter,NULL, + &ConvertedFrames,&ConvertedBytes); +#ifdef LOG + printf ("qt_audio: SoundConverterEndConversion:%i\n",error); +#endif + error = this->SoundConverterClose (this->myConverter); +#ifdef LOG + printf ("qt_audio: SoundConverterClose:%i\n",error); +#endif + + free (this); +} + +static audio_decoder_t *qta_open_plugin (audio_decoder_class_t *class_gen, + xine_stream_t *stream) { + + qta_decoder_t *this ; + + this = (qta_decoder_t *) xine_xmalloc (sizeof (qta_decoder_t)); + + this->audio_decoder.decode_data = qta_decode_data; + this->audio_decoder.reset = qta_reset; + this->audio_decoder.discontinuity = qta_discontinuity; + this->audio_decoder.dispose = qta_dispose; + this->stream = stream; + + this->output_open = 0; + + return (audio_decoder_t *) this; +} + +/* + * qta plugin class + */ + +static char *qta_get_identifier (audio_decoder_class_t *this) { + return "qta"; +} + +static char *qta_get_description (audio_decoder_class_t *this) { + return "quicktime audio decoder plugin"; +} + +static void qta_dispose_class (audio_decoder_class_t *this) { + free (this); +} + +static void *qta_init_class (xine_t *xine, void *data) { + + qta_class_t *this; + config_values_t *cfg; + + pthread_once (&once_control, init_routine); + + this = (qta_class_t *) malloc (sizeof (qta_class_t)); + + this->decoder_class.open_plugin = qta_open_plugin; + this->decoder_class.get_identifier = qta_get_identifier; + this->decoder_class.get_description = qta_get_description; + this->decoder_class.dispose = qta_dispose_class; + + cfg = xine->config; + win32_def_path = cfg->register_string (cfg, "codec.win32_path", + "/usr/lib/win32", + _("path to win32 codec dlls"), + NULL, 0, NULL, NULL); + + return this; +} + +static uint32_t audio_types[] = { + BUF_AUDIO_QDESIGN1, BUF_AUDIO_QDESIGN2, 0 +}; + +static decoder_info_t qta_dec_info = { + audio_types, /* supported types */ + 5 /* priority */ +}; + +/* + * + * part 2: video decoder + * ===================== + * + */ + +typedef struct { + video_decoder_class_t decoder_class; + + char *qt_codec_path; + +} qtv_class_t; + + +typedef struct qtv_decoder_s { + video_decoder_t video_decoder; + + qtv_class_t *cls; + + xine_stream_t *stream; + + HINSTANCE qtml_dll; + + xine_bmiheader bih; + + int codec_initialized; + + uint8_t *plane; + + uint8_t data[BUFSIZE]; + int data_len; + + /* ComponentDescription desc; */ /* for FindNextComponent() */ + ComponentInstance ci; /* codec handle */ + /* CodecInfo cinfo;*/ /* for ImageCodecGetCodecInfo() */ + /* Component prev=NULL; */ + /* ComponentResult cres; */ + CodecCapabilities codeccap; /* for decpar */ + CodecDecompressParams decpar; /* for ImageCodecPreDecompress() */ + /* ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() */ + Rect OutBufferRect; /* the dimensions of our GWorld */ + + GWorldPtr OutBufferGWorld; /* a GWorld is some kind of + description for a drawing + environment */ + ImageDescriptionHandle framedescHandle; + + /* function pointers */ + + Component (*FindNextComponent) (Component prev, + ComponentDescription* desc); + OSErr (*GetComponentInfo) (Component prev, + ComponentDescription* desc, + Handle h1,Handle h2,Handle h3); + long (*CountComponents) (ComponentDescription* desc); + OSErr (*InitializeQTML) (long flags); + OSErr (*EnterMovies) (void); + ComponentInstance (*OpenComponent) (Component c); + ComponentResult (*ImageCodecInitialize) (ComponentInstance ci, + ImageSubCodecDecompressCapabilities * cap); + ComponentResult (*ImageCodecBeginBand) (ComponentInstance ci, + CodecDecompressParams * params, + ImageSubCodecDecompressRecord * drp, + long flags); + ComponentResult (*ImageCodecDrawBand) (ComponentInstance ci, + ImageSubCodecDecompressRecord * drp); + ComponentResult (*ImageCodecEndBand) (ComponentInstance ci, + ImageSubCodecDecompressRecord * drp, + OSErr result, long flags); + ComponentResult (*ImageCodecGetCodecInfo) (ComponentInstance ci, + CodecInfo *info); + ComponentResult (*ImageCodecPreDecompress)(ComponentInstance ci, + CodecDecompressParams * params); + ComponentResult (*ImageCodecBandDecompress)(ComponentInstance ci, + CodecDecompressParams * params); + PixMapHandle (*GetGWorldPixMap) (GWorldPtr offscreenGWorld); + OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw, + OSType pixelFormat, + const Rect *boundsRect, + CTabHandle cTable, + /*GDHandle*/void* aGDevice, /*unused*/ + GWorldFlags flags, + void *baseAddr, + long rowBytes); + OSErr (*NewHandleClear)(Size byteCount); + +} qtv_decoder_t; + +#ifdef LOG +static void qtv_hexdump (char *buf, int length) { + + int i; + + printf ("qt_video: ascii contents>"); + for (i = 0; i < length; i++) { + unsigned char c = buf[i]; + + if ((c >= 32) && (c <= 128)) + printf ("%c", c); + else + printf ("."); + } + printf ("\n"); + + printf ("qt_video: complete hexdump of package follows:\nqt_video: 0x0000: "); + for (i = 0; i < length; i++) { + unsigned char c = buf[i]; + + printf ("%02x", c); + + if ((i % 16) == 15) + printf ("\nqt_video: 0x%04x: ", i+1); + + if ((i % 2) == 1) + printf (" "); + + } + printf ("\n"); +} +#endif + +/* + * qt codec loader + */ + +static void qtv_init_driver (qtv_decoder_t *this, buf_element_t *buf) { + + long result = 1; + ComponentResult cres; + ComponentDescription desc; + Component prev=NULL; + CodecInfo cinfo; /* for ImageCodecGetCodecInfo() */ + ImageSubCodecDecompressCapabilities icap; /* for ImageCodecInitialize() */ + ImageDescription *id; + +#ifdef LOG + printf ("qt_video: init_driver... (trying to lock mutex...)\n"); +#endif + + pthread_mutex_lock(&win32_codec_mutex); + +#ifdef LOG + printf ("qt_video: mutex locked\n"); +#endif + + Setup_LDT_Keeper(); + + this->qtml_dll = LoadLibraryA("qtmlClient.dll"); + + if (this->qtml_dll == NULL ) { + printf ("qt_video: failed to load dll\n" ); + return; + } + + this->InitializeQTML = GetProcAddress (this->qtml_dll, "InitializeQTML"); + this->EnterMovies = GetProcAddress (this->qtml_dll, "EnterMovies"); + this->FindNextComponent = GetProcAddress (this->qtml_dll, "FindNextComponent"); + this->CountComponents = GetProcAddress (this->qtml_dll, "CountComponents"); + this->GetComponentInfo = GetProcAddress (this->qtml_dll, "GetComponentInfo"); + this->OpenComponent = GetProcAddress (this->qtml_dll, "OpenComponent"); + this->ImageCodecInitialize = GetProcAddress (this->qtml_dll, "ImageCodecInitialize"); + this->ImageCodecGetCodecInfo = GetProcAddress (this->qtml_dll, "ImageCodecGetCodecInfo"); + this->ImageCodecBeginBand = GetProcAddress (this->qtml_dll, "ImageCodecBeginBand"); + this->ImageCodecPreDecompress = GetProcAddress (this->qtml_dll, "ImageCodecPreDecompress"); + this->ImageCodecBandDecompress = GetProcAddress (this->qtml_dll, "ImageCodecBandDecompress"); + this->GetGWorldPixMap = GetProcAddress (this->qtml_dll, "GetGWorldPixMap"); + this->QTNewGWorldFromPtr = GetProcAddress (this->qtml_dll, "QTNewGWorldFromPtr"); + this->NewHandleClear = GetProcAddress (this->qtml_dll, "NewHandleClear"); + + if (!this->InitializeQTML || !this->EnterMovies || !this->FindNextComponent + || !this->ImageCodecBandDecompress){ + printf ("qt_video: invalid qt DLL!\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } + +#ifdef LOG + printf ("qt_video: calling InitializeQTML...\n"); +#endif + + result = this->InitializeQTML(6+16); + /* result=InitializeQTML(0); */ +#ifdef LOG + printf("qt_video: InitializeQTML returned %d\n",result); +#endif + /* result=EnterMovies(); */ + /* printf("EnterMovies->%d\n",result); */ + + memset(&desc,0,sizeof(desc)); + desc.componentType= (((unsigned char)'i')<<24)| + (((unsigned char)'m')<<16)| + (((unsigned char)'d')<<8)| + (((unsigned char)'c')); + desc.componentSubType= + (((unsigned char)'S'<<24))| + (((unsigned char)'V')<<16)| + (((unsigned char)'Q')<<8)| + (((unsigned char)'3')); + + desc.componentManufacturer=0; + desc.componentFlags=0; + desc.componentFlagsMask=0; + +#ifdef LOG + printf("qt_video: Count = %d\n", this->CountComponents(&desc)); +#endif + + prev = this->FindNextComponent(NULL,&desc); + if(!prev){ + printf("Cannot find requested component\n"); + pthread_mutex_unlock(&win32_codec_mutex); + return; + } +#ifdef LOG + printf ("qt_video: Found it! ID = 0x%X\n",prev); +#endif + + this->ci = this->OpenComponent(prev); + printf ("qt_video: this->ci=%p\n",this->ci); + + memset (&icap,0,sizeof(icap)); + cres = this->ImageCodecInitialize (this->ci, &icap); +#ifdef LOG + printf ("qt_video: ImageCodecInitialize->%p size=%d (%d)\n", + cres,icap.recordSize,icap.decompressRecordSize); +#endif + + memset(&cinfo,0,sizeof(cinfo)); + cres = this->ImageCodecGetCodecInfo (this->ci, &cinfo); +#ifdef LOG + printf ("qt_video: Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", + cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); + printf ("qt_video: Codec name: %.*s\n", ((unsigned char*)&cinfo.typeName)[0], + ((unsigned char*)&cinfo.typeName)+1); +#endif + + /* make a yuy2 gworld */ + this->OutBufferRect.top = 0; + this->OutBufferRect.left = 0; + this->OutBufferRect.right = this->bih.biWidth; + this->OutBufferRect.bottom = this->bih.biHeight; + +#ifdef LOG + printf ("qt_video: image size %d x %d\n", + this->bih.biWidth, this->bih.biHeight); + + printf ("qt_video: stsd (%d bytes):\n", buf->size) ; + + qtv_hexdump (buf->content, buf->size); +#endif + + { + uint8_t *stdata = buf->content + 20; + int stdata_len = buf->size - 24; + + id=malloc (8+stdata_len) ; /* trak->stdata_len); */ + id->idSize = 8+stdata_len; + id->cType = (((unsigned char)'S'<<24))| + (((unsigned char)'V')<<16)| + (((unsigned char)'Q')<<8)| + (((unsigned char)'3')); /* bswap_32(trak->fourcc); */ + id->version = BE_16 (stdata+ 8); + id->revisionLevel = BE_16 (stdata+10); + id->vendor = BE_32 (stdata+12); + id->temporalQuality = BE_32 (stdata+16); + id->spatialQuality = BE_32 (stdata+20); + id->width = BE_16 (stdata+24); + id->height = BE_16 (stdata+26); + id->hRes = BE_32 (stdata+28); + id->vRes = BE_32 (stdata+32); + id->dataSize = BE_32 (stdata+36); + id->frameCount = BE_16 (stdata+40); + memcpy(&id->name,stdata+42,32); + id->depth = BE_16 (stdata+74); + id->clutID = BE_16 (stdata+76); + if (stdata_len>78) + memcpy (((char*)&id->clutID)+2, stdata+78, stdata_len-78); + +#ifdef LOG + printf ("qt_video: id (%d bytes)\n", stdata_len); + qtv_hexdump (id, stdata_len); +#endif + + } + +#ifdef LOG + printf ("qt_video: ImageDescription size: %d\n", + id->idSize); + + qtv_hexdump (id, id->idSize); +#endif + + this->framedescHandle = (ImageDescriptionHandle) this->NewHandleClear (id->idSize); + +#ifdef LOG + printf ("qt_video: framedescHandle = %x\n", + this->framedescHandle); +#endif + + memcpy (*this->framedescHandle, id, id->idSize); + + /* + * alloc video plane + */ + + this->plane = malloc (this->bih.biWidth * this->bih.biHeight * 3); + + result = this->QTNewGWorldFromPtr(&this->OutBufferGWorld, + kYUVSPixelFormat, /*pixel format of new GWorld==YUY2 */ + &this->OutBufferRect, /*we should benchmark if yvu9 is faster for svq3, too */ + 0, + 0, + 0, + this->plane, + this->bih.biWidth*2); + +#ifdef LOG + printf ("qt_video: NewGWorldFromPtr returned:%d\n", + 65536-(result&0xffff)); +#endif + + this->decpar.imageDescription = this->framedescHandle; + this->decpar.startLine = 0; + this->decpar.stopLine = (**this->framedescHandle).height; + this->decpar.frameNumber = 1; + this->decpar.matrixFlags = 0; + this->decpar.matrixType = 0; + this->decpar.matrix = 0; + this->decpar.capabilities = &this->codeccap; + this->decpar.accuracy = codecNormalQuality; + this->decpar.port = this->OutBufferGWorld; + this->decpar.srcRect = this->OutBufferRect; + + this->decpar.transferMode = srcCopy; + this->decpar.dstPixMap = **this->GetGWorldPixMap (this->OutBufferGWorld);/*destPixmap; */ + + cres = this->ImageCodecPreDecompress (this->ci, &this->decpar); +#ifdef LOG + printf ("qt_video: ImageCodecPreDecompress cres=0x%X\n", cres); +#endif + + this->data_len = 0; + + this->codec_initialized = 1; + + pthread_mutex_unlock(&win32_codec_mutex); + +} + +static void qtv_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { + qtv_decoder_t *this = (qtv_decoder_t *) this_gen; + +#ifdef LOG + printf ("qt_video: decode_data, flags=0x%08x, len=%d, pts=%lld ...\n", + buf->decoder_flags, buf->size, buf->pts); +#endif + + if (buf->decoder_flags & BUF_FLAG_HEADER) { + +#ifdef LOG + printf ("qt_video: copying bih\n"); +#endif + + memcpy (&this->bih, buf->content, sizeof (xine_bmiheader)); + + } else if (buf->decoder_flags & BUF_FLAG_SPECIAL) { +#ifdef LOG + printf ("qt_video: special buffer\n"); +#endif + + if (buf->decoder_info[0] == BUF_SPECIAL_STSD_ATOM) { + +#ifdef LOG + printf ("qt_video: got stsd atom -> init codec\n"); +#endif + + if (!this->codec_initialized) { + qtv_init_driver (this, buf); + } + } + } else { + +#ifdef LOG + printf ("qt_video: actual image data\n"); +#endif + + memcpy (&this->data[this->data_len], buf->content, buf->size); + this->data_len += buf->size; + +#ifdef LOG + printf ("qt_video: got %d bytes in buffer\n", this->data_len); +#endif + + if (buf->decoder_flags & BUF_FLAG_FRAME_END) { + + ComponentResult cres; + vo_frame_t *img; + + pthread_mutex_lock(&win32_codec_mutex); + + this->decpar.data = this->data; + this->decpar.bufferSize = this->data_len; + (**this->framedescHandle).dataSize=this->data_len; + + cres = this->ImageCodecBandDecompress (this->ci, &this->decpar); + + ++this->decpar.frameNumber; + + pthread_mutex_unlock(&win32_codec_mutex); + + if (cres&0xFFFF){ + printf("qt_video: ImageCodecBandDecompress cres=0x%X (-0x%X) %d :(\n", + cres,-cres,cres); + } + + img = this->stream->video_out->get_frame (this->stream->video_out, + this->bih.biWidth, + this->bih.biHeight, + 42, + XINE_IMGFMT_YUY2, + VO_BOTH_FIELDS); + + img->pts = buf->pts; + img->duration = buf->decoder_info[0]; + img->bad_frame = 0; + + xine_fast_memcpy (img->base[0], this->plane, + this->bih.biWidth*this->bih.biHeight*2); + + img->draw(img, this->stream); + img->free(img); + + this->data_len = 0; + } + } + +#ifdef LOG + printf ("qt_video: decode_data...done\n"); +#endif +} + +static void qtv_flush (video_decoder_t *this_gen) { + /* qtv_decoder_t *this = (qtv_decoder_t *) this_gen; */ + +#ifdef LOG + printf ("qt_video: flush\n"); +#endif + +} + +static void qtv_reset (video_decoder_t *this_gen) { + /* qtv_decoder_t *this = (qtv_decoder_t *) this_gen; */ + +} + +static void qtv_discontinuity (video_decoder_t *this_gen) { + /* qtv_decoder_t *this = (qtv_decoder_t *) this_gen; */ + +} + +static void qtv_dispose (video_decoder_t *this_gen) { + + qtv_decoder_t *this = (qtv_decoder_t *) this_gen; + +#ifdef LOG + printf ("qt_video: close\n"); +#endif + + free (this); +} + +static video_decoder_t *qtv_open_plugin (video_decoder_class_t *class_gen, + xine_stream_t *stream) { + + qtv_class_t *cls = (qtv_class_t *) class_gen; + qtv_decoder_t *this ; + + this = (qtv_decoder_t *) xine_xmalloc (sizeof (qtv_decoder_t)); + + this->video_decoder.decode_data = qtv_decode_data; + this->video_decoder.flush = qtv_flush; + this->video_decoder.reset = qtv_reset; + this->video_decoder.discontinuity = qtv_discontinuity; + this->video_decoder.dispose = qtv_dispose; + this->stream = stream; + this->cls = cls; + + return &this->video_decoder; +} + + +/* + * qtv plugin class + */ + +static char *qtv_get_identifier (video_decoder_class_t *this) { + return "qtvdec"; +} + +static char *qtv_get_description (video_decoder_class_t *this) { + return "quicktime binary-only codec based video decoder plugin"; +} + +static void qtv_dispose_class (video_decoder_class_t *this) { + free (this); +} + +/* + * some fake functions to make qt codecs happy + */ + +#if 0 +static void codec_path_cb (void *data, xine_cfg_entry_t *cfg) { + qtv_class_t *this = (qt_class_t *) data; + + this->qt_codec_path = cfg->str_value; +} +#endif + +static void *qtv_init_class (xine_t *xine, void *data) { + + qtv_class_t *this; + config_values_t *cfg = xine->config; + + win32_def_path = cfg->register_string (cfg, "codec.win32_path", "/usr/lib/win32", + _("path to win32 codec dlls"), + NULL, 0, NULL, NULL); + + printf ("qtv_init_class...\n"); + + pthread_once (&once_control, init_routine); + + printf ("qtv_init_class... done\n"); + + this = (qtv_class_t *) xine_xmalloc (sizeof (qtv_class_t)); + + this->decoder_class.open_plugin = qtv_open_plugin; + this->decoder_class.get_identifier = qtv_get_identifier; + this->decoder_class.get_description = qtv_get_description; + this->decoder_class.dispose = qtv_dispose_class; + + return this; +} + +/* + * exported plugin catalog entry + */ + +static uint32_t qtv_supported_types[] = { BUF_VIDEO_SORENSON_V3, 0 }; + +static decoder_info_t qtv_dec_info = { + qtv_supported_types, /* supported types */ + 6 /* priority */ +}; + +plugin_info_t xine_plugin_info[] = { + /* type, API, "name", version, special_info, init_function */ + { PLUGIN_VIDEO_DECODER, 13, "qtv", XINE_VERSION_CODE, &qtv_dec_info, qtv_init_class }, + { PLUGIN_AUDIO_DECODER, 12, "qta", XINE_VERSION_CODE, &qta_dec_info, qta_init_class }, + { PLUGIN_NONE, 0, "", 0, NULL, NULL } +}; + diff --git a/src/libw32dll/qtx/Makefile.am b/src/libw32dll/qtx/Makefile.am new file mode 100644 index 000000000..96dc8d4e4 --- /dev/null +++ b/src/libw32dll/qtx/Makefile.am @@ -0,0 +1,13 @@ +SUBDIRS = qtxsdk + +debug: + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in + diff --git a/src/libw32dll/qtx/qtxsdk/Makefile.am b/src/libw32dll/qtx/qtxsdk/Makefile.am new file mode 100644 index 000000000..87991c24f --- /dev/null +++ b/src/libw32dll/qtx/qtxsdk/Makefile.am @@ -0,0 +1,18 @@ +noinst_HEADERS = components.h select.h + +debug: + @list='$(SUBDIRS)'; for subdir in $$list; do \ + (cd $$subdir && $(MAKE) $@) || exit;\ + done; + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" + +install-debug: debug + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in diff --git a/src/libw32dll/qtx/qtxsdk/components.h b/src/libw32dll/qtx/qtxsdk/components.h new file mode 100644 index 000000000..9d1b167be --- /dev/null +++ b/src/libw32dll/qtx/qtxsdk/components.h @@ -0,0 +1,720 @@ +// Basic types: + +typedef char * Ptr;
+typedef Ptr * Handle;
+typedef long Size;
+typedef unsigned char Boolean;
+typedef unsigned char Str31[32];
+typedef long Fixed;
+ +typedef long OSErr; +typedef int OSType; + +typedef long ComponentResult; +typedef unsigned char UInt8;
+typedef signed char SInt8;
+typedef unsigned short UInt16;
+typedef signed short SInt16;
+typedef unsigned long UInt32;
+typedef signed long SInt32;
+ +#define FOUR_CHAR_CODE(x) ((unsigned long)(x)) /* otherwise compiler will complain about values with high bit set */
+ +// codec private shit: +typedef void *GlobalsPtr; +typedef void **Globals;
+ +//==================== COMPONENTS =========================== + +struct __attribute__((__packed__)) ComponentParameters {
+ UInt8 flags; /* call modifiers: sync/async, deferred, immed, etc */
+ UInt8 paramSize; /* size in bytes of actual parameters passed to this call */
+ short what; /* routine selector, negative for Component management calls */
+ long params[1]; /* actual parameters for the indicated routine */
+};
+typedef struct ComponentParameters ComponentParameters;
+ + +struct __attribute__((__packed__)) ComponentDescription {
+ OSType componentType; /* A unique 4-byte code indentifying the command set */
+ OSType componentSubType; /* Particular flavor of this instance */
+ OSType componentManufacturer; /* Vendor indentification */
+ unsigned long componentFlags; /* 8 each for Component,Type,SubType,Manuf/revision */
+ unsigned long componentFlagsMask; /* Mask for specifying which flags to consider in search, zero during registration */
+};
+typedef struct ComponentDescription ComponentDescription;
+ + +struct __attribute__((__packed__)) ResourceSpec {
+ OSType resType; /* 4-byte code */
+ short resID; /* */
+};
+typedef struct ResourceSpec ResourceSpec;
+
+ +struct __attribute__((__packed__)) ComponentResource {
+ ComponentDescription cd; /* Registration parameters */
+ ResourceSpec component; /* resource where Component code is found */
+ ResourceSpec componentName; /* name string resource */
+ ResourceSpec componentInfo; /* info string resource */
+ ResourceSpec componentIcon; /* icon resource */
+};
+typedef struct ComponentResource ComponentResource;
+typedef ComponentResource * ComponentResourcePtr;
+typedef ComponentResourcePtr * ComponentResourceHandle;
+ +
+struct __attribute__((__packed__)) ComponentRecord {
+ long data[1];
+};
+typedef struct ComponentRecord ComponentRecord;
+typedef ComponentRecord * Component;
+ +
+struct __attribute__((__packed__)) ComponentInstanceRecord {
+ long data[1];
+};
+typedef struct ComponentInstanceRecord ComponentInstanceRecord;
+
typedef ComponentInstanceRecord * ComponentInstance;
+ +// ========================= QUICKDRAW ========================= + +struct __attribute__((__packed__)) Rect {
+ short top;
+ short left;
+ short bottom;
+ short right;
+};
+typedef struct Rect Rect;
+typedef Rect * RectPtr;
+ +struct __attribute__((__packed__)) RGBColor {
+ unsigned short red; /*magnitude of red component*/
+ unsigned short green; /*magnitude of green component*/
+ unsigned short blue; /*magnitude of blue component*/
+};
+typedef struct RGBColor RGBColor;
+typedef RGBColor * RGBColorPtr;
+typedef RGBColorPtr * RGBColorHdl;
+ +struct __attribute__((__packed__)) ColorSpec {
+ short value; /*index or other value*/
+ RGBColor rgb; /*true color*/
+};
+typedef struct ColorSpec ColorSpec;
+typedef ColorSpec * ColorSpecPtr;
+typedef ColorSpec CSpecArray[1];
+
+struct __attribute__((__packed__)) ColorTable {
+ long ctSeed; /*unique identifier for table*/
+ short ctFlags; /*high bit: 0 = PixMap; 1 = device*/
+ short ctSize; /*number of entries in CTTable*/
+ CSpecArray ctTable; /*array [0..0] of ColorSpec*/
+};
+typedef struct ColorTable ColorTable;
+typedef ColorTable * CTabPtr;
+typedef CTabPtr * CTabHandle;
+ +struct __attribute__((__packed__)) MatrixRecord {
+ Fixed matrix[3][3];
+};
+typedef struct MatrixRecord MatrixRecord;
+typedef MatrixRecord * MatrixRecordPtr;
+ +typedef long ImageSequence;
+typedef OSType CodecType;
+typedef unsigned short CodecFlags;
+typedef unsigned long CodecQ;
+ +struct __attribute__((__packed__)) ImageDescription {
+ long idSize; /* total size of ImageDescription including extra data ( CLUTs and other per sequence data ) */
+ CodecType cType; /* what kind of codec compressed this data */
+ long resvd1; /* reserved for Apple use */
+ short resvd2; /* reserved for Apple use */
+ short dataRefIndex; /* set to zero */
+ short version; /* which version is this data */
+ short revisionLevel; /* what version of that codec did this */
+ long vendor; /* whose codec compressed this data */
+ CodecQ temporalQuality; /* what was the temporal quality factor */
+ CodecQ spatialQuality; /* what was the spatial quality factor */
+ short width; /* how many pixels wide is this data */
+ short height; /* how many pixels high is this data */
+ Fixed hRes; /* horizontal resolution */
+ Fixed vRes; /* vertical resolution */
+ long dataSize; /* if known, the size of data for this image descriptor */
+ short frameCount; /* number of frames this description applies to */
+ Str31 name; /* name of codec ( in case not installed ) */
+ short depth; /* what depth is this data (1-32) or ( 33-40 grayscale ) */
+ short clutID; /* clut id or if 0 clut follows or -1 if no clut */
+};
+typedef struct ImageDescription ImageDescription;
+typedef ImageDescription * ImageDescriptionPtr;
+typedef ImageDescriptionPtr * ImageDescriptionHandle;
+ +/* values for PixMap.pixelFormat*/
+enum {
+ k16LE555PixelFormat = FOUR_CHAR_CODE('L555'), /* 16 bit LE rgb 555 (PC)*/
+ k16LE5551PixelFormat = FOUR_CHAR_CODE('5551'), /* 16 bit LE rgb 5551*/
+ k16BE565PixelFormat = FOUR_CHAR_CODE('B565'), /* 16 bit BE rgb 565*/
+ k16LE565PixelFormat = FOUR_CHAR_CODE('L565'), /* 16 bit LE rgb 565*/
+ k24BGRPixelFormat = FOUR_CHAR_CODE('24BG'), /* 24 bit bgr */
+ k32BGRAPixelFormat = FOUR_CHAR_CODE('BGRA'), /* 32 bit bgra (Matrox)*/
+ k32ABGRPixelFormat = FOUR_CHAR_CODE('ABGR'), /* 32 bit abgr */
+ k32RGBAPixelFormat = FOUR_CHAR_CODE('RGBA'), /* 32 bit rgba */
+ kYUVSPixelFormat = FOUR_CHAR_CODE('yuvs'), /* YUV 4:2:2 byte ordering 16-unsigned = 'YUY2'*/
+ kYUVUPixelFormat = FOUR_CHAR_CODE('yuvu'), /* YUV 4:2:2 byte ordering 16-signed*/
+ kYVU9PixelFormat = FOUR_CHAR_CODE('YVU9'), /* YVU9 Planar 9*/
+ kYUV411PixelFormat = FOUR_CHAR_CODE('Y411'), /* YUV 4:1:1 Interleaved 16*/
+ kYVYU422PixelFormat = FOUR_CHAR_CODE('YVYU'), /* YVYU 4:2:2 byte ordering 16*/
+ kUYVY422PixelFormat = FOUR_CHAR_CODE('UYVY'), /* UYVY 4:2:2 byte ordering 16*/
+ kYUV211PixelFormat = FOUR_CHAR_CODE('Y211'), /* YUV 2:1:1 Packed 8*/
+ k2vuyPixelFormat = FOUR_CHAR_CODE('2vuy') /* UYVY 4:2:2 byte ordering 16*/
+};
+ +struct __attribute__((__packed__)) PixMapExtension {
+ long extSize; /*size of struct, duh!*/
+ unsigned long pmBits; /*pixmap attributes bitfield*/
+ void * pmGD; /*this is a GDHandle*/
+ long pmSeed;
+ Fixed gammaLevel; /*pixmap gammalevel*/
+ Fixed requestedGammaLevel;
+ unsigned long reserved2;
+ long longRowBytes; /*used when rowBytes > 16382*/
+ unsigned long signature;
+ Handle baseAddrHandle;
+};
+typedef struct PixMapExtension PixMapExtension;
+
+typedef PixMapExtension * PixMapExtPtr;
+typedef PixMapExtPtr * PixMapExtHandle;
+ + +struct __attribute__((__packed__)) PixMap {
+ Ptr baseAddr; /*pointer to pixels*/
+ short rowBytes; /*offset to next line*/
+ Rect bounds; /*encloses bitmap*/
+ short pmVersion; /*pixMap version number*/
+ short packType; /*defines packing format*/
+ long packSize; /*length of pixel data*/
+ Fixed hRes; /*horiz. resolution (ppi)*/
+ Fixed vRes; /*vert. resolution (ppi)*/
+ short pixelType; /*defines pixel type*/
+ short pixelSize; /*# bits in pixel*/
+ short cmpCount; /*# components in pixel*/
+ short cmpSize; /*# bits per component*/
+ OSType pixelFormat; /*fourCharCode representation*/
+ CTabHandle pmTable; /*color map for this pixMap*/
+ PixMapExtHandle pmExt; /*Handle to pixMap extension*/
+};
+typedef struct PixMap PixMap;
+typedef PixMap * PixMapPtr;
+typedef PixMapPtr * PixMapHandle;
+ + +struct __attribute__((__packed__)) BitMap {
+ Ptr baseAddr;
+ short rowBytes;
+ Rect bounds;
+};
+typedef struct BitMap BitMap;
+typedef BitMap * BitMapPtr;
+typedef BitMapPtr * BitMapHandle;
+typedef struct OpaqueRgnHandle* RgnHandle;
+ +struct Pattern { + UInt8 pat[8]; +}; +typedef struct Pattern Pattern; +typedef unsigned char Style; +typedef Style StyleField; +struct __attribute__((__packed__)) Point { + short v; + short h; +}; +typedef struct Point Point; +struct __attribute__((__packed__)) GrafPort { + short device; + BitMap portBits; + Rect portRect; + RgnHandle visRgn; + RgnHandle clipRgn; + Pattern bkPat; + Pattern fillPat; + Point pnLoc; + Point pnSize; + short pnMode; + Pattern pnPat; + short pnVis; + short txFont; + StyleField txFace; /*StyleField occupies 16-bits, but only first 8-bits are used*/ + UInt8 txFlags; /* QuickTime uses second 8 bits of StyleField for txFlags */ + short txMode; + short txSize; + Fixed spExtra; + long fgColor; + long bkColor; + short colrBit; + short patStretch; + Handle picSave; + Handle rgnSave; + Handle polySave; + /*QDProcsPtr*/void* grafProcs; +}; +typedef struct GrafPort GrafPort; +typedef GrafPort *GWorldPtr; +typedef GWorldPtr *GWorldHandle; +#define anyCodec ((CodecComponent)0) +enum { + /* transfer modes */ + srcCopy = 0, /*the 16 transfer modes*/ + srcOr = 1, + srcXor = 2, + srcBic = 3, + notSrcCopy = 4, + notSrcOr = 5, + notSrcXor = 6, + notSrcBic = 7, + patCopy = 8, + patOr = 9, + patXor = 10, + patBic = 11, + notPatCopy = 12, + notPatOr = 13, + notPatXor = 14, + notPatBic = 15, /* Special Text Transfer Mode */ + grayishTextOr = 49, + hilitetransfermode = 50, + hilite = 50, /* Arithmetic transfer modes */ + blend = 32, + addPin = 33, + addOver = 34, + subPin = 35, + addMax = 37, + adMax = 37, + subOver = 38, + adMin = 39, + ditherCopy = 64, /* Transparent mode constant */ + transparent = 36 +}; + +typedef unsigned long GWorldFlags; + + + +// ============================== CODECS =========================== + +typedef Component CompressorComponent; +typedef Component DecompressorComponent; +typedef Component CodecComponent; + +enum { + codecLosslessQuality = 0x00000400, + codecMaxQuality = 0x000003FF, + codecMinQuality = 0x00000000, + codecLowQuality = 0x00000100, + codecNormalQuality = 0x00000200, + codecHighQuality = 0x00000300 +}; + + + +// callbacks: +typedef void* ImageCodecDrawBandCompleteUPP;
+typedef long long ICMProgressProcRecord; +typedef long long ICMCompletionProcRecord; +typedef long long ICMDataProcRecord; +typedef void* ICMFrameTimePtr; +typedef void* CDSequenceDataSourcePtr; +typedef void* ICMFrameTimeInfoPtr; + +// graphics port +typedef struct OpaqueGrafPtr* GrafPtr;
+typedef GrafPtr CGrafPtr;
+ +
+/* codec capabilities flags */
+enum {
+ codecCanScale = 1L << 0,
// 1 + codecCanMask = 1L << 1,
// 2 + codecCanMatte = 1L << 2,
// 4 + codecCanTransform = 1L << 3,
// 8 + codecCanTransferMode = 1L << 4,
// 10 + codecCanCopyPrev = 1L << 5,
// 20 + codecCanSpool = 1L << 6,
// 40 + codecCanClipVertical = 1L << 7,
// 80 + codecCanClipRectangular = 1L << 8,
// 100 + codecCanRemapColor = 1L << 9,
// 200 + codecCanFastDither = 1L << 10,
// 400 + codecCanSrcExtract = 1L << 11,
// 800 + codecCanCopyPrevComp = 1L << 12,
// 1000 + codecCanAsync = 1L << 13,
// 2000 + codecCanMakeMask = 1L << 14,
// 4000 + codecCanShift = 1L << 15,
// 8000 + codecCanAsyncWhen = 1L << 16,
// 10000 + codecCanShieldCursor = 1L << 17,
// 20000 + codecCanManagePrevBuffer = 1L << 18,
// 40000 + codecHasVolatileBuffer = 1L << 19, // 80000 /* codec requires redraw after window movement */
+ codecWantsRegionMask = 1L << 20,
// 100000 + codecImageBufferIsOnScreen = 1L << 21, // 200000 /* old def of codec using overlay surface, = ( codecIsDirectToScreenOnly | codecUsesOverlaySurface | codecImageBufferIsOverlaySurface | codecSrcMustBeImageBuffer ) */
+ codecWantsDestinationPixels = 1L << 22,
// 400000 + codecWantsSpecialScaling = 1L << 23,
// 800000 + codecHandlesInputs = 1L << 24,
// 1000000 + codecCanDoIndirectSurface = 1L << 25, /* codec can handle indirect surface (GDI) */
+ codecIsSequenceSensitive = 1L << 26,
+ codecRequiresOffscreen = 1L << 27,
+ codecRequiresMaskBits = 1L << 28,
+ codecCanRemapResolution = 1L << 29,
+ codecIsDirectToScreenOnly = 1L << 30, /* codec can only decompress data to the screen */
+ codecCanLockSurface = 1L << 31 /* codec can lock destination surface, icm doesn't lock for you */
+};
+
+/* codec capabilities flags2 */
+enum {
+ codecUsesOverlaySurface = 1L << 0, /* codec uses overlay surface */
+ codecImageBufferIsOverlaySurface = 1L << 1, /* codec image buffer is overlay surface, the bits in the buffer are on the screen */
+ codecSrcMustBeImageBuffer = 1L << 2, /* codec can only source data from an image buffer */
+ codecImageBufferIsInAGPMemory = 1L << 4, /* codec image buffer is in AGP space, byte writes are OK */
+ codecImageBufferIsInPCIMemory = 1L << 5 /* codec image buffer is across a PCI bus; byte writes are bad */
+};
+
+/* codec condition flags */
+// FFD = 13 = 8+4+1 +enum {
+ codecConditionFirstBand = 1L << 0,
// 1 + codecConditionLastBand = 1L << 1,
// 2 + codecConditionFirstFrame = 1L << 2,
// 4 + codecConditionNewDepth = 1L << 3,
// 8 + codecConditionNewTransform = 1L << 4,
// 10 + codecConditionNewSrcRect = 1L << 5,
// 20 + codecConditionNewMask = 1L << 6,
// 40 + codecConditionNewMatte = 1L << 7,
// 80 + codecConditionNewTransferMode = 1L << 8,
// 100 + codecConditionNewClut = 1L << 9,
// 200 + codecConditionNewAccuracy = 1L << 10,
// 400 + codecConditionNewDestination = 1L << 11,
// 800 + codecConditionFirstScreen = 1L << 12,
// 1000 + codecConditionDoCursor = 1L << 13,
// 2000 + codecConditionCatchUpDiff = 1L << 14,
// 4000 + codecConditionMaskMayBeChanged = 1L << 15,
// 8000 + codecConditionToBuffer = 1L << 16,
// 10000 + codecConditionCodecChangedMask = 1L << 31
// 20000 +};
+
+ + +struct __attribute__((__packed__)) CodecCapabilities {
+ long flags;
+ short wantedPixelSize;
+ short extendWidth;
+ short extendHeight;
+ short bandMin;
+ short bandInc;
+ short pad;
+ unsigned long time;
+ long flags2; /* field new in QuickTime 4.0 */
+};
+typedef struct CodecCapabilities CodecCapabilities;
+ +struct __attribute__((__packed__)) CodecDecompressParams {
+ ImageSequence sequenceID; /* predecompress,banddecompress */
+ ImageDescriptionHandle imageDescription; /* predecompress,banddecompress */
+ Ptr data;
+ long bufferSize;
+ + long frameNumber;
+ long startLine;
+ long stopLine;
+ long conditionFlags;
+ + CodecFlags callerFlags;
// short + CodecCapabilities * capabilities; /* predecompress,banddecompress */
+ ICMProgressProcRecord progressProcRecord;
+ ICMCompletionProcRecord completionProcRecord;
+ + ICMDataProcRecord dataProcRecord;
+ CGrafPtr port; /* predecompress,banddecompress */
+ PixMap dstPixMap; /* predecompress,banddecompress */
+ BitMapPtr maskBits;
+ PixMapPtr mattePixMap;
+ Rect srcRect; /* predecompress,banddecompress */
+ MatrixRecord * matrix; /* predecompress,banddecompress */
+ CodecQ accuracy; /* predecompress,banddecompress */
+ short transferMode; /* predecompress,banddecompress */
+ ICMFrameTimePtr frameTime; /* banddecompress */
+ long reserved[1];
+
+ /* The following fields only exist for QuickTime 2.0 and greater */
+ SInt8 matrixFlags; /* high bit set if 2x resize */
+ SInt8 matrixType;
+ Rect dstRect; /* only valid for simple transforms */
+
+ /* The following fields only exist for QuickTime 2.1 and greater */
+ UInt16 majorSourceChangeSeed;
+ UInt16 minorSourceChangeSeed;
+ CDSequenceDataSourcePtr sourceData;
+
+ RgnHandle maskRegion;
+
+ /* The following fields only exist for QuickTime 2.5 and greater */
+ OSType ** wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
+
+ long screenFloodMethod;
+ long screenFloodValue;
+ short preferredOffscreenPixelSize;
+
+ /* The following fields only exist for QuickTime 3.0 and greater */
+ ICMFrameTimeInfoPtr syncFrameTime; /* banddecompress */
+ Boolean needUpdateOnTimeChange; /* banddecompress */
+ Boolean enableBlackLining;
+ Boolean needUpdateOnSourceChange; /* band decompress */
+ Boolean pad;
+
+ long unused;
+
+ CGrafPtr finalDestinationPort;
+
+ long requestedBufferWidth; /* must set codecWantsSpecialScaling to indicate this field is valid*/
+ long requestedBufferHeight; /* must set codecWantsSpecialScaling to indicate this field is valid*/
+
+ /* The following fields only exist for QuickTime 4.0 and greater */
+ Rect displayableAreaOfRequestedBuffer; /* set in predecompress*/
+ Boolean requestedSingleField;
+ Boolean needUpdateOnNextIdle;
+ Boolean pad2[2];
+ Fixed bufferGammaLevel;
+
+ /* The following fields only exist for QuickTime 5.0 and greater */
+ UInt32 taskWeight; /* preferred weight for MP tasks implementing this operation*/
+ OSType taskName; /* preferred name (type) for MP tasks implementing this operation*/
+};
+typedef struct CodecDecompressParams CodecDecompressParams;
+ + + +struct __attribute__((__packed__)) ImageSubCodecDecompressCapabilities {
+ long recordSize; /* sizeof(ImageSubCodecDecompressCapabilities)*/
+ long decompressRecordSize; /* size of your codec's decompress record*/
+ Boolean canAsync; /* default true*/
+ UInt8 pad0;
+
+ /* The following fields only exist for QuickTime 4.0 and greater */
+ UInt16 suggestedQueueSize;
+ Boolean canProvideTrigger;
+
+ /* The following fields only exist for QuickTime 5.0 and greater */
+ Boolean subCodecFlushesScreen; /* only used on Mac OS X*/
+ Boolean subCodecCallsDrawBandComplete;
+ UInt8 pad2[1];
+
+ /* The following fields only exist for QuickTime 5.1 and greater */
+ Boolean isChildCodec; /* set by base codec before calling Initialize*/
+ UInt8 pad3[3];
+};
+typedef struct ImageSubCodecDecompressCapabilities ImageSubCodecDecompressCapabilities;
+ + +struct __attribute__((__packed__)) ImageSubCodecDecompressRecord {
+ Ptr baseAddr;
+ long rowBytes;
+ Ptr codecData;
+ ICMProgressProcRecord progressProcRecord;
+ ICMDataProcRecord dataProcRecord;
+ void * userDecompressRecord; /* pointer to codec-specific per-band data*/
+ UInt8 frameType;
+ Boolean inhibitMP; /* set this in BeginBand to tell the base decompressor not to call DrawBand from an MP task for this frame. (Only has any effect for MP-capable subcodecs. New in QuickTime 5.0.)*/
+ UInt8 pad[2];
+ long priv[2];
+
+ /* The following fields only exist for QuickTime 5.0 and greater */
+ ImageCodecDrawBandCompleteUPP drawBandCompleteUPP; /* only used if subcodec set subCodecCallsDrawBandComplete; if drawBandCompleteUPP is non-nil, codec must call it when a frame is finished, but may return from DrawBand before the frame is finished. */
+ void * drawBandCompleteRefCon; /* Note: do not call drawBandCompleteUPP directly from a hardware interrupt; instead, use DTInstall to run a function at deferred task time, and call drawBandCompleteUPP from that. */
+};
+typedef struct ImageSubCodecDecompressRecord ImageSubCodecDecompressRecord;
+ + +/* These are the bits that are set in the Component flags, and also in the codecInfo struct. */
+enum {
+ codecInfoDoes1 = (1L << 0), /* codec can work with 1-bit pixels */
+ codecInfoDoes2 = (1L << 1), /* codec can work with 2-bit pixels */
+ codecInfoDoes4 = (1L << 2), /* codec can work with 4-bit pixels */
+ codecInfoDoes8 = (1L << 3), /* codec can work with 8-bit pixels */
+ codecInfoDoes16 = (1L << 4), /* codec can work with 16-bit pixels */
+ codecInfoDoes32 = (1L << 5), /* codec can work with 32-bit pixels */
+ codecInfoDoesDither = (1L << 6), /* codec can do ditherMode */
+ codecInfoDoesStretch = (1L << 7), /* codec can stretch to arbitrary sizes */
+ codecInfoDoesShrink = (1L << 8), /* codec can shrink to arbitrary sizes */
+ codecInfoDoesMask = (1L << 9), /* codec can mask to clipping regions */
+ codecInfoDoesTemporal = (1L << 10), /* codec can handle temporal redundancy */
+ codecInfoDoesDouble = (1L << 11), /* codec can stretch to double size exactly */
+ codecInfoDoesQuad = (1L << 12), /* codec can stretch to quadruple size exactly */
+ codecInfoDoesHalf = (1L << 13), /* codec can shrink to half size */
+ codecInfoDoesQuarter = (1L << 14), /* codec can shrink to quarter size */
+ codecInfoDoesRotate = (1L << 15), /* codec can rotate on decompress */
+ codecInfoDoesHorizFlip = (1L << 16), /* codec can flip horizontally on decompress */
+ codecInfoDoesVertFlip = (1L << 17), /* codec can flip vertically on decompress */
+ codecInfoHasEffectParameterList = (1L << 18), /* codec implements get effects parameter list call, once was codecInfoDoesSkew */
+ codecInfoDoesBlend = (1L << 19), /* codec can blend on decompress */
+ codecInfoDoesWarp = (1L << 20), /* codec can warp arbitrarily on decompress */
+ codecInfoDoesRecompress = (1L << 21), /* codec can recompress image without accumulating errors */
+ codecInfoDoesSpool = (1L << 22), /* codec can spool image data */
+ codecInfoDoesRateConstrain = (1L << 23) /* codec can data rate constrain */
+};
+
+
+enum {
+ codecInfoDepth1 = (1L << 0), /* compressed data at 1 bpp depth available */
+ codecInfoDepth2 = (1L << 1), /* compressed data at 2 bpp depth available */
+ codecInfoDepth4 = (1L << 2), /* compressed data at 4 bpp depth available */
+ codecInfoDepth8 = (1L << 3), /* compressed data at 8 bpp depth available */
+ codecInfoDepth16 = (1L << 4), /* compressed data at 16 bpp depth available */
+ codecInfoDepth32 = (1L << 5), /* compressed data at 32 bpp depth available */
+ codecInfoDepth24 = (1L << 6), /* compressed data at 24 bpp depth available */
+ codecInfoDepth33 = (1L << 7), /* compressed data at 1 bpp monochrome depth available */
+ codecInfoDepth34 = (1L << 8), /* compressed data at 2 bpp grayscale depth available */
+ codecInfoDepth36 = (1L << 9), /* compressed data at 4 bpp grayscale depth available */
+ codecInfoDepth40 = (1L << 10), /* compressed data at 8 bpp grayscale depth available */
+ codecInfoStoresClut = (1L << 11), /* compressed data can have custom cluts */
+ codecInfoDoesLossless = (1L << 12), /* compressed data can be stored in lossless format */
+ codecInfoSequenceSensitive = (1L << 13) /* compressed data is sensitive to out of sequence decoding */
+};
+
+struct __attribute__((__packed__)) CodecInfo {
+ Str31 typeName; /* name of the codec type i.e.: 'Apple Image Compression' */
+ short version; /* version of the codec data that this codec knows about */
+ short revisionLevel; /* revision level of this codec i.e: 0x00010001 (1.0.1) */
+ long vendor; /* Maker of this codec i.e: 'appl' */
+ long decompressFlags; /* codecInfo flags for decompression capabilities */
+ long compressFlags; /* codecInfo flags for compression capabilities */
+ long formatFlags; /* codecInfo flags for compression format details */
+ UInt8 compressionAccuracy; /* measure (1-255) of accuracy of this codec for compress (0 if unknown) */
+ UInt8 decompressionAccuracy; /* measure (1-255) of accuracy of this codec for decompress (0 if unknown) */
+ unsigned short compressionSpeed; /* ( millisecs for compressing 320x240 on base mac II) (0 if unknown) */
+ unsigned short decompressionSpeed; /* ( millisecs for decompressing 320x240 on mac II)(0 if unknown) */
+ UInt8 compressionLevel; /* measure (1-255) of compression level of this codec (0 if unknown) */
+ UInt8 resvd; /* pad */
+ short minimumHeight; /* minimum height of image (block size) */
+ short minimumWidth; /* minimum width of image (block size) */
+ short decompressPipelineLatency; /* in milliseconds ( for asynchronous codecs ) */
+ short compressPipelineLatency; /* in milliseconds ( for asynchronous codecs ) */
+ long privateData;
+};
+typedef struct CodecInfo CodecInfo;
+ +static inline void dump_ImageDescription(void* xxx){ + ImageDescription* id=(ImageDescription*)xxx; + unsigned char* x; + int i; + + for(i=0;i<id->idSize;i++){ + printf(" %02X",((unsigned char*)id)[i]); + if((i%16)==15) printf("\n"); + } + printf("\n"); + + + printf("=============== ImageDescription at %p ==================\n",xxx); + printf("idSize=0x%X fourcc=0x%08X\n",id->idSize,id->cType); + printf("ver=%d rev=%d vendor=0x%08X\n",id->version,id->revisionLevel,id->vendor); + printf("tempQ=%d spatQ=%d dim: %d x %d dpi: %d x %d depth: %d\n", + id->temporalQuality,id->spatialQuality, + id->width, id->height, + id->hRes, id->vRes, + id->depth); + printf("dataSize=%d frameCount=%d clutID=%d\n",id->dataSize, id->frameCount, id->clutID); + printf("name='%.*s'\n",((char*)(&id->name))[0],((char*)(&id->name))+1); + x=((char*)(&id->clutID))+2; + if(id->idSize>sizeof(ImageDescription)){ + printf("%02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X\n", + x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15]); + } + printf("=========================================================\n"); +} + +static inline void dump_Rect(char* title,Rect *r){ + printf("%s: %d;%d - %d;%d\n",title, + (int)r->top,(int)r->left,(int)r->bottom,(int)r->right); +} + +static inline void dump_MatrixRecord(char* title, MatrixRecord *m){ + printf("%s: [%d %d %d][%d %d %d][%d %d %d]\n",title, + m->matrix[0][0],m->matrix[0][1],m->matrix[0][2], + m->matrix[1][0],m->matrix[1][1],m->matrix[1][2], + m->matrix[2][0],m->matrix[2][1],m->matrix[2][2]); +} + +static inline void dump_PixMap(void* xxx){ + PixMap *p=xxx; + printf("=============== PixMap at %p ==================\n",xxx); + printf("base=%p stride=%d\n",p->baseAddr, p->rowBytes); + dump_Rect("bounds",&p->bounds); + printf("pmVersion=0x%X packType=0x%X\n packSize=0x%X\n", + p->pmVersion,p->packType, p->packSize); + printf("hRes=0x%X vRes=0x%X pixelType=0x%X pixelSize=0x%X\n", + p->hRes,p->vRes,p->pixelType,p->pixelSize); + printf("cmpCount=0x%X cmpSize=0x%X pixelFormat=0x%X\n", + p->cmpCount,p->cmpSize,p->pixelFormat); + printf("pmTable=%p pmExt=%p\n",p->pmTable,p->pmExt); + printf("=========================================================\n"); +} + +static inline void dump_CodecCapabilities(void* xxx){ + CodecCapabilities* cc=xxx; + if(!xxx) return; + printf("=============== CodecCapabilities at %p =================\n",xxx); + printf("flags=0x%X flags2=0x%X\n",cc->flags,cc->flags2); + printf("wantedPixelSize=%d extendWidth=%d extendHeight=%d band=%d+%d\n", + cc->wantedPixelSize,cc->extendWidth,cc->extendHeight, + cc->bandMin,cc->bandInc); + printf("pad=0x%X time=0x%X\n",cc->pad,cc->time); + printf("=========================================================\n"); +} + +static inline void dump_CodecDecompressParams(void* xxx){ + CodecDecompressParams* cd=xxx; + ImageDescription **idh; + int i; + if(!xxx) return; + printf("=============== CodecDecompressParams at %p ==================\n",xxx); + printf("sequenceID=%d\n",cd->sequenceID); + idh=cd->imageDescription; + if(idh && idh[0]) dump_ImageDescription(idh[0]); + + for(i=0;i<sizeof(CodecDecompressParams);i++){ + printf(" %02X",((unsigned char*)cd)[i]); + if((i%16)==15) printf("\n"); + } + printf("\n"); + + printf("data=%p size=%d\n",cd->data,cd->bufferSize); + printf("frameno=%d lines: %d .. %d condflags=0x%X callerflags=0x%X\n", + cd->frameNumber, cd->startLine, cd->stopLine, cd->conditionFlags,cd->callerFlags); +// printf("maskBits=%p mattePixMap=%p\n", +// cd->maskBits,cd->mattePixMap); + dump_PixMap(&cd->dstPixMap); +// if(cd->mattePixMap) dump_PixMap(cd->mattePixMap); + if(cd->matrix) dump_MatrixRecord("matrix",cd->matrix); + if(cd->capabilities) dump_CodecCapabilities(cd->capabilities); + printf("accuracy=%d transferMode=%d matrixFlags=0x%X matrixType=%d\n", + (int)cd->accuracy, (int)cd->transferMode, (int)cd->matrixFlags, (int)cd->matrixType); + printf("srcrect: %d;%d - %d;%d\n",cd->srcRect.top,cd->srcRect.left,cd->srcRect.bottom,cd->srcRect.right); + printf("dstrect: %d;%d - %d;%d\n",cd->dstRect.top,cd->dstRect.left,cd->dstRect.bottom,cd->dstRect.right); + printf("wantedDestinationPixelTypes=%p\n",cd->wantedDestinationPixelTypes); + if(cd->wantedDestinationPixelTypes){ + unsigned int* p=cd->wantedDestinationPixelTypes; + while(p[0]){ + printf(" 0x%08X %.4s\n",p[0],&p[0]); + ++p; + } + } + printf("screenFloodMethod=%d value=%d preferredOffscreenPixelSize=%d\n", + cd->screenFloodMethod, cd->screenFloodValue, cd->preferredOffscreenPixelSize); + printf("callbacks: progress=%p compl=%p data=%p ftime=%p srcdata=%p sync=%p\n", + cd->progressProcRecord, cd->completionProcRecord, + cd->dataProcRecord, cd->frameTime, cd->sourceData, cd->syncFrameTime); +// printf("\n"); + + printf("=========================================================\n"); + + +} + diff --git a/src/libw32dll/qtx/qtxsdk/select.h b/src/libw32dll/qtx/qtxsdk/select.h new file mode 100644 index 000000000..313cc5768 --- /dev/null +++ b/src/libw32dll/qtx/qtxsdk/select.h @@ -0,0 +1,68 @@ + +enum {
+ kComponentOpenSelect = -1, /* ComponentInstance for this open */
+ kComponentCloseSelect = -2, /* ComponentInstance for this close */
+ kComponentCanDoSelect = -3, /* selector # being queried */
+ kComponentVersionSelect = -4, /* no params */
+ kComponentRegisterSelect = -5, /* no params */
+ kComponentTargetSelect = -6, /* ComponentInstance for top of call chain */
+ kComponentUnregisterSelect = -7, /* no params */
+ kComponentGetMPWorkFunctionSelect = -8, /* some params */
+ kComponentExecuteWiredActionSelect = -9, /* QTAtomContainer actionContainer, QTAtom actionAtom, QTCustomActionTargetPtr target, QTEventRecordPtr event */
+ kComponentGetPublicResourceSelect = -10 /* OSType resourceType, short resourceId, Handle *resource */
+};
+ +/* selectors for component calls */
+enum {
+ kImageCodecGetCodecInfoSelect = 0x0000,
+ kImageCodecGetCompressionTimeSelect = 0x0001,
+ kImageCodecGetMaxCompressionSizeSelect = 0x0002,
+ kImageCodecPreCompressSelect = 0x0003,
+ kImageCodecBandCompressSelect = 0x0004,
+ kImageCodecPreDecompressSelect = 0x0005,
+ kImageCodecBandDecompressSelect = 0x0006,
+ kImageCodecBusySelect = 0x0007,
+ kImageCodecGetCompressedImageSizeSelect = 0x0008,
+ kImageCodecGetSimilaritySelect = 0x0009,
+ kImageCodecTrimImageSelect = 0x000A,
+ kImageCodecRequestSettingsSelect = 0x000B,
+ kImageCodecGetSettingsSelect = 0x000C,
+ kImageCodecSetSettingsSelect = 0x000D,
+ kImageCodecFlushSelect = 0x000E,
+ kImageCodecSetTimeCodeSelect = 0x000F,
+ kImageCodecIsImageDescriptionEquivalentSelect = 0x0010,
+ kImageCodecNewMemorySelect = 0x0011,
+ kImageCodecDisposeMemorySelect = 0x0012,
+ kImageCodecHitTestDataSelect = 0x0013,
+ kImageCodecNewImageBufferMemorySelect = 0x0014,
+ kImageCodecExtractAndCombineFieldsSelect = 0x0015,
+ kImageCodecGetMaxCompressionSizeWithSourcesSelect = 0x0016,
+ kImageCodecSetTimeBaseSelect = 0x0017,
+ kImageCodecSourceChangedSelect = 0x0018,
+ kImageCodecFlushFrameSelect = 0x0019,
+ kImageCodecGetSettingsAsTextSelect = 0x001A,
+ kImageCodecGetParameterListHandleSelect = 0x001B,
+ kImageCodecGetParameterListSelect = 0x001C,
+ kImageCodecCreateStandardParameterDialogSelect = 0x001D,
+ kImageCodecIsStandardParameterDialogEventSelect = 0x001E,
+ kImageCodecDismissStandardParameterDialogSelect = 0x001F,
+ kImageCodecStandardParameterDialogDoActionSelect = 0x0020,
+ kImageCodecNewImageGWorldSelect = 0x0021,
+ kImageCodecDisposeImageGWorldSelect = 0x0022,
+ kImageCodecHitTestDataWithFlagsSelect = 0x0023,
+ kImageCodecValidateParametersSelect = 0x0024,
+ kImageCodecGetBaseMPWorkFunctionSelect = 0x0025,
+ kImageCodecRequestGammaLevelSelect = 0x0028,
+ kImageCodecGetSourceDataGammaLevelSelect = 0x0029,
+ kImageCodecGetDecompressLatencySelect = 0x002B,
+ kImageCodecPreflightSelect = 0x0200,
+ kImageCodecInitializeSelect = 0x0201,
+ kImageCodecBeginBandSelect = 0x0202,
+ kImageCodecDrawBandSelect = 0x0203,
+ kImageCodecEndBandSelect = 0x0204,
+ kImageCodecQueueStartingSelect = 0x0205,
+ kImageCodecQueueStoppingSelect = 0x0206,
+ kImageCodecDroppingFrameSelect = 0x0207,
+ kImageCodecScheduleFrameSelect = 0x0208,
+ kImageCodecCancelTriggerSelect = 0x0209
+};
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c index df3e23bae..29bdc093c 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.108 2002/12/12 01:52:21 miguelfreitas Exp $ + * $Id: w32codec.c,v 1.109 2002/12/18 04:00:49 guenter Exp $ * * routines for using w32 codecs * DirectShow support by Miguel Freitas (Nov/2001) @@ -47,9 +47,9 @@ #include "buffer.h" #include "xineutils.h" -/* + #define LOG -*/ + static GUID CLSID_Voxware = { @@ -99,7 +99,7 @@ static GUID mss1_clsid = */ static pthread_mutex_t win32_codec_mutex; static pthread_once_t once_control = PTHREAD_ONCE_INIT; -extern char* win32_codec_name; +static char* win32_codec_name; extern char* win32_def_path; #define VIDEOBUFSIZE 128*1024 diff --git a/src/libw32dll/wine/Makefile.am b/src/libw32dll/wine/Makefile.am index ecae2cdaa..48b3cee8f 100644 --- a/src/libw32dll/wine/Makefile.am +++ b/src/libw32dll/wine/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = stubs.s +EXTRA_DIST = stubs.s wrapper.S noinst_LTLIBRARIES = $(wine_lib) @@ -33,7 +33,7 @@ libwine_la_SOURCES = \ vfl.c \ win32.c -libwine_la_LIBADD = stubs.lo +libwine_la_LIBADD = stubs.lo wrapper.lo noinst_HEADERS = \ avifmt.h \ @@ -70,11 +70,15 @@ noinst_HEADERS = \ winestring.h \ winnt.h \ winreg.h \ - winuser.h + winuser.h \ + wrapper.h stubs.lo: stubs.s $(CC) -c $(srcdir)/stubs.s -o stubs.lo +wrapper.lo: wrapper.S + $(CC) -c $(srcdir)/wrapper.S -o wrapper.lo + debug: @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" diff --git a/src/libw32dll/wine/afl.c b/src/libw32dll/wine/afl.c index a887ead80..6f3fb0eb6 100644 --- a/src/libw32dll/wine/afl.c +++ b/src/libw32dll/wine/afl.c @@ -39,6 +39,10 @@ #include "driver.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#pragma pack(1) #define OpenDriverA DrvOpen #define CloseDriver DrvClose @@ -215,7 +219,8 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe icopen.dwSize = sizeof(ICOPEN); icopen.dwFlags = 0; - if (!padid->hInstModule) + icopen.pV1Reserved = padid->pszFileName; + if (!padid->hInstModule) pad->hDrvr = OpenDriverA((long)&icopen); else pad->hDrvr = padid->hInstModule; @@ -267,22 +272,19 @@ PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL; /*********************************************************************** * MSACM_RegisterDriver32() */ -PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName, +PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName, + WORD wFormatTag, HINSTANCE hinstModule) -// -// File names are stored in driver.c. I reuse this variable to store driver ID -// in it. If it's <0x10000, it is primary codec for corresponding format. -// { PWINE_ACMDRIVERID padid; - TRACE("('%s', '%x', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule); + TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule); padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)); - padid->pszDriverAlias = (char*)malloc(strlen(pszDriverAlias)+1); - strcpy(padid->pszDriverAlias, pszDriverAlias); + padid->pszFileName = (char*)malloc(strlen(pszFileName)+1); + strcpy(padid->pszFileName, pszFileName); // 1~strdup(pszDriverAlias); - padid->pszFileName = pszFileName; + padid->wFormatTag = wFormatTag; padid->hInstModule = hinstModule; padid->bEnabled = TRUE; padid->pACMDriverList = NULL; @@ -297,23 +299,6 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName, return padid; } -/*********************************************************************** - * MSACM_RegisterAllDrivers32() - */ -void MSACM_RegisterAllDrivers(void) -{ - /*LPSTR pszBuffer; - DWORD dwBufferLength; -- not used */ - - if (MSACM_pFirstACMDriverID) - return; - - MSACM_RegisterDriver("divxa32", (LPSTR)0x161, 0); // DivX/WMA [07] - MSACM_RegisterDriver("msadp32", (LPSTR)0x2, 0); // MS ADPCM [08] - MSACM_RegisterDriver("l3codeca", (LPSTR)0x55, 0); // MPEG Layer-3 [12] -// MSACM_RegisterDriver("imaadp32", (LPSTR)0x11, 0); // IMA ADPCM [13] -// MSACM_RegisterDriver("msgsm32", (LPSTR)0x32, 0); // MS GSM 6.10 [14] -} /*********************************************************************** * MSACM_UnregisterDriver32() @@ -325,10 +310,8 @@ PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p) while (p->pACMDriverList) acmDriverClose((HACMDRIVER) p->pACMDriverList, 0); - if (p->pszDriverAlias) - HeapFree(MSACM_hHeap, 0, p->pszDriverAlias); -// if (p->pszFileName) -// HeapFree(MSACM_hHeap, 0, p->pszFileName); + if (p->pszFileName) + free(p->pszFileName); if (p == MSACM_pFirstACMDriverID) MSACM_pFirstACMDriverID = p->pNextACMDriverID; @@ -398,8 +381,6 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw int wfxSrcSize; int wfxDstSize; - //printf("gcc-3.0 bug, pwfxSrc=%p, pwfxSrc->cbSize=%d\n", pwfxSrc, pwfxSrc->cbSize); - TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n", phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen); @@ -416,13 +397,15 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw wfxDstSize = SIZEOF_WFX(pwfxDst); #undef SIZEOF_WFX - was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0)); + was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0)); if (was == NULL) return MMSYSERR_NOMEM; - was->drvInst.cbStruct = sizeof(was->drvInst); was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was)); memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize); + // LHACM is checking for 0x1 + // but if this will not help + // was->drvInst.pwfxSrc->wFormatTag = 1; was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize); memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize); if (pwfltr) { @@ -479,10 +462,14 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw } } acmDriverClose(had, 0L);*/ - if(MSACM_pFirstACMDriverID==NULL) - MSACM_RegisterAllDrivers(); + //if(MSACM_pFirstACMDriverID==NULL) + // MSACM_RegisterAllDrivers(); - for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) { + for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) + { + /* Check Format */ + if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue; + ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L); if (ret == MMSYSERR_NOERROR) { if ((wad = MSACM_GetDriver(had)) != 0) { @@ -491,6 +478,8 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw was->hAcmDriver = had; ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L); + //lhacm - crash printf("RETOPEN %d\n", ret); + //ret = 0; if (ret == MMSYSERR_NOERROR) { if (fdwOpen & ACM_STREAMOPENF_QUERY) { acmDriverClose(had, 0L); diff --git a/src/libw32dll/wine/com.h b/src/libw32dll/wine/com.h index 84a667f0f..50d47a7f2 100644 --- a/src/libw32dll/wine/com.h +++ b/src/libw32dll/wine/com.h @@ -27,12 +27,12 @@ typedef struct } GUID; #endif -extern GUID IID_IUnknown; -extern GUID IID_IClassFactory; +extern const GUID IID_IUnknown; +extern const GUID IID_IClassFactory; -typedef long (*GETCLASSOBJECT) (GUID* clsid, GUID* iid, void** ppv); -int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs); -int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs); +typedef long (*GETCLASSOBJECT) (GUID* clsid, const GUID* iid, void** ppv); +int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs); +int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs); #ifndef STDCALL #define STDCALL __attribute__((__stdcall__)) @@ -42,7 +42,7 @@ struct IUnknown; struct IClassFactory; struct IUnknown_vt { - long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv); + long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv); long STDCALL (*AddRef)(struct IUnknown* _this) ; long STDCALL (*Release)(struct IUnknown* _this) ; } ; @@ -54,10 +54,10 @@ typedef struct IUnknown struct IClassFactory_vt { - long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv); + long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv); long STDCALL (*AddRef)(struct IUnknown* _this) ; long STDCALL (*Release)(struct IUnknown* _this) ; - long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, GUID* riid, void** ppvObject); + long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, const GUID* riid, void** ppvObject); }; struct IClassFactory @@ -66,7 +66,7 @@ struct IClassFactory }; long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, - long dwClsContext, GUID* riid, void** ppv); + long dwClsContext, const GUID* riid, void** ppv); #ifdef __cplusplus }; diff --git a/src/libw32dll/wine/driver.c b/src/libw32dll/wine/driver.c index 822d0167f..8dea4b85f 100644 --- a/src/libw32dll/wine/driver.c +++ b/src/libw32dll/wine/driver.c @@ -9,29 +9,34 @@ #endif #include "win32.h" +#include "driver.h" #include "pe_image.h" #include "winreg.h" #include "vfw.h" #include "registry.h" #include "ldt_keeper.h" -#include "driver.h" + +extern char* win32_def_path; #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 is no longer needed #define STORE_ALL \ - __asm__( \ + __asm__ __volatile__ ( \ "push %%ebx\n\t" \ "push %%ecx\n\t" \ "push %%edx\n\t" \ @@ -39,7 +44,7 @@ "push %%edi\n\t"::) #define REST_ALL \ - __asm__( \ + __asm__ __volatile__ ( \ "pop %%edi\n\t" \ "pop %%esi\n\t" \ "pop %%edx\n\t" \ @@ -47,182 +52,123 @@ "pop %%ebx\n\t"::) #endif +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; + } + win32_def_path = (char*) malloc(strlen(path)+1); + strcpy(win32_def_path, path); + needs_free=1; +} - - static DWORD dwDrvID = 0; - -LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message, - LPARAM lParam1, LPARAM lParam2 ) +LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message, + LPARAM lParam1, LPARAM lParam2) { DRVR* module=(DRVR*)hDriver; int result; -#ifdef DETAILED_OUT +#ifndef __svr4__ + char qw[300]; +#endif +#ifdef DETAILED_OUT printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2); #endif - if(module==0)return -1; - if(module->hDriverModule==0)return -1; - if(module->DriverProc==0)return -1; + if (!module || !module->hDriverModule || !module->DriverProc) return -1; +#ifndef __svr4__ + __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); +#endif + + Setup_FS_Segment(); + STORE_ALL; - result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2); + result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2); REST_ALL; -#ifdef DETAILED_OUT + +#ifndef __svr4__ + __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); +#endif + +#ifdef DETAILED_OUT printf("\t\tResult: %X\n", result); #endif return result; } -static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult) +void DrvClose(HDRVR hDriver) { - NPDRVR npDriver; - /* allocate and lock handle */ - if (lpDriver) + if (hDriver) { - if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) ) - { - if ((npDriver = (NPDRVR) *lpDriver)) - { - *lpDrvResult = MMSYSERR_NOERROR; - return (npDriver); - } - free((NPDRVR)*lpDriver); - } - return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0); - } - return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0); -} - - -static void DrvFree(HDRVR hDriver) -{ - /* int i; -- unused */ - Setup_FS_Segment(); - 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; + DRVR* d = (DRVR*)hDriver; + if (d->hDriverModule) + { + Setup_FS_Segment(); + if (d->DriverProc) + { + SendDriverMessage(hDriver, DRV_CLOSE, 0, 0); + d->dwDriverID = 0; + SendDriverMessage(hDriver, DRV_FREE, 0, 0); + } + FreeLibrary(d->hDriverModule); + } + free(d); } -} - -void DrvClose(HDRVR hdrvr) -{ - DrvFree(hdrvr); CodecRelease(); } - -char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!! - -HDRVR VFWAPI -DrvOpen(LPARAM lParam2) +//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2) +HDRVR DrvOpen(LPARAM lParam2) { - /* ICOPEN *icopen=(ICOPEN *) lParam2; -- unused */ - UINT uDrvResult; - HDRVR hDriver; - NPDRVR npDriver; - char unknown[0x24]; -// char* codec_name=icopen->fccHandler; + NPDRVR hDriver; + int i; + char unknown[0x124]; + const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved; - Setup_FS_Segment(); + Setup_LDT_Keeper(); + printf("Loading codec DLL: '%s'\n",filename); - if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult))) + hDriver = (NPDRVR) malloc(sizeof(DRVR)); + if (!hDriver) return ((HDRVR) 0); + memset((void*)hDriver, 0, sizeof(DRVR)); - if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) { - printf("Can't open library %s\n", win32_codec_name); - DrvFree(hDriver); - return ((HDRVR) 0); - } + CodecAlloc(); + Setup_FS_Segment(); -#if 0 + hDriver->hDriverModule = LoadLibraryA(filename); + if (!hDriver->hDriverModule) { - 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; + printf("Can't open library %s\n", filename); + DrvClose((HDRVR)hDriver); + return ((HDRVR) 0); } -#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 - - FreeLibrary(npDriver->hDriverModule); - DrvFree(hDriver); - return ((HDRVR) 0); + hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule, + "DriverProc"); + if (!hDriver->DriverProc) + { + printf("Library %s is not a valid VfW/ACM codec\n", filename); + DrvClose((HDRVR)hDriver); + return ((HDRVR) 0); } - //TRACE("DriverProc == %X\n", npDriver->DriverProc); - npDriver->dwDriverID = ++dwDrvID; - - Setup_FS_Segment(); + TRACE("DriverProc == %X\n", hDriver->DriverProc); + SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0); + TRACE("DRV_LOAD Ok!\n"); + SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0); + TRACE("DRV_ENABLE Ok!\n"); + hDriver->dwDriverID = ++dwDrvID; // generate new id - 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 and remmeber proper DriverID + hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2); + TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID); - // open driver - STORE_ALL; - npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN, - (LPARAM) (LPSTR) unknown, lParam2); - REST_ALL; - - //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID); - - if (uDrvResult) - { - DrvFree(hDriver); - hDriver = (HDRVR) 0; - } - -// printf("Successfully loaded codec %s\n",win32_codec_name); - - CodecAlloc(); - return (hDriver); + printf("Loaded DLL driver %s\n", filename); + return (HDRVR)hDriver; } - diff --git a/src/libw32dll/wine/elfdll.c b/src/libw32dll/wine/elfdll.c index fd4712fcd..ecee7a28c 100644 --- a/src/libw32dll/wine/elfdll.c +++ b/src/libw32dll/wine/elfdll.c @@ -22,16 +22,6 @@ #include <ctype.h> #include <dlfcn.h> -struct modref_list_t; - -typedef struct modref_list_t -{ - WINE_MODREF* wm; - struct modref_list_t *next; - struct modref_list_t *prev; -} -modref_list; - //WINE_MODREF *local_wm=NULL; extern modref_list* local_wm; diff --git a/src/libw32dll/wine/ldt_keeper.c b/src/libw32dll/wine/ldt_keeper.c index b7c611ddc..fef86c6bd 100644 --- a/src/libw32dll/wine/ldt_keeper.c +++ b/src/libw32dll/wine/ldt_keeper.c @@ -1,7 +1,7 @@ /* - * Copyright (C) 2000-2001 the xine project + * Copyright (C) 2000-2002 the xine project * - * This file is part of xine, a unix video player. + * This file is part of xine, a free video player. * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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: ldt_keeper.c,v 1.4 2002/06/21 01:44:17 miguelfreitas Exp $ + * $Id: ldt_keeper.c,v 1.5 2002/12/18 04:00:53 guenter Exp $ * * * contents: @@ -202,6 +202,8 @@ static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt } #endif +void* fs_seg=0; + ldt_fs_t* Setup_LDT_Keeper(void) { struct modify_ldt_ldt_s array; @@ -216,6 +218,7 @@ ldt_fs_t* Setup_LDT_Keeper(void) perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); return NULL; } + fs_seg= ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, ldt_fs->fd, 0); if (ldt_fs->fs_seg == (void*)-1) diff --git a/src/libw32dll/wine/module.c b/src/libw32dll/wine/module.c index f7bee81d6..8e88fb5e6 100644 --- a/src/libw32dll/wine/module.c +++ b/src/libw32dll/wine/module.c @@ -3,6 +3,13 @@ * * Copyright 1995 Alexandre Julliard */ + +// define for quicktime calls debugging and/or MacOS-level emulation: +#define EMU_QTX_API + +// define for quicktime debugging (verbose logging): +//#define DEBUG_QTX_API + #include "config.h" #include <assert.h> @@ -29,18 +36,15 @@ #include "win32.h" #include "driver.h" +#ifdef EMU_QTX_API +#include "wrapper.h" +static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); +static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); +#endif + //#undef TRACE //#define TRACE printf -struct modref_list_t; - -typedef struct modref_list_t -{ - WINE_MODREF* wm; - struct modref_list_t *next; - struct modref_list_t *prev; -} modref_list; - //WINE_MODREF *local_wm=NULL; modref_list* local_wm=NULL; @@ -49,10 +53,11 @@ HANDLE SegptrHeap; WINE_MODREF* MODULE_FindModule(LPCSTR m) { modref_list* list=local_wm; - TRACE("Module %s request\n", m); + TRACE("FindModule: Module %s request\n", m); if(list==NULL) return NULL; - while(strcmp(m, list->wm->filename)) +// while(strcmp(m, list->wm->filename)) + while(!strstr(list->wm->filename, m)) { TRACE("%s: %x\n", list->wm->filename, list->wm->module); list=list->prev; @@ -97,16 +102,22 @@ static void MODULE_RemoveFromList(WINE_MODREF *mod) WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m) { modref_list* list=local_wm; - TRACE("Module %X request\n", m); + TRACE("LookupHMODULE: Module %X request\n", m); if(list==NULL) + { + TRACE("LookupHMODULE failed\n"); return NULL; + } while(m!=list->wm->module) { // printf("Checking list %X wm %X module %X\n", // list, list->wm, list->wm->module); list=list->prev; if(list==NULL) + { + TRACE("LookupHMODULE failed\n"); return NULL; + } } TRACE("LookupHMODULE hit %p\n", list->wm); return list->wm; @@ -216,7 +227,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved ) //local_wm=wm; if(local_wm) { - local_wm->next=malloc(sizeof(modref_list)); + local_wm->next = (modref_list*) malloc(sizeof(modref_list)); local_wm->next->prev=local_wm; local_wm->next->next=NULL; local_wm->next->wm=wm; @@ -224,7 +235,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved ) } else { - local_wm=malloc(sizeof(modref_list)); + local_wm = (modref_list*)malloc(sizeof(modref_list)); local_wm->next=local_wm->prev=NULL; local_wm->wm=wm; } @@ -353,7 +364,10 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags) SetLastError(ERROR_INVALID_PARAMETER); return 0; } - printf("Loading DLL: '%s'\n", libname); + + wm=MODULE_FindModule(libname); + if(wm) return wm->module; + // if(fs_installed==0) // install_fs(); @@ -404,8 +418,69 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags) } if (!wm) - printf("Win32 LoadLibrary failed to load: %s\n", checked); + printf("wine/module: Win32 LoadLibrary failed to load: %s\n", checked); + + if (strstr(libname,"QuickTime.qts") && wm) + { + void** ptr; + void *dispatch_addr; + int i; + +// dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE); + dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE); + if (dispatch_addr == 0x62924c30) + { + printf ("wine/module: QuickTime5 DLLs found\n"); + ptr = 0x62b75ca4; // dispatch_ptr + for (i=0;i<5;i++) ((char*)0x6299e842)[i]=0x90; // make_new_region ? + for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; // call__call_CreateCompatibleDC ? + for (i=0;i<5;i++) ((char*)0x6299e898)[i]=0x90; // jmp_to_call_loadbitmap ? + for (i=0;i<9;i++) ((char*)0x6299e8ac)[i]=0x90; // call__calls_OLE_shit ? + for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; // disable threads +#if 0 + /* CreateThread callers */ + for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90; + for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90; +#endif + +#if 0 + /* TerminateQTML fix */ + for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; // terminate thread + for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; // terminate thread + for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90; + ((char *)0x6288e0ae)[0] = 0xc3; // font/dc remover + for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; // destroy window +#endif + } else if (dispatch_addr == 0x6693b330) + { + printf ("wine/module: QuickTime6 DLLs found\n"); + ptr = 0x66bb9524; // dispatcher_ptr + for (i=0;i<5;i++) ((char *)0x66a730cc)[i]=0x90; // make_new_region + for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; // call__call_CreateCompatibleDC + for (i=0;i<5;i++) ((char *)0x66a73122)[i]=0x90; // jmp_to_call_loadbitmap + for (i=0;i<9;i++) ((char *)0x66a73131)[i]=0x90; // call__calls_OLE_shit + for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; // disable threads + } else + { + printf ("wine/module: Unsupported QuickTime version (0x%x)\n", + dispatch_addr); + return NULL; + } + + printf ("wine/module: QuickTime.qts patched!!! old entry=%p\n",ptr[0]); +#ifdef EMU_QTX_API + report_entry = report_func; + report_ret = report_func_ret; + wrapper_target=ptr[0]; + ptr[0]=wrapper; +#endif + } return wm ? wm->module : 0; } @@ -482,6 +557,337 @@ FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function ) return MODULE_GetProcAddress( hModule, function, TRUE ); } +#ifdef DEBUG_QTX_API + +struct ComponentParameters {
+ unsigned char flags; /* call modifiers: sync/async, deferred, immed, etc */
+ unsigned char paramSize; /* size in bytes of actual parameters passed to this call */
+ short what; /* routine selector, negative for Component management calls */
+ long params[1]; /* actual parameters for the indicated routine */
+};
+typedef struct ComponentParameters ComponentParameters;
+ +static char* component_func(int what){ +switch(what){ +case -1: return "kComponentOpenSelect"; +case -2: return "kComponentCloseSelect"; +case -3: return "kComponentCanDoSelect"; +case -4: return "kComponentVersionSelect"; +case -5: return "kComponentRegisterSelect"; +case -6: return "kComponentTargetSelect"; +case -7: return "kComponentUnregisterSelect"; +} +return "???"; +} + +static char* component_func_type(int type,int what){ +if(type==1) switch(what){ +case 0: return "kImageCodecGetCodecInfoSelect"; +case 1: return "kImageCodecGetCompressionTimeSelect"; +case 5: return "kImageCodecPreDecompressSelect"; +case 6: return "kImageCodecBandDecompressSelect"; +case 0x12: return "kImageCodecDisposeMemorySelect"; +case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect"; +case 0x14: return "kImageCodecNewImageBufferMemorySelect"; +case 0x28: return "kImageCodecRequestGammaLevelSelect"; +} +return "???"; +} + + +static int c_level=0; + +static int dump_component(char* name,int type,void* _orig, ComponentParameters *params,void** glob){ + int ( *orig)(ComponentParameters *params, void** glob) = _orig; + int ret,i; + + if(params->what<0) + fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=%d %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what)); + else + fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func_type(type,params->what)); + + for(i=0;i<params->paramSize/4;i++) + fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]); + + ++c_level; + ret=orig(params,glob); + --c_level; + + if(ret>=0x1000) + fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret); + else + fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret); + return ret; +} + +#define DECL_COMPONENT(sname,name,type) \ + static void* real_ ## sname = NULL; \ + static int fake_ ## sname(ComponentParameters *params,void** glob){ \ + return dump_component(name,type,real_ ## sname, params, glob); \ + } + +#include "qt_comp.h" + +#undef DECL_COMPONENT + +#include "qt_fv.h" + +#endif + +#ifdef EMU_QTX_API + +static u_int32_t ret_array[4096]; +static int ret_i=0; + +static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) +{ +#ifdef DEBUG_QTX_API + int i; + int* dptr; + void* pwrapper=NULL; + void* pptr=NULL; + char* pname=NULL; + int plen=-1; + // find the code: + + dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255); +// printf("FUNC: flag=%d ptr=%p\n",dptr[0],dptr[1]); + if(dptr[0]&255){ + dptr=dptr[1];dptr+=4*(reg->eax&65535); +// printf("FUNC: ptr2=%p eax=%p edx=%p\n",dptr[1],dptr[0],dptr[2]); + pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2]; + } else { + pwrapper=0x62924910; + switch(dptr[1]){ + case 0x629248d0: + dptr=0x62b672c0;dptr+=2*(reg->eax&65535); +// printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]); + pptr=dptr[0]; plen=dptr[1]; + break; + case 0x62924e40: + dptr=0x62b67c70;dptr+=2*(reg->eax&65535); +// printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]); + pptr=dptr[0]; plen=dptr[1]; + break; + case 0x62924e60: + dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535); +// printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]); + pptr=dptr[0]; plen=dptr[1]; + break; + case 0x62924e80: + dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535); +// printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]); + pptr=dptr[0]; plen=dptr[1]; + break; + default: + printf("FUNC: unknown ptr & psize!\n"); + pwrapper=dptr[1]; + } + } + + for(i=0;qt_fv_list[i].name;i++){ + if(qt_fv_list[i].id==reg->eax){ + pname=qt_fv_list[i].name; + break; + } + } + + printf("FUNC[%X/%s]: wrapper=%p func=%p len=%d\n",reg->eax, + pname?pname:"???",pwrapper,pptr,plen); + + printf("FUNC: caller=%p ebx=%p\n",((u_int32_t *)stack_base)[0],reg->ebx); + + if(pname) + printf("%*sENTER(%d): %s(",ret_i*2,"",ret_i,pname); + else + printf("%*sENTER(%d): %X(",ret_i*2,"",ret_i,reg->eax); + for (i=0;i<plen/4;i++){ + unsigned int val=((u_int32_t *)stack_base)[1+i]; + unsigned char* fcc=&val; + printf("%s0x%X", i?", ":"",val); + if(fcc[0]>=0x20 && fcc[0]<128 && + fcc[1]>=0x20 && fcc[1]<128 && + fcc[2]>=0x20 && fcc[2]<128 && + fcc[3]>=0x20 && fcc[3]<128) printf("='%c%c%c%c'",fcc[3],fcc[2],fcc[1],fcc[0]); + else if(val>=8 && val<65536) printf("=%d",val); + } + printf(")\n"); + fflush(stdout); + +#endif + +#if 1 + // emulate some functions: + switch(reg->eax){ + // memory management: + case 0x150011: //NewPtrClear + case 0x150012: //NewPtrSysClear + reg->eax=malloc(((u_int32_t *)stack_base)[1]); + memset(reg->eax,0,((u_int32_t *)stack_base)[1]); +#ifdef DEBUG_QTX_API + printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); +#endif + return 1; + case 0x15000F: //NewPtr + case 0x150010: //NewPtrSys + reg->eax=malloc(((u_int32_t *)stack_base)[1]); +#ifdef DEBUG_QTX_API + printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); +#endif + return 1; + case 0x15002f: //DisposePtr + if(((u_int32_t *)stack_base)[1]>=0x60000000) + printf("WARNING! Invalid Ptr handle!\n"); + else + free(((u_int32_t *)stack_base)[1]); + reg->eax=0; +#ifdef DEBUG_QTX_API + printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); +#endif + return 1; + // mutexes: + case 0x1d0033: //QTMLCreateMutex + reg->eax=0xdeadbabe; +#ifdef DEBUG_QTX_API + printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); +#endif + return 1; + case 0x1d0034: //QTMLDestroyMutex + case 0x1d0035: //QTMLGrabMutex + case 0x1d0036: //QTMLReturnMutex + case 0x1d003d: //QTMLTryGrabMutex + reg->eax=0; +#ifdef DEBUG_QTX_API + printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); +#endif + return 1; + } +#endif + +#if 0 + switch(reg->eax){ +// case 0x00010000: +// printf("FUNC: ImageCodecInitialize/ImageCodecGetCodecInfo(ci=%p,&icap=%p)\n",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[4]); +// break; + case 0x00010003: + printf("FUNC: CountComponents(&desc=%p)\n",((u_int32_t *)stack_base)[1]); + break; + case 0x00010004: + printf("FUNC: FindNextComponent(prev=%p,&desc=%p)\n",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[2]); + break; + case 0x00010007: + printf("FUNC: OpenComponent(prev=%p)\n",((u_int32_t *)stack_base)[1]); + break; + case 0x0003008b: + printf("FUNC: QTNewGWorldFromPtr(&pts=%p,fourcc=%.4s,&rect=%p,x1=%p,x2=%p,x3=%p,plane=%p,stride=%d)\n", + ((u_int32_t *)stack_base)[1], + &(((u_int32_t *)stack_base)[2]), + ((u_int32_t *)stack_base)[3], + ((u_int32_t *)stack_base)[4], + ((u_int32_t *)stack_base)[5], + ((u_int32_t *)stack_base)[6], + ((u_int32_t *)stack_base)[7], + ((u_int32_t *)stack_base)[8]); + break; + case 0x001c0018: + printf("FUNC: GetGWorldPixMap(gworld=%p)\n",((u_int32_t *)stack_base)[1]); + break; + case 0x00110001: + printf("FUNC: Gestalt(fourcc=%.4s, &ret=%p)\n",&(((u_int32_t *)stack_base)[1]),((u_int32_t *)stack_base)[2]); + break; + default: { + int i; + for(i=0;qt_fv_list[i].name;i++){ + if(qt_fv_list[i].id==reg->eax){ + printf("FUNC: %s\n",qt_fv_list[i].name); + break; + } + } + } + } + + // print stack/reg information + printf("ENTER(%d) stack = %d bytes @ %p\n" + "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n" + "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n" + "flags = 0x%08x\n", ret_i, + stack_size, stack_base, + reg->eax, reg->edx, reg->ebx, reg->ecx, + reg->esp, reg->ebp, reg->esi, reg->edi, + *flags); +#endif + + // save ret addr: + ret_array[ret_i]=((u_int32_t *)stack_base)[0]; + ++ret_i; + +#if 0 + // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) + printf("stack[] = { "); + for (i=0;i<7;i++) { + printf("%08x ", ((u_int32_t *)stack_base)[i]); + } + printf("}\n\n"); +#endif + +// // mess with function parameters +// ((u_int32_t *)stack_base)[1] = 0x66554433; + +// // mess with return address... +// reg->eax = 0x11223344; + return 0; +} + +static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) +{ + int i; + short err; + + // restore ret addr: + --ret_i; + ((u_int32_t *)stack_base)[0]=ret_array[ret_i]; + +#ifdef DEBUG_QTX_API + +#if 1 + printf("%*sLEAVE(%d): 0x%X",ret_i*2,"",ret_i, reg->eax); + err=reg->eax; + if(err && (reg->eax>>16)==0) printf(" = %d",err); + printf("\n"); + fflush(stdout); +#else + // print stack/reg information + printf("LEAVE(%d) stack = %d bytes @ %p\n" + "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n" + "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n" + "flags = 0x%08x\n", ret_i, + stack_size, stack_base, + reg->eax, reg->edx, reg->ebx, reg->ecx, + reg->esp, reg->ebp, reg->esi, reg->edi, + *flags); +#endif + +#if 0 + // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) + printf("stack[] = { "); + for (i=0;i<7;i++) { + printf("%08x ", ((u_int32_t *)stack_base)[i]); + } + printf("}\n\n"); +#endif + +#endif + +// // mess with function parameters +// ((u_int32_t *)stack_base)[1] = 0x66554433; + +// // mess with return address... +// reg->eax = 0x11223344; + return 0; +} + +#endif + /*********************************************************************** * MODULE_GetProcAddress (internal) */ @@ -494,10 +900,17 @@ FARPROC MODULE_GetProcAddress( // WINE_MODREF *wm=local_wm; FARPROC retproc; +#ifdef DEBUG_QTX_API if (HIWORD(function)) - TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function); + fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function); else - TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function); + fprintf(stderr,"XXX GetProcAddress(%08lx,%p)\n",(DWORD)hModule,function); +#endif + +// TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function); +// else +// TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function); + if (!wm) { SetLastError(ERROR_INVALID_HANDLE); return (FARPROC)0; @@ -507,7 +920,7 @@ FARPROC MODULE_GetProcAddress( case MODULE32_PE: retproc = PE_FindExportedFunction( wm, function, snoop ); if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND); - return retproc; + break; #ifdef HAVE_LIBDL case MODULE32_ELF: retproc = (FARPROC) dlsym( (void*) wm->module, function); @@ -519,6 +932,35 @@ FARPROC MODULE_GetProcAddress( SetLastError(ERROR_INVALID_HANDLE); return (FARPROC)0; } + +#ifdef EMU_QTX_API + if (HIWORD(function) && retproc){ + +#ifdef DEBUG_QTX_API +#define DECL_COMPONENT(sname,name,type) \ + if(!strcmp(function,name)){ \ + fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \ + real_ ## sname = retproc; retproc = fake_ ## sname; \ + } +#include "qt_comp.h" +#undef DECL_COMPONENT +#endif + + if(!strcmp(function,"theQuickTimeDispatcher") +// || !strcmp(function,"_CallComponentFunctionWithStorage") +// || !strcmp(function,"_CallComponent") + ){ + fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc); + report_entry = report_func; + report_ret = report_func_ret; + wrapper_target=retproc; + retproc=wrapper; + } + + } +#endif + + return retproc; } static int acounter = 0; diff --git a/src/libw32dll/wine/module.h b/src/libw32dll/wine/module.h index 91e94b122..6f6b31a0a 100644 --- a/src/libw32dll/wine/module.h +++ b/src/libw32dll/wine/module.h @@ -128,6 +128,16 @@ typedef struct resource_nameinfo_s NE_NAMEINFO; #define NE_MODULE_NAME(pModule) \ (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName) +struct modref_list_t; + +typedef struct modref_list_t +{ + WINE_MODREF* wm; + struct modref_list_t *next; + struct modref_list_t *prev; +} modref_list; + + /* module.c */ extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, WIN_BOOL snoop ); extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule ); diff --git a/src/libw32dll/wine/registry.c b/src/libw32dll/wine/registry.c index c8495d453..ed7f5e74d 100644 --- a/src/libw32dll/wine/registry.c +++ b/src/libw32dll/wine/registry.c @@ -406,65 +406,65 @@ long RegCloseKey(long key) 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); - if(c==NULL) - 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; - return ERROR_MORE_DATA; + struct reg_value* t; + char* c; + TRACE("Querying value %s\n", value); + if(!regs) + init_registry(); + + c=build_keyname(key, value); + if (!c) + 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; + return ERROR_MORE_DATA; } else { - *count=t->len; - } + *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) { - reg_handle_t* t; - char* fullname; - struct reg_value* v; -// TRACE("Creating/Opening key %s\n", name); - TRACE("Creating/Opening key %s\n", name); - if(!regs) - init_registry(); - - fullname=build_keyname(key, name); - if(fullname==NULL) - return 1; - v=find_value_by_name(fullname); - if(v==0) - { - int qw=45708; - v=insert_reg_value(key, name, DIR, &qw, 4); - if (status) *status=REG_CREATED_NEW_KEY; -// return 0; - } + reg_handle_t* t; + char* fullname; + struct reg_value* v; + // TRACE("Creating/Opening key %s\n", name); + if(!regs) + init_registry(); - t=insert_handle(generate_handle(), fullname); - *newkey=t->handle; - free(fullname); - return 0; + fullname=build_keyname(key, name); + if (!fullname) + return 1; + TRACE("Creating/Opening key %s\n", fullname); + v=find_value_by_name(fullname); + if(v==0) + { + int qw=45708; + v=insert_reg_value(key, name, DIR, &qw, 4); + if (status) *status=REG_CREATED_NEW_KEY; + // return 0; + } + + t=insert_handle(generate_handle(), fullname); + *newkey=t->handle; + free(fullname); + return 0; } /* diff --git a/src/libw32dll/wine/vfl.c b/src/libw32dll/wine/vfl.c index b86b702e1..e8eb7969f 100644 --- a/src/libw32dll/wine/vfl.c +++ b/src/libw32dll/wine/vfl.c @@ -26,46 +26,12 @@ #define OpenDriverA DrvOpen #define CloseDriver DrvClose -long VFWAPI VideoForWindowsVersion(void); - - -#if 1 -/* - * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to - * WINAPI/no-WINAPI bustage. - * - * There should be no need for the STORE_ALL/REST_ALL hack once all - * function definitions agree with their prototypes (WINAPI-wise) and - * we make sure, that we do not call these functions without a proper - * prototype in scope. - */ -#define STORE_ALL /**/ -#define REST_ALL /**/ -#else -#define STORE_ALL \ - __asm__ ( \ - "push %%ebx\n\t" \ - "push %%ecx\n\t" \ - "push %%edx\n\t" \ - "push %%esi\n\t" \ - "push %%edi\n\t"::) - -#define REST_ALL \ - __asm__ ( \ - "pop %%edi\n\t" \ - "pop %%esi\n\t" \ - "pop %%edx\n\t" \ - "pop %%ecx\n\t" \ - "pop %%ebx\n\t"::) -#endif - - /*********************************************************************** * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2] * Returns the version in major.minor form. * In Windows95 this returns 0x040003b6 (4.950) */ -long VideoForWindowsVersion(void) { +long VFWAPI VideoForWindowsVersion(void) { return 0x040003B6; /* 4.950 */ } @@ -82,28 +48,10 @@ ICInfo( long fccHandler, /* [in] <n>th compressor */ ICINFO *lpicinfo /* [out] information about compressor */ ) { - char type[5]; - - memcpy(type,&fccType,4);type[4]=0; - /* does OpenDriver/CloseDriver */ lpicinfo->dwSize = sizeof(ICINFO); lpicinfo->fccType = fccType; lpicinfo->dwFlags = 0; -/* - if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) { - char *s = buf; - while (*s) { - if (!lstrncmpiA(type,s,4)) { - if(!fccHandler--) { - lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0); - return TRUE; - } - } - s=s+lstrlenA(s)+1; - } - } -*/ return TRUE; } @@ -112,69 +60,32 @@ ICInfo( * Opens an installable compressor. Return special handle. */ HIC VFWAPI -ICOpen(long fccType,long fccHandler,unsigned int wMode) { - char type[5],handler[5],codecname[20]; +//ICOpen(long fccType,long fccHandler,unsigned int wMode) { +ICOpen(long filename,long fccHandler,unsigned int wMode) { ICOPEN icopen; HDRVR hdrv; WINE_HIC *whic; - memcpy(type,&fccType,4);type[4]=0; - memcpy(handler,&fccHandler,4);handler[4]=0; - - snprintf(codecname,20,"%s.%s",type,handler); - /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the * same layout as ICOPEN */ - icopen.fccType = fccType; + icopen.fccType = 0x63646976; // "vidc" //fccType; icopen.fccHandler = fccHandler; icopen.dwSize = sizeof(ICOPEN); icopen.dwFlags = wMode; + icopen.pV1Reserved = (void*)filename; /* FIXME: do we need to fill out the rest too? */ -// hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen); hdrv=OpenDriverA((long)&icopen); -/* - if (!hdrv) { - if (!strcasecmp(type,"vids")) { - snprintf(codecname,20,"vidc.%s",handler); - fccType = mmioFOURCC('v','i','d','c'); - } -// hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen); - hdrv=OpenDriverA((long)&icopen); -*/ - if (!hdrv) - return 0; -// } - whic = (WINE_HIC*)my_mreq(sizeof(WINE_HIC), 0); + if (!hdrv) return 0; + whic = (WINE_HIC*)malloc(sizeof(WINE_HIC)); whic->hdrv = hdrv; whic->driverproc= ((DRVR*)hdrv)->DriverProc; // whic->private = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen); - whic->private = ((DRVR*)hdrv)->dwDriverID; + whic->driverid = ((DRVR*)hdrv)->dwDriverID; return (HIC)whic; } /*********************************************************************** - * ICOpenFunction [MSVFW.38] - */ -HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, -void* lpfnHandler) { - char type[5],handler[5]; - HIC hic; - WINE_HIC *whic; - - memcpy(type,&fccType,4);type[4]=0; - memcpy(handler,&fccHandler,4);handler[4]=0; - FIXME("(%s,%s,%d,%p), stub!\n",type,handler,wMode,lpfnHandler); - hic = ICOpen(fccType,fccHandler,wMode); - if (!hic) - return hic; - whic = (WINE_HIC*)hic; - whic->driverproc = (DRIVERPROC)lpfnHandler; - return hic; -} - - -/*********************************************************************** * ICGetInfo [MSVFW.30] */ LRESULT VFWAPI @@ -187,53 +98,6 @@ ICGetInfo(HIC hic,ICINFO *picinfo,long cb) { } /*********************************************************************** - * ICLocate [MSVFW.35] - */ -HIC VFWAPI -ICLocate( - long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, - LPBITMAPINFOHEADER lpbiOut, short wMode -) { - char type[5],handler[5]; - HIC hic; - long querymsg; - - switch (wMode) { - case ICMODE_FASTCOMPRESS: - case ICMODE_COMPRESS: - querymsg = ICM_COMPRESS_QUERY; - break; - case ICMODE_DECOMPRESS: - case ICMODE_FASTDECOMPRESS: - querymsg = ICM_DECOMPRESS_QUERY; - break; - case ICMODE_DRAW: - querymsg = ICM_DRAW_QUERY; - break; - default: - FIXME("Unknown mode (%d)\n",wMode); - return 0; - } - - /* Easy case: handler/type match, we just fire a query and return */ - hic = ICOpen(fccType,fccHandler,wMode); - if (hic) { - if (!ICSendMessage(hic,querymsg,(long)lpbiIn,(long)lpbiOut)) - return hic; - ICClose(hic); - } - type[4]='\0';memcpy(type,&fccType,4); - handler[4]='\0';memcpy(handler,&fccHandler,4); - if (fccType==streamtypeVIDEO) { - hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode); - if (hic) - return hic; - } - FIXME("(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode); - return 0; -} - -/*********************************************************************** * ICCompress [MSVFW.23] */ long VFWAPIV @@ -276,9 +140,7 @@ ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPB icd.lpbiOutput = lpbi; icd.lpOutput = lpBits; icd.ckid = 0; - STORE_ALL; result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd)); - REST_ALL; return result; } @@ -307,9 +169,7 @@ ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,L icd.dyDst=abs(lpbi->biHeight); //icd.ckid = 0; - STORE_ALL; result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd)); - REST_ALL; return result; } @@ -335,9 +195,7 @@ ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEAD icd.dyDst=abs(lpbi->biHeight); //icd.ckid = 0; - STORE_ALL; result=ICSendMessage(hic,command,(long)&icd,sizeof(icd)); - REST_ALL; return result; } @@ -347,33 +205,8 @@ ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEAD */ LRESULT VFWAPI ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) { - LRESULT ret; - WINE_HIC *whic = (WINE_HIC*)hic; - /* char qw[200]; -- unused*/ - -// printf("ICSendMessage.whic=%p\n",whic); - -#if 0 - __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); -#endif - STORE_ALL; - /*__asm__ - ( - "pushl %eax\n\t" - "movl $0xf,%eax\n\t" - "movw %ax, %fs\n\t" - "popl %eax\n\t" - );*/ - ret = whic->driverproc(whic->private,1,msg,lParam1,lParam2); - REST_ALL; -#if 0 - __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); -#endif -// } else - -// ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2); -// TRACE(" -> 0x%08lx\n",ret); - return ret; + WINE_HIC *whic = (WINE_HIC*)hic; + return SendDriverMessage(whic->hdrv, msg, lParam1,lParam2); } @@ -386,9 +219,10 @@ LRESULT VFWAPI ICClose(HIC hic) { // CloseDriver(whic->hdrv,0,0); DrvClose(whic->hdrv); //#warning FIXME: DrvClose - my_release(whic); + free(whic); return 0; } + int VFWAPI ICDoSomething() { return 0; diff --git a/src/libw32dll/wine/vfw.h b/src/libw32dll/wine/vfw.h index bc32aff5e..d2917601e 100644 --- a/src/libw32dll/wine/vfw.h +++ b/src/libw32dll/wine/vfw.h @@ -69,11 +69,7 @@ typedef struct tagWINE_HIC { long type; /* 08: */ long handler; /* 0C: */ HDRVR hdrv; /* 10: */ -#ifndef __cplusplus - long private; /* 14:(handled by SendDriverMessage)*/ -#else - long _private; /* 14:(handled by SendDriverMessage)*/ -#endif + long driverid; /* 14:(handled by SendDriverMessage)*/ DRIVERPROC driverproc; /* 18:(handled by SendDriverMessage)*/ long x1; /* 1c: name? */ short x2; /* 20: */ @@ -200,7 +196,7 @@ typedef struct { LPBITMAPINFOHEADER lpbiOutput; void* lpOutput; LPBITMAPINFOHEADER lpbiInput; - void* lpInput; + const void* lpInput; long* lpckid; long* lpdwFlags; long lFrameNum; @@ -211,10 +207,10 @@ typedef struct { } ICCOMPRESS; long VFWAPIV ICCompress( - HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf, - LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid, + HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData, + LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid, long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality, - LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev + LPBITMAPINFOHEADER lpbiPrev,void* lpPrev ); @@ -350,7 +346,7 @@ typedef struct { typedef struct { long dwFlags; /* flags (from AVI index...) */ LPBITMAPINFOHEADER lpbiInput; /* BITMAPINFO of compressed data */ - void* lpInput; /* compressed data */ + const void* lpInput; /* compressed data */ LPBITMAPINFOHEADER lpbiOutput; /* DIB to decompress to */ void* lpOutput; long ckid; /* ckid from AVI file */ @@ -359,7 +355,7 @@ typedef struct { typedef struct { long dwFlags; LPBITMAPINFOHEADER lpbiSrc; - void* lpSrc; + const void* lpSrc; LPBITMAPINFOHEADER lpbiDst; void* lpDst; @@ -427,6 +423,7 @@ long VFWAPIV ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPB ) #define ICDecompressEnd(hic) ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0) +#define ICDecompressEndEx(hic) ICSendMessage(hic,ICM_DECOMPRESSEX_END, 0, 0) #define ICDRAW_QUERY 0x00000001L /* test for support */ @@ -437,11 +434,11 @@ long VFWAPIV ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPB 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); +//HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler); LRESULT VFWAPI ICClose(HIC hic); LRESULT VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2); -HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags); +//HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags); int VFWAPI ICDoSomething(void); diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c index 144c1ade8..00fcabb4f 100644 --- a/src/libw32dll/wine/win32.c +++ b/src/libw32dll/wine/win32.c @@ -13,12 +13,21 @@ for DLL to know too much about its environment. #include "config.h" +#define QTX + +#ifdef QTX +#define PSEUDO_SCREEN_WIDTH /*640*/800 +#define PSEUDO_SCREEN_HEIGHT /*480*/600 +#endif + + #include "winbase.h" #include "winreg.h" #include "winnt.h" #include "winerror.h" #include "debugtools.h" #include "module.h" +#include "winuser.h" #include <stdio.h> #include "win32.h" @@ -41,6 +50,7 @@ for DLL to know too much about its environment. #include <unistd.h> #include <fcntl.h> #include <sys/types.h> +#include <dirent.h> #include <sys/time.h> #include <sys/timeb.h> #ifdef HAVE_KSTAT @@ -257,7 +267,7 @@ static void test_heap(void) #ifdef MEMORY_DEBUG -void* my_mreq(int size, int to_zero) +static void* my_mreq(int size, int to_zero) { static int test=0; test++; @@ -290,7 +300,7 @@ void* my_mreq(int size, int to_zero) heap_counter+=size; return heap+heap_counter-size; } -int my_release(char* memory) +static int my_release(char* memory) { // test_heap(); if(memory==NULL) @@ -348,7 +358,7 @@ void* mreq_private(int size, int to_zero, int type); void* mreq_private(int size, int to_zero, int type) { int nsize = size + sizeof(alloc_header); - alloc_header* header = malloc(nsize); + alloc_header* header = (alloc_header* ) malloc(nsize); if (!header) return 0; if (to_zero) @@ -379,7 +389,7 @@ void* mreq_private(int size, int to_zero, int type) return header + 1; } -int my_release(void* memory) +static int my_release(void* memory) { alloc_header* header = (alloc_header*) memory - 1; #ifdef GARBAGE @@ -389,7 +399,7 @@ int my_release(void* memory) if (memory == 0) return 0; - if (header->deadbeef != 0xdeadbeef) + if (header->deadbeef != (long) 0xdeadbeef) { printf("FATAL releasing corrupted memory! %p 0x%lx (%d)\n", header, header->deadbeef, alccnt); return 0; @@ -446,12 +456,12 @@ int my_release(void* memory) } #endif -inline void* my_mreq(int size, int to_zero) +static inline void* my_mreq(int size, int to_zero) { return mreq_private(size, to_zero, AREATYPE_CLIENT); } -static /*inline*/ int my_size(void* memory) +static int my_size(void* memory) { if(!memory) return 0; return ((alloc_header*)memory)[-1].size; @@ -516,13 +526,22 @@ static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv) #define MODULE_HANDLE_kernel32 ((HMODULE)0x120) #define MODULE_HANDLE_user32 ((HMODULE)0x121) +#ifdef QTX +#define MODULE_HANDLE_wininet ((HMODULE)0x122) +#define MODULE_HANDLE_ddraw ((HMODULE)0x123) +#define MODULE_HANDLE_advapi32 ((HMODULE)0x124) +#endif static HMODULE WINAPI expGetModuleHandleA(const char* name) { WINE_MODREF* wm; HMODULE result; if(!name) +#ifdef QTX + result=1; +#else result=0; +#endif else { wm=MODULE_FindModule(name); @@ -532,21 +551,24 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name) } if(!result) { - if(name && strcasecmp(name, "kernel32")==0) + if(name && (strcasecmp(name, "kernel32")==0 || !strcasecmp(name, "kernel32.dll"))) result=MODULE_HANDLE_kernel32; +#ifdef QTX + if(name && strcasecmp(name, "user32")==0) + result=MODULE_HANDLE_user32; +#endif } dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result); return result; } - static void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress, void* lpParameter, long dwFlags, long* dwThreadId) { pthread_t *pth; // printf("CreateThread:"); - pth=my_mreq(sizeof(pthread_t), 0); + pth = (pthread_t*) my_mreq(sizeof(pthread_t), 0); pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter); if(dwFlags) printf( "WARNING: CreateThread flags not supported\n"); @@ -791,25 +813,64 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration) return (void *)ret; } -static int pf_set = 0; -static BYTE PF[64] = {0,}; - -static void WINAPI expGetSystemInfo(SYSTEM_INFO* si); /* forward declaration */ - -static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v) +#ifdef QTX +static void* WINAPI expWaitForMultipleObjects(int count, const void** objects, + int WaitAll, int duration) { - WIN_BOOL result; - if(v>63)result=0; - if (!pf_set) + int i; + void *object; + int ret; + + dbgprintf("WaitForMultipleObjects(%d, 0x%x, %d, duration %d) =>\n", + count, objects, WaitAll, duration); + + for (i = 0; i < count; i++) { - SYSTEM_INFO si; - expGetSystemInfo(&si); + object = (void *) objects[i]; + ret = expWaitForSingleObject(object, duration); + if (WaitAll) + dbgprintf("WaitAll flag not yet supported...\n"); + else + return ret; } - else result=PF[v]; - dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result); - return result; + return NULL; } +static void WINAPI expExitThread(int retcode) +{ + dbgprintf("ExitThread(%d)\n", retcode); + pthread_exit(&retcode); +} + +static HANDLE WINAPI expCreateMutexA(void *pSecAttr, + char bInitialOwner, const char *name) +{ + HANDLE mlist = expCreateEventA(pSecAttr, 0, 0, name); + + if (name) + dbgprintf("CreateMutexA(0x%x, %d, '%s') => 0x%x\n", + pSecAttr, bInitialOwner, name, mlist); + else + dbgprintf("CreateMutexA(0x%x, %d, NULL) => 0x%x\n", + pSecAttr, bInitialOwner, mlist); +#ifndef QTX + /* 10l to QTX, if CreateMutex returns a real mutex, WaitForSingleObject + waits for ever, else it works ;) */ + return mlist; +#endif +} + +static int WINAPI expReleaseMutex(HANDLE hMutex) +{ + dbgprintf("ReleaseMutex(%x) => 1\n", hMutex); + /* FIXME:XXX !! not yet implemented */ + return 1; +} +#endif + +static int pf_set = 0; +static BYTE PF[64] = {0,}; + static void DumpSystemInfo(const SYSTEM_INFO* si) { dbgprintf(" Processor architecture %d\n", si->u.s.wProcessorArchitecture); @@ -1012,7 +1073,7 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si) } if (!lstrncmpiA(line,"processor",strlen("processor"))) { /* processor number counts up...*/ - int x; + unsigned int x; if (sscanf(value,"%d",&x)) if (x+1>cachedsi.dwNumberOfProcessors) @@ -1060,6 +1121,21 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si) DumpSystemInfo(si); } +// avoid undefined expGetSystemInfo +static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v) +{ + WIN_BOOL result = 0; + if (!pf_set) + { + SYSTEM_INFO si; + expGetSystemInfo(&si); + } + if(v<64) result=PF[v]; + dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result); + return result; +} + + static long WINAPI expGetVersion() { dbgprintf("GetVersion() => 0xC0000004\n"); @@ -1112,7 +1188,11 @@ static long WINAPI expHeapDestroy(void* heap) static long WINAPI expHeapFree(HANDLE heap, DWORD dwFlags, LPVOID lpMem) { dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", heap, dwFlags, lpMem); - if (heapfreehack != lpMem && lpMem != (void*)0xffffffff) + if (heapfreehack != lpMem && lpMem != (void*)0xffffffff + && lpMem != (void*)0xbdbdbdbd) + // 0xbdbdbdbd is for i263_drv.drv && libefence + // it seems to be reading from relased memory + // EF_PROTECT_FREE doens't show any probleme my_release(lpMem); else { @@ -1162,12 +1242,14 @@ struct critsecs_list_t struct CRITSECT *cs_unix; }; -/* 'NEWTYPE' is working with VIVO and 3ivX dll (no more segfaults) -- alex */ +/* 'NEWTYPE' is working with VIVO, 3ivX and QTX dll (no more segfaults) -- alex */ #undef CRITSECS_NEWTYPE //#define CRITSECS_NEWTYPE 1 #ifdef CRITSECS_NEWTYPE -#define CRITSECS_LIST_MAX 20 +/* increased due to ucod needs more than 32 entries */ +/* and 64 should be enough for everything */ +#define CRITSECS_LIST_MAX 64 static struct critsecs_list_t critsecs_list[CRITSECS_LIST_MAX]; static int critsecs_get_pos(CRITICAL_SECTION *cs_win) @@ -1190,9 +1272,6 @@ static int critsecs_get_unused(void) 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; @@ -1203,7 +1282,6 @@ struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win) return(NULL); } #endif -#endif static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c) { @@ -1246,7 +1324,7 @@ static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c) pthread_mutex_init(&cs->mutex, NULL); cs->locked=0; cs->deadbeef = 0xdeadbeef; - *(void**)c = cs + 1; + *(void**)c = cs; } #endif return; @@ -1257,10 +1335,9 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c) #ifdef CRITSECS_NEWTYPE struct CRITSECT* cs = critsecs_get_unix(c); #else - struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1; - + struct CRITSECT* cs = (*(struct CRITSECT**)c); #endif - dbgprintf("EnterCriticalSection(0x%x) %p maso:0x%x\n",c, cs, cs->deadbeef); + dbgprintf("EnterCriticalSection(0x%x) %p\n",c, cs); if (!cs) { dbgprintf("entered uninitialized critisec!\n"); @@ -1268,9 +1345,9 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c) #ifdef CRITSECS_NEWTYPE cs=critsecs_get_unix(c); #else - cs = (*(struct CRITSECT**)c) - 1; + cs = (*(struct CRITSECT**)c); #endif - printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c); + printf("wine/win32: Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c); } if(cs->locked) if(cs->id==pthread_self()) @@ -1285,10 +1362,10 @@ static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c) #ifdef CRITSECS_NEWTYPE struct CRITSECT* cs = critsecs_get_unix(c); #else - struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1; + struct CRITSECT* cs = (*(struct CRITSECT**)c); #endif // struct CRITSECT* cs=(struct CRITSECT*)c; - dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs->deadbeef); + dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs); if (!cs) { printf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c); @@ -1303,7 +1380,7 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c) #ifdef CRITSECS_NEWTYPE struct CRITSECT* cs = critsecs_get_unix(c); #else - struct CRITSECT* cs= (*(struct CRITSECT**)c) - 1; + struct CRITSECT* cs= (*(struct CRITSECT**)c); #endif // struct CRITSECT* cs=(struct CRITSECT*)c; dbgprintf("DeleteCriticalSection(0x%x)\n",c); @@ -1333,8 +1410,8 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c) } static int WINAPI expGetCurrentThreadId() { - dbgprintf("GetCurrentThreadId() => %d\n", getpid()); - return getpid(); + dbgprintf("GetCurrentThreadId() => %d\n", pthread_self()); + return pthread_self(); } static int WINAPI expGetCurrentProcess() { @@ -1342,12 +1419,12 @@ static int WINAPI expGetCurrentProcess() return getpid(); } -extern void* fs_seg; - -#if 0 +#ifdef QTX // this version is required for Quicktime codecs (.qtx/.qts) to work. // (they assume some pointers at FS: segment) +extern void* fs_seg; + //static int tls_count; static int tls_use_map[64]; static int WINAPI expTlsAlloc() @@ -1364,9 +1441,10 @@ static int WINAPI expTlsAlloc() return -1; } -static int WINAPI expTlsSetValue(DWORD index, void* value) +//static int WINAPI expTlsSetValue(DWORD index, void* value) +static int WINAPI expTlsSetValue(int index, void* value) { - dbgprintf("TlsSetValue(%d,%p)\n",index,value); + dbgprintf("TlsSetValue(%d,0x%x) => 1\n",index,value); // if((index<0) || (index>64)) if((index>=64)) return 0; @@ -1402,7 +1480,7 @@ struct tls_s { static void* WINAPI expTlsAlloc() { - if(g_tls==NULL) + if (g_tls == NULL) { g_tls=my_mreq(sizeof(tls_t), 0); g_tls->next=g_tls->prev=NULL; @@ -1457,6 +1535,8 @@ static int WINAPI expTlsFree(void* idx) index->next->prev=index->prev; if(index->prev) index->prev->next=index->next; + if (g_tls == index) + g_tls = index->prev; my_release((void*)index); result=1; } @@ -2077,17 +2157,32 @@ static int WINAPI expGetStdHandle(int z) dbgprintf("GetStdHandle(0x%x) => 0x%x\n", z+0x1234); return z+0x1234; } + +#ifdef QTX +#define FILE_HANDLE_quicktimeqts ((HANDLE)0x444) +#define FILE_HANDLE_quicktimeqtx ((HANDLE)0x445) +#endif + static int WINAPI expGetFileType(int handle) { dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle); return 0x3; } +#ifdef QTX +static int WINAPI expGetFileAttributesA(char *filename) +{ + dbgprintf("GetFileAttributesA(%s) => FILE_ATTR_NORMAL\n", filename); + if (strstr(filename, "QuickTime.qts")) + return FILE_ATTRIBUTE_SYSTEM; + return FILE_ATTRIBUTE_NORMAL; +} +#endif static int WINAPI expSetHandleCount(int count) { dbgprintf("SetHandleCount(0x%x) => 1\n", count); return 1; } -static int WINAPI expGetACP() +static int WINAPI expGetACP(void) { dbgprintf("GetACP() => 0\n"); return 0; @@ -2097,8 +2192,15 @@ static int WINAPI expGetModuleFileNameA(int module, char* s, int len) { WINE_MODREF *mr; int result; - // printf("File name of module %X requested\n", module); - if(s==0) + //printf("File name of module %X (%s) requested\n", module, s); + + if (module == 0 && len >= 12) + { + /* return caller program name */ + strcpy(s, "aviplay.dll"); + result=1; + } + else if(s==0) result=0; else if(len<35) @@ -2169,17 +2271,32 @@ static int WINAPI expLoadLibraryA(char* name) // return MODULE_HANDLE_kernel32; return MODULE_HANDLE_user32; +#ifdef QTX + if (strcasecmp(name, "wininet.dll") == 0 || strcasecmp(name, "wininet") == 0) + return MODULE_HANDLE_wininet; + if (strcasecmp(name, "ddraw.dll") == 0 || strcasecmp(name, "ddraw") == 0) + return MODULE_HANDLE_ddraw; + if (strcasecmp(name, "advapi32.dll") == 0 || strcasecmp(name, "advapi32") == 0) + return MODULE_HANDLE_advapi32; +#endif + result=LoadLibraryA(name); dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, win32_def_path, result); return result; } + static int WINAPI expFreeLibrary(int module) { +#ifdef QTX + int result=0; /* FIXME:XXX: qtx svq3 frees up qt.qts */ +#else int result=FreeLibrary(module); +#endif dbgprintf("FreeLibrary(0x%x) => %d\n", module, result); return result; } + static void* WINAPI expGetProcAddress(HMODULE mod, char* name) { void* result; @@ -2188,6 +2305,14 @@ static void* WINAPI expGetProcAddress(HMODULE mod, char* name) result=LookupExternalByName("kernel32.dll", name); break; case MODULE_HANDLE_user32: result=LookupExternalByName("user32.dll", name); break; +#ifdef QTX + case MODULE_HANDLE_wininet: + result=LookupExternalByName("wininet.dll", name); break; + case MODULE_HANDLE_ddraw: + result=LookupExternalByName("ddraw.dll", name); break; + case MODULE_HANDLE_advapi32: + result=LookupExternalByName("advapi32.dll", name); break; +#endif default: result=GetProcAddress(mod, name); } @@ -2264,7 +2389,15 @@ static int WINAPI expCreateCompatibleDC(int hdc) static int WINAPI expGetDeviceCaps(int hdc, int unk) { dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk); - return 0; +#ifdef QTX + #define BITSPIXEL 12 + #define PLANES 14 + if (unk == BITSPIXEL) + return 24; + if (unk == PLANES) + return 1; +#endif + return 1; } static WIN_BOOL WINAPI expDeleteDC(int hdc) @@ -2289,6 +2422,178 @@ static void* WINAPI expGetWindowDC(int hdc) return 0; } +#ifdef QTX +static int WINAPI expGetWindowRect(HWND win, RECT *r) +{ + dbgprintf("GetWindowRect(0x%x, 0x%x) => 1\n", win, r); + /* (win == 0) => desktop */ + r->right = PSEUDO_SCREEN_WIDTH; + r->left = 0; + r->bottom = PSEUDO_SCREEN_HEIGHT; + r->top = 0; + return 1; +} + +static int WINAPI expMonitorFromWindow(HWND win, int flags) +{ + dbgprintf("MonitorFromWindow(0x%x, 0x%x) => 0\n", win, flags); + return 0; +} + +static int WINAPI expMonitorFromRect(RECT *r, int flags) +{ + dbgprintf("MonitorFromRect(0x%x, 0x%x) => 0\n", r, flags); + return 0; +} + +static int WINAPI expMonitorFromPoint(void *p, int flags) +{ + dbgprintf("MonitorFromPoint(0x%x, 0x%x) => 0\n", p, flags); + return 0; +} + +static int WINAPI expEnumDisplayMonitors(void *dc, RECT *r, + int WINAPI (*callback_proc)(), void *callback_param) +{ + dbgprintf("EnumDisplayMonitors(0x%x, 0x%x, 0x%x, 0x%x) => ?\n", + dc, r, callback_proc, callback_param); + return callback_proc(0, dc, r, callback_param); +} + +#if 0 +typedef struct tagMONITORINFO { + DWORD cbSize; + RECT rcMonitor; + RECT rcWork; + DWORD dwFlags; +} MONITORINFO, *LPMONITORINFO; +#endif + +#define CCHDEVICENAME 8 +typedef struct tagMONITORINFOEX { + DWORD cbSize; + RECT rcMonitor; + RECT rcWork; + DWORD dwFlags; + TCHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEX, *LPMONITORINFOEX; + +static int WINAPI expGetMonitorInfoA(void *mon, LPMONITORINFO lpmi) +{ + dbgprintf("GetMonitorInfoA(0x%x, 0x%x) => 1\n", mon, lpmi); + + lpmi->rcMonitor.right = lpmi->rcWork.right = PSEUDO_SCREEN_WIDTH; + lpmi->rcMonitor.left = lpmi->rcWork.left = 0; + lpmi->rcMonitor.bottom = lpmi->rcWork.bottom = PSEUDO_SCREEN_HEIGHT; + lpmi->rcMonitor.top = lpmi->rcWork.top = 0; + + lpmi->dwFlags = 1; /* primary monitor */ + + if (lpmi->cbSize == sizeof(MONITORINFOEX)) + { + LPMONITORINFOEX lpmiex = lpmi; + dbgprintf("MONITORINFOEX!\n"); + strncpy(lpmiex->szDevice, "Monitor1", CCHDEVICENAME); + } + + return 1; +} + +static int WINAPI expEnumDisplayDevicesA(const char *device, int devnum, + void *dispdev, int flags) +{ + dbgprintf("EnumDisplayDevicesA(0x%x = %s, %d, 0x%x, %x) => 1\n", + device, device, devnum, dispdev, flags); + return 1; +} + +static int WINAPI expIsWindowVisible(HWND win) +{ + dbgprintf("IsWindowVisible(0x%x) => 1\n", win); + return 1; +} + +static HWND WINAPI expGetActiveWindow(void) +{ + dbgprintf("GetActiveWindow() => 0\n"); + return (HWND)0; +} + +static int WINAPI expGetClassNameA(HWND win, LPTSTR classname, int maxcount) +{ + strncat(classname, "QuickTime", maxcount); + dbgprintf("GetClassNameA(0x%x, 0x%x, %d) => %d\n", + win, classname, maxcount, strlen(classname)); + return strlen(classname); +} + +#define LPWNDCLASS void * +static int WINAPI expGetClassInfoA(HINSTANCE inst, LPCSTR classname, LPWNDCLASS wndclass) +{ + dbgprintf("GetClassInfoA(0x%x, 0x%x = %s, 0x%x) => 1\n", inst, + classname, classname, wndclass); + return 1; +} + +static int WINAPI expGetWindowLongA(HWND win, int index) +{ + dbgprintf("GetWindowLongA(0x%x, %d) => 0\n", win, index); + return 1; +} + +static int WINAPI expGetObjectA(HGDIOBJ hobj, int objsize, LPVOID obj) +{ + dbgprintf("GetObjectA(0x%x, %d, 0x%x) => %d\n", hobj, objsize, obj, objsize); + return objsize; +} + +static int WINAPI expCreateRectRgn(int x, int y, int width, int height) +{ + dbgprintf("CreateRectRgn(%d, %d, %d, %d) => 0\n", x, y, width, height); + return 0; +} + +static int WINAPI expEnumWindows(int (*callback_func)(), void *callback_param) +{ + int i, i2; + dbgprintf("EnumWindows(0x%x, 0x%x) => 1\n", callback_func, callback_param); + i = callback_func(0, callback_param); + i2 = callback_func(1, callback_param); + return i && i2; +} + +static int WINAPI expGetWindowThreadProcessId(HWND win, int *pid_data) +{ + int tid = pthread_self(); + dbgprintf("GetWindowThreadProcessId(0x%x, 0x%x) => %d\n", + win, pid_data, tid); + if (pid_data) + (int)*pid_data = tid; + return tid; +} + +//HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,INT,INT, +// INT,INT,HWND,HMENU,HINSTANCE,LPVOID); + +static HWND WINAPI expCreateWindowExA(int exstyle, const char *classname, + const char *winname, int style, int x, int y, int w, int h, + HWND parent, HMENU menu, HINSTANCE inst, LPVOID param) +{ + printf("CreateWindowEx() called\n"); + dbgprintf("CreateWindowEx(%d, 0x%x = %s, 0x%x = %s, %d, %d, %d, %d, %d, 0x%x, 0x%x, 0x%x, 0x%x) => 1\n", + exstyle, classname, classname, winname, winname, style, x, y, w, h, + parent, menu, inst, param); + printf("CreateWindowEx() called okey\n"); + return 1; +} + +static int WINAPI expwaveOutGetNumDevs(void) +{ + dbgprintf("waveOutGetNumDevs() => 0\n"); + return 0; +} +#endif + /* * Returns the number of milliseconds, modulo 2^32, since the start * of the wineserver. @@ -2510,6 +2815,14 @@ static long WINAPI expInterlockedExchangeAdd( long* dest, long incr ) return ret; } +static long WINAPI expInterlockedCompareExchange( unsigned long* dest, unsigned long exchange, unsigned long comperand) +{ + unsigned long retval = *dest; + if(*dest == comperand) + *dest = exchange; + return retval; +} + static long WINAPI expInterlockedIncrement( long* dest ) { long result=expInterlockedExchangeAdd( dest, 1 ) + 1; @@ -2531,14 +2844,14 @@ static void WINAPI expOutputDebugStringA( const char* string ) static int WINAPI expGetDC(int hwnd) { - dbgprintf("GetDC(0x%x) => 0\n", hwnd); - return 0; + dbgprintf("GetDC(0x%x) => 1\n", hwnd); + return 1; } static int WINAPI expReleaseDC(int hwnd, int hdc) { - dbgprintf("ReleaseDC(0x%x, 0x%x) => 0\n", hwnd, hdc); - return 0; + dbgprintf("ReleaseDC(0x%x, 0x%x) => 1\n", hwnd, hdc); + return 1; } static int WINAPI expGetDesktopWindow() @@ -2564,6 +2877,18 @@ static int WINAPI expGetCursorPos(void *cursor) dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor); return 1; } +#ifdef QTX +static int show_cursor = 0; +static int WINAPI expShowCursor(int show) +{ + dbgprintf("ShowCursor(%d) => %d\n", show, show); + if (show) + show_cursor++; + else + show_cursor--; + return show_cursor; +} +#endif static int WINAPI expRegisterWindowMessageA(char *message) { dbgprintf("RegisterWindowMessageA(%s)\n", message); @@ -2590,14 +2915,39 @@ static int WINAPI expGetCPInfo(int cp,void *info) dbgprintf("GetCPInfo()\n"); return 0; } +#ifdef QTX +#define SM_CXSCREEN 0 +#define SM_CYSCREEN 1 +#define SM_XVIRTUALSCREEN 76 +#define SM_YVIRTUALSCREEN 77 +#define SM_CXVIRTUALSCREEN 78 +#define SM_CYVIRTUALSCREEN 79 +#define SM_CMONITORS 80 +#endif static int WINAPI expGetSystemMetrics(int index) { dbgprintf("GetSystemMetrics(%d)\n", index); +#ifdef QTX + switch(index) + { + case SM_XVIRTUALSCREEN: + case SM_YVIRTUALSCREEN: + return 0; + case SM_CXSCREEN: + case SM_CXVIRTUALSCREEN: + return PSEUDO_SCREEN_WIDTH; + case SM_CYSCREEN: + case SM_CYVIRTUALSCREEN: + return PSEUDO_SCREEN_HEIGHT; + case SM_CMONITORS: + return 1; + } +#endif return 1; } static int WINAPI expGetSysColor(int index) { - dbgprintf("GetSysColor(%d)\n", index); + dbgprintf("GetSysColor(%d) => 1\n", index); return 1; } static int WINAPI expGetSysColorBrush(int index) @@ -2702,6 +3052,21 @@ static int WINAPI expGetSystemTime(SYSTEMTIME* systime) return 0; } +#define SECS_1601_TO_1970 ((369 * 365 + 89) * 86400ULL) +static void WINAPI expGetSystemTimeAsFileTime(FILETIME* systime) +{ + /* struct tm *local_tm; -- unused */ + struct timeval tv; + unsigned long long secs; + + dbgprintf("GetSystemTime(0x%x)\n", systime); + gettimeofday(&tv, NULL); + secs = (tv.tv_sec + SECS_1601_TO_1970) * 10000000; + secs += tv.tv_usec * 10; + systime->dwLowDateTime = secs & 0xffffffff; + systime->dwHighDateTime = (secs >> 32); +} + static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size) { /* char *p; */ @@ -2747,12 +3112,12 @@ void CoTaskMemFree(void* cb) struct COM_OBJECT_INFO { GUID clsid; - long (*GetClassObject) (GUID* clsid, GUID* iid, void** ppv); + long (*GetClassObject) (GUID* clsid, const GUID* iid, void** ppv); }; static struct COM_OBJECT_INFO* com_object_table=0; static int com_object_size=0; -int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs) +int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs) { if(!clsid || !gcs) return -1; @@ -2762,7 +3127,7 @@ int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs) return 0; } -int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs) +int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs) { int found = 0; int i = 0; @@ -2799,19 +3164,19 @@ int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs) } -GUID IID_IUnknown = +const GUID IID_IUnknown = { 0x00000000, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }; -GUID IID_IClassFactory = +const GUID IID_IClassFactory = { 0x00000001, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }; -static 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, const GUID* riid, void** ppv) { int i; struct COM_OBJECT_INFO* ci=0; @@ -2825,7 +3190,7 @@ static long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, } long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, - long dwClsContext, GUID* riid, void** ppv) + long dwClsContext, const GUID* riid, void** ppv) { return expCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); } @@ -2833,9 +3198,8 @@ long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, static int WINAPI expIsRectEmpty(CONST RECT *lprc) { int r = 0; -// int r = (!lprc || (lprc->right == lprc->left) || (lprc->top == lprc->bottom)); int w,h; - +//trapbug(); if (lprc) { w = lprc->right - lprc->left; @@ -2847,9 +3211,9 @@ static int WINAPI expIsRectEmpty(CONST RECT *lprc) r = 1; dbgprintf("IsRectEmpty(%p) => %s\n", lprc, (r) ? "TRUE" : "FALSE"); -// printf("Rect: left: %d, top: %d, right: %d, bottom: %d\n", -// lprc->left, lprc->top, lprc->right, lprc->bottom); - return r; + //printf("Rect: left: %d, top: %d, right: %d, bottom: %d\n", lprc->left, lprc->top, lprc->right, lprc->bottom); +// return 0; // wmv9? + return r; // TM20 } static int _adjust_fdiv=0; //what's this? - used to adjust division @@ -2886,21 +3250,69 @@ static unsigned int WINAPI expGetTempPathA(unsigned int len, char* path) } WIN32_FIND_DATAA, *LPWIN32_FIND_DATAA; */ +static DIR* qtx_dir=NULL; + +static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA lpfd) +{ +#ifdef QTX + dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, lpfd); + if(h==FILE_HANDLE_quicktimeqtx){ + struct dirent* d; + if(!qtx_dir) return 0; + while((d=readdir(qtx_dir))){ + char* x=strrchr(d->d_name,'.'); + if(!x) continue; + if(strcmp(x,".qtx")) continue; + strcpy(lpfd->cFileName,d->d_name); +// sprintf(lpfd->cAlternateFileName,"%-8s.qtx",d->d_name); + strcpy(lpfd->cAlternateFileName,"foobar.qtx"); + printf("### FindNext: %s\n",lpfd->cFileName); + return 1; + } + closedir(qtx_dir); qtx_dir=NULL; + return 0; + } +#endif + return 0; +} + static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd) { +#ifdef QTX + if(strstr(s, "*.QTX")){ + dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd); + qtx_dir=opendir(win32_def_path); + if(!qtx_dir) return (HANDLE)-1; + memset(lpfd,0,sizeof(*lpfd)); + if(expFindNextFileA(FILE_HANDLE_quicktimeqtx,lpfd)) + return FILE_HANDLE_quicktimeqtx; + printf("loader: Couldn't find the QuickTime plugins (.qtx files) at %s\n",win32_def_path); + return (HANDLE)-1; + } + if(strstr(s, "QuickTime.qts")){ + dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTS\n", s, s, lpfd); +// if(!strcmp(s,"C:\\windows\\QuickTime.qts\\QuickTime.qts\\*.QTX")) +// return (HANDLE)-1; + strcpy(lpfd->cFileName, "QuickTime.qts"); + strcpy(lpfd->cAlternateFileName, "QuickT~1.qts"); + return FILE_HANDLE_quicktimeqts; + } +#endif 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; -} -static WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p) -{ - dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, p); - return 0; + return (HANDLE)-1; } + static WIN_BOOL WINAPI expFindClose(HANDLE h) { dbgprintf("FindClose(0x%x) => 0\n", h); +#ifdef QTX +// if(h==FILE_HANDLE_quicktimeqtx && qtx_dir){ +// closedir(qtx_dir); +// qtx_dir=NULL; +// } +#endif return 0; } static UINT WINAPI expSetErrorMode(UINT i) @@ -2917,7 +3329,52 @@ static UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c) dbgprintf("GetWindowsDirectoryA(0x%x, %d) => %d\n", s, c, result); return result; } +#ifdef QTX +static UINT WINAPI expGetCurrentDirectoryA(UINT c, LPSTR s) +{ + char curdir[]="c:\\"; + int result; + strncpy(s, curdir, c); + result=1+((c<strlen(curdir))?c:strlen(curdir)); + dbgprintf("GetCurrentDirectoryA(0x%x, %d) => %d\n", s, c, result); + return result; +} + +static int WINAPI expSetCurrentDirectoryA(const char *pathname) +{ + dbgprintf("SetCurrentDirectoryA(0x%x = %s) => 1\n", pathname, pathname); +#if 0 + if (strrchr(pathname, '\\')) + chdir(strcat(strrchr(pathname, '\\')+1, '/')); + else + chdir(pathname); +#endif + return 1; +} +static int WINAPI expCreateDirectoryA(const char *pathname, void *sa) +{ + dbgprintf("CreateDirectory(0x%x = %s, 0x%x) => 1\n", + pathname, pathname, sa); +#if 0 + p = strrchr(pathname, '\\')+1; + strcpy(&buf[0], p); /* should be strncpy */ + if (!strlen(p)) + { + buf[0] = '.'; + buf[1] = 0; + } +#if 0 + if (strrchr(pathname, '\\')) + mkdir(strcat(strrchr(pathname, '\\')+1, '/'), 666); + else + mkdir(pathname, 666); +#endif + mkdir(&buf); +#endif + return 1; +} +#endif static WIN_BOOL WINAPI expDeleteFileA(LPCSTR s) { dbgprintf("DeleteFileA(0x%x='%s') => 0\n", s, s); @@ -2956,6 +3413,31 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, i2, p1, i3, i4, i5); if((!cs1) || (strlen(cs1)<2))return -1; +#ifdef QTX + if(strstr(cs1, "QuickTime.qts")) + { + int result; + char* tmp=(char*)malloc(strlen(win32_def_path)+50); + strcpy(tmp, win32_def_path); + strcat(tmp, "/"); + strcat(tmp, "QuickTime.qts"); + result=open(tmp, O_RDONLY); + free(tmp); + return result; + } + if(strstr(cs1, ".qtx")) + { + int result; + char* tmp=(char*)malloc(strlen(win32_def_path)+250); + char* x=strrchr(cs1,'\\'); + sprintf(tmp,"%s/%s",win32_def_path,x?(x+1):cs1); +// printf("### Open: %s -> %s\n",cs1,tmp); + result=open(tmp, O_RDONLY); + free(tmp); + return result; + } +#endif + if(strncmp(cs1, "AP", 2) == 0) { int result; @@ -2994,7 +3476,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, } #if 0 - /* we need this for some virtualdub filters */ + /* we need this for some virtualdub filters */ { int r; int flg = 0; @@ -3007,7 +3489,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, } r=open(cs1, flg); return r; - } + } #endif return atoi(cs1+2); @@ -3038,7 +3520,18 @@ static DWORD WINAPI expGetFullPathNameA if(!lpFileName) return 0; dbgprintf("GetFullPathNameA('%s',%d,%p,%p)\n",lpFileName,nBufferLength, lpBuffer, lpFilePart); +#if 0 +#ifdef QTX + strcpy(lpFilePart, "Quick123.qts"); +#else strcpy(lpFilePart, lpFileName); +#endif +#else + if (strrchr(lpFileName, '\\')) + *lpFilePart = strrchr(lpFileName, '\\'); + else + *lpFilePart = lpFileName; +#endif strcpy(lpBuffer, lpFileName); // strncpy(lpBuffer, lpFileName, rindex(lpFileName, '\\')-lpFileName); return strlen(lpBuffer); @@ -3055,7 +3548,7 @@ static DWORD WINAPI expGetShortPathNameA strcpy(shortpath,longpath); return strlen(shortpath); } - + static WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused) { int result; @@ -3079,7 +3572,7 @@ static WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LP 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); + dbgprintf("SetFilePointer(%d, 0x%x, 0x%x = %d, %d)\n", h, val, ext, *ext, whence); //why would DLL want temporary file with >2Gb size? switch(whence) { @@ -3092,6 +3585,10 @@ static DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whe default: return -1; } +#ifdef QTX + if (val == 0 && ext != 0) + val = val&(*ext); +#endif return lseek(h, val, wh); } @@ -3180,14 +3677,25 @@ static LONG WINAPI expInterlockedExchange(long *dest, long l) static void WINAPI expInitCommonControls(void) { - printf("InitCommonControls called!\n"); + dbgprintf("InitCommonControls called!\n"); return; } +#ifdef QTX +/* needed by QuickTime.qts */ +static HWND WINAPI expCreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy, + HWND parent, INT id, HINSTANCE inst, + HWND buddy, INT maxVal, INT minVal, INT curVal) +{ + dbgprintf("CreateUpDownControl(...)\n"); + return 0; +} +#endif + /* alex: implement this call! needed for 3ivx */ static HRESULT WINAPI expCoCreateFreeThreadedMarshaler(void *pUnkOuter, void **ppUnkInner) { - printf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n", + dbgprintf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n", pUnkOuter, ppUnkInner); // return 0; return ERROR_CALL_NOT_IMPLEMENTED; @@ -3280,7 +3788,81 @@ static int expdelete(void* memory) my_release(memory); return 0; } -#if 1 + +/* + * local definition - we need only the last two members at this point + * otherwice we would have to introduce here GUIDs and some more types.. + */ +typedef struct __attribute__((__packed__)) +{ + char hay[0x40]; + unsigned long cbFormat; //0x40 + char* pbFormat; //0x44 +} MY_MEDIA_TYPE; +static HRESULT WINAPI expMoCopyMediaType(MY_MEDIA_TYPE* dest, const MY_MEDIA_TYPE* src) +{ + if (!dest || !src) + return E_POINTER; + memcpy(dest, src, sizeof(MY_MEDIA_TYPE)); + if (dest->cbFormat) + { + dest->pbFormat = (char*) my_mreq(dest->cbFormat, 0); + if (!dest->pbFormat) + return E_OUTOFMEMORY; + memcpy(dest->pbFormat, src->pbFormat, dest->cbFormat); + } + return S_OK; +} +static HRESULT WINAPI expMoInitMediaType(MY_MEDIA_TYPE* dest, DWORD cbFormat) +{ + if (!dest) + return E_POINTER; + memset(dest, 0, sizeof(MY_MEDIA_TYPE)); + if (cbFormat) + { + dest->pbFormat = (char*) my_mreq(cbFormat, 0); + if (!dest->pbFormat) + return E_OUTOFMEMORY; + } + return S_OK; +} +static HRESULT WINAPI expMoCreateMediaType(MY_MEDIA_TYPE** dest, DWORD cbFormat) +{ + if (!dest) + return E_POINTER; + *dest = my_mreq(sizeof(MY_MEDIA_TYPE), 0); + return expMoInitMediaType(*dest, cbFormat); +} +static HRESULT WINAPI expMoDuplicateMediaType(MY_MEDIA_TYPE** dest, const void* src) +{ + if (!dest) + return E_POINTER; + *dest = my_mreq(sizeof(MY_MEDIA_TYPE), 0); + return expMoCopyMediaType(*dest, src); +} +static HRESULT WINAPI expMoFreeMediaType(MY_MEDIA_TYPE* dest) +{ + if (!dest) + return E_POINTER; + if (dest->pbFormat) + { + my_release(dest->pbFormat); + dest->pbFormat = 0; + dest->cbFormat = 0; + } + return S_OK; +} +static HRESULT WINAPI expMoDeleteMediaType(MY_MEDIA_TYPE* dest) +{ + if (!dest) + return E_POINTER; + expMoFreeMediaType(dest); + my_release(dest); + return S_OK; +} + + +#if 0 static int exp_initterm(int v1, int v2) { dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2); @@ -3288,25 +3870,49 @@ static int exp_initterm(int v1, int v2) } #else /* merged from wine - 2002.04.21 */ -typedef void (*_INITTERMFUNC)(void); +typedef void (*_INITTERMFUNC)(); static int exp_initterm(_INITTERMFUNC *start, _INITTERMFUNC *end) { - _INITTERMFUNC *current = start; - - dbgprintf("_initterm(0x%x, 0x%x)\n", start, end); - while (current < end) + dbgprintf("_initterm(0x%x, 0x%x) %p\n", start, end, *start); + while (start < end) { - if (*current) + if (*start) { - printf("call init func: %p\n", *current); - (**current)(); + //printf("call _initfunc: from: %p %d\n", *start); + // ok this trick with push/pop is necessary as otherwice + // edi/esi registers are being trashed + void* p = *start; + __asm__ __volatile__ + ( + "pushl %%ebx \n\t" + "pushl %%ecx \n\t" + "pushl %%edx \n\t" + "pushl %%edi \n\t" + "pushl %%esi \n\t" + "call *%%eax \n\t" + "popl %%esi \n\t" + "popl %%edi \n\t" + "popl %%edx \n\t" + "popl %%ecx \n\t" + "popl %%ebx \n\t" + : + : "a"(p) + : "memory" + ); + //printf("done %p %d:%d\n", end); } - current++; + start++; } return 0; } #endif +static void* exp__dllonexit() +{ + // FIXME extract from WINE + return NULL; +} + static int expwsprintfA(char* string, char* format, ...) { va_list va; @@ -3435,7 +4041,7 @@ static char* expstrcat(char* str1, const char* str2) static char* exp_strdup(const char* str1) { int l = strlen(str1); - char* result = my_mreq(l + 1,0); + char* result = (char*) my_mreq(l + 1,0); if (result) strcpy(result, str1); dbgprintf("_strdup(0x%x='%s') => %p\n", str1, str1, result); @@ -3578,12 +4184,31 @@ static void exp_ftol(void) ); } +/* #warning check for _CIpow */ +static double exp_CIpow(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 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 double expldexp(double x, int expo) +{ + /*printf("Cos %f => %f 0x%Lx\n", x, cos(x), *((int64_t*)&x));*/ + return ldexp(x, expo); +} + +static double expfrexp(double x, int* expo) +{ + /*printf("Cos %f => %f 0x%Lx\n", x, cos(x), *((int64_t*)&x));*/ + return frexp(x, expo); +} + static int exp_stricmp(const char* s1, const char* s2) @@ -3616,6 +4241,7 @@ static int exp_setjmp3(void* jmpbuf, int x) "movl $0, 36(%%edx) \n\t" : // output : "d"(jmpbuf) // input + : "eax" ); #if 1 __asm__ __volatile__ @@ -3628,6 +4254,7 @@ static int exp_setjmp3(void* jmpbuf, int x) "l1: \n\t" : : + : "eax" ); #endif @@ -3636,16 +4263,10 @@ static int exp_setjmp3(void* jmpbuf, int x) static DWORD WINAPI expGetCurrentProcessId(void) { + dbgprintf("GetCurrentProcessId(void) => %d\n", getpid()); return getpid(); //(DWORD)NtCurrentTeb()->pid; } -static HANDLE WINAPI -expCreateMutexA( SECURITY_ATTRIBUTES *sa, WIN_BOOL owner, LPCSTR name ){ - static int x=0xcfcf9898; - //++x; - dbgprintf("CreateMutexA(%p,%d,'%s') => %d\n",sa,owner,name,x); - return x; -} typedef struct { UINT wPeriodMin; @@ -3669,6 +4290,16 @@ static MMRESULT WINAPI exptimeBeginPeriod(UINT wPeriod) return 0; } +#ifdef QTX +static MMRESULT WINAPI exptimeEndPeriod(UINT wPeriod) +{ + dbgprintf("timeEndPeriod(%u) !\n", wPeriod); + + if (wPeriod < 1 || wPeriod > 65535) return 96+1; //TIMERR_NOCANDO; + return 0; +} +#endif + static void WINAPI expGlobalMemoryStatus( LPMEMORYSTATUS lpmem ) { @@ -3777,7 +4408,11 @@ static void WINAPI expExitProcess( DWORD status ) static INT WINAPI expMessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type){ printf("MSGBOX '%s' '%s' (%d)\n",text,title,type); - return 1; +#ifdef QTX + if (type == MB_ICONHAND && !strlen(text) && !strlen(title)) + return IDIGNORE; +#endif + return IDOK; } /* these are needed for mss1 */ @@ -3797,6 +4432,11 @@ static WINAPI inline unsigned long int expntohl(unsigned long int netlong) // dbgprintf("ntohl(%x) => %x\n", netlong, ntohl(netlong)); return ntohl(netlong); } +static void WINAPI expVariantInit(void* p) +{ + printf("InitCommonControls called!\n"); + return; +} int expRegisterClassA(const void/*WNDCLASSA*/ *wc) { @@ -3810,6 +4450,113 @@ int expUnregisterClassA(const char *className, HINSTANCE hInstance) return 0; } +#ifdef QTX +/* should be fixed bcs it's not fully strlen equivalent */ +static int expSysStringByteLen(void *str) +{ + dbgprintf("SysStringByteLen(%p) => %d\n", str, strlen(str)); + return strlen(str); +} + +static int expDirectDrawCreate(void) +{ + dbgprintf("DirectDrawCreate(...) => NULL\n"); + return NULL; +} + +#if 1 +typedef struct tagPALETTEENTRY { + BYTE peRed; + BYTE peGreen; + BYTE peBlue; + BYTE peFlags; +} PALETTEENTRY; + +/* reversed the first 2 entries */ +typedef struct tagLOGPALETTE { + WORD palNumEntries; + WORD palVersion; + PALETTEENTRY palPalEntry[1]; +} LOGPALETTE; + +static HPALETTE WINAPI expCreatePalette(CONST LOGPALETTE *lpgpl) +{ + HPALETTE test; + int i; + + dbgprintf("CreatePalette(%x) => NULL\n", lpgpl); + + i = sizeof(LOGPALETTE)+((lpgpl->palNumEntries-1)*sizeof(PALETTEENTRY)); + test = malloc(i); + memcpy(test, lpgpl, i); + + return test; +} +#else +static int expCreatePalette(void) +{ + dbgprintf("CreatePalette(...) => NULL\n"); + return NULL; +} +#endif + +static int WINAPI expGetClientRect(HWND win, RECT *r) +{ + dbgprintf("GetClientRect(0x%x, 0x%x) => 1\n", win, r); + r->right = PSEUDO_SCREEN_WIDTH; + r->left = 0; + r->bottom = PSEUDO_SCREEN_HEIGHT; + r->top = 0; + return 1; +} + +#if 0 +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT, *PPOINT; +#endif + +static int WINAPI expClientToScreen(HWND win, POINT *p) +{ + dbgprintf("ClientToScreen(0x%x, 0x%x = %d,%d) => 1\n", win, p, p->x, p->y); + p->x = 0; + p->y = 0; + return 1; +} +#endif + +/* for m3jpeg */ +static int WINAPI expSetThreadIdealProcessor(HANDLE thread, int proc) +{ + dbgprintf("SetThreadIdealProcessor(0x%x, %x) => 0\n", thread, proc); + return 0; +} + +static int WINAPI expMessageBeep(int type) +{ + dbgprintf("MessageBeep(%d) => 1\n", type); + return 1; +} + +static int WINAPI expDialogBoxParamA(void *inst, const char *name, + HWND parent, void *dialog_func, void *init_param) +{ + dbgprintf("DialogBoxParamA(0x%x, 0x%x = %s, 0x%x, 0x%x, 0x%x) => 0x42424242\n", + inst, name, name, parent, dialog_func, init_param); + return 0x42424242; +} + +/* needed by imagepower mjpeg2k */ +static void *exprealloc(void *ptr, size_t size) +{ + dbgprintf("realloc(0x%x, %x)\n", ptr, size); + if (!ptr) + return my_mreq(size,0); + else + return my_realloc(ptr, size); +} + struct exports { char name[64]; @@ -3838,6 +4585,12 @@ struct exports exp_kernel32[]= FF(SetEvent, -1) FF(ResetEvent, -1) FF(WaitForSingleObject, -1) +#ifdef QTX + FF(WaitForMultipleObjects, -1) + FF(ExitThread, -1) + FF(CreateMutexA,-1) + FF(ReleaseMutex,-1) +#endif FF(GetSystemInfo, -1) FF(GetVersion, 332) FF(HeapCreate, 461) @@ -3893,6 +4646,9 @@ struct exports exp_kernel32[]= FF(GetStartupInfoA, -1) FF(GetStdHandle, -1) FF(GetFileType, -1) +#ifdef QTX + FF(GetFileAttributesA, -1) +#endif FF(SetHandleCount, -1) FF(GetACP, -1) FF(GetModuleFileNameA, -1) @@ -3918,6 +4674,7 @@ struct exports exp_kernel32[]= FF(OutputDebugStringA, -1) FF(GetLocalTime, -1) FF(GetSystemTime, -1) + FF(GetSystemTimeAsFileTime, -1) FF(GetEnvironmentVariableA, -1) FF(SetEnvironmentVariableA, -1) FF(RtlZeroMemory,-1) @@ -3936,12 +4693,18 @@ struct exports exp_kernel32[]= FF(CreateFileA,-1) FF(GetSystemDirectoryA,-1) FF(GetWindowsDirectoryA,-1) +#ifdef QTX + FF(GetCurrentDirectoryA,-1) + FF(SetCurrentDirectoryA,-1) + FF(CreateDirectoryA,-1) +#endif FF(GetShortPathNameA,-1) FF(GetFullPathNameA,-1) FF(SetErrorMode, -1) FF(IsProcessorFeaturePresent, -1) FF(GetProcessAffinityMask, -1) FF(InterlockedExchange, -1) + FF(InterlockedCompareExchange, -1) FF(MulDiv, -1) FF(lstrcmpiA, -1) FF(lstrlenA, -1) @@ -3956,16 +4719,17 @@ struct exports exp_kernel32[]= FF(GetTickCount, -1) FF(SetThreadAffinityMask,-1) FF(GetCurrentProcessId,-1) - FF(CreateMutexA,-1) FF(GlobalMemoryStatus,-1) FF(SetThreadPriority,-1) FF(ExitProcess,-1) {"LoadLibraryExA", -1, (void*)&LoadLibraryExA}, + FF(SetThreadIdealProcessor,-1) }; struct exports exp_msvcrt[]={ FF(malloc, -1) FF(_initterm, -1) + FF(__dllonexit, -1) FF(free, -1) {"??3@YAXPAX@Z", -1, expdelete}, {"??2@YAPAXI@Z", -1, expnew}, @@ -3996,6 +4760,9 @@ struct exports exp_msvcrt[]={ FF(pow, -1) FF(cos, -1) FF(_ftol,-1) + FF(_CIpow,-1) + FF(ldexp,-1) + FF(frexp,-1) FF(sprintf,-1) FF(sscanf,-1) FF(fopen,-1) @@ -4004,7 +4771,14 @@ struct exports exp_msvcrt[]={ FF(getenv,-1) FF(_EH_prolog,-1) FF(calloc,-1) - {"ceil",-1,(void*)&ceil} + {"ceil",-1,(void*)&ceil}, +/* needed by imagepower mjpeg2k */ + {"clock",-1,(void*)&clock}, + {"memchr",-1,(void*)&memchr}, + {"vfprintf",-1,(void*)&vfprintf}, +// {"realloc",-1,(void*)&realloc}, + FF(realloc,-1) + {"puts",-1,(void*)&puts} }; struct exports exp_winmm[]={ FF(GetDriverModuleHandle, -1) @@ -4014,6 +4788,10 @@ struct exports exp_winmm[]={ FF(OpenDriver, -1) FF(timeGetDevCaps, -1) FF(timeBeginPeriod, -1) +#ifdef QTX + FF(timeEndPeriod, -1) + FF(waveOutGetNumDevs, -1) +#endif }; struct exports exp_user32[]={ FF(LoadStringA, -1) @@ -4025,7 +4803,9 @@ struct exports exp_user32[]={ FF(LoadCursorA,-1) FF(SetCursor,-1) FF(GetCursorPos,-1) - FF(GetCursorPos,-1) +#ifdef QTX + FF(ShowCursor,-1) +#endif FF(RegisterWindowMessageA,-1) FF(GetSystemMetrics,-1) FF(GetSysColor,-1) @@ -4035,6 +4815,27 @@ struct exports exp_user32[]={ FF(MessageBoxA, -1) FF(RegisterClassA, -1) FF(UnregisterClassA, -1) +#ifdef QTX + FF(GetWindowRect, -1) + FF(MonitorFromWindow, -1) + FF(MonitorFromRect, -1) + FF(MonitorFromPoint, -1) + FF(EnumDisplayMonitors, -1) + FF(GetMonitorInfoA, -1) + FF(EnumDisplayDevicesA, -1) + FF(GetClientRect, -1) + FF(ClientToScreen, -1) + FF(IsWindowVisible, -1) + FF(GetActiveWindow, -1) + FF(GetClassNameA, -1) + FF(GetClassInfoA, -1) + FF(GetWindowLongA, -1) + FF(EnumWindows, -1) + FF(GetWindowThreadProcessId, -1) + FF(CreateWindowExA, -1) +#endif + FF(MessageBeep, -1) + FF(DialogBoxParamA, -1) }; struct exports exp_advapi32[]={ FF(RegCloseKey, -1) @@ -4053,6 +4854,11 @@ struct exports exp_gdi32[]={ FF(DeleteObject, -1) FF(GetDeviceCaps, -1) FF(GetSystemPaletteEntries, -1) +#ifdef QTX + FF(CreatePalette, -1) + FF(GetObjectA, -1) + FF(CreateRectRgn, -1) +#endif }; struct exports exp_version[]={ FF(GetFileVersionInfoSizeA, -1) @@ -4074,6 +4880,9 @@ struct exports exp_crtdll[]={ struct exports exp_comctl32[]={ FF(StringFromGUID2, -1) FF(InitCommonControls, 17) +#ifdef QTX + FF(CreateUpDownControl, 16) +#endif }; struct exports exp_wsock32[]={ FF(htonl,8) @@ -4081,6 +4890,18 @@ struct exports exp_wsock32[]={ }; struct exports exp_msdmo[]={ FF(memcpy, -1) // just test + FF(MoCopyMediaType, -1) + FF(MoCreateMediaType, -1) + FF(MoDeleteMediaType, -1) + FF(MoDuplicateMediaType, -1) + FF(MoFreeMediaType, -1) + FF(MoInitMediaType, -1) +}; +struct exports exp_oleaut32[]={ + FF(VariantInit, 8) +#ifdef QTX + FF(SysStringByteLen, 149) +#endif }; /* realplayer8: @@ -4098,6 +4919,7 @@ struct exports exp_msdmo[]={ 2300e 85 __CxxFrameHandler 23022 411 _purecall */ +#ifdef REALPLAYER struct exports exp_pncrt[]={ FF(malloc, -1) // just test FF(free, -1) // just test @@ -4106,14 +4928,13 @@ struct exports exp_pncrt[]={ FF(_ftol,-1) FF(_initterm, -1) }; +#endif -/* needed for Morgand MJPEG */ -struct exports exp_msvfw32[]={ - {"ICOpen", -1, (void *)&ICOpen}, - {"ICClose", -1, (void *)&ICClose}, - {"ICDecompress", -1, (void *)&ICDecompress}, - {"ICSendMessage", -1, (void *)&ICSendMessage} +#ifdef QTX +struct exports exp_ddraw[]={ + FF(DirectDrawCreate, -1) }; +#endif #define LL(X) \ {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X}, @@ -4127,48 +4948,77 @@ struct libs libraries[]={ LL(gdi32) LL(version) LL(ole32) + LL(oleaut32) LL(crtdll) LL(comctl32) LL(wsock32) LL(msdmo) - LL(msvfw32) +#ifdef REALPLAYER LL(pncrt) +#endif +#ifdef QTX + LL(ddraw) +#endif }; #if defined(__CYGWIN__) || defined(__OS2__) || defined (__OpenBSD__) #define MANGLE(a) "_" #a #else #define MANGLE(a) #a #endif -static char* called_unk = "Called unk_%s\n"; static void ext_stubs(void) { // expects: // ax position index // cx address of printf function +#if 1 + __asm__ __volatile__ + ( + "push %%edx \n\t" + "movl $0xdeadbeef, %%eax \n\t" + "movl $0xdeadbeef, %%edx \n\t" + "shl $5, %%eax \n\t" // ax * 32 + "addl $0xdeadbeef, %%eax \n\t" // overwrite export_names + "pushl %%eax \n\t" + "pushl $0xdeadbeef \n\t" // overwrite called_unk + "call *%%edx \n\t" // printf (via dx) + "addl $8, %%esp \n\t" + "xorl %%eax, %%eax \n\t" + "pop %%edx \n\t" + : + : + : "eax" + ); +#else __asm__ __volatile__ ( - "push %edx \n\t" - "movl $0, %eax \n\t" - "movl $0, %edx \n\t" - "shl $5,%eax \n\t" // ax * 32 - "addl $"MANGLE(export_names)",%eax \n\t" - "pushl %eax \n\t" - "pushl "MANGLE(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" + "push %%edx \n\t" + "movl $0, %%eax \n\t" + "movl $0, %%edx \n\t" + "shl $5, %%eax \n\t" // ax * 32 + "addl %0, %%eax \n\t" + "pushl %%eax \n\t" + "pushl %1 \n\t" + "call *%%edx \n\t" // printf (via dx) + "addl $8, %%esp \n\t" + "xorl %%eax, %%eax \n\t" + "pop %%edx \n\t" + ::"m"(*export_names), "m"(*called_unk) + : "memory", "edx", "eax" ); +#endif + } //static void add_stub(int pos) extern int unk_exp1; -static char extcode[20000];// place for 200 unresolved exports static int pos=0; +static char extcode[20000];// place for 200 unresolved exports +static const char* called_unk = "Called unk_%s\n"; -static void* add_stub() +static void* add_stub(void) { + // generated code in runtime! char* answ = (char*)extcode+pos*0x30; #if 0 memcpy(answ, &unk_exp1, 0x64); @@ -4176,10 +5026,14 @@ static void* add_stub() *(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) + //answ[4] = 0xb8; // movl $0, eax (0xb8 0x00000000) *((int*) (answ + 5)) = pos; - //answ[5] = 0xb9; // movl $0, edx (0xb9 0x00000000) - *((int*) (answ + 10)) = (int) printf; + //answ[9] = 0xba; // movl $0, edx (0xba 0x00000000) + *((long*) (answ + 10)) = (long)printf; + //answ[17] = 0x05; // addl $0, eax (0x05 0x00000000) + *((long*) (answ + 18)) = (long)export_names; + //answ[23] = 0x68; // pushl $0 (0x68 0x00000000) + *((long*) (answ + 24)) = (long)called_unk; pos++; return (void*)answ; } @@ -4209,9 +5063,10 @@ void* LookupExternal(const char* library, int ordinal) } } +#ifdef LOADLIB_TRY_NATIVE /* ok, this is a hack, and a big memory leak. should be fixed. - alex */ { - HMODULE *hand; + int hand; WINE_MODREF *wm; void *func; @@ -4224,23 +5079,24 @@ void* LookupExternal(const char* library, int ordinal) FreeLibrary(hand); goto no_dll; } - func = PE_FindExportedFunction(wm, ordinal, 0); + func = PE_FindExportedFunction(wm, (LPCSTR) ordinal, 0); if (!func) { printf("No such ordinal in external dll\n"); - FreeLibrary(hand); + FreeLibrary((int)hand); goto no_dll; } - printf("External dll loaded (offset: %p, func: %p)\n", - hand, func); + printf("External dll loaded (offset: 0x%x, func: %p)\n", + hand, func); return func; } +#endif no_dll: if(pos>150)return 0; sprintf(export_names[pos], "%s:%d", library, ordinal); - return add_stub(pos); + return add_stub(); } void* LookupExternalByName(const char* library, const char* name) @@ -4258,7 +5114,7 @@ void* LookupExternalByName(const char* library, const char* name) printf("ERROR: name=0\n"); return (void*)ext_unknown; } - //printf("External func %s:%s\n", library, name); + dbgprintf("External func %s:%s\n", library, name); for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++) { if(strcasecmp(library, libraries[i].name)) @@ -4273,7 +5129,7 @@ void* LookupExternalByName(const char* library, const char* name) } if(pos>150)return 0;// to many symbols strcpy(export_names[pos], name); - return add_stub(pos); + return add_stub(); } void my_garbagecollection(void) @@ -4281,15 +5137,19 @@ void my_garbagecollection(void) #ifdef GARBAGE int unfree = 0, unfreecnt = 0; + int max_fatal = 8; free_registry(); while (last_alloc) { alloc_header* mem = last_alloc + 1; unfree += my_size(mem); unfreecnt++; - my_release(mem); + if (my_release(mem) != 0) + // avoid endless loop when memory is trashed + if (--max_fatal < 0) + break; } - dbgprintf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt); + 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 89321eb7a..79d6877e3 100644 --- a/src/libw32dll/wine/win32.h +++ b/src/libw32dll/wine/win32.h @@ -25,9 +25,7 @@ typedef struct tls_s tls_t; 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); - +extern int expRegisterClassA(const void/*WNDCLASSA*/ *wc); +extern int expUnregisterClassA(const char *className, HINSTANCE hInstance); #endif diff --git a/src/libw32dll/wine/wineacm.h b/src/libw32dll/wine/wineacm.h index 5984a68c5..e7604dc64 100644 --- a/src/libw32dll/wine/wineacm.h +++ b/src/libw32dll/wine/wineacm.h @@ -1,8 +1,19 @@ +#ifndef WINEACM_H +#define WINEACM_H /* -*- tab-width: 8; c-basic-offset: 4 -*- */ /*********************************************************************** * Wine specific - Win32 */ + + +#include "msacmdrv.h" + +#ifdef __cplusplus +extern "C" { +#endif /* defined(__cplusplus) */ + + typedef struct _WINE_ACMDRIVERID *PWINE_ACMDRIVERID; typedef struct _WINE_ACMDRIVER *PWINE_ACMDRIVER; @@ -17,6 +28,7 @@ typedef struct _WINE_ACMDRIVER HDRVR hDrvr; DRIVERPROC pfnDriverProc; PWINE_ACMDRIVER pNextACMDriver; + int iUsage; } WINE_ACMDRIVER; typedef struct _WINE_ACMSTREAM @@ -29,8 +41,8 @@ typedef struct _WINE_ACMSTREAM typedef struct _WINE_ACMDRIVERID { - LPSTR pszDriverAlias; LPSTR pszFileName; + WORD wFormatTag; HINSTANCE hInstModule; /* NULL if global */ DWORD dwProcessID; /* ID of process which installed a local driver */ WIN_BOOL bEnabled; @@ -43,13 +55,18 @@ typedef struct _WINE_ACMDRIVERID extern HANDLE MSACM_hHeap; extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID; extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID; -PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, - LPSTR pszFileName, + +PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName, + WORD wFormatTag, HINSTANCE hinstModule); -void MSACM_RegisterAllDrivers(void); PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p); void MSACM_UnregisterAllDrivers(void); PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID); PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver); PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj); +#ifdef __cplusplus +} /* extern "C" */ +#endif /* defined(__cplusplus) */ + +#endif /* WINEACM_H */ diff --git a/src/libw32dll/wine/wrapper.S b/src/libw32dll/wine/wrapper.S new file mode 100644 index 000000000..fe2d85619 --- /dev/null +++ b/src/libw32dll/wine/wrapper.S @@ -0,0 +1,83 @@ +.section .data +.globl caller_return +caller_return: + .long 0 +.globl report_entry +report_entry: + .long null_call +.globl report_ret +report_ret: + .long null_call +.global wrapper_target +wrapper_target: + .long null_call + +.section .text +.globl null_call + .type null_call, @function + .balign 16,0x90 +null_call: + ret +.globl wrapper + .type wrapper, @function + .balign 16,0x90 +wrapper: + pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) + pushf # store flags + + push %ebp # set up a stack frame + movl %esp, %ebp + + leal 4(%ebp), %eax # push flags addr + push %eax + leal 8(%ebp), %eax # push registers addr + push %eax + + leal 40(%ebp), %edx + movl (%ebp), %eax + subl %edx, %eax + push %eax + push %edx + + call *report_entry # report entry + + test %eax, %eax + jnz .Ldone + + leave # restore %esp, %ebp + popf # restore flags + popa # restore registers + + popl caller_return # switch return addresses + pushl $.Lwrapper_return + + jmp *wrapper_target # wrapper_target should return at .Lwrapper_return + + .balign 16, 0x90 +.Lwrapper_return: + pushl caller_return # restore the original return address + pusha # more for reference sake here + pushf + + push %ebp # set up a stack frame + movl %esp, %ebp + + leal 4(%ebp), %eax # push flags addr + push %eax + leal 8(%ebp), %eax # push registers addr + push %eax + + leal 40(%ebp), %edx # push stack top address (relative to our entry) + movl (%ebp), %eax + subl %edx, %eax # calculate difference between entry and previous frame + push %eax + push %edx + + call *report_ret # report the return information (same args) +.Ldone: + + leave + popf + popa + ret + diff --git a/src/libw32dll/wine/wrapper.h b/src/libw32dll/wine/wrapper.h new file mode 100644 index 000000000..e307c0e65 --- /dev/null +++ b/src/libw32dll/wine/wrapper.h @@ -0,0 +1,20 @@ +#ifndef _WRAPPER_H +#define _WRAPPER_H + +#include <sys/types.h> + +typedef struct { + u_int32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; +} reg386_t; + +typedef int (*wrapper_func_t)(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); + +extern wrapper_func_t report_entry, report_ret; + +extern void (*wrapper_target)(void); + +extern int wrapper(void); +extern int null_call(void); + +#endif /* _WRAPPER_H */ + |