long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count) { 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; } else { *count=t->len; } return 0; }
long __stdcall RegCreateKeyExA(long key, const char* name, long reserved, void* classs, long options, long security, void* sec_attr, int* newkey, int* status) { reg_handle_t* t; char* fullname; struct reg_value* v; // TRACE("Creating/Opening key %s\n", name); if(!regs) init_registry(); 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; }
LONG WINAPI dllRegCreateKeyExA (HKEY key, LPCSTR name, DWORD reserved, LPTSTR classs, DWORD options, REGSAM security, LPSECURITY_ATTRIBUTES sec_attr, PHKEY newkey, LPDWORD status) { reg_handle_t* t; char* fullname; struct reg_value* v; // mp_msg(0,0,"Creating/Opening key %s\n", name); if(!regs) init_registry (); fullname=build_keyname((long)key, name); if (!fullname) return 1; //mp_msg(0,0,"Creating/Opening key %s\n", fullname); v=find_value_by_name(fullname); if(v==0) { int qw=45708; v=insert_reg_value((int)key, name, DIR, &qw, 4); if (status) *status=REG_CREATED_NEW_KEY; // return 0; } t=insert_handle(generate_handle(), fullname); *newkey=(HKEY)t->handle; free(fullname); return 0; }
long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey) { char* full_name; reg_handle_t* t; struct reg_value* v; TRACE("Opening key %s\n", subkey); if(!regs) init_registry() ; /* t=find_handle_2(key, subkey); if(t==0) return -1; if(t==(reg_handle_t*)-1) return -1; */ full_name=build_keyname(key, subkey); if(!full_name) return -1; TRACE("Opening key Fullname %s\n", full_name); v=find_value_by_name(full_name); t=insert_handle(generate_handle(), full_name); *newkey=t->handle; free(full_name); return 0; }
LONG WINAPI dllRegOpenKeyExA(HKEY key, LPCSTR subkey, DWORD reserved, REGSAM access, PHKEY newkey) { char* full_name; reg_handle_t* t; struct reg_value* v; if(!regs) init_registry(); full_name=build_keyname((long)key, subkey); if(!full_name) return -1; dbgprintf("RegOpenKeyExA(key 0x%x, subkey %s, reserved %d, access 0x%x, pnewkey 0x%x) => 0\n", key, subkey, reserved, access, newkey); if(newkey) { v=find_value_by_name(full_name); t=insert_handle(generate_handle(), full_name); *newkey=(HKEY)t->handle; dbgprintf(" New key: 0x%x\n", *newkey); } free(full_name); return 0; }
static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len) { // reg_handle_t* t; struct reg_value* v; char* fullname; if((fullname=build_keyname(handle, name))==NULL) { OutputDebugString("Registery:Invalid handle\n"); return NULL; } if((v=find_value_by_name(fullname))==0) //creating new value in registry { regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1)); //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1)); v=regs+reg_size; reg_size++; } else //replacing old one { free(v->value); free(v->name); } //mp_msg(0,0,"RegInsert '%s' %p v:%d len:%d\n", name, value, *(int*)value, len); v->type=type; v->len=len; v->value=(char*)malloc(len); memcpy(v->value, value, len); v->name=(char*)malloc(strlen(fullname)+1); strcpy(v->name, fullname); free(fullname); return v; }
long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count) { 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); if (t==0) { // Hacks for CineForm. if (strcmp(c, "HKCU\\SOFTWARE\\CineForm\\DecoderProperties\\Resolution") == 0) { if (data) *data = 1000; if (type) *type = REG_DWORD; if (count) *count = sizeof(DWORD); free(c); return ERROR_SUCCESS; } if (strcmp(c, "HKCU\\SOFTWARE\\CineForm\\DecoderProperties\\PixelFormats") == 0) { if (data) *data = 0xffff; if (type) *type = REG_DWORD; if (count) *count = sizeof(DWORD); free(c); return ERROR_SUCCESS; } free(c); return ERROR_FILE_NOT_FOUND; } free(c); 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; } else { *count=t->len; } return ERROR_SUCCESS; }
LONG WINAPI dllRegQueryValueExA (HKEY key, LPCSTR value, LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count) { struct reg_value* t; char* c; if(!regs) init_registry(); c=build_keyname((long)key, value); if (!c) return 1; t=find_value_by_name(c); free(c); if (t==0){ dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)" " => 0x%x\n", key, value, reserved, data, count, 2); memset(data, 0, *count); return 2; } if (type) *type=t->type; if (data) { memcpy(data, t->value, (t->len<(int)*count)?t->len:(int)*count); //mp_msg(0,0,"returning %d bytes: %d\n", t->len, *(int*)data); } if((int)*count<t->len) { *count=t->len; dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)" " => 0x%x\n", key, value, reserved, data, count, ERROR_MORE_DATA); if(data && count)dbgprintf(" read %d bytes: '%s'\n", *count, data); return ERROR_MORE_DATA; } else { *count=t->len; } dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)" " => 0x%x\n", key, value, reserved, data, count, 0); if(data && count)dbgprintf(" read %d bytes: '%s'\n", *count, data); return 0; }
long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count) { // 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) { struct reg_value* v=find_value_by_name(t->name); if (v) { memcpy(data, v->value, (v->len < *count) ? v->len : *count); if(*count < v->len) *count = v->len; if (type) *type = v->type; //printf("Found handle %s\n", v->name); return 0; } } return ERROR_NO_MORE_ITEMS; }
static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len) { 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 = realloc(regs, sizeof(struct reg_value) * (reg_size +1 )); //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1)); v=regs+reg_size; reg_size++; } else //replacing old one { free(v->value); free(v->name); } TRACE("RegInsert '%s' %p v:%d len:%d\n", name, value, *(int*)value, len); v->type=type; v->len=len; v->value=malloc(len); memcpy(v->value, value, len); v->name=malloc(strlen(fullname)+1); strcpy(v->name, fullname); free(fullname); save_registry(); return v; }