[docs] Replace cyrillic 'с' with latin 'c' in register names
[kolibrios.git] / programs / other / GameHack / gh_shell.c
blobbb32a97b1f294eec84833ae12db7bd28b15bec6d
1 #include <conio.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include <kos32sys1.h>
6 #include "gh_core.c"
8 #define CMD_LEN 255
9 #define TITLE "GameHack 1.0 ALPHA "
11 char cmd_line[CMD_LEN];
12 char cmd_line_tmp[CMD_LEN];
14 void notify_show(char *text)
16 start_app("/sys/@notify", text);
19 void cmd_processing()
21 strcpy(cmd_line_tmp, cmd_line);
22 char *cmd = strtok(cmd_line_tmp, " \n");
23 if(!strcmp(cmd, "pause")){
24 kdebugger_pause(PID);
26 else if(!strcmp(cmd, "play")){
27 kdebugger_play(PID);
29 else if(!strcmp(cmd, "exit")){
30 exit(0);
32 else if(!strcmp(cmd, "write")){
33 unsigned addr=0;
34 int val =0;
35 if(sscanf(cmd_line, "%s %x %d %d",cmd_line, &addr, &val, &val)==3){
36 if(kdebugger_write(PID, sizeof(int), addr, &val)==-1){
37 puts("Memory write error!");
39 }else{
40 puts("Invalid arguments!");
43 else if(!strcmp(cmd, "read")){
44 unsigned addr=0;
45 int val =0;
46 if(sscanf(cmd_line, "%s %x %x",cmd_line, &addr, &addr)==2){
47 if(kdebugger_read(PID, sizeof(int), addr, &val)==-1){
48 puts("Memory read error!");
50 printf("0x%.8X: %d\n", addr, val);
51 }else{
52 puts("Invalid arguments!");
57 else if(!strcmp(cmd, "help"))
59 puts("Commands:");
60 puts(" write [addres] [value] - Write DWORD value by address.");
61 puts(" read [addres] [value] - Read DWORD value by address.");
62 puts(" pause - Suspend the game (process)." );
63 puts(" play - Resume running the game(process).");
64 puts(" find [value] - Search for DWORD value in memory(VIP).");
66 else if(!strcmp(cmd, "find"))
68 puts("Not yet implemented ...");
70 else if(cmd != NULL){
71 puts("Unknown command!");
75 int main(int argc, char* argv[])
77 if (argc!=2 ){
78 notify_show("'No game selected!' -E");
79 exit(0);
81 con_init_console_dll();
82 con_set_title(TITLE);
83 PID = load_game(argv[1], NULL);
84 PID = 2;
85 if(PID<0){
86 notify_show("'Game not loaded!' -E");
87 exit(0);
89 kdebugger_play(PID);
90 while (1){
91 printf("GameHack> ");
92 con_gets(cmd_line, CMD_LEN);
93 cmd_processing();
94 memset(cmd_line, '\n', CMD_LEN);