diff --git a/TypeInfoHack/Hack.cpp b/TypeInfoHack/Hack.cpp new file mode 100644 index 0000000..c32b85e --- /dev/null +++ b/TypeInfoHack/Hack.cpp @@ -0,0 +1,48 @@ + +#include "Hack.h" + +#pragma warning(push) +#pragma warning(disable: 4577) // 'noexcept' used with no exception handling mode specified + +size_t type_info::hash_code() const noexcept +{ + return __std_type_info_hash(&_Data); +} + +bool type_info::operator==(const type_info& _Other) const noexcept +{ + return __std_type_info_compare(&_Data, &_Other._Data) == 0; +} + +bool type_info::operator!=(const type_info& _Other) const noexcept +{ + return __std_type_info_compare(&_Data, &_Other._Data) != 0; +} + +bool type_info::before(const type_info& _Other) const noexcept +{ + return __std_type_info_compare(&_Data, &_Other._Data) < 0; +} + +const char* type_info::name() const +{ +#ifdef _M_CEE_PURE + return __std_type_info_name(&_Data, static_cast<__type_info_node*>(__type_info_root_node.ToPointer())); +#else + return __std_type_info_name(&_Data, &__type_info_root_node); +#endif +} + +const char* type_info::name(__type_info_node*) const +{ +#ifdef _M_CEE_PURE + return __std_type_info_name(&_Data, static_cast<__type_info_node*>(__type_info_root_node.ToPointer())); +#else + return __std_type_info_name(&_Data, &__type_info_root_node); +#endif +} + +const char* type_info::raw_name() const +{ + return _Data._DecoratedName; +} diff --git a/TypeInfoHack/Hack.h b/TypeInfoHack/Hack.h new file mode 100644 index 0000000..aa2504b --- /dev/null +++ b/TypeInfoHack/Hack.h @@ -0,0 +1,90 @@ +#pragma once + +#include + +#ifdef MYDLL_EXPORTS +#define API __declspec(dllexport) +#else +#define API __declspec(dllimport) +#endif + + +#include + +#include + +#pragma warning(push) +#pragma warning(disable: _VCRUNTIME_DISABLED_WARNINGS) + +#if defined _M_CEE_MIXED && !defined _VCRT_BUILD +// Provide a fake definition of __type_info_node to suppress linker warning +// LNK4248: unresolved typeref token for '__type_info_node'; image may not run. +struct __type_info_node { }; +#else +struct __type_info_node; +#endif + +#ifdef _M_CEE_PURE +extern System::IntPtr __type_info_root_node; +#else +extern __type_info_node __type_info_root_node; +#endif + + +_CRT_BEGIN_C_HEADER + +struct __std_type_info_data +{ + const char* _UndecoratedName; + const char _DecoratedName[1]; + __std_type_info_data() = delete; + __std_type_info_data(const __std_type_info_data&) = delete; + __std_type_info_data(__std_type_info_data&&) = delete; + + __std_type_info_data& operator=(const __std_type_info_data&) = delete; + __std_type_info_data& operator=(__std_type_info_data&&) = delete; +}; + +_VCRTIMP int __cdecl __std_type_info_compare( + _In_ const __std_type_info_data* _Lhs, + _In_ const __std_type_info_data* _Rhs +); + +_VCRTIMP size_t __cdecl __std_type_info_hash( + _In_ const __std_type_info_data* _Data +); + +_VCRTIMP const char* __cdecl __std_type_info_name( + _Inout_ __std_type_info_data* _Data, + _Inout_ __type_info_node* _RootNode +); + +_CRT_END_C_HEADER + +class API type_info +{ +public: + + type_info(const type_info&) = delete; + type_info& operator=(const type_info&) = delete; + + size_t hash_code() const noexcept; + + bool operator==(const type_info& _Other) const noexcept; + + bool operator!=(const type_info& _Other) const noexcept; + + bool before(const type_info& _Other) const noexcept; + + const char* name() const; + + const char* name(__type_info_node*) const; + + const char* raw_name() const; + + virtual ~type_info() noexcept; + +private: + + mutable __std_type_info_data _Data; +}; \ No newline at end of file diff --git a/TypeInfoHack/TypeInfoHack.vcxproj b/TypeInfoHack/TypeInfoHack.vcxproj new file mode 100644 index 0000000..7ab1ab9 --- /dev/null +++ b/TypeInfoHack/TypeInfoHack.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {20bc294d-e18f-4fb2-84bf-6ede694f35b2} + TypeInfoHack + 10.0 + + + + StaticLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + MYDLL_EXPORTS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + MYDLL_EXPORTS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/TypeInfoHack/TypeInfoHack.vcxproj.filters b/TypeInfoHack/TypeInfoHack.vcxproj.filters new file mode 100644 index 0000000..4fa0daf --- /dev/null +++ b/TypeInfoHack/TypeInfoHack.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/TypeInfoHack/TypeInfoHack.vcxproj.user b/TypeInfoHack/TypeInfoHack.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/TypeInfoHack/TypeInfoHack.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/v110_static/class_110.cpp b/v110_static/class_110.cpp index fdc757d..118523b 100644 --- a/v110_static/class_110.cpp +++ b/v110_static/class_110.cpp @@ -1,4 +1,5 @@ #include "class_110.h" +#include string::string(const char* _c): c(_c) { diff --git a/vs2019.sln b/vs2019.sln index ce942ad..61306b3 100644 --- a/vs2019.sln +++ b/vs2019.sln @@ -16,6 +16,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v142", "v142\vs2019.vcxproj EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v110_static", "v110_static\v110_static.vcxproj", "{19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TypeInfoHack", "TypeInfoHack\TypeInfoHack.vcxproj", "{20BC294D-E18F-4FB2-84BF-6EDE694F35B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -54,6 +56,14 @@ Global {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x64.Build.0 = Release|x64 {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x86.ActiveCfg = Release|Win32 {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x86.Build.0 = Release|Win32 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Debug|x64.ActiveCfg = Debug|x64 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Debug|x64.Build.0 = Debug|x64 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Debug|x86.ActiveCfg = Debug|Win32 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Debug|x86.Build.0 = Debug|Win32 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Release|x64.ActiveCfg = Release|x64 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Release|x64.Build.0 = Release|x64 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Release|x86.ActiveCfg = Release|Win32 + {20BC294D-E18F-4FB2-84BF-6EDE694F35B2}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE