|
个人感觉腾讯把关的游戏质量还是很严格的,而且确实越来越好。比如去年我还能破解那些游戏,看看源代码,今年新发布的腾讯上的游戏全部都加密过了。用的方法应该和以前说过的一样,幸好我可以去小平台下载游戏的老版本去看源代码。
先说一个我现在正在研究的问题吧,android上的代码热更新。我看过我叫MT2,盗梦英雄,酷酷爱魔兽等,只要使用U3d的,我都会去稍微看下,除了今天新看的天天传奇,暂时没有发现任何热更新代码的策略和逻辑。百度上所说的啥lua啊,C#脚本啊,腾讯平台上应该没有采用这种手段的,个人也觉得lua性能吃不消。而另一种就是将逻辑抽出到一个dll里面,然后利用反射实现代码的更新。
然后今天看了下天天传奇的,首先他确实将逻辑抽出来了。一般游戏逻辑dll都有3M以上,它只有500k。所以肯定还有其他逻辑放到了另一个dll。果然我检查了下,发现Assembly-CSharp-firstpass.dll特别大,反编译后里面确实有全部的游戏逻辑。
但我看了下代码,它有这样一个类:
public class NgAssembly { // Fields
public static BindingFlags m_bindingAttr = (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); // Methods
private static object GetField(object inObj, string fieldName)
{ object obj2 = null; FieldInfo field = inObj.GetType().GetField(fieldName); if (field != null)
{ obj2 = field.GetValue(inObj);
} return obj2;
}
public static object GetProperty(object srcObj, string fieldName)
{ PropertyInfo property = srcObj.GetType().GetProperty(fieldName, m_bindingAttr); if (((property != null) && property.CanRead) && (property.GetIndexParameters().[url=http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.5.0:7cec85d7bea7798e/System.Array/property ength:Int32]Length[/url] == 0))
{ return property.GetValue(srcObj, null);
} ssLogger.LogWarning(property.Name + " could not be read."); return null;
}
public static T GetReference<T>(object inObj, string fieldName) where T: class { return (GetField(inObj, fieldName) as T);
}
public static T GetValue<T>(object inObj, string fieldName) where T: struct { return (T) GetField(inObj, fieldName);
}
public static void LogFieldsPropertis(Object srcObj)
{
}
public static void SetField(object inObj, string fieldName, object newValue)
{ FieldInfo field = inObj.GetType().GetField(fieldName); if (field != null)
{ field.SetValue(inObj, newValue);
}
}
public static void SetProperty(object srcObj, string fieldName, object newValue)
{
PropertyInfo property = srcObj.GetType().GetProperty(fieldName, m_bindingAttr); if ((property != null) && property.CanWrite)
{
property.SetValue(srcObj, newValue, null);
}
else { ssLogger.LogWarning(property.Name + " could not be write.");
}
}
}
对于反射我不是很了解,但应该就是它去取dll里面的类定义吧。另一个问题在于我看到大部分的逻辑依然还是直接用类本身,也就是说,我感觉他虽然抽出了dll,但实际上是没有实现代码热更新的功能,
我也举得覆盖Assembly-CSharp-firstpass.dll应该不太可能吧。
不知道有没有人也感兴趣的,一起研究讨论下?
|
|