Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
evmar committed Sep 15, 2024
1 parent 6427aed commit acac080
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
4 changes: 3 additions & 1 deletion win32/src/winapi/kernel32/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Process initialization and startup.
use super::{EventObject, FindHandle, Mappings, ResourceHandle, DLL, HMODULE, STDERR_HFILE, STDOUT_HFILE};
use super::{
EventObject, FindHandle, Mappings, ResourceHandle, DLL, HMODULE, STDERR_HFILE, STDOUT_HFILE,
};
use crate::{
machine::MemImpl,
pe,
Expand Down
12 changes: 9 additions & 3 deletions win32/src/winapi/kernel32/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ pub fn find_resource<'a>(
let image = mem.slice(hInstance..);
if hInstance == kernel32.image_base {
let section = kernel32.resources.as_slice(image)?;
pe::find_resource(section, typ.into_pe(), name.into_pe()).map(|r| (hInstance + r.start)..(hInstance + r.end))
pe::find_resource(section, typ.into_pe(), name.into_pe())
.map(|r| (hInstance + r.start)..(hInstance + r.end))
} else {
let dll = kernel32.dlls.get(&HMODULE::from_raw(hInstance))?;
match dll.dll.resources.clone() {
None => return None,
Some(resources) => {
let section = resources.as_slice(image)?;
pe::find_resource(section, typ.into_pe(), name.into_pe()).map(|r| (hInstance + r.start)..(hInstance + r.end))
pe::find_resource(section, typ.into_pe(), name.into_pe())
.map(|r| (hInstance + r.start)..(hInstance + r.end))
}
}
}
Expand Down Expand Up @@ -125,7 +127,11 @@ pub fn FindResourceW(
lpName,
) {
None => HRSRC::null(),
Some(mem) => machine.state.kernel32.resource_handles.add(ResourceHandle(mem)),
Some(mem) => machine
.state
.kernel32
.resource_handles
.add(ResourceHandle(mem)),
}
}

Expand Down
12 changes: 6 additions & 6 deletions win32/src/winapi/kernel32/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ pub struct EventObject {
}

#[win32_derive::dllexport]
pub fn WaitForSingleObject(
_machine: &mut Machine,
hHandle: HEVENT,
dwMilliseconds: u32,
) -> u32 {
pub fn WaitForSingleObject(_machine: &mut Machine, hHandle: HEVENT, dwMilliseconds: u32) -> u32 {
todo!()
}

Expand All @@ -29,7 +25,11 @@ pub fn CreateEventA(
todo!("CreateEventA: named events not supported");
}

machine.state.kernel32.event_handles.add(EventObject { state: false })
machine
.state
.kernel32
.event_handles
.add(EventObject { state: false })
}

#[win32_derive::dllexport]
Expand Down
5 changes: 1 addition & 4 deletions win32/src/winapi/kernel32/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ pub async fn CreateThread(
}

#[win32_derive::dllexport]
pub fn ResumeThread(
_machine: &mut Machine,
hThread: HTHREAD,
) -> u32 {
pub fn ResumeThread(_machine: &mut Machine, hThread: HTHREAD) -> u32 {
1
}

Expand Down
1 change: 0 additions & 1 deletion win32/src/winapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl<'a> std::fmt::Display for ImportSymbol<'a> {
}

pub const DLLS: [builtin::BuiltinDLL; 16] = [

builtin::advapi32::DLL,
builtin::bass::DLL,
builtin::ddraw::DLL,
Expand Down
8 changes: 7 additions & 1 deletion win32/src/winapi/user32/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ pub fn SetMenu(_machine: &mut Machine, hWnd: HWND, hMenu: HMENU) -> bool {
}

#[win32_derive::dllexport]
pub fn SetMenuItemInfoA(_machine: &mut Machine, hMenu: HMENU, item: u32, fByPosition: bool, lpmii: u32) -> bool {
pub fn SetMenuItemInfoA(
_machine: &mut Machine,
hMenu: HMENU,
item: u32,
fByPosition: bool,
lpmii: u32,
) -> bool {
false // fail
}

Expand Down
2 changes: 1 addition & 1 deletion win32/src/winapi/wininet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn InternetOpenA(
dwAccessType: u32,
lpszProxy: Option<&str>,
lpszProxyBypass: Option<&str>,
dwFlags: u32
dwFlags: u32,
) -> u32 {
0
}

0 comments on commit acac080

Please sign in to comment.