;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SYSTEM FUNCTIONS of OS Kolibri 0.7.7.0 Number of the function is located in the register eax. The call of the system function is executed by "int 0x40" command. All registers except explicitly declared in the returned value, including eflags, are preserved. ====================================================================== ============== Function 0 - define and draw the window. ============== ====================================================================== Defines an application window. Draws a frame of the window, header and working area. For skinned windows defines standard close and minimize buttons. Parameters: * eax = 0 - function number * ebx = [coordinate on axis x]*65536 + [size on axis x] * ecx = [coordinate on axis y]*65536 + [size on axis y] * edx = 0xXYRRGGBB, where: * Y = style of the window: * Y=1 - only define window area, draw nothing * Y=3 - skinned window * Y=4 - skinned fixed-size window * Y=0,2 window types are outdated and should not be used anymore, they are retained for compatibility with old programs. * other possible values (from 5 to 15) are reserved, function call with such Y is ignored * RR, GG, BB = accordingly red, green, blue components of a color of the working area of the window (are ignored for style Y=1) * X = DCBA (bits) * A = 1 - window has caption * B = 1 - coordinates of all graphics primitives are relative to window client area * C = 1 - don't fill working area on window draw * D = 0 - normal filling of the working area, 1 - gradient The following parameters are intended for windows of a type I and II, and ignored for styles Y=1,3: * esi = 0xXYRRGGBB - color of the header * RR, GG, BB define color * Y=0 - usual window, Y=1 - unmovable window (works for all window styles) * X not used, other values of Y are reserved * edi = caption string for styles Y=3,4 (also can be set by func 71.1) Returned value: * function does not return value Remarks: * Position and sizes of the window are installed by the first call of this function and are ignored at subsequent; to change position and/or sizes of already created window use function 67. * For windows with styles Y=3,4 and caption (A=1) caption string is set by the first call of this function and is ignored at subsequent (strictly speaking, is ignored after a call to subfunction 2 of function 12 - end redraw); to change caption of already created window use subfunction 1 of function 71. * If the window has appropriate styles, position and/or sizes can be changed by user. Current position and sizes can be obtained by function 9. * The window must fit on the screen. If the transferred coordinates and sizes do not satisfy to this condition, appropriate coordinate (or, probably, both) is considered as zero, and if it does not help too, the appropriate size (or, probably, both) is installed in a size of the screen. Further let us designate xpos,ypos,xsize,ysize - values passed in ebx,ecx. The coordinates are resulted concerning the left upper corner of the window, which, thus, is set as (0,0), coordinates of the right lower corner essence (xsize,ysize). * The sizes of the window are understood in sense of coordinates of the right lower corner. This concerns all other functions too. It means, that the real sizes are on 1 pixel more. * The window of style Y=1 looks as follows: * completely defined by the application * The skinned window Y=3,4 looks as follows: * draw external frame of width 1 pixel with color 'outer' from the skin * draw intermediate frame of width 3 pixel with color 'frame' from the skin * draw internal frame of width 1 pixel with color 'inner' from the skin * draw header (on bitmaps from the skin) in a rectangle (0,0) - (xsize,_skinh-1) * if ysize>=26, fill the working area of the window - rectangle with the left upper corner (5,_skinh) and right lower (xsize-5,ysize-5) with color indicated in edx (taking a gradient into account) * define two standard buttons: close and minimize (see function 8) * if A=1 and edi contains (nonzero) pointer to caption string, it is drawn in place in header defined in the skin * value _skinh is accessible as the result of call subfunction 4 of function 48 ---------------------- Constants for registers: ---------------------- eax - SF_CREATE_WINDOW (0) ====================================================================== ================ Function 1 - put pixel in the window. =============== ====================================================================== Parameters: * eax = 1 - function number * ebx = x-coordinate (relative to the window) * ecx = y-coordinate (relative to the window) * edx = 0x00RRGGBB - color of a pixel edx = 0x01xxxxxx - invert color of a pixel (low 24 bits are ignored) Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_PUT_PIXEL (1) ====================================================================== ============ Function 2 - get the code of the pressed key. =========== ====================================================================== Takes away the code of the pressed key from the buffer. Parameters: * eax = 2 - function number Returned value: * if the buffer is empty, function returns eax=1 * if the buffer is not empty, function returns al=0, ah=code of the pressed key, bits 16-23 = contain scancode for pressed key in ASCII mode, in the scancodes mode this bits cleared. bits 23-31 = zero * if there is "hotkey", function returns al=2, ah=scancode of the pressed key (0 for control keys), high word of eax contains a status of control keys at the moment of pressing a hotkey Remarks: * There is a common system buffer of the pressed keys by a size of 120 bytes, organized as queue. * There is one more common system buffer on 120 "hotkeys". * If the application with the inactive window calls this function, the buffer of the pressed keys is considered to be empty. * By default this function returns ASCII-codes; to switch to the scancodes mode (and back) use function 66. However, hotkeys are always notificated as scancodes. * To find out, what keys correspond to what codes, start the application keyascii and scancode. * Scancodes come directly from keyboard and are fixed; ASCII-codes turn out with usage of the conversion tables, which can be set by subfunction 2 of function 21 and get by subfunction 2 of function 26. * As a consequence, ASCII-codes take into account current keyboard layout (rus/en) as opposed to scancodes. * This function notifies only about those hotkeys, which were defined by this thread by subfunction 4 of function 66. ---------------------- Constants for registers: ---------------------- eax - SF_GET_KEY (2) ====================================================================== ==================== Function 3 - get system time. =================== ====================================================================== Parameters: * eax = 3 - function number Returned value: * eax = 0x00SSMMHH, where HH:MM:SS = Hours:Minutes:Seconds * each item is BCD-number, for example, for time 23:59:59 function returns 0x00595923 Remarks: * See also subfunction 9 of function 26 - get time from the moment of start of the system; it is more convenient, because returns simply DWORD-value of the time counter. * System time can be set by function 22. ---------------------- Constants for registers: ---------------------- eax - SF_GET_SYS_TIME (3) ====================================================================== =================== Function 4 - draw text string. =================== ====================================================================== Parameters: * eax = 4 - function number * ebx = X*65536+Y, coordinates in the window or buffer * ecx = 0xXXRRGGBB, where * RR, GG, BB specify text color * XX = ABFFCSSS (bits): * A=1 - output zero terminated string * B=1 - fill background (color = edi) * FF specifies the font and encoding: 0 = 6x9 cp866 1 = 8x16 cp866 2 = 8x16 UTF-16LE 3 = 8x16 UTF-8 * C=0 - draw to the window, C=1 - draw to the user buffer (edi) * SSS = (size multiplier)-1, so 0 = x1, 7 = x8 * edx = pointer to the beginning of the string * esi = for A=0 length of the string, for A=1 is ignored * edi = for B=1 color to fill background, for C=1 pointer to user buffer Returned value: * function does not return value Remarks: * You can not use B=1 and C=1 at the same time, since both use edi. * When SSS=0, font may be smoothed, depending on system setting. * User buffer structure: Xsize dd Ysize dd picture rb Xsize*Ysize*4 ; 32 bpp ---------------------- Constants for registers: ---------------------- eax - SF_DRAW_TEXT (4) ====================================================================== ========================= Function 5 - delay. ======================== ====================================================================== Delays execution of the program on the given time. Parameters: * eax = 5 - function number * ebx = time in the 1/100 of second Returned value: * function does not return value Remarks: * Passing ebx=0 does not transfer control to the next process and does not make any operations at all. If it is really required to transfer control to the next process (to complete a current time slice), use subfunction 1 of function 68. ---------------------- Constants for registers: ---------------------- eax - SF_SLEEP (5) ====================================================================== =============== Function 7 - draw image in the window. =============== ====================================================================== Paramters: * eax = 7 - function number * ebx = pointer to the image in the format BBGGRRBBGGRR... * ecx = [size on axis x]*65536 + [size on axis y] * edx = [coordinate on axis x]*65536 + [coordinate on axis y] Returned value: * function does not return value Remarks: * Coordinates of the image are coordinates of the upper left corner of the image relative to the window. * Size of the image in bytes is 3*xsize*ysize. ---------------------- Constants for registers: ---------------------- eax - SF_PUT_IMAGE (7) ====================================================================== =============== Function 8 - define/delete the button. =============== ====================================================================== Parameters for button definition: * eax = 8 - function number * ebx = [coordinate on axis x]*65536 + [size on axis x] * ecx = [coordinate on axis y]*65536 + [size on axis y] * edx = 0xXYnnnnnn, where: * nnnnnn = identifier of the button * high (31st) bit of edx is cleared * if 30th bit of edx is set - do not draw the button * if 29th bit of edx is set - do not draw a frame at pressing the button * esi = 0x00RRGGBB - color of the button Parameters for button deleting: * eax = 8 - function number * edx = 0x80nnnnnn, where nnnnnn - identifier of the button Returned value: * function does not return value Remarks: * Sizes of the button must be more than 0 and less than 0x8000. * For skinned windows definition of the window (call of 0th function) creates two standard buttons - for close of the window with identifier 1 and for minimize of the window with identifier 0xffff. * The creation of two buttons with same identifiers is admitted. * The button with the identifier 0xffff at pressing is interpreted by the system as the button of minimization, the system handles such pressing independently, not accessing to the application. In rest it is usual button. * Total number of buttons for all applications is limited to 4095. ---------------------- Constants for registers: ---------------------- eax - SF_DEFINE_BUTTON (8) ====================================================================== ============ Function 9 - information on execution thread. =========== ====================================================================== Parameters: * eax = 9 - function number * ebx = pointer to 1-Kb buffer * ecx = number of the slot of the thread ecx = -1 - get information on the current thread Returned value: * eax = maximum number of the slot of a thread but if pointer in ebx is illegal, for example, [ebx, ebx + 0x4C) region intersects with kernel memory, then function returns -1 * buffer pointed to by ebx contains the following information: * +0: dword: usage of the processor (how many time units per second leaves on execution of this thread) * +4: word: position of the window of thread in the window stack * +6: word: (has no relation to the specified thread) number of the thread slot, which window has in the window stack position ecx * +8: word: reserved * +10 = +0xA: 11 bytes: name of the process (name of the started file - executable file without extension) * +21 = +0x15: byte: reserved, this byte is not changed * +22 = +0x16: dword: address of the process in memory * +26 = +0x1A: dword: size of used memory - 1 * +30 = +0x1E: dword: identifier (PID/TID) * +34 = +0x22: dword: coordinate of the thread window on axis x * +38 = +0x26: dword: coordinate of the thread window on axis y * +42 = +0x2A: dword: size of the thread window on axis x * +46 = +0x2E: dword: size of the thread window on axis y * +50 = +0x32: word: status of the thread slot: * 0 = thread is running * 1 = thread is suspended * 2 = thread is suspended while waiting for event * 3 = thread is terminating as a result of call to function -1 or under duress as a result of call to subfunction 2 of function 18 or termination of the system * 4 = thread is terminating as a result of exception * 5 = thread waits for event * 9 = requested slot is free, all other information on the slot is not meaningful * +52 = +0x34: word: reserved, this word is not changed * +54 = +0x36: dword: coordinate of the client area on axis x * +58 = +0x3A: dword: coordinate of the client area on axis y * +62 = +0x3E: dword: width of the client area * +66 = +0x42: dword: height of the client area * +70 = +0x46: byte: state of the window - bitfield * bit 0 (mask 1): window is maximized * bit 1 (mask 2): window is minimized to panel * bit 2 (mask 4): window is rolled up * +71 = +0x47: dword: event mask * +75 = +0x4B: byte: keyboard mode(ASCII = 0; SCAN = 1) Remarks: * Slots are numbered starting from 1. * Returned value is not a total number of threads, because there can be free slots. * When process is starting, system automatically creates execution thread. * Function gives information on the thread. Each process has at least one thread. One process can create many threads, in this case each thread has its own slot and the fields +10, +22, +26 in these slots coincide. Applications have no common way to define whether two threads belong to one process. * The active window - window on top of the window stack - receives the messages on a keyboard input. For such window the position in the window stack coincides with returned value. * Slot 1 corresponds to special system thread, for which: * the window is in the bottom of the window stack, the fields +4 and +6 contain value 1 * name of the process - "OS/IDLE" (supplemented by spaces) * address of the process in memory is 0, size of used memory is 16 Mb (0x1000000) * PID=1 * coordinates and sizes of the window and the client area are by convention set to 0 * status of the slot is always 0 (running) * the execution time adds of time leaving on operations itself and idle time in waiting for interrupt (which can be got by call to subfunction 4 of function 18). * Beginning from slot 2, the normal applications are placed. * The normal applications are placed in memory at the address 0 (kernel constant 'std_application_base_address'). There is no intersection, as each process has its own page table. * At creation of the thread it is assigned the slot in the system table and identifier (Process/Thread IDentifier = PID/TID), which do not vary with time for given thread. After completion of the thread its slot can be anew used for another thread. The thread identifier can not be assigned to other thread even after completion of this thread. Identifiers, assigned to new threads, grow monotonously. * If the thread has not yet defined the window by call to function 0, the position and the sizes of its window are considered to be zero. * Coordinates of the client area are relative to the window. * At the moment only the part of the buffer by a size 76 = 0x4C bytes is used. Nevertheless it is recommended to use 1-Kb buffer for the future compatibility, in the future some fields can be added. ---------------------- Constants for registers: ---------------------- eax - SF_THREAD_INFO (9) ====================================================================== ==================== Function 10 - wait for event. =================== ====================================================================== If the message queue is empty, waits for appearance of the message in queue. In this state thread does not consume CPU time. Then reads out the message from queue. Parameters: * eax = 10 - function number Returned value: * eax = event (see the list of events) Remarks: * Those events are taken into account only which enter into a mask set by function 40. By default it is redraw, key and button events. * To check, whether there is a message in queue, use function 11. To wait for no more than given time, use function 23. ---------------------- Constants for registers: ---------------------- eax - SF_WAIT_EVENT (10) ====================================================================== =============== Function 11 - check for event, no wait. ============== ====================================================================== If the message queue contains event, function reads out and return it. If the queue is empty, function returns 0. Parameters: * eax = 11 - function number Returned value: * eax = 0 - message queue is empty * else eax = event (see the list of events) Remarks: * Those events are taken into account only, which enter into a mask set by function 40. By default it is redraw, key and button events. * To wait for event, use function 10. To wait for no more than given time, use function 23. ---------------------- Constants for registers: ---------------------- eax - SF_CHECK_EVENT (11) ====================================================================== =============== Function 12 - begin/end window redraw. =============== ====================================================================== ---------------- Subfunction 1 - begin window redraw. ---------------- Parameters: * eax = 12 - function number * ebx = 1 - subfunction number Returned value: * function does not return value ----------------- Subfunction 2 - end window redraw. ----------------- Parameters: * eax = 12 - function number * ebx = 2 - subfunction number Returned value: * function does not return value Remarks: * Subfunction 1 deletes all buttons defined with function 8, they must be defined again. ---------------------- Constants for registers: ---------------------- eax - SF_REDRAW (12) ebx - SSF_BEGIN_DRAW (1), SSF_END_DRAW (2) ====================================================================== ============ Function 13 - draw a rectangle in the window. =========== ====================================================================== Parameters: * eax = 13 - function number * ebx = [coordinate on axis x]*65536 + [size on axis x] * ecx = [coordinate on axis y]*65536 + [size on axis y] * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill Returned value: * function does not return value Remarks: * Coordinates are understood as coordinates of the left upper corner of a rectangle relative to the window. ---------------------- Constants for registers: ---------------------- eax - SF_DRAW_RECT (13) ====================================================================== =================== Function 14 - get screen size. =================== ====================================================================== Parameters: * eax = 14 - function number Returned value: * eax = [xsize]*65536 + [ysize], where * xsize = x-coordinate of the right lower corner of the screen = horizontal size - 1 * ysize = y-coordinate of the right lower corner of the screen = vertical size - 1 Remarks: * See also subfunction 5 of function 48 - get sizes of working area of the screen. ---------------------- Constants for registers: ---------------------- eax - SF_GET_SCREEN_SIZE (14) ====================================================================== == Function 15, subfunction 1 - set a size of the background image. == ====================================================================== Parameters: * eax = 15 - function number * ebx = 1 - subfunction number * ecx = width of the image * edx = height of the image Returned value: * function does not return value Remarks: * Before calling subfunctions 2 and 5 you should call this function to set image size! * For update of the screen (after completion of a series of commands working with a background) call subfunction 3. * There is a pair function for get size of the background image - subfunction 1 of function 39. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_SIZE_BG (1) ====================================================================== === Function 15, subfunction 2 - put pixel on the background image. == ====================================================================== Parameters: * eax = 15 - function number * ebx = 2 - subfunction number * ecx = offset * edx = color of a pixel 0xRRGGBB Returned value: * function does not return value Remarks: * Offset for a pixel with coordinates (x,y) is calculated as (x+y*xsize)*3. * If the given offset exceeds size set by subfunction 1, the call is ignored. * For update of the screen (after completion of a series of commands working with a background) call subfunction 3. * There is a pair function for get pixel on the background image - subfunction 2 of function 39. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_PIXEL_BG (2) ====================================================================== =========== Function 15, subfunction 3 - redraw background. ========== ====================================================================== Parameters: * eax = 15 - function number * ebx = 3 - subfunction number Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_REDRAW_BG (3) ====================================================================== == Function 15, subfunction 4 - set drawing mode for the background. = ====================================================================== Parameters: * eax = 15 - function number * ebx = 4 - subfunction number * ecx = drawing mode: * 1 = tile * 2 = stretch Returned value: * function does not return value Remarks: * For update of the screen (after completion of a series of commands working with a background) call subfunction 3. * There is a pair function for get drawing mode of the background - subfunction 4 of function 39. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_MODE_BG (4) ====================================================================== ===================== Function 15, subfunction 5 ===================== ============ Put block of pixels on the background image. ============ ====================================================================== Parameters: * eax = 15 - function number * ebx = 5 - subfunction number * ecx = pointer to the data in the format BBGGRRBBGGRR... * edx = offset in data of the background image * esi = size of data in bytes = 3 * number of pixels Returned value: * function does not return value Remarks: * Offset and size are not checked for correctness. * Color of each pixel is stored as 3-bytes value BBGGRR. * Pixels of the background image are written sequentially from left to right, from up to down. * Offset of pixel with coordinates (x,y) is (x+y*xsize)*3. * For update of the screen (after completion of a series of commands working with a background) call subfunction 3. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_IMAGE_BG (5) ====================================================================== ===================== Function 15, subfunction 6 ===================== ======== Map background data to the address space of process. ======== ====================================================================== Parameters: * eax = 15 - function number * ebx = 6 - subfunction number Returned value: * eax = pointer to background data, 0 if error Remarks: * Mapped data are available for read and write. * Size of background data is 3*xsize*ysize. The system blocks changes of background sizes while process works with mapped data. * Color of each pixel is stored as 3-bytes value BBGGRR. * Pixels of the background image are written sequentially from left to right, from up to down. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_MAP_BG (6) ====================================================================== ===== Function 15, subfunction 7 - close mapped background data. ===== ====================================================================== Parameters: * eax = 15 - function number * ebx = 7 - subfunction number * ecx = pointer to mapped data Returned value: * eax = 1 - success, 0 - error ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_UNMAP_BG (7) ====================================================================== ===================== Function 15, subfunction 8 ===================== ============= Get coordinates of last draw the background ============ ====================================================================== Parameters: * eax = 15 - function number * ebx = 8 - subfunction number Returned value: * eax = [left]*65536 + [right] * ebx = [top]*65536 + [bottom] Remarks: * (left,top) are coordinates of the left upper corner, (right,bottom) are coordinates of the right lower one. * For receiving more reliable information, call the function immediately after the event: 5 = kernel finished redrawing of the desktop background ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_LAST_DRAW (8) ====================================================================== ===================== Function 15, subfunction 9 ===================== ============= Redraws a rectangular part of the background =========== ====================================================================== Parameters: * eax = 15 - function number * ebx = 9 - subfunction number * ecx = [left]*65536 + [right] * edx = [top]*65536 + [bottom] Returned value: * function does not return value Remarks: * (left,top) are coordinates of the left upper corner, (right,bottom) are coordinates of the right lower one. * If parameters are set incorrectly then background is not redrawn. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_SET (15) ebx - SSF_REDRAW_RECT (9) ====================================================================== =============== Function 16 - save ramdisk on a floppy. ============== ====================================================================== Parameters: * eax = 16 - function number * ebx = 1 or ebx = 2 - on which floppy save Returned value: * eax = 0 - success * eax = 1 - error ---------------------- Constants for registers: ---------------------- eax - SF_RD_TO_FLOPPY (16) ====================================================================== ======= Function 17 - get the identifier of the pressed button. ====== ====================================================================== Takes away the code of the pressed button from the buffer. Parameters: * eax = 17 - function number Returned value: * if the buffer is empty, function returns eax=1 * if the buffer is not empty: * high 24 bits of eax contain button identifier (in particular, ah contains low byte of the identifier; if all buttons have the identifier less than 256, ah is enough to distinguish) * al = 0 - the button was pressed with left mouse button * al = bit corresponding to used mouse button otherwise Remarks: * "Buffer" keeps only one button, at pressing the new button the information about old is lost. * The call of this function by an application with inactive window will return answer "buffer is empty". * Returned value for al corresponds to the state of mouse buttons as in subfunction 2 of function 37 at the beginning of button press, excluding lower bit, which is cleared. ---------------------- Constants for registers: ---------------------- eax - SF_GET_BUTTON (17) ====================================================================== ===================== Function 18, subfunction 1 ===================== ============= Make deactive the window of the given thread. ========== ====================================================================== Parameters: * eax = 18 - function number * ebx = 1 - subfunction number * ecx = number of the thread slot Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_UNFOCUS_WINDOW (1) ====================================================================== = Function 18, subfunction 2 - terminate process/thread by the slot. = ====================================================================== Parameters: * eax = 18 - function number * ebx = 2 - subfunction number * ecx = number of the slot of process/thread Returned value: * function does not return value Remarks: * It is impossible to terminate system thread OS/IDLE (with number of the slot 1), it is possible to terminate any normal process/thread. * See also subfunction 18 - terminate process/thread by the identifier. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_TERMINATE_THREAD (2) ====================================================================== ===================== Function 18, subfunction 3 ===================== ============= Make active the window of the given thread. ============ ====================================================================== Parameters: * eax = 18 - function number * ebx = 3 - subfunction number * ecx = number of the thread slot Returned value: * function does not return value Remarks: * If correct, but nonexistent slot is given, some window is made active. * To find out, which window is active, use subfunction 7. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_FOCUS_WINDOW (3) ====================================================================== ===================== Function 18, subfunction 4 ===================== =========== Get counter of idle time units per one second. =========== ====================================================================== Idle time units are units, in which the processor stands idle in waiting for interrupt (in the command 'hlt'). Parameters: * eax = 18 - function number * ebx = 4 - subfunction number Returned value: * eax = value of the counter of idle time units per one second ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_IDLE_COUNT (4) ====================================================================== ========== Function 18, subfunction 5 - get CPU clock rate. ========== ====================================================================== Parameters: * eax = 18 - function number * ebx = 5 - subfunction number Returned value: * eax = clock rate (modulo 2^32 clock ticks = 4GHz) ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_CPU_FREQUENCY (5) ====================================================================== Function 18, subfunction 6 - save ramdisk to the file on hard drive. ====================================================================== Parameters: * eax = 18 - function number * ebx = 6 - subfunction number * ecx = pointer to the full path to file (for example, "/hd0/1/kolibri/kolibri.img") Returned value: * eax = 0 - success * else eax = error code of the file system Remarks: * All folders in the given path must exist, otherwise function returns value 5, "file not found". ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_RD_TO_HDD (6) ====================================================================== =========== Function 18, subfunction 7 - get active window. ========== ====================================================================== Parameters: * eax = 18 - function number * ebx = 7 - subfunction number Returned value: * eax = number of the active window (number of the slot of the thread with active window) Remarks: * Active window is at the top of the window stack and receives messages on all keyboard input. * To make a window active, use subfunction 3. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_ACTIVE_WINDOW (7) ====================================================================== == Function 18, subfunction 8 - disable/enable the internal speaker. = ====================================================================== If speaker sound is disabled, all calls to subfunction 55 of function 55 are ignored. If speaker sound is enabled, they are routed on builtin speaker. ------------------- Subsubfunction 1 - get status. ------------------- Parameters: * eax = 18 - function number * ebx = 8 - subfunction number * ecx = 1 - number of the subsubfunction Returned value: * eax = 0 - speaker sound is enabled; 1 - disabled ----------------- Subsubfunction 2 - toggle status. ------------------ Toggles states of disable/enable. Parameters: * eax = 18 - function number * ebx = 8 - subfunction number * ecx = 2 - number of the subsubfunction Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_SPEAKER (8) ecx - SSSF_GET_STATE (1), SSSF_TOGGLE (2) ====================================================================== == Function 18, subfunction 9 - system shutdown with the parameter. == ====================================================================== Parameters: * eax = 18 - function number * ebx = 9 - subfunction number * ecx = parameter: * 2 = turn off computer * 3 = reboot computer * 4 = restart the kernel from the file 'kernel.mnt' on ramdisk Returned value: * at incorrect ecx the registers do not change (i.e. eax=18) * by correct call function always returns eax=0 as the tag of success Remarks: * Do not rely on returned value by incorrect call, it can be changed in future versions of the kernel. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_SHUTDOWN (9) ====================================================================== ======= Function 18, subfunction 10 - minimize topmost window. ======= ====================================================================== Minimizes the topmost (active) window. Parameters: * eax = 18 - function number * ebx = 10 - subfunction number Returned value: * function does not return value Remarks: * The minimized window from the point of view of function 9 keeps position and sizes. * Restoring of an application window occurs at its activation by subfunction 3. * Usually there is no necessity to minimize/restore a window explicitly: minimization of a window is carried out by the system at pressing the minimization button (for skinned windows it is defined automatically by function 0, for other windows it can be defined manually by function 8), restore of a window is done by the application '@taskbar'. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_MINIMIZE_WINDOW (10) ====================================================================== Function 18, subfunction 11 - get information on the disk subsystem. ====================================================================== Parameters: * eax = 18 - function number * ebx = 11 - subfunction number * ecx = type of the table: * 1 = short version, 16 bytes * edx = pointer to the buffer (in the application) for the table Returned value: * function does not return value Format of the table: short version: * +0: byte: information about FDD's (drives for floppies), AAAABBBB, where AAAA gives type of the first drive, BBBB - of the second regarding to the following list: * 0 = there is no drive * 1 = 360Kb, 5.25'' * 2 = 1.2Mb, 5.25'' * 3 = 720Kb, 3.5'' * 4 = 1.44Mb, 3.5'' * 5 = 2.88Mb, 3.5'' (such drives are not used anymore) For example, for the standard configuration from one 1.44-drive here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B: the value is 24h. First IDE controller: * +1: byte: information about hard disks and CD-drives, AABBCCDD, where AA corresponds to the controller IDE0, ..., DD - IDE3: * 0 = device not found * 1 = hard drive * 2 = CD-drive For example, in the case HD on IDE0 and CD on IDE2 this field contains 48h. * +2: 4 db: number of the retrieved partitions on hard disks at accordingly IDE0,...,IDE3. Second IDE controller: * +6: byte: information about hard disks and CD-drives, AABBCCDD, where AA corresponds to the controller IDE4, ..., DD - IDE7: * 0 = device not found * 1 = hard drive * 2 = CD-drive For example, in the case HD on IDE4 and CD on IDE6 this field contains 48h. * +7: 4 db: number of the retrieved partitions on hard disks at accordingly IDE4,...,IDE7. Third IDE controller: * +11: byte: information about hard disks and CD-drives, AABBCCDD, where AA corresponds to the controller IDE8, ..., DD - IDE11: * 0 = device not found * 1 = hard drive * 2 = CD-drive For example, in the case HD on IDE8 and CD on IDE10 this field contains 48h. * +12: 4 db: number of the retrieved partitions on hard disks at accordingly IDE8,...,IDE11. If the hard disk on IDEx is absent, appropriate byte is zero, otherwise it shows number of the recognized partitions, which can be not presented (if the drive is not formatted or if the file system is not supported). Current version of the kernel supports only FAT12/16/32, NTFS, ext2/3/4 and XFS for hard disks. Remarks: * The table can be used for obtaining the information about available devices. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_INFO_DISC_SYS (11) ====================================================================== ========== Function 18, subfunction 13 - get kernel version. ========= ====================================================================== Parameters: * eax = 18 - function number * ebx = 13 - subfunction number * ecx = pointer to the buffer (not less than 16 bytes), where the information will be placed Returned value: * function does not return value Structure of the buffer: db a,b,c,d for version a.b.c.d db 0: reserved dd REV - kernel SVN revision number For Kolibri 0.7.7.0+ kernel: db 0,7,7,0 db 0 dd 1675 ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_KERNEL_VERSION (13) ====================================================================== ======= Function 18, subfunction 14 - wait for screen retrace. ======= ====================================================================== Waits for the beginning of retrace of the scanning ray of the screen monitor. Parameters: * eax = 18 - function number * ebx = 14 - subfunction number Returned value: * eax = 0 as the tag of success Remarks: * Function is intended only for active high-efficiency graphics applications; is used for smooth output of a graphics. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_WAIT_RETRACE (14) ====================================================================== == Function 18, subfunction 15 - center mouse cursor on the screen. == ====================================================================== Parameters: * eax = 18 - function number * ebx = 15 - subfunction number Returned value: * eax = 0 as the tag of success ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_CURSOR_CENTER (15) ====================================================================== ========= Function 18, subfunction 16 - get size of free RAM. ======== ====================================================================== Parameters: * eax = 18 - function number * ebx = 16 - subfunction number Returned value: * eax = size of free memory in kilobytes ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_FREE_RAM (16) ====================================================================== ======== Function 18, subfunction 17 - get full amount of RAM. ======= ====================================================================== Parameters: * eax = 18 - function number * ebx = 17 - subfunction number Returned value: * eax = total size of existing memory in kilobytes ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_TOTAL_RAM (17) ====================================================================== ===================== Function 18, subfunction 18 ==================== ============= Terminate process/thread by the identifier. ============ ====================================================================== Parameters: * eax = 18 - function number * ebx = 18 - subfunction number * ecx = identifier of process/thread (PID/TID) Returned value: * eax = 0 - success * eax = -1 - error (process is not found or is system) Remarks: * It is impossible to terminate system thread OS/IDLE (identifier 1), it is possible to terminate any normal process/thread. * See also subfunction 2 - terminate process/thread by given slot. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_TERMINATE_THREAD_ID (18) ====================================================================== ======== Function 18, subfunction 19 - get/set mouse features. ======= ====================================================================== ---------------- Subsubfunction 0 - get mouse speed. ----------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 0 - subsubfunction number Returned value: * eax = current speed divider ---------------- Subsubfunction 1 - set mouse speed. ----------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 1 - subsubfunction number * edx = new value for speed divider Returned value: * function does not return value Remark: recommended speed divider = 4 -------------- Subsubfunction 2 - get mouse sensitivity -------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 2 - subsubfunction number Returned value: * eax = current sensitivity -------------- Subsubfunction 3 - set mouse sensitivity -------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 3 - subsubfunction number * edx = new value for sensitivity Returned value: * function does not return value Remark: recommended sensitivity = 3 ----------- Subsubfunction 4 - set mouse pointer position. ----------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 4 - subsubfunction number * edx = [coordinate on axis x]*65536 + [coordinate on axis y] Returned value: * function does not return value -------- Subsubfunction 5 - simulate state of mouse buttons. --------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 5 - subsubfunction number * edx = information about emulated state of mouse buttons: (same as return value in subfunction 2 of function 37) * bit 0 is set = left button is pressed * bit 1 is set = right button is pressed * bit 2 is set = middle button is pressed * bit 3 is set = 4th button is pressed * bit 4 is set = 5th button is pressed Returned value: * function does not return value -------------- Subsubfunction 6 - get doubleclick delay. ------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 6 - subsubfunction number Returned value: * eax = current doubleclick delay (100 = 1 second) -------------- Subsubfunction 7 - set doubleclick delay. ------------- Parameters: * eax = 18 - function number * ebx = 19 - subfunction number * ecx = 7 - subsubfunction number * dl = new value for doubleclick delay (100 = 1 second) Returned value: * function does not return value Remark: mouse settings can be modified in the application mouse_cfg. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_MOUSE_SETTINGS (19) ecx - SSSF_GET_SPEED (0), SSSF_SET_SPEED (1), SSSF_GET_SPEEDUP (2), SSSF_SET_SPEEDUP (3), SSSF_SET_POS (4), SSSF_SET_BUTTON (5), SSSF_GET_DOUBLE_CLICK_DELAY (6), SSSF_SET_DOUBLE_CLICK_DELAY (7) ====================================================================== ======== Function 18, subfunction 20 - get information on RAM. ======= ====================================================================== Parameters: * eax = 18 - function number * ebx = 20 - subfunction number * ecx = pointer to the buffer for information (36 bytes) Returned value: * eax = total size of existing RAM in pages or -1 if error has occurred * buffer pointed to by ecx contains the following information: * +0: dword: total size of existing RAM in pages * +4: dword: size of free RAM in pages * +8: dword: number of page faults (exceptions #PF) in applications * +12: dword: size of kernel heap in bytes * +16: dword: free in kernel heap in bytes * +20: dword: total number of memory blocks in kernel heap * +24: dword: number of free memory blocks in kernel heap * +28: dword: size of maximum free block in kernel heap (reserved) * +32: dword: size of maximum allocated block in kernel heap (reserved) ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_RAM_INFO (20) ====================================================================== ===================== Function 18, subfunction 21 ==================== ======== Get slot number of process/thread by the identifier. ======== ====================================================================== Parameters: * eax = 18 - function number * ebx = 21 - subfunction number * ecx = identifier of process/thread (PID/TID) Returned value: * eax = 0 - error (invalid identifier) * otherwise eax = slot number ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_GET_THREAD_SLOT (21) ====================================================================== ===================== Function 18, subfunction 22 ==================== ============== Operations with window of another thread. ============= ====================================================================== Parameters: * eax = 18 - function number * ebx = 22 - subfunction number * ecx = operation type: * 0 = minimize window of the thread with given slot number * 1 = minimize window of the thread with given identifier * 2 = restore window of the thread with given slot number * 3 = restore window of the thread with given identifier * edx = parameter (slot number or PID/TID) Returned value: * eax = 0 - success * eax = -1 - error (invalid identifier) Remarks: * The thread can minimize its window with subfunction 10. * One can restore and activate window simultaneously with subfunction 3 (which requires slot number). ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_FOREIGN_WINDOW (22) ecx - SSSF_MINIMIZE (0), SSSF_MINIMIZE_ID (1), SSSF_RESTORE (2), SSSF_RESTORE_ID (3) ====================================================================== ======== Function 18, subfunction 23 - minimize all windows. ========== ====================================================================== Parameters: * eax = 18 - function number * ebx = 23 - subfunction number Returned value: * eax = 0 - all windows have been minimized before a function call * eax = N - number of windows minimized from function Remarks: * Window of special thread (name begin to symbol @) is not minimize. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_MINIMIZE_ALL (23) ====================================================================== ======= Function 18, subfunction 24 - set limits of screen. ========== ====================================================================== Parameters: * eax = 18 - function number * ebx = 24 - subfunction number * ecx = new X size * edx = new Y size Returned value: * function does not return value Remarks: * The function does not change the physical size of the video mode. It is designed for non-standard displays which display the image partially. * The sizes specified in the function should not exceed the sizes of the current video mode, otherwise the function will not change anything. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_SET_SCREEN_LIMITS (24) ====================================================================== ===================== Function 18, subfunction 25 ==================== ===== Control position of the window relative to other windows. ====== ====================================================================== ------------- Subsubfunction 1 - get position ----------------------- Parameters: * eax = 18 - function number * ebx = 25 - subfunction number * ecx = 1 - subsubfunction number * edx = -1(for current window) or PID application Returned value: * eax = one of the constants window position ------------- Subsubfunction 2 - set position ----------------------- Parameters: * eax = 18 - function number * ebx = 25 - subfunction number * ecx = 2 - subsubfunction number * edx = -1(for current window) or PID application * esi = new window position (one of the constants below) Returned value: * eax = 0 - error * eax = 1 - success Constant position of the window relative to other windows: ZPOS_DESKTOP = -2 - on the background ZPOS_ALWAYS_BACK = -1 - behind all the windows ZPOS_NORMAL = 0 - normal ZPOS_ALWAYS_TOP = 1 - on top of all windows ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM (18) ebx - SSF_WINDOW_BEHAVIOR (25) ecx - SSSF_GET_WB (1), SSSF_SET_WB (2) ====================================================================== ==================== Function 20 - MIDI interface. =================== ====================================================================== ----------------------- Subfunction 1 - reset ------------------------ Parameters: * eax = 20 - function number * ebx = 1 - subfunction number -------------------- Subfunction 2 - output byte --------------------- Parameters: * eax = 20 - function number * ebx = 2 - subfunction number * cl = byte for output Returned value (is the same for both subfunctions): * eax = 0 - success * eax = 1 - base port is not defined Remarks: * Previously the base port must be defined by subfunction 1 of function 21. ---------------------- Constants for registers: ---------------------- eax - SF_MIDI (20) ebx - SSF_RESET (1), SSF_OUTPUT (2) ====================================================================== ======== Function 21, subfunction 1 - set MPU MIDI base port. ======== ====================================================================== Parameters: * eax = 21 - function number * ebx = 1 - subfunction number * ecx = number of base port Returned value * eax = 0 - success * eax = -1 - erratic number of a port Remarks: * Number of a port must satisfy to conditions 0x100<=ecx<=0xFFFF. * The installation of base is necessary for function 20. * To get base port use subfunction 1 of function 26. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_SET (21) ebx - SSF_MPU_MIDI_BASE (1) ====================================================================== ========== Function 21, subfunction 2 - set keyboard layout. ========= ====================================================================== Keyboard layout is used to convert keyboard scancodes to ASCII-codes, which will be read by function 2. Parameters: * eax = 21 - function number * ebx = 2 - subfunction number * ecx = which layout to set: * 1 = normal layout * 2 = layout at pressed Shift * 3 = layout at pressed Alt * edx = pointer to layout - table of length 128 bytes Or: * ecx = 9 * dx = country identifier (1=eng, 2=fi, 3=ger, 4=rus) Returned value: * eax = 0 - success * eax = 1 - incorrect parameter Remarks: * If Alt is pressed, the layout with Alt is used; if Alt is not pressed, but Shift is pressed, the layout with Shift is used; if Alt and Shift are not pressed, but Ctrl is pressed, the normal layout is used and then from the code is subtracted 0x60; if no control key is pressed, the normal layout is used. * To get layout and country identifier use subfunction 2 of function 26. * Country identifier is global system variable, which is not used by the kernel itself; however the application '@taskbar' displays the corresponding icon. * The application @taskbar switches layouts on user request. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_SET (21) ebx - SSF_KEYBOARD_LAYOUT (2) ====================================================================== ========== Function 21, subfunction 5 - set system language. ========= ====================================================================== Parameters: * eax = 21 - function number * ebx = 5 - subfunction number * ecx = system language (1=eng, 2=fi, 3=ger, 4=rus) Returned value: * eax = 0 Remarks: * System language is global system variable and is not used by the kernel itself, however application @taskbar draws the appropriate icon. * Function does not check for correctness, as the kernel does not use this variable. * To get system language use subfunction 5 of function 26. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_SET (21) ebx - SSF_SYS_LANG (5) ====================================================================== Function 21, subfunction 11 - enable/disable low-level access to HD. ====================================================================== Parameters: * eax = 21 - function number * ebx = 11 - subfunction number * ecx = 0/1 - disable/enable Returned value: * eax = 0 Remarks: * Is used in LBA-read (subfunction 8 of function 58). * The current implementation uses only low bit of ecx. * To get current status use subfunction 11 of function 26. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_SET (21) ebx - SSF_ACCESS_HD_LBA (11) ====================================================================== Function 21, subfunction 12 - enable/disable low-level access to PCI. ====================================================================== Parameters: * eax = 21 - function number * ebx = 12 - subfunction number * ecx = 0/1 - disable/enable Returned value: * eax = 0 Remarks: * Is used in operations with PCI bus (function 62). * The current implementation uses only low bit of ecx. * To get current status use subfunction 12 of function 26. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_SET (21) ebx - SSF_ACCESS_PCI (12) ====================================================================== ================= Function 22 - set system date/time. ================ ====================================================================== Parameters: * eax = 22 - function number * ebx = 0 - set time * ecx = 0x00SSMMHH - time in the binary-decimal code (BCD): * HH=hour 00..23 * MM=minute 00..59 * SS=second 00..59 * ebx = 1 - set date * ecx = 0x00DDMMYY - date in the binary-decimal code (BCD): * DD=day 01..31 * MM=month 01..12 * YY=year 00..99 * ebx = 2 - set day of week * ecx = 1 for Sunday, ..., 7 for Saturday * ebx = 3 - set alarm clock * ecx = 0x00SSMMHH Returned value: * eax = 0 - success * eax = 1 - incorrect parameter * eax = 2 - CMOS-battery was unloaded Remarks: * Value of installation of day of week seems to be doubtful, as it a little where is used (day of week can be calculated by date). * Alarm clock can be set on operation in the given time every day. But there is no existing system function to disable it. * Operation of alarm clock consists in generation IRQ8. * Generally CMOS supports for alarm clock set of value 0xFF as one of parameters and it means that the appropriate parameter is ignored. But current implementation does not allow this (will return 1). * Alarm clock is a global system resource; the set of an alarm clock cancels automatically the previous set. However, at moment no program uses it. ---------------------- Constants for registers: ---------------------- eax - SF_SET_TIME_DATE (22) ====================================================================== ============= Function 23 - wait for event with timeout. ============= ====================================================================== If the message queue is empty, waits for new message in the queue, but no more than given time. Then reads out a message from the queue. Parameters: * eax = 23 - function number * ebx = timeout (in 1/100 of second) Returned value: * eax = 0 - the message queue is empty * otherwise eax = event (see the list of events) Remarks: * Only those events are taken into account, which enter into the mask set by function 40. By default it is redraw, key and button events. * To check for presence of a message in the queue use function 11. To wait without timeout use function 10. * Transmission ebx=0 results in immediate returning eax=0. * Current implementation returns immediately with eax=0, if the addition of ebx with the current value of time counter makes 32-bit overflow. ---------------------- Constants for registers: ---------------------- eax - SF_WAIT_EVENT_TIMEOUT (23) ====================================================================== ======= Function 24, subfunction 4 - eject tray of disk drive. ======= ====================================================================== Parameters: * eax = 24 - function number * ebx = 4 - subfunction number * ecx = position of CD/DVD-drive from 0=Primary Master to 3=Secondary Slave for first IDE contr. from 4=Primary Master to 7=Secondary Slave for second IDE contr. from 8=Primary Master to 11=Secondary Slave for third IDE contr. Returned value: * function does not return value Remarks: * The function is supported only for ATAPI devices (CD and DVD). * When the tray is being ejected, manual control of tray is unlocked. * When the tray is being ejected, the code clears the cache for corresponding device. * An example of usage of the function is the application CD_tray. ---------------------- Constants for registers: ---------------------- eax - SF_CD (24) ebx - SSF_EJECT_TRAY (4), SSF_INSERT_TRAY (5) ====================================================================== ======== Function 24, subfunction 5 - load tray of disk drive. ======= ====================================================================== Parameters: * eax = 24 - function number * ebx = 5 - subfunction number * ecx = position of CD/DVD-drive from 0=Primary Master to 3=Secondary Slave for first IDE contr. from 4=Primary Master to 7=Secondary Slave for second IDE contr. from 8=Primary Master to 11=Secondary Slave for third IDE contr. Returned value: * function does not return value Remarks: * The function is supported only for ATAPI devices (CD and DVD). * An example of usage of the function is the application CD_tray. ---------------------- Constants for registers: ---------------------- eax - SF_CD (24) ebx - SSF_EJECT_TRAY (4), SSF_INSERT_TRAY (5) ====================================================================== ======= Function 25 - put image area on the background layer. ======== ====================================================================== Parameters: * eax = 25 - function number * ebx = pointer to the previously allocated memory area, where placed the source images in a format BBGGRRTTBBGGRRTT... * ecx = [size on axis x]*65536 + [size on axis y] * edx = [coordinate on axis x]*65536 + [coordinate on axis y] Returned value: * function does not return value Remarks: * Coordinates of the image are coordinates of the upper left corner of the image relative to the screen. * Size of the image in bytes is 4*xsize*ysize * TT - byte pointer of transparency, at current version: 1 to FF - opaque, 0 - transparent. * The function places the image directly to LFB. It is not for background image f.15. Options f.15 to f.25 does not make sense. ---------------------- Constants for registers: ---------------------- eax - SF_SCREEN_PUT_IMAGE (25) ====================================================================== ======== Function 26, subfunction 1 - get MPU MIDI base port. ======== ====================================================================== Parameters: * eax = 26 - function number * ebx = 1 - subfunction number Returned value: * eax = port number Parameters: * To set base port use subfunction 1 of function 21. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_MPU_MIDI_BASE (1) ====================================================================== ========== Function 26, subfunction 2 - get keyboard layout. ========= ====================================================================== The keyboard layout is used to convert keyboard scancodes to ASCII-codes for function 2. Parameters: * eax = 26 - function number * ebx = 2 - subfunction number * ecx = what layout to get: * 1 = normal layout * 2 = layout with pressed Shift * 3 = layout with pressed Alt * edx = pointer to the 128-bytes buffer, where the layout will be copied Returned value: * function does not return value but if pointer in edx is illegal, for example, [edx, edx + 128) region intersects with kernel memory, then function returns -1 Or: * eax = 26 - function number * ebx = 2 - subfunction number * ecx = 9 Returned value: * eax = country identifier (1=eng, 2=fi, 3=ger, 4=rus) Remarks: * If Alt is pressed, the layout with Alt is used; if Alt is not pressed, but Shift is pressed, the layout with Shift is used; if Alt and Shift are not pressed, but Ctrl is pressed, the normal layout is used and then from the code is subtracted 0x60; if no control key is pressed, the normal layout is used. * To set layout and country identifier use subfunction 2 of function 21. * Country identifier is global system variable, which is not used by the kernel itself; however the application '@taskbar' displays the corresponding icon (using this function). * The application @taskbar switches layouts on user request. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_KEYBOARD_LAYOUT (2) ====================================================================== ========== Function 26, subfunction 5 - get system language. ========= ====================================================================== Parameters: * eax = 26 - function number * ebx = 5 - subfunction number Returned value: * eax = system language (1=eng, 2=fi, 3=ger, 4=rus) Remarks: * System language is global system variable and is not used by the kernel itself, however application @taskbar draws the appropriate icon (using this function). * To set system language use subfunction 5 of function 21. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_SYS_LANG (5) ====================================================================== === Function 26, subfunction 9 - get the value of the time counter. == ====================================================================== Parameters: * eax = 26 - function number * ebx = 9 - subfunction number Returned value: * eax = number of 1/100s of second, past from the system boot time Remarks: * Counter takes modulo 2^32, that correspond to a little more than 497 days. * To get system time use function 3. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_TIME_COUNT (9) ====================================================================== ===================== Function 26, subfunction 10 ==================== ========== Get the value of the high precision time counter. ========= ====================================================================== Parameters: * eax = 26 - function number * ebx = 10 - subfunction number Returned value: * eax = number of nanoseconds since system boot time (lower DWORD) * edx = number of nanoseconds since system boot time (high DWORD) Remarks: * The counter is based on HPET, if HPET is not available, resolution will be reduced to 10 000 000 nanoseconds. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_TIME_COUNT_PRO (10) ====================================================================== ===================== Function 26, subfunction 11 ==================== ========== Find out whether low-level HD access is enabled. ========== ====================================================================== Parameters: * eax = 26 - function number * ebx = 11 - subfunction number Returned value: * eax = 0/1 - disabled/enabled Remarks: * Is used in LBA read (subfunction 8 of function 58). * To set current state use subfunction 11 of function 21. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_ACCESS_HD_LBA (11) ====================================================================== ===================== Function 26, subfunction 12 ==================== ========== Find out whether low-level PCI access is enabled. ========= ====================================================================== Parameters: * eax = 26 - function number * ebx = 12 - subfunction number Returned value: * eax = 0/1 - disabled/enabled Remarks: * Is used by operations with PCI bus (function 62). * The current implementation uses only low bit of ecx. * To set the current state use subfunction 12 of function 21. ---------------------- Constants for registers: ---------------------- eax - SF_SYSTEM_GET (26) ebx - SSF_ACCESS_PCI (12) ====================================================================== =================== Function 29 - get system date. =================== ====================================================================== Parameters: * eax = 29 - function number Returned value: * eax = 0x00DDMMYY, where (binary-decimal coding, BCD, is used) * YY = two low digits of year (00..99) * MM = month (01..12) * DD = day (01..31) Remarks: * To set system date use function 22. ---------------------- Constants for registers: ---------------------- eax - SF_GET_SYS_DATE (29) ====================================================================== ============= Function 30 - work with the current folder. ============ ====================================================================== --------- Subfunction 1 - set current folder for the thread. --------- Parameters: * eax = 30 - function number * ebx = 1 - subfunction number * ecx = pointer to string with the path to new current folder, rules of path forming can be found in function 70 description. Returned value: * function does not return value ---------------------------------------------------------------------- --------- Subfunction 2 - get current folder for the thread. --------- Parameters: * eax = 30 - function number * ebx = 2 - subfunction number * ecx = pointer to buffer * edx = size of buffer Returned value: * eax = size of the string (including terminating 0) Remarks: * If the buffer is too small to hold all path, only part of the string will be copied and terminated with 0. * By default, current folder for the thread is "/sys". * At process/thread creation the current folder will be inherited from the parent. ---------------------------------------------------------------------- --- Subfunction 3 - install the add.system directory for the kernel -- Parameters: * eax = 30 - function number * ebx = 3 - subfunction number * ecx = pointer to a block of data: key rb 64 path rb 64 Example: align 64 key db 'kolibrios',0 ; key must be in lower case align 64 path db 'HD0/1',0 Returned value: * function does not return value Remarks: * The function can be called only 1 time for 1 session of the OS. * On input the symbolic key is not changing by encoding. ---------------------------------------------------------------------- ---- Subfunction 4 - set current folder, specifying the encoding. ---- Parameters: * eax = 30 - function number * ebx = 4 - subfunction number * ecx = pointer to string with the path to new current folder * edx = string encoding, details can be found in function 80 description. Returned value: * function does not return value ---------------------------------------------------------------------- ---- Subfunction 5 - get current folder, specifying the encoding. ---- Parameters: * eax = 30 - function number * ebx = 5 - subfunction number * ecx = pointer to buffer * edx = size of buffer * esi = string encoding Returned value: * eax = size of the string in bytes (including terminating 0) Remarks: * If the buffer is too small to hold all path, only part of the string will be copied and terminated with 0. * By default, current folder for the thread is "/sys". * At process/thread creation the current folder will be inherited from the parent. ---------------------- Constants for registers: ---------------------- eax - SF_CURRENT_FOLDER (30) ebx - SSF_SET_CF (1), SSF_GET_CF (2), SSF_ADD_SYS_FOLDER (3) ====================================================================== ========= Function 34 - who owner the pixel on the screen. =========== ====================================================================== Parameters: * eax = 34 - function number * ebx = x-coordinate (relative to the display) * ecx = y-coordinate (relative to the display) Returned value: * eax = 0x000000XX - owner of pixel the slot window N If incorrect values ebx and ecx then function returns 0 * The function takes the value from the area [_WinMapAddress] ---------------------- Constants for registers: ---------------------- eax - SF_GET_PIXEL_OWNER (34) ====================================================================== ======= Function 35 - read the color of a pixel on the screen. ======= ====================================================================== Parameters: * eax = 35 * ebx = y*xsize+x, where * (x,y) = coordinates of a pixel (beginning from 0) * xsize = horizontal screen size Returned value: * eax = color 0x00RRGGBB Remarks: * To get screen sizes use function 14. Pay attention, that it subtracts 1 from both sizes. * There is also direct access (without any system calls) to videomemory through the selector gs. To get parameters of the current videomode, use function 61. ---------------------- Constants for registers: ---------------------- eax - SF_GET_PIXEL (35) ====================================================================== =================== Function 36 - read screen area. ================== ====================================================================== Paramters: * eax = 36 - function number * ebx = pointer to the previously allocated memory area, where will be placed the image in the format BBGGRRBBGGRR... * ecx = [size on axis x]*65536 + [size on axis y] * edx = [coordinate on axis x]*65536 + [coordinate on axis y] Returned value: * function does not return value Remarks: * Coordinates of the image are coordinates of the upper left corner of the image relative to the screen. * Size of the image in bytes is 3*xsize*ysize. ---------------------- Constants for registers: ---------------------- eax - SF_GET_IMAGE (36) ====================================================================== =================== Function 37 - work with mouse. =================== ====================================================================== ---------- Subfunction 0 - screen coordinates of the mouse ----------- Parameters: * eax = 37 - function number * ebx = 0 - subfunction number Returned value: * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer (beginning from 0) -- Subfunction 1 - coordinates of the mouse relative to the window --- Parameters: * eax = 37 - function number * ebx = 1 - subfunction number Returned value: * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer relative to the application window (beginning from 0) Remarks: * The value is calculated by formula (x-xwnd)*65536 + (y-ywnd). If y>=ywnd, the low word is non-negative and contains relative y-coordinate, and the high word - relative x-coordinate (with correct sign). Otherwise the low word is negative and still contains relative y-coordinate, and to the high word 1 should be added. ------------- Subfunction 2 - states of the mouse buttons ------------ Parameters: * eax = 37 - function number * ebx = 2 - subfunction number Returned value: * eax = bits 0-4 equal to subfunction 3 ------- Subfunction 3 - states and events of the mouse buttons ------- Parameters: * eax = 37 - function number * ebx = 3 - subfunction number Returned value: * eax contains next information: states: * bit 0 is set = left button is held * bit 1 is set = right button is held * bit 2 is set = middle button is held * bit 3 is set = 4th button is held * bit 4 is set = 5th button is held events: * bit 8 is set = left button is pressed * bit 9 is set = right button is pressed * bit 10 is set = middle button is pressed * bit 15 is set = vertical scroll is used * bit 16 is set = left button is released * bit 17 is set = right button is released * bit 18 is set = middle button is released * bit 23 is set = horizontal scroll is used * bit 24 is set = doubleclick by left button -------------------- Subfunction 4 - load cursor --------------------- Parameters: * eax = 37 - function number * ebx = 4 - subfunction number * dx = data source: * dx = LOAD_FROM_FILE = 0 - data in a file * ecx = pointer to full path to the cursor file * the file must be in the format .cur, which is standard for MS Windows, at that of the size 32*32 pixels * dx = LOAD_FROM_MEM = 1 - data of file are already loaded in memory * ecx = pointer to data of the cursor file * the data format is the same as in the previous case * dx = LOAD_INDIRECT = 2 - data in memory * ecx = pointer to cursor image in the format ARGB 32*32 pixels * edx = 0xXXYY0002, where * XX = x-coordinate of cursor hotspot * YY = y-coordinate * 0 <= XX, YY <= 31 Returned value: * eax = 0 - failed * otherwise eax = cursor handle --------------------- Subfunction 5 - set cursor --------------------- Sets new cursor for the window of the current thread. Parameters: * eax = 37 - function number * ebx = 5 - subfunction number * ecx = cursor handle Returned value: * eax = handle of previous cursor Remarks: * If the handle is incorrect, the function restores the default cursor (standard arrow). In particular, ecx=0 restores it. ------------------- Subfunction 6 - delete cursor -------------------- Parameters: * eax = 37 - function number * ebx = 6 - subfunction number * ecx = cursor handle Returned value: * eax destroyed Remarks: * The cursor must be loaded previously by the current thread (with the call to subfunction 4). The function does not delete system cursors and cursors, loaded by another applications. * If the active cursor (set by subfunction 5) is deleted, the system restores the default cursor (standard arrow). ------------------ Subfunction 7 - get scroll data ------------------- Parameters: * eax = 37 - function number * ebx = 7 - subfunction number Returned value: * eax = [horizontal offset]*65536 + [vertical offset] Remarks: * Scroll data is available for active window only. * Values are zeroed after reading. * Values are signed. -------- Subfunction 8 - load cursor, specifying the encoding -------- Parameters: * eax = 37 - function number * ebx = 8 - subfunction number * ecx = pointer to the cursor file path string * edx = string encoding, details can be found in function 80 description. Returned value: * eax = cursor handle, 0 - failed ---------------------- Constants for registers: ---------------------- eax - SF_MOUSE_GET (37) ebx - SSF_SCREEN_POSITION (0), SSF_WINDOW_POSITION (1), SSF_BUTTON (2), SSF_BUTTON_EXT (3), SSF_LOAD_CURSOR (4), SSF_SET_CURSOR (5), SSF_DEL_CURSOR (6), SSF_SCROLL_DATA (7) ====================================================================== ====================== Function 38 - draw line. ====================== ====================================================================== Parameters: * eax = 38 - function number * ebx = [start coordinate on axis x]*65536 + [end coordinate on axis x] * ecx = [start coordinate on axis y]*65536 + [end coordinate on axis y] * edx = 0x00RRGGBB - color edx = 0x01xxxxxx - draw inversed line (low 24 bits are ignored) Returned value: * function does not return value Remarks: * Coordinates are relative to the window. * End point is also drawn. ---------------------- Constants for registers: ---------------------- eax - SF_DRAW_LINE (38) ====================================================================== == Function 39, subfunction 1 - get a size of the background image. == ====================================================================== Parameters: * eax = 39 - function number * ebx = 1 - subfunction number Returned value: * eax = [width]*65536 + [height] Remarks: * There is a pair function to set sizes of background image - subfunction 1 of function 15. After which it is necessary, of course, anew to define image. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_GET (39) ====================================================================== == Function 39, subfunction 2 - get pixel from the background image. = ====================================================================== Parameters: * eax = 39 - function number * ebx = 2 - subfunction number * ecx = offset Returned value: * eax = 0x00RRGGBB - pixel color, if offset is valid (less than 0x160000-16) * eax = 2 otherwise Remarks: * Do not rely on returned value for invalid offsets, it may be changed in future kernel versions. * Offset for pixel with coordinates (x,y) is calculated as (x+y*xsize)*3. * There is a pair function to set pixel on the background image - subfunction 2 of function 15. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_GET (39) ====================================================================== == Function 39, subfunction 4 - get drawing mode for the background. = ====================================================================== Parameters: * eax = 39 - function number * ebx = 4 - subfunction number Returned value: * eax = 1 - tile * eax = 2 - stretch Remarks: * There is a pair function to set drawing mode - subfunction 4 of function 15. ---------------------- Constants for registers: ---------------------- eax - SF_BACKGROUND_GET (39) ====================================================================== =========== Function 40 - set the mask for expected events. ========== ====================================================================== The mask for expected events affects function working with events 10, 11, 23 - they notify only about events allowed by this mask. Parameters: * eax = 40 - function number * ebx = mask: bit i corresponds to event i+1 (see list of events) (set bit permits notice on event) bit 31: mouse active/inactive filter bit 31 = 0 - inactive window receive mouse events bit 31 = 1 - inactive window does not receive mouse events bit 30: cursor position filter bit 30 = 0 = the window receive mouse events if cursor outside window bit 30 = 1 - the window does not receive mouse events if cursor outside window Returned value: * eax = previous value of mask Remarks: * Default mask (7=111b) enables notices about redraw, keys and buttons. This is enough for many applications. * Events prohibited in the mask are saved anyway, when come; they are simply not informed with event functions. * Event functions take into account the mask on moment of function call, not on moment of event arrival. ---------------------- Constants for registers: ---------------------- eax - SF_SET_EVENTS_MASK (40) ====================================================================== ================ Function 43 - input/output to a port. =============== ====================================================================== ------------------------ Output data to port ------------------------- Parameters: * eax = 43 - function number * bl = byte for output * ecx = port number 0xnnnn (from 0 to 0xFFFF) Returned value: * eax = 0 - success * eax = 1 - the thread has not reserved the selected port ------------------------ Input data from port ------------------------ Parameters: * eax = 43 - function number * ebx is ignored * ecx = 0x8000nnnn, where nnnn = port number (from 0 to 0xFFFF) Returned value: * eax = 0 - success, thus ebx = entered byte * eax = 1 - the thread has not reserved the selected port Remarks: * Previously the thread must reserve the selected port for itself by function 46. * Instead of call to this function it is better to use processor instructions in/out - this is much faster and a bit shorter and easier. ---------------------- Constants for registers: ---------------------- eax - SF_PORT_IN_OUT (43) ====================================================================== ====== Function 46 - reserve/free a group of input/output ports. ===== ====================================================================== To work with reserved ports an application can access directly by commands in/out (recommended way) and can use function 43 (not recommended way). Parameters: * eax = 46 - function number * ebx = 0 - reserve, 1 - free * ecx = start port number * edx = end port number (inclusive) Returned value: * eax = 0 - success * eax = 1 - error Remarks: * For ports reservation: an error occurs if and only if one from the following condition satisfies: * start port is more than end port; * the selected range contains incorrect port number (correct are from 0 to 0xFFFF); * limit for the total number of reserved areas is exceeded (maximum 255 are allowed); * the selected range intersects with any of earlier reserved * For ports free: an error is an attempt to free range, that was not earlier reserved by this function (with same ecx,edx). * If an error occurs (for both cases) function performs no action. * At booting the system reserves for itself ports 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (inclusively). * When a thread terminates, all reserved by it ports are freed automatically. ---------------------- Constants for registers: ---------------------- eax - SF_SET_PORTS (46) ====================================================================== ============= Function 47 - draw a number in the window. ============= ====================================================================== Parameters: * eax = 47 - function number * ebx = parameters of conversion number to text: * bl = 0 - ecx contains number * bl = 1 - ecx contains pointer to dword/qword-number * bh = 0 - display in decimal number system * bh = 1 - display in hexadecimal system * bh = 2 - display in binary system * bits 16-21 = how many digits to display * bits 22-29 reserved and must be set to 0 * bit 30 set = display qword (64-bit) number (must be bl=1) * bit 31 set = do not display leading zeroes of the number * ecx = number (if bl=0) or pointer (if bl=1) * edx = [coordinate on axis x]*65536 + [coordinate on axis y] * esi = 0xXXRRGGBB, where * RR, GG, BB specify text color * XX = 0B0FCSSS (bits): * B=1 - fill background (color = edi) * F specifies the font: 0 = 6x9 1 = 8x16 * C=0 - draw to the window, C=1 - draw to the user buffer (edi) * SSS = (size multiplier)-1, so 0 = x1, 7 = x8 Returned value: * function does not return value Remarks: * The given length must not exceed 60. * The exactly given amount of digits is output. If number is small and can be written by smaller amount of digits, it is supplemented by leading zeroes; if the number is big and can not be written by given amount of digits, extra digits are not drawn. ---------------------- Constants for registers: ---------------------- eax - SF_DRAW_NUMBER (47) ====================================================================== ========= Function 48, subfunction 0 - apply screen settings. ======== ====================================================================== Parameters: * eax = 48 - function number * ebx = 0 - subfunction number * ecx = 0 - reserved Returned value: * function does not return value Remarks: * Function redraws the screen after parameters change by subfunctions 1 and 2. * Function call without prior call to one of indicated subfunctions is ignored. * Function call with nonzero ecx is ignored. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_APPLY (0) ====================================================================== =========== Function 48, subfunction 1 - set button style. =========== ====================================================================== Parameters: * eax = 48 - function number * ebx = 1 - subfunction number * ecx = button style: * 0 = flat * 1 = 3d Returned value: * function does not return value Remarks: * After call to this function one should redraw the screen by subfunction 0. * Button style influences only to their draw of function 8. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_BUTTON_STYLE (1) ====================================================================== ====== Function 48, subfunction 2 - set standard window colors. ====== ====================================================================== Parameters: * eax = 48 - function number * ebx = 2 - subfunction number * ecx = pointer to the color table * edx = size of the color table (must be 40 bytes for future compatibility) Format of the color table is shown in description of subfunction 3. Returned value: * function does not return value Remarks: * After call to this function one should redraw the screen by subfunction 0. * Table of standard colors influences only to applications, which receive this table obviously (by subfunction 3) and use it (specifying colors from it to drawing functions). * Table of standard colors is included in skin and is installed anew with skin installation (by subfunction 8). * Color table can be viewed/changed interactively with the application 'desktop'. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_COLORS (2) ====================================================================== ====== Function 48, subfunction 3 - get standard window colors. ====== ====================================================================== Parameters: * eax = 48 - function number * ebx = 3 - subfunction number * ecx = pointer to the buffer with size edx bytes, where table will be written * edx = size of color table (must be 40 bytes for future compatibility) Returned value: * function does not return value Format of the color table: each item is dword-value for color 0x00RRGGBB * +0: dword: frames - color of frame * +4: dword: grab - color of header * +8: dword: grab_button - color of button on header bar * +12 = +0xC: dword: grab_button_text - color of text on button on header bar * +16 = +0x10: dword: grab_text - color of text on header * +20 = +0x14: dword: work - color of working area * +24 = +0x18: dword: work_button - color of button in working area * +28 = +0x1C: dword: work_button_text - color of text on button in working area * +32 = +0x20: dword: work_text - color of text in working area * +36 = +0x24: dword: work_graph - color of graphics in working area Remarks: * Structure of the color table is described in the standard include file 'macros.inc' as 'system_colors'; for example, it is possible to write: sc system_colors ; variable declaration ... ; somewhere one must call ; this function with ecx=sc mov ecx, [sc.work_button_text] ; read text color on ; button in working area * A program itself decides to use or not to use color table. For usage program must simply at calls to drawing functions select color taken from the table. * At change of the table of standard colors (by subfunction 2 with the subsequent application of changes by subfunction 0 or at skin set by subfunction 8) the system sends to all windows redraw message (the event with code 1). * Color table can be viewed/changed interactively with the application 'desktop'. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_COLORS (3) ====================================================================== ============ Function 48, subfunction 4 - get skin height. =========== ====================================================================== Parameters: * eax = 48 - function number * ebx = 4 - subfunction number Returned value: * eax = skin height Remarks: * Skin height is defined as the height of a header of skinned windows. * See also general structure of window in the description of function 0. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_SKIN_HEIGHT (4) ====================================================================== ======== Function 48, subfunction 5 - get screen working area. ======= ====================================================================== Parameters: * eax = 48 - function number * ebx = 5 - subfunction number Returned value: * eax = [left]*65536 + [right] * ebx = [top]*65536 + [bottom] Remarks: * The screen working area defines position and coordinates of a maximized window. * The screen working area in view of normal work is all screen without taskbar ('@taskbar' application). * (left,top) are coordinates of the left upper corner, (right,bottom) are coordinates of the right lower one. Thus the size of working area on x axis can be calculated by formula right-left+1, on y axis - by formula bottom-right+1. * See also function 14, to get sizes of all screen. * There is a pair function to set working area - subfunction 6. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_SCREEN_AREA (5) ====================================================================== ======== Function 48, subfunction 6 - set screen working area. ======= ====================================================================== Parameters: * eax = 48 - function number * ebx = 6 - subfunction number * ecx = [left]*65536 + [right] * edx = [top]*65536 + [bottom] Returned value: * function does not return value Remarks: * The screen working area defines position and coordinates of a maximized window. * This function is used only by the application '@taskbar', which set working area to all screen without taskbar. * (left,top) are coordinates of the left upper corner, (right,bottom) are coordinates of the right lower one. Thus the size of working area on x axis can be calculated by formula right-left+1, on y axis - by formula bottom-right+1. * If 'left'>='right', x-coordinate of working area is not changed. If 'left'<0, 'left' will not be set. If 'right' is greater than or equal to screen width, 'right' will not be set. Similarly on y axis. * See also function 14, to get sizes of all screen. * There is a pair function to get working area - subfunction 5. * This function redraws the screen automatically, updating coordinates and sizes of maximized windows. The system sends to all windows redraw message (the event 1). ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_SCREEN_AREA (6) ====================================================================== =========== Function 48, subfunction 7 - get skin margins. =========== ====================================================================== Returns the area of a header of a skinned window, intended for a text of a header. Parameters: * eax = 48 - function number * ebx = 7 - subfunction number Returned value: * eax = [left]*65536 + [right] * ebx = [top]*65536 + [bottom] Remarks: * An application decides itself to use or not to use this function. * It is recommended to take into account returned value of this function for choice of a place for drawing header text (by function 4) or a substitute of header text (at the discretion of an application). ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_SKIN_MARGINS (7) ====================================================================== ============= Function 48, subfunction 8 - set used skin. ============ ====================================================================== Parameters: * eax = 48 - function number * ebx = 8 - subfunction number * ecx = pointer to filename of the skin Returned value: * eax = 0 - success * otherwise eax = file system error code; if file does not contain valid skin, function returns error 3 (unknown file system). Remarks: * After successful skin loading the system sends to all windows redraw message (the event 1). * At booting the system reads skin from file 'default.skn' on ramdisk. * User can change the skin statically by creating hisself 'default.skn' or dynamically with the application 'desktop'. ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_SKIN (8) ====================================================================== ====== Function 48, subfunction 9 - get font smoothing setting. ====== ====================================================================== Parameters: * eax = 48 - function number * ebx = 9 - subfunction number Returned value: * eax = 2 - subpixel, 1 - anti-aliasing, 0 - off ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_FONT_SMOOTH (9) ====================================================================== ========== Function 48, subfunction 10 - set font smoothing. ========= ====================================================================== Parameters: * eax = 48 - function number * ebx = 10 - subfunction number * cl = 2 - subpixel, 1 - anti-aliasing, 0 - off ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_FONT_SMOOTH (10) ====================================================================== ============ Function 48, subfunction 11 - get font size. ============ ====================================================================== Parameters: * eax = 48 - function number * ebx = 11 - subfunction number Returned value: * eax = current font height in pixels ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_GET_FONT_SIZE (11) ====================================================================== ============ Function 48, subfunction 12 - set font size. ============ ====================================================================== Parameters: * eax = 48 - function number * ebx = 12 - subfunction number * cl = new font height in pixels ---------------------- Constants for registers: ---------------------- eax - SF_STYLE_SETTINGS (48) ebx - SSF_SET_FONT_SIZE (12) ====================================================================== == Function 48, subfunction 13 - set skin, specifying the encoding. == ====================================================================== Parameters: * eax = 48 - function number * ebx = 13 - subfunction number * ecx = pointer to the skin file path string * edx = string encoding, details can be found in function 80 description. Returned value: * eax = 0 - success * otherwise eax = file system error code; if file does not contain valid skin, function returns error 3 (unknown file system). Remarks: * After successful skin loading the system sends to all windows redraw message (the event 1). * At booting the system reads skin from file 'default.skn' on ramdisk. * User can change the skin statically by creating hisself 'default.skn' or dynamically with the application 'desktop'. ====================================================================== =========== Function 49 - Advanced Power Management (APM). =========== ====================================================================== Parameters: * eax = 49 - function number * dx = number of the APM function (analogue of ax in APM specification) * bx, cx = parameters of the APM function Returned value: * 16-bit registers ax, bx, cx, dx, si, di and carry flag CF are set according to the APM specification * high halves of 32-bit registers eax, ebx, ecx, edx, esi, edi are destroyed Remarks: * APM 1.2 specification is described in the document "Advanced Power Management (APM) BIOS Specification" (Revision 1.2), available at http://www.microsoft.com/whdc/archive/amp_12.mspx; besides it is included in famous Interrupt List by Ralf Brown (http://www.pobox.com/~ralf/files.html, ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/). ---------------------- Constants for registers: ---------------------- eax - SF_APM (49) ====================================================================== =================== Function 50 - set window shape. ================== ====================================================================== Normal windows have rectangular shape. This function can give to a window any shape. The shape is given by a set of points inside the base rectangle belonging to a window. Position and coordinates of the base rectangle are set by function 0 and changed by function 67. --------------------------- Set shape data --------------------------- Parameters: * eax = 50 - function number * ebx = 0 - subfunction number * ecx = pointer to shape data (array of bytes 0/1) Returned value: * function does not return value -------------------------- Set shape scale --------------------------- Parameters: * eax = 50 - function number * ebx = 1 - subfunction number * ecx sets a scale: each byte of data defines (2^scale)*(2^scale) pixels Returned value: * function does not return value Remarks: * Default scale is 0 (scale factor is 1). If in the shape data one byte corresponds to one pixel, there is no necessity to set scale. * Let's designate xsize = window width (in pixels), ysize = height; pay attention, that they are one pixel more than defined by functions 0, 67. * On definition of scale xsize and ysize must be divisible on 2^scale. * Byte of data on offset 'a' must be 0/1 and defines belonging to a window of square with the side 2^scale (if scale=0, this is one pixel) and coordinates of the left upper corner (a mod (xsize shr scale), a div (xsize shr scale)) * Data size: (xsize shr scale)*(ysize shr scale). * Data must be presented in the memory and not change after set of shape. * The system views the shape data at every window redraw by function 0. * The call of subfunction 0 with NULL pointer results in return to the rectangular shape. ---------------------- Constants for registers: ---------------------- eax - SF_SET_WINDOW_SHAPE (50) ====================================================================== ==================== Function 51 - create thread. ==================== ====================================================================== Parameters: * eax = 51 - function number * ebx = 1 - unique subfunction * ecx = address of thread entry point (starting eip) * edx = pointer to thread stack (starting esp) Returned value: * eax = -1 - error (there is too many threads) * otherwise eax = TID - thread identifier ---------------------- Constants for registers: ---------------------- eax - SF_CREATE_THREAD (51) ====================================================================== ==================== Function 54, subfunction 0 ====================== ============== Get the number of slots in the clipboard. ============= ====================================================================== Parameters: * eax = 54 - function number * ebx = 0 - subfunction number Returned value: * eax = slots in the clipboard * eax = -1 - main list area not found ---------------------- Constants for registers: ---------------------- eax - SF_CLIPBOARD (54) ebx - SSF_GET_SLOT_COUNT (0) ====================================================================== ==================== Function 54, subfunction 1 ====================== ================= Read the data from the clipboard. ================== ====================================================================== Parameters: * eax = 54 - function number * ebx = 1 - subfunction number * eсx = slot number Returned value: * eax = if successful - pointer to a memory with data * eax = 1 - error * eax = -1 - main list area not found Remarks: * The function must be used in conjunction with 68.11. The application must pre-initialize the local heap by calling 68.11. ---------------------- Constants for registers: ---------------------- eax - SF_CLIPBOARD (54) ebx - SSF_READ_CB (1) ====================================================================== ==================== Function 54, subfunction 2 ====================== ================= Write the data to the clipboard. =================== ====================================================================== Parameters: * eax = 54 - function number * ebx = 2 - subfunction number * eсx = the number of bytes to be copied * edx = a pointer to a buffer for data to be copied Returned value: * eax = 0 - success * eax = 1 - error * eax = -1 - main list area not found ---------------------- Constants for registers: ---------------------- eax - SF_CLIPBOARD (54) ebx - SSF_WRITE_CB (2) ====================================================================== ===================== Function 54, subfunction 3 ===================== ================ Delete the last slot in the clipboard =============== ====================================================================== Parameters: * eax = 54 - function number * ebx = 3 - subfunction number Returned value: * eax = 0 - success * eax = 1 - error * eax = -1 - main list area not found ---------------------- Constants for registers: ---------------------- eax - SF_CLIPBOARD (54) ebx - SSF_DEL_SLOT (3) ====================================================================== ===================== Function 54, subfunction 4 ===================== ===================== Alarm reset the lock buffer ==================== ====================================================================== Parameters: * eax = 54 - function number * ebx = 4 - subfunction number Returned value: * eax = 0 - success * eax = -1 - main list area not found or no blocking Remarks: * Used in exceptional cases, where no responsible or killed application blocked the clipboard operations. ---------------------- Constants for registers: ---------------------- eax - SF_CLIPBOARD (54) ebx - SSF_UNLOCK_BUFFER (4) ====================================================================== Function 55, subfunction 55 - begin to play data on built-in speaker. ====================================================================== Parameters: * eax = 55 - function number * ebx = 55 - subfunction number * esi = pointer to data Returned value: * eax = 0 - success * eax = 55 - error (speaker is off or busy) Data is an array of items with variable length. Format of each item is defined by first byte: * 0 = end of data * 1..0x80 = sets sound duration on 1/100 of second; sound note is defined by immediate value of frequency * following word (2 bytes) contains frequency divider; frequency is defined as 1193180/divider * 0x81 = invalid * 0x82..0xFF = note is defined by octave and number: * duration in 1/100 of second = (first byte)-0x81 * there is one more byte; * (second byte)=0xFF - delay * otherwise it looks like a*0x10+b, where b=number of the note in an octave from 1 to 12, a=number of octave (beginning from 0) Remarks: * Speaker play can be disabled/enabled by subfunction 8 of function 18. * Function returns control, having informed the system an information on request. Play itself goes independently from the program. * The data must be kept in the memory at least up to the end of play. ---------------------- Constants for registers: ---------------------- eax - SF_SPEAKER_PLAY (55) ====================================================================== ======================= Function 57 - PCI BIOS. ====================== ====================================================================== Parameters: * eax = 57 - function number * ebp corresponds to al in PCI BIOS specification * other registers are set according to PCI BIOS specification Returned value: * CF is undefined * other registers are set according to PCI BIOS specification Remarks: * Many effects of this function can be also achieved with corresponding subfunctions of function 62. * The function calls PCI32 BIOS extension, documented e.g. in http://alpha1.dyns.net/files/PCI/bios21.pdf. * If BIOS does not support this extension, its behavior is emulated (through kernel-mode analogues of subfunctions of function 62). ---------------------- Constants for registers: ---------------------- eax - SF_PCI_BIOS (57) ====================================================================== ========== Function 60 - Inter Process Communication (IPC). ========== ====================================================================== IPC is used for message dispatching from one process/thread to another. Previously it is necessary to agree how to interpret the concrete message. ----------- Subfunction 1 - set the area for IPC receiving ----------- Is called by process-receiver. Parameters: * eax = 60 - function number * ebx = 1 - subfunction number * ecx = pointer to the buffer * edx = size of the buffer Returned value: * eax = 0 - always success Format of IPC-buffer: * +0: dword: if nonzero, buffer is considered locked; lock/unlock the buffer, when you work with it and need that buffer data are not changed from outside (no new messages) * +4: dword: occupied place in the buffer (in bytes) * +8: first message * +8+n: second message * ... Format of a message: * +0: dword: PID of sender * +4: dword: message length (not including this header) * +8: n*byte: message data ------------------ Subfunction 2 - send IPC message ------------------ Is called by process-sender. Parameters: * eax = 60 - function number * ebx = 2 - subfunction number * ecx = PID of receiver * edx = pointer to the message data * esi = message length (in bytes) Returned value: * eax = 0 - success * eax = 1 - the receiver has not defined buffer for IPC messages (can be, still have no time, and can be, this is not right process) * eax = 2 - the receiver has blocked IPC-buffer; try to wait a bit * eax = 3 - overflow of IPC-buffer of the receiver * eax = 4 - process/thread with such PID does not exist Remarks: * Immediately after writing of IPC-message to the buffer the system sends to the receiver the event with code 7 (see event codes). ---------------------- Constants for registers: ---------------------- eax - SF_IPC (60) ebx - SSF_SET_AREA (1), SSF_SEND_MESSAGE (2) ====================================================================== ==== Function 61 - get parameters for the direct graphics access. ==== ====================================================================== The data of the graphics screen (the memory area which displays screen contents) are accessible to a program directly, without any system calls, through the selector gs: mov eax, [gs:0] places in eax the first dword of the buffer, which contains information on color of the left upper point (and, possibly, colors of several following). mov [gs:0], eax by work in VESA modes with LFB sets color of the left upper point (and, possibly, colors of several following). To interpret the data of graphics screen program needs to know some parameters, returning by this function. Remarks: * Graphics parameters changes very seldom at work. * At videomode change the system redraws all windows (event with code 1) and redraws the background (event 5). Same events occur in other cases too, which meet much more often, than videomode change. * By operation in videomodes with LFB the selector gs points to LFB itself, so reading/writing on gs result directly in change of screen contents. By operation in videomodes without LFB gs points to some data area in the kernel, and all functions of screen output fulfil honesty double operation on writing directly to the screen and writing to this buffer. In result at reading contents of this buffer the results correspond to screen contents (with, generally speaking, large color resolution), and writing is ignored. One exception is the mode 320*200, for which main loop of the system thread updates the screen according to mouse movements. ------------------------- Screen resolution -------------------------- Parameters: * eax = 61 - function number * ebx = 1 - subfunction number Returned value: * eax = [resolution on x axis]*65536 + [resolution on y axis] Remarks: * One can use function 14 paying attention that it returns sizes on 1 pixel less. It is fully equivalent way. ---------------------- Number of bits per pixel ---------------------- Parameters: * eax = 61 - function number * ebx = 2 - subfunction number Returned value: * eax = number of bits per pixel (24 or 32) -------------------- Number of bytes per scanline -------------------- Parameters: * eax = 61 - function number * ebx = 3 - subfunction number Returned value: * eax = number of bytes occupied by one scanline (horizontal line on the screen) ---------------------- Constants for registers: ---------------------- eax - SF_GET_GRAPHICAL_PARAMS (61) ebx - SSF_SCREEN_SIZE (1), SSF_BITS_PER_PIXEL (2), SSF_BYTES_PER_LINE (3) ====================================================================== ===== Function 62, subfunction 0 - get version of PCI-interface. ===== ====================================================================== Parameters: * eax = 62 - function number * bl = 0 - subfunction number Returned value: * eax = -1 - PCI access is disabled; otherwise * ah.al = version of PCI-interface (ah=version, al=subversion) * high word of eax is zeroed Remarks: * Previously low-level access to PCI for applications must be enabled by subfunction 12 of function 21. * If PCI BIOS is not supported, the value of ax is undefined. ---------------------- Constants for registers: ---------------------- eax - SF_PCI (62) ebx - SSF_GET_VERSION (0) ====================================================================== ==== Function 62, subfunction 1 - get number of the last PCI-bus. ==== ====================================================================== Parameters: * eax = 62 - function number * bl = 1 - subfunction number Returned value: * eax = -1 - access to PCI is disabled; otherwise * al = number of the last PCI-bus; other bytes of eax are destroyed Remarks: * Previously low-level access to PCI for applications must be enabled by subfunction 12 of function 21. * If PCI BIOS is not supported, the value of ax is undefined. ---------------------- Constants for registers: ---------------------- eax - SF_PCI (62) ebx - SSF_GET_LAST_BUS (1) ====================================================================== ===================== Function 62, subfunction 2 ===================== ===== Get mechanism of addressing to the PCI configuration space. ==== ====================================================================== Parameters: * eax = 62 - function number * bl = 2 - subfunction number Returned value: * eax = -1 - access to PCI is disabled; otherwise * al = mechanism (1 or 2); other bytes of eax are destroyed Remarks: * Previously low-level access to PCI for applications must be enabled by subfunction 12 of function 21. * Addressing mechanism is selected depending on equipment characteristics. * Subfunctions of read and write work automatically with the selected mechanism. ---------------------- Constants for registers: ---------------------- eax - SF_PCI (62) ebx - SSF_GET_ADRR_MODE (2) ====================================================================== ======== Function 62, subfunctions 4,5,6 - read PCI-register. ======== ====================================================================== Parameters: * eax = 62 - function number * bl = 4 - read byte * bl = 5 - read word * bl = 6 - read dword * bh = number of PCI-bus * ch = dddddfff, where ddddd = number of the device on the bus, fff = function number of device * cl = number of register (must be even for bl=5, divisible by 4 for bl=6) Returned value: * eax = -1 - error (access to PCI is disabled or parameters are not supported); otherwise * al/ax/eax (depending on requested size) contains the data; the other part of register eax is destroyed Remarks: * Previously low-level access to PCI for applications must be enabled by subfunction 12 of function 21. * Access mechanism 2 supports only 16 devices on a bus and ignores function number. To get access mechanism use subfunction 2. * Some registers are standard and exist for all devices, some are defined by the concrete device. The list of registers of the first type can be found e.g. in famous Interrupt List by Ralf Brown (http://www.pobox.com/~ralf/files.html, ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/); registers of the second type must be listed in the device documentation. ---------------------- Constants for registers: ---------------------- eax - SF_PCI (62) ebx - SSF_READ_BYTE (4), SSF_READ_WORD (5), SSF_READ_DWORD (6) ====================================================================== ====== Function 62, subfunctions 8,9,10 - write to PCI-register. ===== ====================================================================== Parameters: * eax = 62 - function number * bl = 8 - write byte * bl = 9 - write word * bl = 10 - write dword * bh = number of PCI-bus * ch = dddddfff, where ddddd = number of the device on the bus, fff = function number of device * cl = number of register (must be even for bl=9, divisible by 4 for bl=10) * dl/dx/edx (depending on requested size) contains the data to write Returned value: * eax = -1 - error (access to PCI is disabled or parameters are not supported) * eax = 0 - success Remarks: * Previously low-level access to PCI for applications must be enabled by subfunction 12 of function 21. * Access mechanism 2 supports only 16 devices on a bus and ignores function number. To get access mechanism use subfunction 2. * Some registers are standard and exist for all devices, some are defined by the concrete device. The list of registers of the first type can be found e.g. in famous Interrupt List by Ralf Brown; registers of the second type must be listed in the device documentation. ---------------------- Constants for registers: ---------------------- eax - SF_PCI (62) ebx - SSF_WRITE_BYTE (8), SSF_WRITE_WORD (9), SSF_WRITE_DWORD (10) ====================================================================== ============== Function 63 - work with the debug board. ============== ====================================================================== The debug board is the global system buffer (with the size 1024 bytes), to which any program can write (generally speaking, arbitrary) data and from which other program can read these data. By the agreement written data are text strings interpreted as debug messages on a course of program execution. The kernel in some situations also writes to the debug board information on execution of some functions; by the agreement kernel messages begins from the prefix "K : ". For view of the debug board the application 'board' was created, which reads data from the buffer and displays them in its window. 'board' interpretes the sequence of codes 13,10 as newline. A character with null code in an end of line is not necessary, but also does not prevent. Because debugger has been written, the value of the debug board has decreased, as debugger allows to inspect completely a course of program execution without any efforts from the direction of program itself. Nevertheless in some cases the debug board is still useful. ----------------------------- Write byte ----------------------------- Parameters: * eax = 63 - function number * ebx = 1 - subfunction number * cl = data byte Returned value: * function does not return value Remarks: * Byte is written to the buffer. Buffer size is 512 bytes. At buffer overflow all obtained data are lost. * For output to the debug board of more complicated objects (strings, numbers) it is enough to call this function in cycle. It is possible not to write the appropriate code manually and use file 'debug.inc', which is included into the distributive. ----------------------------- Read byte ------------------------------ Takes away byte from the buffer. Parameters: * eax = 63 - function number * ebx = 2 - subfunction number Returned value: * eax = ebx = 0 - the buffer is empty * eax = byte, ebx = 1 - byte was successfully read ---------------------- Constants for registers: ---------------------- eax - SF_BOARD (63) ebx - SSF_DEBUG_WRITE (1), SSF_DEBUG_READ (2) ====================================================================== ============== Function 64 - resize application memory. ============== ====================================================================== Parameters: * eax = 64 - function number * ebx = 1 - unique subfunction * ecx = new memory size Returned value: * eax = 0 - success * eax = 1 - not enough memory Remarks: * There is another way to dynamically allocate/free memory - subfunctions 12, 13 and 20 of function 68, but after creation of the process heap 64 function call will be ignored. * The function cannot be used together with 68.11, 68.12, 68.13. The function call will be ignored after creation of process heap with function 68.11. ---------------------- Constants for registers: ---------------------- eax - SF_MEMORY_RESIZE (64) ====================================================================== ======== Function 65 - draw image with palette in the window. ======== ====================================================================== Parameters: * eax = 65 - function number * ebx = pointer to the image * ecx = [size on axis x]*65536 + [size on axis y] * edx = [coordinate on axis x]*65536 + [coordinate on axis y] * esi = number of bits per pixel, must be 1,2,4,8,9,15,16,24 or 32; * edi = pointer to palette (2 to the power esi colors 0x00RRGGBB); ignored when esi > 8 * ebp = offset of next row data relative to previous row data Returned value: * function does not return value Remarks: * Coordinates of the image are coordinates of the upper left corner of the image relative to the window. * Format of image with 1 bit per pixel: each byte of image (possibly excluding last bytes in rows), contains information on the color of 8 pixels, MSB corresponds to first pixel. * Format of image with 2 bits per pixel: each byte of image (possibly excluding last bytes in rows), contains information on the color of 4 pixels, two MSBs correspond to first pixel. * Format of image with 4 bits per pixel: each byte of image excluding last bytes in rows (if width is odd) contains information on the color of 2 pixels, high-order tetrad corresponds to first pixel. * Format of image with 8 bits per pixel: each byte of image is index in the palette. * Format of image with 9 bits per pixel: array of one byte values; each byte (8 bit) represents the intensity of gray for one pixel; this format is equal to 8bpp without palette. * Format of image with 15 bits per pixel: the color of each pixel is coded as (bit representation) 0RRRRRGGGGGBBBBB - 5 bits per each color. * Format of image with 16 bits per pixel: the color of each pixel is coded as RRRRRGGGGGGBBBBB (5+6+5). * Format of image with 24 bits per pixel: the color of each pixel is coded as 3 bytes - sequentially blue, green, red components. * Format of image with 32 bits per pixel: similar to 24, but one additional ignored byte is present. It's format is BGRX, where X is the ignored byte. * The call to function 7 is equivalent to call to this function with esi=24, ebp=0. ---------------------- Constants for registers: ---------------------- eax - SF_PUT_IMAGE_EXT (65) ====================================================================== ================== Function 66 - work with keyboard. ================= ====================================================================== The input mode influences results of reading keys by function 2. When a program loads, ASCII input mode is set for it. -------------- Subfunction 1 - set keyboard input mode. -------------- Parameters: * eax = 66 - function number * ebx = 1 - subfunction number * ecx = mode: * 0 = normal (ASCII-characters) * 1 = scancodes Returned value: * function does not return value -------------- Subfunction 2 - get keyboard input mode. -------------- Parameters: * eax = 66 - function number * ebx = 2 - subfunction number Returned value: * eax = current mode ------------ Subfunction 3 - get status of control keys. ------------- Parameters: * eax = 66 - function number * ebx = 3 - subfunction number Returned value: * eax = bit mask: * bit 0 (mask 1): left Shift is pressed * bit 1 (mask 2): right Shift is pressed * bit 2 (mask 4): left Ctrl is pressed * bit 3 (mask 8): right Ctrl is pressed * bit 4 (mask 0x10): left Alt is pressed * bit 5 (mask 0x20): right Alt is pressed * bit 6 (mask 0x40): CapsLock is on * bit 7 (mask 0x80): NumLock is on * bit 8 (mask 0x100): ScrollLock is on * bit 9 (mask 0x200): left Win is pressed * bit 10 (mask 0x400): right Win is pressed * other bits are cleared -------------- Subfunction 4 - set system-wide hotkey. --------------- When hotkey is pressed, the system notifies only those applications, which have installed it; the active application (which receives all normal input) does not receive such keys. The notification consists in sending event with the code 2. Reading hotkey is the same as reading normal key - by function 2. Parameters: * eax = 66 - function number * ebx = 4 - subfunction number * cl determines key scancode; use cl=0 to give combinations such as Ctrl+Shift * edx = 0xXYZ determines possible states of control keys: * Z (low 4 bits) determines state of LShift and RShift: * 0 = no key must be pressed; * 1 = exactly one key must be pressed; * 2 = both keys must be pressed; * 3 = must be pressed LShift, but not RShift; * 4 = must be pressed RShift, but not LShift * Y - similar for LCtrl and RCtrl; * X - similar for LAlt and RAlt Returned value: * eax=0 - success * eax=1 - too many hotkeys (maximum 256 are allowed) Remarks: * Hotkey can work either at pressing or at release. Release scancode of a key is more on 128 than pressing scancode (i.e. high bit is set). * Several applications can set the same combination; all such applications will be informed on pressing such combination. -------------- Subfunction 5 - delete installed hotkey. -------------- Parameters: * eax = 66 - function number * ebx = 5 - subfunction number * cl = scancode of key and edx = 0xXYZ the same as in subfunction 4 Returned value: * eax = 0 - success * eax = 1 - there is no such hotkey Remarks: * When a process/thread terminates, all hotkey installed by it are deleted. * The call to this subfunction does not affect other applications. If other application has defined the same combination, it will still receive notices. --------------- Subfunction 6 - block the normal input. -------------- Parameters: * eax = 66 - function number * ebx = 6 - subfunction number Returned value: * function does not return value Remarks: * Blocking the normal keyboard input for installed hotkeys * To emulate a mouse via the keyboard, the application MOUSEMUL ------------ Subfunction 7 - unlock the normal input. ---------------- Parameters: * eax = 66 - function number * ebx = 7 - subfunction number Returned value: * function does not return value Remarks: * Unlocking the results of the f. 66.6 * To emulate a mouse via the keyboard, the application MOUSEMUL ---------------------- Constants for registers: ---------------------- eax - SF_KEYBOARD (66) ebx - SSF_SET_INPUT_MODE (1), SSF_GET_INPUT_MODE (2), SSF_GET_CONTROL_KEYS (3), SSF_SET_SYS_HOTKEY (4), SSF_DEL_SYS_HOTKEY (5), SSF_LOCK_INPUT (6), SSF_UNLOCK_INPUT (7) ====================================================================== ========= Function 67 - change position/sizes of the window. ========= ====================================================================== Parameters: * eax = 67 - function number * ebx = new x-coordinate of the window * ecx = new y-coordinate of the window * edx = new x-size of the window * esi = new y-size of the window Returned value: * function does not return value Remarks: * The value -1 for a parameter means "do not change"; e.g. to move the window without resizing it is possible to specify edx=esi=-1. * Previously the window must be defined by function 0. It sets initial coordinates and sizes of the window. * Sizes of the window are understood in sense of function 0, that is one pixel less than real sizes. * The function call for maximized windows is simply ignored. * For windows of appropriate styles position and/or sizes can be changed by user; current position and sizes can be obtained by call to function 9. * The function sends to the window redraw event (with the code 1). ---------------------- Constants for registers: ---------------------- eax - SF_CHANGE_WINDOW (67) ====================================================================== ====== Function 68, subfunction 0 - get the task switch counter. ===== ====================================================================== Parameters: * eax = 68 - function number * ebx = 0 - subfunction number Returned value: * eax = number of task switches from the system booting (modulo 2^32) ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_GET_TASK_SWITCH_COUNT (0) ====================================================================== ======= Function 68, subfunction 1 - switch to the next thread. ====== ====================================================================== The function completes the current time slice allocated to the thread and switches to the next. (Which thread in which process will be next, is unpredictable). Later, when execution queue will reach the current thread, execution will be continued. Parameters: * eax = 68 - function number * ebx = 1 - subfunction number Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_SWITCH_TASK (1) ====================================================================== ============= Function 68, subfunction 2 - cache + rdpmc. ============ ====================================================================== Parameters: * eax = 68 - function number * ebx = 2 - subfunction number * ecx = required action: * ecx = 0 - enable instruction 'rdpmc' (ReaD Performance-Monitoring Counters) for applications * ecx = 1 - find out whether cache is disabled/enabled * ecx = 2 - enable cache * ecx = 3 - disable cache Returned value: * for ecx=0: * eax = the value of cr4 * for ecx=1: * eax = (cr0 and 0x60000000): * eax = 0 - cache is on * eax <> 0 - cache is off * for ecx=2 and ecx=3: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_PERFORMANCE (2) ecx - SSSF_ALLOW_RDPMC (0), SSSF_CACHE_STATUS (1), SSSF_CACHE_ON (2), SSSF_CACHE_OFF (3) ====================================================================== =========== Function 68, subfunction 3 - read MSR-register. ========== ====================================================================== MSR = Model Specific Register; the complete list of MSR-registers of a processor is included to the documentation on it (for example, IA-32 Intel Architecture Software Developer's Manual, Volume 3, Appendix B); each processor family has its own subset of the MSR-registers. Parameters: * eax = 68 - function number * ebx = 3 - subfunction number * ecx is ignored * edx = MSR address Returned value: * ebx:eax = high:low dword of the result Remarks: * If ecx contains nonexistent or not implemented for this processor MSR, processor will generate an exception in the kernel, which will kill the thread. * Previously it is necessary to check, whether MSRs are supported as a whole, with the instruction 'cpuid'. Otherwise processor will generate other exception in the kernel, which will anyway kill the thread. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_READ_MSR (3) ====================================================================== ========= Function 68, subfunction 4 - write to MSR-register. ======== ====================================================================== MSR = Model Specific Register; the complete list of MSR-registers of a processor is included to the documentation on it (for example, IA-32 Intel Architecture Software Developer's Manual, Volume 3, Appendix B); each processor family has its own subset of the MSR-registers. Parameters: * eax = 68 - function number * ebx = 4 - subfunction number * ecx is ignored * edx = MSR address * esi:edi = high:low dword Returned value: * function does not return value Remarks: * If ecx contains nonexistent or not implemented for this processor MSR, processor will generate an exception in the kernel, which will kill the thread. * Previously it is necessary to check, whether MSRs are supported as a whole, with the instruction 'cpuid'. Otherwise processor will generate other exception in the kernel, which will anyway kill the thread. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_WRITE_MSR (4) ====================================================================== === Function 68, subfunction 11 - initialize process heap ============ ====================================================================== Parameters: * eax = 68 - function number * ebx = 11 - subfunction number Returned value: * eax = 0 - failed * otherwise size of created heap Remarks: * The function call initializes heap for subfunctions 12, 13 and 20. * If the process heap is already created, this function will return the size of the existing heap. Heap size is equal to total amount of free application memory. * After creation of the heap calls to function 64 will be ignored. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_HEAP_INIT (11) ====================================================================== ======== Function 68, subfunction 12 - allocate memory block. ======== ====================================================================== Parameters: * eax = 68 - function number * ebx = 12 - subfunction number * ecx = required size in bytes Returned value: * eax = pointer to the allocated block Remarks: * The function allocates an integer number of pages (4 Kb) in such way that the real size of allocated block is more than or equal to requested size. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_ALLOC (12) ====================================================================== ========== Function 68, subfunction 13 - free memory block. ========== ====================================================================== Parameters: * eax = 68 - function number * ebx = 13 - subfunction number * ecx = pointer to the memory block Returned value: * eax = 1 - success * eax = 0 - failed Remarks: * The memory block must have been allocated by subfunction 12 or subfunction 20. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_FREE (13) ====================================================================== ===================== Function 68, subfunction 14 ==================== ============ Wait for signal from another program/driver. ============ ====================================================================== Parameters: * eax = 68 - function number * ebx = 14 - subfunction number * ecx = pointer to the buffer for information (24 bytes) Returned value: * buffer pointed to by ecx contains the following information: * +0: dword: identifier for following data of signal * +4: dword: data of signal (20 bytes), format of which is defined by the first dword ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_WAIT_SIGNAL (14) ====================================================================== ============= Function 68, subfunction 16 - load driver. ============= ====================================================================== Parameters: * eax = 68 - function number * ebx = 16 - subfunction number * ecx = pointer to ASCIIZ-string with driver name Returned value: * eax = 0 - failed * otherwise eax = driver handle Remarks: * If the driver was not loaded yet, it is loaded; if the driver was loaded yet, nothing happens. * Driver name is case-sensitive. Maximum length of the name is 16 characters, including terminating null character, the rest is ignored. * Driver ABC is loaded from file /sys/drivers/ABC.sys. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_LOAD_DRIVER (16) ====================================================================== ============ Function 68, subfunction 17 - driver control. =========== ====================================================================== Parameters: * eax = 68 - function number * ebx = 17 - subfunction number * ecx = pointer to the control structure: * +0: dword: handle of driver * +4: dword: code of driver function * +8: dword: pointer to input data * +12 = +0xC: dword: size of input data * +16 = +0x10: dword: pointer to output data * +20 = +0x14: dword: size of output data Returned value: * eax = determined by driver Remarks: * Function codes and the structure of input/output data are defined by driver. * Previously one must obtain driver handle by subfunction 16. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_CONTROL_DRIVER (17) ====================================================================== == Function 68, subfunction 18 - load DLL, specifying the encoding. == ====================================================================== Parameters: * eax = 68 - function number * ebx = 18 - subfunction number * ecx = pointer to the string with path to DLL * edx = string encoding, details can be found in function 80 description. Returned value: * eax = 0 - failed * otherwise eax = pointer to DLL export table Remarks: * Export table is an array of structures of 2 dword's, terminated by zero. The first dword in structure points to function name, the second dword contains address of function. ====================================================================== =============== Function 68, subfunction 19 - load DLL. ============== ====================================================================== Parameters: * eax = 68 - function number * ebx = 19 - subfunction number * ecx = pointer to the string with path to DLL, rules of path forming can be found in function 70 description. Returned value: * eax = 0 - failed * otherwise eax = pointer to DLL export table ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_LOAD_DLL (19) ====================================================================== ======= Function 68, subfunction 20 - reallocate memory block. ======= ====================================================================== Parameters: * eax = 68 - function number * ebx = 20 - subfunction number * ecx = new size in bytes * edx = pointer to already allocated block Returned value: * eax = pointer to the reallocated block, 0 = error Remarks: * Before this call one must initialize process heap by call to subfunction 11. * The function allocates an integer number of pages (4 Kb) in such way that the real size of allocated block is more than or equal to requested size. * If edx=0, the function call is equivalent to memory allocation with subfunction 12. Otherwise the block at edx must be allocated earlier with subfunction 12 or this subfunction. * If ecx=0, the function frees memory block at edx and returns 0. * The contents of the block are unchanged up to the shorter of the new and old sizes. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_REALLOC (20) ====================================================================== =========== Function 68, subfunction 21 - load driver PE. ============ ====================================================================== Parameters: * eax = 68 - function number * ebx = 21 - subfunction number * ecx = pointer to ASCIIZ-string with driver name * edx = pointer to command line Returned value: * eax = 0 - failed * otherwise eax = driver handle Remarks: * If the driver was not loaded yet, it is loaded; if the driver was loaded yet, nothing happens. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_LOAD_DRIVER_PE (21) ====================================================================== ======== Function 68, subfunction 22 - open named memory area. ======= ====================================================================== Parameters: * eax = 68 - function number * ebx = 22 - subfunction number * ecx = area name. Maximum of 31 characters with terminating zero * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS * esi = flags for open and access: * SHM_OPEN = 0x00 - open existing memory area. If an area with such name does not exist, the function will return error code 5. * SHM_OPEN_ALWAYS = 0x04 - open existing or create new memory area. * SHM_CREATE = 0x08 - create new memory area. If an area with such name already exists, the function will return error code 10. * SHM_READ = 0x00 - only read access * SHM_WRITE = 0x01 - read and write access Returned value: * eax = pointer to memory area, 0 if error has occurred * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS): edx = 0 - success, otherwise - error code * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS): edx = error code (if eax=0) or area size in bytes Error codes: * E_NOTFOUND = 5 * E_ACCESS = 10 * E_NOMEM = 30 * E_PARAM = 33 Remarks: * Before this call one must initialize process heap by call to subfunction 11. * If a new area is created, access flags set maximal rights for other processes. An attempt from other process to open with denied rights will fail with error code E_ACCESS. * The process which has created an area always has write access. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_OPEN (22) ====================================================================== ======= Function 68, subfunction 23 - close named memory area. ======= ====================================================================== Parameters: * eax = 68 - function number * ebx = 23 - subfunction number * ecx = area name. Maximum of 31 characters with terminating zero Returned value: * eax destroyed Remarks: * A memory area is physically freed (with deleting all data and freeing physical memory), when all threads which have opened this area will close it. * When thread is terminating, all opened by it areas are closed. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_CLOSE (23) ====================================================================== ======== Function 68, subfunction 24 - set exception handler. ======== ====================================================================== Parameters: * eax = 68 - function number * ebx = 24 - subfunction number * ecx = address of the new exception handler * edx = the mask of handled exceptions Returned value: * eax = address of the old exception handler (0, if it was not set) * ebx = the old mask of handled exceptions Remarks: * Bit number in mask of exceptions corresponds to exception number in CPU-specification (Intel-PC). For example, FPU exceptions have number 16 (#MF), and SSE exceptions - 19 (#XF). * The current implementation ignores the inquiry for hook of 7 exception - the system handles #NM by its own. * The exception handler is called with exception number as first (and only) stack parameter. So, correct exit from the handler is RET 4. It returns to the instruction, that caused the exception, for faults, and to the next instruction for traps (see classification of exceptions in CPU specification). * When user handler receives control, the corresponding bit in the exception mask is cleared. Raising this exception in consequence leads to default handling, that is, terminating the application in absence of debugger or suspend with notification of debugger otherwise. * After user handler completes critical operations, it can set the corresponding bit in the exception mask with subfunction 25. Also user handler is responsible for clearing exceptions flags in FPU and/or SSE. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_SET_EXCEPTION_HANDLER (24) ====================================================================== ======== Function 68, subfunction 25 - set exception activity ======== ====================================================================== Parameters: * eax = 68 - function number * ebx = 25 - subfunction number * ecx = signal number * edx = value of activity (0/1) Returned value: * eax = -1 - invalid signal number * otherwise eax = old value of activity for this signal (0/1) Remarks: * In current implementation only mask for user exception handler, which has been previously set by subfunction 24, is changed. Signal number corresponds to exception number. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_SET_EXCEPTION_STATE (25) ====================================================================== ====== Function 68, subfunction 26 - release memory pages ============ ====================================================================== Parameters: * eax = 68 - function number * ebx = 26 - subfunction number * ecx = pointer to the memory block, allocated by subfunction 12 * edx = offset from the block beginnings * esi = the size of the region of memory to release, in bytes Remarks: * function release range of pages from ecx+edx to ecx+edx+esi and set virtual memory into reserved state. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_FREE_EXT (26) ====================================================================== ========== Function 68, subfunction 27 - load file =================== ====================================================================== Parameters: * eax = 68 - function number * ebx = 27 - subfunction number * ecx = pointer to the string with path to file, rules of path forming can be found in function 70 description. Returned value: * eax = pointer to the loaded file, or zero * edx = size of the loaded file, or zero Remarks: * function loads file and unpacks, if necessary * Before this call one must initialize process heap by call to subfunction 11. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_LOAD_FILE (27) ====================================================================== == Function 68, subfunction 28 - load file, specifying the encoding == ====================================================================== Parameters: * eax = 68 - function number * ebx = 28 - subfunction number * ecx = pointer to the string with path to file * edx = string encoding, details can be found in function 80 description. Returned value: * eax = pointer to the loaded file, or zero * edx = size of the loaded file, or zero Remarks: * function loads file and unpacks, if necessary ====================================================================== ======== Function 68, subfunction 29 - allocate ring memory. ========= ====================================================================== Parameters: * eax = 68 - function number * ebx = 29 - subfunction number * ecx = required size in bytes Returned value: * eax = 0 - failed * eax = pointer to the allocated ring Remarks: * The requested size must be an exact multiple of pagesize (4 Kb) * The function allocates memory in such a way that you can read and write beyond the size of the allocated memory and will reach the beginning of the buffer again. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) ebx - SSF_MEM_ALLOC_RING (29) ====================================================================== ====================== Function 69 - debugging. ====================== ====================================================================== A process can load other process as debugged by set of corresponding bit by call to subfunction 7 of function 70. A process can have only one debugger; one process can debug some others. The system notifies debugger on events occurring with debugged process. Messages are written to the buffer defined by subfunction 0. Format of a message: * +0: dword: message code * +4: dword: PID of debugged process * +8: there can be additional data depending on message code Message codes: * 1 = exception * in addition dword-number of the exception is given * process is suspended * 2 = process has terminated * comes at any termination: both through the system function -1, and at "murder" by any other process (including debugger itself) * 3 = debug exception int 1 = #DB * in addition dword-image of the register DR6 is given: * bits 0-3: condition of the corresponding breakpoint (set by subfunction 9) is satisfied * bit 14: exception has occurred because of the trace mode (flag TF is set TF) * process is suspended When debugger terminates, all debugged processes are killed. If debugger does not want this, it must previously detach by subfunction 3. All subfunctions are applicable only to processes/threads started from the current by function 70 with set debugging flag. Debugging of multithreaded programs is not supported yet. The full list of subfunctions: * subfunction 0 - define data area for debug messages * subfunction 1 - get contents of registers of debugged thread * subfunction 2 - set contents of registers of debugged thread * subfunction 3 - detach from debugged process * subfunction 4 - suspend debugged thread * subfunction 5 - resume debugged thread * subfunction 6 - read from the memory of debugged process * subfunction 7 - write to the memory of debugged process * subfunction 8 - terminate debugged thread * subfunction 9 - set/clear hardware breakpoint ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_SET_MESSAGE_AREA (0), SSF_GET_REGISTERS (1), SSF_SET_REGISTERS (2), SSF_DETACH (3), SSF_SUSPEND (4), SSF_RESUME (5), SSF_READ_MEMORY (6), SSF_WRITE_MEMORY (7), SSF_TERMINATE (8), SSF_DEFINE_BREAKPOINT (9) ====================================================================== = Function 69, subfunction 0 - define data area fror debug messages. = ====================================================================== Parameters: * eax = 69 - function number * ebx = 0 - subfunction number * ecx = pointer Format of data area: * +0: dword: N = buffer size (not including this header) * +4: dword: occupied place * +8: N*byte: buffer Returned value: * function does not return value Remarks: * If the size field is negative, the buffer is considered locked and at arrival of new message the system will wait. For synchronization frame all work with the buffer by operations lock/unlock neg [bufsize] * Data in the buffer are considered as array of items with variable length - messages. Format of a message is explained in general description. ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_SET_MESSAGE_AREA (0) ====================================================================== ===================== Function 69, subfunction 1 ===================== ============ Get contents of registers of debugged thread. =========== ====================================================================== Parameters: * eax = 69 - function number * ebx = 1 - subfunction number * ecx = thread identifier * edx = size of context structure, must be 0x28=40 bytes * esi = pointer to context structure Returned value: * function does not return value Format of context structure: (FPU is not supported yet) * +0: dword: eip * +4: dword: eflags * +8: dword: eax * +12 = +0xC: dword: ecx * +16 = +0x10: dword: edx * +20 = +0x14: dword: ebx * +24 = +0x18: dword: esp * +28 = +0x1C: dword: ebp * +32 = +0x20: dword: esi * +36 = +0x24: dword: edi Remarks: * If the thread executes code of ring-0, the function returns contents of registers of ring-3. * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_GET_REGISTERS (1) ====================================================================== ===================== Function 69, subfunction 2 ===================== ============ Set contents of registers of debugged thread. =========== ====================================================================== Parameters: * eax = 69 - function number * ebx = 2 - subfunction number * ecx = thread identifier * edx = size of context structure, must be 0x28=40 bytes * esi -> context structure Returned value: * function does not return value Format of context structure is shown in the description of subfunction 1. Remarks: * If the thread executes code of ring-0, the function returns contents of registers of ring-3. * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_SET_REGISTERS (2) ====================================================================== ===== Function 69, subfunction 3 - detach from debugged process. ===== ====================================================================== Parameters: * eax = 69 - function number * ebx = 3 - subfunction number * ecx = identifier Returned value: * function does not return value Remarks: * If the process was suspended, it resumes execution. ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_DETACH (3) ====================================================================== ======== Function 69, subfunction 4 - suspend debugged thread. ======= ====================================================================== Parameters: * eax = 69 - function number * ebx = 4 - subfunction number * ecx = thread identifier Returned value: * function does not return value Remarks: * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_SUSPEND (4) ====================================================================== ======== Function 69, subfunction 5 - resume debugged thread. ======== ====================================================================== Parameters: * eax = 69 - function number * ebx = 5 - subfunction number * ecx = thread identifier Returned value: * function does not return value Remarks: * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_RESUME (5) ====================================================================== = Fucntion 69, subfunction 6 - read from memory of debugged process. = ====================================================================== Parameters: * eax = 69 - function number * ebx = 6 - subfunction number * ecx = identifier * edx = number of bytes to read * esi = address in the memory of debugged process * edi = pointer to buffer for data Returned value: * eax = -1 at an error (invalid PID or buffer) * otherwise eax = number of read bytes (possibly, 0, if esi is too large) Remarks: * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_READ_MEMORY (6) ====================================================================== == Function 69, subfunction 7 - write to memory of debugged process. = ====================================================================== Parameters: * eax = 69 - function number * ebx = 7 - subfunction number * ecx = identifier * edx = number of bytes to write * esi = address of memory in debugged process * edi = pointer to data Returned value: * eax = -1 at an error (invalid PID or buffer) * otherwise eax = number of written bytes (possibly, 0, if esi is too large) Remarks: * Process must be loaded for debugging (as is shown in general description). ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_WRITE_MEMORY (7) ====================================================================== ======= Function 69, subfunction 8 - terminate debugged thread. ====== ====================================================================== Parameters: * eax = 69 - function number * ebx = 8 - subfunction number * ecx = identifier Returned value: * function does not return value Remarks: * Process must be loaded for debugging (as is shown in general description). * The function is similar to subfunction 2 of function 18 with two differences: it requires first remark and accepts PID rather than slot number. ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_TERMINATE (8) ====================================================================== ===== Function 69, subfunction 9 - set/clear hardware breakpoint. ==== ====================================================================== Parameters: * eax = 69 - function number * ebx = 9 - subfunction number * ecx = thread identifier * dl = index of breakpoint, from 0 to 3 inclusively * dh = flags: * if high bit is cleared - set breakpoint: * bits 0-1 - condition: * 00 = breakpoint on execution * 01 = breakpoint on read * 11 = breakpoint on read/write * bits 2-3 - length; for breakpoints on exception it must be 00, otherwise one of * 00 = byte * 01 = word * 11 = dword * esi = breakpoint address; must be aligned according to the length (i.e. must be even for word breakpoints, divisible by 4 for dword) * if high bit is set - clear breakpoint Returned value: * eax = 0 - success * eax = 1 - error in the input data * eax = 2 - (reserved, is never returned in the current implementation) a global breakpoint with that index is already set Remarks: * Process must be loaded for debugging (as is shown in general description). * Hardware breakpoints are implemented through DRx-registers of the processor, all limitations results from this. * The function can reinstall the breakpoint, previously set by it (and it does not inform on this). Carry on the list of set breakpoints in the debugger. * Breakpoints generate debug exception #DB, on which the system notifies debugger. * Breakpoints on write and read/write act after execution of the caused it instruction. ---------------------- Constants for registers: ---------------------- eax - SF_DEBUG (69) ebx - SSF_DEFINE_BREAKPOINT (9) ====================================================================== ==== Function 70 - work with file system with long names support. ==== ====================================================================== Parameters: * eax = 70 * ebx = pointer to the information structure Returned value: * eax = 0 - success; otherwise file system error code * some subfunctions return value in other registers too General format of the information structure: * +0: dword: subfunction number * +4: dword: offset in file or folder * +8: dword: higher part of offset or flags * +12 = +0xC: dword: size of data * +16 = +0x10: dword: pointer to data * +20 = +0x14: ?: path - zero terminated string or * +20 = +0x14: byte: 0 * +21 = +0x15: dword: pointer to string Case sensitivity depends on filesystem. If a path not begins with '/', it is considered a relative. To get or set the current folder, use the sysfunction 30. '../' in the path means a lift by one folder relatively current folder. To set the encoding, put at the start of the string a byte with next values: * 1 = cp866 * 2 = UTF-16LE * 3 = UTF-8 otherwise will be used cp866. In an absolute path you may put this byte after the '/' or put an additional '/' before it. Also, you may use the sysfunction 80. Format of an absolute path: /base/number/dir1/dir2/.../dirn/file, where base/number identifies device, on which file is located: * RD/1 = ramdisk * FD/1 = first floppy drive, FD/2 = second floppy drive * HD0/x, HD1/x, HD2/x, HD3/x = hard drives accordingly on IDE0 (Primary Master), IDE1 (Primary Slave), IDE2 (Secondary Master), IDE3 (Secondary Slave); x - partition number on the selected hard drive, starts from 1 * CD0/1, CD1/1, CD2/1, CD3/1 = same for cd * SYS = system folder (encoding inaffected key), second key may be set by sysfunction 30.3. Examples: * '/sys/example.asm',0 * '/rd/1/example.asm',0 * '/HD0/1/folder/file.txt',0 * '/hd2/2/pics/tanzania.bmp',0 * 2,'/',0,'sys','/',0,'F',0,'I',0,'L',0,'E',0,0,0 Available subfunctions: * subfunction 0 - read file * subfunction 1 - read folder * subfunction 2 - create/rewrite file * subfunction 3 - write to existing file * subfunction 4 - set file size * subfunction 5 - get attributes of file/folder * subfunction 6 - set attributes of file/folder * subfunction 7 - start application * subfunction 8 - delete file/folder * subfunction 9 - create folder For CD-drives due to hardware limitations only subfunctions 0,1,5 and 7 are available, other subfunctions return error with code 2. At the first call of subfunctions 0,1,5,7 to ATAPI devices (CD and DVD) the manual control of tray is locked due to caching drive data. Unlocking is made when subfunction 4 of function 24 is called for corresponding device. ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_READ_FILE (0), SSF_READ_FOLDER (1), SSF_CREATE_FILE (2), SSF_WRITE_FILE (3), SSF_SET_END (4), SSF_GET_INFO (5), SSF_SET_INFO (6), SSF_START_APP (7), SSF_DELETE (8), SSF_CREATE_FOLDER (9) ====================================================================== === Function 70, subfunction 0 - read file with long names support. == ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 0 = subfunction number * +4: dword: file offset (in bytes) * +8: dword: 0 (reserved for high dword of offset) * +12 = +0xC: dword: number of bytes to read * +16 = +0x10: dword: pointer to buffer for data * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx = number of bytes read Remarks: * If file was ended before last requested block was read, the function will read as many as it can, and after that return eax=6 (EOF). * The function does not allow to read folder (returns eax=10, access denied). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_READ_FILE (0) ====================================================================== == Function 70, subfunction 1 - read folder with long names support. = ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 1 = subfunction number * +4: dword: index of starting block (beginning from 0) * +8: dword: names encoding: 0 = default 1 = cp866 2 = UTF-16LE 3 = UTF-8 * +12 = +0xC: dword: number of blocks to read * +16 = +0x10: dword: pointer to buffer for data * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx = number of file information blocks, written to the buffer Structure of the buffer: * header (32 bytes) * block with information on file 1 * block with information on file 2 * ... Structure of header: * +0: dword: version of structure (current is 1) * +4: dword: number of placed blocks; is not greater than requested in the field +12 of information structure; can be less, if there are no more files in folder (the same as in ebx) * +8: dword: total number of files in folder * +12 = +0xC: 20*byte: reserved (zeroed) Structure of block of data for folder entry (BDFE): * +0: dword: attributes of file: * bit 0 (mask 1): file is read-only * bit 1 (mask 2): file is hidden * bit 2 (mask 4): file is system * bit 3 (mask 8): this is the volume label (using by subfunction 5) * bit 4 (mask 0x10): this is a folder * bit 5 (mask 0x20): file was not archived - many archivation programs have an option to archive only files with this bit set, and after archiving this bit is cleared - it can be useful for automatically creating of backup-archives as at writing this bit is usually set * +4: dword: encoding, equals to field +8 in the information structure * +8: 4*byte: time of file creation * +12 = +0xC: 4*byte: date of file creation * +16 = +0x10: 4*byte: time of last access (read or write) * +20 = +0x14: 4*byte: date of last access * +24 = +0x18: 4*byte: time of last modification * +28 = +0x1C: 4*byte: date of last modification * +32 = +0x20: qword: file size in bytes (up to 16777216 Tb) * +40 = +0x28: name, 264 bytes in cp866, otherwise - 520 bytes. Time format: * +0: byte: seconds * +1: byte: minutes * +2: byte: hours * +3: byte: reserved (0) * for example, 23.59.59 is written as (in hex) 3B 3B 17 00 Date format: * +0: byte: day * +1: byte: month * +2: word: year * for example, 25.11.1979 is written as (in hex) 19 0B BB 07 Remarks: * If BDFE contains cp866 name, the length of BDFE is 304 bytes, otherwise - 560 bytes. * Name string is zero terminated, further data contain garbage. * If files in folder were ended before requested number was read, the function will read as many as it can, and after that return eax=6 (EOF). * Any folder on the disk, except for root, contains two special entries "." and "..", identifying accordingly the folder itself and the parent folder. * The function allows also to read virtual folders "/", "/rd", "/fd", "/hd[n]", thus attributes of subfolders are set to 0x10, and times and dates are zeroed. An alternative way to get the equipment information - subfunction 11 of function 18. ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_READ_FOLDER (1) ====================================================================== ===================== Function 70, subfunction 2 ===================== ============ Create/rewrite file with long names support. ============ ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 2 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 (reserved) * +12 = +0xC: dword: number of bytes to write * +16 = +0x10: dword: pointer to data * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx = number of written bytes (possibly 0) Remarks: * If a file with given name did not exist, it is created; if it existed, it is rewritten. * If there is not enough free space on disk, the function will write as many as can and then return error code 8. * The function is not supported for CD (returns error code 2). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_CREATE_FILE (2) ====================================================================== ===================== Function 70, subfunction 3 ===================== =========== Write to existing file with long names support. ========== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 3 = subfunction number * +4: dword: file offset (in bytes) * +8: dword: high dword of offset (must be 0 for FAT) * +12 = +0xC: dword: number of bytes to write * +16 = +0x10: dword: pointer to data * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx = number of written bytes (possibly 0) Remarks: * The file must already exist, otherwise function returns eax=5. * The only result of write 0 bytes is update in the file attributes date/time of modification and access to the current date/time. * If beginning and/or ending position is greater than file size (except for the previous case), the file is expanded to needed size with zero characters. * The function is not supported for CD (returns error code 2). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_WRITE_FILE (3) ====================================================================== ============ Function 70, subfunction 4 - set end of file. =========== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 4 = subfunction number * +4: dword: low dword of new file size * +8: dword: high dword of new file size (must be 0 for FAT) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: 0 (reserved) * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed Remarks: * If new file size is less than old one, file will be truncated. If new size is greater than old one, file will be expanded, and if size difference is up to 16 MB, new space will be cleared with 0. * If there is not enough free space on disk for expansion, the function will expand to maximum possible size and then return error code 8. * The function is not supported for CD (returns error code 2). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_SET_END (4) ====================================================================== ==== Function 70, subfunction 5 - get information on file/folder. ==== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 5 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 or flags (for the root folder) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: pointer to buffer for data (40 bytes) * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed Information on file is returned in the BDFE format (block of data for folder entry), explained in the description of subfunction 1, but without filename, except the root folder. Remarks: * For the root folder returns the partition size, and if encoding byte is non-zero, the volume label. * For the device returns only the size. ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_GET_INFO (5) ====================================================================== ===== Function 70, subfunction 6 - set attributes of file/folder. ==== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 6 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 (reserved) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: pointer to buffer with attributes (32 bytes) * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed File attributes are first 32 bytes in BDFE (block of data for folder entry), explained in the description of subfunction 1 (that is, without name and size of file). Attribute file/folder/volume label (bits 3,4 in dword +0) is not changed. Byte +4 (name format) is ignored. Remarks: * The function does not support virtual folders such as /, /rd and root folders like /rd/1. * The function is not supported for CD (returns error code 2). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_SET_INFO (6) ====================================================================== =========== Function 70, subfunction 7 - start application. ========== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 7 = subfunction number * +4: dword: flags field: * bit 0: start process as debugged * other bits are reserved and must be set to 0 * +8: dword: 0 or pointer to ASCIIZ-string with parameters * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: 0 (reserved) * +20 = +0x14: path, general rules of names forming Returned value: * eax > 0 - program is loaded, eax contains PID * eax < 0 - an error has occurred, -eax contains file system error code * ebx destroyed Remarks: * Command line must be terminated by the character with the code 0 (ASCIIZ-string); function takes into account either all characters up to terminating zero inclusively or first 256 character regarding what is less. * If the process is started as debugged, it is created in the suspended state; to run use subfunction 5 of function 69. ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_START_APP (7) ====================================================================== ========== Function 70, subfunction 8 - delete file/folder. ========== ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 8 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 (reserved) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: 0 (reserved) * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed Remarks: * The function is not supported for CD (returns error code 2). * The function can delete only empty folders (attempt to delete nonempty folder results in error with code 10, "access denied"). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_DELETE (8) ====================================================================== ============= Function 70, subfunction 9 - create folder. ============ ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 9 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 (reserved) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: 0 (reserved) * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed Remarks: * The function is not supported for CD (returns error code 2). * The parent folder must already exist. * If target folder already exists, function returns success (eax=0). ---------------------- Constants for registers: ---------------------- eax - SF_FILE (70) [ebx] - SSF_CREATE_FOLDER (9) ====================================================================== ============= Function 70, subfunction 10 - rename/move. ============= ====================================================================== Parameters: * eax = 70 - function number * ebx = pointer to the information structure Format of the information structure: * +0: dword: 10 = subfunction number * +4: dword: 0 (reserved) * +8: dword: 0 (reserved) * +12 = +0xC: dword: 0 (reserved) * +16 = +0x10: dword: pointer to the new name/path string * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code * ebx destroyed Remarks: * New path forming differs from general rules: relative path relates to the target's parent folder, absolute path relates to the partition's root folder. ====================================================================== ================== Function 71 - set window caption ================== ====================================================================== Parameters: * eax = 71 - function number * ebx = 1 * ecx = pointer to zero terminated string, the string may start with an encoding byte: 1 = cp866 2 = UTF-16LE 3 = UTF-8 or: * ebx = 2 * ecx = pointer to zero terminated string * dl = string encoding Returned value: * function does not return value Remarks: * Pass NULL in ecx to remove caption. ---------------------- Constants for registers: ---------------------- eax - SF_SET_CAPTION (71) ====================================================================== =============== Function 72 - send message to a window. ============== ====================================================================== - Subfunction 1 - send message with parameter to the active window. -- Parameters: * eax = 72 - function number * ebx = 1 - subfunction number * ecx = event code: 2 or 3 * edx = parameter: key code for ecx=2, button identifier for ecx=3 Returned value: * eax = 0 - success * eax = 1 - buffer is full ---------------------- Constants for registers: ---------------------- eax - SF_SEND_MESSAGE (72) ====================================================================== ===================== Function 73 - blit bitmap ===================== ====================================================================== Parameters: * eax = 73 - function number * ebx = ROP and optional flags 31 30 29 28 6 5 4 3 0 [reserved][CR][reserved][T][B][ROP] ROP - raster operation code 0: Copy 1-15: reserved B - blit into the background surface T - transparent blit CR - blit client relative * ecx = pointer to the function parameters destination offset and clipping +0 signed dword: destination rectangle X offset from the window top-left corner +4 signed dword: destination rectangle Y offset from the window top-left corner +8 dword: destination rectangle width +12 dword: destination rectangle height source offset and clipping +16 signed dword: source rectangle X offset from the bitmap top-left corner +20 signed dword: source rectangle Y offset from the bitmap top-left corner +24 dword: source rectangle width +28 dword: source rectangle height +32: dword: bitmap data - must be 32bpp +36: dword: size of the bitmap row in bytes Returned value: * function does not return value ---------------------- Constants for registers: ---------------------- eax - SF_BLITTER (73) ====================================================================== = Function 74, Subfunction 255, Get number of active network devices. = ====================================================================== Parameters: * eax = 74 - function number * bl = 255 - subfunction number Returned value: * eax = number of active network devices ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_DEVICE_COUNT (255) ====================================================================== ======== Function 74, Subfunction 0, Get network device type. ======== ====================================================================== Parameters: * eax = 74 - function number * bl = 0 - subfunction number * bh = device number Returned value: * eax = device type number, -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_DEVICE_TYPE (0) ====================================================================== ======== Function 74, Subfunction 1, Get network device name. ======== ====================================================================== Parameters: * eax = 74 - function number * bl = 1 - subfunction number * bh = device number * ecx = pointer to 64 byte buffer Returned value: * eax = -1 on error * The network device name is written into the buffer, on success ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_DEVICE_NAME (1) ====================================================================== ========= Function 74, Subfunction 2, Reset network device. ========== ====================================================================== Parameters: * eax = 74 - function number * bl = 2 - subfunction number * bh = device number Returned value: * eax = -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_RESET_DEVICE (2) ====================================================================== ========== Function 74, Subfunction 3, Stop network device. ========== ====================================================================== Parameters: * eax = 74 - function number * bl = 3 - subfunction number * bh = device number Returned value: * eax = -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_STOP_DEVICE (3) ====================================================================== =========== Function 74, Subfunction 4, Get device pointer. ========== ====================================================================== Parameters: * eax = 74 - function number * bl = 4 - subfunction number * bh = device number Returned value: * eax = device pointer, -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_DEVICE_POINTER (4) ====================================================================== ========= Function 74, Subfunction 6, Get packet TX counter. ========= ====================================================================== Parameters: * eax = 74 - function number * bl = 6 - subfunction number * bh = device number Returned value: * eax = Number of packets sent since device start, -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_TX_PACKET_COUNT (6) ====================================================================== ========= Function 74, Subfunction 7, Get packet RX counter. ========= ====================================================================== Parameters: * eax = 74 - function number * bl = 7 - subfunction number * bh = device number Returned value: * eax = Number of packets received since device start, -1 on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_RX_PACKET_COUNT (7) ====================================================================== ========== Function 74, Subfunction 8, Get TX byte counter. ========== ====================================================================== Parameters: * eax = 74 - function number * bl = 8 - subfunction number * bh = device number Returned value: * eax = Number of bytes sent since device start (lower dword) -1 on error * ebx = Number of bytes sent since device start (higher dword) ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_TX_BYTE_COUNT (8) ====================================================================== ========== Function 74, Subfunction 9, Get RX byte counter. ========== ====================================================================== Parameters: * eax = 74 - function number * bl = 9 - subfunction number * bh = device number Returned value: * eax = Number of bytes received since device start (lower dword) -1 on error * ebx = Number of bytes received since device start (higher dword) ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_RX_BYTE_COUNT (9) ====================================================================== ========== Function 74, Subfunction 10, Get link status. ============= ====================================================================== Parameters: * eax = 74 - function number * bl = 10 - subfunction number * bh = device number Returned value: * eax = link status, -1 on error Link status: ETH_LINK_DOWN = 0b ; Link is down ETH_LINK_UNKNOWN= 1b ; There could be an active link ETH_LINK_FD = 10b ; full duplex flag ETH_LINK_10M = 100b ; 10 mbit ETH_LINK_100M = 1000b ; 100 mbit ETH_LINK_1G = 1100b ; gigabit ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_GET (74) bl - SSF_LINK_STATUS (10) ====================================================================== ============== Function 75, Subfunction 0, Open socket. ============== ====================================================================== Parameters: * eax = 75 - function number * bl = 0 - subfunction number * ecx = domain * edx = type * esi = protocol Returned value: * eax = socket number, -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_OPEN (0) ====================================================================== ============= Function 75, Subfunction 1, Close socket. ============== ====================================================================== Parameters: * eax = 75 - function number * bl = 1 - subfunction number * ecx = socket number Returned value: * eax = -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_CLOSE (1) ====================================================================== ================== Function 75, Subfunction 2, Bind. ================= ====================================================================== Parameters: * eax = 75 - function number * bl = 2 - subfunction number * ecx = socket number * edx = pointer to sockaddr structure * esi = length of sockaddr structure Format of SockAddr structure: * +0: Word: Family * +2: 14*Byte: Data Returned value: * eax = -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_BIND (2) ====================================================================== ================= Function 75, Subfunction 3, Listen. ================ ====================================================================== Parameters: * eax = 75 - function number * bl = 3 - subfunction number * ecx = socket number * edx = backlog Returned value: * eax = -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_LISTEN (3) ====================================================================== ================ Function 75, Subfunction 4, Connect. ================ ====================================================================== Parameters: * eax = 75 - function number * bl = 4 - subfunction number * ecx = socket number * edx = pointer to sockaddr structure * esi = length of sockaddr structure Format of SockAddr structure: * +0: Word: Family * +2: 14*Byte: Data Returned value: * eax = -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_CONNECT (4) ====================================================================== ================= Function 75, Subfunction 5, Accept. ================ ====================================================================== Parameters: * eax = 75 - function number * bl = 5 - subfunction number * ecx = socket number * edx = pointer to sockaddr structure * esi = length of sockaddr structure Format of SockAddr structure: * +0: Word: Family * +2: 14*Byte: Data Returned value: * eax = socket number of accepted socket, -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_ACCEPT (5) ====================================================================== ================== Function 75, Subfunction 6, Send. ================= ====================================================================== Parameters: * eax = 75 - function number * bl = 6 - subfunction number * ecx = socket number * edx = pointer to buffer * esi = length of buffer * edi = flags Returned value: * eax = number of bytes copied, -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_SEND (6) ====================================================================== ================ Function 75, Subfunction 7, Receive. ================ ====================================================================== Parameters: * eax = 75 - function number * bl = 7 - subfunction number * ecx = socket number * edx = pointer to buffer * esi = length of buffer * edi = flags Returned value: * eax = number of bytes copied, -1 on error * ebx = errorcode ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_RECEIVE (7) ====================================================================== =========== Function 75, Subfunction 8, Set socket options. ========== ====================================================================== Parameters: * eax = 75 - function number * bl = 8 - subfunction number * ecx = socket number * edx = pointer to optstruct Returned value: * eax = -1 on error * ebx = errorcode Remarks: Optstruct: dd level dd optionname dd optlength db options... ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_SET_OPTIONS (8) ====================================================================== =========== Function 75, Subfunction 9, Get socket options. ========== ====================================================================== Parameters: * eax = 75 - function number * bl = 9 - subfunction number * ecx = socket number * edx = pointer to optstruct Returned value: * eax = -1 on error * ebx = errorcode Remarks: Optstruct: dd level dd optionname dd optlength db options... ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_GET_OPTIONS (9) ====================================================================== ============ Function 75, Subfunction 10, Get socketpair. ============ ====================================================================== Parameters: * eax = 75 - function number * bl = 10 - subfunction number Returned value: * eax = socketnum1, -1 on error * ebx = socketnum2, errorcode on error ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_SOCKET (75) bl - SSF_GET_PAIR (10) ====================================================================== ============ Function 76, Network options and statistics. ============ ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = protocol number * bh = device number * bl = subfunction number ====================================================================== ==== Function 76, Protocol 0 - Ethernet, Subfunction 0, Read MAC. ==== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 0 (Ethernet) * bh = device number * bl = 0 (Read MAC) Returned value: * eax = -1 on error, otherwise lower bits of MAC * bx = upper bits of MAC ====================================================================== = Function 76, Protocol 1 - IPv4, Subfunction 0, Read # Packets sent = ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 0 (Read # packets sent) Returned value: * eax = number of packets sent (-1 on error) ====================================================================== = Function 76, Protocol 1 - IPv4, Subfunction 1, Read # Packets rcvd = ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 1 (Read # packets received) Returned value: * eax = number of packets received (-1 on error) ====================================================================== === Function 76, Protocol 1 - IPv4, Subfunction 2, Read IP address === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 2 (Read IP address) Returned value: * eax = IP address (-1 on error) ====================================================================== === Function 76, Protocol 1 - IPv4, Subfunction 3, Set IP address ==== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 3 (Set IP address) * ecx = IP address Returned value: * eax = -1 on error ====================================================================== == Function 76, Protocol 1 - IPv4, Subfunction 4, Read DNS address === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 4 (Read DNS server IP address) Returned value: * eax = DNS server IP address (-1 on error) ====================================================================== === Function 76, Protocol 1 - IPv4, Subfunction 5, Set DNS address === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 5 (Set DNS address) * ecx = DNS server IP address Returned value: * eax = -1 on error ====================================================================== == Function 76, Protocol 1 - IPv4, Subfunction 6, Read subnet mask === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 6 (Read subnet mask) Returned value: * eax = subnet mask (-1 on error) ====================================================================== === Function 76, Protocol 1 - IPv4, Subfunction 7, Set subnet mask === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 7 (Set subnet mask) * ecx = subnet mask Returned value: * eax = -1 on error ====================================================================== ===== Function 76, Protocol 1 - IPv4, Subfunction 8, Read gateway ==== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 8 (Read gateway IP address) Returned value: * eax = gateway IP address (-1 on error) ====================================================================== ===== Function 76, Protocol 1 - IPv4, Subfunction 9, Set gateway ===== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 1 (IPv4) * bh = device number * bl = 9 (Set getway address) * ecx = gateway IP address Returned value: * eax = -1 on error ====================================================================== = Function 76, Protocol 2 - ICMP, Subfunction 0, Read # Packets sent = ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 2 (ICMP) * bh = device number * bl = 0 (Read # packets sent) Returned value: * eax = number of packets sent (-1 on error) ====================================================================== = Function 76, Protocol 2 - ICMP, Subfunction 1, Read # Packets rcvd = ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 2 (ICMP) * bh = device number * bl = 1 (Read # packets received) Returned value: * eax = number of packets received (-1 on error) ====================================================================== = Function 76, Protocol 3 - UDP, Subfunction 0, Read # Packets sent == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 3 (UDP) * bh = device number * bl = 0 (Read # packets sent) Returned value: * eax = number of packets sent (-1 on error) ====================================================================== = Function 76, Protocol 3 - UDP, Subfunction 1, Read # Packets rcvd == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 3 (UDP) * bh = device number * bl = 1 (Read # packets received) Returned value: * eax = number of packets received (-1 on error) ====================================================================== = Function 76, Protocol 4 - TCP, Subfunction 0, Read # Packets sent == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 4 (TCP) * bh = device number * bl = 0 (Read # packets sent) Returned value: * eax = number of packets sent (-1 on error) ====================================================================== = Function 76, Protocol 4 - TCP, Subfunction 1, Read # Packets rcvd == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 4 (TCP) * bh = device number * bl = 1 (Read # packets received) Returned value: * eax = number of packets received (-1 on error) ====================================================================== = Function 76, Protocol 5 - ARP, Subfunction 0, Read # Packets sent == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 0 (Read # packets sent) Returned value: * eax = number of packets sent (-1 on error) ====================================================================== = Function 76, Protocol 5 - ARP, Subfunction 1, Read # Packets rcvd == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 1 (Read # packets received) Returned value: * eax = number of packets received (-1 on error) ====================================================================== == Function 76, Protocol 5 - ARP, Subfunction 2, Read # ARP entries == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 2 (Read # current entries in the ARP table) Returned value: * eax = number of entries (-1 on error) ====================================================================== ==== Function 76, Protocol 5 - ARP, Subfunction 3, Read ARP entry ==== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 3 (Read ARP entry) * ecx = ARP entry number (0 based) * edi = ptr to buffer where ARP entry will be written Returned value: * eax = -1 on error Remarks: * ARP_entry struct is defined in ARP.inc in kernel and currently looks like this: struct ARP_entry IP dd ? MAC dp ? Status dw ? TTL dw ? ends ====================================================================== ===== Function 76, Protocol 5 - ARP, Subfunction 4, Add ARP entry ==== ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 4 (Add ARP entry) * esi = ptr to buffer holding ARP entry Returned value: * eax = -1 on error Remarks: * See previous function for details on ARP entry. ====================================================================== === Function 76, Protocol 5 - ARP, Subfunction 5, Remove ARP entry === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 5 (Remove ARP entry) * ecx = ARP entry number (0 based), use -1 to clear whole ARP table. Returned value: * eax = -1 on error ====================================================================== === Function 76, Protocol 5 - ARP, Subfunction 6, Send ARP announce == ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 6 (Send ARP announce) Returned value: * eax = -1 on error ====================================================================== === Function 76, Protocol 5 - ARP, Subfunction 7, Read # conflicts === ====================================================================== Parameters: * eax = 76 - function number * high half of ebx = 5 (ARP) * bh = device number * bl = 7 (Read # IP address conflicts that have occured) Returned value: * eax = # IP address conflicts (-1 on error) ---------------------- Constants for registers: ---------------------- eax - SF_NETWORK_PROTOCOL (76) ====================================================================== ========== Function 77, Subfunction 0, Create futex object =========== ====================================================================== Parameters: * eax = 77 - function number * ebx = 0 - subfunction number * ecx = pointer to futex dword Returned value: * eax = futex handle, 0 on error Remarks: * Use subfunction 1 to destroy the futex. The kernel destroys the futexes automatically when the process terminates. ---------------------- Constants for registers: ---------------------- eax - SF_FUTEX (77) ebx - SSF_CREATE (0) ====================================================================== ========= Function 77, Subfunction 1, Destroy futex object =========== ====================================================================== Parameters: * eax = 77 - function number * ebx = 1 - subfunction number * ecx = futex handle Returned value: * eax = 0 - successfull, -1 on error Remarks: * The futex handle must have been created by subfunction 0 ---------------------- Constants for registers: ---------------------- eax - SF_FUTEX (77) ebx - SSF_DESTROY (1) ====================================================================== =============== Function 77, Subfunction 2, Futex wait =============== ====================================================================== Parameters: * eax = 77 - function number * ebx = 2 - subfunction number * ecx = futex handle * edx = control value * esi = timeout in system ticks or 0 for infinity Returned value: * eax = 0 - successfull -1 - timeout -2 - futex dword does not have the same value as edx Remarks: * This functionn tests that the value at the futex dword still contains the expected control value, and if so, then sleeps waiting for a wake operation on the futex. * The futex handle must have been created by subfunction 0 ---------------------- Constants for registers: ---------------------- eax - SF_FUTEX (77) ebx - SSF_WAIT (2) ====================================================================== =============== Function 77, Subfunction 3, Futex wake =============== ====================================================================== Parameters: * eax = 77 - function number * ebx = 3 - subfunction number * ecx = futex handle * edx = number of waiters to wake Returned value: * eax = number of waiters that were woken up Remarks: * This function wakes at most edx of the waiters that are waiting (e.g., inside futex wait) on the futex dword * The futex handle must have been created by subfunction 0 ---------------------- Constants for registers: ---------------------- eax - SF_FUTEX (77) ebx - SSF_WAKE (3) ====================================================================== === Function 80 - file system interface with parameter of encoding === ====================================================================== Parameters: * eax = 80 * ebx = pointer to the information structure Returned value: * eax = 0 - success; otherwise file system error code * some subfunctions return value in other registers too General format of the information structure: * +0: dword: subfunction number * +4: dword: offset in file or folder * +8: dword: higher part of offset or flags * +12 = +0xC: dword: size of data * +16 = +0x10: dword: pointer to data * +20 = +0x14: dword: string encoding: 1 = cp866 2 = UTF-16LE 3 = UTF-8 0 = default (supports encoding byte at the start of the string) * +24 = +0x18: dword: pointer to zero terminated string with path The rest is similar to sysfunction 70. ====================================================================== =============== Function -1 - terminate thread/process =============== ====================================================================== Parameters: * eax = -1 - function number Returned value: * function does not return neither value nor control Remarks: * If the process did not create threads obviously, it has only one thread, which termination results in process termination. * If the current thread is last in the process, its termination also results in process terminates. * This function terminates the current thread. Other thread can be killed by call to subfunction 2 of function 18. ---------------------- Constants for registers: ---------------------- eax - SF_TERMINATE_PROCESS (-1) ====================================================================== =========================== List of events =========================== ====================================================================== Next event can be retrieved by the call of one from functions 10 (to wait for event), 11 (to check without waiting), 23 (to wait during the given time). These functions return only those events, which enter into a mask set by function 40. By default it is first three, there is enough for most applications. Codes of events: * 1 = redraw event (is reset by call to function 0) * 2 = key on keyboard is pressed (acts, only when the window is active) or hotkey is pressed; is reset, when all keys from the buffer are read out by function 2 * 3 = button is pressed, defined earlier by function 8 (or close button, created implicitly by function 0; minimize button is handled by the system and sends no message; acts, only when the window is active; is reset when all buttons from the buffer are read out by function 17) * 4 = reserved (in current implementation never comes even after unmasking by function 40) * 5 = kernel finished redrawing of the desktop background * 6 = mouse event (something happened - button pressing or moving; is reset at reading) * 7 = IPC event (see function 60 - Inter Process Communication; is reset at reading) * 8 = network event (is reset at reading) * 9 = debug event (is reset at reading; see debug subsystem) * 16..31 = event with appropriate IRQ (16=IRQ0, 31=IRQ15) (is reset after reading all IRQ data) ====================================================================== =================== Error codes of the file system =================== ====================================================================== * 0 = success * 2 = function is not supported for the given file system * 3 = unknown file system * 5 = file not found * 6 = end of file, EOF * 7 = pointer lies outside of application memory * 8 = disk is full * 9 = file system error * 10 = access denied * 11 = device error * 12 = file system requires more memory Application start functions can return also following errors: * 30 = 0x1E = not enough memory * 31 = 0x1F = file is not executable * 32 = 0x20 = too many processes