用WinForm写一个虚拟WiFi助手玩玩(附源码)_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > 用WinForm写一个虚拟WiFi助手玩玩(附源码)

用WinForm写一个虚拟WiFi助手玩玩(附源码)

 2015/4/19 17:26:37  taney  程序员俱乐部  我要评论(0)
  • 摘要:这早不是什么新鲜的东西了,同类软件已经有很多,但不是收费就是有广告,在学校的时候就想自已写一个了,但那时候啥也没学,对C的掌握程度也就是定义几个变量,打印一行“Hello,world”这样,为了写这破玩意,还特意跑图书馆看了几天的VB,然后网上拷了些代码,用调cmd的方式实现了基本功能。到现在也做了1年的.Net码农了,打算重新撸一个,windows应该会开放这方面的api,估计也简单。在开始之前我搜了一下,貌似没有用.Net写的,应该早有人写过只是没发出来吧
  • 标签:for 源码 一个 winform WiFi

这早不是什么新鲜的东西了,同类软件已经有很多,但不是收费就是有广告,在学校的时候就想自已写一个了,但那时候啥也没学,对C的掌握程度也就是定义几个变量,打印一行“Hello,world”这样,为了写这破玩意,还特意跑图书馆看了几天的VB,然后网上拷了些代码,用调cmd的方式实现了基本功能。到现在也做了1年的.Net码农了,打算重新撸一个,windows应该会开放这方面的api,估计也简单。

在开始之前我搜了一下,貌似没有用.Net写的,应该早有人写过只是没发出来吧。唯一找到的就是在codeplex上的一个开源项目Virtual Router,于是就使用了它的部分代码。

下面是最终的程序QQQkgwzR0FUyGEEEJIMM0dBVMhhBBCSDDNHQVTIYQQQnaR//ivvwkJbdXcUTAVQnaVd5cXT5+8kvo8e37x+MV7o+X9kytjk9ubi6uXv8T3Yg2i3129A1+InAFCtpozm8rhcDgcDnILpkIIsWJO2AbP3y19DHV4/+Tq4vL2xE5+efHUMJX3T65Ohrm8ve9zcfNMV5JsKr+8eHpa6P2wtzfeXTx77j28C309hGw4go5UWlMx1aREUzAVQvaTpDWVe1MxGl1TOXZ4ePzq5WPRhMK78+Rkd69ePjZNJb60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ACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKBpBCAAoGkEIACgaQQgAKNqQQQgAwBgME4QAAEwIQQgAKBpBCAAozrt37969e7d5TBACAIpDEAIAsEUQAgBKUU8EmRECAEpEEAIA4CMIAQAzF04EmRECAApCEAIAEEUQAgCKlheEFEVRFDW/sgYhRVEURRVSBCFFURRVdBGEFEVRVNFFEFIURVFFF0FIURRFFV0EIUVRFFV0/eH5L9Ufnv9CURRFUcXW/wO6PJYuJvh6oQAAAABJRU5ErkJggg==" alt="" />

界面比较挫,我们就不要在意这些细节了,来看看实现过程吧。

MSDN上有关于虚拟wifi的详细文档,里面介绍了一些概念和相关函数的用途。地址

windows的api是用C写的,C#调用C就要用到PInvoke(平台调用)方面的知识,主要涉及的类有:

  • DllImportAttribute:表示某个方法来自外部非托管dll中的函数
  • IntPtr:用来表示一个指针(跟C中的指针相比弱爆了)
  • Marshal:一个工具类,提供大量的静态方法用于操作未托管内存

因为windows api中定义了大量的的结构体和和常量,这些在C#中无法直接使用,所以要在C#中重新定义一遍,非常麻烦,但有了pinvoke.net,生活就幸福多了。

但是在搞的过程中还是遇到了点小问题,某个结构体有一个数组成员,像这样:

public WLAN_HOSTED_NETWORK_PEER_STATE[] PeerList;

这个对象是通过一个函数的指向指针的指针参数取到的,在通过函数返回这个结构体时,这个成员始终为null。在C中可以把数组当作指向首地址的指针,所以我把这个成员改成了IntPtr类型,但取到的居然是个负值,shit!请教了下谷哥,看到在stackoverflow上有人提了同样的问题,答案的思路就是:既然有了这个结构体对象的首地址,因为成员在内存中都是按顺序布局的,所以把这个指针偏移到PeerList成员的地方就可以了,所以我就为这个结构体加了下面这个方法:

    public void FixPeerListAddr(IntPtr ptr)
        {
            //将指向WLAN_HOSTED_NETWORK_STATUS首地址的指针偏移到PeerList成员的地方
            IntPtr offset = Marshal.OffsetOf(typeof(WLAN_HOSTED_NETWORK_STATUS), "PeerList");
            PeerList = ptr + offset.ToInt32();
        }

问题搞定!

那怎么使用这个IntPtr对象遍历它指向的数组呢,在C中就非常简单,直接for循环里面PeerList[偏移]或*(PeerList + 偏移),而IntPtr对象只是对指针的一个表示,并没有C中那么强大的用法,只能每次增加偏移然后调用Marshal.PtrToStructure来取指针指向的对象,考虑到很多地方会这么做,为简化代码,我为IntPtr增加了两个扩展方法,如下:

 1 public static class SystemExtension
 2     {
 3         /// <summary>
 4         /// 根据数组首地址枚举出所有元素
 5         /// </summary>
 6         /// <typeparam name="T"></typeparam>
 7         /// <param name="self"></param>
 8         /// <param name="length"></param>
 9         /// <returns></returns>
10         public static IEnumerable<T> AsEnumerable<T>(this IntPtr self, int length)
11         {
12             int size = Marshal.SizeOf(typeof(T));
13             for (int i = 0; i < length; ++i) {
14                 yield return self.Dereference<T>();
15                 self += size;
16             }
17         }
18         
19         /// <summary>
20         /// 获取指针指向的对象
21         /// </summary>
22         /// <param name="self"></param>
23         /// <returns></returns>
24         public static T Dereference<T>(this IntPtr self)
25         {
26             return (T)Marshal.PtrToStructure(self, typeof(T));
27         }
28     }

 

很简单的一个小玩意,就扯这么多吧,程序还有很多值得改进的地方,大家有什么想法欢迎交流,也让我学习学习。第一次写博客,渣渣一个,还望各位前辈多多指教!

源码下载

发表评论
用户名: 匿名