Domanda

Following on from this question, I need to set some memory values to strings, rather than longs. I noticed from using Cheat Engine that if I set a value of an address to a string via browsing the memory region, there is an integer value, such as "6513249" being "abc".

How would I go about converting a string to this form, for use as a long?

Thanks.

È stato utile?

Soluzione

Convert string to byte array with proper encoding using Encoding.GetBytes and than write bytes directly, you may not need to convert to longs afterall.

If you have to convert to longs - make sure you are understand endiannes to know what bytes should be first, again figure out encoding and convert characters (potentially including surrogate pairs) to byte array with Encoding.GetBytes and combine long values out of every 8 bytes by using shift operators (>> and <<) on bytes. It may be easier to wrap resulting byte array in MemeoryStream and than BinaryReader and read long values.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top