OpenCBM
WINDOWS/getpluginaddress.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 1999-2005 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8  * Copyright 2001-2005,2007,2012 Spiro Trikaliotis
9  *
10 */
11 
20 #include "getpluginaddress.h"
21 
22 #include "libmisc.h"
23 
24 #include <windows.h>
25 #include <stdio.h>
26 
34 plugin_load(const char * name)
35 {
36  SHARED_OBJECT_HANDLE ModuleHandle = LoadLibrary(name);
37 
38  if (ModuleHandle == NULL) {
39  DWORD Error = GetLastError();
40 
41  char * ErrorMessage = cbmlibmisc_format_error_message(Error);
42 
43  fprintf(stderr, "Error loading plugin '%s': %s (%u)\n", name, ErrorMessage, Error);
44  }
45 
46  return ModuleHandle;
47 }
48 
57 void *
58 plugin_get_address(SHARED_OBJECT_HANDLE handle, const char * name)
59 {
60  return GetProcAddress(handle, name);
61 }
62 
69 void
71 {
72  FreeLibrary(handle);
73 }
void * SHARED_OBJECT_HANDLE
@@@
SHARED_OBJECT_HANDLE plugin_load(const char *name)
@@@
void plugin_unload(SHARED_OBJECT_HANDLE handle)
@@@
Shared library / DLL for accessing the driver Functions for obtaining the addresses of plugin functio...
void * plugin_get_address(SHARED_OBJECT_HANDLE handle, const char *name)
@@@
Some functions for string handling.
char * cbmlibmisc_format_error_message(unsigned int ErrorNumber)
Format a returned error code into a string.