solib.cpp
来自「这是整套横扫千军3D版游戏的源码」· C++ 代码 · 共 48 行
CPP
48 行
/**
* @file SoLib.cpp
* @brief Linux shared object loader implementation
* @author Christopher Han <xiphux@gmail.com>
*
* Linux Shared Object loader class implementation
* Copyright (C) 2005. Licensed under the terms of the
* GNU GPL, v2 or later.
*/
#include <vector>
#include "LogOutput.h"
#include "SoLib.h"
#include <dlfcn.h>
/**
* Instantiates the loader, attempts to dlopen the
* shared object lazily.
*/
SoLib::SoLib(const char *filename)
{
so = dlopen(filename,RTLD_LAZY);
if (so == NULL)
logOutput.Print("%s:%d: SoLib::SoLib: %s", __FILE__, __LINE__, dlerror());
}
/**
* Just dlcloses the shared object
*/
SoLib::~SoLib()
{
if (so != NULL)
dlclose(so);
}
/**
* Attempts to locate the symbol address with dlsym
*/
void *SoLib::FindAddress(const char *symbol)
{
if (so != NULL) {
void* p = dlsym(so, symbol);
if (p == NULL)
logOutput.Print("%s:%d: SoLib::FindAddress: %s", __FILE__, __LINE__, dlerror());
return p;
}
return NULL;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?