If you are requesting memory from Windows via the API, it sounds like you have not released a previous memory object and thus have corrupted the memory.

What are you using to allocate memory? Windows or malloc()/new?