hm im no coding expert but why do you relocate the vector? and how does that look like in the source?
C++ does this anyway, because the vector needs to grow when you add things to it. I just push the process along and grow it to 1000 entries which is more than I will need and prevents it from up and moving while I am in the middle of using it. This alone isn't a problem and I can continue to use dwarf fortress in any way without a crash, since the entire vector is never freed from memory. When you add jobs from within DF it will allocate them into their own memory and also have no problem freeing them.
A STL vector in MSVC 2010 is 16 bytes. There is a pointer to its base, a pointer to its current position, and a pointer to its highest address, and then 4 bytes of unused padding.
In code, moving it from another process kind of looks like..
const LPVOID lpvResult = VirtualAllocEx(hDF, NULL, 0x20000, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
const uint32_t queuebase = readDWord(queuePointer);
const uint32_t queuepos = readDWord(queuePointer+4);
const uint32_t queuesize = queuepos-queuebase;
const uint32_t queue = (uint32_t *) malloc(queuesize);
ReadProcessMemory(hDF, (void *) queuebase, (void *) queue, queuesize, 0);
WriteProcessMemory(hDF, (void *) lpvResult, (void *) queue, queuesize, 0);
free ((uint32_t *) queue);
writeDWord(queuePointer, (uint32_t) lpvResult);
writeDWord(queuePointer+4, ((uint32_t) lpvResult) + queuesize);
writeDWord(queuePointer+8, ((uint32_t) lpvResult) + 0x0FA0);
writeDWord(queuePointer+12, 0xDEADBEAF);
And of course, the read/write dword code looks kind of like..
uint32_t readDWord(const uint32_t address)
{
uint32_t dword = 0;
ReadProcessMemory(hDF, (void *) address, (void *) &dword, 4, 0);
return dword;
}
bool writeDWord(const uint32_t address, const uint32_t data)
{
return(WriteProcessMemory(hDF, (void *) address, &data, 4, 0));
}
It is all typically stuff we do when we hack games, it is just rare we have to add stuff that the game will want to free later
So now I am studying the internat heap structure of MSVC 2010 and how to add my own allocations to it, lol.