Kalamity Library - WriteBytes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Stupify
Posts: 8
Joined: 28 May 2018, 03:09

Kalamity Library - WriteBytes

31 Oct 2018, 08:24

Hello.

I'm using this great memory library someone referenced me to a while ago, and I have slowly got everything working the way I need for my project, aside from figuring out how to write bytes to an address.

This is the library: https://github.com/Kalamity/classMemory ... Memory.ahk

I have the following address/bytes as an example, that I would like to write to the processes memory:
Address: 0x004932F3,
Bytes: 8B8B 88 02 00 00

I've overly searched the forums for any examples, and tried to work it out myself, but I cannot figure out how to do this.
If anyone can provide an example of how I could write bytes to an address, I would greatly appreciate it!
Stupify
Posts: 8
Joined: 28 May 2018, 03:09

Re: Kalamity Library - WriteBytes

01 Nov 2018, 07:06

Does anyone have any ideas or examples of a memory function to write bytes?

Out of all the related posts, the below code is all I could find, that is similar to what I need.

WriteMemoryUInt(value, address, program){
winget, pid, PID, %program%
ProcessHandle := DllCall("OpenProcess", "UInt", 2035711, "char", 0, "UInt", PID, "Ptr")
DllCall("WriteProcessMemory", "Ptr", ProcessHandle, "Ptr", address, "UInt*", value, "Ptr", 4, "Ptr", 0)
DllCall("CloseHandle", "Ptr", ProcessHandle)
return
}



I can't get the code above to work as is. For one, I'm testing in my main project currently using the Kalamity Library.
I will test this in a new script later to see if I can at least get this function working, but I'd like to figure out how to adapt this code for use in the kalamity memory class.

Does anyone know how I can make the above function, compatible with the kalamity library?
An example of the Kalamity write function:

Client1.write(0x004932F3, 1, "UInt")

Write(address, value, type := "Uint", aOffsets*)
{
IF !This.aTypeSize.hasKey(type)
RETURN "", ErrorLevel := -2
RETURN DllCall("WriteProcessMemory", "Ptr", This.hProcess, "Ptr", aOffsets.maxIndex() ? This.getAddressFromOffsets(address, aOffsets*) : address, type "*", value, "Ptr", This.aTypeSize[type], "Ptr", This.pNumberOfBytesWritten)
}


I'd like to be able to do: Client1.write(0x004932F3, 0x909090909090, "UInt")
I'm completely lost, so I'd treasure any help! xD
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Kalamity Library - WriteBytes  Topic is solved

01 Nov 2018, 08:49

Add the following method to classMemory, i.e. place the method inside the actual class.


writeHexString(address, hexString, aOffsets*)
{
AOBPattern := this.hexStringToPattern(hexString)
if !IsObject(AOBPattern)
return AOBPattern

sizeBytes := this.getNeedleFromAOBPattern("", buffer, AOBPattern*)
return this.writeRaw(address, &buffer, sizeBytes, aOffsets*)
}

And to use it:
Client1.writeHexString(0x004932F3, "0A0B030405060B")
That will write: 0A to 0x004932F3, 0B to 0x004932F4, 03 to 0x004932F5, and so on.

Are the code format tags broken on the forum? Had to use quotes.

Cheers.

P.S.

To write a single byte:
client1.write(0x004932F3, 25, "UChar")
Stupify
Posts: 8
Joined: 28 May 2018, 03:09

Re: Kalamity Library - WriteBytes

01 Nov 2018, 10:33

Thank you so much for responding, and so fast to! This is exactly what I needed. I've had so much trouble trying to figure this out myself. You've saved me a lot of stress. xD

I really appreciate your help, and for providing this awesome library to the community. Seriously, this is awesome, and this library is a huge part of my programs purpose. Thanks to you, I can do everything I need now, and continue on with the memory side of my project. I'll definitely credit you on my site for providing this library.

Almost forgot to mention, it does seem like the code display tags are broken. I had to edit my post and use inline code tags. =d

Thanks again! Cheers :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 176 guests