2010-07-30 19:55:49 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2012-07-09 14:45:04 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;;
|
2010-07-30 19:55:49 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; Synergyc.asm - Synergy client for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
format binary as ""
|
|
|
|
|
2010-07-30 19:55:49 +02:00
|
|
|
use32
|
2012-07-09 14:45:04 +02:00
|
|
|
org 0x0
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
db 'MENUET01' ; signature
|
|
|
|
dd 1 ; header version
|
|
|
|
dd start ; entry point
|
|
|
|
dd i_end ; initialized size
|
|
|
|
dd mem+0x1000 ; required memory
|
|
|
|
dd mem+0x1000 ; stack pointer
|
|
|
|
dd 0 ; parameters
|
|
|
|
dd path ; path
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
__DEBUG__ equ 1 ; enable/disable
|
|
|
|
__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors
|
|
|
|
|
|
|
|
BUFFERSIZE equ 1024
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
include '../macros.inc'
|
|
|
|
purge mov,add,sub
|
2012-07-09 14:45:04 +02:00
|
|
|
include '../debug-fdo.inc'
|
|
|
|
include '../proc32.inc'
|
2010-07-30 19:55:49 +02:00
|
|
|
include '../dll.inc'
|
|
|
|
|
|
|
|
include '../network.inc'
|
|
|
|
|
|
|
|
start:
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cld
|
|
|
|
mov edi, path ; Calculate the length of zero-terminated string
|
|
|
|
xor al, al
|
|
|
|
mov ecx, 1024
|
|
|
|
repne scasb
|
|
|
|
dec edi
|
|
|
|
mov esi, filename ; append the path with '.ini'
|
|
|
|
movsd
|
|
|
|
movsb
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall 68, 11
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
stdcall dll.Load, @IMPORT
|
|
|
|
test eax, eax
|
|
|
|
jnz exit
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push 1
|
|
|
|
call [con_start]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push title
|
|
|
|
push 25
|
|
|
|
push 80
|
|
|
|
push 25
|
|
|
|
push 80
|
|
|
|
call [con_init]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push path
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push newline
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push newline
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0
|
|
|
|
test eax, eax
|
|
|
|
jnz error
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
invoke ini.get_int, path, str_remote, str_port, 24800
|
|
|
|
mov [sockaddr1.port], ax
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push str1
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push buffer_ptr
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push newline
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall socket, AF_INET4, SOCK_STREAM, 0
|
|
|
|
cmp eax, -1
|
|
|
|
je error
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mov [socketnum], eax
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push buffer_ptr ; hostname
|
|
|
|
call [inet_addr]
|
|
|
|
cmp eax, -1
|
|
|
|
je error
|
|
|
|
mov [sockaddr1.ip], eax
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall connect, [socketnum], sockaddr1, 18
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push str7
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall 40, 1 shl 7; + 7
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
login:
|
2012-07-09 14:45:04 +02:00
|
|
|
call wait_for_data
|
|
|
|
|
|
|
|
push buffer_ptr + 4
|
|
|
|
call [con_write_asciiz]
|
|
|
|
|
|
|
|
cmp dword [buffer_ptr], 11 shl 24
|
|
|
|
jne login
|
|
|
|
cmp dword [buffer_ptr + 4], 'Syne'
|
|
|
|
jne login
|
|
|
|
cmp word [buffer_ptr + 8], 'rg'
|
|
|
|
jne login
|
|
|
|
cmp byte [buffer_ptr + 10], 'y'
|
|
|
|
jne login
|
|
|
|
|
|
|
|
push str2
|
|
|
|
call [con_write_asciiz]
|
|
|
|
|
|
|
|
lea edi, [buffer_ptr + 11 + 4 + 4]
|
|
|
|
invoke ini.get_str, path, str_local, str_name, edi, 255, 0
|
|
|
|
xor al , al
|
|
|
|
mov ecx, 256
|
|
|
|
repne scasb
|
|
|
|
sub edi, buffer_ptr + 1 + 4
|
|
|
|
mov esi, edi
|
|
|
|
bswap edi
|
|
|
|
mov dword [buffer_ptr], edi
|
|
|
|
mov edi, esi
|
|
|
|
sub edi, 11 + 4
|
|
|
|
bswap edi
|
|
|
|
mov dword [buffer_ptr + 11 + 4], edi
|
|
|
|
add esi, 4
|
|
|
|
|
|
|
|
mcall send, [socketnum], buffer_ptr, , 0
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
mainloop:
|
2012-07-09 14:45:04 +02:00
|
|
|
call wait_for_data
|
|
|
|
mov edi, buffer_ptr
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.command:
|
2012-07-09 14:45:04 +02:00
|
|
|
push eax edi
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'QINF' ; query screen info
|
|
|
|
je .qinf
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'CALV' ; alive ?
|
|
|
|
je .calv
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'CINN' ; mouse moved into screen
|
|
|
|
je .cinn
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'DCLP' ; Clipboard event
|
|
|
|
je .dclp
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'DMMV' ; Mouse moved
|
|
|
|
je .dmmv
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'COUT' ; leave screen
|
|
|
|
je .cout
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'DMDN' ; mouse button down
|
|
|
|
je .dmdn
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'DMUP' ; mouse button released
|
|
|
|
je .dmup
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'CNOP' ; no operation
|
|
|
|
je .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp dword [edi + 4], 'CIAK' ; resolution changed?
|
|
|
|
je .ciak
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push str3
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mov byte[edi+8],0
|
|
|
|
add edi, 4
|
|
|
|
push edi
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push newline
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.next:
|
2012-07-09 14:45:04 +02:00
|
|
|
pop edi eax
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mov ecx, dword [edi]
|
|
|
|
bswap ecx
|
|
|
|
add ecx, 4
|
|
|
|
sub eax, ecx
|
|
|
|
jle mainloop
|
|
|
|
add edi, ecx
|
|
|
|
jmp .command
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
.qinf:
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall 14 ; get screen info
|
|
|
|
add eax, 0x00010001
|
|
|
|
bswap eax
|
|
|
|
mov dword [screeninfo.size], eax
|
|
|
|
mcall send, [socketnum], screeninfo, screeninfo.length, 0 ; send client name
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
.calv:
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
.cinn:
|
2012-07-09 14:45:04 +02:00
|
|
|
mov edx, [edi + 8]
|
|
|
|
bswap edx
|
|
|
|
mcall 18, 19, 4
|
|
|
|
; ignore sequence number and modify key mask for now
|
|
|
|
push str6
|
|
|
|
call [con_write_asciiz]
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.dclp:
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.dmmv:
|
2012-07-09 14:45:04 +02:00
|
|
|
mov edx, [edi + 8]
|
|
|
|
bswap edx
|
|
|
|
mcall 18, 19, 4
|
|
|
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
|
|
|
push str4
|
|
|
|
call [con_write_asciiz]
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.cout:
|
2012-07-09 14:45:04 +02:00
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.dmdn:
|
2012-07-09 14:45:04 +02:00
|
|
|
movzx eax, byte [edi + 8]
|
|
|
|
or [mousestate], eax
|
|
|
|
mcall 18, 19, 5, [mousestate]
|
|
|
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
|
|
|
push str5
|
|
|
|
call [con_write_asciiz]
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.dmup:
|
2012-07-09 14:45:04 +02:00
|
|
|
movzx eax, byte [edi + 8]
|
|
|
|
not eax
|
|
|
|
and [mousestate], eax
|
|
|
|
mcall 18, 19, 5, [mousestate]
|
|
|
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
|
|
|
push str5
|
|
|
|
call [con_write_asciiz]
|
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
.ciak:
|
2012-07-09 14:45:04 +02:00
|
|
|
jmp .next
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
error:
|
2012-07-09 14:45:04 +02:00
|
|
|
push str_err
|
|
|
|
call [con_write_asciiz]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
call [con_gets]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
push 1
|
|
|
|
call [con_exit]
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall close, [socketnum]
|
2010-07-30 19:55:49 +02:00
|
|
|
exit:
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall -1
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
wait_for_data:
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall 10 ; wait for data
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
|
|
|
cmp eax, -1
|
|
|
|
je wait_for_data
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
cmp eax, 8
|
|
|
|
jl wait_for_data
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
ret
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; data
|
2012-07-09 14:45:04 +02:00
|
|
|
title db 'Synergy client',0
|
|
|
|
str1 db 'Connecting to: ',0
|
|
|
|
str7 db 'Connected!',13,10,0
|
|
|
|
str2 db 13,10,'Handshake received',13,10,0
|
|
|
|
str3 db 'Unsupported command: ',0
|
|
|
|
newline db 13,10,0
|
|
|
|
str4 db 'mouse moved',13,10,0
|
|
|
|
str5 db 'mouse buttons changed',13,10,0
|
|
|
|
str6 db 'Enter screen',13,10,0
|
|
|
|
str_err db 'Error occured !',13,10,'Press any key to quit',0
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
screeninfo:
|
2012-07-09 14:45:04 +02:00
|
|
|
dd (screeninfo.length - 4) shl 24
|
|
|
|
db 'DINF'
|
|
|
|
dw 0 ; coordinate of leftmost pixel
|
|
|
|
dw 0 ; coordiante of topmost pixel
|
2010-07-30 19:55:49 +02:00
|
|
|
.size:
|
2012-07-09 14:45:04 +02:00
|
|
|
dw 0 ; width
|
|
|
|
dw 0 ; height
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
dw 0 ; size of warp zone
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
dw 0xb88b ; x position of the mouse on the secondary screen (no idea what it means)
|
|
|
|
dw 0xbcfb ; y position of the mouse on the secondary screen
|
2010-07-30 19:55:49 +02:00
|
|
|
.length = $ - screeninfo
|
|
|
|
|
|
|
|
calv:
|
2012-07-09 14:45:04 +02:00
|
|
|
dd (4) shl 24
|
|
|
|
db 'CALV'
|
2010-07-30 19:55:49 +02:00
|
|
|
.length = $ - calv + 8 ; also send cnop
|
|
|
|
|
|
|
|
cnop:
|
2012-07-09 14:45:04 +02:00
|
|
|
dd (4) shl 24
|
|
|
|
db 'CNOP'
|
2010-07-30 19:55:49 +02:00
|
|
|
.length = $ - cnop
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
mousestate dd 0
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
sockaddr1:
|
2012-07-09 14:45:04 +02:00
|
|
|
dw AF_INET4
|
|
|
|
.port dw 24800
|
|
|
|
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
|
|
|
|
rb 10
|
|
|
|
|
|
|
|
filename db '.ini', 0
|
|
|
|
str_local db 'local', 0
|
|
|
|
str_name db 'name', 0
|
|
|
|
str_remote db 'remote', 0
|
|
|
|
str_port db 'port', 0
|
|
|
|
str_ip db 'ip', 0
|
2010-07-30 19:55:49 +02:00
|
|
|
|
|
|
|
; import
|
|
|
|
align 16
|
|
|
|
@IMPORT:
|
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
library console, 'console.obj',\
|
|
|
|
network, 'network.obj',\
|
|
|
|
libini, 'libini.obj'
|
|
|
|
|
|
|
|
import network,\
|
|
|
|
inet_addr, 'inet_addr'
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
import console, \
|
|
|
|
con_start, 'START',\
|
|
|
|
con_init, 'con_init',\
|
|
|
|
con_write_asciiz, 'con_write_asciiz',\
|
|
|
|
con_exit, 'con_exit',\
|
|
|
|
con_gets, 'con_gets',\
|
|
|
|
con_cls, 'con_cls',\
|
|
|
|
con_getch2, 'con_getch2',\
|
|
|
|
con_set_cursor_pos, 'con_set_cursor_pos'
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
import libini,\
|
|
|
|
ini.get_str, 'ini_get_str',\
|
|
|
|
ini.get_int, 'ini_get_int'
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
include_debug_strings
|
2010-07-30 19:55:49 +02:00
|
|
|
|
2012-07-09 14:45:04 +02:00
|
|
|
align 4
|
2010-07-30 19:55:49 +02:00
|
|
|
i_end:
|
2012-07-09 14:45:04 +02:00
|
|
|
socketnum dd ?
|
|
|
|
buffer_ptr rb BUFFERSIZE
|
|
|
|
path rb 4096 ; stack
|
2010-07-30 19:55:49 +02:00
|
|
|
mem:
|