이런 경우 dynamic loading 으로 dll을 메모리에 로딩 시킬 수 있다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// call convention과 parameter, return 값을 알맞게 선언해준다. | |
PVOID (__cdecl * pmalloc)(SIZE_T); | |
// GetProcAddress 함수를 사용해서 msvcrt.dll에 malloc함수의 시작주소를 앞에서 선언한 | |
//pmalloc 함수의 형태에 맞게 형변환을 시켜서 pmalloc에 넣어준다. | |
// - hdll LoadLibrary(char* dllName) | |
// - PVOID GetProcAddress(hdll, char* apiName) | |
pmalloc = (PVOID (__cdecl *)(SIZE_T))GetProcAddress(LoadLibrary("msvcrt.dll"), "malloc"); | |
//PVOID pmalloc(SIZE_T size) 이런식으로 malloc과 동일하게 사용할 수 있다. |
0 개의 댓글:
댓글 쓰기