public unsafe static Hashtable DumpTable(RecvTable *table, int offset = 0) { Hashtable hashtable = new Hashtable(); for (int i = 0; i < table->GetPropsCount(); i++) { RecvProp *prop = (RecvProp *)((IntPtr)table->GetRecvProps() + i * sizeof(RecvProp)); if (prop == null) { continue; } if (prop->GetName().Contains("baseclass") || prop->GetName().StartsWith("0") || prop->GetName().StartsWith("1") || prop->GetName().StartsWith("2")) { continue; } if (!hashtable.ContainsKey(prop->GetName())) { hashtable.Add(prop->GetName(), prop->GetOffset() + offset); } if (prop->GetDataTable() != null) { foreach (DictionaryEntry entry in DumpTable(prop->GetDataTable(), prop->GetOffset() + offset)) { if (!hashtable.ContainsKey(entry.Key)) { hashtable.Add(entry.Key, entry.Value); } } } } return(hashtable); }
public static void Hook() { if (bHooked) { return; } for (ClientClass *pClass = g_Client.GetAllClasses(); (IntPtr)pClass != IntPtr.Zero; pClass = pClass->m_pNext) { if (Marshal.PtrToStringAnsi((IntPtr)pClass->m_pNetworkName) == "CBaseViewModel") { var pClassTable = pClass->m_pRecvTable; for (int nIndex = 0; nIndex < pClassTable->m_nProps; nIndex++) { var pProp = &pClassTable->m_pProps[nIndex]; if (Marshal.PtrToStringAnsi((IntPtr)pProp->m_pVarName) == "m_nSequence") { o_pSequence_Prop = pProp; o_ProxyFn = pProp->m_ProxyFn; o_SetViewModelSequence = Marshal.GetDelegateForFunctionPointer <SetViewModelSequence>(o_ProxyFn); pProp->m_ProxyFn = Marshal.GetFunctionPointerForDelegate(hkSetViewModelSequence_callback); bHooked = true; return; } } } } }