Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added peekmem! command #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
| Command | Description |
| ------- | ----------- |
| **dumpmem!** | Dumps the whole 64MB physical memory map to `E:\DEVKIT\dxt\memdump.bin` |
| **peekmem!** _addr_ | Reads a DWORD (4 bytes) from the specified address. |
| **pokemem!** _addr value_ | Writes a specified DWORD (4 bytes) to the specified address. |
| **freezemem!** _addr value_ | Same as pokemem, but instead freezes the specified address with the written value. |
| **startsearch!** _equals/not-equals/less-than/greater-than/unknown value_ | Begins a conditional or unknown search for memory values. Restarts any existing search. |
Expand Down
1 change: 1 addition & 0 deletions plugin/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static VOID NTAPI cheat_thread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)

void DxtEntry(ULONG *pfUnload) {
DmRegisterCommandProcessor("DUMPMEM", dump_memory);
DmRegisterCommandProcessor("PEEKMEM", peek_memory);
DmRegisterCommandProcessor("POKEMEM", poke_memory);
DmRegisterCommandProcessor("FREEZEMEM", freeze_memory);
DmRegisterCommandProcessor("STARTSEARCH", start_search);
Expand Down
17 changes: 17 additions & 0 deletions plugin/memfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ HRESULT __stdcall freeze_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, P
return XBDM_NOERR;
}

HRESULT __stdcall peek_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc) {
char code_address_buf[16];
DWORD code_address;

sscanf(szCommand, "peekmem! %s", code_address_buf);

code_address = strtol(code_address_buf, NULL, 16);

PVOID addr = MmMapIoSpace(code_address, 4, PAGE_READWRITE);

sprintf(szResp, "%08X", *(DWORD*)addr);

MmUnmapIoSpace(addr, 4);

return XBDM_NOERR;
}

HRESULT __stdcall poke_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc) {
char code_address_buf[16], val_buf[16];
DWORD code_address, val;
Expand Down
1 change: 1 addition & 0 deletions plugin/memfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void add_freeze_entry(DWORD address, DWORD val);
void apply_freeze_entries();

HRESULT __stdcall dump_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc);
HRESULT __stdcall peek_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc);
HRESULT __stdcall poke_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc);
HRESULT __stdcall freeze_memory(LPCSTR szCommand, LPSTR szResp, DWORD cchResp, PDM_CMDCONT pdmcc);

Expand Down