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.

939 lines
23 KiB

  1. //************************************************************************
  2. //
  3. // dpmfprf.c : Dynamic Patch Module for Profile API family
  4. //
  5. // History:
  6. // 19-jan-02 cmjones created it.
  7. //
  8. //************************************************************************
  9. #ifdef DBG
  10. unsigned long dwLogLevel = 0;
  11. #endif
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <windows.h>
  16. #include "dpmtbls.h"
  17. #include "dpmdbg.h" // include handy debug print macros
  18. #include "shimdb.h"
  19. BOOL DllInitProc(HMODULE hModule, DWORD Reason, PCONTEXT pContext);
  20. PFAMILY_TABLE DpmInitFamTable(PFAMILY_TABLE,
  21. HMODULE,
  22. PVOID,
  23. PVOID,
  24. LPWSTR,
  25. PDPMMODULESETS);
  26. void DpmDestroyFamTable(PFAMILY_TABLE pgDpmFamTbl, PFAMILY_TABLE pFT);
  27. #define GROW_HEAP_AS_NEEDED 0
  28. HANDLE hHeap = NULL;
  29. DWORD dwTlsIndex;
  30. char szShimEngDll[] = "\\ShimEng.dll";
  31. BOOL DllInitProc(HMODULE hModule, DWORD Reason, PCONTEXT pContext)
  32. {
  33. BOOL bRet = TRUE;
  34. UNREFERENCED_PARAMETER(hModule);
  35. UNREFERENCED_PARAMETER(pContext);
  36. switch(Reason) {
  37. case DLL_PROCESS_ATTACH:
  38. if((hHeap = HeapCreate(0, 4096, GROW_HEAP_AS_NEEDED)) == NULL) {
  39. DPMDBGPRN("NTVDM::DpmfPrf:Can't initialize heap!\n");
  40. bRet = FALSE;
  41. }
  42. dwTlsIndex = TlsAlloc();
  43. if(dwTlsIndex == TLS_OUT_OF_INDEXES) {
  44. DPMDBGPRN("NTVDM::DpmfPrf:Can't initialize TLS!\n");
  45. bRet = FALSE;
  46. }
  47. break;
  48. case DLL_PROCESS_DETACH:
  49. if(hHeap) {
  50. HeapDestroy(hHeap);
  51. }
  52. TlsFree(dwTlsIndex);
  53. break;
  54. }
  55. return bRet;
  56. }
  57. PFAMILY_TABLE DpmInitFamTable(PFAMILY_TABLE pgDpmFamTbl,
  58. HMODULE hMod,
  59. PVOID hSdb,
  60. PVOID pSdbQuery,
  61. LPWSTR pwszAppFilePath,
  62. PDPMMODULESETS pModSet)
  63. {
  64. int i, numApis, len;
  65. PVOID lpdpmfn;
  66. PFAMILY_TABLE pFT = NULL;
  67. PVOID *pFN = NULL;
  68. PVOID *pShimTbl = NULL;
  69. PAPIDESC pApiDesc = NULL;
  70. VDMTABLE VdmTbl;
  71. char szShimEng[MAX_PATH];
  72. HMODULE hModShimEng = NULL;
  73. LPFNSE_SHIMNTVDM lpShimNtvdm;
  74. DPMDBGPRN("NTVDM::DpmfPrf:Initialziing File I/O API tables\n");
  75. // Get hooked API count from global table
  76. numApis = pgDpmFamTbl->numHookedAPIs;
  77. // Allocate a new family table
  78. pFT = (PFAMILY_TABLE)HeapAlloc(hHeap,
  79. HEAP_ZERO_MEMORY,
  80. sizeof(FAMILY_TABLE));
  81. if(!pFT) {
  82. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:malloc 1 failed\n");
  83. goto ErrorExit;
  84. }
  85. // Allocate the shim dispatch table for this family in this task
  86. pShimTbl = (PVOID *)HeapAlloc(hHeap,
  87. HEAP_ZERO_MEMORY,
  88. numApis * sizeof(PVOID));
  89. if(!pShimTbl) {
  90. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:malloc 2 failed\n");
  91. goto ErrorExit;
  92. }
  93. pFT->pDpmShmTbls = pShimTbl;
  94. // Allocate an array of ptrs to hooked API's
  95. pFN = (PVOID *)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, numApis * sizeof(PVOID));
  96. if(!pFN) {
  97. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:malloc 3 failed\n");
  98. goto ErrorExit;
  99. }
  100. pFT->pfn = pFN;
  101. pFT->numHookedAPIs = numApis;
  102. pFT->hMod = hMod;
  103. // Allocate a temp array of APIDESC structs to help attach shims
  104. pApiDesc = (PAPIDESC)HeapAlloc(hHeap,
  105. HEAP_ZERO_MEMORY,
  106. numApis * sizeof(APIDESC));
  107. if(!pApiDesc) {
  108. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:malloc 4 failed\n");
  109. goto ErrorExit;
  110. }
  111. VdmTbl.nApiCount = numApis;
  112. VdmTbl.ppfnOrig = pShimTbl;
  113. VdmTbl.pApiDesc = pApiDesc;
  114. // Fill in the family table with ptrs to the patch functions in this DLL.
  115. for(i = 0; i < numApis; i++) {
  116. // must start with 1 since EXPORT ordinals can't be == 0
  117. lpdpmfn = (PVOID)GetProcAddress(hMod, (LPCSTR)MAKELONG(i+1, 0));
  118. if(!lpdpmfn) {
  119. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:Unable to get proc address\n");
  120. goto ErrorExit;
  121. }
  122. // save ptr to the real API in the shim table until it gets shimmed
  123. pShimTbl[i] = pgDpmFamTbl->pfn[i];
  124. // relate the corresponding module and API name to the API function ptr
  125. pApiDesc[i].pszModule = (char *)pModSet->ApiModuleName;
  126. pApiDesc[i].pszApi = (char *)pModSet->ApiNames[i];
  127. // save ptr to the patch function
  128. pFN[i] = lpdpmfn;
  129. }
  130. // Only do this if we need to attach the shim engine.
  131. GetSystemDirectory(szShimEng, MAX_PATH);
  132. strcat(szShimEng, szShimEngDll);
  133. hModShimEng = LoadLibrary(szShimEng);
  134. pFT->hModShimEng = hModShimEng;
  135. if(NULL == hModShimEng) {
  136. DPMDBGPRN("NTVDM::dpmfprf:DpmInit:ShimEng load failed\n");
  137. goto ErrorExit;
  138. }
  139. lpShimNtvdm = (LPFNSE_SHIMNTVDM)GetProcAddress(hModShimEng, "SE_ShimNTVDM");
  140. if(!lpShimNtvdm) {
  141. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:GetProcAddress failed\n");
  142. goto ErrorExit;
  143. }
  144. // Patch the shim dispatch table with the shim function ptrs
  145. // If this fails we will stick with ptrs to the original API's
  146. (lpShimNtvdm)(pwszAppFilePath, hSdb, pSdbQuery, &VdmTbl);
  147. // Do this if you want dispatch directly to the shim functions
  148. // for(i = 0; i < numApis; i++) {
  149. // pFN[i] = pShimTbl[i];
  150. // }
  151. // HeapFree(hHeap, 0, pShimTbl);
  152. // pFT->pDpmShmTbls = NULL;
  153. if(!TlsSetValue(dwTlsIndex, pFT)) {
  154. DPMDBGPRN("NTVDM::DpmfPrf:DpmInit:TLS set failed\n");
  155. goto ErrorExit;
  156. }
  157. if(pApiDesc) {
  158. HeapFree(hHeap, 0, pApiDesc);
  159. }
  160. DPMDBGPRN1(" DpmfPrf:Returning File I/o API tables: %#lx\n",pFT);
  161. return(pFT);
  162. ErrorExit:
  163. DPMDBGPRN(" DpmfPrf:Init failed: Returning NULL\n");
  164. DpmDestroyFamTable(pgDpmFamTbl, pFT);
  165. if(pApiDesc) {
  166. HeapFree(hHeap, 0, pApiDesc);
  167. }
  168. return(NULL);
  169. }
  170. void DpmDestroyFamTable(PFAMILY_TABLE pgDpmFamTbl, PFAMILY_TABLE pFT)
  171. {
  172. PVDM_TIB pVdmTib;
  173. PVOID *pShimTbl;
  174. LPFNSE_REMOVENTVDM lpfnSE_RemoveNtvdmTask = NULL;
  175. DPMDBGPRN("NTVDM::DpmfPrf:Destroying Profile API tables for task\n");
  176. // if this task is using the global table for this family, nothing to do
  177. if(!pFT || pFT == pgDpmFamTbl)
  178. return;
  179. pShimTbl = pFT->pDpmShmTbls;
  180. if(pShimTbl) {
  181. HeapFree(hHeap, 0, pShimTbl);
  182. }
  183. if(pFT->pfn) {
  184. HeapFree(hHeap, 0, pFT->pfn);
  185. }
  186. // See if the shim engine is attached & detach it
  187. if(pFT->hModShimEng) {
  188. lpfnSE_RemoveNtvdmTask =
  189. (LPFNSE_REMOVENTVDM)GetProcAddress(pFT->hModShimEng,
  190. "SE_RemoveNTVDMTask");
  191. if(lpfnSE_RemoveNtvdmTask) {
  192. (lpfnSE_RemoveNtvdmTask)(NtCurrentTeb()->ClientId.UniqueThread);
  193. }
  194. FreeLibrary(pFT->hModShimEng);
  195. }
  196. HeapFree(hHeap, 0, pFT);
  197. }
  198. // ^^^^^^^^^^ All the above should be in every DPM module. ^^^^^^^^^^^^
  199. // vvvvvvvvvv Define module specific stuff below. vvvvvvvvvvvv
  200. ULONG dpmGetPrivateProfileInt(LPCSTR lpszSection,
  201. LPCSTR lpszEntry,
  202. int iDefault,
  203. LPCSTR lpszFileName)
  204. {
  205. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  206. ULONG ret = 0;
  207. DPMDBGPRN("GetPrivateProfileInt: ");
  208. ret = SHM_GetPrivateProfileInt(lpszSection, lpszEntry, iDefault, lpszFileName);
  209. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  210. return(ret);
  211. }
  212. ULONG dpmGetPrivateProfileString(LPCSTR lpszSection,
  213. LPCSTR lpszEntry,
  214. LPCSTR lpszDefault,
  215. LPSTR lpszRetBuf,
  216. int cbRetBuf,
  217. LPCSTR lpszFileName)
  218. {
  219. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  220. ULONG ret = 0;
  221. DPMDBGPRN("GetPrivateProfileString: ");
  222. ret = SHM_GetPrivateProfileString(lpszSection,
  223. lpszEntry,
  224. lpszDefault,
  225. lpszRetBuf,
  226. cbRetBuf,
  227. lpszFileName);
  228. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  229. return(ret);
  230. }
  231. ULONG dpmGetProfileInt(LPCSTR lpszSection, LPCSTR lpszEntry, int iDefault)
  232. {
  233. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  234. ULONG ret = 0;
  235. DPMDBGPRN("GetProfileInt: ");
  236. ret = SHM_GetProfileInt(lpszSection, lpszEntry, iDefault);
  237. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  238. return(ret);
  239. }
  240. ULONG dpmGetProfileString(LPCSTR lpszSection,
  241. LPCSTR lpszEntry,
  242. LPCSTR lpszDefault,
  243. LPSTR lpszRetBuf,
  244. int cbRetBuf)
  245. {
  246. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  247. ULONG ret = 0;
  248. DPMDBGPRN("GetProfileString: ");
  249. ret = SHM_GetProfileString(lpszSection,
  250. lpszEntry,
  251. lpszDefault,
  252. lpszRetBuf,
  253. cbRetBuf);
  254. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  255. return(ret);
  256. }
  257. ULONG dpmWritePrivateProfileString(LPCSTR lpszSection,
  258. LPCSTR lpszEntry,
  259. LPCSTR lpszString,
  260. LPCSTR lpszFileName)
  261. {
  262. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  263. ULONG ret = 0;
  264. DPMDBGPRN("WritePrivateProfileString: ");
  265. ret = SHM_WritePrivateProfileString(lpszSection,
  266. lpszEntry,
  267. lpszString,
  268. lpszFileName);
  269. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  270. return(ret);
  271. }
  272. ULONG dpmWriteProfileString(LPCSTR lpszSection,
  273. LPCSTR lpszEntry,
  274. LPCSTR lpszString)
  275. {
  276. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  277. ULONG ret = 0;
  278. DPMDBGPRN("WriteProfileString: ");
  279. ret = SHM_WriteProfileString(lpszSection,
  280. lpszEntry,
  281. lpszString);
  282. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  283. return(ret);
  284. }
  285. ULONG dpmWritePrivateProfileSection(LPCSTR lpszSection,
  286. LPCSTR lpszString,
  287. LPCSTR lpszFileName)
  288. {
  289. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  290. ULONG ret = 0;
  291. DPMDBGPRN("WritePrivateProfileSection: ");
  292. ret = SHM_WritePrivateProfileSection(lpszSection,
  293. lpszString,
  294. lpszFileName);
  295. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  296. return(ret);
  297. }
  298. ULONG dpmGetPrivateProfileSection(LPCSTR lpszSection,
  299. LPSTR lpszRetString,
  300. DWORD dwSize,
  301. LPCSTR lpszFileName)
  302. {
  303. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  304. ULONG ret = 0;
  305. DPMDBGPRN("GetPrivateProfileSection: ");
  306. ret = SHM_GetPrivateProfileSection(lpszSection,
  307. lpszRetString,
  308. dwSize,
  309. lpszFileName);
  310. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  311. return(ret);
  312. }
  313. ULONG dpmGetProfileSection(LPCSTR lpszSection,
  314. LPSTR lpszRetString,
  315. DWORD dwSize)
  316. {
  317. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  318. ULONG ret = 0;
  319. DPMDBGPRN("GetProfileSection: ");
  320. ret = SHM_GetProfileSection(lpszSection,
  321. lpszRetString,
  322. dwSize);
  323. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  324. return(ret);
  325. }
  326. ULONG dpmGetPrivateProfileSectionNames(LPSTR lpszRetBuf,
  327. DWORD dwSize,
  328. LPCSTR lpszFileName)
  329. {
  330. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  331. ULONG ret = 0;
  332. DPMDBGPRN("GetPrivateProfileSectionNames: ");
  333. ret = SHM_GetPrivateProfileSectionNames(lpszRetBuf,
  334. dwSize,
  335. lpszFileName);
  336. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  337. return(ret);
  338. }
  339. /* This isn't an API
  340. ULONG dpmGetProfileSectionNames(LPSTR lpszRetBuf, DWORD dwSize)
  341. {
  342. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  343. ULONG ret = 0;
  344. DPMDBGPRN("GetProfileSectionNames: ");
  345. ret = SHM_GetProfileSectionNames(lpszRetBuf,
  346. dwSize);
  347. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  348. return(ret);
  349. }
  350. */
  351. ULONG dpmGetPrivateProfileStruct(LPCSTR lpszSection,
  352. LPCSTR lpszKey,
  353. LPVOID lpStruct,
  354. UINT cbSize,
  355. LPCSTR lpszFileName)
  356. {
  357. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  358. ULONG ret = 0;
  359. DPMDBGPRN("GetPrivateProfileStruct: ");
  360. ret = SHM_GetPrivateProfileStruct(lpszSection,
  361. lpszKey,
  362. lpStruct,
  363. cbSize,
  364. lpszFileName);
  365. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  366. return(ret);
  367. }
  368. ULONG dpmWritePrivateProfileStruct(LPCSTR lpszSection,
  369. LPCSTR lpszKey,
  370. LPVOID lpStruct,
  371. UINT cbSize,
  372. LPCSTR lpszFileName)
  373. {
  374. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  375. ULONG ret = 0;
  376. DPMDBGPRN("WritePrivateProfileStruct: ");
  377. ret = SHM_WritePrivateProfileStruct(lpszSection,
  378. lpszKey,
  379. lpStruct,
  380. cbSize,
  381. lpszFileName);
  382. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  383. return(ret);
  384. }
  385. ULONG dpmWriteProfileSection(LPCSTR lpszSection, LPCSTR lpszString)
  386. {
  387. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  388. ULONG ret = 0;
  389. DPMDBGPRN("WriteProfileSection: ");
  390. ret = SHM_WriteProfileSection(lpszSection,
  391. lpszString);
  392. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  393. return(ret);
  394. }
  395. ULONG dpmGetPrivateProfileIntW(LPCWSTR lpszSection,
  396. LPCWSTR lpszEntry,
  397. int iDefault,
  398. LPCWSTR lpszFileName)
  399. {
  400. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  401. ULONG ret = 0;
  402. DPMDBGPRN("GetPrivateProfileIntW ");
  403. ret = SHM_GetPrivateProfileIntW(lpszSection, lpszEntry, iDefault, lpszFileName);
  404. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  405. return(ret);
  406. }
  407. ULONG dpmGetPrivateProfileStringW(LPCWSTR lpszSection,
  408. LPCWSTR lpszEntry,
  409. LPCWSTR lpszDefault,
  410. LPWSTR lpszRetBuf,
  411. int cbRetBuf,
  412. LPCWSTR lpszFileName)
  413. {
  414. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  415. ULONG ret = 0;
  416. DPMDBGPRN("GetPrivateProfileStringW ");
  417. ret = SHM_GetPrivateProfileStringW(lpszSection,
  418. lpszEntry,
  419. lpszDefault,
  420. lpszRetBuf,
  421. cbRetBuf,
  422. lpszFileName);
  423. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  424. return(ret);
  425. }
  426. ULONG dpmGetProfileIntW(LPCWSTR lpszSection, LPCWSTR lpszEntry, int iDefault)
  427. {
  428. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  429. ULONG ret = 0;
  430. DPMDBGPRN("GetProfileIntW ");
  431. ret = SHM_GetProfileIntW(lpszSection, lpszEntry, iDefault);
  432. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  433. return(ret);
  434. }
  435. ULONG dpmGetProfileStringW(LPCWSTR lpszSection,
  436. LPCWSTR lpszEntry,
  437. LPCWSTR lpszDefault,
  438. LPWSTR lpszRetBuf,
  439. int cbRetBuf)
  440. {
  441. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  442. ULONG ret = 0;
  443. DPMDBGPRN("GetProfileStringW ");
  444. ret = SHM_GetProfileStringW(lpszSection,
  445. lpszEntry,
  446. lpszDefault,
  447. lpszRetBuf,
  448. cbRetBuf);
  449. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  450. return(ret);
  451. }
  452. ULONG dpmWritePrivateProfileStringW(LPCWSTR lpszSection,
  453. LPCWSTR lpszEntry,
  454. LPCWSTR lpszString,
  455. LPCWSTR lpszFileName)
  456. {
  457. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  458. ULONG ret = 0;
  459. DPMDBGPRN("WritePrivateProfileStringW ");
  460. ret = SHM_WritePrivateProfileStringW(lpszSection,
  461. lpszEntry,
  462. lpszString,
  463. lpszFileName);
  464. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  465. return(ret);
  466. }
  467. ULONG dpmWriteProfileStringW(LPCWSTR lpszSection,
  468. LPCWSTR lpszEntry,
  469. LPCWSTR lpszString)
  470. {
  471. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  472. ULONG ret = 0;
  473. DPMDBGPRN("WriteProfileStringW ");
  474. ret = SHM_WriteProfileStringW(lpszSection,
  475. lpszEntry,
  476. lpszString);
  477. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  478. return(ret);
  479. }
  480. ULONG dpmWritePrivateProfileSectionW(LPCWSTR lpszSection,
  481. LPCWSTR lpszString,
  482. LPCWSTR lpszFileName)
  483. {
  484. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  485. ULONG ret = 0;
  486. DPMDBGPRN("WritePrivateProfileSectionW ");
  487. ret = SHM_WritePrivateProfileSectionW(lpszSection,
  488. lpszString,
  489. lpszFileName);
  490. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  491. return(ret);
  492. }
  493. ULONG dpmGetPrivateProfileSectionW(LPCWSTR lpszSection,
  494. LPWSTR lpszRetString,
  495. DWORD dwSize,
  496. LPCWSTR lpszFileName)
  497. {
  498. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  499. ULONG ret = 0;
  500. DPMDBGPRN("GetPrivateProfileSectionW ");
  501. ret = SHM_GetPrivateProfileSectionW(lpszSection,
  502. lpszRetString,
  503. dwSize,
  504. lpszFileName);
  505. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  506. return(ret);
  507. }
  508. ULONG dpmGetProfileSectionW(LPCWSTR lpszSection,
  509. LPWSTR lpszRetString,
  510. DWORD dwSize)
  511. {
  512. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  513. ULONG ret = 0;
  514. DPMDBGPRN("GetProfileSectionW ");
  515. ret = SHM_GetProfileSectionW(lpszSection,
  516. lpszRetString,
  517. dwSize);
  518. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  519. return(ret);
  520. }
  521. ULONG dpmGetPrivateProfileSectionNamesW(LPWSTR lpszRetBuf,
  522. DWORD dwSize,
  523. LPCWSTR lpszFileName)
  524. {
  525. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  526. ULONG ret = 0;
  527. DPMDBGPRN("GetPrivateProfileSectionNamesW ");
  528. ret = SHM_GetPrivateProfileSectionNamesW(lpszRetBuf,
  529. dwSize,
  530. lpszFileName);
  531. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  532. return(ret);
  533. }
  534. ULONG dpmGetPrivateProfileStructW(LPCWSTR lpszSection,
  535. LPCWSTR lpszKey,
  536. LPVOID lpStruct,
  537. UINT cbSize,
  538. LPCWSTR lpszFileName)
  539. {
  540. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  541. ULONG ret = 0;
  542. DPMDBGPRN("GetPrivateProfileStructW ");
  543. ret = SHM_GetPrivateProfileStructW(lpszSection,
  544. lpszKey,
  545. lpStruct,
  546. cbSize,
  547. lpszFileName);
  548. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  549. return(ret);
  550. }
  551. ULONG dpmWritePrivateProfileStructW(LPCWSTR lpszSection,
  552. LPCWSTR lpszKey,
  553. LPVOID lpStruct,
  554. UINT cbSize,
  555. LPCWSTR lpszFileName)
  556. {
  557. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  558. ULONG ret = 0;
  559. DPMDBGPRN("WritePrivateProfileStructW ");
  560. ret = SHM_WritePrivateProfileStructW(lpszSection,
  561. lpszKey,
  562. lpStruct,
  563. cbSize,
  564. lpszFileName);
  565. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  566. return(ret);
  567. }
  568. ULONG dpmWriteProfileSectionW(LPCWSTR lpszSection, LPCWSTR lpszString)
  569. {
  570. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  571. ULONG ret = 0;
  572. DPMDBGPRN("WriteProfileSectionW ");
  573. ret = SHM_WriteProfileSectionW(lpszSection,
  574. lpszString);
  575. DPMDBGPRN1(" -> %d\n", ((int)(ret)));
  576. return(ret);
  577. }