Win32s NetBIOS Programming Considerations

Last reviewed: November 2, 1995
Article ID: Q104314
The information in this article applies to:
  • Microsoft Win32s version 1.0, 1.1, and 1.2

This article addresses common questions about NetBIOS programming under Win32s.

Under Windows 3.1, you normally do not issue a RESET command due to the common name table. When running your Win32-based application under Windows version 3.1, you may issue a NetBIOS RESET command. Win32s keeps an internal list of all the names added in the Windows 3.1 NetBIOS name table by Win32 processes. A RESET on Win32s mimics the RESET on Windows NT by clearing the names added by that process from the system-wide name table. As a result, issuing a RESET command as the first NetBIOS command (as required by Windows NT) on Win32s does not clear out all of the names.

The Windows 3.1 NetBIOS VxD expects memory allocated for the NetBIOS Control Block (NCB) and the data buffer (NCB.ncb_buffer) to be allocated with GlobalAlloc(). The VxD will lock the specified memory page. If a Win32- based application running under Win32s passes the Netbios() command virtual memory, Netbios() will return error 0x22, indicating that there are too many commands outstanding. On Win32s, each piece of memory that might pass through Netbios() must be allocated with GlobalAlloc().

The Win32s NetBIOS thunk layer translates the ncb_buffer pointer in the NCB itself. The translation back from a 16-bit to original 32-bit pointer is done for asynchronous commands in the Win32s private post routine. A problem might occur when an application checks the NCB and finds that the netbios() command is completed (ncb_retcode == NRC_GOODRET), but the Win32s post routine was not called yet. The ncb_buffer has not been translated back. The best way to avoid problems is to define and use a post routine. At that point you are sure that the netbios() command is completed and the NCB is correct. If you don't want to use a post routine, you should make sure that the command was completed by checking the the ncb_retcode field and verifying that the ncb_buffer pointer is a 32-bit pointer.

There is also no need to page lock the NetBIOS post routine code under Win32s. NetBIOS post routine on Win32s is not called at interrupt time. The post routine is called in the context of the process, and therefore there is no need to page lock the post routine code.


Additional reference words: 1.00 1.10 1.20
KBCategory: kbprg
KBSubcategory: W32s


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.