Index: loader/dmo/DMO_VideoDecoder.c =================================================================== --- loader/dmo/DMO_VideoDecoder.c (revision 26108) +++ loader/dmo/DMO_VideoDecoder.c (working copy) @@ -39,7 +39,7 @@ #include #include #include -#ifndef __MINGW32__ +#ifdef HAVE_SYS_MMAN_H #include #endif #include Index: loader/ext.c =================================================================== --- loader/ext.c (revision 26108) +++ loader/ext.c (working copy) @@ -18,13 +18,18 @@ #include #endif #include +#ifdef HAVE_SYS_MMAN_H #include +#endif #include #include #include #include #include +#ifndef HAVE_SYS_MMAN_H +#include "osdep/mmap.h" +#endif #include "osdep/mmap_anon.h" #include "wine/windef.h" #include "wine/winbase.h" Index: loader/wrapper.S =================================================================== --- loader/wrapper.S (revision 26108) +++ loader/wrapper.S (working copy) @@ -1,4 +1,4 @@ -.section .data + .data .globl caller_return caller_return: .long 0 @@ -12,7 +12,7 @@ wrapper_target: .long null_call -.section .text + .text .globl null_call .type null_call, @function .balign 16,0x90 Index: loader/win32.c =================================================================== --- loader/win32.c (revision 26108) +++ loader/win32.c (working copy) @@ -68,7 +68,11 @@ #include #endif +#ifdef HAVE_SYS_MMAN_H #include +#else +#include "osdep/mmap.h" +#endif #include "osdep/mmap_anon.h" #if HAVE_VSSCANF Index: loader/dshow/DS_VideoDecoder.c =================================================================== --- loader/dshow/DS_VideoDecoder.c (revision 26108) +++ loader/dshow/DS_VideoDecoder.c (working copy) @@ -39,7 +39,7 @@ #include #include #include -#ifndef __MINGW32__ +#ifdef HAVE_SYS_MMAN_H #include #endif #include Index: loader/pe_image.c =================================================================== --- loader/pe_image.c (revision 26108) +++ loader/pe_image.c (working copy) @@ -51,6 +51,8 @@ #include #ifdef HAVE_SYS_MMAN_H #include +#else +#include "osdep/mmap.h" #endif #include "wine/windef.h" #include "wine/winbase.h" Index: loader/ldt_keeper.c =================================================================== --- loader/ldt_keeper.c (revision 26108) +++ loader/ldt_keeper.c (working copy) @@ -23,10 +23,15 @@ #include #include #include +#ifdef HAVE_SYS_MMAN_H #include +#endif #include #include #include +#ifndef HAVE_SYS_MMAN_H +#include "osdep/mmap.h" +#endif #include "osdep/mmap_anon.h" #include "mp_msg.h" #include "help_mp.h" @@ -105,8 +110,13 @@ #endif +#ifndef __OS2__ /* user level (privilege level: 3) ldt (1<<2) segment selector */ #define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3) +#else +/* we converted flat to sel already, so just return itself */ +#define LDT_SEL(sel) (sel) +#endif /* i got this value from wine sources, it's the first free LDT entry */ #if (defined(__APPLE__) || defined(__FreeBSD__)) && defined(LDT_AUTO_ALLOC) @@ -276,6 +286,11 @@ } #endif +#ifdef __OS2__ + /* convert flat addr to sel */ + fs_ldt = ( unsigned int )(( unsigned long )fs_seg >> 13 | 7 ); +#endif + Setup_FS_Segment(); ldt_fs->prev_struct = malloc(8); Index: loader/module.c =================================================================== --- loader/module.c (revision 26108) +++ loader/module.c (working copy) @@ -26,7 +26,9 @@ #include #include #include +#ifdef HAVE_SYS_MMAN_H #include +#endif #include #include "wine/windef.h" @@ -742,6 +744,48 @@ #ifdef EMU_QTX_API +#ifdef __OS2__ +uint32_t _System DosQueryMem( void *, uint32_t *, uint32_t * ); + +static int isValidPtr( void *p ) +{ + uint32_t cb = 1; + uint32_t fl; + + if( DosQueryMem( p, &cb, &fl )) + return 0; + +#ifdef DEBUG_QTX_API + printf("addr = %p, cb = %d, fl = %08X : ", p, cb, fl ); + if( fl & 0x10 ) + printf("COMMIT "); + if( fl & 0x2000 ) + printf("SHARED "); + if( fl & 0x4000 ) + printf("FREE "); + if( fl & 0x10000 ) + printf("BASE "); + if( fl & 0x01 ) + printf("READ "); + if( fl & 0x02 ) + printf("WRITE "); + if( fl & 0x04 ) + printf("EXEC "); + if( fl & 0x08 ) + printf("GUARD "); + printf("\n"); +#endif + + // Occasionally, ptr with 'EXEC' attr is passed. + // On OS/2, however, malloc() never set 'EXEC' attr. + // So ptr with 'EXEC' attr is invalid. + if( fl & 0x04 ) + return 0; + + return 1; +} +#endif + static uint32_t ret_array[4096]; static int ret_i=0; @@ -756,6 +800,7 @@ int plen=-1; // find the code: +#ifndef __OS2__ dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255); // printf("FUNC: flag=%d ptr=%p\n",dptr[0],dptr[1]); if(dptr[0]&255){ @@ -790,6 +835,7 @@ pwrapper=dptr[1]; } } +#endif for(i=0;qt_fv_list[i].name;i++){ if(qt_fv_list[i].id==reg->eax){ @@ -842,7 +888,11 @@ #endif return 1; case 0x15002f: //DisposePtr +#ifndef __OS2__ if(((uint32_t *)stack_base)[1]>=0x60000000) +#else + if( !isValidPtr((void *)((uint32_t *)stack_base)[1])) +#endif printf("WARNING! Invalid Ptr handle!\n"); else free((void *)((uint32_t *)stack_base)[1]); Index: loader/wrapper.h =================================================================== --- loader/wrapper.h (revision 26108) +++ loader/wrapper.h (working copy) @@ -9,12 +9,12 @@ typedef int (*wrapper_func_t)(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags); -extern wrapper_func_t report_entry, report_ret; +extern wrapper_func_t report_entry __asm__("report_entry"), report_ret __asm__("report_ret"); -extern void (*wrapper_target)(void); +extern void (*wrapper_target)(void) __asm__("wrapper_target"); -extern int wrapper(void); -extern int null_call(void); +extern int wrapper(void) __asm__("wrapper"); +extern int null_call(void) __asm__("null_call"); #endif /* MPLAYER_WRAPPER_H */ Index: loader/Makefile =================================================================== --- loader/Makefile (revision 26108) +++ loader/Makefile (working copy) @@ -35,6 +35,11 @@ CFLAGS+=-fno-omit-frame-pointer $(CFLAG_NO_OMIT_LEAF_FRAME_POINTER) +ifeq ($(TARGET_OS),OS/2) +wrapper.o : wrapper.S + $(CC) -Zomf -c -o $@ $^ +endif + TEST_OBJS = $(LIBNAME_COMMON) ../cpudetect.o ../mp_msg.o ../mp_fifo.o ../osdep/libosdep.a TEST_LDFLAGS = -ltermcap -ldl -lm -lpthread -g