From af8a046f9d82f1c4167652ae010b26123108d09e Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 23 May 2026 21:58:13 +0200 Subject: [PATCH] tests --- kern.h | 13 - kern_wasm.asm | 1708 ------------------------------------------------- nwtests.c | 752 +++------------------- 3 files changed, 105 insertions(+), 2368 deletions(-) diff --git a/kern.h b/kern.h index 8d0f06e..8e2c5a4 100644 --- a/kern.h +++ b/kern.h @@ -20,11 +20,6 @@ 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_MapVar_Probe(UI specLen, UI flag, void *outbuf); -extern int KERN_CALL C32_MapFull2_Probe(void *outbuf); -extern int KERN_CALL C32_MapFull_Probe(void *outbuf); -extern int KERN_CALL C32_ScanRefsIter_Probe(UI iterLo, UI iterHi, void *outbuf); -extern int KERN_CALL C32_ScanRefs2_Probe(void *outbuf); -extern int KERN_CALL C32_ScanFirst_Probe(void *outbuf); extern int KERN_CALL C32_OpenRef_Probe(UI refLo, UI refHi, void *outbuf); extern int KERN_CALL C32_NCP87_Raw5_Probe(UI connLo, UI connHi, void *hdr, UI hdrLen, @@ -32,17 +27,9 @@ extern int KERN_CALL C32_NCP87_Raw5_Probe(UI connLo, UI connHi, void *rep0, UI rep0Len, void *rep1, UI rep1Len, void *outbuf); -extern int KERN_CALL C32_NCP87_Raw_Probe(UI connLo, UI connHi, - void *hdr, UI hdrLen, - void *path, UI pathLen, - void *rep0, UI rep0Len, - void *rep1, UI rep1Len, - void *outbuf); extern int KERN_CALL Net_Call_VLM_Raw(UI ax, UI bx, UI cx, UI dx, void *req, void *repl, UI p1, UI p2, UI p3); -extern int KERN_CALL Net_Call_NWCVLMREQ(UI flags, void *regblk, - UI p1, UI p2, UI p3); extern int KERN_CALL Net_Call_C(UI func, void *req, void *repl); extern int KERN_CALL Net_Call_CX(UI func, UI bx, UI cx, UI dx, void *req, void *repl); diff --git a/kern_wasm.asm b/kern_wasm.asm index 215b5d4..2b7be2b 100644 --- a/kern_wasm.asm +++ b/kern_wasm.asm @@ -24,18 +24,10 @@ public _C32_LoadNios_Probe public _C32_GetFunc_Probe public _C32_CallVersion_Nios_Probe public _C32_MapLock_Probe -public _C32_NCP87_Raw_Probe public _C32_NCP87_Raw5_Probe public _C32_OpenRef_Probe -public _C32_ScanFirst_Probe -public _C32_ScanRefs2_Probe -public _C32_ScanRefsIter_Probe -public _C32_MapFull_Probe -public _C32_MapFull2_Probe public _C32_MapVar_Probe public _Net_Call_VLM_Raw -public _Net_Call_NWCVLMREQ - _IPXinit proc far push bp mov bp, sp @@ -718,453 +710,6 @@ mapflat_store: _C32_MapLock_Probe endp -; int C32_NCP87_Raw_Probe(UI connLo, UI connHi, -; void *hdr, UI hdrLen, -; void *path, UI pathLen, -; void *rep0, UI rep0Len, -; void *rep1, UI rep1Len, -; void *outbuf) -; -; Specialized raw Client32 NCP87/S6 request probe. -; Reproduces d32wrap.o _COMPATNcpRequestReply mechanics: -; - INT 2F AX=D8C1 -; - resolve COMPATNcpRequestReply via ESI resolver -; - MapLockFlat each fragment data buffer -; - build flat 8-byte frag tables -; - MapLockFlat frag tables and actualReplyLen -; - call ECX NIOS trampoline with command 8 and COMPATNcpRequestReply pointer -; - unlock mappings -; -; outbuf: -; +00 load AX -; +02 resolver off -; +04 resolver seg -; +06 trampoline off -; +08 trampoline seg -; +0A function off -; +0C function seg -; +0E ret AX -; +10 ret DX -; +12 actualReplyLen low -; +14 actualReplyLen high -_C32_NCP87_Raw_Probe proc far - push bp - mov bp, sp - sub sp, 100 - - push ds - push es - push si - push di - - ; clear ESI/ECX - db 66h, 33h, 0F6h - db 66h, 33h, 0C9h - - mov ax, 0D8C1h - int 2Fh - - ; save resolver ESI at [bp-84] - db 66h, 89h, 76h, 0ACh - ; save trampoline ECX at [bp-88] - db 66h, 89h, 4Eh, 0A8h - - mov [bp-2], ax ; load AX - or ax, ax - jne c32raw_fail - - ; resolve "COMPATNcpRequestReply" - push cs - push offset c32raw_name - push 0 - push 0 - call dword ptr [bp-84] - add sp, 8 - mov [bp-92], ax - mov [bp-90], dx - or ax, dx - jne c32raw_have_func - jmp c32raw_fail - -c32raw_have_func: - ; actualReplyLen local at [bp-52] - mov word ptr [bp-52], 0 - mov word ptr [bp-50], 0 - - ; Map hdr data -> [bp-56] - push 0 - push word ptr [bp+0eH] - push word ptr [bp+0cH] - push word ptr [bp+0aH] - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-56], ax - mov [bp-54], dx - - ; Map path data -> [bp-60] - push 0 - push word ptr [bp+14H] - push word ptr [bp+12H] - push word ptr [bp+10H] - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-60], ax - mov [bp-58], dx - - ; Map reply0 -> [bp-64] - push 0 - push word ptr [bp+1aH] - push word ptr [bp+18H] - push word ptr [bp+16H] - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-64], ax - mov [bp-62], dx - - ; Map reply1 -> [bp-68] - push 0 - push word ptr [bp+20H] - push word ptr [bp+1eH] - push word ptr [bp+1cH] - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-68], ax - mov [bp-66], dx - - ; Build req flat table at [bp-32], two entries: - ; entry = flatptr dword + len dword - mov ax, [bp-56] - mov [bp-32], ax - mov ax, [bp-54] - mov [bp-30], ax - mov ax, [bp+0eH] - mov [bp-28], ax - mov word ptr [bp-26], 0 - - mov ax, [bp-60] - mov [bp-24], ax - mov ax, [bp-58] - mov [bp-22], ax - mov ax, [bp+14H] - mov [bp-20], ax - mov word ptr [bp-18], 0 - - ; Build reply flat table at [bp-48] - mov ax, [bp-64] - mov [bp-48], ax - mov ax, [bp-62] - mov [bp-46], ax - mov ax, [bp+1aH] - mov [bp-44], ax - mov word ptr [bp-42], 0 - - mov ax, [bp-68] - mov [bp-40], ax - mov ax, [bp-66] - mov [bp-38], ax - mov ax, [bp+20H] - mov [bp-36], ax - mov word ptr [bp-34], 0 - - ; Map req table [bp-32] len 16 -> [bp-72] - push 0 - push 10H - push ss - lea ax, -32[bp] - push ax - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-72], ax - mov [bp-70], dx - - ; Map reply table [bp-48] len 16 -> [bp-76] - push 0 - push 10H - push ss - lea ax, -48[bp] - push ax - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-76], ax - mov [bp-74], dx - - ; Map actualReplyLen [bp-52] len 4 -> [bp-80] - push 0 - push 4 - push ss - lea ax, -52[bp] - push ax - push 0 - push 2 - call dword ptr [bp-84] - add sp, 0cH - mov [bp-80], ax - mov [bp-78], dx - - ; Call NIOS trampoline command 8 with COMPATNcpRequestReply pointer. - push word ptr [bp-78] ; actual flat hi - push word ptr [bp-80] ; actual flat lo - push word ptr [bp-74] ; reply table flat hi - push word ptr [bp-76] ; reply table flat lo - push 0 - push 2 ; num reply frags - push word ptr [bp-70] ; req table flat hi - push word ptr [bp-72] ; req table flat lo - push 0 - push 2 ; num req frags - push 0 - push 57H ; NCP function 87 - push 0 - push 0 - push word ptr [bp+8] ; conn high - push word ptr [bp+6] ; conn low - push 0 - push 8 - push word ptr [bp-90] ; function seg - push word ptr [bp-92] ; function off - call dword ptr [bp-88] - add sp, 28H - - mov [bp-96], ax - mov [bp-94], dx - - ; unlock mapped actual/table/data. Ignore returns. - push 0 - push 4 - push word ptr [bp-78] - push word ptr [bp-80] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push 10H - push word ptr [bp-74] - push word ptr [bp-76] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push 10H - push word ptr [bp-70] - push word ptr [bp-72] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push word ptr [bp+20H] - push word ptr [bp-66] - push word ptr [bp-68] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push word ptr [bp+1aH] - push word ptr [bp-62] - push word ptr [bp-64] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push word ptr [bp+14H] - push word ptr [bp-58] - push word ptr [bp-60] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - push 0 - push word ptr [bp+0eH] - push word ptr [bp-54] - push word ptr [bp-56] - push 0 - push 3 - call dword ptr [bp-84] - add sp, 0cH - - jmp short c32raw_store - -c32raw_fail: - mov word ptr [bp-92], 0 - mov word ptr [bp-90], 0 - mov word ptr [bp-96], 0FFFFH - mov word ptr [bp-94], 0FFFFH - mov word ptr [bp-52], 0 - mov word ptr [bp-50], 0 - -c32raw_store: - les di, dword ptr [bp+22H] - - mov ax, [bp-2] - mov es:[di+0], ax - mov ax, [bp-84] - mov es:[di+2], ax - mov ax, [bp-82] - mov es:[di+4], ax - mov ax, [bp-88] - mov es:[di+6], ax - mov ax, [bp-86] - mov es:[di+8], ax - mov ax, [bp-92] - mov es:[di+10], ax - mov ax, [bp-90] - mov es:[di+12], ax - mov ax, [bp-96] - mov es:[di+14], ax - mov ax, [bp-94] - mov es:[di+16], ax - mov ax, [bp-52] - mov es:[di+18], ax - mov ax, [bp-50] - mov es:[di+20], ax - - pop di - pop si - pop es - pop ds - mov sp, bp - pop bp - xor ah, ah - ret - -c32raw_name db 'COMPATNcpRequestReply',0 - -_C32_NCP87_Raw_Probe endp - - -; int Net_Call_NWCVLMREQ(UI flags, void *regblk, UI p1, UI p2, UI p3) -; -; 16-bit wrapper that reproduces the DeveloperNet NWCVLMREQ register-block -; calling convention, but without using Novell globals. -; -; regblk layout, same as dvlmreq.o: -; +00 SI -; +02 DS -; +04 DI -; +06 ES -; +08 AX -; +0A BX -; +0C CX -; +0E DX -; -; It calls the VLM entry returned by INT 2F AX=7A20. -; Stack args are pushed as p3,p2,p1, exactly like NWCVLMREQ. -_Net_Call_NWCVLMREQ proc far - push bp - mov bp, sp - sub sp, 4 - - push ds - push si - push di - push es - - mov ax, 7A20h - xor bx, bx - int 2Fh - or ax, ax - jz nwcvlm_found - - mov ax, 88FFh - jmp short nwcvlm_done - -nwcvlm_found: - ; save VLM entry ES:BX in [bp-4] - mov [bp-4], bx - mov ax, es - mov [bp-2], ax - - les bx, dword ptr [bp+8] ; regblk - - ; Match NWCVLMREQ defaulting: - ; if !(flags & 2), set regblk.ES to current ES. - ; We normally pass flags=2, so this is skipped. - test word ptr [bp+6], 2 - jne nwcvlm_skip_es - mov ax, es - mov word ptr es:[bx+6], ax -nwcvlm_skip_es: - - ; if !(flags & 1), set regblk.DS to current DS. - test word ptr [bp+6], 1 - jne nwcvlm_skip_ds - mov ax, ds - mov word ptr es:[bx+2], ax -nwcvlm_skip_ds: - - ; Load target registers from regblk. - mov ax, word ptr es:[bx+0Ah] - push ax ; target BX - mov ax, word ptr es:[bx+6] - push ax ; target ES - - mov ax, word ptr es:[bx+8] - mov cx, word ptr es:[bx+0Ch] - mov dx, word ptr es:[bx+0Eh] - mov si, word ptr es:[bx+0] - mov di, word ptr es:[bx+4] - mov ds, word ptr es:[bx+2] - - pop es - pop bx - - push word ptr [bp+10h] ; p3 - push word ptr [bp+0eh] ; p2 - push word ptr [bp+0ch] ; p1 - call dword ptr [bp-4] - - ; Store registers back into regblk. - push bx - push es - - les bx, dword ptr [bp+8] - mov word ptr es:[bx+8], ax - pop ax - mov word ptr es:[bx+6], ax - pop ax - mov word ptr es:[bx+0Ah], ax - mov word ptr es:[bx+0Ch], cx - mov word ptr es:[bx+0Eh], dx - mov word ptr es:[bx+0], si - mov word ptr es:[bx+4], di - mov word ptr es:[bx+2], ds - - mov ax, word ptr es:[bx+8] - -nwcvlm_done: - pop es - pop di - pop si - pop ds - - mov sp, bp - pop bp - ret -_Net_Call_NWCVLMREQ endp - - ; int C32_OpenRef_Probe(UI refLo, UI refHi, void *outbuf) ; @@ -1331,1259 +876,6 @@ c32openref_name db 'CONNOpenByReference',0 _C32_OpenRef_Probe endp -; int C32_ScanFirst_Probe(void *outbuf) -; -; Experimental minimal CONNScanInfo call through Client32/NIOS. -; It resolves CONNScanInfo and calls NIOS command 0x0A with: -; - no scan criterion -; - no returnConnInfo -; - a 4-byte iterator/connRef buffer -; -; This follows the d32wrap.o _CONNScanInfo call mechanics, but avoids the -; higher-level NWCString/SPECTDATA conversions for the first probe. -; -; outbuf: -; +00 load AX -; +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 result/iterator low -; +14 result/iterator high -_C32_ScanFirst_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 c32scan_fail - - ; resolve "CONNScanInfo" - push cs - push offset c32scan_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 c32scan_have_func - jmp c32scan_fail - -c32scan_have_func: - ; local result/iterator dword at [bp-20] - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - - ; MapLockFlat(&iterator, 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 - - ; NIOS command 0x0A / CONNScanInfo. - ; Layout mirrors d32wrap _CONNScanInfo's final ECX trampoline call: - ; mapped iterator/result pointer - push word ptr [bp-22] - push word ptr [bp-24] - - ; mapped returnInfo pointer = NULL - push 0 - push 0 - - ; returnInfo length = 0 - push 0 - push 0 - - ; eight scan/return fields = 0 for first/enumerate probe - push 0 - push 0 - push 0 - push 0 - push 0 - push 0 - push 0 - push 0 - - ; mapped scanInfo pointer = NULL - push 0 - push 0 - - ; four reserved/handle words; d32conni uses FEFE placeholders - push 0fefeH - push 0fefeH - push 0fefeH - push 0fefeH - - push 0 - push 0aH - push word ptr [bp-14] - push word ptr [bp-16] - call dword ptr [bp-12] - add sp, 30H - - mov [bp-28], ax - mov [bp-26], dx - - ; Unlock iterator - 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 c32scan_store - -c32scan_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 - -c32scan_store: - les di, dword ptr [bp+6] - - 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 - -c32scan_name db 'CONNScanInfo',0 - -_C32_ScanFirst_Probe endp - - -; int C32_ScanRefs2_Probe(void *outbuf) -; -; Second CONNScanInfo probe, following d32conni.o _C32SCANCONNINFO -; case: scanInfoLevel = none/0, returnInfoLevel = NWCC_INFO_CONN_REF(3). -; -; This uses the exact _CONNScanInfo / d32wrap parameter shape: -; scanIterator pointer -; returnConnInfo pointer length 4 -; connReference pointer -; and then calls ECX trampoline command 0x0A. -; -; outbuf: -; +00 load AX -; +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 connRef low from connReference local -; +14 connRef high -; +16 returnInfo low from return buffer -; +18 returnInfo high -; +1A scanIterator low -; +1C scanIterator high -_C32_ScanRefs2_Probe proc far - push bp - mov bp, sp - sub sp, 100 - - 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 c32scan2_fail - - ; resolve "CONNScanInfo" - push cs - push offset c32scan2_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 c32scan2_have_func - jmp c32scan2_fail - -c32scan2_have_func: - ; locals: - ; [bp-20] scanIterator dword, initialize to 0 - ; [bp-24] returnInfo dword - ; [bp-28] connReference dword - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - mov word ptr [bp-28], 0 - mov word ptr [bp-26], 0 - - ; Map scanIterator -> [bp-32] - 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-32], ax - mov [bp-30], dx - - ; Map returnInfo -> [bp-36] - push 0 - push 4 - push ss - lea ax, -24[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-36], ax - mov [bp-34], dx - - ; Map connReference -> [bp-40] - push 0 - push 4 - push ss - lea ax, -28[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-40], ax - mov [bp-38], dx - - ; Direct NIOS command 0x0A / CONNScanInfo. - ; This mirrors d32wrap _CONNScanInfo after its MapLockFlat calls. - push word ptr [bp-38] ; connReference flat high - push word ptr [bp-40] ; connReference flat low - - push word ptr [bp-34] ; returnInfo flat high - push word ptr [bp-36] ; returnInfo flat low - - push 0 ; returnInfo pointer high/or len high - push 4 ; returnInfo length low - - push 0 ; returnInfoLevel high - push 3 ; NWCC_INFO_CONN_REF - - push 0 ; scanIterator selector/hi from d32conni - push 1 ; scan iteration flag/value from d32conni default - - push 0 ; scanInfo flat high = none - push 0 ; scanInfo flat low = none - - push 0 ; scanInfoLevel hi - push 0 ; scanInfoLevel none - - push word ptr [bp-30] ; scanIterator flat high - push word ptr [bp-32] ; scanIterator flat low - - push 0fefeH - push 0fefeH - push 0fefeH - push 0fefeH - - push 0 - push 0aH - push word ptr [bp-14] - push word ptr [bp-16] - call dword ptr [bp-12] - add sp, 30H - - mov [bp-44], ax - mov [bp-42], dx - - ; Unlock all three mappings. - push 0 - push 4 - push word ptr [bp-38] - push word ptr [bp-40] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-34] - push word ptr [bp-36] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-30] - push word ptr [bp-32] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - jmp short c32scan2_store - -c32scan2_fail: - mov word ptr [bp-16], 0 - mov word ptr [bp-14], 0 - mov word ptr [bp-44], 0ffffH - mov word ptr [bp-42], 0ffffH - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - mov word ptr [bp-28], 0 - mov word ptr [bp-26], 0 - -c32scan2_store: - les di, dword ptr [bp+6] - - 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-44] - mov es:[di+14], ax - mov ax, [bp-42] - mov es:[di+16], ax - mov ax, [bp-28] - mov es:[di+18], ax - mov ax, [bp-26] - mov es:[di+20], ax - mov ax, [bp-24] - mov es:[di+22], ax - mov ax, [bp-22] - mov es:[di+24], ax - mov ax, [bp-20] - mov es:[di+26], ax - mov ax, [bp-18] - mov es:[di+28], ax - - pop di - pop si - pop es - pop ds - mov sp, bp - pop bp - xor ah, ah - ret - -c32scan2_name db 'CONNScanInfo',0 - -_C32_ScanRefs2_Probe endp - - -; int C32_ScanRefsIter_Probe(UI iterLo, UI iterHi, void *outbuf) -; -; Second CONNScanInfo probe, following d32conni.o _C32SCANCONNINFO -; case: scanInfoLevel = none/0, returnInfoLevel = NWCC_INFO_CONN_REF(3). -; -; This uses the exact _CONNScanInfo / d32wrap parameter shape: -; scanIterator pointer -; returnConnInfo pointer length 4 -; connReference pointer -; and then calls ECX trampoline command 0x0A. -; -; outbuf: -; +00 load AX -; +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 connRef low from connReference local -; +14 connRef high -; +16 returnInfo low from return buffer -; +18 returnInfo high -; +1A scanIterator low -; +1C scanIterator high -_C32_ScanRefsIter_Probe proc far - push bp - mov bp, sp - sub sp, 100 - - 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 c32scani_fail - - ; resolve "CONNScanInfo" - push cs - push offset c32scani_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 c32scani_have_func - jmp c32scani_fail - -c32scani_have_func: - ; locals: - ; [bp-20] scanIterator dword, initialize to 0 - ; [bp-24] returnInfo dword - ; [bp-28] connReference dword - mov ax, [bp+6] - mov word ptr [bp-20], ax - mov ax, [bp+8] - mov word ptr [bp-18], ax - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - mov word ptr [bp-28], 0 - mov word ptr [bp-26], 0 - - ; Map scanIterator -> [bp-32] - 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-32], ax - mov [bp-30], dx - - ; Map returnInfo -> [bp-36] - push 0 - push 4 - push ss - lea ax, -24[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-36], ax - mov [bp-34], dx - - ; Map connReference -> [bp-40] - push 0 - push 4 - push ss - lea ax, -28[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-40], ax - mov [bp-38], dx - - ; Direct NIOS command 0x0A / CONNScanInfo. - ; This mirrors d32wrap _CONNScanInfo after its MapLockFlat calls. - push word ptr [bp-38] ; connReference flat high - push word ptr [bp-40] ; connReference flat low - - push word ptr [bp-34] ; returnInfo flat high - push word ptr [bp-36] ; returnInfo flat low - - push 0 ; returnInfo pointer high/or len high - push 4 ; returnInfo length low - - push 0 ; returnInfoLevel high - push 3 ; NWCC_INFO_CONN_REF - - push 0 ; scanIterator selector/hi from d32conni - push 1 ; scan iteration flag/value from d32conni default - - push 0 ; scanInfo flat high = none - push 0 ; scanInfo flat low = none - - push 0 ; scanInfoLevel hi - push 0 ; scanInfoLevel none - - push word ptr [bp-30] ; scanIterator flat high - push word ptr [bp-32] ; scanIterator flat low - - push 0fefeH - push 0fefeH - push 0fefeH - push 0fefeH - - push 0 - push 0aH - push word ptr [bp-14] - push word ptr [bp-16] - call dword ptr [bp-12] - add sp, 30H - - mov [bp-44], ax - mov [bp-42], dx - - ; Unlock all three mappings. - push 0 - push 4 - push word ptr [bp-38] - push word ptr [bp-40] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-34] - push word ptr [bp-36] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-30] - push word ptr [bp-32] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - jmp short c32scani_store - -c32scani_fail: - mov word ptr [bp-16], 0 - mov word ptr [bp-14], 0 - mov word ptr [bp-44], 0ffffH - mov word ptr [bp-42], 0ffffH - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - mov word ptr [bp-28], 0 - mov word ptr [bp-26], 0 - -c32scani_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-44] - mov es:[di+14], ax - mov ax, [bp-42] - mov es:[di+16], ax - mov ax, [bp-28] - mov es:[di+18], ax - mov ax, [bp-26] - mov es:[di+20], ax - mov ax, [bp-24] - mov es:[di+22], ax - mov ax, [bp-22] - mov es:[di+24], ax - mov ax, [bp-20] - mov es:[di+26], ax - mov ax, [bp-18] - mov es:[di+28], ax - - pop di - pop si - pop es - pop ds - mov sp, bp - pop bp - xor ah, ah - ret - -c32scani_name db 'CONNScanInfo',0 - -_C32_ScanRefsIter_Probe endp - - - -; int C32_MapFull_Probe(void *outbuf) -; -; Exact-ish raw version of w95mconn.o::__C32MapConn16To32 second step. -; -; It emulates: -; C32MAPCONNONE 40 -> server name MARS -; NWCSCANCONNINFO(scanIterator/result ptr, -; scanInfoLevel=0A, scanConnInfo=NWCString/SPECTDATA "MARS", -; scanFlags=1, connInfoVersion=0, -; returnInfoLevel=0, returnConnInfo=NULL, -; connReference local) -; -; But calls Client32 CONNScanInfo directly through ECX/NIOS command 0A. -; -; outbuf: -; +00 load AX -; +02 resolver off -; +04 resolver seg -; +06 trampoline off -; +08 trampoline seg -; +0A function off -; +0C function seg -; +0E ret AX -; +10 ret DX -; +12 resultRef low ; corresponds to caller output ptr in w95mconn -; +14 resultRef high -; +16 connRefLocal low ; corresponds to d32conni local -1c -; +18 connRefLocal high -_C32_MapFull_Probe proc far - push bp - mov bp, sp - sub sp, 140 - - 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 c32mapfull_fail - - ; resolve "CONNScanInfo" - push cs - push offset c32mapfull_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 c32mapfull_have_func - jmp c32mapfull_fail - -c32mapfull_have_func: - ; resultRef/output dword at [bp-20], init 0 - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - - ; connReference local dword at [bp-24], init 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - - ; string buffer at [bp-80], copy "MARS", zero padded enough - lea di, -80[bp] - push ss - pop es - mov byte ptr es:[di+0], 'M' - mov byte ptr es:[di+1], 'A' - mov byte ptr es:[di+2], 'R' - mov byte ptr es:[di+3], 'S' - mov byte ptr es:[di+4], 0 - - ; Map string buffer len 31h -> [bp-28] - push 0 - push 31H - push ss - lea ax, -80[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-28], ax - mov [bp-26], dx - - ; Build SPECTDATA/NWCString transfer block at [bp-48], len 10h. - ; Mirrors d32conni initialization for server-name scan. - mov word ptr [bp-48], 31H - mov word ptr [bp-46], 0 - mov ax, [bp-28] - mov word ptr [bp-44], ax - mov ax, [bp-26] - mov word ptr [bp-42], ax - mov word ptr [bp-40], 1 - mov word ptr [bp-38], 0 - mov word ptr [bp-36], 0 - mov word ptr [bp-34], 0 - - ; Map scanInfo spectdata block len 10h -> [bp-32] - push 0 - push 10H - push ss - lea ax, -48[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-32], ax - mov [bp-30], dx - - ; Map resultRef/output len4 -> [bp-56] (this is w95mconn caller ptr) - 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-56], ax - mov [bp-54], dx - - ; Map connReference local len4 -> [bp-60] - push 0 - push 4 - push ss - lea ax, -24[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-60], ax - mov [bp-58], dx - - ; Raw CONNScanInfo via NIOS, following d32wrap _CONNScanInfo - ; argument order from d32conni L$115. - push word ptr [bp-58] ; connReference flat high - push word ptr [bp-60] ; connReference flat low - - push 0 ; returnConnInfo flat high = NULL - push 0 ; returnConnInfo flat low = NULL - - push 0 ; returnInfoLen high - push 0 ; returnInfoLen low - - push 0 ; returnInfoLevel high - push 4 ; returnInfoLevel low, as d32conni L$115 - - push 0 ; connInfoVersion high - push 0 ; connInfoVersion low - - push word ptr [bp-30] ; scanInfo flat high - push word ptr [bp-32] ; scanInfo flat low - - push 0 ; scanInfoLevel high - push 0aH ; scanInfoLevel low = SERVER_NAME - - push word ptr [bp-54] ; scanIterator/result flat high - push word ptr [bp-56] ; scanIterator/result flat low - - push 0fefeH - push 0fefeH - push 0fefeH - push 0fefeH - - push 0 - push 0aH - push word ptr [bp-14] - push word ptr [bp-16] - call dword ptr [bp-12] - add sp, 30H - - mov [bp-64], ax - mov [bp-62], dx - - ; Unlock maps. - push 0 - push 4 - push word ptr [bp-58] - push word ptr [bp-60] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-54] - push word ptr [bp-56] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 10H - push word ptr [bp-30] - push word ptr [bp-32] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 31H - push word ptr [bp-26] - push word ptr [bp-28] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - jmp short c32mapfull_store - -c32mapfull_fail: - mov word ptr [bp-16], 0 - mov word ptr [bp-14], 0 - mov word ptr [bp-64], 0ffffH - mov word ptr [bp-62], 0ffffH - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - -c32mapfull_store: - les di, dword ptr [bp+6] - - 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-64] - mov es:[di+14], ax - mov ax, [bp-62] - mov es:[di+16], ax - mov ax, [bp-20] - mov es:[di+18], ax - mov ax, [bp-18] - mov es:[di+20], ax - mov ax, [bp-24] - mov es:[di+22], ax - mov ax, [bp-22] - mov es:[di+24], ax - - pop di - pop si - pop es - pop ds - mov sp, bp - pop bp - xor ah, ah - ret - -c32mapfull_name db 'CONNScanInfo',0 - -_C32_MapFull_Probe endp - - -; int C32_MapFull2_Probe(void *outbuf) -; -; Exact-ish raw version of w95mconn.o::__C32MapConn16To32 second step. -; -; It emulates: -; C32MAPCONNONE 40 -> server name MARS -; NWCSCANCONNINFO(scanIterator/result ptr, -; scanInfoLevel=0A, scanConnInfo=NWCString/SPECTDATA "MARS", -; scanFlags=1, connInfoVersion=0, -; returnInfoLevel=0, returnConnInfo=NULL, -; connReference local) -; -; But calls Client32 CONNScanInfo directly through ECX/NIOS command 0A. -; -; outbuf: -; +00 load AX -; +02 resolver off -; +04 resolver seg -; +06 trampoline off -; +08 trampoline seg -; +0A function off -; +0C function seg -; +0E ret AX -; +10 ret DX -; +12 resultRef low ; corresponds to caller output ptr in w95mconn -; +14 resultRef high -; +16 connRefLocal low ; corresponds to d32conni local -1c -; +18 connRefLocal high -_C32_MapFull2_Probe proc far - push bp - mov bp, sp - sub sp, 140 - - 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 c32mapfull2_fail - - ; resolve "CONNScanInfo" - push cs - push offset c32mapfull2_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 c32mapfull2_have_func - jmp c32mapfull2_fail - -c32mapfull2_have_func: - ; resultRef/output dword at [bp-20], init 0 - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - - ; connReference local dword at [bp-24], init 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - - ; string buffer at [bp-80], copy "MARS", zero padded enough - lea di, -80[bp] - push ss - pop es - mov byte ptr es:[di+0], 'M' - mov byte ptr es:[di+1], 'A' - mov byte ptr es:[di+2], 'R' - mov byte ptr es:[di+3], 'S' - mov byte ptr es:[di+4], 0 - - ; Map string buffer len 31h -> [bp-28] - push 0 - push 31H - push ss - lea ax, -80[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-28], ax - mov [bp-26], dx - - ; Build SPECTDATA/NWCString transfer block at [bp-48], len 10h. - ; Mirrors d32conni initialization for server-name scan. - mov word ptr [bp-48], 31H - mov word ptr [bp-46], 0 - mov ax, [bp-28] - mov word ptr [bp-44], ax - mov ax, [bp-26] - mov word ptr [bp-42], ax - mov word ptr [bp-40], 1 - mov word ptr [bp-38], 0 - mov word ptr [bp-36], 0 - mov word ptr [bp-34], 0 - - ; Map scanInfo spectdata block len 10h -> [bp-32] - push 0 - push 10H - push ss - lea ax, -48[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-32], ax - mov [bp-30], dx - - ; Map resultRef/output len4 -> [bp-56] (this is w95mconn caller ptr) - 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-56], ax - mov [bp-54], dx - - ; Map connReference local len4 -> [bp-60] - push 0 - push 4 - push ss - lea ax, -24[bp] - push ax - push 0 - push 2 - call dword ptr [bp-8] - add sp, 0cH - mov [bp-60], ax - mov [bp-58], dx - - ; Raw CONNScanInfo via NIOS, following d32wrap _CONNScanInfo - ; argument order from d32conni L$115. - push word ptr [bp-58] ; connReference flat high - push word ptr [bp-60] ; connReference flat low - - push 0 ; returnConnInfo flat high = NULL - push 0 ; returnConnInfo flat low = NULL - - push 0 ; returnInfoLen high - push 0 ; returnInfoLen low - - push 0 ; returnInfoLevel high - push 4 ; returnInfoLevel low, as d32conni L$115 - - push 0 ; scan flag/high from d32conni -1e - push 1 ; scan flag/low from d32conni -20 - - push word ptr [bp-30] ; scanInfo flat high - push word ptr [bp-32] ; scanInfo flat low - - push 0 ; scanInfoLevel high - push 0aH ; scanInfoLevel low = SERVER_NAME - - push word ptr [bp-54] ; scanIterator/result flat high - push word ptr [bp-56] ; scanIterator/result flat low - - push 0fefeH - push 0fefeH - push 0fefeH - push 0fefeH - - push 0 - push 0aH - push word ptr [bp-14] - push word ptr [bp-16] - call dword ptr [bp-12] - add sp, 30H - - mov [bp-64], ax - mov [bp-62], dx - - ; Unlock maps. - push 0 - push 4 - push word ptr [bp-58] - push word ptr [bp-60] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 4 - push word ptr [bp-54] - push word ptr [bp-56] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 10H - push word ptr [bp-30] - push word ptr [bp-32] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - push 0 - push 31H - push word ptr [bp-26] - push word ptr [bp-28] - push 0 - push 3 - call dword ptr [bp-8] - add sp, 0cH - - jmp short c32mapfull2_store - -c32mapfull2_fail: - mov word ptr [bp-16], 0 - mov word ptr [bp-14], 0 - mov word ptr [bp-64], 0ffffH - mov word ptr [bp-62], 0ffffH - mov word ptr [bp-20], 0 - mov word ptr [bp-18], 0 - mov word ptr [bp-24], 0 - mov word ptr [bp-22], 0 - -c32mapfull2_store: - les di, dword ptr [bp+6] - - 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-64] - mov es:[di+14], ax - mov ax, [bp-62] - mov es:[di+16], ax - mov ax, [bp-20] - mov es:[di+18], ax - mov ax, [bp-18] - mov es:[di+20], ax - mov ax, [bp-24] - mov es:[di+22], ax - mov ax, [bp-22] - mov es:[di+24], ax - - pop di - pop si - pop es - pop ds - mov sp, bp - pop bp - xor ah, ah - ret - -c32mapfull2_name db 'CONNScanInfo',0 - -_C32_MapFull2_Probe endp - - ; int C32_MapVar_Probe(UI specLen, UI flag, void *outbuf) ; diff --git a/nwtests.c b/nwtests.c index cc12337..e5250df 100644 --- a/nwtests.c +++ b/nwtests.c @@ -1300,111 +1300,6 @@ static int tests_c32mapflat(void) } -static int tests_nwreq87c32raw_one(UI connLo, UI connHi, UI label) -{ - uint8 connid = 0; - uint8 dhandle = 0; - uint8 flags = 0; - int drive; - uint8 hdr[16]; - uint8 path[0x140]; - uint8 rep0[0x60]; - uint8 rep1[0x110]; - uint8 out[32]; - UI path_len; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg, fn_off, fn_seg; - uint16 ret_ax, ret_dx, act_lo, act_hi; - - drive = tests_get_current_drive(); - get_drive_info((uint8)drive, &connid, &dhandle, &flags); - - memset(hdr, 0, sizeof(hdr)); - hdr[0] = 6; - hdr[1] = 0; - hdr[2] = 0; - tests_put_word_lh(hdr + 3, 0x0006); - tests_put_dword_lh(hdr + 5, 0x00000004UL); - - path_len = tests_build_novell_handle_path(path, dhandle, 0, 0, 1, - "LOGIN.EXE", 0, 0); - - memset(rep0, 0, sizeof(rep0)); - memset(rep1, 0, sizeof(rep1)); - memset(out, 0, sizeof(out)); - - fprintf(stdout, "\nTEST NWREQ87C32RAW label=%u conn32=%04X:%04X\n", - label, connHi, connLo); - fprintf(stdout, "drive=%c: connid=%u dhandle=%u flags=%02X path_len=%u\n", - 'A' + drive, connid, dhandle, flags, path_len); - tests_dump_bytes("HDR :", hdr, 9); - tests_dump_bytes("PATH:", path, path_len > 48 ? 48 : path_len); - - C32_NCP87_Raw_Probe(connLo, connHi, - hdr, 9, - path, path_len, - rep0, 0x4d, - rep1, 0x100, - 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); - act_lo = tests_get_word_lh(out + 18); - act_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 COMPAT=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X actual=%04X:%04X\n", - ret_dx, ret_ax, act_hi, act_lo); - tests_dump_bytes("OUT :", out, 22); - tests_dump_bytes("REP0:", rep0, 64); - tests_dump_bytes("REP1:", rep1, 64); - - return(0); -} - -static int tests_nwreq87c32raw(int argc, char *argv[]) -{ - UI lo = 0; - UI hi = 0; - - if (argc > 2) - lo = (UI)atoi(argv[2]); - if (argc > 3) - hi = (UI)atoi(argv[3]); - - return tests_nwreq87c32raw_one(lo, hi, 0); -} - -static int tests_nwreq87c32matrix(void) -{ - UI vals[6]; - int i; - - vals[0] = 0; - vals[1] = 1; - vals[2] = 2; - vals[3] = 3; - vals[4] = 0x31; - vals[5] = 0x3130; - - fprintf(stdout, "TEST NWREQ87C32MATRIX paged\n"); - tests_wait_key(); - - for (i = 0; i < 6; i++) { - tests_nwreq87c32raw_one(vals[i], 0, (UI)i); - if (i != 5) - tests_wait_key(); - } - return(0); -} @@ -1432,504 +1327,16 @@ static void tests_dump_vlm_regs(char *title, uint8 *r) tests_get_reg_word(r, 14)); } -static int tests_c32primref(void) -{ - uint8 regs[16]; - int rc; - UI primref; - memset(regs, 0, sizeof(regs)); - /* - * DeveloperNet dgtprmci.o / NWCGETPRIMCONNREF: - * - * regblk.AX = 1 - * NWCVLMREQ(flags=0, regblk, p1=4, p2=43h, p3=0) - * if rc==0: - * primaryConnRef = regblk.CX - */ - tests_set_reg_word(regs, 8, 1); /* AX */ - fprintf(stdout, "TEST C32PRIMREF / NWCGETPRIMCONNREF VLM step\n"); - tests_dump_vlm_regs("REG in :", regs); - fprintf(stdout, "Call NWCVLMREQ flags=0 p1=0004 p2=0043 p3=0000\n"); - rc = Net_Call_NWCVLMREQ(0, regs, 0x0004, 0x0043, 0); - fprintf(stdout, "NWCVLMREQ rc=%04X\n", rc); - tests_dump_vlm_regs("REG out:", regs); - primref = tests_get_reg_word(regs, 12); /* CX */ - fprintf(stdout, "primary connection reference candidate CX=%04X decimal=%u\n", - primref, primref); - if (rc == 0 && primref != 0) { - fprintf(stdout, "\nNext test:\n"); - fprintf(stdout, " TESTS NWREQ87C32RAW %u 0\n", primref); - } - return(0); -} -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); -} - - -static int tests_c32mapconn_value(UI conn16, UI label) -{ - uint8 regs[16]; - uint8 reply[128]; - int rc; - - memset(regs, 0, sizeof(regs)); - memset(reply, 0, sizeof(reply)); - - /* - * Exact first half of __C32MapConn16To32: - * reg.CX = conn16 - * reg.ES:DI = reply buffer - * NWCVLMREQ(flags=2, regblk, p1=0Dh, p2=10h, p3=0) - */ - tests_set_reg_word(regs, 4, FP_OFF(reply)); /* DI */ - tests_set_reg_word(regs, 6, FP_SEG(reply)); /* ES */ - tests_set_reg_word(regs, 12, conn16); /* CX */ - - fprintf(stdout, "\nC32MAPCONN value=%u label=%u\n", conn16, label); - tests_dump_vlm_regs("REG in :", regs); - fprintf(stdout, "Call NWCVLMREQ flags=2 p1=000D p2=0010 p3=0000\n"); - - rc = Net_Call_NWCVLMREQ(2, regs, 0x000D, 0x0010, 0); - - fprintf(stdout, "NWCVLMREQ rc=%04X\n", rc); - tests_dump_vlm_regs("REG out:", regs); - tests_dump_bytes("REPLY:", reply, 64); - fprintf(stdout, "REPLY text: %s\n", reply); - - return rc; -} - -static int tests_c32mapconnone(int argc, char *argv[]) -{ - UI val; - - if (argc < 3) { - fprintf(stdout, "Usage: TESTS C32MAPCONNONE value\n"); - return(1); - } - - val = (UI)atoi(argv[2]); - return tests_c32mapconn_value(val, val); -} - - -static int tests_c32scanfirst(void) -{ - uint8 out[32]; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg; - uint16 fn_off, fn_seg, ret_ax, ret_dx, ref_lo, ref_hi; - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST C32SCANFIRST\n"); - fprintf(stdout, "Minimal CONNScanInfo enumerate probe, no scan criterion\n"); - - C32_ScanFirst_Probe(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); - ref_lo = tests_get_word_lh(out + 18); - ref_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 CONNScanInfo=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X scan/result=%04X:%04X\n", - ret_dx, ret_ax, ref_hi, ref_lo); - tests_dump_bytes("OUT:", out, 22); - - if (ret_ax == 0 && ret_dx == 0 && (ref_lo || ref_hi)) { - fprintf(stdout, "\nTry next:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", ref_lo, ref_hi); - } - - return(0); -} - - -static int tests_c32scanrefs2(void) -{ - uint8 out[40]; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg; - uint16 fn_off, fn_seg, ret_ax, ret_dx; - uint16 cref_lo, cref_hi, rinfo_lo, rinfo_hi, iter_lo, iter_hi; - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST C32SCANREFS2\n"); - fprintf(stdout, "CONNScanInfo exact-shape probe, return NWCC_INFO_CONN_REF\n"); - - C32_ScanRefs2_Probe(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); - cref_lo = tests_get_word_lh(out + 18); - cref_hi = tests_get_word_lh(out + 20); - rinfo_lo = tests_get_word_lh(out + 22); - rinfo_hi = tests_get_word_lh(out + 24); - iter_lo = tests_get_word_lh(out + 26); - iter_hi = tests_get_word_lh(out + 28); - - 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 CONNScanInfo=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X\n", ret_dx, ret_ax); - fprintf(stdout, "connRef=%04X:%04X returnInfo=%04X:%04X iterator=%04X:%04X\n", - cref_hi, cref_lo, rinfo_hi, rinfo_lo, iter_hi, iter_lo); - tests_dump_bytes("OUT:", out, 30); - - if (ret_ax == 0 && ret_dx == 0 && (cref_lo || cref_hi)) { - fprintf(stdout, "\nTry next:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", cref_lo, cref_hi); - } - - return(0); -} - - -static int tests_c32scaniter(int argc, char *argv[]) -{ - uint8 out[40]; - UI iterLo = 0; - UI iterHi = 0; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg; - uint16 fn_off, fn_seg, ret_ax, ret_dx; - uint16 cref_lo, cref_hi, rinfo_lo, rinfo_hi, out_iter_lo, out_iter_hi; - - if (argc > 2) - iterLo = (UI)atoi(argv[2]); - if (argc > 3) - iterHi = (UI)atoi(argv[3]); - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST C32SCANITER initial iterator=%04X:%04X\n", iterHi, iterLo); - fprintf(stdout, "CONNScanInfo return NWCC_INFO_CONN_REF with caller-supplied iterator\n"); - - C32_ScanRefsIter_Probe(iterLo, iterHi, 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); - cref_lo = tests_get_word_lh(out + 18); - cref_hi = tests_get_word_lh(out + 20); - rinfo_lo = tests_get_word_lh(out + 22); - rinfo_hi = tests_get_word_lh(out + 24); - out_iter_lo = tests_get_word_lh(out + 26); - out_iter_hi = tests_get_word_lh(out + 28); - - 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 CONNScanInfo=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X\n", ret_dx, ret_ax); - fprintf(stdout, "connRef=%04X:%04X returnInfo=%04X:%04X iterator=%04X:%04X\n", - cref_hi, cref_lo, rinfo_hi, rinfo_lo, out_iter_hi, out_iter_lo); - tests_dump_bytes("OUT:", out, 30); - - if (ret_ax == 0 && ret_dx == 0) { - fprintf(stdout, "\nNext iterator test:\n"); - fprintf(stdout, " TESTS C32SCANITER %u %u\n", out_iter_lo, out_iter_hi); - if ((cref_lo || cref_hi) && !(cref_lo == 0xFFFE && cref_hi == 0xFFFF)) { - fprintf(stdout, "Try open:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", cref_lo, cref_hi); - } - } - - return(0); -} - - -static int tests_c32mapfull(void) -{ - uint8 out[32]; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg; - uint16 fn_off, fn_seg, ret_ax, ret_dx; - uint16 result_lo, result_hi, cref_lo, cref_hi; - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST C32MAPFULL\n"); - fprintf(stdout, "Exact-ish w95mconn __C32MapConn16To32 scan step for server MARS\n"); - - C32_MapFull_Probe(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); - result_lo = tests_get_word_lh(out + 18); - result_hi = tests_get_word_lh(out + 20); - cref_lo = tests_get_word_lh(out + 22); - cref_hi = tests_get_word_lh(out + 24); - - 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 CONNScanInfo=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X\n", ret_dx, ret_ax); - fprintf(stdout, "resultRef=%04X:%04X connRefLocal=%04X:%04X\n", - result_hi, result_lo, cref_hi, cref_lo); - tests_dump_bytes("OUT:", out, 26); - - if (ret_ax == 0 && ret_dx == 0 && (result_lo || result_hi)) { - fprintf(stdout, "\nTry next:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", result_lo, result_hi); - fprintf(stdout, " TESTS NWREQ87C32RAW %u %u\n", result_lo, result_hi); - } - - return(0); -} - - -static int tests_c32mapfull2(void) -{ - uint8 out[32]; - uint16 load_ax, res_off, res_seg, tramp_off, tramp_seg; - uint16 fn_off, fn_seg, ret_ax, ret_dx; - uint16 result_lo, result_hi, cref_lo, cref_hi; - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST C32MAPFULL2\n"); - fprintf(stdout, "w95mconn scan step with exact L115 flag pair 0000:0001\n"); - - C32_MapFull2_Probe(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); - result_lo = tests_get_word_lh(out + 18); - result_hi = tests_get_word_lh(out + 20); - cref_lo = tests_get_word_lh(out + 22); - cref_hi = tests_get_word_lh(out + 24); - - 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 CONNScanInfo=%04X:%04X\n", fn_seg, fn_off); - fprintf(stdout, "Return DX:AX=%04X:%04X\n", ret_dx, ret_ax); - fprintf(stdout, "resultRef=%04X:%04X connRefLocal=%04X:%04X\n", - result_hi, result_lo, cref_hi, cref_lo); - tests_dump_bytes("OUT:", out, 26); - - if (ret_ax == 0 && ret_dx == 0 && (result_lo || result_hi)) { - fprintf(stdout, "\nTry next:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", result_lo, result_hi); - fprintf(stdout, " TESTS NWREQ87C32RAW %u %u\n", result_lo, result_hi); - } - - return(0); -} - - -static int tests_c32mapvar_one(UI specLen, UI flag) -{ - uint8 out[32]; - uint16 ret_ax, ret_dx, result_lo, result_hi, cref_lo, cref_hi; - - memset(out, 0, sizeof(out)); - - fprintf(stdout, "\nTEST C32MAPVAR specLen=%u flag=%u\n", specLen, flag); - C32_MapVar_Probe(specLen, flag, out); - - ret_ax = tests_get_word_lh(out + 14); - ret_dx = tests_get_word_lh(out + 16); - result_lo = tests_get_word_lh(out + 18); - result_hi = tests_get_word_lh(out + 20); - cref_lo = tests_get_word_lh(out + 22); - cref_hi = tests_get_word_lh(out + 24); - - fprintf(stdout, "Return DX:AX=%04X:%04X resultRef=%04X:%04X connRefLocal=%04X:%04X\n", - ret_dx, ret_ax, result_hi, result_lo, cref_hi, cref_lo); - tests_dump_bytes("OUT:", out, 26); - - if (ret_ax == 0 && ret_dx == 0 && (cref_lo || cref_hi) && - !(cref_lo == 0xFFFE && cref_hi == 0xFFFF)) { - fprintf(stdout, "Try open with connRefLocal:\n"); - fprintf(stdout, " TESTS C32OPENREF %u %u\n", cref_lo, cref_hi); - } - - return(0); -} - -static int tests_c32mapvar(int argc, char *argv[]) -{ - UI specLen = 5; - UI flag = 0; - - if (argc > 2) - specLen = (UI)atoi(argv[2]); - if (argc > 3) - flag = (UI)atoi(argv[3]); - - return tests_c32mapvar_one(specLen, flag); -} - -static int tests_c32mapvarmatrix(void) -{ - fprintf(stdout, "TEST C32MAPVARMATRIX paged\n"); - fprintf(stdout, "Trying SPECTDATA length/flag variants for server MARS.\n"); - tests_wait_key(); - - tests_c32mapvar_one(5, 0); - tests_wait_key(); - - tests_c32mapvar_one(5, 1); - tests_wait_key(); - - tests_c32mapvar_one(0x31, 0); - tests_wait_key(); - - tests_c32mapvar_one(0x31, 1); - - return(0); -} - - -static int tests_nwreq87c32raw5(int argc, char *argv[]) -{ - UI lo = 0; - UI hi = 0; - uint8 connid = 0; - uint8 dhandle = 0; - uint8 flags = 0; - int drive; - uint8 hdr[16]; - uint8 path[0x140]; - uint8 rep0[0x60]; - uint8 rep1[0x110]; - uint8 out[32]; - UI path_len; - uint16 ret_ax, ret_dx, act_lo, act_hi; - - if (argc > 2) - lo = (UI)atoi(argv[2]); - if (argc > 3) - hi = (UI)atoi(argv[3]); - - drive = tests_get_current_drive(); - get_drive_info((uint8)drive, &connid, &dhandle, &flags); - - memset(hdr, 0, sizeof(hdr)); - hdr[0] = 6; - hdr[1] = 0; - hdr[2] = 0; - tests_put_word_lh(hdr + 3, 0x0006); - tests_put_dword_lh(hdr + 5, 0x00000004UL); - - path_len = tests_build_novell_handle_path(path, dhandle, 0, 0, 1, - "LOGIN.EXE", 0, 0); - - memset(rep0, 0, sizeof(rep0)); - memset(rep1, 0, sizeof(rep1)); - memset(out, 0, sizeof(out)); - - fprintf(stdout, "TEST NWREQ87C32RAW5 conn32=%04X:%04X\n", hi, lo); - fprintf(stdout, "d32wrap-compatible 5-slot/0x28 frag tables\n"); - fprintf(stdout, "drive=%c: connid=%u dhandle=%u flags=%02X path_len=%u\n", - 'A' + drive, connid, dhandle, flags, path_len); - - C32_NCP87_Raw5_Probe(lo, hi, - hdr, 9, - path, path_len, - rep0, 0x4d, - rep1, 0x100, - out); - - ret_ax = tests_get_word_lh(out + 14); - ret_dx = tests_get_word_lh(out + 16); - act_lo = tests_get_word_lh(out + 18); - act_hi = tests_get_word_lh(out + 20); - - fprintf(stdout, "Return DX:AX=%04X:%04X actual=%04X:%04X\n", - ret_dx, ret_ax, act_hi, act_lo); - tests_dump_bytes("OUT :", out, 22); - tests_dump_bytes("REP0:", rep0, 64); - tests_dump_bytes("REP1:", rep1, 64); - - return(0); -} static unsigned long tests_get_dword_be_local(uint8 *p) @@ -2064,42 +1471,31 @@ static int tests_ncp87c32auto(void) } -static int tests_ncp87c32attr(void) -{ - uint8 connid = 0; - uint8 dhandle = 0; - uint8 flags = 0; - int drive; +/* + * Reusable Client32 helpers for FLAG and future DOS tools. + * + * These are intentionally not test/probe commands. They wrap the verified + * Client32 sequence: + * + * C32_MapVar_Probe(4,0) -> connRefLocal FFFF:FFFE + * C32_OpenRef_Probe(connRefLocal) -> Client32 handle, e.g. 0101:0001 + * C32_NCP87_Raw5_Probe(handle) -> NCP87/S6 + */ +static int c32_get_ncp_handle(uint16 *handle_lo, uint16 *handle_hi) +{ uint8 mapout[32]; uint8 openout[32]; - uint8 rawout[32]; - uint16 map_ret_ax, map_ret_dx; uint16 cref_lo, cref_hi; uint16 open_ret_ax, open_ret_dx; - uint16 handle_lo, handle_hi; - uint16 raw_ret_ax, raw_ret_dx; - uint16 actual_lo, actual_hi; - uint8 hdr[16]; - uint8 path[0x140]; - uint8 rep0[0x60]; - uint8 rep1[0x110]; - UI path_len; - unsigned long attr; + if (!handle_lo || !handle_hi) + return(1); - drive = tests_get_current_drive(); - get_drive_info((uint8)drive, &connid, &dhandle, &flags); + *handle_lo = 0; + *handle_hi = 0; - /* - * Client32 path confirmed: - * C32_MapVar_Probe(4,0) -> connRefLocal FFFF:FFFE - * C32_OpenRef_Probe(connRefLocal) -> handle 0101:0001 - * C32_NCP87_Raw5_Probe(handle) -> NCP87/S6 works - * - * No VLM mapper/debug calls are used here. - */ memset(mapout, 0, sizeof(mapout)); C32_MapVar_Probe(4, 0, mapout); @@ -2108,34 +1504,65 @@ static int tests_ncp87c32attr(void) cref_lo = tests_get_word_lh(mapout + 22); cref_hi = tests_get_word_lh(mapout + 24); - if (map_ret_ax != 0 || map_ret_dx != 0 || (cref_lo == 0 && cref_hi == 0)) { - fprintf(stdout, "C32 attr: map failed rc=%04X:%04X\n", map_ret_dx, map_ret_ax); - return(1); - } + if (map_ret_ax != 0 || map_ret_dx != 0 || (cref_lo == 0 && cref_hi == 0)) + return(2); memset(openout, 0, sizeof(openout)); C32_OpenRef_Probe(cref_lo, cref_hi, openout); open_ret_ax = tests_get_word_lh(openout + 14); open_ret_dx = tests_get_word_lh(openout + 16); - handle_lo = tests_get_word_lh(openout + 18); - handle_hi = tests_get_word_lh(openout + 20); + *handle_lo = tests_get_word_lh(openout + 18); + *handle_hi = tests_get_word_lh(openout + 20); - if (open_ret_ax != 0 || open_ret_dx != 0 || (handle_lo == 0 && handle_hi == 0)) { - fprintf(stdout, "C32 attr: openref failed rc=%04X:%04X ref=%04X:%04X\n", - open_ret_dx, open_ret_ax, cref_hi, cref_lo); + if (open_ret_ax != 0 || open_ret_dx != 0 || (*handle_lo == 0 && *handle_hi == 0)) + return(3); + + return(0); +} + +static int c32_ncp87_obtain_rim_attributes(const char *name, + uint16 dir_handle, + unsigned long *attr_out, + uint16 *actual_out, + uint16 *handle_lo_out, + uint16 *handle_hi_out) +{ + uint16 handle_lo, handle_hi; + uint8 hdr[16]; + uint8 path[0x140]; + uint8 rep0[0x60]; + uint8 rep1[0x110]; + uint8 rawout[32]; + UI path_len; + uint16 raw_ret_ax, raw_ret_dx; + uint16 actual_lo; + int rc; + + if (!name || !attr_out) return(1); - } + + *attr_out = 0; + if (actual_out) + *actual_out = 0; + if (handle_lo_out) + *handle_lo_out = 0; + if (handle_hi_out) + *handle_hi_out = 0; + + rc = c32_get_ncp_handle(&handle_lo, &handle_hi); + if (rc) + return(10 + rc); memset(hdr, 0, sizeof(hdr)); hdr[0] = 6; hdr[1] = 0; hdr[2] = 0; - tests_put_word_lh(hdr + 3, 0x0006); /* subfunction 6 */ + tests_put_word_lh(hdr + 3, 0x0006); /* NCP87 subfunction 6 */ tests_put_dword_lh(hdr + 5, 0x00000004UL); /* RIM_ATTRIBUTES */ - path_len = tests_build_novell_handle_path(path, dhandle, 0, 0, 1, - "LOGIN.EXE", 0, 0); + path_len = tests_build_novell_handle_path(path, dir_handle, 0, 0, 1, + (char *)name, 0, 0); memset(rep0, 0, sizeof(rep0)); memset(rep1, 0, sizeof(rep1)); @@ -2151,23 +1578,58 @@ static int tests_ncp87c32attr(void) raw_ret_ax = tests_get_word_lh(rawout + 14); raw_ret_dx = tests_get_word_lh(rawout + 16); actual_lo = tests_get_word_lh(rawout + 18); - actual_hi = tests_get_word_lh(rawout + 20); - if (raw_ret_ax != 0 || raw_ret_dx != 0) { - fprintf(stdout, "C32 attr: ncp87 failed rc=%04X:%04X actual=%04X:%04X\n", - raw_ret_dx, raw_ret_ax, actual_hi, actual_lo); - return(1); - } + if (raw_ret_ax != 0 || raw_ret_dx != 0) + return(20); - /* In the verified reply, RIM_ATTRIBUTES is the little-endian dword at REP0+4. */ - attr = tests_get_dword_le_local(rep0 + 4); + /* + * Verified reply layout for RIM_ATTRIBUTES: + * REP0+4 little-endian dword = DOS attributes + * Example LOGIN.EXE: 20h archive. + */ + *attr_out = tests_get_dword_le_local(rep0 + 4); - fprintf(stdout, "NCP87C32ATTR LOGIN.EXE attr=%02lX handle=%04X:%04X actual=%04X\n", - attr & 0xffUL, handle_hi, handle_lo, actual_lo); + if (actual_out) + *actual_out = actual_lo; + if (handle_lo_out) + *handle_lo_out = handle_lo; + if (handle_hi_out) + *handle_hi_out = handle_hi; return(0); } +static int tests_ncp87c32attr(void) +{ + uint8 connid = 0; + uint8 dhandle = 0; + uint8 flags = 0; + int drive; + unsigned long attr; + uint16 actual; + uint16 handle_lo; + uint16 handle_hi; + int rc; + + drive = tests_get_current_drive(); + get_drive_info((uint8)drive, &connid, &dhandle, &flags); + + rc = c32_ncp87_obtain_rim_attributes("LOGIN.EXE", + (uint16)dhandle, + &attr, + &actual, + &handle_lo, + &handle_hi); + if (rc) { + fprintf(stdout, "NCP87C32ATTR failed rc=%d\n", rc); + return(rc); + } + + fprintf(stdout, "NCP87C32ATTR LOGIN.EXE attr=%02lX handle=%04X:%04X actual=%04X\n", + attr & 0xffUL, handle_hi, handle_lo, actual); + + return(0); +} int func_tests(int argc, char *argv[], int mode) { @@ -2195,10 +1657,6 @@ int func_tests(int argc, char *argv[], int mode) if (tests_same_arg(argv[1], "NCP87C32AUTO")) return tests_ncp87c32auto(); - - if (tests_same_arg(argv[1], "NWREQ87C32RAW5")) - return tests_nwreq87c32raw5(argc, argv); - if (tests_same_arg(argv[1], "NWREQ87C32MATRIX")) return tests_nwreq87c32matrix();