Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DLL ordinal value function #638

Closed
kobevaliant opened this issue Apr 13, 2016 · 6 comments
Closed

Support DLL ordinal value function #638

kobevaliant opened this issue Apr 13, 2016 · 6 comments

Comments

@kobevaliant
Copy link

As we know, VC can hide function name in dll by ordinal value. I have checked the source code.

w32_find_entry(JNIEnv* env, HANDLE handle, const char* funname) {
  void* func = NULL;
  if (handle != GetModuleHandle(NULL)) {
    func = GetProcAddress(handle, funname);
  }
  else {

So I request a feature about ordinal value function support. Thank you.

@twall
Copy link
Contributor

twall commented Apr 14, 2016

Why is a FunctionMapper not sufficient for this purpose?

On Apr 13, 2016, at 5:22 AM, kobevaliant [email protected] wrote:

As we know, VC can hide function name in dll by ordinal value. I have checked the source code.

w32_find_entry(JNIEnv* env, HANDLE handle, const char* funname) {
void* func = NULL;
if (handle != GetModuleHandle(NULL)) {
func = GetProcAddress(handle, funname);
}
else {

So I request a feature abount ordinal value function support. Thank you.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@kobevaliant
Copy link
Author

Because FunctionMapper can only translate function name, But ordinal value is not a string type.
According to
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx

FARPROC WINAPI GetProcAddress(
  _In_ HMODULE hModule,
  _In_ LPCSTR  lpProcName
);

lpProcName [in]

The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero.

@twall
Copy link
Contributor

twall commented Apr 26, 2016

You should be able to make this work by writing a mapping for GetProcAddress() which takes an int/long ordinal as the second parameter, and then use the returned Pointer as the basis to create a Function object. I don’t think there’d have to be any native code involved.

On Apr 21, 2016, at 2:59 AM, kobevaliant [email protected] wrote:

Because FunctionMapper can only translate function name, But ordinal value is not a string type.
According to
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx

FARPROC WINAPI GetProcAddress(
In HMODULE hModule,
In LPCSTR lpProcName
);

lpProcName [in]

The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

@kobevaliant
Copy link
Author

Ok I see, Thank you.

@bwRavencl
Copy link

bwRavencl commented Jun 6, 2016

I require the same feature.
@kobevaliant did @twall's proposal work for you?
And how exactly can the function object be created from the pointer returned by GetProcAddress()?

Edit: The proposal indeed works.
Dirty example for anyone in need:

private interface Kernel32 extends Library {
    public Pointer GetProcAddress(HMODULE hModule, long lpProcName);
}

...

Native.loadLibrary("xinput1_3.dll", Library.class);
HMODULE hModule = com.sun.jna.platform.win32.Kernel32.INSTANCE.GetModuleHandle("xinput1_3.dll");
Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class);
Function function = Function.getFunction(kernel32.GetProcAddress(hModule, 100));
function.invoke(new Object[] { controllerId, cs });

matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 29, 2016
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 29, 2016
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 29, 2016
@matthiasblaesing
Copy link
Member

Needed basic functions were merged as #705, #689 (comment) describes a way and provides code how this basic work can be used to create interface based bindings to ordinal value functions.

mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024
Motivation:

A new netty release was done

Modifications:

Upgrade to netty 4.1.104.Final

Result:

Use latest netty version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants