我想知道如何绕过Windows 8.1中的保护模式,以便我的C程序可以访问其他应用程序的内存并更改其值......我知道可以这样做,因为我曾经使用内存编辑器来破解游戏;我只想自己建一个。下面只是一个基本的程序,我把它拼在一起,看看我是否可以编写一个可以模拟这样一个动作的程序。有用;当然问题是,由于受保护模式,如果我尝试访问程序范围之外的内存,它将崩溃。
/* 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;
}
}