Exemplo n.º 1
0
    public App(string nibName)
    {
        NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication");

        // Load our nib. This will instantiate all of the native objects and wire them together.
        // The C# SimpleLayoutView will be created the first time Objective-C calls one of the
        // methods SimpleLayoutView added or overrode.
        NSObject dict = new Class("NSMutableDictionary").Call("alloc").Call("init").To<NSObject>();
        NSObject key = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("NSOwner")).To<NSObject>();
        dict.Call("setObject:forKey:", app, key);

        NSObject bundle = new Class("NSBundle").Call("mainBundle").To<NSObject>();

        NSObject nib = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto(nibName)).To<NSObject>();
        sbyte loaded = (sbyte) bundle.Call("loadNibFile:externalNameTable:withZone:", nib, dict, null);
        if (loaded != 1)
            throw new InvalidOperationException("Couldn't load the nib file");

        // We need an NSAutoreleasePool to do Native.Call, but we don't want to have one
        // hanging around while we're in the main event loop because that may hide bugs.
        // So, we'll instantiate a Native instance here and call Invoke later which can
        // be done without an NSAutoreleasePool.
        m_run = new Native(app, new Selector("run"));

        dict.release();
    }
Exemplo n.º 2
0
 static IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, ref Native.KBDLLHOOKSTRUCT lParam)
 {
     bool cancel = false;
     if(nCode == Native.HC_ACTION) {
         KeybordCaptureEventArgs e = new KeybordCaptureEventArgs(lParam);
         switch(wParam.ToInt32()) {
             case Native.WM_KEYDOWN:
                 if(KeyDown != null)
                     KeyDown(null, e);
                 break;
             case Native.WM_KEYUP:
                 if(KeyUp != null)
                     KeyUp(null, e);
                 break;
             case Native.WM_SYSKEYDOWN:
                 if(SysKeyDown != null)
                     SysKeyDown(null, e);
                 break;
             case Native.WM_SYSKEYUP:
                 if(SysKeyUp != null)
                     SysKeyUp(null, e);
                 break;
         }
         cancel = e.Cancel;
     }
     return cancel ? (IntPtr)1 : Native.CallNextHookEx(s_hook, nCode, wParam, ref lParam);
 }
Exemplo n.º 3
0
        internal void PopulateConfiguration(ref Native.Configuration configuration)
        {
            var migrationHandle = GCHandle.Alloc(this);

            configuration.migration_callback = MigrationCallback;
            configuration.managed_migration_handle = GCHandle.ToIntPtr(migrationHandle);
        }
Exemplo n.º 4
0
 internal UnixFileSystemInfo(String path, Native.Stat stat)
 {
     this.originalPath = path;
     this.fullPath = UnixPath.GetFullPath (path);
     this.stat = stat;
     this.valid = true;
 }
Exemplo n.º 5
0
		public UnixStream Create (Native.FilePermissions mode)
		{
			int fd = Native.Syscall.creat (FullPath, mode);
			if (fd < 0)
				UnixMarshal.ThrowExceptionForLastError ();
			base.Refresh ();
			return new UnixStream (fd);
		}
 /// <summary>
 /// Creates new instance of this type.
 /// </summary>
 /// <param name="name">Name of the port.</param>
 /// <param name="displayName">Display name of this port.</param>
 /// <param name="description">Description of this port.</param>
 /// <param name="enumConfig">Enumeration config.</param>
 /// <param name="defaultValue">Default value to use.</param>
 public NativeInputPortConfiguration(string name, string displayName, string description, string enumConfig, Native.FlowInputData defaultValue)
 {
     this.Name = Marshal.StringToHGlobalUni(name);
     this.HumanName = Marshal.StringToHGlobalUni(displayName);
     this.Description = Marshal.StringToHGlobalUni(description);
     this.EnumConfig = Marshal.StringToHGlobalUni(enumConfig);
     this.DefaultValue = defaultValue;
 }
Exemplo n.º 7
0
		private static Native.Group CopyGroup (Native.Group group)
		{
			Native.Group g = new Native.Group ();

			g.gr_gid    = group.gr_gid;
			g.gr_mem    = group.gr_mem;
			g.gr_name   = group.gr_name;
			g.gr_passwd = group.gr_passwd;

			return g;
		}
Exemplo n.º 8
0
		private static string strerror_r (Native.Errno errno)
		{
			StringBuilder buf = new StringBuilder (16);
			int r = 0;
			do {
				buf.Capacity *= 2;
				r = Native.Syscall.strerror_r (errno, buf);
			} while (r == -1 && Native.Stdlib.GetLastError() == Native.Errno.ERANGE);

			if (r == -1)
				return "** Unknown error code: " + ((int) errno) + "**";
			return buf.ToString();
		}
Exemplo n.º 9
0
		private static Native.Passwd CopyPasswd (Native.Passwd pw)
		{
			Native.Passwd p = new Native.Passwd ();

			p.pw_name   = pw.pw_name;
			p.pw_passwd = pw.pw_passwd;
			p.pw_uid    = pw.pw_uid;
			p.pw_gid    = pw.pw_gid;
			p.pw_gecos  = pw.pw_gecos;
			p.pw_dir    = pw.pw_dir;
			p.pw_shell  = pw.pw_shell;

			return p;
		}
        public static SharedRealmHandle OpenWithSync(Realms.Native.Configuration configuration, Native.SyncConfiguration syncConfiguration, RealmSchema schema, byte[] encryptionKey)
        {
            DoInitialFileSystemConfiguration();

            var marshaledSchema = new SharedRealmHandle.SchemaMarshaler(schema);

            NativeException nativeException;
            var result = NativeMethods.open_with_sync(configuration, syncConfiguration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, out nativeException);
            nativeException.ThrowIfNecessary();

            var handle = new SharedRealmHandle();
            handle.SetHandle(result);
            return handle;
        }
Exemplo n.º 11
0
        public static void DoEnableDisable(
            Native.DeviceInfoListHandle devs, ref Native.SP_DEVINFO_DATA devInfo,
            string deviceId, EnableDisableParameters parms
        )
        {
            if (devInfo.ClassGuid != parms.ClassGuid)
                return;
            if (devInfo.DevInst != parms.DevInst)
                return;

            var options = parms.AppParams.Options;

            if ((options.Count == 0) || options.Contains("disable")) {
                Console.WriteLine(
                    "// Physical ID for volume {0} is #{1}. You can use this ID to re-enable the volume.",
                    parms.DriveLetter, devInfo.DevInst
                );

                Console.Write("Disabling volume {0}... ", parms.DriveLetter);
                try {
                    Native.ChangeDeviceEnabledState(
                        devs, ref devInfo,
                        DiClassInstallState.DICS_DISABLE,
                        DiClassInstallScope.DICS_FLAG_CONFIGSPECIFIC,
                        DiClassInstallFunction.DIF_PROPERTYCHANGE
                    );

                    Console.WriteLine("ok.");
                } catch (Exception ex) {
                    Console.WriteLine("failed.");
                }
            }

            if ((options.Count == 0) || options.Contains("enable")) {
                Console.Write("Enabling volume {0}... ", parms.DriveLetter);
                try {
                    Native.ChangeDeviceEnabledState(
                        devs, ref devInfo,
                        DiClassInstallState.DICS_ENABLE,
                        DiClassInstallScope.DICS_FLAG_CONFIGSPECIFIC,
                        DiClassInstallFunction.DIF_PROPERTYCHANGE
                    );

                    Console.WriteLine("ok.");
                } catch (Exception ex) {
                    Console.WriteLine("failed.");
                }
            }
        }
Exemplo n.º 12
0
 public void SendKeyboardKey( Native.KeyboardKeys key )
 {
     NativeKeySendingEventArgs e = new NativeKeySendingEventArgs( key );
     if( this.KeySending != null )
     {
         this.KeySending( this, e );
     }
     if( !e.Cancel )
     {
         KeyboardProcessor.Process( key );
         if( this.KeySent != null )
         {
             this.KeySent( this, new NativeKeySentEventArgs( key ) );
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// XmCreateXXの呼び出し
        /// </summary>
        public static IntPtr CallCreate2P(Native.Motif.CreateSymbol sym, Widgets.IWidget parent,string name, Native.Xt.XtArg[] args)
        {
            if (null ==args || 0 == args.Length) {
                return Instance.xmCreateFuncs[(int)sym](parent.NativeHandle.Widget, name, null, 0);
            }

            Native.Xt.NativeXtArg[] au = new Native.Xt.NativeXtArg[args.Length];
            int argc = ExtremeSports.TnkConvertResourceEx(args, au, true);
            foreach(Native.Xt.NativeXtArg k in au) {
                System.Diagnostics.Debug.WriteLine($"NA<A>: {k.Name} : {k.Value}");
            }
            System.Diagnostics.Debug.WriteLine($"XM_CVT {au.Length} -> {argc}");
            IntPtr wgt = Instance.xmCreateFuncs[(int)sym](parent.NativeHandle.Widget, name, au, argc);
            ExtremeSports.TnkFreeDeepCopyArg(au);

            return wgt;
        }
Exemplo n.º 14
0
 public void SetConnectionName(Connection peer, string name)
 {
     Native.SteamAPI_ISteamNetworkingSockets_SetConnectionName(nativeSockets, peer, name);
 }
Exemplo n.º 15
0
 public static extern IntPtr open(Native.Configuration configuration,
     [MarshalAs(UnmanagedType.LPArray), In] Native.SchemaObject[] objects, int objects_length,
     [MarshalAs(UnmanagedType.LPArray), In] Native.SchemaProperty[] properties,
     byte[] encryptionKey,
     out NativeException ex);
Exemplo n.º 16
0
 private void CloseDB(C4Database *db)
 {
     Native.c4db_close(db, null);
     Native.c4db_free(db);
 }
Exemplo n.º 17
0
        static void InitializeDesktop(string libvlcDirectoryPath = null)
        {
            if (PlatformHelper.IsLinux)
            {
                if (!string.IsNullOrEmpty(libvlcDirectoryPath))
                {
                    throw new InvalidOperationException($"Using {nameof(libvlcDirectoryPath)} is not supported on the Linux platform. " +
                                                        $"The recommended way is to have the libvlc librairies in /usr/lib. Use LD_LIBRARY_PATH if you need more customization");
                }
                // Initializes X threads before calling VLC. This is required for vlc plugins like the VDPAU hardware acceleration plugin.
                if (Native.XInitThreads() == 0)
                {
#if !NETSTANDARD1_1
                    Trace.WriteLine("XInitThreads failed");
#endif
                }
                return;
            }

            // full path to directory location of libvlc and libvlccore has been provided
            if (!string.IsNullOrEmpty(libvlcDirectoryPath))
            {
                bool loadResult;
                if (PlatformHelper.IsWindows)
                {
                    var libvlccorePath = LibVLCCorePath(libvlcDirectoryPath);
                    loadResult = LoadNativeLibrary(libvlccorePath, out _libvlccoreHandle);
                    if (!loadResult)
                    {
                        Log($"Failed to load required native libraries at {libvlccorePath}");
                        return;
                    }
                }

                var libvlcPath = LibVLCPath(libvlcDirectoryPath);
                loadResult = LoadNativeLibrary(libvlcPath, out _libvlcHandle);
                if (!loadResult)
                {
                    Log($"Failed to load required native libraries at {libvlcPath}");
                }
                return;
            }

#if !NETSTANDARD1_1
            var paths = ComputeLibVLCSearchPaths();

            foreach (var path in paths)
            {
                if (PlatformHelper.IsWindows)
                {
                    LoadNativeLibrary(path.libvlccore, out _libvlccoreHandle);
                }
                var loadResult = LoadNativeLibrary(path.libvlc, out _libvlcHandle);
                if (loadResult)
                {
                    break;
                }
            }

            if (!Loaded)
            {
                throw new VLCException($"Failed to load required native libraries. Search paths include {string.Join("; ", paths.Select(p => $"{p.libvlc},{p.libvlccore}"))}");
            }
#endif
        }
Exemplo n.º 18
0
		// Read the specified symbolic link.  If the file isn't a symbolic link,
		// return null; otherwise, return the contents of the symbolic link.
		//
		// readlink(2) is horribly evil, as there is no way to query how big the
		// symlink contents are.  Consequently, it's trial and error...
		private static string ReadSymbolicLink (string path, out Native.Errno errno)
		{
			errno = (Native.Errno) 0;
			StringBuilder buf = new StringBuilder (256);
			do {
				int r = Native.Syscall.readlink (path, buf);
				if (r < 0) {
					errno = Native.Stdlib.GetLastError ();
					return null;
				}
				else if (r == buf.Capacity) {
					buf.Capacity *= 2;
				}
				else
					return buf.ToString (0, r);
			} while (true);
		}
Exemplo n.º 19
0
 internal static bool IsSet(Native.FilePermissions mode, Native.FilePermissions type)
 {
     return (mode & type) == type;
 }
Exemplo n.º 20
0
 public bool DestroyPollGroup(PollGroup pollGroup)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_DestroyPollGroup(nativeSockets, pollGroup));
 }
Exemplo n.º 21
0
 public long GetConnectionUserData(Connection peer)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetConnectionUserData(nativeSockets, peer));
 }
Exemplo n.º 22
0
 public bool GetIdentity(ref NetworkingIdentity identity)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetIdentity(nativeSockets, ref identity));
 }
Exemplo n.º 23
0
 public PollGroup CreatePollGroup()
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_CreatePollGroup(nativeSockets));
 }
Exemplo n.º 24
0
 public bool CreateSocketPair(Connection connectionLeft, Connection connectionRight, bool useNetworkLoopback, ref NetworkingIdentity identityLeft, ref NetworkingIdentity identityRight)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_CreateSocketPair(nativeSockets, connectionLeft, connectionRight, useNetworkLoopback, ref identityLeft, ref identityRight));
 }
Exemplo n.º 25
0
 public bool GetListenSocketAddress(ListenSocket socket, ref Address address)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetListenSocketAddress(nativeSockets, socket, ref address));
 }
Exemplo n.º 26
0
 public int GetDetailedConnectionStatus(Connection connection, StringBuilder status, int statusLength)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetDetailedConnectionStatus(nativeSockets, connection, status, statusLength));
 }
Exemplo n.º 27
0
 public void AddMotionEvent(Native.X11.Masks _Mask, EventHandler<Events.Server.MotionEventArgs> listener)
 {
     ulong mask = (ulong)_Mask;
     MotionEventTable.AddHandler(Widget, mask , listener);
 }
Exemplo n.º 28
0
 public bool SetConnectionPollGroup(PollGroup pollGroup, Connection connection)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_SetConnectionPollGroup(nativeSockets, connection, pollGroup));
 }
Exemplo n.º 29
0
    public void Time()
    {
        Class klass = new Class("NSString");
        NSObject str1 = (NSObject) klass.Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("hello world"));
        NSObject str2 = (NSObject) klass.Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("100"));
        NSObject str3 = (NSObject) klass.Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("foo"));

        Stopwatch timer = Stopwatch.StartNew();
        for (int i = 0; i < 10000; ++i)
        {
            str3.Call("hasPrefix:", str1);
        }
        Console.WriteLine("{0}	{1:0.0} secs", new Native(str3, new Selector("hasPrefix:")), timer.ElapsedMilliseconds/1000.0);

        timer = Stopwatch.StartNew();
        for (int i = 0; i < 10000; ++i)
        {
            str2.Call("intValue");
        }
        Console.WriteLine("{0}	{1:0.0} secs", new Native(str2, new Selector("intValue")), timer.ElapsedMilliseconds/1000.0);

        timer = Stopwatch.StartNew();
        for (int i = 0; i < 10000; ++i)
        {
            str1.Call("uppercaseString");
        }
        Console.WriteLine("{0}	{1:0.0} secs", new Native(str1, new Selector("uppercaseString")), timer.ElapsedMilliseconds/1000.0);

        Native native = new Native(str1, new Selector("uppercaseString"));
        timer = Stopwatch.StartNew();
        for (int i = 0; i < 10000; ++i)
        {
            native.Invoke();
        }
        Console.WriteLine("Native {0}	{1:0.0} secs", native, timer.ElapsedMilliseconds/1000.0);

        string s = "hello world";
        timer = Stopwatch.StartNew();
        for (int i = 0; i < 10000; ++i)
        {
            s.ToUpper();
        }
        Console.WriteLine("Managed ToUpper: {0:0.0} secs", timer.ElapsedMilliseconds/1000.0);
    }
Exemplo n.º 30
0
 public void RunCallbacks()
 {
     Native.SteamAPI_ISteamNetworkingSockets_RunCallbacks(nativeSockets);
 }
Exemplo n.º 31
0
		public void RestoreFilePosition (Native.FilePosition pos)
		{
			AssertNotDisposed ();
			if (pos == null)
				throw new ArgumentNullException ("value");
			int r = Native.Stdlib.fsetpos (file, pos);
			UnixMarshal.ThrowExceptionForLastErrorIf (r);
			GC.KeepAlive (this);
		}
Exemplo n.º 32
0
 public bool SetStatusCallback(StatusCallback callback)
 {
     return(Native.SteamAPI_ISteamNetworkingUtils_SetGlobalCallback_SteamNetConnectionStatusChanged(nativeUtils, callback));
 }
Exemplo n.º 33
0
 public long GetConfigurationValue(Native.PathconfName name)
 {
     long r = Native.Syscall.pathconf (FullPath, name);
     if (r == -1 && Native.Stdlib.GetLastError () != (Native.Errno)0)
         UnixMarshal.ThrowExceptionForLastError ();
     return r;
 }
Exemplo n.º 34
0
 public void SetDebugCallback(DebugType detailLevel, DebugCallback callback)
 {
     Native.SteamAPI_ISteamNetworkingUtils_SetDebugOutputFunction(nativeUtils, detailLevel, callback);
 }
Exemplo n.º 35
0
 public bool GetQuickConnectionStatus(Connection connection, ref ConnectionStatus status)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetQuickConnectionStatus(nativeSockets, connection, ref status));
 }
Exemplo n.º 36
0
 public bool SetConfigurationValue(ConfigurationValue configurationValue, ConfigurationScope configurationScope, IntPtr scopeObject, ConfigurationDataType dataType, IntPtr value)
 {
     return(Native.SteamAPI_ISteamNetworkingUtils_SetConfigValue(nativeUtils, configurationValue, configurationScope, scopeObject, dataType, value));
 }
 private static string VisitDefault(C4Error err) => $"CouchbaseLiteException ({err.domain} / {err.code}): {Native.c4error_getMessage(err)}.";
Exemplo n.º 38
0
 public bool SetConfigurationValue(Configuration configuration, ConfigurationScope configurationScope, IntPtr scopeObject)
 {
     return(Native.SteamAPI_ISteamNetworkingUtils_SetConfigValueStruct(nativeUtils, configuration, configurationScope, scopeObject));
 }
Exemplo n.º 39
0
 public bool GetConnectionName(Connection peer, StringBuilder name, int maxLength)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetConnectionName(nativeSockets, peer, name, maxLength));
 }
Exemplo n.º 40
0
 public ConfigurationValueResult GetConfigurationValue(ConfigurationValue configurationValue, ConfigurationScope configurationScope, IntPtr scopeObject, ref ConfigurationDataType dataType, ref IntPtr result, ref IntPtr resultLength)
 {
     return(Native.SteamAPI_ISteamNetworkingUtils_GetConfigValue(nativeUtils, configurationValue, configurationScope, scopeObject, ref dataType, ref result, ref resultLength));
 }
Exemplo n.º 41
0
        public IntPtr Open(Native.Configuration configuration, RealmSchema schema, byte[] encryptionKey)
        {
            var marshaledSchema = new SchemaMarshaler(schema);

            NativeException nativeException;
            var result = NativeMethods.open(configuration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, out nativeException);
            nativeException.ThrowIfNecessary();
            return result;
        }
Exemplo n.º 42
0
 public static void Deinitialize()
 {
     Native.GameNetworkingSockets_Kill();
 }
Exemplo n.º 43
0
 public Body(Native.BodyId bodyId)
 {
   BodyId = bodyId;
 }
Exemplo n.º 44
0
 public Result FlushMessagesOnConnection(Connection connection)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_FlushMessagesOnConnection(nativeSockets, connection));
 }
		public static extern int DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string text, int iCharCount, int dwFlags, ref Native.RECT pRect, ref DTTOPTS pOptions);
Exemplo n.º 46
0
 public Result SendMessageToConnection(Connection connection, IntPtr data, int length, SendFlags flags)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(nativeSockets, connection, data, (uint)length, flags, IntPtr.Zero));
 }
Exemplo n.º 47
0
		public UnixUserInfo (Native.Passwd passwd)
		{
			this.passwd = CopyPasswd (passwd);
		}
Exemplo n.º 48
0
 internal override void DecRef(Context ctx, IntPtr obj)
 {
     Native.Z3_model_dec_ref(ctx.nCtx, obj);
 }
Exemplo n.º 49
0
		public void SaveFilePosition (Native.FilePosition pos)
		{
			AssertNotDisposed ();
			int r = Native.Stdlib.fgetpos (file, pos);
			UnixMarshal.ThrowExceptionForLastErrorIf (r);
			GC.KeepAlive (this);
		}
Exemplo n.º 50
0
 internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx))
 {
     Contract.Requires(ctx != null);
 }
Exemplo n.º 51
0
		public static string GetConfigurationString (Native.ConfstrName name)
		{
			ulong len = Native.Syscall.confstr (name, null, 0);
			if (len == unchecked ((ulong) (-1)))
				UnixMarshal.ThrowExceptionForLastError ();
			if (len == 0)
				return "";
			StringBuilder buf = new StringBuilder ((int) len+1);
			len = Native.Syscall.confstr (name, buf, len);
			if (len == unchecked ((ulong) (-1)))
				UnixMarshal.ThrowExceptionForLastError ();
			return buf.ToString ();
		}
Exemplo n.º 52
0
        public static FrontalFaceDetector GetFrontalFaceDetector()
        {
            var ret = Native.get_frontal_face_detector();

            return(new FrontalFaceDetector(ret));
        }
Exemplo n.º 53
0
 public bool CanAccess(Native.AccessModes mode)
 {
     int r = Native.Syscall.access (FullPath, mode);
     return r == 0;
 }
Exemplo n.º 54
0
 protected override void DisposeUnmanaged()
 {
     base.DisposeUnmanaged();
     Native.frontal_face_detector_delete(this.NativePtr);
 }
Exemplo n.º 55
0
 internal static bool IsFileType(Native.FilePermissions mode, Native.FilePermissions type)
 {
     return (mode & Native.FilePermissions.S_IFMT) == type;
 }
Exemplo n.º 56
0
        private C4Database *OpenDB()
        {
            var database = (C4Database *)LiteCoreBridge.Check(err => Native.c4db_open(DatabasePath(),
                                                                                      Native.c4db_getConfig(Db), err));

            return(database);
        }
Exemplo n.º 57
0
 protected virtual bool GetFileStatus(string path, out Native.Stat stat)
 {
     return Native.Syscall.stat (path, out stat) == 0;
 }
Exemplo n.º 58
0
 public bool GetConnectionInfo(Connection connection, ref ConnectionInfo info)
 {
     return(Native.SteamAPI_ISteamNetworkingSockets_GetConnectionInfo(nativeSockets, connection, ref info));
 }
Exemplo n.º 59
0
        unsafe void ScanSection(Native.IMAGE_SECTION_HEADER sectionHdr)
        {
            long sectionDataAddr = loadAddr + sectionHdr.PointerToRawData;

            Console.WriteLine("\nScanning section '{0}' at 0x{1:X2}...\n", sectionHdr.Name, sectionDataAddr);

            byte* dataPtr = (byte*)(sectionDataAddr);
            byte* endPtr = (byte*)(dataPtr + sectionHdr.SizeOfRawData);

            while (dataPtr < endPtr)
            {

                if (*dataPtr == 0x0A)
                {
                    byte* originalPtr = dataPtr;
                    int nullskiplevel = 0;

                rescan:
                    int t = nullskiplevel;
                    dataPtr = originalPtr;

                    byte[] data = null;

                    using (var ms = new MemoryStream())
                    using (var bw = new BinaryWriter(ms))
                    {
                        for (; *(short*)dataPtr != 0 || t-- > 0; dataPtr++)
                        {
                            bw.Write(*dataPtr);
                        }

                        // do we still need this?
                        // the extra null byte on the descriptor proto is causing the deserializer to freak out
                        // bw.Write((byte)0);

                        data = ms.ToArray();
                    }


                    dataPtr++;

                    if (data.Length < 2)
                    {
                        dataPtr = originalPtr + 1;
                        continue;
                    }

                    byte strLen = data[1];

                    if (data.Length - 2 < strLen)
                    {
                        dataPtr = originalPtr + 1;
                        continue;
                    }

                    string protoName = Encoding.ASCII.GetString(data, 2, strLen);

                    if (!protoName.EndsWith(".proto"))
                    {
                        dataPtr = originalPtr + 1;
                        continue;
                    }

                    if (!HandleProto(protoName, data))
                    {
                        nullskiplevel++;

                        goto rescan;
                    }
                }
                else
                {
                    dataPtr++;
                }
            }
        }
Exemplo n.º 60
0
 /// <summary>
 /// Conversion of models to strings.
 /// </summary>
 /// <returns>A string representation of the model.</returns>
 public override string ToString()
 {
     return(Native.Z3_model_to_string(Context.nCtx, NativeObject));
 }