Skip to content
Permalink
Browse files

8232846: ProcessHandle.Info command with non-English shows question m…

…arks

Reviewed-by: stuefe, ysuenaga, rriggs
  • Loading branch information
Toshio Nakamura committed Mar 28, 2020
1 parent 253ccad commit 7f8d7850860cb96a37ea49ed57d931b009d4f800
Showing with 22 additions and 10 deletions.
  1. +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) {

0 comments on commit 7f8d785

Please sign in to comment.