2005-04-15 20:17:14 +00:00
|
|
|
/*
|
2006-06-22 13:34:00 +00:00
|
|
|
* Modified for use with MPlayer, detailed changelog at
|
|
|
|
* http://svn.mplayerhq.hu/mplayer/trunk/
|
2005-04-15 20:17:14 +00:00
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2001-12-11 22:58:14 +00:00
|
|
|
#include "config.h"
|
2006-11-26 18:33:41 +00:00
|
|
|
#include "debug.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2001-07-12 15:27:48 +00:00
|
|
|
#include <stdlib.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
#include <fcntl.h>
|
2001-07-12 15:27:48 +00:00
|
|
|
#include <unistd.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
#include "wine/winbase.h"
|
|
|
|
#include "wine/winreg.h"
|
|
|
|
#include "wine/winnt.h"
|
|
|
|
#include "wine/winerror.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-12-11 22:58:14 +00:00
|
|
|
#include "ext.h"
|
|
|
|
#include "registry.h"
|
2001-07-12 15:27:48 +00:00
|
|
|
|
2001-03-18 01:01:03 +00:00
|
|
|
//#undef TRACE
|
|
|
|
//#define TRACE printf
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2006-07-03 23:27:37 +00:00
|
|
|
extern char *get_path ( const char * );
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-01-27 17:21:20 +00:00
|
|
|
// ...can be set before init_registry() call
|
|
|
|
char* regpathname = NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-01-27 17:21:20 +00:00
|
|
|
static char* localregpathname = NULL;
|
2001-11-26 01:17:24 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
typedef struct reg_handle_s
|
|
|
|
{
|
|
|
|
int handle;
|
|
|
|
char* name;
|
|
|
|
struct reg_handle_s* next;
|
|
|
|
struct reg_handle_s* prev;
|
|
|
|
} reg_handle_t;
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-11-26 01:17:24 +00:00
|
|
|
struct reg_value
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
char* name;
|
|
|
|
int len;
|
|
|
|
char* value;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct reg_value* regs = NULL;
|
|
|
|
static int reg_size;
|
|
|
|
static reg_handle_t* head = NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#define DIR -25
|
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
static void create_registry(void);
|
|
|
|
static void open_registry(void);
|
|
|
|
static void save_registry(void);
|
2001-11-26 00:47:58 +00:00
|
|
|
static void init_registry(void);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
static void create_registry(void){
|
2001-02-24 20:28:24 +00:00
|
|
|
if(regs)
|
|
|
|
{
|
|
|
|
printf("Logic error: create_registry() called with existing registry\n");
|
|
|
|
save_registry();
|
|
|
|
return;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2006-07-02 03:59:36 +00:00
|
|
|
regs=malloc(3*sizeof(struct reg_value));
|
2001-02-24 20:28:24 +00:00
|
|
|
regs[0].type=regs[1].type=DIR;
|
2006-07-02 03:59:36 +00:00
|
|
|
regs[0].name=malloc(5);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(regs[0].name, "HKLM");
|
2006-07-02 03:59:36 +00:00
|
|
|
regs[1].name=malloc(5);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(regs[1].name, "HKCU");
|
|
|
|
regs[0].value=regs[1].value=NULL;
|
|
|
|
regs[0].len=regs[1].len=0;
|
|
|
|
reg_size=2;
|
2001-11-26 01:17:24 +00:00
|
|
|
head = 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
save_registry();
|
|
|
|
}
|
2001-11-26 01:17:24 +00:00
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
static void open_registry(void)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int i;
|
2001-11-26 00:47:58 +00:00
|
|
|
unsigned int len;
|
2001-02-24 20:28:24 +00:00
|
|
|
if(regs)
|
|
|
|
{
|
|
|
|
printf("Multiple open_registry(>\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-11-26 01:17:24 +00:00
|
|
|
fd = open(localregpathname, O_RDONLY);
|
2001-11-26 00:47:58 +00:00
|
|
|
if (fd == -1)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
printf("Creating new registry\n");
|
|
|
|
create_registry();
|
|
|
|
return;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
read(fd, ®_size, 4);
|
2006-07-02 03:59:36 +00:00
|
|
|
regs=malloc(reg_size*sizeof(struct reg_value));
|
2001-11-26 01:17:24 +00:00
|
|
|
head = 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
for(i=0; i<reg_size; i++)
|
|
|
|
{
|
|
|
|
read(fd,®s[i].type,4);
|
|
|
|
read(fd,&len,4);
|
2006-07-02 03:59:36 +00:00
|
|
|
regs[i].name=malloc(len+1);
|
2001-02-24 20:28:24 +00:00
|
|
|
if(regs[i].name==0)
|
|
|
|
{
|
|
|
|
reg_size=i+1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
read(fd, regs[i].name, len);
|
|
|
|
regs[i].name[len]=0;
|
|
|
|
read(fd,®s[i].len,4);
|
2006-07-02 03:59:36 +00:00
|
|
|
regs[i].value=malloc(regs[i].len+1);
|
2001-02-24 20:28:24 +00:00
|
|
|
if(regs[i].value==0)
|
|
|
|
{
|
2001-11-26 01:17:24 +00:00
|
|
|
free(regs[i].name);
|
2001-02-24 20:28:24 +00:00
|
|
|
reg_size=i+1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
read(fd, regs[i].value, regs[i].len);
|
|
|
|
regs[i].value[regs[i].len]=0;
|
|
|
|
}
|
|
|
|
error:
|
|
|
|
close(fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
static void save_registry(void)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
int fd, i;
|
|
|
|
if (!regs)
|
|
|
|
init_registry();
|
2001-11-26 01:17:24 +00:00
|
|
|
fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
|
2001-11-26 00:47:58 +00:00
|
|
|
if (fd == -1)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
printf("Failed to open registry file '%s' for writing.\n",
|
2001-11-26 01:17:24 +00:00
|
|
|
localregpathname);
|
2001-11-26 00:47:58 +00:00
|
|
|
return;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
write(fd, ®_size, 4);
|
|
|
|
for(i=0; i<reg_size; i++)
|
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
unsigned len=strlen(regs[i].name);
|
2001-02-24 20:28:24 +00:00
|
|
|
write(fd, ®s[i].type, 4);
|
|
|
|
write(fd, &len, 4);
|
|
|
|
write(fd, regs[i].name, len);
|
|
|
|
write(fd, ®s[i].len, 4);
|
|
|
|
write(fd, regs[i].value, regs[i].len);
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
2001-11-26 01:17:24 +00:00
|
|
|
|
|
|
|
void free_registry(void)
|
|
|
|
{
|
|
|
|
reg_handle_t* t = head;
|
|
|
|
while (t)
|
|
|
|
{
|
|
|
|
reg_handle_t* f = t;
|
|
|
|
if (t->name)
|
|
|
|
free(t->name);
|
|
|
|
t=t->prev;
|
|
|
|
free(f);
|
|
|
|
}
|
|
|
|
head = 0;
|
|
|
|
if (regs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i<reg_size; i++)
|
|
|
|
{
|
|
|
|
free(regs[i].name);
|
|
|
|
free(regs[i].value);
|
|
|
|
}
|
|
|
|
free(regs);
|
|
|
|
regs = 0;
|
|
|
|
}
|
2001-12-11 22:58:14 +00:00
|
|
|
|
|
|
|
if (localregpathname && localregpathname != regpathname)
|
2001-11-26 01:17:24 +00:00
|
|
|
free(localregpathname);
|
2001-12-11 22:58:14 +00:00
|
|
|
localregpathname = 0;
|
2001-11-26 01:17:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
static reg_handle_t* find_handle_by_name(const char* name)
|
|
|
|
{
|
|
|
|
reg_handle_t* t;
|
|
|
|
for(t=head; t; t=t->prev)
|
|
|
|
{
|
|
|
|
if(!strcmp(t->name, name))
|
|
|
|
{
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static struct reg_value* find_value_by_name(const char* name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i<reg_size; i++)
|
|
|
|
if(!strcmp(regs[i].name, name))
|
|
|
|
return regs+i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static reg_handle_t* find_handle(int handle)
|
|
|
|
{
|
|
|
|
reg_handle_t* t;
|
|
|
|
for(t=head; t; t=t->prev)
|
|
|
|
{
|
|
|
|
if(t->handle==handle)
|
|
|
|
{
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
static int generate_handle()
|
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
static unsigned int zz=249;
|
2001-02-24 20:28:24 +00:00
|
|
|
zz++;
|
|
|
|
while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
|
|
|
|
zz++;
|
|
|
|
return zz;
|
|
|
|
}
|
|
|
|
|
|
|
|
static reg_handle_t* insert_handle(long handle, const char* name)
|
|
|
|
{
|
|
|
|
reg_handle_t* t;
|
2006-07-02 03:59:36 +00:00
|
|
|
t=malloc(sizeof(reg_handle_t));
|
2001-02-24 20:28:24 +00:00
|
|
|
if(head==0)
|
|
|
|
{
|
|
|
|
t->prev=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
head->next=t;
|
|
|
|
t->prev=head;
|
|
|
|
}
|
|
|
|
t->next=0;
|
2006-07-02 03:59:36 +00:00
|
|
|
t->name=malloc(strlen(name)+1);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(t->name, name);
|
|
|
|
t->handle=handle;
|
|
|
|
head=t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
static char* build_keyname(long key, const char* subkey)
|
|
|
|
{
|
|
|
|
char* full_name;
|
|
|
|
reg_handle_t* t;
|
|
|
|
if((t=find_handle(key))==0)
|
|
|
|
{
|
|
|
|
TRACE("Invalid key\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(subkey==NULL)
|
|
|
|
subkey="<default>";
|
2006-07-02 03:59:36 +00:00
|
|
|
full_name=malloc(strlen(t->name)+strlen(subkey)+10);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(full_name, t->name);
|
|
|
|
strcat(full_name, "\\");
|
|
|
|
strcat(full_name, subkey);
|
|
|
|
return full_name;
|
|
|
|
}
|
2001-07-12 15:27:48 +00:00
|
|
|
static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
reg_handle_t* t;
|
|
|
|
struct reg_value* v;
|
|
|
|
char* fullname;
|
|
|
|
if((fullname=build_keyname(handle, name))==NULL)
|
|
|
|
{
|
|
|
|
TRACE("Invalid handle\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((v=find_value_by_name(fullname))==0)
|
|
|
|
//creating new value in registry
|
|
|
|
{
|
|
|
|
if(regs==0)
|
|
|
|
create_registry();
|
|
|
|
regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
|
2001-11-26 01:17:24 +00:00
|
|
|
//regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
|
2001-02-24 20:28:24 +00:00
|
|
|
v=regs+reg_size;
|
|
|
|
reg_size++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
//replacing old one
|
|
|
|
{
|
2001-11-26 01:17:24 +00:00
|
|
|
free(v->value);
|
|
|
|
free(v->name);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
2002-09-13 19:43:17 +00:00
|
|
|
TRACE("RegInsert '%s' %p v:%d len:%d\n", name, value, *(int*)value, len);
|
2001-02-24 20:28:24 +00:00
|
|
|
v->type=type;
|
|
|
|
v->len=len;
|
2006-07-02 03:59:36 +00:00
|
|
|
v->value=malloc(len);
|
2001-02-24 20:28:24 +00:00
|
|
|
memcpy(v->value, value, len);
|
2006-07-02 03:59:36 +00:00
|
|
|
v->name=malloc(strlen(fullname)+1);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(v->name, fullname);
|
2001-11-26 01:17:24 +00:00
|
|
|
free(fullname);
|
2001-02-24 20:28:24 +00:00
|
|
|
save_registry();
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2001-07-12 15:27:48 +00:00
|
|
|
static void init_registry(void)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
TRACE("Initializing registry\n");
|
|
|
|
// can't be free-ed - it's static and probably thread
|
|
|
|
// unsafe structure which is stored in glibc
|
|
|
|
|
2001-12-11 22:58:14 +00:00
|
|
|
regpathname = get_path("registry");
|
|
|
|
localregpathname = regpathname;
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
open_registry();
|
|
|
|
insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
|
|
|
|
insert_handle(HKEY_CURRENT_USER, "HKCU");
|
|
|
|
}
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
static reg_handle_t* find_handle_2(long key, const char* subkey)
|
|
|
|
{
|
|
|
|
char* full_name;
|
|
|
|
reg_handle_t* t;
|
|
|
|
if((t=find_handle(key))==0)
|
|
|
|
{
|
|
|
|
TRACE("Invalid key\n");
|
|
|
|
return (reg_handle_t*)-1;
|
|
|
|
}
|
|
|
|
if(subkey==NULL)
|
|
|
|
return t;
|
2006-07-02 03:59:36 +00:00
|
|
|
full_name=malloc(strlen(t->name)+strlen(subkey)+10);
|
2001-02-24 20:28:24 +00:00
|
|
|
strcpy(full_name, t->name);
|
|
|
|
strcat(full_name, "\\");
|
|
|
|
strcat(full_name, subkey);
|
|
|
|
t=find_handle_by_name(full_name);
|
|
|
|
free(full_name);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
char* full_name;
|
|
|
|
reg_handle_t* t;
|
|
|
|
struct reg_value* v;
|
|
|
|
TRACE("Opening key %s\n", subkey);
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if(!regs)
|
|
|
|
init_registry()
|
2001-11-26 00:47:58 +00:00
|
|
|
;
|
2001-02-24 20:28:24 +00:00
|
|
|
/* t=find_handle_2(key, subkey);
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if(t==0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if(t==(reg_handle_t*)-1)
|
|
|
|
return -1;
|
2001-11-26 00:47:58 +00:00
|
|
|
*/
|
|
|
|
full_name=build_keyname(key, subkey);
|
2001-02-24 20:28:24 +00:00
|
|
|
if(!full_name)
|
|
|
|
return -1;
|
2001-11-26 00:47:58 +00:00
|
|
|
TRACE("Opening key Fullname %s\n", full_name);
|
|
|
|
v=find_value_by_name(full_name);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
t=insert_handle(generate_handle(), full_name);
|
|
|
|
*newkey=t->handle;
|
|
|
|
free(full_name);
|
2001-11-26 00:47:58 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegCloseKey(long key)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
reg_handle_t *handle;
|
|
|
|
if(key==(long)HKEY_LOCAL_MACHINE)
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
2002-09-13 19:43:17 +00:00
|
|
|
if(key==(long)HKEY_CURRENT_USER)
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
|
|
|
handle=find_handle(key);
|
|
|
|
if(handle==0)
|
|
|
|
return 0;
|
|
|
|
if(handle->prev)
|
|
|
|
handle->prev->next=handle->next;
|
|
|
|
if(handle->next)
|
|
|
|
handle->next->prev=handle->prev;
|
|
|
|
if(handle->name)
|
|
|
|
free(handle->name);
|
|
|
|
if(handle==head)
|
|
|
|
head=head->prev;
|
|
|
|
free(handle);
|
|
|
|
return 1;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
|
|
|
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
struct reg_value* t;
|
|
|
|
char* c;
|
|
|
|
TRACE("Querying value %s\n", value);
|
|
|
|
if(!regs)
|
|
|
|
init_registry();
|
|
|
|
|
|
|
|
c=build_keyname(key, value);
|
|
|
|
if (!c)
|
|
|
|
return 1;
|
|
|
|
t=find_value_by_name(c);
|
|
|
|
free(c);
|
|
|
|
if (t==0)
|
|
|
|
return 2;
|
|
|
|
if (type)
|
|
|
|
*type=t->type;
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
memcpy(data, t->value, (t->len<*count)?t->len:*count);
|
|
|
|
TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
|
|
|
|
}
|
|
|
|
if(*count<t->len)
|
|
|
|
{
|
|
|
|
*count=t->len;
|
|
|
|
return ERROR_MORE_DATA;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
*count=t->len;
|
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
|
2001-11-26 00:47:58 +00:00
|
|
|
void* classs, long options, long security,
|
|
|
|
void* sec_attr, int* newkey, int* status)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
reg_handle_t* t;
|
|
|
|
char* fullname;
|
|
|
|
struct reg_value* v;
|
|
|
|
// TRACE("Creating/Opening key %s\n", name);
|
|
|
|
if(!regs)
|
|
|
|
init_registry();
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
fullname=build_keyname(key, name);
|
|
|
|
if (!fullname)
|
|
|
|
return 1;
|
|
|
|
TRACE("Creating/Opening key %s\n", fullname);
|
|
|
|
v=find_value_by_name(fullname);
|
|
|
|
if(v==0)
|
|
|
|
{
|
|
|
|
int qw=45708;
|
|
|
|
v=insert_reg_value(key, name, DIR, &qw, 4);
|
|
|
|
if (status) *status=REG_CREATED_NEW_KEY;
|
|
|
|
// return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
t=insert_handle(generate_handle(), fullname);
|
|
|
|
*newkey=t->handle;
|
|
|
|
free(fullname);
|
|
|
|
return 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
2001-07-29 16:44:37 +00:00
|
|
|
|
2001-11-26 00:47:58 +00:00
|
|
|
/*
|
|
|
|
LONG RegEnumValue(
|
|
|
|
HKEY hKey, // handle to key to query
|
|
|
|
DWORD dwIndex, // index of value to query
|
|
|
|
LPTSTR lpValueName, // address of buffer for value string
|
|
|
|
LPDWORD lpcbValueName, // address for size of value buffer
|
|
|
|
LPDWORD lpReserved, // reserved
|
|
|
|
LPDWORD lpType, // address of buffer for type code
|
|
|
|
LPBYTE lpData, // address of buffer for value data
|
|
|
|
LPDWORD lpcbData // address for size of data buffer
|
|
|
|
);
|
|
|
|
*/
|
|
|
|
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
|
2001-07-29 16:44:37 +00:00
|
|
|
LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
|
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
// currenly just made to support MSZH & ZLIB
|
|
|
|
//printf("Reg Enum 0x%x %d %s %d data: %p %d %d >%s<\n", hkey, index,
|
|
|
|
// value, *val_count, data, *count, reg_size, data);
|
|
|
|
reg_handle_t* t = find_handle(hkey);
|
|
|
|
if (t && index < 10)
|
2001-07-29 16:44:37 +00:00
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
struct reg_value* v=find_value_by_name(t->name);
|
|
|
|
if (v)
|
2001-07-29 16:44:37 +00:00
|
|
|
{
|
2001-11-26 00:47:58 +00:00
|
|
|
memcpy(data, v->value, (v->len < *count) ? v->len : *count);
|
|
|
|
if(*count < v->len)
|
|
|
|
*count = v->len;
|
|
|
|
if (type)
|
2001-07-29 16:44:37 +00:00
|
|
|
*type = v->type;
|
|
|
|
//printf("Found handle %s\n", v->name);
|
2001-11-26 00:47:58 +00:00
|
|
|
return 0;
|
2001-07-29 16:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-26 00:47:58 +00:00
|
|
|
return ERROR_NO_MORE_ITEMS;
|
2001-07-29 16:44:37 +00:00
|
|
|
}
|
|
|
|
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
struct reg_value* t;
|
|
|
|
char* c;
|
2002-09-13 19:43:17 +00:00
|
|
|
TRACE("Request to set value %s %d\n", name, *(const int*)data);
|
2001-02-24 20:28:24 +00:00
|
|
|
if(!regs)
|
2001-12-11 22:58:14 +00:00
|
|
|
init_registry();
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
c=build_keyname(key, name);
|
|
|
|
if(c==NULL)
|
|
|
|
return 1;
|
|
|
|
insert_reg_value(key, name, v2, data, size);
|
|
|
|
free(c);
|
|
|
|
return 0;
|
2001-11-26 00:47:58 +00:00
|
|
|
}
|
2001-12-11 22:58:14 +00:00
|
|
|
|
2003-04-21 20:13:21 +00:00
|
|
|
long __stdcall RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
|
2001-12-11 22:58:14 +00:00
|
|
|
LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
|
|
|
|
LPFILETIME lpftLastWriteTime)
|
|
|
|
{
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
}
|