먼저 win32 DLL empty 프로젝트를 만든 후 아래와 같이 코딩하자.
그런 후 컴파일 하고 생성된 DLL 을 아래와 같이 검사하면 외부에서 참조할 수 있는 함수가 나타난다.
C:\zextor\제작완료\MyDLL\Release>dumpbin /exports MyDLL.dll
Microsoft (R) COFF Binary File Dumper Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file MyDLL.dll
File Type: DLL
Section contains the following exports for MyDLL.dll
0 characteristics
43E84813 time date stamp Tue Feb 07 16:11:15 2006
0.00 version
1 ordinal base
6 number of functions
6 number of names
ordinal hint RVA name
1 0 00001010 ??4CCalc@@QAEAAV0@ABV0@@Z
2 1 00001020 ?Add@CCalc@@QAEHHH@Z
3 2 00001000 Add
4 3 00001030 CreateCalcInstance
5 4 00001040 DeleteCalcInstance
6 5 00005030 str
Summary
1000 .data
1000 .rdata
1000 .reloc
3000 .text
C:\zextor\제작완료\MyDLL\Release>
01: 02: // 전역 변수 export. 03: extern "C" __declspec(dllexport) char *str = "THE TRUTH IS OUT THERE"; 04: 05: // 전역 함수 export. 06: extern "C" __declspec(dllexport) int Add(int a, int b) { 07: return a + b; 08: } 09: 10: // 클래스 export. 11: class __declspec(dllexport) CCalc { 12: 13: public: 14: int Add(int a, int b); 15: 16: }; 17: 18: int CCalc::Add(int a, int b) { 19: return a + b; 20: }; 21: 22: // CCalc의 인스턴스를 생성해주는 함수. 23: extern "C" __declspec(dllexport) CCalc *CreateCalcInstance(void) { 24: return new CCalc(); 25: } 26: 27: // CCalc의 인스턴스를 파괴해주는 함수. 28: extern "C" __declspec(dllexport) void DeleteCalcInstance(CCalc *obj) { 29: delete obj; 30: }
그런 후 컴파일 하고 생성된 DLL 을 아래와 같이 검사하면 외부에서 참조할 수 있는 함수가 나타난다.
C:\zextor\제작완료\MyDLL\Release>dumpbin /exports MyDLL.dll
Microsoft (R) COFF Binary File Dumper Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file MyDLL.dll
File Type: DLL
Section contains the following exports for MyDLL.dll
0 characteristics
43E84813 time date stamp Tue Feb 07 16:11:15 2006
0.00 version
1 ordinal base
6 number of functions
6 number of names
ordinal hint RVA name
1 0 00001010 ??4CCalc@@QAEAAV0@ABV0@@Z
2 1 00001020 ?Add@CCalc@@QAEHHH@Z
3 2 00001000 Add
4 3 00001030 CreateCalcInstance
5 4 00001040 DeleteCalcInstance
6 5 00005030 str
Summary
1000 .data
1000 .rdata
1000 .reloc
3000 .text
C:\zextor\제작완료\MyDLL\Release>
최근 댓글