Compare commits

..
1 Commits
Author SHA1 Message Date
Matou1306 e9e9ebb4c8 Implemented wrapper for @open (#344)
Fixed #336

Implemented a wrapper for placing the path to a file in quotes.
This corrects the problem of handling paths containing spaces in C programs such as `DGEN`,
 since the space is the argument delimiter.

The wrapper should have the name `<app>_open`. Wrapper trims the `_open` postfix and launches the `<app>`.

Reviewed-on: KolibriOS/kolibrios#344
Reviewed-by: Ivan B <dunkaist@noreply.localhost>
Reviewed-by: Max Logaev <maxlogaev@proton.me>
Co-authored-by: Matou <mathieubotros@gmail.com>
Co-committed-by: Matou <mathieubotros@gmail.com>
2026-03-23 14:34:07 +00:00
7 changed files with 69 additions and 177 deletions

No files matched your search

+1
View File
@@ -800,6 +800,7 @@ if tup.getconfig('NO_NASM') ~= 'full' then
{"kolibrios/games/wolf3d/", VAR_CONTRIB .. "/games/wolf3d/wolf3d"},
{"kolibrios/games/wolf3d/", "common/games/wolf3d/*"},
{"kolibrios/emul/dgen/dgen", VAR_PROGS .. "/emulator/dgen-sdl-1.33/dgen"},
{"kolibrios/emul/dgen/dgen_open", VAR_PROGS .. "/fs/wrap_open/wrap_open"},
{"kolibrios/emul/dgen/dgen.html", SRC_PROGS .. "/emulator/dgen-sdl-1.33/dgen.html"},
{"kolibrios/emul/dgen/dgenrc.html", SRC_PROGS .. "/emulator/dgen-sdl-1.33/dgenrc.html"},
})
+2 -2
View File
@@ -190,8 +190,8 @@ gbc=/kolibrios/emul/gameboy
min=/kolibrios/emul/pokemini
nc=/kolibrios/utils/cnc_editor/cnc_editor
ch8=/kolibrios/emul/chip8/chip8
md=/kolibrios/emul/dgen/dgen
gen=/kolibrios/emul/dgen/dgen
md=/kolibrios/emul/dgen/dgen_open
gen=/kolibrios/emul/dgen/dgen_open
rom=/kolibrios/emul/uxn
zip=$Unz
-61
View File
@@ -1,61 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include 'devices.inc'
VEN_STRIDE = 8
; Returns pointer to the device id stored in data
; clears and returns value in esi
proc PCI_find_dev stdcall ven_id, dev_id
push edx
xor esi, esi
mov esi, ven1_array
cmp [ven_id], VirtVendorID1
jz .next_device_id
mov esi, ven2_array
cmp [ven_id], VirtVendorID2
jnz .not_found ;unknown vendor id
.next_device_id:
mov edx, [esi] ;fewer memory accesses
test edx, edx
jz .not_found ;end of array
add esi, VEN_STRIDE
cmp edx, [dev_id]
jnz .next_device_id
;Found device
sub esi, VEN_STRIDE ;The loop adds it an one time extra
pop edx
ret
.not_found:
pop edx
xor esi, esi
ret
endp
; Follow convention: {id, msg}
align 4
ven1_array dd idDevNetwork,msgDevNetwork
dd idDevBlock,msgDevBlock
dd idDevBalloon,msgDevBallon
dd idDevConsole,msgDevConsole
dd 0,0
ven2_array dd idDevNVME,msgDevNVME
dd 0,0
-27
View File
@@ -1,27 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
VirtVendorID1 = 0x1af4
VirtVendorID2 = 0x1b36
; Device description strings
align 4
idDevNetwork = 0x1000
idDevBlock = 0x1001
idDevBalloon = 0x1002
idDevConsole = 0x1003
idDevNVME = 0x0010
align 4
msgDevNetwork db "Network",0
msgDevBlock db "Block",0
msgDevBallon db "Balloon",0
msgDevConsole db "Console",0
msgDevNVME db "NVME",0
-87
View File
@@ -1,87 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format PE DLL native 0.05
entry START
DEBUG equ 1
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
section '.flat' code readable writable executable
include '../proc32.inc'
include '../struct.inc'
include '../macros.inc'
include '../peimport.inc'
include '../fdo.inc'
include 'device_table.inc'
proc START c, state:dword, cmdline:dword
cmp [state], 1
jne .exit
.entry:
push esi
mov esi, msgInit
invoke SysMsgBoardStr
call detect
pop esi
.exit:
mov eax, 1
ret
endp
proc detect
push ebx
invoke GetPCIList
mov ebx, eax
.next_dev:
mov eax, [eax+PCIDEV.fd]
cmp eax, ebx
jz .finish
mov esi, msgVirtIO
mov edx, [eax+PCIDEV.vendor_device_id]
mov ecx, edx
shr ecx, 16 ;cx upper half - device id, dx lower half - vendor id
;prepare regs for find dev proc
movzx edx, dx
stdcall PCI_find_dev, edx, ecx
test esi, esi
jz .notVirt
add esi, 4
DEBUGF 1, "I: VirtIO Driver %x:%x -> %s\n", dx, cx, [esi]
.notVirt:
jmp .next_dev
.finish:
xor eax, eax
pop ebx
inc eax
ret
endp
align 4
msgInit db 'I: detecting VirtIO drivers',13,10,0
msgVirtIO db 'VirtIO driver',0
align 4
data fixups
end data
include_debug_strings
+3
View File
@@ -0,0 +1,3 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.include("../../use_fasm.lua")
tup.rule("wrap_open.asm", FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "wrap_open")
+63
View File
@@ -0,0 +1,63 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2013-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; wraps command line arguments in quotes and launches a target.
include 'KOSfuncs.inc'
include 'macros.inc'
org 0x0
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd m_end
dd m_end
dd path
dd target_path
start:
mov edi, target_path
or ecx, -1
xor al, al
repne scasb
sub edi, 6
mov byte [edi], 0
cmp byte [path], 0
je .launch
mov byte [q_path], '"'
mov edi, path
or ecx, -1
xor al, al
repne scasb
mov word [edi-1], '"'
mov dword [fi + 8], q_path
.launch:
mcall SF_FILE, fi
mcall SF_TERMINATE_PROCESS
fi:
dd SSF_START_APP, 0, 0, 0, 0
db 0
dd target_path
i_end:
q_path rb 1
path rb 255
target_path rb 1024
m_end: