Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8232846: ProcessHandle.Info command with non-English shows question m…
…arks
Reviewed-by: stuefe, ysuenaga, rriggs
- Loading branch information
Showing
with
22 additions
and
10 deletions.
-
+22
−10
src/java.base/windows/native/libjava/ProcessHandleImpl_win.c
|
|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
|
|
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. |
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
|
* |
|
|
* This code is free software; you can redistribute it and/or modify it |
|
@@ -469,16 +469,28 @@ static void getStatInfo(JNIEnv *env, HANDLE handle, jobject jinfo) { |
|
|
} |
|
|
|
|
|
static void getCmdlineInfo(JNIEnv *env, HANDLE handle, jobject jinfo) { |
|
|
char exeName[1024]; |
|
|
int bufsize = sizeof exeName; |
|
|
jstring commandObj; |
|
|
|
|
|
if (QueryFullProcessImageName(handle, 0, exeName, &bufsize)) { |
|
|
commandObj = (*env)->NewStringUTF(env, exeName); |
|
|
CHECK_NULL(commandObj); |
|
|
(*env)->SetObjectField(env, jinfo, |
|
|
ProcessHandleImpl_Info_commandID, commandObj); |
|
|
WCHAR exeName[1024]; |
|
|
WCHAR *longPath; |
|
|
DWORD bufsize = sizeof(exeName)/sizeof(WCHAR); |
|
|
jstring commandObj = NULL; |
|
|
|
|
|
if (QueryFullProcessImageNameW(handle, 0, exeName, &bufsize)) { |
|
|
commandObj = (*env)->NewString(env, (const jchar *)exeName, |
|
|
(jsize)wcslen(exeName)); |
|
|
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { |
|
|
bufsize = 32768; |
|
|
longPath = (WCHAR*)malloc(bufsize * sizeof(WCHAR)); |
|
|
if (longPath != NULL) { |
|
|
if (QueryFullProcessImageNameW(handle, 0, longPath, &bufsize)) { |
|
|
commandObj = (*env)->NewString(env, (const jchar *)longPath, |
|
|
(jsize)wcslen(longPath)); |
|
|
} |
|
|
free(longPath); |
|
|
} |
|
|
} |
|
|
CHECK_NULL(commandObj); |
|
|
(*env)->SetObjectField(env, jinfo, |
|
|
ProcessHandleImpl_Info_commandID, commandObj); |
|
|
} |
|
|
|
|
|
static void procToUser(JNIEnv *env, HANDLE handle, jobject jinfo) { |
|
|