Re: Alignment question
From: Aslan Kral (spamtrap_at_crayne.org)
Date: 02/27/05
- Next message: Herman Dullink : "Re: Access more than 1MB in ISA Bus"
- Previous message: Aslan Kral: "Re: Alignment question"
- In reply to: Tim Roberts : "Re: Alignment question"
- Next in thread: Aslan Kral: "Re: Alignment question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 27 Feb 2005 19:41:01 +0000 (UTC)
"Tim Roberts" <spamtrap@crayne.org>, haber iletisinde sunlari
yazdi:aps221hh7o9o2eqkfcebbpib58vm90op9d@4ax.com...
> "kingzog" <spamtrap@crayne.org> wrote:
>
> >Aslan Kral wrote:
> >> The following C++ class is used to jump to the first pointer in the
> >> vtable.
> >> class KWndProc
> >> {
> >> uint32 jmp_buf[3];
> >> protected:
> >> virtual LRESULT WndProc(HWND hWnd,UINT nMessage,WPARAM
> >> wParam,LPARAM lParam)=0;
> >>
> >>
> >> public:
> >> #if 1
> >> KWndProc()
> >> {
> >> jmp_buf[0] = 0xB9909090; // mov ecx,
> >> jmp_buf[1] = (uint32)this;// this
> >
> >
> >In Visual C++, the default for non vararg functions is thiscall, so
> >ecx=this at all times, so you could skip these two lines.
>
> No, you missed the trick here. He is returning the address of this code
in
> the cast to WNDPROC. When it is called as a WNDPROC, it isn't a method
> call, it's a straight C call, so there is no "this" pointer.
>
> >I think you should have a pure C++ version too, so it will build for
> >Win64 - just put in a regular function call, e.g.
>
> I agree. It only takes a couple of lines of code to fetch an instance
> pointer from GetWindowLong, cast it, and call a method. Window message
are
> not called thousands of times per second, so this kind of trickery is not
> worth the maintenance headaches.
> --
I use both technique. I like this one because you simply derive a class from
it with a virtual WndProc member function implemented in it and all set. You
don't need to write a static function for windows procedure. I consider it a
useful thing rather than maintenance headache. I have been using this
technique for some time (2 years or so) and it is OK so far.
> - Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
>
- Next message: Herman Dullink : "Re: Access more than 1MB in ISA Bus"
- Previous message: Aslan Kral: "Re: Alignment question"
- In reply to: Tim Roberts : "Re: Alignment question"
- Next in thread: Aslan Kral: "Re: Alignment question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]