The MASM Forum

Projects => MASM32 => Topic started by: dycaly on August 21, 2014, 11:04:04 AM

Title: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 11:04:04 AM
I had searched on the Internel, but I found nothing. How can I do with it, could you help me?
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: hutch-- on August 21, 2014, 11:07:06 AM
It does not appear to be a Microsoft API library, do you know who wrote the original library that the include file prototypes ?
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 11:09:07 AM
I have found wlanapi.h wlanapi.lib wlanapi.dll in VS2013
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 11:13:08 AM
It does not appear to be a Microsoft API library, do you know who wrote the original library that the include file prototypes ?
masm32 also doesn't have wlanapi.inc, why they don't develop it for us 
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: hutch-- on August 21, 2014, 11:25:20 AM
I have pulled a function list from the Win7 DLL of the same name but I don't have the library to get the parameter count. Please post the LIB file and I will see what I can do. I gather it will also need to have structures and equates which I don't have any data for.
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 11:35:47 AM
I have pulled a function list from the Win7 DLL of the same name but I don't have the library to get the parameter count. Please post the LIB file and I will see what I can do. I gather it will also need to have structures and equates which I don't have any data for.
This is the file. Thank you
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: jj2007 on August 21, 2014, 11:58:20 AM
The WlanAPI.dll is present on XP SP3. This code works in principle but my wlan is not working, so I get error messages. Warning: While testing an early version, I got a BSOD and spontaneous reboot - this snippet seems to be safe, though.

include \masm32\MasmBasic\MasmBasic.inc            ; download (http://masm32.com/board/index.php?topic=94.0)
  SetGlobals dwNegotiatedVersion, hClientHandle    ; see MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms706759%28v=vs.85%29.aspx)
  Init
  SetGlobals
  Dll "WlanApi"
  Declare WlanOpenHandle, 4         ; 4 paras expected
  Declare WlanCloseHandle, 2        ; 2 paras expected
  Print Str$("WlanOpenHandle returns\t%i\n", WlanOpenHandle(1, 0, addr dwNegotiatedVersion, addr hClientHandle))
  Print Str$("The version is\t%i\n", dwNegotiatedVersion)
  Print Str$("The client handle is\t%i\n", hClientHandle)
  Inkey Str$("Closing yields %i", WlanCloseHandle(hClientHandle, 0))
  Exit
end start


Output (on Win XP SP3 without WLAN):

WlanOpenHandle returns  1062 (="service not started")
The version is  0
The client handle is    0
Closing yields 87


P.S.: After launching "Windows Zero Configuration Service" (who invented that name? Ballmer far away from the peak? (http://xkcd.com/323/)), the snippet's output is as follows:

WlanOpenHandle returns  0
The version is  1
The client handle is    1
Closing yields 0
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 12:09:46 PM
The WlanAPI.dll is present on XP SP3. This code works in principle but my wlan is not working, so I get error messages. Warning: While testing an early version, I got a BSOD and spontaneous reboot - this snippet seems to be safe, though.

include \masm32\MasmBasic\MasmBasic.inc            ; download (http://masm32.com/board/index.php?topic=94.0)
  SetGlobals dwNegotiatedVersion, hClientHandle    ; see MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms706759%28v=vs.85%29.aspx)
  Init
  SetGlobals
  Dll "WlanApi"
  Declare WlanOpenHandle, 4         ; 4 paras expected
  Declare WlanCloseHandle, 2        ; 2 paras expected
  Print Str$("WlanOpenHandle returns\t%i\n", WlanOpenHandle(1, 0, addr dwNegotiatedVersion, addr hClientHandle))
  Print Str$("The version is\t%i\n", dwNegotiatedVersion)
  Print Str$("The client handle is\t%i\n", hClientHandle)
  Inkey Str$("Closing yields %i", WlanCloseHandle(hClientHandle, 0))
  Exit
end start


Output (on Win XP SP3 without WLAN):

WlanOpenHandle returns  1062
The version is  0
The client handle is    0
Closing yields 87

Are you using DLL directly in asm? But I got known that the effection of  .inc file in asm was the as .h file in C/C++, so I guess there is none of DLL's business
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: jj2007 on August 21, 2014, 12:24:26 PM
Are you using DLL directly in asm?

Yes. Under the hood of Dll & Declare (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1017), LoadLibrary and GetProcAddress do the work (successfully, see P.S. above)

Having a proper .inc file will make the job easier, though. The question is if it's worth the effort - don't forget this is a volunteer site, and Hutch doesn't get paid for it. You can bring him a sixpack, though :biggrin:
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 12:47:40 PM
Are you using DLL directly in asm?

Yes. Under the hood of Dll & Declare (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1017), LoadLibrary and GetProcAddress do the work (successfully, see P.S. above)

Having a proper .inc file will make the job easier, though. The question is if it's worth the effort - don't forget this is a volunteer site, and Hutch doesn't get paid for it. You can bring him a sixpack, though :biggrin:
I am in a quandary´╝îbecause I'm a new learner, so I haven't saw the code that you have written before, what I learn just like
"
         invoke   WlanOpenHandle,2,NULL,NULL,hWlanHandle
         invoke   WlanEnumInterfaces,hWlanHandle,NULL,addr @stWlanList
         invoke   WlanScan,hWlanHandle,addr @stWlanList.InterfaceInfo.InterfaceGuid,NULL,NULL,NULL
         invoke   WlanGetAvailableNetworkList,hWlanHandle,addr @stWlanList.InterfaceInfo.InterfaceGuid,1,NULL,addr   @stWlanAvalibe
"
Especially the "Declare" in your code

Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 12:51:05 PM
Are you using DLL directly in asm?

Yes. Under the hood of Dll & Declare (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1017), LoadLibrary and GetProcAddress do the work (successfully, see P.S. above)

Having a proper .inc file will make the job easier, though. The question is if it's worth the effort - don't forget this is a volunteer site, and Hutch doesn't get paid for it. You can bring him a sixpack, though :biggrin:
I'm curious about why there is no such .inc file. Does it means that there is no one write software about wlan using asm?
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dedndave on August 21, 2014, 12:59:28 PM
you might check Yves' "ready-to-use" includes - or Japheth's WinInc/WinIncEx
otherwise - this one wouldn't be that hard to convert, compared to some i've seen   :biggrin:

http://masm32.com/board/index.php?topic=563.0 (http://masm32.com/board/index.php?topic=563.0)
http://www.japheth.de/WinInc.html (http://www.japheth.de/WinInc.html)
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: jj2007 on August 21, 2014, 01:03:03 PM
         invoke   WlanOpenHandle,2,NULL,NULL,hWlanHandle
...
Especially the "Declare" in your code

Declare is a macro that you can use in a similar way as in Visual Basic. It uses internally an invoke GetProcAddress().

Once you have the inc and lib files, you can indeed use the invoke syntax.
However, hWlanHandle does not seem a correct parameter - WlanOpenHandle expects the address of a handle, as in my example above.
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 01:15:25 PM
         invoke   WlanOpenHandle,2,NULL,NULL,hWlanHandle
...
Especially the "Declare" in your code

Declare is a macro that you can use in a similar way as in Visual Basic. It uses internally an invoke GetProcAddress().

Once you have the inc and lib files, you can indeed use the invoke syntax.
However, hWlanHandle does not seem a correct parameter - WlanOpenHandle expects the address of a handle, as in my example above.
yes, I made a mistake.  :t, 
Once you have the inc and lib files, you can indeed use the invoke syntax.
Does it means that if I don't have inc file, I can use  the syntax that you written in your code and it also work?
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 21, 2014, 01:17:56 PM
you might check Yves' "ready-to-use" includes - or Japheth's WinInc/WinIncEx
otherwise - this one wouldn't be that hard to convert, compared to some i've seen   :biggrin:

http://masm32.com/board/index.php?topic=563.0 (http://masm32.com/board/index.php?topic=563.0)
http://www.japheth.de/WinInc.html (http://www.japheth.de/WinInc.html)
It is a good idea, I think I should have a try. Thanks
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: jj2007 on August 21, 2014, 01:28:41 PM
Does it means that if I don't have inc file, I can use  the syntax that you written in your code and it also work?

The Declare (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1018) syntax works if you add MasmBasic to your Masm32 installation (link (http://masm32.com/board/index.php?topic=94.0)).

In addition, you need JWasm (http://www.japheth.de/JWasm.html): just put JWasm.exe in your \Masm32\bin folder. JWasm is a perfect clone of MASM, and much more up-to-date than the ML.exe version 6.14 that comes bundled with Masm32. It's a must if you want to work with more recent CPUs and SSE instructions.
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: hutch-- on August 22, 2014, 07:41:44 PM
I fed the C .H files through some of the tools I use for converting headers and have a rough and incomplete set of equates and structures. The attached file needs to be edited and tested and I have no way of testing this stuff so all I can give you is a basic conversion. The library format did not allow me to find the linker data to make prototypes from so you will have to extract the C header prototypes and convert them manually but there are not all that many there and what I looked at were mainly STDCALL so they should be easy enough to do.
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: dycaly on August 23, 2014, 08:56:26 PM
I fed the C .H files through some of the tools I use for converting headers and have a rough and incomplete set of equates and structures. The attached file needs to be edited and tested and I have no way of testing this stuff so all I can give you is a basic conversion. The library format did not allow me to find the linker data to make prototypes from so you will have to extract the C header prototypes and convert them manually but there are not all that many there and what I looked at were mainly STDCALL so they should be easy enough to do.
:t :t :t :t, Thank you for your work, I have written a .inc file, too. But it always error when link. I'd like to compare them.
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: hutch-- on August 24, 2014, 05:21:33 PM
Here are some rough prototypes, I have no way to test them but they appear to be the right arg count but will need the data SIZE checked. I have done them all as DWORD in size but you will need to check if any agrs are larger.


WlanAllocateMemory PROTO STDCALL :DWORD
WlanFreeMemory PROTO STDCALL :DWORD
WlanOpenHandle PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanCloseHandle PROTO STDCALL :DWORD,:DWORD
WlanEnumInterfaces PROTO STDCALL :DWORD,:DWORD,:DWORD
WlanSetAutoConfigParameter PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanQueryAutoConfigParameter PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetInterfaceCapability PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanSetInterface PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanQueryInterface PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanIhvControl PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanScan PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetAvailableNetworkList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetNetworkBssList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanConnect PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanDisconnect PROTO STDCALL :DWORD,:DWORD,:DWORD
WlanRegisterNotification PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfileEapUserData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfileEapXmlUserData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanDeleteProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanRenameProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetProfileList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfileList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfilePosition PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetProfileCustomUserData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanGetProfileCustomUserData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanSetFilterList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanGetFilterList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanSetPsdIEDataList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanSaveTemporaryProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanExtractPsdIEDataList PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanReasonCodeToString PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WlanSetSecuritySettings PROTO STDCALL :DWORD,:DWORD,:DWORD
WlanGetSecuritySettings PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WlanUIEditProfile PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
Title: Re: I'am writing a software about wlan, but I don't have wlanapi.inc
Post by: TouEnMasm on September 10, 2014, 02:17:33 AM
with ready to use sdk

Code: [Select]
include sdk32.inc
NET_LUID equ NET_LUID_LH
NDIS_SUPPORT_NDIS6 equ 1 ;or 0
include wlanapi.sdk

Put in comment the 64 bits record not allowed by ml  in ifdef.sdk
Quote
;ECHO   warning(push)
;ECHO   warning(disable:4214) ; bit field types other than int
;RECANET_LUID_LH      RECORD     BBIfType:16,
;            BBNetLuidIndex:24,
;            BBReserved:24
And you have the full set of headers (wlanapi.sdk add 10 files).

http://masm32.com/board/index.php?topic=563.msg4563#msg4563 (http://masm32.com/board/index.php?topic=563.msg4563#msg4563)