Esempio n. 1
0
        private FrgOnAuthenticateResult OnAuthenticate(IntPtr usernameUtf8, IntPtr passwordUtf8, IntPtr domainUtf8)
        {
            _channel.WriteDelimited(new RdpMessage
            {
                Authenticate = new RdpAuthenticateMessage
                {
                    Username = MarshalHelper.ReadUtf8IntPtr(usernameUtf8),
                    Password = MarshalHelper.ReadUtf8IntPtr(passwordUtf8),
                    Domain   = MarshalHelper.ReadUtf8IntPtr(domainUtf8),
                }
            });

            var result = _rdpAuthenticateResultMessage.Wait();

            return(new FrgOnAuthenticateResult
            {
                UsernameUtf8 = result.Username != null?MarshalHelper.AllocUtf8(result.Username) : usernameUtf8,
                                   PasswordUtf8 = result.Password != null?MarshalHelper.AllocUtf8(result.Password) : passwordUtf8,
                                                      DomainUtf8 = result.Domain != null?MarshalHelper.AllocUtf8(result.Domain) : domainUtf8,
                                                                       PasswordEntered = result.PasswordEntered,
            });
        }
Esempio n. 2
0
        public DisposableFrgMainOptions(MainOptions options)
        {
            var argv = new List<string>();
            argv.Add("a.exe");

            if (options.Hostname != null)
            {
                argv.Add($"/v:{options.Hostname}");
            }

            if (options.Domain != null)
            {
                argv.Add($"/d:{options.Domain}");
            }

            if (options.Username != null)
            {
                argv.Add($"/u:{options.Username}");
            }

            if (options.Password != null)
            {
                argv.Add($"/p:{options.Password}");
            }

            var argvArray = argv.Select((term) => MarshalHelper.AllocUtf8(term)).ToArray();
            var (argvNative, argc) = MarshalHelper.AllocCopyArray(argvArray);

            Value = new FrgMainOptions
            {
                Argc = (int) argc,
                Argv = argvNative,
                EntryPoints = new FrgEntryPoints
                {
                    OnContextCreated    = GetDelegatePtr(options.EntryPoints.OnContextCreated),
                    OnVerifyCertificate = GetDelegatePtr(options.EntryPoints.OnVerifyCertificate),
                    OnAuthenticate      = GetDelegatePtr(options.EntryPoints.OnAuthenticate),
                    UpdateCallbacks = new FrgUpdateCallbacks
                    {
                        BeginPaint            = GetDelegatePtr(options.EntryPoints.UpdateCallbacks.BeginPaint),
                        EndPaint              = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.EndPaint),
                        DesktopResize         = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.DesktopResize),
                        Palette               = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.Palette),
                        SetBounds             = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.SetBounds),
                        SurfaceBits           = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.SurfaceBits),
                        SurfaceFrameMarker    = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.SurfaceFrameMarker),
                        BitmapUpdate          = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.BitmapUpdate),
                        DstBlt                = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.DstBlt),
                        PatBlt                = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.PatBlt),
                        ScrBlt                = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.ScrBlt),
                        OpaqueRect            = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.OpaqueRect),
                        MultiOpaqueRect       = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.MultiOpaqueRect),
                        LineTo                = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.LineTo),
                        Polyline              = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.Polyline),
                        MemBlt                = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.MemBlt),
                        Mem3Blt               = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.Mem3Blt),
                        GlyphIndex            = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.GlyphIndex),
                        FastIndex             = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.FastIndex),
                        FastGlyph             = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.FastGlyph),
                        CacheColorTable       = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheColorTable),
                        CacheBrush            = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheBrush),
                        CacheGlyph            = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheGlyph),
                        CacheGlyphV2          = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheGlyphV2),
                        CacheBitmap           = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheBitmap),
                        CacheBitmapV2         = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheBitmapV2),
                        CacheBitmapV3         = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CacheBitmapV3),
                        CreateOffscreenBitmap = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.CreateOffscreenBitmap),
                        SwitchSurface         = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.SwitchSurface),
                        FrameMarker           = GetDelegatePtr(options.EntryPoints.UpdateCallbacks?.FrameMarker),
                    },
                },
            };
        }