Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
添加Dynamic模式支持
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jun 11, 2018
1 parent 6b576e1 commit 51dc96d
Show file tree
Hide file tree
Showing 19 changed files with 191 additions and 117 deletions.
7 changes: 5 additions & 2 deletions VC-LTL helper for Visual Studio.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ VC-LTL默认搜索顺序

<!--#####################################################################VC-LTL设置#####################################################################-->
<PropertyGroup>
<!--取消下方注释可以开启强制XP兼容模式,默认情况下仅在选择WinXP工具集时才开启。-->
<!--<SupportWinXP>true</SupportWinXP>-->

<!--取消下方注释可以开启VC-LTL轻量模式,轻量模式更加注重体积控制,但是CRT规范将会维持在VS2008。如果你需要高度兼容微软UCRT,那么请不要打开此选项!!!-->
<!--<DisableAdvancedSupport>true</DisableAdvancedSupport>-->

<!--取消下方注释可以开启强制XP兼容模式,默认情况下仅在选择WinXP工具集时才开启-->
<!--<SupportWinXP>true</SupportWinXP>-->
<!--取消下方注释可以将C/C++库连接到动态库 ltlbase.dll、msvcp140_ltl.dll、concrt140_ltl.dll-->
<!--<DisableStaticLibSupport>true</DisableStaticLibSupport>-->
</PropertyGroup>
<!--####################################################################################################################################################-->

Expand Down
3 changes: 3 additions & 0 deletions VC-LTL helper for cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#取消下方注释可以开启VC-LTL轻量模式,轻量模式更加注重体积控制,但是CRT规范将会维持在VS2008。如果你需要高度兼容微软UCRT,那么请不要打开此选项!!!
#set(DisableAdvancedSupport "true")

#取消下方注释可以将C/C++库连接到动态库 ltlbase.dll、msvcp140_ltl.dll、concrt140_ltl.dll。
#set(DisableStaticLibSupport "true")

####################################################################################################################################################


Expand Down
3 changes: 3 additions & 0 deletions VC-LTL helper for nmake.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
::取消下方注释可以开启VC-LTL轻量模式,轻量模式更加注重体积控制,但是CRT规范将会维持在VS2008。如果你需要高度兼容微软UCRT,那么请不要打开此选项!!!
::set DisableAdvancedSupport=true

::取消下方注释可以将C/C++库连接到动态库 ltlbase.dll、msvcp140_ltl.dll、concrt140_ltl.dll。
::set DisableStaticLibSupport=true

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Expand Down
2 changes: 1 addition & 1 deletion VC/14.11.25503/include/functional
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public:
}
};

[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xbad_function_call();
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xbad_function_call();

// TEMPLATE FUNCTION _Test_callable
template<class _Fty>
Expand Down
2 changes: 1 addition & 1 deletion VC/14.11.25503/include/regex
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ enum error_type
};
} // namespace regex_constants

[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xregex_error(
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xregex_error(
regex_constants::error_type _Code);

// TEMPLATE CLASS regex_traits
Expand Down
12 changes: 6 additions & 6 deletions VC/14.11.25503/include/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -3727,12 +3727,12 @@ struct allocator_arg_t

constexpr allocator_arg_t allocator_arg{};

[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xbad_alloc();
[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xinvalid_argument(_In_z_ const char *);
[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xlength_error(_In_z_ const char *);
[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xout_of_range(_In_z_ const char *);
[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xoverflow_error(_In_z_ const char *);
[[noreturn]] extern void __CLRCALL_PURE_OR_CDECL _Xruntime_error(_In_z_ const char *);
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xbad_alloc();
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xinvalid_argument(_In_z_ const char *);
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xlength_error(_In_z_ const char *);
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xout_of_range(_In_z_ const char *);
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xoverflow_error(_In_z_ const char *);
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xruntime_error(_In_z_ const char *);
_STD_END

namespace std {
Expand Down
21 changes: 19 additions & 2 deletions _msvcrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
#define _Build_By_LTL 1
#endif

#ifdef _LTL_Using_Dynamic_Lib

#ifdef _STATIC_CPPLIB
#undef _STATIC_CPPLIB
#endif

#else

#ifndef _DISABLE_DEPRECATE_STATIC_CPPLIB
#define _DISABLE_DEPRECATE_STATIC_CPPLIB 1
#endif
Expand All @@ -55,6 +63,7 @@
#define _STATIC_CPPLIB 1
#endif

#endif //!_LTL_Using_Dynamic_Lib



Expand Down Expand Up @@ -100,9 +109,17 @@ _LTL_PushWarning(1004, "不引用_LTL_Initialization 可能导致某些补充函

#endif //!_LIB

#ifndef _LTLIMP
#ifdef _LTL_Using_Dynamic_Lib
#define _LTLIMP __declspec(dllimport)
#else
#define _LTLIMP
#endif
#endif

_CRT_BEGIN_C_HEADER
extern unsigned long __cdecl __LTL_GetOsMinVersion();
extern unsigned long long __cdecl __LTL_GetOsVersion();
_LTLIMP unsigned long __cdecl __LTL_GetOsMinVersion();
_LTLIMP unsigned long long __cdecl __LTL_GetOsVersion();
_CRT_END_C_HEADER

#endif //!RC_INVOKED
7 changes: 7 additions & 0 deletions config/Vista/Dynamic/LTL_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "..\LTL_config.h"

#ifndef _LTL_Using_Dynamic_Lib
#define _LTL_Using_Dynamic_Lib
#endif
24 changes: 21 additions & 3 deletions config/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ if(NOT DisableAdvancedSupport)
set(DisableAdvancedSupport "false")
endif()

if(NOT DisableStaticLibSupport)
set(DisableStaticLibSupport "false")
endif()

if(NOT SupportLTL)
set(SupportLTL "true")
endif()
Expand Down Expand Up @@ -157,6 +161,20 @@ if(${SupportLTL} STREQUAL "true")
set(LTL_Mode "Advanced")
endif()

#设置LTL_LinkDirMod,Dynamic支持文件是否齐全,如果都在那么才开启Dynamic。
set(LTL_LinkDirMod "")
if(${DisableStaticLibSupport} STREQUAL "true")
find_file(FOUND_FILE Dynamic ${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/lib/${PlatformShortName}/${OsPlatformName})
if(NOT ${FOUND_FILE} STREQUAL "FOUND_FILE-NOTFOUND")
find_file(FOUND_FILE Dynamic ${VC_LTL_Root}/UCRT/${VC-LTLTargetUniversalCRTVersion}/lib/${PlatformShortName})
if(NOT ${FOUND_FILE} STREQUAL "FOUND_FILE-NOTFOUND")
set(LTL_LinkDirMod "/Dynamic")
endif()
endif()

endif()


#打印VC-LTL图标
message("###################################################################################################")
message("# #")
Expand All @@ -175,11 +193,11 @@ if(${SupportLTL} STREQUAL "true")
message(" VC-LTL Tools Version :" ${VC-LTLUsedToolsVersion})
message(" VC-LTL UCRT Version :" ${VC-LTLTargetUniversalCRTVersion})
message(" Platform :" ${PlatformShortName})
message(" Using VC-LTL " ${OsPlatformName} " " ${LTL_Mode} " Mode")
message(" Using VC-LTL " ${OsPlatformName}${LTL_LinkDirMod} " " ${LTL_Mode} " Mode")
message("")

set(VC_LTL_Include ${VC_LTL_Root}/config/${OsPlatformName};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/include;${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/atlmfc/include;${VC_LTL_Root}/ucrt/${VC-LTLTargetUniversalCRTVersion})
set(VC_LTL_Library ${VC_LTL_Root}/${PlatformShortName};${VC_LTL_Root}/${PlatformShortName}/${OsPlatformName}/${LTL_Mode};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/lib/${PlatformShortName};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/lib/${PlatformShortName}/${OsPlatformName};${VC_LTL_Root}/ucrt/${VC-LTLTargetUniversalCRTVersion}/lib/${PlatformShortName})
set(VC_LTL_Include ${VC_LTL_Root}/config/${OsPlatformName}${LTL_LinkDirMod};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/include;${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/atlmfc/include;${VC_LTL_Root}/ucrt/${VC-LTLTargetUniversalCRTVersion})
set(VC_LTL_Library ${VC_LTL_Root}/${PlatformShortName};${VC_LTL_Root}/${PlatformShortName}/${OsPlatformName}/${LTL_Mode};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/lib/${PlatformShortName};${VC_LTL_Root}/VC/${VC-LTLUsedToolsVersion}/lib/${PlatformShortName}/${OsPlatformName}${LTL_LinkDirMod};${VC_LTL_Root}/ucrt/${VC-LTLTargetUniversalCRTVersion}/lib/${PlatformShortName}${LTL_LinkDirMod})

#message("INCLUDE " $ENV{INCLUDE})
#message("LIB " $ENV{LIB})
Expand Down
9 changes: 6 additions & 3 deletions config/config.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ if /i "%SupportWinXP%" == "true" (set OsPlatformName=WinXP) else (set OsPlatform

if /i "%DisableAdvancedSupport%" == "true" (set LTL_Mode=Light) else (set LTL_Mode=Advanced)

echo Using VC-LTL %OsPlatformName% %LTL_Mode% Mode
set LTL_LinkDirMod=
if /i "%DisableStaticLibSupport%" == "true" if exist "%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\lib\%PlatformShortName%\%OsPlatformName%\Dynamic" if exist "%VC_LTL_Root%\ucrt\%VC-LTLTargetUniversalCRTVersion%\lib\%PlatformShortName%\Dynamic" set LTL_LinkDirMod=\Dynamic

echo Using VC-LTL %OsPlatformName%%LTL_LinkDirMod% %LTL_Mode% Mode


::修改Include
set INCLUDE=%VC_LTL_Root%\config\%OsPlatformName%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\include;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\atlmfc\include;%VC_LTL_Root%\ucrt\%VC-LTLTargetUniversalCRTVersion%;%INCLUDE%
set INCLUDE=%VC_LTL_Root%\config\%OsPlatformName%%LTL_LinkDirMod%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\include;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\atlmfc\include;%VC_LTL_Root%\ucrt\%VC-LTLTargetUniversalCRTVersion%;%INCLUDE%

set LIB=%VC_LTL_Root%\%PlatformShortName%;%VC_LTL_Root%\%PlatformShortName%\%OsPlatformName%\%LTL_Mode%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\lib\%PlatformShortName%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\lib\%PlatformShortName%\%OsPlatformName%;%VC_LTL_Root%\ucrt\%VC-LTLTargetUniversalCRTVersion%\lib\%PlatformShortName%;%LIB%
set LIB=%VC_LTL_Root%\%PlatformShortName%;%VC_LTL_Root%\%PlatformShortName%\%OsPlatformName%\%LTL_Mode%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\lib\%PlatformShortName%;%VC_LTL_Root%\VC\%VC-LTLUsedToolsVersion%\lib\%PlatformShortName%\%OsPlatformName%%LTL_LinkDirMod%;%VC_LTL_Root%\ucrt\%VC-LTLTargetUniversalCRTVersion%\lib\%PlatformShortName%%LTL_LinkDirMod%;%LIB%

goto:eof

Expand Down
30 changes: 11 additions & 19 deletions config/config.props
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@
<OsPlatformName Condition=" '$(SupportWinXP)'=='true' ">WinXP</OsPlatformName>
<OsPlatformName Condition=" '$(SupportWinXP)'!='true' ">Vista</OsPlatformName>

<!--查看Dynamic支持文件是否齐全,如果都在那么才开启Dynamic。-->
<LTL_LinkDirMod Condition=" ('$(DisableStaticLibSupport)'=='true')
And (Exists('$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(PlatformShortName)\$(OsPlatformName)\Dynamic'))
And (Exists('$(VC_LTL_Root)\UCRT\$(VC-LTLTargetUniversalCRTVersion)\lib\$(PlatformShortName)\Dynamic'))">\Dynamic</LTL_LinkDirMod>


<!--15.7新特性,检测Spectre缓解方案是否已经启用。-->
<VC-LTLLibDirMod Condition=" (('$(VCLibDirMod)'!='') And (Exists('$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VCLibDirMod)$(PlatformShortName)')))">$(VCLibDirMod)</VC-LTLLibDirMod>
<VC-LTLLibDirMod Condition=" (('$(VCLibDirMod)'!='') And (Exists('$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VCLibDirMod)$(PlatformShortName)\$(OsPlatformName)$(LTL_LinkDirMod)')))">$(VCLibDirMod)</VC-LTLLibDirMod>

<VC_LTL_Include>$(VC_LTL_Root)\config\$(OsPlatformName);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\include;$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\atlmfc\include;$(VC_LTL_Root)\ucrt\$(VC-LTLTargetUniversalCRTVersion)</VC_LTL_Include>
<VC_LTL_Library>$(VC_LTL_Root)\$(PlatformShortName);$(VC_LTL_Root)\$(PlatformShortName)\$(OsPlatformName)\$(LTL_Mode);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VC-LTLLibDirMod)$(PlatformShortName);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VC-LTLLibDirMod)$(PlatformShortName)\$(OsPlatformName);$(VC_LTL_Root)\ucrt\$(VC-LTLTargetUniversalCRTVersion)\lib\$(PlatformShortName)</VC_LTL_Library>
<VC_LTL_Include>$(VC_LTL_Root)\config\$(OsPlatformName)$(LTL_LinkDirMod);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\include;$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\atlmfc\include;$(VC_LTL_Root)\ucrt\$(VC-LTLTargetUniversalCRTVersion)</VC_LTL_Include>
<VC_LTL_Library>$(VC_LTL_Root)\$(PlatformShortName);$(VC_LTL_Root)\$(PlatformShortName)\$(OsPlatformName)\$(LTL_Mode);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VC-LTLLibDirMod)$(PlatformShortName);$(VC_LTL_Root)\VC\$(VC-LTLUsedToolsVersion)\lib\$(VC-LTLLibDirMod)$(PlatformShortName)\$(OsPlatformName)$(LTL_LinkDirMod);$(VC_LTL_Root)\ucrt\$(VC-LTLTargetUniversalCRTVersion)\lib\$(PlatformShortName)$(LTL_LinkDirMod)</VC_LTL_Library>
</PropertyGroup>

<PropertyGroup Condition=" '$(SupportLTL)'=='true' ">
Expand All @@ -109,31 +115,17 @@
<ClCompile>
<PreprocessorDefinitions Condition=" '$(SupportLTL)'!='true' ">_ATL_XP_TARGETING=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>

<!--可选,_msvcrt.h自动会添加这些设置-->
<PreprocessorDefinitions Condition=" '$(SupportLTL)'=='true' ">_ATL_XP_TARGETING=1;_NO_CRT_STDIO_INLINE=1;_Build_By_LTL=1;_DISABLE_DEPRECATE_STATIC_CPPLIB=1;_STATIC_CPPLIB=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>

<!--当兼容XP时,对于非 exe 的需要禁用线程安全初始化。避免XP中在DllMain中使用TLS而崩溃-->
<AdditionalOptions Condition=" '$(ConfigurationType)'!='Application' ">/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<!--可选,msvcrt.lib自动会添加这些设置-->
<AdditionalDependencies Condition=" '$(SupportLTL)'=='true'">msvcrt_Platform.lib;ltl.lib;vc.lib;ucrt.lib;%(AdditionalDependencies)</AdditionalDependencies>

<MinimumRequiredVersion Condition=" '$(PlatformShortName)'=='x86' ">5.01</MinimumRequiredVersion>
<MinimumRequiredVersion Condition=" '$(PlatformShortName)'=='x64' ">5.02</MinimumRequiredVersion>
</Link>
</ItemDefinitionGroup>

<!--普通模式-->
<ItemDefinitionGroup Condition=" ('$(SupportLTL)'=='true') And ('$(SupportWinXP)'!='true') ">
<ClCompile>
<!--可选,_msvcrt.h自动会添加这些设置-->
<PreprocessorDefinitions Condition=" '$(SupportLTL)'=='true' ">_NO_CRT_STDIO_INLINE=1;_Build_By_LTL=1;_DISABLE_DEPRECATE_STATIC_CPPLIB=1;_STATIC_CPPLIB=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<!--可选,msvcrt.lib自动会添加这些设置-->
<AdditionalDependencies>msvcrt_Platform.lib;ltl.lib;vc.lib;ucrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>

<!--UCRT模式-->
Expand Down Expand Up @@ -164,7 +156,7 @@
VC Tools Version : $(VC-LTLUsedToolsVersion)
UCRT Version : $(VC-LTLTargetUniversalCRTVersion)
Platform : $(PlatformShortName)
Using VC-LTL $(OsPlatformName) $(LTL_Mode) Mode
Using VC-LTL $(OsPlatformName)$(LTL_LinkDirMod) $(LTL_Mode) Mode
" Importance="high" Condition="('$(SupportLTL)'=='true') Or ('$(SupportLTL)'=='ucrt')"/>
<Warning Code="LTL2000" Text="VC-LTL不兼容 Debug 配置,VC-LTL已经自动禁用,请切换到 Release 配置然后继续。" Condition="'$(UseDebugLibraries)'=='true'" />
<Warning Code="LTL2001" Text="VC-LTL不兼容 MFC 项目,VC-LTL已经自动禁用。" Condition="'$(UseOfMFC)'!='false'" />
Expand All @@ -173,7 +165,7 @@
<Warning Code="LTL2004" Text="VC-LTL不兼容 Windows 10 Universal Driver,VC-LTL已经自动禁用。" Condition="'$(DriverTargetPlatform)'=='Universal'"/>

<Warning Code="LTL3000" Text="VC-LTL不支持 VC $(VCToolsVersion),已临时切换到 VC $(VC-LTLUsedToolsVersion) 来维持基础功能。这可能是你的IDE版本过低,建议升级到最新IDE然后继续!" Condition="('$(SupportLTL)'=='true') And ('$(VC-LTLFoundToolsVersion)'=='false')" />
<Warning Code="LTL3001" Text="VC-LTL不支持 SDK $(TargetUniversalCRTVersion),目前已临时切换到 SDK $(VC-LTLTargetUniversalCRTVersion) 来维持基础功能。这可能是你的SDK版本过低,建议切换到最新SDK然后继续!" Condition="('$(SupportLTL)'=='true') And ('$(VC-LTLFoundTargetUniversalCRTVersion)'=='false')" />
<Warning Code="LTL3001" Text="VC-LTL不支持 UCRT $(TargetUniversalCRTVersion),目前已临时切换到 UCRT $(VC-LTLTargetUniversalCRTVersion) 来维持基础功能。这可能是你的SDK版本过低,建议切换到最新SDK然后继续!" Condition="('$(SupportLTL)'=='true') And ('$(VC-LTLFoundTargetUniversalCRTVersion)'=='false')" />
<Warning Code="LTL3002" Text="VC-LTL不支持 UCRT模式与Windows XP兼容模式同时使用,已临时禁用Windows XP兼容模式。" Condition=" ('$(SupportLTL)'=='ucrt') And ('$(SupportWinXP)'=='true')"/>
<Warning Code="LTL3003" Text="VC-LTL不完全支持 $(SpectreMitigation) 缓解方案,建议升级到最新VC-LTL然后继续。" Condition=" ('$(SupportLTL)'=='true') And ('$(VC-LTLLibDirMod)'!='$(VCLibDirMod)')"/>
</Target>
Expand Down
9 changes: 7 additions & 2 deletions src/LTL_Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <corecrt_internal.h>


#ifndef __Bulib_Dynamic_Lib

static void __cdecl __LTL_Unitialization() throw()
{
//__acrt_uninitialize_locks(false);
Expand All @@ -10,20 +13,22 @@ static void __cdecl __LTL_Unitialization() throw()
__acrt_uninitialize_winapi_thunks(false);

}
#endif

EXTERN_C int __cdecl __LTL_Initialization() throw()
{
//先初始化高级指令支持
__isa_available_init();

//需要支持XP时才需要初始化,Vista以上系统直接使用新接口
#ifndef __Bulib_Dynamic_Lib
//初始化winapi_thunks
__acrt_initialize_winapi_thunks();

//__acrt_initialize_locks();


atexit(__LTL_Unitialization);

#endif
return 0;
}

Expand Down
10 changes: 9 additions & 1 deletion src/_msvcrt.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(NDEBUG)&&defined(_DLL)&&defined(_Build_By_LTL)
#if defined(NDEBUG)&&defined(_DLL)&&defined(__Build_LTL)
#define _CRT_BEST_PRACTICES_USAGE

#include <vcruntime_new.h>
Expand Down Expand Up @@ -73,6 +73,8 @@ extern "C"
return true;
}

_LCRT_DEFINE_IAT_SYMBOL(__scrt_initialize_onexit_tables);

/*void __std_terminate(void)
{
terminate();
Expand Down Expand Up @@ -139,6 +141,9 @@ extern "C"
return InitializeCriticalSectionEx(critical_section, spin_count, flags);
#endif
}

_LCRT_DEFINE_IAT_SYMBOL(__vcrt_InitializeCriticalSectionEx);

//int __scrt_debugger_hook_flag = 0;

//void __cdecl _CRT_DEBUGGER_HOOK(int const reserved)
Expand Down Expand Up @@ -304,6 +309,8 @@ extern "C"
return memcpy_s(_S1, _N1 * sizeof(wchar_t), _S2, _N * sizeof(wchar_t));
}

_LCRT_DEFINE_IAT_SYMBOL(wmemcpy_s);

errno_t __CRTDECL wmemmove_s(
_Out_writes_to_opt_(_N1, _N) wchar_t* _S1,
_In_ rsize_t _N1,
Expand All @@ -314,6 +321,7 @@ extern "C"
return memmove_s(_S1, _N1 * sizeof(wchar_t), _S2, _N * sizeof(wchar_t));
}

_LCRT_DEFINE_IAT_SYMBOL(wmemmove_s);

// int __cdecl __stdio_common_vswprintf(
// _In_ unsigned __int64 _Options,
Expand Down
39 changes: 1 addition & 38 deletions src/frame_thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "ehdata.h"
#include <msvcrt_IAT.h>

EXTERN_C DWORD __cdecl __LTL_GetOsMinVersion();




Expand Down Expand Up @@ -134,39 +132,4 @@ extern "C" void *__AdjustPointer(
return pRet;
}

#ifdef _X86_
extern "C" void __stdcall _CallMemberFunction0(void *pthis, void *pmfn)
{

__asm
{
mov ecx, pthis
call pmfn
}
}
#endif

#ifdef _X86_
extern "C" void __stdcall _CallMemberFunction1(void *pthis, void *pmfn, void *pthat)
{
__asm
{
push pthat
mov ecx, pthis
call pmfn
}
}
#endif

#ifdef _X86_
extern "C" void __stdcall _CallMemberFunction2(void *pthis, void *pmfn, void *pthat, int val2)
{
__asm
{
push val2
push pthat
mov ecx, pthis
call pmfn
}
}
#endif
_LCRT_DEFINE_IAT_SYMBOL(__AdjustPointer);
Loading

0 comments on commit 51dc96d

Please sign in to comment.