Topic: Thunk class for interoperating with C APIs


Author: Lawrence Crowl <crowl@googlers.com>
Date: Tue, 20 Nov 2012 19:21:42 -0800
Raw View
On 11/4/12, DeadMG <wolfeinstein@gmail.com> wrote:
> I'm open for alternative names. Ultimately, I'm perfectly happy to bikeshed
>
> all day, as long as we actually have the shed, as it were. bound_function
> sounds fairly good to me.
>
> Indeed, I have had *significant *trouble making the extern "C" calling
> convention work. It appears that the Standard has a blanket ban on any
> members declaring anything with anything to do with extern "C", ever,
> making it impossible to declare the return type. The closest I could get
> was a template alias in global scope, and that only worked on one of the
> two major compilers with that feature. I'm happy enough that that issue has
>
> been resolved- after all, if you're Visual Studio, you can just make it a
> regular function pointer and don't need to bother, as that compiler does
> not have extern "C" calling conventions.
>
> After the miserable fail which was posting HTML in the original post, I
> have instead decided to link to my website where the proposal is hosted,
> and attach an unstyled version here.
> http://codepuppy.co.uk/ThunkProposal.aspx

Any formal proposal should address security issues.  My understanding
is that gcc's equivalent feature is often disabled to prevent injecting new
code into binaries.

>
> On Sunday, November 4, 2012 9:21:19 PM UTC, Jens Maurer wrote:
>>
>> On 11/03/2012 10:36 PM, DeadMG wrote:
>> > Perhaps it does. The C calling convention part of the C++ Standard, I
>> have never even seen the syntax for that section.
>>
>> I've got slight troubles parsing that sentence.  Anyway, section 7.5 of
>> C++11 talks
>> about language linkage, including C language linkage. ("language linkage"
>>
>> is the
>> C++ standardese phrase for "calling convention".)
>>
>> Re naming: Thanks for the history lesson on "thunk".  What about
>> "bound function", since this is actually what you seem to be producing?
>> (It's not an arbitrary fixup (such as vtable offset adjustment) prior to
>> passing control to another function.)
>>
>> Jens
>>
>>
>
> --
>
>
>
>


--
Lawrence Crowl

--




.


Author: DeadMG <wolfeinstein@gmail.com>
Date: Wed, 21 Nov 2012 03:00:42 -0800 (PST)
Raw View
------=_Part_316_2517159.1353495642622
Content-Type: text/plain; charset=ISO-8859-1

GCC's nested functions are implemented by marking the stack as executable.
This definitely is not implemented that way- a separate page is allocated
which is marked as executable.

Managed language implementations like .NET and Java use this exact
technique, and I'm not aware of any security issues which have developed as
a result.

--




------=_Part_316_2517159.1353495642622
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

GCC's nested functions are implemented by marking the stack as executable. =
This definitely is not implemented that way- a separate page is allocated w=
hich is marked as executable.<div><br></div><div>Managed language implement=
ations like .NET and Java use this exact technique, and I'm not aware of an=
y security issues which have developed as a result.</div>

<p></p>

-- <br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_316_2517159.1353495642622--

.