]> gitweb.factorcode.org Git - factor.git/blob - extra/elevate/windows/windows.factor
elevate.windows: Fix compile error.
[factor.git] / extra / elevate / windows / windows.factor
1 USING: accessors alien elevate io.launcher kernel math sequences
2 splitting strings system windows.errors windows.shell32
3 windows.user32 ;
4 IN: elevate.windows
5
6 <PRIVATE
7 ! TODO
8 M: windows already-root?
9     ! https://msdn.microsoft.com/en-us/library/windows/desktop/aa379296(v=vs.85).aspx
10     ! https://msdn.microsoft.com/en-us/library/windows/desktop/aa446671%28v=vs.85%29.aspx
11     ! https://msdn.microsoft.com/en-us/library/windows/desktop/ms683182(v=vs.85).aspx
12     f ;
13
14 M:: windows elevated ( $command $replace? $win-console? $posix-graphical? -- process )
15     already-root? [
16         <process> $command >>command
17     ] [
18         ! hwnd lpOperation
19         f "runas"
20         $command dup string? [ " " split ] when
21         ! lpFile lpParameters lpDirectory (enum)nShowCmd
22         [ first ] [ rest ] bi " " join f SW_SHOW
23         ! call shell function with questionable return pointer handling (should use WaitForSingleObject but it hangs)
24         ShellExecuteW alien-address :> $retval
25         $retval 32 <= [ $retval n>win32-error-check ] [ ] if
26         $replace? [ $retval exit ] [ ] if
27         $retval
28     ] if ;
29
30 ! no-op (not possible to lower)
31 M: windows lowered ;
32 PRIVATE>