Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 12:13 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Feb 18, 2016 8:41 pm 
Offline
New Member

Joined: Thu Feb 18, 2016 8:29 pm
Posts: 2
Hi there, this is my first post on this forum I've been following for quite some time. Recently I got an idea to improve my decisions while playing poker. I've come a long way, but still I'm figuring out some issues. Currently I'm figuring out how to call back into the Qt framework from an Easyhook hooked Qt function, but can't resolve this for some reason. Can you help me out? I tried searching for it, but either I'm not using the right keywords or there's nothing to be found about this subject (highly unlikely).

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);
        }
    }


Top
 Profile  
 
PostPosted: Thu Feb 18, 2016 10:32 pm 
Offline
Site Admin
User avatar

Joined: Sun Feb 24, 2013 9:39 pm
Posts: 642
http://web.archive.org/web/*/codingthewheel.com

Sorry, know nothing about Qt


Top
 Profile  
 
PostPosted: Thu Feb 18, 2016 11:05 pm 
Offline
New Member

Joined: Thu Feb 18, 2016 8:29 pm
Posts: 2
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group