It is currently Mon Dec 10, 2018 1:31 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 9:29 am 
Offline
New User
New User

Joined: Fri May 04, 2018 9:24 am
Posts: 4
Hi all,

is it possible to export function in a PureBasic DLL with a decorated name?

In C++ you could export EnableProductSupport as:

Code:
C++:         void __cdecl product::common::EnableProductSupport(void)
undecorated: ?EnableProductSupport@common@product@@YAXXZ


If I wanted to export that in my PureBasic DLL, how could I do that?

Thank you very much!


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 9:35 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 709
Location: Berlin and Ibiza
Do you mean ProcedureDLL or ProcedureCDLL? http://www.purearea.net/pb/english/manu ... e/dll.html

_________________
ImageImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 9:41 am 
Offline
New User
New User

Joined: Fri May 04, 2018 9:24 am
Posts: 4
The calling convention is not really the problem. It could either be stdcall or cdecl.

My trouble is defining the function name to reflect the C++ representation to be able to decorate it accordingly.

Code:
  ProcedureCDLL product::common::EnableProductSupport()
    ; perform some magic ...
  EndProcedure


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 2:41 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
How is this not handled with header files?
Code:
extern "C" {
  #include "myPBdll.h" //a C header, so wrap it in extern "C"
}

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 3:00 pm 
Offline
New User
New User

Joined: Fri May 04, 2018 9:24 am
Posts: 4
@Skywalk:
What do you mean by "not handled"?

To interoperate with another application I need to create a DLL that exports the described functionname. I cannot change the name and I don't know how to export decorated names with PureBasic, that's why I asked.


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 3:03 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13423
Location: France
I don't think you can do that, it's a C++ mangling and PB doesn't support support this when creating a DLL. The closer I could think of is to create a thin wrapper in C++ (another DLL) which will call your DLL.


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 3:54 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
Losee wrote:
@Skywalk:
What do you mean by "not handled"?

To interoperate with another application I need to create a DLL that exports the described functionname. I cannot change the name and I don't know how to export decorated names with PureBasic, that's why I asked.
The C++ application needs to be recompiled with the appropriate header information to call a C or PB function. If you are saying the C++ application cannot be recompiled, then you have to use other means of interprocess communication like the Clipboard or SendMessage(hwDispatch, WM_COPYDATA, hWnd, &MyCDS).

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: [DLL] Exporting a Function with a decorated name
PostPosted: Fri May 04, 2018 3:57 pm 
Offline
New User
New User

Joined: Fri May 04, 2018 9:24 am
Posts: 4
OK, that's what I thought. My workaround at the moment was to compile my DLL and then use "CFF Explorer" to manually change the Function name to reflect that of the decorated function.

Thanks again.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye