use super::{HostState, Registry, StubFn, Win32Error, arg_dword};
use crate::emulator::emulator::{Cpu, Mmu};
const SE_OK: u32 = 33;
pub fn register(registry: &mut Registry) {
registry.register(
"shell32.dll",
"ShellExecuteA",
stub_shell_execute as StubFn,
6,
);
registry.register(
"shell32.dll",
"ShellExecuteW",
stub_shell_execute as StubFn,
6,
);
registry.register(
"shell32.dll",
"SHGetFolderPathW",
stub_sh_get_folder_path_w as StubFn,
5,
);
registry.register(
"shell32.dll",
"Shell_NotifyIconA",
stub_shell_notify_icon as StubFn,
2,
);
registry.register(
"shell32.dll",
"CommandLineToArgvW",
stub_command_line_to_argv_w as StubFn,
2,
);
}
fn stub_shell_execute(
_cpu: &mut Cpu,
_mmu: &mut Mmu,
_state: &mut HostState,
_registry: &mut Registry,
) -> Result<u32, Win32Error> {
Ok(SE_OK)
}
fn stub_sh_get_folder_path_w(
cpu: &mut Cpu,
mmu: &mut Mmu,
_state: &mut HostState,
_registry: &mut Registry,
) -> Result<u32, Win32Error> {
let path = arg_dword(cpu, mmu, 4)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("SHGetFolderPathW", t))?;
if path != 0 {
mmu.store16(path, 0)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("SHGetFolderPathW", t))?;
}
Ok(0)
}
fn stub_command_line_to_argv_w(
cpu: &mut Cpu,
mmu: &mut Mmu,
state: &mut HostState,
_registry: &mut Registry,
) -> Result<u32, Win32Error> {
let cmd = arg_dword(cpu, mmu, 0)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("CommandLineToArgvW", t))?;
let p_argc = arg_dword(cpu, mmu, 1)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("CommandLineToArgvW", t))?;
let argv_addr = state.arena_const_alloc(4)?;
mmu.store32(argv_addr, cmd)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("CommandLineToArgvW", t))?;
if p_argc != 0 {
mmu.store32(p_argc, 1)
.map_err(|t| crate::emulator::win32::trap_to_win32_local("CommandLineToArgvW", t))?;
}
Ok(argv_addr)
}
fn stub_shell_notify_icon(
_cpu: &mut Cpu,
_mmu: &mut Mmu,
_state: &mut HostState,
_registry: &mut Registry,
) -> Result<u32, Win32Error> {
Ok(1)
}