Commit f4bf7185 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved 16-bit registry functions to kernel dll and implemented them by

calling up to advapi32.
parent a62a26ce
......@@ -16,6 +16,7 @@ C_SRCS = \
format_msg.c \
kernel_main.c \
locale.c \
registry16.c \
stress.c \
string.c \
sync.c \
......
/*
* 16-bit registry functions
*
* Copyright 1996 Marcus Meissner
* Copyright 1998 Matthew Becker
* Copyright 1999 Sylvain St-Germain
* Copyright 2002 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "winbase.h"
#include "winreg.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(reg);
DWORD (WINAPI *pRegCloseKey)(HKEY);
DWORD (WINAPI *pRegCreateKeyA)(HKEY,LPCSTR,LPHKEY);
DWORD (WINAPI *pRegDeleteKeyA)(HKEY,LPCSTR);
DWORD (WINAPI *pRegDeleteValueA)(HKEY,LPCSTR);
DWORD (WINAPI *pRegEnumKeyA)(HKEY,DWORD,LPSTR,DWORD);
DWORD (WINAPI *pRegEnumValueA)(HKEY,DWORD,LPSTR,LPDWORD,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
DWORD (WINAPI *pRegFlushKey)(HKEY);
DWORD (WINAPI *pRegOpenKeyA)(HKEY,LPCSTR,LPHKEY);
DWORD (WINAPI *pRegQueryValueA)(HKEY,LPCSTR,LPSTR,LPLONG);
DWORD (WINAPI *pRegQueryValueExA)(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
DWORD (WINAPI *pRegSetValueA)(HKEY,LPCSTR,DWORD,LPCSTR,DWORD);
DWORD (WINAPI *pRegSetValueExA)(HKEY,LPCSTR,DWORD,DWORD,CONST BYTE*,DWORD);
static HMODULE advapi32;
/* 0 and 1 are valid rootkeys in win16 shell.dll and are used by
* some programs. Do not remove those cases. -MM
*/
static inline void fix_win16_hkey( HKEY *hkey )
{
if (*hkey == 0 || *hkey == (HKEY)1) *hkey = HKEY_CLASSES_ROOT;
}
static void init_func_ptrs(void)
{
advapi32 = LoadLibraryA("advapi32.dll");
if (!advapi32)
{
ERR( "Unable to load advapi32.dll\n" );
ExitProcess(1);
}
#define GET_PTR(name) p##name = (void *)GetProcAddress(advapi32,#name);
GET_PTR( RegCloseKey );
GET_PTR( RegCreateKeyA );
GET_PTR( RegDeleteKeyA );
GET_PTR( RegDeleteValueA );
GET_PTR( RegEnumKeyA );
GET_PTR( RegEnumValueA );
GET_PTR( RegFlushKey );
GET_PTR( RegOpenKeyA );
GET_PTR( RegQueryValueA );
GET_PTR( RegQueryValueExA );
GET_PTR( RegSetValueA );
GET_PTR( RegSetValueExA );
#undef GET_PTR
}
/******************************************************************************
* RegEnumKey [KERNEL.216]
*/
DWORD WINAPI RegEnumKey16( HKEY hkey, DWORD index, LPSTR name, DWORD name_len )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegEnumKeyA( hkey, index, name, name_len );
}
/******************************************************************************
* RegOpenKey [KERNEL.217]
*/
DWORD WINAPI RegOpenKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegOpenKeyA( hkey, name, retkey );
}
/******************************************************************************
* RegCreateKey [KERNEL.218]
*/
DWORD WINAPI RegCreateKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegCreateKeyA( hkey, name, retkey );
}
/******************************************************************************
* RegDeleteKey [KERNEL.219]
*/
DWORD WINAPI RegDeleteKey16( HKEY hkey, LPCSTR name )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegDeleteKeyA( hkey, name );
}
/******************************************************************************
* RegCloseKey [KERNEL.220]
*/
DWORD WINAPI RegCloseKey16( HKEY hkey )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegCloseKey( hkey );
}
/******************************************************************************
* RegSetValue [KERNEL.221]
*/
DWORD WINAPI RegSetValue16( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegSetValueA( hkey, name, type, data, count );
}
/******************************************************************************
* RegDeleteValue [KERNEL.222]
*/
DWORD WINAPI RegDeleteValue16( HKEY hkey, LPSTR name )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegDeleteValueA( hkey, name );
}
/******************************************************************************
* RegEnumValue [KERNEL.223]
*/
DWORD WINAPI RegEnumValue16( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegEnumValueA( hkey, index, value, val_count, reserved, type, data, count );
}
/******************************************************************************
* RegQueryValue [KERNEL.224]
*
* NOTES
* Is this HACK still applicable?
*
* HACK
* The 16bit RegQueryValue doesn't handle selectorblocks anyway, so we just
* mask out the high 16 bit. This (not so much incidently) hopefully fixes
* Aldus FH4)
*/
DWORD WINAPI RegQueryValue16( HKEY hkey, LPCSTR name, LPSTR data, LPDWORD count )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
if (count) *count &= 0xffff;
return pRegQueryValueA( hkey, name, data, count );
}
/******************************************************************************
* RegQueryValueEx [KERNEL.225]
*/
DWORD WINAPI RegQueryValueEx16( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD type,
LPBYTE data, LPDWORD count )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegQueryValueExA( hkey, name, reserved, type, data, count );
}
/******************************************************************************
* RegSetValueEx [KERNEL.226]
*/
DWORD WINAPI RegSetValueEx16( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
CONST BYTE *data, DWORD count )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
if (!count && (type==REG_SZ)) count = strlen(data);
return pRegSetValueExA( hkey, name, reserved, type, data, count );
}
/******************************************************************************
* RegFlushKey [KERNEL.227]
*/
DWORD WINAPI RegFlushKey16( HKEY hkey )
{
if (!advapi32) init_func_ptrs();
fix_win16_hkey( &hkey );
return pRegFlushKey( hkey );
}
......@@ -1625,145 +1625,5 @@ void SHELL_LoadRegistry( void )
if (PROFILE_GetWineIniBool(RegistryW, load_home_reg_filesW, 1))
_load_home_registry( hkey_users_default );
_init_registry_saving( hkey_users_default );
RegCloseKey(hkey_users_default);
}
/***************************************************************************/
/* 16-BIT API FUNCTIONS */
/***************************************************************************/
/* 0 and 1 are valid rootkeys in win16 shell.dll and are used by
* some programs. Do not remove those cases. -MM
*/
static inline void fix_win16_hkey( HKEY *hkey )
{
if (*hkey == 0 || *hkey == (HKEY)1) *hkey = HKEY_CLASSES_ROOT;
}
/******************************************************************************
* RegEnumKey [KERNEL.216]
* RegEnumKey [SHELL.7]
*/
DWORD WINAPI RegEnumKey16( HKEY hkey, DWORD index, LPSTR name, DWORD name_len )
{
fix_win16_hkey( &hkey );
return RegEnumKeyA( hkey, index, name, name_len );
}
/******************************************************************************
* RegOpenKey [KERNEL.217]
* RegOpenKey [SHELL.1]
*/
DWORD WINAPI RegOpenKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
{
fix_win16_hkey( &hkey );
return RegOpenKeyA( hkey, name, retkey );
}
/******************************************************************************
* RegCreateKey [KERNEL.218]
* RegCreateKey [SHELL.2]
*/
DWORD WINAPI RegCreateKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
{
fix_win16_hkey( &hkey );
return RegCreateKeyA( hkey, name, retkey );
}
/******************************************************************************
* RegDeleteKey [KERNEL.219]
* RegDeleteKey [SHELL.4]
*/
DWORD WINAPI RegDeleteKey16( HKEY hkey, LPCSTR name )
{
fix_win16_hkey( &hkey );
return RegDeleteKeyA( hkey, name );
}
/******************************************************************************
* RegCloseKey [KERNEL.220]
* RegCloseKey [SHELL.3]
*/
DWORD WINAPI RegCloseKey16( HKEY hkey )
{
fix_win16_hkey( &hkey );
return RegCloseKey( hkey );
}
/******************************************************************************
* RegSetValue [KERNEL.221]
* RegSetValue [SHELL.5]
*/
DWORD WINAPI RegSetValue16( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count )
{
fix_win16_hkey( &hkey );
return RegSetValueA( hkey, name, type, data, count );
}
/******************************************************************************
* RegDeleteValue [KERNEL.222]
*/
DWORD WINAPI RegDeleteValue16( HKEY hkey, LPSTR name )
{
fix_win16_hkey( &hkey );
return RegDeleteValueA( hkey, name );
}
/******************************************************************************
* RegEnumValue [KERNEL.223]
*/
DWORD WINAPI RegEnumValue16( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count )
{
fix_win16_hkey( &hkey );
return RegEnumValueA( hkey, index, value, val_count, reserved, type, data, count );
}
/******************************************************************************
* RegQueryValue [KERNEL.224]
* RegQueryValue [SHELL.6]
*
* NOTES
* Is this HACK still applicable?
*
* HACK
* The 16bit RegQueryValue doesn't handle selectorblocks anyway, so we just
* mask out the high 16 bit. This (not so much incidently) hopefully fixes
* Aldus FH4)
*/
DWORD WINAPI RegQueryValue16( HKEY hkey, LPCSTR name, LPSTR data, LPDWORD count )
{
fix_win16_hkey( &hkey );
if (count) *count &= 0xffff;
return RegQueryValueA( hkey, name, data, count );
}
/******************************************************************************
* RegQueryValueEx [KERNEL.225]
*/
DWORD WINAPI RegQueryValueEx16( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD type,
LPBYTE data, LPDWORD count )
{
fix_win16_hkey( &hkey );
return RegQueryValueExA( hkey, name, reserved, type, data, count );
}
/******************************************************************************
* RegSetValueEx [KERNEL.226]
*/
DWORD WINAPI RegSetValueEx16( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
CONST BYTE *data, DWORD count )
{
fix_win16_hkey( &hkey );
if (!count && (type==REG_SZ)) count = strlen(data);
return RegSetValueExA( hkey, name, reserved, type, data, count );
}
/******************************************************************************
* RegFlushKey [KERNEL.227]
*/
DWORD WINAPI RegFlushKey16( HKEY hkey )
{
fix_win16_hkey( &hkey );
return RegFlushKey( hkey );
NtClose(hkey_users_default);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment