Merge branch 'master' of git://factorcode.org/git/factor
commit
0968938917
|
@ -1,44 +1,43 @@
|
|||
USING: alien alien.c-types alien.data alien.syntax arrays continuations
|
||||
destructors generic io.mmap io.ports io.backend.windows io.files.windows
|
||||
kernel libc math math.bitwise namespaces quotations sequences windows
|
||||
windows.advapi32 windows.kernel32 windows.types io.backend system accessors
|
||||
io.backend.windows.privileges windows.errors ;
|
||||
IN: io.backend.windows.nt.privileges
|
||||
|
||||
TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
|
||||
|
||||
! Security tokens
|
||||
! http://msdn.microsoft.com/msdnmag/issues/05/03/TokenPrivileges/
|
||||
|
||||
: (open-process-token) ( handle -- handle )
|
||||
{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } flags PHANDLE <c-object>
|
||||
[ OpenProcessToken win32-error=0/f ] keep *void* ;
|
||||
|
||||
: open-process-token ( -- handle )
|
||||
#! remember to CloseHandle
|
||||
GetCurrentProcess (open-process-token) ;
|
||||
|
||||
: with-process-token ( quot -- )
|
||||
#! quot: ( token-handle -- token-handle )
|
||||
[ open-process-token ] dip
|
||||
[ keep ] curry
|
||||
[ CloseHandle drop ] [ ] cleanup ; inline
|
||||
|
||||
: lookup-privilege ( string -- luid )
|
||||
[ f ] dip LUID <struct>
|
||||
[ LookupPrivilegeValue win32-error=0/f ] keep ;
|
||||
|
||||
: make-token-privileges ( name ? -- obj )
|
||||
TOKEN_PRIVILEGES <struct>
|
||||
1 >>PrivilegeCount
|
||||
LUID_AND_ATTRIBUTES malloc-struct &free
|
||||
swap [ SE_PRIVILEGE_ENABLED >>Attributes ] when
|
||||
>>Privileges
|
||||
[ lookup-privilege ] dip
|
||||
[ Privileges>> (>>Luid) ] keep ;
|
||||
|
||||
M: winnt set-privilege ( name ? -- )
|
||||
[
|
||||
-rot 0 -rot make-token-privileges
|
||||
dup length f f AdjustTokenPrivileges win32-error=0/f
|
||||
] with-process-token ;
|
||||
USING: alien alien.c-types alien.data alien.syntax arrays continuations
|
||||
destructors generic io.mmap io.ports io.backend.windows io.files.windows
|
||||
kernel libc locals math math.bitwise namespaces quotations sequences windows
|
||||
windows.advapi32 windows.kernel32 windows.types io.backend system accessors
|
||||
io.backend.windows.privileges classes.struct windows.errors ;
|
||||
IN: io.backend.windows.nt.privileges
|
||||
|
||||
TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
|
||||
|
||||
! Security tokens
|
||||
! http://msdn.microsoft.com/msdnmag/issues/05/03/TokenPrivileges/
|
||||
|
||||
: (open-process-token) ( handle -- handle )
|
||||
{ TOKEN_ADJUST_PRIVILEGES TOKEN_QUERY } flags PHANDLE <c-object>
|
||||
[ OpenProcessToken win32-error=0/f ] keep *void* ;
|
||||
|
||||
: open-process-token ( -- handle )
|
||||
#! remember to CloseHandle
|
||||
GetCurrentProcess (open-process-token) ;
|
||||
|
||||
: with-process-token ( quot -- )
|
||||
#! quot: ( token-handle -- token-handle )
|
||||
[ open-process-token ] dip
|
||||
[ keep ] curry
|
||||
[ CloseHandle drop ] [ ] cleanup ; inline
|
||||
|
||||
: lookup-privilege ( string -- luid )
|
||||
[ f ] dip LUID <struct>
|
||||
[ LookupPrivilegeValue win32-error=0/f ] keep ;
|
||||
|
||||
:: make-token-privileges ( name enabled? -- obj )
|
||||
TOKEN_PRIVILEGES <struct>
|
||||
1 >>PrivilegeCount
|
||||
LUID_AND_ATTRIBUTES malloc-struct &free
|
||||
enabled? [ SE_PRIVILEGE_ENABLED >>Attributes ] when
|
||||
name lookup-privilege >>Luid
|
||||
>>Privileges ;
|
||||
|
||||
M: winnt set-privilege ( name ? -- )
|
||||
[
|
||||
-rot 0 -rot make-token-privileges
|
||||
dup byte-length f f AdjustTokenPrivileges win32-error=0/f
|
||||
] with-process-token ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: alien.syntax kernel math windows.types windows.kernel32
|
||||
math.bitwise ;
|
||||
math.bitwise classes.struct ;
|
||||
IN: windows.advapi32
|
||||
|
||||
LIBRARY: advapi32
|
||||
|
|
|
@ -690,8 +690,8 @@ STRUCT: OFSTRUCT
|
|||
{ nErrCode WORD }
|
||||
{ Reserved1 WORD }
|
||||
{ Reserved2 WORD }
|
||||
! { szPathName { CHAR OFS_MAXPATHNAME } } ;
|
||||
{ szPathName { CHAR 128 } } ;
|
||||
! { szPathName { CHAR OFS_MAXPATHNAME } } ;
|
||||
|
||||
TYPEDEF: OFSTRUCT* LPOFSTRUCT
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ TYPEDEF: uchar UCHAR
|
|||
TYPEDEF: uchar BYTE
|
||||
|
||||
TYPEDEF: ushort wchar_t
|
||||
SYMBOL: wchar_t*
|
||||
<<
|
||||
{ char* utf16n } \ wchar_t* typedef
|
||||
\ wchar_t \ wchar_t* "pointer-c-type" set-word-prop
|
||||
>>
|
||||
|
||||
TYPEDEF: wchar_t WCHAR
|
||||
|
||||
TYPEDEF: short SHORT
|
||||
|
@ -70,9 +76,6 @@ TYPEDEF: ulonglong ULARGE_INTEGER
|
|||
TYPEDEF: LARGE_INTEGER* PLARGE_INTEGER
|
||||
TYPEDEF: ULARGE_INTEGER* PULARGE_INTEGER
|
||||
|
||||
SYMBOL: wchar_t*
|
||||
<< { char* utf16n } \ wchar_t* typedef >>
|
||||
|
||||
TYPEDEF: wchar_t* LPCSTR
|
||||
TYPEDEF: wchar_t* LPWSTR
|
||||
TYPEDEF: WCHAR TCHAR
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2009 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.syntax alien.destructors ;
|
||||
USING: alien.syntax alien.destructors classes.struct ;
|
||||
IN: windows.usp10
|
||||
|
||||
LIBRARY: usp10
|
||||
|
|
|
@ -204,8 +204,8 @@ CONSTANT: MAX_PROTOCOL_CHAIN 7
|
|||
|
||||
STRUCT: WSAPROTOCOLCHAIN
|
||||
{ ChainLen int }
|
||||
! { ChainEntries { DWORD MAX_PROTOCOL_CHAIN } } ;
|
||||
{ ChainEntries { DWORD 7 } } ;
|
||||
! { ChainEntries { DWORD MAX_PROTOCOL_CHAIN } } ;
|
||||
TYPEDEF: WSAPROTOCOLCHAIN* LPWSAPROTOCOLCHAIN
|
||||
|
||||
CONSTANT: WSAPROTOCOL_LEN 255
|
||||
|
|
Loading…
Reference in New Issue