답변해주시는 분께서 없어, 다시 한번 올립니다...
mongii님의 강좌는 아래 링크구요...
http://research.hackerschool.org/Datas/Research_Lecture/keylog.txt
강좌내용중에,
아래 키로거.exe의 WndProc()을 보면,
DLL TEST.dll에서 선언된 int WiseGuys(int a, int b)의 형식에 맞추어
int (*MyFunc)(int, int); 로 함수포인터를 만들고
MyFunc = (int (*)(int, int))GetProcAddress(hinstDll, "WiseGuys"); 로 WiseGuys함수의 주소를 MyFunc함수포인터와 매치시키는 것은 짐작하겠는데요...
(int (*)(int, int))은 어떤 동작을 하는 건지요?
제 생각에는 MyFunc = GetProcAddress(hinstDll, "WiseGuys"); 하면 될 것같은데, 이렇게 하고 compile하면 오류납니다.
부디 자세한 설명을 부탁드리겠습니다! 감사합니다~
----------------------------< DLL TEST.dll의 코드 >------------------------------
#include <windows.h>
__declspec(dllexport) int WiseGuys(int a, int b)
{
return a+b;
}
--------------------< 키로거.exe의 WndProc의 코드 >--------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
{
static HINSTANCE hinstDll; // 동적 라이브러리를 가리킬 핸들.
int (*MyFunc)(int, int); // DLL안의 WiseGuys 함수를 가리킬 포인터.
char str[100]; // 메시지 출력에 사용할 변수.
switch( iMessage )
{
case WM_CREATE:
hinstDll = LoadLibrary("DLL TEST.dll"); // DLL을 로드한다.
if(!hinstDll){
MessageBox(hWnd, "DLL TEST.dll을 로드할 수 없습니다.", "오류", MB_OK);
ExitProcess(1);
}
MyFunc = (int (*)(int, int))GetProcAddress(hinstDll, "WiseGuys");
// WiseGuys 함수를 로드한다.
if(!MyFunc){
MessageBox(hWnd, "WiseGuys 함수를 로드할 수 없습니다.", "오류", MB_OK);
FreeLibrary(hinstDll);
ExitProcess(1);
}
wsprintf(str, "3 + 5는 %d 입니다.", MyFunc(3, 5));
MessageBox(hWnd, str, "알림", MB_OK);
return 0;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}
return DefWindowProc( hWnd, iMessage, wParam, lParam );
}
|