C++学习(四六一)dll导出函数命名规则

Posted hankern

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++学习(四六一)dll导出函数命名规则相关的知识,希望对你有一定的参考价值。

C++编译时函数名修饰约定规则:
  __stdcall调用约定:
  1、以"?"标识函数名的开始,后跟函数名;

  2、函数名后面以"@@YG"标识参数表的开始,后跟参数表;

  3、参数表以代号表示:
  B:const
    D:char
    E:unsigned char
    F:short
    G:unsigned short
    H:int
    I:unsigned int
    J:long
    K:unsigned long
    M:float
    N:double
    _N:bool
    PA:指针(*,后面的代号表明指针类型,如果相同类型的指针连续出现,以0代替,一个0代表一次重复)
    PB:const指针
    AA:引用(&)
    AB:const引用
    U:类或结构体
    V:Interface(接口)
    W4:enum
    X:void
    Z: 结尾标记
    @: 空,无得意思,构造或析构使用,与?0, ?1配合
  4、参数表的第一项为该函数的返回值类型,其后依次为参数的数据类型,指针标识在其所指数据类型前;

  5、参数表后以"@Z"标识整个名字的结束,如果该函数无参数,则以"Z"标识结束。
  其格式为"?functionname@@YG*****@Z"或"?functionname@@YG*XZ",例如
                      int Test1(char *var1, unsigned long)-----"?Test1@@YGHPADK@Z"                      void Test2()-----"?Test2@@YGXXZ"
6、

@@QAE: public __thiscall
    @@AAE: private __thiscall
    @@QBE: public __thiscall const


  __cdecl调用约定:
  规则同上面的_stdcall调用约定,只是参数表的开始标识由上面的"@@YG"变为"@@YA"。
  __fastcall调用约定:
  规则同上面的_stdcall调用约定,只是参数表的开始标识由上面的"@@YG"变为"@@YI"。

#ifndef TESTCLASSLIB_H
#define TESTCLASSLIB_H

#include "testclasslib_global.h"

class TESTCLASSLIBSHARED_EXPORT TestClassLib


public:
    TestClassLib();

public:
    struct TestStruct
        TestStruct();
        bool accept(int i) const;
        int       _overrideValue;
        int* _accept;
        bool operator < (const TestStruct& rhs) const;
    ;
    struct TestStruct1
    public:
        TestStruct1(int i);
        TestStruct1();
        void test();
        bool accept(int i) const;
        int       _overrideValue;
        int* _accept;
        bool operator < (const TestStruct& rhs) const;
    ;
    struct TESTCLASSLIBSHARED_EXPORT TestStruct2
    public:
        void test();
        bool accept(int i) const;
        int       _overrideValue;
        int* _accept;
        bool operator < (const TestStruct& rhs) const;
    ;
    class TestClass
    public:
        TestClass(int i);
        TestClass();
        void test();
        bool accept(int i) const;
        int       _overrideValue;
        int* _accept;
        bool operator < (const TestStruct& rhs) const;
    ;
    void myTest(int* i);
    int _num;
;

#endif // TESTCLASSLIB_H
OrdinalRvaFunction Name区段Entry Point(中转输出表)
0000000100001000??0TestClassLib@@QAE@XZ.text
0000000200001010??4TestClassLib@@QAEAAV0@$$QAV0@@Z.text
0000000300001010??4TestClassLib@@QAEAAV0@ABV0@@Z.text
0000000400001020??4TestStruct2@TestClassLib@@QAEAAU01@$$QAU01@@Z.text
0000000500001020??4TestStruct2@TestClassLib@@QAEAAU01@ABU01@@Z.text
0000000600001040?myTest@TestClassLib@@QAEXPAH@Z.text

例子:

?0CritSec@@QAE@XZ (public: __thiscall CritSec::CritSec(void))
?0Tick@@QAE@K@Z (public: __thiscall Tick::Tick(unsigned long))
?1CritSec@@QAE@XZ (public: __thiscall CritSec::~CritSec(void))
?0CFontSet@@QAE@XZ (public: __thiscall CFontSet::CFontSet(void))
?0Dx2DDraw@@QAE@XZ (public: __thiscall Dx2DDraw::Dx2DDraw(void))
?1AutoLock@@QAE@XZ (public: __thiscall AutoLock::~AutoLock(void))
?1CD3DDraw@@QAE@XZ (public: __thiscall CD3DDraw::~CD3DDraw(void))
?1CFontSet@@QAE@XZ (public: __thiscall CFontSet::~CFontSet(void))
?1Dx2DDraw@@QAE@XZ (public: __thiscall Dx2DDraw::~Dx2DDraw(void))
Lock@CritSec@@QAEXXZ (public: void __thiscall CritSec::Lock(void))
?0D3dDrawCmd@@QAE@XZ (public: __thiscall D3dDrawCmd::D3dDrawCmd(void))
?0ImgTexture@@QAE@XZ (public: __thiscall ImgTexture::ImgTexture(void))
Unlock@CritSec@@QAEXXZ (public: void __thiscall CritSec::Unlock(void))
?1ImgTexture@@QAE@XZ (public: __thiscall ImgTexture::~ImgTexture(void))
TryLock@CritSec@@QAEHXZ (public: int __thiscall CritSec::TryLock(void))
DelFont@CFontSet@@QAEHH@Z (public: int __thiscall CFontSet::DelFont(int))
TryLock@AutoLock@@QAEHXZ (public: int __thiscall AutoLock::TryLock(void))
Refresh@CD3DDraw@@QAEJXZ (public: long __thiscall CD3DDraw::Refresh(void))
?0ResImageList@@QAE@XZ (public: __thiscall ResImageList::ResImageList(void))
?0simplethread@@QAE@XZ (public: __thiscall simplethread::simplethread(void))
?BTick@@QBEKXZ (public: __thiscall Tick::operator unsigned long(void)const )
stop@simplethread@@QAEXXZ (public: void __thiscall simplethread::stop(void))
?1ResImageList@@QAE@XZ (public: __thiscall ResImageList::~ResImageList(void))
?1simplethread@@QAE@XZ (public: __thiscall simplethread::~simplethread(void))
pass@Tick@@QBE?AU1@XZ (public: struct Tick __thiscall Tick::pass(void)const )
?0CD3DDrawLayer@@QAE@XZ (public: __thiscall CD3DDrawLayer::CD3DDrawLayer(void))
?0D3dDrawCmdSet@@QAE@XZ (public: __thiscall D3dDrawCmdSet::D3dDrawCmdSet(void))
RenderAll@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::RenderAll(void))
Visible@CAllocator@@QAE_NXZ (public: bool __thiscall CAllocator::Visible(void))
?1D3dDrawCmdSet@@QAE@XZ (public: __thiscall D3dDrawCmdSet::~D3dDrawCmdSet(void))
ClearVideo@CD3DDraw@@QAEXXZ (public: void __thiscall CD3DDraw::ClearVideo(void))
TestDevice@CD3DDraw@@QAEJXZ (public: long __thiscall CD3DDraw::TestDevice(void))
clear@D3dDrawCmdSet@@QAEXXZ (public: void __thiscall D3dDrawCmdSet::clear(void))
EndPaint@CD3DDraw@@QAEJPAX@Z (public: long __thiscall CD3DDraw::EndPaint(void *))
getSize@ResImageList@@QAEHXZ (public: int __thiscall ResImageList::getSize(void))
CheckDevice@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::CheckDevice(void))
ClearDraw@CD3DDraw@@QAEJPAX@Z (public: long __thiscall CD3DDraw::ClearDraw(void *))
ResetDevice@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::ResetDevice(void))
SetD3DState@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::SetD3DState(void))
Visible@CD3DDrawLayer@@QAEHXZ (public: int __thiscall CD3DDrawLayer::Visible(void))
OnLostDevice@CFontSet@@QAEJXZ (public: long __thiscall CFontSet::OnLostDevice(void))
Popfront@ResImageList@@QAEXXZ (public: void __thiscall ResImageList::Popfront(void))
CreateDevice@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::CreateDevice(void))
OnLostDevice@CD3DDraw@@AAEXXZ (private: void __thiscall CD3DDraw::OnLostDevice(void))
RenderCursor@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::RenderCursor(void))
?1ImgTextureGeter@@QAE@XZ (public: __thiscall ImgTextureGeter::~ImgTextureGeter(void))
ClearCanvas@CD3DCanvas@@QAEJXZ (public: long __thiscall CD3DCanvas::ClearCanvas(void))
FontUninstall@CD3DDraw@@QAEXH@Z (public: void __thiscall CD3DDraw::FontUninstall(int))
OnResetDevice@CFontSet@@QAEJXZ (public: long __thiscall CFontSet::OnResetDevice(void))
ResetD3Device@CD3DDraw@@QAEJXZ (public: long __thiscall CD3DDraw::ResetD3Device(void))
OnResetDevice@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::OnResetDevice(void))
PresentCanvas@CD3DDraw@@AAEXXZ (private: void __thiscall CD3DDraw::PresentCanvas(void))
SetSysRatio@CD3DDraw@@QAEJHH@Z (public: long __thiscall CD3DDraw::SetSysRatio(int,int))
AddFont@CFontSet@@QAEHHHPAD@Z (public: int __thiscall CFontSet::AddFont(int,int,char *))
OnLostDevice@CAllocator@@QAEJXZ (public: long __thiscall CAllocator::OnLostDevice(void))
OnLostDevice@ImgTexture@@QAEJXZ (public: long __thiscall ImgTexture::OnLostDevice(void))
SetFullScreen@CD3DDraw@@QAEJ_N@Z (public: long __thiscall CD3DDraw::SetFullScreen(bool))
getFront@ResImageList@@QAEPADXZ (public: char * __thiscall ResImageList::getFront(void))
CleanSurface@CD3DDraw@@QAEJPAX@Z (public: long __thiscall CD3DDraw::CleanSurface(void *))
RecreateDevice@CD3DDraw@@AAEJXZ (private: long __thiscall CD3DDraw::RecreateDevice(void))
check_stop@simplethread@@QAE_NXZ (public: bool __thiscall simplethread::check_stop(void))
is_running@simplethread@@QAE_NXZ (public: bool __thiscall simplethread::is_running(void))
OnResetDevice@CAllocator@@QAEJXZ (public: long __thiscall CAllocator::OnResetDevice(void))
OnResetDevice@ImgTexture@@QAEJXZ (public: long __thiscall ImgTexture::OnResetDevice(void))
SetCursorEnable@CD3DDraw@@QAEXH@Z (public: void __thiscall CD3DDraw::SetCursorEnable(int))
DrawLineH@CD3DCanvas@@QAEJHHH@Z (public: long __thiscall CD3DCanvas::DrawLineH(int,int,int))
DrawLineV@CD3DCanvas@@QAEJHHH@Z (public: long __thiscall CD3DCanvas::DrawLineV(int,int,int))
get_canvasWidth@CD3DCanvas@@QAEHXZ (public: int __thiscall CD3DCanvas::get_canvasWidth(void))
AllocatorVisible@CD3DDraw@@AAE_NXZ (private: bool __thiscall CD3DDraw::AllocatorVisible(void))
BeginPaint@CD3DDraw@@QAEPAXK@Z (public: void * __thiscall CD3DDraw::BeginPaint(unsigned long))
TextWidth@CFontSet@@QAEJHPBD@Z (public: long __thiscall CFontSet::TextWidth(int,char const *))
count@D3dDrawCmdSet@@QBEIXZ (public: unsigned int __thiscall D3dDrawCmdSet::count(void)const )
get_arglist@simplethread@@QAEPAXXZ (public: void * __thiscall simplethread::get_arglist(void))
set_bColor@CD3DCanvas@@QAEXK@Z (public: void __thiscall CD3DCanvas::set_bColor(unsigned long))
set_fColor@CD3DCanvas@@QAEXK@Z (public: void __thiscall CD3DCanvas::set_fColor(unsigned long))
Pushback@ResImageList@@QAEXPBD@Z (public: void __thiscall ResImageList::Pushback(char const *))
get_canvasHeight@CD3DCanvas@@QAEHXZ (public: int __thiscall CD3DCanvas::get_canvasHeight(void))
?0CD3DDraw@@QAE@PAUHWND__@@AAJ@Z (public: __thiscall CD3DDraw::CD3DDraw(struct HWND__ *,long &))
SetVideoRenderMode@CD3DDraw@@QAEXH@Z (public: void __thiscall CD3DDraw::SetVideoRenderMode(int))
?0AutoLock@@QAE@PAVCritSec@@HH@Z (public: __thiscall AutoLock::AutoLock(class CritSec *,int,int))
FontInstall@CD3DDraw@@QAEXHHPAD@Z (public: void __thiscall CD3DDraw::FontInstall(int,int,char *))
DrawLineH@CD3DDraw@@QAEJPAXHHH@Z (public: long __thiscall CD3DDraw::DrawLineH(void *,int,int,int))
DrawLineV@CD3DDraw@@QAEJPAXHHH@Z (public: long __thiscall CD3DDraw::DrawLineV(void *,int,int,int))
GetItem@CFontSet@@QAEPAUDrawFont@@H@Z (public: struct DrawFont * __thiscall CFontSet::GetItem(int))
DrawRect@CD3DCanvas@@QAEJUtagRECT@@@Z (public: long __thiscall CD3DCanvas::DrawRect(struct tagRECT))
FillRect@CD3DCanvas@@QAEJUtagRECT@@@Z (public: long __thiscall CD3DCanvas::FillRect(struct tagRECT))
SetResolutionRatio@CD3DDraw@@QAEJHH@Z (public: long __thiscall CD3DDraw::SetResolutionRatio(int,int))
FontTextWidth@CD3DDraw@@QAEJHPBD@Z (public: long __thiscall CD3DDraw::FontTextWidth(int,char const *))
LoadResImage@CD3DDraw@@QAEJPAXPBD@Z (public: long __thiscall CD3DDraw::LoadResImage(void *,char const *))
DrawRect@CD3DDraw@@QAEJPAXUtagRECT@@@Z (public: long __thiscall CD3DDraw::DrawRect(void *,struct tagRECT))
FillRect@CD3DDraw@@QAEJPAXUtagRECT@@@Z (public: long __thiscall CD3DDraw::FillRect(void *,struct tagRECT))
OnLostDevice@CDoubleBufferCanvas@@QAEJXZ (public: long __thiscall CDoubleBufferCanvas::OnLostDevice(void))
SetClipRect@Dx2DDraw@@QAEXPAUtagRECT@@@Z (public: void __thiscall Dx2DDraw::SetClipRect(struct tagRECT *))
GetResolutionRatio@CD3DDraw@@QAEJPAH0@Z (public: long __thiscall CD3DDraw::GetResolutionRatio(int *,int *))
sync_to@D3dDrawCmdSet@@QAEXAAU1@@Z (public: void __thiscall D3dDrawCmdSet::sync_to(struct D3dDrawCmdSet &))
?8D3dDrawCmd@@QBE_NABU0@@Z (public: bool __thiscall D3dDrawCmd::operator==(struct D3dDrawCmd const &)const )
?9D3dDrawCmd@@QBE_NABU0@@Z (public: bool __thiscall D3dDrawCmd::operator!=(struct D3dDrawCmd const &)const )
OnResetDevice@CDoubleBufferCanvas@@QAEJXZ (public: long __thiscall CDoubleBufferCanvas::OnResetDevice(void))
SetVideoRect@CD3DDraw@@QAEXPAUtagRECT@@@Z (public: void __thiscall CD3DDraw::SetVideoRect(struct tagRECT *))
set_clipRect@CD3DCanvas@@QAEXUtagRECT@@@Z (public: void __thiscall CD3DCanvas::set_clipRect(struct tagRECT))
Render@CD3DDraw@@AAEJPAUCD3DDrawLayer@@@Z (private: long __thiscall CD3DDraw::Render(struct CD3DDrawLayer *))

                 

以上是关于C++学习(四六一)dll导出函数命名规则的主要内容,如果未能解决你的问题,请参考以下文章

C++ 中的 DLL 导出调用,带有“::”字符串名称

dll导出命名空间下的c风格函数陷阱

C++ DLL导出函数的两种方法(导出序号那种方法,别人看不到函数名)

c++调用dll导出函数

C++学习(四六零)C++类和结构体的关系

在 C# 中找不到 C++ COM DLL 中的导出函数