NDIS OID query from user mode - ioctl

Writing NDIS 5.1 driver for WinXPe. In addition to normal NDIS send/receive functionality, driver also needs to make some discrete IO values available to user processes, presumably via a set of custom OIDs. Info on web indicates IOCTL_NDISUIO_OPEN_DEVICE then IOCTL_NDISUIO_QUERY_OID_VALUE would be perfect, but these functions appear to be limited to Windows CE and not WinXPe. CreateFile to "\\.\\NdisUio" succeeds, but IOCTL_NDISUIO_OPEN_DEVICE fails with code (50) "the request is not supported". Additionally, I had to cheat just to get nuiouser.h into my project because it's not available with the regular SDK. WMI does not appear to help, because WMI appears to only support "standard" parameters, not custom parameters.
If necessary, I believe I can implement IoCreateDevice and IoCreateSymbolicLink in my NDIS driver, then making custom IOCTLs available to user processes. But I'd rather go the OID route if possible.
Can a WinXPe user process perform an NDIS OID query?

MOF files integrated with the driver SYS permit linkage into WMI system and thus access to OID data.

Related

Should I use SetupApi or CfgMgr32 in 2022?

I have a lot of experience with libusb, libudev, and SetupAPI for writing Windows drivers, but it's totally unclear to me what CfgMgr32 offers over SetupAPI for Windows USB applications. Microsoft outlines how one would port from SetupAPI to CfgMgr32, but, I don't really understand the trade-offs or if there are gotchas.
Specifically, most of the time my work involves communicating to bespoke devices with isochronous endpoints, devices with bulk endpoints and HID devices. Is there any clear reason to do one or the other?
One reason is stated at the top of the Microsoft page describing how to port from SetupApi to CfgMgr32 found here https://learn.microsoft.com/en-us/windows-hardware/drivers/install/porting-from-setupapi-to-cfgmgr32.
Excerpt with pertinent part in bold:
This topic provides code examples that show how to port code that uses Setupapi.dll functionality to use Cfgmgr32.dll instead. Porting your code allows you to run your code on the Universal Windows Platform (UWP), which does not support SetupApi. A subset of CfgMgr32 is supported on UWP, specifically functionality exposed through the api-ms-win-devices-config-l1-1-0.dll API set (Windows 8 and later) or the api-ms-win-devices-config-l1-1-1.dll API set (Windows 8.1 and later). In Windows 10 and later, simply link to onecore.lib.
Another reason is that the CfgMgr API provides a specific return status code for operations whereas SetupApi returns a value to indicate success/error but a further call is required to GetLastError to get the specific error code of the last operation.

Old ABAP code still active for PyRFC even after TR was imported. Why?

I changed an ABAP RFC module in a SAP system X and transported the changes the Y. Now when I call the RFC SAP stills executes the old code.
I compared both versions from X and Y with a diff tool and found no differences, so it looks like the changes where transported. Is there a special step needed to activate my ABAP RFC code?
I use PyRFC as a client library.
We had the same problem with one of our RFC FMs. Reason was that the connection remained open once it was established. In this case, the binaries are not refreshed in the RFC context. Simply restart the connection and everything should work as desired.
This is a known issue: https://github.com/SAP/PyRFC/issues/89
Quoting the issue:
After the Python script ended, the connection should be automatically
closed and SAP NW RFC SDK initialised. Here what happens under the
hub.
Python interpreters and PyRFC instances share the same SAP NW RFC SDK
lib instance and when the remote enabled function module (RFM) is
called for the 1st time, the RFM metadata are cached inside SAP NW RFC
SDK. When the 2nd call of the same RFM requested from Python/PyRFC,
the SAP NW RFC SDK returns the metadata from cache, rather than
reading again from ABAP system, saving one Python/ABAP roundtrip and
some performance, especially in case of complex RFMs. If the RFM
signature changed in the meantime, the cached RFM metadata are not
changed and Python "sees" the old ABAP code.
I hope a developer friendly solution will get used for the future.
There is no need for activating anything. It should be fine as you transport it.
You can try these;
Transport everything again.(Including other tasks of the same request)
Check the destination field in your call to see if you are calling the correct system
Clear the buffer => TCode /$sync

SAPJco invoking BAPI_MATERIAL_DISPLAY

I was trying to invoke BAPI_MATERIAL_DISPLAY functional module from SAP JCO, This is how i pass my input parameter.
function.getImportParameterList().setValue("MATERIAL", "10");
From my program output i got
The material 10 does not exist or is not activated.
If I execute BAPI_MATERIAL_DISPLAY using SAP logon, iam getting the entry. Using debugger I found that,
My input is going as 00000000000010. And so returning response.
Dunno, how to handle this in a proper way in SAPJCO.
I had directly passed the value 00000000000010 from SAPJCo and this time i got an error,
com.sap.conn.jco.JCoException: (104) JCO_ERROR_SYSTEM_FAILURE: Screen output without connection to user.
Hope SAP is opening a popup. Let me know how to solve both the issues in SAPJCO
Field Material has a conversion exit routine. See also its domain MATNR in the DDIC.
These conversion exits are always called automatically by SE37 but not when the Remote Function Module is called directly - like here from outside from a a JCo program.
So if the BAPI expects to get certain parameters in their SAP internal representation format (I don't know if this is the case here), then you have to do this data transformation on your own beforehand, either by doing this purely within an own routine at Java side, or by calling the appropriate conversion routines at ABAP side via RFC.
For more details on this I recommend to study SAP note 206068.
Regarding your second question with the error message "Screen output without connection to user", I guess that this BAPI expects to have a connection to an SAP GUI for displaying the selected data. With a remote function call you don't have a SAP GUI connection by default, but you can attach a SAP GUI to your RFC connection with JCo, namely by specifying the additional logon parameter jco.client.use_sapgui=1. For this to work, an SAP GUI frontend (either for Windows or for Java) also needs to be installed on your host where JCo is running, of course.

VB.NET - Set windows to control/manage wireless over third-party clients

Within VB.NET, trying to find an easy way to in a sense check the check-box "Use Windows to configure my Wireless Network Settings". This is an option that forces windows to use your wireless over third-party programs that may try to steal control. I am aware this requires to have WZC enabled within services and that's something that can be easily accomplished one way or another.
I doubt or rather cannot find a proper registry value or API call to check or initiate such a task.
I would use a registry-recorder to record the changes when manually changing the value, then its a piece of cake to implement the register change in code.
There are plenty programs that can be used to see what changes has been done in the registry, here are one free: http://www.kephyr.com/systemsherlocklite/index.phtml, but google may find more or better variants out there.
With this tool, create a registry dump:
systemsherlock.exe -dump d1.dat -regdirs HKEY_ROOT
Do the change in the wireless network settings
Do a new dump of the registry:
systemsherlock.exe -dump d2.dat -regdirs HKEY_ROOT
And last, compare them and see what has changed:
systemsherlock.exe -compare d1.dat d2.dat

Using the RDP control to login to a Vista machine that requires Network Level Authentication

I'm trying to use the mstscax.dll (Microsoft Remote Desktop Control) to login to a Vista machine that requires Network Level Authentication.
I've played around with all the methods in IMsRdpClientNonScriptable4, IMsRdpClientAdvancedSettings4 and IMsRdpClient6. There are a slew of functions that appear that the might enable this.
EnableCredSspSupport
PromptForCredentials
PromptForCredsOnClient
NegotiateSecurityLayer
Unfortunately the MSDN documentation is pratacily useless and I can find no examples for any of these on the web. I know that it's possible because a product called "Royal TS" can connect this way.
One hint is that both "Royal TS" and Vista's Remote Desktop create a authoriztion prompt that looks like the one from CredUIPromptForWindowsCredentials, this makes me belive that i might be able to use a function like that to get the credential and then possibly use PublisherCertificateChain to tell RDP about it.
Any ideas would be helpful.
So if other people find this:
All that needs to be done is EnableCredSspSupport=true, the problem I had was that I was loading the mstscax.dll manually and the version I was using supported the IMsRdpClientNonScriptable4 interface but simply didn't work. If you just load the control normally just setting EnableCredSspSupport=true works fine.
This property maybe help you
RDPControl.AdvancedSettings8.EnableCredSspSupport = true;
In addition, It also depend on your OS support Network Level Authentication or not.
Reference (http://technet.microsoft.com/en-us/library/ff393716(v=ws.10).aspx)
I've never tried to do what you're doing but I suggest you take a look at the following article:
Multi Remote Desktop Client .NET
The projects uses mstscax.dll.