Sign in to follow this  
Followers 0
civilcalc

Easyhook and dll injection

20 posts in this topic

Ok so this is for a poker related project. But before anyone gets excited, its NOT for a bot, cheating or anything else in voilation of Autoits rules. So sit back down and try and help me if you can.

First take a look at this post from twoplustwo

http://forumserver.twoplustwo.com/45/software/new-free-software-ipoker-bb-mod-convert-table-values-bigblinds-1123532/

this is the source code, and it uses the easyhook library which includes an exe and dll file.

using System;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
using EasyHook;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
namespace IPokerBBMod
{
    public class Program : System.Windows.Forms.Form
    {
        private GroupBox Settings;
        private CheckBox startHook;
        private TextBox infoBox;
        private NotifyIcon notifyIcon1;
        private System.ComponentModel.IContainer components;
        private string clientName = string.Empty;
        private ContextMenuStrip contextMenuStrip1;
        private ToolStripMenuItem closeToolStripMenuItem;
        private ToolStripMenuItem aboutToolStripMenuItem;
        static String ChannelName = null;
        Program()
        {
            InitializeComponent();
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Program());
        }
        static int GetPid()
        {
            Process iPokerProcess = null;
            foreach (var proc in Process.GetProcesses())
            {
                if (proc.ProcessName == "casino")
                {
                    iPokerProcess = proc;
                    break;
                }
            }
            if (iPokerProcess == null)
            {
                MessageBox.Show("Poker client not detected. Please check that the client is running", "Oops! Something has gone wrong", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return -1;
            }
            return iPokerProcess.Id;
        }


        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Program));
            this.Settings = new System.Windows.Forms.GroupBox();
            this.infoBox = new System.Windows.Forms.TextBox();
            this.startHook = new System.Windows.Forms.CheckBox();
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.Settings.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            //
            // Settings
            //
            this.Settings.Controls.Add(this.infoBox);
            this.Settings.Dock = System.Windows.Forms.DockStyle.Top;
            this.Settings.Location = new System.Drawing.Point(0, 0);
            this.Settings.Name = "Settings";
            this.Settings.Size = new System.Drawing.Size(298, 116);
            this.Settings.TabIndex = 0;
            this.Settings.TabStop = false;
            this.Settings.Text = "Info";
            //
            // infoBox
            //
            this.infoBox.BackColor = System.Drawing.Color.White;
            this.infoBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.infoBox.Location = new System.Drawing.Point(3, 16);
            this.infoBox.Multiline = true;
            this.infoBox.Name = "infoBox";
            this.infoBox.ReadOnly = true;
            this.infoBox.Size = new System.Drawing.Size(292, 97);
            this.infoBox.TabIndex = 1;
            //
            // startHook
            //
            this.startHook.Appearance = System.Windows.Forms.Appearance.Button;
            this.startHook.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.startHook.Location = new System.Drawing.Point(97, 119);
            this.startHook.Name = "startHook";
            this.startHook.Size = new System.Drawing.Size(104, 55);
            this.startHook.TabIndex = 0;
            this.startHook.Text = "Start";
            this.startHook.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.startHook.UseVisualStyleBackColor = true;
            this.startHook.CheckedChanged += new System.EventHandler(this.startHook_CheckedChanged);
            //
            // notifyIcon1
            //
            this.notifyIcon1.BalloonTipText = "IPoker BB Mod Status";
            this.notifyIcon1.BalloonTipTitle = "IPoker BB Mod";
            this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
            //
            // contextMenuStrip1
            //
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.closeToolStripMenuItem,
            this.aboutToolStripMenuItem});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(104, 48);
            //
            // closeToolStripMenuItem
            //
            this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
            this.closeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.closeToolStripMenuItem.Text = "Close";
            this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
            //
            // aboutToolStripMenuItem
            //
            this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.aboutToolStripMenuItem.Text = "About";
            this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
            //
            // Program
            //
            this.ClientSize = new System.Drawing.Size(298, 178);
            this.Controls.Add(this.Settings);
            this.Controls.Add(this.startHook);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.Name = "Program";
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Tag = "";
            this.Text = "IPoker BB Mod";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Program_FormClosing);
            this.Resize += new System.EventHandler(this.Program_Resize);
            this.Settings.ResumeLayout(false);
            this.Settings.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
        public class IPokerModInterface : MarshalByRefObject
        {
            public void ReportException(Exception InInfo)
            {
               
            }
            public void Ping()
            {
            }
        }
        private void startHook_CheckedChanged(object sender, EventArgs e)
        {
            var checkbox = sender as CheckBox;
            var exitProg = true;
            if (checkbox.Checked)
            {
                Int32 TargetPID = GetPid();
                Console.WriteLine("WTF");
                if (TargetPID == -1)
                {
                    infoBox.AppendText("Poker Client not detected\n");
                    checkbox.Checked = false;
                }
                else
                {
                    try
                    {
                        try
                        {
                            Config.Register(
                                "IPoker BB Modification",
                                "IPokerBBMod.exe",
                                "LunaInject.dll");
                        }
                        catch (ApplicationException)
                        {
                            MessageBox.Show("This is an administrative task!", "Permission denied...", MessageBoxButtons.OK);
                            System.Diagnostics.Process.GetCurrentProcess().Kill();
                        }
                        RemoteHooking.IpcCreateServer<IPokerModInterface>(ref ChannelName, WellKnownObjectMode.SingleCall);
                        RemoteHooking.Inject(
                            TargetPID,
                            "LunaInject.dll",
                            "LunaInject.dll",
                            ChannelName);
                        clientName = Regex.Match(Process.GetProcessById(TargetPID).MainModule.FileName, @".+(?=\\casino.exe)").Value;
                        clientName = clientName.Substring(clientName.LastIndexOf('\\'));
                        clientName = clientName.Replace("\\", "");
                        infoBox.AppendText(string.Format("Attached to Poker Client: {0}\n", clientName));
                       
                    }
                    catch (Exception ExtInfo)
                    {
                        Console.WriteLine("There was an error while connecting to target:\r\n{0}", ExtInfo.ToString());
                    }
                    checkbox.Text = "Exit";
                    checkbox.ForeColor = Color.Red;
                }
            }
            else if (!checkbox.Checked && checkbox.Text == "Exit")
            {
                Application.Exit();
            }
        }
        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
            this.WindowState = FormWindowState.Normal;
            this.ShowInTaskbar = true;
            notifyIcon1.Visible = true;
        }
        private void Program_FormClosing(object sender, FormClosingEventArgs e)
        {
            notifyIcon1.Visible = false;
        }
        private void Program_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.ShowInTaskbar = false;
                this.Hide();
                notifyIcon1.Visible = true;
                notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
                if (this.startHook.Checked)
                {
                    notifyIcon1.BalloonTipText = string.Format("Mod is enabled on {0}", clientName);
                    notifyIcon1.ShowBalloonTip(1000);
                }
                else
                {
                    notifyIcon1.BalloonTipText = "Mod is not enabled";
                    notifyIcon1.ShowBalloonTip(1000);
                }
            }
        }
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form aboutBox = new AboutBox1();
            aboutBox.Show();
        }
    }
}

First question, can this be replicated in Autoit?

Next question, would anyone know how the hell its done.

The above source is in C# which I know nothing about, but I can get as far as getting the process Id of the casino.exe application.

If this is not possible, I guess I need to learn C#. But I was hoping there was some way to use the dll from easyhook

thanks in advance!

Share this post


Link to post
Share on other sites



think that this is against the rules so I have reported it. If it is ok then I apologise.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

think that this is against the rules so I have reported it. If it is ok then I apologise.

What rule do you think it breaks?

EDIT, I have re-checked the rules, and dont see any rule that this has broken. Despite me stating from the very beginning this is nothing to do with bots or automation you flagged it anyway. Did you even read the full post? to see what this does? do you even know why it does what it does? I bet you saw the word poker and bot and got all excited. I am disappointed.

Edited by civilcalc

Share this post


Link to post
Share on other sites

What rule do you think it breaks?

EDIT, I have re-checked the rules, and dont see any rule that this has broken. Despite me stating from the very beginning this is nothing to do with bots or automation you flagged it anyway. Did you even read the full post? to see what this does? do you even know why it does what it does? I bet you saw the word poker and bot and got all excited. I am disappointed.

I followed the link in your original post and in my opinion it still breaks the no games rule. That is only my opinion at the moment and we will just have to wait and see what higher powers think. If I am wrong I aplogise.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Im pretty sure the rule is no game automation.

There are scripts on here for poker calculators that have been around for years.

I have been here for 6 years and dont ever remember a rule that no games are allowed, I see the no game automation rule enforced all the time, I guess you must be new??

Oh no wait, youve been here longer than me.

There are games written in Autoit for christs sake.

Do you ever read anything?

I hate wannabe mods..... So many of them on here.

Share this post


Link to post
Share on other sites

What rule do you think it breaks?

EDIT, I have re-checked the rules, and dont see any rule that this has broken. Despite me stating from the very beginning this is nothing to do with bots or automation you flagged it anyway. Did you even read the full post? to see what this does? do you even know why it does what it does? I bet you saw the word poker and bot and got all excited. I am disappointed.

I like the attitude and am sure it will get you far..

Anyway, what about a management summary as I am for sure not going to read all the linked stuff in 2 short sentenses or less?

The floor is yours.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry Jos, just evertime I post something on here someone jumps on board with incorrect enforcement of the rules. There should be a rule against it!

How do you mean a management summary?

Share this post


Link to post
Share on other sites

I hate wannabe mods..... So many of them on here.

I am not a wannabe anything.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Yeah I have an attitude, its like getting pulled over for doing the speed limit, I would of preffered if BigDod had asked some questions, or looked into it more, rather than just rock up and hit the report button. It seems he took the shoot first ask questions later, and you will have to excuse me if it gets my back up when Im being shot at, for what I believe to be within the rules of this site. I have NEVER broken a rule, but have been accused of it twice, both incorrectly. It does start to wear thin after a while

Can you confirm if this does or does not break the rules.

Edited by civilcalc

Share this post


Link to post
Share on other sites

Yeah I have an attitude, its like getting pulled over for doing the speed limit, I would of preffered if BigDod had asked some questions, or looked into it more, rather than just rock up and hit the report button. Can you confirm if this does or does not break the rules.

If you fully read my posts you will see that I stated that I may be wrong and apologised in advance incase I was.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Well, let me start with another question before we dive into your intentions here:

Reading your last post about our rules it seems that you are unclear with the current version of our forum rules, at least it sounds that way.

So,let me ask you: did you really reread them and see the bit abou zero tolerance when it comes to bots these days?

When you still am under the impression your question is within our rules I ask you to explain what your intentions are in a few short sentenses as i am not going to do any research on your question and its a little vague to say the least what it is you want to do.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

If you fully read my posts you will see that I stated that I may be wrong and apologised in advance incase I was.

then lets draw a line under this, this thread is getting majorly derailed.

Share this post


Link to post
Share on other sites

Well, let me start with another question before we dive into your intentions here:

Reading your last post about our rules it seems that you are unclear with the current version of our forum rules, at least it siunds that way.

So,let me askyou: did you really reread them and see the bit abou zero tolerance when it comes to bots these days?

When you still am under the impression your question is within our rules I ask you to explain what your intentions are in a few short sentenses as i am not going to do any research on your question and its a little vague to say the least what it is you want to do.

Jos

Jos, Yes I have read the rules, and Autoit has been zero tolerance on bots for almost as long as I can remember, this application is in NO WAY bot, or automation of any kind. I am 100% that this post is within the rules, partly the reason I may of over-reacted like I have.

To get to the point, the C# in question uses the exe and dll of easyhook to read data as it is passed to the client, when it sees what it believes to be a players amount in chips, it converts the amount to BB's (or big blind, if someone has 1000 chips and the big blind is currently 100, they have 10bb's). It changes this data from 1000 to 10 and sends that value to be painted. I believe it uses the easyhook.exe to read the data and the lunainject.dll to send the new data. That is about as much as I know. I have searched on the forums for a few days now, and have drawn a blank on any sort of API hooking, but none of the reference easy hook, which I think could be the solution. I am out of my depth with C# and the easyhook documentation, and I was hoping someone mgiht already know how its used, or have a better insight to it than me.

Share this post


Link to post
Share on other sites

then lets draw a line under this, this thread is getting majorly derailed.

lets not yet and finish our little talk here.

.. And honestly I am getting somewhat annoyed with your handling of your emotions around own perspective of bigdods initial post.

I believe he was pretty mild in the way he wrote it and you elected to defend by attack mode.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos, Yes I have read the rules, and Autoit has been zero tolerance on bots for almost as long as I can remember, this application is in NO WAY bot, or automation of any kind. I am 100% that this post is within the rules, partly the reason I may of over-reacted like I have.

To get to the point, the C# in question uses the exe and dll of easyhook to read data as it is passed to the client, when it sees what it believes to be a players amount in chips, it converts the amount to BB's (or big blind, if someone has 1000 chips and the big blind is currently 100, they have 10bb's). It changes this data from 1000 to 10 and sends that value to be painted. I believe it uses the easyhook.exe to read the data and the lunainject.dll to send the new data. That is about as much as I know. I have searched on the forums for a few days now, and have drawn a blank on any sort of API hooking, but none of the reference easy hook, which I think could be the solution. I am out of my depth with C# and the easyhook documentation, and I was hoping someone mgiht already know how its used, or have a better insight to it than me.

So what would call this then when ready memory and acting on it ?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

For what its worth, seeing a players stack in BB's is much easier when you are playing more than one table, a lot of the decisions are based on how many blinds a player has, and having muliple tables at mulitple blind levels can take time to come up with your move, having all the stacks in bb's makes the process simpiler; to quote the 2+2 link

It converts table stack sizes and bets to Big Blinds. Very useful if you multitable multiple limits

Nice work. +1 for the auto convert bet amounts in the text box. I multi-table 6-9 tables and type bets on a fairly regular basis

Simple but never the less nice solution. Good work

I appreaciate poker may be alien to some people on here, but if someone took literally 2 minutes to read the whole post, they would see thats its not a bot or any sort automation.

Share this post


Link to post
Share on other sites

So what would call this then when ready memory and acting on it ?

I dont understand your question

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I appreaciate poker may be alien to some people on here, but if someone took literally 2 minutes to read the whole post, they would see thats its not a bot or any sort automation.

guilty and so be it.

I am done spending time on his and for this moment will lock the thread unless a Mod with poker knowledge comes along and convinces me its ok as you havent.

Jos

Edited by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I don't really give a shit whether this post breaks the rules or not. What I do give a shit about is your pathetic attitude. BigDod's opinion on whether or not doesn't matter. Your opinion ESPECIALLY doesn't matter (Do you know how many times people clearly breaking the rules claim they aren't?). The opinion of a moderator matters and this thread required our opinion. BigDod did the exact right thing by reporting it for clarification. You fucked everything up, though, with your shit attitude. If Jos had not beaten me to this thread I would have banned you for a few days for the attitude. Since he beat me here and feels the thread should be locked I'm going to just leave it at that.

So to be clear, this thread isn't locked because it breaks any rules (It might or it might not, I don't care to evaluate that aspect). It's locked because you took a shitty attitude about the whole thing instead of waiting for a moderator to come along and confirm one way or the other. If it weren't for your attitude Jos would have easily deferred to someone with more poker knowledge (Likely me) and I would have bothered to determine if you're breaking the rules or not. As it stands, I don't care. I do, however, strongly discourage you from broaching the subject again on this forum as that is very clearly against the rules.

Next time you claim you have nothing to hide prove it by keeping your word-hole shut until your claims are validated. Trying to vigorously defend yourself with a poor attitude only implies guilt even if there isn't real guilt.

TL;DR version: Use your fucking brain, not your fingers.

1 person likes this

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0