/programs/develop/libraries/network/network.asm |
---|
28,8 → 28,8 |
mov [mem.realloc], ecx |
mov [dll.load], edx |
mov [DNSrequestID], 1 |
stdcall edx, @IMPORT |
ret 4 |
xor eax, eax |
ret |
;;===========================================================================;; |
;; in_addr_t __stdcall inet_addr(__in const char* hostname); ;; |
257,7 → 257,7 |
ret |
struct __gai_reqdata |
socket dd ? |
socketnum dd ? |
; external code should not look on rest of this structure, |
; it is internal for getaddrinfo_start/process/abort |
reqid dw ? ; DNS request ID |
279,7 → 279,7 |
;;---------------------------------------------------------------------------;; |
;> first parameter (optional) = host name ;; |
;> second parameter (optional) = service name (decimal number for now) ;; |
;> third parameter (optional) = hints for socket type ;; |
;> third parameter (optional) = hints for socketnum type ;; |
;> fourth parameter = pointer to result (head of L1-list) ;; |
;;---------------------------------------------------------------------------;; |
;< eax = 0 on success / one of EAI_ codes on error ;; |
425,14 → 425,14 |
jecxz @f |
cmp [ecx+addrinfo.ai_family], edi |
jz @f |
cmp [ecx+addrinfo.ai_family], PF_INET |
cmp [ecx+addrinfo.ai_family], AF_INET4 |
jnz .ret |
@@: |
; 1e. Valid combinations for ai_socktype/ai_protocol: 0/0 for any or |
; SOCK_STREAM/IPPROTO_TCP, SOCK_DGRAM/IPPROTO_UDP |
; (raw sockets are not yet supported by the kernel) |
; (raw socketnums are not yet supported by the kernel) |
xor edx, edx ; assume 0=any if no hints |
jecxz .socket_type_ok |
jecxz .socketnum_type_ok |
mov edx, [ecx+addrinfo.ai_socktype] |
mov esi, [ecx+addrinfo.ai_protocol] |
; 1f. Test for ai_socktype=0 and ai_protocol=0. |
439,16 → 439,16 |
test edx, edx |
jnz .check_socktype |
test esi, esi |
jz .socket_type_ok |
jz .socketnum_type_ok |
; 1g. ai_socktype=0, ai_protocol is nonzero. |
push EAI_SERVICE |
pop eax |
inc edx ; edx = SOCK_STREAM |
cmp esi, IPPROTO_TCP |
jz .socket_type_ok |
jz .socketnum_type_ok |
inc edx ; edx = SOCK_DGRAM |
cmp esi, IPPROTO_UDP |
jz .socket_type_ok |
jz .socketnum_type_ok |
.ret: |
; Restore saved registers, destroy stack frame and return. |
mov esp, ebp |
464,16 → 464,16 |
cmp edx, SOCK_DGRAM |
jnz .ret |
test esi, esi |
jz .socket_type_ok |
jz .socketnum_type_ok |
cmp esi, IPPROTO_UDP |
jz .socket_type_ok |
jz .socketnum_type_ok |
jmp .ret |
.check_tcp: |
test esi, esi |
jz .socket_type_ok |
jz .socketnum_type_ok |
cmp esi, IPPROTO_TCP |
jnz .ret |
.socket_type_ok: |
.socketnum_type_ok: |
mov [ebx+__gai_reqdata.socktype], dl |
; 2. Resolve service. |
; 2a. If no name is given, remember value -1. |
513,7 → 513,7 |
; 3. Process host name. |
mov esi, [.hostname] |
; 3a. If hostname is not given, |
; use localhost for active sockets and INADDR_ANY for passive sockets. |
; use localhost for active socketnums and INADDR_ANY for passive socketnums. |
mov eax, 0x0100007F ; 127.0.0.1 in network byte order |
test byte [ebx+__gai_reqdata.flags], AI_PASSIVE |
jz @f |
675,25 → 675,43 |
mov eax, 0x01000100 |
stosd |
; 7. Get DNS server address. |
mcall 52, 13 |
xchg esi, eax ; put server address to esi |
; 8. Open UDP socket to DNS server, port 53. |
mcall 53, 0, 0, 53 |
mcall 76, API_IPv4 + 4 ; protocol IP=0, device number=0, function=get DNS address |
cmp eax, -1 |
je .ret.dnserr |
mov esi, eax ; put server address to esi |
; 8. Open UDP socketnum to DNS server, port 53. |
; 8a. Create new socketnum. |
mcall 75, 0, AF_INET4, SOCK_DGRAM |
cmp eax, -1 ; error? |
jz .ret.dnserr |
xchg ecx, eax ; put socket handle to ecx |
mov ecx, eax ; put socketnum handle to ecx |
; 8b. Create sockaddr structure on the stack. |
push 0 |
push 0 ; sin_zero |
push esi ; sin_addr |
push AF_INET4 + (53 shl 24) |
; sin_family and sin_port in network byte order |
; 8c. Connect. |
mcall 75, 4, , esp, sizeof.sockaddr_in |
; 8d. Restore the stack, undo 8b. |
add esp, esi |
; 8e. Check result. |
cmp eax, -1 |
jz .ret.close |
; 9. Send DNS request packet. |
sub edi, esp ; get packet length |
mcall 53, 4, , edi, esp |
mov esi, edi |
xor edi, edi |
mcall 75, 6, , esp |
cmp eax, -1 |
jz .ret.close |
mov eax, [.reqdata] |
mov [eax+__gai_reqdata.socket], ecx |
mov [eax+__gai_reqdata.socketnum], ecx |
push -1 |
pop eax ; return status: more processing required |
jmp .ret.dns |
.ret.close: |
mcall 53, 1 |
mcall 75, 1 |
.ret.dnserr: |
push EAI_AGAIN |
pop eax |
741,9 → 759,11 |
push ebx esi edi |
mov edi, [.reqdata] |
; 2. Read UDP datagram. |
mov ecx, [edi+__gai_reqdata.socket] |
mcall 53, 11, , , 512 |
; 3. Ignore events for other sockets (return if no data read) |
mov ecx, [edi+__gai_reqdata.socketnum] |
push edi |
mcall 75, 7, , , 512, 0 |
pop edi |
; 3. Ignore events for other socketnums (return if no data read) |
test eax, eax |
jz .ret.more_processing_required |
; 4. Sanity check: discard too short packets. |
898,11 → 918,11 |
@@: |
pop eax |
.ret.close: |
; 15. Close socket. |
; 15. Close socketnum. |
push eax |
mov ecx, [.reqdata] |
mov ecx, [ecx+__gai_reqdata.socket] |
mcall 53, 1 |
mov ecx, [ecx+__gai_reqdata.socketnum] |
mcall 75, 1 |
pop eax |
; 16. Restore used registers, destroy stack frame and return. |
.ret: |
1150,13 → 1170,12 |
; 4. Fill struct addrinfo. |
mov eax, [ebx+__gai_reqdata.flags] |
mov [edi+addrinfo.ai_flags], eax |
mov byte [edi+addrinfo.ai_family], PF_INET |
mov byte [edi+addrinfo.ai_family], AF_INET4 |
mov byte [edi+addrinfo.ai_addrlen], sizeof.sockaddr_in |
lea ecx, [edi+sizeof.addrinfo] |
mov [edi+addrinfo.ai_addr], ecx |
; 5. Fill struct sockaddr_in. |
mov byte [ecx+sockaddr_in.sin_len], sizeof.sockaddr_in |
mov byte [ecx+sockaddr_in.sin_family], PF_INET |
mov byte [ecx+sockaddr_in.sin_family], AF_INET4 |
pop eax |
mov [ecx+sockaddr_in.sin_addr], eax |
; 6. Append new item to the list. |
1170,7 → 1189,7 |
ret |
.set_socktype: |
; Set ai_socktype and ai_protocol fields by given socket type. |
; Set ai_socktype and ai_protocol fields by given socketnum type. |
mov byte [edi+addrinfo.ai_socktype], cl |
dec cl |
jnz .set_udp |
1185,7 → 1204,7 |
; Just copy port from input __gai_reqdata to output addrinfo. |
push edx |
mov edx, [ebx+__gai_reqdata.service] |
xchg dl, dh ; convert to network byte order |
xchg dl, dh ; convert to network byte order ;;;;; CHECKME |
mov [edi+sizeof.addrinfo+sockaddr_in.sin_port], dx |
pop edx |
ret |
1200,10 → 1219,10 |
;;===========================================================================;; |
; 0. Save used registers for __stdcall. |
push ebx |
; 1. Allocated resources: only socket, so close it and return. |
; 1. Allocated resources: only socketnum, so close it and return. |
mov eax, [esp+8] |
mov ecx, [eax+__gai_reqdata.socket] |
mcall 53, 1 |
mov ecx, [eax+__gai_reqdata.socketnum] |
mcall 75, 1 |
; 2. Restore used registers and return. |
pop ebx |
ret 4 |
1264,16 → 1283,6 |
getaddrinfo_abort , 'getaddrinfo_abort' , \ |
freeaddrinfo , 'freeaddrinfo' |
; import from libini |
align 4 |
@IMPORT: |
library libini, 'libini.obj' |
import libini, \ |
ini.get_str, 'ini_get_str', \ |
ini.get_int, 'ini_get_int' |
section '.data' data readable writable align 16 |
; uninitialized data |
mem.alloc dd ? |
/programs/develop/libraries/network/network.inc |
---|
1,22 → 1,27 |
; Socket types |
SOCK_STREAM = 1 |
SOCK_DGRAM = 2 |
SOCK_RAW = 3 ; not supported by the kernel |
SOCK_RAW = 3 |
; Socket options |
SO_NONBLOCK = 1 shl 31 |
; IP protocols |
IPPROTO_IP = 0 |
IPPROTO_ICMP = 1 ; not supported by the kernel |
IPPROTO_ICMP = 1 |
IPPROTO_TCP = 6 |
IPPROTO_UDP = 17 |
; Address families |
AF_UNSPEC = 0 |
AF_INET = 2 ; IPv4 |
;AF_INET6 = 28 ; IPv6 (not supported) |
AF_LOCAL = 1 |
AF_INET4 = 2 ; IPv4 |
AF_INET6 = 28 ; IPv6 (not supported yet) |
PF_UNSPEC = AF_UNSPEC |
PF_INET = AF_INET |
;PF_INET6 = AF_INET6 |
PF_LOCAL = AF_LOCAL |
PF_INET4 = AF_INET4 |
PF_INET6 = AF_INET6 |
; Flags for addrinfo |
AI_PASSIVE = 1 |
28,9 → 33,17 |
; internal definition |
AI_SUPPORTED = 0x40F |
; for system function 76 |
API_ETH = 0 shl 16 |
API_IPv4 = 1 shl 16 |
API_ICMP = 2 shl 16 |
API_UDP = 3 shl 16 |
API_TCP = 4 shl 16 |
API_ARP = 5 shl 16 |
API_PPPOE = 6 shl 16 |
struct sockaddr_in |
sin_len db ? ; uint8_t |
sin_family db ? ; sa_family_t |
sin_family dw ? ; sa_family_t |
sin_port dw ? ; in_port_t |
sin_addr dd ? ; struct in_addr |
sin_zero rb 8 ; zero |
59,3 → 72,23 |
EAI_BADHINTS = 12 |
EAI_PROTOCOL = 13 |
EAI_OVERFLOW = 14 |
socket fix 75, 0 |
close fix 75, 1 |
bind fix 75, 2 |
listen fix 75, 3 |
connect fix 75, 4 |
accept fix 75, 5 |
send fix 75, 6 |
recv fix 75, 7 |
setsockopt fix 75, 8 |
getsockopt fix 75, 9 |
socketpair fix 75, 10 |
struct ARP_entry |
IP dd ? |
MAC dp ? |
status dw ? |
TTL dw ? |
ends |
/programs/network/smtps/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/smtps/trunk/smtps.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/smtps/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/remote/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/remote/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/remote/trunk/remote.asm |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/stackcfg/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/stackcfg/trunk/readme.txt |
---|
File deleted |
\ No newline at end of file |
/programs/network/stackcfg/trunk/stackcfg.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/stackcfg/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ethstat/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ethstat/trunk/ethstat.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ethstat/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/arpstat/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/arpstat/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/arpstat/trunk/arpstat.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/browser/browser.asm |
---|
File deleted |
/programs/network/browser/build.bat |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/network/browser/build.sh |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/network/rccc/trunk/rccc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/rccc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/rccc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/rccs/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/rccs/trunk/rccs.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/rccs/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/mp3s/trunk/mp3s.asm |
---|
File deleted |
/programs/network/mp3s/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/mp3s/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/terminal/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/terminal/trunk/terminal.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/terminal/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ym/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ym/trunk/ym.asm |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ym/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/chess/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/chess/trunk/chess.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/network/chess/trunk/chess.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/chess/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/popc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/popc/trunk/popc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/popc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/local/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/local/trunk/local.asm |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/local/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/VNCclient/ETH.INC |
---|
File deleted |
/programs/network/VNCclient/thread.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/VNCclient/copyrect.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/VNCclient/fdo.inc |
---|
File deleted |
/programs/network/VNCclient/raw.inc |
---|
File deleted |
/programs/network/VNCclient/VNCclient.asm |
---|
File deleted |
/programs/network/VNCclient/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/VNCclient/logon.inc |
---|
File deleted |
/programs/network/nntpc/trunk/nntpc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/nntpc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/nntpc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/tftpa/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/tftpa/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/tftpa/trunk/tftpa.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ppp/trunk/ppp.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ppp/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ppp/trunk/chat.inc |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ppp/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/downloader/trunk/downloader.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/downloader/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/downloader/trunk/build.sh |
---|
File deleted |
/programs/network/https/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/https/trunk/https.asm |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/https/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/dhcp/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/dhcp/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/dhcp/trunk/dhcp.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/airc/trunk/fdo.inc |
---|
File deleted |
/programs/network/airc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/airc/trunk/eth.inc |
---|
File deleted |
/programs/network/airc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/airc/trunk/airc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/ipc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ipc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ipc/trunk/ipc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/icq/trunk/macros.inc |
---|
File deleted |
/programs/network/icq/trunk/struct.inc |
---|
File deleted |
/programs/network/icq/trunk/parser_data.inc |
---|
File deleted |
/programs/network/icq/trunk/editbox.mac |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/dos2win.inc |
---|
File deleted |
/programs/network/icq/trunk/st_red.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/network/icq/trunk/STDCALL.INC |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/ssi_data.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/comp_data.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/ki.cfg |
---|
File deleted |
/programs/network/icq/trunk/parser.inc |
---|
File deleted |
/programs/network/icq/trunk/ssi.inc |
---|
File deleted |
/programs/network/icq/trunk/editbox.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/comp.inc |
---|
File deleted |
/programs/network/icq/trunk/cmdipc.inc |
---|
File deleted |
/programs/network/icq/trunk/build_ru.bat |
---|
File deleted |
/programs/network/icq/trunk/README.TXT |
---|
File deleted |
/programs/network/icq/trunk/dialogs1.inc |
---|
File deleted |
/programs/network/icq/trunk/config.inc |
---|
File deleted |
/programs/network/icq/trunk/proc32.inc |
---|
File deleted |
/programs/network/icq/trunk/ki.asm |
---|
File deleted |
/programs/network/icq/trunk/icons.inc |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/SSI_INFO.txt |
---|
File deleted |
\ No newline at end of file |
/programs/network/icq/trunk/lang.inc |
---|
File deleted |
/programs/network/icq/trunk/2000.inc |
---|
File deleted |
/programs/network/icq/trunk |
---|
Property changes: |
Deleted: tsvn:logminsize |
-5 |
\ No newline at end of property |
/programs/network/icq |
---|
Property changes: |
Deleted: tsvn:logminsize |
-5 |
\ No newline at end of property |
/programs/network/dnsr/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/dnsr/trunk/dnsr.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/dnsr/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/ftps/trunk/build.bat |
---|
File deleted |
/programs/network/ftps/trunk/FTPS.ASM |
---|
File deleted |
/programs/network/netsendc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/netsendc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/netsendc/trunk/netsendc.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/netsends/trunk/netsends.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/netsends/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/netsends/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/arpcfg/arpcfg.asm |
---|
0,0 → 1,156 |
; |
; ARPmanager for KolibriOS |
; |
; hidnplayr@gmail.com |
; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd (I_END+0x100) ; memory for app |
dd (I_END+0x100) ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include '../macros.inc' |
purge mov, add, sub |
include '../struct.inc' |
include '../network.inc' |
START: |
redraw: |
mcall 12, 1 |
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, , str_name |
mcall 4, 25 shl 16 + 31, 0x80000000, str_legend |
mcall 12, 2 |
draw_stats: |
mov edx, 50 shl 16 + 50 |
mov [last], 0 |
.loop: |
mcall 76, API_ARP + 3, [last],,, arp_buf |
cmp eax, -1 |
je mainloop |
mcall 4, edx, 0x80000000, str_entry |
mov edx, ebx |
mov eax, 47 |
mov ebx, 0x00030000 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
xor ecx, ecx |
mov cl, byte[arp_buf.IP+0] |
mcall |
mov cl, byte[arp_buf.IP+1] |
add edx, 24 shl 16 |
mcall |
mov cl, byte[arp_buf.IP+2] |
add edx, 24 shl 16 |
mcall |
mov cl, byte[arp_buf.IP+3] |
add edx, 24 shl 16 |
mcall |
mov ebx, 0x00020100 |
mov cl, byte[arp_buf.MAC+0] |
add edx, 36 shl 16 |
mcall |
mov cl, byte[arp_buf.MAC+1] |
add edx, 18 shl 16 |
mcall |
mov cl, byte[arp_buf.MAC+2] |
add edx, 18 shl 16 |
mcall |
mov cl, byte[arp_buf.MAC+3] |
add edx, 18 shl 16 |
mcall |
mov cl, byte[arp_buf.MAC+4] |
add edx, 18 shl 16 |
mcall |
mov cl, byte[arp_buf.MAC+5] |
add edx, 18 shl 16 |
mcall |
mov ebx, 0x00040000 |
mov cx, [arp_buf.status] |
add edx, 30 shl 16 |
mcall |
mov cx, [arp_buf.TTL] |
add edx, 60 shl 16 |
mcall |
add dx, 20 |
rol edx, 16 |
mov dx, 50 |
rol edx, 16 |
inc [last] |
jmp .loop |
mainloop: |
mcall 23,50 ; wait for event with timeout (0,5 s) |
cmp eax, 1 |
je redraw |
cmp eax, 2 |
je key |
cmp eax, 3 |
je button |
jmp draw_stats |
key: |
mcall 2 |
jmp mainloop |
button: ; button |
mcall 17 ; get id |
cmp ah, 1 |
je exit |
jmp redraw |
exit: |
mcall -1 |
; DATA AREA |
str_name db 'ARP manager', 0 |
str_legend db '# IP-address MAC-address Status TTL', 0 |
str_entry db ' . . . - - - - - s', 0 |
IM_END: |
last dd ? |
arp_buf ARP_entry |
I_END: |
/programs/network/arpcfg |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/config.inc |
---|
0,0 → 1,0 |
__CPU_type fix p5 |
/programs/network/debug-fdo.inc |
---|
0,0 → 1,422 |
; |
; Formatted Debug Output (FDO) |
; Copyright (c) 2005-2006, mike.dld |
; Created: 2005-01-29, Changed: 2006-11-10 |
; |
; For questions and bug reports, mail to mike.dld@gmail.com |
; |
; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
; |
; to be defined: |
; __DEBUG__ equ 1 |
; __DEBUG_LEVEL__ equ 5 |
macro debug_func name { |
if used name |
name@of@func equ name |
} |
macro debug_beginf { |
align 4 |
name@of@func: |
} |
debug_endf fix end if |
macro DEBUGS _sign,[_str] { |
common |
local tp |
tp equ 0 |
match _arg:_num,_str \{ |
DEBUGS_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _str \{ |
DEBUGS_N _sign,,_arg |
\} |
} |
macro DEBUGS_N _sign,_num,[_str] { |
common |
pushf |
pushad |
local ..str,..label,is_str |
is_str = 0 |
forward |
if _str eqtype '' |
is_str = 1 |
end if |
common |
if is_str = 1 |
jmp ..label |
..str db _str,0 |
..label: |
add esp,4*8+4 |
mov edx,..str |
sub esp,4*8+4 |
else |
mov edx,_str |
end if |
if ~_num eq |
if _num eqtype eax |
if _num in <eax,ebx,ecx,edx,edi,ebp,esp> |
mov esi,_num |
else if ~_num eq esi |
movzx esi,_num |
end if |
else if _num eqtype 0 |
mov esi,_num |
else |
local tp |
tp equ 0 |
match [_arg],_num \{ |
mov esi,dword[_arg] |
tp equ 1 |
\} |
match =0 =dword[_arg],tp _num \{ |
mov esi,dword[_arg] |
tp equ 1 |
\} |
match =0 =word[_arg],tp _num \{ |
movzx esi,word[_arg] |
tp equ 1 |
\} |
match =0 =byte[_arg],tp _num \{ |
movzx esi,byte[_arg] |
tp equ 1 |
\} |
match =0,tp \{ |
'Error: specified string width is incorrect' |
\} |
end if |
else |
mov esi,0x7FFFFFFF |
end if |
call fdo_debug_outstr |
popad |
popf |
} |
macro DEBUGD _sign,_dec { |
local tp |
tp equ 0 |
match _arg:_num,_dec \{ |
DEBUGD_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _dec \{ |
DEBUGD_N _sign,,_arg |
\} |
} |
macro DEBUGD_N _sign,_num,_dec { |
pushf |
pushad |
if (~_num eq) |
if (_dec eqtype eax | _dec eqtype 0) |
'Error: precision allowed only for in-memory variables' |
end if |
if (~_num in <1,2,4>) |
if _sign |
'Error: 1, 2 and 4 are only allowed for precision in %d' |
else |
'Error: 1, 2 and 4 are only allowed for precision in %u' |
end if |
end if |
end if |
if _dec eqtype eax |
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> |
mov eax,_dec |
else if ~_dec eq eax |
if _sign = 1 |
movsx eax,_dec |
else |
movzx eax,_dec |
end if |
end if |
else if _dec eqtype 0 |
mov eax,_dec |
else |
add esp,4*8+4 |
if _num eq |
mov eax,dword _dec |
else if _num = 1 |
if _sign = 1 |
movsx eax,byte _dec |
else |
movzx eax,byte _dec |
end if |
else if _num = 2 |
if _sign = 1 |
movsx eax,word _dec |
else |
movzx eax,word _dec |
end if |
else |
mov eax,dword _dec |
end if |
sub esp,4*8+4 |
end if |
mov cl,_sign |
call fdo_debug_outdec |
popad |
popf |
} |
macro DEBUGH _sign,_hex { |
local tp |
tp equ 0 |
match _arg:_num,_hex \{ |
DEBUGH_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _hex \{ |
DEBUGH_N _sign,,_arg |
\} |
} |
macro DEBUGH_N _sign,_num,_hex { |
pushf |
pushad |
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
'Error: 1..8 are only allowed for precision in %x' |
end if |
if _hex eqtype eax |
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
if ~_hex eq eax |
mov eax,_hex |
end if |
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> |
if ~_hex eq ax |
movzx eax,_hex |
end if |
shl eax,16 |
if (_num eq) |
mov edx,4 |
end if |
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> |
if ~_hex eq al |
movzx eax,_hex |
end if |
shl eax,24 |
if (_num eq) |
mov edx,2 |
end if |
end if |
else if _hex eqtype 0 |
mov eax,_hex |
else |
add esp,4*8+4 |
mov eax,dword _hex |
sub esp,4*8+4 |
end if |
if ~_num eq |
mov edx,_num |
else |
mov edx,8 |
end if |
call fdo_debug_outhex |
popad |
popf |
} |
;----------------------------------------------------------------------------- |
debug_func fdo_debug_outchar |
debug_beginf |
pushad |
mov cl,al |
mov ebx,1 |
mov eax,63 |
mcall |
popad |
ret |
debug_endf |
debug_func fdo_debug_outstr |
debug_beginf |
mov eax,63 |
mov ebx,1 |
.l1: dec esi |
js .l2 |
mov cl,[edx] |
or cl,cl |
jz .l2 |
mcall |
inc edx |
jmp .l1 |
.l2: ret |
debug_endf |
debug_func fdo_debug_outdec |
debug_beginf |
or cl,cl |
jz @f |
or eax,eax |
jns @f |
neg eax |
push eax |
mov al,'-' |
call fdo_debug_outchar |
pop eax |
@@: push 10 |
pop ecx |
push -'0' |
.l1: xor edx,edx |
div ecx |
push edx |
test eax,eax |
jnz .l1 |
.l2: pop eax |
add al,'0' |
jz .l3 |
call fdo_debug_outchar |
jmp .l2 |
.l3: ret |
debug_endf |
debug_func fdo_debug_outhex |
__fdo_hexdigits db '0123456789ABCDEF' |
debug_beginf |
mov cl,dl |
neg cl |
add cl,8 |
shl cl,2 |
rol eax,cl |
.l1: rol eax,4 |
push eax |
and eax,0x0000000F |
mov al,[__fdo_hexdigits+eax] |
call fdo_debug_outchar |
pop eax |
dec edx |
jnz .l1 |
ret |
debug_endf |
;----------------------------------------------------------------------------- |
macro DEBUGF _level,_format,[_arg] { |
common |
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
_debug_str_ equ __debug_str_ # a1 |
a1 = 0 |
c2 = 0 |
c3 = 0 |
f2 = 0 |
repeat ..lbl-..f1 |
virtual at 0 |
db _format,0,0 |
load c1 word from %-1 |
end virtual |
if c1 = '%s' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER S,a1,0,_arg |
else if c1 = '%x' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER H,a1,0,_arg |
else if c1 = '%d' | c1 = '%u' |
local c4 |
if c1 = '%d' |
c4 = 1 |
else |
c4 = 0 |
end if |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER D,a1,c4,_arg |
else if c1 = '\n' |
c3 = c3 + 1 |
end if |
end repeat |
virtual at 0 |
db _format,0,0 |
load c1 from f2-c2 |
end virtual |
if (c1<>0)&(f2<>..lbl-..f1-1) |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
virtual at 0 |
..f1 db _format,0 |
..lbl: |
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
end virtual |
end if |
} |
macro __include_debug_strings dummy,[_id,_fmt,_len] { |
common |
local c1,a1,a2 |
forward |
if defined _len & ~_len eq |
_id: |
a1 = 0 |
a2 = 0 |
repeat _len |
virtual at 0 |
db _fmt,0,0 |
load c1 word from %+a2-1 |
end virtual |
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
db 0 |
a2 = a2 + 1 |
else if (c1='\n') |
dw $0A0D |
a1 = a1 + 1 |
a2 = a2 + 1 |
else |
db c1 and 0x0FF |
end if |
end repeat |
db 0 |
end if |
} |
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
common |
local num |
num = 0 |
forward |
if num = _num |
DEBUG#_letter _sign,_arg |
end if |
num = num+1 |
common |
_num = _num+1 |
} |
macro include_debug_strings { |
if __DEBUG__ = 1 |
match dbg_str,__debug_strings \{ |
__include_debug_strings dbg_str |
\} |
end if |
} |
/programs/network/dll.inc |
---|
0,0 → 1,160 |
;----------------------------------------------------------------------------- |
proc mem.Alloc size ;///////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
push ebx ecx |
mov eax,[size] |
lea ecx,[eax+4+4095] |
and ecx, not 4095 |
mcall 68,12 |
test eax, eax |
jz @f |
add ecx,-4 |
mov [eax],ecx |
add eax,4 |
@@: |
pop ecx ebx |
ret |
endp |
;----------------------------------------------------------------------------- |
proc mem.ReAlloc mptr,size;/////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
push ebx ecx esi edi eax |
mov eax,[mptr] |
mov ebx,[size] |
or eax,eax |
jz @f |
lea ecx,[ebx+4+4095] |
and ecx,not 4095 |
add ecx,-4 |
cmp ecx,[eax-4] |
je .exit |
@@: mov eax,ebx |
call mem.Alloc |
xchg eax,[esp] |
or eax,eax |
jz .exit |
mov esi,eax |
xchg eax,[esp] |
mov edi,eax |
mov ecx,[esi-4] |
cmp ecx,[edi-4] |
jbe @f |
mov ecx,[edi-4] |
@@: add ecx,3 |
shr ecx,2 |
cld |
rep movsd |
xchg eax,[esp] |
call mem.Free |
.exit: |
pop eax edi esi ecx ebx |
ret |
endp |
;----------------------------------------------------------------------------- |
proc mem.Free mptr ;////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
mov eax,[mptr] |
or eax,eax |
jz @f |
push ebx ecx |
lea ecx,[eax-4] |
mcall 68,13 |
pop ecx ebx |
@@: ret |
endp |
proc dll.Load, import_table:dword |
mov esi,[import_table] |
.next_lib: mov edx,[esi] |
or edx,edx |
jz .exit |
push esi |
mov esi,[esi+4] |
mov edi,s_libdir.fname |
@@: lodsb |
stosb |
or al,al |
jnz @b |
mcall 68,19,s_libdir |
or eax,eax |
jz .fail |
stdcall dll.Link,eax,edx |
stdcall dll.Init,[eax+4] |
pop esi |
add esi,8 |
jmp .next_lib |
.exit: xor eax,eax |
ret |
.fail: add esp,4 |
xor eax,eax |
inc eax |
ret |
endp |
proc dll.Link, exp:dword,imp:dword |
push eax |
mov esi,[imp] |
test esi,esi |
jz .done |
.next: lodsd |
test eax,eax |
jz .done |
stdcall dll.GetProcAddress,[exp],eax |
or eax,eax |
jz @f |
mov [esi-4],eax |
jmp .next |
@@: mov dword[esp],0 |
.done: pop eax |
ret |
endp |
proc dll.Init, dllentry:dword |
pushad |
mov eax,mem.Alloc |
mov ebx,mem.Free |
mov ecx,mem.ReAlloc |
mov edx,dll.Load |
stdcall [dllentry] |
popad |
ret |
endp |
proc dll.GetProcAddress, exp:dword,sz_name:dword |
mov edx,[exp] |
xor eax,eax |
.next: or edx,edx |
jz .end |
cmp dword[edx],0 |
jz .end |
stdcall strcmp,[edx],[sz_name] |
test eax,eax |
jz .ok |
add edx,8 |
jmp .next |
.ok: mov eax,[edx+4] |
.end: ret |
endp |
proc strcmp, str1:dword,str2:dword |
push esi edi |
mov esi,[str1] |
mov edi,[str2] |
xor eax,eax |
@@: lodsb |
scasb |
jne .fail |
or al,al |
jnz @b |
jmp .ok |
.fail: or eax,-1 |
.ok: pop edi esi |
ret |
endp |
s_libdir: |
db '/sys/lib/' |
.fname rb 32 |
/programs/network/ftpd/commands.inc |
---|
0,0 → 1,1135 |
struct thread_data |
rb 1024 |
stack rb 0 |
home_dir rb 1024 ; home directory in wich the user is locked, asciiz |
work_dir rb 1024 ; working directory, must at all times begin and end with a '/', asciiz |
fpath rb 1024*3 ; file path, combination of home_dir, work_dir and filename |
; Will also be used to temporarily store username |
type db ? ; ASCII/EBDIC/IMAGE/.. |
mode db ? ; active/passive |
socketnum dd ? ; Commands socket |
state dd ? ; disconnected/logging in/logged in/.. |
passivesocknum dd ? ; when in passive mode, this is the listening socket |
datasocketnum dd ? ; socket used for data transfers |
permissions dd ? ; read/write/execute/.... |
buffer_ptr dd ? |
pid dd ? ; Process id of the current thread |
datasock sockaddr_in |
buffer rb BUFFERSIZE |
ends |
;------------------------------------------------ |
; parse_cmd |
; |
; Internal function wich uses the 'commands' |
; table to call an appropriate cmd_xx function. |
; |
; input: esi = ptr to ascii commands |
; ecx = number of bytes input |
; ebp = pointer to thread_data structure |
; |
; output: none |
; |
;------------------------------------------------ |
align 4 |
parse_cmd: ; esi must point to command |
cmp byte [esi], 0x20 ; skip all leading characters |
ja .ok |
inc esi |
dec ecx |
cmp ecx, 3 |
jb .error |
jmp parse_cmd |
.ok: |
cmp byte [esi+3], 0x20 |
ja @f |
mov byte [esi+3], 0 |
@@: |
mov eax, [esi] |
and eax, not 0x20202020 ; convert to upper case |
mov edi, commands ; list of commands to scan |
.scanloop: |
cmp eax, [edi] |
je .got_it |
add edi, 5*4 |
cmp byte [edi], 0 |
jne .scanloop |
.error: |
cmp [ebp + thread_data.state], STATE_ACTIVE |
jb login_first |
sendFTP "500 Unsupported command" |
ret |
.got_it: |
mov eax, [ebp + thread_data.state] |
jmp dword [edi + 4 + eax] |
align 4 |
iglobal |
commands: ; all commands must be in uppercase |
dd 'ABOR', login_first, login_first, login_first, cmdABOR |
; dd 'ACCT', login_first, login_first, login_first, cmd_ACCT |
; dd 'APPE', login_first, login_first, login_first, cmd_APPE |
dd 'CDUP', login_first, login_first, login_first, cmdCDUP |
dd 'CWD', login_first, login_first, login_first, cmdCWD |
dd 'DELE', login_first, login_first, login_first, cmdDELE |
; dd 'HELP', login_first, login_first, login_first, cmd_HELP |
dd 'LIST', login_first, login_first, login_first, cmdLIST |
; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM |
; dd 'MKD', login_first, login_first, login_first, cmd_MKD |
; dd 'MODE', login_first, login_first, login_first, cmd_MODE |
dd 'NLST', login_first, login_first, login_first, cmdNLST |
dd 'NOOP', login_first, login_first, login_first, cmdNOOP |
dd 'PASS', cmdPASS.0, cmdPASS , cmdPASS.2, cmdPASS.3 |
dd 'PASV', login_first, login_first, login_first, cmdPASV |
dd 'PORT', login_first, login_first, login_first, cmdPORT |
dd 'PWD', login_first, login_first, login_first, cmdPWD |
dd 'QUIT', cmdQUIT, cmdQUIT, cmdQUIT, cmdQUIT |
; dd 'REIN', login_first, login_first, login_first, cmd_REIN |
; dd 'REST', login_first, login_first, login_first, cmd_REST |
dd 'RETR', login_first, login_first, login_first, cmdRETR |
; dd 'RMD', login_first, login_first, login_first, cmd_RMD |
; dd 'RNFR', login_first, login_first, login_first, cmd_RNFR |
; dd 'RNTO', login_first, login_first, login_first, cmd_RNTO |
; dd 'SITE', login_first, login_first, login_first, cmd_SITE |
; dd 'SIZE', login_first, login_first, login_first, cmd_SIZE |
; dd 'STAT', login_first, login_first, login_first, cmd_STAT |
dd 'STOR', login_first, login_first, login_first, cmdSTOR |
; dd 'STOU', login_first, login_first, login_first, cmd_STOU |
; dd 'STRU', login_first, login_first, login_first, cmd_STRU |
dd 'SYST', login_first, login_first, login_first, cmdSYST |
dd 'TYPE', login_first, login_first, login_first, cmdTYPE |
dd 'USER', cmdUSER, cmdUSER, cmdUSER, cmdUSER.2 |
db 0 ; end marker |
endg |
align 4 |
login_first: |
sendFTP "530 Please login with USER and PASS" |
ret |
align 4 |
permission_denied: |
sendFTP "550 Permission denied" |
ret |
align 4 |
socketerror: |
invoke con_set_flags, 0x0c |
invoke con_write_asciiz, str_sockerr |
invoke con_set_flags, 0x07 |
sendFTP "425 Can't open data connection" |
ret |
align 4 |
abort_transfer: |
and [ebp + thread_data.permissions], not ABORT |
mov [ebp + thread_data.mode], MODE_NOTREADY |
invoke file.close, ebx |
mcall close, [ebp + thread_data.datasocketnum] |
sendFTP "530 Transfer aborted" |
ret |
align 4 |
ip_to_dword: ; esi = ptr to str, cl = separator ('.', ',') |
call ascii_to_byte |
mov bl, al |
cmp byte [esi], cl |
jne .err |
inc esi |
call ascii_to_byte |
mov bh, al |
cmp byte [esi], cl |
jne .err |
inc esi |
shl ebx, 16 |
call ascii_to_byte |
mov bl, al |
cmp byte [esi], cl |
jne .err |
inc esi |
call ascii_to_byte |
mov bh, al |
ror ebx, 16 |
ret |
.err: |
xor ebx, ebx |
ret |
align 4 ; esi = ptr to str, output in eax |
ascii_to_byte: |
xor eax, eax |
push ebx |
.loop: |
movzx ebx, byte[esi] |
sub bl, '0' |
jb .done |
cmp bl, 9 |
ja .done |
lea eax, [eax*4 + eax] ; |
shl eax, 1 ; eax = eax * 10 |
add eax, ebx |
inc esi |
jmp .loop |
.done: |
pop ebx |
ret |
align 4 |
dword_to_ascii: ; edi = ptr where to write, eax is number |
push edx ebx ecx |
mov ebx, 10 |
xor ecx, ecx |
@@: |
xor edx, edx |
div ebx |
add edx, '0' |
pushw dx |
inc ecx |
test eax, eax |
jnz @r |
@@: |
popw ax |
stosb |
dec ecx |
jnz @r |
pop ecx ebx edx |
ret |
align 4 |
create_path: ; combine home_dir and work_dir strings into fpath |
lea edi, [ebp + thread_data.fpath] |
lea esi, [ebp + thread_data.home_dir] |
mov ecx, 1024 |
.loop1: |
lodsb |
cmp al, 0x20 |
jb .next |
stosb |
loop .loop1 |
.next: |
cmp byte[edi-1], '/' |
jne @f |
dec edi |
@@: |
lea esi, [ebp + thread_data.work_dir] |
mov ecx, 1024 |
.loop2: |
lodsb |
cmp al, 0x20 |
jb .done |
stosb |
loop .loop2 |
.done: |
xor al, al |
stosb |
ret |
align 4 |
nextpasvport: |
inc [pasv_port] |
mov ax, [pasv_port] |
cmp ax, [pasv_start] |
jb .restart |
cmp ax, [pasv_end] |
ja .restart |
ret |
.restart: |
pushw [pasv_start] |
popw [pasv_port] |
ret |
align 4 |
open_datasock: |
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK |
je .start |
; If we are in active mode, it's time to open a data socket.. |
cmp [ebp + thread_data.mode], MODE_ACTIVE |
jne .not_active |
mov ecx, [ebp + thread_data.datasocketnum] |
lea edx, [ebp + thread_data.datasock] |
mov esi, sizeof.thread_data.datasock |
mcall connect |
cmp eax, -1 |
jne .start |
.socketerror: |
add esp, 4 |
jmp socketerror |
; If we are still in passive_wait, it's time we accept an incomming call.. |
.not_active: |
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT |
jne .socketerror |
.try_now: |
mov ecx, [ebp + thread_data.passivesocknum] |
lea edx, [ebp + thread_data.datasock] |
mov esi, sizeof.thread_data.datasock |
mcall accept |
cmp eax, -1 |
jne .pasv_ok |
mov [ebp + thread_data.mode], MODE_PASSIVE_FAILED ; assume that we will fail |
mcall 23, 200 |
mcall accept |
cmp eax, -1 |
je .socketerror |
.pasv_ok: |
mov [ebp + thread_data.datasocketnum], eax |
mov [ebp + thread_data.mode], MODE_PASSIVE_OK |
mcall close ; [ebp + thread_data.passivesocknum] |
mov [ebp + thread_data.passivesocknum], -1 |
invoke con_write_asciiz, str_datasock |
.start: |
ret |
;------------------------------------------------ |
; "ABOR" |
; |
; This command aborts the current filetransfer. |
; |
;------------------------------------------------ |
align 4 |
cmdABOR: |
or [ebp + thread_data.permissions], ABORT |
sendFTP "250 Command succesul" |
ret |
;------------------------------------------------ |
; "CDUP" |
; |
; Change the directory to move up one level. |
; |
;------------------------------------------------ |
align 4 |
cmdCDUP: |
test [ebp + thread_data.permissions], PERMISSION_CD |
jz permission_denied |
cmp byte [ebp + thread_data.work_dir+1], 0 ; are we in "/" ? |
je .done ; if so, we cant go up.. |
; find the end of asciiz string work_dir |
mov ecx, 1024 |
xor al, al |
lea edi, [ebp + thread_data.work_dir] |
repne scasb |
; return 2 characters (right before last /) |
sub edi, 3 |
; and now search backwards, for a '/' |
mov al,'/' |
neg ecx |
add ecx, 1024 |
std |
repne scasb |
cld |
; terminate the string here |
mov byte[edi+2], 0 |
.done: |
; Print the new working dir on the console |
lea eax, [ebp + thread_data.work_dir] |
invoke con_write_asciiz, eax |
invoke con_write_asciiz, str_newline |
sendFTP "250 Command succesul" |
ret |
;------------------------------------------------ |
; "CWD" |
; |
; Change Working Directory. |
; |
;------------------------------------------------ |
align 4 |
cmdCWD: |
test [ebp + thread_data.permissions], PERMISSION_CD |
jz permission_denied |
; do we have enough parameters? |
sub ecx, 4 |
jbe .err |
; get ready to copy the path |
add esi, 4 |
mov ecx, 1024 |
lea edi, [ebp + thread_data.work_dir] |
; if received dir starts with '/', we will simply copy it |
; If not, we will append the current path with the received path. |
cmp byte [esi], '/' |
je .copyloop |
; Find the end of work_dir string. |
xor al, al |
.find_zero: |
repne scasb |
dec edi |
; and now append work_dir with received string |
mov ecx, 1024 |
; scan for end byte, or '.' |
.copyloop: |
lodsb |
cmp al, 0x20 |
jb .done |
;;; cmp al, '.' ; '..' means we must go up one dir TODO |
;;; je .up |
stosb |
loop .copyloop |
; now, now make sure it ends with '/', 0 |
.done: |
cmp byte [edi-1], '/' |
je @f |
mov byte [edi], '/' |
inc edi |
@@: |
mov byte [edi], 0 |
; Print the new working dir on the console |
lea eax, [ebp + thread_data.work_dir] |
invoke con_write_asciiz, eax |
invoke con_write_asciiz, str_newline |
sendFTP "250 Command succesful" |
ret |
.err: |
sendFTP "550 Directory does not exist" |
ret |
;------------------------------------------------ |
; "DELE" |
; |
; Delete a file from the server. |
; |
;------------------------------------------------ |
align 4 |
cmdDELE: |
test [ebp + thread_data.permissions], PERMISSION_DELETE |
jz permission_denied |
ret |
;------------------------------------------------ |
; "LIST" |
; |
; List the files in the current working directory. |
; |
;------------------------------------------------ |
align 4 |
cmdLIST: |
test [ebp + thread_data.permissions], PERMISSION_EXEC |
jz permission_denied |
call open_datasock |
; Create fpath from home_dir and work_dir |
call create_path |
lea ebx, [ebp + thread_data.fpath] |
invoke con_write_asciiz, ebx |
invoke con_write_asciiz, str_newline |
; Start the search |
invoke file.find.first, ebx, str_mask, FA_READONLY+FA_FOLDER+FA_ARCHIVED;+FA_NORMAL |
test eax, eax |
jz .nosuchdir |
lea edi, [ebp + thread_data.buffer] |
.parse_file: |
test eax, eax ; did we find a file? |
jz .done |
mov ebx, eax ; yes, save the descripter in ebx |
; first, convert the attributes |
test [ebx + FileInfoA.Attributes], FA_FOLDER |
jnz .folder |
test [ebx + FileInfoA.Attributes], FA_READONLY |
jnz .readonly |
mov eax, '-rw-' |
stosd |
jmp .attr |
.folder: |
mov eax, 'drwx' |
stosd |
jmp .attr |
.readonly: |
mov eax, '-r--' |
stosd |
.attr: |
mov eax, 'rw-r' |
stosd |
mov ax, 'w-' |
stosw |
mov al, ' ' |
stosb |
; now.. |
mov ax, '1 ' |
stosw |
; now write owner, everything is owned by FTP, woohoo! |
mov eax, 'FTP ' |
stosd |
stosd |
; now the filesize in ascii |
mov eax, [ebx + FileInfoA.FileSizeLow] |
call dword_to_ascii |
mov al, ' ' |
stosb |
; then date (month/day/year) |
movzx eax, [ebx + FileInfoA.DateModify + FileDateTime.month] |
cmp eax, 12 |
ja @f |
mov eax, [months - 4 + 4*eax] |
stosd |
@@: |
movzx eax, [ebx + FileInfoA.DateModify + FileDateTime.day] |
call dword_to_ascii |
mov al, ' ' |
stosb |
movzx eax, [ebx + FileInfoA.DateModify + FileDateTime.year] |
call dword_to_ascii |
mov al, ' ' |
stosb |
; and last but not least, filename |
lea esi, [ebx + FileInfoA.FileName] |
mov ecx, 264 |
.nameloop: |
lodsb |
test al, al |
jz .namedone |
stosb |
loop .nameloop |
; insert a cr lf |
.namedone: |
mov ax, 0x0a0d |
stosw |
test [ebp + thread_data.permissions], ABORT ; Did we receive ABOR command from client? |
jnz abort_transfer |
; check next file |
invoke file.find.next, ebx |
jmp .parse_file |
; close file desc |
.done: |
invoke file.find.close, ebx ; ebx is descriptor of last file, eax will be -1 !! |
; append the string with a 0 |
xor al, al |
stosb |
; Warn the client we're about to send the data |
push edi |
sendFTP "150 Here it comes.." |
pop esi |
; and send it to the client |
mov ecx, [ebp + thread_data.datasocketnum] ; socket num |
lea edx, [ebp + thread_data.buffer] ; buffer ptr |
sub esi, edx ; length |
xor edi, edi ; flags |
mcall send |
; close the data socket.. |
mov [ebp + thread_data.mode], MODE_NOTREADY |
mcall close, [ebp + thread_data.datasocketnum] |
sendFTP "226 Transfer OK" |
ret |
.nosuchdir: |
sendFTP "550 Directory does not exist" |
ret |
;------------------------------------------------ |
; "NLST" |
; |
; List the filenames of the files in the current working directory. |
; |
;------------------------------------------------ |
align 4 |
cmdNLST: |
test [ebp + thread_data.permissions], PERMISSION_EXEC |
jz permission_denied |
; TODO: same as list but simpler output format |
ret |
;------------------------------------------------ |
; "NOOP" |
; |
; No operation, just keep the connection alive. |
; |
;------------------------------------------------ |
align 4 |
cmdNOOP: |
sendFTP "200 Command OK" |
ret |
;------------------------------------------------ |
; "PASS" |
; |
; Second phase of login process, client provides password. |
; |
;------------------------------------------------ |
align 4 |
cmdPASS: |
; read the password from users.ini |
lea edi, [ebp + thread_data.buffer + 512] ; temp pass |
lea ebx, [ebp + thread_data.fpath] ; temp username |
invoke ini.get_str, path2, ebx, str_pass, edi, 512, str_infinity |
test eax, eax ; unable to read password? fail! |
jnz .incorrect |
cmp dword [edi], -1 ; no key, section or file found.. fail! |
je .incorrect |
cmp byte [edi], 0 ; zero password? ok! |
je .ok |
add esi, 5 |
sub ecx, 5 |
jbe .incorrect ; no password given? but hey, we need one! fail.. |
; compare with received password |
repe cmpsb |
cmp byte [esi-1], 0x20 ; printeable characters left? |
jae .incorrect |
cmp byte [edi-1], 0 |
jne .incorrect |
.ok: |
invoke ini.get_int, path2, ebx, str_mode, 0 |
mov [ebp + thread_data.permissions], eax |
invoke con_write_asciiz, str_pass_ok |
mov [ebp + thread_data.state], STATE_ACTIVE |
sendFTP "230 You are now logged in" |
ret |
.2: |
.incorrect: |
invoke con_write_asciiz, str_pass_err |
mov [ebp + thread_data.state], STATE_CONNECTED ; reset state |
sendFTP "530 Login incorrect" |
ret |
.0: |
sendFTP "503 Login with USER first" |
ret |
.3: |
sendFTP "230 Already logged in" |
ret |
;------------------------------------------------ |
; "PASV" |
; |
; Initiate a passive dataconnection. |
; |
;------------------------------------------------ |
align 4 |
cmdPASV: |
; cmp [ebp + thread_data.passivesocknum], -1 |
; je @f |
; mcall close, [ebp + thread_data.passivesocknum] ; if there is still a socket open, close it |
; @@: |
; Open a new TCP socket |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
je socketerror |
mov [ebp + thread_data.passivesocknum], eax |
; Bind it to a known local port |
mov [ebp + thread_data.datasock.sin_family], AF_INET4 |
mov [ebp + thread_data.datasock.sin_addr], 0 |
mov ecx, eax ; passivesocketnum |
lea edx, [ebp + thread_data.datasock] |
mov esi, sizeof.thread_data.datasock |
.next_port: ; TODO: break the endless loop |
call nextpasvport |
mov ax, [pasv_port] |
xchg al, ah |
mov [ebp + thread_data.datasock.sin_port], ax |
mcall bind |
cmp eax, -1 |
je .next_port |
; And set it to listen! |
mcall listen, , 1 |
cmp eax, -1 |
je socketerror |
; Tell our thread we are ready to accept incoming calls |
mov [ebp + thread_data.mode], MODE_PASSIVE_WAIT |
; Now tell the client where to connect to in this format: |
; 227 Entering Passive Mode (a1,a2,a3,a4,p1,p2) |
; where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number. |
; '227 (' |
lea edi, [ebp + thread_data.buffer] |
mov eax, '227 ' |
stosd |
mov al, '(' |
stosb |
; ip |
movzx eax, byte [serverip] |
call dword_to_ascii |
mov al, ',' |
stosb |
movzx eax, byte [serverip+1] |
call dword_to_ascii |
mov al, ',' |
stosb |
movzx eax, byte [serverip+2] |
call dword_to_ascii |
mov al, ',' |
stosb |
movzx eax, byte [serverip+3] |
call dword_to_ascii |
mov al, ',' |
stosb |
; port |
movzx eax, byte [ebp + thread_data.datasock.sin_port] |
call dword_to_ascii |
mov al, ',' |
stosb |
movzx eax, byte [ebp + thread_data.datasock.sin_port+1] |
call dword_to_ascii |
; ')', 13, 10, 0 |
mov eax, ')' + 0x000a0d00 |
stosd |
lea esi, [edi - thread_data.buffer] |
sub esi, ebp |
mov ecx, [ebp + thread_data.socketnum] |
lea edx, [ebp + thread_data.buffer] |
xor edi, edi |
mcall send |
ret |
;------------------------------------------------ |
; "PWD" |
; |
; Print the current working directory. |
; |
;------------------------------------------------ |
align 4 |
cmdPWD: |
mov dword [ebp + thread_data.buffer], '257 ' |
mov byte [ebp + thread_data.buffer+4], '"' |
lea edi, [ebp + thread_data.buffer+5] |
lea esi, [ebp + thread_data.work_dir] |
mov ecx, 1024 |
.loop: |
lodsb |
or al, al |
jz .ok |
stosb |
dec ecx |
jnz .loop |
.ok: |
mov dword [edi], '"' + 0x000a0d00 ; '"',13,10,0 |
lea esi, [edi - thread_data.buffer + 4] |
sub esi, ebp |
mov ecx, [ebp + thread_data.socketnum] |
lea edx, [ebp + thread_data.buffer] |
xor edi, edi |
mcall send |
; Print the new working dir on the console |
lea eax, [ebp + thread_data.work_dir] |
invoke con_write_asciiz, eax |
invoke con_write_asciiz, str_newline |
ret |
;------------------------------------------------ |
; "PORT" |
; |
; Initiate an active dataconnection. |
; |
;------------------------------------------------ |
align 4 |
cmdPORT: |
; PORT a1,a2,a3,a4,p1,p2 |
; IP address a1.a2.a3.a4, port p1*256+p2 |
; Convert the IP |
lea esi, [esi+5] |
mov cl, ',' |
call ip_to_dword |
; And put it in datasock |
mov [ebp + thread_data.datasock.sin_addr], ebx |
; Now the same with portnumber |
inc esi |
call ascii_to_byte |
mov byte[ebp + thread_data.datasock.sin_port], al |
inc esi |
call ascii_to_byte |
mov byte[ebp + thread_data.datasock.sin_port+1], al |
; We will open the socket, but do not connect yet! |
mov [ebp + thread_data.datasock.sin_family], AF_INET4 |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
je socketerror |
mov [ebp + thread_data.datasocketnum], eax |
mov [ebp + thread_data.mode], MODE_ACTIVE |
sendFTP "225 Data connection open" |
ret |
;------------------------------------------------ |
; "QUIT" |
; |
; Close the connection with client. |
; |
;------------------------------------------------ |
align 4 |
cmdQUIT: |
sendFTP "221 Bye!" |
mcall close, [ebp + thread_data.datasocketnum] |
mcall close, [ebp + thread_data.socketnum] |
add esp, 4 ; get rid of call return address |
jmp thread_exit ; now close this thread |
;------------------------------------------------ |
; "RETR" |
; |
; Retrieve a file from the ftp server. |
; |
;------------------------------------------------ |
align 4 |
cmdRETR: |
test [ebp + thread_data.permissions], PERMISSION_READ |
jz permission_denied |
cmp ecx, 1024 + 5 |
jae .cannot_open |
sub ecx, 5 |
jb .cannot_open |
call open_datasock |
call create_path |
dec edi |
lea esi, [ebp + thread_data.buffer + 5] |
mov ecx, 1024 |
cmp byte [esi], '/' |
jne .loop |
inc esi |
.loop: |
lodsb |
cmp al, 0x20 |
jl .done |
stosb |
loop .loop |
.done: |
xor al, al |
stosb |
lea ebx, [ebp + thread_data.fpath] |
invoke con_write_asciiz, ebx |
invoke con_write_asciiz, str_newline |
invoke file.open, ebx, O_READ |
test eax, eax |
jz .cannot_open |
push eax |
sendFTP "150 Here it comes.." |
pop ebx |
.read_more: |
test [ebp + thread_data.permissions], ABORT |
jnz abort_transfer |
lea eax, [ebp + thread_data.buffer] ; FIXME: use another buffer!! if we receive something on control connection now, we screw up! |
invoke file.read, ebx, eax, BUFFERSIZE |
cmp eax, -1 |
je .cannot_open ; FIXME: this is not the correct error |
invoke con_write_asciiz, str2 |
push eax ebx |
mov esi, eax |
mov ecx, [ebp + thread_data.datasocketnum] |
lea edx, [ebp + thread_data.buffer] |
xor edi, edi |
mcall send |
pop ebx ecx |
cmp eax, -1 |
je socketerror ; FIXME: not the correct error |
; cmp eax, ecx |
; jne not_all_byes_sent ; TODO |
cmp ecx, BUFFERSIZE |
je .read_more |
invoke file.close, ebx |
invoke con_write_asciiz, str2b |
mov [ebp + thread_data.mode], MODE_NOTREADY |
mcall close, [ebp + thread_data.datasocketnum] |
sendFTP "226 Transfer OK, closing connection" |
ret |
.cannot_open: |
invoke con_set_flags, 0x0c |
invoke con_write_asciiz, str_notfound |
invoke con_set_flags, 0x07 |
sendFTP "550 No such file" |
ret |
;------------------------------------------------ |
; "STOR" |
; |
; Store a file on the server. |
; |
;------------------------------------------------ |
align 4 |
cmdSTOR: |
test [ebp + thread_data.permissions], PERMISSION_WRITE |
jz permission_denied |
;;;; |
test [ebp + thread_data.permissions], ABORT |
jnz abort_transfer |
;;;; |
ret |
;------------------------------------------------ |
; "SYST" |
; |
; Send information about the system. |
; |
;------------------------------------------------ |
align 4 |
cmdSYST: |
sendFTP "215 UNIX type: L8" |
ret |
;------------------------------------------------ |
; "TYPE" |
; |
; Choose the file transfer type. |
; |
;------------------------------------------------ |
align 4 |
cmdTYPE: |
cmp ecx, 6 |
jb parse_cmd.error |
mov al, byte[esi+5] |
and al, not 0x20 |
cmp al, 'A' |
je .ascii |
cmp al, 'E' |
je .ebdic |
cmp al, 'I' |
je .image |
cmp al, 'L' |
je .local |
jmp parse_cmd.error |
.ascii: |
mov [ebp + thread_data.type], TYPE_ASCII |
jmp .subtype |
.ebdic: |
mov [ebp + thread_data.type], TYPE_EBDIC |
.subtype: |
cmp ecx, 8 |
jb .non_print |
mov al, byte[esi+7] |
and al, not 0x20 |
cmp al, 'N' |
je .non_print |
cmp al, 'T' |
je .telnet |
cmp al, 'C' |
je .asacc |
cmp al, 0x20 |
jb .non_print |
jmp parse_cmd.error |
.non_print: |
or [ebp + thread_data.type], TYPE_NP |
jmp .ok |
.telnet: |
or [ebp + thread_data.type], TYPE_TELNET |
jmp .ok |
.asacc: |
or [ebp + thread_data.type], TYPE_ASA |
jmp .ok |
.image: |
mov [ebp + thread_data.type], TYPE_IMAGE |
jmp .ok |
.local: |
cmp ecx, 8 |
jb parse_cmd.error |
mov al, byte[esi+7] |
sub al, '0' |
jb parse_cmd.error ; FIXME: this is not the correct errormessage |
cmp al, 9 |
ja parse_cmd.error ; FIXME |
or al, TYPE_LOCAL |
mov [ebp + thread_data.type], al |
.ok: |
sendFTP "200 Command ok" |
ret |
;------------------------------------------------ |
; "USER" |
; |
; Login to the server, step one of two. ;;; TODO: prevent buffer overflow! |
; |
;------------------------------------------------ |
align 4 |
cmdUSER: |
lea esi, [esi + 5] |
lea edi, [ebp + thread_data.fpath] ; temp buffer for username |
.loop: |
lodsb |
stosb |
cmp al, 0x20 |
jae .loop |
mov byte [edi-1], 0 |
lea esi, [ebp + thread_data.fpath] |
lea eax, [ebp + thread_data.home_dir] |
invoke ini.get_str, path2, esi, str_home, eax, 1024, str_infinity |
cmp eax, -1 |
je .login_fail |
cmp dword [esi], -1 |
je .login_fail |
mov word [ebp + thread_data.work_dir], "/" ; "/", 0 |
invoke con_write_asciiz, str_logged_in |
mov [ebp + thread_data.state], STATE_LOGIN |
.sendstr: |
sendFTP "331 Please specify the password" |
ret |
.login_fail: |
invoke con_write_asciiz, str_pass_err |
mov [ebp + thread_data.state], STATE_LOGIN_FAIL |
jmp .sendstr |
align 4 |
.2: |
sendFTP "530 Can't change to another user" |
ret |
/programs/network/ftpd/ftpd.asm |
---|
0,0 → 1,455 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ftpd.asm - FTP Daemon for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
DEBUG = 0 ; if set to one, program will run in a single thread |
BUFFERSIZE = 8192 |
; using multiple's of 4 |
STATE_CONNECTED = 0*4 |
STATE_LOGIN = 1*4 |
STATE_LOGIN_FAIL = 2*4 ; When an invalid username was given |
STATE_ACTIVE = 3*4 |
TYPE_UNDEF = 0 |
TYPE_ASCII = 00000100b |
TYPE_EBDIC = 00001000b |
; subtypes for ascii & ebdic (np = default) |
TYPE_NP = 00000001b ; non printable |
TYPE_TELNET = 00000010b |
TYPE_ASA = 00000011b |
TYPE_IMAGE = 01000000b ; binary data |
TYPE_LOCAL = 10000000b ; bits per byte must be specified |
; lower 4 bits will hold this value |
MODE_NOTREADY = 0 |
MODE_ACTIVE = 1 |
MODE_PASSIVE_WAIT = 2 |
MODE_PASSIVE_OK = 3 |
MODE_PASSIVE_FAILED = 4 |
PERMISSION_EXEC = 1b ; LIST |
PERMISSION_READ = 10b |
PERMISSION_WRITE = 100b |
PERMISSION_DELETE = 1000b |
PERMISSION_CD = 10000b ; Change Directory |
ABORT = 1 shl 31 |
format binary as "" |
use32 |
org 0x0 |
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 params ; parameters |
dd path ; path |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../struct.inc' |
include '../libio.inc' |
include '../network.inc' |
macro sendFTP str { |
local string, length |
xor edi, edi |
mcall send, [ebp + thread_data.socketnum], string, length |
iglobal |
string db str, 13, 10 |
length = $ - string |
\} |
} |
include 'commands.inc' |
start: |
mcall 68, 11 ; init heap |
mcall 40, 1 shl 7 ; we only want network events |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; find path to main settings file (ftpd.ini) |
mov edi, path ; Calculate the length of zero-terminated string |
xor al, al |
mov ecx, 1024 |
repne scasb |
dec edi |
mov esi, str_ini ; append it with '.ini', 0 |
movsd |
movsb |
; now create the second path (users.ini) |
std |
mov al, '/' |
repne scasb |
lea ecx, [edi - path + 2] |
cld |
mov esi, path |
mov edi, path2 |
rep movsb |
mov esi, str_users |
movsd |
movsd |
movsw |
; initialize console |
invoke con_start, 1 |
invoke con_init, -1, -1, -1, -1, title |
; get settings from ini |
invoke ini.get_str, path, str_ftpd, str_ip, ini_buf, 16, 0 |
mov esi, ini_buf |
mov cl, '.' |
call ip_to_dword |
mov [serverip], ebx |
invoke ini.get_int, path, str_ftpd, str_port, 21 |
xchg al, ah |
mov [sockaddr1.port], ax |
xchg al, ah |
invoke con_printf, str1, eax |
add esp, 8 |
; open listening socket |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
je sock_err |
mov [socketnum], eax |
invoke con_write_asciiz, str2 |
; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
; cmp eax, -1 |
; je opt_err |
mcall bind, [socketnum], sockaddr1, sockaddr1.length |
cmp eax, -1 |
je bind_err |
invoke con_write_asciiz, str2 |
invoke ini.get_int, path, str_ftpd, str_conn, 1 ; Backlog (max connections) |
mov edx, eax |
invoke con_write_asciiz, str2 |
mcall listen, [socketnum] |
cmp eax, -1 |
je listen_err |
invoke con_write_asciiz, str2b |
invoke ini.get_int, path, str_pasv, str_start, 2000 |
mov [pasv_start], ax |
invoke ini.get_int, path, str_pasv, str_end, 5000 |
mov [pasv_end], ax |
mov [alive], 1 |
mainloop: |
mcall 23, 100 ; Wait here for incoming connections on the base socket (socketnum) |
; One second timeout, we will use this to check if console is still working |
test eax, eax ; network event? |
jz .checkconsole |
if DEBUG |
jmp threadstart |
else |
mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection |
; NOTE: upon initialisation of the thread, stack will not be available! |
end if |
jmp mainloop |
.checkconsole: |
invoke con_get_flags ; Is console still running? |
test eax, 0x0200 |
jz mainloop |
mcall close, [socketnum] ; kill the listening socket |
mov [alive], 0 |
mcall -1 ; and exit |
diff16 "threadstart", 0, $ |
threadstart: |
;;; mcall 68, 11 ; init heap |
mcall 68, 12, sizeof.thread_data ; allocate the thread data struct |
test eax, eax |
je exit |
lea esp, [eax + thread_data.stack] ; init stack |
mov ebp, eax |
mcall 40, 1 shl 7 ; we only want network events for this thread |
lea ebx, [ebp + thread_data.buffer] ; get information about the current process |
or ecx, -1 |
mcall 9 |
mov eax, dword [ebp + thread_data.buffer + 30] ; PID is at offset 30 |
mov [ebp + thread_data.pid], eax |
invoke con_set_flags, 0x03 |
invoke con_printf, str8, [ebp + thread_data.pid] ; print on the console that we have created the new thread successfully |
add esp, 8 ; balance stack |
invoke con_set_flags, 0x07 |
mcall accept, [socketnum], sockaddr1, sockaddr1.length ; time to accept the awaiting connection.. |
cmp eax, -1 |
je thread_exit |
mov [ebp + thread_data.socketnum], eax |
if DEBUG |
mcall close, [socketnum] ; close the listening socket |
end if |
mov [ebp + thread_data.state], STATE_CONNECTED |
mov [ebp + thread_data.permissions], 0 |
mov [ebp + thread_data.mode], MODE_NOTREADY |
lea eax, [ebp + thread_data.buffer] |
mov [ebp + thread_data.buffer_ptr], eax |
mov [ebp + thread_data.passivesocknum], -1 |
sendFTP "220 Welcome to KolibriOS FTP daemon" |
diff16 "threadloop", 0, $ |
threadloop: |
; Check if our socket is still connected |
mcall send, [ebp + thread_data.socketnum], 0, 0 ; Try to send zero bytes, if socket is closed, this will return -1 |
cmp eax, -1 |
je thread_exit |
cmp [alive], 0 ; Did main thread take a run for it? |
je thread_exit |
mcall 10 ; Wait for network event |
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT |
jne .not_passive |
mov ecx, [ebp + thread_data.passivesocknum] |
lea edx, [ebp + thread_data.datasock] |
mov esi, sizeof.thread_data.datasock |
mcall accept |
cmp eax, -1 |
je .not_passive |
mov [ebp + thread_data.datasocketnum], eax |
mov [ebp + thread_data.mode], MODE_PASSIVE_OK |
mcall close ; [ebp + thread_data.passivesocknum] |
mov [ebp + thread_data.passivesocknum], -1 |
invoke con_write_asciiz, str_datasock |
.not_passive: |
mov ecx, [ebp + thread_data.socketnum] |
mov edx, [ebp + thread_data.buffer_ptr] |
mov esi, sizeof.thread_data.buffer ;;; FIXME |
mcall recv |
inc eax ; error? (-1) |
jz threadloop |
dec eax ; 0 bytes read? |
jz threadloop |
mov edi, [ebp + thread_data.buffer_ptr] |
add [ebp + thread_data.buffer_ptr], eax |
; Check if we received a newline character, if not, wait for more data |
mov ecx, eax |
mov al, 13 |
repne scasb |
jne threadloop |
; We got a command! |
mov byte [edi + 1], 0 ; append string with zero byte |
lea esi, [ebp + thread_data.buffer] |
mov ecx, [ebp + thread_data.buffer_ptr] |
sub ecx, esi |
mov [ebp + thread_data.buffer_ptr], esi ; reset buffer ptr |
invoke con_set_flags, 0x02 ; print received data to console (in green color) |
invoke con_write_asciiz, str_newline |
invoke con_write_asciiz, esi |
invoke con_set_flags, 0x07 |
push threadloop |
jmp parse_cmd |
listen_err: |
invoke con_set_flags, 0x0c ; print errors in red |
invoke con_write_asciiz, str3 |
jmp done |
bind_err: |
invoke con_set_flags, 0x0c ; print errors in red |
invoke con_write_asciiz, str4 |
jmp done |
sock_err: |
invoke con_set_flags, 0x0c ; print errors in red |
invoke con_write_asciiz, str6 |
jmp done |
done: |
invoke con_exit, 0 |
exit: |
mcall -1 |
thread_exit: |
invoke con_set_flags, 0x03 ; print thread info in blue |
invoke con_printf, str_bye, [ebp + thread_data.pid] ; print on the console that we are about to kill the thread |
add esp, 8 ; balance stack |
mcall 68, 13, ebp ; free the memory |
mcall -1 ; and kill the thread |
; initialized data |
title db 'KolibriOS FTP daemon 0.1', 0 |
str1 db 'Starting FTP daemon on port %u.', 0 |
str2 db '.', 0 |
str2b db ' OK!',10,0 |
str3 db 'Listen error',10,0 |
str4 db 10,'ERROR: local port is already in use.',10,0 |
;str5 db 'Setsockopt error.',10,10,0 |
str6 db 'ERROR: Could not open socket.',10,0 |
str7 db 'Got data!',10,10,0 |
str8 db 10,'Thread %d created',10,0 |
str_bye db 10,'Thread %d killed',10,0 |
str_logged_in db 'Login ok',10,0 |
str_pass_ok db 'Password ok',10,0 |
str_pass_err db 'Password/Username incorrect',10,0 |
str_pwd db 'Current directory is "%s"\n',0 |
str_err2 db 'ERROR: cannot open the directory.',10,0 |
str_datasock db 'Passive data socket connected.',10,0 |
str_notfound db 'ERROR: file not found.',10,0 |
str_sockerr db 'ERROR: socket error.',10,0 |
str_newline db 10, 0 |
str_mask db '*', 0 |
str_infinity db 0xff, 0xff, 0xff, 0xff, 0 |
months dd 'Jan ' |
dd 'Feb ' |
dd 'Mar ' |
dd 'Apr ' |
dd 'May ' |
dd 'Jun ' |
dd 'Jul ' |
dd 'Aug ' |
dd 'Sep ' |
dd 'Oct ' |
dd 'Nov ' |
dd 'Dec ' |
str_users db 'users' |
str_ini db '.ini', 0 |
str_port db 'port', 0 |
str_ftpd db 'ftpd', 0 |
str_conn db 'conn', 0 |
str_ip db 'ip', 0 |
str_pass db 'pass', 0 |
str_home db 'home', 0 |
str_mode db 'mode', 0 |
str_pasv db 'pasv', 0 |
str_start db 'start', 0 |
str_end db 'end', 0 |
sockaddr1: |
dw AF_INET4 |
.port dw 0 |
.ip dd 0 |
rb 10 |
.length = $ - sockaddr1 |
; import |
align 4 |
@IMPORT: |
diff16 "import", 0, $ |
library console, 'console.obj',\ |
libini, 'libini.obj', \ |
libio, 'libio.obj' |
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_printf, 'con_printf',\ |
con_getch2, 'con_getch2',\ |
con_set_cursor_pos, 'con_set_cursor_pos',\ |
con_set_flags, 'con_set_flags',\ |
con_get_flags, 'con_get_flags' |
import libini,\ |
ini.get_str, 'ini_get_str',\ |
ini.get_int, 'ini_get_int' |
import libio,\ |
file.size, 'file_size',\ |
file.open, 'file_open',\ |
file.read, 'file_read',\ |
file.close, 'file_close',\ |
file.find.first, 'file_find_first',\ |
file.find.next, 'file_find_next',\ |
file.find.close, 'file_find_close' |
IncludeIGlobals |
i_end: |
diff16 "i_end", 0, $ |
; uninitialised data |
socketnum dd ? |
path rb 1024 |
path2 rb 1024 |
params rb 1024 |
serverip dd ? |
pasv_start dw ? |
pasv_end dw ? |
pasv_port dw ? |
ini_buf rb 3*4+3+1 |
alive db ? |
mem: |
/programs/network/ftpd/ftpd.ini |
---|
0,0 → 1,8 |
[ftpd] |
port=21 |
conn=10 |
ip=127.0.0.1 |
[pasv] |
start=2000 |
end=5000 |
/programs/network/ftpd/users.ini |
---|
0,0 → 1,20 |
; Access modes |
; |
; List = 1 |
; Read = 2 |
; Write = 4 |
; Delete = 8 |
; Change directory = 16 |
[anonymous] |
; leavy pass empty to disable it |
pass= |
home=/rd/1/ |
mode=3 |
[test] |
pass=1234 |
home=/rd/1/ |
mode=31 |
/programs/network/ftpd |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/icmp/icmp.inc |
---|
0,0 → 1,77 |
; ICMP types & codes |
ICMP_ECHOREPLY equ 0 ; echo reply message |
ICMP_UNREACH equ 3 |
ICMP_UNREACH_NET equ 0 ; bad net |
ICMP_UNREACH_HOST equ 1 ; bad host |
ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol |
ICMP_UNREACH_PORT equ 3 ; bad port |
ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop |
ICMP_UNREACH_SRCFAIL equ 5 ; src route failed |
ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net |
ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host |
ICMP_UNREACH_ISOLATED equ 8 ; src host isolated |
ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access |
ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto |
ICMP_UNREACH_TOSNET equ 11 ; bad tos for net |
ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host |
ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib |
ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio. |
ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff |
ICMP_SOURCEQUENCH equ 4 ; Packet lost, slow down |
ICMP_REDIRECT equ 5 ; shorter route, codes: |
ICMP_REDIRECT_NET equ 0 ; for network |
ICMP_REDIRECT_HOST equ 1 ; for host |
ICMP_REDIRECT_TOSNET equ 2 ; for tos and net |
ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host |
ICMP_ALTHOSTADDR equ 6 ; alternate host address |
ICMP_ECHO equ 8 ; echo service |
ICMP_ROUTERADVERT equ 9 ; router advertisement |
ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement |
ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing |
ICMP_ROUTERSOLICIT equ 10 ; router solicitation |
ICMP_TIMXCEED equ 11 ; time exceeded, code: |
ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit |
ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass |
ICMP_PARAMPROB equ 12 ; ip header bad |
ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr |
ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent |
ICMP_PARAMPROB_LENGTH equ 2 ; bad length |
ICMP_TSTAMP equ 13 ; timestamp request |
ICMP_TSTAMPREPLY equ 14 ; timestamp reply |
ICMP_IREQ equ 15 ; information request |
ICMP_IREQREPLY equ 16 ; information reply |
ICMP_MASKREQ equ 17 ; address mask request |
ICMP_MASKREPLY equ 18 ; address mask reply |
ICMP_TRACEROUTE equ 30 ; traceroute |
ICMP_DATACONVERR equ 31 ; data conversion error |
ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect |
ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you |
ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here |
ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req |
ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply |
ICMP_SKIP equ 39 ; SKIP |
ICMP_PHOTURIS equ 40 ; Photuris |
ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index |
ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed |
ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed |
virtual at 0 |
ICMP_Packet: |
.Type db ? |
.Code db ? |
.Checksum dw ? |
.Identifier dw ? |
.SequenceNumber dw ? |
.Data: |
end virtual |
/programs/network/icmp/ping.asm |
---|
0,0 → 1,256 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ping.asm - ICMP echo client for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd I_END ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd s ; parameters |
dd 0 ; path |
BUFFERSIZE equ 1500 |
; useful includes |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../network.inc' |
include 'icmp.inc' |
start: |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push 25 |
push 80 |
push 25 |
push 80 |
call [con_init] |
; main loop |
cmp byte[s], 0 |
jne resolve |
main: |
; write prompt |
push str2 |
call [con_write_asciiz] |
; read string |
mov esi, s |
push 256 |
push esi |
call [con_gets] |
; check for exit |
test eax, eax |
jz done |
cmp byte [esi], 10 |
jz done |
; delete terminating '\n' |
push esi |
@@: |
lodsb |
test al, al |
jnz @b |
mov byte [esi-2], al |
pop esi |
resolve: |
; resolve name |
push esp ; reserve stack place |
push esp ; fourth parameter |
push 0 ; third parameter |
push 0 ; second parameter |
push s ; first parameter |
call [getaddrinfo] |
pop esi |
; test for error |
test eax, eax |
jnz fail |
; convert IP address to decimal notation |
mov eax, [esi+addrinfo.ai_addr] |
mov eax, [eax+sockaddr_in.sin_addr] |
mov [sockaddr1.ip], eax |
push eax |
call [inet_ntoa] |
; write result |
mov [ip_ptr], eax |
push eax |
; free allocated memory |
push esi |
call [freeaddrinfo] |
push str4 |
call [con_write_asciiz] |
mcall socket, AF_INET4, SOCK_RAW, IPPROTO_ICMP |
cmp eax, -1 |
jz fail2 |
mov [socketnum], eax |
mcall connect, [socketnum], sockaddr1, 18 |
mcall 40, 1 shl 7 ; + 7 |
; call [con_cls] |
mov [count], 4 |
mainloop: |
push str3 |
call [con_write_asciiz] |
push [ip_ptr] |
call [con_write_asciiz] |
mcall 26,9 |
mov [time_reference], eax |
mcall send, [socketnum], icmp_packet, icmp_packet.length, 0 |
mcall 23, 300 ; 3 seconds time-out |
mcall 26,9 |
neg [time_reference] |
add [time_reference], eax |
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0 |
cmp eax, -1 |
je .no_response |
; validate the packet |
lea esi, [buffer_ptr + ICMP_Packet.Data] |
mov edi, icmp_packet.data |
mov ecx, 32/4 |
repe cmpsd |
jne .miscomp |
push [time_reference] |
push str7 |
call [con_printf] |
jmp continue |
.miscomp: |
sub edi, icmp_packet.data |
push edi |
push str9 |
call [con_printf] |
jmp continue |
.no_response: |
push str8 |
call [con_write_asciiz] |
continue: |
dec [count] |
jz done |
mcall 5, 100 ; wait a second |
inc [icmp_packet.id] |
jmp mainloop |
done: |
push str10 |
call [con_write_asciiz] |
call [con_getch2] |
push 1 |
call [con_exit] |
exit: |
mcall -1 |
fail: |
push str5 |
call [con_write_asciiz] |
jmp done |
fail2: |
push str6 |
call [con_write_asciiz] |
jmp done |
; data |
title db 'ICMP - echo client',0 |
str2 db '> ',0 |
str3 db 'Ping to ',0 |
str4 db 10,0 |
str5 db 'Name resolution failed.',10,0 |
str6 db 'Could not open socket',10,0 |
str7 db ' time= %u0ms',10,0 |
str8 db ' timeout!',10,0 |
str9 db ' miscompare at offset %u',10,0 |
str10 db 10,'Press any key to exit',0 |
sockaddr1: |
dw AF_INET4 |
.port dw 0 |
.ip dd 0 |
rb 10 |
time_reference dd ? |
ip_ptr dd ? |
count dd ? |
; import |
align 4 |
@IMPORT: |
library network, 'network.obj', console, 'console.obj' |
import network, \ |
getaddrinfo, 'getaddrinfo', \ |
freeaddrinfo, 'freeaddrinfo', \ |
inet_ntoa, 'inet_ntoa' |
import console, \ |
con_start, 'START', \ |
con_init, 'con_init', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_printf, 'con_printf', \ |
con_exit, 'con_exit', \ |
con_gets, 'con_gets',\ |
con_cls, 'con_cls',\ |
con_getch2, 'con_getch2',\ |
con_set_cursor_pos, 'con_set_cursor_pos' |
socketnum dd ? |
icmp_packet: db 8 ; type |
db 0 ; code |
dw 0 ; |
.id dw 0x0000 ; identifier |
.seq dw 0x0001 ; sequence number |
.data db 'abcdefghijklmnopqrstuvwxyz012345678' |
.length = $ - icmp_packet |
I_END: |
buffer_ptr rb BUFFERSIZE |
s rb 1024 |
rb 4096 ; stack |
mem: |
/programs/network/icmp |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/ircc/encodings.inc |
---|
0,0 → 1,317 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
get_next_byte: |
; Load next byte from the packet, translating to cp866 if necessary |
; At input esi = pointer to data, edx = limit of data |
; Output is either (translated) byte in al with CF set or CF cleared. |
mov eax, [encoding] |
jmp [get_byte_table+eax*4] |
get_byte_cp866: |
cmp esi, edx |
jae .nothing |
lodsb |
.nothing: |
ret |
get_byte_cp1251: |
cmp esi, edx |
jae .nothing |
lodsb |
cmp al, 0x80 |
jb @f |
and eax, 0x7F |
mov al, [cp1251_table+eax] |
@@: |
stc |
.nothing: |
ret |
get_byte_utf8: |
; UTF8 decoding is slightly complicated. |
; One character can occupy one or more bytes. |
; The boundary in packets theoretically can be anywhere in data, |
; so this procedure keeps internal state between calls and handles |
; one byte at a time, looping until character is read or packet is over. |
; Globally, there are two distinct tasks: decode byte sequence to unicode char |
; and convert this unicode char to our base encoding (that is cp866). |
; 1. Check that there are data. |
cmp esi, edx |
jae .nothing |
; 2. Load byte. |
lodsb |
movzx ecx, al |
; 3. Bytes in an UTF8 sequence can be of any of three types. |
; If most significant bit is cleared, sequence is one byte and usual ASCII char. |
; First byte of a sequence must be 11xxxxxx, other bytes are 10yyyyyy. |
and al, 0xC0 |
jns .single_byte |
jp .first_byte |
; 4. This byte is not first in UTF8 sequence. |
; 4a. Check that the sequence was started. If no, it is invalid byte |
; and we simply ignore it. |
cmp [utf8_bytes_rest], 0 |
jz get_byte_utf8 |
; 4b. Otherwise, it is really next byte and it gives some more bits of char. |
mov eax, [utf8_char] |
shl eax, 6 |
lea eax, [eax+ecx-0x80] |
; 4c. Decrement number of bytes rest in the sequence. |
; If it goes to zero, character is read, so return it. |
dec [utf8_bytes_rest] |
jz .got_char |
mov [utf8_char], eax |
jmp get_byte_utf8 |
; 5. If the byte is first in UTF8 sequence, calculate the number of leading 1s |
; - it equals total number of bytes in the sequence; some other bits rest for |
; leading bits in the character. |
.first_byte: |
mov eax, -1 |
@@: |
inc eax |
add cl, cl |
js @b |
mov [utf8_bytes_rest], eax |
xchg eax, ecx |
inc ecx |
shr al, cl |
mov [utf8_char], eax |
jmp get_byte_utf8 |
; 6. If the byte is ASCII char, it is the character. |
.single_byte: |
xchg eax, ecx |
.got_char: |
; We got the character, now abandon a possible sequence in progress. |
and [utf8_bytes_rest], 0 |
; Now second task. The unicode character is in eax, and now we shall convert it |
; to cp866. |
cmp eax, 0x80 |
jb .done |
; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1 |
cmp eax, 0x401 |
jz .YO |
cmp eax, 0x451 |
jz .yo |
cmp eax, 0x410 |
jb .unrecognized |
cmp eax, 0x440 |
jb .part1 |
cmp eax, 0x450 |
jae .unrecognized |
sub al, (0x40-0xE0) and 0xFF |
ret |
.part1: |
sub al, 0x10-0x80 |
.nothing: |
.done: |
ret |
.unrecognized: |
mov al, '?' |
stc |
ret |
.YO: |
mov al, 0xF0 |
stc |
ret |
.yo: |
mov al, 0xF1 |
stc |
ret |
print_character: |
pusha |
cmp bl, 13 ; line beginning |
jne nobol |
mov ecx, [pos] |
inc ecx |
boll1: |
dec ecx |
mov eax, ecx |
xor edx, edx |
mov ebx, [textbox_width] |
div ebx |
test edx, edx |
jnz boll1 |
mov [pos], ecx |
jmp newdata |
nobol: |
cmp bl, 10 ; line down |
jne nolf |
addx1: |
inc [pos] |
mov eax, [pos] |
xor edx, edx |
mov ecx, [textbox_width] |
div ecx |
test edx, edx |
jnz addx1 |
mov eax, [pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl, 15 ; character |
jbe newdata |
mov eax, [irc_data] |
shl eax, 8 |
mov al, bl |
mov [irc_data], eax |
mov eax, [pos] |
;---- draw data |
pusha |
and ebx, 0xff |
add eax, [text_start] |
mov [eax], bl |
popa |
;---- draw data |
mov eax, [pos] |
inc eax |
cm1: |
mov ebx, [scroll+4] |
imul ebx, [textbox_width] |
cmp eax, ebx |
jb noeaxz |
mov esi, [text_start] |
add esi, [textbox_width] |
mov edi, [text_start] |
mov ecx, ebx |
rep movsb |
mov esi, [text_start] |
mov ecx, [textbox_width] |
imul ecx, 61 |
add esi, ecx |
mov edi, [text_start] |
mov ecx, [textbox_width] |
imul ecx, 60 |
add edi, ecx |
mov ecx, ebx |
rep movsb |
mov eax, ebx |
sub eax, [textbox_width] |
noeaxz: |
mov [pos], eax |
newdata: |
mov eax, [window_print] |
or [eax + window.flags], FLAG_UPDATED |
popa |
ret |
recode_to_cp866: |
rep movsb |
ret |
recode_to_cp1251: |
xor eax, eax |
jecxz .nothing |
.loop: |
lodsb |
cmp al,0x80 |
jb @f |
mov al, [cp866_table-0x80+eax] |
@@: stosb |
loop .loop |
.nothing: |
ret |
recode_to_utf8: |
jecxz .nothing |
.loop: |
lodsb |
cmp al, 0x80 |
jb .single_byte |
and eax, 0x7F |
mov ax, [utf8_table+eax*2] |
stosw |
loop .loop |
ret |
.single_byte: |
stosb |
loop .loop |
.nothing: |
ret |
recode: |
mov eax, [encoding] |
jmp [recode_proc+eax*4] |
encoding dd UTF8 |
recode_proc dd recode_to_cp866, recode_to_cp1251, recode_to_utf8 |
get_byte_table dd get_byte_cp866, get_byte_cp1251, get_byte_utf8 |
cp1251_table: |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; 8 |
db '?','?','?','?','?',$F9,'?','?' , '?','?','?','?','?','?','?','?' ; 9 |
db '?',$F6,$F7,'?',$FD,'?','?','?' , $F0,'?',$F2,'?','?','?','?',$F4 ; A |
db $F8,'?','?','?','?','?','?',$FA , $F1,$FC,$F3,'?','?','?','?',$F5 ; B |
db $80,$81,$82,$83,$84,$85,$86,$87 , $88,$89,$8A,$8B,$8C,$8D,$8E,$8F ; C |
db $90,$91,$92,$93,$94,$95,$96,$97 , $98,$99,$9A,$9B,$9C,$9D,$9E,$9F ; D |
db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E |
db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F |
; 0 1 2 3 4 5 6 7 8 9 A B C D E F |
utf8_table: |
times 80h dw 0x98C3 ; default placeholder |
; 0x80-0xAF -> 0x90D0-0xBFD0 |
repeat 0x30 |
store byte 0xD0 at utf8_table+2*(%-1) |
store byte 0x90+%-1 at utf8_table+2*%-1 |
end repeat |
; 0xE0-0xEF -> 0x80D1-0x8FD1 |
repeat 0x10 |
store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1) |
store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1 |
end repeat |
; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1 |
store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80) |
cp866_table: |
db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8 |
db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9 |
db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; A |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; B |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; C |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; D |
db $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7 , $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF ; E |
db $A8,$B8,$AA,$BA,$AF,$BF,$A1,$A2 , $B0,$95,$B7,'?',$B9,$A4,'?','?' ; F |
; 0 1 2 3 4 5 6 7 8 9 A B C D E F |
/programs/network/ircc/gui.inc |
---|
0,0 → 1,316 |
draw_window: |
pusha |
mcall 9, thread_info, -1 ; get current window size |
mov eax, dword[thread_info+42] ; window xsize |
mov ebx, dword[thread_info+46] ; ysize |
mov edx, dword[thread_info+62] ; work area xsize |
mov esi, dword[thread_info+66] ; ysize |
sub eax, edx |
sub ebx, esi |
cmp edx, WIN_MIN_X |
jae .x_ok |
mov edx, WIN_MIN_X |
.x_ok: |
mov [xsize], edx |
add edx, eax |
cmp esi, WIN_MIN_Y |
jae .y_ok |
mov esi, WIN_MIN_Y |
.y_ok: |
mov [ysize], esi |
add esi, ebx |
mcall 67, -1, -1 ; set the new sizes |
mcall 12, 1 |
xor eax, eax ; draw window |
mov ebx, WIN_MIN_X |
mov ecx, WIN_MIN_Y |
mov edx, [colors.work] |
add edx, 0x33000000 |
mov edi, str_programname |
mcall |
mcall 12, 2 ;; when do we actually need this?? |
mov ebx, [xsize] |
mov ecx, [ysize] |
sub cx, 15 ;;;; |
push cx |
shl ecx, 16 |
pop cx |
mov edx, [colors.work_graph] |
mcall 38 ; draw line |
mov ecx, TOP_Y SHL 16 + TOP_Y |
mcall |
mov edi, [window_open] |
cmp [edi + window.type], WINDOWTYPE_CHANNEL |
jne .not_channel |
; draw a vertical separator line |
mov ebx, [xsize] |
sub ebx, USERLIST_X + SCROLLBAR_WIDTH + 3 |
push bx |
shl ebx, 16 |
pop bx |
mov ecx, [ysize] |
add ecx, TOP_Y SHL 16 -(15) ;;;; |
mcall |
call redraw_channel_list |
.not_channel: |
mov edx, [edi + window.data_ptr] |
add edx, window_data.text |
call draw_channel_text |
; editbox |
mov eax, [ysize] |
sub eax, 12 ;;;;;; |
mov [edit1.top], eax |
mov eax, [xsize] |
mov [edit1.width], eax |
push dword edit1 |
call [edit_box_draw] |
; tabs |
call draw_windownames |
popa |
ret |
redraw_channel_list: |
; First, calculate scrollbar |
mov ebx, [window_open] |
mov eax, [ebx + window.users] ; number of users in the open window |
mov [scroll1.max_area], eax |
mov eax, [ysize] |
sub eax, TOP_Y + 15 ;;;; |
push eax |
mov [scroll1.y_size], ax |
mov eax, [xsize] |
sub eax, SCROLLBAR_WIDTH |
mov [scroll1.x_pos], ax |
pop eax ; scrollbar height |
xor edx, edx |
mov ecx, 10 |
div ecx |
mov [scroll1.cur_area], eax |
; Do we need a scrollbar? |
cmp eax, [scroll1.max_area] |
jae .noscroll |
; Is the current position greater then the max position? |
cmp eax, [scroll1.position] |
ja @f |
mov [scroll1.position], eax |
@@: |
; OK, draw the scrollbar |
mov [scroll1.all_redraw], 1 |
push dword scroll1 |
call [scrollbar_v_draw] |
jmp print_channel_list |
.noscroll: |
mov [scroll1.position], 0 |
print_channel_list: |
pusha |
; Now, draw the usernames themselves |
; first, draw an invisible button |
mov ebx, [xsize] |
sub ebx, USERLIST_X + SCROLLBAR_WIDTH |
shl ebx, 16 |
push ebx |
mov bx, USERLIST_X |
mov ecx, [ysize] |
add ecx, TEXT_Y shl 16 - (TEXT_Y + 15) ;;;;; + 10??? |
push ecx ebx |
mov edx, 50 + 1 shl 29 + 1 shl 30 |
mcall 8 |
; now draw rectangle to clear the names |
pop ebx ecx |
mov edx, [colors.work] |
mcall 13 |
; now draw the names according with scrollbar position and window size |
mov eax, [scroll1.position] |
xor edx, edx |
mov ecx, MAX_NICK_LEN |
mul ecx |
mov edx, eax |
mov eax, [window_open] |
mov ebp, [eax + window.selected] |
add edx, [eax + window.data_ptr] |
sub ebp, [scroll1.position] |
add edx, window_data.names |
pop ebx |
mov bx, TEXT_Y |
mov ecx, [colors.work_text] |
or ecx, 0x80000000 ; ASCIIZ string |
mov eax, 4 ; draw text |
mov edi, [ysize] ; Calculate how many names will fit on screen |
sub edi, TEXT_Y + 15 ;+ 10 ;;;;; |
.loop: |
cmp byte[edx], 0 ; end of list? |
je .done |
dec ebp ; is this name selected? |
jnz .nothighlight |
; yes, highlight it |
pusha |
mov cx, bx |
mov bx, USERLIST_X |
shl ecx, 16 |
mov cx, 10 - 1 |
mov edx, 0x00000055 ; blue! |
mcall 13 |
popa |
mov ecx, 0x8000ffff ; cyan! |
mcall |
mov ecx, [colors.work_text] |
or ecx, 0x80000000 ; ASCIIZ string |
jmp .next |
.nothighlight: |
mcall |
.next: |
add edx, MAX_NICK_LEN ; next name |
add ebx, 10 ; height distance between lines |
sub edi, 10 |
ja .loop |
.done: |
popa |
ret |
draw_channel_text: |
pusha |
mov eax, 4 ; draw text |
mov ebx, TEXT_X shl 16 + TEXT_Y |
mov ecx, 12 ; 12 lines max ? |
mov esi, [textbox_width] |
.dct: |
pusha |
mov cx, bx |
shl ecx, 16 |
mov cx, 9 ; character height |
mov eax, 13 ; draw rectangle |
mov ebx, TEXT_X shl 16 |
mov bx, word[textbox_width] |
imul bx, 6 ; character width |
mov edx, [colors.work] |
mcall |
popa |
push ecx |
mov ecx, [colors.work_text] |
cmp word[edx], '* ' |
jne .no_red |
mov ecx, 0x00aa0000 |
jmp .draw |
.no_red: |
cmp word[edx], '**' |
jne .no_light_blue |
cmp byte[edx+2], '*' |
jne .no_light_blue |
mov ecx, 0x000000aa |
jmp .draw |
.no_light_blue: |
cmp byte[edx], '#' |
jne .no_blue |
mov ecx, 0x0000aa00 |
; jmp .draw |
.no_blue: |
.draw: |
mcall |
add edx, [textbox_width] |
add ebx, 10 ; height distance between lines |
pop ecx |
loop .dct |
popa |
ret |
draw_windownames: |
mov eax, 8 |
mov ebx, 5 shl 16 + 120 |
mov ecx, 12 shl 16 + 12 |
mov edx, WINDOW_BTN_START |
mov edi, windows |
.more_btn: |
mov esi, [colors.work_button] |
cmp [window_open], edi |
jne @f |
not esi |
and esi, 0x00ffffff |
@@: |
mcall |
inc edx |
add ebx, 125 shl 16 |
add edi, sizeof.window |
cmp [edi + window.data_ptr], 0 |
jne .more_btn |
mov eax, 4 |
mov ebx, 10 shl 16 + 15 |
mov ecx, [colors.work_button_text] |
or ecx, 0x80000000 ; ASCIIZ string |
lea edx, [windows + window.name] |
mov esi, MAX_WINDOWS |
.more: |
mcall |
add edx, sizeof.window |
cmp byte[edx], 0 |
je .enough |
add ebx, 125 shl 16 |
dec esi |
jnz .more |
.enough: |
ret |
/programs/network/ircc/ircc.asm |
---|
0,0 → 1,476 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; IRC client for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org, ;; |
;; text encoder/decoder by Clevermouse. ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.1' |
; connection status |
STATUS_DISCONNECTED = 0 |
STATUS_RESOLVING = 1 |
STATUS_CONNECTING = 2 |
STATUS_CONNECTED = 3 |
; window flags |
FLAG_UPDATED = 1 shl 0 |
FLAG_CLOSE = 1 shl 1 |
FLAG_RECEIVING_NAMES = 1 shl 2 |
; window types |
WINDOWTYPE_SERVER = 0 |
WINDOWTYPE_CHANNEL = 1 |
WINDOWTYPE_CHAT = 2 |
WINDOWTYPE_LIST = 3 |
WINDOWTYPE_DCC = 4 |
; supported encodings |
CP866 = 0 |
CP1251 = 1 |
UTF8 = 2 |
; settings |
USERCMD_MAX_SIZE = 400 |
WIN_MIN_X = 600 |
WIN_MIN_Y = 165 |
TEXT_X = 5 |
TEXT_Y = 30 |
TOP_Y = 25 |
MAX_WINDOWS = 20 |
MAX_USERS = 4096 |
MAX_NICK_LEN = 32 |
MAX_REAL_LEN = 32 ; realname |
MAX_SERVER_NAME = 256 |
MAX_CHANNEL_LEN = 40 |
MAX_CHANNELS = 37 |
MAX_COMMAND_LEN = 512 |
TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp |
MAX_WINDOWNAME_LEN = 256 |
WINDOW_BTN_START = 100 |
SCROLLBAR_WIDTH = 12 |
USERLIST_X = 98 |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; header version |
dd START ; program start |
dd I_END ; program image size |
dd IM_END+2048 ; required amount of memory |
dd IM_END+2048 |
dd param |
dd path |
include "../macros.inc" |
include "../proc32.inc" |
include "../dll.inc" |
include "../network.inc" |
include "../struct.inc" |
include '../../../../../programs/develop/libraries/box_lib/trunk/box_lib.mac' |
struct window |
data_ptr dd ? ; zero if not used |
flags db ? |
type db ? |
name rb MAX_WINDOWNAME_LEN |
users dd ? |
users_scroll dd ? |
selected dd ? ; selected user, 0 if none selected |
ends |
struct window_data |
text rb 120*60 |
title rb 256 |
names rb MAX_NICK_LEN * MAX_USERS |
usertext rb 256 |
usertextlen dd ? |
ends |
include "encodings.inc" |
include "window.inc" ; also contains text print routines |
include "serverparser.inc" |
include "userparser.inc" |
include "socket.inc" |
include "gui.inc" |
include "users.inc" |
START: |
mcall 68, 11 ; init heap so we can allocate memory dynamically |
; wanted events |
mcall 40, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK + EVM_MOUSE |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; find path to main settings file (ircc.ini) |
mov edi, path ; Calculate the length of zero-terminated string |
xor al, al |
mov ecx, 1024 |
repne scasb |
dec edi |
mov eax, '.ini' |
stosd |
xor al, al |
stosb |
; Fill the window buffer with zeros |
mov edi, windows |
mov ecx, (sizeof.window*MAX_WINDOWS+3)/4 |
xor eax, eax |
rep stosd |
; clear command area too |
mov edi, servercommand |
mov ecx, 600/4 |
rep stosd |
; allocate window data block |
call window_create |
mov ebx, windows |
mov [ebx + window.data_ptr], eax |
mov [ebx + window.flags], 0 |
mov [ebx + window.type], WINDOWTYPE_SERVER |
add eax, window_data.text |
mov [text_start], eax |
call window_refresh |
; get system colors |
mcall 48, 3, colors, 40 |
; set edit box and scrollbar colors |
mov eax, [colors.work] |
mov [scroll1.bg_color], eax |
mov eax, [colors.work_button] |
mov [scroll1.front_color], eax |
mov eax, [colors.work_text] |
mov [scroll1.line_color], eax |
; get settings from ini |
invoke ini.get_str, path, str_user, str_nick, user_nick, MAX_NICK_LEN, default_nick |
invoke ini.get_str, path, str_user, str_real, user_real_name, MAX_REAL_LEN, default_real |
; Welcome user |
mov esi, str_welcome |
call print_text2 |
call draw_window ;;; FIXME (gui is not correctly drawn first time) |
redraw: |
call draw_window |
still: |
; wait here for event |
mcall 10 |
dec eax |
jz redraw |
dec eax |
jz main_window_key |
dec eax |
jz button |
cmp al, 3 |
je mouse |
call process_network_event |
mov edx, [window_open] |
test [edx + window.flags], FLAG_UPDATED |
jz .no_update |
and [edx + window.flags], not FLAG_UPDATED |
mov edx, [edx + window.data_ptr] |
add edx, window_data.text |
call draw_channel_text |
.no_update: |
call print_channel_list |
jmp still |
button: |
mcall 17 ; get id |
shr eax, 8 |
cmp ax, 1 ; close program |
je exit |
cmp ax, 50 |
jne @f |
mcall 37, 1 ; Get mouse position |
sub ax, TEXT_Y |
mov bl, 10 |
div bl |
and eax, 0x000000ff |
inc eax |
add eax, [scroll1.position] |
mov ebx, [window_open] |
mov [ebx + window.selected], eax |
call print_channel_list |
jmp still |
@@: |
sub ax, WINDOW_BTN_START |
jb exit |
cmp ax, MAX_WINDOWS |
ja exit |
mov dx, sizeof.window |
mul dx |
shl edx, 16 |
mov dx, ax |
add edx, windows |
cmp [edx + window.data_ptr], 0 |
je exit |
mov [window_open], edx |
call window_refresh |
call draw_window |
jmp still |
exit: |
mcall -1 |
main_window_key: |
mcall 2 |
push dword edit1 |
call [edit_box_key] |
cmp ah, 13 ; enter |
jne no_send2 |
call user_parser |
mov [edit1.size], 0 |
mov [edit1.pos], 0 |
push dword edit1 |
call [edit_box_draw] |
mov edx, [window_open] |
mov edx, [edx + window.data_ptr] |
add edx, window_data.text |
call draw_channel_text |
jmp still |
no_send2: |
jmp still |
mouse: |
push dword edit1 |
call [edit_box_mouse] |
; TODO: check if scrollbar is active |
push [scroll1.position] |
push dword scroll1 |
call [scrollbar_v_mouse] |
pop eax |
cmp eax, [scroll1.position] ; did the scrollbar move? |
je @f |
call print_channel_list |
@@: |
jmp still |
; DATA AREA |
encoding_text: |
db 'CP866 ' |
db 'CP1251' |
db 'UTF-8 ' |
encoding_text_len = 6 |
action_header db '*** ', 0 |
action_header_short db '* ', 0 |
ctcp_header db '-> [',0 |
ctcp_version db '] VERSION',10,0 |
ctcp_ping db '] PING',10,0 |
ctcp_time db '] TIME',10,0 |
has_left_channel db ' has left ', 0 |
joins_channel db ' has joined ', 0 |
is_now_known_as db ' is now known as ', 0 |
has_quit_irc db ' has quit IRC', 10, 0 |
sets_mode db ' sets mode ', 0 |
kicked db ' is kicked from ', 0 |
str_talking db 'Now talking in ',0 |
str_topic db 'Topic is ',0 |
str_setby db 'Set by ',0 |
str_version db 'VERSION ' |
str_programname db 'KolibriOS IRC client ', version, 0 |
str_user db 'user', 0 |
str_nick db 'nick', 0 |
str_real db 'realname', 0 |
str_email db 'email', 0 |
default_nick db 'kolibri_user', 0 |
default_real db 'Kolibri User', 0 |
str_welcome db 10 |
db ' ______________________ __ __ __',10 |
db '| \______ \_ ___ \ ____ | | |__| ____ _____/ |_',10 |
db '| || _/ \ \/ _/ ___\| | | |/ __ \ / \ __\',10 |
db '| || | \ \____ \ \___| |_| \ ___/| | \ |',10 |
db '|___||____|_ /\______ / \___ >____/__|\___ >___| /__|',10 |
db ' \/ \/ \/ \/ \/',10 |
db 10 |
db 'Welcome to IRC client ',version,' for KolibriOS',10 |
db 10 |
db 'Type /help for help',10,0 |
str_nickchange db 'Nickname is now ',0 |
str_realchange db 'Real name is now ',0 |
str_dotnewline db '.',10, 0 |
str_newline db 10, 0 |
str_connecting db 10,'* Connecting to ',0 |
str_help db 10,'following commands are available:',10 |
db 10 |
db '/nick <nick> : change nickname to <nick>',10 |
db '/real <real name> : change real name to <real name>',10 |
db '/server <address> : connect to server <address>',10 |
db '/code <code> : change codepage to cp866, cp1251, or utf8',10,0 |
str_1 db ' -',0 |
str_2 db '- ',0 |
str_sockerr db 'Socket Error',10,0 |
str_dnserr db 'Unable to resolve hostname.',10,0 |
str_refused db 'Connection refused',10,0 |
sockaddr1: |
dw AF_INET4 |
.port dw 0x0b1a ; 6667 |
.ip dd 0 |
rb 10 |
status dd STATUS_DISCONNECTED |
text_start dd ? ; pointer to current textbox data |
irc_data dd 0x0 ; encoder |
textbox_width dd 80 ; in characters, not pixels ;) |
pos dd 66 * 11 ; encoder |
window_open dd windows |
window_print dd windows |
scroll dd 1 |
dd 12 |
align 4 |
@IMPORT: |
library network, 'network.obj',\ |
libini, 'libini.obj',\ |
boxlib, 'box_lib.obj' |
import network,\ |
getaddrinfo, 'getaddrinfo',\ |
freeaddrinfo, 'freeaddrinfo',\ |
inet_ntoa, 'inet_ntoa' |
import libini,\ |
ini.get_str, 'ini_get_str',\ |
ini.get_int, 'ini_get_int' |
import boxlib,\ |
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' |
usercommand db '/server chat.freenode.net', 0 |
rb MAX_COMMAND_LEN |
I_END: |
; width, left, top |
edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25 |
; xsize, xpos, ysize, ypos, max, cur, pos, bgcol, frcol, linecol |
scroll1 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 1 |
scroll2 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 1 |
main_PID dd ? ; identifier of main thread |
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence |
utf8_char dd ? ; first bits of current UTF8 character |
gai_reqdata rb 32 ; buffer for getaddrinfo_start/process |
ip_list dd ? ; will be filled as pointer to addrinfo list |
packetbuf rb 1024 ; buffer for packets to server |
path rb 1024 |
param rb 1024 |
socketnum dd ? |
servercommand rb 600 |
thread_info rb 1024 |
xsize dd ? |
ysize dd ? |
colors system_colors |
irc_server_name rb MAX_SERVER_NAME |
user_nick rb MAX_NICK_LEN |
user_real_name rb MAX_REAL_LEN |
windows rb MAX_WINDOWS*sizeof.window |
mouse_dd dd ? |
IM_END: |
/programs/network/ircc/ircc.ini |
---|
0,0 → 1,8 |
[user] |
nick = kolibri_user |
realname = tetten |
[colors] |
action1 = 0x000000aa |
action2 = 0x0000aa00 |
action3 = 0x00aa0000 |
/programs/network/ircc/serverparser.inc |
---|
0,0 → 1,928 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
server_parser: |
mov esi, servercommand |
cmp byte [esi], ':' |
jne .parse |
.spaceloop: |
lodsb |
test al, al |
jz .fail |
cmp al, ' ' |
jne .spaceloop |
.parse: |
mov eax, [esi] |
or eax, 0x20202020 |
mov edi, server_commands |
mov ecx, server_commands.number |
.loop: |
scasd |
je .got_cmd |
add edi, 4 |
dec ecx |
jnz .loop |
.fail: |
ret |
.got_cmd: |
jmp dword[edi] |
server_commands: |
dd '322 ', cmd_322 ; RPL_LIST |
dd '323 ', cmd_323 ; RPL_LISTEND |
dd '328 ', cmd_328 |
dd '332 ', cmd_topic |
dd '333 ', cmd_333 ; nickname and time of topic |
dd '353 ', cmd_353 ; name reply |
dd '366 ', cmd_366 ; end of names list |
dd '372 ', cmd_372 ; motd |
dd '375 ', cmd_375 ; start of motd |
dd '376 ', cmd_376 ; end of motd |
dd '421 ', cmd_421 ; unknown command |
dd 'join', cmd_join |
dd 'kick', cmd_kick |
dd 'mode', cmd_mode |
dd 'nick', cmd_nick |
dd 'part', cmd_part |
dd 'ping', cmd_ping |
dd 'priv', cmd_privmsg |
dd 'quit', cmd_quit |
dd 'noti', cmd_notice |
.number = ($ - server_commands) / 8 |
align 4 |
compare_to_nick: |
push esi |
mov ecx, MAX_NICK_LEN |
mov esi, user_nick |
.loop: |
lodsb |
cmp al, ' ' |
jbe .done |
cmp al, 'a' |
jb .ok |
cmp al, 'z' |
ja .ok |
sub al, 0x20 |
.ok: |
mov bl, byte[edi] |
cmp bl, 'a' |
jb .ok2 |
cmp bl, 'z' |
ja .ok2 |
sub bl, 0x20 |
.ok2: |
cmp bl, al |
jne .not_equal |
inc edi |
dec ecx |
jnz .loop |
.done: |
xor eax, eax |
pop esi |
ret |
.not_equal: |
or eax, -1 |
pop esi |
ret |
align 4 |
skip_nick: |
; First: skip the NICK (maybe we should verify it?) |
.nick: |
lodsb |
cmp al, ' ' |
je .skip |
cmp al, ':' |
je .skip |
jmp .nick |
; skip all leading spaces and semicolons |
.skip: |
lodsb |
cmp al, ' ' |
je .skip |
cmp al, ':' |
je .skip |
dec esi |
ret |
align 4 |
find_window: ; esi is ptr to windowname |
push esi |
mov edi, esi |
call compare_to_nick |
jne .nochat |
mov esi, servercommand+1 |
.nochat: |
; now search for window in list |
mov ebx, windows |
mov [window_print], ebx ; set first window (server window) as default output window |
.scanloop: |
cmp [ebx + window.data_ptr], 0 |
je .create_it |
push esi |
lea edi, [ebx + window.name] |
mov ecx, MAX_WINDOWNAME_LEN |
repe cmpsb |
pop esi |
cmp byte[edi-1], 0 |
je .got_it |
add ebx, sizeof.window |
; TODO: check buffer limits ? |
jmp .scanloop |
; create channel window - search for empty slot |
.create_it: |
mov ebx, windows |
mov ecx, MAX_WINDOWS |
.scanloop2: |
cmp [ebx + window.data_ptr], 0 |
je .free_found |
add ebx, sizeof.window |
dec ecx |
jnz .scanloop2 |
; Error: no more available windows! |
jmp .just_skip |
.free_found: |
push ebx |
call window_create |
pop ebx |
test eax, eax |
jz .just_skip |
mov [ebx + window.data_ptr], eax |
mov [ebx + window.type], WINDOWTYPE_CHAT |
mov [ebx + window.flags], 0 |
call window_set_name |
mov [window_open], ebx |
mov [window_print], ebx |
call window_refresh |
call draw_windownames |
jmp .just_skip |
; found it! |
.got_it: |
mov [window_print], ebx |
call window_refresh |
.just_skip: |
pop esi |
.skip1: |
; skip text |
lodsb |
test al, al |
jz .quit |
cmp al, ' ' |
jne .skip1 |
dec esi |
; now skip trailing spaces and semicolons |
.skip2: |
lodsb |
test al, al |
jz .quit |
cmp al, ' ' |
je .skip2 |
cmp al, ':' |
je .skip2 |
dec esi |
.quit: |
ret |
cmd_328: |
cmd_421: |
cmd_372: |
cmd_375: |
cmd_376: |
add esi, 4 |
jmp cmd_notice.loop |
cmd_notice: |
cmp byte[servercommand], ':' |
jne .gogogo |
mov byte [esi-1], 0 |
push esi |
mov esi, str_1 |
call print_text2 |
mov esi, servercommand+1 |
call print_text2 |
mov esi, str_2 |
call print_text2 |
pop esi |
.gogogo: |
add esi, 6 |
.loop: |
inc esi |
cmp byte [esi], 0 |
je .fail |
cmp byte [esi], ' ' |
jne .loop |
.loop2: |
inc esi |
cmp byte [esi], 0 |
je .fail |
cmp byte [esi], ' ' |
je .loop2 |
cmp byte [esi], ':' |
je .loop2 |
call print_text2 |
mov esi, str_newline |
call print_text2 |
.fail: |
ret |
cmd_ping: |
; Just change PING to PONG |
mov dword[esi], 'PONG' |
; Find the end of the command |
lea edi, [esi + 5] |
xor al, al |
repne scasb |
; Now send it back |
mov edx, esi |
mov esi, edi |
mov word [esi], 0x0d0a |
inc esi |
inc esi |
sub esi, edx |
mcall send, [socketnum], , , 0 |
ret |
cmd_privmsg: |
add esi, 8 ; skip 'PRIVMSG ' |
call find_window ; esi now points to end of destination name |
cmp byte[esi], 1 |
je cmd_ctcp |
cmp dword[esi], 'ACTI' ; Action? |
je .action |
; nope, just plain old privmsg |
if TIMESTAMP |
call print_timestamp |
end if |
push esi |
mov bl, '<' |
call print_character |
mov eax, servercommand+1 |
mov dl, '!' |
call print_text |
mov bl, '>' |
call print_character |
mov bl, ' ' |
call print_character |
pop esi |
call print_text2 |
mov bl, 10 |
call print_character |
.fail: |
ret |
.action: |
add esi, 8 |
push esi |
if TIMESTAMP |
call print_timestamp |
end if |
mov esi, action_header_short |
call print_text2 |
mov eax, servercommand+1 |
mov dl, ' ' |
call print_text |
mov bl, ' ' |
call print_character |
pop esi |
call print_text2 |
mov bl, 10 |
call print_character |
ret |
cmd_ctcp: |
inc esi |
cmp dword[esi], 'VERS' |
je .version |
cmp dword[esi], 'TIME' |
je .time |
cmp dword[esi], 'PING' |
je .ping |
ret |
.time: |
mov byte [esi+4], ' ' |
lea edi, [esi+5] |
; TODO: add system date (fn 29) in human readable format |
mcall 3 ; get system time |
mov ecx, 3 |
.timeloop: |
mov bl, al |
shr al, 4 |
add al, '0' |
stosb |
mov al, bl |
and al, 0x0f |
add al, '0' |
stosb |
dec ecx |
jz .timedone |
mov al, ':' |
stosb |
shr eax, 8 |
jmp .timeloop |
.timedone: |
xor al, al |
stosb |
call ctcp_reply |
if TIMESTAMP |
call print_timestamp |
end if |
mov esi, ctcp_header |
call print_text2 |
mov esi, servercommand+1 |
call print_text2 |
mov esi, ctcp_time |
call print_text2 |
ret |
.version: |
mov esi, str_version |
call ctcp_reply |
if TIMESTAMP |
call print_timestamp |
end if |
mov esi, ctcp_header |
call print_text2 |
mov esi, servercommand+1 |
call print_text2 |
mov esi, ctcp_version |
call print_text2 |
ret |
.ping: |
call ctcp_reply |
if TIMESTAMP |
call print_timestamp |
end if |
mov esi, ctcp_header |
call print_text2 |
mov esi, servercommand+1 |
call print_text2 |
mov esi, ctcp_ping |
call print_text2 |
ret |
ctcp_reply: |
push esi |
mov dword [usercommand], 'NOTI' |
mov dword [usercommand+4], 'CE ' |
mov esi, servercommand+1 |
mov edi, usercommand+7 |
.nickloop: |
lodsb |
cmp al, '!' |
je .done |
cmp al, ' ' |
je .done |
test al, al |
je .fail |
stosb |
jmp .nickloop |
.done: |
mov byte [esi-1], 0 |
mov ax, ' :' |
stosw |
mov al, 1 |
stosb |
pop esi |
.replyloop: |
lodsb |
cmp al, 1 |
jbe .done2 |
stosb |
jmp .replyloop |
.done2: |
mov al, 1 |
stosb |
mov ax, 0x0a0d |
stosw |
lea esi, [edi - usercommand] |
mcall send, [socketnum], usercommand, , 0 |
.fail: |
ret |
cmd_part: |
add esi, 5 ; skip 'PART ' |
push esi |
call skip_nick |
call find_window |
pop esi |
; Is it me who parted? |
mov edi, servercommand+1 |
call compare_to_nick |
jne .dont_close |
; yes, close the window |
mov edi, [window_print] |
mov [edi + window.flags], FLAG_UPDATED + FLAG_CLOSE |
ret |
; somebody else parted, just print message |
.dont_close: |
push esi |
mov esi, action_header |
call print_text2 |
mov eax, servercommand+1 |
mov dl, '!' |
mov cl, ' ' |
call print_text |
mov esi, has_left_channel |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
mov ebx, [window_print] |
mov esi, servercommand+1 |
call user_remove |
ret |
cmd_join: |
add esi, 5 ; skip 'JOIN ' |
; compare nick: did we join a channel? |
mov edi, servercommand+1 |
call compare_to_nick |
jne .no_new_window |
; create channel window - search for empty slot |
mov ebx, windows |
mov ecx, MAX_WINDOWS |
.loop: |
cmp [ebx + window.data_ptr], 0 |
je .free_found |
add ebx, sizeof.window |
dec ecx |
jnz .loop |
; Error: no more available windows!! ;;;;; TODO |
.fail: |
ret |
.free_found: |
push ebx |
call window_create |
pop ebx |
test eax, eax |
jz .fail |
mov [ebx + window.data_ptr], eax |
mov [ebx + window.type], WINDOWTYPE_CHANNEL |
mov [ebx + window.flags], 0 |
call window_set_name |
mov [window_open], ebx |
mov [window_print], ebx |
call window_refresh |
push esi |
mov esi, action_header |
call print_text2 |
mov esi, str_talking |
call print_text2 |
pop eax |
mov dl, ' ' |
call print_text |
mov esi, str_dotnewline |
call print_text2 |
call draw_window |
ret |
.no_new_window: |
push esi |
call find_window |
mov esi, action_header |
call print_text2 |
mov eax, servercommand+1 |
mov dl, '!' |
call print_text |
mov esi, joins_channel |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
mov ebx, [window_print] |
mov esi, servercommand+1 |
call user_add |
ret |
cmd_nick: |
; NOTE: This command applies to a user, and thus has no specific channel |
add esi, 5 ; skip 'NICK ' |
cmp byte[esi], ':' ; TODO: skip all spaces and semicolons? |
jne @f |
inc esi |
@@: |
; Change the nick in the current userlist. TODO: check other channels too! |
push esi |
mov ebx, [window_print] |
mov esi, servercommand+1 |
call user_remove |
mov esi, [esp] |
call user_add |
call redraw_channel_list |
; Is it me who changed nick? |
mov edi, servercommand+1 |
call compare_to_nick |
pop esi |
jne .not_me |
mov ecx, MAX_NICK_LEN-1 |
push esi |
.copyloop: |
lodsb |
test al, al |
jz .copydone |
cmp al, ' ' |
je .copydone |
stosb |
dec ecx |
jnz .copyloop |
.copydone: |
xor al, al |
stosb |
pop esi |
.not_me: |
; Now print a message on the current channel |
push esi |
mov esi, action_header_short |
call print_text2 |
mov eax, servercommand+1 |
mov dl, '!' |
call print_text |
mov esi, is_now_known_as |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
ret |
cmd_kick: |
add esi, 5 ; skip 'KICK ' |
; Is it me who got kicked? |
mov edi, servercommand+1 |
call compare_to_nick |
jne .not_me |
; TODO: mark channel as disconnected |
.not_me: |
; find the channel user has been kicked from |
push esi |
call skip_nick |
call find_window |
mov esi, action_header_short |
call print_text2 |
mov eax, servercommand+1 |
mov dl, '!' |
call print_text |
mov esi, kicked |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
mov ebx, [window_print] |
mov esi, servercommand+1 |
call user_remove |
ret |
cmd_quit: |
; NOTE: This command applies to a user, and thus has no specific channel |
mov esi, action_header |
call print_text2 |
mov eax, servercommand+1 |
mov dl, '!' |
call print_text |
mov esi, has_quit_irc |
call print_text2 |
; TODO: check other channels on same server too! |
mov ebx, [window_print] |
mov esi, servercommand+1 |
call user_remove |
ret |
cmd_mode: |
add esi, 5 ; skip 'MODE ' |
push esi |
mov esi, action_header_short |
call print_text2 |
mov eax, servercommand+1 |
mov dl, ' ' |
call print_text |
mov esi, sets_mode |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
;;; TODO: change username if needed |
ret |
cmd_353: ; channel usernames reply |
add esi, 4 ; skip '353 ' |
call skip_nick |
inc esi ; channel type '*', '=' or '@' |
inc esi ; ' ' |
call find_window |
; now find window ptr and check if this is the first 353 message |
mov ebx, [window_print] |
test [ebx + window.flags], FLAG_RECEIVING_NAMES |
jnz .add |
or [ebx + window.flags], FLAG_RECEIVING_NAMES |
; mov [ebx + window.users], 0 |
; TODO: remove all users? |
.add: |
push esi |
call user_add |
pop esi |
.namesloop: |
lodsb |
test al, al |
jz .done |
cmp al, ' ' ; names list is separated with spaces |
jne .namesloop |
jmp .add |
.done: |
call redraw_channel_list |
ret |
cmd_366: ; channel usernames end |
add esi, 4 ; skip '366 ' |
call skip_nick |
call find_window |
mov ebx, [window_print] |
and [ebx + window.flags], not FLAG_RECEIVING_NAMES |
ret |
cmd_topic: |
add esi, 4 ; skip '332 ' |
call skip_nick |
call find_window |
push esi |
mov esi, action_header |
call print_text2 |
mov esi, str_topic |
call print_text2 |
pop esi |
call print_text2 |
mov esi, str_newline |
call print_text2 |
ret |
cmd_333: |
add esi, 4 ; skip '333 ' |
call skip_nick ;;;; |
call find_window |
; mov ecx, 2 ; number of spaces to find ;;; CHECKME |
; .loop: |
; lodsb |
; test al, al |
; je .fail |
; cmp al, ' ' |
; jne .loop |
; dec ecx |
; jnz .loop ; find some more spaces |
push esi |
mov esi, action_header |
call print_text2 |
mov esi, str_setby |
call print_text2 |
; pop esi |
; call print_text2 |
pop eax |
mov dl, '!' |
call print_text |
mov esi, str_newline |
call print_text2 |
.fail: |
ret |
cmd_322: |
add esi, 4 |
call skip_nick |
call print_text2 |
mov esi, str_newline |
call print_text2 |
ret |
cmd_323: |
ret |
/programs/network/ircc/socket.inc |
---|
0,0 → 1,242 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
socket_connect: |
; cmp [status], STATUS_CONNECTED ; TODO |
; je disconnect |
; ignore if status is not "disconnected" |
cmp [status], STATUS_DISCONNECTED |
jne .nothing |
mov esi, str_connecting |
call print_text2 |
mov esi, irc_server_name |
call print_text2 |
mov esi, str_dotnewline |
call print_text2 |
; update status |
inc [status] ; was STATUS_DISCONNECTED, now STATUS_RESOLVING |
; resolve name |
push esp ; reserve stack place |
push esp ; fourth parameter |
push 0 ; third parameter |
push 0 ; second parameter |
push irc_server_name |
call [getaddrinfo] |
pop esi |
; test for error |
test eax, eax |
jnz .fail_dns |
; fill in ip in sockstruct |
mov eax, [esi + addrinfo.ai_addr] |
mov eax, [eax + sockaddr_in.sin_addr] |
mov [sockaddr1.ip], eax |
; free allocated memory |
push esi |
call [freeaddrinfo] |
; update status |
inc [status] |
; connect |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
jz .fail |
mov [socketnum], eax |
mcall connect, [socketnum], sockaddr1, 18 |
cmp eax, -1 |
jz .fail_refused |
.nothing: |
ret |
.fail: |
mov [status], STATUS_DISCONNECTED |
mov esi, str_sockerr |
call print_text2 |
ret |
.fail_dns: |
mov [status], STATUS_DISCONNECTED |
mov esi, str_dnserr |
call print_text2 |
ret |
.fail_refused: |
mov [status], STATUS_DISCONNECTED |
mov esi, str_refused |
call print_text2 |
ret |
socket_write_userinfo: |
; create packet in packetbuf |
mov edi, packetbuf |
mov eax, 'NICK' |
stosd |
mov al, ' ' |
stosb |
mov esi, user_nick |
mov ecx, MAX_NICK_LEN |
.loop: |
lodsb |
test al, al |
jz .done |
stosb |
dec ecx |
jnz .loop |
.done: |
mov ax, 0x0d0a |
stosw |
mov eax, 'USER' |
stosd |
mov al, ' ' |
stosb |
mov esi, user_nick |
mov ecx, MAX_NICK_LEN |
.loop2: |
lodsb |
test al, al |
jz .done2 |
stosb |
dec ecx |
jnz .loop2 |
.done2: |
mov eax, ' 8 *' |
stosd |
mov ax, ' :' |
stosw |
mov al, ' ' |
stosb |
mov esi, user_real_name |
mov ecx, MAX_REAL_LEN |
.loop3: |
lodsb |
test al, al |
jz .done3 |
stosb |
dec ecx |
jnz .loop3 |
.done3: |
mov ax, 0x0d0a |
stosw |
lea esi, [edi - packetbuf] |
mcall send, [socketnum], packetbuf, , 0 |
ret |
process_network_event: |
; values for status: 0, 1, 2, 3 |
mov eax, [status] |
dec eax |
; 0 = STATUS_DISCONNECTED - do nothing |
; (ignore network events if we are disconnected from network) |
js .nothing |
; 1 = STATUS_RESOLVING |
jz .nothing |
; 2 = STATUS_CONNECTING |
dec eax |
jz .connecting |
; 3 = STATUS_CONNECTED |
jmp .connected |
.nothing: |
ret |
.connecting: |
call socket_write_userinfo |
; The connection has been established, change status from "connecting" to "connected". |
inc [status] |
.connected: |
call read_incoming_data |
ret |
disconnect: |
cmp [status], STATUS_DISCONNECTED |
je .nothing |
mcall close, [socketnum] |
mov [status], STATUS_DISCONNECTED |
.nothing: |
ret |
read_incoming_data: |
pusha |
; TODO: read more data if we receive one full packet |
.nextpacket: |
mcall recv, [socketnum], packetbuf, 1024 ; read a packet |
inc eax ; check if we got one |
jz .done |
dec eax |
jz .done |
; ok we have data, now feed it to the recoder |
lea edx, [packetbuf + eax] ; edx = end pointer |
mov esi, packetbuf ; esi = start pointer |
.nextcommand: |
mov edi, servercommand |
.byteloop: |
call get_next_byte ; reads byte from [esi] to al |
jnc .nextpacket ; if CF is set, we need more data |
cmp al, 10 |
je .got_command |
cmp al, 13 |
je .got_command |
stosb |
jmp .byteloop |
; we have a command, call the serverparser |
.got_command: |
mov byte[edi], 0 ; mark the end of the command |
push esi edx |
call server_parser |
pop edx esi |
jmp .nextcommand |
.done: |
popa |
ret |
/programs/network/ircc/userparser.inc |
---|
0,0 → 1,318 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
user_parser: |
mov eax, [edit1.size] |
mov word [usercommand + eax], 0x0a0d ; terminate the line |
cmp byte[usercommand], '/' ; is it a server command ? |
je server_command |
; Ignore data commands when not connected. |
cmp [status], STATUS_CONNECTED |
jne sdts_ret |
; Ok, we said something, print it to our textbox |
; TODO: dont send if it's a server window? |
push [window_open] ; print to the current window |
pop [window_print] |
call window_refresh |
if TIMESTAMP |
call print_timestamp |
end if |
mov bl, '<' |
call print_character |
mov esi, user_nick |
call print_text2 |
mov bl,'>' |
call print_character |
mov bl,' ' |
call print_character |
mov eax, [edit1.size] |
mov byte[usercommand + eax],0 |
mov esi, usercommand |
call print_text2 |
mov bl, 10 |
call print_character |
; and now send it to the server |
mov dword[packetbuf], 'priv' |
mov dword[packetbuf+4], 'msg ' |
mov esi, [window_open] |
add esi, window.name |
mov edi, packetbuf+8 |
mov ecx, MAX_WINDOWNAME_LEN |
.loop: |
lodsb |
test al, al |
jz .done |
stosb |
dec ecx |
jnz .loop |
.done: |
mov ax, ' :' |
stosw |
mov esi, usercommand |
mov ecx, [edit1.size] |
inc ecx |
call recode |
mov al, 10 |
stosb |
lea esi, [edi - packetbuf] |
mcall send, [socketnum], packetbuf, , 0 |
sdts_ret: |
ret |
user_commands: |
dd 'nick', cmd_usr_nick |
dd 'real', cmd_usr_real |
dd 'serv', cmd_usr_server |
dd 'help', cmd_usr_help |
dd 'code', cmd_usr_code |
; TODO: All other commands require a connection to the server. |
dd 'quer', cmd_usr_quer |
dd 'quit', cmd_usr_quit |
.number = ($ - user_commands) / 8 |
server_command: |
mov eax, dword[usercommand+1] |
or eax, 0x20202020 |
mov edi, user_commands |
mov ecx, user_commands.number |
.loop: |
scasd |
je .got_cmd |
add edi, 4 |
dec ecx |
jnz .loop |
jmp cmd_usr_send ; If none of the previous commands, just send to server |
.got_cmd: |
jmp dword[edi] |
cmd_usr_quit: |
cmp [edit1.size], 5 |
je .ok |
jb cmd_usr_send |
cmp byte[usercommand+5], ' ' |
jne cmd_usr_send |
.ok: |
call cmd_usr_send |
mcall close, [socketnum] |
mov ecx, MAX_WINDOWS |
mov edi, windows |
.loop: |
mov [edi + window.flags], FLAG_CLOSE |
add edi, sizeof.window |
dec ecx |
jnz .loop |
ret |
cmd_usr_nick: |
cmp [edit1.size], 5 |
je .justprint |
cmp byte[usercommand+5], ' ' |
jne cmd_usr_send |
mov ecx, MAX_NICK_LEN |
mov esi, usercommand+6 |
mov edi, user_nick |
.loop: |
lodsb |
cmp al, 13 |
je .done |
stosb |
dec ecx |
jnz .loop |
.done: |
xor al, al |
stosb |
cmp [socketnum], 0 |
je .justprint |
lea esi, [edi - usercommand] |
mcall send, [socketnum], usercommand+1, , 0 |
.justprint: |
mov esi, str_nickchange |
call print_text2 |
mov esi, user_nick |
call print_text2 |
mov esi, str_dotnewline |
call print_text2 |
ret |
cmd_usr_real: |
cmp byte[usercommand+5], ' ' |
jne cmd_usr_send |
mov ecx, MAX_REAL_LEN |
mov esi, usercommand+6 |
mov edi, user_real_name |
.loop: |
lodsb |
cmp al, 13 |
je .done |
stosb |
dec ecx |
jnz .loop |
.done: |
xor al, al |
stosb |
mov esi, str_realchange |
call print_text2 |
mov esi, user_real_name |
call print_text2 |
mov esi, str_dotnewline |
call print_text2 |
ret |
cmd_usr_server: |
mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv' |
or eax, 0x00002020 |
and eax, 0x00ffffff |
cmp eax, 'er ' |
jne cmd_usr_send |
mov ecx, [edit1.size] ; ok now set the address |
sub ecx, 8 |
mov esi, usercommand+8 |
push esi |
mov edi, irc_server_name |
rep movsb |
xor al, al |
stosb |
pop esi |
; set it also in window name |
mov ebx, [window_print] |
call window_set_name |
; now connect |
call socket_connect |
ret |
cmd_usr_quer: |
mov ecx, MAX_WINDOWS |
mov ebx, windows |
.loop: |
cmp [ebx + window.data_ptr], 0 |
je .found |
add ebx, sizeof.window |
dec ecx |
jnz .loop |
; error: no available channels ! FIXME |
ret |
.found: |
call window_create |
test eax, eax |
jz .error |
mov [ebx + window.data_ptr], eax |
mov esi, usercommand+7 |
call window_set_name |
mov [ebx + window.type], WINDOWTYPE_CHAT |
mov [ebx + window.flags], 0 |
.error: |
ret |
cmd_usr_help: |
mov esi, str_help |
call print_text2 |
ret |
cmd_usr_code: |
; TODO |
ret |
cmd_usr_send: |
mov esi, usercommand+1 |
mov ecx, [edit1.size] |
inc ecx |
mov edi, packetbuf |
call recode |
lea esi, [edi - packetbuf] |
mcall send, [socketnum], packetbuf, , 0 |
ret |
/programs/network/ircc/users.inc |
---|
0,0 → 1,164 |
; esi is ptr to nick |
; ebx is ptr to window |
align 4 |
user_add: |
cmp [ebx + window.users], MAX_USERS |
jae fail |
mov edi, [ebx + window.data_ptr] |
add edi, window_data.names |
mov ebp, [ebx + window.users] |
inc ebp ; CHECKME |
push esi edi |
.restart: |
mov ecx, MAX_NICK_LEN |
.loop1: |
lodsb |
cmp al, '@' |
jne @f |
mov al, ' ' ; give @ highest priority |
@@: |
cmp al, 'A' |
jb @f |
cmp al, 'Z' |
ja @f |
add al, 'a' - 'A' ; convert to lowercase |
@@: |
dec ecx |
jz .got_it |
.loop2: |
mov dl, [edi] |
cmp dl, 0 |
je .got_it |
cmp dl, '@' |
jne @f |
mov dl, ' ' ; give @ highest priority |
@@: |
cmp dl, 'A' |
jb @f |
cmp dl, 'Z' |
ja @f |
add dl, 'a' - 'A' ; convert to lowercase |
@@: |
cmp al, dl |
jb .got_it |
je .check_next |
pop edi esi |
add edi, MAX_NICK_LEN |
push esi edi |
dec ebp |
jnz .restart |
.check_next: |
inc edi |
jmp .loop1 |
.got_it: |
pop edi esi |
; OK, insert it here.. |
; mov all trailing usernames by MAX_NICK_LEN bytes |
push esi edi |
mov esi, [ebx + window.data_ptr] |
add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1) |
mov ecx, esi |
sub ecx, edi |
add ecx, MAX_NICK_LEN |
shr ecx, 2 |
lea edi, [esi + MAX_NICK_LEN] |
std |
rep movsd |
cld |
pop edi esi |
; Now insert our new username |
mov ecx, MAX_NICK_LEN-1 |
.fill: |
lodsb |
cmp al, ' ' |
je .done |
cmp al, '!' |
je .done |
stosb |
loop .fill |
.done: |
xor al, al |
stosb |
inc [ebx + window.users] |
ret |
; esi is ptr to nick |
; ebx is ptr to window |
align 4 |
user_remove: |
call user_find |
jz fail |
lea esi, [edi + MAX_NICK_LEN] |
mov ecx, [ebx + window.data_ptr] |
add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS |
sub ecx, esi |
shr ecx, 2 |
rep movsd |
dec [ebx + window.users] |
xor eax, eax |
ret |
; IN: |
; esi is ptr to nick |
; ebx is ptr to window |
; OUT: |
; edi is ptr to nick in userlist |
align 4 |
user_find: |
mov eax, [ebx + window.users] |
test eax, eax |
jz fail |
mov edi, [ebx + window.data_ptr] |
add edi, window_data.names |
.loop: |
push esi edi |
mov ecx, MAX_NICK_LEN |
repe cmpsb |
cmp byte[edi-1], 0 |
je .got_it |
; TODO: check byte[esi] too! |
pop edi esi |
add edi, MAX_NICK_LEN |
dec eax |
jnz .loop |
jmp fail |
.got_it: |
pop edi esi |
test edi, edi ; to clear zero flag |
ret |
fail: |
xor edi, edi |
ret |
/programs/network/ircc/window.inc |
---|
0,0 → 1,167 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
window_create: |
; allocate the window data block |
mcall 68, 12, sizeof.window_data |
test eax, eax |
jz .fail |
; fill it with all zeros |
push eax |
mov edi, eax |
mov ecx, (sizeof.window_data+3)/4 |
xor eax, eax |
rep stosd |
pop eax |
.fail: |
ret |
window_set_name: ; esi = ptr to name, ebx = window ptr |
pusha |
; Skip heading spaces |
.spaceloop: |
cmp byte[esi], ' ' |
jne .done |
inc esi |
jmp .spaceloop |
.done: |
; Now copy it |
lea edi, [ebx + window.name] |
mov ecx, MAX_WINDOWNAME_LEN |
.loop: |
lodsb |
cmp al, 0x21 |
jbe .addzero |
stosb |
dec ecx |
jnz .loop |
.addzero: |
xor al, al |
stosb |
call draw_windownames ; redraw it |
popa |
ret |
window_refresh: |
; set the correct buffer pointers ; FIXME: what is it good for? |
mov eax, [textbox_width] ; |
imul eax, 11 ; |
mov [pos], eax ; |
mov eax, [window_print] |
mov eax, [eax + window.data_ptr] |
add eax, window_data.text |
mov [text_start], eax |
ret |
window_updated: |
mov edi, [window_print] |
test [edi + window.flags], FLAG_UPDATED |
jnz .skip |
or [edi + window.flags], FLAG_UPDATED |
; now play a sound :) |
.skip: |
ret |
print_text: ; eax = start ptr |
; dl = end char |
pusha |
ptr2: |
mov bl, [eax] |
cmp bl, dl |
je ptr_ret |
cmp bl, 0 |
je ptr_ret |
call print_character |
inc eax |
jmp ptr2 |
ptr_ret: |
popa |
ret |
print_text2: ; esi = ptr to ASCIIZ string |
pusha |
.loop: |
lodsb |
test al, al |
jz .done |
mov bl, al |
call print_character |
jmp .loop |
.done: |
popa |
ret |
if TIMESTAMP |
print_timestamp: |
pusha |
mcall 3 ; get system time |
mov bl, '[' |
call print_character |
mov ecx, TIMESTAMP |
.loop: |
mov bl, al |
shr bl, 4 |
add bl, '0' |
call print_character |
mov bl, al |
and bl, 0x0f |
add bl, '0' |
call print_character |
dec ecx |
jz .done |
mov bl, ':' |
call print_character |
shr eax, 8 |
jmp .loop |
.done: |
mov bl, ']' |
call print_character |
mov bl, ' ' |
call print_character |
popa |
ret |
end if |
/programs/network/ircc |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/libio.inc |
---|
0,0 → 1,113 |
;;================================================================================================;; |
;;//// libio.inc //// (c) mike.dld, 2007-2008 ////////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
O_BINARY = 00000000b |
O_READ = 00000001b |
O_WRITE = 00000010b |
O_CREATE = 00000100b |
O_SHARE = 00001000b |
O_TEXT = 00010000b |
SEEK_SET = 0 |
SEEK_CUR = 1 |
SEEK_END = 2 |
struct FileDateTime |
union |
time dd ? |
struct |
sec db ? |
min db ? |
hour db ? |
ends |
ends |
union |
date dd ? |
struct |
day db ? |
month db ? |
year dw ? |
ends |
ends |
ends |
struct FileInfoBlock |
Function dd ? |
Position dd ? |
Flags dd ? |
Count dd ? |
Buffer dd ? |
db ? |
FileName dd ? |
ends |
struct FileInfoHeader |
Version dd ? |
FilesRead dd ? |
FilesCount dd ? |
rd 5 |
ends |
struct FileInfoA |
Attributes dd ? |
Flags dd ? |
DateCreate FileDateTime |
DateAccess FileDateTime |
DateModify FileDateTime |
union |
FileSize dq ? |
struct |
FileSizeLow dd ? |
FileSizeHigh dd ? |
ends |
ends |
FileName rb 264 |
ends |
struct FileInfoW |
Attributes dd ? |
Flags dd ? |
DateCreate FileDateTime |
DateAccess FileDateTime |
DateModify FileDateTime |
union |
FileSize dq ? |
struct |
FileSizeLow dd ? |
FileSizeHigh dd ? |
ends |
ends |
FileName rw 264 |
ends |
virtual at 0 |
FileInfo FileInfoA |
FileInfo fix FileInfoA |
sizeof.FileInfo fix sizeof.FileInfoA |
end virtual |
FA_READONLY = 00000001b |
FA_HIDDEN = 00000010b |
FA_SYSTEM = 00000100b |
FA_LABEL = 00001000b |
FA_FOLDER = 00010000b |
FA_ARCHIVED = 00100000b |
FA_NORMAL = 01000000b |
FA_ANY = 01111111b |
/programs/network/macros.inc |
---|
0,0 → 1,588 |
@^ fix macro comment { |
^@ fix } |
; ------------------------- |
macro library [lname,fname] |
{ |
forward |
dd __#lname#_library_table__,__#lname#_library_name__ |
common |
dd 0 |
forward |
align 4 |
__#lname#_library_name__ db fname,0 |
} |
macro import lname,[name,sname] |
{ |
common |
align 4 |
__#lname#_library_table__: |
forward |
if used name |
name dd __#name#_import_name__ |
end if |
common |
dd 0 |
forward |
if used name |
align 4 |
__#name#_import_name__ db sname,0 |
end if |
} |
macro export [name,sname] |
{ |
forward |
dd __#name#_export_name__,name |
common |
dd 0 |
forward |
align 4 |
__#name#_export_name__ db sname,0 |
} |
; ------------------------- |
macro m2m dest,src { |
push src |
pop dest |
} |
macro iglobal { |
IGlobals equ IGlobals, |
macro __IGlobalBlock { } |
macro uglobal { |
UGlobals equ UGlobals, |
macro __UGlobalBlock { } |
endg fix } ; Use endg for ending iglobal and uglobal blocks. |
macro IncludeIGlobals{ |
macro IGlobals dummy,[n] \{ __IGlobalBlock |
purge __IGlobalBlock \} |
match I, IGlobals \{ I \} } |
macro IncludeUGlobals{ |
macro UGlobals dummy,[n] \{ |
\common |
\local begin, size |
begin = $ |
virtual at $ |
\forward |
__UGlobalBlock |
purge __UGlobalBlock |
\common |
size = $ - begin |
end virtual |
rb size |
\} |
match U, UGlobals \{ U \} } |
uglobal |
endg |
iglobal |
endg |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
IncludeIGlobals |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
IncludeUGlobals |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; macro for defining multiline text data |
struc mls [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring ; mod |
ssize = $ |
end virtual |
db ssize |
db sstring |
common |
db -1 ; mod |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
name db data |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
forward |
if lang eq lng |
db data |
end if |
common |
.size = $-name |
end if |
} |
macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
common |
local s,m |
m = 0 |
if used name |
label name |
forward |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
common |
.size = $-name |
.maxl = m |
end if |
} |
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
common |
local s,m,c |
m = 0 |
c = 0 |
if used name |
label name |
forward |
if lang eq lng |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
c = c+1 |
end if |
common |
.size = $-name |
.maxl = m |
.count = c |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
include 'config.inc' |
;__CPU_type equ p5 |
SYSENTER_VAR equ 0 |
macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls |
local ..ret_point |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
if __CPU_type eq p5 |
int 0x40 |
else |
if __CPU_type eq p6 |
push ebp |
mov ebp, esp |
push ..ret_point ; it may be 2 or 5 byte |
sysenter |
..ret_point: |
pop edx |
pop ecx |
else |
if __CPU_type eq k6 |
push ecx |
syscall |
pop ecx |
else |
display 'ERROR : unknown CPU type (set to p5)', 10, 13 |
__CPU_type equ p5 |
int 0x40 |
end if |
end if |
end if |
} |
; ------------------------- |
macro header a,[b] { |
common |
use32 |
org 0 |
db 'MENUET',a |
forward |
if b eq |
dd 0 |
else |
dd b |
end if } |
macro section name { align 16 |
label name } |
macro func name { |
if ~used name |
display 'FUNC NOT USED: ',`name,13,10 |
else |
align 4 |
name: |
;diff16 `name,0,name |
;pushad |
;pushfd |
;dps `name |
;newline |
;mcall 5,1 |
;popfd |
;popad |
} |
macro endf { end if } |
macro diff16 title,l1,l2 |
{ |
local s,d |
s = l2-l1 |
display title,': 0x' |
repeat 8 |
d = '0' + s shr ((8-%) shl 2) and $0F |
if d > '9' |
d = d + 'A'-'9'-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
macro diff10 title,l1,l2 |
{ |
local s,d,z,m |
s = l2-l1 |
z = 0 |
m = 1000000000 |
display title,': ' |
repeat 10 |
d = '0' + s / m |
s = s - (s/m)*m |
m = m / 10 |
if d <> '0' |
z = 1 |
end if |
if z <> 0 |
display d |
end if |
end repeat |
display 13,10 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro RGB [a] { |
common |
match (r=,g=,b),a \{ |
\dd ((r) shl 16) or ((g) shl 8) or (b) |
\} |
} |
struc POINT _t,_dx,_dy { |
.x _t _dx |
.y _t _dy |
} |
; structure definition helper |
include 'struct.inc' |
struct RECT |
left dd ? |
top dd ? |
right dd ? |
bottom dd ? |
ends |
struct BOX |
left dd ? |
top dd ? |
width dd ? |
height dd ? |
ends |
; structures used in MeOS |
struct process_information |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
dw ? ; +8 |
process_name rb 12 ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
box BOX ; +34 |
slot_state dw ? ; +50 |
dw ? ; +52 |
client_box BOX ; +54 |
wnd_state db ? ; +70 |
rb (1024-71) |
ends |
struct system_colors |
frame dd ? |
grab dd ? |
grab_button dd ? |
grab_button_text dd ? |
grab_text dd ? |
work dd ? |
work_button dd ? |
work_button_text dd ? |
work_text dd ? |
work_graph dd ? |
ends |
struct FILEDATE |
Second db ? |
Minute db ? |
Hour db ? |
db ? |
Day db ? |
Month db ? |
Year dw ? |
ends |
struct FILEINFO |
Attributes dd ? |
IsUnicode db ? |
db 3 dup(?) |
DateCreate FILEDATE |
DateAccess FILEDATE |
DateModify FILEDATE |
Size dq ? |
ends |
if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 |
cmove fix cmovz |
macro cmovz reg1, reg2 { |
local .jumpaddr |
jnz .jumpaddr |
mov reg1, reg2 |
.jumpaddr: |
} |
cmovne fix cmovnz |
macro cmovnz reg1, reg2 { |
local .jumpaddr |
jz .jumpaddr |
mov reg1, reg2 |
.jumpaddr: |
} |
macro cmovg reg1, reg2 { |
local .jumpaddr |
jle .jumpaddr |
mov reg1, reg2 |
.jumpaddr: |
} |
macro cmovl reg1, reg2 { |
local .jumpaddr |
jge .jumpaddr |
mov reg1, reg2 |
.jumpaddr: |
} |
end if |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
EVM_DEBUG = 100000000b |
EVM_STACK2 = 1000000000b |
/programs/network/netcfg/drivers.inc |
---|
0,0 → 1,198 |
driverlist: |
db 'RTL8139',0 |
dd 0x813910ec |
dd 0x813810ec |
dd 0x12111113 |
dd 0x13601500 |
dd 0x13604033 |
dd 0x13001186 |
dd 0x13401186 |
dd 0xab0613d1 |
dd 0xa1171259 |
dd 0xa11e1259 |
dd 0xab0614ea |
dd 0xab0714ea |
dd 0x123411db |
dd 0x91301432 |
dd 0x101202ac |
dd 0x0106018a |
dd 0x1211126c |
dd 0x81391743 |
dd 0x8139021b |
dd 0x0 ; end |
db 'RTL8029',0 |
dd 0x802910ec |
dd 0x0 |
db 'I8255X',0 |
dd 0x12098086 |
dd 0x10298086 |
dd 0x12298086 |
dd 0x10308086 |
dd 0x24498086 |
dd 0x0 |
db 'RTL8169',0 |
dd 0x816810ec |
dd 0x816910ec |
dd 0x011616ec |
dd 0x43001186 |
dd 0x813610ec |
dd 0x0 |
db '3C59X',0 |
dd 0x590010b7 |
dd 0x592010b7 |
dd 0x597010b7 |
dd 0x595010b7 |
dd 0x595110b7 |
dd 0x595210b7 |
dd 0x900010b7 |
dd 0x900110b7 |
dd 0x900410b7 |
dd 0x900510b7 |
dd 0x900610b7 |
dd 0x900A10b7 |
dd 0x905010b7 |
dd 0x905110b7 |
dd 0x905510b7 |
dd 0x905810b7 |
dd 0x905A10b7 |
dd 0x920010b7 |
dd 0x980010b7 |
dd 0x980510b7 |
dd 0x764610b7 |
dd 0x505510b7 |
dd 0x605510b7 |
dd 0x605610b7 |
dd 0x5b5710b7 |
dd 0x505710b7 |
dd 0x515710b7 |
dd 0x525710b7 |
dd 0x656010b7 |
dd 0x656210b7 |
dd 0x656410b7 |
dd 0x450010b7 |
dd 0x0 |
db 'SIS900',0 |
dd 0x09001039 |
dd 0x70161039 |
dd 0x0 |
db 'PCNET32',0 |
dd 0x20001022 |
dd 0x26251022 |
dd 0x20011022 |
dd 0x0 |
db 'FORCEDETH',0 |
dd 0x006610de |
dd 0x01c310de |
dd 0x00D610de |
dd 0x008610de |
dd 0x008c10de |
dd 0x00e610de |
dd 0x00df10de |
dd 0x005610de |
dd 0x005710de |
dd 0x003710de |
dd 0x003810de |
dd 0x026810de |
dd 0x026910de |
dd 0x037210de |
dd 0x037310de |
dd 0x03e510de |
dd 0x03e610de |
dd 0x03ee10de |
dd 0x03ef10de |
dd 0x045010de |
dd 0x045110de |
dd 0x045210de |
dd 0x045310de |
dd 0x054c10de |
dd 0x054d10de |
dd 0x054e10de |
dd 0x054f10de |
dd 0x07dc10de |
dd 0x07dd10de |
dd 0x07de10de |
dd 0x07df10de |
dd 0x076010de |
dd 0x076110de |
dd 0x076210de |
dd 0x076310de |
dd 0x0ab010de |
dd 0x0ab110de |
dd 0x0ab210de |
dd 0x0ab310de |
dd 0x0d7d10de |
dd 0x0 |
db 'MTD80X',0 |
dd 0x08031516 |
dd 0x08001516 |
dd 0x08911516 |
dd 0x0 |
db 'dec21x4x',0 |
dd 0x00091011 |
dd 0x00191011 |
dd 0x09851317 |
dd 0x0 |
db 'R6040',0 |
dd 0x604017F3 |
dd 0x0 |
db 'i8254x',0 |
dd 0x10008086 ; 82542 (Fiber) |
dd 0x10018086 ; 82543GC (Fiber) |
dd 0x10048086 ; 82543GC (Copper) |
dd 0x10088086 ; 82544EI (Copper) |
dd 0x10098086 ; 82544EI (Fiber) |
dd 0x100A8086 ; 82540EM |
dd 0x100C8086 ; 82544GC (Copper) |
dd 0x100D8086 ; 82544GC (LOM) |
dd 0x100E8086 ; 82540EM |
dd 0x100F8086 ; 82545EM (Copper) |
dd 0x10108086 ; 82546EB (Copper) |
dd 0x10118086 ; 82545EM (Fiber) |
dd 0x10128086 ; 82546EB (Fiber) |
dd 0x10138086 ; 82541EI |
dd 0x10148086 ; 82541ER |
dd 0x10158086 ; 82540EM (LOM) |
dd 0x10168086 ; 82540EP (Mobile) |
dd 0x10178086 ; 82540EP |
dd 0x10188086 ; 82541EI |
dd 0x10198086 ; 82547EI |
dd 0x101a8086 ; 82547EI (Mobile) |
dd 0x101d8086 ; 82546EB |
dd 0x101e8086 ; 82540EP (Mobile) |
dd 0x10268086 ; 82545GM |
dd 0x10278086 ; 82545GM |
dd 0x10288086 ; 82545GM |
dd 0x105b8086 ; 82546GB (Copper) |
dd 0x10758086 ; 82547GI |
dd 0x10768086 ; 82541GI |
dd 0x10778086 ; 82541GI |
dd 0x10788086 ; 82541ER |
dd 0x10798086 ; 82546GB |
dd 0x107a8086 ; 82546GB |
dd 0x107b8086 ; 82546GB |
dd 0x107c8086 ; 82541PI |
dd 0x10b58086 ; 82546GB (Copper) |
dd 0x11078086 ; 82544EI |
dd 0x11128086 ; 82544GC |
dd 0x0 |
db 'RHINE', 0 ; VIA Rhine |
dd 0x30431106 |
dd 0x61001106 |
dd 0x30651106 |
dd 0x31061106 |
dd 0x30531106 |
dd 0x0 |
dd 0x0 ; driverlist end |
/programs/network/netcfg/netcfg.asm |
---|
0,0 → 1,548 |
; |
; Netcfg v1.02 |
; |
; Application to load network drivers in KolibriOS |
; |
; By hidnplayr |
; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd (I_END+0x100) ; memory for app |
dd (I_END+0x100) ; esp |
dd param, 0x0 ; I_Param , I_Icon |
type_ethernet equ 1 |
include '../macros.inc' |
START: |
; first, check boot parameters |
cmp byte[param], 0 |
je .noparams |
mcall 40, 0 |
push .exit |
cmp byte[param], 'A' ; A for All |
je Get_PCI_Info |
cmp byte[param], 'F' ; F for First |
je Get_PCI_Info |
ret |
.exit: |
mcall -1 |
.noparams: |
call draw_window |
still: |
mcall 10 ; wait here for event |
dec eax ; redraw request ? |
jz red |
dec eax ; key in buffer ? |
jz key |
dec eax ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size |
mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure |
mov [Form + 2], ax ; x start position |
mov eax, [Proc_Info.box.top]; |
mov [Form + 6], ax ; ystart position |
mov eax, [Proc_Info.box.width] ; |
mov [Form], ax ; window width |
mov eax, [Proc_Info.box.height] ; |
mov [Form + 4] ,ax ; window height |
call draw_window ; go redraw window now |
jmp still |
key: ; key |
mcall 2 ; just read it and ignore |
jmp still |
button: ; button |
mcall 17 ; get id |
cmp ah, 1 ; button id = 1 ? |
jne @f |
exit: mcall -1 ; close this program |
@@: |
cmp eax,0x0000ff00 |
jg load_drv |
cmp ah, 4 |
je hook |
cmp ah, 5 |
je reset |
cmp ah, 6 |
je unload |
jmp still |
load_drv: |
shr eax, 16 |
mov word [selected], ax |
mov bl , 6 ; get a dword |
mov bh , ah ; bus |
mov ch , al ; dev |
mov cl , 0 ; offset to device/vendor id |
mcall 62 ; get ID's |
mov word [PCI_Vendor], ax |
shr eax, 16 |
mov word [PCI_Device], ax |
call get_drv_ptr |
mov ecx, eax |
mcall 68, 16 |
mov [IOCTL.handle], eax |
call draw_window |
cmp [IOCTL.handle], 0 |
jne still |
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , load_error |
jmp still |
hook: |
mov ax , [selected] |
test ax , ax |
jz still |
mov [hardwareinfo.pci_dev], al |
mov [hardwareinfo.pci_bus], ah |
mov [IOCTL.io_code], 1 ; SRV_HOOK |
mov [IOCTL.inp_size], 3 |
mov [IOCTL.input], hardwareinfo |
mov [IOCTL.out_size], 0 |
mov [IOCTL.output], 0 |
mcall 68, 17, IOCTL |
mov byte[drivernumber], al |
jmp still |
reset: |
movzx ebx, byte[drivernumber] |
mcall 74,,2 |
jmp still |
unload: |
movzx ebx, byte[drivernumber] |
mcall 74,,3 |
jmp still |
draw_window: |
mcall 12, 1 ; start of draw |
mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title |
call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device |
cmp edx, 20 shl 16 + 110 |
je .nonefound |
mcall 4, 20 shl 16 + 100, 1 shl 31 + 0x00000000 , caption |
cmp [selected], 0 |
jz .done |
cmp [IOCTL.handle] ,0 |
jz .done |
mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00 |
mcall ,, 55 shl 16 + 18, 5, 0x0000007f |
mcall ,, 75 shl 16 + 18, 6, 0x007f0000 |
mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start |
mcall , 33 shl 16 + 62, , btn_reset |
mcall , 36 shl 16 + 82, , btn_stop |
jmp .done |
.nonefound: |
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound |
.done: |
mcall 12, 2 ; end of draw |
ret |
;------------------------------------------------------------------ |
;* Gets the PCI Version and Last Bus |
Get_PCI_Info: |
mcall 62, 0 |
mov word [PCI_Version], ax |
mcall 62, 1 |
mov byte [PCI_LastBus], al |
;---------------------------------------------------------- |
;* Get all devices on PCI Bus |
mov edx, 20 shl 16 + 110 ; set start write position |
cmp al , 0xff ; 0xFF means no pci bus found |
jne Pci_Exists ; |
ret ; if no bus then leave |
Pci_Exists: |
mov byte [V_Bus], 0 ; reset varibles |
mov byte [V_Dev], 0 ; |
Start_Enum: |
mov bl , 6 ; get a dword |
mov bh , byte [V_Bus] ; bus of pci device |
mov ch , byte [V_Dev] ; device number/function |
mov cl , 0 ; offset to device/vendor id |
mcall 62 ; get ID's |
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF |
je nextDev ; check next device if nothing exists here |
cmp ax, 0xffff ; |
je nextDev ; |
mov word [PCI_Vendor], ax ; There is a device here, save the ID's |
shr eax, 16 ; |
mov word [PCI_Device], ax ; |
mov bl , 4 ; Read config byte |
mov bh , byte [V_Bus] ; Bus # |
mov ch , byte [V_Dev] ; Device # on bus |
mov cl , 0x08 ; Register to read (Get Revision) |
mcall 62 ; Read it |
mov byte [PCI_Rev], al ; Save it |
mov cl , 0x0b ; Register to read (Get class) |
mcall 62 ; Read it |
mov byte [PCI_Class], al ; Save it |
mov cl , 0x0a ; Register to read (Get Subclass) |
mcall 62 ; Read it |
mov byte [PCI_SubClass], al ; Save it |
mov cl , 0x09 ; Register to read (Get Interface) |
mcall 62 ; Read it |
mov [PCI_Interface], al ; Save it |
mov cl , 0x3c ; Register to read (Get IRQ) |
@@: mcall 62 ; Read it |
mov [PCI_IRQ], al ; Save it |
; cmp byte [PCI_Class], 0 ; device from before class codes |
; je @f |
cmp byte [PCI_Class], 2 ; network controller |
jne nextDev |
; @@: |
cmp byte[param], 0 |
jne load_and_start |
mov cl, 0x0e |
mcall 62 |
push eax |
call Print_New_Device ; print device info to screen |
pop eax |
test al, al |
js nextDev |
nextdev2: |
test byte [V_Dev], 7 |
jnz nextDev |
or byte [V_Dev], 7 |
nextDev: |
inc [V_Dev] ; lower 3 bits are the function number |
jnz Start_Enum ; jump until we reach zero |
mov byte [V_Dev], 0 ; reset device number |
inc byte [V_Bus] ; next bus |
mov al , byte [PCI_LastBus] ; get last bus |
cmp byte [V_Bus], al ; was it last bus |
jbe Start_Enum ; if not jump to keep searching |
ret |
load_and_start: |
call get_drv_ptr |
cmp eax, lbl_none |
je .next |
mov ecx, eax |
mcall 68, 16 |
test eax, eax |
jz .next |
mov [IOCTL.handle], eax |
mov al, [V_Dev] |
mov [hardwareinfo.pci_dev], al |
mov al, [V_Bus] |
mov [hardwareinfo.pci_bus], al |
mov [IOCTL.io_code], 1 ; SRV_HOOK |
mov [IOCTL.inp_size], 3 |
mov [IOCTL.input], hardwareinfo |
mov [IOCTL.out_size], 0 |
mov [IOCTL.output], 0 |
mcall 68, 17, IOCTL |
.next: |
cmp byte[param], 'A' |
je nextdev2 |
jmp exit |
;------------------------------------------------------------------ |
;* Print device info to screen |
Print_New_Device: |
push edx ; Magic ! (to print a button...) |
mov ebx, 18 shl 16 |
mov bx , [Form] |
sub bx , 36 |
mov cx , dx |
dec cx |
shl ecx, 16 |
add ecx, 9 |
movzx edx, byte [V_Bus] |
shl dx , 8 |
mov dl , byte [V_Dev] |
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise |
cmp word [selected], dx |
jne @f |
mov esi, 0x00c0c000 |
@@: |
shl edx, 8 |
or dl , 0xff |
mcall 8 |
pop edx |
xor esi, esi ; Color of text |
movzx ecx, word [PCI_Vendor] ; number to be written |
mcall 47, 0x00040100 ; Write Vendor ID |
add edx, (4*6+18) shl 16 |
movzx ecx, word [PCI_Device] ; get Vendor ID |
mcall ; Draw Vendor ID to Window |
add edx, (4*6+18) shl 16 |
movzx ecx, byte [V_Bus] ; get bus number |
mcall ,0x00020100 ; draw bus number to screen |
add edx, (2*6+18) shl 16 |
movzx ecx, byte [V_Dev] ; get device number |
shr ecx, 3 ; device number is bits 3-7 |
mcall ; Draw device Number To Window |
add edx, (2*6+18) shl 16 |
movzx ecx, byte [PCI_Rev] ; get revision number |
mcall ; Draw Revision to screen |
add edx, (2*6+18) shl 16 |
movzx ecx, [PCI_IRQ] |
cmp cl , 0x0f ; IRQ must be between 0 and 15 |
ja @f |
mcall |
@@: |
; |
;Write Names |
movzx ebx, dx ; Set y position |
or ebx, 230 shl 16 ; set Xposition |
;------------------------------------------------------------------ |
; Prints the Vendor's Name based on Vendor ID |
;------------------------------------------------------------------ |
mov edx, VendorsTab |
mov cx , word[PCI_Vendor] |
.fn: mov ax , [edx] |
add edx, 6 |
test ax , ax |
jz .find |
cmp ax , cx |
jne .fn |
.find: mov edx, [edx - 4] |
mcall 4,, 0x80000000 ; lets print the vendor Name |
;------------------------------------------------------------------ |
; Get description based on Class/Subclass |
;------------------------------------------------------------------ |
mov eax, dword [PCI_Class] |
and eax, 0xffffff |
xor edx, edx |
xor esi, esi |
.fnc: inc esi |
mov ecx, [Classes + esi * 8 - 8] |
cmp cx , 0xffff |
je .endfc |
cmp cx , ax |
jne .fnc |
test ecx, 0xff000000 |
jz @f |
mov edx, [Classes + esi * 8 - 4] |
jmp .fnc |
@@: cmp eax, ecx |
jne .fnc |
xor edx, edx |
.endfc: test edx, edx |
jnz @f |
mov edx, [Classes + esi * 8 - 4] |
@@: |
add ebx, 288 shl 16 |
mcall 4,, 0x80000000,, 32 ; draw the text |
movzx edx, bx ; get y coordinate |
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 |
;------------------------------------------------------------------ |
; Print Driver Name |
;------------------------------------------------------------------ |
push edx |
add ebx, 120 shl 16 |
push ebx |
call get_drv_ptr |
mov edx, eax |
pop ebx |
mcall 4,,0x80000000 ; lets print the vendor Name |
pop edx |
ret |
get_drv_ptr: |
mov eax, driverlist ; eax will be the pointer to latest driver title |
mov ebx, driverlist ; ebx is the current pointer |
mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find |
driverloop: |
inc ebx |
cmp byte[ebx],0 |
jne driverloop |
inc ebx ; the device/vendor id list for the driver eax is pointing to starts here. |
deviceloop: |
cmp dword[ebx],0 |
je nextdriver |
cmp dword[ebx],ecx |
je driverfound |
add ebx,4 |
jmp deviceloop |
nextdriver: |
add ebx,4 |
cmp dword[ebx],0 |
je nodriver |
mov eax,ebx |
jmp driverloop |
nodriver: |
mov eax, lbl_none ; lets print the vendor Name |
ret |
driverfound: |
ret |
include 'vendors.inc' |
include 'drivers.inc' |
;------------------------------------------------------------------ |
; DATA AREA |
DATA |
Form: dw 800 ; window width (no more, special for 800x600) |
dw 100 ; window x start |
dw 220 ; window height |
dw 100 ; window y start |
title db 'Network Driver Control Center', 0 |
caption db 'Vendor Device Bus Dev Rev IRQ Company Description DRIVER',0 |
nonefound db 'No compatible devices were found!',0 |
btn_start db 'Start device',0 |
btn_reset db 'Reset device',0 |
btn_stop db 'Stop device',0 |
lbl_none db 'none',0 |
load_error db 'Could not load driver!',0 |
hardwareinfo: |
.type db 1 ; pci |
.pci_bus db ? |
.pci_dev db ? |
IM_END: |
;------------------------------------------------------------------ |
; UNINITIALIZED DATA AREA |
IOCTL: |
.handle dd ? |
.io_code dd ? |
.input dd ? |
.inp_size dd ? |
.output dd ? |
.out_size dd ? |
drivernumber db ? |
MAC dp ? |
type db ? |
selected dw ? |
V_Bus db ? |
V_Dev db ? |
PCI_Version dw ? |
PCI_LastBus db ? |
PCI_Vendor dw ? |
PCI_Device dw ? |
PCI_Bus db ? |
PCI_Dev db ? |
PCI_Rev db ? |
; don`t change order!!! |
PCI_Class db ? |
PCI_SubClass db ? |
PCI_Interface db ? |
PCI_IRQ db ? |
Proc_Info process_information |
param rb 1024 |
I_END: |
/programs/network/netcfg/vendors.inc |
---|
0,0 → 1,1072 |
; AUTHOR: Victor Alberto Gil Hancco Laquita <vhanla@gmail.com> |
; This list might content mistakes, plz report it |
; There are 865 Lists of Vendors' Names |
; Date: 8/14/2005 |
; |
; maybe this list is outdated... |
; (the source was from 2004 list) |
; changed 11/05/2006: + 3 vendors and no more label 'PREVIOUSVERSIONLIST' |
; so the total quantity of vendors is 875 now (changes by Sergey Kuzmin) |
; changed 16/08/2006: + 122 vendors |
; so the total quantity of vendors is 987 now (changes by Sergey Kuzmin) |
; changed ??/04/2007: |
; size optimezed |
; total quantity of vendors is 997 now (changes by Mihailov Ilia) |
macro VendorID a,b { ; by mike.dld |
dw a |
dd _vtmp#a |
\iglobal |
_vtmp#a db b |
db 0 |
\};endg |
} |
macro ClassID a,b,c,d { |
db a |
db b |
local tt |
if c eq |
db 0 |
db 1 |
tt = 'x' |
else |
db c |
db 0 |
tt = c |
end if |
dd _ctmp#a#b#tt |
\iglobal |
_ctmp#a#b#tt db d |
db 0 |
\};endg |
} |
;-------------------------------------- |
VendorsTab: |
VendorID 0x0033, 'PARADYNE CORP.' |
VendorID 0x003D, 'Lockheed Martin Corp' |
VendorID 0x0100, 'NCIPHER CORP. LTD' |
VendorID 0x0675, 'DYNALINK' |
VendorID 0x0571, 'BERKOM' |
VendorID 0x0A89, 'BREA TECHNOLOGIES INC' |
VendorID 0x0E11, 'COMPAQ COMPUTER CORP.' |
VendorID 0x1000, 'SYMBIOS LOGIC INC/LSI Logic' |
VendorID 0x1001, 'KOLTER ELECTRONIC' |
VendorID 0x1002, 'ATI TECHNOLOGIES INC' |
VendorID 0x1003, 'ULSI' |
VendorID 0x1004, 'VLSI TECHNOLOGY INC' |
VendorID 0x1005, 'ADL' |
VendorID 0x100B, 'NATIONAL SEMICONDUCTOR CORPORATION' |
VendorID 0x100C, 'Tseng Labs' |
VendorID 0x100E, 'Weitek' |
VendorID 0x1010, 'VIDEO LOGIC LTD' |
VendorID 0x1011, 'Digital Equipment Corporation' |
VendorID 0x1013, 'Cirrus Logic' |
VendorID 0x1014, 'IBM' |
VendorID 0x1017, 'Spea Software AG' |
VendorID 0x1018, 'UNISYS CORPORATION' |
VendorID 0x1019, 'ELITEGROUP COMPUTER SYS' |
VendorID 0x101A, 'NCR Corporation' |
VendorID 0x101E, 'AMERICAN MEGATRENDS' |
VendorID 0x1020, 'HITACHI COMPUTER PRODUCTS' |
VendorID 0x1021, 'OKI ELECTRIC INDUSTRY CO. LTD.' |
VendorID 0x1022, 'Advanced Micro Devices' |
VendorID 0x1023, 'TRIDENT MICROSYSTEMS' |
VendorID 0x1025, 'Acer Incorporated' |
VendorID 0x1028, 'DELL COMPUTER CORPORATION' |
VendorID 0x102A, 'LSI LOGIC CORPORATION' |
VendorID 0x102B, 'MATROX GRAPHICS' |
VendorID 0x102C, 'Asiliant (Chips And Technologies)' |
VendorID 0x102D, 'Wyse Technologies' |
VendorID 0x102F, 'TOSHIBA AMERICA' |
VendorID 0x1031, 'miro Computer Products AG' |
VendorID 0x1033, 'NEC CORPORATION' |
VendorID 0x1036, 'Future Domain' |
VendorID 0x1038, 'AMP' |
VendorID 0x1039, 'SILICON INTEGRATED SYSTEMS' |
VendorID 0x103C, 'Hewlett-Packard Company' |
VendorID 0x103F, 'SYNOPSYS/LOGIC MODELING GROUP' |
VendorID 0x1042, 'Micron Electronics' |
VendorID 0x1043, 'ASUSTEK COMPUTER' |
VendorID 0x1044, 'DISTRIBUTED PROCESSING TECHNOLOGY' |
VendorID 0x1045, 'OPTI INC.' |
VendorID 0x1048, 'ELSA AG' |
VendorID 0x1049, 'FOUNTAIN TECHNOLOGIES' |
VendorID 0x104A, 'STMicroelectronics' |
VendorID 0x104B, 'BusLogic' |
VendorID 0x104C, 'TEXAS INSTRUMENTS' |
VendorID 0x104D, 'SONY CORPORATION' |
VendorID 0x104E, 'Oak Technology' |
VendorID 0x104F, 'Co-Time Computer Ltd.' |
VendorID 0x1050, 'WINBOND ELECTRONICS CORP' |
VendorID 0x1051, 'Anigma Corp.' |
VendorID 0x1054, 'HITACHI' |
VendorID 0x1055, 'Standard Microsystems Corp.' |
VendorID 0x1057, 'Motorola' |
VendorID 0x1058, 'ETRI' |
VendorID 0x1059, 'TEKNOR INDUSTRIAL COMPUTERS INC' |
VendorID 0x105A, 'PROMISE TECHNOLOGY' |
VendorID 0x105B, 'FOXCONN INTERNATIONAL INC' |
VendorID 0x105D, 'NUMBER 9 VISUAL TECHNOLOGY' |
VendorID 0x105F, 'INFOTRONIC AMERICA INC' |
VendorID 0x1060, 'United Microelectronics' |
VendorID 0x1061, '8x8 Inc.' |
VendorID 0x1063, 'OCEAN MANUFACTURING LTD' |
VendorID 0x1064, 'ALCATEL' |
VendorID 0x1065, 'Texas Microsystems' |
VendorID 0x1066, 'Picopower Technology' |
VendorID 0x1067, 'MITSUBISHI ELECTRIC AMERICA' |
VendorID 0x1068, 'DIVERSIFIED TECHNOLOGY' |
VendorID 0x1069, 'MYLEX CORPORATION' |
VendorID 0x106B, 'APPLE COMPUTER INC.' |
VendorID 0x106C, 'Hyundai Electronics America' |
VendorID 0x106D, 'SEQUENT COMPUTER SYSTEMS' |
VendorID 0x1070, 'DAEWOO TELECOM LTD' |
VendorID 0x1071, 'MITAC' |
VendorID 0x1073, 'YAMAHA CORPORATION' |
VendorID 0x1074, 'Nexgen Microsystems' |
VendorID 0x1076, 'Chaintech Comp.' |
VendorID 0x1077, 'QLOGIC Corporation' |
VendorID 0x1078, 'Cyrix Corporation' |
VendorID 0x1079, 'I-BUS' |
VendorID 0x107B, 'GATEWAY 2000' |
VendorID 0x107D, 'Leadtek Research' |
VendorID 0x107E, 'INTERPHASE CORPORATION' |
VendorID 0x107F, 'Data Technology Corporation' |
VendorID 0x1080, 'Cypress Semiconductor' |
VendorID 0x1081, 'Radius Inc.' |
VendorID 0x1083, 'Forex Computer Corporation' |
VendorID 0x1085, 'Tulip Computers International BV' |
VendorID 0x1087, 'Cache Computer' |
VendorID 0x108A, 'SBS Operations' |
VendorID 0x108D, 'OLICOM' |
VendorID 0x108E, 'Sun Microsystems' |
VendorID 0x1091, 'Intergraph Corporation' |
VendorID 0x1092, 'Diamond Computer Systems' |
VendorID 0x1093, 'National Instruments' |
VendorID 0x1095, 'SILICON IMAGE (WAS CMD TECHNOLOGY INC)' |
VendorID 0x1096, 'ALACRON' |
VendorID 0x1097, 'APPIAN Graphics/ETMA' |
VendorID 0x1098, 'Quantum Designs Ltd.' |
VendorID 0x109A, 'PACKARD BELL NEC' |
VendorID 0x109E, 'BROOKTREE CORPORATION' |
VendorID 0x109F, 'TRIGEM COMPUTER INC.' |
VendorID 0x10A0, 'MEIDENSHA CORPORATION' |
VendorID 0x10A2, 'QUANTUM EFFECT DESIGN' |
VendorID 0x10A4, 'Globe Manufacturing Sales' |
VendorID 0x10A8, 'Sierra Semiconductor' |
VendorID 0x10A9, 'SILICON GRAPHICS' |
VendorID 0x10AC, 'HONEYWELL IAC' |
VendorID 0x10AD, 'Winbond Systems Labs' |
VendorID 0x10AF, 'MICRO COMPUTER SYSTEMS INC' |
VendorID 0x10B5, 'PLX TECHNOLOGY.' |
VendorID 0x10B6, 'MADGE NETWORKS' |
VendorID 0x10B7, '3COM Corp, Networking Division' |
VendorID 0x10B8, 'Standard Microsystems Corporation' |
VendorID 0x10B9, 'ACER LABS Incorp.' |
VendorID 0x10BA, 'MITSUBISHI ELECTRIC CORP.' |
VendorID 0x10BD, 'Surecom Technology' |
VendorID 0x10C2, 'AUSPEX SYSTEMS INC.' |
VendorID 0x10C3, 'Samsung Semiconductors' |
VendorID 0x10C4, 'Award Software International Inc.' |
VendorID 0x10C8, 'NEOMAGIC CORPORATION' |
VendorID 0x10CA, 'FUJITSU MICROELECTRONIC' |
VendorID 0x10CB, 'OMRON CORPORATION' |
VendorID 0x10CD, 'ADVANCED SYSTEM PRODUCTS' |
VendorID 0x10CF, 'FUJITSU LIMITED' |
VendorID 0x10D1, 'FUTUREPLUS SYSTEMS CORP.' |
VendorID 0x10D2, 'MOLEX INCORPORATED' |
VendorID 0x10D9, 'Macronix International Co. Ltd.' |
VendorID 0x10DB, 'ROHM LSI SYSTEMS' |
VendorID 0x10DC, 'CERN-European Lab. for Particle Physics' |
VendorID 0x10DD, 'EVANS & SUTHERLAND' |
VendorID 0x10DE, 'NVIDIA CORPORATION' |
VendorID 0x10DF, 'EMULEX CORPORATION' |
VendorID 0x10E1, 'TEKRAM TECHNOLOGY CO.LTD.' |
VendorID 0x10E3, 'TUNDRA SEMICONDUCTOR CORP' |
VendorID 0x10E5, 'MICRO INDUSTRIES CORPORATION' |
VendorID 0x10E8, 'Applied Micro Circuits Corp.' |
VendorID 0x10EA, 'Tvia, Inc.' |
VendorID 0x10EB, 'Artist Graphics' |
VendorID 0x10EC, 'REALTEK SEMICONDUCTOR CORP.' |
VendorID 0x10ED, 'Ascii Corporation' |
VendorID 0x10EE, 'XILINX' |
VendorID 0x10EF, 'Racore Computer Products' |
VendorID 0x10F0, 'Curtiss-Wright Controls Embedded Computing' |
VendorID 0x10F1, 'TYAN COMPUTER' |
VendorID 0x10F4, 'S-Mos Systems' |
VendorID 0x10F5, 'NKK CORPORATION' |
VendorID 0x10F6, 'Creative Electronic Systems SA' |
VendorID 0x10FA, 'Truevision' |
VendorID 0x10FB, 'Thesys Microelectronics' |
VendorID 0x10FC, 'I-O DATA DEVICE' |
VendorID 0x10FE, 'FAST MULTIMEDIA AG' |
VendorID 0x1101, 'INITIO CORPORATION' |
VendorID 0x1102, 'Creative Labs' |
VendorID 0x1105, 'SIGMA DESIGNS' |
VendorID 0x1106, 'VIA TECHNOLOGIES' |
VendorID 0x1107, 'ASCEND COMMUNICATIONS/Stratus Computer' |
VendorID 0x1108, 'Proteon Inc.' |
VendorID 0x1109, 'Adaptec/Cogent Data Technologies Inc' |
VendorID 0x110A, 'SIEMENS PC SYSTEME GMBH' |
VendorID 0x110B, 'Chromatic Research Inc' |
VendorID 0x1111, 'SANTA CRUZ OPERATION' |
VendorID 0x1112, 'Osicom Technologies Inc.' |
VendorID 0x1113, 'ACCTON TECHNOLOGY' |
VendorID 0x1114, 'Atmel Corp.' |
VendorID 0x1116, 'Media 100, Inc.' |
VendorID 0x1117, 'Datacube Inc.' |
VendorID 0x1118, 'FCI ELECTRONICS' |
VendorID 0x1119, 'ICP-VORTEX COMPUTERSYSTEM GMBH' |
VendorID 0x111A, 'EFFICIENT NETWORKS' |
VendorID 0x111C, 'Tricord Systems Inc.' |
VendorID 0x111D, 'INTEGRATED DEVICE TECH' |
VendorID 0x111F, 'Precision Digital Images' |
VendorID 0x1120, 'EMC CORPORATION' |
VendorID 0x1127, 'FORE SYSTEMS INC' |
VendorID 0x112A, 'HERMES ELECTRONICS COMPANY' |
VendorID 0x112E, 'Infomedia' |
VendorID 0x112F, 'IMAGING TECHNOLOGY' |
VendorID 0x1131, 'PHILIPS SEMICONDUCTORS' |
VendorID 0x1132, 'MITEL CORP' |
VendorID 0x1133, 'Eicon Networks Corporation' |
VendorID 0x1134, 'MERCURY COMPUTER SYSTEMS' |
VendorID 0x1135, 'FUJI XEROX CO LTD' |
VendorID 0x1136, 'MOMENTUM DATA SYSTEMS' |
VendorID 0x1137, 'CISCO SYSTEMS INC' |
VendorID 0x1138, 'ZIATECH CORPORATION' |
VendorID 0x113C, 'CYCLONE MICROSYSTEMS.' |
VendorID 0x113E, 'SANYO ELECTRIC CO-Information Systems Division' |
VendorID 0x113F, 'Equinox Systems' |
VendorID 0x1141, 'CREST MICROSYSTEM INC.' |
VendorID 0x1142, 'Alliance Semiconductor CA - USA' |
VendorID 0x1144, 'Cincinnati Milacron' |
VendorID 0x1145, 'WORKBIT CORPORATION' |
VendorID 0x1146, 'FORCE COMPUTERS GMBH' |
VendorID 0x1147, 'Interface Corp' |
VendorID 0x1148, 'SYSKONNECT/Marvell' |
VendorID 0x114A, 'VMIC' |
VendorID 0x114C, 'ANNABOOKS' |
VendorID 0x114F, 'DIGI INTERNATIONAL' |
VendorID 0x1154, 'MELCO INC' |
VendorID 0x1155, 'Pine Technology Ltd' |
VendorID 0x1158, 'Voarx R&D Inc' |
VendorID 0x1159, 'Mutech' |
VendorID 0x115C, 'PHOTRON LTD.' |
VendorID 0x115D, 'XIRCOM' |
VendorID 0x1161, 'PFU LIMITED' |
VendorID 0x1163, 'RENDITION' |
VendorID 0x1165, 'Imagraph Corporation' |
VendorID 0x1166, 'Reliance Computer Corp./ServerWorks' |
VendorID 0x1169, 'Centre f/Dev. of Adv. Computing' |
VendorID 0x116A, 'Polaris Communications' |
VendorID 0x116E, 'ELECTRONICS FOR IMAGING' |
VendorID 0x1170, 'INVENTEC CORPORATION' |
VendorID 0x1171, 'BLUE WAVE SYSTEMS' |
VendorID 0x1172, 'ALTERA CORPORATION' |
VendorID 0x1176, 'SBE' |
VendorID 0x1178, 'Alfa Inc' |
VendorID 0x1179, 'TOSHIBA AMERICA INFO SYSTEMS' |
VendorID 0x117B, 'GCE-8320B' |
VendorID 0x117E, 'T/R Systems' |
VendorID 0x1180, 'RICOH CO LTD' |
VendorID 0x1185, 'Dataworld' |
VendorID 0x1186, 'D-LINK SYSTEM INC' |
VendorID 0x1187, 'ADVANCED TECHNOLOGY LABORATORIES' |
VendorID 0x1189, 'MATSUSHITA ELECTIC INDUSTRIAL CO LTD' |
VendorID 0x118B, 'PLATYPUS TECHNOLOGY PTY LTD' |
VendorID 0x118C, 'Corollary Inc' |
VendorID 0x118D, 'BitFlow Inc' |
VendorID 0x118E, 'Hermstedt AG' |
VendorID 0x1190, 'Tripace' |
VendorID 0x1191, 'ACARD TECHNOLOGY' |
VendorID 0x1193, 'ZeitNet' |
VendorID 0x1195, 'RATOC SYSTEMS INC' |
VendorID 0x1197, 'Gage Applied Technologies' |
VendorID 0x1199, 'Attachmate Corp.' |
VendorID 0x119A, 'MINDSHARE.' |
VendorID 0x119B, 'Omega Micro Inc.' |
VendorID 0x119D, 'BUG.' |
VendorID 0x119E, 'FUJITSU MICROELECTRONICS LTD.' |
VendorID 0x119F, 'BULL HN INFORMATION SYSTEMS' |
VendorID 0x11A1, 'HAMAMATSU PHOTONICS K.K.' |
VendorID 0x11A8, 'Systech Corp.' |
VendorID 0x11A9, 'InnoSys Inc.' |
VendorID 0x11AA, 'ACTEL' |
VendorID 0x11AB, 'GALILEO TECHNOLOGY LTD/Marvell Semiconductor, Inc.' |
VendorID 0x11AD, 'LITE-ON COMMUNICATIONS INC' |
VendorID 0x11AE, 'SCITEX CORPORATION' |
VendorID 0x11AF, 'AVID TECHNOLOGY INC' |
VendorID 0x11B0, 'V3 SEMICONDUCTOR INC./Quicklogic Corp' |
VendorID 0x11B2, 'EASTMAN KODAK' |
VendorID 0x11B3, 'BARR SYSTEMS INC.' |
VendorID 0x11B5, 'Radstone Technology Ltd.' |
VendorID 0x11B8, 'Xpoint Technologies Inc' |
VendorID 0x11B9, 'Pathlight Technology Inc.' |
VendorID 0x11BC, 'Network Peripherals Inc' |
VendorID 0x11BD, 'Pinnacle Systems Inc.' |
VendorID 0x11BF, 'ASTRODESIGN' |
VendorID 0x11C1, 'AGERE/LUCENT' |
VendorID 0x11C6, 'DAINIPPON SCREEN MFG. CO. LTD' |
VendorID 0x11C8, 'DOLPHIN INTERCONNECT SOLUTIONS AS' |
VendorID 0x11C9, 'MAGMA' |
VendorID 0x11CA, 'LSI SYSTEMS' |
VendorID 0x11CB, 'SPECIALIX INTERNATIONAL LTD' |
VendorID 0x11CE, 'NETACCESS/Primary Rate Inc' |
VendorID 0x11D0, 'LOCKHEED MARTIN-Electronics & Communications' |
VendorID 0x11D1, 'AuraVision Corporation' |
VendorID 0x11D2, 'INTERCOM INC.' |
VendorID 0x11D4, 'Analog Devices, Inc.' |
VendorID 0x11D5, 'IKON CORPORATION/Tahoma Technology' |
VendorID 0x11D9, 'TOSHIBA TEC CORPORATION' |
VendorID 0x11DA, 'NOVELL' |
VendorID 0x11DB, 'Sega Enterprises Ltd' |
VendorID 0x11DE, 'Zoran Corporation' |
VendorID 0x11DF, 'NEW WAVE PDG' |
VendorID 0x11E3, 'QUICKLOGIC CORPORATION' |
VendorID 0x11EC, 'CORECO INC' |
VendorID 0x11EE, 'DOME IMAGING SYSTEMS INC' |
VendorID 0x11F0, 'Compu-Shack GmbH' |
VendorID 0x11F4, 'Kinetic Systems Corporation' |
VendorID 0x11F6, 'Powermatic Data Systems Ltd' |
VendorID 0x11F8, 'PMC-SIERRA INC' |
VendorID 0x11FE, 'Comtrol Corp' |
VendorID 0x1202, 'Network General Corp' |
VendorID 0x1203, 'AGFA CORPORATION' |
VendorID 0x1206, 'AMDAHL CORPORATION' |
VendorID 0x1208, 'Parsytec GmbH' |
VendorID 0x1209, 'Sci Systems Inc' |
VendorID 0x120E, 'Cyclades Corporation' |
VendorID 0x120F, 'ESSENTIAL COMMUNICATIONS' |
VendorID 0x1214, 'PERFORMANCE TECHNOLOGIES.' |
VendorID 0x1216, 'PURUP-EskoFot A/S' |
VendorID 0x1217, 'O2MICRO.' |
VendorID 0x121A, '3DFX INTERACTIVE' |
VendorID 0x121B, 'VIRATA LTD' |
VendorID 0x1220, 'Ariel Corporation' |
VendorID 0x1221, 'CONTEC CO. LTD' |
VendorID 0x1223, 'ARTESYN COMMUNICATIONS PRODUCTS INC' |
VendorID 0x1224, 'Interactive Images' |
VendorID 0x1227, 'TECH-SOURCE' |
VendorID 0x122C, 'SICAN GMBH' |
VendorID 0x122D, 'Aztech System Ltd' |
VendorID 0x1232, 'MARCONI COMMUNICATIONS LTD' |
VendorID 0x1236, 'Sigma Designs, Inc' |
VendorID 0x124C, 'Solitron Technologies Inc.' |
VendorID 0x124D, 'Stallion Technologies' |
VendorID 0x124F, 'Infortrend Technology Inc' |
VendorID 0x1256, 'Perceptive Solutions Inc.' |
VendorID 0x1258, 'Gilbarco Inc.' |
VendorID 0x125B, 'Asix Electronics Corp.' |
VendorID 0x1266, 'Microdyne Corp.' |
VendorID 0x1267, 'S.A. Telecommunications' |
VendorID 0x1361, 'SOLITON SYSTEMS K.K.' |
VendorID 0x123C, 'CENTURY SYSTEMS.' |
VendorID 0x123D, 'Engineering Design Team Inc.' |
VendorID 0x123F, 'C-CUBE MICROSYSTEMS' |
VendorID 0x1242, 'JAYCOR NETWORKS INC./JNI Corporation' |
VendorID 0x1244, 'AVM AUDIOVISUELLES MKTG & COMPUTER SYSTEM GMBH' |
VendorID 0x124B, 'SBS TECHNOLOGIES' |
VendorID 0x1250, 'Hitachi Microcomputer System Ltd.' |
VendorID 0x1253, 'GUZIK TECHNICAL ENTERPRISES' |
VendorID 0x1255, 'OPTIBASE LTD' |
VendorID 0x1259, 'ALLIED TELESYN INTERNATIONAL' |
VendorID 0x125C, 'AURORA TECHNOLOGIES.' |
VendorID 0x125D, 'ESS TECHNOLOGY, INC.' |
VendorID 0x125F, 'CONCURRENT TECHNOLOGIES' |
VendorID 0x1260, 'INTERSIL CORP' |
VendorID 0x1261, 'MATSUSHITA-KOTOBUKI ELECTRONICS' |
VendorID 0x1264, 'AVAL NAGASAKI CORPORATION' |
VendorID 0x1268, 'TEKTRONIX' |
VendorID 0x126C, 'Nortel Networks Corp.' |
VendorID 0x126D, 'SPLASH TECHNOLOGY.' |
VendorID 0x126E, 'SUMITOMO METAL INDUSTRIES' |
VendorID 0x126F, 'SILICON MOTION.' |
VendorID 0x1270, 'OLYMPUS OPTICAL CO. LTD.' |
VendorID 0x1274, 'Creative Labs (was Ensoniq, Malvern)' |
VendorID 0x1275, 'NETWORK APPLIANCE CORPORATION' |
VendorID 0x1278, 'Transtech Parallel Systems' |
VendorID 0x1279, 'TRANSMETA CORPORATION' |
VendorID 0x127A, 'CONEXANT, ROCKWELL' |
VendorID 0x127D, 'VELA RESEARCH LP' |
VendorID 0x127F, 'FUJIFILM' |
VendorID 0x1281, 'YOKOGAWA ELECTRIC CORPORATION' |
VendorID 0x1283, 'Integrated Technology Express Inc.' |
VendorID 0x1286, 'MAZET GMBH' |
VendorID 0x128B, 'TRANSWITCH CORPORATION' |
VendorID 0x128D, 'G2 Networks Inc.' |
VendorID 0x128F, 'TATENO DENNOU.' |
VendorID 0x1290, 'TOSHIBA PERSONAL COMPUTER SYSTEM CORP.' |
VendorID 0x1291, 'NCS COMPUTER ITALIA SRL' |
VendorID 0x1292, 'TRITECH MICROELECTRONICS INC' |
VendorID 0x1297, 'SHUTTLE COMPUTER' |
VendorID 0x1299, 'KNOWLEDGE TECHNOLOGY LAB.' |
VendorID 0x129A, 'VMETRO Inc.' |
VendorID 0x129E, 'VICTOR COMPANY OF JAPAN' |
VendorID 0x12A0, 'ALLEN- BRADLEY COMPANY' |
VendorID 0x12A3, 'Lucent Technologies AMR' |
VendorID 0x12A7, 'AMO GMBH' |
VendorID 0x12A9, 'XIOTECH CORPORATION' |
VendorID 0x12AB, 'YUAN YUAN ENTERPRISE CO. LTD.' |
VendorID 0x12AE, 'Alteon Networks Inc.' |
VendorID 0x12B6, 'NATURAL MICROSYSTEMS' |
VendorID 0x12B7, 'COGNEX MODULAR VISION SYSTEMS DIV.-ACUMEN INC.' |
VendorID 0x12B9, '3Com Corp, Modem Division' |
VendorID 0x12BC, 'ARRAY MICROSYSTEMS' |
VendorID 0x12BE, 'ANCHOR CHIPS INC.' |
VendorID 0x12BF, 'Fujifilm Microdevices' |
VendorID 0x12C0, 'INFIMED' |
VendorID 0x12C3, 'Holtek Microelectronics Inc.' |
VendorID 0x12C4, 'Connect Tech Inc' |
VendorID 0x12C6, 'Mitan Corporation' |
VendorID 0x12C7, 'Dialogic Corp' |
VendorID 0x12CA, 'Integrated Computing Engines' |
VendorID 0x12CD, 'Aims Lab' |
VendorID 0x12D2, 'NVIDIA (WAS: STB,SGS THOMPSON)' |
VendorID 0x12D3, 'GE VINGMED ULTRASOUND AS' |
VendorID 0x12D4, 'COMVERSE NETWORKS SYSTEM & Ulticom, Inc.' |
VendorID 0x12D5, 'Equator Technologies' |
VendorID 0x12D6, 'Analogic Corp' |
VendorID 0x12D8, 'PERICOM SEMICONDUCTOR' |
VendorID 0x12D9, 'Aculab PLC' |
VendorID 0x12DA, 'True Time Inc.' |
VendorID 0x12DE, 'Rainbow Technologies' |
VendorID 0x12DF, 'SBS Technologies Inc' |
VendorID 0x12E0, 'Chase Research PLC' |
VendorID 0x12E2, 'Datum Inc. Bancomm-Timing Division' |
VendorID 0x12E4, 'Brooktrout Technology Inc' |
VendorID 0x12E7, 'Sebring Systems' |
VendorID 0x12EA, 'Real Vision' |
VendorID 0x12EB, 'Aureal Semiconductor' |
VendorID 0x12EC, '3A' |
VendorID 0x12F0, 'PENTEK' |
VendorID 0x12F7, 'COGNEX INC.' |
VendorID 0x12FB, 'Spectrum Signal Processing' |
VendorID 0x12FC, 'CAPITAL EQUIPMENT CORP' |
VendorID 0x12FE, 'ESD Electronic System Design GmbH' |
VendorID 0x1304, 'Juniper Networks Inc.' |
VendorID 0x1307, 'Computer Boards' |
VendorID 0x1308, 'LEVEL ONE COMMUNICATIONS/Jato Technologies Inc.' |
VendorID 0x130A, 'Mitsubishi Electric MicroComputer' |
VendorID 0x130B, 'Colorgraphic Communications Corp' |
VendorID 0x130F, 'Advanet Inc' |
VendorID 0x1310, 'GESPAC' |
VendorID 0x1313, 'YASKAWA ELECTRIC CO.' |
VendorID 0x1316, 'TERADYNE INC.' |
VendorID 0x1317, 'ADMTEK INC' |
VendorID 0x1318, 'Packet Engines Inc.' |
VendorID 0x1319, 'ForteMedia' |
VendorID 0x131F, 'SIIG Inc' |
VendorID 0x1325, 'SALIX TECHNOLOGIES INC' |
VendorID 0x1326, 'SeaChange International' |
VendorID 0x1331, 'RadiSys Corp.' |
VendorID 0x133D, 'PRISA NETWORKS' |
VendorID 0x133F, 'SCM MICROSYSTEMS' |
VendorID 0x1342, 'PROMAX SYSTEMS INC' |
VendorID 0x1344, 'MICRON TECHNOLOGY INC' |
VendorID 0x134A, 'Domex' |
VendorID 0x134B, 'ARK RESEARCH CORP.' |
VendorID 0x134C, 'CHORI JOHO SYSTEM CO. LTD' |
VendorID 0x134D, 'PC-TEL INC' |
VendorID 0x135A, 'BRAIN BOXES LIMITED' |
VendorID 0x135C, 'QUATECH INC' |
VendorID 0x135E, 'SEALEVEL SYSTEMS INC' |
VendorID 0x135F, 'I-DATA INTERNATIONAL A-S' |
VendorID 0x1360, 'MEINBERG FUNKUHREN' |
VendorID 0x1363, 'PHOENIX TECHNOLOGIES LTD' |
VendorID 0x1365, 'HYPERCOPE' |
VendorID 0x1367, 'HITACHI ZOSEN CORPORATION' |
VendorID 0x1368, 'SKYWARE CORPORATION' |
VendorID 0x1369, 'DIGIGRAM' |
VendorID 0x136B, 'KAWASAKI STEEL CORPORATION' |
VendorID 0x136C, 'ADTEK SYSTEM SCIENCE CO LTD' |
VendorID 0x1375, 'BOEING-SUNNYVALE' |
VendorID 0x1376, 'LAN Media Corporation' |
VendorID 0x1377, 'ELECTRONIC EQUIPMENT PRODUCTION & DISTRIBUTION' |
VendorID 0x137A, 'MARK OF THE UNICORN INC' |
VendorID 0x137B, 'PPT VISION' |
VendorID 0x137C, 'IWATSU ELECTRIC CO LTD' |
VendorID 0x137D, 'DYNACHIP CORPORATION' |
VendorID 0x1380, 'SANRITZ AUTOMATION CO LTC' |
VendorID 0x1381, 'BRAINS CO. LTD' |
VendorID 0x1383, 'CONTROLNET INC' |
VendorID 0x1384, 'STELLAR SEMICONDUCTOR INC' |
VendorID 0x1385, 'NETGEAR' |
VendorID 0x1387, 'SYSTRAN CORP' |
VendorID 0x1388, 'HITACHI INFORMATION TECHNOLOGY CO LTD' |
VendorID 0x1389, 'APPLICOM INTERNATIONAL' |
VendorID 0x138A, 'SITERA' |
VendorID 0x138B, 'TOKIMEC INC' |
VendorID 0x138E, 'BASLER GMBH' |
VendorID 0x138F, 'PATAPSCO DESIGNS INC' |
VendorID 0x1393, 'MOXA TECHNOLOGIES CO LTD' |
VendorID 0x1394, 'LEVEL ONE COMMUNICATIONS' |
VendorID 0x1395, 'AMBICOM INC' |
VendorID 0x1396, 'CIPHER SYSTEMS INC' |
VendorID 0x1397, 'COLOGNE CHIP DESIGNS GMBH' |
VendorID 0x1398, 'CLARION CO. LTD' |
VendorID 0x1399, 'RIOS SYSTEMS CO LTD' |
VendorID 0x139A, 'ALACRITECH INC' |
VendorID 0x139C, 'QUANTUM 3D INC' |
VendorID 0x139D, 'XSTREAMS PLC/ EPL LIMITED' |
VendorID 0x139E, 'ECHOSTAR DATA NETWORKS' |
VendorID 0x139F, 'AETHRA S.R.L.' |
VendorID 0x13A0, 'CRYSTAL GROUP INC' |
VendorID 0x13A1, 'KAWASAKI HEAVY INDUSTRIES LTD' |
VendorID 0x13A2, 'OSITECH COMMUNICATIONS INC' |
VendorID 0x13A4, 'RASCOM INC' |
VendorID 0x13A7, 'TELES AG' |
VendorID 0x13A8, 'EXAR CORP.' |
VendorID 0x13A9, 'SIEMENS MEDICAL SYSTEMS' |
VendorID 0x13AA, 'NORTEL NETWORKS-BWA DIVISION' |
VendorID 0x13AF, 'T.SQWARE' |
VendorID 0x13B1, 'TAMURA CORPORATION' |
VendorID 0x13B4, 'WELLBEAN CO INC' |
VendorID 0x13B5, 'ARM Ltd' |
VendorID 0x13B6, 'DLoG GMBH' |
VendorID 0x13B8, 'NOKIA TELECOMMUNICATIONS OY' |
VendorID 0x13BD, 'SHARP CORPORATION' |
VendorID 0x13BF, 'SHAREWAVE INC' |
VendorID 0x13C0, 'Microgate Corp.' |
VendorID 0x13C1, '3ware Inc.' |
VendorID 0x13C2, 'TECHNOTREND SYSTEMTECHNIK GMBH' |
VendorID 0x13C3, 'JANZ COMPUTER AG' |
VendorID 0x13C6, 'CONDOR ENGINEERING INC' |
VendorID 0x13C7, 'BLUE CHIP TECHNOLOGY LTD' |
VendorID 0x13CA, 'IOMEGA CORPORATION' |
VendorID 0x13CC, 'METHEUS CORPORATION' |
VendorID 0x13CF, 'STUDIO AUDIO & VIDEO LTD' |
VendorID 0x13D0, 'B2C2' |
VendorID 0x13D1, 'ABOCOM SYSTEMS' |
VendorID 0x13D2, 'SHARK MULTIMEDIA INC' |
VendorID 0x13D3, 'IMC NETWORKS' |
VendorID 0x13D4, 'GRAPHICS MICROSYSTEMS INC' |
VendorID 0x13D6, 'K.I. TECHNOLOGY CO LTD' |
VendorID 0x13D7, 'TOSHIBA ENGINEERING CORPORATION' |
VendorID 0x13D8, 'PHOBOS CORPORATION' |
VendorID 0x13D9, 'APEX INC' |
VendorID 0x13DC, 'NETBOOST CORPORATION' |
VendorID 0x13DE, 'ABB ROBOTICS PRODUCTS' |
VendorID 0x13DF, 'E-TECH INC' |
VendorID 0x13E0, 'GVC CORPORATION' |
VendorID 0x13E3, 'NEST INC' |
VendorID 0x13E4, 'CALCULEX INC' |
VendorID 0x13E5, 'TELESOFT DESIGN LTD' |
VendorID 0x13E9, 'INTRASERVER TECHNOLOGY INC' |
VendorID 0x13EA, 'DALLAS SEMICONDUCTOR' |
VendorID 0x13F0, 'SUNDANCE TECHNOLOGY INC' |
VendorID 0x13F1, 'OCE-TECHNOLOGIES B.V.' |
VendorID 0x13F2, 'FORD MICROELECTRONICS INC' |
VendorID 0x13F4, 'TROIKA NETWORKS INC' |
VendorID 0x13F6, 'C-MEDIA ELECTRONICS INC' |
VendorID 0x13F9, 'NTT ADVANCED TECHNOLOGY CORP.' |
VendorID 0x13FB, 'AYDIN CORP' |
VendorID 0x13FD, 'MICRO SCIENCE INC' |
VendorID 0x1400, 'ARTX INC' |
VendorID 0x1402, 'Meilhaus Electronic GmbH Germany' |
VendorID 0x1404, 'FUNDAMENTAL SOFTWARE INC' |
VendorID 0x1406, 'OCE PRINTING SYSTEMS GmbH' |
VendorID 0x1407, 'LAVA COMPUTER MFG INC' |
VendorID 0x1408, 'ALOKA CO. LTD' |
VendorID 0x140A, 'DSP RESEARCH INC' |
VendorID 0x140B, 'RAMIX INC' |
VendorID 0x140D, 'MATSUSHITA ELECTRIC WORKS LTD' |
VendorID 0x1412, 'ICEnsemble' |
VendorID 0x1413, 'ADDONICS' |
VendorID 0x1415, 'OXFORD SEMICONDUCTOR LTD' |
VendorID 0x1418, 'KYUSHU ELECTRONICS SYSTEMS INC' |
VendorID 0x1419, 'EXCEL SWITCHING CORP' |
VendorID 0x141B, 'ZOOM TELEPHONICS INC' |
VendorID 0x141E, 'FANUC LTD' |
VendorID 0x1420, 'PSION DACOM PLC' |
VendorID 0x1428, 'EDEC CO LTD' |
VendorID 0x1429, 'UNEX TECHNOLOGY CORP' |
VendorID 0x142A, 'KINGMAX TECHNOLOGY INC' |
VendorID 0x142B, 'RADIOLAN' |
VendorID 0x142C, 'MINTON OPTIC INDUSTRY CO LTD' |
VendorID 0x142D, 'PIXSTREAM INC' |
VendorID 0x1430, 'ITT AEROSPACE/COMMUNICATIONS DIVISION' |
VendorID 0x1433, 'ELTEC ELEKTRONIK GMBH' |
VendorID 0x1436, 'CIS TECHNOLOGY INC' |
VendorID 0x1437, 'NISSIN INC CO' |
VendorID 0x1438, 'ATMEL-DREAM' |
VendorID 0x143F, 'LIGHTWELL CO LTD-ZAX DIVISION' |
VendorID 0x1441, 'AGIE SA' |
VendorID 0x1445, 'LOGICAL CO LTD' |
VendorID 0x1446, 'GRAPHIN CO. LTD' |
VendorID 0x1447, 'AIM GMBH' |
VendorID 0x144A, 'ADLINK Technology Inc' |
VendorID 0x144B, 'LORONIX INFORMATION SYSTEMS INC' |
VendorID 0x144D, 'SAMSUNG ELECTRONICS CO LTD' |
VendorID 0x1450, 'OCTAVE COMMUNICATIONS IND.' |
VendorID 0x1451, 'SP3D CHIP DESIGN GMBH' |
VendorID 0x1453, 'MYCOM INC' |
VendorID 0x1455, 'LOGIC PLUS PLUS INC' |
VendorID 0x1458, 'GIGA-BYTE TECHNOLOGY' |
VendorID 0x145C, 'CRYPTEK' |
VendorID 0x145F, 'BALDOR ELECTRIC COMPANY' |
VendorID 0x1460, 'DYNARC INC' |
VendorID 0x1461, 'AVERMEDIA Tech.' |
VendorID 0x1462, 'MICRO-STAR INTERNATIONAL CO LTD' |
VendorID 0x1463, 'FAST CORPORATION' |
VendorID 0x1464, 'INTERACTIVE CIRCUITS & SYSTEMS LTD' |
VendorID 0x1465, 'GN NETTEST TELECOM DIV.' |
VendorID 0x1468, 'AMBIT MICROSYSTEMS CORP.' |
VendorID 0x1469, 'CLEVELAND MOTION CONTROLS' |
VendorID 0x146C, 'RUBY TECH CORP.' |
VendorID 0x146D, 'TACHYON' |
VendorID 0x146E, 'WILLIAMS ELECTRONICS GAMES.' |
VendorID 0x1471, 'INTEGRATED TELECOM EXPRESS INC' |
VendorID 0x1473, 'ZAPEX TECHNOLOGIES INC' |
VendorID 0x1474, 'DOUG CARSON & ASSOCIATES' |
VendorID 0x1477, 'NET INSIGHT' |
VendorID 0x1478, 'DIATREND CORPORATION' |
VendorID 0x147B, 'ABIT Computer' |
VendorID 0x147F, 'NIHON UNISYS' |
VendorID 0x1482, 'ISYTEC-Integrierte Systemtechnik Gmbh' |
VendorID 0x1483, 'LABWAY COPORATION' |
VendorID 0x1485, 'ERMA-ELECTRONIC GMBH' |
VendorID 0x1489, 'KYE SYSTEMS CORPORATION' |
VendorID 0x148A, 'OPTO 22' |
VendorID 0x148B, 'INNOMEDIALOGIC INC.' |
VendorID 0x148E, 'OSI PLUS CORPORATION' |
VendorID 0x148F, 'PLANT EQUIPMENT.' |
VendorID 0x1490, 'TC LABS PTY LTD.' |
VendorID 0x1493, 'MAKER COMMUNICATIONS' |
VendorID 0x1495, 'TOKAI COMMUNICATIONS INDUSTRY CO. LTD' |
VendorID 0x1496, 'JOYTECH COMPUTER CO. LTD.' |
VendorID 0x1497, 'SMA REGELSYSTEME GMBH' |
VendorID 0x1499, 'EMTEC CO. LTD' |
VendorID 0x149A, 'ANDOR TECHNOLOGY LTD' |
VendorID 0x149B, 'SEIKO INSTRUMENTS INC' |
VendorID 0x149C, 'OVISLINK CORP.' |
VendorID 0x149D, 'NEWTEK INC' |
VendorID 0x149E, 'MAPLETREE NETWORKS INC.' |
VendorID 0x149F, 'LECTRON CO LTD' |
VendorID 0x14A0, 'SOFTING GMBH' |
VendorID 0x14A1, 'SYSTEMBASE CO LTD' |
VendorID 0x14A2, 'MILLENNIUM ENGINEERING INC' |
VendorID 0x14A3, 'MAVERICK NETWORKS' |
VendorID 0x14A4, 'GVC/BCM ADVANCED RESEARCH' |
VendorID 0x14A5, 'XIONICS DOCUMENT TECHNOLOGIES INC.' |
VendorID 0x14A6, 'INOVA COMPUTERS GMBH & CO KG' |
VendorID 0x14A8, 'FEATRON TECHNOLOGIES CORPORATION' |
VendorID 0x14A9, 'HIVERTEC INC.' |
VendorID 0x14AB, 'MENTOR GRAPHICS CORP.' |
VendorID 0x14AC, 'NOVAWEB TECHNOLOGIES INC' |
VendorID 0x14AD, 'TIME SPACE RADIO AB' |
VendorID 0x14AE, 'CTI PET Systems' |
VendorID 0x14AF, 'GUILLEMOT CORPORATION' |
VendorID 0x14B0, 'BST COMMUNICATION TECHNOLOGY LTD' |
VendorID 0x14B1, 'NEXTCOM K.K.' |
VendorID 0x14B2, 'ENNOVATE NETWORKS INC' |
VendorID 0x14B3, 'XPEED INC.' |
VendorID 0x14B4, 'PHILIPS BUSINESS ELECTRONICS B.V.' |
VendorID 0x14B5, 'CREAMWARE GMBH' |
VendorID 0x14B6, 'QUANTUM DATA CORP.' |
VendorID 0x14B7, 'PROXIM INC' |
VendorID 0x14B8, 'TECHSOFT TECHNOLOGY CO LTD' |
VendorID 0x14B9, 'AIRONET WIRELESS COMMUNICATIONS' |
VendorID 0x14BA, 'INTERNIX INC.' |
VendorID 0x14BB, 'SEMTECH CORPORATION' |
VendorID 0x14BC, 'GLOBESPAN SEMICONDUCTOR INC.' |
VendorID 0x14BD, 'CARDIO CONTROL N.V.' |
VendorID 0x14BE, 'L3 COMMUNICATIONS' |
VendorID 0x14BF, 'SPIDER COMMUNICATIONS INC.' |
VendorID 0x14C0, 'COMPAL ELECTRONICS INC' |
VendorID 0x14C1, 'MYRICOM INC.' |
VendorID 0x14C2, 'DTK COMPUTER' |
VendorID 0x14C3, 'MEDIATEK CORP.' |
VendorID 0x14C4, 'IWASAKI INFORMATION SYSTEMS CO LTD' |
VendorID 0x14C5, 'ABB AUTOMATION PRODUCTS' |
VendorID 0x14C6, 'DATA RACE INC' |
VendorID 0x14C7, 'MODULAR TECHNOLOY HOLDINGS LTD' |
VendorID 0x14C8, 'TURBOCOMM TECH. INC.' |
VendorID 0x14C9, 'ODIN TELESYSTEMS INC' |
VendorID 0x14CA, 'PE LOGIC CORP.' |
VendorID 0x14CB, 'Billionton Systems Inc./Cadmus Micro Inc.' |
VendorID 0x14CC, 'NAKAYO TELECOMMUNICATIONS INC' |
VendorID 0x14CD, 'UNIVERSAL SCIENTIFIC IND' |
VendorID 0x14CE, 'WHISTLE COMMUNICATIONS' |
VendorID 0x14CF, 'TEK MICROSYSTEMS INC.' |
VendorID 0x14D0, 'ERICSSON AXE R & D' |
VendorID 0x14D1, 'COMPUTER HI-TECH CO LTD' |
VendorID 0x14D2, 'TITAN ELECTRONICS INC' |
VendorID 0x14D3, 'CIRTECH (UK) LTD' |
VendorID 0x14D4, 'PANACOM TECHNOLOGY CORP' |
VendorID 0x14D5, 'NITSUKO CORPORATION' |
VendorID 0x14D6, 'ACCUSYS' |
VendorID 0x14D7, 'HIRAKAWA HEWTECH CORP' |
VendorID 0x14D8, 'HOPF ELEKTRONIK GMBH' |
VendorID 0x14D9, 'ALPHA PROCESSOR INC' |
VendorID 0x14DA, 'NATIONAL AEROSPACE LABORATORIES' |
VendorID 0x14DB, 'AVLAB TECHNOLOGY INC' |
VendorID 0x14DC, 'AMPLICON LIVELINE LTD' |
VendorID 0x14DD, 'IMODL INC.' |
VendorID 0x14DE, 'APPLIED INTEGRATION CORPORATION' |
VendorID 0x14DF, 'BASIS COMMUNICATIONS CORP' |
VendorID 0x14E1, 'INVERTEX' |
VendorID 0x14E2, 'INFOLIBRIA' |
VendorID 0x14E3, 'AMTELCO' |
VendorID 0x14E4, 'BROADCOM CORPORATION' |
VendorID 0x14E5, 'PIXELFUSION LTD' |
VendorID 0x14E6, 'SHINING TECHNOLOGY INC' |
VendorID 0x14E7, '3CX' |
VendorID 0x14E8, 'RAYCER INC' |
VendorID 0x14E9, 'GARNETS SYSTEM CO LTD' |
VendorID 0x14EA, 'PLANEX COMMUNICATIONS INC' |
VendorID 0x14EB, 'SEIKO EPSON CORPORATION' |
VendorID 0x14EC, 'ACQIRIS' |
VendorID 0x14ED, 'DATAKINETICS LTD' |
VendorID 0x14EE, 'MASPRO KENKOH CORP' |
VendorID 0x14EF, 'CARRY COMPUTER ENG. CO LTD' |
VendorID 0x14F0, 'CANON RESEACH CENTRE FRANCE' |
VendorID 0x14F1, 'Conexant Systems, Inc' |
VendorID 0x14F2, 'Mobility Electronics, Inc.' |
VendorID 0x14F3, 'BROADLOGIC' |
VendorID 0x14F4, 'TOKYO ELECTRONIC INDUSTRY CO LTD' |
VendorID 0x14F5, 'SOPAC LTD' |
VendorID 0x14F6, 'COYOTE TECHNOLOGIES LLC' |
VendorID 0x14F7, 'WOLF TECHNOLOGY INC' |
VendorID 0x14F8, 'AUDIOCODES INC' |
VendorID 0x14F9, 'AG COMMUNICATIONS' |
VendorID 0x14FA, 'WAVETEK WANDEL & GOLTERMANN' |
VendorID 0x14FB, 'TRANSAS MARINE (UK) LTD' |
VendorID 0x14FC, 'QUADRICS SUPERCOMPUTERS WORLD' |
VendorID 0x14FD, 'JAPAN COMPUTER INDUSTRY INC.' |
VendorID 0x14FE, 'ARCHTEK TELECOM CORP.' |
VendorID 0x14FF, 'TWINHEAD INTERNATIONAL CORP' |
VendorID 0x1500, 'LANTECH COMPUTER COMPANY' |
VendorID 0x1501, 'BANKSOFT CANADA LTD' |
VendorID 0x1502, 'MITSUBISHI ELECTRIC LOGISTICS SUPPORT CO' |
VendorID 0x1503, 'KAWASAKI LSI USA INC' |
VendorID 0x1504, 'KAISER ELECTRONICS' |
VendorID 0x1505, 'ITA INGENIEURBURO FUR TESTAUFGABEN GMBH' |
VendorID 0x1506, 'CHAMELEON SYSTEMS INC' |
VendorID 0x1507, 'HTEC LTD' |
VendorID 0x1508, 'HONDA CONNECTORS/MHOTRONICS INC' |
VendorID 0x1509, 'FIRST INTERNATIONAL COMPUTER INC' |
VendorID 0x150A, 'FORVUS RESEARCH INC' |
VendorID 0x150B, 'YAMASHITA SYSTEMS CORP' |
VendorID 0x150C, 'KYOPAL CO LTD' |
VendorID 0x150D, 'WARPSPPED INC' |
VendorID 0x150E, 'C-PORT CORPORATION' |
VendorID 0x150F, 'INTEC GMBH' |
VendorID 0x1510, 'BEHAVIOR TECH COMPUTER CORP' |
VendorID 0x1511, 'CENTILLIUM TECHNOLOGY CORP' |
VendorID 0x1512, 'ROSUN TECHNOLOGIES INC' |
VendorID 0x1513, 'RAYCHEM' |
VendorID 0x1514, 'TFL LAN INC' |
VendorID 0x1515, 'ICS ADVENT' |
VendorID 0x1516, 'MYSON TECHNOLOGY INC' |
VendorID 0x1517, 'ECHOTEK CORPORATION' |
VendorID 0x1518, 'PEP MODULAR COMPUTERS GMBH' |
VendorID 0x1519, 'TELEFON AKTIEBOLAGET LM Ericsson' |
VendorID 0x151A, 'GLOBETEK INC' |
VendorID 0x151B, 'COMBOX LTD' |
VendorID 0x151C, 'DIGITAL AUDIO LABS INC' |
VendorID 0x151D, 'FUJITSU COMPUTER PRODUCTS OF AMERICA' |
VendorID 0x151E, 'MATRIX CORP.' |
VendorID 0x151F, 'TOPIC SEMICONDUCTOR CORP' |
VendorID 0x1520, 'CHAPLET SYSTEM INC' |
VendorID 0x1521, 'BELL CORPORATION' |
VendorID 0x1522, 'MAINPINE LIMITED' |
VendorID 0x1523, 'MUSIC SEMICONDUCTORS' |
VendorID 0x1524, 'ENE TECHNOLOGY INC' |
VendorID 0x1525, 'IMPACT TECHNOLOGIES' |
VendorID 0x1526, 'ISS' |
VendorID 0x1527, 'SOLECTRON' |
VendorID 0x1528, 'ACKSYS' |
VendorID 0x1529, 'AMERICAN MICROSYSTEMS INC' |
VendorID 0x152A, 'QUICKTURN DESIGN SYSTEMS' |
VendorID 0x152B, 'FLYTECH TECHNOLOGY CO LTD' |
VendorID 0x152C, 'MACRAIGOR SYSTEMS LLC' |
VendorID 0x152D, 'QUANTA COMPUTER INC' |
VendorID 0x152E, 'MELEC INC' |
VendorID 0x152F, 'PHILIPS-CRYPTO' |
VendorID 0x1530, 'ACQIS TECHNOLOGY' |
VendorID 0x1531, 'CHRYON CORP.' |
VendorID 0x1532, 'ECHELON CORPORATION' |
VendorID 0x1533, 'BALTIMORE' |
VendorID 0x1534, 'ROAD CORPORATION' |
VendorID 0x1535, 'EVERGREEN TECHNOLOGIES INC' |
VendorID 0x1537, 'DATALEX COMMUNCATIONS' |
VendorID 0x1538, 'ARALION INC.' |
VendorID 0x1539, 'ATELIER INFORMATIQUES et ELECTRONIQUE ETUDES S.A.' |
VendorID 0x153A, 'ONO SOKKI' |
VendorID 0x153B, 'TERRATEC ELECTRONIC GMBH' |
VendorID 0x153C, 'ANTAL ELECTRONIC' |
VendorID 0x153D, 'FILANET CORPORATION' |
VendorID 0x153E, 'TECHWELL INC' |
VendorID 0x153F, 'MIPS DENMARK' |
VendorID 0x1540, 'PROVIDEO MULTIMEDIA CO LTD' |
VendorID 0x1541, 'TELOSITY INC.' |
VendorID 0x1542, 'VIVID TECHNOLOGY INC' |
VendorID 0x1543, 'SILICON LABORATORIES' |
VendorID 0x1544, 'DCM DATA SYSTEMS' |
VendorID 0x1545, 'VISIONTEK' |
VendorID 0x1546, 'IOI TECHNOLOGY CORP.' |
VendorID 0x1547, 'MITUTOYO CORPORATION' |
VendorID 0x1548, 'JET PROPULSION LABORATORY' |
VendorID 0x1549, 'INTERCONNECT SYSTEMS SOLUTIONS' |
VendorID 0x154A, 'MAX TECHNOLOGIES INC.' |
VendorID 0x154B, 'COMPUTEX CO LTD' |
VendorID 0x154C, 'VISUAL TECHNOLOGY INC.' |
VendorID 0x154D, 'PAN INTERNATIONAL INDUSTRIAL CORP' |
VendorID 0x154E, 'SERVOTEST LTD' |
VendorID 0x154F, 'STRATABEAM TECHNOLOGY' |
VendorID 0x1550, 'OPEN NETWORK CO LTD' |
VendorID 0x1551, 'SMART ELECTRONIC DEVELOPMENT GMBH' |
VendorID 0x1552, 'RACAL AIRTECH LTD' |
VendorID 0x1553, 'CHICONY ELECTRONICS CO LTD' |
VendorID 0x1554, 'PROLINK MICROSYSTEMS CORP.' |
VendorID 0x1555, 'GESYTEC GMBH' |
VendorID 0x1556, 'PLD APPLICATIONS' |
VendorID 0x1557, 'MEDIASTAR CO. LTD' |
VendorID 0x1558, 'CLEVO/KAPOK COMPUTER' |
VendorID 0x1559, 'SI LOGIC LTD' |
VendorID 0x155A, 'INNOMEDIA INC' |
VendorID 0x155B, 'PROTAC INTERNATIONAL CORP' |
VendorID 0x155C, 'CEMAX-ICON INC' |
VendorID 0x155D, 'MAC SYSTEM CO LTD' |
VendorID 0x155E, 'LP ELEKTRONIK GMBH/KUKA Controls GmbH' |
VendorID 0x155F, 'PERLE SYSTEMS LIMITED' |
VendorID 0x1560, 'TERAYON COMMUNICATIONS SYSTEMS' |
VendorID 0x1561, 'VIEWGRAPHICS INC' |
VendorID 0x1562, 'Symbol Technologies, Inc.' |
VendorID 0x1563, 'A-TREND' |
VendorID 0x1564, 'YAMAKATSU ELECTRONICS INDUSTRY CO LTD' |
VendorID 0x1565, 'BIOSTAR MICROTECH INT CORP' |
VendorID 0x1566, 'ARDENT TECHNOLOGIES INC' |
VendorID 0x1567, 'JUNGSOFT' |
VendorID 0x1568, 'DDK ELECTRONICS INC' |
VendorID 0x1569, 'PALIT MICROSYSTEMS INC' |
VendorID 0x156A, 'AVTEC SYSTEMS' |
VendorID 0x156B, '2WIRE' |
VendorID 0x156C, 'VIDAC ELECTRONICS GMBH' |
VendorID 0x156D, 'ALPHA-TOP CORP' |
VendorID 0x156E, 'ALFA INC' |
VendorID 0x156F, 'M-SYSTEMS FLASH DISK PIONEERS LTD' |
VendorID 0x1570, 'LECROY CORPORATION' |
VendorID 0x1571, 'CONTEMPORARY CONTROLS' |
VendorID 0x1572, 'OTIS ELEVATOR COMPANY' |
VendorID 0x1573, 'LATTICE-VANTIS' |
VendorID 0x1574, 'FAIRCHILD SEMICONDUCTOR' |
VendorID 0x1575, 'VOLTAIRE ADVANCED DATA SECURITY LTD' |
VendorID 0x1576, 'VIEWCAST COM' |
VendorID 0x1578, 'HITT' |
VendorID 0x1579, 'DUAL TECHNOLOGY CORPORATION' |
VendorID 0x157A, 'JAPAN ELECRONICS IND. INC' |
VendorID 0x157B, 'STAR MULTIMEDIA CORP.' |
VendorID 0x157C, 'EUROSOFT (UK) LTD' |
VendorID 0x157D, 'GEMFLEX NETWORKS' |
VendorID 0x157E, 'TRANSITION NETWORKS' |
VendorID 0x157F, 'PX INSTRUMENTS TECHNOLOGY LTD' |
VendorID 0x1580, 'PRIMEX AEROSPACE CO.' |
VendorID 0x1581, 'SEH COMPUTERTECHNIK GMBH' |
VendorID 0x1582, 'CYTEC CORPORATION' |
VendorID 0x1583, 'INET TECHNOLOGIES INC' |
VendorID 0x1584, 'UNIWILL COMPUTER CORP' |
VendorID 0x1585, 'LOGITRON' |
VendorID 0x1586, 'LANCAST INC' |
VendorID 0x1587, 'KONICA CORPORATION' |
VendorID 0x1588, 'SOLIDUM SYSTEMS CORP' |
VendorID 0x1589, 'ATLANTEK MICROSYSTEMS PTY LTD' |
VendorID 0x158A, 'DIGALOG SYSTEMS INC' |
VendorID 0x158B, 'ALLIED DATA TECHNOLOGIES' |
VendorID 0x158C, 'HITACHI SEMICONDUCTOR & DEVICES SALES CO LTD' |
VendorID 0x158D, 'POINT MULTIMEDIA SYSTEMS' |
VendorID 0x158E, 'LARA TECHNOLOGY INC' |
VendorID 0x158F, 'DITECT COOP' |
VendorID 0x1590, '3PARDATA' |
VendorID 0x1591, 'ARN' |
VendorID 0x1592, 'SYBA TECH LIMITED' |
VendorID 0x1593, 'BOPS INC' |
VendorID 0x1594, 'NETGAME LTD' |
VendorID 0x1595, 'DIVA SYSTEMS CORP.' |
VendorID 0x1596, 'FOLSOM RESEARCH INC' |
VendorID 0x1597, 'MEMEC DESIGN SERVICES' |
VendorID 0x1598, 'GRANITE MICROSYSTEMS' |
VendorID 0x1599, 'DELTA ELECTRONICS INC' |
VendorID 0x159A, 'GENERAL INSTRUMENT' |
VendorID 0x159B, 'FARADAY TECHNOLOGY CORP' |
VendorID 0x159C, 'STRATUS COMPUTER SYSTEMS' |
VendorID 0x159D, 'NINGBO HARRISON ELECTRONICS CO LTD' |
VendorID 0x159E, 'A-MAX TECHNOLOGY' |
VendorID 0x159F, 'GALEA NETWORK SECURITY' |
VendorID 0x15A0, 'COMPUMASTER SRL' |
VendorID 0x15A1, 'GEOCAST NETWORK SYSTEMS INC' |
VendorID 0x15A2, 'CATALYST ENTERPRISES INC' |
VendorID 0x15A3, 'ITALTEL' |
VendorID 0x15A4, 'X-NET OY' |
VendorID 0x15A5, 'TOYOTA MACS INC' |
VendorID 0x15A6, 'SUNLIGHT ULTRASOUND TECHNOLOGIES LTD' |
VendorID 0x15A7, 'SSE TELECOM INC' |
VendorID 0x15A8, 'SHANGHAI COMMUNICATIONS TECHNOLOGIES CENTER' |
VendorID 0x15AA, 'MORETON BAY' |
VendorID 0x15AB, 'BLUESTEEL NETWORKS INC' |
VendorID 0x15AC, 'NORTH ATLANTIC INSTRUMENTS' |
VendorID 0x15AD, 'VMware Inc.' |
VendorID 0x15AE, 'AMERSHAM PHARMACIA BIOTECH' |
VendorID 0x15B0, 'ZOLTRIX INTERNATIONAL LIMITED' |
VendorID 0x15B1, 'SOURCE TECHNOLOGY INC' |
VendorID 0x15B2, 'MOSAID TECHNOLOGIES INC.' |
VendorID 0x15B3, 'MELLANOX TECHNOLOGY' |
VendorID 0x15B4, 'CCI/TRIAD' |
VendorID 0x15B5, 'CIMETRICS INC' |
VendorID 0x15B6, 'TEXAS MEMORY SYSTEMS INC' |
VendorID 0x15B7, 'SANDISK CORP.' |
VendorID 0x15B8, 'ADDI-DATA GMBH' |
VendorID 0x15B9, 'MAESTRO DIGITAL COMMUNICATIONS' |
VendorID 0x15BA, 'IMPACCT TECHNOLOGY CORP' |
VendorID 0x15BB, 'PORTWELL INC' |
VendorID 0x15BC, 'AGILENT TECHNOLOGIES' |
VendorID 0x15BD, 'DFI INC.' |
VendorID 0x15BE, 'SOLA ELECTRONICS' |
VendorID 0x15BF, 'HIGH TECH COMPUTER CORP (HTC)' |
VendorID 0x15C0, 'BVM LIMITED' |
VendorID 0x15C1, 'QUANTEL' |
VendorID 0x15C2, 'NEWER TECHNOLOGY INC' |
VendorID 0x15C3, 'TAIWAN MYCOMP CO LTD' |
VendorID 0x15C4, 'EVSX' |
VendorID 0x15C5, 'PROCOMP INFORMATICS LTD' |
VendorID 0x15C6, 'TECHNICAL UNIVERSITY OF BUDAPEST' |
VendorID 0x15C7, 'TATEYAMA SYSTEM LABORATORY CO LTD' |
VendorID 0x15C8, 'PENTA MEDIA CO. LTD' |
VendorID 0x15C9, 'SEROME TECHNOLOGY INC' |
VendorID 0x15CA, 'BITBOYS OY' |
VendorID 0x15CB, 'AG ELECTRONICS LTD' |
VendorID 0x15CC, 'HOTRAIL INC.' |
VendorID 0x15CD, 'DREAMTECH CO LTD' |
VendorID 0x15CE, 'GENRAD INC.' |
VendorID 0x15CF, 'HILSCHER GMBH' |
VendorID 0x15D1, 'INFINEON TECHNOLOGIES AG' |
VendorID 0x15D2, 'FIC (FIRST INTERNATIONAL COMPUTER INC)' |
VendorID 0x15D3, 'NDS TECHNOLOGIES ISRAEL LTD' |
VendorID 0x15D4, 'IWILL CORPORATION' |
VendorID 0x15D5, 'TATUNG CO.' |
VendorID 0x15D6, 'ENTRIDIA CORPORATION' |
VendorID 0x15D7, 'Rockwell-Collins Inc' |
VendorID 0x15D8, 'CYBERNETICS TECHNOLOGY CO LTD' |
VendorID 0x15D9, 'SUPER MICRO COMPUTER INC' |
VendorID 0x15DA, 'CYBERFIRM INC.' |
VendorID 0x15DB, 'APPLIED COMPUTING SYSTEMS INC.' |
VendorID 0x15DC, 'LITRONIC INC' |
VendorID 0x15DD, 'SIGMATEL INC.' |
VendorID 0x15DE, 'MALLEABLE TECHNOLOGIES INC' |
VendorID 0x15DF, 'INFINILINK CORP.' |
VendorID 0x15E0, 'CACHEFLOW INC' |
VendorID 0x15E1, 'VOICE TECHNOLOGIES GROUP INC' |
VendorID 0x15E2, 'QUICKNET TECHNOLOGIES INC' |
VendorID 0x15E3, 'NETWORTH TECHNOLOGIES INC' |
VendorID 0x15E4, 'VSN SYSTEMEN BV' |
VendorID 0x15E5, 'VALLEY TECHNOLOGIES INC' |
VendorID 0x15E6, 'AGERE INC.' |
VendorID 0x15E7, 'GET ENGINEERING CORP.' |
VendorID 0x15E8, 'NATIONAL DATACOMM CORP.' |
VendorID 0x15E9, 'PACIFIC DIGITAL CORP.' |
VendorID 0x15EA, 'TOKYO DENSHI SEKEI K.K.' |
VendorID 0x15EB, 'DRSEARCH GMBH' |
VendorID 0x15EC, 'BECKHOFF GMBH' |
VendorID 0x15ED, 'MACROLINK INC' |
VendorID 0x15EE, 'IN WIN DEVELOPMENT INC.' |
VendorID 0x15EF, 'INTELLIGENT PARADIGM INC' |
VendorID 0x15F0, 'B-TREE SYSTEMS INC' |
VendorID 0x15F1, 'TIMES N SYSTEMS INC' |
VendorID 0x15F2, 'DIAGNOSTIC INSTRUMENTS INC' |
VendorID 0x15F3, 'DIGITMEDIA CORP.' |
VendorID 0x15F4, 'VALUESOFT' |
VendorID 0x15F5, 'POWER MICRO RESEARCH' |
VendorID 0x15F6, 'EXTREME PACKET DEVICE INC' |
VendorID 0x15F7, 'BANCTEC' |
VendorID 0x15F8, 'KOGA ELECTRONICS CO' |
VendorID 0x15F9, 'ZENITH ELECTRONICS CORPORATION' |
VendorID 0x15FA, 'J P AXZAM CORPORATION' |
VendorID 0x15FB, 'ZILOG INC.' |
VendorID 0x15FC, 'TECHSAN ELECTRONICS CO LTD' |
VendorID 0x15FD, 'N-CUBED.NET' |
VendorID 0x15FE, 'KINPO ELECTRONICS INC' |
VendorID 0x15FF, 'FASTPOINT TECHNOLOGIES INC.' |
VendorID 0x1600, 'NORTHROP GRUMMAN-CANADA LTD' |
VendorID 0x1601, 'TENTA TECHNOLOGY' |
VendorID 0x1602, 'PROSYS-TEC INC.' |
VendorID 0x1603, 'NOKIA WIRELESS BUSINESS COMMUNICATIONS' |
VendorID 0x1604, 'CENTRAL SYSTEM RESEARCH CO LTD' |
VendorID 0x1605, 'PAIRGAIN TECHNOLOGIES' |
VendorID 0x1606, 'EUROPOP AG' |
VendorID 0x1607, 'LAVA SEMICONDUCTOR MANUFACTURING INC.' |
VendorID 0x1608, 'AUTOMATED WAGERING INTERNATIONAL' |
VendorID 0x1609, 'SCIEMETRIC INSTRUMENTS INC' |
VendorID 0x166D, 'Broadcom -SiByte' |
VendorID 0x168C, 'Atheros Communications Inc.' |
VendorID 0x1695, 'EPOX Computer Co' |
VendorID 0x17F2, 'ALBATRON Corp.' |
VendorID 0x1813, 'AMBIENT TECHNOLOGIES INC' |
VendorID 0x1849, 'ASROCK Inc' |
VendorID 0x1B13, 'Jaton Corp' |
VendorID 0x2001, 'TEMPORAL RESEARCH LTD' |
VendorID 0x270F, 'CHAINTECH COMPUTER CO. LTD' |
VendorID 0x3388, 'HINT CORP' |
VendorID 0x3411, 'QUANTUM DESIGNS (H.K.) INC.' |
VendorID 0x4005, 'AVANCE LOGIC INC' |
VendorID 0x4033, 'DELTA NETWORKS INC' |
VendorID 0x416C, 'ALADDIN KNOWLEDGE SYSTEMS' |
VendorID 0x4444, 'CONEXANT (WAS ICOMPRESION INC.)' |
VendorID 0x4943, 'GROWTH NETWORKS' |
VendorID 0x4CA1, 'SEANIX TECHNOLOGY INC' |
VendorID 0x4D51, 'MEDIAQ INC.' |
VendorID 0x4D54, 'MICROTECHNICA CO LTD' |
VendorID 0x5136, 'S S TECHNOLOGIES' |
VendorID 0x5333, 'S3 Graphics Co., Ltd.' |
VendorID 0x544C, 'TERALOGIC INC' |
VendorID 0x5555, 'GENROCO INC' |
VendorID 0x6409, 'LOGITEC CORP.' |
VendorID 0x6666, 'DECISION COMPUTER INTERNATIONAL CO.' |
VendorID 0x8086, 'Intel Corp.' |
VendorID 0x8888, 'SILICON MAGIC CORP.' |
VendorID 0x8E0E, 'COMPUTONE CORPORATION' |
VendorID 0x9004, 'Adaptec Inc' |
VendorID 0x919A, 'GIGAPIXEL CORP' |
VendorID 0x9412, 'HOLTEK' |
VendorID 0x9699, 'OMNI MEDIA TECHNOLOGY INC.' |
VendorID 0x9710, 'NetMos' |
VendorID 0xA0A0, 'AOPEN INC.' |
VendorID 0xA259, 'HEWLETT PACKARD' |
VendorID 0xAC1E, 'DIGITAL RECEIVER TECHNOLOGY INC' |
VendorID 0xC0DE, 'MOTOROLA' |
VendorID 0xC0FE, 'MOTION ENGINEERING.' |
VendorID 0xCA50, 'VARIAN AUSTRIALIA PTY LTD' |
VendorID 0xCAFE, 'CHRYSALIS-ITS' |
VendorID 0xCCCC, 'CATAPULT COMMUNICATIONS' |
VendorID 0xD4D4, 'DY4 Systems Inc/Curtiss-Wright Controls Embed. Com' |
VendorID 0xE159, 'TigerJet' |
VendorID 0xE4BF, 'EKF ELEKTRONIK GMBH' |
VendorID 0xEA01, 'EAGLE TECHNOLOGY' |
VendorID 0xFA57, 'FAST SEARCH & TRANSFER ASA' |
VendorID 0xFEDA, 'EPIGRAM INC' |
VendorID 0, 'Unknown' ; <- terminator |
;-------------------------------------- |
Classes: |
; Class, Subclass, [Interface], Name |
ClassID 2, 0, , 'Ethernet' |
ClassID 2, 1, , 'Token Ring' |
ClassID 2, 2, , 'FDDI' |
ClassID 2, 3, , 'ATM' |
ClassID 2, 4, , 'ISDN' |
ClassID 2, 5, , 'WorldFip' |
ClassID 2, 6, , 'PICMG 2.14' |
ClassID 2, 0x80, , 'misc' |
ClassID 0x0d, 0x20, , 'Wlan (802.11a)' |
ClassID 0x0d, 0x21, , 'Wlan (802.11b)' |
ClassID 0xff, 0xff, , 'Unknown' ; <- terminator |
/programs/network/netcfg |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/netstat/netstat.asm |
---|
0,0 → 1,614 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; netstat.asm - Network Status Tool for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd (I_END+0x100) ; memory for app |
dd (I_END+0x100) ; esp |
dd I_PARAM , 0x0 ; I_Param , I_Icon |
include '..\macros.inc' |
include '..\network.inc' |
START: |
mcall 40, EVM_REDRAW + EVM_BUTTON + EVM_STACK2 |
redraw: |
mcall 12, 1 |
mcall 0, 100 shl 16 + 600, 100 shl 16 + 240, 0x34bcbcbc, , name ; draw window |
call draw_interfaces |
mov edx, 101 |
mov esi, 0x00aaaaff |
mov edi, 0x00aaffff |
cmp dl, [mode] |
cmove esi, edi |
mcall 8, 25 shl 16 + 65, 25 shl 16 + 20 |
.morebuttons: |
inc edx |
add ebx, 75 shl 16 |
mov esi, 0x00aaaaff |
cmp dl, [mode] |
cmove esi, edi |
mcall |
cmp edx, 105 |
jle .morebuttons |
mcall 4, 28 shl 16 + 31, 0x80000000, modes |
cmp [mode], 101 |
jne .no_eth |
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx |
add ebx, 18 |
mov edx, str_packets_rx |
mcall |
add ebx, 18 |
mov edx, str_bytes_tx |
mcall |
add ebx, 18 |
mov edx, str_bytes_rx |
mcall |
add ebx, 18 |
mov edx, str_MAC |
mcall |
add ebx, 18 |
mov edx, str_link |
mcall |
mov ebx, API_ETH + 4 |
mov bh, [device] |
mcall 76 |
push eax |
push bx |
mov edx, 135 shl 16 + 75 + 4*18 |
call draw_mac |
jmp end_of_draw |
.no_eth: |
cmp [mode], 102 |
jne .no_ip |
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx |
add ebx, 18 |
mov edx, str_packets_rx |
mcall |
add ebx, 18 |
mov edx, str_ip |
mcall |
add ebx, 18 |
mov edx, str_dns |
mcall |
add ebx, 18 |
mov edx, str_subnet |
mcall |
add ebx, 18 |
mov edx, str_gateway |
mcall |
mov ebx, API_IPv4 + 8 |
mov bh, [device] |
mcall 76 |
push eax |
dec bl |
dec bl |
mcall 76 |
push eax |
dec bl |
dec bl |
mcall 76 |
push eax |
dec bl |
dec bl |
mcall 76 |
push eax |
mov edx, 135 shl 16 + 75 + 2*18 |
call draw_ip |
add edx, 18 |
call draw_ip |
add edx, 18 |
call draw_ip |
add edx, 18 |
call draw_ip |
jmp end_of_draw |
.no_ip: |
cmp [mode], 103 |
jne .no_arp |
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx |
add ebx, 18 |
mov edx, str_packets_rx |
mcall |
add ebx, 18 |
mov edx, str_arp |
mcall |
add ebx, 18 |
mov edx, str_conflicts |
mcall |
jmp end_of_draw |
.no_arp: |
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx |
add ebx, 18 |
mov edx, str_packets_rx |
mcall |
cmp [mode], 106 |
jne end_of_draw |
add ebx, 18 |
mov edx, str_missed |
mcall |
add ebx, 18 |
mov edx, str_dumped |
mcall |
end_of_draw: |
mcall 12, 2 |
draw_stats: |
cmp [mode], 101 |
jne not_101 |
mov ebx, API_ETH |
mov bh, [device] |
@@: |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
cmp bl, 3 |
jbe @r |
inc bl |
mcall 76 |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 5*18 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18*2 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_101: |
cmp [mode], 102 |
jne not_102 |
mov ebx, API_IPv4 |
mov bh, [device] |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 18 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_102: |
cmp [mode], 103 |
jne not_103 |
mov ebx, API_ARP |
mov bh, [device] |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov bl, 7 |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 3*18 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_103: |
cmp [mode], 104 |
jne not_104 |
mov ebx, API_ICMP |
mov bh, [device] |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 18 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_104: |
cmp [mode], 105 |
jne not_105 |
mov ebx, API_UDP |
mov bh, [device] |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 18 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_105: |
cmp [mode], 106 |
jne not_106 |
mov ebx, API_TCP |
mov bh, [device] |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
inc bl |
push ebx |
mcall 76 |
pop ebx |
push eax |
mov ebx, 0x000a0000 |
pop ecx |
mov edx, 135 shl 16 + 75 + 18*3 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mcall 47 |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
sub edx, 18 |
pop ecx |
mcall |
jmp mainloop |
not_106: |
mainloop: |
mcall 23, 50 ; wait for event with timeout (0,5 s) |
cmp eax, 1 |
je redraw |
cmp eax, 3 |
je button |
cmp eax, 11 |
je redraw |
jmp draw_stats |
button: ; button |
mcall 17 ; get id |
cmp ah, 1 |
je exit |
cmp ah, 0 |
je .interface |
mov [mode], ah |
jmp redraw |
.interface: |
shr eax, 16 |
mov [device], al |
jmp redraw |
exit: |
mcall -1 |
draw_mac: |
mov eax, 47 |
mov ebx, 0x00020100 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
mov cl, [esp+4] |
mcall |
mov cl, [esp+4+1] |
add edx, 15 shl 16 |
mcall |
mov cl, [esp+4+2] |
add edx, 15 shl 16 |
mcall |
mov cl, [esp+4+3] |
add edx, 15 shl 16 |
mcall |
mov cl, [esp+4+4] |
add edx, 15 shl 16 |
mcall |
mov cl, [esp+4+5] |
add edx, 15 shl 16 |
mcall |
sub edx, 5*15 shl 16 |
ret 6 |
draw_ip: |
mov eax, 47 |
mov ebx, 0x00030000 |
mov esi, 0x40000000 |
mov edi, 0x00bcbcbc |
xor ecx, ecx |
mov cl, [esp+4] |
mcall |
mov cl, [esp+4+1] |
add edx, 30 shl 16 |
mcall |
mov cl, [esp+4+2] |
add edx, 30 shl 16 |
mcall |
mov cl, [esp+4+3] |
add edx, 30 shl 16 |
mcall |
sub edx, 3*30 shl 16 |
ret 4 |
draw_interfaces: |
mov [.btnpos], 8 shl 16 + 20 |
mov [.txtpos], 490 shl 16 + 15 |
mcall 74, -1 ; get number of active network devices |
mov ecx, eax |
xor ebx, ebx ; get device type |
.loop: |
mcall 74 |
cmp eax, 1 ; ethernet? |
je .hit |
inc bh |
jb .loop ; tried all 256? |
ret |
.hit: |
push ecx ebx |
movzx edx, bh |
shl edx, 8 |
mov esi, 0x00aaaaff |
cmp bh, [device] |
cmove esi, 0x00aaffff |
mcall 8, 485 shl 16 + 100, [.btnpos] |
mov ebx, [esp] |
inc bl |
mov ecx, namebuf |
mov edx, namebuf |
mcall 74 ; get device name |
cmp eax, -1 |
jne @f |
mov edx, str_unknown |
@@: |
mcall 4, [.txtpos], 0x80000000 ; print the name |
pop ebx ecx |
inc bh |
add [.btnpos], 25 shl 16 |
add [.txtpos], 25 |
dec ecx |
jnz .loop |
ret |
.btnpos dd ? |
.txtpos dd ? |
; DATA AREA |
name db 'Netstat', 0 |
mode db 101 |
device db 0 |
modes db 'Ethernet IPv4 ARP ICMP UDP TCP', 0 |
str_packets_tx db 'Packets sent:', 0 |
str_packets_rx db 'Packets received:', 0 |
str_bytes_tx db 'Bytes sent:', 0 |
str_bytes_rx db 'Bytes received:', 0 |
str_MAC db 'MAC address:', 0 |
str_ip db 'IP address:', 0 |
str_dns db 'DNS address:', 0 |
str_subnet db 'Subnet mask:', 0 |
str_gateway db 'Standard gateway:', 0 |
str_arp db 'ARP entrys:', 0 |
str_conflicts db 'ARP conflicts:', 0 |
str_unknown db 'unknown', 0 |
str_missed db 'Packets missed:',0 |
str_dumped db 'Packets dumped:',0 |
str_link db 'Link state:',0 |
namebuf rb 64 |
I_PARAM rb 1024 |
I_END: |
/programs/network/netstat |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/network.inc |
---|
0,0 → 1,94 |
; Socket types |
SOCK_STREAM = 1 |
SOCK_DGRAM = 2 |
SOCK_RAW = 3 |
; Socket options |
SO_NONBLOCK = 1 shl 31 |
; IP protocols |
IPPROTO_IP = 0 |
IPPROTO_ICMP = 1 |
IPPROTO_TCP = 6 |
IPPROTO_UDP = 17 |
; Address families |
AF_UNSPEC = 0 |
AF_LOCAL = 1 |
AF_INET4 = 2 ; IPv4 |
AF_INET6 = 28 ; IPv6 (not supported yet) |
PF_UNSPEC = AF_UNSPEC |
PF_LOCAL = AF_LOCAL |
PF_INET4 = AF_INET4 |
PF_INET6 = AF_INET6 |
; Flags for addrinfo |
AI_PASSIVE = 1 |
AI_CANONNAME = 2 |
AI_NUMERICHOST = 4 |
AI_NUMERICSERV = 8 |
AI_ADDRCONFIG = 0x400 |
; internal definition |
AI_SUPPORTED = 0x40F |
; for system function 76 |
API_ETH = 0 shl 16 |
API_IPv4 = 1 shl 16 |
API_ICMP = 2 shl 16 |
API_UDP = 3 shl 16 |
API_TCP = 4 shl 16 |
API_ARP = 5 shl 16 |
API_PPPOE = 6 shl 16 |
struct sockaddr_in |
sin_family dw ? ; sa_family_t |
sin_port dw ? ; in_port_t |
sin_addr dd ? ; struct in_addr |
sin_zero rb 8 ; zero |
ends |
struct addrinfo |
ai_flags dd ? ; bitmask of AI_* |
ai_family dd ? ; PF_* |
ai_socktype dd ? ; SOCK_* |
ai_protocol dd ? ; 0 or IPPROTO_* |
ai_addrlen dd ? ; length of ai_addr |
ai_canonname dd ? ; char* |
ai_addr dd ? ; struct sockaddr* |
ai_next dd ? ; struct addrinfo* |
ends |
EAI_ADDRFAMILY = 1 |
EAI_AGAIN = 2 |
EAI_BADFLAGS = 3 |
EAI_FAIL = 4 |
EAI_FAMILY = 5 |
EAI_MEMORY = 6 |
EAI_NONAME = 8 |
EAI_SERVICE = 9 |
EAI_SOCKTYPE = 10 |
EAI_BADHINTS = 12 |
EAI_PROTOCOL = 13 |
EAI_OVERFLOW = 14 |
socket fix 75, 0 |
close fix 75, 1 |
bind fix 75, 2 |
listen fix 75, 3 |
connect fix 75, 4 |
accept fix 75, 5 |
send fix 75, 6 |
recv fix 75, 7 |
setsockopt fix 75, 8 |
getsockopt fix 75, 9 |
socketpair fix 75, 10 |
struct ARP_entry |
IP dd ? |
MAC dp ? |
status dw ? |
TTL dw ? |
ends |
/programs/network/nslookup/nslookup.asm |
---|
0,0 → 1,136 |
format binary as "" |
use32 |
; standard header |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd i_end ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd 0 ; parameters |
dd 0 ; path |
; useful includes |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../network.inc' |
; entry point |
start: |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; main loop |
main: |
; write prompt |
push str1 |
call [con_write_asciiz] |
; read string |
mov esi, s |
push 256 |
push esi |
call [con_gets] |
; check for exit |
test eax, eax |
jz done |
cmp byte [esi], 10 |
jz done |
; delete terminating '\n' |
push esi |
@@: |
lodsb |
test al, al |
jnz @b |
mov byte [esi-2], al |
pop esi |
; resolve name |
push esp ; reserve stack place |
push esp ; fourth parameter |
push 0 ; third parameter |
push 0 ; second parameter |
push esi ; first parameter |
call [getaddrinfo] |
pop esi |
; test for error |
test eax, eax |
jnz fail |
; write results |
push str2 |
call [con_write_asciiz] |
mov edi, esi |
addrloop: |
; before all subsequent addresses print comma |
cmp edi, esi |
jz @f |
push str3 |
call [con_write_asciiz] |
@@: |
; convert IP address to decimal notation |
mov eax, [edi+addrinfo.ai_addr] |
pushd [eax+sockaddr_in.sin_addr] |
call [inet_ntoa] |
; write result |
push eax |
call [con_write_asciiz] |
; advance to next item |
mov edi, [edi+addrinfo.ai_next] |
test edi, edi |
jnz addrloop |
; free allocated memory |
push esi |
call [freeaddrinfo] |
; write newline and continue main loop |
push str4 |
@@: |
call [con_write_asciiz] |
jmp main |
fail: |
push str5 |
jmp @b |
done: |
push 1 |
call [con_exit] |
exit: |
mcall -1 |
; data |
title db 'Names resolver',0 |
str1 db 'Host name to resolve: ',0 |
str2 db 'IP address(es): ',0 |
str3 db ', ',0 |
str4 db 10,0 |
str5 db 'Name resolution failed.',10,0 |
; import |
align 4 |
@IMPORT: |
library network, 'network.obj', console, 'console.obj' |
import network, \ |
getaddrinfo, 'getaddrinfo', \ |
freeaddrinfo, 'freeaddrinfo', \ |
inet_ntoa, 'inet_ntoa' |
import console, \ |
con_start, 'START', \ |
con_init, 'con_init', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_exit, 'con_exit', \ |
con_gets, 'con_gets' |
i_end: |
s rb 256 |
align 4 |
rb 4096 ; stack |
mem: |
/programs/network/nslookup |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/pppoe/pppoe.asm |
---|
0,0 → 1,362 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; pppoe.asm - PPPoE dialer for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
use32 |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd i_end ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd 0 ; parameters |
dd 0 ; path |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../network.inc' |
include '../struct.inc' |
; Ethernet protocol numbers |
ETHER_PPP_DISCOVERY = 0x6388 |
ETHER_PPP_SESSION = 0x6488 |
; PPP protocol numbers |
PPP_LCP = 0x21c0 ; Link Configure Protocol |
PPP_CBCP = 0x29c0 ; CallBack Control Protocol |
PPP_PAP = 0x23c0 ; Password Authenication Protocol packet |
PPP_CHAP = 0x23c2 ; Challenge Handshake Authentication Protocol |
PPP_IPCP = 0x2180 ; Internet Protocol Configure Protocol (maybe this should be in kernel?) |
PPP_CCP = 0xfd80 ; Compression Configure Protocol |
; PPP Active Discovery... |
PPPoE_PADI = 0x09 ; .. Initiation |
PPPoE_PADO = 0x07 ; .. Offer |
PPPoE_PADR = 0x19 ; .. Request |
PPPoE_PADS = 0x65 ; .. Session-confirmation |
PPPoE_PADT = 0xa7 ; .. Terminate |
TAG_EOL = 0x0000 |
TAG_SERVICE_NAME= 0x0101 |
TAG_AC_NAME = 0x0201 |
TAG_HOST_UNIQ = 0x0301 |
TAG_AC_COOKIE = 0x0401 |
LCP_config_request = 1 |
LCP_config_ack = 2 |
LCP_config_nak = 3 |
LCP_config_reject = 4 |
LCP_terminate_request = 5 |
LCP_terminate_ack = 6 |
LCP_code_reject = 7 |
LCP_protocol_reject = 8 |
LCP_echo_request = 9 |
LCP_echo_reply = 10 |
LCP_discard_request = 11 |
struct ETH_frame |
DestMac dp ? |
SrcMac dp ? |
Type dw ? |
ends |
struct PPPoE_frame ETH_frame |
VersionAndType db ? |
Code db ? |
SessionID dw ? |
Length dw ? ; Length of payload, does NOT include the length PPPoE header. |
Payload rb 0 |
ends |
struct PPP_frame PPPoE_frame |
Protocol dw ? |
ends |
struct LCP_frame PPP_frame |
LCP_Code db ? |
LCP_Identifier db ? |
LCP_Length dw ? |
LCP_Data rb 0 |
ends |
; entry point |
start: |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push 25 |
push 80 |
push 25 |
push 80 |
call [con_init] |
main: |
mcall 40, 1 shl 7 |
call [con_cls] |
; Welcome user |
push str1 |
call [con_write_asciiz] |
mcall socket, 777, 3, 666 |
mov [socketnum], eax |
mcall send, [socketnum], PADI, PADI.length, 0 |
mainloop: |
mcall 10 |
call [con_get_flags] |
test eax, 0x200 ; con window closed? |
jnz close_conn |
mcall recv, [socketnum], buffer, 4096 |
cmp eax, sizeof.PPPoE_frame |
jb mainloop |
cmp word [buffer + ETH_frame.Type], ETHER_PPP_SESSION |
je SESSION_input |
cmp word [buffer + ETH_frame.Type], ETHER_PPP_DISCOVERY |
jne mainloop |
cmp [buffer + PPPoE_frame.Code], PPPoE_PADO |
je pado |
cmp [buffer + PPPoE_frame.Code], PPPoE_PADS |
je pads |
cmp [buffer + PPPoE_frame.Code], PPPoE_PADT |
je padt |
jmp mainloop |
pado: |
push str2 |
call [con_write_asciiz] |
lea esi, [buffer + ETH_frame.SrcMac] ; source mac -> dest mac |
lea edi, [buffer + ETH_frame.DestMac] |
movsw |
movsd |
mov byte [buffer + PPPoE_frame.Code], PPPoE_PADR ; change packet type to PADR |
mov al, byte [buffer + PPPoE_frame.Length + 1] ; get packet size |
mov ah, byte [buffer + PPPoE_frame.Length + 0] |
movzx esi, ax |
add esi, sizeof.PPPoE_frame |
mcall send, [socketnum], buffer, , 0 ; now send it! |
jmp mainloop |
pads: |
push str3 |
call [con_write_asciiz] |
mov edx, dword [buffer + ETH_frame.SrcMac] ; source mac -> dest mac |
mov si, word [buffer + ETH_frame.SrcMac + 4] |
mov dword [PADT.mac], edx |
mov word [PADT.mac + 4], si |
mov cx, word [buffer + PPPoE_frame.SessionID] ; and Session ID |
mov [PADT.sid], cx |
mcall 76, API_PPPOE + 0 ; Start PPPoE session |
jmp mainloop |
padt: |
push str4 |
call [con_write_asciiz] |
mcall 76, API_PPPOE + 1 ; Stop PPPoE session |
exit: |
mcall close, [socketnum] |
mcall -1 |
close_conn: |
mcall send, [socketnum], PADT, PADT.length, 0 |
jmp exit |
SESSION_input: |
mov ax, word[buffer + PPP_frame.Protocol] |
cmp ax, PPP_LCP |
je LCP_input |
cmp ax, PPP_CBCP |
je CBCP_input |
cmp ax, PPP_PAP |
je PAP_input |
cmp ax, PPP_CHAP |
je CHAP_input |
cmp ax, PPP_IPCP |
je IPCP_input |
cmp ax, PPP_CCP |
je CCP_input |
jmp mainloop |
LCP_input: |
stdcall con_write_asciiz, str_lcp |
cmp [buffer + LCP_frame.LCP_Code], LCP_echo_request |
je .echo |
.dump: |
jmp mainloop |
.echo: |
mov [buffer + LCP_frame.LCP_Code], LCP_echo_reply |
lea esi, [buffer + ETH_frame.SrcMac] ; source mac -> dest mac |
lea edi, [buffer + ETH_frame.DestMac] |
movsw |
movsd |
mov esi, eax |
mcall send, [socketnum], buffer, , 0 ; now send it back! |
jmp mainloop |
CBCP_input: |
stdcall con_write_asciiz, str_cbcp |
jmp mainloop |
PAP_input: |
stdcall con_write_asciiz, str_pap |
jmp mainloop |
CHAP_input: |
stdcall con_write_asciiz, str_chap |
jmp mainloop |
IPCP_input: |
stdcall con_write_asciiz, str_ipcp |
jmp mainloop |
CCP_input: |
stdcall con_write_asciiz, str_ccp |
jmp mainloop |
; data |
title db 'PPPoE',0 |
str1 db 'Sending PADI',13,10,0 |
str2 db 'Got PADO',13,10,'Sending PADR',13,10,0 |
str3 db 'Got PADS',13,10,'starting PPPoE session',13,10,0 |
str4 db 'Got PADT - connection terminated by Access Concentrator',13,10,0 |
str_lcp db 'Got LCP packet',13,10,0 |
str_cbcp db 'got CBCP packet',13,10,0 |
str_pap db 'got PAP packet',13,10,0 |
str_chap db 'got CHAP packet',13,10,0 |
str_ipcp db 'got IPCP packet',13,10,0 |
str_ccp db 'got CCP packet',13,10,0 |
PADI: |
dp 0xffffffffffff ; dest mac: broadcast |
dp 0 ; source mac (overwritten by kernel) |
dw ETHER_PPP_DISCOVERY ; type |
db 0x11 ; Version and Type |
db PPPoE_PADI ; Code |
dw 0 ; session ID |
dw 20 shl 8 ; Payload Length |
dw TAG_SERVICE_NAME ; tag |
dw 0x0000 ; length |
dw TAG_HOST_UNIQ ; tag |
dw 0x0c00 ; length = 12 bytes |
dd 0xdead ; some random id |
dd 0xbeef |
dd 0x1337 |
.length = $ - PADI |
PADT: |
.mac dp 0 ; Dest mac, to be filled in |
dp 0 ; source mac (overwritten by kernel) |
dw ETHER_PPP_DISCOVERY ; Type |
db 0x11 ; Version and Type |
db PPPoE_PADT ; Code: terminate connection |
.sid dw 0 ; session id, to be filled in |
dw 0 ; PAyload length = 0 |
.length = $ - PADT |
; import |
align 4 |
@IMPORT: |
library console, 'console.obj' |
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',\ |
con_write_string, 'con_write_string',\ |
con_get_flags, 'con_get_flags' |
i_end: |
socketnum dd ? |
buffer rb 4096 |
rb 4096 ; stack |
mem: |
/programs/network/pppoe |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/proc32.inc |
---|
0,0 → 1,270 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label def \\{ match . type,def> \\\{ deflocal@proc .,label,<type \\\} \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc du [val] \\{ \common deflocal@proc .,du,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,du,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
match =label,def \{ ..tmp equ \} |
match tmp,..tmp \{ ..var def val \} |
match ,..tmp \{ label ..var val \} |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/network/socketdbg/socket.inc |
---|
0,0 → 1,164 |
struct LHEAD |
next dd ? ;next object in list |
prev dd ? ;prev object in list |
ends |
struct MUTEX |
lhead LHEAD |
count dd ? |
ends |
struct SOCKET |
NextPtr dd ? ; pointer to next socket in list |
PrevPtr dd ? ; pointer to previous socket in list |
Number dd ? ; socket number |
mutex MUTEX |
PID dd ? ; application process id |
Domain dd ? ; INET/UNIX/.. |
Type dd ? ; RAW/STREAM/DGRAP |
Protocol dd ? ; ICMP/IPv4/ARP/TCP/UDP |
errorcode dd ? |
device dd ? |
options dd ? |
state dd ? |
backlog dw ? ; how many incomming connections that can be queued |
snd_proc dd ? |
rcv_proc dd ? |
ends |
struct IP_SOCKET SOCKET |
LocalIP rd 4 ; network byte order |
RemoteIP rd 4 ; network byte order |
ends |
struct TCP_SOCKET IP_SOCKET |
LocalPort dw ? ; network byte order |
RemotePort dw ? ; network byte order |
t_state dd ? ; TCB state |
t_rxtshift db ? |
rb 3 ; align |
t_rxtcur dd ? |
t_dupacks dd ? |
t_maxseg dd ? |
t_force dd ? |
t_flags dd ? |
;--------------- |
; RFC783 page 21 |
; send sequence |
SND_UNA dd ? ; sequence number of unack'ed sent Packets |
SND_NXT dd ? ; next send sequence number to use |
SND_UP dd ? ; urgent pointer |
SND_WL1 dd ? ; window minus one |
SND_WL2 dd ? ; |
ISS dd ? ; initial send sequence number |
SND_WND dd ? ; send window |
; receive sequence |
RCV_WND dd ? ; receive window |
RCV_NXT dd ? ; next receive sequence number to use |
RCV_UP dd ? ; urgent pointer |
IRS dd ? ; initial receive sequence number |
;--------------------- |
; Additional variables |
; receive variables |
RCV_ADV dd ? |
; retransmit variables |
SND_MAX dd ? |
; congestion control |
SND_CWND dd ? |
SND_SSTHRESH dd ? |
;---------------------- |
; Transmit timing stuff |
t_idle dd ? |
t_rtt dd ? |
t_rtseq dd ? |
t_srtt dd ? |
t_rttvar dd ? |
t_rttmin dd ? |
max_sndwnd dd ? |
;----------------- |
; Out-of-band data |
t_oobflags dd ? |
t_iobc dd ? |
t_softerror dd ? |
;--------- |
; RFC 1323 ; the order of next 4 elements may not change |
SND_SCALE db ? |
RCV_SCALE db ? |
requested_s_scale db ? |
request_r_scale db ? |
ts_recent dd ? ; a copy of the most-recent valid timestamp from the other end |
ts_recent_age dd ? |
last_ack_sent dd ? |
;------- |
; Timers |
timer_retransmission dd ? ; rexmt |
timer_persist dd ? |
timer_keepalive dd ? ; keepalive/syn timeout |
timer_timed_wait dd ? ; also used as 2msl timer |
; extra |
ts_ecr dd ? ; timestamp echo reply |
ts_val dd ? |
temp_bits db ? |
ends |
struct UDP_SOCKET IP_SOCKET |
LocalPort dw ? ; network byte order |
RemotePort dw ? ; network byte order |
firstpacket db ? |
ends |
struct ICMP_SOCKET IP_SOCKET |
Identifier dw ? |
ends |
struct RING_BUFFER |
start_ptr dd ? ; Pointer to start of buffer |
end_ptr dd ? ; pointer to end of buffer |
read_ptr dd ? ; Read pointer |
write_ptr dd ? ; Write pointer |
size dd ? ; Number of bytes buffered |
ends |
struct STREAM_SOCKET TCP_SOCKET |
rcv RING_BUFFER |
snd RING_BUFFER |
ends |
/programs/network/socketdbg/socketdbg.asm |
---|
0,0 → 1,100 |
format binary as "" |
use32 |
; standard header |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd i_end ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd 0 ; parameters |
dd 0 ; path |
; useful includes |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../struct.inc' |
include 'socket.inc' |
; entry point |
start: |
mcall 40, 0 ; we dont want any events |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; main loop |
main: |
mcall 75, 255, 0, socket_list ; get current socket list |
call [con_cls] |
mov esi, socket_list |
.loop: |
lodsd |
test eax, eax |
jz .done |
mov ecx, eax |
mcall 75, 255, , socket_buf |
pushd [socket_buf + SOCKET.state] |
pushd [socket_buf + SOCKET.PID] |
pushd [socket_buf + SOCKET.Number] |
push str_sock |
call [con_printf] |
add esp, 4 |
jmp .loop |
.done: |
mcall 23, 50 |
jmp main |
push 0 |
call [con_exit] |
exit: |
mcall -1 |
; data |
title db 'Socket debugger', 0 |
str_sock db 'Socket=%d PID=%d state=%d', 10, 0 |
; import |
align 4 |
@IMPORT: |
library console, 'console.obj' |
import console, \ |
con_start, 'START', \ |
con_init, 'con_init', \ |
con_cls, 'con_cls', \ |
con_exit, 'con_exit', \ |
con_printf, 'con_printf' |
i_end: |
socket_list rd 4096 |
socket_buf rd 4096 |
align 4 |
rb 4096 ; stack |
mem: |
/programs/network/socketdbg |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/struct.inc |
---|
0,0 → 1,240 |
; Macroinstructions for defining data structures |
macro struct name |
{ virtual at 0 |
fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common define field@struct .,db,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dw [val] \{ \common define field@struct .,dw,<val> |
fields@struct equ fields@struct,field@struct \} |
struc du [val] \{ \common define field@struct .,du,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dd [val] \{ \common define field@struct .,dd,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dp [val] \{ \common define field@struct .,dp,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dq [val] \{ \common define field@struct .,dq,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dt [val] \{ \common define field@struct .,dt,<val> |
fields@struct equ fields@struct,field@struct \} |
struc rb count \{ define field@struct .,db,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rw count \{ define field@struct .,dw,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rd count \{ define field@struct .,dd,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rp count \{ define field@struct .,dp,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rq count \{ define field@struct .,dq,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rt count \{ define field@struct .,dt,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro db [val] \{ \common \local anonymous |
define field@struct anonymous,db,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dw [val] \{ \common \local anonymous |
define field@struct anonymous,dw,<val> |
fields@struct equ fields@struct,field@struct \} |
macro du [val] \{ \common \local anonymous |
define field@struct anonymous,du,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dd [val] \{ \common \local anonymous |
define field@struct anonymous,dd,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dp [val] \{ \common \local anonymous |
define field@struct anonymous,dp,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dq [val] \{ \common \local anonymous |
define field@struct anonymous,dq,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dt [val] \{ \common \local anonymous |
define field@struct anonymous,dt,<val> |
fields@struct equ fields@struct,field@struct \} |
macro rb count \{ \local anonymous |
define field@struct anonymous,db,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rw count \{ \local anonymous |
define field@struct anonymous,dw,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rd count \{ \local anonymous |
define field@struct anonymous,dd,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rp count \{ \local anonymous |
define field@struct anonymous,dp,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rq count \{ \local anonymous |
define field@struct anonymous,dq,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rt count \{ \local anonymous |
define field@struct anonymous,dt,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name tail,fields@struct, \\{ if $ |
display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if \\} |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
define fields@\\#name fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
virtual |
db `name |
load initial@struct byte from 0 |
if initial@struct = '.' |
display 'Error: name of structure should not begin with a dot.',0Dh,0Ah |
err |
end if |
end virtual |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
label name#.#type |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ \\local \\..base |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label \\..base |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common label . at \\..base \\\} |
\\} |
macro name value \\{ |
match any, fields@struct \\\{ \\\local anonymous |
fields@struct equ fields@struct,anonymous,name,<values> \\\} |
match , fields@struct \\\{ |
forward |
match , value \\\\{ type def \\\\} |
match any, value \\\\{ \\\\local ..field |
..field = $ |
type value |
if ~ field eq . |
rb sizeof.#name#field - ($-..field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,parent,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
virtual at parent#.#name |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
if sizeof.#parent#field > $ - parent#.#name |
rb sizeof.#parent#field - ($ - parent#.#name) |
end if |
else |
virtual at parent#.#name |
label parent#.#type |
type def |
end virtual |
label name#.#type at parent#.#name |
if sizeof.#type > $ - parent#.#name |
rb sizeof.#type - ($ - parent#.#name) |
end if |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} |
macro name [value] \{ \common \local ..anonymous |
..anonymous name value \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
label parent#.#type |
rb sizeof.#type |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} |
macro name value \{ \local ..anonymous |
..anonymous name \} } |
/programs/network/synergyc/synergyc.asm |
---|
0,0 → 1,384 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; |
;; 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 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
use32 |
org 0x0 |
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 |
__DEBUG__ equ 1 ; enable/disable |
__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors |
BUFFERSIZE equ 1024 |
DEFAULTPORT equ 24800 |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../network.inc' |
start: |
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 |
mcall 68, 11 |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
push 1 |
call [con_start] |
push title |
push 25 |
push 80 |
push 25 |
push 80 |
call [con_init] |
push path |
call [con_write_asciiz] |
push newline |
call [con_write_asciiz] |
push newline |
call [con_write_asciiz] |
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0 |
test eax, eax |
jnz error |
invoke ini.get_int, path, str_remote, str_port, DEFAULTPORT |
xchg al, ah |
mov [sockaddr1.port], ax |
push str1 |
call [con_write_asciiz] |
push buffer_ptr |
call [con_write_asciiz] |
push newline |
call [con_write_asciiz] |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
je error |
mov [socketnum], eax |
push buffer_ptr ; hostname |
call [inet_addr] |
cmp eax, -1 |
je error |
mov [sockaddr1.ip], eax |
mcall connect, [socketnum], sockaddr1, 18 |
push str7 |
call [con_write_asciiz] |
mcall 40, 1 shl 7; + 7 |
login: |
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 |
mainloop: |
call wait_for_data |
mov edi, buffer_ptr |
.command: |
push eax edi |
cmp dword [edi + 4], 'QINF' ; query screen info |
je .qinf |
cmp dword [edi + 4], 'CALV' ; alive ? |
je .calv |
cmp dword [edi + 4], 'CINN' ; mouse moved into screen |
je .cinn |
cmp dword [edi + 4], 'DCLP' ; Clipboard event |
je .dclp |
cmp dword [edi + 4], 'DMMV' ; Mouse moved |
je .dmmv |
cmp dword [edi + 4], 'COUT' ; leave screen |
je .cout |
cmp dword [edi + 4], 'DMDN' ; mouse button down |
je .dmdn |
cmp dword [edi + 4], 'DMUP' ; mouse button released |
je .dmup |
cmp dword [edi + 4], 'CNOP' ; no operation |
je .next |
cmp dword [edi + 4], 'CIAK' ; resolution changed? |
je .ciak |
push str3 |
call [con_write_asciiz] |
mov byte[edi+8],0 |
add edi, 4 |
push edi |
call [con_write_asciiz] |
push newline |
call [con_write_asciiz] |
.next: |
pop edi eax |
mov ecx, dword [edi] |
bswap ecx |
add ecx, 4 |
sub eax, ecx |
jle mainloop |
add edi, ecx |
jmp .command |
.qinf: |
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 |
.calv: |
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event |
jmp .next |
.cinn: |
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 |
.dclp: |
jmp .next |
.dmmv: |
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 |
.cout: |
jmp .next |
.dmdn: |
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 |
.dmup: |
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 |
.ciak: |
jmp .next |
error: |
push str_err |
call [con_write_asciiz] |
call [con_gets] |
push 1 |
call [con_exit] |
mcall close, [socketnum] |
exit: |
mcall -1 |
wait_for_data: |
mcall 10 ; wait for data |
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0 |
cmp eax, -1 |
je wait_for_data |
cmp eax, 8 |
jl wait_for_data |
ret |
; data |
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 |
screeninfo: |
dd (screeninfo.length - 4) shl 24 |
db 'DINF' |
dw 0 ; coordinate of leftmost pixel |
dw 0 ; coordiante of topmost pixel |
.size: |
dw 0 ; width |
dw 0 ; height |
dw 0 ; size of warp zone |
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 |
.length = $ - screeninfo |
calv: |
dd (4) shl 24 |
db 'CALV' |
.length = $ - calv + 8 ; also send cnop |
cnop: |
dd (4) shl 24 |
db 'CNOP' |
.length = $ - cnop |
mousestate dd 0 |
sockaddr1: |
dw AF_INET4 |
.port dw 0 |
.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 |
; import |
align 16 |
@IMPORT: |
library console, 'console.obj',\ |
network, 'network.obj',\ |
libini, 'libini.obj' |
import network,\ |
inet_addr, 'inet_addr' |
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' |
import libini,\ |
ini.get_str, 'ini_get_str',\ |
ini.get_int, 'ini_get_int' |
align 4 |
i_end: |
socketnum dd ? |
buffer_ptr rb BUFFERSIZE |
path rb 4096 ; stack |
mem: |
/programs/network/synergyc/synergyc.ini |
---|
0,0 → 1,6 |
[local] |
name = karaboeia |
[remote] |
ip = 192.168.1.115 |
port = 24800 |
/programs/network/synergyc |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/tcpserv/tcpserv.asm |
---|
0,0 → 1,168 |
format binary as "" |
use32 |
; standard header |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd i_end ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd 0 ; parameters |
dd 0 ; path |
BUFFERSIZE equ 1500 |
; useful includes |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../network.inc' |
; entry point |
start: |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push 25 |
push 80 |
push 25 |
push 80 |
call [con_init] |
mcall 40, 1 shl 7 ; we only want network events |
push str1 |
call [con_write_asciiz] |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
je sock_err |
mov [socketnum], eax |
;; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
;; cmp eax, -1 |
;; je opt_err |
mcall bind, [socketnum], sockaddr1, sockaddr1.length |
cmp eax, -1 |
je bind_err |
mcall listen, [socketnum], 10 ; Backlog = 10 |
cmp eax, -1 |
je listen_err |
push str2 |
call [con_write_asciiz] |
mcall 10 |
mcall accept, [socketnum], sockaddr1, sockaddr1.length |
cmp eax, -1 |
je acpt_err |
mov [socketnum2], eax |
;; mcall close, [socketnum] |
mcall send, [socketnum2], hello, hello.length |
.loop: |
mcall 10 |
mcall recv, [socketnum2], buffer, buffer.length |
cmp eax, -1 |
je .loop |
mov byte [buffer + eax], 0 |
push buffer |
call [con_write_asciiz] |
jmp .loop |
acpt_err: |
push str8 |
call [con_write_asciiz] |
jmp done |
listen_err: |
push str3 |
call [con_write_asciiz] |
jmp done |
bind_err: |
push str4 |
call [con_write_asciiz] |
jmp done |
sock_err: |
push str6 |
call [con_write_asciiz] |
jmp done |
done: |
call [con_getch2] |
push 1 |
call [con_exit] |
exit: |
mcall -1 |
; data |
title db 'TCP stream server - test',0 |
str1 db 'Opening socket',10, 0 |
str2 db 'Listening for incoming connections...',10,0 |
str3 db 'Listen error',10,10,0 |
str4 db 'Bind error',10,10,0 |
str5 db 'Setsockopt error.',10,10,0 |
str6 db 'Could not open socket',10,10,0 |
str7 db 'Got data!',10,10,0 |
str8 db 'Error accepting connection',10,10,0 |
hello db 'Hello world!',0 |
.length = $ - hello |
sockaddr1: |
dw AF_INET4 |
.port dw 0x1700 ; 23 |
.ip dd 0 |
rb 10 |
.length = $ - sockaddr1 |
; import |
align 4 |
@IMPORT: |
library console, 'console.obj' |
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_printf, 'con_printf',\ |
con_getch2, 'con_getch2',\ |
con_set_cursor_pos, 'con_set_cursor_pos' |
i_end: |
socketnum dd ? |
socketnum2 dd ? |
buffer rb BUFFERSIZE |
.length = BUFFERSIZE |
align 4 |
rb 4096 ; stack |
mem: |
/programs/network/tcpserv |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/telnet/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/telnet/trunk/telnet.asm |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/telnet/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/telnet/telnet.asm |
---|
0,0 → 1,305 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; telnet.asm - Telnet client for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
__DEBUG__ equ 0 |
__DEBUG_LEVEL__ equ 1 |
BUFFERSIZE equ 4096 |
use32 |
; standard header |
db 'MENUET01' ; signature |
dd 1 ; header version |
dd start ; entry point |
dd i_end ; initialized size |
dd mem ; required memory |
dd mem ; stack pointer |
dd s ; parameters |
dd 0 ; path |
include '../macros.inc' |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../debug-fdo.inc' |
include '../network.inc' |
; entry point |
start: |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; initialize console |
push 1 |
call [con_start] |
push title |
push 25 |
push 80 |
push 25 |
push 80 |
call [con_init] |
; Check for parameters |
cmp byte [s], 0 |
jne resolve |
main: |
call [con_cls] |
; Welcome user |
push str1 |
call [con_write_asciiz] |
; write prompt |
push str2 |
call [con_write_asciiz] |
; read string |
mov esi, s |
push 256 |
push esi |
call [con_gets] |
; check for exit |
test eax, eax |
jz done |
cmp byte [esi], 10 |
jz done |
resolve: |
; delete terminating '\n' |
mov esi, s |
@@: |
lodsb |
cmp al, 0x20 |
ja @r |
mov byte [esi-1], 0 |
call [con_cls] |
push str3 |
call [con_write_asciiz] |
push s |
call [con_write_asciiz] |
; resolve name |
push esp ; reserve stack place |
push esp ; fourth parameter |
push 0 ; third parameter |
push 0 ; second parameter |
push s ; first parameter |
call [getaddrinfo] |
pop esi |
; test for error |
test eax, eax |
jnz fail |
; write results |
push str8 |
call [con_write_asciiz] |
; mov edi, esi |
; convert IP address to decimal notation |
mov eax, [esi+addrinfo.ai_addr] |
mov eax, [eax+sockaddr_in.sin_addr] |
mov [sockaddr1.ip], eax |
push eax |
call [inet_ntoa] |
; write result |
push eax |
call [con_write_asciiz] |
; free allocated memory |
push esi |
call [freeaddrinfo] |
push str9 |
call [con_write_asciiz] |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
cmp eax, -1 |
jz fail2 |
mov [socketnum], eax |
mcall connect, [socketnum], sockaddr1, 18 |
mcall 40, 1 shl 7 ; + 7 |
call [con_cls] |
mcall 18, 7 |
push eax |
mcall 51, 1, thread, mem - 2048 |
pop ecx |
mcall 18, 3 |
mainloop: |
DEBUGF 1, 'TELNET: Waiting for events\n' |
mcall 10 |
DEBUGF 1, 'TELNET: EVENT %x !\n', eax |
call [con_get_flags] |
test eax, 0x200 ; con window closed? |
jnz exit |
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0 |
cmp eax, -1 |
je mainloop |
DEBUGF 1, 'TELNET: got %u bytes of data !\n', eax |
mov esi, buffer_ptr |
lea edi, [esi + eax] |
mov byte [edi], 0 |
.scan_cmd: |
cmp byte [esi], 0xff ; Interpret As Command |
jne .no_cmd |
; TODO: parse options, for now, we will reply with 'WONT' to everything |
mov byte [esi + 1], 252 ; WONT |
add esi, 3 ; a command is always 3 bytes |
jmp .scan_cmd |
.no_cmd: |
cmp esi, buffer_ptr |
je .print_loop |
DEBUGF 1, 'TELNET: sending data\n' |
push esi edi |
sub esi, buffer_ptr |
mcall send, [socketnum], buffer_ptr, , 0 |
pop edi esi |
.print_loop: |
DEBUGF 1, 'TELNET: printloop\n' |
cmp esi, edi |
jae mainloop |
cmp byte [esi], 0x1b ; escape character |
jne .print_byte |
inc esi |
cmp word [esi], 0x485b ; move cursor to beginning |
jne @f |
inc esi |
inc esi |
DEBUGF 1, 'TELNET: resetting cursor \n' |
push 0 |
push 0 |
call [con_set_cursor_pos] |
jmp .print_loop |
@@: |
inc esi |
inc esi |
jmp .print_loop |
.print_byte: |
push dword 1 |
push esi ; next string to print |
inc esi |
call [con_write_string] |
jmp .print_loop |
fail2: |
push str6 |
call [con_write_asciiz] |
jmp fail.wait |
fail: |
push str5 |
call [con_write_asciiz] |
.wait: |
push str10 |
call [con_write_asciiz] |
call [con_getch2] |
jmp main |
done: |
push 1 |
call [con_exit] |
exit: |
mcall close, [socketnum] |
mcall -1 |
thread: |
mcall 40, 0 |
.loop: |
call [con_getch2] |
mov byte [send_data], al |
mcall send, [socketnum], send_data, 1 |
call [con_get_flags] |
test eax, 0x200 ; con window closed? |
jz .loop |
mcall -1 |
; data |
title db 'Telnet',0 |
str1 db 'Telnet for KolibriOS v0.11',10,10,'Please enter URL of telnet server (for example: towel.blinkenlights.nl)',10,10,0 |
str2 db '> ',0 |
str3 db 'Connecting to: ',0 |
str4 db 10,0 |
str5 db 10,'Name resolution failed.',10,0 |
str6 db 10,'Could not open socket.',10,0 |
str8 db ' (',0 |
str9 db ')',10,0 |
str10 db 'Push any key to continue.',0 |
sockaddr1: |
dw AF_INET4 |
.port dw 0x1700 ; 23 |
.ip dd 0 |
rb 10 |
include_debug_strings ; ALWAYS present in data section |
; import |
align 4 |
@IMPORT: |
library network, 'network.obj', console, 'console.obj' |
import network, \ |
getaddrinfo, 'getaddrinfo', \ |
freeaddrinfo, 'freeaddrinfo', \ |
inet_ntoa, 'inet_ntoa' |
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',\ |
con_write_string, 'con_write_string',\ |
con_get_flags, 'con_get_flags' |
i_end: |
socketnum dd ? |
buffer_ptr rb BUFFERSIZE+1 |
send_data rb 100 |
s rb 1024 |
rb 4096 ; stack |
mem: |
/programs/network/tftpc/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/tftpc/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/tftpc/trunk/tftpc.asm |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/programs/network/tftpc/tftpc.asm |
---|
0,0 → 1,566 |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x1 |
dd START |
dd I_END |
dd IM_END |
dd IM_END |
dd 0, 0 |
include '../proc32.inc' |
include '../macros.inc' |
include '../libio.inc' |
include '../dll.inc' |
include '../../../../../programs/develop/libraries/box_lib/trunk/box_lib.mac' |
include '../network.inc' |
filebuffer_size equ 4*4096 ; 16kb (dont try to change it yet..) |
TIMEOUT equ 100 |
buffer_len equ 1500 |
AF_INET4 equ 2 |
IP_PROTO_UDP equ 17 |
opcode_rrq equ 1 |
opcode_wrq equ 2 |
opcode_data equ 3 |
opcode_ack equ 4 |
opcode_error equ 5 |
; read/write request packet |
; |
; 2 bytes string 1 byte string 1 byte |
; ------------------------------------------------ |
; | Opcode | Filename | 0 | Mode | 0 | |
; ------------------------------------------------ |
; data packet |
; |
; 2 bytes 2 bytes n bytes |
; ---------------------------------- |
; | Opcode | Block # | Data | |
; ---------------------------------- |
; acknowledgement packet |
; |
; 2 bytes 2 bytes |
; --------------------- |
; | Opcode | Block # | |
; --------------------- |
; error packet |
; |
; 2 bytes 2 bytes string 1 byte |
; ---------------------------------------- |
; | Opcode | ErrorCode | ErrMsg | 0 | |
; ---------------------------------------- |
START: |
mcall 68, 11 |
stdcall dll.Load, @IMPORT |
or eax, eax |
jnz exit |
stop_transfer: |
mcall 40, 00100111b |
red_win: |
call draw_window |
align 4 |
still: |
mcall 10 |
dec eax |
jz red_win |
dec eax |
jz key |
dec eax |
jz button |
push dword edit1 |
call [edit_box_mouse] |
push dword edit2 |
call [edit_box_mouse] |
push dword edit3 |
call [edit_box_mouse] |
push dword edit4 |
call [edit_box_mouse] |
push dword Option_boxs1 |
call [option_box_mouse] |
push dword Option_boxs2 |
call [option_box_mouse] |
jmp still |
button: |
mcall 17 |
cmp ah,0x10 |
je start_transfer |
test ah , ah |
jz still |
exit: mcall -1 |
key: |
mcall 2 |
push dword edit1 |
call [edit_box_key] |
push dword edit2 |
call [edit_box_key] |
push dword edit3 |
call [edit_box_key] |
push dword edit4 |
call [edit_box_key] |
jmp still |
align 4 |
draw_window: |
mcall 12,1 |
mcall 0, (50*65536+400), (30*65536+180), 0x34AABBCC, 0x085080DD, str_title |
mcall 4, 35*65536+10, 0x80000000, str_server |
mov ebx, 5*65536+30 |
mov edx, str_source |
mcall |
mov ebx, 11*65536+50 |
mov edx, str_destination |
mcall |
mov ebx, 47*65536+72 |
mov edx, str_mode |
mcall |
mov ebx, 160*65536+72 |
mov edx, str_method |
mcall |
mov ebx, 270*65536+72 |
mov edx, str_blocksize |
mcall |
push dword edit1 |
call [edit_box_draw] |
push dword edit2 |
call [edit_box_draw] |
push dword edit3 |
call [edit_box_draw] |
push dword edit4 |
call [edit_box_draw] |
push dword Option_boxs1 |
call [option_box_draw] |
push dword Option_boxs2 |
call [option_box_draw] |
mcall 8,210*65536+170, 105*65536+16,0x00000010,0x085080DD |
mcall 4,260*65536+110, 0x80000000, str_transfer |
mcall 38,10*65536+380, 130*65536+130,0x00000000 |
mcall 4,350*65536+137, 0x80000000, str_kb_s |
mcall 47,1 shl 31 + 7 shl 16 + 1,kbps,305*65536+137,0x00000000 |
mcall 4,50*65536+137, 0x80000000, str_complete |
mcall 47,1 shl 31 + 3 shl 16 + 1,done,25*65536+137,0x00000000 |
mcall 12,2 |
ret |
start_transfer: |
; first, resolve the hostname |
push esp ; reserve stack place |
push esp ; fourth parameter |
push 0 ; third parameter |
push 0 ; second parameter |
push dword SRV ; first parameter |
call [getaddrinfo] |
pop esi |
; test for error |
test eax, eax |
jnz still |
mov esi, [esi] |
mov esi, [esi + sockaddr_in.sin_addr] |
mov dword [IP], esi |
mcall socket, AF_INET4, SOCK_DGRAM, 0 ; socket_open |
cmp eax, -1 |
je still |
mov [socketnum], eax |
mcall connect, [socketnum], sockaddr, sockaddr_len ; socket_connect |
cmp eax, -1 |
je still |
mov word [I_END], opcode_rrq |
cmp [option_group2],op3 |
je @f |
mov word [I_END], opcode_wrq |
@@: |
xor al , al |
mov edi, remote_addr |
mov ecx, 250 |
repnz scasb |
sub edi, remote_addr-1 |
mov ecx, edi |
mov edi, I_END+2 |
mov esi, remote_addr |
rep movsb |
cmp [option_group1], op1 |
je .ascii |
mov esi, octet |
movsd |
movsb |
jmp .send_request |
.ascii: |
mov esi, netascii |
movsd |
movsd |
.send_request: |
xor al, al |
stosb |
sub edi, I_END |
mov esi, edi |
mcall send, [socketnum], I_END |
mcall 40, 10000101b |
mov [last_ack], 0 |
receive_data_loop: |
mcall 23, TIMEOUT |
dec eax |
jz .red |
dec eax |
jz .key |
mcall recv, [socketnum], buffer, buffer_len, 0 ; receive data |
cmp word[buffer], opcode_data |
jne .error |
mov bx, [last_ack] |
cmp word [buffer + 2], bx |
jne .packet_got_lost |
inc [last_ack] |
cmp eax, 4+512 |
je .continue |
; last packet, or something else |
.error: |
.packet_got_lost: |
.continue: |
mov word[buffer], opcode_ack ; send ack |
mcall send, [socketnum], buffer, 4, 0 |
jmp receive_data_loop |
.red: |
call draw_window |
jmp receive_data_loop |
.key: |
mcall 2 |
cmp ah, 2 |
jz exit |
; close socket ? |
jmp receive_data_loop |
;-------------------------------- |
send_: |
invoke file_open, local_addr, O_READ |
or eax, eax |
jz .exit |
mov [fh], eax |
stdcall mem.Alloc, filebuffer_size |
or eax, eax |
jz .exit |
mov [fb], eax |
mov [last_ack], 0 |
mov [fo], 0 |
.read_chunk: |
invoke file_seek, [fh], [fo], SEEK_END |
cmp eax, -1 |
je .exit |
invoke file_read, [fh], [fb], filebuffer_size |
cmp eax, -1 |
je .exit |
add [fo], filebuffer_size |
cmp eax, filebuffer_size |
je .packet |
; ijhidfhfdsndsfqk |
.packet: |
movzx esi, [last_ack] |
and esi, 0x000000001f ; last five bits BUFFER SIZE MUST BE 16 kb for this to work !!! |
shl esi, 9 ; = * 512 |
add esi, [fb] |
mov edi, buffer |
mov ax, opcode_data |
stosw |
mov ax, [last_ack] |
stosw |
mov ecx, 512/4 |
rep movsd |
mcall send, [socketnum], buffer, 4+512, 0 ; send data |
.loop: |
mcall 23, TIMEOUT |
dec eax |
jz .red |
dec eax |
jz .key |
mcall recv, [socketnum], buffer, buffer_len, 0 ; receive ack |
cmp word[buffer], opcode_ack |
jne .exit |
mov ax, [last_ack] |
cmp word[buffer+2], ax |
jne .packet |
inc [last_ack] |
test [last_ack],0x001f |
jz .read_chunk |
jmp .packet |
.red: |
call draw_window |
jmp .loop |
.key: |
mcall 2 |
cmp ah, 2 |
jz exit |
; close socket ? |
jmp .loop |
.exit: |
invoke file_close, [fh] |
jmp still |
;------------------------- |
; DATA |
socketnum dd 0 |
kbps dd 0 |
done dd 0 |
sockaddr: |
dw AF_INET4 |
dw 0x4500 ; 69 |
IP db 192,168,1,115 |
sockaddr_len = $ - sockaddr |
align 16 |
@IMPORT: |
library box_lib , 'box_lib.obj', \ |
io_lib , 'libio.obj', \ |
network , 'network.obj' |
import box_lib ,\ |
edit_box_draw ,'edit_box' ,\ |
edit_box_key ,'edit_box_key' ,\ |
edit_box_mouse ,'edit_box_mouse' ,\ |
version_ed ,'version_ed' ,\ |
init_checkbox ,'init_checkbox2' ,\ |
check_box_draw ,'check_box_draw2' ,\ |
check_box_mouse ,'check_box_mouse2' ,\ |
version_ch ,'version_ch2' ,\ |
option_box_draw ,'option_box_draw' ,\ |
option_box_mouse ,'option_box_mouse' ,\ |
version_op ,'version_op' |
import io_lib ,\ |
file_find_first , 'file_find_first' ,\ |
file_find_next , 'file_find_next' ,\ |
file_find_close , 'file_find_close' ,\ |
file_size , 'file_size' ,\ |
file_open , 'file_open' ,\ |
file_read , 'file_read' ,\ |
file_write , 'file_write' ,\ |
file_seek , 'file_seek' ,\ |
file_tell , 'file_tell' ,\ |
file_eof? , 'file_iseof' ,\ |
file_seteof , 'file_seteof' ,\ |
file_truncate , 'file_truncate' ,\ |
file_close , 'file_close' |
import network ,\ |
inet_ntoa , 'inet_ntoa' ,\ |
getaddrinfo , 'getaddrinfo' ,\ |
freeaddrinfo , 'freeaddrinfo' |
edit1 edit_box 300,80,5 ,0xffffff,0x6f9480,0,0,0,99 ,SRV,mouse_dd,ed_focus, 11,11 |
edit2 edit_box 300,80,25,0xffffff,0x6a9480,0,0,0,99 ,remote_addr,mouse_dd,ed_figure_only, 5,5 |
edit3 edit_box 300,80,45,0xffffff,0x6a9480,0,0,0,99 ,local_addr,mouse_dd,ed_figure_only, 27,27 |
edit4 edit_box 40,340,68,0xffffff,0x6a9480,0,0,0,5 ,BLK,mouse_dd,ed_figure_only, 3,3 |
op1 option_box option_group1,80,68,6,12,0xffffff,0,0,netascii,octet-netascii |
op2 option_box option_group1,80,85,6,12,0xFFFFFF,0,0,octet,get-octet |
op3 option_box option_group2,210,68,6,12,0xffffff,0,0,get,put-get |
op4 option_box option_group2,210,85,6,12,0xFFFFFF,0,0,put,BLK-put |
option_group1 dd op1 |
option_group2 dd op3 |
Option_boxs1 dd op1,op2,0 |
Option_boxs2 dd op3,op4,0 |
str_title db 'TFTP client for KolibriOS',0 |
str_server db 'Server:',0 |
str_source db 'Remote file:',0 |
str_destination db 'Local file:',0 |
str_mode db 'Mode:',0 |
str_method db 'Method:',0 |
str_blocksize db 'Blocksize:',0 |
str_kb_s db 'kb/s',0 |
str_complete db '% complete',0 |
str_transfer db 'Transfer',0 |
str_error: |
._0 db 'Not defined, see error message (if any).',0 |
._1 db 'File not found.',0 |
._2 db 'Access violation.',0 |
._3 db 'Disk full or allocation exceeded.',0 |
._4 db 'Illegal TFTP operation.',0 |
._5 db 'Unknown transfer ID.',0 |
._6 db 'File already exists.',0 |
._7 db 'No such user.',0 |
netascii db 'NetASCII' |
octet db 'Octet' |
get db 'GET' |
put db 'PUT' |
BLK db "512",0,0,0 |
last_ack dw ? |
fh dd ? ; file handle |
fo dd ? ; file offset |
fb dd ? ; file buffer |
SRV db "192.168.1.115",0 |
rb (SRV + 256 - $) |
remote_addr db "IMG00",0 |
rb (remote_addr + 256 - $) |
local_addr db "/hd0/1/KolibriOS/kernel.mnt",0 |
rb (local_addr + 256 - $) |
I_END: |
mouse_dd dd ? |
buffer: |
rb buffer_len |
rb 0x1000 ; stack |
IM_END: |
/programs/network/vncc/logon.inc |
---|
0,0 → 1,257 |
red_logon: |
call draw_window_logon ; at first, draw the window |
still_logon: ; main cycle of application begins here |
mov eax,10 ; wait here for event |
mcall |
checkevent_logon: ; Check what event was called _logon: this will be used to return from textbox focus |
dec eax ; redraw request ? |
jz red_logon |
dec eax ; key in buffer ? |
jz key_logon |
dec eax ; button in buffer ? |
jz button_logon |
jmp still_logon |
key_logon: ; key event handler |
mov al,2 ; eax was zero so will now be 2 |
mcall ; just read it and ignore |
cmp ah,13 |
jne still_logon ; return to main loop |
ret ; enter key was pressed => return to logon |
button_logon: ; eax was zero so will now be 17 |
mov al,17 ; get id |
mcall |
cmp ah,1 ; close ? |
jz close_logon |
cmp ah,2 ; logon ? |
je connect_logon |
cmp ah,5 ; first ? |
jz dstbtn_logon |
srcbtn_logon: |
mov dword[addr],first |
jmp rk_logon |
dstbtn_logon: |
mov dword[addr],second |
rk_logon: |
mov edi,[addr] ; load the address of the string |
xor al,al ; mov al,0 ; the symbol we will search for |
mov ecx,STRLEN+1 ; length of the string (+1) |
cld ; search forward |
repne scasb ; do search now |
inc ecx ; we've found a zero or ecx became 0 |
mov eax,STRLEN+1 |
sub eax,ecx ; eax = address of <0> character |
mov [temp],eax ; position |
cmp dword[addr],dword second |
jne @f |
mov dword [passlen],eax |
@@: |
call print_text_logon |
mov edi,[addr] ; address of string |
add edi,[temp] ; cursor position |
.waitev_logon: |
mov eax,10 ; wait for event |
mcall |
cmp eax,2 ; button presed ? |
jne checkevent_logon ; a key is pressed or redraw is nessesary, goto checkevent |
mcall ; eax = 2, read button |
shr eax,8 |
cmp eax,8 |
jnz .nobs_logon ; BACKSPACE |
cmp edi,[addr] |
jz .waitev_logon |
dec edi |
mov byte[edi],0 |
cmp dword[addr],second |
jne @f |
dec [passlen] |
@@: |
call print_text_logon |
jmp .waitev_logon |
.nobs_logon: |
cmp eax,13 ; ENTER |
je still_logon |
cmp eax,192 |
jne .noclear_logon |
xor al,al |
mov edi,[addr] |
mov ecx,STRLEN |
rep stosb |
mov edi,[addr] |
call print_text_logon |
jmp .waitev_logon |
.noclear_logon: |
mov [edi],al |
cmp dword[addr],second |
jne @f |
inc [passlen] |
@@: |
call print_text_logon |
inc edi |
mov esi,[addr] |
add esi,STRLEN |
cmp esi,edi |
jnz .waitev_logon |
jmp still_logon |
; print strings (source & destination) |
print_text_logon: |
pusha |
mov eax, 8 |
mov ebx, 105*65536+200 |
mov ecx, 31*65536+13 |
mov edx, 4 |
mov esi, 0xEBEBEB |
mcall |
cmp byte[mode],0 |
je @f |
mov ecx, 49*65536+12 |
inc edx |
mcall |
@@: |
mov eax, 4 ; function 4 _logon: write text to window |
mov ebx, 107*65536+34 ; [x start] *65536 + [y start] |
xor ecx, ecx ; color of text RRGGBB |
mov edx, first ; pointer to text beginning |
mov esi, STRLEN ; text length |
mcall |
cmp byte[mode],0 |
je dont_draw_pass |
add ebx,16 |
mov edi,[passlen] |
@@: |
cmp edi,0 |
jle dont_draw_pass |
dec edi |
mov edx, passchar |
mov esi, 1 |
mcall |
add ebx,6*65536 |
jmp @r |
dont_draw_pass: |
popa |
ret |
close_logon: |
or eax,-1 |
mcall |
connect_logon: |
ret |
draw_window_logon: |
mcall 12, 1 ; start window draw |
pusha |
; DRAW WINDOW |
xor eax, eax ; function 0 _logon: define and draw window |
mov ebx, 160*65536+330 ; [x start] *65536 + [x size] |
mov ecx, 160*65536+100 ; [y start] *65536 + [y size] |
mov edx, 0x13DDDDDD ; color of work area RRGGBB |
mov edi, title ; WINDOW LABEL |
mcall |
mov eax, 8 ; LOGON BUTTON |
mov ebx, 220*65536+85 |
mov ecx, 63*65536+16 |
mov edx, 2 |
mov esi, 0xCCCCCC |
mcall |
call print_text_logon |
cmp byte[mode], 0 |
je servermode_ |
mov eax, 4 ; function 4 write text to window |
mov ebx, 25*65536+33 ; [x start] *65536 + [y start] |
xor ecx, ecx |
mov edx, userstr ; pointer to text beginning |
mov esi, passstr-userstr ; text length |
mcall |
add bl,19 |
mov edx, passstr ; pointer to text beginning |
mov esi, connectstr-passstr ; text length |
mcall |
jmp drawtherest_ |
servermode_: |
mov eax, 4 ; function 4 write text to window |
mov ebx, 25*65536+33 ; [x start] *65536 + [y start] |
xor ecx, ecx |
mov edx, serverstr ; pointer to text beginning |
mov esi, userstr-serverstr ; text length |
mcall |
drawtherest_: |
mov ebx, 240*65536+67 ; [x start] *65536 + [y start] |
mov edx, connectstr ; pointer to text beginning |
mov esi, connect_e-connectstr ; text length |
mcall |
popa |
inc ebx |
mcall |
ret |
; DATA AREA |
title db 'Kolibrios VNC client by HIDNPLAYR',0 |
first: db '192.168.1.5' |
rb STRLEN |
second: rb STRLEN |
passchar db '*' |
passlen dd 0 |
addr dd 0 |
temp dd 0 |
mode db 0 ; 0 = connection details, 1 = authentication |
serverstr: db 'server:' |
userstr: db 'username:' |
passstr: db 'password:' |
connectstr: db 'connect !' |
connect_e: |
I_END_logon: |
/programs/network/vncc/raw.inc |
---|
0,0 → 1,153 |
encoding_raw: |
DEBUGF 1,'RAW\n' |
mov ax,[frame.y] ; |
mov bx,[screen.width] ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; [screen.width]*[frame.y] |
movzx eax,[frame.x] |
add edx,eax ; [screen.width]*[frame.y]+[frame.x] |
mov eax,3 ; |
mul edx ; ([screen.width]*[frame.y]+[frame.x])*3 |
add eax,framebuffer_data ; |
push eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3 |
mov ax,[frame.width] ; |
mov bx,3 ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; [frame.width]*3 |
pop eax ; |
add edx,eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3+[frame.width]*3 |
push eax ; |
push edx ; |
mov ax,[frame.height] ; |
dec ax ; |
mov bx,3 ; |
mul bx ; |
mov bx,[screen.width] ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; |
mov ecx,edx ; |
pop edx ; |
add ecx,edx ; mov ecx,edx+([frame.height]-1)*[screen.width]*3 |
pop ebx |
.pixelloop32: |
cmp ebx,ecx |
jge next_rectangle |
; add esi,2 ; 32 bit code RAW - OK |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; dec esi ; |
; ; |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; dec esi ; |
; ; |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; add esi,4 ; |
; push ecx ; 16 bit code RAW |
; mov cl,51 |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; and al,00011111b ; |
; xchg al,ah |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; shr ax,5 ; |
; xchg al,ah |
; and al,00011111b ; |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; shr ax,10 ; |
; and al,00011111b ; |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; inc esi ; |
; inc esi ; |
; pop ecx |
push ecx ; 8 bit code RAW - OK |
mov cl,85 ; |
; |
mov al,[esi] ; |
shr al,4 ; |
and al,3 ; |
mul cl ; |
mov [ebx],al ; |
inc ebx ; |
; |
mov al,[esi] ; |
shr al,2 ; |
and al,3 ; |
mul cl ; |
mov [ebx],al ; |
inc ebx ; |
; |
mov al,[esi] ; |
and al,3 ; |
mul cl ; |
mov byte[ebx],al ; |
inc ebx ; |
inc esi ; |
pop ecx ; |
cmp ebx,edx |
jl .pixelloop32 |
push edx |
push ebx |
mov ax,[screen.width] |
mov bx,3 |
mul bx |
shl edx,16 |
mov dx,ax |
mov eax,edx |
pop ebx |
pop edx |
add ebx,eax ; eax = [screen.width]*3 |
add edx,eax |
push edx |
push ebx |
mov ax,[frame.width] |
mov bx,3 |
mul bx |
shl edx,16 |
mov dx,ax |
mov eax,edx |
pop ebx |
pop edx |
sub ebx,eax ; eax = [frame.width]*3 |
jmp .pixelloop32 |
/programs/network/vncc/structs.inc |
---|
0,0 → 1,22 |
struct pixel_format |
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 |
struct framebuffer |
width dw ? |
height dw ? |
pixelformat pixel_format |
name_length dd ? |
name rb 256 |
ends |
/programs/network/vncc/thread.inc |
---|
0,0 → 1,239 |
thread_start: |
DEBUGF 1, 'I am the thread!\n' |
mcall 40, 1 shl 7 |
; resolve name |
push esp ; reserve stack place |
invoke getaddrinfo, first, 0, 0, esp |
pop esi |
; test for error |
test eax, eax |
jnz exit |
mov eax, [esi+addrinfo.ai_addr] |
mov eax, [eax+sockaddr_in.sin_addr] |
mov [sockaddr1.ip], eax |
; DEBUGF 1, 'Connecting to %u.%u.%u.%u:%u\n', \ |
; [server_ip]:1, [server_ip+1]:1, \ |
; [server_ip+2]:1, [server_ip+3]:1, \ |
; [server_port]:2 |
mcall socket, AF_INET4, SOCK_STREAM, 0 |
mov [socketnum], eax |
mcall connect, [socketnum], sockaddr1, 18 |
call wait_for_data |
cmp dword [receive_buffer], 'RFB ' |
jne no_rfb |
DEBUGF 1, 'received: %s\n', receive_buffer |
mcall send, [socketnum], handshake, 12, 0 |
DEBUGF 1, 'Sending handshake: protocol version\n' |
call wait_for_data |
cmp dword [receive_buffer], 0x00000000 |
je invalid_security |
cmp dword [receive_buffer], 0x01000000 |
je no_security |
cmp dword [receive_buffer], 0x02000000 |
je vnc_security |
jmp exit |
vnc_security: |
mov byte[mode], 1 |
call red_logon |
no_security: |
mcall send, [socketnum], shared, 1, 0 |
DEBUGF 1, 'Sending handshake: shared session?\n' |
mcall 23, 100*TIMEOUT |
call wait_for_data ; now the server should send init message |
DEBUGF 1, 'Serverinit: bpp: %u depth: %u bigendian: %u truecolor: %u\n', \ |
[receive_buffer+framebuffer.pixelformat.bpp]:1, \ |
[receive_buffer+framebuffer.pixelformat.depth]:1, \ |
[receive_buffer+framebuffer.pixelformat.big_endian]:1, \ |
[receive_buffer+framebuffer.pixelformat.true_color]:1 |
mov eax, dword [receive_buffer] |
mov dword [fbur.width], eax |
bswap eax |
mov dword [screen], eax |
mcall send, [socketnum], pixel_format8, 20, 0 |
DEBUGF 1, 'Sending pixel format\n' |
call read_data |
; eth.write_tcp [socket],8,encodings |
; DEBUGF 1,'Sending encoding info\n' |
; call read_data |
mov byte [thread_ready], 1 |
request_rfb: |
mov [fbur.inc], 2 |
mcall send, [socketnum], fbur, 10, 0 |
thread_loop: |
mcall 23, 100 |
call read_data ; Read the data into the buffer |
; cmp eax, 2 |
; jb mainloop |
DEBUGF 1,'Data received, %u bytes\n', eax |
cmp byte [receive_buffer],0 |
je framebufferupdate |
cmp byte [receive_buffer],1 |
je setcolourmapentries |
cmp byte [receive_buffer],2 |
je bell |
cmp byte [receive_buffer],3 |
je servercuttext |
jmp thread_loop |
align 4 |
framebufferupdate: |
mov ax, word [receive_buffer+2] |
xchg al, ah |
mov di, ax |
DEBUGF 1, 'Framebufferupdate: %u frames\n', di |
mov esi, receive_buffer+4 |
jmp rectangle_loop |
next_rectangle: |
call drawbuffer |
dec di |
test di, di |
jz request_rfb |
rectangle_loop: |
mov edx, [esi] |
bswap edx |
mov ebx, edx |
shr edx, 16 |
mov [frame.x], dx |
mov [frame.y], bx |
add esi, 4 |
mov ecx, [esi] |
bswap ecx |
mov eax, ecx |
shr ecx, 16 |
mov [frame.width], cx |
mov [frame.height], ax |
add esi, 4 |
mov eax, [esi] |
add esi, 4 |
mov ebx, esi |
sub ebx, receive_buffer+12 |
DEBUGF 1, 'frame: width=%u height=%u x=%u y=%u offset:%u encoding:',\ |
[frame.width]:2, [frame.height]:2, [frame.x]:2, [frame.y]:2, ebx |
cmp eax, 0 |
je encoding_raw |
; cmp eax, 1 |
; je encoding_copyrect |
cmp eax, 2 |
je encoding_RRE |
cmp eax, 5 |
je encoding_hextile |
cmp eax, 16 |
je encoding_ZRLE |
mov ebx, esi |
sub ebx, receive_buffer+8 |
DEBUGF 1, '\nunknown encoding: %u (offset %u)\n', eax, ebx |
jmp bell |
jmp thread_loop |
encoding_RRE: |
DEBUGF 1, 'RRE\n' |
jmp next_rectangle |
encoding_hextile: |
DEBUGF 1, 'hextile\n' |
jmp next_rectangle |
encoding_ZRLE: |
DEBUGF 1, 'ZRLE\n' |
jmp next_rectangle |
setcolourmapentries: |
DEBUGF 1, 'Server sent SetColourMapEntries message\n' |
jmp thread_loop |
bell: |
mcall 55, 55, , , beep |
jmp thread_loop |
servercuttext: |
DEBUGF 1, 'Server cut text\n' |
jmp thread_loop |
read_data: |
mov [datapointer], receive_buffer |
.loop: |
mcall 23, 100*TIMEOUT |
mcall recv, [socketnum], [datapointer], 4096, 0 |
cmp eax, -1 |
je .done |
add [datapointer], eax |
cmp eax, 4096 |
je .loop |
.done: |
mov eax, [datapointer] |
sub eax, receive_buffer |
ret |
wait_for_data: |
mcall 23, 500 |
mcall recv, [socketnum], receive_buffer, 4096, 0 |
cmp eax, -1 |
je wait_for_data |
test eax, eax |
jz wait_for_data |
ret |
/programs/network/vncc/vncc.asm |
---|
0,0 → 1,283 |
; |
; |
; VNC Client for kolibrios by hidnplayr |
; |
; hidnplayr@gmail.com |
; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
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 |
dd 0x0 , 0x0 ; I_Param , I_Path |
__DEBUG__ equ 1 |
__DEBUG_LEVEL__ equ 1 |
STRLEN = 64 ; password and server max length |
xpos = 4 ; coordinates of image |
ypos = 22 ; |
TIMEOUT = 5 ; timeout in seconds |
include '../macros.inc' |
include '../debug-fdo.inc' |
include '../proc32.inc' |
include '../dll.inc' |
include '../struct.inc' |
include '../network.inc' |
include 'structs.inc' |
include 'logon.inc' |
include 'raw.inc' |
include 'thread.inc' |
START: |
mcall 68, 11 ; init heap |
; load libraries |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
call red_logon |
mcall 40, 0 ; no events |
mcall 67, 0, 0, 0, 0 ; resize the window (hide it) |
mcall 51, 1, thread_start, thread_stack |
DEBUGF 1,'Thread created: %u\n', eax |
@@: |
mcall 5, 10 |
cmp byte [thread_ready], 0 |
je @r |
mcall 40, 100111b ; mouse, button, key, redraw |
mov edx, dword [screen] |
movzx esi, dx |
shr edx, 16 |
add edx, 2*xpos |
add esi, ypos+xpos |
mcall 67, 10, 10 ; resize the window |
mainloop: |
mcall 23, 50 ; wait for event, 0,5s timeout |
dec eax |
jz redraw |
dec eax |
jz key |
dec eax |
jz button |
sub eax, 3 |
jz mouse |
jmp mainloop |
key: |
DEBUGF 1,'Sending key event\n' |
mcall 2 |
mov byte [keyevent.key+3], ah |
mcall send, [socketnum], keyevent, 8, 0 |
jmp mainloop |
mouse: |
DEBUGF 1,'Sending mouse event\n' |
mcall 37, 1 ; get mouse pos |
sub eax, xpos shl 16 + ypos |
bswap eax |
mov [pointerevent.x], ax |
shr eax, 16 |
mov [pointerevent.y], ax |
mcall 37, 2 ; get mouse buttons |
test al, 00000010b ; test if right button was pressed (bit 1 in kolibri) |
jz @f |
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 |
@@: |
mov [pointerevent.mask],al |
mcall send, [socketnum], pointerevent, 6, 0 |
jmp mainloop |
redraw: |
DEBUGF 1,'Drawing window\n' |
mcall 12, 1 |
mov ebx, dword[screen] |
movzx ecx, bx |
shr ebx, 16 |
mov edx, 0x74ffffff |
mov edi, name |
mcall 0 ; draw window |
call drawbuffer |
mcall 12, 2 |
jmp mainloop |
drawbuffer: |
mcall 7, framebuffer_data, dword[screen], 0 |
ret |
button: |
mcall 17 ; get id |
exit: |
DEBUGF 1, 'Closing time!\n' |
mcall close, [socketnum] |
mcall -1 |
no_rfb: |
DEBUGF 1, 'This is no vnc server!\n' |
jmp exit |
invalid_security: |
DEBUGF 1, 'Security error: %s\n', receive_buffer+5 |
jmp exit |
; DATA AREA |
include_debug_strings ; ALWAYS present in data section |
handshake db 'RFB 003.003', 10 |
shared db 0 |
beep db 0x85,0x25,0x85,0x40,0 |
pixel_format32 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 32 ; bits per pixel |
.depth db 32 ; 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_shif db 0 ; red-shift |
.green_shift db 8 ; green-shift |
.blue_shift db 16 ; blue-shift |
rb 3 ; padding |
pixel_format16 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 16 ; bits per pixel |
.depth db 15 ; depth |
.big_endian db 0 ; big-endian flag |
.true_color db 1 ; true-colour flag |
.red_max db 0,31 ; red-max |
.green_max db 0,31 ; green-max |
.blue_max db 0,31 ; blue-max |
.red_shif db 0 ; red-shift |
.green_shift db 5 ; green-shift |
.blue_shift db 10 ; blue-shift |
rb 3 ; padding |
pixel_format8 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 8 ; bits per pixel |
.depth db 6 ; depth |
.big_endian db 0 ; big-endian flag |
.true_color db 1 ; true-colour flag |
.red_max db 0,3 ; red-max |
.green_max db 0,3 ; green-max |
.blue_max db 0,3 ; blue-max |
.red_shif db 0 ; red-shift |
.green_shift db 2 ; green-shift |
.blue_shift db 4 ; blue-shift |
rb 3 ; padding |
encodings db 2 ; setEncodings |
rb 1 ; padding |
db 1,0 ; number of encodings |
db 0,0,0,0 ; raw encoding (DWORD, Big endian order) |
db 1,0,0,0 ; Copyrect encoding |
fbur db 3 ; frame buffer update request |
.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 |
sockaddr1: |
dw AF_INET4 |
.port dw 0x0c17 ; 5900 |
.ip dd 0 |
rb 10 |
thread_ready db 0 |
; import |
align 4 |
@IMPORT: |
library network, 'network.obj' |
import network, \ |
getaddrinfo, 'getaddrinfo', \ |
freeaddrinfo, 'freeaddrinfo', \ |
inet_ntoa, 'inet_ntoa' |
name db 'VNC client', 0 |
I_END: |
socketnum dd ? |
datapointer dd ? |
frame: |
.width dw ? |
.height dw ? |
.x dw ? |
.y dw ? |
screen: |
.height dw ? |
.width dw ? |
receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
framebuffer_data rb 1024*768*3 ; framebuffer |
rb 0x1000 |
thread_stack: |
rb 0x1000 |
IM_END: |
/programs/network/vncc |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network/zeroconf/trunk/zeroconf.ini |
---|
File deleted |
\ No newline at end of file |
/programs/network/zeroconf/trunk/zeroconf.asm |
---|
File deleted |
/programs/network/zeroconf/trunk/debug-fdo.inc |
---|
File deleted |
/programs/network/zeroconf/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/zeroconf/trunk/dhcp.inc |
---|
File deleted |
/programs/network/zeroconf/trunk/ETH.INC |
---|
File deleted |
/programs/network/zeroconf/trunk |
---|
Property changes: |
Deleted: tsvn:logminsize |
-5 |
\ No newline at end of property |
/programs/network/zeroconf/dhcp.inc |
---|
0,0 → 1,263 |
;Name Number Length Meaning |
dhcp_pad_option equ 0 ; 0 None |
dhcp_end_option equ 255 ; 0 None |
dhcp_subnet_mask equ 1 ; 4 Subnet Mask Value |
dhcp_time_offset equ 2 ; 4 Time Offset in Seconds from UTC |
dhcp_router equ 3 ; N×4 Router addresses |
dhcp_time_server equ 4 ; N×4 Timeserver addresses |
dhcp_name_server equ 5 ; N×4 IEN-116 Server addresses |
dhcp_domain_server equ 6 ; N×4 DNS Server addresses |
dhcp_log_server equ 7 ; N×4 Logging Server addresses |
dhcp_quotes_server equ 8 ; N×4 Quotes Server addresses |
dhcp_lpr_server equ 9 ; N×4 Printer Server addresses |
dhcp_impress_server equ 10 ; N×4 Impress Server addresses |
dhcp_rlp_server equ 11 ; N×4 N RLP Server addresses |
dhcp_hostname equ 12 ; N Hostname string |
dhcp_boot_file_size equ 13 ; 2 Size of boot file in 512-octet blocks |
dhcp_merit_dump_file equ 14 ; N Client to dump and name the file to dump it to |
dhcp_domain_name equ 15 ; N The DNS domain name of the client |
dhcp_swap_server equ 16 ; 4 Swap Server address |
dhcp_root_path equ 17 ; N Path name for root disk |
dhcp_extension_file equ 18 ; N Path name for more BOOTP info |
;IP Layer Parameters per Host |
dhcp_forward equ 19 ; 1 Enable/Disable IP Forwarding |
dhcp_srcrte equ 20 ; 1 Enable/Disable Non-Local Source Routing |
dhcp_policy equ 21 ; N×8 Non-Local Source Routing Policy Filters |
dhcp_mag_dg_assembly equ 22 ; 2 Max Datagram Reassembly Size |
dhcp_default_ip_tll equ 23 ; 1 Default IP Time to Live |
dhcp_mtu_timeout equ 24 ; 4 Path MTU Aging Timeout |
dhcp_mtu_plateau equ 25 ; N×2 Path MTU Plateau Table |
;IP Layer Parameters per Interface |
dhcp_mtu_interface equ 26 ; 2 Interface MTU Size |
dhcp_mtu_subnet equ 27 ; 1 All Subnets are Local |
dhcp_broadcast_address equ 28 ; 4 Broadcast Address |
dhcp_mask_discovery equ 29 ; 1 Perform Mask Discovery |
dhcp_mask_supplier equ 30 ; 1 Provide Mask to Others |
dhcp_router_discovery equ 31 ; 1 Perform Router Discovery |
dhcp_router_request equ 32 ; 4 Router Solicitation Address |
dhcp_static_route equ 33 ; N×8 Static Routing Table |
;Link Layer Parameters per Interface |
dhcp_trailers equ 34 ; 1 Trailer Encapsulation |
dhcp_arp_timeout equ 35 ; 4 ARP Cache Timeout |
dhcp_ethernet equ 36 ; 1 Ethernet Encapsulation |
;TCP Parameters |
dhcp_default_tcp_tll equ 37 ; 1 Default TCP Time to Live |
dhcp_keepalive_time equ 38 ; 4 TCP Keepalive Interval |
dhcp_keepalive_data equ 39 ; 1 TCP Keepalive Garbage |
;Application and Service Parameters |
dhcp_nis_domain equ 40 ; N NIS Domain Name |
dhcp_nis_servers equ 41 ; N×4 NIS Server Addresses |
dhcp_ntp_servers equ 42 ; N×4 NTP Server Addresses |
dhcp_vendor_specific equ 43 ; N Vendor Specific Information |
dhcp_netbios_name_srv equ 44 ; N×4 NETBIOS Name Servers |
dhcp_netbios_dist_srv equ 45 ; N×4 NETBIOS Datagram Distribution |
dhcp_netbios_node_type equ 46 ; 1 NETBIOS Node Type |
dhcp_netbios_scope equ 47 ; N NETBIOS Scope |
dhcp_x_window_font equ 48 ; N×4 X Window Font Server |
dhcp_x_window_manager equ 49 ; N×4 X Window Display Manager |
dhcp_nis_domain_name equ 64 ; N NIS+ v3 Client Domain Name |
dhcp_nis_server_addr equ 65 ; N×4 NIS+ v3 Server Addresses |
dhcp_home_agent_addrs equ 68 ; N×4 Mobile IP Home Agent Addresses |
dhcp_smtp_server equ 69 ; N×4 Simple Mail Server Addresses |
dhcp_pop3_server equ 70 ; N×4 Post Office Server Addresses |
dhcp_nntp_server equ 71 ; N×4 Network News Server Addresses |
dhcp_www_server equ 72 ; N×4 WWW Server Addresses |
dhcp_finger_server equ 73 ; N×4 Finger Server Addresses |
dhcp_irc_server equ 74 ; N×4 Chat Server Addresses |
dhcp_streettalk_server equ 75 ; N×4 StreetTalk Server Addresses |
dhcp_stda_server equ 76 ; N×4 ST Directory Assist. Addresses |
;DHCP Extensions |
dhcp_address_request equ 50 ; 4 Requested IP Address |
dhcp_address_time equ 51 ; 4 IP Address Lease Time |
dhcp_option_overload equ 52 ; 1 Overload "sname" or "file" |
dhcp_msg_type equ 53 ; 1 DHCP Message Type |
dhcp_dhcp_server_id equ 54 ; 4 DHCP Server Identification |
dhcp_parameter_list equ 55 ; N Parameter Request List |
dhcp_dhcp_message equ 56 ; N DHCP Error Message |
dhcp_dhcp_max_msg_size equ 57 ; 2 DHCP Maximum Message Size |
dhcp_renewal_time equ 58 ; 4 DHCP Renewal (T1) Time |
dhcp_rebinding_time equ 59 ; 4 DHCP Rebinding (T2) Time |
dhcp_class_id equ 60 ; N Vendor Class Identifier |
dhcp_client_id equ 61 ; N Client Identifier |
dhcp_server_name equ 66 ; N TFTP Server Name |
dhcp_bootfile_name equ 67 ; N Boot File Name |
;Newer extensions |
dhcp_netware_ip_domain equ 62 ; N Netware/IP Domain Name |
dhcp_netware_ip_option equ 63 ; N Netware/IP sub Options |
dhcp_user_class equ 77 ; N User Class Information |
dhcp_directory_agent equ 78 ; N directory agent information |
dhcp_service_scope equ 79 ; N service location agent scope |
dhcp_rapid_commit equ 80 ; 0 Rapid Commit |
dhcp_client_fqdn equ 81 ; N Fully Qualified Domain Name |
dhcp_relay_agent_info equ 82 ; N Relay Agent Information, RFC 3046 |
dhcp_isns equ 83 ; N Internet Storage Name Service |
; 84 REMOVED/Unassigned |
dhcp_nds_servers equ 85 ; N Novell Directory Services |
dhcp_nds_tree_name equ 86 ; N Novell Directory Services |
dhcp_nds_conext equ 87 ; N Novell Directory Services |
dhcp_bcmcs equ 88 ; Controller Domain Name list |
dhcp_bcmcs equ 89 ; Controller IPv4 address option |
dhcp_authentication equ 90 ; N Authentication |
; 91 REMOVED/Unassigned |
; 92 REMOVED/Unassigned |
dhcp_client_system equ 93 ; N Client System Architecture |
dhcp_client_ndi equ 94 ; N Client Network Device Interface |
dhcp_ldap equ 95 ; N Lightweight Directory Access Protocol |
; 96 REMOVED/Unassigned |
dhcp_uuid_guid equ 97 ; N UUID/GUID-based Client Identifier |
dchp_user_auth equ 98 ; N Open Group's User Authentication |
; 99 REMOVED/Unassigned |
; 100 REMOVED/Unassigned |
; 101 REMOVED/Unassigned |
; 102 REMOVED/Unassigned |
; 103 REMOVED/Unassigned |
; 104 REMOVED/Unassigned |
; 105 REMOVED/Unassigned |
; 106 REMOVED/Unassigned |
; 107 REMOVED/Unassigned |
; 108 REMOVED/Unassigned |
; 109 REMOVED/Unassigned |
; 110 REMOVED/Unassigned |
; 111 REMOVED/Unassigned |
dhcp_netinfo_address equ 112 ; N NetInfo Parent Server Address |
dhcp_netinfo_tag equ 113 ; N NetInfo Parent Server Tag |
dhcp_url equ 114 ; N URL |
; 115 REMOVED/Unassigned |
dhcp_auto_config equ 116 ; N DHCP Auto-Configuration |
dhcp_ns_search equ 117 ; N Name Service Search |
dhcp_subnet_selection equ 118 ; 4 Subnet Selection Option |
dhcp_domain_search equ 119 ; N DNS domain search list |
dhcp_sip_servers equ 120 ; N SIP Servers DHCP Option |
dhcp_cl_static_route equ 121 ; N Classless Static Route Option |
dhcp_ccc equ 122 ; N CableLabs Client Configuration |
dhcp_geoconf equ 123 ; 16 GeoConf Option |
dhcp_v_i_vendor_class equ 124 ; Vendor-Identifying Vendor Class |
dhcp_v_i_vendor_spec equ 125 ; Vendor-Identifying Vendor-Specific |
; 126 REMOVED/Unassigned |
; 127 REMOVED/Unassigned |
dhcp_pxe equ 128 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot_sign equ 128 ; Etherboot signature. 6 bytes: E4:45:74:68:00:00 |
dhcp_docsis equ 128 ; DOCSIS "full security" server IP address |
dhcp_tftp_server_ip equ 128 ; TFTP Server IP address (for IP Phone software load) |
dhcp_pxe equ 129 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_kernel_options equ 129 ; Kernel options. Variable length string |
dhcp_call_server_ip equ 129 ; Call Server IP address |
dhcp_pxe equ 130 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_ethernet_interface equ 130 ; Ethernet interface. Variable length string. |
dhcp_siscrimination equ 130 ; Discrimination string (to identify vendor) |
dhcp_pxe equ 131 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_remote_stat_server equ 131 ; Remote statistics server IP address |
dhcp_pxe equ 132 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_802.1p equ 132 ; 802.1P VLAN ID |
dhcp_pxe equ 133 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_802.1q equ 133 ; 802.1Q L2 Priority |
dhcp_pxe equ 134 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_diffserv equ 134 ; Diffserv Code Point |
dhcp_pxe equ 135 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_http_proxy_psa equ 135 ; HTTP Proxy for phone-specific applications |
; 136 REMOVED/Unassigned |
; 137 REMOVED/Unassigned |
; 138 REMOVED/Unassigned |
; 139 REMOVED/Unassigned |
; 140 REMOVED/Unassigned |
; 141 REMOVED/Unassigned |
; 142 REMOVED/Unassigned |
; 143 REMOVED/Unassigned |
; 144 REMOVED/Unassigned |
; 145 REMOVED/Unassigned |
; 146 REMOVED/Unassigned |
; 147 REMOVED/Unassigned |
; 148 REMOVED/Unassigned |
; 149 REMOVED/Unassigned |
dhcp_tftp_server_addr equ 150 ; TFTP server address (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot equ 150 ; Etherboot |
dhcp_grub_conf_path equ 150 ; GRUB configuration path name |
; 151 REMOVED/Unassigned |
; 152 REMOVED/Unassigned |
; 153 REMOVED/Unassigned |
; 154 REMOVED/Unassigned |
; 155 REMOVED/Unassigned |
; 156 REMOVED/Unassigned |
; 157 REMOVED/Unassigned |
; 158 REMOVED/Unassigned |
; 159 REMOVED/Unassigned |
; 160 REMOVED/Unassigned |
; 161 REMOVED/Unassigned |
; 162 REMOVED/Unassigned |
; 163 REMOVED/Unassigned |
; 164 REMOVED/Unassigned |
; 165 REMOVED/Unassigned |
; 166 REMOVED/Unassigned |
; 167 REMOVED/Unassigned |
; 168 REMOVED/Unassigned |
; 169 REMOVED/Unassigned |
; 170 REMOVED/Unassigned |
; 171 REMOVED/Unassigned |
; 172 REMOVED/Unassigned |
; 173 REMOVED/Unassigned |
; 174 REMOVED/Unassigned |
dhcp_etherboot equ 175 ; Etherboot (Tentatively Assigned - 23 June 2005) |
dhcp_ip_telephone equ 176 ; IP Telephone (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot equ 177 ; Etherboot (Tentatively Assigned - 23 June 2005) |
dhcp_packetcable equ 177 ; PacketCable and CableHome (replaced by 122) |
; 178 REMOVED/Unassigned |
; 179 REMOVED/Unassigned |
; 180 REMOVED/Unassigned |
; 181 REMOVED/Unassigned |
; 182 REMOVED/Unassigned |
; 183 REMOVED/Unassigned |
; 184 REMOVED/Unassigned |
; 185 REMOVED/Unassigned |
; 186 REMOVED/Unassigned |
; 187 REMOVED/Unassigned |
; 188 REMOVED/Unassigned |
; 189 REMOVED/Unassigned |
; 190 REMOVED/Unassigned |
; 191 REMOVED/Unassigned |
; 192 REMOVED/Unassigned |
; 193 REMOVED/Unassigned |
; 194 REMOVED/Unassigned |
; 195 REMOVED/Unassigned |
; 196 REMOVED/Unassigned |
; 197 REMOVED/Unassigned |
; 198 REMOVED/Unassigned |
; 199 REMOVED/Unassigned |
; 200 REMOVED/Unassigned |
; 201 REMOVED/Unassigned |
; 202 REMOVED/Unassigned |
; 203 REMOVED/Unassigned |
; 204 REMOVED/Unassigned |
; 205 REMOVED/Unassigned |
; 206 REMOVED/Unassigned |
; 207 REMOVED/Unassigned |
dhcp_pxelinux.magic equ 208 ; pxelinux.magic (string) = F1:00:74:7E (241.0.116.126) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.conffile equ 209 ; pxelinux.configfile (text) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.path equ 210 ; pxelinux.pathprefix (text) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.reboot equ 211 ; pxelinux.reboottime (unsigned integer 32 bits) (Tentatively Assigned - 23 June 2005) |
; 212 REMOVED/Unassigned |
; 213 REMOVED/Unassigned |
; 214 REMOVED/Unassigned |
; 215 REMOVED/Unassigned |
; 216 REMOVED/Unassigned |
; 217 REMOVED/Unassigned |
; 218 REMOVED/Unassigned |
; 219 REMOVED/Unassigned |
dhcp_subnet_aloc equ 220 ; Subnet Allocation Option (Tentatively Assigned - 23 June 2005) |
dhcp_virtual_subnet equ 221 ; Virtual Subnet Selection Option (Tentatively Assigned - 23 June 2005) |
; 222 REMOVED/Unassigned |
; 223 REMOVED/Unassigned |
/programs/network/zeroconf/zeroconf.asm |
---|
0,0 → 1,620 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2013. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; zeroconfig.asm - Zeroconfig service for KolibriOS ;; |
;; ;; |
;; Written by hidnplayr@kolibrios.org ;; |
;; Some code contributed by Derpenguin ;; |
;; ;; |
;; DHCP code is based on that by Mike Hibbet ;; |
; (DHCP client for menuetos) ;; |
;; ;; |
;; GNU GENERAL PUBLIC LICENSE ;; |
;; Version 2, June 1991 ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format binary as "" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd (I_END+0x100) ; memory for app |
dd (I_END+0x100) ; esp |
dd 0, 0 ; I_Param, I_Path |
; CONFIGURATION |
TIMEOUT = 60 ; in seconds |
BUFFER = 1024 ; in bytes |
__DEBUG__ = 1 ; enable/disable |
__DEBUG_LEVEL__ = 1 ; 1 = all, 2 = errors |
; CONFIGURATION FOR LINK-LOCAL |
PROBE_WAIT = 1 ; second (initial random delay) |
PROBE_MIN = 1 ; second (minimum delay till repeated probe) |
PROBE_MAX = 2 ; seconds (maximum delay till repeated probe) |
PROBE_NUM = 3 ; (number of probe packets) |
ANNOUNCE_NUM = 2 ; (number of announcement packets) |
ANNOUNCE_INTERVAL = 2 ; seconds (time between announcement packets) |
ANNOUNCE_WAIT = 2 ; seconds (delay before announcing) |
MAX_CONFLICTS = 10 ; (max conflicts before rate limiting) |
RATE_LIMIT_INTERVAL = 60 ; seconds (delay between successive attempts) |
DEFEND_INTERVAL = 10 ; seconds (min. wait between defensive ARPs) |
include '../proc32.inc' |
include '../macros.inc' |
include '../debug-fdo.inc' |
include '../network.inc' |
include 'dhcp.inc' |
include '../dll.inc' |
Ip2dword: |
push edx |
; This code validates if the query is an IP containing 4 numbers and 3 dots |
xor al, al ; make al (dot count) zero |
@@: |
cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP |
jl no_IP ; |
cmp byte[edx],'9' ; |
jg no_IP ; |
inc edx ; the byte was a number, so lets check the next byte |
cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) |
jz @f ; jump to next @@ then |
cmp byte[edx],':' |
jz @f |
cmp byte[edx],'.' ; is this byte a dot? |
jne @r ; if not, jump to previous @@ |
inc al ; the byte was a dot so increment al(dot count) |
inc edx ; next byte |
jmp @r ; lets check for numbers again (jump to previous @@) |
@@: ; we reach this when end of query reached |
cmp al,3 ; check if there where 3 dots |
jnz no_IP ; if not, jump to no_IP |
; The following code will convert this IP into a dword and output it in eax |
; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1 |
pop esi ; edx (query address) was pushed onto stack and is now popped in esi |
xor edx, edx ; result |
xor eax, eax ; current character |
xor ebx, ebx ; current byte |
.outer_loop: |
shl edx, 8 |
add edx, ebx |
xor ebx, ebx |
.inner_loop: |
lodsb |
test eax, eax |
jz .finish |
cmp al, '.' |
jz .outer_loop |
sub eax, '0' |
imul ebx, 10 |
add ebx, eax |
jmp .inner_loop |
.finish: |
shl edx, 8 |
add edx, ebx |
bswap edx ; we want little endian order |
ret |
no_IP: |
pop edx |
xor edx, edx |
ret |
START: |
mcall 40, EVM_STACK2 |
DEBUGF 1,">Zero-config service loaded\n" |
.wait: |
mcall 76, API_ETH + 4 ; get MAC of ethernet interface 0 |
cmp eax, -1 |
jne .start |
mcall 10 |
jmp .wait |
.start: |
mov word[MAC], bx |
mov dword[MAC+2], eax |
DEBUGF 1,"->MAC: %x-%x-%x-%x-%x-%x\n", [MAC+0]:2, [MAC+1]:2, [MAC+2]:2, [MAC+3]:2, [MAC+4]:2, [MAC+5]:2 |
mcall 40, EVM_STACK |
mcall 68, 11 |
stdcall dll.Load,@IMPORT |
or eax, eax |
jnz try_dhcp |
invoke ini.get_str, path, str_ipconfig, str_type, inibuf, 16, 0 |
cmp dword[inibuf], 'stat' |
jne try_dhcp |
invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
mcall 76, API_IPv4 + 3, edx |
invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
mcall 76, API_IPv4 + 9, edx |
invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
mcall 76, API_IPv4 + 5, edx |
invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
mcall 76, API_IPv4 + 7, edx |
mcall -1 |
try_dhcp: |
DEBUGF 1,"->Trying DHCP\n" |
mcall 75, 0, AF_INET4, SOCK_DGRAM, 0 ; open socket (parameters: domain, type, reserved) |
cmp eax, -1 |
je error |
mov [socketNum], eax |
DEBUGF 1,"->Socket %x opened\n", eax |
mcall 75, 2, [socketNum], sockaddr1, 18 ; bind socket to local port 68 |
cmp eax, -1 |
je error |
DEBUGF 1,"->Socket Bound to local port 68\n" |
mcall 75, 4, [socketNum], sockaddr2, 18 ; connect to 255.255.255.255 on port 67 |
cmp eax, -1 |
je error |
DEBUGF 1,"->Connected to 255.255.255.255 on port 67\n" |
mov [dhcpMsgType], 0x01 ; DHCP discover |
mov [dhcpLease], esi ; esi is still -1 (-1 = forever) |
mcall 26, 9 ; Get system time |
imul eax, 100 |
mov [currTime], eax |
build_request: ; Creates a DHCP request packet. |
DEBUGF 1,"->Building request\n" |
stdcall mem.Alloc, BUFFER |
mov [dhcpMsg], eax |
test eax, eax |
jz dhcp_error |
;;; todo: skip this bullcrap |
mov edi, eax |
mov ecx, BUFFER |
xor eax, eax |
rep stosb |
;; todo: put this in a buffer instead of writing bytes and words! |
mov edx, [dhcpMsg] |
; Boot protocol legacy |
mov [edx], byte 0x01 ; Boot request |
mov [edx+1], byte 0x01 ; Ethernet |
mov [edx+2], byte 0x06 ; Ethernet h/w len |
mov [edx+4], dword 0x11223344 ; xid ;;;;;;; |
mov eax, [currTime] |
mov [edx+8], eax ; secs, our uptime |
mov [edx+10], byte 0x80 ; broadcast flag set |
mov eax, dword [MAC] ; first 4 bytes of MAC |
mov [edx+28],dword eax |
mov ax, word [MAC+4] ; last 2 bytes of MAC |
mov [edx+32],word ax |
; DHCP extension |
mov [edx+236], dword 0x63538263 ; magic cookie |
mov [edx+240], word 0x0135 ; option DHCP msg type |
mov al, [dhcpMsgType] |
mov [edx+240+2], al |
mov [edx+240+3], word 0x0433 ; option Lease time = infinity |
mov eax, [dhcpLease] |
mov [edx+240+5], eax |
mov [edx+240+9], word 0x0432 ; option requested IP address |
mov eax, [dhcp.ip] |
mov [edx+240+11], eax |
mov [edx+240+15], word 0x0437 ; option request list |
mov [edx+240+17], dword 0x0f060301 |
cmp [dhcpMsgType], byte 0x01 ; Check which msg we are sending |
jne request_options |
mov [edx+240+21], byte 0xff ; "Discover" options |
mov [dhcpMsgLen], dword 262 ; end of options marker |
jmp send_dhcpmsg |
request_options: |
mov [edx+240+21], word 0x0436 ; server IP |
mov eax, [dhcpServerIP] |
mov [edx+240+23], eax |
mov [edx+240+27], byte 0xff ; end of options marker |
mov [dhcpMsgLen], dword 268 |
send_dhcpmsg: |
mcall 75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen] ; write to socket ( send broadcast request ) |
mov eax, [dhcpMsg] ; Setup the DHCP buffer to receive response |
mov [dhcpMsgLen], eax ; Used as a pointer to the data |
mcall 23, TIMEOUT*10 ; wait for data |
read_data: ; we have data - this will be the response |
mcall 75, 7, [socketNum], [dhcpMsg], BUFFER ; read data from socket |
DEBUGF 1,"->%d bytes received\n", eax |
cmp eax, -1 |
je dhcp_error |
mov [dhcpMsgLen], eax |
; depending on which msg we sent, handle the response |
; accordingly. |
; If the response is to a dhcp discover, then: |
; 1) If response is DHCP OFFER then |
; 1.1) record server IP, lease time & IP address. |
; 1.2) send a request packet |
; If the response is to a dhcp request, then: |
; 1) If the response is DHCP ACK then |
; 1.1) extract the DNS & subnet fields. Set them in the stack |
cmp [dhcpMsgType], 0x01 ; did we send a discover? |
je discover |
cmp [dhcpMsgType], 0x03 ; did we send a request? |
je request |
call dhcp_end ; we should never reach here ;) |
jmp exit |
discover: |
call parse_response |
cmp [dhcpMsgType], 0x02 ; Was the response an offer? |
je send_request |
call dhcp_end |
jmp link_local |
send_request: |
mov [dhcpMsgType], 0x03 ; make it a request |
jmp build_request |
request: |
call parse_response |
cmp [dhcpMsgType], 0x05 ; Was the response an ACK? It should be |
jne read_data ; NO - read next packets |
call dhcp_end |
mcall 76, API_IPv4 + 3, [dhcp.ip] ; ip |
mcall 76, API_IPv4 + 5, [dhcp.dns] ; dns |
mcall 76, API_IPv4 + 7, [dhcp.subnet] ; subnet |
mcall 76, API_IPv4 + 9, [dhcp.gateway] ; gateway |
jmp exit |
dhcp_end: |
mcall close, [socketNum] |
stdcall mem.Free, [dhcpMsg] |
ret |
;*************************************************************************** |
; Function |
; parseResponse |
; |
; Description |
; extracts the fields ( client IP address and options ) from |
; a DHCP response |
; The values go into |
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, |
; dhcpDNSIP, dhcpSubnet |
; The message is stored in dhcpMsg |
; |
;*************************************************************************** |
parse_response: |
DEBUGF 1,"Data received, parsing response\n" |
mov edx, [dhcpMsg] |
push dword [edx+16] |
pop [dhcp.ip] |
DEBUGF 1,"Client: %u.%u.%u.%u\n", [edx+16]:1, [edx+17]:1, [edx+18]:1, [edx+19]:1 |
; TODO: check if there really are options |
mov al, 240 ; Point to first option |
movzx ecx, al |
.next_option: |
add edx, ecx |
mov al, [edx] ; get message identifier |
cmp al, 0xff ; End of options? |
je .done |
cmp al, 0 |
je .pad |
; TODO: check if we still are inside the buffer |
inc edx |
movzx ecx, byte [edx] ; get data length |
inc edx ; point to data |
cmp al, dhcp_msg_type ; Msg type is a single byte option |
je .msgtype |
cmp al, dhcp_dhcp_server_id |
je .server |
cmp al, dhcp_address_time |
je .lease |
cmp al, dhcp_subnet_mask |
je .subnet |
cmp al, dhcp_router |
je .router |
cmp al, dhcp_domain_server |
je .dns |
DEBUGF 1,"Unsupported DHCP option: %u\n", al |
jmp .next_option |
.pad: |
xor ecx, ecx |
inc ecx |
jmp .next_option |
.msgtype: |
mov al, [edx] |
mov [dhcpMsgType], al |
DEBUGF 1,"DHCP Msg type: %u\n", al |
jmp .next_option ; Get next option |
.server: |
mov eax, [edx] |
mov [dhcpServerIP], eax |
DEBUGF 1,"Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
jmp .next_option |
.lease: |
pusha |
mov eax,[edx] |
bswap eax |
mov [dhcpLease],eax |
DEBUGF 1,"lease: %d\n",eax |
popa |
jmp .next_option |
.subnet: |
push dword [edx] |
pop [dhcp.subnet] |
DEBUGF 1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
jmp .next_option |
.router: |
push dword [edx] |
pop [dhcp.gateway] |
DEBUGF 1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
jmp .next_option |
.dns: |
push dword [edx] |
pop [dhcp.dns] |
DEBUGF 1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
jmp .next_option |
.done: |
ret |
dhcp_error: |
call dhcp_end |
link_local: |
call random |
mov cx, ax |
shl ecx, 16 |
mov cx, 0xfea9 ; IP 169.254.0.0 link local net, see RFC3927 |
mcall 76, API_IPv4 + 3, ecx ; mask is 255.255.0.0 |
DEBUGF 1,"Link Local IP assinged: 169.254.%u.%u\n", [generator+0]:1, [generator+1]:1 |
mcall 76, API_IPv4 + 7, 0xffff |
mcall 76, API_IPv4 + 9, 0x0 |
mcall 76, API_IPv4 + 5, 0x0 |
mcall 5, PROBE_WAIT*100 |
xor esi, esi |
probe_loop: |
call random ; create a pseudo random number in eax (seeded by MAC) |
cmp al, PROBE_MIN*100 ; check if al is bigger then PROBE_MIN |
jae @f ; all ok |
add al, (PROBE_MAX-PROBE_MIN)*100 ; al is too small |
@@: |
cmp al, PROBE_MAX*100 |
jbe @f |
sub al, (PROBE_MAX-PROBE_MIN)*100 |
@@: |
movzx ebx,al |
DEBUGF 1,"Waiting %u0ms\n",ebx |
mcall 5 |
DEBUGF 1,"Sending Probe\n" |
mcall 76, API_ARP + 6 |
inc esi |
cmp esi, PROBE_NUM |
jb probe_loop |
; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assingned |
; IP within this time, we should create another adress, that have to be done later |
DEBUGF 1,"Waiting %us\n", ANNOUNCE_WAIT |
mcall 5, ANNOUNCE_WAIT*100 |
xor esi, esi |
announce_loop: |
DEBUGF 1,"Sending Announce\n" |
mcall 76, API_ARP + 6 |
inc esi |
cmp esi,ANNOUNCE_NUM |
je @f |
DEBUGF 1,"Waiting %us\n", ANNOUNCE_INTERVAL |
mcall 5, ANNOUNCE_INTERVAL*100 |
jmp announce_loop |
@@: |
error: |
DEBUGF 1,"Socket error\n" |
exit: ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;) |
mcall -1 |
random: ; Pseudo random actually |
mov eax, [generator] |
add eax, -43ab45b5h |
ror eax, 1 |
bswap eax |
xor eax, dword[MAC] |
ror eax, 1 |
xor eax, dword[MAC+2] |
mov [generator], eax |
ret |
; DATA AREA |
align 16 |
@IMPORT: |
library \ |
libini,'libini.obj' |
import libini, \ |
ini.get_str,'ini_get_str' |
include_debug_strings |
str_ip db 'ip', 0 |
str_subnet db 'subnet', 0 |
str_gateway db 'gateway', 0 |
str_dns db 'dns', 0 |
str_ipconfig db 'ipconfig', 0 |
str_type db 'type', 0 |
sockaddr1: |
dw AF_INET4 |
dw 68 shl 8 ; local port |
dd 0 ; local IP |
rb 10 |
sockaddr2: |
dw AF_INET4 |
dw 67 shl 8 ; destination port |
dd -1 ; destination IP |
rb 10 |
path db '/sys/network.ini' |
IM_END: |
inibuf rb 16 |
dhcpMsgType db ? |
dhcpLease dd ? |
dhcpServerIP dd ? |
dhcp: |
.ip dd ? |
.subnet dd ? |
.dns dd ? |
.gateway dd ? |
dhcpMsgLen dd ? |
socketNum dd ? |
MAC dp ? |
currTime dd ? |
generator dd ? |
dhcpMsg dd ? |
I_END: |
/programs/network/zeroconf |
---|
Property changes: |
Deleted: tsvn:logminsize |
-5 |
\ No newline at end of property |
/programs/network_old/browser/browser.asm |
---|
0,0 → 1,321 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; BROWSER for KolibriOS ; |
; ; |
; Compile with FASM ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; It's a work in progress but I (esevece) commit it, because if I don't continue developing it someone can continue. |
; Please, keep the code clean |
; The header |
use32 ; Tell compiler to use 32 bit instructions |
org 0x0 ; the base address of code, always 0x0 |
db 'MENUET01' |
dd 0x01 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x7fff0 |
dd 0, 0 |
; The code area |
;include 'macros.inc' |
START: ; start of execution |
call draw_window ; draw the window |
; After the window is drawn, it's practical to have the main loop. |
; Events are distributed from here. |
event_wait: |
mov eax, 10 ; function 10 : wait until event |
int 0x40 ; event type is returned in eax |
cmp eax, 1 ; Event redraw request ? |
je redraw ; Expl.: there has been activity on screen and |
; parts of the applications has to be redrawn. |
cmp eax, 2 ; Event key in buffer ? |
je key ; Expl.: User has pressed a key while the |
; app is at the top of the window stack. |
cmp eax, 3 ; Event button in buffer ? |
je button ; Expl.: User has pressed one of the |
; applications buttons. |
jmp event_wait |
; The next section reads the event and processes data. |
redraw: ; Redraw event handler |
call draw_window ; We call the window_draw function and |
jmp event_wait ; jump back to event_wait |
key: ; Keypress event handler |
mov eax, 2 ; The key is returned in ah. The key must be |
int 0x40 ; read and cleared from the system queue. |
jmp event_wait ; Just read the key, ignore it and jump to event_wait. |
button: ; Buttonpress event handler |
mov eax,17 ; The button number defined in window_draw |
int 0x40 ; is returned to ah. |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; Function -1 : close this program |
int 0x40 |
noclose: |
cmp ah, 2 ; call fetch_thread |
jne no_fetch_thread |
call fetch_thread |
jmp event_wait ; This is for ignored events, useful at development |
no_fetch_thread: |
jmp event_wait |
; FETCHER |
FETCH: |
mov ecx, 1000 |
get_free_port: |
inc ecx |
mov eax, 53 |
mov ebx, 9 |
int 0x40 |
cmp eax, 0 ; is port used? |
jz get_free_port |
open_socket: |
mov eax, 53 |
mov ebx, 5 |
mov edx, 80 |
mov esi, 0x0417042E ; 46.4.23.4 (kolibrios.org), only for try |
mov edi, 1 |
int 0x40 |
mov [socket], eax |
cmp [socket], -1 ; error? |
jne status_socket |
ret |
status_socket: |
mov eax, 53 |
mov ebx, 6 |
mov ecx, [socket] |
int 0x40 |
cmp eax, 4 ; connected? |
jne status_socket |
send_request: |
.concat_request: |
mov edi, request |
mov ebx, 0 ; request_length |
mov esi, request_first_line |
._first_line: |
movsb |
inc ebx ; request_length |
cmp byte [edi], 0 |
jne ._first_line |
mov esi, request_second_line |
._second_line: |
movsb |
inc ebx ; request_length |
cmp byte [edi], 0 |
jne ._second_line |
mov esi, host |
._second_line_host: |
movsb |
inc ebx ; request_length |
cmp byte [edi], 0 |
jne ._second_line_host |
mov esi, request_third_line |
._third_line: |
movsb |
inc ebx ; request_length |
cmp byte [edi], 0 |
jne ._third_line |
mov [request_length], ebx |
.write_to_socket: |
mov eax, 53 |
mov ebx, 7 |
mov ecx, [socket] |
mov edx, [request_length] |
mov esi, request |
int 0x40 |
cmp eax, -1 ; error? |
je .write_to_socket |
.poll_socket: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
cmp eax, 0 |
jne .read_socket |
; only for test purposes |
mov eax, 63 |
mov ebx, 1 |
mov cl, 's' |
int 0x40 |
.status_socket: |
mov eax, 53 |
mov ebx, 6 |
mov ecx, [socket] |
int 0x40 |
cmp eax, 4 |
jne end_of_request |
.read_socket: |
mov eax, 53 |
mov ebx, 11 |
mov ecx, [socket] |
mov edx, [buffer] |
mov esi, 4096 |
int 0x40 |
; only for test purposes |
mov eax, 63 |
mov ebx, 1 |
mov cl, 'p' |
int 0x40 |
jmp .poll_socket |
end_of_request: |
.close_socket: |
mov eax, 53 |
mov ebx, 8 |
mov ecx, [socket] |
int 0x40 |
; only for test purposes |
mov eax, 63 |
mov ebx, 1 |
mov cl, 'b' |
int 0x40 |
jmp terminate_thread |
fetch_thread: |
cmp [thread_id], 0 |
jne terminate_thread |
mov eax, 51 |
mov ebx, 1 |
mov ecx, FETCH |
mov edx, [thread_stack] |
int 0x40 |
jmp event_wait |
no_new_thread: |
ret |
terminate_thread: |
mov eax, 18 |
mov ebx, 18 |
mov ecx, [thread_id] |
int 0x40 |
cmp eax, 0 |
jne terminate_thread |
mov [thread_id], 0 |
ret |
thread_stack dd 0x80000 |
thread_id dd 0x0 |
; ********************************************* |
; ****** WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
; |
; The static window parts are drawn in this function. The window canvas can |
; be accessed later from any parts of this code (thread) for displaying |
; processes or recorded data, for example. |
; |
; The static parts *must* be placed within the fn 12 , ebx = 1 and ebx = 2. |
draw_window: |
mov eax, 12 ; function 12: tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, 100 * 65536 + 300 ; [x start] *65536 + [x size] |
mov ecx, 100 * 65536 + 120 ; [y start] *65536 + [y size] |
mov edx, 0x14ffffff ; color of work area RRGGBB |
; 0x02000000 = window type 4 (fixed size, skinned window) |
mov esi, 0x808899ff ; color of grab bar RRGGBB |
; 0x80000000 = color glide |
mov edi, title |
int 0x40 |
; Fetch button |
mov eax, 8 |
mov ebx, 25 * 65536 + 128 |
mov ecx, 88 * 65536 + 20 |
mov edx, 2 |
mov esi, 0x6677cc |
int 0x40 |
mov ebx, 25 * 65536 + 35 ; draw info text with function 4 |
mov ecx, 0x224466 |
mov edx, text |
mov esi, 40 |
mov eax, 4 |
.newline: ; text from the DATA AREA |
int 0x40 |
add ebx, 10 |
add edx, 40 |
cmp byte[edx], 0 |
jne .newline |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 2 ; 2, end of draw |
int 0x40 |
ret |
; ********************************************* |
; ************* DATA AREA ***************** |
; ********************************************* |
; |
; Data can be freely mixed with code to any parts of the image. |
; Only the header information is required at the beginning of the image. |
text db "It look's like you have just compiled " |
db "your first program for KolibriOS. " |
db " " |
db "Congratulations! ", 0 |
title db "KolibriOS Browser", 0 |
socket dd 0 |
socket_status dd 0 |
server_ip db 046,004,023,004 |
server_port db 0,0 |
request_first_line db 'GET / HTTP/1.1',0 |
request_second_line db 13,10,'Host: ',0 |
request_third_line db 13,10,'Connection: close',13,10,13,10,0 |
request db 0 |
request_length dd 0 |
host db 'kolibrios.org',0 |
buffer dd 0 |
I_END: |
; The area after I_END is free for use as the application memory, |
; just avoid the stack. |
; |
; Application memory structure, according to the used header, 1 Mb. |
; |
; 0x00000 - Start of compiled image |
; I_END - End of compiled image |
; |
; + Free for use in the application |
; |
; 0x7ff00 - Start of stack area |
; 0x7fff0 - End of stack area - defined in the header |
; |
; + Free for use in the application |
; |
; 0xFFFFF - End of freely useable memory - defined in the header |
; |
; All of the the areas can be modified within the application with a |
; direct reference. |
; For example, mov [0x80000],byte 1 moves a byte above the stack area. |
/programs/network_old/browser/build.bat |
---|
0,0 → 1,6 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm browser.asm browser |
@kpack browser |
@erase lang.inc |
@pause |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/network_old/browser/build.sh |
---|
0,0 → 1,13 |
#!/bin/bash |
# This script does for linux the same as build.bat for DOS, |
# it compiles the KoOS kernel, hopefully ;-) |
echo "lang fix en" |
echo "lang fix en" > lang.inc |
fasm -m 16384 browser.asm browser |
rm -f lang.inc |
exit 0 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/network_old/airc/trunk/airc.asm |
---|
0,0 → 1,2864 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; IRC CLIENT for KolibriOS ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2004 (c) Ville Turjanmaa ;; |
;; Copyright 2009 (c) CleverMouse ;; |
;; ;; |
;; Compile with FASM for Kolibri ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.6' |
;__DEBUG__ equ 1 |
;__DEBUG_LEVEL__ equ 1 |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd initialized_size ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x100000 |
dd 0,0 |
include "../../../macros.inc" |
include "../../../proc32.inc" |
include "../../../develop/libraries/network/network.inc" |
include "../../../dll.inc" |
;include "fdo.inc" |
include "eth.inc" |
include "lang.inc" |
; connection statuses |
STATUS_DISCONNECTED = 0 ; disconnected |
STATUS_RESOLVING = 1 ; resolving server name |
STATUS_CONNECTING = 2 ; connecting to server |
STATUS_CONNECTED = 3 ; connected |
; where to display status |
STATUS_X = 25 + 22*6 |
STATUS_Y = 183 + 7*12 |
; supported encodings |
CP866 = 0 |
CP1251 = 1 |
UTF8 = 2 |
; where to display encoding |
ENCODING_X = 25 + 15*6 |
ENCODING_Y = 183 + 3*12 |
def_server_name db 'chat.freenode.net',0 ; default server name |
user_nick dd 12 ; length |
db 'kolibri_user ' ; string |
user_nick_max = $ - user_nick - 4 |
user_real_name dd 14 ; length |
db 'KolibriOS User ' ; string |
user_real_name_max = $ - user_real_name - 4 |
START: ; start of execution |
stdcall dll.Load, @IMPORT |
test eax,eax |
jnz exit |
mov eax,40 |
mov ebx,11000111b |
mcall |
mcall 60, 1, ipcbuf, ipcbuf.size |
mcall 9, 0xe0000, -1 |
mov eax,[ebx+process_information.PID] |
mov [main_PID],eax |
mov esi, def_server_name |
mov edi, irc_server_name |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
mov edi,I_END |
mov ecx,60*120 |
mov al,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
redraw: ; redraw |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
dec eax ; redraw |
je redraw |
dec eax ; key |
je main_window_key |
dec eax ; button |
je button |
cmp al,4 |
jz ipc |
call process_network_event |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_channel_text |
no_main_update: |
call print_channel_list |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; close program |
jne noclose |
exit: |
or eax,-1 |
mcall |
noclose: |
cmp ah,21 |
jne no_change_encoding |
cmp byte[edx-1],0 |
jnz still |
mov eax,[encoding] |
inc eax |
mov edx,msgbox_struct |
mov byte[edx],al |
mov byte[edx-1],1 ; msgbox is running |
push mb_stack |
push edx |
call [mb_create] |
push msgbox_func_array |
call [mb_setfunctions] |
jmp still |
no_change_encoding: |
call socket_commands |
jmp still |
ipc: |
mov edx,msgbox_struct |
cmp byte[edx-1],0 |
jz @f |
mov byte[edx-1],0 |
mov al,[edx] |
dec eax |
mov byte[encoding],al |
call update_encoding |
jmp ipc_done |
@@: |
call process_command |
ipc_done: |
mov dword [ipcbuf+4], 8 |
jmp still |
main_window_key: |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,8 |
jne no_bks2 |
cmp [xpos],0 |
je still |
dec [xpos] |
call print_entry |
jmp still |
no_bks2: |
cmp eax,20 |
jbe no_character2 |
mov ebx,[xpos] |
mov [send_string+ebx],al |
inc [xpos] |
cmp [xpos],80 |
jb noxposdec |
mov [xpos],79 |
noxposdec: |
call print_entry |
jmp still |
no_character2: |
cmp eax,13 |
jne no_send2 |
cmp [xpos],0 |
je no_send2 |
cmp [send_string],byte '/' ; server command |
jne no_send2 |
call process_command |
jmp still |
no_send2: |
jmp still |
socket_commands: |
cmp ah,22 ; connect |
jnz tst3 |
; ignore if status is not "disconnected" |
cmp [status], STATUS_DISCONNECTED |
jnz .nothing |
; start name resolving |
inc [status] ; was STATUS_DISCONNECTED, now STATUS_RESOLVING |
push gai_reqdata |
push ip_list |
push 0 |
push 0 |
push irc_server_name |
call [getaddrinfo_start] |
test eax, eax |
jns getaddrinfo_done |
call update_status |
.nothing: |
ret |
tst3: |
cmp ah,23 ; write userinfo |
jnz tst4 |
; ignore if status is not "connected" |
cmp [status], STATUS_CONNECTED |
jnz .nothing |
; create packet in packetbuf |
mov edi, packetbuf |
mov edx, edi |
mov esi, string0 |
mov ecx, string0l-string0 |
rep movsb |
mov esi, user_real_name+4 |
mov ecx, [esi-4] |
rep movsb |
mov al, 13 |
stosb |
mov al, 10 |
stosb |
mov esi, string1 |
mov ecx, string1l-string1 |
rep movsb |
mov esi, user_nick+4 |
mov ecx, [esi-4] |
rep movsb |
mov al, 13 |
stosb |
mov al, 10 |
stosb |
; send packet |
xchg edx, edi |
sub edx, edi |
mov esi, edi |
mcall 53, 7, [socket] |
.nothing: |
ret |
tst4: |
cmp ah,24 ; close socket |
jz disconnect |
no_24: |
ret |
getaddrinfo_done: |
; The address resolving is done. |
; If eax is zero, address is resolved, otherwise there was some problems. |
test eax, eax |
jz .good |
.disconnect: |
; Change status to "disconnected" and return. |
and [status], 0 |
call update_status |
ret |
.good: |
; We got a list of IP addresses. Try to connect to first of them. |
mov eax, [ip_list] |
mov esi, [eax + addrinfo.ai_addr] |
mov esi, [esi + sockaddr_in.sin_addr] |
push eax |
call [freeaddrinfo] |
mcall 53, 5, 0, 6667, , 1 |
cmp eax, -1 |
jz .disconnect |
; Socket has been opened. Save handle and change status to "connecting". |
mov [socket], eax |
inc [status] ; was STATUS_RESOLVING, now STATUS_CONNECTING |
call update_status |
ret |
process_network_event: |
; values for status: 0, 1, 2, 3 |
mov eax, [status] |
dec eax |
; 0 = STATUS_DISCONNECTED - do nothing |
; (ignore network events if we are disconnected from network) |
js .nothing |
; 1 = STATUS_RESOLVING |
jz .resolving |
; 2 = STATUS_CONNECTING |
dec eax |
jz .connecting |
; 3 = STATUS_CONNECTED |
jmp .connected |
.resolving: |
; We are inside address resolving. Let the network library work. |
push ip_list |
push gai_reqdata |
call [getaddrinfo_process] |
; Negative returned value means that the resolving is not yet finished, |
; and we continue the loop without status change. |
; Zero and positive values are handled by getaddrinfo_done. |
test eax, eax |
jns getaddrinfo_done |
.nothing: |
ret |
.connecting: |
; We are connecting to the server, and socket status has changed. |
mcall 53, 6, [socket] |
; Possible values for status: SYN_SENT=2, SYN_RECEIVED=3, ESTABLISHED=4, CLOSE_WAIT=7 |
; First two mean that we are still connecting, and we must continue wait loop |
; without status change. |
; Last means that server has immediately closed the connection, |
; and status becomes "disconnected". |
cmp eax, 4 |
jb .nothing |
jz .established |
and [status], 0 |
call update_status |
; close socket |
mcall 53, 8 |
ret |
.established: |
; The connection has been established, change status from "connecting" to "connected". |
inc [status] |
call update_status |
; Fall through to .connected, because some data can be already in buffer. |
.connected: |
call read_incoming_data |
; Handle closing socket by the server. |
mcall 53, 6, [socket] |
cmp eax, 4 |
jnz disconnect |
ret |
disconnect: |
; Release all allocated resources. |
; Exact actions depend on current status. |
mov eax, [status] |
dec eax |
; 0 = STATUS_DISCONNECTED - do nothing |
js .nothing |
; 1 = STATUS_RESOLVING |
jz .resolving |
; 2 = STATUS_CONNECTING, 3 = STATUS_CONNECTED |
; In both cases we should close the socket. |
mcall 53, 8, [socket] |
jmp .disconnected |
.resolving: |
; Let the network library handle abort of resolving process. |
push gai_reqdata |
call [getaddrinfo_abort] |
.disconnected: |
; In all cases, set status to "disconnected". |
and [status], 0 |
call update_status |
.nothing: |
ret |
msgbox_notify: |
inc byte [msgbox_running] |
mcall 60,2,[main_PID],0,1 |
ret |
print_channel_list: |
pusha |
mov eax,13 |
mov ebx,415*65536+6*13 |
mov ecx,27*65536+12*10 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,415*65536+27 |
mov ecx,[index_list_1] |
mov edx,channel_list+32 |
newch: |
movzx esi,byte [edx+31] |
and esi,0x1f |
mcall |
add edx,32 |
add ebx,12 |
cmp edx,channel_list+32*10 |
jbe newch |
no_channel_list: |
popa |
ret |
print_user_list: |
pusha |
newtry: |
mov edx,ebp |
imul edx,120*80 |
add edx,120*60+8+I_END |
cmp [edx],byte 1 |
je nonp |
mov edx,ebp |
imul edx,120*80 |
add edx,120*70+I_END |
mov edi,edx |
mov eax,[edx-8] |
mov ebx,[edx-4] |
add ebx,edx |
sub ebx,3 |
inc eax |
dec edx |
newnss: |
inc edx |
dec eax |
jz startuu |
asdf: |
cmp [edx],word ' ' |
jne nodouble |
inc edx |
nodouble: |
cmp [edx],byte ' ' |
je newnss |
inc edx |
cmp edx,ebx |
jbe asdf |
dec dword [edi-8] |
popa |
ret |
startuu: |
cmp [edx],byte ' ' |
jne startpr |
inc edx |
startpr: |
pusha |
mov eax,13 |
mov ebx,415*65536+6*13 |
mov ecx,27*65536+12*10 |
mov edx,0xffffff |
mcall |
popa |
mov eax,4 |
mov ebx,415*65536+27 |
mov ebp,0 |
newuser: |
mov esi,0 |
newusers: |
cmp [edx+esi],byte ' ' |
je do_print |
inc esi |
cmp esi,20 |
jbe newusers |
do_print: |
mov ecx,[index_list_1] |
cmp [edx],byte '@' |
jne no_op |
mov ecx,[index_list_2] |
no_op: |
mcall |
inc ebp |
cmp ebp,10 |
je nonp |
add ebx,12 |
add edx,esi |
inc edx |
cmp [edx],byte ' ' |
jne newuser |
inc edx |
jmp newuser |
nonp: |
popa |
ret |
start_user_list_at dd 0x0 |
recode_to_cp866: |
rep movsb |
ret |
recode_to_cp1251: |
xor eax, eax |
jecxz .nothing |
.loop: |
lodsb |
cmp al,0x80 |
jb @f |
mov al,[cp866_table-0x80+eax] |
@@: stosb |
loop .loop |
.nothing: |
ret |
recode_to_utf8: |
jecxz .nothing |
.loop: |
lodsb |
cmp al, 0x80 |
jb .single_byte |
and eax, 0x7F |
mov ax, [utf8_table+eax*2] |
stosw |
loop .loop |
ret |
.single_byte: |
stosb |
loop .loop |
.nothing: |
ret |
recode: |
mov eax, [encoding] |
jmp [recode_proc+eax*4] |
process_command: |
pusha |
mov eax,[xpos] |
mov [send_string+eax+0],byte 13 |
mov [send_string+eax+1],byte 10 |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov eax,[send_to_channel] |
imul eax,120*80 |
add eax,I_END |
mov [text_start],eax |
cmp [send_string],byte '/' ; server command |
je server_command |
; Ignore data commands when not connected. |
cmp [status], STATUS_CONNECTED |
jnz sdts_ret |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
mov bl,'<' |
call print_character |
mov esi,user_nick+4 |
mov ecx,[user_nick] |
newnp: |
mov bl,[esi] |
call print_character |
inc esi |
loop newnp |
mov bl,'>' |
call print_character |
mov bl,' ' |
call print_character |
mov ecx,[xpos] |
mov esi,send_string |
newcw: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcw |
mov eax,dword [send_to_channel] |
shl eax,5 |
add eax,channel_list |
mov esi,eax |
mov edi,send_string_header+8 |
movzx ecx,byte [eax+31] |
cld |
rep movsb |
mov [edi],word ' :' |
mov esi, send_string_header |
mov ecx,10 |
movzx ebx,byte [eax+31] |
add ecx,ebx |
mov edi, packetbuf |
rep movsb |
mov esi,send_string |
mov ecx,[xpos] |
inc ecx |
call recode |
mov esi, packetbuf |
mov edx, edi |
sub edx, esi |
mcall 53, 7, [socket] |
mov [xpos], 0 |
jmp sdts_ret |
server_command: |
cmp [send_string+1],dword 'anic' |
jne no_set_nick |
mov ecx,[xpos] |
sub ecx,7 |
cmp ecx,user_nick_max |
jb @f |
mov ecx,user_nick_max |
@@: |
mov [user_nick],ecx |
mov esi,send_string+7 |
mov edi,user_nick+4 |
cld |
rep movsb |
pusha |
mov edi,text+70*1+15 |
mov al,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov esi,user_nick+4 |
mov edi,text+70*1+15 |
mov ecx,[esi-4] |
cld |
rep movsb |
mov [xpos],0 |
call draw_window |
popa |
ret |
no_set_nick: |
cmp [send_string+1],dword 'area' |
jne no_set_real_name |
mov ecx,[xpos] |
sub ecx,7 |
cmp ecx,user_real_name_max |
jb @f |
mov ecx,user_real_name_max |
@@: |
mov [user_real_name],ecx |
mov esi,send_string+7 |
mov edi,user_real_name+4 |
cld |
rep movsb |
pusha |
mov edi,text+70*0+15 |
mov al,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov esi,user_real_name+4 |
mov edi,text+70*0+15 |
mov ecx,[esi-4] |
rep movsb |
mov [xpos],0 |
call draw_window |
popa |
ret |
no_set_real_name: |
cmp [send_string+1],dword 'aser' |
jne no_set_server |
mov ecx,[xpos] |
sub ecx,7 |
mov esi,send_string+7 |
mov edi,irc_server_name |
rep movsb |
mov al,0 |
stosb |
pusha |
mov edi,text+70*2+15 |
mov al,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov ecx,[xpos] |
sub ecx,7 |
mov esi,send_string+7 |
mov edi,text+70*2+15 |
rep movsb |
mov [xpos],0 |
call draw_window |
popa |
ret |
no_set_server: |
; All other commands require a connection to the server. |
cmp [status], STATUS_CONNECTED |
jnz sdts_ret |
cmp [send_string+1],dword 'quer' |
jne no_query_create |
mov edi,I_END+120*80 |
mov eax,1 ; create channel window - search for empty slot |
newse2: |
mov ebx,eax |
shl ebx,5 |
cmp dword [channel_list+ebx],dword ' ' |
je free_found2 |
add edi,120*80 |
inc eax |
cmp eax,[max_windows] |
jb newse2 |
free_found2: |
mov edx,send_string+7 |
mov ecx,[xpos] |
sub ecx,7 |
mov [channel_list+ebx+31],cl |
call create_channel_name |
push edi |
push eax |
mov [edi+120*60+8],byte 1 ; query window |
mov al,32 |
mov ecx,120*60 |
cld |
rep stosb |
pop eax |
pop edi |
; eax has the free position |
; mov [thread_screen],edi |
call create_channel_window |
mov [xpos],0 |
popa |
ret |
no_query_create: |
mov esi, send_string+1 |
mov ecx, [xpos] |
inc ecx |
mov edi, packetbuf |
call recode |
mov esi, packetbuf |
mov edx, edi |
sub edx, esi |
mov eax, 53 ; write server command |
mov ebx, 7 |
mov ecx, [socket] |
mcall |
send_done: |
mov [xpos],0 |
cmp [send_string+1],dword 'quit' |
jne no_quit_server |
mov eax,5 |
mov ebx,200 |
mcall |
mov eax, 53 ; close socket |
mov ebx, 8 |
mov ecx, [socket] |
mcall |
mov ecx,[max_windows] |
mov edi,I_END |
newclose: |
mov [edi+120*60+4],byte 1 |
call notify_channel_thread |
add edi,120*80 |
loop newclose |
popa |
ret |
no_quit_server: |
sdts_ret: |
popa |
ret |
get_next_byte: |
; Load next byte from the packet, translating to cp866 if necessary |
; At input esi = pointer to data, edx = limit of data |
; Output is either (translated) byte in al with CF set or CF cleared. |
mov eax, [encoding] |
jmp [get_byte_table+eax*4] |
get_byte_cp866: |
cmp esi, edx |
jae .nothing |
lodsb |
.nothing: |
ret |
get_byte_cp1251: |
cmp esi, edx |
jae .nothing |
lodsb |
cmp al, 0x80 |
jb @f |
and eax, 0x7F |
mov al, [cp1251_table+eax] |
@@: |
stc |
.nothing: |
ret |
get_byte_utf8: |
; UTF8 decoding is slightly complicated. |
; One character can occupy one or more bytes. |
; The boundary in packets theoretically can be anywhere in data, |
; so this procedure keeps internal state between calls and handles |
; one byte at a time, looping until character is read or packet is over. |
; Globally, there are two distinct tasks: decode byte sequence to unicode char |
; and convert this unicode char to our base encoding (that is cp866). |
; 1. Check that there are data. |
cmp esi, edx |
jae .nothing |
; 2. Load byte. |
lodsb |
movzx ecx, al |
; 3. Bytes in an UTF8 sequence can be of any of three types. |
; If most significant bit is cleared, sequence is one byte and usual ASCII char. |
; First byte of a sequence must be 11xxxxxx, other bytes are 10yyyyyy. |
and al, 0xC0 |
jns .single_byte |
jp .first_byte |
; 4. This byte is not first in UTF8 sequence. |
; 4a. Check that the sequence was started. If no, it is invalid byte |
; and we simply ignore it. |
cmp [utf8_bytes_rest], 0 |
jz get_byte_utf8 |
; 4b. Otherwise, it is really next byte and it gives some more bits of char. |
mov eax, [utf8_char] |
shl eax, 6 |
lea eax, [eax+ecx-0x80] |
; 4c. Decrement number of bytes rest in the sequence. |
; If it goes to zero, character is read, so return it. |
dec [utf8_bytes_rest] |
jz .got_char |
mov [utf8_char], eax |
jmp get_byte_utf8 |
; 5. If the byte is first in UTF8 sequence, calculate the number of leading 1s |
; - it equals total number of bytes in the sequence; some other bits rest for |
; leading bits in the character. |
.first_byte: |
mov eax, -1 |
@@: |
inc eax |
add cl, cl |
js @b |
mov [utf8_bytes_rest], eax |
xchg eax, ecx |
inc ecx |
shr al, cl |
mov [utf8_char], eax |
jmp get_byte_utf8 |
; 6. If the byte is ASCII char, it is the character. |
.single_byte: |
xchg eax, ecx |
.got_char: |
; We got the character, now abandon a possible sequence in progress. |
and [utf8_bytes_rest], 0 |
; Now second task. The unicode character is in eax, and now we shall convert it |
; to cp866. |
cmp eax, 0x80 |
jb .done |
; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1 |
cmp eax, 0x401 |
jz .YO |
cmp eax, 0x451 |
jz .yo |
cmp eax, 0x410 |
jb .unrecognized |
cmp eax, 0x440 |
jb .part1 |
cmp eax, 0x450 |
jae .unrecognized |
sub al, (0x40-0xE0) and 0xFF |
ret |
.part1: |
sub al, 0x10-0x80 |
.nothing: |
.done: |
ret |
.unrecognized: |
mov al, '?' |
stc |
ret |
.YO: |
mov al, 0xF0 |
stc |
ret |
.yo: |
mov al, 0xF1 |
stc |
ret |
read_incoming_data: |
pusha |
.packetloop: |
.nextpacket: |
mcall 53, 11, [socket], packetbuf, 1024 |
test eax, eax |
jz .nothing |
mov esi, edx ; esi = pointer to data |
add edx, eax ; edx = limit of data |
.byteloop: |
call get_next_byte |
jnc .nextpacket |
cmp al, 10 |
jne .no_start_command |
mov [cmd], 1 |
.no_start_command: |
cmp al, 13 |
jne .no_end_command |
mov ebx, [cmd] |
mov byte [ebx+command-2], 0 |
call analyze_command |
mov edi, command |
mov ecx, 250 |
xor eax, eax |
rep stosb |
mov [cmd], eax |
mov al, 13 |
.no_end_command: |
mov ebx, [cmd] |
cmp ebx, 512 |
jge @f |
mov [ebx+command-2], al |
inc [cmd] |
@@: |
jmp .byteloop |
.nothing: |
popa |
ret |
create_channel_name: |
pusha |
search_first_letter: |
cmp [edx],byte ' ' |
jne first_letter_found |
inc edx |
jmp search_first_letter |
first_letter_found: |
mov esi,edx |
mov edi,channel_list |
add edi,ebx |
mov ecx,30 |
xor eax,eax |
newcase: |
mov al,[esi] |
cmp eax,'a' |
jb nocdec |
cmp eax,'z' |
jg nocdec |
sub al,97-65 |
nocdec: |
mov [edi],al |
inc esi |
inc edi |
loop newcase |
popa |
ret |
create_channel_window: |
pusha |
mov [cursor_on_off],0 |
; mov [thread_nro],eax |
mov edx,[thread_stack] |
sub edx,8 |
mov [edx],eax |
mov [edx+4],edi |
mov eax,51 |
mov ebx,1 |
mov ecx,channel_thread |
mcall |
mov [edi+120*60+12], eax |
add [thread_stack],0x4000 |
; add [thread_screen],120*80 |
popa |
ret |
print_entry: |
pusha |
mov eax,13 |
mov ebx,8*65536+6*80 |
mov ecx,151*65536+13 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,8*65536+154 |
mov ecx,0x000000 |
mov edx,send_string |
mov esi,[xpos] |
mcall |
popa |
; Fall through to draw_cursor. |
; ret |
draw_cursor: |
pusha |
mov eax,9 |
mov ebx,0xe0000 |
mov ecx,-1 |
mcall |
cmp ax,word [0xe0000+4] |
setnz dl |
movzx edx,dl |
neg edx |
and edx,0xffffff |
; jne no_blink |
; call print_entry |
mov ebx,[xpos] |
imul ebx,6 |
add ebx,8 |
mov cx,bx |
shl ebx,16 |
mov bx,cx |
mov ecx,151*65536+163 |
mov eax,38 |
mcall |
popa |
ret |
; no_blink: |
; |
; mov eax,13 |
; mov ebx,8*65536+6*60 |
; mov ecx,151*65536+13 |
; mov edx,0xffffff |
; mcall |
popa |
ret |
set_channel: |
pusha |
; UPPER / LOWER CASE CHECK |
mov esi,eax |
mov edi,channel_temp |
mov ecx,40 |
xor eax,eax |
newcase2: |
mov al,[esi] |
cmp eax,'#' |
jb newcase_over2 |
cmp eax,'a' |
jb nocdec2 |
cmp eax,'z' |
jg nocdec2 |
sub al,97-65 |
nocdec2: |
mov [edi],al |
inc esi |
inc edi |
loop newcase2 |
newcase_over2: |
sub edi,channel_temp |
mov [channel_temp_length],edi |
mov eax,channel_temp |
mov [text_start],I_END+120*80 |
mov ebx,channel_list+32 |
mov eax,[eax] |
mov edx,[channel_temp_length] |
stcl1: |
cmp dl,[ebx+31] |
jne notfound |
pusha |
xor eax,eax |
xor edx,edx |
mov ecx,0 |
stc4: |
mov dl,[ebx+ecx] |
mov al,[channel_temp+ecx] |
cmp eax,edx |
jne notfound2 |
inc ecx |
cmp ecx,[channel_temp_length] |
jb stc4 |
popa |
jmp found |
notfound2: |
popa |
notfound: |
add [text_start],120*80 |
add ebx,32 |
cmp ebx,channel_list+19*32 |
jb stcl1 |
mov [text_start],I_END |
found: |
popa |
ret |
channel_temp: times 100 db 0 |
channel_temp_length dd 0x0 |
print_nick: |
pusha |
mov eax,command+1 |
mov dl,'!' |
call print_text |
popa |
ret |
analyze_command: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
; mov bl,13 |
; call print_character |
; mov bl,10 |
; call print_character |
; mov ecx,[cmd] |
; sub ecx,2 |
; mov esi,command+0 |
; newcmdc: |
; mov bl,[esi] |
; call print_character |
; inc esi |
; loop newcmdc |
mov edx,I_END |
; call draw_channel_text |
; cmp [cmd],20 |
; jge cmd_len_ok |
; |
; mov [cmd],0 |
; |
; popa |
; ret |
cmd_len_ok: |
cmp [command],dword 'PING' ; ping response |
jne no_ping_responce |
call print_command_to_main |
mov [command],dword 'PONG' |
call print_command_to_main |
mov eax,4 |
mov ebx,100*65536+3 |
mov ecx,0xffffff |
mov edx,command |
mov esi,[cmd] |
mov [command+esi-1],word '**' |
; mcall |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[cmd] |
mov esi,command |
mov word [esi+edx-2], 0x0a0d |
mcall |
popa |
ret |
no_ping_responce: |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov [command],byte '<' |
mov eax,command |
mov ecx,100 |
new_blank: |
cmp [eax],byte ' ' |
je bl_found |
inc eax |
loop new_blank |
mov eax,50 |
bl_found: |
inc eax |
mov [command_position],eax |
mov esi,eax |
mov edi,irc_command |
mov ecx,8 |
cld |
rep movsb |
cmp [irc_command],'PRIV' ; message to channel |
jne no_privmsg |
; compare nick |
mov eax,[command_position] |
add eax,8 |
call compare_to_nick |
cmp [cresult],0 |
jne no_query_msg |
mov eax,command+1 |
no_query_msg: |
call set_channel |
mov ecx,100 ; [cmd] |
mov eax,command+10 |
acl3: |
cmp [eax],byte ':' |
je acl4 |
inc eax |
loop acl3 |
mov eax,10 |
acl4: |
inc eax |
cmp [eax+1],dword 'ACTI' |
jne no_action |
push eax |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov bl,' ' |
call print_character |
pop eax |
add eax,8 |
mov dl,0 |
call print_text |
call notify_channel_thread |
popa |
ret |
no_action: |
push eax |
mov bl,10 |
call print_character |
mov eax,command |
mov dl,'!' |
call print_text |
mov bl,'>' |
call print_character |
mov bl,' ' |
call print_character |
pop eax |
mov dl,0 |
call print_text |
call notify_channel_thread |
popa |
ret |
no_privmsg: |
cmp [irc_command],'PART' ; channel leave |
jne no_part |
; compare nick |
mov eax,command+1 |
call compare_to_nick |
cmp [cresult],0 |
jne no_close_window |
mov eax,[command_position] |
add eax,5 |
call set_channel |
mov edi,[text_start] |
mov [edi+120*60+4],byte 1 |
call notify_channel_thread |
popa |
ret |
no_close_window: |
mov eax,[command_position] |
add eax,5 |
call set_channel |
mov eax,action_header_red |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
mov cl,' ' |
call print_text |
mov eax,has_left_channel |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,' ' |
call print_text |
call notify_channel_thread |
popa |
ret |
no_part: |
cmp [irc_command],'JOIN' ; channel join |
jne no_join |
; compare nick |
mov eax,command+1 |
call compare_to_nick |
cmp [cresult],0 |
jne no_new_window |
mov edi,I_END+120*80 |
mov eax,1 ; create channel window - search for empty slot |
newse: |
mov ebx,eax |
shl ebx,5 |
cmp dword [channel_list+ebx],dword ' ' |
je free_found |
add edi,120*80 |
inc eax |
cmp eax,[max_windows] |
jb newse |
free_found: |
mov edx,[command_position] |
add edx,6 |
push eax |
push edx |
mov ecx,0 |
finde: |
inc ecx |
inc edx |
movzx eax,byte [edx] |
cmp eax,'#' |
jge finde |
mov [channel_list+ebx+31],cl |
pop edx |
pop eax |
call create_channel_name |
push edi |
push eax |
mov [edi+120*60+8],byte 0 ; channel window |
mov al,32 |
mov ecx,120*60 |
cld |
rep stosb |
pop eax |
pop edi |
; eax has the free position |
; mov [thread_screen],edi |
call create_channel_window |
no_new_window: |
mov eax,[command_position] |
add eax,6 |
call set_channel |
mov eax,action_header_blue |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
mov cl,' ' |
call print_text |
mov eax,joins_channel |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,6 |
mov dl,0 |
call print_text |
call notify_channel_thread |
popa |
ret |
no_join: |
cmp [irc_command],'NICK' ; nick change |
jne no_nick_change |
add [command_position], 6 |
; test for change of my nick |
mov esi, command+1 |
mov edi, user_nick+4 |
mov ecx, [edi-4] |
repz cmpsb |
jnz .notmy |
cmp byte [esi], '!' |
jnz .notmy |
; yes, this is my nick, set to new |
mov esi, [command_position] |
or ecx, -1 |
mov edi, esi |
xor eax, eax |
repnz scasb |
not ecx |
dec ecx |
cmp ecx, user_nick_max |
jb @f |
mov ecx, user_nick_max |
@@: |
mov edi, user_nick+4 |
mov [edi-4], ecx |
rep movsb |
mov edi, text+70*1+15 |
mov al, ' ' |
mov cl, 15 |
push edi |
rep stosb |
pop edi |
mov esi, user_nick+4 |
mov ecx, [esi-4] |
cmp ecx, 15 |
jb @f |
mov ecx, 15 |
@@: |
rep movsb |
mov [xpos], 0 |
call draw_window |
.notmy: |
; replace nick in all lists of users |
mov ebx, I_END + 120*70 |
.channels: |
mov esi, ebx |
mov edx, [esi-4] |
add edx, esi |
.nicks: |
mov edi, command+1 |
cmp byte [esi], '@' |
jnz @f |
inc esi |
@@: |
cmp esi, edx |
jae .srcdone |
lodsb |
cmp al, ' ' |
jz .srcdone |
scasb |
jz @b |
@@: |
cmp esi, edx |
jae .nextchannel |
lodsb |
cmp al, ' ' |
jnz @b |
.nextnick: |
cmp esi, edx |
jae .nextchannel |
lodsb |
cmp al, ' ' |
jz .nextnick |
dec esi |
jmp .nicks |
.srcdone: |
cmp byte [edi], '!' |
jnz .nextnick |
; here we have esi -> end of nick which must be replaced to [command_position]+6 |
lea edx, [edi-command-1] |
sub esi, edx |
or ecx, -1 |
xor eax, eax |
mov edi, [command_position] |
repnz scasb |
not ecx |
dec ecx |
push ecx |
cmp ecx, edx |
jb .decrease |
jz .copy |
.increase: |
; new nick is longer than the old |
push esi |
lea edi, [ebx+120*10] |
lea esi, [edi+edx] |
sub esi, ecx |
mov ecx, esi |
sub ecx, [esp] |
dec esi |
dec edi |
std |
rep movsb |
cld |
pop esi |
jmp .copy |
.decrease: |
; new nick is shorter than the old |
push esi |
lea edi, [esi+ecx] |
add esi, edx |
lea ecx, [ebx+120*10] |
sub ecx, edi |
rep movsb |
pop esi |
.copy: |
; copy nick |
mov edi, esi |
dec edi |
mov esi, [command_position] |
pop ecx |
sub edx, ecx |
sub [ebx-4], edx |
rep movsb |
mov al, ' ' |
stosb |
.nextchannel: |
add ebx, 120*80 |
cmp ebx, I_END + 120*70 + 120*80*19 |
jb .channels |
mov [text_start],I_END |
add [text_start],120*80 |
new_all_channels3: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,is_now_known_as |
mov dl,0 |
call print_text |
mov eax,[command_position] |
mov dl,0 |
call print_text |
call notify_channel_thread |
add [text_start],120*80 |
cmp [text_start],I_END+120*80*20 |
jb new_all_channels3 |
popa |
ret |
no_nick_change: |
cmp [irc_command],'KICK' ; kick |
jne no_kick |
mov [text_start],I_END |
add [text_start],120*80 |
mov eax,[command_position] |
add eax,5 |
call set_channel |
; new_all_channels4: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,kicked |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,0 |
call print_text |
call notify_channel_thread |
; add [text_start],120*80 |
; cmp [text_start],I_END+120*80*20 |
; jb new_all_channels4 |
popa |
ret |
no_kick: |
cmp [irc_command],'QUIT' ; irc quit |
jne no_quit |
mov [text_start],I_END |
add [text_start],120*80 |
new_all_channels2: |
mov eax,action_header_red |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,has_quit_irc |
mov dl,0 |
call print_text |
call notify_channel_thread |
add [text_start],120*80 |
cmp [text_start],I_END+120*80*20 |
jb new_all_channels2 |
popa |
ret |
no_quit: |
cmp [irc_command],dword 'MODE' ; channel mode change |
jne no_mode |
mov [text_start],I_END |
add [text_start],120*80 |
mov eax,[command_position] |
add eax,5 |
call set_channel |
new_all_channels: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
call print_nick |
mov eax,sets_mode |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,0 |
call print_text |
call notify_channel_thread |
; add [text_start],120*80 |
; cmp [text_start],I_END+120*80*20 |
; jb new_all_channels |
popa |
ret |
no_mode: |
cmp [irc_command],dword '353 ' ; channel user names |
jne no_user_list |
mov eax,[command_position] |
finde2: |
inc eax |
cmp [eax],byte '#' |
jne finde2 |
call set_channel |
finde3: |
inc eax |
cmp [eax],byte ':' |
jne finde3 |
pusha |
cmp [user_list_pos],0 |
jne no_clear_user_list |
mov edi,[text_start] |
add edi,120*70 |
mov [edi-8],dword 0 |
mov [edi-4],dword 0 |
mov al,32 |
mov ecx,1200 |
cld |
rep stosb |
no_clear_user_list: |
popa |
push eax |
mov esi,eax |
inc esi |
mov edi,[text_start] |
add edi,120*70 |
add edi,[user_list_pos] |
mov edx,edi |
mov ecx,command |
add ecx,[cmd] |
sub ecx,[esp] |
sub ecx,3 |
and ecx,0xfff |
cld |
rep movsb |
pop eax |
mov ebx,command |
add ebx,[cmd] |
sub ebx,eax |
sub ebx,2 |
mov [edx+ebx-1],dword ' ' |
add [user_list_pos],ebx |
mov eax,[user_list_pos] |
mov ebx,[text_start] |
add ebx,120*70 |
mov [ebx-4],eax |
call notify_channel_thread |
popa |
ret |
user_list_pos dd 0x0 |
no_user_list: |
cmp [irc_command],dword '366 ' ; channel user names end |
jne no_user_list_end |
mov [user_list_pos],0 |
popa |
ret |
no_user_list_end: |
mov [command],byte '-' |
call print_command_to_main |
popa |
ret |
cresult db 0 |
compare_to_nick: |
; input : eax = start of compare |
; output : [cresult] = 0 if match, [cresult]=1 if no match |
pusha |
mov esi,eax |
mov edi,0 |
new_nick_compare: |
mov bl,byte [esi] |
mov cl,byte [user_nick+4+edi] |
cmp bl,cl |
jne nonickm |
add esi,1 |
add edi,1 |
cmp edi,[user_nick] |
jb new_nick_compare |
movzx eax,byte [esi] |
cmp eax,40 |
jge nonickm |
popa |
mov [cresult],0 |
ret |
nonickm: |
popa |
mov [cresult],1 |
ret |
print_command_to_main: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command |
newcmdc2: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc2 |
mov edx,I_END |
call draw_channel_text |
popa |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
cp1251_table: |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; 8 |
db '?','?','?','?','?',$F9,'?','?' , '?','?','?','?','?','?','?','?' ; 9 |
db '?',$F6,$F7,'?',$FD,'?','?','?' , $F0,'?',$F2,'?','?','?','?',$F4 ; A |
db $F8,'?','?','?','?','?','?',$FA , $F1,$FC,$F3,'?','?','?','?',$F5 ; B |
db $80,$81,$82,$83,$84,$85,$86,$87 , $88,$89,$8A,$8B,$8C,$8D,$8E,$8F ; C |
db $90,$91,$92,$93,$94,$95,$96,$97 , $98,$99,$9A,$9B,$9C,$9D,$9E,$9F ; D |
db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E |
db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F |
; 0 1 2 3 4 5 6 7 8 9 A B C D E F |
utf8_table: |
times 80h dw 0x98C3 ; default placeholder |
; 0x80-0xAF -> 0x90D0-0xBFD0 |
repeat 0x30 |
store byte 0xD0 at utf8_table+2*(%-1) |
store byte 0x90+%-1 at utf8_table+2*%-1 |
end repeat |
; 0xE0-0xEF -> 0x80D1-0x8FD1 |
repeat 0x10 |
store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1) |
store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1 |
end repeat |
; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1 |
store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80) |
cp866_table: |
db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8 |
db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9 |
db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; A |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; B |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; C |
db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; D |
db $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7 , $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF ; E |
db $A8,$B8,$AA,$BA,$AF,$BF,$A1,$A2 , $B0,$95,$B7,'?',$B9,$A4,'?','?' ; F |
; 0 1 2 3 4 5 6 7 8 9 A B C D E F |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
notify_channel_thread: |
pusha |
mov eax, [text_start] |
mov ecx, [eax+120*60+12] |
mcall 60, 2, , 0, 1 |
popa |
ret |
draw_data: |
pusha |
and ebx,0xff |
add eax,[text_start] |
mov [eax],bl |
popa |
ret |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
xor eax,eax ; draw window |
mov ebx,5*65536+499 |
mov ecx,5*65536+381 |
mov edx,[wcolor] |
add edx,0x14ffffff |
mov edi,title |
mcall |
mov eax,8 ; button: change encoding |
mov ebx,(ENCODING_X-2)*65536+38 |
mov ecx,(ENCODING_Y-2)*65536+12 |
mov edx,21 |
mov esi,[main_button] |
mcall |
; mov eax,8 ; button: open socket |
mov ebx,43*65536+22 |
mov ecx,241*65536+10 |
; mov edx,22 |
inc edx |
mcall |
;mov eax,8 ; button: send userinfo |
mov ebx,180*65536+22 |
mov ecx,241*65536+10 |
; mov edx,23 |
inc edx |
mcall |
;mov eax,8 ; button: close socket |
mov ebx,317*65536+22 |
mov ecx,241*65536+10 |
; mov edx,24 |
inc edx |
mcall |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,148*65536+148 |
mov edx,[main_line] |
mcall |
add ecx,1*65536+1 |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,166*65536+166 |
mcall |
add ecx,1*65536+1 |
mov eax,38 ; line |
mov ebx,410*65536+410 |
mov ecx,22*65536+148 |
mcall |
add ebx,1*65536+1 |
mov ebx,25*65536+183 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
mcall |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_channel_text |
call print_entry |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
update_status: |
pusha |
mov esi, [status] |
mov edi, text + 7*70 + 22 |
mov ecx, status_text_len |
push ecx |
imul esi, ecx |
add esi, status_text |
mov edx, edi |
rep movsb |
pop esi |
mcall 4, STATUS_X*65536+STATUS_Y, 0x40000000, , , 0xFFFFFF |
popa |
ret |
update_encoding: |
pusha |
mov edx, 21 |
mcall 8 ; delete button |
mov esi, [main_button] |
mcall , <(ENCODING_X-2),38>, <(ENCODING_Y-2),12> ; recreate it |
mov esi, [encoding] |
mov edi, text + 3*70 + 15 |
mov ecx, encoding_text_len |
push ecx |
imul esi, ecx |
add esi, encoding_text |
mov edx, edi |
rep movsb |
pop esi |
mcall 4, ENCODING_X*65536+ENCODING_Y, 0 |
popa |
ret |
main_line dd 0x000000 |
main_button dd 0x6565cc |
if lang eq ru |
text: |
db ' è¥ ¨¬ï : KolibriOS User - ¬¥ï©â¥ â ª: /areal Jill User ' |
db ' ¨ª : kolibri_user - ¬¥ï©â¥ â ª: /anick Jill ' |
db ' ¥à¢¥à : freenode.net - ¬¥ï©â¥ â ª: /aserv irc.by ' |
db ' ®¤¨à®¢ª : UTF-8 ' |
db ' ' |
db ' 1) Connect 2) Send userinfo 3) Disconnect ' |
db ' ' |
db ' â âãá ᮥ¤¨¥¨ï: ¥ ᮥ¤¨¥® ' |
db ' ' |
db ' ®¬ ¤ë, ¤®áâã¯ë¥ ¯®á«¥ ãáâ ®¢ª¨ ᮥ¤¨¥¨ï: ' |
db ' ' |
db ' /join #ChannelName - ¯à¨¬¥à: /join #kolibrios ' |
db ' /part #ChannelName - ¯à¨¬¥à: /part #windows ' |
db ' /query Nickname - ¯à¨¬¥à: /query Mary ' |
db ' /quit - ®ª¨ãâì á¥à¢¥à ¨ § ªàëâì ᮪¥â ' |
db 'x' ; <- END MARKER, DONT DELETE |
status_text: |
db '¥ ᮥ¤¨¥® ' |
db '¯®«ãç î ¨¬ï á¥à¢¥à ... ' |
db 'ᮥ¤¨¥¨¥... ' |
db 'ᮥ¤¨¥® ' |
status_text_len = 24 |
encoding_text: |
db 'CP866 ' |
db 'CP1251' |
db 'UTF-8 ' |
encoding_text_len = 6 |
else |
text: |
db ' Real name : KolibriOS User - change with eg /areal Jill User ' |
db ' Nick : kolibri_user - change with eg /anick Jill ' |
db ' Server : freenode.net - change with eg /aserv irc.by ' |
db ' Encoding : UTF-8 ' |
db ' ' |
db ' 1) Connect 2) Send userinfo 3) Disconnect ' |
db ' ' |
db ' Connection status: disconnected ' |
db ' ' |
db ' Commands after established connection: ' |
db ' ' |
db ' /join #ChannelName - eg /join #kolibrios ' |
db ' /part #ChannelName - eg /part #windows ' |
db ' /query Nickname - eg /query Mary ' |
db ' /quit - Quit server and Close socket ' |
db 'x' ; <- END MARKER, DONT DELETE |
status_text: |
db 'disconnected ' |
db 'resolving server name...' |
db 'connecting... ' |
db 'connected ' |
status_text_len = 24 |
encoding_text: |
db 'CP866 ' |
db 'CP1251' |
db 'UTF-8 ' |
encoding_text_len = 6 |
end if |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; CHANNEL THREADS |
; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
channel_thread: |
; mov ebp,[thread_nro] |
pop ebp |
pop edx |
mov eax,ebp |
shl eax,14 |
add eax,0x80000 |
mov esp,eax |
; mov edi,ebp ; clear thread memory |
; imul edi,120*80 |
; add edi,I_END |
; mov ecx,120*80 |
; mov al,32 |
; cld |
; rep stosb |
; Create IPC buffer in the stack. |
push eax |
push eax |
push eax |
push 8 |
push 0 |
mov ecx, esp |
push edx |
mcall 60, 1, , 20 |
pop edx |
mcall 40, 1100111b |
; mov edx,[thread_screen] |
thread_redraw: |
call thread_draw_window |
call draw_channel_text |
call print_user_list |
call print_entry |
w_t: |
mov esi,ebp |
imul esi,120*80 |
add esi,I_END |
cmp [esi+120*60+4],byte 1 |
jne no_channel_leave |
mov [esi+120*60+4],byte 0 |
mov edi,ebp |
shl edi,5 |
mov dword [channel_list+edi],dword ' ' |
mov byte [channel_list+edi+31],byte 1 |
mov eax,-1 |
mcall |
no_channel_leave: |
mcall 10 |
dec eax |
jz thread_redraw |
dec eax |
jz thread_key |
dec eax |
jz thread_end |
cmp al,4 |
jz thread_ipc |
call check_mouse |
jmp w_t |
thread_end: |
mov eax,17 |
mcall |
mov eax,ebp |
imul eax,120*80 |
add eax,I_END |
cmp [eax+120*60+8],byte 0 ; channel window |
je not_close |
mov eax,ebp |
shl eax,5 |
add eax,channel_list |
mov [eax],dword ' ' |
mov [eax+31],byte 1 |
mov eax,-1 |
mcall |
not_close: |
mov [text_start],eax |
mov eax,nocl |
newcc: |
mov bl,[eax] |
call print_character |
inc eax |
cmp [eax],byte 0 |
jne newcc |
call draw_channel_text |
jmp w_t |
nocl: db 13,10,'To exit channel, use PART or QUIT command.',0 |
thread_ipc: |
mov byte [esp+4], 8 ; erase message from IPC buffer |
no_end: |
cmp [edx+120*60],byte 1 |
jne no_update |
mov [edx+120*60],byte 0 |
call draw_channel_text |
no_update: |
call print_user_list |
nopri2: |
jmp w_t |
check_mouse: |
pusha |
mov eax,37 |
mov ebx,1 |
mcall |
mov ebx,eax |
shr eax,16 |
and ebx,0xffff |
cmp eax,420 |
jb no_mouse |
cmp eax,494 |
jg no_mouse |
cmp ebx,145 |
jg no_mouse |
cmp ebx,23 |
jb no_mouse |
cmp ebx,100 |
jb no_plus |
mov eax,ebp |
imul eax,120*80 |
add eax,120*70+I_END |
inc dword [eax-8] |
call print_user_list |
mov eax,5 |
mov ebx,8 |
mcall |
jmp no_mouse |
no_plus: |
cmp ebx,80 |
jg no_mouse |
mov eax,ebp |
imul eax,120*80 |
add eax,120*70+I_END |
cmp dword [eax-8],dword 0 |
je no_mouse |
dec dword [eax-8] |
call print_user_list |
mov eax,5 |
mov ebx,8 |
mcall |
no_minus: |
no_mouse: |
popa |
ret |
thread_key: |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,8 |
jne no_bks |
cmp [xpos],0 |
je w_t |
dec [xpos] |
call print_entry |
jmp w_t |
no_bks: |
cmp eax,20 |
jbe no_character |
mov ebx,[xpos] |
mov [send_string+ebx],al |
inc [xpos] |
cmp [xpos],80 |
jb xpok |
mov [xpos],79 |
xpok: |
call print_entry |
jmp w_t |
no_character: |
cmp eax,13 |
jne no_send |
cmp [xpos],0 |
je no_send |
mov dword [send_to_channel],ebp |
pusha |
mcall 60,2,[main_PID],0,1 |
wait_for_sending: |
mov eax,5 |
mov ebx,1 |
mcall |
cmp dword [ipcbuf+4],8 |
jne wait_for_sending |
popa |
call draw_channel_text |
call print_entry |
jmp w_t |
no_send: |
jmp w_t |
draw_channel_text: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,12 |
mov esi,[rxs] |
dct: |
pusha |
mov cx,bx |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
mcall |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
cmp [edx],word '* ' |
jne no_red |
mov ecx,0x0000ff |
no_red: |
cmp [edx],word '**' |
jne no_light_blue |
cmp [edx+2],byte '*' |
jne no_light_blue |
mov ecx,0x0000ff |
no_light_blue: |
cmp [edx],byte '#' |
jne no_blue |
mov ecx,0x0000ff |
no_blue: |
mcall |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
thread_draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
mov ebx,ebp ; draw window |
shl ebx,16+4 |
xor eax,eax |
mov ecx,ebx |
mov bx,499 |
mov cx,170 |
mov edx,[wcolor] |
add edx,0x03ffffff |
mov esi,0x80555599 |
mov edi,0x00ffffff |
mcall |
mov eax,ebp ; label |
add eax,48 |
mov [labelc+14],al |
mov eax,ebp |
shl eax,5 |
add eax,channel_list |
mov esi,eax |
mov edi,labelc+17 |
movzx ecx,byte [eax+31] |
cld |
rep movsb |
mov esi,17 ; print label |
movzx ebx,byte [eax+31] |
add esi,ebx |
mov eax,4 |
mov ebx,9*65536+8 |
mov ecx,0x00ffffff |
mov edx,labelc |
mcall |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,148*65536+148 |
mov edx,[channel_line_sun] |
mcall |
add ecx,1*65536+1 |
mov edx,[channel_line_shadow] |
mcall |
;mov eax,38 ; line |
mov ebx,410*65536+410 |
mov ecx,22*65536+148 |
mov edx,[channel_line_sun] |
mcall |
add ebx,1*65536+1 |
mov edx,[channel_line_shadow] |
mcall |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
; DATA AREA |
socket dd 0x0 |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
channel_line_sun dd 0x9999ff |
channel_line_shadow dd 0x666699 |
cursor_on_off dd 0x0 |
max_windows dd 20 |
thread_stack dd 0x9fff0 |
;thread_nro dd 1 |
;thread_screen dd I_END+120*80*1 |
action_header_blue db 10,'*** ',0 |
action_header_red db 10,'*** ',0 |
action_header_short db 10,'* ',0 |
has_left_channel db ' has left ',0 |
joins_channel db ' has joined ',0 |
is_now_known_as db ' is now known as ',0 |
has_quit_irc db ' has quit IRC',0 |
sets_mode db ' sets mode ',0 |
kicked db ' kicked from ',0 |
index_list_1 dd 0x0000bb |
index_list_2 dd 0x0000ff |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
irc_data dd 0x0 |
print db 0x0 |
cmd dd 0x0 |
rxs dd 66 |
res: db 0,0 |
command: times 600 db 0x0 |
nick dd 0,0,0 |
irc_command dd 0,0 |
command_position dd 0x0 |
counter dd 0 |
send_to_server db 0 |
channel_list: times 32*20 db 32 |
send_to_channel dd 0x0 |
send_string_header: db 'privmsg #eax :' |
times 100 db 0x0 |
send_string: times 100 db 0x0 |
xpos dd 0 |
string0: db 'USER guest ser1 ser2 :' |
string0l: |
string1: db 'nick ' |
string1l: |
attribute dd 0 |
scroll dd 1 |
dd 12 |
numtext db ' ' |
wcolor dd 0x000000 |
labelc db 'AIRC - WINDOW X: #xxx ' |
title db 'IRC client ',version,0 |
ipcbuf: |
dd 0 |
dd 8 |
dd ? |
dd ? |
db ? |
.size = $ |
align 4 |
@IMPORT: |
library network, 'network.obj', msgbox, 'msgbox.obj' |
import network, \ |
getaddrinfo_start, 'getaddrinfo_start', \ |
getaddrinfo_process, 'getaddrinfo_process', \ |
getaddrinfo_abort, 'getaddrinfo_abort', \ |
freeaddrinfo, 'freeaddrinfo' |
import msgbox, mb_create, 'mb_create', mb_setfunctions, 'mb_setfunctions' |
msgbox_running db ? ; must be the byte before msgbox_struct |
; look to the handler of button 21 |
msgbox_struct: |
.default: |
dw ? ; default button, will be filled with current encoding |
db 'Encoding',0 |
db 'Select encoding for all messages:',0 |
db 'CP866',0 |
db 'CP1251',0 |
db 'UTF-8',0 |
db 0 |
align 4 |
status dd STATUS_DISCONNECTED |
encoding dd UTF8 |
recode_proc dd recode_to_cp866, recode_to_cp1251, recode_to_utf8 |
get_byte_table dd get_byte_cp866, get_byte_cp1251, get_byte_utf8 |
msgbox_func_array: |
times 3 dd msgbox_notify |
initialized_size: |
main_PID dd ? ; identifier of main thread |
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence |
utf8_char dd ? ; first bits of current UTF8 character |
gai_reqdata rb 32 ; buffer for getaddrinfo_start/process |
ip_list dd ? ; will be filled as pointer to addrinfo list |
irc_server_name rb 256 ; buffer for irc_server_name |
packetbuf rb 1024 ; buffer for packets to server |
mb_stack rb 1024 ; stack for messagebox thread |
;; |
;; Channel data at I_END |
;; |
;; 120*80 * channel window (1+) |
;; |
;; At Size |
;; |
;; 00 , 120*60 window text 120 characters per row |
;; 120*60 , 1 text is updated |
;; 120*60+4 , 1 close yourself |
;; 120*60+8 , 1 0 = channel window : 1 = private chat |
;; 120*60+12 , 4 identifier of the thread |
;; 120*61 , 256 channel name |
;; 120*61+254 , 254 channel entry text from user |
;; 120*61+255 , 1 length of entry text |
;; 120*69+248 , 4 display names from n:th name |
;; 120*69+252 , 4 length of names string |
;; 120*70 , 1200 names separated with space |
;; |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/airc/trunk/eth.inc |
---|
0,0 → 1,670 |
; |
; ETH.INC |
; |
; made by hidnplayr (hidnplayr@gmail.com) for KolibriOS and DEX4U |
; |
; The given code before every macro is only a simple example |
; |
; Change the OS value to DEX4U or MEOS |
; |
; HISTORY |
; |
; v1.0: 18 august 2006 |
; |
MEOS equ 1 ; Dont change these ! |
DEX4U equ 2 ; |
OS equ MEOS ; Change these instead ;) |
TIMEOUT equ 60 ; timeout for DNS request |
BUFFER equ 512 ; Buffer size for DNS |
macro int1 { |
if OS eq MEOS |
mcall |
else if OS eq DEX4U |
int 0x52 |
end if |
} |
macro int2 { |
if OS eq MEOS |
mcall |
else if OS eq DEX4U |
int 0x53 |
end if |
} |
macro mov arg1,arg2 { |
if arg1 eq arg2 |
else |
mov arg1,arg2 |
end if |
} |
; eth.get_IP eax |
; |
; gets the current IP that is defined in Stack (return in eax in this example) |
macro eth.get_IP IP { |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,1 |
int1 |
mov IP ,eax |
} |
; eth.get_GATEWAY eax |
; |
; gets the current GATEWAY that is defined in Stack (return in eax in this example) |
macro eth.get_GATEWAY GATEWAY { |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,9 |
int1 |
move GATEWAY ,eax |
} |
; eth.get_SUBNET eax |
; |
; gets the current SUBNET that is defined in Stack (return in eax in this example) |
macro eth.get_SUBNET SUBNET { |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,10 |
int1 |
mov SUBNET ,eax |
} |
; eth.get_DNS eax |
; |
; gets the current DNS that is defined in Stack (return in eax in this example) |
macro eth.get_DNS DNS { |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,13 |
int1 |
mov DNS ,eax |
} |
; eth.set_IP eax |
; |
; set a new IP in stack (input in eax in this example) |
macro eth.set_IP IP { |
mov ecx,IP |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,3 |
int1 |
} |
; eth.set_GATEWAY eax |
; |
; set a new GATEWAY in stack (input in eax in this example) |
macro eth.set_GATEWAY GATEWAY { |
mov ecx,GATEWAY |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,11 |
int1 |
} |
; eth.set_SUBNET eax |
; |
; set a new SUBNET in stack (input in eax in this example) |
macro eth.set_SUBNET SUBNET { |
mov ecx,SUBNET |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,12 |
int1 |
} |
; eth.set_DNS eax |
; |
; set a new DNS in stack (input in eax in this example) |
macro eth.set_DNS DNS { |
mov ecx,DNS |
if OS eq MEOS |
mov eax,52 |
end if |
mov ebx,14 |
int1 |
} |
; eth.open eax,80,ebx,[socket] |
; |
; open a socket on local port in eax to port 80 on server on ebx |
; the socketnumber will be returned in [socket] (dword) |
macro eth.open local,remote,ip,socket { |
mov ecx, local |
mov edx, remote |
mov esi, ip |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 0 |
int2 |
mov socket,eax |
} |
; eth.close [socket] |
; |
; closes socket on socketnumber [socket] |
macro eth.close socket { |
mov ecx, socket |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 1 |
int2 |
} |
; eth.poll [socket],eax |
; |
; polls [socket] for data |
; eax = 0 when there is data |
macro eth.poll socket,result { |
mov ecx, socket |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 2 |
int2 |
mov result, eax |
} |
; eth.read_byte [socket], bl |
; |
; reads a byte from the socket and returns in bl |
macro eth.read_byte socket, result { |
mov ecx, socket |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 3 |
int2 |
mov result,bl |
} |
; eth.write [socket],12,msg |
; msg db 'hello world!' |
; |
; send message msg to socket |
macro eth.write socket,length,msg { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 4 |
int2 |
} |
; eth.open_tcp 80,80,eax,0,[socket] |
; |
; opens a tcp socket on port 80 to port 80 on IP eax with passive open |
; returns socket number in eax |
macro eth.open_tcp local,remote,ip,passive,socket { |
pusha |
mov ecx, local |
mov edx, remote |
mov esi, ip |
mov edi, passive ; 0 = PASSIVE open |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 5 |
int2 |
popa |
mov socket,eax |
} |
; eth.socket_status [socket],eax |
; |
; returns socket status in eax |
macro eth.socket_status socket,result { |
mov ecx, socket |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 6 |
int2 |
mov result,eax |
} |
; eth.write_tcp [socket],12,msg |
; |
; msg db 'hello world!' |
; |
; send message to TCP socket |
macro eth.write_tcp socket,length,msg { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 7 |
int2 |
} |
; eth.close_tcp [socket] |
; |
; closes tcp socket [socket] |
macro eth.close_tcp socket { |
mov ecx, socket |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 8 |
int2 |
} |
; eth.check_port 165,eax |
; |
; checks if port 165 is used |
; return is 0 when port is free |
macro eth.check_port port,result { |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 9 |
mov ecx, port |
int2 |
mov result,eax |
} |
; eth.status eax |
; |
; returns socket status in eax |
macro eth.status status { |
if OS eq MEOS |
mov eax,53 |
end if |
mov ebx, 255 |
mov ecx, 6 |
int2 |
mov status,eax |
} |
; eth.search 165,edx |
; |
; searches a free local port starting from 166 (165 + 1 !) |
; returns in edx |
macro eth.search_port port,result { |
mov edx,port |
@@: |
inc edx |
eth.check_port edx,eax |
cmp eax,0 |
je @r |
mov result,edx |
} |
; eth.read_data [socket],buffer,512 |
; buffer rb 512 |
; socket dd ? |
; |
; reads data from socket into a buffer, stops when there is no more data or buffer is full. |
macro eth.read_data socket,dest,endptr,bufferl { |
mov eax, dest |
mov endptr, eax |
; we have data - this will be the response |
@@: |
mov eax,endptr |
cmp eax,bufferl |
jg @f |
mov eax, 53 |
mov ebx, 3 |
mov ecx, socket |
mcall ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, endptr |
mov [eax], bl |
inc dword endptr |
mov eax, 53 |
mov ebx, 2 |
mov ecx, socket |
mcall ; any more data? |
cmp eax, 0 |
jne @r ; yes, so get it |
@@: |
} |
; eth.wait_for_data [socket],60,abort |
; eth.read_data .... |
; abort: |
; |
; Waits for data with timeout |
macro eth.wait_for_data socket,TIMEOUT,abort { |
mov edx,TIMEOUT |
@@: |
eth.poll socket,eax |
cmp eax,0 |
jne @f |
dec edx |
jz abort |
if OS eq MEOS |
mov eax,5 ; wait here for event |
mov ebx,100 |
mcall |
else if OS eq DEX4U |
mov ax,18 |
call [SetDelay] |
call dword[stack_handler] |
end if |
jmp @r |
@@: |
} |
; The function 'resolve' resolves the address in edx and puts the resulting IP in eax. |
; When the input is an IP-adress, the function will output this IP in eax. |
; If something goes wrong, the result in eax should be 0 |
; |
; example: |
; |
; resolve query1,IP |
; resolve '192.168.0.1',IP |
; resolve query2,IP |
; |
; query1 db 'www.google.com',0 |
; query2 db '49.78.84.45',0 |
; IP dd ? |
macro resolve query,result { |
if query eqtype 0 |
mov edx,query |
else |
local ..string, ..label |
jmp ..label |
..string db query,0 |
..label: |
mov edx,..string |
end if |
call __resolve |
mov result,eax |
} |
if used __resolve |
__resolve: |
;DEBUGF 1,'Resolving started\n' |
; This code validates if the query is an IP containing 4 numbers and 3 dots |
push edx ; push edx (query address) onto stack |
xor al, al ; make al (dot count) zero |
@@: |
cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP |
jl no_IP ; |
cmp byte[edx],'9' ; |
jg no_IP ; |
inc edx ; the byte was a number, so lets check the next byte |
cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) |
jz @f ; jump to next @@ then |
cmp byte[edx],'.' ; is this byte a dot? |
jne @r ; if not, jump to previous @@ |
inc al ; the byte was a dot so increment al(dot count) |
inc edx ; next byte |
jmp @r ; lets check for numbers again (jump to previous @@) |
@@: ; we reach this when end of query reached |
cmp al,3 ; check if there where 3 dots |
jnz no_IP ; if not, jump to no_IP (this is where the DNS will take over) |
; The following code should convert this IP into a dword and output it in eax |
pop esi ; edx (query address) was pushed onto stack and is now popped in esi |
xor edx, edx ; result |
xor eax, eax ; current character |
xor ebx, ebx ; current byte |
.outer_loop: |
shl edx, 8 |
add edx, ebx |
xor ebx, ebx |
.inner_loop: |
lodsb |
test eax, eax |
jz .finish |
cmp al, '.' |
jz .outer_loop |
sub eax, '0' |
imul ebx, 10 |
add ebx, eax |
jmp .inner_loop |
.finish: |
shl edx, 8 |
add edx, ebx |
bswap edx |
mov eax, edx |
;DEBUGF 1,'The query was an IP: %x.%x.%x.%x\n',dh,dl,al,ah |
ret |
no_IP: |
pop edx |
; The query is not an IP address, we will send the query to a DNS server and hope for answer ;) |
;DEBUGF 1,'The query is no ip, Building request string from:%u\n',edx |
; Build the request string |
mov eax, 0x00010100 |
mov [dnsMsg], eax |
mov eax, 0x00000100 |
mov [dnsMsg+4], eax |
mov eax, 0x00000000 |
mov [dnsMsg+8], eax |
; domain name goes in at dnsMsg+12 |
mov esi, dnsMsg + 12 ; location of label length |
mov edi, dnsMsg + 13 ; label start |
mov ecx, 12 ; total string length so far |
td002: |
mov [esi], byte 0 |
inc ecx |
td0021: |
mov al, [edx] |
cmp al, 0 |
je td001 ; we have finished the string translation |
cmp al, '.' |
je td004 ; we have finished the label |
inc byte [esi] |
inc ecx |
mov [edi], al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi, edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi], byte 0 |
inc ecx |
inc edi |
mov [edi], dword 0x01000100 |
add ecx, 4 |
mov [dnsMsgLen], ecx ; We'll need the length of the message when we send it |
; Now, lets send this and wait for an answer |
eth.search_port 1024,edx ; Find a free port starting from 1025 and store in edx |
eth.get_DNS esi ; Read DNS IP from stack into esi |
eth.open edx,53,esi,[socketNum] ; First, open socket |
; DEBUGF 1,'Socket opened: %u (port %u)\n',[socketNum],ecx |
eth.write [socketNum],[dnsMsgLen],dnsMsg ; Write to socket ( request DNS lookup ) |
; DEBUGF 1,'Data written, length:%u offset:%u\n',[dnsMsgLen],dnsMsg |
; DEBUGF 1,'Waiting for data: (timeout is %us)\n',TIMEOUT |
eth.wait_for_data [socketNum],TIMEOUT,no_data; Now, we wait for data from remote |
eth.read_data [socketNum],dnsMsg,[dnsMsgLen],dnsMsg+BUFFER ; Read the data into the buffer |
; DEBUGF 1,'Data received, offset:%u buffer size:%u length:%u\n',dnsMsg,BUFFER,esi-dnsMsg |
eth.close [socketNum] ; We're done, close the socket |
; DEBUGF 1,'Closed Socket\n' |
; Now parse the message to get the host IP. Man, this is complicated. It's described in RFC 1035 |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg, the end of the buffer is pointed to by [dnsMsgLen] |
mov esi, dnsMsg |
mov al, [esi+2] ; Is this a response to my question? |
and al, 0x80 |
cmp al, 0x80 |
jne abort |
;DEBUGF 1,'It was a response to my question\n' |
mov al, [esi+3] ; Were there any errors? |
and al, 0x0F |
cmp al, 0x00 |
jne abort |
;DEBUGF 1,'There were no errorst\n' |
mov ax, [esi+6] ; Is there ( at least 1 ) answer? |
cmp ax, 0x00 |
je abort |
; Header validated. Scan through and get my answer |
add esi, 12 ; Skip to the question field |
call skipName ; Skip through the question field |
add esi, 4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax, [esi] |
cmp ax, 0x0100 ; Is this the IP address answer? |
jne ctr002c |
add esi, 10 ; Yes! Point eax to the first byte of the IP address |
mov eax,[esi] |
;DEBUGF 1,'Found First Byte of IP\n' |
ret |
ctr002c: ; Skip through the answer, move to the next |
add esi, 8 |
movzx eax, byte [esi+1] |
mov ah, [esi] |
add esi, eax |
add esi, 2 |
cmp esi, [dnsMsgLen] ; Have we reached the end of the msg? This is an error condition, should not happen |
jl ctr002z ; Check next answer |
abort: |
;DEBUGF 1,'Something went wrong, aborting\n' |
xor eax,eax |
ret |
skipName: |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
mov al, [esi] |
cmp al, 0 |
je sn_exit |
and al, 0xc0 |
cmp al, 0xc0 |
je sn001 |
movzx eax, byte [esi] |
inc eax |
add esi, eax |
jmp skipName |
sn001: |
add esi, 2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
no_data: |
eth.close [socketNum] |
xor eax,eax |
ret |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
if ~defined dnsMsg |
dnsMsg: rb BUFFER |
end if |
end if |
/programs/network_old/airc/trunk/fdo.inc |
---|
0,0 → 1,343 |
; |
; Formatted Debug Output (FDO) |
; Copyright (c) 2005-2006, mike.dld |
; Created: 2005-01-29, Changed: 2006-07-20 |
; |
; For questions and bug reports, mail to mike.dld@gmail.com |
; |
; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
; |
; to be defined: |
; __DEBUG__ equ 1 |
; __DEBUG_LEVEL__ equ 5 |
macro debug_func name { |
if used name |
name@of@func equ name |
} |
macro debug_beginf { |
align 4 |
name@of@func: |
} |
debug_endf fix end if |
macro DEBUGS _sign,[_str] { |
common |
pushf |
pushad |
local ..str,..label,is_str |
is_str = 0 |
forward |
if _str eqtype '' |
is_str = 1 |
end if |
common |
if is_str = 1 |
jmp ..label |
..str db _str,0 |
..label: |
add esp,4*8+4 |
mov edx,..str |
sub esp,4*8+4 |
call fdo_debug_outstr |
else |
mov edx,_str |
call fdo_debug_outstr |
end if |
popad |
popf |
} |
macro DEBUGD _sign,_dec { |
pushf |
pushad |
if _dec eqtype eax |
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> |
mov eax,_dec |
else if ~_dec eq eax |
if _sign = 1 |
movsx eax,_dec |
else |
movzx eax,_dec |
end if |
end if |
else if _dec eqtype 0 |
mov eax,_dec |
else |
add esp,4*8+4 |
local tp |
tp equ 0 |
match _num[_arg],_dec \{ |
if _num = 1 |
if _sign = 1 |
movsx eax,byte[_arg] |
else |
movzx eax,byte[_arg] |
end if |
else if _num = 2 |
if _sign = 1 |
movsx eax,word[_arg] |
else |
movzx eax,word[_arg] |
end if |
else |
mov eax,dword[_arg] |
end if |
tp equ 1 |
\} |
match =0 [_arg],tp _dec \{ |
mov eax,dword[_arg] |
\} |
sub esp,4*8+4 |
end if |
mov cl,_sign |
call fdo_debug_outdec |
popad |
popf |
} |
macro DEBUGH _sign,_hex { |
pushf |
pushad |
if _hex eqtype eax |
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
if ~_hex eq eax |
mov eax,_hex |
end if |
mov edx,8 |
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> |
if ~_hex eq ax |
movzx eax,_hex |
end if |
shl eax,16 |
mov edx,4 |
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> |
if ~_hex eq al |
movzx eax,_hex |
end if |
shl eax,24 |
mov edx,2 |
end if |
else if _hex eqtype 0 |
mov eax,_hex |
mov edx,8 |
else |
add esp,4*8+4 |
local tp |
tp equ 0 |
match _num[_arg],_hex \{ |
mov eax,dword[_arg] |
mov edx,_num |
tp equ 1 |
\} |
match =0 [_arg],tp _hex \{ |
mov eax,dword[_arg] |
mov edx,8 |
\} |
sub esp,4*8+4 |
end if |
call fdo_debug_outhex |
popad |
popf |
} |
;----------------------------------------------------------------------------- |
debug_func fdo_debug_outchar |
debug_beginf |
pushad |
mov cl,al |
mov ebx,1 |
mov eax,63 |
mcall |
popad |
ret |
debug_endf |
debug_func fdo_debug_outstr |
debug_beginf |
mov eax,63 |
mov ebx,1 |
.l1: mov cl,[edx] |
or cl,cl |
jz .l2 |
mcall |
inc edx |
jmp .l1 |
.l2: ret |
debug_endf |
debug_func fdo_debug_outdec |
debug_beginf |
or cl,cl |
jz @f |
or eax,eax |
jns @f |
neg eax |
push eax |
mov al,'-' |
call fdo_debug_outchar |
pop eax |
@@: push 10 |
pop ecx |
push -'0' |
.l1: xor edx,edx |
div ecx |
push edx |
test eax,eax |
jnz .l1 |
.l2: pop eax |
add al,'0' |
jz .l3 |
call fdo_debug_outchar |
jmp .l2 |
.l3: ret |
debug_endf |
debug_func fdo_debug_outhex |
__fdo_hexdigits db '0123456789ABCDEF' |
debug_beginf |
mov cl,dl |
neg cl |
add cl,8 |
shl cl,2 |
rol eax,cl |
.l1: rol eax,4 |
push eax |
and eax,0x0000000F |
mov al,[__fdo_hexdigits+eax] |
call fdo_debug_outchar |
pop eax |
dec edx |
jnz .l1 |
ret |
debug_endf |
;----------------------------------------------------------------------------- |
macro DEBUGF _level,_format,[_arg] { |
common |
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
_debug_str_ equ __debug_str_ # a1 |
a1 = 0 |
c2 = 0 |
c3 = 0 |
f2 = 0 |
repeat ..lbl-..f1 |
virtual at 0 |
db _format,0,0 |
load c1 word from %-1 |
end virtual |
if c1 = '%s' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER S,a1,0,_arg |
else if c1 = '%x' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER H,a1,0,_arg |
else if c1 = '%d' | c1 = '%u' |
local c4 |
if c1 = '%d' |
c4 = 1 |
else |
c4 = 0 |
end if |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER D,a1,c4,_arg |
else if c1 = '\n' |
c3 = c3 + 1 |
end if |
end repeat |
virtual at 0 |
db _format,0,0 |
load c1 from f2-c2 |
end virtual |
if (c1<>0)&(f2<>..lbl-..f1-1) |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
virtual at 0 |
..f1 db _format,0 |
..lbl: |
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
end virtual |
end if |
} |
macro __include_debug_strings dummy,[_id,_fmt,_len] { |
common |
local c1,a1,a2 |
forward |
if defined _len & ~_len eq |
_id: |
a1 = 0 |
a2 = 0 |
repeat _len |
virtual at 0 |
db _fmt,0,0 |
load c1 word from %+a2-1 |
end virtual |
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
db 0 |
a2 = a2 + 1 |
else if (c1='\n') |
dw $0A0D |
a1 = a1 + 1 |
a2 = a2 + 1 |
else |
db c1 and 0x0FF |
end if |
end repeat |
db 0 |
end if |
} |
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
common |
local num |
num = 0 |
forward |
if num = _num |
DEBUG#_letter _sign,_arg |
end if |
num = num+1 |
common |
_num = _num+1 |
} |
macro include_debug_strings { |
if __DEBUG__ = 1 |
match dbg_str,__debug_strings \{ |
__include_debug_strings dbg_str |
\} |
end if |
} |
/programs/network_old/airc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm airc.asm airc |
@erase lang.inc |
@pause |
/programs/network_old/airc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm airc.asm airc |
@erase lang.inc |
@pause |
/programs/network_old/downloader/trunk/downloader.asm |
---|
0,0 → 1,1634 |
; version: 0.6 - 0.62 |
; last update: 04/06/2012 |
; written by: Lipatov Kirill aka Leency |
; changes: removed old code |
; added edit_box |
; using system colors |
; indicates file saving |
; download by pressing Enter |
;----------------------------------------------------------- |
; version: 0.5 |
; date: 07/10/2010 |
; written by: Marat Zakiyanov aka Mario79, aka Mario |
; changes: reducing the size of the binary code, |
; program uses far less memory while running |
; (>0x7000, the old version used >0x100000), |
; process only net event at start with parameter |
;----------------------------------------------------------- |
; version: 0.3 -0.4 |
; written by: CleverMouse |
; |
;----------------------------------------------------------- |
; wget 0.2 by barsuk |
; based on Menuet Httpc |
;TODO |
;downloading status indication in window |
; Enabling debugging puts stuff to the debug board |
DEBUGGING_ENABLED equ 1 |
DEBUGGING_DISABLED equ 0 |
DEBUGGING_STATE equ DEBUGGING_ENABLED |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd IM_END ; image size |
dd I_END ;0x100000 ; required memory |
dd stacktop ; esp |
dd params ; I_PARAM |
dd 0x0 ; I_Path |
include 'lang.inc' |
include '../../../macros.inc' |
include '../../../proc32.inc' |
include '../../../develop/libraries/box_lib/load_lib.mac' |
include '../../../develop/libraries/box_lib/trunk/box_lib.mac' |
include '../../../dll.inc' |
include '../../../debug.inc' |
URLMAXLEN equ 256 ; maximum length of url string |
primary_buffer_size equ 4096 |
sc system_colors |
@use_library |
; Memory usage |
; webpage headers at buf_headers |
START: ; start of execution |
;dps <"Program started",13,10> |
; prepare webAddr area |
load_libraries l_libs_start,l_libs_end |
mov ebp,lib_0 |
cmp dword [ebp+ll_struc_size-4],0 |
jz @f |
mcall -1 ;exit not correct |
@@: |
mov al,' ' |
mov edi,webAddr |
mov ecx,URLMAXLEN |
cld |
rep stosb |
xor eax,eax |
stosb |
; prepare document area |
mov al,'/' |
mov edi,document |
cld |
stosb |
mov al,' ' |
mov ecx,URLMAXLEN-1 |
rep stosb |
; create local heap |
mcall 68,11 |
call load_settings |
cmp [params],byte 0 |
jz prepare_event ;red |
mcall 40, 10000000b ; only net event!!! |
; we have an url |
mov edi,document_user |
mov al,' ' |
mov ecx,URLMAXLEN |
rep stosb |
mov esi,params |
mov edi,document_user |
.copy_param: |
mov al,[esi] |
cmp al,0 |
jz .done |
cmp al,' ' |
jz .done_inc |
mov [edi],al |
inc esi |
inc edi |
jmp .copy_param |
.done_inc: |
; url is followed by shared memory name. |
inc esi |
.done: |
mov [shared_name],esi |
mov ah,22 ; strange way to tell that socket should be opened... |
call socket_commands |
jmp still |
prepare_event: |
; Report events |
; Stack 8 + defaults |
mcall 40,10100111b |
red: ; redraw |
call draw_window |
still: |
mcall 23,1 ; wait here for event |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
cmp eax,6 ; mouse in buffer ? |
je mouse |
; Get the web page data from the remote server |
call read_incoming_data |
mov eax,[status] |
mov [prev_status],eax |
mcall 53,6,[socket] |
mov [status],eax |
cmp [prev_status],4 |
jge no_send |
cmp [status],4 |
jne no_send |
mov [onoff],1 |
call send_request |
no_send: |
call print_status |
cmp [prev_status],4 |
jne no_close |
cmp [status],4 ; connection closed by server |
jbe no_close ; respond to connection close command |
; draw page |
call read_incoming_data |
mcall 53,8,[socket] |
mov [onoff],0 |
no_close: |
jmp still |
key: |
mcall 2 ; read key |
stdcall [edit_box_key], dword edit1 |
shr eax,8 |
cmp eax,13 |
je retkey |
jmp still |
button: |
mcall 17 ; get id |
cmp ah,26 |
je save |
cmp ah,1 ; button id=1 ? |
jne noclose |
; dps "Closing socket before exit... " |
close_end_exit: |
;dpd eax |
;dps <13,10> |
exit: |
or eax,-1 ; close this program |
mcall |
mouse: |
stdcall [edit_box_mouse], edit1 |
jmp still |
save: |
dps "file saved" |
newline |
mcall 70,fileinfo |
mov ecx,[sc.work_text] |
or ecx,80000000h |
mcall 4,<10,93>,,download_complete |
;pregs |
jmp still |
noclose: |
cmp ah,31 |
jne noup |
sub [display_from],20 |
jmp still |
noup: |
cmp ah,32 |
jne nourl |
add [display_from],20 |
jmp still |
retkey: |
mov ah,22 ; start load |
nourl: |
call socket_commands ; opens or closes the connection |
jmp still |
;**************************************************************************** |
; Function |
; send_request |
; |
; Description |
; Transmits the GET request to the server. |
; This is done as GET then URL then HTTP/1.1',13,10,13,10 in 3 packets |
; |
;**************************************************************************** |
send_request: |
pusha |
mov esi,string0 |
mov edi,request |
movsd |
; If proxy is used, make absolute URI - prepend http://<host> |
cmp [proxyAddr],byte 0 |
jz .noproxy |
mov dword [edi],'http' |
mov [edi+4],byte ':' |
mov [edi+5],word '//' |
add edi,7 |
mov esi,webAddr |
.copy_host_loop: |
lodsb |
cmp al,' ' |
jz .noproxy |
stosb |
jmp .copy_host_loop |
.noproxy: |
xor edx,edx ; 0 |
.next_edx: |
; Determine the length of the url to send in the GET request |
mov al,[edx+document] |
cmp al,' ' |
je .document_done |
mov [edi],al |
inc edi |
inc edx |
jmp .next_edx |
.document_done: |
mov esi,stringh |
mov ecx,stringh_end-stringh |
rep movsb |
xor edx,edx ; 0 |
.webaddr_next: |
mov al,[webAddr + edx] |
cmp al,' ' |
je .webaddr_done |
mov [edi],al |
inc edi |
inc edx |
jmp .webaddr_next |
.webaddr_done: |
cmp [proxyUser],byte 0 |
jz @f |
call append_proxy_auth_header |
@@: |
mov esi,connclose |
mov ecx,connclose_end-connclose |
rep movsb |
pusha |
mov eax,63 |
mov ebx,1 |
mov edx,request |
@@: |
mov cl,[edx] |
cmp edx,edi |
jz @f |
mcall |
inc edx |
jmp @b |
@@: |
popa |
mov edx,edi |
sub edx,request |
;;;;now write \r\nConnection: Close \r\n\r\n |
mcall 53,7,[socket],,request ;' HTTP/1.1 .. ' |
popa |
ret |
;**************************************************************************** |
; Function |
; print_status |
; |
; Description |
; displays the socket/data received status information |
; |
;**************************************************************************** |
print_status: |
pusha |
mcall 26,9 |
cmp eax,[nextupdate] |
jb status_return |
add eax,25 |
mov [nextupdate],eax |
mov ecx,[winys] |
shl ecx,16 |
add ecx,-18*65536+10 |
mcall 13,<5,100>,,0xffffff |
mov edx,12*65536-18 |
add edx,[winys] |
xor esi,esi |
mcall 47,<3,0>,[status],, |
mov edx,40*65536-18 |
add edx,[winys] |
mcall ,<6,0>,[pos] |
status_return: |
popa |
ret |
;**************************************************************************** |
; Function |
; read_incoming_data |
; |
; Description |
; receive the web page from the server, storing it without processing |
; |
;**************************************************************************** |
read_incoming_data: |
cmp [onoff],1 |
je rid |
ret |
rid: |
push esi |
push edi |
dps "rid" |
newline |
newbyteread: |
;call print_status |
mcall 53,2,[socket] |
cmp eax,0 |
je no_more_data |
mcall 53,11,[socket],primary_buf,primary_buffer_size |
;dps "part " |
;dph eax |
;newline |
mov edi,[pos] |
add [pos],eax |
push eax |
mcall 68,20,[pos],[buf_ptr] |
mov [buf_ptr],eax |
add edi,eax |
mov esi,primary_buf |
pop ecx ; number of recently read bytes |
lea edx,[ecx - 3] |
rep movsb |
no_more_data: |
mcall 53,6,[socket] |
cmp eax,4 |
jne no_more_data.finish |
jmp newbyteread |
.finish: |
;dps "finish " |
;pregs |
call parse_result |
mov ecx,[shared_name] |
test ecx, ecx |
jz @f |
cmp [ecx],byte 0 |
jnz save_in_shared |
@@: |
mcall 70,fileinfo |
mov ecx,[sc.work_text] |
or ecx,80000000h |
mcall 4,<10,93>,,download_complete |
dps "file saved" |
newline |
;pregs |
; jmp close_end_exit |
pop edi |
pop esi |
; if called from command line, then exit |
cmp [params],byte 0 |
jnz exit |
ret |
save_in_shared: |
mov esi,1 ; SHM_OPEN+SHM_WRITE |
mcall 68,22 |
test eax,eax |
jz save_in_shared_done |
sub edx,4 |
jbe save_in_shared_done |
mov ecx,[final_size] |
cmp ecx,edx |
jb @f |
mov ecx,edx |
@@: |
mov [eax],ecx |
lea edi,[eax+4] |
mov esi,[final_buffer] |
mov edx,ecx |
shr ecx,2 |
rep movsd |
mov ecx,edx |
and ecx,3 |
rep movsb |
save_in_shared_done: |
pop edi |
pop esi |
jmp exit |
; this function cuts header, and removes chunk sizes if doc is chunked |
; in: buf_ptr, pos; out: buf_ptr, pos. |
parse_result: |
; close socket |
mcall 53,8,[socket] |
dps "close socket: " |
dph eax |
newline |
mov edi,[buf_ptr] |
mov edx,[pos] |
mov [buf_size],edx |
; mcall 70,fileinfo_tmp |
dps "pos = " |
dph edx |
newline |
; first, find end of headers |
.next_byte: |
cmp [edi],dword 0x0d0a0d0a ; ìíå ëåíü ÷èòàòü ñòàíäàðò, ïóñòü áóäóò îáà âàðèàíòà |
je .end_of_headers |
cmp [edi],dword 0x0a0d0a0d |
je .end_of_headers |
inc edi |
dec edx |
jne .next_byte |
; no end of headers. it's an error. let client see all those headers. |
ret |
.end_of_headers: |
; here we look at headers and search content-length or transfer-encoding headers |
;dps "eoh " |
;newline |
sub edi,[buf_ptr] |
add edi,4 |
mov [body_pos],edi ; store position where document body starts |
mov [is_chunked],0 |
; find content-length in headers |
; not good method, but should work for 'Content-Length:' |
mov esi,[buf_ptr] |
mov edi,s_contentlength |
mov ebx,[body_pos] |
xor edx,edx ; 0 |
.cl_next: |
mov al,[esi] |
cmp al,[edi + edx] |
jne .cl_fail |
inc edx |
cmp edx,len_contentlength |
je .cl_found |
jmp .cl_incr |
.cl_fail: |
xor edx,edx ; 0 |
.cl_incr: |
inc esi |
dec ebx |
je .cl_error |
jmp .cl_next |
.cl_error: |
;pregs |
;newline |
;dph esi |
;dps " content-length not found " |
; find 'chunked' |
; äà, ÿ êîïèðóþ êîä, ýòî óæàñíî, íî ìíå õî÷åòñÿ, ÷òîáû ïîñêîðåå çàðàáîòàëî |
; à òàì óæ îòðåôàêòîðþ |
mov esi,[buf_ptr] |
mov edi,s_chunked |
mov ebx,[body_pos] |
xor edx,edx ; 0 |
.ch_next: |
mov al,[esi] |
cmp al,[edi + edx] |
jne .ch_fail |
inc edx |
cmp edx,len_chunked |
je .ch_found |
jmp .ch_incr |
.ch_fail: |
xor edx,edx ; 0 |
.ch_incr: |
inc esi |
dec ebx |
je .ch_error |
jmp .ch_next |
.ch_error: |
; if neither of the 2 headers is found, it's an error |
;dps "transfer-encoding: chunked not found " |
mov eax,[pos] |
sub eax,[body_pos] |
jmp .write_final_size |
.ch_found: |
mov [is_chunked],1 |
mov eax,[body_pos] |
add eax,[buf_ptr] |
sub eax,2 |
mov [prev_chunk_end],eax |
jmp parse_chunks |
.cl_found: |
call read_number ; eax = number from *esi |
.write_final_size: |
mov [final_size],eax ; if this works, i will b very happy... |
mov ebx,[pos] ; we well check if it is right |
sub ebx,[body_pos] |
;dps "check cl eax==ebx " |
;pregs |
; everything is ok, so we return |
mov eax,[body_pos] |
mov ebx,[buf_ptr] |
add ebx,eax |
mov [final_buffer],ebx |
; mov ebx,[pos] |
; sub ebx,eax |
; mov [final_size],ebx |
ret |
parse_chunks: |
;dps "parse chunks" |
;newline |
; we have to look through the data and remove sizes of chunks we see |
; 1. read size of next chunk |
; 2. if 0, it's end. if not, continue. |
; 3. make a good buffer and copy a chunk there |
xor eax,eax |
mov [final_buffer],eax ; 0 |
mov [final_size],eax ; 0 |
.read_size: |
mov eax,[prev_chunk_end] |
mov ebx,eax |
sub ebx,[buf_ptr] |
mov edx,eax |
;dps "rs " |
;pregs |
cmp ebx,[pos] |
jae chunks_end ; not good |
call read_hex ; in: eax=pointer to text. out:eax=hex number,ebx=end of text. |
cmp eax,0 |
jz chunks_end |
add ebx,1 |
mov edx,ebx ; edx = size of size of chunk |
add ebx,eax |
mov [prev_chunk_end],ebx |
;dps "sz " |
;pregs |
; do copying: from buf_ptr+edx to final_buffer+prev_final_size count eax |
; realloc final buffer |
push eax |
push edx |
push dword [final_size] |
add [final_size],eax |
mcall 68,20,[final_size],[final_buffer] |
mov [final_buffer],eax |
;dps "re " |
;pregs |
pop edi |
pop esi |
pop ecx |
; add [pos],ecx |
add edi,[final_buffer] |
;dps "cp " |
;pregs |
rep movsb |
jmp .read_size |
chunks_end: |
; free old buffer |
dps "chunks end" |
newline |
mcall 68,13,[buf_ptr] |
; done! |
ret |
; reads content-length from [edi+ecx], result in eax |
read_number: |
push ebx |
xor eax,eax |
xor ebx,ebx |
.next: |
mov bl,[esi] |
;dph ebx |
cmp bl,'0' |
jb .not_number |
cmp bl,'9' |
ja .not_number |
sub bl,'0' |
shl eax,1 |
lea eax,[eax + eax * 4] ; eax *= 10 |
add eax,ebx |
.not_number: |
cmp bl,13 |
jz .done |
inc esi |
jmp .next |
.done: |
pop ebx |
;newline |
;dps "strtoint eax " |
;pregs |
ret |
; reads hex from eax,result in eax,end of text in ebx |
read_hex: |
add eax,2 |
mov ebx,eax |
mov eax,[ebx] |
mov [deba],eax |
; pushf |
; pushad |
; mov edx,deba |
; call debug_outstr |
; popad |
; popf |
xor eax,eax |
xor ecx,ecx |
.next: |
mov cl,[ebx] |
inc ebx |
cmp cl,0x0d |
jz .done |
;dph ebx |
or cl,0x20 |
sub cl,'0' |
jb .bad |
cmp cl,0x9 |
jbe .adding |
sub cl,'a'-'0'-10 |
cmp cl,0x0a |
jb .bad |
cmp cl,0x0f |
ja .bad |
.adding: |
shl eax,4 |
or eax,ecx |
; jmp .not_number |
;.bad: |
.bad: |
jmp .next |
.done: |
;newline |
;dps "hextoint eax " |
;pregs |
ret |
;**************************************************************************** |
; Function |
; socket_commands |
; |
; Description |
; opens or closes the socket |
; |
;**************************************************************************** |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
dps "opening socket" |
newline |
; Clear all page memory |
xor eax,eax |
mov [prev_chunk_end],eax ; 0 |
cmp [buf_ptr],eax ; 0 |
jz no_free |
mcall 68,13,[buf_ptr] ; free buffer |
no_free: |
xor eax,eax |
mov [buf_size],eax ; 0 |
; Parse the entered url |
call parse_url |
; Get a free port number |
mov ecx,1000 ; local port starting at 1000 |
getlp1: |
inc ecx |
push ecx |
mcall 53,9 |
pop ecx |
cmp eax,0 ; is this local port in use? |
jz getlp1 ; yes - so try next |
mov edx,80 |
cmp [proxyAddr],byte 0 |
jz sc000 |
mov edx,[proxyPort] |
sc000: |
mcall 53,5,,,[server_ip],1 |
mov [socket],eax |
mov [pagexs],80 |
push eax |
xor eax,eax ; 0 |
mov [pos],eax |
mov [pagex],eax |
mov [pagey],eax |
mov [command_on_off],eax |
mov [is_body],eax |
pop eax |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mcall 53,8,[socket] |
no_24: |
ret |
;**************************************************************************** |
; Function |
; parse_url |
; |
; Description |
; parses the full url typed in by the user into a web address ( that |
; can be turned into an IP address by DNS ) and the page to display |
; DNS will be used to translate the web address into an IP address, if |
; needed. |
; url is at document_user and will be space terminated. |
; web address goes to webAddr and is space terminated. |
; ip address goes to server_ip |
; page goes to document and is space terminated. |
; |
; Supported formats: |
; <protocol://>address<page> |
; <protocol> is optional, removed and ignored - only http supported |
; <address> is required. It can be an ip address or web address |
; <page> is optional and must start with a leading / character |
; |
;**************************************************************************** |
parse_url: |
; First, reset destination variables |
cld |
mov al,' ' |
mov edi,document |
mov ecx,URLMAXLEN |
rep stosb |
mov edi,webAddr |
mov ecx,URLMAXLEN |
rep stosb |
mov al,'/' |
mov [document],al |
mov esi,document_user |
; remove any leading protocol text |
mov ecx,URLMAXLEN |
mov ax,'//' |
pu_000: |
cmp [esi],byte ' ' ; end of text? |
je pu_002 ; yep, so not found |
cmp [esi],ax |
je pu_001 ; Found it, so esi+2 is start |
inc esi |
loop pu_000 |
pu_002: |
; not found, so reset esi to start |
mov esi,document_user-2 |
pu_001: |
add esi,2 |
mov ebx,esi ; save address of start of web address |
mov edi,document_user + URLMAXLEN ; end of string |
; look for page delimiter - it's a '/' character |
pu_003: |
cmp [esi],byte ' ' ; end of text? |
je pu_004 ; yep, so none found |
cmp esi,edi ; end of string? |
je pu_004 ; yep, so none found |
cmp [esi],byte '/' ; delimiter? |
je pu_005 ; yep - process it |
inc esi |
jmp pu_003 |
pu_005: |
; copy page to document address |
; esi = delimiter |
push esi |
mov ecx,edi ; end of document_user |
mov edi,document |
cld |
pu_006: |
movsb |
cmp esi,ecx |
je pu_007 ; end of string? |
cmp [esi],byte ' ' ; end of text |
; je pu_007 ; äçåí-àññåìáëåð |
; jmp pu_006 ; íå íàäî ïëîäèòü ñóùíîñòè ïî íàïðàñíó |
jne pu_006 |
pu_007: |
pop esi ; point esi to '/' delimiter |
pu_004: |
; copy web address to webAddr |
; start in ebx,end in esi-1 |
mov ecx,esi |
mov esi,ebx |
mov edi,webAddr |
cld |
pu_008: |
movsb |
cmp esi,ecx |
; je pu_009 ; äçåí-àññåìáëåð |
; jmp pu_008 ; íå íàäî ïëîäèòü ñóùíîñòè ïî íàïðàñíó |
jne pu_008 |
pu_009: |
; For debugging, display resulting strings |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi,document_user |
call debug_print_string |
mov esi,webAddr |
call debug_print_string |
mov esi,document |
call debug_print_string |
end if |
; Look up the ip address, or was it specified? |
mov al,[proxyAddr] |
cmp al,0 |
jnz pu_015 |
mov al,[webAddr] |
pu_015: |
cmp al,'0' |
jb pu_010 ; Resolve address |
cmp al,'9' |
ja pu_010 ; Resolve address |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi,str2 ; print gotip |
call debug_print_string |
end if |
; Convert address |
; If proxy is given, get proxy address instead of server |
mov esi,proxyAddr-1 |
cmp byte [esi+1],0 |
jnz pu_020 |
mov esi,webAddr-1 |
pu_020: |
mov edi,server_ip |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,server_ip+3 |
jbe ip1 |
jmp pu_011 |
pu_010: |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi,str1 ; print resolving |
call debug_print_string |
end if |
; Resolve Address |
call translateData ; Convert domain & DNS IP address |
call resolveDomain ; get ip address |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi,str3 |
call debug_print_string |
end if |
pu_011: |
; Done |
ret |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the domain name and DNS IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The ename, in query, is converted and stored in dnsMsg |
; |
;*************************************************************************** |
translateData: |
; first, get the IP address of the DNS server |
; Then, build up the request string. |
; Build the request string |
mov eax,0x00010100 |
mov [dnsMsg],eax |
mov eax,0x00000100 |
mov [dnsMsg+4],eax |
mov eax,0x00000000 |
mov [dnsMsg+8],eax |
; domain name goes in at dnsMsg+12 |
mov esi,dnsMsg +12 ;location of label length |
mov edi,dnsMsg + 13 ;label start |
mov edx,proxyAddr |
cmp byte [edx],0 |
jnz td000 |
mov edx,webAddr |
td000: |
mov ecx,12 ; total string length so far |
td002: |
mov [esi],byte 0 |
inc ecx |
td0021: |
mov al,[edx] |
cmp al,' ' |
je td001 ; we have finished the string translation |
cmp al,0 |
je td001 |
cmp al,'.' ; we have finished the label |
je td004 |
inc byte [esi] |
inc ecx |
mov [edi],al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi,edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi],byte 0 |
inc ecx |
inc edi |
mov [edi],dword 0x01000100 |
add ecx,4 |
mov [dnsMsgLen],ecx |
ret |
;*************************************************************************** |
; Function |
; resolveDomain |
; |
; Description |
; Sends a question to the dns server |
; works out the IP address from the response from the DNS server |
; |
;*************************************************************************** |
resolveDomain: |
; Get a free port number |
mov ecx,1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mcall 53,9 |
pop ecx |
cmp eax,0 ; is this local port in use? |
jz getlp ; yes - so try next |
; Get DNS IP |
mcall 52,13 |
mov esi,eax |
; First, open socket |
mov edx,53 ; remote port - dns |
; mov esi,dword [dns_ip] |
xor ebx,ebx ; 0 |
mcall 53 |
mov [socketNum],eax |
; write to socket ( request DNS lookup ) |
mcall 53,4,[socketNum],[dnsMsgLen],dnsMsg |
; Setup the DNS response buffer |
mov eax,dnsMsg |
mov [dnsMsgLen],eax |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mcall 10 ; wait here for event |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mcall 53,2,[socketNum] |
cmp eax,0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mcall 53,3,[socketNum] ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax,[dnsMsgLen] |
mov [eax],bl |
inc dword [dnsMsgLen] |
mcall 53,2,[socketNum] ; any more data? |
cmp eax,0 |
jne ctr002 ; yes, so get it |
; close socket |
mcall 53,1,[socketNum] |
mov [socketNum],dword 0xFFFF |
; Now parse the message to get the host IP |
; Man, this is complicated. It's described in |
; RFC 1035 |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi,str4 |
call debug_print_string |
end if |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg |
; The end of the buffer is pointed to by [dnsMsgLen] |
; Clear the IP address text |
mov [server_ip],dword 0 |
mov esi,dnsMsg |
; Is this a response to my question? |
mov al,[esi+2] |
and al,0x80 |
cmp al,0x80 |
jne ctr002a |
; Were there any errors? |
mov al,[esi+3] |
and al,0x0F |
cmp al,0x00 |
jne ctr002a |
; Is there ( at least 1 ) answer? |
mov ax,[esi+6] |
cmp ax,0x00 |
je ctr002a |
; Header valdated. Scan through and get my answer |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
pusha |
mov esi,str4 |
call debug_print_string |
popa |
end if |
add esi,12 ; Skip to the question field |
; Skip through the question field |
call skipName |
add esi,4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, |
; find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax,[esi] |
cmp ax,0x0100 ; Is this the IP address answer? |
jne ctr002c |
; Yes! Point esi to the first byte of the IP address |
add esi,10 |
mov eax,[esi] |
mov [server_ip],eax |
ret |
ctr002c: ; Skip through the answer, move to the next |
add esi,8 |
movzx eax,byte [esi+1] |
mov ah,[esi] |
add esi,eax |
add esi,2 |
; Have we reached the end of the msg? |
; This is an error condition, should not happen |
cmp esi,[dnsMsgLen] |
jl ctr002z ; Check next answer |
jmp ctr002a ; abort |
ctr002a: |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mcall 2 ; just read it and ignore |
jmp ctr001 |
ctr005: ; button |
mcall 17 ; get id |
mov dl,ah |
; close socket |
mcall 53,1,[socketNum] |
cmp dl,1 |
je exit |
mov [socketNum],dword 0xFFFF |
mov [server_ip],dword 0 |
ret |
;*************************************************************************** |
; Function |
; skipName |
; |
; Description |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
; |
;*************************************************************************** |
skipName: |
mov al,[esi] |
cmp al,0 |
je sn_exit |
and al,0xc0 |
cmp al,0xc0 |
je sn001 |
movzx eax,byte [esi] |
inc eax |
add esi,eax |
jmp skipName |
sn001: |
add esi,2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
;*************************************************************************** |
; Function |
; load_settings |
; |
; Description |
; Load settings from configuration file network.ini |
; |
;*************************************************************************** |
load_settings: |
stdcall dll.Load,@IMPORT |
test eax,eax |
jnz ls001 |
invoke ini.get_str,inifile,sec_proxy,key_proxy,proxyAddr,256,proxyAddr |
invoke ini.get_int,inifile,sec_proxy,key_proxyport,80 |
mov [proxyPort],eax |
invoke ini.get_str,inifile,sec_proxy,key_user, proxyUser,256,proxyUser |
invoke ini.get_str,inifile,sec_proxy,key_password,proxyPassword,256,proxyPassword |
ls001: |
ret |
;*************************************************************************** |
; Function |
; append_proxy_auth_header |
; |
; Description |
; Append header to HTTP request for proxy authentification |
; |
;*************************************************************************** |
append_proxy_auth_header: |
mov esi,proxy_auth_basic |
mov ecx,proxy_auth_basic_end - proxy_auth_basic |
rep movsb |
; base64-encode string <user>:<password> |
mov esi,proxyUser |
apah000: |
lodsb |
test al,al |
jz apah001 |
call encode_base64_byte |
jmp apah000 |
apah001: |
mov al,':' |
call encode_base64_byte |
mov esi,proxyPassword |
apah002: |
lodsb |
test al,al |
jz apah003 |
call encode_base64_byte |
jmp apah002 |
apah003: |
call encode_base64_final |
ret |
encode_base64_byte: |
inc ecx |
shl edx,8 |
mov dl,al |
cmp ecx,3 |
je ebb001 |
ret |
ebb001: |
shl edx,8 |
inc ecx |
ebb002: |
rol edx,6 |
xor eax,eax |
xchg al,dl |
mov al,[base64_table+eax] |
stosb |
loop ebb002 |
ret |
encode_base64_final: |
mov al,0 |
test ecx,ecx |
jz ebf000 |
call encode_base64_byte |
test ecx,ecx |
jz ebf001 |
call encode_base64_byte |
mov byte [edi-2],'=' |
ebf001: |
mov byte [edi-1],'=' |
ebf000: |
ret |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board, in quotes |
; |
; esi holds ptr to msg to display, which is space or 0 terminated |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
push esi |
mov cl,'"' |
mcall 63,1 |
pop esi |
dps_000: |
mov cl,[esi] |
cmp cl,0 |
je dps_exit |
cmp cl,' ' |
je dps_exit |
jmp dps_001 |
dps_exit: |
mov cl,'"' |
mcall 63,1 |
mov cl,13 |
mcall |
mov cl,10 |
mcall |
ret |
dps_001: |
push esi |
mcall 63,1 |
pop esi |
inc esi |
jmp dps_000 |
end if |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
; cmp [params],byte 0 |
; jz .noret |
;.noret: |
mcall 12,1 |
mcall 48,3,sc,40 ;get system colors |
mov edx,[sc.work] |
or edx,0x34000000 |
mcall 0,<50,370>,<350,140>,,0,title ;draw window |
mov ecx,[sc.work_text] |
or ecx,80000000h |
mcall 4, <14,14>, ,type_pls ;"URL:" |
;mov ecx,[winys] |
;shl ecx,16 |
;add ecx,[winys] |
;sub ecx,26*65536+26 |
;mcall 38,<5,545> |
edit_boxes_set_sys_color edit1,editboxes_end,sc |
stdcall [edit_box_draw], edit1 |
; RELOAD |
mcall 8,<90,68>,<54,16>,22,[sc.work_button] |
; STOP |
mcall ,<166,50>,<54,16>,24 |
; SAVE |
mcall ,<224,54>,,26 |
; BUTTON TEXT |
mov ecx,[sc.work_button_text] |
or ecx,80000000h |
mcall 4,<102,59>,,button_text |
mcall 12,2 ; end window redraw |
ret |
;----------------------------------------------------------------------------- |
; Data area |
;----------------------------------------------------------------------------- |
align 4 |
@IMPORT: |
library libini,'libini.obj' |
import libini, \ |
ini.get_str,'ini_get_str', \ |
ini.get_int,'ini_get_int' |
;--------------------------------------------------------------------- |
fileinfo dd 2,0,0 |
final_size dd 0 |
final_buffer dd 0 |
db '/rd/1/.download',0 |
body_pos dd 0 |
;fileinfo_tmp dd 2,0,0 |
buf_size dd 0 |
buf_ptr dd 0 |
; db '/rd/1/1',0 |
deba dd 0 |
db 0 |
;--------------------------------------------------------------------- |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
str1: db "Resolving...",0 |
str3: db "Resolved",0 |
str2: db "GotIP",0 |
str4: db "GotResponse",0 |
end if |
;--------------------------------------------------------------------- |
;Leency editbox |
mouse_dd dd 0 |
edit1 edit_box 295, 48, 10, 0xffffff, 0xff, 0x80ff, 0, 0x8000, URLMAXLEN, document_user, mouse_dd, ed_focus+ed_always_focus,7,7 |
editboxes_end: |
head_f_i: head_f_l db 'System error',0 |
system_dir_0 db '/sys/lib/' |
lib_name_0 db 'box_lib.obj',0 |
err_msg_found_lib_0 db '¥ ©¤¥ ¡¨¡«¨®â¥ª ',39,'box_lib.obj',39,0 |
err_msg_import_0 db '訡ª ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,0 |
l_libs_start: |
lib_0 l_libs lib_name_0, sys_path, library_path, system_dir_0,\ |
err_msg_found_lib_0,head_f_l,import_box_lib,err_msg_import_0,head_f_i |
l_libs_end: |
align 4 |
import_box_lib: |
;dd sz_init1 |
edit_box_draw dd sz_edit_box_draw |
edit_box_key dd sz_edit_box_key |
edit_box_mouse dd sz_edit_box_mouse |
;edit_box_set_text dd sz_edit_box_set_text |
dd 0,0 |
;sz_init1 db 'lib_init',0 |
sz_edit_box_draw db 'edit_box',0 |
sz_edit_box_key db 'edit_box_key',0 |
sz_edit_box_mouse db 'edit_box_mouse',0 |
;sz_edit_box_set_text db 'edit_box_set_text',0 |
sys_path rb 4096 |
library_path rb 4096 |
;--------------------------------------------------------------------- |
type_pls db 'URL:',0 |
button_text db 'DOWNLOAD STOP RESAVE',0 |
download_complete db 'File saved as /rd/1/.download',0 |
display_from dd 20 |
pos dd 0x0 |
pagex dd 0x0 |
pagey dd 0x0 |
pagexs dd 80 |
command_on_off dd 0x0 |
text_type db 1 |
com2 dd 0x0 |
script dd 0x0 |
socket dd 0x0 |
addr dd 0x0 |
ya dd 0x0 |
len dd 0x00 |
title db 'Network Downloader',0 |
server_ip: db 207,44,212,20 |
;dns_ip: db 194,145,128,1 |
;--------------------------------------------------------------------- |
;webAddr: |
;times URLMAXLEN db ' ' |
;db 0 |
;document: db '/' |
;times URLMAXLEN-1 db ' ' |
;--------------------------------------------------------------------- |
s_contentlength db 'Content-Length:' |
len_contentlength = 15 |
s_chunked db 'Transfer-Encoding: chunked' |
len_chunked = $ - s_chunked |
is_body dd 0 ; 0 if headers, 1 if content |
is_chunked dd 0 |
prev_chunk_end dd 0 |
cur_chunk_size dd 0 |
string0: db 'GET ' |
stringh: db ' HTTP/1.1',13,10,'Host: ' |
stringh_end: |
proxy_auth_basic: db 13,10,'Proxy-Authorization: Basic ' |
proxy_auth_basic_end: |
connclose: db 13,10,'User-Agent: Kolibrios Downloader',13,10,'Connection: Close',13,10,13,10 |
connclose_end: |
base64_table db 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' |
db '0123456789+/' |
inifile db '/sys/network/zeroconf.ini',0 |
sec_proxy: |
key_proxy db 'proxy',0 |
key_proxyport db 'port',0 |
key_user db 'user',0 |
key_password db 'password',0 |
proxyPort dd 80 |
shared_name dd 0 |
;yandex: db 'menuetos.net' |
;yandex_end: |
status dd 0x0 |
prev_status dd 0x0 |
onoff dd 0x0 |
nextupdate: dd 0 |
winys: dd 400 |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
;--------------------------------------------------------------------- |
document_user db 'http://',0 |
;--------------------------------------------------------------------- |
IM_END: |
rb URLMAXLEN-(IM_END - document_user) |
;--------------------------------------------------------------------- |
align 4 |
document: |
rb URLMAXLEN |
;--------------------------------------------------------------------- |
align 4 |
webAddr: |
rb URLMAXLEN+1 |
;--------------------------------------------------------------------- |
align 4 |
primary_buf: |
rb primary_buffer_size |
;--------------------------------------------------------------------- |
align 4 |
params: ; db 1024 dup(0) |
rb 1024 |
;--------------------------------------------------------------------- |
align 4 |
request: ; db 256 dup(0) |
rb 256 |
;--------------------------------------------------------------------- |
align 4 |
proxyAddr: ; db 256 dup(0) |
rb 256 |
;--------------------------------------------------------------------- |
align 4 |
proxyUser: ; db 256 dup(0) |
rb 256 |
;--------------------------------------------------------------------- |
align 4 |
proxyPassword: ; db 256 dup(0) |
rb 256 |
;--------------------------------------------------------------------- |
align 4 |
dnsMsg: |
rb 4096 |
; rb 0x100000 |
;--------------------------------------------------------------------- |
align 4 |
rb 4096 |
stacktop: |
;--------------------------------------------------------------------- |
I_END: |
;--------------------------------------------------------------------- |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/downloader/trunk/build.bat |
---|
0,0 → 1,6 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm downloader.asm downloader |
@kpack downloader |
@erase lang.inc |
@pause |
/programs/network_old/downloader/trunk/build.sh |
---|
0,0 → 1,13 |
#!/bin/bash |
# This script does for linux the same as build.bat for DOS, |
# it compiles the KoOS kernel, hopefully ;-) |
echo "lang fix ru" |
echo "lang fix ru" > lang.inc |
fasm -m 16384 downloader.asm downloader |
rm -f lang.inc |
exit 0 |
/programs/network_old/zeroconf/trunk/zeroconf.asm |
---|
0,0 → 1,492 |
; Zero-config |
; v 1.4 |
; |
; DHCP code is based on that by Mike Hibbet (DHCP client for menuetos) |
; |
; Written by HidnPlayr & Derpenguin |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd I_END ; memory for app |
dd I_END ; esp |
dd 0x0 , path ; I_Param , I_Icon |
; CONFIGURATION |
TIMEOUT equ 60 ; in seconds |
BUFFER equ 1024 ; in bytes |
__DEBUG__ equ 1 ; enable/disable |
__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors |
; CONFIGURATION FOR LINK-LOCAL |
PROBE_WAIT equ 1 ; second (initial random delay) |
PROBE_MIN equ 1 ; second (minimum delay till repeated probe) |
PROBE_MAX equ 2 ; seconds (maximum delay till repeated probe) |
PROBE_NUM equ 3 ; (number of probe packets) |
ANNOUNCE_NUM equ 2 ; (number of announcement packets) |
ANNOUNCE_INTERVAL equ 2 ; seconds (time between announcement packets) |
ANNOUNCE_WAIT equ 2 ; seconds (delay before announcing) |
MAX_CONFLICTS equ 10 ; (max conflicts before rate limiting) |
RATE_LIMIT_INTERVAL equ 60 ; seconds (delay between successive attempts) |
DEFEND_INTERVAL equ 10 ; seconds (min. wait between defensive ARPs) |
include '../../../proc32.inc' |
include '../../../macros.inc' |
include 'ETH.INC' |
include 'debug-fdo.inc' |
include 'dhcp.inc' |
include '../../../dll.inc' |
START: ; start of execution |
mcall 40, 0 |
eth.set_network_drv 0x00000383 |
DEBUGF 1,"Zero-config service:\n" |
eth.status eax ; Read the Stack status |
test eax,eax ; if eax is zero, no driver was found |
jnz @f |
DEBUGF 1,"No Card found!\n" |
jmp close |
@@: |
DEBUGF 1,"Detected card: %x\n",eax |
@@: |
eth.check_cable eax |
test al,al |
jnz @f |
DEBUGF 1,"Cable disconnected!\n" |
mcall 5, 500 ; loop until cable is connected (check every 5 sec) |
jmp @r |
@@: |
eth.read_mac MAC |
DEBUGF 1,"MAC: %x-%x-%x-%x-%x-%x\n",[MAC]:2,[MAC+1]:2,[MAC+2]:2,[MAC+3]:2,[MAC+4]:2,[MAC+5]:2 |
cld |
mov edi, path ; Calculate the length of zero-terminated string |
xor al , al |
mov ecx, 1024 |
repnz scas byte[es:edi] |
dec edi |
mov esi, filename |
mov ecx, 5 |
rep movsb |
mcall 68,11 |
stdcall dll.Load,@IMPORT |
or eax,eax |
jnz skip_ini |
invoke ini.get_str, path, str_ipconfig, str_type, inibuf, 16, 0 |
mov eax,dword[inibuf] |
cmp eax,'stat' |
jne skip_ini |
invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
eth.set_IP edx |
invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
eth.set_GATEWAY edx |
invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
eth.set_DNS edx |
invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0 |
mov edx, inibuf |
call Ip2dword |
eth.set_SUBNET edx |
mcall -1 |
skip_ini: |
eth.check_port 68,eax ; Check if port 68 is available |
cmp eax,1 |
je @f |
DEBUGF 1,"Port 68 is already in use!\n" |
jmp close |
@@: |
eth.open_udp 68,67,-1,[socketNum] ; open socket (local,remote,ip,socket) |
; Setup the first msg we will send |
mov byte [dhcpMsgType], 0x01 ; DHCP discover |
mov dword [dhcpLease], esi ; esi is still -1 (-1 = forever) |
mcall 26, 9 |
imul eax,100 |
mov [currTime],eax |
buildRequest: ; Creates a DHCP request packet. |
stdcall mem.Alloc, BUFFER |
mov [dhcpMsg], eax |
test eax,eax |
jz apipa |
mov edi, eax |
mov ecx,BUFFER |
xor eax,eax |
cld |
rep stosb |
mov edx,[dhcpMsg] |
mov [edx], byte 0x01 ; Boot request |
mov [edx+1], byte 0x01 ; Ethernet |
mov [edx+2], byte 0x06 ; Ethernet h/w len |
mov [edx+4], dword 0x11223344 ; xid |
mov eax,[currTime] |
mov [edx+8], eax ; secs, our uptime |
mov [edx+10], byte 0x80 ; broadcast flag set |
mov eax, dword [MAC] ; first 4 bytes of MAC |
mov [edx+28],dword eax |
mov ax, word [MAC+4] ; last 2 bytes of MAC |
mov [edx+32],word ax |
mov [edx+236], dword 0x63538263 ; magic number |
mov [edx+240], word 0x0135 ; option DHCP msg type |
mov al, [dhcpMsgType] |
mov [edx+240+2], al |
mov [edx+240+3], word 0x0433 ; option Lease time = infinity |
mov eax, [dhcpLease] |
mov [edx+240+5], eax |
mov [edx+240+9], word 0x0432 ; option requested IP address |
mov eax, [dhcpClientIP] |
mov [edx+240+11], eax |
mov [edx+240+15], word 0x0437 ; option request list |
mov [edx+240+17], dword 0x0f060301 |
cmp [dhcpMsgType], byte 0x01 ; Check which msg we are sending |
jne request_options |
mov [edx+240+21], byte 0xff ; "Discover" options |
mov [dhcpMsgLen], dword 262 ; end of options marker |
jmp send_request |
request_options: |
mov [edx+240+21], word 0x0436 ; server IP |
mov eax, [dhcpServerIP] |
mov [edx+240+23], eax |
mov [edx+240+27], byte 0xff ; end of options marker |
mov [dhcpMsgLen], dword 268 |
send_request: |
eth.write_udp [socketNum],[dhcpMsgLen],[dhcpMsg] ; write to socket ( send broadcast request ) |
mov eax, [dhcpMsg] ; Setup the DHCP buffer to receive response |
mov [dhcpMsgLen], eax ; Used as a pointer to the data |
mov eax,23 ; wait here for event (data from remote) |
mov ebx,TIMEOUT*10 |
mcall |
eth.poll [socketNum] |
test eax,eax |
jnz read_data |
DEBUGF 2,"Timeout!\n" |
eth.close_udp [socketNum] |
jmp apipa ; no server found, lets try zeroconf |
read_data: ; we have data - this will be the response |
eth.read_packet [socketNum], [dhcpMsg], BUFFER |
mov [dhcpMsgLen], eax |
eth.close_udp [socketNum] |
; depending on which msg we sent, handle the response |
; accordingly. |
; If the response is to a dhcp discover, then: |
; 1) If response is DHCP OFFER then |
; 1.1) record server IP, lease time & IP address. |
; 1.2) send a request packet |
; If the response is to a dhcp request, then: |
; 1) If the response is DHCP ACK then |
; 1.1) extract the DNS & subnet fields. Set them in the stack |
cmp [dhcpMsgType], byte 0x01 ; did we send a discover? |
je discover |
cmp [dhcpMsgType], byte 0x03 ; did we send a request? |
je request |
jmp close ; really unknown, what we did |
discover: |
call parseResponse |
cmp [dhcpMsgType], byte 0x02 ; Was the response an offer? |
jne apipa ; NO - so we do zeroconf |
mov [dhcpMsgType], byte 0x03 ; DHCP request |
jmp buildRequest |
request: |
call parseResponse |
cmp [dhcpMsgType], byte 0x05 ; Was the response an ACK? It should be |
jne apipa ; NO - so we do zeroconf |
jmp close |
;*************************************************************************** |
; Function |
; parseResponse |
; |
; Description |
; extracts the fields ( client IP address and options ) from |
; a DHCP response |
; The values go into |
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, |
; dhcpDNSIP, dhcpSubnet |
; The message is stored in dhcpMsg |
; |
;*************************************************************************** |
parseResponse: |
DEBUGF 1,"Data received, parsing response\n" |
mov edx, [dhcpMsg] |
pusha |
eth.set_IP [edx+16] |
mov eax,[edx] |
mov [dhcpClientIP],eax |
DEBUGF 1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1 |
popa |
add edx, 240 ; Point to first option |
xor ecx, ecx |
next_option: |
add edx, ecx |
pr001: |
mov al, [edx] |
cmp al, 0xff ; End of options? |
je pr_exit |
cmp al, dhcp_msg_type ; Msg type is a single byte option |
jne @f |
mov al, [edx+2] |
mov [dhcpMsgType], al |
add edx, 3 |
jmp pr001 ; Get next option |
@@: |
inc edx |
movzx ecx, byte [edx] |
inc edx ; point to data |
cmp al, dhcp_dhcp_server_id ; server ip |
jne @f |
mov eax, [edx] |
mov [dhcpServerIP], eax |
DEBUGF 1,"Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
jmp next_option |
@@: |
cmp al, dhcp_address_time |
jne @f |
pusha |
mov eax,[edx] |
bswap eax |
mov [dhcpLease],eax |
DEBUGF 1,"lease: %d\n",eax |
popa |
jmp next_option |
@@: |
cmp al, dhcp_subnet_mask |
jne @f |
pusha |
eth.set_SUBNET [edx] |
DEBUGF 1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
popa |
jmp next_option |
@@: |
cmp al, dhcp_router |
jne @f |
pusha |
eth.set_GATEWAY [edx] |
DEBUGF 1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
popa |
jmp next_option |
@@: |
cmp al, dhcp_domain_server |
jne next_option |
pusha |
eth.set_DNS [edx] |
DEBUGF 1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 |
popa |
jmp next_option |
pr_exit: |
; DEBUGF 1,"Sending ARP announce\n" |
; eth.ARP_ANNOUNCE [dhcpClientIP] ; send an ARP announce packet |
jmp close |
apipa: |
stdcall mem.Free, [dhcpMsg] |
link_local: |
call random |
mov ecx,0xfea9 ; IP 169.254.0.0 link local net, see RFC3927 |
mov cx,ax |
eth.set_IP ecx ; mask is 255.255.0.0 |
DEBUGF 1,"Link Local IP assigned: 169.254.%u.%u\n",[generator+2]:1,[generator+3]:1 |
eth.set_SUBNET 0xffff |
eth.set_GATEWAY 0x0 |
eth.set_DNS 0x0 |
mcall 5, PROBE_WAIT*100 |
xor esi,esi |
probe_loop: |
call random ; create a pseudo random number in eax (seeded by MAC) |
cmp al,PROBE_MIN*100 ; check if al is bigger then PROBE_MIN |
jge @f ; all ok |
add al,(PROBE_MAX-PROBE_MIN)*100 ; al is too small |
@@: |
cmp al,PROBE_MAX*100 |
jle @f |
sub al,(PROBE_MAX-PROBE_MIN)*100 |
@@: |
movzx ebx,al |
DEBUGF 1,"Waiting %u0ms\n",ebx |
mcall 5 |
DEBUGF 1,"Sending Probe\n" |
; eth.ARP_PROBE MAC |
inc esi |
cmp esi,PROBE_NUM |
jl probe_loop |
; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assigned |
; IP within this time, we should create another adress, that have to be done later |
DEBUGF 1,"Waiting %us\n",ANNOUNCE_WAIT |
mcall 5, ANNOUNCE_WAIT*100 |
xor esi,esi |
announce_loop: |
DEBUGF 1,"Sending Announce\n" |
; eth.ARP_ANNOUNCE MAC |
inc esi |
cmp esi,ANNOUNCE_NUM |
je @f |
DEBUGF 1,"Waiting %us\n",ANNOUNCE_INTERVAL |
mcall 5, ANNOUNCE_INTERVAL*100 |
jmp announce_loop |
@@: |
; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;) |
close: |
mcall -1 |
random: ; Pseudo random actually |
mov eax,[generator] |
add eax,-43ab45b5h |
ror eax,1 |
bswap eax |
xor eax,dword[MAC] |
ror eax,1 |
xor eax,dword[MAC+2] |
mov [generator],eax |
ret |
; DATA AREA |
align 16 |
@IMPORT: |
library \ |
libini,'libini.obj' |
import libini, \ |
ini.get_str,'ini_get_str' |
include_debug_strings |
filename db '.ini',0 |
str_ip db 'ip',0 |
str_subnet db 'subnet',0 |
str_gateway db 'gateway',0 |
str_dns db 'dns',0 |
str_ipconfig db 'ipconfig',0 |
str_type db 'type',0 |
IM_END: |
inibuf rb 16 |
dhcpClientIP dd ? |
dhcpMsgType db ? |
dhcpLease dd ? |
dhcpServerIP dd ? |
dhcpMsgLen dd ? |
socketNum dd ? |
MAC dp ? |
currTime dd ? |
renewTime dd ? |
generator dd ? |
dhcpMsg dd ? |
I_END_2: |
path rb 1024+5 |
I_END: |
/programs/network_old/zeroconf/trunk/build.bat |
---|
0,0 → 1,2 |
@fasm zeroconf.asm zeroconf |
@pause |
/programs/network_old/zeroconf/trunk/ETH.INC |
---|
0,0 → 1,413 |
; |
; ETH.INC |
; |
; made by hidnplayr (hidnplayr@kolibrios.org) for KolibriOS |
; |
; The given code before every macro is only a simple example |
; |
; |
; HISTORY |
; |
; v1.0: august 2006 original release |
; v1.1: december 2006 bugfixes and improvements |
; v1.2: february 2007 more bugfixes and improvements |
macro mov arg1,arg2 { |
if arg1 eq arg2 |
else |
mov arg1,arg2 |
end if |
} |
TCB_LISTEN = 1 |
TCB_SYN_SENT = 2 |
TCB_SYN_RECEIVED = 3 |
TCB_ESTABLISHED = 4 |
TCB_FIN_WAIT_1 = 5 |
TCB_FIN_WAIT_2 = 6 |
TCB_CLOSE_WAIT = 7 |
TCB_CLOSING = 8 |
TCB_LAST_ASK = 9 |
TCB_TIME_WAIT = 10 |
TCB_CLOSED = 11 |
PASSIVE = 0 |
ACTIVE = 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
macro eth.get_IP IP { |
mov ebx,1 |
mov eax,52 |
mcall |
mov IP ,eax |
} |
macro eth.get_GATEWAY GATEWAY { |
mov ebx,9 |
mov eax,52 |
mcall |
mov GATEWAY ,eax |
} |
macro eth.get_SUBNET SUBNET { |
mov ebx,10 |
mov eax,52 |
mcall |
mov SUBNET ,eax |
} |
macro eth.get_DNS DNS { |
mov ebx,13 |
mov eax,52 |
mcall |
mov DNS ,eax |
} |
macro eth.set_IP IP { |
mov ecx,IP |
mov ebx,3 |
mov eax,52 |
mcall |
} |
macro eth.set_GATEWAY GATEWAY { |
mov ecx,GATEWAY |
mov ebx,11 |
mov eax,52 |
mcall |
} |
macro eth.set_SUBNET SUBNET { |
mov ecx,SUBNET |
mov ebx,12 |
mov eax,52 |
mcall |
} |
macro eth.set_DNS DNS { |
mov ecx,DNS |
mov ebx,14 |
mov eax,52 |
mcall |
} |
macro eth.set_network_drv conf { |
mov ecx,conf |
mov ebx,2 |
mov eax,52 |
mcall |
} |
macro eth.open_udp local,remote,ip,socket { |
mov ecx, local |
mov edx, remote |
mov esi, ip |
mov ebx, 0 |
mov eax, 53 |
mcall |
mov socket,eax |
} |
macro eth.close_udp socket { |
mov ecx, socket |
mov ebx, 1 |
mov eax, 53 |
mcall |
} |
macro eth.poll socket { |
mov ecx, socket |
mov ebx, 2 |
mov eax, 53 |
mcall |
} |
macro eth.read_byte socket, result { |
mov ecx, socket |
mov ebx, 3 |
mov eax, 53 |
mcall |
mov result,bl |
} |
macro eth.read_packet socket, result, buffersize { |
mov esi, buffersize |
mov edx, result |
mov ecx, socket |
mov ebx, 11 |
mov eax, 53 |
mcall |
} |
macro eth.write_udp socket,length,msg,verify { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
mov ebx, 4 |
mov eax, 53 |
mcall |
if verify eq 1 |
call verifysend |
end if |
} |
verifysend: |
test eax,eax |
jnz @f |
ret |
@@: |
pusha |
mov eax,5 |
mov ebx,100 |
mcall |
popa |
mcall |
ret |
macro eth.open_tcp local,remote,ip,passive,socket { |
mov ecx, local |
mov edx, remote |
mov esi, ip |
mov edi, passive ; 0 = PASSIVE open |
mov ebx, 5 |
mov eax, 53 |
mcall |
mov socket,eax |
} |
macro eth.socket_status socket,result { |
mov ecx, socket |
mov ebx, 6 |
mov eax, 53 |
mcall |
mov result,eax |
} |
macro eth.write_tcp socket,length,msg,verify { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
mov ebx, 7 |
mov eax, 53 |
mcall |
if verify eq 1 |
call verifysend |
end if |
} |
macro eth.read_mac mac { |
mov eax, 52 |
mov ebx, 15 |
xor ecx, ecx |
pusha |
mcall |
mov dword[mac],eax |
popa |
add cl, 4 |
mcall |
mov word[mac+4],ax |
} |
macro eth.close_tcp socket { |
mov ecx, socket |
mov ebx, 8 |
mov eax, 53 |
mcall |
} |
macro eth.check_port port,result { |
mov ecx, port |
mov ebx, 9 |
mov eax, 53 |
mcall |
mov result,eax |
} |
macro eth.check_cable result { |
mov ebx, 10 |
mov eax, 53 |
mcall |
mov result,eax |
} |
macro eth.status status { |
mov ebx, 255 |
mov ecx, 6 |
mov eax, 53 |
mcall |
mov status,eax |
} |
macro eth.search_port port,result { |
mov edx,port |
@@: |
inc edx |
eth.check_port edx,eax |
cmp eax,0 |
je @r |
mov result,edx |
} |
macro eth.ARP_PROBE address{ |
mov edx,address |
mov eax,52 |
mov ebx,16 |
xor ecx,ecx |
mcall |
} |
macro eth.ARP_ANNOUNCE address{ |
mov edx,address |
mov eax,52 |
mov ebx,16 |
xor ecx,ecx |
inc ecx |
mcall |
} |
macro eth.read_data socket,dest,endptr,bufferl { |
local .getdata,.loop,.end |
mov eax, dest |
mov endptr, eax |
.getdata: |
cmp endptr, bufferl |
jg .end |
eth.read_packet socket, endptr, 0 |
add endptr,eax |
test eax, eax |
jnz .getdata |
xor edx, edx |
.loop: |
eth.poll socket |
test eax, eax |
jnz .getdata |
mov eax,5 |
mov ebx,1 |
mcall |
inc edx |
cmp edx,30 |
jl .loop |
.end: |
} |
macro eth.wait_for_data socket,TIMEOUT,abort { |
mov edx,TIMEOUT |
@@: |
eth.poll socket |
cmp eax,0 |
jne @f |
dec edx |
jz abort |
mov eax,5 ; wait here for event |
mov ebx,10 |
mcall |
jmp @r |
@@: |
} |
Ip2dword: |
push edx |
; This code validates if the query is an IP containing 4 numbers and 3 dots |
xor al, al ; make al (dot count) zero |
@@: |
cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP |
jl no_IP ; |
cmp byte[edx],'9' ; |
jg no_IP ; |
inc edx ; the byte was a number, so lets check the next byte |
cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) |
jz @f ; jump to next @@ then |
cmp byte[edx],':' |
jz @f |
cmp byte[edx],'.' ; is this byte a dot? |
jne @r ; if not, jump to previous @@ |
inc al ; the byte was a dot so increment al(dot count) |
inc edx ; next byte |
jmp @r ; lets check for numbers again (jump to previous @@) |
@@: ; we reach this when end of query reached |
cmp al,3 ; check if there where 3 dots |
jnz no_IP ; if not, jump to no_IP |
; The following code will convert this IP into a dword and output it in eax |
; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1 |
pop esi ; edx (query address) was pushed onto stack and is now popped in esi |
xor edx, edx ; result |
xor eax, eax ; current character |
xor ebx, ebx ; current byte |
.outer_loop: |
shl edx, 8 |
add edx, ebx |
xor ebx, ebx |
.inner_loop: |
lodsb |
test eax, eax |
jz .finish |
cmp al, '.' |
jz .outer_loop |
sub eax, '0' |
imul ebx, 10 |
add ebx, eax |
jmp .inner_loop |
.finish: |
shl edx, 8 |
add edx, ebx |
bswap edx ; we want little endian order |
ret |
no_IP: |
pop edx |
xor edx, edx |
ret |
/programs/network_old/zeroconf/trunk/debug-fdo.inc |
---|
0,0 → 1,422 |
; |
; Formatted Debug Output (FDO) |
; Copyright (c) 2005-2006, mike.dld |
; Created: 2005-01-29, Changed: 2006-11-10 |
; |
; For questions and bug reports, mail to mike.dld@gmail.com |
; |
; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
; |
; to be defined: |
; __DEBUG__ equ 1 |
; __DEBUG_LEVEL__ equ 5 |
macro debug_func name { |
if used name |
name@of@func equ name |
} |
macro debug_beginf { |
align 4 |
name@of@func: |
} |
debug_endf fix end if |
macro DEBUGS _sign,[_str] { |
common |
local tp |
tp equ 0 |
match _arg:_num,_str \{ |
DEBUGS_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _str \{ |
DEBUGS_N _sign,,_arg |
\} |
} |
macro DEBUGS_N _sign,_num,[_str] { |
common |
pushf |
pushad |
local ..str,..label,is_str |
is_str = 0 |
forward |
if _str eqtype '' |
is_str = 1 |
end if |
common |
if is_str = 1 |
jmp ..label |
..str db _str,0 |
..label: |
add esp,4*8+4 |
mov edx,..str |
sub esp,4*8+4 |
else |
mov edx,_str |
end if |
if ~_num eq |
if _num eqtype eax |
if _num in <eax,ebx,ecx,edx,edi,ebp,esp> |
mov esi,_num |
else if ~_num eq esi |
movzx esi,_num |
end if |
else if _num eqtype 0 |
mov esi,_num |
else |
local tp |
tp equ 0 |
match [_arg],_num \{ |
mov esi,dword[_arg] |
tp equ 1 |
\} |
match =0 =dword[_arg],tp _num \{ |
mov esi,dword[_arg] |
tp equ 1 |
\} |
match =0 =word[_arg],tp _num \{ |
movzx esi,word[_arg] |
tp equ 1 |
\} |
match =0 =byte[_arg],tp _num \{ |
movzx esi,byte[_arg] |
tp equ 1 |
\} |
match =0,tp \{ |
'Error: specified string width is incorrect' |
\} |
end if |
else |
mov esi,0x7FFFFFFF |
end if |
call fdo_debug_outstr |
popad |
popf |
} |
macro DEBUGD _sign,_dec { |
local tp |
tp equ 0 |
match _arg:_num,_dec \{ |
DEBUGD_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _dec \{ |
DEBUGD_N _sign,,_arg |
\} |
} |
macro DEBUGD_N _sign,_num,_dec { |
pushf |
pushad |
if (~_num eq) |
if (_dec eqtype eax | _dec eqtype 0) |
'Error: precision allowed only for in-memory variables' |
end if |
if (~_num in <1,2,4>) |
if _sign |
'Error: 1, 2 and 4 are only allowed for precision in %d' |
else |
'Error: 1, 2 and 4 are only allowed for precision in %u' |
end if |
end if |
end if |
if _dec eqtype eax |
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> |
mov eax,_dec |
else if ~_dec eq eax |
if _sign = 1 |
movsx eax,_dec |
else |
movzx eax,_dec |
end if |
end if |
else if _dec eqtype 0 |
mov eax,_dec |
else |
add esp,4*8+4 |
if _num eq |
mov eax,dword _dec |
else if _num = 1 |
if _sign = 1 |
movsx eax,byte _dec |
else |
movzx eax,byte _dec |
end if |
else if _num = 2 |
if _sign = 1 |
movsx eax,word _dec |
else |
movzx eax,word _dec |
end if |
else |
mov eax,dword _dec |
end if |
sub esp,4*8+4 |
end if |
mov cl,_sign |
call fdo_debug_outdec |
popad |
popf |
} |
macro DEBUGH _sign,_hex { |
local tp |
tp equ 0 |
match _arg:_num,_hex \{ |
DEBUGH_N _sign,_num,_arg |
tp equ 1 |
\} |
match =0 _arg,tp _hex \{ |
DEBUGH_N _sign,,_arg |
\} |
} |
macro DEBUGH_N _sign,_num,_hex { |
pushf |
pushad |
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) |
'Error: 1..8 are only allowed for precision in %x' |
end if |
if _hex eqtype eax |
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
if ~_hex eq eax |
mov eax,_hex |
end if |
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> |
if ~_hex eq ax |
movzx eax,_hex |
end if |
shl eax,16 |
if (_num eq) |
mov edx,4 |
end if |
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> |
if ~_hex eq al |
movzx eax,_hex |
end if |
shl eax,24 |
if (_num eq) |
mov edx,2 |
end if |
end if |
else if _hex eqtype 0 |
mov eax,_hex |
else |
add esp,4*8+4 |
mov eax,dword _hex |
sub esp,4*8+4 |
end if |
if ~_num eq |
mov edx,_num |
else |
mov edx,8 |
end if |
call fdo_debug_outhex |
popad |
popf |
} |
;----------------------------------------------------------------------------- |
debug_func fdo_debug_outchar |
debug_beginf |
pushad |
mov cl,al |
mov ebx,1 |
mov eax,63 |
mcall |
popad |
ret |
debug_endf |
debug_func fdo_debug_outstr |
debug_beginf |
mov eax,63 |
mov ebx,1 |
.l1: dec esi |
js .l2 |
mov cl,[edx] |
or cl,cl |
jz .l2 |
mcall |
inc edx |
jmp .l1 |
.l2: ret |
debug_endf |
debug_func fdo_debug_outdec |
debug_beginf |
or cl,cl |
jz @f |
or eax,eax |
jns @f |
neg eax |
push eax |
mov al,'-' |
call fdo_debug_outchar |
pop eax |
@@: push 10 |
pop ecx |
push -'0' |
.l1: xor edx,edx |
div ecx |
push edx |
test eax,eax |
jnz .l1 |
.l2: pop eax |
add al,'0' |
jz .l3 |
call fdo_debug_outchar |
jmp .l2 |
.l3: ret |
debug_endf |
debug_func fdo_debug_outhex |
__fdo_hexdigits db '0123456789ABCDEF' |
debug_beginf |
mov cl,dl |
neg cl |
add cl,8 |
shl cl,2 |
rol eax,cl |
.l1: rol eax,4 |
push eax |
and eax,0x0000000F |
mov al,[__fdo_hexdigits+eax] |
call fdo_debug_outchar |
pop eax |
dec edx |
jnz .l1 |
ret |
debug_endf |
;----------------------------------------------------------------------------- |
macro DEBUGF _level,_format,[_arg] { |
common |
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
_debug_str_ equ __debug_str_ # a1 |
a1 = 0 |
c2 = 0 |
c3 = 0 |
f2 = 0 |
repeat ..lbl-..f1 |
virtual at 0 |
db _format,0,0 |
load c1 word from %-1 |
end virtual |
if c1 = '%s' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER S,a1,0,_arg |
else if c1 = '%x' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER H,a1,0,_arg |
else if c1 = '%d' | c1 = '%u' |
local c4 |
if c1 = '%d' |
c4 = 1 |
else |
c4 = 0 |
end if |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER D,a1,c4,_arg |
else if c1 = '\n' |
c3 = c3 + 1 |
end if |
end repeat |
virtual at 0 |
db _format,0,0 |
load c1 from f2-c2 |
end virtual |
if (c1<>0)&(f2<>..lbl-..f1-1) |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
virtual at 0 |
..f1 db _format,0 |
..lbl: |
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
end virtual |
end if |
} |
macro __include_debug_strings dummy,[_id,_fmt,_len] { |
common |
local c1,a1,a2 |
forward |
if defined _len & ~_len eq |
_id: |
a1 = 0 |
a2 = 0 |
repeat _len |
virtual at 0 |
db _fmt,0,0 |
load c1 word from %+a2-1 |
end virtual |
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
db 0 |
a2 = a2 + 1 |
else if (c1='\n') |
dw $0A0D |
a1 = a1 + 1 |
a2 = a2 + 1 |
else |
db c1 and 0x0FF |
end if |
end repeat |
db 0 |
end if |
} |
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
common |
local num |
num = 0 |
forward |
if num = _num |
DEBUG#_letter _sign,_arg |
end if |
num = num+1 |
common |
_num = _num+1 |
} |
macro include_debug_strings { |
if __DEBUG__ = 1 |
match dbg_str,__debug_strings \{ |
__include_debug_strings dbg_str |
\} |
end if |
} |
/programs/network_old/zeroconf/trunk/dhcp.inc |
---|
0,0 → 1,263 |
;Name Number Length Meaning |
dhcp_pad_option equ 0 ; 0 None |
dhcp_end_option equ 255 ; 0 None |
dhcp_subnet_mask equ 1 ; 4 Subnet Mask Value |
dhcp_time_offset equ 2 ; 4 Time Offset in Seconds from UTC |
dhcp_router equ 3 ; N×4 Router addresses |
dhcp_time_server equ 4 ; N×4 Timeserver addresses |
dhcp_name_server equ 5 ; N×4 IEN-116 Server addresses |
dhcp_domain_server equ 6 ; N×4 DNS Server addresses |
dhcp_log_server equ 7 ; N×4 Logging Server addresses |
dhcp_quotes_server equ 8 ; N×4 Quotes Server addresses |
dhcp_lpr_server equ 9 ; N×4 Printer Server addresses |
dhcp_impress_server equ 10 ; N×4 Impress Server addresses |
dhcp_rlp_server equ 11 ; N×4 N RLP Server addresses |
dhcp_hostname equ 12 ; N Hostname string |
dhcp_boot_file_size equ 13 ; 2 Size of boot file in 512-octet blocks |
dhcp_merit_dump_file equ 14 ; N Client to dump and name the file to dump it to |
dhcp_domain_name equ 15 ; N The DNS domain name of the client |
dhcp_swap_server equ 16 ; 4 Swap Server address |
dhcp_root_path equ 17 ; N Path name for root disk |
dhcp_extension_file equ 18 ; N Path name for more BOOTP info |
;IP Layer Parameters per Host |
dhcp_forward equ 19 ; 1 Enable/Disable IP Forwarding |
dhcp_srcrte equ 20 ; 1 Enable/Disable Non-Local Source Routing |
dhcp_policy equ 21 ; N×8 Non-Local Source Routing Policy Filters |
dhcp_mag_dg_assembly equ 22 ; 2 Max Datagram Reassembly Size |
dhcp_default_ip_tll equ 23 ; 1 Default IP Time to Live |
dhcp_mtu_timeout equ 24 ; 4 Path MTU Aging Timeout |
dhcp_mtu_plateau equ 25 ; N×2 Path MTU Plateau Table |
;IP Layer Parameters per Interface |
dhcp_mtu_interface equ 26 ; 2 Interface MTU Size |
dhcp_mtu_subnet equ 27 ; 1 All Subnets are Local |
dhcp_broadcast_address equ 28 ; 4 Broadcast Address |
dhcp_mask_discovery equ 29 ; 1 Perform Mask Discovery |
dhcp_mask_supplier equ 30 ; 1 Provide Mask to Others |
dhcp_router_discovery equ 31 ; 1 Perform Router Discovery |
dhcp_router_request equ 32 ; 4 Router Solicitation Address |
dhcp_static_route equ 33 ; N×8 Static Routing Table |
;Link Layer Parameters per Interface |
dhcp_trailers equ 34 ; 1 Trailer Encapsulation |
dhcp_arp_timeout equ 35 ; 4 ARP Cache Timeout |
dhcp_ethernet equ 36 ; 1 Ethernet Encapsulation |
;TCP Parameters |
dhcp_default_tcp_tll equ 37 ; 1 Default TCP Time to Live |
dhcp_keepalive_time equ 38 ; 4 TCP Keepalive Interval |
dhcp_keepalive_data equ 39 ; 1 TCP Keepalive Garbage |
;Application and Service Parameters |
dhcp_nis_domain equ 40 ; N NIS Domain Name |
dhcp_nis_servers equ 41 ; N×4 NIS Server Addresses |
dhcp_ntp_servers equ 42 ; N×4 NTP Server Addresses |
dhcp_vendor_specific equ 43 ; N Vendor Specific Information |
dhcp_netbios_name_srv equ 44 ; N×4 NETBIOS Name Servers |
dhcp_netbios_dist_srv equ 45 ; N×4 NETBIOS Datagram Distribution |
dhcp_netbios_node_type equ 46 ; 1 NETBIOS Node Type |
dhcp_netbios_scope equ 47 ; N NETBIOS Scope |
dhcp_x_window_font equ 48 ; N×4 X Window Font Server |
dhcp_x_window_manager equ 49 ; N×4 X Window Display Manager |
dhcp_nis_domain_name equ 64 ; N NIS+ v3 Client Domain Name |
dhcp_nis_server_addr equ 65 ; N×4 NIS+ v3 Server Addresses |
dhcp_home_agent_addrs equ 68 ; N×4 Mobile IP Home Agent Addresses |
dhcp_smtp_server equ 69 ; N×4 Simple Mail Server Addresses |
dhcp_pop3_server equ 70 ; N×4 Post Office Server Addresses |
dhcp_nntp_server equ 71 ; N×4 Network News Server Addresses |
dhcp_www_server equ 72 ; N×4 WWW Server Addresses |
dhcp_finger_server equ 73 ; N×4 Finger Server Addresses |
dhcp_irc_server equ 74 ; N×4 Chat Server Addresses |
dhcp_streettalk_server equ 75 ; N×4 StreetTalk Server Addresses |
dhcp_stda_server equ 76 ; N×4 ST Directory Assist. Addresses |
;DHCP Extensions |
dhcp_address_request equ 50 ; 4 Requested IP Address |
dhcp_address_time equ 51 ; 4 IP Address Lease Time |
dhcp_option_overload equ 52 ; 1 Overload "sname" or "file" |
dhcp_msg_type equ 53 ; 1 DHCP Message Type |
dhcp_dhcp_server_id equ 54 ; 4 DHCP Server Identification |
dhcp_parameter_list equ 55 ; N Parameter Request List |
dhcp_dhcp_message equ 56 ; N DHCP Error Message |
dhcp_dhcp_max_msg_size equ 57 ; 2 DHCP Maximum Message Size |
dhcp_renewal_time equ 58 ; 4 DHCP Renewal (T1) Time |
dhcp_rebinding_time equ 59 ; 4 DHCP Rebinding (T2) Time |
dhcp_class_id equ 60 ; N Vendor Class Identifier |
dhcp_client_id equ 61 ; N Client Identifier |
dhcp_server_name equ 66 ; N TFTP Server Name |
dhcp_bootfile_name equ 67 ; N Boot File Name |
;Newer extensions |
dhcp_netware_ip_domain equ 62 ; N Netware/IP Domain Name |
dhcp_netware_ip_option equ 63 ; N Netware/IP sub Options |
dhcp_user_class equ 77 ; N User Class Information |
dhcp_directory_agent equ 78 ; N directory agent information |
dhcp_service_scope equ 79 ; N service location agent scope |
dhcp_rapid_commit equ 80 ; 0 Rapid Commit |
dhcp_client_fqdn equ 81 ; N Fully Qualified Domain Name |
dhcp_relay_agent_info equ 82 ; N Relay Agent Information, RFC 3046 |
dhcp_isns equ 83 ; N Internet Storage Name Service |
; 84 REMOVED/Unassigned |
dhcp_nds_servers equ 85 ; N Novell Directory Services |
dhcp_nds_tree_name equ 86 ; N Novell Directory Services |
dhcp_nds_conext equ 87 ; N Novell Directory Services |
dhcp_bcmcs equ 88 ; Controller Domain Name list |
dhcp_bcmcs equ 89 ; Controller IPv4 address option |
dhcp_authentication equ 90 ; N Authentication |
; 91 REMOVED/Unassigned |
; 92 REMOVED/Unassigned |
dhcp_client_system equ 93 ; N Client System Architecture |
dhcp_client_ndi equ 94 ; N Client Network Device Interface |
dhcp_ldap equ 95 ; N Lightweight Directory Access Protocol |
; 96 REMOVED/Unassigned |
dhcp_uuid_guid equ 97 ; N UUID/GUID-based Client Identifier |
dchp_user_auth equ 98 ; N Open Group's User Authentication |
; 99 REMOVED/Unassigned |
; 100 REMOVED/Unassigned |
; 101 REMOVED/Unassigned |
; 102 REMOVED/Unassigned |
; 103 REMOVED/Unassigned |
; 104 REMOVED/Unassigned |
; 105 REMOVED/Unassigned |
; 106 REMOVED/Unassigned |
; 107 REMOVED/Unassigned |
; 108 REMOVED/Unassigned |
; 109 REMOVED/Unassigned |
; 110 REMOVED/Unassigned |
; 111 REMOVED/Unassigned |
dhcp_netinfo_address equ 112 ; N NetInfo Parent Server Address |
dhcp_netinfo_tag equ 113 ; N NetInfo Parent Server Tag |
dhcp_url equ 114 ; N URL |
; 115 REMOVED/Unassigned |
dhcp_auto_config equ 116 ; N DHCP Auto-Configuration |
dhcp_ns_search equ 117 ; N Name Service Search |
dhcp_subnet_selection equ 118 ; 4 Subnet Selection Option |
dhcp_domain_search equ 119 ; N DNS domain search list |
dhcp_sip_servers equ 120 ; N SIP Servers DHCP Option |
dhcp_cl_static_route equ 121 ; N Classless Static Route Option |
dhcp_ccc equ 122 ; N CableLabs Client Configuration |
dhcp_geoconf equ 123 ; 16 GeoConf Option |
dhcp_v_i_vendor_class equ 124 ; Vendor-Identifying Vendor Class |
dhcp_v_i_vendor_spec equ 125 ; Vendor-Identifying Vendor-Specific |
; 126 REMOVED/Unassigned |
; 127 REMOVED/Unassigned |
dhcp_pxe equ 128 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot_sign equ 128 ; Etherboot signature. 6 bytes: E4:45:74:68:00:00 |
dhcp_docsis equ 128 ; DOCSIS "full security" server IP address |
dhcp_tftp_server_ip equ 128 ; TFTP Server IP address (for IP Phone software load) |
dhcp_pxe equ 129 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_kernel_options equ 129 ; Kernel options. Variable length string |
dhcp_call_server_ip equ 129 ; Call Server IP address |
dhcp_pxe equ 130 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_ethernet_interface equ 130 ; Ethernet interface. Variable length string. |
dhcp_siscrimination equ 130 ; Discrimination string (to identify vendor) |
dhcp_pxe equ 131 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_remote_stat_server equ 131 ; Remote statistics server IP address |
dhcp_pxe equ 132 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_802.1p equ 132 ; 802.1P VLAN ID |
dhcp_pxe equ 133 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_802.1q equ 133 ; 802.1Q L2 Priority |
dhcp_pxe equ 134 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_diffserv equ 134 ; Diffserv Code Point |
dhcp_pxe equ 135 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) |
dhcp_http_proxy_psa equ 135 ; HTTP Proxy for phone-specific applications |
; 136 REMOVED/Unassigned |
; 137 REMOVED/Unassigned |
; 138 REMOVED/Unassigned |
; 139 REMOVED/Unassigned |
; 140 REMOVED/Unassigned |
; 141 REMOVED/Unassigned |
; 142 REMOVED/Unassigned |
; 143 REMOVED/Unassigned |
; 144 REMOVED/Unassigned |
; 145 REMOVED/Unassigned |
; 146 REMOVED/Unassigned |
; 147 REMOVED/Unassigned |
; 148 REMOVED/Unassigned |
; 149 REMOVED/Unassigned |
dhcp_tftp_server_addr equ 150 ; TFTP server address (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot equ 150 ; Etherboot |
dhcp_grub_conf_path equ 150 ; GRUB configuration path name |
; 151 REMOVED/Unassigned |
; 152 REMOVED/Unassigned |
; 153 REMOVED/Unassigned |
; 154 REMOVED/Unassigned |
; 155 REMOVED/Unassigned |
; 156 REMOVED/Unassigned |
; 157 REMOVED/Unassigned |
; 158 REMOVED/Unassigned |
; 159 REMOVED/Unassigned |
; 160 REMOVED/Unassigned |
; 161 REMOVED/Unassigned |
; 162 REMOVED/Unassigned |
; 163 REMOVED/Unassigned |
; 164 REMOVED/Unassigned |
; 165 REMOVED/Unassigned |
; 166 REMOVED/Unassigned |
; 167 REMOVED/Unassigned |
; 168 REMOVED/Unassigned |
; 169 REMOVED/Unassigned |
; 170 REMOVED/Unassigned |
; 171 REMOVED/Unassigned |
; 172 REMOVED/Unassigned |
; 173 REMOVED/Unassigned |
; 174 REMOVED/Unassigned |
dhcp_etherboot equ 175 ; Etherboot (Tentatively Assigned - 23 June 2005) |
dhcp_ip_telephone equ 176 ; IP Telephone (Tentatively Assigned - 23 June 2005) |
dhcp_etherboot equ 177 ; Etherboot (Tentatively Assigned - 23 June 2005) |
dhcp_packetcable equ 177 ; PacketCable and CableHome (replaced by 122) |
; 178 REMOVED/Unassigned |
; 179 REMOVED/Unassigned |
; 180 REMOVED/Unassigned |
; 181 REMOVED/Unassigned |
; 182 REMOVED/Unassigned |
; 183 REMOVED/Unassigned |
; 184 REMOVED/Unassigned |
; 185 REMOVED/Unassigned |
; 186 REMOVED/Unassigned |
; 187 REMOVED/Unassigned |
; 188 REMOVED/Unassigned |
; 189 REMOVED/Unassigned |
; 190 REMOVED/Unassigned |
; 191 REMOVED/Unassigned |
; 192 REMOVED/Unassigned |
; 193 REMOVED/Unassigned |
; 194 REMOVED/Unassigned |
; 195 REMOVED/Unassigned |
; 196 REMOVED/Unassigned |
; 197 REMOVED/Unassigned |
; 198 REMOVED/Unassigned |
; 199 REMOVED/Unassigned |
; 200 REMOVED/Unassigned |
; 201 REMOVED/Unassigned |
; 202 REMOVED/Unassigned |
; 203 REMOVED/Unassigned |
; 204 REMOVED/Unassigned |
; 205 REMOVED/Unassigned |
; 206 REMOVED/Unassigned |
; 207 REMOVED/Unassigned |
dhcp_pxelinux.magic equ 208 ; pxelinux.magic (string) = F1:00:74:7E (241.0.116.126) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.conffile equ 209 ; pxelinux.configfile (text) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.path equ 210 ; pxelinux.pathprefix (text) (Tentatively Assigned - 23 June 2005) |
dhcp_pxelinux.reboot equ 211 ; pxelinux.reboottime (unsigned integer 32 bits) (Tentatively Assigned - 23 June 2005) |
; 212 REMOVED/Unassigned |
; 213 REMOVED/Unassigned |
; 214 REMOVED/Unassigned |
; 215 REMOVED/Unassigned |
; 216 REMOVED/Unassigned |
; 217 REMOVED/Unassigned |
; 218 REMOVED/Unassigned |
; 219 REMOVED/Unassigned |
dhcp_subnet_aloc equ 220 ; Subnet Allocation Option (Tentatively Assigned - 23 June 2005) |
dhcp_virtual_subnet equ 221 ; Virtual Subnet Selection Option (Tentatively Assigned - 23 June 2005) |
; 222 REMOVED/Unassigned |
; 223 REMOVED/Unassigned |
/programs/network_old/zeroconf/trunk/zeroconf.ini |
---|
0,0 → 1,9 |
[ipconfig] |
; type should be static or zeroconf |
; zeroconf means the service first tries to contact a DHCP server |
; If dhcp is not available, it switches to link-local |
type = static |
ip = 192.168.1.150 |
gateway = 192.168.1.1 |
dns = 192.168.1.1 |
subnet = 255.255.255.0 |
/programs/network_old/zeroconf/trunk |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network_old/zeroconf |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network_old/icq/trunk/cmdipc.inc |
---|
0,0 → 1,221 |
include "MACROS.INC" |
initipc: |
mov eax,9 |
mov ebx,prc |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loop1: |
push ecx |
mov eax,9 |
mov ebx,prc |
int 0x40 |
cmp word [prc+10],'CM' |
jne no_cmd |
cmp byte [prc+12],'D' |
jne no_cmd |
mov ebx,[prc+30] |
mov dword [cmdpid],ebx |
mov dword [cmdnumb],ecx |
no_cmd: |
pop ecx |
loop loop1 |
cmp dword [cmdpid],0 |
jne no_exit |
jmp exit |
no_exit: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,printf |
mov esi,4 |
int 0x40 |
call initcmd |
waitcmdinit: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,23 |
mov ebx,100 |
int 0x40 |
cmp eax,7 |
je cmd_ok |
jmp exit |
cmd_ok: |
cmp byte [ipcb+16],'.' |
jne exit |
mov eax,18 |
mov ebx,3 |
mov ecx,dword [cmdnumb] |
int 0x40 |
ret |
pause1: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
ret |
exit: |
mov eax,-1 |
int 0x40 |
cls: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipccls |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
print: |
mov ecx,84 |
loopprt: |
mov edi,stripc |
add edi,ecx |
mov esi,fill_symbol |
movsb |
loop loopprt |
cld |
mov ecx,4 |
mov edi,stripc |
mov esi,printf |
rep movsb |
cld |
mov edx,79 |
sub edx,eax |
mov ecx,79 |
sub ecx,edx |
mov edi,stripc+4 |
mov esi,ebx |
rep movsb |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,stripc |
mov esi,84 |
int 0x40 |
call pause1 |
ret |
eol: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipceol |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
initcmd: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipckey |
mov esi,4 |
int 0x40 |
mov eax,60 |
mov ebx,1 |
mov ecx,ipcb |
mov edx,28 |
int 0x40 |
cld |
mov ecx,28 |
mov edi,ipcb |
mov esi,ipcc |
rep movsb |
ret |
getkey: |
call initcmd |
waitagain: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,10 |
int 0x40 |
cmp eax,7 |
jne waitagain |
mov edi,key |
mov esi,ipcb+16 |
movsb |
ret |
endipc: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipcend |
mov esi,4 |
int 0x40 |
jmp exit |
cmdpid dd 0 |
cmdnumb dd 0 |
printf db '~ppp' |
ipceol db '~lll' |
ipcend db '~eee' |
ipccls db '~ccc' |
ipckey db '~kkk' |
key db 0 |
ipcb: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
ipcc: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
stripc: times 84 db 0 |
fill_symbol db 0 |
prc: times 52 db 0 |
/programs/network_old/icq/trunk/editbox.inc |
---|
0,0 → 1,275 |
; SEE YOU File FAQ.txt and HISTORY. Good Like! |
;;;;;;;;;;;;;;;;;; |
include 'editbox.mac' ;¬ ªà®á ª®â®àë© ¤®«¦¥ ®¡«¥£ç¨âì ¦¨§ì :) á¯¥æ¨ «ì® ¤«ï editbox |
;;;;;;;;;;;;;;;;;; |
macro use_edit_box procinfo,scr_h,scr_w |
{ |
edit_box: |
ed_width equ [edi] ;è¨à¨ ª®¬¯®¥â |
ed_left equ [edi+4] ;¯®«®¦¥¨¥ ¯® ®á¨ å |
ed_top equ [edi+8] ;¯®«®¦¥¨¥ ¯® ®á¨ ã |
ed_color equ [edi+12] ;梥â ä® ª®¬¯®¥â |
shift_color equ [edi+16] ;=0x6a9480 |
ed_focus_border_color equ [edi+20] ;梥â à ¬ª¨ ª®¬¯®¥â |
ed_blur_border_color equ [edi+24] ;梥⠥ ªâ¨¢®£® ª®¬¯®¥â |
ed_text_color equ [edi+28] ;梥â ⥪áâ |
ed_max equ [edi+32] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦® ¬ ªá¨¬ «ì® ¢¢¥á⨠|
ed_text equ [edi+36] ;㪠§ â¥«ì ¡ãä¥à |
ed_flags equ [edi+40] ;ä« £¨ |
ed_size equ [edi+42] ;ª®«-¢® ᨬ¢®«®¢ |
ed_pos equ [edi+46] ;¯®§¨æ¨ï ªãàá®à |
ed_offset equ [edi+50] ;ᬥ饨¥ |
cl_curs_x equ [edi+54] ;¯à¥¤ë¤ã饥 ª®®à¤¨ â ªãàá®à ¯® å |
cl_curs_y equ [edi+58] ;¯à¥¤ë¤ã饥 ª®®à¤¨ â ªãàá®à ¯® ã |
ed_shift_pos equ [edi+62] ;¯®«®¦¥¨¥ ªãàá®à |
ed_shift_pos_old equ [edi+66] ;áâ ஥ ¯®«®¦¥¨¥ ªãàá®à |
;========================================================== |
;=== ¯à®æ¥¤ãà ¯à®à¨á®¢ª¨ ================================= |
;========================================================== |
.draw: |
pusha |
;--- à¨á㥬 à ¬ªã --- |
call .draw_border ; ãªæ¨ï áâ ¡¨«ì |
.draw_bg_cursor_text: |
;--- ¨§¬¥ï¥¬ ᬥ饨¥, ¥á«¨ ¤® --- |
call .check_offset ;¢ëç¨á«¥¨¥ ¯®§¨æ¨¨ ªãàá®à áâ ¡¨«ì |
;--- à¨á㥬 ¢ãâà¥îî ®¡« áâì --- |
call .draw_bg ; à¨á®¢ âì ¯àאַ㣮«ì¨ª à ¡®ç¥© ®¡« á⨠|
;---- à¨á㥬 ¢ë¤¥«¥¨¥, ¯® shift ¥á«¨ ¥áâì |
call .draw_shift |
.draw_cursor_text: |
;--- à¨á㥬 ªãàá®à --- |
;--- ¬®¦¥â ¥£® ¥ ¤® à¨á®¢ âì ---- |
test word ed_flags,ed_focus |
je @f |
call .draw_cursor |
@@: |
call .draw_text |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
;¡é¨© ¢ë室 ¨§ editbox ¤«ï ¢á¥å äãªæ¨© ¨ ¯®áâ ®¡à ¡®â稪®¢ |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
.editbox_exit: |
edit_ex |
;========================================================== |
;=== ®¡à ¡®âª ª« ¢¨ âãàë ================================= |
;========================================================== |
.key: |
pusha |
test word ed_flags,ed_focus ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
je .editbox_exit |
;஢¥àª ¦ â shift ? |
call .check_shift |
;---------------------------------------------------------- |
;--- ¯à®¢¥à塞, çâ® ¦ â® -------------------------------- |
;---------------------------------------------------------- |
use_key_process backspase,delete,left,right,home,end,insert |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; £«ãèª ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢¨§ â.¥. ¯à¨ ®¡ à㦥¨¨ íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_key_no_process up,down,esc |
;--- ¦ â ¤àã£ ï ª« ¢¨è --- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;஢¥àª ãáâ ®¢«¥ «¨ ä« £ ¯à¨ ª®â®à®¬ 㦮 ¢ë¢®¤¨âì ⮫쪮 æ¨äàë ¢ 㦮¬ ¡®ªá¥ ¥á«¨ â ª®©¥®¡å®¤¨¬®á⨠¥â 㦮 § ª®¬¥â¨à®¢ âì ¬ ªà®á |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_key_figures_only |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;¯à®¢¥àª shift ¡ë« «¨ ¦ â |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
are_key_shift_press |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ¯à®¢¥à塞, 室¨âáï «¨ ªãàá®à ¢ ª®æ¥ + ¤ «ì¥©è ï ®¡à ¡®âª |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
are_key_cur_end |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;¡à ¡®âª ª« ¢¨è insert,delete.backspase,home,end,left,right |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_work_key |
;========================================================== |
;=== ®¡à ¡®âª ¬ëè¨ ======================================= |
;========================================================== |
.mouse: |
pusha |
;debug |
;---------------------------------------------------------- |
;--- ¯®«ãç ¥¬ á®áâ®ï¨¥ ª®¯®ª ¬ëè¨ ----------------------- |
;---------------------------------------------------------- |
mcall 37,2 |
;---------------------------------------------------------- |
;--- ¯à®¢¥à塞 á®áâ®ï¨¥ ---------------------------------- |
;---------------------------------------------------------- |
test eax,1 |
jnz .mouse_left_button |
and word ed_flags,ed_mouse_on_off |
xor ebx,ebx |
mov dword [mouse_flag],ebx |
jmp .editbox_exit |
.mouse_left_button: |
;---------------------------------------------------------- |
;--- ¡«®ª¨à®¢ª ®â 䮪ãá¨à®¢ª¨ ¢ ¤àã£¨å ¡®ªá å ¯à¨ ¯®¯ ¤ ¨¨ ¨å ªãàá®à |
;---------------------------------------------------------- |
mov eax,dword [mouse_flag] |
test eax,eax |
jz @f |
cmp eax,edi |
je @f |
jmp ._blur |
;---------------------------------------------------------- |
;--- ¯®«ãç ¥¬ ª®®à¤¨ âë ¬ëè¨ ®â®á¨â¥«ì® 0 â.¥ ¢á¥© ®¡« á⨠íªà |
;---------------------------------------------------------- |
@@: mcall 37,0 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;ãªæ¨ï ®¡à ¡®âª¨ ¬ë誨 ¯®«ã票¥ ª®®à¤¨ â ¨ ¯à®¢¥àª ¨å + ¢ë¤¥«¥¨ï |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_work_mause scr_h,scr_w |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;¡é¨¥ äãªæ¨¨ ®¡à ¡®âª¨ |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_general_func |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;ãªæ¨¨ ¤«ï à ¡®âë á key |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_key_func |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;ãªæ¨¨ ¤«ï à ¡®âë á mouse |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use_mouse_func scr_w |
} |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;Bit mask from editbox |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ed_figure_only= 1000000000000000b ;®¤¨ ᨬ¢®«ë |
ed_always_focus= 100000000000000b |
ed_focus= 10b ;䮪ãá ¯à¨«®¦¥¨ï |
ed_shift_on= 1000b ;¥á«¨ ¥ ãáâ ®¢«¥ -§ ç¨â ¢¯¥à¢ë¥ ¦ â shift,¥á«¨ ¡ë« ãáâ ®¢«¥, § ç¨â ¬ë 㦥 çâ® - â® ¤¥« «¨ 㤥ন¢ ï shift |
ed_shift_on_off=1111111111110111b |
ed_shift= 100b ;¢ª«îç ¥âáï ¯à¨ ¦ ⨨ shift â.¥. ¥á«¨ ¦¨¬ î |
ed_shift_off= 1111111111111011b |
ed_shift_bac= 10000b ;¡¨â ¤«ï ®ç¨á⪨ ¢ë¤¥«¥®£® shift â.¥. ¯à¨ ãáâ ®¢ª¥ £®¢®à¨â çâ® ¥áâì ¢ë¤¥«¥¨¥ |
ed_shift_bac_cl=1111111111101111b ;®ç¨á⪠¯à¨ 㤠«¥¨¨ ¢ë¤¥«¥¨ï |
ed_shift_cl= 1111111111100011b |
ed_shift_mcl= 1111111111111011b |
ed_left_fl= 100000b |
ed_right_fl= 1111111111011111b |
ed_offset_fl= 1000000b |
ed_offset_cl= 1111111110111111b |
ed_insert= 10000000b |
ed_insert_cl= 1111111101111111b |
ed_mouse_on = 100000000b |
ed_mous_adn_b= 100011000b |
ed_mouse_on_off=1111111011111111b |
ed_height=14 ; ¢ëá®â |
macro draw_edit_boxes start,_end,use_f9,procinfo |
{ |
if use_f9 eq |
else |
mcall 9,procinfo,-1 |
end if |
mov edi,start |
mov ecx,((_end-start)/ed_struc_size) |
@@: |
call edit_box.draw |
add edi,ed_struc_size |
loop @b |
} |
macro mouse_edit_boxes start,_end |
{ |
mov edi,start |
mov ecx,((_end-start)/ed_struc_size) |
@@: |
call edit_box.mouse |
add edi,ed_struc_size |
loop @b |
} |
macro key_edit_boxes start,end |
{ |
mov edi,start |
mov ecx,((end-start)/ed_struc_size) |
@@: |
call edit_box.key |
add edi,ed_struc_size |
loop @b |
} |
ed_struc_size=70 |
struc edit_box width,left,top,color,shift_color,focus_border_color,\ |
blur_border_color,text_color,max,text,flags,size,pos |
{ |
.width dd width |
.left dd left |
.top dd top |
.color dd color |
.shift_color dd shift_color |
.focus_border_color dd focus_border_color |
.blur_border_color dd blur_border_color |
.text_color dd text_color |
.max dd max |
.text dd text |
.flags dw flags+0 |
.size dd size+0 |
.pos dd pos+0 |
.offset dd 0 |
.cl_curs_x dd 0 |
.cl_curs_y dd 0 |
.shift dd 0 |
.shift_old dd 0 |
} |
macro edit_boxes_set_sys_color start,end,color_table |
{ |
mov edi,start |
mov ecx,((end-start)/ed_struc_size) |
mov esi,color_table |
@@: |
mov eax,[esi+36] |
mov ebx,[esi+20] |
mov ed_focus_border_color,eax |
shr bh,1 |
shr bl,1 |
shr ah,1 |
shr al,1 |
add ah,bh |
add al,bl |
ror eax,16 |
ror ebx,16 |
shr bl,1 |
shr al,1 |
add al,bl |
ror eax,16 |
mov ed_blur_border_color,eax |
add edi,ed_struc_size |
loop @b |
} |
macro draw_edit_box ed_ptr,use_f9,procinfo |
{ |
if use_f9 eq |
else |
mcall 9,procinfo,-1 |
end if |
mov edi,ed_ptr |
call edit_box.draw |
} |
macro mouse_edit_box ed_ptr |
{ |
mov edi,ed_ptr |
call edit_box.mouse |
} |
macro key_edit_box ed_ptr |
{ |
mov edi,ed_ptr |
call edit_box.key |
} |
macro default_box ed_ptr |
{ |
pusha |
; xor eax,eax |
; mov ed_shift_pos,eax |
; mov ed_shift_pos_old,eax |
and word ed_flags,ed_shift_cl |
; mov ed_offset,eax |
popa |
} |
/programs/network_old/icq/trunk/ki.asm |
---|
0,0 → 1,4046 |
; compiler: FASM 1.67.21 |
; name: ICQ client for Kolibri |
; version: 0.1.30 |
; written by: LV |
; e-mail: lv4evil@yandex.ru |
include "lang.inc" |
include "macros.inc" |
;purge mov |
;include "ASCL9/ascl.inc" |
;include "../../../debug.inc" |
include "editbox.inc" |
MEOS_APP_START |
;include "../../../debug.inc" |
include "2000.inc" |
include "comp.inc" |
;include "fsio.inc" |
include "dos2win.inc" |
include "parser.inc" |
include "ssi.inc" |
use_edit_box procinfo,22,5 |
; |
; ᫨ == 0, ª®¤ ¤«ï ¨á¯®«ì§®¢ ¨ï ª®â ªâ «¨áâ |
; á¥à¢¥à¥ ¥ áᥬ¡«¨àã¥âáï |
; |
USE_SSI = 1 |
; |
; |
CODE |
;mov eax, 40 |
;mov ebx, 47h |
;int 40h |
; |
; £à㧪 ª®ä¨£®¢ |
; |
mov eax, fname |
call parseconf |
; |
; 뢮¤ § £à㦥®© ¨ä®à¬ 樨 |
; |
mov eax, cfg_message |
xor ebx, ebx |
call writemsg |
call showcfg |
;call loaduin |
call draw_window ; at first create and draw the window |
;call buttonbox |
wait_event: ; main cycle |
;mov eax, 23 |
;mov ebx, 20 |
;int 0x40 |
mcall 23,20 |
cmp eax, 1 ; if event == 1 |
je redraw ; jump to redraw handler |
cmp eax, 2 ; else if event == 2 |
je key ; jump to key handler |
cmp eax, 3 ; else if event == 3 |
je button ; jump to button handler |
; |
; ¤¥¬ ¤ ëå |
; |
mcall 53,2,[socket] |
cmp eax, 0 |
jnz read_socket |
mouse_edit_box inputbox |
; |
; ᫨ ¥áâì ᮥ¤¨¥¨¥ á á¥à¢¥à®¬, ¯®áë« ¥¬ ¯ ª¥âë - ¯®¤â¢¥¦¤¥¨ï ª ¦¤ë¥ 60 á |
; ¥ âॡã¥âáï |
; call sendkeep |
jmp wait_event ; else return to the start of main cycle |
redraw: ; redraw event handler |
call draw_window |
jmp wait_event |
key: ; get key code |
mcall 2 |
cmp ah, 0Dh ; ஡¥« - ®â¯à ¢¨âì á®®¡é¥¨¥ |
jz send |
key_edit_box inputbox |
jmp wait_event |
button: ; button event handler |
;mov eax, 17 ; get button identifier |
;int 0x40 |
mcall 17 |
cmp ah, 2 |
jz connect |
cmp ah, 3 |
jz disconnect |
cmp ah, 4 |
jz send |
; |
; ஢¥à塞, ¥ ¦ â «¨ ª®¯ª ¢ |
; 100 <ID <= 100+UINS |
cmp ah, UINS+100 |
jnc @f |
cmp ah, 100 |
jc @f |
; |
; ¦ â |
; |
sub ah, 100 |
mov [curruser], ah |
; |
; 뢮¤¨¬ áâà®çªã, ª®¬ã |
; |
shr eax, 8 |
and eax, 000000FFh |
push eax |
mov eax, CUSER |
call strlen |
mov ecx, eax |
mov eax, CUSER |
mov ebx, buff |
call strcpy |
pop eax |
mov ebx, NAME_LEN |
imul ebx, eax |
lea eax, [names + ebx] |
mov [buff + ecx], ' ' ; ஡¥« |
lea ebx, [buff + ecx + 1] |
mov ecx, NAME_LEN |
;debug |
push ebx |
mov ebx, NAME_LEN |
call print_mem |
pop ebx |
; |
call strcpy |
mov eax, buff |
xor ebx, ebx |
call writemsg |
@@: |
cmp ah, 1 |
jne wait_event ; return if button id != 1 |
; exit application |
mcall -1 |
draw_window: |
; start drawing |
mcall 12,1 |
mcall 0,(100*65536+700),(100*65536+500),0x14ffffff,0,head |
draw_edit_box inputbox |
rect 10, 30, 500, 450, 0 |
draw_button 600, 460, 60, 15, 2, 'CONNECT' |
;draw_button 600, 460, 60, 15, 3, 'Disconnect' |
draw_button 530, 460, 60, 15, 4, 'SEND' |
call printbuff |
call buttonbox |
; |
; Image |
; |
;mov eax, 7 |
;mov ebx, redicq |
;mov ecx, 15*65536+15 |
;mov edx, 100*65536+100 |
;int 40h |
; finish drawing |
mcall 12,2 |
ret |
; |
; ®¥¤¨¥¨¥ |
; |
connect: |
lea eax, [vtable + vartable.icqip] |
call ip_parser |
call htonl |
data_debug 'IP:', eax |
;mov eax, ICQ_IP |
mov ebx, ICQ_PORT |
call srv_connect |
jmp wait_event |
; |
; |
; |
disconnect: |
mov ecx, [socket] |
call closesocket |
jmp wait_event |
; |
; |
; |
send: |
; |
; ¯à¥¤¥«ï¥¬, ¥ ᬥ¥ «¨ ⥪ã騩 |
; |
; «ï á¬¥ë ¨á¯®«ì§ã¥âáï / ¢ ç «¥ áâப¨ ¨ ®¬¥à 㨠|
; ¯® ¯®à浪ã. ᫨ ¤«¨ > 2 ᨬ¢®«®¢, áç¨â ¥âáï, çâ® ¯¥à¥¤ |
; á ¬ 㨠- ¤«ï ®â¯à ¢ª¨ á®®¡é¥¨© î§¥à ¬, ª®â®àëå ¥â ¢ |
; |
mov al, [inputbuff] |
cmp al, '/' |
jnz sd_message |
; ¬¥ 㨠|
;mov al, [inputbuff+2] |
;cmp al, 20h |
;jz sd_use_kl |
mov al, [inputbuff+3] |
cmp al, 20h ; ஡¥« |
jz sd_use_kl |
; |
; 饬 ¯¥à¢ë© ¯à®¡¥«, ¨¬ ¤®«¦¥ § ª®ç¨âìáï 㨠|
; |
xor ecx, ecx |
sd_loop: |
mov al, [inputbuff+ecx] |
cmp al, 20h |
jz sd_space |
cmp al, 0 |
jz wait_event |
inc ecx |
jmp sd_loop |
sd_space: |
; |
; ¬¥ï¥¬ ¯à®¡¥« 0, ®âáë« ¥¬ á®®¡é¥¨¥ |
mov [inputbuff+ecx], byte 0 |
lea ebx, [inputbuff+1] |
lea eax, [inputbuff+ecx+1] |
call sendmsg |
mov ebx, 0000FFh |
call writemsg |
jmp wait_event |
sd_use_kl: |
lea eax, [inputbuff+1] |
mov [inputbuff+3], byte 0 |
call ascitoint |
lea eax, [eax-1] ; .ª. ¢ ®âáç¥â á 0 |
mov [curruser], al |
sd_message: |
; |
; ®®¡é¥¨¥ |
movzx eax, [curruser] |
mov ebx, UIN_LEN |
imul ebx, eax |
lea ebx, [uins+ebx] |
mov al, [inputbuff] |
cmp al, '/' |
jz @f |
mov eax, inputbuff |
jmp sd_send |
@@: |
;mov al, [inputbuff+2] |
;cmp al, ' ' |
;jz @f |
lea eax, [inputbuff+4] |
;jmp sd_send |
;@@: lea eax, [inputbuff+3] |
sd_send: |
call sendmsg |
mov ebx, 0000FFh |
call writemsg |
jmp wait_event |
; |
; áâì ¯à¨ïâë¥ ¤ ë¥ |
; |
read_socket: |
pushf |
pushad |
;write_debug 'Some data in socket' |
; |
; ஢¥à塞, ¥ ¡ë« «¨ ¯®«ãç¥ § £®«®¢®ª ®â¤¥«ì® ®â ¤ ëå |
; ¢ ¯à¥¤ë¤ã饬 横«¥ |
; |
cmp [hrf], 1 |
jz rs_head_recived |
rs_check_sock: |
;mov eax, 53 |
;mov ebx, 2 |
;mov ecx, [socket] |
;int 40h |
mcall 53,2,[socket] |
cmp eax, 6 ; Flap head size |
jc r_end |
; |
; ਨ¬ ¥¬ § £®«®¢®ª |
; |
xor edx, edx |
;mov ecx, [socket] |
rs_loop: |
;mov eax, 53 |
;mov ebx, 3 |
;int 40h |
mcall 53,3,[socket] |
mov [mbuff+edx], bl |
inc edx |
cmp edx, 6 |
jnz rs_loop |
; |
; ¯®«ï¥¬ § £®«®¢®ª |
; |
;xor eax, eax |
; |
; £®«®¢®ª ¯à¨ïâ! |
; |
mov [hrf], 1 |
mov bl, [mbuff] |
mov [rflap.bId], bl |
mov bl, [mbuff+1] |
mov [rflap.bCh], bl |
mov bh, [mbuff+2] |
mov bl, [mbuff+3] |
mov [rflap.wSn], bx |
mov bh, [mbuff+4] |
mov bl, [mbuff+5] |
mov [rflap.wDs], bx |
; |
; ਨ¬ ¥¬ ¤ ë¥ |
; |
;xor edx, edx |
cmp [rflap.bId], 2Ah |
jnz rs_flap_error |
; |
; ஢¥à塞, ¯®«ãç¥ë «¨ ¤ ë¥ |
; |
rs_head_recived: |
;mov eax, 53 |
;mov ebx, 2 |
;mov ecx, [socket] |
;int 40h |
mcall 53,2,[socket] |
cmp ax, [rflap.wDs] ; §¬¥à ¤ ëå |
jc r_end |
; |
; |
mov ax, [rflap.wDs] |
; |
; ஢¥à塞 à §¬¥à ¤ ëå |
; |
cmp ax, MBUFF_SIZE+1 |
jnc rs_big_flap |
xor esi, esi |
mov esi, eax |
xor edx, edx |
;mov ecx, [socket] |
rs_data_loop: |
cmp edx, esi |
jz rs_data_end |
;mov eax, 53 |
;mov ebx, 3 |
;int 40h |
mcall 53,3,[socket] |
mov [mbuff+edx], bl |
inc edx |
jmp rs_data_loop |
; |
; ë¥ ¯à¨ïâë |
; |
rs_data_end: |
mov [hrf], 0 |
;write_debug 'Some data recived' |
; |
; |
; |
cmp [login], 0 |
jz rs_login |
call main_loop |
; |
; áâì á¬ëá« ¯à®¢¥à¨âì ᮪¥â «¨ç¨¥ á«¥¤ãî饣® § £®«®¢ª |
; |
;jmp r_end |
jmp rs_check_sock |
rs_login: |
call srv_login |
;write_debug 'Exited srv_login' |
;jmp r_end |
jmp rs_check_sock |
rs_flap_error: |
write_debug 'Invalid Flap' |
; |
; FLAP.id ¥¢¥àë©. 㦮 § ªàëâì ᮪¥â |
; |
mov ecx, [socket] |
;call closesocket |
jmp r_end |
; |
; «¨èª®¬ ¡®«ì让 ¯ ª¥â! |
; |
rs_big_flap: |
write_debug 'Too BIG FLAP Recived' |
mov [hrf], 0 |
;mov ecx, [socket] |
mov ax, [rflap.wDs] |
xor esi, esi |
mov esi, eax |
xor edx, edx |
rs_data_loop2: |
cmp edx, esi |
jz r_end |
;mov eax, 53 |
;mov ebx, 3 |
;int 40h |
mcall 53,3,[socket] |
;mov [mbuff+edx], bl |
inc edx |
jmp rs_data_loop2 |
r_end: |
popad |
popf |
jmp wait_event |
; ®¥¤¨¥¨¥ á á¥à¢¥à®¬, ¢®§¢à é ¥â ¢ eax - åí¤« ᮪¥â |
; ¯¥à¥¤ ¥¬ ¢ ¥ å IP ¤à¥á á¥à¢¥à |
; ¢ ebx - ¯®àâ |
srv_connect: |
push ecx |
push edx |
push esi |
push edi |
push ebx |
mov esi, eax ; IP - ¢ esi |
; find free port |
mov ecx, 1000 ; ¯à¥¤¥«ï¥¬ «®ª «ìë© ¯®àâ, ç¨ ¥¬ á 1000 |
getlp: |
inc ecx |
push ecx |
;mov eax, 53 |
;mov ebx, 9 |
;int 0x40 |
mcall 53,9,ecx |
pop ecx |
cmp eax, 0 ; íâ®â «®ª «ìë© ¯®à⠨ᯮ«ì§ã¥âáï? |
jz getlp ; ¤ - ¯à®¤®«¦ ¥¬ ¯¥à¥¡¨à âì |
;OK ecx = port number |
;Open Socket |
;mov eax, 53 |
;mov ebx, 5 |
xor edx, edx |
;mov dx, ICQ_PORT |
pop edx |
;mov esi,ICQ_IP |
;mov edi, 1;SOCKET_ACTIVE |
;int 40h |
mcall 53, 5, ecx, edx, esi, 1 |
; |
mov [socket], eax |
; |
; ¤¥¬ ãáâ ®¢ª¨ ᮥ¤¨¥¨ï |
mov ecx, eax |
srv_loop: |
;mov eax, 5 |
;mov ebx, 50 |
;int 40h |
mcall 5, 50 |
;mov eax, 53 |
;mov ebx, 6 |
;int 40h |
mcall 53, 6, ecx |
cmp eax, TCB_ESTABLISHED |
jz fin |
cmp eax, 11 |
jae c_end |
; |
;inc [timer] |
;cmp [timer], 50 |
;jz srv_err |
jmp srv_loop |
;srv_err: |
;mov [timer], word 0 |
;cmp eax,-1 |
;jnz fin |
;delay 100 |
write_debug 'CONNECTION FAILED' ;®¤ª«î票¥ ¥ 㤠«®áì |
jmp c_end |
;connrcted: |
;CONNECTED |
fin: |
write_debug 'Connected!!!!' |
c_end: |
pop edi |
pop esi |
pop edx |
pop ecx |
;pop ebx |
ret |
; |
; --> ecx socket handle |
; |
srv_login: |
pushf |
push eax |
push ebx |
;push ecx |
push edx |
; |
; ¯à¥¤¥«ï¥¬ ⨯ ¯®«ãç¥ëå ¤ ëå |
; |
movzx eax, [rflap.bCh] |
cmp eax, 01 |
jz s_new_connection |
cmp eax, 04 |
jz s_cookie ; cookie |
jmp l_flap_err |
s_new_connection: |
; |
; ஢¥à塞 ¯®«ãç¥ë© ¯ ª¥â |
; |
movzx eax, [rflap.wDs] |
cmp eax, 4 |
jnz l_len_err |
mov eax, dword [mbuff] |
cmp eax, 01000000h ; 00 00 00 01 |
jnz l_data_err |
; |
;®à¬¨à㥬 ¯ ª¥â ¤«ï ᮥ¤¨¥¨ï |
; |
;mov [flap.bId], FLAP_ID |
mov [flap.bCh], NEW_CONNECTION |
;mov eax, 26 |
;mov ebx, 9 |
;int 40h |
mcall 26, 9 |
mov [seq], ax |
mov [flap.wSn], ax ; Sequence number |
;mov [buff],0 |
;mov [buff+1],0 |
;mov [buff+2],0 |
mov dword [buff], 0x01000000 ;login Protokol version 00 00 00 01 |
;mov[buff+4],0 |
mov word [buff+4], 0x0100; TLV.TYPE = UIN 00 01 |
lea eax, [vtable + vartable.uin] |
call strlen |
mov [buff+6], ah |
mov [buff+7], al ; Length of UIN |
mov edx, eax |
add edx, 7 ; ¢ edx ¤«¨ § ¯®«¥®£® ¡ãä¥à |
mov ecx, eax ;«¨ áâப¨ |
lea eax, [vtable + vartable.uin] |
lea ebx, [buff+8] ; + à §¬¥à ¤ ëå ¢ ¡ãä¥à¥ + 1 |
call strcpy |
lea eax, [vtable + vartable.pass] |
call roast |
mov [buff+edx+2], 2 ; TLV.TYPE - rosted password |
call strlen |
mov [buff+edx+4], al |
mov [buff+edx+3], ah ; Length of pass |
add edx, 4 |
mov ebx, buff |
add ebx, edx ; § 票¥ |
add edx, eax ; ®åà 塞 ¢ EDX ¤«¨ã § ¯®«¥®£® ¡ãäà |
mov ecx, eax ; «¨ áâப¨ |
lea eax, [vtable + vartable.pass] ; áâ®ç¨ª |
inc ebx |
call strcpy |
mov [buff+edx+2], 3 ; TLV.TYPE - client id string |
mov eax, ID_STRING |
call strlen |
mov [buff+edx+4], al |
mov [buff+edx+3], ah |
add edx, 4 |
mov ecx, eax |
mov ebx, buff |
add ebx, edx |
add edx, eax |
inc ebx |
mov eax, ID_STRING |
call strcpy |
xor eax, eax |
mov [buff+edx+2], 016h ; TLV.TYPE - Client id |
mov [buff+edx+4], 2 |
mov ax, ID_NUM |
call htons |
mov word [buff+edx+5], ax |
add edx, 6 |
mov [buff+edx+2], 017h ; Client major version |
mov [buff+edx+4], 2 |
mov ax, MAJOR |
call htons |
mov word [buff+edx+5], ax |
add edx, 6 |
mov [buff+edx+2], 018h ; Client minor version |
mov [buff+edx+4], 2 |
mov ax, MINOR |
call htons |
mov word [buff+edx+5], ax |
add edx, 6 |
mov [buff+edx+2], 019h ; Client lesser version |
mov [buff+edx+4], 2 |
mov ax, LESSER |
call htons |
mov word [buff+edx+5], ax |
add edx, 6 |
mov [buff+edx+2], 01Ah ; Client build number |
mov [buff+edx+4], 2 |
mov ax, BUILD |
call htons |
mov word [buff+edx+5], ax |
add edx, 6 |
mov [buff+edx+2], 014h ; Client distribution number |
mov [buff+edx+4], 4 |
mov eax, DISTR |
call htonl |
mov dword [buff+edx+5], eax |
add edx, 8 |
mov [buff+edx+2], 0Fh ; Client language |
mov eax, CL_LANG |
call strlen |
mov word [buff+edx+4], ax |
add edx, 4 |
mov ecx, eax |
mov ebx, buff |
add ebx, edx |
inc ebx |
add edx, eax |
mov eax, CL_LANG |
call strcpy |
mov [buff+edx+2], 0Eh ; Client country |
mov eax, CL_COUNTRY |
call strlen |
mov word [buff+edx+4], ax |
add edx, 4 |
mov ecx, eax |
mov ebx, buff |
add ebx, edx |
inc ebx |
add edx, eax |
mov eax, CL_COUNTRY |
call strcpy |
;write_debug 'Connect attemption' |
; mov eax, ICQ_IP |
; call srv_connect |
; cmp eax, -1 ; ®¤ª«î票¥ ¥ 㤠«®áì |
; jz l_fin |
; mov ecx, eax |
; mov eax, rflap |
; mov ebx, lbuff |
; call recvflap |
; cmp eax, -1 |
; jz l_flap_err |
; cmp [rflap.bCh], 01 ; AUTH channel |
; jnz l_ch_err |
; cmp eax, 4 |
; jnz l_len_err |
; cmp dword [lbuff+3], dword 1 |
; jnz l_data_err |
mov ecx, [socket] |
inc dx |
mov [flap.wDs], dx ; Data size |
mov eax, flap |
mov ebx, buff |
call sendflap |
cmp eax, 0 |
jnz l_fin ; ¥ãᯥå |
jmp l_end |
s_cookie: |
;mov eax, rflap |
;mov ebx, buff |
;call recvflap |
;cmp eax, -1 |
;jz l_flap_err |
;cmp [rflap.bCh], 4 |
;jnz l_ch_err |
;write_debug 'UIN' |
xor ebx, ebx |
uin_loop: |
xor eax, eax |
mov ax, word [mbuff+ebx] |
cmp ax, 0100h ; 00 01 TLV.Type UIN |
jz l_uin_ok ; ¥¯¥àì á¥à¢¥à ¯¥à¥¤ ¥â ¥é¥ ¤ ë¥ ¯à¨ ᮥ¤¨¥¨¨, ¯®â®¬ ®¯ïâì |
add ebx, 5 ; â®â ¦¥ TLV 1 (®¢ë© ä®à¬ â ¯ ª¥ªâ ) |
cmp ebx, 5 |
ja l_tlvt_err |
jmp uin_loop |
l_uin_ok: |
mov eax, ebx |
xor ebx, ebx |
mov bl, [mbuff+eax+3] ; |
mov bh, [mbuff+eax+2] ; «¨ ¤ ëå |
; |
; UIN ®ª ¥ ¯à®¢¥àï¥âáï |
; |
lea ebx, [ebx+eax+4] |
mov ax, word [mbuff+ebx] |
cmp ax, 0500h ; 00 05 Bos address |
jz l_all_ok |
cmp ax, 0400h ; UIN incorrect |
jz l_uin_err |
cmp ax, 0800h |
jz l_pass_err |
jmp l_tlvt_err |
; |
; ¥á«¨ ¥¢¥àë© UIN/ ¯ ஫ì, ¯®«ãç ¥¬ TLV.TYPE 4/8 |
; |
l_all_ok: |
xor ecx, ecx |
mov cl, [mbuff+ebx+3] ;length |
mov ch, [mbuff+ebx+2] ; |
lea eax, [mbuff+ebx+4] |
push ebx |
mov ebx, bos_address |
call strcpy |
pop ebx |
add ebx, ecx |
lea ebx, [ebx+4] ; §¬¥à § £®«®¢ª |
; |
; cookie |
; |
;write_debug 'Login Cookie' |
xor eax, eax |
mov ax, word [mbuff+ebx] |
cmp ax, 0600h ; TLV.Type cookie |
jnz l_tlvt_err |
mov cl, [mbuff+ebx+3] ; |
mov ch, [mbuff+ebx+2] ; Length |
mov [cookie_len], cx |
lea eax, [mbuff+ebx+4] |
push ebx |
mov ebx, srv_cookie |
call strcpy |
pop ebx |
; |
; ®¥¤¨ï¥¬áï á BOS |
; |
;call srv_disconnect |
mov ecx, [socket] |
write_debug 'Closing socket' |
;call closesocket |
; |
; |
; |
;FIXME!!! |
; ª®¬¬¥â®à®¢ ® ¨§-§ ¯à®¡«¥¬ë á á¥â¥¢ë¬ á⥪®¬ |
;§ ªàë⨥ ᮪¥â § ¢¥è¨¢ ¥â á¨á⥬ã |
;mcall 53, 8, ecx |
mov eax, bos_address |
call ip_parser |
call htonl |
data_debug 'BOS Address: ', eax |
data_debug 'BOS Port: ', ebx |
mov [bos_ip], eax |
mov [bos_port], ebx |
call srv_connect |
mov [login], 1 ; ®¥¤¨¥¨¥ á ®á®¢ë¬ á¥à¢¥à®¬ ãáâ ®¢«¥® |
;mov [socket], eax |
jmp l_end |
; |
; |
; |
l_pass_err: |
write_debug 'PASSWORD INVALID' |
jmp l_fin |
l_uin_err: |
write_debug 'UIN INVALID' |
jmp l_fin |
l_data_err: |
write_debug 'LOGIN DATA MISMATCH' |
jmp l_fin |
l_len_err: |
write_debug 'RECIVED DATA LENGTH MISMATCH' |
jmp l_fin |
l_tlvt_err: |
write_debug 'TLV TYPE MISMATCH' |
jmp l_fin |
l_ch_err: |
write_debug 'FLAP CHANNEL MISMATCH' |
jmp l_fin |
l_flap_err: |
write_debug 'FLAP ID MISMATCH / RECIVE ERROR' |
l_fin: |
; |
; ¥®¡å®¤¨¬® § ªàëâì ᮪¥â |
; |
;call srv_disconnect |
call closesocket |
l_end: |
pop edx |
;pop ecx |
pop ebx |
pop eax |
popf |
ret |
; |
; Length of string |
; input eax = offset string |
; output eax = strlen |
; |
strlen: |
push ebx |
push ecx |
pushf |
xor ebx, ebx |
xor ecx, ecx |
loop_s: |
mov cl, [eax+ebx] |
cmp ecx,0 |
jz nl |
inc ebx |
jmp loop_s |
nl: |
mov eax, ebx |
popf |
pop ecx |
pop ebx |
ret |
; |
; Roasting password |
; EAX = offset password |
; |
roast: |
pushf |
push ecx |
push ebx |
xor ecx, ecx |
xor ebx, ebx |
loop_r: |
mov bl, [eax+ecx] ;¨¬¢®« ¨§ ¬ áᨢ ¯ ஫ï |
cmp bl, 0 ;®¥æ áâப¨ |
jz r_fin |
xor bl, [ROASTING_ARRAY+ecx] |
mov [eax+ecx], bl |
inc ecx |
jmp loop_r |
r_fin: |
pop ebx |
pop ecx |
popf |
ret |
; |
;Copy string of bytes |
; EAX = ¤à¥á ¨á室®© áâப¨ |
; EBX = ¤à¥á § 票ï |
; ECX = ¤«¨ áâப¨ |
; |
strcpy: |
pushf |
push esi |
push edi |
push ecx |
cld ;¡à ¡ âë¢ ¥¬ áâப㠮â ç « ª ª®æã |
mov esi, eax |
mov edi, ebx |
rep movsb |
pop ecx |
pop edi |
pop esi |
popf |
ret |
; |
; ªà®á ¤«ï áà ¢¥¨ï áâப |
; |
macro strcmp first, second, len |
{ |
push ecx |
push esi |
push edi |
mov ecx, len |
mov esi, first |
mov edi, second |
repe cmpsb |
pop edi |
pop esi |
pop ecx |
} |
; |
; ¯®«ï¥â ¡ãä¥à, ¯® ¤à¥áã ¢ ebx |
; ¤ 묨, ¯® ¤à¥áã eax, ¢ |
; cx - ¨¯ TLV |
; dx - ¤«¨ ¤ ëå |
; |
; |
tlvstr: |
;pushf |
push edx |
push ecx |
push ebx |
mov [ebx], ch ; Type |
mov [ebx+1], cl |
mov [ebx+2], dh ; Length |
mov [ebx+3], dl |
lea ebx, [ebx+4] |
; EBX = offset of destination |
mov ecx, edx |
call strcpy |
pop ebx |
pop ecx |
pop edx |
;popf |
ret |
; |
; eax - 㪠§ ⥫ì FLAP_head |
; ebx - 㪠§ â¥«ì ¬ áᨢ, § ¯®«¥ë© ¤ 묨 |
; ecx - 奤« ᮪¥â |
; |
; eax ¢®§¢à é ¥â १ã«ìâ â § ¯¨á¨ ¢ ᮪¥â |
; |
sendflap: |
pushf |
push edx |
;push ecx |
push esi |
push ebx |
push ecx |
xor edx, edx |
mov dl, [eax] ; ID byte |
mov [sbuff], dl |
mov dl, [eax+1] ; FLAP channel |
mov [sbuff+1], dl |
mov dl, [eax+2] ; FLAP datagramm seq number |
mov [sbuff+3], dl ; ¬¥ï¥¬ ¬¥áâ ¬¨ ¡ ©âë ¤«ï ¯¥à¥¤ ç¨ ¯® á¥â¨ |
mov dl, [eax+3] |
mov [sbuff+2], dl |
mov dl, [eax+4] ; FLAP data size |
mov [sbuff+5], dl |
mov dl, [eax+5] |
mov [sbuff+4], dl |
mov dx, word [eax+4] |
xchg ecx, edx ; ecx - size edx - handle |
mov eax, ebx ; data |
mov ebx, sbuff ; dest |
add ebx, 6 ; + header size |
call strcpy |
xchg ecx, edx ; ecx - handle, edx - data size |
s_wait: |
;mov eax, 53 ; ஢¥à塞 á®áâ®ï¨¥ ᮪¥â . ᫨ ᮥ¤¨¥¨¥ |
;mov ebx, 6 ; ãáâ ®¢«¥® - ¯®áë« ¥¬ ¡ãä¥à, ¥á«¨ ᮪¥â § ªàëâ, ã室¨¬ |
;int 40h |
mcall 53, 6, ecx |
cmp eax, TCB_ESTABLISHED ; ãáâ ®¢«¥® |
jz s_est |
cmp eax, TCB_CLOSED |
jz s_fin |
cmp eax, 12 ; ¬¥ï â ª®¥ ¡ë«®, ª®£¤ ᮥ¤¨¥¨¥ ãáâ ¢«¨¢ «®áì á ¯ãáâ®â®© :-) |
jnc s_fin ; |
;mov eax, 5 |
;mov ebx, 1 |
;int 40h ; ¤¥¬ |
mcall 5, 1 |
jmp s_wait |
s_est: |
;mov eax, 53 |
;mov ebx, 7 ; ¯¨á âì ¢ ᮪¥â |
add edx, 6 ; + size of header |
;mov esi, sbuff ; data |
;int 40h |
mcall 53, 7, ecx, edx, sbuff |
s_fin: |
pop ecx |
pop ebx |
pop esi |
;pop ecx |
pop edx |
popf |
ret |
; |
; eax - 㪠§ â¥«ì ¡ãä¥à |
; ebx - § 票¥, ª®â®àë¬ ¥®¡å®¤¨¬® § ⮫¨âì. ᯮ«ì§ã¥âáï ⮫쪮 bl |
; ecx - à §¬¥à |
; |
memset: |
pushf |
push edi |
push eax |
push ebx |
push ecx |
cld |
mov edi, eax |
mov eax, ebx |
rep stosb |
pop ecx |
pop ebx |
pop eax |
pop edi |
popf |
ret |
; |
; àᨬ TLV |
; <-- ¢ eax ¤à¥á TLV |
; <-- ¢ ebx ¤à¥á ¡ãä¥à , ª®â®àë© ã¦® § ¯®«¨âì |
; --> ¢ ebx ¤«¨ ¯®«ãç¥ëå ¤ ëå |
; --> ¢ eax ⨯ TLV |
; |
tlvpar: |
pushf |
;push esi |
;push edi |
push ecx |
xor ecx, ecx |
mov cl, [eax+3] ;TLV.Length |
mov ch, [eax+2] |
call strcpy |
xor eax, eax |
mov al, [ebx+1] ;TLV.Type |
mov ah, [ebx] |
mov ebx, ecx |
pop ecx |
;pop edi |
;pop esi |
popf |
ret |
; |
; <-- ECX - 奤« ᮪¥â , ª®â®àë© ã¦® § ªàëâì |
; --> ECX - ¥§ã«ìâ â (¥ ¤¥¦®) |
; |
closesocket: |
push eax |
;push ebx |
;mov eax, 53 |
;mov ebx, 8 |
;int 40h |
mcall 53, 8, ecx |
mov ecx, eax |
;pop ebx |
pop eax |
ret |
; |
; ecx <-- 奤« ᮪¥â |
; |
; |
srv_disconnect: |
pushf |
push eax |
push ebx |
mov [flap.bId], FLAP_ID |
mov [flap.bCh], 4 ;Disconnect |
xor eax, eax |
mov ax, [seq] |
mov [flap.wSn], ax |
mov [flap.wDs], 0 |
mov eax, flap |
mov ebx, buff |
call sendflap |
pop ebx |
pop eax |
popf |
ret |
; |
; <-- eax [bos_address] |
; --> eax = IP ADDRESS |
; --> ebx = port number |
; |
par_buff db 9 dup 0 |
ip_parser: |
pushf |
push ecx |
push edx |
push esi |
push edi |
xor ecx, ecx |
;xor eax, eax |
mov ebx, eax |
xor edx, edx |
xor esi, esi |
xor edi, edi |
ip_loop: |
xor eax, eax |
;xor edx, edx |
mov al, [ebx+ecx] |
cmp al, '.' |
jz ip_dot |
cmp al, 0 |
jz ip_end_str |
cmp al, ':' |
jz ip_colon |
;sub al, 30h |
;cmp al, 9 |
;ja ip_err ; ¥ æ¨äà |
mov [par_buff+edx], al |
inc ecx |
inc edx |
jmp ip_loop |
ip_dot: |
;xor eax, eax |
mov [par_buff+edx], 0 ; ®¥æ áâப¨ |
mov eax, par_buff |
call ascitoint |
;data_debug 'Debug eax: ', eax |
cmp ecx, 0 ; ¥ ¬®¦¥â ç¨ âìáï á â®çª¨ |
jz ip_err |
shl esi, 8 ; ¤¢¨£ ¥¬ ¯à¥¤ë¤ã騩 ¡ ©â |
add esi, eax |
inc ecx |
xor edx, edx ; ç¥â稪 ¡ãä¥à = 0 |
jmp ip_loop |
ip_colon: ; : áâப¥ ¤à¥á |
inc edi ; ë«® : |
jmp ip_dot |
ip_end_str: |
cmp edi, 1 |
jz @f |
; : ¥ ¡ë«® |
mov [par_buff+edx], 0 ; ®¥æ áâப¨ |
mov eax, par_buff |
call ascitoint |
shl esi, 8 ; ¤¢¨£ ¥¬ ¯à¥¤ë¤ã騩 ¡ ©â |
add esi, eax |
;mov eax, esi ; IP ¢ 16 à¨ç®© ä®à¬¥ |
xor ebx, ebx ; ®¬¥à ¯®àâ ¥â |
jmp ip_end |
@@: ; ë«® : |
mov [par_buff+edx], 0 |
mov eax, par_buff |
call ascitoint |
mov ebx, eax |
jmp ip_end |
ip_err: |
xor esi, esi |
ip_end: |
mov eax, esi |
pop edi |
pop esi |
pop edx |
pop ecx |
popf |
ret |
; |
; <-- eax 㪠§ ⥫ì asci |
; --> eax int |
; |
ascitoint: |
pushf |
push ebx |
push ecx |
push edx |
push esi |
push edi |
xor ebx, ebx |
xor ecx, ecx |
xor edx, edx |
;xor esi, esi |
xor edi, edi |
ati_loop: |
mov bl, [eax+ecx] |
cmp bl, 0 ; ®¥æ áâப¨ |
jz ati_str_end |
cmp bl, 39h |
ja ati_err ; ¥ æ¨äà |
cmp bl, 30h |
jb ati_err |
inc ecx |
jmp ati_loop |
ati_str_end: ; ecx ¤«¨ áâப¨ |
;dec ecx ; áâ ®¢¨¬ ¯®á«¥¤¨© ᨬ¢®« |
add eax, ecx ; ª § ⥫ì áâபã + «¨ áâப¨ |
dec eax |
ati_loop2: |
cmp edx, ecx |
jz ati_all |
push eax |
sub eax, edx ; ëç¥áâì áç¥â稪 |
movzx ebx, byte [eax] ; bl ᨬ¢®« |
;pop eax |
sub bl, 30h ; ëç¨á«ï¥¬ 10â¨çãî æ¨äàã |
;push eax |
mov eax, ebx ; eax - æ¨äà |
mov ebx, 10 ; ®¦¨â¥«ì |
xor esi, esi |
ati_mul: |
cmp esi, edx ; ¬®¦ ¥¬ 10 n à § |
jz ati_mul_end |
;push eax |
;mov eax, ebx |
imul eax, ebx |
;mov ebx, eax |
;pop eax |
inc esi |
jmp ati_mul |
ati_mul_end: |
mov ebx, eax ; ebx ¢ëç¨á«¥®¥ ç¨á«® |
pop eax |
add edi, ebx |
inc edx |
jmp ati_loop2 |
ati_all: |
mov eax, edi |
jmp ati_end |
ati_err: |
;ati_str_end: |
xor eax, eax |
ati_end: |
pop edi |
pop esi |
pop edx |
pop ecx |
pop ebx |
popf |
ret |
; |
; |
; <-- ecx 奤« ᮪¥â |
; <-- eax 㪠§ ⥫ì áâàãªâãàã SNAC_head |
; <-- ebx 㪠§ â¥«ì ¤ ë¥ |
; <-- edx à §¬¥à ¤ ëå |
; --> eax १ã«ìâ â § ¯¨á¨ ¢ ᮪¥â |
; |
snac_buff db 1024 dup 0 |
sendsnac: |
pushf |
push esi |
push edi |
push ebx |
push edx |
;xor ebx, ebx |
mov esi, ecx ; 奤« ᮪¥â |
mov edi, ebx ; ª § â¥«ì ¤ ë¥ |
xor ebx, ebx |
mov bl, [eax] ; |
mov [snac_buff+1], bl ; Family ID |
mov bl, [eax+1] ; ®¢¥àâ¨àã¥âáï ¢ BigEndian |
mov [snac_buff], bl ; |
mov bl, [eax+2] ; |
mov [snac_buff+3], bl ; Subtype ID |
mov bl, [eax+3] ; |
mov [snac_buff+2], bl ; |
mov bl, [eax+4] ; |
mov [snac_buff+5], bl ; |
mov bl, [eax+5] ; Flags |
mov [snac_buff+4], bl ; |
mov bl, [eax+6] ; |
mov [snac_buff+9], bl ; |
mov bl, [eax+7] ; |
mov [snac_buff+8], bl ; |
mov bl, [eax+8] ; Reqest ID |
mov [snac_buff+7], bl ; |
mov bl, [eax+9] ; |
mov [snac_buff+6], bl ; |
lea ebx, [snac_buff+10] |
mov eax, edi ; ª § â¥«ì ¤ ë¥ |
;add ebx, 10 ; + à §¬¥à § £®«®¢ª SNAC |
mov ecx, edx ; à §¬¥à ¤ ëå |
call strcpy |
mov ecx, esi ; ¥¤« ᮪¥â |
mov [flap.bId], FLAP_ID |
mov [flap.bCh], 2 ; « ¤«ï ¯®á뫪¨ SNAC |
xor ebx, ebx |
inc [seq] ; seq ¢¥«¨ç¨¢ ¥âáï 1 ¯à¨ ª ¦¤®© ¯®á뫪¥ |
mov bx, [seq] |
mov [flap.wSn], bx |
add edx, 10 ; à §¬¥à ¤ ëå + à §¬¥à § £®«®¢ª SNAC |
mov [flap.wDs], dx |
mov eax, flap |
mov ebx, snac_buff |
call sendflap |
pop edx |
pop ebx |
pop edi |
pop esi |
popf |
ret |
; ¡à ¡®âª ¢á¥å ¯ ªâ®¢, ¯à¨å®¤ïé¨å ®â á¥à¢¥à |
; ECX <-- ¥¤« ᮪¥â |
; |
; |
; |
; |
; |
main_loop: |
pushf |
;push eax |
;push ebx |
;push edx |
pushad |
mov ecx, [socket] |
; |
; ¦¤¥¬ ¯ ª¥â |
; |
;m_loop: |
;mov eax, 53 |
;mov ebx, 2 |
;int 40h |
;cmp eax, 6 ; à §¬¥à § £®«® ª FLAP |
;jnc recived ; >= |
; |
; 室¨¬ |
; |
;jmp m_fin |
;mov eax, 5 |
;mov ebx, 5 |
;int 40h |
;jmp m_loop |
; |
; ¥áâì ¯ ª¥â |
; |
;recived: |
;mov eax, rflap |
;mov ebx, rbuff |
;call recvflap |
; |
; ¯à¥¤¥«ï¥¬ ⨯ ¯à¨ï⮣® FLAP |
; |
xor ebx, ebx |
mov bl, [rflap.bCh] |
cmp bl, 1 ; áâ ®¢ª ᮥ¤¨¥¨ï |
jz m_login |
cmp bl, 2 |
jz m_snac ; ®«ãç¥ SNAC |
cmp bl, 3 |
jz m_flap_err ; FLAP-level error |
cmp bl, 4 |
jz m_close_conn ; ªàë⨥ ᮥ¤¨¥¨ï |
cmp bl, 5 |
jz m_keep_alive ; |
; |
; ¡à ¡®âª à áᮥ¤¨¥¨ï |
; |
m_close_conn: |
write_debug 'Another Computer Use YOUR UIN!' |
call srv_disconnect |
call closesocket |
jmp m_fin |
; |
; ®¡à ¡®âª ᮥ¤¨¥¨ï |
; |
m_login: |
; |
; ¯à®¢¥à塞 ¢¥àá¨î ¯à®â®ª®« |
; |
xor eax, eax |
mov al, [mbuff+3] |
cmp eax, 1 |
jnz m_login_other ; ¥ ¯®¤å®¤¨â |
; |
; £¥¥à¨à㥬 á«ãç ©ë© seq |
; «ï í⮣® ¡¥à¥¬ ¢à¥¬ï, ¯à®è¥¤è¥¥ á ¬®¬¥â § ¯ã᪠á¨á⥬ë |
; |
;mov eax, 26 |
;mov ebx, 9 |
;int 40h |
mcall 26, 9 |
mov [seq], ax |
; |
; ⤠¥¬ á¥à¢¥àã cookie |
; |
mov [flap.bCh], 1 |
mov [flap.wSn], ax |
xor eax, eax |
mov ax, [cookie_len] |
add eax, 8 ; TLV len + protocol version len |
mov [flap.wDs], ax |
mov dword [buff], 01000000h ; 00 00 00 01 ®¬¥à ¯à®â®ª®« |
mov word [buff+4], 0600h ; 00 06 TLV.Type |
mov ax, [cookie_len] |
mov [buff+6], ah ; |
mov [buff+7], al ; TLV.Length |
mov edx, ecx ; edx <-- socket handle |
mov ecx, eax ; ecx <-- cookie len |
mov eax, srv_cookie ; Src |
lea ebx, [buff+8] |
call strcpy |
mov ecx, edx ; ecx <-- socket handle |
mov eax, flap |
mov ebx, buff |
call sendflap |
jmp m_fin |
m_login_other: |
jmp m_fin |
; |
; ª ®¡à ¡®â âì ®è¨¡ªã, ï ¥ § î |
; |
m_flap_err: |
jmp m_fin |
; |
; ®ª ¥ ®¡à ¡ âë¢ ¥âáï |
; |
m_keep_alive: |
jmp m_fin |
; |
; ®«ãç¥ SNAC |
; ᯮ§ ¥¬ ¥£® ⨯ |
; |
m_snac: |
mov eax, rsnac |
mov ebx, mbuff |
call snacpar |
xor ebx, ebx |
xor edx, edx |
mov bx, [rsnac.wFid] |
mov dx, [rsnac.wSid] |
cmp bx, 1 |
jz m_snac_1 ;Generic service controls |
cmp bx, 2 |
jz m_snac_2 ;Location services |
cmp bx, 3 |
jz m_snac_3 ;Buddy List management service |
cmp bx, 4 |
jz m_snac_4 ;ICBM (messages) service |
cmp bx, 9 |
jz m_snac_9 ;Privacy management service |
cmp bx, 015h |
jz m_snac_15 ;ICQ specific extensions service |
cmp bx, 013h |
jz m_snac_13 ;Server Side Information (SSI) service |
jmp m_other_snac |
; |
; FAMILY 1 |
; |
m_snac_1: |
cmp dx, 7 |
jz m_snac_1_7 |
cmp dx, 3 |
jz m_snac_1_3 |
cmp dx, 018h |
jz m_snac_1_18 |
cmp dx, 01Fh |
jz m_snac_1_f |
cmp dx, 13h |
jz m_snac_13 |
cmp dx, 1 |
jz m_snac_1_1 |
jmp m_snac_1_other |
; |
; Rate limits information response |
; |
m_snac_1_7: ; â¢¥ç ¥¬ |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 8 ; Subtype |
mov [ssnac.dRi], 8 |
mov word [buff], 0100h ; 0001 |
mov word [buff+2], 0200h ; 0002 |
mov word [buff+4], 0300h ; 0003 |
mov word [buff+6], 0400h ; 0004 |
mov word [buff+8], 0500h ; 0005 |
mov eax, ssnac |
mov ebx, buff |
mov edx, 10 ; §¬¥à ¤ ëå |
call sendsnac |
; |
; Client ask server location service limitations |
; |
mov [ssnac.wFid], 2 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
jmp m_fin |
; |
; Server supported snac families list |
; |
m_snac_1_3: |
; |
; Server sends supported services list |
; |
; |
; SNAC(01,17) |
; Client ask for services version numbers |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 17h ; Subtype |
mov [ssnac.dRi], 17h |
; |
; ¯¨á®ª á¥à¢¨á®¢, ª®â®àë¥ ¬ ã¦ë |
; |
; xx xx word family number #1 |
; xx xx word family version |
; ... ... ... |
; |
; |
; ®¯à ¢¨« ¨§ ¤ ¬¯ &RQ |
; |
mov word [buff], 0100h ; 0001 |
mov word [buff+2], 0300h ; 0003 |
mov word [buff+4], 1300h ; 0013 |
mov word [buff+6], 0200h ; 0002 |
mov word [buff+8], 0200h ; 0002 |
mov word [buff+10], 0100h ; 0001 |
mov word [buff+12], 0300h ; 0002 |
mov word [buff+14], 0100h ; 0001 |
mov word [buff+16], 1500h ; 0015 |
mov word [buff+18], 0100h ; 0001 |
mov word [buff+20], 0400h ; 0004 |
mov word [buff+22], 0100h ; 0001 |
mov word [buff+24], 0600h ; 0006 |
mov word [buff+26], 0100h ; 0001 |
mov word [buff+28], 0900h ; 0009 |
mov word [buff+30], 0100h ; 0001 |
mov word [buff+32], 1300h ; 0013 |
mov word [buff+34], 0400h ; 0004 |
mov word [buff+36], 1500h ; 0015 |
mov word [buff+38], 0400h ; 0004 |
mov word [buff+40], 1000h ; 0010 |
mov word [buff+42], 0100h ; 0001 |
mov eax, ssnac |
mov ebx, buff |
mov edx, 44 |
call sendsnac |
jmp m_fin |
; |
; Server services versions |
; |
m_snac_1_18: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
; |
; Client ask server for rate limits info |
; SNAC(01,06) |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 6 ; Subtype |
mov [ssnac.dRi], 6 |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
jmp m_fin |
; |
; Requested online info response |
; |
m_snac_1_f: |
; |
;ãâ ¤®«¦ ¡ëâì è ¨ä®à¬ æ¨ï, ¯®ª ®¡à ¡®âª¨ ¥â |
; |
jmp m_fin |
; |
; Message of the day (MOTD) |
; |
m_snac_1_13: |
; |
; ¥ç¥£® ®¡à ¡ âë¢ âì :-)) |
; |
jmp m_fin |
; |
; ®®¡é¥¨¥ ®¡ ®è¨¡ª¥ |
; |
m_snac_1_1: |
xor eax, eax |
mov ax, word [mbuff+10] |
call ntohs |
data_debug 'SERVER SEND ERROR #', eax |
jmp m_fin |
m_snac_1_other: |
data_debug 'Unknown SNAC Family 1 recived, type ', edx |
jmp m_fin |
; |
; Family 2 |
; |
m_snac_2: |
cmp dx, 3 |
jz m_snac_2_3 |
jmp m_snac_2_other |
; |
; Server replies via location service limitations |
; |
m_snac_2_3: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
; |
; ¯®áë« ¥¬ capabilities / profile |
; |
mov [ssnac.wFid], 2 ; Family |
mov [ssnac.wSid], 4 ; Subtype |
mov [ssnac.dRi], 4 |
;mov eax, CAPABILITIES |
;mov ebx, buff |
;push ecx |
;mov ecx, 5 ; TLV.Type(0x05) - CLSID values |
;mov edx, C_LEN |
;call tlvstr |
;pop ecx |
mov word [buff], 0500h ; 00 05 |
mov eax, C_LEN |
call htons |
mov word [buff+2], ax |
push ecx |
mov eax, CAPABILITIES |
lea ebx, [buff+4] |
mov ecx, C_LEN |
call strcpy |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
mov edx, C_LEN+4 ; «¨ ¤ ëå+à §¬¥à § £®«®¢ª TLV |
call sendsnac |
; |
; § ¯à 訢 ¥¬ server BLM service limitations |
; |
mov [ssnac.wFid], 3 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
jmp m_fin |
m_snac_2_other: |
write_debug 'Unknown SNAC Family 2 Recived' |
jmp m_fin |
; |
; FAMILY 3 |
; |
m_snac_3: |
cmp dx, 3 |
jz m_snac_3_3 |
cmp dx, 0Bh |
jz m_snac_3_b |
cmp dx, 0Ch |
jz m_snac_3_c |
jmp m_snac_3_other |
; |
; Server replies via BLM service limitations |
; |
m_snac_3_3: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
; |
; Client ask server for ICBM service parameters |
; |
mov [ssnac.wFid], 4 ; Family |
mov [ssnac.wSid], 4 ; Subtype |
mov [ssnac.dRi], 4 ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
jmp m_fin |
; |
; User online notification |
; |
m_snac_3_b: |
; |
; § ¢á¥© ¨ä®à¬ 樨 ¯®ª 㦥 ⮫쪮 áâ âãá |
; |
xor edx, edx ; ç¥â稪 - ®¬¥à UIN ¢ ¬ áᨢ¥ |
xor ecx, ecx |
xor eax, eax |
cld ; ¯à ¢«¥¨¨ 㢥«¨ç¥¨ï ¤à¥á®¢ |
dec edx |
m_snac_3_b_loop: |
inc edx |
cmp edx, UINS |
jnc m_snac_3_b_end ;>= |
mov cl, [mbuff+10] ; Ǭ |
mov eax, ecx |
mov edi, UIN_LEN |
imul edi, edx |
lea edi, [uins+edi] |
lea esi, [mbuff+11] |
repe cmpsb |
jnz m_snac_3_b_loop |
; |
; UIN ¯à¥¤¥«¥ |
; |
; |
; ©â¨ TLV á® áâ âãᮬ |
; á®åà ïâì edx |
xor esi, esi ; ç¥â稪 TLV |
xor ecx, ecx |
mov ch, byte [mbuff + eax + 13] ; ®«-¢® TLV ¢ 楯®çª¥ |
mov cl, byte [mbuff + eax + 14] ; |
lea eax, [eax + 10 + 5] ; eax 㪠§ ⥫ì 楯®çªã TLV |
lea eax, [mbuff + eax] ; |
m_snac_3_b_next_tlv: |
cmp esi, ecx |
jz m_snac_3_b_endchain |
xor ebx, ebx |
mov bh, [eax] ; |
mov bl, [eax + 1] ; TLV.Type |
data_debug 'TLV type', ebx |
cmp ebx, 0x06 ;TLV.Type(0x06) - user status |
jz m_snac_3_b_status |
; |
; §¡¨à ¥¬ 楯®çªã ¤ «ìè¥ |
; |
get_next_tlv |
inc esi |
jmp m_snac_3_b_next_tlv |
; FIXME ¥®¯â¨¬ «ì® - ª®¤ ¡ã¤¥â 㤠«¥ |
; |
;lea ecx, [eax+10+11] ; +sizeof SNAC_head + offset #2 TLV |
;mov ax, word [mbuff+ecx] ;#2 TLV.Type |
;cmp ax, 0C00h ;dc info (optional) |
;jz m_snac_3_b_dc |
;cmp ax, 0A00h ;external ip address |
;jz m_snac_3_b_extip |
;jmp m_snac_3_b_bad_tlv |
;m_snac_3_b_dc: |
; |
; யã᪠¥¬ íâ®â TLV |
; |
;lea ecx, [ecx+41] |
;m_snac_3_b_extip: |
; |
; íâ®â :-) |
;lea ecx, [ecx+8] |
;mov ax, word [mbuff+ecx] |
;cmp ax, 0600h ;TLV.Type(0x0A) - external ip address |
;jz m_snac_3_b_status |
;jmp m_snac_3_b_bad_tlv |
; |
; |
m_snac_3_b_status: |
; |
; áâ âãá |
; |
mov ecx, eax |
mov eax, dword [ecx + 4] |
;mov eax, dword [mbuff+ecx+4] |
call ntohl |
;mov ebx, 4 |
;imul ebx, edx |
;mov [stats+ebx], eax |
mov ecx, eax |
mov ebx, NAME_LEN |
imul ebx, edx |
lea ebx, [names+ebx] |
mov eax, edx |
call loadbb |
jmp m_fin |
m_snac_3_b_bad_tlv: |
write_debug 'TLV Type Mismatch in SNAC(3,b)' |
jmp m_fin |
m_snac_3_b_end: |
write_debug 'UIN not in local Contact List' |
jmp m_fin |
m_snac_3_b_endchain: |
jmp m_fin |
m_snac_3_c: |
; |
; User offline notification |
; |
xor edx, edx |
xor ecx, ecx |
dec edx |
m_snac_3_c_loop: |
inc edx |
cmp edx, UINS |
jnc m_snac_3_b_end ;>= |
mov cl, [mbuff+10] ; Ǭ |
mov edi, UIN_LEN |
imul edi ,edx |
lea edi, [uins+edi] |
lea esi, [mbuff+11] |
repe cmpsb |
jnz m_snac_3_c_loop |
; |
; UIN ¯à¥¤¥«¥ |
; |
;mov eax, -1 |
;mov ebx, 4 |
;imul ebx, edx |
;mov [stats+ebx], eax |
mov ecx, -1 |
mov ebx, NAME_LEN |
imul ebx, edx |
lea ebx, [names+ebx] |
mov eax, edx |
call loadbb |
jmp m_fin |
m_snac_3_other: |
write_debug 'Unknown SNAC Family 3 Recived' |
jmp m_fin |
; |
; FAMILY 4 |
; |
m_snac_4: |
cmp dx, 5 |
jz m_snac_4_5 |
cmp dx, 7 |
jz m_snac_4_7 |
jmp m_snac_4_other |
; |
; Server sends ICBM service parameters to client |
; |
m_snac_4_5: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
; |
; Client change default ICBM parameters command |
; |
mov [ssnac.wFid], 4 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov eax, ICBM_PARAMS |
mov ebx, buff |
push ecx |
mov ecx, ICBMP_LEN |
call strcpy |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
mov edx, ICBMP_LEN |
call sendsnac |
; |
; Client ask server PRM service limitations |
; |
mov [ssnac.wFid], 9 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
jmp m_fin |
; |
; Message for client from server |
; |
m_snac_4_7: |
; |
; ¯à¥¤¥«ï¥¬ ⨯ á®®¡é¥¨ï ¯® ¯®«î message channel |
; |
xor eax, eax |
mov ax, word [mbuff+10+8] ; +10 - à §¬¥à SNAC |
; +8 ᬥ饨¥ ¤® message channel |
cmp ax, 0100h ; 00 01 |
jz m_snac_ch1 |
cmp ax, 0200h |
jz m_snac_ch2 |
cmp ax, 0400h |
jz m_snac_ch4 |
jmp m_ch_other |
; |
; channel 1 plain text |
; |
m_snac_ch1: |
; |
; .ª ¢ ®ç¥à¥¤®© à § ®¯¨á ¨¥ ¯à®â®ª®« ¥ ᮢ¯ ¤ ¥â á ॠ«ì®áâìî |
; à §¡¨à ¥¬ ¢á¥ TLV ¯® ¯®à浪ã |
mov eax, dword [mbuff+10] ; cookie |
mov [msg_cookie1], eax |
mov eax, dword [mbuff+10+4] |
mov [msg_cookie2], eax ; ᯮ«ì§ãîâáï ¤«ï ¯®â¢¥à¦¤¥¨ï ¯à¨¥¬ á®®¡é¥¨© |
mov al, [mbuff+10+10] ; Sender UIN length |
mov [ui.bUinLength], al |
push ecx |
movzx ecx, al |
lea eax, [mbuff+10+11] ; UIN string |
lea ebx, [ui.bUin] ; Dest |
call strcpy |
lea ecx, [ecx+10+15] ; ¯¥à¢ë© TLV |
m_snac_ch1_loop: |
movzx eax, word [mbuff+ecx] |
cmp eax, 0100h ;TLV.Type(0x01) - user class |
jz m_snac_ch1_1 |
cmp eax, 0600h ;TLV.Type(0x06) - user status |
jz m_snac_ch1_6 |
cmp eax, 0800h ; Unknown type |
jz m_snac_ch1_8 |
cmp eax, 0500h ; Unknown type |
jz m_snac_ch1_5 |
cmp eax, 0F00h ; TLV.Type(0x0f) - user idle time |
jz m_snac_ch1_f |
cmp eax, 0300h ; TLV.Type(0x03) - account creation time |
jz m_snac_ch1_3 |
cmp eax, 0400h ; TLV.Type(0x04) - automated response flag |
jz m_snac_ch1_4 |
cmp eax, 0200h ; TLV.Type(0x02) - message data |
jz m_snac_ch1_mess |
jmp m_snac_msg_tlv_err |
; |
; ®§¬®¦®, ¤®¯®«¨â¥«ì ï ¨¨ä®à¬ æ¨ï ¡ã¤¥â ®¡à ¡ âë¢ âìáï |
; ® ¯®ª ¥â |
m_snac_ch1_1: |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_6: |
mov eax, dword [mbuff+ecx+4] ; User status |
call ntohl |
mov [ui.dUserStatus], eax |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
; |
; |
jmp m_snac_ch1_loop |
m_snac_ch1_8: |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_5: |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_f: |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_3: |
movzx eax, word [mbuff+ecx+2] ; TLV.Length |
call ntohs |
lea ecx, [eax+ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_4: |
;movzx eax, word [buff+ecx+2] ; TLV.Length |
lea ecx, [ecx+4] |
jmp m_snac_ch1_loop |
m_snac_ch1_mess: |
; |
; |
movzx eax, word [mbuff+ecx+4] ; |
cmp eax, 0105h ; 05 fragment identifier (array of required capabilities) |
jnz m_snac_ch1_fr_err ; 01 fragment version |
movzx eax, word [mbuff+ecx+6] ; Length |
call ntohs |
lea ecx, [ecx+eax+8] ; யã᪠¥¬ byte array of required capabilities (1 - text) |
movzx eax, word [mbuff+ecx] ; fragment identifier (message text) |
cmp eax, 0101h ; fragment version |
jnz m_snac_ch1_fr_err |
movzx eax, word [mbuff+ecx+2] ; TLV Length |
call ntohs |
xchg eax, ecx |
lea eax, [eax+8] ; ç «® ⥪á⮢®£® á®®¡é¥¨ï |
lea ecx, [ecx-4] ; - sizeof Message charset number, Message charset subset |
push eax |
push ecx |
; |
; 뢮¤¨¬ Message From UIN |
; |
mov eax, MESS |
call strlen |
mov ecx, eax |
mov eax, MESS |
mov ebx, buff |
call strcpy |
lea ebx, [ebx + ecx] |
; |
; ¥¯«®å® ¡ë«® ¡ë ¢ë¢¥á⨠¥ UIN Nickname, ¥á«¨ ® ¥áâì ¢ ª®â ªâ «¨á⥠|
; |
xor esi, esi ; ç¥â稪 |
m_snac_ch1_next_uin: |
cmp esi, UINS |
jz m_snac_ch1_notfound |
mov edx, UIN_LEN |
imul edx, esi |
lea edx, [uins + edx] |
movzx ecx, byte [ui.bUinLength] |
strcmp edx, ui.bUin, ecx |
jz m_snac_ch1_uin |
inc esi |
jmp m_snac_ch1_next_uin |
; |
; ®¤å®¤ï騩 UIN ¥áâì ¢ ª®â ªâ-«¨á⥠|
; |
m_snac_ch1_uin: |
mov edx, NAME_LEN |
imul edx, esi |
lea edx, [names + edx] |
mov eax, edx |
call strlen |
mov ecx, eax |
mov eax, edx |
call strcpy |
jmp m_snac_ch1_msgfrom |
; |
; ᫨ ¯®¤å®¤ï饣® UIN ¥â ¢ ª®â ªâ-«¨á⥠|
; |
m_snac_ch1_notfound: |
lea eax, [ui.bUin] |
movzx ecx, byte [ui.bUinLength] |
call strcpy |
; |
; 뢮¤ á®®¡é¥¨ï "®â ª®£®" |
; |
m_snac_ch1_msgfrom: |
mov [ebx + ecx], byte 0 |
mov eax, buff |
xor ebx, ebx |
call writemsg |
; |
; ¬® á®®¡é¥¨¥ |
; |
pop ecx |
pop eax |
lea eax, [mbuff+eax] |
mov ebx, buff |
call strcpy |
mov [ebx+ecx], byte 0 |
mov eax, buff |
call win2dos |
mov ebx, 00FF0000h |
call writemsg |
; |
; ®¤â¢¥à¦¤ ¥¬ ¯à¨¥¬ |
; |
pop ecx |
; |
; ®ª ¥ ॠ«¨§®¢ ®, â.ª. ¥ ¬®£ã ©â¨ ª«¨¥â, ª®â®àë© íâ® ¨á¯®«ì§ã¥â :-) |
; |
jmp m_fin |
m_snac_msg_tlv_err: |
write_debug 'TLV TYPE MISMATCH' |
pop ecx |
jmp m_fin |
m_snac_ch1_fr_err: |
write_debug 'UNKNOWN FRAGMENT IDENTIFIER OR FRAGMENT VERSION' |
;m_snac_ch1_end: |
pop ecx |
jmp m_fin |
; |
; Channel 2 message format (rtf messages, rendezvous) |
; |
m_snac_ch2: |
; |
; ®â¯à ¢¨¬ á®®¡é¥¨¥, çâ® ª « ¥ ¯®¤¤¥à¦¨¢ ¥âáï |
; ã¦ë ªãª¨ ¨ 㨠|
mov eax, dword [mbuff+10] |
mov [msg_cookie1], eax |
mov eax, dword [mbuff+10+4] |
mov [msg_cookie2], eax |
mov al, [mbuff+10+10] ; Sender UIN length |
mov [ui.bUinLength], al |
push ecx |
movzx ecx, al |
lea eax, [mbuff+10+11] ; UIN string |
lea ebx, [ui.bUin] ; Dest |
call strcpy |
mov [ssnac.wFid], 4 ; Family |
mov [ssnac.wSid], 0Bh ; Subtype |
mov [ssnac.dRi], 0Bh |
mov eax, [msg_cookie1] |
mov dword [buff], eax |
mov eax, [msg_cookie2] |
mov dword [buff+4], eax |
mov word [buff+8], 0200h ; Channel 2 |
mov al, [ui.bUinLength] |
mov [buff+10], al |
lea eax, [ui.bUin] |
lea ebx, [buff+11] |
call strcpy |
lea ecx, [ecx+11] |
mov word [buff+ecx], 0100h ; reason code (1 - unsupported channel, 2 - busted payload, 3 - channel specific) |
mov edx, ecx |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
jmp m_fin |
; |
; Channel 4 message format (typed old-style messages) |
; |
m_snac_ch4: |
m_ch_other: |
write_debug 'Unknown message channel' |
jmp m_fin |
m_snac_4_other: |
write_debug 'Unknown SNAC Family 4 recived' |
jmp m_fin |
; |
; FAMILY 9 |
; |
m_snac_9: |
cmp dx, 3 |
jz m_snac_9_3 |
jmp m_snac_9_other |
; |
; Server sends PRM service limitations to client |
; |
m_snac_9_3: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
if USE_SSI <> 0 |
; |
; ¯à®á á á¥à¢¥à |
; |
; |
; Request contact list (first time) |
; |
mov [ssnac.wFid], 13h ; Family |
mov [ssnac.wSid], 04h ; Subtype |
mov [ssnac.dRi], 04h ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
else |
; ⪫î祮, ⪠¥ ¯®¤¤¥à¦¨¢ ¥âáï SIQ |
; |
; |
; Client ask server for SSI service limitations |
; |
;mov [ssnac.wFid], 13h ; Family |
;mov [ssnac.wSid], 2 ; Subtype |
;mov [ssnac.dRi], 2 ; request-id |
;mov eax, ssnac |
;mov ebx, buff |
;xor edx, edx |
;call sendsnac |
; |
; ¯®á«¥¤ïï áâ ¤¨ï ᮥ¤¨¥¨ï |
; |
; |
; ¯à 訢 ¥¬ á¢®î ¨ä®à¬ æ¨î |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 0Eh ; Subtype |
mov [ssnac.dRi], 0Eh ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx ; TLV head len |
call sendsnac |
; |
; Client sends its DC info and status to server |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 1Eh ; Subtype |
mov [ssnac.dRi], 1Eh ; request-id |
mov [buff], 0 ; TLV type 06 |
mov [buff+1], 6h ; |
mov [buff+2], 0 ; TLV data length |
mov [buff+3], 4 ; |
; |
; |
mov ax, STATUS_DCDISABLED ; DC disabled |
call htons |
mov word [buff+4], ax |
mov ax, STATUS_ONLINE |
mov [status], ax |
mov word [buff+6], ax |
mov eax, ssnac |
mov ebx, buff |
mov edx, 8 ; TLV head len+ data len |
call sendsnac |
; |
; ë£à㦠¥¬ á¥à¢¥à |
; |
call uploadkl |
; |
; ë£à㦠¥¬ ¨¢¨§¨¡« «¨áâ, ¯®ª ¯ãá⮩ |
; |
mov [ssnac.wFid], 9 ; Family |
mov [ssnac.wSid], 7 ; Subtype |
mov [ssnac.dRi], 7 |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
; |
; &RQ áâì ¯ ª¥â ãáâ ®¢ª¨ à §à¥è¥¨©. ï ¨á¯®«ì§ãî ¥£® ¡¥§ ¨§¬¥¥¨ï |
; â.ª. ¥ § î, çâ® ® ᮤ¥à¦¨â |
; - ¢®§¬®¦®, ¡ã¤ã ¨á¯®«ì§®¢ âì ¯®§¤¥¥ |
;mov [ssnac.wFid], 15 ; Family |
;mov [ssnac.wSid], 2 ; Subtype |
;mov [ssnac.dRi], 2 |
;mov word [buff], 0100h ; 00 01 encapsulated META_DATA |
;mov word [buff+2], 1000h ; 00 10 Len |
;mov word [buff+4], 000Eh ; LE Len |
;mov word [buff+10], 07D0h ; META_DATA_REQ |
;mov eax, UIN |
;call ascitoint |
;mov dword [buff+6], eax |
;mov word [buff+12], 0102h ; request sequence number (incrementing) |
;mov word [buff+14], 0424h ; META_SET_PERMS_USERINFO |
;mov [buff+16], 1 ; authorization (1-required, 0-not required) |
;mov [buff+17], byte 0 ; webaware (0-no, 1-yes) |
;mov [buff+18], 1 ; dc_perms (0-any, 1-contact, 2-authorization) |
;mov [buff+19], 0 ;unknown |
;mov eax, ssnac |
;mov ebx, buff |
;mov edx, 20 |
; |
; Client READY command |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov eax, FAMILY_ARR |
mov ebx, buff |
push ecx |
mov ecx, FA_LEN |
call strcpy |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
mov edx, FA_LEN |
call sendsnac |
; |
; ¯à 訢 ¥¬ offline á®®¡é¥¨ï |
; |
mov [ssnac.wFid], 15h ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov word [buff], 0100h ; TLV type 01 |
mov word [buff+2], 0A00h ; 00 0a Ǭ |
mov word [buff+4], 0008h ; 08 00 |
lea eax, [vtable + vartable.uin] |
call ascitoint |
mov dword [buff+6], eax |
mov word [buff+10], 003Ch ; 3C 00 - ¯à®á ®ää« ©®¢ë¥ á®®¡é¥¨ï |
mov word [buff+12], 0002 ; 02 00 - request sequence number |
mov edx, 14 ; ¡é¨© à §¬¥à ¤ ëå ¢ ¡ãä¥à¥ |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
; |
; ¯à 訢 ¥¬ ¨ä®à¬ æ¨î ¢á¥å UIN |
; |
call getinfo |
; |
; § ¢¥à襮 ᮥ¤¨¥¨¥ |
; |
mov [login], 2 |
end if ; USE_SSI = 0 |
jmp m_fin |
m_snac_9_other: |
write_debug 'Unknown SNAC Family 9 Recived' |
jmp m_fin |
; |
; FAMILY 13 |
; |
m_snac_13: |
cmp dx, 3 |
jz m_snac_13_3 |
cmp dx, 6 |
jz m_snac_13_6 |
cmp dx, 0fh |
jz m_snac_13_F |
jmp m_snac_13_other |
; |
; Server sends SSI service limitations to client |
; |
m_snac_13_3: |
; |
; ¡à ¡®âª¨ ¯®ª ¥â |
; |
; |
; SNAC(13,05) Client check if its local SSI copy is up-to-date |
; |
mov [ssnac.wFid], 13h ; Family |
mov [ssnac.wSid], 5 ; Subtype |
mov [ssnac.dRi], 5 ; request-id |
mov eax, ssnac |
; |
; |
; |
mov [buff], 03Dh ; |
mov [buff+1], 0E7h ; modification date/time of client local SSI copy |
mov [buff+2], 48h ; |
mov [buff+3], 17h ; |
; |
; |
mov [buff+4], 00 ; |
mov [buff+5], 00h ; number of items in client local SSI copy |
mov ebx, buff |
mov edx, 5 |
call sendsnac |
jmp m_fin |
; |
; Server contact list reply |
; |
m_snac_13_6: |
lea eax, [mbuff+10] ; eax § £à㦠¥¬ ¤à¥á ¯à¨¥¬®£® ¡ãä¥à + à §¬¥à § £®«®¢ª snac |
call ssi_process_data ; ¡à ¡®âª ¯ ª¥â á |
; |
; ªâ¨¢¨à㥬 SSI |
; |
mov [ssnac.wFid], 13h ; Family |
mov [ssnac.wSid], 7 ; Subtype |
mov [ssnac.dRi], 7 ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
; |
; ¯®á«¥¤ïï áâ ¤¨ï ᮥ¤¨¥¨ï |
; |
; |
; ¯à 訢 ¥¬ á¢®î ¨ä®à¬ æ¨î |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 0Eh ; Subtype |
mov [ssnac.dRi], 0Eh ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx ; TLV head len |
call sendsnac |
; |
; Client sends its DC info and status to server |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 1Eh ; Subtype |
mov [ssnac.dRi], 1Eh ; request-id |
mov [buff], 0 ; TLV type 06 |
mov [buff+1], 6h ; |
mov [buff+2], 0 ; TLV data length |
mov [buff+3], 4 ; |
; |
; |
mov ax, STATUS_DCDISABLED ; DC disabled |
call htons |
mov word [buff+4], ax |
mov ax, STATUS_ONLINE |
mov [status], ax |
mov word [buff+6], ax |
mov eax, ssnac |
mov ebx, buff |
mov edx, 8 ; TLV head len+ data len |
call sendsnac |
; |
; ë£à㦠¥¬ á¥à¢¥à |
; FIXME ®§¬®¦®, §¤¥áì ¥ 㦠íâ äãªæ¨ï |
;call uploadkl |
; |
; ë£à㦠¥¬ ¨¢¨§¨¡« «¨áâ, ¯®ª ¯ãá⮩ |
; |
;mov [ssnac.wFid], 9 ; Family |
;mov [ssnac.wSid], 7 ; Subtype |
;mov [ssnac.dRi], 7 |
;mov eax, ssnac |
;mov ebx, buff |
;xor edx, edx |
;call sendsnac |
; |
; &RQ áâì ¯ ª¥â ãáâ ®¢ª¨ à §à¥è¥¨©. ï ¨á¯®«ì§ãî ¥£® ¡¥§ ¨§¬¥¥¨ï |
; â.ª. ¥ § î, çâ® ® ᮤ¥à¦¨â |
; - ¢®§¬®¦®, ¡ã¤ã ¨á¯®«ì§®¢ âì ¯®§¤¥¥ |
;mov [ssnac.wFid], 15 ; Family |
;mov [ssnac.wSid], 2 ; Subtype |
;mov [ssnac.dRi], 2 |
;mov word [buff], 0100h ; 00 01 encapsulated META_DATA |
;mov word [buff+2], 1000h ; 00 10 Len |
;mov word [buff+4], 000Eh ; LE Len |
;mov word [buff+10], 07D0h ; META_DATA_REQ |
;mov eax, UIN |
;call ascitoint |
;mov dword [buff+6], eax |
;mov word [buff+12], 0102h ; request sequence number (incrementing) |
;mov word [buff+14], 0424h ; META_SET_PERMS_USERINFO |
;mov [buff+16], 1 ; authorization (1-required, 0-not required) |
;mov [buff+17], byte 0 ; webaware (0-no, 1-yes) |
;mov [buff+18], 1 ; dc_perms (0-any, 1-contact, 2-authorization) |
;mov [buff+19], 0 ;unknown |
;mov eax, ssnac |
;mov ebx, buff |
;mov edx, 20 |
; |
; Client READY command |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov eax, FAMILY_ARR |
mov ebx, buff |
push ecx |
mov ecx, FA_LEN |
call strcpy |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
mov edx, FA_LEN |
call sendsnac |
; |
; ¯à 訢 ¥¬ offline á®®¡é¥¨ï |
; |
mov [ssnac.wFid], 15h ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov word [buff], 0100h ; TLV type 01 |
mov word [buff+2], 0A00h ; 00 0a Ǭ |
mov word [buff+4], 0008h ; 08 00 |
lea eax, [vtable + vartable.uin] |
call ascitoint |
mov dword [buff+6], eax |
mov word [buff+10], 003Ch ; 3C 00 - ¯à®á ®ää« ©®¢ë¥ á®®¡é¥¨ï |
mov word [buff+12], 0002 ; 02 00 - request sequence number |
mov edx, 14 ; ¡é¨© à §¬¥à ¤ ëå ¢ ¡ãä¥à¥ |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
; |
; ¯à 訢 ¥¬ ¨ä®à¬ æ¨î ¢á¥å UIN |
; FIXME ®§¬®¦®, §¤¥áì ¥ 㦠íâ äãªæ¨ï |
;call getinfo |
; |
; § ¢¥à襮 ᮥ¤¨¥¨¥ |
; |
mov [login], 2 |
jmp m_fin |
; |
; Server tell client its local copy up-to-date |
; |
m_snac_13_F: |
; |
; ¡à ¡®âª¨ ¥â |
; |
; |
; Client activates server SSI data |
; |
mov [ssnac.wFid], 13h ; Family |
mov [ssnac.wSid], 7 ; Subtype |
mov [ssnac.dRi], 7 ; request-id |
mov eax, ssnac |
mov ebx, buff |
xor edx, edx |
call sendsnac |
; |
; ¯®á«¥¤ïï áâ ¤¨ï ᮥ¤¨¥¨ï |
; |
; |
; Client sends its DC info and status to server |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 1Eh ; Subtype |
mov [ssnac.dRi], 1Eh ; request-id |
mov [buff], 0 ; TLV type 06 |
mov [buff+1], 6h ; |
mov [buff+2], 0 ; TLV data length |
mov [buff+3], 4 ; |
; |
; |
mov ax, STATUS_DCDISABLED ; DC disabled |
call htons |
mov word [buff+4], ax |
; |
; |
mov ax, [status] |
mov word [buff+6], ax |
mov eax, ssnac |
mov ebx, buff |
mov edx, 8 ; TLV head len+ data len |
call sendsnac |
; |
; Client READY command |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov eax, FAMILY_ARR |
mov ebx, buff |
push ecx |
mov ecx, FA_LEN |
call strcpy |
pop ecx |
mov eax, ssnac |
mov ebx, buff |
mov edx, FA_LEN |
call sendsnac |
; |
; ¯à 訢 ¥¬ offline á®®¡é¥¨ï |
; |
mov [ssnac.wFid], 15h ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 2 ; request-id |
mov word [buff], 0100h ; TLV type 01 |
mov word [buff+2], 0A00h ; 00 0a Ǭ |
mov word [buff+4], 0008h ; 08 00 |
lea eax, [vtable + vartable.uin] |
call ascitoint |
mov dword [buff+6], eax |
mov [buff+10], 003Ch ; 3C 00 - ¯à®á ®ää« ©®¢ë¥ á®®¡é¥¨ï |
mov [buff+12], 0002 ; 02 00 - request sequence number |
mov edx, 14 ; ¡é¨© à §¬¥à ¤ ëå ¢ ¡ãä¥à¥ |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
jmp m_fin |
m_snac_13_other: |
write_debug 'Unknown SNAC Family 13 Recived' |
jmp m_fin |
; |
; Family 15 |
; |
m_snac_15: |
cmp dx, 3 |
jz m_snac_15_3 |
jmp m_snac_15_other |
; |
; Server sends message #N |
; |
m_snac_15_3: |
; |
; ¯à¥¤¥«ï¥¬ ¯®¤â¨¯ ¯à¨ï⮣® ¯ ª¥â |
; |
;write_debug 'SNAC 15, 3' |
xor eax, eax |
mov ax, word [mbuff+10] ; + SNAC.head size |
cmp ax, 0100h ; 00 01 TLV type |
jnz m_snac_tlv_err |
mov ax, word [mbuff+10+10] |
cmp ax, 0041h ; Offline Message |
jz m_snac_offline_mes |
cmp ax, 0042h ; End messages |
jz m_snac_offline_end |
cmp ax, 07DAh |
jz m_snac_meta_data |
write_debug 'Unknown Subtype SNAC (15,3)' |
jmp m_fin |
m_snac_offline_mes: |
mov eax, MESS ; |
call strlen ; 뢮¤¨¬ áâபã á á®®¡é¥¨¥¬ ® ®â¯à ¢¨â¥«¥ ¨ ¢à¥¬¥¨ ®â¯à ¢ª¨ |
push ecx ; |
mov ecx, eax ; |
mov eax, MESS |
mov ebx, buff |
call strcpy |
mov eax, dword [mbuff+14+10] ; Sender UIN |
lea ebx, [buff+ecx] ; ®á«¥ áâà®çª¨ ® á®®¡é¥¨¨ |
call int2strd |
lea ebx, [ebx+eax] |
mov [ebx], byte ' ' |
inc ebx |
; + Ǭ UIN |
movzx eax, byte [mbuff+21+10] ; Day |
call int2strd |
lea ebx, [ebx+eax] |
mov [ebx], byte '.' |
inc ebx |
movzx eax, byte [mbuff+20+10] ;Mounth |
call int2strd |
lea ebx, [ebx+eax] |
mov [ebx], byte ' ' |
inc ebx |
movzx eax, [mbuff+22+10] ; Hour |
call int2strd |
lea ebx, [ebx+eax] |
mov [ebx], byte ':' |
inc ebx |
movzx eax, [mbuff+23+10] ; Minute |
call int2strd |
lea ebx, [ebx+eax] |
;mov [ebx], byte ' ' |
;inc ebx |
mov [ebx], byte 0 ; Str end |
mov eax, buff |
xor ebx, ebx |
call writemsg |
movzx ecx, word [mbuff+26+10] ; «¨ á®®®¡é¥¨ï |
lea eax, [mbuff+28+10] |
mov ebx, buff |
call strcpy |
mov [ebx+ecx], byte 0 |
mov eax, buff |
call win2dos ;¯¥à¥ª®¤¨à㥬 |
mov ebx, 00FF0000h ;¢¥â |
call writemsg |
pop ecx |
jmp m_fin |
m_snac_offline_end: |
; |
; ¤ «ï¥¬ á®®¡é¥¨ï á¥à¢¥à¥ |
; |
mov [ssnac.wFid], 15h ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 0602h ; request-id |
mov word [buff], 0100h ; 00 01 TLV.Type(1) - encapsulated META_DATA1 |
mov word [buff+2], 0A00h ; 00 0A TLV.Length |
mov word [buff+4], 0008h ; 08 00 data chunk size (TLV.Length-2) |
lea eax, [vtable + vartable.uin] |
call ascitoint |
mov dword [buff+6], eax ; xx xx xx xx (LE) client uin |
mov word [buff+10], 003Eh ; 3E 00 (LE) data type: delete offline msgs request cmd |
mov word [buff+12], 0007h ; xx xx (LE) request sequence number |
mov edx, 14 ; §¬¥à ¤ ëå |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
jmp m_fin |
; |
; ⢥⠧ ¯à®á ® ¯®«ì§®¢ ⥫ïå |
; |
m_snac_meta_data: |
; |
; ¯à¥¤¥«ï¥¬ ®ç¥à¥¤®© ¯®¤â¨¯ :-) |
; |
mov ax, word [mbuff+10+14] |
cmp ax, 0104h ;data subtype: META_SHORT_USERINFO |
jz m_snac_short_userinfo |
cmp ax, 00C8h |
jz m_snac_basic_userinfo ;data subtype: META_BASIC_USERINFO |
write_debug 'Unknown META DATA subtype' |
jmp m_fin |
m_snac_short_userinfo: |
; |
; § ¢á¥© ¨ä®à¬ 樨 ¯®ª 㦥 ⮫쪮 ¨ª |
; |
mov al, [mbuff+10+16] |
cmp al, 0Ah ;success byte |
jnz m_fin |
movzx eax, word [mbuff+10+12] ;request sequence number |
; |
; § ¯à®á¥ ï ¨á¯®«ì§®¢ « ¯®à浪®¢ë© ®¬¥à î§¥à ¢ |
lea ebx, [mbuff+10+19] ;nickname string |
; «¨ áâப¨ ¥ 㦠, â.ª. áâப Null-Terminated |
;¯à¥¤¥«ï¥¬ áâ âãá |
mov ecx, 4 |
imul ecx, eax |
mov ecx, [stats+ecx] |
call loadbb |
jmp m_fin |
; |
; ⪠SIQ § ¯à®á ª®à®âª®© ¨äë ®â¢¥ç ¥â |
; ¯ ª¥â®¬ ¡ §®¢®© ¨ä®à¬ 樨, ॠ«¨§ãî ¯®ª ⮫쪮 ¥£® |
; |
m_snac_basic_userinfo: |
mov al, [mbuff+10+16] |
cmp al, 0Ah ;success byte |
jnz m_fin |
movzx eax, word [mbuff+10+12] ;request sequence number |
; |
; § ¯à®á¥ ï ¨á¯®«ì§®¢ « ¯®à浪®¢ë© ®¬¥à î§¥à ¢ |
lea ebx, [mbuff+10+19] ;nickname string |
; «¨ áâப¨ ¥ 㦠, â.ª. áâப Null-Terminated |
;¯à¥¤¥«ï¥¬ áâ âãá |
mov ecx, 4 |
imul ecx, eax |
mov ecx, [stats+ecx] |
call loadbb |
jmp m_fin |
m_snac_tlv_err: |
write_debug 'TLV TYPE MISMATCH' |
jmp m_fin |
m_snac_15_other: |
write_debug 'Unknown SNAC Family 15 Recived' |
jmp m_fin |
m_other_snac: |
write_debug 'Unknown SNAC recived' |
jmp m_fin |
m_fin: |
;pop edx |
;pop ebx |
;pop eax |
popad |
popf |
ret |
; «ï ¯¥à¥¢®¤ DWORD ¨§ Little Endian ¢ Big Endian |
; ¨ ®¡®à®â :-) |
; <--EAX DWORD |
; -->EAX |
; |
ntohl: |
htonl: |
;pushf |
push ebx |
;push ecx |
xor ebx, ebx |
mov bl, ah |
mov bh, al |
shl ebx, 16 |
shr eax, 16 |
mov bl, ah |
mov bh, al |
mov eax, ebx |
;pop ecx |
pop ebx |
;popf |
ret |
; «ï ¯¥à¥¢®¤ WORD ¨§ Little Endian ¢ Big Endian |
; <--AX WORD |
; -->AX WORD |
; |
ntohs: |
htons: |
;pushf |
push ebx |
xor ebx, ebx |
mov bl, ah |
mov bh, al |
mov eax, ebx |
pop ebx |
;popf |
ret |
; |
; ¯ àá¨â SNAC |
; <--EAX 㪠§ ⥫ì SNAC_head |
; <--EBX 㪠§ â¥«ì ¡ãää¥à |
; -->EAX 㪠§ ⥫ì ç «® ¤ ëå = buffer+sizeof SNAC_head |
; |
; |
snacpar: |
pushf |
push ecx |
;push edx |
mov cl, [ebx+1] ; Family (service) id number ¬« ¤è¨© ¡ ©â |
mov ch, [ebx] ; áâ à訩 |
mov word [eax], cx |
mov cl, [ebx+3] ; Family subtype id number |
mov ch, [ebx+2] ; |
mov word [eax+2], cx |
mov cl, [ebx+5] ; SNAC flags |
mov ch, [ebx+4] ; |
mov word [eax+4], cx ; |
mov cl, [ebx+7] ; |
mov ch, [ebx+6] ; |
mov word [eax+8], cx ; SNAC request id |
mov cl, [ebx+8] ; |
mov ch, [ebx+7] ; |
mov word [eax+6], cx ; |
add ebx, 10 ; §¬¥à § £®«®¢ª |
mov eax, ebx |
;pop edx |
pop ecx |
popf |
ret |
; |
; ¯ àá¨â userinfo block |
; FIXIT |
; |
; userinfopar: |
; pushf |
; |
; |
; |
; |
; |
; |
; popf |
; ret |
; |
; ¯®á뫪 á®®¡é¥¨ï |
; [eax] <-- ⥪áâ®¢ë© ¡ãä¥à \ |
; [ebx] <-- UIN / Null-terminated |
sendmsg: |
pushf |
pushad |
push eax |
push ebx |
mov [ssnac.wFid], 4h ; Family |
mov [ssnac.wSid], 6 ; Subtype |
mov [ssnac.dRi], 106h ; request-id |
; |
; ®«ãç ¥¬ ¢à¥¬ï á § ¯ã᪠á¨á⥬ë, ¤«ï cookie |
; |
;mov eax, 26 |
;mov ebx, 9 |
;int 40h |
mcall 26, 9 |
mov dword [buff], eax ; Cookie 1 |
mov dword [buff+4], eax ; Cookie 2 |
mov word [buff+8], 0100h ; Message channel 00 01 |
pop ebx |
mov eax, ebx |
call strlen |
mov [buff+10], al |
mov ecx, eax |
mov eax, ebx |
lea ebx, [buff+11] |
call strcpy |
lea ecx, [ecx+11] |
mov word [buff+ecx], 0200h ; TLV.Type(0x02) - message data |
;push ecx ; |
; TLV.Length |
mov word [buff+ecx+4], 0105h ; 05 01 01 - fragment version, 05 - fragment identifier |
mov word [buff+ecx+6], 0100h ; data length |
mov [buff+ecx+8], 01 ; byte array of required capabilities (1 - text) |
mov [buff+ecx+9], 01 ; fragment identifier (text message) |
mov [buff+ecx+10], 01 ; fragment version |
pop ebx |
mov eax, ebx |
call strlen |
mov edx, eax |
lea eax, [eax+4] ; «¨ á®®¡é¥¨ï + Message charset number+ Message language number |
call htons |
mov word [buff+ecx+11], ax |
mov eax, edx |
lea eax, [eax+13] ; + ¤«¨ á«ã¦¥¡ëå ¤ ëå |
call htons |
mov word [buff+ecx+2], ax |
mov word [buff+ecx+13], 0700h ; Message charset number |
mov word [buff+ecx+15], 0300h ; Message language number |
mov eax, ecx |
mov ecx, edx ; Len |
lea edx, [eax+17] |
mov eax, ebx ;Source |
lea ebx, [buff+edx] ;Dest |
call strcpy |
lea ecx, [ecx+edx] ; +String length |
mov [buff+ecx], byte 0 |
mov eax, ebx |
call dos2win |
mov word [buff+ecx], 0600h ; TLV.Type(0x06) - store message if recipient offline |
mov word [buff+ecx+2], 0 ; TLV.Length |
lea edx, [ecx+4] ; +TLV_head length |
mov eax, ssnac |
mov ebx, buff |
mov ecx, [socket] |
call sendsnac |
popad |
popf |
ret |
; |
; ¯à®á ¨ä®à¬ 樨 UIN®¢ |
; |
getinfo: |
pushad |
pushf |
; |
; SNAC (15,2) - Meta information request |
; |
mov [ssnac.wFid], 15h ; Family |
mov [ssnac.wSid], 2 ; Subtype |
mov [ssnac.dRi], 702h ; request-id |
mov word [buff], 0100h ;TLV.Type(1) - encapsulated META_DATA |
mov word [buff+2], 1000h ; 00 10 TLV.Length |
mov word [buff+4], 000Eh ; (LE) data chunk size (TLV.Length-2) |
lea eax, [vtable + vartable.uin] |
call ascitoint |
mov dword [buff+6], eax ;(LE) request owner uin |
mov word [buff+10], 07D0h ;data type: META_DATA_REQ |
;mov word [buff+12], 0008h ; request sequence number <<<-- ®¦¥â ¬¥ïâìáï FIXIT |
mov word [buff+14], 04BAh ; data subtype: META_SHORTINFO_REQUEST |
mov ecx, [socket] |
mov edx, 20 |
xor esi, esi ; ç¥â稪 |
xor eax, eax |
gi_loop: |
mov ebx, esi |
mov word [buff+12], bx ; request sequence number |
mov ebx, UIN_LEN |
imul ebx, esi |
mov al, [uins+ebx] |
cmp al, 0 |
jz gi_end |
lea eax, [uins+ebx] |
call ascitoint |
mov dword [buff+16], eax |
mov eax, ssnac |
mov ebx, buff |
call sendsnac |
inc esi |
cmp esi, UINS |
jnc gi_end |
jmp gi_loop |
gi_end: |
popf |
popad |
ret |
; |
; £à㦠¥¬ «®ª «ìë© á¥à¢¥à ¤«ï ¯®«ã票ï áâ âãá ஢ |
; |
uploadkl: |
pushf |
pushad |
; |
; Add buddy(s) to contact list |
; |
mov [ssnac.wFid], 3 ; Family |
mov [ssnac.wSid], 4 ; Subtype |
mov [ssnac.dRi], 4 ; request-id |
xor esi, esi ; ç¥â稪 |
xor edx, edx ; ¯®«¥® ¡ ©â |
ukk_loop: |
mov ebx, UIN_LEN |
imul ebx, esi |
mov al, [uins+ebx] |
cmp al, 0 |
jz ukk_end |
lea eax, [uins+ebx] |
call strlen |
mov [buff+edx], al |
inc edx |
mov ecx, eax |
lea eax, [uins+ebx] ; Source |
lea ebx, [buff+edx] |
call strcpy |
add edx, ecx |
inc esi |
cmp esi, UINS |
jz ukk_end |
jmp ukk_loop |
ukk_end: |
mov eax, ssnac |
mov ebx, buff |
mov ecx, [socket] |
call sendsnac |
popad |
popf |
ret |
; |
; |
; |
sendkeep: |
pushf |
pushad |
cmp [login], 2 |
jnz @f |
mov ax, [timer] |
cmp ax, 300 ;60 c |
jb @f |
mov [timer], 0 |
mov [flap.bId], FLAP_ID |
mov [flap.bCh], 5 ;Keep alive |
mov [flap.wDs], 0 |
inc [seq] |
mov ax, [seq] |
mov [flap.wSn], ax |
mov eax, flap |
mov ebx, buff |
mov ecx, [socket] |
call sendflap |
@@: |
popad |
popf |
ret |
; |
; ãªæ¨ï ¤«ï ãáâ ®¢ª¨ áâ âãá |
; áâ âãá ¢ ¯¥à¥¬¥®© status |
setstatus: |
push eax |
push ebx |
push edx |
; |
; Client sends its DC info and status to server |
; |
mov [ssnac.wFid], 1 ; Family |
mov [ssnac.wSid], 1Eh ; Subtype |
mov [ssnac.dRi], 1Eh ; request-id |
mov [buff], 0 ; TLV type 06 |
mov [buff+1], 6h ; |
mov [buff+2], 0 ; TLV data length |
mov [buff+3], 4 ; |
; |
; |
mov ax, STATUS_DCDISABLED ; DC disabled |
call htons |
mov word [buff+4], ax |
; |
; |
mov ax, [status] |
mov word [buff+6], ax |
mov eax, ssnac |
mov ebx, buff |
mov edx, 8 ; TLV head len+ data len |
call sendsnac |
pop edx |
pop ebx |
pop eax |
ret |
; |
; ªà®á ¯à®¯ã᪠¥â ¢á¥ ¯à®¡¥«ë ¢ áâப¥ ¤® |
; 1 £® § ç 饣® ᨬ¢®« |
; eax - 㪠§ ⥫ì null-terminated áâபã |
macro skip_spaces { |
local ..sp_end, ..sp_loop |
push ebx |
push ecx |
xor ebx, ebx |
xor ecx, ecx |
..sp_loop: |
mov bl, [eax + ecx] |
cmp bl, 0x20 |
jnz ..sp_end |
inc ecx |
jmp ..sp_loop |
..sp_end: |
lea eax, [eax + ecx] |
pop ecx |
pop ebx |
} |
; |
; ¡à ¡®âª ª®¬ ¤ |
; ¥ax ¯¥à¥¤ ¥âáï 㪠§ ⥫ì áâபã. ®¬ ¤ ¨ à£ã¬¥âë à §¤¥«¥ë ¯à®¡¥«®¬ |
; ª®¬ ¤ ç¨ ¥âáï á / |
; ¢ eax - १ã«ìâ ⠢믮«¥¨ï ª®¬ ¤ë, -1 ª®¬ ¤ ¥ áãé¥áâ¢ã¥â, 0 ®ª, ¤à㣨¥ § ¢¨áï⠮⠪®¬ ¤ë |
cmd: |
push ebx |
push ecx |
push edi |
push esi |
; |
; ஢¥à¨âì ¯¥à¢ë© ᨬ¢®« |
; |
xor ebx, ebx |
mov bl, [eax] |
cmp bl, '/' |
jnz cmd_end |
; |
; §¤¥«¥¨¥ ¯® 1© ¡ãª¢¥ ª®¬ ¤ë |
; |
mov bl, [eax + 1] |
cmp bl, 'c' |
jz cmd_c |
cmp bl, 'e' |
jz cmd_e |
cmp bl, 's' |
jz cmd_s |
jmp cmd_no |
cmd_c: |
cmd_e: |
lea ebx, [eax + 1] |
strcmp ebx, str_exit, str_exit.len |
jz cmd_exit |
jmp cmd_no |
cmd_s: |
lea ebx, [eax + 1] |
strcmp ebx, str_status, str_status.len |
jz cmd_status |
jmp cmd_no |
cmd_exit: |
cmd_status: |
; |
; ãáâ ®¢¨âì áâ âãá ¨ ¯®á« âì ¯ ª¥â ᬥë áâ âãá |
; |
lea eax, [eax + 1 + str_status.len] |
skip_spaces |
strcmp eax, str_online, str_online.len |
jz cmd_st_online |
strcmp eax, str_away, str_away.len |
jz cmd_st_away |
strcmp eax, str_na, str_na.len |
jz cmd_st_na |
strcmp eax, str_dnd, str_dnd.len |
jz cmd_st_dnd |
strcmp eax, str_bisy, str_bisy.len |
jz cmd_st_bisy |
strcmp eax, str_free4chat, str_free4chat.len |
jz cmd_st_free4chat |
; |
; â âãá ¥ ®¯à¥¤¥«¥. |
; 뢥á⨠ᮮ¡é¥¨¥ ® ¤®áâã¯ëå áâ âãá å |
; |
mov eax, str_status_message |
xor ebx, ebx |
call writemsg |
jmp cmd_end |
cmd_st_online: |
cmd_st_away: |
cmd_st_na: |
cmd_st_dnd: |
cmd_st_bisy: |
cmd_st_free4chat: |
cmd_no: |
cmd_end: |
pop esi |
pop edi |
pop ecx |
pop ebx |
ret |
; <--- initialised data ---> |
DATA |
include "parser_data.inc" |
include "ssi_data.inc" |
include "comp_data.inc" |
head db 'KI',0 |
; |
MESS db 'Message from ', 0 |
CUSER db 'Current user: ', 0 |
; |
; ¯¨á®ª IP á¥à¢¥à®¢ ICQ |
;205.188.153.121 |
;icq_ip db '64.12.200.089',0 |
;icq_ip db '64.12.161.185',0 |
;icq_ip db '205.188.179.233',0 |
; |
flap FLAP_head |
rflap FLAP_head |
; |
ssnac SNAC_head ; ¤«ï ¯¥à¥¤ ç¨ SNAC |
rsnac SNAC_head ; ¤«ï ¯à¨ï⮣® SNAC |
; |
ui UI_head ; User info |
; |
procinfo process_information |
; |
;UIN db '362820484',0 |
;PASS db 'test',0 |
ID_STRING db 'ICQ Inc. - Product of ICQ (TM).2000b.4.65.1.3281.85',0 |
;ID_STRING db 'ICQ Inc. - Product of ICQ (TM).2001b.5.17.1.3642.85',0 |
;CAPABILITIES db 0x09, 0x46, 0x13, 0x49, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,\ |
;0x97, 0xB1, 0x27, 0x51, 0x24, 0x3C, 0x43, 0x34, 0xAD, 0x22, 0xD6, 0xAB, 0xF7, 0x3F, 0x14, 0x92,\ |
CAPABILITIES db 0x2E, 0x7A, 0x64, 0x75, 0xFA, 0xDF, 0x4D, 0xC8, 0x88, 0x6F, 0xEA, 0x35, 0x95, 0xFD, 0xB6, 0xDF,\ |
'KOLIBRI KI(cq)',0,0 |
;0x09, 0x46, 0x13, 0x44, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 |
; 1 áâப |
; {09461349-4C7F-11D1-8222-444553540000} |
; Client supports channel 2 extended, TLV(0x2711) based messages. Currently used only by ICQ clients. |
;ICQ clients and clones use this GUID as message format sign. Trillian client use another GUID |
; in channel 2 messages to implement its own message format (trillian doesn't use TLV(x2711) in SecureIM channel 2 messages!). |
; |
; 2 áâப |
; {97B12751-243C-4334-AD22-D6ABF73F1492} |
; Client supports RTF messages. This capability currently used by ICQ service and ICQ clients. |
; |
; 4 áâப |
; {0946134E-4C7F-11D1-8222-444553540000} |
; Client supports UTF-8 messages. This capability currently used by AIM service and AIM clients |
; |
; |
; From &RQ |
; |
;CAPABILITIES db 0x09, 0x46, 0x13, 0x49, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45,\ ;...P.F.IL.T"DE |
; 0x53, 0x54, 0x00, 0x00, 0x09, 0x46, 0x13, 0x44, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45,\ ;ST...F.DL.T"DE |
; 0x53, 0x54, 0x00, 0x00, 0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45,\ ;ST...F.NL.T"DE |
; 0x53, 0x54, 0x00, 0x00, 0x09, 0x46, 0x00, 0x00, 0x4C, 0x7F, 0x11, 0xD1, 0x82, 0x22, 0x44, 0x45,\ ;ST...F..L.T"DE |
; 0x53, 0x54, 0x00, 0x00, 0x26, 0x52, 0x51, 0x69, 0x6E, 0x73, 0x69, 0x64, 0x65, 0x02, 0x07, 0x09,\ ;ST..&RQinside... |
; 0x00, 0x00, 0x00, 0x00 |
C_LEN = 32 |
;C_LEN = 80 |
ICBM_PARAMS db 0, 0, 0, 0, 0, 0Bh, 01Fh, 040h, 3, 0E7h, 3, 0E7h, 0, 0, 0, 0 |
ICBMP_LEN = 16 ; ^^^ from &RQ |
; |
; from &rq |
; |
FAMILY_ARR db 0x00, 0x01, 0x00, 0x03, 0x01, 0x10, 0x04, 0x7B, 0x00, 0x13, 0x00, 0x02, 0x01, 0x10, 0x04, 0x7B,\ |
0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x04, 0x7B, 0x00, 0x03, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B,\ |
0x00, 0x15, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B, 0x00, 0x04, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B,\ |
0x00, 0x06, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B, 0x00, 0x09, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B,\ |
0x00, 0x0A, 0x00, 0x01, 0x01, 0x10, 0x04, 0x7B, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x06, 0x6A |
; |
; |
; |
FA_LEN = 50h |
; |
; |
; |
ID_NUM = 010Ah |
MAJOR = 05h |
;MAJOR = 04h |
;MINOR = 041h |
MINOR = 011h |
LESSER = 01h |
;BUILD = 0CD1h |
BUILD = 0E3Ah |
DISTR = 055h |
; |
; |
TCB_ESTABLISHED = 4 |
TCB_CLOSED = 11 |
; |
CL_LANG db 'en',0 |
CL_COUNTRY db 'us',0 |
sbuff db 1024 dup 0 ; ãä¥à ¤«ï ¯¥à¥¤ ç¨ ¨á¯®«ì§ã¥âáï ¢ãâਠsendflap |
;recived db 0 ; à¨ïâ® ¤ ëå ¨§ ⥫ ¯ ª¥â |
;rbuff db 1024 dup 0 ; ਥ¬ë© ¡ãä¥à |
tbuff db 512 dup 0 ; «ï TLV |
srv_cookie db 512 dup 0 ; 㪨 ¤«ï ¢â®à¨§ 樨 |
bos_address db 128 dup 0 ; ¤à¥á BOS á¥à¢¥à |
cookie_len dw 0 ; «¨ ªãª¨ |
seq dw 0 ; Sequence number |
bos_ip dd 0 |
bos_port dd 0 |
status dw 0 ; status |
mbuff db 2048 dup 0 ; «ï ¯à¨¥¬ |
MBUFF_SIZE = 2048 |
hrf db 0 ; « £ ¯à¨¥¬ § £®«®¢ª |
mouse_flag dd 0 |
socket dd 0 |
login db 0 |
msg_cookie1 dd 0 ; ᯮ«ì§ãîâáï ¤«ï ¯®â¢¥à¦¤¥¨ï ¯à¨¥¬ á®®¡é¥¨© |
msg_cookie2 dd 0 ; |
curruser db 0 ; ⥪ã騩 ¯®«ì§®¢ ⥫ì, ª®â®à®¬ã ¡ã¤ãâ ®â¯à ¢«ïâìáï á®®¡é¥¨ï |
; - ®¬¥à ¢ ¯® ¯®à浪ã |
timer dw 0 |
;ltest db "ADMIN",0 |
buff db 1024 dup 0 |
; lbuff db 8 dup 0 ; «ï 1 ¯ ª¥â ®â á¥à¢¥à |
; |
; âப¨ ª®¬ ¤ ¤«ï áà ¢¥¨ï |
; |
str_status db 'status ' |
str_status.len = $ - str_status |
str_exit db 'exit ' |
str_exit.len = $ - str_exit |
; |
; âப¨ áâ âãᮢ ¤«ï áà ¢¥¨ï |
; |
str_away db 'away' |
str_away.len = $ - str_away |
str_dnd db 'dnd' |
str_dnd.len = $ - str_dnd |
str_bisy db 'bisy' |
str_bisy.len = $ - str_bisy |
str_na db 'na' |
str_na.len = $ - str_na |
str_online db 'online' |
str_online.len = $ - str_online |
str_free4chat db 'free4chat' |
str_free4chat.len = $ - str_free4chat |
str_status_message db '®áâã¯ë¥ áâ âãáë: away, bisy, na, dnd, online, free4chat',0 |
; |
; |
; |
cfg_message db 'Config:',0 |
; |
; EDITBOXES |
; |
inputbuff: |
rb 512 |
inputbox edit_box 490,10,460,0xffffff,0x6a9480,0,0xAABBCC,0,511,inputbuff,ed_focus,0,0 |
; <--- uninitialised data ---> |
UDATA |
MEOS_APP_END |
; <--- end of MenuetOS application ---> |
/programs/network_old/icq/trunk/lang.inc |
---|
0,0 → 1,0 |
lang fix en |
/programs/network_old/icq/trunk/README.TXT |
---|
0,0 → 1,37 |
v 0.01 |
Âåðñèÿ òåñòîâàÿ, ïîýòîìó ìíîãî íåäîðàáîòîê |
è âûâîäÿòñÿ îòëàäî÷íûå ñîîáùåíèÿ |
Ïîääåðæèâàåòñÿ: |
* Ñåðâåðíûé ÊË |
* ïåðåäà÷à/ïðèåì ñîîáùåíèé plain-text |
* Ïåðåêîäèðîâêà CP866<->CP1251 |
* Ïðèåì offline ñîîáùåíèé |
* Îòïðàâêà ñîîáùåíèÿ ïîëüçîâàòåëþ íå â êîíòàêò-ëèñòå |
/UIN Ñîîáùåíèå |
Íåäîðàáîòêè: Ìíîãî :-) |
* Îòêëþ÷åíî çàêðûòèå ñîêåòîâ - ÿäðî âèñíåò, ïðè |
ïîïûòêå çàêðûòü ñîêåò |
* Âñå ñîîáùåíèÿ îò ðàçíûõ þçåðîâ â îäíîì ïîëå âûâîäà |
* Íåëüçÿ ñìåíèòü ñòàòóñ |
* Íåëüçÿ îòêëþ÷èòñÿ, îïÿòü æå èç-çà çàêðûòèÿ ñîêåòîâ |
* Íå ïîääåðæèâàåòñÿ UTF-8 è RTF ñîîáùåíèÿ |
* Èç èíôîðìàöèè î þçåðå äîñòóïåí òîëüêî íèê |
* editbox èíîãäà âåäåò ñåáÿ ñòðàííî :-) |
* .......... |
Âûðàæàþ áëàãîäàðíîñòü âñåì ðàçðàáîò÷èêàì OS Kolibri |
çà ïðåêðàñíûå èíñòðóìåíòû è äîêóìåíòàöèþ, áåç êîòîðîé ÿ áû |
íè÷åãî íå íàïèñàë :-), à òàêæå ïðîåêòó iserverd.khstu.ru, |
ñåðâåð è îïèñàíèÿ ïðîòîêîëîâ êîòîðîãî ÿ èñïîëüçîâàë. |
åñëè ó âàñ åñòü êàêèå-íèáóäü ïðåäëîæåíèÿ, ïðèñûëàéòå íà lv4evil@yandex.ru |
/programs/network_old/icq/trunk/SSI_INFO.txt |
---|
0,0 → 1,56 |
00 00 08 00 07 36 32 31 38 38 39 37 0A 1E 43 18 .....6218897..C. |
^^ byte Version number of SSI protocol (currently 0x00) |
^^ ^^ word Number of items in this snac |
^^ ^^ word Length of the item name |
^^ ^^ ^^ ^^ ^^ ^^ ^^ string Item name string |
^^ ^^ word Group ID# |
^^ ^^ word Item ID# |
00 00 00 0A 01 31 00 06 46 75 6E 42 6F 6F 00 09 .....1..FunBoo.. |
^^ ^^ word Type of item flag (see list bellow) |
^^ ^^ word Length of the additional data |
^^ ^^ word TLV.Type (TLV #1) |
^^ ^^ word TLV.Length |
^^ ^^ ^^ ^^ ^^ ^^ TLV.Value |
31 37 36 33 33 33 30 37 38 17 B7 2A 18 00 00 00 176333078..*.... |
09 01 31 00 05 45 2E 53 2E 56 00 07 36 32 31 38 ..1..E.S.V..6218 |
38 39 38 23 8C 12 A1 00 00 00 09 01 31 00 05 74 898#........1..t |
68 6F 72 64 00 07 46 72 69 65 6E 64 73 7F ED 00 hord..Friends... |
00 00 01 00 00 00 0A 43 6F 2D 57 6F 72 6B 65 72 .......Co-Worker |
73 55 7F 00 00 00 01 00 00 00 07 36 32 31 38 38 sU.........62188 |
39 35 23 8C 08 80 00 00 00 0D 01 31 00 09 52 65 95#........1..Re |
67 72 65 73 73 6F 72 00 07 36 32 35 31 37 32 33 gressor..6251723 |
23 8C 05 83 00 00 00 0D 01 31 00 05 47 68 6F 73 #........1..Ghos |
74 00 66 00 00 00 07 36 32 31 33 39 34 39 23 8C t.f....6213949#. |
26 9A 00 00 00 0D 01 31 00 05 6D 69 63 6B 79 00 &......1..micky. |
66 00 00 3B B7 4B 7D |
0x0000 Buddy record (name: uin for ICQ and screenname for AIM) |
0x0001 Group record |
0x0002 Permit record ("Allow" list in AIM, and "Visible" list in ICQ) |
0x0003 Deny record ("Block" list in AIM, and "Invisible" list in ICQ) |
0x0004 Permit/deny settings or/and bitmask of the AIM classes |
0x0005 Presence info (if others can see your idle status, etc) |
0x0009 Unknown. ICQ2k shortcut bar items ? |
0x000E Ignore list record. |
0x000F Last update date (name: "LastUpdateDate"). |
0x0010 Non-ICQ contact (to send SMS). Name: 1#EXT, 2#EXT, etc |
0x0013 Item that contain roster import time (name: "Import time") |
0x0014 Own icon (avatar) info. Name is an avatar id number as text |
[TLV(0x0131), itype 0x00, size XX] - This stores the name that the contact should show up as in the contact list. It should initially be set to the contact's nick name, and can be changed to anything by the client. |
/programs/network_old/icq/trunk/STDCALL.INC |
---|
0,0 → 1,151 |
..Open = 0 |
; When some procedure is not finished with 'endp' macro, |
; "Unexpected end of file" error, occur without any info, where is error. |
; in this case, comment followind 2 rows and uncomment next two. |
; proc_used and endp_used are optimized versions of the macroses. |
; proc_debug and endp_debug are debug versions. When you use debug |
; versions, error message will show you where is missing 'endp'. |
; |
; Don't forget to recompile with *_used versions, to get optimised |
; binary with all not used procedure excluded. |
macro RestoreEx [name] |
{ |
macro rstr#name _% RESTORE name %_ |
macro rstr _% %_ |
rstr#name |
purge rstr,rstr#name |
} |
_% fix { |
%_ fix } |
restore fix RestoreEx |
proc fix proc_used |
endp fix endp_used |
;proc fix proc_debug |
;endp fix endp_debug |
macro proc_used name,[arg] { ; define procedure |
common |
proc_args fix arg |
; if ~ used name |
; if ~..ShowSkipped eq OFF |
; display 1,'Procedure skiped: ',`name, $0d, $0a |
; end if |
; else |
if used name |
name: |
virtual at ebp+8 |
if ~ arg eq |
forward |
local ..arg |
..arg dd ? |
arg equ ..arg |
common |
end if |
..ret = $ - (ebp+8) |
end virtual |
local ..dynamic_data,..dynamic_size |
dynamic_data equ ..dynamic_data |
dynamic_size equ ..dynamic_size |
virtual at ebp - dynamic_size |
dynamic_data: |
} |
macro proc_debug name,[arg] { ; define procedure |
common |
proc_args fix arg |
if ..Open > 0 |
Error! Missing 'endp' before procedure `name |
end if |
..Open = ..Open+1 |
name: |
virtual at ebp+8 |
if ~ arg eq |
forward |
local ..arg |
..arg dd ? |
arg equ ..arg |
common |
end if |
..ret = $ - (ebp+8) |
end virtual |
local ..dynamic_data,..dynamic_size |
dynamic_data equ ..dynamic_data |
dynamic_size equ ..dynamic_size |
virtual at ebp - dynamic_size |
dynamic_data: |
} |
macro begin { ; begin procedure instructions |
; continue from "proc" macro. |
; align 4 |
rb (4 - ($ - dynamic_data) and 11b) and 11b ; align the stack at dword. |
dynamic_size = $ - dynamic_data |
end virtual |
if (dynamic_size = 0) |
if ..ret <> 0 |
push ebp ; smaller is dynamic_size = 0 |
mov ebp, esp |
end if |
else |
enter dynamic_size, 0 |
end if |
} |
macro return { ; return from procedure |
; continue from "enter" macro. |
if ..ret <> 0 |
leave |
ret ..ret |
else |
if dynamic_size <> 0 |
leave |
end if |
ret |
end if |
} |
macro endp_used { |
restore proc_args |
end if |
} |
macro endp_debug { |
restore proc_args |
..Open = ..Open - 1 |
} |
macro _reversepusharg [arg] { |
reverse |
pushd arg |
} |
macro stdcall proc,[arg] { ; call procedure |
common |
if ~ arg eq |
_reversepusharg arg |
end if |
call proc |
} |
macro invoke proc,[arg] { ; invoke procedure (indirect) |
common |
stdcall [proc],arg |
} |
;end of file |
/programs/network_old/icq/trunk/build_ru.bat |
---|
0,0 → 1,2 |
@fasm ki.asm ki |
/programs/network_old/icq/trunk/comp.inc |
---|
0,0 → 1,972 |
; |
; à¨á®¢ âì ¯àאַ㣮«ì¨ª |
; x1,y1 ---------| |
; | | |
; | | |
; |-------------x2,y2 |
; |
macro rect x1, y1, x2, y2, color |
{ |
pushad |
;mov edx, color |
; ------------ |
;mov eax, 38 |
mov ebx, x1 |
shl ebx, 16 |
add ebx, x2 |
mov ecx, y1 |
shl ecx, 16 |
add ecx, y1 |
;int 40h |
mcall 38, ebx, ecx, color |
; ------------ |
;mov eax, 38 |
mov ebx, x1 |
shl ebx, 16 |
add ebx, x2 |
mov ecx, y2 |
shl ecx, 16 |
add ecx, y2 |
;int 40h |
mcall 38, ebx, ecx, color |
; | |
; | |
; | |
;mov eax, 38 |
mov ebx, x1 |
shl ebx, 16 |
add ebx, x1 |
mov ecx, y1 |
shl ecx, 16 |
add ecx, y2 |
;int 40h |
mcall 38, ebx, ecx, color |
; | |
; | |
; | |
;mov eax, 38 |
mov ebx, x2 |
shl ebx, 16 |
add ebx, x2 |
mov ecx, y1 |
shl ecx, 16 |
add ecx, y2 |
;int 40h |
mcall 38, ebx, ecx, color |
popad |
} |
; |
; 뢮¤ íªà ¡ãä¥à á® áâப ¬¨ |
; |
scbuff db 80*41 dup 0 |
; 60 - ¤«¨ áâப¨ |
; 41 - ª®«¨ç¥á⢮ áâப |
; |
ind db 0 ; ¥ªã騩 ¨¤¥ªá |
; |
; |
x_s dw 15 ; ®®à¤¨ âë «¥¢®£® ¢¥à奣® 㣫 FIXIT |
y_s dw 38 ; |
; ëá®â áâப¨ |
SH = 10 |
xlen dw 80 ; ¤«¨ áâப¨ |
;ylen dw 128 ; ª®«¨ç¥á⢮ áâப |
ylen dw 40 |
;®á«¥¤¨¥ 4 ¡ ©â ¢ áâப¥ ®¡®§ ç îâ 梥â |
printbuff: |
pushad |
; |
; à¨á㥬 ¡¥«ë© ¯àאַ㣮«ì¨ª |
; |
;mov eax, 13 |
;mov ebx, 15*65536+480 |
;mov ecx, 31*65536+418 |
;mov edx, 0FFFFFFh |
;int 40h |
mcall 13, (15 * 65536 + 480), (31 * 65536 + 418), 0x00FFFFFF |
xor ecx, ecx ; ç¥â稪 |
;xor eax, eax |
xor ebx, ebx |
;xor edx, edx |
pb_loop: |
xor edx, edx |
xor eax, eax |
mov dl, [ind] ; ¤¥ªá |
mov ax, [ylen] |
;mul edx |
cmp ecx, eax |
ja pr_end |
; |
; |
add edx, ecx ;ਡ ¢¨¬ áç¥â稪 |
xor eax, eax |
mov ax, [ylen] |
cmp edx, eax ;¤¥ªá ¬¥ìè¥ ª®«¨ç¥á⢠áâப |
jna @f ;<= |
sub edx, eax ; ᫨ ¡®«ìè¥, áç¨â ¥¬ á ç « |
dec edx |
@@: |
; |
mov bx, [x_s] ; ®®à¤¨ â X |
shl ebx, 16 ; |
push ecx |
mov eax, SH ; ëç¨á«ï¥¬ ¬¥á⮯®«®¦¥¨¥ áâப¨ |
imul eax, ecx ; |
;mov ecx, eax |
;xor eax, eax |
;mov ax , [x_s] |
xor ecx, ecx |
mov cx, [y_s] |
add ecx, eax |
add ebx, ecx ; ®®à¤¨ â Y |
; |
xor eax, eax |
mov ax, [xlen] ;¤«¨ áâப¨ |
imul edx, eax ;¬®¦ ¥¬ áç¥â稪 ¤«¨ã áâப¨, ¯®«ãç ¥¬ ᬥ饨¥ ®â®á¨â¥«ì® ç « ¡ãä¥à |
;mov edx, eax |
add edx, scbuff |
xor eax, eax |
mov ax, [xlen] |
sub eax, 4 |
xor ecx, ecx |
mov ecx, dword [edx+eax] ; ®á«¥¤¨¥ 4 ©â á 梥⮬ |
or ecx, 0x80000000 ; 뢮¤¨âì ASCIIZ |
;mov eax, 4 |
;mov esi, -1 ; For Menuet |
;int 40h |
mcall 4, ebx, ecx, edx |
pop ecx |
inc ecx |
jmp pb_loop |
pr_end: |
popad |
ret |
; |
; â« ¤®çë¥ á®®¡é¥¨ï |
; |
macro write_debug str |
{ |
local ..string, ..label, ..end, ..loop, ..fin, ..n_inc |
jmp ..label |
..string db str, 0 |
..label: |
pushad |
xor eax, eax |
xor ebx, ebx |
xor ecx, ecx |
xor edx, edx |
mov bl, [ind] |
mov ax, [xlen] |
imul ebx, eax |
add ebx, scbuff |
; |
; ¥àë© æ¢¥â ¢ë¢®¤ |
; |
mov edx, ebx |
lea edx, [edx+eax] |
sub edx, 4 ;4 ¡ ©â á 梥⮬ |
mov dword [edx], dword 0 |
xor edx, edx |
..loop: |
mov dl, [..string+ecx] |
cmp dl, 0 |
jz ..end |
mov [ebx+ecx], dl |
inc ecx |
jmp ..loop |
..end: |
mov [ebx+ecx], dl |
xor ebx, ebx |
mov bl, [ind] |
cmp bx, [ylen] |
jz ..n_inc |
inc bl |
jmp ..fin |
..n_inc: |
xor bl, bl |
..fin: |
mov [ind], bl |
call printbuff |
;call draw_window |
popad |
} |
; |
; ®¯ª |
; |
macro draw_button x, y, xlen, ylen, id, str |
{ |
pushad |
local ..string, ..label |
jmp ..label |
..string db str, 0 |
..label: |
mcall 8, (x*65536+xlen), (y*65536+ylen), id, 0x4466aa |
mcall 4, ((x+5)*65536+y+ylen/2-3), 0x80FFFFFF, ..string |
popad |
} |
; |
; â« ¤®çë© ¢ë¢®¤ ¤ ëå |
; |
macro data_debug str, rg |
{ |
pushad |
local ..string, ..end, ..loop, ..strend, ..fin, ..label, ..n_inc |
jmp ..label |
..string db str, 20h, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
..strend: |
..label: |
;xor eax, eax |
;xor ebx, ebx |
xor ecx, ecx |
xor edx, edx |
mov eax, rg |
lea ebx, [..strend-9] |
call int2str |
xor eax, eax |
xor ebx, ebx |
mov bl, [ind] |
mov ax, [xlen] |
imul ebx, eax |
add ebx, scbuff |
; |
; ¥àë© æ¢¥â ¢ë¢®¤ |
; |
mov edx, ebx |
lea edx, [edx+eax] |
sub edx, 4 ;4 ¡ ©â á 梥⮬ |
mov dword [edx], dword 0 |
xor edx, edx |
..loop: |
mov dl, [..string+ecx] |
cmp dl, 0 |
jz ..end |
mov [ebx+ecx], dl |
inc ecx |
jmp ..loop |
..end: |
mov [ebx+ecx], dl |
xor ebx, ebx |
mov bl, [ind] |
cmp bx, [ylen] |
jz ..n_inc |
inc bl |
jmp ..fin |
..n_inc: |
xor bl, bl |
..fin: |
mov [ind], bl |
call printbuff |
;call draw_window |
popad |
} |
; <--EAX |
; -->[ebx] |
; |
int2str: |
pushf |
;push ebx |
push ecx |
push edx |
push esi |
;xor ebx, ebx |
xor ecx, ecx |
i_loop: |
mov edx, eax |
push ecx |
shl ecx, 2 |
mov esi, 28 |
sub esi, ecx |
mov ecx, esi |
shr edx, cl |
pop ecx |
and dl, 0fh ;⤥«¨âì ¬« ¤è¨¥ 4 ¡¨â |
cmp dl, 0Ah ;㪢 |
jnc @f |
or dl, 0x30 |
jmp i_n1 |
@@: |
sub dl, 9 |
or dl, 0x40 |
i_n1: |
mov [ebx+ecx], dl |
inc ecx |
cmp ecx, 8 |
jnz i_loop |
pop esi |
pop edx |
pop ecx |
;pop ebx |
popf |
ret |
; |
; «ï ¢ë¢®¤ á®®¡é¥¨© |
; [eax] <-- null-terminated string |
; ebx <-- color |
; |
writemsg: |
pushad |
xor edi, edi |
wm_loop: |
xor esi, esi ; ᫨ 1 - ¥áâì ¥é¥ á¨¬¢®«ë ¢ áâப¥ |
lea eax, [eax+edi] |
push ebx |
push eax |
xor eax, eax |
xor ebx, ebx |
mov bl, [ind] |
mov ax, [xlen] |
imul ebx, eax |
add ebx, scbuff |
; |
; §¡¨¢ ¥¬ áâபã á®®¡é¥¨ï ¥áª®«ìª® áâப ¯® xlen-4 (â.ª ¢ ª®æ¥ ¤¢®©®¥ á«®¢® - 梥â áâப¨) |
; |
pop eax |
mov edx, eax |
call strlen |
movzx ecx, [xlen] |
cmp eax, ecx |
jc @f ;< |
movzx edi, [xlen] |
lea edi, [edi-4] |
mov ecx, eax |
inc esi |
@@: |
mov eax, edx |
call strcpy |
mov [ebx+ecx], byte 0x00 |
xor eax, eax |
mov ax, [xlen] |
sub eax, 4 |
pop ecx |
mov dword [ebx+eax], ecx ; ®á«¥¤¨¥ 4 ©â á 梥⮬ |
xor eax, eax |
mov al, [ind] |
cmp ax, [ylen] |
jz @f |
inc al |
jmp ..fin |
@@: |
xor al, al |
..fin: |
mov [ind], al |
mov ebx, ecx ; 梥â |
mov eax, edx ; 㪠§ ⥫ì áâபã |
cmp esi, 0 |
jnz wm_loop |
call printbuff |
popad |
ret |
; |
; |
; <--EAX ¥à¥¢®¤ ¨§ 16 ¢ 10 ä®à¬ã |
; -->[ebx] áâப |
; --> eax ¤«¨ |
int2strd: |
pushf |
;push ebx |
push ecx |
push edx |
push esi |
;push edi |
;xor ebx, ebx |
xor ecx, ecx |
mov esi, 10 |
id_loop: |
xor edx, edx |
div esi |
and dl, 0fh ;⤥«¨âì ¬« ¤è¨¥ 4 ¡¨â |
or dl, 0x30 |
mov [ebx+ecx], dl |
cmp eax, 10 |
inc ecx |
jnc id_loop |
and al, 0fh ;⤥«¨âì ¬« ¤è¨¥ 4 ¡¨â |
or al, 0x30 |
mov [ebx+ecx], al |
;mov [ebx+ecx+1], byte 0 |
inc ecx |
mov eax, ecx |
; ¯¥à¥¢¥àãâì ¯®«ãç¥ãî áâபã |
; |
;xor edx, edx |
;mov esi, 2 |
;div esi |
shr eax, 1 |
xor edx, edx |
id_loop2: |
cmp eax, 0 |
jz id_end |
mov dl, [ebx+eax-1] |
lea esi, [ebx+ecx] |
sub esi, eax |
mov dh, [esi] |
mov [ebx+eax-1], dh |
mov [esi], dl |
dec eax |
jmp id_loop2 |
id_end: |
mov eax, ecx |
;pop edi |
pop esi |
pop edx |
pop ecx |
;pop ebx |
popf |
ret |
; |
; |
; |
x_bb dw 550 ; ®®à¤¨ âë «¥¢®£® ¢¥à奣® 㣫 |
y_bb dw 30 ; |
; |
bb_width dw 100 ; ¨à¨ ª®¯®ª |
bb_height dw 12 ; ¢ëá®â ª®¯®ª |
; |
bb_dist dw 6 ; ááâ®ï¨¥ ¬¥¦¤ã ª®¯ª ¬¨ |
; ¤¥â¨ä¨ª â®àë ª®¯®ª ç¨ ï á 100 |
; |
; «ï |
; |
; |
buttonbox: |
pushad |
pushf |
xor ecx, ecx |
xor eax, eax |
xor ebx, ebx |
bb_loop: |
; ஢¥à塞 ¯¥à¢ë© ¡ ©â 㨠, ¥á«¨ 0, ª®¯ªã à¨á®¢ âì ¥ ¤® |
;mov ebx, NAME_LEN |
;imul ebx, ecx |
;mov al, [names+ebx] |
;cmp al, 0 |
;jz bb_end |
mov ebx, UIN_LEN |
imul ebx, ecx |
mov al, [uins + ebx] |
cmp al, 0 |
jz bb_end |
; à¨á㥬 ª®¯ªã |
; ¢¥â § ¢¨á¨â ®â áâ âãá UIN |
mov ebx, 4 |
imul ebx, ecx |
mov eax, [stats+ebx] ; áâ à襬 á«®¢¥ ¤®¯®«¨â¥«ìë© áâ âãá |
cmp ax, -1 |
jz bb_offline |
cmp ax, 1 |
jz bb_away |
cmp ax, 2 |
jz bb_dnd |
cmp ax, 4 |
jz bb_na |
cmp ax, 10h |
jz bb_bisy |
cmp ax, 20h |
jz bb_free4chat |
cmp ax, 100h |
jz bb_invis |
; Online |
mov esi, 0x4466AA |
jmp bb_dr |
bb_offline: |
mov esi, 0xBEBEBE |
jmp bb_dr |
bb_away: |
mov esi, 0x14dcc3 |
jmp bb_dr |
bb_dnd: |
mov esi, 0x14dcc3 |
jmp bb_dr |
bb_na: |
mov esi, 0x14dcc3 |
jmp bb_dr |
bb_bisy: |
mov esi, 0x14dcc3 |
jmp bb_dr |
bb_free4chat: |
mov esi, 0x2233FF |
jmp bb_dr |
bb_invis: |
mov esi, 0xD0D0D0 |
bb_dr: |
mov bx, [x_bb] |
shl ebx, 16 |
mov bx, [bb_width] |
;push ecx |
mov edx, ecx |
lea edx, [edx+100] ; ID |
mov edi, ecx |
mov cx, [y_bb] |
movzx eax, [bb_height] |
add ax, [bb_dist] |
imul eax, edi |
add ecx, eax |
shl ecx, 16 |
mov cx, [bb_height] |
mov eax, 8 |
int 40h |
; |
; ¤¯¨áì ª®¯ª¥ |
; |
add ebx, 50000h ; ¬¥é¥¨¥ ®â «¥¢®£® ªà ï |
shr ecx, 16 |
movzx eax, [bb_height] |
shr eax, 1 ; /2 |
sub eax, 3 ; ᬥ饨¥ ¢¢¥àå ®â æ¥âà |
add ecx, eax ; + ¯®«®¢¨ à §¬¥à ª®¯ª¨ |
mov bx, cx |
mov ecx, 0x80FFFFFF ; ¢¥â |
mov edx, names |
mov esi, NAME_LEN |
imul esi, edi |
add edx, esi |
;mov esi, -1 |
mov eax, 4 |
int 40h |
mov ecx, edi |
inc ecx |
cmp ecx, UINS |
ja bb_end |
jmp bb_loop |
bb_end: |
popf |
popad |
ret |
; |
; áᨢ á UIN |
; |
UIN_LEN = 11 ; Ǭ |
UINS = 22 ; ®«¨ç¥á⢮ |
; |
uins db UIN_LEN*UINS dup 0 |
; |
; ¬ áᨢ á® áâ âãá ¬¨ |
; |
stats dd UINS dup -1 |
; |
; áᨢ á ¨¬¥ ¬¨ |
; |
NAME_LEN = 30 |
names db NAME_LEN*UINS dup 0 |
; |
; |
U1 db '405577261',0 |
U2 db '455395049',0 |
U3 db '488118046',0 |
; |
; £à㧪 ¬ áᨢ UIN |
; |
; FIXME ¡ã¤¥â 㤠«¥ |
loaduin: |
pushad |
mov eax, U1 |
mov ebx, uins |
mov ecx, 9 |
call strcpy |
mov ebx, names |
call strcpy |
mov eax, U2 |
mov ebx, uins+UIN_LEN |
mov ecx, 9 |
call strcpy |
mov ebx, names+NAME_LEN |
call strcpy |
mov eax, U3 |
mov ebx, uins+UIN_LEN*2 |
mov ecx, 9 |
call strcpy |
mov ebx, names+NAME_LEN*2 |
call strcpy |
popad |
ret |
; |
; ãªæ¨ï ¤«ï § £à㧪¨ ¨ª ¬¨ ¨ áâ âãá ¬¨ |
; eax <-- ®¬¥à 㨠¯® ¯®à浪㠢 ¬ áᨢ¥ uins, ç¨ ï á 0 |
; [ebx] <-- 㪠§ ⥫ì null-terminated áâபã á ®¢ë¬ ¨¬¥¥¬ |
; ecx <-- ®¢ë© áâ âãá |
; |
loadbb: |
pushad |
pushf |
; |
; ஢¥à塞 ®¬¥à |
; |
cmp eax, UINS |
jnc loadbb_end ;>= |
; |
; ¤ «ï¥¬ ª®¯ªã |
; |
push ecx |
push ebx |
push eax |
lea edx, [eax+100] |
or edx, 0x80000000 |
mov eax, 8 |
int 40h |
; |
; ®åà 塞 ®¢ë© áâ âãá ¢ ¬ áᨢ¥ áâ âãᮢ |
; |
pop eax |
mov edx, 4 ; DWORD |
imul edx, eax |
mov [stats+edx], ecx |
; |
; ®åà 塞 ®¢®¥ ¨¬ï |
; |
mov edi, eax ; edi <-- Uin number |
pop eax ; <-- offset of string |
mov ebx, eax |
call strlen |
mov ecx, eax ; Len |
mov eax, ebx ;Source |
mov edx, NAME_LEN |
imul edx, edi |
lea ebx, [names+edx] ; Dest |
call strcpy |
mov [names+edx+ecx], byte 0 |
xchg edi, eax ; eax - áç¥â¨ª, edi - 㪠§ ⥫ì áâபã |
pop ecx |
push edi |
; à¨á㥬 ª®¯ªã |
; ¢¥â § ¢¨á¨â ®â áâ âãá UIN |
cmp cx, -1 |
jz l_offline |
cmp cx, 1 |
jz l_away |
cmp cx, 2 |
jz l_dnd |
cmp cx, 4 |
jz l_na |
cmp cx, 10h |
jz l_bisy |
cmp cx, 20h |
jz l_free4chat |
cmp cx, 100h |
jz l_invis |
; Online |
mov esi, 0x4466AA |
jmp l_dr |
l_offline: |
mov esi, 0xBEBEBE |
jmp l_dr |
l_away: |
mov esi, 0x14dcc3 |
jmp l_dr |
l_dnd: |
mov esi, 0x14dcc3 |
jmp l_dr |
l_na: |
mov esi, 0x14dcc3 |
jmp l_dr |
l_bisy: |
mov esi, 0x14dcc3 |
jmp l_dr |
l_free4chat: |
mov esi, 0x2233FF |
jmp l_dr |
l_invis: |
mov esi, 0xD0D0D0 |
l_dr: |
mov bx, [x_bb] |
shl ebx, 16 |
mov bx, [bb_width] |
;push ecx |
mov edx, eax |
lea edx, [edx+100] ; ID |
mov edi, eax |
mov cx, [y_bb] |
movzx eax, [bb_height] |
add ax, [bb_dist] |
imul eax, edi |
add ecx, eax |
shl ecx, 16 |
mov cx, [bb_height] |
mov eax, 8 |
int 40h |
; |
; ¤¯¨áì ª®¯ª¥ |
; |
add ebx, 50000h ; ¬¥é¥¨¥ ®â «¥¢®£® ªà ï |
shr ecx, 16 |
movzx eax, [bb_height] |
shr eax, 1 ; /2 |
sub eax, 3 ; ᬥ饨¥ ¢¢¥àå ®â æ¥âà |
add ecx, eax ; + ¯®«®¢¨ à §¬¥à ª®¯ª¨ |
mov bx, cx |
mov ecx, 0x80FFFFFF ; ¢¥â |
pop edx |
mov esi, -1 |
mov eax, 4 |
int 40h |
loadbb_end: |
popf |
popad |
ret |
; |
; |
; â« ¤®ç ï äãªæ¨ï - ¢ë¢®¤¨â ®¡« áâì ¯ ¬ï⨠|
; EAX - 㪠§ â¥«ì ®¡« áâì |
; EBX - ª®«¨ç¥á⢮ ¡ ©â |
; |
print_mem: |
push eax |
push ebx |
push ecx |
push edx |
push esi |
xor ecx, ecx |
xor esi, esi |
pm_loop: |
cmp ecx, ebx |
jz pm_exit |
mov dl, [eax + ecx] |
shr dl, 4 ;¤¢¨ãâì 4 à §àï¤ ¢¯à ¢® |
cmp dl, 0x0A |
jnb pm_chars |
or dl, 0x30 |
jmp pm_write |
pm_chars: |
add dl, 0x37 |
pm_write: |
mov [membuff + esi], dl |
inc esi |
; |
; |
mov dl, [eax + ecx] |
and dl, 0x0F |
cmp dl, 0x0A |
jnb pm_chars2 |
or dl, 0x30 |
jmp pm_write2 |
pm_chars2: |
add dl, 0x37 |
pm_write2: |
mov [membuff + esi], dl |
inc esi |
mov [membuff + esi], 0x20 |
inc esi |
cmp esi, MEMBUFF_SIZE - 2 |
jb pm_nwrite |
; |
; ¢ë¢¥á⨠¡ãä¥à |
mov [membuff + esi], byte 0 |
push eax |
push ebx |
mov eax, membuff |
xor ebx, ebx |
xor esi, esi |
call writemsg |
pop ebx |
pop eax |
pm_nwrite: |
inc ecx |
jmp pm_loop |
pm_exit: |
mov [membuff + esi], byte 0 |
mov eax, membuff |
xor ebx, ebx |
xor esi, esi |
call writemsg |
pop esi |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
/programs/network_old/icq/trunk/comp_data.inc |
---|
0,0 → 1,3 |
MEMBUFF_SIZE = (16 * 3 + 1) |
membuff db MEMBUFF_SIZE dup 0 |
/programs/network_old/icq/trunk/config.inc |
---|
0,0 → 1,0 |
__CPU_type fix p5 |
/programs/network_old/icq/trunk/dialogs1.inc |
---|
0,0 → 1,597 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; DIALOGS1.INC ; |
; ; |
; COMPILE WITH FASM for MENUET ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
menus dd 3 ; number of menus |
m_x dd 0x5 ; x start |
m_y dd 20 ; y start |
m_xs dd 290 ; x size |
m_ys dd 14 ; y size |
g_stack dd 0xf000 ; thread stack - required |
menu:; AB C D E F G |
db '*D FILE +Save File +Load File +- +Quit ' |
db '*B EDIT +Copy +Paste ' |
db '*B HELP +Setup +About.. ' |
db '@' ; end mark |
; A : Data type '*' -> New menu , '+' -> menu selection |
; B : Number of selections in menu (A+) |
; C : Menu header text |
; D-G : Menu selection text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; DATA BELOW IS FOR DIALOGS1.INC INTERNALS |
menu_action dd '----' |
window_on db 0 |
g_n dd -1 |
g_x dd 0x0 |
g_t dd 0x0 |
g_1 dd 0x0 |
g_l dd 0x0 |
closet db 0 |
table: times 1024 db 0 |
last_mouse dd 0x0 |
mo_x dd 0x0 |
mo_y dd 0x0 |
check_mouse: |
pusha |
cmp [window_on],1 |
je no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp [window_on],0 |
jne openw2 |
cmp eax,0 |
je no_open |
openw2: |
waitformouse: |
mov eax,23 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne waitformouse |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov esi,eax |
shr eax,16 |
xor edx,edx |
mov ebx,50 |
div ebx |
mov edx,eax |
cmp edx,[g_n] |
je no_open |
cmp edx,[menus] |
jge no_open |
mov eax,esi |
and eax,0xffff |
mov ebx,[m_y] |
cmp eax,ebx |
jbe no_open |
add ebx,[m_ys] |
cmp eax,ebx |
jge no_open |
cmp [window_on],0 |
je noww |
mov [closet],1 |
mov ecx,100 |
waitm: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
dec ecx |
jz no_open |
cmp [window_on],0 |
jne waitm |
noww: |
mov eax,edx |
jmp cll |
no_open: |
mov [last_mouse],esi |
popa |
ret |
cll: |
mov [window_on],2 |
mov [g_n],eax |
mov [g_x],96 |
mov [g_t],0 |
mov [g_1],1 |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
mov eax,[table+34] |
mov [mo_x],eax |
mov eax,[table+38] |
mov [mo_y],eax |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [esp+28],dword 0 ; clear button entry |
mov [menu_action],'MD ' |
check_gr: |
popa |
ret |
draw_menu: |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp [table+46],dword 30 |
jb drmr |
mov eax,13 ; white background |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_xs] |
inc ebx |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_ys] |
mov edx,0xf0f8ff |
int 0x40 |
mov eax,38 ; egde lines |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_x] |
add ebx,[m_xs] |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_y] |
mov edx,0x000000 |
int 0x40 |
mov eax,38 |
mov ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
add ecx,[m_y] |
add ecx,[m_ys] |
int 0x40 |
mov esi,menu-1 |
mov edi,[m_x] |
mov ebp,1 |
new_menu: |
inc esi |
cmp [esi],byte '*' |
jne drmnl1 |
push esi |
mov eax,4 |
mov ebx,edi |
shl ebx,16 |
add ebx,[m_y] |
add ebx,0x00050004 |
mov ecx,0x000000 |
mov edx,esi |
add edx,3 |
mov esi,12 |
int 0x40 ; draw text |
pop esi |
add esi,2 |
add edi,50 |
inc ebp |
drmnl1: |
cmp [esi],byte '@' |
jne new_menu |
drmr: |
ret |
alert_box: |
; eax : x size - min 200 |
; ebx : pointer to ASCIIZ - max 128 character text |
; ecx : button 1 id ( OK or YES ) |
; edx : button 2 id or zero ( NO ) |
cmp [window_on],0 |
jne alert_box_return |
mov [window_on],1 |
cmp eax,100 |
jg size_ok |
mov eax,100 |
size_ok: |
mov [g_x],eax |
mov [g_t],ebx |
mov [g_1],ecx |
mov ecx,0 |
new_search: |
cmp [ebx],byte 0 |
je found_len |
inc ebx |
inc ecx |
cmp ecx,128 |
jbe new_search |
found_len: |
mov [g_l],ecx |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [menu_action],'MA ' |
alert_box_return: |
ret |
alert_entry: |
call alert_draw_window |
alert_still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
int 0x40 |
cmp eax,1 ; redraw request ? |
je alert_red |
cmp eax,2 ; key in buffer ? |
je alert_key |
cmp eax,3 ; button in buffer ? |
je alert_button |
cmp [closet],0 |
jne ccc |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp ax,[table+4] |
je no_close |
ccc: |
mov [closet],0 |
mov [g_n],-1 |
mov [menu_action],'----' |
mov [window_on],0 |
mov eax,-1 |
int 0x40 |
no_close: |
jmp alert_still |
alert_red: ; redraw |
call alert_draw_window |
jmp alert_still |
alert_key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp alert_still |
alert_button: ; button |
mov eax,17 ; get id |
int 0x40 |
shr eax,8 |
cmp eax,3 |
jg no_action1 |
dec eax |
shl eax,2 |
mov eax,dword [eax+rtext] |
mov [menu_action],eax |
jmp action_done |
no_action1: |
sub eax,16 |
add eax,65 |
shl eax,8 |
mov ebx,[g_n] |
add ebx,65 |
add eax,ebx |
mov [menu_action],eax |
action_done: |
mov [closet],0 |
mov [g_n],-1 |
mov [window_on],0 |
mov eax,-1 ; close this program |
int 0x40 |
rtext db 'NO YES OK ' |
jmp alert_still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
alert_draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
cmp [window_on],2 |
jne no_win_type_2 |
mov edx,menu-1 |
mov ecx,[g_n] |
add ecx,1 |
find_menu: |
inc edx |
cmp [edx],byte '*' |
je menu_loop |
jmp find_menu |
menu_loop: |
loop find_menu |
movzx ebp,byte [edx+1] |
sub ebp,64 |
push edx |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,[g_n] |
imul ebx,50 |
add ebx,[mo_x] |
add ebx,[m_x] |
shl ebx,16 |
add ebx,[g_x] |
mov ecx,[mo_y] |
add ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
mov edx,14 |
imul edx,ebp |
add edx,7 |
add ecx,edx |
mov edx,0x00ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x00ffffff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x000000cc ; color of frames RRGGBB |
int 0x40 |
pop edx |
mov ebx,5*65536+7 ; draw info text with function 4 |
mov ecx,0x10000000 |
mov esi,12 |
mov ebp,16 |
no_d_found: |
inc edx |
cmp [edx],byte '*' |
je d_drawed |
cmp [edx],byte '@' |
je d_drawed |
cmp [edx],byte '+' |
jne no_d_found |
inc edx |
pusha ; draw button |
mov eax,8 |
mov ecx,ebx |
mov ebx,[g_x] |
add ebx,0x0000fffe |
shl ecx,16 |
add ecx,0xfffc0000+14 |
mov edx,0x40000000 |
add edx,ebp |
mov esi,0 |
int 0x40 |
popa |
mov eax,4 ; draw text |
int 0x40 |
inc ebp |
add ebx,14 |
jmp no_d_found |
d_drawed: |
no_win_type_2: |
cmp [window_on],1 |
jne no_win_1 |
mov eax,14 ; to middle of screen |
int 0x40 |
mov ecx,eax |
and ecx,0xffff |
shr ecx,1 |
shr eax,1 |
mov ebx,[g_x] |
shr ebx,1 |
shl ebx,16 |
sub eax,ebx |
mov ebx,eax |
mov eax,0 ; function 0 : define and draw window |
mov bx,word [g_x] |
sub ecx,80 |
shl ecx,16 |
mov cx,110 ; [y start] *65536 + [y size] |
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x80d05050 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00d05050 ; color of frames RRGGBB |
int 0x40 |
mov eax,4 ; label |
mov ebx,8*65536+8 |
mov ecx,0x10ddeeff |
mov edx,alert_labelt1 |
mov esi,alert_label1len-alert_labelt1 |
int 0x40 |
mov eax,4 |
mov ebx,10*65536+43 |
mov ecx,0x10000000 |
mov edx,[g_t] |
mov esi,[g_l] |
int 0x40 |
cmp [g_1],1 |
jne gadgets_no_1 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,30*65536+40 |
mov ecx,75*65536+16 |
mov edx,3 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,31*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t2 |
mov esi,alert_t2len-alert_t2 |
int 0x40 |
gadgets_no_1: |
cmp [g_1],2 |
jne gadgets_no_2 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,0*65536+40 |
mov ecx,75*65536+16 |
mov edx,1 |
mov esi,0x446688 |
int 0x40 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,57*65536+40 |
mov ecx,75*65536+16 |
mov edx,2 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,1*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t1 |
mov esi,alert_t1len-alert_t1 |
int 0x40 |
gadgets_no_2: |
no_win_1: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
alert_t1: |
db ' No Yes' |
alert_t1len: |
alert_t2: |
db ' OK' |
alert_t2len: |
alert_labelt1: |
db 'ALERT' |
alert_label1len: |
/programs/network_old/icq/trunk/dos2win.inc |
---|
0,0 → 1,121 |
; |
; |
CP866 db ' ¡¢£¤¥¦§¨©ª«¬®¯àáâãäåæçèéêëìíîï' |
; |
; ¥à¥ª®¤¨à®¢ª ¨§ cp1251 ¢ cp866 |
; |
; [eax] <-- Null-terminated string |
; |
win2dos: |
pushad |
pushf |
xor ebx, ebx |
xor ecx, ecx |
;xor edx, edx |
w2d_loop: |
mov bl, [eax+ecx] |
cmp bl, 0 |
jz w2d_end |
cmp bl, 0A8h ; ð |
jz w2d_yo1 |
cmp bl, 0B8h ; ñ |
jz w2d_yo2 |
cmp bl, 0C0h ; ãááª ï ¡ãª¢ |
jnc w2d_rchar |
inc ecx |
jmp w2d_loop |
w2d_yo1: |
mov [eax+ecx], byte 0F0h |
inc ecx |
jmp w2d_loop |
w2d_yo2: |
mov [eax+ecx], byte 0F1h |
inc ecx |
jmp w2d_loop |
w2d_rchar: |
sub bl, 0C0h |
mov bl, [CP866+ebx] |
mov [eax+ecx], bl |
inc ecx |
jmp w2d_loop |
w2d_end: |
popf |
popad |
ret |
CP1251 db 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ' |
; |
; ¥à¥ª®¤¨à®¢ª ¨§ CP866 ¢ CP1251 |
; [eax] <-- Null termainated string |
; |
dos2win: |
pushf |
pushad |
xor ebx, ebx |
xor ecx, ecx |
dec ecx |
d2w_loop: |
inc ecx |
mov bl, [eax+ecx] |
cmp bl, 0 |
jz d2w_end |
cmp bl, 80h |
jnc d2w_rchar |
;inc ecx |
jmp d2w_loop |
d2w_yo1: |
mov byte [eax+ecx], 0A8h |
;inc ecx |
jmp d2w_loop |
d2w_yo2: |
mov byte [eax+ecx], 0B8h |
;inc ecx |
jmp d2w_loop |
d2w_rchar: |
cmp bl, 0B0h |
jnc d2w_rchar2 |
sub bl, 80h |
mov bl, [CP1251+ebx] |
mov [eax+ecx], bl |
jmp d2w_loop |
d2w_rchar2: |
cmp bl, 0E0h |
jc d2w_loop |
cmp bl, 0F0h |
jz d2w_yo1 |
cmp bl, 0F1h |
jz d2w_yo2 |
cmp bl, 0F2h |
jnc d2w_loop |
add bl, 10h |
mov [eax+ecx], bl |
jmp d2w_loop |
d2w_end: |
popad |
popf |
ret |
/programs/network_old/icq/trunk/editbox.mac |
---|
0,0 → 1,1129 |
; ªà®á ¤«ï ¢ë¢®¤ ®á®¢ëå äãªæ¨© ª®â®àë¥ ¨á¯«ì§ãîâáï ¡®ªá®¬ |
macro use_general_func |
{ |
;debug_func |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà ¯à®à¨á®¢ª¨ ¢ë¤¥«¥®© ç á⨠----------------- |
;---------------------------------------------------------- |
.draw_shift: |
test word ed_flags,ed_shift_bac ;ãáâ ®¢ª ä« £ , ¢ë¤¥«¥®© ®¡« á⨠|
jz @f |
mov ebp,shift_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
@@: ret |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà ¯à®à¨á®¢ª¨ ⥪áâ -------------------------- |
;---------------------------------------------------------- |
.draw_text: |
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ --- |
;--- çâ®¡ë ¬ãá®à ¥ à¨á®¢ âì --- |
call .get_n |
mov esi,ed_size |
mov ebx,ed_offset |
sub esi,ebx |
cmp eax,esi |
jae @F |
mov esi,eax ;çâ®¡ë ¥ ¢ë室¨âì § ¯à¥¤¥«ë íªà |
;--- à¨á㥬 ⥪áâ --- |
@@: mov eax,4 |
mov ebx,ed_left |
mov edx,ed_offset |
add ebx,2 |
shl ebx,16 |
add ebx,ed_top |
mov ecx,ed_text_color |
add ebx,4 |
add edx,ed_text |
mcall |
ret |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà ¯à®à¨á®¢ª¨ ä® ---------------------------- |
;¢å®¤ë¥ ¤ ë¥ |
;eax |
;edx - color |
;---------------------------------------------------------- |
;¢å®¤ ⮫쪮 梥â edx |
.draw_bg: |
mov ebx,ed_left |
add ebx,1 |
mov edx,ed_color |
shl ebx,16 |
add ebx,ed_width |
sub ebx,1 |
.draw_bg_eax: |
mov ecx,ed_top |
mov eax,13 |
add ecx,1 |
shl ecx,16 |
add ecx,ed_height |
dec ecx |
mcall |
ret |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà ¯®«ãç¥¨ï ª®«¨ç¥á⢠ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨¥ ª®¬¯®¥â |
;---------------------------------------------------------- |
.get_n: |
mov eax,ed_width ;¯®«ã祬 è¨à¨ã ª®¬¯®¥â |
xor edx,edx ;१ã«ìâ â à ᯮ«®£ ¥âáï ¢ ¯ ॠedx:eax ¢ eax - ®áâ ⮪ |
sub eax,4 ;¢ëç⨬ 4 |
mov ebx,6 ;§ £à㧬¨ ¤¥«¨â¥«ì |
div ebx ;à §¬¤¥«¨¬ 6 |
ret |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà à¨á®¢ ¨ï ªãàá®à -------------------------- |
;---------------------------------------------------------- |
;¢å®¤ë¥ ebp- 梥â |
.clear_cursor: |
mov edx,ebp |
mov ebx,cl_curs_x |
mov ecx,cl_curs_y |
jmp .draw_curs |
.draw_cursor: |
mov edx,ed_text_color |
mov ebx,ed_pos |
mov ecx,ed_offset |
sub ebx,ecx |
lea ebx,[ebx*2+ebx] |
shl ebx,1 |
;imul ebx,6 |
add ebx,ed_left |
mov ecx,ed_top |
inc ebx |
add ecx,2 |
mov ebp,ebx |
shl ebx,16 |
mov bx,bp |
mov ebp,ecx |
shl ecx,16 |
mov cx,bp |
add ecx,ed_height-4 |
mov cl_curs_x,ebx |
mov cl_curs_y,ecx |
.draw_curs: |
mcall 38 |
ret |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà à¨á®¢ ¨ï à ¬ª¨ ---------------------------- |
;---------------------------------------------------------- |
.draw_border: |
;--- 梥â à ¬ª¨ --- |
test word ed_flags,ed_focus |
mov edx,ed_focus_border_color |
jne @f |
mov edx,ed_blur_border_color |
@@: |
;--- ᢥàåã --- |
mov eax,38 |
mov ebx,ed_left |
mov ecx,ebx |
shl ebx,16 |
mov bx,cx |
add ebx,ed_width |
mov ecx,ed_top |
mov esi,ecx |
shl ecx,16 |
mov cx,si |
mcall |
;--- ᨧã --- |
mov esi,ecx |
add ecx,ed_height |
mov ebp,ecx |
shl ecx,16 |
mov cx,bp |
mcall |
;--- á«¥¢ --- |
mov cx,si |
mov ebp,ebx |
sub ebx,ed_width |
mcall |
;--- á¯à ¢ --- |
mov ebx,ebp |
shl ebx,16 |
mov bx,bp |
mcall |
ret |
;---------------------------------------------------------- |
;--- ¯à®¢¥àª , § 襫 «¨ ªãàá®à § £à ¨æë ¨, ¥á«¨ ¤®, --- |
;--- ¨§¬¥ï¥¬ ᬥ饨¥ ------------------------------------ |
;--- ¥á«¨ ᬥ饨¥ ¡ë«® ãáâ ®¢ª ä« £ ed_offset_cl ¨ ç¥ |
; ¥á«¨ ¨ç¥£® ¥ ¨§¬¥¨«®áì â® ¢ëáâ ¢«¥¨¥ ed_offset_fl |
; ¢ ®¡é¥© ¡¨â®¢®© ¬ àà¨æ¥ á®áâ®ï¨ï ª®¬¯®¥â®¢ word ed_flags |
;---------------------------------------------------------- |
.check_offset: |
pusha |
mov ecx,ed_pos |
mov ebx,ed_offset |
cmp ebx,ecx |
ja .sub_8 |
push ebx |
call .get_n ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ ॠॣ¨áâ஢ edx:eax |
pop ebx |
mov edx,ebx |
add edx,eax ;ed_offset+width editbox |
inc edx ;¥®¡å®¤¨¬® ¤«ï ®¬ «ì®£® ¯®«®¦¥¨ï ªãàá®à ¢ ªà ©¥© «¥¢®© ¯®§¨æ¨¨ |
cmp edx,ecx |
ja @f |
mov edx,ed_size |
cmp edx,ecx |
je .add_end |
sub edx,ecx |
cmp edx,8 |
jbe .add_8 |
add ebx,8 |
jmp .chk_d |
.sub_8: cmp ecx,0 |
je .sub_min |
cmp ebx,8 |
jbe .sub_min |
sub ebx,8 ;ebx=ed_offset |
jmp .chk_d |
.sub_min: |
xor ebx,ebx |
jmp .chk_d |
.add_end:sub edx,eax |
mov ebx,edx |
jmp .chk_d |
.add_8: add ebx,edx |
.chk_d: mov ed_offset,ebx |
call .draw_bg |
and word ed_flags,ed_offset_cl |
edit_ex |
@@: |
or word ed_flags,ed_offset_fl |
edit_ex |
} |
macro use_key_func |
{ |
;¡à ¡®âª Shift ¤«ï áïâ¨ï ¢ë¤¥«¥¨ï ¥¨§¢¥á⮩ ®¡« á⨠|
.shift: ;;;;;;;SHIFT |
test word ed_flags,ed_shift |
je .f_exit |
@@: mov ebp,shift_color |
or word ed_flags,ed_shift_bac ;ãáâ ®¢ª ä« £ , ¢ë¤¥«¥®© ®¡« á⨠|
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
jmp .draw_cursor_text |
;;;;;;;;;;;;;;;;;;;;; |
.f_exit:call .check_offset |
and word ed_flags,ed_shift_cl |
call .enable_null |
jmp .draw_cursor_text |
.sh_cl_: |
;;;;;;SHIFT end |
;®¡à ¡®âª ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥¨¨ ¢ë¤¥«¥¨ï |
;¤«ï ®¡à ¡®âª¨ áïâ¨ï ¢ë¤¥«¥¨ï |
;¢å®¤ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos |
mov eax,dword ed_pos |
cmp eax,ebx |
jae .sh_n |
push eax ;¬¥ì襥 ¢ eax |
push ebx ;¡®«ì襥 |
jmp .sh_n1 |
;¥á«¨ ¨ ç¥ |
.sh_n: push ebx |
push eax |
.sh_n1: |
call .check_offset |
call .get_n |
mov edx,eax ;size of ed_box |
mov ecx,ed_offset |
add eax,ecx ;eax = w_off= ed_offset+width |
mov edx,eax ;save |
pop ebx ;¡®«ì襥 |
pop eax ;¬¥ì襥 |
cmp eax,ecx ;áà ¢¥¨¥ á ¬¥ì襣® á offset. |
jae .f_f ;¥á«¨ ¡®«ìè¥ |
xor eax,eax |
cmp edx,ebx ;cà ¢¨¬ à §¬¥à w_off á ¡®«ì訬 |
jb @f |
sub ebx,ecx |
jmp .nxt_f |
@@: mov ebx,edx |
sub ebx,ecx |
jmp .nxt_f |
.f_f: |
sub eax,ecx |
cmp edx,ebx ;cà ¢¨¬ à §¬¥à w_off á ¡®«ì訬 |
jle @f |
sub ebx,ecx |
sub ebx,eax |
jmp .nxt_f |
@@: |
mov ebx,edx |
sub ebx,ecx |
sub ebx,eax |
.nxt_f: |
mov edx,ebx |
lea ebx,[eax*2+eax] |
shl ebx,1 |
add ebx,ed_left |
inc ebx |
shl ebx,16 |
lea ecx,[edx*2+edx] |
shl ecx,1 |
mov bx,cx |
inc ebx |
mov edx,ebp;shift_color |
call .draw_bg_eax |
@@: call .enable_null |
ret |
;;;;;;;;;;;;;;;;;;;;; |
;áâ ®¢ª - áï⨥ ¢ë¤¥«¥¨ï ¢ ®¤¨ ᨬ¢®« |
;;;;;;;;;;;;;;;;;;;;; |
.drw_sim: |
mov eax,dword ed_pos |
call .draw_rectangle ; à¨á®¢ âì ¯àאַ㣮«ì¨ª á § ¤ ë¬ æ¢¥â®¬ |
jmp @b |
;;;;;;;;;;;;;;;;;;;;; |
;ãªæ¨ï ãáâ ®¢ª¨ ¢ë¤¥«¥¨ï ¯à¨ ¤¢¨¦¥¨ï ¢«¥¢® ¨ ¢¯à ¢® ¨ ¦ ⨨ shift |
;®£¨ª : |
;;;;;;;;;; |
.draw_wigwag: |
;äãªæ¨ï ãáâ ®¢ª¨ ¯¥à¥¬¥ëå |
mov ebp,shift_color |
call .clear_cursor |
or word ed_flags,ed_shift_bac ;ãáâ ®¢ª ä« £ , ¢ë¤¥«¥®© ®¡« á⨠|
mov ebp,shift_color |
mov eax,dword ed_pos |
test word ed_flags,ed_left_fl |
jz .low |
jmp @f |
;;;;;;;;;; |
;ãªæ¨ï 㤠«¥¨ï ¢ë¤¥«¥¨ï ¯à¨ ¤¢¨¦¥¨ï ¢«¥¢® ¨ ¢¯à ¢® ¨ ¦ ⨨ shift |
;®£¨ª : |
;;;;;;;;;; |
.draw_wigwag_cl: |
;äãªæ¨ï ãáâ ®¢ª¨ ¯¥à¥¬¥ëå |
mov ebp,ed_color |
call .clear_cursor |
mov ebp,ed_color |
mov eax,dword ed_pos |
test word ed_flags,ed_left_fl |
jz .low |
@@: call .draw_rectangle ; à¨á®¢ âì ¯àאַ㣮«ì¨ª § ªà 訢 ¥¬®© ®¡« á⨠|
ret |
.low: dec eax |
jmp @b |
;¢å®¤®© ¯ à ¬¥âà ebx - ed_pos |
.sh_first_sh: |
test word ed_flags,ed_shift |
je @f |
mov dword ed_shift_pos_old,ebx |
test word ed_flags,ed_shift_on |
jne @f |
mov dword ed_shift_pos,ebx |
or word ed_flags,ed_shift_on |
@@: ret |
;¡à ¡®âª ªà ©¨å ¯®«®¦¥¨© ¢ editbox ¯à¨ ¦ ⮬ shift |
;¯à®¨§¢®¤¨â áï⨥ ¢ë¤¥«¥¨¥, ¥á«¨ ¥â shift |
;¨ ç¥ ¢®®¡é¥ ¢ë室¨â |
.sh_st_of: |
test word ed_flags,ed_shift |
jne @f |
test word ed_flags,ed_shift_bac |
je @f |
mov ebp,ed_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ ;®ç¨á⪠¢ë¤¥«¥®£® äà £¬¥â |
and word ed_flags,ed_shift_cl ; ®ç¨á⪠®â ⮣® çâ® ã¡à «¨ ¢ë¤¥«¥¨¥ |
jmp .draw_cursor_text |
@@: |
and word ed_flags,ed_shift_off |
edit_ex |
;¯à®¢¥àª á®áâ®ï¨ï shift ¡ë« «¨ ® ¦ â à ìè¥? |
.sh_enable: |
test word ed_flags,ed_shift |
jne .sh_ext_en ; à¨á®¢ âì § ªà è¥ë© ¯àאַ㣮«ì¨ª |
test word ed_flags,ed_shift_bac |
je @f |
call .check_offset |
mov ebp,ed_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ ;®ç¨á⪠¢ë¤¥«¥®£® äà £¬¥â |
call .draw_wigwag_cl |
and word ed_flags,ed_shift_cl ; 1¢ à ¥ 㦮 |
ret |
@@: mov ebp,ed_color |
call .clear_cursor |
call .check_offset |
ret |
.sh_ext_en: |
call .check_offset |
test word ed_flags,ed_offset_fl |
je @f |
;¨á®¢ ¨¥ § ªà è¥ëå ¯àאַ㣮«ì¨ª®¢ ¨ ®ç¨á⪠¨å |
mov eax,dword ed_shift_pos |
mov ebx,dword ed_pos |
mov ecx,dword ed_shift_pos_old |
;¯à®¢¥àª ¨ à¨á®¢ ¨¥ § ªà è¥ëå ®¡« á⥩ |
cmp eax,ecx |
je .1_shem |
jb .smaller |
cmp ecx,ebx |
ja .1_shem |
call .draw_wigwag_cl ;clear |
jmp .sh_e_end |
.smaller: |
cmp ecx,ebx |
jb .1_shem |
call .draw_wigwag_cl ;clear |
jmp .sh_e_end |
;alike = |
.1_shem: call .draw_wigwag |
.sh_e_end: and word ed_flags,ed_shift_off |
ret |
@@: mov ebp,shift_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
jmp .sh_e_end |
;äãªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ¦ ⨨ home and end |
.sh_home_end: |
mov ebp,ed_color |
call .clear_cursor |
test word ed_flags,ed_shift_bac |
je @f |
mov ebp,ed_color |
mov ebx,dword ed_shift_pos_old |
call .sh_cl_ |
@@: test word ed_flags,ed_shift |
je .sh_exit_ ;¢ë©â¨ |
mov ebp,shift_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
or word ed_flags,ed_shift_bac ;ãáâ ®¢ª ä« £ , ¢ë¤¥«¥®© ®¡« á⨠|
jmp .sh_e_end |
.sh_exit_: call .check_offset |
ret |
;äãªæ¨ï ¢¥á¥¨ï 0 ¯® ¤à¥áã ed_size+1 |
.enable_null: |
pusha |
mov eax,ed_size |
mov ebx,ed_text |
test eax,eax |
add eax,ebx |
jne @f |
inc eax |
@@: xor ebx,ebx |
mov [eax],bl |
edit_ex |
;- 㤠«¥¨¥ ᨬ¢®« |
;å®¤ë¥ ¤ ë¥ edx=ed_size;ecx=ed_pos |
.del_char: |
mov esi,ed_text |
test word ed_flags,ed_shift_on |
je @f |
mov eax,dword ed_shift_pos |
mov ebx,esi |
cmp eax,ecx |
jae .dh_n |
mov ed_pos,eax ;çâ® ¡ë ¥ ¡ë«® ã¡¥£ ¨ï ªãàá®à |
mov ebp,ecx |
sub ebp,eax |
add ebx,eax ;eax ¬¥ìè¥ |
sub edx,ecx |
add esi,ecx |
mov dword ed_shift_pos,ebp |
jmp .del_ch_sh |
;¥á«¨ ¨ ç¥ |
.dh_n: |
mov ebp,eax |
sub ebp,ecx |
add ebx,ecx |
sub edx,eax |
add esi,eax |
mov dword ed_shift_pos,ebp |
jmp .del_ch_sh |
@@: add esi,ecx ;㪠§ ⥫ì + ᬥ饨¥ ª ॠ«ì®¬ã ¡ãää¥àã |
mov ebx,esi |
inc esi |
cld |
sub edx,ecx |
.del_ch_sh: |
push edi |
mov edi,ebx |
@@: |
lodsb |
stosb |
dec edx |
jns @b |
pop edi |
ret |
;¢ëç¨á«¨âì § ªà 訢 ¥¬ãî ®¡« áâì |
;ᮣ« 襨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size |
.clear_bg: |
call .get_n ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨ë ª®¬¯®¥â |
push eax |
mov ebx,ed_offset |
add eax,ebx ;eax = w_off= ed_offset+width |
mov ebx,ebp ;ed_size |
cmp eax,ebx |
jb @f |
mov eax,ed_pos |
sub ebx,eax |
mov ecx,ed_offset |
sub eax,ecx |
jmp .nxt |
@@: mov ebx,ed_pos |
push ebx |
sub eax,ebx |
mov ebx,eax ;It is don't optimal |
pop eax ;ed_pos |
mov ecx,ed_offset |
sub eax,ecx |
.nxt: |
mov ebp,eax ;¯à®¢¥àª ¢ë室 § ªà 訢 ¥¬®© ®¡« á⨠§ ¯à¥¤¥«ë ¤«¨ë |
add ebp,ebx |
pop edx |
cmp ebp,edx |
je @f |
inc ebx |
@@: mov edx,ebx |
lea ebx,[eax*2+eax] |
shl ebx,1 |
add ebx,ed_left |
inc ebx |
shl ebx,16 |
lea ecx,[edx*2+edx] |
shl ecx,1 |
mov bx,cx |
mov edx,ed_color |
call .draw_bg_eax |
ret |
;;;;;;;;;;;;;;;;;;; |
;;; ¡à ¡®âª ¯à¨¬¨â¨¢®¢ |
;;;;;;;;;;;;;;;;;;;; |
; à¨á®¢ âì ¯àאַ㣮«ì¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp |
;¢å®¤ë¥ ¯ à ¬¥âàë: |
;eax=dword ed_pos |
;ebp=-梥â ed_color or shift_color |
.draw_rectangle: |
mov ecx,dword ed_offset |
sub eax,ecx |
lea ebx,[eax*2+eax] |
shl ebx,1 |
inc ebx |
add ebx,ed_left |
shl ebx,16 |
add ebx,6 |
mov edx,ebp |
call .draw_bg_eax |
ret |
;;;;;;;;;;;;;;;;;; |
;;஢¥àª ¦ â «¨ shift |
;;;;;;;;;;;;;;;;;; |
.check_shift: |
pusha ;á®åà ¨¬ ¢á¥ ॣ¨áâàë |
mcall 66,3,1 |
test al,0x03 |
je @f |
or word ed_flags,ed_shift ;ãáâ ®¢¨¬ ä« £ |
@@:edit_ex |
} |
;¬ ªà®á ª« ¢¨è ª®â®àë¥ ¯à®¨á室¨â ॠªæ¨ï |
macro use_key_process backspase,delete,left,right,home,end,insert |
{ |
if backspase eq |
else |
cmp ah,8 |
jz .backspace |
end if |
if delete eq |
else |
cmp ah,0xb6 |
jz .delete |
end if |
if left eq |
else |
cmp ah,176 |
jz .left |
end if |
if right eq |
else |
cmp ah,179 |
jz .right |
end if |
if home eq |
else |
cmp ah,180 |
jz .home |
end if |
if home eq |
else |
cmp ah,181 |
jz .end |
end if |
if insert eq |
else |
cmp ah,185 ;insert |
jz .insert |
end if |
} |
macro use_key_no_process up,down,esc |
{ |
if up eq |
else |
cmp ah,177 |
jz .editbox_exit |
end if |
if down eq |
else |
cmp ah,178 |
jz .editbox_exit |
end if |
if esc eq |
else |
cmp ah,27 ;ESC - ª« ¢¨è )) |
jz .editbox_exit |
end if |
} |
macro use_key_figures_only |
{ |
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë ? |
jz @f |
cmp ah,'0' |
jb .editbox_exit |
cmp ah,'9' |
ja .editbox_exit |
@@: |
} |
macro are_key_shift_press |
{ |
test word ed_flags,ed_shift_on |
je @f |
;å®¤ë¥ ¤ ë¥ edx=ed_size;ecx=ed_pos |
push eax |
mov edx,ed_size |
mov ecx, ed_pos |
pusha |
;;;;;;;;;;;;;;;;;;;;; |
;clear input arrea |
mov ebp,ed_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
mov ebp,ed_size |
call .clear_bg |
;;;;;;;;;;;;;;;;;;;;; |
popa |
call .del_char |
;;;; |
mov eax,dword ed_shift_pos |
mov ebx,ed_size |
sub ebx,eax |
mov ed_size,ebx |
pop eax |
@@: |
} |
macro are_key_cur_end |
{ |
mov ecx,ed_size |
mov edx, ed_max |
test word ed_flags,ed_insert |
jne @f |
cmp ecx,edx |
jae .editbox_exit |
@@: mov ebx, ed_pos |
cmp ebx,edx |
jl @f ; ¥á«¨ ¬¥ìè¥ ¨«¨ à ¢® |
jmp .editbox_exit |
@@: ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à ¢¯à ¢® |
mov ecx,ed_size |
push edi eax |
mov ebp,edi |
mov esi,ed_text ; ª § â¥«ì ¡ãä¥à |
;㤥¬ à ¡®â âì á® áâப®© |
add esi,ecx ;add ed_size ¤®¡ ¢¨¬ max size |
mov edi,esi |
cmp ecx,ebx ; ᫨ ã á ¯®§¨æ¨ï ªãàá®à = ⥪ã饬ã à §¬¥àã ¯¥ç â ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®æ¥ |
je .In_k |
test word [ebp+40],ed_insert ;IF insert is enable â.ª. edi ¨§¬¥¥ ¤à¥á㥬 ç¥à¥§ ebp |
jne .ins_v |
;clear |
pusha |
mov edi,ebp |
mov ebp,ed_size |
call .clear_bg |
popa |
sub ecx,ebx ; ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥¨ï. |
inc edi ;¬¥á⨬ è¨ á¨¬¢®«ë ¢ ¯à ¢® |
std |
inc ecx |
@@: |
;-------- |
lodsb |
stosb |
;-------- |
loop @b |
.In_k: cld |
pop eax |
mov al,ah |
stosb |
pop edi |
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à |
; 㢥«¨ç¨¢ ¥¬ § 票¥ à §¬¥à ¨ ¯®§¨æ¨¨ |
inc dword ed_size |
inc dword ed_pos |
call .draw_all2 |
jmp .shift |
} |
macro use_work_key |
{ |
.insert: test word ed_flags,ed_insert ;not word ed_insert |
je @f |
and word ed_flags,ed_insert_cl |
jmp .editbox_exit |
@@: |
or word ed_flags,ed_insert |
jmp .editbox_exit |
.ins_v: |
dec dword [ebp+42];ed_size ;processing is insert |
sub esi,ecx |
add esi,ebx |
mov edi,esi |
;clear |
pusha |
mov edi,ebp |
mov ebp,ed_pos |
call .clear_bg |
popa |
jmp .In_k |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
.delete: |
mov edx,ed_size |
mov ecx,ed_pos |
cmp edx,ecx |
jg .bac_del |
test word ed_flags,ed_shift_on |
jne .del_bac |
edit_ex |
.bac_del: |
call .del_char |
jmp .draw_all |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;--- ¦ â ª« ¢¨è backspace --- |
.backspace: |
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ? |
mov ecx,ed_pos |
test ecx,ecx |
jnz .del_bac |
test word ed_flags,ed_shift_on |
jne .bac_del |
edit_ex |
.del_bac: |
mov edx,ed_size |
cmp edx,ecx ;if ed_pos=ed_size |
je @f |
dec ecx |
call .del_char |
@@: test word ed_flags,ed_shift_on |
jne .bac_del |
dec dword ed_pos |
.draw_all: |
push .shift;.draw_cursor_text;eax |
test word ed_flags,ed_shift_on |
je @f |
mov eax,dword ed_shift_pos |
mov ebx,ed_size |
sub ebx,eax |
mov ed_size,ebx |
mov ebp,ed_color |
call .clear_cursor |
call .check_offset |
call .draw_bg |
ret |
@@: dec dword ed_size |
.draw_all2: |
and word ed_flags,ed_shift_cl |
mov ebp,ed_color |
call .clear_cursor |
call .check_offset |
mov ebp,ed_size |
call .clear_bg |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;--- ¦ â ª« ¢¨è left --- |
.left: mov ebx,ed_pos |
test ebx,ebx |
jz .sh_st_of |
or word ed_flags,ed_left_fl |
call .sh_first_sh |
dec dword ed_pos |
call .sh_enable |
jmp .draw_cursor_text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;--- ¦ â ª« ¢¨è right --- |
.right: mov ebx,ed_pos |
cmp ebx,ed_size |
je .sh_st_of |
and word ed_flags,ed_right_fl |
call .sh_first_sh |
inc dword ed_pos |
call .sh_enable |
jmp .draw_cursor_text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
.home: |
mov ebx,ed_pos |
test ebx,ebx |
jz .sh_st_of |
call .sh_first_sh |
xor eax,eax |
mov ed_pos,eax |
call .sh_home_end |
jmp .draw_cursor_text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
.end: |
mov ebx,ed_pos |
cmp ebx,dword ed_size |
je .sh_st_of |
call .sh_first_sh |
mov eax,ed_size |
mov ed_pos,eax |
call .sh_home_end |
jmp .draw_cursor_text |
} |
macro use_mouse_func scr_w |
{ |
;---------------------------------------------------------- |
;--- ¡à ¡®âª .mouse_wigwag |
;---------------------------------------------------------- |
.mouse_wigwag: |
shr eax,16 |
or word ed_flags,ed_shift_bac+ed_shift_on+ed_shift |
;;;;;;;;;;;;;;;;;; |
;;¯à®æ¥¤ãà ®¡à ¡®âª¨ ¯®«®¦¥¨ï ¢ë¤¥«¥®£® ⥪áâ , ª®£¤ ¯à®¨á室¨â ¢ë室 § ¯à¥¤¥«ë editbox |
;;;;;;;;;;;;;;;;;; |
mov ebx,[procinfo.box.left] |
add ebx,ed_left |
if scr_w eq |
else |
add ebx,dword scr_w |
end if |
cmp eax,ebx |
jb .mleft |
add ebx,ed_width |
cmp eax,ebx |
ja .mright |
sub ebx,ed_width |
xor edx,edx |
sub eax,ebx ; ¢ëç⨬ ¨§ ª®®à¤¨ â ¬ë誨 ¯® ®á¨ å ª®®à¤¨ âë ¤® editbox ¯® ®á¨ å |
mov ebx,6 |
div ebx |
;;;;;;;;;;;;;;;;;; |
;;¯à®æ¥¤ãà ®¡à ¡®âª¨ ¯®«®¦¥¨ï ¢ë¤¥«¥®£® ⥪áâ , ¢ ¯à¥¤¥« å ®¡« á⨠editbox |
;;;;;;;;;;;;;;;;;; |
;®«ã稫¨ ª®®à¤¨ âë ¢ eax ¬ë誨, â.¥. ªã¤ ® ¯¥à¥¬¥á⨫ áì |
;¨á®¢ ¨¥ § ªà è¥ëå ¯àאַ㣮«ì¨ª®¢ ¨ ®ç¨á⪠¨å |
add eax,ed_offset ;¤®¡ ¢¨¬ ᬥ饨¥ |
cmp eax,dword ed_size ;¥á«¨ ¢ë諨 § ¯à¥¤¥«ë, â® ¨ç¥£® ¥ ¤¥« âì |
ja .mwigvag |
.mdraw: |
mov dword ed_pos,eax ;á®åà ¨¬ ®¢®¥ § 票¥ |
;¨á®¢ ¨¥ § ªà è¥ëå ¯àאַ㣮«ì¨ª®¢ ¨ ®ç¨á⪠¨å |
mov ecx,dword ed_shift_pos |
mov ebx,dword ed_shift_pos_old |
mov dword ed_shift_pos_old,eax ;¢¥á¥¬ ®¢®¥ § 票¥ áâ ன ¯®§¨æ¨¨ ªãàá®à |
;¯à®¢¥àª ¨ à¨á®¢ ¨¥ § ªà è¥ëå ®¡« á⥩ |
cmp ecx,ebx ;¢ëïá塞 ªã¤ ¡ë«® ¤¢¨¦¥¨¥ ®¤¨ è £ § ¤ |
je .m1_shem ;¤¢¨¦¥¨ï ¥ ¡ë«® à ¥¥ |
jb .msmaller ;¤¢¨¦¥¨¥ ¡ë«® -> |
cmp ebx,eax ;¤¢¨¦¥¨¥ ¡ë«® ¤® í⮣® <- ¨ âãâ ¬ë ¯à®¢¥à塞 ᥩç á ªã¤ ¤¢¨¦¥¨¥ ¯à®¨á室¨â |
ja .m1_shem ;¥á«¨ ¡ë«® ¤¢¨¦¥¨¥ <- ⮠㦮 § ªà á¨âì ®¡« áâì |
je .mwigvag ;¥á«¨ ¨§¬¥¥¨ï ¥ ¡ë«®, â® ¨ç¥£® ¥ ¤¥« âì |
mov ebp,ed_color ;âãâ 㦮 ®ç¨áâ¨âì ®¡« áâì c ed_pos ed_shift_pos_old |
;¢å®¤ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos |
call .sh_cl_ |
jmp .mwigvag |
.msmaller: |
cmp ebx,eax |
jb .m1_shem |
mov ebp,ed_color |
;¢å®¤ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos |
call .sh_cl_ |
jmp .mwigvag |
;alike = |
.m1_shem: |
mov ebp,shift_color |
;¢å®¤ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos |
mov ebx,ecx |
call .sh_cl_ |
jmp .mwigvag |
.mwigvag: |
and word ed_flags,ed_shift_mcl |
jmp .draw_cursor_text |
; popa |
; ret |
.mleft: |
mov eax,ed_pos |
cmp eax,0 |
jbe .mwigvag |
dec eax |
call .check_offset |
push eax |
mov ebx,ed_shift_pos |
mov ebp,shift_color |
call .sh_cl_ |
pop eax |
jmp .mdraw |
.mright: |
mov eax,ed_pos |
mov ebx,ed_size |
cmp eax,ebx |
jae .mwigvag |
inc eax |
call .check_offset |
mov ebx,ed_shift_pos |
mov ebp,shift_color |
push eax |
call .sh_cl_ |
pop eax |
jmp .mdraw |
} |
macro use_work_mause scr_h,scr_w |
;---------------------------------------------------------- |
;--- ¥ 㤥ন¢ ¥¬ «¨ ¬ë ª« ¢¨èã ¬ë誨, ¯¥à¥¬¥é ï ªãàá®à, ¢® ¢á¥ à §ë¥ áâ®à®ë? |
;---------------------------------------------------------- |
{ |
test word ed_flags,ed_mouse_on |
jne .mouse_wigwag |
;---------------------------------------------------------- |
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box ------------- |
;---------------------------------------------------------- |
mov ebx,[procinfo.box.top] |
add ebx,ed_top |
if scr_h eq |
else |
add ebx,scr_h |
end if |
cmp ax,bx |
jl ._blur;.mouse_end_no_focus |
add ebx,ed_height |
cmp ax,bx |
jg ._blur;.mouse_end_no_focus |
shr eax,16 |
mov ebx,[procinfo.box.left] |
add ebx,ed_left |
if scr_w eq |
else |
add ebx,scr_w |
end if |
cmp ax,bx |
jl ._blur;.mouse_end_no_focus |
add ebx,ed_width |
cmp ax,bx |
jg ._blur;.mouse_end_no_focus |
;--- ¨§¬¥ï¥¬ ¯®§¨æ¨î ªãàá®à --- |
push eax |
mov ebp,ed_color |
call .clear_cursor |
pop eax |
._mvpos: |
mov ebx,dword [procinfo.box.left] |
xor edx,edx |
sub eax,ed_left |
sub eax,ebx |
if scr_w eq |
else |
add ebx,scr_w |
sub eax,2 |
end if |
mov ebx,6 |
div bx |
add eax,ed_offset |
cmp eax,ed_size |
jna ._mshift |
mov eax,ed_size |
._mshift: |
;;;;;;; |
;;¥ªæ¨ï ®¡à ¡®âª¨ shift ¨ ¢ë¤¥«¥¨ï ¯® shift |
;;;;;;; |
test word ed_flags,ed_shift_bac |
je @f |
mov ebp,dword ed_color |
mov ebx,dword ed_shift_pos |
push eax |
call .sh_cl_ |
and word ed_flags,ed_shift_bac_cl |
pop eax |
@@: |
test word ed_flags,ed_mouse_on |
jne @f |
mov dword ed_shift_pos,eax |
or word ed_flags,ed_mouse_on |
mov dword ed_pos,eax |
mov dword [mouse_flag],edi ;ãáâ ®¢¨¬ ¨¤¥â¨ä¨ª â®à |
bts word ed_flags,1 ;ãáâ ®¢ª 䮪ãá |
jmp .m_sh |
@@: |
cmp eax,dword ed_shift_pos ;¥á«¨ ¯®§¨æ¨¨ ¥ ¨§¬¥¨«¨áì |
je .editbox_exit |
mov ed_pos,eax |
mov ebp,dword shift_color |
mov ebx,dword ed_shift_pos |
call .sh_cl_ |
or word ed_flags,ed_mous_adn_b ;ãáâ ®¢¨¬ ¡¨â çâ® ¬ë ¢ë¤¥«¨«¨ +shift_on + |
.m_sh: call .draw_text |
call .draw_cursor |
;---------------------------------------------------------- |
;--- ¯à®æ¥¤ãà ãáâ ®¢ª¨ 䮪ãá --------------------------- |
;---------------------------------------------------------- |
jmp .drc |
._blur: |
test word ed_flags,ed_always_focus |
jne .editbox_exit |
btr word ed_flags,1 ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
jnc .editbox_exit |
mov ebp,ed_color |
call .clear_cursor |
.drc: call .draw_border |
jmp .editbox_exit |
} |
; ªà®á ¢ë室 |
macro edit_ex |
{ |
popa |
ret |
} |
macro debug |
{ |
;----------- ®â« ¤ª |
pushad |
; mov dword [ed_buffer.2],0 |
; mov eax,edi |
mov eax,dword [ed_buffer.2] |
mov edi,ed_buffer.3 |
call .str |
;à¨á®¢ ¨¥ ä® |
mov eax,13 |
mov ebx,178*65536+70 |
mov ecx,28*65536+10 |
xor edx,edx |
int 0x40 |
;¢ë¢®¤ § 票ï íªà |
mov eax,4 |
mov ebx,180*65536+30 |
mov ecx,0x10DDBBCC |
mov edx,ed_buffer.3 |
mov esi,8 |
int 0x40 |
popad |
;----------- ®â« ¤ª |
} |
macro debug_func |
{ |
.str: |
mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬ áç¨á«¥¨ï ¨§¬¥ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤ë¥ ¯ à ¬¥âàë eax - ç¨á«® |
;¯à¥à¥¢®¤ ç¨á« ¢ ASCII áâப㠢§®¤ë¥ ¤ ë¥ ecx=á¨á⥬ áç¨á«¥ï edi ¤à¥á ªã¤ § ¯¨áë¢ âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®¥æ ¯¥à¥¬¥®© |
cmp eax,ecx ;áà ¢¨âì ¥á«¨ ¢ eax ¬¥ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ @@-1 â.¥. pop eax |
jb @f |
xor edx,edx ;®ç¨áâ¨âì edx |
div ecx ;à §¤¥«¨âì - ®áâ ⮪ ¢ edx |
push edx ;¯®«®¦¨âì ¢ á⥪ |
;dec edi ;ᬥ饨¥ ¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®æ áâப¨ |
call .str;¯¥à¥©â¨ á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥â ¯®ª ¢ eax ¥ á⠥⠬¥ìè¥ ç¥¬ ¢ ecx |
pop eax |
@@: ;cmp al,10 ;¯à®¢¥à¨âì ¥ ¬¥ìè¥ «¨ § 票¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥ï 10 ¤ ï ª®¬ ¤ - «¨è ï)) |
;sbb al,$69 ;- ç¥áâ® ¤ ï ¨áâàãªæ¨ï ¬¥ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ¥ § î ª ª íâ® à ¡®â ¥â |
;das ;¯®á«¥ ¤ ®© ª®¬ ¤ë ª ª ¡ë ¯à®¨á室¨â 㬥ì襨¥ al 66h (¢ ª¨£¥ ¯¨á ® ¤à㣮¥) |
or al,0x30 ;¤ ï ª®¬ ¤ ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥ |
stosb ;§ ¯¨á âì í«¥¬¥â ¨§ ॣ¨áâà al ¢ ï祪㠯 ¬ï⨠es:edi |
ret ;¢¥àãâìáï ç¥ì ¨â¥à¥áë© å®¤ â.ª. ¯®ª ¢ á⥪¥ åà ¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï |
} |
;;;;;;;;;;;;;;; |
;For LibGui |
;;;;;;;;;;;;;;; |
macro srt_ed_libgui |
{ |
ed_width equ [EditBox.ed_width] ;è¨à¨ ª®¬¯®¥â |
ed_left equ [EditBox.ed_left] ;¯®«®¦¥¨¥ ¯® ®á¨ å |
ed_top equ [EditBox.ed_top] ;¯®«®¦¥¨¥ ¯® ®á¨ ã |
ed_color equ [EditBox.ed_color] ;梥â ä® ª®¬¯®¥â |
shift_color equ [EditBox.shift_color] ;=0x6a9480 |
ed_focus_border_color equ [EditBox.ed_focus_border_color] ;梥â à ¬ª¨ ª®¬¯®¥â |
ed_blur_border_color equ [EditBox.ed_blur_border_color] ;梥⠥ ªâ¨¢®£® ª®¬¯®¥â |
ed_text_color equ [EditBox.ed_text_color] ;梥â ⥪áâ |
ed_max equ [EditBox.ed_max] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦® ¬ ªá¨¬ «ì® ¢¢¥á⨠|
ed_text equ [EditBox.ed_text] ;㪠§ â¥«ì ¡ãä¥à |
ed_flags equ [EditBox.ed_flags] ;ä« £¨ |
ed_size equ [EditBox.ed_size] ;ª®«-¢® ᨬ¢®«®¢ |
ed_pos equ [EditBox.ed_poz] ;¯®§¨æ¨ï ªãàá®à |
ed_offset equ [EditBox.ed_offset] ;ᬥ饨¥ |
cl_curs_x equ [EditBox.cl_curs_x] ;¯à¥¤ë¤ã饥 ª®®à¤¨ â ªãàá®à ¯® å |
cl_curs_y equ [EditBox.cl_curs_y] ;¯à¥¤ë¤ã饥 ª®®à¤¨ â ªãàá®à ¯® ã |
ed_shift_pos equ [EditBox.ed_shift_pos] ;¯®«®¦¥¨¥ ªãàá®à |
ed_shift_pos_old equ [EditBox.ed_shift_pos_old] ;áâ ஥ ¯®«®¦¥¨¥ ªãàá®à |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;Bit mask from editbox |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ed_figure_only= 1000000000000000b ;®¤¨ ᨬ¢®«ë |
ed_always_focus= 100000000000000b |
ed_focus= 10b ;䮪ãá ¯à¨«®¦¥¨ï |
ed_shift_on= 1000b ;¥á«¨ ¥ ãáâ ®¢«¥ -§ ç¨â ¢¯¥à¢ë¥ ¦ â shift,¥á«¨ ¡ë« ãáâ ®¢«¥, § ç¨â ¬ë 㦥 çâ® - â® ¤¥« «¨ 㤥ন¢ ï shift |
ed_shift_on_off=1111111111110111b |
ed_shift= 100b ;¢ª«îç ¥âáï ¯à¨ ¦ ⨨ shift â.¥. ¥á«¨ ¦¨¬ î |
ed_shift_off= 1111111111111011b |
ed_shift_bac= 10000b ;¡¨â ¤«ï ®ç¨á⪨ ¢ë¤¥«¥®£® shift â.¥. ¯à¨ ãáâ ®¢ª¥ £®¢®à¨â çâ® ¥áâì ¢ë¤¥«¥¨¥ |
ed_shift_bac_cl=1111111111101111b ;®ç¨á⪠¯à¨ 㤠«¥¨¨ ¢ë¤¥«¥¨ï |
ed_shift_cl= 1111111111100011b |
ed_shift_mcl= 1111111111111011b |
ed_left_fl= 100000b |
ed_right_fl= 1111111111011111b |
ed_offset_fl= 1000000b |
ed_offset_cl= 1111111110111111b |
ed_insert= 10000000b |
ed_insert_cl= 1111111101111111b |
ed_mouse_on = 100000000b |
ed_mous_adn_b= 100011000b |
ed_mouse_on_off=1111111011111111b |
ed_height=14 ; ¢ëá®â |
} |
/programs/network_old/icq/trunk/icons.inc |
---|
0,0 → 1,64 |
redicq: |
db 0,0,0,0,0,0,0,0,0,0 |
db 0,0,0,0,128,0,0,128,0,0,128,0,0,0,0,0 |
db 128,0,0,128,0,0,128 |
db 0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,128,0,0,179,0,0,179,0,0,179,0,0,128,0,0 |
db 179,0,0,179,0,0,179,0,0,128 |
db 0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,128,0,0,230,0,0,202,0,0,179,0,0,128,0,0 |
db 230,0,0,202,0,0,179,0,0,128 |
db 0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,128,0,0,128,0 |
db 0,128,0,0,179,0,0,202,0,0,230,0,0,128,0,0 |
db 230,0,0,202,0,0,179,0,0,128,0,0,128,0,0,128 |
db 0,0,0 |
db 0,0,128,0,0,179,0,0,179,0 |
db 0,179,0,0,128,0,0,230,0,0,230,0,0,128,0,0 |
db 230,0,0,230,0,0,128,0,0,179,0,0,179,0,0,179 |
db 0,0,128 |
db 0,0,128,0,0,179,0,0,202,0 |
db 0,202,0,0,230,0,0,128,0,0,230,0,0,128,0,0 |
db 230,0,0,128,0,0,230,0,0,202,0,0,202,0,0,179 |
db 0,0,128 |
db 0,0,128,0,0,179,0,0,230,0 |
db 0,230,0,0,230,0,0,230,0,0,128,0,255,255,0,0 |
db 128,0,0,230,0,0,230,0,0,230,0,0,230,0,0,179 |
db 0,0,128 |
db 0,0,0,0,0,128,0,0,128,0 |
db 0,128,0,0,128,0,0,128,0,255,255,0,255,255,0,255 |
db 255,0,0,128,0,0,128,0,0,128,0,0,128,0,0,128 |
db 0,0,0,0,0,128,0,0,179,0,0,179,0 |
db 0,179,0,0,179,0,0,179,0,0,128,0,255,255,0,0 |
db 128,0,0,179,0,0,179,0,0,179,0,0,179,0,0,179 |
db 0,0,128 |
db 0,0,128,0,0,202,0,0,202,0 |
db 0,202,0,0,202,0,0,128,0,0,179,0,0,128,0,0 |
db 179,0,0,128,0,0,230,0,0,202,0,0,202,0,0,179 |
db 0,0,128 |
db 0,0,128,0,0,230,0,0,230,0 |
db 0,230,0,0,128,0,0,202,0,0,179,0,0,128,0,0 |
db 230,0,0,179,0,0,128,0,0,230,0,0,230,0,0,179 |
db 0,0,128 |
db 0,0,0,0,0,128,0,0,128,0 |
db 0,128,0,0,230,0,0,202,0,0,179,0,0,128,0,0 |
db 230,0,0,202,0,0,179,0,0,128,0,0,128,0,0,128 |
db 0,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,128,0,0,230,0,0,202,0,0,179,0,0,128,0,0 |
db 230,0,0,202,0,0,179,0,0,128 |
db 0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,128,0,0,230,0,0,230,0,0,179,0,0,128,0,0 |
db 230,0,0,230,0,0,179,0,0,128 |
db 0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,0,0,0,128,0,0,128,0,0,128,0,0,0,0,0 |
db 128,0,0,128,0,0,128,0,0,0,0,0,0,0,0,0 |
db 0,0,0 |
/programs/network_old/icq/trunk/ki.cfg |
---|
0,0 → 1,9 |
# |
# |
# |
UIN="123456789" |
PASS="PASS" |
# |
# |
ICQIP="64.12.200.89" |
#ICQIP="192.168.0.1" |
/programs/network_old/icq/trunk/macros.inc |
---|
0,0 → 1,543 |
@^ fix macro comment { |
^@ fix } |
; ------------------------- |
macro library [lname,fname] |
{ |
forward |
dd __#lname#_library_table__,__#lname#_library_name__ |
common |
dd 0 |
forward |
align 4 |
__#lname#_library_name__ db fname,0 |
} |
macro import lname,[name,sname] |
{ |
common |
align 4 |
__#lname#_library_table__: |
forward |
if used name |
name dd __#name#_import_name__ |
end if |
common |
dd 0 |
forward |
if used name |
align 4 |
__#name#_import_name__ db sname,0 |
end if |
} |
macro export [name,sname] |
{ |
forward |
dd __#name#_export_name__,name |
common |
dd 0 |
forward |
align 4 |
__#name#_export_name__ db sname,0 |
} |
; ------------------------- |
macro m2m dest,src { |
push src |
pop dest |
} |
macro iglobal { |
IGlobals equ IGlobals, |
macro __IGlobalBlock { } |
macro uglobal { |
UGlobals equ UGlobals, |
macro __UGlobalBlock { } |
endg fix } ; Use endg for ending iglobal and uglobal blocks. |
macro IncludeIGlobals{ |
macro IGlobals dummy,[n] \{ __IGlobalBlock |
purge __IGlobalBlock \} |
match I, IGlobals \{ I \} } |
macro IncludeUGlobals{ |
macro UGlobals dummy,[n] \{ |
\common |
\local begin, size |
begin = $ |
virtual at $ |
\forward |
__UGlobalBlock |
purge __UGlobalBlock |
\common |
size = $ - begin |
end virtual |
rb size |
\} |
match U, UGlobals \{ U \} } |
uglobal |
endg |
iglobal |
endg |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
IncludeIGlobals |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
IncludeUGlobals |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; macro for defining multiline text data |
struc mls [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring ; mod |
ssize = $ |
end virtual |
db ssize |
db sstring |
common |
db -1 ; mod |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
name db data |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
forward |
if lang eq lng |
db data |
end if |
common |
.size = $-name |
end if |
} |
macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
common |
local s,m |
m = 0 |
if used name |
label name |
forward |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
common |
.size = $-name |
.maxl = m |
end if |
} |
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
common |
local s,m,c |
m = 0 |
c = 0 |
if used name |
label name |
forward |
if lang eq lng |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
c = c+1 |
end if |
common |
.size = $-name |
.maxl = m |
.count = c |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
include 'config.inc' |
;__CPU_type equ p5 |
SYSENTER_VAR equ 0 |
macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls |
local ..ret_point |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
if __CPU_type eq p5 |
int 0x40 |
else |
if __CPU_type eq p6 |
push ebp |
mov ebp, esp |
push ..ret_point ; it may be 2 or 5 byte |
sysenter |
..ret_point: |
pop edx |
pop ecx |
else |
if __CPU_type eq k6 |
push ecx |
syscall |
pop ecx |
else |
display 'ERROR : unknown CPU type (set to p5)', 10, 13 |
__CPU_type equ p5 |
int 0x40 |
end if |
end if |
end if |
} |
; ------------------------- |
macro header a,[b] { |
common |
use32 |
org 0 |
db 'MENUET',a |
forward |
if b eq |
dd 0 |
else |
dd b |
end if } |
macro section name { align 16 |
label name } |
macro func name { |
if ~used name |
display 'FUNC NOT USED: ',`name,13,10 |
else |
align 4 |
name: |
;diff16 `name,0,name |
;pushad |
;pushfd |
;dps `name |
;newline |
;mcall 5,1 |
;popfd |
;popad |
} |
macro endf { end if } |
macro diff16 title,l1,l2 |
{ |
local s,d |
s = l2-l1 |
display title,': 0x' |
repeat 8 |
d = '0' + s shr ((8-%) shl 2) and $0F |
if d > '9' |
d = d + 'A'-'9'-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
macro diff10 title,l1,l2 |
{ |
local s,d,z,m |
s = l2-l1 |
z = 0 |
m = 1000000000 |
display title,': ' |
repeat 10 |
d = '0' + s / m |
s = s - (s/m)*m |
m = m / 10 |
if d <> '0' |
z = 1 |
end if |
if z <> 0 |
display d |
end if |
end repeat |
display 13,10 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro RGB [a] { |
common |
match (r=,g=,b),a \{ |
\dd ((r) shl 16) or ((g) shl 8) or (b) |
\} |
} |
struc POINT _t,_dx,_dy { |
.x _t _dx |
.y _t _dy |
} |
; structure definition helper |
include 'struct.inc' |
struct RECT |
left dd ? |
top dd ? |
right dd ? |
bottom dd ? |
ends |
struct BOX |
left dd ? |
top dd ? |
width dd ? |
height dd ? |
ends |
; structures used in MeOS |
struct process_information |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
dw ? ; +8 |
process_name rb 12 ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
box BOX ; +34 |
slot_state dw ? ; +50 |
dw ? ; +52 |
client_box BOX ; +54 |
wnd_state db ? ; +70 |
rb (1024-71) |
ends |
struct system_colors |
frame dd ? |
grab dd ? |
grab_button dd ? |
grab_button_text dd ? |
grab_text dd ? |
work dd ? |
work_button dd ? |
work_button_text dd ? |
work_text dd ? |
work_graph dd ? |
ends |
struct FILEDATE |
Second db ? |
Minute db ? |
Hour db ? |
db ? |
Day db ? |
Month db ? |
Year dw ? |
ends |
struct FILEINFO |
Attributes dd ? |
IsUnicode db ? |
db 3 dup(?) |
DateCreate FILEDATE |
DateAccess FILEDATE |
DateModify FILEDATE |
Size dq ? |
ends |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/network_old/icq/trunk/parser.inc |
---|
0,0 → 1,696 |
; |
; âàãªâãà ¤«ï äãªæ¨¨ 70 |
; |
struc sinfo |
{ |
.subfnc_name dd 0 |
.pos_in_file dd 0 |
.reserved dd 0 |
.bytes_to_read dd 0 |
.pbuffer dd 0 |
.null db 0 |
.pname dd 0 |
} |
; |
; â ¡«¨æë § 票© |
; |
; +----+-------------+-----------------+ |
; | in | Variable | Variable | |
; | de | name | string | |
; | x | | | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | | |
; | | | | |
; | 1 | UIN | 'XXXXX..XX',0 | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | |
; |
; § £à㧪 int ¯®ª ¥ ॠ«¨§®¢ |
; |
; +----+-------------+-----------------+ |
; | in | Variable | Variable | |
; | de | name | int | |
; | x | | | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | | |
; | | | | |
; | 1 | BUFFSIZE | XXXXXXXX | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | |
; |
; |
TABLE_SIZE equ 16 |
VNAME_LEN equ 8 |
VAR_LEN equ 16 |
; |
; ¯¨á ¨¥ â ¡«¨æë § 票© |
virtual at 0 |
vartable: |
.uin db VAR_LEN dup ? |
.pass db VAR_LEN dup ? |
.icqip db VAR_LEN dup ? |
end virtual |
; |
; ®¤ë ®è¨¡®ª ä ©«®¢®© á¨á⥬ë |
; |
FIO_SUCCESS equ 0 |
FIO_UNSUPPORTED equ 2 |
FIO_UNKNOWNFS equ 3 |
FIO_FILENOTFOUND equ 5 |
FIO_EOF equ 6 |
FIO_BADPOINTER equ 7 |
FIO_DISKFULL equ 8 |
FIO_FATDAMAGED equ 9 |
FIO_DENIED equ 10 |
FIO_ERRORDEVICE equ 11 |
IOBUFF_SIZE equ 128 |
; |
; ¬ ªà®á ¤«ï ¯®¨áª í«¥¬¥â ¢ áâப¥ |
; ¢®§¢à é ¥â ¢ eax ®¬¥à í«¥¬¥â ¨«¨ -1 ¥á«¨ ¥ ©¤¥ |
macro findchar string, len, char |
{ |
local ..fc_endstr, ..fc_end |
push ebx |
push ecx |
push edi |
mov edi, string |
mov ecx, len |
mov ebx, ecx |
cld |
mov al, char |
repne scasb |
jcxz ..fc_endstr |
sub ebx, ecx ; ®¬¥à = |
mov eax, ebx |
jmp ..fc_end |
..fc_endstr: |
mov eax, -1 |
..fc_end: |
pop edi |
pop ecx |
pop ebx |
} |
; |
; ªà®á ¤«ï ¯®¨áª í«¥¬¥â áâப¨, ®â«¨ç î饣®áï ®â |
; § ¤ ®£® |
macro findother string, len, char |
{ |
local ..fc_endstr, ..fc_end |
push ebx |
push ecx |
push edi |
mov edi, string |
mov ecx, len |
mov ebx, ecx |
cld |
mov al, char |
repe scasb ; ᫨ ᨬ¢®« ¥ char - ¢ë室¨¬ |
jcxz ..fc_endstr ; áâப ¨§ char |
sub ebx, ecx ; ¢ ebx - ®¬¥à í«¥¬¥â ®â«¨ç®£® ®â char |
mov eax, ebx |
jmp ..fc_end |
..fc_endstr: |
mov eax, -1 |
..fc_end: |
pop edi |
pop ecx |
pop ebx |
} |
; |
; ªà®á ¤«ï ª®¯¨à®¢ ¨ï áâப |
; |
macro mstrcpy from, to, leng |
{ |
push ecx |
push esi |
push edi |
mov ecx, leng |
mov esi, from |
mov edi, to |
cld |
rep movsb |
pop edi |
pop esi |
pop ecx |
} |
; |
; ¨æ¨ «¨§¨àã¥â â ¡«¨æë |
; |
; inittables: |
; |
; |
; mstrcpy name1, nvtable, VNAME_LEN |
; mstrcpy name2, (nvtable + NAME_LEN), VNAME_LEN |
; mstrcpy name3, (nvtable + NAME_LEN * 2), VNAME_LEN |
; |
; |
; |
; ret |
; |
; § ¯®«ï¥â â ¡«¨æë § 票ﬨ |
; IN eax - ASCIIZ ¨¬ï ä ©« |
; OUT eax - १ã«ìâ â ç⥨ï |
; ¥á«¨ १ã«ìâ â -1, ä®à¬ â ä ©« ¥¯à ¢¨«ìë© |
; |
parseconf: |
push edi |
push esi |
;push eax |
push ebx |
push ecx |
push edx |
mov [strnum], dword 0 |
; |
; à®ç¨â âì ¯®áâà®ç® ª®ä¨£ |
; ¥á«¨ áâப ç¨ ¥âáï á ;, # - ª®¬¬¥â ਩ |
; ®à¬ â UIN="1234567890" |
; PASS="******" ¨ â.¤. |
; |
; ¡à®á ᬥ饨ï |
mov [shift], dword 0 |
mov esi, eax |
pc_still: |
mov edx, esi |
mov ecx, IOBUFF_SIZE |
mov ebx, iobuff |
call getstr |
inc [strnum] |
push eax |
; |
;஢¥àª ¯®«ã祮© áâப¨ |
; |
movzx eax, byte [iobuff] |
test eax, eax |
jz pc_next |
cmp al, '#' |
jz pc_next |
cmp al, ';' |
jz pc_next |
; |
; ©â¨ ¨¬ï ¯¥à¥¬¥®© |
; |
findother iobuff, ebx, ' ' |
cmp eax, -1 |
jz pc_next |
mov [stnpos], eax ; ç «® ¨¬¥¨ |
; |
; ©â¨ = |
; |
mov ecx, ebx ; ᪠âì ®â ©¤¥®£® ᨬ¢®« |
sub ecx, eax ; |
mov edi, iobuff |
add edi, eax |
findchar edi, ecx, '=' |
cmp eax, -1 |
jz pc_badformat |
mov edi, [stnpos] |
add eax, edi ; ¢ eax - ᬥ饨¥ ®â ç « áâப¨ |
mov [eqpos], eax |
mov ecx, ebx |
sub ecx, eax |
; |
; ¯à®¢¥à¨âì " |
; |
mov dl, [iobuff + eax] |
cmp dl, '"' |
jnz pc_badformat |
; |
; ©â¨ § ªàë¢ îéãî " |
; |
mov edi, iobuff |
add edi, eax |
inc edi |
findchar edi, ecx, '"' |
cmp eax, -1 |
jz pc_badformat |
inc eax |
mov edx, [eqpos] |
add eax, edx |
mov [edvpos], eax |
; |
; áâ ®¢¨âì § 票¥ |
; |
; ®¡ ¢¨âì § ¢¥àè î騥 0 |
mov eax, [stnpos] |
dec eax |
mov ebx, [eqpos] |
mov ecx, ebx |
dec ecx ; ª®«¨ç¥á⢮ ᨬ¢®«®¢ ¤® = |
inc ebx ; யãáâ¨âì " |
mov [iobuff + ecx], byte 0 |
mov edx, [edvpos] |
dec edx |
mov [iobuff + edx], byte 0 |
lea eax, [iobuff + eax] |
lea ebx, [iobuff + ebx] |
call setavar |
jmp pc_next |
pc_badformat: |
pop eax |
mov ebx, [strnum] |
jmp pc_err |
pc_next: |
pop eax |
cmp eax, FIO_EOF |
jz pc_eof |
cmp eax, FIO_SUCCESS |
jnz pc_err |
jmp pc_still |
pc_eof: |
pc_err: |
pop edx |
pop ecx |
pop ebx |
;pop eax |
pop esi |
pop edi |
ret |
; ®¨áª ¢ â ¡«¨æ¥ ¯¥à¥¬¥®© ¨ ãáâ ®¢ª ¥ñ § 票ï |
; IN eax - §¢ ¨¥ ¯¥à¥¬¥®© 㪠§ ⥫ì ASCIIZ |
; IN ebx - § 票¥ ¯¥à¥¬¥®© 㪠§ ⥫ì ASCIIZ |
; OUT eax -१ã«ìâ â 0 = OK, -1 = ¥â ¢ â ¡«¨æ¥ ¯¥à¥¬¥ëå |
; OUT § ¯®«ï¥â £«®¡ «ìãî â ¡«¨æã |
setavar: |
;push ebx |
push ecx |
push edx |
push esi |
push edi |
push ebx |
; |
; ¯à¥¤¥«¨âì ¤«¨ã áâப¨ - §¢ ¨¥ ¯¥à¥¬¥®© |
; |
mov edi, eax |
push eax |
mov ecx, VNAME_LEN |
xor eax, eax ;饬 \0 |
cld |
repne scasb |
mov eax, VNAME_LEN |
sub eax, ecx ; ecx - ®áâ ⮪ ¤® ¬ ªá¨¬ «ì®£® à §¬¥à áâப¨ |
mov ebx, eax |
pop eax |
; |
; ᪠âì ¢ â ¡«¨æ¥ ¯®¤å®¤ï饥 ¨¬ï |
; |
xor edx, edx ;index |
sv_next: |
mov ecx, ebx |
push eax |
mov esi, eax |
mov edi, nvtable |
mov eax, edx |
imul eax, VNAME_LEN ;offset |
add edi, eax |
pop eax |
cld |
repe cmpsb |
jz sv_match |
sv_inc: |
inc edx |
cmp edx, TABLE_SIZE |
jae sv_fail |
jmp sv_next |
sv_match: |
cmp ebx, VNAME_LEN ; ebx - ¤«¨ ¨á室®© áâà®çª¨ |
jz sv_match2 |
push eax |
mov edi, nvtable |
mov eax, edx |
imul eax, VNAME_LEN ;offset |
add edi, eax |
pop eax |
cmp [edi + ebx], byte 0 ; ᫨ ¨¬ï ¢ â ¡«¨æ¥ ª®à®ç¥ ¬ ªá¨¬ «ì®£®, |
jnz sv_inc ; § ª 稢 ¥âáï 0 |
sv_match2: |
pop edi ; |
push edi |
; |
; ¯à¥¤¥«ïâì ¤«¨ã áâப¨ - ¯¥à¥¬¥ ï |
; |
xor eax, eax |
mov ecx, VAR_LEN |
cld |
repne scasb |
mov eax, VAR_LEN |
sub eax, ecx |
mov ecx, eax |
mov ebx, eax |
; |
; ®¯¨à®¢ âì ¯¥à¥¬¥ãî ¢ â ¡«¨æã |
; |
pop esi |
push esi |
mov eax, VAR_LEN |
imul eax, edx |
mov edi, vtable |
add edi, eax |
cld |
rep movsb |
; |
; ᫨ áâப ª®à®ç¥ ¯®«ï ¢ â ¡«¨æ¥, § ¯¨á âì ¢ ª®¥æ 0 |
; |
cmp ebx, VAR_LEN |
jz sv_end |
mov [edi + ebx], byte 0 |
sv_end: |
xor eax, eax |
jmp sv_fin |
sv_fail: |
mov eax, -1 |
sv_fin: |
pop ebx |
pop edi |
pop esi |
pop edx |
pop ecx |
;pop ebx |
ret |
; |
; ⥨¥ ASCIIZ áâப¨ ¨§ ä ©« |
; IN ebx - 㪠§ â¥«ì ¡ãä¥à |
; ecx - à §¬¥à ¡ãä¥à |
; edx - 㪠§ ⥫ì áâப㠨¬ï ä ©« |
; OUT ebx - ¤«¨ áâப¨ |
; eax - १ã«ìâ â ç⥨ï |
getstr: |
;push eax |
;push ebx |
push ecx |
push edx |
push esi |
;xor edx, edx |
xor esi, esi |
gs_read: |
; |
; ¯®«ï¥¬ áâàãªâãàã |
; |
mov [finfo.subfnc_name], 0 |
mov eax, [shift] |
mov [finfo.pos_in_file], eax |
mov [finfo.bytes_to_read], ecx |
mov [finfo.pbuffer], ebx |
mov [finfo.pname], edx |
push ebx |
; |
; ¨â¥¬ |
; |
;mov eax, 70 |
;mov ebx, finfo |
;int 40h |
mcall 70, finfo |
mov ecx, ebx ; ebx ª®«¨ç¥á⢮ ¯à®çâ¥ëå ¡ ©â |
pop ebx |
; |
; ஢¥à¨âì १ã«ìâ â ç⥨ï - ¥á«¨ ¥ EOF ¨ 0, |
; ¢ë室¨¬ |
cmp eax, FIO_EOF |
jz gs_loop |
cmp eax, 0 |
jz gs_loop |
jmp gs_ok |
; |
; ¡à ¡®âª ¯®«ã祮£® ¡«®ª |
; |
gs_loop: |
mov dl, [ebx + esi] |
cmp dl, 0Ah ;cr |
jz gs_cr |
inc esi |
cmp esi, ecx |
jnb gs_err |
jmp gs_loop |
gs_err: |
; |
; ¡ãä¥à¥ ¥â ᨬ¢®« ¯¥à¥®á áâப¨, â.¥. áâப ᫨誮¬ ¤«¨ ï |
; â¡à áë¢ ¥¬ ¢á¥ ¤® ¡«¨¦ ©è¥£® ᨬ¢®« ¯¥à¥®á áâப¨ |
; ¥á«¨ ª®¥æ ä ©« - ¢ë室¨¬ |
cmp eax, FIO_EOF |
jz gs_endf |
add [shift], ecx |
jmp gs_read |
gs_endf: |
xor ebx, ebx |
jmp gs_ok |
gs_cr: |
; |
; ¡à®á¨âì १ã«ìâ â ç⥨ï |
; |
xor eax, eax |
mov dl, [ebx + esi - 1] |
cmp dl, 0Dh ;le |
jz gs_le |
mov [ebx + esi], byte 0 |
mov ebx, esi |
inc esi |
add [shift], esi |
jmp gs_ok |
gs_le: |
mov [ebx + esi - 1], byte 0 |
mov [ebx + esi], byte 0 |
lea ebx, [esi - 1] |
inc esi |
add [shift], esi |
gs_ok: |
pop esi |
pop edx |
pop ecx |
;pop ebx |
;pop eax |
ret |
; |
; ãªæ¨ï ¤«ï ¢ë¢®¤ § £à㦥®© ¨äë |
; |
showcfg: |
push eax |
push ebx |
push ecx |
push edx |
push edi |
xor edx, edx ; áç¥â稪 |
sc_loop: |
cmp edx, TABLE_SIZE |
jnb sc_end |
; |
; ª®¯¨à®¢ âì ¢ ¡ãä¥à ¨¬ï ¨ § 票¥ ¯¥à¥¬¥®© |
; |
mov eax, VNAME_LEN |
imul eax, edx |
lea eax, [nvtable + eax] |
mov cl, [eax] |
cmp cl, byte 0 |
jz sc_next |
push eax |
call strlen |
mov ecx, eax |
pop eax |
mov ebx, cfgbuff |
call strcpy |
mov [cfgbuff + ecx], ':' |
lea ebx, [cfgbuff + ecx + 1] |
mov eax, VAR_LEN |
imul eax, edx |
lea eax, [vtable + eax] |
push eax |
call strlen |
mov ecx, eax |
pop eax |
call strcpy |
mov [ebx + ecx], byte 0 |
mov eax, cfgbuff |
xor ebx, ebx |
call writemsg |
sc_next: |
inc edx |
jmp sc_loop |
sc_end: |
pop edi |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
/programs/network_old/icq/trunk/parser_data.inc |
---|
0,0 → 1,100 |
; |
; ë¥ ¤«ï parser.inc |
; |
; |
; |
; ¨¬ï ä ©« , ª®â®àë© ã¦® ¯ àá¨âì |
; |
fname db '/sys/ki.cfg',0 |
; |
; â ¡«¨æë § 票© |
; |
; +----+-------------+-----------------+ |
; | in | Variable | Variable | |
; | de | name | string | |
; | x | | | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | | |
; | | | | |
; | 1 | UIN | 'XXXXX..XX' | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | |
; |
; § £à㧪 int ¯®ª ¥ ॠ«¨§®¢ |
; |
; +----+-------------+-----------------+ |
; | in | Variable | Variable | |
; | de | name | int | |
; | x | | | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | | |
; | | | | |
; | 1 | BUFFSIZE | XXXXXXXX | |
; | | | | |
; +----+-------------+-----------------+ |
; | | | |
; |
; |
;nvtable db (TABLE_SIZE * NAME_LEN) dup 0 |
vtable db (TABLE_SIZE * VAR_LEN) dup 0 |
finfo sinfo |
; |
; ¯®«¨âì â ¡«¨æã ¨¬¥ ¯¥à¥¬¥ëå |
; |
nvtable db 'UIN',(VNAME_LEN - 3) dup 0 |
db 'PASS',(VNAME_LEN - 4) dup 0 |
db 'ICQIP',(VNAME_LEN - 5) dup 0 |
db ((TABLE_SIZE - 3) * VNAME_LEN) dup 0 |
; |
; ¤«ï ¨¨æ¨ «¨§ 樨 â ¡«¨æ |
; |
; |
; |
;name1 db 'UIN',(VNAME_LEN - 3) dup 0 |
;name2 db 'PASS',(VNAME_LEN - 4) dup 0 |
;name3 db 'ICQIP',(VNAME_LEN - 5) dup 0 |
; |
; ãä¥à ¤«ï ¢¢®¤ /¢ë¢®¤ |
; |
iobuff db IOBUFF_SIZE dup 0 |
; |
; ¬¥é¥¨¥ ¢ ä ©«¥ |
; |
shift dd 0 |
; |
; ¥à¥¬¥ë¥ ¤«ï åà ¥¨ï ®¬¥à®¢ |
; ᨬ¢®«®¢ ç « ¨¬¥¨ ¯¥à¥¬¥®© |
; ª®æ , à ¢®, ª®æ § 票ï |
stnpos dd 0 |
ednpos dd 0 |
eqpos dd 0 |
edvpos dd 0 |
; |
;®¬¥à áâப¨ ¤«ï ®¯à¥¤¥«¥¨ï ®è¨¡®çëå |
; |
strnum dd 0 |
; |
; ãä¥à ¤«ï ¢ë¢®¤ § £à㦥®£® ª®ä¨£ |
; |
cfgbuff db (VAR_LEN + VNAME_LEN + 8) dup 0 |
cfgbuff.len = $ - cfgbuff |
/programs/network_old/icq/trunk/proc32.inc |
---|
0,0 → 1,270 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label def \\{ match . type,def> \\\{ deflocal@proc .,label,<type \\\} \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc du [val] \\{ \common deflocal@proc .,du,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,du,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
match =label,def \{ ..tmp equ \} |
match tmp,..tmp \{ ..var def val \} |
match ,..tmp \{ label ..var val \} |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/network_old/icq/trunk/ssi.inc |
---|
0,0 → 1,413 |
; |
; |
; Ïîääåðæêà êîíòàêò ëèñòà íà ñåðâåðå |
; |
; |
; |
; Çàïîëíÿåò òàáëèöó ñ UIN |
; è îïöèîíàëüíî òàáëèöû ñ èìåíåì è äîï. èíôîé |
; |
; Èç comp.inc äëÿ îòëàäêè |
; |
; |
; Ìàññèâ ñ UIN |
; |
;UIN_LEN = 11 ; Äëèíà |
;UINS = 15 ; Êîëè÷åñòâî |
; |
;uins db UIN_LEN*UINS dup 0 |
; |
; ìàññèâ ñî ñòàòóñàìè |
; |
;stats dd UINS dup -1 |
; |
; Ìàññèâ ñ èìåíàìè |
; |
;NAME_LEN = 30 |
;names db NAME_LEN*UINS dup 0 |
; |
; Äîñòàåò èç item UIN |
; eax <- óêàçàòåëü íà item |
; Ïðîïóñêàåò ãðóïïû |
; |
ssi_get_uin: |
push eax |
push ebx |
push ecx |
push edx |
; |
; Ïðîâåðÿåì ItemID |
; |
xor ebx, ebx |
mov bl, [eax + 1] ; Length of the item name |
mov bh, [eax] ; |
;push ebx |
;mov ebx, 128 |
;call print_mem |
;pop ebx |
;; FIXIT Ðàçóìíåå ïðîâåðÿòü ôëàãè |
;; Åñëè äëèíà ñòðîêè = 0 |
;; ïðîïóñêàåì item |
;cmp ebx, 0 |
;jz ssi_get_end |
;; |
;;data_debug 'Item name len', ebx |
;;+ñìåùåíèå äî ItemID |
;;xor ecx, ecx |
;;mov ch, [eax + ebx + 4] |
;;mov cl, [eax + ebx + 5] ; Item ID# |
;;cmp ecx, 0 |
;;jz ssi_get_end |
; |
; Ïðîâåðÿåì ôëàãè, îáðàáàòûâàåì òîëüêî çàïèñè UIN |
; |
xor ecx, ecx |
mov ch, [eax + ebx + 6] |
mov cl, [eax + ebx + 7] |
cmp ecx, 0 ; 0x0000 Buddy record (name: uin for ICQ and screenname for AIM) |
jz ssi_uin |
; debug |
; |
lea eax, [eax + ebx + 6] |
mov ebx, 2 |
call print_mem |
jmp ssi_get_end |
ssi_uin: |
; |
; Êîïèðóåì UIN â òàáëèöó |
; |
mov ecx, ebx ; Äëèíà ñòðîêè |
lea eax, [eax + 2] |
mov edx, [uin_ind] |
cmp edx, UINS |
jnb ssi_get_end ;Íåò ñâîáîäíîãî ìåñòà â òàáëèöå UIN |
imul edx, UIN_LEN |
mov ebx, uins |
lea ebx, [ebx + edx] |
call strcpy |
inc [uin_ind] |
;debug |
;mov eax, ebx |
;xor ebx, ebx |
;call writemsg |
; |
ssi_get_end: |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
; |
; eax <- óêàçàòåëü íà item |
; âîçâðàùàåò â eax óêàçàòåëü íà ñëåäóþùèé item |
; |
; |
ssi_next_item: |
push ebx |
push ecx |
xor ebx, ebx |
mov bl, [eax + 1] ; äëèíà UIN |
mov bh, [eax] ; |
xor ecx, ecx |
mov cl, [eax + ebx + 9] ; Äëèíà äîïîëíèòåëüíûõ äàííûõ |
mov ch, [eax + ebx + 8] ; |
add ebx, ecx |
add ebx, 10 ;+Äëèíà çàãîëîâêà |
lea eax, [eax + ebx] |
pop ecx |
pop ebx |
ret |
; |
; eax <- óêàçàòåëü íà tlv |
; âîçâðàùàåò â eax óêàçàòåëü íà ñëåä tlv |
; |
macro get_next_tlv { |
push ebx |
xor ebx, ebx |
mov bl, [eax + 3] |
mov bh, [eax + 2] |
; + ðàçìåð çàãîëîâêà |
lea ebx, [ebx + 4] |
lea eax, [eax + ebx] |
pop ebx |
} |
; |
; Èùåò â additional èìÿ è äð. ñâåäåíèÿ |
; eax <- óêàçàòåëü íà item |
; |
ssi_get_add: |
push eax |
push ebx |
push ecx |
push edx |
push esi |
;mov ebx, 128 |
;call print_mem |
xor ebx, ebx |
mov bl, [eax + 1] ; Length of the item name |
mov bh, [eax] ; |
;;cmp ebx, 0 ; Åñëè äëèíà èìåíè = 0 |
;;jz ssi_all_tlv ; Íåò ñìûñëà îáðàáàòûâàòü |
;;+ñìåùåíèå äî ItemID |
;;xor ecx, ecx |
;;mov ch, [eax + ebx + 4] |
;;mov cl, [eax + ebx + 5] ; Item ID# |
; |
;;cmp ecx, 0 ; Ãðóïïû ïîêà íå îáðàáàòûâàþòñÿ |
;;jz ssi_all_tlv ; |
; |
; Ïðîâåðÿåì ôëàãè, îáðàáàòûâàåì òîëüêî çàïèñè UIN |
; |
xor ecx, ecx |
mov ch, [eax + ebx + 6] |
mov cl, [eax + ebx + 7] |
cmp ecx, 0 ; 0x0000 Buddy record (name: uin for ICQ and screenname for AIM) |
jnz ssi_all_tlv |
xor edx, edx |
mov dl, [eax + ebx + 9] ; |
mov dh, [eax + ebx + 8] ; Length of the additional data |
lea eax, [eax + ebx + 10] ; eax óêàçàòåëü íà ïåðâûé tlv |
;FIXME : Iservd íå ïðèñûëàåò additional - ïîêà íå ìîãó îòëàäèòü |
;debug |
;push ebx |
;mov ebx, edx |
;data_debug 'length additional data', ebx |
;call print_mem |
;pop ebx |
; |
xor esi, esi |
ssi_tlv_process: |
cmp esi, edx ; |
jnb ssi_all_tlv ; additional çàêîí÷èëîñü |
xor ecx, ecx |
mov cl, [eax + 3] ; |
mov ch, [eax + 2] ; TLV.Length |
xor ebx, ebx |
mov bl, [eax + 1] ; TLV.Type |
mov bh, [eax] ; |
cmp bx, 0x0131 ;Èìÿ ïîëüçîâàòåëÿ |
jz ssi_name |
cmp bx, 0x0066 ;Îæèäàåì àâòîðèçàöèè |
jz ssi_auth_wait |
jmp ssi_next_tlv |
ssi_auth_wait: |
; |
; |
; |
jmp ssi_next_tlv |
ssi_name: |
; |
; Ñêîïèðîâàòü èìÿ â ìàññèâ |
; |
push eax |
push ecx |
mov ebx, [name_ind] |
cmp ebx, UINS |
jnb ssi_name_end ;Íåò ìåñòà â òàáëèöå |
lea eax, [eax + 4] ;Óêàçàòåëü íà ñòðîêó (Ïðèáàâëÿåì ðàçìåð çàãîëîâêà TLV) |
imul ebx, NAME_LEN |
lea ebx, [names + ebx] |
cmp ecx, NAME_LEN - 1 ; Åñëè èìÿ äëèííåå ïîëÿ â òàáëèöå |
jna @f |
mov ecx, NAME_LEN - 1 |
@@: |
call strcpy |
;; FIXIT |
;; Ïåðåêîäèðîâêà èìåíè |
;; |
;;mov eax, ebx |
;;call win2dos |
; |
;debug |
;push eax |
;push ebx |
;mov eax, ebx |
;xor ebx, ebx |
;call writemsg |
;pop ebx |
;pop eax |
; |
; |
inc [name_ind] |
pop ecx |
pop eax |
ssi_next_tlv: |
lea ecx, [ecx + 4] ; Äëèíà äàííûõ tlv + äëèíà çàãîëîâêà |
add esi, ecx |
get_next_tlv |
jmp ssi_tlv_process |
ssi_name_end: |
pop ecx |
pop eax |
ssi_all_tlv: |
pop esi |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
; |
; |
; Îáðàáîòêà êîíòàêò ëèñòà, ïðèøåäøåãî îò ñåðâåðà |
; |
; â eax <- óêàçàòåëü íà äàííûå â ïàêåòå SNAC(13,06) |
ssi_process_data: |
push eax |
push ebx |
push ecx |
push edx |
; |
; Ïðîâåðèòü âåðñèþ ïðîòîêîëà |
; |
xor ebx, ebx |
mov bl, [eax] |
cmp bl, 0 |
jnz ssi_bad_prot |
; |
;â ebx - êîëè÷åñòâî items |
mov bl, [eax + 2] |
mov bh, [eax + 1] |
; |
data_debug 'SSI items:', ebx |
lea eax, [eax + 3] ; Óñòàíîâèòü eax íà ñïèñîê items |
xor ecx, ecx ; Ñ÷åò÷èê items |
ssi_next_uin: |
cmp ecx, ebx |
jnb ssi_all_items |
call ssi_get_uin |
call ssi_get_add |
call ssi_next_item |
inc ecx |
jmp ssi_next_uin |
ssi_bad_prot: |
write_debug "ERR: SSI protocol version mismatch" |
ssi_all_items: |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
/programs/network_old/icq/trunk/ssi_data.inc |
---|
0,0 → 1,5 |
; |
; Èíäåêñ â ìàññèâå UINS |
; |
uin_ind dd 0 |
name_ind dd 0 |
/programs/network_old/icq/trunk/st_red.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/network_old/icq/trunk/struct.inc |
---|
0,0 → 1,180 |
; Macroinstructions for defining data structures |
macro struct name |
{ fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \} |
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \} |
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \} |
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \} |
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \} |
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \} |
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \} |
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
macro db [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,db,<val> \} |
macro dw [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dw,<val> \} |
macro du [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,du,<val> \} |
macro dd [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dd,<val> \} |
macro dp [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dp,<val> \} |
macro dq [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dq,<val> \} |
macro dt [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dt,<val> \} |
macro rb count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
macro rw count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
macro rd count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
macro rp count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
macro rq count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
macro rt count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} |
virtual at 0 } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
fields@\\#name equ fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
if $ |
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label . |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,name,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at 0 |
forward |
if ~ field eq . |
virtual at 0 |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
if sizeof.#parent#field > $ |
rb sizeof.#parent#field - $ |
end if |
else if sizeof.#type > $ |
rb sizeof.#type - $ |
end if |
common |
sizeof.#name = $ |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at 0 |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
rb sizeof.#type |
end if |
local value |
common |
sizeof.#name = $ |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} } |
/programs/network_old/icq/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ki.asm ki |
@erase lang.inc |
@pause |
/programs/network_old/icq/trunk/2000.inc |
---|
0,0 → 1,160 |
; constants |
FLAP_HEAD_SIZE = 6 |
SNAC_HEAD_SIZE = 10 |
;AUTH_MESSAGE = 0008h |
;USER_ADDED_MESS = 000Ch |
;AUTH_REQ_MESS = 0006h |
;URL_MESS = 0004h |
;WEB_MESS = 000dh |
;EMAIL_MESS = 000eh |
;MASS_MESS_MASK = 8000h |
;MRURL_MESS = 8004h |
;NORM_MESS = 0001h |
;MRNORM_MESS = 8001h |
;CONTACT_MESS = 0013h |
;MRCONTACT_MESS = 8013h |
; |
; |
; |
;CAP_PRECAP = "\x09\x46\x13" |
;CAP_PRERTF = "\x97\xb1\x27" |
;CAP_POSCAP = "\x4c\x7f\x11\xd1\x82\x22\x44\x45\x53\x54\x00\x00" |
;CAP_POSRTF = "\x24\x3c\x43\x34\xad\x22\xd6\xab\xf7\x3f\x14\x92" |
; |
;Fingerprinting Capabilities |
; |
;CAP_M2001 = "\x2e\x7a\x64" "\x75" "\xfa\xdf\x4d\xc8\x88\x6f\xea\x35\x95\xfd\xb6\xdf" |
;CAP_M2001_2 = "\xa0\xe9\x3f" "\x37" "\x4f\xe9\xd3\x11\xbc\xd2\x00\x04\xac\x96\xdd\x96" |
;CAP_M2002 = "\x10\xcf\x40" "\xd1" "\x4f\xe9\xd3\x11\xbc\xd2\x00\x04\xac\x96\xdd\x96" |
;CAP_MLITE = "\x56\x3f\xc8" "\x09" "\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3" |
;CAP_SIMICQ = "\x97\xb1\x27" "\x51" "\x24\x3c\x43\x34\xad\x22\xd6\xab\xf7\x3f\x14\x48" |
;CAP_MICQ = "mICQ \xa9 R.K. \x00\x00\x00\x00" |
;CAP_TRILL_NORM = "\x97\xb1\x27" "\x51" "\x24\x3c\x43\x34\xad\x22\xd6\xab\xf7\x3f\x14\x09" |
;CAP_TRILL_CRYPT= "\xf2\xe7\xc7" "\xf4" "\xfe\xad\x4d\xfb\xb2\x35\x36\x79\x8b\xdf\x00\x00" |
;CAP_LICQ = "\x09\x49\x13" |
; |
;DC Packet Types |
; |
;PEER_INIT = 0ffh |
;PEER_INITACK = 01h |
;PEER_MSG = 02h |
;PEER_INIT2 = 03h |
;PEER_FILE_INIT = 00h |
;PEER_FILE_INIT_ACK = 01h |
;PEER_FILE_START = 02h |
;PEER_FILE_START_ACK = 03h |
;PEER_FILE_STOP = 04h |
;PEER_FILE_SPEED = 05h |
;PEER_FILE_DATA = 06h |
ICQ_PORT = 5190 |
; |
; FLAP transport |
; |
FLAP_ID = 02ah |
struc FLAP_head |
{ |
.bId db FLAP_ID ;id byte |
.bCh db ? ;channel |
.wSn dw ? ;seq number |
.wDs dw ? ;data size |
} |
; |
; Channels ID |
; |
NEW_CONNECTION = 01h |
SNAC_DATA = 02h |
FLAP_ERROR = 03h |
CLOSE_CONNECTION = 04h |
KEEP_ALIVE = 05h |
; |
; SNAC |
; |
struc SNAC_head |
{ |
.wFid dw ?; Family id |
.wSid dw ?; subtype id |
.wDf dw ?; SNAC flags |
.dRi dd ?; SNAC Request id |
} |
; |
; |
; Familes/SNACs list |
; |
GENERIC_SN = 0001h |
LOCATION_SN = 0002h |
BUDDY_LIST_SN = 0003h |
ICBM_SN = 0004h |
PRIVACY_SN = 0009h |
BUDDY_ICONS_SN = 0010h |
SSI_SN = 0013h |
AUTH_REG_SN = 0017h |
; |
; TLV |
; |
struc TLV_head |
{ |
.wTn dw ?; TLV type number |
.wLv dw ?; TLV length value |
} |
; |
; userinfo block |
; |
struc UI_head |
{ |
.bUinLength db 0 ; UIN/screenname length |
.bUin db 11 dup 0 ; string |
.wWl dw 0 ; Warning level |
.dUserClass dd 0 |
.dCreateTime dd 0 |
.dSignonTime dd 0 |
.wIdleTime dw 0 |
.dCreationTime dd 0 |
.dUserStatus dd 0 |
.dIpAddress dd 0 |
.dOnlineTime dd 0 |
} |
; |
;Roasting array |
; |
ROASTING_ARRAY db 0F3h, 026h, 081h, 0C4h, 039h, 086h, 0DBh, 092h, 071h, 0A3h, 0B9h, 0E6h, 053h, 07Ah, 095h, 07Ch |
; |
; Status flags |
; |
; |
STATUS_WEBAWARE = 0x0001 ;Status webaware flag |
STATUS_SHOWIP = 0x0002 ;Status show ip flag |
STATUS_BIRTHDAY = 0x0008 ;User birthday flag |
STATUS_WEBFRONT = 0x0020 ;User active webfront flag |
STATUS_DCDISABLED = 0x0100 ;Direct connection not supported |
STATUS_DCAUTH = 0x1000 ;Direct connection upon authorization |
STATUS_DCCONT = 0x2000 ;DC only with contact users |
; |
; Status |
; |
STATUS_ONLINE = 0x0000 ;Status is online |
STATUS_AWAY = 0x0001 ;Status is away |
STATUS_DND = 0x0002 ;Status is no not disturb (DND) |
STATUS_NA = 0x0004 ;Status is not available (N/A) |
STATUS_OCCUPIED = 0x0010 ;Status is occupied (BISY) |
STATUS_FREE4CHAT = 0x0020 ;Status is free for chat |
STATUS_INVISIBLE = 0x0100 ;Status is invisible |
/programs/network_old/icq/trunk |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network_old/icq |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/network_old/ftps/trunk/FTPS.ASM |
---|
0,0 → 1,1724 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; FTPS |
; FTP Server |
; |
; Compile with FASM for Menuet |
; |
; note: telnet == 23, ftp cmd == 21, data on 20 |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; header version |
dd START ; program start |
dd I_END ; program image size |
dd 0x170000 ; required amount of memory |
dd 0x16FFF0 ; esp = 0x16FFF0 |
dd 0, 0 ; no params, no path |
include '../../../macros.inc' |
; Various states of client connection |
USER_NONE equ 0 ; Awaiting a connection |
USER_CONNECTED equ 1 ; User just connected, prompt given |
USER_USERNAME equ 2 ; User given username |
USER_LOGGED_IN equ 3 ; User given password |
START: ; start of execution |
; Clear the screen memory |
mov eax, ' ' |
mov edi,text |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_window |
; init the receive buffer pointer |
mov [buffptr], buff |
; Init FTP server state machine |
mov [state], USER_NONE |
; Open the listening socket |
call connect |
still: |
; check connection status |
mov eax,53 |
mov ebx,6 ; Get socket status |
mov ecx,[CmdSocket] |
mcall |
mov ebx, [CmdSocketStatus] |
mov [CmdSocketStatus], eax |
cmp eax, ebx |
je waitev |
; If the socket closed by remote host, open it again. |
cmp eax, 7 |
je con |
; If socket closed by Reset, open it again |
cmp eax, 11 |
je con |
; If a user has just connected, start by outputting welcome msg |
cmp eax, 4 |
jne noc |
mov esi, loginStr0 |
mov edx, loginStr0_end - loginStr0 |
call outputStr |
mov [state], USER_CONNECTED |
jmp noc |
con: |
; Need to call disconnect, since a remote close does not fully |
; close the socket |
call disconnect |
mov eax,5 |
mov ebx,10 ; Delay for 100ms |
mcall |
call connect |
jmp noc |
noc: |
; Display the changed connected status |
call draw_window |
waitev: |
mov eax,23 ; wait here for event |
mov ebx,1 ; Delay for up to 1s |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
; any data from the socket? |
mov eax, 53 |
mov ebx, 2 ; Get # of bytes in input queue |
mov ecx, [CmdSocket] |
mcall |
test eax, eax |
jz still |
read_input: |
mov eax, 53 |
mov ebx, 3 ; Get a byte from socket in bl |
mov ecx, [CmdSocket] |
mcall |
call ftpRxCmdData ; process incoming ftp command |
; Keep processing data until there is no more to process |
mov eax, 53 |
mov ebx, 2 ; Get # of bytes in input queue |
mov ecx, [CmdSocket] |
mcall |
cmp eax, 0 |
jne read_input |
; Now redraw the text text field. |
; Probably not required, since ftp requires no |
; console i/o. |
; Leave in for now, for debugging. |
; (fall through to "red:") |
; call draw_text |
; jmp still |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; get but ignore |
mcall |
jmp still |
button: |
mov eax,17 |
mcall |
cmp ah,1 |
jne still |
; Exit button pressed, so close socket and quit |
mov eax,53 |
mov ebx,8 |
mov ecx,[CmdSocket] |
mcall |
; ... terminate program |
or eax,-1 |
mcall |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
xor eax,eax ; DRAW WINDOW |
mov ebx,100*65536+491 + 8 +15 |
mov ecx,100*65536+270 + 20 ; 20 for status bar |
mov edx,0x14000000 |
mov edi,labelt |
mcall |
; draw status bar |
mov eax, 13 |
mov ebx, 4*65536+484 + 8 +15 |
mov ecx, 270*65536 + 3 |
mov edx, 0x00557799 |
mcall |
mov esi,contlen-contt ; display connected status |
mov edx, contt |
cmp [CmdSocketStatus], 4 ; 4 is connected |
je pcon |
mov esi,discontlen-discontt |
mov edx, discontt |
pcon: |
mov eax,4 ; status text |
mov ebx,380*65536+276 |
mov ecx,0x00ffffff |
mcall |
; Draw the text on the screen, clearing it first |
; This can go when we loose debuggin info. |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
;*************************************************************************** |
; Function |
; draw_text |
; |
; Description |
; Updates the text on the screen. This is part of the debugging code |
; |
; Inputs |
; Character to add in bl |
; |
;*************************************************************************** |
draw_text: |
pusha |
mov esi,text |
mov eax,0 |
mov ebx,0 |
newletter: |
mov cl,[esi] |
cmp cl,[esi+30*80] |
jz noletter |
yesletter: |
mov [esi+30*80],cl |
; erase character |
pusha |
mov edx, 0 ; bg colour |
mov ecx, ebx |
add ecx, 26 |
shl ecx, 16 |
mov cx, 9 |
mov ebx, eax |
add ebx, 6 |
shl ebx, 16 |
mov bx, 6 |
mov eax, 13 |
mcall |
popa |
; draw character |
pusha |
mov ecx, 0x00ffffff |
push bx |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
pop bx |
add bx,26 |
mov eax,4 |
mov edx,esi |
mov esi,1 |
mcall |
popa |
noletter: |
add esi,1 |
add eax,6 |
cmp eax,80*6 |
jb newletter |
mov eax,0 |
add ebx,10 |
cmp ebx,24*10 |
jb newletter |
popa |
ret |
;*************************************************************************** |
; Function |
; ftpRxCmdData |
; |
; Description |
; Prcoesses incoming command data, calling a handler for each command. |
; Commands are built up in buff before being processed. |
; |
; Inputs |
; Character to add in bl |
; |
;*************************************************************************** |
ftpRxCmdData: |
; Quit if we are not connected |
;( This case shouldn't be necessary, but be safe ) |
mov al, [state] |
cmp al, USER_NONE |
je frcd_exit |
; Store the incoming character |
mov esi, [buffptr] |
mov [esi], bl |
inc esi |
mov [buffptr], esi |
; For debugging, show the data coming in |
pusha |
call printChar |
popa |
; Do we have an end of line? (LF) |
; if not, just exit |
cmp bl, 0x0a |
jne frcd_exit |
; OK we have a complete command. |
; Process, and send response |
; There are a number of states involved in ftp, |
; to do with logging in. |
mov al, [state] |
cmp al, USER_CONNECTED |
jne fs001 |
; This should be the username |
; TODO validate username |
; OK, username accepted - ask for password |
mov esi, loginStr1 |
mov edx, loginStr1_end - loginStr1 |
call outputStr |
mov [state], USER_USERNAME |
; init the receive buffer pointer |
mov [buffptr], buff |
jmp frcd_exit |
fs001: |
cmp al, USER_USERNAME |
jne fs002 |
; This should be the password |
; TODO validate password |
; OK, password accepted - show they are logged in |
mov esi, loginStr2 |
mov edx, loginStr2_end - loginStr2 |
call outputStr |
mov [state], USER_LOGGED_IN |
; init the receive buffer pointer |
mov [buffptr], buff |
jmp frcd_exit |
fs002: |
cmp al, USER_LOGGED_IN |
jne fs003 |
; This should be a cmd |
call findCmd |
mov eax, [cmdPtr] |
cmp eax, 0 |
je fs002b |
call [cmdPtr] |
fs002a: |
; init the receive buffer pointer |
mov [buffptr], buff |
jmp frcd_exit |
fs002b: |
; an unsupported command was entered. |
; Tell user that the command is not supported |
mov esi, unsupStr |
mov edx, unsupStr_end - unsupStr |
call outputStr |
jmp fs002a |
fs003: |
frcd_exit: |
ret |
;*************************************************************************** |
; Function |
; outputStr |
; |
; Description |
; Sends a string over the 'Command' socket |
; |
; Inputs |
; String in esi |
; Length in edx |
; |
;*************************************************************************** |
outputStr: |
push esi |
push edx |
mov eax,53 |
mov ebx,7 |
mov ecx,[CmdSocket] |
mcall |
pop edx |
pop esi |
cmp eax, 0 |
je os_exit |
; The TCP/IP transmit queue is full; Wait a bit, then retry |
pusha |
mov eax,5 |
mov ebx,1 ; Delay for up 10ms |
mcall |
popa |
jmp outputStr |
os_exit: |
ret |
;*************************************************************************** |
; Function |
; outputDataStr |
; |
; Description |
; Sends a string over the 'Data' socket |
; |
; Inputs |
; String in esi |
; Length in edx |
; |
;*************************************************************************** |
outputDataStr: |
push esi |
push edx |
mov eax,53 |
mov ebx,7 |
mov ecx,[DataSocket] |
mcall |
pop edx |
pop esi |
cmp eax, 0 |
je ods_exit |
; The TCP/IP transmit queue is full; Wait a bit, then retry |
pusha |
mov eax,5 |
mov ebx,1 ; Delay for up 10ms |
mcall |
popa |
jmp outputDataStr |
ods_exit: |
ret |
;*************************************************************************** |
; Function |
; printChar |
; |
; Description |
; Writes a character to the screen; Used to display the data coming |
; in from the user. Really only useful for debugging. |
; |
; Inputs |
; Character in bl |
; |
;*************************************************************************** |
printChar: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
putcha: |
mov eax,[pos] |
mov [eax+text],bl |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
ret |
;*************************************************************************** |
; Function |
; disconnect |
; |
; Description |
; Closes the command socket |
; |
; Inputs |
; None |
; |
;*************************************************************************** |
disconnect: |
mov eax, 53 ; Stack Interface |
mov ebx,8 ; Close TCP socket |
mov ecx,[CmdSocket] |
mcall |
ret |
;*************************************************************************** |
; Function |
; disconnectData |
; |
; Description |
; Closes the data socket |
; |
; Inputs |
; None |
; |
;*************************************************************************** |
disconnectData: |
; This delay would be better done by allowing the socket code |
; to wait for all data to pass through the stack before closing |
pusha |
mov eax,5 |
mov ebx,10 ; Delay for 100ms |
mcall |
popa |
mov eax, 53 ; Stack Interface |
mov ebx,8 ; Close TCP socket |
mov ecx,[DataSocket] |
mcall |
ret |
;*************************************************************************** |
; Function |
; connect |
; |
; Description |
; Opens the command socket |
; |
; Inputs |
; None |
; |
;*************************************************************************** |
connect: |
pusha |
mov eax, 53 ; Stack Interface |
mov ebx, 5 ; Open TCP socket |
mov esi, 0 ; No remote IP address |
mov edx, 0 ; No remote port |
mov ecx, 21 ; ftp command port id |
mov edi, 0 ; passive open |
mcall |
mov [CmdSocket], eax |
popa |
ret |
;*************************************************************************** |
; Function |
; connectData |
; |
; Description |
; Opens the data socket |
; |
; Inputs |
; None |
; |
;*************************************************************************** |
connectData: |
pusha |
mov eax, 53 ; Stack Interface |
mov ebx, 5 ; Open TCP socket |
mov esi, [DataIP] ; remote IP address |
mov edx, [DataPort] ; remote port |
mov ecx, 0 ; ftp data port id |
mov edi, 1 ; active open |
mcall |
mov [DataSocket], eax |
popa |
ret |
;*************************************************************************** |
; Function |
; findCmd |
; |
; Description |
; Scans the command string for a valid command. The command string |
; is in the global variable buff. |
; |
; Returns result in cmdPtr. This will be zero if none found |
; |
; Inputs |
; None |
; |
;*************************************************************************** |
findCmd: |
; Setup to return 'none' in cmdPtr, if we find no cmd |
mov eax, 0 |
mov [cmdPtr], eax |
cld |
mov esi, buff |
mov edi, CMDList |
fc000: |
cmp [edi], byte 0 ; Are we at the end of the CMDList? |
je fc_exit |
fc000a: |
cmpsb |
je fc_nextbyte |
; Command is different - move to the next entry in cmd table |
mov esi, buff |
fc001: |
; skip to the next command in the list |
cmp [edi], byte 0 |
je fc002 |
inc edi |
jmp fc001 |
fc002: |
add edi, 5 |
jmp fc000 |
fc_nextbyte: |
; Have we reached the end of the CMD text? |
cmp [edi], byte 0 |
je fc_got ; Yes - so we have a match |
jmp fc000a ; No - loop back |
fc_got: |
; Copy the function pointer for the selected command |
inc edi |
mov eax, [edi] |
mov [cmdPtr], eax |
fc_exit: |
ret |
;*************************************************************************** |
; Function |
; decStr2Byte |
; |
; Description |
; Converts the decimal string pointed to by esi to a byte |
; |
; Inputs |
; string ptr in esi |
; |
; Outputs |
; esi points to next character not in string |
; eax holds result ( 0..255) |
; |
;*************************************************************************** |
decStr2Byte: |
xor eax, eax |
xor ebx, ebx |
mov ecx, 3 |
dsb001: |
mov bl, [esi] |
cmp bl, '0' |
jb dsb_exit |
cmp bl, '9' |
ja dsb_exit |
imul eax, 10 |
add eax, ebx |
sub eax, '0' |
inc esi |
loop dsb001 |
dsb_exit: |
ret |
;*************************************************************************** |
; Function |
; parsePortStr |
; |
; Description |
; Converts the parameters of the PORT command, and stores them in the |
; appropriate variables. |
; |
; Inputs |
; None ( string in global variable buff ) |
; |
; Outputs |
; None |
; |
;*************************************************************************** |
parsePortStr: |
; skip past the PORT text to get the the parameters. The command format |
; is |
; PORT i,i,i,i,p,p,0x0d,0x0a |
; where i and p are decimal byte values, high byte first. |
xor eax, eax |
mov [DataIP], eax |
mov [DataPort], eax |
mov esi, buff + 4 ; Start at first space character |
pps001: |
cmp [esi], byte ' ' ; Look for first non space character |
jne pps002 |
inc esi |
jmp pps001 |
pps002: |
call decStr2Byte |
add [DataIP], eax |
ror dword [DataIP], 8 |
inc esi |
call decStr2Byte |
add [DataIP], eax |
ror dword [DataIP], 8 |
inc esi |
call decStr2Byte |
add [DataIP], eax |
ror dword [DataIP], 8 |
inc esi |
call decStr2Byte |
add [DataIP], eax |
ror dword [DataIP], 8 |
inc esi |
call decStr2Byte |
add [DataPort], eax |
shl [DataPort], 8 |
inc esi |
call decStr2Byte |
add [DataPort], eax |
ret |
;*************************************************************************** |
; Function |
; sendDir |
; |
; Description |
; Transmits the directory listing over the data connection. |
; The data connection is already open. |
; |
; Inputs |
; None |
; |
; Outputs |
; None |
; |
;*************************************************************************** |
sendDir: |
mov eax, text+0x4000 |
mov [fsize], eax |
mov ebx, dirinfoblock |
and dword [ebx+4], 0 ; start from zero block |
sd001: |
; Read the next DirBlocksPerCall (=16) blocks |
mov eax, 70 |
mcall |
; Did we read anything? |
test eax, eax |
jz @f |
cmp eax, 6 |
jnz sd_exit |
@@: |
test ebx, ebx |
jz sd_exit |
; Parse these blocks. There could be up to 16 files specified |
mov esi, text + 0x1300 + 0x20 |
sd002: |
dec ebx |
js sd004 |
push ebx |
; OK, lets parse the entry. Ignore volume entries |
test byte [esi], 8 |
jnz sd003 |
; Valid file or directory. Start to compose the string we will send |
mov edi, dirStr |
; If we have been called as a result of an NLST command, we only display |
; the filename |
cmp [buff], byte 'N' |
jz sd006 |
mov [edi], byte '-' |
test byte [esi], 10h |
jz @f |
mov [edi], byte 'd' |
@@: |
; Ok, now copy across the directory listing text that will be constant |
; ( I dont bother looking at the read only or archive bits ) |
mov ebx, tmplStr |
@@: |
inc edi |
mov al, [ebx] |
test al, al |
jz @f |
mov [edi], al |
inc ebx |
jmp @b |
@@: |
; point to the last character of the string; |
; We will write the file size here, backwards |
push edi ; Remember where the string ends |
dec edi |
; eax holds the number |
mov eax, [esi+32] |
mov ebx, 10 |
@@: |
xor edx, edx |
div ebx |
add dl, '0' |
mov [edi], dl |
dec edi |
test eax, eax |
jnz @b |
pop edi |
; now create the time & date fields |
;timeStr: db ' Jan 1 2000 ',0 |
mov al, ' ' |
stosb |
movzx eax, byte [esi+28+1] |
mov eax, dword [months + (eax-1)*4] |
stosd |
mov al, byte [esi+28] |
aam |
test ah, ah |
jz sd005a |
xchg al, ah |
add ax, '00' |
jmp sd005b |
sd005a: |
add al, '0' |
mov ah, ' ' |
sd005b: |
stosw |
mov al, ' ' |
mov ecx, 6 |
rep stosb |
push edi |
movzx eax, word [esi+28+2] |
@@: |
xor edx, edx |
div ebx |
add dl, '0' |
mov [edi], dl |
dec edi |
test eax, eax |
jnz @b |
pop edi |
inc edi |
mov al, ' ' |
stosb |
sd006: |
; ** End of copying |
; now copy the filename across |
lea ebx, [esi+40] |
@@: |
mov al, [ebx] |
inc ebx |
test al, al |
jz @f |
stosb |
jmp @b |
@@: |
terminate: |
; Now terminate the line by putting CRLF sequence in |
mov al, 0x0D |
stosb |
mov al, 0x0A |
stosb |
; Send the completed line to the user over data socket |
push esi |
push edi |
mov esi, dirStr |
mov ecx, edi |
sub ecx, esi |
mov edi, [fsize] |
cld |
rep movsb |
mov [fsize], edi |
cmp edi, text+0x4400 |
jb @f |
mov esi, text+0x4000 |
mov edx, [fsize] |
sub edx, esi |
mov [fsize], esi |
call outputDataStr |
@@: |
pop edi |
pop esi |
sd003: ; Move to next entry in the block |
pop ebx |
add esi, 304 |
jmp sd002 |
sd004: |
mov ebx, dirinfoblock |
add dword [ebx+4], DirBlocksPerCall |
jmp sd001 |
sd_exit: |
mov esi, text+0x4000 |
mov edx, [fsize] |
sub edx, esi |
call outputDataStr |
ret |
;*************************************************************************** |
; Function |
; setupFilePath |
; |
; Description |
; Copies the file name from the input request string into the |
; file descriptor |
; |
; Inputs |
; None |
; |
; Outputs |
; None |
; |
;*************************************************************************** |
setupFilePath: |
mov esi, buff + 4 ; Point to (1 before) first character of file |
; Skip any trailing spaces or / character |
sfp001: |
inc esi |
cmp [esi], byte ' ' |
je sfp001 |
cmp [esi], byte '/' |
je sfp001 |
; esi points to start of filename. |
cld |
push esi |
; Copy across the directory path '/' |
; into the fileinfoblock |
mov esi, dirpath |
mov edi, filename |
sfp003: |
movsb |
cmp [esi], byte 0 |
jne sfp003 |
mov al, '/' |
stosb |
pop esi |
; Copy across the filename |
sfp002: |
movsb |
cmp [esi], byte 0x0d |
jne sfp002 |
mov [edi], byte 0 |
ret |
;*************************************************************************** |
; Function |
; sendFile |
; |
; Description |
; Transmits the requested file over the open data socket |
; The file to send is named in the buff string |
; |
; Inputs |
; None |
; |
; Outputs |
; None |
; |
;*************************************************************************** |
sendFile: |
call setupFilePath |
; init fileblock descriptor, for file read |
mov ebx, fileinfoblock |
and dword [ebx], 0 ; read cmd |
and dword [ebx+4], 0 ; first block |
mov dword [ebx+12], 0x400 ; block size |
sf002a: |
; now read the file.. |
mov eax,70 |
mcall |
test eax, eax |
jz @f |
cmp eax, 6 |
jnz sf_exit |
@@: |
push eax |
mov esi, text + 0x1300 |
mov edx, ebx |
call outputDataStr |
pop eax |
test eax, eax |
jnz sf_exit |
; wait a bit |
mov eax, 5 |
mov ebx, 1 |
mcall |
mov ebx, fileinfoblock |
add dword [ebx+4], edx |
jmp sf002a |
sf_exit: |
ret |
;*************************************************************************** |
; Function |
; getFile |
; |
; Description |
; Receives the specified file over the open data socket |
; The file to receive is named in the buff string |
; |
; Inputs |
; None |
; |
; Outputs |
; None |
; |
;*************************************************************************** |
getFile: |
call setupFilePath |
; init fileblock descriptor, for file write |
xor eax, eax |
mov [fsize], eax ; Start filelength at 0 |
mov [fileinfoblock+4], eax ; set to 0 |
inc eax |
inc eax |
mov [fileinfoblock], eax ; write cmd |
; Read data from the socket until the socket closes |
; loop |
; loop |
; read byte from socket |
; write byte to file buffer |
; until no more bytes in socket |
; sleep 100ms |
; until socket no longer connected |
; write file to ram |
gf000: |
mov eax, 53 |
mov ebx, 2 ; Get # of bytes in input queue |
mov ecx, [DataSocket] |
mcall |
test eax, eax |
je gf_sleep |
mov eax, 53 |
mov ebx, 11 ; Get bytes from socket |
mov ecx, [DataSocket] |
mov edx, text + 0x1300 |
add edx, dword [fsize] |
xor esi, esi |
mcall ; returned data len in eax |
add dword [fsize], eax |
jmp gf000 |
gf_sleep: |
; Check to see if socket closed... |
mov eax,53 |
mov ebx,6 ; Get socket status |
mov ecx,[DataSocket] |
mcall |
cmp eax, 7 |
jne gf001 ; still open, so just sleep a bit |
; Finished, so write the file |
mov eax, [fsize] |
mov [fileinfoblock+12], eax |
mov eax,70 |
mov ebx,fileinfoblock |
mcall |
ret ; Finished |
gf001: |
; wait a bit |
mov eax,5 |
mov ebx,1 ; Delay for up 10ms |
mcall |
jmp gf000 ; try for more data |
;*************************************************************************** |
; COMMAND HANDLERS FOLLOW |
; |
; These handlers implement the functionality of each supported FTP Command |
; |
;*************************************************************************** |
cmdPWD: |
cld |
mov edi, text+0x1300 |
mov esi, curdir_1 |
mov ecx, curdir_2-curdir_1 |
rep movsb |
mov esi, [curdirptr] |
cmp [esi], byte 0 |
jne cpwd_000 |
mov al, '/' |
stosb |
jmp cpwd_001 |
cpwd_000: |
movsb |
cmp [esi], byte 0 |
jne cpwd_000 |
cpwd_001: |
mov esi, curdir_2 |
mov ecx, curdir_end-curdir_2 |
rep movsb |
; OK, show the directory name text |
mov esi, text+0x1300 |
mov edx, edi |
sub edx, esi |
call outputStr |
ret |
cmdCWD: |
lea esi, [buff+4] |
mov edi, [curdirptr] |
mov ecx, -1 |
xor eax, eax |
repne scasb |
dec edi |
cmp [esi], word '..' |
je ccwd_002 |
test [esi], byte 0xE0 |
je ccwd_000 |
push edi |
mov al, '/' |
stosb |
@@: |
movsb |
cmp [esi], byte 0xD |
jne @b |
xor al, al |
stosb |
mov eax, 70 |
mov ebx, dirinfoblock |
and dword [ebx+4], 0 |
mcall |
pop edi |
test eax, eax |
je @f |
cmp eax, 6 |
jne ccwd_000 |
@@: |
test ebx, ebx |
je ccwd_000 |
mov esi, text + 0x1300 + 0x20 |
mov al, byte [esi] |
and al, 0x18 |
cmp al, 0x10 |
jne ccwd_000 |
ccwd_ok: |
; OK, show the directory name text |
mov esi, chdir |
mov edx, chdir_end - chdir |
jmp ccwd_001 |
ccwd_002: |
dec edi |
cmp byte [edi], '/' |
je ccwd_003 |
cmp edi, [curdirptr] |
ja ccwd_002 |
jmp ccwd_ok |
ccwd_003: |
mov byte [edi], 0 |
jmp ccwd_ok |
ccwd_000: |
mov byte [edi], 0 |
; Tell user there is no such directory |
mov esi, noFileStr |
mov edx, noFileStr_end - noFileStr |
ccwd_001: |
call outputStr |
ret |
cmdQUIT: |
; The remote end will do the close; We just |
; say goodbye. |
mov esi, byeStr |
mov edx, byeStr_end - byeStr |
call outputStr |
ret |
cmdABOR: |
; Close port |
call disconnectData |
mov esi, abortStr |
mov edx, abortStr_end - abortStr |
call outputStr |
ret |
cmdPORT: |
; TODO |
; Copy the IP and port values to DataIP and DataPort |
call parsePortStr |
; Indicate the command was accepted |
mov esi, cmdOKStr |
mov edx, cmdOKStr_end - cmdOKStr |
call outputStr |
ret |
cmdnoop: |
; Indicate the command was accepted |
mov esi, cmdOKStr |
mov edx, cmdOKStr_end - cmdOKStr |
call outputStr |
ret |
cmdTYPE: |
; TODO |
; Note the type field selected - reject if needed. |
; Indicate the command was accepted |
mov esi, cmdOKStr |
mov edx, cmdOKStr_end - cmdOKStr |
call outputStr |
ret |
cmdsyst: |
; Indicate the system type |
mov esi, systStr |
mov edx, systStr_end - systStr |
call outputStr |
ret |
cmdDELE: |
call setupFilePath |
mov ebx, fileinfoblock |
mov dword [ebx], 8 |
and dword [ebx+4], 0 |
push dword [ebx+12] |
push dword [ebx+16] |
and dword [ebx+12], 0 |
and dword [ebx+16], 0 |
mov eax, 70 |
mcall |
mov ebx, fileinfoblock |
pop dword [ebx+16] |
pop dword [ebx+12] |
test eax, eax |
jne cmdDele_err |
mov esi, delokStr |
mov edx, delokStr_end - delokStr |
call outputStr |
jmp cmdDele_exit |
cmdDele_err: |
mov esi, noFileStr |
mov edx, noFileStr_end - noFileStr |
call outputStr |
cmdDele_exit: |
ret |
cmdNLST: |
cmdLIST: |
; Indicate the command was accepted |
mov esi, startStr |
mov edx, startStr_end - startStr |
call outputStr |
call connectData |
; Wait for socket to establish |
cl001: |
; wait a bit |
mov eax,5 |
mov ebx,10 ; Delay for up 100ms |
mcall |
; check connection status |
mov eax,53 |
mov ebx,6 ; Get socket status |
mov ecx,[DataSocket] |
mcall |
cmp eax, 4 |
jne cl001 |
; send directory listing |
call sendDir |
; Close port |
call disconnectData |
mov esi, endStr |
mov edx, endStr_end - endStr |
call outputStr |
ret |
cmdRETR: |
; Indicate the command was accepted |
mov esi, startStr |
mov edx, startStr_end - startStr |
call outputStr |
call connectData |
; Wait for socket to establish |
cr001: |
; wait a bit |
mov eax,5 |
mov ebx,10 ; Delay for up 100ms |
mcall |
; check connection status |
mov eax,53 |
mov ebx,6 ; Get socket status |
mov ecx,[DataSocket] |
mcall |
cmp eax, 4 |
jne cr001 |
; send data to remote user |
call sendFile |
; Close port |
call disconnectData |
mov esi, endStr |
mov edx, endStr_end - endStr |
call outputStr |
ret |
cmdSTOR: |
; Indicate the command was accepted |
mov esi, storStr |
mov edx, storStr_end - storStr |
call outputStr |
call connectData |
; Wait for socket to establish |
cs001: |
; wait a bit |
mov eax,5 |
mov ebx,10 ; Delay for up 100ms |
mcall |
; check connection status |
mov eax,53 |
mov ebx,6 ; Get socket status |
mov ecx,[DataSocket] |
mcall |
cmp eax, 4 |
je @f |
cmp eax, 7 |
jne cs001 |
@@: |
; get data file from remote user |
call getFile |
mov esi, endStr |
mov edx, endStr_end - endStr |
call outputStr |
; Close port |
call disconnectData |
ret |
; DATA AREA |
; This is the list of supported commands, and the function to call |
; The list end with a NULL. |
CMDList: |
db 'pwd',0 |
dd cmdPWD |
db 'PWD',0 |
dd cmdPWD |
db 'XPWD',0 |
dd cmdPWD |
db 'xpwd',0 |
dd cmdPWD |
db 'QUIT',0 |
dd cmdQUIT |
db 'quit',0 |
dd cmdQUIT |
db 'PORT',0 |
dd cmdPORT |
db 'port',0 |
dd cmdPORT |
db 'LIST',0 |
dd cmdLIST |
db 'list',0 |
dd cmdLIST |
db 'NLST',0 |
dd cmdNLST |
db 'nlst',0 |
dd cmdNLST |
db 'TYPE',0 |
dd cmdTYPE |
db 'type',0 |
dd cmdTYPE |
db 'syst',0 |
dd cmdsyst |
db 'noop',0 |
dd cmdnoop |
db 'CWD',0 |
dd cmdCWD |
db 'cwd',0 |
dd cmdCWD |
db 'RETR',0 |
dd cmdRETR |
db 'retr',0 |
dd cmdRETR |
db 'DELE',0 |
dd cmdDELE |
db 'dele',0 |
dd cmdDELE |
db 'stor',0 |
dd cmdSTOR |
db 'STOR',0 |
dd cmdSTOR |
db 'ABOR',0 |
dd cmdABOR |
db 'abor',0 |
dd cmdABOR |
db 0xff,0xf4,0xff,0xf2,'ABOR',0 |
dd cmdABOR |
db 0 |
cmdPtr dd 0 |
CmdSocket dd 0x0 |
CmdSocketStatus dd 0x0 |
DataSocket dd 0x0 |
DataSocketStatus dd 0x0 |
DataPort dd 0x00 |
DataIP dd 0x00 |
pos dd 80 * 1 |
scroll dd 1 |
dd 24 |
labelt db 'FTP Server v0.1',0 |
contt db 'Connected' |
contlen: |
discontt db 'Disconnected' |
discontlen: |
cmdOKStr: db '200 Command OK',0x0d,0x0a |
cmdOKStr_end: |
loginStr0: db '220- Menuet FTP Server v0.1',0x0d,0x0a |
db '220 Username and Password required',0x0d,0x0a |
loginStr0_end: |
loginStr1: db '331 Password now required',0x0d,0x0a |
loginStr1_end: |
loginStr2: db '230 You are now logged in.',0x0d,0x0a |
loginStr2_end: |
byeStr: db '221 Bye bye!',0x0d,0x0a |
byeStr_end: |
systStr: db '215 UNIX system type',0x0d,0x0a |
systStr_end: |
curdir_1: db '257 "' |
curdir_2: db '"',0x0d,0x0a |
curdir_end: |
chdir: db '250 CWD command successful',0x0d,0x0a |
chdir_end: |
unsupStr: db '500 Unsupported command',0x0d,0x0a |
unsupStr_end: |
noFileStr: db '550 No such file',0x0d,0x0a |
noFileStr_end: |
delokStr: db '250 DELE command successful',0x0d,0x0a |
delokStr_end: |
startStr: db '150 Here it comes...',0x0d,0x0a |
startStr_end: |
storStr: db '150 Connecting for STOR',0x0d,0x0a |
storStr_end: |
endStr: db '226 Transfer OK, Closing connection',0x0d,0x0a |
endStr_end: |
abortStr: db '225 Abort successful',0x0d,0x0a |
abortStr_end: |
; This is the buffer used for building up a directory listing line |
dirStr: times 128 db 0 |
; This is template string used in building up a directory listing line |
tmplStr: db 'rw-rw-rw- 1 0 0 ',0 |
months: |
dd 'Jan ','Feb ','Mar ','Apr ','May ','Jun ' |
dd 'Jul ','Aug ','Sep ','Oct ','Nov ','Dec ' |
fileinfoblock: |
dd 0x00 |
dd 0x00 |
dd 0x00 |
dd 0x200 ; bytes to read |
dd text + 0x1300 ; data area |
filename: times 256 db 0 |
; The following lines define data for reading a directory block |
DirBlocksPerCall = 16 |
dirinfoblock: |
dd 1 |
dd 0x00 |
dd 0x00 |
dd DirBlocksPerCall |
dd text + 0x1300 ; data area |
; The 'filename' for a directory listing |
dirpath: db '/sys' |
times 252 db 0 |
curdirptr: dd dirpath+4 |
fsize: dd 0 |
state db 0 |
buffptr dd 0 |
buff: times 256 db 0 ; Could put this after iend |
; Ram use at the end of the application: |
; text : 2400 bytes for screen memory |
; text + 0x1300 : file data area |
text: |
I_END: |
/programs/network_old/ftps/trunk/build.bat |
---|
0,0 → 1,2 |
@fasm ftps.asm ftps |
@pause |
/programs/network_old/VNCclient/logon.inc |
---|
0,0 → 1,257 |
red_logon: |
call draw_window_logon ; at first, draw the window |
still_logon: ; main cycle of application begins here |
mov eax,10 ; wait here for event |
mcall |
checkevent_logon: ; Check what event was called _logon: this will be used to return from textbox focus |
dec eax ; redraw request ? |
jz red_logon |
dec eax ; key in buffer ? |
jz key_logon |
dec eax ; button in buffer ? |
jz button_logon |
jmp still_logon |
key_logon: ; key event handler |
mov al,2 ; eax was zero so will now be 2 |
mcall ; just read it and ignore |
cmp ah,13 |
jne still_logon ; return to main loop |
ret ; enter key was pressed => return to logon |
button_logon: ; eax was zero so will now be 17 |
mov al,17 ; get id |
mcall |
cmp ah,1 ; close ? |
jz close_logon |
cmp ah,2 ; logon ? |
je connect_logon |
cmp ah,5 ; first ? |
jz dstbtn_logon |
srcbtn_logon: |
mov dword[addr],first |
jmp rk_logon |
dstbtn_logon: |
mov dword[addr],second |
rk_logon: |
mov edi,[addr] ; load the address of the string |
xor al,al ; mov al,0 ; the symbol we will search for |
mov ecx,STRLEN+1 ; length of the string (+1) |
cld ; search forward |
repne scasb ; do search now |
inc ecx ; we've found a zero or ecx became 0 |
mov eax,STRLEN+1 |
sub eax,ecx ; eax = address of <0> character |
mov [temp],eax ; position |
cmp dword[addr],dword second |
jne @f |
mov dword [passlen],eax |
@@: |
call print_text_logon |
mov edi,[addr] ; address of string |
add edi,[temp] ; cursor position |
.waitev_logon: |
mov eax,10 ; wait for event |
mcall |
cmp eax,2 ; button presed ? |
jne checkevent_logon ; a key is pressed or redraw is nessesary, goto checkevent |
mcall ; eax = 2, read button |
shr eax,8 |
cmp eax,8 |
jnz .nobs_logon ; BACKSPACE |
cmp edi,[addr] |
jz .waitev_logon |
dec edi |
mov byte[edi],0 |
cmp dword[addr],second |
jne @f |
dec [passlen] |
@@: |
call print_text_logon |
jmp .waitev_logon |
.nobs_logon: |
cmp eax,13 ; ENTER |
je still_logon |
cmp eax,192 |
jne .noclear_logon |
xor al,al |
mov edi,[addr] |
mov ecx,STRLEN |
rep stosb |
mov edi,[addr] |
call print_text_logon |
jmp .waitev_logon |
.noclear_logon: |
mov [edi],al |
cmp dword[addr],second |
jne @f |
inc [passlen] |
@@: |
call print_text_logon |
inc edi |
mov esi,[addr] |
add esi,STRLEN |
cmp esi,edi |
jnz .waitev_logon |
jmp still_logon |
; print strings (source & destination) |
print_text_logon: |
pusha |
mov eax, 8 |
mov ebx, 105*65536+200 |
mov ecx, 31*65536+13 |
mov edx, 4 |
mov esi, 0xEBEBEB |
mcall |
cmp byte[mode],0 |
je @f |
mov ecx, 49*65536+12 |
inc edx |
mcall |
@@: |
mov eax, 4 ; function 4 _logon: write text to window |
mov ebx, 107*65536+34 ; [x start] *65536 + [y start] |
xor ecx, ecx ; color of text RRGGBB |
mov edx, first ; pointer to text beginning |
mov esi, STRLEN ; text length |
mcall |
cmp byte[mode],0 |
je dont_draw_pass |
add ebx,16 |
mov edi,[passlen] |
@@: |
cmp edi,0 |
jle dont_draw_pass |
dec edi |
mov edx, passchar |
mov esi, 1 |
mcall |
add ebx,6*65536 |
jmp @r |
dont_draw_pass: |
popa |
ret |
close_logon: |
or eax,-1 |
mcall |
connect_logon: |
ret |
draw_window_logon: |
mcall 12, 1 ; start window draw |
pusha |
; DRAW WINDOW |
xor eax, eax ; function 0 _logon: define and draw window |
mov ebx, 160*65536+330 ; [x start] *65536 + [x size] |
mov ecx, 160*65536+100 ; [y start] *65536 + [y size] |
mov edx, 0x13DDDDDD ; color of work area RRGGBB |
mov edi, title ; WINDOW LABEL |
mcall |
mov eax, 8 ; LOGON BUTTON |
mov ebx, 220*65536+85 |
mov ecx, 63*65536+16 |
mov edx, 2 |
mov esi, 0xCCCCCC |
mcall |
call print_text_logon |
cmp byte[mode], 0 |
je servermode_ |
mov eax, 4 ; function 4 write text to window |
mov ebx, 25*65536+33 ; [x start] *65536 + [y start] |
xor ecx, ecx |
mov edx, userstr ; pointer to text beginning |
mov esi, passstr-userstr ; text length |
mcall |
add bl,19 |
mov edx, passstr ; pointer to text beginning |
mov esi, connect-passstr ; text length |
mcall |
jmp drawtherest_ |
servermode_: |
mov eax, 4 ; function 4 write text to window |
mov ebx, 25*65536+33 ; [x start] *65536 + [y start] |
xor ecx, ecx |
mov edx, serverstr ; pointer to text beginning |
mov esi, userstr-serverstr ; text length |
mcall |
drawtherest_: |
mov ebx, 240*65536+67 ; [x start] *65536 + [y start] |
mov edx, connect ; pointer to text beginning |
mov esi, connect_e-connect ; text length |
mcall |
popa |
inc ebx |
mcall |
ret |
; DATA AREA |
title db 'Kolibrios VNC client by HIDNPLAYR',0 |
first: db '192.168.1.5' |
rb STRLEN |
second: rb STRLEN |
passchar db '*' |
passlen dd 0 |
addr dd 0 |
temp dd 0 |
mode db 0 ; 0 = connection details, 1 = authentication |
serverstr: db 'server:' |
userstr: db 'username:' |
passstr: db 'password:' |
connect: db 'connect !' |
connect_e: |
I_END_logon: |
/programs/network_old/VNCclient/VNCclient.asm |
---|
0,0 → 1,330 |
; |
; |
; VNC Client for kolibrios by hidnplayr |
; |
; |
; WORK IN PROGRESS... |
; |
; FEEL FREE TO CONTRIBUTE ! |
; |
; hidnplayr@gmail.com |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
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 |
dd 0x0 , 0x0 ; I_Param , I_Icon |
__DEBUG__ equ 1 |
__DEBUG_LEVEL__ equ 1 |
STRLEN = 64 ; password and server max length |
xpos = 4 ; coordinates of image |
ypos = 22 ; |
TIMEOUT = 60 ; timeout in seconds |
BUFFER = 1500 ; Buffer size for DNS |
include '..\..\macros.inc' |
include 'fdo.inc' |
include 'ETH.INC' |
include 'logon.inc' |
include 'raw.inc' |
include 'copyrect.inc' |
include 'thread.inc' |
START: ; start of execution |
call red_logon |
mov eax,40 ; Report events |
mov ebx,00000000b ; Only Stack |
mcall |
mov eax,67 ; resize the window (hide it) |
xor ebx,ebx |
mov ecx,ebx |
mov edx,ebx |
mov esi,ebx |
mcall |
mov eax,51 |
mov ebx,1 |
mov ecx,thread_start |
mov edx,thread_stack |
mcall |
DEBUGF 1,'Thread created: %u\n',eax |
@@: |
mov eax,5 |
mov ebx,10 |
mcall |
cmp byte[thread_ready],0 |
je @r |
mov eax,40 ; report events |
mov ebx,100111b ; mouse, button, key, redraw |
mcall |
mov eax,67 ; resize the window |
mov ebx,10 |
mov ecx,10 |
mov edx,dword[framebuffer] |
bswap edx |
movzx esi,dx |
shr edx,16 |
add edx,2*xpos |
add esi,ypos+xpos |
mcall |
mainloop: |
eth.socket_status [socket],eax |
cmp al,TCB_CLOSE_WAIT |
je close |
mov eax,23 ; wait for event with timeout |
mov ebx,50 ; 0,5 s |
mcall |
cmp eax,1 |
je redraw |
cmp eax,2 ; key |
je key |
cmp eax,3 ; button |
je button |
cmp eax,6 ; mouse |
je mouse |
call drawbuffer |
jmp mainloop |
key: |
DEBUGF 1,'Sending key event\n' |
mov eax,2 |
mcall |
mov byte[keyevent.key+3],ah |
eth.write_tcp [socket],8,keyevent |
jmp mainloop |
mouse: |
DEBUGF 1,'Sending mouse event\n' |
mov eax,37 |
mov ebx,1 |
mcall |
sub eax,xpos*65536+ypos |
bswap eax |
mov word[pointerevent.x],ax |
shr eax,16 |
mov word[pointerevent.y],ax |
mov eax,37 |
mov ebx,2 |
mcall |
test al,00000010b ; test if right button was pressed (bit 1 in kolibri) |
jz @f |
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 |
@@: |
mov byte[pointerevent.mask],al |
eth.write_tcp [socket],6,pointerevent |
jmp mainloop |
redraw: |
DEBUGF 1,'Drawing window\n' |
mcall 12, 1 |
mov eax,0 ; draw window |
mov ebx,dword[framebuffer] |
bswap ebx |
movzx ecx,bx |
shr ebx,16 |
add ebx,2*xpos |
add ecx,ypos+xpos |
mov edx,0xffffff |
mcall |
mov eax,4 ; label |
mov ebx,9*65536+8 |
mov ecx,0x10ffffff |
mov edx,name |
mov esi,[name_length] |
bswap esi |
mcall |
call drawbuffer |
mcall 12, 2 |
jmp mainloop |
drawbuffer: |
mov eax,7 |
mov ebx,framebuffer_data |
mov ecx,dword[screen] |
mov edx,xpos*65536+ypos |
mcall |
ret |
button: ; button |
mov eax,17 ; get id |
mcall |
close: |
call read_data |
; eth.close_tcp [socket] ; We're done, close the socket ;;; BUG WHEN CLOSING SOCKET !! |
DEBUGF 1,'Socket closed\n' |
mov eax,-1 |
mcall |
no_rfb: |
DEBUGF 1,'This is no vnc server!\n' |
jmp close |
invalid_security: |
DEBUGF 1,'Security error: %s\n',receive_buffer+5 |
jmp close |
; DATA AREA |
include_debug_strings ; ALWAYS present in data section |
handshake db 'RFB 003.003',0x0a |
shared db 0 |
beep db 0x85,0x25,0x85,0x40,0 |
pixel_format32 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 32 ; bits per pixel |
.depth db 32 ; 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_shif db 0 ; red-shift |
.green_shift db 8 ; green-shift |
.blue_shift db 16 ; blue-shift |
rb 3 ; padding |
pixel_format16 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 16 ; bits per pixel |
.depth db 15 ; depth |
.big_endian db 0 ; big-endian flag |
.true_color db 1 ; true-colour flag |
.red_max db 0,31 ; red-max |
.green_max db 0,31 ; green-max |
.blue_max db 0,31 ; blue-max |
.red_shif db 0 ; red-shift |
.green_shift db 5 ; green-shift |
.blue_shift db 10 ; blue-shift |
rb 3 ; padding |
pixel_format8 db 0 ; setPixelformat |
rb 3 ; padding |
.bpp db 8 ; bits per pixel |
.depth db 6 ; depth |
.big_endian db 0 ; big-endian flag |
.true_color db 1 ; true-colour flag |
.red_max db 0,3 ; red-max |
.green_max db 0,3 ; green-max |
.blue_max db 0,3 ; blue-max |
.red_shif db 0 ; red-shift |
.green_shift db 2 ; green-shift |
.blue_shift db 4 ; blue-shift |
rb 3 ; padding |
encodings db 2 ; setEncodings |
rb 1 ; padding |
db 1,0 ; number of encodings |
db 0,0,0,0 ; raw encoding (DWORD, Big endian order) |
db 1,0,0,0 ; Copyrect encoding |
fbur db 3 ; frame buffer update request |
.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 |
I_END: |
framebuffer: |
.width dw ? |
.height dw ? |
pixelformat: |
.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 |
name_length dd ? |
name rb 256 |
server_ip dd 0 |
server_port dd 0 |
socket dd 0 |
datapointer dd 0 |
frame: |
.width dw 0 |
.height dw 0 |
.x dw 0 |
.y dw 0 |
screen: |
.height dw 0 |
.width dw 0 |
thread_ready db 0 |
dnsMsg: |
receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
framebuffer_data rb 1024*768*3 ; framebuffer |
thread_stack rb 0x1000 |
IM_END: |
/programs/network_old/VNCclient/ETH.INC |
---|
0,0 → 1,671 |
; |
; ETH.INC |
; |
; made by hidnplayr (hidnplayr@gmail.com) for KolibriOS |
; |
; The given code before every macro is only a simple example |
; |
; |
; HISTORY |
; |
; v1.0: 18 august 2006 original release |
; v1.1: december 2006 bugfixes and improvements |
; |
macro mov arg1,arg2 { |
if arg1 eq arg2 |
else |
mov arg1,arg2 |
end if |
} |
TCB_LISTEN = 1 |
TCB_SYN_SENT = 2 |
TCB_SYN_RECEIVED = 3 |
TCB_ESTABLISHED = 4 |
TCB_FIN_WAIT_1 = 5 |
TCB_FIN_WAIT_2 = 6 |
TCB_CLOSE_WAIT = 7 |
TCB_CLOSING = 8 |
TCB_LAST_ASK = 9 |
TCB_TIME_WAIT = 10 |
TCB_CLOSED = 11 |
PASSIVE = 0 |
ACTIVE = 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; eth.get_IP eax |
; |
; gets the current IP that is defined in Stack (return in eax in this example) |
macro eth.get_IP IP { |
mov ebx,1 |
mov eax,52 |
mcall |
mov IP ,eax |
} |
; eth.get_GATEWAY eax |
; |
; gets the current GATEWAY that is defined in Stack (return in eax in this example) |
macro eth.get_GATEWAY GATEWAY { |
mov ebx,9 |
mov eax,52 |
mcall |
move GATEWAY ,eax |
} |
; eth.get_SUBNET eax |
; |
; gets the current SUBNET that is defined in Stack (return in eax in this example) |
macro eth.get_SUBNET SUBNET { |
mov ebx,10 |
mov eax,52 |
mcall |
mov SUBNET ,eax |
} |
; eth.get_DNS eax |
; |
; gets the current DNS that is defined in Stack (return in eax in this example) |
macro eth.get_DNS DNS { |
mov ebx,13 |
mov eax,52 |
mcall |
mov DNS ,eax |
} |
; eth.set_IP eax |
; |
; set a new IP in stack (input in eax in this example) |
macro eth.set_IP IP { |
mov ecx,IP |
mov ebx,3 |
mov eax,52 |
mcall |
} |
; eth.set_GATEWAY eax |
; |
; set a new GATEWAY in stack (input in eax in this example) |
macro eth.set_GATEWAY GATEWAY { |
mov ecx,GATEWAY |
mov ebx,11 |
mov eax,52 |
mcall |
} |
; eth.set_SUBNET eax |
; |
; set a new SUBNET in stack (input in eax in this example) |
macro eth.set_SUBNET SUBNET { |
mov ecx,SUBNET |
mov ebx,12 |
mov eax,52 |
mcall |
} |
; eth.set_DNS eax |
; |
; set a new DNS in stack (input in eax in this example) |
macro eth.set_DNS DNS { |
mov ecx,DNS |
mov ebx,14 |
mov eax,52 |
mcall |
} |
; eth.open eax,80,ebx,[socket] |
; |
; open a socket on local port in eax to port 80 on server on ebx |
; the socketnumber will be returned in [socket] (dword) |
macro eth.open_udp local,remote,ip,socket { |
mov ecx, local |
mov edx, remote |
mov esi, ip |
mov ebx, 0 |
mov eax, 53 |
mcall |
mov socket,eax |
} |
; eth.close [socket] |
; |
; closes socket on socketnumber [socket] |
macro eth.close_udp socket { |
mov ecx, socket |
mov ebx, 1 |
mov eax, 53 |
mcall |
} |
; eth.poll [socket],eax |
; |
; polls [socket] for data |
; eax = 0 when there is data |
macro eth.poll socket { |
mov ecx, socket |
mov ebx, 2 |
mov eax, 53 |
mcall |
} |
; eth.read_byte [socket], bl |
; |
; reads a byte from the socket and returns in bl |
macro eth.read_byte socket, result { |
mov ecx, socket |
mov ebx, 3 |
mov eax, 53 |
mcall |
mov result,bl |
} |
; eth.read_byte [socket], bl |
; |
; reads a byte from the socket and returns in bl |
macro eth.read_packet socket, result { |
mov edx, result |
mov ecx, socket |
mov ebx, 10 |
mov eax, 53 |
mcall |
} |
; eth.write [socket],12,msg |
; msg db 'hello world!' |
; |
; send message msg to socket |
macro eth.write_udp socket,length,msg,verify { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
mov ebx, 4 |
mov eax, 53 |
mcall |
if verify eq 1 |
call verifysend |
end if |
} |
verifysend: |
test eax,eax |
jnz @f |
ret |
@@: |
pusha |
mov eax,5 |
mov ebx,100 |
mcall |
popa |
mcall |
ret |
; eth.open_tcp 80,80,eax,0,[socket] |
; |
; opens a tcp socket on port 80 to port 80 on IP eax with passive open |
; returns socket number in eax |
macro eth.open_tcp local,remote,ip,passive,socket { |
mov ecx, local |
mov edx, remote |
mov esi, ip |
mov edi, passive ; 0 = PASSIVE open |
mov ebx, 5 |
mov eax, 53 |
mcall |
mov socket,eax |
} |
; eth.socket_status [socket],eax |
; |
; returns socket status in eax |
macro eth.socket_status socket,result { |
mov ecx, socket |
mov ebx, 6 |
mov eax, 53 |
mcall |
mov result,eax |
} |
; eth.write_tcp [socket],12,msg |
; |
; msg db 'hello world!' |
; |
; send message to TCP socket |
macro eth.write_tcp socket,length,msg,verify { |
mov ecx, socket |
mov edx, length |
mov esi, msg |
mov ebx, 7 |
mov eax, 53 |
mcall |
if verify eq 1 |
call verifysend |
end if |
} |
; eth.close_tcp [socket] |
; |
; closes tcp socket [socket] |
macro eth.close_tcp socket { |
mov ecx, socket |
mov ebx, 8 |
mov eax, 53 |
mcall |
} |
; eth.check_port 165,eax |
; |
; checks if port 165 is used |
; return is 0 when port is free |
macro eth.check_port port,result { |
mov ecx, port |
mov ebx, 9 |
mov eax, 53 |
mcall |
mov result,eax |
} |
; eth.status eax |
; |
; returns socket status in eax |
macro eth.status status { |
mov ebx, 255 |
mov ecx, 6 |
mov eax, 53 |
mcall |
mov status,eax |
} |
; eth.search 165,edx |
; |
; searches a free local port starting from 166 (165 + 1 !) |
; returns in edx |
macro eth.search_port port,result { |
mov edx,port |
@@: |
inc edx |
eth.check_port edx,eax |
cmp eax,0 |
je @r |
mov result,edx |
} |
; eth.read_data [socket],buffer,512 |
; buffer rb 512 |
; socket dd ? |
; |
; reads data from socket into a buffer, stops when there is no more data or buffer is full. |
macro eth.read_data socket,dest,endptr,bufferl { |
local .getdata,.loop,.end |
mov eax, dest |
mov endptr, eax |
; we have data - this will be the response |
.getdata: |
mov eax,endptr |
cmp eax,bufferl |
jg .end |
eth.read_byte socket,bl |
; Store the data in the response buffer |
mov eax, endptr |
mov [eax], bl |
inc dword endptr |
eth.poll socket |
cmp eax,0 |
jne .getdata ; yes, so get it |
; now we are going to wait 30 times 10 ms (300ms) |
mov edx,0 |
.loop: |
mov eax,5 |
mov ebx,1 |
mcall |
eth.poll socket |
cmp eax, 0 |
jne .getdata ; yes, so get it |
inc edx |
cmp edx,100 |
jl .loop |
.end: |
} |
; eth.wait_for_data [socket],60,abort |
; eth.read_data .... |
; abort: |
; |
; Waits for data with timeout |
macro eth.wait_for_data socket,TIMEOUT,abort { |
mov edx,TIMEOUT |
@@: |
eth.poll socket |
cmp eax,0 |
jne @f |
dec edx |
jz abort |
mov eax,5 ; wait here for event |
mov ebx,10 |
mcall |
jmp @r |
@@: |
} |
; The function 'resolve' resolves the address in edx and puts the resulting IP in eax. |
; When the input is an IP-adress, the function will output this IP in eax. |
; If something goes wrong, the result in eax should be 0 |
; |
; example: |
; |
; resolve query1,IP,PORT |
; resolve '192.168.0.1',IP,PORT |
; resolve query2,IP,PORT |
; |
; query1 db 'www.google.com',0 |
; query2 db '49.78.84.45',0 |
; IP dd ? |
; PORT dd ? |
macro resolve query,result { |
if query eqtype 0 |
mov edx,query |
else |
local ..string, ..label |
jmp ..label |
..string db query,0 |
..label: |
mov edx,..string |
end if |
call __resolve |
mov result,eax |
} |
if used __resolve |
__resolve: |
if __DEBUG__ eq 1 |
DEBUGF 1,'Resolving started\n' |
end if |
; This code validates if the query is an IP containing 4 numbers and 3 dots |
push edx ; push edx (query address) onto stack |
xor al, al ; make al (dot count) zero |
@@: |
cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP |
jl no_IP ; |
cmp byte[edx],'9' ; |
jg no_IP ; |
inc edx ; the byte was a number, so lets check the next byte |
cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) |
jz @f ; jump to next @@ then |
cmp byte[edx],':' |
jz @f |
cmp byte[edx],'.' ; is this byte a dot? |
jne @r ; if not, jump to previous @@ |
inc al ; the byte was a dot so increment al(dot count) |
inc edx ; next byte |
jmp @r ; lets check for numbers again (jump to previous @@) |
@@: ; we reach this when end of query reached |
cmp al,3 ; check if there where 3 dots |
jnz no_IP ; if not, jump to no_IP (this is where the DNS will take over) |
; The following code will convert this IP into a dword and output it in eax |
; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1 |
pop esi ; edx (query address) was pushed onto stack and is now popped in esi |
xor edx, edx ; result |
xor eax, eax ; current character |
xor ebx, ebx ; current byte |
.outer_loop: |
shl edx, 8 |
add edx, ebx |
xor ebx, ebx |
.inner_loop: |
lodsb |
test eax, eax |
jz .finish |
cmp al, '.' |
jz .outer_loop |
sub eax, '0' |
imul ebx, 10 |
add ebx, eax |
jmp .inner_loop |
.finish: |
shl edx, 8 |
add edx, ebx |
bswap edx ; we want little endian order |
mov eax, edx |
ret |
no_IP: |
pop edx |
; The query is not an IP address, we will send the query to a DNS server and hope for answer ;) |
if __DEBUG__ eq 1 |
DEBUGF 1,'The query is no ip, Building request string from:%u\n',edx |
end if |
; Build the request string |
mov eax, 0x00010100 |
mov [dnsMsg], eax |
mov eax, 0x00000100 |
mov [dnsMsg+4], eax |
mov eax, 0x00000000 |
mov [dnsMsg+8], eax |
; domain name goes in at dnsMsg+12 |
mov esi, dnsMsg + 12 ; location of label length |
mov edi, dnsMsg + 13 ; label start |
mov ecx, 12 ; total string length so far |
td002: |
mov [esi], byte 0 |
inc ecx |
td0021: |
mov al, [edx] |
cmp al, 0 |
je td001 ; we have finished the string translation |
cmp al, '.' |
je td004 ; we have finished the label |
inc byte [esi] |
inc ecx |
mov [edi], al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi, edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi], byte 0 |
inc ecx |
inc edi |
mov [edi], dword 0x01000100 |
add ecx, 4 |
mov [dnsMsgLen], ecx ; We'll need the length of the message when we send it |
; Now, lets send this and wait for an answer |
eth.search_port 1024,edx ; Find a free port starting from 1025 and store in edx |
eth.get_DNS esi ; Read DNS IP from stack into esi |
eth.open_udp edx,53,esi,[socketNum] ; First, open socket |
if __DEBUG__ eq 1 |
DEBUGF 1,'Socket opened: %u (port %u)\n',[socketNum],ecx |
end if |
eth.write_udp [socketNum],[dnsMsgLen],dnsMsg ; Write to socket ( request DNS lookup ) |
if __DEBUG__ eq 1 |
DEBUGF 1,'Data written, length:%u offset:%u\n',[dnsMsgLen],dnsMsg |
DEBUGF 1,'Waiting for data: (timeout is %us)\n',TIMEOUT |
end if |
eth.wait_for_data [socketNum],TIMEOUT,abort ; Now, we wait for data from remote |
eth.read_data [socketNum],dnsMsg,[dnsMsgLen],dnsMsg+BUFFER ; Read the data into the buffer |
if __DEBUG__ eq 1 |
DEBUGF 1,'Data received, offset:%u buffer size:%u length:%u\n',dnsMsg,BUFFER,esi-dnsMsg |
end if |
eth.close_udp [socketNum] ; We're done, close the socket |
if __DEBUG__ eq 1 |
DEBUGF 1,'Closed Socket\n' |
end if |
; Now parse the message to get the host IP. Man, this is complicated. It's described in RFC 1035 |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg, the end of the buffer is pointed to by [dnsMsgLen] |
mov esi, dnsMsg |
mov al, [esi+2] ; Is this a response to my question? |
and al, 0x80 |
cmp al, 0x80 |
jne abort |
if __DEBUG__ eq 1 |
DEBUGF 1,'It was a response to my question\n' |
end if |
mov al, [esi+3] ; Were there any errors? |
and al, 0x0F |
cmp al, 0x00 |
jne abort |
if __DEBUG__ eq 1 |
DEBUGF 1,'There were no errors\n' |
end if |
mov ax, [esi+6] ; Is there ( at least 1 ) answer? |
cmp ax, 0x00 |
je abort |
; Header validated. Scan through and get my answer |
add esi, 12 ; Skip to the question field |
call skipName ; Skip through the question field |
add esi, 4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax, [esi] |
cmp ax, 0x0100 ; Is this the IP address answer? |
jne ctr002c |
add esi, 10 ; Yes! Point eax to the first byte of the IP address |
mov eax,[esi] |
ret |
ctr002c: ; Skip through the answer, move to the next |
add esi, 8 |
movzx eax, byte [esi+1] |
mov ah, [esi] |
add esi, eax |
add esi, 2 |
cmp esi, [dnsMsgLen] ; Have we reached the end of the msg? This is an error condition, should not happen |
jl ctr002z ; Check next answer |
abort: |
if __DEBUG__ eq 1 |
DEBUGF 1,'Something went wrong, aborting\n' |
end if |
xor eax,eax |
ret |
skipName: |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
mov al, [esi] |
cmp al, 0 |
je sn_exit |
and al, 0xc0 |
cmp al, 0xc0 |
je sn001 |
movzx eax, byte [esi] |
inc eax |
add esi, eax |
jmp skipName |
sn001: |
add esi, 2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
if ~defined dnsMsg |
dnsMsg: rb BUFFER |
end if |
end if |
/programs/network_old/VNCclient/build.bat |
---|
0,0 → 1,2 |
@fasm VNCclient.asm VNCclient |
@pause |
/programs/network_old/VNCclient/fdo.inc |
---|
0,0 → 1,343 |
; |
; Formatted Debug Output (FDO) |
; Copyright (c) 2005-2006, mike.dld |
; Created: 2005-01-29, Changed: 2006-07-20 |
; |
; For questions and bug reports, mail to mike.dld@gmail.com |
; |
; Available format specifiers are: %s, %d, %u, %x (with partial width support) |
; |
; to be defined: |
; __DEBUG__ equ 1 |
; __DEBUG_LEVEL__ equ 5 |
macro debug_func name { |
if used name |
name@of@func equ name |
} |
macro debug_beginf { |
align 4 |
name@of@func: |
} |
debug_endf fix end if |
macro DEBUGS _sign,[_str] { |
common |
pushf |
pushad |
local ..str,..label,is_str |
is_str = 0 |
forward |
if _str eqtype '' |
is_str = 1 |
end if |
common |
if is_str = 1 |
jmp ..label |
..str db _str,0 |
..label: |
add esp,4*8+4 |
mov edx,..str |
sub esp,4*8+4 |
call fdo_debug_outstr |
else |
mov edx,_str |
call fdo_debug_outstr |
end if |
popad |
popf |
} |
macro DEBUGD _sign,_dec { |
pushf |
pushad |
if _dec eqtype eax |
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> |
mov eax,_dec |
else if ~_dec eq eax |
if _sign = 1 |
movsx eax,_dec |
else |
movzx eax,_dec |
end if |
end if |
else if _dec eqtype 0 |
mov eax,_dec |
else |
add esp,4*8+4 |
local tp |
tp equ 0 |
match _num[_arg],_dec \{ |
if _num = 1 |
if _sign = 1 |
movsx eax,byte[_arg] |
else |
movzx eax,byte[_arg] |
end if |
else if _num = 2 |
if _sign = 1 |
movsx eax,word[_arg] |
else |
movzx eax,word[_arg] |
end if |
else |
mov eax,dword[_arg] |
end if |
tp equ 1 |
\} |
match =0 [_arg],tp _dec \{ |
mov eax,dword[_arg] |
\} |
sub esp,4*8+4 |
end if |
mov cl,_sign |
call fdo_debug_outdec |
popad |
popf |
} |
macro DEBUGH _sign,_hex { |
pushf |
pushad |
if _hex eqtype eax |
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
if ~_hex eq eax |
mov eax,_hex |
end if |
mov edx,8 |
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> |
if ~_hex eq ax |
movzx eax,_hex |
end if |
shl eax,16 |
mov edx,4 |
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> |
if ~_hex eq al |
movzx eax,_hex |
end if |
shl eax,24 |
mov edx,2 |
end if |
else if _hex eqtype 0 |
mov eax,_hex |
mov edx,8 |
else |
add esp,4*8+4 |
local tp |
tp equ 0 |
match _num[_arg],_hex \{ |
mov eax,dword[_arg] |
mov edx,_num |
tp equ 1 |
\} |
match =0 [_arg],tp _hex \{ |
mov eax,dword[_arg] |
mov edx,8 |
\} |
sub esp,4*8+4 |
end if |
call fdo_debug_outhex |
popad |
popf |
} |
;----------------------------------------------------------------------------- |
debug_func fdo_debug_outchar |
debug_beginf |
pushad |
mov cl,al |
mov ebx,1 |
mov eax,63 |
mcall |
popad |
ret |
debug_endf |
debug_func fdo_debug_outstr |
debug_beginf |
mov eax,63 |
mov ebx,1 |
.l1: mov cl,[edx] |
or cl,cl |
jz .l2 |
mcall |
inc edx |
jmp .l1 |
.l2: ret |
debug_endf |
debug_func fdo_debug_outdec |
debug_beginf |
or cl,cl |
jz @f |
or eax,eax |
jns @f |
neg eax |
push eax |
mov al,'-' |
call fdo_debug_outchar |
pop eax |
@@: push 10 |
pop ecx |
push -'0' |
.l1: xor edx,edx |
div ecx |
push edx |
test eax,eax |
jnz .l1 |
.l2: pop eax |
add al,'0' |
jz .l3 |
call fdo_debug_outchar |
jmp .l2 |
.l3: ret |
debug_endf |
debug_func fdo_debug_outhex |
__fdo_hexdigits db '0123456789ABCDEF' |
debug_beginf |
mov cl,dl |
neg cl |
add cl,8 |
shl cl,2 |
rol eax,cl |
.l1: rol eax,4 |
push eax |
and eax,0x0000000F |
mov al,[__fdo_hexdigits+eax] |
call fdo_debug_outchar |
pop eax |
dec edx |
jnz .l1 |
ret |
debug_endf |
;----------------------------------------------------------------------------- |
macro DEBUGF _level,_format,[_arg] { |
common |
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ |
local ..f1,f2,a1,a2,c1,c2,c3,..lbl |
_debug_str_ equ __debug_str_ # a1 |
a1 = 0 |
c2 = 0 |
c3 = 0 |
f2 = 0 |
repeat ..lbl-..f1 |
virtual at 0 |
db _format,0,0 |
load c1 word from %-1 |
end virtual |
if c1 = '%s' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER S,a1,0,_arg |
else if c1 = '%x' |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER H,a1,0,_arg |
else if c1 = '%d' | c1 = '%u' |
local c4 |
if c1 = '%d' |
c4 = 1 |
else |
c4 = 0 |
end if |
virtual at 0 |
db _format,0,0 |
store word 0 at %-1 |
load c1 from f2-c2 |
end virtual |
if c1 <> 0 |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
c2 = c2 + 1 |
f2 = %+1 |
DEBUGF_HELPER D,a1,c4,_arg |
else if c1 = '\n' |
c3 = c3 + 1 |
end if |
end repeat |
virtual at 0 |
db _format,0,0 |
load c1 from f2-c2 |
end virtual |
if (c1<>0)&(f2<>..lbl-..f1-1) |
DEBUGS 0,_debug_str_+f2-c2 |
end if |
virtual at 0 |
..f1 db _format,0 |
..lbl: |
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 |
end virtual |
end if |
} |
macro __include_debug_strings dummy,[_id,_fmt,_len] { |
common |
local c1,a1,a2 |
forward |
if defined _len & ~_len eq |
_id: |
a1 = 0 |
a2 = 0 |
repeat _len |
virtual at 0 |
db _fmt,0,0 |
load c1 word from %+a2-1 |
end virtual |
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') |
db 0 |
a2 = a2 + 1 |
else if (c1='\n') |
dw $0A0D |
a1 = a1 + 1 |
a2 = a2 + 1 |
else |
db c1 and 0x0FF |
end if |
end repeat |
db 0 |
end if |
} |
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { |
common |
local num |
num = 0 |
forward |
if num = _num |
DEBUG#_letter _sign,_arg |
end if |
num = num+1 |
common |
_num = _num+1 |
} |
macro include_debug_strings { |
if __DEBUG__ = 1 |
match dbg_str,__debug_strings \{ |
__include_debug_strings dbg_str |
\} |
end if |
} |
/programs/network_old/VNCclient/thread.inc |
---|
0,0 → 1,188 |
thread_start: |
DEBUGF 1,'I am the thread!\n' |
mov eax,40 ; Report events |
mov ebx,10000000b ; Only Stack |
mcall |
resolve first,[server_ip] ; the input window putted the server @ 'first', resolve it into a real ip |
mov [server_port],5900 ; no port input for now, only standard port 5900 |
DEBUGF 1,'connecting to %u.%u.%u.%u:%u\n',1[server_ip],1[server_ip+1],1[server_ip+2],1[server_ip+3],4[server_port] |
eth.search_port 1000,edx ; Find a free port starting from 1001 and store in edx |
eth.open_tcp edx,[server_port],[server_ip],1,[socket] ; open socket |
DEBUGF 1,'Socket opened: %u (port %u)\n',[socket],ecx |
call read_data |
cmp dword[receive_buffer+1],'RFB ' |
jne no_rfb |
eth.write_tcp [socket],12,handshake |
DEBUGF 1,'Sending handshake: protocol version\n' |
call read_data |
mov eax,receive_buffer+1 |
mov eax,[eax] |
bswap eax |
cmp eax,0 |
je invalid_security |
cmp eax,1 |
je no_security |
cmp eax,2 |
je vnc_security |
jmp close |
vnc_security: |
mov byte[mode],1 |
call red_logon |
no_security: |
eth.write_tcp [socket],1,shared |
DEBUGF 1,'Sending handshake: shared session?\n' |
eth.wait_for_data [socket],TIMEOUT*10,close |
eth.read_data [socket],framebuffer,[datapointer],IM_END-receive_buffer ; now the server should send init message |
DEBUGF 1,'Serverinit: bpp:%u depth:%u bigendian:%u truecolor:%u\n',1[pixelformat.bpp],1[pixelformat.depth],1[pixelformat.big_endian],1[pixelformat.true_color] |
mov eax,dword[framebuffer] |
bswap eax |
mov dword[screen],eax |
eth.write_tcp [socket],20,pixel_format8 |
DEBUGF 1,'Sending pixel format\n' |
call read_data |
; eth.write_tcp [socket],8,encodings |
; DEBUGF 1,'Sending encoding info\n' |
; call read_data |
mov eax,dword[framebuffer.width] |
mov dword[fbur.width],eax |
mov byte[thread_ready],1 |
request_rfb: |
mov byte[fbur.inc],2 ;;;;;;;; |
eth.write_tcp [socket],10,fbur ;;;;;;;;; |
thread_loop: |
eth.wait_for_data [socket],1000,thread_loop |
call read_data ; Read the data into the buffer |
mov eax,[datapointer] ; at least 2 bytes should be received |
sub eax,receive_buffer |
cmp eax,1 |
jle mainloop |
DEBUGF 1,'Data received, %u bytes\n',eax |
cmp byte[receive_buffer],0 |
je framebufferupdate |
cmp byte[receive_buffer],1 |
je setcolourmapentries |
cmp byte[receive_buffer],2 |
je bell |
cmp byte[receive_buffer],3 |
je servercuttext |
jmp thread_loop |
framebufferupdate: |
mov ax,word[receive_buffer+2] |
xchg al,ah |
mov di,ax |
DEBUGF 1,'Framebufferupdate: %u frames\n',di |
mov esi,receive_buffer+4 |
jmp rectangle_loop |
next_rectangle: |
call drawbuffer |
dec di |
test di,di |
jz request_rfb |
rectangle_loop: |
mov edx,[esi] |
bswap edx |
mov ebx,edx |
shr edx,16 |
mov [frame.x],dx |
mov [frame.y],bx |
add esi,4 |
mov ecx,[esi] |
bswap ecx |
mov eax,ecx |
shr ecx,16 |
mov [frame.width],cx |
mov [frame.height],ax |
add esi,4 |
mov eax,[esi] |
add esi,4 |
mov ebx,esi |
sub ebx,receive_buffer+12 |
DEBUGF 1,'frame: width=%u height=%u x=%u y=%u offset:%u encoding:',2[frame.width],2[frame.height],2[frame.x],2[frame.y],ebx |
cmp eax,0 |
je encoding_raw |
cmp eax,1 |
je encoding_copyrect |
cmp eax,2 |
je encoding_RRE |
cmp eax,5 |
je encoding_hextile |
cmp eax,16 |
je encoding_ZRLE |
mov ebx,esi |
sub ebx,receive_buffer+8 |
DEBUGF 1,'\nunknown encoding: %u (offset %u)\n',eax,ebx |
jmp bell |
jmp thread_loop |
encoding_RRE: |
DEBUGF 1,'RRE\n' |
jmp next_rectangle |
encoding_hextile: |
DEBUGF 1,'hextile\n' |
jmp next_rectangle |
encoding_ZRLE: |
DEBUGF 1,'ZRLE\n' |
jmp next_rectangle |
setcolourmapentries: |
DEBUGF 1,'Server sended SetColourMapEntries message\n' |
jmp thread_loop |
bell: |
mov eax,55 |
mov ebx,eax |
mov esi,beep |
mcall |
jmp thread_loop |
servercuttext: |
DEBUGF 1,'Server cut text\n' |
jmp thread_loop |
read_data: |
eth.read_data [socket],receive_buffer,[datapointer],IM_END-receive_buffer |
ret |
/programs/network_old/VNCclient/raw.inc |
---|
0,0 → 1,153 |
encoding_raw: |
DEBUGF 1,'RAW\n' |
mov ax,[frame.y] ; |
mov bx,[screen.width] ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; [screen.width]*[frame.y] |
movzx eax,[frame.x] |
add edx,eax ; [screen.width]*[frame.y]+[frame.x] |
mov eax,3 ; |
mul edx ; ([screen.width]*[frame.y]+[frame.x])*3 |
add eax,framebuffer_data ; |
push eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3 |
mov ax,[frame.width] ; |
mov bx,3 ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; [frame.width]*3 |
pop eax ; |
add edx,eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3+[frame.width]*3 |
push eax ; |
push edx ; |
mov ax,[frame.height] ; |
dec ax ; |
mov bx,3 ; |
mul bx ; |
mov bx,[screen.width] ; |
mul bx ; |
shl edx,16 ; |
mov dx,ax ; |
mov ecx,edx ; |
pop edx ; |
add ecx,edx ; mov ecx,edx+([frame.height]-1)*[screen.width]*3 |
pop ebx |
.pixelloop32: |
cmp ebx,ecx |
jge next_rectangle |
; add esi,2 ; 32 bit code RAW - OK |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; dec esi ; |
; ; |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; dec esi ; |
; ; |
; mov al,[esi] ; |
; mov [ebx],al ; |
; inc ebx ; |
; add esi,4 ; |
; push ecx ; 16 bit code RAW |
; mov cl,51 |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; and al,00011111b ; |
; xchg al,ah |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; shr ax,5 ; |
; xchg al,ah |
; and al,00011111b ; |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; mov ax,[esi] ; |
; xchg al,ah |
; shr ax,10 ; |
; and al,00011111b ; |
; mul cl |
; mov [ebx],al ; |
; inc ebx ; |
; |
; inc esi ; |
; inc esi ; |
; pop ecx |
push ecx ; 8 bit code RAW - OK |
mov cl,85 ; |
; |
mov al,[esi] ; |
shr al,4 ; |
and al,3 ; |
mul cl ; |
mov [ebx],al ; |
inc ebx ; |
; |
mov al,[esi] ; |
shr al,2 ; |
and al,3 ; |
mul cl ; |
mov [ebx],al ; |
inc ebx ; |
; |
mov al,[esi] ; |
and al,3 ; |
mul cl ; |
mov byte[ebx],al ; |
inc ebx ; |
inc esi ; |
pop ecx ; |
cmp ebx,edx |
jl .pixelloop32 |
push edx |
push ebx |
mov ax,[screen.width] |
mov bx,3 |
mul bx |
shl edx,16 |
mov dx,ax |
mov eax,edx |
pop ebx |
pop edx |
add ebx,eax ; eax = [screen.width]*3 |
add edx,eax |
push edx |
push ebx |
mov ax,[frame.width] |
mov bx,3 |
mul bx |
shl edx,16 |
mov dx,ax |
mov eax,edx |
pop ebx |
pop edx |
sub ebx,eax ; eax = [frame.width]*3 |
jmp .pixelloop32 |
/programs/network_old/VNCclient/copyrect.inc |
---|
0,0 → 1,5 |
encoding_copyrect: |
DEBUGF 1,'FRAME: copyrect\n' |
jmp next_rectangle |
/programs/network_old/https/trunk/https.asm |
---|
0,0 → 1,1362 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; Tiny HTTP Server v 0.5 for KolibriOS ; |
; ; |
; License GPL / See file COPYING for details. ; |
; Copyright 2003 Ville Turjanmaa ; |
; ; |
; Compile with FASM for Menuet/KolibriOS ; |
; ; |
; Request /TinyStat for server statistics ; |
; Request /TinyBoard for server message board ; |
; ; |
; Special version for KoOS by Hex && Heavyiron ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
appname equ 'Kolibri HTTP Server ' |
version equ '0.6' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x400000 ; required amount of memory |
dd 0x20000 |
dd 0,0 ; reserved=no extended header |
include "macros.inc" |
; 0x0+ - program image |
; 0x1ffff - stack |
; 0x20000+ - message board |
; 0x100000+ - requested file |
filel: |
dd 0 |
dd 0 |
dd 0 |
dd 50000 |
dd 0x20000 |
db '/sys/board.htm',0 |
files: |
dd 2 |
dd 0 |
dd 0 |
dd 0 |
dd 0x20000 |
db '/sys/board.htm',0 |
START: ; start of execution |
mov eax,70 |
mov ebx,filel |
mcall |
mov [board_size],ebx |
cmp eax,0 |
je board_found |
mov [board_size],board_end-board |
mov esi,board |
mov edi,0x20000 |
mov ecx,[board_size] |
cld |
rep movsb |
board_found: |
mov eax,70 |
mov ebx,files |
mov ecx,[board_size] |
mov [files+12],ecx |
mcall |
mov [status],-1 |
mov [last_status],-2 |
call clear_input |
red: |
call draw_window ; at first, draw the window |
still: |
call check_status |
cmp [status],4 |
je start_transmission |
cmp [status],0 |
jne nnn |
cmp [server_active],1 |
jne nnn |
call ops |
nnn: |
mov eax,5 |
mov ebx,1 |
mcall |
mov eax,11 |
mcall |
call check_events |
jmp still |
last_status dd 0x0 |
check_events: |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
ret |
key: ; Keys are not valid at this part of the |
mov al,2 ; loop. Just read it and ignore |
mcall |
ret |
button: ; button |
mov al,17 ; get id |
mcall |
cmp ah,1 ; close |
jnz tst2 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,-1 |
mcall |
tst2: |
cmp ah,2 ; button id=2 ? |
jnz tst3 |
; open socket |
ops: |
mov eax,53 |
mov ebx,5 |
mov ecx,80 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
mov [posy],1 |
mov [posx],0 |
call check_for_incoming_data |
call clear_input |
call draw_data |
mov [server_active],1 |
call check_status |
ret |
tst3: |
cmp ah,4 ; button id=4 ? |
jnz no4 |
mov [server_active],0 |
close_socket: |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,5 |
mov ebx,2 |
mcall |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
cmp [server_active],1 |
jne no_re_open |
mov eax,53 |
mov ebx,5 |
mov ecx,80 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
no_re_open: |
mov edi,input_text+256*15+1 |
mov [edi+2],dword ': :' |
call set_time |
mov edi,input_text+256*16+1 |
mov [edi+2],dword '. .' |
call set_date |
mov eax,[documents_served] |
mov ecx,9 |
mov edi,input_text+256*15+12 |
call set_value |
mov eax,[bytes_transferred] |
mov ecx,9 |
mov edi,input_text+256*16+12 |
call set_value |
call draw_data |
mov esp,0x1ffff |
jmp still |
no4: |
cmp ah,6 ; read directory |
je read_string |
ret |
clear_input: |
mov edi,input_text |
mov eax,0 |
mov ecx,256*30 |
cld |
rep stosb |
ret |
retries dd 50 |
start_transmission: |
mov [posy],1 |
mov [posx],0 |
call clear_input |
mov [retries],50 |
wait_for_data: |
call check_for_incoming_data |
cmp [input_text+256+1],dword 'GET ' |
je data_received |
cmp [input_text+256+1],dword 'POST' |
je data_received |
mov eax,5 |
mov ebx,1 |
mcall |
dec [retries] |
jnz wait_for_data |
jmp no_http_request |
data_received: |
mov eax,0x100000 |
mov ebx,0x2f0000 / 512 |
call read_file |
call wait_for_empty_slot |
call send_header |
mov [filepos],0x100000 |
mov [fileadd],700 |
call check_status |
call draw_data |
newblock: |
call wait_for_empty_slot |
mov edx,[fileadd] |
cmp edx,[file_left] |
jbe file_size_ok |
mov edx,[file_left] |
file_size_ok: |
sub [file_left],edx |
; write to socket |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi,[filepos] |
mcall |
mov eax,esi |
add eax,edx |
sub eax,0x100000 |
call display_progress |
mov edx,[fileadd] |
add [filepos],edx |
cmp [file_left],0 |
jg newblock |
no_http_request: |
jmp close_socket |
filepos dd 0x100000 |
fileadd dd 0x1 |
filesize dd 0x0 |
file_left dd 0x0 |
wait_for_empty_slot: |
pusha |
wait_more: |
mov eax,5 |
mov ebx,1 |
mcall |
mov eax,11 |
mcall |
call check_events |
mov eax,53 |
mov ebx,255 |
mov ecx,103 |
mcall |
cmp eax,0 |
je no_wait_more |
jmp wait_more |
no_wait_more: |
popa |
ret |
display_progress: |
pusha |
mov edi,eax |
mov eax,13 |
mov ebx,115*65536+8*6 |
mov ecx,178*65536+10 |
mov edx,0xffffff |
mcall |
mov eax,47 |
mov ebx,8*65536 |
mov ecx,edi |
mov edx,115*65536+178 |
mov esi,0x000000 |
mcall |
popa |
ret |
send_header: |
pusha |
mov eax,53 ; send response and file length |
mov ebx,7 |
mov ecx,[socket] |
mov edx,h_len-html_header |
mov esi,html_header |
mcall |
mov eax,53 ; send file type |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[type_len] |
mov esi,[file_type] |
mcall |
popa |
ret |
fileinfo dd 0 |
dd 0 |
dd 0 |
dd 512 |
dd 0x100000 |
getf db '/sys/' |
times 50 db 0 |
wanted_file: times 100 db 0 |
getflen dd 6 |
make_room: |
pusha |
mov edx,ecx |
mov esi,0x20000 |
add esi,[board_size] |
mov edi,esi |
add edi,edx |
mov ecx,[board_size] |
sub ecx,board1-board |
inc ecx |
std |
rep movsb |
cld |
popa |
ret |
from_i dd 0x0 |
from_len dd 0x0 |
message dd 0x0 |
message_len dd 0x0 |
read_file: ; start of execution |
mov [fileinfo+16],eax |
shl ebx, 9 |
mov [fileinfo+12],ebx |
mov [file_type],unk |
mov [type_len],unkl-unk |
mov [filename+40*2+6],dword 'UNK ' |
cmp [input_text+256+1],dword 'POST' |
je yes_new_message |
cmp [input_text+256+11],dword 'oard' ; server board message |
jne no_server_message_2 |
yes_new_message: |
mov eax,70 |
mov ebx,filel |
mcall |
mov [board_size],ebx |
cmp [input_text+256+1],dword 'POST' |
jne no_new_message |
mov edi,bsmt |
call set_time |
mov edi,bsmd |
call set_date |
call check_for_incoming_data |
mov esi,input_text+256 ; from |
newfroms: |
inc esi |
cmp esi,input_text+256*20 |
je no_server_message_2 |
cmp [esi],dword 'from' |
jne newfroms |
add esi,5 |
mov [from_i],esi |
mov edx,0 |
name_new_len: |
cmp [esi+edx],byte 13 |
je name_found_len |
cmp [esi+edx],byte '&' |
je name_found_len |
cmp edx,1000 |
je name_found_len |
inc edx |
jmp name_new_len |
name_found_len: |
mov [from_len],edx |
mov esi,input_text+256 |
newmessages: |
inc esi |
cmp esi,input_text+256*20 |
je no_server_message_2 |
cmp [esi],dword 'sage' |
jne newmessages |
add esi,5 |
mov [message],esi |
mov edx,0 |
new_len: |
inc edx |
cmp [esi+edx],byte ' ' |
je found_len |
cmp [esi+edx],byte 13 |
jbe found_len |
cmp edx,input_text+5000 |
je found_len |
jmp new_len |
found_len: |
mov [message_len],edx |
mov edx,0 |
change_letters: |
cmp [esi+edx],byte '+' |
jne no_space |
mov [esi+edx],byte ' ' |
no_space: |
cmp [esi+edx+1],word '0D' |
jne no_br |
mov [esi+edx],dword '<br>' |
mov [esi+edx+4],word ' ' |
no_br: |
cmp [esi+edx],byte '%' |
jne no_ascii |
movzx eax,byte [esi+edx+2] |
sub eax,48 |
cmp eax,9 |
jbe eax_ok |
sub eax,7 |
eax_ok: |
movzx ebx,byte [esi+edx+1] |
sub ebx,48 |
cmp ebx,9 |
jbe ebx_ok |
sub ebx,7 |
ebx_ok: |
imul ebx,16 |
add ebx,eax |
mov [esi+edx],bl |
mov [esi+edx+1],word '' |
add edx,2 |
no_ascii: |
inc edx |
cmp edx,[message_len] |
jbe change_letters |
mov edx,board1e-board1 + board2e-board2 + board3e-board3 |
add edx,[from_len] |
add edx,[message_len] |
add [board_size],edx |
mov ecx,edx |
call make_room |
mov esi,board1 ; first part |
mov edi,0x20000 |
add edi,board1-board |
mov ecx,edx |
cld |
rep movsb |
mov esi,[from_i] ; name |
mov edi,0x20000 |
add edi,board1-board |
add edi,board1e-board1 |
mov ecx,[from_len] |
cld |
rep movsb |
mov esi,board2 ; middle part |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 |
add edi,[from_len] |
mov ecx,board2e-board2 |
cld |
rep movsb |
mov esi,[message] ; message |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 + board2e-board2 |
add edi,[from_len] |
mov ecx,[message_len] |
cld |
rep movsb |
mov esi,board3 ; end part |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 + board2e-board2 |
add edi,[from_len] |
add edi,[message_len] |
mov ecx,board3e-board3 |
cld |
rep movsb |
inc [board_messages] |
mov eax,[board_size] |
mov [files+12],eax |
mov eax,70 |
mov ebx,files |
mcall |
no_new_message: |
mov esi,0x20000 |
mov edi,0x100000 |
mov ecx,[board_size] |
cld |
rep movsb |
mov ebx,[board_size] |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_loaded |
no_server_message_2: |
cmp [input_text+256+9],dword 'ySta' ; server message |
jne no_server_message_1 |
mov edi,smt |
call set_time |
mov edi,smd |
call set_date |
mov eax,[documents_served] |
mov ecx,9 |
mov edi,sms+21 |
call set_value |
mov eax,[bytes_transferred] |
mov ecx,9 |
mov edi,smb+21 |
call set_value |
mov eax,[board_messages] |
mov ecx,9 |
mov edi,smm+21 |
call set_value |
mov eax,[board_size] |
mov ecx,9 |
mov edi,smz+21 |
call set_value |
mov esi,sm |
mov edi,0x100000 |
mov ecx,sme-sm |
cld |
rep movsb |
mov ebx,sme-sm |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_loaded |
no_server_message_1: |
mov esi,input_text+256+6 |
cmp [input_text+256+1],dword 'GET ' |
jne no_new_let |
mov edi,wanted_file |
cld |
new_let: |
cmp [esi],byte ' ' |
je no_new_let |
cmp edi,wanted_file+30 |
jge no_new_let |
movsb |
jmp new_let |
no_new_let: |
mov [edi+0],dword 0 |
mov [edi+4],dword 0 |
mov [edi+8],dword 0 |
cmp esi,input_text+256+6 |
jne no_index |
mov edi,wanted_file |
mov [edi+0],dword 'inde' |
mov [edi+4],dword 'x.ht' |
mov [edi+8],byte 'm' |
mov [edi+9],byte 0 |
add edi,9 |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp html_file |
no_index: |
cmp [edi-3],dword 'htm'+0 |
je htm_header |
cmp [edi-3],dword 'HTM'+0 |
je htm_header |
jmp no_htm_header |
htm_header: |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp found_file_type |
no_htm_header: |
cmp [edi-3],dword 'png'+0 |
je png_header |
cmp [edi-3],dword 'PNG'+0 |
je png_header |
jmp no_png_header |
png_header: |
mov [file_type],png |
mov [type_len],pngl-png |
mov [filename+40*2+6],dword 'PNG ' |
jmp found_file_type |
no_png_header: |
cmp [edi-3],dword 'gif'+0 |
je gif_header |
cmp [edi-3],dword 'GIF'+0 |
je gif_header |
jmp no_gif_header |
gif_header: |
mov [file_type],gif |
mov [type_len],gifl-gif |
mov [filename+40*2+6],dword 'GIF ' |
jmp found_file_type |
no_gif_header: |
cmp [edi-3],dword 'jpg'+0 |
je jpg_header |
cmp [edi-3],dword 'JPG'+0 |
je jpg_header |
jmp no_jpg_header |
jpg_header: |
mov [file_type],jpg |
mov [type_len],jpgl-jpg |
mov [filename+40*2+6],dword 'JPG ' |
jmp found_file_type |
no_jpg_header: |
cmp [edi-3],dword 'asm'+0 |
je txt_header |
cmp [edi-3],dword 'ASM'+0 |
je txt_header |
cmp [edi-3],dword 'txt'+0 |
je txt_header |
cmp [edi-3],dword 'TXT'+0 |
je txt_header |
jmp no_txt_header |
txt_header: |
mov [file_type],txt |
mov [type_len],txtl-txt |
mov [filename+40*2+6],dword 'TXT ' |
jmp found_file_type |
no_txt_header: |
html_file: |
found_file_type: |
mov edi,getf |
add edi,[getflen] |
mov esi,wanted_file |
mov ecx,40 |
cld |
rep movsb |
mov esi,getf |
mov edi,filename |
mov ecx,35 |
cld |
rep movsb |
mov [fileinfo+12],dword 1 ; file exists ? |
mov eax,70 |
mov ebx,fileinfo |
mcall |
cmp eax,0 ; file not found - message |
je file_found |
mov edi,et |
call set_time |
mov edi,ed |
call set_date |
mov esi,fnf |
mov edi,0x100000 |
mov ecx,fnfe-fnf |
cld |
rep movsb |
mov ebx,fnfe-fnf |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_not_found |
file_found: |
mov [fileinfo+12],dword 0x2f0000 ; read all of file |
mov eax,70 |
mov ebx,fileinfo |
mcall |
file_not_found: |
file_loaded: |
and ebx,0x3fffff |
mov [filesize],ebx |
mov [file_left],ebx |
mov eax,ebx |
mov edi,c_l+5 |
mov ebx,10 |
newl: |
xor edx,edx |
div ebx |
mov ecx,edx |
add cl,48 |
mov [edi],cl |
dec edi |
cmp edi,c_l |
jge newl |
mov esi,c_l |
mov edi,filename+46 |
mov ecx,7 |
cld |
rep movsb |
inc [documents_served] |
mov eax,[filesize] |
add [bytes_transferred],eax |
call draw_data |
ret |
set_value: |
pusha |
add edi,ecx |
mov ebx,10 |
new_value: |
xor edx,edx |
div ebx |
add dl,48 |
mov [edi],dl |
dec edi |
loop new_value |
popa |
ret |
set_time: |
pusha |
mov eax,3 |
mcall |
mov ecx,3 |
new_time_digit: |
mov ebx,eax |
and ebx,0xff |
shl ebx,4 |
shr bl,4 |
add bx,48*256+48 |
mov [edi],bh |
mov [edi+1],bl |
add edi,3 |
shr eax,8 |
loop new_time_digit |
popa |
ret |
set_date: |
pusha |
mov eax,29 |
mcall |
mov ecx,3 |
add edi,6 |
new_date_digit: |
mov ebx,eax |
and ebx,0xff |
shl ebx,4 |
shr bl,4 |
add bx,48*256+48 |
mov [edi],bh |
mov [edi+1],bl |
sub edi,3 |
shr eax,8 |
loop new_date_digit |
popa |
ret |
check_for_incoming_data: |
pusha |
check: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
cmp eax,0 |
je _ret_now |
new_data: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
je _ret |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
mcall |
cmp bl,10 |
jne no_lf |
inc [posy] |
mov [posx],0 |
jmp new_data |
no_lf: |
cmp bl,20 |
jb new_data |
inc [posx] |
cmp [posy],20 |
jbe yok |
mov [posy],1 |
yok: |
mov eax,[posy] |
imul eax,256 |
add eax,[posx] |
mov [input_text+eax],bl |
jmp new_data |
_ret: |
call draw_data |
mov eax,5 |
mov ebx,1 |
cmp [input_text+256+1],dword 'POST' |
jne no_ld |
mov ebx,50 |
no_ld: |
mcall |
jmp check |
_ret_now: |
popa |
ret |
posy dd 1 |
posx dd 0 |
check_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
cmp eax,[status] |
je c_ret |
mov [status],eax |
add al,48 |
mov [text+12],al |
call draw_data |
c_ret: |
popa |
ret |
addr dd 0x0 |
ya dd 0x0 |
filename2: times 100 db 32 |
read_string: |
mov [addr],dword getf |
mov [ya],dword 139 |
mov edi,[addr] |
mov eax,0 |
mov ecx,30 |
cld |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 32 |
call print_text |
jmp f11 |
nobsl: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,30 |
cmp esi,edi |
jnz f11 |
read_done: |
push edi |
mov ecx,40 |
mov eax,32 |
cld |
rep stosb |
call print_text |
pop edi |
sub edi,[addr] |
mov [getflen],edi |
mov esi,getf |
mov edi,dirp+12 |
mov ecx,28 |
cld |
rep movsb |
jmp still |
print_text: |
pusha |
mov eax,4 |
mov edx,[addr] |
mov ebx,97*65536 |
add ebx,[ya] |
mov ecx,0x40000000 |
mov esi,23 |
mov edi,0xffffff |
mcall |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+480 ; [x start] *65536 + [x size] |
mov ecx,100*65536+215 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size] |
mov ecx,59*65536+9 ; [y start] *65536 + [y size] |
mov edx,2 ; button id |
mov esi,0x66aa66 ; button color RRGGBB |
mcall |
; function 8 : define and draw button |
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size] |
mov ecx,72*65536+9 ; [y start] *65536 + [y size] |
mov edx,4 ; button id |
mov esi,0xaa6666 ; button color RRGGBB |
mcall |
; Enter directory |
mov ebx,(25)*65536+66 |
mov ecx,135*65536+15 |
mov edx,6 |
mov esi,0x3388dd |
mcall |
mov eax,38 |
mov ebx,240*65536+240 |
mov ecx,22*65536+210 |
mov edx,0x6699cc ; 002288 |
mcall |
mov ebx,241*65536+241 |
mov ecx,22*65536+210 |
mov edx,0x336699 ; 002288 |
mcall |
call draw_data |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
draw_data: |
pusha |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,35 |
newline: |
pusha |
cmp ebx,25*65536+61 |
je now |
cmp ebx,25*65536+74 |
je now |
cmp ebx,25*65536+74+13*5 |
je now |
mov ecx,ebx |
mov bx,35*6 |
shl ecx,16 |
mov cx,9 |
mov edx,0xffffff |
mov eax,13 |
mcall |
now: |
popa |
mov eax,4 |
mcall |
add ebx,13 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov [input_text+0],dword 'RECE' |
mov [input_text+4],dword 'IVED' |
mov [input_text+8],dword ': ' |
mov ebx,255*65536+35 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,input_text |
mov esi,35 |
mov edi,17 |
newline2: |
pusha |
mov ecx,ebx |
mov bx,35*6 |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov edx,0xffffff |
mcall |
popa |
mov eax,4 |
mcall |
add ebx,10 |
add edx,256 |
dec edi |
jnz newline2 |
popa |
ret |
; DATA AREA |
status dd 0x0 |
text: |
db 'TCB status: x ' |
db ' ' |
db ' Activate server ' |
db ' Stop server ' |
db ' ' |
db 'Requests: /TinyStat -statistics ' |
db ' /TinyBoard -message board ' |
db ' ' |
dirp: |
db ' Files: /sys/ ' |
db ' ' |
filename: |
db ' ' |
db 'Size: ------- ' |
db 'Type: --- ' |
db 'x' ; <- END MARKER, DONT DELETE |
html_header: |
db 'HTTP/1.0 200 OK',13,10 |
db 'Server: KolibriOS HTTP Server',13,10 |
db 'Content-Length: ' |
c_l: db '000000',13,10 |
h_len: |
fnf: |
db '<body>' |
db '<pre>' |
db "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10 |
db "<H1>Error <FONT color=red>404</FONT> - File not found</H1>",13,10,13,10 |
db "Äëÿ ïîëó÷åíèÿ ñòàòèñòèêè âûïîëíèòå çàïðîñ /TinyStat",13,10,13,10 |
et: db "xx:xx:xx",13,10 |
ed: db "xx.xx.xx",13,10 |
db "</pre></body>" |
fnfe: |
sm: |
db '<body>' |
db '<pre>' |
db "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10 |
db "Ñòàòèñòèêà: (ïîñëå äàííîãî çàïðîñà)",13,10,13,10 |
sms: db "- Äîêóìåíòîâ ïðèíÿòî: xxxxxxxxx",13,10 |
smb: db "- Áàéò ïåðåäàííî : xxxxxxxxx",13,10 |
db "- Ìåñòîíàõîæäåíèå : <a href=/TinyStat>Ñòàòèñòèêà</a>",13,10,13,10 |
db "Ãîñòåâàÿ:",13,10,13,10 |
smm: db "- Ñîîáùåíèé : xxxxxxxxx",13,10 |
smz: db "- Ðàçìåð â áàéòàõ : xxxxxxxxx",13,10 |
db "- Ìåñòîíàõîæäåíèå : <a href=/TinyBoard>Ãîñòåâàÿ</a>",13,10,13,10 |
smt: db "xx:xx:xx",13,10 |
smd: db "xx.xx.xx",13,10 |
db '</pre></body>' |
sme: |
documents_served dd 0x0 |
bytes_transferred dd 0x0 |
file_type dd 0 |
type_len dd 0 |
htm: db 'Content-Type: text/html',13,10,13,10 |
html: |
txt: db 'Content-Type: text/plain',13,10,13,10 |
txtl: |
png: db 'Content-Type: image/png',13,10,13,10 |
pngl: |
gif: db 'Content-Type: image/gif',13,10,13,10 |
gifl: |
jpg: db 'Content-Type: image/jpeg',13,10,13,10 |
jpgl: |
unk: db 'Content-Type: unknown/unknown',13,10,13,10 |
unkl: |
title db appname,version,0 |
socket dd 0x0 |
server_active db 0x0 |
board: |
db "<HTML><HEAD><TITLE>INTKolibriOS - /Ãîñòåâàÿ/</TITLE></HEAD>",13,10 |
db "<BODY background=bgnd.gif BGCOLOR=#ffffff ALINK=black VLINK=black><br>",13,10 |
db "<center>",13,10 |
db "<TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0 bgcolor=#ffffff width=600>" |
db 13,10 |
db "<TR VALIGN=top><TD ALIGN=center bgcolor=F4F4F4>",13,10 |
db "<font size=4>Ãîñòåâàÿ ñåðâåðà INTKolibriOS</TD></TR></TABLE><br>",13,10 |
db "<TABLE CELLPADDING=14 CELLSPACING=2 BORDER=0 bgcolor=#ffffff width=600>" |
db 13,10,13,10 |
board1: |
db "<TR VALIGN=top>",13,10 |
db "<TD ALIGN=left width=80 bgcolor=F4F4F4><P>",13,10 |
db "<font size=3>",13,10 |
board1e: |
db "Hex",13,10 |
board2: |
db "</font>",13,10 |
db "<br><br><br>",13,10 |
db "<br><br><br><br>",13,10 |
bsmt: |
db "15.23.45<br>",13,10 |
bsmd: |
db "22.03.06",13,10 |
db "</P></TD>",13,10 |
db "<TD bgcolor=F4F4F4><P>",13,10 |
board2e: |
db "Äîáðî ïîæàëîâàòü â ãîñòåâóþ ñåðâåðà INTKolibriOS! (-:<br>" |
db 13,10 |
board3: |
db "</P></TD></TR>",13,10,13,10 |
board3e: |
boardadd: |
db "</TABLE>",13,10 |
db "<br>",13,10 |
db "<TABLE CELLPADDING=14 CELLSPACING=3 BORDER=0 bgcolor=#ffffff width=600>" |
db 13,10 |
db "<TR VALIGN=top>",13,10 |
db "<TD ALIGN=left bgcolor=F4F4F4><P>",13,10 |
db "<form method=Post Action=/TinyBoard>",13,10 |
db "Èìÿ: <br><input type=text name=from size=20 MAXLENGTH=20><br>",13,10 |
db "Ñîîáùåíèå: <br><textarea cols=60 rows=6 name=message></textarea><br>",13,10 |
db "<input type=Submit Value=' Îòïðàâèòü ñîîáùåíèå '></form>",13,10 |
db "</TD></TR>",13,10 |
db "</TABLE>",13,10 |
db "</BODY>",13,10 |
db "</HTML>",13,10 |
board_end: |
board_size dd 0x0 |
board_messages dd 0x0 |
input_text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/https/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm https.asm https |
@erase lang.inc |
@pause |
/programs/network_old/https/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm https.asm https |
@erase lang.inc |
@pause |
/programs/network_old/stackcfg/trunk/stackcfg.asm |
---|
0,0 → 1,701 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; Stack Configuration Tool ; |
; ; |
; Compile with FASM for Menuet ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
memsize = 100000h |
org 0 |
PARAMS = memsize - 1024 |
use32 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd memsize ; memory for app |
dd memsize - 1024 ; esp |
dd PARAMS , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include '../../../macros.inc' |
START: ; start of execution |
read_stack_setup: |
mov eax,52 |
mov ebx,0 |
mcall |
mov [config],eax |
mov eax,52 |
mov ebx,1 |
mcall |
mov dword [ip_address],eax |
mov eax,52 |
mov ebx,9 |
mcall |
mov dword [gateway_ip],eax |
mov eax,52 |
mov ebx,10 |
mcall |
mov dword [subnet_mask],eax |
mov eax,52 |
mov ebx,13 |
mcall |
mov dword [dns_ip],eax |
mov eax,[config] ; unwrap com IRQ |
shr eax,8 |
and eax,0xf |
mov [com_irq],eax |
mov eax,[config] ; unwrap com PORT |
shr eax,16 |
and eax,0xfff |
mov [com_add],eax |
mov eax,[config] ; unwrap IRQ |
and eax,0xf |
mov [interface],eax |
mov eax,[config] ; unwrap com PORT |
shr eax,7 |
and eax,1 |
mov [assigned],eax |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jnz button |
key: ; key |
; mov al,2 ; just read it and ignore |
mcall |
jmp still |
button: ; button |
mov al,17 ; get id |
mcall |
shr eax,8 |
dec eax ; button id=1 ? |
jne noclose |
or eax,-1 ; close this program |
mcall |
noclose: |
dec eax |
je read_stack_setup |
dec eax |
jne no_apply_stack_setup |
call apply_stack_setup |
jmp still |
no_apply_stack_setup: |
dec eax ; GET COM PORT |
dec eax |
jne no_read_comport |
mov [string_x],272 |
mov [string_y],40 |
mov [string_length],3 |
call read_string |
movzx eax,byte [string] |
cmp eax,'A' |
jb gcp1 |
sub eax,'A'-'9'-1 |
gcp1: |
sub eax,48 |
shl eax,8 |
mov ebx,eax |
movzx eax,byte [string+1] |
cmp eax,'A' |
jb gcp2 |
sub eax,'A'-'9'-1 |
gcp2: |
sub eax,48 |
shl eax,4 |
add ebx,eax |
movzx eax,byte [string+2] |
cmp eax,'A' |
jb gcp3 |
sub eax,'A'-'9'-1 |
gcp3: |
sub eax,48 |
add ebx,eax |
mov [com_add],ebx |
jmp red |
no_read_comport: |
dec eax ; GET COM IRQ |
jne no_read_comirq |
mov [string_x],284 |
mov [string_y],50 |
mov [string_length],1 |
call read_string |
movzx eax,byte [string] |
cmp eax,'A' |
jb gci1 |
sub eax,'A'-'9'-1 |
gci1: |
sub eax,48 |
mov [com_irq],eax |
jmp red |
no_read_comirq: |
dec eax ; GET IP |
jne no_read_ip |
mov [string_x],205 |
mov [string_y],80 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,ip_address |
ip0: |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
stosb |
cmp edi,ip_address+3 |
jbe ip0 |
jmp red |
no_read_ip: |
dec eax ; set gateway ip |
jne no_set_gateway |
mov [string_x],205 |
mov [string_y],90 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,gateway_ip |
gip0: |
xor eax,eax |
gip1: |
inc esi |
cmp [esi],byte '0' |
jb gip2 |
cmp [esi],byte '9' |
jg gip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp gip1 |
gip2: |
stosb |
cmp edi,gateway_ip+3 |
jbe gip0 |
jmp red |
no_set_gateway: |
dec eax |
jne no_set_subnet |
mov [string_x],205 |
mov [string_y],100 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,subnet_mask |
sip0: |
xor eax,eax |
sip1: |
inc esi |
cmp [esi],byte '0' |
jb sip2 |
cmp [esi],byte '9' |
jg sip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp sip1 |
sip2: |
stosb |
cmp edi,subnet_mask+3 |
jbe sip0 |
jmp red |
no_set_subnet: |
dec eax |
jne no_set_dns |
mov [string_x],205 |
mov [string_y],110 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,dns_ip |
dip0: |
xor eax,eax |
dip1: |
inc esi |
cmp [esi],byte '0' |
jb dip2 |
cmp [esi],byte '9' |
jg dip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp dip1 |
dip2: |
stosb |
cmp edi,dns_ip+3 |
jbe dip0 |
jmp red |
no_set_dns: |
dec eax |
jb no_set_interface |
cmp eax,14-11 |
ja no_set_interface |
mov [interface],eax |
jmp red |
no_set_interface: |
sub eax,21-11 |
jb no_ip_sf |
cmp eax,22-21 |
ja no_ip_sf |
xor eax,1 |
mov [assigned],eax |
jmp red |
no_ip_sf: |
jmp still |
apply_stack_setup: |
mov eax,[com_irq] |
shl eax,8 |
mov ebx,[com_add] |
shl ebx,16 |
add eax,ebx |
add eax,[interface] |
mov ebx,[assigned] |
shl ebx,7 |
add eax,ebx |
mov [config],eax |
mov eax,52 |
mov ebx,3 |
mov ecx,dword [ip_address] |
mcall |
mov eax,52 |
mov ebx,11 |
mov ecx,dword [gateway_ip] |
mcall |
mov eax,52 |
mov ebx,12 |
mov ecx,dword [subnet_mask] |
mcall |
mov eax,52 |
mov ebx,14 |
mov ecx,dword [dns_ip] |
mcall |
mov eax,52 |
mov ebx,2 |
mov ecx,[config] |
mcall |
ret |
string_length dd 16 |
string_x dd 200 |
string_y dd 60 |
string db '________________' |
read_string: |
mov edi,string |
mov eax,'_' |
mov ecx,[string_length] |
cld |
rep stosb |
call print_text |
mov edi,string |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
; mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,string |
jz f11 |
sub edi,1 |
mov [edi],byte '_' |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,string |
add esi,[string_length] |
cmp esi,edi |
jnz f11 |
read_done: |
print_text: |
pusha |
mov eax,13 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_length] |
imul bx,6 |
mov ecx,[string_y] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_y] |
mov ecx,0x000000 |
mov edx,string |
mov esi,[string_length] |
mcall |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+330 ; [x start] *65536 + [x size] |
mov ecx,100*65536+157 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB,8->color gl |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; BUTTON : READ SETUP |
mov ebx,90*65536+65 |
mov ecx,127*65536+12 |
mov edx,2 |
mov esi,[button_color] |
mcall |
;mov eax,8 ; BUTTON : APPLY SETUP |
mov ebx,163*65536+65 |
mov ecx,127*65536+12 |
mov edx,3 |
mcall |
;mov eax,8 ; BUTTONS 11-14 : SELECT INTERFACE |
mov ebx,29*65536+8 |
mov ecx,39*65536+8 |
mov edx,11 |
interface_select: |
mcall |
add ecx,10*65536 |
inc edx |
cmp edx,11+4 |
jb interface_select |
mov ebx,[interface] ; PRINT SELECTED INTERFACE 'X' |
imul ebx,10 |
add ebx,31*65536+39 |
mov eax,4 |
mov ecx,0xffffff |
mov edx,xx |
mov esi,1 |
mcall |
mov eax,8 ; BUTTONS 21-22 : SERVER / MANUAL IP |
mov ebx,143*65536+8 |
mov ecx,69*65536+8 |
mov edx,21 |
mov esi,[button_color] |
mcall |
;mov eax,8 |
mov ebx,143*65536+8 |
mov ecx,79*65536+8 |
mov edx,22 |
mcall |
mov ebx,[assigned] ; PRINT SELECTED SERVER/MANUAL 'X' |
not ebx |
and ebx,1 |
imul ebx,10 |
add ebx,145*65536+69 |
mov eax,4 |
mov ecx,0xffffff |
mov edx,xx |
mov esi,1 |
mcall |
mov eax,47 ; COM ADDRESS |
mov ebx,3*65536+1*256 |
mov ecx,[com_add] |
mov edx,272*65536+40 |
mov esi,0x000000 |
mcall |
;mov eax,47 ; COM IRQ |
mov ebx,1*65536+1*256 |
mov ecx,[com_irq] |
mov edx,(266+3*6)*65536+50 |
mov esi,0x000000 |
mcall |
mov edi,ip_address |
mov edx,205*65536+80 |
mov esi,0x000000 |
mov ebx,3*65536 |
ipdisplay: |
;mov eax,47 |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,ip_address+4 |
jb ipdisplay |
mov edi,gateway_ip |
mov edx,205*65536+90 |
mov esi,0x000000 |
mov ebx,3*65536 |
gipdisplay: |
;mov eax,47 |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,gateway_ip+4 |
jb gipdisplay |
mov edi,subnet_mask |
mov edx,205*65536+100 |
mov esi,0x000000 |
mov ebx,3*65536 |
sipdisplay: |
;mov eax,47 |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,subnet_mask+4 |
jb sipdisplay |
mov edi,dns_ip |
mov edx,205*65536+110 |
mov esi,0x000000 |
mov ebx,3*65536 |
dipdisplay: |
;mov eax,47 |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,dns_ip+4 |
jb dipdisplay |
mov eax,8 ; BUTTON 5 : SET PORT |
mov ebx,299*65536+8 |
mov ecx,39*65536+8 |
mov edx,5 |
mov esi,[button_color] |
mcall |
;mov eax,8 ; BUTTON 6 : SET IRQ |
mov ecx,49*65536+8 |
inc edx |
mcall |
;mov eax,8 ; BUTTON 7 : SET IP |
mov ecx,79*65536+8 |
inc edx |
mcall |
;mov eax,8 ; BUTTON 8 : SET gateway IP |
mov ebx,299*65536+8 |
mov ecx,89*65536+8 |
inc edx |
mcall |
;mov eax,8 ; BUTTON 9 : SET subnet |
mov ecx,99*65536+8 |
inc edx |
mcall |
;mov eax,8 ; BUTTON 10 : SET dns ip |
mov ecx,109*65536+8 |
inc edx |
mcall |
mov ebx,31*65536+40 ; draw info text with function 4 |
mov edx,text |
mov esi,49 |
mov eax,4 |
newline: |
mov ecx,0x224466 |
cmp [edx],byte 'w' |
jne nowhite |
mov ecx,0xeeeeee |
nowhite: |
inc edx |
mcall |
add ebx,10 |
add edx,49 |
cmp [edx],byte 'x' |
jne newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
if lang eq ru |
title db ' áâனª á¥â¥¢®£® á⥪ ',0 |
text: |
db ' ¥ ªâ¨¢ë© ®¤¥¬ Com-¯®àâã: 0x < ' |
db ' Slip à¥àë¢ ¨¥ ¬®¤¥¬ : 0x < ' |
db ' PPP ' |
db ' à ©¢¥à ¯ ª¥â®¢ IP § ç ¥âáï á¥à¢¥à®¬ ' |
db ' (Ethernet) ¨ªá.: . . . < ' |
db ' «î§: . . . < ' |
db ' ®¤á¥âì: . . . < ' |
db ' DNS IP: . . . < ' |
db ' ' |
db 'w ¨â âì ਬ¥¨âì ' |
else if lang eq nl |
title db 'Netwerk configuratie',0 |
text: |
db ' Niet actief Modem Com Poort: 0x < ' |
db ' Slip Modem Com Irq: 0x < ' |
db ' PPP ' |
db ' Pakket Driver Door IP-server toegekend ' |
db ' (Ethernet) Vast IP: . . . < ' |
db ' Gateway: . . . < ' |
db ' Subnet: . . . < ' |
db ' DNS IP: . . . < ' |
db ' ' |
db 'w Vernieuw Toepassen ' |
else if lang eq ua |
title db ' « èâã¢ ï ¬¥à¥¦i' |
text: |
db ' ¥ ªâ¨¢¨© ®¤¥¬ Com-¯®àâã 0x < ' |
db ' Slip Com-¯®àâ ¬®¤¥¬ : 0x < ' |
db ' PPP ' |
db ' à ©¢¥à ¯ ª¥âi¢ IP ¯à¨§ ç óâìáï á¥à¢¥à®¬ ' |
db ' (Ethernet) iªá.: . . . < ' |
db ' àèàãâ: . . . < ' |
db ' ᪠: . . . < ' |
db ' DNS IP . . . < ' |
db ' ' |
db 'w à®ç¨â ⨠áâ®á㢠⨠' |
else |
title db 'Stack configuration',0 |
text: |
db ' Not active Modem Com Port: 0x < ' |
db ' Slip Modem Com Irq: 0x < ' |
db ' PPP ' |
db ' Packet Driver IP server assigned ' |
db ' (Ethernet) Fixed: . . . < ' |
db ' Gateway: . . . < ' |
db ' Subnet: . . . < ' |
db ' DNS IP: . . . < ' |
db ' ' |
db 'w READ APPLY ' |
end if |
xx: db 'x' ;<- END MARKER, DONT DELETE |
button_color dd 0x2254b9 |
ip_address dd ? |
gateway_ip dd ? |
subnet_mask dd ? |
dns_ip dd ? |
com_irq dd ? ; irq for slip/ppp |
com_add dd ? ; com port address for slip/ppp |
interface dd ? ; not active,slip,ppp,packet driver |
assigned dd ? ; get ip from server |
config dd ? |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/stackcfg/trunk/readme.txt |
---|
0,0 → 1,11 |
Ïðîãðàììà äëÿ íàñòðîéê ñåòåâûõ ïàðàìåòðîâ |
28.10.06 Heavyiron |
Äîáàâëåí ïàðàìåòð BOOT |
Òåïåðü ìîæíî â èñõîäíèê âáèòü íóæíûå IP, ìàñêó, øëþç è DNS, ïåðåêîìïèëëèðîâàòü ïðîãðàììó è çàêèíóòü åå â àâòîçàãðóçêó. Ñëåäîâàòåëüíî ýòè íàñòðîéêè íå ïðèäåòñÿ êàæäûé ðàç âáèâàòü âðó÷íóþ. |
 autorun.dat íåîáõîäèìî ïîìåñòèòü,íàïðèìåð, òàêóþ ñòðîêó: |
/sys/stackcfg BOOT 30 # Set yor network settings, |
íå çàáûâ ïðè ýòîì óâåëè÷èòü êîëè÷åñòâî çàïóñêàåìûõ ïðîãðàìì íà îäíó |
â ñàìîì íà÷àëå ôàéëà autorun.dat. |
TODO: |
ñäåëàòü ÷òåíèå íàñòðîåê èç ôàéëà network.dat, ÷òîáû íå òðåáîâàëàñü ïåðåêîìïèëëÿöèÿ äëÿ èçìåíåíèÿ íàñòðîåê. |
/programs/network_old/stackcfg/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm stackcfg.asm stackcfg |
@erase lang.inc |
@pause |
/programs/network_old/stackcfg/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm stackcfg.asm stackcfg |
@erase lang.inc |
@pause |
/programs/network_old/terminal/trunk/terminal.asm |
---|
0,0 → 1,727 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; TERMINAL |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
START: ; start of execution |
call draw_window |
call set_variables |
still: |
mov eax,23 ; wait here for event |
mov ebx,20 |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
cmp eax,16+4 |
je read_input |
jmp still |
read_input: |
mcall 42,4,text+120*80 |
test eax, eax |
jle still |
read_input_loop: |
mov bl,[ecx] |
inc ecx |
push eax ecx |
cmp bl,27 ; ESCAPE COMMAND |
jne no_esc |
call esc_command |
jmp newdata |
no_esc: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov esi,text+80+60*80 |
mov edi,text+60*80 |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
pop ecx eax |
dec eax |
jnz read_input_loop |
call draw_text |
jmp still |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; send to modem |
mcall |
shr eax,8 |
cmp eax,178 ; ARROW KEYS |
jne noaup |
mov al,'A' |
call arrow |
jmp still |
noaup: |
cmp eax,177 |
jne noadown |
mov al,'B' |
call arrow |
jmp still |
noadown: |
cmp eax,179 |
jne noaright |
mov al,'C' |
call arrow |
jmp still |
noaright: |
cmp eax,176 |
jne noaleft |
mov al,'D' |
call arrow |
jmp still |
noaleft: |
modem_out: |
mov dx,0x3f8 |
out dx,al |
jmp still |
button: ; BUTTON |
mov eax,17 |
mcall |
cmp ah,1 ; CLOSE PROGRAM |
jne noclose |
mov eax,45 ; FREE IRQ |
mov ebx,1 |
mov ecx,4 |
mcall |
mov eax,46 |
mov ebx,1 |
mov ecx,0x3f0 |
mov edx,0x3ff |
mcall |
or eax,-1 |
mcall |
noclose: |
jmp still |
arrow: |
push eax |
mov al,27 |
call to_modem |
mov al,'[' |
call to_modem |
pop eax |
call to_modem |
ret |
to_modem: |
pusha |
mov dx,0x3f8 |
out dx,al |
mov eax,5 |
mov ebx,5 |
mcall |
popa |
ret |
draw_data: |
pusha |
cmp bl,0xe4 ; Á |
jne noe4 |
mov bl,0xc1 |
noe4: |
cmp bl,0xc4 ; É |
jne noc4 |
mov bl,0xc9 |
noc4: |
mov [eax+text],bl |
mov bl,byte [attribute] |
mov [eax+text+60*80],bl |
popa |
ret |
irqtable: |
dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
set_variables: |
pusha |
mov eax,46 |
mov ebx,0 |
mov ecx,0x3f0 |
mov edx,0x3ff |
mcall |
mov eax,45 ; reserve irq 4 |
mov ebx,0 |
mov ecx,4 |
mcall |
mov eax,44 |
mov ebx,irqtable |
mov ecx,4 |
mcall |
; jmp noportint |
mov dx,0x3f8+3 |
mov al,0x80 |
out dx,al |
mov dx,0x3f8+1 |
mov al,0 |
out dx,al |
mov dx,0x3f8+0 |
mov al,0x30 / 16 |
out dx,al |
mov dx,0x3f8+3 |
mov al,3 |
out dx,al |
mov dx,0x3f8+4 |
mov al,0xB |
out dx,al |
mov dx,0x3f8+1 |
mov al,1 |
out dx,al |
noportint: |
mov eax,40 |
mov ebx,0000000000010000b shl 16 + 111b |
mcall |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
mov eax,0 ; DRAW WINDOW |
mov ebx,100*65536+491 |
mov ecx,100*65536+270 |
mov edx,0x13000000 |
mov edi,title |
mcall |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
draw_text: |
pusha |
mov esi,text |
mov eax,0 |
mov ebx,0 |
newletter: |
mov cl,[esi] |
mov dl,[esi+60*80] |
cmp cl,[esi+30*80] |
jne yesletter |
cmp dl,[esi+90*80] |
jne yesletter |
jmp noletter |
yesletter: |
mov [esi+30*80],cl |
mov [esi+90*80],dl |
pusha |
and edx,0xff |
shl edx,2 |
add edx,bgc |
mov edx,[edx] |
mov ecx,ebx |
add ecx,26 |
shl ecx,16 |
mov cx,9 |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
mov bx,6 |
mov eax,13 |
mcall |
popa |
pusha |
and edx,0xff |
shl edx,2 |
add edx,tc |
mov ecx,[edx] |
push bx |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
pop bx |
add bx,26 |
mov eax,4 |
mov edx,esi |
mov esi,1 |
mcall |
popa |
noletter: |
add esi,1 |
add eax,6 |
cmp eax,80*6 |
jb newletter |
mov eax,0 |
add ebx,10 |
cmp ebx,24*10 |
jb newletter |
popa |
ret |
esc_command: |
mov eax,32 |
mov edi,esccmd |
mov ecx,10 |
cld |
rep stosb |
mov edi,esccmd |
newescc: |
mov eax,42 |
mov ebx,4 |
mcall |
cmp ecx,0 |
je escok |
mov eax,5 |
mov ebx,1 |
mcall |
jmp newescc |
escok: |
mov [edi],bl |
add edi,1 |
cmp edi,esccmd+20 |
je dontunderstand |
mov esi,escend |
nec: |
cmp bl,[esi] |
jz com_ok |
add esi,1 |
cmp [esi],byte 0 |
je newescc |
jmp nec |
com_ok: |
call get_numbers |
cmp bl,'H' ; SET CURSOR POSITION |
jne no_cursor_position |
cmp [escnumbers],0 |
jne ncp1 |
mov [pos],dword 0 |
jmp cmd_done |
ncp1: |
mov eax,[escnumbers] |
dec eax |
imul eax,80 |
add eax,[escnumbers+4] |
dec eax |
mov [pos],eax |
jmp cmd_done |
no_cursor_position: |
cmp bl,'K' ; ERASE LINE |
jne no_erase_end_of_line |
cmp [escnumbers],0 |
jne no_end_line |
mov ecx,[pos] |
eeol: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
add ecx,1 |
xor edx,edx |
mov eax,ecx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne eeol |
jmp cmd_done |
no_end_line: |
cmp [escnumbers],1 ; BEGINNING OF LINE |
jne no_beg_line |
mov ecx,[pos] |
ebol: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
sub ecx,1 |
xor edx,edx |
mov eax,ecx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne ebol |
mov [pos],ecx |
jmp cmd_done |
no_beg_line: |
no_erase_end_of_line: |
cmp bl,'J' ; ERASE TO END OF SCREEN |
jne no_erase_to_end_of_screen |
cmp [escnumbers],dword 0 |
jne no_erase_to_end_of_screen |
mov ecx,[pos] |
eteos: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
add ecx,1 |
cmp ecx,80*24+1 |
jb eteos |
jmp cmd_done |
no_erase_to_end_of_screen: |
cmp bl,'r' ; SET SCROLL REGION |
jne no_scroll_region |
mov eax,[escnumbers] |
dec eax |
mov [scroll+0],eax |
mov eax,[escnumbers+4] |
mov [scroll+4],eax |
jmp cmd_done |
no_scroll_region: |
cmp bl,'A' ; CURSOR UP |
jne no_cursor_up |
mov eax,[pos] |
sub eax,80 |
mov [pos],eax |
jmp cmd_done |
no_cursor_up: |
cmp bl,'C' ; CURSOR LEFT |
jne no_cursor_left |
mov eax,[pos] |
mov ebx,[escnumbers] |
sub eax,ebx |
mov [pos],eax |
call cmd_done |
no_cursor_left: |
cmp bl,'m' ; CHARACTER ATTRIBUTE |
jne no_char_attribute |
mov eax,[escnumbers] |
mov [attribute],eax |
jmp cmd_done |
no_char_attribute: |
cmp bl,'Z' ; TERMINAL TYPE |
jne no_terminal_type |
mov al,27 |
call to_modem |
mov al,'?' |
call to_modem |
mov al,'1' |
call to_modem |
mov al,';' |
call to_modem |
mov al,'0' |
call to_modem |
mov al,'c' |
call to_modem |
jmp cmd_done |
no_terminal_type: |
dontunderstand: |
cmd_done: |
ret |
draw_numbers: |
pusha |
mov eax,13 |
mov ebx,250*65536+100 |
mov ecx,8*65536+8 |
mov edx,0x000000 |
mcall |
mov eax,[escnumbers] |
xor edx,edx |
mov ebx,10 |
div ebx |
add eax,48 |
add edx,48 |
mov byte [numtext+0],al |
mov byte [numtext+1],dl |
mov eax,[escnumbers+4] |
xor edx,edx |
mov ebx,10 |
div ebx |
add eax,48 |
add edx,48 |
mov [numtext+3],al |
mov [numtext+4],dl |
mov eax,4 |
mov ebx,250*65536+8 |
mov ecx,0xffffff |
mov edx,numtext |
mov esi,10 |
mcall |
popa |
ret |
draw_event: |
pusha |
mov eax,13 |
mov ebx,150*65536+100 |
mov ecx,8*65536+8 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,150*65536+8 |
mov ecx,0x000000 |
mov edx,esccmd |
mov esi,20 |
mcall |
popa |
ret |
get_numbers: |
pusha |
mov [escnumbers+0],0 |
mov [escnumbers+4],0 |
mov [escnumbers+8],0 |
mov ecx,esccmd |
cmp [ecx+1],byte '0' |
jb gn_over |
cmp [ecx+1],byte '9' |
jg gn_over |
mov edi,escnumbers |
gn_new: |
add ecx,1 |
movzx eax,byte [ecx] |
sub eax,48 |
add ecx,1 |
cmp [ecx],byte '0' |
jb gnl1 |
cmp [ecx],byte '9' |
jg gnl1 |
mov ebx,10 |
xor edx,edx |
mul ebx |
movzx ebx,byte[ecx] |
add eax,ebx |
sub eax,48 |
add ecx,1 |
gnl1: |
mov [edi],eax |
add edi,4 |
cmp [ecx],byte ';' |
je gn_new |
gn_over: |
popa |
ret |
; DATA AREA |
pos dd 80*10 |
irc_data dd 0x0 |
print db 0x0 |
attribute dd 0 |
scroll dd 1 |
dd 24 |
numtext db ' ' |
esccmd dd 0,0,0,0,0,0,0,0,0,0,0,0,0 |
escend db 'ZrhlABCDHfDME=>NmKJgincoyq',0 |
escnumbers dd 0,0,0,0,0 |
wcolor dd 0x000000 |
title db 'TERMINAL FOR MODEM IN COM1 0.03',0 |
text: |
db ' ' |
db ' ' |
db '*** A TELNET APPLICATION FOR HAYES COMPATIBLE MODEMS IN COM1 ' |
db ' ' |
db '*** USE HAYES COMMANDS TO CONNECT TO A SERVER ' |
db ' ' |
db '*** ATDT (PHONENUMBER) ' |
db ' ' |
db ' ' |
db ' ' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/terminal/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm terminal.asm terminal |
@erase lang.inc |
@pause |
/programs/network_old/terminal/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm terminal.asm terminal |
@erase lang.inc |
@pause |
/programs/network_old/tftpc/trunk/tftpc.asm |
---|
0,0 → 1,977 |
; |
; TFTP Client |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
mcall |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
or eax,-1 ; close this program |
mcall |
noclose: |
cmp ah,2 ; copy file to local machine? |
jnz nocopyl |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from Remote Host to this machine |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x01 ; setup tftp msg |
call copyFromRemote |
jmp still |
nocopyl: |
cmp ah,3 ; Copy file to host? |
jnz nocopyh |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from this machine to Remote Host |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x02 ; setup tftp msg |
call copyToRemote |
jmp still |
nocopyh: |
cmp ah,4 |
jz f1 |
cmp ah,5 |
jz f2 |
jmp nof12 |
f1: |
mov [addr],dword source |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword destination |
mov [ya],dword 35+16 |
rk: |
mov ecx,15 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
mcall ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,15 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+15*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
mcall |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,15 |
mcall |
ret |
nof12: |
jmp still |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the filename and IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The filename, in source, is converted and stored in tftp_filename |
; The host ip, in destination, is converted and stored in tftp_IP |
; |
;*************************************************************************** |
translateData: |
; first, build up the tftp command string. This includes the filename |
; and the transfer protocol |
; First, write 0,0 |
mov al, 0 |
mov edi, tftp_filename |
mov [edi], al |
inc edi |
mov [edi], al |
inc edi |
; Now, write the file name itself, and null terminate it |
mov ecx, 15 |
mov ah, ' ' |
mov esi, source |
td001: |
lodsb |
stosb |
cmp al, ah |
loopnz td001 |
cmp al,ah ; Was the entire buffer full of characters? |
jne td002 |
dec edi ; No - so remove ' ' character |
td002: |
mov [edi], byte 0 |
inc edi |
mov [edi], byte 'O' |
inc edi |
mov [edi], byte 'C' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 'E' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 0 |
mov esi, tftp_filename |
sub edi, esi |
mov [tftp_len], edi |
; Now, convert the typed IP address into a real address |
; No validation is done on the number entered |
; ip addresses must be typed in normally, eg |
; 192.1.45.24 |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [tftp_IP], eax |
; 192.168.24.1 1.1.1.1 1. 9.2.3. |
mov esi, destination |
mov edi, tftp_IP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
ret |
;*************************************************************************** |
; Function |
; copyFromRemote |
; |
; Description |
; |
;*************************************************************************** |
copyFromRemote: |
xor eax, eax |
mov [filesize], eax |
mov eax, I_END + 512 ; This is the point where the file buffer is |
mov [fileposition], eax |
; Get a random # for the local socket port # |
mov eax, 3 |
int 0x40 |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
int 0x40 |
mov [socketNum], eax |
; make sure there is no data in the socket - there shouldn't be.. |
cfr001: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfr001 ; yes, so get it |
; Now, request the file |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
int 0x40 |
cfr002: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
je cfr003 |
cmp eax,2 ; key in buffer ? |
je cfr004 |
cmp eax,3 ; button in buffer ? |
je cfr005 |
; Any data to fetch? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je cfr002 |
push eax ; eax holds # chars |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p3 |
je cfr008 |
mov dword [prompt], p3 |
mov dword [promptlen], p3len - p3 |
call draw_window ; |
cfr008: |
; we have data - this will be a tftp frame |
; read first two bytes - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
pop eax |
; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
cmp bl, 3 |
jne cfrerr |
push eax |
; do data stuff. Read block #. Read data. Send Ack. |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber+1], bl |
cfr007: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
je no_more_data ; no |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov esi, [fileposition] |
mov [esi], bl |
inc dword [fileposition] |
inc dword [filesize] |
jmp cfr007 |
no_more_data: |
; write the block number into the ack |
mov al, [blockNumber] |
mov [ack + 2], al |
mov al, [blockNumber+1] |
mov [ack + 3], al |
; send an 'ack' |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, ackLen - ack |
mov esi, ack |
int 0x40 |
; If # of chars in the frame is less that 516, |
; this frame is the last |
pop eax |
cmp eax, 516 |
je cfr002 |
; Write the file |
mov ebx, writeinfo |
lea esi, [ebx + 20] |
@@: |
lodsb |
test al, al |
jnz @b |
@@: |
dec esi |
cmp byte [esi-1], ' ' |
jnz @b |
mov byte [esi], 0 |
mcall 70, writeinfo |
mov byte [esi], ' ' |
jmp cfrexit |
cfrerr: |
; simple implementation on error - just read all data, and return |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfrerr ; yes, so get it |
jmp cfr006 ; close socket and close app |
cfr003: ; redraw request |
call draw_window |
jmp cfr002 |
cfr004: ; key pressed |
mov eax,2 ; just read it and ignore |
mcall |
jmp cfr002 |
cfr005: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jne cfr002 ; If not, ignore. |
cfr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
mcall |
jmp $ |
cfrexit: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ret |
;*************************************************************************** |
; Function |
; copyToRemote |
; |
; Description |
; |
;*************************************************************************** |
copyToRemote: |
mov eax,6 ; Read file from floppy (image) |
mov ebx,source |
mov ecx,0 |
mov edx,0xffffffff |
mov esi,I_END + 512 |
int 0x40 |
cmp eax,0xffffffff |
jnz filefound |
mov dword [prompt], p6 |
mov dword [promptlen], p6len - p6 |
call draw_window ; |
jmp ctr_exit |
filefound: |
mov [filesize], eax |
; First, set up the file pointers |
mov eax, 0x01000300 |
mov [blockBuffer], eax ; This makes sure our TFTP header is valid |
mov eax, I_END + 512 ; This is the point where the file buffer is |
mov [fileposition], eax |
mov eax, [filesize] |
cmp eax, 512 |
jb ctr000 |
mov eax, 512 |
ctr000: |
mov [fileblocksize], ax |
; Get a random # for the local socket port # |
mov eax, 3 |
int 0x40 |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] |
int 0x40 |
mov [socketNum], eax |
; write to socket ( request write file ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
int 0x40 |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je ctr001 |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p2 |
je ctr002 |
mov dword [prompt], p2 |
mov dword [promptlen], p2len - p2 |
call draw_window ; |
; we have data - this will be the ack |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (low byte ) |
mov [blockNumber+1], bl |
ctr0022: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte (shouldn't have worked) |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr0022 ; yes, so get it, and dump it |
; If the ack is 0, it is to the request |
mov bx, [blockNumber] |
cmp bx, 0 |
je txd |
; now, the ack should be one more than the current field - otherwise, resend |
cmp bx, [blockBuffer+2] |
jne txre ; not the same, so send again |
; update the block number |
mov esi, blockBuffer + 3 |
mov al, [esi] |
inc al |
mov [esi], al |
cmp al, 0 |
jne ctr008 |
dec esi |
inc byte [esi] |
ctr008: |
; Move forward through the file |
mov eax, [fileposition] |
movzx ebx, word [fileblocksize] |
add eax, ebx |
mov [fileposition], eax |
; new .. |
; fs = 0 , fbs = 512 -> send with fbs = 0 |
cmp [filesize],0 |
jne no_special_end |
cmp [fileblocksize],512 |
jne no_special_end |
mov ax,0 |
jmp ctr006 |
no_special_end: |
mov eax, [filesize] |
cmp eax, 0 |
je ctr009 |
cmp eax, 512 |
jb ctr006 |
mov eax, 512 |
ctr006: |
mov [fileblocksize], ax |
txd: |
; Readjust the file size variable ( before sending ) |
mov eax, [filesize] |
movzx ebx, word [fileblocksize] |
sub eax, ebx |
mov [filesize], eax |
txre: |
; Copy the fragment of the file to the block buffer |
movzx ecx, word [fileblocksize] |
mov esi, [fileposition] |
mov edi, I_END |
cld |
rep movsb |
; send the file data |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
movzx edx, word [fileblocksize] |
add edx, 4 |
mov esi, blockBuffer |
int 0x40 |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne ctr001 |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
int 0x40 |
jmp $ |
ctr009: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ctr_exit: |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
mov ecx,100*65536+170 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title |
mcall |
mov eax,8 ; COPY BUTTON |
mov ebx,20*65536+190 |
mov ecx,79*65536+15 |
mov edx,2 |
mov esi,0x557799 |
mcall |
; mov eax,8 ; DELETE BUTTON |
mov ebx,20*65536+190 |
mov ecx,111*65536+15 |
mov edx,3 |
mcall |
; mov eax,8 |
; mov ebx,200*65536+10 |
mov ecx,34*65536+10 |
mov edx,4 |
mcall |
; mov eax,8 |
; mov ebx,200*65536+10 |
mov ecx,50*65536+10 |
mov edx,5 |
mcall |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,source |
mov edi,text+13 |
mov ecx,15 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,destination |
mov edi,text+40+13 |
mov ecx,15 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+280 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
; file name: source |
; file data: I_END + 512 |
; file size: [filesize] |
writeinfo: |
dd 2 |
dd 0 |
dd 0 |
filesize dd 0 ; The number of bytes written / left to write |
dd I_END + 512 |
source db 'KERNEL.ASM ',0 |
destination db '192.168.1.23 ' |
tftp_filename: times 15 + 9 db 0 |
tftp_IP: dd 0 |
tftp_len: dd 0 |
addr dd 0x0 |
ya dd 0x0 |
fileposition dd 0 ; Points to the current point in the file |
fileblocksize dw 0 ; The number of bytes to send in this frame |
text: |
db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
db ' ' |
db ' COPY HOST -> LOCAL ' |
db ' ' |
db ' COPY LOCAL -> HOST ' |
db ' ' |
db ' ' |
db 'x' ; <- END MARKER, DONT DELETE |
title db 'TFTP Client',0 |
prompt: dd 0 |
promptlen: dd 0 |
p1: db 'Waiting for Command' |
p1len: |
p2: db 'Sending File ' |
p2len: |
p3: db 'Receiving File ' |
p3len: |
p4: db 'Tranfer Complete ' |
p4len: |
p5: db 'Contacting Host... ' |
p5len: |
p6: db 'File not found. ' |
p6len: |
ack: |
db 00,04,0,1 |
ackLen: |
socketNum: |
dd 0 |
blockNumber: |
dw 0 |
; This must be the last part of the file, because the blockBuffer |
; continues at I_END. |
blockBuffer: |
db 00, 03, 00, 01 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/tftpc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tftpc.asm tftpc |
@erase lang.inc |
@pause |
/programs/network_old/tftpc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tftpc.asm tftpc |
@erase lang.inc |
@pause |
/programs/network_old/dnsr/trunk/dnsr.asm |
---|
0,0 → 1,785 |
; |
; DNS Domain name -> IP lookup |
; |
; Compile with FASM for Menuet |
; |
; If you like, you camd change the DNS server default by changing the |
; IP address in the dnsServer string. |
; Enabling debugging puts the received response to the |
; debug board |
DEBUGGING_ENABLED equ 1 |
DEBUGGING_DISABLED equ 0 |
DEBUGGING_STATE equ DEBUGGING_DISABLED |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 ; 'waiting for command' |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov eax,0xffffffff ; close this program |
mcall |
noclose: |
cmp ah,3 ; Resolve address? |
jnz noresolve |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 ; display 'Resolving' |
call draw_window |
call translateData ; Convert domain & DNS IP address |
call resolveDomain |
jmp still |
noresolve: |
cmp ah,4 |
jz f1 ; Enter domain name |
cmp ah,5 |
jz f2 ; enter DNS Server IP |
jmp still |
f1: |
mov [addr],dword query |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword dnsServer |
mov [ya],dword 35+16 |
rk: |
mov ecx,26 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
mcall ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,26 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+26*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
mcall |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,26 |
mcall |
ret |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the domain name and DNS IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The ename, in query, is converted and stored in dnsMsg |
; The DNS ip, in dnsServer, is converted and stored in dnsIP |
; |
;*************************************************************************** |
translateData: |
; first, get the IP address of the DNS server |
; Then, build up the request string. |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [dnsIP], eax |
mov esi, dnsServer |
mov edi, dnsIP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
; Build the request string |
mov eax, 0x00010100 |
mov [dnsMsg], eax |
mov eax, 0x00000100 |
mov [dnsMsg+4], eax |
mov eax, 0x00000000 |
mov [dnsMsg+8], eax |
; domain name goes in at dnsMsg+12 |
mov esi, dnsMsg + 12 ; location of label length |
mov edi, dnsMsg + 13 ; label start |
mov edx, query |
mov ecx, 12 ; total string length so far |
td002: |
mov [esi], byte 0 |
inc ecx |
td0021: |
mov al, [edx] |
cmp al, ' ' |
je td001 ; we have finished the string translation |
cmp al, '.' ; we have finished the label |
je td004 |
inc byte [esi] |
inc ecx |
mov [edi], al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi, edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi], byte 0 |
inc ecx |
inc edi |
mov [edi], dword 0x01000100 |
add ecx, 4 |
mov [dnsMsgLen], ecx |
ret |
;*************************************************************************** |
; Function |
; resolveDomain |
; |
; Description |
; Sends a question to the dns server |
; works out the IP address from the response from the DNS server |
; |
;*************************************************************************** |
resolveDomain: |
; Get a free port number |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
mcall |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 53 ; remote port - dns |
mov esi, [dnsIP] |
mcall |
mov [socketNum], eax |
; write to socket ( request DNS lookup ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dnsMsgLen] |
mov esi, dnsMsg |
mcall |
; Setup the DNS response buffer |
mov eax, dnsMsg |
mov [dnsMsgLen], eax |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall |
cmp eax, 0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dnsMsgLen] |
mov [eax], bl |
inc dword [dnsMsgLen] |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
call debug_print_rx_ip |
end if |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0xFFFF |
; Now parse the message to get the host IP |
; Man, this is complicated. It's described in |
; RFC 1035 |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg |
; The end of the buffer is pointed to by [dnsMsgLen] |
; Clear the IP address text |
mov [hostIP], dword 0 |
mov esi, dnsMsg |
; Is this a response to my question? |
mov al, [esi+2] |
and al, 0x80 |
cmp al, 0x80 |
jne ctr002a |
; Were there any errors? |
mov al, [esi+3] |
and al, 0x0F |
cmp al, 0x00 |
jne ctr002a |
; Is there ( at least 1 ) answer? |
mov ax, [esi+6] |
cmp ax, 0x00 |
je ctr002a |
; Header validated. Scan through and get my answer |
add esi, 12 ; Skip to the question field |
; Skip through the question field |
call skipName |
add esi, 4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, |
; find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax, [esi] |
cmp ax, 0x0100 ; Is this the IP address answer? |
jne ctr002c |
; Yes! Point esi to the first byte of the IP address |
add esi, 10 |
mov eax, [esi] |
mov [hostIP], eax |
jmp ctr002a ; And exit... |
ctr002c: ; Skip through the answer, move to the next |
add esi, 8 |
movzx eax, byte [esi+1] |
mov ah, [esi] |
add esi, eax |
add esi, 2 |
; Have we reached the end of the msg? |
; This is an error condition, should not happen |
cmp esi, [dnsMsgLen] |
jl ctr002z ; Check next answer |
jmp ctr002a ; abort |
ctr002a: |
mov dword [prompt], p4 ; Display IP address |
mov dword [promptlen], p4len - p4 |
call draw_window |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
mcall |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
mcall |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0xFFFF |
mov [hostIP], dword 0 |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 ; 'waiting for command' |
call draw_window ; at first, draw the window |
ret |
;*************************************************************************** |
; Function |
; skipName |
; |
; Description |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
; |
;*************************************************************************** |
skipName: |
mov al, [esi] |
cmp al, 0 |
je sn_exit |
and al, 0xc0 |
cmp al, 0xc0 |
je sn001 |
movzx eax, byte [esi] |
inc eax |
add esi, eax |
jmp skipName |
sn001: |
add esi, 2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+140 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL; |
mcall |
mov eax,8 ; Resolve |
mov ebx,20*65536+190 |
mov ecx,79*65536+15 |
mov edx,3 |
mov esi,0x557799 |
mcall |
;mov eax,8 |
mov ebx,270*65536+10 |
mov ecx,34*65536+10 |
inc edx |
mcall |
;mov eax,8 |
mov ebx,270*65536+10 |
mov ecx,50*65536+10 |
inc edx |
mcall |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,query |
mov edi,text+13 |
mov ecx,26 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,dnsServer |
mov edi,text+40+13 |
mov ecx,26 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+200 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
; Write the host IP, if we have one |
mov eax, [hostIP] |
cmp eax, 0 |
je dw001 |
; We have an IP address... display it |
mov edi,hostIP |
mov edx,97*65536+115 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,hostIP+4 |
jb ipdisplay |
dw001: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
mov cl, [esi] |
cmp cl, 0 |
jnz dps_001 |
ret |
dps_001: |
mov eax,63 |
mov ebx, 1 |
push esi |
mcall |
inc word [ind] |
mov ax, [ind] |
and ax, 0x1f |
cmp ax, 0 |
jne ds1 |
mov cl, 13 |
mov eax,63 |
mov ebx, 1 |
mcall |
mov cl, 10 |
mov eax,63 |
mov ebx, 1 |
mcall |
ds1: |
pop esi |
inc esi |
jmp debug_print_string |
ind: dw 0 |
; This is used for translating hex to ASCII for display or output |
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
IP_STR db 'xx',0 |
debug_print_rx_ip: |
pusha |
mov edi, IP_STR |
xor eax, eax |
mov al, bl |
shr al, 4 |
mov ah, [eax + hexchars] |
mov [edi], ah |
inc edi |
xor eax, eax |
mov al, bl |
and al, 0x0f |
mov ah, [eax + hexchars] |
mov [edi], ah |
mov esi, IP_STR |
call debug_print_string |
popa |
ret |
end if |
; DATA AREA |
addr dd 0x0 |
ya dd 0x0 |
text: |
if lang eq ru |
db '¬ï å®áâ : xxxxxxxxxxxxxxx ' |
db 'DNS á¥à¢¥à : xxx.xxx.xxx.xxx ' |
db ' ' |
db ' ®«ãç¨âì ¤à¥á ' |
db ' ' |
db ' ' |
db 'x <- END MARKER, DONT DELETE ' |
else |
db 'Host name : xxxxxxxxxxxxxxx ' |
db 'DNS server : xxx.xxx.xxx.xxx ' |
db ' ' |
db ' RESOLVE ADDRESS ' |
db ' ' |
db ' ' |
db 'x <- END MARKER, DONT DELETE ' |
end if |
if lang eq ru |
title db 'DNS «¨¥â',0 |
else |
title db 'DNS Client',0 |
end if |
prompt: dd 0 |
promptlen: dd 0 |
if lang eq ru |
p1: db '¤ã ª®¬ ¤ë ' |
p1len: |
else |
p1: db 'Waiting for Command ' |
p1len: |
end if |
p4: db 'IP Address: . . . ' |
p4len: |
p5: db 'Resolving... ' |
p5len: |
dnsServer db '194.145.128.1 ' ; iolfree.ie DNS |
query db 'WWW.MENUETOS.NET ' |
hostIP: dd 0 |
dnsIP: dd 0 |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dnsMsg: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/dnsr/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm dnsr.asm dnsr |
@erase lang.inc |
@pause |
/programs/network_old/dnsr/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm dnsr.asm dnsr |
@erase lang.inc |
@pause |
/programs/network_old/netsendc/trunk/netsendc.asm |
---|
0,0 → 1,173 |
; |
; NetSend(Client) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ ¤«ï ®¡¬¥ á®®¡é¥¨ï¬¨ ¢ á¥â¨.«¨¥â᪠ï ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; header version |
dd START ; program start |
dd I_END ; program image size |
dd mem ; required amount of memory |
dd mem ; stack pointer |
dd 0, 0 ; param, icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x4000 ; local port |
mov edx,0x5000 ; remote port |
mov esi,dword [remote_ip] ; node IP |
mcall |
mov [socketNum], eax |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
dec eax |
jz red |
dec eax |
jnz button |
key: |
mov al,2 |
mcall |
jmp still |
button: |
mov al,17 |
mcall |
dec ah ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
or eax,-1 |
mcall |
noclose: |
; it was not close button, so it must be send code button |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND CODE TO REMOTE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_xcode: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,end_message-send_data |
mov esi,send_data |
mcall |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+250 ; [x start] *65536 + [x size] |
mov ecx,60*65536+150 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; SEND MESSAGE |
mov ebx,50*65536+145 |
mov ecx,47*65536+13 |
mov edx,2 |
mov esi,0x667788 |
mcall |
mov eax,4 |
mov ebx,25*65536+50 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,esi |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
if lang eq ru |
text: |
db ' ®á« âì á®®¡é¥¨¥ ' |
db ' ' |
db ' ®ª «ìë© ¤à¥á : 192.168.0.1 ' |
db ' ¤ «ñë© ¤à¥á : 192.168.0.2 ' |
db '¥ªáâ ¨ ¤à¥á ¢ ª®æ¥ ¨á室¨ª ' |
db 'x' ; <- END MARKER, DONT DELETE |
else |
text: |
db ' Send message ' |
db ' ' |
db ' Local address : 192.168.0.1 ' |
db ' Remote address : 192.168.0.2 ' |
db 'Text and address in end of source ' |
db 'x' ; <- END MARKER, DONT DELETE |
end if |
title db 'NetSend(Client)',0 |
remote_ip db 192,168,1,2 |
send_data db 'ਢ¥â,íâ® â¥áâ!Hello,this is a test!' |
end_message: |
I_END: |
align 4 |
socketNum dd ? |
rb 32 ; this is for stack |
mem: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/netsendc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm netsendc.asm netsendc |
@erase lang.inc |
@pause |
/programs/network_old/netsendc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm netsendc.asm netsendc |
@erase lang.inc |
@pause |
/programs/network_old/netsends/trunk/netsends.asm |
---|
0,0 → 1,186 |
; |
; NetSend(Server) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ ¤«ï ®¡¬¥ á®®¡é¥¨ï¬¨ ¢ á¥â¨.¥à¢¥à ï ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include 'macros.inc' |
remote_ip db 192,168,0,1 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x5000 ; local port |
mov edx, 0xffff ; remote port |
mov esi, dword [remote_ip] ; remote IP |
mcall |
mov [socketNum],eax |
mov [0],eax ; save for remote code |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socketNum] |
mcall |
cmp eax,0 |
jne data_arrived |
jmp still |
key: |
mov eax,2 |
mcall |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socketNum] |
mcall |
or eax,-1 |
mcall |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
mcall |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socketNum] |
mcall |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socketNum] |
mcall |
cmp eax,0 |
jne get_data |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,100 |
mcall |
add [y],10 |
jmp still |
y dd 0x10 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+330 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
if lang eq ru |
text: |
db ' ë© ¤à¥á : 192.168.0.2 ' |
db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x5000 ' |
db 'à¨á« ë¥ á®®¡é¥¨ï: ' |
db 'x' ; <- END MARKER, DONT DELETE |
else |
text: |
db 'This address : 192.168.0.2 ' |
db 'Used port : 0x5000 ' |
db 'Received messages: ' |
db 'x' ; <- END MARKER, DONT DELETE |
end if |
title db 'NetSend(Server)',0 |
socketNum dd 0x0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/netsends/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm netsends.asm netsends |
@erase lang.inc |
@pause |
/programs/network_old/netsends/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm netsends.asm netsends |
@erase lang.inc |
@pause |
/programs/network_old/popc/trunk/popc.asm |
---|
0,0 → 1,1019 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; POP CLIENT for MenuetOS ;; |
;; - Modified from IRC client ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2002 (c) Ville Turjanmaa ;; |
;; ;; |
;; Compile with FASM for Menuet ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
include 'macros.inc' |
version equ '0.1' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x200000 ; required amount of memory |
dd 0xffff0 |
dd 0,0 |
START: ; start of execution |
mov [file_start],0x100000 |
mov eax,70 |
mov ebx,filel |
mcall |
test eax,eax |
jz @f |
cmp eax,6 |
jnz notfound |
@@: |
add [file_start],ebx |
notfound: |
mov edi,I_END |
mov ecx,60*120 |
mov al,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
redraw: ; redraw |
call draw_window ; at first, draw the window |
still: |
mov eax,5 |
mov ebx,1 |
mcall |
mov eax,11 ; wait here for event |
mcall |
cmp eax,1 ; redraw |
je redraw |
cmp eax,2 ; key |
je key |
cmp eax,3 ; button |
je button |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_server_data |
no_main_update: |
cmp [server_active],0 |
je noread |
call read_incoming_data |
noread: |
call print_status |
cmp [status],4 |
je send_request |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Save the fetched mails |
;; |
save_file: |
pusha |
mov ebx,files |
mov eax,[file_start] |
sub eax,0x100000 |
mov [ebx+12],eax |
mov eax,70 |
mcall |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Send user id/passwd/mailrq |
;; |
send_request: |
inc [mcounter] |
cmp [mcounter],1000 |
jbe no_send |
mov eax,[ccounter] |
imul eax,32 |
add eax,getmail |
mov esi,eax |
inc [ccounter] |
mov edx,32 |
cmp [ccounter],1 |
jne no1 |
mov edx,5+2 |
add edx,[l2] |
no1: |
cmp [ccounter],2 |
jne no2 |
mov edx,5+2 |
add edx,[l3] |
no2: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mcall |
mov [mcounter],0 |
cmp [esi],dword 'quit' |
je close_fetch |
no_send: |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Close connection to server |
;; |
close_fetch: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,14 |
mov esi,quitc |
mcall |
mov [mcounter],0 |
mov eax,5 |
mov ebx,150 |
mcall |
call read_incoming_data |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,5 |
mov ebx,2 |
mcall |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov [server_active],0 |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; User input processing |
;; |
key: |
mov eax,2 |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,60 |
jne no_open |
mov eax, 70 |
mov ebx, tinypad_start |
mcall |
jmp still |
no_open: |
cmp ah,1 ; close program |
jne noclose |
mov eax,-1 |
mcall |
noclose: |
cmp ah,51 |
je read_string |
cmp ah,52 |
je read_string |
cmp ah,53 |
je read_string |
call socket_commands |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Socket open & close |
;; |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
mov [server_active],1 |
mov [mcounter],900 |
mov [ccounter],0 |
mov eax,3 |
mcall |
mov eax,3 |
mcall |
mov ecx,eax |
and ecx,0xffff |
mov eax,53 |
mov ebx,5 |
mov edx,110 |
mov esi,dword [ip] |
mov edi,1 |
mcall |
mov [socket], eax |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov [header_sent],0 |
mov [mail_rp],0 |
mov [server_active],0 |
ret |
no_24: |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Display connection status |
;; |
old_status dd 0x0 |
print_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
mov [status],eax |
cmp eax,[old_status] |
je nopr |
mov [old_status],eax |
push eax |
mov eax,13 |
mov ebx,200*65536+30 |
mov ecx,160*65536+10 |
mov edx,0xffffff |
mcall |
pop ecx |
cmp [server_active],1 |
jne nopr |
mov eax,47 |
mov ebx,3*65536 |
mov edx,200*65536+160 |
mov esi,0x000000 |
mcall |
nopr: |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Read data from server |
;; |
read_incoming_data: |
pusha |
read_new_byte: |
call read_incoming_byte |
cmp ecx,-1 |
je no_data_in_buffer |
mov eax,[file_start] |
mov [eax],bl |
inc [file_start] |
cmp bl,10 |
jne no_start_command |
mov [cmd],1 |
no_start_command: |
cmp bl,13 |
jne no_end_command |
mov eax,[cmd] |
mov [eax+command-2],byte 0 |
call save_file |
call analyze_data |
mov edi,command |
mov ecx,250 |
mov eax,0 |
cld |
rep stosb |
mov [cmd],0 |
no_end_command: |
mov eax,[cmd] |
cmp eax,250 |
jge still |
mov [eax+command-2],bl |
inc [cmd] |
jmp read_new_byte |
no_data_in_buffer: |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Read user input for ip/user/passwd |
;; |
read_string: |
shr eax,8 |
sub eax,51 |
mov ebx,eax |
imul eax,12 |
add eax,181 |
mov [len],ebx |
shl [len],2 |
add [len],l1 |
imul ebx,50 |
add ebx,input1 |
mov [addr],ebx |
mov [ya],eax |
mov edi,[addr] |
mov eax,0 |
mov ecx,30 |
cld |
rep stosb |
call print_input_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 32 |
call print_text |
jmp f11 |
nobsl: |
mov [edi],al |
call print_input_text |
add edi,1 |
mov esi,[addr] |
add esi,30 |
cmp esi,edi |
jnz f11 |
read_done: |
push edi |
mov ecx,40 |
mov eax,32 |
cld |
rep stosb |
call print_input_text |
pop edi |
sub edi,[addr] |
mov eax,[len] |
mov [eax],edi |
cmp [len],l1 |
jne noip |
mov esi,input1 |
mov edi,ip_text+15 |
mov ecx,16 |
cld |
rep movsb |
call ip_set |
noip: |
cmp [len],l2 |
jne nol2 |
mov esi,input2 |
mov edi,l2_text+15 |
mov ecx,22 |
cld |
rep movsb |
mov esi,input2 |
mov edi,getmail+5 |
mov ecx,[l2] |
cld |
rep movsb |
mov al,13 |
stosb |
mov al,10 |
stosb |
nol2: |
cmp [len],l3 |
jne nol3 |
mov esi,input3 |
mov edi,getmail+32+5 |
mov ecx,[l3] |
cld |
rep movsb |
mov al,13 |
stosb |
mov al,10 |
stosb |
nol3: |
call draw_window |
jmp still |
print_input_text: |
pusha |
mov eax,13 |
mov ebx,95*65536+23*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,9 |
mov edx,0xffffff |
mcall |
cmp [len],l3 |
je noprt |
mov eax,4 |
mov edx,[addr] |
mov ebx,95*65536 |
add ebx,[ya] |
mov ecx,0x000000 |
mov esi,23 |
mcall |
noprt: |
popa |
ret |
ip_set: |
mov esi,input1-1 |
mov edi,ip |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,ip+3 |
jbe ip1 |
ret |
no_read_ip: |
ret |
analyze_data: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
cmp [cmd],2 |
jbe nott |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command+0 |
newcmdc: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc |
nott: |
mov edx,I_END |
call draw_server_data |
cmd_len_ok: |
cmp [command],dword '-ERR' |
je close_fetch |
cmp [command],word '+O' |
jne nook |
mov [mcounter],990 |
nook: |
popa |
ret |
draw_data: |
push eax |
add eax,[text_start] |
mov [eax],bl |
pop eax |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
read_incoming_byte: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
mov ecx,-1 |
cmp eax,0 |
je no_more_data |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
mcall |
mov ecx,0 |
no_more_data: |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Window definitions |
;; |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
mov eax,0 ; draw window |
mov ebx,5*65536+435 |
mov ecx,5*65536+232 |
mov edx,0x14ffffff |
mov edi,labelt |
mcall |
mov [old_status],300 |
mov eax,8 ; button: open socket |
mov ebx,23*65536+22 |
mov ecx,155*65536+10 |
mov edx,22 |
mov esi,0x44cc44 |
mcall |
; mov eax,8 ; button: close socket |
mov ebx,295*65536+22 |
mov ecx,155*65536+10 |
mov edx,24 |
mov esi,0xcc4444 |
mcall |
; mov eax,8 ; button: text entries |
mov ebx,243*65536+8 |
mov ecx,180*65536+8 |
mov edx,51 |
mov esi,0x4488dd |
newi: |
mcall |
inc edx |
add ecx,12*65536 |
cmp edx,53 |
jbe newi |
; mov eax,8 ; open inbox |
mov ebx,295*65536+102 |
mov ecx,190*65536+14 |
mov edx,60 |
mov esi,0x5577dd |
mcall |
mov eax,38 ; line |
mov ebx,5*65536+430 |
mov ecx,114*65536+114 |
mov edx,0x000000 |
mcall |
mov ebx,5*65536+133 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
mcall |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_server_data |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
draw_server_data: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,8 |
mov esi,[rxs] |
dct: |
pusha |
mov ecx,ebx |
shl ecx,16 |
mov cl,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
mcall |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
mcall |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
text: |
db ' Incoming mails are written to /rd/1/popc.txt ' |
db ' ' |
db ' Check for mail. Force close ' |
db ' ' |
ip_text: |
db ' Server IP : 192.168.1.200 < ' |
l2_text: |
db ' User : < Open popc.txt ' |
l3_text: |
db ' Password : (not shown) < ' |
db 'x' ; <- END MARKER, DONT DELETE |
file_start dd 0x100000 |
; max size is 0x100000 bytes, read to/write from 0x100000 |
files: |
dd 2,0,0,?,0x100000 |
db 0 |
dd pr |
filel: |
dd 0,0,0,0x100000,0x100000 |
pr db '/sys/popc.txt',0 |
ip db 192,168,1,200 |
socket dd 0x0 |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
print db 0x0 |
cmd dd 0x0 |
rxs dd 66 |
res: db 0,0 |
command: times 256 db 0x0 |
command_position dd 0 |
counter dd 0 |
numtext db ' ' |
labelt db 'POP client v ',version,0 |
scroll: dd 1,8 |
tinypad_start: |
dd 7 |
dd 0 |
dd pr |
dd 0 |
dd 0 |
db '/sys/TINYPAD',0 |
getmail: |
db 'user xyz ',13,10 |
db 'pass xyz ',13,10 |
db 'retr 1 ',13,10 |
db 'retr 2 ',13,10 |
db 'retr 3 ',13,10 |
db 'retr 4 ',13,10 |
db 'retr 5 ',13,10 |
db 'retr 6 ',13,10 |
db 'retr 7 ',13,10 |
db 'retr 8 ',13,10 |
db 'retr 9 ',13,10 |
quitc: |
db 'quit ',13,10 |
mcounter dd 900 |
ccounter dd 0 |
ld db 13,10 |
server_active db 0 |
header_sent db 0 |
close_connection dd 0x0 |
mail_rp dd 0 |
irc_data dd 0x0 |
addr dd 0x0 |
ya dd 0x0 |
len dd 0x0 |
input1: times 50 db 32 |
input2: times 50 db 32 |
input3: times 50 db 32 |
l1 dd 0 |
l2 dd 3 |
l3 dd 3 |
status dd 0x0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/popc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm popc.asm popc |
@erase lang.inc |
@pause |
/programs/network_old/popc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm popc.asm popc |
@erase lang.inc |
@pause |
/programs/network_old/telnet/trunk/telnet.asm |
---|
0,0 → 1,793 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; TERMINAL |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
; Clear the screen memory |
mov eax, ' ' |
mov edi,text |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_window |
still: |
; check connection status |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
mov ebx, [socket_status] |
mov [socket_status], eax |
cmp eax, ebx |
je waitev |
red: |
call draw_window |
waitev: |
mov eax,23 ; wait here for event |
mov ebx,20 |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
; any data from the socket? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
cmp eax, 0 |
jne read_input |
jmp still |
read_input: |
push ecx |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
mcall |
pop ecx |
call handle_data |
push ecx |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
pop ecx |
cmp eax, 0 |
jne read_input |
call draw_text |
jmp still |
handle_data: |
; Telnet servers will want to negotiate options about our terminal window |
; just reject them all. |
; Telnet options start with the byte 0xff and are 3 bytes long. |
mov al, [telnetstate] |
cmp al, 0 |
je state0 |
cmp al, 1 |
je state1 |
cmp al, 2 |
je state2 |
jmp hd001 |
state0: |
cmp bl, 255 |
jne hd001 |
mov al, 1 |
mov [telnetstate], al |
ret |
state1: |
mov al, 2 |
mov [telnetstate], al |
ret |
state2: |
mov al, 0 |
mov [telnetstate], al |
mov [telnetrep+2], bl |
mov edx, 3 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, telnetrep |
mcall |
ret |
hd001: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
mov eax,[pos] |
mov [eax+text],bl |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
ret |
key: ; KEY |
mov eax,2 ; send to modem |
mcall |
mov ebx, [socket_status] |
cmp ebx, 4 ; connection open? |
jne still ; no, so ignore key |
shr eax,8 |
cmp eax,178 ; ARROW KEYS |
jne noaup |
mov al,'A' |
call arrow |
jmp still |
noaup: |
cmp eax,177 |
jne noadown |
mov al,'B' |
call arrow |
jmp still |
noadown: |
cmp eax,179 |
jne noaright |
mov al,'C' |
call arrow |
jmp still |
noaright: |
cmp eax,176 |
jne noaleft |
mov al,'D' |
call arrow |
jmp still |
noaleft: |
modem_out: |
call to_modem |
jmp still |
button: ; BUTTON |
mov eax,17 |
mcall |
cmp ah,1 ; CLOSE PROGRAM |
jne noclose |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
or eax,-1 |
mcall |
noclose: |
cmp ah, 2 ; Set IP |
jne notip |
mov [string_x], dword 78 |
mov [string_y], dword 276 |
mov [string_length], dword 15 |
call read_string |
mov esi,string-1 |
mov edi,ip_address |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,ip_address+3 |
jbe ip1 |
call draw_window |
jmp still |
notip: |
cmp ah, 3 ; set port |
jne notport |
mov [string_x], dword 215 |
mov [string_y], dword 276 |
mov [string_length], dword 4 |
call read_string |
mov esi,string-1 |
mov edi,port |
xor eax,eax |
ip11: |
inc esi |
cmp [esi],byte '0' |
jb ip21 |
cmp [esi],byte '9' |
jg ip21 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip11 |
ip21: |
mov [edi],al |
inc edi |
mov [edi],ah |
call draw_window |
jmp still |
notport: |
cmp ah, 4 ; connect |
jne notcon |
mov eax, [socket_status] |
cmp eax, 4 |
je still |
call connect |
jmp still |
notcon: |
cmp ah,5 ; disconnect |
jne notdiscon |
call disconnect |
jmp still |
notdiscon: ; Echo Toggle |
cmp ah, 6 |
jne still |
mov al, [echo] |
not al |
mov [echo], al |
call draw_window |
jmp still |
arrow: |
push eax |
mov al,27 |
call to_modem |
mov al,'[' |
call to_modem |
pop eax |
call to_modem |
ret |
to_modem: |
pusha |
push ax |
mov [tx_buff], al |
mov edx, 1 |
cmp al, 13 |
jne tm_000 |
mov edx, 2 |
tm_000: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, tx_buff |
mcall |
pop bx |
mov al, [echo] |
cmp al, 0 |
je tm_001 |
push bx |
call handle_data |
pop bx |
cmp bl, 13 |
jne tm_002 |
mov bl, 10 |
call handle_data |
tm_002: |
call draw_text |
tm_001: |
popa |
ret |
disconnect: |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
ret |
connect: |
pusha |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
mcall |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
mov eax,53 |
mov ebx,5 |
mov dl, [ip_address + 3] |
shl edx, 8 |
mov dl, [ip_address + 2] |
shl edx, 8 |
mov dl, [ip_address + 1] |
shl edx, 8 |
mov dl, [ip_address] |
mov esi, edx |
movzx edx, word [port] ; telnet port id |
mov edi,1 ; active open |
mcall |
mov [socket], eax |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
xor eax,eax ; DRAW WINDOW |
mov ebx,100*65536+491 + 8 +15 |
mov ecx,100*65536+270 + 20 ; 20 for status bar |
mov edx,0x14000000 |
mov edi,title |
mcall |
; draw status bar |
mov eax, 13 |
mov ebx, 4*65536+484 + 8 +15 |
mov ecx, 270*65536 + 3 |
mov edx, 0x00557799 |
mcall |
mov eax,8 ; BUTTON 2: SET IP |
mov ebx,4*65536+70 |
mov ecx,273*65536+12 |
mov esi, 0x00557799 |
mov edx,2 |
mcall |
mov eax,4 ; Button text |
mov ebx,6*65536+276 |
mov ecx,0x00ffffff |
mov edx,setipt |
mov esi,setiplen-setipt |
mcall |
mov eax,47 |
mov edi,ip_address ; display IP address |
mov edx,78*65536+276 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
movzx ecx,byte [edi] |
mcall |
add edx,6*4*65536 |
inc edi |
cmp edi,ip_address+4 |
jb ipdisplay |
mov eax,8 ; BUTTON 3: SET PORT |
mov ebx,173*65536+38 |
mov ecx,273*65536+12 |
mov edx,3 |
mov esi, 0x00557799 |
mcall |
mov eax,4 ; Button text |
mov ebx,178*65536+276 |
mov ecx,0x00ffffff |
mov edx,setportt |
mov esi,setportlen-setportt |
mcall |
mov edx,216*65536+276 ; display port |
mov esi,0x00ffffff |
mov ebx,4*65536 |
mov eax,47 |
movzx ecx,word [port] |
mcall |
mov eax,8 ; BUTTON 4: Connect |
mov ebx,250*65536+50 |
mov ecx,273*65536+12 |
mov esi, 0x00557799 |
mov edx,4 |
mcall |
mov eax,4 ; Button text |
mov ebx,255*65536+276 |
mov ecx,0x00ffffff |
mov edx,cont |
mov esi,conlen-cont |
mcall |
mov eax,8 ; BUTTON 5: disconnect |
mov ebx,303*65536+70 |
mov ecx,273*65536+12 |
mov edx,5 |
mov esi, 0x00557799 |
mcall |
mov eax,4 ; Button text |
mov ebx,307*65536+276 |
mov ecx,0x00ffffff |
mov edx,dist |
mov esi,dislen-dist |
mcall |
mov esi,contlen-contt ; display connected status |
mov edx, contt |
mov eax, [socket_status] |
cmp eax, 4 ; 4 is connected |
je pcon |
mov esi,discontlen-discontt |
mov edx, discontt |
pcon: |
mov eax,4 ; status text |
mov ebx,380*65536+276 |
mov ecx,0x00ffffff |
mcall |
mov eax,8 ; BUTTON 6: echo |
mov ebx,460*65536+50 |
mov ecx,273*65536+12 |
mov edx,6 |
mov esi, 0x00557799 |
mcall |
mov edx,echot |
mov esi,echolen-echot |
mov al, [echo] |
cmp al, 0 |
jne peo |
mov edx,echoot |
mov esi,echoolen-echoot |
peo: |
mov eax,4 ; Button text |
mov ebx,463*65536+276 |
mov ecx,0x00ffffff |
mcall |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
draw_text: |
pusha |
mov esi,text |
mov eax,0 |
mov ebx,0 |
newletter: |
mov cl,[esi] |
cmp cl,[esi+30*80] |
jne yesletter |
jmp noletter |
yesletter: |
mov [esi+30*80],cl |
; erase character |
pusha |
mov edx, 0 ; bg colour |
mov ecx, ebx |
add ecx, 26 |
shl ecx, 16 |
mov cx, 9 |
mov ebx, eax |
add ebx, 6 |
shl ebx, 16 |
mov bx, 6 |
mov eax, 13 |
mcall |
popa |
; draw character |
pusha |
mov ecx, 0x00ffffff |
push bx |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
pop bx |
add bx,26 |
mov eax,4 |
mov edx,esi |
mov esi,1 |
mcall |
popa |
noletter: |
add esi,1 |
add eax,6 |
cmp eax,80*6 |
jb newletter |
mov eax,0 |
add ebx,10 |
cmp ebx,24*10 |
jb newletter |
popa |
ret |
read_string: |
mov edi,string |
mov eax,'_' |
mov ecx,[string_length] |
inc ecx |
cld |
rep stosb |
call print_text |
mov edi,string |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,string |
jz f11 |
sub edi,1 |
mov [edi],byte '_' |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,string |
add esi,[string_length] |
cmp esi,edi |
jnz f11 |
read_done: |
call print_text |
ret |
print_text: |
pusha |
mov eax,13 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_length] |
imul bx,6 |
mov ecx,[string_y] |
shl ecx,16 |
mov cx,8 |
mov edx,0x00000000 |
mcall |
mov eax,4 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_y] |
mov ecx,0x00ffffff |
mov edx,string |
mov esi,[string_length] |
mcall |
popa |
ret |
; DATA AREA |
telnetrep db 0xff,0xfc,0x00 |
telnetstate db 0 |
string_length dd 16 |
string_x dd 200 |
string_y dd 60 |
string db '________________' |
tx_buff db 0, 10 |
ip_address db 001,002,003,004 |
port db 0,0 |
echo db 0 |
socket dd 0x0 |
socket_status dd 0x0 |
pos dd 80 * 1 |
scroll dd 1 |
dd 24 |
wcolor dd 0x000000 |
title db 'Telnet v0.1',0 |
setipt db 'IP Address: . . .' |
setiplen: |
setportt db 'Port:' |
setportlen: |
cont db 'Connect' |
conlen: |
dist db 'Disconnect' |
dislen: |
contt db 'Connected' |
contlen: |
discontt db 'Disconnected' |
discontlen: |
echot db 'Echo On' |
echolen: |
echoot db 'Echo Off' |
echoolen: |
text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/telnet/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm telnet.asm telnet |
@erase lang.inc |
@pause |
/programs/network_old/telnet/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm telnet.asm telnet |
@erase lang.inc |
@pause |
/programs/network_old/arpstat/trunk/arpstat.asm |
---|
0,0 → 1,416 |
; |
; ARP Status Monitor |
; |
; Compile with FASM for Menuet |
; |
; This program displays the ARP table, and it's settings |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include '..\..\..\macros.inc' |
purge mov ; decrease kpack'ed size |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,200 ; Time out after 2s |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
; read the stack status data, and write it to the screen buffer |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 200 |
mcall |
push eax |
mov ebx, text + 24 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 201 |
mcall |
mov ebx, text + 64 |
call printhex |
; Fill the table with blanks |
mov edi, text + 160 |
doBlank: |
mov esi, blank |
mov ecx, 40 |
rep movsb |
cmp edi, text + 560 |
jne doBlank |
pop ecx ; The number of entries |
mov ebx, text+ 160 +1 ; the position for the first IP address line |
xor edx, edx ; edx is index into the ARP table |
cmp ecx, 10 |
jle show_entries |
mov ecx, 10 |
; The following code is not very efficient; Sorry about that. |
; ARPSTAT is a debugging tool, so I didn't want to put much effort in |
show_entries: |
; Ecx now holds the number of entries to populate. |
; Ebx holds the place to put the data |
; edx is a counter |
cmp ecx, 0 |
je red |
push ecx |
push edx |
push ebx |
; select the arp table entry (in edx) |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 202 |
mcall |
; Read the IP address |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 203 |
mcall |
; IP in eax. Get the address to put it back |
pop ebx |
push ebx |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
; Now display the 6 byte MAC |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 204 |
mcall |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 20 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 16 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 28 |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 24 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 205 |
mcall |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
; Now display the stat field |
inc ebx |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 206 |
mcall |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
; Now display the TTL field (this is intel word format) |
inc ebx |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 207 |
mcall |
pop ebx |
mov ecx, eax |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
pop ebx |
add ebx, 40 |
pop edx |
inc edx |
pop ecx |
dec ecx |
jmp show_entries |
red: ; redraw |
call draw_window |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz still |
mov eax,0xffffffff ; close this program |
mcall |
writeDecimal: |
pusha |
and eax, 0xff |
mov dl, 100 |
div dl |
movzx ecx, ah |
add al, '0' |
mov [ebx], al |
inc ebx |
mov eax, ecx |
mov dl, 10 |
div dl |
add ax, '00' |
mov [ebx], ax |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+280 ; [x start] *65536 + [x size] |
mov ecx,100*65536+270 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,esi |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; Taken from PS.ASM |
printhex: |
; number in eax |
; print to ebx |
; xlat from hextable |
pusha |
mov esi, ebx |
add esi, 8 |
mov ebx, hextable |
mov ecx, 8 |
phex_loop: |
mov edx, eax |
and eax, 15 |
xlatb |
mov [esi], al |
mov eax, edx |
shr eax, 4 |
dec esi |
loop phex_loop |
popa |
ret |
; DATA AREA |
text: |
db ' Number of ARP entries: xxxxxxxx ' |
db ' Maximum # of entries : xxxxxxxx ' |
db ' ' |
db ' IP Address MAC Stat TTL ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db 'x' ; <- END MARKER, DONT DELETE |
blank: |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
title db 'ARP Table ( First 10 Entries )',0 |
hextable db '0123456789ABCDEF' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/arpstat/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm arpstat.asm arpstat |
@erase lang.inc |
@pause |
/programs/network_old/arpstat/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm arpstat.asm arpstat |
@erase lang.inc |
@pause |
/programs/network_old/chess/trunk/chess.asm |
---|
0,0 → 1,1301 |
; |
; CHESS CLIENT for CHESSCLUB.COM (VT) |
; |
; Compile with FASM for Menuet |
; |
appname equ 'Chess Client for Chessclub.com ' |
version equ '0.2' |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd 0x100000 ; required memory |
dd 0x100000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
pawn_color: |
dd 0x000000 |
dd 0x222222 |
dd 0x444444 |
dd 0xf0f0f0 |
dd 0xc0c0c0 |
dd 0xa0a0a0 |
dd 0xa0a0a0 |
dd 0x707070 |
dd 0xb0b0b0 |
dd 0xc0c0c0 |
dd 0xd0d0d0 |
dd 0xd8d8d8 |
dd 0xe0e0e0 |
dd 0xe8e8e8 |
dd 0x00ff00 |
dd 0xffffff |
texts equ board_old+80*30 |
text equ texts+80*32*4 |
START: ; start of execution |
mov esi,chess_bmp |
mov edi,0x10000+18*3 |
mov ebx,0 |
mov ecx,0 |
newp: |
xor eax,eax |
mov al,[esi] |
and al,0xf0 |
shr al,4 |
shl eax,2 |
mov eax,[pawn_color+eax] |
mov [edi+0],eax |
xor eax,eax |
mov al,[esi] |
and al,0x0f |
shl eax,2 |
mov eax,[pawn_color+eax] |
mov [edi+3],eax |
add edi,6 |
add esi,1 |
inc ebx |
cmp ebx,23 |
jbe newp |
sub edi,12 |
mov ebx,0 |
inc ecx |
cmp ecx,279 |
jb newp |
; Clear the screen memory |
mov eax, ' ' |
mov edi,text |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_window |
still: |
call check_for_board |
call board_changed |
call draw_board |
; check connection status |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
mov ebx, [socket_status] |
mov [socket_status], eax |
cmp eax, ebx |
je waitev |
call display_status |
waitev: |
mov eax,23 ; wait here for event |
mov ebx,20 |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
; any data from the socket? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
cmp eax, 0 |
jne read_input |
jmp still |
read_input: |
push ecx |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
mcall |
pop ecx |
call handle_data |
push ecx |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
pop ecx |
cmp eax, 0 |
jne read_input |
call draw_text |
jmp still |
check_for_board: |
pusha |
mov esi,text-80 |
news: |
add esi,80 |
cmp esi,text+80*10 |
je board_not_found |
cmp [esi+12],dword '----' |
je cfb1 |
jmp news |
cfb1: |
cmp [esi+16*80+12],dword '----' |
je cfb2 |
jmp news |
cfb2: |
cmp [esi+2*80+12],dword '+---' |
jne news |
cmp [esi+4*80+12],dword '+---' |
jne news |
board_found: |
mov edi,chess_board |
mov ecx,80*18 |
cld |
rep movsb |
board_not_found: |
popa |
ret |
yst dd 150 |
textx equ 10 |
ysts equ 410 |
boardx dd 45 |
boardy dd 45 |
boardxs dd 44 |
boardys dd 44 |
conx equ 420 |
cony equ 118 |
dconx equ 420 |
dcony equ 148 |
statusx equ 420 |
statusy equ 178 |
drsq: |
push eax ebx |
mov ecx,ebx |
mov ebx,eax |
mov eax,ebx |
add eax,ecx |
imul ebx,[boardxs] |
add ebx,[boardx] |
shl ebx,16 |
imul ecx,[boardys] |
add ecx,[boardy] |
shl ecx,16 |
add ebx,[boardxs] |
add ecx,[boardys] |
mov edx,[sq_black] |
test eax,1 |
jnz dbl22 |
mov edx,[sq_white] |
dbl22: |
mov eax,13 |
mcall |
pop ebx eax |
ret |
draw_pawn: |
; edi,0 ; white / black |
; esi,0 ; from position 2 , 20 square |
; eax,2 ; board x |
; ebx,0 ; board y |
pusha |
call drsq |
cmp esi,20 |
jne no_sqd |
popa |
ret |
no_sqd: |
imul eax,[boardxs] |
imul ebx,[boardys] |
add eax,[boardx] |
add ebx,[boardy] |
imul esi,44*45*3 |
add esi,0x10000+18*3 |
mov ecx,43 |
dp0: |
pusha |
mov ecx,44 |
ldp1: |
pusha |
mov ecx,ebx |
mov ebx,eax |
mov edx,[esi] |
and edx,0xffffff |
mov eax,1 |
cmp edx,0x00ff00 |
je nowp |
cmp edi,1 |
jne nobl |
shr edx,1 |
and edx,0x7f7f7f |
nobl: |
mcall |
nowp: |
popa |
add esi,3 |
add eax,1 |
dec ecx |
jnz ldp1 |
popa |
add ebx,1 |
add esi,3*44 |
dec ecx |
jnz dp0 |
popa |
ret |
board_changed: |
pusha |
mov eax,0 |
mov esi,chess_board |
bcl1: |
add eax,[esi] |
add esi,4 |
cmp esi,chess_board+19*80 |
jb bcl1 |
cmp eax,[checksum] |
je bcl2 |
mov [changed],1 |
bcl2: |
mov [checksum],eax |
popa |
ret |
checksum dd 0 |
changed db 1 |
draw_board: |
pusha |
cmp [changed],1 |
jne no_change_in_board |
mov [changed],0 |
mov eax,0 |
mov ebx,0 |
scan_board: |
push eax ebx |
mov esi,ebx |
imul esi,2 |
imul esi,80 |
add esi,80 |
imul eax,4 |
add eax,10 |
add esi,eax |
movzx edx,word [chess_board+esi] |
cmp dx,[board_old+esi] |
je empty_slot |
mov ecx,13 |
newseek2: |
mov edi,ecx |
imul edi,8 |
sub edi,8 |
cmp dx,[edi+nappulat] |
je foundnappula2 |
loop newseek2 |
jmp empty_slot |
foundnappula2: |
mov esi,[edi+nappulat+4] |
mov edi,0 |
cmp dl,'*' |
jne nnbb |
mov edi,1 |
nnbb: |
mov eax,[esp+4] |
mov ebx,[esp] |
call draw_pawn |
empty_slot: |
pop ebx eax |
inc eax |
cmp eax,8 |
jb scan_board |
mov eax,0 |
inc ebx |
cmp ebx,8 |
jb scan_board |
mov esi,chess_board |
mov edi,board_old |
mov ecx,80*19 |
cld |
rep movsb |
mov eax,13 |
mov ebx,[boardx] |
sub ebx,14 |
shl ebx,16 |
add ebx,8 |
mov ecx,[boardy] |
shl ecx,16 |
add ecx,46*8 |
mov edx,[wcolor] |
mcall |
mov eax,4 ; numbers at left |
mov ebx,[boardx] |
sub ebx,14 |
shl ebx,16 |
add ebx,[boardy] |
add ebx,18 |
mov ecx,[tcolor] |
mov edx,chess_board+80+5 |
mov esi,3 |
db1: |
mcall |
add edx,80*2 |
add ebx,[boardxs] |
cmp edx,chess_board+80*16 |
jb db1 |
mov eax,13 |
mov ebx,[boardx] |
shl ebx,16 |
add ebx,8*46 |
mov ecx,[boardys] |
imul ecx,8 |
add ecx,[boardy] |
add ecx,8 |
shl ecx,16 |
add ecx,10 |
mov edx,[wcolor] |
mcall |
mov eax,4 ; letters at bottom |
mov ebx,[boardx] |
add ebx,3 |
shl ebx,16 |
mov bx,word [boardys] |
imul bx,8 |
add ebx,[boardy] |
add ebx,8 |
mov ecx,[tcolor] |
mov edx,chess_board+80*17+8 |
mov esi,4 |
db3: |
mcall |
mov edi,[boardxs] |
shl edi,16 |
add ebx,edi |
add edx,4 |
cmp edx,chess_board+80*17+8+4*8 |
jb db3 |
; print player times |
mov edi,74 |
cmp [chess_board+80+5],byte '1' |
jne nowww2 |
mov edi,371 |
nowww2: |
mov eax,13 |
mov ebx,(conx)*65536+100 |
mov ecx,edi |
shl ecx,16 |
add ecx,10 |
mov edx,[wcolor] |
mcall |
mov eax,4 |
mov ebx,(conx)*65536 |
add ebx,edi |
mov ecx,[tcolor] |
mov edx,chess_board+80*7+59-1 |
mov esi,20 |
mcall |
mov edi,74 |
cmp [chess_board+80+5],byte '1' |
je nowww |
mov edi,371 |
nowww: |
mov eax,13 |
mov ebx,(conx)*65536+100 |
mov ecx,edi |
shl ecx,16 |
add ecx,10 |
mov edx,[wcolor] |
mcall |
mov eax,4 |
mov ebx,(conx)*65536 |
add ebx,edi |
mov ecx,[tcolor] |
mov edx,chess_board+80*9+59-1 |
mov esi,20 |
mcall |
; move # |
mov eax,13 |
mov ebx,conx*65536+120 |
mov ecx,200*65536+10 |
mov edx,[wcolor] |
mcall |
mov eax,4 |
mov ebx,conx*65536 |
add ebx,200 |
mov ecx,[tcolor] |
mov edx,chess_board+80*1+46 |
mov esi,30 |
mcall |
no_change_in_board: |
popa |
ret |
handle_data: |
; Telnet servers will want to negotiate options about our terminal window |
; just reject them all. |
; Telnet options start with the byte 0xff and are 3 bytes long. |
mov al, [telnetstate] |
cmp al, 0 |
je state0 |
cmp al, 1 |
je state1 |
cmp al, 2 |
je state2 |
jmp hd001 |
state0: |
cmp bl, 255 |
jne hd001 |
mov al, 1 |
mov [telnetstate], al |
ret |
state1: |
mov al, 2 |
mov [telnetstate], al |
ret |
state2: |
mov al, 0 |
mov [telnetstate], al |
mov [telnetrep+2], bl |
mov edx, 3 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, telnetrep |
mcall |
ret |
hd001: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
call check_for_board |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,9 ; TAB |
jne notab |
add [pos],dword 8 |
jmp newdata |
notab: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
mov eax,[pos] |
mov [eax+text],bl |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
ret |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; send to modem |
mcall |
mov ebx, [socket_status] |
cmp ebx, 4 ; connection open? |
jne still ; no, so ignore key |
shr eax,8 |
cmp eax,178 ; ARROW KEYS |
jne noaup |
mov al,'A' |
call arrow |
jmp still |
noaup: |
cmp eax,177 |
jne noadown |
mov al,'B' |
call arrow |
jmp still |
noadown: |
cmp eax,179 |
jne noaright |
mov al,'C' |
call arrow |
jmp still |
noaright: |
cmp eax,176 |
jne noaleft |
mov al,'D' |
call arrow |
jmp still |
noaleft: |
modem_out: |
call to_modem |
jmp still |
button: ; BUTTON |
mov eax,17 |
mcall |
cmp ah,1 ; CLOSE PROGRAM |
jne noclose |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,-1 |
mcall |
noclose: |
cmp ah, 4 ; connect |
jne notcon |
mov eax, [socket_status] |
cmp eax, 4 |
je still |
call connect |
jmp still |
notcon: |
cmp ah,5 ; disconnect |
jne notdiscon |
call disconnect |
jmp still |
notdiscon: |
jmp still |
arrow: |
push eax |
mov al,27 |
call to_modem |
mov al,'[' |
call to_modem |
pop eax |
call to_modem |
ret |
to_modem: |
pusha |
push ax |
mov [tx_buff], al |
mov edx, 1 |
cmp al, 13 |
jne tm_000 |
mov edx, 2 |
tm_000: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, tx_buff |
mcall |
pop bx |
mov al, [echo] |
cmp al, 0 |
je tm_001 |
push bx |
call handle_data |
pop bx |
cmp bl, 13 |
jne tm_002 |
mov bl, 10 |
call handle_data |
tm_002: |
call draw_text |
tm_001: |
popa |
ret |
disconnect: |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
ret |
connect: |
pusha |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
mcall |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
mov eax,53 |
mov ebx,5 |
mov dl, [ip_address + 3] |
shl edx, 8 |
mov dl, [ip_address + 2] |
shl edx, 8 |
mov dl, [ip_address + 1] |
shl edx, 8 |
mov dl, [ip_address] |
mov esi, edx |
movzx edx, word [port] ; telnet port id |
mov edi,1 ; active open |
mcall |
mov [socket], eax |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
mov eax,14 |
mcall |
mov ebx,eax |
mov ecx,eax |
shr ebx,16 |
and ebx,0xffff |
and ecx,0xffff |
shr ebx,1 |
shr ecx,1 |
sub ebx,275 |
sub ecx,235 |
shl ebx,16 |
shl ecx,16 |
mov eax,0 ; DRAW WINDOW |
mov bx,550 |
mov cx,470 |
mov edx,[wcolor] |
add edx,0x14000000 |
mov edi,title |
mcall |
call display_status |
mov eax,8 ; BUTTON 4: Connect |
mov ebx,conx*65536+80 |
mov ecx,cony*65536+15 |
mov esi,[wbutton] |
mov edx,4 |
mcall |
mov eax,4 ; Button text |
mov ebx,(conx+4)*65536+cony+4 |
mov ecx,0xffffff |
mov edx,cont |
mov esi,conlen-cont |
mcall |
mov eax,8 ; BUTTON 5: disconnect |
mov ebx,dconx*65536+80 |
mov ecx,dcony*65536+15 |
mov edx,5 |
mov esi,[wbutton] |
mcall |
mov eax,4 ; Button text |
mov ebx,(dconx+4)*65536+dcony+4 |
mov ecx,0x00ffffff |
mov edx,dist |
mov esi,dislen-dist |
mcall |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov [changed],1 |
mov edi,board_old |
mov ecx,80*19 |
mov al,0 |
cld |
rep stosb |
mov eax,4 |
mov ebx,conx*65536+52 |
mov ecx,[tcolor] |
mov edx,quick_start |
mov esi,30 |
prqs: |
mcall |
add ebx,10 |
add edx,30 |
cmp [edx],byte 'x' |
jne prqs |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
display_status: |
pusha |
; draw status bar |
mov eax, 13 |
mov ebx, statusx*65536+80 |
mov ecx, statusy*65536 + 16 |
mov edx, [wcolor] |
mcall |
mov esi,contlen-contt ; display connected status |
mov edx, contt |
mov eax, [socket_status] |
cmp eax, 4 ; 4 is connected |
je pcon |
mov esi,discontlen-discontt |
mov edx, discontt |
pcon: |
mov eax,4 ; status text |
mov ebx,statusx*65536+statusy+2 |
mov ecx,[tcolor] |
mcall |
popa |
ret |
nappulat: |
dd '*P ',5 |
dd '*K ',3 |
dd '*Q ',4 |
dd '*R ',0 |
dd '*N ',1 |
dd '*B ',2 |
dd ' ',20 |
dd 'P ',5 |
dd 'K ',3 |
dd 'Q ',4 |
dd 'R ',0 |
dd 'N ',1 |
dd 'B ',2 |
row dd 0x0 |
col dd 0x0 |
draw_text: |
mov esi,text+80*24 |
mov edi,texts+80*3 |
dtl1: |
cmp [esi],dword 'logi' |
je add_text |
cmp [esi],dword 'aics' |
je add_text |
cmp [esi],dword 'You ' |
je add_text |
cmp [esi],dword 'Your' |
je add_text |
cmp [esi],dword 'Game' |
je add_text |
cmp [esi],dword 'Ille' |
je add_text |
cmp [esi],dword 'No s' |
je add_text |
sub esi,80 |
cmp esi,text |
jge dtl1 |
dtl2: |
mov eax,13 |
mov ebx,10*65536+532 |
mov ecx,420*65536+40 |
mov edx,[wtcom] |
mcall |
mov eax,4 |
mov ebx,10*65536+420 |
mov ecx,[wtxt] |
mov edx,texts |
mov esi,80 |
dtl3: |
mcall |
add edx,80 |
add ebx,10 |
cmp edx,texts+4*80 |
jb dtl3 |
ret |
add_text: |
pusha |
cld |
mov ecx,80 |
rep movsb |
popa |
sub esi,80 |
sub edi,80 |
cmp edi,texts |
jb dtl2 |
jmp dtl1 |
read_string: |
mov edi,string |
mov eax,'_' |
mov ecx,[string_length] |
inc ecx |
cld |
rep stosb |
call print_text |
mov edi,string |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,string |
jz f11 |
sub edi,1 |
mov [edi],byte '_' |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,string |
add esi,[string_length] |
cmp esi,edi |
jnz f11 |
read_done: |
call print_text |
ret |
print_text: |
pusha |
mov eax,13 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_length] |
imul bx,6 |
mov ecx,[string_y] |
shl ecx,16 |
mov cx,8 |
mov edx,[wcolor] |
mcall |
mov eax,4 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_y] |
mov ecx,[tcolor] |
mov edx,string |
mov esi,[string_length] |
mcall |
popa |
ret |
; DATA AREA |
telnetrep db 0xff,0xfc,0x00 |
telnetstate db 0 |
string_length dd 16 |
string_x dd 200 |
string_y dd 60 |
string db '________________' |
tx_buff db 0, 10 |
ip_address db 204,178,125,65 |
port dw 5051 ; 0,0 |
echo db 1 |
socket dd 0x0 |
socket_status dd 0x0 |
pos dd 80 * 22 |
scroll dd 1 |
dd 24 |
wbutton dd 0x336688 |
wtcom dd 0x336688 ; 0x666666 |
wtxt dd 0xffffff |
wcolor dd 0xe0e0e0 |
tcolor dd 0x000000 |
sq_black dd 0x336688 ; 666666 |
sq_white dd 0xffffff |
title db appname,version,0 |
setipt db ' . . .' |
setiplen: |
setportt db ' ' |
setportlen: |
cont db 'Connect' |
conlen: |
dist db 'Disconnect' |
dislen: |
contt db 'Connected' |
contlen: |
discontt db 'Disconnected' |
discontlen: |
echot db 'Echo On' |
echolen: |
echoot db 'Echo Off' |
echoolen: |
quick_start: |
db '( OPPONENT ) ' |
times 16 db ' 1' |
db 'Quick start: ' |
db ' ' |
db '1 Connect ' |
db '2 login: "guest" ' |
db '3 aics% "seek 10 0" ' |
db ' (for a player) ' |
db ' (wait) ' |
db '4 Play eg. "e7e5" ' |
db ' or "d2d4" ' |
db '5 aics% "resign" ' |
db ' (quit game) ' |
db '6 Disconnect ' |
times 5 db ' ' |
db '( YOU ) ' |
db 'x' |
chess_board: |
times 80 db 0 |
db ' 8 *R *N *B *Q *K *B *N *R' |
db ' ' |
times 80 db 0 |
db ' 7 *P *P *P *P *P *P *P *P' |
db ' ' |
times 80 db 0 |
db ' 6 ' |
db ' ' |
times 80 db 0 |
db ' 5 ' |
db ' ' |
times 80 db 0 |
db ' 4 ' |
db ' ' |
times 80 db 0 |
db ' 3 ' |
db ' ' |
times 80 db 0 |
db ' 2 P P P P P P P P ' |
db ' ' |
times 80 db 0 |
db ' 1 R N B Q K B N R ' |
db ' ' |
times 80 db 0 |
db ' a b c d e f g h ' |
db ' ' |
times 80*20 db 0 |
chess_bmp: |
file 'chess.bmp':22*3+4+24*2 |
board_old: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/chess/trunk/chess.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/network_old/chess/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm chess.asm chess |
@erase lang.inc |
@pause |
/programs/network_old/chess/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm chess.asm chess |
@erase lang.inc |
@pause |
/programs/network_old/dhcp/trunk/dhcp.asm |
---|
0,0 → 1,582 |
; |
; DHCP Client |
; |
; Compile with FASM for Menuet |
; |
include 'lang.inc' |
include '..\..\..\macros.inc' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd I_END+0x8000 ; memory for app |
dd I_END+0x8000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
red: ; redraw |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov eax,0xffffffff ; close this program |
mcall |
noclose: |
cmp ah,3 ; Resolve address? |
jnz still |
call draw_window |
call contactDHCPServer |
jmp still |
;*************************************************************************** |
; Function |
; parseResponse |
; |
; Description |
; extracts the fields ( client IP address and options ) from |
; a DHCP response |
; The values go into |
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, |
; dhcpDNSIP, dhcpSubnet |
; The message is stored in dhcpMsg |
; |
;*************************************************************************** |
parseResponse: |
mov edx, dhcpMsg |
mov eax, [edx+16] |
mov [dhcpClientIP], eax |
; Scan options |
add edx, 240 ; Point to first option |
pr001: |
; Get option id |
mov al, [edx] |
cmp al, 0xff ; End of options? |
je pr_exit |
cmp al, 53 ; Msg type is a single byte option |
jne pr002 |
mov al, [edx+2] |
mov [dhcpMsgType], al |
add edx, 3 |
jmp pr001 ; Get next option |
pr002: |
; All other (accepted) options are 4 bytes in length |
inc edx |
movzx ecx, byte [edx] |
inc edx ; point to data |
cmp al, 54 ; server id |
jne pr0021 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpServerIP], eax |
jmp pr003 |
pr0021: |
cmp al, 51 ; lease |
jne pr0022 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpLease], eax |
jmp pr003 |
pr0022: |
cmp al, 1 ; subnet mask |
jne pr0023 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpSubnet], eax |
jmp pr003 |
pr0023: |
cmp al, 6 ; dns ip |
jne pr0024 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpDNSIP], eax |
pr0024: |
cmp al, 3 ; gateway ip |
jne pr003 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpGateway], eax |
pr003: |
add edx, ecx |
jmp pr001 |
pr_exit: |
ret |
;*************************************************************************** |
; Function |
; buildRequest |
; |
; Description |
; Creates a DHCP request packet. |
; |
;*************************************************************************** |
buildRequest: |
; Clear dhcpMsg to all zeros |
xor eax,eax |
mov edi,dhcpMsg |
mov ecx,512 |
cld |
rep stosb |
mov edx, dhcpMsg |
mov [edx], byte 0x01 ; Boot request |
mov [edx+1], byte 0x01 ; Ethernet |
mov [edx+2], byte 0x06 ; Ethernet h/w len |
mov [edx+4], dword 0x11223344 ; xid |
mov [edx+10], byte 0x80 ; broadcast flag set |
mov [edx+236], dword 0x63538263 ; magic number |
; option DHCP msg type |
mov [edx+240], word 0x0135 |
mov al, [dhcpMsgType] |
mov [edx+240+2], al |
; option Lease time = infinity |
mov [edx+240+3], word 0x0433 |
mov eax, [dhcpLease] |
mov [edx+240+5], eax |
; option requested IP address |
mov [edx+240+9], word 0x0432 |
mov eax, [dhcpClientIP] |
mov [edx+240+11], eax |
; option request list |
mov [edx+240+15], word 0x0437 |
mov [edx+240+17], dword 0x0f060301 |
; Check which msg we are sending |
cmp [dhcpMsgType], byte 0x01 |
jne br001 |
; "Discover" options |
; end of options marker |
mov [edx+240+21], byte 0xff |
mov [dhcpMsgLen], dword 262 |
jmp br_exit |
br001: |
; "Request" options |
; server IP |
mov [edx+240+21], word 0x0436 |
mov eax, [dhcpServerIP] |
mov [edx+240+23], eax |
; end of options marker |
mov [edx+240+27], byte 0xff |
mov [dhcpMsgLen], dword 268 |
br_exit: |
ret |
;*************************************************************************** |
; Function |
; contactDHCPServer |
; |
; Description |
; negotiates settings with a DHCP server |
; |
;*************************************************************************** |
contactDHCPServer: |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov ecx, 68 ; local port dhcp client |
mov edx, 67 ; remote port - dhcp server |
mov esi, 0xffffffff ; broadcast |
mcall |
mov [socketNum], eax |
; Setup the first msg we will send |
mov [dhcpMsgType], byte 0x01 ; DHCP discover |
mov [dhcpLease], dword 0xffffffff |
mov [dhcpClientIP], dword 0 |
mov [dhcpServerIP], dword 0 |
call buildRequest |
ctr000: |
; write to socket ( send broadcast request ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dhcpMsgLen] |
mov esi, dhcpMsg |
mcall |
; Setup the DHCP buffer to receive response |
mov eax, dhcpMsg |
mov [dhcpMsgLen], eax ; Used as a pointer to the data |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall |
cmp eax, 0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dhcpMsgLen] |
mov [eax], bl |
inc dword [dhcpMsgLen] |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; depending on which msg we sent, handle the response |
; accordingly. |
; If the response is to a dhcp discover, then: |
; 1) If response is DHCP OFFER then |
; 1.1) record server IP, lease time & IP address. |
; 1.2) send a request packet |
; 2) else exit ( display error ) |
; If the response is to a dhcp request, then: |
; 1) If the response is DHCP ACK then |
; 1.1) extract the DNS & subnet fields. Set them in the stack |
; 2) else exit ( display error ) |
cmp [dhcpMsgType], byte 0x01 ; did we send a discover? |
je ctr007 |
cmp [dhcpMsgType], byte 0x03 ; did we send a request? |
je ctr008 |
; should never get here - we only send discover or request |
jmp ctr006 |
ctr007: |
call parseResponse |
; Was the response an offer? It should be |
cmp [dhcpMsgType], byte 0x02 |
jne ctr006 ; NO - so quit |
; send request |
mov [dhcpMsgType], byte 0x03 ; DHCP request |
call buildRequest |
jmp ctr000 |
ctr008: |
call parseResponse |
; Was the response an ACK? It should be |
cmp [dhcpMsgType], byte 0x05 |
jne ctr006 ; NO - so quit |
; Set or display addresses here... |
ctr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0xFFFF |
call draw_window |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
mcall |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
mcall |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0xFFFF |
call draw_window ; at first, draw the window |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
; Pass in the IP address in edi |
; row to display in [ya] |
drawIP: |
; mov edi,hostIP |
mov ecx, edi |
add ecx, 4 |
mov edx,[ya] |
add edx, 97*65536 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
push ecx |
movzx ecx,byte [edi] |
mcall |
pop ecx |
add edx,6*4*65536 |
inc edi |
cmp edi,ecx |
jb ipdisplay |
ret |
drawDHMS: |
mov eax,[edi] |
bswap eax |
mov esi,dhms |
mov ecx,16 |
mov edi,text+40*4+12 |
cmp eax,0xffffffff |
jne nforever |
mov esi,forever |
cld |
rep movsb |
ret |
nforever: |
cld |
rep movsb |
mov ecx,28 |
xor edx,edx |
mov ebx,60 |
div ebx |
call displayDHMS |
xor edx,edx |
div ebx |
call displayDHMS |
xor edx,edx |
mov ebx,24 |
div ebx |
call displayDHMS |
mov edx,eax |
call displayDHMS |
ret |
displayDHMS: |
pusha |
mov eax,47 |
mov ebx,3*65536 |
mov edx,ecx |
imul edx,6 |
shl edx,16 |
add edx,1*65536+99 |
mov ecx,[esp+20] |
mov esi,0xffffff |
mcall |
popa |
sub ecx,4 |
ret |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+156 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; Resolve |
mov ebx,20*65536+90 |
mov ecx,127*65536+15 |
mov edx,3 |
mov esi,0x557799 |
mcall |
; Pass in the IP address in edi |
; row to display in [ya] |
mov edi, dhcpClientIP |
mov eax, 35 |
mov [ya], eax |
call drawIP |
mov edi, dhcpGateway |
mov eax, 35 + 16 |
mov [ya], eax |
call drawIP |
mov edi, dhcpSubnet |
mov eax, 35 + 32 |
mov [ya], eax |
call drawIP |
mov edi, dhcpDNSIP |
mov eax, 35 + 48 |
mov [ya], eax |
call drawIP |
mov edi, dhcpLease |
call drawDHMS |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
ya dd 0x0 |
text: |
db 'Client IP : . . . ' |
db 'Gateway IP: . . . ' |
db 'Subnet : . . . ' |
db 'DNS IP : . . . ' |
db 'Lease Time: d h m s ' |
db ' ' |
db ' SEND REQUEST ' |
db 'x <- END MARKER, DONT DELETE ' |
dhms db ' d h m s' |
forever db 'Forever ' |
title db 'DHCP Client Test',0 |
dhcpMsgType: db 0 |
dhcpLease: dd 0 |
dhcpClientIP: dd 0 |
dhcpServerIP: dd 0 |
dhcpDNSIP: dd 0 |
dhcpSubnet: dd 0 |
dhcpGateway: dd 0 |
dhcpMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dhcpMsg: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/dhcp/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm dhcp.asm dhcp |
@erase lang.inc |
@pause |
/programs/network_old/dhcp/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm dhcp.asm dhcp |
@erase lang.inc |
@pause |
/programs/network_old/ethstat/trunk/ethstat.asm |
---|
0,0 → 1,218 |
; |
; Stack Status Monitor |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,200 ; Time out after 2s |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
; read the stack status data, and write it to the screen buffer |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 6 |
mcall |
mov ebx, text + 24 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 2 |
mcall |
mov ebx, text + 107 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 5 |
mcall |
mov ebx, text + 107 + 40 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 4 |
mcall |
mov ebx, text + 107 + 80 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 100 |
mcall |
mov ebx, text + 258 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 101 |
mcall |
mov ebx, text + 258 + 40 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 102 |
mcall |
mov ebx, text + 258 + 80 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 103 |
mcall |
mov ebx, text + 258 + 120 |
call printhex |
red: ; redraw |
call draw_window |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz still |
or eax,-1 ; close this program |
mcall |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
xor eax,eax ; function 0 : define and draw window |
mov ebx,100*65536+260 ; [x start] *65536 + [x size] |
mov ecx,100*65536+205 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; Taken from PS.ASM |
printhex: |
; number in eax |
; print to ebx |
; xlat from hextable |
pusha |
mov esi, ebx |
add esi, 8 |
mov ebx, hextable |
mov ecx, 8 |
phex_loop: |
mov edx, eax |
and eax, 15 |
xlatb |
mov [esi], al |
mov eax, edx |
shr eax, 4 |
dec esi |
loop phex_loop |
popa |
ret |
; DATA AREA |
text: |
db ' Ethernet card status : xxxxxxxx ' |
db ' ' |
db ' IP packets received : xxxxxxxx ' |
db ' ARP packets received : xxxxxxxx ' |
db ' Dumped received packets : xxxxxxxx ' |
db ' ' |
db ' EMPTY QUEUE : xxxxxxxx ' |
db ' IPOUT QUEUE : xxxxxxxx ' |
db ' IPIN QUEUE : xxxxxxxx ' |
db ' NET1OUT QUEUE : xxxxxxxx ' |
db 'x <- END MARKER, DONT DELETE ' |
title db 'Stack Status',0 |
hextable db '0123456789ABCDEF' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/ethstat/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ethstat.asm ethstat |
@pause |
/programs/network_old/ethstat/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ethstat.asm ethstat |
@pause |
/programs/network_old/ipc/trunk/ipc.asm |
---|
0,0 → 1,412 |
; |
; Example for Inter Process Communication |
; |
; Compile with FASM for Menuet |
; |
include 'lang.inc' |
include '..\..\..\macros.inc' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x60000 ; memory for app |
dd 0x60000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,60 ; IPC |
mov ebx,1 ; define receive area |
mov ecx,received_messages ; pointer to start |
mov edx,1000 ; size of area |
mcall |
mov eax,40 ; WANTED EVENTS |
mov ebx,01000111b ; IPC 7 + defaults |
mcall |
mov [received_messages+8],dword 0*256+0 |
mov [received_messages+12],dword 0 |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,50 |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
cmp eax,7 ; IPC ? |
jne no_ipc |
call display_ipc_messages |
jmp still |
no_ipc: |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
mcall |
noclose: |
cmp ah,2 |
jne no_read |
call read_string |
movzx eax,byte [message] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+3] |
add eax,ebx |
sub eax,48 |
mov [PID],eax |
mov eax,60 ; IPC |
mov ebx,2 ; send message |
mov ecx,[PID] |
mov edx,message+4 |
mov esi,20;[message_size] |
mcall |
jmp still |
no_read: |
cmp ah,3 |
jne no_messages_pop ; pop the first out |
call ipc_message_pop |
jmp still |
no_messages_pop: |
jmp still |
ipc_message_pop: |
pusha |
cmp [received_messages+4],dword 8 |
je already_empty |
mov [received_messages],byte 1 ; lock the area |
push dword [received_messages+4] |
mov ecx,[received_messages+12] |
sub [received_messages+4],ecx |
sub [received_messages+4],dword 8 |
mov edi,received_messages+8 |
mov esi,edi |
add esi,ecx |
add esi,8 |
pop ecx |
cld |
rep movsb |
call display_ipc_messages |
mov [received_messages],byte 0 ; free the area |
already_empty: |
popa |
ret |
display_ipc_messages: |
pusha |
mov eax,13 |
mov ebx,25*65536+245 |
mov ecx,105*65536+90 |
mov edx,0xdddddd |
mcall |
cmp [received_messages+4],dword 8 ; empty list |
je ipma1 |
mov ebx,25*65536+105 ; draw info text with function 4 |
mov ecx,0x224466 |
mov edx,received_messages+8 |
mov esi,40 |
mov [counter],0 |
newline2: |
pusha |
mov ecx,[edx] |
and ecx,0xfff |
mov edx,ebx |
mov eax,47 |
mov ebx,4*65536 |
mov esi,0xff0000 |
mcall |
popa |
pusha |
mov esi,20 |
add edx,8 |
add ebx,30*65536 |
mov eax,4 |
mcall |
popa |
add ebx,10 |
mov edi,[edx+4] |
add edi,8 |
and edi,0xfff |
add edx,edi |
mov edi,[received_messages+4] |
add edi,received_messages |
cmp edx,edi |
jge ipma1 |
inc [counter] |
cmp [counter],8 |
jbe newline2 |
ipma1: |
popa |
ret |
counter dd 0x0 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+290 ; [x start] *65536 + [x size] |
mov ecx,100*65536+220 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB,8->color gl |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,9 |
mov ebx,process_info |
mov ecx,-1 |
mcall |
mov eax,47 |
mov ebx,4*65536 |
mov ecx,[process_info+30] |
mov edx,180*65536+35 |
mov esi,0x000000 |
mcall |
mov eax,8 ; MESSAGE |
mov ebx,25*65536+87 |
mov ecx,50*65536+16 |
mov edx,2 |
mov esi,0x5588dd |
mcall |
;mov eax,8 ; POP |
mov ebx,216*65536+53 |
mov ecx,80*65536+16 |
mov edx,3 |
mcall |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x224466 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jne newline |
call display_ipc_messages |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
read_string: |
pusha |
mov [addr],dword message |
mov [ya],55 |
mov [xa],120 |
mov ecx,20 |
mov edi,[addr] |
mov al,' ' |
cld |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jz fbu |
exit_readkey: |
popa |
ret |
fbu: |
mov eax,2 |
mcall ; get key |
shr eax,8 |
cmp eax,13 |
je exit_readkey |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
dec edi |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,31 |
jbe f11 |
cmp eax,95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,[addr] |
add esi,20 |
cmp esi,edi |
jnz f11 |
popa |
ret |
print_text: |
mov eax,13 |
mov ebx,[xa] |
shl ebx,16 |
add ebx,25*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,[xa] |
shl ebx,16 |
add ebx,[ya] |
mov ecx,0x000000 |
mov edx,[addr] |
mov esi,25 |
mcall |
ret |
; DATA AREA |
ya dd 0x0 |
xa dd 0x0 |
addr dd 0x0 |
text: |
db 'PROCESS ID FOR THIS APP : ' |
db ' ' |
db ' PID:MESSAGE 0130 EXAMPLE MESSAGE ' |
db ' ' |
db ' ' |
db 'RECEIVED: POP ' |
db 'x' ; <- END MARKER, DONT DELETE |
title db 'IPC - START AT LEAST 2',0 |
I_END: |
PID: dd 0x0 |
message_size: dd 20 |
received_messages: |
db 0 ; lock byte |
db 0,0,0 ; reserved |
dd 8 ; pointer to free msg position from received_messages |
; Sender PID |
; Msg length |
; Msg data |
rb 0x1000 |
message: times 70 db ? |
process_info: times 256 dd ? |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/ipc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ipc.asm ipc |
@erase lang.inc |
@pause |
/programs/network_old/ipc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ipc.asm ipc |
@erase lang.inc |
@pause |
/programs/network_old/local/trunk/local.asm |
---|
0,0 → 1,507 |
; |
; Remote processing example (local node) |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x2000 ; local port |
mov edx,0x3000 ; remote port |
mov esi,dword [host_ip] ; node IP |
mcall |
mov [socketNum], eax |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
mov eax, 53 ; get data |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall |
cmp eax, 0 |
jne read |
jmp still |
key: |
mov eax,2 |
mcall |
jmp still |
button: |
mov eax,17 |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov eax,-1 |
mcall |
noclose: |
cmp ah,2 ; SEND CODE ? |
je send_xcode |
cmp ah,3 ; LEFT COORDINATES ? |
jne no_left |
mov [picture_position],0 |
mov dword [send_data+15],dword STARTX |
mov dword [send_data+19],dword 4 |
mov esi,send_data |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov [I_END+23],dword -20 |
mov eax,53 |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + 4 |
mov esi,I_END |
mcall |
jmp still |
no_left: |
cmp ah,4 ; RIGHT COORDINATES ? |
jne no_right |
mov [picture_position],128 |
mov dword [send_data+15],dword STARTX |
mov dword [send_data+19],dword 4 |
mov esi,send_data |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov [I_END+23],dword -20 + 128 |
mov eax,53 |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + 4 |
mov esi,I_END |
mcall |
jmp still |
no_right: |
cmp ah,5 ; SEND EXECUTE ? |
je send_execute |
jmp still |
xx dd 0 |
yy dd 0 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND CODE TO REMOTE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_xcode: |
mov dword [send_data+15],dword 0x80000 |
mov dword [send_data+19],dword remote_code_end - remote_code_start |
mov esi,send_data ; header |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov esi,remote_code ; remote_code_start ; data |
mov edi,I_END+23 |
mov ecx,remote_code_end - remote_code_start |
cld |
rep movsb |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + remote_code_end - remote_code_start |
mov esi,I_END |
mcall |
jmp still |
send_execute: |
mov dword [execute+15],dword draw_fractal |
mov eax,53 ; START EXECUTE AT REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,19 |
mov esi,execute |
mcall |
mov edi,3 |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; READ ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
read: |
cfr007: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
shl edx,8 |
mov dl,bl |
dec edi |
jnz cok |
mov edi,3 |
and edx,0xffffff |
mov eax,1 |
mov ebx,[xx] |
mov ecx,[yy] |
add ebx,15 |
add ecx,35 |
add ebx,[picture_position] |
mcall |
inc [xx] |
cmp [xx],dword 128 |
jb cok |
mov [xx],0 |
inc [yy] |
cmp [yy],dword 128 |
jb cok |
mov [yy],0 |
cok: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne cfr007 ; yes, so get it |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+286 ; [x start] *65536 + [x size] |
mov ecx,60*65536+330 ; [y start] *65536 + [y size] |
mov edx,0x04ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; SEND CODE |
mov ebx,60*65536+160 |
mov ecx,181*65536+13 |
mov edx,2 |
mov esi,0x667788 |
mcall |
;mov eax,8 ; LEFT |
mov ebx,60*65536+75 |
mov ecx,197*65536+13 |
mov edx,3 |
mcall |
;mov eax,8 ; RIGHT |
mov ebx,148*65536+72 |
mov ecx,197*65536+13 |
mov edx,4 |
mcall |
;mov eax,8 ; SEND EXECUTE |
mov ebx,60*65536+160 |
mov ecx,213*65536+13 |
mov edx,5 |
mcall |
cld |
mov eax,4 |
mov ebx,25*65536+185 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
text: |
db ' 1) SEND CODE ' |
db ' 2) LEFT RIGHT ' |
db " 3) SEND 'EXECUTE' " |
db ' ' |
db ' LOCAL : 192.168.1.26 ' |
db ' REMOTE : 192.168.1.22 ' |
db ' REMOTE CODE AT THE END OF THIS FILE ' |
db 'x' ;<- END MARKER, DONT DELETE |
title db 'CLUSTER LOCAL',0 |
socketNum dd 0x0 |
host_ip db 192,168,1,22 |
picture_position dd 0x0 |
send_data db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 1 ; 14 send |
dd 0x0 ; 15 position |
dd 0x0 ; 19 size |
; 23 |
execute db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 2 ; 14 execute |
dd 0x0 ; 15 position |
; 19 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; REMOTE CODE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
remote_code: |
org 0x80000 |
remote_code_start: |
PIXWIDTH equ 129 |
PIXHEIGHT equ 129 |
ZOOMLIMIT equ 13 |
DELTA equ 200 |
THRESHOLD equ 7 |
STARTSCALE equ 6 |
CHAR_COLOR equ 0fh |
STARTX dd -20 |
STARTY dd 10 |
scaleaddy dd 60 |
scaleaddx dd 100 |
draw_fractal: |
pusha |
movzx ebp,word [STARTX] |
movzx edi,word [STARTY] |
mov cx, PIXHEIGHT ; height of screen in pixels |
sub di,cx ; adjust our Y offset |
@@CalcRow: |
push cx |
mov cx, PIXWIDTH -1 ; width of screen in pixels |
sub bp,cx ; |
@@CalcPixel: |
push cx ; save the column counter on stack |
xor cx, cx ; clear out color loop counter |
xor bx, bx ; zero i coefficient |
xor dx, dx ; zero j coefficient |
@@CycleColors: |
push dx ; save j value for later |
mov ax, bx ; ax = i |
sub ax, dx ; ax = i - j |
add dx, bx ; dx = i + j |
stc ; one additional shift, please |
call Shifty ; ax = ((i+j)*(i-j)) shifted right |
pop dx ; retrieve our saved value for j |
add ax,bp ; account for base offset... |
cmp ah,THRESHOLD ; Q: is i > THRESHOLD * 256? |
xchg bx,ax ; now swap new i with old i |
jg @@draw ; Y: draw this pixel |
clc ; no additional shifts here, please |
call Shifty ; now dx:ax = old i * j |
xchg dx,ax ; |
add dx,di ; account for base offset... |
inc cl ; increment color |
jnz @@CycleColors ; keep going until we're done |
@@draw: |
xchg ax, cx ; mov color into al |
pop cx ; retrieve our column counter |
pop dx ; fetch row (column already in cx) |
push dx ; must leave a copy on the stack |
xor bx,bx ; write to video page zero |
call store_pixel |
inc bp |
loop @@CalcPixel |
inc di |
pop cx |
loop @@CalcRow |
call return_data |
popa |
ret |
Shifty: |
push cx |
db 0b1h |
scale db STARTSCALE |
adc cl,0 |
imul dx |
xchg ax,dx |
shl eax,16 |
xchg ax,dx |
shr eax,cl |
pop cx |
ret |
pixel_pos: dd data_area |
store_pixel: |
pusha |
mov ebx,[pixel_pos] |
shl eax,3 |
and eax,0xff |
mov [ebx],eax |
add dword [pixel_pos],dword 3 |
popa |
ret |
return_data: |
mov ecx,128 * 128/16 |
mov esi,data_area |
sd: |
pusha |
mov eax,53 ; use the socket provided by host |
mov ebx,4 |
mov ecx,[0] |
mov edx,3*16 |
mcall |
mov eax,5 |
mov ebx,1 |
mcall |
popa |
add esi,3*16 |
loop sd |
ret |
data_area: |
remote_code_end: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/local/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm local.asm local |
@erase lang.inc |
@pause |
/programs/network_old/local/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm local.asm local |
@erase lang.inc |
@pause |
/programs/network_old/mp3s/trunk/mp3s.asm |
---|
0,0 → 1,782 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; Tiny MP3 Shoutcast Server v0.1 (vt) ; |
; ; |
; Compile with FASM for Menuet ; |
; ; |
; Listening to port 8008 ; |
; Connect with eg: 192.168.1.22:8008 ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.3' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; program start |
dd I_END ; program image size |
dd 0x80000 ; memory usage |
dd 0x20000 ; stack |
dd 0,0 |
include 'lang.inc' |
include '..\..\..\macros.inc' |
; 0x0+ program image |
; 0x1ffff stack |
; 0x20000 work area for file read |
; 0x40000+ file send buffer ( 100 kb ) |
START: ; start of execution |
mov [status],0 |
call clear_input |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,2 |
mcall |
call check_events |
call check_connection_status |
cmp [status],4 |
je start_transmission |
jmp still |
check_events: |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
ret |
red: ; redraw |
call draw_window |
ret |
key: |
mov eax,2 ; Just read it and ignore |
mcall |
ret |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; close |
jne no_close |
mov eax,-1 |
mcall |
no_close: |
cmp ah,2 ; button id=2 ? |
jnz tst3 |
; open socket |
mov eax,53 |
mov ebx,5 |
mov ecx,8008 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
mov [posy],1 |
mov [posx],0 |
mov [read_on],1 |
call check_for_incoming_data |
call draw_window |
ret |
tst3: |
cmp ah,4 |
je close_socket |
cmp ah,6 |
je close_socket |
jmp no_socket_close |
close_socket: |
mov edx,eax |
; Close socket |
mov eax, 53 |
mov ebx, 8 |
mov ecx, [socket] |
mcall |
mov esp,0x1fff0 |
cmp dh,6 |
je read_string |
jmp still |
no_socket_close: |
cmp ah,9 |
jne no_bps_add |
add [bps],8*1000 |
call draw_window |
ret |
no_bps_add: |
cmp ah,8 |
jne no_bps_sub |
sub [bps],8*1000 |
call draw_window |
ret |
no_bps_sub: |
ret |
clear_input: |
mov edi,input_text |
mov eax,0 |
mov ecx,60*40 |
cld |
rep stosb |
ret |
read_string: |
mov [addr],dword filename |
mov [ya],dword 95 |
mov edi,[addr] |
mov eax,32 |
mov ecx,30 |
cld |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jne read_done |
mov eax,2 |
mcall |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 32 |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,30 |
cmp esi,edi |
jnz f11 |
read_done: |
mov ecx,40 |
mov eax,0 |
cld |
rep movsb |
call print_text |
jmp still |
print_text: |
pusha |
mov eax,13 |
mov ebx,56*65536+30*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov edx,[addr] |
mov ebx,56*65536 |
add ebx,[ya] |
mov ecx,0x000000 |
mov esi,30 |
mcall |
popa |
ret |
wait_for dd 0x0 |
transmission_start dd 0x0 |
sentbytes dd 0x0 |
start_transmission: |
call clear_input |
mov eax,5 |
mov ebx,50 |
mcall |
call check_for_incoming_data |
call draw_window |
call send_header |
mov [fileinfo+4],dword 0 ; start from beginning |
mov [read_to],0x40000 |
mov [playpos],0x40000 |
mov ecx,1024 / 512 |
new_buffer: |
mov eax,[read_to] |
mov ebx,1 |
call read_file |
loop new_buffer |
newpart: |
call check_connection_status |
call draw_window |
mov eax,26 |
mov ebx,9 |
mcall |
mov [transmission_start],eax |
mov [sentbytes],0 |
newblock: |
mov eax,[read_to] |
mov ebx,2 |
call read_file |
wait_more: |
mov eax,26 |
mov ebx,9 |
mcall |
cmp eax,[wait_for] |
jge nomw |
mov eax,5 |
mov ebx,1 |
mcall |
jmp wait_more |
nomw: |
add eax,2 |
mov [wait_for],eax |
mov eax,11 |
mcall |
call check_events |
mov eax,53 |
mov ebx,255 |
mov ecx,103 |
mcall |
cmp eax,0 |
jne wait_more |
; write to socket |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[playadd] |
mov esi,[playpos] |
mcall |
add [sentbytes],edx |
mov esi,[playpos] |
add esi,[playadd] |
mov edi,0x40000 |
mov ecx,110000 / 4 |
cld |
rep movsd |
mov eax,[playadd] |
sub [read_to],eax |
call check_for_incoming_data |
call show_progress |
call check_rate |
mov eax, 53 |
mov ebx, 6 |
mov ecx, [socket] |
mcall |
cmp eax,4 |
jne end_stream |
cmp [read_to],0x40000 |
jge newblock |
end_stream: |
; Close socket |
mov eax, 53 |
mov ebx, 8 |
mov ecx, [socket] |
mcall |
mov eax,5 |
mov ebx,5 |
mcall |
; Open socket |
mov eax,53 |
mov ebx,5 |
mov ecx,8008 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
mov [posy],1 |
mov [posx],0 |
mov [read_on],0 |
call draw_window |
jmp still |
check_rate: |
pusha |
mov eax,[bps] |
xor edx,edx |
mov ebx,8*100 |
div ebx |
shl eax,1 |
mov [playadd],eax |
mov eax,26 |
mov ebx,9 |
mcall |
sub eax,[transmission_start] |
shr eax,1 |
imul eax,[playadd] |
mov edx,0x00dd00 |
cmp [sentbytes],eax |
jge sendok |
sub eax,20000 |
cmp [sentbytes],eax ; a long buffer underrun correction |
jge no_buffer_overrun ; actually leads to overrun |
mov [sentbytes],eax |
no_buffer_overrun: |
add [playadd],150 |
mov edx,0xdd0000 |
sendok: |
mov eax,13 |
mov ebx,320*65536+10 |
mov ecx,105*65536+10 |
mcall |
mov eax,47 |
mov ebx,4*65536 |
mov ecx,[playadd] |
mov edx,322*65536+106 |
mov esi,0x000000 |
; mcall |
popa |
ret |
show_progress: |
pusha |
mov eax,13 |
mov ebx,236*65536+10*6 |
mov ecx,107*65536+8 |
mov edx,0xffffff |
mcall |
mov ecx,[fileinfo+4] |
imul ecx,512 |
mov eax,47 ; file read |
mov ebx,9*65536 |
mov edx,236*65536+107 |
mov esi,0x000000 |
mcall |
popa |
ret |
playpos dd 0x100000 |
playadd dd 256000 / 8 / 100 |
send_header: |
pusha |
mov [playpos],0x40000 |
mov esi,fileinfo+5*4 |
mov edi,transname |
mov ecx,30 |
cld |
rep movsb |
mov eax, 53 |
mov ebx, 7 |
mov ecx, [socket] |
mov edx, headere-headers |
mov esi, headers |
mcall |
popa |
ret |
read_file: |
cmp [read_to],0x40000+2000 |
jg cache_ok |
mov [read_on],1 |
cache_ok: |
cmp [read_to],0x40000+95500 |
jg no_read_1 |
mov [fileinfo+12],eax |
mov [fileinfo+8],ebx |
mov eax,58 |
mov ebx,fileinfo |
mcall |
cmp eax,0 |
jne no_read_1 |
mov eax,[fileinfo+8] |
add [fileinfo+4],eax |
add [read_to],512*2 |
ret |
no_read_1: |
mov [read_on],0 |
ret |
check_for_incoming_data: |
pusha |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
cmp eax,0 |
je _ret_now |
new_data: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
cmp eax,0 |
je _ret |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
mcall |
cmp bl,10 |
jne no_lf |
inc [posy] |
mov [posx],0 |
jmp new_data |
no_lf: |
cmp bl,20 |
jb new_data |
inc [posx] |
cmp [posx],60 |
jbe xok |
inc [posy] |
mov [posx],0 |
xok: |
cmp [posy],12 |
jbe yok |
mov [posy],1 |
yok: |
mov eax,[posy] |
imul eax,60 |
add eax,[posx] |
mov [input_text+eax],bl |
jmp new_data |
_ret: |
; call draw_window |
_ret_now: |
popa |
ret |
check_connection_status: |
pusha |
mov eax, 53 |
mov ebx, 6 |
mov ecx, [socket] |
mcall |
cmp eax,[status] |
je .ccs_ret |
mov [status],eax |
add eax,48 |
mov [text+20],al |
call draw_window |
.ccs_ret: |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
mov eax,0 ; Draw Window |
mov ebx,50*65536+410 |
mov ecx,100*65536+141 |
mov edx,0x14ffffff |
mov edi,title |
mcall |
mov eax,8 ; Start server |
mov ebx,(25)*65536+21 |
mov ecx,57*65536+10 |
mov edx,2 |
mov esi,0x409040 |
mcall ; Stop server |
; mov eax,8 |
mov ebx,(25)*65536+21 |
mov ecx,69*65536+10 |
mov edx,4 |
mov esi,0x904040 |
mcall |
mov esi,0x3366d0 |
; mov eax,8 ; Enter filename |
mov ebx,(25)*65536+21 |
mov ecx,93*65536+10 |
mov edx,6 |
mcall |
; mov eax,8 ; Decrease transfer rate |
mov ebx,(25)*65536+10 |
mov ecx,105*65536+10 |
; mov edx,8 |
mcall |
; mov eax,8 ; Increase transfer rate |
mov ebx,(36)*65536+10 |
mov ecx,105*65536+10 |
mov edx,9 |
mcall |
mov ebx,10*65536+35 ; draw info text |
mov ecx,0x00000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
mcall |
add ebx,12 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,4 ; Filename |
mov ebx,56*65536+95 |
mov ecx,0x000000 |
mov edx,filename |
mov esi,30 |
mcall |
mov eax,[bps] |
xor edx,edx |
mov ebx,1000 |
div ebx |
mov ecx,eax |
mov eax,47 |
mov ebx,3*65536 |
mov edx,58*65536+107 |
mov esi,0x00000000 |
mcall |
mov [input_text+0],dword 'RECE' |
mov [input_text+4],dword 'IVED' |
mov [input_text+8],dword ': ' |
mov ebx,230*65536+35 ; draw info text |
mov ecx,0x00000000 |
mov edx,input_text |
mov esi,28 |
mov edi,7 |
newline2: |
mov eax,4 |
mcall |
add ebx,10 |
add edx,60 |
dec edi |
jnz newline2 |
mov eax,38 |
mov ebx,210*65536+210 |
mov ecx,22*65536+136 |
mov edx,0x6699cc ; 002288 |
mcall |
mov eax,38 |
mov ebx,211*65536+211 |
mov ecx,22*65536+136 |
mov edx,0x336699 ; 002288 |
mcall |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
popa |
ret |
; DATA AREA |
text: |
db ' TCB status: 0 ' |
db ' ' |
db ' Activate - port 8008 ' |
db ' Stop server ' |
db ' ' |
db ' > ' |
db ' < > Kbps ' |
db 'x'; <- END MARKER, DONT DELETE |
headers: |
db 'ICY 200 OK',13,10 |
db 'icy-notice1:This stream requires Winamp or xmms',13,10 |
db 'icy-url:http://www.menuetos.org',13,10 |
db 'icy-pub: 1',13,10 |
db 'icy-name: Menuet Mp3 Shoutcast Radio ',version,' - ' |
transname: |
db ' ',13,10,13,10 |
headere: |
title db 'MP3 shoutcast server ',version,0 |
socket dd 0 |
status dd 0 |
posy dd 1 |
posx dd 0 |
read_on db 1 |
read_to dd 0 |
addr dd 0 |
ya dd 0 |
bps dd 128*1000 |
fileinfo: dd 0,0,0,0,0x20000 |
filename: db '/sys/MENUET.MP3',0 |
times 50 db 0 |
input_text: |
I_END: |
/programs/network_old/mp3s/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm mp3s.asm mp3s |
@erase lang.inc |
@pause |
/programs/network_old/mp3s/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm mp3s.asm mp3s |
@erase lang.inc |
@pause |
/programs/network_old/ppp/trunk/ppp.asm |
---|
0,0 → 1,2238 |
; |
; PPP.ASM |
; |
; Compile with FASM for Menuet |
; This program dials into an ISP and establishes a PPP connection |
; |
; Version 11 26th January 2004 |
; |
; This code is a port of the PPP dialer program by Microchip, from |
; their application note AN724 |
; It has been ported by Mike Hibbett mikeh@oceanfree.net for Menuet |
; |
; 26/1/04 - Mike Hibbett - added support for com port selected by |
; stackcfg |
; 2/5/03 - Shrirang - Added Abort Strings To sendwait to get out early |
; if modem sends abort strings like NO CARRIER etc. |
; |
; The original copyright statement follows |
;////////////////////////////////////////////////////////////////////////// |
;// |
;//PING.C version 1.10 July 29/99 (C)opyright by Microchip Technology Inc |
;// |
;////////////////////////////////////////////////////////////////////////// |
FALSE equ 0 |
TRUE equ 1 |
DEBUG_OUTPUT equ TRUE ; If FALSE, not debugging info outputted |
DEBUG_PPP_OUTPUT equ TRUE ; write PPP status msgs to debug board? |
DEBUG_PORT2_OUTPUT equ TRUE ; write debug data also to com2 |
BAUD_9600 equ 12 |
BAUD_57600 equ 2 |
; The next line sets the baud rate of the connection to the modem |
BAUDRATE equ BAUD_57600 |
LINE_END equ 0x0D ; End of input data character |
; Defines for Internet constants |
REQ equ 1 ; Request options list for PPP negotiations |
PPP_ACK equ 2 ; Acknowledge options list for PPP negotiations |
PPP_NAK equ 3 ; Not acknowledged options list for PPP neg |
REJ equ 4 ; Reject options list for PPP negotiations |
TERM equ 5 ; Termination packet for LCP to close connectio |
LCP_ECHO_REQ equ 9 |
LCP_ECHO_REP equ 10 |
IP equ 0x0021 ; Internet Protocol packet |
IPCP equ 0x8021 ; Internet Protocol Configure Protocol packet |
CCP equ 0x80FD ; Compression Configure Protocol packet |
LCP equ 0xC021 ; Link Configure Protocol packet |
PAP equ 0xC023 ; Password Authenication Protocol packet |
MaxRx equ 1500 |
MaxTx equ 1500 |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd STARTAPP ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include "lang.inc" |
include "..\..\..\macros.inc" |
include "chat.inc" ; Hosts modem chatting routine |
STARTAPP: |
; mov eax, 0x3f8 |
; mov [comport], eax |
; mov eax, 4 |
; mov [comirq], eax |
; Get the com port & IRQ to use from the kernel stack config option |
mov eax, 52 ; Stack Interface |
mov ebx, 0 ; read configuration word |
mcall |
mov ecx, eax |
shr ecx, 16 ; get the port address |
mov [comport], ecx |
shr eax, 8 |
and eax, 0x000000FF ; get the irq |
mov [comirq], eax |
mov eax, [comport] |
add eax, 0x01000000 |
mov [irqtable], eax |
call enable_port |
appdsp: |
mov eax, welcomep |
mov [prompt], eax ; set up prompt to display |
mov al, [welcomep_len] |
mov [prompt_len], al |
red: |
call draw_window ; at first, draw the window |
apploop: |
mov eax, 23 ; wait here for event |
mov ebx, 20 |
mcall |
cmp eax, 1 ; redraw request ? |
je red |
cmp eax, 2 ; key in buffer ? |
je key |
cmp eax, 3 ; button in buffer ? |
je button |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
je flush_input ; Dont want serial data yet |
jmp apploop |
key: ; key - ignore |
mov eax, 2 ; just read it |
mcall |
jmp apploop |
button: ; button |
mov eax, 17 ; get id |
mcall |
cmp ah, 1 ; close program ? |
jne noclose |
mov esi, hangupWait |
mov edi, hangupSend |
mov edx, 1000 ; Allow sendwait 10s |
call sendwait |
call disable_port |
or eax, -1 ; close this program |
mcall |
jmp apploop |
noclose: |
cmp ah, 2 ; Dial Button pressed? |
jne apploop |
mov eax, conp |
mov [prompt], eax ; set up prompt to display |
mov al,[conp_len] |
mov [prompt_len], al |
call draw_window |
jmp dialloop ; connect to the host |
; Data received, so get it, and throw it away at this point |
flush_input: |
mov eax,42 |
mov ebx, [comirq] |
mcall |
mov eax,11 ; This will return 0 most of the time |
mcall |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
je flush_input |
jmp apploop |
dialloop: |
call modem_chat ; Try chatting with the modem |
cmp eax, 1 ; Did it work? ( = 1) |
jne appdsp |
; OK, we are now connected. |
mov eax, pppOnp |
mov [prompt], eax ; set up prompt to display |
mov al,[pppOnp_len] |
mov [prompt_len], al |
call draw_window |
mov eax, 23 |
mov ebx, 100 |
mcall ; wait for 1s to display message |
call PPPStateMachine ; This is the main code |
jmp appdsp |
;**************************************************************************** |
; Function |
; PPPStateMachine |
; |
; Description |
; Handles PPP link establishment |
; |
;**************************************************************************** |
PPPStateMachine: |
; Start the timer |
xor eax, eax |
call settimer |
PPPLoop: |
mov eax, 11 ; check event |
mcall |
cmp eax, 3 |
jne PPPLred |
; button pressed |
mov eax, 17 ; get id |
mcall |
mov eax, hangp |
mov [prompt], eax ; set up prompt to display |
mov al,[hangp_len] |
mov [prompt_len], al |
call draw_window |
mov esi, hangupWait |
mov edi, hangupSend |
mov edx, 1000 ; Allow sendwait 10s |
call sendwait |
call disable_port |
mov eax, -1 ; close this program |
mcall |
jmp PPPLoop |
PPPLred: |
cmp eax, 1 ; redraw request ? |
jne PPPLoop0 |
call draw_window |
jmp PPPLoop |
PPPLoop0: |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
jne ppp_002 ; check for tx to send |
; we have data in the rx buffer, get it |
mov eax, 42 |
mov ebx, [comirq] ; ecx will return 0 =data read, 1 =no data |
mcall ; or 2 =not irq owner |
inc dword [rxbytes] |
cmp bl, 0x7E |
jne ppp_001a |
mov eax, [rx_ptr] |
cmp eax, 0 |
jz ppp_001 |
mov eax, [checksum1] |
cmp eax, 0xf0b8 |
jne ppp_001 |
movzx eax, byte [rx_str + 3] |
mov ah, [rx_str + 2] |
mov [packet], eax |
ppp_001: |
mov eax, [extended] |
and eax, 0x7e |
mov [extended], eax |
xor eax, eax |
mov [rx_ptr], eax |
mov eax, 0xffff |
mov [checksum1], eax |
jmp ppp_003 |
ppp_001a: |
cmp bl, 0x7D |
jne ppp_001b |
mov eax, [extended] |
or eax, 0x01 |
mov [extended], eax |
jmp ppp_003 |
ppp_001b: |
mov eax, [extended] |
test eax, 0x01 |
jz ppp_001c |
xor bl, 0x20 |
and eax, 0xFE |
mov [extended], eax |
ppp_001c: |
mov edx, [rx_ptr] |
cmp edx, 0 |
jnz ppp_001d |
cmp bl, 0xff |
je ppp_001d |
mov [rx_str + edx], byte 0xff |
inc edx |
ppp_001d: |
cmp edx, 1 |
jnz ppp_001e |
cmp bl, 0x03 |
je ppp_001e |
mov [rx_str + edx], byte 0x03 |
inc edx |
ppp_001e: |
cmp edx, 2 |
jnz ppp_001f |
test bl, 0x01 |
jz ppp_001f |
mov [rx_str + edx], byte 0 |
inc edx |
ppp_001f: |
mov [rx_str + edx], bl |
inc edx |
mov [rx_ptr], edx |
cmp edx, MaxRx |
jle ppp_001g |
mov edx, MaxRx |
mov [rx_ptr], edx |
ppp_001g: |
; do checksum calc |
mov eax, [checksum1] |
xor bh, bh |
xor ax, bx |
call calc |
mov ebx, [checksum1] |
and ebx, 0xffff |
shr ebx, 8 |
xor eax, ebx |
mov [checksum1], eax |
jmp ppp_003 |
ppp_002: |
mov eax, [tx_end] |
cmp eax, 0 |
jz ppp_003 |
mov ebx, [tx_ptr] |
mov cl, [tx_str + ebx] |
cmp ebx, eax |
jne ppp_002a |
mov [tx_end], dword 0 |
mov cl, '~' |
jmp ppp_002d |
ppp_002a: |
mov eax, [extended] |
and eax, 0x02 |
jz ppp_002b |
xor cl, 0x20 |
mov eax, [extended] |
and eax, 0xFD |
mov [extended], eax |
inc [tx_ptr] |
jmp ppp_002d |
ppp_002b: |
cmp cl, 0x20 |
jl ppp_002b1 |
cmp cl, 0x7d |
je ppp_002b1 |
cmp cl, 0x7e |
je ppp_002b1 |
jmp ppp_002c |
ppp_002b1: |
mov eax, [extended] |
or eax, 0x02 |
mov [extended], eax |
mov cl, 0x7d |
jmp ppp_002d |
ppp_002c: |
mov eax, [tx_ptr] |
cmp eax, 0 |
jnz ppp_002c1 |
mov cl, '~' |
ppp_002c1: |
inc [tx_ptr] |
ppp_002d: |
; Test for tx ready. |
push ecx |
wait_txd2: |
mov eax,43 |
mov ecx, [comport] |
add ecx, 0x80000000 + 5 |
mcall |
and bl, 0x40 |
cmp bl, 0 |
jz wait_txd2 ; loop until free |
pop ebx |
; send the character |
inc dword [txbytes] |
mov ecx, [comport] |
mov eax, 43 |
mcall |
ppp_003: |
mov eax, [packet] |
cmp eax, LCP |
jne ppp_004 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_003b |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_REQ |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfd |
mov [state], eax |
mov ebx, 0xc6 |
push eax |
call TestOptions |
pop eax |
cmp edx, 0 |
jz ppp_003g |
cmp edx, 1 |
jle ppp_003h |
mov edx, PPP_ACK |
cmp eax, 3 |
jge ppp_003i |
or eax, 0x02 |
mov [state], eax |
jmp ppp_003i |
ppp_003h: |
mov bl, 0xc0 |
mov [rx_str + 10], bl |
mov edx, PPP_NAK |
jmp ppp_003i |
ppp_003g: |
mov edx, REJ |
ppp_003i: |
mov ebx, LCP |
mov ecx, edx |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
mov eax, 0 |
call settimer |
jmp ppp_003a |
ppp_003b: |
cmp al, PPP_ACK |
jne ppp_003c |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_ACK |
call debug_output |
popa |
mov eax, [number] |
cmp al, [rx_str+5] |
jne ppp_003a |
mov eax, [state] |
cmp eax, 3 |
jge ppp_003a |
or eax, 0x01 |
mov [state], eax |
jmp ppp_003a |
ppp_003c: |
cmp al, PPP_NAK |
jne ppp_003d |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_NAK |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfe |
mov [state], eax |
jmp ppp_003a |
ppp_003d: |
cmp al, REJ |
jne ppp_003e |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_REJ |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfe |
mov [state], eax |
jmp ppp_003a |
ppp_003e: |
cmp al, TERM |
jne ppp_003j |
jmp ppp_003a |
ppp_003j: |
cmp al, LCP_ECHO_REQ |
jne ppp_003a |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_ECHO_REQ |
call debug_output |
popa |
mov al, 0 |
mov [rx_str+8],al |
mov [rx_str+9],al |
mov [rx_str+10],al |
mov [rx_str+11],al |
mov ebx, LCP |
mov ecx, LCP_ECHO_REP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
ppp_003a: |
mov eax, [state] |
cmp eax, 3 |
jne ppp_013 |
mov eax, 4 |
mov [state], eax |
jmp ppp_013 |
ppp_004: |
cmp eax, PAP |
jne ppp_005 |
mov al, [rx_str + 4] |
cmp al, PPP_ACK |
jne ppp_013 |
; Debugging output to debug board |
pusha |
mov esi, RX_PAP_ACK |
call debug_output |
popa |
mov eax, 5 |
mov [state],eax |
jmp ppp_013 |
ppp_005: |
cmp eax, IPCP |
jne ppp_006 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_005a |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_REQ |
call debug_output |
popa |
mov ebx, 0x04 |
call TestOptions |
cmp edx, 0 |
jz ppp_005b |
mov ecx, PPP_ACK |
mov eax, 6 |
mov [state], eax |
jmp ppp_005c |
ppp_005b: |
mov ecx, REJ |
ppp_005c: |
mov ebx, IPCP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_005a: |
cmp al, PPP_ACK |
jne ppp_005d |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_ACK |
call debug_output |
popa |
mov al, [rx_str + 5] |
mov ecx, [number] |
cmp al, cl |
jne ppp_013 |
mov eax, 7 |
mov [state], eax |
mov eax, 5800 |
call settimer |
mov eax, IPOnp |
mov [prompt], eax ; set up prompt to display |
mov al,[IPOnp_len] |
mov [prompt_len], al |
call draw_window |
jmp ppp_013 |
ppp_005d: |
cmp al, PPP_NAK |
jne ppp_005e |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_NAK |
call debug_output |
popa |
mov al, [rx_str + 10] |
mov [addr1], al |
mov al, [rx_str + 11] |
mov [addr2], al |
mov al, [rx_str + 12] |
mov [addr3], al |
mov al, [rx_str + 13] |
mov [addr4], al |
pusha |
call draw_window |
mov eax,52 |
mov ebx,3 |
mov cl, [addr4] |
shl ecx, 8 |
mov cl, [addr3] |
shl ecx, 8 |
mov cl, [addr2] |
shl ecx, 8 |
mov cl, [addr1] |
mcall ; Set the stacks IP address |
popa |
mov ebx, IPCP ;; added 28/4/03 |
mov ecx, REQ |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_005e: |
cmp al, REJ |
jne ppp_005f |
jmp ppp_013 |
ppp_005f: |
cmp al, TERM |
jne ppp_013 |
jmp ppp_013 |
ppp_006: |
cmp eax, IP |
jne ppp_007 |
;; |
;; |
;; |
;; This is where we will pass the IP packet up to the stack |
;; |
;; |
;; |
mov eax, 52 |
mov ebx, 6 |
mov edx, 1500 ; this should be exact amount |
mov esi, rx_str + 4 |
mcall |
; Debugging output to debug board |
pusha |
mov esi, RX_IP |
call debug_output |
popa |
jmp ppp_013 |
ppp_007: |
cmp eax, CCP |
jne ppp_008 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_013 |
; Debugging output to debug board |
pusha |
mov esi, RX_CCP_REQ |
call debug_output |
popa |
mov ebx, 0x04 |
call TestOptions |
cmp edx, 0 |
jz ppp_007b |
mov ecx, PPP_ACK |
jmp ppp_007c |
ppp_007b: |
mov ecx, REJ |
ppp_007c: |
mov ebx, CCP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_008: |
cmp eax, 0 |
jz ppp_009 |
jmp ppp_013 |
ppp_009: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_010 |
call gettimer |
cmp eax, 100 |
jle ppp_010 |
mov eax, [state] |
cmp eax, 0 |
je ppp_009a |
cmp eax, 2 |
jne ppp_010 |
ppp_009a: |
; Debugging output to debug board |
pusha |
mov esi, TX_LCP_REQ |
call debug_output |
popa |
inc [number] |
mov eax, 0 |
call settimer |
mov ebx, LCP |
mov ecx, REQ |
mov edx, [number] |
mov esi, LCPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_010: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_011 |
call gettimer |
cmp eax, 100 |
jle ppp_011 |
mov eax, [state] |
cmp eax, 4 |
jne ppp_011 |
mov eax, 0 |
call settimer |
inc [number] |
; Debugging output to debug board |
pusha |
mov esi, TX_PAP_REQ |
call debug_output |
popa |
mov ebx, PAP |
mov ecx, REQ |
mov edx, [number] |
mov esi, PAPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_011: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_012 |
call gettimer |
cmp eax, 100 |
jle ppp_012 |
mov eax, [state] |
cmp eax, 6 |
jne ppp_012 |
inc [number] |
mov eax, 0 |
call settimer |
; Debugging output to debug board |
pusha |
mov esi, TX_IPCP_REQ |
call debug_output |
popa |
mov ebx, IPCP |
mov ecx, REQ |
mov edx, [number] |
mov esi, IPCPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_012: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_013 |
mov eax, [state] |
cmp eax, 7 |
jne ppp_013 |
; 10ms Delay suggested by Ville |
mov eax,23 ; over here |
mov ebx,1 |
mcall |
call gettimer |
cmp eax, 200 |
jle ppp_012a |
; every 2s, when things are quiet, redraw window |
call draw_window_limited |
mov eax, 0 |
call settimer |
ppp_012a: |
mov eax, 52 |
mov ebx, 8 |
mov esi, ip_buff |
mcall |
cmp eax, 0 |
je ppp_013 |
call MakeIPPacket |
; Debugging output to debug board |
pusha |
mov esi, TX_IP |
call debug_output |
popa |
ppp_013: |
mov eax, [packet] |
cmp eax, 0 |
jz PPPLoop |
mov eax, 0 |
mov [packet], eax |
mov edi, rx_str |
mov ecx, MaxRx + 1 |
rep stosb |
jmp PPPLoop |
;**************************************************************************** |
; Function |
; calc |
; |
; Description |
; Adds a character to the CRC checksum |
; byte in lsb of eax |
; |
; |
;**************************************************************************** |
calc: |
and eax, 0xFF |
push ecx |
mov ecx, 8 |
calc_001: |
test al, 0x01 |
jz calc_002 |
shr eax, 1 |
xor eax, 0x8408 |
and eax, 0xffff |
jmp calc_003 |
calc_002: |
shr eax, 1 |
calc_003: |
loop calc_001 |
pop ecx |
ret |
;**************************************************************************** |
; Function |
; add2tx |
; |
; Description |
; Adds a character into the tx buffer |
; byte in low byte of eax |
; |
; |
;**************************************************************************** |
add2tx: |
pusha |
mov esi, tx_str |
add esi, [tx_ptr] |
inc [tx_ptr] |
mov [esi], al ; Save byte in buffer |
mov ecx, [checksum2] |
and eax, 0xff |
xor eax, ecx |
call calc |
shr ecx, 8 |
and ecx, 0xff |
xor eax, ecx |
mov [checksum2], eax |
popa |
ret |
;**************************************************************************** |
; Function |
; MakeIPPacket |
; |
; Description |
; Creates a PPP packet for transmission to the host from the |
; IP packet extracted from the stack |
; |
; IP data is in ip_buff |
; |
;**************************************************************************** |
MakeIPPacket: |
mov [tx_ptr], dword 1 |
mov edi, tx_str |
mov [edi], byte ' ' |
mov eax, 0xffff |
mov [checksum2], eax |
mov al, 0xff |
call add2tx |
mov al, 3 |
call add2tx |
mov al, IP / 256 |
call add2tx |
mov al, IP |
call add2tx |
movzx ecx, byte [ip_buff + 3] |
mov ch, byte [ip_buff + 2] |
mov esi, ip_buff |
mip001: |
mov al, byte [esi] |
call add2tx |
inc esi |
loop mip001 |
mov eax, [checksum2] |
not eax |
call add2tx |
shr eax, 8 |
call add2tx |
mov eax, [tx_ptr] |
mov [tx_end], eax |
xor eax, eax |
mov [tx_ptr], eax |
ret |
;**************************************************************************** |
; Function |
; MakePacket |
; |
; Description |
; Creates a PPP packet for transmission to the host |
; |
; Packet type in ebx |
; Code is in ecx |
; num is in edx |
; str is pointed to by esi |
; |
;**************************************************************************** |
MakePacket: |
mov [tx_ptr], dword 1 |
mov edi, tx_str |
mov [edi], byte ' ' |
mov eax, 0xffff |
mov [checksum2], eax |
mov al, 0xff |
call add2tx |
mov al, 3 |
call add2tx |
mov al, bh ; packet/256 |
call add2tx |
mov al, bl ; packet&255 |
call add2tx |
cmp ebx, IP ; is packet type IP? |
jne mp_001 ; No - its a lower layer packet |
; Do IP packet assembly |
jmp mp_002 |
mp_001: |
; Do PPP layer packet assembly |
mov al, cl |
call add2tx |
mov al, dl |
call add2tx |
mov al, 0 |
call add2tx |
movzx ecx, byte [esi] ; length = *str - 3 |
sub ecx, 3 |
mp_002: ; Now copy the data acros |
mov al, byte [esi] |
call add2tx |
inc esi |
loop mp_002 |
mov eax, [checksum2] |
not eax |
call add2tx |
shr eax, 8 |
call add2tx |
mov eax, [tx_ptr] |
mov [tx_end], eax |
xor eax, eax |
mov [tx_ptr], eax |
ret |
;**************************************************************************** |
; Function |
; TestOptions |
; |
; Description |
; Test a PPP packets options fields for valid entries |
; |
; option ebx |
; |
; Returns result in edx, but may also modify rx_str |
; |
;**************************************************************************** |
TestOptions: |
mov esi, 8 ; ptr1 |
mov edi, 8 ; ptr2 |
mov edx, 3 ; edx is the return value |
movzx ecx, byte [rx_str + 7] |
add ecx, 4 ; ecx is size |
cmp ecx, MaxRx |
jle to_001 |
mov ecx, MaxRx |
to_001: |
cmp esi, ecx |
jge to_002 |
mov al, byte [esi + rx_str] |
cmp al, 3 |
jne to_001a |
mov al, byte [esi + rx_str + 2] |
cmp al, 0x80 |
je to_001a |
; bug fix for chap authenticate reject below |
mov al, byte [esi + rx_str + 2] |
cmp al, 0xc2 |
jne to_001a |
and edx, 0xfd |
to_001a: |
push ecx |
mov cl, [esi + rx_str] |
dec cl |
mov eax, 1 |
shl eax, cl |
and eax, ebx |
and eax, 0xffff |
pop ecx |
cmp eax, 0 |
jnz to_001b |
xor edx,edx |
to_001b: |
movzx eax, byte [esi+rx_str+1] |
add esi, eax |
jmp to_001 |
to_002: |
; if (!(pass&2))... |
test edx, 2 |
jnz to_exit |
test edx, 1 |
jz to_002a |
mov ebx, 0xFFFB |
to_002a: |
mov esi, 8 |
to_002b: ; for loop |
cmp esi, ecx |
jge to_003 |
push ecx |
mov cl, [esi + rx_str] |
dec cl |
mov eax, 1 |
shl eax, cl |
and eax, ebx |
and eax, 0xffff |
pop ecx |
cmp eax, 0 |
jnz to_002c |
movzx edx, byte [esi+rx_str+1] |
to_002d: |
cmp esi, ecx |
jge to_002b |
cmp edx, 0 |
jz to_002b |
mov al, [esi + rx_str] |
mov [edi + rx_str], al |
inc esi |
inc edi |
dec edx |
jmp to_002d |
to_002c: |
movzx eax, byte [esi+rx_str+1] |
add esi, eax |
jmp to_002b ; end of for loop |
to_003: |
mov eax, edi |
sub al, 4 |
mov [rx_str+7], al |
xor edx, edx |
cmp ebx, 0xfffb |
jne to_exit |
inc edx |
to_exit: |
; Return value in EDX |
ret |
;*************************************************************************** |
; Function |
; disable_port |
; |
; Description; |
; Releases this applications use of the com port |
; |
;*************************************************************************** |
disable_port: |
if DEBUG_PORT2_OUTPUT = TRUE |
mov eax, 46 ; free port area |
mov ebx, 1 |
mov ecx, 0x2f8 |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
mcall |
end if |
mov eax, 45 ; free irq 4 |
mov ebx, 1 |
mov ecx, [comirq] |
mcall |
mov eax, 46 ; free port area |
mov ebx, 1 |
mov ecx, [comport] |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
mcall |
ret |
;*************************************************************************** |
; Function |
; enable_port |
; |
; Description; |
; Takes control of the com port, defining the IRQ table and initialising |
; the uart chip. |
; |
;*************************************************************************** |
enable_port: |
pusha |
if DEBUG_PORT2_OUTPUT = TRUE |
mov eax, 46 |
mov ebx, 0 |
mov ecx, 0x2f8 |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
mcall ; reseve port memory to this process |
mov eax, 45 ; reserve irq 3 |
mov ebx, 0 |
mov ecx, 3 |
mcall |
mov ecx, 0x2f8 ; data format register |
add ecx, 3 |
mov bl, 0x80 ; enable access to divisor latch |
mov eax, 43 ; send data to device - com port setup |
mcall |
mov ecx, 0x2f8 ; interrupt enable register |
inc ecx |
mov bl, 0 ; No interruts enabled |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, 0x2f8 ; Divisor latch LSB |
mov bl, BAUDRATE ; set baud rate |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, 0x2f8 ; Data format register |
add ecx, 3 |
mov bl, 3 ; 8 data bits |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, 0x2f8 ; Modem control register |
add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
; 0xb -> out2 enabled, RTS/DTR enabled |
mov eax, 43 ; send data to device (modem) |
mcall |
; mov ecx, 0x2f8 ; interrupt enable register |
; inc ecx |
; mov bl, 1 ; rx data interrupt enabled, othrs not |
; mov eax, 43 ; send data to device (modem) |
; mcall |
end if |
mov eax, 46 |
mov ebx, 0 |
mov ecx, [comport] |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
mcall ; reseve port memory to this process |
mov eax, 45 ; reserve irq 4 |
mov ebx, 0 |
mov ecx, [comirq] |
mcall |
mov eax, 44 ; setup irq table |
mov ebx, irqtable |
mov ecx, [comirq] |
mcall |
mov ecx, [comport] ; data format register |
add ecx, 3 |
mov bl, 0x80 ; enable access to divisor latch |
mov eax, 43 ; send data to device - com port setup |
mcall |
mov ecx, [comport] ; interrupt enable register |
inc ecx |
mov bl, 0 ; No interruts enabled |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, [comport] ; Divisor latch LSB |
mov bl, BAUDRATE ; set baud rate |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, [comport] ; Data format register |
add ecx, 3 |
mov bl, 3 ; 8 data bits |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, [comport] ; Modem control register |
add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
; 0xb -> out2 enabled, RTS/DTR enabled |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, [comport] ; interrupt enable register |
inc ecx |
mov bl, 1 ; rx data interrupt enabled, othrs not |
mov eax, 43 ; send data to device (modem) |
mcall |
mov ecx, [comirq] |
add ecx, 16 |
mov ebx, 1 |
shl ebx, cl |
add ebx, 111b |
mov eax,40 ; enable irq 4 data |
mcall |
popa |
ret |
;************************************************************************** |
; Function |
; draw_window |
; |
; Description; |
; Normal window definition and text layout for application |
;************************************************************************** |
draw_window: |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, 100*65536+250 ; [x start] *65536 + [x size] |
mov ecx, 100*65536+150 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title ; color of frames RRGGBB |
mcall |
; DIAL BUTTON |
mov eax, 8 ; function 8 : define and draw button |
mov ebx, (50)*65536+40 ; [x start] *65536 + [x size] |
mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
mov edx, 2 ; button id |
mov esi, 0x5599cc ; button color RRGGBB |
mcall |
mov ebx, 55*65536+133 ; Draw button text |
mov ecx, 0x00FFFFFF |
mov edx, button1_text |
xor eax, eax |
mov al, [button1_text_len] |
mov esi, eax |
mov eax, 4 |
mcall |
; DISCONNECT BUTTON |
mov eax, 8 ; function 8 : define and draw button |
mov ebx, (150)*65536+65 ; [x start] *65536 + [x size] |
mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
mov edx, 3 ; button id |
mov esi, 0x5599cc ; button color RRGGBB |
mcall |
mov ebx, 155*65536+133 ; Draw button text |
mov ecx, 0x00FFFFFF |
mov edx, button3_text |
xor eax, eax |
mov al, [button3_text_len] |
mov esi, eax |
mov eax, 4 |
mcall |
mov ebx, 5*65536+40 ; draw info text with function 4 |
mov ecx, 0x00FFFFFF |
mov edx, [prompt] |
xor eax, eax |
mov al, [prompt_len] |
mov esi, eax |
mov eax, 4 |
mcall |
; Draw IP address |
mov edx, 10*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr1] |
mov eax, 47 |
mcall |
mov edx, 31*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr2] |
mov eax, 47 |
mcall |
mov edx, 52*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr3] |
mov eax, 47 |
mcall |
mov edx, 73*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr4] |
mov eax, 47 |
mcall |
; Status byte |
mov edx, 100*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00010000 |
movzx ecx, byte [state] |
mov eax, 47 |
mcall |
; bytes sent / received |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 10*65536+80 ; [x start] *65536 + [y start] |
mov ecx, 0x00ffffff ; color of text RRGGBB |
mov edx, txmsg ; pointer to text beginning |
mov esi, txmsglen-txmsg ; text length |
mcall |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 10*65536+100 ; [x start] *65536 + [y start] |
mov ecx, 0x00ffffff ; color of text RRGGBB |
mov edx, rxmsg ; pointer to text beginning |
mov esi, rxmsglen-rxmsg ; text length |
mcall |
call draw_window_limited |
mov eax, 12 ; end of redraw |
mov ebx, 2 |
mcall |
ret |
draw_window_limited: |
mov eax,13 |
mov ebx,80*65536+10*6 |
mov ecx,80*65536+10 |
mov edx,0x03224466 |
mcall |
mov ecx,100*65536+10 |
mcall |
mov ebx, 0x000A0000 |
mov ecx, [txbytes] |
mov esi, 0x00ffffff ; color of text RRGGBB |
mov eax, 47 ; function 47 : write number to window |
mov edx, 80*65536+80 ; [x start] *65536 + [y start] |
mcall |
mov ebx, 0x000A0000 |
mov ecx, [rxbytes] |
mov esi, 0x00ffffff ; color of text RRGGBB |
mov eax, 47 ; function 47 : write number to window |
mov edx, 80*65536+100 ; [x start] *65536 + [y start] |
mcall |
ret |
;**************************************************************************** |
; Function |
; settimer |
; |
; Description |
; sets the general purpose timer to a given value in eax |
; All times are in 1/100s |
; |
; |
;**************************************************************************** |
settimer: |
push eax |
mov eax, 26 |
mov ebx, 9 |
mcall ; get 100th second counter |
pop ebx |
sub eax, ebx ; This could have some funny side effecs if PPP |
; called within ebx seconds of startup |
mov [timerValue], eax |
ret |
;**************************************************************************** |
; Function |
; gettimer |
; |
; Description |
; gets the general purpose timer count in eax |
; All times are in 1/100s |
; |
; |
;**************************************************************************** |
gettimer: |
mov eax, 26 |
mov ebx, 9 |
mcall ; get 100th second counter |
sub eax, [timerValue] |
ret |
;**************************************************************************** |
; Function |
; sendwait |
; |
; Description |
; Sends a command string to the modem, then waits for a defined rsp |
; |
; esi points to string to wait for |
; edi points to string to send |
; edx holds wait time, in ms |
; |
; Returns 1 if OK or 0 if timeout occurred |
; |
;**************************************************************************** |
sendwait: |
mov [sendwaitTime], edx |
; Shrirang 2/5/03 |
mov byte [abortcnt], 0 ; reset the abort counter |
;--! |
; Start the timer |
xor eax, eax |
call settimer |
; Check for incoming data |
xor edx, edx |
xor eax, eax |
sw_001: |
push eax |
push edx |
; Has connection timer expired? |
call gettimer |
cmp eax, [sendwaitTime] |
jl sw_000 |
pop edx |
pop eax |
xor eax, eax |
jmp sw_exit ; Exit indicating an error ( timeout ) |
sw_000: |
; any data from modem? |
mov eax,11 ; This will return 0 most of the time |
mcall |
mov ecx, eax |
pop edx |
pop eax |
cmp ecx, 1 ; redraw request ? |
je red1 |
cmp ecx, 3 ; button in buffer ? |
je button1 |
mov ebx, [comirq] |
add ebx, 16 |
cmp ecx,ebx |
jne sw_002 |
jmp sw_000a |
red1: |
pusha |
call draw_window |
popa |
push eax |
push edx |
jmp sw_000 |
button1: |
mov eax, 0 |
jmp sw_exit |
sw_000a: |
; there was data, so get it |
push edx |
push eax |
mov eax,42 |
mov ebx, [comirq] |
mcall |
pop eax |
pop edx |
; Shrirang 2/5/03 |
; Now that the expected response is not got we check if we |
; got the abort part, before we reset the fsm |
cmp bl, 0x0d ; AT commands normally start and end with \r\n |
je checkabort |
cmp bl, 0x0a |
je checkabort |
push eax |
xor eax, eax |
mov al, [abortcnt] |
mov byte [abortres+eax], bl ; update abort response |
inc byte [abortcnt] |
pop eax |
jmp noabort |
checkabort : |
cmp byte [abortcnt], 2 ; if we got valid abort this cannot happen! |
jbe noabortflush |
push eax |
push esi |
push edi |
push ecx |
mov esi, abortres |
mov edi, aborts |
xor ecx, ecx |
mov cl, byte [abortcnt] |
call scanaborts ; scan 'em |
pop ecx |
pop edi |
pop esi |
and eax, eax |
jz noabortdec |
pop eax |
xor eax, eax |
jmp sw_exit |
noabortdec: |
pop eax |
noabortflush: |
mov byte [abortcnt], 0 |
noabort: |
;--! |
cmp [esi+edx], bl |
je sw_003 |
xor edx, edx |
; Added 28/4/03 |
cmp [esi+edx], bl |
je sw_003 |
jmp sw_001 |
sw_003: ; They are the same |
inc edx |
cmp [esi+edx], byte 0 |
jne sw_001 |
xor eax, eax |
inc eax |
jmp sw_exit |
sw_002: |
; Test for data to send to modem |
cmp [ edi + eax ], byte 0 |
je sw_001 |
; Is it a '|' character? |
cmp [ edi + eax ], byte '|' |
jne sw_004 |
push eax |
call gettimer |
cmp eax, 100 |
pop eax |
jl sw_001 |
; restart the timer |
push eax |
xor eax, eax |
call settimer |
pop eax |
; Move to next character |
inc eax |
jmp sw_001 |
sw_004: |
push edx |
push eax |
; restart the timer |
xor eax, eax |
call settimer |
; Test for tx ready. |
; OR, wait then send |
push edi |
mov eax, 5 |
mov ebx, 1 |
mcall ; 10ms delay |
pop edi |
; send the character |
pop eax |
mov bl, [edi + eax] |
mov ecx, [comport] |
inc eax |
push eax |
mov eax, 43 |
mcall |
pop eax |
pop edx |
cmp [ edi + eax ], byte 0 |
jne sw_001 |
cmp [ esi + edx ], byte 0 |
jne sw_001 |
xor eax, eax |
inc eax |
sw_exit: |
; return success (1) or failure (0) in eax |
ret |
if DEBUG_OUTPUT = TRUE |
;**************************************************************************** |
; Function |
; debug_output |
; |
; Description |
; prints a description of the PPP protocol's data exchanges to the |
; debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_output: |
cmp esi, RX_IP |
jne do_001 |
call debug_print_string |
call debug_print_rx_ip |
mov esi, IP_DATA1 |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
mov esi, IP_DATA2 |
call debug_print_string |
ret |
do_001: |
cmp esi, TX_IP |
jne do_002 |
call debug_print_string |
call debug_print_tx_ip |
mov esi, IP_DATA1 |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
mov esi, IP_DATA2 |
call debug_print_string |
ret |
do_002: |
; Print PPP protocol information |
if DEBUG_PPP_OUTPUT = TRUE |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
end if |
ret |
txCom2: |
push ecx |
wait_txd2t: |
mov eax,43 |
mov ecx,0x80000000 + 0x2f8 + 5 |
mcall |
and bl, 0x40 |
cmp bl, 0 |
jz wait_txd2t ; loop until free |
pop ebx |
; send the character |
mov ecx, 0x2f8 |
mov eax, 43 |
mcall |
ret |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
mov cl, [esi] |
cmp cl, 0 |
jnz dps_001 |
ret |
dps_001: |
if DEBUG_PORT2_OUTPUT = TRUE |
pusha |
call txCom2 |
popa |
end if |
mov eax,63 |
mov ebx, 1 |
push esi |
mcall |
pop esi |
inc esi |
jmp debug_print_string |
; This is used for translating hex to ASCII for display or output |
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
IP_DATA1 db 'TCP From: xxxxxxxx To: xxxxxxxx SrcP: xxxx DestP: xxxx',0 |
IP_DATA2 db 'Seq: xxxxxxxx Ack: xxxxxxxx Flags: xx dataLen: xxxx',13,10,0 |
debug_print_rx_ip: |
mov esi, rx_str + 4 ; The ip buffer address start |
mov edi, IP_DATA1 |
cmp [esi+9], byte 1 |
jne rnICMP |
mov eax,'ICMP' |
jmp drp |
rnICMP: |
cmp [esi+9], byte 6 |
jne rnTCP |
mov eax,'TCP ' |
jmp drp |
rnTCP: |
cmp [esi+9], byte 17 |
jne rnUDP |
mov eax,'UDP ' |
jmp drp |
rnUDP: |
drp: |
mov [edi], eax |
call fillData |
ret |
debug_print_tx_ip: |
mov esi, ip_buff ; The ip buffer address start |
mov edi, IP_DATA1 |
cmp [esi+9], byte 1 |
jne tnICMP |
mov eax,'ICMP' |
jmp dtp |
tnICMP: |
cmp [esi+9], byte 6 |
jne tnTCP |
mov eax,'TCP ' |
jmp dtp |
tnTCP: |
cmp [esi+9], byte 17 |
jne tnUDP |
mov eax,'UDP ' |
jmp dtp |
tnUDP: |
dtp: |
mov [edi], eax |
call fillData |
ret |
fillData: |
; Display from IP |
mov cl, [esi+12] |
mov edx, 11 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+13] |
mov edx, 13 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+14] |
mov edx, 15 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+15] |
mov edx, 17 |
call wbyte ; byte in cl, dest in edi+edx |
; Display to IP |
mov cl, [esi+16] |
mov edx, 24 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+17] |
mov edx, 26 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+18] |
mov edx, 28 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+19] |
mov edx, 30 |
call wbyte ; byte in cl, dest in edi+edx |
; Only display extra data for TCP |
cmp [esi+9], byte 6 ; TCP? |
je nTCP |
; display source port |
mov [edi+32], byte 0 |
mov edi, IP_DATA2 |
mov [edi], byte 0 |
ret |
nTCP: |
mov [edi+32], byte ' ' |
mov cl, [esi+20] |
mov edx, 39 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+21] |
mov edx, 41 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+22] |
mov edx, 51 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+23] |
mov edx, 53 |
call wbyte ; byte in cl, dest in edi+edx |
mov edi, IP_DATA2 |
mov [edi], byte 'S' |
mov cl, [esi+24] |
mov edx, 5 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+25] |
mov edx, 7 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+26] |
mov edx, 9 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+27] |
mov edx, 11 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+28] |
mov edx, 19 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+29] |
mov edx, 21 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+30] |
mov edx, 23 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+31] |
mov edx, 25 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+33] |
and cl, 0x3F |
mov edx, 35 |
call wbyte ; byte in cl, dest in edi+edx |
; Display the size of the received packet |
mov dh, [esi + 2] |
mov dl, [esi + 3] |
sub dx, 40 |
mov cl, dh |
mov edx, 48 |
call wbyte ; byte in cl, dest in edi+edx |
mov dh, [esi + 2] |
mov dl, [esi + 3] |
sub dx, 40 |
mov cl, dl |
mov edx, 50 |
call wbyte ; byte in cl, dest in edi+edx |
ret |
wbyte: ; byte in cl, dest in edi+edx, edi unchanged |
xor eax, eax |
mov al, cl |
shr al, 4 |
mov bl, [eax + hexchars] |
mov [edi+edx], bl |
inc edx |
mov al, cl |
and al, 0x0f |
mov bl, [eax + hexchars] |
mov [edi+edx], bl |
ret |
else |
debug_output: |
ret |
end if |
; DATA AREA |
; debug msgs |
RX_IP db 'R: ',0 |
TX_IP db 'T: ',0 |
CRLF db 13,10,0 |
RX_LCP_REQ db 'RX_LCP_REQ',0 |
RX_LCP_ACK db 'RX_LCP_ACK',0 |
RX_LCP_NAK db 'RX_LCP_NAK',0 |
RX_LCP_REJ db 'RX_LCP_REJ',0 |
RX_LCP_ECHO_REQ db 'RX_LCP_ECHO_REQ',0 |
RX_PAP_ACK db 'RX_PAP_ACK',0 |
RX_IPCP_REQ db 'RX_IPCP_REQ',0 |
RX_IPCP_ACK db 'RX_IPCP_ACK',0 |
RX_IPCP_NAK db 'RX_IPCP_NAK ( IP Address assigned )',0 |
RX_CCP_REQ db 'RX_CCP_REQ',0 |
TX_LCP_REQ db 'TX_LCP_REQ',0 |
TX_PAP_REQ db 'TX_PAP_REQ',0 |
TX_IPCP_REQ db 'TX_IPCP_REQ',0 |
; Labels for GUI buttons |
button1_text db 'DIAL' |
button1_text_len db 4 |
button3_text db 'DISCONNECT' |
button3_text_len db 10 |
comport dd 0 |
comirq dd 0 |
; Pointer to prompt shown to user |
prompt dd 0 |
prompt_len db 0 |
; Application Title |
title db 'PPP Dialer',0 |
txmsg: db 'Tx bytes :' |
txmsglen: |
rxmsg: db 'Rx bytes :' |
rxmsglen: |
timerValue dd 0 |
sendwaitTime dd 0 |
; Prompts displayed to the user |
welcomep db 'Select an option below, see ppp.txt' |
welcomep_len db 35 |
dialfp db 'Connect Failed...' |
dialfp_len db 17 |
connectedp db 'Connected to Host' |
connectedp_len db 17 |
conp db 'Connecting to Host' |
conp_len db 18 |
pppOnp db 'PPP Started' |
pppOnp_len db 11 |
IPOnp db 'IP Link established' |
IPOnp_len db 19 |
discp db 'Disconnected from Host' |
discp_len db 22 |
hangp db 'Hanging up Modem......' |
hangp_len db 22 |
PPPconSend db 0x7e,0xff,0x7d,0x23,0x08,0x08,0x08,0x08,0 |
PPPconWait db '~~',0 |
hangupWait db 'ATZ',0 |
hangupSend db '|||+++|||',10,13,'ATH',10,13,'|ATZ',10,13,0 |
; Shrirang 2/5/03 |
abortres: times(50) db 0 |
abortcnt db 0 |
;--! |
LCPREQStr db 0x0e,0x02,0x06,0x00, 0x0a, 0x00, 0x00, 0x07, 0x02, 0x08, 0x02 |
PAPREQStr db 14, 4, 'free', 4, 'free' |
IPCPREQStr db 10, 3, 6, 0, 0, 0, 0 |
irqtable: dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
checksum1 dd 0 |
checksum2 dd 0 |
packet dd 0 |
state dd 0 |
extended dd 0 |
number dd 0 |
tx_end dd 0 |
tx_ptr dd 0 |
rx_ptr dd 0 |
addr1 db 0 |
addr2 db 0 |
addr3 db 0 |
addr4 db 0 |
rxbytes dd 0 |
txbytes dd 0 |
; End of application code and data marker |
I_END: |
rx_str: rb MaxRx + 1 |
tx_str: rb MaxTx + 1 |
ip_buff: rb 1500 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/ppp/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ppp.asm ppp |
@erase lang.inc |
@pause |
/programs/network_old/ppp/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ppp.asm ppp |
@erase lang.inc |
@pause |
/programs/network_old/ppp/trunk/chat.inc |
---|
0,0 → 1,188 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; CHAT.INC ;; |
;; ;; |
;; Modem Chat Initiator for PPP Dialer ;; |
;; ;; |
;; Version 3 2nd May 2003 ;; |
;; ;; |
;; Copyright 2002 Shrirang Bhagwat, b_shrirang@hotmail.com ;; |
;; ;; |
;; See file COPYING for details ;; |
;; ;; |
;; 2/5/03 - Shrirang - Added Abort Strings For sendwait ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; Request And Response Chat Strings |
; Following Data Structure is used for Request Response Chatting |
; with the modem, for each request there is an expected response |
; chatreq <-> chatres, 0 (NULL) is delimeter for 1 string |
; '`' is delimiter for the section, modify according to your |
; modem dialing scheme; in future MenuetOS might provide a graphical |
; client to generate this kind of data structure and the PAP packet |
; for username and password! |
; Aborts strings are used to get outta sendwait early... |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; REQUESTS |
chatreq db 'ATH',13,0 ; 0 (NULL) is required by sendwait |
db 'ATZ',13,0 |
db 'ATM1',13,0 |
db 'ATX1',13,0 ; My Modem doesn't connect without this |
; db 'ATDT;',13,0 |
db 'ATDT phonenumber',13,0 |
db '`' ; <- End Marker |
; RESPONSES |
chatres db 'OK',0 |
db 'OK',0 |
db 'OK',0 |
db 'OK',0 |
; db 'OK',0 |
db 'CONNECT',0 |
db '`' ; <- End Marker |
; ABORTS |
aborts db 'ERROR',0 |
db 'NO CARRIER',0 |
db 'NO DIALTONE',0 |
db 'BUSY',0 |
db 'LINE IN USE',0 |
db 'NO ANSWER',0 |
db '`' ; <- End Marker |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; modem_chat - chats with the modem to initiate a connection |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
modem_chat: |
push edi |
push esi |
push edx |
mov edi, chatreq ; init everytime, safe, stateless |
mov esi, chatres |
chat_now: |
cmp byte [esi], '`' ; are we done? |
je chatover |
mov edx, 6000 ; strings like "atdt;" take long on my modem |
call sendwait |
and eax, eax |
jz timeoutoccured |
updatereq: |
inc edi |
cmp byte [edi], '`' |
je updateres |
cmp byte [edi], 0 |
jne updatereq |
inc edi |
updateres: |
inc esi |
cmp byte [esi], '`' |
je chatover |
cmp byte [esi], 0 |
jne updateres |
inc esi |
jmp chat_now |
chatover: |
xor eax, eax ; SUCCESS! |
inc eax |
pop edx |
pop esi |
pop edi |
ret |
timeoutoccured: |
xor eax, eax ; FAIL! |
pop edx |
pop esi |
pop edi |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; scanaborts - scans the response from modem for abort srings |
; ESI - Response from modem |
; EDI - Pointer to Abort Table |
; ECX - Response Length |
; Returns 1 if abort detected, 0 otherwise |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
scanaborts: |
push esi |
push edi |
push ecx |
checkit: |
push esi |
repe cmpsb ; any abort matches? |
je abortdetected |
pop esi |
updatetbl: |
inc edi |
cmp byte [edi], '`' |
je noabortfound |
cmp byte [edi], 0 |
jne updatetbl |
inc edi |
jmp checkit |
abortdetected: |
pop esi |
pop ecx |
pop edi |
pop esi |
xor eax, eax ; SUCCESS! |
inc eax |
ret |
noabortfound : |
pop ecx |
pop edi |
pop esi |
xor eax, eax ; FAILED! |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/rccc/trunk/rccc.asm |
---|
0,0 → 1,308 |
; |
; Remote Control Center(Client) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ , ¯à¥¤ § ç¥ ï ¤«ï ã¯à ¢«¥¨ï 㤠«ñë¬ ª®¬¯ìîâ¥à®¬.«¨¥â᪠ï |
; ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x5000 ; memory for app |
dd 0x5000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include '..\..\..\macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x6000 ; local port |
mov edx,0x6100 ; remote port |
mov esi,dword [remote_ip] ; remote IP |
mcall |
mov [socket], eax |
mov eax,53 ; send connect code |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,connect |
mcall |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
key: |
mov eax,2 |
mcall |
jmp still |
button: |
mov eax,17 |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socket] |
mcall |
or eax,-1 |
mcall |
noclose: |
cmp ah,2 ; SEND SHUTDOWN COMMAND? |
je send_shutdown |
cmp ah,3 ; SEND REBOOT COMMAND? |
je send_reboot |
cmp ah,4 ; SEND SAVEFI COMMAND? |
je send_savefi |
cmp ah,5 ; SEND SAVEHI COMMAND? |
je send_savehi |
cmp ah,6 ; SEND HOTREBOOT COMMAND? |
je send_hotreboot |
cmp ah,7 ; SEND EXIT COMMAND? |
je send_exit |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND COMMANDS TO SERVER ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_shutdown: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_shutdown |
mcall |
jmp still |
send_reboot: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_reboot |
mcall |
jmp still |
send_savefi: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_savefi |
mcall |
jmp still |
send_savehi: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_savehi |
mcall |
jmp still |
send_hotreboot: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_hotreboot |
mcall |
jmp still |
send_exit: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_exit |
mcall |
jmp still |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
mcall |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
jne get_data |
mov eax,4 |
mov ebx,30*65536+30 |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,15 |
mcall |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+250 ; [x start] *65536 + [x size] |
mov ecx,60*65536+280 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,8 ; CONTROL BUTTONS |
mov ebx,25*65536+9 |
mov ecx,113*65536+9 |
mov edx,2 |
mov esi,0x667788 |
newbut: |
mcall |
add ecx,16*65536 |
inc edx |
cmp edx,8 |
jb newbut |
cld |
mov eax,4 |
mov ebx,25*65536+50 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
text: |
if lang eq ru |
db ' ६ï á¥à¢¥à : ' |
db ' ' |
db ' ¥î ã¯à ¢«¥¨ï á¥à¢¥à®¬: ' |
db ' ' |
db ' - 몫îç¨âì ' |
db ' - ¥à¥§ £à㧨âì ' |
db ' - ®åà ¨âì ä«®¯¯¨-¨¬¥¤¦ ' |
db ' - ®åà ¨âì ¨¬¥¤¦ . ¤¨áª ' |
db ' - ®àï稩 à¥áâ àâ ï¤à ' |
db ' - ªàë⨥ á¥à¢¥à®© ç á⨠' |
db ' ' |
db ' ®ª «ìë© ¤à¥á : 192.168.0.1 ' |
db ' ¤ «ñë© ¤à¥á : 192.168.0.2 ' |
db '¤à¥á á¥à¢¥à - ¢ ª®æ¥ ¨á室¨ª ' |
db 'x' ; <- END MARKER, DONT DELETE |
else |
db ' On server: ' |
db ' ' |
db ' Server control menu: ' |
db ' ' |
db ' - Shutdown ' |
db ' - Reboot ' |
db ' - Save ramdisk image to floppy ' |
db ' - Save ramdisk image to hard disk ' |
db ' - Kernel restart ' |
db ' - Close server part ' |
db ' ' |
db ' Local address : 192.168.0.1 ' |
db ' Remote address : 192.168.0.2 ' |
db 'Address of server is in end of source ' |
db 'x' ; <- END MARKER, DONT DELETE |
end if |
title db 'Remote Control Center(Client)',0 |
socket dd 0x0 |
remote_ip db 192,168,0,2 |
sen_shutdown db 'S' |
sen_reboot db 'R' |
sen_savefi db 'F' |
sen_savehi db 'H' |
sen_hotreboot db 'O' |
sen_exit db 'E' |
connect db 'C' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/rccc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rccc.asm rccc |
@erase lang.inc |
@pause |
/programs/network_old/rccc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rccc.asm rccc |
@erase lang.inc |
@pause |
/programs/network_old/rccs/trunk/rccs.asm |
---|
0,0 → 1,341 |
; |
; Remote Control Center(Server) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ , ¯à¥¤ § ç¥ ï ¤«ï ã¯à ¢«¥¨ï 㤠«ñë¬ ª®¬¯ìîâ¥à®¬.¥à¢¥à ï |
; ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x5000 ; memory for app |
dd 0x5000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include '..\..\..\macros.inc' |
remote_ip db 192,168,0,1 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x6100 ; local port |
mov edx, 0x6000 ; remote port |
mov esi, dword [remote_ip] ; remote IP |
mcall |
mov [socket],eax |
mov [0],eax ; save for remote code |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
jne data_arrived |
jmp still |
key: |
mov eax,2 |
mcall |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socket] |
mcall |
or eax,-1 |
mcall |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
mcall |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
mcall |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
jne get_data |
cmp byte [I_END],'C' ;Connect ? |
jne no_con |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_con |
mov esi,inp_con.len |
mcall |
add [y],10 |
jmp still |
no_con: |
cmp byte [I_END],'S' ; Shutdown ? |
jne no_shut |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_shut |
mov esi,inp_shut.len |
mcall |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,2 |
mcall |
jmp still |
no_shut: |
cmp byte [I_END],'R' ; Reboot ? |
jne no_reb |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_reb |
mov esi,inp_reb.len |
mcall |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,3 |
mcall |
jmp still |
no_reb: |
cmp byte [I_END],'F' ; Save image on floppi ? |
jne no_savefi |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_savefi |
mov esi,inp_savefi.len |
mcall |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,1 |
mcall |
jmp still |
no_savefi: |
cmp byte [I_END],'H' ; Save image on hard disk ? |
jne no_savehi |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_savehi |
mov esi,inp_savehi.len |
mcall |
add [y],10 |
mov eax,18 |
mov ebx,6 |
mov ecx,2 |
mcall |
jmp still |
no_savehi: |
cmp byte [I_END],'O' ; Hot reboot ? |
jne no_hotreb |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_hotreb |
mov esi,inp_hotreb.len |
mcall |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,4 |
mcall |
jmp still |
no_hotreb: |
cmp byte [I_END],'E' ; Unload server ? |
jne no_com |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_exit |
mov esi,inp_exit.len |
mcall |
add [y],10 |
call button |
jmp still |
no_com: |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_com |
mov esi,inp_com.len |
mcall |
add [y],10 |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+330 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
text: |
if lang eq ru |
db ' ë© ¤à¥á : 192.168.0.2 ' |
db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x6100 ' |
db '®áâ®ï¨¥: ' |
db 'x' ; <- END MARKER, DONT DELETE |
else |
db 'This address : 192.168.0.2 ' |
db 'Used port : 0x6100 ' |
db 'Status: ' |
db 'x' ; <- END MARKER, DONT DELETE |
end if |
title db 'Remote Control Center(Server)',0 |
socket dd 0x0 |
y dd 0x10 |
sysclock dd 0x0 |
if lang eq ru |
inp_con db '¨¬ ¨¥, ¯®¤ª«î稫áï ª«¨¥â!' |
.len = $-inp_con |
inp_shut db '¤ñ⠮⪫î票¥ á¨á⥬ë...' |
.len = $-inp_shut |
inp_reb db '¤ñâ ¯¥à¥§ £à㧪 ...' |
.len = $-inp_reb |
inp_savefi db '®åà 塞 ¨¬¥¤¦ ¤¨áª¥âã...' |
.len = $-inp_savefi |
inp_savehi db '®åà 塞 ¨¬¥¤¦ . ¤¨áª...' |
.len = $-inp_savehi |
inp_hotreb db '¤ñâ £®àï稩 à¥áâ àâ ï¤à ...' |
.len = $-inp_hotreb |
inp_exit db 'ë室 ¨§ ¯à®£à ¬¬ë...' |
.len = $-inp_exit |
inp_com db '¥®¯®§ ï ª®¬¬ ¤ !' |
.len = $-inp_com |
else |
inp_con db 'Note, client has been connected!' |
.len = $-inp_con |
inp_shut db 'Turn off in progress...' |
.len = $-inp_shut |
inp_reb db 'Reboot in progress...' |
.len = $-inp_reb |
inp_savefi db 'Saving image to floppy...' |
.len = $-inp_savefi |
inp_savehi db 'Saving image to hard disk...' |
.len = $-inp_savehi |
inp_hotreb db 'Kernel restart in progress...' |
.len = $-inp_hotreb |
inp_exit db 'Exiting from program...' |
.len = $-inp_exit |
inp_com db 'Unknown command!' |
.len = $-inp_com |
end if |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/rccs/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rccs.asm rccs |
@erase lang.inc |
@pause |
/programs/network_old/rccs/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rccs.asm rccs |
@erase lang.inc |
@pause |
/programs/network_old/remote/trunk/remote.asm |
---|
0,0 → 1,208 |
; |
; Remote processing example (remote node) - vt |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
remote_ip db 192,168,1,26 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x3000 ; local port |
mov edx, 0xffff ; remote port |
mov esi, dword [remote_ip] ; remote IP |
mcall |
mov [socketNum],eax |
mov [0],eax ; save for remote code |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socketNum] |
mcall |
cmp eax,0 |
jne data_arrived |
jmp still |
key: |
mov eax,2 |
mcall |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socketNum] |
mcall |
or eax,-1 |
mcall |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
mcall |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socketNum] |
mcall |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socketNum] |
mcall |
cmp eax,0 |
jne get_data |
add byte [I_END+14],48 |
mov eax,4 |
mov ebx,10*65536+50 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,23 |
mcall |
add [y],10 |
cmp byte [I_END+14],'1' ; DATA PACKET ? |
jne no_packet |
mov esi,I_END+23 |
mov edi,[I_END+15] |
mov ecx,[I_END+19] |
cld |
rep movsb |
jmp still |
no_packet: |
cmp byte [I_END+14],'2' ; EXECUTE ? |
jne no_execute |
mov eax,[I_END+15] |
call eax |
jmp still |
no_execute: |
jmp still |
y dd 0x10 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+286 ; [x start] *65536 + [x size] |
mov ecx,100*65536+330 ; [y start] *65536 + [y size] |
mov edx,0x14ffffff ; color of work area RRGGBB |
mov edi,title ; WINDOW LABEL |
mcall |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
text: |
db 'THIS NODE : 192.168.1.22 ' |
db 'LISTENING TO PORT : 0x3000 ' |
db 'x' ;<- END MARKER, DONT DELETE |
title db 'CLUSTER REMOTE',0 |
socketNum dd 0x0 |
send_data db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 1 ; 14 send |
dd 0x0 ; 15 position |
dd 0x0 ; 19 size |
; 23 |
execute db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 2 ; 14 execute |
dd 0x0 ; 15 position |
; 19 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/remote/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm remote.asm remote |
@erase lang.inc |
@pause |
/programs/network_old/remote/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm remote.asm remote |
@erase lang.inc |
@pause |
/programs/network_old/tftpa/trunk/tftpa.asm |
---|
0,0 → 1,725 |
; |
; TFTP Wave Player |
; |
; Compile with FASM for Menuet |
; |
; |
; 12.7.2002 - Audio system calls by VT |
; |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
include 'lang.inc' |
include '..\..\..\macros.inc' |
delay dd 145 |
wait_for dd 0x0 |
START: ; start of execution |
mov dword [prompt], p9 |
mov dword [promptlen], p9len - p9 |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
mcall |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
mcall |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jnz noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0 |
or eax,-1 ; close this program |
mcall |
noclose: |
cmp ah,2 ; copy file to local machine? |
jnz nocopyl |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from Remote Host to this machine |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x01 ; setup tftp msg |
call copyFromRemote |
jmp still |
nocopyl: |
cmp ah,4 |
jz f1 |
cmp ah,5 |
jz f2 |
jmp nof12 |
f1: |
mov [addr],dword source |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword destination |
mov [ya],dword 35+16 |
rk: |
mov ecx,15 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
mcall |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
mcall ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,15 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+15*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
mcall |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,15 |
mcall |
ret |
nof12: |
jmp still |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the filename and IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The filename, in source, is converted and stored in tftp_filename |
; The host ip, in destination, is converted and stored in tftp_IP |
; |
;*************************************************************************** |
translateData: |
; first, build up the tftp command string. This includes the filename |
; and the transfer protocol |
; First, write 0,0 |
mov al, 0 |
mov edi, tftp_filename |
mov [edi], al |
inc edi |
mov [edi], al |
inc edi |
; Now, write the file name itself, and null terminate it |
mov ecx, 15 |
mov ah, ' ' |
mov esi, source |
td001: |
lodsb |
stosb |
cmp al, ah |
loopnz td001 |
cmp al,ah ; Was the entire buffer full of characters? |
jne td002 |
dec edi ; No - so remove ' ' character |
td002: |
mov [edi], byte 0 |
inc edi |
mov [edi], byte 'O' |
inc edi |
mov [edi], byte 'C' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 'E' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 0 |
mov esi, tftp_filename |
sub edi, esi |
mov [tftp_len], edi |
; Now, convert the typed IP address into a real address |
; No validation is done on the number entered |
; ip addresses must be typed in normally, eg |
; 192.1.45.24 |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [tftp_IP], eax |
; 192.168.24.1 1.1.1.1 1. 9.2.3. |
mov esi, destination |
mov edi, tftp_IP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
ret |
;*************************************************************************** |
; Function |
; copyFromRemote |
; |
; Description |
; |
;*************************************************************************** |
copyFromRemote: |
mov eax,0x20000-512 |
mov [fileposition], eax |
; Get a random # for the local socket port # |
mov eax, 3 |
mcall |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
mcall |
mov [socketNum], eax |
; make sure there is no data in the socket - there shouldn't be.. |
cfr001: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne cfr001 ; yes, so get it |
; Now, request the file |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
mcall |
cfr002: |
mov eax,23 ; wait here for event |
mov ebx,1 ; Time out after 10ms |
mcall |
cmp eax,1 ; redraw request ? |
je cfr003 |
cmp eax,2 ; key in buffer ? |
je cfr004 |
cmp eax,3 ; button in buffer ? |
je cfr005 |
; Any data to fetch? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall |
cmp eax, 0 |
je cfr002 |
push eax ; eax holds # chars |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p3 |
je cfr008 |
mov dword [prompt], p3 |
mov dword [promptlen], p3len - p3 |
call draw_window ; |
cfr008: |
; we have data - this will be a tftp frame |
; read first two bytes - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
pop eax |
; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
cmp bl, 3 |
jne cfrerr |
push eax |
; do data stuff. Read block #. Read data. Send Ack. |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov [blockNumber+1], bl |
cfr007: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov esi, [fileposition] |
mov [esi], bl |
mov [esi+1],bl |
add dword [fileposition],2 |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne cfr007 ; yes, so get it |
cmp [fileposition],0x20000+0xffff |
jb get_more_stream |
wait_more: |
mov eax,5 ; wait for correct timer position |
; to trigger new play block |
mov ebx,1 |
mcall |
mov eax,26 |
mov ebx,9 |
mcall |
cmp eax,[wait_for] |
jb wait_more |
add eax,[delay] |
mov [wait_for],eax |
mov esi,0x20000 |
mov edi,0x10000 |
mov ecx,65536 |
cld |
rep movsb |
mov eax,55 |
mov ebx,0 |
mov ecx,0x10000 |
mcall |
mov eax,55 |
mov ebx,1 |
mcall |
mov [fileposition],0x20000 |
get_more_stream: |
; write the block number into the ack |
mov al, [blockNumber] |
mov [ack + 2], al |
mov al, [blockNumber+1] |
mov [ack + 3], al |
; send an 'ack' |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, ackLen - ack |
mov esi, ack |
mcall |
; If # of chars in the frame is less that 516, |
; this frame is the last |
pop eax |
cmp eax, 516 |
je cfr002 |
; Write the file |
mov eax, 33 |
mov ebx, source |
mov edx, [filesize] |
mov ecx, I_END + 512 |
mov esi, 0 |
mcall |
jmp cfrexit |
cfrerr: |
; simple implementation on error - just read all data, and return |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
mcall ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
mcall ; any more data? |
cmp eax, 0 |
jne cfrerr ; yes, so get it |
jmp cfr006 ; close socket and close app |
cfr003: ; redraw request |
call draw_window |
jmp cfr002 |
cfr004: ; key pressed |
mov eax,2 ; just read it and ignore |
mcall |
jmp cfr002 |
cfr005: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; button id=1 ? |
jne cfr002 ; If not, ignore. |
cfr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
mcall |
jmp $ |
cfrexit: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
mcall |
mov [socketNum], dword 0 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
mov ecx,100*65536+170 ; [y start] *65536 + [y size] |
mov edx,0x14224466 ; color of work area RRGGBB |
mov edi,title |
mcall |
mov eax,8 ; DELETE BUTTON |
mov ebx,20*65536+190 |
mov ecx,111*65536+15 |
mov edx,2 |
mov esi,0x557799 |
mcall |
mov ebx,200*65536+10 |
mov ecx,34*65536+10 |
mov edx,4 |
mcall |
mov ecx,50*65536+10 |
mov edx,5 |
mcall |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,source |
mov edi,text+13 |
mov ecx,15 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,destination |
mov edi,text+40+13 |
mov ecx,15 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+280 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov eax,4 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mcall |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
ret |
; DATA AREA |
source db 'HEAT8M22.WAV ' |
destination db '192.168.1.24 ' |
tftp_filename: times 15 + 9 db 0 |
tftp_IP: dd 0 |
tftp_len: dd 0 |
addr dd 0x0 |
ya dd 0x0 |
fileposition dd 0 ; Points to the current point in the file |
filesize dd 0 ; The number of bytes written / left to write |
fileblocksize dw 0 ; The number of bytes to send in this frame |
text: |
db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
db ' ' |
db 'WAVE FORMAT: 8 BIT,MONO,22050HZ ' |
db ' ' |
db ' SERVER -> PLAY FILE ' |
db ' ' |
db ' ' |
db 'x' ; <- END MARKER, DONT DELETE |
title db 'TFTP Wave Player',0 |
prompt: dd 0 |
promptlen: dd 0 |
p1: db 'Waiting for Command ' |
p1len: |
p9: db 'Define SB with setup' |
p9len: |
p2: db 'Sending File ' |
p2len: |
p3: db 'Playing File ' |
p3len: |
p4: db 'Complete ' |
p4len: |
p5: db 'Contacting Host... ' |
p5len: |
p6: db 'File not found. ' |
p6len: |
ack: |
db 00,04,0,1 |
ackLen: |
socketNum: |
dd 0 |
blockNumber: |
dw 0 |
; This must be the last part of the file, because the blockBuffer |
; continues at I_END. |
blockBuffer: |
db 00, 03, 00, 01 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/tftpa/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tftpa.asm tftpa |
@erase lang.inc |
@pause |
/programs/network_old/tftpa/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tftpa.asm tftpa |
@erase lang.inc |
@pause |
/programs/network_old/ym/trunk/ym.asm |
---|
0,0 → 1,1069 |
; Yahoo Messanger for MenuetOS |
; Compile with FASM for Menuet |
;B+ System header |
use32 |
org 0x0 |
db 'MENUET01' ; header |
dd 0x01 ; header version |
dd START ; entry point |
dd I_END ; image size |
dd I_END+0x10000 ; required memory |
dd I_END+0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Path |
;E:. |
include 'lang.inc' |
include '..\..\..\macros.inc' |
;B+ Definitions |
v_sp equ 330 |
h_sp equ 400 |
fr_sp equ 120 |
line_wid equ 45 |
fr_max_lines equ 17 |
;memory |
sys_colors equ I_END |
text_zone equ sys_colors+4*10 |
;friend_zone equ text_zone+45*25 ;uncom |
;friend_zone+32*fr_max_lines |
;E:. |
START: |
;B+ Main execution |
mov ebx,3 |
mov ecx,sys_colors |
mov edx,10*4 |
mov eax,48 |
mcall |
call clear_text |
red: |
call draw_window |
still: |
mov ebx,50 |
mov eax,23 |
mcall |
cmp eax,1 |
je red |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
call check_message |
jmp still |
key: |
mov eax,2 |
mcall |
cmp [is_connect],0 |
je still |
call send_key_string |
jmp still |
button: |
mov eax,17 |
mcall |
cmp ah,1 |
jne noclose |
or eax,-1 |
mcall |
jmp $ |
noclose: |
;B+ Check friend |
cmp ah,2 |
jb .no_friend |
cmp ah,100 |
ja .no_friend |
;pressed number |
sub ah,2 |
shr ax,8 |
;find real name |
mov [friend_p],friend_zone |
mov edi,0 |
.next: |
push [friend_p] |
call test_friend |
jc .group |
inc edi |
.group: |
cmp di,ax |
pop ebx |
jbe .next |
inc ebx |
;exact place |
mov ecx,[friend_p] |
sub ecx,ebx |
dec ecx |
;Insert in send |
cmp al,10 |
jb .good |
add al,'A'-'0'-10 |
.good: |
add al,'0' |
mov [view_text+1],al |
;Clear old a. friend |
pusha |
mov ebx,(h_sp-140) shl 16 + 132 |
mov ecx,(v_sp-53) shl 16 + 10 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
mcall |
popa |
;show item |
mov [f_name_b],ebx |
mov [f_name_l],ecx |
call show_a_friend |
jmp still |
.no_friend: |
;E:. |
;B+ Check User / Password |
cmp ah,103 |
je input_username |
cmp ah,104 |
je input_password |
;E:. |
;B+ Connect / Dis... |
cmp ah,101 |
je yahoo_c |
cmp ah,102 |
je yahoo_d |
;E:. |
jmp still |
;E:. |
draw_window: |
;B+ Draw window |
mov ebx,1 |
mov eax,12 |
mcall |
xor eax,eax ;DRAW WINDOW |
mov ebx,150*65536+h_sp |
mov ecx,100*65536+v_sp |
mov edx,[sys_colors+4*5] |
or edx,0x14000000 |
mov edi,title |
mcall |
;B+ Friend panel |
mov ebx,(h_sp-fr_sp) shl 16 + 3 |
mov ecx,20 shl 16 + v_sp-31 -56 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
mcall |
call show_friends |
;E:. |
;B+ Input panel |
mov ebx,5 shl 16 + h_sp-9 |
mov ecx,(v_sp-31 -33-3) shl 16 + 3 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
mcall |
mov ebx,(h_sp-(fr_sp-12)*8/6) shl 16 + 4 |
mov ecx,(v_sp-31-33) shl 16 + 30 |
mcall |
mov ebx,(h_sp-8) shl 16 + 4 |
mcall |
call show_a_friend |
call show_string |
;E:. |
;B+ Login panel |
mov ebx,5 shl 16 + h_sp-9 |
mov ecx,(v_sp-35) shl 16 + 31 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
mcall |
mov ebx,(5+2+8+(user_txt_end-user_txt)*6) shl 16 + 6*15+7 |
mov ecx,(v_sp-32) shl 16 + 12 |
mov edx,[sys_colors+4*5] |
mcall |
mov ebx,(171+2+8+(psw_txt_end-psw_txt)*6) shl 16 + 6*23+7 |
mov ecx,(v_sp-32) shl 16 + 12 |
mcall |
;connect button |
mov ebx,(h_sp-128) shl 16 + (con_txt_end-con_txt)*6 + 7 |
mov ecx,(v_sp-18) shl 16 + 12 |
mov edx,101 |
mov esi,[sys_colors+4*6] |
mov eax,8 |
mcall |
;disconnect button |
shl ebx,16 |
add ebx,(h_sp-128+3) shl 16 + (dis_txt_end-dis_txt)*6 + 7 |
mov edx,102 |
mcall |
;user button |
mov ebx,8 shl 16 + (user_txt_end-user_txt)*6 + 5 |
mov ecx,(v_sp-18-15) shl 16 + 12 |
mov edx,103 |
mcall |
;password button |
mov ebx,174 shl 16 + (psw_txt_end-psw_txt)*6 + 5 |
mov edx,104 |
mcall |
;login text |
mov ebx,11 shl 16 + v_sp-15 |
mov ecx,[sys_colors+4*7] |
mov edx,login_txt |
mov esi,login_txt_end-login_txt |
mov eax,4 |
mcall |
;user text |
mov ebx,11 shl 16 + v_sp-15-15 |
mov edx,user_txt |
mov esi,user_txt_end-user_txt |
mcall |
;password text |
mov ebx,(174+5) shl 16 + v_sp-15-15 |
mov edx,psw_txt |
mov esi,psw_txt_end-psw_txt |
mcall |
;connect text |
mov ebx,(h_sp-128+5) shl 16 + v_sp-15 |
mov edx,con_txt |
mov esi,con_txt_end-con_txt |
mcall |
;disconnect text |
add ebx,((con_txt_end-con_txt)*6+8 + 3) shl 16 |
mov edx,dis_txt |
mov esi,dis_txt_end-dis_txt |
mcall |
call show_username |
call show_password |
;E:. |
call show_text |
mov ebx,2 |
mov eax,12 |
mcall |
ret |
;E:. |
show_friends: |
;B+ Show friend list |
cmp [last_friend_place],friend_zone |
jne .yes_show |
ret |
.yes_show: |
;show button |
mov ebx,(h_sp-fr_sp+5) shl 16 + 10 |
mov ecx,(20+3) shl 16 + 10 |
mov edx,2 |
mov esi,[sys_colors+4*6] |
mov eax,8 |
mov edi,0 |
mov [friend_p],friend_zone |
.next_button: |
call test_friend |
jc .no_b |
mcall |
inc edx |
.no_b: |
inc edi |
add ecx,15 shl 16 |
cmp edi,[last_friend_line] |
jne .next_button |
;show numbers |
mov [digit],'0'-1 |
mov ebx,(h_sp-fr_sp+8) shl 16 + (20+3)+2 |
;mov ecx,[sys_colors+4*7] |
mov edx,digit |
mov esi,1 |
mov eax,4 |
mov edi,0 |
mov [friend_p],friend_zone |
push edx |
.next_digit: |
mov edx,[friend_p] |
call test_friend |
cmp [edx],byte 1 |
je .no_item |
inc [digit] |
cmp [digit],'9'+1 |
jne .good |
mov [digit],'A' |
.good: |
;add ebx,1 shl 16 |
cmp [edx],byte 2 |
mov edx,[esp] |
mov ecx,[sys_colors+4*6] |
call hi_light |
jne .no_online |
mov ecx,[sys_colors+4*7] |
;mcall |
;or ecx,0x10000000 |
.no_online: |
;sub ebx,1 shl 16 |
mcall |
;and ecx,not 0x10000000 |
.no_item: |
add ebx,15 |
inc edi |
cmp edi,[last_friend_line] |
jne .next_digit |
add esp,4 |
;show names |
mov ebx,(h_sp-fr_sp+8 + 10) shl 16 + (20+3)+2 |
mov ecx,[sys_colors+4*8] |
mov eax,4 |
mov edi,0 |
mov [friend_p],friend_zone |
mov esi,4 |
.next_name: |
mov edx,[friend_p] |
call test_friend |
mov esi,[friend_p] |
inc edx |
sub esi,edx |
and ebx,0xffff |
or ebx,(h_sp-fr_sp+8 + 10) shl 16 |
cmp [edx-1],byte 1 |
jne .no_group |
sub ebx,12 shl 16 |
.no_group: |
mcall |
add ebx,15 |
inc edi |
cmp edi,[last_friend_line] |
jne .next_name |
ret |
.p db 16 ;> |
digit db '0' |
;last_friend_line dd 0x0 ;uncom |
test_friend: |
push eax |
mov eax,[friend_p] |
clc |
cmp [eax],byte 1 |
jne .no_hide |
stc |
.no_hide: |
pushf |
.next: |
inc [friend_p] |
mov eax,[friend_p] |
cmp [eax],byte 0 |
jne .next |
inc [friend_p] |
popf |
pop eax |
ret |
friend_p dd 0x0 |
hi_light: |
pushf |
add ecx,0x400000 |
test ecx,0xb00000 |
jnz .no_red_plus |
sub ecx,0x400000 |
.no_red_plus: |
add ecx,0x004000 |
test ecx,0x00b000 |
jnz .no_green_plus |
sub ecx,0x008000 |
.no_green_plus: |
add ecx,0x000040 ;80 |
test ecx,0x0000b0 ;80 |
jnz .no_blue_plus |
sub ecx,0x000040 ;100 |
.no_blue_plus: |
popf |
ret |
;E:. |
;B+ Message text op. |
clear_text: |
mov edi,text_zone |
mov ecx,45*26 |
mov al,0 |
cld |
rep stosb |
ret |
show_text: |
mov ebx,7 shl 16 + (20+3) ;+ 2 |
mov ecx,[sys_colors+4*8] |
mov edx,text_zone+45 |
mov esi,45 |
mov eax,4 |
mov edi,0 |
.next_line: |
cmp [edx-1],byte 0 |
jne .shift |
mcall |
.next: |
add ebx,10 |
add edx,45 |
inc edi |
cmp edi,24 |
jne .next_line |
ret |
.shift: |
add ebx,3 shl 16 |
mcall |
sub ebx,3 shl 16 |
jmp .next |
scroll_text: |
pusha |
;move text |
mov edi,text_zone |
mov esi,edi |
add esi,line_wid |
mov ecx,line_wid*24 |
cld |
rep movsb |
;clear last line |
mov ecx,line_wid |
mov al,0 |
rep stosb |
;clear zone |
mov ebx,7 shl 16 + line_wid*6+2 |
mov ecx,(25-2) shl 16 + 24*10-2 +2 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
mcall |
;show text |
call show_text |
popa |
ret |
show_message: |
;ebx - begin |
;ecx - length |
mov eax,[.m_p] |
add eax,ecx |
.test: |
cmp eax,text_zone+line_wid*25-1 |
jb .good1 |
call scroll_text |
sub eax,line_wid |
sub [.m_p],line_wid |
jmp .test |
.good1: |
cmp [.m_p],text_zone+line_wid |
jae .good2 |
add ebx,line_wid |
add [.m_p],line_wid |
sub ecx,line_wid |
jmp .good1 |
.good2: |
; |
push ecx |
mov esi,ebx |
mov edi,[.m_p] |
cld |
rep movsb |
pop ecx |
;find v place |
mov eax,[.m_p] |
sub eax,text_zone+line_wid |
mov ebx,line_wid |
xor edx,edx |
div ebx |
xor edx,edx |
mov ebx,10 |
mul ebx |
mov ebx,eax |
;show line |
add ebx,7 shl 16 + 23 ;+2 |
mov ecx,[sys_colors+4*8] |
mov edx,[.m_p] |
mov esi,line_wid |
mov eax,4 |
mcall |
add ebx,3 shl 16 |
.next_line: |
add ebx,10 |
add edx,line_wid |
cmp [edx-1],byte 0 |
je .good3 |
mcall |
jmp .next_line |
.good3: |
mov [.m_p],edx |
ret |
.m_p dd text_zone+45 |
;E:. |
;B+ Show current people |
show_a_friend: |
mov ebx,(h_sp-137) shl 16 + v_sp-52 |
mov ecx,[sys_colors+4*8] |
or ecx,0x10000000 |
mov edx,[f_name_b] |
mov esi,[f_name_l] |
mov eax,4 |
mcall |
ret |
f_name_b dd fnb |
f_name_l dd 10 |
fnb: |
db 'yahoo_help' |
;E:. |
;B+ Input strings |
send_key_string: |
;B+ Test active keys |
cmp ah,13 |
je send_text |
cmp ah,27 |
je clear_input_text |
cmp ah,8 |
je .backs_text |
;E:. |
mov [.this_c],ah |
cmp [.c_pl],123 |
jne .show |
ret |
.show: |
;save char |
mov ebx,[.c_pl] |
mov [in_text+ebx],ah |
inc [.c_pl] |
;show char |
mov ebx,[.xy] |
mov ecx,[sys_colors+4*8] |
mov edx,.this_c |
mov esi,1 |
mov eax,4 |
mcall |
; |
cmp [.c_pl],41 |
je .new_line |
cmp [.c_pl],82 |
je .new_line |
add [.xy],6 shl 16 |
call show_cursor |
ret |
;;; |
.new_line: |
and [.xy],0x0000ffff |
add [.xy],9 shl 16 + 9 |
call show_cursor |
ret |
.this_c db ' ' |
.c_pl dd 0x0 |
.xy dd 7 shl 16 + v_sp-62 |
;B+ Special keys - action |
.backs_text: |
; |
cmp [.c_pl],0 |
jne .yes_back |
ret |
.yes_back: |
cmp [.c_pl],41 |
je .back_line |
add [.xy],2 shl 16 |
cmp [.c_pl],82 |
je .back_line |
sub [.xy],2 shl 16 |
.next: |
; |
sub [.xy],6 shl 16 |
dec [.c_pl] |
mov eax,[.c_pl] |
mov bl,[in_text+eax] |
mov [.this_c],bl |
mov ebx,[.xy] |
mov ecx,[sys_colors+4*5] |
mov edx,.this_c |
mov esi,1 |
mov eax,4 |
mcall |
mov ebx,[.c_pl] |
mov [in_text+ebx],byte 0 |
jmp show_cursor |
; |
.back_line: |
;and [.xy],0x0000ffff |
sub [.xy],9 |
add [.xy],(253-9) shl 16 |
jmp .next |
send_text: |
;show text to message board |
mov ebx,view_text |
mov ecx,[send_key_string.c_pl] |
add ecx,3 |
call show_message |
;send message to internet |
;call internet_send |
clear_input_text: |
;prepare new message |
;; clear memory |
mov edi,in_text |
mov ecx,255/4 |
xor eax,eax |
cld |
rep stosd |
;; clear zone |
mov ebx,5 shl 16 + h_sp-140-9 |
mov ecx,(v_sp-31 -33) shl 16 + 29 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
mcall |
;; move cursor |
mov ebx,7 shl 16 + v_sp-62 |
mov [send_key_string.xy],ebx |
mov [show_cursor.old_xy],ebx |
;; clear place |
xor ebx,ebx |
mov [send_key_string.c_pl],ebx |
; call show_cursor |
; ret |
;E:. |
show_cursor: |
;login text |
; mov ebx,4 shl 16 + v_sp-64 |
mov ebx,[.old_xy] |
sub ebx,3 shl 16 + 2 |
mov ecx,[sys_colors+4*5] |
mov edx,curs |
mov esi,1 |
mov eax,4 |
mcall |
add ebx,4 |
mcall |
mov ebx,[send_key_string.xy] |
mov [.old_xy],ebx |
sub ebx,3 shl 16 + 2 |
mov ecx,0xffffff;[sys_colors+4*8] |
mcall |
add ebx,4 |
mcall |
ret |
.old_xy dd 7 shl 16 + v_sp-62 |
curs db '|' |
show_string: |
mov ebx,7 shl 16 + v_sp-62 |
mov ecx,[sys_colors+4*8] |
mov edx,in_text |
mov esi,41 |
mov eax,4 |
mcall |
add ebx,2 shl 16 + 9 |
add edx,41 |
mcall |
add ebx,9 |
add edx,41 |
mcall |
call show_cursor |
ret |
view_text db 16,'?',16 |
in_text: times 255 db 0 |
;E:. |
;B+ Friends... |
add_friend: |
;ebx - begin |
; [ebx]=1 - Group name |
; [ebx]=2 - Active user |
; [ebx]=other - Non active user |
;ecx - length |
cmp [last_friend_line],fr_max_lines-1 |
je .no_more |
test ecx,not 31 |
jnz .no_more ; very long id name |
inc [last_friend_line] |
mov esi,ebx |
mov edi,[last_friend_place] |
inc ecx |
add [last_friend_place],ecx |
dec ecx |
cld |
rep movsb |
mov al,0 |
stosb |
stosb |
.no_more: |
ret |
last_friend_place dd fr_e ;del |
;last_friend_place dd friend_zone ;uncom |
find_friend: |
push ebx ecx |
mov edx,friend_zone |
mov esi,0 |
mov edi,[last_friend_line] |
; inc edi ;? uncom ? |
.next_name: |
cmp [edx],byte 1 |
je .no_find ;Group |
inc edx |
dec ecx |
.next: |
mov al,[edx] |
mov ah,[ebx] |
cmp ah,al |
jne .no_find |
inc edx |
inc ebx |
dec ecx |
jne .next |
cmp [edx],byte 0 |
jne .no_find |
;find |
mov eax,esi |
cmp esi,9 |
ja .letter |
add al,'0' |
ret |
.letter: |
add al,'A'-10 |
ret |
.no_find: |
cmp [edx],byte 0 |
je .go_next |
inc edx |
jmp .no_find |
.go_next: |
dec edi |
je .noting |
mov ebx,[esp+4] |
mov ecx,[esp] |
inc esi |
jmp .next_name |
.noting: |
mov al,'!' |
pop ecx ebx |
ret |
;E:. |
;B+ Connect / Disconnect |
yahoo_c: |
call connect |
cmp eax,0 |
jne still ;not connected |
mov [is_connect],0x1 |
jmp still |
yahoo_d: |
cmp [is_connect],0x0 |
je .noting |
call disconnect |
; |
;stop connection |
mov [is_connect],0x0 |
; |
;clear text |
mov ah,27 |
call send_key_string |
; |
;clear friends |
; mov [last_friend_line],0x0 ;uncom |
; mov [last_friend_place],friend_zone ;uncom |
; |
;set dafaut friend |
mov [f_name_b],fnb |
mov [f_name_l],10 |
mov [view_text+1],'?' |
call draw_window |
.noting: |
jmp still |
is_connect dd 0x0 |
;E:. |
;B+ Load username / password |
input_username: |
mov edi,username |
mov [edi],byte '_' |
inc edi |
mov ecx,16-1 |
cld |
rep stosb |
mov [.unp],username |
.next: |
call show_username |
;get enen |
mov eax,10 |
mcall |
cmp eax,1 |
je .end |
cmp eax,3 |
je .end |
;key |
mov eax,2 |
mcall |
cmp ah,13 |
je .end |
cmp ah,8 |
jne .no_back |
cmp [.unp],username |
je .next |
dec [.unp] |
mov ebx,[.unp] |
mov [ebx],byte '_' |
mov [ebx+1],byte 0 |
jmp .next |
.no_back: |
cmp [.unp],username+16 |
je .next |
cmp ah,'0' |
jb .bad |
mov ebx,[.unp] |
mov [ebx],ah |
mov [ebx+1],byte '_' |
inc [.unp] |
.bad: |
jmp .next |
.end: |
;del cursor |
mov ebx,[.unp] |
mov [ebx],byte 0 |
call show_username |
;clear password |
mov [password],byte 0 |
;hide password |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*5] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
mcall |
jmp still |
.unp dd username |
show_username: |
;hide |
mov ebx,(4+12*6-1) shl 16 + 16*6+1 |
mov ecx,(v_sp-15-15) shl 16 + 9 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
mcall |
;show |
mov ebx,(4+12*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*8] |
mov edx,username |
mov esi,16 |
mov eax,4 |
mcall |
ret |
username: times (16+1) db 0 |
input_password: |
;clear |
mov edi,password |
mov ecx,24 |
mov al,0 |
cld |
rep stosb |
mov [.unp],password |
;hide password |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*5] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
mcall |
.next: |
;get enen |
mov eax,10 |
mcall |
cmp eax,1 |
je still |
cmp eax,3 |
je still |
;key |
mov eax,2 |
mcall |
cmp [.unp],password+24 |
je .no_next |
cmp ah,13 |
jne .no_still |
.no_next: |
call show_password |
jmp still |
.no_still: |
mov ebx,[.unp] |
mov [ebx],ah |
inc [.unp] |
jmp .next |
.unp dd password |
show_password: |
cmp [password],byte 0 |
je .end |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*8] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
mcall |
.end: |
ret |
f_password db '####' |
password: times (24+1) db 0 |
;E:. |
;B+ INTERNET |
;Functions: |
;call add_friend |
; ebx+1 - pointer to name |
; [ebx]=1 - Group name |
; [ebx]=2 - Active user |
; [ebx]=other - Non active user |
; ecx - length |
; |
;call show_message |
; ebx - begin of string |
; ecx - length |
; ----- |
; NOTE Use format: |
; (<char>) <message> |
; where: |
; <char> - friend user char |
; <message> - message from friend |
; |
;call find_friend |
; ebx - begin of name |
; ecx - length |
; ret: |
; al - friend user char |
; ----- |
; NOTE currenly don't show message if al='!' |
;Variables |
;usernave (zero terminated) |
;password (zero terminated) |
;f_name_b - current friend user (to send) |
;f_name_l - ^ length |
;Memory |
; (friend_zone+32*fr_max_lines) < addr: [addr] - free |
connect: |
;conect to yahoo |
;return 0 if OK |
;return <>0 if some other event (sys.func.23) |
mov eax,0 |
ret |
disconnect: |
;disconnect |
ret |
check_message: |
;test receive messages |
ret |
;E:. |
;B+ Test data ;del |
friend_zone: ;del |
db 1,'First:',0 ;del |
db 2,'hahaha',0 ;del |
db 3,'second',0 ;del |
db 3,'menuetos',0 ;del |
db 1,'Treti:',0 ;del |
db 2,'fourth',0 ;del |
fr_e db 0 ;del |
;del |
times 200 db 0 ;del |
;del |
last_friend_line dd 0x6 ;del |
title db 'Messenger (Yahoo Compatible)',0 |
;User / Password |
login_txt db 'STATUS: SESSION: ___.___.___.___' |
;VISIBLE |
;HIDDEN |
login_txt_end: |
user_txt db 'USER ID ->' |
user_txt_end: |
psw_txt db 'PASSWORD ->' |
psw_txt_end: |
con_txt db 'CONNECT' |
con_txt_end: |
dis_txt db 'DISCONNECT' |
dis_txt_end: |
;E:. |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/ym/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ym.asm ym |
@erase lang.inc |
@pause |
/programs/network_old/ym/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ym.asm ym |
@erase lang.inc |
@pause |
/programs/network_old/smtps/trunk/smtps.asm |
---|
0,0 → 1,828 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SMTP server for MenuetOS ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2002 (c) Ville Turjanmaa ;; |
;; ;; |
;; Compile with FASM for Menuet ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.1' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x200000 ; required amount of memory |
dd 0xffff0 |
dd 0,0 |
include '..\..\..\macros.inc' |
save_file: |
; cmp [file_start],0x100000+10 |
; jbe nosub |
; sub [file_start],8 |
; nosub: |
mov eax,[file_start] |
sub eax,0x100000 |
mov ebx,files |
mov [ebx+12],eax |
mov eax,70 |
mcall |
ret |
START: ; start of execution |
mov [file_start],0x100000 |
mov eax,70 |
mov ebx,filel |
mcall |
test eax,eax |
jz @f |
cmp eax,6 |
jnz notfound |
@@: |
add [file_start],ebx |
notfound: |
mov edi,I_END |
mov ecx,60*120 |
mov al,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
redraw: |
call draw_window ; at first, draw the window |
still: |
inc [cursor_on_off] |
mov eax,5 |
mov ebx,1 |
mcall |
mov eax,11 ; wait here for event |
mcall |
cmp eax,1 ; redraw |
je redraw |
cmp eax,2 ; key |
je key |
cmp eax,3 ; button |
je button |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_channel_text |
no_main_update: |
cmp [server_active],0 |
je noread |
cmp [status],4 |
jne noread |
call read_incoming_data |
inc [close_connection] |
cmp [close_connection],15*100 |
jbe noread |
call yq |
noread: |
call print_status |
cmp [status],4 |
je check_header |
jmp still |
check_header: |
cmp [header_sent],1 |
je still |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r220 |
mcall |
mov [header_sent],1 |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
cmp ah,1 ; close program |
jne noclose |
or eax,-1 |
mcall |
noclose: |
call socket_commands |
jmp still |
old_status dd 0x0 |
print_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
mov [status],eax |
cmp eax,[old_status] |
je no_print |
mov [old_status],eax |
push eax |
mov eax,13 |
mov ebx,360*65536+30 |
mov ecx,151*65536+10 |
mov edx,0xffffff |
mcall |
pop ecx |
mov eax,47 |
mov ebx,3*65536 |
mov edx,360*65536+151 |
mov esi,0x000000 |
cmp [server_active],0 |
je no_print |
mcall |
no_print: |
popa |
ret |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
mov eax,3 |
mcall |
mov [server_active],1 |
mov eax,53 |
mov ebx,5 |
mov ecx,25 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov [header_sent],0 |
mov [mail_rp],0 |
mov [server_active],0 |
ret |
no_24: |
ret |
key: |
mov eax,2 |
mcall |
jmp still |
read_incoming_data: |
pusha |
read_new_byte: |
call read_incoming_byte |
cmp ecx,-1 |
je no_data_in_buffer |
mov eax,[file_start] |
mov [eax],bl |
inc [file_start] |
cmp bl,10 |
jne no_start_command |
mov [cmd],1 |
no_start_command: |
cmp bl,13 |
jne no_end_command |
mov eax,[cmd] |
mov [eax+command-2],byte 0 |
call analyze_command |
mov edi,command |
mov ecx,250 |
mov eax,0 |
cld |
rep stosb |
mov [cmd],0 |
no_end_command: |
mov eax,[cmd] |
cmp eax,250 |
jge still |
mov [eax+command-2],bl |
inc [cmd] |
jmp read_new_byte |
no_data_in_buffer: |
popa |
ret |
analyze_command: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
cmp [cmd],2 |
jbe nott |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command+0 |
newcmdc: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc |
nott: |
mov edx,I_END |
call draw_channel_text |
cmd_len_ok: |
cmp [command],dword 'data' |
je datacom |
cmp [command],dword 'DATA' |
je datacom |
cmp [command],dword 'Data' |
je datacom |
jmp nodatacom |
datacom: |
inc [mail_rp] |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r354 |
mcall |
mov [cmd],0 |
popa |
ret |
nodatacom: |
cmp [mail_rp],0 |
jne nomrp0 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r250 |
mcall |
mov [cmd],0 |
popa |
ret |
nomrp0: |
cmp [command],dword 'QUIT' |
je yesquit |
cmp [command],dword 'Quit' |
je yesquit |
cmp [command],dword 'quit' |
je yesquit |
jmp noquit |
yq: |
pusha |
yesquit: |
mov [close_connection],0 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r221 |
mcall |
mov [cmd],0 |
mov eax,5 |
mov ebx,5 |
mcall |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,5 |
mov ebx,5 |
mcall |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov [header_sent],0 |
mov [mail_rp],0 |
call save_file |
mov eax,5 |
mov ebx,20 |
mcall |
mov eax,53 |
mov ebx,5 |
mov ecx,25 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
mcall |
mov [socket], eax |
popa |
ret |
noquit: |
cmp [command],byte '.' |
jne nodot |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r250 |
mcall |
mov [cmd],0 |
popa |
ret |
nodot: |
popa |
ret |
r250 db '250 ',13,10 |
r221 db '221 ',13,10 |
r220 db '220 ',13,10 |
r354 db '354 ',13,10 |
draw_data: |
pusha |
add eax,[text_start] |
mov [eax],bl |
popa |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
read_incoming_byte: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
mcall |
mov ecx,-1 |
cmp eax,0 |
je no_more_data |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
mcall |
mov ecx,0 |
no_more_data: |
ret |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
mcall |
mov [old_status],300 |
mov eax,0 ; draw window |
mov ebx,5*65536+400 |
mov ecx,5*65536+200 |
mov edx,0x13ffffff |
mov edi,title |
mcall |
mov eax,8 ; button: open socket |
mov ebx,23*65536+22 |
mov ecx,169*65536+10 |
mov edx,22 |
mov esi,0x55aa55 |
mcall |
; mov eax,8 ; button: close socket |
mov ebx,265*65536+22 |
mov edx,24 |
mov esi,0xaa5555 |
mcall |
mov eax,38 ; line |
mov ebx,5*65536+395 |
mov ecx,108*65536+108 |
mov edx,0x000000 |
mcall |
mov eax,4 |
mov ebx,5*65536+123 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mcall |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_channel_text |
mov eax,12 |
mov ebx,2 |
mcall |
popa |
ret |
draw_channel_text: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,[scroll+4] |
mov esi,[rxs] |
dct: |
pusha |
mov cx,bx |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
mcall |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
cmp [edx],word '* ' |
jne no_red |
mov ecx,0xff0000 |
no_red: |
cmp [edx],word '**' |
jne no_light_blue |
cmp [edx+2],byte '*' |
jne no_light_blue |
mov ecx,0x0000ff |
no_light_blue: |
cmp [edx],byte '#' |
jne no_blue |
mov ecx,0x00ff00 |
no_blue: |
mcall |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
text: |
db ' Incoming mails are written to /sys/smtps.txt ' |
db ' The file can be fetched with TinyServer and a Html-browser. ' |
db ' Timeout is set to 15 seconds. ' |
db ' ' |
db ' Open SMTP server port 25 Close SMTP ' |
db 'x' ; <- END MARKER, DONT DELETE |
irc_server_ip db 192,168,1,1 |
file_start dd 0x100000 |
files: |
dd 2,0,0,?,0x100000 |
db '/sys/smtps.txt',0 |
filel: |
dd 0,0,0,0x100000,0x100000 |
db '/sys/smtps.txt',0 |
server_active dd 0 |
status dd 0x0 |
header_sent db 0 |
channel_temp: times 100 db 0 |
channel_temp_length dd 0x0 |
close_connection dd 0x0 |
mail_rp dd 0 |
socket dd 0x0 |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
cursor_on_off dd 0x0 |
max_windows dd 20 |
thread_stack dd 0x9fff0 |
thread_nro dd 1 |
thread_screen dd I_END+120*80*1 |
action_header_blue db 10,'*** ',0 |
action_header_red db 10,'*** ',0 |
action_header_short db 10,'* ',0 |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
irc_data dd 0x0 |
print db 0x0 |
cmd dd 0x0 |
rxs dd 56 |
res: db 0,0 |
command: times 256 db 0x0 |
nick dd 0,0,0 |
irc_command dd 0,0 |
command_position dd 0x0 |
counter dd 0 |
send_to_server db 0 |
channel_list: times 32*20 db 32 |
send_to_channel dd 0x0 |
send_string: times 100 db 0x0 |
xpos dd 0 |
attribute dd 0 |
scroll dd 1 |
dd 8 |
numtext db ' ' |
title db 'Tiny SMTP email server v ',version,0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network_old/smtps/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm smtps.asm smtps |
@erase lang.inc |
@pause |
/programs/network_old/smtps/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm smtps.asm smtps |
@erase lang.inc |
@pause |
/programs/network_old/nntpc/trunk/build_en.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm nntpc.asm nntpc |
@erase lang.inc |
@pause |
/programs/network_old/nntpc/trunk/build_ru.bat |
---|
0,0 → 1,5 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm nntpc.asm nntpc |
@erase lang.inc |
@pause |
/programs/network_old/nntpc/trunk/nntpc.asm |
---|
0,0 → 1,911 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; NNTP CLIENT v 0.1 |
;; |
;; (C) Ville Turjanmaa |
;; |
version equ '0.1' |
include "lang.inc" |
include "..\..\..\macros.inc" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x80000 ; memory for app |
dd 0x80000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
connect_state db 0,0,'Disconnected' |
db 1,3,'Trying.. ' |
db 4,4,'Connected ' |
db 5,9,'Closing.. ' |
prev_state dd -1 |
space dd 0x0 |
text_start dd 0x0 |
text_current dd 0x0 |
status dd 0x0 |
server_ip db 192,168,0,96 |
socket dd 0x0 |
xpos dd 0x0 |
ypos dd 0x0 |
;; |
group db 'GROUP alt.test',13,10 |
db ' ' |
grouplen dd 16 |
stat db 'STAT ' |
statlen dd 0x0 |
article db 'ARTICLE',13,10 |
articlelen: |
;; |
quit db 'QUIT',13,10 |
quitlen: |
xwait dd 0x0 |
ywait dd 0x0 |
article_n dd 0x0 |
article_l dd 0x0 |
article_start dd 0x0 |
article_last dd 0x0 |
article_all dd 0x0 |
article_fetch dd 0x0 |
xpost dd 0x0 |
edisave dd 0x0 |
connection_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
mcall |
cmp eax,[prev_state] |
je no_cos |
mov [prev_state],eax |
mov eax,13 |
mov ebx,435*65536+12*6 |
mov ecx,42*65536+10 |
mov edx,0xffffff |
mcall |
mov ecx,-14 |
mov eax,[prev_state] |
next_test: |
add ecx,14 |
cmp ecx,14*4 |
je no_cos |
cmp al,[connect_state+ecx+0] |
jb next_test |
cmp al,[connect_state+ecx+1] |
jg next_test |
mov edx,ecx |
add edx,2 |
add edx,connect_state |
mov eax,4 |
mov ebx,435*65536+42 |
mov ecx,0x000000 |
mov esi,12 |
mcall |
no_cos: |
popa |
ret |
text_input: |
pusha |
mov ecx,25 |
mov eax,32 |
cld |
rep stosb |
popa |
mov [edisave],edi |
ti0: |
mov [edi],byte ' ' |
call draw_entries |
mov eax,10 |
mcall |
cmp eax,2 |
jne no_more_text |
mov eax,2 |
mcall |
cmp ah,8 |
jne no_bg |
cmp edi,[edisave] |
je ti0 |
dec edi |
jmp ti0 |
no_bg: |
cmp ah,13 |
je no_more_text |
mov [edi],ah |
inc edi |
call draw_entries |
jmp ti0 |
no_more_text: |
mov [xpost],edi |
ret |
convert_text_to_ip: |
pusha |
mov edi,server_ip |
mov esi,text+10 |
mov eax,0 |
mov edx,[xpost] |
newsip: |
cmp [esi],byte '.' |
je sipn |
cmp esi,edx |
jge sipn |
movzx ebx,byte [esi] |
inc esi |
imul eax,10 |
sub ebx,48 |
add eax,ebx |
jmp newsip |
sipn: |
mov [edi],al |
xor eax,eax |
inc esi |
cmp esi,text+50 |
jg sipnn |
inc edi |
cmp edi,server_ip+3 |
jbe newsip |
sipnn: |
popa |
ret |
send_group: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[grouplen] |
mov esi,group |
mcall |
mov [status],3 |
call clear_text |
call save_coordinates |
ret |
convert_number_to_text: |
pusha |
mov eax,[esi] |
mov ecx,0 |
newch: |
inc ecx |
xor edx,edx |
mov ebx,10 |
div ebx |
cmp eax,0 |
jne newch |
add edi,ecx |
dec edi |
mov [article_l],ecx |
mov eax,[esi] |
newdiv: |
xor edx,edx |
mov ebx,10 |
div ebx |
add edx,48 |
mov [edi],dl |
dec edi |
loop newdiv |
popa |
ret |
convert_text_to_number: |
pusha |
mov edx,0 |
newdigit: |
movzx eax,byte [esi] |
cmp eax,'0' |
jb cend |
cmp eax,'9' |
jg cend |
imul edx,10 |
add edx,eax |
sub edx,48 |
inc esi |
jmp newdigit |
cend: |
mov [edi],edx |
popa |
ret |
clear_text: |
mov [text_start],0 |
mov [xpos],0 |
mov [ypos],0 |
mov [xwait],0 |
mov [ywait],0 |
mov edi,nntp_text |
mov ecx,0x50000 |
mov eax,32 |
cld |
rep stosb |
ret |
state_machine_write: |
cmp [status],2 |
jne no_22 |
call send_group |
ret |
no_22: |
cmp [status],4 |
jne no_4 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[statlen] ; -stat |
mov esi,stat |
mcall |
mov [status],5 |
call save_coordinates |
ret |
no_4: |
cmp [status],6 |
jne no_6 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,articlelen-article |
mov esi,article |
mcall |
mov [status],7 |
call save_coordinates |
ret |
no_6: |
ret |
save_coordinates: |
mov eax,[xpos] |
mov ebx,[ypos] |
mov [xwait],eax |
mov [ywait],ebx |
ret |
state_machine_read: |
cmp [status],1 |
jne no_1 |
mov eax,'200 ' |
call wait_for_string |
ret |
no_1: |
cmp [status],3 ;; responce to group |
jne no_3 |
mov eax,'211 ' |
call wait_for_string |
ret |
no_3: |
cmp [status],5 ;; responce to stat |
jne no_5 |
mov eax,'223 ' |
call wait_for_string |
ret |
no_5: |
;; after 'article' request - no wait |
cmp [status],9 |
jne no_9 |
mov eax,'222 ' |
call wait_for_string |
ret |
no_9: |
ret |
wait_for_string: |
mov ecx,[ywait] |
imul ecx,80 |
add ecx,[xwait] |
mov ecx,[nntp_text+ecx] |
cmp eax,ecx |
jne no_match |
cmp [status],3 |
jne no_stat_ret |
mov esi,[ywait] |
imul esi,80 |
add esi,[xwait] |
new32s: |
inc esi |
movzx eax,byte [esi+nntp_text] |
cmp eax,47 |
jge new32s |
new32s2: |
inc esi |
movzx eax,byte [esi+nntp_text] |
cmp eax,47 |
jge new32s2 |
inc esi |
add esi,nntp_text |
; mov [esi-1],byte '.' |
mov edi,article_n |
call convert_text_to_number |
mov eax,[article_n] |
mov [article_start],eax |
new32s3: |
inc esi |
movzx eax,byte [esi] |
cmp eax,47 |
jge new32s3 |
inc esi |
mov edi,article_last |
call convert_text_to_number |
mov eax,[text_current] |
add [article_n],eax |
mov esi,article_n |
mov edi,nntp_text+71 |
call convert_number_to_text |
mov esi,article_n |
mov edi,stat+5 |
call convert_number_to_text |
mov eax,[article_l] |
mov [stat+5+eax],byte 13 |
mov [stat+6+eax],byte 10 |
add eax,5+2 |
mov [statlen],eax |
pusha |
mov edi,text+10+66*2 |
mov ecx,25 |
mov eax,32 |
cld |
rep stosb |
mov esi,text_current |
mov edi,text+10+66*2 |
call convert_number_to_text |
mov eax,32 |
mov ecx,20 |
mov edi,text+10+66*3 |
cld |
rep stosb |
mov eax,[article_last] |
sub eax,[article_start] |
mov [article_all],eax |
mov esi,article_all |
mov edi,text+10+66*3 |
call convert_number_to_text |
call draw_entries |
popa |
call draw_text |
no_stat_ret: |
inc [status] |
mov eax,5 |
mov ebx,10 |
mcall |
call check_for_incoming_data |
no_match: |
ret |
START: ; start of execution |
mov eax,40 |
mov ebx,10000111b |
mcall |
call clear_text |
call draw_window |
still: |
call state_machine_write |
call state_machine_read |
mov eax,23 ; wait here for event |
mov ebx,5 |
mcall |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
call check_for_incoming_data |
call connection_status |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
mcall |
cmp ah,' ' |
jne no_space |
mov eax,[space] |
dec eax |
add [text_start],eax |
call draw_text |
jmp still |
no_space: |
cmp ah,177 |
jne no_plus |
inc [text_start] |
call draw_text |
jmp still |
no_plus: |
cmp ah,178 |
jne no_minus |
cmp [text_start],0 |
je no_minus |
dec [text_start] |
call draw_text |
jmp still |
no_minus: |
cmp ah,179 |
jne no_next |
inc [text_current] |
call send_group |
jmp still |
no_next: |
cmp ah,176 |
jne no_prev |
cmp [text_current],0 |
je still |
dec [text_current] |
call send_group |
jmp still |
no_prev: |
jmp still |
button: ; button |
mov eax,17 ; get id |
mcall |
shr eax,8 |
cmp eax,11 |
jne no_11 |
mov edi,text+10 |
call text_input |
call convert_text_to_ip |
jmp still |
no_11: |
cmp eax,12 |
jne no_12 |
mov edi,text+66+10 |
call text_input |
mov esi,text+66+10 |
mov edi,group+6 |
mov ecx,[xpost] |
sub ecx,text+66+10 |
mov eax,ecx |
cld |
rep movsb |
mov [group+6+eax],byte 13 |
mov [group+7+eax],byte 10 |
add eax,6+2 |
mov [grouplen],eax |
mov [text_current],0 |
jmp still |
no_12: |
cmp eax,13 |
jne no_13 |
mov edi,text+10+66*2 |
call text_input |
mov esi,text+10+66*2 |
mov edi,text_current |
call convert_text_to_number |
call send_group |
jmp still |
no_13: |
cmp eax,14 |
jne no_start |
call clear_text |
mov eax,3 |
mcall |
mov ecx,eax |
mov eax,53 |
mov ebx,5 |
mov edx,119 |
mov esi,dword [server_ip] |
mov edi,1 |
mcall |
mov [socket],eax |
mov [status],1 |
jmp still |
no_start: |
cmp eax,15 |
jne no_end |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,quitlen-quit |
mov esi,quit |
mcall |
mov eax,5 |
mov ebx,10 |
mcall |
call check_for_incoming_data |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov eax,5 |
mov ebx,5 |
mcall |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
mcall |
mov [status],0 |
jmp still |
no_end: |
cmp eax,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
mcall |
noclose: |
jmp still |
check_for_incoming_data: |
cmp [status],0 |
jne go_on |
ret |
go_on: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
je ch_ret |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
mcall |
and ebx,0xff |
cmp ebx,13 |
jb no_print |
cmp bl,13 |
jne char |
mov [xpos],0 |
inc [ypos] |
jmp no_print |
char: |
cmp ebx,128 |
jbe char_ok |
mov ebx,'?' |
char_ok: |
mov ecx,[ypos] |
imul ecx,80 |
add ecx,[xpos] |
mov [nntp_text+ecx],bl |
cmp [xpos],78 |
jg noxinc |
inc [xpos] |
noxinc: |
no_print: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
mcall |
cmp eax,0 |
jne check_for_incoming_data |
call draw_text |
ch_ret: |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov [prev_state],-1 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
mcall |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+520 ; [x start] *65536 + [x size] |
mov ecx,5*65536+470 ; [y start] *65536 + [y size] |
mov edx,0x13ffffff ; color of work area RRGGBB,8->color gl |
mov edi,title ; WINDOW LABEL |
mcall |
mov eax,38 |
mov ebx,5*65536+515 |
mov ecx,101*65536+101 |
mov edx,0x99bbff |
mcall |
mov ecx,102*65536+102 |
mov edx,0x3366aa |
mcall |
mov eax,8 |
mov ebx,238*65536+8 |
mov ecx,30*65536+8 |
mov edx,11 |
mov esi,0x88aadd |
mcall |
mov ecx,41*65536+8 |
mov edx,12 |
mcall |
mov ecx,52*65536+8 |
mov edx,13 |
mcall |
mov ebx,265*65536+75 |
mov ecx,39*65536+13 |
mov edx,14 |
mcall |
mov ebx,351*65536+75 |
mov edx,15 |
mcall |
call draw_entries |
call draw_text |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
mcall |
popa |
ret |
draw_entries: |
pusha |
mov eax,13 |
mov ebx,30*65536+200 |
mov ecx,30*65536+44 |
mov edx,0xffffff |
mcall |
mov eax,4 |
mov ebx,30*65536+31 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,66 |
mov edi,6 |
newline2: |
mcall |
add ebx,11 |
add edx,66 |
dec edi |
jnz newline2 |
popa |
ret |
draw_text: |
pusha |
mov eax,9 |
mov ebx,0x70000 |
mov ecx,-1 |
mcall |
mov eax,[0x70000+46] |
cmp eax,150 |
jbe dtret |
sub eax,111 |
mov ebx,10 |
xor edx,edx |
div ebx |
mov edi,eax |
dec edi |
mov [space],edi |
mov eax,4 |
mov ebx,20*65536+111 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,[text_start] |
imul edx,80 |
add edx,nntp_text |
mov esi,80 |
newline: |
pusha |
mov ecx,ebx |
shl ecx,16 |
mov eax,13 |
mov ebx,20*65536+80*6 |
mov cx,10 |
mov edx,0xffffff |
mcall |
popa |
mcall |
add ebx,10 |
add edx,80 |
dec edi |
jnz newline |
dtret: |
popa |
ret |
; DATA AREA |
text: |
db 'NNTP IP : 192.168.0.96 < ' |
db 'Group : alt.test < Connect Disconnect ' |
db 'Article : 0 < ' |
db 'Art.max : ? ' |
db ' ' |
db 'Arrow left/rigth: fetch prev/next - Arrow up/down & space: scroll ' |
textl: |
title db 'NNTP client v',version,0 |
nntp_text: |
db 'a' |
I_END: ;;; |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |