diff options
author | Marc-André Moreau <marcandre.moreau@gmail.com> | 2012-04-03 05:12:44 +0400 |
---|---|---|
committer | Marc-André Moreau <marcandre.moreau@gmail.com> | 2012-04-03 05:12:44 +0400 |
commit | 21be5931871ef18b95e898ea5638f1646c3b2e6e (patch) | |
tree | ad0752d603ae4f72cf7ff44779df23b55286cce8 /FreeRDP |
FreeRDP-Sharp: Initial commit
Diffstat (limited to 'FreeRDP')
34 files changed, 3304 insertions, 0 deletions
diff --git a/FreeRDP/AssemblyInfo.cs b/FreeRDP/AssemblyInfo.cs new file mode 100644 index 0000000..36befdd --- /dev/null +++ b/FreeRDP/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("FreeRDP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("FreeRDP")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/FreeRDP/Cache/BitmapCache.cs b/FreeRDP/Cache/BitmapCache.cs new file mode 100644 index 0000000..2a21bf7 --- /dev/null +++ b/FreeRDP/Cache/BitmapCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Bitmap Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpBitmapCache + { + + } +} + diff --git a/FreeRDP/Cache/BrushCache.cs b/FreeRDP/Cache/BrushCache.cs new file mode 100644 index 0000000..ee7923a --- /dev/null +++ b/FreeRDP/Cache/BrushCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Brush Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpBrushCache + { + + } +} + diff --git a/FreeRDP/Cache/Cache.cs b/FreeRDP/Cache/Cache.cs new file mode 100644 index 0000000..cd4d8ac --- /dev/null +++ b/FreeRDP/Cache/Cache.cs @@ -0,0 +1,36 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpCache + { + public rdpGlyphCache* glyph; + public rdpBrushCache* brush; + public rdpPointerCache* pointer; + public rdpBitmapCache* bitmap; + public rdpOffscreenCache* offscreen; + public rdpPaletteCache* palette; + } +} + diff --git a/FreeRDP/Cache/GlyphCache.cs b/FreeRDP/Cache/GlyphCache.cs new file mode 100644 index 0000000..ec45d95 --- /dev/null +++ b/FreeRDP/Cache/GlyphCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Glyph Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpGlyphCache + { + + } +} + diff --git a/FreeRDP/Cache/OffscreenCache.cs b/FreeRDP/Cache/OffscreenCache.cs new file mode 100644 index 0000000..8b145ff --- /dev/null +++ b/FreeRDP/Cache/OffscreenCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Offscreen Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpOffscreenCache + { + + } +} + diff --git a/FreeRDP/Cache/PaletteCache.cs b/FreeRDP/Cache/PaletteCache.cs new file mode 100644 index 0000000..696abf6 --- /dev/null +++ b/FreeRDP/Cache/PaletteCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Palette Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPaletteCache + { + + } +} + diff --git a/FreeRDP/Cache/PointerCache.cs b/FreeRDP/Cache/PointerCache.cs new file mode 100644 index 0000000..cda0edf --- /dev/null +++ b/FreeRDP/Cache/PointerCache.cs @@ -0,0 +1,31 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Pointer Cache + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPointerCache + { + + } +} + diff --git a/FreeRDP/Codec/FrameMarkerCommand.cs b/FreeRDP/Codec/FrameMarkerCommand.cs new file mode 100644 index 0000000..182a3c4 --- /dev/null +++ b/FreeRDP/Codec/FrameMarkerCommand.cs @@ -0,0 +1,59 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Frame Marker Command + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; + +namespace FreeRDP +{ + public class FrameMarkerCommand : SurfaceCommand + { + private UInt16 frameAction; + private UInt32 frameId; + + public FrameMarkerCommand() + { + } + + public override void Read(BinaryReader fp) + { + frameAction = fp.ReadUInt16(); /* frameAction */ + frameId = fp.ReadUInt32(); /* frameId */ + } + + public override byte[] Write() + { + byte[] buffer = new byte[2 + 6]; + BinaryWriter s = new BinaryWriter(new MemoryStream(buffer)); + + s.Write(CmdType); + + s.Write(frameAction); + s.Write(frameId); + + return buffer; + } + + public override UInt16 GetCmdType() + { + return CMDTYPE_FRAME_MARKER; + } + } +} + diff --git a/FreeRDP/Codec/Rfx.cs b/FreeRDP/Codec/Rfx.cs new file mode 100644 index 0000000..cc456d0 --- /dev/null +++ b/FreeRDP/Codec/Rfx.cs @@ -0,0 +1,67 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RemoteFX + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class Rfx + { + protected IntPtr handle; + + public enum RFX_PIXEL_FORMAT + { + BGRA = 0, + RGBA = 1, + BGR = 2, + RGB = 3, + BGR565_LE = 4, + RGB565_LE = 5, + PALETTE4_PLANER = 6, + PALETTE8 = 7 + } + + [DllImport("libfreerdp-codec")] + public static extern IntPtr rfx_context_new(); + + [DllImport("libfreerdp-codec")] + public static extern void rfx_context_free(IntPtr handle); + + [DllImport("libfreerdp-codec")] + public static extern void rfx_context_set_pixel_format(IntPtr handle, RFX_PIXEL_FORMAT format); + + public Rfx() + { + handle = rfx_context_new(); + rfx_context_set_pixel_format(handle, RFX_PIXEL_FORMAT.RGBA); + } + + public RfxMessage ParseMessage(byte[] data, UInt32 length) + { + return RfxMessage.Parse(handle, data, length); + } + + ~Rfx() + { + rfx_context_free(handle); + } + } +} + diff --git a/FreeRDP/Codec/RfxMessage.cs b/FreeRDP/Codec/RfxMessage.cs new file mode 100644 index 0000000..8a04c96 --- /dev/null +++ b/FreeRDP/Codec/RfxMessage.cs @@ -0,0 +1,138 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RemoteFX Message + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class RfxMessage + { + IntPtr handle; + IntPtr rfxHandle; + + protected int itiles; + protected int irects; + protected UInt16 nrects; + protected UInt16 ntiles; + + public int RectCount + { + get { return (int) nrects; } + } + + public int TileCount + { + get { return (int) ntiles; } + } + + [StructLayout(LayoutKind.Sequential)] + public struct RFX_RECT + { + public UInt16 x; + public UInt16 y; + public UInt16 width; + public UInt16 height; + } + + [StructLayout(LayoutKind.Sequential)] + public struct RFX_TILE + { + public UInt16 x; + public UInt16 y; + public byte* data; + } + + [DllImport("libfreerdp-codec")] + public static extern IntPtr rfx_process_message(IntPtr rfxHandle, byte[] data, UInt32 length); + + [DllImport("libfreerdp-codec")] + public static extern UInt16 rfx_message_get_tile_count(IntPtr handle); + + [DllImport("libfreerdp-codec")] + public static extern RFX_TILE* rfx_message_get_tile(IntPtr handle, int index); + + [DllImport("libfreerdp-codec")] + public static extern UInt16 rfx_message_get_rect_count(IntPtr handle); + + [DllImport("libfreerdp-codec")] + public static extern RFX_RECT* rfx_message_get_rect(IntPtr handle, int index); + + [DllImport("libfreerdp-codec")] + public static extern void rfx_message_free(IntPtr rfxHandle, IntPtr handle); + + private RfxMessage(IntPtr rfxHandle, IntPtr handle) + { + this.handle = handle; + this.rfxHandle = rfxHandle; + + itiles = irects = 0; + ntiles = nrects = 0; + } + + public static RfxMessage Parse(IntPtr rfxHandle, byte[] data, UInt32 length) + { + IntPtr msgHandle; + + msgHandle = rfx_process_message(rfxHandle, data, length); + RfxMessage message = new RfxMessage(rfxHandle, msgHandle); + + message.ntiles = rfx_message_get_tile_count(msgHandle); + message.nrects = rfx_message_get_rect_count(msgHandle); + + return message; + } + + public bool HasNextTile() + { + return (itiles < ntiles); + } + + public void GetNextTile(byte[] buffer, ref int x, ref int y) + { + RFX_TILE* tile = rfx_message_get_tile(handle, itiles++); + + x = tile->x; + y = tile->y; + + Marshal.Copy(new IntPtr(tile->data), buffer, 0, 4096 * 4); + } + + public bool HasNextRect() + { + return (irects < nrects); + } + + public void GetNextRect(ref int x, ref int y, ref int width, ref int height) + { + RFX_RECT* rect = rfx_message_get_rect(handle, irects++); + + x = rect->x; + y = rect->y; + width = rect->width; + height = rect->height; + } + + ~RfxMessage() + { + rfx_message_free(rfxHandle, handle); + } + } +} + diff --git a/FreeRDP/Codec/SetSurfaceBitsCommand.cs b/FreeRDP/Codec/SetSurfaceBitsCommand.cs new file mode 100644 index 0000000..28a32a6 --- /dev/null +++ b/FreeRDP/Codec/SetSurfaceBitsCommand.cs @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Set Surface Bits Command + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; + +namespace FreeRDP +{ + public class SetSurfaceBitsCommand : SurfaceBitsCommand + { + public SetSurfaceBitsCommand() : base() + { + + } + + public override UInt16 GetCmdType() + { + return CMDTYPE_SET_SURFACE_BITS; + } + } +} diff --git a/FreeRDP/Codec/StreamSurfaceBitsCommand.cs b/FreeRDP/Codec/StreamSurfaceBitsCommand.cs new file mode 100644 index 0000000..962b0ca --- /dev/null +++ b/FreeRDP/Codec/StreamSurfaceBitsCommand.cs @@ -0,0 +1,38 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Stream Surface Bits Command + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; + +namespace FreeRDP +{ + public class StreamSurfaceBitsCommand : SurfaceBitsCommand + { + public StreamSurfaceBitsCommand() : base() + { + + } + + public override UInt16 GetCmdType() + { + return CMDTYPE_STREAM_SURFACE_BITS; + } + } +} + diff --git a/FreeRDP/Codec/SurfaceBitsCommand.cs b/FreeRDP/Codec/SurfaceBitsCommand.cs new file mode 100644 index 0000000..8758fe3 --- /dev/null +++ b/FreeRDP/Codec/SurfaceBitsCommand.cs @@ -0,0 +1,114 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Surface Bits Command + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class SurfaceBitsCommand : SurfaceCommand + { + protected byte[] buffer; + + protected UInt16 destLeft; + protected UInt16 destTop; + protected UInt16 destRight; + protected UInt16 destBottom; + protected Byte bpp; + protected Byte reserved1; + protected Byte reserved2; + protected Byte codecID; + protected UInt16 width; + protected UInt16 height; + protected UInt32 bitmapDataLength; + protected byte[] bitmapData; + + public SurfaceBitsCommand() + { + reserved1 = 0; + reserved2 = 0; + buffer = new byte[4096 * 4]; + } + + public override void Read(BinaryReader fp) + { + destLeft = fp.ReadUInt16(); /* destLeft */ + destTop = fp.ReadUInt16(); /* destTop */ + destRight = fp.ReadUInt16(); /* destRight */ + destBottom = fp.ReadUInt16(); /* destBottom */ + bpp = fp.ReadByte(); /* bpp */ + reserved1 = fp.ReadByte(); /* Reserved1 */ + reserved2 = fp.ReadByte(); /* Reserved2 */ + codecID = fp.ReadByte(); /* codecID */ + width = fp.ReadUInt16(); /* width */ + height = fp.ReadUInt16(); /* height */ + bitmapDataLength = fp.ReadUInt32(); /* bitmapDataLength */ + bitmapData = fp.ReadBytes((int) bitmapDataLength); /* bitmapData */ + } + + public void Read(SurfaceBits* surfaceBits) + { + destLeft = (UInt16) surfaceBits->destLeft; /* destLeft */ + destTop = (UInt16) surfaceBits->destTop; /* destTop */ + destRight = (UInt16) surfaceBits->destRight; /* destRight */ + destBottom = (UInt16) surfaceBits->destBottom; /* destBottom */ + bpp = (Byte) surfaceBits->bpp; /* bpp */ + codecID = (Byte) surfaceBits->codecID; /* codecID */ + width = (UInt16) surfaceBits->width; /* width */ + height = (UInt16) surfaceBits->height; /* height */ + + bitmapDataLength = (UInt32) surfaceBits->bitmapDataLength; /* bitmapDataLength */ + + bitmapData = new byte[bitmapDataLength]; + + Marshal.Copy(new IntPtr(surfaceBits->bitmapData), + bitmapData, 0, (int) bitmapDataLength); /* bitmapData */ + } + + public override byte[] Write() + { + byte[] buffer = new byte[2 + 20 + bitmapDataLength]; + BinaryWriter s = new BinaryWriter(new MemoryStream(buffer)); + + s.Write(GetCmdType()); + + s.Write(destLeft); + s.Write(destTop); + s.Write(destRight); + s.Write(destBottom); + s.Write(bpp); + s.Write(reserved1); + s.Write(reserved2); + s.Write(codecID); + s.Write(width); + s.Write(height); + s.Write(bitmapDataLength); + s.Write(bitmapData); + + return buffer; + } + + public override UInt16 GetCmdType() + { + return CMDTYPE_STREAM_SURFACE_BITS; + } + } +} + diff --git a/FreeRDP/Codec/SurfaceCommand.cs b/FreeRDP/Codec/SurfaceCommand.cs new file mode 100644 index 0000000..f0ebcfc --- /dev/null +++ b/FreeRDP/Codec/SurfaceCommand.cs @@ -0,0 +1,79 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Surface Command + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; + +namespace FreeRDP +{ + public abstract class SurfaceCommand + { + public UInt16 CmdType = 0; + + protected const UInt16 CMDTYPE_SET_SURFACE_BITS = 1; + protected const UInt16 CMDTYPE_STREAM_SURFACE_BITS = 6; + protected const UInt16 CMDTYPE_FRAME_MARKER = 4; + + protected const byte CODEC_ID_NONE = 0x00; + protected const byte CODEC_ID_NSCODEC = 0x01; + protected const byte CODEC_ID_REMOTEFX = 0x03; + + public SurfaceCommand() + { + } + + public virtual void Read(BinaryReader fp) {} + public abstract byte[] Write(); + + public abstract UInt16 GetCmdType(); + + public static SurfaceCommand Parse(BinaryReader fp) + { + UInt16 cmdType; + SurfaceCommand cmd = null; + + cmdType = fp.ReadUInt16(); + + switch (cmdType) + { + case CMDTYPE_SET_SURFACE_BITS: + cmd = new SetSurfaceBitsCommand(); + cmd.Read(fp); + break; + + case CMDTYPE_STREAM_SURFACE_BITS: + cmd = new StreamSurfaceBitsCommand(); + cmd.Read(fp); + break; + + case CMDTYPE_FRAME_MARKER: + cmd = new FrameMarkerCommand(); + cmd.Read(fp); + break; + + default: + Console.WriteLine("Unknown Surface Command: {0}", cmdType); + break; + } + + return cmd; + } + } +} + diff --git a/FreeRDP/Core/Context.cs b/FreeRDP/Core/Context.cs new file mode 100644 index 0000000..57e4a6a --- /dev/null +++ b/FreeRDP/Core/Context.cs @@ -0,0 +1,45 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Context + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpContext + { + public freerdp* instance; + public IntPtr peer; + public fixed UInt32 paddingA[16-2]; + + public int argc; + public IntPtr argv; + public fixed UInt32 paddingB[32-18]; + + public IntPtr rdp; + public IntPtr gdi; + public IntPtr rail; + public IntPtr cache; + public IntPtr channels; + public IntPtr graphics; + public fixed UInt32 paddingC[64-38]; + }; +} + diff --git a/FreeRDP/Core/FreeRDP.cs b/FreeRDP/Core/FreeRDP.cs new file mode 100644 index 0000000..1b8050a --- /dev/null +++ b/FreeRDP/Core/FreeRDP.cs @@ -0,0 +1,61 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe delegate void pContextNew(freerdp* instance, rdpContext* context); + public unsafe delegate void pContextFree(freerdp* instance, rdpContext* context); + + public unsafe delegate bool pPreConnect(freerdp* instance); + public unsafe delegate bool pPostConnect(freerdp* instance); + + public unsafe delegate bool pAuthenticate(freerdp* instance, IntPtr username, IntPtr password, IntPtr domain); + public unsafe delegate bool pVerifyCertificate(freerdp* instance, IntPtr subject, IntPtr issuer, IntPtr fingerprint); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct freerdp + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr input; + public rdpUpdate* update; + public rdpSettings* settings; + public fixed UInt32 paddingB[32-19]; + + public UIntPtr ContextSize; + public IntPtr ContextNew; + public IntPtr ContextFree; + public fixed UInt32 paddingC[48-35]; + + public IntPtr PreConnect; + public IntPtr PostConnect; + public IntPtr Authenticate; + public IntPtr VerifyCertificate; + public fixed UInt32 paddingD[64-52]; + + public IntPtr SendChannelData; + public IntPtr RecvChannelData; + public fixed UInt32 paddingF[80-66]; + }; +} + diff --git a/FreeRDP/Core/Graphics/Bitmap.cs b/FreeRDP/Core/Graphics/Bitmap.cs new file mode 100644 index 0000000..5244f43 --- /dev/null +++ b/FreeRDP/Core/Graphics/Bitmap.cs @@ -0,0 +1,59 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Bitmap + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe delegate void pBitmap_New(rdpContext* context, rdpBitmap* bitmap); + public unsafe delegate void pBitmap_Free(rdpContext* context, rdpBitmap* bitmap); + public unsafe delegate void pBitmap_Paint(rdpContext* context, rdpBitmap* bitmap); + public unsafe delegate void pBitmap_Decompress(rdpContext* context, rdpBitmap* bitmap); + public unsafe delegate void pBitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpBitmap + { + public IntPtr size; + public IntPtr New; + public IntPtr Free; + public IntPtr Paint; + public IntPtr Decompress; + public IntPtr SetSurface; + public fixed UInt32 paddingA[16-6]; + + public UInt32 left; + public UInt32 top; + public UInt32 right; + public UInt32 bottom; + public UInt32 width; + public UInt32 height; + public UInt32 bpp; + public UInt32 flags; + public UInt32 length; + public IntPtr data; + public fixed UInt32 paddingB[32-26]; + + public UInt32 compressed; + public UInt32 ephemeral; + public fixed UInt32 paddingC[64-34]; + } +} + diff --git a/FreeRDP/Core/Graphics/Glyph.cs b/FreeRDP/Core/Graphics/Glyph.cs new file mode 100644 index 0000000..90549f1 --- /dev/null +++ b/FreeRDP/Core/Graphics/Glyph.cs @@ -0,0 +1,54 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Glyph + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe delegate void pGlyph_New(rdpContext* context, rdpGlyph* glyph); + public unsafe delegate void pGlyph_Free(rdpContext* context, rdpGlyph* glyph); + public unsafe delegate void pGlyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y); + + public unsafe delegate void pGlyph_BeginDraw(rdpContext* context, rdpGlyph* glyph, + int x, int y, UInt32 bgcolor, UInt32 fgcolor); + + public unsafe delegate void pGlyph_EndDraw(rdpContext* context, rdpGlyph* glyph, + int x, int y, UInt32 bgcolor, UInt32 fgcolor); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpGlyph + { + public IntPtr size; + public IntPtr New; + public IntPtr Free; + public IntPtr Draw; + public IntPtr BeginDraw; + public IntPtr EndDraw; + public fixed UInt32 paddingA[16-6]; + + public UInt32 x; + public UInt32 y; + public UInt32 cx; + public UInt32 cy; + public UInt32 cb; + public IntPtr aj; + public fixed UInt32 paddingB[32-22]; + } +} diff --git a/FreeRDP/Core/Graphics/Graphics.cs b/FreeRDP/Core/Graphics/Graphics.cs new file mode 100644 index 0000000..1a5c887 --- /dev/null +++ b/FreeRDP/Core/Graphics/Graphics.cs @@ -0,0 +1,38 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpGraphics + { + public rdpContext* context; + public IntPtr Bitmap_Prototype; + public IntPtr Pointer_Prototype; + public IntPtr Glyph_Prototype; + public fixed UInt32 paddingA[16-4]; + } + + public unsafe delegate void pGraphicsRegisterBitmap(rdpGraphics* graphics, rdpBitmap* bitmap); + public unsafe delegate void pGraphicsRegisterPointer(rdpGraphics* graphics, rdpPointer* pointer); + public unsafe delegate void pGraphicsRegisterGlyph(rdpGraphics* graphics, rdpGlyph* glyph); +} diff --git a/FreeRDP/Core/Graphics/Pointer.cs b/FreeRDP/Core/Graphics/Pointer.cs new file mode 100644 index 0000000..4cbd12b --- /dev/null +++ b/FreeRDP/Core/Graphics/Pointer.cs @@ -0,0 +1,49 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Pointer + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe delegate void pPointer_New(rdpContext* context, rdpPointer* pointer); + public unsafe delegate void pPointer_Free(rdpContext* context, rdpPointer* pointer); + public unsafe delegate void pPointer_Set(rdpContext* context, rdpPointer* pointer); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPointer + { + public IntPtr size; + public IntPtr New; + public IntPtr Free; + public IntPtr Set; + public fixed UInt32 paddingA[16-4]; + + public UInt32 xPos; + public UInt32 yPos; + public UInt32 width; + public UInt32 height; + public UInt32 xorBpp; + public UInt32 lengthAndMask; + public UInt32 lengthXorMask; + public IntPtr xorMaskData; + public IntPtr andMaskData; + public fixed UInt32 paddingB[32-25]; + } +} diff --git a/FreeRDP/Core/Input.cs b/FreeRDP/Core/Input.cs new file mode 100644 index 0000000..d520afe --- /dev/null +++ b/FreeRDP/Core/Input.cs @@ -0,0 +1,40 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Input + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpInput + { + public rdpContext* context; + public IntPtr param; + public fixed UInt32 paddingA[16-2]; + + public IntPtr SynchronizeEvent; + public IntPtr KeyboardEvent; + public IntPtr UnicodeKeyboardEvent; + public IntPtr MouseEvent; + public IntPtr ExtendedMouseEvent; + public fixed UInt32 paddingB[32-21]; + }; +} + diff --git a/FreeRDP/Core/RDP.cs b/FreeRDP/Core/RDP.cs new file mode 100644 index 0000000..d845045 --- /dev/null +++ b/FreeRDP/Core/RDP.cs @@ -0,0 +1,265 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RDP + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class RDP + { + [DllImport("libfreerdp-core")] + public static extern void freerdp_context_new(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_context_free(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern int freerdp_connect(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern int freerdp_disconnect(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern int freerdp_check_fds(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern freerdp* freerdp_new(); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_free(freerdp* instance); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_input_send_synchronize_event(IntPtr input, UInt32 flags); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_input_send_keyboard_event(IntPtr input, UInt16 flags, UInt16 code); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_input_send_unicode_keyboard_event(IntPtr input, UInt16 flags, UInt16 code); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_input_send_mouse_event(IntPtr input, UInt16 flags, UInt16 x, UInt16 y); + + [DllImport("libfreerdp-core")] + public static extern void freerdp_input_send_extended_mouse_event(IntPtr input, UInt16 flags, UInt16 x, UInt16 y); + + public int Port { get { return (int) settings->port; } set { settings->port = (UInt32) value; } } + public int Width { get { return (int) settings->width; } set { settings->width = (UInt32) value; } } + public int Height { get { return (int) settings->height; } set { settings->height = (UInt32) value; } } + + private freerdp* handle; + private IntPtr input; + private rdpContext* context; + private rdpSettings* settings; + + private IUpdate iUpdate; + private IPrimaryUpdate iPrimaryUpdate; + private ISecondaryUpdate iSecondaryUpdate; + private IAltSecUpdate iAltSecUpdate; + + private pContextNew hContextNew; + private pContextFree hContextFree; + + private pPreConnect hPreConnect; + private pPostConnect hPostConnect; + + private pAuthenticate hAuthenticate; + private pVerifyCertificate hVerifyCertificate; + + private Update update; + private PrimaryUpdate primary; + + public RDP() + { + handle = freerdp_new(); + + iUpdate = null; + iPrimaryUpdate = null; + iSecondaryUpdate = null; + iAltSecUpdate = null; + + hContextNew = new pContextNew(ContextNew); + hContextFree = new pContextFree(ContextFree); + + handle->ContextNew = Marshal.GetFunctionPointerForDelegate(hContextNew); + handle->ContextFree = Marshal.GetFunctionPointerForDelegate(hContextFree); + + hAuthenticate = new pAuthenticate(Authenticate); + hVerifyCertificate = new pVerifyCertificate(VerifyCertificate); + + handle->Authenticate = Marshal.GetFunctionPointerForDelegate(hAuthenticate); + handle->VerifyCertificate = Marshal.GetFunctionPointerForDelegate(hVerifyCertificate); + + freerdp_context_new(handle); + } + + ~RDP() + { + + } + + public void SetUpdateInterface(IUpdate iUpdate) + { + this.iUpdate = iUpdate; + } + + public void SetPrimaryUpdateInterface(IPrimaryUpdate iPrimaryUpdate) + { + this.iPrimaryUpdate = iPrimaryUpdate; + } + + private IntPtr GetNativeAnsiString(string str) + { + ASCIIEncoding strEncoder = new ASCIIEncoding(); + + int size = strEncoder.GetByteCount(str); + IntPtr pStr = Memory.Zalloc(size); + byte[] buffer = strEncoder.GetBytes(str); + Marshal.Copy(buffer, 0, pStr, size); + + return pStr; + } + + void ContextNew(freerdp* instance, rdpContext* context) + { + Console.WriteLine("ContextNew"); + + hPreConnect = new pPreConnect(this.PreConnect); + hPostConnect = new pPostConnect(this.PostConnect); + + instance->PreConnect = Marshal.GetFunctionPointerForDelegate(hPreConnect); + instance->PostConnect = Marshal.GetFunctionPointerForDelegate(hPostConnect); + + this.context = context; + input = instance->input; + settings = instance->settings; + } + + void ContextFree(freerdp* instance, rdpContext* context) + { + Console.WriteLine("ContextFree"); + } + + bool PreConnect(freerdp* instance) + { + Console.WriteLine("PreConnect"); + + if (iUpdate != null) + { + update = new Update(instance->context); + update.RegisterInterface(iUpdate); + } + + if (iPrimaryUpdate != null) + { + primary = new PrimaryUpdate(instance->context); + primary.RegisterInterface(iPrimaryUpdate); + } + + settings->rfxCodec = 1; + settings->fastpathOutput = 1; + settings->colorDepth = 32; + settings->frameAcknowledge = 0; + settings->performanceFlags = 0; + settings->largePointer = 1; + settings->glyphCache = 0; + settings->bitmapCache = 0; + settings->offscreenBitmapCache = 0; + + return true; + } + + bool PostConnect(freerdp* instance) + { + Console.WriteLine("PostConnect"); + return true; + } + + public bool Connect(string hostname, int port, string username, string domain, string password) + { + settings->port = (uint) port; + + Console.WriteLine("hostname:{0} username:{1} width:{2} height:{3} port:{4}", + hostname, username, settings->width, settings->height, settings->port); + + settings->ignoreCertificate = 1; + + settings->hostname = GetNativeAnsiString(hostname); + settings->username = GetNativeAnsiString(username); + + if (domain.Length > 1) + settings->domain = GetNativeAnsiString(domain); + + if (password.Length > 1) + settings->password = GetNativeAnsiString(password); + else + settings->authentication = 0; + + return ((freerdp_connect(handle) == 0) ? false : true); + } + + public bool Disconnect() + { + return ((freerdp_disconnect(handle) == 0) ? false : true); + } + + private bool Authenticate(freerdp* instance, IntPtr username, IntPtr password, IntPtr domain) + { + return true; + } + + private bool VerifyCertificate(freerdp* instance, IntPtr subject, IntPtr issuer, IntPtr fingerprint) + { + return true; + } + + public bool CheckFileDescriptor() + { + return ((freerdp_check_fds(handle) == 0) ? false : true); + } + + public void SendInputSynchronizeEvent(UInt32 flags) + { + freerdp_input_send_synchronize_event(input, flags); + } + + public void SendInputKeyboardEvent(UInt16 flags, UInt16 code) + { + freerdp_input_send_keyboard_event(input, flags, code); + } + + public void SendInputUnicodeKeyboardEvent(UInt16 flags, UInt16 code) + { + freerdp_input_send_unicode_keyboard_event(input, flags, code); + } + + public void SendInputMouseEvent(UInt16 flags, UInt16 x, UInt16 y) + { + freerdp_input_send_mouse_event(input, flags, x, y); + } + + public void SendInputExtendedMouseEvent(UInt16 flags, UInt16 x, UInt16 y) + { + freerdp_input_send_extended_mouse_event(input, flags, x, y); + } + } +} + diff --git a/FreeRDP/Core/Settings.cs b/FreeRDP/Core/Settings.cs new file mode 100644 index 0000000..570a73f --- /dev/null +++ b/FreeRDP/Core/Settings.cs @@ -0,0 +1,203 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Settings + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe struct rdpSettings + { + [FieldOffset(0 * 8)] public freerdp* instance; + + /* Core Protocol Parameters */ + [FieldOffset(16 * 8)] public UInt32 width; + [FieldOffset(17 * 8)] public UInt32 height; + [FieldOffset(18 * 8)] public UInt32 rdpVersion; + [FieldOffset(19 * 8)] public UInt32 colorDepth; + [FieldOffset(20 * 8)] public UInt32 kbdLayout; + [FieldOffset(21 * 8)] public UInt32 kbdType; + [FieldOffset(22 * 8)] public UInt32 kbdSubType; + [FieldOffset(23 * 8)] public UInt32 kbdFnKeys; + [FieldOffset(24 * 8)] public UInt32 clientBuild; + [FieldOffset(25 * 8)] public UInt32 requestedProtocols; + [FieldOffset(26 * 8)] public UInt32 selectedProtocol; + [FieldOffset(27 * 8)] public UInt32 encryptionMethod; + [FieldOffset(28 * 8)] public UInt32 encryptionLevel; + [FieldOffset(29 * 8)] public int authentication; + [FieldOffset(30 * 8)] public UInt32 negotiationFlags; + + /* Connection Settings */ + [FieldOffset(48 * 8)] public UInt32 port; + [FieldOffset(49 * 8)] public int ipv6; + [FieldOffset(50 * 8)] public IntPtr hostname; + [FieldOffset(51 * 8)] public IntPtr username; + [FieldOffset(52 * 8)] public IntPtr password; + [FieldOffset(53 * 8)] public IntPtr domain; + [FieldOffset(54 * 8)] public IntPtr shell; + [FieldOffset(55 * 8)] public IntPtr directory; + [FieldOffset(56 * 8)] public IntPtr ipAddress; + [FieldOffset(57 * 8)] public IntPtr clientDir; + [FieldOffset(58 * 8)] public int autologon; + [FieldOffset(59 * 8)] public int compression; + [FieldOffset(60 * 8)] public UInt32 performanceFlags; + [FieldOffset(61 * 8)] public IntPtr passwordCookie; + [FieldOffset(62 * 8)] public IntPtr kerberosKDC; + [FieldOffset(63 * 8)] public IntPtr kerberosRealm; + + /* User Interface Parameters */ + [FieldOffset(80 * 8)] public int softwareGdi; + [FieldOffset(81 * 8)] public int workarea; + [FieldOffset(82 * 8)] public int fullscreen; + [FieldOffset(83 * 8)] public int grabKeyboard; + [FieldOffset(84 * 8)] public int decorations; + [FieldOffset(85 * 8)] public UInt32 percentScreen; + [FieldOffset(86 * 8)] public int mouseMotion; + [FieldOffset(87 * 8)] public IntPtr windowTitle; + [FieldOffset(88 * 8)] public UInt64 parentWindowXid; + + /* Internal Parameters */ + [FieldOffset(112 * 8)] public IntPtr homePath; + [FieldOffset(113 * 8)] public UInt32 shareId; + [FieldOffset(114 * 8)] public UInt32 pduSource; + [FieldOffset(115 * 8)] public IntPtr uniconv; + [FieldOffset(116 * 8)] public int serverMode; + [FieldOffset(117 * 8)] public IntPtr configPath; + [FieldOffset(118 * 8)] public IntPtr currentPath; + [FieldOffset(119 * 8)] public IntPtr developmentPath; + [FieldOffset(120 * 8)] public int developmentMode; + + /* Security */ + [FieldOffset(144 * 8)] public int encryption; + [FieldOffset(145 * 8)] public int tlsSecurity; + [FieldOffset(146 * 8)] public int nlaSecurity; + [FieldOffset(147 * 8)] public int rdpSecurity; + [FieldOffset(148 * 8)] public UInt32 ntlmVersion; + [FieldOffset(149 * 8)] public int saltedChecksum; + + /* Session */ + [FieldOffset(160 * 8)] public int consoleAudio; + [FieldOffset(161 * 8)] public int consoleSession; + [FieldOffset(162 * 8)] public UInt32 redirectedSessionId; + [FieldOffset(163 * 8)] public int audioPlayback; + [FieldOffset(164 * 8)] public int audioCapture; + + /* Output Control */ + [FieldOffset(176 * 8)] public int refreshRect; + [FieldOffset(177 * 8)] public int suppressOutput; + [FieldOffset(178 * 8)] public int desktopResize; + + /* Reconnection */ + [FieldOffset(192 * 8)] public int autoReconnection; + [FieldOffset(193 * 8)] public IntPtr clientAutoReconnectCookie; + [FieldOffset(194 * 8)] public IntPtr serverAutoReconnectCookie; + + /* Time Zone */ + [FieldOffset(208 * 8)] public IntPtr clientTimeZone; + + /* Capabilities */ + [FieldOffset(216 * 8)] public UInt32 osMajorType; + [FieldOffset(217 * 8)] public UInt32 osMinorType; + [FieldOffset(218 * 8)] public UInt32 vcChunkSize; + [FieldOffset(219 * 8)] public int soundBeeps; + [FieldOffset(220 * 8)] public int smoothFonts; + [FieldOffset(221 * 8)] public int frameMarker; + [FieldOffset(222 * 8)] public int fastpathInput; + [FieldOffset(223 * 8)] public int fastpathOutput; + [FieldOffset(224 * 8)] public IntPtr receivedCaps; + [FieldOffset(225 * 8)] public IntPtr orderSupport; + [FieldOffset(226 * 8)] public int surfaceCommands; + [FieldOffset(227 * 8)] public int disableWallpaper; + [FieldOffset(228 * 8)] public int disableFullWindowDrag; + [FieldOffset(229 * 8)] public int disableMenuAnimations; + [FieldOffset(230 * 8)] public int disableTheming; + [FieldOffset(231 * 8)] public UInt32 connectionType; + [FieldOffset(232 * 8)] public UInt32 multifragMaxRequestSize; + + /* Certificate */ + [FieldOffset(248 * 8)] public IntPtr certFile; + [FieldOffset(249 * 8)] public IntPtr privateKeyFile; + [FieldOffset(250 * 8)] public IntPtr clientHostname; + [FieldOffset(251 * 8)] public IntPtr clientProductId; + [FieldOffset(252 * 8)] public IntPtr serverRandom; + [FieldOffset(253 * 8)] public IntPtr serverCertificate; + [FieldOffset(254 * 8)] public int ignoreCertificate; + [FieldOffset(255 * 8)] public IntPtr serverCert; + [FieldOffset(256 * 8)] public IntPtr rdpKeyFile; + [FieldOffset(257 * 8)] public IntPtr serverKey; + [FieldOffset(258 * 8)] public IntPtr certificateName; + + /* Codecs */ + [FieldOffset(280 * 8)] public int rfxCodec; + [FieldOffset(281 * 8)] public int nsCodec; + [FieldOffset(282 * 8)] public UInt32 rfxCodecId; + [FieldOffset(283 * 8)] public UInt32 nsCodecId; + [FieldOffset(284 * 8)] public UInt32 rfxCodecMode; + [FieldOffset(285 * 8)] public int frameAcknowledge; + + /* Recording */ + [FieldOffset(296 * 8)] public int dumpRfx; + [FieldOffset(297 * 8)] public int playRfx; + [FieldOffset(298 * 8)] public IntPtr dumpRfxFile; + [FieldOffset(299 * 8)] public IntPtr playRfxFile; + + /* RemoteApp */ + [FieldOffset(312 * 8)] public int remoteApp; + [FieldOffset(313 * 8)] public UInt32 numIconCaches; + [FieldOffset(314 * 8)] public UInt32 numIconCacheEntries; + [FieldOffset(315 * 8)] public int railLangbarSupported; + + /* Pointer */ + [FieldOffset(320 * 8)] public int largePointer; + [FieldOffset(321 * 8)] public int colorPointer; + [FieldOffset(322 * 8)] public UInt32 pointerCacheSize; + + /* Bitmap Cache */ + [FieldOffset(328 * 8)] public int bitmapCache; + [FieldOffset(329 * 8)] public int bitmapCacheV3; + [FieldOffset(330 * 8)] public int persistentBitmapCache; + [FieldOffset(331 * 8)] public UInt32 bitmapCacheV2NumCells; + [FieldOffset(332 * 8)] public IntPtr bitmapCacheV2CellInfo; + + /* Offscreen Bitmap Cache */ + [FieldOffset(344 * 8)] public int offscreenBitmapCache; + [FieldOffset(345 * 8)] public UInt32 offscreenBitmapCacheSize; + [FieldOffset(346 * 8)] public UInt32 offscreenBitmapCacheEntries; + + /* Glyph Cache */ + [FieldOffset(352 * 8)] public int glyphCache; + [FieldOffset(353 * 8)] public UInt32 glyphSupportLevel; + [FieldOffset(354 * 8)] public IntPtr glyphCacheInfo; + [FieldOffset(355 * 8)] public IntPtr fragCacheInfo; + + /* Draw Nine Grid */ + [FieldOffset(360 * 8)] public int drawNineGrid; + [FieldOffset(361 * 8)] public UInt32 drawNineGridCacheSize; + [FieldOffset(362 * 8)] public UInt32 drawNineGridCacheEntries; + + /* Draw GDI+ */ + [FieldOffset(368 * 8)] public int drawGdiPlus; + [FieldOffset(369 * 8)] public int drawGdiPlusCache; + + /* Desktop Composition */ + [FieldOffset(376 * 8)] public int desktopComposition; + }; +} + diff --git a/FreeRDP/Core/Update/AltSecUpdate.cs b/FreeRDP/Core/Update/AltSecUpdate.cs new file mode 100644 index 0000000..7ea5004 --- /dev/null +++ b/FreeRDP/Core/Update/AltSecUpdate.cs @@ -0,0 +1,261 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Alternate Secondary Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct OffscreenDeleteList + { + public UInt32 cIndices; + public UInt16* indices; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CreateOffscreenBitmapOrder + { + public UInt32 id; + public UInt32 cx; + public UInt32 cy; + public OffscreenDeleteList deleteList; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SwitchSurfaceOrder + { + public UInt32 bitmapId; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct NineGridBitmapInfo + { + public UInt32 flFlags; + public UInt32 ulLeftWidth; + public UInt32 ulRightWidth; + public UInt32 ulTopHeight; + public UInt32 ulBottomHeight; + public UInt32 crTransparent; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CreateNineGridBitmapOrder + { + public UInt32 bitmapBpp; + public UInt32 bitmapId; + public UInt32 cx; + public UInt32 cy; + public NineGridBitmapInfo* nineGridInfo; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct FrameMarkerOrder + { + public UInt32 action; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct StreamBitmapFirstOrder + { + public UInt32 bitmapFlags; + public UInt32 bitmapBpp; + public UInt32 bitmapType; + public UInt32 bitmapWidth; + public UInt32 bitmapHeight; + public UInt32 bitmapSize; + public UInt32 bitmapBlockSize; + public byte* bitmapBlock; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct StreamBitmapNextOrder + { + public UInt32 bitmapFlags; + public UInt32 bitmapType; + public UInt32 bitmapBlockSize; + public byte* bitmapBlock; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusFirstOrder + { + public UInt32 cbSize; + public UInt32 cbTotalSize; + public UInt32 cbTotalEmfSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusNextOrder + { + public UInt32 cbSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusEndOrder + { + public UInt32 cbSize; + public UInt32 cbTotalSize; + public UInt32 cbTotalEmfSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusCacheFirstOrder + { + public UInt32 flags; + public UInt32 cacheType; + public UInt32 cacheIndex; + public UInt32 cbSize; + public UInt32 cbTotalSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusCacheNextOrder + { + public UInt32 flags; + public UInt32 cacheType; + public UInt32 cacheIndex; + public UInt32 cbSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawGdiPlusCacheEndOrder + { + public UInt32 flags; + public UInt32 cacheType; + public UInt32 cacheIndex; + public UInt32 cbSize; + public UInt32 cbTotalSize; + public byte* emfRecords; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpAltSecUpdate + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr CreateOffscreenBitmap; + public IntPtr SwitchSurface; + public IntPtr CreateNineGridBitmap; + public IntPtr FrameMarker; + public IntPtr StreamBitmapFirst; + public IntPtr StreamBitmapNext; + public IntPtr DrawGdiPlusFirst; + public IntPtr DrawGdiPlusNext; + public IntPtr DrawGdiPlusEnd; + public IntPtr DrawGdiPlusCacheFirst; + public IntPtr DrawGdiPlusCacheNext; + public IntPtr DrawGdiPlusCacheEnd; + public fixed UInt32 paddingB[32-28]; + } + + public unsafe interface IAltSecUpdate + { + void CreateOffscreenBitmap(rdpContext* context, CreateOffscreenBitmapOrder* createOffscreenBitmap); + void SwitchSurface(rdpContext* context, SwitchSurfaceOrder* switchSurface); + void CreateNineGridBitmap(rdpContext* context, CreateNineGridBitmapOrder* createNineGridBitmap); + void FrameMarker(rdpContext* context, FrameMarkerOrder* frameMarker); + void StreamBitmapFirst(rdpContext* context, StreamBitmapFirstOrder* streamBitmapFirst); + void StreamBitmapNext(rdpContext* context, StreamBitmapNextOrder* streamBitmapNext); + void DrawGdiPlusFirst(rdpContext* context, DrawGdiPlusFirstOrder* drawGdiPlusFirst); + void DrawGdiPlusNext(rdpContext* context, DrawGdiPlusNextOrder* drawGdiPlusNext); + void DrawGdiPlusEnd(rdpContext* context, DrawGdiPlusEndOrder* drawGdiPlusEnd); + void DrawGdiPlusCacheFirst(rdpContext* context, DrawGdiPlusCacheFirstOrder* drawGdiPlusCacheFirst); + void DrawGdiPlusCacheNext(rdpContext* context, DrawGdiPlusCacheNextOrder* drawGdiPlusCacheNext); + void DrawGdiPlusCacheEnd(rdpContext* context, DrawGdiPlusCacheEndOrder* drawGdiPlusCacheEnd); + } + + public unsafe class AltSecUpdate + { + private freerdp* instance; + private rdpContext* context; + private rdpUpdate* update; + private rdpAltSecUpdate* altsec; + + delegate void CreateOffscreenBitmapDelegate(rdpContext* context, CreateOffscreenBitmapOrder* createOffscreenBitmap); + delegate void SwitchSurfaceDelegate(rdpContext* context, SwitchSurfaceOrder* switchSurface); + delegate void CreateNineGridBitmapDelegate(rdpContext* context, CreateNineGridBitmapOrder* createNineGridBitmap); + delegate void FrameMarkerDelegate(rdpContext* context, FrameMarkerOrder* frameMarker); + delegate void StreamBitmapFirstDelegate(rdpContext* context, StreamBitmapFirstOrder* streamBitmapFirst); + delegate void StreamBitmapNextDelegate(rdpContext* context, StreamBitmapNextOrder* streamBitmapNext); + delegate void DrawGdiPlusFirstDelegate(rdpContext* context, DrawGdiPlusFirstOrder* drawGdiPlusFirst); + delegate void DrawGdiPlusNextDelegate(rdpContext* context, DrawGdiPlusNextOrder* drawGdiPlusNext); + delegate void DrawGdiPlusEndDelegate(rdpContext* context, DrawGdiPlusEndOrder* drawGdiPlusEnd); + delegate void DrawGdiPlusCacheFirstDelegate(rdpContext* context, DrawGdiPlusCacheFirstOrder* drawGdiPlusCacheFirst); + delegate void DrawGdiPlusCacheNextDelegate(rdpContext* context, DrawGdiPlusCacheNextOrder* drawGdiPlusCacheNext); + delegate void DrawGdiPlusCacheEndDelegate(rdpContext* context, DrawGdiPlusCacheEndOrder* drawGdiPlusCacheEnd); + + private CreateOffscreenBitmapDelegate CreateOffscreenBitmap; + private SwitchSurfaceDelegate SwitchSurface; + private CreateNineGridBitmapDelegate CreateNineGridBitmap; + private FrameMarkerDelegate FrameMarker; + private StreamBitmapFirstDelegate StreamBitmapFirst; + private StreamBitmapNextDelegate StreamBitmapNext; + private DrawGdiPlusFirstDelegate DrawGdiPlusFirst; + private DrawGdiPlusNextDelegate DrawGdiPlusNext; + private DrawGdiPlusEndDelegate DrawGdiPlusEnd; + private DrawGdiPlusCacheFirstDelegate DrawGdiPlusCacheFirst; + private DrawGdiPlusCacheNextDelegate DrawGdiPlusCacheNext; + private DrawGdiPlusCacheEndDelegate DrawGdiPlusCacheEnd; + + public AltSecUpdate(rdpContext* context) + { + this.context = context; + this.instance = context->instance; + this.update = instance->update; + this.altsec = update->altsec; + } + + public void RegisterInterface(IAltSecUpdate iAltSec) + { + CreateOffscreenBitmap = new CreateOffscreenBitmapDelegate(iAltSec.CreateOffscreenBitmap); + SwitchSurface = new SwitchSurfaceDelegate(iAltSec.SwitchSurface); + CreateNineGridBitmap = new CreateNineGridBitmapDelegate(iAltSec.CreateNineGridBitmap); + FrameMarker = new FrameMarkerDelegate(iAltSec.FrameMarker); + StreamBitmapFirst = new StreamBitmapFirstDelegate(iAltSec.StreamBitmapFirst); + StreamBitmapNext = new StreamBitmapNextDelegate(iAltSec.StreamBitmapNext); + DrawGdiPlusFirst = new DrawGdiPlusFirstDelegate(iAltSec.DrawGdiPlusFirst); + DrawGdiPlusNext = new DrawGdiPlusNextDelegate(iAltSec.DrawGdiPlusNext); + DrawGdiPlusEnd = new DrawGdiPlusEndDelegate(iAltSec.DrawGdiPlusEnd); + DrawGdiPlusCacheFirst = new DrawGdiPlusCacheFirstDelegate(iAltSec.DrawGdiPlusCacheFirst); + DrawGdiPlusCacheNext = new DrawGdiPlusCacheNextDelegate(iAltSec.DrawGdiPlusCacheNext); + DrawGdiPlusCacheEnd = new DrawGdiPlusCacheEndDelegate(iAltSec.DrawGdiPlusCacheEnd); + + altsec->CreateOffscreenBitmap = Marshal.GetFunctionPointerForDelegate(CreateOffscreenBitmap); + altsec->SwitchSurface = Marshal.GetFunctionPointerForDelegate(SwitchSurface); + altsec->CreateNineGridBitmap = Marshal.GetFunctionPointerForDelegate(CreateNineGridBitmap); + altsec->FrameMarker = Marshal.GetFunctionPointerForDelegate(FrameMarker); + altsec->StreamBitmapFirst = Marshal.GetFunctionPointerForDelegate(StreamBitmapFirst); + altsec->StreamBitmapNext = Marshal.GetFunctionPointerForDelegate(StreamBitmapNext); + altsec->DrawGdiPlusFirst = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusFirst); + altsec->DrawGdiPlusNext = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusNext); + altsec->DrawGdiPlusEnd = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusEnd); + altsec->DrawGdiPlusCacheFirst = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusCacheFirst); + altsec->DrawGdiPlusCacheNext = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusCacheNext); + altsec->DrawGdiPlusCacheEnd = Marshal.GetFunctionPointerForDelegate(DrawGdiPlusCacheEnd); + } + } +} + diff --git a/FreeRDP/Core/Update/PointerUpdate.cs b/FreeRDP/Core/Update/PointerUpdate.cs new file mode 100644 index 0000000..d53382c --- /dev/null +++ b/FreeRDP/Core/Update/PointerUpdate.cs @@ -0,0 +1,85 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Pointer Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PointerPositionUpdate + { + public UInt32 xPos; + public UInt32 yPos; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PointerSystemUpdate + { + public UInt32 type; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PointerColorUpdate + { + public UInt32 cacheIndex; + public UInt32 xPos; + public UInt32 yPos; + public UInt32 width; + public UInt32 height; + public UInt32 lengthAndMask; + public UInt32 lengthXorMask; + public byte* xorMaskData; + public byte* andMaskData; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PointerNewUpdate + { + public UInt32 xorBpp; + public PointerColorUpdate colorPtrAttr; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PointerCachedUpdate + { + public UInt32 cacheIndex; + } + + public unsafe delegate void pPointerPosition(rdpContext* context, PointerPositionUpdate* pointerPosition); + public unsafe delegate void pPointerSystem(rdpContext* context, PointerSystemUpdate* pointerSystem); + public unsafe delegate void pPointerColor(rdpContext* context, PointerColorUpdate* pointerColor); + public unsafe delegate void pPointerNew(rdpContext* context, PointerNewUpdate* pointerNew); + public unsafe delegate void pPointerCached(rdpContext* context, PointerCachedUpdate* pointerCached); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPointerUpdate + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr PointerPosition; + public IntPtr PointerSystem; + public IntPtr PointerColor; + public IntPtr PointerNew; + public IntPtr PointerCached; + public fixed UInt32 paddingB[32-21]; + } +} + diff --git a/FreeRDP/Core/Update/PrimaryUpdate.cs b/FreeRDP/Core/Update/PrimaryUpdate.cs new file mode 100644 index 0000000..02225db --- /dev/null +++ b/FreeRDP/Core/Update/PrimaryUpdate.cs @@ -0,0 +1,574 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Primary Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpBrush + { + public UInt32 x; + public UInt32 y; + public UInt32 bpp; + public UInt32 style; + public UInt32 hatch; + public UInt32 index; + public UInt32 data; + public fixed byte p8x8[8]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct OrderInfo + { + public UInt32 orderType; + public UInt32 fieldFlags; + public rdpBounds* bounds; + public Int32 deltaBoundLeft; + public Int32 deltaBoundTop; + public Int32 deltaBoundRight; + public Int32 deltaBoundBottom; + public int deltaCoordinates; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DstBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PatBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public UInt32 backColor; + public UInt32 foreColor; + public rdpBrush* brush; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct ScrBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public Int32 nXSrc; + public Int32 nYSrc; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct OpaqueRectOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 color; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawNineGridOrder + { + public Int32 srcLeft; + public Int32 srcTop; + public Int32 srcRight; + public Int32 srcBottom; + public UInt32 bitmapId; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DeltaRect + { + public Int32 left; + public Int32 top; + public Int32 width; + public Int32 height; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MultiDstBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public UInt32 numRectangles; + public UInt32 cbData; + //public fixed DeltaRect rectangles[45]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MultiPatBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public UInt32 backColor; + public UInt32 foreColor; + public rdpBrush brush; + public UInt32 numRectangles; + public UInt32 cbData; + //public fixed DeltaRect rectangles[45]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MultiScrBltOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public Int32 nXSrc; + public Int32 nYSrc; + public UInt32 numRectangles; + public UInt32 cbData; + //public fixed DeltaRect rectangles[45]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MultiOpaqueRectOrder + { + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 color; + public UInt32 numRectangles; + public UInt32 cbData; + //public fixed DeltaRect rectangles[45]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MultiDrawNineGridOrder + { + public Int32 srcLeft; + public Int32 srcTop; + public Int32 srcRight; + public Int32 srcBottom; + public UInt32 bitmapId; + public UInt32 nDeltaEntries; + public UInt32 cbData; + public byte* codeDeltaList; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct LineToOrder + { + public UInt32 backMode; + public Int32 nXStart; + public Int32 nYStart; + public Int32 nXEnd; + public Int32 nYEnd; + public UInt32 backColor; + public UInt32 bRop2; + public UInt32 penStyle; + public UInt32 penWidth; + public UInt32 penColor; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DeltaPoint + { + public Int32 x; + public Int32 y; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PolylineOrder + { + public Int32 xStart; + public Int32 yStart; + public UInt32 bRop2; + public UInt32 penColor; + public UInt32 numPoints; + public UInt32 cbData; + public DeltaPoint* points; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MemBltOrder + { + public UInt32 cacheId; + public UInt32 colorIndex; + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public Int32 nXSrc; + public Int32 nYSrc; + public UInt32 cacheIndex; + public rdpBitmap* bitmap; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct Mem3BltOrder + { + public UInt32 cacheId; + public UInt32 colorIndex; + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nWidth; + public Int32 nHeight; + public UInt32 bRop; + public Int32 nXSrc; + public Int32 nYSrc; + public UInt32 backColor; + public UInt32 foreColor; + public rdpBrush brush; + public UInt32 cacheIndex; + public rdpBitmap* bitmap; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SaveBitmapOrder + { + public UInt32 savedBitmapPosition; + public Int32 nLeftRect; + public Int32 nTopRect; + public Int32 nRightRect; + public Int32 nBottomRect; + public UInt32 operation; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct GlyphFragmentIndex + { + public UInt32 index; + public UInt32 delta; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct GlyphFragment + { + public UInt32 operation; + public UInt32 index; + public UInt32 size; + public UInt32 nindices; + public GlyphFragmentIndex* indices; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct GlyphIndexOrder + { + public UInt32 cacheId; + public UInt32 flAccel; + public UInt32 ulCharInc; + public UInt32 fOpRedundant; + public UInt32 backColor; + public UInt32 foreColor; + public Int32 bkLeft; + public Int32 bkTop; + public Int32 bkRight; + public Int32 bkBottom; + public Int32 opLeft; + public Int32 opTop; + public Int32 opRight; + public Int32 opBottom; + public rdpBrush brush; + public Int32 x; + public Int32 y; + public UInt32 cbData; + public fixed byte data[256]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct FastIndexOrder + { + public UInt32 cacheId; + public UInt32 flAccel; + public UInt32 ulCharInc; + public UInt32 backColor; + public UInt32 foreColor; + public Int32 bkLeft; + public Int32 bkTop; + public Int32 bkRight; + public Int32 bkBottom; + public Int32 opLeft; + public Int32 opTop; + public Int32 opRight; + public Int32 opBottom; + public int opaqueRect; + public Int32 x; + public Int32 y; + public UInt32 cbData; + public fixed byte data[256]; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct FastGlyphOrder + { + public UInt32 cacheId; + public UInt32 flAccel; + public UInt32 ulCharInc; + public UInt32 backColor; + public UInt32 foreColor; + public Int32 bkLeft; + public Int32 bkTop; + public Int32 bkRight; + public Int32 bkBottom; + public Int32 opLeft; + public Int32 opTop; + public Int32 opRight; + public Int32 opBottom; + public Int32 x; + public Int32 y; + public UInt32 cbData; + public fixed byte data[256]; + public void* glyphData; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PolygonSCOrder + { + public Int32 xStart; + public Int32 yStart; + public UInt32 bRop2; + public UInt32 fillMode; + public UInt32 brushColor; + public UInt32 nDeltaEntries; + public UInt32 cbData; + public byte* codeDeltaList; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PolygonCBOrder + { + public Int32 xStart; + public Int32 yStart; + public UInt32 bRop2; + public UInt32 fillMode; + public UInt32 backColor; + public UInt32 foreColor; + public rdpBrush brush; + public UInt32 nDeltaEntries; + public UInt32 cbData; + public byte* codeDeltaList; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct EllipseSCOrder + { + public Int32 leftRect; + public Int32 topRect; + public Int32 rightRect; + public Int32 bottomRect; + public UInt32 bRop2; + public UInt32 fillMode; + public UInt32 color; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct EllipseCBOrder + { + public Int32 leftRect; + public Int32 topRect; + public Int32 rightRect; + public Int32 bottomRect; + public UInt32 bRop2; + public UInt32 fillMode; + public UInt32 backColor; + public UInt32 foreColor; + public rdpBrush brush; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPrimaryUpdate + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr DstBlt; + public IntPtr PatBlt; + public IntPtr ScrBlt; + public IntPtr OpaqueRect; + public IntPtr DrawNineGrid; + public IntPtr MultiDstBlt; + public IntPtr MultiPatBlt; + public IntPtr MultiScrBlt; + public IntPtr MultiOpaqueRect; + public IntPtr MultiDrawNineGrid; + public IntPtr LineTo; + public IntPtr Polyline; + public IntPtr MemBlt; + public IntPtr Mem3Blt; + public IntPtr SaveBitmap; + public IntPtr GlyphIndex; + public IntPtr FastIndex; + public IntPtr FastGlyph; + public IntPtr PolygonSC; + public IntPtr PolygonCB; + public IntPtr EllipseSC; + public IntPtr EllipseCB; + public fixed UInt32 paddingB[48-38]; + } + + public unsafe interface IPrimaryUpdate + { + void DstBlt(rdpContext* context, DstBltOrder* dstblt); + void PatBlt(rdpContext* context, PatBltOrder* patblt); + void ScrBlt(rdpContext* context, ScrBltOrder* scrblt); + void OpaqueRect(rdpContext* context, OpaqueRectOrder* opaqueRect); + void DrawNineGrid(rdpContext* context, DrawNineGridOrder* drawNineGrid); + void MultiDstBlt(rdpContext* context, MultiDstBltOrder* multi_dstblt); + void MultiPatBlt(rdpContext* context, MultiPatBltOrder* multi_patblt); + void MultiScrBlt(rdpContext* context, MultiScrBltOrder* multi_scrblt); + void MultiOpaqueRect(rdpContext* context, MultiOpaqueRectOrder* multi_opaque_rect); + void MultiDrawNineGrid(rdpContext* context, MultiDrawNineGridOrder* multi_draw_nine_grid); + void LineTo(rdpContext* context, LineToOrder* line_to); + void Polyline(rdpContext* context, PolylineOrder* polyline); + void MemBlt(rdpContext* context, MemBltOrder* memblt); + void Mem3Blt(rdpContext* context, Mem3BltOrder* mem3blt); + void SaveBitmap(rdpContext* context, SaveBitmapOrder* save_bitmap); + void GlyphIndex(rdpContext* context, GlyphIndexOrder* glyph_index); + void FastIndex(rdpContext* context, FastIndexOrder* fast_index); + void FastGlyph(rdpContext* context, FastGlyphOrder* fast_glyph); + void PolygonSC(rdpContext* context, PolygonSCOrder* polygon_sc); + void PolygonCB(rdpContext* context, PolygonCBOrder* polygon_cb); + void EllipseSC(rdpContext* context, EllipseSCOrder* ellipse_sc); + void EllipseCB(rdpContext* context, EllipseCBOrder* ellipse_cb); + } + + public unsafe class PrimaryUpdate + { + private freerdp* instance; + private rdpContext* context; + private rdpUpdate* update; + private rdpPrimaryUpdate* primary; + + delegate void DstBltDelegate(rdpContext* context, DstBltOrder* dstBlt); + delegate void PatBltDelegate(rdpContext* context, PatBltOrder* patBlt); + delegate void ScrBltDelegate(rdpContext* context, ScrBltOrder* scrBlt); + delegate void OpaqueRectDelegate(rdpContext* context, OpaqueRectOrder* opaqueRect); + delegate void DrawNineGridDelegate(rdpContext* context, DrawNineGridOrder* drawNineGrid); + delegate void MultiDstBltDelegate(rdpContext* context, MultiDstBltOrder* multiDstBlt); + delegate void MultiPatBltDelegate(rdpContext* context, MultiPatBltOrder* multiPatBlt); + delegate void MultiScrBltDelegate(rdpContext* context, MultiScrBltOrder* multiScrBlt); + delegate void MultiOpaqueRectDelegate(rdpContext* context, MultiOpaqueRectOrder* multiOpaqueRect); + delegate void MultiDrawNineGridDelegate(rdpContext* context, MultiDrawNineGridOrder* multiDrawNineGrid); + delegate void LineToDelegate(rdpContext* context, LineToOrder* lineTo); + delegate void PolylineDelegate(rdpContext* context, PolylineOrder* polyline); + delegate void MemBltDelegate(rdpContext* context, MemBltOrder* memBlt); + delegate void Mem3BltDelegate(rdpContext* context, Mem3BltOrder* mem3Blt); + delegate void SaveBitmapDelegate(rdpContext* context, SaveBitmapOrder* saveBitmap); + delegate void GlyphIndexDelegate(rdpContext* context, GlyphIndexOrder* glyphIndex); + delegate void FastIndexDelegate(rdpContext* context, FastIndexOrder* fastIndex); + delegate void FastGlyphDelegate(rdpContext* context, FastGlyphOrder* fastGlyph); + delegate void PolygonSCDelegate(rdpContext* context, PolygonSCOrder* polygonSC); + delegate void PolygonCBDelegate(rdpContext* context, PolygonCBOrder* polygonCB); + delegate void EllipseSCDelegate(rdpContext* context, EllipseSCOrder* ellipseSC); + delegate void EllipseCBDelegate(rdpContext* context, EllipseCBOrder* ellipseCB); + + private DstBltDelegate DstBlt; + private PatBltDelegate PatBlt; + private ScrBltDelegate ScrBlt; + private OpaqueRectDelegate OpaqueRect; + private DrawNineGridDelegate DrawNineGrid; + private MultiDstBltDelegate MultiDstBlt; + private MultiPatBltDelegate MultiPatBlt; + private MultiScrBltDelegate MultiScrBlt; + private MultiOpaqueRectDelegate MultiOpaqueRect; + private MultiDrawNineGridDelegate MultiDrawNineGrid; + private LineToDelegate LineTo; + private PolylineDelegate Polyline; + private MemBltDelegate MemBlt; + private Mem3BltDelegate Mem3Blt; + private SaveBitmapDelegate SaveBitmap; + private GlyphIndexDelegate GlyphIndex; + private FastIndexDelegate FastIndex; + private FastGlyphDelegate FastGlyph; + private PolygonSCDelegate PolygonSC; + private PolygonCBDelegate PolygonCB; + private EllipseSCDelegate EllipseSC; + private EllipseCBDelegate EllipseCB; + + public PrimaryUpdate(rdpContext* context) + { + this.context = context; + this.instance = context->instance; + this.update = instance->update; + this.primary = update->primary; + } + + public void RegisterInterface(IPrimaryUpdate iPrimary) + { + DstBlt = new DstBltDelegate(iPrimary.DstBlt); + PatBlt = new PatBltDelegate(iPrimary.PatBlt); + ScrBlt = new ScrBltDelegate(iPrimary.ScrBlt); + OpaqueRect = new OpaqueRectDelegate(iPrimary.OpaqueRect); + DrawNineGrid = new DrawNineGridDelegate(iPrimary.DrawNineGrid); + MultiDstBlt = new MultiDstBltDelegate(iPrimary.MultiDstBlt); + MultiPatBlt = new MultiPatBltDelegate(iPrimary.MultiPatBlt); + MultiScrBlt = new MultiScrBltDelegate(iPrimary.MultiScrBlt); + MultiOpaqueRect = new MultiOpaqueRectDelegate(iPrimary.MultiOpaqueRect); + MultiDrawNineGrid = new MultiDrawNineGridDelegate(iPrimary.MultiDrawNineGrid); + LineTo = new LineToDelegate(iPrimary.LineTo); + Polyline = new PolylineDelegate(iPrimary.Polyline); + MemBlt = new MemBltDelegate(iPrimary.MemBlt); + Mem3Blt = new Mem3BltDelegate(iPrimary.Mem3Blt); + SaveBitmap = new SaveBitmapDelegate(iPrimary.SaveBitmap); + GlyphIndex = new GlyphIndexDelegate(iPrimary.GlyphIndex); + FastIndex = new FastIndexDelegate(iPrimary.FastIndex); + FastGlyph = new FastGlyphDelegate(iPrimary.FastGlyph); + PolygonSC = new PolygonSCDelegate(iPrimary.PolygonSC); + PolygonCB = new PolygonCBDelegate(iPrimary.PolygonCB); + EllipseSC = new EllipseSCDelegate(iPrimary.EllipseSC); + EllipseCB = new EllipseCBDelegate(iPrimary.EllipseCB); + + primary->DstBlt = Marshal.GetFunctionPointerForDelegate(DstBlt); + primary->PatBlt = Marshal.GetFunctionPointerForDelegate(PatBlt); + primary->ScrBlt = Marshal.GetFunctionPointerForDelegate(ScrBlt); + primary->OpaqueRect = Marshal.GetFunctionPointerForDelegate(OpaqueRect); + primary->DrawNineGrid = Marshal.GetFunctionPointerForDelegate(DrawNineGrid); + primary->MultiDstBlt = Marshal.GetFunctionPointerForDelegate(MultiDstBlt); + primary->MultiPatBlt = Marshal.GetFunctionPointerForDelegate(MultiPatBlt); + primary->MultiScrBlt = Marshal.GetFunctionPointerForDelegate(MultiScrBlt); + primary->MultiOpaqueRect = Marshal.GetFunctionPointerForDelegate(MultiOpaqueRect); + primary->MultiDrawNineGrid = Marshal.GetFunctionPointerForDelegate(MultiDrawNineGrid); + primary->LineTo = Marshal.GetFunctionPointerForDelegate(LineTo); + primary->Polyline = Marshal.GetFunctionPointerForDelegate(Polyline); + primary->MemBlt = Marshal.GetFunctionPointerForDelegate(MemBlt); + primary->Mem3Blt = Marshal.GetFunctionPointerForDelegate(Mem3Blt); + primary->SaveBitmap = Marshal.GetFunctionPointerForDelegate(SaveBitmap); + primary->GlyphIndex = Marshal.GetFunctionPointerForDelegate(GlyphIndex); + primary->FastIndex = Marshal.GetFunctionPointerForDelegate(FastIndex); + primary->FastGlyph = Marshal.GetFunctionPointerForDelegate(FastGlyph); + primary->PolygonSC = Marshal.GetFunctionPointerForDelegate(PolygonSC); + primary->PolygonCB = Marshal.GetFunctionPointerForDelegate(PolygonCB); + primary->EllipseSC = Marshal.GetFunctionPointerForDelegate(EllipseSC); + primary->EllipseCB = Marshal.GetFunctionPointerForDelegate(EllipseCB); + } + } +} + diff --git a/FreeRDP/Core/Update/SecondaryUpdate.cs b/FreeRDP/Core/Update/SecondaryUpdate.cs new file mode 100644 index 0000000..788b58e --- /dev/null +++ b/FreeRDP/Core/Update/SecondaryUpdate.cs @@ -0,0 +1,219 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Secondary Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheBitmapOrder + { + public UInt32 cacheId; + public UInt32 bitmapBpp; + public UInt32 bitmapWidth; + public UInt32 bitmapHeight; + public UInt32 bitmapLength; + public UInt32 cacheIndex; + public fixed byte bitmapComprHdr[8]; + public byte* bitmapDataStream; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheBitmapV2Order + { + public UInt32 cacheId; + public UInt32 flags; + public UInt32 key1; + public UInt32 key2; + public UInt32 bitmapBpp; + public UInt32 bitmapWidth; + public UInt32 bitmapHeight; + public UInt32 bitmapLength; + public UInt32 cacheIndex; + public int compressed; + public fixed byte bitmapComprHdr[8]; + public byte* bitmapDataStream; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct BitmapDataEx + { + public UInt32 bpp; + public UInt32 codecID; + public UInt32 width; + public UInt32 height; + public UInt32 length; + public byte* data; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheBitmapV3Order + { + public UInt32 cacheId; + public UInt32 bpp; + public UInt32 flags; + public UInt32 cacheIndex; + public UInt32 key1; + public UInt32 key2; + public BitmapDataEx* bitmapData; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheColorTableOrder + { + public UInt32 cacheIndex; + public UInt32 numberColors; + public UInt32* colorTable; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct GlyphData + { + public UInt32 cacheIndex; + public Int32 x; + public Int32 y; + public UInt32 cx; + public UInt32 cy; + public UInt32 cb; + public byte* aj; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheGlyphOrder + { + public UInt32 cacheId; + public UInt32 cGlyphs; + //public GlyphData glyphData[255]; + public byte* unicodeCharacters; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct GlyphDataV2 + { + public UInt32 cacheIndex; + public Int32 x; + public Int32 y; + public UInt32 cx; + public UInt32 cy; + public UInt32 cb; + public byte* aj; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheGlyphV2Order + { + public UInt32 cacheId; + public UInt32 flags; + public UInt32 cGlyphs; + //public GlyphDataV2 glyphData[255]; + public byte* unicodeCharacters; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CacheBrushOrder + { + public UInt32 index; + public UInt32 bpp; + public UInt32 cx; + public UInt32 cy; + public UInt32 style; + public UInt32 length; + public byte* data; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpSecondaryUpdate + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr CacheBitmap; + public IntPtr CacheBitmapV2; + public IntPtr CacheBitmapV3; + public IntPtr CacheColorTable; + public IntPtr CacheGlyph; + public IntPtr CacheGlyphV2; + public IntPtr CacheBrush; + public fixed UInt32 paddingB[32-23]; + } + + public unsafe interface ISecondaryUpdate + { + void CacheBitmap(rdpContext* context, CacheBitmapOrder* cacheBitmapOrder); + void CacheBitmapV2(rdpContext* context, CacheBitmapV2Order* cacheBitmapV2Order); + void CacheBitmapV3(rdpContext* context, CacheBitmapV3Order* cacheBitmapV3Order); + void CacheColorTable(rdpContext* context, CacheColorTableOrder* cacheColorTableOrder); + void CacheGlyph(rdpContext* context, CacheGlyphOrder* cacheGlyphOrder); + void CacheGlyphV2(rdpContext* context, CacheGlyphV2Order* cacheGlyphV2Order); + void CacheBrush(rdpContext* context, CacheBrushOrder* cacheBrushOrder); + } + + public unsafe class SecondaryUpdate + { + private freerdp* instance; + private rdpContext* context; + private rdpUpdate* update; + private rdpSecondaryUpdate* secondary; + + delegate void CacheBitmapDelegate(rdpContext* context, CacheBitmapOrder* cacheBitmapOrder); + delegate void CacheBitmapV2Delegate(rdpContext* context, CacheBitmapV2Order* cacheBitmapV2Order); + delegate void CacheBitmapV3Delegate(rdpContext* context, CacheBitmapV3Order* cacheBitmapV3Order); + delegate void CacheColorTableDelegate(rdpContext* context, CacheColorTableOrder* cacheColorTableOrder); + delegate void CacheGlyphDelegate(rdpContext* context, CacheGlyphOrder* cacheGlyphOrder); + delegate void CacheGlyphV2Delegate(rdpContext* context, CacheGlyphV2Order* cacheGlyphV2Order); + delegate void CacheBrushDelegate(rdpContext* context, CacheBrushOrder* cacheBrushOrder); + + private CacheBitmapDelegate CacheBitmap; + private CacheBitmapV2Delegate CacheBitmapV2; + private CacheBitmapV3Delegate CacheBitmapV3; + private CacheColorTableDelegate CacheColorTable; + private CacheGlyphDelegate CacheGlyph; + private CacheGlyphV2Delegate CacheGlyphV2; + private CacheBrushDelegate CacheBrush; + + public SecondaryUpdate(rdpContext* context) + { + this.context = context; + this.instance = context->instance; + this.update = instance->update; + this.secondary = update->secondary; + } + + public void RegisterInterface(ISecondaryUpdate iSecondary) + { + CacheBitmap = new CacheBitmapDelegate(iSecondary.CacheBitmap); + CacheBitmapV2 = new CacheBitmapV2Delegate(iSecondary.CacheBitmapV2); + CacheBitmapV3 = new CacheBitmapV3Delegate(iSecondary.CacheBitmapV3); + CacheColorTable = new CacheColorTableDelegate(iSecondary.CacheColorTable); + CacheGlyph = new CacheGlyphDelegate(iSecondary.CacheGlyph); + CacheGlyphV2 = new CacheGlyphV2Delegate(iSecondary.CacheGlyphV2); + CacheBrush = new CacheBrushDelegate(iSecondary.CacheBrush); + + secondary->CacheBitmap = Marshal.GetFunctionPointerForDelegate(CacheBitmap); + secondary->CacheBitmapV2 = Marshal.GetFunctionPointerForDelegate(CacheBitmapV2); + secondary->CacheBitmapV3 = Marshal.GetFunctionPointerForDelegate(CacheBitmapV3); + secondary->CacheColorTable = Marshal.GetFunctionPointerForDelegate(CacheColorTable); + secondary->CacheGlyph = Marshal.GetFunctionPointerForDelegate(CacheGlyph); + secondary->CacheGlyphV2 = Marshal.GetFunctionPointerForDelegate(CacheGlyphV2); + secondary->CacheBrush = Marshal.GetFunctionPointerForDelegate(CacheBrush); + } + } +} + diff --git a/FreeRDP/Core/Update/Update.cs b/FreeRDP/Core/Update/Update.cs new file mode 100644 index 0000000..9175ab1 --- /dev/null +++ b/FreeRDP/Core/Update/Update.cs @@ -0,0 +1,217 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpBounds + { + public Int32 left; + public Int32 top; + public Int32 right; + public Int32 bottom; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct BitmapData + { + public UInt32 destLeft; + public UInt32 destTop; + public UInt32 destRight; + public UInt32 destBottom; + public UInt32 width; + public UInt32 height; + public UInt32 bitsPerPixel; + public UInt32 flags; + public UInt32 bitmapLength; + public fixed byte bitmapComprHdr[8]; + public IntPtr bitmapDataStream; + public int compressed; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct BitmapUpdate + { + public UInt32 count; + public UInt32 number; + public BitmapData* rectangles; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PaletteEntry + { + public byte red; + public byte green; + public byte blue; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PaletteUpdate + { + public UInt32 number; + public PaletteEntry* entries; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpPalette + { + public UInt32 count; + public PaletteEntry* entries; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct PlaySoundUpdate + { + public UInt32 duration; + public UInt32 frequency; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SurfaceBits + { + public UInt32 cmdType; + public UInt32 destLeft; + public UInt32 destTop; + public UInt32 destRight; + public UInt32 destBottom; + public UInt32 bpp; + public UInt32 codecID; + public UInt32 width; + public UInt32 height; + public UInt32 bitmapDataLength; + public byte* bitmapData; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SurfaceFrameMarker + { + public UInt32 frameAction; + public UInt32 frameId; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpUpdate + { + public IntPtr context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr BeginPaint; + public IntPtr EndPaint; + public IntPtr SetBounds; + public IntPtr Synchronize; + public IntPtr DesktopResize; + public IntPtr BitmapUpdate; + public IntPtr Palette; + public IntPtr PlaySound; + public fixed UInt32 paddingB[32-24]; + + public rdpPointerUpdate* pointer; + public rdpPrimaryUpdate* primary; + public rdpSecondaryUpdate* secondary; + public rdpAltSecUpdate* altsec; + public rdpWindowUpdate* window; + public fixed UInt32 paddingC[48-37]; + + public IntPtr RefreshRect; + public IntPtr SuppressOutput; + public fixed UInt32 paddingD[64-50]; + + public IntPtr Surface; + public IntPtr SurfaceBits; + public fixed UInt32 paddingE[80-66]; + } + + public unsafe interface IUpdate + { + void BeginPaint(rdpContext* context); + void EndPaint(rdpContext* context); + void SetBounds(rdpContext* context, rdpBounds* bounds); + void Synchronize(rdpContext* context); + void DesktopResize(rdpContext* context); + void BitmapUpdate(rdpContext* context, BitmapUpdate* bitmap); + void Palette(rdpContext* context, PaletteUpdate* palette); + void PlaySound(rdpContext* context, PlaySoundUpdate* playSound); + void SurfaceBits(rdpContext* context, SurfaceBits* surfaceBits); + } + + public unsafe class Update + { + private freerdp* instance; + private rdpContext* context; + private rdpUpdate* update; + + delegate void BeginPaintDelegate(rdpContext* context); + delegate void EndPaintDelegate(rdpContext* context); + delegate void SetBoundsDelegate(rdpContext* context, rdpBounds* bounds); + delegate void SynchronizeDelegate(rdpContext* context); + delegate void DesktopResizeDelegate(rdpContext* context); + delegate void BitmapUpdateDelegate(rdpContext* context, BitmapUpdate* bitmap); + delegate void PaletteDelegate(rdpContext* context, PaletteUpdate* palette); + delegate void PlaySoundDelegate(rdpContext* context, PlaySoundUpdate* playSound); + + delegate void RefreshRectDelegate(rdpContext* context, byte count, IntPtr areas); + delegate void SuppressOutputDelegate(rdpContext* context, byte allow, IntPtr area); + + delegate void SurfaceBitsDelegate(rdpContext* context, SurfaceBits* surfaceBits); + + private BeginPaintDelegate BeginPaint; + private EndPaintDelegate EndPaint; + private SetBoundsDelegate SetBounds; + private SynchronizeDelegate Synchronize; + private DesktopResizeDelegate DesktopResize; + private BitmapUpdateDelegate BitmapUpdate; + private PaletteDelegate Palette; + private PlaySoundDelegate PlaySound; + + private SurfaceBitsDelegate SurfaceBits; + + public Update(rdpContext* context) + { + this.context = context; + this.instance = context->instance; + this.update = instance->update; + } + + public void RegisterInterface(IUpdate iUpdate) + { + BeginPaint = new BeginPaintDelegate(iUpdate.BeginPaint); + EndPaint = new EndPaintDelegate(iUpdate.EndPaint); + SetBounds = new SetBoundsDelegate(iUpdate.SetBounds); + Synchronize = new SynchronizeDelegate(iUpdate.Synchronize); + DesktopResize = new DesktopResizeDelegate(iUpdate.DesktopResize); + BitmapUpdate = new BitmapUpdateDelegate(iUpdate.BitmapUpdate); + Palette = new PaletteDelegate(iUpdate.Palette); + PlaySound = new PlaySoundDelegate(iUpdate.PlaySound); + SurfaceBits = new SurfaceBitsDelegate(iUpdate.SurfaceBits); + + update->BeginPaint = Marshal.GetFunctionPointerForDelegate(BeginPaint); + update->EndPaint = Marshal.GetFunctionPointerForDelegate(EndPaint); + update->SetBounds = Marshal.GetFunctionPointerForDelegate(SetBounds); + update->Synchronize = Marshal.GetFunctionPointerForDelegate(Synchronize); + update->DesktopResize = Marshal.GetFunctionPointerForDelegate(DesktopResize); + update->BitmapUpdate = Marshal.GetFunctionPointerForDelegate(BitmapUpdate); + update->Palette = Marshal.GetFunctionPointerForDelegate(Palette); + update->PlaySound = Marshal.GetFunctionPointerForDelegate(PlaySound); + update->SurfaceBits = Marshal.GetFunctionPointerForDelegate(SurfaceBits); + } + } +} diff --git a/FreeRDP/Core/Update/WindowUpdate.cs b/FreeRDP/Core/Update/WindowUpdate.cs new file mode 100644 index 0000000..7f118f6 --- /dev/null +++ b/FreeRDP/Core/Update/WindowUpdate.cs @@ -0,0 +1,55 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Window Updates + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe delegate void pWindowCreate(rdpContext* context, IntPtr orderInfo, IntPtr window_state); + public unsafe delegate void pWindowUpdate(rdpContext* context, IntPtr orderInfo, IntPtr window_state); + public unsafe delegate void pWindowIcon(rdpContext* context, IntPtr orderInfo, IntPtr window_icon); + public unsafe delegate void pWindowCachedIcon(rdpContext* context, IntPtr orderInfo, IntPtr window_cached_icon); + public unsafe delegate void pWindowDelete(rdpContext* context, IntPtr orderInfo); + public unsafe delegate void pNotifyIconCreate(rdpContext* context, IntPtr orderInfo, IntPtr notify_icon_state); + public unsafe delegate void pNotifyIconUpdate(rdpContext* context, IntPtr orderInfo, IntPtr notify_icon_state); + public unsafe delegate void pNotifyIconDelete(rdpContext* context, IntPtr orderInfo); + public unsafe delegate void pMonitoredDesktop(rdpContext* context, IntPtr orderInfo, IntPtr monitored_desktop); + public unsafe delegate void pNonMonitoredDesktop(rdpContext* context, IntPtr orderInfo); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct rdpWindowUpdate + { + public rdpContext* context; + public fixed UInt32 paddingA[16-1]; + + public IntPtr WindowCreate; + public IntPtr WindowUpdate; + public IntPtr WindowIcon; + public IntPtr WindowCachedIcon; + public IntPtr WindowDelete; + public IntPtr NotifyIconCreate; + public IntPtr NotifyIconUpdate; + public IntPtr NotifyIconDelete; + public IntPtr MonitoredDesktop; + public IntPtr NonMonitoredDesktop; + public fixed UInt32 paddingB[32-26]; + } +} + diff --git a/FreeRDP/FreeRDP.csproj b/FreeRDP/FreeRDP.csproj new file mode 100644 index 0000000..28bb33f --- /dev/null +++ b/FreeRDP/FreeRDP.csproj @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>10.0.0</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{C5E8D831-864B-4BE7-8027-77727D5A6D80}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>FreeRDP</RootNamespace> + <AssemblyName>FreeRDP</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\bin\Debug</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <NoWarn>0414, 0219</NoWarn> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="AssemblyInfo.cs" /> + <Compile Include="Codec\FrameMarkerCommand.cs" /> + <Compile Include="Codec\Rfx.cs" /> + <Compile Include="Codec\RfxMessage.cs" /> + <Compile Include="Codec\SetSurfaceBitsCommand.cs" /> + <Compile Include="Codec\StreamSurfaceBitsCommand.cs" /> + <Compile Include="Codec\SurfaceBitsCommand.cs" /> + <Compile Include="Codec\SurfaceCommand.cs" /> + <Compile Include="Core\RDP.cs" /> + <Compile Include="Utils\Memory.cs" /> + <Compile Include="Core\Settings.cs" /> + <Compile Include="Core\Context.cs" /> + <Compile Include="GDI\GDI.cs" /> + <Compile Include="Core\FreeRDP.cs" /> + <Compile Include="Cache\Cache.cs" /> + <Compile Include="Cache\GlyphCache.cs" /> + <Compile Include="Cache\BitmapCache.cs" /> + <Compile Include="Cache\PointerCache.cs" /> + <Compile Include="Cache\BrushCache.cs" /> + <Compile Include="Cache\PaletteCache.cs" /> + <Compile Include="Cache\OffscreenCache.cs" /> + <Compile Include="Core\Update\SecondaryUpdate.cs" /> + <Compile Include="Core\Update\PrimaryUpdate.cs" /> + <Compile Include="Core\Update\PointerUpdate.cs" /> + <Compile Include="Core\Update\AltSecUpdate.cs" /> + <Compile Include="Core\Update\WindowUpdate.cs" /> + <Compile Include="Core\Update\Update.cs" /> + <Compile Include="Core\Graphics\Bitmap.cs" /> + <Compile Include="Core\Graphics\Pointer.cs" /> + <Compile Include="Core\Graphics\Glyph.cs" /> + <Compile Include="Core\Graphics\Graphics.cs" /> + <Compile Include="Core\Input.cs" /> + <Compile Include="Locale\Keyboard.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ProjectExtensions> + <MonoDevelop> + <Properties> + <Policies> + <DotNetNamingPolicy DirectoryNamespaceAssociation="None" ResourceNamePolicy="FileFormatDefault" /> + </Policies> + </Properties> + </MonoDevelop> + </ProjectExtensions> + <ItemGroup /> +</Project>
\ No newline at end of file diff --git a/FreeRDP/GDI/GDI.cs b/FreeRDP/GDI/GDI.cs new file mode 100644 index 0000000..1d95336 --- /dev/null +++ b/FreeRDP/GDI/GDI.cs @@ -0,0 +1,53 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Device Interface (GDI) + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class GDI + { + [DllImport("libfreerdp-gdi")] + public static extern int gdi_init(freerdp* instance, UInt32 flags, IntPtr buffer); + + [DllImport("libfreerdp-gdi")] + public static extern void gdi_free(freerdp* instance); + + private UInt32 flags; + private freerdp* instance; + + public GDI(freerdp* instance) + { + this.flags = 0; + this.instance = instance; + } + + public bool Init() + { + return ((gdi_init(instance, flags, IntPtr.Zero) == 0) ? false : true); + } + + ~GDI() + { + gdi_free(instance); + } + } +} + diff --git a/FreeRDP/Locale/Keyboard.cs b/FreeRDP/Locale/Keyboard.cs new file mode 100644 index 0000000..8bb1046 --- /dev/null +++ b/FreeRDP/Locale/Keyboard.cs @@ -0,0 +1,94 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Keyboard + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class Keyboard + { + private UInt32 keyboardLayoutId; + + [DllImport("libfreerdp-locale")] + public static extern UInt32 freerdp_keyboard_init(UInt32 keyboardLayoutId); + + [DllImport("libfreerdp-locale")] + public static extern IntPtr freerdp_keyboard_get_layout_name_from_id(UInt32 keyboardLayoutId); + + [DllImport("libfreerdp-locale")] + public static extern UInt32 freerdp_keyboard_get_rdp_scancode_from_x11_keycode(UInt32 keycode, ref int extended); + + [DllImport("libfreerdp-locale")] + public static extern UInt32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(UInt32 scancode, int extended); + + [DllImport("libfreerdp-locale")] + public static extern UInt32 freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(UInt32 vkcode, ref int extended); + + [DllImport("libfreerdp-locale")] + public static extern IntPtr freerdp_keyboard_get_virtual_key_code_name(UInt32 vkcode); + + public Keyboard() + { + keyboardLayoutId = freerdp_keyboard_init(0); + } + + public string GetKeyboardLayoutNameFromId(UInt32 keyboardLayoutId) + { + string keyboardLayoutName; + IntPtr cstr = freerdp_keyboard_get_layout_name_from_id(keyboardLayoutId); + keyboardLayoutName = Marshal.PtrToStringAuto(cstr); + return keyboardLayoutName; + } + + public UInt32 GetRdpScancodeFromX11Keycode(UInt32 keycode, ref int extended) + { + UInt32 scancode; + scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode, ref extended); + return scancode; + } + + public UInt32 GetX11KeycodeFromRdpScancode(UInt32 scancode, int extended) + { + UInt32 keycode; + keycode = freerdp_keyboard_get_x11_keycode_from_rdp_scancode(scancode, extended); + return keycode; + } + + public UInt32 GetRdpScancodeFromVirtualKeyCode(UInt32 vkcode, ref int extended) + { + UInt32 scancode; + scancode = freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(vkcode, ref extended); + return scancode; + } + + public string GetVirtualKeyCodeName(UInt32 vkcode) + { + string vkcodeName; + IntPtr cstr = freerdp_keyboard_get_virtual_key_code_name(vkcode); + vkcodeName = Marshal.PtrToStringAuto(cstr); + return vkcodeName; + } + + ~Keyboard() + { + + } + } +} diff --git a/FreeRDP/Utils/Memory.cs b/FreeRDP/Utils/Memory.cs new file mode 100644 index 0000000..3301509 --- /dev/null +++ b/FreeRDP/Utils/Memory.cs @@ -0,0 +1,67 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Memory Utils + * + * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace FreeRDP +{ + public unsafe class Memory + { + [DllImport("libfreerdp-utils")] + public static extern IntPtr xmalloc(UIntPtr size); + + [DllImport("libfreerdp-utils")] + public static extern IntPtr xzalloc(UIntPtr size); + + [DllImport("libfreerdp-utils")] + public static extern IntPtr xrealloc(IntPtr ptr, UIntPtr size); + + [DllImport("libfreerdp-utils")] + public static extern void xfree(IntPtr ptr); + + public Memory() + { + } + + public static IntPtr Malloc(int size) + { + UIntPtr size_t = new UIntPtr((ulong) size); + return xmalloc(size_t); + } + + public static IntPtr Zalloc(int size) + { + UIntPtr size_t = new UIntPtr((ulong) size); + return xzalloc(size_t); + } + + public static IntPtr Realloc(IntPtr ptr, int size) + { + UIntPtr size_t = new UIntPtr((ulong) size); + return xrealloc(ptr, size_t); + } + + public static void Free(IntPtr ptr) + { + xfree(ptr); + } + } +} + |