Leaked source code of windows server 2003
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.

104 lines
2.0 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. int __cdecl main(int, char **, char **);
  4. typedef void (__cdecl *_PVFV)(void);
  5. #pragma data_seg(".CRT$XIA")
  6. _PVFV __xi_a[] = { NULL };
  7. #pragma data_seg(".CRT$XIZ")
  8. _PVFV __xi_z[] = { NULL };
  9. #pragma data_seg(".CRT$XCA")
  10. _PVFV __xc_a[] = { NULL };
  11. #pragma data_seg(".CRT$XCZ")
  12. _PVFV __xc_z[] = { NULL };
  13. #pragma data_seg(".CRT$XPA")
  14. _PVFV __xp_a[] = { NULL };
  15. #pragma data_seg(".CRT$XPZ")
  16. _PVFV __xp_z[] = { NULL };
  17. #pragma data_seg(".CRT$XTA")
  18. _PVFV __xt_a[] = { NULL };
  19. #pragma data_seg(".CRT$XTZ")
  20. _PVFV __xt_z[] = { NULL };
  21. #if defined(_IA64_)
  22. #pragma comment(linker, "/merge:.CRT=.srdata")
  23. #else
  24. #pragma comment(linker, "/merge:.CRT=.rdata")
  25. #endif
  26. #pragma data_seg() /* reset */
  27. _PVFV *__onexitbegin;
  28. _PVFV *__onexitend;
  29. static void
  30. _initterm (
  31. _PVFV * pfbegin,
  32. _PVFV * pfend
  33. )
  34. {
  35. /*
  36. * walk the table of function pointers from the bottom up, until
  37. * the end is encountered. Do not skip the first entry. The initial
  38. * value of pfbegin points to the first valid entry. Do not try to
  39. * execute what pfend points to. Only entries before pfend are valid.
  40. */
  41. while ( pfbegin < pfend ) {
  42. /*
  43. * if current table entry is non-NULL, call thru it.
  44. */
  45. if ( *pfbegin != NULL )
  46. (**pfbegin)();
  47. ++pfbegin;
  48. }
  49. }
  50. void
  51. mainNoCRTStartup(
  52. void
  53. )
  54. {
  55. __try {
  56. // do C initializations
  57. _initterm( __xi_a, __xi_z );
  58. // do C++ initializations
  59. _initterm( __xc_a, __xc_z );
  60. main(1, 0, 0);
  61. } __except ( EXCEPTION_EXECUTE_HANDLER ) {
  62. }
  63. __try {
  64. // Do C++ terminators
  65. _initterm(__onexitbegin, __onexitend);
  66. // do pre-terminators
  67. _initterm(__xp_a, __xp_z);
  68. // do C terminiators
  69. _initterm(__xt_a, __xt_z);
  70. } __except(EXCEPTION_EXECUTE_HANDLER) {
  71. }
  72. }