__declspec(dllexport) 定义了EXPORT表示函数是引出函数 __stdcall 函数参数入stack的顺序 从右到左Element Implementation Argument-passing order Right to left. Argument-passing convention By value, unless a pointer or reference type is passed. Stack-maintenance responsibility Called function pops its own arguments from the stack. Name-decoration convention An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12 Case-translation convention None
{
func1();
}
编译器产生这样的代码;call func1
连接器这样调用:call 0x4000000 ; 'func1'的地址.
如果func1()在另外的dll里,那么连接器会增加一个thunk:
0x40000000: jmp DWORD PTR __imp_func1
__imp_func1是真正的函数地址。它在一个exe文件里的导出地址表里。这样会使文件增大并且降低缓存性能。如果这样写的话
__declspec(dllimport) void func1(void);
void main(void)
{
func1();
}
会这样调用:call DWORD PTR __imp_func1没有多余的thunk,代码不仅小而且快。
__stdcall仅仅是一种调用方式。
__stdcall
函数参数入stack的顺序 从右到左Element Implementation
Argument-passing order Right to left.
Argument-passing convention By value, unless a pointer or reference type is passed.
Stack-maintenance responsibility Called function pops its own arguments from the stack.
Name-decoration convention An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12
Case-translation convention None