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.

1797 lines
47 KiB

  1. //*************************************************************
  2. //
  3. // Contains the A/W api stubs
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1995
  7. // All rights reserved
  8. //
  9. //*************************************************************
  10. #include "uenv.h"
  11. #include "strsafe.h"
  12. //*************************************************************
  13. #ifdef UNICODE
  14. //
  15. // ANSI entry point when this module is compiled Unicode.
  16. //
  17. BOOL WINAPI LoadUserProfileA (HANDLE hToken, LPPROFILEINFOA lpProfileInfoA)
  18. {
  19. PROFILEINFOW ProfileInfoW;
  20. BOOL bResult;
  21. //
  22. // Check Parameters
  23. //
  24. if (!lpProfileInfoA) {
  25. DebugMsg((DM_WARNING, TEXT("LoadUserProfileA: NULL lpProfileInfo")));
  26. SetLastError(ERROR_INVALID_PARAMETER);
  27. return FALSE;
  28. }
  29. if (lpProfileInfoA->dwSize != sizeof(PROFILEINFO)) {
  30. DebugMsg((DM_WARNING, TEXT("LoadUserProfileA: lpProfileInfo->dwSize != sizeof(PROFILEINFO)")));
  31. SetLastError(ERROR_INVALID_PARAMETER);
  32. return FALSE;
  33. }
  34. //
  35. // Thunk ProfileInfoA to ProfileInfoW
  36. //
  37. memset(&ProfileInfoW, 0, sizeof(PROFILEINFOW));
  38. ProfileInfoW.dwSize = sizeof(PROFILEINFOW);
  39. ProfileInfoW.dwFlags = lpProfileInfoA->dwFlags;
  40. ProfileInfoW.lpUserName = ProduceWFromA (lpProfileInfoA->lpUserName);
  41. ProfileInfoW.lpProfilePath = ProduceWFromA (lpProfileInfoA->lpProfilePath);
  42. ProfileInfoW.lpDefaultPath = ProduceWFromA (lpProfileInfoA->lpDefaultPath);
  43. ProfileInfoW.lpServerName = ProduceWFromA (lpProfileInfoA->lpServerName);
  44. if (ProfileInfoW.dwFlags & PI_APPLYPOLICY) {
  45. ProfileInfoW.lpPolicyPath = ProduceWFromA (lpProfileInfoA->lpPolicyPath);
  46. }
  47. //
  48. // Now call the real LoadUserProfile function.
  49. //
  50. bResult = LoadUserProfileW (hToken, &ProfileInfoW);
  51. //
  52. // Free memory allocated above and save the return
  53. // values.
  54. //
  55. FreeProducedString (ProfileInfoW.lpUserName);
  56. FreeProducedString (ProfileInfoW.lpProfilePath);
  57. FreeProducedString (ProfileInfoW.lpDefaultPath);
  58. FreeProducedString (ProfileInfoW.lpServerName);
  59. if (ProfileInfoW.dwFlags & PI_APPLYPOLICY) {
  60. FreeProducedString (ProfileInfoW.lpPolicyPath);
  61. }
  62. lpProfileInfoA->hProfile = ProfileInfoW.hProfile;
  63. return bResult;
  64. }
  65. #else
  66. //
  67. // Unicode entry point when this module is compiled ANSI.
  68. //
  69. BOOL WINAPI LoadUserProfileW (HANDLE hToken, LPPROFILEINFOW lpProfileInfoW)
  70. {
  71. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  72. return FALSE;
  73. }
  74. #endif // UNICODE
  75. //*************************************************************
  76. #ifdef UNICODE
  77. //
  78. // ANSI entry point when this module is compiled Unicode.
  79. //
  80. BOOL WINAPI CreateGroupA (LPCSTR lpGroupName, BOOL bCommonGroup)
  81. {
  82. LPWSTR lpGroupNameW;
  83. BOOL bResult;
  84. //
  85. // Convert the ANSI string to Unicode and call
  86. // the real function.
  87. //
  88. if (!(lpGroupNameW = ProduceWFromA (lpGroupName))) {
  89. return FALSE;
  90. }
  91. bResult = CreateGroupW (lpGroupNameW, bCommonGroup);
  92. FreeProducedString (lpGroupNameW);
  93. return bResult;
  94. }
  95. #else
  96. //
  97. // Unicode entry point when this module is compiled ANSI.
  98. //
  99. BOOL WINAPI CreateGroupW (LPCWSTR lpGroupName, BOOL bCommonGroup)
  100. {
  101. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  102. return FALSE;
  103. }
  104. #endif // UNICODE
  105. //*************************************************************
  106. #ifdef UNICODE
  107. //
  108. // ANSI entry point when this module is compiled Unicode.
  109. //
  110. BOOL WINAPI CreateGroupExA(LPCSTR lpGroupName, BOOL bCommonGroup,
  111. LPCSTR lpResourceModuleName, UINT iResourceID)
  112. {
  113. LPWSTR lpGroupNameW;
  114. LPWSTR lpResourceModuleNameW;
  115. BOOL bResult;
  116. //
  117. // Convert the ANSI string to Unicode and call
  118. // the real function.
  119. //
  120. if (!(lpGroupNameW = ProduceWFromA (lpGroupName))) {
  121. return FALSE;
  122. }
  123. if (!(lpResourceModuleNameW = ProduceWFromA (lpResourceModuleName))) {
  124. return FALSE;
  125. }
  126. bResult = CreateGroupExW (lpGroupNameW, bCommonGroup,
  127. lpResourceModuleNameW, iResourceID);
  128. FreeProducedString (lpGroupNameW);
  129. FreeProducedString (lpResourceModuleNameW);
  130. return bResult;
  131. }
  132. #else
  133. //
  134. // Unicode entry point when this module is compiled ANSI.
  135. //
  136. BOOL WINAPI CreateGroupExW(LPCWSTR lpGroupName, BOOL bCommonGroup,
  137. LPCWSTR lpResourceModuleName, UINT iResourceID)
  138. {
  139. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  140. return FALSE;
  141. }
  142. #endif // UNICODE
  143. //*************************************************************
  144. #ifdef UNICODE
  145. //
  146. // ANSI entry point when this module is compiled Unicode.
  147. //
  148. BOOL WINAPI DeleteGroupA (LPCSTR lpGroupName, BOOL bCommonGroup)
  149. {
  150. LPWSTR lpGroupNameW;
  151. BOOL bResult;
  152. //
  153. // Convert the ANSI string to Unicode and call
  154. // the real function.
  155. //
  156. if (!(lpGroupNameW = ProduceWFromA (lpGroupName))) {
  157. return FALSE;
  158. }
  159. bResult = DeleteGroupW (lpGroupNameW, bCommonGroup);
  160. FreeProducedString (lpGroupNameW);
  161. return bResult;
  162. }
  163. #else
  164. //
  165. // Unicode entry point when this module is compiled ANSI.
  166. //
  167. BOOL WINAPI DeleteGroupW (LPCWSTR lpGroupName, BOOL bCommonGroup)
  168. {
  169. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  170. return FALSE;
  171. }
  172. #endif // UNICODE
  173. //*************************************************************
  174. BOOL WINAPI AddItemA (LPCSTR lpGroupName, BOOL bCommonGroup,
  175. LPCSTR lpFileName, LPCSTR lpCommandLine,
  176. LPCSTR lpIconPath, INT iIconIndex,
  177. LPCSTR lpWorkingDirectory, WORD wHotKey,
  178. INT iShowCmd)
  179. {
  180. return CreateLinkFileA (bCommonGroup ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS,
  181. lpGroupName, lpFileName, lpCommandLine,
  182. lpIconPath, iIconIndex, lpWorkingDirectory,
  183. wHotKey, iShowCmd, NULL);
  184. }
  185. BOOL WINAPI AddItemW (LPCWSTR lpGroupName, BOOL bCommonGroup,
  186. LPCWSTR lpFileName, LPCWSTR lpCommandLine,
  187. LPCWSTR lpIconPath, int iIconIndex,
  188. LPCWSTR lpWorkingDirectory, WORD wHotKey,
  189. int iShowCmd)
  190. {
  191. return CreateLinkFileW (bCommonGroup ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS,
  192. lpGroupName, lpFileName, lpCommandLine,
  193. lpIconPath, iIconIndex, lpWorkingDirectory,
  194. wHotKey, iShowCmd, NULL);
  195. }
  196. //*************************************************************
  197. BOOL WINAPI DeleteItemA (LPCSTR lpGroupName, BOOL bCommonGroup,
  198. LPCSTR lpFileName, BOOL bDeleteGroup)
  199. {
  200. return DeleteLinkFileA (bCommonGroup ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS,
  201. lpGroupName, lpFileName, bDeleteGroup);
  202. }
  203. BOOL WINAPI DeleteItemW (LPCWSTR lpGroupName, BOOL bCommonGroup,
  204. LPCWSTR lpFileName, BOOL bDeleteGroup)
  205. {
  206. return DeleteLinkFileW (bCommonGroup ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS,
  207. lpGroupName, lpFileName, bDeleteGroup);
  208. }
  209. //*************************************************************
  210. BOOL WINAPI AddDesktopItemA (BOOL bCommonItem,
  211. LPCSTR lpFileName, LPCSTR lpCommandLine,
  212. LPCSTR lpIconPath, INT iIconIndex,
  213. LPCSTR lpWorkingDirectory, WORD wHotKey,
  214. INT iShowCmd)
  215. {
  216. return CreateLinkFileA (bCommonItem ? CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY,
  217. NULL, lpFileName, lpCommandLine,
  218. lpIconPath, iIconIndex, lpWorkingDirectory,
  219. wHotKey, iShowCmd, NULL);
  220. }
  221. BOOL WINAPI AddDesktopItemW (BOOL bCommonItem,
  222. LPCWSTR lpFileName, LPCWSTR lpCommandLine,
  223. LPCWSTR lpIconPath, int iIconIndex,
  224. LPCWSTR lpWorkingDirectory, WORD wHotKey,
  225. int iShowCmd)
  226. {
  227. return CreateLinkFileW (bCommonItem ? CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY,
  228. NULL, lpFileName, lpCommandLine,
  229. lpIconPath, iIconIndex, lpWorkingDirectory,
  230. wHotKey, iShowCmd, NULL);
  231. }
  232. //*************************************************************
  233. BOOL WINAPI DeleteDesktopItemA (BOOL bCommonItem, LPCSTR lpFileName)
  234. {
  235. return DeleteLinkFileA (bCommonItem ? CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY,
  236. NULL, lpFileName, FALSE);
  237. }
  238. BOOL WINAPI DeleteDesktopItemW (BOOL bCommonItem, LPCWSTR lpFileName)
  239. {
  240. return DeleteLinkFileW (bCommonItem ? CSIDL_COMMON_DESKTOPDIRECTORY : CSIDL_DESKTOPDIRECTORY,
  241. NULL, lpFileName, FALSE);
  242. }
  243. //*************************************************************
  244. #ifdef UNICODE
  245. //
  246. // ANSI entry point when this module is compiled Unicode.
  247. //
  248. BOOL WINAPI CreateLinkFileA (INT csidl, LPCSTR lpSubDirectory,
  249. LPCSTR lpFileName, LPCSTR lpCommandLine,
  250. LPCSTR lpIconPath, INT iIconIndex,
  251. LPCSTR lpWorkingDirectory, WORD wHotKey,
  252. INT iShowCmd, LPCSTR lpDescription)
  253. {
  254. LPWSTR lpSubDirectoryW, lpFileNameW, lpCommandLineW;
  255. LPWSTR lpIconPathW, lpWorkingDirectoryW, lpDescriptionW;
  256. BOOL bResult;
  257. //
  258. // Convert the ANSI strings to Unicode and call
  259. // the real function.
  260. //
  261. lpSubDirectoryW = ProduceWFromA(lpSubDirectory);
  262. if (!(lpFileNameW = ProduceWFromA(lpFileName))) {
  263. FreeProducedString(lpSubDirectoryW);
  264. return FALSE;
  265. }
  266. if (!(lpCommandLineW = ProduceWFromA(lpCommandLine))) {
  267. FreeProducedString(lpSubDirectoryW);
  268. FreeProducedString(lpFileNameW);
  269. return FALSE;
  270. }
  271. lpIconPathW = ProduceWFromA(lpIconPath);
  272. lpWorkingDirectoryW = ProduceWFromA(lpWorkingDirectory);
  273. lpDescriptionW = ProduceWFromA(lpDescription);
  274. bResult = CreateLinkFileW(csidl, lpSubDirectoryW, lpFileNameW,
  275. lpCommandLineW, lpIconPathW, iIconIndex,
  276. lpWorkingDirectoryW, wHotKey, iShowCmd,
  277. lpDescriptionW);
  278. FreeProducedString(lpSubDirectoryW);
  279. FreeProducedString(lpFileNameW);
  280. FreeProducedString(lpCommandLineW);
  281. FreeProducedString(lpIconPathW);
  282. FreeProducedString(lpWorkingDirectoryW);
  283. FreeProducedString(lpDescriptionW);
  284. return bResult;
  285. }
  286. #else
  287. //
  288. // Unicode entry point when this module is compiled ANSI.
  289. //
  290. BOOL WINAPI CreateLinkFileW (INT csidl, LPCWSTR lpSubDirectory,
  291. LPCWSTR lpFileName, LPCWSTR lpCommandLine,
  292. LPCWSTR lpIconPath, INT iIconIndex,
  293. LPCWSTR lpWorkingDirectory, WORD wHotKey,
  294. INT iShowCmd, LPCWSTR lpDescription)
  295. {
  296. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  297. return FALSE;
  298. }
  299. #endif // UNICODE
  300. //*************************************************************
  301. #ifdef UNICODE
  302. //
  303. // ANSI entry point when this module is compiled Unicode.
  304. //
  305. BOOL WINAPI CreateLinkFileExA (INT csidl, LPCSTR lpSubDirectory,
  306. LPCSTR lpFileName, LPCSTR lpCommandLine,
  307. LPCSTR lpIconPath, INT iIconIndex,
  308. LPCSTR lpWorkingDirectory, WORD wHotKey,
  309. INT iShowCmd, LPCSTR lpDescription,
  310. LPCSTR lpResourceModuleName, UINT iResourceID)
  311. {
  312. LPWSTR lpSubDirectoryW, lpFileNameW, lpCommandLineW;
  313. LPWSTR lpIconPathW, lpWorkingDirectoryW, lpDescriptionW;
  314. LPWSTR lpResourceModuleNameW;
  315. BOOL bResult;
  316. //
  317. // Convert the ANSI strings to Unicode and call
  318. // the real function.
  319. //
  320. lpSubDirectoryW = ProduceWFromA(lpSubDirectory);
  321. if (!(lpFileNameW = ProduceWFromA(lpFileName))) {
  322. FreeProducedString(lpSubDirectoryW);
  323. return FALSE;
  324. }
  325. if (!(lpCommandLineW = ProduceWFromA(lpCommandLine))) {
  326. FreeProducedString(lpSubDirectoryW);
  327. FreeProducedString(lpFileNameW);
  328. return FALSE;
  329. }
  330. lpIconPathW = ProduceWFromA(lpIconPath);
  331. lpWorkingDirectoryW = ProduceWFromA(lpWorkingDirectory);
  332. lpDescriptionW = ProduceWFromA(lpDescription);
  333. lpResourceModuleNameW = ProduceWFromA(lpResourceModuleName);
  334. bResult = CreateLinkFileExW(csidl, lpSubDirectoryW, lpFileNameW,
  335. lpCommandLineW, lpIconPathW, iIconIndex,
  336. lpWorkingDirectoryW, wHotKey, iShowCmd,
  337. lpDescriptionW, lpResourceModuleNameW, iResourceID);
  338. FreeProducedString(lpResourceModuleNameW);
  339. FreeProducedString(lpSubDirectoryW);
  340. FreeProducedString(lpFileNameW);
  341. FreeProducedString(lpCommandLineW);
  342. FreeProducedString(lpIconPathW);
  343. FreeProducedString(lpWorkingDirectoryW);
  344. FreeProducedString(lpDescriptionW);
  345. return bResult;
  346. }
  347. #else
  348. //
  349. // Unicode entry point when this module is compiled ANSI.
  350. //
  351. BOOL WINAPI CreateLinkFileExW (INT csidl, LPCWSTR lpSubDirectory,
  352. LPCWSTR lpFileName, LPCWSTR lpCommandLine,
  353. LPCWSTR lpIconPath, INT iIconIndex,
  354. LPCWSTR lpWorkingDirectory, WORD wHotKey,
  355. INT iShowCmd, LPCWSTR lpDescription,
  356. LPCSTR lpResourceModuleName, UINT iResourceID)
  357. {
  358. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  359. return FALSE;
  360. }
  361. #endif // UNICODE
  362. //*************************************************************
  363. #ifdef UNICODE
  364. //
  365. // ANSI entry point when this module is compiled Unicode.
  366. //
  367. BOOL WINAPI DeleteLinkFileA (INT csidl, LPCSTR lpSubDirectory,
  368. LPCSTR lpFileName, BOOL bDeleteSubDirectory)
  369. {
  370. LPWSTR lpSubDirectoryW, lpFileNameW;
  371. BOOL bResult;
  372. //
  373. // Convert the ANSI strings to Unicode and call
  374. // the real function.
  375. //
  376. lpSubDirectoryW = ProduceWFromA(lpSubDirectory);
  377. if (!(lpFileNameW = ProduceWFromA(lpFileName))) {
  378. FreeProducedString(lpSubDirectoryW);
  379. return FALSE;
  380. }
  381. bResult = DeleteLinkFileW(csidl, lpSubDirectoryW, lpFileNameW, bDeleteSubDirectory);
  382. FreeProducedString(lpSubDirectoryW);
  383. FreeProducedString(lpFileNameW);
  384. return bResult;
  385. }
  386. #else
  387. //
  388. // Unicode entry point when this module is compiled ANSI.
  389. //
  390. BOOL WINAPI DeleteLinkFileW (INT csidl, LPCWSTR lpSubDirectory,
  391. LPCWSTR lpFileName, BOOL bDeleteSubDirectory)
  392. {
  393. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  394. return FALSE;
  395. }
  396. #endif // UNICODE
  397. //*************************************************************
  398. #ifdef UNICODE
  399. //
  400. // ANSI entry point when this module is compiled Unicode.
  401. //
  402. BOOL WINAPI CreateUserProfileA (PSID pSid, LPCSTR lpUserNameA, LPCSTR lpUserHiveA,
  403. LPSTR lpProfileDirA, DWORD dwDirSize)
  404. {
  405. LPWSTR lpUserNameW, lpUserHiveW, lpProfileDirW = NULL;
  406. BOOL bResult;
  407. //
  408. // Convert the ANSI string to Unicode and call
  409. // the real function.
  410. //
  411. if (!(lpUserNameW = ProduceWFromA(lpUserNameA))) {
  412. return FALSE;
  413. }
  414. if (lpProfileDirA) {
  415. lpProfileDirW = (LPWSTR) LocalAlloc (LPTR, dwDirSize * sizeof(WCHAR));
  416. if (!lpProfileDirW) {
  417. FreeProducedString(lpUserNameW);
  418. return FALSE;
  419. }
  420. }
  421. lpUserHiveW = ProduceWFromA(lpUserHiveA);
  422. bResult = CreateUserProfileW(pSid, lpUserNameW, lpUserHiveW,
  423. lpProfileDirW, dwDirSize);
  424. FreeProducedString(lpUserNameW);
  425. FreeProducedString(lpUserHiveW);
  426. if (lpProfileDirW) {
  427. if (bResult) {
  428. WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  429. dwDirSize, NULL, NULL);
  430. }
  431. LocalFree (lpProfileDirW);
  432. }
  433. return bResult;
  434. }
  435. #else
  436. //
  437. // Unicode entry point when this module is compiled ANSI.
  438. //
  439. BOOL WINAPI CreateUserProfileW (PSID pSid, LPCWSTR lpUserNameW, LPCWSTR lpUserHiveW,
  440. LPWSTR lpProfileDirW, DWORD dwDirSize)
  441. {
  442. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  443. return FALSE;
  444. }
  445. #endif // UNICODE
  446. //*************************************************************
  447. #ifdef UNICODE
  448. //
  449. // ANSI entry point when this module is compiled Unicode.
  450. //
  451. BOOL WINAPI CreateUserProfileExA (PSID pSid, LPCSTR lpUserNameA, LPCSTR lpUserHiveA,
  452. LPSTR lpProfileDirA, DWORD dwDirSize, BOOL bWin9xUpg)
  453. {
  454. LPWSTR lpUserNameW, lpUserHiveW, lpProfileDirW = NULL;
  455. BOOL bResult;
  456. //
  457. // Convert the ANSI string to Unicode and call
  458. // the real function.
  459. //
  460. if (!(lpUserNameW = ProduceWFromA(lpUserNameA))) {
  461. return FALSE;
  462. }
  463. if (lpProfileDirA) {
  464. lpProfileDirW = (LPWSTR) LocalAlloc (LPTR, dwDirSize * sizeof(WCHAR));
  465. if (!lpProfileDirW) {
  466. FreeProducedString(lpUserNameW);
  467. return FALSE;
  468. }
  469. }
  470. lpUserHiveW = ProduceWFromA(lpUserHiveA);
  471. bResult = CreateUserProfileExW(pSid, lpUserNameW, lpUserHiveW,
  472. lpProfileDirW, dwDirSize, bWin9xUpg);
  473. FreeProducedString(lpUserNameW);
  474. FreeProducedString(lpUserHiveW);
  475. if (lpProfileDirW) {
  476. if (bResult) {
  477. WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  478. dwDirSize, NULL, NULL);
  479. }
  480. LocalFree (lpProfileDirW);
  481. }
  482. return bResult;
  483. }
  484. #else
  485. //
  486. // Unicode entry point when this module is compiled ANSI.
  487. //
  488. BOOL WINAPI CreateUserProfileExW (PSID pSid, LPCWSTR lpUserNameW, LPCWSTR lpUserHiveW,
  489. LPSTR lpProfileDirW, DWORD dwDirSize, BOOL bWin9xUpg)
  490. {
  491. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  492. return FALSE;
  493. }
  494. #endif // UNICODE
  495. //*************************************************************
  496. //
  497. // Stubs for CopyProfileDirectoryA/W
  498. //
  499. BOOL WINAPI CopyProfileDirectoryA (LPCSTR lpSrcDir, LPCSTR lpDstDir, DWORD dwFlags)
  500. {
  501. return CopyProfileDirectoryExA (lpSrcDir, lpDstDir, dwFlags, NULL, NULL);
  502. }
  503. BOOL WINAPI CopyProfileDirectoryW (LPCWSTR lpSrcDir, LPCWSTR lpDstDir, DWORD dwFlags)
  504. {
  505. return CopyProfileDirectoryExW (lpSrcDir, lpDstDir, dwFlags, NULL, NULL);
  506. }
  507. //*************************************************************
  508. #ifdef UNICODE
  509. //
  510. // ANSI entry point when this module is compiled Unicode.
  511. //
  512. BOOL WINAPI CopyProfileDirectoryExA (LPCSTR lpSrcDirA, LPCSTR lpDstDirA,
  513. DWORD dwFlags, LPFILETIME ftDelRefTime,
  514. LPCSTR lpExclusionListA)
  515. {
  516. LPWSTR lpSrcDirW, lpDstDirW, lpExclusionListW = NULL;
  517. BOOL bResult;
  518. //
  519. // Convert the ANSI strings to Unicode and call
  520. // the real function.
  521. //
  522. if (!(lpSrcDirW = ProduceWFromA(lpSrcDirA))) {
  523. return FALSE;
  524. }
  525. if (!(lpDstDirW = ProduceWFromA(lpDstDirA))) {
  526. FreeProducedString(lpSrcDirW);
  527. return FALSE;
  528. }
  529. if (dwFlags & CPD_USEEXCLUSIONLIST) {
  530. lpExclusionListW = ProduceWFromA(lpExclusionListA);
  531. }
  532. bResult = CopyProfileDirectoryExW(lpSrcDirW, lpDstDirW, dwFlags, ftDelRefTime,
  533. lpExclusionListW);
  534. FreeProducedString(lpSrcDirW);
  535. FreeProducedString(lpDstDirW);
  536. FreeProducedString(lpExclusionListW);
  537. return bResult;
  538. }
  539. #else
  540. //
  541. // Unicode entry point when this module is compiled ANSI.
  542. //
  543. BOOL WINAPI CopyProfileDirectoryExW (LPCWSTR lpSrcDirW, LPCWSTR lpDstDirW,
  544. DWORD dwFlags, LPFILETIME ftDelRefTime,
  545. LPCWSTR lpExclusionListW)
  546. {
  547. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  548. return FALSE;
  549. }
  550. #endif // UNICODE
  551. //*************************************************************
  552. #ifdef UNICODE
  553. //
  554. // ANSI entry point when this module is compiled Unicode.
  555. //
  556. BOOL WINAPI GetProfilesDirectoryA (LPSTR lpProfilesDirA, LPDWORD lpcchSize)
  557. {
  558. LPWSTR lpProfilesDirW;
  559. BOOL bResult;
  560. DWORD cchOrgSize, cchReq;
  561. if (!lpProfilesDirA) {
  562. DebugMsg((DM_WARNING, TEXT("GetProfilesDirectoryA : lpProfilesDirA is null")));
  563. SetLastError(ERROR_INVALID_PARAMETER);
  564. return FALSE;
  565. }
  566. if (!lpcchSize) {
  567. DebugMsg((DM_WARNING, TEXT("GetProfilesDirectoryA : lpcchSize is null")));
  568. SetLastError(ERROR_INVALID_PARAMETER);
  569. return FALSE;
  570. }
  571. //
  572. // Allocate a buffer to match the ANSI buffer
  573. //
  574. if (!(lpProfilesDirW = GlobalAlloc(GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  575. return FALSE;
  576. }
  577. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  578. bResult = GetProfilesDirectoryW(lpProfilesDirW, lpcchSize);
  579. if (bResult) {
  580. cchReq = WideCharToMultiByte(CP_ACP, 0, lpProfilesDirW, -1, lpProfilesDirA,
  581. 0, NULL, NULL);
  582. *lpcchSize = cchReq;
  583. if (cchReq > cchOrgSize) {
  584. bResult = FALSE;
  585. }
  586. else {
  587. bResult = WideCharToMultiByte(CP_ACP, 0, lpProfilesDirW, -1, lpProfilesDirA,
  588. *lpcchSize, NULL, NULL);
  589. }
  590. }
  591. GlobalFree(lpProfilesDirW);
  592. return bResult;
  593. }
  594. #else
  595. //
  596. // Unicode entry point when this module is compiled ANSI.
  597. //
  598. BOOL WINAPI GetProfilesDirectoryW (LPWSTR lpProfilesDirW, LPDWORD lpcchSize)
  599. {
  600. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  601. return FALSE;
  602. }
  603. #endif // UNICODE
  604. //*************************************************************
  605. #ifdef UNICODE
  606. //
  607. // ANSI entry point when this module is compiled Unicode.
  608. //
  609. BOOL WINAPI GetDefaultUserProfileDirectoryA (LPSTR lpProfileDirA, LPDWORD lpcchSize)
  610. {
  611. LPWSTR lpProfileDirW;
  612. BOOL bResult;
  613. DWORD cchOrgSize, cchReq;
  614. if (!lpProfileDirA) {
  615. DebugMsg((DM_WARNING, TEXT("GetDefaultUserProfileDirectoryA : lpProfileDirA is null")));
  616. SetLastError(ERROR_INVALID_PARAMETER);
  617. return FALSE;
  618. }
  619. if (!lpcchSize) {
  620. DebugMsg((DM_WARNING, TEXT("GetDefaultUserProfileDirectoryA : lpcchSize is null")));
  621. SetLastError(ERROR_INVALID_PARAMETER);
  622. return FALSE;
  623. }
  624. //
  625. // Allocate a buffer to match the ANSI buffer
  626. //
  627. if (!(lpProfileDirW = GlobalAlloc(GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  628. return FALSE;
  629. }
  630. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  631. bResult = GetDefaultUserProfileDirectoryW(lpProfileDirW, lpcchSize);
  632. if (bResult) {
  633. cchReq = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  634. 0, NULL, NULL);
  635. *lpcchSize = cchReq;
  636. if (cchReq > cchOrgSize) {
  637. bResult = FALSE;
  638. }
  639. else {
  640. bResult = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  641. *lpcchSize, NULL, NULL);
  642. }
  643. }
  644. GlobalFree(lpProfileDirW);
  645. return bResult;
  646. }
  647. #else
  648. //
  649. // Unicode entry point when this module is compiled ANSI.
  650. //
  651. BOOL WINAPI GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDirW, LPDWORD lpcchSize)
  652. {
  653. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  654. return FALSE;
  655. }
  656. #endif // UNICODE
  657. //*************************************************************
  658. #ifdef UNICODE
  659. //
  660. // ANSI entry point when this module is compiled Unicode.
  661. //
  662. BOOL WINAPI GetAllUsersProfileDirectoryA (LPSTR lpProfileDirA, LPDWORD lpcchSize)
  663. {
  664. LPWSTR lpProfileDirW;
  665. BOOL bResult;
  666. DWORD cchOrgSize, cchReq;
  667. if (!lpProfileDirA) {
  668. DebugMsg((DM_WARNING, TEXT("GetAllUsersProfileDirectoryA : lpProfileDirA is null")));
  669. SetLastError(ERROR_INVALID_PARAMETER);
  670. return FALSE;
  671. }
  672. if (!lpcchSize) {
  673. DebugMsg((DM_WARNING, TEXT("GetAllUsersProfileDirectoryA : lpcchSize is null")));
  674. SetLastError(ERROR_INVALID_PARAMETER);
  675. return FALSE;
  676. }
  677. //
  678. // Allocate a buffer to match the ANSI buffer
  679. //
  680. if (!(lpProfileDirW = GlobalAlloc(GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  681. return FALSE;
  682. }
  683. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  684. bResult = GetAllUsersProfileDirectoryW(lpProfileDirW, lpcchSize);
  685. if (bResult) {
  686. cchReq = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  687. 0, NULL, NULL);
  688. *lpcchSize = cchReq;
  689. if (cchReq > cchOrgSize) {
  690. bResult = FALSE;
  691. }
  692. else {
  693. bResult = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  694. *lpcchSize, NULL, NULL);
  695. }
  696. }
  697. GlobalFree(lpProfileDirW);
  698. return bResult;
  699. }
  700. #else
  701. //
  702. // Unicode entry point when this module is compiled ANSI.
  703. //
  704. BOOL WINAPI GetAllUsersProfileDirectoryW (LPWSTR lpProfileDirW, LPDWORD lpcchSize)
  705. {
  706. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  707. return FALSE;
  708. }
  709. #endif // UNICODE
  710. //*************************************************************
  711. #ifdef UNICODE
  712. //
  713. // ANSI entry point when this module is compiled Unicode.
  714. //
  715. BOOL WINAPI GetUserProfileDirectoryA (HANDLE hToken, LPSTR lpProfileDirA, LPDWORD lpcchSize)
  716. {
  717. LPWSTR lpProfileDirW;
  718. BOOL bResult;
  719. DWORD cchOrgSize, cchReq;
  720. if (!lpProfileDirA) {
  721. DebugMsg((DM_WARNING, TEXT("GetUserProfileDirectoryA : lpProfileDirA is null")));
  722. SetLastError(ERROR_INVALID_PARAMETER);
  723. return FALSE;
  724. }
  725. if (!lpcchSize) {
  726. DebugMsg((DM_WARNING, TEXT("GetUserProfileDirectoryA : lpcchSize is null")));
  727. SetLastError(ERROR_INVALID_PARAMETER);
  728. return FALSE;
  729. }
  730. //
  731. // Allocate a buffer to match the ANSI buffer
  732. //
  733. if (!(lpProfileDirW = GlobalAlloc(GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  734. return FALSE;
  735. }
  736. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  737. bResult = GetUserProfileDirectoryW(hToken, lpProfileDirW, lpcchSize);
  738. if (bResult) {
  739. cchReq = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  740. 0, NULL, NULL);
  741. *lpcchSize = cchReq;
  742. if (cchReq > cchOrgSize) {
  743. bResult = FALSE;
  744. }
  745. else {
  746. bResult = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  747. *lpcchSize, NULL, NULL);
  748. }
  749. }
  750. GlobalFree(lpProfileDirW);
  751. return bResult;
  752. }
  753. #else
  754. //
  755. // Unicode entry point when this module is compiled ANSI.
  756. //
  757. BOOL WINAPI GetUserProfileDirectoryW (HANDLE hToken, LPWSTR lpProfileDirW, LPDWORD lpcchSize)
  758. {
  759. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  760. return FALSE;
  761. }
  762. #endif // UNICODE
  763. //*************************************************************
  764. #ifdef UNICODE
  765. //
  766. // ANSI entry point when this module is compiled Unicode.
  767. //
  768. BOOL WINAPI GetUserProfileDirFromSidA (PSID pSid, LPSTR lpProfileDirA, LPDWORD lpcchSize)
  769. {
  770. LPWSTR lpProfileDirW;
  771. BOOL bResult;
  772. DWORD cchOrgSize, cchReq;
  773. if (!lpProfileDirA) {
  774. DebugMsg((DM_WARNING, TEXT("GetUserProfileDirFromSidA : lpProfileDirA is null")));
  775. SetLastError(ERROR_INVALID_PARAMETER);
  776. return FALSE;
  777. }
  778. if (!lpcchSize) {
  779. DebugMsg((DM_WARNING, TEXT("GetUserProfileDirFromSidA : lpcchSize is null")));
  780. SetLastError(ERROR_INVALID_PARAMETER);
  781. return FALSE;
  782. }
  783. //
  784. // Allocate a buffer to match the ANSI buffer
  785. //
  786. if (!(lpProfileDirW = GlobalAlloc(GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  787. return FALSE;
  788. }
  789. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  790. bResult = GetUserProfileDirFromSidW(pSid, lpProfileDirW, lpcchSize);
  791. if (bResult) {
  792. cchReq = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  793. 0, NULL, NULL);
  794. *lpcchSize = cchReq;
  795. if (cchReq > cchOrgSize) {
  796. bResult = FALSE;
  797. }
  798. else {
  799. bResult = WideCharToMultiByte(CP_ACP, 0, lpProfileDirW, -1, lpProfileDirA,
  800. *lpcchSize, NULL, NULL);
  801. }
  802. }
  803. GlobalFree(lpProfileDirW);
  804. return bResult;
  805. }
  806. #else
  807. //
  808. // Unicode entry point when this module is compiled ANSI.
  809. //
  810. BOOL WINAPI GetUserProfileDirFromSidW (PSID pSid, LPWSTR lpProfileDirW, LPDWORD lpcchSize)
  811. {
  812. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  813. return FALSE;
  814. }
  815. #endif // UNICODE
  816. //*************************************************************
  817. #ifdef UNICODE
  818. //
  819. // ANSI entry point when this module is compiled Unicode.
  820. //
  821. BOOL WINAPI ExpandEnvironmentStringsForUserA (HANDLE hToken, LPCSTR lpSrcA, LPSTR lpDestA, DWORD dwSize)
  822. {
  823. LPWSTR lpSrcW, lpDestW;
  824. BOOL bResult;
  825. if (!lpDestA) {
  826. DebugMsg((DM_WARNING, TEXT("ExpandEnvironmentStringsForUserA : lpDestA is null")));
  827. SetLastError(ERROR_INVALID_PARAMETER);
  828. return FALSE;
  829. }
  830. //
  831. // Convert the ANSI strings to Unicode and call
  832. // the real function.
  833. //
  834. if (!(lpSrcW = ProduceWFromA(lpSrcA))) {
  835. DebugMsg((DM_WARNING, TEXT("ExpandEnvircallonmentStringsForUserA : lpSrcA is null")));
  836. SetLastError(ERROR_INVALID_PARAMETER);
  837. return FALSE;
  838. }
  839. //
  840. // Allocate a buffer to match the ANSI buffer
  841. //
  842. if (!(lpDestW = GlobalAlloc(GPTR, dwSize * sizeof(TCHAR)))) {
  843. FreeProducedString(lpSrcW);
  844. return FALSE;
  845. }
  846. bResult = ExpandEnvironmentStringsForUserW(hToken, lpSrcW, lpDestW, dwSize);
  847. if (bResult) {
  848. bResult = WideCharToMultiByte(CP_ACP, 0, lpDestW, -1, lpDestA,
  849. dwSize, NULL, NULL);
  850. }
  851. GlobalFree(lpDestW);
  852. FreeProducedString(lpSrcW);
  853. return bResult;
  854. }
  855. #else
  856. //
  857. // Unicode entry point when this module is compiled ANSI.
  858. //
  859. BOOL WINAPI ExpandEnvironmentStringsForUserW (HANDLE hToken, LPCWSTR lpSrcW, LPWSTR lpDestW, DWORD dwSize)
  860. {
  861. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  862. return FALSE;
  863. }
  864. #endif // UNICODE
  865. //*************************************************************
  866. #ifdef UNICODE
  867. //
  868. // ANSI entry point when this module is compiled Unicode.
  869. //
  870. BOOL WINAPI GetSystemTempDirectoryA (LPSTR lpDirA, LPDWORD lpcchSize)
  871. {
  872. LPWSTR lpDirW;
  873. BOOL bResult;
  874. DWORD cchOrgSize, cchReq;
  875. if (!lpcchSize) {
  876. DebugMsg((DM_WARNING, TEXT("GetSystemTempDirectoryA : lpcchSize is null")));
  877. SetLastError(ERROR_INVALID_PARAMETER);
  878. return FALSE;
  879. }
  880. //
  881. // Allocate a buffer to match the ANSI buffer
  882. //
  883. if (!(lpDirW = GlobalAlloc (GPTR, (*lpcchSize) * sizeof(TCHAR)))) {
  884. return FALSE;
  885. }
  886. cchOrgSize = *lpcchSize; // Store the original size passed to the function
  887. bResult = GetSystemTempDirectoryW (lpDirW, lpcchSize);
  888. if (bResult) {
  889. cchReq = WideCharToMultiByte(CP_ACP, 0, lpDirW, -1, lpDirA,
  890. 0, NULL, NULL);
  891. *lpcchSize = cchReq;
  892. if (cchReq > cchOrgSize) {
  893. bResult = FALSE;
  894. }
  895. else {
  896. WideCharToMultiByte (CP_ACP, 0, lpDirW, -1, lpDirA,
  897. *lpcchSize, NULL, NULL);
  898. }
  899. }
  900. GlobalFree (lpDirW);
  901. return bResult;
  902. }
  903. #else
  904. //
  905. // Unicode entry point when this module is compiled ANSI.
  906. //
  907. BOOL WINAPI GetSystemTempDirectoryW (LPWSTR lpDirW, LPDWORD lpcchSize)
  908. {
  909. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  910. return FALSE;
  911. }
  912. #endif // UNICODE
  913. //*************************************************************
  914. #ifdef UNICODE
  915. //
  916. // ANSI entry point when this module is compiled Unicode.
  917. //
  918. BOOL WINAPI ConvertGPOListWToA( PGROUP_POLICY_OBJECTW pGPOListW,
  919. PGROUP_POLICY_OBJECTA *pGPOListA )
  920. {
  921. LPSTR lpDSPathA, lpFileSysPathA, lpDisplayNameA, lpExtensionsA, lpLinkA;
  922. DWORD dwSize;
  923. PGROUP_POLICY_OBJECTA pGPOTempA = NULL, pNew, pTemp;
  924. PGROUP_POLICY_OBJECTW pGPO = pGPOListW;
  925. while (pGPO) {
  926. //
  927. // Build an ANSI structure for this entry
  928. //
  929. lpDSPathA = ProduceAFromW(pGPO->lpDSPath);
  930. lpFileSysPathA = ProduceAFromW(pGPO->lpFileSysPath);
  931. lpDisplayNameA = ProduceAFromW(pGPO->lpDisplayName);
  932. lpExtensionsA = ProduceAFromW( pGPO->lpExtensions );
  933. lpLinkA = ProduceAFromW( pGPO->lpLink );
  934. //
  935. // Calculate the size of the new GPO item
  936. //
  937. dwSize = sizeof (GROUP_POLICY_OBJECTA);
  938. if (lpDSPathA) {
  939. dwSize += (lstrlenA(lpDSPathA) + 1);
  940. }
  941. if (lpFileSysPathA) {
  942. dwSize += (lstrlenA(lpFileSysPathA) + 1);
  943. }
  944. if (lpDisplayNameA) {
  945. dwSize += (lstrlenA(lpDisplayNameA) + 1);
  946. }
  947. if (lpExtensionsA) {
  948. dwSize += (lstrlenA(lpExtensionsA) + 1);
  949. }
  950. if (lpLinkA) {
  951. dwSize += (lstrlenA(lpLinkA) + 1);
  952. }
  953. //
  954. // Allocate space for it
  955. //
  956. pNew = (PGROUP_POLICY_OBJECTA) LocalAlloc (LPTR, dwSize);
  957. if (!pNew) {
  958. DebugMsg((DM_WARNING, TEXT("ConvertGPOListWToA: Failed to allocate memory with %d"),
  959. GetLastError()));
  960. FreeProducedString(lpDSPathA);
  961. FreeProducedString(lpFileSysPathA);
  962. FreeProducedString(lpDisplayNameA);
  963. FreeProducedString(lpExtensionsA);
  964. FreeProducedString(lpLinkA);
  965. FreeGPOListW (pGPOListW);
  966. return FALSE;
  967. }
  968. //
  969. // Fill in item
  970. //
  971. pNew->dwOptions = pGPO->dwOptions;
  972. pNew->dwVersion = pGPO->dwVersion;
  973. if (lpDSPathA) {
  974. pNew->lpDSPath = (LPSTR)(((LPBYTE)pNew) + sizeof(GROUP_POLICY_OBJECTA));
  975. (void) StringCchCopyA(pNew->lpDSPath, lstrlenA(lpDSPathA)+1, lpDSPathA);
  976. }
  977. if (lpFileSysPathA) {
  978. if (lpDSPathA) {
  979. pNew->lpFileSysPath = pNew->lpDSPath + lstrlenA (pNew->lpDSPath) + 1;
  980. } else {
  981. pNew->lpFileSysPath = (LPSTR)(((LPBYTE)pNew) + sizeof(GROUP_POLICY_OBJECTA));
  982. }
  983. (void) StringCchCopyA(pNew->lpFileSysPath, lstrlenA(lpFileSysPathA)+1, lpFileSysPathA);
  984. }
  985. if (lpDisplayNameA) {
  986. if (lpFileSysPathA) {
  987. pNew->lpDisplayName = pNew->lpFileSysPath + lstrlenA (pNew->lpFileSysPath) + 1;
  988. } else {
  989. if (lpDSPathA)
  990. {
  991. pNew->lpDisplayName = pNew->lpDSPath + lstrlenA (pNew->lpDSPath) + 1;
  992. }
  993. else
  994. {
  995. pNew->lpDisplayName = (LPSTR)(((LPBYTE)pNew) + sizeof(GROUP_POLICY_OBJECTA));
  996. }
  997. }
  998. (void) StringCchCopyA(pNew->lpDisplayName, lstrlenA(lpDisplayNameA)+1, lpDisplayNameA);
  999. }
  1000. if (lpExtensionsA) {
  1001. if (lpDisplayNameA) {
  1002. pNew->lpExtensions = pNew->lpDisplayName + lstrlenA(pNew->lpDisplayName) + 1;
  1003. } else {
  1004. if (lpFileSysPathA) {
  1005. pNew->lpExtensions = pNew->lpFileSysPath + lstrlenA(pNew->lpFileSysPath) + 1;
  1006. } else {
  1007. if (lpDSPathA) {
  1008. pNew->lpExtensions = pNew->lpDSPath + lstrlenA(pNew->lpDSPath) + 1;
  1009. } else {
  1010. pNew->lpExtensions = (LPSTR)(((LPBYTE)pNew) + sizeof(GROUP_POLICY_OBJECTA));
  1011. }
  1012. }
  1013. }
  1014. (void)StringCchCopyA( pNew->lpExtensions, lstrlenA(lpExtensionsA)+1, lpExtensionsA );
  1015. }
  1016. if (lpLinkA) {
  1017. if (lpExtensionsA) {
  1018. pNew->lpLink = pNew->lpExtensions + lstrlenA(pNew->lpExtensions) + 1;
  1019. } else {
  1020. if (lpDisplayNameA) {
  1021. pNew->lpLink = pNew->lpDisplayName + lstrlenA(pNew->lpDisplayName) + 1;
  1022. } else {
  1023. if (lpFileSysPathA) {
  1024. pNew->lpLink = pNew->lpFileSysPath + lstrlenA(pNew->lpFileSysPath) + 1;
  1025. } else {
  1026. if (lpDSPathA) {
  1027. pNew->lpLink = pNew->lpDSPath + lstrlenA(pNew->lpDSPath) + 1;
  1028. } else {
  1029. pNew->lpLink = (LPSTR)(((LPBYTE)pNew) + sizeof(GROUP_POLICY_OBJECTA));
  1030. }
  1031. }
  1032. }
  1033. }
  1034. (void) StringCchCopyA( pNew->lpLink, lstrlenA(lpLinkA)+1, lpLinkA );
  1035. }
  1036. WideCharToMultiByte(CP_ACP, 0, pGPO->szGPOName, -1, pNew->szGPOName, 50, NULL, NULL);
  1037. pNew->GPOLink = pGPO->GPOLink;
  1038. pNew->lParam = pGPO->lParam;
  1039. //
  1040. // Add it to the ANSI link list
  1041. //
  1042. if (pGPOTempA) {
  1043. pTemp = pGPOTempA;
  1044. while (pTemp->pNext != NULL) {
  1045. pTemp = pTemp->pNext;
  1046. }
  1047. pTemp->pNext = pNew;
  1048. pNew->pPrev = pTemp;
  1049. } else {
  1050. pGPOTempA = pNew;
  1051. }
  1052. FreeProducedString(lpDSPathA);
  1053. FreeProducedString(lpFileSysPathA);
  1054. FreeProducedString(lpDisplayNameA);
  1055. FreeProducedString(lpExtensionsA);
  1056. FreeProducedString(lpLinkA);
  1057. pGPO = pGPO->pNext;
  1058. }
  1059. *pGPOListA = pGPOTempA;
  1060. FreeGPOListW (pGPOListW);
  1061. return TRUE;
  1062. }
  1063. BOOL WINAPI GetGPOListA (HANDLE hToken, LPCSTR lpNameA, LPCSTR lpHostNameA,
  1064. LPCSTR lpComputerNameA, DWORD dwFlags,
  1065. PGROUP_POLICY_OBJECTA *pGPOListA)
  1066. {
  1067. LPWSTR lpNameW, lpHostNameW, lpComputerNameW;
  1068. PGROUP_POLICY_OBJECTW pGPOListW;
  1069. BOOL bResult;
  1070. if (!pGPOListA) {
  1071. DebugMsg((DM_WARNING, TEXT("GetGPOListA: pGPOList is null")));
  1072. SetLastError(ERROR_INVALID_PARAMETER);
  1073. return FALSE;
  1074. }
  1075. lpNameW = ProduceWFromA(lpNameA);
  1076. lpHostNameW = ProduceWFromA(lpHostNameA);
  1077. lpComputerNameW = ProduceWFromA(lpComputerNameA);
  1078. bResult = GetGPOListW (hToken, lpNameW, lpHostNameW, lpComputerNameW,
  1079. dwFlags, &pGPOListW);
  1080. FreeProducedString(lpNameW);
  1081. FreeProducedString(lpHostNameW);
  1082. FreeProducedString(lpComputerNameW);
  1083. if (bResult) {
  1084. bResult = ConvertGPOListWToA( pGPOListW, pGPOListA );
  1085. }
  1086. return bResult;
  1087. }
  1088. #else
  1089. //
  1090. // Unicode entry point when this module is compiled ANSI.
  1091. //
  1092. BOOL WINAPI GetGPOListW (HANDLE hToken, LPCWSTR lpNameW, LPCWSTR lpHostNameW,
  1093. LPCWSTR lpComputerNameW, DWORD dwFlags,
  1094. PGROUP_POLICY_OBJECTW *pGPOListW)
  1095. {
  1096. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1097. return FALSE;
  1098. }
  1099. #endif // UNICODE
  1100. //*************************************************************
  1101. #ifdef UNICODE
  1102. //
  1103. // ANSI entry point when this module is compiled Unicode.
  1104. //
  1105. BOOL WINAPI FreeGPOListA (PGROUP_POLICY_OBJECTA pGPOListA)
  1106. {
  1107. PGROUP_POLICY_OBJECTA pGPOTemp;
  1108. while (pGPOListA) {
  1109. pGPOTemp = pGPOListA->pNext;
  1110. LocalFree (pGPOListA);
  1111. pGPOListA = pGPOTemp;
  1112. }
  1113. return TRUE;
  1114. }
  1115. #else
  1116. //
  1117. // Unicode entry point when this module is compiled ANSI.
  1118. //
  1119. BOOL WINAPI FreeGPOListW (PGROUP_POLICY_OBJECTW pGPOListW)
  1120. {
  1121. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1122. return FALSE;
  1123. }
  1124. #endif // UNICODE
  1125. //*************************************************************
  1126. #ifdef UNICODE
  1127. //
  1128. // ANSI entry point when this module is compiled Unicode.
  1129. //
  1130. BOOL WINAPI ApplySystemPolicyA (DWORD dwFlags, HANDLE hToken, HKEY hKeyCurrentUser,
  1131. LPCSTR lpUserNameA, LPCSTR lpPolicyPathA,
  1132. LPCSTR lpServerNameA)
  1133. {
  1134. LPWSTR lpUserNameW, lpPolicyPathW, lpServerNameW;
  1135. BOOL bResult;
  1136. //
  1137. // Convert the ANSI strings to Unicode and call
  1138. // the real function.
  1139. //
  1140. if (!(lpUserNameW = ProduceWFromA(lpUserNameA))) {
  1141. return FALSE;
  1142. }
  1143. lpPolicyPathW = ProduceWFromA(lpPolicyPathA);
  1144. lpServerNameW = ProduceWFromA(lpServerNameA);
  1145. bResult = ApplySystemPolicyW(dwFlags, hToken, hKeyCurrentUser, lpUserNameW,
  1146. lpPolicyPathW, lpServerNameW);
  1147. FreeProducedString(lpServerNameW);
  1148. FreeProducedString(lpPolicyPathW);
  1149. FreeProducedString(lpUserNameW);
  1150. return bResult;
  1151. }
  1152. #else
  1153. //
  1154. // Unicode entry point when this module is compiled ANSI.
  1155. //
  1156. BOOL WINAPI ApplySystemPolicyW (DWORD dwFlags, HANDLE hToken, HKEY hKeyCurrentUser,
  1157. LPCWSTR lpUserNameW, LPCWSTR lpPolicyPathW,
  1158. LPCWSTR lpServerNameW)
  1159. {
  1160. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  1161. return FALSE;
  1162. }
  1163. #endif // UNICODE
  1164. //*************************************************************
  1165. #ifdef UNICODE
  1166. //
  1167. // ANSI entry point when this module is compiled Unicode.
  1168. //
  1169. DWORD WINAPI GetAppliedGPOListA ( DWORD dwFlags,
  1170. LPCSTR pMachineNameA,
  1171. PSID pSidUser,
  1172. GUID *pGuidExtension,
  1173. PGROUP_POLICY_OBJECTA *pGPOListA)
  1174. {
  1175. PGROUP_POLICY_OBJECTW pGPOListW;
  1176. DWORD dwRet;
  1177. LPWSTR pMachineNameW;
  1178. if (!pGPOListA || !pGuidExtension) {
  1179. DebugMsg((DM_WARNING, TEXT("GetAppliedGPOListA: pGPOList or pGuidExtension is null")));
  1180. return ERROR_INVALID_PARAMETER;
  1181. }
  1182. pMachineNameW = ProduceWFromA(pMachineNameA);
  1183. dwRet = GetAppliedGPOListW ( dwFlags, pMachineNameW, pSidUser, pGuidExtension, &pGPOListW);
  1184. FreeProducedString(pMachineNameW);
  1185. if ( dwRet == ERROR_SUCCESS ) {
  1186. BOOL bResult = ConvertGPOListWToA( pGPOListW, pGPOListA );
  1187. dwRet = bResult ? ERROR_SUCCESS : E_FAIL;
  1188. }
  1189. return dwRet;
  1190. }
  1191. #else
  1192. //
  1193. // Unicode entry point when this module is compiled ANSI.
  1194. //
  1195. DWORD WINAPI GetAppliedGPOListW ( DWORD dwFlags,
  1196. GUID *pGuidExtension,
  1197. PGROUP_POLICY_OBJECTW *pGPOListW)
  1198. {
  1199. return ERROR_CALL_NOT_IMPLEMENTED;
  1200. }
  1201. #endif // UNICODE
  1202. //*************************************************************
  1203. #ifdef UNICODE
  1204. //
  1205. // ANSI entry point when this module is compiled Unicode.
  1206. //
  1207. BOOL WINAPI DeleteProfileA ( LPCSTR lpSidStringA,
  1208. LPCSTR lpProfilePathA,
  1209. LPCSTR lpComputerNameA)
  1210. {
  1211. LPWSTR pSidStringW;
  1212. LPWSTR pProfilePathW;
  1213. LPWSTR pComputerNameW;
  1214. BOOL dwRet;
  1215. if (!lpSidStringA) {
  1216. DebugMsg((DM_WARNING, TEXT("DeleteProfileA: lpSidString is null")));
  1217. SetLastError(ERROR_INVALID_PARAMETER);
  1218. return FALSE;
  1219. }
  1220. if (!(pSidStringW = ProduceWFromA(lpSidStringA))) {
  1221. return FALSE;
  1222. }
  1223. if (lpProfilePathA) {
  1224. if (!(pProfilePathW = ProduceWFromA(lpProfilePathA))) {
  1225. FreeProducedString(pSidStringW);
  1226. return FALSE;
  1227. }
  1228. }
  1229. else {
  1230. pProfilePathW = NULL;
  1231. }
  1232. if (lpComputerNameA) {
  1233. if (!(pComputerNameW = ProduceWFromA(lpComputerNameA))) {
  1234. FreeProducedString(pSidStringW);
  1235. FreeProducedString(pProfilePathW);
  1236. return FALSE;
  1237. }
  1238. }
  1239. else {
  1240. pComputerNameW = NULL;
  1241. }
  1242. dwRet = DeleteProfileW ( pSidStringW, pProfilePathW, pComputerNameW);
  1243. FreeProducedString(pSidStringW);
  1244. if (pProfilePathW)
  1245. FreeProducedString(pProfilePathW);
  1246. if (pComputerNameW)
  1247. FreeProducedString(pComputerNameW);
  1248. return dwRet;
  1249. }
  1250. #else
  1251. //
  1252. // Unicode entry point when this module is compiled ANSI.
  1253. //
  1254. BOOL WINAPI DeleteProfileW ( LPWSTR lpSidStringW,
  1255. LPWSTR lpProfilePathW,
  1256. HKEY hKeyLM)
  1257. {
  1258. return ERROR_CALL_NOT_IMPLEMENTED;
  1259. }
  1260. #endif // UNICODE
  1261. //*************************************************************
  1262. #ifdef UNICODE
  1263. //
  1264. // ANSI entry point when this module is compiled Unicode.
  1265. //
  1266. DWORD WINAPI GetUserAppDataPathA (HANDLE hToken, BOOL fLocalAppData, LPSTR lpFolderPathA)
  1267. {
  1268. LPWSTR lpFolderPathW;
  1269. BOOL bResult;
  1270. DWORD dwError = ERROR_SUCCESS, cchReq;
  1271. if (!lpFolderPathA) {
  1272. DebugMsg((DM_WARNING, TEXT("GetUserAppDataPathA : lpFolderPathA is null")));
  1273. SetLastError(ERROR_INVALID_PARAMETER);
  1274. return ERROR_INVALID_PARAMETER;
  1275. }
  1276. else {
  1277. *lpFolderPathA = TEXT('\0');
  1278. }
  1279. //
  1280. // Allocate a buffer to match the ANSI buffer
  1281. //
  1282. if (!(lpFolderPathW = GlobalAlloc(GPTR, (MAX_PATH) * sizeof(TCHAR)))) {
  1283. SetLastError(ERROR_OUTOFMEMORY);
  1284. return ERROR_OUTOFMEMORY;
  1285. }
  1286. dwError = GetUserAppDataPathW(hToken, fLocalAppData, lpFolderPathW);
  1287. if (dwError == ERROR_SUCCESS) {
  1288. cchReq = WideCharToMultiByte(CP_ACP, 0, lpFolderPathW, -1, lpFolderPathA,
  1289. 0, NULL, NULL);
  1290. if (cchReq > MAX_PATH) {
  1291. dwError = ERROR_INSUFFICIENT_BUFFER;
  1292. }
  1293. else {
  1294. bResult = WideCharToMultiByte(CP_ACP, 0, lpFolderPathW, -1, lpFolderPathA,
  1295. MAX_PATH, NULL, NULL);
  1296. }
  1297. }
  1298. GlobalFree(lpFolderPathW);
  1299. SetLastError(dwError);
  1300. return dwError;
  1301. }
  1302. #else
  1303. //
  1304. // Unicode entry point when this module is compiled ANSI.
  1305. //
  1306. BOOL WINAPI GetUserAppDataPathW (HANDLE hToken, BOOL fLocalAppData, LPWSTR lpFolderPathW)
  1307. {
  1308. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  1309. return ERROR_CALL_NOT_IMPLEMENTED;
  1310. }
  1311. #endif // UNICODE