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

Commit

Permalink
解决BUG,修复无法使用__argc、__argv、__wargv、_environ、_wenviron全局变量问题(感谢 亮叔叔)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jul 28, 2017
1 parent 4e9df5d commit 0b96be8
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 36 deletions.
8 changes: 8 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ msvcrt_winxp.obj(WinXP 32)/msvcrt_win2003.obj(WinXP 64)
* ltl140xp.lib/ltl141xp.lib VC2015/VC2017 XP模式 编译平台使用到的扩展函数,其内容通过编译_msvcrt.cpp得到
* msvcrt_base.lib Vista msvcrt.dll删除过的导出符号表(从原版中删除了一些无用符号,并且加入了helper.asm转发函数)
* msvcrt_vista.lib Vista msvcrt.dll 原版符号表(从DDK提取)
* msvcrtp.lib 微软在msvcrt中导出的函数,但是并未在msvcrt.lib中提供的函数。
* ucrt_14393.lib/ucrt_15063.lib 从libucrt.lib提取的一些原有lib不支持的函数集合。
* vc140.lib/vc141.lib 从msvcrt.lib提取的一些原有lib不支持的函数集合。

## Changes:
1.0.0.10 2017-07-28 20:28
* 解决BUG 9,某些时候编译器引用异常导致XP模式时意外引入_except_handler4_common(感谢 HwangBae)
* 解决BUG 8,修复typeid功能无法使用问题(感谢 HwangBae)
* 调整异常实现代码,尽可能复用msvcrt.dll代码减少代码体积
* 解决BUG,修复无法使用__argc、__argv、__wargv、_environ、_wenviron全局变量问题(感谢 亮叔叔)
* 解决微软BUG,修复使用ATL库的程序不支持XP RTM问题

1.0.0.9 2017-05-26 14:46
* 改进Windows XP支持
* 优化库结构裁剪ltl库体积
Expand Down
3 changes: 3 additions & 0 deletions VC-LTL.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@
<Library Include="$(MSBuildThisFileDirectory)x64\ltl140xp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\ltl141.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\ltl141xp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\msvcrtp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\msvcrt_base.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\msvcrt_vista.lib" />
<Library Include="$(MSBuildThisFileDirectory)x64\ucrt_10240.lib" />
Expand All @@ -997,6 +998,7 @@
<Library Include="$(MSBuildThisFileDirectory)x86\ltl140xp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\ltl141.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\ltl141xp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\msvcrtp.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\msvcrt_base.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\msvcrt_vista.lib" />
<Library Include="$(MSBuildThisFileDirectory)x86\ucrt_10240.lib" />
Expand All @@ -1011,6 +1013,7 @@
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)ltlvcrt.props" />
<None Include="$(MSBuildThisFileDirectory)ltlvcrtWinXp.props" />
<None Include="$(MSBuildThisFileDirectory)msvcrtp.def" />
<None Include="$(MSBuildThisFileDirectory)VC\140\atlmfc\include\afx.inl" />
<None Include="$(MSBuildThisFileDirectory)VC\140\atlmfc\include\afxcmn.inl" />
<None Include="$(MSBuildThisFileDirectory)VC\140\atlmfc\include\afxcmn2.inl" />
Expand Down
9 changes: 9 additions & 0 deletions VC-LTL.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,12 @@
<Library Include="$(MSBuildThisFileDirectory)x86\ucrt_10240.lib">
<Filter>Libx86</Filter>
</Library>
<Library Include="D:\用户数据\Documents\Visual Studio 2015\Projects\VC-LTL\x64\msvcrtp.lib">
<Filter>Libx64</Filter>
</Library>
<Library Include="D:\用户数据\Documents\Visual Studio 2015\Projects\VC-LTL\x86\msvcrtp.lib">
<Filter>Libx86</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)VC\140\include\algorithm">
Expand Down Expand Up @@ -3815,6 +3821,9 @@
<Filter>源代码\VC\141\atlmfc\include</Filter>
</None>
<None Include="$(MSBuildThisFileDirectory)ltlvcrtWinXp.props" />
<None Include="D:\用户数据\Documents\Visual Studio 2015\Projects\VC-LTL\msvcrtp.def">
<Filter>源代码</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="$(MSBuildThisFileDirectory)VC\140\atlmfc\include\about_.rc">
Expand Down
2 changes: 2 additions & 0 deletions _msvcrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,7 @@

//导入Windows Vista 动态库 msvcrt.dll
#pragma comment(lib,"msvcrt_base.lib")
//导入msvcrt补充库
#pragma comment(lib,"msvcrtp.lib")

#endif //NDEBUG&&_DLL
5 changes: 5 additions & 0 deletions msvcrtp.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LIBRARY msvcrt.dll

EXPORTS
_environ
_wenviron
45 changes: 33 additions & 12 deletions ucrt/10.0.10240.0/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,38 +1155,59 @@ __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t, _splitpath_s, char, _Dest)
#endif // __STDC_WANT_SECURE_LIB__




_ACRTIMP int* __cdecl __p___argc (void);
_ACRTIMP char*** __cdecl __p___argv (void);
_ACRTIMP wchar_t*** __cdecl __p___wargv(void);

#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_ACRTIMP extern int __argc;
_ACRTIMP extern char** __argv;
_ACRTIMP extern wchar_t** __wargv;


__inline int* __cdecl __p___argc(void)
{
return &__argc;
}
__inline char*** __cdecl __p___argv(void)
{
return &__argv;
}
__inline wchar_t*** __cdecl __p___wargv(void)
{
return &__wargv;
}

/*#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
extern int __argc;
extern char** __argv;
extern wchar_t** __wargv;
#else
#define __argc (*__p___argc()) // Pointer to number of command line arguments
#define __argv (*__p___argv()) // Pointer to table of narrow command line arguments
#define __wargv (*__p___wargv()) // Pointer to table of wide command line arguments
#endif
#endif*/

_DCRTIMP char*** __cdecl __p__environ (void);
_DCRTIMP wchar_t*** __cdecl __p__wenviron(void);
_ACRTIMP extern char ** _environ;
_ACRTIMP extern wchar_t ** _wenviron;

__inline char*** __cdecl __p__environ(void)
{
return &_environ;
}
__inline wchar_t*** __cdecl __p__wenviron(void)
{
return &_wenviron;
}

#ifndef _CRT_BEST_PRACTICES_USAGE
#define _CRT_V12_LEGACY_FUNCTIONALITY
#endif

#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
/*#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
// Deprecated symbol: Do not expose environment global pointers unless
// legacy access is specifically requested
#define _environ crt_usage_error__do_not_reference_global_pointer_directly__environ
#define _wenviron crt_usage_error__do_not_reference_global_pointer_directly__wenviron
#else
#define _environ (*__p__environ()) // Pointer to narrow environment table
#define _wenviron (*__p__wenviron()) // Pointer to wide environment table
#endif
#endif*/



Expand Down
45 changes: 33 additions & 12 deletions ucrt/10.0.14393.0/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1159,38 +1159,59 @@ __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t, _splitpath_s, char, _Dest)
#endif // __STDC_WANT_SECURE_LIB__




_ACRTIMP int* __cdecl __p___argc (void);
_ACRTIMP char*** __cdecl __p___argv (void);
_ACRTIMP wchar_t*** __cdecl __p___wargv(void);

#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_ACRTIMP extern int __argc;
_ACRTIMP extern char** __argv;
_ACRTIMP extern wchar_t** __wargv;


__inline int* __cdecl __p___argc(void)
{
return &__argc;
}
__inline char*** __cdecl __p___argv(void)
{
return &__argv;
}
__inline wchar_t*** __cdecl __p___wargv(void)
{
return &__wargv;
}

/*#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
extern int __argc;
extern char** __argv;
extern wchar_t** __wargv;
#else
#define __argc (*__p___argc()) // Pointer to number of command line arguments
#define __argv (*__p___argv()) // Pointer to table of narrow command line arguments
#define __wargv (*__p___wargv()) // Pointer to table of wide command line arguments
#endif
#endif*/

_ACRTIMP extern char ** _environ;
_ACRTIMP extern wchar_t ** _wenviron;

_DCRTIMP char*** __cdecl __p__environ (void);
_DCRTIMP wchar_t*** __cdecl __p__wenviron(void);
__inline char*** __cdecl __p__environ(void)
{
return &_environ;
}
__inline wchar_t*** __cdecl __p__wenviron(void)
{
return &_wenviron;
}

#ifndef _CRT_BEST_PRACTICES_USAGE
#define _CRT_V12_LEGACY_FUNCTIONALITY
#endif

#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
/*#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
// Deprecated symbol: Do not expose environment global pointers unless
// legacy access is specifically requested
#define _environ crt_usage_error__do_not_reference_global_pointer_directly__environ
#define _wenviron crt_usage_error__do_not_reference_global_pointer_directly__wenviron
#else
#define _environ (*__p__environ()) // Pointer to narrow environment table
#define _wenviron (*__p__wenviron()) // Pointer to wide environment table
#endif
#endif*/



Expand Down
45 changes: 33 additions & 12 deletions ucrt/10.0.15063.0/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1170,38 +1170,59 @@ __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t, _splitpath_s, char, _Dest)
#endif // __STDC_WANT_SECURE_LIB__




_ACRTIMP int* __cdecl __p___argc (void);
_ACRTIMP char*** __cdecl __p___argv (void);
_ACRTIMP wchar_t*** __cdecl __p___wargv(void);

#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_ACRTIMP extern int __argc;
_ACRTIMP extern char** __argv;
_ACRTIMP extern wchar_t** __wargv;


__inline int* __cdecl __p___argc(void)
{
return &__argc;
}
__inline char*** __cdecl __p___argv(void)
{
return &__argv;
}
__inline wchar_t*** __cdecl __p___wargv(void)
{
return &__wargv;
}

/*#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
extern int __argc;
extern char** __argv;
extern wchar_t** __wargv;
#else
#define __argc (*__p___argc()) // Pointer to number of command line arguments
#define __argv (*__p___argv()) // Pointer to table of narrow command line arguments
#define __wargv (*__p___wargv()) // Pointer to table of wide command line arguments
#endif
#endif*/

_ACRTIMP extern char ** _environ;
_ACRTIMP extern wchar_t ** _wenviron;

_DCRTIMP char*** __cdecl __p__environ (void);
_DCRTIMP wchar_t*** __cdecl __p__wenviron(void);
__inline char*** __cdecl __p__environ(void)
{
return &_environ;
}
__inline wchar_t*** __cdecl __p__wenviron(void)
{
return &_wenviron;
}

#ifndef _CRT_BEST_PRACTICES_USAGE
#define _CRT_V12_LEGACY_FUNCTIONALITY
#endif

#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
/*#ifndef _CRT_V12_LEGACY_FUNCTIONALITY
// Deprecated symbol: Do not expose environment global pointers unless
// legacy access is specifically requested
#define _environ crt_usage_error__do_not_reference_global_pointer_directly__environ
#define _wenviron crt_usage_error__do_not_reference_global_pointer_directly__wenviron
#else
#define _environ (*__p__environ()) // Pointer to narrow environment table
#define _wenviron (*__p__wenviron()) // Pointer to wide environment table
#endif
#endif*/



Expand Down
Binary file added x64/msvcrtp.lib
Binary file not shown.
Binary file added x86/msvcrtp.lib
Binary file not shown.

0 comments on commit 0b96be8

Please sign in to comment.