📄 oemsetup.inf
字号:
endif
EndWait
;; Intentional fall-through to ReviewBindings
; -----------------------------------------------
; ReviewBindings
; -----------------------------------------------
ReviewBindings =+
Debug-Output "VPCNetNT: ReviewBindings label"
Debug-Output "VPCNetNT: --> NTN_RegBase : "$(!NTN_RegBase)
ifstr(i) $(FirstTime) == TRUE
set CheckBindings = TRUE
endif
ifstr(i) $(CheckBindings) == TRUE
;; Get the current bindings
Debug-Output "VPCNetNT: Reviewing bindings in "$(NDISProtocolLinkageKeyName)
OpenRegKey $(!REG_H_LOCAL) "" $(NDISProtocolLinkageKeyName) $(MAXIMUM_ALLOWED) NDISProtocolLinkageKey
ifstr(i) $(NDISProtocolLinkageKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to open linkage key for "$(NDISProtocolLinkageKeyName)
goto fatalregistry
endif
GetRegValue $(NDISProtocolLinkageKey) "Bind" KeyValue
ifint $(RegLastError) == 0
set Bindings = *($(KeyValue), 4)
else
set Bindings = {}
endif
Debug-Output "VPCNetNT: Bind : "$(Bindings)
set DisabledBind = {}
set DisabledExport = {}
set DisabledRoute = {}
;; Get the currently disabled bindings, exports and routes
OpenRegKey $(NDISProtocolLinkageKey) "" "Disabled" $(MAXIMUM_ALLOWED) NDISProtocolLinkageDisabledKey
ifstr(i) $(NDISProtocolLinkageDisabledKey) != $(KeyNull)
GetRegValue $(NDISProtocolLinkageDisabledKey) "Bind" KeyValue
ifint $(RegLastError) == 0
set DisabledBind = *($(KeyValue), 4)
GetRegValue $(NDISProtocolLinkageDisabledKey) "Export" KeyValue
set DisabledExport = *($(KeyValue), 4)
GetRegValue $(NDISProtocolLinkageDisabledKey) "Route" KeyValue
set DisabledRoute = *($(KeyValue), 4)
endif
endif ; $(NDISProtocolLinkageDisabledKey) != $(KeyNull)
Debug-Output "VPCNetNT: DisabledBind : "$(DisabledBind)
QueryListSize BindingsCount $(Bindings)
Debug-Output "VPCNetNT: BindingsCount : "$(BindingsCount)
QueryListSize DisabledBindingsCount $(DisabledBind)
Debug-Output "VPCNetNT: DisabledBindingsCount : "$(DisabledBindingsCount)
set-add BindingsCount = $(BindingsCount), $(DisabledBindingsCount)
ifint $(BindingsCount) == 0
;; This is probably the first time we've installed, so generate
;; an artificial binding list from the list of network adapters
OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) NetworkCardsKey
ifstr(i) $(NetworkCardsKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to open network cards key"
goto fatalregistry
endif
set Bindings = {}
EnumRegKey $(NetworkCardsKey) KeyList
ForListDo $(KeyList)
set CardKeyName = *($($), 1)
OpenRegKey $(NetworkCardsKey) "" $(CardKeyName) $(MAXIMUM_ALLOWED) CardKey
ifstr(i) $(CardKey) != $(KeyNull)
Shell "", CanBindToCard, $(NDISProtocolName), $(NetRuleNDISProtocolBindable), $(CardKey)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to call CanBindToCard, skipping card - ShellCode "$($ShellCode)
else-ifstr(i) $($R0) == TRUE
GetRegValue $(CardKey) "ServiceName" KeyValue
ifint $(RegLastError) != 0
Debug-Output "VPCNetNT: Failed to get ServiceName key value - error "$(RegLastError)
else
set ServiceName = *($(KeyValue), 4)
set Bindings = >($(Bindings), "\Device\"$(ServiceName))
endif
endif
CloseRegKey $(CardKey)
endif ; $(CardKey) != $(KeyNull)
EndForListDo ; $(KeyList)
CloseRegKey $(NetworkCardsKey)
endif ; $(BindingsCount) != 0
;; Parse the bindings to create a list of adapter cards and a list
;; of our virtual NICs. We will disable any bindings to our virtual
;; NIC.
set CardList = {}
set CreateCardList = {}
set NewBind = {}
set NewExport = {}
set NewRoute = {}
ForListDo $(Bindings)
Split-String $($) "\" ValueList
QueryListSize ValueListSize $(ValueList)
set CardServiceName = *($(ValueList), $(ValueListSize))
;; Open the card entry at "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\N"
Shell "", OpenNetworkCardFromServiceName, $(CardServiceName)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to find card entry for "$(CardServiceName)" - ShellCode "$($ShellCode)
else-ifstr(i) $($R0) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to find card entry for "$(CardServiceName)
else
set NetworkCardKey = $($R0)
;; Check to see if this is a binding to ourselves - if so, disable it
GetRegValue $(NetworkCardKey) "ProductName" KeyValue
set CardProductName = *($(KeyValue), 4)
ifstr(i) $(CardProductName) == $(NDISMiniportName)
Debug-Output "VPCNetNT: Found binding to card "$(CardServiceName)" - disabling"
set DisabledBind = >($(DisabledBind), $($))
set DisabledExport = >($(DisabledExport), "\Device\"$(NDISProtocolName)"_"$(CardServiceName))
set DisabledRoute = >($(DisabledRoute), """"$(CardProductName)""" """$(CardServiceName)"""")
else
Debug-Output "VPCNetNT: Found binding to card "$(CardServiceName)
set NewBind = >($(NewBind), $($))
set NewExport = >($(NewExport), "\Device\"$(NDISProtocolName)"_"$(CardServiceName))
set NewRoute = >($(NewRoute), """"$(CardProductName)""" """$(CardServiceName)"""")
set CardList = >($(CardList), $(CardServiceName))
endif
CloseRegKey $(NetworkCardKey)
endif
EndForListDo ; $(Bindings)
Debug-Output "VPCNetNT: Updating protocol linkage..."
Debug-Output "VPCNetNT: Bind : "$(NewBind)
Debug-Output "VPCNetNT: Export : "$(NewExport)
Debug-Output "VPCNetNT: Route : "$(NewRoute)
set NewValueList = { +
{"Bind", $(NoTitle), $(!REG_VT_MULTI_SZ), $(NewBind)}, +
{"Export", $(NoTitle), $(!REG_VT_MULTI_SZ), $(NewExport)}, +
{"Route", $(NoTitle), $(!REG_VT_MULTI_SZ), $(NewRoute)} +
}
Shell $(UtilityInf), AddValueList, $(NDISProtocolLinkageKey), $(NewValueList)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to add values list! ShellCode "$($ShellCode)
CloseRegKey $(NDISProtocolLinkageDisabledKey)
CloseRegKey $(NDISProtocolLinkageKey)
goto fatal
else-ifstr(i) $($R0) != NO_ERROR
Debug-Output "VPCNetNT: Failed to add values list! RegistryError "$($R0)
set RegistryErrorIndex = $($R0)
CloseRegKey $(NDISProtocolLinkageDisabledKey)
CloseRegKey $(NDISProtocolLinkageKey)
goto fatalregistry
endif
ifstr(i) $(NDISProtocolLinkageDisabledKey) != $(KeyNull)
Debug-Output "VPCNetNT: Disabled\Bind : "$(DisabledBind)
Debug-Output "VPCNetNT: Disabled\Export : "$(DisabledExport)
Debug-Output "VPCNetNT: Disabled\Route : "$(DisabledRoute)
set NewValueList = { +
{"Bind", $(NoTitle), $(!REG_VT_MULTI_SZ), $(DisabledBind)}, +
{"Export", $(NoTitle), $(!REG_VT_MULTI_SZ), $(DisabledExport)}, +
{"Route", $(NoTitle), $(!REG_VT_MULTI_SZ), $(DisabledRoute)} +
}
Shell $(UtilityInf), AddValueList, $(NDISProtocolLinkageDisabledKey), $(NewValueList)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to add values list! ShellCode "$($ShellCode)
else-ifstr(i) $($R0) != NO_ERROR
Debug-Output "VPCNetNT: Failed to add values list! RegistryError "$($R0)
endif
CloseRegKey $(NDISProtocolLinkageDisabledKey)
endif ; $(NDISProtocolLinkageDisabledKey) != $(KeyNull)
CloseRegKey $(NDISProtocolLinkageKey)
Debug-Output "VPCNetNT: CardList : "$(CardList)
set CreatedNewAdapter = FALSE
ForListDo $(CardList)
set CardServiceName = $($)
Debug-Output "VPCNetNT: Processing "$(CardServiceName)"..."
set CardKeyName = $(!NTN_ServiceBase)"\"$(CardServiceName)
OpenRegKey $(!REG_H_LOCAL) "" $(CardKeyName) $(MAXIMUM_ALLOWED) CardKey
ifstr(i) $(CardKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to open key "$(CardKeyName)
else
;; Open the card entry at "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\N"
Shell "", OpenNetworkCardFromServiceName, $($)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to find card entry for "$(CardServiceName)" - ShellCode "$($ShellCode)
else-ifstr(i) $($R0) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to find card entry for "$(CardServiceName)
else
set NetworkCardKey = $($R0)
;; Check to see if this is a binding to ourselves - if so, skip it
GetRegValue $(NetworkCardKey) "ProductName" KeyValue
set CardProductName = *($(KeyValue), 4)
ifstr(i) $(CardProductName) == $(NDISMiniportName)
Debug-Output "VPCNetNT: Skipping bind to ourselves"
else
;; Open or create the protocol specific key in the adapter's parameters
OpenRegKey $(CardKey) "" "Parameters\"$(NDISProtocolName) $(MAXIMUM_ALLOWED) ProtocolParametersKey
ifstr(i) $(ProtocolParametersKey) != $(KeyNull)
;; skip this adapter as we have already processed it
Debug-Output "VPCNetNT: "$(CardServiceName)" has already been processed - skipping."
CloseRegKey $(ProtocolParametersKey)
else
;; Get the card title
GetRegValue $(NetworkCardKey) "Title" KeyValue
set CardTitle = *($(KeyValue), 4)
;; Create a title for our virtual NIC
set AdapterTitleBase = $(NDISMiniportTitle)" -> "$(CardTitle)
;; Add a virtual NIC for this card
Shell "", CreateVirtualNIC, $(Option), $(STF_CONTEXTINFNAME), $(AdapterTitleBase), *($(Now), 1)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to create virtual NIC for "$(CardServiceName)" - ShellCode "$($ShellCode)
else-ifstr(i) $($R0) != NO_ERROR
Debug-Output "VPCNetNT: Failed to create virtual NIC for "$(CardServiceName)" - RegistryError "$($R0)
else
set AdapterKey = $($R1)
set AdapterRulesKey = $($R2)
set AdapterParametersKey = $($R3)
set AdapterNumber = $($R4)
set AdapterServiceName = $($R5)
set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$(AdapterNumber))
CloseRegKey $(AdapterKey)
CloseRegKey $(AdapterRulesKey)
OpenRegKey $(CardKey) "" "Parameters" $(MAXIMUM_ALLOWED) CardParametersKey
ifstr(i) $(CardParametersKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to open card parameters key"
else
;; Copy the protocol parameters from the real NIC to our virtual NIC
EnumRegKey $(CardParametersKey) KeyList
ForListDo $(KeyList)
set KeyName = *($($), 1)
Debug-Output "VPCNetNT: Copying key """$(KeyName)""" from "$(CardServiceName)" to "$(AdapterServiceName)"..."
OpenRegKey $(CardParametersKey) "" $(KeyName) $(MAXIMUM_ALLOWED) TempKey
ifstr(i) $(TempKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to open card parameter key """$(KeyName)""""
else
Shell $(UtilityInf), CopyRegTreeAs, $(TempKey), $(AdapterParametersKey), $(KeyName)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to copy key """$(KeyName)""" to virtual NIC parameter key - ShellCode "$($ShellCode)
else-ifstr(i) $($R0) != NO_ERROR
Debug-Output "VPCNetNT: Failed to copy key """$(KeyName)""" to virtual NIC parameter key - RegistryErrorIndex "$($R0)
endif
CloseRegKey $(TempKey)
endif
EndForListDo ; $(KeyList)
;; Add our protocol specific parameter key
Debug-Output "VPCNetNT: Adding """$(NDISProtocolName)""" key to """$($)"\Parameters"""
CreateRegKey $(CardParametersKey) {$(NDISProtocolName), $(NoTitle), GenericClass} "" $(MAXIMUM_ALLOWED) "" ProtocolParametersKey
ifstr(i) $(ProtocolParametersKey) == $(KeyNull)
Debug-Output "VPCNetNT: Failed to create key Parameters\"$(NDISProtocolName)
else
;; Add our protocol specific parameter values
set NewValueList = { +
{"AdapterNumber", $(NoTitle), $(!REG_VT_SZ), $(AdapterNumber)}, +
{"LowerNICTitle", $(NoTitle), $(!REG_VT_SZ), $(CardTitle)}, +
{"NextGuestID", $(NoTitle), $(!REG_VT_DWORD), 1}, +
{"NextVirtualAdapterID", $(NoTitle), $(!REG_VT_DWORD), 1}, +
{"UpperBindings", $(NoTitle), $(!REG_VT_SZ), $(AdapterServiceName)} +
}
Shell $(UtilityInf), AddValueList, $(ProtocolParametersKey), $(NewValueList)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: Failed to add values list! ShellCode "$($ShellCode)
else-ifstr(i) $($R0) != NO_ERROR
Debug-Output "VPCNetNT: Failed to add values list! RegistryError "$($R0)
endif
set CreatedNewAdapter = TRUE
CloseRegKey $(ProtocolParametersKey)
endif ; $(ProtocolParametersKey) == $(KeyNull)
CloseRegKey $(CardParametersKey)
endif ; $(CardParametersKey) == $(KeyNull)
endif
endif ; $(ProtocolParametersKey) != $(KeyNull)
endif ; $(CardProductName) == $(NDISMiniportName)
CloseRegKey $(NetworkCardKey)
endif
CloseRegKey $(CardKey)
endif ; $(CardKey) == $(KeyNull)
EndForListDo ; $(CardList)
;; Disable the protocol bindings to the real NIC
;; FIX ME! We should really find some way of dynamically determining
;; the protocols to disable rather than relying on a fixed list of
;; protocols.
ForListDo $(DisableProtocolsList)
Shell "", AdjustBindings, $($), $(CardList), disable
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "VPCNetNT: AdjustBindings failed! ShellCode "$($ShellCode)
endif
EndForListDo ; $(DisableProtocolsList)
ifstr(i) $(CreatedNewAdapter) == TRUE
;; We added a new virtual adapter, so we need to tell NCPA to
;; review the bindings.
set NCPAKeyName = $(!NTN_SoftwareBase)"\Microsoft\NCPA\CurrentVersion"
OpenRegKey $(!REG_H_LOCAL) "" $(NCPAKeyName) $(MAXIMUM_ALLOWED) NCPAKey
ifstr(i) $(NCPAKey) == $(KeyNull)
Debug-Output "Failed to open key "$(NCPAKeyName)
goto fatalregistry
endif
SetRegValue $(NCPAKey) {"BindRestart", $(NoTitle), $(!REG_VT_DWORD), 1}
CloseRegKey $(NCPAKey)
endif ; $(CreatedNewAdapter) == TRUE
endif ; $(CheckBindings) == TRUE
;; ifstr(i) $(FirstTime) == TRUE
;; read-syms ProtocolBindingsMessageDlg$(!STF_LANGUAGE)
;; ui start "MessageBox"
;; ifstr(i) $(DLGEVENT) == "OK" ; DLGEVENT indicates button pressed
;; Debug-Output "VPCNetNT - user agreed"
;; endif
;; endif
Goto $(WhenDone)
; -----------------------------------------------
; Configure Adapter
; -----------------------------------------------
ConfigureSoftware = +
Debug-Output "VPCNetNT: ConfigureSoftware label"
Debug-Output "VPCNetNT: --> NTN_RegBase : "$(!NTN_RegBase)
Debug-Output "VPCNetNT: Configuration is not yet supported!"
read-syms ConfigureMessageDlg$(!STF_LANGUAGE)
ui start "MessageBox"
ifstr(i) $(DLGEVENT) == "OK" ; DLGEVENT indicates button pressed
Debug-Output "VPCNetNT - user agreed"
endif
;; set CommonStatus = STATUS_REBIND
goto $(WhenDone)
; -----------------------------------------------
; Error Handling
; -----------------------------------------------
abandon = +
;
Debug-Output "VPCNetNT - abandon label"
;
ForListDo $(OEM_ABANDON_OPTIONS)
Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
$(NDISMiniportName), $($)
ifint $($ShellCode) != $(!SHELL_CODE_OK)
Debug-Output "ShellCode error"
goto ShellCodeError
endif
set RegistryErrorIndex = $($R0)
ifstr(i) $(RegistryErrorIndex) != NO_ERROR
goto fatalregistry
endif
EndForListDo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -