Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

797 lines
24 KiB

  1. /***
  2. *crtlib.c - CRT DLL initialization and termination routine (Win32, Dosx32)
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This module contains initialization entry point for the CRT DLL
  8. * in the Win32 environment. It also contains some of the supporting
  9. * initialization and termination code.
  10. *
  11. *Revision History:
  12. * 08-12-91 GJF Module created. Sort of.
  13. * 01-17-92 GJF Return exception code value for RTEs corresponding
  14. * to exceptions.
  15. * 01-29-92 GJF Support for wildcard expansion in filenames on the
  16. * command line.
  17. * 02-14-92 GJF Moved file inheritance stuff to ioinit.c. Call to
  18. * inherit() is replace by call to _ioinit().
  19. * 08-26-92 SKS Add _osver, _winver, _winmajor, _winminor
  20. * 09-04-92 GJF Replaced _CALLTYPE3 with WINAPI.
  21. * 09-30-92 SRW Call _heap_init before _mtinit
  22. * 10-19-92 SKS Add "dowildcard" parameter to GetMainArgs()
  23. * Prepend a second "_" to name since it is internal-only
  24. * 03-20-93 SKS Remove obsolete variables _osmode, _cpumode, etc.
  25. * 04-06-93 SKS Replace _CRTAPI* with _cdecl
  26. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  27. * Change __GetMainArgs to __getmainargs
  28. * 04-13-93 SKS Change call to _mtdeletelocks to new routine _mtterm
  29. * 04-26-93 SKS Change _CRTDLL_INIT to fail loading on failure to
  30. * initialize/clean up, rather than calling _amsg_exit().
  31. * 04-27-93 GJF Removed support for _RT_STACK, _RT_INTDIV,
  32. * _RT_INVALDISP and _RT_NONCONT.
  33. * 05-06-93 SKS Add call to _heap_term to free up all allocated memory
  34. * *and* address space. This must be the last thing done.
  35. * 06-03-93 GJF Added __proc_attached flag.
  36. * 06-07-93 GJF Incorporated SteveWo's code to call LoadLibrary, from
  37. * crtdll.c.
  38. * 11-05-93 CFW Undefine GetEnviromentStrings.
  39. * 11-09-93 GJF Added call to __initmbctable (must happen before
  40. * environment strings are processed).
  41. * 11-09-93 GJF Merged with NT SDK version (primarily the change of
  42. * 06-07-93 noted above). Also, replace MTHREAD with
  43. * _MT.
  44. * 11-23-93 CFW GetEnviromentStrings undef moved to internal.h.
  45. * 11-23-93 CFW Wide char enable.
  46. * 11-29-93 CFW Wide environment.
  47. * 12-02-93 CFW Remove WPRFLAG dependencies since only one version.
  48. * 12-13-93 SKS Free up per-thread CRT data on DLL_THREAD_DETACH
  49. * with a call to _freeptd() in _CRT_INIT()
  50. * 01-11-94 GJF Use __GetMainArgs name when building libs for NT SDK.
  51. * 02-07-94 CFW POSIXify.
  52. * 03-04-94 SKS Add _newmode parameter to _*getmainargs (except NTSDK)
  53. * 03-31-94 CFW Use __crtGetEnvironmentStrings.
  54. * 04-08-93 CFW Move __crtXXX calls past initialization.
  55. * 04-28-94 GJF Major changes for Win32S support! Added
  56. * AllocPerProcessDataStuct() to allocate and initialize
  57. * the per-process data structure needed in the Win32s
  58. * version of msvcrt*.dll. Also, added a function to
  59. * free and access functions for all read-write global
  60. * variables which might be used by a Win32s app.
  61. * 05-04-94 GJF Made access functions conditional on _M_IX86, added
  62. * some comments to function headers, and fixed a
  63. * possible bug in AllocPerProcessDataStruct (the return
  64. * value for success was NOT explicitly set to something
  65. * nonzero).
  66. * 05-10-94 GJF Added version check so that Win32 version (Win32s)
  67. * will not load on Win32s (resp., Win32).
  68. * 09-06-94 CFW Remove _INTL switch.
  69. * 09-06-94 CFW Remove _MBCS_OS switch.
  70. * 09-06-94 GJF Added __error_mode and __app_type.
  71. * 09-15-94 SKS Clean up comments to avoid source release problems
  72. * 09-21-94 SKS Fix typo: no leading _ on "DLL_FOR_WIN32S"
  73. * 10-04-94 CFW Removed #ifdef _KANJI
  74. * 10-04-94 BWT Fix _NTSDK build
  75. * 11-22-94 CFW Must create wide environment if none.
  76. * 12-19-94 GJF Changed "MSVCRT20" to "MSVCRT30". Also, put testing for
  77. * Win32S under #ifdef _M_IX86. Both changes from Richard
  78. * Shupak.
  79. * 01-16-95 CFW Set default debug output for console.
  80. * 02-13-95 GJF Added initialization for the new _ppd_tzstd and
  81. * _ppd_tzdst fields, thereby fixing the definition of
  82. * _ppd__tzname.
  83. * 02-15-95 CFW Make all CRT message boxes look alike.
  84. * 02-24-95 CFW Use __crtMessageBoxA.
  85. * 02-27-95 CFW Change __crtMessageBoxA params.
  86. * 03-08-95 GJF Added initialization for _ppd__nstream. Removed
  87. * _ppd_lastiob.
  88. * 02-24-95 CFW Call _CrtDumpMemoryLeaks.
  89. * 04-06-95 CFW Use __crtGetEnvironmentStringsA.
  90. * 04-17-95 SKS Free TLS index ppdindex when it is no longer needed
  91. * 04-26-95 GJF Added support for winheap in DLL_FOR_WIN32S build.
  92. * 05-02-95 GJF No _ppd__heap_maxregsize, _ppd__heap_regionsize or
  93. * _ppd__heap_resetsize for WINHEAP.
  94. * 05-24-95 CFW Official ANSI C++ new handler added.
  95. * 06-13-95 CFW De-install client dump hook as client EXE/DLL is gone.
  96. * 06-14-95 GJF Changes for new lowio scheme (__pioinof[]) - no more
  97. * per-process data initialization needed (Win32s) and
  98. * added a call to _ioterm().
  99. * 07-04-95 GJF Interface to __crtGetEnvironmentStrings and _setenvp
  100. * changes slightly.
  101. * 06-27-95 CFW Add win32s support for debug libs.
  102. * 07-03-95 CFW Changed offset of _lc_handle[LC_CTYPE], added sanity
  103. * check to crtlib.c to catch changes to win32s.h that
  104. * modify offset.
  105. * 07-07-95 CFW Simplify default report mode scheme.
  106. * 07-25-95 CFW Add win32s support for user visible debug heap vars.
  107. * 08-21-95 SKS (_ppd_)_CrtDbgMode needs to be initialized for Win32s
  108. * 08-31-95 GJF Added _dstbias.
  109. * 11-09-95 GJF Changed "ISTNT" to "IsTNT".
  110. * 03-18-96 SKS Add _fileinfo to variables implemented as functions.
  111. * 04-22-96 GJF Check for failure of heap initialization.
  112. * 05-14-96 GJF Changed where __proc_attached is set so that it
  113. * denotes successful completion of initialization.
  114. * 06-11-96 JWM Changed string "MSVCRT40" to "MSVCRT" in _CRTDLL_INIT().
  115. * 06-27-96 GJF Purged Win32s support. Note, the access functions must
  116. * be retained for backwards compatibility.
  117. * 06-28-96 SKS Remove obsolete local variable "hmod".
  118. * 03-17-97 RDK Add reference to _mbcasemap.
  119. * 07-24-97 GJF heap_init changed slightly to support option to use
  120. * heap running directly on Win32 API.
  121. * 08-08-97 GJF Rearranged #ifdef-s so ptd is only defined when it is
  122. * used (under ANSI_NEW_HANDLER).
  123. * 10-02-98 GJF Use GetVersionEx instead of GetVersion and store OS ID
  124. * in _osplatform.
  125. * 04-30-99 GJF Don't clean up system resources if the whole process
  126. * if terminating.
  127. * 09-02-99 PML Put Win32s check in system CRT only.
  128. * 02-02-00 GB Added ATTACH_THREAD support for _CRT_INIT where we
  129. * initialise per thread data so that in case where we
  130. * are short of memory, we don't have to kill the whole
  131. * process for inavailablity of space.
  132. * 08-22-00 GB Fixed potentia leak of ptd in CRT_INIT
  133. * 09-06-00 GB Changed the function definations of _pctype and
  134. * _pwctype to const
  135. * 03-16-01 PML _alloca the OSVERSIONINFO so /GS can work (vs7#224261)
  136. * 03-19-01 BWT Add test to preclude msvcrt.dll loading on anything other
  137. * than the OS it ships with.
  138. * 03-26-01 PML Use GetVersionExA, not GetVersionEx (vs7#230286)
  139. * 03-27-01 PML Fail DLL load instead of calling _amsg_exit, and
  140. * propogate error on EXE arg parsing up (vs7#231220).
  141. * 03-28-01 PML Protect against GetModuleFileName overflow (vs7#231284)
  142. * 04-05-01 PML Clean up on DLL unload due to FreeLibrary, or on
  143. * termination by ExitProcess instead of exit (vs7#235781)
  144. * 04-30-01 BWT Remove _NTSDK and just return false if the OS doesn't match
  145. *
  146. *******************************************************************************/
  147. #if defined(CRTDLL)
  148. #include <cruntime.h>
  149. #include <oscalls.h>
  150. #include <dos.h>
  151. #include <internal.h>
  152. #include <malloc.h>
  153. #include <mbctype.h>
  154. #include <mtdll.h>
  155. #include <process.h>
  156. #include <rterr.h>
  157. #include <stdio.h>
  158. #include <stdlib.h>
  159. #include <string.h>
  160. #include <awint.h>
  161. #include <tchar.h>
  162. #include <time.h>
  163. #include <dbgint.h>
  164. #ifdef _SYSCRT
  165. #include <ntverp.h>
  166. #endif
  167. /*
  168. * flag set iff _CRTDLL_INIT was called with DLL_PROCESS_ATTACH
  169. */
  170. static int proc_attached = 0;
  171. /*
  172. * command line, environment, and a few other globals
  173. */
  174. wchar_t *_wcmdln = NULL; /* points to wide command line */
  175. char *_acmdln = NULL; /* points to command line */
  176. char *_aenvptr = NULL; /* points to environment block */
  177. #ifndef _POSIX_
  178. wchar_t *_wenvptr = NULL; /* points to wide environment block */
  179. #endif /* _POSIX_ */
  180. void (__cdecl * _aexit_rtn)(int) = _exit; /* RT message return procedure */
  181. extern int _newmode; /* declared in <internal.h> */
  182. int __error_mode = _OUT_TO_DEFAULT;
  183. int __app_type = _UNKNOWN_APP;
  184. static void __cdecl inherit(void); /* local function */
  185. /***
  186. *int __[w]getmainargs - get values for args to main()
  187. *
  188. *Purpose:
  189. * This function invokes the command line parsing and copies the args
  190. * to main back through the passsed pointers. The reason for doing
  191. * this here, rather than having _CRTDLL_INIT do the work and exporting
  192. * the __argc and __argv, is to support the linked-in option to have
  193. * wildcard characters in filename arguments expanded.
  194. *
  195. *Entry:
  196. * int *pargc - pointer to argc
  197. * _TCHAR ***pargv - pointer to argv
  198. * _TCHAR ***penvp - pointer to envp
  199. * int dowildcard - flag (true means expand wildcards in cmd line)
  200. * _startupinfo * startinfo- other info to be passed to CRT DLL
  201. *
  202. *Exit:
  203. * Returns 0 on success, negative if _*setargv returns an error. Values
  204. * for the arguments to main() are copied through the passed pointers.
  205. *
  206. *******************************************************************************/
  207. #if !defined(_POSIX_)
  208. _CRTIMP int __cdecl __wgetmainargs (
  209. int *pargc,
  210. wchar_t ***pargv,
  211. wchar_t ***penvp,
  212. int dowildcard,
  213. _startupinfo * startinfo)
  214. {
  215. int ret;
  216. #ifdef ANSI_NEW_HANDLER
  217. #ifdef _MT
  218. /* set per-thread new handler for main thread */
  219. _ptiddata ptd = _getptd();
  220. ptd->_newh = startinfo->newh;
  221. #endif
  222. /* set global default per-thread new handler */
  223. _defnewh = startinfo->newh;
  224. #endif /* ANSI_NEW_HANDLER */
  225. /* set global new mode flag */
  226. _newmode = startinfo->newmode;
  227. if ( dowildcard )
  228. ret = __wsetargv(); /* do wildcard expansion after parsing args */
  229. else
  230. ret = _wsetargv(); /* NO wildcard expansion; just parse args */
  231. if (ret < 0)
  232. return ret;
  233. *pargc = __argc;
  234. *pargv = __wargv;
  235. /*
  236. * if wide environment does not already exist,
  237. * create it from multibyte environment
  238. */
  239. if (!_wenviron)
  240. __mbtow_environ();
  241. *penvp = _wenviron;
  242. return ret;
  243. }
  244. #endif /* !defined(_POSIX_) */
  245. _CRTIMP int __cdecl __getmainargs (
  246. int *pargc,
  247. char ***pargv,
  248. char ***penvp,
  249. int dowildcard
  250. ,
  251. _startupinfo * startinfo
  252. )
  253. {
  254. int ret;
  255. #ifdef ANSI_NEW_HANDLER
  256. #ifdef _MT
  257. /* set per-thread new handler for main thread */
  258. _ptiddata ptd = _getptd();
  259. ptd->_newh = startinfo->newh;
  260. #endif
  261. /* set global default per-thread new handler */
  262. _defnewh = startinfo->newh;
  263. #endif /* ANSI_NEW_HANDLER */
  264. /* set global new mode flag */
  265. _newmode = startinfo->newmode;
  266. if ( dowildcard )
  267. ret = __setargv(); /* do wildcard expansion after parsing args */
  268. else
  269. ret = _setargv(); /* NO wildcard expansion; just parse args */
  270. if (ret < 0)
  271. return ret;
  272. *pargc = __argc;
  273. *pargv = __argv;
  274. *penvp = _environ;
  275. return ret;
  276. }
  277. /***
  278. *BOOL _CRTDLL_INIT(hDllHandle, dwReason, lpreserved) - C DLL initialization.
  279. *
  280. *Purpose:
  281. * This routine does the C runtime initialization.
  282. *
  283. *Entry:
  284. *
  285. *Exit:
  286. *
  287. *******************************************************************************/
  288. BOOL WINAPI _CRTDLL_INIT(
  289. HANDLE hDllHandle,
  290. DWORD dwReason,
  291. LPVOID lpreserved
  292. )
  293. {
  294. if ( dwReason == DLL_PROCESS_ATTACH ) {
  295. OSVERSIONINFOA *posvi;
  296. #if defined(_SYSCRT)
  297. void __declspec(dllimport) __stdcall RtlGetNtVersionNumbers(PDWORD, PDWORD, PDWORD);
  298. // The app may have set Win32VersionValue in the PE header to change
  299. // GetVersionEx. Ask NTDLL for the real version and bail if we don't match.
  300. DWORD NtMajorVersion;
  301. DWORD NtMinorVersion;
  302. RtlGetNtVersionNumbers(&NtMajorVersion, &NtMinorVersion, NULL);
  303. if ((NtMajorVersion != VER_PRODUCTMAJORVERSION) || (NtMinorVersion != VER_PRODUCTMINORVERSION))
  304. return FALSE;
  305. #endif /* _SYSCRT */
  306. /*
  307. * Dynamically allocate the OSVERSIONINFOA buffer, so we avoid
  308. * triggering the /GS buffer overrun detection. That can't be
  309. * used here, since the guard cookie isn't available until we
  310. * initialize it from here!
  311. */
  312. posvi = (OSVERSIONINFOA *)_alloca(sizeof(OSVERSIONINFOA));
  313. /*
  314. * Get the full Win32 version.
  315. */
  316. posvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
  317. if ( !GetVersionExA(posvi) )
  318. return FALSE;
  319. _osplatform = posvi->dwPlatformId;
  320. _winmajor = posvi->dwMajorVersion;
  321. _winminor = posvi->dwMinorVersion;
  322. /*
  323. * The somewhat bizarre calculations of _osver and _winver are
  324. * required for backward compatibility (used to use GetVersion)
  325. */
  326. _osver = (posvi->dwBuildNumber) & 0x07fff;
  327. if ( _osplatform != VER_PLATFORM_WIN32_NT )
  328. _osver |= 0x08000;
  329. _winver = (_winmajor << 8) + _winminor;
  330. #ifdef _MT
  331. if ( !_heap_init(1) ) /* initialize heap */
  332. #else
  333. if ( !_heap_init(0) ) /* initialize heap */
  334. #endif
  335. /*
  336. * The heap cannot be initialized, return failure to the
  337. * loader.
  338. */
  339. return FALSE;
  340. #ifdef _MT
  341. if(!_mtinit()) /* initialize multi-thread */
  342. {
  343. /*
  344. * If the DLL load is going to fail, we must clean up
  345. * all resources that have already been allocated.
  346. */
  347. _heap_term(); /* heap is now invalid! */
  348. return FALSE; /* fail DLL load on failure */
  349. }
  350. #endif /* _MT */
  351. if (_ioinit() < 0) { /* inherit file info */
  352. /* Clean up already-allocated resources */
  353. #ifdef _MT
  354. /* free TLS index, call _mtdeletelocks() */
  355. _mtterm();
  356. #endif /* _MT */
  357. _heap_term(); /* heap is now invalid! */
  358. return FALSE; /* fail DLL load on failure */
  359. }
  360. _aenvptr = (char *)__crtGetEnvironmentStringsA();
  361. _acmdln = (char *)GetCommandLineA();
  362. #ifndef _POSIX_
  363. _wcmdln = (wchar_t *)__crtGetCommandLineW();
  364. #endif /* _POSIX_ */
  365. #ifdef _MBCS
  366. /*
  367. * Initialize multibyte ctype table. Always done since it is
  368. * needed for processing the environment strings.
  369. */
  370. __initmbctable();
  371. #endif
  372. /*
  373. * For CRT DLL, since we don't know the type (wide or multibyte)
  374. * of the program, we create only the multibyte type since that
  375. * is by far the most likely case. Wide environment will be created
  376. * on demand as usual.
  377. */
  378. if (_setenvp() < 0 || /* get environ info */
  379. _cinit() != 0) /* do C data initialize */
  380. {
  381. _ioterm(); /* shut down lowio */
  382. #ifdef _MT
  383. _mtterm(); /* free TLS index, call _mtdeletelocks() */
  384. #endif /* _MT */
  385. _heap_term(); /* heap is now invalid! */
  386. return FALSE; /* fail DLL load on failure */
  387. }
  388. /*
  389. * Increment flag indicating process attach notification
  390. * has been received.
  391. */
  392. proc_attached++;
  393. }
  394. else if ( dwReason == DLL_PROCESS_DETACH ) {
  395. /*
  396. * if a client process is detaching, make sure minimal
  397. * runtime termination is performed and clean up our
  398. * 'locks' (i.e., delete critical sections).
  399. */
  400. if ( proc_attached > 0 ) {
  401. proc_attached--;
  402. /*
  403. * Any basic clean-up done here may also need
  404. * to be done below if Process Attach is partly
  405. * processed and then a failure is encountered.
  406. */
  407. if ( _C_Termination_Done == FALSE )
  408. _cexit();
  409. #ifdef _DEBUG
  410. /* Dump all memory leaks */
  411. if (_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & _CRTDBG_LEAK_CHECK_DF)
  412. {
  413. _CrtSetDumpClient(NULL);
  414. _CrtDumpMemoryLeaks();
  415. }
  416. #endif
  417. /*
  418. * What remains is to clean up the system resources we have
  419. * used (handles, critical sections, memory,...,etc.). This
  420. * needs to be done if the whole process is NOT terminating.
  421. */
  422. if ( lpreserved == NULL )
  423. {
  424. /*
  425. * The process is NOT terminating so we must clean up...
  426. */
  427. _ioterm();
  428. #ifdef _MT
  429. /* free TLS index, call _mtdeletelocks() */
  430. _mtterm();
  431. #endif /* _MT */
  432. /* This should be the last thing the C run-time does */
  433. _heap_term(); /* heap is now invalid! */
  434. }
  435. }
  436. else
  437. /* no prior process attach, just return */
  438. return FALSE;
  439. }
  440. #ifdef _MT
  441. else if ( dwReason == DLL_THREAD_ATTACH )
  442. {
  443. _ptiddata ptd;
  444. if ( ((ptd = _calloc_crt(1, sizeof(struct _tiddata))) != NULL))
  445. {
  446. if (TlsSetValue(__tlsindex, (LPVOID)ptd) ) {
  447. /*
  448. * Initialize of per-thread data
  449. */
  450. _initptd(ptd);
  451. ptd->_tid = GetCurrentThreadId();
  452. ptd->_thandle = (uintptr_t)(-1);
  453. } else
  454. {
  455. _free_crt(ptd);
  456. return FALSE;
  457. }
  458. } else
  459. {
  460. return FALSE;
  461. }
  462. }
  463. else if ( dwReason == DLL_THREAD_DETACH )
  464. {
  465. _freeptd(NULL); /* free up per-thread CRT data */
  466. }
  467. #endif /* _MT */
  468. return TRUE;
  469. }
  470. /***
  471. *_amsg_exit(rterrnum) - Fast exit fatal errors
  472. *
  473. *Purpose:
  474. * Exit the program with error code of 255 and appropriate error
  475. * message.
  476. *
  477. *Entry:
  478. * int rterrnum - error message number (amsg_exit only).
  479. *
  480. *Exit:
  481. * Calls exit() (for integer divide-by-0) or _exit() indirectly
  482. * through _aexit_rtn [amsg_exit].
  483. * For multi-thread: calls _exit() function
  484. *
  485. *Exceptions:
  486. *
  487. *******************************************************************************/
  488. void __cdecl _amsg_exit (
  489. int rterrnum
  490. )
  491. {
  492. if ( (__error_mode == _OUT_TO_STDERR) || ((__error_mode ==
  493. _OUT_TO_DEFAULT) && (__app_type == _CONSOLE_APP)) )
  494. _FF_MSGBANNER(); /* write run-time error banner */
  495. _NMSG_WRITE(rterrnum); /* write message */
  496. _aexit_rtn(255); /* normally _exit(255) */
  497. }
  498. #if defined(_M_IX86 )
  499. /*
  500. * Functions to access user-visible, per-process variables
  501. */
  502. /*
  503. * Macro to construct the name of the access function from the variable
  504. * name.
  505. */
  506. #define AFNAME(var) __p_ ## var
  507. /*
  508. * Macro to construct the access function's return value from the variable
  509. * name.
  510. */
  511. #define AFRET(var) &var
  512. /*
  513. ***
  514. *** Template
  515. ***
  516. _CRTIMP __cdecl
  517. AFNAME() (void)
  518. {
  519. return AFRET();
  520. }
  521. ***
  522. ***
  523. ***
  524. */
  525. #ifdef _DEBUG
  526. _CRTIMP long *
  527. AFNAME(_crtAssertBusy) (void)
  528. {
  529. return AFRET(_crtAssertBusy);
  530. }
  531. _CRTIMP long *
  532. AFNAME(_crtBreakAlloc) (void)
  533. {
  534. return AFRET(_crtBreakAlloc);
  535. }
  536. _CRTIMP int *
  537. AFNAME(_crtDbgFlag) (void)
  538. {
  539. return AFRET(_crtDbgFlag);
  540. }
  541. #endif /* _DEBUG */
  542. _CRTIMP char ** __cdecl
  543. AFNAME(_acmdln) (void)
  544. {
  545. return AFRET(_acmdln);
  546. }
  547. _CRTIMP wchar_t ** __cdecl
  548. AFNAME(_wcmdln) (void)
  549. {
  550. return AFRET(_wcmdln);
  551. }
  552. _CRTIMP unsigned int * __cdecl
  553. AFNAME(_amblksiz) (void)
  554. {
  555. return AFRET(_amblksiz);
  556. }
  557. _CRTIMP int * __cdecl
  558. AFNAME(__argc) (void)
  559. {
  560. return AFRET(__argc);
  561. }
  562. _CRTIMP char *** __cdecl
  563. AFNAME(__argv) (void)
  564. {
  565. return AFRET(__argv);
  566. }
  567. _CRTIMP wchar_t *** __cdecl
  568. AFNAME(__wargv) (void)
  569. {
  570. return AFRET(__wargv);
  571. }
  572. _CRTIMP int * __cdecl
  573. AFNAME(_commode) (void)
  574. {
  575. return AFRET(_commode);
  576. }
  577. _CRTIMP int * __cdecl
  578. AFNAME(_daylight) (void)
  579. {
  580. return AFRET(_daylight);
  581. }
  582. _CRTIMP long * __cdecl
  583. AFNAME(_dstbias) (void)
  584. {
  585. return AFRET(_dstbias);
  586. }
  587. _CRTIMP char *** __cdecl
  588. AFNAME(_environ) (void)
  589. {
  590. return AFRET(_environ);
  591. }
  592. _CRTIMP wchar_t *** __cdecl
  593. AFNAME(_wenviron) (void)
  594. {
  595. return AFRET(_wenviron);
  596. }
  597. _CRTIMP int * __cdecl
  598. AFNAME(_fmode) (void)
  599. {
  600. return AFRET(_fmode);
  601. }
  602. _CRTIMP int * __cdecl
  603. AFNAME(_fileinfo) (void)
  604. {
  605. return AFRET(_fileinfo);
  606. }
  607. _CRTIMP char *** __cdecl
  608. AFNAME(__initenv) (void)
  609. {
  610. return AFRET(__initenv);
  611. }
  612. _CRTIMP wchar_t *** __cdecl
  613. AFNAME(__winitenv) (void)
  614. {
  615. return AFRET(__winitenv);
  616. }
  617. _CRTIMP FILE *
  618. AFNAME(_iob) (void)
  619. {
  620. return &_iob[0];
  621. }
  622. _CRTIMP unsigned char * __cdecl
  623. AFNAME(_mbctype) (void)
  624. {
  625. return &_mbctype[0];
  626. }
  627. _CRTIMP unsigned char * __cdecl
  628. AFNAME(_mbcasemap) (void)
  629. {
  630. return &_mbcasemap[0];
  631. }
  632. _CRTIMP int * __cdecl
  633. AFNAME(__mb_cur_max) (void)
  634. {
  635. return AFRET(__mb_cur_max);
  636. }
  637. _CRTIMP unsigned int * __cdecl
  638. AFNAME(_osver) (void)
  639. {
  640. return AFRET(_osver);
  641. }
  642. _CRTIMP const unsigned short ** __cdecl
  643. AFNAME(_pctype) (void)
  644. {
  645. return AFRET(_pctype);
  646. }
  647. _CRTIMP const unsigned short ** __cdecl
  648. AFNAME(_pwctype) (void)
  649. {
  650. return AFRET(_pwctype);
  651. }
  652. _CRTIMP char ** __cdecl
  653. AFNAME(_pgmptr) (void)
  654. {
  655. return AFRET(_pgmptr);
  656. }
  657. _CRTIMP wchar_t ** __cdecl
  658. AFNAME(_wpgmptr) (void)
  659. {
  660. return AFRET(_wpgmptr);
  661. }
  662. _CRTIMP long * __cdecl
  663. AFNAME(_timezone) (void)
  664. {
  665. return AFRET(_timezone);
  666. }
  667. _CRTIMP char ** __cdecl
  668. AFNAME(_tzname) (void)
  669. {
  670. return &_tzname[0];
  671. }
  672. _CRTIMP unsigned int * __cdecl
  673. AFNAME(_winmajor) (void)
  674. {
  675. return AFRET(_winmajor);
  676. }
  677. _CRTIMP unsigned int * __cdecl
  678. AFNAME(_winminor) (void)
  679. {
  680. return AFRET(_winminor);
  681. }
  682. _CRTIMP unsigned int * __cdecl
  683. AFNAME(_winver) (void)
  684. {
  685. return AFRET(_winver);
  686. }
  687. #endif /* _M_IX86 */
  688. #endif /* CRTDLL */