MemoryModule icon indicating copy to clipboard operation
MemoryModule copied to clipboard

MemoryGetProcAddress fails to import a function by ordinal number if dll has no exported names

Open leo-liu opened this issue 5 years ago • 1 comments

I debugged the function and noticed:

    if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0) {
        // DLL doesn't export anything
        SetLastError(ERROR_PROC_NOT_FOUND);
        return NULL;
    }

A dll may have no exported names, but has a set of private exported functions with no expoted names. Thus, NumberOfNames == 0 while NumberOfFunctions > 0 cannot impliy that DLL doesn't export anything.

Maybe the code above should be changed to

    if (exports->NumberOfFunctions == 0) {
        // DLL doesn't export anything
        SetLastError(ERROR_PROC_NOT_FOUND);
        return NULL;
    }

leo-liu avatar May 14 '20 13:05 leo-liu

See https://github.com/fancycode/MemoryModule/pull/96/files

Elmue avatar Jun 22 '20 17:06 Elmue