private ulong Sigma0(ulong x) { return(rotateRight(x, 1) ^ rotateRight(x, 8) ^ (x >> 7)); }
private static extern bool VerifyVersionInfo( [In] ref OsVersionInfoEx lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
public override void WriteValue(ulong value) { base.WriteValue(value); AddValue(value, JsonToken.Integer); }
private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); }
/// <summary> /// Try parse enum members specified in a string value from declared schema types. /// </summary> /// <param name="value">Enum value string</param> /// <param name="enumType">The enum type.</param> /// <param name="location">The location of the enum member in csdl</param> /// <param name="result">Parsed enum members</param> /// <returns>True for successfully parsed, false for failed</returns> internal static bool TryParseJsonEnumMember(string value, IEdmEnumType enumType, EdmLocation location, out IEnumerable<IEdmEnumMember> result) { result = null; bool isUnresolved = enumType is UnresolvedEnumType; if (isUnresolved) { result = new List<IEdmEnumMember> { new UnresolvedEnumMember(value, enumType, location) }; return true; } List<IEdmEnumMember> enumMembers = new List<IEdmEnumMember>(); // "@self.HasPattern": "1" // or with numeric value 1 + 16 if (long.TryParse(value, out long longValue)) { // In numeric value IEdmEnumMember member = enumType.Members.SingleOrDefault(m => m.Value.Value == longValue); if (member == null) { if (enumType.IsFlags) { long memberValue = 1; ulong ulongValue = (ulong)longValue; ulong mask = 1; while (ulongValue != 0) { ulong add = ulongValue & mask; if (add != 0) { member = enumType.Members.SingleOrDefault(m => m.Value.Value == memberValue); if (member == null) { return false; } enumMembers.Add(member); } ulongValue >>= 1; memberValue <<= 1; } } else { return false; } } else { enumMembers.Add(member); } } else { // in symbolic value // "@self.HasPattern": "Red,Striped" string[] enumValues = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (enumValues.Length > 1 && (!enumType.IsFlags || !EdmEnumValueParser.IsEnumIntegerType(enumType))) { return false; } foreach (string enumValue in enumValues) { IEdmEnumMember member = enumType.Members.SingleOrDefault(m => m.Name == enumValue.Trim()); if (member == null) { return false; } enumMembers.Add(member); } } result = enumMembers; return true; }
public void Test_BitTricks_Min_Signed() { Tools tools = CreateTools(); tools.StateConfig.Set_All_Reg_Off(); tools.StateConfig.RAX = true; tools.StateConfig.RBX = true; tools.StateConfig.RDX = true; return; // this trick does not seem to be correct?! string line1 = "sub rax, rbx"; // Will not work if overflow here! string line2 = "cqo"; // rdx1 = (rax0 > rbx0) ? -1 : 0 string line3 = "and rdx, rax"; // rdx2 = (rax0 > rbx0) ? 0 : (rax0 - rbx0) string line4 = "add rbx, rdx"; // rbx1 = (rax0 > rbx0) ? (rbx0 + 0) : (rbx0 + rax0 - rbx0) { // forward State state = CreateState(tools); Context ctx = state.Ctx; if (true) { ulong rax_value = 0x61a4292198602827; ulong rbx_value = 0x8739140220c24080; StateUpdate updateState = new StateUpdate("!PREVKEY", "!NEXTKEY", state.Tools); updateState.Set(Rn.RAX, rax_value); updateState.Set(Rn.RBX, rbx_value); state.Update_Forward(updateState); if (logToDisplay) { Console.WriteLine("Initially, we know:\n" + state); } } BitVecExpr rax0 = state.Create(Rn.RAX); BitVecExpr rbx0 = state.Create(Rn.RBX); { state.Solver.Assert(state.Ctx.MkNot(ToolsFlags.Create_OF_Sub(rax0, rbx0, rax0.SortSize, ctx))); // this code only works when there is no overflow in line1 } { // line 1 state = Runner.SimpleStep_Forward(line1, state); // retrieve the overflow after line 1, OF has to be zero for the code to work state.Solver.AssertAndTrack(ctx.MkNot(state.Create(Flags.OF)), ctx.MkBoolConst("OF-ZERO")); Assert.AreEqual(Status.SATISFIABLE, state.Solver.Check()); if (logToDisplay) { Console.WriteLine("After \"" + line1 + "\", we know:\n" + state); } } { // line 2 state = Runner.SimpleStep_Forward(line2, state); //if (logToDisplay) Console.WriteLine("After \"" + line2 + "\", we know:\n" + state); BoolExpr t2 = ctx.MkEq(state.Create(Rn.RDX), ctx.MkITE(ctx.MkBVSGT(rax0, rbx0), ctx.MkBV(0xFFFF_FFFF_FFFF_FFFF, 64), ctx.MkBV(0, 64))); //Assert.AreEqual(Tv5.ONE, ToolsZ3.GetTv5(t2, state.Solver, state.Ctx)); } { state = Runner.SimpleStep_Forward(line3, state); //if (logToDisplay) Console.WriteLine("After \"" + line3 + "\", we know:\n" + state); //BoolExpr t2 = ctx.MkEq(state.Get(Rn.RDX), ctx.MkITE(ctx.MkBVSGT(rax0, rbx0), ctx.MkBV(0, 64), ctx.MkBVSub(rax0, rbx0))); //Assert.AreEqual(Tv5.ONE, ToolsZ3.GetTv5(t2, state.Solver, state.Ctx)); } { state = Runner.SimpleStep_Forward(line4, state); if (logToDisplay) { Console.WriteLine("After \"" + line4 + "\", we know:\n" + state); } } // ebx is minimum of ebx and eax BitVecExpr rbx1 = state.Create(Rn.RBX); BoolExpr t = ctx.MkEq(rbx1, ctx.MkITE(ctx.MkBVSGT(rax0, rbx0), rbx0, rax0)); if (false) { state.Solver.Push(); state.Solver.AssertAndTrack(t, ctx.MkBoolConst("MIN_RAX_RBX")); Status s = state.Solver.Check(); if (logToDisplay) { Console.WriteLine("Status A = " + s + "; expected " + Status.SATISFIABLE); } if (s == Status.UNSATISFIABLE) { if (logToDisplay) { Console.WriteLine("UnsatCore has " + state.Solver.UnsatCore.Length + " elements"); } foreach (BoolExpr b in state.Solver.UnsatCore) { if (logToDisplay) { Console.WriteLine("UnsatCore=" + b); } } if (logToDisplay) { Console.WriteLine(state.Solver); } Assert.Fail(); } state.Solver.Pop(); } if (true) { state.Solver.Push(); state.Solver.Assert(ctx.MkNot(t), ctx.MkBoolConst("NOT_MIN_RAX_RBX")); Status s = state.Solver.Check(); if (logToDisplay) { Console.WriteLine("Status B = " + s + "; expected " + Status.UNSATISFIABLE); } if (s == Status.SATISFIABLE) { if (logToDisplay) { Console.WriteLine("Model=" + state.Solver.Model); } Assert.Fail(); } state.Solver.Pop(); } Assert.AreEqual(Tv.ONE, ToolsZ3.GetTv(t, state.Solver, state.Ctx)); } }
public static bool IsCorrectMessage(Cacheable<IUserMessage, ulong> message, SocketReaction reaction, ulong desiredMessage, string emojiName) { if (emojiName != null) return message.Id == desiredMessage && reaction.Emote.Name == emojiName; return message.Id == desiredMessage; }
// Extracts higher 32-bit word from an 64-bit int. // in: // number ulong // returns: // lower word public static uint HiDWord(ulong number) { return (uint)((number >> 32) & 0xffffffff); }
/// <summary> /// Rotate a 64-bit unsigned integer to the left by <see cref="shift"/> bits /// </summary> /// <param name="original">Original value</param> /// <param name="shift">The shift value</param> /// <returns>The rotated 64-bit integer</returns> private static ulong RotateLeft64(ulong original, int shift) { return((original << shift) | (original >> (64 - shift))); }
public void ConsensusService_SingleNodeActors_OnStart_PrepReq_PrepResponses_Commits() { var mockWallet = new Mock<Wallet>(); mockWallet.Setup(p => p.GetAccount(It.IsAny<UInt160>())).Returns<UInt160>(p => new TestWalletAccount(p)); Console.WriteLine($"\n(UT-Consensus) Wallet is: {mockWallet.Object.GetAccount(UInt160.Zero).GetKey().PublicKey}"); var mockContext = new Mock<ConsensusContext>(mockWallet.Object, Blockchain.Singleton.Store); mockContext.Object.LastSeenMessage = new int[] { 0, 0, 0, 0, 0, 0, 0 }; KeyPair[] kp_array = new KeyPair[7] { UT_Crypto.generateKey(32), // not used, kept for index consistency, didactically UT_Crypto.generateKey(32), UT_Crypto.generateKey(32), UT_Crypto.generateKey(32), UT_Crypto.generateKey(32), UT_Crypto.generateKey(32), UT_Crypto.generateKey(32) }; var timeValues = new[] { new DateTime(1980, 06, 01, 0, 0, 1, 001, DateTimeKind.Utc), // For tests, used below new DateTime(1980, 06, 01, 0, 0, 3, 001, DateTimeKind.Utc), // For receiving block new DateTime(1980, 05, 01, 0, 0, 5, 001, DateTimeKind.Utc), // For Initialize new DateTime(1980, 06, 01, 0, 0, 15, 001, DateTimeKind.Utc), // unused }; for (int i = 0; i < timeValues.Length; i++) Console.WriteLine($"time {i}: {timeValues[i].ToString()} "); ulong defaultTimestamp = 328665601001; // GMT: Sunday, June 1, 1980 12:00:01.001 AM // check basic ConsensusContext // mockConsensusContext.Object.block_received_time.ToTimestamp().Should().Be(4244941697); //1968-06-01 00:00:01 // ============================================================================ // creating ConsensusService actor // ============================================================================ int timeIndex = 0; var timeMock = new Mock<TimeProvider>(); timeMock.SetupGet(tp => tp.UtcNow).Returns(() => timeValues[timeIndex]); //.Callback(() => timeIndex = timeIndex + 1); //Comment while index is not fixed TimeProvider.Current = timeMock.Object; TimeProvider.Current.UtcNow.ToTimestampMS().Should().Be(defaultTimestamp); //1980-06-01 00:00:15:001 //public void Log(string message, LogLevel level) //create ILogPlugin for Tests /* mockConsensusContext.Setup(mr => mr.Log(It.IsAny<string>(), It.IsAny<LogLevel>())) .Callback((string message, LogLevel level) => { Console.WriteLine($"CONSENSUS LOG: {message}"); } ); */ // Creating a test block Header header = new Header(); TestUtils.SetupHeaderWithValues(header, UInt256.Zero, out UInt256 merkRootVal, out UInt160 val160, out ulong timestampVal, out uint indexVal, out Witness scriptVal); header.Size.Should().Be(105); Console.WriteLine($"header {header} hash {header.Hash} {header.PrevHash} timestamp {timestampVal}"); timestampVal.Should().Be(defaultTimestamp); TestProbe subscriber = CreateTestProbe(); TestActorRef<ConsensusService> actorConsensus = ActorOfAsTestActorRef<ConsensusService>( Akka.Actor.Props.Create(() => (ConsensusService)Activator.CreateInstance(typeof(ConsensusService), BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { subscriber, subscriber, mockContext.Object }, null)) ); var testPersistCompleted = new Blockchain.PersistCompleted { Block = new Block { Version = header.Version, PrevHash = header.PrevHash, MerkleRoot = header.MerkleRoot, Timestamp = header.Timestamp, Index = header.Index, NextConsensus = header.NextConsensus, Transactions = new Transaction[0] } }; Console.WriteLine("\n=========================="); Console.WriteLine("Telling a new block to actor consensus..."); Console.WriteLine("will trigger OnPersistCompleted without OnStart flag!"); // OnPersist will not launch timer, we need OnStart actorConsensus.Tell(testPersistCompleted); Console.WriteLine("\n=========================="); Console.WriteLine("\n=========================="); Console.WriteLine("will start consensus!"); actorConsensus.Tell(new ConsensusService.Start { IgnoreRecoveryLogs = true }); Console.WriteLine("Waiting for subscriber recovery message..."); // The next line force a waits, then, subscriber keeps running its thread // In the next case it waits for a Msg of type LocalNode.SendDirectly // As we may expect, as soon as consensus start it sends a RecoveryRequest of this aforementioned type var askingForInitialRecovery = subscriber.ExpectMsg<LocalNode.SendDirectly>(); Console.WriteLine($"Recovery Message I: {askingForInitialRecovery}"); // Ensuring cast of type ConsensusPayload from the received message from subscriber ConsensusPayload initialRecoveryPayload = (ConsensusPayload)askingForInitialRecovery.Inventory; // Ensuring casting of type RecoveryRequest RecoveryRequest rrm = (RecoveryRequest)initialRecoveryPayload.ConsensusMessage; rrm.Timestamp.Should().Be(defaultTimestamp); Console.WriteLine("Waiting for backup ChangeView... "); var backupOnAskingChangeView = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var changeViewPayload = (ConsensusPayload)backupOnAskingChangeView.Inventory; ChangeView cvm = (ChangeView)changeViewPayload.ConsensusMessage; cvm.Timestamp.Should().Be(defaultTimestamp); cvm.ViewNumber.Should().Be(0); cvm.Reason.Should().Be(ChangeViewReason.Timeout); // Original Contract Contract originalContract = Contract.CreateMultiSigContract(mockContext.Object.M, mockContext.Object.Validators); Console.WriteLine($"\nORIGINAL Contract is: {originalContract.ScriptHash}"); Console.WriteLine($"ORIGINAL NextConsensus: {mockContext.Object.Block.NextConsensus}\nENSURING values..."); originalContract.ScriptHash.Should().Be(UInt160.Parse("0x7ab841144dcdbf228ff57f7068f795e2afd1a3c1")); mockContext.Object.Block.NextConsensus.Should().Be(UInt160.Parse("0x7ab841144dcdbf228ff57f7068f795e2afd1a3c1")); Console.WriteLine("\n=========================="); Console.WriteLine("will trigger OnPersistCompleted again with OnStart flag!"); actorConsensus.Tell(testPersistCompleted); Console.WriteLine("\n=========================="); // Disabling flag ViewChanging by reverting cache of changeview that was sent mockContext.Object.ChangeViewPayloads[mockContext.Object.MyIndex] = null; Console.WriteLine("Forcing Failed nodes for recovery request... "); mockContext.Object.CountFailed.Should().Be(0); mockContext.Object.LastSeenMessage = new int[] { -1, -1, -1, -1, -1, -1, -1 }; mockContext.Object.CountFailed.Should().Be(7); Console.WriteLine("\nWaiting for recovery due to failed nodes... "); var backupOnRecoveryDueToFailedNodes = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var recoveryPayload = (ConsensusPayload)backupOnRecoveryDueToFailedNodes.Inventory; rrm = (RecoveryRequest)recoveryPayload.ConsensusMessage; rrm.Timestamp.Should().Be(defaultTimestamp); Console.WriteLine("will create template MakePrepareRequest..."); mockContext.Object.PrevHeader.Timestamp = defaultTimestamp; mockContext.Object.PrevHeader.NextConsensus.Should().Be(UInt160.Parse("0x7ab841144dcdbf228ff57f7068f795e2afd1a3c1")); var prepReq = mockContext.Object.MakePrepareRequest(); var ppToSend = (PrepareRequest)prepReq.ConsensusMessage; // Forcing hashes to 0 because mempool is currently shared ppToSend.TransactionHashes = new UInt256[0]; ppToSend.TransactionHashes.Length.Should().Be(0); Console.WriteLine($"\nAsserting PreparationPayloads is 1 (After MakePrepareRequest)..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(1); mockContext.Object.PreparationPayloads[prepReq.ValidatorIndex] = null; Console.WriteLine("will tell prepare request!"); actorConsensus.Tell(prepReq); Console.WriteLine("Waiting for something related to the PrepRequest...\nNothing happens...Recovery will come due to failed nodes"); var backupOnRecoveryDueToFailedNodesII = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var recoveryPayloadII = (ConsensusPayload)backupOnRecoveryDueToFailedNodesII.Inventory; rrm = (RecoveryRequest)recoveryPayloadII.ConsensusMessage; Console.WriteLine($"\nAsserting PreparationPayloads is 0..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(0); Console.WriteLine($"\nAsserting CountFailed is 6..."); mockContext.Object.CountFailed.Should().Be(6); Console.WriteLine("\nFailed because it is not primary and it created the prereq...Time to adjust"); prepReq.ValidatorIndex = 1; //simulating primary as prepreq creator (signature is skip, no problem) // cleaning old try with Self ValidatorIndex mockContext.Object.PreparationPayloads[mockContext.Object.MyIndex] = null; actorConsensus.Tell(prepReq); var OnPrepResponse = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var prepResponsePayload = (ConsensusPayload)OnPrepResponse.Inventory; PrepareResponse prm = (PrepareResponse)prepResponsePayload.ConsensusMessage; prm.PreparationHash.Should().Be(prepReq.Hash); Console.WriteLine("\nAsserting PreparationPayloads count is 2..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(2); Console.WriteLine($"\nAsserting CountFailed is 5..."); mockContext.Object.CountFailed.Should().Be(5); // Simulating CN 3 actorConsensus.Tell(GetPayloadAndModifyValidator(prepResponsePayload, 2)); //Waiting for RecoveryRequest for a more deterministic UT backupOnRecoveryDueToFailedNodes = subscriber.ExpectMsg<LocalNode.SendDirectly>(); recoveryPayload = (ConsensusPayload)backupOnRecoveryDueToFailedNodes.Inventory; rrm = (RecoveryRequest)recoveryPayload.ConsensusMessage; rrm.Timestamp.Should().Be(defaultTimestamp); //Asserts Console.WriteLine("\nAsserting PreparationPayloads count is 3..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(3); Console.WriteLine($"\nAsserting CountFailed is 4..."); mockContext.Object.CountFailed.Should().Be(4); // Simulating CN 5 actorConsensus.Tell(GetPayloadAndModifyValidator(prepResponsePayload, 4)); //Waiting for RecoveryRequest for a more deterministic UT backupOnRecoveryDueToFailedNodes = subscriber.ExpectMsg<LocalNode.SendDirectly>(); recoveryPayload = (ConsensusPayload)backupOnRecoveryDueToFailedNodes.Inventory; rrm = (RecoveryRequest)recoveryPayload.ConsensusMessage; rrm.Timestamp.Should().Be(defaultTimestamp); //Asserts Console.WriteLine("\nAsserting PreparationPayloads count is 4..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(4); Console.WriteLine($"\nAsserting CountFailed is 3..."); mockContext.Object.CountFailed.Should().Be(3); // Simulating CN 4 actorConsensus.Tell(GetPayloadAndModifyValidator(prepResponsePayload, 3)); var onCommitPayload = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var commitPayload = (ConsensusPayload)onCommitPayload.Inventory; Commit cm = (Commit)commitPayload.ConsensusMessage; Console.WriteLine("\nAsserting PreparationPayloads count is 5..."); mockContext.Object.PreparationPayloads.Count(p => p != null).Should().Be(5); Console.WriteLine("\nAsserting CountCommitted is 1..."); mockContext.Object.CountCommitted.Should().Be(1); Console.WriteLine($"\nAsserting CountFailed is 2..."); mockContext.Object.CountFailed.Should().Be(2); Console.WriteLine($"ORIGINAL BlockHash: {mockContext.Object.Block.Hash}"); Console.WriteLine($"ORIGINAL Block NextConsensus: {mockContext.Object.Block.NextConsensus}"); for (int i = 0; i < mockContext.Object.Validators.Length; i++) Console.WriteLine($"{mockContext.Object.Validators[i]}/{Contract.CreateSignatureContract(mockContext.Object.Validators[i]).ScriptHash}"); mockContext.Object.Validators = new ECPoint[7] { kp_array[0].PublicKey, kp_array[1].PublicKey, kp_array[2].PublicKey, kp_array[3].PublicKey, kp_array[4].PublicKey, kp_array[5].PublicKey, kp_array[6].PublicKey }; Console.WriteLine($"Generated keypairs PKey:"); for (int i = 0; i < mockContext.Object.Validators.Length; i++) Console.WriteLine($"{mockContext.Object.Validators[i]}/{Contract.CreateSignatureContract(mockContext.Object.Validators[i]).ScriptHash}"); var updatedContract = Contract.CreateMultiSigContract(mockContext.Object.M, mockContext.Object.Validators); Console.WriteLine($"\nContract updated: {updatedContract.ScriptHash}"); // =============================================================== mockContext.Object.Snapshot.Storages.Add(CreateStorageKeyForNativeNeo(14), new StorageItem() { Value = mockContext.Object.Validators.ToByteArray() }); mockContext.Object.Snapshot.Commit(); // =============================================================== // Forcing next consensus var originalBlockHashData = mockContext.Object.Block.GetHashData(); mockContext.Object.Block.NextConsensus = updatedContract.ScriptHash; mockContext.Object.Block.Header.NextConsensus = updatedContract.ScriptHash; var originalBlockMerkleRoot = mockContext.Object.Block.MerkleRoot; Console.WriteLine($"\noriginalBlockMerkleRoot: {originalBlockMerkleRoot}"); var updatedBlockHashData = mockContext.Object.Block.GetHashData(); Console.WriteLine($"originalBlockHashData: {originalBlockHashData.ToScriptHash()}"); Console.WriteLine($"updatedBlockHashData: {updatedBlockHashData.ToScriptHash()}"); Console.WriteLine("\n\n=========================="); Console.WriteLine("\nBasic commits Signatures verification"); // Basic tests for understanding signatures and ensuring signatures of commits are correct on tests var cmPayloadTemp = GetCommitPayloadModifiedAndSignedCopy(commitPayload, 6, kp_array[6], updatedBlockHashData); Crypto.VerifySignature(originalBlockHashData, cm.Signature, mockContext.Object.Validators[0]).Should().BeFalse(); Crypto.VerifySignature(updatedBlockHashData, cm.Signature, mockContext.Object.Validators[0]).Should().BeFalse(); Crypto.VerifySignature(originalBlockHashData, ((Commit)cmPayloadTemp.ConsensusMessage).Signature, mockContext.Object.Validators[6]).Should().BeFalse(); Crypto.VerifySignature(updatedBlockHashData, ((Commit)cmPayloadTemp.ConsensusMessage).Signature, mockContext.Object.Validators[6]).Should().BeTrue(); Console.WriteLine("\n=========================="); Console.WriteLine("\n=========================="); Console.WriteLine("\nCN7 simulation time"); actorConsensus.Tell(cmPayloadTemp); var tempPayloadToBlockAndWait = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var rmPayload = (ConsensusPayload)tempPayloadToBlockAndWait.Inventory; RecoveryMessage rmm = (RecoveryMessage)rmPayload.ConsensusMessage; Console.WriteLine("\nAsserting CountCommitted is 2..."); mockContext.Object.CountCommitted.Should().Be(2); Console.WriteLine($"\nAsserting CountFailed is 1..."); mockContext.Object.CountFailed.Should().Be(1); Console.WriteLine("\nCN6 simulation time"); actorConsensus.Tell(GetCommitPayloadModifiedAndSignedCopy(commitPayload, 5, kp_array[5], updatedBlockHashData)); tempPayloadToBlockAndWait = subscriber.ExpectMsg<LocalNode.SendDirectly>(); rmPayload = (ConsensusPayload)tempPayloadToBlockAndWait.Inventory; rmm = (RecoveryMessage)rmPayload.ConsensusMessage; Console.WriteLine("\nAsserting CountCommitted is 3..."); mockContext.Object.CountCommitted.Should().Be(3); Console.WriteLine($"\nAsserting CountFailed is 0..."); mockContext.Object.CountFailed.Should().Be(0); Console.WriteLine("\nCN5 simulation time"); actorConsensus.Tell(GetCommitPayloadModifiedAndSignedCopy(commitPayload, 4, kp_array[4], updatedBlockHashData)); tempPayloadToBlockAndWait = subscriber.ExpectMsg<LocalNode.SendDirectly>(); Console.WriteLine("\nAsserting CountCommitted is 4..."); mockContext.Object.CountCommitted.Should().Be(4); // ============================================= // Testing commit with wrong signature not valid // It will be invalid signature because we did not change ECPoint Console.WriteLine("\nCN4 simulation time. Wrong signature, KeyPair is not known"); actorConsensus.Tell(GetPayloadAndModifyValidator(commitPayload, 3)); Console.WriteLine("\nWaiting for recovery due to failed nodes... "); var backupOnRecoveryMessageAfterCommit = subscriber.ExpectMsg<LocalNode.SendDirectly>(); rmPayload = (ConsensusPayload)backupOnRecoveryMessageAfterCommit.Inventory; rmm = (RecoveryMessage)rmPayload.ConsensusMessage; Console.WriteLine("\nAsserting CountCommitted is 4 (Again)..."); mockContext.Object.CountCommitted.Should().Be(4); Console.WriteLine("\nAsserting recovery message Preparation is 5..."); rmm.PreparationMessages.Count().Should().Be(5); Console.WriteLine("\nAsserting recovery message CommitMessages is 4..."); rmm.CommitMessages.Count().Should().Be(4); // ============================================= Console.WriteLine($"\nForcing block {mockContext.Object.Block.GetHashData().ToScriptHash()} PrevHash to UInt256.Zero"); // Another option would be to manipulate Blockchain.Singleton.GetSnapshot().Blocks.GetAndChange // We would need to get the PrevHash and change the NextConsensus field var oldPrevHash = mockContext.Object.Block.PrevHash; mockContext.Object.Block.PrevHash = UInt256.Zero; //Payload should also be forced, otherwise OnConsensus will not pass commitPayload.PrevHash = UInt256.Zero; Console.WriteLine($"\nNew Hash is {mockContext.Object.Block.GetHashData().ToScriptHash()}"); Console.WriteLine($"\nForcing block VerificationScript to {updatedContract.Script.ToScriptHash()}"); // The default behavior for BlockBase, when PrevHash = UInt256.Zero, is to use its own Witness mockContext.Object.Block.Witness = new Witness { }; mockContext.Object.Block.Witness.VerificationScript = updatedContract.Script; Console.WriteLine($"\nUpdating BlockBase Witness scripthash to: {mockContext.Object.Block.Witness.ScriptHash}"); Console.WriteLine($"\nNew Hash is {mockContext.Object.Block.GetHashData().ToScriptHash()}"); Console.WriteLine("\nCN4 simulation time - Final needed signatures"); actorConsensus.Tell(GetCommitPayloadModifiedAndSignedCopy(commitPayload, 3, kp_array[3], mockContext.Object.Block.GetHashData())); Console.WriteLine("\nWait for subscriber Local.Node Relay"); var onBlockRelay = subscriber.ExpectMsg<LocalNode.Relay>(); Console.WriteLine("\nAsserting time was Block..."); var utBlock = (Block)onBlockRelay.Inventory; Console.WriteLine("\nAsserting CountCommitted is 5..."); mockContext.Object.CountCommitted.Should().Be(5); Console.WriteLine($"\nAsserting block NextConsensus..{utBlock.NextConsensus}"); utBlock.NextConsensus.Should().Be(updatedContract.ScriptHash); Console.WriteLine("\n=========================="); // ============================================= Console.WriteLine("\nRecovery simulation..."); mockContext.Object.CommitPayloads = new ConsensusPayload[mockContext.Object.Validators.Length]; // avoiding the BlockSent flag mockContext.Object.Block.Transactions = null; // ensuring same hash as snapshot mockContext.Object.Block.PrevHash = oldPrevHash; Console.WriteLine("\nAsserting CountCommitted is 0..."); mockContext.Object.CountCommitted.Should().Be(0); Console.WriteLine($"\nAsserting CountFailed is 0..."); mockContext.Object.CountFailed.Should().Be(0); Console.WriteLine($"\nModifying CountFailed and asserting 7..."); // This will ensure a non-deterministic behavior after last recovery mockContext.Object.LastSeenMessage = new int[] { -1, -1, -1, -1, -1, -1, -1 }; mockContext.Object.CountFailed.Should().Be(7); actorConsensus.Tell(rmPayload); Console.WriteLine("\nWaiting for RecoveryRequest before final asserts..."); var onRecoveryRequestAfterRecovery = subscriber.ExpectMsg<LocalNode.SendDirectly>(); var rrPayload = (ConsensusPayload)onRecoveryRequestAfterRecovery.Inventory; var rrMessage = (RecoveryRequest)rrPayload.ConsensusMessage; // It should be 3 because the commit generated by the default wallet is still invalid Console.WriteLine("\nAsserting CountCommitted is 3 (after recovery)..."); mockContext.Object.CountCommitted.Should().Be(3); // ============================================= // ============================================= // ============================================================================ // finalize ConsensusService actor // ============================================================================ Console.WriteLine("Returning states."); // Updating context.Snapshot with the one that was committed Console.WriteLine("mockContext Reset for returning Blockchain.Singleton snapshot to original state."); mockContext.Object.Reset(0); mockContext.Object.Snapshot.Storages.Delete(CreateStorageKeyForNativeNeo(14)); mockContext.Object.Snapshot.Commit(); Console.WriteLine("mockContext Reset."); mockContext.Object.Reset(0); Console.WriteLine("TimeProvider Reset."); TimeProvider.ResetToDefault(); Console.WriteLine("Finalizing consensus service actor."); Sys.Stop(actorConsensus); Console.WriteLine("Actor actorConsensus Stopped.\n"); }
// Extracts lower 32-bit word from an 64-bit int. // in: // number ulong // returns: // lower word public static uint LoDWord(ulong number) { return (uint)(number & 0xffffffff); }
public void SendScoreEvent(ulong channelId, SubmitScore score) { var channel = _client.GetChannel(channelId) as SocketTextChannel; channel?.SendMessageAsync($"{score.Score.Username} has scored {score.Score._Score}{(score.Score.FullCombo ? " (Full Combo!)" : "")} on {score.Score.Parameters.Beatmap.Name}!"); }
/// <summary> /// ulong变量转化缓存数据 /// </summary> /// <param name="value">等待转化的数据</param> /// <returns>buffer数据</returns> public virtual byte[] TransByte( ulong value ) { return TransByte( new ulong[] { value } ); }
private ulong Sigma1(ulong x) { return(rotateRight(x, 19) ^ rotateRight(x, 61) ^ (x >> 6)); }
/// <summary> /// Process extra data fields updating the entry based on the contents. /// </summary> /// <param name="localHeader">True if the extra data fields should be handled /// for a local header, rather than for a central header. /// </param> internal void ProcessExtraData(bool localHeader) { ZipExtraData extraData = new ZipExtraData(this.extra); if ( extraData.Find(0x0001) ) { if ( (versionToExtract & 0xff) < ZipConstants.VersionZip64 ) { throw new ZipException("Zip64 Extended information found but version is not valid"); } // The recorded size will change but remember that this is zip64. forceZip64_ = true; if ( extraData.ValueLength < 4 ) { throw new ZipException("Extra data extended Zip64 information length is invalid"); } if ( localHeader || (size == uint.MaxValue) ) { size = (ulong)extraData.ReadLong(); } if ( localHeader || (compressedSize == uint.MaxValue) ) { compressedSize = (ulong)extraData.ReadLong(); } if ( !localHeader && (offset == uint.MaxValue) ) { offset = extraData.ReadLong(); } } else { if ( ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) && ((size == uint.MaxValue) || (compressedSize == uint.MaxValue)) ) { throw new ZipException("Zip64 Extended information required but is missing."); } } /* TODO: Testing for handling of windows extra data is not yet done if ( extraData.Find(10) ) { // No room for any tags. if ( extraData.ValueLength < 8 ) { throw new ZipException("NTFS Extra data invalid"); } extraData.ReadInt(); // Reserved while ( extraData.UnreadCount >= 4 ) { int ntfsTag = extraData.ReadShort(); int ntfsLength = extraData.ReadShort(); if ( ntfsTag == 1 ) { if ( ntfsLength >= 24 ) { long lastModification = extraData.ReadLong(); long lastAccess = extraData.ReadLong(); long createTime = extraData.ReadLong(); DateTime = System.DateTime.FromFileTime(lastModification); } break; } else { // An unknown NTFS tag so simply skip it. extraData.Skip(ntfsLength); } } } else */ if ( extraData.Find(0x5455) ) { int length = extraData.ValueLength; int flags = extraData.ReadByte(); // Can include other times but these are ignored. Length of data should // actually be 1 + 4 * no of bits in flags. if ( ((flags & 1) != 0) && (length >= 5) ) { int iTime = extraData.ReadInt(); DateTime = (new System.DateTime ( 1970, 1, 1, 0, 0, 0 ).ToUniversalTime() + new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime(); } } }
/// <summary>将 8 字节无符号整数写入当前流,并将流的位置提升 8 个字节。</summary> /// <param name="value">要写入的 8 字节无符号整数。</param> //[CLSCompliant(false)] public virtual void Write(ulong value) { Write((Int64)value); }
private void GetLoginsHandler(Request r, Response resp, Aes aes) { if (!VerifyRequest(r, aes)) { return; } string submithost = null; var host = GetHost(CryptoTransform(r.Url, true, false, aes, CMode.DECRYPT)); if (r.SubmitUrl != null) { submithost = GetHost(CryptoTransform(r.SubmitUrl, true, false, aes, CMode.DECRYPT)); } var items = FindMatchingEntries(r, aes); if (items.ToList().Count > 0) { Func <PwEntry, bool> filter = delegate(PwEntry e) { var c = GetEntryConfig(e); var title = e.Strings.ReadSafe(PwDefs.TitleField); var entryUrl = e.Strings.ReadSafe(PwDefs.UrlField); if (c != null) { return(title != host && entryUrl != host && !c.Allow.Contains(host) || (submithost != null && !c.Allow.Contains(submithost) && submithost != title && submithost != entryUrl)); } return(title != host && entryUrl != host || (submithost != null && title != submithost && entryUrl != submithost)); }; var configOpt = new ConfigOpt(this.host.CustomConfig); var config = GetConfigEntry(true); var autoAllowS = config.Strings.ReadSafe("Auto Allow"); var autoAllow = autoAllowS != null && autoAllowS.Trim() != ""; autoAllow = autoAllow || configOpt.AlwaysAllowAccess; var needPrompting = from e in items where filter(e.entry) select e; if (needPrompting.ToList().Count > 0 && !autoAllow) { var clicked = true; if (canShowBalloonTips()) { clicked = false; var wait = new ManualResetEvent(false); var delegated = false; EventHandler onclick = delegate { delegated = true; clicked = true; wait.Set(); }; EventHandler onclose = delegate { delegated = true; wait.Set(); }; ShowNotification(String.Format( "{0}: {1} is requesting access, click to allow or deny", r.Id, submithost != null ? submithost : host), onclick, onclose); wait.WaitOne(GetNotificationTime() + 5000); // give a little time to fade if (!delegated) { resp.Error = "Notification bubble did not appear"; } } if (clicked) { var win = this.host.MainWindow; using (var f = new AccessControlForm()) { win.Invoke((MethodInvoker) delegate { f.Icon = win.Icon; f.Plugin = this; f.Entries = (from e in items where filter(e.entry) select e.entry).ToList(); //f.Entries = needPrompting.ToList(); f.Host = submithost != null ? submithost : host; f.Load += delegate { f.Activate(); }; f.ShowDialog(win); if (f.Remember && (f.Allowed || f.Denied)) { foreach (var e in needPrompting) { var c = GetEntryConfig(e.entry); if (c == null) { c = new KeePassHttpEntryConfig(); } var set = f.Allowed ? c.Allow : c.Deny; set.Add(host); if (submithost != null && submithost != host) { set.Add(submithost); } SetEntryConfig(e.entry, c); } } if (!f.Allowed) { items = items.Except(needPrompting); } }); } } else { items = items.Except(needPrompting); } } //if (r.SortSelection == "true" || configOpt.SpecificMatchingOnly) //{ string sortHost = CryptoTransform(r.Url, true, false, aes, CMode.DECRYPT); if (sortHost.EndsWith("/")) { sortHost = sortHost.Substring(0, sortHost.Length - 1); } string sortSubmiturl = null; if (r.SubmitUrl != null) { sortSubmiturl = CryptoTransform(r.SubmitUrl, true, false, aes, CMode.DECRYPT); } if (sortSubmiturl == null) { sortSubmiturl = String.Copy(sortHost); } if (sortSubmiturl.EndsWith("/")) { sortSubmiturl = sortSubmiturl.Substring(0, sortSubmiturl.Length - 1); } if (!sortSubmiturl.Contains("://")) { sortSubmiturl = "http://" + sortSubmiturl; } if (!sortHost.Contains("://")) { sortHost = "http://" + sortHost; } string sortBaseSubmiturl = String.Copy(sortSubmiturl); if (sortSubmiturl.LastIndexOf("/") > 7) { Uri sortBaseSubmithostURI = new Uri(sortSubmiturl); sortBaseSubmiturl = String.Format("{0}{1}{2}{3}", sortBaseSubmithostURI.Scheme, Uri.SchemeDelimiter, sortBaseSubmithostURI.Authority, sortBaseSubmithostURI.AbsolutePath.Substring(0, sortBaseSubmithostURI.AbsolutePath.LastIndexOf("/")) ); } sortSubmiturl = sortSubmiturl.ToLower(); sortHost = sortHost.ToLower(); sortBaseSubmiturl = sortBaseSubmiturl.ToLower(); foreach (var entryDatabase in items) { string entryUrl = String.Copy(entryDatabase.entry.Strings.ReadSafe(PwDefs.UrlField)); if (entryUrl.EndsWith("/")) { entryUrl = entryUrl.Substring(0, entryUrl.Length - 1); } entryUrl = entryUrl.ToLower(); if (!entryUrl.Contains("://")) { entryUrl = "http://" + entryUrl; } string baseEntryUrl = String.Copy(entryUrl); if (baseEntryUrl.LastIndexOf("/") > 7) { Uri baseEntryUrlURI = new Uri(entryUrl); baseEntryUrl = String.Format("{0}{1}{2}{3}", baseEntryUrlURI.Scheme, Uri.SchemeDelimiter, baseEntryUrlURI.Authority, baseEntryUrlURI.AbsolutePath.Substring(0, baseEntryUrlURI.AbsolutePath.LastIndexOf("/"))); } if (sortSubmiturl == entryUrl) { entryDatabase.entry.UsageCount = 90; } else if (sortSubmiturl.StartsWith(entryUrl) && sortHost != entryUrl && sortBaseSubmiturl != entryUrl) { entryDatabase.entry.UsageCount = 80; } else if (sortSubmiturl.StartsWith(baseEntryUrl) && sortHost != baseEntryUrl && sortBaseSubmiturl != baseEntryUrl) { entryDatabase.entry.UsageCount = 70; } else if (sortHost == entryUrl) { entryDatabase.entry.UsageCount = 50; } else if (sortBaseSubmiturl == entryUrl) { entryDatabase.entry.UsageCount = 40; } else if (entryUrl.StartsWith(sortSubmiturl)) { entryDatabase.entry.UsageCount = 30; } else if (entryUrl.StartsWith(sortBaseSubmiturl) && sortBaseSubmiturl != sortHost) { entryDatabase.entry.UsageCount = 25; } else if (sortSubmiturl.StartsWith(entryUrl)) { entryDatabase.entry.UsageCount = 20; } else if (sortSubmiturl.StartsWith(baseEntryUrl)) { entryDatabase.entry.UsageCount = 15; } else if (entryUrl.StartsWith(sortHost)) { entryDatabase.entry.UsageCount = 10; } else if (sortHost.StartsWith(entryUrl)) { entryDatabase.entry.UsageCount = 5; } else { entryDatabase.entry.UsageCount = 1; } } //} var itemsList = items.ToList(); if (configOpt.SpecificMatchingOnly) { ulong highestCount = 0; foreach (var entryDatabase in itemsList.ToList()) { if (highestCount == 0) { highestCount = entryDatabase.entry.UsageCount; } if (entryDatabase.entry.UsageCount != highestCount) { itemsList.Remove(entryDatabase); } } } if (configOpt.SortResultByUsername) { var items2 = from e in itemsList orderby e.entry.UsageCount descending, GetUserPass(e)[0] ascending select e; itemsList = items2.ToList(); } else { var items2 = from e in itemsList orderby e.entry.UsageCount descending, e.entry.Strings.ReadSafe(PwDefs.TitleField) ascending select e; itemsList = items2.ToList(); } foreach (var entryDatabase in itemsList) { var e = PrepareElementForResponseEntries(configOpt, entryDatabase); resp.Entries.Add(e); } if (itemsList.Count > 0) { var names = (from e in resp.Entries select e.Name).Distinct <string>(); var n = String.Join("\n ", names.ToArray <string>()); if (configOpt.ReceiveCredentialNotification) { ShowNotification(String.Format("{0}: {1} is receiving credentials for:\n {2}", r.Id, host, n)); } } resp.Success = true; resp.Id = r.Id; SetResponseVerifier(resp, aes); foreach (var entry in resp.Entries) { entry.Name = CryptoTransform(entry.Name, false, true, aes, CMode.ENCRYPT); entry.Login = CryptoTransform(entry.Login, false, true, aes, CMode.ENCRYPT); entry.Uuid = CryptoTransform(entry.Uuid, false, true, aes, CMode.ENCRYPT); entry.Password = CryptoTransform(entry.Password, false, true, aes, CMode.ENCRYPT); if (entry.StringFields != null) { foreach (var sf in entry.StringFields) { sf.Key = CryptoTransform(sf.Key, false, true, aes, CMode.ENCRYPT); sf.Value = CryptoTransform(sf.Value, false, true, aes, CMode.ENCRYPT); } } } resp.Count = resp.Entries.Count; } else { resp.Success = true; resp.Id = r.Id; SetResponseVerifier(resp, aes); } }
public IOutputStream GetOutputStreamAt(ulong position) { ThrowCloningNotSupported("GetOutputStreamAt"); return null; }
static void Main(string[] args) { try { Console.Title = "FastDiscordOffensive Made by alty4182"; Console.ForegroundColor = ConsoleColor.Green; Console.BackgroundColor = ConsoleColor.Black; } catch (Exception e) { Console.WriteLine(e.Message); } Console.Write("Input token file here >"); try { string[] tokens = File.ReadAllLines(Console.ReadLine()); try { IEnumerable<int> ranges = Enumerable.Range(0, tokens.Length); try { Console.WriteLine("Loading tokens..."); } catch (Exception e) { Console.WriteLine(e.Message); } Parallel.ForEach(ranges, i => { client_list.Add(LoggingIn(tokens[i])); }); Console.Clear(); } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } attack: Console.Clear(); Console.WriteLine("[1]Fast Spamming"); Console.WriteLine("[2]Fast Joiner"); Console.WriteLine("[3]Fast Leaver"); Console.WriteLine("[4]Fast Friend Request Sender"); string command = Console.ReadLine(); if (command == "1") { Console.Write("Enter channel id here >"); try { ulong channel_id = Convert.ToUInt64(Console.ReadLine()); try { Console.Write("Enter message here >"); try { string message = Console.ReadLine(); Console.Write("Enter send count here >"); try { string send_str_count = Console.ReadLine(); int send_count = int.Parse(send_str_count); for (int i = 0; i < send_count; i++) { IEnumerable<int> ranges = Enumerable.Range(0, client_list.Count); Parallel.ForEach(ranges, j => { client_list[j].SendMessage(channel_id, message); }); } } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } goto attack; } if (command == "2") { Console.Write("Enter invite link here >"); try { string invite_link = Console.ReadLine(); try { IEnumerable<int> ranges = Enumerable.Range(0, client_list.Count); Parallel.ForEach(ranges, i => { client_list[i].JoinGuild(invite_link.Split(new char[] { '/' }).Last()); }); } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } goto attack; } if (command == "3") { Console.Write("Enter server id here >"); try { string server_id = Console.ReadLine(); IEnumerable<int> ranges = Enumerable.Range(0, client_list.Count); Parallel.ForEach(ranges, i => { client_list[i].LeaveGuild(Convert.ToUInt64(server_id)); }); } catch (Exception e) { Console.WriteLine(e.Message); } goto attack; } if (command == "4") { Console.Write("Enter username here >"); try { string username = Console.ReadLine(); Console.Write("Enter discriminator here >"); try { string discriminator = Console.ReadLine(); IEnumerable<int> ranges = Enumerable.Range(0, client_list.Count); Parallel.ForEach(ranges, i => { client_list[i].SendFriendRequest(username, uint.Parse(discriminator)); }); } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } goto attack; } }
public ValueRangeAttribute(ulong from, ulong to) { From = from; To = to; }
/// <summary> /// Formatted for the danish format! /// </summary> public static bool TryParseDatetime(string input, ulong userID, out DateTime result) { CultureInfo danishCulture = new CultureInfo (UserConfiguration.GetSetting<string>(userID, "Culture")); return DateTime.TryParse (input, danishCulture.DateTimeFormat, DateTimeStyles.None, out result); }
public ValueRangeAttribute(ulong value) { From = To = value; }
private static void GameServer_ValidateAuthTicketResponse(ulong remoteUserId, AuthSessionResponseEnum response, ulong ownerSteamId) { //using the player join event takes too long, sometimes they can load in before we boot them //we're not replacing the lobby yet, but hooking into this event will give us more time to verify players if (!PluginSettings.Instance.ReservedSlotsEnabled) { return; } if (response != AuthSessionResponseEnum.OK) { return; } if (PluginSettings.Instance.ReservedSlotsPlayers.Contains(remoteUserId.ToString( ))) { _reservedPlayers.Add(remoteUserId); Essentials.Log.Info("Whitelisted player connected: " + remoteUserId); Essentials.Log.Info("{0} whitelisted players connected. {1} of {2} reserved slots allocated.", _reservedPlayers.Count, Math.Min(_reservedPlayers.Count, PluginSettings.Instance.ReservedSlotsCount), PluginSettings.Instance.ReservedSlotsCount); return; } if (PluginSettings.Instance.TicketPlayers.Any(item => item.TicketId == remoteUserId)) { _reservedPlayers.Add(remoteUserId); Essentials.Log.Info("Ticket player connected: " + remoteUserId); Essentials.Log.Info("{0} whitelisted players connected. {1} of {2} reserved slots allocated.", _reservedPlayers.Count, Math.Min(_reservedPlayers.Count, PluginSettings.Instance.ReservedSlotsCount), PluginSettings.Instance.ReservedSlotsCount); return; } if (PluginSettings.Instance.ReservedSlotsAdmins && PlayerManager.Instance.IsUserAdmin(remoteUserId)) { _reservedPlayers.Add(remoteUserId); Essentials.Log.Info("Whitelisted admin connected: " + remoteUserId); Essentials.Log.Info("{0} whitelisted players connected. {1} of {2} reserved slots allocated.", _reservedPlayers.Count, Math.Min(_reservedPlayers.Count, PluginSettings.Instance.ReservedSlotsCount), PluginSettings.Instance.ReservedSlotsCount); return; } if (PluginSettings.Instance.ReservedSlotsGroup != 0) { _waitingPlayers.Add(remoteUserId); //ask Steam if the connecting player is in the whitelisted group. response is raised as an event; GameServer_UserGroupStatus SteamServerAPI.Instance.GameServer.RequestGroupStatus(remoteUserId, PluginSettings.Instance.ReservedSlotsGroup); return; } DenyPlayer(remoteUserId); }
public bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason) { string r = string.Empty; bool success = m_CacheWrapper.AddGroupRole(groupID, roleID, description, name, powers, title, delegate { return m_GroupsService.AddGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers, out r); }); reason = r; return success; }
private static extern ulong VerSetConditionMask(ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask);
public bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers) { return m_CacheWrapper.UpdateGroupRole(groupID, roleID, name, description, title, powers, delegate { return m_GroupsService.UpdateGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers); }); }
/// <summary> /// Use only if you have the onnxruntime package specific to this Execution Provider. /// </summary> public void AppendExecutionProvider_Nnapi(ulong nnapi_flags) { NativeApiStatus.VerifySuccess(NativeMethods.OrtSessionOptionsAppendExecutionProvider_Nnapi(handle, nnapi_flags)); }
protected override void ReadDirtyFields(BMSByte data, ulong timestep) { if (readDirtyFlags == null) { Initialize(); } Buffer.BlockCopy(data.byteArr, data.StartIndex(), readDirtyFlags, 0, readDirtyFlags.Length); data.MoveStartIndex(readDirtyFlags.Length); if ((0x1 & readDirtyFlags[0]) != 0) { if (positionInterpolation.Enabled) { positionInterpolation.target = UnityObjectMapper.Instance.Map <Vector3>(data); positionInterpolation.Timestep = timestep; } else { _position = UnityObjectMapper.Instance.Map <Vector3>(data); RunChange_position(timestep); } } if ((0x2 & readDirtyFlags[0]) != 0) { if (rotationInterpolation.Enabled) { rotationInterpolation.target = UnityObjectMapper.Instance.Map <Quaternion>(data); rotationInterpolation.Timestep = timestep; } else { _rotation = UnityObjectMapper.Instance.Map <Quaternion>(data); RunChange_rotation(timestep); } } if ((0x4 & readDirtyFlags[0]) != 0) { if (ownerNetIdInterpolation.Enabled) { ownerNetIdInterpolation.target = UnityObjectMapper.Instance.Map <uint>(data); ownerNetIdInterpolation.Timestep = timestep; } else { _ownerNetId = UnityObjectMapper.Instance.Map <uint>(data); RunChange_ownerNetId(timestep); } } if ((0x8 & readDirtyFlags[0]) != 0) { if (playerIDInterpolation.Enabled) { playerIDInterpolation.target = UnityObjectMapper.Instance.Map <int>(data); playerIDInterpolation.Timestep = timestep; } else { _playerID = UnityObjectMapper.Instance.Map <int>(data); RunChange_playerID(timestep); } } }
public void Init() { Console.WriteLine("Start Test Length!"); len = new Length(1234567); lon = 1234567; }
private ulong Sum1(ulong x) { return(rotateRight(x, 14) ^ rotateRight(x, 18) ^ rotateRight(x, 41)); }