Skip to content

Instantly share code, notes, and snippets.

@ippo-lit
Forked from trkyshorty/knightonline.py
Last active May 30, 2022 16:13
Show Gist options
  • Save ippo-lit/e7d5246de8dbd9c3e2c3bf26c8f54561 to your computer and use it in GitHub Desktop.
Save ippo-lit/e7d5246de8dbd9c3e2c3bf26c8f54561 to your computer and use it in GitHub Desktop.
import ctypes
from mem_edit import Process
import OFF_SET ## for CNKO - Game v3246
KO_CHR_PTR = 0x100503C ## for CNKO - Game v3246
pid = Process.get_pid_by_name("KnightOnline.exe")
ON = 0
OFF = 1
def GET_CHR_PTR(OFF_SET_VALUE):
with Process.open_process(pid) as p:
KO_CHR_PTR_ADDR = p.read_memory(KO_CHR_PTR, ctypes.c_int())
CHR_PTR_OFF_SET = p.read_memory(KO_CHR_PTR_ADDR.value + OFF_SET_VALUE, ctypes.c_int())
return CHR_PTR_OFF_SET.value
def GET_CHARACTERS_INFO_PRINT():
HP = GET_CHR_PTR(OFF_SET.HP) / GET_CHR_PTR(OFF_SET.MAX_HP) * 100
MP = GET_CHR_PTR(OFF_SET.MP) / GET_CHR_PTR(OFF_SET.MAX_MP) * 100
EXP = GET_CHR_PTR(OFF_SET.EXP) / GET_CHR_PTR(OFF_SET.MAX_EXP) * 100
WEIGHT = GET_CHR_PTR(OFF_SET.WEIGHT) / GET_CHR_PTR(OFF_SET.MAX_WEIGHT) * 100
GOLD = GET_CHR_PTR(OFF_SET.GOLD)
STR_HP = "HP: %{:.4}".format(HP)
STR_MP = "MP: %{:.4}".format(MP)
STR_EXP = "EXP: %{:.3}".format(EXP)
STR_WEIGHT = "WEIGHT: %{:.3}".format(WEIGHT)
print(f"\r{STR_HP} | {STR_MP} | {STR_EXP} | COIN: {GOLD} | {STR_WEIGHT} | ", end="")
def GET_WALL_HACK(VALUE):
with Process.open_process(pid) as p:
KO_CHR_PTR_ADDR = p.read_memory(KO_CHR_PTR, ctypes.c_int())
GET_CHANGE_OFF_SET_VALUE = p.write_memory(KO_CHR_PTR_ADDR.value + OFF_SET.WH, ctypes.c_int(VALUE))
if VALUE == 0:
print("Wall Hack: ON")
else:
print("Wall Hack: OFF")
return GET_CHANGE_OFF_SET_VALUE
def GET_CHR_NAME():
with Process.open_process(pid) as p:
KO_CHR_PTR_ADDR = p.read_memory(KO_CHR_PTR, ctypes.c_int())
GET_NAME = p.read_memory(KO_CHR_PTR_ADDR.value + OFF_SET.NAME, (ctypes.c_char * OFF_SET.NAME_LEN)())
print(f"CHAR: {GET_NAME.value}")
GET_WALL_HACK(ON)
GET_CHR_NAME()
while True:
GET_CHARACTERS_INFO_PRINT()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment