⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oemsetup.inf

📁 linux环境编程的电子文稿
💻 INF
📖 第 1 页 / 共 4 页
字号:
    ifstr(i) $(OEM_ABANDON_PROTOCOL) == TRUE
        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
            $(NDISProtocolName), FALSE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto fatalregistry
        endif
    endif

	goto end

fatalregistry = +
    ;
    Debug-Output "VPCNetNT - fatalregistry label"
    ;
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    set Error = $($R0)
    goto fatal

fatal = +
    ;
    Debug-Output "VPCNetNT - fatal label"
    ;
    ifstr(i) $(Error) == ""
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif
        set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    goto setfailed

ShellCodeError = +
    ;
    Debug-Output "VPCNetNT - ShellCodeError label"
    ;
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = $(ShellCodeErrorTitle)
    set STF_MB_TEXT  = $(ShellCodeErrorText)
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed

SetFailed = +
    ;
    Debug-Output "VPCNetNT - setfailed label"
    ;
    set CommonStatus = STATUS_FAILED
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
        set OEM_ABANDON_ON = FALSE
        goto abandon
    endif
    goto end

end = +
    ;
    Debug-Output "VPCNetNT - end label"
    ;
    Return $(CommonStatus)

; ======================================================================
;	Subroutines
; ======================================================================

; ----------------------------------------------------------------------
;	OpenNetworkCardFromServiceName
;
;	This subroutine return a handle to registry key "SOFTWARE\Microsoft\
;	Windows NT\CurrentVersion\NetworkCards\N" where "N" is the adapter
;	number of the card referenced by the specified service name.
;
;	Parameters:
;		In:		$($0)	- The card service name
;		Out:	$($R0)	- The network card key
; ----------------------------------------------------------------------

[OpenNetworkCardFromServiceName]
	read-syms	GeneralConstants
	read-syms	FileConstants
	read-syms	FileConstants$(!STF_LANGUAGE)

	set DesiredCardServiceName	 = $($0)

	Debug-Output "VPCNetNT: OpenNetworkCardFromServiceName called!"
	Debug-Output "VPCNetNT: --> DesiredCardServiceName : "$(DesiredCardServiceName)

	set ReturnedCardKey		 = $(KeyNull)

	OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) NetworkCardsKey
	ifstr(i) $(NetworkCardsKey) != $(KeyNull)
		EnumRegKey $(NetworkCardsKey) NetworkCardsList
		
		ForListDo $(NetworkCardsList)
			set CardNumber	 = *($($), 1)

			OpenRegKey $(NetworkCardsKey) "" $(CardNumber) $(MAXIMUM_ALLOWED) CardKey

			ifstr(i) $(CardKey) != $(KeyNull)
				GetRegValue $(CardKey) "ServiceName" KeyValue
				set CardServiceName = *($(KeyValue), 4)

				ifstr(i) $(CardServiceName) != $(DesiredCardServiceName)
					CloseRegKey $(CardKey)
				else
					Debug-Output "VPCNetNT: Found desired card key at "$(CardNumber)

					ifstr(i) $(ReturnedCardKey) != $(KeyNull)
						CloseRegKey $(ReturnedCardKey)
					endif
					set ReturnedCardKey	 = $(CardKey)
				endif ; $(CardServiceName) != $(DesiredCardServiceName)
			endif ; $(CardKey) != $(KeyNull)

		EndForListDo ; $(NetworkCardsList)

		CloseRegKey $(NetworkCardsKey)
	endif ; $(NetworkCardsKey) != $(KeyNull)

	Return $(ReturnedCardKey)

; ----------------------------------------------------------------------
;	CanBindToCard
;
;	This subroutine checks to see if the specified network component
;	can be bound to the specified network card
;
;	Parameters:
;		In:		$($0)	- The component name
;				$($1)	- The component's bindable rule
;				$($2)	- A handle to the network card key
;		Out:	$($R0)	- TRUE if the component can bind to the card
; ----------------------------------------------------------------------

[CanBindToCard]
	read-syms	GeneralConstants
	read-syms	FileConstants
	read-syms	FileConstants$(!STF_LANGUAGE)

	set ComponentName	 = $($0)
	set Bindable		 = $($1)
	set NetworkCardKey	 = $($2)

	Debug-Output "VPCNetNT: CanBindToCard called!"
	Debug-Output "VPCNetNT: --> ComponentName : "$(ComponentName)
	Debug-Output "VPCNetNT: --> Bindable      : "$(Bindable)

	set CanBind	 = FALSE

	;; Find the card's software product registry key
	GetRegValue $(NetworkCardKey) "Manufacturer" KeyValue
	ifint $(RegLastError) != 0
		Debug-Output "VPCNetNT: Failed to get Manufacturer key value - error "$(RegLastError)
	else
		set Manufacturer = *($(KeyValue), 4)
		GetRegValue $(NetworkCardKey) "ProductName" KeyValue
		ifint $(RegLastError) != 0
			Debug-Output "VPCNetNT: Failed to get ProductName key value - error "$(RegLastError)
		else
			set ProductName	 = *($(KeyValue), 4)

			set NetRuleKeyName	 = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductName)"\CurrentVersion\NetRules"
			OpenRegKey $(!REG_H_LOCAL) "" $(NetRuleKeyName) $(MAXIMUM_ALLOWED) NetRuleKey
			ifstr(i) $(NetRuleKey) == $(KeyNull)
				Debug-Output "VPCNetNT: Failed to open key "$(NetRuleKeyName)
			else
				GetRegValue $(NetRuleKey) "type" KeyValue
				ifint $(RegLastError) != 0
					Debug-Output "VPCNetNT: Failed to get type net rule - error "$(RegLastError)
				else
					Split-String *($(KeyValue), 4) " " TypeRule
					set CardClass	 = *($(TypeRule), 3)

					Debug-Output "VPCNetNT: The card's class is """$(CardClass)""""

					ForListDo $(Bindable)
						Split-String $($) " " EntryValue

						ifstr(i) *($(EntryValue), 1) == $(ComponentName)
							set TargetClass	 = *($(EntryValue), 3)
							
							ifstr(i) $(TargetClass) == $(CardClass)
								set CanBind	 = TRUE
							endif
							
						endif ; *($(EntryValue), 1) == $(ComponentName)
					EndForListDo ; $(Bindable)
				endif ; $(RegLastError) != 0

				CloseRegKey $(NetRuleKey)
			endif ; $(NetRuleKey) == $(KeyNull)
		endif ; $(RegLastError) != 0
	endif ; $(RegLastError) != 0

	Return $(CanBind)

; ----------------------------------------------------------------------
;	CreateVirtualNIC
;
;	This subroutine returns a list of all real network adapters in the 
;	computer.
;
;	Parameters:
;		In:		$($0)	- The name of the option being installed
;				$($1)	- The Inf filename
;				$($2)	- The title name of the NIC to which this
;				$($3)	- The installation date
;		Out:	$($R0)	- A registry error index or NO_ERROR
;				$($R1)	- A handle to the key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\N
;				$($R2)	- A handle to the key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\N\NetRule
;				$($R3)	- A handle to the key HKLM\SYSTEM\CurrentControlSet\Services\<service-name>\Parameters
;				$($R4)	- Adapter number of newly created Virtual NIC
;				$($R5)	- The service name of the newly created Virtual NIC
; ----------------------------------------------------------------------

[CreateVirtualNIC]
	read-syms	GeneralConstants
	read-syms	FileConstants
	read-syms	FileConstants$(!STF_LANGUAGE)
	read-syms	DialogConstants$(!STF_LANGUAGE)

	set Option			 = $($0)
	set InfName			 = $($1)
	set AdapterTitleBase = $($2)
	set InstallDate		 = $($3)

	Debug-Output "VPCNetNT: CreateVirtualNIC called!"
	Debug-Output "VPCNetNT: --> Option           : "$(Option)
	Debug-Output "VPCNetNT: --> InfName          : "$(InfName)
	Debug-Output "VPCNetNT: --> AdapterTitleBase : "$(AdapterTitleBase)
	Debug-Output "VPCNetNT: --> InstallDate      : "$(InstallDate)

	Shell $(UtilityInf), AddHardwareComponent, $(AdapterName), $(InfName), $(NDISMiniportProductKeyName)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "VPCNetNT: AddHardwareComponent failed - ShellCode "$($ShellCode)
		set RegistryErrorIndex	 = SETUP_FAIL
		goto CreateVirtualNIC_AddHardwareComponentFailed
	else-ifstr(i) $($R0) != NO_ERROR
		set RegistryKeyIndex	 = $($R0)
		Debug-Output "VPCNetNT: AddHardwareComponent failed - registry error "$(RegistryKeyIndex)
		goto CreateVirtualNIC_AddHardwareComponentFailed
	endif

	set AdapterKey			 = $($R1)
	set AdapterRulesKey		 = $($R2)
	set AdapterParametersKey = $($R3)
	set AdapterNumber		 = $($R4)
	set AdapterServiceName	 = $($R5)

	;; Prepend the adapter number to the adapter title
	set AdapterTitle	 = "["$(AdapterNumber)"] "$(AdapterTitleBase)

	;; Add the required adapter information to the adapter registry key
	set NewValueList	 = { +
		{"Description",		 $(NoTitle), $(!REG_VT_SZ),		 $(AdapterDescription)}, +
		{"InstallDate",		 $(NoTitle), $(!REG_VT_SZ),		 $(InstallDate)}, +
		{"Manufacturer",	 $(NoTitle), $(!REG_VT_SZ),		 $(Manufacturer)}, +
		{"OperationsSupport",$(NoTitle), $(!REG_VT_DWORD),	 $(AdapterOperationsSupport)}, +
		{"ProductName",		 $(NoTitle), $(!REG_VT_SZ),		 $(AdapterName)}, +
		{"ServiceName",		 $(NoTitle), $(!REG_VT_SZ),		 $(AdapterServiceName)}, +
		{"Title",			 $(NoTitle), $(!REG_VT_SZ),		 $(AdapterTitle)} +
	}
	Shell $(UtilityInf), AddValueList, $(AdapterKey), $(NewValueList)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "VPCNetNT: AddValueList failed - ShellCode "$($ShellCode)
		set RegistryErrorIndex	 = SETUP_FAIL
		goto CreateVirtualNIC_Failure1
	else-ifstr(i) $($R0) != NO_ERROR
		set RegistryKeyIndex	 = $($R0)
		Debug-Output "VPCNetNT: AddValueList failed - registry error "$(RegistryKeyIndex)
		goto CreateVirtualNIC_Failure1
	endif

	;; Add the appropriate entries to the NetRule subkey
	set TempProductName	 = """"$(AdapterName)$(AdapterNumber)""""
	set TempBindForm	 = $(TempProductName)$(NetRuleAdapterBindForm)
	set NewValueList	 = { +
		{"bindform",	 $(NoTitle), $(!REG_VT_SZ),	 $(TempBindForm)}, +
		{"class",		 $(NoTitle), $(!REG_VT_SZ),	 $(NetRuleAdapterClass)}, +
		{"InfOption",	 $(NoTitle), $(!REG_VT_SZ),	 $(Option)}, +
		{"type",		 $(NoTitle), $(!REG_VT_SZ),	 $(NetRuleAdapterType)} +
		}
	Shell $(UtilityInf), AddValueList, $(AdapterRulesKey), $(NewValueList)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "VPCNetNT: AddValueList failed - ShellCode "$($ShellCode)
		set RegistryErrorIndex	 = SETUP_FAIL
		goto CreateVirtualNIC_Failure1
	else-ifstr(i) $($R0) != NO_ERROR
		set RegistryKeyIndex	 = $($R0)
		Debug-Output "VPCNetNT: AddValueList failed - registry error "$(RegistryKeyIndex)
		goto CreateVirtualNIC_Failure1
	endif

	Return NO_ERROR, $(AdapterKey), $(AdapterRulesKey), $(AdapterParametersKey), $(AdapterNumber), $(AdapterServiceName)

CreateVirtualNIC_Failure1 = +
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), $(AdapterName), +
		$(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$(AdapterNumber)

CreateVirtualNIC_AddHardwareComponentFailed = +
	CloseRegKey	$(AdapterKey)
	CloseRegKey $(AdapterRulesKey)
	CloseRegKey $(AdapterParametersKey)

	Return $(RegistryErrorIndex), $(KeyNull), $(KeyNull), $(KeyNull), -1, ""

; ----------------------------------------------------------------------
;	AdjustBindings
;
;	This subroutine enables or disables the specified binding of one 
;	network component (usually a protocol) to another network component 
;	(usually a driver).
;
;	Parameters:
;		In:		$($0)	- The service name of the component whose binding
;							is to be disabled
;				$($1)	- A list of service names of the bindings to disable
;				$($2)	- "activate" or "disable"
;		Out:	$($R0)	- If TRUE, any binding was disabled; if FALSE,
;							no binding could not be disabled
; ----------------------------------------------------------------------

[AdjustBindings]
	read-syms	GeneralConstants
	read-syms	FileConstants

	set FromService		 = $($0)
	set ToServiceList	 = $($1)
	set Action			 = $($2)

	set Disabled	 = FALSE

	Debug-Output "VPCNetNT: AdjustBindings called!"
	Debug-Output "--> FromService   : "$(FromService)
	Debug-Output "--> ToServiceList : "$(ToServiceList)
	Debug-Output "--> Action        : "$(Action)

	;; Get the "From" service bindings
	ifstr(i) $(Action) == activate
		set FromServiceLinkageKeyName	 = $(!NTN_ServiceBase)"\"$(FromService)"\Linkage\Disabled"
	else
		set FromServiceLinkageKeyName	 = $(!NTN_ServiceBase)"\"$(FromService)"\Linkage"
	endif

	OpenRegKey $(!REG_H_LOCAL) "" $(FromServiceLinkageKeyName) $(MAXIMUM_ALLOWED) FromServiceLinkageKey
	ifstr(i) $(FromServiceLinkageKey) == $(KeyNull)
		Debug-Output "VPCNetNT: Failed to open linkage key "$(FromServiceLinkageKeyName)
		goto AdjustBindings_FatalError
	endif

	GetRegValue $(FromServiceLinkageKey) "Bind" KeyValue
	ifint $(RegLastError) == 0
		set Bindings	 = *($(KeyValue), 4)
	else
		set Bindings	 = {}
	endif

	CloseRegKey $(FromServiceLinkageKey)

	Debug-Output "VPCNetNT: Bindings : "$(Bindings)

	set BindingIndex	 = 0
	ForListDo $(Bindings)
		set-add BindingIndex	 = $(BindingIndex), 1
		set		CurrentBinding	 = $($)

		;; FIX ME! This won't work correctly for service names that contain the
		;; "_" character.
		Split-String $(CurrentBinding) "\_" BindingPath

		ForListDo $(ToServiceList)
			ifcontains(i) $($) in $(BindingPath)
				Debug-Output "VPCNetNT: "$(Action)" binding "$(CurrentBinding)" from "$(FromService)
				Shell $(UtilityInf), ToggleBinding, $(FromService), $(BindingIndex), $(Action)
				ifint $($ShellCode) != $(!SHELL_CODE_OK)
					Debug-Output "VPCNetNT: Failed to "$(Action)" binding! ShellCode "$($ShellCode)
				else-ifstr(i) $($R0) != NO_ERROR
					Debug-Output "VPCNetNT: Failed to "$(Action)" binding! Status "$($R0)
				else
					set-sub BindingIndex = $(BindingIndex), 1
					set		Disabled	 = TRUE
				endif
			endif 
		EndForListDo ; $(ToServiceList)
	EndForListDo ; $(Bindings)

	Return $(Disabled)

AdjustBindings_FatalError = +
	Return FALSE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -