Skip to content

Commit

Permalink
windows stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
chayleaf committed Jul 5, 2023
1 parent f5b1287 commit 8ab0e04
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ jobs:
with:
publish-release: true
build-win32:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: rs-action
uses: chayleaf/rs-actions@konigsberg
with:
publish-release: true
target: i686-pc-windows-msvc
build-win64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ unsafe fn parse_ver(ver: *const c_char) -> Option<Interface> {
}

#[allow(clippy::missing_safety_doc)]
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
unsafe extern "C" fn b_is_dlc_installed(_this: *mut c_void, _app_id: AppId_t) -> bool {
true
}
#[allow(clippy::missing_safety_doc)]
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
unsafe extern "fastcall" fn b_is_dlc_installed(
_this: *mut c_void,
_edx: usize,
_app_id: AppId_t,
) -> bool {
true
}
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
#[allow(clippy::missing_safety_doc, improper_ctypes_definitions)]
unsafe extern "C" fn user_has_license_for_app(
_this: *mut c_void,
Expand All @@ -60,7 +60,7 @@ unsafe extern "C" fn user_has_license_for_app(
) -> EUserHasLicenseForAppResult {
EUserHasLicenseForAppResult::k_EUserHasLicenseResultHasLicense
}
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
#[allow(clippy::missing_safety_doc, improper_ctypes_definitions)]
unsafe extern "fastcall" fn user_has_license_for_app(
_this: *mut c_void,
Expand All @@ -73,31 +73,31 @@ unsafe extern "fastcall" fn user_has_license_for_app(

#[derive(Copy, Clone)]
struct OrigSteamClientFns {
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
generic: Option<
unsafe extern "C" fn(*mut c_void, HSteamUser, HSteamPipe, *const c_char) -> *mut c_void,
>,
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
generic: unsafe extern "fastcall" fn(
*mut c_void,
usize,
HSteamUser,
HSteamPipe,
*const c_char,
) -> *mut c_void,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
apps: unsafe extern "C" fn(*mut c_void, HSteamUser, HSteamPipe, *const c_char) -> *mut c_void,
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
apps: unsafe extern "fastcall" fn(
*mut c_void,
usize,
HSteamUser,
HSteamPipe,
*const c_char,
) -> *mut c_void,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
user: unsafe extern "C" fn(*mut c_void, HSteamUser, HSteamPipe, *const c_char) -> *mut c_void,
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
user: unsafe extern "fastcall" fn(
*mut c_void,
usize,
Expand Down Expand Up @@ -143,7 +143,7 @@ unsafe fn steam_client_common(
)
}

#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "C" fn get_i_steam_generic_interface(
this: *mut c_void,
Expand All @@ -153,7 +153,7 @@ unsafe extern "C" fn get_i_steam_generic_interface(
) -> *mut c_void {
steam_client_common(this, steam_user, steam_pipe, ver, SteamClientFn::Generic)
}
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "fastcall" fn get_i_steam_generic_interface(
this: *mut c_void,
Expand All @@ -164,7 +164,7 @@ unsafe extern "fastcall" fn get_i_steam_generic_interface(
) -> *mut c_void {
steam_client_common(this, steam_user, steam_pipe, ver, SteamClientFn::Generic)
}
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "C" fn get_i_steam_user(
this: *mut c_void,
Expand All @@ -174,7 +174,7 @@ unsafe extern "C" fn get_i_steam_user(
) -> *mut c_void {
steam_client_common(this, steam_user, steam_pipe, ver, SteamClientFn::User)
}
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "fastcall" fn get_i_steam_user(
this: *mut c_void,
Expand All @@ -185,7 +185,7 @@ unsafe extern "fastcall" fn get_i_steam_user(
) -> *mut c_void {
steam_client_common(this, steam_user, steam_pipe, ver, SteamClientFn::User)
}
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "C" fn get_i_steam_apps(
this: *mut c_void,
Expand All @@ -195,7 +195,7 @@ unsafe extern "C" fn get_i_steam_apps(
) -> *mut c_void {
steam_client_common(this, steam_user, steam_pipe, ver, SteamClientFn::Apps)
}
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
#[allow(clippy::missing_safety_doc)]
unsafe extern "fastcall" fn get_i_steam_apps(
this: *mut c_void,
Expand Down Expand Up @@ -250,12 +250,12 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
// this is issubscribedapp, same sig as isdlcinstalled
(
6,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
b_is_dlc_installed
as unsafe extern "C" fn(*mut c_void, AppId_t) -> bool,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
b_is_dlc_installed
as unsafe extern "fastcall" fn(
Expand All @@ -270,12 +270,12 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
if n >= 3 {
patches.push((
7,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
b_is_dlc_installed
as unsafe extern "C" fn(*mut c_void, AppId_t) -> bool,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
b_is_dlc_installed
as unsafe extern "fastcall" fn(
Expand All @@ -299,7 +299,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
13..=14 => 16,
15.. => 17,
},
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
user_has_license_for_app
as unsafe extern "C" fn(
Expand All @@ -309,7 +309,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
)
-> EUserHasLicenseForAppResult,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
user_has_license_for_app
as unsafe extern "fastcall" fn(
Expand Down Expand Up @@ -346,7 +346,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
let mut patches = vec![
(
offset_apps,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
get_i_steam_apps
as unsafe extern "C" fn(
Expand All @@ -357,7 +357,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
)
-> *mut c_void,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
get_i_steam_apps
as unsafe extern "fastcall" fn(
Expand All @@ -372,7 +372,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
),
(
offset_user,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
get_i_steam_user
as unsafe extern "C" fn(
Expand All @@ -383,7 +383,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
)
-> *mut c_void,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
get_i_steam_user
as unsafe extern "fastcall" fn(
Expand All @@ -400,7 +400,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
if let Some(offset_generic) = offset_generic {
patches.push((
offset_generic,
#[cfg(any(not(target_os = "windows"), not(target_arch = "x86")))]
#[cfg(any(not(target_os = "windows"), not(target_pointer_width = "32")))]
std::mem::transmute(Some(
get_i_steam_generic_interface
as unsafe extern "C" fn(
Expand All @@ -411,7 +411,7 @@ unsafe fn patch_ptr(ver: Option<Interface>, ret: *mut c_void) -> *mut c_void {
)
-> *mut c_void,
)),
#[cfg(all(target_os = "windows", target_arch = "x86"))]
#[cfg(all(target_os = "windows", target_pointer_width = "32"))]
std::mem::transmute(Some(
get_i_steam_generic_interface
as unsafe extern "fastcall" fn(
Expand Down

0 comments on commit 8ab0e04

Please sign in to comment.