Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,070
    Reputation
    50
    Thanks
    940
    My Mood
    Fine

    Simple MemoryMgr Class

    I was bored, pretty much it easily allows you to manage all your addresses.

    There are some things you can do to easily make this better(Get the original bytes for the addresses automatically), but hey its for the public

    Credits: mmbob, nubzgetskillz

    Code:
    /*===============================|
    |Simple MemoryMgr Class			 |
    |								 |
    |By CodeDemon					 |
    |Credits: mmbob, nubzgetskillz	 |
    |===============================*/
    #include <Windows.h>
    
    #define ON true
    #define OFF false
    #define ingamecheck 0x37829B4C
    
    struct memory{
    	char * name;
    	bool enabled;
    	int address;
    	int size;
    	char * original;
    	char * newbytes;
    };
    
    class MemoryMgr{
    	public:
    		memory mem[99]; //change 99 to however many addresses you have as to not allocate too much memory
    
    		void AddOffset(char * name, int address, char * original, char * newbytes , int size);
    		void UnPatchAll();
    		void PatchBytes(char * name, bool onoff);
    	private:
    		int adrcount;
    };
    
    void MemoryMgr::AddOffset(char * name, int address, char * original, char * newbytes, int size)
    {
    	mem[adrcount].address = address;
    	mem[adrcount].name = name;
    	mem[adrcount].size = size;
    	mem[adrcount].original = original;
    	mem[adrcount].newbytes = newbytes;
    	mem[adrcount].enabled = false;
    	adrcount++;
    }
    
    void MemoryMgr::UnPatchAll()
    {
    	for(int i = 0; i<(sizeof(mem)/sizeof(memory)); i++){
    		memcpy((LPVOID)mem[i].address,mem[i].original,mem[i].size);
    		mem[i].enabled = false;
    	}
    }
    
    
    void MemoryMgr::PatchBytes(char * name, bool onoff)
    {
    	for(int i = 0; i<(sizeof(mem)/sizeof(memory)); i++){
    		if(mem[i].name == name){
    			if(*(int*)ingamecheck == 1){
    				if(onoff == true){
    					memcpy((LPVOID)mem[i].address,mem[i].newbytes,mem[i].size);
    					mem[i].enabled = true;
    				} else {
    					memcpy((LPVOID)mem[i].address,mem[i].original,mem[i].size);
    					mem[i].enabled = false;
    				}
    			} else {
    				memcpy((LPVOID)mem[i].address,mem[i].original,mem[i].size);
    			}
    		}
    	}
    }
    How to use:

    Paste the code into a new header file.

    Create a new instance of the class, preferably where your DLL main function is, or where your hacks are. You can also extern it if that will be easier for you.
    Code:
    MemoryMgr mempatch
    In your DLL main, initiate the addresses, this is done, so that you dont initiate addresses more than once.

    Code:
    bool APIENTRY DllMain(HMODULE hMod, DWORD pReason, LPVOID lpReserved)
    {
    	if (pReason == DLL_PROCESS_ATTACH)
    	{
    
    		mempatch.AddOffset("NoReload", 0x374BB8F4, "\x0F\x84\xB1\x01\x00\x00", "\x90\x90\x90\x90\x90\x90", 6);
    		mempatch.AddOffset("SuperBullets", 0x374B65D6, "\x0F\x94\xC0", "\x90\x90\x90", 3);
    	}
    
    	return true;
    
    }
    Use:

    Code:
     mempatch.PatchBytes("HACKNAME",ON);
    or

    Code:
     mempatch.PatchBytes("HACKNAME",OFF);
    The function automatically checks if bytes can be patched(patches only if in game), and patches them accordingly.

  2. The Following 8 Users Say Thank You to CodeDemon For This Useful Post:

    Alessandro10 (02-26-2011),Departure (02-27-2011),gibam761 (10-07-2012),NiCe_ShOt (02-27-2011),Nubzgetkillz (02-26-2011),Otaviomorais (11-16-2012),pDevice (06-30-2012),TEN.HGPM (02-26-2011)

  3. #2
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Nice work, I made something similar awhile ago but nothing to do with hacks, just similar idea of an array of patches... A lot of my coding is based around reverse engineering so it was for creating a simple loader which patches the target when loaded in a Suspended state.

    [highlight=Delphi]
    (* ************************************************** ***
    Unit : uMultiMemPatch
    Author : Departure
    Url : cheesydoodle.com

    Info:
    An Easy way to patch your Target in memory,
    Just add your VA and your array of bytes,
    it will load the target in suspended mode
    write the bytes to address(s) given and then
    resume the thread with new Patches.

    Usage:
    uses
    uMultiMemPatch;
    Var
    MyArrayOfPatches: APatchRec;
    Being
    AddPatch($0040107B,[$90,$90,$90],MyArrayOfPatches);
    AddPatch($004010B0,[$90,$EB],MyArrayOfPatches);
    WritePatches('CrackMe.exe', MyArrayOfPatches);
    MyArrayOfPatches:= Nil;
    end;
    ************************************************** *** *)
    unit uMultiMemPatch;

    interface

    uses
    Windows;

    type
    TPatchRec = Record
    dwAddress: Dword;
    baPatches: Array of Byte;
    end;

    type
    APatchRec = Array of TPatchRec;

    Procedure AddPatch(dwAddress: Dword; aPatches: Array of byte; var ArrayRecord: APatchRec);

    implementation

    Procedure AddPatch(dwAddress: Dword; aPatches: Array of byte; var ArrayRecord: APatchRec);
    var
    Patch: TPatchRec;
    i: Integer;
    begin
    {Set the Address}
    Patch.dwAddress:= dwAddress;
    {Set the Length of Patches}
    SetLength(Patch.baPatches, Length(aPatches));
    {Add the Patches}
    for i:= low(aPatches) to high(aPatches) do
    Patch.baPatches[i]:= aPatches[i];

    {Check if Array is already Built}
    if ArrayRecord = Nil then
    SetLength(ArrayRecord,1)
    else
    SetLength(ArrayRecord,Length(ArrayRecord) +1);
    {Add out Patches to the Array}
    ArrayRecord[high(ArrayRecord)]:= Patch;
    end;

    Function WritePatches(sFileName: String; ArrayPatches: APatchRec):Boolean;
    var
    { Startup and variables used in procedure }
    StartInfo : TStartupInfo;
    ProcInfo : TProcessInformation;
    CreateOK : Boolean;
    Write: Cardinal;
    i: Integer;
    begin
    Result:= False;
    { Intinilize }
    FillChar(StartInfo,SizeOf(TStartupInfo),#0);
    FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
    StartInfo.cb := SizeOf(TStartupInfo);

    { Create Process in a suspended state }
    CreateOK := CreateProcess(PChar(sFileName),nil, nil, nil,False,CREATE_SUSPENDED,nil, nil, StartInfo, ProcInfo);

    { check to see if successful }
    if CreateOK then
    try
    Begin
    for i:= low(ArrayPatches) to high(ArrayPatches) do
    { Write MultiPatch to memory }
    WriteProcessMemory(ProcInfo.hProcess,ptr(ArrayPatc hes[i].dwAddress),@arrayPatches[i].baPatches,Length(ArrayPatches[i].baPatches),Write);
    { Resume the thread }
    ResumeThread(ProcInfo.hThread);
    CloseHandle(ProcInfo.hProcess);
    Result:= True;
    end;
    except
    Result:= False;
    end;
    end;

    end.
    [/highlight]

    Anyway great work, keep it up

  4. The Following 2 Users Say Thank You to Departure For This Useful Post:

    ChaosMagician (08-29-2011),CodeDemon (02-26-2011)

  5. #3
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,285
    Reputation
    435
    Thanks
    3,715
    My Mood
    Doh
    Pretty cool, if I had a working hack, id probably use this haha

  6. The Following User Says Thank You to supercarz1991 For This Useful Post:

    CodeDemon (02-26-2011)

  7. #4
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,070
    Reputation
    50
    Thanks
    940
    My Mood
    Fine
    Quote Originally Posted by Departure View Post
    Nice work, I made something similar awhile ago but nothing to do with hacks, just similar idea of an array of patches... A lot of my coding is based around reverse engineering so it was for creating a simple loader which patches the target when loaded in a Suspended state.

    [highlight=Delphi]
    (* ************************************************** ***
    Unit : uMultiMemPatch
    Author : Departure
    Url : cheesydoodle.com

    Info:
    An Easy way to patch your Target in memory,
    Just add your VA and your array of bytes,
    it will load the target in suspended mode
    write the bytes to address(s) given and then
    resume the thread with new Patches.

    Usage:
    uses
    uMultiMemPatch;
    Var
    MyArrayOfPatches: APatchRec;
    Being
    AddPatch($0040107B,[$90,$90,$90],MyArrayOfPatches);
    AddPatch($004010B0,[$90,$EB],MyArrayOfPatches);
    WritePatches('CrackMe.exe', MyArrayOfPatches);
    MyArrayOfPatches:= Nil;
    end;
    ************************************************** *** *)
    unit uMultiMemPatch;

    interface

    uses
    Windows;

    type
    TPatchRec = Record
    dwAddress: Dword;
    baPatches: Array of Byte;
    end;

    type
    APatchRec = Array of TPatchRec;

    Procedure AddPatch(dwAddress: Dword; aPatches: Array of byte; var ArrayRecord: APatchRec);

    implementation

    Procedure AddPatch(dwAddress: Dword; aPatches: Array of byte; var ArrayRecord: APatchRec);
    var
    Patch: TPatchRec;
    i: Integer;
    begin
    {Set the Address}
    Patch.dwAddress:= dwAddress;
    {Set the Length of Patches}
    SetLength(Patch.baPatches, Length(aPatches));
    {Add the Patches}
    for i:= low(aPatches) to high(aPatches) do
    Patch.baPatches[i]:= aPatches[i];

    {Check if Array is already Built}
    if ArrayRecord = Nil then
    SetLength(ArrayRecord,1)
    else
    SetLength(ArrayRecord,Length(ArrayRecord) +1);
    {Add out Patches to the Array}
    ArrayRecord[high(ArrayRecord)]:= Patch;
    end;

    Function WritePatches(sFileName: String; ArrayPatches: APatchRec):Boolean;
    var
    { Startup and variables used in procedure }
    StartInfo : TStartupInfo;
    ProcInfo : TProcessInformation;
    CreateOK : Boolean;
    Write: Cardinal;
    i: Integer;
    begin
    Result:= False;
    { Intinilize }
    FillChar(StartInfo,SizeOf(TStartupInfo),#0);
    FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
    StartInfo.cb := SizeOf(TStartupInfo);

    { Create Process in a suspended state }
    CreateOK := CreateProcess(PChar(sFileName),nil, nil, nil,False,CREATE_SUSPENDED,nil, nil, StartInfo, ProcInfo);

    { check to see if successful }
    if CreateOK then
    try
    Begin
    for i:= low(ArrayPatches) to high(ArrayPatches) do
    { Write MultiPatch to memory }
    WriteProcessMemory(ProcInfo.hProcess,ptr(ArrayPatc hes[i].dwAddress),@arrayPatches[i].baPatches,Length(ArrayPatches[i].baPatches),Write);
    { Resume the thread }
    ResumeThread(ProcInfo.hThread);
    CloseHandle(ProcInfo.hProcess);
    Result:= True;
    end;
    except
    Result:= False;
    end;
    end;

    end.
    [/highlight]

    Anyway great work, keep it up
    Thanks! Nice Delphi btw

  8. #5
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,285
    Reputation
    435
    Thanks
    3,715
    My Mood
    Doh
    Quote Originally Posted by CodeDemon View Post
    Thanks! Nice Delphi btw
    I know this is a lil off topic but where can I find a download link for the delphi programs to write it? (I've been using note pad to make a uce >…<)

  9. #6
    AtomicStone's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    827
    Reputation
    18
    Thanks
    476
    My Mood
    Lurking
    Useful Thanks.

  10. #7
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Nice classes bro

  11. #8
    Alessandro10's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    MPGH.NET
    Posts
    6,140
    Reputation
    215
    Thanks
    4,607
    My Mood
    Busy
    Hahahahaha, I had seen it somewhere.

  12. #9
    whatup777's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    CA Source Code Section
    Posts
    4,025
    Reputation
    147
    Thanks
    351
    My Mood
    Dead
    Good job .
    Quotes I live by.


    A foolish person learns from his mistakes, I wise person learns from others.
    Quote Originally Posted by AVGN View Post



    mhm

    i live in texas

    i was at the grocery store with my son. He saw a mexican guy, and he said "Look daddy! a mower man!"

    he's 4 yrs old

  13. #10
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,070
    Reputation
    50
    Thanks
    940
    My Mood
    Fine
    Quote Originally Posted by Alessandro10 View Post
    Hahahahaha, I had seen it somewhere.
    Ummm are you saying I leeched this?

  14. #11
    Alessandro10's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    MPGH.NET
    Posts
    6,140
    Reputation
    215
    Thanks
    4,607
    My Mood
    Busy
    Quote Originally Posted by CodeDemon View Post
    Ummm are you saying I leeched this?
    No, I said I've seen something like that.

  15. #12
    D-Vid the DBag's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    146
    Reputation
    10
    Thanks
    13
    My Mood
    Lurking
    Quote Originally Posted by Alessandro10 View Post
    No, I said I've seen something like that.
    Well, I assure you that this was ALL CD.
    I was on MSN when he was talking about it.

    ...and I am sure glad that you've changed your avatar, cuz that's homo to be stealing other people's avatars.

    [IMG]https://i33.photobucke*****m/albums/d55/y_owns_you/D-Vid665.png[/IMG]

  16. #13
    Nubzgetkillz's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Location
    hacktown
    Posts
    838
    Reputation
    13
    Thanks
    411
    My Mood
    Amazed
    Good job. This can be used in very obscure ways like to suck your dick!!!

    Member since September 25, 2010

    Current Objectives:
    • Graduate college with a degree in Computer Science
    • Find a decent job in the Computer Science Field
    • Learn more programming languages

    Looking for Elo Boosting Job - League of Legends
    Looking for Bronze -> Gold Jobs


    Skype: whatthedream

  17. #14
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    720
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    Quote Originally Posted by D-Vid the DBag View Post


    Well, I assure you that this was ALL CD.
    I was on MSN when he was talking about it.

    ...and I am sure glad that you've changed your avatar, cuz that's homo to be stealing other people's avatars.
    He stole UnknownCoder's this time xD



    Put this image in your signature if you support HTML5 development!

  18. #15
    D-Vid the DBag's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    146
    Reputation
    10
    Thanks
    13
    My Mood
    Lurking
    Quote Originally Posted by _Fk127_ View Post
    He stole UnknownCoder's this time xD
    Lolz. I don't give a shit if he steals anyone else's, but not my little buddy, CodeDemon's avatar. He BETTER not steal mine tho.

    [IMG]https://i33.photobucke*****m/albums/d55/y_owns_you/D-Vid665.png[/IMG]

Page 1 of 2 12 LastLast