Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1114 lines
32 KiB

  1. ;***********************************************************************
  2. ;
  3. ; OEMNSVSN.INF
  4. ;
  5. ; SNMP driver SETUP INF file.
  6. ;
  7. ; History:
  8. ; davidhov 00-Feb-1992 Created
  9. ; terryk 27-Feb-1992 Reorganize section location
  10. ; added comment
  11. ; terryk 03-Mar-1992 Changed to SNMP setup
  12. ; terryk 02-Apr-1992 Code review changed
  13. ; davidhov 03-Apr-1992 Enhanced to use new INF section
  14. ; structure from SunilP, et al.
  15. ; terryk 20-Apr-1992 Changed to SNMP inf file
  16. ; terryk 05-Jan-1994 Changed to New SNMP
  17. ; donryan 14-Mar-1996 Added SNMP Trap Service
  18. ;
  19. ;***********************************************************************
  20. ;-----------------------------------------------------------------------
  21. ; OPTION TYPE
  22. ; -----------
  23. ; This identifies the Option type we are dealing with. The different
  24. ; possible types are:
  25. ;
  26. ; COMPUTER, DISPLAY, MOUSE, KEYBOARD, LAYOUT, SCSI, PRINTER, ...
  27. ;
  28. ; Types specific to networking:
  29. ;
  30. ; NetAdapter, a netcard / adapter combination or just a netcard
  31. ; NetDriver, just a netcard driver
  32. ; NetTransport, a complete NDIS-compliant TDI transport stack
  33. ; NetService, an NT networking service
  34. ; NetWork, a complete network ensemble.
  35. ; NetProvider a complete network which supports NT MPR protocol
  36. ;-----------------------------------------------------------------------
  37. [Identification]
  38. OptionType = NetService
  39. ;-----------------------------------------------------------------------
  40. ; OPTION LIST
  41. ; -----------
  42. ; This section lists the OEM Option key names. These keys are locale
  43. ; independent and used to represent the option in a locale independent
  44. ; manner.
  45. ;
  46. ;-----------------------------------------------------------------------
  47. [Options]
  48. SNMP
  49. ;***********************************************************************
  50. ; CONSTANTS FOR USING DIALOGS
  51. ;***********************************************************************
  52. [FileConstants]
  53. ;
  54. ; File names, etc.
  55. ;
  56. UtilityInf = "UTILITY.INF"
  57. subroutineinf = "SUBROUTN.INF"
  58. SoftwareType = "service"
  59. Exit_Code = 0
  60. ;
  61. ; EventLog Message File
  62. ;
  63. NetEventDLL = "%SystemRoot%\System32\netevent.dll"
  64. IoLogMsgDLL = "%SystemRoot%\System32\IoLogMsg.dll"
  65. SNMPEXE = "%SystemRoot%\System32\snmp.exe"
  66. SNMPTRAPEXE = "%SystemRoot%\System32\snmptrap.exe"
  67. ;
  68. ; Product Info
  69. ;
  70. Manufacturer = "Microsoft"
  71. ProductMajorVersion = "4"
  72. ProductMinorVersion = "0"
  73. ProductVersion = $(ProductMajorVersion)"."$(ProductMinorVersion)
  74. ProductOpSupport = 134 ; 0x0086 ; Display,Removable,Properties,Not Updatable
  75. ;
  76. ; Software
  77. ;
  78. ProductSoftwareName = "SNMP"
  79. ProductSoftwareTitle = $(ProductSoftwareName)
  80. ProductSoftwareImagePath = $(SNMPEXE)
  81. ;
  82. ; Registry Key
  83. ;
  84. SystemService = $(!NTN_ServiceBase)
  85. ServiceKeyName = $(!NTN_ServiceBase)
  86. TCPIPKeyName = $(!NTN_ServiceBase)"\TCPIP"
  87. ProductKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
  88. [GeneralConstants]
  89. ;
  90. ; Program flow control variables.
  91. ;
  92. from = ""
  93. to = ""
  94. ;
  95. ; Return codes; Exit_Code is set to one of these
  96. ;
  97. ExitCodeOk = 0
  98. ExitCodeCancel = 1
  99. ExitCodeFatal = 2
  100. KeyNull = ""
  101. MAXIMUM_ALLOWED = 33554432
  102. RegistryErrorIndex = NO_ERROR
  103. KeyProduct = ""
  104. KeyParameters = ""
  105. TRUE = 1
  106. FALSE = 0
  107. NoTitle = 0
  108. ExitState = "Active"
  109. OldVersionExisted = $(FALSE)
  110. DriverPath = $(!STF_NTPATH)\drivers
  111. [date]
  112. ; Now is a list which contains { Sec from 1-1-1970, Year, Month, Day, Hour,
  113. ; Minute, Second }
  114. Now = {} ? $(!LIBHANDLE) GetSystemDate
  115. ;---------------------------------------------------------------------------
  116. ; 1. Identify
  117. ;
  118. ; DESCRIPTION: To verify that this INF deals with the same type of options
  119. ; as we are choosing currently.
  120. ;
  121. ; INPUT: None
  122. ;
  123. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL
  124. ; $($R1): Option Type (COMPUTER ...)
  125. ; $($R2): Diskette description
  126. ;---------------------------------------------------------------------------
  127. [Identify]
  128. ;
  129. ;
  130. read-syms Identification
  131. set Status = STATUS_SUCCESSFUL
  132. set Identifier = $(OptionType)
  133. set Media = #("Source Media Descriptions", 1, 1)
  134. Return $(Status) $(Identifier) $(Media)
  135. ;------------------------------------------------------------------------
  136. ; 2. ReturnOptions:
  137. ;
  138. ; DESCRIPTION: To return the option list supported by this INF and the
  139. ; localised text list representing the options.
  140. ;
  141. ;
  142. ; INPUT: $($0): Language used. ( ENG | FRN | ... )
  143. ;
  144. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL |
  145. ; STATUS_NOLANGUAGE
  146. ; STATUS_FAILED
  147. ;
  148. ; $($R1): Option List
  149. ; $($R2): Option Text List
  150. ;------------------------------------------------------------------------
  151. [ReturnOptions]
  152. ;
  153. ;
  154. set Status = STATUS_FAILED
  155. set OptionList = {}
  156. set OptionTextList = {}
  157. ;
  158. ; Check if the language requested is supported
  159. ;
  160. set LanguageList = ^(LanguagesSupported, 1)
  161. Ifcontains(i) $($0) in $(LanguageList)
  162. goto returnoptions
  163. else
  164. set Status = STATUS_NOLANGUAGE
  165. goto finish_ReturnOptions
  166. endif
  167. ;
  168. ; form a list of all the options and another of the text representing
  169. ;
  170. returnoptions = +
  171. set OptionList = ^(Options, 1)
  172. set OptionTextList = ^(OptionsText$($0), 1)
  173. set Status = STATUS_SUCCESSFUL
  174. finish_ReturnOptions = +
  175. Return $(Status) $(OptionList) $(OptionTextList)
  176. ;----------InstallOption-------------------------------------------------
  177. ;
  178. ; InstallOption:
  179. ;
  180. ; This section is shelled to by main installation processing
  181. ; or by NCPASHEL.INF during reconfig, removal, update, etc.
  182. ;
  183. ;
  184. ; FUNCTION: To copy files representing Options
  185. ; To configure the installed option
  186. ; To update the registry for the installed option
  187. ;
  188. ; INPUT: $($0): Language to use
  189. ; $($1): OptionID to install
  190. ; $($2): SourceDirectory
  191. ; $($3): AddCopy (YES | NO)
  192. ; $($4): DoCopy (YES | NO)
  193. ; $($5): DoConfig (YES | NO)
  194. ;
  195. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL |
  196. ; STATUS_NOLANGUAGE |
  197. ; STATUS_USERCANCEL |
  198. ; STATUS_FAILED
  199. ;
  200. ;------------------------------------------------------------------------
  201. [InstallOption]
  202. ;
  203. ; extract parameters
  204. ;
  205. set Option = $($1)
  206. set SrcDir = $($2)
  207. set AddCopy = $($3)
  208. set DoCopy = $($4)
  209. set DoConfig = $($5)
  210. ;
  211. ; Check if the language requested is supported
  212. ;
  213. set LanguageList = ^(LanguagesSupported, 1)
  214. Ifcontains(i) $($0) NOT-IN $(LanguageList)
  215. Return STATUS_NOLANGUAGE
  216. endif
  217. Debug-Output "OEMNSVSN.INF: STF_CWDIR is: "$(!STF_CWDIR)
  218. Debug-Output "OEMNSVSN.INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)
  219. ; define all the constants
  220. set-subst LF = "\n"
  221. read-syms GeneralConstants
  222. read-syms FileConstants
  223. read-syms DialogConstants$(!STF_LANGUAGE)
  224. ifstr(i) $(!NTN_Origination) == "NCPA"
  225. set Continue = $(OK)
  226. endif
  227. read-syms FileConstants$(!STF_LANGUAGE)
  228. detect date
  229. set-title $(FunctionTitle)
  230. set to = Begin
  231. set from = Begin
  232. ;
  233. ; Assume all is well.
  234. ;
  235. set CommonStatus = STATUS_SUCCESSFUL
  236. LoadLibrary "x" $(!STF_CWDDIR)\tcpcfg.dll !TCPCFG_HANDLE
  237. EndWait
  238. ;
  239. ; Set up the operation-mode-based variables and gaily welcome
  240. ; the user. If the "install mode" variable is improperly set,
  241. ; assume this is a new installation.
  242. ;
  243. Begin = +
  244. Ifstr(i) $(!NTN_InstallMode) == deinstall
  245. set StartLabel = removeadapter
  246. else-Ifstr(i) $(!NTN_InstallMode) == Update
  247. set StartLabel = UpgradeSoftware
  248. else-Ifstr(i) $(!NTN_InstallMode) == bind
  249. set StartLabel = bindingadapter
  250. else-Ifstr(i) $(!NTN_InstallMode) == configure
  251. set StartLabel = configureadapter
  252. else
  253. set StartLabel = installadapter
  254. endif
  255. set from = $(fatal)
  256. set to = $(fatal)
  257. goto $(StartLabel)
  258. ;-----------------------------------------------
  259. ; Installation Section
  260. ;-----------------------------------------------
  261. installadapter = +
  262. Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES
  263. Ifint $($ShellCode) != $(!SHELL_CODE_OK)
  264. Goto ShellCodeError
  265. Else-Ifstr(i) $($R0) == STATUS_FAILED
  266. Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
  267. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  268. goto ShellCodeError
  269. endif
  270. set Error = $($R0)
  271. Goto fatal
  272. Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
  273. Goto successful
  274. Endif
  275. Set SrcDir = $($R1)
  276. OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
  277. Ifstr $(KeyProduct) != $(KeyNull)
  278. ;
  279. ; Same version already existed in the local machine
  280. ; Popup the dialog and ask the user whether he wants to continue
  281. ;
  282. CloseRegKey $(KeyProduct)
  283. Shell $(UtilityInf), VerExistedDlg, $(ProductSoftwareTitle),+
  284. $(ProductVersion)
  285. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  286. Debug-Output "ShellCode error: cannot get an error string."
  287. goto ShellCodeError
  288. endif
  289. goto end
  290. endif
  291. OpenRegKey $(!REG_H_LOCAL) "" $(TCPIPKeyName) $(MAXIMUM_ALLOWED) TCPIPKey
  292. Ifstr $(TCPIPKey) == $(KeyNull)
  293. ;
  294. ; Tcpip section does not exist
  295. ;
  296. ; BUGBUG - snmp can now run over ipx only...
  297. ;
  298. set RegistryErrorIndex = TCPIP_NONEXIST_ERROR
  299. goto fatalregistry
  300. endif
  301. CloseRegKey $(TCPIPKey)
  302. StartWait
  303. ifstr(i) $(OldVersionExisted) == $(FALSE)
  304. install "Install-Option"
  305. ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
  306. Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
  307. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  308. goto ShellCodeError
  309. endif
  310. set Error = $($R0)
  311. goto fatal
  312. endif
  313. set OEM_ABANDON_ON = TRUE
  314. ;
  315. ; register snmp service
  316. ;
  317. Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
  318. $(ProductSoftwareName), $(ProductSoftwareName),+
  319. $(ProductSoftwareName), +
  320. $(STF_CONTEXTINFNAME), $(ProductSoftwareImagePath), "serviceauto", "",+
  321. {"Tcpip", "EventLog"}, "", $(SNMPEXE)
  322. Set SoftwareProductKey = $($R1)
  323. Set SoftwareNetRuleKey = $($R2)
  324. Set SoftwareServiceKey = $($R3)
  325. Set SoftwareParameterKey = $($R4)
  326. Set SoftLinkageKey = $($R5)
  327. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  328. Debug-Output "ShellCode error"
  329. goto ShellCodeError
  330. endif
  331. set RegistryErrorIndex = $($R0)
  332. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  333. EndWait
  334. Debug-Output "Registry error: add software components"
  335. CloseRegKey $(SoftwareProductKey)
  336. CloseRegKey $(SoftwareNetRuleKey)
  337. CloseRegKey $(SoftwareServiceKey)
  338. CloseRegKey $(SoftwareParameterKey)
  339. CloseRegKey $(SoftLinkageKey)
  340. CloseRegKey $(KeyParameters)
  341. goto fatalregistry
  342. endif
  343. ;
  344. ; add snmp service registry keys
  345. ;
  346. set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
  347. {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
  348. {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
  349. {Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitle)},+
  350. {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescription)},+
  351. {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
  352. {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductOpSupport)}, +
  353. {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
  354. Shell $(UtilityInf), AddValueList, $(SoftwareProductKey), $(NewValueList)
  355. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  356. Debug-Output "ShellCode error."
  357. goto ShellCodeError
  358. endif
  359. set RegistryErrorIndex = $($R0)
  360. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  361. EndWait
  362. Debug-Output "Resgitry error: add value list."
  363. CloseRegKey $(SoftwareProductKey)
  364. CloseRegKey $(SoftwareNetRuleKey)
  365. CloseRegKey $(SoftwareServiceKey)
  366. CloseRegKey $(SoftLinkageKey)
  367. CloseRegKey $(SoftwareParameterKey)
  368. goto fatalregistry
  369. endif
  370. ;
  371. ; add inf file to ncpa option list
  372. ;
  373. set NewValueList = {{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
  374. Shell $(UtilityInf), AddValueList, $(SoftwareNetRuleKey), $(NewValueList)
  375. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  376. Debug-Output "ShellCode error."
  377. goto ShellCodeError
  378. endif
  379. set RegistryErrorIndex = $($R0)
  380. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  381. EndWait
  382. Debug-Output "Resgitry error: add value list."
  383. CloseRegKey $(SoftwareProductKey)
  384. CloseRegKey $(SoftwareNetRuleKey)
  385. CloseRegKey $(SoftwareServiceKey)
  386. CloseRegKey $(SoftwareParameterKey)
  387. CloseRegKey $(SoftLinkageKey)
  388. goto fatalregistry
  389. endif
  390. ;
  391. ; create EnableAuthenticationTraps key under Services\SNMP\Parameters
  392. ;
  393. ; BUGBUG - why is this a key instead of value under Parameters???
  394. ;
  395. CreateRegKey $(SoftwareParameterKey) {"EnableAuthenticationTraps",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  396. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  397. {{"switch", $(NoTitle), $(!REG_VT_DWORD), "1"}}
  398. CloseRegKey $(KeyTypesSubkey)
  399. ;
  400. ; create TrapConfiguration key under Services\SNMP\Parameters
  401. ;
  402. CreateRegKey $(SoftwareParameterKey) {"TrapConfiguration",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  403. CloseRegKey $(KeyTypesSubkey)
  404. ;
  405. ; create PermittedManagers key under Services\SNMP\Parameters
  406. ;
  407. CreateRegKey $(SoftwareParameterKey) {"PermittedManagers",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  408. CloseRegKey $(KeyTypesSubkey)
  409. ;
  410. ; create ValidCommunities key under Services\SNMP\Parameters
  411. ;
  412. CreateRegKey $(SoftwareParameterKey) {"ValidCommunities",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  413. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  414. {{"1", $(NoTitle), $(!REG_VT_SZ), "public"}}
  415. CloseRegKey $(KeyTypesSubkey)
  416. ;
  417. ; create RFC1156Agent key under Services\SNMP\Parameters
  418. ;
  419. ; BUGBUG - why does this subagent have two keys (see below)???
  420. ;
  421. CreateRegKey $(SoftwareParameterKey) {"RFC1156Agent",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  422. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  423. {{"sysContact", $(NoTitle), $(!REG_VT_SZ), ""},+
  424. {"sysLocation", $(NoTitle), $(!REG_VT_SZ), ""},+
  425. {"sysServices", $(NoTitle), $(!REG_VT_DWORD), 76}}
  426. CloseRegKey $(KeyTypesSubkey)
  427. ;
  428. ; create ExtensionAgents key under Services\SNMP\Parameters
  429. ;
  430. CreateRegKey $(SoftwareParameterKey) {"ExtensionAgents",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  431. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  432. {{"1", $(NoTitle), $(!REG_VT_SZ), "SOFTWARE\Microsoft\LANManagerMIB2Agent\CurrentVersion"}, +
  433. {"2", $(NoTitle), $(!REG_VT_SZ), "SOFTWARE\Microsoft\RFC1156Agent\CurrentVersion"} +
  434. }
  435. CloseRegKey $(KeyTypesSubkey)
  436. ;
  437. ; close snmp service registry keys
  438. ;
  439. CloseRegKey $(SoftwareProductKey)
  440. CloseRegKey $(SoftwareNetRuleKey)
  441. CloseRegKey $(SoftwareServiceKey)
  442. CloseRegKey $(SoftwareParameterKey)
  443. CloseRegKey $(SoftLinkageKey)
  444. ;
  445. ; add subagent registry keys
  446. ;
  447. OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft" $(MAXIMUM_ALLOWED) MicrosoftKey
  448. ;
  449. ; create RFC1156Agent key under Software\Microsoft
  450. ;
  451. CreateRegKey $(MicrosoftKey) {"RFC1156Agent",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypes
  452. CreateRegKey $(KeyTypes) {"CurrentVersion",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  453. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  454. {{"Pathname", $(NoTitle), $(!REG_VT_EXPAND_SZ), "%SystemRoot%\System32\inetmib1.dll"}}
  455. CloseRegKey $(KeyTypesSubkey)
  456. CloseRegKey $(KeyTypes)
  457. ;
  458. ; create LANManagerMIB2Agent key under Software\Microsoft
  459. ;
  460. CreateRegKey $(MicrosoftKey) {"LANManagerMIB2Agent",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypes
  461. CreateRegKey $(KeyTypes) {"CurrentVersion",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  462. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  463. {{"Pathname", $(NoTitle), $(!REG_VT_EXPAND_SZ), "%SystemRoot%\System32\lmmib2.dll"}}
  464. CloseRegKey $(KeyTypesSubkey)
  465. CloseRegKey $(KeyTypes)
  466. ;
  467. ; create dhcp and wins registry keys using nifty subroutine
  468. ;
  469. Shell "" InstallMicrosoftAgent "WINS" "WinsMibAgent" "%SystemRoot%\System32\winsmib.dll"
  470. Shell "" InstallMicrosoftAgent "DHCPServer" "DhcpMibAgent" "%SystemRoot%\System32\dhcpmib.dll"
  471. ;
  472. ; add snmptrap service
  473. ;
  474. Shell "" AddSnmpTrapService
  475. set RegistryErrorIndex = $($R0)
  476. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  477. goto fatalregistry
  478. endif
  479. endif
  480. EndWait
  481. set FLibraryErrCtl = 1
  482. LibraryProcedure Result, $(!TCPCFG_HANDLE), CPlSnmp, $(!STF_HWND), $(!STF_GUI_UNATTENDED), $(!STF_UNATTENDED), $(!STF_UNATTENDED_SECTION)
  483. ifint $(Result) == 0
  484. set CommonStatus = STATUS_REBOOT
  485. else-ifint $(Result) == 1
  486. set CommonStatus = STATUS_REBOOT
  487. else
  488. set RegistryErrorIndex = $(Result)
  489. goto fatalregistry
  490. endif
  491. ;
  492. ; Set our master component for auto-self-removal
  493. ;
  494. Shell $(UtilityInf) SetMasterComponent Microsoft Tcpip $(STF_CONTEXTINFNAME) SNMP
  495. Goto successful
  496. ;-----------------------------------------------
  497. ; Configuration Section
  498. ;-----------------------------------------------
  499. configureadapter = +
  500. set FLibraryErrCtl = 1
  501. LibraryProcedure Result, $(!TCPCFG_HANDLE), CPlSnmp, $(!STF_HWND), "NO", "", ""
  502. ifint $(Result) == 0
  503. set CommonStatus = STATUS_NO_EFFECT
  504. else-ifint $(Result) == 1
  505. set CommonStatus = STATUS_NO_EFFECT
  506. else
  507. set RegistryErrorIndex = $(Result)
  508. goto fatalregistry
  509. endif
  510. goto successful
  511. ;-----------------------------------------------
  512. ; Binding section
  513. ;-----------------------------------------------
  514. bindingadapter =+
  515. set Error = "Binding: Sorry, not yet implemented."
  516. goto fatal
  517. ;-----------------------------------------------
  518. ; Removeadapter section
  519. ;-----------------------------------------------
  520. removeadapter = +
  521. ;
  522. ; remove snmp service
  523. ;
  524. Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
  525. $(ProductSoftwareName)
  526. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  527. Debug-Output "ShellCode error"
  528. goto ShellCodeError
  529. endif
  530. set RegistryErrorIndex = $($R0)
  531. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  532. goto fatalregistry
  533. endif
  534. ;
  535. ; delete subagent keys from Software\Microsoft
  536. ;
  537. OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft" $(MAXIMUM_ALLOWED) MicrosoftKey
  538. ;
  539. ; delete RFC1156Agent key from Software\Microsoft
  540. ;
  541. DeleteRegTree $(MicrosoftKey) "RFC1156Agent"
  542. ;
  543. ; delete LANManagerMIB2Agent key from Software\Microsoft
  544. ;
  545. DeleteRegTree $(MicrosoftKey) "LANManagerMIB2Agent"
  546. CloseRegKey $(MicrosoftKey)
  547. ;
  548. ; remove snmptrap service
  549. ;
  550. Shell "" RemoveSnmpTrapService
  551. set RegistryErrorIndex = $($R0)
  552. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  553. goto fatalregistry
  554. endif
  555. goto end
  556. ;-----------------------------------------------
  557. ; Upgrade Software section
  558. ;-----------------------------------------------
  559. UpgradeSoftware = +
  560. ; Upgrade software component
  561. ;
  562. ; Update the old key information. These moves it from a protocol to a service
  563. Set SNMPKeyName = "Software\Microsoft\SNMP\CurrentVersion\NetRules"
  564. Set MaskAllAccess = 33554432
  565. Set ValueName = "InfName"
  566. Set NewInfName = "oemnsvsn.inf"
  567. OpenRegKey $(!REG_H_LOCAL) "" $(SNMPKeyName) $(MaskAllAccess) SNMPKey
  568. Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
  569. SetRegValue $(SNMPKey) {$(ValueName),0,$(!REG_VT_SZ),$(NewInfName)}
  570. CloseRegKey $(SNMPKey)
  571. Set CacheKey = "SOFTWARE\Microsoft\Ncpa\InfOptions"
  572. Set CacheValue = "oemnxpsn.inf"
  573. OpenRegKey $(!REG_H_LOCAL) "" $(CacheKey) $(MaskAllAccess) Cache
  574. Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
  575. DeleteRegTree $(Cache) $(CacheValue)
  576. CloseRegKey $(Cache)
  577. endif
  578. endif
  579. OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
  580. Ifstr $(KeyProduct) != $(KeyNull)
  581. install "Install-Update"
  582. ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
  583. goto fatal
  584. endif
  585. ; upgrade version number
  586. ;
  587. SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
  588. SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}
  589. ; Fixup software type, old versions of NT has it has a protocol
  590. ;
  591. SetRegValue $(KeyProduct) {SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)}
  592. ;
  593. ; Update description and op support
  594. ;
  595. SetRegValue $(KeyProduct) {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescription)}
  596. SetRegValue $(KeyProduct) {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductOpSupport)}
  597. ;
  598. ; close registry key
  599. ;
  600. CloseRegKey $(KeyProduct)
  601. ;
  602. ; need to add snmptrap service for update
  603. ;
  604. Shell "" AddSnmpTrapService
  605. set RegistryErrorIndex = $($R0)
  606. Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
  607. goto fatalregistry
  608. endif
  609. else
  610. ;
  611. ; Cannot Open software key, goto ERROR
  612. ;
  613. goto fatalregistry
  614. endif
  615. goto end
  616. ;
  617. ; End of Upgrade Software
  618. ;
  619. ;
  620. ; Escape hatches
  621. ;
  622. successful = +
  623. goto end
  624. ;
  625. ; warning display
  626. ;
  627. warning = +
  628. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
  629. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  630. goto ShellCodeError
  631. endif
  632. ifstr(i) $($R1) == "OK"
  633. goto $(to)
  634. else-ifstr(i) $($R1) == "CANCEL"
  635. goto $(from)
  636. else
  637. ; Debug-Msg "Error Error Bad DLGEVENT"
  638. goto "end"
  639. endif
  640. ;
  641. ; non fatal error display
  642. ;
  643. nonfatal = +
  644. ifstr(i) $(Error) == ""
  645. Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
  646. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  647. goto ShellCodeError
  648. endif
  649. set Error = $($R0)
  650. endif
  651. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "NONFATAL", $(Error)
  652. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  653. goto ShellCodeError
  654. endif
  655. ifstr(i) $($R1) == "OK"
  656. goto $(from)
  657. else
  658. goto "end"
  659. endif
  660. ;
  661. ; Registry is broken
  662. ;
  663. fatalregistry = +
  664. Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
  665. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  666. goto ShellCodeError
  667. endif
  668. set Error = $($R0)
  669. goto fatal
  670. ;
  671. ; fatal error display
  672. ;
  673. fatal = +
  674. ifstr(i) $(Error) == ""
  675. Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
  676. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  677. goto ShellCodeError
  678. endif
  679. set Error = $($R0)
  680. endif
  681. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
  682. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  683. goto ShellCodeError
  684. endif
  685. goto setfailed
  686. ;
  687. ; Shelling error
  688. ;
  689. ShellCodeError = +
  690. set DlgType = "MessageBox"
  691. set STF_MB_TITLE = $(ShellCodeErrorTitle)
  692. set STF_MB_TEXT = $(ShellCodeErrorText)
  693. set STF_MB_TYPE = 1
  694. set STF_MB_ICON = 3
  695. set STF_MB_DEF = 1
  696. ui start "Error Message"
  697. goto setfailed
  698. setfailed = +
  699. set CommonStatus = STATUS_FAILED
  700. Ifint $(RegistryErrorIndex) == TCPIP_NONEXIST_ERROR
  701. set CommonStatus = STATUS_USERCANCEL
  702. endif
  703. ;
  704. ; If OEM_ABANDON_ON, we need to clean up the registry
  705. ;
  706. ifstr(i) $(OEM_ABANDON_ON) == TRUE
  707. set OEM_ABANDON_ON = FALSE
  708. goto removeadapter
  709. endif
  710. goto end
  711. end = +
  712. freeLibrary $(!TCPCFG_HANDLE)
  713. goto term
  714. term = +
  715. Return $(CommonStatus)
  716. ;***************************************************************
  717. ; Get File Size SECTIONS
  718. ;***************************************************************
  719. [GetFilesSize]
  720. set FileSizeList = ^(Files-SNMP,3)
  721. set TotalSize = 0
  722. ForListDo $(FileSizeList)
  723. Split-String $($) "=" SplitString
  724. set Size = *($(SplitString),3)
  725. set-add TotalSize = $(TotalSize) $(Size)
  726. EndForListDo
  727. set-div SizeInK = $(TotalSize) 1024
  728. return $(SizeInK)
  729. ;***************************************************************
  730. ; INSTALL SECTIONS
  731. ;***************************************************************
  732. [Install-Option]
  733. set STF_VITAL = ""
  734. ifstr(i) $(AddCopy) == "YES"
  735. ;
  736. ; Add the files to the copy list
  737. ;
  738. ; BUGBUG: eliminate the "nt2" in the next line when Sunil fixes
  739. ; the other INF files
  740. ;
  741. AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)
  742. endif
  743. ifstr(i) $(DoCopy) == "YES"
  744. ;
  745. ; Copy files in the copy list
  746. ;
  747. set !STF_NCPA_FLUSH_COPYLIST = TRUE
  748. CopyFilesInCopyList
  749. endif
  750. ifstr(i) $(DoConfig) == "YES"
  751. ;
  752. ; Add product to registry
  753. ;
  754. ;
  755. ; Finish up
  756. endif
  757. Exit
  758. [Install-Update]
  759. set STF_VITAL = ""
  760. set STF_OVERWRITE = "VERIFYSOURCEOLDER"
  761. ;set STF_VERSION = "YES"
  762. AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)
  763. exit
  764. [InstallMicrosoftAgent]
  765. read-syms GeneralConstants
  766. read-syms FileConstants
  767. set AServiceName = $($0)
  768. set AAgentName = $($1)
  769. set APath = $($2)
  770. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\SNMP" $(MAXIMUM_ALLOWED) SNMPKey
  771. ifstr(i) $(SNMPKey) != ""
  772. CloseRegKey $(SNMPKey)
  773. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$(AServiceName) $(MAXIMUM_ALLOWED) ServiceKey
  774. ifstr(i) $(ServiceKey) != ""
  775. CloseRegKey $(ServiceKey)
  776. ;
  777. ; Set up agents information
  778. ;
  779. OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft" $(MAXIMUM_ALLOWED) MicrosoftKey
  780. ;
  781. ; Create Agent
  782. ;
  783. CreateRegKey $(MicrosoftKey) {$(AAgentName),$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypes
  784. CreateRegKey $(KeyTypes) {"CurrentVersion",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  785. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  786. {{"Pathname", $(NoTitle), $(!REG_VT_EXPAND_SZ), $(APath)}}
  787. CloseRegKey $(KeyTypesSubkey)
  788. CloseRegKey $(KeyTypes)
  789. CloseRegKey $(MicrosoftKey)
  790. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\SNMP\Parameters" $(MAXIMUM_ALLOWED) SNMPParmKey
  791. ;
  792. ; Create Agent parameter
  793. ;
  794. CreateRegKey $(SNMPParmKey) {$(AAgentName),$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyTypesSubkey
  795. CloseRegKey $(KeyTypesSubkey)
  796. CloseRegKey $(SNMPParmKey)
  797. ;
  798. ; Create ExtensionAgents
  799. ;
  800. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents" $(MAXIMUM_ALLOWED) KeyTypesSubkey
  801. EnumRegValue $(KeyTypesSubkey) AgentsList
  802. set Pos = 1
  803. ForListDo $(AgentsList)
  804. set-add Pos = $(Pos), 1
  805. EndForListDo
  806. Shell $(UtilityInf) AddValueList, $(KeyTypesSubkey), +
  807. {{$(Pos), $(NoTitle), $(!REG_VT_SZ), "SOFTWARE\Microsoft\"$(AAgentName)"\CurrentVersion"}}
  808. CloseRegKey $(KeyTypesSubkey)
  809. endif
  810. endif
  811. return
  812. [RemoveMicrosoftAgent]
  813. read-syms GeneralConstants
  814. read-syms FileConstants
  815. set AAgentName = $($0)
  816. ;
  817. ; Remove Agent if exist
  818. ;
  819. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\SNMP" $(MAXIMUM_ALLOWED) SNMPKey
  820. ifstr(i) $(SNMPKey) != ""
  821. CloseRegKey $(SNMPKey)
  822. ;
  823. ; Remove agent information
  824. ;
  825. OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft" $(MAXIMUM_ALLOWED) MicrosoftKey
  826. DeleteRegTree $(MicrosoftKey) $(AAgentName)
  827. CloseRegKey $(MicorosoftKey)
  828. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\SNMP\Parameters" $(MAXIMUM_ALLOWED) SNMPParmKey
  829. DeleteRegKey $(SNMPParmKey) $(AAgentName)
  830. OpenRegKey $(SNMPParmKey) "" "ExtensionAgents" $(MAXIMUM_ALLOWED) AgentKey
  831. EnumRegValue $(AgentKey) AgentsList
  832. ForListDo $(AgentsList)
  833. Split-String *($($),4), "\", AgentInfo
  834. ifContains(i) $(AAgentName) in $(AgentInfo)
  835. DeleteRegValue $(AgentKey) *($($),1)
  836. endif
  837. EndForListDo
  838. CloseRegKey $(AgentKey)
  839. CloseRegKey $(SNMPParmKey)
  840. endif
  841. return
  842. [AddSnmpTrapService]
  843. read-syms GeneralConstants
  844. read-syms FileConstants
  845. ;
  846. ; local constants
  847. ;
  848. Set TrapServiceName = "SNMPTRAP"
  849. Set TrapServiceDisplayName = "SNMP Trap Service"
  850. Set TrapServiceImagePath = $(SNMPTRAPEXE)
  851. ;
  852. ; register snmp trap service
  853. ;
  854. Debug-Output "OEMNSVSN.INF: Before CreateService"
  855. Shell $(UtilityInf), CreateService, +
  856. $(TrapServiceName), +
  857. $(TrapServiceDisplayName), +
  858. $(TrapServiceImagePath), +
  859. "service", +
  860. "",+
  861. {"Tcpip", "EventLog"}, +
  862. "", +
  863. $(SNMPTRAPEXE)
  864. Debug-Output "OEMNSVSN.INF: After CreateService"
  865. Debug-Output "OEMNSVSN.INF: R0 from CreateService "$($R0)
  866. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  867. Debug-Output "OEMNSVSN.INF: ShellCode error"
  868. goto ShellCodeError
  869. endif
  870. Set RegistryErrorIndex = $($R0)
  871. Set SoftwareServiceKey = $($R1)
  872. Set SoftwareParameterKey = $($R2)
  873. Set SoftwareLinkageKey = $($R3)
  874. ;
  875. ; close snmptrap service registry keys only if RegistryErrorIndex is not NO_ERROR
  876. ;
  877. ifstr(i) $(RegistryErrorIndex) == NO_ERROR
  878. CloseRegKey $(SoftwareServiceKey)
  879. CloseRegKey $(SoftwareParameterKey)
  880. CloseRegKey $(SoftwareLinkageKey)
  881. endif
  882. ;
  883. ; do not fail if service already installed
  884. ;
  885. Ifstr(i) $(RegistryErrorIndex) == SERVICE_ALREADY_EXISTS
  886. Set RegistryErrorIndex = NO_ERROR
  887. Endif
  888. ;
  889. ; let caller handle error
  890. ;
  891. Return $(RegistryErrorIndex)
  892. [RemoveSnmpTrapService]
  893. read-syms GeneralConstants
  894. read-syms FileConstants
  895. ;
  896. ; local constants
  897. ;
  898. Set TrapServiceName = "SNMPTRAP"
  899. ;
  900. ; remove snmp trap service
  901. ;
  902. Shell $(UtilityInf), RemoveService, $(TrapServiceName), "YES"
  903. Set RegistryErrorIndex = $($R0)
  904. ;
  905. ; let caller handle error
  906. ;
  907. Return $(RegistryErrorIndex)