Leaked source code of windows server 2003
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.

709 lines
23 KiB

  1. /*-----------------------------------------------------------------------
  2. rocku.c - Utils for setup program. Get and Set registry settings.
  3. 11-05-97 V1.12, Add backup server fields to registry.
  4. Copyright 1997,98 Comtrol(TM) Corporation.
  5. |-----------------------------------------------------------------------*/
  6. #include "precomp.h"
  7. // had a problem with c-file stuff with DLL build, uncomment to ignore problem
  8. //#define NO_CLIB_FILE_STUFF
  9. static char *szSetupVer = {"SetupVersion"};
  10. //---- port options:
  11. static char *szParameters = {"Parameters"};
  12. static char *szLinkage = {"Linkage"};
  13. static char *szSlash = {"\\"};
  14. static char *szDeviceNode = {"Device%d"};
  15. static char *szPortNode = {"Port%d"};
  16. //static char gstr[200];
  17. static int get_reg_option(int OptionVarType,
  18. HKEY RegKey,
  19. const char *szVarName,
  20. char *szValue,
  21. int szValueSize,
  22. DWORD *ret_dword);
  23. #ifdef NT50
  24. /*-----------------------------------------------------------------
  25. clear_nt_device - clear out the Device# entries.
  26. |------------------------------------------------------------------*/
  27. int clear_nt_device(Driver_Config *wi)
  28. {
  29. DWORD dstat;
  30. char tmpstr[50];
  31. char reg_str[240];
  32. HKEY DrvHandle = NULL;
  33. HKEY NewHandle = NULL;
  34. Device_Config *dev;
  35. int stat;
  36. DbgPrintf(D_Test, (TEXT("clear_nt_device\n")));
  37. #ifdef NT50
  38. make_szSCS(reg_str, szServiceName);
  39. stat = reg_open_key(NULL, &NewHandle, reg_str, KEY_READ);
  40. #else
  41. make_szSCS(reg_str, szServiceName);
  42. stat = reg_open_key(NULL, &NewHandle, reg_str, KEY_READ);
  43. #endif
  44. if (stat == 0)
  45. {
  46. stat = reg_open_key(NewHandle, &DrvHandle, szParameters, KEY_READ);
  47. reg_close_key(NewHandle);
  48. }
  49. else
  50. {
  51. DbgPrintf(D_Error, (TEXT("no service key %s\n"), reg_str));
  52. return 1;
  53. }
  54. if (DrvHandle == NULL)
  55. {
  56. DbgPrintf(D_Error, (TEXT("no drv key for %s\n"), szParameters));
  57. return 2;
  58. }
  59. dev = &wi->dev[0];
  60. #if (defined(NT50))
  61. // for nt50 and rocketport, the os tracks our devices, and
  62. // we use a pnp name to stash our configuration
  63. strcpy(tmpstr, wi->ip.szNt50DevObjName);
  64. #else
  65. wsprintf(tmpstr, szDeviceNode, dev_i);
  66. #endif
  67. RegDeleteKeyNT(DrvHandle, tmpstr);
  68. reg_close_key(DrvHandle);
  69. return 0;
  70. }
  71. #endif
  72. /*-----------------------------------------------------------------
  73. get_nt_config - Read the configuration information from the registry.
  74. |------------------------------------------------------------------*/
  75. int get_nt_config(Driver_Config *wi)
  76. {
  77. DWORD dstat, option_dword; //hopefully ERROR_SUCCESS
  78. int dev_i, pi;
  79. Device_Config *dev;
  80. Port_Config *port;
  81. char tmpstr[50];
  82. char reg_str[240];
  83. char option_str[240];
  84. Our_Options *options;
  85. HKEY DrvHandle = NULL;
  86. HKEY DevHandle = NULL;
  87. HKEY PortHandle = NULL;
  88. //HKEY NewHandle = NULL;
  89. int stat;
  90. #ifdef S_VS
  91. int mac_nums[6];
  92. #endif
  93. DbgPrintf(D_Test, (TEXT("get_nt_config\n")));
  94. make_szSCS(reg_str, szServiceName);
  95. strcat(reg_str, szSlash);
  96. strcat(reg_str, szParameters);
  97. wi->nt_reg_flags = 0; // default these flags to zero
  98. // get setup version string, helps us track if this is initial
  99. // install, if we are upgrading setup, etc.
  100. stat = reg_get_str(NULL, reg_str, szSetupVer, tmpstr, 10);
  101. if (stat != 0)
  102. {
  103. // failed to load this, so mark as initial install.
  104. wi->nt_reg_flags |= 4; // initial install(no version string found).
  105. }
  106. wi->VerboseLog = 0;
  107. #ifndef NT50
  108. wi->NumDevices = 0;
  109. #endif
  110. wi->NoPnpPorts = 0;
  111. wi->ScanRate = 0;
  112. wi->GlobalRS485 = 0;
  113. wi->ModemCountry = mcNA; // North America
  114. options = driver_options; // point at first in array(null terminated list)
  115. stat = reg_open_key(NULL, &DrvHandle, reg_str, KEY_READ);
  116. if (stat != 0)
  117. {
  118. DbgPrintf(D_Error, (TEXT("bad drv handle:%s\n"),reg_str));
  119. }
  120. while (options->name != NULL)
  121. {
  122. dstat = get_reg_option(options->var_type, // dword, string, etc
  123. DrvHandle,
  124. options->name, // name of var. to get
  125. option_str,
  126. 60,
  127. &option_dword);
  128. if (dstat == 0) // ok we read it
  129. {
  130. //DbgPrintf(D_Test, (TEXT("got drv op %s\n"), options->name));
  131. switch(options->id)
  132. {
  133. case OP_VerboseLog:
  134. wi->VerboseLog = option_dword;
  135. break;
  136. case OP_NumDevices:
  137. wi->NumDevices = option_dword;
  138. break;
  139. case OP_NoPnpPorts:
  140. wi->NoPnpPorts = option_dword;
  141. break;
  142. case OP_ScanRate:
  143. wi->ScanRate = option_dword;
  144. break;
  145. case OP_ModemCountry:
  146. wi->ModemCountry = option_dword;
  147. break;
  148. case OP_GlobalRS485:
  149. wi->GlobalRS485 = option_dword;
  150. break;
  151. }
  152. }
  153. else
  154. {
  155. //DbgPrintf(D_Error, (TEXT("no driver option %s\n"),options->name));
  156. }
  157. ++options; // next in list
  158. } // while
  159. if (wi->NumDevices > MAX_NUM_DEVICES) // limit to some sane value
  160. wi->NumDevices = MAX_NUM_DEVICES;
  161. // Loop through all possible boards/devices
  162. if (DrvHandle != NULL)
  163. {
  164. stat = reg_open_key(DrvHandle, &DevHandle, szParameters, KEY_READ);
  165. }
  166. //--- read in device options
  167. for(dev_i=0; dev_i<wi->NumDevices; dev_i++)
  168. {
  169. dev = &wi->dev[dev_i];
  170. #if (defined(NT50))
  171. // for nt50 and rocketport, the os tracks our devices, and
  172. // we use a pnp name to stash our configuration
  173. strcpy(tmpstr, wi->ip.szNt50DevObjName);
  174. #else
  175. wsprintf(tmpstr, szDeviceNode,dev_i);
  176. #endif
  177. stat = reg_open_key(DrvHandle, &DevHandle, tmpstr, KEY_READ);
  178. if (stat)
  179. {
  180. DbgPrintf(D_Error, (TEXT("no dev key for %s\n"), tmpstr));
  181. continue;
  182. }
  183. options = device_options; // point at first in array(null terminated list)
  184. while (options->name != NULL)
  185. {
  186. dstat = get_reg_option(options->var_type, // dword, string, etc
  187. DevHandle,
  188. options->name, // name of var. to get
  189. option_str, 60, &option_dword); // return string value
  190. if (dstat == 0) // ok we read it
  191. {
  192. //DbgPrintf(D_Test, (TEXT("got dev op %s\n"), options->name));
  193. switch(options->id)
  194. {
  195. case OP_NumPorts:
  196. dev->NumPorts = option_dword;
  197. break;
  198. #ifdef S_VS
  199. case OP_MacAddr:
  200. stat = sscanf(option_str, "%x %x %x %x %x %x",
  201. &mac_nums[0], &mac_nums[1], &mac_nums[2],
  202. &mac_nums[3], &mac_nums[4], &mac_nums[5]);
  203. if (stat == 6)
  204. {
  205. dev->MacAddr[0] = mac_nums[0];
  206. dev->MacAddr[1] = mac_nums[1];
  207. dev->MacAddr[2] = mac_nums[2];
  208. dev->MacAddr[3] = mac_nums[3];
  209. dev->MacAddr[4] = mac_nums[4];
  210. dev->MacAddr[5] = mac_nums[5];
  211. DbgPrintf(D_Test, ("read config mac: %x %x %x %x %x %x\n",
  212. dev->MacAddr[0], dev->MacAddr[1], dev->MacAddr[2],
  213. dev->MacAddr[3], dev->MacAddr[4], dev->MacAddr[5]))
  214. }
  215. break;
  216. case OP_BackupServer:
  217. dev->BackupServer = option_dword;
  218. break;
  219. case OP_BackupTimer:
  220. dev->BackupTimer = option_dword;
  221. DbgPrintf(D_Test,(TEXT("reg backTimer:%d\n"), dev->BackupTimer));
  222. break;
  223. #endif
  224. case OP_Name:
  225. if (strlen(option_str) >= sizeof(dev->Name))
  226. option_str[sizeof(dev->Name)-1] = 0;
  227. strcpy(dev->Name, option_str);
  228. break;
  229. case OP_ModelName:
  230. if (strlen(option_str) >= sizeof(dev->ModelName))
  231. option_str[sizeof(dev->ModelName)-1] = 0;
  232. strcpy(dev->ModelName, option_str);
  233. break;
  234. #ifdef S_RK
  235. case OP_IoAddress:
  236. dev->IoAddress = option_dword;
  237. break;
  238. #endif
  239. case OP_ModemDevice:
  240. dev->ModemDevice = option_dword;
  241. break;
  242. case OP_HubDevice:
  243. dev->HubDevice = option_dword;
  244. break;
  245. }
  246. }
  247. else
  248. {
  249. DbgPrintf(D_Test, (TEXT("NOT got dev op %s\n"), options->name));
  250. }
  251. ++options;
  252. }
  253. for(pi=0; pi<dev->NumPorts; pi++) // Loop through all ports
  254. {
  255. port = &dev->ports[pi];
  256. port->LockBaud = 0;
  257. port->TxCloseTime = 0;
  258. port->MapCdToDsr = 0;
  259. port->RingEmulate = 0;
  260. port->WaitOnTx = 0;
  261. port->RS485Override = 0;
  262. port->RS485Low = 0;
  263. port->Map2StopsTo1 = 0;
  264. wsprintf(tmpstr, szPortNode,pi);
  265. stat = reg_open_key(DevHandle, &PortHandle, tmpstr, KEY_READ);
  266. if (stat)
  267. {
  268. DbgPrintf(D_Error, (TEXT("no port key: %s\n"), tmpstr));
  269. if (DevHandle == NULL)
  270. {
  271. DbgPrintf(D_Error, (TEXT("no dev handle\n")));
  272. }
  273. continue;
  274. }
  275. options = port_options; // point at first in array(null terminated list)
  276. while (options->name != NULL)
  277. {
  278. dstat = get_reg_option(options->var_type, // dword, string, etc
  279. PortHandle,
  280. options->name, // name of var. to get
  281. option_str, 60, &option_dword); // return string value
  282. if (dstat == 0) // ok we read it
  283. {
  284. //DbgPrintf(D_Test, (TEXT("got port op %s\n"), options->name));
  285. switch(options->id)
  286. {
  287. case OP_WaitOnTx:
  288. port->WaitOnTx = option_dword;
  289. break;
  290. case OP_RS485Override:
  291. port->RS485Override = option_dword;
  292. break;
  293. case OP_RS485Low:
  294. port->RS485Low = option_dword;
  295. break;
  296. case OP_TxCloseTime:
  297. port->TxCloseTime = option_dword;
  298. break;
  299. case OP_LockBaud:
  300. port->LockBaud = option_dword;
  301. break;
  302. case OP_Map2StopsTo1:
  303. port->Map2StopsTo1 = option_dword;
  304. break;
  305. case OP_MapCdToDsr:
  306. port->MapCdToDsr = option_dword;
  307. break;
  308. case OP_RingEmulate:
  309. port->RingEmulate = option_dword;
  310. break;
  311. case OP_PortName:
  312. if (strlen(option_str) >= sizeof(port->Name))
  313. option_str[sizeof(port->Name)-1] = 0;
  314. strcpy(port->Name, option_str);
  315. break;
  316. }
  317. }
  318. ++options;
  319. }
  320. //wsprintf(dev->Name, "COM%d", pi+5);
  321. reg_close_key(PortHandle);
  322. } // numports
  323. reg_close_key(DevHandle);
  324. } // for all devices(boards or boxes)
  325. reg_close_key(DrvHandle);
  326. // "SYSTEM\\CurrentControlSet\\Services -
  327. // \\EventLog\\System\\RocketPort"
  328. make_szSCSES(reg_str, szServiceName);
  329. if (!reg_key_exists(NULL,reg_str))
  330. wi->nt_reg_flags |= 1; // missing important registry info(possibly)
  331. make_szSCS(reg_str, szServiceName);
  332. strcat(reg_str, szSlash); strcat(reg_str, szLinkage);
  333. if (!reg_key_exists(NULL, reg_str))
  334. wi->nt_reg_flags |= 2; // missing linkage thing(did not install via network inf)
  335. return 0;
  336. }
  337. /*----------------------------------------------------------------------
  338. get_reg_option - read in a option from the registry, and convert it to
  339. ascii.
  340. |----------------------------------------------------------------------*/
  341. static int get_reg_option(int OptionVarType,
  342. HKEY RegKey,
  343. const char *szVarName,
  344. char *szValue,
  345. int szValueSize,
  346. DWORD *ret_dword)
  347. {
  348. int stat = 1; // err
  349. //ULONG dwValue;
  350. if (RegKey == NULL)
  351. return 1;
  352. if (OptionVarType == OP_T_STRING) // string option type
  353. {
  354. szValue[0] = 0;
  355. stat = reg_get_str(RegKey, "", szVarName, szValue, szValueSize);
  356. if (stat)
  357. szValue[0] = 0;
  358. }
  359. else // DWORD option type
  360. {
  361. stat = reg_get_dword(RegKey, "", szVarName, ret_dword);
  362. if (stat)
  363. *ret_dword = 0;
  364. }
  365. return stat;
  366. }
  367. /*-----------------------------------------------------------------
  368. set_nt_config - Set the configuration information.
  369. |------------------------------------------------------------------*/
  370. int set_nt_config(Driver_Config *wi)
  371. {
  372. int i,pi, stat;
  373. char tmpstr[150];
  374. char str[240];
  375. DWORD dstat, dwstat;
  376. int bad_error = 0;
  377. int new_install = 0;
  378. Device_Config *dev;
  379. Port_Config *port;
  380. HKEY DrvHandle = NULL;
  381. HKEY DevHandle = NULL;
  382. HKEY PortHandle = NULL;
  383. HKEY NewHandle = NULL;
  384. DbgPrintf(D_Test, (TEXT("set_nt_config\n")));
  385. // -------- create the following if not present:
  386. // "SYSTEM\\CurrentControlSet\\Services\\RocketPort",
  387. make_szSCS(str, szServiceName);
  388. if (!reg_key_exists(NULL, str))
  389. dstat = reg_create_key(NULL, str);
  390. stat = reg_open_key(NULL, &NewHandle, str, KEY_ALL_ACCESS);
  391. if (stat)
  392. {
  393. DbgPrintf(D_Test, (TEXT("bad service handle:%s\n"),str));
  394. }
  395. // -------- create the following if not present:
  396. // "SYSTEM\\CurrentControlSet\\Services\\RocketPort\\Parameters",
  397. if (!reg_key_exists(NewHandle, szParameters))
  398. dstat = reg_create_key(NewHandle, szParameters); // create it
  399. stat = reg_open_key(NewHandle, &DrvHandle, szParameters, KEY_ALL_ACCESS);
  400. if (stat)
  401. {
  402. DbgPrintf(D_Test, (TEXT("bad drv handle:%s\n"),str));
  403. }
  404. reg_close_key(NewHandle);
  405. //----- set setup version string, helps us track if this is initial
  406. // install, if we are upgrading setup, etc.
  407. dstat = reg_set_str(DrvHandle, "", szSetupVer, VERSION_STRING, REG_SZ);
  408. //---- see if parameter is present, if not assume it
  409. //---- is a new install(as apposed to changing parameters).
  410. dstat = reg_get_dword(DrvHandle, "", szNumDevices, &dwstat);
  411. if (dstat)
  412. new_install = 1; // new install
  413. // -------- create the following if not present:
  414. // "SYSTEM\\CurrentControlSet\\Services\\EventLog\\System\\RocketPort"
  415. make_szSCSES(str, szServiceName);
  416. if (!reg_key_exists(NULL,str))
  417. dstat = reg_create_key(NULL,str);
  418. // ---- Set the Event ID message-file name.
  419. strcpy(tmpstr, "%SystemRoot%\\system32\\IoLogMsg.dll;");
  420. strcat(tmpstr, "%SystemRoot%\\system32\\drivers\\");
  421. strcat(tmpstr, wi->ip.szDriverName);
  422. dstat = reg_set_str(NULL, str, "EventMessageFile", tmpstr, REG_EXPAND_SZ);
  423. // ---- Set the supported types flags.
  424. dstat = reg_set_dword(NULL, str, "TypesSupported",
  425. EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
  426. EVENTLOG_INFORMATION_TYPE);
  427. // ---- Setup some NT-specific registry variables
  428. // "SYSTEM\\CurrentControlSet\\Services\\RocketPort",
  429. make_szSCS(str, szServiceName);
  430. dstat = reg_set_dword(NULL, str, "ErrorControl", SERVICE_ERROR_IGNORE); // 0
  431. dstat = reg_set_str(NULL, str, "Group", "Extended Base", REG_SZ);
  432. strcpy(tmpstr, "System32\\Drivers\\");
  433. strcat(tmpstr, wi->ip.szDriverName);
  434. dstat = reg_set_str(NULL, str, "ImagePath", tmpstr, REG_SZ);
  435. // allows user(programmer) to turn following off and leave it off!
  436. if (new_install) // fresh install
  437. {
  438. #ifdef NT50
  439. dstat = reg_set_dword(NULL, str, "Start", 3); // SERVICE_DEMAND_START
  440. #else
  441. dstat = reg_set_dword(NULL, str, "Start", SERVICE_AUTO_START); // 2
  442. #endif
  443. }
  444. dstat = reg_set_dword(NULL, str, "Tag", 1); // 1 (load order)
  445. dstat = reg_set_dword(NULL, str, "Type", SERVICE_KERNEL_DRIVER); // 1
  446. dstat = reg_set_dword_del(DrvHandle,"", szNumDevices, wi->NumDevices,0);
  447. dstat = reg_set_dword_del(DrvHandle,"", szModemCountry, wi->ModemCountry, mcNA);
  448. dstat = reg_set_dword_del(DrvHandle,"", szGlobalRS485, wi->GlobalRS485, 0);
  449. dstat = reg_set_dword_del(DrvHandle,"", szVerboseLog, wi->VerboseLog,0);
  450. dstat = reg_set_dword_del(DrvHandle,"", szScanRate, wi->ScanRate,0);
  451. dstat = reg_set_dword_del(DrvHandle,"", szNoPnpPorts, wi->NoPnpPorts,0);
  452. reg_close_key(DrvHandle);
  453. #if (defined(NT50) && defined(USE_PNP_AREA))
  454. stat = nt5_open_dev_key(&NewHandle);
  455. #else
  456. make_szSCS(str, szServiceName);
  457. stat = reg_open_key(NULL, &NewHandle, str, KEY_ALL_ACCESS);
  458. if (stat)
  459. {
  460. DbgPrintf(D_Test, (TEXT("bad service handle:%s\n"),str));
  461. }
  462. #endif
  463. // -------- create the following if not present:
  464. // "SYSTEM\\CurrentControlSet\\Services\\RocketPort\\Parameters",
  465. if (!reg_key_exists(NewHandle, szParameters))
  466. dstat = reg_create_key(NewHandle, szParameters); // create it
  467. stat = reg_open_key(NewHandle, &DrvHandle, szParameters, KEY_ALL_ACCESS);
  468. if (stat)
  469. {
  470. DbgPrintf(D_Test, (TEXT("Bad drv handle:%s\n"),str));
  471. }
  472. reg_close_key(NewHandle);
  473. for(i=0; i<wi->NumDevices; i++) // Loop through all possible boxes
  474. {
  475. dev = &wi->dev[i];
  476. #if (defined(NT50))
  477. # ifdef USE_PNP_AREA
  478. tmpstr[0] = 0;
  479. # else
  480. // for nt50 and rocketport, the os tracks our devices, and
  481. // we use a pnp name to stash our configuration
  482. strcpy(tmpstr, wi->ip.szNt50DevObjName);
  483. #endif
  484. #else
  485. wsprintf(tmpstr, szDeviceNode,i);
  486. #endif
  487. if (tmpstr[0] != 0)
  488. {
  489. if (!reg_key_exists(DrvHandle, tmpstr))
  490. dstat = reg_create_key(DrvHandle, tmpstr); // create it
  491. stat = reg_open_key(DrvHandle, &DevHandle, tmpstr, KEY_ALL_ACCESS);
  492. if (stat)
  493. {
  494. DbgPrintf(D_Test, (TEXT("bad dev handle:%s\n"),tmpstr));
  495. }
  496. }
  497. else
  498. {
  499. // must be nt50 pnp, where we write out to the pnp reg area.
  500. DevHandle = DrvHandle;
  501. }
  502. DbgPrintf(D_Test, (TEXT("set reg dev %s \n"), tmpstr));
  503. dstat = reg_set_dword_del(DevHandle,"", szNumPorts, dev->NumPorts,0);
  504. dstat = reg_set_str(DevHandle,"", szName, dev->Name, REG_SZ);
  505. dstat = reg_set_dword_del(DevHandle,"", szModemDevice, dev->ModemDevice, 0);
  506. dstat = reg_set_dword_del(DevHandle,"", szHubDevice, dev->HubDevice, 0);
  507. dstat = reg_set_str(DevHandle,"", szModelName, dev->ModelName, REG_SZ);
  508. #ifdef S_VS
  509. dstat = reg_set_dword_del(DevHandle,"", szBackupServer, dev->BackupServer,0);
  510. dstat = reg_set_dword_del(DevHandle,"", szBackupTimer, dev->BackupTimer,0);
  511. wsprintf(tmpstr, "%x %x %x %x %x %x",
  512. dev->MacAddr[0], dev->MacAddr[1], dev->MacAddr[2],
  513. dev->MacAddr[3], dev->MacAddr[4], dev->MacAddr[5]);
  514. dstat = reg_set_str(DevHandle,"", szMacAddr, tmpstr,REG_SZ);
  515. #else
  516. // rocket
  517. dstat = reg_set_dword_del(DevHandle,"", szIoAddress, dev->IoAddress,0);
  518. #endif
  519. for(pi=0; pi<dev->NumPorts; pi++) // Loop through all ports
  520. {
  521. port = &dev->ports[pi];
  522. wsprintf(tmpstr, szPortNode,pi);
  523. if (!reg_key_exists(DevHandle, tmpstr))
  524. dstat = reg_create_key(DevHandle, tmpstr); // create it
  525. stat = reg_open_key(DevHandle, &PortHandle, tmpstr, KEY_ALL_ACCESS);
  526. if (stat)
  527. {
  528. DbgPrintf(D_Test, (TEXT("bad port handle:%s\n"),tmpstr));
  529. }
  530. //DbgPrintf(D_Test, (TEXT("set port %s \n"), tmpstr));
  531. dstat = reg_set_str(PortHandle,"", szName, port->Name, REG_SZ);
  532. dstat = reg_set_dword_del(PortHandle,"", szLockBaud, port->LockBaud, 0);
  533. dstat = reg_set_dword_del(PortHandle,"", szTxCloseTime, port->TxCloseTime, 0);
  534. dstat = reg_set_dword_del(PortHandle,"", szMapCdToDsr, port->MapCdToDsr, 0);
  535. dstat = reg_set_dword_del(PortHandle,"", szRingEmulate, port->RingEmulate, 0);
  536. dstat = reg_set_dword_del(PortHandle,"", szWaitOnTx, port->WaitOnTx, 0);
  537. dstat = reg_set_dword_del(PortHandle,"", szRS485Override, port->RS485Override, 0);
  538. dstat = reg_set_dword_del(PortHandle,"", szRS485Low, port->RS485Low, 0);
  539. dstat = reg_set_dword_del(PortHandle,"", szMap2StopsTo1, port->Map2StopsTo1, 0);
  540. reg_close_key(PortHandle);
  541. } // ports loop
  542. // clear out any old box keys(bugbug:this won't work with values in it!)
  543. for(pi=dev->NumPorts; pi<MAX_NUM_PORTS_PER_DEVICE; pi++)// Loop through all ports
  544. {
  545. port = &dev->ports[pi];
  546. wsprintf(tmpstr, szPortNode,pi);
  547. if (reg_key_exists(DevHandle, tmpstr))
  548. reg_delete_key(DevHandle, "", tmpstr); // create it
  549. }
  550. reg_close_key(DevHandle);
  551. } // dev loop
  552. reg_close_key(DrvHandle);
  553. return 0; // ok
  554. }
  555. /*----------------------------------------------------------------------
  556. | copy_files_nt - Handle file copies for either Windows NT
  557. |----------------------------------------------------------------------*/
  558. int copy_files_nt(InstallPaths *ip)
  559. {
  560. char *pstr;
  561. int stat;
  562. #ifdef S_VS
  563. static char *nt_files[] = {
  564. "ctmmdm35.inf",
  565. "readme.txt",
  566. "setup.exe",
  567. "setup.hlp",
  568. "wcom32.exe",
  569. "wcom.hlp",
  570. "portmon.exe",
  571. "portmon.hlp",
  572. "peer.exe",
  573. "peer.hlp",
  574. NULL};
  575. static char *nt_driver[] = {"vslinka.sys",
  576. "vslinka.bin",
  577. NULL};
  578. #else
  579. static char *nt_files[] = {
  580. "ctmmdm35.inf",
  581. "readme.txt",
  582. "setup.exe",
  583. "setup.hlp",
  584. "wcom32.exe",
  585. "wcom.hlp",
  586. "portmon.exe",
  587. "portmon.hlp",
  588. "peer.exe",
  589. "ctmmdmld.rm",
  590. "ctmmdmfw.rm",
  591. "peer.hlp",
  592. NULL};
  593. static char *nt_driver[] = {"rocket.sys",
  594. NULL};
  595. #endif
  596. static char *nt_inf[] = { "mdmctm1.inf",
  597. NULL};
  598. //------ Copy driver to the driver dir
  599. GetSystemDirectory(ip->dest_dir, 144);
  600. strcat(ip->dest_dir,"\\Drivers");
  601. stat = copy_files(ip, nt_driver);
  602. if (stat)
  603. return 1; // error
  604. GetSystemDirectory(ip->dest_dir, 144);
  605. pstr = ip->dest_dir;
  606. while (*pstr) // find end of string
  607. ++pstr;
  608. while ((*pstr != '\\') && (pstr != ip->dest_dir)) // find "\\System32"
  609. --pstr;
  610. *pstr = 0; // null terminate here
  611. strcat(ip->dest_dir,"\\Inf"); // copy to INF directory
  612. stat = copy_files(ip, nt_inf);
  613. GetSystemDirectory(ip->dest_dir, 144);
  614. #ifdef S_VS
  615. strcat(ip->dest_dir, "\\vslink");
  616. #else
  617. strcat(ip->dest_dir, "\\rocket");
  618. #endif
  619. #ifndef NO_CLIB_FILE_STUFF
  620. _mkdir(ip->dest_dir);
  621. #endif
  622. stat = copy_files(ip, nt_files);
  623. return 0; // ok
  624. }