-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# python3-win7-shim | ||
Shim DLL to run unpatched Python3.8+ on Win7 | ||
This is a shim DLL to run unpatched Python3.8+ on Windows 7. This built specifically for Python and is not a full featured, general purpose replacement for `api-ms-win-core-path-l1-1-0.dll`. | ||
|
||
It passes through these functions, and only works with `PATHCCH_NONE` flags:<br> | ||
`PathCchCanonicalizeEx() => PathCanonicalizeW()`<br> | ||
`PathCchCombineEx() => PathCombineW()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@echo off | ||
REM Make sure to run rustup install stable-i686-pc-windows-msvc | ||
REM rustup install stable-x86_64-pc-windows-msvc | ||
|
||
rmdir 64bit /s /q | ||
rmdir 32bit /s /q | ||
mkdir 64bit | ||
mkdir 32bit | ||
rustup default stable-i686-pc-windows-msvc | ||
rustc --target i686-pc-windows-msvc -C panic=abort -C target-feature=+crt-static -o 32bit/api-ms-win-core-path-l1-1-0.dll lib.rs | ||
rustup default stable-x86_64-pc-windows-msvc | ||
rustc --target x86_64-pc-windows-msvc -C panic=abort -C target-feature=+crt-static -o 64bit/api-ms-win-core-path-l1-1-0.dll lib.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![crate_type = "cdylib"] | ||
#![no_std] | ||
|
||
#[panic_handler] | ||
unsafe fn panic(_panic: &core::panic::PanicInfo) -> ! { ExitProcess(1); loop { } } | ||
|
||
#[no_mangle] | ||
unsafe extern "system" fn _DllMainCRTStartup(_: *const u8, _: u32, _: *const u8) -> u32 { 1 } | ||
|
||
#[link(name = "kernel32")] | ||
#[allow(non_snake_case)] | ||
extern "stdcall" { | ||
fn ExitProcess(exit_code: u32) -> (); | ||
} | ||
|
||
#[link(name = "shlwapi")] | ||
#[allow(non_snake_case)] | ||
extern "stdcall" { | ||
fn PathCanonicalizeW(path_out: *mut u8, path: *const u8) -> bool; | ||
fn PathCombineW(path_out: *mut u8, dir: *const u8, file: *const u8) -> usize; | ||
} | ||
|
||
const MAX_PATH: usize = 256; | ||
const S_OK: u32 = 0; | ||
const E_INVALIDARG: u32 = 0x80070057; | ||
const PATHCCH_NONE: u32 = 0; | ||
|
||
|
||
#[no_mangle] | ||
pub unsafe extern "stdcall" fn PathCchCanonicalizeEx(path_out_buf: *mut u8, buf_size: usize, path: *const u8, flags: u32) -> u32 { | ||
if flags != PATHCCH_NONE || buf_size < MAX_PATH { return E_INVALIDARG; } | ||
let success = PathCanonicalizeW(path_out_buf, path); | ||
return if success { S_OK } else { E_INVALIDARG }; | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "stdcall" fn PathCchCombineEx(path_out_buf: *mut u8, buf_size: usize, path: *const u8, path_more: *const u8, flags: u32) -> u32 { | ||
if flags != PATHCCH_NONE || buf_size < MAX_PATH { return E_INVALIDARG; } | ||
let str_ptr = PathCombineW(path_out_buf, path, path_more); | ||
return if str_ptr > 0 { S_OK } else { E_INVALIDARG }; | ||
} |