6787009: (attach) Stub injection potentially unsafe on windows-x64
Reviewed-by: mchung
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Fri Dec 19 22:07:37 2008 -0800
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Mon Dec 22 19:28:49 2008 +0000
@@ -345,7 +345,6 @@
DataBlock data;
DataBlock* pData;
DWORD* pCode;
- DWORD numBytes;
DWORD stubLen;
HANDLE hProcess, hThread;
jint argsLen, i;
@@ -400,7 +399,7 @@
JNU_ThrowIOExceptionWithLastError(env, "VirtualAllocEx failed");
return;
}
- WriteProcessMemory( hProcess, (LPVOID)pData, (LPVOID)&data, (DWORD)sizeof(DataBlock), &numBytes );
+ WriteProcessMemory( hProcess, (LPVOID)pData, (LPCVOID)&data, (SIZE_T)sizeof(DataBlock), NULL );
stubLen = (DWORD)(*env)->GetArrayLength(env, stub);
@@ -412,7 +411,7 @@
VirtualFreeEx(hProcess, pData, 0, MEM_RELEASE);
return;
}
- WriteProcessMemory( hProcess, (LPVOID)pCode, (LPVOID)stubCode, (DWORD)stubLen, &numBytes );
+ WriteProcessMemory( hProcess, (LPVOID)pCode, (LPCVOID)stubCode, (SIZE_T)stubLen, NULL );
if (isCopy) {
(*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT);
}