Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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