Wine as shared library patch

Alexandre Julliard julliard at winehq.org
Mon Mar 8 16:50:21 CST 2004


Miguel de Icaza <miguel at ximian.com> writes:

> Our patch is simple, and we lack the experience to work on Wine, TEB and
> what not.    We just do not have the time to learn everything there is
> to Wine. 

Something along these lines should do the trick:


#include <wine/library.h>
#include <stdio.h>
#include <windows.h>
#include <winternl.h>
#include <setjmp.h>

static jmp_buf jmpbuf;

int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
    longjmp( jmpbuf, 1 );
}

int
SharedWineInit(void)
{
    unsigned char Error[1024]="";
    char *WineArguments[] = {"sharedapp", LIBPATH "/wine-sharedlib.exe.so", NULL};

    if (!setjmp( jmpbuf ))
    {
        wine_init(2, WineArguments, Error, sizeof(Error));
        printf( "should not get here\n" );
    }
    NtCurrentTeb()->Tib.ExceptionList = (void *)~0UL;
    VirtualFree( NtCurrentTeb()->DeallocationStack, 0, MEM_RELEASE );
    NtCurrentTeb()->DeallocationStack = NULL;
    NtCurrentTeb()->Tib.StackBase = (void*)~0UL;  /* FIXME: should find actual limits here */
    NtCurrentTeb()->Tib.StackLimit = 0;
    return(0);
}

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list