< prev index next >
src/os/windows/vm/os_windows.cpp
Print this page
*** 1149,1174 ****
}
}
return dirp;
}
! /* parameter dbuf unused on Windows */
!
! struct dirent *
! os::readdir(DIR *dirp, dirent *dbuf)
{
assert(dirp != NULL, "just checking"); // hotspot change
if (dirp->handle == INVALID_HANDLE_VALUE) {
! return 0;
}
strcpy(dirp->dirent.d_name, dirp->find_data.cFileName);
if (!FindNextFile(dirp->handle, &dirp->find_data)) {
if (GetLastError() == ERROR_INVALID_HANDLE) {
errno = EBADF;
! return 0;
}
FindClose(dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
}
--- 1149,1171 ----
}
}
return dirp;
}
! struct dirent *os::readdir(DIR *dirp)
{
assert(dirp != NULL, "just checking"); // hotspot change
if (dirp->handle == INVALID_HANDLE_VALUE) {
! return NULL;
}
strcpy(dirp->dirent.d_name, dirp->find_data.cFileName);
if (!FindNextFile(dirp->handle, &dirp->find_data)) {
if (GetLastError() == ERROR_INVALID_HANDLE) {
errno = EBADF;
! return NULL;
}
FindClose(dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
}
*** 1648,1657 ****
--- 1645,1698 ----
int pid = os::current_process_id();
st->print_cr("Dynamic libraries:");
enumerate_modules(pid, _print_module, (void *)st);
}
+ int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
+ HANDLE hProcess;
+
+ # define MAX_NUM_MODULES 128
+ HMODULE modules[MAX_NUM_MODULES];
+ static char filename[MAX_PATH];
+ int result = 0;
+
+ int pid = os::current_process_id();
+ hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+ FALSE, pid);
+ if (hProcess == NULL) return 0;
+
+ DWORD size_needed;
+ if (!EnumProcessModules(hProcess, modules, sizeof(modules), &size_needed)) {
+ CloseHandle(hProcess);
+ return 0;
+ }
+
+ // number of modules that are currently loaded
+ int num_modules = size_needed / sizeof(HMODULE);
+
+ for (int i = 0; i < MIN2(num_modules, MAX_NUM_MODULES); i++) {
+ // Get Full pathname:
+ if (!GetModuleFileNameEx(hProcess, modules[i], filename, sizeof(filename))) {
+ filename[0] = '\0';
+ }
+
+ MODULEINFO modinfo;
+ if (!GetModuleInformation(hProcess, modules[i], &modinfo, sizeof(modinfo))) {
+ modinfo.lpBaseOfDll = NULL;
+ modinfo.SizeOfImage = 0;
+ }
+
+ // Invoke callback function
+ result = callback(filename, (address)modinfo.lpBaseOfDll,
+ (address)((u8)modinfo.lpBaseOfDll + (u8)modinfo.SizeOfImage), param);
+ if (result) break;
+ }
+
+ CloseHandle(hProcess);
+ return result;
+ }
+
void os::print_os_info_brief(outputStream* st) {
os::print_os_info(st);
}
void os::print_os_info(outputStream* st) {
*** 4325,4334 ****
--- 4366,4391 ----
jlong os::lseek(int fd, jlong offset, int whence) {
return (jlong) ::_lseeki64(fd, offset, whence);
}
+ size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+ OVERLAPPED ov;
+ DWORD nread;
+ BOOL result;
+
+ ZeroMemory(&ov, sizeof(ov));
+ ov.Offset = (DWORD)offset;
+ ov.OffsetHigh = (DWORD)(offset >> 32);
+
+ HANDLE h = (HANDLE)::_get_osfhandle(fd);
+
+ result = ReadFile(h, (LPVOID)buf, nBytes, &nread, &ov);
+
+ return result ? nread : 0;
+ }
+
// This method is a slightly reworked copy of JDK's sysNativePath
// from src/windows/hpi/src/path_md.c
/* Convert a pathname to native format. On win32, this involves forcing all
separators to be '\\' rather than '/' (both are legal inputs, but Win95
< prev index next >