1. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

бан на проекте

Тема в разделе "Оффтопик", создана пользователем BeerBear, 22 дек 2015.

Статус темы:
Закрыта.
  1. Автор темы
    BeerBear

    BeerBear Активный участник Пользователь

    Баллы:
    61
    Копался в структуре лаунчера и нашел классы, где про uuid что-то идет, кажется это и есть то, что нужно?
    Кто-нибудь может расшифровать?
    1 класс:
    Код:
    package org.caver.m2k;
    
    import com.mojang.launcher.OperatingSystem;
    import java.lang.reflect.InvocationTargetException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    public class m2kRegistry
    {
      private static final String m2kKey = "SOFTWARE\\m2k";
      private static final String uuidKey = "uuid";
    
      public static String readkey()
      {
        String uuid = null;
        if (OperatingSystem.getCurrentPlatform().equals(OperatingSystem.WINDOWS)) {
          try
          {
            uuid = WinRegistry.readString(-2147483647, "SOFTWARE\\m2k", "uuid");
          }
          catch (IllegalArgumentException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
          catch (IllegalAccessException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
          catch (InvocationTargetException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        return uuid;
      }
    
      public static Boolean writeKey(String uuid)
      {
        if (OperatingSystem.getCurrentPlatform().equals(OperatingSystem.WINDOWS)) {
          try
          {
            WinRegistry.createKey(-2147483647, "SOFTWARE\\m2k");
            WinRegistry.writeStringValue(-2147483647, "SOFTWARE\\m2k", "uuid", uuid);
            return Boolean.valueOf(true);
          }
          catch (IllegalArgumentException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
          catch (IllegalAccessException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
          catch (InvocationTargetException ex)
          {
            Logger.getLogger(m2kRegistry.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        return Boolean.valueOf(false);
      }
    }
    
    2 класс:
    Код:
    package org.caver.m2k;
    
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.prefs.Preferences;
    
    public class WinRegistry
    {
      public static final int HKEY_CURRENT_USER = -2147483647;
      public static final int HKEY_LOCAL_MACHINE = -2147483646;
      public static final int REG_SUCCESS = 0;
      public static final int REG_NOTFOUND = 2;
      public static final int REG_ACCESSDENIED = 5;
      private static final int KEY_ALL_ACCESS = 983103;
      private static final int KEY_READ = 131097;
      private static Preferences userRoot = ;
      private static Preferences systemRoot = Preferences.systemRoot();
      private static Class<? extends Preferences> userClass = userRoot.getClass();
      private static Method regOpenKey = null;
      private static Method regCloseKey = null;
      private static Method regQueryValueEx = null;
      private static Method regEnumValue = null;
      private static Method regQueryInfoKey = null;
      private static Method regEnumKeyEx = null;
      private static Method regCreateKeyEx = null;
      private static Method regSetValueEx = null;
      private static Method regDeleteKey = null;
      private static Method regDeleteValue = null;
    
      static
      {
        try
        {
          regOpenKey = userClass.getDeclaredMethod("WindowsRegOpenKey", new Class[] { Integer.TYPE, byte[].class, Integer.TYPE });
       
          regOpenKey.setAccessible(true);
          regCloseKey = userClass.getDeclaredMethod("WindowsRegCloseKey", new Class[] { Integer.TYPE });
       
          regCloseKey.setAccessible(true);
          regQueryValueEx = userClass.getDeclaredMethod("WindowsRegQueryValueEx", new Class[] { Integer.TYPE, byte[].class });
       
          regQueryValueEx.setAccessible(true);
          regEnumValue = userClass.getDeclaredMethod("WindowsRegEnumValue", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE });
       
          regEnumValue.setAccessible(true);
          regQueryInfoKey = userClass.getDeclaredMethod("WindowsRegQueryInfoKey1", new Class[] { Integer.TYPE });
       
          regQueryInfoKey.setAccessible(true);
          regEnumKeyEx = userClass.getDeclaredMethod("WindowsRegEnumKeyEx", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE });
       
          regEnumKeyEx.setAccessible(true);
          regCreateKeyEx = userClass.getDeclaredMethod("WindowsRegCreateKeyEx", new Class[] { Integer.TYPE, byte[].class });
       
          regCreateKeyEx.setAccessible(true);
          regSetValueEx = userClass.getDeclaredMethod("WindowsRegSetValueEx", new Class[] { Integer.TYPE, byte[].class, byte[].class });
       
          regSetValueEx.setAccessible(true);
          regDeleteValue = userClass.getDeclaredMethod("WindowsRegDeleteValue", new Class[] { Integer.TYPE, byte[].class });
       
          regDeleteValue.setAccessible(true);
          regDeleteKey = userClass.getDeclaredMethod("WindowsRegDeleteKey", new Class[] { Integer.TYPE, byte[].class });
       
          regDeleteKey.setAccessible(true);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    
      public static String readString(int hkey, String key, String valueName)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        if (hkey == -2147483646) {
          return readString(systemRoot, hkey, key, valueName);
        }
        if (hkey == -2147483647) {
          return readString(userRoot, hkey, key, valueName);
        }
        throw new IllegalArgumentException("hkey=" + hkey);
      }
    
      public static Map<String, String> readStringValues(int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        if (hkey == -2147483646) {
          return readStringValues(systemRoot, hkey, key);
        }
        if (hkey == -2147483647) {
          return readStringValues(userRoot, hkey, key);
        }
        throw new IllegalArgumentException("hkey=" + hkey);
      }
    
      public static List<String> readStringSubKeys(int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        if (hkey == -2147483646) {
          return readStringSubKeys(systemRoot, hkey, key);
        }
        if (hkey == -2147483647) {
          return readStringSubKeys(userRoot, hkey, key);
        }
        throw new IllegalArgumentException("hkey=" + hkey);
      }
    
      public static void createKey(int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        if (hkey == -2147483646)
        {
          int[] ret = createKey(systemRoot, hkey, key);
          regCloseKey.invoke(systemRoot, new Object[] { new Integer(ret[0]) });
        }
        else if (hkey == -2147483647)
        {
          int[] ret = createKey(userRoot, hkey, key);
          regCloseKey.invoke(userRoot, new Object[] { new Integer(ret[0]) });
        }
        else
        {
          throw new IllegalArgumentException("hkey=" + hkey);
        }
        int[] ret;
        if (ret[1] != 0) {
          throw new IllegalArgumentException("rc=" + ret[1] + "  key=" + key);
        }
      }
    
      public static void writeStringValue(int hkey, String key, String valueName, String value)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        if (hkey == -2147483646) {
          writeStringValue(systemRoot, hkey, key, valueName, value);
        } else if (hkey == -2147483647) {
          writeStringValue(userRoot, hkey, key, valueName, value);
        } else {
          throw new IllegalArgumentException("hkey=" + hkey);
        }
      }
    
      public static void deleteKey(int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int rc = -1;
        if (hkey == -2147483646) {
          rc = deleteKey(systemRoot, hkey, key);
        } else if (hkey == -2147483647) {
          rc = deleteKey(userRoot, hkey, key);
        }
        if (rc != 0) {
          throw new IllegalArgumentException("rc=" + rc + "  key=" + key);
        }
      }
    
      public static void deleteValue(int hkey, String key, String value)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int rc = -1;
        if (hkey == -2147483646) {
          rc = deleteValue(systemRoot, hkey, key, value);
        } else if (hkey == -2147483647) {
          rc = deleteValue(userRoot, hkey, key, value);
        }
        if (rc != 0) {
          throw new IllegalArgumentException("rc=" + rc + "  key=" + key + "  value=" + value);
        }
      }
    
      private static int deleteValue(Preferences root, int hkey, String key, String value)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int[] handles = (int[])regOpenKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key), new Integer(983103) });
        if (handles[1] != 0) {
          return handles[1];
        }
        int rc = ((Integer)regDeleteValue.invoke(root, new Object[] { new Integer(handles[0]), toCstr(value) })).intValue();
     
        regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
        return rc;
      }
    
      private static int deleteKey(Preferences root, int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int rc = ((Integer)regDeleteKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key) })).intValue();
     
        return rc;
      }
    
      private static String readString(Preferences root, int hkey, String key, String value)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int[] handles = (int[])regOpenKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key), new Integer(131097) });
        if (handles[1] != 0) {
          return null;
        }
        byte[] valb = (byte[])regQueryValueEx.invoke(root, new Object[] { new Integer(handles[0]), toCstr(value) });
     
        regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
        return valb != null ? new String(valb).trim() : null;
      }
    
      private static Map<String, String> readStringValues(Preferences root, int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        HashMap<String, String> results = new HashMap();
        int[] handles = (int[])regOpenKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key), new Integer(131097) });
        if (handles[1] != 0) {
          return null;
        }
        int[] info = (int[])regQueryInfoKey.invoke(root, new Object[] { new Integer(handles[0]) });
     
        int count = info[0];
        int maxlen = info[3];
        for (int index = 0; index < count; index++)
        {
          byte[] name = (byte[])regEnumValue.invoke(root, new Object[] { new Integer(handles[0]), new Integer(index), new Integer(maxlen + 1) });
       
          String value = readString(hkey, key, new String(name));
          results.put(new String(name).trim(), value);
        }
        regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
        return results;
      }
    
      private static List<String> readStringSubKeys(Preferences root, int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        List<String> results = new ArrayList();
        int[] handles = (int[])regOpenKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key), new Integer(131097) });
        if (handles[1] != 0) {
          return null;
        }
        int[] info = (int[])regQueryInfoKey.invoke(root, new Object[] { new Integer(handles[0]) });
     
        int count = info[0];
        int maxlen = info[3];
        for (int index = 0; index < count; index++)
        {
          byte[] name = (byte[])regEnumKeyEx.invoke(root, new Object[] { new Integer(handles[0]), new Integer(index), new Integer(maxlen + 1) });
       
          results.add(new String(name).trim());
        }
        regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
        return results;
      }
    
      private static int[] createKey(Preferences root, int hkey, String key)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        return (int[])regCreateKeyEx.invoke(root, new Object[] { new Integer(hkey), toCstr(key) });
      }
    
      private static void writeStringValue(Preferences root, int hkey, String key, String valueName, String value)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      {
        int[] handles = (int[])regOpenKey.invoke(root, new Object[] { new Integer(hkey), toCstr(key), new Integer(983103) });
     
        regSetValueEx.invoke(root, new Object[] { new Integer(handles[0]), toCstr(valueName), toCstr(value) });
     
        regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
      }
    
      private static byte[] toCstr(String str)
      {
        byte[] result = new byte[str.length() + 1];
        for (int i = 0; i < str.length(); i++) {
          result[i] = ((byte)str.charAt(i));
        }
        result[str.length()] = 0;
        return result;
      }
    }
    
     
  2. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
    Тут и так все понятно, лучше отпиши что за проект.
    Тут тебе нужны пару функций, записывалка в реестр и читалка.
    Пруфит.
    P.s научи лаунчер читать уид из файлика рядом с лаунчером и все збс станет :D.
    И зафлуди их мультами.
     
  3. niki96

    niki96 Старожил Пользователь

    Баллы:
    123
    Он его читает из реестра, не легче просто там его менять?
     
  4. log_inil

    log_inil Активный участник Пользователь

    Баллы:
    88
    m2k => minecraft2000
     
  5. Автор темы
    BeerBear

    BeerBear Активный участник Пользователь

    Баллы:
    61
    Закройте тему.
     
  6. Starr

    Starr Активный участник Пользователь

    Баллы:
    98
    @RikkiLook, @slenky
     
Статус темы:
Закрыта.

Поделиться этой страницей