NETUI and Disabling Prompts for Credentials by the Redirector

One of the questions that I've seen asked, time and time again, is "How do you disable the username and password dialog that is generated by such and such Microsoft provided component?"

 The answer to all great questions is that it usually depends.  In particular it depends on how this said Microsoft component generates its UI.  In the specific case of this blog posting, I'm going to talk about one of these components and one of the methods you could use to disable various UI.

 The Redirector component on Windows CE almost always refers to the client-side Server Message Block (SMB) network filesystem.  This component can display a number of UI forms, Message Boxes, Username and Password Dialogs, etc.  It puts up these UI forms by making calls into another component called NetUI, which is used by many Microsoft provided components to display UI.  The NetUI module is provided as public sample code with Platform Builder and it is available for the user to modify.

 The following MSDN article discusses how to modify/make changes to NetUI.

 When the Redirector component displays a Username and Password Dialog in Windows CE 6.0 it does so by calling CallGetUsernamePassword.   This method is defined in netui.h.

 If you wanted to fail the Username and Password dialog silently in the Redirector component then you would want to set the return value of CallGetUsernamePassword to FALSE.  CallGetUsernamePassword is defined in $(_WINCEROOT)\public\common\oak\inc\netui.h.  If you investigate netui.h you can see that there is logic that handles displaying UI from both Usermode and Kernel.  What is important to know is that you must change the final calls that both Usermode and Kernel mode will eventually call.  Reading the code in netui.h one can find dependencies on netui_kernel.h and netui_user.h. 

Looking to netui.h and netui_user.h we can see:

CallGetUsernamePassword calls CallUGetUsernamePassword.

CallUGetUsernamePassword calls GetUsernamePassword.

GetUsernamePassword is found in getuser.c in the netui directory: 


Here you can modify GetUsernamePassword to return FALSE, effectively removing the username and password dialog from being displayed.

Hopefully this illustration helps you disable or improve the default UI that comes with other Microsoft components.