Subversion Repositories Kolibri OS

Rev

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

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