Skip to content

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

Description

@leo-liu

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;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions