From 49c02c66349237b6b8b62321589564d2d31ab11e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 21 Nov 2003 05:28:36 +0000 Subject: Start of winreg idl. Implement OpenHKLM, GetVersion and CloseKey. (This used to be commit c8b87f5feb7756c7a5b38135517788c9f4ade36f) --- source4/Makefile.in | 8 +- source4/librpc/idl/winreg.idl | 206 ++++++++++++++++++++++++++++++++++++++++++ source4/librpc/ndr/libndr.h | 1 + source4/torture/rpc/winreg.c | 124 +++++++++++++++++++++++++ source4/torture/torture.c | 1 + 5 files changed, 337 insertions(+), 3 deletions(-) create mode 100644 source4/librpc/idl/winreg.idl create mode 100644 source4/torture/rpc/winreg.c diff --git a/source4/Makefile.in b/source4/Makefile.in index a6cc8eff266..0d577d93e10 100644 --- a/source4/Makefile.in +++ b/source4/Makefile.in @@ -199,14 +199,15 @@ LIBRAW_NDR_OBJ = librpc/ndr/ndr.o librpc/ndr/ndr_basic.o librpc/ndr/ndr_sec.o \ librpc/gen_ndr/ndr_lsa.o librpc/gen_ndr/ndr_dfs.o \ librpc/gen_ndr/ndr_samr.o librpc/gen_ndr/ndr_spoolss.o \ librpc/gen_ndr/ndr_wkssvc.o librpc/gen_ndr/ndr_srvsvc.o \ - librpc/gen_ndr/ndr_atsvc.o librpc/gen_ndr/ndr_eventlog.o + librpc/gen_ndr/ndr_atsvc.o librpc/gen_ndr/ndr_eventlog.o \ + librpc/gen_ndr/ndr_winreg.o LIBRAW_RPC_OBJ = librpc/rpc/dcerpc.o librpc/rpc/dcerpc_smb.o \ librpc/gen_rpc/rpc_echo.o librpc/gen_rpc/rpc_lsa.o \ librpc/gen_rpc/rpc_dfs.o librpc/gen_rpc/rpc_spoolss.o \ librpc/gen_rpc/rpc_samr.o librpc/gen_rpc/rpc_wkssvc.o \ librpc/gen_rpc/rpc_srvsvc.o librpc/gen_rpc/rpc_atsvc.o \ - librpc/gen_rpc/rpc_eventlog.o + librpc/gen_rpc/rpc_eventlog.o librpc/gen_rpc/rpc_winreg.o LIBRAW_OBJ = libcli/raw/rawfile.o libcli/raw/smb_signing.o \ libcli/raw/clisocket.o libcli/raw/clitransport.o \ @@ -443,7 +444,8 @@ SMBTORTURE_RAW_OBJ = torture/raw/qfsinfo.o torture/raw/qfileinfo.o torture/raw/s SMBTORTURE_RPC_OBJ = torture/rpc/lsa.o torture/rpc/echo.o torture/rpc/dfs.o \ torture/rpc/spoolss.o torture/rpc/samr.o torture/rpc/wkssvc.o \ - torture/rpc/srvsvc.o torture/rpc/atsvc.o torture/rpc/eventlog.o + torture/rpc/srvsvc.o torture/rpc/atsvc.o \ + torture/rpc/eventlog.o torture/rpc/winreg.o SMBTORTURE_OBJ1 = torture/torture.o torture/torture_util.o torture/nbio.o torture/scanner.o \ torture/utable.o torture/denytest.o torture/mangle_test.o \ diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl new file mode 100644 index 00000000000..c41f75a3b22 --- /dev/null +++ b/source4/librpc/idl/winreg.idl @@ -0,0 +1,206 @@ +/* + winreg interface definition +*/ + +[ uuid(338cd001-2244-31f1-aaaa-900038001003), + version(1.0), + pointer_default(unique) +] interface winreg +{ + /******************/ + /* Function: 0x00 */ + NTSTATUS winreg_OpenHKCR( + ); + + /******************/ + /* Function: 0x01 */ + NTSTATUS winreg_OpenHKCU( + ); + + typedef struct { + uint16 unknown0; + uint16 unknown1; + } winreg_OpenHKLMUnknown; + + /******************/ + /* Function: 0x02 */ + NTSTATUS winreg_OpenHKLM( + [in] winreg_OpenHKLMUnknown *unknown, + [in] uint32 access_required, + [out,ref] policy_handle *handle + ); + + /******************/ + /* Function: 0x03 */ + NTSTATUS winreg_OpenHKPD( + ); + + /******************/ + /* Function: 0x04 */ + NTSTATUS winreg_OpenHKU( + ); + + /******************/ + /* Function: 0x05 */ + NTSTATUS winreg_CloseKey( + [in,out,ref] policy_handle *handle + ); + + /******************/ + /* Function: 0x06 */ + NTSTATUS winreg_CreateKey( + ); + + /******************/ + /* Function: 0x07 */ + NTSTATUS winreg_DeleteKey( + ); + + /******************/ + /* Function: 0x08 */ + NTSTATUS winreg_DeleteValue( + ); + + typedef struct { + uint32 low; + uint32 high; + } winreg_Time; + + typedef struct { + [value(2*strlen_m(r->name))] uint16 name_len; + [value(r->name_len)] uint16 name_size; + unistr_noterm *name; + } winreg_String; + + /******************/ + /* Function: 0x09 */ + NTSTATUS winreg_EnumKey( + ); + + /******************/ + /* Function: 0x0a */ + NTSTATUS winreg_EnumValue( + ); + + /******************/ + /* Function: 0x0b */ + NTSTATUS winreg_FlushKey( + ); + + /******************/ + /* Function: 0x0c */ + NTSTATUS winreg_GetKeySecurity( + ); + + /******************/ + /* Function: 0x0d */ + NTSTATUS winreg_LoadKey( + ); + + /******************/ + /* Function: 0x0e */ + NTSTATUS winreg_NotifyChangeKeyValue( + ); + + /******************/ + /* Function: 0x0f */ + NTSTATUS winreg_OpenKey( + ); + + /******************/ + /* Function: 0x10 */ + NTSTATUS winreg_QueryInfoKey( + ); + + /******************/ + /* Function: 0x11 */ + NTSTATUS winreg_QueryValue( + ); + + /******************/ + /* Function: 0x12 */ + NTSTATUS winreg_ReplaceKey( + ); + + /******************/ + /* Function: 0x13 */ + NTSTATUS winreg_RestoreKey( + ); + + /******************/ + /* Function: 0x14 */ + NTSTATUS winreg_SaveKey( + ); + + /******************/ + /* Function: 0x15 */ + NTSTATUS winreg_SetKeySecurity( + ); + + /******************/ + /* Function: 0x16 */ + NTSTATUS winreg_SetValue( + ); + + /******************/ + /* Function: 0x17 */ + NTSTATUS winreg_UnLoadKey( + ); + + /******************/ + /* Function: 0x18 */ + NTSTATUS winreg_InitiateSystemShutdown( + ); + + /******************/ + /* Function: 0x19 */ + NTSTATUS winreg_AbortSystemShutdown( + ); + + /******************/ + /* Function: 0x1a */ + NTSTATUS winreg_GetVersion( + [in,ref] policy_handle *handle, + [out] uint32 version + ); + + /******************/ + /* Function: 0x1b */ + NTSTATUS winreg_OpenHKCC( + ); + + /******************/ + /* Function: 0x1c */ + NTSTATUS winreg_OpenHKDD( + ); + + /******************/ + /* Function: 0x1d */ + NTSTATUS winreg_QueryMultipleValues( + ); + + /******************/ + /* Function: 0x1e */ + NTSTATUS winreg_InitiateSystemShutdownEx( + ); + + /******************/ + /* Function: 0x1f */ + NTSTATUS winreg_SaveKeyEx( + ); + + /******************/ + /* Function: 0x20 */ + NTSTATUS winreg_OpenHKPT( + ); + + /******************/ + /* Function: 0x21 */ + NTSTATUS winreg_OpenHKPN( + ); + + /******************/ + /* Function: 0x21 */ + NTSTATUS winreg_QueryMultipleValues2( + ); +} diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index b599d01023a..7876d3cc1cd 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -201,3 +201,4 @@ typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint32, v #include "librpc/gen_ndr/ndr_srvsvc.h" #include "librpc/gen_ndr/ndr_atsvc.h" #include "librpc/gen_ndr/ndr_eventlog.h" +#include "librpc/gen_ndr/ndr_winreg.h" diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c new file mode 100644 index 00000000000..4931f54ea17 --- /dev/null +++ b/source4/torture/rpc/winreg.c @@ -0,0 +1,124 @@ +/* + Unix SMB/CIFS implementation. + test suite for winreg rpc operations + + Copyright (C) Tim Potter 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + NTSTATUS status; + struct winreg_GetVersion r; + + printf("\ntesting GetVersion\n"); + + r.in.handle = handle; + + status = dcerpc_winreg_GetVersion(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + printf("GetVersion failed - %s\n", nt_errstr(status)); + return False; + } + + return True; +} + +static BOOL test_CloseKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + NTSTATUS status; + struct winreg_CloseKey r; + + printf("\ntesting CloseKey\n"); + + r.in.handle = r.out.handle = handle; + + status = dcerpc_winreg_CloseKey(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + printf("CloseKey failed - %s\n", nt_errstr(status)); + return False; + } + + return True; +} + +static BOOL test_OpenHKLM(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + NTSTATUS status; + struct winreg_OpenHKLM r; + struct winreg_OpenHKLMUnknown unknown; + struct policy_handle handle; + BOOL ret = True; + + printf("\ntesting OpenHKLM\n"); + + unknown.unknown0 = 0x84e0; + unknown.unknown1 = 0x0000; + r.in.unknown = &unknown; + r.in.access_required = SEC_RIGHTS_MAXIMUM_ALLOWED; + r.out.handle = &handle; + + status = dcerpc_winreg_OpenHKLM(p, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + printf("OpenHKLM failed - %s\n", nt_errstr(status)); + return False; + } + + if (!test_GetVersion(p, mem_ctx, &handle)) { + ret = False; + } + + if (!test_CloseKey(p, mem_ctx, &handle)) { + ret = False; + } + + return ret; +} + +BOOL torture_rpc_winreg(int dummy) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + + mem_ctx = talloc_init("torture_rpc_winreg"); + + status = torture_rpc_connection(&p, + DCERPC_WINREG_NAME, + DCERPC_WINREG_UUID, + DCERPC_WINREG_VERSION); + if (!NT_STATUS_IS_OK(status)) { + return False; + } + + p->flags |= DCERPC_DEBUG_PRINT_BOTH; + + if (!test_OpenHKLM(p, mem_ctx)) { + ret = False; + } + + torture_rpc_close(p); + + return ret; +} diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 54299e031d0..25602e3a839 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -3996,6 +3996,7 @@ static struct { {"RPC-SRVSVC", torture_rpc_srvsvc, 0}, {"RPC-ATSVC", torture_rpc_atsvc, 0}, {"RPC-EVENTLOG", torture_rpc_eventlog, 0}, + {"RPC-WINREG", torture_rpc_winreg, 0}, {NULL, NULL, 0}}; -- cgit