Discover and enable/disable devices on Win8? - wmi

I'm writing a metro app for Windows 8 (C# 5) to act as a power control app allowing the user to enable and disable various devices the computer will likely have. For now, I'm just thinking bluetooth and wireless network adapter. Eventually I'll add other devices, but one step at a time.
The main aspects I'm worried about is reliably finding devices, enabling and disabling them, and querying their state (is the device already enabled?). I need to be able to do any of these on a variety of machines with a variety of different devices, including multiple NIC or Bluetooth hardware setups.
I've looked into devcon on Win7, but I'm worried about reliably discovering the devices. If I grab the wrong devices, who knows what I'll be disabling, not to mention it won't disable what I intend to disable. Also I haven't tried it on Win8 yet and it may not be a portable app, I don't want people to install it and then my app.
WMI is powerful but always a bit intimidating to wander around in without a little guidance. If that's my best bet, I would appreciate some resources.
Command line or .Net library is what I'm hoping for, but I haven't tried this kind of stuff before so I'm open to any other alternatives. Also, any foresight into working with other devices like cellular network cards or devices I haven't thought of yet would be great.

Much of what you want (eg Bluetooth APIs) are indeed sandboxed away from Metro apps. There are some substitutes in the Windows namespace, though whether they will meet your needs I don't know. Take a look at http://msdn.microsoft.com/en-us/library/windows/apps/hh464945 which has links to the suggested alternatives for working with devices.
Specifically the Windows.Devices.Enumeration namespace says it's about finding devices. However as I read the page it seems like it's more about discovering and less about controlling. I wouldn't be surprised to find you can't control them. But that's where I'd start digging.

Related

Using a STM upsd3200 series mcu for the first time

I've received a dk 3200 kit recently. I know it's old but I would like to start using it to have more of a challenge than just arduino. It came with the board, an st flashlink FL-101B and some cables. I do not have the install disc, but I found the software for psd soft express online. It doesn't work with current windows 7 64bit. If I could use my arduino to program it, that would be great! Or maybe just do it through USB or the parallel ports? I've read that st provides a stm32 library used to help make code. If that works for my mcu, I'll use that.
Thanks
ST is a company that loves to re-organize their website and break links, but a data sheet for a part of what seems to be the same family as on your board is available from a toolchain vendor at:
http://www.keil.com/dd/docs/datashts/st/upsd321x_ds.pdf
On page 118 this seems to indicate that programs can be loaded using JTAG In System Configuration commands, which may be somewhat standardized though quick searching isn't producing a lot of leads. A reference is also made to ST's AN1153 which would be worth trying to locate a copy of, however it's not entirely clear if that will say anything about the programming, or if it only covers the additional two optional signals which have been added for hardware acceleration of the interface.
In theory, if you can find sufficient information about this device (looking at related devices may provide clues) then you should be able to craft a programming from an Arduino or anything else that can be adapted to twiddle bits at the appropriate voltage/threshold levels.
In practice, you may be better off trying to find an old Windows XP box, or even trying to run that software on a virtual/emulated environment and trap the I/O access either to proxy or to figure out what it is doing and reverse engineer your own programmer.
But unless you have a large installed base of boards using these chips, or particular need some unusual feature of them (I thought I saw something about a built-in CPLD?) it's really not going to be worth the effort.

Creating a File System "Driver"

I'm looking to create a "driver" I guess for a custom file system on physical disk for Windows. I don't exactly know the best way to explain it, but the device already has proper drivers and everything like that for Windows to communicate with it, but what I want to happen is for the user to be able to plug the device in to their PC, have it show up in My Computer, and give them full support for browsing the device.
I realize it's probably a little scary thinking about someone who doesn't know the basics of doing something like this even asking the question, but I already have classes and everything constructed for reading it within my own app... I just want everything to be more centralized and without more work from the end user. Does anyone have a good guide for creating a project like this?
The closest thing I know of to what I understand from your description is an installable file system, like the Ext2 installable file system that allows Windows computers to work with
Linux originating ext2 (and to a certain degree ext3) filesystems.
Maybe that can serve as a starting point for your investigations.
As an alternative approach there's the Shell extension which is a lot less complicated than the IFS. The now-defunct GMail shell extension used that approach, and even though it's become nonfunctional due to changes in GMail, it can still serve as inspiration.
Your options are:
Create a kernel mode file system driver. 9-12 months of work for experienced developer.
Use a framework and do everything in user mode. A couple of weeks of work to get the prototype working. The only drawback of this approach is that it's slower, than kernel-mode driver. You can play with Dokan mentioned above, or you can use our Callback File System for commercial-grade development.
I think you need to look through the Windows Driver Kit documentation (and related subjects) to figure out exactly what you're looking to create.
If you're intending to rely on the drivers that already exist, i.e. you don't need to actually execute your code in kernel land to communicate with it, I would recommend you take a look at FUSE for windows Dokan
If you indeed need to run in kernel space, and communicate directly with the hardware, you probably want to download windows DDK (driver development kit). Keep in mind that drivers for communicating with a block device and filesystems are separated, and it sound like you're talking about the filesystem itself. I believe that anything you run in kernel space will not have access to the c++ runtime, which means you can only use a subset of c++ for kernel drivers.

If I want to develop Layered Service Provider to support all Windows OS's, what problems should I expect?

I want to develop simple HTTP filter (transparent proxy).
I want it to support all versions of Windows including XP and above.
From the folks that have experience with this, what problems should iIexpect when installing the service?
There are some that I could quickly think of on top of my head:
-You should be aware that you have to cover all browsers or at least major ones like IE, firefox, chrome, safari and opera. The ways they use Winsock are different, eg overlapped vs. non-overlapped IO.
-Installation/Uninstallation is challenging as it's very easy to mess up and end up losing internet connection.
-It is even more challenging if there is other LSPs already installed. Your LSP might interfere other LSPs and vice versa.
-It's very common that Windows PCs pre-installed with anti-virus. Some of them provides proxy-like internet filter as well, eg. Avast and Kaspersky. As being winsock applications, anti-viruses are also loaded with and controlled by your LSP. Once your LSP breaks these antivirus and their net filters, expect no network connection for any other apps on your computer.
I could list more but that could cast away your hunger to dive into this challenge. Start doing it first and you will get know it better along the way. Good luck!

An example of an embedded project for a single person

I've been trying to wrap my head around embedded. Since I will be self-taught in this specific niche, I realize it will be harder to get a job in the field, so I'm hoping to add a completed project to my resume to prove to potential employers that I've done it and can do it again for them.
Can someone suggest a project that I can undertake as a single person and actually be able to finish, but at the same time not too simple that it doesn't prove anything? Something reasonable that I can aim for.
If you can substantiate your example with a project you worked on yourself, and mention how many people were involved, and how long it took to finish it, that would also help me gauge the difficulty of projects I see in general and rule out the ones that are probably too big for my capacity. It's very difficult to gauge the amount of work a project needs from my position.
You should take a look at the arduino. To quote their site:
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
There is a really handy playground listing a bunch of personal projects on the arduino, any one of which might fulfil your need to do some embedded development. You can also trawl around the internet (e.g. instructables) to find many other interesting arduino applications -- I particularly like the one building a fancy control system for an espresso machine, and, of course, there is the mandatory fart detecting chair that tweets its findings.
Being an arduino experimenter myself, I can attest to the simplicity and power of this device -- and the great fun you will have playing with it. If you want to get started quickly, I can recommend buying the starter kit from the very helpful people at oomlout.
Are you looking specifically at embedded software development, or are you interested in circuit board design as well?
If it's just software, then I would suggest getting hold of an ARM development board (Possibly the Philips LPC range - sparkfun have some nice ones) that you can program via a bootloader over usb and start hacking. Get one with a display and an ethernet port and you can build up to making some sort of network attached sensor (temperature, water level, object counter, etc). Start out little (turn on a LED from a button) and work your way up.
If you're also into the electronics side of things, I'd suggest something like an MP3 (or WAV) player and maybe stick to the AVR or PIC 8bit microcontrollers (AVR is used on the Arduino) as these are a little easier to deal with than ARM. Here you could start with a usb powered device that streams wav files from a PC serial port out to a pair of headphones, and build up to a battery powered board, feeding data to an MP3 decoder IC from an SD card.
Some things you may want to learn & demonstrate:
Understands the bounds of working with limited resources, including memory management (dynamic and/or static); resource management (locks, semaphores, mutex); multiple tasks (interrupts); and appropriate data structures
Ability to interface with other devices/ICs over various interconnects (analog & digital IO, serial bus (RS232, I2C, SPI))
Ability to sanely structure a program and segment the various modules without producing 'spaghetti' code
Ability to use source and integrate 3rd party libraries where appropriate (think FAT filesystem, or TCP/IP stack)
Misc Tips:
read and understand the datasheets (yes all of them)
code and test on the desktop where possible, but understand that there are differences and bugs will still creep through (this is where it helps to be using a tool-chain that is common with the desktop - GCC is good, but the tools are generally CLI)
use assert a lot - you can flash the line number of a failed assert using a single LED - this is invaluable
Most of all have fun - it still makes me smile when you first get a new component working (display, motor, sensor). Embedded makes the world go round :)

Restrict functionality to a certain computer

I have a program that is using a configuration file.
I would like to tie the configuration file to the PC, so copying the file on another PC with the same configuration won't work.
I know that Windows Activation Mecanism is monitoring hardware to detect changes and that it can tolerates some minor changes to the hardware.
Is there any library that can help me doing that?
My other option is to use WMI to get Hardware configuration and to program my own tolerance mecanism.
Thanks a lot,
Nicolas
Microsoft Software Licensing and Protection Services has functionality to bind a license to hardware. It might be worth looking into. Here's a blog posting that might be of interest to you as well.
If you wish to restrict the use of data to a particular PC you'll have to implement this yourself, or find a third-party solution that can do this. There are no general Windows API's that offer this functionality.
You'll need to define what you currently call a "machine."
If I replace the CPU, memory, and hard drive, is it still the same computer? Network adaptor, video card?
What defines a machine?
There are many, many licensing libraries out there to do this for you, but almost all are for pay (because, ostensibly, you'd only ever want to protect commercial software this way). Check out what RSA, Verisign, and even microsoft have to offer. The windows API does not expose this, ostensibly to prevent hacking.
Alternately, do it yourself. It's not hard to do, the difficult part is defining what you believe a machine to be.
If you decide to track 5 things (HD, Network card, Video card, motherboard, memory sticks) and you allow 3 changes before requiring a new license, then users can duplicate the hard drive, take out two of the above, put them in a new machine, replace them with new parts in the old machine and run your program on the two separate PCs.
So it does require some thought.
-Adam
If the machine has a network card you could always check its mac address. This is supposed to be unique and checking it as part of the program's startup routine should guarantee that it only works in one machine at a time... even if you remove the network card and put it another machine it will then only work in that machine. This will prevent network card upgrades though.
Maybe you could just keep something in the registry? Like the last modification timestamp for this file - if there's no entry in the registry or the timestamps do not match then fall back to defaults - would that work? (there's more then one way to skin a cat ;) )