Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

How can I invoke win32 function pointer with _stdcall type #4137

Closed
zaker139 opened this issue Apr 25, 2020 · 3 comments
Closed

How can I invoke win32 function pointer with _stdcall type #4137

zaker139 opened this issue Apr 25, 2020 · 3 comments

Comments

@zaker139
Copy link

zaker139 commented Apr 25, 2020

I get function pointer from GetProcAddress API.
I want to indicate to use _stdcall type to invoke it. How can I implement it in Kotlin/Native?
Like this:
val handle = LoadLibraryExA("D:\DependLibsX86\skfapi.dll", null, LOAD_WITH_ALTERED_SEARCH_PATH)
val funcAdd = GetProcAddress(handle, "SKF_DisConnectDev")
val actualFunc = funcAdd?.reinterpret<CFunction<(DEVHANDLE?) -> ULONG>>()

How to invode actualFunc with _stdcall flag?

@artdfel
Copy link
Contributor

artdfel commented Apr 27, 2020

Hello! First of all, I got to remind you about Kotlin/Native issue tracker migration(see #4079). Bugs should be reported to the YouTrack, while questions are preferable to be asked on the #kotlin-native slack channel.
In two words, there is no such option for now. As this is a quite uncommon scenario, can you explain a bit deeper - what's the reason behind using calling conventions from K/N?

@zaker139
Copy link
Author

Hello! First of all, I got to remind you about Kotlin/Native issue tracker migration(see #4079). Bugs should be reported to the YouTrack, while questions are preferable to be asked on the #kotlin-native slack channel.
In two words, there is no such option for now. As this is a quite uncommon scenario, can you explain a bit deeper - what's the reason behind using calling conventions from K/N?

Because funcitons in this dll is compiled with _stdcall flag, so if invoke pointer of this function without
_stdcall flag, it just can't work well. About the issue tracker, I get it next time, sorry!

@SvyatoslavScherbina
Copy link
Contributor

Moved to https://youtrack.jetbrains.com/issue/KT-48080, closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants