Getting an Old 32-bit Windows App to Use the Right Network Adapter
I figured out how to get an old 32-bit Windows program to pick the correct network adapter/IP.
The app was using the old Win32 API:
GetAdaptersInfo(...)
Situation
I needed the program to use a local virtual adapter, so I created a:
Microsoft KM-TEST Loopback Adapter
Then I assigned it the IP address I wanted.
Simple, right? Naturally, Windows and ancient application logic disagreed, because apparently one problem was not enough.
The Problem
The app would only use the loopback adapter if my other Ethernet adapters were disabled.
That was not an option, because those adapters needed to stay enabled.
After digging through the decompiled code, it looked like the app was calling GetAdaptersInfo() and then blindly using the first returned adapter’s IPv4 address.
No real validation.
No skipping bad addresses.
No “is this the right adapter?” logic.
So if an enabled-but-unplugged Ethernet adapter came first, the app grabbed that adapter and returned:
0.0.0.0
Truly elite software craftsmanship.
Things I Tried
I tested the old binding-order registry area:
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage
Specifically:
Bind
Export
Route
I also tried:
- Interface metrics
- Adapter names / alphabetical order
- Hyper-V adapter tests
- Various enable / disable combinations
None of those fixed it.
What Finally Worked
On this machine, the app’s adapter order lined up with the numbered network adapter class keys here:
HKLM\SYSTEM\CurrentControlSet\Control\Class\
{4D36E972-E325-11CE-BFC1-08002BE10318}
The fix was:
- Uninstall the Ethernet adapter that had the lowest class number and was being picked first.
- Install the Microsoft KM-TEST Loopback Adapter so it took that lower-numbered slot.
- Reinstall the original Ethernet adapter afterward so it came back later in the order.
After that, the old app picked the loopback adapter first and used the correct IP.
Final Result
The program now grabs the KM-TEST Loopback Adapter first and uses the IP I actually wanted.
Only took about 8 hours to fix something that could have been avoided if the original devs had added the wildly advanced logic of:
if IP == 0.0.0.0, skip it