Retrieving a static pointer from a closed-source library, not exposed by
the public interface
I am using a dll which code I cannot change. I have a public interface
that exposes a class Surface that I am using.
The code of the dll contains something similar to this:
static Texture staticTexture[MAXTEXTURECOUNT];
static Texture *staticTextureCurrent = NULL;
static Texture *staticGetTextureById(int id);
class Texture
{
public:
int _id;
...
void *_dib;
...
};
void Surface::DrawSetTexture(int id)
{
Texture *texture = staticGetTextureById(id);
staticTextureCurrent = texture;
}
The Texture class is not exposed in any way by the public header files. I
need to access the memory that is being pointed to by Texture::_dib.
Ideally I would want to be able to call staticGetTextureById from
anywhere, but the memory is what I am after. I do however know more or
less how the Texture class looks like.
I already tried to see if I can recover the Texture pointer by fiddling
with the cpu registers after a call to DrawSetTexture, but that didn't
work out at all.
Any ideas how to retrieve this pointer? I would be glad about any solution
no matter how hacky as long as it doesn't crash and works somewhat
reliably. I need a faster way to draw to that memory then with what I am
given.
No comments:
Post a Comment