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.

1057 lines
23 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ndsmrshl.cxx
  7. //
  8. // Contents:
  9. //
  10. // Functions:
  11. //
  12. // CopyNDS1ToNDSSynId1
  13. // CopyNDS2ToNDSSynId2
  14. // CopyNDS3ToNDSSynId3
  15. // CopyNDS4ToNDSSynId4
  16. // CopyNDS5ToNDSSynId5
  17. // CopyNDS6ToNDSSynId6
  18. // CopyNDS7ToNDSSynId7
  19. // CopyNDS8ToNDSSynId8
  20. // CopyNDS9ToNDSSynId9
  21. // CopyNDS10ToNDSSynId10
  22. // CopyNDS11ToNDSSynId11
  23. // CopyNDS12ToNDSSynId12
  24. // CopyNDS13ToNDSSynId13
  25. // CopyNDS14ToNDSSynId14
  26. // CopyNDS15ToNDSSynId15
  27. // CopyNDS16ToNDSSynId16
  28. // CopyNDS17ToNDSSynId17
  29. // CopyNDS18ToNDSSynId18
  30. // CopyNDS19ToNDSSynId19
  31. // CopyNDS20ToNDSSynId20
  32. // CopyNDS21ToNDSSynId21
  33. // CopyNDS22ToNDSSynId22
  34. // CopyNDS23ToNDSSynId23
  35. // CopyNDS24ToNDSSynId24
  36. // CopyNDS25ToNDSSynId25
  37. // CopyNDS26ToNDSSynId26
  38. // CopyNDS27ToNDSSynId27
  39. //
  40. // History: 25-Apr-96 KrishnaG Created.
  41. //
  42. // Warnings: NDS Data type 6 is not yet supported (no problems just
  43. // not done!
  44. //
  45. // NDS Data type 16 need to complete the for loop code
  46. // NDS Data type 21 is the stream data type some stress.
  47. //----------------------------------------------------------------------------
  48. #include "nds.hxx"
  49. HRESULT
  50. NdsTypeInit(
  51. PNDSOBJECT pNdsType
  52. )
  53. {
  54. memset(pNdsType, 0, sizeof(NDSOBJECT));
  55. RRETURN(S_OK);
  56. }
  57. LPBYTE
  58. CopyNDS1ToNDSSynId1(
  59. LPBYTE lpByte,
  60. PNDSOBJECT lpNdsObject
  61. )
  62. {
  63. LPASN1_TYPE_1 lpASN1_1 = (LPASN1_TYPE_1) lpByte;
  64. lpNdsObject->NdsType = NDS_SYNTAX_ID_1;
  65. lpNdsObject->NdsValue.value_1.DNString =
  66. (LPWSTR)AllocADsStr(lpASN1_1->DNString);
  67. lpByte = (LPBYTE ) lpASN1_1 + sizeof(ASN1_TYPE_1);
  68. return(lpByte);
  69. }
  70. LPBYTE
  71. CopyNDS2ToNDSSynId2(
  72. LPBYTE lpByte,
  73. PNDSOBJECT lpNdsObject
  74. )
  75. {
  76. LPASN1_TYPE_2 lpASN1_2 = (LPASN1_TYPE_2) lpByte;
  77. lpNdsObject->NdsType = NDS_SYNTAX_ID_2;
  78. lpNdsObject->NdsValue.value_2.CaseExactString =
  79. (LPWSTR)AllocADsStr(lpASN1_2->CaseExactString);
  80. lpByte = (LPBYTE ) lpASN1_2 + sizeof(ASN1_TYPE_2);
  81. return(lpByte);
  82. }
  83. LPBYTE
  84. CopyNDS3ToNDSSynId3(
  85. LPBYTE lpByte,
  86. PNDSOBJECT lpNdsObject
  87. )
  88. {
  89. LPASN1_TYPE_3 lpASN1_3 = (LPASN1_TYPE_3) lpByte;
  90. lpNdsObject->NdsType = NDS_SYNTAX_ID_3;
  91. lpNdsObject->NdsValue.value_3.CaseIgnoreString =
  92. (LPWSTR)AllocADsStr(lpASN1_3->CaseIgnoreString);
  93. lpByte = (LPBYTE ) lpASN1_3 + sizeof(ASN1_TYPE_3);
  94. return(lpByte);
  95. }
  96. LPBYTE
  97. CopyNDS4ToNDSSynId4(
  98. LPBYTE lpByte,
  99. PNDSOBJECT lpNdsObject
  100. )
  101. {
  102. LPASN1_TYPE_4 lpASN1_4 = (LPASN1_TYPE_4) lpByte;
  103. lpNdsObject->NdsType = NDS_SYNTAX_ID_4;
  104. lpNdsObject->NdsValue.value_4.PrintableString =
  105. (LPWSTR)AllocADsStr(lpASN1_4->PrintableString);
  106. lpByte = (LPBYTE) lpASN1_4 + sizeof(ASN1_TYPE_4);
  107. return(lpByte);
  108. }
  109. LPBYTE
  110. CopyNDS5ToNDSSynId5(
  111. LPBYTE lpByte,
  112. PNDSOBJECT lpNdsObject
  113. )
  114. {
  115. LPASN1_TYPE_5 lpASN1_5 = (LPASN1_TYPE_5) lpByte;
  116. lpNdsObject->NdsType = NDS_SYNTAX_ID_5;
  117. lpNdsObject->NdsValue.value_5.NumericString =
  118. (LPWSTR)AllocADsStr(lpASN1_5->NumericString);
  119. lpByte = (LPBYTE ) lpASN1_5 + sizeof(ASN1_TYPE_5);
  120. return(lpByte);
  121. }
  122. LPBYTE
  123. CopyNDS6ToNDSSynId6(
  124. LPBYTE lpByte,
  125. PNDSOBJECT lpNdsObject
  126. )
  127. {
  128. LPASN1_TYPE_6 lpASN1_6 = (LPASN1_TYPE_6) lpByte;
  129. LPNDS_ASN1_TYPE_6 lpNdsTempASN1_6 = NULL;
  130. LPNDS_ASN1_TYPE_6 lpNdsNextASN1_6 = NULL;
  131. lpNdsTempASN1_6 = &(lpNdsObject->NdsValue.value_6);
  132. lpNdsObject->NdsType = NDS_SYNTAX_ID_6;
  133. lpNdsTempASN1_6->String =
  134. (LPWSTR)AllocADsStr(lpASN1_6->String);
  135. if (!lpNdsTempASN1_6->String)
  136. return (NULL);
  137. while ( lpASN1_6->Next != NULL )
  138. {
  139. lpASN1_6 = lpASN1_6->Next;
  140. lpNdsNextASN1_6 =
  141. (LPNDS_ASN1_TYPE_6)AllocADsMem(sizeof(NDS_ASN1_TYPE_6));
  142. if (!lpNdsNextASN1_6)
  143. return (NULL);
  144. lpNdsNextASN1_6->String =
  145. (LPWSTR)AllocADsStr(lpASN1_6->String);
  146. if (!lpNdsNextASN1_6->String)
  147. return (NULL);
  148. lpNdsTempASN1_6->Next = lpNdsNextASN1_6;
  149. lpNdsTempASN1_6 = lpNdsNextASN1_6;
  150. }
  151. lpByte = (LPBYTE ) lpASN1_6 + sizeof(ASN1_TYPE_6);
  152. return(lpByte);
  153. }
  154. LPBYTE
  155. CopyNDS7ToNDSSynId7(
  156. LPBYTE lpByte,
  157. PNDSOBJECT lpNdsObject
  158. )
  159. {
  160. LPASN1_TYPE_7 lpASN1_7 = (LPASN1_TYPE_7) lpByte;
  161. lpNdsObject->NdsType = NDS_SYNTAX_ID_7;
  162. lpNdsObject->NdsValue.value_7.Boolean = lpASN1_7->Boolean;
  163. lpByte = (LPBYTE ) lpASN1_7 + sizeof(ASN1_TYPE_7);
  164. return(lpByte);
  165. }
  166. LPBYTE
  167. CopyNDS8ToNDSSynId8(
  168. LPBYTE lpByte,
  169. PNDSOBJECT lpNdsObject
  170. )
  171. {
  172. LPASN1_TYPE_8 lpASN1_8 = (LPASN1_TYPE_8) lpByte;
  173. lpNdsObject->NdsType = NDS_SYNTAX_ID_8;
  174. lpNdsObject->NdsValue.value_8.Integer = lpASN1_8->Integer;
  175. lpByte = (LPBYTE ) lpASN1_8 + sizeof(ASN1_TYPE_8);
  176. return(lpByte);
  177. }
  178. LPBYTE
  179. CopyNDS9ToNDSSynId9(
  180. LPBYTE lpByte,
  181. PNDSOBJECT lpNdsObject
  182. )
  183. {
  184. LPASN1_TYPE_9 lpASN1_9 = (LPASN1_TYPE_9) lpByte;
  185. LPBYTE pBuffer = NULL;
  186. lpNdsObject->NdsType = NDS_SYNTAX_ID_9;
  187. lpNdsObject->NdsValue.value_9.Length = lpASN1_9->Length;
  188. pBuffer = (LPBYTE)AllocADsMem(lpASN1_9->Length);
  189. if (!pBuffer)
  190. return (NULL);
  191. memcpy(pBuffer, lpASN1_9->OctetString, lpASN1_9->Length);
  192. lpNdsObject->NdsValue.value_9.OctetString = pBuffer;
  193. lpByte = (LPBYTE ) lpASN1_9 + sizeof(ASN1_TYPE_9);
  194. return(lpByte);
  195. }
  196. LPBYTE
  197. CopyNDS10ToNDSSynId10(
  198. LPBYTE lpByte,
  199. PNDSOBJECT lpNdsObject
  200. )
  201. {
  202. LPASN1_TYPE_10 lpASN1_10 = (LPASN1_TYPE_10) lpByte;
  203. lpNdsObject->NdsType = NDS_SYNTAX_ID_10;
  204. lpNdsObject->NdsValue.value_10.TelephoneNumber =
  205. (LPWSTR)AllocADsStr(lpASN1_10->TelephoneNumber);
  206. lpByte = (LPBYTE ) lpASN1_10 + sizeof(ASN1_TYPE_10);
  207. return(lpByte);
  208. }
  209. LPBYTE
  210. CopyNDS11ToNDSSynId11(
  211. LPBYTE lpByte,
  212. PNDSOBJECT lpNdsObject
  213. )
  214. {
  215. LPBYTE pBuffer = NULL;
  216. LPASN1_TYPE_11 lpASN1_11 = (LPASN1_TYPE_11) lpByte;
  217. lpNdsObject->NdsType = NDS_SYNTAX_ID_11;
  218. lpNdsObject->NdsValue.value_11.NumberOfBits = lpASN1_11->NumberOfBits;
  219. if (lpASN1_11->NumberOfBits) {
  220. pBuffer = (LPBYTE)AllocADsMem(lpASN1_11->NumberOfBits);
  221. if (!pBuffer)
  222. return (NULL);
  223. memcpy(pBuffer, lpASN1_11->Parameters, lpASN1_11->NumberOfBits);
  224. lpNdsObject->NdsValue.value_11.Parameters= pBuffer;
  225. }
  226. else {
  227. lpNdsObject->NdsValue.value_11.Parameters= NULL;
  228. }
  229. lpNdsObject->NdsValue.value_11.TelephoneNumber =
  230. (LPWSTR)AllocADsStr(lpASN1_11->TelephoneNumber);
  231. if (!lpNdsObject->NdsValue.value_11.TelephoneNumber)
  232. return (NULL);
  233. lpByte = (LPBYTE ) lpASN1_11 + sizeof(ASN1_TYPE_11);
  234. return(lpByte);
  235. }
  236. LPBYTE
  237. CopyNDS12ToNDSSynId12(
  238. LPBYTE lpByte,
  239. PNDSOBJECT lpNdsObject
  240. )
  241. {
  242. LPASN1_TYPE_12 lpASN1_12 = (LPASN1_TYPE_12) lpByte;
  243. LPBYTE pBuffer = NULL;
  244. lpNdsObject->NdsType = NDS_SYNTAX_ID_12;
  245. lpNdsObject->NdsValue.value_12.AddressType = lpASN1_12->AddressType;
  246. lpNdsObject->NdsValue.value_12.AddressLength = lpASN1_12->AddressLength;
  247. pBuffer = (LPBYTE)AllocADsMem(lpASN1_12->AddressLength);
  248. if (!pBuffer)
  249. return (NULL);
  250. memcpy(pBuffer, lpASN1_12->Address, lpASN1_12->AddressLength);
  251. lpNdsObject->NdsValue.value_12.Address = pBuffer;
  252. lpByte = (LPBYTE ) lpASN1_12 + sizeof(ASN1_TYPE_12);
  253. return(lpByte);
  254. }
  255. LPBYTE
  256. CopyNDS13ToNDSSynId13(
  257. LPBYTE lpByte,
  258. PNDSOBJECT lpNdsObject
  259. )
  260. {
  261. LPASN1_TYPE_13 lpASN1_13 = (LPASN1_TYPE_13) lpByte;
  262. LPNDS_ASN1_TYPE_13 * lppNext = NULL;
  263. LPBYTE lpBuffer = NULL;
  264. LPNDS_ASN1_TYPE_13 pNextObj = NULL;
  265. lpNdsObject->NdsType = NDS_SYNTAX_ID_13;
  266. lpBuffer = (LPBYTE)AllocADsMem(lpASN1_13->Length);
  267. if (!lpBuffer)
  268. return (NULL);
  269. memcpy(lpBuffer, lpASN1_13->Data, lpASN1_13->Length);
  270. lpNdsObject->NdsValue.value_13.Length = lpASN1_13->Length;
  271. lpNdsObject->NdsValue.value_13.Data = lpBuffer;
  272. lppNext = &(lpNdsObject->NdsValue.value_13.Next);
  273. while ( lpASN1_13->Next != NULL )
  274. {
  275. lpASN1_13 = lpASN1_13->Next;
  276. pNextObj =
  277. (LPNDS_ASN1_TYPE_13)AllocADsMem(sizeof(NDS_ASN1_TYPE_13));
  278. if (!pNextObj)
  279. return (NULL);
  280. lpBuffer = (LPBYTE)AllocADsMem(lpASN1_13->Length);
  281. if (!lpBuffer)
  282. return (NULL);
  283. memcpy(lpBuffer, lpASN1_13->Data, lpASN1_13->Length);
  284. pNextObj->Length = lpASN1_13->Length;
  285. pNextObj->Data = lpBuffer;
  286. *lppNext = pNextObj;
  287. lppNext = &pNextObj->Next;
  288. }
  289. lpByte = (LPBYTE ) lpASN1_13 + sizeof(ASN1_TYPE_13);
  290. return(lpByte);
  291. }
  292. LPBYTE
  293. CopyNDS14ToNDSSynId14(
  294. LPBYTE lpByte,
  295. PNDSOBJECT lpNdsObject
  296. )
  297. {
  298. LPASN1_TYPE_14 lpASN1_14 = (LPASN1_TYPE_14) lpByte;
  299. lpNdsObject->NdsType = NDS_SYNTAX_ID_14;
  300. lpNdsObject->NdsValue.value_14.Type = lpASN1_14->Type;
  301. lpNdsObject->NdsValue.value_14.Address =
  302. (LPWSTR)AllocADsStr(lpASN1_14->Address);
  303. lpByte = (LPBYTE ) lpASN1_14 + sizeof(ASN1_TYPE_14);
  304. return(lpByte);
  305. }
  306. LPBYTE
  307. CopyNDS15ToNDSSynId15(
  308. LPBYTE lpByte,
  309. PNDSOBJECT lpNdsObject
  310. )
  311. {
  312. LPASN1_TYPE_15 lpASN1_15 = (LPASN1_TYPE_15) lpByte;
  313. lpNdsObject->NdsType = NDS_SYNTAX_ID_15;
  314. lpNdsObject->NdsValue.value_15.Type = lpASN1_15->Type;
  315. lpNdsObject->NdsValue.value_15.VolumeName =
  316. (LPWSTR)AllocADsStr(lpASN1_15->VolumeName);
  317. lpNdsObject->NdsValue.value_15.Path =
  318. (LPWSTR)AllocADsStr(lpASN1_15->Path);
  319. lpByte = (LPBYTE ) lpASN1_15 + sizeof(ASN1_TYPE_15);
  320. return(lpByte);
  321. }
  322. LPBYTE
  323. CopyNDS12ToNDS12(
  324. LPBYTE lpByte,
  325. LPNDS_ASN1_TYPE_12 lpDest12
  326. )
  327. {
  328. LPASN1_TYPE_12 lpSrc12 = (LPASN1_TYPE_12) lpByte;
  329. LPBYTE pBuffer = NULL;
  330. lpDest12->AddressType = lpSrc12->AddressType;
  331. lpDest12->AddressLength = lpSrc12->AddressLength;
  332. if (lpSrc12->AddressLength) {
  333. pBuffer = (LPBYTE)AllocADsMem(lpSrc12->AddressLength);
  334. if (!pBuffer)
  335. return (NULL);
  336. memcpy(pBuffer, lpSrc12->Address, lpSrc12->AddressLength);
  337. lpDest12->Address = pBuffer;
  338. }else {
  339. lpDest12->Address = NULL;
  340. }
  341. lpByte = (LPBYTE )lpSrc12 + sizeof(ASN1_TYPE_12);
  342. return(lpByte);
  343. }
  344. LPBYTE
  345. CopyNDS16ToNDSSynId16(
  346. LPBYTE lpByte,
  347. PNDSOBJECT lpNdsObject
  348. )
  349. {
  350. LPASN1_TYPE_16 lpASN1_16 = (LPASN1_TYPE_16) lpByte;
  351. LPNDS_ASN1_TYPE_12 lpNdsASN1_12;
  352. DWORD iter = 0;
  353. lpNdsObject->NdsType = NDS_SYNTAX_ID_16;
  354. lpNdsObject->NdsValue.value_16.ServerName =
  355. (LPWSTR)AllocADsStr(lpASN1_16->ServerName);
  356. if (!lpNdsObject->NdsValue.value_16.ServerName)
  357. return (NULL);
  358. lpNdsObject->NdsValue.value_16.ReplicaType = lpASN1_16->ReplicaType;
  359. lpNdsObject->NdsValue.value_16.ReplicaNumber = lpASN1_16->ReplicaNumber;
  360. lpNdsObject->NdsValue.value_16.Count = lpASN1_16->Count;
  361. //
  362. // NDS is kinda goofy. It stores one substructure as part of the
  363. // containing data type instead of a pointer to the object.
  364. //
  365. lpByte = (LPBYTE ) lpASN1_16 + sizeof(ASN1_TYPE_16) - sizeof(ASN1_TYPE_12);
  366. lpNdsASN1_12 = (LPNDS_ASN1_TYPE_12)AllocADsMem(
  367. lpASN1_16->Count * sizeof(NDS_ASN1_TYPE_12)
  368. );
  369. if (!lpNdsASN1_12)
  370. return (NULL);
  371. lpNdsObject->NdsValue.value_16.ReplicaAddressHints = lpNdsASN1_12;
  372. for ( iter = 0; iter < lpASN1_16->Count; iter++ )
  373. {
  374. lpByte = CopyNDS12ToNDS12(
  375. lpByte,
  376. (lpNdsASN1_12 + iter)
  377. );
  378. if (!lpByte)
  379. return (NULL);
  380. }
  381. return(lpByte);
  382. }
  383. LPBYTE
  384. CopyNDS17ToNDSSynId17(
  385. LPBYTE lpByte,
  386. PNDSOBJECT lpNdsObject
  387. )
  388. {
  389. LPASN1_TYPE_17 lpASN1_17 = (LPASN1_TYPE_17) lpByte;
  390. lpNdsObject->NdsType = NDS_SYNTAX_ID_17;
  391. lpNdsObject->NdsValue.value_17.ProtectedAttrName =
  392. (LPWSTR)AllocADsStr(lpASN1_17->ProtectedAttrName);
  393. lpNdsObject->NdsValue.value_17.SubjectName =
  394. (LPWSTR)AllocADsStr(lpASN1_17->SubjectName);
  395. lpNdsObject->NdsValue.value_17.Privileges =
  396. lpASN1_17->Privileges;
  397. lpByte = (LPBYTE ) lpASN1_17 + sizeof(ASN1_TYPE_17);
  398. return(lpByte);
  399. }
  400. LPBYTE
  401. CopyNDS18ToNDSSynId18(
  402. LPBYTE lpByte,
  403. PNDSOBJECT lpNdsObject
  404. )
  405. {
  406. LPASN1_TYPE_18 lpASN1_18 = (LPASN1_TYPE_18) lpByte;
  407. lpNdsObject->NdsType = NDS_SYNTAX_ID_18;
  408. lpNdsObject->NdsValue.value_18.PostalAddress[0] =
  409. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[0]);
  410. lpNdsObject->NdsValue.value_18.PostalAddress[1] =
  411. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[1]);
  412. lpNdsObject->NdsValue.value_18.PostalAddress[2] =
  413. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[2]);
  414. lpNdsObject->NdsValue.value_18.PostalAddress[3] =
  415. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[3]);
  416. lpNdsObject->NdsValue.value_18.PostalAddress[4] =
  417. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[4]);
  418. lpNdsObject->NdsValue.value_18.PostalAddress[5] =
  419. (LPWSTR)AllocADsStr(lpASN1_18->PostalAddress[5]);
  420. lpByte = (LPBYTE ) lpASN1_18 + sizeof(ASN1_TYPE_18);
  421. return(lpByte);
  422. }
  423. LPBYTE
  424. CopyNDS19ToNDSSynId19(
  425. LPBYTE lpByte,
  426. PNDSOBJECT lpNdsObject
  427. )
  428. {
  429. LPASN1_TYPE_19 lpASN1_19 = (LPASN1_TYPE_19) lpByte;
  430. lpNdsObject->NdsType = NDS_SYNTAX_ID_19;
  431. lpNdsObject->NdsValue.value_19.WholeSeconds = lpASN1_19->WholeSeconds;
  432. lpNdsObject->NdsValue.value_19.EventID = lpASN1_19->EventID;
  433. lpByte = (LPBYTE ) lpASN1_19 + sizeof(ASN1_TYPE_19);
  434. return(lpByte);
  435. }
  436. LPBYTE
  437. CopyNDS20ToNDSSynId20(
  438. LPBYTE lpByte,
  439. PNDSOBJECT lpNdsObject
  440. )
  441. {
  442. LPASN1_TYPE_20 lpASN1_20 = (LPASN1_TYPE_20) lpByte;
  443. lpNdsObject->NdsType = NDS_SYNTAX_ID_20;
  444. lpNdsObject->NdsValue.value_20.ClassName =
  445. (LPWSTR)AllocADsStr(lpASN1_20->ClassName);
  446. lpByte = (LPBYTE ) lpASN1_20 + sizeof(ASN1_TYPE_20);
  447. return(lpByte);
  448. }
  449. LPBYTE
  450. CopyNDS21ToNDSSynId21(
  451. LPBYTE lpByte,
  452. PNDSOBJECT lpNdsObject
  453. )
  454. {
  455. LPASN1_TYPE_21 lpASN1_21 = (LPASN1_TYPE_21) lpByte;
  456. LPBYTE pBuffer = NULL;
  457. lpNdsObject->NdsType = NDS_SYNTAX_ID_21;
  458. lpNdsObject->NdsValue.value_21.Length = lpASN1_21->Length;
  459. if (lpASN1_21->Length) {
  460. pBuffer = (LPBYTE)AllocADsMem(lpASN1_21->Length);
  461. if (!pBuffer)
  462. return (NULL);
  463. memcpy(pBuffer, lpASN1_21->Data, lpASN1_21->Length);
  464. lpNdsObject->NdsValue.value_21.Data = pBuffer;
  465. }
  466. else {
  467. lpNdsObject->NdsValue.value_21.Data = NULL;
  468. }
  469. lpByte = (LPBYTE ) lpASN1_21 + sizeof(ASN1_TYPE_21);
  470. return(lpByte);
  471. }
  472. LPBYTE
  473. CopyNDS22ToNDSSynId22(
  474. LPBYTE lpByte,
  475. PNDSOBJECT lpNdsObject
  476. )
  477. {
  478. LPASN1_TYPE_22 lpASN1_22 = (LPASN1_TYPE_22) lpByte;
  479. lpNdsObject->NdsType = NDS_SYNTAX_ID_22;
  480. lpNdsObject->NdsValue.value_22.Counter = lpASN1_22->Counter;
  481. lpByte = (LPBYTE ) lpASN1_22 + sizeof(ASN1_TYPE_22);
  482. return(lpByte);
  483. }
  484. LPBYTE
  485. CopyNDS23ToNDSSynId23(
  486. LPBYTE lpByte,
  487. PNDSOBJECT lpNdsObject
  488. )
  489. {
  490. LPASN1_TYPE_23 lpASN1_23 = (LPASN1_TYPE_23) lpByte;
  491. lpNdsObject->NdsType = NDS_SYNTAX_ID_23;
  492. lpNdsObject->NdsValue.value_23.RemoteID = lpASN1_23->RemoteID;
  493. lpNdsObject->NdsValue.value_23.ObjectName =
  494. (LPWSTR)AllocADsStr(lpASN1_23->ObjectName);
  495. lpByte = (LPBYTE ) lpASN1_23 + sizeof(ASN1_TYPE_23);
  496. return(lpByte);
  497. }
  498. LPBYTE
  499. CopyNDS24ToNDSSynId24(
  500. LPBYTE lpByte,
  501. PNDSOBJECT lpNdsObject
  502. )
  503. {
  504. LPASN1_TYPE_24 lpASN1_24 = (LPASN1_TYPE_24) lpByte;
  505. lpNdsObject->NdsType = NDS_SYNTAX_ID_24;
  506. lpNdsObject->NdsValue.value_24.Time = lpASN1_24->Time;
  507. lpByte = (LPBYTE ) lpASN1_24 + sizeof(ASN1_TYPE_24);
  508. return(lpByte);
  509. }
  510. LPBYTE
  511. CopyNDS25ToNDSSynId25(
  512. LPBYTE lpByte,
  513. PNDSOBJECT lpNdsObject
  514. )
  515. {
  516. LPASN1_TYPE_25 lpASN1_25 = (LPASN1_TYPE_25) lpByte;
  517. lpNdsObject->NdsType = NDS_SYNTAX_ID_25;
  518. lpNdsObject->NdsValue.value_25.ObjectName =
  519. (LPWSTR)AllocADsStr(lpASN1_25->ObjectName);
  520. lpNdsObject->NdsValue.value_25.Level = lpASN1_25->Level;
  521. lpNdsObject->NdsValue.value_25.Interval = lpASN1_25->Interval;
  522. lpByte = (LPBYTE ) lpASN1_25 + sizeof(ASN1_TYPE_25);
  523. return(lpByte);
  524. }
  525. LPBYTE
  526. CopyNDS26ToNDSSynId26(
  527. LPBYTE lpByte,
  528. PNDSOBJECT lpNdsObject
  529. )
  530. {
  531. LPASN1_TYPE_26 lpASN1_26 = (LPASN1_TYPE_26) lpByte;
  532. lpNdsObject->NdsType = NDS_SYNTAX_ID_26;
  533. lpNdsObject->NdsValue.value_26.ObjectName =
  534. (LPWSTR)AllocADsStr(lpASN1_26->ObjectName);
  535. lpNdsObject->NdsValue.value_26.Amount = lpASN1_26->Amount;
  536. lpByte = (LPBYTE ) lpASN1_26 + sizeof(ASN1_TYPE_26);
  537. return(lpByte);
  538. }
  539. LPBYTE
  540. CopyNDS27ToNDSSynId27(
  541. LPBYTE lpByte,
  542. PNDSOBJECT lpNdsObject
  543. )
  544. {
  545. LPASN1_TYPE_27 lpASN1_27 = (LPASN1_TYPE_27) lpByte;
  546. lpNdsObject->NdsType = NDS_SYNTAX_ID_27;
  547. lpNdsObject->NdsValue.value_27.Interval = lpASN1_27->Interval;
  548. lpByte = (LPBYTE ) lpASN1_27 + sizeof(ASN1_TYPE_27);
  549. return(lpByte);
  550. }
  551. LPBYTE
  552. CopyNDSToNDSSynId(
  553. DWORD dwSyntaxId,
  554. LPBYTE lpByte,
  555. PNDSOBJECT lpNdsObject
  556. )
  557. {
  558. switch (dwSyntaxId) {
  559. case 1:
  560. lpByte = CopyNDS1ToNDSSynId1(
  561. lpByte,
  562. lpNdsObject
  563. );
  564. break;
  565. case 2:
  566. lpByte = CopyNDS2ToNDSSynId2(
  567. lpByte,
  568. lpNdsObject
  569. );
  570. break;
  571. case 3:
  572. lpByte = CopyNDS3ToNDSSynId3(
  573. lpByte,
  574. lpNdsObject
  575. );
  576. break;
  577. case 4:
  578. lpByte = CopyNDS4ToNDSSynId4(
  579. lpByte,
  580. lpNdsObject
  581. );
  582. break;
  583. case 5:
  584. lpByte = CopyNDS5ToNDSSynId5(
  585. lpByte,
  586. lpNdsObject
  587. );
  588. break;
  589. case 6:
  590. lpByte = CopyNDS6ToNDSSynId6(
  591. lpByte,
  592. lpNdsObject
  593. );
  594. break;
  595. case 7:
  596. lpByte = CopyNDS7ToNDSSynId7(
  597. lpByte,
  598. lpNdsObject
  599. );
  600. break;
  601. case 8:
  602. lpByte = CopyNDS8ToNDSSynId8(
  603. lpByte,
  604. lpNdsObject
  605. );
  606. break;
  607. case 9:
  608. lpByte = CopyNDS9ToNDSSynId9(
  609. lpByte,
  610. lpNdsObject
  611. );
  612. break;
  613. case 10:
  614. lpByte = CopyNDS10ToNDSSynId10(
  615. lpByte,
  616. lpNdsObject
  617. );
  618. break;
  619. case 11:
  620. lpByte = CopyNDS11ToNDSSynId11(
  621. lpByte,
  622. lpNdsObject
  623. );
  624. break;
  625. case 12:
  626. lpByte = CopyNDS12ToNDSSynId12(
  627. lpByte,
  628. lpNdsObject
  629. );
  630. break;
  631. case 13:
  632. lpByte = CopyNDS13ToNDSSynId13(
  633. lpByte,
  634. lpNdsObject
  635. );
  636. break;
  637. case 14:
  638. lpByte = CopyNDS14ToNDSSynId14(
  639. lpByte,
  640. lpNdsObject
  641. );
  642. break;
  643. case 15:
  644. lpByte = CopyNDS15ToNDSSynId15(
  645. lpByte,
  646. lpNdsObject
  647. );
  648. break;
  649. case 16:
  650. lpByte = CopyNDS16ToNDSSynId16(
  651. lpByte,
  652. lpNdsObject
  653. );
  654. break;
  655. case 17:
  656. lpByte = CopyNDS17ToNDSSynId17(
  657. lpByte,
  658. lpNdsObject
  659. );
  660. break;
  661. case 18:
  662. lpByte = CopyNDS18ToNDSSynId18(
  663. lpByte,
  664. lpNdsObject
  665. );
  666. break;
  667. case 19:
  668. lpByte = CopyNDS19ToNDSSynId19(
  669. lpByte,
  670. lpNdsObject
  671. );
  672. break;
  673. case 20:
  674. lpByte = CopyNDS20ToNDSSynId20(
  675. lpByte,
  676. lpNdsObject
  677. );
  678. break;
  679. case 21:
  680. lpByte = CopyNDS21ToNDSSynId21(
  681. lpByte,
  682. lpNdsObject
  683. );
  684. break;
  685. case 22:
  686. lpByte = CopyNDS22ToNDSSynId22(
  687. lpByte,
  688. lpNdsObject
  689. );
  690. break;
  691. case 23:
  692. lpByte = CopyNDS23ToNDSSynId23(
  693. lpByte,
  694. lpNdsObject
  695. );
  696. break;
  697. case 24:
  698. lpByte = CopyNDS24ToNDSSynId24(
  699. lpByte,
  700. lpNdsObject
  701. );
  702. break;
  703. case 25:
  704. lpByte = CopyNDS25ToNDSSynId25(
  705. lpByte,
  706. lpNdsObject
  707. );
  708. break;
  709. case 26:
  710. lpByte = CopyNDS26ToNDSSynId26(
  711. lpByte,
  712. lpNdsObject
  713. );
  714. break;
  715. case 27:
  716. lpByte = CopyNDS27ToNDSSynId27(
  717. lpByte,
  718. lpNdsObject
  719. );
  720. break;
  721. default:
  722. break;
  723. }
  724. return(lpByte);
  725. }
  726. HRESULT
  727. UnMarshallNDSToNDSSynId(
  728. DWORD dwSyntaxId,
  729. DWORD dwNumValues,
  730. LPBYTE lpValue,
  731. PNDSOBJECT * ppNdsObject
  732. )
  733. {
  734. HRESULT hr = S_OK;
  735. LPBYTE lpByte = lpValue;
  736. DWORD i = 0;
  737. PNDSOBJECT pNdsObject = NULL;
  738. pNdsObject = (PNDSOBJECT)AllocADsMem(
  739. dwNumValues * sizeof(NDSOBJECT)
  740. );
  741. if (!pNdsObject) {
  742. RRETURN(E_FAIL);
  743. }
  744. for (i = 0; i < dwNumValues; i++) {
  745. lpByte = CopyNDSToNDSSynId(
  746. dwSyntaxId,
  747. lpByte,
  748. (pNdsObject + i)
  749. );
  750. if (!lpByte) {
  751. hr = E_OUTOFMEMORY;
  752. BAIL_ON_FAILURE(hr);
  753. }
  754. }
  755. *ppNdsObject = pNdsObject;
  756. error:
  757. RRETURN(hr);
  758. }