1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Copyright (C) KolibriOS team 2013-2022. All rights reserved. ;;
4 ;; Distributed under terms of the GNU General Public License ;;
6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 ;------------------------------------------------------------------------------
16 ; check availability of main list
17 cmp [clipboard_main_list], eax
18 je .exit_1 ; main list area not found
20 test ebx, ebx ; 0 - Get the number of slots in the clipboard
22 ; get the number of slots
23 mov eax, [clipboard_slots]
25 ;------------------------------------------------------------------------------
28 dec ebx ; 1 - Read the data from the clipboard
30 ; verify the existence of slot
31 cmp ecx, [clipboard_slots]
33 ; get a pointer to the data of slot
35 add ecx, [clipboard_main_list]
38 ; allocate memory for application for copy the data of slots
40 stdcall user_alloc, ecx
42 ; copying data of slots
47 ;------------------------------------------------------------------------------
50 dec ebx ; 2 - Write the data to the clipboard
53 ; check pointer on kernel address
54 stdcall is_region_userspace, edx, ecx
60 mov ebx, clipboard_write_lock
67 ; check the overflow pointer of slots
68 cmp [clipboard_slots], 1024
70 ; get memory for new slot
72 stdcall kernel_alloc, ecx
78 mov eax, [clipboard_slots]
80 add eax, [clipboard_main_list]
82 ; copy the data into the slot
86 stosd ; store size of slot
89 rep movsb ; store slot data
90 ; increase the counter of slots
96 ;------------------------------------------------------------------------------
99 dec ebx ; 3 - Delete the last slot in the clipboard
101 ; check the availability of slots
102 mov eax, [clipboard_slots]
106 mov ebx, clipboard_write_lock
113 ; decrease the counter of slots
114 mov eax, clipboard_slots
116 ; free of kernel memory allocated for the slot
119 add eax, [clipboard_main_list]
122 stdcall kernel_free, eax
128 ;------------------------------------------------------------------------------
131 dec ebx ; 4 - Emergency discharge of clipboard
134 mov ebx, clipboard_write_lock
139 ; there should be a procedure for checking the integrity of the slots
140 ; and I will do so in the future
145 ;------------------------------------------------------------------------------
158 ;------------------------------------------------------------------------------
162 clipboard_main_list dd ?
163 clipboard_write_lock dd ?
165 ;------------------------------------------------------------------------------