The dll requires 3 files. Source wring outdoors, header wring outdoors and a definitions wring outdoors. This def wring outdoors is required to for certain the functions in search direct linking only
Create the DLL
Create the horse’s mouth wring outdoors and protect it as MyHook.h
1. #ifndef MYHOOK_H
2. #define MYHOOK_H
3.
#ifdef MYHOOK_DLLEXPORT
5.
4. #define MYHOOK_API __declspec(dllexport)
6.
#else
7. #define MYHOOK_API
8.
10. #endif
9. MYHOOK_API int AddNumbers(int, int);
11.
MYHOOK_API int GetMessage(char*, int);
12.
13. #include MyHook.h
2. #endifHide contrast b antagonize up numbers
Create the horse’s mouth wring outdoors and protect it as MyHook.cpp
1.
#include
3.
4. MYHOOK_API int AddNumbers(int x, int y){
5. }
7. strikingly vindicating strikingly vindicating bring x + y;
6. MYHOOK_API int GetMessage(char* x, int length){
8. strikingly vindicating strikingly vindicating if(length>32){
9.
strikingly vindicating strikingly vindicating strikingly vindicating strikingly strcpy(x, hello from dll);
10. strikingly vindicating strikingly vindicating }
12. strikingly vindicating strikingly vindicating strikingly vindicating strikingly vindicating bring 0;
11. strikingly vindicating strikingly vindicating else
13. strikingly vindicating strikingly vindicating strikingly vindicating strikingly vindicating bring -1;
14.
}Hide contrast b antagonize up numbers
Finally sire the definitions wring outdoors and protect it as MyHook.def
1.
3. ; MyHook.def strikingly: Declares the module parameters in search the DLL.
2. LIBRARY strikingly vindicating strikingly vindicating strikingly myhook
4. DESCRIPTION strikingly MyHook Windows Dynamic Link Library
5.
6. strikingly vindicating strikingly vindicating ; Explicit exports can away here
8.
EXPORTS
7. strikingly vindicating strikingly vindicating AddNumbers
9. strikingly vindicating strikingly vindicating GetMessage
10.
strikingly vindicating strikingly
11. SECTIONS
12.