From f4fd3f6ea049dc4c7c0fd3b9bd41fd3377e92e0e Mon Sep 17 00:00:00 2001 From: Andrew Dent Date: Wed, 29 May 2024 14:27:12 +0000 Subject: [PATCH] Fix EN typos - Corrections for en_US language. - Some whitespace sanitation. git-svn-id: svn://kolibrios.org@10062 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/ftpc/servercommands.inc | 8 +- programs/network/netcfg/netcfg.asm | 1152 +++++++++++----------- programs/network/netstat/ipcfg.inc | 850 ++++++++-------- programs/network/netsurf/nsinstall.asm | 830 ++++++++-------- 4 files changed, 1420 insertions(+), 1420 deletions(-) diff --git a/programs/network/ftpc/servercommands.inc b/programs/network/ftpc/servercommands.inc index f1e1e45526..d8275a7f1c 100644 --- a/programs/network/ftpc/servercommands.inc +++ b/programs/network/ftpc/servercommands.inc @@ -69,7 +69,7 @@ login_ok: cmp [param_path], 0x20 ; no path specified jbe wait_for_usercommand - + ; copy path to buf_cmd and execute CWD jmp arg_handler.get_path @@ -175,7 +175,7 @@ data_loop: cmp [operation], OPERATION_LIST je .list - + ; not retreiving, just print to console icall eax, interface_addr, interface.print, buf_buffer2 jmp data_loop @@ -267,9 +267,9 @@ data_loop: jne .copy_buf ; All received filenames have been copied, calculate new size of fname buffer - dec edi ; dont count the trailing 0 byte + dec edi ; don't count the trailing 0 byte sub edi, [ptr_fname] - mov [size_fname], edi + mov [size_fname], edi jmp data_loop diff --git a/programs/network/netcfg/netcfg.asm b/programs/network/netcfg/netcfg.asm index b94912e205..8fd7d8afe1 100644 --- a/programs/network/netcfg/netcfg.asm +++ b/programs/network/netcfg/netcfg.asm @@ -1,576 +1,576 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2010-2016. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; netcfg.asm - Network driver control center for KolibriOS ;; -;; ;; -;; Written by hidnplayr@kolibrios.org ;; -;; ;; -;; GNU GENERAL PUBLIC LICENSE ;; -;; Version 2, June 1991 ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -format binary as "" - -__DEBUG__ = 1 -__DEBUG_LEVEL__ = 1 - -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 - -include '../../macros.inc' -include '../../debug-fdo.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 [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 [PCI_Vendor], ax - shr eax, 16 - mov [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 [drivernumber], al - - jmp still - -reset: - movzx ebx, [drivernumber] - mcall 74,,2 - - jmp still - -unload: - movzx ebx, [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 [PCI_Version], ax - mcall 62, 1 - mov [PCI_LastBus], al - ;---------------------------------------------------------- - ;* Get all devices on PCI Bus - cmp al, 0xff ; 0xFF means no pci bus found - jne Pci_Exists ; - ret ; if no bus then leave - -Pci_Exists: - mov [V_Bus], 0 - mov [V_Dev], 0 - mov edx, 20 shl 16 + 110 ; set start write position - -Start_Enum: - mov bl, 6 ; read dword - mov bh, [V_Bus] - mov ch, [V_Dev] - 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 [PCI_Vendor], ax ; There is a device here, save the ID's - shr eax, 16 ; - mov [PCI_Device], ax ; - mov bl, 4 ; Read config byte - mov bh, [V_Bus] ; Bus # - mov ch, [V_Dev] ; Device # on bus - mov cl, 0x08 ; Register to read (Get Revision) - mcall 62 ; Read it - mov [PCI_Rev], al ; Save it - - mov cl, 0x0b ; Register to read (Get class) - mcall 62 ; Read it - mov [PCI_Class], al ; Save it - - mov cl, 0x0a ; Register to read (Get Subclass) - mcall 62 ; Read it - mov [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 - -; Could it be a network card? - cmp [PCI_Class], 2 ; network controller - je .found - - cmp [PCI_Class], 6 ; bridge type device - jne .nextDev - cmp [PCI_SubClass], 0x80 ; PCI-other bridge (for nvidia chipset) - jne .nextDev - cmp [PCI_Vendor], 0x10DE ; nvidia - jne .nextDev - - .found: - cmp byte[param], 0 ; Load network driver immediately? - jne load_and_start - - call Print_New_Device ; print device info to screen - - .nextDev: - test [V_Dev], 7 - jnz .nextFn - -; Is this a multifunction device? - mov bl, 4 ; Read config byte - mov bh, [V_Bus] ; Bus # - mov ch, [V_Dev] ; Device # on bus - mov cl, 0x0e - mcall 62 - test al, al - js .nextFn - -; Not a multifunction device, go to the next device - or [V_Dev], 7 - - .nextFn: - inc [V_Dev] ; lower 3 bits are the function number - jnz Start_Enum ; jump until we reach zero - - mov [V_Dev], 0 ; reset device number - inc [V_Bus] ; next bus - mov al, [PCI_LastBus] ; get last bus - cmp [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 .notsupp - - mov ecx, eax - mcall 68, 16 - test eax, eax - jz .fail - 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 Start_Enum.nextDev - jmp exit - - .fail: - DEBUGF 1,"Could not load network driver %s\n", ecx - jmp .next - - .notsupp: - DEBUGF 1,"Unsupported PCI network card detected: 0x%x:0x%x\n", [PCI_Vendor]:4, [PCI_Device]:4 - jmp .next - - -ITEM_H = 15 -;------------------------------------------------------------------ -;* 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, ITEM_H - - xor edx, edx - mov dh, [V_Bus] - mov dl, [V_Dev] - - mov esi, 0x0059DFFF ; color: yellow if selected, blue otherwise - cmp [selected], dx - jne @f - mov esi, 0x00FFCD0B - @@: - - shl edx, 8 - or dl, 0xff - - mcall 8 - pop edx - - xor esi, esi ; Color of text - movzx ecx, [PCI_Vendor] ; number to be written - add edx, 3 - mcall 47, 0x00040100 ; Write Vendor ID - - add edx, (4*6+18) shl 16 - movzx ecx, [PCI_Device] ; get Vendor ID - mcall ; Draw Vendor ID to Window - - add edx, (4*6+18) shl 16 - movzx ecx, [V_Bus] - mcall ,0x00020100 ; draw bus number to screen - - add edx, (2*6+18) shl 16 - movzx ecx, [V_Dev] - shr ecx, 3 ; device number is bits 3-7 - mcall ; Draw device Number To Window - - add edx, (2*6+18) shl 16 - movzx ecx, [PCI_Rev] - 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, [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 740 ; 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 network driver!',0 - -include_debug_strings - -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 ? -; Dont change order -PCI_Vendor dw ? -PCI_Device dw ? - -PCI_Bus db ? -PCI_Dev db ? -PCI_Rev db ? -; Dont change order -PCI_Class db ? -PCI_SubClass db ? -PCI_Interface db ? -PCI_IRQ db ? - -Proc_Info process_information - -param rb 1024 - - -I_END: \ No newline at end of file +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2010-2024. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; netcfg.asm - Network driver control center for KolibriOS ;; +;; ;; +;; Written by hidnplayr@kolibrios.org ;; +;; ;; +;; GNU GENERAL PUBLIC LICENSE ;; +;; Version 2, June 1991 ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +format binary as "" + +__DEBUG__ = 1 +__DEBUG_LEVEL__ = 1 + +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 + +include '../../macros.inc' +include '../../debug-fdo.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 [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 [PCI_Vendor], ax + shr eax, 16 + mov [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 [drivernumber], al + + jmp still + +reset: + movzx ebx, [drivernumber] + mcall 74,,2 + + jmp still + +unload: + movzx ebx, [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 [PCI_Version], ax + mcall 62, 1 + mov [PCI_LastBus], al + ;---------------------------------------------------------- + ;* Get all devices on PCI Bus + cmp al, 0xff ; 0xFF means no pci bus found + jne Pci_Exists ; + ret ; if no bus then leave + +Pci_Exists: + mov [V_Bus], 0 + mov [V_Dev], 0 + mov edx, 20 shl 16 + 110 ; set start write position + +Start_Enum: + mov bl, 6 ; read dword + mov bh, [V_Bus] + mov ch, [V_Dev] + 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 [PCI_Vendor], ax ; There is a device here, save the ID's + shr eax, 16 ; + mov [PCI_Device], ax ; + mov bl, 4 ; Read config byte + mov bh, [V_Bus] ; Bus # + mov ch, [V_Dev] ; Device # on bus + mov cl, 0x08 ; Register to read (Get Revision) + mcall 62 ; Read it + mov [PCI_Rev], al ; Save it + + mov cl, 0x0b ; Register to read (Get class) + mcall 62 ; Read it + mov [PCI_Class], al ; Save it + + mov cl, 0x0a ; Register to read (Get Subclass) + mcall 62 ; Read it + mov [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 + +; Could it be a network card? + cmp [PCI_Class], 2 ; network controller + je .found + + cmp [PCI_Class], 6 ; bridge type device + jne .nextDev + cmp [PCI_SubClass], 0x80 ; PCI-other bridge (for nvidia chipset) + jne .nextDev + cmp [PCI_Vendor], 0x10DE ; nvidia + jne .nextDev + + .found: + cmp byte[param], 0 ; Load network driver immediately? + jne load_and_start + + call Print_New_Device ; print device info to screen + + .nextDev: + test [V_Dev], 7 + jnz .nextFn + +; Is this a multifunction device? + mov bl, 4 ; Read config byte + mov bh, [V_Bus] ; Bus # + mov ch, [V_Dev] ; Device # on bus + mov cl, 0x0e + mcall 62 + test al, al + js .nextFn + +; Not a multifunction device, go to the next device + or [V_Dev], 7 + + .nextFn: + inc [V_Dev] ; lower 3 bits are the function number + jnz Start_Enum ; jump until we reach zero + + mov [V_Dev], 0 ; reset device number + inc [V_Bus] ; next bus + mov al, [PCI_LastBus] ; get last bus + cmp [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 .notsupp + + mov ecx, eax + mcall 68, 16 + test eax, eax + jz .fail + 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 Start_Enum.nextDev + jmp exit + + .fail: + DEBUGF 1,"Could not load network driver %s\n", ecx + jmp .next + + .notsupp: + DEBUGF 1,"Unsupported PCI network card detected: 0x%x:0x%x\n", [PCI_Vendor]:4, [PCI_Device]:4 + jmp .next + + +ITEM_H = 15 +;------------------------------------------------------------------ +;* 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, ITEM_H + + xor edx, edx + mov dh, [V_Bus] + mov dl, [V_Dev] + + mov esi, 0x0059DFFF ; color: yellow if selected, blue otherwise + cmp [selected], dx + jne @f + mov esi, 0x00FFCD0B + @@: + + shl edx, 8 + or dl, 0xff + + mcall 8 + pop edx + + xor esi, esi ; Color of text + movzx ecx, [PCI_Vendor] ; number to be written + add edx, 3 + mcall 47, 0x00040100 ; Write Vendor ID + + add edx, (4*6+18) shl 16 + movzx ecx, [PCI_Device] ; get Vendor ID + mcall ; Draw Vendor ID to Window + + add edx, (4*6+18) shl 16 + movzx ecx, [V_Bus] + mcall ,0x00020100 ; draw bus number to screen + + add edx, (2*6+18) shl 16 + movzx ecx, [V_Dev] + shr ecx, 3 ; device number is bits 3-7 + mcall ; Draw device Number To Window + + add edx, (2*6+18) shl 16 + movzx ecx, [PCI_Rev] + 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, [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 ; let's 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 ; let's 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 ; let's print the vendor Name + ret + + .driverfound: + ret + +include 'vendors.inc' +include 'drivers.inc' + + +;------------------------------------------------------------------ +; DATA AREA + + +DATA + + +Form: dw 740 ; 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 network driver!',0 + +include_debug_strings + +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 ? +; Don't change order +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: diff --git a/programs/network/netstat/ipcfg.inc b/programs/network/netstat/ipcfg.inc index 2c2de6a995..9dc60c74b4 100644 --- a/programs/network/netstat/ipcfg.inc +++ b/programs/network/netstat/ipcfg.inc @@ -1,425 +1,425 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2010-2024. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; Written by hidnplayr@kolibrios.org ;; -;; ;; -;; GNU GENERAL PUBLIC LICENSE ;; -;; Version 2, June 1991 ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -ipcfg: - - mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK - -; Create the 'ip..' string with correct device number - call create_str_ini_int - -; Try to read settings from .ini file - invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0 - test eax, eax - jz @f -; If settings not found, use default settings from 'ip?' section - mov dword[str_ini_int], 'ip?' - @@: - -; Read ip/subnet/gateway type - mov [option_ip], op_ip_disabled - invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0 - test eax, eax - jnz .ip_type_loaded - mov eax, dword[ini_buf] - or eax, 0x20202020 - cmp eax, 'auto' - jne @f -; cmp byte[ini_buf+4], 0 -; jne @f - mov [option_ip], op_ip_auto - jmp .ip_type_loaded - @@: - cmp eax, 'dhcp' - jne @f -; cmp byte[ini_buf+4], 0 -; jne @f - mov [option_ip], op_ip_auto - jmp .ip_type_loaded - @@: - cmp eax, 'stat' - jne @f -; mov eax, dword[ini_buf+3] -; or eax, 0x202020 -; cmp eax, 'tic' -; jne @f - mov [option_ip], op_ip_static -; jmp .ip_type_loaded - @@: - .ip_type_loaded: - -; Read DNS type - mov [option_dns], op_dns_auto - invoke ini.get_str, net_ini, str_ini_int, str_ini_dns_type, ini_buf, 16, sz_0 - test eax, eax - jnz @f - mov eax, dword[ini_buf] - or eax, 0x20202020 - cmp eax, 'stat' - jne @f -; mov eax, dword[ini_buf+3] -; or eax, 0x202020 -; cmp eax, 'tic' -; jne @f - mov [option_dns], op_dns_static - @@: - -; Read all IP addresses - mov [str_edit_ip], 0 - mov [str_edit_subnet], 0 - mov [str_edit_gateway], 0 - mov [str_edit_dns], 0 - - invoke ini.get_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, 16, sz_0 - invoke ini.get_str, net_ini, str_ini_int, str_ini_subnet, str_edit_subnet, 16, sz_0 - invoke ini.get_str, net_ini, str_ini_int, str_ini_gateway, str_edit_gateway, 16, sz_0 - invoke ini.get_str, net_ini, str_ini_int, str_ini_dns, str_edit_dns, 16, sz_0 - - invoke edit_set_text, edit_ip, str_edit_ip - invoke edit_set_text, edit_subnet, str_edit_subnet - invoke edit_set_text, edit_gateway, str_edit_gateway - invoke edit_set_text, edit_dns, str_edit_dns - - .parse_settings: - call toggle_editboxes - - .draw: -; get system colors - mcall 48, 3, sc, 40 - - mcall 12, 1 - - mov edx, [sc.work] - or edx, 0x34000000 - xor esi, esi - mov edi, str_title - mcall 0, 50 shl 16 + 200, 30 shl 16 + 200 - - mov ecx, 0x80000000 - or ecx, [sc.work_text] -; mov ebx, 47 shl 16 + 25 -; mov edx, str_mode -; mcall - mov ebx, 59 shl 16 + 50 - mov edx, sz_ip - mcall 4 - mov ebx, 5 shl 16 + 70 - mov edx, sz_subnet - mcall - mov ebx, 29 shl 16 + 90 - mov edx, sz_gateway - mcall -; mov ebx, 47 shl 16 + 95 -; mov edx, str_mode -; mcall - mov ebx, 53 shl 16 + 135 - mov edx, sz_dns - mcall - - invoke edit_box_draw, edit_ip - invoke edit_box_draw, edit_subnet - invoke edit_box_draw, edit_gateway - invoke edit_box_draw, edit_dns - - invoke option_box_draw, Option_boxs1 - invoke option_box_draw, Option_boxs2 - - mcall 8, 80 shl 16 + 100, 155 shl 16 + 16, 2, [sc.work_button] - - mov ecx, 0x80000000 - or ecx, [sc.work_button_text] - mov ebx, 112 shl 16 + 160 - mov edx, sz_apply - mcall 4 - - mcall 12, 2 - - .loop: - mcall 10 - dec eax - jz .draw - dec eax - jz .key - dec eax - jz .btn - - invoke edit_box_mouse, edit_ip - invoke edit_box_mouse, edit_subnet - invoke edit_box_mouse, edit_gateway - invoke edit_box_mouse, edit_dns - - push [option_ip] [option_dns] - invoke option_box_mouse, Option_boxs1 - invoke option_box_mouse, Option_boxs2 - pop ebx eax - cmp eax, [option_ip] - jne @f - cmp ebx, [option_dns] - je .loop - @@: - call toggle_editboxes - jmp .draw - - .btn: - mcall 17 - - test ah , ah - jz .loop - - cmp ah, 2 ; apply - jne .exit - -; Apply settings! - .apply: - xor edi, edi - - cmp [option_ip], op_ip_static - jne .skip_ip - mov [edit_ip.color], 0xffffff - mov esi, str_edit_ip - call validate_ip - test eax, eax - jz @f - mov [edit_ip.color], 0xff4444 - inc edi - @@: - - mov [edit_subnet.color], 0xffffff - mov esi, str_edit_subnet - call validate_ip - test eax, eax - jz @f - mov [edit_subnet.color], 0xff4444 - inc edi - @@: - - mov [edit_gateway.color], 0xffffff - mov esi, str_edit_gateway - call validate_ip - test eax, eax - jz @f - mov [edit_gateway.color], 0xff4444 - inc edi - @@: - .skip_ip: - - cmp [option_dns], op_dns_static - jne .skip_dns - mov [edit_dns.color], 0xffffff - mov esi, str_edit_dns - call validate_ip - test eax, eax - jz @f - mov [edit_dns.color], 0xff4444 - inc edi - @@: - .skip_dns: - - test edi, edi - jnz .draw - -; Settings look valid, save them to the ini file -; Re-create 'ip..' string, we dont want to save to 'ip?' section. - call create_str_ini_int - - cmp [option_ip], op_ip_auto - jne @f - invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_auto, 4 - jmp .ip_type_ok - @@: - cmp [option_ip], op_ip_static - jne @f - invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_static, 6 - jmp .ip_type_ok - @@: -; cmp [option_ip], op_ip_disabled -; jne @f - invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_disabled, 8 -; @@: - .ip_type_ok: - - cmp [option_dns], op_dns_auto - jne .dns_static - invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_auto, 4 - jmp @f - .dns_static: - invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_static, 6 - @@: - - invoke ini.set_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, [edit_ip.size] - invoke ini.set_str, net_ini, str_ini_int, str_ini_subnet, str_edit_subnet, [edit_subnet.size] - invoke ini.set_str, net_ini, str_ini_int, str_ini_gateway, str_edit_gateway, [edit_gateway.size] - invoke ini.set_str, net_ini, str_ini_int, str_ini_dns, str_edit_dns, [edit_dns.size] - - .exit: - mcall -1 - - .key: - mcall 2 - -; Editbox doesnt allow us to filter input decently, so we do it here. - cmp ah, 13 - je .apply - cmp ah, 8 - je @f - cmp ah, 0xb0 ; left arrow - je @f - cmp ah, 0xb3 ; right arrow - je @f - cmp ah, '.' - je @f - cmp ah, '0' - jb .loop - cmp ah, '9' - ja .loop - @@: - invoke edit_box_key, edit_ip - invoke edit_box_key, edit_subnet - invoke edit_box_key, edit_gateway - invoke edit_box_key, edit_dns - - jmp .loop - -toggle_editboxes: - - and [edit_ip.flags], not ed_disabled - and [edit_subnet.flags], not ed_disabled - and [edit_gateway.flags], not ed_disabled - cmp [option_ip], op_ip_static - je @f - or [edit_ip.flags], ed_disabled - or [edit_subnet.flags], ed_disabled - or [edit_gateway.flags], ed_disabled - @@: - - or [edit_dns.flags], ed_disabled - cmp [option_ip], op_ip_disabled - je @f - cmp [option_dns], op_dns_static - jne @f - and [edit_dns.flags], not ed_disabled - @@: - - ret - - -; in: esi = ptr to ascii ip -; out: eax = 0 - ok / -1 - error -validate_ip: - xor ecx, ecx ; octet count - .outer_loop: - xor ebx, ebx ; current number - inc ecx - .inner_loop: - lodsb ; load one character from ascii string - test al, al - je .finish - cmp al, '.' - je .outer_loop - ; Convert current digit from ascii to bin, if valid - sub al, '0' - jb .invalid - cmp al, 9 - ja .invalid - ; multiply current number by 10 - add bl, bl - jc .invalid - lea ebx, [ebx + 4 * ebx] - test ebx, 0xffffff00 - jnz .invalid - ; add current digit to current number - add bl, al - jc .invalid - jmp .inner_loop - .finish: - cmp cl, 4 - jne .invalid - xor eax, eax - ret - - .invalid: - or eax, -1 - ret - -create_str_ini_int: - movzx eax, [device] - mov ebx, 10 - xor edx, edx - push 0 - @@: - div ebx - add dl, '0' - push edx - test eax, eax - jnz @r - @@: - mov edi, str_ini_int+2 - @@: - pop eax - stosb - test eax, eax - jnz @r - - ret - - -;------------------------- -; DATA - -edit_ip edit_box 100, 80, 45, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_ip, mouse_dd, 0, 0, 1 -edit_subnet edit_box 100, 80, 65, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_subnet, mouse_dd, 0, 0, 1 -edit_gateway edit_box 100, 80, 85, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_gateway, mouse_dd, 0, 0, 1 - -edit_dns edit_box 100, 80, 130, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_dns, mouse_dd, 0, 0, 1 - -op_ip_disabled option_box option_ip, 15, 5, 6, 12, 0xffffff, 0, 0, sz_disabled, 9 -op_ip_auto option_box option_ip, 15, 25, 6, 12, 0xffffff, 0, 0, sz_auto, 5 -op_ip_static option_box option_ip, 80, 25, 6, 12, 0xffffff, 0, 0, sz_static, 7 - -op_dns_auto option_box option_dns, 15, 110, 6, 12, 0xffffff, 0, 0, sz_auto, 5 -op_dns_static option_box option_dns, 80, 110, 6, 12, 0xffffff, 0, 0, sz_static, 7 - -option_ip dd op_ip_auto -option_dns dd op_dns_auto -Option_boxs1 dd op_ip_disabled, op_ip_auto, op_ip_static, 0 -Option_boxs2 dd op_dns_auto, op_dns_static, 0 - -net_ini db '/sys/settings/network.ini', 0 - -str_ini_int db 'ip1', 0 - rb 10 -str_ini_ip db 'ip', 0 -str_ini_subnet db 'subnet', 0 -str_ini_gateway db 'gateway', 0 -str_ini_dns db 'dns', 0 -str_ini_ip_type db 'ip_type', 0 -str_ini_dns_type db 'dns_type', 0 - -str_title db 'IP settings', 0 -sz_0 db 0 -sz_ip db 'IP:', 0 -sz_subnet db 'Subnet mask:', 0 -sz_gateway db 'Gateway:', 0 -sz_dns db 'DNS:', 0 -sz_auto db 'Auto', 0 -sz_static db 'Static', 0 -sz_disabled db 'Disabled', 0 -sz_apply db 'Apply', 0 - -str_edit_ip rb 16 -str_edit_subnet rb 16 -str_edit_gateway rb 16 -str_edit_dns rb 16 - -ini_buf rb 16 - -mouse_dd dd ? \ No newline at end of file +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2010-2024. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; Written by hidnplayr@kolibrios.org ;; +;; ;; +;; GNU GENERAL PUBLIC LICENSE ;; +;; Version 2, June 1991 ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +ipcfg: + + mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK + +; Create the 'ip..' string with correct device number + call create_str_ini_int + +; Try to read settings from .ini file + invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0 + test eax, eax + jz @f +; If settings not found, use default settings from 'ip?' section + mov dword[str_ini_int], 'ip?' + @@: + +; Read ip/subnet/gateway type + mov [option_ip], op_ip_disabled + invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0 + test eax, eax + jnz .ip_type_loaded + mov eax, dword[ini_buf] + or eax, 0x20202020 + cmp eax, 'auto' + jne @f +; cmp byte[ini_buf+4], 0 +; jne @f + mov [option_ip], op_ip_auto + jmp .ip_type_loaded + @@: + cmp eax, 'dhcp' + jne @f +; cmp byte[ini_buf+4], 0 +; jne @f + mov [option_ip], op_ip_auto + jmp .ip_type_loaded + @@: + cmp eax, 'stat' + jne @f +; mov eax, dword[ini_buf+3] +; or eax, 0x202020 +; cmp eax, 'tic' +; jne @f + mov [option_ip], op_ip_static +; jmp .ip_type_loaded + @@: + .ip_type_loaded: + +; Read DNS type + mov [option_dns], op_dns_auto + invoke ini.get_str, net_ini, str_ini_int, str_ini_dns_type, ini_buf, 16, sz_0 + test eax, eax + jnz @f + mov eax, dword[ini_buf] + or eax, 0x20202020 + cmp eax, 'stat' + jne @f +; mov eax, dword[ini_buf+3] +; or eax, 0x202020 +; cmp eax, 'tic' +; jne @f + mov [option_dns], op_dns_static + @@: + +; Read all IP addresses + mov [str_edit_ip], 0 + mov [str_edit_subnet], 0 + mov [str_edit_gateway], 0 + mov [str_edit_dns], 0 + + invoke ini.get_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, 16, sz_0 + invoke ini.get_str, net_ini, str_ini_int, str_ini_subnet, str_edit_subnet, 16, sz_0 + invoke ini.get_str, net_ini, str_ini_int, str_ini_gateway, str_edit_gateway, 16, sz_0 + invoke ini.get_str, net_ini, str_ini_int, str_ini_dns, str_edit_dns, 16, sz_0 + + invoke edit_set_text, edit_ip, str_edit_ip + invoke edit_set_text, edit_subnet, str_edit_subnet + invoke edit_set_text, edit_gateway, str_edit_gateway + invoke edit_set_text, edit_dns, str_edit_dns + + .parse_settings: + call toggle_editboxes + + .draw: +; get system colors + mcall 48, 3, sc, 40 + + mcall 12, 1 + + mov edx, [sc.work] + or edx, 0x34000000 + xor esi, esi + mov edi, str_title + mcall 0, 50 shl 16 + 200, 30 shl 16 + 200 + + mov ecx, 0x80000000 + or ecx, [sc.work_text] +; mov ebx, 47 shl 16 + 25 +; mov edx, str_mode +; mcall + mov ebx, 59 shl 16 + 50 + mov edx, sz_ip + mcall 4 + mov ebx, 5 shl 16 + 70 + mov edx, sz_subnet + mcall + mov ebx, 29 shl 16 + 90 + mov edx, sz_gateway + mcall +; mov ebx, 47 shl 16 + 95 +; mov edx, str_mode +; mcall + mov ebx, 53 shl 16 + 135 + mov edx, sz_dns + mcall + + invoke edit_box_draw, edit_ip + invoke edit_box_draw, edit_subnet + invoke edit_box_draw, edit_gateway + invoke edit_box_draw, edit_dns + + invoke option_box_draw, Option_boxs1 + invoke option_box_draw, Option_boxs2 + + mcall 8, 80 shl 16 + 100, 155 shl 16 + 16, 2, [sc.work_button] + + mov ecx, 0x80000000 + or ecx, [sc.work_button_text] + mov ebx, 112 shl 16 + 160 + mov edx, sz_apply + mcall 4 + + mcall 12, 2 + + .loop: + mcall 10 + dec eax + jz .draw + dec eax + jz .key + dec eax + jz .btn + + invoke edit_box_mouse, edit_ip + invoke edit_box_mouse, edit_subnet + invoke edit_box_mouse, edit_gateway + invoke edit_box_mouse, edit_dns + + push [option_ip] [option_dns] + invoke option_box_mouse, Option_boxs1 + invoke option_box_mouse, Option_boxs2 + pop ebx eax + cmp eax, [option_ip] + jne @f + cmp ebx, [option_dns] + je .loop + @@: + call toggle_editboxes + jmp .draw + + .btn: + mcall 17 + + test ah , ah + jz .loop + + cmp ah, 2 ; apply + jne .exit + +; Apply settings! + .apply: + xor edi, edi + + cmp [option_ip], op_ip_static + jne .skip_ip + mov [edit_ip.color], 0xffffff + mov esi, str_edit_ip + call validate_ip + test eax, eax + jz @f + mov [edit_ip.color], 0xff4444 + inc edi + @@: + + mov [edit_subnet.color], 0xffffff + mov esi, str_edit_subnet + call validate_ip + test eax, eax + jz @f + mov [edit_subnet.color], 0xff4444 + inc edi + @@: + + mov [edit_gateway.color], 0xffffff + mov esi, str_edit_gateway + call validate_ip + test eax, eax + jz @f + mov [edit_gateway.color], 0xff4444 + inc edi + @@: + .skip_ip: + + cmp [option_dns], op_dns_static + jne .skip_dns + mov [edit_dns.color], 0xffffff + mov esi, str_edit_dns + call validate_ip + test eax, eax + jz @f + mov [edit_dns.color], 0xff4444 + inc edi + @@: + .skip_dns: + + test edi, edi + jnz .draw + +; Settings look valid, save them to the ini file +; Re-create 'ip..' string, we don't want to save to 'ip?' section. + call create_str_ini_int + + cmp [option_ip], op_ip_auto + jne @f + invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_auto, 4 + jmp .ip_type_ok + @@: + cmp [option_ip], op_ip_static + jne @f + invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_static, 6 + jmp .ip_type_ok + @@: +; cmp [option_ip], op_ip_disabled +; jne @f + invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_disabled, 8 +; @@: + .ip_type_ok: + + cmp [option_dns], op_dns_auto + jne .dns_static + invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_auto, 4 + jmp @f + .dns_static: + invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_static, 6 + @@: + + invoke ini.set_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, [edit_ip.size] + invoke ini.set_str, net_ini, str_ini_int, str_ini_subnet, str_edit_subnet, [edit_subnet.size] + invoke ini.set_str, net_ini, str_ini_int, str_ini_gateway, str_edit_gateway, [edit_gateway.size] + invoke ini.set_str, net_ini, str_ini_int, str_ini_dns, str_edit_dns, [edit_dns.size] + + .exit: + mcall -1 + + .key: + mcall 2 + +; Editbox doesn't allow us to filter input decently, so we do it here. + cmp ah, 13 + je .apply + cmp ah, 8 + je @f + cmp ah, 0xb0 ; left arrow + je @f + cmp ah, 0xb3 ; right arrow + je @f + cmp ah, '.' + je @f + cmp ah, '0' + jb .loop + cmp ah, '9' + ja .loop + @@: + invoke edit_box_key, edit_ip + invoke edit_box_key, edit_subnet + invoke edit_box_key, edit_gateway + invoke edit_box_key, edit_dns + + jmp .loop + +toggle_editboxes: + + and [edit_ip.flags], not ed_disabled + and [edit_subnet.flags], not ed_disabled + and [edit_gateway.flags], not ed_disabled + cmp [option_ip], op_ip_static + je @f + or [edit_ip.flags], ed_disabled + or [edit_subnet.flags], ed_disabled + or [edit_gateway.flags], ed_disabled + @@: + + or [edit_dns.flags], ed_disabled + cmp [option_ip], op_ip_disabled + je @f + cmp [option_dns], op_dns_static + jne @f + and [edit_dns.flags], not ed_disabled + @@: + + ret + + +; in: esi = ptr to ascii ip +; out: eax = 0 - ok / -1 - error +validate_ip: + xor ecx, ecx ; octet count + .outer_loop: + xor ebx, ebx ; current number + inc ecx + .inner_loop: + lodsb ; load one character from ascii string + test al, al + je .finish + cmp al, '.' + je .outer_loop + ; Convert current digit from ascii to bin, if valid + sub al, '0' + jb .invalid + cmp al, 9 + ja .invalid + ; multiply current number by 10 + add bl, bl + jc .invalid + lea ebx, [ebx + 4 * ebx] + test ebx, 0xffffff00 + jnz .invalid + ; add current digit to current number + add bl, al + jc .invalid + jmp .inner_loop + .finish: + cmp cl, 4 + jne .invalid + xor eax, eax + ret + + .invalid: + or eax, -1 + ret + +create_str_ini_int: + movzx eax, [device] + mov ebx, 10 + xor edx, edx + push 0 + @@: + div ebx + add dl, '0' + push edx + test eax, eax + jnz @r + @@: + mov edi, str_ini_int+2 + @@: + pop eax + stosb + test eax, eax + jnz @r + + ret + + +;------------------------- +; DATA + +edit_ip edit_box 100, 80, 45, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_ip, mouse_dd, 0, 0, 1 +edit_subnet edit_box 100, 80, 65, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_subnet, mouse_dd, 0, 0, 1 +edit_gateway edit_box 100, 80, 85, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_gateway, mouse_dd, 0, 0, 1 + +edit_dns edit_box 100, 80, 130, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_dns, mouse_dd, 0, 0, 1 + +op_ip_disabled option_box option_ip, 15, 5, 6, 12, 0xffffff, 0, 0, sz_disabled, 9 +op_ip_auto option_box option_ip, 15, 25, 6, 12, 0xffffff, 0, 0, sz_auto, 5 +op_ip_static option_box option_ip, 80, 25, 6, 12, 0xffffff, 0, 0, sz_static, 7 + +op_dns_auto option_box option_dns, 15, 110, 6, 12, 0xffffff, 0, 0, sz_auto, 5 +op_dns_static option_box option_dns, 80, 110, 6, 12, 0xffffff, 0, 0, sz_static, 7 + +option_ip dd op_ip_auto +option_dns dd op_dns_auto +Option_boxs1 dd op_ip_disabled, op_ip_auto, op_ip_static, 0 +Option_boxs2 dd op_dns_auto, op_dns_static, 0 + +net_ini db '/sys/settings/network.ini', 0 + +str_ini_int db 'ip1', 0 + rb 10 +str_ini_ip db 'ip', 0 +str_ini_subnet db 'subnet', 0 +str_ini_gateway db 'gateway', 0 +str_ini_dns db 'dns', 0 +str_ini_ip_type db 'ip_type', 0 +str_ini_dns_type db 'dns_type', 0 + +str_title db 'IP settings', 0 +sz_0 db 0 +sz_ip db 'IP:', 0 +sz_subnet db 'Subnet mask:', 0 +sz_gateway db 'Gateway:', 0 +sz_dns db 'DNS:', 0 +sz_auto db 'Auto', 0 +sz_static db 'Static', 0 +sz_disabled db 'Disabled', 0 +sz_apply db 'Apply', 0 + +str_edit_ip rb 16 +str_edit_subnet rb 16 +str_edit_gateway rb 16 +str_edit_dns rb 16 + +ini_buf rb 16 + +mouse_dd dd ? diff --git a/programs/network/netsurf/nsinstall.asm b/programs/network/netsurf/nsinstall.asm index 9fb8fb9380..6673a63f34 100644 --- a/programs/network/netsurf/nsinstall.asm +++ b/programs/network/netsurf/nsinstall.asm @@ -1,415 +1,415 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2017. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; netsurf-installer - Set up Netsurf Browser on KolibriOS ;; -;; Author: ashmew2. ;; -;; ;; -;; Inspired from downloader.asm by hidnplayr@kolibrios.org ;; -;; GENERAL PUBLIC LICENSE ;; -;; Version 2, June 1991 ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -URLMAXLEN = 65535 -FILENAMEMAXLEN = 1024 -__DEBUG_LEVEL__ = 2 -__DEBUG__ = 1 - -format binary as "" -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x1000 ; required memory - dd I_END+0x1000 ; esp - dd 0x0 ; I_Path - dd 0x0 ; I_Path - -include '../../macros.inc' -include '../../proc32.inc' -include '../../dll.inc' -include '../../debug-fdo.inc' -include '../../develop/libraries/http/http.inc' -include '../../string.inc' - -include '../../system/notify3/notify.inc' - -include 'notify.asm' - -virtual at 0 - http_msg http_msg -end virtual - -;; Parameters -;; HTTP URL to download -;; Target filename -proc get_file_over_http targeturl, targetfilename - pusha - xor eax, eax - mov [write_to_file.current_offset], eax - mov [write_to_file.bufsize], eax - mov [write_to_file.bufptr], eax - - DEBUGF 1, "---- HTTP : Getting %s\n", [targeturl] - invoke HTTP_get, [targeturl], 0, FLAG_KEEPALIVE or FLAG_BLOCK, 0 - cmp eax, 0 - je .http_error - mov [httpstruct], eax - - ;; No HTTP errors, create a new file for the download. - DEBUGF 1, "---- Creating new file : %s\n", [targetfilename] - mcall 70, create_new_file - cmp eax, 0 - jne .file_error - - .http_receive_loop: - DEBUGF 1, "---- Receiving over http.\n" - invoke HTTP_receive, [httpstruct] - - cmp eax, 0 - je .http_transfer_done - - - mov ebp, [httpstruct] - DEBUGF 1, "---- http flags = 0x%x.\n", [ebp + http_msg.flags] - test [ebp + http_msg.flags], 0xffff0000 - jnz .http_error - - mov ebp, [ebp + http_msg.content_received] - cmp ebp, [write_to_file.current_offset] - jle .http_receive_loop - ;; Only proceed if we have more data in HTTP buffer than we have written to file. - - ;; Process data we got (write it to the file) - mov ebp, [httpstruct] - mov ecx, [ebp + http_msg.content_length] - mov edx, [ebp + http_msg.content_received] - - DEBUGF 1, "---- Current file write offset : %u (http got : %u / %u)\n", [write_to_file.current_offset], edx, ecx - sub edx, [write_to_file.current_offset] - mov [write_to_file.bufsize], edx - - mov ecx, [ebp + http_msg.content_ptr] - add ecx, [write_to_file.current_offset] - mov [write_to_file.bufptr], ecx - - DEBUGF 1, "---- ecx + offset = 0x%x\n", ecx - DEBUGF 1, "---- Writing to file %u bytes at 0x%x to %s\n", [write_to_file.bufsize], [write_to_file.bufptr], current_filename - mcall 70, write_to_file - cmp eax, 0 - jne .file_error - - DEBUGF 1, "---- Wrote to file %u bytes.\n", ebx - add [write_to_file.current_offset], ebx - DEBUGF 1, "---- File offset updated to : %u\n", [write_to_file.current_offset] - - jmp .http_receive_loop - - .file_error: - DEBUGF 1, "file_erroR with eax = %u!", eax - call EXIT - - .http_error: - DEBUGF 1, "http_erroR!" - call EXIT - - .http_transfer_done: - ;; Write any remaining bytes from the http buffer into the file - DEBUGF 1, "---- http flags = 0x%x.\n", [httpstruct + http_msg.flags] - DEBUGF 1, "Got %u bytes in total\n", [httpstruct + http_msg.content_length] - - mov ebp, [httpstruct] - mov edx, [ebp + http_msg.content_length] - - sub edx, [write_to_file.current_offset] - mov [write_to_file.bufsize], edx - - mov ecx, [ebp + http_msg.content_ptr] - add ecx, [write_to_file.current_offset] - mov [write_to_file.bufptr], ecx - - DEBUGF 1, "---- Final ecx + offset = 0x%x\n", ecx - DEBUGF 1, "-- Writing to file %u bytes at 0x%x to %s\n", [write_to_file.bufsize], [write_to_file.bufptr], current_filename - - mcall 70, write_to_file - cmp eax, 0 - jne .file_error - - DEBUGF 1, "-- Wrote to file %u bytes.\n", ebx - add [write_to_file.current_offset], ebx - DEBUGF 1, "-- File offset updated to : %u\n", [write_to_file.current_offset] - mov ebp, [httpstruct] - mov edx, [ebp + http_msg.content_length] - cmp [write_to_file.current_offset], edx - jne .http_transfer_done - - invoke HTTP_free, [httpstruct] - - popa - ret -endp - -proc make_new_folder newfolder - pusha - - mov eax, [newfolder] - mov [create_new_folder.foldername], eax - mcall 70, create_new_folder - test eax, eax - jz .success - - DEBUGF 1, "Failed to create folder: %s\n", [newfolder] - call EXIT - -.success: - popa - ret -endp - -proc run_if_exists file_path - m2m [fileinfo.path], [file_path] - mcall 70, fileinfo - test eax, eax - jnz @f - m2m [fileopen.path], [file_path] - mcall 70, fileopen - mcall -1 -@@: - ret -endp - - -START: - stdcall run_if_exists, TMP_netsurf - stdcall run_if_exists, ISO_netsurf - - mcall 68, 11 ; init heap - call NOTIFY_RUN - -; load libraries - stdcall dll.Load, @IMPORT - test eax, eax - jnz .all_files_done_error - - DEBUGF 2, "-------------------------\n" - DEBUGF 2, "NETSURF INSTALLER.\n" - - stdcall make_new_folder, dirname_res - ; stdcall make_new_folder, dirname_res_pointers - ; stdcall make_new_folder, dirname_res_throbber - ; stdcall make_new_folder, dirname_res_icons - - -.get_next_file: - mov edi, current_url - mov esi, url - - @@: - movsb - cmp byte[esi], 0 - jne @b - ;; Loaded the base URL into current URL - - ;; Move onto the subsequent file. - mov esi, [filelistoffset] - cmp byte[esi], 0 - je .all_files_done - - @@: - movsb - cmp byte[esi], 0 - jne @b - movsb - - ;; DEBUGF 1, "-- Current URL with filename is : %s\n", current_url - -; Create name of file we will download to - mov esi, download_file_path - mov edi, current_filename - - @@: - movsb - cmp byte[esi], 0 - jne @b - - mov esi, [filelistoffset] - @@: - movsb - cmp byte[esi], 0 - jne @b - movsb - mov [filelistoffset], esi - - ;; current_filename is now set to the name of the file - ;; current_url is now set to the name of the file we will get after download - DEBUGF 2, "Fetching : %s", current_filename - pusha - call NOTIFY_CHANGE - popa - stdcall get_file_over_http, current_url, current_filename - DEBUGF 2, "...DONE!\n" - jmp .get_next_file - -.all_files_done: - DEBUGF 2, "-------------------------\n" - DEBUGF 2, "NETSURF INSTALLED. Enjoy!\n" - DEBUGF 2, "-------------------------\n" - call EXIT - ;; Inform user that all files are done - -.all_files_done_error: - DEBUGF 1, "FATAL ERROR: FAILED.\n", eax - call EXIT - -;--------------------------------------------------------------------- -; Data area -;----------------------------------------------------------------------------- -align 4 -@IMPORT: - -library lib_http, 'http.obj' -import lib_http, \ - HTTP_get, 'get', \ - HTTP_receive, 'receive', \ - HTTP_free, 'free' - -include_debug_strings - -download_file_path db '/tmp0/1/', 0 -dirname_res db '/tmp0/1/res', 0 -dirname_res_pointers db '/tmp0/1/res/pointers', 0 -dirname_res_throbber db '/tmp0/1/res/throbber', 0 -dirname_res_icons db '/tmp0/1/res/icons', 0 - -url db 'www.kolibri-n.org/files/netsurf/',0 - -; I don't know why NOTIFY_CHANGE doesn't work for the first file -; so I use this small shit to fix it at NOTIFY_RUN phase -filelist_first db '/tmp0/1/netsurf', 0 - -MAX_FILES = 6 - -filelist db 'netsurf', 0 - ;db 'netsurf-kolibrios.map', 0 ;what this??? - db 'res/adblock.css', 0 - db 'res/quirks.css', 0 - db 'res/Messages', 0 - db 'res/default.css', 0 - db 'res/sans.ttf', 0 - db 'res/internal.css', 0 - ; db 'res/welcome.html', 0 - ; db 'res/licence.html', 0 - ; db 'res/maps.html', 0 - ; db 'res/credits.html', 0 - ; db 'res/favicon.png', 0 - ; db 'res/netsurf.png', 0 - ; db 'res/throbber/throbber8.png', 0 - ; db 'res/throbber/throbber3.png', 0 - ; db 'res/throbber/throbber4.png', 0 - ; db 'res/throbber/throbber0.png', 0 - ; db 'res/throbber/throbber6.png', 0 - ; db 'res/throbber/throbber2.png', 0 - ; db 'res/throbber/throbber1.png', 0 - ; db 'res/throbber/throbber7.png', 0 - ; db 'res/throbber/throbber5.png', 0 - ; db 'res/pointers/point.png', 0 - ; db 'res/pointers/no_drop.png', 0 - ; db 'res/pointers/wait.png', 0 - ; db 'res/pointers/up-down.png', 0 - ; db 'res/pointers/help.png', 0 - ; db 'res/pointers/ru-ld.png', 0 - ; db 'res/pointers/menu.png', 0 - ; db 'res/pointers/not_allowed.png', 0 - ; db 'res/pointers/cross.png', 0 - ; db 'res/pointers/default.png', 0 - ; db 'res/pointers/caret.png', 0 - ; db 'res/pointers/left-right.png', 0 - ; db 'res/pointers/lu-rd.png', 0 - ; db 'res/pointers/progress.png', 0 - ; db 'res/pointers/move.png', 0 - ; db 'res/icons/back.png', 0 - ; db 'res/icons/back_g.png', 0 - ; db 'res/icons/scrollr.png', 0 - ; db 'res/icons/osk.png', 0 - ; db 'res/icons/forward_g.png', 0 - ; db 'res/icons/scrolll.png', 0 - ; db 'res/icons/history.png', 0 - ; db 'res/icons/forward.png', 0 - ; db 'res/icons/home_g.png', 0 - ; db 'res/icons/history_g.png', 0 - ; db 'res/icons/reload_g.png', 0 - ; db 'res/icons/scrollu.png', 0 - ; db 'res/icons/stop.png', 0 - ; db 'res/icons/scrolld.png', 0 - ; db 'res/icons/stop_g.png', 0 - ; db 'res/icons/home.png', 0 - ; db 'res/icons/reload.png', 0 - db 0 - -filelistoffset dd filelist -httpstruct dd 0 - -create_new_file dd 2, 0, 0, 0, 0 - db 0 - dd current_filename - -create_new_folder dd 9, 0, 0, 0, 0 - db 0 - .foldername dd 0 - -write_to_file dd 3 - .current_offset dd 0, 0 - .bufsize dd 0 - .bufptr dd 0 - db 0 - dd current_filename - -socketdata rb 4096 -current_url rb URLMAXLEN -current_filename rb FILENAMEMAXLEN - -ISO_netsurf db "/kolibrios/netsurf/netsurf", 0 -TMP_netsurf db "/tmp0/1/netsurf", 0 - -bdvk_buf rb 560 - -fileinfo dd 5 - dd 0,0,0 - dd bdvk_buf - db 0 -.path dd ? ; path - -;===================================================================== -; NOTIFY DATA -timer dd 0 -params rb 256 -ctrl: - .name rb 32 - .addr rd 1 -rb 2048 - - sz_text: - db "Downloading Netsurf ",10, 0 - sz_quote: - db "'", 0 - sz_flags: - db "Ddcpt", 0 - - sz_final_text: - db "Netsurf download complete.",10,"Enjoy!",0 - - fi_launch: - dd 7, 0, params, 0, 0 - db "/sys/@notify", 0 - -fileopen dd 7 - dd 0,0,0,0 - db 0 -.path dd ? ; path -;===================================================================== - -I_END: +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2017-2024. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; netsurf-installer - Set up Netsurf Browser on KolibriOS ;; +;; Author: ashmew2. ;; +;; ;; +;; Inspired from downloader.asm by hidnplayr@kolibrios.org ;; +;; GENERAL PUBLIC LICENSE ;; +;; Version 2, June 1991 ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +URLMAXLEN = 65535 +FILENAMEMAXLEN = 1024 +__DEBUG_LEVEL__ = 2 +__DEBUG__ = 1 + +format binary as "" +use32 + org 0x0 + db 'MENUET01' ; header + dd 0x01 ; header version + dd START ; entry point + dd I_END ; image size + dd I_END+0x1000 ; required memory + dd I_END+0x1000 ; esp + dd 0x0 ; I_Path + dd 0x0 ; I_Path + +include '../../macros.inc' +include '../../proc32.inc' +include '../../dll.inc' +include '../../debug-fdo.inc' +include '../../develop/libraries/http/http.inc' +include '../../string.inc' + +include '../../system/notify3/notify.inc' + +include 'notify.asm' + +virtual at 0 + http_msg http_msg +end virtual + +;; Parameters +;; HTTP URL to download +;; Target filename +proc get_file_over_http targeturl, targetfilename + pusha + xor eax, eax + mov [write_to_file.current_offset], eax + mov [write_to_file.bufsize], eax + mov [write_to_file.bufptr], eax + + DEBUGF 1, "---- HTTP : Getting %s\n", [targeturl] + invoke HTTP_get, [targeturl], 0, FLAG_KEEPALIVE or FLAG_BLOCK, 0 + cmp eax, 0 + je .http_error + mov [httpstruct], eax + + ;; No HTTP errors, create a new file for the download. + DEBUGF 1, "---- Creating new file : %s\n", [targetfilename] + mcall 70, create_new_file + cmp eax, 0 + jne .file_error + + .http_receive_loop: + DEBUGF 1, "---- Receiving over http.\n" + invoke HTTP_receive, [httpstruct] + + cmp eax, 0 + je .http_transfer_done + + + mov ebp, [httpstruct] + DEBUGF 1, "---- http flags = 0x%x.\n", [ebp + http_msg.flags] + test [ebp + http_msg.flags], 0xffff0000 + jnz .http_error + + mov ebp, [ebp + http_msg.content_received] + cmp ebp, [write_to_file.current_offset] + jle .http_receive_loop + ;; Only proceed if we have more data in HTTP buffer than we have written to file. + + ;; Process data we got (write it to the file) + mov ebp, [httpstruct] + mov ecx, [ebp + http_msg.content_length] + mov edx, [ebp + http_msg.content_received] + + DEBUGF 1, "---- Current file write offset : %u (http got : %u / %u)\n", [write_to_file.current_offset], edx, ecx + sub edx, [write_to_file.current_offset] + mov [write_to_file.bufsize], edx + + mov ecx, [ebp + http_msg.content_ptr] + add ecx, [write_to_file.current_offset] + mov [write_to_file.bufptr], ecx + + DEBUGF 1, "---- ecx + offset = 0x%x\n", ecx + DEBUGF 1, "---- Writing to file %u bytes at 0x%x to %s\n", [write_to_file.bufsize], [write_to_file.bufptr], current_filename + mcall 70, write_to_file + cmp eax, 0 + jne .file_error + + DEBUGF 1, "---- Wrote to file %u bytes.\n", ebx + add [write_to_file.current_offset], ebx + DEBUGF 1, "---- File offset updated to : %u\n", [write_to_file.current_offset] + + jmp .http_receive_loop + + .file_error: + DEBUGF 1, "file_erroR with eax = %u!", eax + call EXIT + + .http_error: + DEBUGF 1, "http_erroR!" + call EXIT + + .http_transfer_done: + ;; Write any remaining bytes from the http buffer into the file + DEBUGF 1, "---- http flags = 0x%x.\n", [httpstruct + http_msg.flags] + DEBUGF 1, "Got %u bytes in total\n", [httpstruct + http_msg.content_length] + + mov ebp, [httpstruct] + mov edx, [ebp + http_msg.content_length] + + sub edx, [write_to_file.current_offset] + mov [write_to_file.bufsize], edx + + mov ecx, [ebp + http_msg.content_ptr] + add ecx, [write_to_file.current_offset] + mov [write_to_file.bufptr], ecx + + DEBUGF 1, "---- Final ecx + offset = 0x%x\n", ecx + DEBUGF 1, "-- Writing to file %u bytes at 0x%x to %s\n", [write_to_file.bufsize], [write_to_file.bufptr], current_filename + + mcall 70, write_to_file + cmp eax, 0 + jne .file_error + + DEBUGF 1, "-- Wrote to file %u bytes.\n", ebx + add [write_to_file.current_offset], ebx + DEBUGF 1, "-- File offset updated to : %u\n", [write_to_file.current_offset] + mov ebp, [httpstruct] + mov edx, [ebp + http_msg.content_length] + cmp [write_to_file.current_offset], edx + jne .http_transfer_done + + invoke HTTP_free, [httpstruct] + + popa + ret +endp + +proc make_new_folder newfolder + pusha + + mov eax, [newfolder] + mov [create_new_folder.foldername], eax + mcall 70, create_new_folder + test eax, eax + jz .success + + DEBUGF 1, "Failed to create folder: %s\n", [newfolder] + call EXIT + +.success: + popa + ret +endp + +proc run_if_exists file_path + m2m [fileinfo.path], [file_path] + mcall 70, fileinfo + test eax, eax + jnz @f + m2m [fileopen.path], [file_path] + mcall 70, fileopen + mcall -1 +@@: + ret +endp + + +START: + stdcall run_if_exists, TMP_netsurf + stdcall run_if_exists, ISO_netsurf + + mcall 68, 11 ; init heap + call NOTIFY_RUN + +; load libraries + stdcall dll.Load, @IMPORT + test eax, eax + jnz .all_files_done_error + + DEBUGF 2, "-------------------------\n" + DEBUGF 2, "NETSURF INSTALLER.\n" + + stdcall make_new_folder, dirname_res + ; stdcall make_new_folder, dirname_res_pointers + ; stdcall make_new_folder, dirname_res_throbber + ; stdcall make_new_folder, dirname_res_icons + + +.get_next_file: + mov edi, current_url + mov esi, url + + @@: + movsb + cmp byte[esi], 0 + jne @b + ;; Loaded the base URL into current URL + + ;; Move onto the subsequent file. + mov esi, [filelistoffset] + cmp byte[esi], 0 + je .all_files_done + + @@: + movsb + cmp byte[esi], 0 + jne @b + movsb + + ;; DEBUGF 1, "-- Current URL with filename is : %s\n", current_url + +; Create name of file we will download to + mov esi, download_file_path + mov edi, current_filename + + @@: + movsb + cmp byte[esi], 0 + jne @b + + mov esi, [filelistoffset] + @@: + movsb + cmp byte[esi], 0 + jne @b + movsb + mov [filelistoffset], esi + + ;; current_filename is now set to the name of the file + ;; current_url is now set to the name of the file we will get after download + DEBUGF 2, "Fetching : %s", current_filename + pusha + call NOTIFY_CHANGE + popa + stdcall get_file_over_http, current_url, current_filename + DEBUGF 2, "...DONE!\n" + jmp .get_next_file + +.all_files_done: + DEBUGF 2, "-------------------------\n" + DEBUGF 2, "NETSURF INSTALLED. Enjoy!\n" + DEBUGF 2, "-------------------------\n" + call EXIT + ;; Inform user that all files are done + +.all_files_done_error: + DEBUGF 1, "FATAL ERROR: FAILED.\n", eax + call EXIT + +;--------------------------------------------------------------------- +; Data area +;----------------------------------------------------------------------------- +align 4 +@IMPORT: + +library lib_http, 'http.obj' +import lib_http, \ + HTTP_get, 'get', \ + HTTP_receive, 'receive', \ + HTTP_free, 'free' + +include_debug_strings + +download_file_path db '/tmp0/1/', 0 +dirname_res db '/tmp0/1/res', 0 +dirname_res_pointers db '/tmp0/1/res/pointers', 0 +dirname_res_throbber db '/tmp0/1/res/throbber', 0 +dirname_res_icons db '/tmp0/1/res/icons', 0 + +url db 'www.kolibri-n.org/files/netsurf/',0 + +; TODO: I don't know why NOTIFY_CHANGE doesn't work for the first file +; so I use this small hack to fix it at NOTIFY_RUN phase +filelist_first db '/tmp0/1/netsurf', 0 + +MAX_FILES = 6 + +filelist db 'netsurf', 0 + ;db 'netsurf-kolibrios.map', 0 ; what's this??? + db 'res/adblock.css', 0 + db 'res/quirks.css', 0 + db 'res/Messages', 0 + db 'res/default.css', 0 + db 'res/sans.ttf', 0 + db 'res/internal.css', 0 + ; db 'res/welcome.html', 0 + ; db 'res/licence.html', 0 + ; db 'res/maps.html', 0 + ; db 'res/credits.html', 0 + ; db 'res/favicon.png', 0 + ; db 'res/netsurf.png', 0 + ; db 'res/throbber/throbber8.png', 0 + ; db 'res/throbber/throbber3.png', 0 + ; db 'res/throbber/throbber4.png', 0 + ; db 'res/throbber/throbber0.png', 0 + ; db 'res/throbber/throbber6.png', 0 + ; db 'res/throbber/throbber2.png', 0 + ; db 'res/throbber/throbber1.png', 0 + ; db 'res/throbber/throbber7.png', 0 + ; db 'res/throbber/throbber5.png', 0 + ; db 'res/pointers/point.png', 0 + ; db 'res/pointers/no_drop.png', 0 + ; db 'res/pointers/wait.png', 0 + ; db 'res/pointers/up-down.png', 0 + ; db 'res/pointers/help.png', 0 + ; db 'res/pointers/ru-ld.png', 0 + ; db 'res/pointers/menu.png', 0 + ; db 'res/pointers/not_allowed.png', 0 + ; db 'res/pointers/cross.png', 0 + ; db 'res/pointers/default.png', 0 + ; db 'res/pointers/caret.png', 0 + ; db 'res/pointers/left-right.png', 0 + ; db 'res/pointers/lu-rd.png', 0 + ; db 'res/pointers/progress.png', 0 + ; db 'res/pointers/move.png', 0 + ; db 'res/icons/back.png', 0 + ; db 'res/icons/back_g.png', 0 + ; db 'res/icons/scrollr.png', 0 + ; db 'res/icons/osk.png', 0 + ; db 'res/icons/forward_g.png', 0 + ; db 'res/icons/scrolll.png', 0 + ; db 'res/icons/history.png', 0 + ; db 'res/icons/forward.png', 0 + ; db 'res/icons/home_g.png', 0 + ; db 'res/icons/history_g.png', 0 + ; db 'res/icons/reload_g.png', 0 + ; db 'res/icons/scrollu.png', 0 + ; db 'res/icons/stop.png', 0 + ; db 'res/icons/scrolld.png', 0 + ; db 'res/icons/stop_g.png', 0 + ; db 'res/icons/home.png', 0 + ; db 'res/icons/reload.png', 0 + db 0 + +filelistoffset dd filelist +httpstruct dd 0 + +create_new_file dd 2, 0, 0, 0, 0 + db 0 + dd current_filename + +create_new_folder dd 9, 0, 0, 0, 0 + db 0 + .foldername dd 0 + +write_to_file dd 3 + .current_offset dd 0, 0 + .bufsize dd 0 + .bufptr dd 0 + db 0 + dd current_filename + +socketdata rb 4096 +current_url rb URLMAXLEN +current_filename rb FILENAMEMAXLEN + +ISO_netsurf db "/kolibrios/netsurf/netsurf", 0 +TMP_netsurf db "/tmp0/1/netsurf", 0 + +bdvk_buf rb 560 + +fileinfo dd 5 + dd 0,0,0 + dd bdvk_buf + db 0 +.path dd ? ; path + +;===================================================================== +; NOTIFY DATA +timer dd 0 +params rb 256 +ctrl: + .name rb 32 + .addr rd 1 +rb 2048 + + sz_text: + db "Downloading Netsurf ",10, 0 + sz_quote: + db "'", 0 + sz_flags: + db "Ddcpt", 0 + + sz_final_text: + db "Netsurf download complete.",10,"Enjoy!",0 + + fi_launch: + dd 7, 0, params, 0, 0 + db "/sys/@notify", 0 + +fileopen dd 7 + dd 0,0,0,0 + db 0 +.path dd ? ; path +;===================================================================== + +I_END: