From cb893d618cd884b61e96e626c9406cbeac718683 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 23 May 2026 22:25:49 +0200 Subject: [PATCH] dostools flag --- c32ncp.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/c32ncp.c b/c32ncp.c index a53e0c3..128e3ea 100644 --- a/c32ncp.c +++ b/c32ncp.c @@ -29,22 +29,72 @@ static uint32 c32_get_dword_lh(uint8 *p) ((uint32)p[3] << 24)); } -static int c32_build_handle_path(uint8 *p, uint8 dhandle, const char *name) +static UI c32_build_handle_path(uint8 *buf, uint8 dhandle, + uint16 dirbase, uint8 style, + int count, + const char *c1, const char *c2, const char *c3) { - int nlen; + uint8 *p; + int l; + UI used; - nlen = strlen(name); - if (nlen > 255) - nlen = 255; + /* + * DeveloperNet/ncpdos16 path structure used by NCP87/S6 through + * Client32 COMPATNcpRequestReply. + * + * This is the exact shape verified by TESTS NCP87C32AUTO: + * 00 02 00 00 00 00 01 09 4C 4F 47 49 4E 2E 45 58 45 + * + * Meaning: + * word[1] = short dir handle + * word[3] = dir base + * byte[5] = dirstyle + * byte[6] = component count + * then len/name components + * + * The old/simple struct used by the INT 21h F257 fallback is not accepted + * by this Client32 path. + */ + memset(buf, 0, 0x140); - *p++ = dhandle; - c32_put_dword_lh(p, 0L); p += 4; - *p++ = 0; /* dirstyle = short dir handle */ - *p++ = 1; /* one path component */ - *p++ = (uint8)nlen; - memcpy(p, name, nlen); + if (dhandle) { + c32_put_word_lh(buf + 1, (uint16)dhandle); + c32_put_word_lh(buf + 3, dirbase); + buf[5] = style; + } else { + buf[5] = 0xff; + } - return(1 + 4 + 1 + 1 + 1 + nlen); + p = buf + 6; + *p++ = (uint8)count; + + if (count > 0 && c1) { + l = strlen(c1); + if (l > 255) l = 255; + *p++ = (uint8)l; + memcpy(p, c1, l); + p += l; + } + + if (count > 1 && c2) { + l = strlen(c2); + if (l > 255) l = 255; + *p++ = (uint8)l; + memcpy(p, c2, l); + p += l; + } + + if (count > 2 && c3) { + l = strlen(c3); + if (l > 255) l = 255; + *p++ = (uint8)l; + memcpy(p, c3, l); + p += l; + } + + used = (UI)(p - buf); + c32_put_word_lh(buf + 0x13c, used); + return(used); } /* @@ -133,7 +183,8 @@ int c32_ncp87_obtain_rim_attributes(const char *name, c32_put_word_lh(hdr + 3, 0x0006); /* SA_ALL */ c32_put_dword_lh(hdr + 5, 0x00000004UL); /* RIM_ATTRIBUTES */ - path_len = c32_build_handle_path(path, (uint8)dir_handle, name); + path_len = c32_build_handle_path(path, (uint8)dir_handle, 0, 0, 1, + name, NULL, NULL); memset(rep0, 0, sizeof(rep0)); memset(rep1, 0, sizeof(rep1));