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.

902 lines
28 KiB

  1. ;***********************************************************************
  2. ;
  3. ; NBINFO.INF
  4. ;
  5. ; NETBIOS LANA number and provider management inf file.
  6. ;
  7. ; History:
  8. ;
  9. ;***********************************************************************
  10. ;-----------------------------------------------------------------------
  11. ; OPTION TYPE
  12. ; -----------
  13. ; This identifies the Option type we are dealing with. The different
  14. ; possible types are:
  15. ;
  16. ; COMPUTER, DISPLAY, MOUSE, KEYBOARD, LAYOUT, SCSI, PRINTER, ...
  17. ;
  18. ; Types specific to networking:
  19. ;
  20. ; NetAdapter, a netcard / adapter combination or just a netcard
  21. ; NetDriver, just a netcard driver
  22. ; NetTransport, a complete NDIS-compliant TDI transport stack
  23. ; NetService, an NT networking service
  24. ; NetWork, a complete network ensemble.
  25. ; NetProvider a complete network which supports NT MPR protocol
  26. ;-----------------------------------------------------------------------
  27. [Identification]
  28. OptionType = NetProvider
  29. ;-----------------------------------------------------------------------
  30. ; OPTION LIST
  31. ; -----------
  32. ; This section lists the OEM Option key names. These keys are locale
  33. ; independent and used to represent the option in a locale independent
  34. ; manner.
  35. ;
  36. ;-----------------------------------------------------------------------
  37. [Options]
  38. NETBIOS
  39. ;***********************************************************************
  40. ; CONSTANTS FOR USING DIALOGS
  41. ;***********************************************************************
  42. [FileConstants]
  43. ;
  44. ; File names, etc.
  45. ;
  46. UtilityInf = "UTILITY.INF"
  47. subroutineinf = "SUBROUTN.INF"
  48. SoftwareType = "driver"
  49. Exit_Code = 0
  50. ;ShellCode = 0
  51. ;
  52. ; EventLog Message File
  53. ;
  54. NetEventDLL = "%SystemRoot%\System32\netevent.dll"
  55. IoLogMsgDLL = "%SystemRoot%\System32\IoLogMsg.dll"
  56. ;
  57. ; Product Info
  58. ;
  59. Manufacturer = "Microsoft"
  60. ProductMajorVersion = "4"
  61. ProductMinorVersion = "0"
  62. ProductVersion = $(ProductMajorVersion)"."$(ProductMinorVersion)
  63. ;
  64. ; Registry Key
  65. ;
  66. ProductKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
  67. ParamKeyName = $(!NTN_ServiceBase)$(ProductHardwareName)"\Parameters"
  68. ;
  69. ; Misc
  70. ;
  71. NbProviderField = "NbProvider"
  72. EndPointField = "EndPoint"
  73. RouteField = "Route"
  74. ExportField = "Export"
  75. [GeneralConstants]
  76. ;
  77. ; Program flow control variables.
  78. ;
  79. from = ""
  80. to = ""
  81. ;
  82. ; Return codes; Exit_Code is set to one of these
  83. ;
  84. ExitCodeOk = 0
  85. ExitCodeCancel = 1
  86. ExitCodeFatal = 2
  87. KeyNull = ""
  88. MAXIMUM_ALLOWED = 33554432
  89. RegistryErrorIndex = NO_ERROR
  90. KeyProduct = ""
  91. KeyParameters = ""
  92. TRUE = 1
  93. FALSE = 0
  94. NoTitle = 0
  95. ExitState = "Active"
  96. OldVersionExisted = $(FALSE)
  97. DriverPath = $(!STF_NTPATH)\drivers
  98. [date]
  99. ; Now is a list which contains { Sec from 1-1-1970, Year, Month, Day, Hour,
  100. ; Minute, Second }
  101. Now = {} ? $(!LIBHANDLE) GetSystemDate
  102. ;---------------------------------------------------------------------------
  103. ; 1. Identify
  104. ;
  105. ; DESCRIPTION: To verify that this INF deals with the same type of options
  106. ; as we are choosing currently.
  107. ;
  108. ; INPUT: None
  109. ;
  110. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL
  111. ; $($R1): Option Type (COMPUTER ...)
  112. ; $($R2): Diskette description
  113. ;---------------------------------------------------------------------------
  114. [Identify]
  115. ;
  116. ;
  117. read-syms Identification
  118. set Status = STATUS_SUCCESSFUL
  119. set Identifier = $(OptionType)
  120. set Media = #("Source Media Descriptions", 1, 1)
  121. Return $(Status) $(Identifier) $(Media)
  122. ;------------------------------------------------------------------------
  123. ; 2. ReturnOptions:
  124. ;
  125. ; DESCRIPTION: To return the option list supported by this INF and the
  126. ; localised text list representing the options.
  127. ;
  128. ;
  129. ; INPUT: $($0): Language used. ( ENG | FRN | ... )
  130. ;
  131. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL |
  132. ; STATUS_NOLANGUAGE
  133. ; STATUS_FAILED
  134. ;
  135. ; $($R1): Option List
  136. ; $($R2): Option Text List
  137. ;------------------------------------------------------------------------
  138. [ReturnOptions]
  139. ;
  140. ;
  141. set Status = STATUS_FAILED
  142. set OptionList = {}
  143. set OptionTextList = {}
  144. ;
  145. ; Check if the language requested is supported
  146. ;
  147. set LanguageList = ^(LanguagesSupported, 1)
  148. Ifcontains(i) $($0) in $(LanguageList)
  149. goto returnoptions
  150. else
  151. set Status = STATUS_NOLANGUAGE
  152. goto finish_ReturnOptions
  153. endif
  154. ;
  155. ; form a list of all the options and another of the text representing
  156. ;
  157. returnoptions = +
  158. set OptionList = ^(Options, 1)
  159. set OptionTextList = ^(OptionsText$($0), 1)
  160. set Status = STATUS_SUCCESSFUL
  161. finish_ReturnOptions = +
  162. Return $(Status) $(OptionList) $(OptionTextList)
  163. ;***********************************************************************
  164. ; SETUP (NTLANMAN) INVOCATION SECTION
  165. ;***********************************************************************
  166. ;------------------------------------------------------------------------
  167. ;
  168. ; InstallOption:
  169. ;
  170. ; This section is shelled to by main installation processing.
  171. ;
  172. ;
  173. ; FUNCTION: To copy files representing Options
  174. ; To configure the installed option
  175. ; To update the registry for the installed option
  176. ;
  177. ; INPUT: $($0): Language to use
  178. ; $($1): OptionID to install
  179. ; $($2): SourceDirectory
  180. ; $($3): AddCopy (YES | NO)
  181. ; $($4): DoCopy (YES | NO)
  182. ; $($5): DoConfig (YES | NO)
  183. ;
  184. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL |
  185. ; STATUS_NOLANGUAGE |
  186. ; STATUS_USERCANCEL |
  187. ; STATUS_FAILED
  188. ;
  189. ;------------------------------------------------------------------------
  190. [InstallOption]
  191. ;
  192. ; Set default values for
  193. ;
  194. set Status = STATUS_FAILED
  195. ;
  196. ; extract parameters
  197. ;
  198. set Option = $($1)
  199. set SrcDir = $($2)
  200. set AddCopy = $($3)
  201. set DoCopy = $($4)
  202. set DoConfig = $($5)
  203. ;
  204. ; Check if the language requested is supported
  205. ;
  206. set LanguageList = ^(LanguagesSupported, 1)
  207. Ifcontains(i) $($0) NOT-IN $(LanguageList)
  208. Return STATUS_NOLANGUAGE
  209. endif
  210. ;
  211. ; Call the CommonSection
  212. ;
  213. Shell "" CommonSection $(Option) $(SrcDir) $(AddCopy) $(DoCopy) $(DoConfig)
  214. set Status = $($R0)
  215. Return $(Status)
  216. [BindingsReview]
  217. ;
  218. ; extract parameters
  219. ;
  220. set Option = $($1)
  221. set SrcDir = $($2)
  222. set AddCopy = $($3)
  223. set DoCopy = $($4)
  224. set DoConfig = $($5)
  225. Shell "" CommonSection $(Option) $(SrcDir) $(AddCopy) $(DoCopy) $(DoConfig)
  226. set Status = $($R0)
  227. Return $(Status)
  228. ;***********************************************************************
  229. ; COMMON SECTION
  230. ;***********************************************************************
  231. ;------------------------------------------------------------------------
  232. ;
  233. ; CommonSection:
  234. ;
  235. ; This section is shelled to from above by this INF.
  236. ;
  237. ;
  238. ; FUNCTION: To copy files representing Options
  239. ; To configure the installed option
  240. ; To update the registry for the installed option
  241. ;
  242. ; INPUT: $($1): OptionID to install
  243. ; $($2): SourceDirectory
  244. ; $($3): AddCopy (YES | NO)
  245. ; $($4): DoCopy (YES | NO)
  246. ; $($5): DoConfig (YES | NO)
  247. ;
  248. ; OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL |
  249. ; STATUS_NOLANGUAGE |
  250. ; STATUS_USERCANCEL |
  251. ; STATUS_FAILED
  252. ;
  253. ;------------------------------------------------------------------------
  254. [CommonSection]
  255. StartWait
  256. ;
  257. ; extract parameters
  258. ;
  259. set Option = $($1)
  260. set SrcDir = $($2)
  261. set AddCopy = $($3)
  262. set DoCopy = $($4)
  263. set DoConfig = $($5)
  264. ; define all the constants
  265. set-subst LF = "\n"
  266. read-syms GeneralConstants
  267. read-syms FileConstants
  268. read-syms DialogConstants$(!STF_LANGUAGE)
  269. read-syms FileConstants$(!STF_LANGUAGE)
  270. detect date
  271. set-title $(FunctionTitle)
  272. set to = Begin
  273. set from = Begin
  274. ;
  275. ; Assume all is well.
  276. ;
  277. set CommonStatus = STATUS_SUCCESSFUL
  278. ;
  279. ; Set up the operation-mode-based variables and gaily welcome
  280. ; the user. If the "install mode" variable is improperly set,
  281. ; assume this is a new installation.
  282. ;
  283. Begin = +
  284. ;
  285. ; Open Service key
  286. ;
  287. OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase) $(MAXIMUM_ALLOWED) ServiceKey
  288. Ifstr $(ServiceKey) == $(KeyNull)
  289. set RegistryErrorIndex = $($R0)
  290. goto fatalregistry
  291. endif
  292. ;
  293. ; Set the result values to {empty}
  294. ;
  295. ; List of Route strings from NetBIOS; element form {<NetBIOS linkage route string>}
  296. ;
  297. Set RouteInformationList = {}
  298. ;
  299. ; Get the Linkage information from the NetBIOS service. If the NetBIOS key doesn't
  300. ; exist, then assume we're not wanted and exit quietly.
  301. ;
  302. OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NetBIOS\Linkage" $(MAXIMUM_ALLOWED) NbKey
  303. Ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
  304. ;
  305. ; NetBIOS service isn't present. Bail out.
  306. ;
  307. Debug-Output "NBINFO.INF: could not open CurrentControlSet\Services\NetBIOS\Linkage key"
  308. goto successful
  309. Endif
  310. ;
  311. ; First the active bindings Route data.
  312. ;
  313. GetRegValue $(NbKey) Route RouteListValue
  314. Ifint $(RegLastError) != 0
  315. Debug-Output "NBINFO.INF: Error reading NetBIOS\Linkage:Route value: "$(RegLastError)
  316. Set RouteList = {}
  317. Else
  318. Set RouteList = *($(RouteListValue),4)
  319. Endif
  320. set ActiveRouteList = $(RouteList)
  321. ForListDo $(RouteList)
  322. Debug-Output "NBINFO.INF: Adding NetBIOS route value: "$($)
  323. Set RouteInformationList = >($(RouteInformationList),$($))
  324. EndForListDo
  325. ;
  326. ; Read the disabled binding route information; add it to the list
  327. ;
  328. OpenRegKey $(NbKey) "" "Disabled" $(MAXIMUM_ALLOWED) NbDisKey
  329. Ifstr(i) $(NbDisKey) != $(KeyNull)
  330. Set RouteList = {}
  331. GetRegValue $(NbDisKey) Route RouteListValue
  332. Ifint $(RegLastError) == 0
  333. Set RouteList = *($(RouteListValue),4)
  334. Endif
  335. ForListDo $(RouteList)
  336. Debug-Output "NBINFO.INF: Adding DISABLED NetBIOS route value: "$($)
  337. Set RouteInformationList = >($(RouteInformationList),$($))
  338. EndForListDo
  339. CloseRegKey $(NbDisKey)
  340. Endif
  341. CloseRegKey $(NbKey)
  342. Debug-Output "NBINFO.INF: open N/B info service"
  343. ;
  344. ; Open the service key in registry.
  345. ; If key isn't there, perform [CreateService].
  346. ;
  347. ; Leave the Parameters key open for later use.
  348. ;
  349. OpenRegKey $(ServiceKey) "" "NetBIOSInformation" $(MAXIMUM_ALLOWED) NetBIOSKey
  350. Ifstr(i) $(NetBIOSKey) == ""
  351. Shell $(UtilityInf), CreateService, "NetBIOSInformation", "NetBIOSInformation", "", "adapter", "", {}, ""
  352. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  353. Debug-Output "NBINFO.INF: Shell error creating service"
  354. goto ShellCodeError
  355. endif
  356. set RegistryErrorIndex = $($R0)
  357. Set ParameterKey = $($R2)
  358. CloseRegKey $($R1)
  359. CloseRegKey $($R3)
  360. Else
  361. ;
  362. ; Create the Linkage and Parameters keys.
  363. ;
  364. OpenRegKey $(NetBIOSKey) "" "Linkage" $(MAXIMUM_ALLOWED) LinkageKey
  365. Ifstr(i) $(LinkageKey) == $(KeyNull)
  366. CreateRegKey $(NetBIOSKey) { "Linkage", $(NoTitle), GenericClass } "" $(MAXIMUM_ALLOWED) "" LinkageKey
  367. Endif
  368. CloseRegKey $(LinkageKey)
  369. OpenRegKey $(NetBIOSKey) "" "Parameters" $(MAXIMUM_ALLOWED) ParameterKey
  370. Ifstr(i) $(ParameterKey) == $(KeyNull)
  371. CreateRegKey $(NetBIOSKey) { "Parameters", $(NoTitle), GenericClass } "" $(MAXIMUM_ALLOWED) "" ParameterKey
  372. Endif
  373. CloseRegKey $(NetBIOSKey)
  374. Endif
  375. Ifstr(i) $(ParameterKey) == $(KeyNull)
  376. read-syms FatalError1$(!STF_LANGUAGE)
  377. goto fatal
  378. Endif
  379. ;
  380. ; Prune old information from NetBIOSInformation\Parameters key.
  381. ;
  382. ; Iterate the Route list. Any routes found which are not currently associated
  383. ; with the NetBIOS service are removed, along with their LanaNum<n> and EnumExport<n>
  384. ; values.
  385. ;
  386. GetRegValue $(ParameterKey) "Route" OrigRouteValue
  387. Ifint $(RegLastError) == 0
  388. Set OrigRouteList = *($(OrigRouteValue), 4)
  389. ifstr(i) $(OrigRouteList) == ""
  390. set OrigRouteList = {}
  391. Endif
  392. Set OrigIndex = 0
  393. Set NewIndex = 0
  394. Set AnyChanges = 0
  395. Set CurrentRouteList = {}
  396. Set NewValueList = {}
  397. ForListDo $(OrigRouteList)
  398. Set-add OrigIndex = $(OrigIndex),1
  399. Set ThisOrigRoute = $($)
  400. ifContains(i) $(ThisOrigRoute) NOT-IN $(RouteInformationList)
  401. ;
  402. ; A route value has disappeared from the NetBIOS service.
  403. ; Remove the corresponding LanaNum and EnumExport values.
  404. ;
  405. Debug-Output "NBINFO.INF: Removing info for old route: "$(ThisOrigRoute)", index "$(OrigIndex)
  406. DeleteRegValue $(ParameterKey) LanaNum$(OrigIndex)
  407. DeleteRegValue $(ParameterKey) EnumExport$(OrigIndex)
  408. Set AnyChanges = 1
  409. Else
  410. Set CurrentRouteList = >($(CurrentRouteList),$(ThisOrigRoute))
  411. Set-add NewIndex = $(NewIndex),1
  412. GetRegValue $(ParameterKey) LanaNum$(OrigIndex) OrigLanaValue
  413. Set OrigLanaNum = *($(OrigLanaValue),4)
  414. GetRegValue $(ParameterKey) EnumExport$(OrigIndex) OrigExportValue
  415. Set OrigExport = *($(OrigExportValue),4)
  416. set NewValueList = >($(NewValueList),{LanaNum$(NewIndex), $(NoTitle), $(!REG_VT_DWORD), $(OrigLanaNum) })
  417. set NewValueList = >($(NewValueList),{EnumExport$(NewIndex), $(NoTitle), $(!REG_VT_DWORD), $(OrigExport)})
  418. Endif
  419. EndForListDo
  420. Ifint $(AnyChanges) != 0
  421. DeleteNextOldLana = +
  422. Ifint $(NewIndex) <= $(OrigIndex)
  423. Debug-Output "NBINFO.INF: pruning old lana info for index = "$(NewIndex)
  424. DeleteRegValue $(ParameterKey) LanaNum$(NewIndex)
  425. DeleteRegValue $(ParameterKey) EnumExport$(NewIndex)
  426. Set-add NewIndex = $(NewIndex),1
  427. Goto DeleteNextOldLana
  428. Endif
  429. Debug-Output "NBINFO.INF: updating Route, LanaNumX and EnumExportX after pruning"
  430. Set NewValueList = >($(NewValueList),{Route, $(NoTitle), $(!REG_VT_MULTI_SZ), $(CurrentRouteList)})
  431. Shell $(UtilityInf), AddValueList, $(ParameterKey), $(NewValueList)
  432. Endif
  433. Endif
  434. ;
  435. ; Get the registry values; algorithm:
  436. ;
  437. ; Read the existing information into a list.
  438. ;
  439. Debug-Output "NBINFO.INF: Access N/B info route data"
  440. GetRegValue $(ParameterKey) "Route" OldRouteValue
  441. set OldRouteList = *($(OldRouteValue), 4)
  442. ifstr(i) $(OldRouteList) == ""
  443. set OldRouteList = {}
  444. Endif
  445. Debug-Output "NBINFO.INF: Enumerate N/B info lananums"
  446. EnumRegValue $(ParameterKey) ParameterValue
  447. Set HighLana = 0
  448. set UsedLanaNum = {}
  449. ForListDo $(ParameterValue)
  450. set LanaNumName = *($($), 1)
  451. Set LanaNumNum = *($($), 4)
  452. LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp $(LanaNumName) "LanaNum" 7
  453. ifint $(Result) == 0
  454. Ifint $(HighLana) < $(LanaNumNum)
  455. Set HighLana = $(LanaNumNum)
  456. Endif
  457. set UsedLanaNum = >($(UsedLanaNum),$(LanaNumNum))
  458. ;
  459. ; remember the zero position
  460. ;
  461. ifint $(LanaNumNum) == 0
  462. set LanaZeroNum = $(LanaNumName)
  463. endif
  464. ;
  465. ; declare a variable for RPC support: "RpcLanaNum<n> = <n>"
  466. ;
  467. Set Rpc$(LanaNumName) = $(LanaNumNum)
  468. endif
  469. EndForListDo
  470. Set NewValueList = {}
  471. Set RpcLanaList = {}
  472. Set RpcProtoList = {}
  473. QueryListSize Position $(OldRouteList)
  474. Set LanaNum = 0
  475. Set AnyChanges = 0
  476. Set LanaXnsNum = ""
  477. ForListDo $(RouteInformationList)
  478. Set ThisRoute = $($)
  479. ifContains(i) $(ThisRoute) NOT-IN $(OldRouteList)
  480. ;
  481. ; New route; add it to the old list.
  482. ; Then find first unused LanaNum.
  483. ;
  484. Debug-Output "NBINFO.INF: New route to be added: "$(ThisRoute)
  485. Set-add Position = $(Position), 1
  486. Set OldRouteList = >($(OldRouteList), $(ThisRoute))
  487. Set AnyChanges = 1
  488. TryAgain = +
  489. ifContains(i) $(LanaNum) IN $(UsedLanaNum)
  490. set-add LanaNum = $(LanaNum), 1
  491. goto TryAgain
  492. else
  493. ifint $(LanaNum) == 0
  494. set LanaZeroNum = "LanaNum"$(Position)
  495. endif
  496. Debug-Output "NBINFO.INF: LanaNum "$(LanaNum)" assigned to "$(ThisRoute)
  497. set NewValueList = >($(NewValueList),{LanaNum$(Position), $(NoTitle), $(!REG_VT_DWORD), $(LanaNum) })
  498. set NewValueList = >($(NewValueList),{EnumExport$(Position), $(NoTitle), $(!REG_VT_DWORD), 1})
  499. set UsedLanaNum = >($(UsedLanaNum), $(LanaNum))
  500. Set RpcLanaNum$(Position) = $(LanaNum)
  501. Ifint $(HighLana) < $(LanaNum)
  502. Set HighLana = $(LanaNum)
  503. Endif
  504. set-add LanaNum = $(LanaNum), 1
  505. endif
  506. ;
  507. ; hack: always set xns lananum to 0
  508. ; BUGBUG: this should be based upon an "MS Campus" flag!
  509. ;
  510. set FLibraryErrCtl = 1
  511. LibraryProcedure Result $(!NCPA_HANDLE) EqualToXnsRoute $(ThisRoute)
  512. ifstr(i) $(Result) == "1"
  513. set LanaXnsNum = "LanaNum"$(Position)
  514. endif
  515. endif
  516. ;
  517. ; Locate the position of this route in the newly-updated OldRouteList.
  518. ; Build lists containing RPC lanas and protocol suffix strings.
  519. ;
  520. Set RouteIndex = ~($(OldRouteList),$(ThisRoute))
  521. Set ThisLana = $(RpcLanaNum$(RouteIndex))
  522. ;
  523. ; Locate the provider for this route. Strip the name of the first service from
  524. ; the route, open its "Parameters" key, get its "NbProvider" value.
  525. ;
  526. LibraryProcedure CEPSTemp $(!NCPA_HANDLE) CPlSetup $(!STF_HWND), ROUTETOLIST, $(ThisRoute)
  527. Set ThisProto = ""
  528. Set ThisService = *($(CEPSTemp),2)
  529. Debug-Output "NBINFO.INF: CEPS: "$(ThisRoute)" = "$(CEPSTemp)", ThisService = "$(ThisService)
  530. OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(ThisService)"\Parameters" $(!REG_KEY_READ) SrvParmKey
  531. Ifint $(RegLastError) == 0
  532. GetRegValue $(SrvParmKey) $(NbProviderField) NbProviderData
  533. Ifint $(RegLastError) == 0
  534. Set ThisProto = *($(NbProviderData),4)
  535. Debug-Output "NBINFO.INF: Service "$(ThisService)" is a NetBIOS provider: "$(ThisProto)
  536. Set RpcSuffixCount$(ThisProto) = 0
  537. Set RpcLanaList = >($(RpcLanaList),$(ThisLana))
  538. Set RpcProtoList = >($(RpcProtoList),$(ThisProto))
  539. Else
  540. Debug-Output "NBINFO.INF: "$(ThisService)"\Parameters has no NbProvider value"
  541. Endif
  542. CloseRegKey $(SrvParmKey)
  543. Else
  544. Debug-Output "NBINFO.INF: open of key "$(ThisService)"\Parameters FAILED; no provider info"
  545. Endif
  546. Debug-Output "NBINFO.INF: RPC string for route "$(ThisRoute)" is "$(ThisProto)" = "$(ThisLana)
  547. EndForListDo
  548. Ifint $(AnyChanges) != 0
  549. Debug-Output "NBINFO.INF: Update Parameters..."
  550. Set NewValueList = >($(NewValueList),{Route, $(NoTitle), $(!REG_VT_MULTI_SZ), $(OldRouteList)})
  551. Shell $(UtilityInf), AddValueList, $(ParameterKey), $(NewValueList)
  552. Endif
  553. set ExportNum = 1
  554. ForListDo $(OldRouteList)
  555. Set ThisRoute = *($($),1)
  556. Set ThisProto = *($($),2)
  557. ; setup the EnumExport value
  558. LibraryProcedure "" $(!NCPA_HANDLE) SetEnumExport $(ExportNum) $(ThisRoute)
  559. set-add ExportNum = $(ExportNum), 1
  560. EndForListDo
  561. ;
  562. ; hack: always set xns lananum to 0
  563. ; BUGBUG: this should be based upon an "MS Campus" flag!
  564. ;
  565. ifstr(i) $(LanaXnsNum) != ""
  566. GetRegValue $(ParameterKey) $(LanaXnsNum) LanaXnsInfo
  567. GetRegValue $(ParameterKey) $(LanaZeroNum) LanaZeroInfo
  568. set XnsNum = *($(LanaXnsInfo), 4)
  569. set ZeroNum = *($(LanaZeroInfo), 4)
  570. SetRegValue $(ParameterKey) {$(LanaXnsNum),$(NoTitle),$(!REG_VT_DWORD),$(ZeroNum)}
  571. SetRegValue $(ParameterKey) {$(LanaZeroNum),$(NoTitle),$(!REG_VT_DWORD),$(XnsNum)}
  572. Endif
  573. CloseRegKey $(ParameterKey)
  574. set FLibraryErrCtl = 1
  575. LibraryProcedure "" $(!NCPA_HANDLE), CPlSetupLanaMap
  576. EndWait
  577. ;
  578. ; Using the lists build above, update the RPC NetBIOS information in the
  579. ; SOFTWARE hive.
  580. ;
  581. ; This starts by deleting the NetBios key to reset all values, then the key is
  582. ; recreated and the new values are added. Uses the lists $(RpcLanaList)
  583. ; and $(RpcProtoList). The values $(RpcSuffixCount<suffix)) have already been
  584. ; set to zero.
  585. ;
  586. ; This bizarro logic is necessary because RPC wants to have its protocol strings
  587. ; sorted into LANA order. There can be no gaps in the numbering of protocol strings,
  588. ; but there may be gaps in the numbering of LANAs.
  589. ;
  590. OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft\Rpc" $(MAXIMUM_ALLOWED) KeyRpc
  591. Ifstr(i) $(KeyRpc) == ""
  592. Debug-Output "NBINFO.INF: Unable to open RPC software key"
  593. goto successful
  594. Endif
  595. Set RpcValueList = {}
  596. Set NextLana = 0
  597. OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\NetBIOS\Linkage" $(MAXIMUM_ALLOWED) NetBiosLinkage
  598. ifstr(i) $(NetBiosLinkage) != ""
  599. GetRegValue $(NetBiosLinkage) "LanaMap" LanaMapInfo
  600. set BindedLana = {}
  601. set Odd = 1
  602. ForListDo *($(LanaMapInfo),4)
  603. ifint $(Odd) == 1
  604. set Odd = 0
  605. else
  606. set Odd = 1
  607. ifstr $(BindedLana) == {}
  608. set BindedLana = $($)
  609. else
  610. set BindedLana = >($(BindedLana),$($))
  611. endif
  612. endif
  613. EndForListDo
  614. CloseRegKey $(NetBiosLinkage)
  615. endif
  616. ;
  617. ; Increment through all the possible LANAs. If one is used for RPC, generate
  618. ; the appropriate protocol string and LANA number value; then update the
  619. ; suffix for that protocol.
  620. ;
  621. trynextlana = +
  622. Debug-Output "Binded Lana:"$(BindedLana)
  623. Debug-Output "NBINFO.INF: HighLana = "$(HighLana)", LanaXnsNum = "$(LanaXnsNum)", XnsNum = "$(XnsNum)", ZeroNum = "$(ZeroNum)
  624. Ifint $(NextLana) > $(HighLana)
  625. goto updaterpc
  626. Endif
  627. Ifcontains(i) $(NextLana) in $(RpcLanaList)
  628. Set Index = ~($(RpcLanaList),$(NextLana))
  629. Set ThisProto = *($(RpcProtoList),$(Index))
  630. Set NextSuffix = $(RpcSuffixCount$(ThisProto))
  631. Set-add RpcSuffixCount$(ThisProto) = $(NextSuffix),1
  632. Set ThisString = "ncacn_nb"$(ThisProto)$(NextSuffix)
  633. Set UseLana = $(NextLana)
  634. Ifstr(i) $(LanaXnsNum) != ""
  635. Ifint $(NextLana) == $(XnsNum)
  636. Set UseLana = $(ZeroNum)
  637. Else-ifint $(NextLana) == $(ZeroNum)
  638. Set UseLana = $(XnsNum)
  639. Endif
  640. Endif
  641. Debug-Output "NBINFO.INF: RPC string = "$(ThisString)", lana = "$(UseLana)
  642. ifcontains(i) $(UseLana) in $(BindedLana)
  643. Set RpcValueList = >($(RpcValueList),{$(ThisString),$(NoTitle),$(!REG_VT_DWORD),$(UseLana)})
  644. endif
  645. Endif
  646. Set-add NextLana = $(NextLana),1
  647. Goto trynextlana
  648. updaterpc = +
  649. ;
  650. ; Delete the Rpc\NetBios key, recreate it, append the generated values.
  651. ; The result of the deletion operation is not checked, since recreation will
  652. ; fail if the key already exists.
  653. ;
  654. Set KeyNameNetBios = "NetBios"
  655. DeleteRegKey $(KeyRpc) $(KeyNameNetBios)
  656. CreateRegKey $(KeyRpc) { $(KeyNameNetBios), $(NoTitle), GenericClass } "" $(MAXIMUM_ALLOWED) "" KeyNetBios
  657. Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
  658. Debug-Output "NBINFO.INF: RpcValueList = "$(RpcValueList)
  659. Shell $(UtilityInf), AddValueList, $(KeyNetBios), $(RpcValueList)
  660. CloseRegKey $(KeyNetBios)
  661. Else
  662. Debug-Output "NBINFO.INF: Rpc\Netbios key recreation failed"
  663. Endif
  664. CloseRegKey $(KeyRpc)
  665. goto successful
  666. ; Escape hatches
  667. ;
  668. successful = +
  669. ;
  670. goto end
  671. ;
  672. ; warning display
  673. ;
  674. warning = +
  675. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
  676. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  677. goto ShellCodeError
  678. endif
  679. ifstr(i) $($R1) == "OK"
  680. goto $(to)
  681. else-ifstr(i) $($R1) == "CANCEL"
  682. goto $(from)
  683. else
  684. ; Debug-Msg "Error Error Bad DLGEVENT"
  685. goto "end"
  686. endif
  687. ;
  688. ; non fatal error display
  689. ;
  690. nonfatal = +
  691. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "NONFATAL", $(Error)
  692. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  693. goto ShellCodeError
  694. endif
  695. ifstr(i) $($R1) == "OK"
  696. goto $(from)
  697. else
  698. goto "end"
  699. endif
  700. ;
  701. ; Registry is broken
  702. ;
  703. fatalregistry = +
  704. Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
  705. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  706. goto ShellCodeError
  707. endif
  708. set Error = $($R0)
  709. goto fatal
  710. ;
  711. ; fatal error display
  712. ;
  713. fatal = +
  714. Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
  715. ifint $($ShellCode) != $(!SHELL_CODE_OK)
  716. goto ShellCodeError
  717. endif
  718. goto setfailed
  719. ;
  720. ; Shelling error
  721. ;
  722. ShellCodeError = +
  723. set DlgType = "MessageBox"
  724. set STF_MB_TITLE = $(ShellCodeErrorTitle)
  725. set STF_MB_TEXT = $(ShellCodeErrorText)
  726. set STF_MB_TYPE = 1
  727. set STF_MB_ICON = 3
  728. set STF_MB_DEF = 1
  729. ui start "Error Message"
  730. goto setfailed
  731. setfailed = +
  732. set CommonStatus = STATUS_FAILED
  733. goto end
  734. end = +
  735. goto term
  736. term = +
  737. Return $(CommonStatus)
  738. ;------------------------------------------------------------------------
  739. ;
  740. ; CheckMixRpcProtocol
  741. ;
  742. ; During review binding, this function will be called by other
  743. ; inf file. The function will check whether the binding is
  744. ; disabled or not. If it is disabled, it will remove the RPC client
  745. ; and server protocol
  746. ;
  747. ;
  748. ; FUNCTION: Check active binding for netbios
  749. ; remove or add the rpc client or server protocol
  750. ;
  751. ; INPUT: $($0): Netbios Related protocol name (eg, NetBT)
  752. ; $($1): Length of $($0)
  753. ; $($2): actual protocol name (eg, tcpip)
  754. ; $($3): rpc tag (eg, ncacn_nb_tcp)
  755. ; $($4): rpc client dll
  756. ; $($5): rpc server dll
  757. ;
  758. ;------------------------------------------------------------------------
  759. [CheckMixRpcProtocol]
  760. read-syms GeneralConstants
  761. read-syms FileConstants
  762. OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NetBIOS\Linkage" $(MAXIMUM_ALLOWED) NbKey
  763. Ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
  764. goto CheckMixRpcProtocolReturn
  765. endif
  766. ;
  767. ; First get the active bindings Route data.
  768. ;
  769. GetRegValue $(NbKey) Route RouteListValue
  770. Ifint $(RegLastError) != 0
  771. Debug-Output "NBINFO.INF: Error reading NetBIOS\Linkage:Route value: "$(RegLastError)
  772. Set RouteList = {}
  773. Else
  774. Set RouteList = *($(RouteListValue),4)
  775. Endif
  776. set ActiveRouteList = $(RouteList)
  777. set CheckedProtocol = """"$($0)""""
  778. set-add Length = $($1),2
  779. set AddedProtocol = $($2)
  780. set AddedRpcString = $($3)
  781. set AddedClientDLL = $($4)
  782. set AddedServerDLL = $($5)
  783. set Find = 0
  784. ForListDo $(ActiveRouteList)
  785. ;
  786. ; see whether we have the related binding
  787. ;
  788. LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp $($) $(CheckedProtocol) $(Length)
  789. ifint $(Result) == 0
  790. set Find = 1
  791. goto FindIt
  792. endif
  793. EndForListDo
  794. FindIt = +
  795. ifint $(Find) == 1
  796. ;
  797. ; Add the rpc stuff if we have active binding
  798. ;
  799. Shell $(UtilityInf) AddMixRpcProtocol "Netbios" $(AddedProtocol) $(AddedRpcString) $(AddedClientDLL) $(AddedServerDLL)
  800. else
  801. ;
  802. ; remove the rpc stuff if we don't have the active binding
  803. ;
  804. Shell $(UtilityInf) RemoveRpcProtocol $(AddedRpcString)
  805. endif
  806. CheckMixRpcProtocolReturn = +
  807. return
  808.