Solved Keep getting CloseHandle Failed

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat


Jul 16, 2014
Hi, I watched Fleep's tutorial on how to make a trainer(This: ), I followed his steps so far but right now i'm having a problem that isn't addressed in the video, Whenever i try to launch the program I get CloseHandle Failed Screenshot:
This is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Threading;

namespace elstrainer
    public partial class Form1 : Form
        #region Global Variables
        Memory myMemory = new Memory();
        Process[] myProcess;
        bool IsGameAvaiable;
        bool infiniteHP = false;
        string hpPointer = "00F7F454";
        int[] hpOffset = {0x2C4};
        int hpToFill = 1;

        public Form1()

        private void Form1_Load(object sender, EventArgs e)


        private void timer1_Tick(object sender, EventArgs e)
            myProcess = Process.GetProcessesByName("x2");
            if (myProcess.Length != 0)
                IsGameAvaiable = true;
                statusLBL.Text = "x2.exe found";
            else {
                IsGameAvaiable = false;
                statusLBL.Text = "x2.exe not found";

        private void button1_Click(object sender, EventArgs e)
            if (IsGameAvaiable) {

                if (infiniteHP)
                    infiniteHP = false;
                    button1.Text = "HP OFF";
                else {
                    infiniteHP = true;
                    button1.Text = "HP ON";

        private void updateCheatsTMR_Tick(object sender, EventArgs e)
            if (IsGameAvaiable)
                #region infinite HP
                if (infiniteHP) {
                    myMemory.ReadProcess = myProcess[0];
                    int pointerAdress = HexToDec(hpPointer);
                    int[] pointerOffset = hpOffset;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(hpToFill);
                    string writtenAdress = myMemory.PointerWrite((IntPtr)pointerAdress, valueToWrite, pointerOffset, out bytesWritten );
        public static string HexToDec(int DEC)
            return DEC.ToString("X");

        public static int HexToDec(string Hex){
            return int.Parse(Hex, NumberStyles.HexNumber);


What am I doing wrong here?
My guess is that I might've gotten the pointer wrong since I skipped that part entirely

I used 00F7F454 as the pointer and 0x2C4 as the Offset. Could that possibly be the reason I'm getting that error? If so, what is the right way?


Full Member
Jun 8, 2014
That Error happens when there's no Handle to close. I see you call the 'Open()' and you're not getting an Object Reference error before CloseHandle(). Check your Memory.PointerWrite() function to make sure it's not doing a CloseHandle() prematurely. It sounds like you're calling CloseHandle() twice.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods