mikeash.com pyblog/hacking-c-from-c.html commentshttp://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsmikeash.com Recent CommentsThu, 28 Mar 2024 18:39:40 GMTPyRSS2Gen-1.0.0http://blogs.law.harvard.edu/tech/rssmikeash - 2009-11-06 17:21:51http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsWell, it took me an absurdly long time, but the site now uses a floating div for the menu instead of table-based layout. This means that wide code in pre blocks will no longer cause the entire page to be widened, as would happen previously. <br /> <br />Thanks for giving me the impetus to get this fixed, guys.159cb770e866f35bb2d3c8d617b26e40Fri, 06 Nov 2009 17:21:51 GMTRon - 2009-11-04 09:15:11http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsany reason this page is formatted strangely? I have to scroll to the right to read it all in Opera 10.699569a4a10fbb9be9abc0817ba592afWed, 04 Nov 2009 09:15:11 GMTmikeash - 2009-11-04 02:50:16http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsIs passing <code>this</code> in ECX a feature of Visual Studio only, or is it part of the Windows ABI in general? Or to put it another way, are VS-generated C++ object files compatible with, say, gcc-generated ones on Windows?e0b353d1b98c08de111f3208aa2569a4Wed, 04 Nov 2009 02:50:16 GMTRamsey Stone - 2009-11-04 02:21:37http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsThis behavior is highly compiler specific. For instance, in Visual Studio compiled binaries, the this pointer is passed to member functions in the ECX register, not on the stack. You can emulate this doing something like: <br /> <br />void __fastcall Class__member(void *this, void *unused, int arg1, int arg2, int arg3); <br /> <br />__fastcall is a calling convention where the first two arguments are passed in through the ECX and EDX registers. This becomes incredibly useful when hooking C++ member functions.3db4bb865385e4d0ba70862c230f3f95Wed, 04 Nov 2009 02:21:37 GMTRichard Marston - 2009-11-03 22:13:24http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsIf you wish to demangle c++ symbol names, the command c++filt is useful: <br />rich@rich-laptop:~$ c++filt <br />_ZN5khtml12RenderObject9setPixmapERK7QPixmapRK5QRectPNS_11CachedImageE <br />khtml::RenderObject::setPixmap(QPixmap const&amp;, QRect const&amp;, khtml::CachedImage*) <br />e8345474cd307dba72dfff1e793223fbTue, 03 Nov 2009 22:13:24 GMTmikeash - 2006-11-19 02:35:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsI have no idea if it&amp;#8217;s illegal in C++, but this is all pure C code so that is not a concern. As to whether it&amp;#8217;s legal in standard C, I couldn&amp;#8217;t tell you for sure, but I know that gcc accepts this code and that&amp;#8217;s good enough for me. This kind of hackery is never going to be portable so there&amp;#8217;s little point in making it work on obscure compilers the code will never encounter anyway. <br />a935005fd900b005f2012eb8e83fe999Sun, 19 Nov 2006 02:35:00 GMTMorpheus - 2006-11-17 20:29:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsi thought it was illegal in c++ to use typedef in a function definition <br />9e78ab1203f41cfea0bb0810914aa3eeFri, 17 Nov 2006 20:29:00 GMTChris - 2006-08-04 20:13:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsAh, ok. Well, as I said before, great work anyways!!! It was fun to read and very interesting! <br />0e1b47d8500a4574b031c35f2b85aa94Fri, 04 Aug 2006 20:13:00 GMTmikeash - 2006-08-04 17:54:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsChris,&lt;br /&gt; <br />&lt;br /&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;Because WebKit source code is fairly new. At the time I wrote this, WebKit (not to be confused with WebCore) was not open source. WebCore was, but I couldn&amp;#8217;t use it directly since it was only designed to be used from WebKit. <br />4e0c0e48b9b417f1fe90713fa4b0bfebFri, 04 Aug 2006 17:54:00 GMTChris - 2006-08-04 10:00:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsHey, great article!&lt;br /&gt; <br />Perhaps I&amp;#8217;m not getting the point, but I&amp;#8217;m wondering why you don&amp;#8217;t just use the public available WebKit source code. <br />ca16f1cf806e3a9c3533153dab76c810Fri, 04 Aug 2006 10:00:00 GMTRosyna - 2006-08-03 21:46:00http://www.mikeash.com/?page=pyblog/hacking-c-from-c.html#commentsThere is a special place in hell reserved for people like you. <br />d8aec77962bebdbb30607eb61b7dea04Thu, 03 Aug 2006 21:46:00 GMT