public static PyLongObject Create(DkmProcess process, BigInteger value) { var allocator = process.GetDataItem <PyObjectAllocator>(); Debug.Assert(allocator != null); var bitsInDigit = process.Is64Bit() ? 30 : 15; var bytesInDigit = process.Is64Bit() ? 4 : 2; var absValue = BigInteger.Abs(value); long numDigits = 0; for (var t = absValue; t != 0;) { ++numDigits; t >>= bitsInDigit; } var result = allocator.Allocate <PyLongObject>(numDigits * bytesInDigit); if (value == 0) { result.ob_size.Write(0); } else if (value > 0) { result.ob_size.Write(numDigits); } else if (value < 0) { result.ob_size.Write(-numDigits); } if (bitsInDigit == 15) { for (var digitPtr = new UInt16Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1)) { digitPtr.Write((ushort)(absValue % (1 << bitsInDigit))); absValue >>= bitsInDigit; } } else { for (var digitPtr = new UInt32Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1)) { digitPtr.Write((uint)(absValue % (1 << bitsInDigit))); absValue >>= bitsInDigit; } } return(result); }
public ulong EvaluateReturnValueUInt64() { return(EvaluateUInt64(_process.Is64Bit() ? "@rax" : "@eax")); }
public ReprOptions(DkmProcess process) { Is64Bit = process.Is64Bit(); LanguageVersion = process.GetPythonRuntimeInfo().LanguageVersion; }
public static byte GetPointerSize(this DkmProcess process) { return(process.Is64Bit() ? (byte)8 : (byte)4); }