Quick-n-dirty fix for ZeroConf

git-svn-id: svn://kolibrios.org@2856 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-07-11 11:59:14 +00:00
parent baa66d1a4c
commit dfd433a9b9
2 changed files with 232 additions and 386 deletions

View File

@ -1,157 +0,0 @@
;-----------------------------------------------------------------------------
proc mem.Alloc size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov eax,[size]
lea ecx,[eax+4+4095]
and ecx,not 4095
mcall 68,12
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

View File

@ -5,6 +5,8 @@
; ;
; Written by HidnPlayr & Derpenguin ; Written by HidnPlayr & Derpenguin
format binary as ""
use32 use32
org 0x0 org 0x0
@ -47,7 +49,7 @@ include '../macros.inc'
include '../debug-fdo.inc' include '../debug-fdo.inc'
include '../network.inc' include '../network.inc'
include 'dhcp.inc' include 'dhcp.inc'
include 'dll.inc' include '../dll.inc'
Ip2dword: Ip2dword:
@ -129,7 +131,7 @@ START: ; start of execution
DEBUGF 1,">Zero-config service:\n" DEBUGF 1,">Zero-config service:\n"
mcall 76, 1337 shl 16 + 4 mcall 76, API_ETH + 4
cmp eax, -1 cmp eax, -1
je exit je exit
@ -169,22 +171,22 @@ START: ; start of execution
invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0 invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0
mov edx, inibuf mov edx, inibuf
call Ip2dword call Ip2dword
mcall 76, 3, edx mcall 76, API_IPv4 + 3, edx
invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0 invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0
mov edx, inibuf mov edx, inibuf
call Ip2dword call Ip2dword
mcall 76, 9, edx mcall 76, API_IPv4 + 9, edx
invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0 invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0
mov edx, inibuf mov edx, inibuf
call Ip2dword call Ip2dword
mcall 76, 5, edx mcall 76, API_IPv4 + 5, edx
invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0 invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0
mov edx, inibuf mov edx, inibuf
call Ip2dword call Ip2dword
mcall 76, 7, edx mcall 76, API_IPv4 + 7, edx
mcall -1 mcall -1
@ -355,7 +357,7 @@ parseResponse:
mov edx, [dhcpMsg] mov edx, [dhcpMsg]
pusha pusha
mcall 76, 3, [edx+16] mcall 76, API_IPv4 + 3, [edx+16]
mov eax,[edx] mov eax,[edx]
mov [dhcpClientIP],eax mov [dhcpClientIP],eax
DEBUGF 1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1 DEBUGF 1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1
@ -409,7 +411,7 @@ pr001:
jne @f jne @f
pusha pusha
mcall 76, 7, [edx] mcall 76, API_IPv4 + 7, [edx]
DEBUGF 1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 DEBUGF 1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
popa popa
@ -420,7 +422,7 @@ pr001:
jne @f jne @f
pusha pusha
mcall 76, 9, [edx] mcall 76, API_IPv4 + 9, [edx]
DEBUGF 1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 DEBUGF 1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
popa popa
@ -432,7 +434,7 @@ pr001:
jne next_option jne next_option
pusha pusha
mcall 76, 5, [edx] mcall 76, API_IPv4 + 5, [edx]
DEBUGF 1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 DEBUGF 1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
popa popa
@ -440,10 +442,11 @@ pr001:
pr_exit: pr_exit:
ret
; DEBUGF 1,"Sending ARP announce\n" ; DEBUGF 1,"Sending ARP announce\n"
;;; ;;;
jmp exit
apipa: apipa:
stdcall mem.Free, [dhcpMsg] stdcall mem.Free, [dhcpMsg]
@ -452,11 +455,11 @@ link_local:
call random call random
mov ecx,0xfea9 ; IP 169.254.0.0 link local net, see RFC3927 mov ecx,0xfea9 ; IP 169.254.0.0 link local net, see RFC3927
mov cx,ax mov cx,ax
mcall 76, 3, ecx ; mask is 255.255.0.0 mcall 76, API_IPv4 + 3, ecx ; mask is 255.255.0.0
DEBUGF 1,"Link Local IP assinged: 169.254.%u.%u\n",[generator+2]:1,[generator+3]:1 DEBUGF 1,"Link Local IP assinged: 169.254.%u.%u\n",[generator+2]:1,[generator+3]:1
mcall 76, 5, 0xffff mcall 76, API_IPv4 + 5, 0xffff
mcall 76, 9, 0x0 mcall 76, API_IPv4 + 9, 0x0
mcall 76, 7, 0x0 mcall 76, API_IPv4 + 7, 0x0
mcall 5, PROBE_WAIT*100 mcall 5, PROBE_WAIT*100