public void MessageSend(Event Event, MacAddress ToMacAddress, byte[] Data = null) { if (Data == null) { Data = new byte[0]; } ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Green, () => { Console.WriteLine( "< Matching.SendMessage(Event={0}, From={1}, To={2}, Data={3})", Event, sceNet.SelfMacAddress.ToString(), ToMacAddress.ToString(), BitConverter.ToString(Data) ); ArrayUtils.HexDump(Data); }); var Out = new MemoryStream(); Out.WriteStruct(new Header() { Event = Event, FromMacAddress = sceNet.SelfMacAddress, ToMacAddress = ToMacAddress, DataLength = Data.Length }); Out.WriteBytes(Data); SendRaw(Out.ToArray()); }
public static MacAddress GenerateRandom() { var MacAddress = new MacAddress(); *(uint *)MacAddress.Data = (uint)DateTime.UtcNow.GetTotalMicroseconds(); return(MacAddress); }
/// <summary> /// /// </summary> /// <param name="Event"></param> /// <param name="Mac"></param> /// <param name="Data"></param> public void NotifyEvent(Event Event, MacAddress Mac, byte[] Data) { var MacPartition = HleMemoryManager.GetPartition(MemoryPartitions.User).Allocate(8); PointerUtils.Memcpy((byte *)MacPartition.LowPointer, new ArraySegment <byte>(Mac.GetAddressBytes())); { var DataPartition = HleMemoryManager.GetPartition(MemoryPartitions.User).Allocate(Data.Length); PointerUtils.Memcpy((byte *)DataPartition.LowPointer, new ArraySegment <byte>(Data)); Console.WriteLine( "Executing callback. Matching.NotifyEvent: 0x{0:X8}, {1}, {2}, 0x{3:X8}, {4}, 0x{5:X8}", this.Callback, this.GetUidIndex(InjectContext), Event, MacPartition.Low, DataPartition.Size, DataPartition.Low); HleInterop.ExecuteFunctionLater( this.Callback, this.GetUidIndex(InjectContext), (int)Event, MacPartition.Low, DataPartition.Size, (DataPartition.Size != 0) ? DataPartition.Low : 0 ); DataPartition.DeallocateFromParent(); } MacPartition.DeallocateFromParent(); }
public void SelectTarget(MacAddress MacAddress, byte[] Data) { if (ReceivedJoinMacAddressPending && MacAddress == ReceivedJoinMacAddress) { ReceivedJoinMacAddressPending = false; MessageSend(Event.Accept, MacAddress, Data); } else { MessageSend(Event.Join, MacAddress, Data); } }
public static MacAddress GetNative() { var MacAddress = new MacAddress(); var PhysicalAddress = NetworkInterface.GetAllNetworkInterfaces() .First(nic => nic.OperationalStatus == OperationalStatus.Up).GetPhysicalAddress(); var Bytes = PhysicalAddress.GetAddressBytes(); for (int n = 0; n < 8; n++) { MacAddress.Data[n] = (n < Bytes.Length) ? Bytes[n] : (byte)0; } return(MacAddress); }
private void MessageReceived(Header PacketHeader, byte[] PacketData) { ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Blue, () => { Console.WriteLine("> Matching.MessageReceived(): {0}", PacketHeader); ArrayUtils.HexDump(PacketData); }); if (PacketHeader.Event == Event.Join) { ReceivedJoinMacAddress = PacketHeader.FromMacAddress; ReceivedJoinMacAddressPending = true; } if (PacketHeader.Event != Event.InternalPing) { NotifyEvent(PacketHeader.Event, PacketHeader.FromMacAddress, PacketData); } }
public int sceNetAdhocMatchingCancelTargetWithOpt(Matching Matching, ref MacAddress MacAddress, int DataLength, byte *DataPointer) { Matching.CancelTarget(MacAddress, PointerUtils.PointerToByteArray(DataPointer, DataLength)); return(0); }
public int sceNetAdhocMatchingCancelTarget(Matching Matching, ref MacAddress MacAddress) { Matching.CancelTarget(MacAddress); return(0); }
public int sceNetAdhocMatchingAbortSendData(Matching Matching, ref MacAddress MacAddress) { return(0); }
public int sceNetAdhocMatchingSendData(Matching Matching, ref MacAddress MacAddress, int DataLength, byte *DataPointer) { Matching.SendData(MacAddress, PointerUtils.PointerToByteArray(DataPointer, DataLength)); return(0); }
public void CancelTarget(MacAddress MacAddress, byte[] Data = null) { throw new NotImplementedException(); }
public void SendData(MacAddress MacAddress, byte[] Data) { MessageSend(Event.Data, MacAddress, Data); }