├── .gitattributes ├── .gitignore ├── LICENSE ├── ReadMe.txt ├── libc.vcxproj ├── libc.vcxproj.filters └── src ├── amd64 └── exc.asm ├── assert.cpp ├── cpp.cpp ├── cpp.h ├── except.cpp ├── libc.cpp ├── libc.h ├── std.cpp └── typeinfo.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peter Hlavaty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | C++ to kernel drivers! .. link this lib with driver and start use c++ features, and std & boost supported also (not at all ofc, but f.e. shared_ptr / unique_ptr, boostL::instrusive ..), in visual studio 2013 2 | more to read at : http://www.zer0mem.sk/?p=517 3 | -------------------------------------------------------------------------------- /libc.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {6B090B01-76A1-4521-902D-6011FE9AA4ED} 23 | Win32Proj 24 | libc 25 | 26 | 27 | 28 | StaticLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | StaticLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | StaticLibrary 41 | false 42 | WindowsKernelModeDriver8.1 43 | true 44 | Unicode 45 | 46 | 47 | StaticLibrary 48 | false 49 | WindowsKernelModeDriver8.1 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | $(WindowsSDKDir)\include\km\;$(VC_IncludePath);$(WindowsSDK_IncludePath); 70 | $(SolutionDir)$(Platform)\ 71 | 72 | 73 | 74 | Use 75 | Level3 76 | Disabled 77 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Windows 82 | true 83 | 84 | 85 | 86 | 87 | Use 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 91 | true 92 | 93 | 94 | Windows 95 | true 96 | 97 | 98 | 99 | 100 | Level3 101 | NotUsing 102 | MaxSpeed 103 | true 104 | true 105 | R32R0;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 106 | true 107 | false 108 | $(WindowsSDKDir)\include\shared\;$(WindowsSDKDir)\include\km\;$(SolutionDir);$(IntDir);%(AdditionalIncludeDirectories) 109 | 110 | 111 | Windows 112 | true 113 | true 114 | true 115 | 116 | 117 | true 118 | 119 | 120 | libcmt.lib 121 | $(DDK_LIB_PATH)\libcntpr.lib; 122 | 123 | 124 | 125 | 126 | Level3 127 | NotUsing 128 | MaxSpeed 129 | true 130 | true 131 | R32R0;CPP_DRIVER_COMMON;_WIN64;_AMD64_;AMD64;NDEBUG;_LIB;%(PreprocessorDefinitions) 132 | true 133 | MultiThreaded 134 | false 135 | 136 | $(WindowsSDKDir)\include\km\;$(SolutionDir);$(IntDir);%(AdditionalIncludeDirectories) 137 | /kernel %(ClCompile.AdditionalOptions) 138 | false 139 | false 140 | NoListing 141 | Default 142 | FastCall 143 | 144 | 145 | Windows 146 | true 147 | true 148 | true 149 | 150 | 151 | 152 | 153 | true 154 | $(DDK_LIB_PATH)\libcntpr.lib; 155 | libcmt.lib 156 | 157 | 158 | 159 | 160 | true 161 | 162 | 163 | true 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | true 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | true 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /libc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {8d77a827-bdc1-47fe-973a-d90c8779da50} 18 | 19 | 20 | {7d45792e-8fc8-4b0b-a729-d8c817122ed8} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Source Files\LIBC 29 | 30 | 31 | Source Files\LIBC 32 | 33 | 34 | Source Files\LIBC 35 | 36 | 37 | Source Files\LIBC 38 | 39 | 40 | Source Files\LIBC 41 | 42 | 43 | Source Files\LIBC 44 | 45 | 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | 55 | 56 | Source Files\amd64 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/amd64/exc.asm: -------------------------------------------------------------------------------- 1 | IFDEF RAX 2 | ELSE 3 | .model flat 4 | ENDIF 5 | 6 | .code 7 | 8 | IFDEF RAX 9 | __EH_prolog proc 10 | pop rax 11 | push rbp 12 | mov rbp, rsp 13 | jmp rax 14 | __EH_prolog endp 15 | 16 | __EH_prolog3_catch proc 17 | pop rax 18 | push rbp 19 | mov rbp, rsp 20 | jmp rax 21 | __EH_prolog3_catch endp 22 | 23 | __EH_epilog3 proc 24 | mov rsp, rbp 25 | pop rbp 26 | ret 27 | __EH_epilog3 endp 28 | 29 | __EH_epilog3_catch proc 30 | mov rsp, rbp 31 | pop rbp 32 | ret 33 | __EH_epilog3_catch endp 34 | ELSE 35 | __EH_prolog proc 36 | pop eax 37 | push ebp 38 | mov ebp, esp 39 | jmp eax 40 | __EH_prolog endp 41 | 42 | __EH_prolog3_catch proc 43 | pop eax 44 | push ebp 45 | mov ebp, esp 46 | jmp eax 47 | __EH_prolog3_catch endp 48 | 49 | __EH_epilog3 proc 50 | mov esp, ebp 51 | pop ebp 52 | ret 53 | __EH_epilog3 endp 54 | 55 | __EH_epilog3_catch proc 56 | mov esp, ebp 57 | pop ebp 58 | ret 59 | __EH_epilog3_catch endp 60 | ENDIF 61 | 62 | _wassert proc 63 | ret 64 | _wassert endp 65 | 66 | __InternalCxxFrameHandler proc 67 | int 3 68 | ret 69 | __InternalCxxFrameHandler endp 70 | 71 | __hypot proc 72 | ret 73 | __hypot endp 74 | 75 | __invalid_parameter proc 76 | ret 77 | __invalid_parameter endp 78 | 79 | 80 | IFDEF RAX 81 | __CxxFrameHandler3 proc 82 | __CxxThrowException proc 83 | ELSE 84 | ___CxxFrameHandler3 proc 85 | ___CxxThrowException proc 86 | ENDIF 87 | 88 | 89 | int 3 90 | ret 91 | 92 | IFDEF RAX 93 | __CxxThrowException endp 94 | __CxxFrameHandler3 endp 95 | ELSE 96 | ___CxxThrowException endp 97 | ___CxxFrameHandler3 endp 98 | ENDIF 99 | 100 | end 101 | -------------------------------------------------------------------------------- /src/assert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | __cdecl 5 | _wassert( 6 | __in_z const wchar_t * message, 7 | __in_z const wchar_t *file, 8 | __in unsigned line 9 | ) 10 | { 11 | return; 12 | } 13 | -------------------------------------------------------------------------------- /src/cpp.cpp: -------------------------------------------------------------------------------- 1 | #include "cpp.h" 2 | 3 | extern "C" 4 | int 5 | __cdecl 6 | atexit( 7 | __in void(__cdecl *destructor)(void) 8 | ) 9 | { 10 | if (!destructor) 11 | return 0; 12 | 13 | ATEXIT_ENTRY* entry = new ATEXIT_ENTRY(destructor, g_pTopAtexitEntry); 14 | if (!entry) 15 | return 0; 16 | g_pTopAtexitEntry = entry; 17 | return 1; 18 | } 19 | 20 | #if defined(_IA64_) || defined(_AMD64_) 21 | #pragma section(".CRT$XCA",long,read) 22 | __declspec(allocate(".CRT$XCA")) void(*__ctors_begin__[1])(void) = { 0 }; 23 | #pragma section(".CRT$XCZ",long,read) 24 | __declspec(allocate(".CRT$XCZ")) void(*__ctors_end__[1])(void) = { 0 }; 25 | #pragma data_seg() 26 | #else 27 | #pragma data_seg(".CRT$XCA") 28 | void(*__ctors_begin__[1])(void) = { 0 }; 29 | #pragma data_seg(".CRT$XCZ") 30 | void(*__ctors_end__[1])(void) = { 0 }; 31 | #pragma data_seg() 32 | #endif 33 | 34 | #pragma data_seg(".STL$A") 35 | void(*___StlStartInitCalls__[1])(void) = { 0 }; 36 | #pragma data_seg(".STL$L") 37 | void(*___StlEndInitCalls__[1])(void) = { 0 }; 38 | #pragma data_seg(".STL$M") 39 | void(*___StlStartTerminateCalls__[1])(void) = { 0 }; 40 | #pragma data_seg(".STL$Z") 41 | void(*___StlEndTerminateCalls__[1])(void) = { 0 }; 42 | #pragma data_seg() 43 | 44 | extern "C" 45 | void 46 | __cdecl 47 | cc_doexit( 48 | __in int, 49 | __in int, 50 | __in int 51 | ) 52 | { 53 | for (ATEXIT_ENTRY* entry = g_pTopAtexitEntry; entry;) 54 | { 55 | ATEXIT_ENTRY* next = entry->Next; 56 | delete entry; 57 | entry = next; 58 | } 59 | } 60 | 61 | extern "C" 62 | int 63 | __cdecl 64 | cc_init( 65 | __in int 66 | ) 67 | { 68 | for (void(**ctor)(void) = __ctors_begin__ + 1; 69 | *ctor && ctor < __ctors_end__; 70 | ctor++) 71 | { 72 | (*ctor)(); 73 | } 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /src/cpp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct ATEXIT_ENTRY 6 | { 7 | ATEXIT_ENTRY( 8 | __in void(__cdecl *destructor)(void), 9 | __in ATEXIT_ENTRY* next 10 | ) 11 | { 12 | Destructor = destructor; 13 | Next = next; 14 | } 15 | 16 | ~ATEXIT_ENTRY() 17 | { 18 | Destructor(); 19 | } 20 | 21 | void(_cdecl *Destructor)(); 22 | ATEXIT_ENTRY* Next; 23 | }; 24 | 25 | static ATEXIT_ENTRY* g_pTopAtexitEntry = nullptr; 26 | 27 | extern "C" 28 | int 29 | __cdecl 30 | cc_atexit( 31 | __in void(__cdecl *destructor)(void) 32 | ); 33 | 34 | extern "C" 35 | int 36 | __cdecl 37 | cc_init( 38 | __in int 39 | ); 40 | 41 | extern "C" 42 | void 43 | __cdecl 44 | cc_doexit( 45 | __in int, 46 | __in int, 47 | __in int 48 | ); 49 | -------------------------------------------------------------------------------- /src/except.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" 6 | EXCEPTION_DISPOSITION 7 | ExCxxFrameHandler3( 8 | __in void* pExcept, // Information for this exception 9 | __in ULONG_PTR RN, // Dynamic information for this frame 10 | __in void* pContext, // Context info 11 | __in void* pDC // More dynamic info for this frame 12 | ) 13 | { 14 | __debugbreak(); 15 | return EXCEPTION_DISPOSITION::ExceptionNestedException; 16 | } 17 | 18 | #ifdef _WIN64 19 | 20 | extern "C" 21 | void 22 | _CxxThrowException( 23 | __in void *, 24 | __in _ThrowInfo * 25 | ) 26 | { 27 | } 28 | 29 | #else 30 | 31 | extern "C" 32 | void 33 | __stdcall 34 | _CxxThrowException( 35 | __in void *, 36 | __in _ThrowInfo * 37 | ) 38 | { 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/libc.cpp: -------------------------------------------------------------------------------- 1 | #include "libc.h" 2 | #include 3 | #include 4 | 5 | void* 6 | __cdecl 7 | operator new( 8 | __in size_t size 9 | ) 10 | { 11 | return malloc(size); 12 | } 13 | 14 | void 15 | __cdecl 16 | operator delete( 17 | __inout void* ptr 18 | ) 19 | { 20 | free(ptr); 21 | } 22 | 23 | #pragma warning(push) 24 | #pragma warning (disable : 4565) 25 | __drv_maxIRQL(DISPATCH_LEVEL) 26 | void* 27 | __cdecl 28 | malloc( 29 | __in size_t size 30 | ) 31 | { 32 | if ((size_t)(~0) - sizeof(MEMBLOCK) < size) 33 | return nullptr; 34 | 35 | MEMBLOCK* block = static_cast( 36 | ExAllocatePoolWithTag( 37 | NonPagedPoolNxCacheAligned, 38 | size + sizeof(MEMBLOCK), 39 | _LIBC_POOL_TAG)); 40 | 41 | if (nullptr == block) 42 | return nullptr; 43 | block->size = size; 44 | return block->data; 45 | } 46 | 47 | __drv_maxIRQL(DISPATCH_LEVEL) 48 | void 49 | __cdecl 50 | free( 51 | __inout void* ptr 52 | ) 53 | { 54 | if (ptr) 55 | ExFreePoolWithTag(CONTAINING_RECORD(ptr, MEMBLOCK, data), _LIBC_POOL_TAG); 56 | } 57 | 58 | __drv_maxIRQL(DISPATCH_LEVEL) 59 | void* 60 | __cdecl 61 | realloc( 62 | __in_opt void* ptr, 63 | __in size_t size 64 | ) 65 | { 66 | if (!ptr) 67 | return malloc(size); 68 | 69 | if (CONTAINING_RECORD(ptr, MEMBLOCK, data)->size >= size) 70 | return ptr; 71 | 72 | auto inblock = std::unique_ptr(static_cast(ptr)); 73 | 74 | // alloc new block 75 | void* mem = malloc(size); 76 | if (!mem) 77 | return nullptr; 78 | 79 | // copy from old one, not overflow .. 80 | memcpy(mem, inblock.get(), size); 81 | return mem; 82 | } 83 | 84 | extern "C" 85 | __drv_maxIRQL(DISPATCH_LEVEL) 86 | void* 87 | __cdecl 88 | calloc( 89 | __in size_t n, 90 | __in size_t size 91 | ) 92 | { 93 | if (!size) 94 | return nullptr; 95 | if ((size_t)(~0) / n < size) 96 | return nullptr; 97 | size_t total = n * size; 98 | 99 | void* p = malloc(total); 100 | 101 | if (!p) 102 | return nullptr; 103 | 104 | return memset(p, 0, total); 105 | } 106 | #pragma warning(pop) 107 | 108 | extern "C" 109 | int 110 | __cdecl 111 | vsnprintf( 112 | __in_ecount(count) char *buf, 113 | __in size_t count, 114 | __in const char *fmt, 115 | __in va_list args 116 | ) 117 | { 118 | return vsprintf_s(buf, count, fmt, args); 119 | } 120 | 121 | extern "C" 122 | int 123 | __cdecl 124 | printf( 125 | __in const char* fmt, 126 | ... 127 | ) 128 | { 129 | char buff[0x100] = { 0 }; 130 | va_list arg_list; 131 | 132 | va_start(arg_list, fmt); 133 | int ret = vsprintf_s(buff, sizeof(buff), fmt, arg_list); 134 | va_end(arg_list); 135 | if (ret) 136 | DbgPrint(buff); 137 | return ret; 138 | } 139 | -------------------------------------------------------------------------------- /src/libc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _CRT_ALLOCATION_DEFINED 4 | 5 | #include 6 | #include 7 | 8 | #define _LIBC_POOL_TAG 'LIBC' 9 | 10 | #pragma pack(push, 1) 11 | struct MEMBLOCK 12 | { 13 | size_t size; 14 | #pragma warning(push) 15 | #pragma warning (disable : 4200) 16 | char data[0]; 17 | #pragma warning(pop) 18 | }; 19 | #pragma pack(pop) 20 | 21 | extern "C" 22 | void* 23 | __cdecl 24 | malloc( 25 | __in size_t size 26 | ); 27 | 28 | extern "C" 29 | void 30 | __cdecl 31 | free( 32 | __inout void* ptr 33 | ); 34 | 35 | extern "C" 36 | void* 37 | __cdecl 38 | realloc( 39 | __inout_opt void* ptr, 40 | __in size_t size 41 | ); 42 | 43 | extern "C" 44 | void* 45 | __cdecl 46 | calloc( 47 | __in size_t n, 48 | __in size_t size 49 | ); 50 | 51 | 52 | extern "C" 53 | int 54 | __cdecl 55 | vsnprintf( 56 | __in_ecount(count) char *buf, 57 | __in size_t count, 58 | __in const char *fmt, 59 | __in va_list args 60 | ); 61 | 62 | extern "C" 63 | int 64 | __cdecl 65 | printf( 66 | __in const char* fmt, 67 | ... 68 | ); -------------------------------------------------------------------------------- /src/std.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | - very dangerous "implementation" 3 | - for real use, necessary proper handling! 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | namespace std 10 | { 11 | void 12 | __cdecl 13 | _Xbad_alloc() 14 | { 15 | __debugbreak(); 16 | } 17 | 18 | void 19 | __cdecl 20 | _Xlength_error( 21 | __in char const* 22 | ) 23 | { 24 | __debugbreak(); 25 | } 26 | 27 | void 28 | __cdecl 29 | _Xout_of_range( 30 | __in char const* 31 | ) 32 | { 33 | __debugbreak(); 34 | } 35 | 36 | char const* 37 | __cdecl 38 | _Syserror_map( 39 | __in int 40 | ) 41 | { 42 | __debugbreak(); 43 | return nullptr; 44 | } 45 | 46 | char const* 47 | __cdecl 48 | _Winerror_map( 49 | __in int 50 | ) 51 | { 52 | __debugbreak(); 53 | return nullptr; 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /src/typeinfo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //DUMMY 4 | 5 | bool 6 | __cdecl 7 | type_info::operator==( 8 | __in type_info const& 9 | ) const 10 | { 11 | return true; 12 | } 13 | 14 | type_info::~type_info() 15 | { 16 | } 17 | --------------------------------------------------------------------------------