c++dll导出损坏的名称
c++ dll export mangled name
我正试图导出一个名为CreateGameClient
的函数,当我进行转储/导出时,我得到的是?CreateGameClient@@YAXXZ
,而我将DLL注入的程序需要CreateGameClient
,而不是?CreateGameClient@@YAXXZ
我正在使用Visual Studio 2012,如果这对有帮助的话
这是我的代码ExpFunc.h
#ifndef INDLL_H
#define INDLL_H
#ifdef EXPORTING_DLL
__declspec(dllexport) void CreateGameClient() ;
#else
__declspec(dllimport) void CreateGameClient() ;
#endif
#endif
主要.cpp
#include "stdafx.h"
#include <Windows.h>
#include <string.h>
#include <sstream>
#include <stdio.h>
#include <fstream>
#define EXPORTING_DLL
#include "ExpFunc.h"
void WriteLogFile(const char*);
void CreateGameClient2(int);
char* logStr;
char* CGCNStr;
char buf[250];
DWORD pid = GetCurrentProcessId();
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
logStr = "Attached To: %d";
sprintf(buf, logStr, pid);
WriteLogFile(buf);
break;
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
logStr = "Detached To: %d";
sprintf(buf, logStr, pid);
WriteLogFile(buf);
break;
}
return TRUE;
}
void CreateGameClient()
{
CreateGameClient2(2);
}
void CreateGameClient2(int num)
{
std::stringstream temp_str;
temp_str << (num);
std::string str = temp_str.str();
const char* cstr2 = str.c_str();
sprintf(buf, cstr2, pid);
WriteLogFile(buf);
}
void WriteLogFile(const char* szString)
{
FILE* pFile = fopen("logFile.txt", "a");
fprintf(pFile, "%sn",szString);
fclose(pFile);
}
我尝试过C++DLL导出:修饰/混乱的名称
但仍然不起作用
必须用extern "C" __declspec(...)
修饰函数的声明和定义,否则将收到关于不一致链接定义和不稳定行为的警告。
相关文章:
- 为什么会发生堆损坏
- 挂起和取消挂起一个文件DLL
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- Dll中缺少什么(致命错误LNK1107:无效或损坏的文件:)
- 放置在外部 DLL 中的类中的字符串数据的内存损坏
- 内存损坏从vb.net调用c dll
- 从 /MD Exe 文件中删除 /MDd 的 DLL 内存会导致堆损坏
- 获取无效或损坏的文件LNK1107:尝试链接 OpenSceneGraph 教程.dll时无法0x378读取
- 从 dll 中的函数返回时堆损坏
- 尝试读取或写入受保护的内存.这通常表示其他内存已损坏.在C++Dll中
- c++dll导出损坏的名称
- 由于加载的堆或 dll 损坏,Windows 触发了断点
- DLL内存损坏
- 使用DLL代码时堆损坏
- Dll导出构造函数有导致堆损坏的风险
- 两个dll之间的堆损坏
- 从C++DLL中获取损坏的函数名称
- C++dll返回的字符串在C#调用程序中损坏,原因是什么
- MFC 程序挂起:在 Vista 上更新KB3059317后损坏的 Comctl32.dll