1

I wrote an application in C#.Net with a simple double variable which get changed on run-time. My goal is to read this variable from another program. So I had a look on the memory with ArtMoney to get the memory-address. But the address of my variable changes on run-time. Can anyone tell me why?

Memory on the locations

On both tries the address changed two times and gets then stady. The first two bytes of the address changed on both tries the same but the next bytes are at every start of the application different.

  • Why do the address change two times on runtime?
  • How chan I determ the "offset" of the addres?
Ivar
  • 6,138
  • 12
  • 49
  • 61
Brunousi
  • 23
  • 3
  • 4
    There are many possibilities here but simple things as timing and [ASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization) could be at work here. On the other hand, nobody has guaranteed that memory allocations across multiple runs will end up using the same address so it doesn't really matter why this happens. It does, deal with it. – Lasse V. Karlsen Jun 13 '17 at 12:31
  • 1
    What you want is IPC: https://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro – adjan Jun 13 '17 at 12:33
  • Seeing your code may be useful to make any informed response but Marc's answer below is likely to be correct. – PaulF Jun 13 '17 at 12:37
  • From my experience of making trainers for games i know that there might be a series of pointers that end up at an address which is static – ikari.shinji Jun 13 '17 at 14:34

1 Answers1

10

"because it is allowed to"; .NET doesn't make any guarantees about where things are in memory, unless you (either):

  • allocate managed memory and pin it
  • allocate unmanaged memory

and you'll notice that in both of those cases, it isn't fixed between runs - it is only fixed for the duration of a run.

Basically: find a different way to communicate between processes. Raw memory offset lookups: will not work here.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900