Subversion Repositories Kolibri OS

Rev

Rev 576 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "crt.h"
  2.  
  3. #define atexitBufferSize        32
  4.  
  5. #ifdef AUTOBUILD
  6. char kosExePath[1024];
  7. char exeStack[16384];
  8. char params[1024];
  9. // must be alphabetically first in the image
  10. #pragma data_seg(".1seg")
  11. struct
  12. {
  13.         char header[8];
  14.         int headerver;
  15.         void* entry;
  16.         void* i_end;
  17.         void* memsize;
  18.         void* stack;
  19.         void* params;
  20.         void* icon;
  21. } __MENUET_APP_header = {
  22.         {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'},
  23.         1,
  24.         &crtStartUp,
  25.         0,      // filled by doexe2.asm
  26.         0,      // filled by doexe2.asm
  27.         exeStack + sizeof(exeStack),
  28.         params,
  29.         kosExePath
  30. };
  31. #pragma data_seg()
  32. #endif
  33.  
  34. char pureCallMessage[] = "PURE function call!";
  35.  
  36. //char *__argv[2];
  37. //int __argc;
  38.  
  39. void (__cdecl *atExitList[atexitBufferSize])();
  40. int atExitFnNum = 0;
  41. int main(int argc, char *argv[]);
  42.  
  43. void exit()
  44. {       /*int i;
  45.  
  46.         for ( i = atExitFnNum - 1; i >= 0; i-- )
  47.                 atExitList[i]();*/
  48.        
  49.         __asm
  50.         {
  51.                 mov eax, -1
  52.                 int 0x40
  53.   };
  54. };
  55.  
  56. /*int __cdecl atexit( void (__cdecl *func )( void ))
  57. {
  58.         //
  59.         if ( atExitFnNum < atexitBufferSize )
  60.         {
  61.                 //
  62.                 atExitList[atExitFnNum++] = func;
  63.                 return 0;
  64.         }
  65.         else
  66.         {
  67.                 return 1;
  68.         }
  69. }*/
  70.  
  71. int __cdecl _purecall()
  72. {
  73.         exit();
  74.         return 0;
  75. }
  76.  
  77. #pragma section(".CRT$XCA",long,read,write)
  78. #pragma section(".CRT$XCZ",long,read,write)
  79. typedef void (__cdecl *_PVFV)(void);
  80. //__declspec(allocate(".CRT$XCA"))  _PVFV __xc_a[1] = { 0 };
  81. //__declspec(allocate(".CRT$XCZ"))  _PVFV __xc_z[1] = { 0 };
  82. //
  83. #pragma comment(linker, "/merge:.CRT=.rdata")
  84. //
  85. void crtStartUp()
  86. {_PVFV *pbegin;
  87.         char* __argv[2];
  88.  
  89. #ifdef AUTOBUILD
  90.         __MENUET_APP_header.header;
  91. #endif
  92.  
  93.         _asm {fninit};
  94.  
  95.         /*for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
  96.         {
  97.                 //
  98.                 if ( *pbegin != 0 )
  99.                         (**pbegin)();
  100.         }
  101.         __argc = 2;*/
  102. #ifdef AUTOBUILD
  103.         __argv[0] = kosExePath;
  104.         __argv[1] = params;
  105. #else
  106.         __argv[0] = *((char **)0x20);
  107.         __argv[1] = *((char **)0x1C);
  108. #endif
  109.         main(/*__argc*/2, __argv);
  110.         exit();
  111. }
  112.  
  113.  
  114.