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 __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 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 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 ocmem_buf *__ocmem_allocate_range(int id, unsigned long min, unsigned long max, unsigned long step, bool block, bool wait) { struct ocmem_handle *handle = NULL; int ret = 0; handle = generate_handle(); if (!handle) { pr_err("ocmem: Unable to generate handle\n"); return NULL; } mutex_lock(&handle->handle_mutex); ret = process_allocate(id, handle, min, max, step, block, wait); mutex_unlock(&handle->handle_mutex); if (ret) { pr_err("ocmem allocation failed\n"); free_handle(handle); return NULL; } else return handle_to_buffer(handle); }
static bool load_registry_key(long handle, TiXmlElement *key) { if(!key) return false; const char* path = key->Attribute("path"); if(!path) { reg_handle_t* t = find_handle(handle); CLog::Log(LOGERROR, __FUNCTION__" - key element is missing path, parent %s", t ? t->name : ""); return false; } if(!handle) { int span = strcspn(path, "\\"); if(strncmp(path, "HKCU",span) == 0 || strncmp(path, "HKEY_CURRENT_USER", span) == 0) { handle = (long)HKEY_CURRENT_USER; path+=span; } else if(strncmp(path, "HKLM",span) == 0 || strncmp(path, "HKEY_LOCAL_MACHINE", span) == 0) { handle = (long)HKEY_LOCAL_MACHINE; path+=span; } else { CLog::Log(LOGERROR, __FUNCTION__" - invalid root element %s", path); return false; } } char * fullname = build_keyname(handle, path); reg_handle_t *t = insert_handle(generate_handle(), fullname); free(fullname); TiXmlNode *node = NULL; while(node = key->IterateChildren(node)) { TiXmlElement *element = node->ToElement(); if(!element) continue; if(strcmp("value", element->Value()) == 0) { const char* type = element->Attribute("type"); const char* id = element->Attribute("id"); if(!type) type = "string"; if(!id || !id[0]) id = "<default>"; if(strcmp(type, "string") == 0) { const char* str = element->GetText(); if(!str) continue; insert_reg_value(t->handle, id, REG_SZ, str, strlen(str)+1); } else if(strcmp(type, "dword") == 0) { DWORD val = atol(element->GetText()); insert_reg_value(t->handle, id, REG_DWORD, &val, sizeof(DWORD)); } else CLog::Log(LOGERROR, __FUNCTION__" - Unsupported value type"); } else if(strcmp("key", element->Value()) == 0) load_registry_key(t->handle, element); } remove_handle(t); return true; }