Jump to content

Photo

I can't even sleep :)


  • Please log in to reply
3 replies to this topic

#1 vmv Posted 18 November 2013 - 03:14 AM

vmv

    Soldier

  • Members
  • Pip
  • 2 posts

So, hi first...i did make an account here too, after seeing this lib on  ownedcore forum :).

I really like your work here...and the integration with vs2013...no words :).

I just have an old code made from here and there and i want to port everything.

 

I will try not to bother to much but i am still newbie with c#...and this lib is quite impressive for me.

To the point ...first thing first : 

1: - Is really necessary to use 2 times OpenProcess...for Open & GetBaseAddress ?

2: - What does this  ".First" and what are the access rights when opening a process?       // found the answer in the library :)

3: - Where can i write the Allocate/Dealc function exactly...there are many ways as i see...?

        public static void OpenProcess()
        {
            using (var memory = new MemorySharp(ApplicationFinder.FromProcessName("Game.exe").First()))
            {
                var open = memory.Modules.RemoteModules.First().BaseAddress;
                MessageBox.Show("address : " + open.ToString("X"));
            }
        }
        public static void GetBaseAddress()
        {
            using (var memory = new MemorySharp(ApplicationFinder.FromProcessName("Game.exe").First()))
            {
                var gameBase = memory.Modules.RemoteModules.First(m => m.Name == "Game.dll").BaseAddress;

                var atkBase = gameBase + 0x18A73D;

                MessageBox.Show("atkBase : " + atkBase.ToString("X"));
            }
        }

// Old Code
        public static void allocate(out int vMemory, int nSize)

        {
            vMemory = VirtualAllocEx(m_hProcess, IntPtr.Zero, nSize, AllocType.Commit, Protect.ExecuteReadWrite);
        }
        public static bool dealloc(int vMemory)
        {
            return VirtualFreeEx(m_hProcess, (IntPtr)vMemory, 0, FreeType.Release);
        }
}

Oh i forgot.. if there is no process..i get an error...how do i prevent that ?

 

 

Thank you,


Edited by vmv, 18 November 2013 - 12:17 PM.

  • Back to top
  • Report

#2 ZenLulz Posted 18 November 2013 - 01:37 PM

ZenLulz

    Lead Developer

  • Administrators
  • 67 posts
  • LocationSwitzerland

Hello Vmv and welcome to the board !

 

1. You can store the instance of the class MemorySharp ouside the scope of your functions. The keyword using explicitely disposes the object in this context.

The base address of the application module can be retrieved in this way:

// Assuming the sharp object is an object of the class MemorySharp class

var baseAddress = sharp.Modules.MainModule.BaseAddress;

2. The extension method .First() is provided by LINQ Queries. You can use .FirstOrDefault() and check for null reference if you want to see if a given program is running.

 

3. You can manage the memory management using the property Memory of the instances of the class MemorySharp.

 

Cheers,

ZenLulz


ZenLulz

  • Back to top
  • Report

#3 vmv Posted 18 November 2013 - 02:29 PM

vmv

    Soldier

  • Members
  • Pip
  • 2 posts

Maybe is to much for my knowledge...i can't even port few lines of code :|....

 

What i'm doing wrong here :)...is not allocating anything...:

        public static IntPtr atkBase, wepBase;

        public static void OpenProcess()
        {
            using (var memory = new MemorySharp(ApplicationFinder.FromProcessName("Game.exe").First()))
            {
                var gameBase = memory.Modules.RemoteModules.First(m => m.Name == "Game.dll").BaseAddress;
                atkBase = gameBase + 0x18A73D; wepBase = gameBase + 0x1379E0;
            }
        }

        public static void Allocate()
        {
            var address = atkBase;
            var sharp = new MemorySharp(Process.GetCurrentProcess());
            var allocated = sharp.Memory.Allocate(1024);
        }

Edited by vmv, 18 November 2013 - 03:50 PM.

  • Back to top
  • Report

#4 ZenLulz Posted 18 November 2013 - 09:33 PM

ZenLulz

    Lead Developer

  • Administrators
  • 67 posts
  • LocationSwitzerland

One requirement of this library is to have a good skill in C#. I cannot support you because you don't have these basics.

For the next, I highly suggest you to read tutorials or read a book about this programming language to fully understand what you are doing in your program, before manipulating others.

 

For your code, the above code correctly allocates a chunk of memory but in the current process. Also, you create two instances of MemorySharp, which is absolutely not necessary.

 

Cheers,

ZenLulz


ZenLulz

  • Back to top
  • Report




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users