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

x/sys/windows: a way to load dll functions by ordinal (not only by name) #16507

Closed
matwachich opened this issue Jul 27, 2016 · 10 comments
Closed

Comments

@matwachich
Copy link

It would be usefull to be able to load DLL functions by ordinal in syscall package.

Example: to use the SHCreateMemStream function on Windows XP

Thanks :)

@bradfitz bradfitz changed the title syscall: a way to load dll functions by ordinal (not only by name) x/sys/windows: a way to load dll functions by ordinal (not only by name) Jul 27, 2016
@bradfitz
Copy link
Contributor

The syscall package is frozen (see its package docs) but maybe something can be added to the https://godoc.org/golang.org/x/sys/windows package (it's a bug that those docs don't show anything: #16509).

@bradfitz bradfitz added this to the Unreleased milestone Jul 27, 2016
@alexbrainman
Copy link
Member

It would be usefull to be able to load DLL functions by ordinal in syscall package.

I don't see usefulness of that. You have mentioned "SHCreateMemStream", but I have never used that function. What is the problem that you are trying to solve?

And you can do it now. You can copy syscall.GetProcAddress and change the function to pass integer to syscall.Syscall instead of string. I just don't see how this can be used to justify us adding this functionality even in golang.org/x/sys/windows.

Alex

@matwachich
Copy link
Author

SHCreateMemStream is exported by ordinal in WindowsXP. I needed it to
create a memory stream to export/import an in-memory jpeg GpImage.

Finally, I solved the problem by using GlobalAlloc/Free and
CreateStreamFromHGlobal.

Le ven. 5 août 2016 à 07:54, Alex Brainman notifications@github.com a
écrit :

It would be usefull to be able to load DLL functions by ordinal in syscall
package.

I don't see usefulness of that. You have mentioned "SHCreateMemStream",
but I have never used that function. What is the problem that you are
trying to solve?

And you can do it now. You can copy syscall.GetProcAddress and change the
function to pass integer to syscall.Syscall instead of string. I just don't
see how this can be used to justify us adding this functionality even in
golang.org/x/sys/windows.

Alex


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#16507 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtU_uA2harxClZghpKKEdVTEGL5F_Kcks5qct46gaJpZM4JVvOf
.

@alexbrainman
Copy link
Member

SHCreateMemStream is exported by ordinal in WindowsXP.

Do you have some references? Just for my curiosity. Thank you.

I solved the problem by using GlobalAlloc/Free and
CreateStreamFromHGlobal.

Cool. I take it you don't need ability to find DLL procedure by cardinal number then.

Alex

@matwachich
Copy link
Author

Reference: MSDN

In fact, I don't need it anymore but using SHCreateMemStream would have
been easier.

Thanks.

Le Lun 8 Aoû 2016 2:43, Alex Brainman notifications@github.com a écrit :

SHCreateMemStream is exported by ordinal in WindowsXP.

Do you have some references? Just for my curiosity. Thank you.

I solved the problem by using GlobalAlloc/Free and
CreateStreamFromHGlobal.

Cool. I take it you don't need ability to find DLL procedure by cardinal
number then.

Alex


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#16507 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABtU_l3aMWEFRjmRfr1pPHbSQ0xV-tQ4ks5qdonUgaJpZM4JVvOf
.

@alexbrainman
Copy link
Member

Reference: MSDN

How do I use this reference? I was hoping you have some official links on the Internet. I tried implementing this, but I cannot even write a test for it - what should my test do?

Alex

@hillu
Copy link
Contributor

hillu commented Oct 13, 2017

Example: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773795.aspx tells me to import shlwapi.dll:IsOS by ordinal in order to be compatible across OS versions.

@alexbrainman
Copy link
Member

Example: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773795.aspx tells me to import shlwapi.dll:IsOS by ordinal in order to be compatible across OS versions.

@hillu thank you for the reference. I will try to implement this when I have spare time. Unless someone beats me to it.

Alex

@alexbrainman
Copy link
Member

@hillu I have found your CL 70690. I will review it when I have time. Thank you.

Alex

@gopherbot
Copy link

Change https://golang.org/cl/70690 mentions this issue: windows: add GetProcAddressByOrdinal

@golang golang locked and limited conversation to collaborators Oct 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants