Skip to content

Commit

Permalink
Restore Build.bat and DiagReport; they do not need to be private
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Jun 28, 2017
1 parent cf7bfc3 commit ae9dd3d
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 0 deletions.
38 changes: 38 additions & 0 deletions installer/Build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SET NPCAPDIR="..\npcap"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Use VS2013's MSBuild to build wpcap.dll, Packet.dll, NPFInstall.exe, NpcapHelper.exe and WlanHelper.exe
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"

msbuild "%NPCAPDIR%\packetWin7\Dll\Project\Packet.sln" /t:Build /p:Configuration="Release No NetMon and AirPcap" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\Dll\Project\Packet.sln" /t:Build /p:Configuration="Release No NetMon and AirPcap" /p:Platform="x64"
msbuild "%NPCAPDIR%\packetWin7\Dll\Project\Packet.sln" /t:Build /p:Configuration="Release No NetMon and AirPcap(WinPcap Mode)" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\Dll\Project\Packet.sln" /t:Build /p:Configuration="Release No NetMon and AirPcap(WinPcap Mode)" /p:Platform="x64"

:: wpcap.sln project depends on the Packet.sln project, because Packet.lib generated by Packet.sln is required to be linked to build wpcap.sln.
msbuild "%NPCAPDIR%\wpcap\libpcap\Win32\Prj\wpcap.sln" /t:Build /p:Configuration="Release" /p:Platform="Win32"
msbuild "%NPCAPDIR%\wpcap\libpcap\Win32\Prj\wpcap.sln" /t:Build /p:Configuration="Release" /p:Platform="x64"

msbuild "%NPCAPDIR%\packetWin7\NPFInstall\NPFInstall.sln" /t:Build /p:Configuration="Release" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\NPFInstall\NPFInstall.sln" /t:Build /p:Configuration="Release" /p:Platform="x64"
msbuild "%NPCAPDIR%\packetWin7\NPFInstall\NPFInstall.sln" /t:Build /p:Configuration="Release(WinPcap Mode)" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\NPFInstall\NPFInstall.sln" /t:Build /p:Configuration="Release(WinPcap Mode)" /p:Platform="x64"

msbuild "%NPCAPDIR%\packetWin7\Helper\NpcapHelper.sln" /t:Build /p:Configuration="Release" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\Helper\NpcapHelper.sln" /t:Build /p:Configuration="Release" /p:Platform="x64"

msbuild "%NPCAPDIR%\packetWin7\WlanHelper\WlanHelper.sln" /t:Build /p:Configuration="Release" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\WlanHelper\WlanHelper.sln" /t:Build /p:Configuration="Release" /p:Platform="x64"

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Use VS2015's MSBuild to build npf.sys (and npcap.sys)
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

:: "%28" is the escape for "(", "%29" is the escape for ")", and "%%" is the escape for "%" itself. Not using escape will cause target error of MSBuild.
msbuild "%NPCAPDIR%\packetWin7\npf\npf.sln" /t:Build /p:Configuration="Win7 Release%%28WinPcap Mode%%29" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\npf\npf.sln" /t:Build /p:Configuration="Win7 Release%%28WinPcap Mode%%29" /p:Platform="x64"
msbuild "%NPCAPDIR%\packetWin7\npf\npf.sln" /t:Build /p:Configuration="Win7 Release" /p:Platform="Win32"
msbuild "%NPCAPDIR%\packetWin7\npf\npf.sln" /t:Build /p:Configuration="Win7 Release" /p:Platform="x64"

pause


31 changes: 31 additions & 0 deletions installer/DiagReport.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@echo off

net session >nul 2>&1
if not "%errorLevel%" == "0" (
rem This tools must run with administrator permissions
rem It will popup the UAC dialog, please click [Yes] to continue.
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /b 2
)

set dir=%~dp0
set scriptPath=%dir%DiagReport.ps1
for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do (
set originPolicy=%%a
)
powershell Set-ExecutionPolicy 0

rem this call only works for Administrator
rem powershell %scriptPath%

rem This call works also for normal users
rem "No Exit" version:
rem powershell -NoExit -noprofile -command "&{start-process powershell -ArgumentList '-NoExit -noprofile -file \"%scriptPath%\"' -verb RunAs}"
rem "Exit" version:
powershell -noprofile -command "&{start-process powershell -ArgumentList '-noprofile -file \"%scriptPath%\"' -verb RunAs}"

powershell Set-ExecutionPolicy %originPolicy%

rem pause
235 changes: 235 additions & 0 deletions installer/DiagReport.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#
# Deploy.ps1 - The diagnostic report script for Npcap
# Author: Yang Luo
# Date: August 29, 2016
#

$report_file_name = $MyInvocation.MyCommand.Definition.Replace(".ps1", "-" + (Get-Date -Format 'yyyyMMdd-HHmmss') + ".txt")

# Delete the old report if exists.
if (Test-Path $report_file_name)
{
Remove-Item $report_file_name
}

$(

# $ErrorActionPreference="SilentlyContinue"
# Stop-Transcript | Out-Null
# $ErrorActionPreference = "Continue"
# Start-Transcript -IncludeInvocationHeader -Path $report_file_name

function write_report($text)
{
# Write-Host $text
# Write-Output $text
# $text | Out-File -Append -FilePath $report_file_name
$text
# $text >> $report_file_name
# Write-Output $text | Out-File -Append -FilePath $report_file_name
}

function get_script_bit()
{
if ([IntPtr]::Size -eq 8)
{
'64-bit'
}
else
{
'32-bit'
}
}

function get_os_bit()
{
return (Get-WmiObject Win32_OperatingSystem).OSArchitecture
}

function get_winpcap_mode()
{
return (Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\npcap).GetValue("WinPcapCompatible")
}

function get_install_path()
{
if ($os_bit -eq "32-bit")
{
return (Get-ItemProperty HKLM:\SOFTWARE\Npcap).'(default)'
}
else
{
return (Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Npcap).'(default)'
}
}

$os_bit = get_os_bit
$winpcap_mode = get_winpcap_mode
$install_path = get_install_path


write_report ("*************************************************")
write_report "DiagReport for Npcap ( http://npcap.org )"
write_report ("*************************************************")
"Script Architecture:`t`t" + (get_script_bit)
"Script Path:`t`t`t" + ($MyInvocation.MyCommand.Definition)
"Current Time:`t`t`t" + (Get-Date)
"Npcap install path:`t`t" + $install_path
"Npcap Version:`t`t`t" + ([System.Diagnostics.FileVersionInfo]::GetVersionInfo($install_path + "\NPFInstall.exe").FileVersion)
"PowerShell Version:`t`t" + ($PSVersionTable.PSVersion)

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("OS Info:")
write_report ("*************************************************")

(Get-WmiObject Win32_OperatingSystem) | Format-List Caption, BuildNumber, Locale, MUILanguages, OSArchitecture, ServicePackMajorVersion, ServicePackMinorVersion, SystemDirectory, Version

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("CPU Info:")
write_report ("*************************************************")

(Get-WmiObject Win32_Processor) | Format-List Name, Manufacturer, DeviceID, NumberOfCores, NumberOfEnabledCore, NumberOfLogicalProcessors, Addresswidth

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("Memory Info:")
write_report ("*************************************************")

"Size:`t`t`t`t" + [int]((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory / 1024 / 1024) + " MB" + " (" + (Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory + " Bytes)"

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("Network Adapter(s) Info:")
write_report ("*************************************************")

Get-NetAdapter

(Get-WmiObject Win32_NetworkAdapter) | Where-Object {$_.GUID -ne $null} | Format-List Caption, GUID, Index, InterfaceIndex, Manufacturer, NetConnectionID, PNPDeviceID

#########################################################
#write_report ("`n")
#write_report ("*************************************************")
#write_report ("Driver Info:")
#write_report ("*************************************************")

#Get-WmiObject Win32_SystemDriver |
# select *, @{ N='CompanyName';E={ (Get-ItemProperty $_.pathname -ErrorAction Ignore).VersionInfo.companyname }} |
# Where CompanyName -NotLike "*microsoft*" |
# Where State -NotLike "Stopped" |
# sort State, Name |
# Format-Table Name, Description, ServiceType, State, ExitCode, CompanyName, PathName

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("NDIS Light-Weight Filter (LWF) Info:")
write_report ("*************************************************")

(Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Network\{4d36e974-e325-11ce-bfc1-08002be10318}\*' | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })

#########################################################
write_report ("`n")
"*************************************************"
write_report ("File Info:")
write_report ("*************************************************")

# write_report ("C:\Program Files\Npcap:")
dir $install_path

# write_report ("C:\Windows\System32:")
dir ($env:WinDir + "\System32\") NpcapHelper.exe
dir ($env:WinDir + "\System32\") Packet.dll
dir ($env:WinDir + "\System32\") WlanHelper.exe
dir ($env:WinDir + "\System32\") wpcap.dll
dir ($env:WinDir + "\System32\Npcap\")

if ($os_bit -eq "64-bit")
{
# write_report ("C:\Windows\SysWOW64:")
dir ($env:WinDir + "\SysWOW64\") NpcapHelper.exe
dir ($env:WinDir + "\SysWOW64\") Packet.dll
dir ($env:WinDir + "\SysWOW64\") WlanHelper.exe
dir ($env:WinDir + "\SysWOW64\") wpcap.dll
dir ($env:WinDir + "\SysWOW64\Npcap\")
}

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("WinPcap Info:")
write_report ("*************************************************")

if ($os_bit -eq "32-bit")
{
write_report ("HKLM:\SOFTWARE\WinPcap:")
(Get-ItemProperty HKLM:\SOFTWARE\WinPcap | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
}
else
{
write_report ("HKLM:\SOFTWARE\WOW6432Node\WinPcap:")
(Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\WinPcap | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
}

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("Registry Info:")
write_report ("*************************************************")

if ($os_bit -eq "32-bit")
{
write_report ("HKLM:\SOFTWARE\Npcap:")
(Get-ItemProperty HKLM:\SOFTWARE\Npcap | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
}
else
{
write_report ("HKLM:\SOFTWARE\WOW6432Node\Npcap:")
(Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Npcap | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
}

write_report ("HKLM:\SYSTEM\CurrentControlSet\Services\npcap:")
(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\npcap | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
write_report ("HKLM:\SYSTEM\CurrentControlSet\Services\npcap_wifi:")
(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\npcap_wifi | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })

if ($winpcap_mode -eq 1)
{
write_report ("HKLM:\SYSTEM\CurrentControlSet\Services\npf:")
(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\npf | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
write_report ("HKLM:\SYSTEM\CurrentControlSet\Services\npf_wifi:")
(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\npf_wifi | out-string -stream | ? { $_ -NOTMATCH '^ps.+' })
}

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("Service Info:")
write_report ("*************************************************")

Get-Service npcap

if ($winpcap_mode)
{
Get-Service npf
}

#########################################################
write_report ("`n")
write_report ("*************************************************")
write_report ("Install Info:")
write_report ("*************************************************")

write_report ("Please refer to: $install_path\install.log")

# Stop-Transcript
# ) *>&1 > $report_file_name
# ) >> $report_file_name
) 2>&1 >> $report_file_name

notepad $report_file_name

0 comments on commit ae9dd3d

Please sign in to comment.