i looked up at the follow up question in SO and i am posting a reply that lets you compile what you asked
I am not sure what purpose this can solve the header you are including vcxxx is a c only header and is to be used only to build crt and not to be used as a public header
(vs2019 x64 190xx sdk vc src)
code compilation disassembly as follows
D:\test\scrt>dir /b
scrt.cpp
D:\test\scrt>type scrt.cpp
#define _VCRT_BUILD
#include <vcstartup_internal.h>
int __CRTDECL main(
_In_ int argc,
_In_reads_(argc) _Pre_z_ char** argv,
_In_z_ char** envp
)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
UNREFERENCED_PARAMETER(envp);
unsigned long long myVar;
__security_init_cookie();
myVar = __scrt_initialize_crt((__scrt_module_type)1);
return 0;
}
compilation on vs2019 x64 19xxxx sdk crt src
D:\test\scrt>cl /Zi /W4 /analyze:autolog- /I d:\vs\VC\Tools\MSVC\14.29.30133\crt\src\vcruntime scrt.cpp /link /release
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30140 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
scrt.cpp
Microsoft (R) Incremental Linker Version 14.29.30140.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:scrt.exe
/debug
/release
scrt.obj
D:\test\scrt>dir /b
scrt.cpp
scrt.exe
scrt.obj
scrt.pdb
vc140.pdb
disassembly
D:\test\scrt>cdb -c "uf scrt!main;q" scrt.exe
Microsoft (R) Windows Debugger Version 10.0.19041.685 AMD64
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0:000> cdb: Reading initial command 'uf scrt!main;q'
scrt!main:
00007ff7`322b1000 4c89442418 mov qword ptr [rsp+18h],r8
00007ff7`322b1005 4889542410 mov qword ptr [rsp+10h],rdx
00007ff7`322b100a 894c2408 mov dword ptr [rsp+8],ecx
00007ff7`322b100e 4883ec38 sub rsp,38h
00007ff7`322b1012 e885000000 call scrt!__security_init_cookie (00007ff7`322b109c)
00007ff7`322b1017 b901000000 mov ecx,1
00007ff7`322b101c e837030000 call scrt!__scrt_initialize_crt (00007ff7`322b1358)
00007ff7`322b1021 0fb6c0 movzx eax,al
00007ff7`322b1024 4889442420 mov qword ptr [rsp+20h],rax
00007ff7`322b1029 33c0 xor eax,eax
00007ff7`322b102b 4883c438 add rsp,38h
00007ff7`322b102f c3 ret
quit:
__security_init_cookie()
and the__scrt_initialize_crt()
instructions. The former seems to just insure functions have no side effects on the stack, and the latter just check if the instructions are called from a.dll
file or a.exe
executable.