-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug,解决DllMain DLL_THREAD_ATTACH时间接加载msvcrt导致死锁风险
- Loading branch information
1 parent
cf300d8
commit 3610737
Showing
8 changed files
with
167 additions
and
105 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
#pragma once | ||
#include <Windows.h> | ||
|
||
HMODULE __fastcall __LTL_GetMSVCRTModule(); | ||
|
||
#define __EXPAND_MSVCRT_FUN(name) \ | ||
static decltype(name)* _CRT_CONCATENATE(pMSVCRT_, name); \ | ||
if(_CRT_CONCATENATE(pMSVCRT_, name) == NULL)\ | ||
{ \ | ||
auto fun = GetProcAddress(__LTL_GetMSVCRTModule(), #name);\ | ||
_CRT_CONCATENATE(pMSVCRT_, name) = fun ? (decltype(name)*)fun : (decltype(name)*)INVALID_HANDLE_VALUE;\ | ||
} | ||
#pragma section(".YYLT1$DAA", long, read, write) | ||
#pragma section(".YYLT1$DAB", long, read, write) //LTL函数缓存节点 | ||
#pragma section(".YYLT1$DAC", long, read, write) //保留,暂时用于边界结束 | ||
|
||
#pragma section(".YYLT2$IFA", long, read) | ||
#pragma section(".YYLT2$IFB", long, read) //LTL函数缓存初始化函数 | ||
#pragma section(".YYLT2$IFC", long, read) //LTL函数缓存初始化函数结束 | ||
|
||
#define __Get_MSVCRT_FUN(name) (_CRT_CONCATENATE(pMSVCRT_, name) != (decltype(name)*)INVALID_HANDLE_VALUE ? _CRT_CONCATENATE(pMSVCRT_, name) : (decltype(name)*)NULL) | ||
namespace YY | ||
{ | ||
namespace VC_LTL | ||
{ | ||
void* __fastcall try_get_function( | ||
void** _ppFunAddress, | ||
char const* const _szName); | ||
} | ||
} | ||
|
||
#define __EXPAND_MSVCRT_FUN(name) \ | ||
static decltype(name)* _CRT_CONCATENATE(try_get_, name)() \ | ||
{ \ | ||
__declspec(allocate(".YYLT2$IFB")) static void* const s_pfnInitFun = &_CRT_CONCATENATE(try_get_, name); \ | ||
__pragma(warning(suppress:6031)) \ | ||
_bittest((LONG*)(&s_pfnInitFun), 0); \ | ||
__declspec(allocate(".YYLT1$DAB")) static void* _CRT_CONCATENATE(s_pfn_, name); \ | ||
return (decltype(name)*)YY::VC_LTL::try_get_function(&_CRT_CONCATENATE(s_pfn_, name), #name); \ | ||
} |
Oops, something went wrong.