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.

1211 lines
29 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ndscopy.cxx
  7. //
  8. // Contents: NDS Object Copy Routines
  9. //
  10. // Functions:
  11. //
  12. // History: 25-Apr-96 KrishnaG Created.
  13. //
  14. //
  15. // Issues: Object Types 6, 13, 16, and 21 are flaky - pay extra attn.
  16. //
  17. //
  18. //----------------------------------------------------------------------------
  19. #include "nds.hxx"
  20. //
  21. // NdsType objects copy code
  22. //
  23. HRESULT
  24. NdsTypeCopyNDSSynId1(
  25. PNDSOBJECT lpNdsSrcObject,
  26. PNDSOBJECT lpNdsDestObject
  27. )
  28. {
  29. HRESULT hr = S_OK;
  30. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  31. lpNdsDestObject->NdsValue.value_1.DNString =
  32. (LPWSTR)AllocADsStr(
  33. lpNdsSrcObject->NdsValue.value_1.DNString
  34. );
  35. if ((!lpNdsDestObject->NdsValue.value_1.DNString) &&
  36. (lpNdsSrcObject->NdsValue.value_1.DNString)) {
  37. hr = E_OUTOFMEMORY;
  38. }
  39. RRETURN(hr);
  40. }
  41. HRESULT
  42. NdsTypeCopyNDSSynId2(
  43. PNDSOBJECT lpNdsSrcObject,
  44. PNDSOBJECT lpNdsDestObject
  45. )
  46. {
  47. HRESULT hr = S_OK;
  48. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  49. lpNdsDestObject->NdsValue.value_1.DNString =
  50. (LPWSTR)AllocADsStr(
  51. lpNdsSrcObject->NdsValue.value_1.DNString
  52. );
  53. if ((!lpNdsDestObject->NdsValue.value_1.DNString) &&
  54. (lpNdsSrcObject->NdsValue.value_1.DNString)) {
  55. hr = E_OUTOFMEMORY;
  56. }
  57. RRETURN(hr);
  58. }
  59. HRESULT
  60. NdsTypeCopyNDSSynId3(
  61. PNDSOBJECT lpNdsSrcObject,
  62. PNDSOBJECT lpNdsDestObject
  63. )
  64. {
  65. HRESULT hr = S_OK;
  66. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  67. lpNdsDestObject->NdsValue.value_1.DNString =
  68. (LPWSTR)AllocADsStr(
  69. lpNdsSrcObject->NdsValue.value_1.DNString
  70. );
  71. if ((!lpNdsDestObject->NdsValue.value_1.DNString) &&
  72. (lpNdsSrcObject->NdsValue.value_1.DNString)) {
  73. hr = E_OUTOFMEMORY;
  74. }
  75. RRETURN(hr);
  76. }
  77. HRESULT
  78. NdsTypeCopyNDSSynId4(
  79. PNDSOBJECT lpNdsSrcObject,
  80. PNDSOBJECT lpNdsDestObject
  81. )
  82. {
  83. HRESULT hr = S_OK;
  84. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  85. lpNdsDestObject->NdsValue.value_1.DNString =
  86. (LPWSTR)AllocADsStr(
  87. lpNdsSrcObject->NdsValue.value_1.DNString
  88. );
  89. if ((!lpNdsDestObject->NdsValue.value_1.DNString) &&
  90. (lpNdsSrcObject->NdsValue.value_1.DNString)) {
  91. hr = E_OUTOFMEMORY;
  92. }
  93. RRETURN(hr);
  94. }
  95. HRESULT
  96. NdsTypeCopyNDSSynId5(
  97. PNDSOBJECT lpNdsSrcObject,
  98. PNDSOBJECT lpNdsDestObject
  99. )
  100. {
  101. HRESULT hr = S_OK;
  102. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  103. lpNdsDestObject->NdsValue.value_1.DNString =
  104. (LPWSTR)AllocADsStr(
  105. lpNdsSrcObject->NdsValue.value_1.DNString
  106. );
  107. if ((!lpNdsDestObject->NdsValue.value_1.DNString) &&
  108. (lpNdsSrcObject->NdsValue.value_1.DNString)) {
  109. hr = E_OUTOFMEMORY;
  110. }
  111. RRETURN(hr);
  112. }
  113. HRESULT
  114. NdsTypeCopyNDSSynId6(
  115. PNDSOBJECT lpNdsSrcObject,
  116. PNDSOBJECT lpNdsDestObject
  117. )
  118. {
  119. HRESULT hr = S_OK;
  120. LPNDS_ASN1_TYPE_6 lpNdsSrcTempASN1_6 = NULL;
  121. LPNDS_ASN1_TYPE_6 lpNdsDestTempASN1_6 = NULL;
  122. LPNDS_ASN1_TYPE_6 lpNdsDestNextASN1_6 = NULL;
  123. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  124. lpNdsSrcTempASN1_6 = &(lpNdsSrcObject->NdsValue.value_6);
  125. lpNdsDestTempASN1_6 = &(lpNdsDestObject->NdsValue.value_6);
  126. lpNdsDestTempASN1_6->Next = NULL;
  127. lpNdsDestTempASN1_6->String =
  128. (LPWSTR)AllocADsStr(lpNdsSrcTempASN1_6->String);
  129. if (!lpNdsDestTempASN1_6->String) {
  130. hr = E_OUTOFMEMORY;
  131. BAIL_ON_FAILURE(hr);
  132. }
  133. while ( lpNdsSrcTempASN1_6->Next != NULL )
  134. {
  135. lpNdsSrcTempASN1_6 = lpNdsSrcTempASN1_6->Next;
  136. lpNdsDestNextASN1_6 =
  137. (LPNDS_ASN1_TYPE_6)AllocADsMem(sizeof(NDS_ASN1_TYPE_6));
  138. if (!lpNdsDestNextASN1_6) {
  139. hr = E_OUTOFMEMORY;
  140. BAIL_ON_FAILURE(hr);
  141. }
  142. lpNdsDestNextASN1_6->Next = NULL;
  143. lpNdsDestNextASN1_6->String =
  144. (LPWSTR)AllocADsStr(lpNdsSrcTempASN1_6->String);
  145. if (!lpNdsDestNextASN1_6->String) {
  146. FreeADsMem(lpNdsDestNextASN1_6);
  147. hr = E_OUTOFMEMORY;
  148. BAIL_ON_FAILURE(hr);
  149. }
  150. lpNdsDestTempASN1_6->Next = lpNdsDestNextASN1_6;
  151. lpNdsDestTempASN1_6 = lpNdsDestNextASN1_6;
  152. }
  153. RRETURN(hr);
  154. error:
  155. if (lpNdsDestObject->NdsValue.value_6.String)
  156. FreeADsStr(lpNdsDestObject->NdsValue.value_6.String);
  157. lpNdsDestTempASN1_6 = lpNdsDestObject->NdsValue.value_6.Next;
  158. while (lpNdsDestTempASN1_6 != NULL) {
  159. if (lpNdsDestTempASN1_6->String)
  160. FreeADsStr(lpNdsDestTempASN1_6->String);
  161. lpNdsDestNextASN1_6 = lpNdsDestTempASN1_6->Next;
  162. FreeADsMem(lpNdsDestTempASN1_6);
  163. lpNdsDestTempASN1_6 = lpNdsDestNextASN1_6;
  164. }
  165. RRETURN(hr);
  166. }
  167. HRESULT
  168. NdsTypeCopyNDSSynId7(
  169. PNDSOBJECT lpNdsSrcObject,
  170. PNDSOBJECT lpNdsDestObject
  171. )
  172. {
  173. HRESULT hr = S_OK;
  174. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  175. lpNdsDestObject->NdsValue.value_7.Boolean =
  176. lpNdsSrcObject->NdsValue.value_7.Boolean;
  177. RRETURN(hr);
  178. }
  179. HRESULT
  180. NdsTypeCopyNDSSynId8(
  181. PNDSOBJECT lpNdsSrcObject,
  182. PNDSOBJECT lpNdsDestObject
  183. )
  184. {
  185. HRESULT hr = S_OK;
  186. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  187. lpNdsDestObject->NdsValue.value_8.Integer =
  188. lpNdsSrcObject->NdsValue.value_8.Integer;
  189. RRETURN(hr);
  190. }
  191. HRESULT
  192. NdsTypeCopyNDSSynId9(
  193. PNDSOBJECT lpNdsSrcObject,
  194. PNDSOBJECT lpNdsDestObject
  195. )
  196. {
  197. HRESULT hr = S_OK;
  198. DWORD Length = 0;
  199. LPBYTE pBuffer = NULL;
  200. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  201. Length = lpNdsSrcObject->NdsValue.value_9.Length;
  202. if (Length) {
  203. pBuffer = (LPBYTE)AllocADsMem(Length);
  204. if (!pBuffer) {
  205. hr = E_OUTOFMEMORY;
  206. BAIL_ON_FAILURE(hr);
  207. }
  208. memcpy(
  209. pBuffer,
  210. lpNdsSrcObject->NdsValue.value_9.OctetString,
  211. Length
  212. );
  213. lpNdsDestObject->NdsValue.value_9.Length = Length;
  214. lpNdsDestObject->NdsValue.value_9.OctetString = pBuffer;
  215. }else{
  216. lpNdsDestObject->NdsValue.value_9.Length = 0;
  217. lpNdsDestObject->NdsValue.value_9.OctetString = NULL;
  218. }
  219. error:
  220. RRETURN(hr);
  221. }
  222. HRESULT
  223. NdsTypeCopyNDSSynId10(
  224. PNDSOBJECT lpNdsSrcObject,
  225. PNDSOBJECT lpNdsDestObject
  226. )
  227. {
  228. HRESULT hr = S_OK;
  229. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  230. lpNdsDestObject->NdsValue.value_10.TelephoneNumber =
  231. (LPWSTR)AllocADsStr(
  232. lpNdsSrcObject->NdsValue.value_10.TelephoneNumber
  233. );
  234. if ((!lpNdsDestObject->NdsValue.value_10.TelephoneNumber) &&
  235. (lpNdsSrcObject->NdsValue.value_10.TelephoneNumber)) {
  236. hr = E_OUTOFMEMORY;
  237. }
  238. RRETURN(hr);
  239. }
  240. HRESULT
  241. NdsTypeCopyNDSSynId11(
  242. PNDSOBJECT lpNdsSrcObject,
  243. PNDSOBJECT lpNdsDestObject
  244. )
  245. {
  246. HRESULT hr = S_OK;
  247. DWORD AddressLength = 0;
  248. LPBYTE Address = NULL;
  249. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  250. lpNdsDestObject->NdsValue.value_11.NumberOfBits =
  251. lpNdsSrcObject->NdsValue.value_11.NumberOfBits;
  252. lpNdsDestObject->NdsValue.value_11.TelephoneNumber =
  253. (LPWSTR)AllocADsStr(
  254. lpNdsSrcObject->NdsValue.value_11.TelephoneNumber
  255. );
  256. if (!lpNdsDestObject->NdsValue.value_11.TelephoneNumber) {
  257. hr = E_OUTOFMEMORY;
  258. BAIL_ON_FAILURE(hr);
  259. }
  260. AddressLength = lpNdsSrcObject->NdsValue.value_11.NumberOfBits;
  261. if (AddressLength) {
  262. Address = (LPBYTE)AllocADsMem(AddressLength);
  263. if (!Address) {
  264. hr = E_OUTOFMEMORY;
  265. BAIL_ON_FAILURE(hr);
  266. }
  267. memcpy(
  268. Address,
  269. lpNdsSrcObject->NdsValue.value_11.Parameters,
  270. AddressLength
  271. );
  272. lpNdsDestObject->NdsValue.value_11.NumberOfBits = AddressLength;
  273. lpNdsDestObject->NdsValue.value_11.Parameters = Address;
  274. }else{
  275. lpNdsDestObject->NdsValue.value_11.NumberOfBits = 0;
  276. lpNdsDestObject->NdsValue.value_11.Parameters = NULL;
  277. }
  278. RRETURN(hr);
  279. error:
  280. if (lpNdsDestObject->NdsValue.value_11.TelephoneNumber)
  281. FreeADsMem(lpNdsDestObject->NdsValue.value_11.TelephoneNumber);
  282. RRETURN(hr);
  283. }
  284. HRESULT
  285. NdsTypeCopyNDSSynId12(
  286. PNDSOBJECT lpNdsSrcObject,
  287. PNDSOBJECT lpNdsDestObject
  288. )
  289. {
  290. HRESULT hr = S_OK;
  291. DWORD AddressLength = 0;
  292. LPBYTE Address = NULL;
  293. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  294. lpNdsDestObject->NdsValue.value_12.AddressType =
  295. lpNdsSrcObject->NdsValue.value_12.AddressType;
  296. AddressLength = lpNdsSrcObject->NdsValue.value_12.AddressLength;
  297. if (AddressLength) {
  298. Address = (LPBYTE)AllocADsMem(AddressLength);
  299. if (!Address) {
  300. hr = E_OUTOFMEMORY;
  301. BAIL_ON_FAILURE(hr);
  302. }
  303. memcpy(
  304. Address,
  305. lpNdsSrcObject->NdsValue.value_12.Address,
  306. AddressLength
  307. );
  308. lpNdsDestObject->NdsValue.value_12.AddressLength = AddressLength;
  309. lpNdsDestObject->NdsValue.value_12.Address = Address;
  310. }else{
  311. lpNdsDestObject->NdsValue.value_12.AddressLength = 0;
  312. lpNdsDestObject->NdsValue.value_12.Address = NULL;
  313. }
  314. error:
  315. RRETURN(hr);
  316. }
  317. HRESULT
  318. NdsTypeCopyNDSSynId13(
  319. PNDSOBJECT lpNdsSrcObject,
  320. PNDSOBJECT lpNdsDestObject
  321. )
  322. {
  323. HRESULT hr = S_OK;
  324. LPNDS_ASN1_TYPE_13 pSrc13, *ppDest13, pDest13, pDestNext13;
  325. LPBYTE lpBuffer;
  326. DWORD Length;
  327. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  328. lpNdsDestObject->NdsValue.value_13.Next = NULL;
  329. lpNdsDestObject->NdsValue.value_13.Data = NULL;
  330. Length = lpNdsSrcObject->NdsValue.value_13.Length;
  331. lpBuffer = (LPBYTE)AllocADsMem(
  332. Length
  333. );
  334. if (!lpBuffer) {
  335. hr = E_OUTOFMEMORY;
  336. BAIL_ON_FAILURE(hr);
  337. }
  338. memcpy(
  339. lpBuffer,
  340. lpNdsSrcObject->NdsValue.value_13.Data,
  341. Length
  342. );
  343. lpNdsDestObject->NdsValue.value_13.Length = Length;
  344. lpNdsDestObject->NdsValue.value_13.Data = lpBuffer;
  345. pSrc13 = lpNdsSrcObject->NdsValue.value_13.Next;
  346. ppDest13 = &(lpNdsDestObject->NdsValue.value_13.Next);
  347. while (pSrc13)
  348. {
  349. *ppDest13 =
  350. (LPNDS_ASN1_TYPE_13)AllocADsMem(sizeof(NDS_ASN1_TYPE_13));
  351. if (!*ppDest13) {
  352. hr = E_OUTOFMEMORY;
  353. BAIL_ON_FAILURE(hr);
  354. }
  355. (*ppDest13)->Data = (LPBYTE)AllocADsMem(pSrc13->Length);
  356. if (!((*ppDest13)->Data)) {
  357. hr = E_OUTOFMEMORY;
  358. BAIL_ON_FAILURE(hr);
  359. }
  360. memcpy((*ppDest13)->Data, pSrc13->Data, pSrc13->Length);
  361. (*ppDest13)->Length = pSrc13->Length;
  362. ppDest13 = &(*ppDest13)->Next;
  363. pSrc13 = pSrc13->Next;
  364. }
  365. RRETURN(hr);
  366. error:
  367. if (lpNdsDestObject->NdsValue.value_13.Data)
  368. FreeADsMem(lpNdsDestObject->NdsValue.value_13.Data);
  369. pDest13 = lpNdsDestObject->NdsValue.value_13.Next;
  370. while (pDest13) {
  371. if (pDest13->Data)
  372. FreeADsMem(pDest13->Data);
  373. pDestNext13 = pDest13->Next;
  374. FreeADsMem(pDest13);
  375. pDest13 = pDestNext13;
  376. }
  377. RRETURN(hr);
  378. }
  379. HRESULT
  380. NdsTypeCopyNDSSynId14(
  381. PNDSOBJECT lpNdsSrcObject,
  382. PNDSOBJECT lpNdsDestObject
  383. )
  384. {
  385. HRESULT hr = S_OK;
  386. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  387. lpNdsDestObject->NdsValue.value_14.Address =
  388. (LPWSTR)AllocADsStr(
  389. lpNdsSrcObject->NdsValue.value_14.Address
  390. );
  391. if ((!lpNdsDestObject->NdsValue.value_14.Address) &&
  392. (lpNdsSrcObject->NdsValue.value_14.Address)) {
  393. RRETURN(E_OUTOFMEMORY);
  394. }
  395. lpNdsDestObject->NdsValue.value_14.Type =
  396. lpNdsSrcObject->NdsValue.value_14.Type;
  397. RRETURN(hr);
  398. }
  399. HRESULT
  400. NdsTypeCopyNDSSynId15(
  401. PNDSOBJECT lpNdsSrcObject,
  402. PNDSOBJECT lpNdsDestObject
  403. )
  404. {
  405. HRESULT hr = S_OK;
  406. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  407. lpNdsDestObject->NdsValue.value_15.Type =
  408. lpNdsSrcObject->NdsValue.value_15.Type;
  409. lpNdsDestObject->NdsValue.value_15.VolumeName =
  410. (LPWSTR)AllocADsStr(
  411. lpNdsSrcObject->NdsValue.value_15.VolumeName
  412. );
  413. if ((!lpNdsDestObject->NdsValue.value_15.VolumeName) &&
  414. (lpNdsSrcObject->NdsValue.value_15.VolumeName)) {
  415. RRETURN(E_OUTOFMEMORY);
  416. }
  417. lpNdsDestObject->NdsValue.value_15.Path =
  418. (LPWSTR)AllocADsStr(
  419. lpNdsSrcObject->NdsValue.value_15.Path
  420. );
  421. if ((!lpNdsDestObject->NdsValue.value_15.Path) &&
  422. (lpNdsSrcObject->NdsValue.value_15.Path)) {
  423. hr = E_OUTOFMEMORY;
  424. }
  425. RRETURN(hr);
  426. }
  427. HRESULT
  428. NdsTypeCopyNDSSynId16(
  429. PNDSOBJECT lpNdsSrcObject,
  430. PNDSOBJECT lpNdsDestObject
  431. )
  432. {
  433. HRESULT hr = S_OK;
  434. DWORD Count = 0;
  435. DWORD iter = 0;
  436. DWORD dwAddrAlloc = 0;
  437. LPBYTE Address = NULL;
  438. DWORD AddressLength = 0;
  439. LPNDS_ASN1_TYPE_12 lpNdsDestASN1_12 = NULL, lpNdsSrcASN1_12 = NULL;
  440. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  441. lpNdsDestObject->NdsValue.value_16.ServerName =
  442. (LPWSTR)AllocADsStr(
  443. lpNdsSrcObject->NdsValue.value_16.ServerName
  444. );
  445. if (!lpNdsDestObject->NdsValue.value_16.ServerName) {
  446. hr = E_OUTOFMEMORY;
  447. BAIL_ON_FAILURE(hr);
  448. }
  449. lpNdsDestObject->NdsValue.value_16.ReplicaType =
  450. lpNdsSrcObject->NdsValue.value_16.ReplicaType;
  451. lpNdsDestObject->NdsValue.value_16.ReplicaNumber =
  452. lpNdsSrcObject->NdsValue.value_16.ReplicaNumber;
  453. Count = lpNdsSrcObject->NdsValue.value_16.Count;
  454. lpNdsDestObject->NdsValue.value_16.Count = Count;
  455. lpNdsDestASN1_12 = (LPNDS_ASN1_TYPE_12)AllocADsMem(
  456. Count * sizeof(NDS_ASN1_TYPE_12)
  457. );
  458. if (!lpNdsDestASN1_12) {
  459. hr = E_OUTOFMEMORY;
  460. BAIL_ON_FAILURE(hr);
  461. }
  462. lpNdsDestObject->NdsValue.value_16.ReplicaAddressHints = lpNdsDestASN1_12;
  463. lpNdsSrcASN1_12 = lpNdsSrcObject->NdsValue.value_16.ReplicaAddressHints;
  464. for ( iter = 0; iter < Count; iter++ )
  465. {
  466. (lpNdsDestASN1_12 + iter)->AddressType =
  467. (lpNdsSrcASN1_12 + iter)->AddressType;
  468. AddressLength = (lpNdsSrcASN1_12 + iter)->AddressLength;
  469. if (AddressLength) {
  470. Address = (LPBYTE)AllocADsMem(AddressLength);
  471. if (!Address) {
  472. hr = E_OUTOFMEMORY;
  473. BAIL_ON_FAILURE(hr);
  474. }
  475. memcpy(
  476. Address,
  477. (lpNdsSrcASN1_12 + iter)->Address,
  478. AddressLength
  479. );
  480. (lpNdsDestASN1_12 + iter)->AddressLength = AddressLength;
  481. (lpNdsDestASN1_12 + iter)->Address = Address;
  482. (lpNdsDestASN1_12 + iter)->AddressType = (lpNdsSrcASN1_12 + iter)->AddressType;
  483. }else{
  484. (lpNdsDestASN1_12 + iter)->AddressLength = AddressLength;
  485. (lpNdsDestASN1_12 + iter)->Address = NULL;
  486. (lpNdsDestASN1_12 + iter)->AddressType = 0;
  487. }
  488. dwAddrAlloc++;
  489. }
  490. RRETURN(hr);
  491. error:
  492. if (lpNdsDestASN1_12) {
  493. for (iter=0; iter < dwAddrAlloc; iter++) {
  494. if ((lpNdsDestASN1_12 + iter)->Address)
  495. FreeADsMem((lpNdsDestASN1_12 + iter)->Address);
  496. }
  497. FreeADsMem(lpNdsDestASN1_12);
  498. }
  499. if (lpNdsDestObject->NdsValue.value_16.ServerName)
  500. FreeADsStr(lpNdsDestObject->NdsValue.value_16.ServerName);
  501. RRETURN(hr);
  502. }
  503. HRESULT
  504. NdsTypeCopyNDSSynId17(
  505. PNDSOBJECT lpNdsSrcObject,
  506. PNDSOBJECT lpNdsDestObject
  507. )
  508. {
  509. HRESULT hr = S_OK;
  510. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  511. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  512. lpNdsDestObject->NdsValue.value_17.Privileges =
  513. lpNdsSrcObject->NdsValue.value_17.Privileges;
  514. lpNdsDestObject->NdsValue.value_17.ProtectedAttrName =
  515. (LPWSTR)AllocADsStr(
  516. lpNdsSrcObject->NdsValue.value_17.ProtectedAttrName
  517. );
  518. if ((!lpNdsDestObject->NdsValue.value_17.ProtectedAttrName) &&
  519. (lpNdsSrcObject->NdsValue.value_17.ProtectedAttrName)) {
  520. RRETURN(E_OUTOFMEMORY);
  521. }
  522. lpNdsDestObject->NdsValue.value_17.SubjectName =
  523. (LPWSTR)AllocADsStr(
  524. lpNdsSrcObject->NdsValue.value_17.SubjectName
  525. );
  526. if ((!lpNdsDestObject->NdsValue.value_17.SubjectName) &&
  527. (lpNdsSrcObject->NdsValue.value_17.SubjectName)) {
  528. hr = E_OUTOFMEMORY;
  529. }
  530. RRETURN(hr);
  531. }
  532. HRESULT
  533. NdsTypeCopyNDSSynId18(
  534. PNDSOBJECT lpNdsSrcObject,
  535. PNDSOBJECT lpNdsDestObject
  536. )
  537. {
  538. HRESULT hr = S_OK;
  539. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  540. lpNdsDestObject->NdsValue.value_18.PostalAddress[0] =
  541. (LPWSTR)AllocADsStr(
  542. lpNdsSrcObject->NdsValue.value_18.PostalAddress[0]
  543. );
  544. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[0]) &&
  545. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[0])) {
  546. RRETURN(E_OUTOFMEMORY);
  547. }
  548. lpNdsDestObject->NdsValue.value_18.PostalAddress[1] =
  549. (LPWSTR)AllocADsStr(
  550. lpNdsSrcObject->NdsValue.value_18.PostalAddress[1]
  551. );
  552. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[1]) &&
  553. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[1])) {
  554. RRETURN(E_OUTOFMEMORY);
  555. }
  556. lpNdsDestObject->NdsValue.value_18.PostalAddress[2] =
  557. (LPWSTR)AllocADsStr(
  558. lpNdsSrcObject->NdsValue.value_18.PostalAddress[2]
  559. );
  560. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[2]) &&
  561. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[2])) {
  562. RRETURN(E_OUTOFMEMORY);
  563. }
  564. lpNdsDestObject->NdsValue.value_18.PostalAddress[3] =
  565. (LPWSTR)AllocADsStr(
  566. lpNdsSrcObject->NdsValue.value_18.PostalAddress[3]
  567. );
  568. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[3]) &&
  569. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[3])) {
  570. RRETURN(E_OUTOFMEMORY);
  571. }
  572. lpNdsDestObject->NdsValue.value_18.PostalAddress[4] =
  573. (LPWSTR)AllocADsStr(
  574. lpNdsSrcObject->NdsValue.value_18.PostalAddress[4]
  575. );
  576. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[4]) &&
  577. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[4])) {
  578. RRETURN(E_OUTOFMEMORY);
  579. }
  580. lpNdsDestObject->NdsValue.value_18.PostalAddress[5] =
  581. (LPWSTR)AllocADsStr(
  582. lpNdsSrcObject->NdsValue.value_18.PostalAddress[5]
  583. );
  584. if ((!lpNdsDestObject->NdsValue.value_18.PostalAddress[5]) &&
  585. (lpNdsSrcObject->NdsValue.value_18.PostalAddress[5])) {
  586. hr = E_OUTOFMEMORY;
  587. }
  588. RRETURN(hr);
  589. }
  590. HRESULT
  591. NdsTypeCopyNDSSynId19(
  592. PNDSOBJECT lpNdsSrcObject,
  593. PNDSOBJECT lpNdsDestObject
  594. )
  595. {
  596. HRESULT hr = S_OK;
  597. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  598. lpNdsDestObject->NdsValue.value_19.WholeSeconds =
  599. lpNdsSrcObject->NdsValue.value_19.WholeSeconds;
  600. lpNdsDestObject->NdsValue.value_19.EventID =
  601. lpNdsSrcObject->NdsValue.value_19.EventID;
  602. RRETURN(hr);
  603. }
  604. HRESULT
  605. NdsTypeCopyNDSSynId20(
  606. PNDSOBJECT lpNdsSrcObject,
  607. PNDSOBJECT lpNdsDestObject
  608. )
  609. {
  610. HRESULT hr = S_OK;
  611. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  612. lpNdsDestObject->NdsValue.value_20.ClassName =
  613. AllocADsStr(lpNdsSrcObject->NdsValue.value_20.ClassName);
  614. if ((!lpNdsDestObject->NdsValue.value_20.ClassName) &&
  615. (lpNdsSrcObject->NdsValue.value_20.ClassName)) {
  616. hr = E_OUTOFMEMORY;
  617. }
  618. RRETURN(hr);
  619. }
  620. HRESULT
  621. NdsTypeCopyNDSSynId21(
  622. PNDSOBJECT lpNdsSrcObject,
  623. PNDSOBJECT lpNdsDestObject
  624. )
  625. {
  626. HRESULT hr = S_OK;
  627. DWORD Length = 0;
  628. LPBYTE pBuffer = NULL;
  629. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  630. Length = lpNdsSrcObject->NdsValue.value_21.Length;
  631. if (Length) {
  632. pBuffer = (LPBYTE)AllocADsMem(Length);
  633. if (!pBuffer) {
  634. hr = E_OUTOFMEMORY;
  635. BAIL_ON_FAILURE(hr);
  636. }
  637. memcpy(
  638. pBuffer,
  639. lpNdsSrcObject->NdsValue.value_21.Data,
  640. Length
  641. );
  642. lpNdsDestObject->NdsValue.value_21.Length = Length;
  643. lpNdsDestObject->NdsValue.value_21.Data = pBuffer;
  644. }else{
  645. lpNdsDestObject->NdsValue.value_21.Length = 0;
  646. lpNdsDestObject->NdsValue.value_21.Data = NULL;
  647. }
  648. error:
  649. RRETURN(hr);
  650. }
  651. HRESULT
  652. NdsTypeCopyNDSSynId22(
  653. PNDSOBJECT lpNdsSrcObject,
  654. PNDSOBJECT lpNdsDestObject
  655. )
  656. {
  657. HRESULT hr = S_OK;
  658. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  659. lpNdsDestObject->NdsValue.value_22.Counter =
  660. lpNdsSrcObject->NdsValue.value_22.Counter;
  661. RRETURN(hr);
  662. }
  663. HRESULT
  664. NdsTypeCopyNDSSynId23(
  665. PNDSOBJECT lpNdsSrcObject,
  666. PNDSOBJECT lpNdsDestObject
  667. )
  668. {
  669. HRESULT hr = S_OK;
  670. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  671. lpNdsDestObject->NdsValue.value_23.RemoteID =
  672. lpNdsSrcObject->NdsValue.value_23.RemoteID;
  673. lpNdsDestObject->NdsValue.value_23.ObjectName =
  674. AllocADsStr(
  675. lpNdsSrcObject->NdsValue.value_23.ObjectName
  676. );
  677. if ((!lpNdsDestObject->NdsValue.value_23.ObjectName) &&
  678. (lpNdsSrcObject->NdsValue.value_23.ObjectName)) {
  679. hr = E_OUTOFMEMORY;
  680. }
  681. RRETURN(hr);
  682. }
  683. HRESULT
  684. NdsTypeCopyNDSSynId24(
  685. PNDSOBJECT lpNdsSrcObject,
  686. PNDSOBJECT lpNdsDestObject
  687. )
  688. {
  689. HRESULT hr = S_OK;
  690. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  691. lpNdsDestObject->NdsValue.value_24.Time =
  692. lpNdsSrcObject->NdsValue.value_24.Time;
  693. RRETURN(hr);
  694. }
  695. HRESULT
  696. NdsTypeCopyNDSSynId25(
  697. PNDSOBJECT lpNdsSrcObject,
  698. PNDSOBJECT lpNdsDestObject
  699. )
  700. {
  701. HRESULT hr = S_OK;
  702. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  703. lpNdsDestObject->NdsValue.value_25.ObjectName =
  704. AllocADsStr(
  705. lpNdsSrcObject->NdsValue.value_25.ObjectName
  706. );
  707. if ((!lpNdsDestObject->NdsValue.value_25.ObjectName) &&
  708. (lpNdsSrcObject->NdsValue.value_25.ObjectName)) {
  709. RRETURN(E_OUTOFMEMORY);
  710. }
  711. lpNdsDestObject->NdsValue.value_25.Level =
  712. lpNdsSrcObject->NdsValue.value_25.Level;
  713. lpNdsDestObject->NdsValue.value_25.Interval =
  714. lpNdsSrcObject->NdsValue.value_25.Interval;
  715. RRETURN(hr);
  716. }
  717. HRESULT
  718. NdsTypeCopyNDSSynId26(
  719. PNDSOBJECT lpNdsSrcObject,
  720. PNDSOBJECT lpNdsDestObject
  721. )
  722. {
  723. HRESULT hr = S_OK;
  724. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  725. lpNdsDestObject->NdsValue.value_26.ObjectName =
  726. AllocADsStr(lpNdsSrcObject->NdsValue.value_26.ObjectName);
  727. if ((!lpNdsDestObject->NdsValue.value_26.ObjectName) &&
  728. (lpNdsSrcObject->NdsValue.value_26.ObjectName)) {
  729. RRETURN(E_OUTOFMEMORY);
  730. }
  731. lpNdsDestObject->NdsValue.value_26.Amount =
  732. lpNdsSrcObject->NdsValue.value_26.Amount;
  733. RRETURN(hr);
  734. }
  735. HRESULT
  736. NdsTypeCopyNDSSynId27(
  737. PNDSOBJECT lpNdsSrcObject,
  738. PNDSOBJECT lpNdsDestObject
  739. )
  740. {
  741. HRESULT hr = S_OK;
  742. lpNdsDestObject->NdsType = lpNdsSrcObject->NdsType;
  743. lpNdsDestObject->NdsValue.value_27.Interval =
  744. lpNdsSrcObject->NdsValue.value_27.Interval;
  745. RRETURN(hr);
  746. }
  747. HRESULT
  748. NdsTypeCopy(
  749. PNDSOBJECT lpNdsSrcObject,
  750. PNDSOBJECT lpNdsDestObject
  751. )
  752. {
  753. HRESULT hr = S_OK;
  754. switch (lpNdsSrcObject->NdsType) {
  755. case 1:
  756. hr = NdsTypeCopyNDSSynId1(
  757. lpNdsSrcObject,
  758. lpNdsDestObject
  759. );
  760. break;
  761. case 2:
  762. hr = NdsTypeCopyNDSSynId2(
  763. lpNdsSrcObject,
  764. lpNdsDestObject
  765. );
  766. break;
  767. case 3:
  768. hr = NdsTypeCopyNDSSynId3(
  769. lpNdsSrcObject,
  770. lpNdsDestObject
  771. );
  772. break;
  773. case 4:
  774. hr = NdsTypeCopyNDSSynId4(
  775. lpNdsSrcObject,
  776. lpNdsDestObject
  777. );
  778. break;
  779. case 5:
  780. hr = NdsTypeCopyNDSSynId5(
  781. lpNdsSrcObject,
  782. lpNdsDestObject
  783. );
  784. break;
  785. case 6:
  786. hr = NdsTypeCopyNDSSynId6(
  787. lpNdsSrcObject,
  788. lpNdsDestObject
  789. );
  790. break;
  791. case 7:
  792. hr = NdsTypeCopyNDSSynId7(
  793. lpNdsSrcObject,
  794. lpNdsDestObject
  795. );
  796. break;
  797. case 8:
  798. hr = NdsTypeCopyNDSSynId8(
  799. lpNdsSrcObject,
  800. lpNdsDestObject
  801. );
  802. break;
  803. case 9:
  804. hr = NdsTypeCopyNDSSynId9(
  805. lpNdsSrcObject,
  806. lpNdsDestObject
  807. );
  808. break;
  809. case 10:
  810. hr = NdsTypeCopyNDSSynId10(
  811. lpNdsSrcObject,
  812. lpNdsDestObject
  813. );
  814. break;
  815. case 11:
  816. hr = NdsTypeCopyNDSSynId11(
  817. lpNdsSrcObject,
  818. lpNdsDestObject
  819. );
  820. break;
  821. case 12:
  822. hr = NdsTypeCopyNDSSynId12(
  823. lpNdsSrcObject,
  824. lpNdsDestObject
  825. );
  826. break;
  827. case 13:
  828. hr = NdsTypeCopyNDSSynId13(
  829. lpNdsSrcObject,
  830. lpNdsDestObject
  831. );
  832. break;
  833. case 14:
  834. hr = NdsTypeCopyNDSSynId14(
  835. lpNdsSrcObject,
  836. lpNdsDestObject
  837. );
  838. break;
  839. case 15:
  840. hr = NdsTypeCopyNDSSynId15(
  841. lpNdsSrcObject,
  842. lpNdsDestObject
  843. );
  844. break;
  845. case 16:
  846. hr = NdsTypeCopyNDSSynId16(
  847. lpNdsSrcObject,
  848. lpNdsDestObject
  849. );
  850. break;
  851. case 17:
  852. hr = NdsTypeCopyNDSSynId17(
  853. lpNdsSrcObject,
  854. lpNdsDestObject
  855. );
  856. break;
  857. case 18:
  858. hr = NdsTypeCopyNDSSynId18(
  859. lpNdsSrcObject,
  860. lpNdsDestObject
  861. );
  862. break;
  863. case 19:
  864. hr = NdsTypeCopyNDSSynId19(
  865. lpNdsSrcObject,
  866. lpNdsDestObject
  867. );
  868. break;
  869. case 20:
  870. hr = NdsTypeCopyNDSSynId20(
  871. lpNdsSrcObject,
  872. lpNdsDestObject
  873. );
  874. break;
  875. case 21:
  876. hr = NdsTypeCopyNDSSynId21(
  877. lpNdsSrcObject,
  878. lpNdsDestObject
  879. );
  880. break;
  881. case 22:
  882. hr = NdsTypeCopyNDSSynId22(
  883. lpNdsSrcObject,
  884. lpNdsDestObject
  885. );
  886. break;
  887. case 23:
  888. hr = NdsTypeCopyNDSSynId23(
  889. lpNdsSrcObject,
  890. lpNdsDestObject
  891. );
  892. break;
  893. case 24:
  894. hr = NdsTypeCopyNDSSynId24(
  895. lpNdsSrcObject,
  896. lpNdsDestObject
  897. );
  898. break;
  899. case 25:
  900. hr = NdsTypeCopyNDSSynId25(
  901. lpNdsSrcObject,
  902. lpNdsDestObject
  903. );
  904. break;
  905. case 26:
  906. hr = NdsTypeCopyNDSSynId26(
  907. lpNdsSrcObject,
  908. lpNdsDestObject
  909. );
  910. break;
  911. case 27:
  912. hr = NdsTypeCopyNDSSynId27(
  913. lpNdsSrcObject,
  914. lpNdsDestObject
  915. );
  916. break;
  917. default:
  918. hr = E_FAIL;
  919. break;
  920. }
  921. RRETURN(hr);
  922. }
  923. HRESULT
  924. NdsTypeCopyConstruct(
  925. LPNDSOBJECT pNdsSrcObjects,
  926. DWORD dwNumObjects,
  927. LPNDSOBJECT * ppNdsDestObjects
  928. )
  929. {
  930. DWORD i = 0;
  931. LPNDSOBJECT pNdsDestObjects = NULL;
  932. HRESULT hr = S_OK;
  933. pNdsDestObjects = (LPNDSOBJECT)AllocADsMem(
  934. dwNumObjects * sizeof(NDSOBJECT)
  935. );
  936. if (!pNdsDestObjects) {
  937. RRETURN(E_FAIL);
  938. }
  939. for (i = 0; i < dwNumObjects; i++ ) {
  940. hr = NdsTypeCopy(pNdsSrcObjects + i, pNdsDestObjects + i);
  941. }
  942. *ppNdsDestObjects = pNdsDestObjects;
  943. RRETURN(S_OK);
  944. }