修改字符串常量
看了一本书,《加密与解密》,认识了一个函数,VirtualProtect,不敢独享...不多废话了,代码很简单
程序代码:
#include "stdio.h" #include "stdlib.h" #include "windows.h" int main(void) { char *str = "kankan"; DWORD new_p = 0x40; DWORD old_p; printf ("%s\n", str); VirtualProtect (str, 6, new_p, &old_p); str[2] = 'k'; //"kankan"[2] = 'k'; 这样也可以 VirtualProtect (str, 6, old_p, &new_p); printf ("%s\n", str); system ("pause"); return 0; }
[ 本帖最后由 pycansi 于 2014-6-12 15:12 编辑 ]