| View previous topic :: View next topic |
| Author |
Message |
ap13ski How do I cheat?
Reputation: 0
Joined: 17 Dec 2020 Posts: 3
|
Posted: Thu Dec 17, 2020 8:17 am Post subject: C# decimal value type (Unity) |
|
|
Hi Dark Byte!
Games developed on the Unity engine are not a surprise to anyone now - they are everywhere.
The main language for Unity engine is C#.
The C# language has a floating-point value type decimal that has a size of 16 bytes (see MSDN).
Quite often game developers use this value type, but due to the unavailability of this value type in the search settings, it is not possible to find addresses with the Cheat Engine directly.
1. Is it possible in the current version of Cheat Engine to somehow search for values of the decimal value type used in C#?
2. Are there any plans to add decimal value type to the standard Cheat Engine set?
P.S. Thanks for everything, Dark Byte! You are my hero!
From Russia with love.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25860 Location: The netherlands
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4725
|
Posted: Thu Dec 17, 2020 1:00 pm Post subject: |
|
|
Looks like neither.
https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=net-5.0
Specifically here:
| Quote: | | The binary representation of a Decimal value consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the 96-bit integer and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10, raised to an exponent ranging from 0 to 28. Therefore, the binary representation of a Decimal value the form, ((-2^96 to 2^96) / 10^(0 to 28)), where -(2^96-1) is equal to MinValue, and 2^96-1 is equal to MaxValue. For more information about the binary representation of Decimal values and an example, see the Decimal(Int32[]) constructor and the GetBits method. |
Decimal (int[] bits); constructor:
| Quote: | bits is a four-element long array of 32-bit signed integers.
bits [0], bits [1], and bits [2] contain the low, middle, and high 32 bits of the 96-bit integer number.
bits [3] contains the scale factor and sign, and consists of following parts:
Bits 0 to 15, the lower word, are unused and must be zero.
Bits 16 to 23 must contain an exponent between 0 and 28, which indicates the power of 10 to divide the integer number.
Bits 24 to 30 are unused and must be zero.
Bit 31 contains the sign; 0 meaning positive, and 1 meaning negative.
A numeric value might have several possible binary representations; all are equally valid and numerically equivalent. Note that the bit representation differentiates between negative and positive zero. These values are treated as being equal in all operations. |
A custom type can be made from this.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Csimbi I post too much
Reputation: 98
Joined: 14 Jul 2007 Posts: 3347
|
Posted: Thu Dec 17, 2020 3:46 pm Post subject: |
|
|
| ParkourPenguin wrote: | | A custom type can be made from this. |
Are you gonna?
An internal type might be a good idea - it's unlikely that it's going to disappear any soon.
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4725
|
Posted: Thu Dec 17, 2020 8:31 pm Post subject: |
|
|
Probably not. It looks annoying to do correctly.
Here's the source code if anyone wants to try:
https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Decimal.cs
Specifically "public static float ToSingle(decimal d)" (Decimal -> float = ConvertRoutine) and "public Decimal(float value)" (float -> Decimal = ConvertBackRoutine).
C#'s Decimal type is a bad implementation of an idea that AFAIK neither has nor will ever have hardware support for. It'll only ever be a custom type.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25860 Location: The netherlands
|
Posted: Fri Dec 18, 2020 3:27 am Post subject: |
|
|
Hint: write a plugin in C# that registers a custom type
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25860 Location: The netherlands
|
|
| Back to top |
|
 |
|