VOGONS


First post, by Sevirman

User metadata
Rank Newbie
Rank
Newbie

Hey Dege. Long time ago i have asked for help to solve Turok's stucked colors+ memory overflow bug, you said that you can look into it at some spare time and asked for modified Video_D3D.dll.
I've sent files at 7th January and still was no any answer. I just want to know if you still remember about this.
Sorry for pushing this as topic.

Reply 2 of 5, by Dege

User metadata
Rank l33t
Rank
l33t
Sevirman wrote on 2025-03-21, 16:33:

Hey Dege. Long time ago i have asked for help to solve Turok's stucked colors+ memory overflow bug, you said that you can look into it at some spare time and asked for modified Video_D3D.dll.
I've sent files at 7th January and still was no any answer. I just want to know if you still remember about this.
Sorry for pushing this as topic.

Hi, yes, sorry, I looked into and forgot about it.
The problem is, textures are created but not released properly.
The game (or your code, I can't remember exactly) queries for interfaces like IDirectDrawSurface and IDirect3DTexture, for each texture, and only one of the interfaces is released (I also don't remember) that's why the texture objects survive and leak away.

Reply 3 of 5, by Sevirman

User metadata
Rank Newbie
Rank
Newbie
Dege wrote on 2025-03-30, 15:37:

Hi, yes, sorry, I looked into and forgot about it.
The problem is, textures are created but not released properly.
The game (or your code, I can't remember exactly) queries for interfaces like IDirectDrawSurface and IDirect3DTexture, for each texture, and only one of the interfaces is released (I also don't remember) that's why the texture objects survive and leak away.

Yes, yes, i had that guess. Thats a part of original bug that i trying to fix but sadly don't have enough skill to debug api. How to properly release a memory here?

Reply 4 of 5, by Dege

User metadata
Rank l33t
Rank
l33t

Texture objects are COM objects so they have interfaces referring to them, each interface with one reference count. Each interface inherits from the IUnknown interface.

Each time you query an interface through IUnknown::QueryInterface (which increments the ref count), you should call IUnknown::Release on the queried interface to decrease the ref count.
The same is true for IUnknown::AddRef, which increments the refcount of a given interface instance.

The game factors a texture surface, so it has IDirectDrawSurface* (I can't remember which version) and later calls IDirectDrawSurface*::QueryInterface to get an IDirect3DTexture* interface.
Both interface instances are referring to the same object but ::Release is called only on one of them, so the object remain alive.

If you debug with MS ddraw and d3d then you can download symbol files for them in the debugger (ddraw.dll, d3dimm.dll, maybe d3d700.dll), so you can see where the IUnknown calls are made, and insert the missing Release somehow into the code.

Reply 5 of 5, by Sevirman

User metadata
Rank Newbie
Rank
Newbie
Dege wrote on 2025-03-30, 18:12:

If you debug with MS ddraw and d3d then you can download symbol files for them in the debugger (ddraw.dll, d3dimm.dll, maybe d3d700.dll), so you can see where the IUnknown calls are made, and insert the missing Release somehow into the code.

I have tried to mess around once more, but as i said its currently out of my skill bounds, i don't know how to properly debug such things and all my attempts led to nothing. It's like shooting in the dark.

I can see QueryInterface and CreateSurface debug strings but have no idea what to do further, associated memory addresses leads to DDraw or D3DImm or Video_D3D.

I have checked functions you mentioned, all "Unknown" ones is never used, but i have found calls to DirectDraw::CreateSurface, DirectDrawSurface::QueryInterface and DirectDrawSurface::Release.

I've also found a small conditional function that is relative to texture updating, its first uses a call to Video_D3D and then uses DirectDraw::CreateSurface. Maybe i should try to put something in there? Not sure how to handle it because input values required. As random attempt i've tried to just copy input values from CreateSurface and uses them with DirectDrawSurface::Release, but ofc it leads to a crash.

Would be extremely helphul if you just point me to where and what should i put into memory to fix that issue. If no - then i hoping for your further assistance.