2017-05-22 00:21:22 -04:00
|
|
|
/*
|
|
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Try to load a support DLL.
|
|
|
|
|
*
|
2017-10-17 01:59:09 -04:00
|
|
|
* Version: @(#)win_dynld.c 1.0.6 2017/10/16
|
2017-05-22 00:21:22 -04:00
|
|
|
*
|
|
|
|
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
2017-10-11 05:40:44 -04:00
|
|
|
*
|
2017-05-22 00:21:22 -04:00
|
|
|
* Copyright 2017 Fred N. van Kempen
|
|
|
|
|
*/
|
|
|
|
|
#include <stdio.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdint.h>
|
2017-05-22 00:21:22 -04:00
|
|
|
#include <string.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
#include <windows.h>
|
2017-10-17 01:59:09 -04:00
|
|
|
#include "../86box.h"
|
2017-10-11 05:40:44 -04:00
|
|
|
#include "../plat_dynld.h"
|
2017-05-22 00:21:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
|
dynld_module(const char *name, dllimp_t *table)
|
|
|
|
|
{
|
2017-05-26 13:12:31 -04:00
|
|
|
HMODULE h;
|
2017-05-22 00:21:22 -04:00
|
|
|
dllimp_t *imp;
|
|
|
|
|
void *func;
|
|
|
|
|
|
|
|
|
|
/* See if we can load the desired module. */
|
|
|
|
|
if ((h = LoadLibrary(name)) == NULL) {
|
|
|
|
|
pclog("DynLd(\"%s\"): library not found!\n", name);
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now load the desired function pointers. */
|
|
|
|
|
for (imp=table; imp->name!=NULL; imp++) {
|
|
|
|
|
func = GetProcAddress(h, imp->name);
|
|
|
|
|
if (func == NULL) {
|
|
|
|
|
pclog("DynLd(\"%s\"): function '%s' not found!\n",
|
|
|
|
|
name, imp->name);
|
|
|
|
|
CloseHandle(h);
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* To overcome typing issues.. */
|
|
|
|
|
*(char **)imp->func = (char *)func;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* All good. */
|
|
|
|
|
return((void *)h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
dynld_close(void *handle)
|
|
|
|
|
{
|
|
|
|
|
if (handle != NULL)
|
2017-05-26 13:12:31 -04:00
|
|
|
FreeLibrary((HMODULE)handle);
|
2017-05-22 00:21:22 -04:00
|
|
|
}
|