|
1 | 1 | use super::super::super::windows_sys::*;
|
2 | 2 | use super::mystd::ffi::OsString;
|
3 |
| -#[cfg(windows)] |
4 |
| -use super::mystd::os::windows::prelude::*; |
5 | 3 | use super::{coff, mmap, Library, LibrarySegment};
|
6 | 4 | use alloc::vec;
|
7 | 5 | use alloc::vec::Vec;
|
@@ -47,7 +45,7 @@ unsafe fn add_loaded_images(ret: &mut Vec<Library>) {
|
47 | 45 | // Safety: long_path should be null-terminated
|
48 | 46 | #[cfg(target_os = "cygwin")]
|
49 | 47 | unsafe fn get_posix_path(long_path: &[u16]) -> Option<OsString> {
|
50 |
| - use std::os::unix::ffi::OsStringExt; |
| 48 | + use super::mystd::os::unix::ffi::OsStringExt; |
51 | 49 |
|
52 | 50 | unsafe extern "C" {
|
53 | 51 | fn cygwin_conv_path(
|
@@ -91,17 +89,20 @@ unsafe fn get_posix_path(long_path: &[u16]) -> Option<OsString> {
|
91 | 89 | }
|
92 | 90 |
|
93 | 91 | unsafe fn load_library(me: &MODULEENTRY32W) -> Option<Library> {
|
94 |
| - let pos = me |
95 |
| - .szExePath |
96 |
| - .iter() |
97 |
| - .position(|i| *i == 0) |
98 |
| - .unwrap_or(me.szExePath.len()); |
99 | 92 | #[cfg(windows)]
|
100 |
| - let name = OsString::from_wide(&me.szExePath[..pos]); |
| 93 | + let name = { |
| 94 | + use super::mystd::os::windows::prelude::*; |
| 95 | + let pos = me |
| 96 | + .szExePath |
| 97 | + .iter() |
| 98 | + .position(|i| *i == 0) |
| 99 | + .unwrap_or(me.szExePath.len()); |
| 100 | + OsString::from_wide(&me.szExePath[..pos]) |
| 101 | + }; |
101 | 102 | #[cfg(target_os = "cygwin")]
|
102 | 103 | // Safety: the path with max length MAX_PATH always contains a null
|
103 |
| - // terminator |
104 |
| - let name = unsafe { get_posix_path(&me.szExePath[..pos])? }; |
| 104 | + // terminator. Don't slice it. |
| 105 | + let name = unsafe { get_posix_path(&me.szExePath[..])? }; |
105 | 106 |
|
106 | 107 | // MinGW libraries currently don't support ASLR
|
107 | 108 | // (rust-lang/rust#16514), but DLLs can still be relocated around in
|
|
0 commit comments