當前位置: 首頁>>代碼示例>>C#>>正文


C# IntPtr.ToInt64方法代碼示例

本文整理匯總了C#中System.IntPtr.ToInt64方法的典型用法代碼示例。如果您正苦於以下問題:C# IntPtr.ToInt64方法的具體用法?C# IntPtr.ToInt64怎麽用?C# IntPtr.ToInt64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.ToInt64方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Align

 private byte* Align(IntPtr buf, uint alignTo)
 {
     //This makes an aligned buffer linux needs this.
     //The buffer must originally be at least one alignment bigger!
     var diff = alignTo - (buf.ToInt64() % alignTo);
     var aligned = (IntPtr)(buf.ToInt64() + diff);
     return (byte*)aligned;
 }
開發者ID:czcz1024,項目名稱:EventStore,代碼行數:8,代碼來源:UnbufferedFileStream.cs

示例2: SharedMemory

        public SharedMemory(string name, IntPtr size)
        {
            mmf = MemoryMappedFile.OpenExisting(name + "_CONNECT_DATA");

            mmva = mmf.CreateViewAccessor();
            if (mmf.SafeMemoryMappedFileHandle.IsInvalid)
                throw new MySqlException("Cannot open file mapping " + name);
            mmvs = mmf.CreateViewStream(0L, size.ToInt64());
            mmva = mmf.CreateViewAccessor(0L, size.ToInt64());
        }
開發者ID:noahvans,項目名稱:mariadb-connector-net,代碼行數:10,代碼來源:SharedMemoryStream.cs

示例3: GetReadSize

 static IntPtr GetReadSize(IntPtr pointer, IntPtr endPointer, int bufferSize)
 {
     if (endPointer.ToInt64() < IntPtr.Add(pointer, bufferSize).ToInt64())
     {
         return (IntPtr)(endPointer.ToInt64() - pointer.ToInt64());
     }
     else
     {
         return new IntPtr(bufferSize);
     }
 }
開發者ID:toydev,項目名稱:ExampleCSharp,代碼行數:11,代碼來源:Program.cs

示例4: Read

        /// <summary>
        /// Read a hardware independent dictionary of language and code page identifier tables.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of data.</param>
        /// <returns>Pointer to the end of data.</returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _vars.Clear();
            IntPtr pChild = base.Read(lpRes);

            while (pChild.ToInt64() < (lpRes.ToInt64() + _header.wLength))
            {
                VarTable res = new VarTable(pChild);
                _vars.Add(res.Key, res);
                pChild = ResourceUtil.Align(pChild.ToInt64() + res.Header.wLength);
            }

            return new IntPtr(lpRes.ToInt64() + _header.wLength);
        }
開發者ID:xingkongtianyu,項目名稱:Apex-Crypter,代碼行數:19,代碼來源:VarFileInfo.cs

示例5: Read

        /// <summary>
        /// Read a table of language and code page identifier pairs.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of the data.</param>
        /// <returns></returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _languages.Clear();
            IntPtr pVar = base.Read(lpRes);

            while (pVar.ToInt64() < (lpRes.ToInt64() + _header.wLength))
            {
                Kernel32.VAR_HEADER var = (Kernel32.VAR_HEADER) Marshal.PtrToStructure(
                    pVar, typeof(Kernel32.VAR_HEADER));
                _languages.Add(var.wLanguageIDMS, var.wCodePageIBM);
                pVar = new IntPtr(pVar.ToInt64() + Marshal.SizeOf(var));
            }

            return new IntPtr(lpRes.ToInt64() + _header.wLength);
        }
開發者ID:GabberBaby,項目名稱:DotNetObfuscator,代碼行數:20,代碼來源:VarTable.cs

示例6: MarshallingStream

 /// <summary> Constructs a stream that marshals bytes from unmanaged memory </summary>
 public MarshallingStream(IntPtr ptrBytes, bool readOnly, int start, int length)
 {
     _ptrBytes = start == 0 ? ptrBytes : new IntPtr(ptrBytes.ToInt64() + start);
     _readOnly = readOnly;
     _length = length;
     _position = 0;
 }
開發者ID:hivie7510,項目名稱:csharptest-net,代碼行數:8,代碼來源:MarshallingStream.cs

示例7: Read

        /// <summary>
        /// Read the accelerator.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        internal IntPtr Read(IntPtr lpRes)
        {
            _accel = (User32.ACCEL) Marshal.PtrToStructure(
                lpRes, typeof(User32.ACCEL));

            return new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_accel));
        }
開發者ID:xingkongtianyu,項目名稱:Apex-Crypter,代碼行數:11,代碼來源:Accelerator.cs

示例8: NtWriteFile

        public static UInt32 NtWriteFile(
            IntPtr FileHandle,
            IntPtr Event,
            IntPtr ApcRoutine,
            IntPtr ApcContext,
            IntPtr IoStatusBlock,
            IntPtr Buffer,
            UInt32 Length,
            UInt32 ByteOffset,
            UInt32 Key)
        {
            if (DetourBlock.IsDetouring) {
                return OriginalFn(FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock,
                    Buffer, Length, ByteOffset, Key);
            }

            using (var block = new DetourBlock())
            {
                var result = OriginalFn(FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock,
                    Buffer, Length, ByteOffset, Key);

                if (result == 0 /* STATUS_SUCCESS */)
                {
                    Remoting.Scribe.DocumentFileWrite(Process.GetCurrentProcess().Id, FileHandle.ToInt64());
                }

                return result;
            }
        }
開發者ID:coapp-deprecated,項目名稱:_trace_deprecated,代碼行數:29,代碼來源:NtWriteFile.cs

示例9: Assemble

 /// <summary>
 ///     Assemble the specified assembly code at a base address.
 /// </summary>
 /// <param name="asm">The assembly code.</param>
 /// <param name="baseAddress">The address where the code is rebased.</param>
 /// <returns>An array of bytes containing the assembly code.</returns>
 public byte[] Assemble(string asm, IntPtr baseAddress)
 {
     // Rebase the code
     asm = $"use32\norg 0x{baseAddress.ToInt64():X8}\n" + asm;
     // Assemble and return the code
     return FasmNet.Assemble(asm);
 }
開發者ID:jasteph,項目名稱:MemorySharp,代碼行數:13,代碼來源:Fasm32Assembler.cs

示例10: WndProc

		internal static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
		{
			if (msg != CUSTOM_MESSAGE) {
				return IntPtr.Zero;
			}
			handled = true;
			long fileNumber = wParam.ToInt64();
			long openEvenIfProjectIsOpened = lParam.ToInt64();
			LoggingService.Info("Receiving custom message...");
			if (openEvenIfProjectIsOpened == 0 && ProjectService.OpenSolution != null) {
				return new IntPtr(RESULT_PROJECT_IS_OPEN);
			} else {
				try {
					WorkbenchSingleton.SafeThreadAsyncCall(
						delegate { NativeMethods.SetForegroundWindow(WorkbenchSingleton.MainWin32Window.Handle) ; }
					);
					string tempFileName = Path.Combine(Path.GetTempPath(), "sd" + fileNumber + ".tmp");
					foreach (string file in File.ReadAllLines(tempFileName)) {
						WorkbenchSingleton.SafeThreadAsyncCall(
							delegate(string openFileName) { FileService.OpenFile(openFileName); }
							, file
						);
					}
				} catch (Exception ex) {
					LoggingService.Warn(ex);
				}
				return new IntPtr(RESULT_FILES_HANDLED);
			}
		}
開發者ID:Altaxo,項目名稱:Altaxo,代碼行數:29,代碼來源:SingleInstanceHelper.cs

示例11: Initialize

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			GFileDescriptorBasedIface native_iface = (GFileDescriptorBasedIface) Marshal.PtrToStructure (ifaceptr, typeof (GFileDescriptorBasedIface));
			native_iface.GetFd = iface.GetFd;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}
開發者ID:akrisiun,項目名稱:gtk-sharp,代碼行數:7,代碼來源:FileDescriptorBasedAdapter.cs

示例12: WLAN_INTERFACE_INFO_LIST

        /// <summary>
        ///     Constructor for WLAN_INTERFACE_INFO_LIST.
        ///     Constructor is needed because the InterfaceInfo member varies based on how many adapters are in the system.
        /// </summary>
        /// <param name="pointerToWlanInterfaceInfoList">the unmanaged pointer containing the list.</param>
        public WLAN_INTERFACE_INFO_LIST(IntPtr pointerToWlanInterfaceInfoList)
        {
            // The first 4 bytes are the number of WLAN_INTERFACE_INFO structures.
            this.dwNumberOfItems = Marshal.ReadInt32(pointerToWlanInterfaceInfoList, (0 * Marshal.SizeOf(typeof(int))));

            // The next 4 bytes are the index of the current item in the unmanaged API.
            this.dwIndex = Marshal.ReadInt32(pointerToWlanInterfaceInfoList, (1 * Marshal.SizeOf(typeof(int))));

            // Construct the array of WLAN_INTERFACE_INFO structures.
            this.InterfaceInfo = new WLAN_INTERFACE_INFO[this.dwNumberOfItems];

            // start pointer
            long start = pointerToWlanInterfaceInfoList.ToInt64() + (2 * Marshal.SizeOf(typeof(int))); // we skip 8 for the first and second int in the structure

            // get the size of WLAN_INTERFACE_INFO
            int sizeOfWlanInterfaceInfo = Marshal.SizeOf(typeof (WLAN_INTERFACE_INFO));

            // we know there are dwNumberOfItems in the struct
            // so we can take each of those memory pieces and marshal them to WLAN_INTERFACE_INFO

            for (int i = 0; i <= this.dwNumberOfItems - 1; i++)
            {
                var pItemList = new IntPtr(start + (i * sizeOfWlanInterfaceInfo));

                this.InterfaceInfo[i] = (WLAN_INTERFACE_INFO) Marshal.PtrToStructure(pItemList, typeof (WLAN_INTERFACE_INFO));
            }
        }
開發者ID:CSharpFan,項目名稱:wireless-prio,代碼行數:32,代碼來源:WLAN_INTERFACE_INFO_LIST.cs

示例13: IntPtrToBytes

 private static byte[] IntPtrToBytes(IntPtr p, long offset, long length)
 {
     byte[] buffer = new byte[0x10 + IntPtr.Size];
     for (int i = 0; i < 8; i++)
     {
         buffer[i] = (byte) ((offset >> (8 * i)) & 0xffL);
     }
     for (int j = 0; j < 8; j++)
     {
         buffer[8 + j] = (byte) ((length >> (8 * j)) & 0xffL);
     }
     if (IntPtr.Size == 4)
     {
         int num3 = p.ToInt32();
         for (int m = 0; m < 4; m++)
         {
             buffer[0x10 + m] = (byte) ((num3 >> (8 * m)) & 0xff);
         }
         return buffer;
     }
     long num5 = p.ToInt64();
     for (int k = 0; k < 8; k++)
     {
         buffer[0x10 + k] = (byte) ((num5 >> (8 * k)) & 0xffL);
     }
     return buffer;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:27,代碼來源:MemoryBytes.cs

示例14: GetEveObjectType

 public static PyType? GetEveObjectType(IntPtr intptr, bool isDerived = false)
 {
     PyType? returnType;
     if (!_pythontypesLoaded)
     {
         PopulatePythonTypes();
     }
     if (intptr == IntPtr.Zero)
     {
         return PyType.Invalid;
     }
     IntPtr key = Marshal.ReadIntPtr(((IntPtr)intptr.ToInt64() + 4)); // Points to the type
     if (!_pythonTypes.TryGetValue(key, out returnType) && !isDerived)
     {
         returnType = GetEveObjectType(key, true);
         _pythonTypes.Add(key, returnType);
         return returnType;
     }
     if (isDerived)
     {
         string str = returnType.ToString();
         returnType = (PyType)Enum.Parse(typeof(PyType), "Derived" + str);
     }
     return returnType;
 }
開發者ID:Pgde,項目名稱:EBot-master,代碼行數:25,代碼來源:PyCall.cs

示例15: Initialize

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			AtkHyperlinkImplIface native_iface = (AtkHyperlinkImplIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkHyperlinkImplIface));
			native_iface.GetHyperlink = iface.GetHyperlink;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}
開發者ID:akrisiun,項目名稱:gtk-sharp,代碼行數:7,代碼來源:HyperlinkImplAdapter.cs


注:本文中的System.IntPtr.ToInt64方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。