Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically access the 'netsh' API via Windows SDK

Is there a way to access the netsh API (e.g. WIN32 API, WDK)?
For example, I'm trying to get mobile broadband information via netsh with the following command:

netsh mbn show interfaces  

So I guess the real question is: what's the actual programmatic representation of netsh mbn show interfaces using Windows SDK methods?

An example in pseudo code:

MBN_DEVICE mbn;
GetMbnDev(&mbn);
char* Name = mbn.Name;
char* IMEI = mbn.IMEI;
char* DeviceId = mbn.DevId;
float signal = mbn.Signal;

What APIs (Win32/.Net/.Core) would I have to call to get the same result in a data structure like with the command above?

like image 226
Binary01 Avatar asked Oct 26 '25 15:10

Binary01


1 Answers

Some of the Microsoft tools use internal/undocumented APIs to perform their work so cloning them often require a bit of investigation.

The first step is to download Dependency Walker and take a look at the functions netsh imports. In this case it does not look like it imports a lot of network related stuff (on my Windows 8 machine) but it does import CoCreateInstance and GetProcAddress so you can set a breakpoint on both in your debugger, this should allow you to determine the functions/interfaces it ultimately ends up calling.

Even before you get that far you can simply Google "Mobile Broadband API", it should lead you to this MSDN page. You should take a look at those interfaces and see if they provide the information you are after...

like image 88
Anders Avatar answered Oct 29 '25 07:10

Anders



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!