Fogeaters, Light The World.

13

2016-Nov

[VS] DllMain 에서 DLL 호출하기

작성자: title: MoonBlonix IP ADRESS: *.64.228.3 조회 수: 1590

는 안됨.

즉, dll을 동적으로 로드해서 사용하는 dll은 만들 수 없다.

알아서 다른 방법을 강구해보길.



참고 :: http://stackoverflow.com/questions/2674736/loading-a-dll-from-a-dll



First of all, it's still not clear why you need to load a dll in DllMain with LoadLibrary. This is definitely a bad idea, since your DllMain is running inside another call to LoadLibrary, which holds the loader lock, as explained by the documentation of DllMain:

During initial process startup or after a call to LoadLibrary, the system scans the list of loaded DLLs for the process. For each DLL that has not already been called with the DLL_PROCESS_ATTACH value, the system calls the DLL's entry-point function. This call is made in the context of the thread that caused the process address space to change, such as the primary thread of the process or the thread that called LoadLibrary. Access to the entry point is serialized by the system on a process-wide basis. Threads in DllMain hold the loader lock so no additional DLLs can be dynamically loaded or initialized.
The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code. Similarly, the entry-point function must not call the FreeLibrary function (or a function that calls FreeLibrary) during process termination, because this can result in a DLL being used after the system has executed its termination code.

(emphasis added)

So, this on why it is forbidden; for a clear, more in-depth explanation, see this and this, for some other examples about what can happen if you don't stick to these rules in DllMain see also some posts inRaymond Chen's blog.

profile
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 [Web] 클라우드 IDE + 2 title: MoonBlonix 2017-06-25 15122
72 [VS] 다중 프로젝트 dll로 연결하기 title: MoonBlonix 2016-11-13 1626
» [VS] DllMain 에서 DLL 호출하기 title: MoonBlonix 2016-11-13 1590
70 [Win API] 유니코드, 멀티바이트, TCHAR 문자열함수 title: MoonBlonix 2016-11-08 1457
69 [AVR] LED 입출력을 제어해보자 - 1 file title: Zwei츠바이 2016-09-16 1600
68 [알고리즘] 문자열 검색 title: MoonBlonix 2016-04-17 1697
67 [AVR] ATTiny13A 그리고 ADC에 대해 + 2 title: MoonBlonix 2016-04-01 1545
66 [OpenCV] 32bit(x86) 빌드 및 초기설정(GPU, TBB, IPP 등) title: MoonBlonix 2016-03-29 1543
65 [OpenCV] Mat 픽셀 접근방법 title: MoonBlonix 2016-03-26 1676
64 [OpenCV] Mat 구조를 Tesseract 에서 쓸 수 있게 title: MoonBlonix 2016-03-24 1452
63 [영상처리] Bitmap 구조 분석 title: MoonBlonix 2016-03-24 1704
62 [OpenCV] 3.x - 캠 사용 & 얼굴 인식 title: MoonBlonix 2016-03-24 1682
61 [tesseract] (3.0.4) vs2013으로 빌드하기 title: MoonBlonix 2016-03-23 1604
60 [OpenCV] 3.1 설치하기 file title: MoonBlonix 2016-03-17 1425
59 AVR / ARM / DSP 비교 file + 2 title: MoonBlonix 2016-03-12 1735
58 (작성중)[OpenCV/ARM/DSP] 임베디드 환경에서의 OpenCV 사용 title: MoonBlonix 2016-03-12 1602
57 [OpenCV] 예제 코드 모음 file title: MoonBlonix 2016-03-12 1789
56 [OpenCV] 마커 추출 file title: MoonBlonix 2016-03-12 1404
55 [OpenCV] 영상 이진화 & 레이블링(Blob Labeling) file + 3 title: MoonBlonix 2016-03-12 1534
54 [OpenCV] 문자 인식 file + 1 title: MoonBlonix 2016-03-12 1465
53 [AVR] ATTiny13A 에 대한 숨겨진 사실들 title: MoonBlonix 2016-03-10 1626