annotate loader/registry.c @ 3509:21c7b77b3e83

fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in FLI decoder and also implemented (untested due to lack of sample data) the FLI_COPY chunk type
author melanson
date Sun, 16 Dec 2001 00:26:21 +0000
parents 4dad31e655b6
children a1d27234018f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
1 #include "config.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 #include <stdio.h>
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
4 #include <stdlib.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 #include <fcntl.h>
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
6 #include <unistd.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 #include <pwd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include <wine/winbase.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include <wine/winreg.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 #include <wine/winnt.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 #include <wine/winerror.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
15 #include "ext.h"
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
16 #include "registry.h"
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
17
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
18 //#undef TRACE
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
19 //#define TRACE printf
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
20
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
21 // ...can be set before init_registry() call
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
22 char* regpathname = 0;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
23
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
24
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
25 static char* localregpathname = 0;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
26
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
27 typedef struct reg_handle_s
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
28 {
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
29 int handle;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
30 char* name;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
31 struct reg_handle_s* next;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
32 struct reg_handle_s* prev;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
33 } reg_handle_t;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
34
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 struct reg_value
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 int type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 char* name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 char* value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
43 static struct reg_value* regs = NULL;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
44 static int reg_size;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
45 static reg_handle_t* head = NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 #define DIR -25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
49 static void create_registry(void);
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
50 static void open_registry(void);
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
51 static void save_registry(void);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
52 static void init_registry(void);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
55 static void create_registry(void){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 if(regs)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 printf("Logic error: create_registry() called with existing registry\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 save_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 return;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
61 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 regs=(struct reg_value*)malloc(3*sizeof(struct reg_value));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 regs[0].type=regs[1].type=DIR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 regs[0].name=(char*)malloc(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 strcpy(regs[0].name, "HKLM");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 regs[1].name=(char*)malloc(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 strcpy(regs[1].name, "HKCU");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 regs[0].value=regs[1].value=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 regs[0].len=regs[1].len=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 reg_size=2;
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
71 head = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 save_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 }
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
74
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
75 static void open_registry(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 int fd;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 int i;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
79 unsigned int len;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 if(regs)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 printf("Multiple open_registry(>\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 }
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
85 fd = open(localregpathname, O_RDONLY);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
86 if (fd == -1)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 printf("Creating new registry\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 create_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 return;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
91 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 read(fd, &reg_size, 4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 regs=(struct reg_value*)malloc(reg_size*sizeof(struct reg_value));
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
94 head = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 for(i=0; i<reg_size; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 read(fd,&regs[i].type,4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 read(fd,&len,4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 regs[i].name=(char*)malloc(len+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 if(regs[i].name==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 reg_size=i+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 goto error;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 read(fd, regs[i].name, len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 regs[i].name[len]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 read(fd,&regs[i].len,4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 regs[i].value=(char*)malloc(regs[i].len+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 if(regs[i].value==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 {
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
111 free(regs[i].name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 reg_size=i+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 goto error;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 read(fd, regs[i].value, regs[i].len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 regs[i].value[regs[i].len]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 error:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 close(fd);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
123 static void save_registry(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
125 int fd, i;
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
126 if (!regs)
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
127 init_registry();
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
128 fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
129 if (fd == -1)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
131 printf("Failed to open registry file '%s' for writing.\n",
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
132 localregpathname);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
133 return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 write(fd, &reg_size, 4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 for(i=0; i<reg_size; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
138 unsigned len=strlen(regs[i].name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 write(fd, &regs[i].type, 4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 write(fd, &len, 4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 write(fd, regs[i].name, len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 write(fd, &regs[i].len, 4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 write(fd, regs[i].value, regs[i].len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 close(fd);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 }
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
147
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
148 void free_registry(void)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
149 {
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
150 reg_handle_t* t = head;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
151 while (t)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
152 {
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
153 reg_handle_t* f = t;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
154 if (t->name)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
155 free(t->name);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
156 t=t->prev;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
157 free(f);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
158 }
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
159 head = 0;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
160 if (regs)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
161 {
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
162 int i;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
163 for(i=0; i<reg_size; i++)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
164 {
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
165 free(regs[i].name);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
166 free(regs[i].value);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
167 }
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
168 free(regs);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
169 regs = 0;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
170 }
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
171
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
172 if (localregpathname && localregpathname != regpathname)
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
173 free(localregpathname);
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
174 localregpathname = 0;
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
175 }
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
176
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
177
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 static reg_handle_t* find_handle_by_name(const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 for(t=head; t; t=t->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 if(!strcmp(t->name, name))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 return t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 static struct reg_value* find_value_by_name(const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 for(i=0; i<reg_size; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 if(!strcmp(regs[i].name, name))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 return regs+i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 static reg_handle_t* find_handle(int handle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 for(t=head; t; t=t->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 if(t->handle==handle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 return t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 return 0;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
209 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 static int generate_handle()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 static int zz=249;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 zz++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 zz++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 return zz;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 static reg_handle_t* insert_handle(long handle, const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 t=(reg_handle_t*)malloc(sizeof(reg_handle_t));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 if(head==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 t->prev=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 head->next=t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 t->prev=head;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 t->next=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 t->name=(char*)malloc(strlen(name)+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 strcpy(t->name, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 t->handle=handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 head=t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 return t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 static char* build_keyname(long key, const char* subkey)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 char* full_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 if((t=find_handle(key))==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 TRACE("Invalid key\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 if(subkey==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 subkey="<default>";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 strcpy(full_name, t->name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 strcat(full_name, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 strcat(full_name, subkey);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 return full_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
256 static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 struct reg_value* v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 char* fullname;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 if((fullname=build_keyname(handle, name))==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 TRACE("Invalid handle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 if((v=find_value_by_name(fullname))==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 //creating new value in registry
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 if(regs==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 create_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
273 //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 v=regs+reg_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 reg_size++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 //replacing old one
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 {
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
280 free(v->value);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
281 free(v->name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 v->type=type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 v->len=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 v->value=(char*)malloc(len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 memcpy(v->value, value, len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 v->name=(char*)malloc(strlen(fullname)+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 strcpy(v->name, fullname);
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
289 free(fullname);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 save_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 return v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 340
diff changeset
294 static void init_registry(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
296 TRACE("Initializing registry\n");
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
297 // can't be free-ed - it's static and probably thread
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
298 // unsafe structure which is stored in glibc
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
299
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
300 #ifdef MPLAYER
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
301 regpathname = get_path("registry");
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
302 localregpathname = regpathname;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
303 #else
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
304 // regpathname is an external pointer
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
305 //
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
306 // registry.c is holding it's own internal pointer
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
307 // localregpathname - which is being allocate/deallocated
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
308
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
309 if (localregpathname == 0)
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
310 {
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
311 const char* pthn = regpathname;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
312 if (!regpathname)
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
313 {
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
314 // avifile - for now reading data from user's home
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
315 struct passwd* pwent;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
316 pwent = getpwuid(geteuid());
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
317 pthn = pwent->pw_dir;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
318 }
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
319
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
320 localregpathname = (char*)malloc(strlen(pthn)+20);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
321 strcpy(localregpathname, pthn);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
322 strcat(localregpathname, "/.registry");
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
323 }
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 178
diff changeset
324 #endif
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
325
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 open_registry();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 insert_handle(HKEY_CURRENT_USER, "HKCU");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 }
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
330
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 static reg_handle_t* find_handle_2(long key, const char* subkey)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 char* full_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 if((t=find_handle(key))==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 TRACE("Invalid key\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 return (reg_handle_t*)-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 if(subkey==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 return t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 strcpy(full_name, t->name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 strcat(full_name, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 strcat(full_name, subkey);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 t=find_handle_by_name(full_name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 free(full_name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 return t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 long RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 char* full_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 struct reg_value* v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 TRACE("Opening key %s\n", subkey);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
357
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 if(!regs)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 init_registry()
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
360 ;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 /* t=find_handle_2(key, subkey);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
362
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 if(t==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 if(t==(reg_handle_t*)-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 return -1;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
368 */
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
369 full_name=build_keyname(key, subkey);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 if(!full_name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 return -1;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
372 TRACE("Opening key Fullname %s\n", full_name);
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
373 v=find_value_by_name(full_name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 t=insert_handle(generate_handle(), full_name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 *newkey=t->handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 free(full_name);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
378
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 return 0;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
380 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 long RegCloseKey(long key)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 reg_handle_t *handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 if(key==HKEY_LOCAL_MACHINE)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 if(key==HKEY_CURRENT_USER)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 handle=find_handle(key);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 if(handle==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 if(handle->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 handle->prev->next=handle->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 if(handle->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 handle->next->prev=handle->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 if(handle->name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 free(handle->name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 if(handle==head)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 head=head->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 free(handle);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 return 1;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
401 }
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
402
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 long RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 struct reg_value* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 char* c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 TRACE("Querying value %s\n", value);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 if(!regs)
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
409 init_registry();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
410
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
411 c=build_keyname(key, value);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 if(c==NULL)
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
413 return 1;
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
414 t=find_value_by_name(c);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
415 free(c);
181db9e5a887 avifile sync again... :(
arpi
parents: 3128
diff changeset
416 if(t==0)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 return 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 if(type)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 *type=t->type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 if(data)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 memcpy(data, t->value, (t->len<*count)?t->len:*count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
424 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 if(*count<t->len)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 *count=t->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 return ERROR_MORE_DATA;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 *count=t->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 return 0;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
435 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 long RegCreateKeyExA(long key, const char* name, long reserved,
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
437 void* classs, long options, long security,
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
438 void* sec_attr, int* newkey, int* status)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 reg_handle_t* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 char* fullname;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 struct reg_value* v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 // TRACE("Creating/Opening key %s\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 TRACE("Creating/Opening key %s\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 if(!regs)
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
446 init_registry();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
447
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 fullname=build_keyname(key, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 if(fullname==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 v=find_value_by_name(fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 if(v==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 int qw=45708;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 v=insert_reg_value(key, name, DIR, &qw, 4);
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
456 if (status) *status=REG_CREATED_NEW_KEY;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 // return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 t=insert_handle(generate_handle(), fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 *newkey=t->handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 free(fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 }
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
465
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
466 /*
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
467 LONG RegEnumValue(
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
468 HKEY hKey, // handle to key to query
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
469 DWORD dwIndex, // index of value to query
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
470 LPTSTR lpValueName, // address of buffer for value string
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
471 LPDWORD lpcbValueName, // address for size of value buffer
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
472 LPDWORD lpReserved, // reserved
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
473 LPDWORD lpType, // address of buffer for type code
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
474 LPBYTE lpData, // address of buffer for value data
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
475 LPDWORD lpcbData // address for size of data buffer
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
476 );
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
477 */
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
478
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
479 long RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
480 LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
481 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
482 // currenly just made to support MSZH & ZLIB
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
483 //printf("Reg Enum 0x%x %d %s %d data: %p %d %d >%s<\n", hkey, index,
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
484 // value, *val_count, data, *count, reg_size, data);
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
485 reg_handle_t* t = find_handle(hkey);
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
486 if (t && index < 10)
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
487 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
488 struct reg_value* v=find_value_by_name(t->name);
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
489 if (v)
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
490 {
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
491 memcpy(data, v->value, (v->len < *count) ? v->len : *count);
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
492 if(*count < v->len)
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
493 *count = v->len;
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
494 if (type)
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
495 *type = v->type;
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
496 //printf("Found handle %s\n", v->name);
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
497 return 0;
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
498 }
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
499 }
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
500 return ERROR_NO_MORE_ITEMS;
1416
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
501 }
8e841fe5668b partial avifile-CVS merge
arpi
parents: 1307
diff changeset
502
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
503 long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
504 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505 struct reg_value* t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 char* c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
507 TRACE("Request to set value %s\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 if(!regs)
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
509 init_registry();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
510
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 c=build_keyname(key, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
512 if(c==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
513 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 insert_reg_value(key, name, v2, data, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
515 free(c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
516 return 0;
3128
392316004607 avifile sync... maybe broken, tell me if so.
arpi
parents: 1416
diff changeset
517 }
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
518
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
519 long RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
520 LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
521 LPFILETIME lpftLastWriteTime)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
522 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
523 return ERROR_NO_MORE_ITEMS;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3138
diff changeset
524 }