LD_PRELOAD custom libraries

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
redst
Newbie
Newbie
Posts: 2
Joined: Mon May 23, 2016 9:18 am

LD_PRELOAD custom libraries

Post by redst »

I'm trying to override GetCursorPos from user32, to always return the same point (and do more complex stuff in the future). At first I tried to use LD_PRELOAD with a simple .so file that only implemented that function:

Code: Select all

/* wov.c */
#include <wtypes.h>

WINUSERAPI BOOL WINAPI GetCursorPos(LPPOINT p)
{
    if(p) {
        p->x = 100;
        p->y = 100;
    }
    return TRUE;
}
I'm compiling it with winegcc, both a 32 and 64 bit version and I have them symlinked in /usr/lib32/wov.so and /usr/lib/wov.so respectively, to verify that it was being found and loaded I added a _init() just to inform me, but GetCursorPos doesn't return that fixed point, it's as if the function is not being replaced.

So I took a more aggressive approach and built wine from source, 32 and 64 bit versions, with the original GetCursorPos edited to do the same trick, return always the (100,100) point. I symlinked the resulting .so files to /usr/lib32/wov2.so and /usr/lib/wov2.so, just to check that LD_PRELOAD wasn't being thrown away .And indeed this worked, but it's far from ideal, I looked into the Makefiles and changed my custom library's compilation flags, but I can't get it to work.

So my question is, what's the best way to, with portability in mind, override a single function from a built-in .so like user32, and where's the difference that makes LD_PRELOAD take wov2.so into account but not wov.so?
Locked