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.

7131 lines
164 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. llsrpc.c
  5. Abstract:
  6. Client side RPC wrappers for License Logging Service.
  7. Author:
  8. Arthur Hanson (arth) 30-Jan-1995
  9. Revision History:
  10. Jeff Parham (jeffparh) 04-Dec-1995
  11. o Forced include of LLS API prototypes, exposing an incorrect prototype
  12. in LLSAPI.H.
  13. o Fixed case where an LSA access denied was interpreted as implying the
  14. server had no DC, rather than properly bubbling the access denied back
  15. to the caller (of LlsConnectEnterprise()). This plugs a security hole
  16. wherein a non-admin user with the ability to read the System registry
  17. key would be allowed to administer domain licenses through
  18. License Manager. (Bug #11441.)
  19. o Added functions to support extended LLSRPC API.
  20. o Removed replication dependency on no further LlsConnect()'s being made
  21. until replication was completed.
  22. o Installed lock around llsrpc_handle global binding variable. Required
  23. addition of DllMain() function.
  24. o Added LLSRPC capabilities detection. Upon connection, the client
  25. requests the server's capabilities (an RPC call which itself will fail
  26. when connected to a 3.51 server). The capabilities set is an
  27. arbitrary bit field, but individual bits are normally defined to
  28. indicate that a specific feature has been implemented at the server.
  29. o Added szServerName filed to LOCAL_HANDLE to remember the name of the
  30. machine to which we're connected.
  31. --*/
  32. #include <nt.h>
  33. #include <ntlsa.h>
  34. #include <ntsam.h>
  35. #include <ntrtl.h>
  36. #include <nturtl.h>
  37. #include <windows.h>
  38. #include <lm.h>
  39. #include <dsgetdc.h>
  40. #include <dsrole.h>
  41. #include "debug.h"
  42. #include "llsapi.h"
  43. #include "llsrpc_c.h"
  44. #include "lsapi_c.h"
  45. #include <strsafe.h> //include it last
  46. // #define API_TRACE
  47. typedef struct _GENERIC_INFO_CONTAINER {
  48. DWORD EntriesRead;
  49. LPBYTE Buffer;
  50. } GENERIC_INFO_CONTAINER, *PGENERIC_INFO_CONTAINER, *LPGENERIC_INFO_CONTAINER ;
  51. typedef struct _GENERIC_ENUM_STRUCT {
  52. DWORD Level;
  53. PGENERIC_INFO_CONTAINER Container;
  54. } GENERIC_ENUM_STRUCT, *PGENERIC_ENUM_STRUCT, *LPGENERIC_ENUM_STRUCT ;
  55. typedef struct _LOCAL_HANDLE {
  56. TCHAR szServerName[ 3 + MAX_PATH ];
  57. LPTSTR pszStringBinding;
  58. handle_t llsrpc_handle;
  59. LLS_HANDLE Handle;
  60. BYTE Capabilities[ ( LLS_CAPABILITY_MAX + 7 ) / 8 ];
  61. } LOCAL_HANDLE, *PLOCAL_HANDLE;
  62. LPTSTR pszStringBinding = NULL;
  63. RTL_CRITICAL_SECTION g_RpcHandleLock;
  64. /////////////////////////////////////////////////////////////////////////
  65. BOOL APIENTRY DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved )
  66. /*++
  67. Routine Description:
  68. Standard DLL entry point.
  69. Arguments:
  70. hInstance (HINSTANCE)
  71. dwReason (DWORD)
  72. lpReserved (LPVOID)
  73. Return Value:
  74. TRUE if successful.
  75. --*/
  76. {
  77. NTSTATUS nt = STATUS_SUCCESS;
  78. UNREFERENCED_PARAMETER(lpReserved);
  79. switch (dwReason)
  80. {
  81. case DLL_PROCESS_ATTACH:
  82. DisableThreadLibraryCalls(hInstance);
  83. nt = RtlInitializeCriticalSection( &g_RpcHandleLock );
  84. break;
  85. case DLL_PROCESS_DETACH:
  86. nt = RtlDeleteCriticalSection( &g_RpcHandleLock );
  87. break;
  88. }
  89. return NT_SUCCESS( nt );
  90. }
  91. /////////////////////////////////////////////////////////////////////////
  92. NTSTATUS
  93. NTDomainGet(
  94. LPTSTR ServerName,
  95. LPTSTR Domain,
  96. DWORD cbDomain
  97. )
  98. /*++
  99. Routine Description:
  100. Arguments:
  101. Return Value:
  102. None.
  103. --*/
  104. {
  105. TCHAR Serv[MAX_PATH + 3];
  106. UNICODE_STRING us;
  107. NTSTATUS ret;
  108. OBJECT_ATTRIBUTES oa;
  109. ACCESS_MASK am;
  110. SECURITY_QUALITY_OF_SERVICE qos;
  111. LSA_HANDLE hLSA;
  112. PPOLICY_PRIMARY_DOMAIN_INFO pvBuffer;
  113. HRESULT hr;
  114. ASSERT(NULL != Domain);
  115. ASSERT(0 < cbDomain);
  116. Domain[0] = 0;
  117. // only need read access
  118. //
  119. //am = POLICY_READ | POLICY_VIEW_LOCAL_INFORMATION;
  120. am = MAXIMUM_ALLOWED;
  121. // set up quality of service
  122. qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
  123. qos.ImpersonationLevel = SecurityImpersonation;
  124. qos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
  125. qos.EffectiveOnly = FALSE;
  126. // Macro sets everything except security field
  127. InitializeObjectAttributes( &oa, NULL, 0L, NULL, NULL );
  128. oa.SecurityQualityOfService = &qos;
  129. if ( (ServerName == NULL) || (ServerName[0] == TEXT('\0')) )
  130. ret = LsaOpenPolicy(NULL, &oa, am, &hLSA);
  131. else {
  132. if (ServerName[0] == TEXT('\\'))
  133. hr = StringCbCopy(Serv, sizeof(Serv), ServerName);
  134. else
  135. hr = StringCbPrintf(Serv, sizeof(Serv), TEXT("\\\\%s"), ServerName);
  136. ASSERT(SUCCEEDED(hr));
  137. // Set up unicode string structure
  138. us.Length = (USHORT)(lstrlen(Serv) * sizeof(TCHAR));
  139. us.MaximumLength = us.Length + sizeof(TCHAR);
  140. us.Buffer = Serv;
  141. ret = LsaOpenPolicy(&us, &oa, am, &hLSA);
  142. }
  143. if (!ret) {
  144. //swi code review, seems PolicyPrimaryDomainInformation is obsolete, should use PolicyDnsDomainInformation?
  145. ret = LsaQueryInformationPolicy(hLSA, PolicyPrimaryDomainInformation, (PVOID *) &pvBuffer);
  146. LsaClose(hLSA);
  147. if ((!ret) && (pvBuffer != NULL) && (pvBuffer->Sid != NULL)) {
  148. hr = StringCbCopy(Domain, cbDomain, pvBuffer->Name.Buffer);
  149. ASSERT(SUCCEEDED(hr));
  150. LsaFreeMemory((PVOID) pvBuffer);
  151. } else
  152. if (!ret)
  153. ret = STATUS_UNSUCCESSFUL;
  154. }
  155. return ret;
  156. } // NTDomainGet
  157. /////////////////////////////////////////////////////////////////////////
  158. NTSTATUS
  159. EnterpriseServerGet(
  160. LPTSTR ServerName,
  161. LPTSTR pEnterpriseServer,
  162. DWORD cbEnterpriseServer
  163. )
  164. /*++
  165. Routine Description:
  166. Arguments:
  167. Return Value:
  168. None.
  169. --*/
  170. {
  171. HKEY hKey = NULL;
  172. HKEY hKey2 = NULL;
  173. BOOL bIsNetBIOSName = TRUE;
  174. DWORD dwType, dwSize;
  175. TCHAR RegKeyText[512];
  176. NTSTATUS Status;
  177. DWORD UseEnterprise;
  178. TCHAR EnterpriseServer[MAX_PATH + 3] = TEXT("");
  179. LPTSTR pName = ServerName;
  180. HRESULT hr;
  181. Status = RegConnectRegistry(ServerName, HKEY_LOCAL_MACHINE, &hKey);
  182. if (Status == ERROR_SUCCESS) {
  183. //
  184. // Create registry key-name we are looking for
  185. //
  186. hr = StringCbCopy(RegKeyText, sizeof(RegKeyText), TEXT("System\\CurrentControlSet\\Services\\LicenseService\\Parameters"));
  187. ASSERT(SUCCEEDED(hr));
  188. if ((Status = RegOpenKeyEx(hKey, RegKeyText, 0, KEY_READ, &hKey2)) == ERROR_SUCCESS) {
  189. dwSize = sizeof(UseEnterprise);
  190. Status = RegQueryValueEx(hKey2, TEXT("UseEnterprise"), NULL, &dwType, (LPBYTE) &UseEnterprise, &dwSize);
  191. if ((Status == ERROR_SUCCESS) && (UseEnterprise == 1)) {
  192. //
  193. // ** NEW - NT 5.0 **
  194. //
  195. // NB : This is temporary code! The proper way to do this is to
  196. // consult the license settings object in the site in which
  197. // the server resides.
  198. //
  199. // Read the SiteServer value first, if available, to get the site
  200. // server's DNS name. If this fails, default to EnterpriseServer.
  201. //
  202. dwSize = sizeof(EnterpriseServer);
  203. Status = RegQueryValueEx(hKey2,
  204. TEXT("SiteServer"),
  205. NULL,
  206. &dwType,
  207. (LPBYTE)EnterpriseServer,
  208. &dwSize);
  209. if (Status == ERROR_SUCCESS && EnterpriseServer[0]) {
  210. bIsNetBIOSName = FALSE;
  211. }
  212. else {
  213. dwSize = sizeof(EnterpriseServer);
  214. Status = RegQueryValueEx(hKey2,
  215. TEXT("EnterpriseServer"),
  216. NULL,
  217. &dwType,
  218. (LPBYTE)EnterpriseServer,
  219. &dwSize);
  220. }
  221. if (Status == ERROR_SUCCESS) {
  222. pName = EnterpriseServer;
  223. }
  224. }
  225. RegCloseKey(hKey2);
  226. }
  227. RegCloseKey(hKey);
  228. }
  229. if (bIsNetBIOSName && *pName != TEXT('\\')) {
  230. hr = StringCbCopy(pEnterpriseServer, cbEnterpriseServer, TEXT("\\\\"));
  231. ASSERT(SUCCEEDED(hr));
  232. hr = StringCbCat(pEnterpriseServer, cbEnterpriseServer, pName);
  233. ASSERT(SUCCEEDED(hr));
  234. } else {
  235. hr = StringCbCopy(pEnterpriseServer, cbEnterpriseServer, pName);
  236. ASSERT(SUCCEEDED(hr));
  237. }
  238. return STATUS_SUCCESS;
  239. } // EnterpriseServerGet
  240. /////////////////////////////////////////////////////////////////////////
  241. /////////////////////////////////////////////////////////////////////////
  242. /////////////////////////////////////////////////////////////////////////
  243. /////////////////////////////////////////////////////////////////////////
  244. NTSTATUS
  245. NTAPI
  246. LlsEnterpriseServerFindW(
  247. LPTSTR Focus,
  248. DWORD Level,
  249. LPBYTE *BufPtr
  250. )
  251. /*++
  252. Routine Description:
  253. Arguments:
  254. Return Value:
  255. None.
  256. --*/
  257. {
  258. NTSTATUS Status;
  259. LPTSTR pFocus;
  260. BOOL Domain = TRUE;
  261. TCHAR EnterpriseServer[MAX_PATH + 4];
  262. TCHAR szDomain[MAX_PATH + 4];
  263. DWORD uRet;
  264. PDOMAIN_CONTROLLER_INFO pbBuffer = NULL;
  265. PLLS_CONNECT_INFO_0 pConnectInfo;
  266. ULONG Size;
  267. DSROLE_PRIMARY_DOMAIN_INFO_BASIC *pDomainInfo = NULL;
  268. BOOL fInWorkgroup = TRUE;
  269. HRESULT hr;
  270. DWORD cch1, cch2;
  271. ASSERT(NULL != BufPtr);
  272. *BufPtr = NULL;
  273. if (Level != 0)
  274. return STATUS_INVALID_LEVEL;
  275. szDomain[0] = 0;
  276. EnterpriseServer[0] = 0;
  277. //
  278. // Figure out if doing domain or server
  279. //
  280. pFocus = Focus;
  281. if (pFocus !=NULL)
  282. while ((*pFocus != TEXT('\0')) && (*pFocus == TEXT('\\'))) {
  283. Domain = FALSE;
  284. pFocus++;
  285. }
  286. uRet = DsRoleGetPrimaryDomainInformation((!Domain) ? Focus : NULL,
  287. DsRolePrimaryDomainInfoBasic,
  288. (PBYTE *) &pDomainInfo);
  289. if ((uRet == NO_ERROR) && (pDomainInfo != NULL) && (pDomainInfo->MachineRole != DsRole_RoleStandaloneWorkstation) && (pDomainInfo->MachineRole != DsRole_RoleStandaloneServer))
  290. {
  291. fInWorkgroup = FALSE;
  292. }
  293. if ((uRet == NO_ERROR) && (pDomainInfo != NULL))
  294. {
  295. DsRoleFreeMemory(pDomainInfo);
  296. }
  297. if (!fInWorkgroup)
  298. {
  299. //
  300. // If we got a domain find the DC of it, else find DC of server
  301. //
  302. if (!Domain) {
  303. uRet = DsGetDcName(Focus, NULL, NULL, NULL, DS_BACKGROUND_ONLY, &pbBuffer);
  304. } else {
  305. //
  306. // Get the DC name of wherever we are going
  307. //
  308. if ((pFocus == NULL) || (*pFocus == TEXT('\0')))
  309. uRet = DsGetDcName(NULL, NULL, NULL, NULL, DS_BACKGROUND_ONLY, &pbBuffer);
  310. else
  311. uRet = DsGetDcName(NULL, pFocus, NULL, NULL, DS_BACKGROUND_ONLY, &pbBuffer);
  312. }
  313. }
  314. else
  315. {
  316. //
  317. // Not in a domain, don't call DsGetDcName
  318. //
  319. uRet = ERROR_NO_SUCH_DOMAIN;
  320. }
  321. if (uRet || (pbBuffer == NULL)) {
  322. //
  323. // If we focus on a server and can't find a domain then look for an
  324. // enterprise server. This is the case if the focus server is a
  325. // standalone system.
  326. //
  327. if (Domain == FALSE) {
  328. Status = EnterpriseServerGet((LPTSTR) Focus, EnterpriseServer, sizeof(EnterpriseServer));
  329. goto LlsEnterpriseServerFindWExit;
  330. }
  331. return STATUS_NO_SUCH_DOMAIN;
  332. } else {
  333. hr = StringCbCopy(szDomain, sizeof(szDomain), pbBuffer->DomainName);
  334. ASSERT(SUCCEEDED(hr));
  335. }
  336. //
  337. // Go to DC and figure out if they are replicating anywhere, if so go
  338. // to that system.
  339. //
  340. Status = EnterpriseServerGet((LPTSTR) (pbBuffer->DomainControllerName), EnterpriseServer, sizeof(EnterpriseServer));
  341. if (pbBuffer != NULL)
  342. NetApiBufferFree(pbBuffer);
  343. LlsEnterpriseServerFindWExit:
  344. if (Status != STATUS_SUCCESS)
  345. return Status;
  346. cch1 = lstrlen(szDomain) + 1;
  347. cch2 = lstrlen(EnterpriseServer) + 1;
  348. Size = sizeof(LLS_CONNECT_INFO_0);
  349. Size += (cch1 + cch2) * sizeof(TCHAR);
  350. pConnectInfo = (PLLS_CONNECT_INFO_0) MIDL_user_allocate(Size);
  351. if (pConnectInfo == NULL)
  352. return STATUS_NO_MEMORY;
  353. pConnectInfo->Domain = (LPTSTR) (((PBYTE) pConnectInfo) + sizeof(LLS_CONNECT_INFO_0));
  354. pConnectInfo->EnterpriseServer = (LPTSTR) &pConnectInfo->Domain[lstrlen(szDomain) + 1];
  355. hr = StringCchCopy(pConnectInfo->Domain, cch1, szDomain);
  356. ASSERT(SUCCEEDED(hr));
  357. hr = StringCchCopy(pConnectInfo->EnterpriseServer, cch2, EnterpriseServer);
  358. ASSERT(SUCCEEDED(hr));
  359. *BufPtr = (LPBYTE) pConnectInfo;
  360. return Status;
  361. } // LlsEnterpriseServerFindW
  362. /////////////////////////////////////////////////////////////////////////
  363. NTSTATUS
  364. NTAPI
  365. LlsEnterpriseServerFindA(
  366. LPSTR Focus,
  367. DWORD Level,
  368. LPBYTE *BufPtr
  369. )
  370. /*++
  371. Routine Description:
  372. Arguments:
  373. Return Value:
  374. None.
  375. --*/
  376. {
  377. #ifdef API_TRACE
  378. dprintf(TEXT("LLSRPC.DLL: LlsEnterpriseServerFindA\n"));
  379. #endif
  380. UNREFERENCED_PARAMETER(Focus);
  381. UNREFERENCED_PARAMETER(Level);
  382. UNREFERENCED_PARAMETER(BufPtr);
  383. return STATUS_NOT_SUPPORTED;
  384. } // LlsEnterpriseServerFindA
  385. /////////////////////////////////////////////////////////////////////////
  386. NTSTATUS
  387. NTAPI
  388. LlsConnectW(
  389. LPTSTR Server,
  390. LLS_HANDLE* Handle
  391. )
  392. /*++
  393. Routine Description:
  394. Arguments:
  395. Return Value:
  396. None.
  397. --*/
  398. {
  399. RPC_STATUS Status;
  400. LPTSTR pszUuid = NULL;
  401. LPTSTR pszProtocolSequence = NULL;
  402. LPTSTR pszNetworkAddress = NULL;
  403. LPTSTR pszEndpoint = NULL;
  404. LPTSTR pszOptions = NULL;
  405. TCHAR pComputer[MAX_COMPUTERNAME_LENGTH + 1];
  406. ULONG Size;
  407. PLOCAL_HANDLE pLocalHandle = NULL;
  408. handle_t prev_llsrpc_handle;
  409. HRESULT hr;
  410. DWORD cch;
  411. #ifdef API_TRACE
  412. if (Server == NULL)
  413. dprintf(TEXT("LLSRPC.DLL: LlsConnectW: <NULL>\n"));
  414. else
  415. dprintf(TEXT("LLSRPC.DLL: LlsConnectW: %s\n"), Server);
  416. #endif
  417. //
  418. // ** NEW - NT 5.0 **
  419. //
  420. // The server name may either be a DNS name or a NetBIOS name.
  421. //
  422. if (Handle == NULL)
  423. return STATUS_INVALID_PARAMETER;
  424. *Handle = NULL;
  425. Size = sizeof(pComputer) / sizeof(TCHAR);
  426. GetComputerName(pComputer, &Size);
  427. if ((Server == NULL) || (*Server == TEXT('\0'))) {
  428. pszProtocolSequence = TEXT("ncalrpc");
  429. pszEndpoint = TEXT(LLS_LPC_ENDPOINT);
  430. pszNetworkAddress = NULL;
  431. pszOptions = TEXT("Security=Identification Dynamic True"); // Bug# 559563 - Dynamic is default for ncalrpc
  432. } else {
  433. pszProtocolSequence = TEXT("ncacn_np");
  434. pszEndpoint = TEXT(LLS_NP_ENDPOINT);
  435. pszNetworkAddress = Server;
  436. pszOptions = TEXT("Security=Identification Static True"); // Bug# 559563 - Static is default for ncacn_np
  437. }
  438. pLocalHandle = MIDL_user_allocate(sizeof(LOCAL_HANDLE));
  439. if (pLocalHandle == NULL)
  440. return STATUS_NO_MEMORY;
  441. pLocalHandle->pszStringBinding = NULL;
  442. pLocalHandle->llsrpc_handle = NULL;
  443. pLocalHandle->Handle = NULL;
  444. //swi, code review, why zero memory here?
  445. ZeroMemory( pLocalHandle->szServerName, sizeof( pLocalHandle->szServerName ) );
  446. cch = sizeof( pLocalHandle->szServerName ) / sizeof( *pLocalHandle->szServerName );
  447. if ( NULL != Server )
  448. {
  449. hr = StringCchCopy( pLocalHandle->szServerName, cch, Server );
  450. ASSERT(SUCCEEDED(hr));
  451. }
  452. else
  453. {
  454. hr = StringCchCopy( pLocalHandle->szServerName, cch, pComputer );
  455. ASSERT(SUCCEEDED(hr));
  456. }
  457. // Compose a string binding
  458. Status = RpcStringBindingComposeW(pszUuid,
  459. pszProtocolSequence,
  460. pszNetworkAddress,
  461. pszEndpoint,
  462. pszOptions,
  463. &pLocalHandle->pszStringBinding);
  464. if(Status) {
  465. #if DBG
  466. dprintf(TEXT("LLSRPC RpcStringBindingComposeW Failed: 0x%lX\n"), Status);
  467. #endif
  468. if(pLocalHandle->pszStringBinding)
  469. {
  470. RpcStringFree(&pLocalHandle->pszStringBinding);
  471. pLocalHandle->pszStringBinding = NULL;
  472. }
  473. MIDL_user_free( pLocalHandle );
  474. return I_RpcMapWin32Status(Status);
  475. }
  476. RtlEnterCriticalSection( &g_RpcHandleLock );
  477. prev_llsrpc_handle = llsrpc_handle;
  478. llsrpc_handle = NULL;
  479. // Bind using the created string binding...
  480. Status = RpcBindingFromStringBindingW(pLocalHandle->pszStringBinding, &llsrpc_handle);
  481. if(Status) {
  482. #if DBG
  483. dprintf(TEXT("LLSRPC RpcBindingFromStringBindingW Failed: 0x%lX\n"), Status);
  484. #endif
  485. if(llsrpc_handle)
  486. {
  487. RpcBindingFree(llsrpc_handle);
  488. llsrpc_handle = prev_llsrpc_handle;
  489. }
  490. Status = I_RpcMapWin32Status(Status);
  491. }
  492. if ( NT_SUCCESS( Status ) )
  493. {
  494. pLocalHandle->llsrpc_handle = llsrpc_handle;
  495. try {
  496. Status = LlsrConnect(&pLocalHandle->Handle, pComputer);
  497. }
  498. except (TRUE) {
  499. Status = I_RpcMapWin32Status(RpcExceptionCode());
  500. #if DBG
  501. dprintf(TEXT("LLSRPC ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  502. #endif
  503. }
  504. if ( NT_SUCCESS( Status ) )
  505. {
  506. // get server capabilities
  507. try {
  508. LlsrCapabilityGet( pLocalHandle->Handle, sizeof( pLocalHandle->Capabilities ), pLocalHandle->Capabilities );
  509. }
  510. except (TRUE) {
  511. Status = I_RpcMapWin32Status(RpcExceptionCode());
  512. if ( RPC_NT_PROCNUM_OUT_OF_RANGE == Status )
  513. {
  514. // 'salright; API doesn't exist at target server (it's running 3.51)
  515. ZeroMemory( pLocalHandle->Capabilities, sizeof( pLocalHandle->Capabilities ) );
  516. Status = STATUS_SUCCESS;
  517. }
  518. else
  519. {
  520. #if DBG
  521. dprintf(TEXT("LLSRPC ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  522. #endif
  523. }
  524. }
  525. if ( !NT_SUCCESS( Status ) )
  526. {
  527. LlsClose( pLocalHandle );
  528. }
  529. else
  530. {
  531. *Handle = (LLS_HANDLE) pLocalHandle;
  532. }
  533. }
  534. else
  535. {
  536. if(pLocalHandle->pszStringBinding)
  537. {
  538. RpcStringFree(&pLocalHandle->pszStringBinding);
  539. pLocalHandle->pszStringBinding = NULL;
  540. }
  541. if(llsrpc_handle)
  542. {
  543. RpcBindingFree(llsrpc_handle);
  544. llsrpc_handle = prev_llsrpc_handle;
  545. }
  546. MIDL_user_free( pLocalHandle );
  547. }
  548. }
  549. else
  550. {
  551. if(pLocalHandle->pszStringBinding)
  552. RpcStringFree(&pLocalHandle->pszStringBinding);
  553. MIDL_user_free( pLocalHandle );
  554. }
  555. llsrpc_handle = prev_llsrpc_handle;
  556. RtlLeaveCriticalSection( &g_RpcHandleLock );
  557. return Status;
  558. } // LlsConnectW
  559. /////////////////////////////////////////////////////////////////////////
  560. NTSTATUS
  561. NTAPI
  562. LlsConnectA(
  563. LPSTR Server,
  564. LLS_HANDLE* Handle
  565. )
  566. /*++
  567. Routine Description:
  568. Arguments:
  569. Return Value:
  570. None.
  571. --*/
  572. {
  573. #ifdef API_TRACE
  574. dprintf(TEXT("LLSRPC.DLL: LlsConnectA\n"));
  575. #endif
  576. UNREFERENCED_PARAMETER(Handle);
  577. UNREFERENCED_PARAMETER(Server);
  578. return STATUS_NOT_SUPPORTED;
  579. } // LlsConnectA
  580. /////////////////////////////////////////////////////////////////////////
  581. NTSTATUS
  582. NTAPI
  583. LlsConnectEnterpriseW(
  584. LPTSTR Focus,
  585. LLS_HANDLE* Handle,
  586. DWORD Level,
  587. LPBYTE *BufPtr
  588. )
  589. /*++
  590. Routine Description:
  591. Arguments:
  592. Return Value:
  593. None.
  594. --*/
  595. {
  596. NTSTATUS Status;
  597. PLLS_CONNECT_INFO_0 pConnectInfo;
  598. Status = LlsEnterpriseServerFindW(Focus, Level, BufPtr);
  599. if (Status)
  600. return Status;
  601. pConnectInfo = (PLLS_CONNECT_INFO_0) *BufPtr;
  602. Status = LlsConnectW(pConnectInfo->EnterpriseServer, Handle);
  603. return Status;
  604. } // LlsConnectEnterpriseW
  605. /////////////////////////////////////////////////////////////////////////
  606. NTSTATUS
  607. NTAPI
  608. LlsConnectEnterpriseA(
  609. LPSTR Focus,
  610. LLS_HANDLE* Handle,
  611. DWORD Level,
  612. LPBYTE *BufPtr
  613. )
  614. /*++
  615. Routine Description:
  616. Arguments:
  617. Return Value:
  618. None.
  619. --*/
  620. {
  621. #ifdef API_TRACE
  622. dprintf(TEXT("LLSRPC.DLL: LlsConnectEnterpriseA\n"));
  623. #endif
  624. UNREFERENCED_PARAMETER(Handle);
  625. UNREFERENCED_PARAMETER(Focus);
  626. UNREFERENCED_PARAMETER(Level);
  627. UNREFERENCED_PARAMETER(BufPtr);
  628. return STATUS_NOT_SUPPORTED;
  629. } // LlsConnectEnterpriseA
  630. /////////////////////////////////////////////////////////////////////////
  631. NTSTATUS
  632. NTAPI
  633. LlsClose(
  634. LLS_HANDLE Handle
  635. )
  636. /*++
  637. Routine Description:
  638. Arguments:
  639. Return Value:
  640. None.
  641. --*/
  642. {
  643. RPC_STATUS Status;
  644. NTSTATUS NtStatus = STATUS_SUCCESS;
  645. PLOCAL_HANDLE pLocalHandle;
  646. pLocalHandle = (PLOCAL_HANDLE) Handle;
  647. if (pLocalHandle == NULL)
  648. return STATUS_INVALID_PARAMETER;
  649. try {
  650. NtStatus = LlsrCloseEx(&(pLocalHandle->Handle));
  651. }
  652. except (TRUE) {
  653. NtStatus = I_RpcMapWin32Status(RpcExceptionCode());
  654. #if DBG
  655. dprintf(TEXT("ERROR LLSRPC.DLL: LlsrCloseEx RPC Exception: 0x%lX\n"), NtStatus);
  656. #endif
  657. }
  658. //
  659. // LlsrCloseEx was added for NT 5.0. Check for downlevel.
  660. //
  661. if (NtStatus == RPC_S_PROCNUM_OUT_OF_RANGE) {
  662. try {
  663. NtStatus = LlsrClose(pLocalHandle->Handle);
  664. }
  665. except (TRUE) {
  666. NtStatus = I_RpcMapWin32Status(RpcExceptionCode());
  667. #if DBG
  668. dprintf(TEXT("ERROR LLSRPC.DLL: LlsrClose RPC Exception: 0x%lX\n"), NtStatus);
  669. #endif
  670. }
  671. }
  672. try {
  673. Status = RpcStringFree(&pLocalHandle->pszStringBinding);
  674. if (Status ) {
  675. NtStatus = I_RpcMapWin32Status(Status);
  676. #if DBG
  677. dprintf(TEXT("LLSRPC.DLL: LlsClose - RpcStringFree returned: 0x%lX\n"), NtStatus);
  678. #endif
  679. }
  680. Status = RpcBindingFree(&pLocalHandle->llsrpc_handle);
  681. if (Status ) {
  682. NtStatus = I_RpcMapWin32Status(Status);
  683. #if DBG
  684. dprintf(TEXT("LLSRPC.DLL: LlsClose - RpcBindingFree returned: 0x%lX\n"), NtStatus);
  685. #endif
  686. }
  687. }
  688. except (TRUE) {
  689. NtStatus = I_RpcMapWin32Status(RpcExceptionCode());
  690. #if DBG
  691. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), NtStatus);
  692. #endif
  693. }
  694. MIDL_user_free(pLocalHandle);
  695. return NtStatus;
  696. } // LlsClose
  697. /////////////////////////////////////////////////////////////////////////
  698. NTSTATUS
  699. NTAPI
  700. LlsFreeMemory(
  701. PVOID BufPtr
  702. )
  703. /*++
  704. Routine Description:
  705. Arguments:
  706. Return Value:
  707. None.
  708. --*/
  709. {
  710. MIDL_user_free( BufPtr );
  711. return STATUS_SUCCESS;
  712. } // LlsFreeMemory
  713. /////////////////////////////////////////////////////////////////////////
  714. NTSTATUS
  715. NTAPI
  716. LlsLicenseEnumW(
  717. LLS_HANDLE Handle,
  718. DWORD Level,
  719. LPBYTE* bufptr,
  720. DWORD PrefMaxLen,
  721. LPDWORD EntriesRead,
  722. LPDWORD TotalEntries,
  723. LPDWORD ResumeHandle
  724. )
  725. /*++
  726. Routine Description:
  727. Arguments:
  728. Return Value:
  729. None.
  730. --*/
  731. {
  732. NTSTATUS Status;
  733. GENERIC_INFO_CONTAINER GenericInfoContainer;
  734. GENERIC_ENUM_STRUCT InfoStruct;
  735. PLOCAL_HANDLE pLocalHandle;
  736. #ifdef API_TRACE
  737. dprintf(TEXT("LLSRPC.DLL: LlsLicenseEnumW\n"));
  738. #endif
  739. //init
  740. *bufptr = NULL;
  741. pLocalHandle = (PLOCAL_HANDLE) Handle;
  742. if (pLocalHandle == NULL)
  743. return STATUS_INVALID_PARAMETER;
  744. GenericInfoContainer.Buffer = NULL;
  745. GenericInfoContainer.EntriesRead = 0;
  746. InfoStruct.Container = &GenericInfoContainer;
  747. InfoStruct.Level = Level;
  748. try {
  749. Status = LlsrLicenseEnumW(
  750. pLocalHandle->Handle,
  751. (PLLS_LICENSE_ENUM_STRUCTW) &InfoStruct,
  752. PrefMaxLen,
  753. TotalEntries,
  754. ResumeHandle
  755. );
  756. }
  757. except (TRUE) {
  758. Status = I_RpcMapWin32Status(RpcExceptionCode());
  759. #if DBG
  760. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  761. #endif
  762. }
  763. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  764. if (NULL != GenericInfoContainer.Buffer)
  765. {
  766. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  767. *EntriesRead = GenericInfoContainer.EntriesRead;
  768. }
  769. else
  770. {
  771. Status = ERROR_INVALID_DATA;
  772. }
  773. }
  774. return Status;
  775. } // LlsLicenseEnumW
  776. /////////////////////////////////////////////////////////////////////////
  777. NTSTATUS
  778. NTAPI
  779. LlsLicenseEnumA(
  780. LLS_HANDLE Handle,
  781. DWORD Level,
  782. LPBYTE* bufptr,
  783. DWORD PrefMaxLen,
  784. LPDWORD EntriesRead,
  785. LPDWORD TotalEntries,
  786. LPDWORD ResumeHandle
  787. )
  788. /*++
  789. Routine Description:
  790. Arguments:
  791. Return Value:
  792. None.
  793. --*/
  794. {
  795. NTSTATUS Status;
  796. GENERIC_INFO_CONTAINER GenericInfoContainer;
  797. GENERIC_ENUM_STRUCT InfoStruct;
  798. PLOCAL_HANDLE pLocalHandle;
  799. #ifdef API_TRACE
  800. dprintf(TEXT("LLSRPC.DLL: LlsLicenseEnumA\n"));
  801. #endif
  802. pLocalHandle = (PLOCAL_HANDLE) Handle;
  803. if (pLocalHandle == NULL)
  804. return STATUS_INVALID_PARAMETER;
  805. GenericInfoContainer.Buffer = NULL;
  806. GenericInfoContainer.EntriesRead = 0;
  807. InfoStruct.Container = &GenericInfoContainer;
  808. InfoStruct.Level = Level;
  809. try {
  810. Status = LlsrLicenseEnumA(
  811. pLocalHandle->Handle,
  812. (PLLS_LICENSE_ENUM_STRUCTA) &InfoStruct,
  813. PrefMaxLen,
  814. TotalEntries,
  815. ResumeHandle
  816. );
  817. }
  818. except (TRUE) {
  819. Status = I_RpcMapWin32Status(RpcExceptionCode());
  820. #if DBG
  821. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  822. #endif
  823. }
  824. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  825. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  826. *EntriesRead = GenericInfoContainer.EntriesRead;
  827. }
  828. return Status;
  829. } // LlsLicenseEnumA
  830. /////////////////////////////////////////////////////////////////////////
  831. NTSTATUS
  832. NTAPI
  833. LlsLicenseAddW(
  834. IN LLS_HANDLE Handle,
  835. IN DWORD Level, // Level 0 supported
  836. IN LPBYTE bufptr
  837. )
  838. /*++
  839. Routine Description:
  840. Arguments:
  841. Return Value:
  842. None.
  843. --*/
  844. {
  845. NTSTATUS Status;
  846. PLOCAL_HANDLE pLocalHandle;
  847. #ifdef API_TRACE
  848. dprintf(TEXT("LLSRPC.DLL: LlsLicenseAddW\n"));
  849. #endif
  850. pLocalHandle = (PLOCAL_HANDLE) Handle;
  851. if (pLocalHandle == NULL)
  852. return STATUS_INVALID_PARAMETER;
  853. try {
  854. Status = LlsrLicenseAddW(pLocalHandle->Handle, Level, (PVOID) bufptr);
  855. }
  856. except (TRUE) {
  857. Status = I_RpcMapWin32Status(RpcExceptionCode());
  858. #if DBG
  859. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  860. #endif
  861. }
  862. return Status;
  863. } // LlsLicenseAddW
  864. /////////////////////////////////////////////////////////////////////////
  865. NTSTATUS
  866. NTAPI
  867. LlsLicenseAddA(
  868. IN LLS_HANDLE Handle,
  869. IN DWORD Level, // Level 0 supported
  870. IN LPBYTE bufptr
  871. )
  872. /*++
  873. Routine Description:
  874. Arguments:
  875. Return Value:
  876. None.
  877. --*/
  878. {
  879. NTSTATUS Status;
  880. PLOCAL_HANDLE pLocalHandle;
  881. #ifdef API_TRACE
  882. dprintf(TEXT("LLSRPC.DLL: LlsLicenseAddA\n"));
  883. #endif
  884. pLocalHandle = (PLOCAL_HANDLE) Handle;
  885. if (pLocalHandle == NULL)
  886. return STATUS_INVALID_PARAMETER;
  887. try {
  888. Status = LlsrLicenseAddA(pLocalHandle->Handle, Level, (PVOID) bufptr);
  889. }
  890. except (TRUE) {
  891. Status = I_RpcMapWin32Status(RpcExceptionCode());
  892. #if DBG
  893. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  894. #endif
  895. }
  896. return Status;
  897. } // LlsLicenseAddA
  898. /////////////////////////////////////////////////////////////////////////
  899. NTSTATUS
  900. NTAPI
  901. LlsProductEnumW(
  902. LLS_HANDLE Handle,
  903. DWORD Level,
  904. LPBYTE* bufptr,
  905. DWORD PrefMaxLen,
  906. LPDWORD EntriesRead,
  907. LPDWORD TotalEntries,
  908. LPDWORD ResumeHandle
  909. )
  910. /*++
  911. Routine Description:
  912. Arguments:
  913. Return Value:
  914. None.
  915. --*/
  916. {
  917. NTSTATUS Status;
  918. GENERIC_INFO_CONTAINER GenericInfoContainer;
  919. GENERIC_ENUM_STRUCT InfoStruct;
  920. PLOCAL_HANDLE pLocalHandle;
  921. #ifdef API_TRACE
  922. dprintf(TEXT("LLSRPC.DLL: LlsProductEnumW\n"));
  923. #endif
  924. //init
  925. *bufptr = NULL;
  926. pLocalHandle = (PLOCAL_HANDLE) Handle;
  927. if (pLocalHandle == NULL)
  928. return STATUS_INVALID_PARAMETER;
  929. GenericInfoContainer.Buffer = NULL;
  930. GenericInfoContainer.EntriesRead = 0;
  931. InfoStruct.Container = &GenericInfoContainer;
  932. InfoStruct.Level = Level;
  933. try {
  934. Status = LlsrProductEnumW(
  935. pLocalHandle->Handle,
  936. (PLLS_PRODUCT_ENUM_STRUCTW) &InfoStruct,
  937. PrefMaxLen,
  938. TotalEntries,
  939. ResumeHandle
  940. );
  941. }
  942. except (TRUE) {
  943. Status = I_RpcMapWin32Status(RpcExceptionCode());
  944. #if DBG
  945. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  946. #endif
  947. }
  948. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  949. if (NULL != GenericInfoContainer.Buffer)
  950. {
  951. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  952. *EntriesRead = GenericInfoContainer.EntriesRead;
  953. }
  954. else
  955. {
  956. Status = ERROR_INVALID_DATA;
  957. }
  958. }
  959. return Status;
  960. } // LlsProductEnumW
  961. /////////////////////////////////////////////////////////////////////////
  962. NTSTATUS
  963. NTAPI
  964. LlsProductEnumA(
  965. LLS_HANDLE Handle,
  966. DWORD Level,
  967. LPBYTE* bufptr,
  968. DWORD PrefMaxLen,
  969. LPDWORD EntriesRead,
  970. LPDWORD TotalEntries,
  971. LPDWORD ResumeHandle
  972. )
  973. /*++
  974. Routine Description:
  975. Arguments:
  976. Return Value:
  977. None.
  978. --*/
  979. {
  980. NTSTATUS Status;
  981. GENERIC_INFO_CONTAINER GenericInfoContainer;
  982. GENERIC_ENUM_STRUCT InfoStruct;
  983. PLOCAL_HANDLE pLocalHandle;
  984. #ifdef API_TRACE
  985. dprintf(TEXT("LLSRPC.DLL: LlsProductEnumA\n"));
  986. #endif
  987. pLocalHandle = (PLOCAL_HANDLE) Handle;
  988. if (pLocalHandle == NULL)
  989. return STATUS_INVALID_PARAMETER;
  990. GenericInfoContainer.Buffer = NULL;
  991. GenericInfoContainer.EntriesRead = 0;
  992. InfoStruct.Container = &GenericInfoContainer;
  993. InfoStruct.Level = Level;
  994. try {
  995. Status = LlsrProductEnumA(
  996. pLocalHandle->Handle,
  997. (PLLS_PRODUCT_ENUM_STRUCTA) &InfoStruct,
  998. PrefMaxLen,
  999. TotalEntries,
  1000. ResumeHandle
  1001. );
  1002. }
  1003. except (TRUE) {
  1004. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1005. #if DBG
  1006. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1007. #endif
  1008. }
  1009. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1010. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1011. *EntriesRead = GenericInfoContainer.EntriesRead;
  1012. }
  1013. return Status;
  1014. } // LlsProductEnumA
  1015. /////////////////////////////////////////////////////////////////////////
  1016. NTSTATUS
  1017. LlsProductAddW(
  1018. IN LLS_REPL_HANDLE Handle,
  1019. IN LPWSTR ProductFamily,
  1020. IN LPWSTR Product,
  1021. IN LPWSTR Version
  1022. )
  1023. /*++
  1024. Routine Description:
  1025. Arguments:
  1026. Return Value:
  1027. None.
  1028. --*/
  1029. {
  1030. NTSTATUS Status;
  1031. PLOCAL_HANDLE pLocalHandle;
  1032. #ifdef API_TRACE
  1033. dprintf(TEXT("LLSRPC.DLL: LlsProductAddW\n"));
  1034. #endif
  1035. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1036. if (pLocalHandle == NULL)
  1037. return STATUS_INVALID_PARAMETER;
  1038. try {
  1039. Status = LlsrProductAddW(pLocalHandle->Handle, ProductFamily, Product, Version);
  1040. }
  1041. except (TRUE) {
  1042. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1043. #if DBG
  1044. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1045. #endif
  1046. }
  1047. return Status;
  1048. } // LlsProductAddW
  1049. /////////////////////////////////////////////////////////////////////////
  1050. NTSTATUS
  1051. LlsProductAddA(
  1052. IN LLS_REPL_HANDLE Handle,
  1053. IN LPSTR ProductFamily,
  1054. IN LPSTR Product,
  1055. IN LPSTR Version
  1056. )
  1057. /*++
  1058. Routine Description:
  1059. Arguments:
  1060. Return Value:
  1061. None.
  1062. --*/
  1063. {
  1064. NTSTATUS Status;
  1065. PLOCAL_HANDLE pLocalHandle;
  1066. #ifdef API_TRACE
  1067. dprintf(TEXT("LLSRPC.DLL: LlsProductAddA\n"));
  1068. #endif
  1069. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1070. if (pLocalHandle == NULL)
  1071. return STATUS_INVALID_PARAMETER;
  1072. try {
  1073. Status = LlsrProductAddA(pLocalHandle->Handle, ProductFamily, Product, Version);
  1074. }
  1075. except (TRUE) {
  1076. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1077. #if DBG
  1078. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1079. #endif
  1080. }
  1081. return Status;
  1082. } // LlsProductAddA
  1083. /////////////////////////////////////////////////////////////////////////
  1084. NTSTATUS
  1085. NTAPI
  1086. LlsProductUserEnumW(
  1087. LLS_HANDLE Handle,
  1088. LPTSTR Product,
  1089. DWORD Level,
  1090. LPBYTE* bufptr,
  1091. DWORD PrefMaxLen,
  1092. LPDWORD EntriesRead,
  1093. LPDWORD TotalEntries,
  1094. LPDWORD ResumeHandle
  1095. )
  1096. /*++
  1097. Routine Description:
  1098. Arguments:
  1099. Return Value:
  1100. None.
  1101. --*/
  1102. {
  1103. NTSTATUS Status;
  1104. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1105. GENERIC_ENUM_STRUCT InfoStruct;
  1106. PLOCAL_HANDLE pLocalHandle;
  1107. #ifdef API_TRACE
  1108. dprintf(TEXT("LLSRPC.DLL: LlsProductUserEnumW\n"));
  1109. #endif
  1110. //init
  1111. *bufptr = NULL;
  1112. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1113. if (pLocalHandle == NULL)
  1114. return STATUS_INVALID_PARAMETER;
  1115. GenericInfoContainer.Buffer = NULL;
  1116. GenericInfoContainer.EntriesRead = 0;
  1117. InfoStruct.Container = &GenericInfoContainer;
  1118. InfoStruct.Level = Level;
  1119. try {
  1120. Status = LlsrProductUserEnumW(
  1121. pLocalHandle->Handle,
  1122. Product,
  1123. (PLLS_PRODUCT_USER_ENUM_STRUCTW) &InfoStruct,
  1124. PrefMaxLen,
  1125. TotalEntries,
  1126. ResumeHandle
  1127. );
  1128. }
  1129. except (TRUE) {
  1130. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1131. #if DBG
  1132. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1133. #endif
  1134. }
  1135. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1136. if (NULL != GenericInfoContainer.Buffer)
  1137. {
  1138. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1139. *EntriesRead = GenericInfoContainer.EntriesRead;
  1140. }
  1141. else
  1142. {
  1143. Status = ERROR_INVALID_DATA;
  1144. }
  1145. }
  1146. return Status;
  1147. } // LlsProductUserEnumW
  1148. /////////////////////////////////////////////////////////////////////////
  1149. NTSTATUS
  1150. NTAPI
  1151. LlsProductUserEnumA(
  1152. LLS_HANDLE Handle,
  1153. LPSTR Product,
  1154. DWORD Level,
  1155. LPBYTE* bufptr,
  1156. DWORD PrefMaxLen,
  1157. LPDWORD EntriesRead,
  1158. LPDWORD TotalEntries,
  1159. LPDWORD ResumeHandle
  1160. )
  1161. /*++
  1162. Routine Description:
  1163. Arguments:
  1164. Return Value:
  1165. None.
  1166. --*/
  1167. {
  1168. NTSTATUS Status;
  1169. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1170. GENERIC_ENUM_STRUCT InfoStruct;
  1171. PLOCAL_HANDLE pLocalHandle;
  1172. #ifdef API_TRACE
  1173. dprintf(TEXT("LLSRPC.DLL: LlsProductUserEnumA\n"));
  1174. #endif
  1175. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1176. if (pLocalHandle == NULL)
  1177. return STATUS_INVALID_PARAMETER;
  1178. GenericInfoContainer.Buffer = NULL;
  1179. GenericInfoContainer.EntriesRead = 0;
  1180. InfoStruct.Container = &GenericInfoContainer;
  1181. InfoStruct.Level = Level;
  1182. try {
  1183. Status = LlsrProductUserEnumA(
  1184. pLocalHandle->Handle,
  1185. Product,
  1186. (PLLS_PRODUCT_USER_ENUM_STRUCTA) &InfoStruct,
  1187. PrefMaxLen,
  1188. TotalEntries,
  1189. ResumeHandle
  1190. );
  1191. }
  1192. except (TRUE) {
  1193. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1194. #if DBG
  1195. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1196. #endif
  1197. }
  1198. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1199. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1200. *EntriesRead = GenericInfoContainer.EntriesRead;
  1201. }
  1202. return Status;
  1203. } // LlsProductUserEnumA
  1204. /////////////////////////////////////////////////////////////////////////
  1205. NTSTATUS
  1206. NTAPI
  1207. LlsProductServerEnumW(
  1208. LLS_HANDLE Handle,
  1209. LPTSTR Product,
  1210. DWORD Level,
  1211. LPBYTE* bufptr,
  1212. DWORD PrefMaxLen,
  1213. LPDWORD EntriesRead,
  1214. LPDWORD TotalEntries,
  1215. LPDWORD ResumeHandle
  1216. )
  1217. /*++
  1218. Routine Description:
  1219. Arguments:
  1220. Return Value:
  1221. None.
  1222. --*/
  1223. {
  1224. NTSTATUS Status;
  1225. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1226. GENERIC_ENUM_STRUCT InfoStruct;
  1227. PLOCAL_HANDLE pLocalHandle;
  1228. #ifdef API_TRACE
  1229. dprintf(TEXT("LLSRPC.DLL: LlsProductServerEnumW\n"));
  1230. #endif
  1231. //init
  1232. *bufptr = NULL;
  1233. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1234. if (pLocalHandle == NULL)
  1235. return STATUS_INVALID_PARAMETER;
  1236. GenericInfoContainer.Buffer = NULL;
  1237. GenericInfoContainer.EntriesRead = 0;
  1238. InfoStruct.Container = &GenericInfoContainer;
  1239. InfoStruct.Level = Level;
  1240. try {
  1241. Status = LlsrProductServerEnumW(
  1242. pLocalHandle->Handle,
  1243. Product,
  1244. (PLLS_SERVER_PRODUCT_ENUM_STRUCTW) &InfoStruct,
  1245. PrefMaxLen,
  1246. TotalEntries,
  1247. ResumeHandle
  1248. );
  1249. }
  1250. except (TRUE) {
  1251. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1252. #if DBG
  1253. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1254. #endif
  1255. }
  1256. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1257. if (NULL != GenericInfoContainer.Buffer)
  1258. {
  1259. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1260. *EntriesRead = GenericInfoContainer.EntriesRead;
  1261. }
  1262. else
  1263. {
  1264. Status = ERROR_INVALID_DATA;
  1265. }
  1266. }
  1267. return Status;
  1268. } // LlsProductServerEnumW
  1269. /////////////////////////////////////////////////////////////////////////
  1270. NTSTATUS
  1271. NTAPI
  1272. LlsProductServerEnumA(
  1273. LLS_HANDLE Handle,
  1274. LPSTR Product,
  1275. DWORD Level,
  1276. LPBYTE* bufptr,
  1277. DWORD PrefMaxLen,
  1278. LPDWORD EntriesRead,
  1279. LPDWORD TotalEntries,
  1280. LPDWORD ResumeHandle
  1281. )
  1282. /*++
  1283. Routine Description:
  1284. Arguments:
  1285. Return Value:
  1286. None.
  1287. --*/
  1288. {
  1289. NTSTATUS Status;
  1290. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1291. GENERIC_ENUM_STRUCT InfoStruct;
  1292. PLOCAL_HANDLE pLocalHandle;
  1293. #ifdef API_TRACE
  1294. dprintf(TEXT("LLSRPC.DLL: LlsProductServerEnumA\n"));
  1295. #endif
  1296. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1297. if (pLocalHandle == NULL)
  1298. return STATUS_INVALID_PARAMETER;
  1299. GenericInfoContainer.Buffer = NULL;
  1300. GenericInfoContainer.EntriesRead = 0;
  1301. InfoStruct.Container = &GenericInfoContainer;
  1302. InfoStruct.Level = Level;
  1303. try {
  1304. Status = LlsrProductServerEnumA(
  1305. pLocalHandle->Handle,
  1306. Product,
  1307. (PLLS_SERVER_PRODUCT_ENUM_STRUCTA) &InfoStruct,
  1308. PrefMaxLen,
  1309. TotalEntries,
  1310. ResumeHandle
  1311. );
  1312. }
  1313. except (TRUE) {
  1314. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1315. #if DBG
  1316. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1317. #endif
  1318. }
  1319. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1320. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1321. *EntriesRead = GenericInfoContainer.EntriesRead;
  1322. }
  1323. return Status;
  1324. } // LlsProductServerEnumA
  1325. /////////////////////////////////////////////////////////////////////////
  1326. NTSTATUS
  1327. NTAPI
  1328. LlsProductLicenseEnumW(
  1329. LLS_HANDLE Handle,
  1330. LPTSTR Product,
  1331. DWORD Level,
  1332. LPBYTE* bufptr,
  1333. DWORD PrefMaxLen,
  1334. LPDWORD EntriesRead,
  1335. LPDWORD TotalEntries,
  1336. LPDWORD ResumeHandle
  1337. )
  1338. /*++
  1339. Routine Description:
  1340. Arguments:
  1341. Return Value:
  1342. None.
  1343. --*/
  1344. {
  1345. NTSTATUS Status;
  1346. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1347. GENERIC_ENUM_STRUCT InfoStruct;
  1348. PLOCAL_HANDLE pLocalHandle;
  1349. #ifdef API_TRACE
  1350. dprintf(TEXT("LLSRPC.DLL: LlsProductLicenseEnumW\n"));
  1351. #endif
  1352. //init
  1353. *bufptr = NULL;
  1354. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1355. if (pLocalHandle == NULL)
  1356. return STATUS_INVALID_PARAMETER;
  1357. GenericInfoContainer.Buffer = NULL;
  1358. GenericInfoContainer.EntriesRead = 0;
  1359. InfoStruct.Container = &GenericInfoContainer;
  1360. InfoStruct.Level = Level;
  1361. try {
  1362. Status = LlsrProductLicenseEnumW(
  1363. pLocalHandle->Handle,
  1364. Product,
  1365. (PLLS_PRODUCT_LICENSE_ENUM_STRUCTW) &InfoStruct,
  1366. PrefMaxLen,
  1367. TotalEntries,
  1368. ResumeHandle
  1369. );
  1370. }
  1371. except (TRUE) {
  1372. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1373. #if DBG
  1374. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1375. #endif
  1376. }
  1377. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1378. if (NULL != GenericInfoContainer.Buffer)
  1379. {
  1380. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1381. *EntriesRead = GenericInfoContainer.EntriesRead;
  1382. }
  1383. else
  1384. {
  1385. Status = ERROR_INVALID_DATA;
  1386. }
  1387. }
  1388. return Status;
  1389. } // LlsProductLicenseEnumW
  1390. /////////////////////////////////////////////////////////////////////////
  1391. NTSTATUS
  1392. NTAPI
  1393. LlsProductLicenseEnumA(
  1394. LLS_HANDLE Handle,
  1395. LPSTR Product,
  1396. DWORD Level,
  1397. LPBYTE* bufptr,
  1398. DWORD PrefMaxLen,
  1399. LPDWORD EntriesRead,
  1400. LPDWORD TotalEntries,
  1401. LPDWORD ResumeHandle
  1402. )
  1403. /*++
  1404. Routine Description:
  1405. Arguments:
  1406. Return Value:
  1407. None.
  1408. --*/
  1409. {
  1410. NTSTATUS Status;
  1411. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1412. GENERIC_ENUM_STRUCT InfoStruct;
  1413. PLOCAL_HANDLE pLocalHandle;
  1414. #ifdef API_TRACE
  1415. dprintf(TEXT("LLSRPC.DLL: LlsProductLicenseEnumA\n"));
  1416. #endif
  1417. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1418. if (pLocalHandle == NULL)
  1419. return STATUS_INVALID_PARAMETER;
  1420. GenericInfoContainer.Buffer = NULL;
  1421. GenericInfoContainer.EntriesRead = 0;
  1422. InfoStruct.Container = &GenericInfoContainer;
  1423. InfoStruct.Level = Level;
  1424. try {
  1425. Status = LlsrProductLicenseEnumA(
  1426. pLocalHandle->Handle,
  1427. Product,
  1428. (PLLS_PRODUCT_LICENSE_ENUM_STRUCTA) &InfoStruct,
  1429. PrefMaxLen,
  1430. TotalEntries,
  1431. ResumeHandle
  1432. );
  1433. }
  1434. except (TRUE) {
  1435. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1436. #if DBG
  1437. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1438. #endif
  1439. }
  1440. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1441. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1442. *EntriesRead = GenericInfoContainer.EntriesRead;
  1443. }
  1444. return Status;
  1445. } // LlsProductLicenseEnumA
  1446. /////////////////////////////////////////////////////////////////////////
  1447. NTSTATUS
  1448. NTAPI
  1449. LlsUserEnumW(
  1450. LLS_HANDLE Handle,
  1451. DWORD Level,
  1452. LPBYTE* bufptr,
  1453. DWORD PrefMaxLen,
  1454. LPDWORD EntriesRead,
  1455. LPDWORD TotalEntries,
  1456. LPDWORD ResumeHandle
  1457. )
  1458. /*++
  1459. Routine Description:
  1460. Arguments:
  1461. Return Value:
  1462. None.
  1463. --*/
  1464. {
  1465. NTSTATUS Status;
  1466. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1467. GENERIC_ENUM_STRUCT InfoStruct;
  1468. PLOCAL_HANDLE pLocalHandle;
  1469. #ifdef API_TRACE
  1470. dprintf(TEXT("LLSRPC.DLL: LlsUserEnumW\n"));
  1471. #endif
  1472. //init
  1473. *bufptr = NULL;
  1474. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1475. if (pLocalHandle == NULL)
  1476. return STATUS_INVALID_PARAMETER;
  1477. GenericInfoContainer.Buffer = NULL;
  1478. GenericInfoContainer.EntriesRead = 0;
  1479. InfoStruct.Container = &GenericInfoContainer;
  1480. InfoStruct.Level = Level;
  1481. try {
  1482. Status = LlsrUserEnumW(
  1483. pLocalHandle->Handle,
  1484. (PLLS_USER_ENUM_STRUCTW) &InfoStruct,
  1485. PrefMaxLen,
  1486. TotalEntries,
  1487. ResumeHandle
  1488. );
  1489. }
  1490. except (TRUE) {
  1491. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1492. #if DBG
  1493. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1494. #endif
  1495. }
  1496. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1497. if (NULL != GenericInfoContainer.Buffer)
  1498. {
  1499. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1500. *EntriesRead = GenericInfoContainer.EntriesRead;
  1501. }
  1502. else
  1503. {
  1504. Status = ERROR_INVALID_DATA;
  1505. }
  1506. }
  1507. return Status;
  1508. } // LlsUserEnumW
  1509. /////////////////////////////////////////////////////////////////////////
  1510. NTSTATUS
  1511. NTAPI
  1512. LlsUserEnumA(
  1513. LLS_HANDLE Handle,
  1514. DWORD Level,
  1515. LPBYTE* bufptr,
  1516. DWORD PrefMaxLen,
  1517. LPDWORD EntriesRead,
  1518. LPDWORD TotalEntries,
  1519. LPDWORD ResumeHandle
  1520. )
  1521. /*++
  1522. Routine Description:
  1523. Arguments:
  1524. Return Value:
  1525. None.
  1526. --*/
  1527. {
  1528. NTSTATUS Status;
  1529. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1530. GENERIC_ENUM_STRUCT InfoStruct;
  1531. PLOCAL_HANDLE pLocalHandle;
  1532. #ifdef API_TRACE
  1533. dprintf(TEXT("LLSRPC.DLL: LlsUserEnumA\n"));
  1534. #endif
  1535. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1536. if (pLocalHandle == NULL)
  1537. return STATUS_INVALID_PARAMETER;
  1538. GenericInfoContainer.Buffer = NULL;
  1539. GenericInfoContainer.EntriesRead = 0;
  1540. InfoStruct.Container = &GenericInfoContainer;
  1541. InfoStruct.Level = Level;
  1542. try {
  1543. Status = LlsrUserEnumA(
  1544. pLocalHandle->Handle,
  1545. (PLLS_USER_ENUM_STRUCTA) &InfoStruct,
  1546. PrefMaxLen,
  1547. TotalEntries,
  1548. ResumeHandle
  1549. );
  1550. }
  1551. except (TRUE) {
  1552. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1553. #if DBG
  1554. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1555. #endif
  1556. }
  1557. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1558. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1559. *EntriesRead = GenericInfoContainer.EntriesRead;
  1560. }
  1561. return Status;
  1562. } // LlsUserEnumA
  1563. /////////////////////////////////////////////////////////////////////////
  1564. NTSTATUS
  1565. NTAPI
  1566. LlsUserInfoGetW(
  1567. IN LLS_HANDLE Handle,
  1568. IN LPWSTR User,
  1569. IN DWORD Level,
  1570. OUT LPBYTE* bufptr
  1571. )
  1572. /*++
  1573. Routine Description:
  1574. Arguments:
  1575. Return Value:
  1576. None.
  1577. --*/
  1578. {
  1579. NTSTATUS Status;
  1580. PLOCAL_HANDLE pLocalHandle;
  1581. #ifdef API_TRACE
  1582. dprintf(TEXT("LLSRPC.DLL: LlsUserInfoGetW\n"));
  1583. #endif
  1584. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1585. if ((pLocalHandle == NULL) || (bufptr == NULL))
  1586. return STATUS_INVALID_PARAMETER;
  1587. *bufptr = NULL;
  1588. try {
  1589. Status = LlsrUserInfoGetW(pLocalHandle->Handle, User, Level, (PLLS_USER_INFOW *) bufptr);
  1590. }
  1591. except (TRUE) {
  1592. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1593. #if DBG
  1594. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1595. #endif
  1596. }
  1597. if (NULL == *bufptr)
  1598. {
  1599. Status = ERROR_INVALID_DATA;
  1600. }
  1601. return Status;
  1602. } // LlsUserInfoGetW
  1603. /////////////////////////////////////////////////////////////////////////
  1604. NTSTATUS
  1605. NTAPI
  1606. LlsUserInfoGetA(
  1607. IN LLS_HANDLE Handle,
  1608. IN LPSTR User,
  1609. IN DWORD Level,
  1610. OUT LPBYTE* bufptr
  1611. )
  1612. /*++
  1613. Routine Description:
  1614. Arguments:
  1615. Return Value:
  1616. None.
  1617. --*/
  1618. {
  1619. NTSTATUS Status;
  1620. PLOCAL_HANDLE pLocalHandle;
  1621. #ifdef API_TRACE
  1622. dprintf(TEXT("LLSRPC.DLL: LlsUserInfoGetA\n"));
  1623. #endif
  1624. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1625. if ((pLocalHandle == NULL) || (bufptr == NULL))
  1626. return STATUS_INVALID_PARAMETER;
  1627. *bufptr = NULL;
  1628. try {
  1629. Status = LlsrUserInfoGetA(pLocalHandle->Handle, User, Level, (PVOID) bufptr);
  1630. }
  1631. except (TRUE) {
  1632. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1633. #if DBG
  1634. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1635. #endif
  1636. }
  1637. return Status;
  1638. } // LlsUserInfoGetA
  1639. /////////////////////////////////////////////////////////////////////////
  1640. NTSTATUS
  1641. NTAPI
  1642. LlsUserInfoSetW(
  1643. IN LLS_HANDLE Handle,
  1644. IN LPWSTR User,
  1645. IN DWORD Level,
  1646. IN LPBYTE bufptr // Level 1 supported
  1647. )
  1648. /*++
  1649. Routine Description:
  1650. Arguments:
  1651. Return Value:
  1652. None.
  1653. --*/
  1654. {
  1655. NTSTATUS Status;
  1656. PLOCAL_HANDLE pLocalHandle;
  1657. #ifdef API_TRACE
  1658. dprintf(TEXT("LLSRPC.DLL: LlsUserInfoSetW\n"));
  1659. #endif
  1660. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1661. if (pLocalHandle == NULL)
  1662. return STATUS_INVALID_PARAMETER;
  1663. try {
  1664. Status = LlsrUserInfoSetW(pLocalHandle->Handle, User, Level, (PLLS_USER_INFOW) bufptr);
  1665. }
  1666. except (TRUE) {
  1667. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1668. #if DBG
  1669. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1670. #endif
  1671. }
  1672. return Status;
  1673. } // LlsUserInfoSetW
  1674. /////////////////////////////////////////////////////////////////////////
  1675. NTSTATUS
  1676. NTAPI
  1677. LlsUserInfoSetA(
  1678. IN LLS_HANDLE Handle,
  1679. IN LPSTR User,
  1680. IN DWORD Level,
  1681. IN LPBYTE bufptr
  1682. )
  1683. /*++
  1684. Routine Description:
  1685. Arguments:
  1686. Return Value:
  1687. None.
  1688. --*/
  1689. {
  1690. NTSTATUS Status;
  1691. PLOCAL_HANDLE pLocalHandle;
  1692. #ifdef API_TRACE
  1693. dprintf(TEXT("LLSRPC.DLL: LlsUserInfoSetA\n"));
  1694. #endif
  1695. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1696. if (pLocalHandle == NULL)
  1697. return STATUS_INVALID_PARAMETER;
  1698. try {
  1699. Status = LlsrUserInfoSetA(pLocalHandle->Handle, User, Level, (PVOID) bufptr);
  1700. }
  1701. except (TRUE) {
  1702. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1703. #if DBG
  1704. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1705. #endif
  1706. }
  1707. return Status;
  1708. } // LlsUserInfoSetA
  1709. /////////////////////////////////////////////////////////////////////////
  1710. NTSTATUS
  1711. NTAPI
  1712. LlsUserDeleteW(
  1713. IN LLS_HANDLE Handle,
  1714. IN LPWSTR User
  1715. )
  1716. /*++
  1717. Routine Description:
  1718. Arguments:
  1719. Return Value:
  1720. None.
  1721. --*/
  1722. {
  1723. NTSTATUS Status;
  1724. PLOCAL_HANDLE pLocalHandle;
  1725. #ifdef API_TRACE
  1726. dprintf(TEXT("LLSRPC.DLL: LlsUserDeleteW\n"));
  1727. #endif
  1728. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1729. if (pLocalHandle == NULL)
  1730. return STATUS_INVALID_PARAMETER;
  1731. try {
  1732. Status = LlsrUserDeleteW(pLocalHandle->Handle, User);
  1733. }
  1734. except (TRUE) {
  1735. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1736. #if DBG
  1737. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1738. #endif
  1739. }
  1740. return Status;
  1741. } // LlsUserDeleteW
  1742. /////////////////////////////////////////////////////////////////////////
  1743. NTSTATUS
  1744. NTAPI
  1745. LlsUserDeleteA(
  1746. IN LLS_HANDLE Handle,
  1747. IN LPSTR User
  1748. )
  1749. /*++
  1750. Routine Description:
  1751. Arguments:
  1752. Return Value:
  1753. None.
  1754. --*/
  1755. {
  1756. NTSTATUS Status;
  1757. PLOCAL_HANDLE pLocalHandle;
  1758. #ifdef API_TRACE
  1759. dprintf(TEXT("LLSRPC.DLL: LlsUserDeleteA\n"));
  1760. #endif
  1761. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1762. if (pLocalHandle == NULL)
  1763. return STATUS_INVALID_PARAMETER;
  1764. try {
  1765. Status = LlsrUserDeleteA(pLocalHandle->Handle, User);
  1766. }
  1767. except (TRUE) {
  1768. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1769. #if DBG
  1770. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1771. #endif
  1772. }
  1773. return Status;
  1774. } // LlsUserDeleteA
  1775. /////////////////////////////////////////////////////////////////////////
  1776. NTSTATUS
  1777. NTAPI
  1778. LlsUserProductEnumW(
  1779. LLS_HANDLE Handle,
  1780. LPTSTR User,
  1781. DWORD Level,
  1782. LPBYTE* bufptr,
  1783. DWORD PrefMaxLen,
  1784. LPDWORD EntriesRead,
  1785. LPDWORD TotalEntries,
  1786. LPDWORD ResumeHandle
  1787. )
  1788. /*++
  1789. Routine Description:
  1790. Arguments:
  1791. Return Value:
  1792. None.
  1793. --*/
  1794. {
  1795. NTSTATUS Status;
  1796. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1797. GENERIC_ENUM_STRUCT InfoStruct;
  1798. PLOCAL_HANDLE pLocalHandle;
  1799. #ifdef API_TRACE
  1800. dprintf(TEXT("LLSRPC.DLL: LlsUserProductEnumW\n"));
  1801. #endif
  1802. //init
  1803. *bufptr = NULL;
  1804. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1805. if (pLocalHandle == NULL)
  1806. return STATUS_INVALID_PARAMETER;
  1807. GenericInfoContainer.Buffer = NULL;
  1808. GenericInfoContainer.EntriesRead = 0;
  1809. InfoStruct.Container = &GenericInfoContainer;
  1810. InfoStruct.Level = Level;
  1811. try {
  1812. Status = LlsrUserProductEnumW(
  1813. pLocalHandle->Handle,
  1814. User,
  1815. (PLLS_USER_PRODUCT_ENUM_STRUCTW) &InfoStruct,
  1816. PrefMaxLen,
  1817. TotalEntries,
  1818. ResumeHandle
  1819. );
  1820. }
  1821. except (TRUE) {
  1822. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1823. #if DBG
  1824. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1825. #endif
  1826. }
  1827. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1828. if (NULL != GenericInfoContainer.Buffer)
  1829. {
  1830. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1831. *EntriesRead = GenericInfoContainer.EntriesRead;
  1832. }
  1833. else
  1834. {
  1835. Status = ERROR_INVALID_DATA;
  1836. }
  1837. }
  1838. return Status;
  1839. } // LlsUserProductEnumW
  1840. /////////////////////////////////////////////////////////////////////////
  1841. NTSTATUS
  1842. NTAPI
  1843. LlsUserProductEnumA(
  1844. LLS_HANDLE Handle,
  1845. LPSTR User,
  1846. DWORD Level,
  1847. LPBYTE* bufptr,
  1848. DWORD PrefMaxLen,
  1849. LPDWORD EntriesRead,
  1850. LPDWORD TotalEntries,
  1851. LPDWORD ResumeHandle
  1852. )
  1853. /*++
  1854. Routine Description:
  1855. Arguments:
  1856. Return Value:
  1857. None.
  1858. --*/
  1859. {
  1860. NTSTATUS Status;
  1861. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1862. GENERIC_ENUM_STRUCT InfoStruct;
  1863. PLOCAL_HANDLE pLocalHandle;
  1864. #ifdef API_TRACE
  1865. dprintf(TEXT("LLSRPC.DLL: LlsUserProductEnumA\n"));
  1866. #endif
  1867. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1868. if (pLocalHandle == NULL)
  1869. return STATUS_INVALID_PARAMETER;
  1870. GenericInfoContainer.Buffer = NULL;
  1871. GenericInfoContainer.EntriesRead = 0;
  1872. InfoStruct.Container = &GenericInfoContainer;
  1873. InfoStruct.Level = Level;
  1874. try {
  1875. Status = LlsrUserProductEnumA(
  1876. pLocalHandle->Handle,
  1877. User,
  1878. (PLLS_USER_PRODUCT_ENUM_STRUCTA) &InfoStruct,
  1879. PrefMaxLen,
  1880. TotalEntries,
  1881. ResumeHandle
  1882. );
  1883. }
  1884. except (TRUE) {
  1885. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1886. #if DBG
  1887. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1888. #endif
  1889. }
  1890. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  1891. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  1892. *EntriesRead = GenericInfoContainer.EntriesRead;
  1893. }
  1894. return Status;
  1895. } // LlsUserProductEnumA
  1896. /////////////////////////////////////////////////////////////////////////
  1897. NTSTATUS
  1898. NTAPI
  1899. LlsUserProductDeleteW(
  1900. IN LLS_HANDLE Handle,
  1901. IN LPWSTR User,
  1902. IN LPWSTR Product
  1903. )
  1904. /*++
  1905. Routine Description:
  1906. Arguments:
  1907. Return Value:
  1908. None.
  1909. --*/
  1910. {
  1911. NTSTATUS Status;
  1912. PLOCAL_HANDLE pLocalHandle;
  1913. #ifdef API_TRACE
  1914. dprintf(TEXT("LLSRPC.DLL: LlsUserProductDeleteW\n"));
  1915. #endif
  1916. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1917. if (pLocalHandle == NULL)
  1918. return STATUS_INVALID_PARAMETER;
  1919. try {
  1920. Status = LlsrUserProductDeleteW(pLocalHandle->Handle, User, Product);
  1921. }
  1922. except (TRUE) {
  1923. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1924. #if DBG
  1925. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1926. #endif
  1927. }
  1928. return Status;
  1929. } // LlsUserProductDeleteW
  1930. /////////////////////////////////////////////////////////////////////////
  1931. NTSTATUS
  1932. NTAPI
  1933. LlsUserProductDeleteA(
  1934. IN LLS_HANDLE Handle,
  1935. IN LPSTR User,
  1936. IN LPSTR Product
  1937. )
  1938. /*++
  1939. Routine Description:
  1940. Arguments:
  1941. Return Value:
  1942. None.
  1943. --*/
  1944. {
  1945. NTSTATUS Status;
  1946. PLOCAL_HANDLE pLocalHandle;
  1947. #ifdef API_TRACE
  1948. dprintf(TEXT("LLSRPC.DLL: LlsUserProductDeleteA\n"));
  1949. #endif
  1950. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1951. if (pLocalHandle == NULL)
  1952. return STATUS_INVALID_PARAMETER;
  1953. try {
  1954. Status = LlsrUserProductDeleteA(pLocalHandle->Handle, User, Product);
  1955. }
  1956. except (TRUE) {
  1957. Status = I_RpcMapWin32Status(RpcExceptionCode());
  1958. #if DBG
  1959. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  1960. #endif
  1961. }
  1962. return Status;
  1963. } // LlsUserProductDeleteA
  1964. /////////////////////////////////////////////////////////////////////////
  1965. NTSTATUS
  1966. NTAPI
  1967. LlsGroupEnumW(
  1968. LLS_HANDLE Handle,
  1969. DWORD Level,
  1970. LPBYTE* bufptr,
  1971. DWORD PrefMaxLen,
  1972. LPDWORD EntriesRead,
  1973. LPDWORD TotalEntries,
  1974. LPDWORD ResumeHandle
  1975. )
  1976. /*++
  1977. Routine Description:
  1978. Arguments:
  1979. Return Value:
  1980. None.
  1981. --*/
  1982. {
  1983. NTSTATUS Status;
  1984. GENERIC_INFO_CONTAINER GenericInfoContainer;
  1985. GENERIC_ENUM_STRUCT InfoStruct;
  1986. PLOCAL_HANDLE pLocalHandle;
  1987. #ifdef API_TRACE
  1988. dprintf(TEXT("LLSRPC.DLL: LlsGroupEnumW\n"));
  1989. #endif
  1990. //init
  1991. *bufptr = NULL;
  1992. pLocalHandle = (PLOCAL_HANDLE) Handle;
  1993. if (pLocalHandle == NULL)
  1994. return STATUS_INVALID_PARAMETER;
  1995. GenericInfoContainer.Buffer = NULL;
  1996. GenericInfoContainer.EntriesRead = 0;
  1997. InfoStruct.Container = &GenericInfoContainer;
  1998. InfoStruct.Level = Level;
  1999. try {
  2000. Status = LlsrMappingEnumW(
  2001. pLocalHandle->Handle,
  2002. (PLLS_MAPPING_ENUM_STRUCTW) &InfoStruct,
  2003. PrefMaxLen,
  2004. TotalEntries,
  2005. ResumeHandle
  2006. );
  2007. }
  2008. except (TRUE) {
  2009. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2010. #if DBG
  2011. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2012. #endif
  2013. }
  2014. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2015. if (NULL != GenericInfoContainer.Buffer)
  2016. {
  2017. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2018. *EntriesRead = GenericInfoContainer.EntriesRead;
  2019. }
  2020. else
  2021. {
  2022. Status = ERROR_INVALID_DATA;
  2023. }
  2024. }
  2025. return Status;
  2026. } // LlsGroupEnumW
  2027. /////////////////////////////////////////////////////////////////////////
  2028. NTSTATUS
  2029. NTAPI
  2030. LlsGroupEnumA(
  2031. LLS_HANDLE Handle,
  2032. DWORD Level,
  2033. LPBYTE* bufptr,
  2034. DWORD PrefMaxLen,
  2035. LPDWORD EntriesRead,
  2036. LPDWORD TotalEntries,
  2037. LPDWORD ResumeHandle
  2038. )
  2039. /*++
  2040. Routine Description:
  2041. Arguments:
  2042. Return Value:
  2043. None.
  2044. --*/
  2045. {
  2046. NTSTATUS Status;
  2047. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2048. GENERIC_ENUM_STRUCT InfoStruct;
  2049. PLOCAL_HANDLE pLocalHandle;
  2050. #ifdef API_TRACE
  2051. dprintf(TEXT("LLSRPC.DLL: LlsGroupEnumA\n"));
  2052. #endif
  2053. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2054. if (pLocalHandle == NULL)
  2055. return STATUS_INVALID_PARAMETER;
  2056. GenericInfoContainer.Buffer = NULL;
  2057. GenericInfoContainer.EntriesRead = 0;
  2058. InfoStruct.Container = &GenericInfoContainer;
  2059. InfoStruct.Level = Level;
  2060. try {
  2061. Status = LlsrMappingEnumA(
  2062. pLocalHandle->Handle,
  2063. (PLLS_MAPPING_ENUM_STRUCTA) &InfoStruct,
  2064. PrefMaxLen,
  2065. TotalEntries,
  2066. ResumeHandle
  2067. );
  2068. }
  2069. except (TRUE) {
  2070. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2071. #if DBG
  2072. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2073. #endif
  2074. }
  2075. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2076. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2077. *EntriesRead = GenericInfoContainer.EntriesRead;
  2078. }
  2079. return Status;
  2080. } // LlsGroupEnumA
  2081. /////////////////////////////////////////////////////////////////////////
  2082. NTSTATUS
  2083. NTAPI
  2084. LlsGroupInfoGetW(
  2085. IN LLS_HANDLE Handle,
  2086. IN LPWSTR Group,
  2087. IN DWORD Level,
  2088. OUT LPBYTE* bufptr
  2089. )
  2090. /*++
  2091. Routine Description:
  2092. Arguments:
  2093. Return Value:
  2094. None.
  2095. --*/
  2096. {
  2097. NTSTATUS Status;
  2098. PLOCAL_HANDLE pLocalHandle;
  2099. #ifdef API_TRACE
  2100. dprintf(TEXT("LLSRPC.DLL: LlsGroupInfoGetW\n"));
  2101. #endif
  2102. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2103. if ((pLocalHandle == NULL) || (bufptr == NULL))
  2104. return STATUS_INVALID_PARAMETER;
  2105. *bufptr = NULL;
  2106. try {
  2107. Status = LlsrMappingInfoGetW(pLocalHandle->Handle, Group, Level, (PVOID) bufptr);
  2108. }
  2109. except (TRUE) {
  2110. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2111. #if DBG
  2112. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2113. #endif
  2114. }
  2115. if (NULL == *bufptr)
  2116. {
  2117. Status = ERROR_INVALID_DATA;
  2118. }
  2119. return Status;
  2120. } // LlsGroupInfoGetW
  2121. /////////////////////////////////////////////////////////////////////////
  2122. NTSTATUS
  2123. NTAPI
  2124. LlsGroupInfoGetA(
  2125. IN LLS_HANDLE Handle,
  2126. IN LPSTR Group,
  2127. IN DWORD Level,
  2128. OUT LPBYTE* bufptr
  2129. )
  2130. /*++
  2131. Routine Description:
  2132. Arguments:
  2133. Return Value:
  2134. None.
  2135. --*/
  2136. {
  2137. NTSTATUS Status;
  2138. PLOCAL_HANDLE pLocalHandle;
  2139. #ifdef API_TRACE
  2140. dprintf(TEXT("LLSRPC.DLL: LlsGroupInfoGetA\n"));
  2141. #endif
  2142. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2143. if ((pLocalHandle == NULL) || (bufptr == NULL))
  2144. return STATUS_INVALID_PARAMETER;
  2145. *bufptr = NULL;
  2146. try {
  2147. Status = LlsrMappingInfoGetA(pLocalHandle->Handle, Group, Level, (PVOID) bufptr);
  2148. }
  2149. except (TRUE) {
  2150. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2151. #if DBG
  2152. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2153. #endif
  2154. }
  2155. return Status;
  2156. } // LlsGroupInfoGetA
  2157. /////////////////////////////////////////////////////////////////////////
  2158. NTSTATUS
  2159. NTAPI
  2160. LlsGroupInfoSetW(
  2161. IN LLS_HANDLE Handle,
  2162. IN LPWSTR Group,
  2163. IN DWORD Level,
  2164. IN LPBYTE bufptr
  2165. )
  2166. /*++
  2167. Routine Description:
  2168. Arguments:
  2169. Return Value:
  2170. None.
  2171. --*/
  2172. {
  2173. NTSTATUS Status;
  2174. PLOCAL_HANDLE pLocalHandle;
  2175. #ifdef API_TRACE
  2176. dprintf(TEXT("LLSRPC.DLL: LlsGroupInfoSetW\n"));
  2177. #endif
  2178. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2179. if (pLocalHandle == NULL)
  2180. return STATUS_INVALID_PARAMETER;
  2181. try {
  2182. Status = LlsrMappingInfoSetW(pLocalHandle->Handle, Group, Level, (PVOID) bufptr);
  2183. }
  2184. except (TRUE) {
  2185. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2186. #if DBG
  2187. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2188. #endif
  2189. }
  2190. return Status;
  2191. } // LlsGroupInfoSetW
  2192. /////////////////////////////////////////////////////////////////////////
  2193. NTSTATUS
  2194. NTAPI
  2195. LlsGroupInfoSetA(
  2196. IN LLS_HANDLE Handle,
  2197. IN LPSTR Group,
  2198. IN DWORD Level,
  2199. IN LPBYTE bufptr
  2200. )
  2201. /*++
  2202. Routine Description:
  2203. Arguments:
  2204. Return Value:
  2205. None.
  2206. --*/
  2207. {
  2208. NTSTATUS Status;
  2209. PLOCAL_HANDLE pLocalHandle;
  2210. #ifdef API_TRACE
  2211. dprintf(TEXT("LLSRPC.DLL: LlsGroupInfoSetA\n"));
  2212. #endif
  2213. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2214. if (pLocalHandle == NULL)
  2215. return STATUS_INVALID_PARAMETER;
  2216. try {
  2217. Status = LlsrMappingInfoSetA(pLocalHandle->Handle, Group, Level, (PVOID) bufptr);
  2218. }
  2219. except (TRUE) {
  2220. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2221. #if DBG
  2222. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2223. #endif
  2224. }
  2225. return Status;
  2226. } // LlsGroupInfoSetA
  2227. /////////////////////////////////////////////////////////////////////////
  2228. NTSTATUS
  2229. NTAPI
  2230. LlsGroupUserEnumW(
  2231. LLS_HANDLE Handle,
  2232. LPTSTR Group,
  2233. DWORD Level,
  2234. LPBYTE* bufptr,
  2235. DWORD PrefMaxLen,
  2236. LPDWORD EntriesRead,
  2237. LPDWORD TotalEntries,
  2238. LPDWORD ResumeHandle
  2239. )
  2240. /*++
  2241. Routine Description:
  2242. Arguments:
  2243. Return Value:
  2244. None.
  2245. --*/
  2246. {
  2247. NTSTATUS Status;
  2248. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2249. GENERIC_ENUM_STRUCT InfoStruct;
  2250. PLOCAL_HANDLE pLocalHandle;
  2251. #ifdef API_TRACE
  2252. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserEnumW\n"));
  2253. #endif
  2254. //init
  2255. *bufptr = NULL;
  2256. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2257. if (pLocalHandle == NULL)
  2258. return STATUS_INVALID_PARAMETER;
  2259. GenericInfoContainer.Buffer = NULL;
  2260. GenericInfoContainer.EntriesRead = 0;
  2261. InfoStruct.Container = &GenericInfoContainer;
  2262. InfoStruct.Level = Level;
  2263. try {
  2264. Status = LlsrMappingUserEnumW(
  2265. pLocalHandle->Handle,
  2266. Group,
  2267. (PLLS_USER_ENUM_STRUCTW) &InfoStruct,
  2268. PrefMaxLen,
  2269. TotalEntries,
  2270. ResumeHandle
  2271. );
  2272. }
  2273. except (TRUE) {
  2274. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2275. #if DBG
  2276. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2277. #endif
  2278. }
  2279. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2280. if (NULL != GenericInfoContainer.Buffer)
  2281. {
  2282. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2283. *EntriesRead = GenericInfoContainer.EntriesRead;
  2284. }
  2285. else
  2286. {
  2287. Status = ERROR_INVALID_DATA;
  2288. }
  2289. }
  2290. return Status;
  2291. } // LlsGroupUserEnumW
  2292. /////////////////////////////////////////////////////////////////////////
  2293. NTSTATUS
  2294. NTAPI
  2295. LlsGroupUserEnumA(
  2296. LLS_HANDLE Handle,
  2297. LPSTR Group,
  2298. DWORD Level,
  2299. LPBYTE* bufptr,
  2300. DWORD PrefMaxLen,
  2301. LPDWORD EntriesRead,
  2302. LPDWORD TotalEntries,
  2303. LPDWORD ResumeHandle
  2304. )
  2305. /*++
  2306. Routine Description:
  2307. Arguments:
  2308. Return Value:
  2309. None.
  2310. --*/
  2311. {
  2312. NTSTATUS Status;
  2313. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2314. GENERIC_ENUM_STRUCT InfoStruct;
  2315. PLOCAL_HANDLE pLocalHandle;
  2316. #ifdef API_TRACE
  2317. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserEnumA\n"));
  2318. #endif
  2319. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2320. if (pLocalHandle == NULL)
  2321. return STATUS_INVALID_PARAMETER;
  2322. GenericInfoContainer.Buffer = NULL;
  2323. GenericInfoContainer.EntriesRead = 0;
  2324. InfoStruct.Container = &GenericInfoContainer;
  2325. InfoStruct.Level = Level;
  2326. try {
  2327. Status = LlsrMappingUserEnumA(
  2328. pLocalHandle->Handle,
  2329. Group,
  2330. (PLLS_USER_ENUM_STRUCTA) &InfoStruct,
  2331. PrefMaxLen,
  2332. TotalEntries,
  2333. ResumeHandle
  2334. );
  2335. }
  2336. except (TRUE) {
  2337. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2338. #if DBG
  2339. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2340. #endif
  2341. }
  2342. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2343. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2344. *EntriesRead = GenericInfoContainer.EntriesRead;
  2345. }
  2346. return Status;
  2347. } // LlsGroupUserEnumA
  2348. /////////////////////////////////////////////////////////////////////////
  2349. NTSTATUS
  2350. NTAPI
  2351. LlsGroupUserAddW(
  2352. IN LLS_HANDLE Handle,
  2353. IN LPWSTR Group,
  2354. IN LPWSTR User
  2355. )
  2356. /*++
  2357. Routine Description:
  2358. Arguments:
  2359. Return Value:
  2360. None.
  2361. --*/
  2362. {
  2363. NTSTATUS Status;
  2364. PLOCAL_HANDLE pLocalHandle;
  2365. #ifdef API_TRACE
  2366. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserAddW\n"));
  2367. #endif
  2368. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2369. if (pLocalHandle == NULL)
  2370. return STATUS_INVALID_PARAMETER;
  2371. try {
  2372. Status = LlsrMappingUserAddW(pLocalHandle->Handle, Group, User);
  2373. }
  2374. except (TRUE) {
  2375. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2376. #if DBG
  2377. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2378. #endif
  2379. }
  2380. return Status;
  2381. } // LlsGroupUserAddW
  2382. /////////////////////////////////////////////////////////////////////////
  2383. NTSTATUS
  2384. NTAPI
  2385. LlsGroupUserAddA(
  2386. IN LLS_HANDLE Handle,
  2387. IN LPSTR Group,
  2388. IN LPSTR User
  2389. )
  2390. /*++
  2391. Routine Description:
  2392. Arguments:
  2393. Return Value:
  2394. None.
  2395. --*/
  2396. {
  2397. NTSTATUS Status;
  2398. PLOCAL_HANDLE pLocalHandle;
  2399. #ifdef API_TRACE
  2400. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserAddA\n"));
  2401. #endif
  2402. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2403. if (pLocalHandle == NULL)
  2404. return STATUS_INVALID_PARAMETER;
  2405. try {
  2406. Status = LlsrMappingUserAddA(pLocalHandle->Handle, Group, User);
  2407. }
  2408. except (TRUE) {
  2409. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2410. #if DBG
  2411. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2412. #endif
  2413. }
  2414. return Status;
  2415. } // LlsGroupUserAddA
  2416. /////////////////////////////////////////////////////////////////////////
  2417. NTSTATUS
  2418. NTAPI
  2419. LlsGroupUserDeleteW(
  2420. IN LLS_HANDLE Handle,
  2421. IN LPWSTR Group,
  2422. IN LPWSTR User
  2423. )
  2424. /*++
  2425. Routine Description:
  2426. Arguments:
  2427. Return Value:
  2428. None.
  2429. --*/
  2430. {
  2431. NTSTATUS Status;
  2432. PLOCAL_HANDLE pLocalHandle;
  2433. #ifdef API_TRACE
  2434. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserDeleteW\n"));
  2435. #endif
  2436. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2437. if (pLocalHandle == NULL)
  2438. return STATUS_INVALID_PARAMETER;
  2439. try {
  2440. Status = LlsrMappingUserDeleteW(pLocalHandle->Handle, Group, User);
  2441. }
  2442. except (TRUE) {
  2443. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2444. #if DBG
  2445. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2446. #endif
  2447. }
  2448. return Status;
  2449. } // LlsGroupUserDeleteW
  2450. /////////////////////////////////////////////////////////////////////////
  2451. NTSTATUS
  2452. NTAPI
  2453. LlsGroupUserDeleteA(
  2454. IN LLS_HANDLE Handle,
  2455. IN LPSTR Group,
  2456. IN LPSTR User
  2457. )
  2458. /*++
  2459. Routine Description:
  2460. Arguments:
  2461. Return Value:
  2462. None.
  2463. --*/
  2464. {
  2465. NTSTATUS Status;
  2466. PLOCAL_HANDLE pLocalHandle;
  2467. #ifdef API_TRACE
  2468. dprintf(TEXT("LLSRPC.DLL: LlsGroupUserDeleteA\n"));
  2469. #endif
  2470. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2471. if (pLocalHandle == NULL)
  2472. return STATUS_INVALID_PARAMETER;
  2473. try {
  2474. Status = LlsrMappingUserDeleteA(pLocalHandle->Handle, Group, User);
  2475. }
  2476. except (TRUE) {
  2477. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2478. #if DBG
  2479. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2480. #endif
  2481. }
  2482. return Status;
  2483. } // LlsGroupUserDeleteA
  2484. /////////////////////////////////////////////////////////////////////////
  2485. NTSTATUS
  2486. NTAPI
  2487. LlsGroupAddW(
  2488. IN LLS_HANDLE Handle,
  2489. IN DWORD Level,
  2490. IN LPBYTE bufptr
  2491. )
  2492. /*++
  2493. Routine Description:
  2494. Arguments:
  2495. Return Value:
  2496. None.
  2497. --*/
  2498. {
  2499. NTSTATUS Status;
  2500. PLOCAL_HANDLE pLocalHandle;
  2501. #ifdef API_TRACE
  2502. dprintf(TEXT("LLSRPC.DLL: LlsGroupAddW\n"));
  2503. #endif
  2504. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2505. if (pLocalHandle == NULL)
  2506. return STATUS_INVALID_PARAMETER;
  2507. try {
  2508. Status = LlsrMappingAddW(pLocalHandle->Handle, Level, (PVOID) bufptr);
  2509. }
  2510. except (TRUE) {
  2511. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2512. #if DBG
  2513. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2514. #endif
  2515. }
  2516. return Status;
  2517. } // LlsGroupAddW
  2518. /////////////////////////////////////////////////////////////////////////
  2519. NTSTATUS
  2520. NTAPI
  2521. LlsGroupAddA(
  2522. IN LLS_HANDLE Handle,
  2523. IN DWORD Level,
  2524. IN LPBYTE bufptr
  2525. )
  2526. /*++
  2527. Routine Description:
  2528. Arguments:
  2529. Return Value:
  2530. None.
  2531. --*/
  2532. {
  2533. NTSTATUS Status;
  2534. PLOCAL_HANDLE pLocalHandle;
  2535. #ifdef API_TRACE
  2536. dprintf(TEXT("LLSRPC.DLL: LlsGroupAddA\n"));
  2537. #endif
  2538. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2539. if (pLocalHandle == NULL)
  2540. return STATUS_INVALID_PARAMETER;
  2541. try {
  2542. Status = LlsrMappingAddA(pLocalHandle->Handle, Level, (PVOID) bufptr);
  2543. }
  2544. except (TRUE) {
  2545. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2546. #if DBG
  2547. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2548. #endif
  2549. }
  2550. return Status;
  2551. } // LlsGroupAddA
  2552. /////////////////////////////////////////////////////////////////////////
  2553. NTSTATUS
  2554. NTAPI
  2555. LlsGroupDeleteW(
  2556. IN LLS_HANDLE Handle,
  2557. IN LPWSTR Group
  2558. )
  2559. /*++
  2560. Routine Description:
  2561. Arguments:
  2562. Return Value:
  2563. None.
  2564. --*/
  2565. {
  2566. NTSTATUS Status;
  2567. PLOCAL_HANDLE pLocalHandle;
  2568. #ifdef API_TRACE
  2569. dprintf(TEXT("LLSRPC.DLL: LlsGroupDeleteW\n"));
  2570. #endif
  2571. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2572. if (pLocalHandle == NULL)
  2573. return STATUS_INVALID_PARAMETER;
  2574. try {
  2575. Status = LlsrMappingDeleteW(pLocalHandle->Handle, Group);
  2576. }
  2577. except (TRUE) {
  2578. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2579. #if DBG
  2580. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2581. #endif
  2582. }
  2583. return Status;
  2584. } // LlsGroupDeleteW
  2585. /////////////////////////////////////////////////////////////////////////
  2586. NTSTATUS
  2587. NTAPI
  2588. LlsGroupDeleteA(
  2589. IN LLS_HANDLE Handle,
  2590. IN LPSTR Group
  2591. )
  2592. /*++
  2593. Routine Description:
  2594. Arguments:
  2595. Return Value:
  2596. None.
  2597. --*/
  2598. {
  2599. NTSTATUS Status;
  2600. PLOCAL_HANDLE pLocalHandle;
  2601. #ifdef API_TRACE
  2602. dprintf(TEXT("LLSRPC.DLL: GroupDeleteA\n"));
  2603. #endif
  2604. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2605. if (pLocalHandle == NULL)
  2606. return STATUS_INVALID_PARAMETER;
  2607. try {
  2608. Status = LlsrMappingDeleteA(pLocalHandle->Handle, Group);
  2609. }
  2610. except (TRUE) {
  2611. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2612. #if DBG
  2613. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2614. #endif
  2615. }
  2616. return Status;
  2617. } // LlsGroupDeleteA
  2618. #ifdef OBSOLETE
  2619. //swi, code review, OBSOLETE routines are compiled but they are not called because they are not exported. some routines have server side implementation but some don't.
  2620. /////////////////////////////////////////////////////////////////////////
  2621. NTSTATUS
  2622. NTAPI
  2623. LlsServerEnumW(
  2624. LLS_HANDLE Handle,
  2625. LPWSTR Server,
  2626. DWORD Level,
  2627. LPBYTE* bufptr,
  2628. DWORD PrefMaxLen,
  2629. LPDWORD EntriesRead,
  2630. LPDWORD TotalEntries,
  2631. LPDWORD ResumeHandle
  2632. )
  2633. /*++
  2634. Routine Description:
  2635. Arguments:
  2636. Return Value:
  2637. None.
  2638. --*/
  2639. {
  2640. NTSTATUS Status;
  2641. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2642. GENERIC_ENUM_STRUCT InfoStruct;
  2643. PLOCAL_HANDLE pLocalHandle;
  2644. #ifdef API_TRACE
  2645. dprintf(TEXT("LLSRPC.DLL: LlsServerEnumW\n"));
  2646. #endif
  2647. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2648. if (pLocalHandle == NULL)
  2649. return STATUS_INVALID_PARAMETER;
  2650. GenericInfoContainer.Buffer = NULL;
  2651. GenericInfoContainer.EntriesRead = 0;
  2652. InfoStruct.Container = &GenericInfoContainer;
  2653. InfoStruct.Level = Level;
  2654. try {
  2655. Status = LlsrServerEnumW(
  2656. pLocalHandle->Handle,
  2657. Server,
  2658. (PLLS_SERVER_ENUM_STRUCTW) &InfoStruct,
  2659. PrefMaxLen,
  2660. TotalEntries,
  2661. ResumeHandle
  2662. );
  2663. }
  2664. except (TRUE) {
  2665. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2666. #if DBG
  2667. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2668. #endif
  2669. }
  2670. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2671. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2672. *EntriesRead = GenericInfoContainer.EntriesRead;
  2673. }
  2674. return Status;
  2675. } // LlsServerEnumW
  2676. /////////////////////////////////////////////////////////////////////////
  2677. NTSTATUS
  2678. NTAPI
  2679. LlsServerEnumA(
  2680. LLS_HANDLE Handle,
  2681. LPSTR Server,
  2682. DWORD Level,
  2683. LPBYTE* bufptr,
  2684. DWORD PrefMaxLen,
  2685. LPDWORD EntriesRead,
  2686. LPDWORD TotalEntries,
  2687. LPDWORD ResumeHandle
  2688. )
  2689. /*++
  2690. Routine Description:
  2691. Arguments:
  2692. Return Value:
  2693. None.
  2694. --*/
  2695. {
  2696. NTSTATUS Status;
  2697. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2698. GENERIC_ENUM_STRUCT InfoStruct;
  2699. PLOCAL_HANDLE pLocalHandle;
  2700. #ifdef API_TRACE
  2701. dprintf(TEXT("LLSRPC.DLL: LlsServerEnumA\n"));
  2702. #endif
  2703. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2704. if (pLocalHandle == NULL)
  2705. return STATUS_INVALID_PARAMETER;
  2706. GenericInfoContainer.Buffer = NULL;
  2707. GenericInfoContainer.EntriesRead = 0;
  2708. InfoStruct.Container = &GenericInfoContainer;
  2709. InfoStruct.Level = Level;
  2710. try {
  2711. Status = LlsrServerEnumA(
  2712. pLocalHandle->Handle,
  2713. Server,
  2714. (PLLS_SERVER_ENUM_STRUCTA) &InfoStruct,
  2715. PrefMaxLen,
  2716. TotalEntries,
  2717. ResumeHandle
  2718. );
  2719. }
  2720. except (TRUE) {
  2721. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2722. #if DBG
  2723. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2724. #endif
  2725. }
  2726. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2727. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2728. *EntriesRead = GenericInfoContainer.EntriesRead;
  2729. }
  2730. return Status;
  2731. } // LlsServerEnumA
  2732. /////////////////////////////////////////////////////////////////////////
  2733. NTSTATUS
  2734. NTAPI
  2735. LlsServerProductEnumW(
  2736. LLS_HANDLE Handle,
  2737. LPWSTR Server,
  2738. DWORD Level,
  2739. LPBYTE* bufptr,
  2740. DWORD PrefMaxLen,
  2741. LPDWORD EntriesRead,
  2742. LPDWORD TotalEntries,
  2743. LPDWORD ResumeHandle
  2744. )
  2745. /*++
  2746. Routine Description:
  2747. Arguments:
  2748. Return Value:
  2749. None.
  2750. --*/
  2751. {
  2752. NTSTATUS Status;
  2753. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2754. GENERIC_ENUM_STRUCT InfoStruct;
  2755. PLOCAL_HANDLE pLocalHandle;
  2756. #ifdef API_TRACE
  2757. dprintf(TEXT("LLSRPC.DLL: LlsServerProductEnumW\n"));
  2758. #endif
  2759. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2760. if (pLocalHandle == NULL)
  2761. return STATUS_INVALID_PARAMETER;
  2762. GenericInfoContainer.Buffer = NULL;
  2763. GenericInfoContainer.EntriesRead = 0;
  2764. InfoStruct.Container = &GenericInfoContainer;
  2765. InfoStruct.Level = Level;
  2766. try {
  2767. Status = LlsrServerProductEnumW(
  2768. pLocalHandle->Handle,
  2769. Server,
  2770. (PLLS_SERVER_PRODUCT_ENUM_STRUCTW) &InfoStruct,
  2771. PrefMaxLen,
  2772. TotalEntries,
  2773. ResumeHandle
  2774. );
  2775. }
  2776. except (TRUE) {
  2777. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2778. #if DBG
  2779. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2780. #endif
  2781. }
  2782. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2783. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2784. *EntriesRead = GenericInfoContainer.EntriesRead;
  2785. }
  2786. return Status;
  2787. } // LlsServerProductEnumW
  2788. /////////////////////////////////////////////////////////////////////////
  2789. NTSTATUS
  2790. NTAPI
  2791. LlsServerProductEnumA(
  2792. LLS_HANDLE Handle,
  2793. LPSTR Server,
  2794. DWORD Level,
  2795. LPBYTE* bufptr,
  2796. DWORD PrefMaxLen,
  2797. LPDWORD EntriesRead,
  2798. LPDWORD TotalEntries,
  2799. LPDWORD ResumeHandle
  2800. )
  2801. /*++
  2802. Routine Description:
  2803. Arguments:
  2804. Return Value:
  2805. None.
  2806. --*/
  2807. {
  2808. NTSTATUS Status;
  2809. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2810. GENERIC_ENUM_STRUCT InfoStruct;
  2811. PLOCAL_HANDLE pLocalHandle;
  2812. #ifdef API_TRACE
  2813. dprintf(TEXT("LLSRPC.DLL: LlsServerProductEnumA\n"));
  2814. #endif
  2815. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2816. if (pLocalHandle == NULL)
  2817. return STATUS_INVALID_PARAMETER;
  2818. GenericInfoContainer.Buffer = NULL;
  2819. GenericInfoContainer.EntriesRead = 0;
  2820. InfoStruct.Container = &GenericInfoContainer;
  2821. InfoStruct.Level = Level;
  2822. try {
  2823. Status = LlsrServerProductEnumA(
  2824. pLocalHandle->Handle,
  2825. Server,
  2826. (PLLS_SERVER_PRODUCT_ENUM_STRUCTA) &InfoStruct,
  2827. PrefMaxLen,
  2828. TotalEntries,
  2829. ResumeHandle
  2830. );
  2831. }
  2832. except (TRUE) {
  2833. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2834. #if DBG
  2835. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2836. #endif
  2837. }
  2838. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2839. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2840. *EntriesRead = GenericInfoContainer.EntriesRead;
  2841. }
  2842. return Status;
  2843. } // LlsServerProductEnumA
  2844. /////////////////////////////////////////////////////////////////////////
  2845. NTSTATUS
  2846. NTAPI
  2847. LlsLocalProductEnumW(
  2848. LLS_HANDLE Handle,
  2849. DWORD Level,
  2850. LPBYTE* bufptr,
  2851. DWORD PrefMaxLen,
  2852. LPDWORD EntriesRead,
  2853. LPDWORD TotalEntries,
  2854. LPDWORD ResumeHandle
  2855. )
  2856. /*++
  2857. Routine Description:
  2858. Arguments:
  2859. Return Value:
  2860. None.
  2861. --*/
  2862. {
  2863. NTSTATUS Status;
  2864. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2865. GENERIC_ENUM_STRUCT InfoStruct;
  2866. PLOCAL_HANDLE pLocalHandle;
  2867. #ifdef API_TRACE
  2868. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductEnumW\n"));
  2869. #endif
  2870. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2871. if (pLocalHandle == NULL)
  2872. return STATUS_INVALID_PARAMETER;
  2873. GenericInfoContainer.Buffer = NULL;
  2874. GenericInfoContainer.EntriesRead = 0;
  2875. InfoStruct.Container = &GenericInfoContainer;
  2876. InfoStruct.Level = Level;
  2877. try {
  2878. Status = LlsrLocalProductEnumW(
  2879. pLocalHandle->Handle,
  2880. (PLLS_SERVER_PRODUCT_ENUM_STRUCTW) &InfoStruct,
  2881. PrefMaxLen,
  2882. TotalEntries,
  2883. ResumeHandle
  2884. );
  2885. }
  2886. except (TRUE) {
  2887. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2888. #if DBG
  2889. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2890. #endif
  2891. }
  2892. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2893. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2894. *EntriesRead = GenericInfoContainer.EntriesRead;
  2895. }
  2896. return Status;
  2897. } // LlsLocalProductEnumW
  2898. /////////////////////////////////////////////////////////////////////////
  2899. NTSTATUS
  2900. NTAPI
  2901. LlsLocalProductEnumA(
  2902. LLS_HANDLE Handle,
  2903. DWORD Level,
  2904. LPBYTE* bufptr,
  2905. DWORD PrefMaxLen,
  2906. LPDWORD EntriesRead,
  2907. LPDWORD TotalEntries,
  2908. LPDWORD ResumeHandle
  2909. )
  2910. /*++
  2911. Routine Description:
  2912. Arguments:
  2913. Return Value:
  2914. None.
  2915. --*/
  2916. {
  2917. NTSTATUS Status;
  2918. GENERIC_INFO_CONTAINER GenericInfoContainer;
  2919. GENERIC_ENUM_STRUCT InfoStruct;
  2920. PLOCAL_HANDLE pLocalHandle;
  2921. #ifdef API_TRACE
  2922. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductEnumA\n"));
  2923. #endif
  2924. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2925. if (pLocalHandle == NULL)
  2926. return STATUS_INVALID_PARAMETER;
  2927. GenericInfoContainer.Buffer = NULL;
  2928. GenericInfoContainer.EntriesRead = 0;
  2929. InfoStruct.Container = &GenericInfoContainer;
  2930. InfoStruct.Level = Level;
  2931. try {
  2932. Status = LlsrLocalProductEnumA(
  2933. pLocalHandle->Handle,
  2934. (PLLS_SERVER_PRODUCT_ENUM_STRUCTA) &InfoStruct,
  2935. PrefMaxLen,
  2936. TotalEntries,
  2937. ResumeHandle
  2938. );
  2939. }
  2940. except (TRUE) {
  2941. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2942. #if DBG
  2943. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2944. #endif
  2945. }
  2946. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  2947. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  2948. *EntriesRead = GenericInfoContainer.EntriesRead;
  2949. }
  2950. return Status;
  2951. } // LlsLocalProductEnumA
  2952. /////////////////////////////////////////////////////////////////////////
  2953. NTSTATUS
  2954. NTAPI
  2955. LlsLocalProductInfoGetW(
  2956. IN LLS_HANDLE Handle,
  2957. IN LPWSTR Product,
  2958. IN DWORD Level,
  2959. OUT LPBYTE* bufptr
  2960. )
  2961. /*++
  2962. Routine Description:
  2963. Arguments:
  2964. Return Value:
  2965. None.
  2966. --*/
  2967. {
  2968. NTSTATUS Status;
  2969. PLOCAL_HANDLE pLocalHandle;
  2970. #ifdef API_TRACE
  2971. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductInfoGetW\n"));
  2972. #endif
  2973. pLocalHandle = (PLOCAL_HANDLE) Handle;
  2974. if ((pLocalHandle == NULL) || (bufptr == NULL))
  2975. return STATUS_INVALID_PARAMETER;
  2976. *bufptr = NULL;
  2977. try {
  2978. Status = LlsrLocalProductInfoGetW(pLocalHandle->Handle, Product, Level, (PVOID) bufptr);
  2979. }
  2980. except (TRUE) {
  2981. Status = I_RpcMapWin32Status(RpcExceptionCode());
  2982. #if DBG
  2983. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  2984. #endif
  2985. }
  2986. return Status;
  2987. } // LlsLocalProductInfoGetW
  2988. /////////////////////////////////////////////////////////////////////////
  2989. NTSTATUS
  2990. NTAPI
  2991. LlsLocalProductInfoGetA(
  2992. IN LLS_HANDLE Handle,
  2993. IN LPSTR Product,
  2994. IN DWORD Level,
  2995. OUT LPBYTE* bufptr
  2996. )
  2997. /*++
  2998. Routine Description:
  2999. Arguments:
  3000. Return Value:
  3001. None.
  3002. --*/
  3003. {
  3004. NTSTATUS Status;
  3005. PLOCAL_HANDLE pLocalHandle;
  3006. #ifdef API_TRACE
  3007. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductInfoGetA\n"));
  3008. #endif
  3009. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3010. if ((pLocalHandle == NULL) || (bufptr == NULL))
  3011. return STATUS_INVALID_PARAMETER;
  3012. *bufptr = NULL;
  3013. try {
  3014. Status = LlsrLocalProductInfoGetA(pLocalHandle->Handle, Product, Level, (PVOID) bufptr);
  3015. }
  3016. except (TRUE) {
  3017. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3018. #if DBG
  3019. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3020. #endif
  3021. }
  3022. return Status;
  3023. } // LlsLocalProductInfoGetA
  3024. /////////////////////////////////////////////////////////////////////////
  3025. NTSTATUS
  3026. NTAPI
  3027. LlsLocalProductInfoSetW(
  3028. IN LLS_HANDLE Handle,
  3029. IN LPWSTR Product,
  3030. IN DWORD Level,
  3031. IN LPBYTE bufptr
  3032. )
  3033. /*++
  3034. Routine Description:
  3035. Arguments:
  3036. Return Value:
  3037. None.
  3038. --*/
  3039. {
  3040. NTSTATUS Status;
  3041. PLOCAL_HANDLE pLocalHandle;
  3042. #ifdef API_TRACE
  3043. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductInfoSetW\n"));
  3044. #endif
  3045. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3046. if (pLocalHandle == NULL)
  3047. return STATUS_INVALID_PARAMETER;
  3048. try {
  3049. Status = LlsrLocalProductInfoSetW(pLocalHandle->Handle, Product, Level, (PVOID) bufptr);
  3050. }
  3051. except (TRUE) {
  3052. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3053. #if DBG
  3054. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3055. #endif
  3056. }
  3057. return Status;
  3058. } // LlsLocalProductInfoSetW
  3059. /////////////////////////////////////////////////////////////////////////
  3060. NTSTATUS
  3061. NTAPI
  3062. LlsLocalProductInfoSetA(
  3063. IN LLS_HANDLE Handle,
  3064. IN LPSTR Product,
  3065. IN DWORD Level,
  3066. IN LPBYTE bufptr
  3067. )
  3068. /*++
  3069. Routine Description:
  3070. Arguments:
  3071. Return Value:
  3072. None.
  3073. --*/
  3074. {
  3075. NTSTATUS Status;
  3076. PLOCAL_HANDLE pLocalHandle;
  3077. #ifdef API_TRACE
  3078. dprintf(TEXT("LLSRPC.DLL: LlsLocalProductInfoSetA\n"));
  3079. #endif
  3080. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3081. if (pLocalHandle == NULL)
  3082. return STATUS_INVALID_PARAMETER;
  3083. try {
  3084. Status = LlsrLocalProductInfoSetA(pLocalHandle->Handle, Product, Level, (PVOID) bufptr);
  3085. }
  3086. except (TRUE) {
  3087. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3088. #if DBG
  3089. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3090. #endif
  3091. }
  3092. return Status;
  3093. } // LlsLocalProductInfoSetA
  3094. #endif // OBSOLETE
  3095. /////////////////////////////////////////////////////////////////////////
  3096. NTSTATUS
  3097. NTAPI
  3098. LlsServiceInfoGetW(
  3099. IN LLS_HANDLE Handle,
  3100. IN DWORD Level,
  3101. OUT LPBYTE* bufptr
  3102. )
  3103. /*++
  3104. Routine Description:
  3105. Arguments:
  3106. Return Value:
  3107. None.
  3108. --*/
  3109. {
  3110. NTSTATUS Status;
  3111. PLOCAL_HANDLE pLocalHandle;
  3112. HRESULT hr;
  3113. #ifdef API_TRACE
  3114. dprintf(TEXT("LLSRPC.DLL: LlsServiceInfoGetW\n"));
  3115. #endif
  3116. *bufptr = NULL;
  3117. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3118. if ((pLocalHandle == NULL) || (bufptr == NULL))
  3119. return STATUS_INVALID_PARAMETER;
  3120. if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SERVICE_INFO_GETW ) )
  3121. {
  3122. try {
  3123. Status = LlsrServiceInfoGetW(pLocalHandle->Handle, Level, (PVOID) bufptr);
  3124. }
  3125. except (TRUE) {
  3126. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3127. #if DBG
  3128. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3129. #endif
  3130. }
  3131. }
  3132. else if ( 0 != Level )
  3133. {
  3134. Status = STATUS_INVALID_LEVEL;
  3135. }
  3136. else
  3137. {
  3138. // the target server will blow up if we make the RPC call
  3139. // in 3.51, the IDL file for the returned structure was incorrect, causing
  3140. // the ReplicateTo and EnterpriseServer buffers at the server to be freed
  3141. // instead, get this info from the target machine's registry
  3142. PLLS_SERVICE_INFO_0W pServiceInfo;
  3143. pServiceInfo = MIDL_user_allocate( sizeof( *pServiceInfo ) );
  3144. if ( NULL == pServiceInfo )
  3145. {
  3146. Status = STATUS_NO_MEMORY;
  3147. }
  3148. else
  3149. {
  3150. DWORD cbServerName = sizeof( WCHAR ) * ( 3 + MAX_PATH );
  3151. ZeroMemory( pServiceInfo, sizeof( *pServiceInfo ) );
  3152. pServiceInfo->Version = 5; // we know it's a 3.51 box
  3153. pServiceInfo->TimeStarted = 0; // don't know, but 3.51 fills in 0 anyway
  3154. pServiceInfo->Mode = LLS_MODE_ENTERPRISE_SERVER; // we know it's a 3.51 box
  3155. pServiceInfo->ReplicateTo = MIDL_user_allocate( cbServerName );
  3156. pServiceInfo->EnterpriseServer = MIDL_user_allocate( cbServerName );
  3157. if ( ( NULL == pServiceInfo->ReplicateTo ) || ( NULL == pServiceInfo->EnterpriseServer ) )
  3158. {
  3159. Status = STATUS_NO_MEMORY;
  3160. }
  3161. else
  3162. {
  3163. HKEY hKeyLocalMachine;
  3164. LONG lError;
  3165. // get parameters from registry
  3166. lError = RegConnectRegistry( pLocalHandle->szServerName + 2, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  3167. if ( ERROR_SUCCESS == lError )
  3168. {
  3169. HKEY hKeyParameters;
  3170. lError = RegOpenKeyEx( hKeyLocalMachine, TEXT( "System\\CurrentControlSet\\Services\\LicenseService\\Parameters" ), 0, KEY_READ, &hKeyParameters );
  3171. if ( ERROR_SUCCESS == lError )
  3172. {
  3173. DWORD cbData;
  3174. // these parameters all default to 0
  3175. // (they were initialized to 0 via ZeroMemory(), above)
  3176. cbData = sizeof( pServiceInfo->ReplicationTime );
  3177. lError = RegQueryValueEx( hKeyParameters, TEXT( "ReplicationTime" ), NULL, NULL, (LPBYTE) &pServiceInfo->ReplicationTime, &cbData );
  3178. cbData = sizeof( pServiceInfo->ReplicationType );
  3179. lError = RegQueryValueEx( hKeyParameters, TEXT( "ReplicationType" ), NULL, NULL, (LPBYTE) &pServiceInfo->ReplicationType, &cbData );
  3180. cbData = sizeof( pServiceInfo->UseEnterprise );
  3181. lError = RegQueryValueEx( hKeyParameters, TEXT( "UseEnterprise" ), NULL, NULL, (LPBYTE) &pServiceInfo->UseEnterprise, &cbData );
  3182. RegCloseKey( hKeyParameters );
  3183. lError = ERROR_SUCCESS;
  3184. }
  3185. RegCloseKey( hKeyLocalMachine );
  3186. }
  3187. switch ( lError )
  3188. {
  3189. case ERROR_SUCCESS:
  3190. Status = STATUS_SUCCESS;
  3191. break;
  3192. case ERROR_ACCESS_DENIED:
  3193. Status = STATUS_ACCESS_DENIED;
  3194. break;
  3195. default:
  3196. Status = STATUS_UNSUCCESSFUL;
  3197. break;
  3198. }
  3199. if ( STATUS_SUCCESS == Status )
  3200. {
  3201. // parameters retrieved from registry; only remaining parameters
  3202. // to be filled in are EnterpriseServer and ReplicateTo
  3203. TCHAR szDomain[ 1 + MAX_PATH ];
  3204. // retrieve the enterprise server
  3205. EnterpriseServerGet( pLocalHandle->szServerName, pServiceInfo->EnterpriseServer, cbServerName);
  3206. // derive ReplicateTo
  3207. Status = NTDomainGet( pLocalHandle->szServerName, szDomain, sizeof(szDomain));
  3208. if ( STATUS_ACCESS_DENIED != Status )
  3209. {
  3210. if ( STATUS_SUCCESS == Status )
  3211. {
  3212. NET_API_STATUS netStatus;
  3213. LPWSTR pszDCName;
  3214. netStatus = NetGetDCName( NULL, szDomain, (LPBYTE *) &pszDCName );
  3215. if ( NERR_Success == netStatus )
  3216. {
  3217. if ( !lstrcmpi( pszDCName, pLocalHandle->szServerName ) )
  3218. {
  3219. // server is primary domain controller;
  3220. // it replicates to its enterprise server (if any)
  3221. hr = StringCbCopy( pServiceInfo->ReplicateTo, cbServerName, pServiceInfo->EnterpriseServer );
  3222. }
  3223. else
  3224. {
  3225. // server is domain member; it replicates to the DC
  3226. hr = StringCbCopy( pServiceInfo->ReplicateTo, cbServerName, pszDCName );
  3227. }
  3228. ASSERT(SUCCEEDED(hr));
  3229. NetApiBufferFree( pszDCName );
  3230. }
  3231. else
  3232. {
  3233. // server had domain but domain has no DC?
  3234. Status = STATUS_NO_SUCH_DOMAIN;
  3235. }
  3236. }
  3237. else
  3238. {
  3239. // server is not in a domain;
  3240. // it replicates to its enterprise server (if any)
  3241. hr = StringCchCopy( pServiceInfo->ReplicateTo, cbServerName, pServiceInfo->EnterpriseServer );
  3242. ASSERT(SUCCEEDED(hr));
  3243. Status = STATUS_SUCCESS;
  3244. }
  3245. }
  3246. }
  3247. }
  3248. }
  3249. if ( STATUS_SUCCESS != Status )
  3250. {
  3251. if ( NULL != pServiceInfo )
  3252. {
  3253. if ( NULL != pServiceInfo->ReplicateTo )
  3254. {
  3255. MIDL_user_free( pServiceInfo->ReplicateTo );
  3256. }
  3257. if ( NULL != pServiceInfo->EnterpriseServer )
  3258. {
  3259. MIDL_user_free( pServiceInfo->EnterpriseServer );
  3260. }
  3261. MIDL_user_free( pServiceInfo );
  3262. }
  3263. }
  3264. else
  3265. {
  3266. if ( !lstrcmpi( pLocalHandle->szServerName, pServiceInfo->ReplicateTo ) )
  3267. {
  3268. *pServiceInfo->ReplicateTo = TEXT( '\0' );
  3269. }
  3270. if ( !lstrcmpi( pLocalHandle->szServerName, pServiceInfo->EnterpriseServer ) )
  3271. {
  3272. *pServiceInfo->EnterpriseServer = TEXT( '\0' );
  3273. }
  3274. *bufptr = (LPBYTE) pServiceInfo;
  3275. }
  3276. }
  3277. return Status;
  3278. } // LlsServiceInfoGetW
  3279. /////////////////////////////////////////////////////////////////////////
  3280. NTSTATUS
  3281. NTAPI
  3282. LlsServiceInfoGetA(
  3283. IN LLS_HANDLE Handle,
  3284. IN DWORD Level,
  3285. OUT LPBYTE* bufptr
  3286. )
  3287. /*++
  3288. Routine Description:
  3289. Arguments:
  3290. Return Value:
  3291. None.
  3292. --*/
  3293. {
  3294. NTSTATUS Status;
  3295. PLOCAL_HANDLE pLocalHandle;
  3296. #ifdef API_TRACE
  3297. dprintf(TEXT("LLSRPC.DLL: LlsServiceInfoGetA\n"));
  3298. #endif
  3299. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3300. if ((pLocalHandle == NULL) || (bufptr == NULL))
  3301. return STATUS_INVALID_PARAMETER;
  3302. *bufptr = NULL;
  3303. try {
  3304. Status = LlsrServiceInfoGetA(pLocalHandle->Handle, Level, (PVOID) bufptr);
  3305. }
  3306. except (TRUE) {
  3307. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3308. #if DBG
  3309. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3310. #endif
  3311. }
  3312. return Status;
  3313. } // LlsServiceInfoGetA
  3314. /////////////////////////////////////////////////////////////////////////
  3315. NTSTATUS
  3316. NTAPI
  3317. LlsServiceInfoSetW(
  3318. IN LLS_HANDLE Handle,
  3319. IN DWORD Level,
  3320. IN LPBYTE bufptr
  3321. )
  3322. /*++
  3323. Routine Description:
  3324. Arguments:
  3325. Return Value:
  3326. None.
  3327. --*/
  3328. {
  3329. NTSTATUS Status;
  3330. PLOCAL_HANDLE pLocalHandle;
  3331. #ifdef API_TRACE
  3332. dprintf(TEXT("LLSRPC.DLL: LlsServiceInfoSetW\n"));
  3333. #endif
  3334. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3335. if (pLocalHandle == NULL)
  3336. return STATUS_INVALID_PARAMETER;
  3337. try {
  3338. Status = LlsrServiceInfoSetW(pLocalHandle->Handle, Level, (PVOID) bufptr);
  3339. }
  3340. except (TRUE) {
  3341. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3342. #if DBG
  3343. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3344. #endif
  3345. }
  3346. if ( ( STATUS_NOT_SUPPORTED == Status ) && ( 0 == Level ) )
  3347. {
  3348. // RPC API is not supported; use the registry instead
  3349. HKEY hKeyLocalMachine;
  3350. HKEY hKeyParameters;
  3351. LONG lError;
  3352. PLLS_SERVICE_INFO_0W pServiceInfo = (PLLS_SERVICE_INFO_0W) bufptr;
  3353. LPWSTR pszEnterpriseServer;
  3354. pszEnterpriseServer = pServiceInfo->EnterpriseServer;
  3355. // strip leading backslashes from EnterpriseServer
  3356. if ( !wcsncmp( pszEnterpriseServer, L"\\\\", 2 ) )
  3357. {
  3358. pszEnterpriseServer += 2;
  3359. }
  3360. lError = RegConnectRegistry( pLocalHandle->szServerName + 2, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  3361. if ( ERROR_SUCCESS == lError )
  3362. {
  3363. lError = RegOpenKeyEx( hKeyLocalMachine, TEXT( "System\\CurrentControlSet\\Services\\LicenseService\\Parameters" ), 0, KEY_WRITE, &hKeyParameters );
  3364. if ( ERROR_SUCCESS == lError )
  3365. {
  3366. lError = RegSetValueExW( hKeyParameters, L"EnterpriseServer", 0, REG_SZ, (LPBYTE) pszEnterpriseServer, sizeof( *pszEnterpriseServer ) * ( 1 + lstrlenW( pszEnterpriseServer ) ) );
  3367. if ( ERROR_SUCCESS == lError )
  3368. {
  3369. lError = RegSetValueEx( hKeyParameters, TEXT( "ReplicationTime" ), 0, REG_DWORD, (LPBYTE) &pServiceInfo->ReplicationTime, sizeof( pServiceInfo->ReplicationTime ) );
  3370. if ( ERROR_SUCCESS == lError )
  3371. {
  3372. lError = RegSetValueEx( hKeyParameters, TEXT( "ReplicationType" ), 0, REG_DWORD, (LPBYTE) &pServiceInfo->ReplicationType, sizeof( pServiceInfo->ReplicationType ) );
  3373. if ( ERROR_SUCCESS == lError )
  3374. {
  3375. lError = RegSetValueEx( hKeyParameters, TEXT( "UseEnterprise" ), 0, REG_DWORD, (LPBYTE) &pServiceInfo->UseEnterprise, sizeof( pServiceInfo->UseEnterprise ) );
  3376. if ( ERROR_SUCCESS == lError )
  3377. {
  3378. Status = STATUS_SUCCESS;
  3379. }
  3380. }
  3381. }
  3382. }
  3383. RegCloseKey( hKeyParameters );
  3384. }
  3385. RegCloseKey( hKeyLocalMachine );
  3386. }
  3387. }
  3388. return Status;
  3389. } // LlsServiceInfoSetW
  3390. /////////////////////////////////////////////////////////////////////////
  3391. NTSTATUS
  3392. NTAPI
  3393. LlsServiceInfoSetA(
  3394. IN LLS_HANDLE Handle,
  3395. IN DWORD Level,
  3396. IN LPBYTE bufptr
  3397. )
  3398. /*++
  3399. Routine Description:
  3400. Arguments:
  3401. Return Value:
  3402. None.
  3403. --*/
  3404. {
  3405. NTSTATUS Status;
  3406. PLOCAL_HANDLE pLocalHandle;
  3407. #ifdef API_TRACE
  3408. dprintf(TEXT("LLSRPC.DLL: LlsServiceInfoSetA\n"));
  3409. #endif
  3410. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3411. if (pLocalHandle == NULL)
  3412. return STATUS_INVALID_PARAMETER;
  3413. try {
  3414. Status = LlsrServiceInfoSetA(pLocalHandle->Handle, Level, (PVOID) bufptr);
  3415. }
  3416. except (TRUE) {
  3417. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3418. #if DBG
  3419. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3420. #endif
  3421. }
  3422. return Status;
  3423. } // LlsServiceInfoSetA
  3424. /////////////////////////////////////////////////////////////////////////
  3425. /////////////////////////////////////////////////////////////////////////
  3426. /////////////////////////////////////////////////////////////////////////
  3427. /////////////////////////////////////////////////////////////////////////
  3428. NTSTATUS
  3429. LlsReplConnectW(
  3430. LPTSTR Server,
  3431. LLS_REPL_HANDLE* Handle
  3432. )
  3433. /*++
  3434. Routine Description:
  3435. Arguments:
  3436. Return Value:
  3437. None.
  3438. --*/
  3439. {
  3440. RPC_STATUS Status;
  3441. LPTSTR pszUuid = NULL;
  3442. LPTSTR pszProtocolSequence = NULL;
  3443. LPTSTR pszNetworkAddress = NULL;
  3444. LPTSTR pszEndpoint = NULL;
  3445. LPTSTR pszOptions = NULL;
  3446. TCHAR pComputer[MAX_COMPUTERNAME_LENGTH + 1];
  3447. ULONG Size;
  3448. #ifdef API_TRACE
  3449. if (Server == NULL)
  3450. dprintf(TEXT("LLSRPC.DLL: LlsReplConnectW: <NULL>\n"));
  3451. else
  3452. dprintf(TEXT("LLSRPC.DLL: LlsReplConnectW: %s\n"), Server);
  3453. #endif
  3454. //
  3455. // ** NEW - NT 5.0 **
  3456. //
  3457. // The server name may either be a DNS name or a NetBIOS name.
  3458. //
  3459. if (Server == NULL || (Server != NULL && !*Server))
  3460. return STATUS_INVALID_PARAMETER;
  3461. Size = sizeof(pComputer) / sizeof(TCHAR);
  3462. GetComputerName(pComputer, &Size);
  3463. pszProtocolSequence = TEXT("ncacn_np");
  3464. pszEndpoint = TEXT(LLS_NP_ENDPOINT);
  3465. pszNetworkAddress = Server;
  3466. pszOptions = TEXT("Security=Identification Static True"); // Bug# 559563 - Static is default for ncacn_np
  3467. // Compose a string binding
  3468. Status = RpcStringBindingComposeW(pszUuid,
  3469. pszProtocolSequence,
  3470. pszNetworkAddress,
  3471. pszEndpoint,
  3472. pszOptions,
  3473. &pszStringBinding);
  3474. if(Status) {
  3475. #if DBG
  3476. dprintf(TEXT("LLSRPC RpcStringBindingComposeW Failed: 0x%lX\n"), Status);
  3477. #endif
  3478. return I_RpcMapWin32Status(Status);
  3479. }
  3480. RtlEnterCriticalSection( &g_RpcHandleLock );
  3481. // Bind using the created string binding...
  3482. Status = RpcBindingFromStringBindingW(pszStringBinding, &llsrpc_handle);
  3483. if(Status) {
  3484. #if DBG
  3485. dprintf(TEXT("LLSRPC RpcBindingFromStringBindingW Failed: 0x%lX\n"), Status);
  3486. #endif
  3487. if(pszStringBinding != NULL)
  3488. {
  3489. RpcStringFree(&pszStringBinding);
  3490. }
  3491. if(llsrpc_handle != NULL)
  3492. {
  3493. RpcBindingFree(llsrpc_handle);
  3494. llsrpc_handle = NULL;
  3495. }
  3496. RtlLeaveCriticalSection( &g_RpcHandleLock );
  3497. return I_RpcMapWin32Status(Status);
  3498. }
  3499. try {
  3500. LlsrReplConnect(Handle, pComputer);
  3501. }
  3502. except (TRUE) {
  3503. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3504. #if DBG
  3505. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3506. #endif
  3507. }
  3508. if(!NT_SUCCESS(Status))
  3509. {
  3510. if(pszStringBinding != NULL)
  3511. {
  3512. RpcStringFree(&pszStringBinding);
  3513. }
  3514. if(llsrpc_handle != NULL)
  3515. {
  3516. RpcBindingFree(llsrpc_handle);
  3517. llsrpc_handle = NULL;
  3518. }
  3519. }
  3520. RtlLeaveCriticalSection( &g_RpcHandleLock );
  3521. return I_RpcMapWin32Status(Status);
  3522. } // LlsReplConnectW
  3523. /////////////////////////////////////////////////////////////////////////
  3524. NTSTATUS
  3525. NTAPI
  3526. LlsReplClose(
  3527. PLLS_REPL_HANDLE Handle
  3528. )
  3529. /*++
  3530. Routine Description:
  3531. Arguments:
  3532. Return Value:
  3533. None.
  3534. --*/
  3535. {
  3536. RPC_STATUS Status;
  3537. NTSTATUS NtStatus = STATUS_SUCCESS;
  3538. try {
  3539. NtStatus = LlsrReplClose(Handle);
  3540. }
  3541. except (TRUE) {
  3542. NtStatus = I_RpcMapWin32Status(RpcExceptionCode());
  3543. #if DBG
  3544. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), NtStatus);
  3545. #endif
  3546. }
  3547. try {
  3548. Status = RpcStringFree(&pszStringBinding);
  3549. if (Status ) {
  3550. NtStatus = I_RpcMapWin32Status(Status);
  3551. #if DBG
  3552. dprintf(TEXT("LLSRPC.DLL: LlsClose - RpcStringFree returned: 0x%lX\n"), NtStatus);
  3553. #endif
  3554. }
  3555. Status = RpcBindingFree(&llsrpc_handle);
  3556. if (Status ) {
  3557. NtStatus = I_RpcMapWin32Status(Status);
  3558. #if DBG
  3559. dprintf(TEXT("LLSRPC.DLL: LlsClose - RpcBindingFree returned: 0x%lX\n"), NtStatus);
  3560. #endif
  3561. }
  3562. }
  3563. except (TRUE) {
  3564. NtStatus = I_RpcMapWin32Status(RpcExceptionCode());
  3565. #if DBG
  3566. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), NtStatus);
  3567. #endif
  3568. }
  3569. return NtStatus;
  3570. } // LlsClose
  3571. /////////////////////////////////////////////////////////////////////////
  3572. NTSTATUS
  3573. LlsReplicationRequestW(
  3574. IN LLS_REPL_HANDLE Handle,
  3575. IN DWORD Version,
  3576. IN OUT PREPL_REQUEST Request
  3577. )
  3578. /*++
  3579. Routine Description:
  3580. Arguments:
  3581. Return Value:
  3582. None.
  3583. --*/
  3584. {
  3585. NTSTATUS Status;
  3586. try {
  3587. Status = LlsrReplicationRequestW(Handle, Version, Request);
  3588. }
  3589. except (TRUE) {
  3590. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3591. #if DBG
  3592. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3593. #endif
  3594. }
  3595. return Status;
  3596. } // LlsReplicationRequestW
  3597. /////////////////////////////////////////////////////////////////////////
  3598. NTSTATUS
  3599. LlsReplicationServerAddW(
  3600. IN LLS_REPL_HANDLE Handle,
  3601. IN ULONG NumRecords,
  3602. IN PREPL_SERVER_RECORD Servers
  3603. )
  3604. /*++
  3605. Routine Description:
  3606. Arguments:
  3607. Return Value:
  3608. None.
  3609. --*/
  3610. {
  3611. NTSTATUS Status;
  3612. try {
  3613. Status = LlsrReplicationServerAddW(Handle, NumRecords, Servers);
  3614. }
  3615. except (TRUE) {
  3616. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3617. #if DBG
  3618. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3619. #endif
  3620. }
  3621. return Status;
  3622. } // LlsReplicationServerAddW
  3623. /////////////////////////////////////////////////////////////////////////
  3624. NTSTATUS
  3625. LlsReplicationServerServiceAddW(
  3626. IN LLS_REPL_HANDLE Handle,
  3627. IN ULONG NumRecords,
  3628. IN PREPL_SERVER_SERVICE_RECORD ServerServices
  3629. )
  3630. /*++
  3631. Routine Description:
  3632. Arguments:
  3633. Return Value:
  3634. None.
  3635. --*/
  3636. {
  3637. NTSTATUS Status;
  3638. try {
  3639. Status = LlsrReplicationServerServiceAddW(Handle, NumRecords, ServerServices);
  3640. }
  3641. except (TRUE) {
  3642. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3643. #if DBG
  3644. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3645. #endif
  3646. }
  3647. return Status;
  3648. } // LlsReplicationServerServiceAddW
  3649. /////////////////////////////////////////////////////////////////////////
  3650. NTSTATUS
  3651. LlsReplicationServiceAddW(
  3652. IN LLS_REPL_HANDLE Handle,
  3653. IN ULONG NumRecords,
  3654. IN PREPL_SERVICE_RECORD Services
  3655. )
  3656. /*++
  3657. Routine Description:
  3658. Arguments:
  3659. Return Value:
  3660. None.
  3661. --*/
  3662. {
  3663. NTSTATUS Status;
  3664. try {
  3665. Status = LlsrReplicationServiceAddW(Handle, NumRecords, Services);
  3666. }
  3667. except (TRUE) {
  3668. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3669. #if DBG
  3670. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3671. #endif
  3672. }
  3673. return Status;
  3674. } // LlsReplicationServiceAddW
  3675. /////////////////////////////////////////////////////////////////////////
  3676. NTSTATUS
  3677. LlsReplicationUserAddW(
  3678. IN LLS_REPL_HANDLE Handle,
  3679. IN ULONG NumRecords,
  3680. IN PREPL_USER_RECORD_0 Users
  3681. )
  3682. /*++
  3683. Routine Description:
  3684. Arguments:
  3685. Return Value:
  3686. None.
  3687. --*/
  3688. {
  3689. NTSTATUS Status;
  3690. try {
  3691. Status = LlsrReplicationUserAddW(Handle, NumRecords, Users);
  3692. }
  3693. except (TRUE) {
  3694. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3695. #if DBG
  3696. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3697. #endif
  3698. }
  3699. return Status;
  3700. } // LlsReplicationUserAddW
  3701. /////////////////////////////////////////////////////////////////////////
  3702. /////////////////////////////////////////////////////////////////////////
  3703. /////////////////////////////////////////////////////////////////////////
  3704. NTSTATUS
  3705. NTAPI
  3706. LlsProductSecurityGetW(
  3707. LLS_HANDLE Handle,
  3708. LPWSTR Product,
  3709. LPBOOL pIsSecure
  3710. )
  3711. /*++
  3712. Routine Description:
  3713. Retrieve the "security" of a product. A product is deemed secure iff
  3714. it requires a secure certificate. In such a case, licenses for the
  3715. product may not be entered via the Honesty ("enter the number of
  3716. licenses you purchased") method.
  3717. Arguments:
  3718. Handle (LLS_HANDLE)
  3719. An open LLS handle to the target license server.
  3720. Product (LPWSTR)
  3721. The name of the product ("DisplayName") for which to receive the
  3722. security.
  3723. pIsSecure (LPBOOL)
  3724. On return, and if successful, indicates whether the product is
  3725. secure.
  3726. Return Value:
  3727. STATUS_SUCCESS or NTSTATUS error code.
  3728. --*/
  3729. {
  3730. NTSTATUS Status;
  3731. PLOCAL_HANDLE pLocalHandle;
  3732. #ifdef API_TRACE
  3733. dprintf(TEXT("LLSRPC.DLL: LlsProductSecurityGetW\n"));
  3734. #endif
  3735. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  3736. {
  3737. return STATUS_NOT_SUPPORTED;
  3738. }
  3739. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3740. if (pLocalHandle == NULL)
  3741. return STATUS_INVALID_PARAMETER;
  3742. try {
  3743. Status = LlsrProductSecurityGetW( pLocalHandle->Handle, Product, pIsSecure );
  3744. }
  3745. except (TRUE) {
  3746. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3747. #if DBG
  3748. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3749. #endif
  3750. }
  3751. return Status;
  3752. } // LlsProductSecurityGetW
  3753. /////////////////////////////////////////////////////////////////////////
  3754. NTSTATUS
  3755. NTAPI
  3756. LlsProductSecurityGetA(
  3757. LLS_HANDLE Handle,
  3758. LPSTR Product,
  3759. LPBOOL pIsSecure
  3760. )
  3761. /*++
  3762. Routine Description:
  3763. Retrieve the "security" of a product. A product is deemed secure iff
  3764. it requires a secure certificate. In such a case, licenses for the
  3765. product may not be entered via the Honesty ("enter the number of
  3766. licenses you purchased") method.
  3767. NOTE: Not yet implemented. Use LlsProductSecurityGetW().
  3768. Arguments:
  3769. Handle (LLS_HANDLE)
  3770. An open LLS handle to the target license server.
  3771. Product (LPSTR)
  3772. The name of the product ("DisplayName") for which to receive the
  3773. security.
  3774. pIsSecure (LPBOOL)
  3775. On return, and if successful, indicates whether the product is
  3776. secure.
  3777. Return Value:
  3778. STATUS_NOT_SUPPORTED.
  3779. --*/
  3780. {
  3781. #ifdef API_TRACE
  3782. dprintf(TEXT("LLSRPC.DLL: LlsProductSecurityGetA\n"));
  3783. #endif
  3784. UNREFERENCED_PARAMETER(Handle);
  3785. UNREFERENCED_PARAMETER(Product);
  3786. UNREFERENCED_PARAMETER(pIsSecure);
  3787. return STATUS_NOT_SUPPORTED;
  3788. } // LlsProductSecurityGetA
  3789. /////////////////////////////////////////////////////////////////////////
  3790. NTSTATUS
  3791. NTAPI
  3792. LlsProductSecuritySetW(
  3793. LLS_HANDLE Handle,
  3794. LPWSTR Product
  3795. )
  3796. /*++
  3797. Routine Description:
  3798. Flags the given product as secure. A product is deemed secure iff
  3799. it requires a secure certificate. In such a case, licenses for the
  3800. product may not be entered via the Honesty ("enter the number of
  3801. licenses you purchased") method.
  3802. This designation is not reversible and is propagated up the
  3803. replication tree.
  3804. Arguments:
  3805. Handle (LLS_HANDLE)
  3806. An open LLS handle to the target license server.
  3807. Product (LPWSTR)
  3808. The name of the product ("DisplayName") for which to activate
  3809. security.
  3810. Return Value:
  3811. STATUS_SUCCESS or NTSTATUS error code.
  3812. --*/
  3813. {
  3814. NTSTATUS Status;
  3815. PLOCAL_HANDLE pLocalHandle;
  3816. #ifdef API_TRACE
  3817. dprintf(TEXT("LLSRPC.DLL: LlsProductSecuritySetW\n"));
  3818. #endif
  3819. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  3820. {
  3821. return STATUS_NOT_SUPPORTED;
  3822. }
  3823. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3824. if (pLocalHandle == NULL)
  3825. return STATUS_INVALID_PARAMETER;
  3826. try {
  3827. Status = LlsrProductSecuritySetW( pLocalHandle->Handle, Product );
  3828. }
  3829. except (TRUE) {
  3830. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3831. #if DBG
  3832. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3833. #endif
  3834. }
  3835. return Status;
  3836. } // LlsProductSecuritySetW
  3837. /////////////////////////////////////////////////////////////////////////
  3838. NTSTATUS
  3839. NTAPI
  3840. LlsProductSecuritySetA(
  3841. LLS_HANDLE Handle,
  3842. LPSTR Product
  3843. )
  3844. /*++
  3845. Routine Description:
  3846. Flags the given product as secure. A product is deemed secure iff
  3847. it requires a secure certificate. In such a case, licenses for the
  3848. product may not be entered via the Honesty ("enter the number of
  3849. licenses you purchased") method.
  3850. This designation is not reversible and is propagated up the
  3851. replication tree.
  3852. NOTE: Not yet implemented. Use LlsProductSecuritySetW().
  3853. Arguments:
  3854. Handle (LLS_HANDLE)
  3855. An open LLS handle to the target license server.
  3856. Product (LPSTR)
  3857. The name of the product ("DisplayName") for which to activate
  3858. security.
  3859. Return Value:
  3860. STATUS_NOT_SUPPORTED.
  3861. --*/
  3862. {
  3863. #ifdef API_TRACE
  3864. dprintf(TEXT("LLSRPC.DLL: LlsProductSecuritySetA\n"));
  3865. #endif
  3866. UNREFERENCED_PARAMETER(Handle);
  3867. UNREFERENCED_PARAMETER(Product);
  3868. return STATUS_NOT_SUPPORTED;
  3869. } // LlsProductSecuritySetA
  3870. /////////////////////////////////////////////////////////////////////////
  3871. NTSTATUS
  3872. NTAPI
  3873. LlsProductLicensesGetW(
  3874. LLS_HANDLE Handle,
  3875. LPWSTR Product,
  3876. DWORD Mode,
  3877. LPDWORD pQuantity )
  3878. /*++
  3879. Routine Description:
  3880. Returns the number of licenses installed on the target machine for
  3881. use in the given mode.
  3882. Arguments:
  3883. Handle (LLS_HANDLE)
  3884. An open LLS handle to the target license server.
  3885. Product (LPWSTR)
  3886. The name of the product for which to tally licenses.
  3887. Mode (DWORD)
  3888. Licensing mode for which to tally the licenses.
  3889. pQuantity (LPDWORD)
  3890. On return (and if successful), holds the total number of licenses
  3891. for use by the given product in the given license mode.
  3892. Return Value:
  3893. STATUS_SUCCESS or NTSTATUS error code.
  3894. --*/
  3895. {
  3896. NTSTATUS Status;
  3897. PLOCAL_HANDLE pLocalHandle;
  3898. #ifdef API_TRACE
  3899. dprintf(TEXT("LLSRPC.DLL: LlsProductLicensesGetW\n"));
  3900. #endif
  3901. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  3902. {
  3903. return STATUS_NOT_SUPPORTED;
  3904. }
  3905. pLocalHandle = (PLOCAL_HANDLE) Handle;
  3906. if (pLocalHandle == NULL)
  3907. return STATUS_INVALID_PARAMETER;
  3908. try {
  3909. Status = LlsrProductLicensesGetW( pLocalHandle->Handle, Product, Mode, pQuantity );
  3910. }
  3911. except (TRUE) {
  3912. Status = I_RpcMapWin32Status(RpcExceptionCode());
  3913. #if DBG
  3914. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  3915. #endif
  3916. }
  3917. return Status;
  3918. } // LlsProductLicensesGetW
  3919. /////////////////////////////////////////////////////////////////////////
  3920. NTSTATUS
  3921. NTAPI
  3922. LlsProductLicensesGetA(
  3923. LLS_HANDLE Handle,
  3924. LPSTR Product,
  3925. DWORD Mode,
  3926. LPDWORD pQuantity )
  3927. /*++
  3928. Routine Description:
  3929. Returns the number of licenses installed on the target machine for
  3930. use in the given mode.
  3931. NOTE: Not yet implemented. Use LlsProductLicensesGetW().
  3932. Arguments:
  3933. Handle (LLS_HANDLE)
  3934. An open LLS handle to the target license server.
  3935. Product (LPSTR)
  3936. The name of the product for which to tally licenses.
  3937. Mode (DWORD)
  3938. Licensing mode for which to tally the licenses.
  3939. pQuantity (LPDWORD)
  3940. On return (and if successful), holds the total number of licenses
  3941. for use by the given product in the given license mode.
  3942. Return Value:
  3943. STATUS_NOT_SUPPORTED.
  3944. --*/
  3945. {
  3946. #ifdef API_TRACE
  3947. dprintf(TEXT("LLSRPC.DLL: LlsProductLicensesGetA\n"));
  3948. #endif
  3949. UNREFERENCED_PARAMETER(Handle);
  3950. UNREFERENCED_PARAMETER(Product);
  3951. UNREFERENCED_PARAMETER(Mode);
  3952. UNREFERENCED_PARAMETER(pQuantity);
  3953. return STATUS_NOT_SUPPORTED;
  3954. } // LlsProductLicensesGetA
  3955. #ifdef OBSOLETE
  3956. /////////////////////////////////////////////////////////////////////////
  3957. NTSTATUS
  3958. NTAPI
  3959. LlsCertificateClaimEnumW(
  3960. LLS_HANDLE Handle,
  3961. DWORD LicenseLevel,
  3962. LPBYTE pLicenseInfo,
  3963. DWORD TargetLevel,
  3964. LPBYTE * ppTargets,
  3965. LPDWORD pNumTargets )
  3966. /*++
  3967. Routine Description:
  3968. Enumerates the servers on which a given secure certificate is installed.
  3969. This function is normally invoked when an attempt to add licenses from
  3970. a certificate is denied.
  3971. Arguments:
  3972. Handle (LLS_HANDLE)
  3973. An open LLS handle to the target license server.
  3974. LicenseLevel (DWORD)
  3975. The level of the license structure pointed to by pLicenseInfo.
  3976. pLicenseInfo (LPBYTE)
  3977. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  3978. This license structure describes a license for which the certificate
  3979. targets are requested.
  3980. TargetLevel (DWORD)
  3981. The level of the target structure desired.
  3982. ppTargets (LPBYTE *)
  3983. On return (and if successful), holds a PLLS_EX_CERTIFICATE_CLAIM_X,
  3984. where X is TargetLevel. This array of structures describes the
  3985. location of all installations of licenses from the given certificate.
  3986. pNumTargets (LPDWORD)
  3987. On return (and if successful), holds the number of structures pointed
  3988. to by ppTargets.
  3989. Return Value:
  3990. STATUS_SUCCESS or NTSTATUS error code.
  3991. --*/
  3992. {
  3993. NTSTATUS Status;
  3994. GENERIC_INFO_CONTAINER GenericInfoContainer;
  3995. GENERIC_ENUM_STRUCT InfoStruct;
  3996. PLOCAL_HANDLE pLocalHandle;
  3997. #ifdef API_TRACE
  3998. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimEnumW\n"));
  3999. #endif
  4000. //init
  4001. *ppTargets = NULL;
  4002. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  4003. {
  4004. return STATUS_NOT_SUPPORTED;
  4005. }
  4006. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4007. if (pLocalHandle == NULL)
  4008. return STATUS_INVALID_PARAMETER;
  4009. GenericInfoContainer.Buffer = NULL;
  4010. GenericInfoContainer.EntriesRead = 0;
  4011. InfoStruct.Container = &GenericInfoContainer;
  4012. InfoStruct.Level = TargetLevel;
  4013. try
  4014. {
  4015. Status = LlsrCertificateClaimEnumW(
  4016. pLocalHandle->Handle,
  4017. LicenseLevel,
  4018. (LPVOID) pLicenseInfo,
  4019. (PLLS_CERTIFICATE_CLAIM_ENUM_STRUCTW) &InfoStruct );
  4020. }
  4021. except (TRUE)
  4022. {
  4023. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4024. #if DBG
  4025. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4026. #endif
  4027. }
  4028. if (Status == STATUS_SUCCESS)
  4029. {
  4030. if (NULL != GenericInfoContainer.Buffer)
  4031. {
  4032. *ppTargets = (LPBYTE) GenericInfoContainer.Buffer;
  4033. *pNumTargets = GenericInfoContainer.EntriesRead;
  4034. }
  4035. else
  4036. {
  4037. Status = ERROR_INVALID_DATA;
  4038. }
  4039. }
  4040. return Status;
  4041. } // LlsCertificateClaimEnumW
  4042. /////////////////////////////////////////////////////////////////////////
  4043. NTSTATUS
  4044. NTAPI
  4045. LlsCertificateClaimEnumA(
  4046. LLS_HANDLE Handle,
  4047. DWORD LicenseLevel,
  4048. LPBYTE pLicenseInfo,
  4049. DWORD TargetLevel,
  4050. LPBYTE * ppTargets,
  4051. LPDWORD pNumTargets )
  4052. /*++
  4053. Routine Description:
  4054. Enumerates the servers on which a given secure certificate is installed.
  4055. This function is normally invoked when an attempt to add licenses from
  4056. a certificate is denied.
  4057. NOTE: Not yet implemented. Use LlsCertificateClaimEnumW().
  4058. Arguments:
  4059. Handle (LLS_HANDLE)
  4060. An open LLS handle to the target license server.
  4061. LicenseLevel (DWORD)
  4062. The level of the license structure pointed to by pLicenseInfo.
  4063. pLicenseInfo (LPBYTE)
  4064. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  4065. This license structure describes a license for which the certificate
  4066. targets are requested.
  4067. TargetLevel (DWORD)
  4068. The level of the target structure desired.
  4069. ppTargets (LPBYTE *)
  4070. On return (and if successful), holds a PLLS_EX_CERTIFICATE_CLAIM_X,
  4071. where X is TargetLevel. This array of structures describes the
  4072. location of all installations of licenses from the given certificate.
  4073. pNumTargets (LPDWORD)
  4074. On return (and if successful), holds the number of structures pointed
  4075. to by ppTargets.
  4076. Return Value:
  4077. STATUS_NOT_SUPPORTED.
  4078. --*/
  4079. {
  4080. #ifdef API_TRACE
  4081. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimEnumA\n"));
  4082. #endif
  4083. UNREFERENCED_PARAMETER(Handle);
  4084. UNREFERENCED_PARAMETER(LicenseLevel);
  4085. UNREFERENCED_PARAMETER(pLicenseInfo);
  4086. UNREFERENCED_PARAMETER(TargetLevel);
  4087. UNREFERENCED_PARAMETER(ppTargets);
  4088. UNREFERENCED_PARAMETER(pNumTargets);
  4089. return STATUS_NOT_SUPPORTED;
  4090. } // LlsCertificateClaimEnumA
  4091. #endif // OBSOLETE
  4092. /////////////////////////////////////////////////////////////////////////
  4093. NTSTATUS
  4094. NTAPI
  4095. LlsCertificateClaimAddCheckW(
  4096. LLS_HANDLE Handle,
  4097. DWORD LicenseLevel,
  4098. LPBYTE pLicenseInfo,
  4099. LPBOOL pbMayInstall )
  4100. /*++
  4101. Routine Description:
  4102. Verify that no more licenses from a given certificate are installed in
  4103. a licensing enterprise than are allowed by the certificate.
  4104. Arguments:
  4105. Handle (LLS_HANDLE)
  4106. An open LLS handle to the target license server.
  4107. LicenseLevel (DWORD)
  4108. The level of the license structure pointed to by pLicenseInfo.
  4109. pLicenseInfo (LPBYTE)
  4110. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  4111. This license structure describes the license wished to add.
  4112. pbMayInstall (LPBOOL)
  4113. On return (and if successful), indicates whether the certificate
  4114. may be legally installed.
  4115. Return Value:
  4116. STATUS_SUCCESS or NTSTATUS error code.
  4117. --*/
  4118. {
  4119. NTSTATUS Status;
  4120. PLOCAL_HANDLE pLocalHandle;
  4121. #ifdef API_TRACE
  4122. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimAddCheckW\n"));
  4123. #endif
  4124. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  4125. {
  4126. return STATUS_NOT_SUPPORTED;
  4127. }
  4128. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4129. if (pLocalHandle == NULL)
  4130. return STATUS_INVALID_PARAMETER;
  4131. try {
  4132. Status = LlsrCertificateClaimAddCheckW( pLocalHandle->Handle, LicenseLevel, (LPVOID) pLicenseInfo, pbMayInstall );
  4133. }
  4134. except (TRUE) {
  4135. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4136. #if DBG
  4137. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4138. #endif
  4139. }
  4140. return Status;
  4141. } // LlsCertificateClaimAddCheckW
  4142. /////////////////////////////////////////////////////////////////////////
  4143. NTSTATUS
  4144. NTAPI
  4145. LlsCertificateClaimAddCheckA(
  4146. IN LLS_HANDLE Handle,
  4147. IN DWORD LicenseLevel,
  4148. IN LPBYTE pLicenseInfo,
  4149. OUT LPBOOL pbMayInstall )
  4150. /*++
  4151. Routine Description:
  4152. Verify that no more licenses from a given certificate are installed in
  4153. a licensing enterprise than are allowed by the certificate.
  4154. NOTE: Not yet implemented. Use LlsCertificateClaimAddCheckW().
  4155. Arguments:
  4156. Handle (LLS_HANDLE)
  4157. An open LLS handle to the target license server.
  4158. LicenseLevel (DWORD)
  4159. The level of the license structure pointed to by pLicenseInfo.
  4160. pLicenseInfo (LPBYTE)
  4161. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  4162. This license structure describes the license wished to add.
  4163. pbMayInstall (LPBOOL)
  4164. On return (and if successful), indicates whether the certificate
  4165. may be legally installed.
  4166. Return Value:
  4167. STATUS_NOT_SUPPORTED.
  4168. --*/
  4169. {
  4170. #ifdef API_TRACE
  4171. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimAddCheckA\n"));
  4172. #endif
  4173. UNREFERENCED_PARAMETER(Handle);
  4174. UNREFERENCED_PARAMETER(LicenseLevel);
  4175. UNREFERENCED_PARAMETER(pLicenseInfo);
  4176. UNREFERENCED_PARAMETER(pbMayInstall);
  4177. return STATUS_NOT_SUPPORTED;
  4178. } // LlsCertificateClaimAddCheckA
  4179. /////////////////////////////////////////////////////////////////////////
  4180. NTSTATUS
  4181. NTAPI
  4182. LlsCertificateClaimAddW(
  4183. LLS_HANDLE Handle,
  4184. LPWSTR ServerName,
  4185. DWORD LicenseLevel,
  4186. LPBYTE pLicenseInfo )
  4187. /*++
  4188. Routine Description:
  4189. Declare a number of licenses from a given certificate as being installed
  4190. on the target machine.
  4191. Arguments:
  4192. Handle (LLS_HANDLE)
  4193. An open LLS handle to the target license server.
  4194. ServerName (LPWSTR)
  4195. Name of the server on which the licenses are installed.
  4196. LicenseLevel (DWORD)
  4197. The level of the license structure pointed to by pLicenseInfo.
  4198. pLicenseInfo (LPBYTE)
  4199. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  4200. This license structure describes the license added.
  4201. Return Value:
  4202. STATUS_SUCCESS or NTSTATUS error code.
  4203. --*/
  4204. {
  4205. NTSTATUS Status;
  4206. PLOCAL_HANDLE pLocalHandle;
  4207. #ifdef API_TRACE
  4208. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimAddW\n"));
  4209. #endif
  4210. if ( !LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  4211. {
  4212. return STATUS_NOT_SUPPORTED;
  4213. }
  4214. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4215. if (pLocalHandle == NULL)
  4216. return STATUS_INVALID_PARAMETER;
  4217. try {
  4218. Status = LlsrCertificateClaimAddW( pLocalHandle->Handle, ServerName, LicenseLevel, (LPVOID) pLicenseInfo );
  4219. }
  4220. except (TRUE) {
  4221. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4222. #if DBG
  4223. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4224. #endif
  4225. }
  4226. return Status;
  4227. } // LlsCertificateClaimAddW
  4228. /////////////////////////////////////////////////////////////////////////
  4229. NTSTATUS
  4230. NTAPI
  4231. LlsCertificateClaimAddA(
  4232. LLS_HANDLE Handle,
  4233. LPSTR ServerName,
  4234. DWORD LicenseLevel,
  4235. LPBYTE pLicenseInfo )
  4236. /*++
  4237. Routine Description:
  4238. Declare a number of licenses from a given certificate as being installed
  4239. on the target machine.
  4240. NOTE: Not yet implemented. Use LlsCertificateClaimAddW().
  4241. Arguments:
  4242. Handle (LLS_HANDLE)
  4243. An open LLS handle to the target license server.
  4244. ServerName (LPWSTR)
  4245. Name of the server on which the licenses are installed.
  4246. LicenseLevel (DWORD)
  4247. The level of the license structure pointed to by pLicenseInfo.
  4248. pLicenseInfo (LPBYTE)
  4249. Points to a LLS_LICENSE_INFO_X structure, where X is LicenseLevel.
  4250. This license structure describes the license added.
  4251. Return Value:
  4252. STATUS_NOT_SUPPORTED.
  4253. --*/
  4254. {
  4255. #ifdef API_TRACE
  4256. dprintf(TEXT("LLSRPC.DLL: LlsCertificateClaimAddA\n"));
  4257. #endif
  4258. UNREFERENCED_PARAMETER(Handle);
  4259. UNREFERENCED_PARAMETER(ServerName);
  4260. UNREFERENCED_PARAMETER(LicenseLevel);
  4261. UNREFERENCED_PARAMETER(pLicenseInfo);
  4262. return STATUS_NOT_SUPPORTED;
  4263. } // LlsCertificateClaimAddA
  4264. /////////////////////////////////////////////////////////////////////////
  4265. NTSTATUS
  4266. NTAPI
  4267. LlsReplicationCertDbAddW(
  4268. LLS_REPL_HANDLE Handle,
  4269. DWORD Level,
  4270. LPVOID Certificates )
  4271. /*++
  4272. Routine Description:
  4273. Called as an optional part of replication, this function replicates
  4274. the contents of the remote certificate database.
  4275. Arguments:
  4276. Handle (LLS_REPL_HANDLE)
  4277. An open replication handle to the target server.
  4278. Level (DWORD)
  4279. Level of replication information sent.
  4280. Certificates (LPVOID)
  4281. Replicated certificate information.
  4282. Return Value:
  4283. STATUS_SUCCESS or NTSTATUS error code.
  4284. --*/
  4285. {
  4286. NTSTATUS Status;
  4287. #ifdef API_TRACE
  4288. dprintf(TEXT("LLSRPC.DLL: LlsReplicationCertDbAddW\n"));
  4289. #endif
  4290. try {
  4291. Status = LlsrReplicationCertDbAddW( Handle, Level, Certificates );
  4292. }
  4293. except (TRUE) {
  4294. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4295. #if DBG
  4296. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4297. #endif
  4298. }
  4299. return Status;
  4300. } // LlsReplicationCertDbAddW
  4301. /////////////////////////////////////////////////////////////////////////
  4302. NTSTATUS
  4303. NTAPI
  4304. LlsReplicationProductSecurityAddW(
  4305. LLS_REPL_HANDLE Handle,
  4306. DWORD Level,
  4307. LPVOID SecureProducts )
  4308. /*++
  4309. Routine Description:
  4310. Called as an optional part of replication, this function replicates
  4311. the list of products which require secure certificates.
  4312. Arguments:
  4313. Handle (LLS_REPL_HANDLE)
  4314. An open replication handle to the target server.
  4315. Level (DWORD)
  4316. Level of the product security information.
  4317. SecureProducts (LPVOID)
  4318. Replicated secure product information.
  4319. Return Value:
  4320. STATUS_SUCCESS or NTSTATUS error code.
  4321. --*/
  4322. {
  4323. NTSTATUS Status;
  4324. #ifdef API_TRACE
  4325. dprintf(TEXT("LLSRPC.DLL: LlsReplicationProductSecurityAddW\n"));
  4326. #endif
  4327. try {
  4328. Status = LlsrReplicationProductSecurityAddW( Handle, Level, SecureProducts );
  4329. }
  4330. except (TRUE) {
  4331. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4332. #if DBG
  4333. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4334. #endif
  4335. }
  4336. return Status;
  4337. } // LlsReplicationProductSecurityAddW
  4338. /////////////////////////////////////////////////////////////////////////
  4339. NTSTATUS
  4340. NTAPI
  4341. LlsReplicationUserAddExW(
  4342. LLS_REPL_HANDLE Handle,
  4343. DWORD Level,
  4344. LPVOID Users )
  4345. /*++
  4346. Routine Description:
  4347. Replacement for LlsReplicationUserAddW(). (This function, unlike its
  4348. counterpart, supports structure levels.) This function replicates
  4349. the user list.
  4350. Arguments:
  4351. Handle (LLS_REPL_HANDLE)
  4352. An open replication handle to the target server.
  4353. Level (DWORD)
  4354. Level of the user information.
  4355. Users (LPVOID)
  4356. Replicated user information.
  4357. Return Value:
  4358. STATUS_SUCCESS or NTSTATUS error code.
  4359. --*/
  4360. {
  4361. NTSTATUS Status;
  4362. #ifdef API_TRACE
  4363. dprintf(TEXT("LLSRPC.DLL: LlsReplicationUserAddExW\n"));
  4364. #endif
  4365. if ( (0 != Level) && (1 != Level) )
  4366. return STATUS_INVALID_LEVEL;
  4367. try {
  4368. Status = LlsrReplicationUserAddExW( Handle, Level, Users );
  4369. }
  4370. except (TRUE) {
  4371. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4372. #if DBG
  4373. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4374. #endif
  4375. }
  4376. return Status;
  4377. } // LlsReplicationUserAddExW
  4378. /////////////////////////////////////////////////////////////////////////
  4379. BOOL
  4380. NTAPI
  4381. LlsCapabilityIsSupported(
  4382. LLS_HANDLE Handle,
  4383. DWORD Capability )
  4384. /*++
  4385. Routine Description:
  4386. Determine whether the target license server supports an arbitrary
  4387. function.
  4388. Arguments:
  4389. Handle (LLS_HANDLE)
  4390. An open LLS handle to the target license server.
  4391. Capability (DWORD)
  4392. The capability number to check for, 0 <= Capability < LLS_CAPABILITY_MAX.
  4393. Return Value:
  4394. TRUE (supports the capability) or FALSE (does not).
  4395. --*/
  4396. {
  4397. BOOL bIsSupported = FALSE;
  4398. PLOCAL_HANDLE pLocalHandle;
  4399. DWORD dwCapByte;
  4400. DWORD dwCapBit;
  4401. #ifdef API_TRACE
  4402. dprintf(TEXT("LLSRPC.DLL: LlsCapabilityIsSupported\n"));
  4403. #endif
  4404. if ( ( NULL != Handle ) && ( Capability < LLS_CAPABILITY_MAX ) )
  4405. {
  4406. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4407. dwCapByte = Capability / 8;
  4408. dwCapBit = Capability - 8 * dwCapByte;
  4409. if ( 1 & ( pLocalHandle->Capabilities[ dwCapByte ] >> dwCapBit ) )
  4410. {
  4411. bIsSupported = TRUE;
  4412. }
  4413. }
  4414. return bIsSupported;
  4415. } // LlsCapabilityIsSupported
  4416. NTSTATUS
  4417. NTAPI
  4418. LlsLocalServiceEnumW(
  4419. LLS_HANDLE Handle,
  4420. DWORD Level,
  4421. LPBYTE* bufptr,
  4422. DWORD PrefMaxLen,
  4423. LPDWORD EntriesRead,
  4424. LPDWORD TotalEntries,
  4425. LPDWORD ResumeHandle )
  4426. {
  4427. NTSTATUS Status;
  4428. PLOCAL_HANDLE pLocalHandle;
  4429. HRESULT hr;
  4430. #ifdef API_TRACE
  4431. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceEnumW\n"));
  4432. #endif
  4433. //init
  4434. *bufptr = NULL;
  4435. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4436. if (pLocalHandle == NULL)
  4437. {
  4438. Status = STATUS_INVALID_PARAMETER;
  4439. }
  4440. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4441. {
  4442. GENERIC_INFO_CONTAINER GenericInfoContainer;
  4443. GENERIC_ENUM_STRUCT InfoStruct;
  4444. GenericInfoContainer.Buffer = NULL;
  4445. GenericInfoContainer.EntriesRead = 0;
  4446. InfoStruct.Container = &GenericInfoContainer;
  4447. InfoStruct.Level = Level;
  4448. try
  4449. {
  4450. Status = LlsrLocalServiceEnumW(
  4451. pLocalHandle->Handle,
  4452. (PLLS_LOCAL_SERVICE_ENUM_STRUCTW) &InfoStruct,
  4453. PrefMaxLen,
  4454. TotalEntries,
  4455. ResumeHandle
  4456. );
  4457. }
  4458. except (TRUE)
  4459. {
  4460. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4461. #if DBG
  4462. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4463. #endif
  4464. }
  4465. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES))
  4466. {
  4467. if (NULL != GenericInfoContainer.Buffer)
  4468. {
  4469. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  4470. *EntriesRead = GenericInfoContainer.EntriesRead;
  4471. }
  4472. else
  4473. {
  4474. Status = ERROR_INVALID_DATA;
  4475. }
  4476. }
  4477. }
  4478. else if ( 0 != Level )
  4479. {
  4480. Status = STATUS_INVALID_LEVEL;
  4481. }
  4482. else
  4483. {
  4484. PLLS_LOCAL_SERVICE_INFO_0 pLocalServices = NULL;
  4485. DWORD cEntriesRead = 0;
  4486. LONG lError;
  4487. HKEY hKeyLocalMachine;
  4488. lError = RegConnectRegistry( pLocalHandle->szServerName, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  4489. if ( ERROR_SUCCESS == lError )
  4490. {
  4491. HKEY hKeyLicenseInfo;
  4492. lError = RegOpenKeyEx( hKeyLocalMachine, REG_KEY_LICENSE, 0, KEY_READ, &hKeyLicenseInfo );
  4493. if ( ERROR_SUCCESS == lError )
  4494. {
  4495. const DWORD cbBufferSize = 0x4000;
  4496. // fudge; we ignore MaxPrefLen and allocate a 16k buffer
  4497. // this is because when we restart an enumeration, we don't know how
  4498. // many items we have left (we could do it, but it'd be slow)
  4499. // this is only for 3.51 boxes, anyway, and this buffer will hold
  4500. // about 500 local service entries (plenty!)
  4501. // this also keeps us from having to keep the registry key open
  4502. // across function calls
  4503. pLocalServices = MIDL_user_allocate( cbBufferSize );
  4504. if ( NULL == pLocalServices )
  4505. {
  4506. lError = ERROR_OUTOFMEMORY;
  4507. }
  4508. else
  4509. {
  4510. DWORD iSubKey;
  4511. TCHAR szKeyName[ 128 ];
  4512. // read all the services installed on this machine
  4513. for ( iSubKey=0, cEntriesRead=0;
  4514. ( ERROR_SUCCESS == lError ) && ( ( cEntriesRead + 1 ) * sizeof( *pLocalServices ) < cbBufferSize );
  4515. iSubKey++ )
  4516. {
  4517. lError = RegEnumKey( hKeyLicenseInfo, iSubKey, szKeyName, sizeof( szKeyName ) / sizeof( *szKeyName ) );
  4518. if ( ERROR_SUCCESS == lError )
  4519. {
  4520. HKEY hKeyService;
  4521. lError = RegOpenKeyEx( hKeyLicenseInfo, szKeyName, 0, KEY_READ, &hKeyService );
  4522. if ( ERROR_SUCCESS == lError )
  4523. {
  4524. DWORD cbData;
  4525. cbData = sizeof( pLocalServices[ cEntriesRead ].Mode );
  4526. lError = RegQueryValueEx( hKeyService, REG_VALUE_MODE, NULL, NULL, (LPBYTE) &pLocalServices[ cEntriesRead ].Mode, &cbData );
  4527. if ( ERROR_SUCCESS == lError )
  4528. {
  4529. cbData = sizeof( pLocalServices[ cEntriesRead ].FlipAllow );
  4530. lError = RegQueryValueEx( hKeyService, REG_VALUE_FLIP, NULL, NULL, (LPBYTE) &pLocalServices[ cEntriesRead ].FlipAllow, &cbData );
  4531. if ( ERROR_SUCCESS == lError )
  4532. {
  4533. cbData = sizeof( pLocalServices[ cEntriesRead ].ConcurrentLimit );
  4534. lError = RegQueryValueEx( hKeyService, REG_VALUE_LIMIT, NULL, NULL, (LPBYTE) &pLocalServices[ cEntriesRead ].ConcurrentLimit, &cbData );
  4535. if ( ERROR_SUCCESS == lError )
  4536. {
  4537. DWORD cbKeyName;
  4538. DWORD cbDisplayName;
  4539. DWORD cbFamilyDisplayName;
  4540. cbData = sizeof( pLocalServices[ cEntriesRead ].HighMark );
  4541. lError = RegQueryValueEx( hKeyService, REG_VALUE_HIGHMARK, NULL, NULL, (LPBYTE) &pLocalServices[ cEntriesRead ].HighMark, &cbData );
  4542. if ( ERROR_SUCCESS != lError )
  4543. {
  4544. pLocalServices[ cEntriesRead ].HighMark = 0;
  4545. lError = ERROR_SUCCESS;
  4546. }
  4547. if ( ( ERROR_SUCCESS == RegQueryValueEx( hKeyService, REG_VALUE_NAME, NULL, NULL, NULL, &cbDisplayName ) )
  4548. && ( ERROR_SUCCESS == RegQueryValueEx( hKeyService, REG_VALUE_FAMILY, NULL, NULL, NULL, &cbFamilyDisplayName ) ) )
  4549. {
  4550. cbKeyName = sizeof( *szKeyName ) * ( 1 + lstrlen( szKeyName ) );
  4551. pLocalServices[ cEntriesRead ].KeyName = MIDL_user_allocate( cbKeyName );
  4552. if ( NULL == pLocalServices[ cEntriesRead ].KeyName )
  4553. {
  4554. lError = ERROR_OUTOFMEMORY;
  4555. }
  4556. else
  4557. {
  4558. hr = StringCbCopy( pLocalServices[ cEntriesRead ].KeyName, cbKeyName, szKeyName );
  4559. ASSERT(SUCCEEDED(hr));
  4560. pLocalServices[ cEntriesRead ].DisplayName = MIDL_user_allocate( cbDisplayName );
  4561. if ( NULL == pLocalServices[ cEntriesRead ].DisplayName )
  4562. {
  4563. lError = ERROR_OUTOFMEMORY;
  4564. }
  4565. else
  4566. {
  4567. lError = RegQueryValueEx( hKeyService, REG_VALUE_NAME, NULL, NULL, (LPBYTE) pLocalServices[ cEntriesRead ].DisplayName, &cbDisplayName );
  4568. if ( ERROR_SUCCESS == lError )
  4569. {
  4570. pLocalServices[ cEntriesRead ].FamilyDisplayName = MIDL_user_allocate( cbFamilyDisplayName );
  4571. if ( NULL == pLocalServices[ cEntriesRead ].FamilyDisplayName )
  4572. {
  4573. lError = ERROR_OUTOFMEMORY;
  4574. }
  4575. else
  4576. {
  4577. lError = RegQueryValueEx( hKeyService, REG_VALUE_FAMILY, NULL, NULL, (LPBYTE) pLocalServices[ cEntriesRead ].FamilyDisplayName, &cbFamilyDisplayName );
  4578. if ( ERROR_SUCCESS != lError )
  4579. {
  4580. MIDL_user_free( pLocalServices[ cEntriesRead ].FamilyDisplayName );
  4581. }
  4582. }
  4583. }
  4584. if ( ERROR_SUCCESS != lError )
  4585. {
  4586. MIDL_user_free( pLocalServices[ cEntriesRead ].DisplayName );
  4587. }
  4588. }
  4589. if ( ERROR_SUCCESS != lError )
  4590. {
  4591. MIDL_user_free( pLocalServices[ cEntriesRead ].KeyName );
  4592. }
  4593. else
  4594. {
  4595. // all data for this service was retrieved!
  4596. cEntriesRead++;
  4597. }
  4598. }
  4599. }
  4600. }
  4601. }
  4602. }
  4603. RegCloseKey( hKeyService );
  4604. }
  4605. if ( ERROR_OUTOFMEMORY != lError )
  4606. {
  4607. // continue enumeration...
  4608. lError = ERROR_SUCCESS;
  4609. }
  4610. }
  4611. }
  4612. }
  4613. RegCloseKey( hKeyLicenseInfo );
  4614. }
  4615. RegCloseKey( hKeyLocalMachine );
  4616. }
  4617. switch ( lError )
  4618. {
  4619. case ERROR_SUCCESS:
  4620. case ERROR_NO_MORE_ITEMS:
  4621. Status = STATUS_SUCCESS;
  4622. break;
  4623. case ERROR_ACCESS_DENIED:
  4624. Status = STATUS_ACCESS_DENIED;
  4625. break;
  4626. case ERROR_OUTOFMEMORY:
  4627. Status = STATUS_NO_MEMORY;
  4628. break;
  4629. case ERROR_FILE_NOT_FOUND:
  4630. case ERROR_PATH_NOT_FOUND:
  4631. Status = STATUS_NOT_FOUND;
  4632. break;
  4633. default:
  4634. Status = STATUS_UNSUCCESSFUL;
  4635. break;
  4636. }
  4637. if ( STATUS_SUCCESS != Status )
  4638. {
  4639. // free all of our allocations
  4640. DWORD i;
  4641. for ( i=0; i < cEntriesRead; i++ )
  4642. {
  4643. MIDL_user_free( pLocalServices[ i ].KeyName );
  4644. MIDL_user_free( pLocalServices[ i ].DisplayName );
  4645. MIDL_user_free( pLocalServices[ i ].FamilyDisplayName );
  4646. }
  4647. MIDL_user_free( pLocalServices );
  4648. }
  4649. else
  4650. {
  4651. // success! return the array of services.
  4652. *bufptr = (LPBYTE) pLocalServices;
  4653. *EntriesRead = cEntriesRead;
  4654. *TotalEntries = cEntriesRead;
  4655. *ResumeHandle = 0;
  4656. }
  4657. }
  4658. return Status;
  4659. }
  4660. NTSTATUS
  4661. NTAPI
  4662. LlsLocalServiceEnumA(
  4663. LLS_HANDLE Handle,
  4664. DWORD Level,
  4665. LPBYTE* bufptr,
  4666. DWORD PrefMaxLen,
  4667. LPDWORD EntriesRead,
  4668. LPDWORD TotalEntries,
  4669. LPDWORD ResumeHandle )
  4670. {
  4671. NTSTATUS Status;
  4672. PLOCAL_HANDLE pLocalHandle;
  4673. #ifdef API_TRACE
  4674. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceEnumA\n"));
  4675. #endif
  4676. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4677. if (pLocalHandle == NULL)
  4678. {
  4679. Status = STATUS_INVALID_PARAMETER;
  4680. }
  4681. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4682. {
  4683. GENERIC_INFO_CONTAINER GenericInfoContainer;
  4684. GENERIC_ENUM_STRUCT InfoStruct;
  4685. GenericInfoContainer.Buffer = NULL;
  4686. GenericInfoContainer.EntriesRead = 0;
  4687. InfoStruct.Container = &GenericInfoContainer;
  4688. InfoStruct.Level = Level;
  4689. try {
  4690. Status = LlsrLocalServiceEnumA(
  4691. pLocalHandle->Handle,
  4692. (PLLS_LOCAL_SERVICE_ENUM_STRUCTA) &InfoStruct,
  4693. PrefMaxLen,
  4694. TotalEntries,
  4695. ResumeHandle
  4696. );
  4697. }
  4698. except (TRUE) {
  4699. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4700. #if DBG
  4701. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4702. #endif
  4703. }
  4704. if ((Status == STATUS_SUCCESS) || (Status == STATUS_MORE_ENTRIES)) {
  4705. *bufptr = (LPBYTE) GenericInfoContainer.Buffer;
  4706. *EntriesRead = GenericInfoContainer.EntriesRead;
  4707. }
  4708. }
  4709. else
  4710. {
  4711. Status = STATUS_NOT_SUPPORTED;
  4712. }
  4713. return Status;
  4714. }
  4715. #ifdef OBSOLETE
  4716. NTSTATUS
  4717. NTAPI
  4718. LlsLocalServiceAddW(
  4719. LLS_HANDLE Handle,
  4720. DWORD Level,
  4721. LPBYTE bufptr )
  4722. {
  4723. NTSTATUS Status;
  4724. PLOCAL_HANDLE pLocalHandle;
  4725. #ifdef API_TRACE
  4726. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceAddW\n"));
  4727. #endif
  4728. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4729. if (pLocalHandle == NULL)
  4730. {
  4731. Status = STATUS_INVALID_PARAMETER;
  4732. }
  4733. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4734. {
  4735. try
  4736. {
  4737. Status = LlsrLocalServiceAddW( pLocalHandle->Handle, Level, (PLLS_LOCAL_SERVICE_INFOW) bufptr );
  4738. }
  4739. except (TRUE)
  4740. {
  4741. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4742. #if DBG
  4743. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4744. #endif
  4745. }
  4746. }
  4747. else if ( 0 != Level )
  4748. {
  4749. Status = STATUS_INVALID_LEVEL;
  4750. }
  4751. else if ( ( NULL == ((PLLS_LOCAL_SERVICE_INFO_0W) bufptr)->KeyName )
  4752. || ( NULL == ((PLLS_LOCAL_SERVICE_INFO_0W) bufptr)->DisplayName )
  4753. || ( NULL == ((PLLS_LOCAL_SERVICE_INFO_0W) bufptr)->FamilyDisplayName ) )
  4754. {
  4755. Status = STATUS_INVALID_PARAMETER;
  4756. }
  4757. else
  4758. {
  4759. PLLS_LOCAL_SERVICE_INFO_0W LocalServiceInfo;
  4760. LONG lError;
  4761. HKEY hKeyLocalMachine;
  4762. LocalServiceInfo = (PLLS_LOCAL_SERVICE_INFO_0W) bufptr;
  4763. lError = RegConnectRegistry( pLocalHandle->szServerName, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  4764. if ( ERROR_SUCCESS == lError )
  4765. {
  4766. HKEY hKeyLicenseInfo;
  4767. lError = RegOpenKeyEx( hKeyLocalMachine, TEXT( "System\\CurrentControlSet\\Services\\LicenseInfo" ), 0, KEY_WRITE, &hKeyLicenseInfo );
  4768. if ( ERROR_SUCCESS == lError )
  4769. {
  4770. HKEY hKeyService;
  4771. DWORD dwDisposition;
  4772. // create key
  4773. lError = RegCreateKeyEx( hKeyLicenseInfo, LocalServiceInfo->KeyName, 0, NULL, 0, KEY_WRITE, NULL, &hKeyService, &dwDisposition );
  4774. if ( ERROR_SUCCESS == lError )
  4775. {
  4776. // set DisplayName
  4777. lError = RegSetValueEx( hKeyService, TEXT( "DisplayName" ), 0, REG_SZ, (LPBYTE) LocalServiceInfo->DisplayName, sizeof( *LocalServiceInfo->DisplayName ) * ( 1 + lstrlen( LocalServiceInfo->DisplayName ) ) );
  4778. if ( ERROR_SUCCESS == lError )
  4779. {
  4780. // set FamilyDisplayName
  4781. lError = RegSetValueEx( hKeyService, TEXT( "FamilyDisplayName" ), 0, REG_SZ, (LPBYTE) LocalServiceInfo->FamilyDisplayName, sizeof( *LocalServiceInfo->FamilyDisplayName ) * ( 1 + lstrlen( LocalServiceInfo->FamilyDisplayName ) ) );
  4782. }
  4783. RegCloseKey( hKeyService );
  4784. }
  4785. RegCloseKey( hKeyLicenseInfo );
  4786. }
  4787. RegCloseKey( hKeyLocalMachine );
  4788. }
  4789. switch ( lError )
  4790. {
  4791. case ERROR_SUCCESS:
  4792. Status = STATUS_SUCCESS;
  4793. break;
  4794. case ERROR_FILE_NOT_FOUND:
  4795. case ERROR_PATH_NOT_FOUND:
  4796. Status = STATUS_OBJECT_NAME_NOT_FOUND;
  4797. break;
  4798. case ERROR_ACCESS_DENIED:
  4799. Status = STATUS_ACCESS_DENIED;
  4800. break;
  4801. default:
  4802. Status = STATUS_UNSUCCESSFUL;
  4803. break;
  4804. }
  4805. if ( STATUS_SUCCESS == Status )
  4806. {
  4807. // set remaining items
  4808. Status = LlsLocalServiceInfoSetW( Handle, LocalServiceInfo->KeyName, Level, bufptr );
  4809. }
  4810. }
  4811. return Status;
  4812. }
  4813. NTSTATUS
  4814. NTAPI
  4815. LlsLocalServiceAddA(
  4816. LLS_HANDLE Handle,
  4817. DWORD Level,
  4818. LPBYTE bufptr )
  4819. {
  4820. NTSTATUS Status;
  4821. PLOCAL_HANDLE pLocalHandle;
  4822. #ifdef API_TRACE
  4823. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceAddA\n"));
  4824. #endif
  4825. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4826. if (pLocalHandle == NULL)
  4827. {
  4828. Status = STATUS_INVALID_PARAMETER;
  4829. }
  4830. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4831. {
  4832. try {
  4833. Status = LlsrLocalServiceAddA( pLocalHandle->Handle, Level, (PLLS_LOCAL_SERVICE_INFOA) bufptr );
  4834. }
  4835. except (TRUE) {
  4836. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4837. #if DBG
  4838. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4839. #endif
  4840. }
  4841. }
  4842. else
  4843. {
  4844. Status = STATUS_NOT_SUPPORTED;
  4845. }
  4846. return Status;
  4847. }
  4848. #endif // OBSOLETE
  4849. NTSTATUS
  4850. NTAPI
  4851. LlsLocalServiceInfoSetW(
  4852. LLS_HANDLE Handle,
  4853. LPWSTR KeyName,
  4854. DWORD Level,
  4855. LPBYTE bufptr )
  4856. {
  4857. NTSTATUS Status;
  4858. PLOCAL_HANDLE pLocalHandle;
  4859. #ifdef API_TRACE
  4860. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceInfoSetW\n"));
  4861. #endif
  4862. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4863. if (pLocalHandle == NULL)
  4864. {
  4865. Status = STATUS_INVALID_PARAMETER;
  4866. }
  4867. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4868. {
  4869. try
  4870. {
  4871. Status = LlsrLocalServiceInfoSetW( pLocalHandle->Handle, KeyName, Level, (PLLS_LOCAL_SERVICE_INFOW) bufptr );
  4872. }
  4873. except (TRUE)
  4874. {
  4875. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4876. #if DBG
  4877. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4878. #endif
  4879. }
  4880. }
  4881. else if ( 0 != Level )
  4882. {
  4883. Status = STATUS_INVALID_LEVEL;
  4884. }
  4885. else if ( NULL == KeyName )
  4886. {
  4887. Status = STATUS_INVALID_PARAMETER;
  4888. }
  4889. else
  4890. {
  4891. LONG lError;
  4892. HKEY hKeyLocalMachine;
  4893. lError = RegConnectRegistry( pLocalHandle->szServerName, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  4894. if ( ERROR_SUCCESS == lError )
  4895. {
  4896. HKEY hKeyLicenseInfo;
  4897. lError = RegOpenKeyEx( hKeyLocalMachine, REG_KEY_LICENSE, 0, KEY_WRITE, &hKeyLicenseInfo );
  4898. if ( ERROR_SUCCESS == lError )
  4899. {
  4900. HKEY hKeyService;
  4901. PLLS_LOCAL_SERVICE_INFO_0W LocalServiceInfo;
  4902. LocalServiceInfo = (PLLS_LOCAL_SERVICE_INFO_0W) bufptr;
  4903. lError = RegOpenKeyEx( hKeyLicenseInfo, KeyName, 0, KEY_WRITE, &hKeyService );
  4904. if ( ERROR_SUCCESS == lError )
  4905. {
  4906. // set Mode
  4907. lError = RegSetValueEx( hKeyService, REG_VALUE_MODE, 0, REG_DWORD, (LPBYTE) &LocalServiceInfo->Mode, sizeof( LocalServiceInfo->Mode ) );
  4908. if ( ERROR_SUCCESS == lError )
  4909. {
  4910. // set FlipAllow
  4911. lError = RegSetValueEx( hKeyService, REG_VALUE_FLIP, 0, REG_DWORD, (LPBYTE) &LocalServiceInfo->FlipAllow, sizeof( LocalServiceInfo->FlipAllow ) );
  4912. if ( ERROR_SUCCESS == lError )
  4913. {
  4914. // set ConcurrentLimit
  4915. lError = RegSetValueEx( hKeyService, REG_VALUE_LIMIT, 0, REG_DWORD, (LPBYTE) &LocalServiceInfo->ConcurrentLimit, sizeof( LocalServiceInfo->ConcurrentLimit ) );
  4916. }
  4917. }
  4918. RegCloseKey( hKeyService );
  4919. }
  4920. RegCloseKey( hKeyLicenseInfo );
  4921. }
  4922. RegCloseKey( hKeyLocalMachine );
  4923. }
  4924. switch ( lError )
  4925. {
  4926. case ERROR_SUCCESS:
  4927. Status = STATUS_SUCCESS;
  4928. break;
  4929. case ERROR_FILE_NOT_FOUND:
  4930. case ERROR_PATH_NOT_FOUND:
  4931. Status = STATUS_OBJECT_NAME_NOT_FOUND;
  4932. break;
  4933. case ERROR_ACCESS_DENIED:
  4934. Status = STATUS_ACCESS_DENIED;
  4935. break;
  4936. default:
  4937. Status = STATUS_UNSUCCESSFUL;
  4938. break;
  4939. }
  4940. }
  4941. return Status;
  4942. }
  4943. NTSTATUS
  4944. NTAPI
  4945. LlsLocalServiceInfoSetA(
  4946. LLS_HANDLE Handle,
  4947. LPSTR KeyName,
  4948. DWORD Level,
  4949. LPBYTE bufptr )
  4950. {
  4951. NTSTATUS Status;
  4952. PLOCAL_HANDLE pLocalHandle;
  4953. #ifdef API_TRACE
  4954. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceInfoSetA\n"));
  4955. #endif
  4956. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4957. if (pLocalHandle == NULL)
  4958. {
  4959. Status = STATUS_INVALID_PARAMETER;
  4960. }
  4961. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4962. {
  4963. try {
  4964. Status = LlsrLocalServiceInfoSetA( pLocalHandle->Handle, KeyName, Level, (PLLS_LOCAL_SERVICE_INFOA) bufptr );
  4965. }
  4966. except (TRUE) {
  4967. Status = I_RpcMapWin32Status(RpcExceptionCode());
  4968. #if DBG
  4969. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  4970. #endif
  4971. }
  4972. }
  4973. else
  4974. {
  4975. Status = STATUS_NOT_SUPPORTED;
  4976. }
  4977. return Status;
  4978. }
  4979. NTSTATUS
  4980. NTAPI
  4981. LlsLocalServiceInfoGetW(
  4982. LLS_HANDLE Handle,
  4983. LPWSTR KeyName,
  4984. DWORD Level,
  4985. LPBYTE * pbufptr )
  4986. {
  4987. NTSTATUS Status;
  4988. PLOCAL_HANDLE pLocalHandle;
  4989. HRESULT hr;
  4990. #ifdef API_TRACE
  4991. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceInfoGetW\n"));
  4992. #endif
  4993. pLocalHandle = (PLOCAL_HANDLE) Handle;
  4994. if (pLocalHandle == NULL)
  4995. {
  4996. Status = STATUS_INVALID_PARAMETER;
  4997. }
  4998. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  4999. {
  5000. try
  5001. {
  5002. Status = LlsrLocalServiceInfoGetW( pLocalHandle->Handle, KeyName, Level, (PLLS_LOCAL_SERVICE_INFOW *) pbufptr );
  5003. }
  5004. except (TRUE)
  5005. {
  5006. Status = I_RpcMapWin32Status(RpcExceptionCode());
  5007. #if DBG
  5008. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  5009. #endif
  5010. }
  5011. if (STATUS_SUCCESS == Status && NULL == *pbufptr)
  5012. {
  5013. Status = ERROR_INVALID_DATA;
  5014. }
  5015. }
  5016. else if ( 0 != Level )
  5017. {
  5018. Status = STATUS_INVALID_LEVEL;
  5019. }
  5020. else if ( NULL == KeyName )
  5021. {
  5022. Status = STATUS_INVALID_PARAMETER;
  5023. }
  5024. else
  5025. {
  5026. PLLS_LOCAL_SERVICE_INFO_0W pLocalService = NULL;
  5027. LONG lError;
  5028. HKEY hKeyLocalMachine;
  5029. lError = RegConnectRegistry( pLocalHandle->szServerName, HKEY_LOCAL_MACHINE, &hKeyLocalMachine );
  5030. if ( ERROR_SUCCESS == lError )
  5031. {
  5032. HKEY hKeyLicenseInfo;
  5033. lError = RegOpenKeyEx( hKeyLocalMachine, REG_KEY_LICENSE, 0, KEY_READ, &hKeyLicenseInfo );
  5034. if ( ERROR_SUCCESS == lError )
  5035. {
  5036. HKEY hKeyService;
  5037. lError = RegOpenKeyEx( hKeyLicenseInfo, KeyName, 0, KEY_READ, &hKeyService );
  5038. if ( ERROR_SUCCESS == lError )
  5039. {
  5040. pLocalService = MIDL_user_allocate( sizeof( *pLocalService ) );
  5041. if ( NULL == pLocalService )
  5042. {
  5043. lError = ERROR_OUTOFMEMORY;
  5044. }
  5045. else
  5046. {
  5047. DWORD cbData;
  5048. cbData = sizeof( pLocalService->Mode );
  5049. lError = RegQueryValueEx( hKeyService, REG_VALUE_MODE, NULL, NULL, (LPBYTE) &pLocalService->Mode, &cbData );
  5050. if ( ERROR_SUCCESS == lError )
  5051. {
  5052. cbData = sizeof( pLocalService->FlipAllow );
  5053. lError = RegQueryValueEx( hKeyService, REG_VALUE_FLIP, NULL, NULL, (LPBYTE) &pLocalService->FlipAllow, &cbData );
  5054. if ( ERROR_SUCCESS == lError )
  5055. {
  5056. cbData = sizeof( pLocalService->ConcurrentLimit );
  5057. lError = RegQueryValueEx( hKeyService, REG_VALUE_LIMIT, NULL, NULL, (LPBYTE) &pLocalService->ConcurrentLimit, &cbData );
  5058. if ( ERROR_SUCCESS == lError )
  5059. {
  5060. DWORD cbKeyName;
  5061. DWORD cbDisplayName;
  5062. DWORD cbFamilyDisplayName;
  5063. cbData = sizeof( pLocalService->HighMark );
  5064. lError = RegQueryValueEx( hKeyService, REG_VALUE_HIGHMARK, NULL, NULL, (LPBYTE) &pLocalService->HighMark, &cbData );
  5065. if ( ERROR_SUCCESS != lError )
  5066. {
  5067. pLocalService->HighMark = 0;
  5068. lError = ERROR_SUCCESS;
  5069. }
  5070. if ( ( ERROR_SUCCESS == RegQueryValueEx( hKeyService, REG_VALUE_NAME, NULL, NULL, NULL, &cbDisplayName ) )
  5071. && ( ERROR_SUCCESS == RegQueryValueEx( hKeyService, REG_VALUE_FAMILY, NULL, NULL, NULL, &cbFamilyDisplayName ) ) )
  5072. {
  5073. cbKeyName = sizeof( *KeyName ) * ( 1 + lstrlen( KeyName ) );
  5074. pLocalService->KeyName = MIDL_user_allocate( cbKeyName );
  5075. if ( NULL == pLocalService->KeyName )
  5076. {
  5077. lError = ERROR_OUTOFMEMORY;
  5078. }
  5079. else
  5080. {
  5081. hr = StringCbCopy( pLocalService->KeyName, cbKeyName, KeyName );
  5082. ASSERT(SUCCEEDED(hr));
  5083. pLocalService->DisplayName = MIDL_user_allocate( cbDisplayName );
  5084. if ( NULL == pLocalService->DisplayName )
  5085. {
  5086. lError = ERROR_OUTOFMEMORY;
  5087. }
  5088. else
  5089. {
  5090. lError = RegQueryValueEx( hKeyService, REG_VALUE_NAME, NULL, NULL, (LPBYTE) pLocalService->DisplayName, &cbDisplayName );
  5091. if ( ERROR_SUCCESS == lError )
  5092. {
  5093. pLocalService->FamilyDisplayName = MIDL_user_allocate( cbFamilyDisplayName );
  5094. if ( NULL == pLocalService->FamilyDisplayName )
  5095. {
  5096. lError = ERROR_OUTOFMEMORY;
  5097. }
  5098. else
  5099. {
  5100. lError = RegQueryValueEx( hKeyService, REG_VALUE_FAMILY, NULL, NULL, (LPBYTE) pLocalService->FamilyDisplayName, &cbFamilyDisplayName );
  5101. if ( ERROR_SUCCESS != lError )
  5102. {
  5103. MIDL_user_free( pLocalService->FamilyDisplayName );
  5104. }
  5105. }
  5106. }
  5107. if ( ERROR_SUCCESS != lError )
  5108. {
  5109. MIDL_user_free( pLocalService->DisplayName );
  5110. }
  5111. }
  5112. if ( ERROR_SUCCESS != lError )
  5113. {
  5114. MIDL_user_free( pLocalService->KeyName );
  5115. }
  5116. }
  5117. }
  5118. }
  5119. }
  5120. }
  5121. if ( ERROR_SUCCESS != lError )
  5122. {
  5123. MIDL_user_free( pLocalService );
  5124. }
  5125. }
  5126. RegCloseKey( hKeyService );
  5127. }
  5128. RegCloseKey( hKeyLicenseInfo );
  5129. }
  5130. RegCloseKey( hKeyLocalMachine );
  5131. }
  5132. switch ( lError )
  5133. {
  5134. case ERROR_SUCCESS:
  5135. Status = STATUS_SUCCESS;
  5136. break;
  5137. case ERROR_FILE_NOT_FOUND:
  5138. case ERROR_PATH_NOT_FOUND:
  5139. Status = STATUS_OBJECT_NAME_NOT_FOUND;
  5140. break;
  5141. case ERROR_ACCESS_DENIED:
  5142. Status = STATUS_ACCESS_DENIED;
  5143. break;
  5144. default:
  5145. Status = STATUS_UNSUCCESSFUL;
  5146. break;
  5147. }
  5148. if ( STATUS_SUCCESS == Status )
  5149. {
  5150. *pbufptr = (LPBYTE) pLocalService;
  5151. }
  5152. }
  5153. return Status;
  5154. }
  5155. NTSTATUS
  5156. NTAPI
  5157. LlsLocalServiceInfoGetA(
  5158. LLS_HANDLE Handle,
  5159. DWORD Level,
  5160. LPSTR KeyName,
  5161. LPBYTE * pbufptr )
  5162. {
  5163. NTSTATUS Status;
  5164. PLOCAL_HANDLE pLocalHandle;
  5165. #ifdef API_TRACE
  5166. dprintf(TEXT("LLSRPC.DLL: LlsLocalServiceInfoGetA\n"));
  5167. #endif
  5168. pLocalHandle = (PLOCAL_HANDLE) Handle;
  5169. if (pLocalHandle == NULL)
  5170. {
  5171. Status = STATUS_INVALID_PARAMETER;
  5172. }
  5173. else if ( LlsCapabilityIsSupported( Handle, LLS_CAPABILITY_LOCAL_SERVICE_API ) )
  5174. {
  5175. try {
  5176. Status = LlsrLocalServiceInfoGetA( pLocalHandle->Handle, KeyName, Level, (PLLS_LOCAL_SERVICE_INFOA *) pbufptr );
  5177. }
  5178. except (TRUE) {
  5179. Status = I_RpcMapWin32Status(RpcExceptionCode());
  5180. #if DBG
  5181. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  5182. #endif
  5183. }
  5184. }
  5185. else
  5186. {
  5187. Status = STATUS_NOT_SUPPORTED;
  5188. }
  5189. return Status;
  5190. }
  5191. NTSTATUS
  5192. NTAPI
  5193. LlsLicenseRequest2W(
  5194. LLS_HANDLE Handle,
  5195. LPWSTR Product,
  5196. ULONG VersionIndex,
  5197. BOOLEAN IsAdmin,
  5198. ULONG DataType,
  5199. ULONG DataSize,
  5200. PBYTE Data,
  5201. PHANDLE pLicenseHandle )
  5202. {
  5203. NTSTATUS Status;
  5204. PLOCAL_HANDLE pLocalHandle;
  5205. LICENSE_HANDLE RpcLicenseHandle = NULL;
  5206. #ifdef API_TRACE
  5207. dprintf(TEXT("LLSRPC.DLL: LlsLicenseRequestW\n"));
  5208. #endif
  5209. pLocalHandle = (PLOCAL_HANDLE) Handle;
  5210. if ((pLocalHandle == NULL) || (pLicenseHandle == NULL))
  5211. {
  5212. Status = STATUS_INVALID_PARAMETER;
  5213. }
  5214. else
  5215. {
  5216. try {
  5217. RtlEnterCriticalSection( &g_RpcHandleLock );
  5218. lsapirpc_handle = pLocalHandle->llsrpc_handle;
  5219. Status = LlsrLicenseRequestW( &RpcLicenseHandle,
  5220. Product,
  5221. VersionIndex,
  5222. IsAdmin,
  5223. DataType,
  5224. DataSize,
  5225. Data );
  5226. RtlLeaveCriticalSection( &g_RpcHandleLock );
  5227. }
  5228. except (TRUE) {
  5229. Status = I_RpcMapWin32Status(RpcExceptionCode());
  5230. #if DBG
  5231. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  5232. #endif
  5233. }
  5234. // should we check Status before do the assignment below?
  5235. *pLicenseHandle = RpcLicenseHandle;
  5236. }
  5237. return Status;
  5238. }
  5239. NTSTATUS
  5240. NTAPI
  5241. LlsLicenseRequestW(
  5242. LLS_HANDLE Handle,
  5243. LPWSTR Product,
  5244. ULONG VersionIndex,
  5245. BOOLEAN IsAdmin,
  5246. ULONG DataType,
  5247. ULONG DataSize,
  5248. PBYTE Data,
  5249. LPDWORD pLicenseHandle )
  5250. {
  5251. HANDLE RealLicenseHandle = (HANDLE)(-1);
  5252. NTSTATUS status;
  5253. #pragma warning (push)
  5254. #pragma warning (disable : 4127) //conditional expression is constant
  5255. if (sizeof(ULONG) == sizeof(HANDLE))
  5256. #pragma warning (pop)
  5257. {
  5258. // Should still work on Win32
  5259. status = LlsLicenseRequest2W(Handle,Product,VersionIndex,IsAdmin,DataType,DataSize,Data,&RealLicenseHandle);
  5260. if (NULL != pLicenseHandle)
  5261. *pLicenseHandle = PtrToUlong(RealLicenseHandle);
  5262. }
  5263. else
  5264. {
  5265. status = STATUS_NOT_IMPLEMENTED;
  5266. if (NULL != pLicenseHandle)
  5267. *pLicenseHandle = (ULONG) 0xFFFFFFFF;
  5268. }
  5269. return status;
  5270. }
  5271. NTSTATUS
  5272. NTAPI
  5273. LlsLicenseRequest2A(
  5274. LLS_HANDLE Handle,
  5275. LPSTR Product,
  5276. ULONG VersionIndex,
  5277. BOOLEAN IsAdmin,
  5278. ULONG DataType,
  5279. ULONG DataSize,
  5280. PBYTE Data,
  5281. PHANDLE pLicenseHandle )
  5282. {
  5283. UNREFERENCED_PARAMETER(Handle);
  5284. UNREFERENCED_PARAMETER(Product);
  5285. UNREFERENCED_PARAMETER(VersionIndex);
  5286. UNREFERENCED_PARAMETER(IsAdmin);
  5287. UNREFERENCED_PARAMETER(DataType);
  5288. UNREFERENCED_PARAMETER(DataSize);
  5289. UNREFERENCED_PARAMETER(Data);
  5290. UNREFERENCED_PARAMETER(pLicenseHandle);
  5291. return STATUS_NOT_SUPPORTED;
  5292. }
  5293. NTSTATUS
  5294. NTAPI
  5295. LlsLicenseRequestA(
  5296. LLS_HANDLE Handle,
  5297. LPSTR Product,
  5298. ULONG VersionIndex,
  5299. BOOLEAN IsAdmin,
  5300. ULONG DataType,
  5301. ULONG DataSize,
  5302. PBYTE Data,
  5303. LPDWORD pLicenseHandle )
  5304. {
  5305. UNREFERENCED_PARAMETER(Handle);
  5306. UNREFERENCED_PARAMETER(Product);
  5307. UNREFERENCED_PARAMETER(VersionIndex);
  5308. UNREFERENCED_PARAMETER(IsAdmin);
  5309. UNREFERENCED_PARAMETER(DataType);
  5310. UNREFERENCED_PARAMETER(DataSize);
  5311. UNREFERENCED_PARAMETER(Data);
  5312. UNREFERENCED_PARAMETER(pLicenseHandle);
  5313. return STATUS_NOT_SUPPORTED;
  5314. }
  5315. NTSTATUS
  5316. NTAPI
  5317. LlsLicenseFree2(
  5318. LLS_HANDLE Handle,
  5319. HANDLE LicenseHandle )
  5320. {
  5321. NTSTATUS Status;
  5322. PLOCAL_HANDLE pLocalHandle;
  5323. LICENSE_HANDLE RpcLicenseHandle = (LICENSE_HANDLE) LicenseHandle;
  5324. #ifdef API_TRACE
  5325. dprintf(TEXT("LLSRPC.DLL: LlsLicenseFree\n"));
  5326. #endif
  5327. pLocalHandle = (PLOCAL_HANDLE) Handle;
  5328. if (pLocalHandle == NULL)
  5329. {
  5330. Status = STATUS_INVALID_PARAMETER;
  5331. }
  5332. else
  5333. {
  5334. try {
  5335. RtlEnterCriticalSection( &g_RpcHandleLock );
  5336. lsapirpc_handle = pLocalHandle->llsrpc_handle;
  5337. Status = LlsrLicenseFree( &RpcLicenseHandle );
  5338. RtlLeaveCriticalSection( &g_RpcHandleLock );
  5339. }
  5340. except (TRUE) {
  5341. Status = I_RpcMapWin32Status(RpcExceptionCode());
  5342. #if DBG
  5343. dprintf(TEXT("ERROR LLSRPC.DLL: RPC Exception: 0x%lX\n"), Status);
  5344. #endif
  5345. }
  5346. }
  5347. return Status;
  5348. }
  5349. NTSTATUS
  5350. NTAPI
  5351. LlsLicenseFree(
  5352. LLS_HANDLE Handle,
  5353. DWORD LicenseHandle )
  5354. {
  5355. #pragma warning (push)
  5356. #pragma warning (disable : 4127) //conditional expression is constant
  5357. if (sizeof(ULONG) == sizeof(HANDLE))
  5358. #pragma warning (pop)
  5359. {
  5360. // Should still work on Win32
  5361. return LlsLicenseFree2(Handle,ULongToPtr(LicenseHandle));
  5362. }
  5363. else
  5364. {
  5365. return STATUS_NOT_IMPLEMENTED;
  5366. }
  5367. }