0

I want to know how to bypass protected mode in Windows 8.1, so that my C programs can access the memory of other applications and change their values...I know it can be done because I used to use memory editors to hack games; I just want to build one myself. Below is just a basic program that I threw together just to see if I could write a program that could simulate such an action. It works; of course the problem is that because of protected mode it will crash if I try to access memory outside the scope of the program.

    /* Allows the user to view regions of computer memory */

    #include <ctype.h>
    #include <stdio.h>

    typedef unsigned char BYTE;

    unsigned int addr;
    int integer;
    float flt;

    void print_addr();
    void edit_addr(void);

    int main(void)
    {
        integer = 100;
        flt = 5.6;
        char ch;

        printf("Address of main function:    %x\n", (unsigned int) main);
        printf("Address of addr variable:    %x\n", (unsigned int) &addr);

        do {
            printf("Address of integer variable: %x\n", (unsigned int) &integer);
            printf("Address of flt variable:     %x\n", (unsigned int) &flt);
            printf("Value of (int)integer variable: %d\n", integer);
            printf("Value of (float)flt variable:   %.2f\n\n", flt);
            printf(" ----------------------------------------\n");
            printf("|       1 - Edit Address                 |\n");
            printf("|       2 - Print Memory                 |\n");
            printf(" ----------------------------------------\n");
            printf("\tEnter choice: ");
            scanf(" %c", &ch);
            switch(ch) {
                case '1': edit_addr(); break;
                case '2': print_addr(); break;
                default: printf("You entered an invalid menu item\n");
            };

            printf("\nWould you like to continue? ");
            scanf(" %c", &ch);
            putchar('\n');
        } while (toupper(ch) != 'N');

        return 0;
    }

    void print_addr(void)
    {
        int i, n;
        BYTE *ptr;

        printf("\nEnter a (hex) address: ");
        scanf("%x", &addr);
        printf("Enter number of bytes to view: ");
        scanf("%d", &n);

        printf("\n");
        printf(" Address              Bytes              Characters\n");
        printf(" -------  -----------------------------  ----------\n");

        ptr = (BYTE *) addr;
        for (; n > 0; n -= 10) {
            printf("%8X  ", (unsigned int) ptr);
            for (i = 0; i < 10 && i < n; i++)
                printf("%.2X ", *(ptr + i));
            for (; i < 10; i++)
                printf("   ");
            printf(" ");
            for (i = 0; i < 10 && i < n; i++) {
                BYTE ch = *(ptr + i);
                if (!isprint(ch))
                    ch = '.';
                printf("%c", ch);
            }
            printf("\n");
            ptr += 10;
        }
    }

    void edit_addr(void)
    {
        int n, int_value, *int_ptr;
        float flt_value, *flt_ptr;

        printf("\n ----------------------------------------\n");
        printf("|       1 - Integer                      |\n");
        printf("|       2 - Float                        |\n");
        printf(" ----------------------------------------\n");
        do {
            printf("\tEnter choice: ");
            scanf(" %d", &n);
        } while (n != 1 && n != 2);

        printf("\nEnter a (hex) address: ");
        scanf("%x", &addr);

        printf("Enter the value: ");
        switch(n) {
            case 1:
                int_ptr = (int *) addr;
                scanf("%d", &int_value);
                *int_ptr = int_value;
                break;
            case 2:
                flt_ptr = (float *) addr;
                scanf("%f", &flt_value);
                *flt_ptr = flt_value;
                break;
        }
    }
4

0 回答 0