Path: blob/master/libmupen64plus/mupen64plus-video-z64/src/osal_dynamiclib_win32.c
2 views
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *1* Mupen64plus-ui-console - osal_dynamiclib_win32.c *2* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *3* Copyright (C) 2009 Richard Goedeken *4* *5* This program is free software; you can redistribute it and/or modify *6* it under the terms of the GNU General Public License as published by *7* the Free Software Foundation; either version 2 of the License, or *8* (at your option) any later version. *9* *10* This program is distributed in the hope that it will be useful, *11* but WITHOUT ANY WARRANTY; without even the implied warranty of *12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *13* GNU General Public License for more details. *14* *15* You should have received a copy of the GNU General Public License *16* along with this program; if not, write to the *17* Free Software Foundation, Inc., *18* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *19* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */2021#include <windows.h>22#include <stdlib.h>23#include <stdio.h>2425#include "m64p_types.h"26#include "osal_dynamiclib.h"2728m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)29{30if (pLibHandle == NULL || pccLibraryPath == NULL)31return M64ERR_INPUT_ASSERT;3233*pLibHandle = LoadLibrary(pccLibraryPath);3435if (*pLibHandle == NULL)36{37char *pchErrMsg;38DWORD dwErr = GetLastError();39FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,40MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);41fprintf(stderr, "LoadLibrary('%s') error: %s\n", pccLibraryPath, pchErrMsg);42LocalFree(pchErrMsg);43return M64ERR_INPUT_NOT_FOUND;44}4546return M64ERR_SUCCESS;47}4849void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)50{51if (pccProcedureName == NULL)52return NULL;5354return GetProcAddress(LibHandle, pccProcedureName);55}5657m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)58{59int rval = FreeLibrary(LibHandle);6061if (rval == 0)62{63char *pchErrMsg;64DWORD dwErr = GetLastError();65FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,66MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);67fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg);68LocalFree(pchErrMsg);69return M64ERR_INTERNAL;70}7172return M64ERR_SUCCESS;73}747576