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.

1450 lines
30 KiB

  1. //************************************************************************
  2. //
  3. // dpmfreg.c : Dynamic Patch Module for Registry API family
  4. //
  5. // History:
  6. // 12-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::DpmfReg:Can't initialize heap!\n");
  40. bRet = FALSE;
  41. }
  42. dwTlsIndex = TlsAlloc();
  43. if(dwTlsIndex == TLS_OUT_OF_INDEXES) {
  44. DPMDBGPRN("NTVDM::DpmfReg: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::DpmfReg: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::DpmfReg: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::DpmfReg: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::DpmfReg: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::DpmfReg: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::DpmfReg: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::dpmfreg:DpmInit:ShimEng load failed\n");
  137. goto ErrorExit;
  138. }
  139. lpShimNtvdm = (LPFNSE_SHIMNTVDM)GetProcAddress(hModShimEng, "SE_ShimNTVDM");
  140. if(!lpShimNtvdm) {
  141. DPMDBGPRN("NTVDM::dpmfreg:DpmInit:GetProcAddress failed\n");
  142. goto ErrorExit;
  143. }
  144. lpShimNtvdm = (LPFNSE_SHIMNTVDM)GetProcAddress(hModShimEng, "SE_ShimNTVDM");
  145. if(!lpShimNtvdm) {
  146. DPMDBGPRN("NTVDM::DpmfReg:DpmInit:GetProcAddress failed\n");
  147. goto ErrorExit;
  148. }
  149. // Patch the shim dispatch table with the shim function ptrs
  150. // If this fails we will stick with ptrs to the original API's
  151. (lpShimNtvdm)(pwszAppFilePath, hSdb, pSdbQuery, &VdmTbl);
  152. // Do this if you want dispatch directly to the shim functions
  153. // for(i = 0; i < numApis; i++) {
  154. // pFN[i] = pShimTbl[i];
  155. // }
  156. // HeapFree(hHeap, 0, pShimTbl);
  157. // pFT->pDpmShmTbls = NULL;
  158. if(!TlsSetValue(dwTlsIndex, pFT)) {
  159. DPMDBGPRN("NTVDM::DpmfReg:DpmInit:TLS set failed\n");
  160. goto ErrorExit;
  161. }
  162. if(pApiDesc) {
  163. HeapFree(hHeap, 0, pApiDesc);
  164. }
  165. DPMDBGPRN1(" DpmfReg:Returning File I/o API tables: %#lx\n",pFT);
  166. return(pFT);
  167. ErrorExit:
  168. DPMDBGPRN(" DpmfReg:Init failed: Returning NULL\n");
  169. DpmDestroyFamTable(pgDpmFamTbl, pFT);
  170. if(pApiDesc) {
  171. HeapFree(hHeap, 0, pApiDesc);
  172. }
  173. return(NULL);
  174. }
  175. void DpmDestroyFamTable(PFAMILY_TABLE pgDpmFamTbl, PFAMILY_TABLE pFT)
  176. {
  177. PVDM_TIB pVdmTib;
  178. PVOID *pShimTbl;
  179. LPFNSE_REMOVENTVDM lpfnSE_RemoveNtvdmTask = NULL;
  180. DPMDBGPRN("NTVDM::DpmfReg:Destroying Registry API tables for task\n");
  181. // if this task is using the global table for this family, nothing to do
  182. if(!pFT || pFT == pgDpmFamTbl)
  183. return;
  184. pShimTbl = pFT->pDpmShmTbls;
  185. if(pShimTbl) {
  186. HeapFree(hHeap, 0, pShimTbl);
  187. }
  188. if(pFT->pfn) {
  189. HeapFree(hHeap, 0, pFT->pfn);
  190. }
  191. // See if the shim engine is attached & detach it
  192. if(pFT->hModShimEng) {
  193. lpfnSE_RemoveNtvdmTask =
  194. (LPFNSE_REMOVENTVDM)GetProcAddress(pFT->hModShimEng,
  195. "SE_RemoveNTVDMTask");
  196. if(lpfnSE_RemoveNtvdmTask) {
  197. (lpfnSE_RemoveNtvdmTask)(NtCurrentTeb()->ClientId.UniqueThread);
  198. }
  199. FreeLibrary(pFT->hModShimEng);
  200. }
  201. HeapFree(hHeap, 0, pFT);
  202. }
  203. // ^^^^^^^^^^ All the above should be in every DPM module. ^^^^^^^^^^^^
  204. // vvvvvvvvvv Define module specific stuff below. vvvvvvvvvvvv
  205. ULONG dpmRegCloseKey(HKEY hKey)
  206. {
  207. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  208. ULONG ret = 0;
  209. DPMDBGPRN("RegCloseKey: ");
  210. ret = SHM_RegCloseKey(hKey);
  211. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  212. return(ret);
  213. }
  214. ULONG dpmRegCreateKey(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
  215. {
  216. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  217. ULONG ret = 0;
  218. DPMDBGPRN("RegCreateKey: ");
  219. ret = SHM_RegCreateKey(hKey, lpSubKey, phkResult);
  220. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  221. return(ret);
  222. }
  223. ULONG dpmRegDeleteKey(HKEY hKey, LPCSTR lpSubKey)
  224. {
  225. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  226. ULONG ret = 0;
  227. DPMDBGPRN("RegDeleteKey: ");
  228. ret = SHM_RegDeleteKey(hKey, lpSubKey);
  229. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  230. return(ret);
  231. }
  232. ULONG dpmRegEnumKey(HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cchName)
  233. {
  234. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  235. ULONG ret = 0;
  236. DPMDBGPRN("RegEnumKey: ");
  237. ret = SHM_RegEnumKey(hKey, dwIndex, lpName, cchName);
  238. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  239. return(ret);
  240. }
  241. ULONG dpmRegOpenKey(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
  242. {
  243. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  244. ULONG ret = 0;
  245. DPMDBGPRN("RegOpenKey: ");
  246. ret = SHM_RegOpenKey(hKey, lpSubKey, phkResult);
  247. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  248. return(ret);
  249. }
  250. ULONG dpmRegQueryValue(HKEY hKey,
  251. LPCSTR lpSubKey,
  252. LPSTR lpValue,
  253. PLONG lpcbValue)
  254. {
  255. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  256. ULONG ret = 0;
  257. DPMDBGPRN("RegQueryValue: ");
  258. ret = SHM_RegQueryValue(hKey, lpSubKey, lpValue, lpcbValue);
  259. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  260. return(ret);
  261. }
  262. ULONG dpmRegSetValue(HKEY hKey,
  263. LPCSTR lpSubKey,
  264. DWORD dwType,
  265. LPCSTR lpData,
  266. DWORD cbData)
  267. {
  268. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  269. ULONG ret = 0;
  270. DPMDBGPRN("RegSetValue: ");
  271. ret = SHM_RegSetValue(hKey, lpSubKey, dwType, lpData, cbData);
  272. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  273. return(ret);
  274. }
  275. ULONG dpmRegDeleteValue(HKEY hKey, LPCSTR lpValueName)
  276. {
  277. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  278. ULONG ret = 0;
  279. DPMDBGPRN("RegDeleteValue: ");
  280. ret = SHM_RegDeleteValue(hKey, lpValueName);
  281. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  282. return(ret);
  283. }
  284. ULONG dpmRegEnumValue(HKEY hKey,
  285. DWORD dwIndex,
  286. LPSTR lpValueName,
  287. LPDWORD lpcValueName,
  288. LPDWORD lpReserved,
  289. LPDWORD lpType,
  290. LPBYTE lpData,
  291. LPDWORD lpcbData)
  292. {
  293. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  294. ULONG ret = 0;
  295. DPMDBGPRN("RegEnumValue: ");
  296. ret = SHM_RegEnumValue(hKey,
  297. dwIndex,
  298. lpValueName,
  299. lpcValueName,
  300. lpReserved,
  301. lpType,
  302. lpData,
  303. lpcbData);
  304. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  305. return(ret);
  306. }
  307. ULONG dpmRegFlushKey(HKEY hKey)
  308. {
  309. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  310. ULONG ret = 0;
  311. DPMDBGPRN("RegFlushKey: ");
  312. ret = SHM_RegFlushKey(hKey);
  313. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  314. return(ret);
  315. }
  316. ULONG dpmRegLoadKey(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile)
  317. {
  318. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  319. ULONG ret = 0;
  320. DPMDBGPRN("RegLoadKey: ");
  321. ret = SHM_RegLoadKey(hKey, lpSubKey, lpFile);
  322. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  323. return(ret);
  324. }
  325. ULONG dpmRegQueryValueEx(HKEY hKey,
  326. LPCSTR lpValueName,
  327. LPDWORD lpReserved,
  328. LPDWORD lpType,
  329. LPBYTE lpData,
  330. LPDWORD lpcbData)
  331. {
  332. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  333. ULONG ret = 0;
  334. DPMDBGPRN("RegQueryValueEx: ");
  335. ret = SHM_RegQueryValueEx(hKey,
  336. lpValueName,
  337. lpReserved,
  338. lpType,
  339. lpData,
  340. lpcbData);
  341. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  342. return(ret);
  343. }
  344. ULONG dpmRegSaveKey(HKEY hKey,
  345. LPCSTR lpFile,
  346. LPSECURITY_ATTRIBUTES lpSecurityAttributes)
  347. {
  348. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  349. ULONG ret = 0;
  350. DPMDBGPRN("RegSaveKey: ");
  351. ret = SHM_RegSaveKey(hKey, lpFile, lpSecurityAttributes);
  352. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  353. return(ret);
  354. }
  355. ULONG dpmRegSetValueEx(HKEY hKey,
  356. LPCSTR lpValueName,
  357. DWORD Reserved,
  358. DWORD dwType,
  359. CONST BYTE *lpData,
  360. DWORD cbData)
  361. {
  362. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  363. ULONG ret = 0;
  364. DPMDBGPRN("RegSetValueEx: ");
  365. ret = SHM_RegSetValueEx(hKey, lpValueName, Reserved, dwType, lpData, cbData);
  366. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  367. return(ret);
  368. }
  369. ULONG dpmRegUnLoadKey(HKEY hKey, LPCSTR lpSubKey)
  370. {
  371. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  372. ULONG ret = 0;
  373. DPMDBGPRN("RegUnLoadKey: ");
  374. ret = SHM_RegUnLoadKey(hKey, lpSubKey);
  375. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  376. return(ret);
  377. }
  378. ULONG dpmRegConnectRegistry(LPCSTR lpMachineName,
  379. HKEY hKey,
  380. PHKEY phkResult)
  381. {
  382. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  383. ULONG ret = 0;
  384. DPMDBGPRN("RegConnectRegistry: ");
  385. ret = SHM_RegConnectRegistry(lpMachineName, hKey, phkResult);
  386. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  387. return(ret);
  388. }
  389. ULONG dpmRegCreateKeyEx(HKEY hKey,
  390. LPCSTR lpSubKey,
  391. DWORD dwReserved,
  392. LPSTR lpClass,
  393. DWORD dwOptions,
  394. REGSAM samDesired,
  395. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  396. PHKEY phkResult,
  397. LPDWORD lpdwDisposition)
  398. {
  399. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  400. ULONG ret = 0;
  401. DPMDBGPRN("RegCreateKeyEx: ");
  402. ret = SHM_RegCreateKeyEx(hKey,
  403. lpSubKey,
  404. dwReserved,
  405. lpClass,
  406. dwOptions,
  407. samDesired,
  408. lpSecurityAttributes,
  409. phkResult,
  410. lpdwDisposition);
  411. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  412. return(ret);
  413. }
  414. ULONG dpmRegEnumKeyEx(HKEY hKey,
  415. DWORD dwIndex,
  416. LPSTR lpName,
  417. LPDWORD lpcName,
  418. LPDWORD lpReserved,
  419. LPSTR lpClass,
  420. LPDWORD lpcClass,
  421. PFILETIME lpftLastWriteTime)
  422. {
  423. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  424. ULONG ret = 0;
  425. DPMDBGPRN("RegEnumKeyEx: ");
  426. ret = SHM_RegEnumKeyEx(hKey,
  427. dwIndex,
  428. lpName,
  429. lpcName,
  430. lpReserved,
  431. lpClass,
  432. lpcClass,
  433. lpftLastWriteTime);
  434. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  435. return(ret);
  436. }
  437. ULONG dpmRegNotifyChangeKeyValue(HKEY hKey,
  438. BOOL bWatchSubtree,
  439. DWORD dwNotifyFilter,
  440. HANDLE hEvent,
  441. BOOL fAsynchronous)
  442. {
  443. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  444. ULONG ret = 0;
  445. DPMDBGPRN("RegNotifyChangeKeyValue: ");
  446. ret = SHM_RegNotifyChangeKeyValue(hKey,
  447. bWatchSubtree,
  448. dwNotifyFilter,
  449. hEvent,
  450. fAsynchronous);
  451. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  452. return(ret);
  453. }
  454. ULONG dpmRegOpenKeyEx(HKEY hKey,
  455. LPCSTR lpSubKey,
  456. DWORD ulOptions,
  457. REGSAM samDesired,
  458. PHKEY phkResult)
  459. {
  460. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  461. ULONG ret = 0;
  462. DPMDBGPRN("RegOpenKeyEx: ");
  463. ret = SHM_RegOpenKeyEx(hKey, lpSubKey, ulOptions, samDesired, phkResult);
  464. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  465. return(ret);
  466. }
  467. ULONG dpmRegQueryInfoKey(HKEY hKey,
  468. LPSTR lpClass,
  469. LPDWORD lpcClass,
  470. LPDWORD lpReserved,
  471. LPDWORD lpcSubKeys,
  472. LPDWORD lpcMaxSubKeyLen,
  473. LPDWORD lpcMaxClassLen,
  474. LPDWORD lpcValues,
  475. LPDWORD lpcMaxValueNameLen,
  476. LPDWORD lpcMaxValueLen,
  477. LPDWORD lpcbSecurityDescriptor,
  478. PFILETIME lpftLastWriteTime)
  479. {
  480. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  481. ULONG ret = 0;
  482. DPMDBGPRN("RegQueryInfoKey: ");
  483. ret = SHM_RegQueryInfoKey(hKey,
  484. lpClass,
  485. lpcClass,
  486. lpReserved,
  487. lpcSubKeys,
  488. lpcMaxSubKeyLen,
  489. lpcMaxClassLen,
  490. lpcValues,
  491. lpcMaxValueNameLen,
  492. lpcMaxValueLen,
  493. lpcbSecurityDescriptor,
  494. lpftLastWriteTime);
  495. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  496. return(ret);
  497. }
  498. ULONG dpmRegQueryMultipleValues(HKEY hKey,
  499. PVALENT val_list,
  500. DWORD num_vals,
  501. LPSTR lpValueBuf,
  502. LPDWORD ldwTotsize)
  503. {
  504. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  505. ULONG ret = 0;
  506. DPMDBGPRN("RegQueryMultipleValues: ");
  507. ret = SHM_RegQueryMultipleValues(hKey,
  508. val_list,
  509. num_vals,
  510. lpValueBuf,
  511. ldwTotsize);
  512. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  513. return(ret);
  514. }
  515. ULONG dpmRegReplaceKey(HKEY hKey,
  516. LPCSTR lpSubKey,
  517. LPCSTR lpNewFile,
  518. LPCSTR lpOldFile)
  519. {
  520. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  521. ULONG ret = 0;
  522. DPMDBGPRN("RegReplaceKey: ");
  523. ret = SHM_RegReplaceKey(hKey, lpSubKey, lpNewFile, lpOldFile);
  524. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  525. return(ret);
  526. }
  527. ULONG dpmRegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
  528. {
  529. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  530. ULONG ret = 0;
  531. DPMDBGPRN("RegCreateKeyW ");
  532. ret = SHM_RegCreateKeyW(hKey, lpSubKey, phkResult);
  533. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  534. return(ret);
  535. }
  536. ULONG dpmRegDeleteKeyW(HKEY hKey, LPCWSTR lpSubKey)
  537. {
  538. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  539. ULONG ret = 0;
  540. DPMDBGPRN("RegDeleteKeyW ");
  541. ret = SHM_RegDeleteKeyW(hKey, lpSubKey);
  542. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  543. return(ret);
  544. }
  545. ULONG dpmRegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cchName)
  546. {
  547. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  548. ULONG ret = 0;
  549. DPMDBGPRN("RegEnumKeyW ");
  550. ret = SHM_RegEnumKeyW(hKey, dwIndex, lpName, cchName);
  551. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  552. return(ret);
  553. }
  554. ULONG dpmRegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
  555. {
  556. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  557. ULONG ret = 0;
  558. DPMDBGPRN("RegOpenKeyW ");
  559. ret = SHM_RegOpenKeyW(hKey, lpSubKey, phkResult);
  560. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  561. return(ret);
  562. }
  563. ULONG dpmRegQueryValueW(HKEY hKey,
  564. LPCWSTR lpSubKey,
  565. LPWSTR lpValue,
  566. PLONG lpcbValue)
  567. {
  568. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  569. ULONG ret = 0;
  570. DPMDBGPRN("RegQueryValueW ");
  571. ret = SHM_RegQueryValueW(hKey, lpSubKey, lpValue, lpcbValue);
  572. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  573. return(ret);
  574. }
  575. ULONG dpmRegSetValueW(HKEY hKey,
  576. LPCWSTR lpSubKey,
  577. DWORD dwType,
  578. LPCWSTR lpData,
  579. DWORD cbData)
  580. {
  581. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  582. ULONG ret = 0;
  583. DPMDBGPRN("RegSetValueW ");
  584. ret = SHM_RegSetValueW(hKey, lpSubKey, dwType, lpData, cbData);
  585. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  586. return(ret);
  587. }
  588. ULONG dpmRegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
  589. {
  590. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  591. ULONG ret = 0;
  592. DPMDBGPRN("RegDeleteValueW ");
  593. ret = SHM_RegDeleteValueW(hKey, lpValueName);
  594. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  595. return(ret);
  596. }
  597. ULONG dpmRegEnumValueW(HKEY hKey,
  598. DWORD dwIndex,
  599. LPWSTR lpValueName,
  600. LPDWORD lpcValueName,
  601. LPDWORD lpReserved,
  602. LPDWORD lpType,
  603. LPBYTE lpData,
  604. LPDWORD lpcbData)
  605. {
  606. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  607. ULONG ret = 0;
  608. DPMDBGPRN("RegEnumValueW ");
  609. ret = SHM_RegEnumValueW(hKey,
  610. dwIndex,
  611. lpValueName,
  612. lpcValueName,
  613. lpReserved,
  614. lpType,
  615. lpData,
  616. lpcbData);
  617. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  618. return(ret);
  619. }
  620. ULONG dpmRegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
  621. {
  622. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  623. ULONG ret = 0;
  624. DPMDBGPRN("RegLoadKeyW ");
  625. ret = SHM_RegLoadKeyW(hKey, lpSubKey, lpFile);
  626. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  627. return(ret);
  628. }
  629. ULONG dpmRegQueryValueExW(HKEY hKey,
  630. LPCWSTR lpValueName,
  631. LPDWORD lpReserved,
  632. LPDWORD lpType,
  633. LPBYTE lpData,
  634. LPDWORD lpcbData)
  635. {
  636. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  637. ULONG ret = 0;
  638. DPMDBGPRN("RegQueryValueExW ");
  639. ret = SHM_RegQueryValueExW(hKey,
  640. lpValueName,
  641. lpReserved,
  642. lpType,
  643. lpData,
  644. lpcbData);
  645. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  646. return(ret);
  647. }
  648. ULONG dpmRegSaveKeyW(HKEY hKey,
  649. LPCWSTR lpFile,
  650. LPSECURITY_ATTRIBUTES lpSecurityAttributes)
  651. {
  652. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  653. ULONG ret = 0;
  654. DPMDBGPRN("RegSaveKeyW ");
  655. ret = SHM_RegSaveKeyW(hKey, lpFile, lpSecurityAttributes);
  656. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  657. return(ret);
  658. }
  659. ULONG dpmRegSetValueExW(HKEY hKey,
  660. LPCWSTR lpValueName,
  661. DWORD Reserved,
  662. DWORD dwType,
  663. CONST BYTE *lpData,
  664. DWORD cbData)
  665. {
  666. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  667. ULONG ret = 0;
  668. DPMDBGPRN("RegSetValueExW ");
  669. ret = SHM_RegSetValueExW(hKey, lpValueName, Reserved, dwType, lpData, cbData);
  670. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  671. return(ret);
  672. }
  673. ULONG dpmRegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
  674. {
  675. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  676. ULONG ret = 0;
  677. DPMDBGPRN("RegUnLoadKeyW ");
  678. ret = SHM_RegUnLoadKeyW(hKey, lpSubKey);
  679. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  680. return(ret);
  681. }
  682. ULONG dpmRegConnectRegistryW(LPCWSTR lpMachineName,
  683. HKEY hKey,
  684. PHKEY phkResult)
  685. {
  686. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  687. ULONG ret = 0;
  688. DPMDBGPRN("RegConnectRegistryW ");
  689. ret = SHM_RegConnectRegistryW(lpMachineName, hKey, phkResult);
  690. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  691. return(ret);
  692. }
  693. ULONG dpmRegCreateKeyExW(HKEY hKey,
  694. LPCWSTR lpSubKey,
  695. DWORD dwReserved,
  696. LPWSTR lpClass,
  697. DWORD dwOptions,
  698. REGSAM samDesired,
  699. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  700. PHKEY phkResult,
  701. LPDWORD lpdwDisposition)
  702. {
  703. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  704. ULONG ret = 0;
  705. DPMDBGPRN("RegCreateKeyExW ");
  706. ret = SHM_RegCreateKeyExW(hKey,
  707. lpSubKey,
  708. dwReserved,
  709. lpClass,
  710. dwOptions,
  711. samDesired,
  712. lpSecurityAttributes,
  713. phkResult,
  714. lpdwDisposition);
  715. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  716. return(ret);
  717. }
  718. ULONG dpmRegEnumKeyExW(HKEY hKey,
  719. DWORD dwIndex,
  720. LPWSTR lpName,
  721. LPDWORD lpcName,
  722. LPDWORD lpReserved,
  723. LPWSTR lpClass,
  724. LPDWORD lpcClass,
  725. PFILETIME lpftLastWriteTime)
  726. {
  727. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  728. ULONG ret = 0;
  729. DPMDBGPRN("RegEnumKeyExW ");
  730. ret = SHM_RegEnumKeyExW(hKey,
  731. dwIndex,
  732. lpName,
  733. lpcName,
  734. lpReserved,
  735. lpClass,
  736. lpcClass,
  737. lpftLastWriteTime);
  738. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  739. return(ret);
  740. }
  741. ULONG dpmRegOpenKeyExW(HKEY hKey,
  742. LPCWSTR lpSubKey,
  743. DWORD ulOptions,
  744. REGSAM samDesired,
  745. PHKEY phkResult)
  746. {
  747. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  748. ULONG ret = 0;
  749. DPMDBGPRN("RegOpenKeyExW ");
  750. ret = SHM_RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult);
  751. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  752. return(ret);
  753. }
  754. ULONG dpmRegQueryInfoKeyW(HKEY hKey,
  755. LPWSTR lpClass,
  756. LPDWORD lpcClass,
  757. LPDWORD lpReserved,
  758. LPDWORD lpcSubKeys,
  759. LPDWORD lpcMaxSubKeyLen,
  760. LPDWORD lpcMaxClassLen,
  761. LPDWORD lpcValues,
  762. LPDWORD lpcMaxValueNameLen,
  763. LPDWORD lpcMaxValueLen,
  764. LPDWORD lpcbSecurityDescriptor,
  765. PFILETIME lpftLastWriteTime)
  766. {
  767. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  768. ULONG ret = 0;
  769. DPMDBGPRN("RegQueryInfoKeyW ");
  770. ret = SHM_RegQueryInfoKeyW(hKey,
  771. lpClass,
  772. lpcClass,
  773. lpReserved,
  774. lpcSubKeys,
  775. lpcMaxSubKeyLen,
  776. lpcMaxClassLen,
  777. lpcValues,
  778. lpcMaxValueNameLen,
  779. lpcMaxValueLen,
  780. lpcbSecurityDescriptor,
  781. lpftLastWriteTime);
  782. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  783. return(ret);
  784. }
  785. ULONG dpmRegQueryMultipleValuesW(HKEY hKey,
  786. PVALENTW val_list,
  787. DWORD num_vals,
  788. LPWSTR lpValueBuf,
  789. LPDWORD ldwTotsize)
  790. {
  791. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  792. ULONG ret = 0;
  793. DPMDBGPRN("RegQueryMultipleValuesW ");
  794. ret = SHM_RegQueryMultipleValuesW(hKey,
  795. val_list,
  796. num_vals,
  797. lpValueBuf,
  798. ldwTotsize);
  799. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  800. return(ret);
  801. }
  802. ULONG dpmRegReplaceKeyW(HKEY hKey,
  803. LPCWSTR lpSubKey,
  804. LPCWSTR lpNewFile,
  805. LPCWSTR lpOldFile)
  806. {
  807. PFAMILY_TABLE pFT = (PFAMILY_TABLE)TlsGetValue(dwTlsIndex);
  808. ULONG ret = 0;
  809. DPMDBGPRN("RegReplaceKeyW ");
  810. ret = SHM_RegReplaceKeyW(hKey, lpSubKey, lpNewFile, lpOldFile);
  811. DPMDBGPRN1(" -> %s\n", RETSTR(ret));
  812. return(ret);
  813. }