private static void TryQueryPerformanceFrequency(out LARGE_INTEGER lpFrequency) { if (Kernel32.QueryPerformanceFrequency(out lpFrequency) == TerraFX.Interop.Windows.FALSE) { DirectXHelper.ThrowWin32Exception($"{nameof(Kernel32.QueryPerformanceFrequency)} failed"); } }
public Extent(IntPtr ptr) { IntPtr extentPtr = ptr; NextVcn = (LARGE_INTEGER)Marshal.PtrToStructure(extentPtr, typeof(LARGE_INTEGER)); Lcn = (LARGE_INTEGER)Marshal.PtrToStructure(IntPtr.Add(extentPtr, 8), typeof(LARGE_INTEGER)); }
private IStream SaveDocumentWindowPositions(IVsUIShellDocumentWindowMgr windowsMgr) { if (windowsMgr == null) { Debug.Assert(false, "IVsUIShellDocumentWindowMgr", String.Empty, 0); return(null); } IStream stream; NativeMethods.CreateStreamOnHGlobal(IntPtr.Zero, true, out stream); if (stream == null) { Debug.Assert(false, "CreateStreamOnHGlobal", String.Empty, 0); return(null); } int hr = windowsMgr.SaveDocumentWindowPositions(0, stream); if (hr != VSConstants.S_OK) { Debug.Assert(false, "SaveDocumentWindowPositions", String.Empty, hr); return(null); } // Move to the beginning of the stream // In preparation for reading LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = 0; //Seek to the beginning of the stream stream.Seek(l, 0, ul); return(stream); }
internal static ulong PIXGetTimestampCounter() { LARGE_INTEGER time = default; Kernel32.QueryPerformanceCounter(&time); return((ulong)time.QuadPart); }
static extern UInt32 NtCreateSection( ref IntPtr SectionHandle, UInt32 DesiredAccess, IntPtr ObjectAttributes, ref LARGE_INTEGER MaximumSize, UInt32 SectionPageProtection, UInt32 AllocationAttributes, IntPtr FileHandle);
public static long Int64FromLuid([NativeTypeName("const LUID &")] LUID *Luid) { LARGE_INTEGER val = new LARGE_INTEGER(); val.Anonymous.LowPart = Luid->LowPart; val.Anonymous.HighPart = Luid->HighPart; return(val.QuadPart); }
public static Luid FromInt64(long int64) { LARGE_INTEGER val = new LARGE_INTEGER { QuadPart = int64 }; return(new Luid(val.Anonymous.LowPart, val.Anonymous.HighPart)); }
public VOLUME_BITMAP_BUFFER(IntPtr pBitmap, int bufferSize) { StartingLcn = (LARGE_INTEGER)Marshal.PtrToStructure(pBitmap, typeof(LARGE_INTEGER)); BitmapSize = (LARGE_INTEGER)Marshal.PtrToStructure(IntPtr.Add(pBitmap, 8), typeof(LARGE_INTEGER)); Buffer = new byte[bufferSize]; Marshal.Copy(IntPtr.Add(pBitmap, 16), Buffer, 0, bufferSize); }
public override long Seek(long offset, SeekOrigin origin) { LARGE_INTEGER li = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); li.QuadPart = offset; _comStream.Seek(li, (uint)origin, ul); return((long)ul[0].QuadPart); }
private static unsafe void TryQueryPerformanceCounter(out LARGE_INTEGER lpPerformanceCounter) { fixed(LARGE_INTEGER *pPerformanceCounter = &lpPerformanceCounter) { if (Windows.QueryPerformanceCounter(pPerformanceCounter) == Windows.TRUE) { return; } } }
private static unsafe void TryQueryPerformanceFrequency(out LARGE_INTEGER lpFrequency) { fixed(LARGE_INTEGER *pFrequency = &lpFrequency) { if (Windows.QueryPerformanceFrequency(pFrequency) == Windows.TRUE) { return; } } }
public override long Seek(long offset, SeekOrigin origin) { var l = new LARGE_INTEGER(); var ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = offset; comStream.Seek(l, (uint)origin, ul); return((long)ul[0].QuadPart); }
private static unsafe void TryQueryPerformanceFrequency(out LARGE_INTEGER lpFrequency) { fixed(LARGE_INTEGER *pFrequency = &lpFrequency) { if (Kernel32.QueryPerformanceFrequency(pFrequency) == TerraFX.Interop.Windows.FALSE) { DirectXHelper.ThrowComException($"{nameof(Kernel32.QueryPerformanceFrequency)} failed"); } } }
/// <summary> /// 打开或还原进程权限 /// </summary> /// <param name="Access">系统特权枚举</param> /// <param name="Enable">表打开或还原默认</param> /// <returns>返回一个布尔型,表示成功和失败</returns> public bool EnablePrivilege(Privilege Access, bool Enable) { IntPtr hToken = new IntPtr(); //获取当前进程虚拟句柄 IntPtr DescProcess = GetCurrentProcess(); //打开进程令牌 int htRet = OpenProcessToken(DescProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref hToken); if (hToken == null) { return(false); } //获取系统特权值 LARGE_INTEGER SeDebug = new LARGE_INTEGER(); int LookRet = LookupPrivilegeValue(null, SE_NAME[(int)Access], ref SeDebug); if (LookRet == 0) { goto Close; } //构造DeBug特权令牌 TOKEN_PRIVILEGES nToken = new TOKEN_PRIVILEGES(); LUID_AND_ATTRIBUTES nAttrib = new LUID_AND_ATTRIBUTES(); nAttrib.pLuid = SeDebug; nAttrib.Attributes = Enable ? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_ENABLED_BY_DEFAULT; nToken.PrivilegeCount = 1; nToken.Privileges = new LUID_AND_ATTRIBUTES[] { nAttrib }; int nSize = System.Runtime.InteropServices.Marshal.SizeOf(nToken); //接受原始令牌信息 TOKEN_PRIVILEGES rToken = new TOKEN_PRIVILEGES(); int rSize = 0; //打开进程权限[注意:该API返回值不表示成功与失败] int Temp = AdjustTokenPrivileges(hToken, 0, ref nToken, nSize, ref rToken, ref rSize); int Result = GetLastError(); //打开/关闭特权失败 if (Result != 0) { goto Close; } //打开/关闭特权成功 return(true); Close: CloseHandle(hToken); return(false); }
/*** * Attempts to create an RWX section of the given size */ public bool CreateSection(uint size) { LARGE_INTEGER liVal = new LARGE_INTEGER(); size_ = round_to_page(size); liVal.LowPart = size_; var status = ZwCreateSection(ref section_, GenericAll, (IntPtr)0, ref liVal, PageReadWriteExecute, SecCommit, (IntPtr)0); return(nt_success(status)); }
public override long Seek(long offset, SeekOrigin origin) { LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1] { new ULARGE_INTEGER() }; l.QuadPart = offset; _iStream.Seek(l, (uint)origin, ul); return((long)ul[0].QuadPart); }
// public bool GetTick(out LARGE_INTEGER currentTickCount) { if (QueryPerformanceCounter(out currentTickCount) == false) { throw new Win32Exception("QueryPerformanceCounter() failed!"); } else { return(true); } }
private bool CreateSection(uint size) { LARGE_INTEGER liVal = new LARGE_INTEGER(); size_ = round_to_page(size); liVal.LowPart = size_; var status = ZwCreateSection(ref section_, 0x10000000, (IntPtr)0, ref liVal, MemoryProtection.ExecuteReadWrite, AllocationType.SecCommit, (IntPtr)0); return(nt_success(status)); }
/// <include file='WinRT.xml' path='doc/member[@name="WinRT.LuidFromInt64"]/*' /> public static LUID LuidFromInt64([NativeTypeName("INT64")] long Int64) { LARGE_INTEGER val = new LARGE_INTEGER(); val.QuadPart = Int64; LUID Luid = new LUID(); Luid.LowPart = val.Anonymous.LowPart; Luid.HighPart = val.Anonymous.HighPart; return(Luid); }
public static void Rewind(this IStream stream) { var dlibMove = new LARGE_INTEGER(); var plibNewPosition = new ULARGE_INTEGER[1] { new ULARGE_INTEGER() }; dlibMove.QuadPart = 0L; stream.Seek(dlibMove, 0U, plibNewPosition); }
public override long Seek(long offset, SeekOrigin origin) { ThreadHelper.ThrowIfNotOnUIThread(); LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = offset; comStream.Seek(l, (uint)origin, ul); return((long)ul[0].QuadPart); }
public override long Seek(long offset, SeekOrigin origin) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1] { new ULARGE_INTEGER() }; l.QuadPart = offset; _iStream.Seek(l, (uint)origin, ul); return((long)ul[0].QuadPart); }
public bool CreateSection(uint size) { LARGE_INTEGER liVal = new LARGE_INTEGER(); size_ = round_to_page(size); liVal.LowPart = size_; var pointer = Generic.GetLibraryAddress("ntdll.dll", "ZwCreateSection"); var ZwCreateSection = Marshal.GetDelegateForFunctionPointer(pointer, typeof(ZwCreateSection)) as ZwCreateSection; long status = ZwCreateSection(ref section_, GenericAll, (IntPtr)0, ref liVal, PageReadWriteExecute, SecCommit, (IntPtr)0); return(nt_success(status)); }
/// <summary> /// When overridden in a derived class, sets the position within the current stream. /// </summary> /// <param name="offset">A byte offset relative to the <paramref name="origin"/> parameter.</param> /// <param name="origin">A value of type <see cref="T:System.IO.SeekOrigin"/> indicating the reference point used to obtain the new position.</param> /// <returns> /// The new position within the current stream. /// </returns> /// <exception cref="T:System.IO.IOException">An I/O error occurs. </exception> /// <exception cref="T:System.NotSupportedException">The stream does not support seeking, such as if the stream is constructed from a pipe or console output. </exception> /// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception> public override long Seek(long offset, SeekOrigin origin) { if (_disposed) { throw new ObjectDisposedException("ComStreamWrapper"); } LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = offset; _comStream.Seek(l, (uint)origin, ul); return((long)ul[0].QuadPart); }
public VOLUME_BITMAP_BUFFER(IntPtr pBitmap, bool getBuffer) { StartingLcn = (LARGE_INTEGER)Marshal.PtrToStructure(pBitmap, typeof(LARGE_INTEGER)); BitmapSize = (LARGE_INTEGER)Marshal.PtrToStructure(IntPtr.Add(pBitmap, 8), typeof(LARGE_INTEGER)); if (getBuffer) { int bufferSize = (int)(BitmapSize.QuadPart / 8); Buffer = new byte[bufferSize]; Marshal.Copy(IntPtr.Add(pBitmap, 16), Buffer, 0, bufferSize); } else { Buffer = null; } }
public int Seek(IStreamImpl *pinst, LARGE_INTEGER dlibMove, uint dwOrigin, ULARGE_INTEGER *plibNewPosition) { long npos = dlibMove.QuadPart + (dwOrigin == (uint)SeekOrigin.Begin ? pinst->offset : 0); var stm = (Stream)GCHandle.FromIntPtr(pinst->source).Target !; long cpos = stm.Position; if (!(dwOrigin == (uint)SeekOrigin.Current && npos == 0) && !(dwOrigin == (uint)SeekOrigin.Begin && npos == cpos)) { cpos = stm.Seek(npos, (SeekOrigin)dwOrigin); } if (plibNewPosition is not null) { plibNewPosition->QuadPart = (ulong)(cpos - pinst->offset); } return(S_OK); }
public RETRIEVAL_POINTERS_BUFFER(IntPtr ptr) { ExtentCount = (int)Marshal.PtrToStructure(ptr, typeof(int)); ptr = IntPtr.Add(ptr, 8); // Added additional 4 bytes because of padding // StartingVcn StartingVcn = (LARGE_INTEGER)Marshal.PtrToStructure(ptr, typeof(LARGE_INTEGER)); ptr = IntPtr.Add(ptr, 8); Extents = new List <Extent>(); for (int i = 0; i < ExtentCount; i++) { Extents.Add(new Extent(ptr)); ptr = IntPtr.Add(ptr, 16); } }
private void averageTimerDemoButton_Click(object sender, System.EventArgs e) { // Ermitteln der Systemticks LARGE_INTEGER pc = new LARGE_INTEGER(); if (QueryPerformanceCounter(ref pc)) { long systemTicks = pc.GetValue(); pc5.IncrementBy(systemTicks - startTicks); // pc5.RawValue = systemTicks - startTicks; pc6.IncrementBy(1); infoLabel.Text = "Sekunden zwischen den letzten beiden Clicks: " + ((systemTicks - startTicks) / (double)performanceFrequency); startTicks = systemTicks; } else { infoLabel.Text = "Kann QueryPerformanceCounter nicht verwenden"; } }
private static extern int ZwCreateSection(ref IntPtr section, uint desiredAccess, IntPtr pAttrs, ref LARGE_INTEGER pMaxSize, uint pageProt, uint allocationAttribs, IntPtr hFile);
/// <summary> /// When overridden in a derived class, sets the position within the current stream. /// </summary> /// <param name="offset">A byte offset relative to the <paramref name="origin"/> parameter.</param> /// <param name="origin">A value of type <see cref="T:System.IO.SeekOrigin"/> indicating the reference point used to obtain the new position.</param> /// <returns> /// The new position within the current stream. /// </returns> /// <exception cref="T:System.IO.IOException">An I/O error occurs. </exception> /// <exception cref="T:System.NotSupportedException">The stream does not support seeking, such as if the stream is constructed from a pipe or console output. </exception> /// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception> public override long Seek(long offset, SeekOrigin origin) { if (_disposed) throw new ObjectDisposedException("ComStreamWrapper"); LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = offset; _comStream.Seek(l, (uint)origin, ul); return (long)ul[0].QuadPart; }
public static extern bool QueryPerformanceCounter([Out] out LARGE_INTEGER lpPerformanceCount);
public static extern int QueryPerformanceCounter( ref LARGE_INTEGER lpPerformanceCount );
public static extern int QueryPerformanceFrequency(ref LARGE_INTEGER lpFrequency );
public override long Seek(long offset, SeekOrigin origin) { LARGE_INTEGER li = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); li.QuadPart = offset; _comStream.Seek(li, (uint)origin, ul); return (long)ul[0].QuadPart; }
public override long Seek(long offset, SeekOrigin origin) { var l = new LARGE_INTEGER(); var ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = offset; comStream.Seek(l, (uint)origin, ul); return (long)ul[0].QuadPart; }
void IStream.Seek(LARGE_INTEGER dlibMove, uint dwOrigin, ULARGE_INTEGER[] plibNewPosition) { var pos = base.Seek(dlibMove.QuadPart, (SeekOrigin)dwOrigin); plibNewPosition[0].QuadPart = (ulong)pos; }
[DllImport("kernel32.dll")] public extern static int
public override long Seek(long offset, SeekOrigin origin) { LARGE_INTEGER large_integer1 = new LARGE_INTEGER(); ULARGE_INTEGER[] ularge_integerArray1 = new ULARGE_INTEGER[] { new ULARGE_INTEGER() }; large_integer1.QuadPart = offset; this.comStream.Seek(large_integer1, (uint) origin, ularge_integerArray1); return (long) ularge_integerArray1[0].QuadPart; }
private IStream SaveDocumentWindowPositions(IVsUIShellDocumentWindowMgr windowsMgr) { if (windowsMgr == null) { Debug.Assert(false, "IVsUIShellDocumentWindowMgr", String.Empty, 0); return null; } IStream stream; NativeMethods.CreateStreamOnHGlobal(IntPtr.Zero, true, out stream); if (stream == null) { Debug.Assert(false, "CreateStreamOnHGlobal", String.Empty, 0); return null; } int hr = windowsMgr.SaveDocumentWindowPositions(0, stream); if (hr != VSConstants.S_OK) { Debug.Assert(false, "SaveDocumentWindowPositions", String.Empty, hr); return null; } // Move to the beginning of the stream // In preparation for reading LARGE_INTEGER l = new LARGE_INTEGER(); ULARGE_INTEGER[] ul = new ULARGE_INTEGER[1]; ul[0] = new ULARGE_INTEGER(); l.QuadPart = 0; //Seek to the beginning of the stream stream.Seek(l, 0, ul); return stream; }
internal static extern bool GetFileSizeEx( SafeFileHandle hFile, ref LARGE_INTEGER lpFileSize );
public virtual void Seek(LARGE_INTEGER offset, uint origin, ULARGE_INTEGER[] newPosition) { newPosition[0].QuadPart = (ulong)Seek((long)offset.QuadPart, (int)origin); }