This may have previously been answered but I can't find it.
On Day 023 the point was made that the looped live code only worked because we had a fixed virtual base address (2TB) as below:
1 2 3 4 5
#if HANDMADE_INTERNAL LPVOID BaseAddress = (LPVOID)Terabytes(2); #else LPVOID BaseAddress = 0; #endif
I'm struggling to understand why - given that the VirtualAlloc will return the address to the Win32State regardless:
Win32State.GameMemoryBlock = VirtualAlloc(BaseAddress, (size_t)Win32State.TotalSize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
So it would seem the game DLL when loaded would always get a correct pointer to this base address despite the fact that the address may vary each time the game is started. The same would go for the writing and reading of the memory block to disk.
I understand that if a pointer was referencing a particular memory location and the contents moved to a different location that this would break the code - but I can't see how this happens?
I'm sure I'm missing something so any comments or examples would be great.