That is, if you don't lock/unlock bmap.

Engine is supposed to fill finalbits when the bmap is locked. When you unlock the bmap it should read the finalbits and change the bitmap. This is the part that is not working.

When you don't lock/unlock bmap engine does not change the finalbits. Whatever you put there you get it back.

I get the feeling even if i lock/unlock bmap i still get some different memory field that is not the real finalbits. Engine never modifies the data in the field we are looking at.(F.i) it should be empty when bmap is locked, and it should have bits when it's locked. With the above code it always gets the same value wether bmap is locked or not. Could be an engine bug. I will try different stuff now.

i wrote the following function in a c++ dll, and pinvoked it from c# as a workaround.

Code:
extern "C" __declspec(dllexport) void setFinalBits(BMAP* bmap,byte* data,int size)
{
	bmap_lock(bmap,0);
	memcpy(bmap->finalbits,data,size);
	bmap_unlock(bmap);
}




3333333333