digitalmars.D.learn - Some asm help for the 'thiscall' calling convention?
- Andrej Mitrovic (10/10) Apr 23 2011 I'm in the same situation as the person who posted about this 5 years ag...
- Simon (18/28) Apr 23 2011 IASIO is an abstract data type; it's a COM interface.
- Andrej Mitrovic (5/5) Apr 23 2011 Then how come I can create an instance with CoCreateInstance without
- Andrej Mitrovic (6/6) Apr 23 2011 And by calling IASIO.controlPanel(), I mean calling it on the instance.
- Simon (8/14) Apr 24 2011 Not sure how D handles interfaces. If bar is implicitly a pointer
- Kagamin (2/3) Apr 24 2011 COM uses stdcall convention. Everything else is not COM.
- Andrej Mitrovic (1/1) Apr 24 2011 Nevermind guys I'll just use OpenAsio.
- Adam Sansier (5/11) Jul 13 2016 Ignore the fool, mark your functions extern(C++) and it will
- flamencofantasy (2/15) Jul 13 2016 You revived this thread solely to insert a personal attack???
- Adam Sansier (16/32) Jul 13 2016 Um, no, I revived it so that people searching for answers
- flamencofantasy (5/40) Jul 13 2016 You have a nasty attitude and you constantly insult people on
- ethgeh (7/38) Jul 13 2016 Are you sure he's the same ppl ? I had a conversation with
- Adam Sansier (22/62) Jul 16 2016 Well, I'm not sure who all these people are. I figure
- Kagamin (6/8) Jul 14 2016 My word is not COM specification of course, there's the official
- Adam Sansier (17/26) Jul 16 2016 That isn't the point. The point is you make absolute claims that
- Kagamin (7/11) Jul 18 2016 The component must comply with the COM standard to provide a COM
- Andrew Godfrey (10/19) Jul 16 2016 COM is a model; in practice people pick the parts they need, and
- Kagamin (3/5) Jul 18 2016 No need to rename what has a name:
I'm in the same situation as the person who posted about this 5 years ago: http://www.digitalmars.com/d/archives/digitalmars/D/learn/thiscall_calling_convention_4943.html This isn't so much relevant to COM as it is to this ASIO implementation. The issue is that only Microsoft compilers can use the 'thiscall' calling convention which is used with ASIO, while for other compilers your best options are to either use inline assembly when calling functions, or to compile a DLL wrapper using a Microsoft compiler (there's OpenAsio which does exactly that). I could use the OpenAsio DLL wrapper, but I'd like to see if this could be done with inline asm instead. Here's what one call looks like for a C++ Borland compiler (see the Resolver::init wrapper function): http://codepad.org/rArgvPZC In D, I can call a function like IASIO.init() without issues, and some other functions such as "getDriverVersion" which take no parameters will work. But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention. I've attempted to translate this to D's inline asm but I get back access violations. Here's my attempt: http://codepad.org/gFLJ9RJd I admit I barely know much asm but I thought I'd give it a shot. Calling "IASIO.init()" works for me, of course. But calling any IASIO methods which take parameters will fail since parameters are passed differently in the 'thiscall' convention. Anyone know how to translate that asm block to D so it's valid?
Apr 23 2011
On 24/04/2011 02:23, Andrej Mitrovic wrote:I'm in the same situation as the person who posted about this 5 years ago: http://www.digitalmars.com/d/archives/digitalmars/D/learn/thiscall_calling_convention_4943.html This isn't so much relevant to COM as it is to this ASIO implementation. The issue is that only Microsoft compilers can use the 'thiscall' calling convention which is used with ASIO, while for other compilers your best options are to either use inline assembly when calling functions, or to compile a DLL wrapper using a Microsoft compiler (there's OpenAsio which does exactly that). I could use the OpenAsio DLL wrapper, but I'd like to see if this could be done with inline asm instead. Here's what one call looks like for a C++ Borland compiler (see the Resolver::init wrapper function): http://codepad.org/rArgvPZC In D, I can call a function like IASIO.init() without issues, and some other functions such as "getDriverVersion" which take no parameters will work. But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention. I've attempted to translate this to D's inline asm but I get back access violations. Here's my attempt: http://codepad.org/gFLJ9RJd I admit I barely know much asm but I thought I'd give it a shot. Calling "IASIO.init()" works for me, of course. But calling any IASIO methods which take parameters will fail since parameters are passed differently in the 'thiscall' convention. Anyone know how to translate that asm block to D so it's valid?IASIO is an abstract data type; it's a COM interface. you can't declare it as a member of your class as you have done: Your code: class Resolver { IASIO that_; Borland code: class Resolver { IASIO* that_; Notice the * In your code the struct will be 4 bytes long, while the real struct will be a lot bigger. You can never declare any COM interface as a real structure in your code. -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Apr 23 2011
Then how come I can create an instance with CoCreateInstance without the call failing and returning "S_OK" which means the call succeeded, and I can also call void functions like IASIO.controlPanel() and get back this: http://imgur.com/v4Uct
Apr 23 2011
And by calling IASIO.controlPanel(), I mean calling it on the instance. E.g.: class Foo { IASIO bar; // can call bar.controlPanel(); }
Apr 23 2011
On 24/04/2011 03:25, Andrej Mitrovic wrote:And by calling IASIO.controlPanel(), I mean calling it on the instance. E.g.: class Foo { IASIO bar; // can call bar.controlPanel(); }Not sure how D handles interfaces. If bar is implicitly a pointer then the bit where you do: void *this_ = &that_; means you are loading a pointer to a pointer. Try losing the & -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Apr 24 2011
Andrej Mitrovic Wrote:But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.COM uses stdcall convention. Everything else is not COM.
Apr 24 2011
Nevermind guys I'll just use OpenAsio.
Apr 24 2011
On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote:Andrej Mitrovic Wrote:Ignore the fool, mark your functions extern(C++) and it will work. IUnknown uses extern(Windows) while ASIO uses extern(C++) for some reason. It may not be COM in the eyes of God... I mean Kagamin, though.But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.COM uses stdcall convention. Everything else is not COM.
Jul 13 2016
On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote:On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote:You revived this thread solely to insert a personal attack???Andrej Mitrovic Wrote:Ignore the fool, mark your functions extern(C++) and it will work. IUnknown uses extern(Windows) while ASIO uses extern(C++) for some reason. It may not be COM in the eyes of God... I mean Kagamin, though.But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.COM uses stdcall convention. Everything else is not COM.
Jul 13 2016
On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote:On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote:Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything. That's not a personal attack. It's simply pointing out that there is a solution. If it happens to point out that someone makes some blanket statement is an idiot, that's just icing on the cake. We have to point out the idiots so either 1. they stop making such blanket statements and acting like they are correct. 2. People quickly learn not to listen to them. 3. People know their statements are wrong. I wouldn't be in this position if they didn't put me here. I'm sorry if I won't sit idle by and let them spread their ignorance. You may see it as a minor thing, but that your ignorance. I'm sorry if that offends you, are you one of the idiots? I'll be damned if I'm suppose to show humility and they aren't. It's a two way street.On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote:You revived this thread solely to insert a personal attack???Andrej Mitrovic Wrote:Ignore the fool, mark your functions extern(C++) and it will work. IUnknown uses extern(Windows) while ASIO uses extern(C++) for some reason. It may not be COM in the eyes of God... I mean Kagamin, though.But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.COM uses stdcall convention. Everything else is not COM.
Jul 13 2016
On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote:You have a nasty attitude and you constantly insult people on this forum. Whether you call yourself Adam Sansier or Hiemlick Hiemlicker or Joerg Joergonson makes no difference. I wonder why anyone is still willing to interact with you.On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote:Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything. That's not a personal attack. It's simply pointing out that there is a solution. If it happens to point out that someone makes some blanket statement is an idiot, that's just icing on the cake. We have to point out the idiots so either 1. they stop making such blanket statements and acting like they are correct. 2. People quickly learn not to listen to them. 3. People know their statements are wrong. I wouldn't be in this position if they didn't put me here. I'm sorry if I won't sit idle by and let them spread their ignorance. You may see it as a minor thing, but that your ignorance. I'm sorry if that offends you, are you one of the idiots? I'll be damned if I'm suppose to show humility and they aren't. It's a two way street.On Sunday, 24 April 2011 at 22:09:24 UTC, Kagamin wrote:You revived this thread solely to insert a personal attack???Andrej Mitrovic Wrote:Ignore the fool, mark your functions extern(C++) and it will work. IUnknown uses extern(Windows) while ASIO uses extern(C++) for some reason. It may not be COM in the eyes of God... I mean Kagamin, though.But trying to use functions which take parameters will fail with an access violation, probably because D uses stdcall for COM methods, while these ASIO COM methods need to be called with 'thiscall' convention.COM uses stdcall convention. Everything else is not COM.
Jul 13 2016
On Wednesday, 13 July 2016 at 23:06:44 UTC, flamencofantasy wrote:On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:Are you sure he's the same ppl ? I had a conversation with "Hiemlick Hiemlicker" a month ago and the guy didn't seem to be as biased as this one. That said if you search "Joerg Joergonson" there's a match for a related Topic (COM & asio). My guess is that this guy is an addicted, most of the time the conversations are OK but when he's high he sucks a lot.On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote:You have a nasty attitude and you constantly insult people on this forum. Whether you call yourself Adam Sansier or Hiemlick Hiemlicker or Joerg Joergonson makes no difference. I wonder why anyone is still willing to interact with you.On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote:Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything. That's not a personal attack. It's simply pointing out that there is a solution. If it happens to point out that someone makes some blanket statement is an idiot, that's just icing on the cake. We have to point out the idiots so either 1. they stop making such blanket statements and acting like they are correct. 2. People quickly learn not to listen to them. 3. People know their statements are wrong. I wouldn't be in this position if they didn't put me here. I'm sorry if I won't sit idle by and let them spread their ignorance. You may see it as a minor thing, but that your ignorance. I'm sorry if that offends you, are you one of the idiots? I'll be damned if I'm suppose to show humility and they aren't. It's a two way street.[...]You revived this thread solely to insert a personal attack???
Jul 13 2016
On Thursday, 14 July 2016 at 00:51:16 UTC, ethgeh wrote:On Wednesday, 13 July 2016 at 23:06:44 UTC, flamencofantasy wrote:Well, I'm not sure who all these people are. I figure flamencofantasy and ethgeh are alias too! Regardless, I treat people like they treat others. I may seem I like go overboard, it is possible, but it's only because of the butterfly effect! ;) I'd rather make it painfully obvious to them that they way they approach people is wrong than ignore it(then things only fester, look at the world today). Hopefully Make, Kagamin, Ketmar, and any others I've offended will grow up a little and realize the way they approach helping people is not necessarily the best it can be. Making absolute statements rarely help(mostly because they don't even know absolute what they are talking about, they only make absolute assumptions). Also, in some cases, they quickly ignore the persons own experience and write them off in an extremely arrogant way(Ketmar is good at this). Even if that is not arrogant, it is wrong. Every persons experiences are valid, even if they are not as "intelligent" as the next guy(not everyone gets to or wants to spend 100K hours of their life sitting in front of a computer screen). Sometimes people just need the shit slapped out of them, simple as that, they'll get over it.On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:Are you sure he's the same ppl ? I had a conversation with "Hiemlick Hiemlicker" a month ago and the guy didn't seem to be as biased as this one. That said if you search "Joerg Joergonson" there's a match for a related Topic (COM & asio). My guess is that this guy is an addicted, most of the time the conversations are OK but when he's high he sucks a lot.On Wednesday, 13 July 2016 at 22:09:05 UTC, flamencofantasy wrote:You have a nasty attitude and you constantly insult people on this forum. Whether you call yourself Adam Sansier or Hiemlick Hiemlicker or Joerg Joergonson makes no difference. I wonder why anyone is still willing to interact with you.On Wednesday, 13 July 2016 at 20:39:00 UTC, Adam Sansier wrote:Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything. That's not a personal attack. It's simply pointing out that there is a solution. If it happens to point out that someone makes some blanket statement is an idiot, that's just icing on the cake. We have to point out the idiots so either 1. they stop making such blanket statements and acting like they are correct. 2. People quickly learn not to listen to them. 3. People know their statements are wrong. I wouldn't be in this position if they didn't put me here. I'm sorry if I won't sit idle by and let them spread their ignorance. You may see it as a minor thing, but that your ignorance. I'm sorry if that offends you, are you one of the idiots? I'll be damned if I'm suppose to show humility and they aren't. It's a two way street.[...]You revived this thread solely to insert a personal attack???
Jul 16 2016
On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything.My word is not COM specification of course, there's the official documentation and tons of books about COM, what one prefers, they all say the same thing, one doesn't need to trust me on that. This one is a particularly good read: https://www.amazon.com/Inside-Microsoft-Programming-Dale-Rog rson/dp/1572313498/ explains all fundamentals of COM.
Jul 14 2016
On Thursday, 14 July 2016 at 14:01:29 UTC, Kagamin wrote:On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:That isn't the point. The point is you make absolute claims that are obviously not true. It is a personality deficiency you have, not about trust. It's like if you claim all prime numbers are odd, state it as absolute fact, then when someone says "Hey, I found a prime number that is even" you automatically assume they must be wrong. Instead of looking at it as objectively. All it does is lead to confusion. Unless you know something to be absolute fact, don't state it as such then don't pretend it to be such... Your still doing that by trying to show "proof" that you are right. Yet you are wrong. Regardless what the asio standard does right or wrong, it uses COM, correct? Is asio not well established? Yes it is. Hence it proves that not all COM is as you think it is. Just accept it, learn that there are no absolutes and that you can be wrong, and the world would be a better place.Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything.My word is not COM specification of course, there's the official documentation and tons of books about COM, what one prefers, they all say the same thing, one doesn't need to trust me on that. This one is a particularly good read: https://www.amazon.com/Inside-Microsoft-Programming-Dale-Rog rson/dp/1572313498/ explains all fundamentals of COM.
Jul 16 2016
On Saturday, 16 July 2016 at 20:31:25 UTC, Adam Sansier wrote:Yet you are wrong. Regardless what the asio standard does right or wrong, it uses COM, correct? Is asio not well established? Yes it is. Hence it proves that not all COM is as you think it is.The component must comply with the COM standard to provide a COM interface, just using COM somehow somewhere is not enough for it. The absolute fact is the COM specification, not my words. If you don't like what the COM specification says, argue with it, not with me. I suppose ASIO is whatever compiled on the developer's machine, he didn't bother about COM.
Jul 18 2016
On Thursday, 14 July 2016 at 14:01:29 UTC, Kagamin wrote:On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:COM is a model; in practice people pick the parts they need, and often still call it "COM". I see it used all the time between components that are built with the same compiler build, and so can be lax about calling convention. I've also seen cases with QueryInterface but lacking AddRef and Release, and I've seen the reverse. All of these were called "COM" by many people. So even if there's some ISO standard saying that COM must include all these elements, saying "everything else is not COM" would hinder communication.Um, no, I revived it so that people searching for answers wouldn't be led astray by idiots who pretend to know everything.My word is not COM specification of course, there's the official documentation and tons of books about COM, what one prefers, they all say the same thing, one doesn't need to trust me on that. This one is a particularly good read: https://www.amazon.com/Inside-Microsoft-Programming-Dale-Rog rson/dp/1572313498/ explains all fundamentals of COM.
Jul 16 2016
On Saturday, 16 July 2016 at 21:16:29 UTC, Andrew Godfrey wrote:COM is a model; in practice people pick the parts they need, and often still call it "COM".No need to rename what has a name: https://en.wikipedia.org/wiki/Interface-based_programming
Jul 18 2016