Win32 SDK 程序!ReadProcessMemory ( hProcess ,(LPVOID)0x00449B40 ,(LPVOID)&dwBase ,sizeof(dwBase) ,NULL );程序可以成功编译,但是给出不少警告!!winmain.cpp
.\winmain.cpp(273) : warning C4312: “类型转换”: 从“DWORD”转换到更大的“LPVOID以前在 VC6 下是没有问题的,我在程序中 sizeof(LPVOID)结果返回 4 ,长度和 DWORD 一样啊,为什么强制转换时会给出 LPVOID 更大的警告!下面这个问题最重要,我怎么做能消掉这个警告!!!
.\winmain.cpp(273) : warning C4312: “类型转换”: 从“DWORD”转换到更大的“LPVOID以前在 VC6 下是没有问题的,我在程序中 sizeof(LPVOID)结果返回 4 ,长度和 DWORD 一样啊,为什么强制转换时会给出 LPVOID 更大的警告!下面这个问题最重要,我怎么做能消掉这个警告!!!
ReadProcessMemory ( hProcess ,reinterpret_cast<LPVOID>(0x00449B40) ,(LPVOID)&dwBase ,sizeof(dwBase) ,NULL );
警告是:
.\winmain.cpp(278) : warning C4312: “reinterpret_cast”: 从“DWORD”转换到更大的“LPVOID”
'operation' : conversion from 'type1' to 'type2' of greater size
This warning detects 64-bit portability issues. You attempted to assign a 32-bit value to a 64-bit type. For example, casting a 32-bit int or 32-bit long to a 64-bit pointer.This can be an unsafe conversion in some circumstances when sign extension occurs. If a negative number is assigned to a pointer type of a size greater than the int, sign extension will occur and the pointer value will refer to a memory address different from the value of the int.This warning is only issued when /Wp64 is used. See /Wp64 for more information. Also, see Rules for Using Pointers.The following code sample generates C4312: