/// <summary> /// Initializes the specified descriptor. /// </summary> /// <param name="descriptor">The descriptor.</param> protected void Initialize(KeyEventDescriptor descriptor) { Initialize(descriptor.Base); _key = descriptor.Key; _text = descriptor.Text; }
/// <summary> /// Creates a new pix instance using an existing handle to a pix structure. /// </summary> /// <remarks> /// Note that the resulting instance takes ownership of the data structure. /// </remarks> /// <param name="handle"></param> public Pix(IntPtr handle) { if (handle == IntPtr.Zero) throw new ArgumentNullException("handle"); this.handle = handle; this.width = Interop.LeptonicaApi.GetWidth(handle); this.height = Interop.LeptonicaApi.GetHeight(handle); this.depth = Interop.LeptonicaApi.GetDepth(handle); this.data = Interop.LeptonicaApi.GetData(handle); this.pixelCount = width * height; }
internal static void Initialize(MultibootHeader* pMultibootHeader) { int memoryMapCount = (int)(pMultibootHeader->MemoryMapsSize / sizeof(MultibootMemoryMap)); ulong lastMemoryMapAddress = pMultibootHeader->MemoryMaps[memoryMapCount - 1].AddressLower | ((ulong)pMultibootHeader->MemoryMaps[memoryMapCount - 1].AddressUpper << 32); ulong lastMemoryMapLength = pMultibootHeader->MemoryMaps[memoryMapCount - 1].LengthLower | ((ulong)pMultibootHeader->MemoryMaps[memoryMapCount - 1].LengthUpper << 32); ulong totalMemory = lastMemoryMapAddress + lastMemoryMapLength; if (totalMemory < MinimumTotalMemory) Panic(); ulong totalMemoryHighestBit = 0; int totalMemoryHighestBitShiftOff = 0; for (int bit = 63; bit >= 0; --bit) { ++totalMemoryHighestBitShiftOff; if ((totalMemory & ((ulong)1 << bit)) != 0) { totalMemoryHighestBit = (ulong)1 << bit; break; } } if ((totalMemory << totalMemoryHighestBitShiftOff) != 0) totalMemoryHighestBit <<= 1; int shiftsForTotalMemory = 64 - totalMemoryHighestBitShiftOff; TreeLevels = (byte)((shiftsForTotalMemory - ShiftsForMinimumPageSize) + 1); ulong bytesRequiredForTree = ((ulong)1 << TreeLevels) >> 3; ulong treeStartAddress = pMultibootHeader->Modules[pMultibootHeader->ModulesCount - 1].End; if ((treeStartAddress & 0x03) != 0) treeStartAddress += 4 - (treeStartAddress & 0x03); Tree = (uint*)treeStartAddress; ulong treeElementCount = bytesRequiredForTree >> 2; for (ulong index = 0; index < treeElementCount; ++index) Tree[index] = 0; SetBitsInTree((byte)(TreeLevels - 1), 0, (treeStartAddress + (treeElementCount << 2)) >> ShiftsForMinimumPageSize, true); MultibootMemoryMap* memoryMap = null; ulong memoryMapAddress = 0; ulong memoryMapLength = 0; for (int memoryMapIndex = 0; memoryMapIndex < memoryMapCount; ++memoryMapIndex) { memoryMap = &pMultibootHeader->MemoryMaps[memoryMapIndex]; if (memoryMap->Type != 1) { memoryMapAddress = memoryMap->AddressLower | ((ulong)memoryMap->AddressUpper << 32); memoryMapLength = memoryMap->LengthLower | ((ulong)memoryMap->LengthUpper << 32); SetBitsInTree((byte)(TreeLevels - 1), memoryMapAddress >> ShiftsForMinimumPageSize, memoryMapLength >> ShiftsForMinimumPageSize, true); } } ulong lengthOfOutOfBoundsMemory = totalMemoryHighestBit - totalMemory; if (lengthOfOutOfBoundsMemory > 0) SetBitsInTree((byte)(TreeLevels - 1), totalMemory >> ShiftsForMinimumPageSize, lengthOfOutOfBoundsMemory >> ShiftsForMinimumPageSize, true); }
public static unsafe void glDrawBuffers(int n, uint *bufs) => __GlueDrawBuffers(n, bufs);
public static unsafe void glGetAttachedShaders(uint program, int maxCount, int *count, uint *shaders) => __GlueGetAttachedShaders(program, maxCount, count, shaders);
/// <summary> /// Parse the still image and save to surface /// </summary> private void parseImage() { // Find start of chunk file.BaseStream.Seek(imageOffset, System.IO.SeekOrigin.Begin); // Read in chunk header VDXChunkHeader chunk = readChunkHeader(); if (chunk.BlockType != VDXBlockType.Image) throw new Exception("Invalid chunk type"); System.IO.BinaryReader stream; if (chunk.LengthBits == 0 || chunk.LengthMask == 0) { // Non-compressed stream = file; } else { // Compressed System.IO.MemoryStream tmp; decompress(file, ref chunk, out tmp); stream = new System.IO.BinaryReader(tmp); stream.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); } // Start frame read-in ushort height, width, depth; // Image details width = (ushort)(stream.ReadUInt16() * 4); height = (ushort)(stream.ReadUInt16() * 4); depth = stream.ReadUInt16(); /* // Create surface if (s == null) { // If no surface to continue on from surface = new Surface(width, height, 32, 0xFF << 16, 0xFF << 8, 0xFF, 0xFF << 24); } else { // "Continue" from previous frame surface = new Surface(s); } */ //Position VDX's appopriately (??) if (width == 640) position = new Point(0, 80); else position = new Point(0, 0); // Read in palette for (short k = 0; k < 256; k++) { palette[k] = (uint)((0xff000000) + (stream.ReadByte() * 65536) + (stream.ReadByte() * 256) + stream.ReadByte()); } // Get pixel data unsafe { surfacePtr = (uint*)((byte*)surface.Pixels); } // Begin drawing byte col1, col0; ushort colorMap; for (ushort j = 0; j < height; j += 4) { for (ushort i = 0; i < width; i += 4) { // Read in dithering colors col1 = stream.ReadByte(); col0 = stream.ReadByte(); colorMap = stream.ReadUInt16(); fillTile(i, j, col1, col0, colorMap); } } stream = null; }
/// <summary> /// Apply the salsa20/8 core to the provided block. /// </summary> private unsafe static void Salsa208(uint *B) { uint x0 = B[0]; uint x1 = B[1]; uint x2 = B[2]; uint x3 = B[3]; uint x4 = B[4]; uint x5 = B[5]; uint x6 = B[6]; uint x7 = B[7]; uint x8 = B[8]; uint x9 = B[9]; uint x10 = B[10]; uint x11 = B[11]; uint x12 = B[12]; uint x13 = B[13]; uint x14 = B[14]; uint x15 = B[15]; for (var i = 0; i < 8; i += 2) { //((x0 + x12) << 7) | ((x0 + x12) >> (32 - 7)); /* Operate on columns. */ x4 ^= R(x0 + x12, 7); x8 ^= R(x4 + x0, 9); x12 ^= R(x8 + x4, 13); x0 ^= R(x12 + x8, 18); x9 ^= R(x5 + x1, 7); x13 ^= R(x9 + x5, 9); x1 ^= R(x13 + x9, 13); x5 ^= R(x1 + x13, 18); x14 ^= R(x10 + x6, 7); x2 ^= R(x14 + x10, 9); x6 ^= R(x2 + x14, 13); x10 ^= R(x6 + x2, 18); x3 ^= R(x15 + x11, 7); x7 ^= R(x3 + x15, 9); x11 ^= R(x7 + x3, 13); x15 ^= R(x11 + x7, 18); /* Operate on rows. */ x1 ^= R(x0 + x3, 7); x2 ^= R(x1 + x0, 9); x3 ^= R(x2 + x1, 13); x0 ^= R(x3 + x2, 18); x6 ^= R(x5 + x4, 7); x7 ^= R(x6 + x5, 9); x4 ^= R(x7 + x6, 13); x5 ^= R(x4 + x7, 18); x11 ^= R(x10 + x9, 7); x8 ^= R(x11 + x10, 9); x9 ^= R(x8 + x11, 13); x10 ^= R(x9 + x8, 18); x12 ^= R(x15 + x14, 7); x13 ^= R(x12 + x15, 9); x14 ^= R(x13 + x12, 13); x15 ^= R(x14 + x13, 18); } B[0] += x0; B[1] += x1; B[2] += x2; B[3] += x3; B[4] += x4; B[5] += x5; B[6] += x6; B[7] += x7; B[8] += x8; B[9] += x9; B[10] += x10; B[11] += x11; B[12] += x12; B[13] += x13; B[14] += x14; B[15] += x15; }
public static void Initialize() { Module m = typeof(AntiTamperNormal).Module; string n = m.FullyQualifiedName; bool f = n.Length > 0 && n[0] == '<'; var b = (byte*)Marshal.GetHINSTANCE(m); byte* p = b + *(uint*)(b + 0x3c); ushort s = *(ushort*)(p + 0x6); ushort o = *(ushort*)(p + 0x14); uint* e = null; uint l = 0; var r = (uint*)(p + 0x18 + o); uint z = (uint)Mutation.KeyI1, x = (uint)Mutation.KeyI2, c = (uint)Mutation.KeyI3, v = (uint)Mutation.KeyI4; for (int i = 0; i < s; i++) { uint g = (*r++) * (*r++); if (g == (uint)Mutation.KeyI0) { e = (uint*)(b + (f ? *(r + 3) : *(r + 1))); l = (f ? *(r + 2) : *(r + 0)) >> 2; } else if (g != 0) { var q = (uint*)(b + (f ? *(r + 3) : *(r + 1))); uint j = *(r + 2) >> 2; for (uint k = 0; k < j; k++) { uint t = (z ^ (*q++)) + x + c * v; z = x; x = c; x = v; v = t; } } r += 8; } uint[] y = new uint[0x10], d = new uint[0x10]; for (int i = 0; i < 0x10; i++) { y[i] = v; d[i] = x; z = (x >> 5) | (x << 27); x = (c >> 3) | (c << 29); c = (v >> 7) | (v << 25); v = (z >> 11) | (z << 21); } Mutation.Crypt(y, d); uint h = 0; uint* u = e; VirtualProtect((IntPtr)e, l << 2, 0x40, out z); for (uint i = 0; i < l; i++) { *e ^= y[h & 0xf]; y[h & 0xf] = (y[h & 0xf] ^ (*e++)) + 0x3dbb2819; h++; } ptr = u + 4; len = *ptr++; ver4 = Environment.Version.Major == 4; ModuleHandle hnd = m.ModuleHandle; if (ver4) { ulong* str = stackalloc ulong[1]; str[0] = 0x0061746144705f6d; //m_pData. moduleHnd = (IntPtr)m.GetType().GetField(new string((sbyte*)str), BindingFlags.NonPublic | BindingFlags.Instance).GetValue(m); ver5 = Environment.Version.Revision > 17020; } else moduleHnd = *(IntPtr*)(&hnd); Hook(); }
public LZ4() { _hashtable64K = (ushort*)Marshal.AllocHGlobal(HASH64K_TABLESIZE*sizeof (ushort)).ToPointer(); _hashtable = (uint*)Marshal.AllocHGlobal(HASH_TABLESIZE * sizeof(uint)).ToPointer(); }
[System.Security.SecurityCritical] // auto-generated private static unsafe void MDTransform(uint *blockDWords, uint *state, byte *block) { uint aa = state[0]; uint bb = state[1]; uint cc = state[2]; uint dd = state[3]; uint ee = state[4]; uint aaa = aa; uint bbb = bb; uint ccc = cc; uint ddd = dd; uint eee = ee; DWORDFromLittleEndian(blockDWords, 16, block); /* * As we don't have macros in C# and we don't want to pay the cost of a function call * (which BTW is quite important here as we would have to pass 5 args by ref in * 16 * 10 = 160 function calls) * we'll prefer a less compact code to a less performant code */ // Left Round 1 // FF(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[0], 11); aa += blockDWords[0] + F(bb, cc, dd); aa = (aa << 11 | aa >> (32 - 11)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // FF(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[1], 14); ee += blockDWords[1] + F(aa, bb, cc); ee = (ee << 14 | ee >> (32 - 14)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // FF(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[2], 15); dd += blockDWords[2] + F(ee, aa, bb); dd = (dd << 15 | dd >> (32 - 15)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // FF(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[3], 12); cc += blockDWords[3] + F(dd, ee, aa); cc = (cc << 12 | cc >> (32 - 12)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // FF(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[4], 5); bb += blockDWords[4] + F(cc, dd, ee); bb = (bb << 5 | bb >> (32 - 5)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // FF(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[5], 8); aa += blockDWords[5] + F(bb, cc, dd); aa = (aa << 8 | aa >> (32 - 8)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // FF(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[6], 7); ee += blockDWords[6] + F(aa, bb, cc); ee = (ee << 7 | ee >> (32 - 7)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // FF(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[7], 9); dd += blockDWords[7] + F(ee, aa, bb); dd = (dd << 9 | dd >> (32 - 9)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // FF(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[8], 11); cc += blockDWords[8] + F(dd, ee, aa); cc = (cc << 11 | cc >> (32 - 11)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // FF(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[9], 13); bb += blockDWords[9] + F(cc, dd, ee); bb = (bb << 13 | bb >> (32 - 13)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // FF(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[10], 14); aa += blockDWords[10] + F(bb, cc, dd); aa = (aa << 14 | aa >> (32 - 14)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // FF(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[11], 15); ee += blockDWords[11] + F(aa, bb, cc); ee = (ee << 15 | ee >> (32 - 15)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // FF(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[12], 6); dd += blockDWords[12] + F(ee, aa, bb); dd = (dd << 6 | dd >> (32 - 6)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // FF(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[13], 7); cc += blockDWords[13] + F(dd, ee, aa); cc = (cc << 7 | cc >> (32 - 7)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // FF(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[14], 9); bb += blockDWords[14] + F(cc, dd, ee); bb = (bb << 9 | bb >> (32 - 9)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // FF(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[15], 8); aa += blockDWords[15] + F(bb, cc, dd); aa = (aa << 8 | aa >> (32 - 8)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // Left Round 2 // GG(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[7], 7); ee += G(aa, bb, cc) + blockDWords[7] + 0x5a827999; ee = (ee << 7 | ee >> (32 - 7)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // GG(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[4], 6); dd += G(ee, aa, bb) + blockDWords[4] + 0x5a827999; dd = (dd << 6 | dd >> (32 - 6)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // GG(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[13], 8); cc += G(dd, ee, aa) + blockDWords[13] + 0x5a827999; cc = (cc << 8 | cc >> (32 - 8)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // GG(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[1], 13); bb += G(cc, dd, ee) + blockDWords[1] + 0x5a827999; bb = (bb << 13 | bb >> (32 - 13)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // GG(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[10], 11); aa += G(bb, cc, dd) + blockDWords[10] + 0x5a827999; aa = (aa << 11 | aa >> (32 - 11)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // GG(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[6], 9); ee += G(aa, bb, cc) + blockDWords[6] + 0x5a827999; ee = (ee << 9 | ee >> (32 - 9)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // GG(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[15], 7); dd += G(ee, aa, bb) + blockDWords[15] + 0x5a827999; dd = (dd << 7 | dd >> (32 - 7)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // GG(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[3], 15); cc += G(dd, ee, aa) + blockDWords[3] + 0x5a827999; cc = (cc << 15 | cc >> (32 - 15)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // GG(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[12], 7); bb += G(cc, dd, ee) + blockDWords[12] + 0x5a827999; bb = (bb << 7 | bb >> (32 - 7)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // GG(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[0], 12); aa += G(bb, cc, dd) + blockDWords[0] + 0x5a827999; aa = (aa << 12 | aa >> (32 - 12)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // GG(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[9], 15); ee += G(aa, bb, cc) + blockDWords[9] + 0x5a827999; ee = (ee << 15 | ee >> (32 - 15)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // GG(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[5], 9); dd += G(ee, aa, bb) + blockDWords[5] + 0x5a827999; dd = (dd << 9 | dd >> (32 - 9)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // GG(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[2], 11); cc += G(dd, ee, aa) + blockDWords[2] + 0x5a827999; cc = (cc << 11 | cc >> (32 - 11)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // GG(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[14], 7); bb += G(cc, dd, ee) + blockDWords[14] + 0x5a827999; bb = (bb << 7 | bb >> (32 - 7)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // GG(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[11], 13); aa += G(bb, cc, dd) + blockDWords[11] + 0x5a827999; aa = (aa << 13 | aa >> (32 - 13)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // GG(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[8], 12); ee += G(aa, bb, cc) + blockDWords[8] + 0x5a827999; ee = (ee << 12 | ee >> (32 - 12)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // Left Round 3 // HH(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[3], 11); dd += H(ee, aa, bb) + blockDWords[3] + 0x6ed9eba1; dd = (dd << 11 | dd >> (32 - 11)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // HH(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[10], 13); cc += H(dd, ee, aa) + blockDWords[10] + 0x6ed9eba1; cc = (cc << 13 | cc >> (32 - 13)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // HH(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[14], 6); bb += H(cc, dd, ee) + blockDWords[14] + 0x6ed9eba1; bb = (bb << 6 | bb >> (32 - 6)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // HH(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[4], 7); aa += H(bb, cc, dd) + blockDWords[4] + 0x6ed9eba1; aa = (aa << 7 | aa >> (32 - 7)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // HH(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[9], 14); ee += H(aa, bb, cc) + blockDWords[9] + 0x6ed9eba1; ee = (ee << 14 | ee >> (32 - 14)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // HH(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[15], 9); dd += H(ee, aa, bb) + blockDWords[15] + 0x6ed9eba1; dd = (dd << 9 | dd >> (32 - 9)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // HH(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[8], 13); cc += H(dd, ee, aa) + blockDWords[8] + 0x6ed9eba1; cc = (cc << 13 | cc >> (32 - 13)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // HH(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[1], 15); bb += H(cc, dd, ee) + blockDWords[1] + 0x6ed9eba1; bb = (bb << 15 | bb >> (32 - 15)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // HH(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[2], 14); aa += H(bb, cc, dd) + blockDWords[2] + 0x6ed9eba1; aa = (aa << 14 | aa >> (32 - 14)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // HH(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[7], 8); ee += H(aa, bb, cc) + blockDWords[7] + 0x6ed9eba1; ee = (ee << 8 | ee >> (32 - 8)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // HH(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[0], 13); dd += H(ee, aa, bb) + blockDWords[0] + 0x6ed9eba1; dd = (dd << 13 | dd >> (32 - 13)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // HH(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[6], 6); cc += H(dd, ee, aa) + blockDWords[6] + 0x6ed9eba1; cc = (cc << 6 | cc >> (32 - 6)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // HH(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[13], 5); bb += H(cc, dd, ee) + blockDWords[13] + 0x6ed9eba1; bb = (bb << 5 | bb >> (32 - 5)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // HH(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[11], 12); aa += H(bb, cc, dd) + blockDWords[11] + 0x6ed9eba1; aa = (aa << 12 | aa >> (32 - 12)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // HH(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[5], 7); ee += H(aa, bb, cc) + blockDWords[5] + 0x6ed9eba1; ee = (ee << 7 | ee >> (32 - 7)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // HH(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[12], 5); dd += H(ee, aa, bb) + blockDWords[12] + 0x6ed9eba1; dd = (dd << 5 | dd >> (32 - 5)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // Left Round 4 // II(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[1], 11); cc += I(dd, ee, aa) + blockDWords[1] + 0x8f1bbcdc; cc = (cc << 11 | cc >> (32 - 11)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // II(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[9], 12); bb += I(cc, dd, ee) + blockDWords[9] + 0x8f1bbcdc; bb = (bb << 12 | bb >> (32 - 12)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // II(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[11], 14); aa += I(bb, cc, dd) + blockDWords[11] + 0x8f1bbcdc; aa = (aa << 14 | aa >> (32 - 14)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // II(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[10], 15); ee += I(aa, bb, cc) + blockDWords[10] + 0x8f1bbcdc; ee = (ee << 15 | ee >> (32 - 15)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // II(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[0], 14); dd += I(ee, aa, bb) + blockDWords[0] + 0x8f1bbcdc; dd = (dd << 14 | dd >> (32 - 14)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // II(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[8], 15); cc += I(dd, ee, aa) + blockDWords[8] + 0x8f1bbcdc; cc = (cc << 15 | cc >> (32 - 15)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // II(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[12], 9); bb += I(cc, dd, ee) + blockDWords[12] + 0x8f1bbcdc; bb = (bb << 9 | bb >> (32 - 9)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // II(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[4], 8); aa += I(bb, cc, dd) + blockDWords[4] + 0x8f1bbcdc; aa = (aa << 8 | aa >> (32 - 8)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // II(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[13], 9); ee += I(aa, bb, cc) + blockDWords[13] + 0x8f1bbcdc; ee = (ee << 9 | ee >> (32 - 9)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // II(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[3], 14); dd += I(ee, aa, bb) + blockDWords[3] + 0x8f1bbcdc; dd = (dd << 14 | dd >> (32 - 14)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // II(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[7], 5); cc += I(dd, ee, aa) + blockDWords[7] + 0x8f1bbcdc; cc = (cc << 5 | cc >> (32 - 5)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // II(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[15], 6); bb += I(cc, dd, ee) + blockDWords[15] + 0x8f1bbcdc; bb = (bb << 6 | bb >> (32 - 6)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // II(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[14], 8); aa += I(bb, cc, dd) + blockDWords[14] + 0x8f1bbcdc; aa = (aa << 8 | aa >> (32 - 8)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // II(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[5], 6); ee += I(aa, bb, cc) + blockDWords[5] + 0x8f1bbcdc; ee = (ee << 6 | ee >> (32 - 6)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // II(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[6], 5); dd += I(ee, aa, bb) + blockDWords[6] + 0x8f1bbcdc; dd = (dd << 5 | dd >> (32 - 5)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // II(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[2], 12); cc += I(dd, ee, aa) + blockDWords[2] + 0x8f1bbcdc; cc = (cc << 12 | cc >> (32 - 12)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // Left Round 5 // JJ(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[4], 9); bb += J(cc, dd, ee) + blockDWords[4] + 0xa953fd4e; bb = (bb << 9 | bb >> (32 - 9)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // JJ(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[0], 15); aa += J(bb, cc, dd) + blockDWords[0] + 0xa953fd4e; aa = (aa << 15 | aa >> (32 - 15)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // JJ(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[5], 5); ee += J(aa, bb, cc) + blockDWords[5] + 0xa953fd4e; ee = (ee << 5 | ee >> (32 - 5)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // JJ(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[9], 11); dd += J(ee, aa, bb) + blockDWords[9] + 0xa953fd4e; dd = (dd << 11 | dd >> (32 - 11)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // JJ(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[7], 6); cc += J(dd, ee, aa) + blockDWords[7] + 0xa953fd4e; cc = (cc << 6 | cc >> (32 - 6)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // JJ(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[12], 8); bb += J(cc, dd, ee) + blockDWords[12] + 0xa953fd4e; bb = (bb << 8 | bb >> (32 - 8)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // JJ(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[2], 13); aa += J(bb, cc, dd) + blockDWords[2] + 0xa953fd4e; aa = (aa << 13 | aa >> (32 - 13)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // JJ(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[10], 12); ee += J(aa, bb, cc) + blockDWords[10] + 0xa953fd4e; ee = (ee << 12 | ee >> (32 - 12)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // JJ(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[14], 5); dd += J(ee, aa, bb) + blockDWords[14] + 0xa953fd4e; dd = (dd << 5 | dd >> (32 - 5)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // JJ(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[1], 12); cc += J(dd, ee, aa) + blockDWords[1] + 0xa953fd4e; cc = (cc << 12 | cc >> (32 - 12)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // JJ(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[3], 13); bb += J(cc, dd, ee) + blockDWords[3] + 0xa953fd4e; bb = (bb << 13 | bb >> (32 - 13)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // JJ(ref aa, ref bb, ref cc, ref dd, ref ee, blockDWords[8], 14); aa += J(bb, cc, dd) + blockDWords[8] + 0xa953fd4e; aa = (aa << 14 | aa >> (32 - 14)) + ee; cc = (cc << 10 | cc >> (32 - 10)); // JJ(ref ee, ref aa, ref bb, ref cc, ref dd, blockDWords[11], 11); ee += J(aa, bb, cc) + blockDWords[11] + 0xa953fd4e; ee = (ee << 11 | ee >> (32 - 11)) + dd; bb = (bb << 10 | bb >> (32 - 10)); // JJ(ref dd, ref ee, ref aa, ref bb, ref cc, blockDWords[6], 8); dd += J(ee, aa, bb) + blockDWords[6] + 0xa953fd4e; dd = (dd << 8 | dd >> (32 - 8)) + cc; aa = (aa << 10 | aa >> (32 - 10)); // JJ(ref cc, ref dd, ref ee, ref aa, ref bb, blockDWords[15], 5); cc += J(dd, ee, aa) + blockDWords[15] + 0xa953fd4e; cc = (cc << 5 | cc >> (32 - 5)) + bb; ee = (ee << 10 | ee >> (32 - 10)); // JJ(ref bb, ref cc, ref dd, ref ee, ref aa, blockDWords[13], 6); bb += J(cc, dd, ee) + blockDWords[13] + 0xa953fd4e; bb = (bb << 6 | bb >> (32 - 6)) + aa; dd = (dd << 10 | dd >> (32 - 10)); // Parallel Right Round 1 // JJJ(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[5], 8); aaa += J(bbb, ccc, ddd) + blockDWords[5] + 0x50a28be6; aaa = (aaa << 8 | aaa >> (32 - 8)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // JJJ(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[14], 9); eee += J(aaa, bbb, ccc) + blockDWords[14] + 0x50a28be6; eee = (eee << 9 | eee >> (32 - 9)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // JJJ(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[7], 9); ddd += J(eee, aaa, bbb) + blockDWords[7] + 0x50a28be6; ddd = (ddd << 9 | ddd >> (32 - 9)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // JJJ(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[0], 11); ccc += J(ddd, eee, aaa) + blockDWords[0] + 0x50a28be6; ccc = (ccc << 11 | ccc >> (32 - 11)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // JJJ(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[9], 13); bbb += J(ccc, ddd, eee) + blockDWords[9] + 0x50a28be6; bbb = (bbb << 13 | bbb >> (32 - 13)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // JJJ(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[2], 15); aaa += J(bbb, ccc, ddd) + blockDWords[2] + 0x50a28be6; aaa = (aaa << 15 | aaa >> (32 - 15)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // JJJ(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[11], 15); eee += J(aaa, bbb, ccc) + blockDWords[11] + 0x50a28be6; eee = (eee << 15 | eee >> (32 - 15)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // JJJ(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[4], 5); ddd += J(eee, aaa, bbb) + blockDWords[4] + 0x50a28be6; ddd = (ddd << 5 | ddd >> (32 - 5)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // JJJ(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[13], 7); ccc += J(ddd, eee, aaa) + blockDWords[13] + 0x50a28be6; ccc = (ccc << 7 | ccc >> (32 - 7)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // JJJ(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[6], 7); bbb += J(ccc, ddd, eee) + blockDWords[6] + 0x50a28be6; bbb = (bbb << 7 | bbb >> (32 - 7)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // JJJ(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[15], 8); aaa += J(bbb, ccc, ddd) + blockDWords[15] + 0x50a28be6; aaa = (aaa << 8 | aaa >> (32 - 8)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // JJJ(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[8], 11); eee += J(aaa, bbb, ccc) + blockDWords[8] + 0x50a28be6; eee = (eee << 11 | eee >> (32 - 11)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // JJJ(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[1], 14); ddd += J(eee, aaa, bbb) + blockDWords[1] + 0x50a28be6; ddd = (ddd << 14 | ddd >> (32 - 14)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // JJJ(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[10], 14); ccc += J(ddd, eee, aaa) + blockDWords[10] + 0x50a28be6; ccc = (ccc << 14 | ccc >> (32 - 14)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // JJJ(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[3], 12); bbb += J(ccc, ddd, eee) + blockDWords[3] + 0x50a28be6; bbb = (bbb << 12 | bbb >> (32 - 12)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // JJJ(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[12], 6); aaa += J(bbb, ccc, ddd) + blockDWords[12] + 0x50a28be6; aaa = (aaa << 6 | aaa >> (32 - 6)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // Parallel Right Round 2 // III(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[6], 9); eee += I(aaa, bbb, ccc) + blockDWords[6] + 0x5c4dd124; eee = (eee << 9 | eee >> (32 - 9)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // III(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[11], 13); ddd += I(eee, aaa, bbb) + blockDWords[11] + 0x5c4dd124; ddd = (ddd << 13 | ddd >> (32 - 13)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // III(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[3], 15); ccc += I(ddd, eee, aaa) + blockDWords[3] + 0x5c4dd124; ccc = (ccc << 15 | ccc >> (32 - 15)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // III(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[7], 7); bbb += I(ccc, ddd, eee) + blockDWords[7] + 0x5c4dd124; bbb = (bbb << 7 | bbb >> (32 - 7)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // III(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[0], 12); aaa += I(bbb, ccc, ddd) + blockDWords[0] + 0x5c4dd124; aaa = (aaa << 12 | aaa >> (32 - 12)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // III(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[13], 8); eee += I(aaa, bbb, ccc) + blockDWords[13] + 0x5c4dd124; eee = (eee << 8 | eee >> (32 - 8)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // III(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[5], 9); ddd += I(eee, aaa, bbb) + blockDWords[5] + 0x5c4dd124; ddd = (ddd << 9 | ddd >> (32 - 9)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // III(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[10], 11); ccc += I(ddd, eee, aaa) + blockDWords[10] + 0x5c4dd124; ccc = (ccc << 11 | ccc >> (32 - 11)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // III(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[14], 7); bbb += I(ccc, ddd, eee) + blockDWords[14] + 0x5c4dd124; bbb = (bbb << 7 | bbb >> (32 - 7)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // III(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[15], 7); aaa += I(bbb, ccc, ddd) + blockDWords[15] + 0x5c4dd124; aaa = (aaa << 7 | aaa >> (32 - 7)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // III(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[8], 12); eee += I(aaa, bbb, ccc) + blockDWords[8] + 0x5c4dd124; eee = (eee << 12 | eee >> (32 - 12)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // III(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[12], 7); ddd += I(eee, aaa, bbb) + blockDWords[12] + 0x5c4dd124; ddd = (ddd << 7 | ddd >> (32 - 7)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // III(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[4], 6); ccc += I(ddd, eee, aaa) + blockDWords[4] + 0x5c4dd124; ccc = (ccc << 6 | ccc >> (32 - 6)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // III(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[9], 15); bbb += I(ccc, ddd, eee) + blockDWords[9] + 0x5c4dd124; bbb = (bbb << 15 | bbb >> (32 - 15)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // III(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[1], 13); aaa += I(bbb, ccc, ddd) + blockDWords[1] + 0x5c4dd124; aaa = (aaa << 13 | aaa >> (32 - 13)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // III(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[2], 11); eee += I(aaa, bbb, ccc) + blockDWords[2] + 0x5c4dd124; eee = (eee << 11 | eee >> (32 - 11)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // Parallel Right Round 3 // HHH(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[15], 9); ddd += H(eee, aaa, bbb) + blockDWords[15] + 0x6d703ef3; ddd = (ddd << 9 | ddd >> (32 - 9)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // HHH(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[5], 7); ccc += H(ddd, eee, aaa) + blockDWords[5] + 0x6d703ef3; ccc = (ccc << 7 | ccc >> (32 - 7)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // HHH(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[1], 15); bbb += H(ccc, ddd, eee) + blockDWords[1] + 0x6d703ef3; bbb = (bbb << 15 | bbb >> (32 - 15)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // HHH(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[3], 11); aaa += H(bbb, ccc, ddd) + blockDWords[3] + 0x6d703ef3; aaa = (aaa << 11 | aaa >> (32 - 11)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // HHH(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[7], 8); eee += H(aaa, bbb, ccc) + blockDWords[7] + 0x6d703ef3; eee = (eee << 8 | eee >> (32 - 8)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // HHH(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[14], 6); ddd += H(eee, aaa, bbb) + blockDWords[14] + 0x6d703ef3; ddd = (ddd << 6 | ddd >> (32 - 6)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // HHH(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[6], 6); ccc += H(ddd, eee, aaa) + blockDWords[6] + 0x6d703ef3; ccc = (ccc << 6 | ccc >> (32 - 6)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // HHH(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[9], 14); bbb += H(ccc, ddd, eee) + blockDWords[9] + 0x6d703ef3; bbb = (bbb << 14 | bbb >> (32 - 14)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // HHH(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[11], 12); aaa += H(bbb, ccc, ddd) + blockDWords[11] + 0x6d703ef3; aaa = (aaa << 12 | aaa >> (32 - 12)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // HHH(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[8], 13); eee += H(aaa, bbb, ccc) + blockDWords[8] + 0x6d703ef3; eee = (eee << 13 | eee >> (32 - 13)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // HHH(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[12], 5); ddd += H(eee, aaa, bbb) + blockDWords[12] + 0x6d703ef3; ddd = (ddd << 5 | ddd >> (32 - 5)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // HHH(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[2], 14); ccc += H(ddd, eee, aaa) + blockDWords[2] + 0x6d703ef3; ccc = (ccc << 14 | ccc >> (32 - 14)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // HHH(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[10], 13); bbb += H(ccc, ddd, eee) + blockDWords[10] + 0x6d703ef3; bbb = (bbb << 13 | bbb >> (32 - 13)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // HHH(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[0], 13); aaa += H(bbb, ccc, ddd) + blockDWords[0] + 0x6d703ef3; aaa = (aaa << 13 | aaa >> (32 - 13)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // HHH(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[4], 7); eee += H(aaa, bbb, ccc) + blockDWords[4] + 0x6d703ef3; eee = (eee << 7 | eee >> (32 - 7)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // HHH(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[13], 5); ddd += H(eee, aaa, bbb) + blockDWords[13] + 0x6d703ef3; ddd = (ddd << 5 | ddd >> (32 - 5)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // Parallel Right Round 4 // GGG(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[8], 15); ccc += G(ddd, eee, aaa) + blockDWords[8] + 0x7a6d76e9; ccc = (ccc << 15 | ccc >> (32 - 15)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // GGG(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[6], 5); bbb += G(ccc, ddd, eee) + blockDWords[6] + 0x7a6d76e9; bbb = (bbb << 5 | bbb >> (32 - 5)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // GGG(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[4], 8); aaa += G(bbb, ccc, ddd) + blockDWords[4] + 0x7a6d76e9; aaa = (aaa << 8 | aaa >> (32 - 8)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // GGG(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[1], 11); eee += G(aaa, bbb, ccc) + blockDWords[1] + 0x7a6d76e9; eee = (eee << 11 | eee >> (32 - 11)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // GGG(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[3], 14); ddd += G(eee, aaa, bbb) + blockDWords[3] + 0x7a6d76e9; ddd = (ddd << 14 | ddd >> (32 - 14)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // GGG(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[11], 14); ccc += G(ddd, eee, aaa) + blockDWords[11] + 0x7a6d76e9; ccc = (ccc << 14 | ccc >> (32 - 14)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // GGG(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[15], 6); bbb += G(ccc, ddd, eee) + blockDWords[15] + 0x7a6d76e9; bbb = (bbb << 6 | bbb >> (32 - 6)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // GGG(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[0], 14); aaa += G(bbb, ccc, ddd) + blockDWords[0] + 0x7a6d76e9; aaa = (aaa << 14 | aaa >> (32 - 14)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // GGG(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[5], 6); eee += G(aaa, bbb, ccc) + blockDWords[5] + 0x7a6d76e9; eee = (eee << 6 | eee >> (32 - 6)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // GGG(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[12], 9); ddd += G(eee, aaa, bbb) + blockDWords[12] + 0x7a6d76e9; ddd = (ddd << 9 | ddd >> (32 - 9)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // GGG(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[2], 12); ccc += G(ddd, eee, aaa) + blockDWords[2] + 0x7a6d76e9; ccc = (ccc << 12 | ccc >> (32 - 12)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // GGG(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[13], 9); bbb += G(ccc, ddd, eee) + blockDWords[13] + 0x7a6d76e9; bbb = (bbb << 9 | bbb >> (32 - 9)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // GGG(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[9], 12); aaa += G(bbb, ccc, ddd) + blockDWords[9] + 0x7a6d76e9; aaa = (aaa << 12 | aaa >> (32 - 12)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // GGG(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[7], 5); eee += G(aaa, bbb, ccc) + blockDWords[7] + 0x7a6d76e9; eee = (eee << 5 | eee >> (32 - 5)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // GGG(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[10], 15); ddd += G(eee, aaa, bbb) + blockDWords[10] + 0x7a6d76e9; ddd = (ddd << 15 | ddd >> (32 - 15)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // GGG(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[14], 8); ccc += G(ddd, eee, aaa) + blockDWords[14] + 0x7a6d76e9; ccc = (ccc << 8 | ccc >> (32 - 8)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // Parallel Right Round 5 // FFF(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[12], 8); bbb += F(ccc, ddd, eee) + blockDWords[12]; bbb = (bbb << 8 | bbb >> (32 - 8)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // FFF(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[15], 5); aaa += F(bbb, ccc, ddd) + blockDWords[15]; aaa = (aaa << 5 | aaa >> (32 - 5)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // FFF(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[10], 12); eee += F(aaa, bbb, ccc) + blockDWords[10]; eee = (eee << 12 | eee >> (32 - 12)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // FFF(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[4], 9); ddd += F(eee, aaa, bbb) + blockDWords[4]; ddd = (ddd << 9 | ddd >> (32 - 9)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // FFF(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[1], 12); ccc += F(ddd, eee, aaa) + blockDWords[1]; ccc = (ccc << 12 | ccc >> (32 - 12)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // FFF(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[5], 5); bbb += F(ccc, ddd, eee) + blockDWords[5]; bbb = (bbb << 5 | bbb >> (32 - 5)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // FFF(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[8], 14); aaa += F(bbb, ccc, ddd) + blockDWords[8]; aaa = (aaa << 14 | aaa >> (32 - 14)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // FFF(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[7], 6); eee += F(aaa, bbb, ccc) + blockDWords[7]; eee = (eee << 6 | eee >> (32 - 6)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // FFF(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[6], 8); ddd += F(eee, aaa, bbb) + blockDWords[6]; ddd = (ddd << 8 | ddd >> (32 - 8)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // FFF(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[2], 13); ccc += F(ddd, eee, aaa) + blockDWords[2]; ccc = (ccc << 13 | ccc >> (32 - 13)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // FFF(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[13], 6); bbb += F(ccc, ddd, eee) + blockDWords[13]; bbb = (bbb << 6 | bbb >> (32 - 6)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // FFF(ref aaa, ref bbb, ref ccc, ref ddd, ref eee, blockDWords[14], 5); aaa += F(bbb, ccc, ddd) + blockDWords[14]; aaa = (aaa << 5 | aaa >> (32 - 5)) + eee; ccc = (ccc << 10 | ccc >> (32 - 10)); // FFF(ref eee, ref aaa, ref bbb, ref ccc, ref ddd, blockDWords[0], 15); eee += F(aaa, bbb, ccc) + blockDWords[0]; eee = (eee << 15 | eee >> (32 - 15)) + ddd; bbb = (bbb << 10 | bbb >> (32 - 10)); // FFF(ref ddd, ref eee, ref aaa, ref bbb, ref ccc, blockDWords[3], 13); ddd += F(eee, aaa, bbb) + blockDWords[3]; ddd = (ddd << 13 | ddd >> (32 - 13)) + ccc; aaa = (aaa << 10 | aaa >> (32 - 10)); // FFF(ref ccc, ref ddd, ref eee, ref aaa, ref bbb, blockDWords[9], 11); ccc += F(ddd, eee, aaa) + blockDWords[9]; ccc = (ccc << 11 | ccc >> (32 - 11)) + bbb; eee = (eee << 10 | eee >> (32 - 10)); // FFF(ref bbb, ref ccc, ref ddd, ref eee, ref aaa, blockDWords[11], 11); bbb += F(ccc, ddd, eee) + blockDWords[11]; bbb = (bbb << 11 | bbb >> (32 - 11)) + aaa; ddd = (ddd << 10 | ddd >> (32 - 10)); // Update the state of the hash object ddd += cc + state[1]; state[1] = state[2] + dd + eee; state[2] = state[3] + ee + aaa; state[3] = state[4] + aa + bbb; state[4] = state[0] + bb + ccc; state[0] = ddd; }
public static PageAllocator.Errors Setup(uint totalMem, byte* pagemap, uint pagemapLen, PageAllocator.Errors* error) { if (pagemap == null || pagemapLen < ComputeControlReq(totalMem)) { *error = PageAllocator.Errors.UnusablePageControlBuffer; return *error; } uint totalBytes = totalMem * 1024; // more intuitive to think in bytes than in kibibytes PageDirectory = (uint*)pagemap; PageTables = (uint*)(((byte*)PageDirectory) + 4096); uint addr = 0; uint* table = (uint*)PageTables; // Page directory needs to span all 4 GBs // FIXME: What about PAE support might different implementation // uint totalPages = UInt32.MaxValue / 4096; // Each page spans of memory 4MB uint totalTables = 1024; // 1024 * 4MB = 4GB MemoryUtil.MemSet32(0, (uint)PageDirectory, 1024); for (int x = 0; x < totalTables; ++x) { bool needsDirectoryPresent = false; for (int i = 0; i < 1024; ++i) { uint val = (addr & (uint)PageAttr.FrameMask) | (uint)(PageAttr.ReadWrite); if (addr <= totalBytes) { val |= (uint)PageAttr.Present; needsDirectoryPresent = true; } table[i] = val; addr += 4096; } // top-level page directory (level-1) uint pageAddress = (uint)table & (uint)PageAttr.FrameMask; // Make direcory read/write enabled pageAddress |= (uint)PageAttr.ReadWrite; if (needsDirectoryPresent) { // Make directory present if its point to a physical memory already pageAddress |= (uint)PageAttr.Present; } PageDirectory[x] = pageAddress; table += 1024; // 1024 x sizeof(int) = 4k } DMA.Setup((byte*)((uint)pagemap) + pagemapLen); *error = PageAllocator.Errors.Success; return *error; }
internal static extern unsafe Error GetIPv4Address(byte *socketAddress, int socketAddressLen, uint *address);
internal static extern unsafe Error GetIPv6Address(byte *socketAddress, int socketAddressLen, byte *address, int addressLen, uint *scopeId);
public int Next([NativeTypeName("ULONG")] uint cPins, IPin **ppPins, [NativeTypeName("ULONG *")] uint *pcFetched) { return(((delegate * unmanaged <IEnumPins *, uint, IPin **, uint *, int>)(lpVtbl[3]))((IEnumPins *)Unsafe.AsPointer(ref this), cPins, ppPins, pcFetched)); }
public HRESULT GetStatus([NativeTypeName("DWORD *")] uint *pdwStatus) { return(((delegate * unmanaged <ITfLangBarItemBalloon *, uint *, int>)(lpVtbl[4]))((ITfLangBarItemBalloon *)Unsafe.AsPointer(ref this), pdwStatus)); }
private static unsafe void EncryptECB(int[] key, byte* bytes) { fixed (int* K = &key[0]) fixed (uint* pS1 = &S1_SBox[0], pS2 = &S2_SBox[0], pS3 = &S3_SBox[0], pS4 = &S4_SBox[0]) { uint L = *((uint*)bytes); uint R = *((uint*)(bytes + 4)); S1 = pS1; S2 = pS2; S3 = pS3; S4 = pS4; EncryptBlock(ref L, ref R, (uint*)K); *((uint*)bytes) = L; *((uint*)(bytes + 4)) = R; } }
public int GetPrivateData([NativeTypeName("const GUID &")] Guid *guid, [NativeTypeName("UINT *")] uint *pDataSize, void *pData) { return(((delegate * unmanaged <ID3D11BlendState *, Guid *, uint *, void *, int>)(lpVtbl[4]))((ID3D11BlendState *)Unsafe.AsPointer(ref this), guid, pDataSize, pData)); }
public int GetTransformCount([NativeTypeName("DWORD *")] uint *pdwCount) { return(((delegate * unmanaged <IMFSensorTransformFactory *, uint *, int>)(lpVtbl[5]))((IMFSensorTransformFactory *)Unsafe.AsPointer(ref this), pdwCount)); }
internal static extern unsafe int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, uint *lpReserved, uint *lpType, void *lpData, uint *lpcbData);
public void CopyDescriptors(uint NumDestDescriptorRanges, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE *")] D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, [NativeTypeName("const UINT *")] uint *pDestDescriptorRangeSizes, uint NumSrcDescriptorRanges, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE *")] D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, [NativeTypeName("const UINT *")] uint *pSrcDescriptorRangeSizes, D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType) { ((delegate * unmanaged <ID3D12Device2 *, uint, D3D12_CPU_DESCRIPTOR_HANDLE *, uint *, uint, D3D12_CPU_DESCRIPTOR_HANDLE *, uint *, D3D12_DESCRIPTOR_HEAP_TYPE, void>)(lpVtbl[23]))((ID3D12Device2 *)Unsafe.AsPointer(ref this), NumDestDescriptorRanges, pDestDescriptorRangeStarts, pDestDescriptorRangeSizes, NumSrcDescriptorRanges, pSrcDescriptorRangeStarts, pSrcDescriptorRangeSizes, DescriptorHeapsType); }
public UHCI(PCI.PCIDeviceNormal aPCIDevice) : base(aPCIDevice) { #if UHCI_TRACE BasicConsole.WriteLine("UHCI: Constructor"); BasicConsole.DelayOutput(5); #endif usbBaseAddress = pciDevice.BaseAddresses[4].BaseAddress(); Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage( (uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000); VirtMemManager.Map((uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000, 4096, VirtMem.VirtMemImpl.PageFlags.KernelOnly); RootPortCount = UHCI_Consts.PORTMAX; EnabledPorts = false; USBCMD = new IO.IOPort(MapPort(UHCI_Consts.USBCMD)); USBINTR = new IO.IOPort(MapPort(UHCI_Consts.USBINTR)); USBSTS = new IO.IOPort(MapPort(UHCI_Consts.USBSTS)); SOFMOD = new IO.IOPort(MapPort(UHCI_Consts.SOFMOD)); FRBASEADD = new IO.IOPort(MapPort(UHCI_Consts.FRBASEADD)); FRNUM = new IO.IOPort(MapPort(UHCI_Consts.FRNUM)); PORTSC1 = new IO.IOPort(MapPort(UHCI_Consts.PORTSC1)); PORTSC2 = new IO.IOPort(MapPort(UHCI_Consts.PORTSC2)); FrameList = (uint*)VirtMemManager.MapFreePage(VirtMem.VirtMemImpl.PageFlags.KernelOnly); Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage( (uint)FrameList & 0xFFFFF000, (uint)FrameList & 0xFFFFF000); Start(); }
public void GetCopyableFootprints([NativeTypeName("const D3D12_RESOURCE_DESC *")] D3D12_RESOURCE_DESC *pResourceDesc, uint FirstSubresource, uint NumSubresources, [NativeTypeName("UINT64")] ulong BaseOffset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, uint *pNumRows, [NativeTypeName("UINT64 *")] ulong *pRowSizeInBytes, [NativeTypeName("UINT64 *")] ulong *pTotalBytes) { ((delegate * unmanaged <ID3D12Device2 *, D3D12_RESOURCE_DESC *, uint, uint, ulong, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *, uint *, ulong *, ulong *, void>)(lpVtbl[38]))((ID3D12Device2 *)Unsafe.AsPointer(ref this), pResourceDesc, FirstSubresource, NumSubresources, BaseOffset, pLayouts, pNumRows, pRowSizeInBytes, pTotalBytes); }
private static unsafe long EncryptCBC(int[] key, byte* bytes, int blockCount, long iv) { fixed (int* K = &key[0]) fixed (uint* pS1 = &S1_SBox[0], pS2 = &S2_SBox[0], pS3 = &S3_SBox[0], pS4 = &S4_SBox[0]) { uint L = (uint)((ulong)iv); uint R = (uint)((ulong)iv >> 32); S1 = pS1; S2 = pS2; S3 = pS3; S4 = pS4; do { L ^= *((uint*)bytes); R ^= *((uint*)(bytes + 4)); EncryptBlock(ref L, ref R, (uint*)K); *((uint*)bytes) = L; *((uint*)(bytes + 4)) = R; bytes += 8; } while (--blockCount != 0); return (long)(((ulong)R << 32) | L); } }
public void GetResourceTiling(ID3D12Resource *pTiledResource, uint *pNumTilesForEntireResource, D3D12_PACKED_MIP_INFO *pPackedMipDesc, D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, uint *pNumSubresourceTilings, uint FirstSubresourceTilingToGet, D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips) { ((delegate * unmanaged <ID3D12Device2 *, ID3D12Resource *, uint *, D3D12_PACKED_MIP_INFO *, D3D12_TILE_SHAPE *, uint *, uint, D3D12_SUBRESOURCE_TILING *, void>)(lpVtbl[42]))((ID3D12Device2 *)Unsafe.AsPointer(ref this), pTiledResource, pNumTilesForEntireResource, pPackedMipDesc, pStandardTileShapeForNonPackedMips, pNumSubresourceTilings, FirstSubresourceTilingToGet, pSubresourceTilingsForNonPackedMips); }
/// <summary> /// Konstruktor /// </summary> public SokowahnHash() { #if multiHash hashes = new Dictionary<ulong, ushort>[hashesAnzahl]; for (int i = 0; i < hashes.Length; i++) hashes[i] = new Dictionary<ulong, ushort>(); #else hash = new Dictionary<ulong, ushort>(); #endif #if Index16 archivIndexPointer = Marshal.AllocHGlobal((1 << 16) * 2 * 4); if (archivIndexPointer == IntPtr.Zero) throw new Exception("Speicher konnte nicht reserviert werden (" + (((1 << 16) * 2 * 4) / 1048576L) + " MB)"); archivIndex = (uint*)archivIndexPointer.ToPointer(); for (int i = 0; i < (1 << 16) * 2; i++) archivIndex[i] = 0; #endif #if Index24 archivIndexPointer = Marshal.AllocHGlobal((1 << 24) * 2 * 4); if (archivIndexPointer == IntPtr.Zero) throw new Exception("Speicher konnte nicht reserviert werden (" + (((1 << 24) * 2 * 4) / 1048576L) + " MB)"); archivIndex = (uint*)archivIndexPointer.ToPointer(); for (int i = 0; i < (1 << 24) * 2; i++) archivIndex[i] = 0; #endif }
public HRESULT GetPrivateData([NativeTypeName("const GUID &")] Guid *guid, uint *pDataSize, void *pData) { return(((delegate * unmanaged <ID3D12Device2 *, Guid *, uint *, void *, int>)(lpVtbl[3]))((ID3D12Device2 *)Unsafe.AsPointer(ref this), guid, pDataSize, pData)); }
protected static extern unsafe bool ReadFile( SafeFileHandle hFile, byte *pBuffer, uint NumberOfBytesToRead, uint *pNumberOfBytesRead, IntPtr Overlapped);
public int GetCount([NativeTypeName("ULONG *")] uint *pcCount) { return(((delegate * unmanaged <IMFSensorActivitiesReport *, uint *, int>)(lpVtbl[3]))((IMFSensorActivitiesReport *)Unsafe.AsPointer(ref this), pcCount)); }
/// <summary> /// Return the result of parsing B_{2r-1} as a little-endian integer. /// </summary> private unsafe static long Integerify(uint *B, int r) { var X = (uint *)(((byte *)B) + (2 * r - 1) * 64); return(((long)(X[1]) << 32) + X[0]); }
public HRESULT GetMaxFrameCountForCategory(AUDIO_STREAM_CATEGORY category, BOOL offloadEnabled, [NativeTypeName("const WAVEFORMATEX *")] WAVEFORMATEX *objectFormat, [NativeTypeName("UINT32 *")] uint *frameCountPerBuffer) { return(((delegate * unmanaged <ISpatialAudioClient2 *, AUDIO_STREAM_CATEGORY, BOOL, WAVEFORMATEX *, uint *, int>)(lpVtbl[12]))((ISpatialAudioClient2 *)Unsafe.AsPointer(ref this), category, offloadEnabled, objectFormat, frameCountPerBuffer)); }
public static unsafe void glGetActiveUniform(uint program, uint index, int maxLength, int *length, int *size, uint *type, char *name) => __GlueGetActiveUniform(program, index, maxLength, length, size, type, name);
public HRESULT GetMaxDynamicObjectCount([NativeTypeName("UINT32 *")] uint *value) { return(((delegate * unmanaged <ISpatialAudioClient2 *, uint *, int>)(lpVtbl[5]))((ISpatialAudioClient2 *)Unsafe.AsPointer(ref this), value)); }
public static unsafe void glVertexAttrib4uiv(uint index, uint *v) => __GlueVertexAttrib4uiv(index, v);
public HRESULT GetMaxFrameCount([NativeTypeName("const WAVEFORMATEX *")] WAVEFORMATEX *objectFormat, [NativeTypeName("UINT32 *")] uint *frameCountPerBuffer) { return(((delegate * unmanaged <ISpatialAudioClient2 *, WAVEFORMATEX *, uint *, int>)(lpVtbl[7]))((ISpatialAudioClient2 *)Unsafe.AsPointer(ref this), objectFormat, frameCountPerBuffer)); }
/// <summary> /// Creates a new CudaRegisteredHostMemory_uint from an existing IntPtr. IntPtr must be page size aligned (4KBytes)! /// </summary> /// <param name="hostPointer">must be page size aligned (4KBytes)</param> /// <param name="size">In elements</param> public CudaRegisteredHostMemory_uint(IntPtr hostPointer, SizeT size) { _intPtr = hostPointer; _size = size; _typeSize = (SizeT)Marshal.SizeOf(typeof(uint)); _ptr = (uint*)_intPtr; }
public static void Sort(uint *keys, uint *workspace, int length, int r = DEFAULT_R, bool descending = false, uint mask = uint.MaxValue) => Sort32(keys, workspace, length, r, mask, !descending, NumberSystem.Unsigned);
/// <summary> /// 随机数 /// </summary> private RandomPlus() { _secureSeeds = unmanaged.Get(64 * sizeof(uint) + 5 * 11 * sizeof(uint), false).UInt; _seeds = _secureSeeds + 64; _current64 = 5 * 11 - 2; var tick = (ulong)PubPlus.StartTime.Ticks ^ (ulong)Environment.TickCount ^ ((ulong)PubPlus.Identity32 << 8) ^ ((ulong)date.NowTimerInterval << 24); var isSeedArray = 0; var seedField = typeof(Random).GetField("SeedArray", BindingFlags.Instance | BindingFlags.NonPublic); if (seedField != null) { var seedArray = seedField.GetValue(new Random()) as int[]; if (seedArray != null && seedArray.Length == 5 * 11 + 1) { tick *= 0xb163dUL; fixed (int* seedFixed = seedArray) { for (uint* write = _seeds, end = _seeds + 5 * 11, read = (uint*)seedFixed; write != end; tick >>= 1) { *write++ = *++read ^ (((uint)tick & 1U) << 31); } } isSeedArray = 1; } } if (isSeedArray == 0) { LogPlus.Default.Add("系统随机数种子获取失败"); for (uint* start = _seeds, end = start + 5 * 11; start != end; ++start) { *start = (uint)tick ^ (uint)(tick >> 32); tick *= 0xb163dUL; tick += tick >> 32; } } for (var start = (ulong*)_secureSeeds; start != _seeds; *start++ = NextULong()) { } _bits = (uint)Next(); _bitCount = 32; }
static MsQuicApi() { if (OperatingSystem.IsWindows()) { if (!IsWindowsVersionSupported()) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Info(null, $"Current Windows version ({Environment.OSVersion}) is not supported by QUIC. Minimal supported version is {MinWindowsVersion}"); } return; } Tls13ServerMayBeDisabled = IsTls13Disabled(true); Tls13ClientMayBeDisabled = IsTls13Disabled(false); } IntPtr msQuicHandle; if (NativeLibrary.TryLoad($"{Interop.Libraries.MsQuic}.{MsQuicVersion.Major}", typeof(MsQuicApi).Assembly, DllImportSearchPath.AssemblyDirectory, out msQuicHandle) || NativeLibrary.TryLoad(Interop.Libraries.MsQuic, typeof(MsQuicApi).Assembly, DllImportSearchPath.AssemblyDirectory, out msQuicHandle)) { try { if (NativeLibrary.TryGetExport(msQuicHandle, "MsQuicOpenVersion", out IntPtr msQuicOpenVersionAddress)) { QUIC_API_TABLE *apiTable; delegate * unmanaged[Cdecl] < uint, QUIC_API_TABLE **, int > msQuicOpenVersion = (delegate * unmanaged[Cdecl] < uint, QUIC_API_TABLE **, int >)msQuicOpenVersionAddress; if (StatusSucceeded(msQuicOpenVersion((uint)MsQuicVersion.Major, &apiTable))) { int arraySize = 4; uint *libVersion = stackalloc uint[arraySize]; uint size = (uint)arraySize * sizeof(uint); if (StatusSucceeded(apiTable->GetParam(null, QUIC_PARAM_GLOBAL_LIBRARY_VERSION, &size, libVersion))) { var version = new Version((int)libVersion[0], (int)libVersion[1], (int)libVersion[2], (int)libVersion[3]); if (version >= MsQuicVersion) { Api = new MsQuicApi(apiTable); IsQuicSupported = true; } else { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Info(null, $"Incompatible MsQuic library version '{version}', expecting '{MsQuicVersion}'"); } } } } } } finally { if (!IsQuicSupported) { NativeLibrary.Free(msQuicHandle); } } } }
public unsafe GdiVideo(Panel panel) { _panel = panel; _bitmapData = _bitmap.LockBits(_bitmapRect, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppRgb); _bitmapPtr = (uint*)_bitmapData.Scan0.ToPointer(); _bitmap.UnlockBits(_bitmapData); for (int i = Video.VIC.X_RESOLUTION * Video.VIC.Y_RESOLUTION - 1; i >= 0; i--) { _bitmapPtr[i] = 0xffffff; } for (int i = 0; i < Video.Pallete.CvtColors.Length; i++) { byte[] c = Video.Pallete.Colors[i]; Video.Pallete.CvtColors[i] = (uint)((c[0] << 16) | (c[1] << 8) | c[2]); } }
private static uint _gpioSetup; // bitfield for setup gpios (setup = out/low) public bool Initialize(int incrementUs) { pulseWidthIncrementUs = incrementUs; // Initialize common stuff _pwmReg = MapPeripheral(PWM_BASE, PWM_LEN); _pcmReg = MapPeripheral(PCM_BASE, PCM_LEN); _clkReg = MapPeripheral(CLK_BASE, CLK_LEN); _gpioReg = MapPeripheral(GPIO_BASE, GPIO_LEN); if (_pwmReg == null || _pcmReg == null || _clkReg == null || _gpioReg == null) { Console.WriteLine("PWM: Failed to map peripherals"); return false; } // Initialise PWM _pwmReg[PWM_CTL] = 0; Thread.Sleep(TimeSpan.FromMilliseconds(0.01)); _clkReg[PWMCLK_CNTL] = 0x5A000006; // Source=PLLD (500MHz) Thread.Sleep(TimeSpan.FromMilliseconds(0.1)); _clkReg[PWMCLK_DIV] = 0x5A000000 | (50 << 12); // set pwm div to 50, giving 10MHz Thread.Sleep(TimeSpan.FromMilliseconds(0.1)); _clkReg[PWMCLK_CNTL] = 0x5A000016; // Source=PLLD and enable Thread.Sleep(TimeSpan.FromMilliseconds(0.1)); _pwmReg[PWM_RNG1] = (uint)incrementUs * 10; Thread.Sleep(TimeSpan.FromMilliseconds(0.01)); _pwmReg[PWM_DMAC] = PWMDMAC_ENAB | PWMDMAC_THRSHLD; Thread.Sleep(TimeSpan.FromMilliseconds(0.01)); _pwmReg[PWM_CTL] = PWMCTL_CLRF; Thread.Sleep(TimeSpan.FromMilliseconds(0.01)); _pwmReg[PWM_CTL] = PWMCTL_USEF1 | PWMCTL_PWEN1; Thread.Sleep(TimeSpan.FromMilliseconds(0.01)); return true; }
/// <summary> /// Initialises a new EHCI device using the specified PCI device. Includes starting the host controller. /// </summary> /// <param name="aPCIDevice">The PCI device that represents the physical EHCI device.</param> public EHCI(PCI.PCIDeviceNormal aPCIDevice) : base(aPCIDevice) { #if EHCI_TESTS try { EHCITesting.Test_PointerManipulation(); EHCITesting.Test_StructValueSetting(); EHCITesting.Test_QueueHeadWrapper(); EHCITesting.Test_qTDWrapper(); } catch { BasicConsole.SetTextColour(BasicConsole.warning_colour); BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message); BasicConsole.SetTextColour(BasicConsole.default_colour); } #endif // The USB Base Address is the physical address of the memory mapped registers // used to control the host controller. It is a Memory Space BAR. // The BAR to use is BAR0. // Section 2.1.3 of the Intel EHCI Spec usbBaseAddress = pciDevice.BaseAddresses[0].BaseAddress(); #if EHCI_TRACE BasicConsole.WriteLine(((FOS_System.String)"EHCI: usbBaseAddress=") + (uint)usbBaseAddress); #endif // Map in the required memory - we will use identity mapping for the PCI / USB registers for now Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage( (uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000); VirtMemManager.Map((uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000, 4096, VirtMem.VirtMemImpl.PageFlags.KernelOnly); // Caps registers start at the beginning of the memory mapped IO registers. // Section 2 of the Intel EHCI Spec CapabilitiesRegAddr = usbBaseAddress; #if EHCI_TRACE DBGMSG("CapabilitiesRegAddr: " + (FOS_System.String)(uint)CapabilitiesRegAddr); #endif // Read the Serial Bus Release Number // This is an 8-bit register where 0xXY means Revision X.Y // e.g. 0x20 means Revision 2.0 // Section 2.1.4 of the Intel EHCI Spec SBRN = pciDevice.ReadRegister8(0x60); #if EHCI_TRACE DBGMSG("SBRN: " + (FOS_System.String)SBRN); #endif // The first register of the Capabilities Registers tells you the length // of the registers (in bytes). This provides the offset from the start of // the capabilities registers to the start of the Operational registers. CapabilitiesRegsLength = *CapabilitiesRegAddr; // BCD encoding of the HC Interface version supported by this host controller. // Most Significant Byte is major version // Least Significant Byte is minor version // e.g. 0x20 = Version 2.0 HCIVersion = *((UInt16*)(CapabilitiesRegAddr + 2)); // Host Controller Structural Params // Section 2.2.3 of the Intel EHCI Spec // This register contains various bit fields providing specific information // about the HC hardware / firmware physical design (e.g. number of root ports) HCSParams = *((UInt32*)(CapabilitiesRegAddr + 4)); // Host Controller Capability Params // Section 2.2.4 of the Intel EHCI Spec // This register contains various bit fields providing specific information // about the HC hardware / firmware capabilities (e.g. 64-bit addressing capaiblity) HCCParams = *((UInt32*)(CapabilitiesRegAddr + 8)); // Operational registers address. Calculated as stated above from: // USB Base Address + Length of Capabilities registers. // Section 2.3 of the Intel EHCI Spec OpRegAddr = (uint*)(usbBaseAddress + CapabilitiesRegsLength); #if EHCI_TRACE DBGMSG("CapabilitiesRegsLength: " + (FOS_System.String)CapabilitiesRegsLength); DBGMSG("HCIVersion: " + (FOS_System.String)HCIVersion); DBGMSG("HCSParams: " + (FOS_System.String)HCSParams); DBGMSG("HCCParams: " + (FOS_System.String)HCCParams); //DBGMSG("HCSPPortRouteDesc: " + (FOS_System.String)HCSPPortRouteDesc); DBGMSG("OpRegAddr: " + (FOS_System.String)(uint)OpRegAddr); #endif // Number of root ports // Section 2.2.3 of Intel EHCI Spec RootPortCount = (byte)(HCSParams & 0x000F); // Start the host controller Start(); }
static GPIO () { string CpuInfo; try { CpuInfo = System.IO.File.ReadAllText("/proc/cpuinfo"); } catch (Exception) { throw new Exception ("Unable to get access to /proc/cpuinfo. To determine how to access GPIO, the application "+ "needs to know of what platform it runs. To get access to this file, the application needs to have " + "superior access privileges. You can get such privileges by executing the application using the sudo command."); } platform = Platform.Unknown; foreach (string Row in CpuInfo.Split(new char[]{'\r','\n'},StringSplitOptions.RemoveEmptyEntries)) { if (Row.StartsWith ("Hardware")) { int i = Row.IndexOf (':'); if (i > 0) { if (Row.IndexOf ("BCM2708", i) > 0 || Row.IndexOf ("BCM2835", i) > 0) { platform = Platform.RaspberryPi; break; } else if (Row.IndexOf ("BCM2709", i) > 0 || Row.IndexOf ("BCM2836", i) > 0) { platform = Platform.RaspberryPi2; break; } else throw new Exception ("Unsupported platform: " + Row.Substring (i + 1).Trim ()); } break; } } if (platform == Platform.Unknown) throw new Exception ("Could not determine what hardware platform is being used."); uint Base; switch (platform) { case Platform.RaspberryPi: Base = 0x20000000 + 0x200000; // BCM2708/BCM2835 base address + GPIO offset. break; case Platform.RaspberryPi2: Base = 0x3f000000 + 0x200000; // BCM2709/BCM2836 base address + GPIO offset. break; default: throw new Exception ("Unsupported platform: " + platform.ToString()); } memoryFileHandler = open ("/dev/mem", O_RDWR | O_SYNC); if (memoryFileHandler < 0) { throw new Exception ("Unable to get access to /dev/mem. Access to GPIO is done through direct access to memory, " + "which is provided through the system file /dev/mem. To get access to this file, the application needs to have " + "superior access privileges. You can get such privileges by executing the application using the sudo command."); } gpio = MapMemory (Base, ref memoryBlockGpio, ref memoryPageGpio, ref memoryMapGpio); ticksPerSecond = Stopwatch.Frequency; }
public int GetIids([NativeTypeName("ULONG *")] uint *iidCount, [NativeTypeName("IID **")] Guid **iids) { return(((delegate * unmanaged <IUserActivitySourceHostInterop *, uint *, Guid **, int>)(lpVtbl[3]))((IUserActivitySourceHostInterop *)Unsafe.AsPointer(ref this), iidCount, iids)); }
public static unsafe long GetOrdinaryIV(int[] key) { fixed (int* K = &key[0]) fixed (uint* pS1 = &S1_SBox[0], pS2 = &S2_SBox[0], pS3 = &S3_SBox[0], pS4 = &S4_SBox[0]) { uint L = 0; uint R = 0; S1 = pS1; S2 = pS2; S3 = pS3; S4 = pS4; EncryptBlock(ref L, ref R, (uint*)K); return (long)(((ulong)R << 32) | L); } }
public HRESULT GetTypeInfoCount(uint *pctinfo) { return(((delegate * unmanaged <DispDOMMSAnimationEvent *, uint *, int>)(lpVtbl[3]))((DispDOMMSAnimationEvent *)Unsafe.AsPointer(ref this), pctinfo)); }
public HRESULT Invoke([NativeTypeName("DISPID")] int dispIdMember, [NativeTypeName("const IID &")] Guid *riid, [NativeTypeName("LCID")] uint lcid, [NativeTypeName("WORD")] ushort wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, uint *puArgErr) { return(((delegate * unmanaged <DispDOMMSAnimationEvent *, int, Guid *, uint, ushort, DISPPARAMS *, VARIANT *, EXCEPINFO *, uint *, int>)(lpVtbl[6]))((DispDOMMSAnimationEvent *)Unsafe.AsPointer(ref this), dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr)); }
private static unsafe uint* AllocateMemory(uint size) { free = free + size; return free; }
public unsafe partial void CreateSemaphores([Flow(FlowDirection.In)] uint n, [Count(Parameter = "n"), Flow(FlowDirection.Out)] uint *semaphores);
internal static void Initialize() { /* open /dev/mem */ if ((mem_fd = Libc.open("/dev/mem", Libc.O_RDWR | Libc.O_SYNC)) < 0) { throw new Exception("can't open /dev/mem"); } /* mmap GPIO */ // Allocate MAP block if ((gpio_mem = Libc.malloc(BLOCK_SIZE + (PAGE_SIZE - 1))) == NULL) { throw new Exception("allocation error"); } // Make sure pointer is on 4K boundary if ((ulong)gpio_mem % PAGE_SIZE != 0) gpio_mem += PAGE_SIZE - ((ulong)gpio_mem % PAGE_SIZE); // Now map it gpio_map = (byte*)Libc.mmap( gpio_mem, BLOCK_SIZE, Libc.PROT_READ | Libc.PROT_WRITE, Libc.MAP_SHARED | Libc.MAP_FIXED, mem_fd, GPIO_BASE ); if ((long)gpio_map < 0) { throw new Exception(String.Format("mmap error {0}", (int)gpio_map)); } // Always use volatile pointer! gpio = (uint*)gpio_map; }
protected static extern unsafe bool WriteFile( SafeFileHandle hFile, byte *pBuffer, uint NumberOfBytesToWrite, uint *pNumberOfBytesWritten, IntPtr Overlapped);
/// <summary> /// Initializes page management and paging. Using <see cref="Alloc" /> /// and related management functions before calling this function results /// in a kernel panic. After this function is called, the /// <see cref="ReservePage"/> and <see cref="ReservePageRange" /> /// functions can be used to reserve memory that should not be allocated. /// You should ensure that no memory allocations have happened between /// calling this function and reserving memory. /// </summary> public static void Setup (byte* kernelOffset, uint _kernelSize, uint totalKbMem) { PagingMemoryRequirements* pagingMemory = stackalloc PagingMemoryRequirements[1]; // The total memory in bytes totalMem = totalKbMem * 1024; // Total pages totalPages = totalMem / Pager.AtomicPageSize; // First page of the kernel kernelStartPage = (byte*)PtrToPage (kernelOffset); // Kernel size in pages kernelSize = (_kernelSize / Pager.AtomicPageSize) + 1; // Allocate the free page stack immediately after end of the kernel fpStack = (uint*)(kernelStartPage + (kernelSize * Pager.AtomicPageSize)); // Initalize the stack pointer fpStackPointer = 0; // Free page stack size in pages fpStackSize = (totalPages * (uint)sizeof (uint*) / Pager.AtomicPageSize) + 1; // Allocate the reserved page stack immediately after free page stack rpStack = (ReservedPages*)((uint)fpStack + (fpStackSize * Pager.AtomicPageSize)); // Initalize the reserve stack pointer rpStackPointer = 0; // Reserve stack size in pages rpStackSize = 1; // fixed - should be enough // Allocate paging information pagingData = (byte*)(rpStack + (rpStackSize * Pager.AtomicPageSize)); pagingMemory->Start = (void*)pagingData; // Reserve 4 mega bytes of memory for Virtual memory manager // FIXME: pagingDataSize = (4 * 1024 * 1024) / 4096; // Reserve the memory ranges we're using. ReservePageRange (kernelStartPage, kernelSize, "kernel"); ReservePageRange (fpStack, fpStackSize, "fpstack"); ReservePageRange (rpStack, rpStackSize, "rpstack"); ReservePageRange (pagingData, pagingDataSize, "paging"); // Reserve memory below 0x100000 (1MB) for the BIOS/video memory ReservePageRange ((void*)0, (0x100000 / ADC.Pager.AtomicPageSize), "Reserve memory below 0x100000 (1MB) for the BIOS/video memory"); // FIXME: the value we get back from Pager.Setup is not the same value that // we 'return' from inside the method itself!!!! Errors error = Errors.Unknown; Pager.Setup (totalKbMem, pagingData, pagingDataSize, &error); if (error != Errors.Success) { PrintError (error); return; } // NOTE: 0x0000 page is reserved currentPage = 1; error = Errors.Unknown; Pager.Enable (&error); if (error != Errors.Success) PrintError (error); }
/// <summary> /// HTML编码器 /// </summary> /// <param name="htmls">HTML转义字符集合</param> public encoder(string htmls) { size = (htmls.max((char)0) + 1); this.htmls = unmanaged.Get(size * sizeof(uint), true).UInt; foreach (char value in htmls) { int div = (value * (int)number.Div10_16Mul) >> number.Div10_16Shift; this.htmls[value] = (uint)(((value - div * 10) << 16) | div | 0x300030); } }