use of com.ibm.j9ddr.corereaders.memory.IMemory in project openj9 by eclipse.
the class MiniDumpReader method getCommandLine.
String getCommandLine() throws CorruptDataException, DataUnavailableException {
// For dumps from Windows Vista, Server 2008 and later, we have no way to find the command line
if (_windowsMajorVersion >= 6) {
throw new DataUnavailableException("Command line not available from Windows core dump");
}
// For dumps from older Windows versions, we can get the command line from the known PEB location
String commandLine = null;
try {
IMemory memory = getMemory();
short length;
long commandAddress;
if (is64Bit()) {
length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_64);
commandAddress = memory.getLongAt(COMMAND_LINE_ADDRESS_ADDRESS_64);
} else {
length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_32);
commandAddress = 0xFFFFFFFF & memory.getIntAt(COMMAND_LINE_ADDRESS_ADDRESS_32);
}
if (commandAddress == 0) {
throw new DataUnavailableException("Command line not in core file");
}
byte[] buf = new byte[length];
memory.getBytesAt(commandAddress, buf);
// FIXME: Should UTF-16LE be hard coded here? Is the encoding platform
// specific?
commandLine = new String(buf, "UTF-16LE");
return commandLine;
} catch (Exception e) {
// throw a corrupt data exception as we expect the command line to be present so DataUnavailable is not appropriate
throw new CorruptDataException("Failed to read command line from core file", e);
}
}
Aggregations