in reply to WIN32: How to power-up a device?

What software are you running that changes the apparent MAC address? The one that's permanently assigned to the interface is, well, permanent.

Unless you're assigning something else at the network stack level (in which case there should be the new MAC address in that software's configuration somewhere), then you only need to get the MAC address for a given network interface on the local machine once.

I'd suggest something like c:\mymac.dat or c:\windows\system32\mymac.dat as a place to store the MAC address for when you're offline. That is, unless you're trusting a Perl program to do something sneaky like lock a user out if they install the software on another machine or change Ethernet cards. ;-)

Replies are listed 'Best First'.
Re^2: WIN32: How to power-up a device?
by cmv (Chaplain) on Sep 26, 2007 at 18:48 UTC
    My software doesn't change the apparent MAC address, it wants to simply record the permanent MAC address of the machine it is running on when first started up.

    The current problem is if a laptop user first runs the software when their power management has shut down the ethernet hardware, it cannot go ahead and record it.

    Once it gets the address, it stores it in a file, similar to what you suggest.

    One easy solution would be to popup "Please connect your laptop to the network", but even I would get uncomfortable thinking it was going to transmit data somewhere, or something sneaky like that.

      Well if you have access to change the hardware profile that's being used, that's a good bet.

      You could also ask for a power connection instead of a network connection if you're worried about people thinking something is being submitted somewhere.

      You can also get MAC addresses from the registry (at least if it's been changed by the system admin -- I'm not sure if there's any record of it there when deaulting to the physical MAC).

      In short, I'm not sure you have a Perl problem so much as a Windows problem.

        Asking for power could be a gamble, if they've reset the default power profile to go ahead and power down unused devices even when off of battery power. Connecting to the network is a sure thing.

        I explored getting the MAC addresses from the registry, but that can be easily spoofed. Getting the permanent MAC address via IOCTL directly from the driver is harder to mess with. At least I think...

        I kind-of agree with you. It's more of a windows problem that I'm trying to solve via some perl code. I'm hoping I can de-select the "allow power saving" in the device driver for the user temporarily, get the MAC address, then set it back again.