pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Simpify kernel2userland string transfer, document Borland Turbo C+misc, 2025-09-20
Posted by Anonymous on Sat 20th Sep 2025 17:00
raw | new post

  1. From ad4aa3a0cf0eb01a72b9505e3369b3b9b9a0387f Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Sat, 20 Sep 2025 17:46:29 +0200
  4. Subject: [PATCH 1/2] daemon,sys: Simplify UTF-8 string transfer kernel to
  5.  userland daemon
  6.  
  7. Simplify UTF-8 string transfer kernel to userland daemon.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. daemon/util.c         | 11 ++++++++++-
  12.  sys/nfs41sys_driver.c | 45 ++++++++++++++++++++++++-------------------
  13.  sys/nfs41sys_util.h   |  3 ++-
  14.  3 files changed, 37 insertions(+), 22 deletions(-)
  15.  
  16. diff --git a/daemon/util.c b/daemon/util.c
  17. index 4788d85..37660d2 100644
  18. --- a/daemon/util.c
  19. +++ b/daemon/util.c
  20. @@ -82,6 +82,7 @@ int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
  21.  {
  22.      int status;
  23.      USHORT len;
  24. +    const char *name;
  25.      
  26.      status = safe_read(pos, remaining, &len, sizeof(USHORT));
  27.      if (status) goto out;
  28. @@ -89,9 +90,17 @@ int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
  29.          status = ERROR_BUFFER_OVERFLOW;
  30.          goto out;
  31.      }
  32. -    *out_name = (const char*)*pos;
  33. +
  34. +    name = (const char *)*pos;
  35. +
  36. +    EASSERT_MSG((name[len-1] == '\0'),
  37. +        ("name='%s', (len-1)=%d, expected 0x00, got 0x%x\n",
  38. +        name, (int)(len-1), (int)name[len-1]));
  39. +
  40. +    *out_name = name;
  41.      *pos += len;
  42.      *remaining -= len;
  43. +
  44.  out:
  45.      return status;
  46.  }
  47. diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
  48. index efd2d94..33b4a40 100644
  49. --- a/sys/nfs41sys_driver.c
  50. +++ b/sys/nfs41sys_driver.c
  51. @@ -180,42 +180,47 @@ NTSTATUS marshall_unicode_as_utf8(
  52.      IN OUT unsigned char **pos,
  53.      IN PCUNICODE_STRING str)
  54.  {
  55. -    ANSI_STRING ansi;
  56.      ULONG ActualCount;
  57.      NTSTATUS status;
  58. +    PCHAR out_str;
  59. +
  60. +    out_str = ((PCHAR)*pos) + sizeof(USHORT);
  61.  
  62.      if (str->Length == 0) {
  63.          status = STATUS_SUCCESS;
  64.          ActualCount = 0;
  65. -        ansi.MaximumLength = 1;
  66.          goto out_copy;
  67.      }
  68.  
  69. -    /* query the number of bytes required for the utf8 encoding */
  70. -    status = RtlUnicodeToUTF8N(NULL, 0xffff,
  71. +    /*
  72. +     * Convert the string directly into the upcall buffer
  73. +     * (We assume that the caller has used |length_as_utf8()|
  74. +     * to make sure the buffer is big enougth)
  75. +     */
  76. +    status = RtlUnicodeToUTF8N(out_str, 0xFFFF,
  77.          &ActualCount, str->Buffer, str->Length);
  78.      if (status) {
  79. -        print_error("RtlUnicodeToUTF8N('%wZ') failed with 0x%08X\n",
  80. -            str, status);
  81. +        print_error("marshall_unicode_as_utf8: "
  82. +            "RtlUnicodeToUTF8N(str='%wZ',str->Length=%ld) failed with 0x%lx\n",
  83. +            str, (long)str->Length, (long)status);
  84.          goto out;
  85.      }
  86.  
  87. -    /* convert the string directly into the upcall buffer */
  88. -    ansi.Buffer = (PCHAR)*pos + sizeof(ansi.MaximumLength);
  89. -    ansi.MaximumLength = (USHORT)ActualCount + sizeof(UNICODE_NULL);
  90. -    status = RtlUnicodeToUTF8N(ansi.Buffer, ansi.MaximumLength,
  91. -        &ActualCount, str->Buffer, str->Length);
  92. -    if (status) {
  93. -        print_error("RtlUnicodeToUTF8N(%hu, '%wZ', %hu) failed with 0x%08X\n",
  94. -            ansi.MaximumLength, str, str->Length, status);
  95. -        goto out;
  96. -    }
  97.  
  98.  out_copy:
  99. -    RtlCopyMemory(*pos, &ansi.MaximumLength, sizeof(ansi.MaximumLength));
  100. -    *pos += sizeof(ansi.MaximumLength);
  101. -    (*pos)[ActualCount] = '\0';
  102. -    *pos += ansi.MaximumLength;
  103. +    /* Terminate buffer */
  104. +    out_str[ActualCount] = '\0';
  105. +
  106. +    /*
  107. +     * Copy size field
  108. +     * (string itself was already converted&&written by |RtlUnicodeToUTF8N()|)
  109. +     */
  110. +    USHORT out_str_len = (USHORT)(ActualCount+1L);
  111. +    RtlCopyMemory(*pos, &out_str_len, sizeof(out_str_len));
  112. +    *pos += sizeof(out_str_len);
  113. +
  114. +    /* Add string size to buffer pointer */
  115. +    *pos += out_str_len;
  116.  out:
  117.      return status;
  118.  }
  119. diff --git a/sys/nfs41sys_util.h b/sys/nfs41sys_util.h
  120. index f0f6791..c1ade4c 100644
  121. --- a/sys/nfs41sys_util.h
  122. +++ b/sys/nfs41sys_util.h
  123. @@ -40,7 +40,8 @@ static INLINE ULONG length_as_utf8(
  124.  {
  125.      ULONG ActualCount = 0;
  126.      RtlUnicodeToUTF8N(NULL, 0xffff, &ActualCount, str->Buffer, str->Length);
  127. -    return sizeof(str->MaximumLength) + ActualCount + sizeof(UNICODE_NULL);
  128. +    /* Length of length field + string length + '\0'*/
  129. +    return sizeof(USHORT) + ActualCount + 1;
  130.  }
  131.  
  132.  /* Prototypes */
  133. --
  134. 2.51.0
  135.  
  136. From 92bdef5254e8408e288557a10a64b4985ea428af Mon Sep 17 00:00:00 2001
  137. From: Roland Mainz <roland.mainz@nrubsig.org>
  138. Date: Sat, 20 Sep 2025 17:53:57 +0200
  139. Subject: [PATCH 2/2] README.md,docs: Document "Borland Turbo C" as supported
  140.  in NTVDM
  141.  
  142. Document "Borland Turbo C" as supported in NTVDM
  143.  
  144. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  145. ---
  146. README.md       | 6 ++++--
  147.  docs/README.xml | 1 +
  148.  2 files changed, 5 insertions(+), 2 deletions(-)
  149.  
  150. diff --git a/README.md b/README.md
  151. index 4a05d7e..69478be 100644
  152. --- a/README.md
  153. +++ b/README.md
  154. @@ -246,8 +246,10 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11 & Windows Server
  155.  
  156.    - Windows 16bit DOS and Windows 3.x applications via [NT Virtual DOS
  157.      Machine](https://learn.microsoft.com/en-us/windows/compatibility/ntvdm-and-16-bit-app-support)
  158. -    (requires case-insensitive filesystem), e.g. [Total Commander for
  159. -    Windows 3.x](https://www.ghisler.com/wcmd16.htm),
  160. +    (requires case-insensitive filesystem), e.g. [Borland Turbo C
  161. +    compiler](https://web.archive.org/web/20040401174842/http://bdn.borland.com/article/0,1410,20841,00.html),
  162. +    [Total Commander for Windows
  163. +    3.x](https://www.ghisler.com/wcmd16.htm),
  164.      [DOSNIX](http://www.retroarchive.org/garbo/pc/unix/dosnx23b.zip),
  165.      [DOS 16bit
  166.      zip](https://github.com/DankRank/ftp.info-zip.org/raw/refs/heads/master/ftp.info-zip.org/pub/infozip/msdos/zip232x.zip),
  167. diff --git a/docs/README.xml b/docs/README.xml
  168. index 02ddeb4..4f66314 100644
  169. --- a/docs/README.xml
  170. +++ b/docs/README.xml
  171. @@ -280,6 +280,7 @@
  172.                <para>Windows 16bit DOS and Windows 3.x applications via
  173.                  <link xl:href="https://learn.microsoft.com/en-us/windows/compatibility/ntvdm-and-16-bit-app-support">NT Virtual DOS Machine</link> (requires case-insensitive filesystem), e.g.
  174.                  <simplelist type="inline">
  175. +                  <member><link xl:href="https://web.archive.org/web/20040401174842/http://bdn.borland.com/article/0,1410,20841,00.html">Borland Turbo C compiler</link></member>
  176.                    <member><link xl:href="https://www.ghisler.com/wcmd16.htm">Total Commander for Windows 3.x</link></member>
  177.                    <member><link xl:href="http://www.retroarchive.org/garbo/pc/unix/dosnx23b.zip">DOSNIX</link></member>
  178.                    <member><link xl:href="https://github.com/DankRank/ftp.info-zip.org/raw/refs/heads/master/ftp.info-zip.org/pub/infozip/msdos/zip232x.zip">DOS 16bit zip</link></member>
  179. --
  180. 2.51.0

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at