Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
{
    char* c;
    TRACE("Request to set value %s %d\n", name, *(const int*)data);
    if(!regs)
	init_registry();

    c=build_keyname(key, name);
    if(c==NULL)
	return 1;
    insert_reg_value(key, name, v2, data, size);
    free(c);
    return 0;
}
Ejemplo n.º 4
0
long RegSetValueExA(long key, const char* name, long v1, long v2, const void* data, long size)
{
    /* struct reg_value* t; -- unused */
    char* c;
    TRACE("Request to set value %s\n", name);
    if(!regs)
	init_registry();

    c=build_keyname(key, name);
    if(c==NULL)
	return 1;
    insert_reg_value(key, name, v2, data, size);
    free(c);
    return 0;
}
Ejemplo n.º 5
0
LONG WINAPI dllRegSetValueExA(HKEY key, LPCTSTR name, DWORD v1,
                              DWORD v2, const BYTE * data, DWORD size)
{
  // struct reg_value* t;
  char* c;
  //mp_msg(0,0,"Request to set value %s %d\n", name, *(const int*)data);
  if(!regs)
    init_registry
    ();

  c=build_keyname((long)key, name);
  if(c==NULL)
    return 1;
  insert_reg_value((int)key, name, v2, data, size);
  free(c);
  return 0;
}
Ejemplo n.º 6
0
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;
}