1 /*
2  * Copyright 2021 Hugh McMaster
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef __REG_TEST_H__
20 #define __REG_TEST_H__
21 
22 #include <stdio.h>
23 #include <windows.h>
24 #include "wine/test.h"
25 
26 /* Common #defines */
27 #define lok ok_(file,line)
28 #define KEY_WINE "Software\\Wine"
29 #define KEY_BASE KEY_WINE "\\reg_test"
30 #define REG_EXIT_SUCCESS 0
31 #define REG_EXIT_FAILURE 1
32 
33 #define TODO_REG_TYPE    (0x0001u)
34 #define TODO_REG_SIZE    (0x0002u)
35 #define TODO_REG_DATA    (0x0004u)
36 #define TODO_REG_COMPARE (0x0008u)
37 
38 /* add.c */
39 #define run_reg_exe(c,r) run_reg_exe_(__FILE__,__LINE__,c,r)
40 BOOL run_reg_exe_(const char *file, unsigned line, const char *cmd, DWORD *rc);
41 
42 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__FILE__,__LINE__,k,v,t,d,s,todo)
43 void verify_reg_(const char *file, unsigned line, HKEY hkey, const char *value,
44                  DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo);
45 
46 #define verify_reg_nonexist(k,v) verify_reg_nonexist_(__FILE__,__LINE__,k,v)
47 void verify_reg_nonexist_(const char *file, unsigned line, HKEY hkey, const char *value);
48 
49 #define open_key(r,p,s,k) open_key_(__FILE__,__LINE__,r,p,s,k)
50 void open_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam, HKEY *hkey);
51 
52 #define close_key(k) close_key_(__FILE__,__LINE__,k)
53 void close_key_(const char *file, unsigned line, HKEY hkey);
54 
55 #define verify_key(r,p,s) verify_key_(__FILE__,__LINE__,r,p,s)
56 void verify_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
57 
58 #define verify_key_nonexist(r,p,s) verify_key_nonexist_(__FILE__,__LINE__,r,p,s)
59 void verify_key_nonexist_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
60 
61 #define add_key(r,p,s,k) add_key_(__FILE__,__LINE__,r,p,s,k)
62 void add_key_(const char *file, unsigned line, const HKEY root, const char *path, REGSAM sam, HKEY *hkey);
63 
64 #define delete_key(r,p,s) delete_key_(__FILE__,__LINE__,r,p,s)
65 void delete_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
66 
67 #define delete_tree(r,p,s) delete_tree_(__FILE__,__LINE__,r,p,s)
68 LONG delete_tree_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
69 
70 #define add_value(k,n,t,d,s) add_value_(__FILE__,__LINE__,k,n,t,d,s)
71 void add_value_(const char *file, unsigned line, HKEY hkey, const char *name,
72                 DWORD type, const void *data, size_t size);
73 
74 #define delete_value(k,n) delete_value_(__FILE__,__LINE__,k,n)
75 void delete_value_(const char *file, unsigned line, HKEY hkey, const char *name);
76 
77 /* export.c */
78 #define compare_export(f,e,todo) compare_export_(__FILE__,__LINE__,f,e,todo)
79 BOOL compare_export_(const char *file, unsigned line, const char *filename,
80                      const char *expected, DWORD todo);
81 extern const char *empty_key_test;
82 extern const char *simple_data_test;
83 extern const char *complex_data_test;
84 extern const char *key_order_test;
85 extern const char *value_order_test;
86 extern const char *empty_hex_test;
87 extern const char *empty_hex_test2;
88 extern const char *hex_types_test;
89 extern const char *slashes_test;
90 extern const char *embedded_null_test;
91 extern const char *escaped_null_test;
92 extern const char *registry_view_test;
93 
94 /* import.c */
95 BOOL is_elevated_process(void);
96 
97 #define delete_file(f) delete_file_(__FILE__,__LINE__,f)
98 BOOL delete_file_(const char *file, unsigned line, const char *fname);
99 
100 #define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r)
101 #define test_import_wstr(c,r) import_reg(__FILE__,__LINE__,c,TRUE,r)
102 BOOL import_reg(const char *file, unsigned line, const char *contents, BOOL unicode, DWORD *rc);
103 
104 #endif /* __REG_TEST_H__ */
105