mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[ADVAPI32_VISTA] Introduce this module to hold Vista+ exports that we need to provide. CORE-10536
svn path=/trunk/; revision=69903
This commit is contained in:
parent
071b9d445b
commit
6eff4a799b
6 changed files with 149 additions and 0 deletions
|
@ -4,6 +4,7 @@ add_subdirectory(aclui)
|
|||
add_subdirectory(activeds)
|
||||
add_subdirectory(actxprxy)
|
||||
add_subdirectory(advapi32)
|
||||
add_subdirectory(advapi32_vista)
|
||||
add_subdirectory(advpack)
|
||||
add_subdirectory(atl)
|
||||
add_subdirectory(atl100)
|
||||
|
|
17
reactos/dll/win32/advapi32_vista/CMakeLists.txt
Normal file
17
reactos/dll/win32/advapi32_vista/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
|
||||
add_definitions(-D_WIN32_WINNT=0x600 -DWINVER=0x600)
|
||||
|
||||
add_definitions(-D_ADVAPI32_)
|
||||
spec2def(advapi32_vista.dll advapi32_vista.spec ADD_IMPORTLIB)
|
||||
|
||||
list(APPEND SOURCE
|
||||
DllMain.c
|
||||
RegDeleteTree.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/advapi32_vista.def)
|
||||
|
||||
add_library(advapi32_vista SHARED ${SOURCE})
|
||||
set_module_type(advapi32_vista win32dll ENTRYPOINT DllMain 12)
|
||||
add_importlibs(advapi32_vista advapi32 kernel32 ntdll)
|
||||
add_dependencies(advapi32_vista psdk)
|
||||
add_cd_file(TARGET advapi32_vista DESTINATION reactos/system32 FOR all)
|
14
reactos/dll/win32/advapi32_vista/DllMain.c
Normal file
14
reactos/dll/win32/advapi32_vista/DllMain.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
#include "advapi32_vista.h"
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
DllMain(HANDLE hDll,
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
/* For now, there isn't much to do */
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
DisableThreadLibraryCalls(hDll);
|
||||
return TRUE;
|
||||
}
|
102
reactos/dll/win32/advapi32_vista/RegDeleteTree.c
Normal file
102
reactos/dll/win32/advapi32_vista/RegDeleteTree.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
#include "advapi32_vista.h"
|
||||
|
||||
/* heap allocation helpers */
|
||||
static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
|
||||
static inline void *heap_alloc( size_t len )
|
||||
{
|
||||
return HeapAlloc( GetProcessHeap(), 0, len );
|
||||
}
|
||||
|
||||
static inline BOOL heap_free( void *mem )
|
||||
{
|
||||
return HeapFree( GetProcessHeap(), 0, mem );
|
||||
}
|
||||
|
||||
/* Taken from Wine advapi32/registry.c */
|
||||
|
||||
/******************************************************************************
|
||||
* RegDeleteTreeW [ADVAPI32.@]
|
||||
*
|
||||
*/
|
||||
LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
|
||||
{
|
||||
LONG ret;
|
||||
DWORD dwMaxSubkeyLen, dwMaxValueLen;
|
||||
DWORD dwMaxLen, dwSize;
|
||||
WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
|
||||
HKEY hSubKey = hKey;
|
||||
|
||||
if(lpszSubKey)
|
||||
{
|
||||
ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
|
||||
if (ret) return ret;
|
||||
}
|
||||
|
||||
/* Get highest length for keys, values */
|
||||
ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
|
||||
&dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
|
||||
if (ret) goto cleanup;
|
||||
|
||||
dwMaxSubkeyLen++;
|
||||
dwMaxValueLen++;
|
||||
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
|
||||
if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
|
||||
{
|
||||
/* Name too big: alloc a buffer for it */
|
||||
if (!(lpszName = heap_alloc( dwMaxLen*sizeof(WCHAR))))
|
||||
{
|
||||
ret = ERROR_NOT_ENOUGH_MEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Recursively delete all the subkeys */
|
||||
while (TRUE)
|
||||
{
|
||||
dwSize = dwMaxLen;
|
||||
if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
|
||||
NULL, NULL, NULL)) break;
|
||||
|
||||
ret = RegDeleteTreeW(hSubKey, lpszName);
|
||||
if (ret) goto cleanup;
|
||||
}
|
||||
|
||||
if (lpszSubKey)
|
||||
ret = RegDeleteKeyW(hKey, lpszSubKey);
|
||||
else
|
||||
while (TRUE)
|
||||
{
|
||||
dwSize = dwMaxLen;
|
||||
if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
|
||||
NULL, NULL, NULL, NULL)) break;
|
||||
|
||||
ret = RegDeleteValueW(hKey, lpszName);
|
||||
if (ret) goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
/* Free buffer if allocated */
|
||||
if (lpszName != szNameBuf)
|
||||
heap_free( lpszName);
|
||||
if(lpszSubKey)
|
||||
RegCloseKey(hSubKey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* RegDeleteTreeA [ADVAPI32.@]
|
||||
*
|
||||
*/
|
||||
LSTATUS WINAPI RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
|
||||
{
|
||||
LONG ret;
|
||||
UNICODE_STRING lpszSubKeyW;
|
||||
|
||||
if (lpszSubKey) RtlCreateUnicodeStringFromAsciiz( &lpszSubKeyW, lpszSubKey);
|
||||
else lpszSubKeyW.Buffer = NULL;
|
||||
ret = RegDeleteTreeW( hKey, lpszSubKeyW.Buffer);
|
||||
RtlFreeUnicodeString( &lpszSubKeyW );
|
||||
return ret;
|
||||
}
|
12
reactos/dll/win32/advapi32_vista/advapi32_vista.h
Normal file
12
reactos/dll/win32/advapi32_vista/advapi32_vista.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* PSDK/NDK Headers */
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winreg.h>
|
||||
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
/* EOF */
|
3
reactos/dll/win32/advapi32_vista/advapi32_vista.spec
Normal file
3
reactos/dll/win32/advapi32_vista/advapi32_vista.spec
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
@ stdcall RegDeleteTreeA(long str)
|
||||
@ stdcall RegDeleteTreeW(long wstr)
|
Loading…
Reference in a new issue