VC6能运行的代码VS2010不能运行
#include "windows.h"
#include "stdio.h"
#pragma comment(linker, "/INCREMENTAL:NO")
void Fun()
{
MessageBox(0,0,0,0);
}
void main()
{
LPVOID p = malloc(0x100);
memcpy(p,Fun,0x100);
_asm call p;
}
这段代码在Visual C++ 6.0里能运行,但是到了Visual Studio 2010里就不行了。
只有把malloc改成VirtualAlloc才行,为什么会这样啊,malloc会失败。
[解决办法]
刚才测试了一下,应该是malloc分配的内存的页属性的问题。
[解决办法]
Routine, Required Header
malloc, <stdlib.h> and <malloc.h>
memcpy, <memory.h> or <string.h>