This commit is contained in:
Mario Fetka
2026-05-23 19:25:36 +02:00
parent 698143d135
commit c97700a1d3
3 changed files with 216 additions and 0 deletions

1
kern.h
View File

@@ -19,6 +19,7 @@ extern int KERN_CALL C32_LoadNios_Probe(UI axfunc, void *outbuf);
extern int KERN_CALL C32_GetFunc_Probe(char *name, void *outbuf);
extern int KERN_CALL C32_CallVersion_Nios_Probe(void *outbuf);
extern int KERN_CALL C32_MapLock_Probe(void *ptr, UI len, void *outbuf);
extern int KERN_CALL C32_OpenRef_Probe(UI refLo, UI refHi, void *outbuf);
extern int KERN_CALL C32_NCP87_Raw_Probe(UI connLo, UI connHi,
void *hdr, UI hdrLen,
void *path, UI pathLen,

View File

@@ -25,6 +25,7 @@ public _C32_GetFunc_Probe
public _C32_CallVersion_Nios_Probe
public _C32_MapLock_Probe
public _C32_NCP87_Raw_Probe
public _C32_OpenRef_Probe
public _Net_Call_VLM_Raw
public _Net_Call_NWCVLMREQ
@@ -1158,4 +1159,169 @@ _Net_Call_NWCVLMREQ endp
; int C32_OpenRef_Probe(UI refLo, UI refHi, void *outbuf)
;
; Opens a Client32 connection by connection reference using the same d32wrap
; convention as _CONNOpenByReference / w95ocref.o.
;
; Input:
; refLo/refHi = connection reference, e.g. C32PRIMREF returned 0028:0000.
;
; outbuf:
; +00 load AX from D8C1
; +02 resolver off
; +04 resolver seg
; +06 trampoline off
; +08 trampoline seg
; +0A function off
; +0C function seg
; +0E return AX
; +10 return DX
; +12 handle low
; +14 handle high
_C32_OpenRef_Probe proc far
push bp
mov bp, sp
sub sp, 80
push ds
push es
push si
push di
; clear ESI/ECX
db 66h, 33h, 0F6h
db 66h, 33h, 0C9h
mov ax, 0D8C1h
int 2Fh
mov [bp-4], ax ; load AX
; resolver ESI -> [bp-8]
db 66h, 89h, 76h, 0F8h
; trampoline ECX -> [bp-12]
db 66h, 89h, 4Eh, 0F4h
or ax, ax
jne c32openref_fail
; resolve "CONNOpenByReference"
push cs
push offset c32openref_name
push 0
push 0
call dword ptr [bp-8]
add sp, 8
mov [bp-16], ax
mov [bp-14], dx
or ax, dx
jne c32openref_have_func
jmp c32openref_fail
c32openref_have_func:
; local output handle dword at [bp-20]
mov word ptr [bp-20], 0
mov word ptr [bp-18], 0
; MapLockFlat(&handle, 4) -> flat [bp-24]
push 0
push 4
push ss
lea ax, -20[bp]
push ax
push 0
push 2
call dword ptr [bp-8]
add sp, 0cH
mov [bp-24], ax
mov [bp-22], dx
; Call NIOS trampoline command 5 / CONNOpenByReference.
; This matches d32wrap _CONNOpenByReference after w95ocref:
; flat handle ptr,
; refHi/refLo,
; 0,0,
; FEFE FEFE FEFE FEFE,
; command 5,
; function ptr.
push word ptr [bp-22] ; flat handle high
push word ptr [bp-24] ; flat handle low
push word ptr [bp+8] ; ref high
push word ptr [bp+6] ; ref low
push 0
push 0
push 0fefeH
push 0fefeH
push 0fefeH
push 0fefeH
push 0
push 5
push word ptr [bp-14] ; function seg
push word ptr [bp-16] ; function off
call dword ptr [bp-12]
add sp, 1cH
mov [bp-28], ax
mov [bp-26], dx
; UnlockFlat(handle flat, 4)
push 0
push 4
push word ptr [bp-22]
push word ptr [bp-24]
push 0
push 3
call dword ptr [bp-8]
add sp, 0cH
jmp short c32openref_store
c32openref_fail:
mov word ptr [bp-16], 0
mov word ptr [bp-14], 0
mov word ptr [bp-28], 0ffffH
mov word ptr [bp-26], 0ffffH
mov word ptr [bp-20], 0
mov word ptr [bp-18], 0
c32openref_store:
les di, dword ptr [bp+10]
mov ax, [bp-4]
mov es:[di+0], ax
mov ax, [bp-8]
mov es:[di+2], ax
mov ax, [bp-6]
mov es:[di+4], ax
mov ax, [bp-12]
mov es:[di+6], ax
mov ax, [bp-10]
mov es:[di+8], ax
mov ax, [bp-16]
mov es:[di+10], ax
mov ax, [bp-14]
mov es:[di+12], ax
mov ax, [bp-28]
mov es:[di+14], ax
mov ax, [bp-26]
mov es:[di+16], ax
mov ax, [bp-20]
mov es:[di+18], ax
mov ax, [bp-18]
mov es:[di+20], ax
pop di
pop si
pop es
pop ds
mov sp, bp
pop bp
xor ah, ah
ret
c32openref_name db 'CONNOpenByReference',0
_C32_OpenRef_Probe endp
end

View File

@@ -1472,6 +1472,52 @@ static int tests_c32primref(void)
}
static int tests_c32openref(int argc, char *argv[])
{
UI refLo = 40;
UI refHi = 0;
uint8 out[32];
uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg;
uint16 fn_off, fn_seg, ret_ax, ret_dx, h_lo, h_hi;
if (argc > 2)
refLo = (UI)atoi(argv[2]);
if (argc > 3)
refHi = (UI)atoi(argv[3]);
memset(out, 0, sizeof(out));
fprintf(stdout, "TEST C32OPENREF ref=%04X:%04X\n", refHi, refLo);
fprintf(stdout, "Open Client32 connection by reference via CONNOpenByReference\n");
C32_OpenRef_Probe(refLo, refHi, out);
load_ax = tests_get_word_lh(out + 0);
res_off = tests_get_word_lh(out + 2);
res_seg = tests_get_word_lh(out + 4);
tramp_off = tests_get_word_lh(out + 6);
tramp_seg = tests_get_word_lh(out + 8);
fn_off = tests_get_word_lh(out + 10);
fn_seg = tests_get_word_lh(out + 12);
ret_ax = tests_get_word_lh(out + 14);
ret_dx = tests_get_word_lh(out + 16);
h_lo = tests_get_word_lh(out + 18);
h_hi = tests_get_word_lh(out + 20);
fprintf(stdout, "Load AX=%04X Resolver=%04X:%04X Tramp=%04X:%04X\n",
load_ax, res_seg, res_off, tramp_seg, tramp_off);
fprintf(stdout, "Function CONNOpenByReference=%04X:%04X\n", fn_seg, fn_off);
fprintf(stdout, "Return DX:AX=%04X:%04X handle=%04X:%04X\n",
ret_dx, ret_ax, h_hi, h_lo);
tests_dump_bytes("OUT:", out, 22);
if (ret_ax == 0 && ret_dx == 0)
fprintf(stdout, "\nNext test:\n TESTS NWREQ87C32RAW %u %u\n", h_lo, h_hi);
return(0);
}
int func_tests(int argc, char *argv[], int mode)
{
if (argc >= 2) {
@@ -1499,6 +1545,9 @@ int func_tests(int argc, char *argv[], int mode)
if (tests_same_arg(argv[1], "C32PRIMREF"))
return tests_c32primref();
if (tests_same_arg(argv[1], "C32OPENREF"))
return tests_c32openref(argc, argv);
if (tests_same_arg(argv[1], "NWREQ87C32MATRIX"))
return tests_nwreq87c32matrix();