2013-06-07 21:26:03 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-08-03 15:32:28 +03:00
|
|
|
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;;
|
2013-06-07 21:26:03 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2015-08-03 21:07:56 +03:00
|
|
|
;; VNC client for KolibriOS ;;
|
2013-06-07 21:26:03 +04:00
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
format binary as ""
|
|
|
|
|
2013-06-07 21:26:03 +04:00
|
|
|
__DEBUG__ = 1
|
2015-08-04 11:59:09 +03:00
|
|
|
__DEBUG_LEVEL__ = 2
|
2013-06-07 21:26:03 +04:00
|
|
|
|
2015-08-14 16:30:03 +03:00
|
|
|
BITS_PER_PIXEL = 32 ; 8, 16, 24 or 32
|
2015-08-13 22:20:59 +03:00
|
|
|
SERVERADDRLEN = 4096
|
2015-08-04 19:29:37 +03:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
use32
|
|
|
|
|
|
|
|
org 0x0
|
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
db "MENUET01" ; 8 byte id
|
2013-06-07 21:26:03 +04:00
|
|
|
dd 0x01 ; header version
|
|
|
|
dd START ; start of code
|
|
|
|
dd I_END ; size of image
|
|
|
|
dd IM_END ; memory for app
|
|
|
|
dd IM_END ; esp
|
2015-08-13 22:20:59 +03:00
|
|
|
dd serveraddr, 0x0 ; I_Param , I_Path
|
2013-06-07 21:26:03 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
include "../../macros.inc"
|
|
|
|
include "../../debug-fdo.inc"
|
|
|
|
include "../../proc32.inc"
|
|
|
|
include "../../dll.inc"
|
|
|
|
include "../../struct.inc"
|
|
|
|
include "../../develop/libraries/box_lib/trunk/box_lib.mac"
|
|
|
|
include "../../network.inc"
|
|
|
|
|
2015-08-14 16:30:03 +03:00
|
|
|
struct PixelFormat
|
2015-08-03 15:32:28 +03:00
|
|
|
bpp db ?
|
|
|
|
depth db ?
|
|
|
|
big_endian db ?
|
|
|
|
true_color db ?
|
|
|
|
red_max dw ?
|
|
|
|
green_max dw ?
|
|
|
|
blue_max dw ?
|
|
|
|
red_shift db ?
|
|
|
|
green_shift db ?
|
|
|
|
blue_shift db ?
|
|
|
|
padding rb 3
|
|
|
|
ends
|
|
|
|
|
2015-08-14 16:30:03 +03:00
|
|
|
struct ServerInit
|
2015-08-03 15:32:28 +03:00
|
|
|
width dw ?
|
|
|
|
height dw ?
|
2015-08-14 16:30:03 +03:00
|
|
|
pixelformat PixelFormat
|
2015-08-03 15:32:28 +03:00
|
|
|
name_length dd ?
|
2015-08-14 16:30:03 +03:00
|
|
|
name db ?
|
2015-08-03 15:32:28 +03:00
|
|
|
ends
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
xpos = 4
|
2015-08-04 11:59:09 +03:00
|
|
|
ypos = 21
|
2015-08-03 21:07:56 +03:00
|
|
|
|
|
|
|
TIMEOUT = 5 ; timeout in seconds
|
|
|
|
|
|
|
|
RECEIVE_BUFFER_SIZE = 8*1024*1024 ; 8 Mib
|
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
STATUS_CONNECT = 0
|
2015-08-03 21:07:56 +03:00
|
|
|
STATUS_CONNECTING = 1
|
2015-08-04 11:59:09 +03:00
|
|
|
STATUS_REQ_LOGIN = 2
|
|
|
|
STATUS_LOGIN = 3
|
|
|
|
STATUS_CONNECTED = 4
|
2015-08-05 12:37:00 +03:00
|
|
|
STATUS_CLOSED = 5
|
2015-08-03 21:07:56 +03:00
|
|
|
|
|
|
|
STATUS_DISCONNECTED = 10
|
|
|
|
STATUS_DNS_ERR = 11
|
|
|
|
STATUS_SOCK_ERR = 12
|
|
|
|
STATUS_CONNECT_ERR = 13
|
|
|
|
STATUS_PROTO_ERR = 14
|
|
|
|
STATUS_SECURITY_ERR = 15
|
|
|
|
STATUS_LIB_ERR = 16
|
|
|
|
STATUS_THREAD_ERR = 17
|
2015-08-05 12:37:00 +03:00
|
|
|
STATUS_LOGIN_FAILED = 18
|
2015-08-13 22:20:59 +03:00
|
|
|
STATUS_SECURITY_ERR_C = 19
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
WORK_FRAMEBUFFER = 1 shl 0
|
|
|
|
WORK_CURSOR = 1 shl 1
|
|
|
|
WORK_GUI = 1 shl 2
|
|
|
|
|
2015-08-11 21:39:38 +03:00
|
|
|
BYTES_PER_PIXEL = (BITS_PER_PIXEL + 7) / 8
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
if BITS_PER_PIXEL = 32
|
|
|
|
BYTES_PER_CPIXEL= 3
|
|
|
|
else
|
|
|
|
BYTES_PER_CPIXEL= BYTES_PER_PIXEL
|
|
|
|
end if
|
|
|
|
|
2015-08-04 19:29:37 +03:00
|
|
|
include "keymap.inc"
|
2015-08-03 21:07:56 +03:00
|
|
|
include "gui.inc"
|
|
|
|
include "network.inc"
|
2015-08-03 15:32:28 +03:00
|
|
|
include "raw.inc"
|
2015-08-03 16:13:09 +03:00
|
|
|
include "copyrect.inc"
|
2015-08-03 21:07:56 +03:00
|
|
|
include "rre.inc"
|
2015-08-12 14:47:57 +03:00
|
|
|
include "trle.inc"
|
2015-08-12 19:01:13 +03:00
|
|
|
include "zrle.inc"
|
2015-08-20 12:30:24 +03:00
|
|
|
include "cursor.inc"
|
2015-08-05 12:37:00 +03:00
|
|
|
include "des.inc"
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
|
|
|
|
if BITS_PER_PIXEL = 8
|
|
|
|
create_lut:
|
|
|
|
mov edi, lut_8bpp ; 332 format
|
|
|
|
xor eax, eax
|
|
|
|
call green
|
|
|
|
add eax, 0x240000
|
|
|
|
call green
|
|
|
|
add eax, 0x250000
|
|
|
|
call green
|
|
|
|
add eax, 0x240000
|
|
|
|
call green
|
|
|
|
add eax, 0x250000
|
|
|
|
call green
|
|
|
|
add eax, 0x240000
|
|
|
|
call green
|
|
|
|
add eax, 0x250000
|
|
|
|
call green
|
|
|
|
add eax, 0x240000
|
|
|
|
call green
|
|
|
|
ret
|
|
|
|
|
|
|
|
green:
|
|
|
|
mov ah, 0
|
|
|
|
call blue
|
|
|
|
mov ah, 36
|
|
|
|
call blue
|
|
|
|
add ah, 37
|
|
|
|
call blue
|
|
|
|
add ah, 36
|
|
|
|
call blue
|
|
|
|
add ah, 37
|
|
|
|
call blue
|
|
|
|
add ah, 36
|
|
|
|
call blue
|
|
|
|
add ah, 37
|
|
|
|
call blue
|
|
|
|
add ah, 36
|
|
|
|
call blue
|
|
|
|
ret
|
|
|
|
|
|
|
|
blue:
|
|
|
|
mov al, 0
|
|
|
|
stosd
|
|
|
|
mov al, 85
|
|
|
|
stosd
|
|
|
|
mov al, 170
|
|
|
|
stosd
|
|
|
|
mov al, 255
|
|
|
|
stosd
|
|
|
|
ret
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
START:
|
|
|
|
|
|
|
|
mcall 68, 11 ; init heap
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
; Load libraries
|
2013-05-28 21:34:26 +04:00
|
|
|
stdcall dll.Load, @IMPORT
|
|
|
|
test eax, eax
|
2015-08-03 21:07:56 +03:00
|
|
|
jz @f
|
|
|
|
mov [status], STATUS_LIB_ERR
|
2015-08-20 12:30:24 +03:00
|
|
|
jmp draw_gui.first_time
|
2015-08-03 21:07:56 +03:00
|
|
|
@@:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
; When using 8BPP, create lookup table
|
|
|
|
if BITS_PER_PIXEL = 8
|
|
|
|
call create_lut
|
|
|
|
end if
|
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
; Check if we got a server address through parameters
|
|
|
|
cmp byte[serveraddr], 0
|
|
|
|
je @f
|
|
|
|
xor al, al
|
|
|
|
mov edi, serveraddr
|
|
|
|
mov ecx, SERVERADDRLEN
|
|
|
|
repne scasb
|
|
|
|
sub edi, serveraddr+1
|
|
|
|
mov [URLbox.size], edi
|
|
|
|
mov [URLbox.pos], edi
|
|
|
|
call open_connection
|
|
|
|
@@:
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
; Present the user with the GUI and wait for network connection
|
2015-08-24 17:29:14 +03:00
|
|
|
jmp draw_gui.first_time
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
; Create main window
|
2015-08-24 17:29:14 +03:00
|
|
|
connected:
|
2015-08-03 21:07:56 +03:00
|
|
|
mcall 71, 1, name ; reset window caption (add server name)
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
mov edx, dword[screen]
|
2013-05-28 21:34:26 +04:00
|
|
|
movzx esi, dx
|
|
|
|
shr edx, 16
|
|
|
|
add edx, 2*xpos
|
|
|
|
add esi, ypos+xpos
|
|
|
|
mcall 67, 10, 10 ; resize the window
|
|
|
|
|
2015-08-24 17:29:14 +03:00
|
|
|
mcall 40, EVM_CURSOR_FILTER + EVM_MOUSE_FILTER + EVM_MOUSE + EVM_KEY + EVM_REDRAW + EVM_BUTTON
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2015-08-04 11:59:09 +03:00
|
|
|
mcall 66, 1, 1 ; Switch keyboard to scancode mode
|
2015-08-04 19:29:37 +03:00
|
|
|
|
|
|
|
call generate_keymap
|
2015-08-04 11:59:09 +03:00
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
redraw:
|
|
|
|
mcall 12, 1
|
|
|
|
|
|
|
|
mov ebx, dword[screen]
|
|
|
|
movzx ecx, bx
|
|
|
|
shr ebx, 16
|
|
|
|
mov edx, 0x74ffffff
|
|
|
|
mov edi, name
|
|
|
|
mcall 0 ; draw window
|
|
|
|
|
|
|
|
mcall 12, 2
|
|
|
|
|
2015-08-04 11:59:09 +03:00
|
|
|
draw_framebuffer:
|
2015-08-13 22:20:59 +03:00
|
|
|
DEBUGF 1, "Drawing framebuffer\n"
|
2015-08-14 16:30:03 +03:00
|
|
|
mcall 7, framebuffer, dword[screen], 0
|
2015-08-20 12:30:24 +03:00
|
|
|
and [work], not WORK_FRAMEBUFFER
|
2015-08-04 11:59:09 +03:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mainloop:
|
2015-08-03 21:07:56 +03:00
|
|
|
cmp [status], STATUS_CONNECTED
|
|
|
|
jne draw_gui
|
2015-08-20 12:30:24 +03:00
|
|
|
test [work], WORK_FRAMEBUFFER
|
|
|
|
jnz draw_framebuffer
|
|
|
|
test [work], WORK_CURSOR
|
|
|
|
jnz update_cursor
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
mcall 23, 10 ; Check for event with 0,1s timeout
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
dec eax
|
|
|
|
jz redraw
|
|
|
|
dec eax
|
|
|
|
jz key
|
|
|
|
dec eax
|
|
|
|
jz button
|
|
|
|
sub eax, 3
|
|
|
|
jz mouse
|
|
|
|
jmp mainloop
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
key:
|
2015-08-04 19:29:37 +03:00
|
|
|
mcall 66, 3
|
2015-08-07 16:18:23 +03:00
|
|
|
mov ebx, eax ; get modifier keys
|
2015-08-04 19:29:37 +03:00
|
|
|
|
2015-08-07 16:18:23 +03:00
|
|
|
mcall 2 ; get key scancode
|
|
|
|
cmp ah, 224 ; extended keycode?
|
|
|
|
je .extended
|
2015-08-04 11:59:09 +03:00
|
|
|
|
|
|
|
xor al, al
|
|
|
|
test ah, 0x80 ; key up?
|
|
|
|
jnz @f
|
|
|
|
inc al
|
2015-08-20 19:42:04 +03:00
|
|
|
and ah, 0x7f
|
2015-08-04 11:59:09 +03:00
|
|
|
@@:
|
|
|
|
mov byte[KeyEvent.down], al
|
|
|
|
|
2015-08-07 16:18:23 +03:00
|
|
|
movzx eax, ah
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-04 19:29:37 +03:00
|
|
|
test ebx, 100000b ; alt?
|
2015-08-07 16:18:23 +03:00
|
|
|
jz .no_alt
|
|
|
|
mov ax, [keymap_alt+eax*2]
|
2015-08-04 19:29:37 +03:00
|
|
|
jmp .key
|
2015-08-07 16:18:23 +03:00
|
|
|
.no_alt:
|
|
|
|
|
2015-08-04 19:29:37 +03:00
|
|
|
test ebx, 11b ; shift?
|
2015-08-07 16:18:23 +03:00
|
|
|
jz .no_shift
|
|
|
|
mov ax, [keymap_shift+eax*2]
|
|
|
|
jmp .key
|
|
|
|
.no_shift:
|
|
|
|
|
|
|
|
test ebx, 10000000b ; numlock ?
|
|
|
|
jz .no_numlock
|
|
|
|
cmp al, 71
|
|
|
|
jb .no_numlock
|
|
|
|
cmp al, 83
|
|
|
|
ja .no_numlock
|
|
|
|
mov ah, [keymap_numlock+eax-71]
|
|
|
|
xor al, al
|
|
|
|
jmp .key
|
|
|
|
|
|
|
|
.extended: ; extended keys always use regular keymap
|
|
|
|
mcall 2
|
|
|
|
shr eax, 8
|
|
|
|
jz mainloop
|
2015-08-20 19:42:04 +03:00
|
|
|
|
|
|
|
xor ah, ah
|
|
|
|
test al, 0x80 ; key up?
|
|
|
|
jnz @f
|
|
|
|
inc ah
|
|
|
|
@@:
|
|
|
|
mov byte[KeyEvent.down], ah
|
|
|
|
and ax, 0x007f
|
2015-08-07 16:18:23 +03:00
|
|
|
.no_numlock:
|
|
|
|
mov ax, [keymap+eax*2]
|
2015-08-04 19:29:37 +03:00
|
|
|
.key:
|
2015-08-07 16:18:23 +03:00
|
|
|
test ax, ax
|
|
|
|
jz mainloop
|
2015-08-04 19:29:37 +03:00
|
|
|
mov word[KeyEvent.key+2], ax
|
|
|
|
DEBUGF 1, "Sending key: 0x%x\n", ax
|
2015-08-03 21:07:56 +03:00
|
|
|
mcall send, [socketnum], KeyEvent, 8, 0
|
2013-05-28 21:34:26 +04:00
|
|
|
jmp mainloop
|
|
|
|
|
2015-08-04 19:29:37 +03:00
|
|
|
|
2015-08-07 16:18:23 +03:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mouse:
|
2015-08-04 19:29:37 +03:00
|
|
|
; DEBUGF 1, "Sending pointer event\n"
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mcall 37, 1 ; get mouse pos
|
|
|
|
bswap eax
|
2015-08-03 21:07:56 +03:00
|
|
|
mov [PointerEvent.x], ax
|
2013-05-28 21:34:26 +04:00
|
|
|
shr eax, 16
|
2015-08-03 21:07:56 +03:00
|
|
|
mov [PointerEvent.y], ax
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mcall 37, 2 ; get mouse buttons
|
|
|
|
test al, 00000010b ; test if right button was pressed (bit 1 in kolibri)
|
|
|
|
jz @f
|
2015-08-03 15:32:28 +03:00
|
|
|
add al, 00000010b ; in RFB protocol it is bit 2, so if we add bit 2 again, we"ll get bit 3 and bit 1 will remain the same
|
2013-05-28 21:34:26 +04:00
|
|
|
@@:
|
2015-08-03 21:07:56 +03:00
|
|
|
mov [PointerEvent.mask], al
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
mcall send, [socketnum], PointerEvent, 6, 0
|
2013-05-28 21:34:26 +04:00
|
|
|
jmp mainloop
|
|
|
|
|
|
|
|
button:
|
|
|
|
mcall 17 ; get id
|
2015-08-05 12:37:00 +03:00
|
|
|
mov [status], STATUS_CLOSED
|
2015-08-04 19:29:37 +03:00
|
|
|
mcall close, [socketnum]
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall -1
|
|
|
|
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
update_cursor:
|
|
|
|
|
|
|
|
; load cursor
|
|
|
|
mov dx, word[cursor.y]
|
|
|
|
shl edx, 16
|
|
|
|
mov dx, 2
|
|
|
|
mcall 37, 4, cursor.image
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
|
|
|
|
; set cursor
|
|
|
|
mov ecx, eax
|
|
|
|
mcall 37, 5
|
|
|
|
|
|
|
|
; delete previously set cursor
|
|
|
|
mov ecx, eax
|
|
|
|
mcall 37, 6
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
and [work], not WORK_CURSOR
|
|
|
|
jmp mainloop
|
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
; DATA AREA
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
include_debug_strings
|
|
|
|
|
2015-08-07 16:18:23 +03:00
|
|
|
keymap_numlock:
|
|
|
|
db '7', '8', '9', '-'
|
|
|
|
db '4', '5', '6', '+'
|
|
|
|
db '1', '2', '3'
|
|
|
|
db '0', '.'
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
HandShake db "RFB 003.003", 10
|
|
|
|
|
|
|
|
ClientInit db 0 ; not shared
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
if BITS_PER_PIXEL = 32
|
|
|
|
|
|
|
|
SetPixelFormat db 0 ; setPixelformat
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
.bpp db 32 ; bits per pixel
|
2015-08-14 16:30:03 +03:00
|
|
|
.depth db 24 ; depth
|
2015-08-03 21:07:56 +03:00
|
|
|
.big_endian db 0 ; big-endian flag
|
|
|
|
.true_color db 1 ; true-colour flag
|
|
|
|
.red_max db 0, 255 ; red-max
|
|
|
|
.green_max db 0, 255 ; green-max
|
|
|
|
.blue_max db 0, 255 ; blue-max
|
2015-08-14 16:30:03 +03:00
|
|
|
.red_shift db 16 ; red-shift
|
2015-08-03 21:07:56 +03:00
|
|
|
.green_shift db 8 ; green-shift
|
2015-08-14 16:30:03 +03:00
|
|
|
.blue_shift db 0 ; blue-shift
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
else if BITS_PER_PIXEL = 24
|
|
|
|
|
|
|
|
SetPixelFormat db 0 ; setPixelformat
|
2015-08-04 19:29:37 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
.bpp db 24 ; bits per pixel
|
|
|
|
.depth db 24 ; depth
|
|
|
|
.big_endian db 0 ; big-endian flag
|
|
|
|
.true_color db 1 ; true-colour flag
|
|
|
|
.red_max db 0, 255 ; red-max
|
|
|
|
.green_max db 0, 255 ; green-max
|
|
|
|
.blue_max db 0, 255 ; blue-max
|
|
|
|
.red_shift db 16 ; red-shift
|
|
|
|
.green_shift db 8 ; green-shift
|
|
|
|
.blue_shift db 0 ; blue-shift
|
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
else if BITS_PER_PIXEL = 16
|
|
|
|
|
|
|
|
SetPixelFormat db 0 ; setPixelformat
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
.bpp db 16 ; bits per pixel
|
2015-08-04 19:29:37 +03:00
|
|
|
.depth db 16 ; depth
|
2015-08-03 21:07:56 +03:00
|
|
|
.big_endian db 0 ; big-endian flag
|
|
|
|
.true_color db 1 ; true-colour flag
|
|
|
|
.red_max db 0, 31 ; red-max
|
2015-08-04 19:29:37 +03:00
|
|
|
.green_max db 0, 63 ; green-max
|
2015-08-03 21:07:56 +03:00
|
|
|
.blue_max db 0, 31 ; blue-max
|
2015-08-04 19:29:37 +03:00
|
|
|
.red_shift db 11 ; red-shift
|
2015-08-03 21:07:56 +03:00
|
|
|
.green_shift db 5 ; green-shift
|
2015-08-04 19:29:37 +03:00
|
|
|
.blue_shift db 0 ; blue-shift
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
else if BITS_PER_PIXEL = 8
|
|
|
|
|
|
|
|
SetPixelFormat db 0 ; setPixelformat
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
.bpp db 8 ; bits per pixel
|
2015-08-04 19:29:37 +03:00
|
|
|
.depth db 8 ; depth
|
2015-08-03 21:07:56 +03:00
|
|
|
.big_endian db 0 ; big-endian flag
|
|
|
|
.true_color db 1 ; true-colour flag
|
2015-08-04 19:29:37 +03:00
|
|
|
.red_max db 0, 7 ; red-max
|
|
|
|
.green_max db 0, 7 ; green-max
|
2015-08-03 21:07:56 +03:00
|
|
|
.blue_max db 0, 3 ; blue-max
|
2015-08-20 12:30:24 +03:00
|
|
|
.red_shift db 5 ; red-shift
|
|
|
|
.green_shift db 2 ; green-shift
|
|
|
|
.blue_shift db 0 ; blue-shift
|
2015-08-03 21:07:56 +03:00
|
|
|
db 0, 0, 0 ; padding
|
|
|
|
|
2015-08-20 12:30:24 +03:00
|
|
|
end if
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
SetEncodings db 2 ; setEncodings
|
|
|
|
db 0 ; padding
|
2015-08-20 12:30:24 +03:00
|
|
|
db 0, 5 ; number of encodings
|
2015-08-13 22:20:59 +03:00
|
|
|
; db 0, 0, 0, 16 ; ZRLE
|
|
|
|
db 0, 0, 0, 15 ; TRLE
|
2015-08-11 21:39:38 +03:00
|
|
|
db 0, 0, 0, 2 ; RRE
|
2015-08-13 22:20:59 +03:00
|
|
|
db 0, 0, 0, 1 ; Copyrect encoding
|
2015-08-20 12:30:24 +03:00
|
|
|
db 0xff, 0xff, 0xff, 0x11 ; Cursor pseudo encoding
|
2015-08-11 21:39:38 +03:00
|
|
|
db 0, 0, 0, 0 ; raw encoding
|
2015-08-10 14:09:36 +03:00
|
|
|
.length = $ - SetEncodings
|
2015-08-03 21:07:56 +03:00
|
|
|
|
|
|
|
FramebufferUpdateRequest db 3
|
|
|
|
.inc db 0 ; incremental
|
|
|
|
.x dw 0
|
|
|
|
.y dw 0
|
|
|
|
.width dw 0
|
|
|
|
.height dw 0
|
|
|
|
|
|
|
|
KeyEvent db 4 ; keyevent
|
|
|
|
.down db 0 ; down-flag
|
|
|
|
dw 0 ; padding
|
|
|
|
.key dd 0 ; key
|
|
|
|
|
|
|
|
PointerEvent db 5 ; pointerevent
|
|
|
|
.mask db 0 ; button-mask
|
|
|
|
.x dw 0 ; x-position
|
|
|
|
.y dw 0 ; y-position
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
sockaddr1:
|
2015-08-03 21:07:56 +03:00
|
|
|
dw AF_INET4
|
|
|
|
.port dw 0x0c17 ; 5900
|
|
|
|
.ip dd 0
|
|
|
|
rb 10
|
|
|
|
|
|
|
|
beep db 0x85, 0x25, 0x85, 0x40, 0
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
status dd STATUS_CONNECT
|
2015-08-20 12:30:24 +03:00
|
|
|
work dd 0
|
2015-08-04 11:59:09 +03:00
|
|
|
mouse_dd dd 0
|
2015-08-13 22:20:59 +03:00
|
|
|
thread_id dd 0
|
2015-08-03 15:32:28 +03:00
|
|
|
|
2015-08-12 19:01:13 +03:00
|
|
|
deflate_buffer dd 0
|
|
|
|
deflate_length dd ?
|
|
|
|
deflate_str dd ?
|
|
|
|
|
2017-09-27 05:01:45 +03:00
|
|
|
URLbox edit_box 235, 70, 20, 0xffffff, 0x6f9480, 0, 0, 0x90000000, SERVERADDRLEN, serveraddr, mouse_dd, ed_focus, 0, 0
|
|
|
|
USERbox edit_box 215, 90, 10, 0xffffff, 0x6f9480, 0, 0, 0x90000000, 127, username, mouse_dd, ed_focus, 0, 0
|
|
|
|
PASSbox edit_box 215, 90, 35, 0xffffff, 0x6f9480, 0, 0, 0x10000000, 127, password, mouse_dd, ed_pass, 0, 0
|
2015-08-03 15:32:28 +03:00
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
serverstr db "server:"
|
|
|
|
userstr db "username:"
|
|
|
|
passstr db "password:"
|
2015-08-04 11:59:09 +03:00
|
|
|
connectstr db "Connect"
|
|
|
|
loginstr db "Log in"
|
2015-08-13 22:20:59 +03:00
|
|
|
cancelstr db "Cancel"
|
|
|
|
okstr db "OK"
|
|
|
|
okstr_e:
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
sz_err_disconnected db "The server has closed the connection unexpectedly.", 0
|
2015-08-03 21:07:56 +03:00
|
|
|
sz_err_dns db "Could not resolve hostname.", 0
|
|
|
|
sz_err_sock db "Could not open socket.", 0
|
|
|
|
sz_err_connect db "Could not connect to the server.", 0
|
|
|
|
sz_err_proto db "A protocol error has occured.", 0
|
2015-08-13 22:20:59 +03:00
|
|
|
sz_err_security db "An authentication problem has occured.", 0
|
2015-08-03 21:07:56 +03:00
|
|
|
sz_err_library db "Could not load needed libraries.", 0
|
|
|
|
sz_err_thread db "Could not create thread.", 0
|
2015-08-05 12:37:00 +03:00
|
|
|
sz_err_login_failed db "Login failed.", 0
|
2015-08-03 21:07:56 +03:00
|
|
|
|
|
|
|
err_msg dd sz_err_disconnected
|
|
|
|
dd sz_err_dns
|
|
|
|
dd sz_err_sock
|
|
|
|
dd sz_err_connect
|
|
|
|
dd sz_err_proto
|
|
|
|
dd sz_err_security
|
|
|
|
dd sz_err_library
|
|
|
|
dd sz_err_thread
|
2015-08-05 12:37:00 +03:00
|
|
|
dd sz_err_login_failed
|
2015-08-13 22:20:59 +03:00
|
|
|
dd sz_err_security_c
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
; import
|
|
|
|
align 4
|
|
|
|
@IMPORT:
|
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
library network, "network.obj",\
|
|
|
|
box_lib, "box_lib.obj",\
|
|
|
|
archiver, "archiver.obj"
|
|
|
|
|
|
|
|
import network,\
|
|
|
|
getaddrinfo, "getaddrinfo", \
|
|
|
|
freeaddrinfo, "freeaddrinfo", \
|
|
|
|
inet_ntoa, "inet_ntoa"
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
import box_lib,\
|
|
|
|
edit_box_draw, "edit_box",\
|
|
|
|
edit_box_key, "edit_box_key",\
|
|
|
|
edit_box_mouse, "edit_box_mouse",\
|
|
|
|
scrollbar_v_draw, "scrollbar_v_draw",\
|
|
|
|
scrollbar_v_mouse, "scrollbar_v_mouse",\
|
|
|
|
scrollbar_h_draw, "scrollbar_h_draw",\
|
|
|
|
scrollbar_h_mouse, "scrollbar_h_mouse"
|
|
|
|
|
|
|
|
import archiver,\
|
2015-08-12 19:01:13 +03:00
|
|
|
deflate_unpack2, "deflate_unpack2"
|
2015-08-03 15:32:28 +03:00
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
name db "VNC viewer "
|
|
|
|
.dash db 0, " "
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
I_END:
|
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
servername rb 64+1
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
serveraddr db 0
|
|
|
|
rb SERVERADDRLEN
|
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
socketnum dd ?
|
|
|
|
datapointer dd ?
|
2015-08-03 21:07:56 +03:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
rectangles dw ?
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
rectangle:
|
2015-08-03 21:07:56 +03:00
|
|
|
.x dd ?
|
|
|
|
.y dd ?
|
|
|
|
.width dd ?
|
|
|
|
.height dd ?
|
|
|
|
|
|
|
|
subrectangles dd ?
|
|
|
|
|
|
|
|
subrectangle:
|
|
|
|
.x dd ?
|
|
|
|
.y dd ?
|
|
|
|
.width dd ?
|
|
|
|
.height dd ?
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
screen: ; Remote screen resolution
|
|
|
|
.height dw ?
|
|
|
|
.width dw ?
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-12 14:47:57 +03:00
|
|
|
palette rd 128 ; TRLE/ZRLE
|
|
|
|
palettesize db ? ; TRLE/ZRLE
|
|
|
|
|
2015-08-04 19:29:37 +03:00
|
|
|
keymap rw 128
|
|
|
|
keymap_shift rw 128
|
|
|
|
keymap_alt rw 128
|
2015-08-04 11:59:09 +03:00
|
|
|
username rb 128
|
|
|
|
password rb 128
|
2015-08-20 12:30:24 +03:00
|
|
|
keys rd 32*2 ; DES keys for VNC authentication
|
|
|
|
|
|
|
|
cursor:
|
|
|
|
.y db ?
|
|
|
|
.x db ?
|
|
|
|
.image rd 32*32
|
|
|
|
|
|
|
|
align 4
|
|
|
|
if BITS_PER_PIXEL = 8
|
|
|
|
lut_8bpp rd 256
|
|
|
|
end if
|
2015-08-05 12:37:00 +03:00
|
|
|
|
2015-08-13 22:20:59 +03:00
|
|
|
sz_err_security_c rb 512+1
|
|
|
|
|
2015-08-03 21:07:56 +03:00
|
|
|
receive_buffer rb RECEIVE_BUFFER_SIZE
|
2015-08-14 16:30:03 +03:00
|
|
|
framebuffer rb 1280*1024*3 ; framebuffer
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2015-08-03 15:32:28 +03:00
|
|
|
rb 0x1000
|
2013-05-28 21:34:26 +04:00
|
|
|
thread_stack:
|
2015-08-03 15:32:28 +03:00
|
|
|
rb 0x1000
|
2013-05-28 21:34:26 +04:00
|
|
|
IM_END:
|
|
|
|
|
|
|
|
|