Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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"
  7.  
  8. #define CMD_LEN 255
  9. #define TITLE "GameHack 1.0 ALPHA "
  10.  
  11. char cmd_line[CMD_LEN];
  12. char cmd_line_tmp[CMD_LEN];
  13.  
  14. void notify_show(char *text)
  15. {
  16.    start_app("/sys/@notify", text);
  17. }
  18.  
  19. void cmd_processing()
  20. {
  21.     strcpy(cmd_line_tmp, cmd_line);
  22.     char *cmd = strtok(cmd_line_tmp, " \n");
  23.     if(!strcmp(cmd, "pause")){
  24.         kdebugger_pause(PID);
  25.     }
  26.     else if(!strcmp(cmd, "play")){
  27.         kdebugger_play(PID);
  28.     }
  29.     else if(!strcmp(cmd, "exit")){
  30.         exit(0);
  31.     }
  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!");
  38.             }
  39.         }else{
  40.             puts("Invalid arguments!");
  41.         }
  42.     }
  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!");
  49.             }
  50.             printf("0x%.8X: %d\n", addr, val);
  51.         }else{
  52.             puts("Invalid arguments!");
  53.         }
  54.     }
  55.  
  56.  
  57.     else if(!strcmp(cmd, "help"))
  58.     {
  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).");
  65.     }
  66.     else if(!strcmp(cmd, "find"))
  67.     {
  68.         puts("Not yet implemented ...");
  69.     }
  70.     else if(cmd != NULL){
  71.         puts("Unknown command!");
  72.     }
  73. }
  74.  
  75. int main(int argc, char* argv[])
  76. {
  77.     if (argc!=2 ){
  78.         notify_show("'No game selected!' -E");
  79.         exit(0);
  80.     }
  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);
  88.     }
  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);
  95.     }
  96. }