Should I use SetupApi or CfgMgr32 in 2022? - libusb

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.

Related

Can I use a USB pen drive with libusbdotnet

I have just started on libusbdotnet. I have downloaded the sample code from http://libusbdotnet.sourceforge.net/V2/Index.html.
I am using a JetFlash 4GB Flash drive (a libusb-win32 filter driver was added for this drive).
The ShowInfo code works perfectly, and I can see my device info with two endpoints. Following is the device info from pastebin
http://pastebin.com/2Jdph6bY
However, the ReadOnly sample code does not work.
http://pastebin.com/hNZaEt8N
My code is almost same as that from the libsubdotnet website. I have only changed the endpoint that UsbEndpointReader uses. I have changed it from Ep01 to Ep02, because I read that the first endpoint is a control endpoint used for configuration, access control and similar stuff.
UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep02);
I always get the message "No more bytes!".
I thought that this is because of the absence of data, so I used the ReadWrite sample code.
http://pastebin.com/NiN5w9Jt
But here I also get "No more bytes!" message.
Interestly, the line
ec = writer.Write(Encoding.Default.GetBytes(cmdLine), 2000, out bytesWritten);
executes without errors.
Can pen drives be used for read write operations? Or is something wrong with the code?
A USB thumb drive implements the USB mass storage device class, which is a subset of SCSI. The specification is here.
You're not going to get anything sensible by just reading from an endpoint - you have to send the appropriate commands to get any response.
You have not chosen an easy device class to begin your exploration of USB - you may be better starting with something easier - a HID class device, perhaps (Mouse/Keyboard) though Windows does have enhanced security around mice and keyboards which may prevent you installing a filter.
If you meddle with the filesystem on the USB stick while it's mounted as a drive by Windows, you'll almost certainly run into cache-consistency problems, unless you're extremely careful about what kind of access you allow Windows to do.

Advices to correctly manage threads

I have a big Domino Web application, which uses numerous calls "OpenAgent" to Java agents to retrieve data via ajax. The application is used by several users.
What are the main parameters that you advise me to check and adjust on server, in order to avoid HTTP hang or performance issues?
There is quite an overhead in calling to an agent be it LotusScript or Java. So if your AJAX calls are quite frequent you are going to overload the server easily.
Domino comes with a test tool for this called Server.Load. It will allow you to emulate a heavy load server and you will see how your code performs under that. Another I've used is Rational Functional Tester (trial version), but there are probably free ones out there as well (eg. JMeter/LoadRunner. I haven't used).
So if you are doing infrequent complex actions that may take time and don't need a quick response to the user, I would recommend to continue with the web agent.
If it is simple look up calls I would recommend to use alternative methods. For example XPages has the AJAX functionality built into it with scaling in mind. Or if it is JSON data then look into Domino Data Service, or Domino URL commands.

Is It Posssible To Access AwesomePlayer Info And Error Messages From An Application?

I'm an untrained, newbie code hacker playing with a homebrew MediaPlayer for streaming live internet audio. An old fashioned "radio" if you will. I'm using OnInfo, OnError and OnBuffferingUpdate info to fill a "status" textView box on my player, but I see so much more detailed info in logcat from the AwesomePlayer engine. Is it possible to access the AwesomePlayer info directly from the application?
From an application perspective (assuming the application is written in JAVA), MediaPlayer is the abstraction for all player engines. There are multiple player engines such as StagefrightPlayer which internally uses AwesomePlayer and NuPlayer to name a couple.
The information made available on listeners i.e. onInfoListener, onBufferingUpdateListener, onErrorListener originates from AwesomePlayer which is translated into a generic message and is communicated through the listeners. This information is deemed to be sufficient for any application developer to develop their code around the same.
AwesomePlayer logs are more from debug perspective and helps to understand the underlying implementation of the engine. I feel that this information is good to know and understand, but not sure if this is essential for application development.
To summarize, AwesomePlayer information is actually communicated through the listeners which are generic in nature and rest of the logcat information is more for debug or understanding purposes. Currently, there is no scheme to get this information unless the developer explicitly customizes the AOSP distribution.

Working around Windows Store App Sandbox

I want to create a Metro app for learning and personal consumption purposes to do all sorts of low-level device API work, such as tracking power consumption, enumerating processes and calculating CPU usage per process, etc... Unfortunately, these Desktop APIs are forbidden from Metro applications.
My first attempt to work around this was to create a non-windows store C++ library, which has the WINAPI_FAMILY variable set correctly in order to use functions like QueryIdleProcessorCycleTime() and CallNtPowerInformation(). Unfortunately, it is this latter function call that fails when I pass it the ProcessorInformation token in the first argument, with a STATUS_ACCESS_DENIED return code.
Interestingly, CallNtPowerInformation() works just fine when given SystemBatteryState as the first argument, so I imagine there is some kind of access privilege I am missing when running as a Metro app for getting processor info. I read that Metro apps are run with quite restricted privileges, and so I am looking for a way to increase these privileges to allow my API calls to go through properly. To test that it is the process privileges and not a coding error, I used the C++ library from a console application, and everything worked just fine.
I would really like to not have to create a second, desktop background process that does all the dirty work and communicates the results to the Metro app over a socket. I realize this can work, but I would rather have everything housed in the same process space.

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.