/// <summary> /// Converts a <see cref="UInt32"/> to big endian notation. /// </summary> /// <param name="input">The <see cref="UInt32"/> to convert.</param> /// <returns>The converted <see cref="UInt32"/>.</returns> public static UInt32 BigEndian(UInt32 input) { if (!BitConverter.IsLittleEndian) return input; return Swap(input); }
internal static IAsyncOperationWithProgress<IBuffer, UInt32> ReadAsync_MemoryStream(Stream stream, IBuffer buffer, UInt32 count) { Debug.Assert(stream != null); Debug.Assert(stream is SREMemoryStream); Debug.Assert(stream.CanRead); Debug.Assert(stream.CanSeek); Debug.Assert(buffer != null); Debug.Assert(buffer is IBufferByteAccess); Debug.Assert(0 <= count); Debug.Assert(count <= Int32.MaxValue); Debug.Assert(count <= buffer.Capacity); Contract.EndContractBlock(); // We will return a different buffer to the user backed directly by the memory stream (avoids memory copy). // This is permitted by the WinRT stream contract. // The user specified buffer will not have any data put into it: buffer.Length = 0; SREMemoryStream memStream = stream as SREMemoryStream; Debug.Assert(memStream != null); try { IBuffer dataBuffer = memStream.GetWindowsRuntimeBuffer((Int32)memStream.Position, (Int32)count); if (dataBuffer.Length > 0) memStream.Seek(dataBuffer.Length, SeekOrigin.Current); return AsyncInfo.CreateCompletedOperation<IBuffer, UInt32>(dataBuffer); } catch (Exception ex) { return AsyncInfo.CreateFaultedOperation<IBuffer, UInt32>(ex); } } // ReadAsync_MemoryStream
//Initializes, attaches it to archive internal ZipArchiveEntry(ZipArchive archive, ZipCentralDirectoryFileHeader cd) { _archive = archive; _originallyInArchive = true; _diskNumberStart = cd.DiskNumberStart; _versionToExtract = (ZipVersionNeededValues)cd.VersionNeededToExtract; _generalPurposeBitFlag = (BitFlagValues)cd.GeneralPurposeBitFlag; CompressionMethod = (CompressionMethodValues)cd.CompressionMethod; _lastModified = new DateTimeOffset(ZipHelper.DosTimeToDateTime(cd.LastModified)); _compressedSize = cd.CompressedSize; _uncompressedSize = cd.UncompressedSize; _offsetOfLocalHeader = cd.RelativeOffsetOfLocalHeader; /* we don't know this yet: should be _offsetOfLocalHeader + 30 + _storedEntryNameBytes.Length + extrafieldlength * but entryname/extra length could be different in LH */ _storedOffsetOfCompressedData = null; _crc32 = cd.Crc32; _compressedBytes = null; _storedUncompressedData = null; _currentlyOpenForWrite = false; _everOpenedForWrite = false; _outstandingWriteStream = null; FullName = DecodeEntryName(cd.Filename); _lhUnknownExtraFields = null; //the cd should have these as null if we aren't in Update mode _cdUnknownExtraFields = cd.ExtraFields; _fileComment = cd.FileComment; _compressionLevel = null; }
public static UInt32 SwapBytes(UInt32 x) { // swap adjacent 16-bit blocks x = (x >> 16) | (x << 16); // swap adjacent 8-bit blocks return ((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8); }
/** * Returns 1 if enabled, 0 if disabled, -1 if not applicable (i.e., a 64-bit process) */ public static int IsDepEnabled(UInt32 pid) { UInt32 Flags = PROCESS_DEP_DISABLE; bool Permanent = false; IntPtr hProcess = IntPtr.Zero; hProcess = OpenProcess(ProcessAccessFlags.QueryInformation, false, (int)pid); if (hProcess == IntPtr.Zero) { throw new System.ComponentModel.Win32Exception(GetLastError()); } bool is32bit = false; if (!IsWow64Process(hProcess, out is32bit)) { throw new System.ComponentModel.Win32Exception(GetLastError()); } if (is32bit) { if (GetProcessDEPPolicy(hProcess, out Flags, out Permanent)) { CloseHandle(hProcess); if ((Flags | PROCESS_DEP_ENABLE) == PROCESS_DEP_ENABLE) { return 1; } else { return 0; } } else { CloseHandle(hProcess); throw new System.ComponentModel.Win32Exception(GetLastError()); } } else { return -1; } }
public override void Write(UInt32 val) { val = Utilities.SwapBytes(val); base.Write(val); if (AutoFlush) Flush(); }
public static byte[] UInt32(UInt32 i, Endianness e = Endianness.Machine) { byte[] bytes = BitConverter.GetBytes(i); if (NeedsFlipping(e)) Array.Reverse(bytes); return bytes; }
private static extern IntPtr CreateThread( UInt32 lpThreadAttributes, UInt32 dwStackSize, UInt32 lpStartAddress, IntPtr param, UInt32 dwCreationFlags, ref UInt32 lpThreadId );
public static void Write(this BinaryWriter writer, UInt32 value, bool invertEndian = false) { if (invertEndian) { writer.WriteInvertedBytes(BitConverter.GetBytes(value)); } else { writer.Write(value); } }
public void ToString_() { UInt32 i = new UInt32(); foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) { i.ToString(); i.ToString(); i.ToString(); i.ToString(); i.ToString(); i.ToString(); i.ToString(); i.ToString(); i.ToString(); } }
private unsafe static Boolean HexNumberToUInt32(ref NumberBuffer number, ref UInt32 value) { Int32 i = number.scale; if (i > UINT32_PRECISION || i < number.precision) { return false; } Char* p = number.digits; Debug.Assert(p != null, ""); UInt32 n = 0; while (--i >= 0) { if (n > ((UInt32)0xFFFFFFFF / 16)) { return false; } n *= 16; if (*p != '\0') { UInt32 newN = n; if (*p != '\0') { if (*p >= '0' && *p <= '9') { newN += (UInt32)(*p - '0'); } else { if (*p >= 'A' && *p <= 'F') { newN += (UInt32)((*p - 'A') + 10); } else { Debug.Assert(*p >= 'a' && *p <= 'f', ""); newN += (UInt32)((*p - 'a') + 10); } } p++; } // Detect an overflow here... if (newN < n) { return false; } n = newN; } } value = n; return true; }
public void ToString_() { UInt32 testint = new UInt32(); foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) for (int i = 0; i < 10000; i++) { testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); testint.ToString(); } }
private static ulong calculate_master_key(string generator) { UInt32[] table = new UInt32[256]; UInt32 data; UInt32 y; byte x; UInt64 yll; UInt32 yhi; for(int i=0; i<256; i++) { data = (UInt32)i; for(int j=0; j<4; j++) { if ((data & 1) != 0) data = 0xEDBA6320 ^ (data>>1); else data = data>>1; if ((data & 1) != 0) data = 0xEDBA6320 ^ (data>>1); else data = data>>1; } table[i] = data; } y = 0xFFFFFFFF; x = Convert.ToByte(generator[0]); for(int i=0; i<4; i++) { x = (byte)(x ^ y); y = table[x] ^ (y>>8); x = (byte)(Convert.ToByte(generator[1+i*2]) ^ y); y = table[x] ^ (y>>8); x = Convert.ToByte(generator[2+i*2]); } y ^= 0xAAAA; y += 0x1657; yll = (ulong)y; yll = (yll+1) * 0xA7C5AC47ULL; yhi = (uint)(yll>>48); yhi *= 0xFFFFF3CB; y += (uint)(yhi<<5); return y; }
// TODO public static bool PlatformCreatePackages(UInt32 platformId) { Log.Trace("PlatformCreatePackages: Enter"); var dbConn = _dbConn(); var images = Image.GetByPlatformId(dbConn, platformId); if (images == null) { return false; } foreach (var image in images) { Log.Trace("Creating packages descriptor for {0}", image.ImageId.ToString()); image.CreatePackages(dbConn); } Log.Trace("PlatformCreatePackages: OK"); return true; }
public static Int32 MyAcquisitionEventsManagerCallbackInterface( UInt32 OccurredEventCode, Int32 GetFrameErrorCode, UInt32 Eventinfo, IntPtr FramePtr, Int32 FrameSizeX, Int32 FrameSizeY, Double CurrentFrameRate, Double NominalFrameRate, UInt32 GB_Diagnostic, System.IntPtr UserDefinedParameters ) { Byte[] ArrayToPass = null; if (FramePtr != IntPtr.Zero && FrameSizeX > 0 && FrameSizeY > 0) { ArrayToPass = new Byte[FrameSizeX * FrameSizeY]; Marshal.Copy(FramePtr, ArrayToPass, 0, FrameSizeX * FrameSizeY); } else { FrameSizeX = 0; FrameSizeY = 0; ArrayToPass = null; } GC.KeepAlive(GBMSAPI_AcquisitionCallbackInterface.FunctionToBeCalled); if (FunctionToBeCalled != null) { return FunctionToBeCalled(OccurredEventCode, GetFrameErrorCode, Eventinfo, ArrayToPass, FrameSizeX, FrameSizeY, CurrentFrameRate, NominalFrameRate, GB_Diagnostic, UserDefinedParameters ); } else return 1; }
public static int GetProcessArchitecture(UInt32 pid) { IntPtr hProcess = IntPtr.Zero; ProcessAccessFlags flags = ProcessAccessFlags.QueryInformation | ProcessAccessFlags.VMRead; hProcess = OpenProcess(flags, false, (int)pid); if (hProcess == IntPtr.Zero) { throw new System.ComponentModel.Win32Exception(GetLastError()); } try { bool wow64; if (!IsWow64Process(hProcess, out wow64)) { return 32; // call failed means 32-bit } if (wow64) { return 32; } else { return 64; } } finally { CloseHandle(hProcess); } }
private SNILoadHandle() : base(IntPtr.Zero, true) { // From security review - SafeHandle guarantees this is only called once. // The reason for the safehandle is guaranteed initialization and termination of SNI to // ensure SNI terminates and cleans up properly. try { } finally { _sniStatus = SNINativeMethodWrapper.SNIInitialize(); UInt32 value = 0; // VSDevDiv 479597: If initialize fails, don't call QueryInfo. if (TdsEnums.SNI_SUCCESS == _sniStatus) { // Query OS to find out whether encryption is supported. SNINativeMethodWrapper.SNIQueryInfo(SNINativeMethodWrapper.QTypes.SNI_QUERY_CLIENT_ENCRYPT_POSSIBLE, ref value); } _encryptionOption = (value == 0) ? EncryptionOptions.NOT_SUP : EncryptionOptions.OFF; base.handle = (IntPtr)1; // Initialize to non-zero dummy variable. } }
/*DosTime format 32 bits //Year: 7 bits, 0 is ValidZipDate_YearMin, unsigned (ValidZipDate_YearMin = 1980) //Month: 4 bits //Day: 5 bits //Hour: 5 //Minute: 6 bits //Second: 5 bits */ //will silently return InvalidDateIndicator if the UInt32 is not a valid Dos DateTime internal static DateTime DosTimeToDateTime(UInt32 dateTime) { // do the bit shift as unsigned because the fields are unsigned, but // we can safely convert to Int32, because they won't be too big Int32 year = (Int32)(ValidZipDate_YearMin + (dateTime >> 25)); Int32 month = (Int32)((dateTime >> 21) & 0xF); Int32 day = (Int32)((dateTime >> 16) & 0x1F); Int32 hour = (Int32)((dateTime >> 11) & 0x1F); Int32 minute = (Int32)((dateTime >> 5) & 0x3F); Int32 second = (Int32)((dateTime & 0x001F) * 2); // only 5 bits for second, so we only have a granularity of 2 sec. try { return new System.DateTime(year, month, day, hour, minute, second, 0); } catch (ArgumentOutOfRangeException) { return s_invalidDateIndicator; } catch (ArgumentException) { return s_invalidDateIndicator; } }
internal extern static unsafe void glGetNextPerfQueryIdINTEL(UInt32 queryId, UInt32* nextQueryId);
internal extern static unsafe void glXSelectEventSGIX(IntPtr dpy, IntPtr drawable, UInt32 mask);
internal extern static unsafe void glGetPerfCounterInfoINTEL(UInt32 queryId, UInt32 counterId, UInt32 counterNameLength, String counterName, UInt32 counterDescLength, String counterDesc, UInt32* counterOffset, UInt32* counterDataSize, UInt32* counterTypeEnum, UInt32* counterDataTypeEnum, UInt64* rawCounterMaxValue);
internal extern static unsafe void glCreatePerfQueryINTEL(UInt32 queryId, UInt32* queryHandle);
}// tdsLogin private void SSPIData(byte[] receivedBuff, UInt32 receivedLength, byte[] sendBuff, ref UInt32 sendLength) { SNISSPIData(receivedBuff, receivedLength, sendBuff, ref sendLength); }
Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
public virtual extern void RemoveAt([In] UInt32 dwIndex);
public virtual extern HRESULT GetAt([In] UInt32 dwIndex, out PropertyKey pKey);
public virtual extern void GetCount(out UInt32 pcElems);
public static extern IntPtr SetupDiGetClassDevs( ref Guid ClassGuid, [MarshalAs(UnmanagedType.LPTStr)] string Enumerator, IntPtr hwndParent, UInt32 Flags );
internal extern static void glEndPerfQueryINTEL(UInt32 queryHandle);
public static string ToString(UInt32 value) { return value.ToString(null, NumberFormatInfo.InvariantInfo); }
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam);
private void SocketThread(object state) { try { ModDotaHelper.workersactive.AddCount(); // Make a socket communicationSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); communicationSocket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Loopback, 25788)); communicationSocket.Listen(2); byte[] buffer = new byte[256]; // Check if we're shutting down while (ModDotaHelper.closedown.WaitOne(0) == false) { int len = communicationSocket.Receive(buffer); // Message header is 8 bytes long if (len < 8) { continue; } BinaryReader br = new BinaryReader(new MemoryStream(buffer)); UInt32 messagetype = br.ReadUInt32(); UInt32 length = br.ReadUInt32(); if (length != len - 8) continue; switch (messagetype) { case (uint)MessageType.Ping: { byte[] response = new byte[8]; BinaryWriter bw = new BinaryWriter(new MemoryStream(response)); bw.Write((UInt32)MessageType.Pong); bw.Write((UInt32)0); bw.Flush(); communicationSocket.Send(response); break; } case (uint)MessageType.Pong: // Don't really care break; case (uint)MessageType.SubscribeToMod: { // Gotta read this message's header if (length < 6) continue; SubscriptionStatus ss = (SubscriptionStatus)br.ReadUInt32(); UInt16 namelen = br.ReadUInt16(); if (2 * namelen > length - (6 + 8)) continue; string name = new string(br.ReadChars(namelen)); bool installed = ModDotaHelper.modman.GetInstallStatus(name); if (installed) { // it's already installed, don't do anything } else { ModDotaHelper.modman.Install(name); } UInt32 responselength = (UInt32)(6 + 2 * namelen); byte[] response = new byte[8 + responselength]; BinaryWriter bw = new BinaryWriter(new MemoryStream(response)); bw.Write((UInt32)MessageType.SubscriptionStatusChanged); bw.Write(responselength); bw.Write((UInt16)namelen); bw.Write(name.ToCharArray()); communicationSocket.Send(response); break; } case (uint)MessageType.SubscriptionStatusChanged: // we're supposed to be the ones sending this... default: // Unknown message type, return error { string message = "Unknown Message Type "+messagetype.ToString(); UInt32 responselength = (UInt32)(2 + message.Length * 2); byte[] response = new byte[8 + responselength]; BinaryWriter bw = new BinaryWriter(new MemoryStream(response)); bw.Write((UInt32)MessageType.Error); bw.Write(responselength); bw.Write((UInt16)message.Length); bw.Write(message.ToCharArray()); communicationSocket.Send(response); } } } } finally { ModDotaHelper.workersactive.Signal(); } }
private void ValidateResult(void *result, [CallerMemberName] string method = "") { UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As <UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef <byte>(result), (uint)Unsafe.SizeOf <Vector128 <UInt32> >()); ValidateResult(outArray, method); }
internal extern static unsafe void glGetPerfQueryDataINTEL(UInt32 queryHandle, UInt32 flags, Int32 dataSize, void* data, UInt32* bytesWritten);
public Int32u() { mParse = (aText, aStyle) => UInt32.Parse(aText, aStyle); }
private static RawMeshContainer ContainRawMesh(MemoryStream gfs, UInt32 vertCount, UInt32 indCount, UInt32 vertOffset, UInt32 tx0Offset, UInt32 normalOffset, UInt32 colorOffset, UInt32 tx1Offset, UInt32 indOffset, UInt32 vpStride, Vector4 qScale, Vector4 qTrans) { BinaryReader gbr = new BinaryReader(gfs); Vec3[] vertices = new Vec3[vertCount]; uint[] indices = new uint[indCount]; Vec2[] tx0coords = new Vec2[vertCount]; Vec3[] normals = new Vec3[vertCount]; Vec4[] tangents = new Vec4[vertCount]; Vec4[] colors = new Vec4[vertCount]; Vec2[] tx1coords = new Vec2[vertCount]; // geting vertices for (int i = 0; i < vertCount; i++) { gfs.Position = vertOffset + i * vpStride; float x = (gbr.ReadInt16() / 32767f) * qScale.X.Value + qTrans.X.Value; float y = (gbr.ReadInt16() / 32767f) * qScale.Y.Value + qTrans.Y.Value; float z = (gbr.ReadInt16() / 32767f) * qScale.Z.Value + qTrans.Z.Value; vertices[i] = new Vec3(x, y, z); } // got vertices Converters converter = new Converters(); // contains methods for halffloats float[] values = new float[vertCount * 2]; if (tx0Offset != 0) { // getting texturecoord0 as half floats gfs.Position = tx0Offset; for (int i = 0; i < vertCount * 2; i++) { UInt16 read = gbr.ReadUInt16(); values[i] = converter.hfconvert(read); } for (int i = 0; i < vertCount; i++) { tx0coords[i] = new Vec2(values[2 * i], values[2 * i + 1]); } // got texturecoord0 as half floats } UInt32 NorRead32; // getting 10bit normals for (int i = 0; i < vertCount; i++) { gfs.Position = normalOffset + 8 * i; NorRead32 = gbr.ReadUInt32(); Vec4 tempv = converter.U32toVec4(NorRead32); normals[i] = new Vec3(tempv.X, tempv.Y, tempv.Z); } // got 10bit normals // getting 10bit tangents for (int i = 0; i < vertCount; i++) { gfs.Position = normalOffset + 4 + 8 * i; NorRead32 = gbr.ReadUInt32(); Vec4 tempv = converter.U32toVec4(NorRead32); tangents[i] = new Vec4(tempv.X, tempv.Y, tempv.Z, 1f); } if (tx1Offset != 0) { // getting texturecoord1 as half floats gfs.Position = tx1Offset; for (int i = 0; i < vertCount * 2; i++) { UInt16 read = gbr.ReadUInt16(); values[i] = converter.hfconvert(read); } for (int i = 0; i < vertCount; i++) { tx1coords[i] = new Vec2(values[2 * i], values[2 * i + 1]); } // got texturecoord1 as half floats } if (colorOffset != 0) { // getting vert colors, not sure of the format TBH RN,just a hush, may not work, lulz for (int i = 0; i < vertCount; i++) { gfs.Position = colorOffset + i * 8; Vec4 tempv = new Vec4(gbr.ReadUInt16() / 65535f, gbr.ReadUInt16() / 65535f, gbr.ReadUInt16() / 65535f, gbr.ReadUInt16() / 65535f); colors[i] = new Vec4(tempv.Y, tempv.Z, tempv.W, tempv.X); } // got vert colors } // getting uint16 faces/indices gfs.Position = indOffset; for (int i = 0; i < indCount; i++) { indices[i] = gbr.ReadUInt16(); } // got uint16 faces/indices RawMeshContainer mesh = new RawMeshContainer() { vertices = vertices, indices = indices, tx0coords = tx0coords, normals = normals, tangents = tangents, colors = colors, tx1coords = tx1coords }; return(mesh); }
private static extern bool AddPrinterDriver(String pName, UInt32 Level, ref DRIVER_INFO_3 pDriverInfo);
private void btnAdd_Click(object sender, EventArgs e) { string name = txtName.Text.Trim(); string type = cmbValueKind.Text.Trim(); string value = txtValue.Text.Trim(); if (RegistryManager.GetKeyValues(_key).Any(item => item.Name == name)) { MessageBox.Show("این نام استفاده شده است.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (name.Length == 0 || type.Length == 0 || value.Length == 0) { MessageBox.Show("لطفا مقادیر را وارد نمایید", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } RegistryValueKind valueKind; if (!Enum.TryParse(type, out valueKind)) { MessageBox.Show("نوع داده وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } object val = null; switch (valueKind) { case RegistryValueKind.String: case RegistryValueKind.ExpandString: { val = value; } break; case RegistryValueKind.Binary: { char[] bytesList = value.ToCharArray(); foreach (char item in bytesList) { if ((int)item > byte.MaxValue) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } byte[] bytes = bytesList.Select(b => (byte)b).ToArray(); val = bytes; } break; case RegistryValueKind.DWord: { UInt32 v = 0; if (!UInt32.TryParse(value, out v)) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } val = v; } break; case RegistryValueKind.MultiString: { val = value.Replace(';', '\0'); } break; case RegistryValueKind.QWord: { UInt64 v = 0; if (!UInt64.TryParse(value, out v)) { MessageBox.Show("مقدار وارده صحیح نیست.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } val = v; } break; } RegistryManager.EditValue(_key, _valueName, new RegistryValue { Name = name, ValueKind = valueKind, Value = val }); MessageBox.Show("مقدار ویرایش شد.", "ویرایش مقدار", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; }
public PropVariant(uint value) { _valueType = (ushort)VarEnum.VT_UI4; _uint32 = value; }
public static IntPtr CreateGLXPbufferSGIX(IntPtr dpy, IntPtr config, UInt32 width, UInt32 height, int[] attrib_list) { IntPtr retValue; unsafe { fixed(int *p_attrib_list = attrib_list) { Debug.Assert(Delegates.pglXCreateGLXPbufferSGIX != null, "pglXCreateGLXPbufferSGIX not implemented"); retValue = Delegates.pglXCreateGLXPbufferSGIX(dpy, config, width, height, p_attrib_list); LogCommand("glXCreateGLXPbufferSGIX", retValue, dpy, config, width, height, attrib_list); } } DebugCheckErrors(retValue); return(retValue); }
public Elf32() { hash = 0; }
public override void Initialize() { hash = 0; }
private void LoadSSPILibrary() { // Outer check so we don't acquire lock once once it's loaded. if (!s_fSSPILoaded) { lock (s_tdsParserLock) { // re-check inside lock if (!s_fSSPILoaded) { // use local for ref param to defer setting s_maxSSPILength until we know the call succeeded. UInt32 maxLength = 0; if (0 != SNINativeMethodWrapper.SNISecInitPackage(ref maxLength)) SSPIError(SQLMessage.SSPIInitializeError(), TdsEnums.INIT_SSPI_PACKAGE); s_maxSSPILength = maxLength; s_fSSPILoaded = true; } } } if (s_maxSSPILength > Int32.MaxValue) { throw SQL.InvalidSSPIPacketSize(); // SqlBu 332503 } }
internal extern static unsafe IntPtr glXCreateGLXPbufferSGIX(IntPtr dpy, IntPtr config, UInt32 width, UInt32 height, int *attrib_list);
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
private static UInt32 SCardAttrValue(UInt32 attrClass, UInt32 val) { return (attrClass << 16) | val; }
/* parameters to saveCrcAndSizes are * initialPosition (initialPosition in baseBaseStream), * currentPosition (in this CheckSumAndSizeWriteStream), * checkSum (of data passed into this CheckSumAndSizeWriteStream), * baseBaseStream it's a backingStream, passed here so as to avoid closure allocation, * zipArchiveEntry passed here so as to avoid closure allocation, * onClose handler passed here so as to avoid closure allocation */ public CheckSumAndSizeWriteStream(Stream baseStream, Stream baseBaseStream, Boolean leaveOpenOnClose, ZipArchiveEntry entry, EventHandler onClose, Action<Int64, Int64, UInt32, Stream, ZipArchiveEntry, EventHandler> saveCrcAndSizes) { _baseStream = baseStream; _baseBaseStream = baseBaseStream; _position = 0; _checksum = 0; _leaveOpenOnClose = leaveOpenOnClose; _canWrite = true; _isDisposed = false; _initialPosition = 0; _zipArchiveEntry = entry; _onClose = onClose; _saveCrcAndSizes = saveCrcAndSizes; }
private static void VerifyComparison(BigInteger x, UInt32 y, int expectedResult) { bool expectedEquals = 0 == expectedResult; bool expectedLessThan = expectedResult < 0; bool expectedGreaterThan = expectedResult > 0; Assert.Equal(expectedEquals, x == y); Assert.Equal(expectedEquals, y == x); Assert.Equal(!expectedEquals, x != y); Assert.Equal(!expectedEquals, y != x); Assert.Equal(expectedEquals, x.Equals(y)); VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)"); if (expectedEquals) { Assert.Equal(x.GetHashCode(), ((BigInteger)y).GetHashCode()); Assert.Equal(x.ToString(), ((BigInteger)y).ToString()); } Assert.Equal(x.GetHashCode(), x.GetHashCode()); Assert.Equal(((BigInteger)y).GetHashCode(), ((BigInteger)y).GetHashCode()); Assert.Equal(expectedLessThan, x < y); Assert.Equal(expectedGreaterThan, y < x); Assert.Equal(expectedGreaterThan, x > y); Assert.Equal(expectedLessThan, y > x); Assert.Equal(expectedLessThan || expectedEquals, x <= y); Assert.Equal(expectedGreaterThan || expectedEquals, y <= x); Assert.Equal(expectedGreaterThan || expectedEquals, x >= y); Assert.Equal(expectedLessThan || expectedEquals, y >= x); }
/// <summary> /// Logs remoting fragment data to verbose channel. /// </summary> /// <param name="id"></param> /// <param name="opcode"></param> /// <param name="task"></param> /// <param name="keyword"></param> /// <param name="objectId"></param> /// <param name="fragmentId"></param> /// <param name="isStartFragment"></param> /// <param name="isEndFragment"></param> /// <param name="fragmentLength"></param> /// <param name="fragmentData"></param> internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask task, PSKeyword keyword, Int64 objectId, Int64 fragmentId, int isStartFragment, int isEndFragment, UInt32 fragmentLength, PSETWBinaryBlob fragmentData) { if (provider.IsEnabled(PSLevel.Verbose, keyword)) { string payLoadData = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length); payLoadData = string.Format(CultureInfo.InvariantCulture, "0x{0}", payLoadData.Replace("-", "")); provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword, objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength, payLoadData); } }
private void SNISSPIData(byte[] receivedBuff, UInt32 receivedLength, byte[] sendBuff, ref UInt32 sendLength) { if (receivedBuff == null) { // we do not have SSPI data coming from server, so send over 0's for pointer and length receivedLength = 0; } // we need to respond to the server's message with SSPI data if (0 != SNINativeMethodWrapper.SNISecGenClientContext(_physicalStateObj.Handle, receivedBuff, receivedLength, sendBuff, ref sendLength, _sniSpnBuffer)) { SSPIError(SQLMessage.SSPIGenerateError(), TdsEnums.GEN_CLIENT_CONTEXT); } }
internal extern static unsafe void glGetPerfQueryInfoINTEL(UInt32 queryId, UInt32 queryNameLength, String queryName, UInt32* dataSize, UInt32* noCounters, UInt32* noInstances, UInt32* capsMask);
//Initializes new entry internal ZipArchiveEntry(ZipArchive archive, String entryName) { _archive = archive; _originallyInArchive = false; _diskNumberStart = 0; _versionMadeByPlatform = CurrentZipPlatform; _versionMadeBySpecification = ZipVersionNeededValues.Default; _versionToExtract = ZipVersionNeededValues.Default; //this must happen before following two assignment _generalPurposeBitFlag = 0; CompressionMethod = CompressionMethodValues.Deflate; _lastModified = DateTimeOffset.Now; _compressedSize = 0; //we don't know these yet _uncompressedSize = 0; _offsetOfLocalHeader = 0; _storedOffsetOfCompressedData = null; _crc32 = 0; _compressedBytes = null; _storedUncompressedData = null; _currentlyOpenForWrite = false; _everOpenedForWrite = false; _outstandingWriteStream = null; FullName = entryName; _cdUnknownExtraFields = null; _lhUnknownExtraFields = null; _fileComment = null; _compressionLevel = null; if (_storedEntryNameBytes.Length > UInt16.MaxValue) throw new ArgumentException(SR.EntryNamesTooLong); //grab the stream if we're in create mode if (_archive.Mode == ZipArchiveMode.Create) { _archive.AcquireArchiveStream(this); } }
public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer) { return CalculateHash(seed, buffer, 0, buffer.Length); }
public static string ToString(UInt32 value) { return value.ToString(); }
protected override bool DoGenerateMeshes() { meshes = new List <TSOMesh>(); foreach (MqoObject obj in mqo.Objects) { if (obj.name.ToLower() == "bone") { continue; } Console.WriteLine("object:" + obj.name); int object_id = obj.id; obj.CreateNormal(); List <int> faces_1 = new List <int>(); List <int> faces_2 = new List <int>(); Heap <int> bh = new Heap <int>(); Heap <Vertex> vh = new Heap <Vertex>(); Vertex[] refvs = new Vertex[3]; List <ushort> vert_indices = new List <ushort>(); Dictionary <int, bool> adding_bone_indices = new Dictionary <int, bool>(); List <TSOSubMesh> subs = new List <TSOSubMesh>(); for (int i = 0, n = obj.faces.Count; i < n; ++i) { faces_1.Add(i); } #region ボーンパーティション Console.WriteLine(" vertices bone_indices"); Console.WriteLine(" -------- ------------"); while (faces_1.Count != 0) { int spec = obj.faces[faces_1[0]].spec; bh.Clear(); vh.Clear(); vert_indices.Clear(); foreach (int f in faces_1) { MqoFace face = obj.faces[f]; if (face.spec != spec) { faces_2.Add(f); continue; } for (int k = 0; k < 3; ++k) { refvs[k] = new Vertex(); } adding_bone_indices.Clear(); for (int k = 0; k < 3; ++k) { UInt32 idx0 = refvs[k].Idx; Point4 wgt0 = refvs[k].Wgt; byte * idx = (byte *)(&idx0); float *wgt = (float *)(&wgt0); int vertex_id = obj.vertices[face.vert_indices[k]].id; //Console.WriteLine("v.{0} oi:{1} vi:{2}", k, object_id, vertex_id); mqx.UpdateWeits(object_id, vertex_id); for (int l = 0; l < 4; ++l) { idx[l] = (byte)mqx.weits[l].node_id; wgt[l] = mqx.weits[l].weit; //Console.WriteLine(" w.{0} i:{1} w:{2}", l, idx[l], wgt[l]); } refvs[k].Idx = idx0; refvs[k].Wgt = wgt0; for (int l = 0; l < 4; ++l) { if (wgt[l] <= float.Epsilon) { continue; } if (bh.map.ContainsKey(idx[l])) { continue; } adding_bone_indices[idx[l]] = true; } } if (bh.Count + adding_bone_indices.Count > 16) { faces_2.Add(f); continue; } foreach (int i in adding_bone_indices.Keys) { bh.Add(i); } for (int k = 0; k < 3; ++k) { UInt32 idx0 = refvs[k].Idx; Point4 wgt0 = refvs[k].Wgt; byte * idx = (byte *)(&idx0); float *wgt = (float *)(&wgt0); for (int l = 0; l < 4; ++l) { if (wgt[l] <= float.Epsilon) { continue; } idx[l] = (byte)bh[idx[l]]; } refvs[k].Idx = idx0; } Vertex va = new Vertex(obj.vertices[face.a].Pos, refvs[0].Wgt, refvs[0].Idx, obj.vertices[face.a].Nrm, new Point2(face.ta.x, 1 - face.ta.y)); Vertex vb = new Vertex(obj.vertices[face.b].Pos, refvs[1].Wgt, refvs[1].Idx, obj.vertices[face.b].Nrm, new Point2(face.tb.x, 1 - face.tb.y)); Vertex vc = new Vertex(obj.vertices[face.c].Pos, refvs[2].Wgt, refvs[2].Idx, obj.vertices[face.c].Nrm, new Point2(face.tc.x, 1 - face.tc.y)); vert_indices.Add(vh.Add(va)); vert_indices.Add(vh.Add(vc)); vert_indices.Add(vh.Add(vb)); } ushort[] optimized_indices = NvTriStrip.Optimize(vert_indices.ToArray()); TSOSubMesh sub = new TSOSubMesh(); sub.spec = spec; sub.numbones = bh.Count; sub.bones = bh.ary.ToArray(); sub.numvertices = optimized_indices.Length; Vertex[] vertices = new Vertex[optimized_indices.Length]; for (int i = 0; i < optimized_indices.Length; ++i) { vertices[i] = vh.ary[optimized_indices[i]]; } sub.vertices = vertices; Console.WriteLine(" {0,8} {1,12}", sub.vertices.Length, sub.bones.Length); subs.Add(sub); List <int> faces_tmp = faces_1; faces_1 = faces_2; faces_2 = faces_tmp; faces_tmp.Clear(); } #endregion TSOMesh mesh = new TSOMesh(); mesh.name = obj.name; mesh.numsubs = subs.Count; mesh.sub_meshes = subs.ToArray(); mesh.matrix = Matrix44.Identity; mesh.effect = 0; meshes.Add(mesh); } return(true); }
public override void Write(Byte[] buffer, Int32 offset, Int32 count) { //we can't pass the argument checking down a level if (buffer == null) throw new ArgumentNullException("buffer"); if (offset < 0) throw new ArgumentOutOfRangeException("offset", SR.ArgumentNeedNonNegative); if (count < 0) throw new ArgumentOutOfRangeException("count", SR.ArgumentNeedNonNegative); if ((buffer.Length - offset) < count) throw new ArgumentException(SR.OffsetLengthInvalid); Contract.EndContractBlock(); //if we're not actually writing anything, we don't want to trigger as if we did write something ThrowIfDisposed(); Debug.Assert(CanWrite); if (count == 0) return; if (!_everWritten) { _initialPosition = _baseBaseStream.Position; _everWritten = true; } _checksum = Crc32Helper.UpdateCrc32(_checksum, buffer, offset, count); _baseStream.Write(buffer, offset, count); _position += count; }
private static MeshesInfo GetMeshesinfo(CR2WFile cr2w) { int Index = int.MaxValue; for (int i = 0; i < cr2w.Chunks.Count; i++) { if (cr2w.Chunks[i].REDType == "rendRenderMeshBlob") { Index = i; } } int meshC = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos.Count; UInt32[] vertCounts = new UInt32[meshC]; UInt32[] indCounts = new UInt32[meshC]; UInt32[] vertOffsets = new UInt32[meshC]; UInt32[] tx0Offsets = new UInt32[meshC]; UInt32[] normalOffsets = new UInt32[meshC]; UInt32[] colorOffsets = new UInt32[meshC]; UInt32[] tx1Offsets = new UInt32[meshC]; UInt32[] indicesOffsets = new UInt32[meshC]; UInt32[] vpStrides = new UInt32[meshC]; UInt32[] LODLvl = new UInt32[meshC]; for (int i = 0; i < meshC; i++) { vertCounts[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].NumVertices.Value; indCounts[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].NumIndices.Value; vertOffsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.ByteOffsets[0].Value; tx0Offsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.ByteOffsets[1].Value; normalOffsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.ByteOffsets[2].Value; colorOffsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.ByteOffsets[3].Value; tx1Offsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.ByteOffsets[4].Value; if ((cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkIndices.TeOffset == null) { indicesOffsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.IndexBufferOffset.Value; } else { indicesOffsets[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.IndexBufferOffset.Value + (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkIndices.TeOffset.Value; } vpStrides[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].ChunkVertices.VertexLayout.SlotStrides[0].Value; LODLvl[i] = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.RenderChunkInfos[i].LodMask.Value; } Vector4 qScale = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.QuantizationScale; Vector4 qTrans = (cr2w.Chunks[Index].Data as rendRenderMeshBlob).Header.QuantizationOffset; MeshesInfo meshesInfo = new MeshesInfo() { vertCounts = vertCounts, indCounts = indCounts, vertOffsets = vertOffsets, tx0Offsets = tx0Offsets, normalOffsets = normalOffsets, colorOffsets = colorOffsets, tx1Offsets = tx1Offsets, indicesOffsets = indicesOffsets, vpStrides = vpStrides, LODLvl = LODLvl, qScale = qScale, qTrans = qTrans, meshC = meshC }; return(meshesInfo); }
protected override void HashCore(byte[] array, int ibStart, int cbSize) { hash = CalculateHash(hash, array, ibStart, cbSize); }
public static void GetPerfCounterInfoINTEL(UInt32 queryId, UInt32 counterId, UInt32 counterNameLength, String counterName, UInt32 counterDescLength, String counterDesc, [Out] UInt32[] counterOffset, [Out] UInt32[] counterDataSize, [Out] UInt32[] counterTypeEnum, [Out] UInt32[] counterDataTypeEnum, [Out] UInt64[] rawCounterMaxValue) { unsafe { fixed (UInt32* p_counterOffset = counterOffset) fixed (UInt32* p_counterDataSize = counterDataSize) fixed (UInt32* p_counterTypeEnum = counterTypeEnum) fixed (UInt32* p_counterDataTypeEnum = counterDataTypeEnum) fixed (UInt64* p_rawCounterMaxValue = rawCounterMaxValue) { Debug.Assert(Delegates.pglGetPerfCounterInfoINTEL != null, "pglGetPerfCounterInfoINTEL not implemented"); Delegates.pglGetPerfCounterInfoINTEL(queryId, counterId, counterNameLength, counterName, counterDescLength, counterDesc, p_counterOffset, p_counterDataSize, p_counterTypeEnum, p_counterDataTypeEnum, p_rawCounterMaxValue); LogCommand("glGetPerfCounterInfoINTEL", null, queryId, counterId, counterNameLength, counterName, counterDescLength, counterDesc, counterOffset, counterDataSize, counterTypeEnum, counterDataTypeEnum, rawCounterMaxValue ); } } DebugCheckErrors(null); }