Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. SYSTEM FUNCTIONS of OS Kolibri 0.7.7.0
  9.  
  10. Number of the function is located in the register eax.
  11. The call of the system function is executed by "int 0x40" command.
  12. All registers except explicitly declared in the returned value,
  13.     including eflags, are preserved.
  14.  
  15.  
  16. ======================================================================
  17. ============== Function 0 - define and draw the window. ==============
  18. ======================================================================
  19. Defines an application window. Draws a frame of the window, header and
  20. working area. For skinned windows defines standard close and minimize
  21. buttons.
  22. Parameters:
  23.   * eax = 0 - function number
  24.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  25.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  26.   * edx = 0xXYRRGGBB, where:
  27.     * Y = style of the window:
  28.       * Y=1 - only define window area, draw nothing
  29.       * Y=3 - skinned window
  30.       * Y=4 - skinned fixed-size window
  31.       * Y=0,2 window types are outdated and should not be used anymore,
  32.         they are retained for compatibility with old programs.
  33.       * other possible values (from 5 to 15) are reserved,
  34.         function call with such Y is ignored
  35.     * RR, GG, BB = accordingly red, green, blue components of a color
  36.       of the working area of the window (are ignored for style Y=1)
  37.     * X = DCBA (bits)
  38.       * A = 1 - window has caption
  39.       * B = 1 - coordinates of all graphics primitives are relative to
  40.                   window client area
  41.       * C = 1 - don't fill working area on window draw
  42.       * D = 0 - normal filling of the working area, 1 - gradient
  43.     The following parameters are intended for windows
  44.     of a type I and II, and ignored for styles Y=1,3:
  45.   * esi = 0xXYRRGGBB - color of the header
  46.     * RR, GG, BB define color
  47.     * Y=0 - usual window, Y=1 - unmovable window (works for all window styles)
  48.     * X not used, other values of Y are reserved
  49.   * edi = caption string for styles Y=3,4 (also can be set by func 71.1)
  50. Returned value:
  51.   * function does not return value
  52. Remarks:
  53.   * Position and sizes of the window are installed by the first
  54.     call of this function and are ignored at subsequent; to change
  55.     position and/or sizes of already created window use function 67.
  56.   * For windows with styles Y=3,4 and caption (A=1) caption string
  57.     is set by the first call of this function and is ignored
  58.     at subsequent (strictly speaking, is ignored after a call to
  59.     subfunction 2 of function 12 - end redraw); to change caption of
  60.     already created window use subfunction 1 of function 71.
  61.   * If the window has appropriate styles, position and/or sizes can be
  62.     changed by user. Current position and sizes can be obtained
  63.     by function 9.
  64.   * The window must fit on the screen. If the transferred
  65.     coordinates and sizes do not satisfy to this condition,
  66.     appropriate coordinate (or, probably, both) is considered as zero,
  67.     and if it does not help too, the appropriate size
  68.     (or, probably, both) is installed in a size of the screen.
  69.  
  70.     Further let us designate xpos,ypos,xsize,ysize - values passed
  71.     in ebx,ecx. The coordinates are resulted concerning
  72.     the left upper corner of the window, which, thus, is set as (0,0),
  73.     coordinates of the right lower corner essence (xsize,ysize).
  74.   * The sizes of the window are understood in sence of coordinates
  75.     of the right lower corner. This concerns all other functions too.
  76.     It means, that the real sizes are on 1 pixel more.
  77.   * The window of style Y=1 looks as follows:
  78.     * completely defined by the application
  79.   * The skinned window Y=3,4 looks as follows:
  80.     * draw external frame of width 1 pixel
  81.       with color 'outer' from the skin
  82.     * draw intermediate frame of width 3 pixel
  83.       with color 'frame' from the skin
  84.     * draw internal frame of width 1 pixel
  85.       with color 'inner' from the skin
  86.     * draw header (on bitmaps from the skin) in a rectangle
  87.       (0,0) - (xsize,_skinh-1)
  88.     * if ysize>=26, fill the working area of the window -
  89.       rectangle with the left upper corner (5,_skinh) and right lower
  90.       (xsize-5,ysize-5) with color indicated in edx
  91.       (taking a gradient into account)
  92.     * define two standard buttons: close and minimize
  93.       (see function 8)
  94.     * if A=1 and edi contains (nonzero) pointer to caption string,
  95.       it is drawn in place in header defined in the skin
  96.     * value _skinh is accessible as the result of call
  97.       subfunction 4 of function 48
  98.  
  99. ---------------------- Constants for registers: ----------------------
  100.   eax - SF_CREATE_WINDOW (0)
  101. ======================================================================
  102. ================ Function 1 - put pixel in the window. ===============
  103. ======================================================================
  104. Parameters:
  105.   * eax = 1 - function number
  106.   * ebx = x-coordinate (relative to the window)
  107.   * ecx = y-coordinate (relative to the window)
  108.   * edx = 0x00RRGGBB - color of a pixel
  109.     edx = 0x01xxxxxx - invert color of a pixel
  110.           (low 24 bits are ignored)
  111. Returned value:
  112.   * function does not return value
  113.  
  114. ---------------------- Constants for registers: ----------------------
  115.   eax - SF_PUT_PIXEL (1)
  116. ======================================================================
  117. ============ Function 2 - get the code of the pressed key. ===========
  118. ======================================================================
  119. Takes away the code of the pressed key from the buffer.
  120. Parameters:
  121.   * eax = 2 - function number
  122. Returned value:
  123.   * if the buffer is empty, function returns eax=1
  124.   * if the buffer is not empty, function returns al=0,
  125.     ah=code of the pressed key,
  126.     bits 16-23 = contain scancode for pressed key in ASCII mode,
  127.                  in the scancodes mode this bits cleared.
  128.     bits 23-31 = zero
  129.   * if there is "hotkey", function returns al=2,
  130.     ah=scancode of the pressed key (0 for control keys),
  131.     high word of eax contains a status of control keys at the moment
  132.     of pressing a hotkey
  133. Remarks:
  134.   * There is a common system buffer of the pressed keys
  135.     by a size of 120 bytes, organized as queue.
  136.   * There is one more common system buffer on 120 "hotkeys".
  137.   * If the application with the inactive window calls this function,
  138.     the buffer of the pressed keys is considered to be empty.
  139.   * By default this function returns ASCII-codes; to switch
  140.     to the scancodes mode (and back) use function 66.
  141.     However, hotkeys are always notificated as scancodes.
  142.   * To find out, what keys correspond to what codes, start
  143.     the application keyascii and scancode.
  144.   * Scancodes come directly from keyboard and are fixed;
  145.     ASCII-codes turn out with usage of the conversion tables,
  146.     which can be set by subfunction 2 of function 21
  147.     and get by subfunction 2 of function 26.
  148.   * As a consequence, ASCII-codes take into account current
  149.     keyboard layout (rus/en) as opposed to scancodes.
  150.   * This function notifies only about those hotkeys, which were
  151.     defined by this thread by subfunction 4 of function 66.
  152.  
  153. ---------------------- Constants for registers: ----------------------
  154.   eax - SF_GET_KEY (2)
  155. ======================================================================
  156. ==================== Function 3 - get system time. ===================
  157. ======================================================================
  158. Parameters:
  159.   * eax = 3 - function number
  160. Returned value:
  161.   * eax = 0x00SSMMHH, where HH:MM:SS = Hours:Minutes:Seconds
  162.   * each item is BCD-number, for example,
  163.     for time 23:59:59 function returns 0x00595923
  164. Remarks:
  165.   * See also subfunction 9 of function 26 - get time from
  166.     the moment of start of the system; it is more convenient, because
  167.     returns simply DWORD-value of the time counter.
  168.   * System time can be set by function 22.
  169.  
  170. ---------------------- Constants for registers: ----------------------
  171.   eax - SF_GET_SYS_TIME (3)
  172. ======================================================================
  173. =================== Function 4 - draw text string. ===================
  174. ======================================================================
  175. Parameters:
  176.   * eax = 4 - function number
  177.   * ebx = X*65536+Y, coordinates in the window or buffer
  178.   * ecx = 0xXXRRGGBB, where
  179.     * RR, GG, BB specify text color
  180.     * XX = ABFFCSSS (bits):
  181.       * A=1 - output zero terminated string
  182.       * B=1 - fill background (color = edi)
  183.       * FF specifies the font and encoding:
  184.         0 = 6x9  cp866
  185.         1 = 8x16 cp866
  186.         2 = 8x16 UTF-16LE
  187.         3 = 8x16 UTF-8
  188.       * C=0 - draw to the window,
  189.         C=1 - draw to the user buffer (edi)
  190.       * SSS = (size multiplier)-1, so 0 = x1, 7 = x8
  191.   * edx = pointer to the beginning of the string
  192.   * esi = for A=0 length of the string, for A=1 is ignored
  193.   * edi = for B=1 color to fill background,
  194.           for C=1 pointer to user buffer
  195.  
  196. Returned value:
  197.   * function does not return value
  198. Remarks:
  199.   * You can not use B=1 and C=1 at the same time, since both use edi.
  200.   * When SSS=0, font may be smoothed, depending on system setting.
  201.   * User buffer structure:
  202. Xsize       dd
  203. Ysize       dd
  204. picture     rb  Xsize*Ysize*4  ; 32 bpp
  205.  
  206. ---------------------- Constants for registers: ----------------------
  207.   eax - SF_DRAW_TEXT (4)
  208. ======================================================================
  209. ========================= Function 5 - delay. ========================
  210. ======================================================================
  211. Delays execution of the program on the given time.
  212. Parameters:
  213.   * eax = 5 - function number
  214.   * ebx = time in the 1/100 of second
  215. Returned value:
  216.   * function does not return value
  217. Remarks:
  218.   * Passing ebx=0 does not transfer control to the next process
  219.     and does not make any operations at all. If it is really required
  220.     to transfer control to the next process (to complete a current
  221.     time slice), use subfunction 1 of function 68.
  222.  
  223. ---------------------- Constants for registers: ----------------------
  224.   eax - SF_SLEEP (5)
  225. ======================================================================
  226. =============== Function 7 - draw image in the window. ===============
  227. ======================================================================
  228. Paramters:
  229.   * eax = 7 - function number
  230.   * ebx = pointer to the image in the format BBGGRRBBGGRR...
  231.   * ecx = [size on axis x]*65536 + [size on axis y]
  232.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  233. Returned value:
  234.   * function does not return value
  235. Remarks:
  236.   * Coordinates of the image are coordinates of the upper left corner
  237.     of the image relative to the window.
  238.   * Size of the image in bytes is 3*xsize*ysize.
  239.  
  240. ---------------------- Constants for registers: ----------------------
  241.   eax - SF_PUT_IMAGE (7)
  242. ======================================================================
  243. =============== Function 8 - define/delete the button. ===============
  244. ======================================================================
  245. Parameters for button definition:
  246.   * eax = 8 - function number
  247.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  248.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  249.   * edx = 0xXYnnnnnn, where:
  250.     * nnnnnn = identifier of the button
  251.     * high (31st) bit of edx is cleared
  252.     * if 30th bit of edx is set - do not draw the button
  253.     * if 29th bit of edx is set - do not draw a frame
  254.       at pressing the button
  255.   * esi = 0x00RRGGBB - color of the button
  256. Parameters for button deleting:
  257.   * eax = 8 - function number
  258.   * edx = 0x80nnnnnn, where nnnnnn - identifier of the button
  259. Returned value:
  260.   * function does not return value
  261. Remarks:
  262.   * Sizes of the button must be more than 0 and less than 0x8000.
  263.   * For skinned windows definition of the window
  264.     (call of 0th function) creates two standard buttons -
  265.     for close of the window with identifier 1 and
  266.     for minimize of the window with identifier 0xffff.
  267.   * The creation of two buttons with same identifiers is admitted.
  268.   * The button with the identifier 0xffff at pressing is interpreted
  269.     by the system as the button of minimization, the system handles
  270.     such pressing independently, not accessing to the application.
  271.     In rest it is usual button.
  272.   * Total number of buttons for all applications is limited to 4095.
  273.  
  274. ---------------------- Constants for registers: ----------------------
  275.   eax - SF_DEFINE_BUTTON (8)
  276. ======================================================================
  277. ============ Function 9 - information on execution thread. ===========
  278. ======================================================================
  279. Parameters:
  280.   * eax = 9 - function number
  281.   * ebx = pointer to 1-Kb buffer
  282.   * ecx = number of the slot of the thread
  283.     ecx = -1 - get information on the current thread
  284. Returned value:
  285.   * eax = maximum number of the slot of a thread
  286.   * buffer pointed to by ebx contains the following information:
  287.     * +0: dword: usage of the processor (how many time units
  288.       per second leaves on execution of this thread)
  289.     * +4: word: position of the window of thread in the window stack
  290.     * +6: word: (has no relation to the specified thread)
  291.       number of the thread slot, which window has in the window stack
  292.       position ecx
  293.     * +8: word: reserved
  294.     * +10 = +0xA: 11 bytes: name of the process
  295.       (name of the started file - executable file without extension)
  296.     * +21 = +0x15: byte: reserved, this byte is not changed
  297.     * +22 = +0x16: dword: address of the process in memory
  298.     * +26 = +0x1A: dword: size of used memory - 1
  299.     * +30 = +0x1E: dword: identifier (PID/TID)
  300.     * +34 = +0x22: dword: coordinate of the thread window on axis x
  301.     * +38 = +0x26: dword: coordinate of the thread window on axis y
  302.     * +42 = +0x2A: dword: size of the thread window on axis x
  303.     * +46 = +0x2E: dword: size of the thread window on axis y
  304.     * +50 = +0x32: word: status of the thread slot:
  305.       * 0 = thread is running
  306.       * 1 = thread is suspended
  307.       * 2 = thread is suspended while waiting for event
  308.       * 3 = thread is terminating as a result of call to function -1
  309.         or under duress as a result of call to subfunction 2
  310.         of function 18 or termination of the system
  311.       * 4 = thread is terminating as a result of exception
  312.       * 5 = thread waits for event
  313.       * 9 = requested slot is free, all other information on the slot
  314.         is not meaningful
  315.     * +52 = +0x34: word: reserved, this word is not changed
  316.     * +54 = +0x36: dword: coordinate of the client area on axis x
  317.     * +58 = +0x3A: dword: coordinate of the client area on axis y
  318.     * +62 = +0x3E: dword: width of the client area
  319.     * +66 = +0x42: dword: height of the client area
  320.     * +70 = +0x46: byte: state of the window - bitfield
  321.       * bit 0 (mask 1): window is maximized
  322.       * bit 1 (mask 2): window is minimized to panel
  323.       * bit 2 (mask 4): window is rolled up
  324.     * +71 = +0x47: dword: event mask
  325.     * +75 = +0x4B: byte: keyboard mode(ASCII = 0; SCAN = 1)
  326. Remarks:
  327.   * Slots are numbered starting from 1.
  328.   * Returned value is not a total number of threads, because there
  329.     can be free slots.
  330.   * When process is starting, system automatically creates
  331.     execution thread.
  332.   * Function gives information on the thread. Each process has
  333.     at least one thread. One process can create many threads,
  334.     in this case each thread has its own slot and the fields
  335.     +10, +22, +26 in these slots coincide.
  336.     Applications have no common way to define whether two threads
  337.     belong to one process.
  338.   * The active window - window on top of the window stack -
  339.     receives the messages on a keyboard input. For such window
  340.     the position in the window stack coincides with returned value.
  341.   * Slot 1 corresponds to special system thread, for which:
  342.     * the window is in the bottom of the window stack, the fields
  343.       +4 and +6 contain value 1
  344.     * name of the process - "OS/IDLE" (supplemented by spaces)
  345.     * address of the process in memory is 0, size of used memory is
  346.       16 Mb (0x1000000)
  347.     * PID=1
  348.     * coordinates and sizes of the window and the client area are by
  349.       convention set to 0
  350.     * status of the slot is always 0 (running)
  351.     * the execution time adds of time leaving on operations itself
  352.       and idle time in waiting for interrupt (which can be got by call
  353.       to subfunction 4 of function 18).
  354.   * Beginning from slot 2, the normal applications are placed.
  355.   * The normal applications are placed in memory at the address
  356.     0 (kernel constant 'std_application_base_address').
  357.     There is no intersection, as each process has its own page table.
  358.   * At creation of the thread it is assigned the slot
  359.     in the system table and identifier (Process/Thread IDentifier =
  360.     PID/TID), which do not vary with time for given thread.
  361.     After completion of the thread its slot can be anew used
  362.     for another thread. The thread identifier can not be assigned
  363.     to other thread even after completion of this thread.
  364.     Identifiers, assigned to new threads, grow monotonously.
  365.   * If the thread has not yet defined the window by call to
  366.     function 0, the position and the sizes
  367.     of its window are considered to be zero.
  368.   * Coordinates of the client area are relative to the window.
  369.   * At the moment only the part of the buffer by a size
  370.     76 = 0x4C bytes is used. Nevertheless it is recommended to use
  371.     1-Kb buffer for the future compatibility, in the future
  372.     some fields can be added.
  373.  
  374. ---------------------- Constants for registers: ----------------------
  375.   eax - SF_THREAD_INFO (9)
  376. ======================================================================
  377. ==================== Function 10 - wait for event. ===================
  378. ======================================================================
  379. If the message queue is empty, waits for appearance of the message
  380. in queue. In this state thread does not consume CPU time.
  381. Then reads out the message from queue.
  382.  
  383. Parameters:
  384.   * eax = 10 - function number
  385. Returned value:
  386.   * eax = event (see the list of events)
  387. Remarks:
  388.   * Those events are taken into account only which enter into
  389.     a mask set by function 40. By default it is
  390.     redraw, key and button events.
  391.   * To check, whether there is a message in queue, use function 11.
  392.     To wait for no more than given time, use function 23.
  393.  
  394. ---------------------- Constants for registers: ----------------------
  395.   eax - SF_WAIT_EVENT (10)
  396. ======================================================================
  397. =============== Function 11 - check for event, no wait. ==============
  398. ======================================================================
  399. If the message queue contains event, function reads out
  400. and return it. If the queue is empty, function returns 0.
  401. Parameters:
  402.   * eax = 11 - function number
  403. Returned value:
  404.   * eax = 0 - message queue is empty
  405.   * else eax = event (see the list of events)
  406. Remarks:
  407.   * Those events are taken into account only, which enter into
  408.     a mask set by function 40. By default it is
  409.     redraw, key and button events.
  410.   * To wait for event, use function 10.
  411.     To wait for no more than given time, use function 23.
  412.  
  413. ---------------------- Constants for registers: ----------------------
  414.   eax - SF_CHECK_EVENT (11)
  415. ======================================================================
  416. =============== Function 12 - begin/end window redraw. ===============
  417. ======================================================================
  418.  
  419. ---------------- Subfunction 1 - begin window redraw. ----------------
  420. Parameters:
  421.   * eax = 12 - function number
  422.   * ebx = 1 - subfunction number
  423. Returned value:
  424.   * function does not return value
  425.  
  426. ----------------- Subfunction 2 - end window redraw. -----------------
  427. Parameters:
  428.   * eax = 12 - function number
  429.   * ebx = 2 - subfunction number
  430. Returned value:
  431.   * function does not return value
  432. Remarks:
  433.   * Subfunction 1 deletes all buttons defined with
  434.     function 8, they must be defined again.
  435.  
  436. ---------------------- Constants for registers: ----------------------
  437.   eax - SF_REDRAW (12)
  438.   ebx - SSF_BEGIN_DRAW (1), SSF_END_DRAW (2)
  439. ======================================================================
  440. ============ Function 13 - draw a rectangle in the window. ===========
  441. ======================================================================
  442. Parameters:
  443.   * eax = 13 - function number
  444.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  445.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  446.   * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill
  447. Returned value:
  448.   * function does not return value
  449. Remarks:
  450.   * Coordinates are understood as coordinates of the left upper corner
  451.     of a rectangle relative to the window.
  452.  
  453. ---------------------- Constants for registers: ----------------------
  454.   eax - SF_DRAW_RECT (13)
  455. ======================================================================
  456. =================== Function 14 - get screen size. ===================
  457. ======================================================================
  458. Parameters:
  459.   * eax = 14 - function number
  460. Returned value:
  461.   * eax = [xsize]*65536 + [ysize], where
  462.   * xsize = x-coordinate of the right lower corner of the screen =
  463.             horizontal size - 1
  464.   * ysize = y-coordinate of the right lower corner of the screen =
  465.             vertical size - 1
  466. Remarks:
  467.   * See also subfunction 5 of function 48 - get sizes of
  468.     working area of the screen.
  469.  
  470. ---------------------- Constants for registers: ----------------------
  471.   eax - SF_GET_SCREEN_SIZE (14)
  472. ======================================================================
  473. == Function 15, subfunction 1 - set a size of the background image. ==
  474. ======================================================================
  475. Parameters:
  476.   * eax = 15 - function number
  477.   * ebx = 1 - subfunction number
  478.   * ecx = width of the image
  479.   * edx = height of the image
  480. Returned value:
  481.   * function does not return value
  482. Remarks:
  483.   * Before calling subfunctions 2 and 5 you should call this function
  484.     to set image size!
  485.   * For update of the screen (after completion of a series of commands
  486.     working with a background) call subfunction 3.
  487.   * There is a pair function for get size of the background image -
  488.     subfunction 1 of function 39.
  489.  
  490. ---------------------- Constants for registers: ----------------------
  491.   eax - SF_BACKGROUND_SET (15)
  492.   ebx - SSF_SIZE_BG (1)
  493. ======================================================================
  494. === Function 15, subfunction 2 - put pixel on the background image. ==
  495. ======================================================================
  496. Parameters:
  497.   * eax = 15 - function number
  498.   * ebx = 2 - subfunction number
  499.   * ecx = offset
  500.   * edx = color of a pixel 0xRRGGBB
  501. Returned value:
  502.   * function does not return value
  503. Remarks:
  504.   * Offset for a pixel with coordinates (x,y) is calculated as
  505.     (x+y*xsize)*3.
  506.   * If the given offset exceeds size set by subfunction 1,
  507.     the call is ignored.
  508.   * For update of the screen (after completion of a series of commands
  509.     working with a background) call subfunction 3.
  510.   * There is a pair function for get pixel on the background image -
  511.     subfunction 2 of function 39.
  512.  
  513. ---------------------- Constants for registers: ----------------------
  514.   eax - SF_BACKGROUND_SET (15)
  515.   ebx - SSF_PIXEL_BG (2)
  516. ======================================================================
  517. =========== Function 15, subfunction 3 - redraw background. ==========
  518. ======================================================================
  519. Parameters:
  520.   * eax = 15 - function number
  521.   * ebx = 3 - subfunction number
  522. Returned value:
  523.   * function does not return value
  524.  
  525. ---------------------- Constants for registers: ----------------------
  526.   eax - SF_BACKGROUND_SET (15)
  527.   ebx - SSF_REDRAW_BG (3)
  528. ======================================================================
  529. == Function 15, subfunction 4 - set drawing mode for the background. =
  530. ======================================================================
  531. Parameters:
  532.   * eax = 15 - function number
  533.   * ebx = 4 - subfunction number
  534.   * ecx = drawing mode:
  535.     * 1 = tile
  536.     * 2 = stretch
  537. Returned value:
  538.   * function does not return value
  539. Remarks:
  540.   * For update of the screen (after completion of a series of commands
  541.     working with a background) call subfunction 3.
  542.   * There is a pair function for get drawing mode of the background -
  543.     subfunction 4 of function 39.
  544.  
  545. ---------------------- Constants for registers: ----------------------
  546.   eax - SF_BACKGROUND_SET (15)
  547.   ebx - SSF_MODE_BG (4)
  548. ======================================================================
  549. ===================== Function 15, subfunction 5 =====================
  550. ============ Put block of pixels on the background image. ============
  551. ======================================================================
  552. Parameters:
  553.   * eax = 15 - function number
  554.   * ebx = 5 - subfunction number
  555.   * ecx = pointer to the data in the format BBGGRRBBGGRR...
  556.   * edx = offset in data of the background image
  557.   * esi = size of data in bytes = 3 * number of pixels
  558. Returned value:
  559.   * function does not return value
  560. Remarks:
  561.   * Offset and size are not checked for correctness.
  562.   * Color of each pixel is stored as 3-bytes value BBGGRR.
  563.   * Pixels of the background image are written sequentially
  564.     from left to right, from up to down.
  565.   * Offset of pixel with coordinates (x,y) is (x+y*xsize)*3.
  566.   * For update of the screen (after completion of a series of commands
  567.     working with a background) call subfunction 3.
  568.  
  569. ---------------------- Constants for registers: ----------------------
  570.   eax - SF_BACKGROUND_SET (15)
  571.   ebx - SSF_IMAGE_BG (5)
  572. ======================================================================
  573. ===================== Function 15, subfunction 6 =====================
  574. ======== Map background data to the address space of process. ========
  575. ======================================================================
  576. Parameters:
  577.   * eax = 15 - function number
  578.   * ebx = 6 - subfunction number
  579. Returned value:
  580.   * eax = pointer to background data, 0 if error
  581. Remarks:
  582.   * Mapped data are available for read and write.
  583.   * Size of background data is 3*xsize*ysize. The system blocks
  584.     changes of background sizes while process works with mapped data.
  585.   * Color of each pixel is stored as 3-bytes value BBGGRR.
  586.   * Pixels of the background image are written sequentially
  587.     from left to right, from up to down.
  588.  
  589. ---------------------- Constants for registers: ----------------------
  590.   eax - SF_BACKGROUND_SET (15)
  591.   ebx - SSF_MAP_BG (6)
  592. ======================================================================
  593. ===== Function 15, subfunction 7 - close mapped background data. =====
  594. ======================================================================
  595. Parameters:
  596.   * eax = 15 - function number
  597.   * ebx = 7 - subfunction number
  598.   * ecx = pointer to mapped data
  599. Returned value:
  600.   * eax = 1 - success, 0 - error
  601.  
  602. ---------------------- Constants for registers: ----------------------
  603.   eax - SF_BACKGROUND_SET (15)
  604.   ebx - SSF_UNMAP_BG (7)
  605. ======================================================================
  606. ===================== Function 15, subfunction 8 =====================
  607. ============= Get coordinates of last draw the background ============
  608. ======================================================================
  609. Parameters:
  610.   * eax = 15 - function number
  611.   * ebx = 8 - subfunction number
  612. Returned value:
  613.   * eax = [left]*65536 + [right]
  614.   * ebx = [top]*65536 + [bottom]
  615. Remarks:
  616.   * (left,top) are coordinates of the left upper corner,
  617.     (right,bottom) are coordinates of the right lower one.
  618.   * For receiving more reliable information, call the function
  619.     immediately after the event:
  620.              5 = kernel finished redrawing of the desktop background
  621.  
  622. ---------------------- Constants for registers: ----------------------
  623.   eax - SF_BACKGROUND_SET (15)
  624.   ebx - SSF_LAST_DRAW (8)
  625. ======================================================================
  626. ===================== Function 15, subfunction 9 =====================
  627. ============= Redraws a rectangular part of the background ===========
  628. ======================================================================
  629. Parameters:
  630.   * eax = 15 - function number
  631.   * ebx = 9 - subfunction number
  632.   * ecx = [left]*65536 + [right]
  633.   * edx = [top]*65536 + [bottom]
  634. Returned value:
  635.   * function does not return value
  636. Remarks:
  637.   * (left,top) are coordinates of the left upper corner,
  638.     (right,bottom) are coordinates of the right lower one.
  639.   * If parameters are set incorrectly then background is not redrawn.
  640.  
  641. ---------------------- Constants for registers: ----------------------
  642.   eax - SF_BACKGROUND_SET (15)
  643.   ebx - SSF_REDRAW_RECT (9)
  644. ======================================================================
  645. =============== Function 16 - save ramdisk on a floppy. ==============
  646. ======================================================================
  647. Parameters:
  648.   * eax = 16 - function number
  649.   * ebx = 1 or ebx = 2 - on which floppy save
  650. Returned value:
  651.   * eax = 0 - success
  652.   * eax = 1 - error
  653.  
  654. ---------------------- Constants for registers: ----------------------
  655.   eax - SF_RD_TO_FLOPPY (16)
  656. ======================================================================
  657. ======= Function 17 - get the identifier of the pressed button. ======
  658. ======================================================================
  659. Takes away the code of the pressed button from the buffer.
  660. Parameters:
  661.   * eax = 17 - function number
  662. Returned value:
  663.   * if the buffer is empty, function returns eax=1
  664.   * if the buffer is not empty:
  665.     * high 24 bits of eax contain button identifier (in particular,
  666.       ah contains low byte of the identifier; if all buttons have
  667.       the identifier less than 256, ah is enough to distinguish)
  668.     * al = 0 - the button was pressed with left mouse button
  669.     * al = bit corresponding to used mouse button otherwise
  670. Remarks:
  671.   * "Buffer" keeps only one button, at pressing the new button the
  672.     information about old is lost.
  673.   * The call of this function by an application with inactive window
  674.     will return answer "buffer is empty".
  675.   * Returned value for al corresponds to the state of mouse buttons
  676.     as in subfunction 2 of function 37 at the beginning
  677.     of button press, excluding lower bit, which is cleared.
  678.  
  679. ---------------------- Constants for registers: ----------------------
  680.   eax - SF_GET_BUTTON (17)
  681. ======================================================================
  682. ===================== Function 18, subfunction 1 =====================
  683. ============= Make deactive the window of the given thread. ==========
  684. ======================================================================
  685. Parameters:
  686.   * eax = 18 - function number
  687.   * ebx = 1 - subfunction number
  688.   * ecx = number of the thread slot
  689. Returned value:
  690.   * function does not return value
  691.  
  692. ---------------------- Constants for registers: ----------------------
  693.   eax - SF_SYSTEM (18)
  694.   ebx - SSF_UNFOCUS_WINDOW (1)
  695. ======================================================================
  696. = Function 18, subfunction 2 - terminate process/thread by the slot. =
  697. ======================================================================
  698. Parameters:
  699.   * eax = 18 - function number
  700.   * ebx = 2 - subfunction number
  701.   * ecx = number of the slot of process/thread
  702. Returned value:
  703.   * function does not return value
  704. Remarks:
  705.   * It is impossible to terminate system thread OS/IDLE (with
  706.     number of the slot 1),
  707.     it is possible to terminate any normal process/thread.
  708.   * See also subfunction 18 - terminate
  709.     process/thread by the identifier.
  710.  
  711. ---------------------- Constants for registers: ----------------------
  712.   eax - SF_SYSTEM (18)
  713.   ebx - SSF_TERMINATE_THREAD (2)
  714. ======================================================================
  715. ===================== Function 18, subfunction 3 =====================
  716. ============= Make active the window of the given thread. ============
  717. ======================================================================
  718. Parameters:
  719.   * eax = 18 - function number
  720.   * ebx = 3 - subfunction number
  721.   * ecx = number of the thread slot
  722. Returned value:
  723.   * function does not return value
  724. Remarks:
  725.   * If correct, but nonexistent slot is given,
  726.     some window is made active.
  727.   * To find out, which window is active, use subfunction 7.
  728.  
  729. ---------------------- Constants for registers: ----------------------
  730.   eax - SF_SYSTEM (18)
  731.   ebx - SSF_FOCUS_WINDOW (3)
  732. ======================================================================
  733. ===================== Function 18, subfunction 4 =====================
  734. =========== Get counter of idle time units per one second. ===========
  735. ======================================================================
  736. Idle time units are units, in which the processor stands idle
  737. in waiting for interrupt (in the command 'hlt').
  738.  
  739. Parameters:
  740.   * eax = 18 - function number
  741.   * ebx = 4 - subfunction number
  742. Returned value:
  743.   * eax = value of the counter of idle time units per one second
  744.  
  745. ---------------------- Constants for registers: ----------------------
  746.   eax - SF_SYSTEM (18)
  747.   ebx - SSF_GET_IDLE_COUNT (4)
  748. ======================================================================
  749. ========== Function 18, subfunction 5 - get CPU clock rate. ==========
  750. ======================================================================
  751. Parameters:
  752.   * eax = 18 - function number
  753.   * ebx = 5 - subfunction number
  754. Returned value:
  755.   * eax = clock rate (modulo 2^32 clock ticks = 4GHz)
  756.  
  757. ---------------------- Constants for registers: ----------------------
  758.   eax - SF_SYSTEM (18)
  759.   ebx - SSF_GET_CPU_FREQUENCY (5)
  760. ======================================================================
  761.  Function 18, subfunction 6 - save ramdisk to the file on hard drive.
  762. ======================================================================
  763. Parameters:
  764.   * eax = 18 - function number
  765.   * ebx = 6 - subfunction number
  766.   * ecx = pointer to the full path to file
  767.     (for example, "/hd0/1/kolibri/kolibri.img")
  768. Returned value:
  769.   * eax = 0 - success
  770.   * else eax = error code of the file system
  771. Remarks:
  772.   * All folders in the given path must exist, otherwise function
  773.     returns value 5, "file not found".
  774.  
  775. ---------------------- Constants for registers: ----------------------
  776.   eax - SF_SYSTEM (18)
  777.   ebx - SSF_RD_TO_HDD (6)
  778. ======================================================================
  779. =========== Function 18, subfunction 7 - get active window. ==========
  780. ======================================================================
  781. Parameters:
  782.   * eax = 18 - function number
  783.   * ebx = 7 - subfunction number
  784. Returned value:
  785.   * eax = number of the active window
  786.     (number of the slot of the thread with active window)
  787. Remarks:
  788.   * Active window is at the top of the window stack and receives
  789.     messages on all keyboard input.
  790.   * To make a window active, use subfunction 3.
  791.  
  792. ---------------------- Constants for registers: ----------------------
  793.   eax - SF_SYSTEM (18)
  794.   ebx - SSF_GET_ACTIVE_WINDOW (7)
  795. ======================================================================
  796. == Function 18, subfunction 8 - disable/enable the internal speaker. =
  797. ======================================================================
  798. If speaker sound is disabled, all calls to subfunction 55 of
  799. function 55 are ignored. If speaker sound is enabled,
  800. they are routed on builtin speaker.
  801.  
  802. ------------------- Subsubfunction 1 - get status. -------------------
  803. Parameters:
  804.   * eax = 18 - function number
  805.   * ebx = 8 - subfunction number
  806.   * ecx = 1 - number of the subsubfunction
  807. Returned value:
  808.   * eax = 0 - speaker sound is enabled; 1 - disabled
  809.  
  810. ----------------- Subsubfunction 2 - toggle status. ------------------
  811. Toggles states of disable/enable.
  812. Parameters:
  813.   * eax = 18 - function number
  814.   * ebx = 8 - subfunction number
  815.   * ecx = 2 - number of the subsubfunction
  816. Returned value:
  817.   * function does not return value
  818.  
  819. ---------------------- Constants for registers: ----------------------
  820.   eax - SF_SYSTEM (18)
  821.   ebx - SSF_SPEAKER (8)
  822.   ecx - SSSF_GET_STATE (1), SSSF_TOGGLE (2)
  823. ======================================================================
  824. == Function 18, subfunction 9 - system shutdown with the parameter. ==
  825. ======================================================================
  826. Parameters:
  827.   * eax = 18 - function number
  828.   * ebx = 9 - subfunction number
  829.   * ecx = parameter:
  830.     * 2 = turn off computer
  831.     * 3 = reboot computer
  832.     * 4 = restart the kernel from the file 'kernel.mnt' on ramdisk
  833. Returned value:
  834.   * at incorrect ecx the registers do not change (i.e. eax=18)
  835.   * by correct call function always returns eax=0
  836.     as the tag of success
  837. Remarks:
  838.   * Do not rely on returned value by incorrect call, it can be
  839.     changed in future versions of the kernel.
  840.  
  841. ---------------------- Constants for registers: ----------------------
  842.   eax - SF_SYSTEM (18)
  843.   ebx - SSF_SHUTDOWN (9)
  844. ======================================================================
  845. ======= Function 18, subfunction 10 - minimize topmost window. =======
  846. ======================================================================
  847. Minimizes the topmost (active) window.
  848. Parameters:
  849.   * eax = 18 - function number
  850.   * ebx = 10 - subfunction number
  851. Returned value:
  852.   * function does not return value
  853. Remarks:
  854.   * The minimized window from the point of view of function 9
  855.     keeps position and sizes.
  856.   * Restoring of an application window occurs at its activation by
  857.     subfunction 3.
  858.   * Usually there is no necessity to minimize/restore a window
  859.     explicitly: minimization of a window is carried out by the system
  860.     at pressing the minimization button (for skinned windows
  861.     it is defined automatically by function 0,
  862.     for other windows it can be defined manually by function 8),
  863.     restore of a window is done by the application '@taskbar'.
  864.  
  865. ---------------------- Constants for registers: ----------------------
  866.   eax - SF_SYSTEM (18)
  867.   ebx - SSF_MINIMIZE_WINDOW (10)
  868. ======================================================================
  869.  Function 18, subfunction 11 - get information on the disk subsystem.
  870. ======================================================================
  871. Parameters:
  872.   * eax = 18 - function number
  873.   * ebx = 11 - subfunction number
  874.   * ecx = type of the table:
  875.     * 1 = short version, 16 bytes
  876.   * edx = pointer to the buffer (in the application) for the table
  877. Returned value:
  878.   * function does not return value
  879. Format of the table: short version:
  880.   * +0: byte: information about FDD's (drives for floppies),
  881.     AAAABBBB, where AAAA gives type of the first drive, BBBB -
  882.     of the second regarding to the following list:
  883.     * 0 = there is no drive
  884.     * 1 = 360Kb, 5.25''
  885.     * 2 = 1.2Mb, 5.25''
  886.     * 3 = 720Kb, 3.5''
  887.     * 4 = 1.44Mb, 3.5''
  888.     * 5 = 2.88Mb, 3.5'' (such drives are not used anymore)
  889.     For example, for the standard configuration from one 1.44-drive
  890.     here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B:
  891.     the value is 24h.
  892.  
  893.   First IDE controller:
  894.   * +1: byte: information about hard disks and CD-drives, AABBCCDD,
  895.     where AA corresponds to the controller IDE0, ..., DD - IDE3:
  896.     * 0 = device not found
  897.     * 1 = hard drive
  898.     * 2 = CD-drive
  899.     For example, in the case HD on IDE0 and CD on IDE2
  900.     this field contains 48h.
  901.   * +2: 4 db: number of the retrieved partitions on hard disks
  902.     at accordingly IDE0,...,IDE3.
  903.  
  904.   Second IDE controller:
  905.   * +6: byte: information about hard disks and CD-drives, AABBCCDD,
  906.     where AA corresponds to the controller IDE4, ..., DD - IDE7:
  907.     * 0 = device not found
  908.     * 1 = hard drive
  909.     * 2 = CD-drive
  910.     For example, in the case HD on IDE4 and CD on IDE6
  911.     this field contains 48h.
  912.   * +7: 4 db: number of the retrieved partitions on hard disks
  913.     at accordingly IDE4,...,IDE7.
  914.  
  915.   Third IDE controller:
  916.   * +11: byte: information about hard disks and CD-drives, AABBCCDD,
  917.     where AA corresponds to the controller IDE8, ..., DD - IDE11:
  918.     * 0 = device not found
  919.     * 1 = hard drive
  920.     * 2 = CD-drive
  921.     For example, in the case HD on IDE8 and CD on IDE10
  922.     this field contains 48h.
  923.   * +12: 4 db: number of the retrieved partitions on hard disks
  924.     at accordingly IDE8,...,IDE11.
  925.  
  926.     If the hard disk on IDEx is absent, appropriate byte is zero,
  927.     otherwise it shows number of the recognized partitions, which
  928.     can be not presented (if the drive is not formatted or if
  929.     the file system is not supported). Current version of the kernel
  930.     supports only FAT12/16/32, NTFS, ext2/3/4 and XFS for hard disks.
  931.  
  932. Remarks:
  933.   * The table can be used for obtaining the information about
  934.     available devices.
  935.  
  936. ---------------------- Constants for registers: ----------------------
  937.   eax - SF_SYSTEM (18)
  938.   ebx - SSF_INFO_DISC_SYS (11)
  939. ======================================================================
  940. ========== Function 18, subfunction 13 - get kernel version. =========
  941. ======================================================================
  942. Parameters:
  943.   * eax = 18 - function number
  944.   * ebx = 13 - subfunction number
  945.   * ecx = pointer to the buffer (not less than 16 bytes), where
  946.     the information will be placed
  947. Returned value:
  948.   * function does not return value
  949. Structure of the buffer:
  950. db a,b,c,d for version a.b.c.d
  951. db 0: reserved
  952. dd REV - kernel SVN revision number
  953. For Kolibri 0.7.7.0+ kernel:
  954. db 0,7,7,0
  955. db 0
  956. dd 1675
  957.  
  958. ---------------------- Constants for registers: ----------------------
  959.   eax - SF_SYSTEM (18)
  960.   ebx - SSF_KERNEL_VERSION (13)
  961. ======================================================================
  962. ======= Function 18, subfunction 14 - wait for screen retrace. =======
  963. ======================================================================
  964. Waits for the beginning of retrace of the scanning ray of the screen
  965. monitor.
  966. Parameters:
  967.   * eax = 18 - function number
  968.   * ebx = 14 - subfunction number
  969. Returned value:
  970.   * eax = 0 as the tag of success
  971. Remarks:
  972.   * Function is intended only for active high-efficiency graphics
  973.     applications; is used for smooth output of a graphics.
  974.  
  975. ---------------------- Constants for registers: ----------------------
  976.   eax - SF_SYSTEM (18)
  977.   ebx - SSF_WAIT_RETRACE (14)
  978. ======================================================================
  979. == Function 18, subfunction 15 - center mouse cursor on the screen. ==
  980. ======================================================================
  981. Parameters:
  982.   * eax = 18 - function number
  983.   * ebx = 15 - subfunction number
  984. Returned value:
  985.   * eax = 0 as the tag of success
  986.  
  987. ---------------------- Constants for registers: ----------------------
  988.   eax - SF_SYSTEM (18)
  989.   ebx - SSF_CURSOR_CENTER (15)
  990. ======================================================================
  991. ========= Function 18, subfunction 16 - get size of free RAM. ========
  992. ======================================================================
  993. Parameters:
  994.   * eax = 18 - function number
  995.   * ebx = 16 - subfunction number
  996. Returned value:
  997.   * eax = size of free memory in kilobytes
  998.  
  999. ---------------------- Constants for registers: ----------------------
  1000.   eax - SF_SYSTEM (18)
  1001.   ebx - SSF_GET_FREE_RAM (16)
  1002. ======================================================================
  1003. ======== Function 18, subfunction 17 - get full amount of RAM. =======
  1004. ======================================================================
  1005. Parameters:
  1006.   * eax = 18 - function number
  1007.   * ebx = 17 - subfunction number
  1008. Returned value:
  1009.   * eax = total size of existing memory in kilobytes
  1010.  
  1011. ---------------------- Constants for registers: ----------------------
  1012.   eax - SF_SYSTEM (18)
  1013.   ebx - SSF_GET_TOTAL_RAM (17)
  1014. ======================================================================
  1015. ===================== Function 18, subfunction 18 ====================
  1016. ============= Terminate process/thread by the identifier. ============
  1017. ======================================================================
  1018. Parameters:
  1019.   * eax = 18 - function number
  1020.   * ebx = 18 - subfunction number
  1021.   * ecx = identifer of process/thread (PID/TID)
  1022. Returned value:
  1023.   * eax = 0 - success
  1024.   * eax = -1 - error (process is not found or is system)
  1025. Remarks:
  1026.   * It is impossible to terminate system thread OS/IDLE (identifier
  1027.     1), it is possible to terminate any normal process/thread.
  1028.   * See also subfunction 2 - terminate
  1029.     process/thread by given slot.
  1030.  
  1031. ---------------------- Constants for registers: ----------------------
  1032.   eax - SF_SYSTEM (18)
  1033.   ebx - SSF_TERMINATE_THREAD_ID (18)
  1034. ======================================================================
  1035. ======== Function 18, subfunction 19 - get/set mouse features. =======
  1036. ======================================================================
  1037.  
  1038. ---------------- Subsubfunction 0 - get mouse speed. -----------------
  1039. Parameters:
  1040.   * eax = 18 - function number
  1041.   * ebx = 19 - subfunction number
  1042.   * ecx = 0 - subsubfunction number
  1043. Returned value:
  1044.   * eax = current speed divider
  1045.  
  1046. ---------------- Subsubfunction 1 - set mouse speed. -----------------
  1047. Parameters:
  1048.   * eax = 18 - function number
  1049.   * ebx = 19 - subfunction number
  1050.   * ecx = 1 - subsubfunction number
  1051.   * edx = new value for speed divider
  1052. Returned value:
  1053.   * function does not return value
  1054.  
  1055. Remark: recommended speed divider = 4
  1056.  
  1057. -------------- Subsubfunction 2 - get mouse sensitivity --------------
  1058. Parameters:
  1059.   * eax = 18 - function number
  1060.   * ebx = 19 - subfunction number
  1061.   * ecx = 2 - subsubfunction number
  1062. Returned value:
  1063.   * eax = current sensitivity
  1064.  
  1065. -------------- Subsubfunction 3 - set mouse sensitivity --------------
  1066. Parameters:
  1067.   * eax = 18 - function number
  1068.   * ebx = 19 - subfunction number
  1069.   * ecx = 3 - subsubfunction number
  1070.   * edx = new value for sensitivity
  1071. Returned value:
  1072.   * function does not return value
  1073.  
  1074. Remark: recommended sensitivity = 3
  1075.  
  1076. ----------- Subsubfunction 4 - set mouse pointer position. -----------
  1077. Parameters:
  1078.   * eax = 18 - function number
  1079.   * ebx = 19 - subfunction number
  1080.   * ecx = 4 - subsubfunction number
  1081.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  1082. Returned value:
  1083.   * function does not return value
  1084.  
  1085. -------- Subsubfunction 5 - simulate state of mouse buttons. ---------
  1086. Parameters:
  1087.   * eax = 18 - function number
  1088.   * ebx = 19 - subfunction number
  1089.   * ecx = 5 - subsubfunction number
  1090.   * edx = information about emulated state of mouse buttons:
  1091.     (same as return value in subfunction 2 of function 37)
  1092.     * bit 0 is set = left button is pressed
  1093.     * bit 1 is set = right button is pressed
  1094.     * bit 2 is set = middle button is pressed
  1095.     * bit 3 is set = 4th button is pressed
  1096.     * bit 4 is set = 5th button is pressed
  1097. Returned value:
  1098.   * function does not return value
  1099.  
  1100. -------------- Subsubfunction 6 - get doubleclick delay. -------------
  1101. Parameters:
  1102.   * eax = 18 - function number
  1103.   * ebx = 19 - subfunction number
  1104.   * ecx = 6 - subsubfunction number
  1105. Returned value:
  1106.   * eax = current doubleclick delay (100 = 1 second)
  1107.  
  1108. -------------- Subsubfunction 7 - set doubleclick delay. -------------
  1109. Parameters:
  1110.   * eax = 18 - function number
  1111.   * ebx = 19 - subfunction number
  1112.   * ecx = 7 - subsubfunction number
  1113.   * dl  = new value for doubleclick delay (100 = 1 second)
  1114. Returned value:
  1115.   * function does not return value
  1116.  
  1117. Remark: mouse settings can be modified in the application mouse_cfg.
  1118.  
  1119. ---------------------- Constants for registers: ----------------------
  1120.   eax - SF_SYSTEM (18)
  1121.   ebx - SSF_MOUSE_SETTINGS (19)
  1122.   ecx - SSSF_GET_SPEED (0), SSSF_SET_SPEED (1), SSSF_GET_SPEEDUP (2),
  1123.     SSSF_SET_SPEEDUP (3), SSSF_SET_POS (4), SSSF_SET_BUTTON (5),
  1124.     SSSF_GET_DOUBLE_CLICK_DELAY (6), SSSF_SET_DOUBLE_CLICK_DELAY (7)
  1125. ======================================================================
  1126. ======== Function 18, subfunction 20 - get information on RAM. =======
  1127. ======================================================================
  1128. Parameters:
  1129.   * eax = 18 - function number
  1130.   * ebx = 20 - subfunction number
  1131.   * ecx = pointer to the buffer for information (36 bytes)
  1132. Returned value:
  1133.   * eax = total size of existing RAM in pages
  1134.     or -1 if error has occured
  1135.   * buffer pointed to by ecx contains the following information:
  1136.     * +0:  dword: total size of existing RAM in pages
  1137.     * +4:  dword: size of free RAM in pages
  1138.     * +8:  dword: number of page faults (exceptions #PF)
  1139.                  in applications
  1140.     * +12: dword: size of kernel heap in bytes
  1141.     * +16: dword: free in kernel heap in bytes
  1142.     * +20: dword: total number of memory blocks in kernel heap
  1143.     * +24: dword: number of free memory blocks in kernel heap
  1144.     * +28: dword: size of maximum free block in kernel heap
  1145.                  (reserved)
  1146.     * +32: dword: size of maximum allocated block in kernel heap
  1147.                  (reserved)
  1148.  
  1149. ---------------------- Constants for registers: ----------------------
  1150.   eax - SF_SYSTEM (18)
  1151.   ebx - SSF_GET_RAM_INFO (20)
  1152. ======================================================================
  1153. ===================== Function 18, subfunction 21 ====================
  1154. ======== Get slot number of process/thread by the identifier. ========
  1155. ======================================================================
  1156. Parameters:
  1157.   * eax = 18 - function number
  1158.   * ebx = 21 - subfunction number
  1159.   * ecx = identifer of process/thread (PID/TID)
  1160. Returned value:
  1161.   * eax = 0 - error (invalid identifier)
  1162.   * otherwise eax = slot number
  1163.  
  1164. ---------------------- Constants for registers: ----------------------
  1165.   eax - SF_SYSTEM (18)
  1166.   ebx - SSF_GET_THREAD_SLOT (21)
  1167. ======================================================================
  1168. ===================== Function 18, subfunction 22 ====================
  1169. ============== Operations with window of another thread. =============
  1170. ======================================================================
  1171. Parameters:
  1172.   * eax = 18 - function number
  1173.   * ebx = 22 - subfunction number
  1174.   * ecx = operation type:
  1175.     * 0 = minimize window of the thread with given slot number
  1176.     * 1 = minimize window of the thread with given identifier
  1177.     * 2 = restore window of the thread with given slot number
  1178.     * 3 = restore window of the thread with given identifier
  1179.   * edx = parameter (slot number or PID/TID)
  1180. Returned value:
  1181.   * eax = 0 - success
  1182.   * eax = -1 - error (invalid identifier)
  1183. Remarks:
  1184.   * The thread can minimize its window with subfunction 10.
  1185.   * One can restore and activate window simultaneously with
  1186.     subfunction 3 (which requires slot number).
  1187.  
  1188. ---------------------- Constants for registers: ----------------------
  1189.   eax - SF_SYSTEM (18)
  1190.   ebx - SSF_FOREIGN_WINDOW (22)
  1191.   ecx - SSSF_MINIMIZE (0), SSSF_MINIMIZE_ID (1), SSSF_RESTORE (2),
  1192.     SSSF_RESTORE_ID (3)
  1193. ======================================================================
  1194. ======== Function 18, subfunction 23 - minimize all windows. ==========
  1195. ======================================================================
  1196. Parameters:
  1197.   * eax = 18 - function number
  1198.   * ebx = 23 - subfunction number
  1199. Returned value:
  1200.   * eax = 0 - all windows have been minimized before a function call
  1201.   * eax = N - number of windows minimized from function
  1202. Remarks:
  1203.   * Window of special thread (name begin to symbol @) is not minimize.
  1204.  
  1205. ---------------------- Constants for registers: ----------------------
  1206.   eax - SF_SYSTEM (18)
  1207.   ebx - SSF_MINIMIZE_ALL (23)
  1208. ======================================================================
  1209. ======= Function 18, subfunction 24 - set limits of screen. ==========
  1210. ======================================================================
  1211. Parameters:
  1212.   * eax = 18 - function number
  1213.   * ebx = 24 - subfunction number
  1214.   * ecx = new X size
  1215.   * edx = new Y size
  1216. Returned value:
  1217.   * function does not return value
  1218. Remarks:
  1219.   * The function does not change the physical size of the video mode.
  1220.     It is designed for non-standard displays which display the image
  1221.     partially.
  1222.   * The sizes specified in the function should not exceed the sizes
  1223.     of the current video mode, otherwise the function will not change
  1224.     anything.
  1225.  
  1226. ---------------------- Constants for registers: ----------------------
  1227.   eax - SF_SYSTEM (18)
  1228.   ebx - SSF_SET_SCREEN_LIMITS (24)
  1229. ======================================================================
  1230. ===================== Function 18, subfunction 25 ====================
  1231. ===== Control position of the window relative to other windows. ======
  1232. ======================================================================
  1233.  
  1234. ------------- Subsubfunction 1 - get position  -----------------------
  1235. Parameters:
  1236.   * eax = 18 - function number
  1237.   * ebx = 25 - subfunction number
  1238.   * ecx = 1 - subsubfunction number
  1239.   * edx = -1(for current window) or PID application
  1240. Returned value:
  1241.   * eax = one of the constants window position
  1242.  
  1243. ------------- Subsubfunction 2 - set position  -----------------------
  1244. Parameters:
  1245.   * eax = 18 - function number
  1246.   * ebx = 25 - subfunction number
  1247.   * ecx = 2 - subsubfunction number
  1248.   * edx = -1(for current window) or PID application
  1249.   * esi = new window position (one of the constants below)
  1250. Returned value:
  1251.   * eax = 0 - error
  1252.   * eax = 1 - success
  1253.  
  1254. Constant position of the window relative to other windows:
  1255.  ZPOS_DESKTOP     = -2 - on the background
  1256.  ZPOS_ALWAYS_BACK = -1 - behind all the windows
  1257.  ZPOS_NORMAL      = 0  - normal
  1258.  ZPOS_ALWAYS_TOP  = 1  - on top of all windows
  1259.  
  1260. ---------------------- Constants for registers: ----------------------
  1261.   eax - SF_SYSTEM (18)
  1262.   ebx - SSF_WINDOW_BEHAVIOR (25)
  1263.   ecx - SSSF_GET_WB (1), SSSF_SET_WB (2)
  1264. ======================================================================
  1265. ==================== Function 20 - MIDI interface. ===================
  1266. ======================================================================
  1267.  
  1268. ----------------------- Subfunction 1 - reset ------------------------
  1269. Parameters:
  1270.   * eax = 20 - function number
  1271.   * ebx = 1 - subfunction number
  1272.  
  1273. -------------------- Subfunction 2 - output byte ---------------------
  1274. Parameters:
  1275.   * eax = 20 - function number
  1276.   * ebx = 2 - subfunction number
  1277.   * cl = byte for output
  1278. Returned value (is the same for both subfunctions):
  1279.   * eax = 0 - success
  1280.   * eax = 1 - base port is not defined
  1281. Remarks:
  1282.   * Previously the base port must be defined by
  1283.     subfunction 1 of function 21.
  1284.  
  1285. ---------------------- Constants for registers: ----------------------
  1286.   eax - SF_MIDI (20)
  1287.   ebx - SSF_RESET (1), SSF_OUTPUT (2)
  1288. ======================================================================
  1289. ======== Function 21, subfunction 1 - set MPU MIDI base port. ========
  1290. ======================================================================
  1291. Parameters:
  1292.   * eax = 21 - function number
  1293.   * ebx = 1 - subfunction number
  1294.   * ecx = number of base port
  1295. Returned value
  1296.   * eax = 0 - success
  1297.   * eax = -1 - erratic number of a port
  1298. Remarks:
  1299.   * Number of a port must satisfy to conditions 0x100<=ecx<=0xFFFF.
  1300.   * The installation of base is necessary for function 20.
  1301.   * To get base port use subfunction 1 of function 26.
  1302.  
  1303. ---------------------- Constants for registers: ----------------------
  1304.   eax - SF_SYSTEM_SET (21)
  1305.   ebx - SSF_MPU_MIDI_BASE (1)
  1306. ======================================================================
  1307. ========== Function 21, subfunction 2 - set keyboard layout. =========
  1308. ======================================================================
  1309. Keyboard layout is used to convert keyboard scancodes to ASCII-codes,
  1310. which will be read by function 2.
  1311. Parameters:
  1312.   * eax = 21 - function number
  1313.   * ebx = 2 - subfunction number
  1314.   * ecx = which layout to set:
  1315.     * 1 = normal layout
  1316.     * 2 = layout at pressed Shift
  1317.     * 3 = layout at pressed Alt
  1318.   * edx = pointer to layout - table of length 128 bytes
  1319. Or:
  1320.   * ecx = 9
  1321.   * dx = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
  1322. Returned value:
  1323.   * eax = 0 - success
  1324.   * eax = 1 - incorrect parameter
  1325. Remarks:
  1326.   * If Alt is pressed, the layout with Alt is used;
  1327.     if Alt is not pressed, but Shift is pressed,
  1328.     the layout with Shift is used;
  1329.     if Alt and Shift are not pressed, but Ctrl is pressed, the normal
  1330.     layout is used and then from the code is subtracted 0x60;
  1331.     if no control key is pressed, the normal layout is used.
  1332.   * To get layout and country identifier use
  1333.     subfunction 2 of function 26.
  1334.   * Country identifier is global system variable, which is not used
  1335.     by the kernel itself; however the application '@taskbar' displays
  1336.     the corresponding icon.
  1337.   * The application @taskbar switches layouts on user request.
  1338.  
  1339. ---------------------- Constants for registers: ----------------------
  1340.   eax - SF_SYSTEM_SET (21)
  1341.   ebx - SSF_KEYBOARD_LAYOUT (2)
  1342. ======================================================================
  1343. ========== Function 21, subfunction 5 - set system language. =========
  1344. ======================================================================
  1345. Parameters:
  1346.   * eax = 21 - function number
  1347.   * ebx = 5 - subfunction number
  1348.   * ecx = system language (1=eng, 2=fi, 3=ger, 4=rus)
  1349. Returned value:
  1350.   * eax = 0
  1351. Remarks:
  1352.   * System language is global system variable and is not used
  1353.     by the kernel itself, however application @taskbar draws the
  1354.     appropriate icon.
  1355.   * Function does not check for correctness, as the kernel does not
  1356.     use this variable.
  1357.   * To get system language use subfunction 5 of function 26.
  1358.  
  1359. ---------------------- Constants for registers: ----------------------
  1360.   eax - SF_SYSTEM_SET (21)
  1361.   ebx - SSF_SYS_LANG (5)
  1362. ======================================================================
  1363.  Function 21, subfunction 11 - enable/disable low-level access to HD.
  1364. ======================================================================
  1365. Parameters:
  1366.   * eax = 21 - function number
  1367.   * ebx = 11 - subfunction number
  1368.   * ecx = 0/1 - disable/enable
  1369. Returned value:
  1370.   * eax = 0
  1371. Remarks:
  1372.   * Is used in LBA-read (subfunction 8 of function 58).
  1373.   * The current implementation uses only low bit of ecx.
  1374.   * To get current status use subfunction 11 of function 26.
  1375.  
  1376. ---------------------- Constants for registers: ----------------------
  1377.   eax - SF_SYSTEM_SET (21)
  1378.   ebx - SSF_ACCESS_HD_LBA (11)
  1379. ======================================================================
  1380.  Function 21, subfunction 12 - enable/disable low-level access to PCI.
  1381. ======================================================================
  1382. Parameters:
  1383.   * eax = 21 - function number
  1384.   * ebx = 12 - subfunction number
  1385.   * ecx = 0/1 - disable/enable
  1386. Returned value:
  1387.   * eax = 0
  1388. Remarks:
  1389.   * Is used in operations with PCI bus (function 62).
  1390.   * The current implementation uses only low bit of ecx.
  1391.   * To get current status use subfunction 12 of function 26.
  1392.  
  1393. ---------------------- Constants for registers: ----------------------
  1394.   eax - SF_SYSTEM_SET (21)
  1395.   ebx - SSF_ACCESS_PCI (12)
  1396. ======================================================================
  1397. ================= Function 22 - set system date/time. ================
  1398. ======================================================================
  1399. Parameters:
  1400.   * eax = 22 - function number
  1401.   * ebx = 0 - set time
  1402.     * ecx = 0x00SSMMHH - time in the binary-decimal code (BCD):
  1403.     * HH=hour 00..23
  1404.     * MM=minute 00..59
  1405.     * SS=second 00..59
  1406.   * ebx = 1 - set date
  1407.     * ecx = 0x00DDMMYY - date in the binary-decimal code (BCD):
  1408.     * DD=day 01..31
  1409.     * MM=month 01..12
  1410.     * YY=year 00..99
  1411.   * ebx = 2 - set day of week
  1412.     * ecx = 1 for Sunday, ..., 7 for Saturday
  1413.   * ebx = 3 - set alarm clock
  1414.     * ecx = 0x00SSMMHH
  1415. Returned value:
  1416.   * eax = 0 - success
  1417.   * eax = 1 - incorrect parameter
  1418.   * eax = 2 - CMOS-battery was unloaded
  1419. Remarks:
  1420.   * Value of installation of day of week seems to be doubtful,
  1421.     as it a little where is used
  1422.     (day of week can be calculated by date).
  1423.   * Alarm clock can be set on operation in the given time every day.
  1424.     But there is no existing system function to disable it.
  1425.   * Operation of alarm clock consists in generation IRQ8.
  1426.   * Generally CMOS supports for alarm clock set of value 0xFF
  1427.     as one of parameters and it means that the appropriate parameter
  1428.     is ignored. But current implementation does not allow this
  1429.     (will return 1).
  1430.   * Alarm clock is a global system resource; the set of
  1431.     an alarm clock cancels automatically the previous set.
  1432.     However, at moment no program uses it.
  1433.  
  1434. ---------------------- Constants for registers: ----------------------
  1435.   eax - SF_SET_TIME_DATE (22)
  1436. ======================================================================
  1437. ============= Function 23 - wait for event with timeout. =============
  1438. ======================================================================
  1439. If the message queue is empty, waits for new message in the queue,
  1440. but no more than given time. Then reads out a message from the queue.
  1441.  
  1442. Parameters:
  1443.   * eax = 23 - function number
  1444.   * ebx = timeout (in 1/100 of second)
  1445. Returned value:
  1446.   * eax = 0 - the message queue is empty
  1447.   * otherwise eax = event (see the list of events)
  1448. Remarks:
  1449.   * Only those events are taken into account, which enter into
  1450.     the mask set by function 40. By default it is
  1451.     redraw, key and button events.
  1452.   * To check for presence of a message in the queue use function 11.
  1453.     To wait without timeout use function 10.
  1454.   * Transmission ebx=0 results in immediate returning eax=0.
  1455.   * Current implementation returns immediately with eax=0,
  1456.     if the addition of ebx with the current value of time counter
  1457.     makes 32-bit overflow.
  1458.  
  1459. ---------------------- Constants for registers: ----------------------
  1460.   eax - SF_WAIT_EVENT_TIMEOUT (23)
  1461. ======================================================================
  1462. ======= Function 24, subfunction 4 - eject tray of disk drive. =======
  1463. ======================================================================
  1464. Parameters:
  1465.   * eax = 24 - function number
  1466.   * ebx = 4 - subfunction number
  1467.   * ecx = position of CD/DVD-drive
  1468.     from 0=Primary Master to 3=Secondary Slave for first IDE contr.
  1469.     from 4=Primary Master to 7=Secondary Slave for second IDE contr.
  1470.     from 8=Primary Master to 11=Secondary Slave for third IDE contr.
  1471. Returned value:
  1472.   * function does not return value
  1473. Remarks:
  1474.   * The function is supported only for ATAPI devices (CD and DVD).
  1475.   * When the tray is being ejected,
  1476.     manual control of tray is unlocked.
  1477.   * When the tray is being ejected, the code clears the cache for
  1478.     corresponding device.
  1479.   * An example of usage of the function is the application CD_tray.
  1480.  
  1481. ---------------------- Constants for registers: ----------------------
  1482.   eax - SF_CD (24)
  1483.   ebx - SSF_EJECT_TRAY (4), SSF_INSERT_TRAY (5)
  1484. ======================================================================
  1485. ======== Function 24, subfunction 5 - load tray of disk drive. =======
  1486. ======================================================================
  1487. Parameters:
  1488.   * eax = 24 - function number
  1489.   * ebx = 5 - subfunction number
  1490.   * ecx = position of CD/DVD-drive
  1491.     from 0=Primary Master to 3=Secondary Slave for first IDE contr.
  1492.     from 4=Primary Master to 7=Secondary Slave for second IDE contr.
  1493.     from 8=Primary Master to 11=Secondary Slave for third IDE contr.
  1494. Returned value:
  1495.   * function does not return value
  1496. Remarks:
  1497.   * The function is supported only for ATAPI devices (CD and DVD).
  1498.   * An example of usage of the function is the application CD_tray.
  1499.  
  1500. ---------------------- Constants for registers: ----------------------
  1501.   eax - SF_CD (24)
  1502.   ebx - SSF_EJECT_TRAY (4), SSF_INSERT_TRAY (5)
  1503. ======================================================================
  1504. ======= Function 25 - put image area on the background layer. ========
  1505. ======================================================================
  1506. Paramters:
  1507.   * eax = 25 - function number
  1508.   * ebx = pointer to the previously allocated memory area,
  1509.         where placed the source images in a format BBGGRRTTBBGGRRTT...
  1510.   * ecx = [size on axis x]*65536 + [size on axis y]
  1511.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  1512. Returned value:
  1513.   * function does not return value
  1514. Remarks:
  1515.   * Coordinates of the image are coordinates of the upper left corner
  1516.     of the image relative to the screen.
  1517.   * Size of the image in bytes is 4*xsize*ysize
  1518.   * TT - byte pointer of transparency, at current version:
  1519.          1 to FF - opaque, 0 - transparent.
  1520.   * The function places the image directly to LFB. It is not for
  1521.     background image f.15. Options f.15 to f.25 does not make sense.
  1522.  
  1523. ---------------------- Constants for registers: ----------------------
  1524.   eax - SF_SCREEN_PUT_IMAGE (25)
  1525. ======================================================================
  1526. ======== Function 26, subfunction 1 - get MPU MIDI base port. ========
  1527. ======================================================================
  1528. Parameters:
  1529.   * eax = 26 - function number
  1530.   * ebx = 1 - subfunction number
  1531. Returned value:
  1532.   * eax = port number
  1533. Parameters:
  1534.   * To set base port use subfunction 1 of function 21.
  1535.  
  1536. ---------------------- Constants for registers: ----------------------
  1537.   eax - SF_SYSTEM_GET (26)
  1538.   ebx - SSF_MPU_MIDI_BASE (1)
  1539. ======================================================================
  1540. ========== Function 26, subfunction 2 - get keyboard layout. =========
  1541. ======================================================================
  1542. The keyboard layout is used to convert keyboard scancodes to
  1543. ASCII-codes for function 2.
  1544. Parameters:
  1545.   * eax = 26 - function number
  1546.   * ebx = 2 - subfunction number
  1547.   * ecx = what layout to get:
  1548.     * 1 = normal layout
  1549.     * 2 = layout with pressed Shift
  1550.     * 3 = layout with pressed Alt
  1551.   * edx = pointer to the 128-bytes buffer, where the layout will be
  1552.     copied
  1553. Returned value:
  1554.   * function does not return value
  1555. Or:
  1556.   * eax = 26 - function number
  1557.   * ebx = 2 - subfunction number
  1558.   * ecx = 9
  1559. Returned value:
  1560.   * eax = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
  1561. Remarks:
  1562.   * If Alt is pressed, the layout with Alt is used;
  1563.     if Alt is not pressed, but Shift is pressed,
  1564.     the layout with Shift is used;
  1565.     if Alt and Shift are not pressed, but Ctrl is pressed, the normal
  1566.     layout is used and then from the code is subtracted 0x60;
  1567.     if no control key is pressed, the normal layout is used.
  1568.   * To set layout and country identifier use
  1569.     subfunction 2 of function 21.
  1570.   * Country identifier is global system variable, which is not used
  1571.     by the kernel itself; however the application '@taskbar' displays
  1572.     the corresponding icon (using this function).
  1573.   * The application @taskbar switches layouts on user request.
  1574.  
  1575. ---------------------- Constants for registers: ----------------------
  1576.   eax - SF_SYSTEM_GET (26)
  1577.   ebx - SSF_KEYBOARD_LAYOUT (2)
  1578. ======================================================================
  1579. ========== Function 26, subfunction 5 - get system language. =========
  1580. ======================================================================
  1581. Parameters:
  1582.   * eax = 26 - function number
  1583.   * ebx = 5 - subfunction number
  1584. Returned value:
  1585.   * eax = system language (1=eng, 2=fi, 3=ger, 4=rus)
  1586. Remarks:
  1587.   * System language is global system variable and is not used
  1588.     by the kernel itself, however application @taskbar draws the
  1589.     appropriate icon (using this function).
  1590.   * To set system language use subfunction 5 of function 21.
  1591.  
  1592. ---------------------- Constants for registers: ----------------------
  1593.   eax - SF_SYSTEM_GET (26)
  1594.   ebx - SSF_SYS_LANG (5)
  1595. ======================================================================
  1596. === Function 26, subfunction 9 - get the value of the time counter. ==
  1597. ======================================================================
  1598. Parameters:
  1599.   * eax = 26 - function number
  1600.   * ebx = 9 - subfunction number
  1601. Returned value:
  1602.   * eax = number of 1/100s of second, past from the system boot time
  1603. Remarks:
  1604.   * Counter takes modulo 2^32, that correspond to a little more
  1605.     than 497 days.
  1606.   * To get system time use function 3.
  1607.  
  1608. ---------------------- Constants for registers: ----------------------
  1609.   eax - SF_SYSTEM_GET (26)
  1610.   ebx - SSF_TIME_COUNT (9)
  1611. ======================================================================
  1612. ===================== Function 26, subfunction 10 ====================
  1613. ========== Get the value of the high precision time counter. =========
  1614. ======================================================================
  1615. Parameters:
  1616.   * eax = 26 - function number
  1617.   * ebx = 10 - subfunction number
  1618. Returned value:
  1619.   * eax = number of nanoseconds since system boot time (lower DWORD)
  1620.   * edx = number of nanoseconds since system boot time (high DWORD)
  1621. Remarks:
  1622.   * The counter is based on HPET, if HPET is not available, resolution
  1623.     will be reduced to 10 000 000 nanoseconds.
  1624.  
  1625. ---------------------- Constants for registers: ----------------------
  1626.   eax - SF_SYSTEM_GET (26)
  1627.   ebx - SSF_TIME_COUNT_PRO (10)
  1628. ======================================================================
  1629. ===================== Function 26, subfunction 11 ====================
  1630. ========== Find out whether low-level HD access is enabled. ==========
  1631. ======================================================================
  1632. Parameters:
  1633.   * eax = 26 - function number
  1634.   * ebx = 11 - subfunction number
  1635. Returned value:
  1636.   * eax = 0/1 - disabled/enabled
  1637. Remarks:
  1638.   * Is used in LBA read (subfunction 8 of function 58).
  1639.   * To set current state use subfunction 11 of function 21.
  1640.  
  1641. ---------------------- Constants for registers: ----------------------
  1642.   eax - SF_SYSTEM_GET (26)
  1643.   ebx - SSF_ACCESS_HD_LBA (11)
  1644. ======================================================================
  1645. ===================== Function 26, subfunction 12 ====================
  1646. ========== Find out whether low-level PCI access is enabled. =========
  1647. ======================================================================
  1648. Parameters:
  1649.   * eax = 26 - function number
  1650.   * ebx = 12 - subfunction number
  1651. Returned value:
  1652.   * eax = 0/1 - disabled/enabled
  1653. Remarks:
  1654.   * Is used by operations with PCI bus (function 62).
  1655.   * The current implementation uses only low bit of ecx.
  1656.   * To set the current state use subfunction 12 of function 21.
  1657.  
  1658. ---------------------- Constants for registers: ----------------------
  1659.   eax - SF_SYSTEM_GET (26)
  1660.   ebx - SSF_ACCESS_PCI (12)
  1661. ======================================================================
  1662. =================== Function 29 - get system date. ===================
  1663. ======================================================================
  1664. Parameters:
  1665.   * eax = 29 - function number
  1666. Returned value:
  1667.   * eax = 0x00DDMMYY, where
  1668.     (binary-decimal coding, BCD, is used)
  1669.   * YY = two low digits of year (00..99)
  1670.   * MM = month (01..12)
  1671.   * DD = day (01..31)
  1672. Remarks:
  1673.   * To set system date use function 22.
  1674.  
  1675. ---------------------- Constants for registers: ----------------------
  1676.   eax - SF_GET_SYS_DATE (29)
  1677. ======================================================================
  1678. ============= Function 30 - work with the current folder. ============
  1679. ======================================================================
  1680.  
  1681. --------- Subfunction 1 - set current folder for the thread. ---------
  1682. Parameters:
  1683.   * eax = 30 - function number
  1684.   * ebx = 1 - subfunction number
  1685.   * ecx = pointer to string with the path to new current folder,
  1686.     rules of path forming can be found in function 70 description.
  1687. Returned value:
  1688.   * function does not return value
  1689.  
  1690. --------- Subfunction 2 - get current folder for the thread. ---------
  1691. Parameters:
  1692.   * eax = 30 - function number
  1693.   * ebx = 2 - subfunction number
  1694.   * ecx = pointer to buffer
  1695.   * edx = size of buffer
  1696. Returned value:
  1697.   * eax = size of the current folder's name (including terminating 0)
  1698. Remarks:
  1699.   * If the buffer is too small to hold all data, only first (edx-1)
  1700.     bytes are copied and than terminating 0 is inserted.
  1701.   * By default, current folder for the thread is "/rd/1".
  1702.   * At process/thread creation the current folder will be inherited
  1703.     from the parent.
  1704.  
  1705. --- Subfunction 3 - install the add.system directory for the kernel --
  1706. Parameters:
  1707.   * eax = 30 - function number
  1708.   * ebx = 3 - subfunction number
  1709.   * ecx = pointer to a block of data:
  1710.     for cp866 encoding:
  1711. key     rb  64
  1712. path    rb  64
  1713.     for UTF-16LE encoding:
  1714. key     rb  64
  1715.         dw  2
  1716. path    rw  31
  1717.     Example:
  1718. align 64
  1719. key     db  'kolibrios',0   ; key must be in lower case
  1720. align 64
  1721. path    db  'HD0/1',0
  1722.  
  1723. Returned value:
  1724.   * function does not return value
  1725. Remarks:
  1726.   * The function can be called only 1 time for 1 session of the OS.
  1727.   * The key is not affected by encoding.
  1728.  
  1729. ------ Subfunction 4 - get current folder in UTF-16LE encoding. ------
  1730. Parameters:
  1731.   * eax = 30 - function number
  1732.   * ebx = 4 - subfunction number
  1733.   * ecx = pointer to buffer
  1734.   * edx = size of buffer
  1735. Returned value:
  1736.   * eax = number of chars in the buffer (including terminating 0)
  1737. Remarks:
  1738.   * If the buffer is too small to hold all data, only first (edx-2)
  1739.     bytes are copied and than terminating 0 is inserted.
  1740.   * By default, current folder for the thread is "/rd/1".
  1741.   * At process/thread creation the current folder will be inherited
  1742.     from the parent.
  1743.  
  1744. ---------------------- Constants for registers: ----------------------
  1745.   eax - SF_CURRENT_FOLDER (30)
  1746.   ebx - SSF_SET_CF (1), SSF_GET_CF (2), SSF_ADD_SYS_FOLDER (3)
  1747. ======================================================================
  1748. ========= Function 34 - who owner the pixel on the screen. ===========
  1749. ======================================================================
  1750. Parameters:
  1751.   * eax = 34 - function number
  1752.   * ebx = x-coordinate (relative to the display)
  1753.   * ecx = y-coordinate (relative to the display)
  1754.  
  1755. Returned value:
  1756.   * eax = 0x000000XX - owner of pixel the slot window N
  1757.     If incorrect values ebx and ecx then function returns 0
  1758.   * The function takes the value from the area [_WinMapAddress]
  1759.  
  1760. ---------------------- Constants for registers: ----------------------
  1761.   eax - SF_GET_PIXEL_OWNER (34)
  1762. ======================================================================
  1763. ======= Function 35 - read the color of a pixel on the screen. =======
  1764. ======================================================================
  1765. Parameters:
  1766.   * eax = 35
  1767.   * ebx = y*xsize+x, where
  1768.   * (x,y) = coordinates of a pixel (beginning from 0)
  1769.   * xsize = horizontal screen size
  1770. Returned value:
  1771.   * eax = color 0x00RRGGBB
  1772. Remarks:
  1773.   * To get screen sizes use function 14. Pay attention,
  1774.     that it subtracts 1 from both sizes.
  1775.   * There is also direct access (without any system calls)
  1776.     to videomemory through the selector gs. To get parameters of
  1777.     the current videomode, use function 61.
  1778.  
  1779. ---------------------- Constants for registers: ----------------------
  1780.   eax - SF_GET_PIXEL (35)
  1781. ======================================================================
  1782. =================== Function 36 - read screen area. ==================
  1783. ======================================================================
  1784. Paramters:
  1785.   * eax = 36 - function number
  1786.   * ebx = pointer to the previously allocated memory area,
  1787.         where will be placed the image in the format BBGGRRBBGGRR...
  1788.   * ecx = [size on axis x]*65536 + [size on axis y]
  1789.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  1790. Returned value:
  1791.   * function does not return value
  1792. Remarks:
  1793.   * Coordinates of the image are coordinates of the upper left corner
  1794.     of the image relative to the screen.
  1795.   * Size of the image in bytes is 3*xsize*ysize.
  1796.  
  1797. ---------------------- Constants for registers: ----------------------
  1798.   eax - SF_GET_IMAGE (36)
  1799. ======================================================================
  1800. =================== Function 37 - work with mouse. ===================
  1801. ======================================================================
  1802.  
  1803. ---------- Subfunction 0 - screen coordinates of the mouse -----------
  1804. Parameters:
  1805.   * eax = 37 - function number
  1806.   * ebx = 0 - subfunction number
  1807. Returned value:
  1808.   * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
  1809.     (beginning from 0)
  1810.  
  1811. -- Subfunction 1 - coordinates of the mouse relative to the window ---
  1812. Parameters:
  1813.   * eax = 37 - function number
  1814.   * ebx = 1 - subfunction number
  1815. Returned value:
  1816.   * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
  1817.     relative to the application window (beginning from 0)
  1818. Remarks:
  1819.   * The value is calculated by formula (x-xwnd)*65536 + (y-ywnd).
  1820.     If y>=ywnd, the low word is non-negative and contains
  1821.     relative y-coordinate, and the high word - relative x-coordinate
  1822.     (with correct sign). Otherwise the low word is negative and still
  1823.     contains relative y-coordinate, and to the high word
  1824.     1 should be added.
  1825.  
  1826. ------------- Subfunction 2 - states of the mouse buttons ------------
  1827. Parameters:
  1828.   * eax = 37 - function number
  1829.   * ebx = 2 - subfunction number
  1830. Returned value:
  1831.   * eax = bits 0-4 equal to subfunction 3
  1832.  
  1833. ------- Subfunction 3 - states and events of the mouse buttons -------
  1834. Parameters:
  1835.   * eax = 37 - function number
  1836.   * ebx = 3 - subfunction number
  1837. Returned value:
  1838.   * eax contains next information:
  1839.  
  1840. states:
  1841.   * bit 0 is set = left button is held
  1842.   * bit 1 is set = right button is held
  1843.   * bit 2 is set = middle button is held
  1844.   * bit 3 is set = 4th button is held
  1845.   * bit 4 is set = 5th button is held
  1846.  
  1847. events:
  1848.   * bit 8 is set = left button is pressed
  1849.   * bit 9 is set = right button is pressed
  1850.   * bit 10 is set = middle button is pressed
  1851.  
  1852.   * bit 15 is set = vertical scroll is used
  1853.  
  1854.   * bit 16 is set = left button is released
  1855.   * bit 17 is set = right button is released
  1856.   * bit 18 is set = middle button is released
  1857.  
  1858.   * bit 23 is set = horisontal scroll is used
  1859.  
  1860.   * bit 24 is set = doubleclick by left button
  1861.  
  1862. -------------------- Subfunction 4 - load cursor ---------------------
  1863. Parameters:
  1864.   * eax = 37 - function number
  1865.   * ebx = 4 - subfunction number
  1866.   * dx = data source:
  1867.   * dx = LOAD_FROM_FILE = 0 - data in a file
  1868.     * ecx = pointer to full path to the cursor file
  1869.     * the file must be in the format .cur, which is standard for
  1870.       MS Windows, at that of the size 32*32 pixels
  1871.   * dx = LOAD_FROM_MEM = 1 - data of file are already loaded in memory
  1872.     * ecx = pointer to data of the cursor file
  1873.     * the data format is the same as in the previous case
  1874.   * dx = LOAD_INDIRECT = 2 - data in memory
  1875.     * ecx = pointer to cursor image in the format ARGB 32*32 pixels
  1876.     * edx = 0xXXYY0002, where
  1877.       * XX = x-coordinate of cursor hotspot
  1878.       * YY = y-coordinate
  1879.       * 0 <= XX, YY <= 31
  1880. Returned value:
  1881.   * eax = 0 - failed
  1882.   * otherwise eax = cursor handle
  1883.  
  1884. --------------------- Subfunction 5 - set cursor ---------------------
  1885. Sets new cursor for the window of the current thread.
  1886. Parameters:
  1887.   * eax = 37 - function number
  1888.   * ebx = 5 - subfunction number
  1889.   * ecx = cursor handle
  1890. Returned value:
  1891.   * eax = handle of previous cursor
  1892. Remarks:
  1893.   * If the handle is incorrect, the function restores the default
  1894.     cursor (standard arrow). In particular, ecx=0 restores it.
  1895.  
  1896. ------------------- Subfunction 6 - delete cursor --------------------
  1897. Parameters:
  1898.   * eax = 37 - function number
  1899.   * ebx = 6 - subfunction number
  1900.   * ecx = cursor handle
  1901. Returned value:
  1902.   * eax destroyed
  1903. Remarks:
  1904.   * The cursor must be loaded previously by the current thread
  1905.     (with the call to subfunction 4). The function does not delete
  1906.     system cursors and cursors, loaded by another applications.
  1907.   * If the active cursor (set by subfunction 5) is deleted,
  1908.     the system restores the default cursor (standard arrow).
  1909.  
  1910. ------------------ Subfunction 7 - get scroll data -------------------
  1911. Parameters:
  1912.   * eax = 37 - function number
  1913.   * ebx = 7 - subfunction number
  1914. Returned value:
  1915.   * eax = [horizontal offset]*65536 + [vertical offset]
  1916. Remarks:
  1917.   * Scroll data is available for active window only.
  1918.   * Values are zeroed after reading.
  1919.   * Values are signed.
  1920.  
  1921. ---------------------- Constants for registers: ----------------------
  1922.   eax - SF_MOUSE_GET (37)
  1923.   ebx - SSF_SCREEN_POSITION (0), SSF_WINDOW_POSITION (1),
  1924.     SSF_BUTTON (2), SSF_BUTTON_EXT (3), SSF_LOAD_CURSOR (4),
  1925.     SSF_SET_CURSOR (5), SSF_DEL_CURSOR (6), SSF_SCROLL_DATA (7)
  1926. ======================================================================
  1927. ====================== Function 38 - draw line. ======================
  1928. ======================================================================
  1929. Parameters:
  1930.   * eax = 38 - function number
  1931.   * ebx = [start coordinate on axis x]*65536 +
  1932.               [end coordinate on axis x]
  1933.   * ecx = [start coordinate on axis y]*65536 +
  1934.               [end coordinate on axis y]
  1935.   * edx = 0x00RRGGBB - color
  1936.     edx = 0x01xxxxxx - draw inversed line
  1937.           (low 24 bits are ignored)
  1938. Returned value:
  1939.   * function does not return value
  1940. Remarks:
  1941.   * Coordinates are relative to the window.
  1942.   * End point is also drawn.
  1943.  
  1944. ---------------------- Constants for registers: ----------------------
  1945.   eax - SF_DRAW_LINE (38)
  1946. ======================================================================
  1947. == Function 39, subfunction 1 - get a size of the background image. ==
  1948. ======================================================================
  1949. Parameters:
  1950.   * eax = 39 - function number
  1951.   * ebx = 1 - subfunction number
  1952. Returned value:
  1953.   * eax = [width]*65536 + [height]
  1954. Remarks:
  1955.   * There is a pair function to set sizes of background image -
  1956.     subfunction 1 of function 15. After which it is necessary,
  1957.     of course, anew to define image.
  1958.  
  1959. ---------------------- Constants for registers: ----------------------
  1960.   eax - SF_BACKGROUND_GET (39)
  1961. ======================================================================
  1962. == Function 39, subfunction 2 - get pixel from the background image. =
  1963. ======================================================================
  1964. Parameters:
  1965.   * eax = 39 - function number
  1966.   * ebx = 2 - subfunction number
  1967.   * ecx = offset
  1968. Returned value:
  1969.   * eax = 0x00RRGGBB - pixel color, if offset is valid
  1970.     (less than 0x160000-16)
  1971.   * eax = 2 otherwise
  1972. Remarks:
  1973.   * Do not rely on returned value for invalid offsets, it may be
  1974.     changed in future kernel versions.
  1975.   * Offset for pixel with coordinates (x,y)
  1976.     is calculated as (x+y*xsize)*3.
  1977.   * There is a pair function to set pixel on the background image -
  1978.     subfunction 2 of function 15.
  1979.  
  1980. ---------------------- Constants for registers: ----------------------
  1981.   eax - SF_BACKGROUND_GET (39)
  1982. ======================================================================
  1983. == Function 39, subfunction 4 - get drawing mode for the background. =
  1984. ======================================================================
  1985. Parameters:
  1986.   * eax = 39 - function number
  1987.   * ebx = 4 - subfunction number
  1988. Returned value:
  1989.   * eax = 1 - tile
  1990.   * eax = 2 - stretch
  1991. Remarks:
  1992.   * There is a pair function to set drawing mode -
  1993.     subfunction 4 of function 15.
  1994.  
  1995. ---------------------- Constants for registers: ----------------------
  1996.   eax - SF_BACKGROUND_GET (39)
  1997. ======================================================================
  1998. =========== Function 40 - set the mask for expected events. ==========
  1999. ======================================================================
  2000. The mask for expected events affects function working with events
  2001. 10, 11, 23 - they notify only about events allowed by this mask.
  2002. Parameters:
  2003.   * eax = 40 - function number
  2004.   * ebx = mask: bit i corresponds to event i+1 (see list of events)
  2005.     (set bit permits notice on event)
  2006.     bit 31: mouse active/inactive filter
  2007.     bit 31 = 0 - inactive window receive mouse events
  2008.     bit 31 = 1 - inactive window does not receive mouse events
  2009.     bit 30: cursor position filter
  2010.     bit 30 = 0 = the window receive mouse events if cursor
  2011.                  outside window
  2012.     bit 30 = 1 - the window does not receive mouse events if cursor
  2013.                  outside window
  2014. Returned value:
  2015.   * eax = previous value of mask
  2016. Remarks:
  2017.   * Default mask (7=111b) enables nofices about redraw,
  2018.     keys and buttons. This is enough for many applications.
  2019.   * Events prohibited in the mask are saved anyway, when come;
  2020.     they are simply not informed with event functions.
  2021.   * Event functions take into account the mask on moment of
  2022.     function call, not on moment of event arrival.
  2023.  
  2024. ---------------------- Constants for registers: ----------------------
  2025.   eax - SF_SET_EVENTS_MASK (40)
  2026. ======================================================================
  2027. ================ Function 43 - input/output to a port. ===============
  2028. ======================================================================
  2029.  
  2030. ------------------------ Output data to port -------------------------
  2031. Parameters:
  2032.   * eax = 43 - function number
  2033.   * bl = byte for output
  2034.   * ecx = port number 0xnnnn (from 0 to 0xFFFF)
  2035. Returned value:
  2036.   * eax = 0 - success
  2037.   * eax = 1 - the thread has not reserved the selected port
  2038.  
  2039. ------------------------ Input data from port ------------------------
  2040. Parameters:
  2041.   * eax = 43 - function number
  2042.   * ebx is ignored
  2043.   * ecx = 0x8000nnnn, where nnnn = port number (from 0 to 0xFFFF)
  2044. Returned value:
  2045.   * eax = 0 - success, thus ebx = entered byte
  2046.   * eax = 1 - the thread has not reserved the selected port
  2047. Remarks:
  2048.   * Previously the thread must reserve the selected port
  2049.     for itself by function 46.
  2050.   * Instead of call to this function it is better to use
  2051.     processor instructions in/out - this is much
  2052.     faster and a bit shorter and easier.
  2053.  
  2054. ---------------------- Constants for registers: ----------------------
  2055.   eax - SF_PORT_IN_OUT (43)
  2056. ======================================================================
  2057. ====== Function 46 - reserve/free a group of input/output ports. =====
  2058. ======================================================================
  2059. To work with reserved ports an application can access directly by
  2060. commands in/out (recommended way) and can use function 43
  2061. (not recommended way).
  2062. Parameters:
  2063.   * eax = 46 - function number
  2064.   * ebx = 0 - reserve, 1 - free
  2065.   * ecx = start port number
  2066.   * edx = end port number (inclusive)
  2067. Returned value:
  2068.   * eax = 0 - success
  2069.   * eax = 1 - error
  2070. Remarks:
  2071.   * For ports reservation: an error occurs if and only if
  2072.     one from the following condition satisfies:
  2073.     * start port is more than end port;
  2074.     * the selected range contains incorrect port number
  2075.       (correct are from 0 to 0xFFFF);
  2076.     * limit for the total number of reserved areas is exceeded
  2077.       (maximum 255 are allowed);
  2078.     * the selected range intersects with any of earlier reserved
  2079.   * For ports free: an error is an attempt to free range,
  2080.     that was not earlier reserved by this function
  2081.     (with same ecx,edx).
  2082.   * If an error occurs (for both cases) function performs no action.
  2083.   * At booting the system reserves for itself ports
  2084.     0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (inclusively).
  2085.   * When a thread terminates, all reserved by it ports
  2086.     are freed automatically.
  2087.  
  2088. ---------------------- Constants for registers: ----------------------
  2089.   eax - SF_SET_PORTS (46)
  2090. ======================================================================
  2091. ============= Function 47 - draw a number in the window. =============
  2092. ======================================================================
  2093. Parameters:
  2094.   * eax = 47 - function number
  2095.   * ebx = parameters of conversion number to text:
  2096.     * bl = 0 - ecx contains number
  2097.     * bl = 1 - ecx contains pointer to dword/qword-number
  2098.     * bh = 0 - display in decimal number system
  2099.     * bh = 1 - display in hexadecimal system
  2100.     * bh = 2 - display in binary system
  2101.     * bits 16-21 = how many digits to display
  2102.     * bits 22-29 reserved and must be set to 0
  2103.     * bit 30 set = display qword (64-bit) number (must be bl=1)
  2104.     * bit 31 set = do not display leading zeroes of the number
  2105.   * ecx = number (if bl=0) or pointer (if bl=1)
  2106.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  2107.   * esi = 0xXXRRGGBB, where
  2108.     * RR, GG, BB specify text color
  2109.     * XX = 0B0FCSSS (bits):
  2110.       * B=1 - fill background (color = edi)
  2111.       * F specifies the font:
  2112.         0 = 6x9
  2113.         1 = 8x16
  2114.       * C=0 - draw to the window,
  2115.         C=1 - draw to the user buffer (edi)
  2116.       * SSS = (size multiplier)-1, so 0 = x1, 7 = x8
  2117. Returned value:
  2118.   * function does not return value
  2119. Remarks:
  2120.   * The given length must not exceed 60.
  2121.   * The exactly given amount of digits is output. If number is small
  2122.     and can be written by smaller amount of digits, it is supplemented
  2123.     by leading zeroes; if the number is big and can not be written by
  2124.     given amount of digits, extra digits are not drawn.
  2125.  
  2126. ---------------------- Constants for registers: ----------------------
  2127.   eax - SF_DRAW_NUMBER (47)
  2128. ======================================================================
  2129. ========= Function 48, subfunction 0 - apply screen settings. ========
  2130. ======================================================================
  2131. Parameters:
  2132.   * eax = 48 - function number
  2133.   * ebx = 0 - subfunction number
  2134.   * ecx = 0 - reserved
  2135. Returned value:
  2136.   * function does not return value
  2137. Remarks:
  2138.   * Function redraws the screen after parameters change by
  2139.     subfunctions 1 and 2.
  2140.   * Function call without prior call to one of indicated subfunctions
  2141.     is ignored.
  2142.   * Function call with nonzero ecx is ignored.
  2143.  
  2144. ---------------------- Constants for registers: ----------------------
  2145.   eax - SF_STYLE_SETTINGS (48)
  2146.   ebx - SSF_APPLY (0)
  2147. ======================================================================
  2148. =========== Function 48, subfunction 1 - set button style. ===========
  2149. ======================================================================
  2150. Parameters:
  2151.   * eax = 48 - function number
  2152.   * ebx = 1 - subfunction number
  2153.   * ecx = button style:
  2154.     * 0 = flat
  2155.     * 1 = 3d
  2156. Returned value:
  2157.   * function does not return value
  2158. Remarks:
  2159.   * After call to this function one should redraw the screen by
  2160.     subfunction 0.
  2161.   * Button style influences only to their draw of function 8.
  2162.  
  2163. ---------------------- Constants for registers: ----------------------
  2164.   eax - SF_STYLE_SETTINGS (48)
  2165.   ebx - SSF_SET_BUTTON_STYLE (1)
  2166. ======================================================================
  2167. ====== Function 48, subfunction 2 - set standard window colors. ======
  2168. ======================================================================
  2169. Parameters:
  2170.   * eax = 48 - function number
  2171.   * ebx = 2 - subfunction number
  2172.   * ecx = pointer to the color table
  2173.   * edx = size of the color table
  2174.     (must be 40 bytes for future compatibility)
  2175. Format of the color table is shown in description of subfunction 3.
  2176. Returned value:
  2177.   * function does not return value
  2178. Remarks:
  2179.   * After call to this function one should redraw the screen by
  2180.     subfunction 0.
  2181.   * Table of standard colors influences only to applications,
  2182.     which receive this table obviously (by subfunction 3)
  2183.     and use it (specifying colors from it to drawing functions).
  2184.   * Table of standard colors is included in skin and is installed
  2185.     anew with skin installation (by subfunction 8).
  2186.   * Color table can be viewed/changed interactively with
  2187.     the application 'desktop'.
  2188.  
  2189. ---------------------- Constants for registers: ----------------------
  2190.   eax - SF_STYLE_SETTINGS (48)
  2191.   ebx - SSF_SET_COLORS (2)
  2192. ======================================================================
  2193. ====== Function 48, subfunction 3 - get standard window colors. ======
  2194. ======================================================================
  2195. Parameters:
  2196.   * eax = 48 - function number
  2197.   * ebx = 3 - subfunction number
  2198.   * ecx = pointer to the buffer with size edx bytes,
  2199.     where table will be written
  2200.   * edx = size of color table
  2201.     (must be 40 bytes for future compatibility)
  2202. Returned value:
  2203.   * function does not return value
  2204. Format of the color table:
  2205. each item is dword-value for color 0x00RRGGBB
  2206.   * +0: dword: frames - color of frame
  2207.   * +4: dword: grab - color of header
  2208.   * +8: dword: grab_button - color of button on header bar
  2209.   * +12 = +0xC: dword: grab_button_text - color of text on button
  2210.     on header bar
  2211.   * +16 = +0x10: dword: grab_text - color of text on header
  2212.   * +20 = +0x14: dword: work - color of working area
  2213.   * +24 = +0x18: dword: work_button - color of button in working area
  2214.   * +28 = +0x1C: dword: work_button_text - color of text on button
  2215.     in working area
  2216.   * +32 = +0x20: dword: work_text - color of text in working area
  2217.   * +36 = +0x24: dword: work_graph - color of graphics in working area
  2218. Remarks:
  2219.   * Structure of the color table is described in the standard
  2220.     include file 'macros.inc' as 'system_colors'; for example,
  2221.     it is possible to write:
  2222.         sc      system_colors           ; variable declaration
  2223.         ...                             ; somewhere one must call
  2224.                                         ; this function with ecx=sc
  2225.         mov     ecx, [sc.work_button_text]      ; read text color on
  2226.                                         ; buttin in working area
  2227.   * A program itself desides to use or not to use color table.
  2228.     For usage program must simply at calls to drawing functions select
  2229.     color taken from the table.
  2230.   * At change of the table of standard colors (by subfunction 2 with
  2231.     the subsequent application of changes by subfunction 0 or
  2232.     at skin set by subfunction 8) the system sends to all windows
  2233.     redraw message (the event with code 1).
  2234.   * Color table can be viewed/changed interactively with
  2235.     the application 'desktop'.
  2236.  
  2237. ---------------------- Constants for registers: ----------------------
  2238.   eax - SF_STYLE_SETTINGS (48)
  2239.   ebx - SSF_GET_COLORS (3)
  2240. ======================================================================
  2241. ============ Function 48, subfunction 4 - get skin height. ===========
  2242. ======================================================================
  2243. Parameters:
  2244.   * eax = 48 - function number
  2245.   * ebx = 4 - subfunction number
  2246. Returned value:
  2247.   * eax = skin height
  2248. Remarks:
  2249.   * Skin height is defined as the height of a header
  2250.     of skinned windows.
  2251.   * See also general structure of window in the description
  2252.     of function 0.
  2253.  
  2254. ---------------------- Constants for registers: ----------------------
  2255.   eax - SF_STYLE_SETTINGS (48)
  2256.   ebx - SSF_GET_SKIN_HEIGHT (4)
  2257. ======================================================================
  2258. ======== Function 48, subfunction 5 - get screen working area. =======
  2259. ======================================================================
  2260. Parameters:
  2261.   * eax = 48 - function number
  2262.   * ebx = 5 - subfunction number
  2263. Returned value:
  2264.   * eax = [left]*65536 + [right]
  2265.   * ebx = [top]*65536 + [bottom]
  2266. Remarks:
  2267.   * The screen working area defines position and coordinates of
  2268.     a maximized window.
  2269.   * The screen working area in view of normal work is all screen
  2270.     without taskbar ('@taskbar' application).
  2271.   * (left,top) are coordinates of the left upper corner,
  2272.     (right,bottom) are coordinates of the right lower one.
  2273.     Thus the size of working area on x axis can be calculated by
  2274.     formula right-left+1, on y axis - by formula bottom-right+1.
  2275.   * See also function 14,
  2276.     to get sizes of all screen.
  2277.   * There is a pair function to set working area - subfunction 6.
  2278.  
  2279. ---------------------- Constants for registers: ----------------------
  2280.   eax - SF_STYLE_SETTINGS (48)
  2281.   ebx - SSF_GET_SCREEN_AREA (5)
  2282. ======================================================================
  2283. ======== Function 48, subfunction 6 - set screen working area. =======
  2284. ======================================================================
  2285. Parameters:
  2286.   * eax = 48 - function number
  2287.   * ebx = 6 - subfunction number
  2288.   * ecx = [left]*65536 + [right]
  2289.   * edx = [top]*65536 + [bottom]
  2290. Returned value:
  2291.   * function does not return value
  2292. Remarks:
  2293.   * The screen working area defines position and coordinates of
  2294.     a maximized window.
  2295.   * This function is used only by the application '@taskbar',
  2296.     which set working area to all screen without taskbar.
  2297.   * (left,top) are coordinates of the left upper corner,
  2298.     (right,bottom) are coordinates of the right lower one.
  2299.     Thus the size of working area on x axis can be calculated by
  2300.     formula right-left+1, on y axis - by formula bottom-right+1.
  2301.   * If 'left'>='right', x-coordinate of working area is not changed.
  2302.     If 'left'<0, 'left' will not be set. If 'right' is greater than or
  2303.     equal to screen width, 'right' will not be set.
  2304.     Similarly on y axis.
  2305.   * See also function 14,
  2306.     to get sizes of all screen.
  2307.   * There is a pair function to get working area - subfunction 5.
  2308.   * This function redraws the screen automatically,
  2309.     updating coordinates and sizes of maximized windows.
  2310.     The system sends to all windows redraw message (the event 1).
  2311.  
  2312. ---------------------- Constants for registers: ----------------------
  2313.   eax - SF_STYLE_SETTINGS (48)
  2314.   ebx - SSF_SET_SCREEN_AREA (6)
  2315. ======================================================================
  2316. =========== Function 48, subfunction 7 - get skin margins. ===========
  2317. ======================================================================
  2318. Returns the area of a header of a skinned window, intended for
  2319. a text of a header.
  2320. Parameters:
  2321.   * eax = 48 - function number
  2322.   * ebx = 7 - subfunction number
  2323. Returned value:
  2324.   * eax = [left]*65536 + [right]
  2325.   * ebx = [top]*65536 + [bottom]
  2326. Remarks:
  2327.   * An application decides itself to use or not to use this function.
  2328.   * It is recommended to take into account returned value
  2329.     of this function for choice of a place for drawing header text
  2330.     (by function 4) or a substitute of header text
  2331.     (at the discretion of an application).
  2332.  
  2333. ---------------------- Constants for registers: ----------------------
  2334.   eax - SF_STYLE_SETTINGS (48)
  2335.   ebx - SSF_GET_SKIN_MARGINS (7)
  2336. ======================================================================
  2337. ============= Function 48, subfunction 8 - set used skin. ============
  2338. ======================================================================
  2339. Parameters:
  2340.   * eax = 48 - function number
  2341.   * ebx = 8 - subfunction number
  2342.   * ecx = pointer to filename of the skin
  2343. Returned value:
  2344.   * eax = 0 - success
  2345.   * otherwise eax = file system error code; if file does not
  2346.     contain valid skin, function returns error 3
  2347.     (unknown file system).
  2348. Remarks:
  2349.   * After successful skin loading the system sends to all windows
  2350.     redraw message (the event 1).
  2351.   * At booting the system reads skin from file 'default.skn'
  2352.     on ramdisk.
  2353.   * User can change the skin statically by creating hisself
  2354.     'default.skn' or dynamically with the application 'desktop'.
  2355.  
  2356. ---------------------- Constants for registers: ----------------------
  2357.   eax - SF_STYLE_SETTINGS (48)
  2358.   ebx - SSF_SET_SKIN (8)
  2359. ======================================================================
  2360. ====== Function 48, subfunction 9 - get font smoothing setting. ======
  2361. ======================================================================
  2362. Parameters:
  2363.   * eax = 48 - function number
  2364.   * ebx = 9 - subfunction number
  2365. Returned value:
  2366.   * eax = 2 - subpixel, 1 - anti-aliasing, 0 - off
  2367.  
  2368. ---------------------- Constants for registers: ----------------------
  2369.   eax - SF_STYLE_SETTINGS (48)
  2370.   ebx - SSF_GET_FONT_SMOOTH (9)
  2371. ======================================================================
  2372. ========== Function 48, subfunction 10 - set font smoothing. =========
  2373. ======================================================================
  2374. Parameters:
  2375.   * eax = 48 - function number
  2376.   * ebx = 10 - subfunction number
  2377.   * cl  = 2 - subpixel, 1 - anti-aliasing, 0 - off
  2378.  
  2379. ---------------------- Constants for registers: ----------------------
  2380.   eax - SF_STYLE_SETTINGS (48)
  2381.   ebx - SSF_SET_FONT_SMOOTH (10)
  2382. ======================================================================
  2383. ============ Function 48, subfunction 11 - get font size. ============
  2384. ======================================================================
  2385. Parameters:
  2386.   * eax = 48 - function number
  2387.   * ebx = 9 - subfunction number
  2388. Returned value:
  2389.   * eax = current font height in pixels
  2390.  
  2391. ---------------------- Constants for registers: ----------------------
  2392.   eax - SF_STYLE_SETTINGS (48)
  2393.   ebx - SSF_GET_FONT_SIZE (11)
  2394. ======================================================================
  2395. ============ Function 48, subfunction 12 - set font size. ============
  2396. ======================================================================
  2397. Parameters:
  2398.   * eax = 48 - function number
  2399.   * ebx = 10 - subfunction number
  2400.   * cl  = new font height in pixels
  2401.  
  2402. ---------------------- Constants for registers: ----------------------
  2403.   eax - SF_STYLE_SETTINGS (48)
  2404.   ebx - SSF_SET_FONT_SIZE (12)
  2405. ======================================================================
  2406. =========== Function 49 - Advanced Power Management (APM). ===========
  2407. ======================================================================
  2408. Parameters:
  2409.   * eax = 49 - function number
  2410.   * dx = number of the APM function
  2411.     (analogue of ax in APM specification)
  2412.   * bx, cx = parameters of the APM function
  2413. Returned value:
  2414.   * 16-bit registers ax, bx, cx, dx, si, di and carry flag CF
  2415.     are set according to the APM specification
  2416.   * high halves of 32-bit registers eax, ebx, ecx,
  2417.     edx, esi, edi are destroyed
  2418. Remarks:
  2419.   * APM 1.2 specification is described in the document
  2420.     "Advanced Power Management (APM) BIOS Specification"
  2421.     (Revision 1.2), available at
  2422.     http://www.microsoft.com/whdc/archive/amp_12.mspx;
  2423.     besides it is included in famous Interrupt List by Ralf Brown
  2424.     (http://www.pobox.com/~ralf/files.html,
  2425.     ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/).
  2426.  
  2427. ---------------------- Constants for registers: ----------------------
  2428.   eax - SF_APM (49)
  2429. ======================================================================
  2430. =================== Function 50 - set window shape. ==================
  2431. ======================================================================
  2432. Normal windows have rectangular shape. This function can give to
  2433. a window any shape. The shape is given by a set of points inside
  2434. the base rectangle belonging to a window. Position and coordinates
  2435. of the base rectangle are set by function 0
  2436. and changed by function 67.
  2437.  
  2438. --------------------------- Set shape data ---------------------------
  2439. Parameters:
  2440.   * eax = 50 - function number
  2441.   * ebx = 0 - subfunction number
  2442.   * ecx = pointer to shape data (array of bytes 0/1)
  2443. Returned value:
  2444.   * function does not return value
  2445.  
  2446. -------------------------- Set shape scale ---------------------------
  2447. Parameters:
  2448.   * eax = 50 - function number
  2449.   * ebx = 1 - subfunction number
  2450.   * ecx sets a scale: each byte of data defines
  2451.     (2^scale)*(2^scale) pixels
  2452. Returned value:
  2453.   * function does not return value
  2454. Remarks:
  2455.   * Default scale is 0 (scale factor is 1). If in the shape data
  2456.     one byte corresponds to one pixel, there is no necessity
  2457.     to set scale.
  2458.   * Let's designate xsize = window width (in pixels), ysize = height;
  2459.     pay attention, that they are one pixel more than defined by
  2460.     functions 0, 67.
  2461.   * On definition of scale xsize and ysize must be divisible
  2462.     on 2^scale.
  2463.   * Byte of data on offset 'a' must be 0/1 and defines belonging
  2464.     to a window of square with the side 2^scale (if scale=0,
  2465.     this is one pixel) and coordinates of the left upper corner
  2466.     (a mod (xsize shr scale), a div (xsize shr scale))
  2467.   * Data size: (xsize shr scale)*(ysize shr scale).
  2468.   * Data must be presented in the memory and not change
  2469.     after set of shape.
  2470.   * The system views the shape data at every window redraw by
  2471.     function 0.
  2472.   * The call of subfunction 0 with NULL pointer results in return
  2473.     to the rectangular shape.
  2474.  
  2475. ---------------------- Constants for registers: ----------------------
  2476.   eax - SF_SET_WINDOW_SHAPE (50)
  2477. ======================================================================
  2478. ==================== Function 51 - create thread. ====================
  2479. ======================================================================
  2480. Parameters:
  2481.   * eax = 51 - function number
  2482.   * ebx = 1 - unique subfunction
  2483.   * ecx = address of thread entry point (starting eip)
  2484.   * edx = pointer to thread stack (starting esp)
  2485. Returned value:
  2486.   * eax = -1 - error (there is too many threads)
  2487.   * otherwise eax = TID - thread identifier
  2488.  
  2489. ---------------------- Constants for registers: ----------------------
  2490.   eax - SF_CREATE_THREAD (51)
  2491. ======================================================================
  2492. ==================== Function 54, subfunction 0 ======================
  2493. ============== Get the number of slots in the clipboard. =============
  2494. ======================================================================
  2495. Parameters:
  2496.   * eax = 54 - function number
  2497.   * ebx = 0 - subfunction number
  2498. Returned value:
  2499.   * eax = slots in the clipboard
  2500.   * eax = -1 - main list area not found
  2501.  
  2502. ---------------------- Constants for registers: ----------------------
  2503.   eax - SF_CLIPBOARD (54)
  2504.   ebx - SSF_GET_SLOT_COUNT (0)
  2505. ======================================================================
  2506. ==================== Function 54, subfunction 1 ======================
  2507. ================= Read the data from the clipboard. ==================
  2508. ======================================================================
  2509. Parameters:
  2510.   * eax = 54 - function number
  2511.   * ebx = 1 - subfunction number
  2512.   * eсx = slot number
  2513. Returned value:
  2514.   * eax = if successful - pointer to a memory with data
  2515.   * eax = 1 - error
  2516.   * eax = -1 - main list area not found
  2517.  
  2518. ---------------------- Constants for registers: ----------------------
  2519.   eax - SF_CLIPBOARD (54)
  2520.   ebx - SSF_READ_CB (1)
  2521. ======================================================================
  2522. ==================== Function 54, subfunction 2 ======================
  2523. ================= Write the data to the clipboard. ===================
  2524. ======================================================================
  2525. Parameters:
  2526.   * eax = 54 - function number
  2527.   * ebx = 2 - subfunction number
  2528.   * eсx = the number of bytes to be copied
  2529.   * edx = a pointer to a buffer for data to be copied
  2530. Returned value:
  2531.   * eax = 0 - success
  2532.   * eax = 1 - error
  2533.   * eax = -1 - main list area not found
  2534.  
  2535. ---------------------- Constants for registers: ----------------------
  2536.   eax - SF_CLIPBOARD (54)
  2537.   ebx - SSF_WRITE_CB (2)
  2538. ======================================================================
  2539. ===================== Function 54, subfunction 3 =====================
  2540. ================ Delete the last slot in the clipboard ===============
  2541. ======================================================================
  2542. Parameters:
  2543.   * eax = 54 - function number
  2544.   * ebx = 3 - subfunction number
  2545. Returned value:
  2546.   * eax = 0 - success
  2547.   * eax = 1 - error
  2548.   * eax = -1 - main list area not found
  2549.  
  2550. ---------------------- Constants for registers: ----------------------
  2551.   eax - SF_CLIPBOARD (54)
  2552.   ebx - SSF_DEL_SLOT (3)
  2553. ======================================================================
  2554. ===================== Function 54, subfunction 4 =====================
  2555. ===================== Alarm reset the lock buffer ====================
  2556. ======================================================================
  2557. Parameters:
  2558.   * eax = 54 - function number
  2559.   * ebx = 4 - subfunction number
  2560. Returned value:
  2561.   * eax = 0 - success
  2562.   * eax = -1 - main list area not found or no blocking
  2563. Remarks:
  2564.   * Used in exceptional cases, where no responsible or killed
  2565.     application blocked the clipboard operations.
  2566.  
  2567. ---------------------- Constants for registers: ----------------------
  2568.   eax - SF_CLIPBOARD (54)
  2569.   ebx - SSF_UNLOCK_BUFFER (4)
  2570. ======================================================================
  2571.  Function 55, subfunction 55 - begin to play data on built-in speaker.
  2572. ======================================================================
  2573. Parameters:
  2574.   * eax = 55 - function number
  2575.   * ebx = 55 - subfunction number
  2576.   * esi = pointer to data
  2577. Returned value:
  2578.   * eax = 0 - success
  2579.   * eax = 55 - error (speaker is off or busy)
  2580. Data is an array of items with variable length.
  2581. Format of each item is defined by first byte:
  2582.   * 0 = end of data
  2583.   * 1..0x80 = sets sound duration on 1/100 of second; sound note
  2584.     is defined by immediate value of frequency
  2585.     * following word (2 bytes) contains frequency divider;
  2586.       frequency is defined as 1193180/divider
  2587.   * 0x81 = invalid
  2588.   * 0x82..0xFF = note is defined by octave and number:
  2589.     * duration in 1/100 of second = (first byte)-0x81
  2590.     * there is one more byte;
  2591.     * (second byte)=0xFF - delay
  2592.     * otherwise it looks like a*0x10+b, where b=number of the note in
  2593.       an octave from 1 to 12, a=number of octave (beginning from 0)
  2594. Remarks:
  2595.   * Speaker play can be disabled/enabled by
  2596.     subfunction 8 of function 18.
  2597.   * Function returns control, having informed the system
  2598.     an information on request. Play itself goes independently from
  2599.     the program.
  2600.   * The data must be kept in the memory at least up to the end
  2601.     of play.
  2602.  
  2603. ---------------------- Constants for registers: ----------------------
  2604.   eax - SF_SPEAKER_PLAY (55)
  2605. ======================================================================
  2606. ======================= Function 57 - PCI BIOS. ======================
  2607. ======================================================================
  2608. Parameters:
  2609.   * eax = 57 - function number
  2610.   * ebp corresponds to al in PCI BIOS specification
  2611.   * other registers are set according to PCI BIOS specification
  2612. Returned value:
  2613.   * CF is undefined
  2614.   * other registers are set according to PCI BIOS specification
  2615. Remarks:
  2616.   * Many effects of this function can be also achieved with
  2617.     corresponding subfunctions of function 62.
  2618.   * The function calls PCI32 BIOS extension, documented e.g. in
  2619.     http://alpha1.dyns.net/files/PCI/bios21.pdf.
  2620.   * If BIOS does not support this extension, its behavior is emulated
  2621.     (through kernel-mode analogues of subfunctions of function 62).
  2622.  
  2623. ---------------------- Constants for registers: ----------------------
  2624.   eax - SF_PCI_BIOS (57)
  2625. ======================================================================
  2626. ========== Function 60 - Inter Process Communication (IPC). ==========
  2627. ======================================================================
  2628. IPC is used for message dispatching from one process/thread to
  2629. another. Previously it is necessary to agree how to interpret
  2630. the concrete message.
  2631.  
  2632. ----------- Subfunction 1 - set the area for IPC receiving -----------
  2633. Is called by process-receiver.
  2634. Parameters:
  2635.   * eax = 60 - function number
  2636.   * ebx = 1 - subfunction number
  2637.   * ecx = pointer to the buffer
  2638.   * edx = size of the buffer
  2639. Returned value:
  2640.   * eax = 0 - always success
  2641. Format of IPC-buffer:
  2642.   * +0: dword: if nonzero, buffer is considered locked;
  2643.     lock/unlock the buffer, when you work with it and need that
  2644.     buffer data are not changed from outside (no new messages)
  2645.   * +4: dword: occupied place in the buffer (in bytes)
  2646.   * +8: first message
  2647.   * +8+n: second message
  2648.   * ...
  2649. Format of a message:
  2650.   * +0: dword: PID of sender
  2651.   * +4: dword: message length (not including this header)
  2652.   * +8: n*byte: message data
  2653.  
  2654. ------------------ Subfunction 2 - send IPC message ------------------
  2655. Is called by process-sender.
  2656. Parameters:
  2657.   * eax = 60 - function number
  2658.   * ebx = 2 - subfunction number
  2659.   * ecx = PID of receiver
  2660.   * edx = pointer to the message data
  2661.   * esi = message length (in bytes)
  2662. Returned value:
  2663.   * eax = 0 - success
  2664.   * eax = 1 - the receiver has not defined buffer for IPC messages
  2665.     (can be, still have no time,
  2666.     and can be, this is not right process)
  2667.   * eax = 2 - the receiver has blocked IPC-buffer; try to wait a bit
  2668.   * eax = 3 - overflow of IPC-buffer of the receiver
  2669.   * eax = 4 - process/thread with such PID does not exist
  2670. Remarks:
  2671.   * Immediately after writing of IPC-message to the buffer the system
  2672.     sends to the receiver the event with code 7 (see event codes).
  2673.  
  2674. ---------------------- Constants for registers: ----------------------
  2675.   eax - SF_IPC (60)
  2676.   ebx - SSF_SET_AREA (1), SSF_SEND_MESSAGE (2)
  2677. ======================================================================
  2678. ==== Function 61 - get parameters for the direct graphics access. ====
  2679. ======================================================================
  2680. The data of the graphics screen (the memory area which displays
  2681. screen contents) are accessible to a program directly, without
  2682. any system calls, through the selector gs:
  2683.         mov     eax, [gs:0]
  2684. places in eax the first dword of the buffer, which contains
  2685. information on color of the left upper point (and, possibly, colors
  2686. of several following).
  2687.         mov     [gs:0], eax
  2688. by work in VESA modes with LFB sets color of the left upper point
  2689. (and, possibly, colors of several following).
  2690. To interpret the data of graphics screen program needs to know
  2691. some parameters, returning by this function.
  2692. Remarks:
  2693.   * Graphics parameters changes very seldom at work,
  2694.     namely, only in cases, when user works with the application VRR.
  2695.   * At videomode change the system redraws all windows (event
  2696.     with code 1) and redraws the background (event 5).
  2697.     Same events occur in other cases too, which meet much more often,
  2698.     than videomode change.
  2699.   * By operation in videomodes with LFB the selector gs points to
  2700.     LFB itself, so reading/writing on gs result directly in
  2701.     change of screen contents. By operation in videomodes without
  2702.     LFB gs points to some data area in the kernel, and all functions
  2703.     of screen output fulfil honesty double operation on writing
  2704.     directly to the screen and writing to this buffer. In result
  2705.     at reading contents of this buffer the results correspond to
  2706.     screen contents (with, generally speaking, large color
  2707.     resolution), and writing is ignored.
  2708.     One exception is the mode 320*200, for which main loop of the
  2709.     system thread updates the screen according to mouse movements.
  2710.  
  2711. ------------------------- Screen resolution --------------------------
  2712. Parameters:
  2713.   * eax = 61 - function number
  2714.   * ebx = 1 - subfunction number
  2715. Returned value:
  2716.   * eax = [resolution on x axis]*65536 + [resolution on y axis]
  2717. Remarks:
  2718.   * One can use function 14 paying attention that
  2719.     it returns sizes on 1 pixel less. It is fully equivalent way.
  2720.  
  2721. ---------------------- Number of bits per pixel ----------------------
  2722. Parameters:
  2723.   * eax = 61 - function number
  2724.   * ebx = 2 - subfunction number
  2725. Returned value:
  2726.   * eax = number of bits per pixel (24 or 32)
  2727.  
  2728. -------------------- Number of bytes per scanline --------------------
  2729. Parameters:
  2730.   * eax = 61 - function number
  2731.   * ebx = 3 - subfunction number
  2732. Returned value:
  2733.   * eax = number of bytes occupied by one scanline
  2734.     (horizontal line on the screen)
  2735.  
  2736. ---------------------- Constants for registers: ----------------------
  2737.   eax - SF_GET_GRAPHICAL_PARAMS (61)
  2738.   ebx - SSF_SCREEN_SIZE (1), SSF_BITS_PER_PIXEL (2),
  2739.     SSF_BYTES_PER_LINE (3)
  2740. ======================================================================
  2741. ===== Function 62, subfunction 0 - get version of PCI-interface. =====
  2742. ======================================================================
  2743. Parameters:
  2744.   * eax = 62 - function number
  2745.   * bl = 0 - subfunction number
  2746. Returned value:
  2747.   * eax = -1 - PCI access is disabled; otherwise
  2748.   * ah.al = version of PCI-interface (ah=version, al=subversion)
  2749.   * high word of eax is zeroed
  2750. Remarks:
  2751.   * Previously low-level access to PCI for applications must be
  2752.     enabled by subfunction 12 of function 21.
  2753.   * If PCI BIOS is not supported, the value of ax is undefined.
  2754.  
  2755. ---------------------- Constants for registers: ----------------------
  2756.   eax - SF_PCI (62)
  2757.   ebx - SSF_GET_VERSION (0)
  2758. ======================================================================
  2759. ==== Function 62, subfunction 1 - get number of the last PCI-bus. ====
  2760. ======================================================================
  2761. Parameters:
  2762.   * eax = 62 - function number
  2763.   * bl = 1 - subfunction number
  2764. Returned value:
  2765.   * eax = -1 - access to PCI is disabled; otherwise
  2766.   * al = number of the last PCI-bus; other bytes of eax are destroyed
  2767. Remarks:
  2768.   * Previously low-level access to PCI for applications must be
  2769.     enabled by subfunction 12 of function 21.
  2770.   * If PCI BIOS is not supported, the value of ax is undefined.
  2771.  
  2772. ---------------------- Constants for registers: ----------------------
  2773.   eax - SF_PCI (62)
  2774.   ebx - SSF_GET_LAST_BUS (1)
  2775. ======================================================================
  2776. ===================== Function 62, subfunction 2 =====================
  2777. ===== Get mechanism of addressing to the PCI configuration space. ====
  2778. ======================================================================
  2779. Parameters:
  2780.   * eax = 62 - function number
  2781.   * bl = 2 - subfunction number
  2782. Returned value:
  2783.   * eax = -1 - access to PCI is disabled; otherwise
  2784.   * al = mechanism (1 or 2); other bytes of eax are destroyed
  2785. Remarks:
  2786.   * Previously low-level access to PCI for applications must be
  2787.     enabled by subfunction 12 of function 21.
  2788.   * Addressing mechanism is selected depending on
  2789.     equipment characteristics.
  2790.   * Subfunctions of read and write work automatically
  2791.     with the selected mechanism.
  2792.  
  2793. ---------------------- Constants for registers: ----------------------
  2794.   eax - SF_PCI (62)
  2795.   ebx - SSF_GET_ADRR_MODE (2)
  2796. ======================================================================
  2797. ======== Function 62, subfunctions 4,5,6 - read PCI-register. ========
  2798. ======================================================================
  2799. Parameters:
  2800.   * eax = 62 - function number
  2801.   * bl = 4 - read byte
  2802.   * bl = 5 - read word
  2803.   * bl = 6 - read dword
  2804.   * bh = number of PCI-bus
  2805.   * ch = dddddfff, where ddddd = number of the device on the bus,
  2806.     fff = function number of device
  2807.   * cl = number of register (must be even for bl=5,
  2808.     divisible by 4 for bl=6)
  2809. Returned value:
  2810.   * eax = -1 - error (access to PCI is disabled or parameters
  2811.     are not supported); otherwise
  2812.   * al/ax/eax (depending on requested size) contains the data;
  2813.     the other part of register eax is destroyed
  2814. Remarks:
  2815.   * Previously low-level access to PCI for applications must be
  2816.     enabled by subfunction 12 of function 21.
  2817.   * Access mechanism 2 supports only 16 devices on a bus and ignores
  2818.     function number. To get access mechanism use subfunction 2.
  2819.   * Some registers are standard and exist for all devices, some are
  2820.     defined by the concrete device. The list of registers of the
  2821.     first type can be found e.g. in famous
  2822.     Interrupt List by Ralf Brown
  2823.     (http://www.pobox.com/~ralf/files.html,
  2824.     ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/);
  2825.     registers of the second type must be listed
  2826.     in the device documentation.
  2827.  
  2828. ---------------------- Constants for registers: ----------------------
  2829.   eax - SF_PCI (62)
  2830.   ebx - SSF_READ_BYTE (4), SSF_READ_WORD (5), SSF_READ_DWORD (6)
  2831. ======================================================================
  2832. ====== Function 62, subfunctions 8,9,10 - write to PCI-register. =====
  2833. ======================================================================
  2834. Parameters:
  2835.   * eax = 62 - function number
  2836.   * bl = 8 - write byte
  2837.   * bl = 9 - write word
  2838.   * bl = 10 - write dword
  2839.   * bh = number of PCI-bus
  2840.   * ch = dddddfff, where ddddd = number of the device on the bus,
  2841.     fff = function number of device
  2842.   * cl = number of register (must be even for bl=9,
  2843.     divisible by 4 for bl=10)
  2844.   * dl/dx/edx (depending on requested size) contatins
  2845.     the data to write
  2846. Returned value:
  2847.   * eax = -1 - error (access to PCI is disabled or parameters
  2848.     are not supported)
  2849.   * eax = 0 - success
  2850. Remarks:
  2851.   * Previously low-level access to PCI for applications must be
  2852.     enabled by subfunction 12 of function 21.
  2853.   * Access mechanism 2 supports only 16 devices on a bus and ignores
  2854.     function number. To get access mechanism use subfunction 2.
  2855.   * Some registers are standard and exist for all devices, some are
  2856.     defined by the concrete device. The list of registers of the
  2857.     first type can be found e.g. in famous Interrupt List by
  2858.     Ralf Brown; registers of the second type must be listed
  2859.     in the device documentation.
  2860.  
  2861. ---------------------- Constants for registers: ----------------------
  2862.   eax - SF_PCI (62)
  2863.   ebx - SSF_WRITE_BYTE (8), SSF_WRITE_WORD (9), SSF_WRITE_DWORD (10)
  2864. ======================================================================
  2865. ============== Function 63 - work with the debug board. ==============
  2866. ======================================================================
  2867. The debug board is the global system buffer (with the size
  2868. 1024 bytes), to which any program can write (generally speaking,
  2869. arbitrary) data and from which other program can read these data.
  2870. By the agreement written data are text strings interpreted as
  2871. debug messages on a course of program execution. The kernel in
  2872. some situations also writes to the debug board information on
  2873. execution of some functions; by the agreement kernel messages
  2874. begins from the prefix "K : ".
  2875. For view of the debug board the application 'board' was created,
  2876. which reads data from the buffer and displays them in its window.
  2877. 'board' interpretes the sequence of codes 13,10 as newline.
  2878. A character with null code in an end of line is not necessary,
  2879. but also does not prevent.
  2880. Because debugger has been written, the value of the debug board
  2881. has decreased, as debugger allows to inspect completely a course of
  2882. program execution without any efforts from the direction of program
  2883. itself. Nevertheless in some cases the debug board is still useful.
  2884.  
  2885. ----------------------------- Write byte -----------------------------
  2886. Parameters:
  2887.   * eax = 63 - function number
  2888.   * ebx = 1 - subfunction number
  2889.   * cl = data byte
  2890. Returned value:
  2891.   * function does not return value
  2892. Remarks:
  2893.   * Byte is written to the buffer. Buffer size is 512 bytes.
  2894.     At buffer overflow all obtained data are lost.
  2895.   * For output to the debug board of more complicated objects
  2896.     (strings, numbers) it is enough to call this function in cycle.
  2897.     It is possible not to write the appropriate code manually and use
  2898.     file 'debug.inc', which is included into the distributive.
  2899.  
  2900. ----------------------------- Read byte ------------------------------
  2901. Takes away byte from the buffer.
  2902. Parameters:
  2903.   * eax = 63 - function number
  2904.   * ebx = 2 - subfunction number
  2905. Returned value:
  2906.   * eax = ebx = 0 - the buffer is empty
  2907.   * eax = byte, ebx = 1 - byte was successfully read
  2908.  
  2909. ---------------------- Constants for registers: ----------------------
  2910.   eax - SF_BOARD (63)
  2911.   ebx - SSF_DEBUG_WRITE (1), SSF_DEBUG_READ (2)
  2912. ======================================================================
  2913. ============== Function 64 - resize application memory. ==============
  2914. ======================================================================
  2915. Parameters:
  2916.   * eax = 64 - function number
  2917.   * ebx = 1 - unique subfunction
  2918.   * ecx = new memory size
  2919. Returned value:
  2920.   * eax = 0 - success
  2921.   * eax = 1 - not enough memory
  2922. Remarks:
  2923.   * There is another way to dynamically allocate/free memory -
  2924.     subfunctions 11, 12, 13 of function 68.
  2925.   * The function cannot be used together with 68.11, 68.12, 68.13.
  2926.     The function call will be ignored after creation of process heap
  2927.     with function 68.11.
  2928.  
  2929. ---------------------- Constants for registers: ----------------------
  2930.   eax - SF_MEMORY_RESIZE (64)
  2931. ======================================================================
  2932. ======== Function 65 - draw image with palette in the window. ========
  2933. ======================================================================
  2934. Parameters:
  2935.   * eax = 65 - function number
  2936.   * ebx = pointer to the image
  2937.   * ecx = [size on axis x]*65536 + [size on axis y]
  2938.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  2939.   * esi = number of bits per pixel, must be 1,2,4,8,9,15,16,24 or 32;
  2940.   * edi = pointer to palette (2 to the power esi colors 0x00RRGGBB);
  2941.           ignored when esi > 8
  2942.   * ebp = offset of next row data relative to previous row data
  2943. Returned value:
  2944.   * function does not return value
  2945. Remarks:
  2946.   * Coordinates of the image are coordinates of the upper left corner
  2947.     of the image relative to the window.
  2948.   * Format of image with 1 bit per pixel: each byte of image
  2949.     (possibly excluding last bytes in rows), contains information on
  2950.     the color of 8 pixels, MSB corresponds to first pixel.
  2951.   * Format of image with 2 bits per pixel: each byte of image
  2952.     (possibly excluding last bytes in rows), contains information on
  2953.     the color of 4 pixels, two MSBs correspond to first pixel.
  2954.   * Format of image with 4 bits per pixel: each byte of image
  2955.     excluding last bytes in rows (if width is odd) contains
  2956.     information on the color of 2 pixels, high-order tetrad
  2957.     corresponds to first pixel.
  2958.   * Format of image with 8 bits per pixel: each byte of image is
  2959.     index in the palette.
  2960.   * Format of image with 9 bits per pixel: array of one byte values;
  2961.     each byte (8 bit) represents the intensity of gray for one pixel;
  2962.     this format is equal to 8bpp without palette.
  2963.   * Format of image with 15 bits per pixel: the color of each pixel
  2964.     is coded as (bit representation) 0RRRRRGGGGGBBBBB - 5 bits per
  2965.     each color.
  2966.   * Format of image with 16 bits per pixel: the color of each pixel
  2967.     is coded as RRRRRGGGGGGBBBBB (5+6+5).
  2968.   * Format of image with 24 bits per pixel: the color of each pixel
  2969.     is coded as 3 bytes - sequentially blue, green, red components.
  2970.   * Format of image with 32 bits per pixel: similar to 24, but
  2971.     one additional ignored byte is present. It's format is BGRX,
  2972.     where X is the ignored byte.
  2973.   * The call to function 7 is equivalent to call to this function
  2974.     with esi=24, ebp=0.
  2975.  
  2976. ---------------------- Constants for registers: ----------------------
  2977.   eax - SF_PUT_IMAGE_EXT (65)
  2978. ======================================================================
  2979. ================== Function 66 - work with keyboard. =================
  2980. ======================================================================
  2981. The input mode influences results of reading keys by function 2.
  2982. When a program loads, ASCII input mode is set for it.
  2983.  
  2984. -------------- Subfunction 1 - set keyboard input mode. --------------
  2985. Parameters:
  2986.   * eax = 66 - function number
  2987.   * ebx = 1 - subfunction number
  2988.   * ecx = mode:
  2989.     * 0 = normal (ASCII-characters)
  2990.     * 1 = scancodes
  2991. Returned value:
  2992.   * function does not return value
  2993.  
  2994. -------------- Subfunction 2 - get keyboard input mode. --------------
  2995. Parameters:
  2996.   * eax = 66 - function number
  2997.   * ebx = 2 - subfunction number
  2998. Returned value:
  2999.   * eax = current mode
  3000.  
  3001. ------------ Subfunction 3 - get status of control keys. -------------
  3002. Parameters:
  3003.   * eax = 66 - function number
  3004.   * ebx = 3 - subfunction number
  3005. Returned value:
  3006.   * eax = bit mask:
  3007.   * bit 0  (mask 1): left Shift is pressed
  3008.   * bit 1  (mask 2): right Shift is pressed
  3009.   * bit 2  (mask 4): left Ctrl is pressed
  3010.   * bit 3  (mask 8): right Ctrl is pressed
  3011.   * bit 4  (mask 0x10): left Alt is pressed
  3012.   * bit 5  (mask 0x20): right Alt is pressed
  3013.   * bit 6  (mask 0x40): CapsLock is on
  3014.   * bit 7  (mask 0x80): NumLock is on
  3015.   * bit 8  (mask 0x100): ScrollLock is on
  3016.   * bit 9  (mask 0x200): left Win is pressed
  3017.   * bit 10 (mask 0x400): right Win is pressed
  3018.   * other bits are cleared
  3019.  
  3020. -------------- Subfunction 4 - set system-wide hotkey. ---------------
  3021. When hotkey is pressed, the system notifies only those applications,
  3022. which have installed it; the active application (which receives
  3023. all normal input) does not receive such keys.
  3024. The notification consists in sending event with the code 2.
  3025. Reading hotkey is the same as reading normal key - by function 2.
  3026. Parameters:
  3027.   * eax = 66 - function number
  3028.   * ebx = 4 - subfunction number
  3029.   * cl determines key scancode;
  3030.     use cl=0 to give combinations such as Ctrl+Shift
  3031.   * edx = 0xXYZ determines possible states of control keys:
  3032.     * Z (low 4 bits) determines state of LShift and RShift:
  3033.       * 0 = no key must be pressed;
  3034.       * 1 = exactly one key must be pressed;
  3035.       * 2 = both keys must be pressed;
  3036.       * 3 = must be pressed LShift, but not RShift;
  3037.       * 4 = must be pressed RShift, but not LShift
  3038.     * Y - similar for LCtrl and RCtrl;
  3039.     * X - similar for LAlt and RAlt
  3040. Returned value:
  3041.   * eax=0 - success
  3042.   * eax=1 - too mant hotkeys (maximum 256 are allowed)
  3043. Remarks:
  3044.   * Hotkey can work either at pressing or at release. Release
  3045.     scancode of a key is more on 128 than pressing scancode
  3046.     (i.e. high bit is set).
  3047.   * Several applications can set the same combination;
  3048.     all such applications will be informed on pressing
  3049.     such combination.
  3050.  
  3051. -------------- Subfunction 5 - delete installed hotkey. --------------
  3052. Parameters:
  3053.   * eax = 66 - function number
  3054.   * ebx = 5 - subfunction number
  3055.   * cl = scancode of key and edx = 0xXYZ the same as in subfunction 4
  3056. Returned value:
  3057.   * eax = 0 - success
  3058.   * eax = 1 - there is no such hotkey
  3059. Remarks:
  3060.   * When a process/thread terminates, all hotkey installed by it are
  3061.     deleted.
  3062.   * The call to this subfunction does not affect other applications.
  3063.     If other application has defined the same combination, it will
  3064.     still receive notices.
  3065.  
  3066. --------------- Subfunction 6 - block the normal input. --------------
  3067. Parameters:
  3068.   * eax = 66 - function number
  3069.   * ebx = 6 - subfunction number
  3070. Returned value:
  3071.   * function does not return value
  3072. Remarks:
  3073.   * Blocking the normal keyboard input for installed hotkeys
  3074.   * To emulate a mouse via the keyboard, the application MOUSEMUL
  3075.  
  3076. ------------ Subfunction 7 - unlock the normal input. ----------------
  3077. Parameters:
  3078.   * eax = 66 - function number
  3079.   * ebx = 7 - subfunction number
  3080. Returned value:
  3081.   * function does not return value
  3082. Remarks:
  3083.   * Unlocking the results of the f. 66.6
  3084.   * To emulate a mouse via the keyboard, the application MOUSEMUL
  3085.  
  3086. ---------------------- Constants for registers: ----------------------
  3087.   eax - SF_KEYBOARD (66)
  3088.   ebx - SSF_SET_INPUT_MODE (1), SSF_GET_INPUT_MODE (2),
  3089.     SSF_GET_CONTROL_KEYS (3), SSF_SET_SYS_HOTKEY (4),
  3090.     SSF_DEL_SYS_HOTKEY (5),  SSF_LOCK_INPUT (6), SSF_UNLOCK_INPUT (7)
  3091. ======================================================================
  3092. ========= Function 67 - change position/sizes of the window. =========
  3093. ======================================================================
  3094. Parameters:
  3095.   * eax = 67 - function number
  3096.   * ebx = new x-coordinate of the window
  3097.   * ecx = new y-coordinate of the window
  3098.   * edx = new x-size of the window
  3099.   * esi = new y-size of the window
  3100. Returned value:
  3101.   * function does not return value
  3102. Remarks:
  3103.   * The value -1 for a parameter means "do not change"; e.g. to move
  3104.     the window without resizing it is possible to specify edx=esi=-1.
  3105.   * Previously the window must be defined by function 0.
  3106.     It sets initial coordinates and sizes of the window.
  3107.   * Sizes of the window are understood in sense of function 0,
  3108.     that is one pixel less than real sizes.
  3109.   * The function call for maximized windows is simply ignored.
  3110.   * For windows of appropriate styles position and/or sizes can be
  3111.     changed by user; current position and sizes can be obtained by
  3112.     call to function 9.
  3113.   * The function sends to the window redraw event (with the code 1).
  3114.  
  3115. ---------------------- Constants for registers: ----------------------
  3116.   eax - SF_CHANGE_WINDOW (67)
  3117. ======================================================================
  3118. ====== Function 68, subfunction 0 - get the task switch counter. =====
  3119. ======================================================================
  3120. Parameters:
  3121.   * eax = 68 - function number
  3122.   * ebx = 0 - subfunction number
  3123. Returned value:
  3124.   * eax = number of task switches from the system booting
  3125.     (modulo 2^32)
  3126.  
  3127. ---------------------- Constants for registers: ----------------------
  3128.   eax - SF_SYS_MISC (68)
  3129.   ebx - SSF_GET_TASK_SWITCH_COUNT (0)
  3130. ======================================================================
  3131. ======= Function 68, subfunction 1 - switch to the next thread. ======
  3132. ======================================================================
  3133. The function completes the current time slice allocated to the
  3134. thread and switches to the next. (Which thread in which process
  3135. will be next, is unpredictable). Later, when execution queue
  3136. will reach the current thread, execution will be continued.
  3137. Parameters:
  3138.   * eax = 68 - function number
  3139.   * ebx = 1 - subfunction number
  3140. Returned value:
  3141.   * function does not return value
  3142.  
  3143. ---------------------- Constants for registers: ----------------------
  3144.   eax - SF_SYS_MISC (68)
  3145.   ebx - SSF_SWITCH_TASK (1)
  3146. ======================================================================
  3147. ============= Function 68, subfunction 2 - cache + rdpmc. ============
  3148. ======================================================================
  3149. Parameters:
  3150.   * eax = 68 - function number
  3151.   * ebx = 2 - subfunction number
  3152.   * ecx = required action:
  3153.     * ecx = 0 - enable instruction 'rdpmc'
  3154.       (ReaD Performance-Monitoring Counters) for applications
  3155.     * ecx = 1 - find out whether cache is disabled/enabled
  3156.     * ecx = 2 - enable cache
  3157.     * ecx = 3 - disable cache
  3158. Returned value:
  3159.   * for ecx=0:
  3160.     * eax = the value of cr4
  3161.   * for ecx=1:
  3162.     * eax = (cr0 and 0x60000000):
  3163.     * eax = 0 - cache is on
  3164.     * eax <> 0 - cache is off
  3165.   * for ecx=2 and ecx=3:
  3166.     * function does not return value
  3167.  
  3168. ---------------------- Constants for registers: ----------------------
  3169.   eax - SF_SYS_MISC (68)
  3170.   ebx - SSF_PERFORMANCE (2)
  3171.   ecx - SSSF_ALLOW_RDPMC (0), SSSF_CACHE_STATUS (1),
  3172.     SSSF_CACHE_ON (2), SSSF_CACHE_OFF (3)
  3173. ======================================================================
  3174. =========== Function 68, subfunction 3 - read MSR-register. ==========
  3175. ======================================================================
  3176. MSR = Model Specific Register; the complete list of MSR-registers
  3177. of a processor is included to the documentation on it (for example,
  3178. IA-32 Intel Architecture Software Developer's Manual,
  3179. Volume 3, Appendix B); each processor family has its own subset
  3180. of the MSR-registers.
  3181. Parameters:
  3182.   * eax = 68 - function number
  3183.   * ebx = 3 - subfunction number
  3184.   * ecx is ignored
  3185.   * edx = MSR address
  3186. Returned value:
  3187.   * ebx:eax = high:low dword of the result
  3188. Remarks:
  3189.   * If ecx contains nonexistent or not implemented for this processor
  3190.     MSR, processor will generate an exception in the kernel, which
  3191.     will kill the thread.
  3192.   * Previously it is necessary to check, whether MSRs are supported
  3193.     as a whole, with the instruction 'cpuid'. Otherwise processor
  3194.     will generate other exception in the kernel, which will anyway
  3195.     kill the thread.
  3196.  
  3197. ---------------------- Constants for registers: ----------------------
  3198.   eax - SF_SYS_MISC (68)
  3199.   ebx - SSF_READ_MSR (3)
  3200. ======================================================================
  3201. ========= Function 68, subfunction 4 - write to MSR-register. ========
  3202. ======================================================================
  3203. MSR = Model Specific Register; the complete list of MSR-registers
  3204. of a processor is included to the documentation on it (for example,
  3205. IA-32 Intel Architecture Software Developer's Manual,
  3206. Volume 3, Appendix B); each processor family has its own subset
  3207. of the MSR-registers.
  3208. Parameters:
  3209.   * eax = 68 - function number
  3210.   * ebx = 4 - subfunction number
  3211.   * ecx is ignored
  3212.   * edx = MSR address
  3213.   * esi:edi = high:low dword
  3214. Returned value:
  3215.   * function does not return value
  3216. Remarks:
  3217.   * If ecx contains nonexistent or not implemented for this processor
  3218.     MSR, processor will generate an exception in the kernel, which
  3219.     will kill the thread.
  3220.   * Previously it is necessary to check, whether MSRs are supported
  3221.     as a whole, with the instruction 'cpuid'. Otherwise processor
  3222.     will generate other exception in the kernel, which will anyway
  3223.     kill the thread.
  3224.  
  3225. ---------------------- Constants for registers: ----------------------
  3226.   eax - SF_SYS_MISC (68)
  3227.   ebx - SSF_WRITE_MSR (4)
  3228. ======================================================================
  3229. ======= Function 68, subfunction 11 - initialize process heap. =======
  3230. ======================================================================
  3231. Parameters:
  3232.   * eax = 68 - function number
  3233.   * ebx = 11 - subfunction number
  3234. Returned value:
  3235.   * eax = 0 - failed
  3236.   * otherwise size of created heap
  3237. Remarks:
  3238.   * The function call initializes heap, from which one can in future
  3239.     allocate and free memory blocks with subfunctions 12 and 13.
  3240.     Heap size is equal to total amount of free application memory.
  3241.   * The second function call from the same process results in
  3242.     returning the size of the existing heap.
  3243.   * After creation of the heap calls to function 64 will be ignored.
  3244.  
  3245. ---------------------- Constants for registers: ----------------------
  3246.   eax - SF_SYS_MISC (68)
  3247.   ebx - SSF_HEAP_INIT (11)
  3248. ======================================================================
  3249. ======== Function 68, subfunction 12 - allocate memory block. ========
  3250. ======================================================================
  3251. Parameters:
  3252.   * eax = 68 - function number
  3253.   * ebx = 12 - subfunction number
  3254.   * ecx = required size in bytes
  3255. Returned value:
  3256.   * eax = pointer to the allocated block
  3257. Remarks:
  3258.   * Before this call one must initialize process heap by call to
  3259.     subfunction 11.
  3260.   * The function allocates an integer number of pages (4 Kb) in such
  3261.     way that the real size of allocated block is more than or equal to
  3262.     requested size.
  3263.  
  3264. ---------------------- Constants for registers: ----------------------
  3265.   eax - SF_SYS_MISC (68)
  3266.   ebx - SSF_MEM_ALLOC (12)
  3267. ======================================================================
  3268. ========== Function 68, subfunction 13 - free memory block. ==========
  3269. ======================================================================
  3270. Parameters:
  3271.   * eax = 68 - function number
  3272.   * ebx = 13 - subfunction number
  3273.   * ecx = pointer to the memory block
  3274. Returned value:
  3275.   * eax = 1 - success
  3276.   * eax = 0 - failed
  3277. Remarks:
  3278.   * The memory block must have been allocated by subfunction 12
  3279.     or subfunction 20.
  3280.  
  3281. ---------------------- Constants for registers: ----------------------
  3282.   eax - SF_SYS_MISC (68)
  3283.   ebx - SSF_MEM_FREE (13)
  3284. ======================================================================
  3285. ===================== Function 68, subfunction 14 ====================
  3286. ============ Wait for signal from another program/driver. ============
  3287. ======================================================================
  3288. Parameters:
  3289.   * eax = 68 - function number
  3290.   * ebx = 14 - subfunction number
  3291.   * ecx = pointer to the buffer for information (24 bytes)
  3292. Returned value:
  3293.   * buffer pointed to by ecx contains the following information:
  3294.     * +0: dword: identifier for following data of signal
  3295.     * +4: dword: data of signal (20 bytes), format of which is defined
  3296.           by the first dword
  3297.  
  3298. ---------------------- Constants for registers: ----------------------
  3299.   eax - SF_SYS_MISC (68)
  3300.   ebx - SSF_WAIT_SIGNAL (14)
  3301. ======================================================================
  3302. ============= Function 68, subfunction 16 - load driver. =============
  3303. ======================================================================
  3304. Parameters:
  3305.   * eax = 68 - function number
  3306.   * ebx = 16 - subfunction number
  3307.   * ecx = pointer to ASCIIZ-string with driver name
  3308. Returned value:
  3309.   * eax = 0 - failed
  3310.   * otherwise eax = driver handle
  3311. Remarks:
  3312.   * If the driver was not loaded yet, it is loaded;
  3313.     if the driver was loaded yet, nothing happens.
  3314.   * Driver name is case-sensitive.
  3315.     Maximum length of the name is 16 characters, including
  3316.     terminating null character, the rest is ignored.
  3317.   * Driver ABC is loaded from file /rd/1/drivers/ABC.obj.
  3318.  
  3319. ---------------------- Constants for registers: ----------------------
  3320.   eax - SF_SYS_MISC (68)
  3321.   ebx - SSF_LOAD_DRIVER (16)
  3322. ======================================================================
  3323. ============ Function 68, subfunction 17 - driver control. ===========
  3324. ======================================================================
  3325. Parameters:
  3326.   * eax = 68 - function number
  3327.   * ebx = 17 - subfunction number
  3328.   * ecx = pointer to the control structure:
  3329.     * +0: dword: handle of driver
  3330.     * +4: dword: code of driver function
  3331.     * +8: dword: pointer to input data
  3332.     * +12 = +0xC: dword: size of input data
  3333.     * +16 = +0x10: dword: pointer to output data
  3334.     * +20 = +0x14: dword: size of output data
  3335. Returned value:
  3336.   * eax = determined by driver
  3337. Remarks:
  3338.   * Function codes and the structure of input/output data
  3339.     are defined by driver.
  3340.   * Previously one must obtain driver handle by subfunction 16.
  3341.  
  3342. ---------------------- Constants for registers: ----------------------
  3343.   eax - SF_SYS_MISC (68)
  3344.   ebx - SSF_CONTROL_DRIVER (17)
  3345. ======================================================================
  3346. =============== Function 68, subfunction 19 - load DLL. ==============
  3347. ======================================================================
  3348. Parameters:
  3349.   * eax = 68 - function number
  3350.   * ebx = 19 - subfunction number
  3351.   * ecx = pointer to the string with path to DLL,
  3352.     rules of path forming can be found in function 70 description.
  3353. Returned value:
  3354.   * eax = 0 - failed
  3355.   * otherwise eax = pointer to DLL export table
  3356. Remarks:
  3357.   * Export table is an array of structures of 2 dword's, terminated
  3358.     by zero. The first dword in structure points to function name,
  3359.     the second dword contains address of function.
  3360.  
  3361. ---------------------- Constants for registers: ----------------------
  3362.   eax - SF_SYS_MISC (68)
  3363.   ebx - SSF_LOAD_DLL (19)
  3364. ======================================================================
  3365. ======= Function 68, subfunction 20 - reallocate memory block. =======
  3366. ======================================================================
  3367. Parameters:
  3368.   * eax = 68 - function number
  3369.   * ebx = 20 - subfunction number
  3370.   * ecx = new size in bytes
  3371.   * edx = pointer to already allocated block
  3372. Returned value:
  3373.   * eax = pointer to the reallocated block, 0 = error
  3374. Remarks:
  3375.   * Before this call one must initialize process heap by call to
  3376.     subfunction 11.
  3377.   * The function allocates an integer number of pages (4 Kb) in such
  3378.     way that the real size of allocated block is more than or equal to
  3379.     requested size.
  3380.   * If edx=0, the function call is equivalent to memory allocation
  3381.     with subfunction 12. Otherwise the block at edx
  3382.     must be allocated earlier with subfunction 12 or this subfunction.
  3383.   * If ecx=0, the function frees memory block at edx and returns 0.
  3384.   * The contents of the block are unchanged up to the shorter of
  3385.     the new and old sizes.
  3386.  
  3387. ---------------------- Constants for registers: ----------------------
  3388.   eax - SF_SYS_MISC (68)
  3389.   ebx - SSF_MEM_REALLOC (20)
  3390. ======================================================================
  3391. =========== Function 68, subfunction 21 - load driver PE. ============
  3392. ======================================================================
  3393. Parameters:
  3394.   * eax = 68 - function number
  3395.   * ebx = 21 - subfunction number
  3396.   * ecx = pointer to ASCIIZ-string with driver name
  3397.   * edx = pointer to command line
  3398. Returned value:
  3399.   * eax = 0 - failed
  3400.   * otherwise eax = driver handle
  3401. Remarks:
  3402.   * If the driver was not loaded yet, it is loaded;
  3403.     if the driver was loaded yet, nothing happens.
  3404.  
  3405. ---------------------- Constants for registers: ----------------------
  3406.   eax - SF_SYS_MISC (68)
  3407.   ebx - SSF_LOAD_DRIVER_PE (21)
  3408. ======================================================================
  3409. ======== Function 68, subfunction 22 - open named memory area. =======
  3410. ======================================================================
  3411. Parameters:
  3412.   * eax = 68 - function number
  3413.   * ebx = 22 - subfunction number
  3414.   * ecx = area name. Maximum of 31 characters with terminating zero
  3415.   * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS
  3416.   * esi = flags for open and access:
  3417.     * SHM_OPEN        = 0x00 - open existing memory area. If an area
  3418.                           with such name does not exist, the function
  3419.                           will return error code 5.
  3420.     * SHM_OPEN_ALWAYS = 0x04 - open existing or create new
  3421.                           memory area.
  3422.     * SHM_CREATE      = 0x08 - create new memory area. If an area
  3423.                           with such name already exists, the function
  3424.                           will return error code 10.
  3425.     * SHM_READ        = 0x00 - only read access
  3426.     * SHM_WRITE       = 0x01 - read and write access
  3427. Returned value:
  3428.   * eax = pointer to memory area, 0 if error has occured
  3429.   * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS):
  3430.     edx = 0 - success, otherwise - error code
  3431.   * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS):
  3432.     edx = error code (if eax=0) or area size in bytes
  3433. Error codes:
  3434.   * E_NOTFOUND = 5
  3435.   * E_ACCESS = 10
  3436.   * E_NOMEM = 30
  3437.   * E_PARAM = 33
  3438. Remarks:
  3439.   * Before this call one must initialize process heap by call to
  3440.     subfunction 11.
  3441.   * If a new area is created, access flags set maximal rights
  3442.     for other processes. An attempt from other process to open
  3443.     with denied rights will fail with error code E_ACCESS.
  3444.   * The process which has created an area always has write access.
  3445.  
  3446. ---------------------- Constants for registers: ----------------------
  3447.   eax - SF_SYS_MISC (68)
  3448.   ebx - SSF_MEM_OPEN (22)
  3449. ======================================================================
  3450. ======= Function 68, subfunction 23 - close named memory area. =======
  3451. ======================================================================
  3452. Parameters:
  3453.   * eax = 68 - function number
  3454.   * ebx = 23 - subfunction number
  3455.   * ecx = area name. Maximum of 31 characters with terminating zero
  3456. Returned value:
  3457.   * eax destroyed
  3458. Remarks:
  3459.   * A memory area is physically freed (with deleting all data and
  3460.     freeing physical memory), when all threads which have opened
  3461.     this area will close it.
  3462.   * When thread is terminating, all opened by it areas are closed.
  3463.  
  3464. ---------------------- Constants for registers: ----------------------
  3465.   eax - SF_SYS_MISC (68)
  3466.   ebx - SSF_MEM_CLOSE (23)
  3467. ======================================================================
  3468. ======== Function 68, subfunction 24 - set exception handler. ========
  3469. ======================================================================
  3470. Parameters:
  3471.   * eax = 68 - function number
  3472.   * ebx = 24 - subfunction number
  3473.   * ecx = address of the new exception handler
  3474.   * edx = the mask of handled exceptions
  3475. Returned value:
  3476.   * eax = address of the old exception handler (0, if it was not set)
  3477.   * ebx = the old mask of handled exceptions
  3478. Remarks:
  3479.   * Bit number in mask of exceptions corresponds to exception number
  3480.     in CPU-specification (Intel-PC). For example, FPU exceptions have
  3481.     number 16 (#MF), and SSE exceptions - 19 (#XF).
  3482.   * The current implementation ignores the inquiry for hook of 7
  3483.     exception - the system handles #NM by its own.
  3484.   * The exception handler is called with exception number as first
  3485.     (and only) stack parameter. So, correct exit from the handler is
  3486.     RET 4. It returns to the instruction, that caused the exception,
  3487.     for faults, and to the next instruction for traps (see
  3488.     classification of exceptions in CPU specification).
  3489.   * When user handler receives control, the corresponding bit in
  3490.     the exception mask is cleared. Raising this exception
  3491.     in consequence leads to default handling, that is,
  3492.     terminating the application in absence of debugger or
  3493.     suspend with notification of debugger otherwise.
  3494.   * After user handler completes critical operations, it can set
  3495.     the corresponding bit in the exception mask with subfunction 25.
  3496.     Also user handler is responsible for clearing exceptions flags in
  3497.     FPU and/or SSE.
  3498.  
  3499. ---------------------- Constants for registers: ----------------------
  3500.   eax - SF_SYS_MISC (68)
  3501.   ebx - SSF_SET_EXCEPTION_HANDLER (24)
  3502. ======================================================================
  3503. ======== Function 68, subfunction 25 - set exception activity ========
  3504. ======================================================================
  3505. Parameters:
  3506.   * eax = 68 - function number
  3507.   * ebx = 25 - subfunction number
  3508.   * ecx = signal number
  3509.   * edx = value of activity (0/1)
  3510. Returned value:
  3511.   * eax = -1 - invalid signal number
  3512.   * otherwise eax = old value of activity for this signal (0/1)
  3513. Remarks:
  3514.   * In current implementation only mask for user excepton handler,
  3515.     which has been previously set by subfunction 24,
  3516.     is changed. Signal number corresponds to exception number.
  3517.  
  3518. ---------------------- Constants for registers: ----------------------
  3519.   eax - SF_SYS_MISC (68)
  3520.   ebx - SSF_SET_EXCEPTION_STATE (25)
  3521. ======================================================================
  3522. ====== Function 68, subfunction 26 - release memory pages ============
  3523. ======================================================================
  3524. Parameters:
  3525.   * eax = 68 - function number
  3526.   * ebx = 26 - subfunction number
  3527.   * ecx = pointer to the memory block, allocated by subfunction 12
  3528.   * edx = offset from the block beginnings
  3529.   * esi = the size of the region of memory to release, in bytes
  3530. Remarks:
  3531.   * function release range of pages from ecx+edx to ecx+edx+esi
  3532.     and set virtual memory into reserved state.
  3533.  
  3534. ---------------------- Constants for registers: ----------------------
  3535.   eax - SF_SYS_MISC (68)
  3536.   ebx - SSF_MEM_FREE_EXT (26)
  3537. ======================================================================
  3538. ========== Function 68, subfunction 27 - load file ===================
  3539. ======================================================================
  3540. Parameters:
  3541.   * eax = 68 - function number
  3542.   * ebx = 27 - subfunction number
  3543.   * ecx = pointer to the string with path to file,
  3544.     rules of path forming can be found in function 70 description.
  3545. Returned value:
  3546.   * eax = pointer to the loaded file, or zero
  3547.   * edx = size of the loaded file, or zero
  3548. Remarks:
  3549.   * function loads file and unpacks, if necessary
  3550.  
  3551. ---------------------- Constants for registers: ----------------------
  3552.   eax - SF_SYS_MISC (68)
  3553.   ebx - SSF_LOAD_FILE (27)
  3554. ======================================================================
  3555. ====================== Function 69 - debugging. ======================
  3556. ======================================================================
  3557. A process can load other process as debugged by set of corresponding
  3558. bit by call to subfunction 7 of function 70.
  3559. A process can have only one debugger; one process can debug some
  3560. others. The system notifies debugger on events occuring with
  3561. debugged process. Messages are written to the buffer defined by
  3562. subfunction 0.
  3563. Format of a message:
  3564.   * +0: dword: message code
  3565.   * +4: dword: PID of debugged process
  3566.   * +8: there can be additional data depending on message code
  3567. Message codes:
  3568.   * 1 = exception
  3569.     * in addition dword-number of the exception is given
  3570.     * process is suspended
  3571.   * 2 = process has terminated
  3572.     * comes at any termination: both through the system function -1,
  3573.       and at "murder" by any other process (including debugger itself)
  3574.   * 3 = debug exception int 1 = #DB
  3575.     * in addition dword-image of the register DR6 is given:
  3576.       * bits 0-3: condition of the corresponding breakpoint (set by
  3577.         subfunction 9) is satisfied
  3578.       * bit 14: exception has occured because of the trace mode
  3579.         (flag TF is set TF)
  3580.     * process is suspended
  3581. When debugger terminates, all debugged processes are killed.
  3582. If debugger does not want this, it must previously detach by
  3583. subfunction 3.
  3584.  
  3585. All subfunctions are applicable only to processes/threads started
  3586. from the current by function 70 with set debugging flag.
  3587. Debugging of multithreaded programs is not supported yet.
  3588. The full list of subfunctions:
  3589.   * subfunction 0 - define data area for debug messages
  3590.   * subfunction 1 - get contents of registers of debugged thread
  3591.   * subfunction 2 - set contents of registers of debugged thread
  3592.   * subfunction 3 - detach from debugged process
  3593.   * subfunction 4 - suspend debugged thread
  3594.   * subfunction 5 - resume debugged thread
  3595.   * subfunction 6 - read from the memory of debugged process
  3596.   * subfunction 7 - write to the memory of debugged process
  3597.   * subfunction 8 - terminate debugged thread
  3598.   * subfunction 9 - set/clear hardware breakpoint
  3599.  
  3600. ---------------------- Constants for registers: ----------------------
  3601.   eax - SF_DEBUG (69)
  3602.   ebx - SSF_SET_MESSAGE_AREA (0), SSF_GET_REGISTERS (1),
  3603.     SSF_SET_REGISTERS (2), SSF_DETACH (3), SSF_SUSPEND (4),
  3604.     SSF_RESUME (5), SSF_READ_MEMORY (6), SSF_WRITE_MEMORY (7),
  3605.     SSF_TERMINATE (8), SSF_DEFINE_BREAKPOINT (9)
  3606. ======================================================================
  3607. = Function 69, subfunction 0 - define data area fror debug messages. =
  3608. ======================================================================
  3609. Parameters:
  3610.   * eax = 69 - function number
  3611.   * ebx = 0 - subfunction number
  3612.   * ecx = pointer
  3613. Format of data area:
  3614.   * +0: dword: N = buffer size (not including this header)
  3615.   * +4: dword: occupied place
  3616.   * +8: N*byte: buffer
  3617. Returned value:
  3618.   * function does not return value
  3619. Remarks:
  3620.   * If the size field is negative, the buffer is considered locked
  3621.     and at arrival of new message the system will wait.
  3622.     For synchronization frame all work with the buffer by operations
  3623.     lock/unlock
  3624.         neg     [bufsize]
  3625.   * Data in the buffer are considered as array of items with variable
  3626.     length - messages. Format of a message is explained in
  3627.     general description.
  3628.  
  3629. ---------------------- Constants for registers: ----------------------
  3630.   eax - SF_DEBUG (69)
  3631.   ebx - SSF_SET_MESSAGE_AREA (0)
  3632. ======================================================================
  3633. ===================== Function 69, subfunction 1 =====================
  3634. ============ Get contents of registers of debugged thread. ===========
  3635. ======================================================================
  3636. Parameters:
  3637.   * eax = 69 - function number
  3638.   * ebx = 1 - subfunction number
  3639.   * ecx = thread identifier
  3640.   * edx = size of context structure, must be 0x28=40 bytes
  3641.   * esi = pointer to context structure
  3642. Returned value:
  3643.   * function does not return value
  3644. Format of context structure: (FPU is not supported yet)
  3645.   * +0: dword: eip
  3646.   * +4: dword: eflags
  3647.   * +8: dword: eax
  3648.   * +12 = +0xC: dword: ecx
  3649.   * +16 = +0x10: dword: edx
  3650.   * +20 = +0x14: dword: ebx
  3651.   * +24 = +0x18: dword: esp
  3652.   * +28 = +0x1C: dword: ebp
  3653.   * +32 = +0x20: dword: esi
  3654.   * +36 = +0x24: dword: edi
  3655. Remarks:
  3656.   * If the thread executes code of ring-0, the function returns
  3657.     contents of registers of ring-3.
  3658.   * Process must be loaded for debugging (as is shown in
  3659.     general description).
  3660.  
  3661. ---------------------- Constants for registers: ----------------------
  3662.   eax - SF_DEBUG (69)
  3663.   ebx - SSF_GET_REGISTERS (1)
  3664. ======================================================================
  3665. ===================== Function 69, subfunction 2 =====================
  3666. ============ Set contents of registers of debugged thread. ===========
  3667. ======================================================================
  3668. Parameters:
  3669.   * eax = 69 - function number
  3670.   * ebx = 2 - subfunction number
  3671.   * ecx = thread identifier
  3672.   * edx = size of context structure, must be 0x28=40 bytes
  3673. Returned value:
  3674.   * function does not return value
  3675. Format of context structure is shown in the description of
  3676. subfunction 1.
  3677. Remarks:
  3678.   * If the thread executes code of ring-0, the function returns
  3679.     contents of registers of ring-3.
  3680.   * Process must be loaded for debugging (as is shown in
  3681.     general description).
  3682.  
  3683. ---------------------- Constants for registers: ----------------------
  3684.   eax - SF_DEBUG (69)
  3685.   ebx - SSF_SET_REGISTERS (2)
  3686. ======================================================================
  3687. ===== Function 69, subfunction 3 - detach from debugged process. =====
  3688. ======================================================================
  3689. Parameters:
  3690.   * eax = 69 - function number
  3691.   * ebx = 3 - subfunction number
  3692.   * ecx = identifier
  3693. Returned value:
  3694.   * function does not return value
  3695. Remarks:
  3696.   * If the process was suspended, it resumes execution.
  3697.  
  3698. ---------------------- Constants for registers: ----------------------
  3699.   eax - SF_DEBUG (69)
  3700.   ebx - SSF_DETACH (3)
  3701. ======================================================================
  3702. ======== Function 69, subfunction 4 - suspend debugged thread. =======
  3703. ======================================================================
  3704. Parameters:
  3705.   * eax = 69 - function number
  3706.   * ebx = 4 - subfunction number
  3707.   * ecx = thread identifier
  3708. Returned value:
  3709.   * function does not return value
  3710. Remarks:
  3711.   * Process must be loaded for debugging (as is shown in
  3712.     general description).
  3713.  
  3714. ---------------------- Constants for registers: ----------------------
  3715.   eax - SF_DEBUG (69)
  3716.   ebx - SSF_SUSPEND (4)
  3717. ======================================================================
  3718. ======== Function 69, subfunction 5 - resume debugged thread. ========
  3719. ======================================================================
  3720. Parameters:
  3721.   * eax = 69 - function number
  3722.   * ebx = 5 - subfunction number
  3723.   * ecx = thread identifier
  3724. Returned value:
  3725.   * function does not return value
  3726. Remarks:
  3727.   * Process must be loaded for debugging (as is shown in
  3728.     general description).
  3729.  
  3730. ---------------------- Constants for registers: ----------------------
  3731.   eax - SF_DEBUG (69)
  3732.   ebx - SSF_RESUME (5)
  3733. ======================================================================
  3734. = Fucntion 69, subfunction 6 - read from memory of debugged process. =
  3735. ======================================================================
  3736. Parameters:
  3737.   * eax = 69 - function number
  3738.   * ebx = 6 - subfunction number
  3739.   * ecx = identifier
  3740.   * edx = number of bytes to read
  3741.   * esi = address in the memory of debugged process
  3742.   * edi = pointer to buffer for data
  3743. Returned value:
  3744.   * eax = -1 at an error (invalid PID or buffer)
  3745.   * otherwise eax = number of read bytes (possibly, 0,
  3746.     if esi is too large)
  3747. Remarks:
  3748.   * Process must be loaded for debugging (as is shown in
  3749.     general description).
  3750.  
  3751. ---------------------- Constants for registers: ----------------------
  3752.   eax - SF_DEBUG (69)
  3753.   ebx - SSF_READ_MEMORY (6)
  3754. ======================================================================
  3755. == Function 69, subfunction 7 - write to memory of debugged process. =
  3756. ======================================================================
  3757. Parameters:
  3758.   * eax = 69 - function number
  3759.   * ebx = 7 - subfunction number
  3760.   * ecx = identifier
  3761.   * edx = number of bytes to write
  3762.   * esi = address of memory in debugged process
  3763.   * edi = pointer to data
  3764. Returned value:
  3765.   * eax = -1 at an error (invalid PID or buffer)
  3766.   * otherwise eax = number of written bytes (possibly, 0,
  3767.     if esi is too large)
  3768. Remarks:
  3769.   * Process must be loaded for debugging (as is shown in
  3770.     general description).
  3771.  
  3772. ---------------------- Constants for registers: ----------------------
  3773.   eax - SF_DEBUG (69)
  3774.   ebx - SSF_WRITE_MEMORY (7)
  3775. ======================================================================
  3776. ======= Function 69, subfunction 8 - terminate debugged thread. ======
  3777. ======================================================================
  3778. Parameters:
  3779.   * eax = 69 - function number
  3780.   * ebx = 8 - subfunction number
  3781.   * ecx = identifier
  3782. Returned value:
  3783.   * function does not return value
  3784. Remarks:
  3785.   * Process must be loaded for debugging (as is shown in
  3786.     general description).
  3787.   * The function is similar to subfunction 2 of function 18
  3788.     with two differences: it requires first remark and
  3789.     accepts PID rather than slot number.
  3790.  
  3791. ---------------------- Constants for registers: ----------------------
  3792.   eax - SF_DEBUG (69)
  3793.   ebx - SSF_TERMINATE (8)
  3794. ======================================================================
  3795. ===== Function 69, subfunction 9 - set/clear hardware breakpoint. ====
  3796. ======================================================================
  3797. Parameters:
  3798.   * eax = 69 - function number
  3799.   * ebx = 9 - subfunction number
  3800.   * ecx = thread identifier
  3801.   * dl = index of breakpoint, from 0 to 3 inclusively
  3802.   * dh = flags:
  3803.     * if high bit is cleared - set breakpoint:
  3804.       * bits 0-1 - condition:
  3805.         * 00 = breakpoint on execution
  3806.         * 01 = breakpoint on read
  3807.         * 11 = breakpoint on read/write
  3808.       * bits 2-3 - length; for breakpoints on exception it must be
  3809.         00, otherwise one of
  3810.         * 00 = byte
  3811.         * 01 = word
  3812.         * 11 = dword
  3813.       * esi = breakpoint address; must be aligned according to
  3814.         the length (i.e. must be even for word breakpoints,
  3815.         divisible by 4 for dword)
  3816.     * if high bit is set - clear breakpoint
  3817. Returned value:
  3818.   * eax = 0 - success
  3819.   * eax = 1 - error in the input data
  3820.   * eax = 2 - (reserved, is never returned in the current
  3821.     implementation) a global breakpoint with that index is already set
  3822. Remarks:
  3823.   * Process must be loaded for debugging (as is shown in
  3824.     general description).
  3825.   * Hardware breakpoints are implemented through DRx-registers of
  3826.     the processor, all limitations results from this.
  3827.   * The function can reinstall the breakpoint, previously set
  3828.     by it (and it does not inform on this).
  3829.     Carry on the list of set breakpoints in the debugger.
  3830.   * Breakpoints generate debug exception #DB, on which the system
  3831.     notifies debugger.
  3832.   * Breakpoints on write and read/write act after
  3833.     execution of the caused it instruction.
  3834.  
  3835. ---------------------- Constants for registers: ----------------------
  3836.   eax - SF_DEBUG (69)
  3837.   ebx - SSF_DEFINE_BREAKPOINT (9)
  3838. ======================================================================
  3839. ==== Function 70 - work with file system with long names support. ====
  3840. ======================================================================
  3841. Parameters:
  3842.   * eax = 70
  3843.   * ebx = pointer to the information structure
  3844. Returned value:
  3845.   * eax = 0 - success; otherwise file system error code
  3846.   * some subfunctions return value in other registers too
  3847. General format of the information structure:
  3848.   * +0: dword: subfunction number
  3849.   * +4: dword: file offset
  3850.   * +8: dword: high dword of offset (must be 0) or flags field
  3851.   * +12 = +0xC: dword: size
  3852.   * +16 = +0x10: dword: pointer to data
  3853.   * +20 = +0x14: ?: path - zero terminated string
  3854.   or
  3855.   * +20 = +0x14: byte: 0
  3856.   * +21 = +0x15: dword: pointer to string
  3857. Case sensitivity depends on filesystem.
  3858. To set the encoding, put at the start of the string a byte with next values:
  3859.   * 1 = cp866
  3860.   * 2 = UTF-16LE
  3861.   * 3 = UTF-8
  3862.   otherwise will be used cp866.
  3863. Format of filename:
  3864.   /base/number/dir1/dir2/.../dirn/file,
  3865. where base/number identifies device, on which file is located:
  3866.   * RD/1 = ramdisk
  3867.   * FD/1 = first floppy drive,
  3868.     FD/2 = second floppy drive
  3869.   * HD0/x, HD1/x, HD2/x, HD3/x = hard drives accordingly on
  3870.     IDE0 (Primary Master), IDE1 (Primary Slave),
  3871.     IDE2 (Secondary Master), IDE3 (Secondary Slave);
  3872.     x - partition number on the selected hard drive, starts from 1
  3873.   * CD0/1, CD1/1, CD2/1, CD3/1 = same for cd
  3874.   * SYS = system folder (encoding inaffected key),
  3875.     second key may be set by sysfunction 30.3.
  3876. Examples:
  3877.   * '/sys/example.asm',0
  3878.   * '/rd/1/example.asm',0
  3879.   * '/HD0/1/folder/file.txt',0
  3880.   * '/hd2/2/pics/tanzania.bmp',0
  3881.   * 2,'/',0,'sys','/',0,'F',0,'I',0,'L',0,'E',0,0,0
  3882. Also function supports relative names.  If the path begins not
  3883. with '/', it is considered relative to a current folder. To get or
  3884. set a current folder, use the function 30.
  3885.  
  3886. Available subfunctions:
  3887.   * subfunction 0 - read file
  3888.   * subfunction 1 - read folder
  3889.   * subfunction 2 - create/rewrite file
  3890.   * subfunction 3 - write to existing file
  3891.   * subfunction 4 - set file size
  3892.   * subfunction 5 - get attributes of file/folder
  3893.   * subfunction 6 - set attributes of file/folder
  3894.   * subfunction 7 - start application
  3895.   * subfunction 8 - delete file/folder
  3896.   * subfunction 9 - create folder
  3897. For CD-drives due to hardware limitations only subfunctions
  3898. 0,1,5 and 7 are available, other subfunctions return error
  3899. with code 2.
  3900. At the first call of subfunctions 0,1,5,7 to ATAPI devices
  3901. (CD and DVD) the manual control of tray is locked due to caching
  3902. drive data. Unlocking is made when subfunction 4 of function 24
  3903. is called for corresponding device.
  3904.  
  3905. ---------------------- Constants for registers: ----------------------
  3906.   eax - SF_FILE (70)
  3907.  [ebx] - SSF_READ_FILE (0), SSF_READ_FOLDER (1), SSF_CREATE_FILE (2),
  3908.     SSF_WRITE_FILE (3), SSF_SET_END (4), SSF_GET_INFO (5),
  3909.     SSF_SET_INFO (6), SSF_START_APP (7), SSF_DELETE (8),
  3910.     SSF_CREATE_FOLDER (9)
  3911. ======================================================================
  3912. === Function 70, subfunction 0 - read file with long names support. ==
  3913. ======================================================================
  3914. Parameters:
  3915.   * eax = 70 - function number
  3916.   * ebx = pointer to the information structure
  3917. Format of the information structure:
  3918.   * +0: dword: 0 = subfunction number
  3919.   * +4: dword: file offset (in bytes)
  3920.   * +8: dword: 0 (reserved for high dword of offset)
  3921.   * +12 = +0xC: dword: number of bytes to read
  3922.   * +16 = +0x10: dword: pointer to buffer for data
  3923.   * +20 = +0x14: path, general rules of names forming
  3924. Returned value:
  3925.   * eax = 0 - success, otherwise file system error code
  3926.   * ebx = number of read bytes or -1=0xffffffff if file was not found
  3927. Remarks:
  3928.   * If file was ended before last requested block was read,
  3929.     the function will read as many as it can, and after that return
  3930.     eax=6 (EOF).
  3931.   * The function does not allow to read folder (returns eax=10,
  3932.     access denied).
  3933.  
  3934. ---------------------- Constants for registers: ----------------------
  3935.   eax - SF_FILE (70)
  3936.  [ebx] - SSF_READ_FILE (0)
  3937. ======================================================================
  3938. == Function 70, subfunction 1 - read folder with long names support. =
  3939. ======================================================================
  3940. Parameters:
  3941.   * eax = 70 - function number
  3942.   * ebx = pointer to the information structure
  3943. Format of the information structure:
  3944.   * +0: dword: 1 = subfunction number
  3945.   * +4: dword: index of starting block (beginning from 0)
  3946.   * +8: dword: encoding:
  3947.     * 0 = cp866 -> byte per char
  3948.     * 1 = UTF-16LE -> word per char
  3949.   * +12 = +0xC: dword: number of blocks to read
  3950.   * +16 = +0x10: dword: pointer to buffer for data, buffer size
  3951.     must be not less than 32+n(40+256*enc+8) bytes
  3952.   * +20 = +0x14: path, general rules of names forming
  3953. Returned value:
  3954.   * eax = 0 - success, otherwise file system error code
  3955.   * ebx = number of files, information on which was written to
  3956.     the buffer, or -1=0xffffffff, if folder was not found
  3957. Structure of the buffer:
  3958.   * header (32 bytes)
  3959.   * block with information on file 1
  3960.   * block with information on file 2
  3961.   * ...
  3962. Structure of header:
  3963.   * +0: dword: version of structure (current is 1)
  3964.   * +4: dword: number of placed blocks; is not greater than requested
  3965.     in the field +12 of information structure; can be less, if
  3966.     there are no more files in folder (the same as in ebx)
  3967.   * +8: dword: total number of files in folder
  3968.   * +12 = +0xC: 20*byte: reserved (zeroed)
  3969. Structure of block of data for folder entry (BDFE):
  3970.   * +0: dword: attributes of file:
  3971.     * bit 0 (mask 1): file is read-only
  3972.     * bit 1 (mask 2): file is hidden
  3973.     * bit 2 (mask 4): file is system
  3974.     * bit 3 (mask 8): this is not a file but volume label
  3975.       (for one partition meets no more than once and
  3976.       only in root folder)
  3977.     * bit 4 (mask 0x10): this is a folder
  3978.     * bit 5 (mask 0x20): file was not archived - many archivation
  3979.       programs have an option to archive only files with this bit set,
  3980.       and after archiving this bit is cleared - it can be useful
  3981.       for automatically creating of backup-archives as at writing
  3982.       this bit is usually set
  3983.   * +4: dword: encoding:
  3984.     * 0 = cp866 -> byte per char
  3985.     * 1 = UTF-16LE -> word per char
  3986.   * +8: 4*byte: time of file creation
  3987.   * +12 = +0xC: 4*byte: date of file creation
  3988.   * +16 = +0x10: 4*byte: time of last access (read or write)
  3989.   * +20 = +0x14: 4*byte: date of last access
  3990.   * +24 = +0x18: 4*byte: time of last modification
  3991.   * +28 = +0x1C: 4*byte: date of last modification
  3992.   * +32 = +0x20: qword: file size in bytes (up to 16777216 Tb)
  3993.   * +40 = +0x28: (256*enc+8)*byte: name
  3994. Time format:
  3995.   * +0: byte: seconds
  3996.   * +1: byte: minutes
  3997.   * +2: byte: hours
  3998.   * +3: byte: reserved (0)
  3999.   * for example, 23.59.59 is written as (in hex) 3B 3B 17 00
  4000. Date format:
  4001.   * +0: byte: day
  4002.   * +1: byte: month
  4003.   * +2: word: year
  4004.   * for example, 25.11.1979 is written as (in hex) 19 0B BB 07
  4005. Remarks:
  4006.   * If BDFE contains cp866 name, the length of BDFE is 304 bytes,
  4007.     if UTF-16LE name - 560 bytes. Value of length is aligned
  4008.     on 16-byte bound to accelerate processing in CPU cache.
  4009.   * Name string is zero terminated, further data contain garbage.
  4010.   * If files in folder were ended before requested number was read,
  4011.     the function will read as many as it can, and after that return
  4012.     eax=6 (EOF).
  4013.   * Any folder on the disk, except for root, contains two special
  4014.     entries "." and "..", identifying accordingly the folder itself
  4015.     and the parent folder.
  4016.   * The function allows also to read virtual folders "/", "/rd",
  4017.     "/fd", "/hd[n]", thus attributes of subfolders are set to 0x10,
  4018.     and times and dates are zeroed. An alternative way to get the
  4019.     equipment information - subfunction 11 of function 18.
  4020.  
  4021. ---------------------- Constants for registers: ----------------------
  4022.   eax - SF_FILE (70)
  4023.  [ebx] - SSF_READ_FOLDER (1)
  4024. ======================================================================
  4025. ===================== Function 70, subfunction 2 =====================
  4026. ============ Create/rewrite file with long names support. ============
  4027. ======================================================================
  4028. Parameters:
  4029.   * eax = 70 - function number
  4030.   * ebx = pointer to the information structure
  4031. Format of the information structure:
  4032.   * +0: dword: 2 = subfunction number
  4033.   * +4: dword: 0 (reserved)
  4034.   * +8: dword: 0 (reserved)
  4035.   * +12 = +0xC: dword: number of bytes to write
  4036.   * +16 = +0x10: dword: pointer to data
  4037.   * +20 = +0x14: path, general rules of names forming
  4038. Returned value:
  4039.   * eax = 0 - success, otherwise file system error code
  4040.   * ebx = number of written bytes (possibly 0)
  4041. Remarks:
  4042.   * If a file with given name did not exist, it is created;
  4043.     if it existed, it is rewritten.
  4044.   * If there is not enough free space on disk, the function will
  4045.     write as many as can and then return error code 8.
  4046.   * The function is not supported for CD (returns error code 2).
  4047.  
  4048. ---------------------- Constants for registers: ----------------------
  4049.   eax - SF_FILE (70)
  4050.  [ebx] - SSF_CREATE_FILE (2)
  4051. ======================================================================
  4052. ===================== Function 70, subfunction 3 =====================
  4053. =========== Write to existing file with long names support. ==========
  4054. ======================================================================
  4055. Parameters:
  4056.   * eax = 70 - function number
  4057.   * ebx = pointer to the information structure
  4058. Format of the information structure:
  4059.   * +0: dword: 3 = subfunction number
  4060.   * +4: dword: file offset (in bytes)
  4061.   * +8: dword: high dword of offset (must be 0 for FAT)
  4062.   * +12 = +0xC: dword: number of bytes to write
  4063.   * +16 = +0x10: dword: pointer to data
  4064.   * +20 = +0x14: path, general rules of names forming
  4065. Returned value:
  4066.   * eax = 0 - success, otherwise file system error code
  4067.   * ebx = number of written bytes (possibly 0)
  4068. Remarks:
  4069.   * The file must already exist, otherwise function returns eax=5.
  4070.   * The only result of write 0 bytes is update in the file attributes
  4071.     date/time of modification and access to the current date/time.
  4072.   * If beginning and/or ending position is greater than file size
  4073.     (except for the previous case), the file is expanded to needed
  4074.     size with zero characters.
  4075.   * The function is not supported for CD (returns error code 2).
  4076.  
  4077. ---------------------- Constants for registers: ----------------------
  4078.   eax - SF_FILE (70)
  4079.  [ebx] - SSF_WRITE_FILE (3)
  4080. ======================================================================
  4081. ============ Function 70, subfunction 4 - set end of file. ===========
  4082. ======================================================================
  4083. Parameters:
  4084.   * eax = 70 - function number
  4085.   * ebx = pointer to the information structure
  4086. Format of the information structure:
  4087.   * +0: dword: 4 = subfunction number
  4088.   * +4: dword: low dword of new file size
  4089.   * +8: dword: high dword of new file size (must be 0 for FAT)
  4090.   * +12 = +0xC: dword: 0 (reserved)
  4091.   * +16 = +0x10: dword: 0 (reserved)
  4092.   * +20 = +0x14: path, general rules of names forming
  4093. Returned value:
  4094.   * eax = 0 - success, otherwise file system error code
  4095.   * ebx destroyed
  4096. Remarks:
  4097.   * If the new file size is less than old one, file is truncated.
  4098.     If the new size is greater than old one, file is expanded with
  4099.     characters with code 0. If the new size is equal to old one,
  4100.     the only result of call is set date/time of modification and
  4101.     access to the current date/time.
  4102.   * If there is not enough free space on disk for expansion, the
  4103.     function will expand to maximum possible size and then return
  4104.     error code 8.
  4105.   * The function is not supported for CD (returns error code 2).
  4106.  
  4107. ---------------------- Constants for registers: ----------------------
  4108.   eax - SF_FILE (70)
  4109.  [ebx] - SSF_SET_END (4)
  4110. ======================================================================
  4111. ==== Function 70, subfunction 5 - get information on file/folder. ====
  4112. ======================================================================
  4113. Parameters:
  4114.   * eax = 70 - function number
  4115.   * ebx = pointer to the information structure
  4116. Format of the information structure:
  4117.   * +0: dword: 5 = subfunction number
  4118.   * +4: dword: 0 (reserved)
  4119.   * +8: dword: 0 or flags (for the root folder)
  4120.   * +12 = +0xC: dword: 0 (reserved)
  4121.   * +16 = +0x10: dword: pointer to buffer for data (40 bytes)
  4122.   * +20 = +0x14: path, general rules of names forming
  4123. Returned value:
  4124.   * eax = 0 - success, otherwise file system error code
  4125.   * ebx destroyed
  4126. Information on file is returned in the BDFE format (block of data
  4127. for folder entry), explained in the description of subfunction 1,
  4128. but without filename, except the root folder.
  4129. Remarks:
  4130.   * For the root folder returns size and name of partition.
  4131.   * The function does not support virtual folders such as / and /rd.
  4132.  
  4133. ---------------------- Constants for registers: ----------------------
  4134.   eax - SF_FILE (70)
  4135.  [ebx] - SSF_GET_INFO (5)
  4136. ======================================================================
  4137. ===== Function 70, subfunction 6 - set attributes of file/folder. ====
  4138. ======================================================================
  4139. Parameters:
  4140.   * eax = 70 - function number
  4141.   * ebx = pointer to the information structure
  4142. Format of the information structure:
  4143.   * +0: dword: 6 = subfunction number
  4144.   * +4: dword: 0 (reserved)
  4145.   * +8: dword: 0 (reserved)
  4146.   * +12 = +0xC: dword: 0 (reserved)
  4147.   * +16 = +0x10: dword: pointer to buffer with attributes (32 bytes)
  4148.   * +20 = +0x14: path, general rules of names forming
  4149. Returned value:
  4150.   * eax = 0 - success, otherwise file system error code
  4151.   * ebx destroyed
  4152. File attributes are first 32 bytes in BDFE (block of data
  4153. for folder entry), explained in the description of subfunction 1
  4154. (that is, without name and size of file). Attribute
  4155. file/folder/volume label (bits 3,4 in dword +0) is not changed.
  4156. Byte +4 (name format) is ignored.
  4157. Remarks:
  4158.   * The function does not support virtual folders such as /, /rd and
  4159.     root folders like /rd/1.
  4160.   * The function is not supported for CD (returns error code 2).
  4161.  
  4162. ---------------------- Constants for registers: ----------------------
  4163.   eax - SF_FILE (70)
  4164.  [ebx] - SSF_SET_INFO (6)
  4165. ======================================================================
  4166. =========== Function 70, subfunction 7 - start application. ==========
  4167. ======================================================================
  4168. Parameters:
  4169.   * eax = 70 - function number
  4170.   * ebx = pointer to the information structure
  4171. Format of the information structure:
  4172.   * +0: dword: 7 = subfunction number
  4173.   * +4: dword: flags field:
  4174.     * bit 0: start process as debugged
  4175.     * other bits are reserved and must be set to 0
  4176.   * +8: dword: 0 or pointer to ASCIIZ-string with parameters
  4177.   * +12 = +0xC: dword: 0 (reserved)
  4178.   * +16 = +0x10: dword: 0 (reserved)
  4179.   * +20 = +0x14: path, general rules of names forming
  4180. Returned value:
  4181.   * eax > 0 - program is loaded, eax contains PID
  4182.   * eax < 0 - an error has occured, -eax contains
  4183.     file system error code
  4184.   * ebx destroyed
  4185. Remarks:
  4186.   * Command line must be terminated by the character with the code 0
  4187.     (ASCIIZ-string); function takes into account either all characters
  4188.     up to terminating zero inclusively or first 256 character
  4189.     regarding what is less.
  4190.   * If the process is started as debugged, it is created in
  4191.     the suspended state; to run use subfunction 5 of function 69.
  4192.  
  4193. ---------------------- Constants for registers: ----------------------
  4194.   eax - SF_FILE (70)
  4195.  [ebx] - SSF_START_APP (7)
  4196. ======================================================================
  4197. ========== Function 70, subfunction 8 - delete file/folder. ==========
  4198. ======================================================================
  4199. Parameters:
  4200.   * eax = 70 - function number
  4201.   * ebx = pointer to the information structure
  4202. Format of the information structure:
  4203.   * +0: dword: 8 = subfunction number
  4204.   * +4: dword: 0 (reserved)
  4205.   * +8: dword: 0 (reserved)
  4206.   * +12 = +0xC: dword: 0 (reserved)
  4207.   * +16 = +0x10: dword: 0 (reserved)
  4208.   * +20 = +0x14: path, general rules of names forming
  4209. Returned value:
  4210.   * eax = 0 - success, otherwise file system error code
  4211.   * ebx destroyed
  4212. Remarks:
  4213.   * The function is not supported for CD (returns error code 2).
  4214.   * The function can delete only empty folders (attempt to delete
  4215.     nonempty folder results in error with code 10, "access denied").
  4216.  
  4217. ---------------------- Constants for registers: ----------------------
  4218.   eax - SF_FILE (70)
  4219.  [ebx] - SSF_DELETE (8)
  4220. ======================================================================
  4221. ============= Function 70, subfunction 9 - create folder. ============
  4222. ======================================================================
  4223. Parameters:
  4224.   * eax = 70 - function number
  4225.   * ebx = pointer to the information structure
  4226. Format of the information structure:
  4227.   * +0: dword: 9 = subfunction number
  4228.   * +4: dword: 0 (reserved)
  4229.   * +8: dword: 0 (reserved)
  4230.   * +12 = +0xC: dword: 0 (reserved)
  4231.   * +16 = +0x10: dword: 0 (reserved)
  4232.   * +20 = +0x14: path, general rules of names forming
  4233. Returned value:
  4234.   * eax = 0 - success, otherwise file system error code
  4235.   * ebx destroyed
  4236. Remarks:
  4237.   * The function is not supported for CD (returns error code 2).
  4238.   * The parent folder must already exist.
  4239.   * If target folder already exists, function returns success (eax=0).
  4240.  
  4241. ---------------------- Constants for registers: ----------------------
  4242.   eax - SF_FILE (70)
  4243.  [ebx] - SSF_CREATE_FOLDER (9)
  4244. ======================================================================
  4245. ========== Function 71, subfunction 1 - set window caption. ==========
  4246. ======================================================================
  4247. Parameters:
  4248.   * eax = 71 - function number
  4249.   * ebx = 1 - subfunction number
  4250.   * ecx = pointer to zero terminated string
  4251. Returned value:
  4252.   * function does not return value
  4253. Remarks:
  4254.   * You may set the caption string encoding by putting
  4255.     at the start of the string a byte with next values:
  4256.     1 = cp866
  4257.     2 = UTF-16LE
  4258.     3 = UTF-8
  4259.     otherwise will be used cp866.
  4260.   * Pass NULL in ecx to remove caption.
  4261.  
  4262. ---------------------- Constants for registers: ----------------------
  4263.   eax - SF_SET_CAPTION (71)
  4264. ======================================================================
  4265. =============== Function 72 - send message to a window. ==============
  4266. ======================================================================
  4267.  
  4268. - Subfunction 1 - send message with parameter to the active window. --
  4269. Parameters:
  4270.   * eax = 72 - function number
  4271.   * ebx = 1 - subfunction number
  4272.   * ecx = event code: 2 or 3
  4273.   * edx = parameter: key code for ecx=2, button identifier for ecx=3
  4274. Returned value:
  4275.   * eax = 0 - success
  4276.   * eax = 1 - buffer is full
  4277.  
  4278. ---------------------- Constants for registers: ----------------------
  4279.   eax - SF_SEND_MESSAGE (72)
  4280. ======================================================================
  4281. ===================== Function 73 - blit bitmap  =====================
  4282. ======================================================================
  4283.  
  4284. Parameters:
  4285.   * eax = 73 - function number
  4286.  
  4287.   * ebx = ROP and optional flags
  4288.      31           6 5  4 3   0
  4289.      [  reserved  ][T][B][ROP]
  4290.      ROP - raster operation code
  4291.         0: Copy
  4292.      1-15: reserved
  4293.      B   - blit into the background surface
  4294.      T   - transparent blit
  4295.  
  4296.   * ecx = pointer to the function parameters
  4297.         destination offset and clipping
  4298.      +0 signed dword: destination rectangle X offset from the window
  4299.                       top-left corner
  4300.      +4 signed dword: destination rectangle Y offset from the window
  4301.                       top-left corner
  4302.      +8 dword:        destination rectangle width
  4303.     +12 dword:        destination rectangle height
  4304.  
  4305.         source offset and clipping
  4306.     +16 signed dword: source rectangle X offset from the bitmap
  4307.                       top-left corner
  4308.     +20 signed dword: source rectangle Y offset from the bitmap
  4309.                       top-left corner
  4310.     +24 dword:        source rectangle width
  4311.     +28 dword:        source rectangle height
  4312.  
  4313.     +32: dword: bitmap data - must be 32bpp
  4314.     +36: dword: size of the bitmap row in bytes
  4315.  
  4316. Returned value:
  4317.   * function does not return value
  4318.  
  4319. ---------------------- Constants for registers: ----------------------
  4320.   eax - SF_BLITTER (73)
  4321. ======================================================================
  4322. = Function 74, Subfunction 255, Get number of active network devices. =
  4323. ======================================================================
  4324. Parameters:
  4325.   * eax = 74 - function number
  4326.   * bl = 255 - subfunction number
  4327. Returned value:
  4328.   * eax = number of active network devices
  4329.  
  4330. ---------------------- Constants for registers: ----------------------
  4331.   eax - SF_NETWORK_GET (74)
  4332.    bl - SSF_DEVICE_COUNT (255)
  4333. ======================================================================
  4334. ======== Function 74, Subfunction 0, Get network device type. ========
  4335. ======================================================================
  4336. Parameters:
  4337.   * eax = 74 - function number
  4338.   * bl = 0 - subfunction number
  4339.   * bh = device number
  4340. Returned value:
  4341.   * eax = device type number
  4342.  
  4343. ---------------------- Constants for registers: ----------------------
  4344.   eax - SF_NETWORK_GET (74)
  4345.    bl - SSF_DEVICE_TYPE (0)
  4346. ======================================================================
  4347. ======== Function 74, Subfunction 1, Get network device name. ========
  4348. ======================================================================
  4349. Parameters:
  4350.   * eax = 74 - function number
  4351.   * bl = 1 - subfunction number
  4352.   * bh = device number
  4353.   * ecx = pointer to 64 byte buffer
  4354. Returned value:
  4355.   * eax = -1 on error
  4356.   * The network device name is written into the buffer, on success
  4357.  
  4358. ---------------------- Constants for registers: ----------------------
  4359.   eax - SF_NETWORK_GET (74)
  4360.    bl - SSF_DEVICE_NAME (1)
  4361. ======================================================================
  4362. ========= Function 74, Subfunction 2, Reset network device. ==========
  4363. ======================================================================
  4364. Parameters:
  4365.   * eax = 74 - function number
  4366.   * bl = 2 - subfunction number
  4367.   * bh = device number
  4368. Returned value:
  4369.   * eax = -1 on error
  4370.  
  4371. ---------------------- Constants for registers: ----------------------
  4372.   eax - SF_NETWORK_GET (74)
  4373.    bl - SSF_RESET_DEVICE (2)
  4374. ======================================================================
  4375. ========== Function 74, Subfunction 3, Stop network device. ==========
  4376. ======================================================================
  4377. Parameters:
  4378.   * eax = 74 - function number
  4379.   * bl = 3 - subfunction number
  4380.   * bh = device number
  4381. Returned value:
  4382.   * eax = -1 on error
  4383.  
  4384. ---------------------- Constants for registers: ----------------------
  4385.   eax - SF_NETWORK_GET (74)
  4386.    bl - SSF_STOP_DEVICE (3)
  4387. ======================================================================