Archive for 3月, 2011

VB枚举系统网卡代码

Posted by on 星期一, 28 3月, 2011

  通过枚举系统网卡,获得网卡名称,如果包含”TAP-Win32 Adapter”则说明找到OpenVPN的虚拟网卡。部分代码如下:

Public Function CheckTapDrive() As Long
Dim AdapterInfoSize As Long
Dim AdapterInfo As IP_ADAPTER_INFO
Dim AdapterInfoBuffer() As Byte
Dim ptr1 As Long
On Error GoTo CheckFailed
AdapterInfoSize = 0
Call GetAdaptersInfo(ByVal 0&, AdapterInfoSize)
ReDim AdapterInfoBuffer(AdapterInfoSize - 1)
If 0 = GetAdaptersInfo(AdapterInfoBuffer(0), AdapterInfoSize) Then
ptr1 = VarPtr(AdapterInfoBuffer(0))
Do While (ptr1 <> 0)
CopyMemory AdapterInfo, ByVal ptr1, IP_ADAPTER_INFO_LENGTH

If InStr(AdapterInfo.Description, "TAP-Win32 Adapter") <> 0 Then '此处即是如果找到OpenVPN的TAP虚拟网卡
CheckTapDrive = 1
Exit Function
End If
ptr1 = AdapterInfo.Next
Loop
End If
Exit Function
CheckFailed:
CheckTapDrive = -1
End Function

  完整代码下载:http://www.awolf.net/downloads/enum-network-adapter.zip

WolfLAN源码和简单原理介绍

Posted by on 星期一, 28 3月, 2011

>>WolfLAN源码下载<<


  在登录时等待OpenVPN返回“Enter Auth Username”和“Enter Auth Password”,然后将帐号密码送入管道。之后读取管道,根据OpenVPN输出来判断当前状态。


登录代码:


PipeClosed = False
txtLog.Text = Now & vbCrLf
Set OvpnPipe = New ClsPipe
OvpnPipe.ConsoleShell = strAppPath & "openvpn.exe --config " & Chr(34) & strAppPath & "Wolf.ovpn" & Chr(34) '以指定参数在管道中运行OpenVPN
OvpnPipe.Silent = True
OvpnPipe.CreateConsolePipe
tmrLog.Enabled = True
'等待输入用户名并发送用户名===================
Do While InStr(1, txtLog.Text, "Enter Auth Username:") = 0
DoEvents
Loop
lbMsg.ToolTipText = "验证用户名和密码"
OvpnPipe.WriteToPipe txtUserName.Text
'===========================================
'等待输入密码并发送密码======================
Do While InStr(1, txtLog.Text, "Enter Auth Password:") = 0
DoEvents
Loop
OvpnPipe.WriteToPipe txtPassword.Text


状态判断:


If InStr(1, txtLog.Text, "TUN/TAP interface has been stopped") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡已停止"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "process exiting") <> 0 Then
ConnectError
lbMsg.Caption = "- 进程终止"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Closing TUN/TAP interface") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡关闭"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "There are no TAP-Win32 adapters on this system.") <> 0 Then
ConnectError
lbMsg.Caption = "- 未找到Tap网卡"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "All TAP-Win32 adapters on this system are currently in use.") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡被占用"
Exit Sub
End If
DoEvents
If (InStr(1, txtLog.Text, "TCP/UDP: Closing socket") <> 0) And (InStr(1, txtLog.Text, "Restart pause, 5 second(s)") <> 0) Then
ConnectError
lbMsg.Caption = "- 错误:Closing socket"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Exiting") <> 0 Then
ConnectError
lbMsg.Caption = "- 主动断开"
Exit Sub
End If
DoEvents
If (InStr(1, txtLog.Text, "VERIFY OK") <> 0) And (InStr(1, txtLog.Text, "--dhcp-option") = 0) Then lbMsg.ToolTipText = "建立通道"
If (InStr(1, txtLog.Text, "--dhcp-option") <> 0) And (InStr(1, txtLog.Text, "Initialization Sequence Completed") = 0) Then lbMsg.ToolTipText = "获取IP"
If (InStr(1, txtLog.Text, "Initialization Sequence Completed") <> 0) And (InStr(1, txtLog.Text, "With Errors") = 0) Then
If chkRoute.Value = 1 Then
lbMsg.ToolTipText = "设置借线"
OvpnPipe.Wait (2000)
WaitRun "route", "add 0.0.0.0 mask 0.0.0.0 192.168.27.254"
End If
lbMsg.Caption = "+ 链接成功"
SocketsInitialize
tmrStatus.Enabled = False
cmdLogin.Enabled = True
cmdLogin.Caption = "&D.断开"
PopInfo
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Initialization Sequence Completed With Errors") <> 0 Then
ConnectError
lbMsg.Caption = "- Errors"
Exit Sub
End If
DoEvents



Win7 OEM Loader 正版激活

Posted by on 星期一, 28 3月, 2011

一个把Win7变成正版的loader

>>本地下载<<

cd-key

install loader

succeed


日本一地震后果很严重啊

Posted by on 星期四, 17 3月, 2011

沈阳三好街内存现在正以10元/天的速度疯涨。

还有我的三菱翼神啊。。。

我家小狗跑丢了

Posted by on 星期一, 7 3月, 2011

昨晚我家小狗跑丢了,一宿没回家。

结果今天早上在我姥姥家发现我家的狗了。。这家伙跑到4、5公里以外的对象家去了。。。太不可思议了。。。