2

我有一个包含超过 400 个函数的 dll,而我的 exe 文件仅使用 dll 中的 15 个函数,所以我需要创建一个新的 dll 并导出函数并伪造它们的返回值以模拟更复杂系统的输出.

我尝试过的:

 #include "stdafx.h"

//the compiler complains about the '@20'

__declspec ( dllexport ) XLStatus _xlActivateChannel@20(XLportHandle,  XLuint64, unsigned int, unsigned int)
{
    return 0;
} 

// causing the exe to crash

dumpbin /exports vxlapi.dll (original dll): 显示重复的函数名(不是所有函数)

ordinal  name
         _xlActivateChannel@20
14       xlActivateChannel

注意:在 dll 的头文件中,函数声明如下:

DECL_STDXL_FUNC ( xlActivateChannel, XLACTIVATECHANNEL, (
                  XLportHandle  portHandle,
                  XLaccess      accessMask,
                  unsigned int  busType,
                  unsigned int  flags)
                  );

在 dumpbin / export dll 中为什么函数名以 '_' 下划线开头并以 '@number' 结尾,注意:exe 正在使用 let's say(decorated) 函数,以及如何创建新的 dll 和导出函数包含@,

4

2 回答 2

2

调用约定使用“@n” 。stdcall您无需在声明中提及它,只需将声明更改为,stdcall以便编译器知道它们需要用“@n”后缀修饰。像这样:

__declspec ( dllexport ) XLStatus __stdcall _xlActivateChannel(XLportHandle,  XLuint64, unsigned int, unsigned int)
于 2018-12-25T05:56:37.970 回答
0

名称修改对于 C++ 等来说是典型的,这就是您在导出中看到这些符号的原因。Ansi C 出口没有被破坏。不允许使用 @ 符号。你可以试试 AT 或 _AT。

extern "C" 用于删除 C 类型的修饰。Is 不适用于类或其他 C++ 类型。

我读得太快了,但约翰更正确。

于 2018-12-25T06:00:40.093 回答