1bcfd09deSwinesync /*
2bcfd09deSwinesync  * Copyright 2021 Hugh McMaster
3bcfd09deSwinesync  *
4bcfd09deSwinesync  * This library is free software; you can redistribute it and/or
5bcfd09deSwinesync  * modify it under the terms of the GNU Lesser General Public
6bcfd09deSwinesync  * License as published by the Free Software Foundation; either
7bcfd09deSwinesync  * version 2.1 of the License, or (at your option) any later version.
8bcfd09deSwinesync  *
9bcfd09deSwinesync  * This library is distributed in the hope that it will be useful,
10bcfd09deSwinesync  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11bcfd09deSwinesync  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12bcfd09deSwinesync  * Lesser General Public License for more details.
13bcfd09deSwinesync  *
14bcfd09deSwinesync  * You should have received a copy of the GNU Lesser General Public
15bcfd09deSwinesync  * License along with this library; if not, write to the Free Software
16bcfd09deSwinesync  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17bcfd09deSwinesync  */
18bcfd09deSwinesync 
19bcfd09deSwinesync #ifndef __REG_TEST_H__
20bcfd09deSwinesync #define __REG_TEST_H__
21bcfd09deSwinesync 
22bcfd09deSwinesync #include <stdio.h>
23bcfd09deSwinesync #include <windows.h>
24bcfd09deSwinesync #include "wine/test.h"
25bcfd09deSwinesync 
26bcfd09deSwinesync /* Common #defines */
2707907552Swinesync #define lok ok_(file,line)
28bcfd09deSwinesync #define KEY_WINE "Software\\Wine"
29bcfd09deSwinesync #define KEY_BASE KEY_WINE "\\reg_test"
30bcfd09deSwinesync #define REG_EXIT_SUCCESS 0
31bcfd09deSwinesync #define REG_EXIT_FAILURE 1
32bcfd09deSwinesync 
335132d26cSwinesync #define TODO_REG_TYPE    (0x0001u)
345132d26cSwinesync #define TODO_REG_SIZE    (0x0002u)
355132d26cSwinesync #define TODO_REG_DATA    (0x0004u)
365132d26cSwinesync #define TODO_REG_COMPARE (0x0008u)
375132d26cSwinesync 
38a09c8c41Swinesync /* add.c */
3907907552Swinesync #define run_reg_exe(c,r) run_reg_exe_(__FILE__,__LINE__,c,r)
4007907552Swinesync BOOL run_reg_exe_(const char *file, unsigned line, const char *cmd, DWORD *rc);
41bcfd09deSwinesync 
4207907552Swinesync #define verify_reg(k,v,t,d,s,todo) verify_reg_(__FILE__,__LINE__,k,v,t,d,s,todo)
4307907552Swinesync void verify_reg_(const char *file, unsigned line, HKEY hkey, const char *value,
4407907552Swinesync                  DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo);
456498aac7Swinesync 
4607907552Swinesync #define verify_reg_nonexist(k,v) verify_reg_nonexist_(__FILE__,__LINE__,k,v)
4707907552Swinesync void verify_reg_nonexist_(const char *file, unsigned line, HKEY hkey, const char *value);
48bcfd09deSwinesync 
49ea4fae51Swinesync #define open_key(r,p,s,k) open_key_(__FILE__,__LINE__,r,p,s,k)
50ea4fae51Swinesync void open_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam, HKEY *hkey);
516498aac7Swinesync 
5207907552Swinesync #define close_key(k) close_key_(__FILE__,__LINE__,k)
5307907552Swinesync void close_key_(const char *file, unsigned line, HKEY hkey);
54bcfd09deSwinesync 
55cd3b6fe7Swinesync #define verify_key(r,p,s) verify_key_(__FILE__,__LINE__,r,p,s)
56cd3b6fe7Swinesync void verify_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
57bcfd09deSwinesync 
58df92c046Swinesync #define verify_key_nonexist(r,p,s) verify_key_nonexist_(__FILE__,__LINE__,r,p,s)
59df92c046Swinesync void verify_key_nonexist_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
60bcfd09deSwinesync 
6177b2d21eSwinesync #define add_key(r,p,s,k) add_key_(__FILE__,__LINE__,r,p,s,k)
6277b2d21eSwinesync void add_key_(const char *file, unsigned line, const HKEY root, const char *path, REGSAM sam, HKEY *hkey);
63bcfd09deSwinesync 
640ea0084cSwinesync #define delete_key(r,p,s) delete_key_(__FILE__,__LINE__,r,p,s)
650ea0084cSwinesync void delete_key_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
667fcb8acaSwinesync 
672d9dfc03Swinesync #define delete_tree(r,p,s) delete_tree_(__FILE__,__LINE__,r,p,s)
682d9dfc03Swinesync LONG delete_tree_(const char *file, unsigned line, HKEY root, const char *path, REGSAM sam);
69bcfd09deSwinesync 
7007907552Swinesync #define add_value(k,n,t,d,s) add_value_(__FILE__,__LINE__,k,n,t,d,s)
7107907552Swinesync void add_value_(const char *file, unsigned line, HKEY hkey, const char *name,
7207907552Swinesync                 DWORD type, const void *data, size_t size);
73bcfd09deSwinesync 
7407907552Swinesync #define delete_value(k,n) delete_value_(__FILE__,__LINE__,k,n)
7564c84526Swinesync void delete_value_(const char *file, unsigned line, HKEY hkey, const char *name);
766498aac7Swinesync 
77d40c4ec1Swinesync /* export.c */
78d40c4ec1Swinesync #define compare_export(f,e,todo) compare_export_(__FILE__,__LINE__,f,e,todo)
79d40c4ec1Swinesync BOOL compare_export_(const char *file, unsigned line, const char *filename,
80d40c4ec1Swinesync                      const char *expected, DWORD todo);
81d40c4ec1Swinesync extern const char *empty_key_test;
82d40c4ec1Swinesync extern const char *simple_data_test;
836ae4684dSwinesync extern const char *complex_data_test;
84552256c1Swinesync extern const char *key_order_test;
85552256c1Swinesync extern const char *value_order_test;
866ae4684dSwinesync extern const char *empty_hex_test;
876ae4684dSwinesync extern const char *empty_hex_test2;
886ae4684dSwinesync extern const char *hex_types_test;
89927db6beSwinesync extern const char *slashes_test;
90927db6beSwinesync extern const char *embedded_null_test;
91927db6beSwinesync extern const char *escaped_null_test;
92*be726bd7Swinesync extern const char *registry_view_test;
93d40c4ec1Swinesync 
946498aac7Swinesync /* import.c */
95334c2e27Swinesync BOOL is_elevated_process(void);
96334c2e27Swinesync 
97bed77337Swinesync #define delete_file(f) delete_file_(__FILE__,__LINE__,f)
98bed77337Swinesync BOOL delete_file_(const char *file, unsigned line, const char *fname);
99bed77337Swinesync 
10007907552Swinesync #define test_import_str(c,r) import_reg(__FILE__,__LINE__,c,FALSE,r)
10107907552Swinesync #define test_import_wstr(c,r) import_reg(__FILE__,__LINE__,c,TRUE,r)
10207907552Swinesync BOOL import_reg(const char *file, unsigned line, const char *contents, BOOL unicode, DWORD *rc);
1036498aac7Swinesync 
104bcfd09deSwinesync #endif /* __REG_TEST_H__ */
105