Question

I'm trying to write a forwarding library for libEGL.dll so I can catch calls being passed through it for debug.

The problem is the library is missing 2 methods NvEglGetStdProcAddress and NvEglRegClientApi.

This is a C library built for Arm7 (WinCE). The header file I have for libEGL doesn't include these 2 methods so I have no idea what the signature is in order to forward the calls.

Is there any way of forwarding the calls without knowing the signature? Could I disassemble the dll and look for the parameters being popped from the stack?

DumpBin shows these at RVA 0x217C and Ox1E5C, /ALL /DISASM shows the .text section starting at 0x11000. How do I translate between these two offsets?

I'm guessing this wouldn't work, Would it just leave the parameters on the stack and then mangle them slightly with the local variable? What would happen to the return value (if there is one?)

typedef void (*NvEglGetStdProcAddressFunc) (void);
void NvEglGetStdProcAddress()
{
    NvEglGetStdProcAddressFunc ptr = (NvEglGetStdProcAddressFunc)GetProcAddress(hInst, _T("NvEglGetStdProcAddress"));
    ptr();
}
Was it helpful?

Solution

You can simply forward export calls.

So my debug libEGL.dll .def file now has two extra lines at the top of it

; libEGL.def
EXPORTS
  NvEglGetStdProcAddress = libEGLOld.NvEglGetStdProcAddress 
  NvEglRegClientApi = libEGLOld.NvEglRegClientApi
  eglBindAPI
  eglBindTexImage
  ...

A colleague of mine tested this and verified it works, although it also requires the ordinal to be specified

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top