问题一:
一个MSG.DLL里面程序代码是:
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) void output()
{
MessageBox(NULL, "这是一个列子", "msg.dll", 0);
}
#ifdef __cplusplus
}
#endif
在一个EXE里面程序代码是:
#include <windows.h>
int main()
{
HMODULE hMod = LoadLibrary("msg");
if (hMod)
{
FARPROC a = GetProcAddress(hMod, TEXT("output"));
if (a)
a();
else
MessageBox(NULL, "无法获得msg.dll的output()函数", "错误", 0);
FreeLibrary(hMod);
}
else
MessageBox(NULL, "不能加载msg.dll", "错误", 0);
}
这个编译出来很成功没有任何问题.但这算是隐式加载还是显式加载,我看他们都是用到*.H文件的.
问题二:
这是DEVC++的DLL工程示范:
dllmain.cpp文件
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
DllClass::DllClass()
{
}
DllClass::~DllClass ()
{
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
dll.h文件
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
private:
};
#endif /* _DLL_H_ */
问题三:
有个文件d2hackmap.dll我有它的源代码.
但现在的问题是,我用LoadLibrary("d2hackmap");无法引进!?
返回LoadLibrary函数值时失败.........
LoadLibrary只是把DLL映射到EXE里这样都不行???
我用工具检测编译好的DLL倒出函数是:QueryInterface 地址:0000AC80