您的位置:程序门 -> c/c++ -> c++ 语言



有谁知道_crtmainstartup源码是什么样子的?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


有谁知道_crtmainstartup源码是什么样子的?[已结贴,结贴人:iwillalwaysloveyou]
发表于:2007-04-25 13:38:06 楼主
除了内存申请函数之外,_crtmainstartup还可能调用哪些windows的api?
发表于:2007-04-25 13:39:241楼 得分:1
不如说说为啥想问这个问题吧。
发表于:2007-04-25 13:40:122楼 得分:0
除了初始化全局或静态对象之外,还干什么?
发表于:2007-04-25 13:41:463楼 得分:5
$(vc)/crt/src/crt0.c   这东西自己找三   ...
发表于:2007-04-25 13:42:104楼 得分:0
我想把一个vc6编译的程序直接用被改造的bochs虚拟机执行,不使用操作系统
发表于:2007-04-25 13:43:165楼 得分:10
int   wmaincrtstartup(
#else     /*   wprflag   */
int   maincrtstartup(
#endif     /*   wprflag   */

#endif     /*   _winmain_   */

                void
                )

{
                int   initret;
                int   mainret;
                osversioninfoa   *posvi;
                int   managedapp;
#ifdef   _winmain_
                _tuchar   *lpszcommandline;
                startupinfo   startupinfo;
#endif     /*   _winmain_   */
                /*
                  *   dynamically   allocate   the   osversioninfoa   buffer,   so   we   avoid
                  *   triggering   the   /gs   buffer   overrun   detection.     that   can 't   be
                  *   used   here,   since   the   guard   cookie   isn 't   available   until   we
                  *   initialize   it   from   here!
                  */
                posvi   =   (osversioninfoa   *)_alloca(sizeof(osversioninfoa));

                /*
                  *   get   the   full   win32   version
                  */
                posvi-> dwosversioninfosize   =   sizeof(osversioninfoa);
                (void)getversionexa(posvi);

                _osplatform   =   posvi-> dwplatformid;
                _winmajor   =   posvi-> dwmajorversion;
                _winminor   =   posvi-> dwminorversion;

                /*
                  *   the   somewhat   bizarre   calculations   of   _osver   and   _winver   are
                  *   required   for   backward   compatibility   (used   to   use   getversion)
                  */
                _osver   =   (posvi-> dwbuildnumber)   &   0x07fff;
                if   (   _osplatform   !=   ver_platform_win32_nt   )
                        _osver   ¦=   0x08000;
                _winver   =   (_winmajor   < <   8)   +   _winminor;

                /*
                  *   determine   if   this   is   a   managed   application
                  */
                managedapp   =   check_managed_app();

#ifdef   _mt
                if   (   !_heap_init(1)   )                               /*   initialize   heap   */
#else     /*   _mt   */
                if   (   !_heap_init(0)   )                               /*   initialize   heap   */
#endif     /*   _mt   */
                        fast_error_exit(_rt_heapinit);     /*   write   message   and   die   */

#ifdef   _mt
                if(   !_mtinit()   )                                         /*   initialize   multi-thread   */
                        fast_error_exit(_rt_thread);         /*   write   message   and   die   */
#endif     /*   _mt   */

                /*
                  *   initialize   the   runtime   checks   stuff
                  */
#ifdef   _rtc
                _rtc_initialize();
#endif     /*   _rtc   */
                /*
                  *   guard   the   remainder   of   the   initialization   code   and   the   call
                  *   to   user 's   main,   or   winmain,   function   in   a   __try/__except
                  *   statement.
                  */

                __try   {

                        if   (   _ioinit()   <   0   )                         /*   initialize   lowio   */
                                _amsg_exit(_rt_lowioinit);

#ifdef   wprflag
                        /*   get   wide   cmd   line   info   */
                        _wcmdln   =   (wchar_t   *)__crtgetcommandlinew();

                        /*   get   wide   environ   info   */
                        _wenvptr   =   (wchar_t   *)__crtgetenvironmentstringsw();

                        if   (   _wsetargv()   <   0   )
                                _amsg_exit(_rt_spacearg);
                        if   (   _wsetenvp()   <   0   )
                                _amsg_exit(_rt_spaceenv);
#else     /*   wprflag   */
                        /*   get   cmd   line   info   */
                        _acmdln   =   (char   *)getcommandlinea();

                        /*   get   environ   info   */
                        _aenvptr   =   (char   *)__crtgetenvironmentstringsa();

                        if   (   _setargv()   <   0   )
                                _amsg_exit(_rt_spacearg);
                        if   (   _setenvp()   <   0   )
                                _amsg_exit(_rt_spaceenv);
#endif     /*   wprflag   */

                        initret   =   _cinit(true);                                     /*   do   c   data   initialize   */
                        if   (initret   !=   0)
                                _amsg_exit(initret);

#ifdef   _winmain_

                        startupinfo.dwflags   =   0;
                        getstartupinfo(   &startupinfo   );

#ifdef   wprflag
                        lpszcommandline   =   _wwincmdln();
                        mainret   =   wwinmain(
#else     /*   wprflag   */
                        lpszcommandline   =   _wincmdln();
                        mainret   =   winmain(
#endif     /*   wprflag   */
                                                              getmodulehandlea(null),
                                                              null,
                                                              lpszcommandline,
                                                              startupinfo.dwflags   &   startf_useshowwindow
                                                                        ?   startupinfo.wshowwindow
                                                                        :   sw_showdefault
                                                          );
#else     /*   _winmain_   */

#ifdef   wprflag
                        __winitenv   =   _wenviron;
                        mainret   =   wmain(__argc,   __wargv,   _wenviron);
#else     /*   wprflag   */
                        __initenv   =   _environ;
                        mainret   =   main(__argc,   __argv,   _environ);
#endif     /*   wprflag   */

#endif     /*   _winmain_   */

                        if   (   !managedapp   )
                                exit(mainret);

                        _cexit();

                }
                __except   (   _xcptfilter(getexceptioncode(),   getexceptioninformation())   )
                {
                        /*
                          *   should   never   reach   here
                          */

                        mainret   =   getexceptioncode();

                        if   (   !managedapp   )
                                _exit(mainret);

                        _c_exit();

                }   /*   end   of   try   -   except   */

                return   mainret;
}
vc里直接跟踪一下就出来了
发表于:2007-04-25 13:44:296楼 得分:0
在vc6.0安装目录下搜crt0.c,找不到
发表于:2007-04-25 13:46:437楼 得分:2
你首先要确认下有没有安装源码,   找不大才怪   ...
发表于:2007-04-25 14:09:548楼 得分:2
vc如果选择安装源码的话是可以在源码目录找到的


快速检索

最新资讯
热门点击