Ejemplo n.º 1
0
static void InitializeTransactions()
{
    static bool initialized = false;
    if (initialized)
        return;
    initialized = true;

    HMODULE hLibKTM = SafeLoadLibrary(_T("ktmw32.dll"));
    HMODULE hLibKernel = SafeLoadLibrary(_T("kernel32.dll"));
    if (!hLibKTM || !hLibKernel)
        return;

#define Load(lib, func) _ ## func = (func ## Ptr)GetProcAddress(lib, #func)
    Load(hLibKTM, CreateTransaction);
    Load(hLibKTM, CommitTransaction);
    Load(hLibKTM, RollbackTransaction);
#undef Load
#ifdef UNICODE
#define Load(lib, func) _ ## func = (func ## Ptr)GetProcAddress(lib, #func "W")
#else
#define Load(lib, func) _ ## func = (func ## Ptr)GetProcAddress(lib, #func "A")
#endif
    Load(hLibKernel, CreateFileTransacted);
    Load(hLibKernel, DeleteFileTransacted);
#undef Load
}
Ejemplo n.º 2
0
FARPROC LoadDllFunc(WCHAR *dllName, const char *funcName)
{
    HMODULE h = SafeLoadLibrary(dllName);
    if (!h)
        return NULL;
    return GetProcAddress(h, funcName);

    // Note: we don't unload the dll. It's harmless for those that would stay
    // loaded anyway but we would crash trying to call a function that
    // was grabbed from a dll that was unloaded in the meantime
}
Ejemplo n.º 3
0
void Initialize()
{
    static bool funcsLoaded = false;
    if (funcsLoaded)
        return;

    HMODULE h = SafeLoadLibrary(L"Dwmapi.dll");
#define Load(func) _ ## func = (func ## Proc)GetProcAddress(h, #func)
    Load(DwmIsCompositionEnabled);
    Load(DwmExtendFrameIntoClientArea);
    Load(DwmDefWindowProc);
    Load(DwmGetWindowAttribute);
#undef Load

    funcsLoaded = true;
}
Ejemplo n.º 4
0
static void InitializeGestures()
{
    static bool initialized = false;
    if (initialized)
        return;
    initialized = true;

    HMODULE hLib = SafeLoadLibrary(L"user32.dll");
    if (!hLib)
        return;

#define Load(func) g_p ## func = (func ## Ptr)GetProcAddress(hLib, #func)
    Load(GetGestureInfo);
    Load(CloseGestureInfoHandle);
    Load(SetGestureConfig);
#undef Load
}
Ejemplo n.º 5
0
void Initialize()
{
    static bool funcsLoaded = false;
    if (funcsLoaded)
        return;

    HMODULE h = SafeLoadLibrary(L"UxTheme.dll");
#define Load(func) _ ## func = (func ## Proc)GetProcAddress(h, #func)
    Load(OpenThemeData);
    Load(CloseThemeData);
    Load(DrawThemeBackground);
    Load(IsThemeActive);
    Load(IsThemeBackgroundPartiallyTransparent);
    Load(GetThemeColor);
#undef Load

    funcsLoaded = true;
}
Ejemplo n.º 6
0
void ISV_RegisterModule (BOOL fMode)
{
    char *pchDll,*pchInit,*pchDispatch;
    HANDLE hDll;
    FARPROC DispatchEntry;
    FARPROC InitEntry;
    ULONG i;
    UCHAR uchMode;

    // Check if we have free space in bop table.
    for (i=0; i<MAX_ISV_BOP; i++) {
    if (isvbop_table[i].hDll == 0)
        break;
    }

    if (i == MAX_ISV_BOP) {
    setCF (1);
    setAX(4);
    return;
    }

    uchMode = fMode ? TRUE : FALSE;

    pchDll = (PCHAR) Sim32GetVDMPointer (SEGOFF(getDS(),getSI()),
                                         1,
                                         uchMode
                                         );
    if (pchDll == NULL) {
    setCF (1);
    setAX(1);
    return;
    }
    pchInit = (PCHAR) Sim32GetVDMPointer(SEGOFF(getES(),getDI()),
                                         1,
                                         uchMode
                                         );

    pchDispatch = (PCHAR) Sim32GetVDMPointer(SEGOFF(getDS(),getBX()),
                                             1,
                                             uchMode
                                             );
    if (pchDispatch == NULL) {
    setCF (1);
    setAX(2);
    return;
    }

    if ((hDll = SafeLoadLibrary(pchDll)) == NULL){
    setCF (1);
    setAX(1);
    return;
    }

    // Get the init entry point and dispatch entry point
    if (pchInit){
    if ((ULONG)pchInit < 64*1024){
        if (strlen (pchInit) >= MAX_PROC_NAME) {
        FreeLibrary(hDll);
        setCF (1);
        setAX(4);
        return;
        }
        strcpy (procbuffer,pchInit);
        pchInit = procbuffer;
    }

    if ((InitEntry = (MYFARPROC)GetProcAddress(hDll, pchInit)) == NULL){
        FreeLibrary(hDll);
        setCF(1);
        setAX(3);
            return;
    }
    }

    if ((ULONG)pchDispatch < 64*1024){
    if (strlen (pchDispatch) >= MAX_PROC_NAME) {
        FreeLibrary(hDll);
        setCF (1);
        setAX(4);
        return;
    }
    strcpy (procbuffer,pchDispatch);
    pchDispatch = procbuffer;
    }

    if ((DispatchEntry = (MYFARPROC)GetProcAddress(hDll, pchDispatch)) == NULL){
    FreeLibrary(hDll);
    setCF(1);
    setAX(2);
    return;
    }

    // Call the init routine
    if (pchInit) {
    (*InitEntry)();
    }

    // Fill up the bop table
    isvbop_table[i].hDll = hDll;
    isvbop_table[i].fpDispatch = DispatchEntry;

    i++;

    setAX((USHORT)i);

    return;
}
Ejemplo n.º 7
0
BOOL LoadVdmRedir() {

#if DBG
    LPSTR funcName = "";
#endif

    if (VdmRedirLoaded) {
        return TRUE;
    }
    if (hVdmRedir = SafeLoadLibrary("VDMREDIR")) {

        //
        // get addresses of procedures called by functions in dos\dem\demfile.c
        // and dos\dem\demhndl.c
        //

        if ((VrDispatch = (MYFARPROC)GetProcAddress(hVdmRedir, "VrDispatch")) == NULL) {
#if DBG
            funcName = "VrDispatch";
#endif
            goto closeAndReturnError;
        }
        if ((VrInitialized = (MYFARPROC)GetProcAddress(hVdmRedir, "VrInitialized")) == NULL) {
#if DBG
            funcName = "VrInitialized";
#endif
            goto closeAndReturnError;
        }
        if ((VrReadNamedPipe = (MYFARPROC)GetProcAddress(hVdmRedir, "VrReadNamedPipe")) == NULL) {
#if DBG
            funcName = "VrReadNamedPipe";
#endif
            goto closeAndReturnError;
        }
        if ((VrWriteNamedPipe = (MYFARPROC)GetProcAddress(hVdmRedir, "VrWriteNamedPipe")) == NULL) {
#if DBG
            funcName = "VrWriteNamedPipe";
#endif
            goto closeAndReturnError;
        }
        if ((VrIsNamedPipeName = (MYFARPROC)GetProcAddress(hVdmRedir, "VrIsNamedPipeName")) == NULL) {
#if DBG
            funcName = "VrIsNamedPipeName";
#endif
            goto closeAndReturnError;
        }
        if ((VrIsNamedPipeHandle = (MYFARPROC)GetProcAddress(hVdmRedir, "VrIsNamedPipeHandle")) == NULL) {
#if DBG
            funcName = "VrIsNamedPipeHandle";
#endif
            goto closeAndReturnError;
        }
        if ((VrAddOpenNamedPipeInfo = (MYFARPROC)GetProcAddress(hVdmRedir, "VrAddOpenNamedPipeInfo")) == NULL) {
#if DBG
            funcName = "VrAddOpenNamedPipeInfo";
#endif
            goto closeAndReturnError;
        }
        if ((VrConvertLocalNtPipeName = (MYFARPROC)GetProcAddress(hVdmRedir, "VrConvertLocalNtPipeName")) == NULL) {
#if DBG
            funcName = "VrConvertLocalNtPipeName";
#endif
            goto closeAndReturnError;
        }
        if ((VrRemoveOpenNamedPipeInfo = (MYFARPROC)GetProcAddress(hVdmRedir, "VrRemoveOpenNamedPipeInfo")) == NULL) {
#if DBG
            funcName = "VrRemoveOpenNamedPipeInfo";
#endif
            goto closeAndReturnError;
        }
        VdmRedirLoaded = TRUE;
        return TRUE;
    }

closeAndReturnError:

#if DBG
        printf("MS_bop_7: Error: cannot locate entry point %s in VDMREDIR.DLL\n", funcName);
#endif

    CloseHandle(hVdmRedir);
    return FALSE;
}
Ejemplo n.º 8
0
void MS_bop_1(void) {

    if (!WowModeInitialized) {
    //Load the WOW DLL
    if ((hWOWDll = SafeLoadLibrary("WOW32")) == NULL)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        TerminateVDM();
        return;
    }

    // Get the init entry point and dispatch entry point
    if ((WOWInitEntry = (MYFARPROC)GetProcAddress(hWOWDll, "W32Init")) == NULL)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        FreeLibrary(hWOWDll);
        TerminateVDM();
        return;
    }

    if ((WOWDispatchEntry = GetProcAddress(hWOWDll, "W32Dispatch")) == NULL)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        FreeLibrary(hWOWDll);
        TerminateVDM();
        return;
    }

    //Get Comms functions
    if ((GetCommHandle = (GCHfn) GetProcAddress(hWOWDll, "GetCommHandle")) == NULL)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        FreeLibrary(hWOWDll);
        TerminateVDM();
        return;
    }

    if ((GetCommShadowMSR = (GCSfn) GetProcAddress(hWOWDll, "GetCommShadowMSR")) == NULL)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        FreeLibrary(hWOWDll);
        TerminateVDM();
        return;
    }

    //Get hung app Notification routine
    pW32HungAppNotifyThread = (VOID(*)(UINT))GetProcAddress( hWOWDll,
                                                    "W32HungAppNotifyThread");
    if (!pW32HungAppNotifyThread)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        FreeLibrary(hWOWDll);
        TerminateVDM();
        return;
    }


    // Call the init routine
    if ((*WOWInitEntry)() == FALSE)
    {
#ifndef PROD
        HostDebugBreak();
#endif
        TerminateVDM();
        return;
    }

    WowModeInitialized = TRUE;
    }

#if !defined(CPU_40_STYLE) || defined(CCPU)
    (*WOWDispatchEntry)();
#else
    // Dispatch to WOW dispatcher
    {
	static BYTE **AddressOfLocal;
	BYTE *localSimulateContext = GLOBAL_SimulateContext;

	AddressOfLocal = &localSimulateContext;

	(*WOWDispatchEntry)();

	SET_GLOBAL_SimulateContext(localSimulateContext);

	if(AddressOfLocal != &localSimulateContext)
	{
	    //Thread switch detected via stack change, force CPU to
	    //abort the current fragment, reseting GDP var's refering
	    //to the host stack

	    setEIP(getEIP());
	}
    }
#endif	/* CPU_40_STYLE */
}