private void RestoreOriginalFunction() { byte[] numArray = new byte[] { 144, 144 }; MemoryManager.WriteBytes(this.offset_MyFunc + 36, numArray); MemoryManager.WriteBytes(cOptions.PacketSendFunction, this.OriginalBytes); Thread.Sleep(500); InjectHelper.FreeMemory(this.processHandle, this.offset_MyFunc, (int)this._ListenFunction.Length); InjectHelper.FreeMemory(this.processHandle, this.offset_data_addr, 4); InjectHelper.FreeMemory(this.processHandle, this.offset_data_size, 4); InjectHelper.FreeMemory(this.processHandle, this.offset_flag, 4); }
public void SendPacket(byte[] packetData) { IntPtr openProcessHandle = MemoryManager.OpenProcessHandle; int num = InjectHelper.AllocateMemory(openProcessHandle, (int)packetData.Length); MemoryManager.WriteBytes(num, packetData); byte[] bytes = BitConverter.GetBytes(num); if (this._sendPacketOpcodeAddress == 0) { this.LoadSendPacketOpcode(openProcessHandle); } MemoryManager.WriteBytes(this._packetAddressLocation, bytes); MemoryManager.WriteBytes(this._packetSizeAddress, BitConverter.GetBytes((int)packetData.Length)); IntPtr intPtr = InjectHelper.CreateRemoteThread(openProcessHandle, this._sendPacketOpcodeAddress); WinApi.WaitForSingleObject(intPtr, 100); WinApi.CloseHandle(intPtr); InjectHelper.FreeMemory(openProcessHandle, num, (int)packetData.Length); InjectHelper.FreeMemory(openProcessHandle, this._sendPacketOpcodeAddress, (int)this._sendPacketOpcode.Length); }