Poker-AI.org Poker AI and Botting Discussion Forum 2016-02-18T23:05:01+00:00 http://poker-ai.org/phpbb/feed.php?f=22&t=2964 2016-02-18T23:05:01+00:00 2016-02-18T23:05:01+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2964&p=6918#p6918 <![CDATA[Re: Calling back into the Qt framework from a hooked functio]]> spears wrote:

http://web.archive.org/web/*/codingthewheel.com

Sorry, know nothing about Qt

Awesome, saw the archive.org link on the forum too. Such a wonderful resource. Too bad you know nothing abou Qt, but there must be someone out there who can help me out :).

I found this code https://searchcode.com/codesearch/view/8384629/ and it looks like they're doing it succesfully (it being calling back into Qt from the hooked function to get extra info from the client) in the QWidgetPrivate_repaint_sys_Hooked function...

Statistics: Posted by stat80 — Thu Feb 18, 2016 11:05 pm


]]>
2016-02-18T22:32:12+00:00 2016-02-18T22:32:12+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2964&p=6917#p6917 <![CDATA[Re: Calling back into the Qt framework from a hooked functio]]> http://web.archive.org/web/*/codingthewheel.com

Sorry, know nothing about Qt

Statistics: Posted by spears — Thu Feb 18, 2016 10:32 pm


]]>
2016-02-18T20:41:13+00:00 2016-02-18T20:41:13+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2964&p=6916#p6916 <![CDATA[Calling back into the Qt framework from a hooked function]]>
I'm hooking into QLabel::paintEvent and in the hook I want to call (for example) the QLabel::text function of the passed in QLabel. Please check the code below.

The hook works, but the moment I call QLabel::text I'm getting an AccessViolationException.

Thanks a million!

PS: I saw codingthewheel.com is down. Such a shame! Is there a mirror of the site?

Currently I have this (c#)

Code:
 [DllImport("Qt5Widgets.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.ThisCall, EntryPoint = "?text@QLabel@@QBE?AVQString@@XZ")]
    protected static extern IntPtr QLabel_text(IntPtr obj);

    [DllImport("Qt5Widgets.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.ThisCall, EntryPoint = "?paintEvent@QLabel@@MAEXPAVQPaintEvent@@@Z")]
    protected static extern void QLabel_paintEvent(IntPtr obj, IntPtr p1);

    [UnmanagedFunctionPointer(CallingConvention.ThisCall, CharSet = CharSet.Unicode, SetLastError = true)]
    delegate void TQLabel_paintEvent(IntPtr obj, IntPtr p1);

    static unsafe void QLabel_paintEvent_Hooked(IntPtr obj, IntPtr p1)
    {
        try
        {
            var ptr = QLabel_text(obj); // <-- I'm getting an AccessViolationException here. Why? And how can I resolve this?
            var str = (QString)Marshal.PtrToStructure(ptr, typeof(QString));
            ((Main)HookRuntimeInfo.Callback).Interface.GotQLabel_paintEvent(str.ToString());
            QLabel_paintEvent(obj, p1);
        }
        catch (Exception ex)
        {
            ((Main)HookRuntimeInfo.Callback).Interface.ErrorHandler(ex);
        }
    }

Statistics: Posted by stat80 — Thu Feb 18, 2016 8:41 pm


]]>