+ return ret;
+}
+
+static BOOL test_OpenHKU(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct winreg_OpenHKU r;
+ struct winreg_OpenUnknown unknown;
+ BOOL ret = True;
+
+ printf("\ntesting OpenHKU\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_OpenHKU(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenHKU failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ return ret;
+}
+
+static BOOL test_OpenHKCR(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct winreg_OpenHKCR r;
+ struct winreg_OpenUnknown unknown;
+ BOOL ret = True;
+
+ printf("\ntesting OpenHKCR\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_OpenHKCR(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenHKCR failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ return ret;
+}
+
+static BOOL test_InitiateSystemShutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ const char *msg, uint32 timeout)
+{
+ struct winreg_InitiateSystemShutdown r;
+ NTSTATUS status;
+
+ init_winreg_String(&r.in.message, msg);
+ r.in.flags = 0;
+ r.in.timeout = timeout;
+
+ status = dcerpc_winreg_InitiateSystemShutdown(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("InitiateSystemShutdown failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("InitiateSystemShutdown failed - %s\n", win_errstr(r.out.result));
+ return False;
+ }
+
+ return True;
+}
+
+static BOOL test_AbortSystemShutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+{
+ struct winreg_AbortSystemShutdown r;
+ NTSTATUS status;
+ uint16 server = 0x0;
+
+ r.in.server = &server;
+
+ status = dcerpc_winreg_AbortSystemShutdown(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("AbortSystemShutdown failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("AbortSystemShutdown failed - %s\n", win_errstr(r.out.result));
+ return False;
+ }
+
+ return True;
+}
+
+static BOOL test_OpenHKCU(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct winreg_OpenHKCU r;
+ struct winreg_OpenUnknown unknown;
+ BOOL ret = True;
+
+ printf("\ntesting OpenHKCU\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_OpenHKCU(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenHKCU failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ return ret;
+}
+
+#define MAX_DEPTH 2 /* Only go this far down the tree */
+
+static BOOL test_key(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, int depth)
+{
+ if (depth == MAX_DEPTH)
+ return True;
+
+ if (!test_QueryInfoKey(p, mem_ctx, handle, NULL)) {
+ }
+
+ if (!test_EnumKey(p, mem_ctx, handle, depth)) {
+ }
+
+ if (!test_EnumValue(p, mem_ctx, handle)) {
+ }
+
+ /* Enumerate values */
+
+ test_CloseKey(p, mem_ctx, handle);
+
+ return True;
+}
+
+typedef BOOL winreg_open_fn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle);
+
+static BOOL test_Open(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, void *fn)
+{
+ struct policy_handle handle, newhandle;
+ BOOL ret = True;
+ winreg_open_fn *open_fn = (winreg_open_fn *)fn;
+
+ if (!open_fn(p, mem_ctx, &handle))
+ return False;
+
+ if (!test_CreateKey(p, mem_ctx, &handle, "spottyfoot", NULL)) {
+ printf("CreateKey failed\n");
+ ret = False;
+ }
+
+ if (!test_FlushKey(p, mem_ctx, &handle)) {
+ printf("FlushKey failed\n");
+ ret = False;
+ }
+
+ if (!test_OpenKey(p, mem_ctx, &handle, "spottyfoot", &newhandle)) {
+ printf("CreateKey failed (OpenKey after Create didn't work)\n");