Subversion Repositories Kolibri OS

Rev

Rev 5115 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "kosSyst.h"
  2.  
  3. #define atexitBufferSize        32
  4.  
  5.  
  6. char pureCallMessage[] = "PURE function call!";
  7.  
  8. char *kosExePath = NULL;
  9.  
  10. //
  11. void (__cdecl *atExitList[atexitBufferSize])();
  12. int atExitFnNum = 0;
  13. //
  14. int __cdecl atexit( void (__cdecl *func )( void ))
  15. {
  16.         //
  17.         if ( atExitFnNum < atexitBufferSize )
  18.         {
  19.                 //
  20.                 atExitList[atExitFnNum++] = func;
  21.                 return 0;
  22.         }
  23.         else
  24.         {
  25.                 return 1;
  26.         }
  27. }
  28.  
  29.  
  30. //
  31. Dword RandomSeed = 1;
  32. //
  33. void rtlSrand( Dword seed )
  34. {
  35.         RandomSeed = seed;
  36. }
  37. //
  38. Dword rtlRand( void )
  39. {
  40.   //ìàñêà 0x80000776
  41.  
  42.   Dword dwi, i;
  43.  
  44.   for ( i = 0; i < 32; i++ )
  45.   {
  46.  
  47.     dwi = RandomSeed & 0x80000776;
  48.  
  49.       __asm{
  50.             mov   eax, dwi
  51.             mov   edx, eax
  52.             bswap eax
  53.             xor   eax, edx
  54.             xor   al, ah
  55.             setpo al
  56.             movzx eax, al
  57.             mov   dwi, eax
  58.     }
  59.  
  60.     RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 );
  61.   }
  62.  
  63.  return RandomSeed;
  64. }
  65.  
  66. //
  67. void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount )
  68. {
  69.         __asm{
  70.                 mov edi, dst
  71.                 mov eax, dst
  72.                 mov esi, src
  73.                 mov ecx, bytesCount
  74.                 rep movsb
  75.         }
  76. }
  77.  
  78. //
  79. void memset( Byte *dst, Byte filler, Dword count )
  80. {
  81.         //
  82.         __asm{
  83.                 mov edi, dst
  84.                 mov al, filler
  85.                 mov ecx, count
  86.                 rep stosb
  87.         }
  88. }
  89.  
  90. //
  91. Dword rtlInterlockedExchange( Dword *target, Dword value )
  92. {
  93. //      Dword result;
  94.  
  95.         //
  96.         __asm{
  97.                 mov eax, value
  98.                 mov ebx, target
  99.                 xchg eax, [ebx]
  100. //              mov result, eax
  101.         }
  102.         //
  103. //      return result;
  104. }
  105.  
  106.  
  107. //////////////////////////////////////////////////////////////////////
  108. //
  109. // êîïèðîâàíèå ñòðîêè
  110. //
  111.  
  112. char * __cdecl strcpy( char *target, const char *source )
  113. {
  114.         char *result = target;
  115.  
  116.         while( target[0] = source[0] )
  117.         {
  118.                 target++;
  119.                 source++;
  120.         }
  121.  
  122.         return result;
  123. }
  124.  
  125.  
  126. //////////////////////////////////////////////////////////////////////
  127. //
  128. // ðåâåðñèâíûé ïîèñê ñèìâîëà
  129. //
  130.  
  131. char * __cdecl strrchr( const char * string, int c )
  132. {
  133.         char *cPtr;
  134.  
  135.         //
  136.         for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- )
  137.         {
  138.                 //
  139.                 if ( *cPtr == c ) return cPtr;
  140.         }
  141.         //
  142.         return NULL;
  143. }
  144.  
  145.  
  146. //////////////////////////////////////////////////////////////////////
  147. //
  148. // îïðåäåëåíèå äëèíû ñòðîêè
  149. //
  150.  
  151. int __cdecl strlen( const char *line )
  152. {
  153.   int i;
  154.  
  155.   for( i=0; line[i] != 0; i++ );
  156.   return i;
  157. }
  158.  
  159.  
  160.  
  161. //////////////////////////////////////////////////////////////////////
  162. //
  163. // ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë
  164. //
  165.  
  166. unsigned int num2hex( unsigned int num )
  167. {
  168.   if( num < 10 )
  169.     return num + '0';
  170.   return num - 10 + 'A';
  171. }
  172.  
  173.  
  174. //////////////////////////////////////////////////////////////////////
  175. //
  176. // âûâîä ñòðîêè íà ïå÷àòü
  177. //
  178.  
  179. Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
  180.                    10000, 1000, 100, 10, 0 };
  181.  
  182. //
  183. void sprintk( char *Str, PRINTK *arg )
  184. {
  185.         int i, fmtlinesize, j, ac, k, flag;
  186.         Dword head, tail;
  187.         char c;
  188.        
  189.         //
  190.         ac = 0;
  191.  
  192.         //
  193.         fmtlinesize = strlen( arg->fmtline );
  194.         //
  195.         if( fmtlinesize == 0 ) return;
  196.  
  197.         //
  198.         for( i = 0, j = 0; i < fmtlinesize; i++ )
  199.         {
  200.                 //
  201.                 c = arg->fmtline[i];
  202.                 //
  203.                 if( c != '%' )
  204.                 {
  205.                         Str[j++] = c;
  206.                         continue;
  207.                 }
  208.                 //
  209.                 i++;
  210.                 //
  211.                 if( i >= fmtlinesize ) break;
  212.  
  213.                 //
  214.                 flag = 0;
  215.                 //
  216.                 c = arg->fmtline[i];
  217.                 //
  218.                 switch( c )
  219.                 {
  220.                 //
  221.                 case '%':
  222.                         Str[j++] = c;
  223.                         break;
  224.                 // âûâîä ñòðîêè
  225.                 case 'S':
  226.                         for( k = 0; ( c = ((Byte *)arg->args[ac])[k] ) != 0; k++ )
  227.                         {
  228.                                 Str[j++] = c;
  229.                         }
  230.                         ac++;
  231.                         break;
  232.                 // âûâîä áàéòà
  233.                 case 'B':
  234.                         k = (int)(arg->args[ac]) & 0xFF;
  235.                         Str[j++] = num2hex( ( k >> 4 ) & 0xF );
  236.                         Str[j++] = num2hex( k & 0xF );
  237.                         ac++;
  238.                         break;
  239.                 // âûâîä ñèìâîëà
  240.                 case 'C':
  241.                         Str[j++] = (int)(arg->args[ac]) & 0xFF;
  242.                         ac++;
  243.                         break;
  244.                 // âûâîä äâîéíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
  245.                 case 'X':
  246.                         for( k = 7; k >= 0; k-- )
  247.                         {
  248.                                 //
  249.                                 c = num2hex ( ( (Dword)(arg->args[ac]) >> (k * 4) ) & 0xF );
  250.                                 //
  251.                                 if( c == '0' )
  252.                                 {
  253.                                         if( flag ) Str[j++] = c;
  254.                                 }
  255.                                 else
  256.                                 {
  257.                                         flag++;
  258.                                         Str[j++] = c;
  259.                                 }
  260.                         }
  261.                         //
  262.                         if( flag == 0 ) Str[j++] = '0';
  263.                         ac++;
  264.                         break;
  265.                 // âûâîä äâîéíîãî ñëîâà â äåñÿòè÷íîì âèäå
  266.                 case 'U':
  267.                         head = (Dword)(arg->args[ac]);
  268.                         tail = 0;
  269.                         for( k = 0; dectab[k] != 0; k++ )
  270.                         {
  271.                                 tail = head % dectab[k];
  272.                                 head /= dectab[k];
  273.                                 c = head + '0';
  274.                                 if( c == '0' )
  275.                                 {
  276.                                         if( flag ) Str[j++] = c;
  277.                                 }
  278.                                 else
  279.                                 {
  280.                                         flag++;
  281.                                         Str[j++] = c;
  282.                                 }
  283.                                 //
  284.                                 head = tail;
  285.                         }
  286.                         //
  287.                         c = head + '0';
  288.                         Str[j++] = c;
  289.                         ac++;
  290.                         break;
  291.                 // âûâîä 64-áèòíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
  292.                 case 'Q':
  293.                         for( k = 7; k >= 0; k-- )
  294.                         {
  295.                                 //
  296.                                 c = num2hex ( ( *((unsigned int *)(arg->args[ac]) + 1) >> (k * 4) ) & 0xF );
  297.                                 //
  298.                                 if( c == '0' )
  299.                                 {
  300.                                         if( flag ) Str[j++] = c;
  301.                                 }
  302.                                 else
  303.                                 {
  304.                                         flag++;
  305.                                         Str[j++] = c;
  306.                                 }
  307.                         }
  308.                         //
  309.                         for( k=7; k >= 0; k-- )
  310.                         {
  311.                                 //
  312.                                 c = num2hex ( ( *((unsigned int *)(arg->args[ac])) >> (k * 4) ) & 0xF );
  313.                                 //
  314.                                 if( c == '0' )
  315.                                 {
  316.                                         if( flag ) Str[j++] = c;
  317.                                 }
  318.                                 else
  319.                                 {
  320.                                         flag++;
  321.                                         Str[j++] = c;
  322.                                 }
  323.                         }
  324.                         //
  325.                         if( flag == 0 ) Str[j++] = '0';
  326.                         //
  327.                         ac++;
  328.                         break;
  329.                 //
  330.                 default:
  331.                         break;
  332.                 }
  333.         }
  334.         //
  335.         Str[j] = 0;
  336. }
  337.  
  338.  
  339. // ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
  340. void kos_ExitApp()
  341. {
  342.         int i;
  343.  
  344.         //
  345.         for ( i = atExitFnNum - 1; i >= 0; i-- )
  346.         {
  347.                 //
  348.                 atExitList[i]();
  349.         }
  350.         //
  351.         __asm{
  352.                 mov eax, -1
  353.                 int 0x40
  354.         }
  355. }
  356.  
  357.  
  358. // ôóíêöèÿ 0
  359. void kos_DefineAndDrawWindow(
  360.         Word x, Word y,
  361.         Word sizeX, Word sizeY,
  362.         Byte mainAreaType,
  363.         Dword mainAreaColour,
  364.         Byte headerType,
  365.         Dword headerColour,
  366.         Dword borderColour
  367.         )
  368. {
  369.         Dword arg1, arg2, arg3, arg4;
  370.  
  371.         //
  372.         arg1 = ( x << 16 ) + sizeX;
  373.         arg2 = ( y << 16 ) + sizeY;
  374.         arg3 = ( mainAreaType << 24 ) | mainAreaColour;
  375.         arg4 = ( headerType << 24 ) | headerColour;
  376.         //
  377.         __asm{
  378.                 mov eax, 0
  379.                 mov ebx, arg1
  380.                 mov ecx, arg2
  381.                 mov edx, arg3
  382.                 mov esi, arg4
  383.                 mov edi, borderColour
  384.                 int 0x40
  385.         }
  386. }
  387.  
  388.  
  389. // ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
  390. void kos_PutPixel( Dword x, Dword y, Dword colour )
  391. {
  392.         //
  393.         __asm{
  394.                 mov eax, 1
  395.                 mov ebx, x
  396.                 mov ecx, y
  397.                 mov edx, colour
  398.                 int 0x40
  399.         }
  400. }
  401.  
  402.  
  403. // ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
  404. bool kos_GetKey( Byte &keyCode )
  405. {
  406.         Dword result;
  407.  
  408.         //
  409.         __asm{
  410.                 mov eax, 2
  411.                 int 0x40
  412.                 mov result, eax
  413.         }
  414.         //
  415.         keyCode = result >> 8;
  416.         //
  417.         return ( result & 0xFF ) == 0;
  418. }
  419.  
  420.  
  421. // ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
  422. Dword kos_GetSystemClock()
  423. {
  424. //      Dword result;
  425.  
  426.         //
  427.         __asm{
  428.                 mov eax, 3
  429.                 int 0x40
  430. //              mov result, eax
  431.         }
  432.         //
  433. //      return result;
  434. }
  435.  
  436.  
  437. // ôóíêöèÿ 4
  438. void kos_WriteTextToWindow(
  439.         Word x,
  440.         Word y,
  441.         Byte fontType,
  442.         Dword textColour,
  443.         char *textPtr,
  444.         Dword textLen
  445.         )
  446. {
  447.         Dword arg1, arg2;
  448.  
  449.         //
  450.         arg1 = ( x << 16 ) | y;
  451.         arg2 = ( fontType << 24 ) | textColour;
  452.         //
  453.         __asm{
  454.                 mov eax, 4
  455.                 mov ebx, arg1
  456.                 mov ecx, arg2
  457.                 mov edx, textPtr
  458.                 mov esi, textLen
  459.                 int 0x40
  460.         }
  461. }
  462.  
  463.  
  464. // ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
  465. void kos_Pause( Dword value )
  466. {
  467.         //
  468.         __asm{
  469.                 mov eax, 5
  470.                 mov ebx, value
  471.                 int 0x40
  472.         }
  473. }
  474.  
  475.  
  476. // ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
  477. void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
  478. {
  479.         Dword arg1, arg2;
  480.  
  481.         //
  482.         arg1 = ( sizeX << 16 ) | sizeY;
  483.         arg2 = ( x << 16 ) | y;
  484.         //
  485.         __asm{
  486.                 mov eax, 7
  487.                 mov ebx, imagePtr
  488.                 mov ecx, arg1
  489.                 mov edx, arg2
  490.                 int 0x40
  491.         }
  492. }
  493.  
  494.  
  495.  
  496. // ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
  497. void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
  498. {
  499.         Dword arg1, arg2;
  500.  
  501.         //
  502.         arg1 = ( x << 16 ) | sizeX;
  503.         arg2 = ( y << 16 ) | sizeY;
  504.         //
  505.         __asm{
  506.                 mov eax, 8
  507.                 mov ebx, arg1
  508.                 mov ecx, arg2
  509.                 mov edx, buttonID
  510.                 mov esi, colour
  511.                 int 0x40
  512.         }
  513. }
  514.  
  515.  
  516. // ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå
  517. Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
  518. {
  519. //      Dword result;
  520.  
  521.         //
  522.         __asm{
  523.                 mov eax, 9
  524.                 mov ebx, targetPtr
  525.                 mov ecx, processID
  526.                 int 0x40
  527. //              mov result, eax
  528.         }
  529.         //
  530. //      return result;
  531. }
  532.  
  533.  
  534. // ôóíêöèÿ 10
  535. Dword kos_WaitForEvent()
  536. {
  537. //      Dword result;
  538.  
  539.         __asm{
  540.                 mov eax, 10
  541.                 int 0x40
  542. //              mov result, eax
  543.         }
  544.        
  545. //      return result;
  546. }
  547.  
  548.  
  549. // ôóíêöèÿ 11
  550. Dword kos_CheckForEvent()
  551. {
  552. //      Dword result;
  553.  
  554.         __asm{
  555.                 mov eax, 11
  556.                 int 0x40
  557. //              mov result, eax
  558.         }
  559.        
  560. //      return result;
  561. }
  562.  
  563.  
  564. // ôóíêöèÿ 12
  565. void kos_WindowRedrawStatus( Dword status )
  566. {
  567.         __asm{
  568.                 mov eax, 12
  569.                 mov ebx, status
  570.                 int 0x40
  571.         }
  572. }
  573.  
  574.  
  575. // ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó
  576. void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
  577. {
  578.         Dword arg1, arg2;
  579.  
  580.         //
  581.         arg1 = ( x << 16 ) | sizeX;
  582.         arg2 = ( y << 16 ) | sizeY;
  583.         //
  584.         __asm{
  585.                 mov eax, 13
  586.                 mov ebx, arg1
  587.                 mov ecx, arg2
  588.                 mov edx, colour
  589.                 int 0x40
  590.         }
  591. }
  592.  
  593.  
  594. // ôóíêöèÿ 17
  595. bool kos_GetButtonID( Dword &buttonID )
  596. {
  597.         Dword result;
  598.  
  599.         //
  600.         __asm{
  601.                 mov eax, 17
  602.                 int 0x40
  603.                 mov result, eax
  604.         }
  605.         //
  606.         buttonID = result >> 8;
  607.         //
  608.         return (result & 0xFF) == 0;
  609. }
  610.  
  611.  
  612. // ôóíêöèÿ 23
  613. Dword kos_WaitForEvent( Dword timeOut )
  614. {
  615. //      Dword result;
  616.  
  617.         __asm{
  618.                 mov eax, 23
  619.                 mov ebx, timeOut
  620.                 int 0x40
  621. //              mov result, eax
  622.         }
  623.        
  624. //      return result;
  625. }
  626.  
  627.  
  628. // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37
  629. void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
  630. {
  631.         Dword mB;
  632.         Word curX;
  633.         Word curY;
  634.         sProcessInfo sPI;
  635.  
  636.         //
  637.         __asm{
  638.                 mov             eax, 37
  639.                 mov             ebx, 0
  640.                 int             0x40
  641.                 mov             curY, ax
  642.                 shr             eax, 16
  643.                 mov             curX, ax
  644.                 mov             eax, 37
  645.                 mov             ebx, 2
  646.                 int             0x40
  647.                 mov             mB, eax
  648.         }
  649.         //
  650.         kos_ProcessInfo( &sPI );
  651.         //
  652.         buttons = mB;
  653.         cursorX = curX - sPI.processInfo.x_start;
  654.         cursorY = curY - sPI.processInfo.y_start;
  655. }
  656.  
  657.  
  658. // ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
  659. void kos_SetMaskForEvents( Dword mask )
  660. {
  661.         //
  662.         __asm{
  663.                 mov eax, 40
  664.                 mov ebx, mask
  665.                 int 0x40
  666.         }
  667. }
  668.  
  669.  
  670. // ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
  671. void kos_DisplayNumberToWindow(
  672.    Dword value,
  673.    Dword digitsNum,
  674.    Word x,
  675.    Word y,
  676.    Dword colour,
  677.    eNumberBase nBase,
  678.    bool valueIsPointer
  679.    )
  680. {
  681.         Dword arg1, arg2;
  682.  
  683.         //
  684.         arg1 = ( valueIsPointer ? 1 : 0 ) |
  685.                 ( ((Byte)nBase) << 8 ) |
  686.                 ( ( digitsNum & 0x1F ) << 16 );
  687.         arg2 = ( x << 16 ) | y;
  688.         //
  689.         __asm{
  690.                 mov eax, 47
  691.                 mov ebx, arg1
  692.                 mov ecx, value
  693.                 mov edx, arg2
  694.                 mov esi, colour
  695.                 int 0x40
  696.         }
  697. }
  698.  
  699.  
  700. // ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå
  701. Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
  702. {
  703. //      Dword result;
  704.  
  705.         //
  706.         __asm{
  707.                 mov eax, 70
  708.                 mov ebx, fileInfo
  709.                 int 0x40
  710. //              mov result, eax
  711.         }
  712.         //
  713. //      return result;
  714. }
  715.  
  716.  
  717. // ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè
  718. void kos_DebugOutChar( char ccc )
  719. {
  720.         //
  721.         __asm{
  722.                 mov eax, 63
  723.                 mov ebx, 1
  724.                 mov cl, ccc
  725.                 int 0x40
  726.         }
  727. }
  728.  
  729.  
  730. // ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
  731. void kos_SetKeyboardDataMode( Dword mode )
  732. {
  733.         //
  734.         __asm{
  735.                 mov eax, 66
  736.                 mov ebx, 1
  737.                 mov ecx, mode
  738.                 int 0x40
  739.         }
  740. }
  741.  
  742.  
  743. // âûâîä ñòðîêè â îêíî îòëàäêè
  744. void rtlDebugOutString( char *str )
  745. {
  746.         //
  747.         for ( ; str[0] != 0; str++ )
  748.         {
  749.                 kos_DebugOutChar( str[0] );
  750.         }
  751.         //
  752.         kos_DebugOutChar( 13 );
  753.         kos_DebugOutChar( 10 );
  754. }
  755.  
  756.  
  757. // ôóíêöèÿ 64 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
  758. bool kos_ApplicationMemoryResize( Dword targetSize )
  759. {
  760.         Dword result;
  761.  
  762.         //
  763.         __asm{
  764.                 mov eax, 64
  765.                 mov ebx, 1
  766.                 mov ecx, targetSize
  767.                 int 0x40
  768.                 mov result, eax
  769.         }
  770.         //
  771.         return result == 0;
  772. }
  773.  
  774.  
  775. // ôóíêöèÿ 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
  776. void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY )
  777. {
  778.         //
  779.         __asm{
  780.                 mov eax, 67
  781.                 mov ebx, x
  782.                 mov ecx, y
  783.                 mov edx, sizeX
  784.                 mov esi, sizeY
  785.                 int 0x40
  786.         }
  787. }
  788.  
  789.  
  790.  
  791. // âûçîâ àáñòðàêòíîãî ìåòîäà
  792. int __cdecl _purecall()
  793. {
  794.         rtlDebugOutString( pureCallMessage );
  795.         kos_ExitApp();
  796.         return 0;
  797. }
  798.  
  799.  
  800. // âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ
  801. // çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë
  802. #pragma section(".CRT$XCA",long,read,write)
  803. #pragma section(".CRT$XCZ",long,read,write)
  804. typedef void (__cdecl *_PVFV)(void);
  805. __declspec(allocate(".CRT$XCA"))  _PVFV __xc_a[1] = { NULL };
  806. __declspec(allocate(".CRT$XCZ"))  _PVFV __xc_z[1] = { NULL };
  807. //
  808. #pragma comment(linker, "/merge:.CRT=.rdata")
  809. //
  810. void crtStartUp()
  811. {
  812.         // âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì
  813.         for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
  814.         {
  815.                 //
  816.                 if ( *pbegin != NULL )
  817.                         (**pbegin)();
  818.         }
  819.         // èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
  820.         rtlSrand( kos_GetSystemClock() );
  821.         // ïóòü ê ôàéëó ïðîöåññà
  822.         kosExePath = *((char **)0x20);
  823.         // âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ
  824.         kos_Main();
  825.         // âûõîä
  826.         kos_ExitApp();
  827. }
  828.  
  829.  
  830.