< prev index next >
src/java.base/windows/native/libjava/ProcessHandleImpl_win.c
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2014, 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 467,486 ****
JNU_CHECK_EXCEPTION(env);
}
}
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);
- }
}
static void procToUser(JNIEnv *env, HANDLE handle, jobject jinfo) {
#define TOKEN_LEN 256
DWORD token_len = TOKEN_LEN;
--- 467,498 ----
JNU_CHECK_EXCEPTION(env);
}
}
static void getCmdlineInfo(JNIEnv *env, HANDLE handle, jobject jinfo) {
! 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) {
#define TOKEN_LEN 256
DWORD token_len = TOKEN_LEN;
< prev index next >