diff --git a/basis/io/backend/windows/nt/privileges/privileges.factor b/basis/io/backend/windows/nt/privileges/privileges.factor index 6acc1f3544..bb075233bd 100755 --- a/basis/io/backend/windows/nt/privileges/privileges.factor +++ b/basis/io/backend/windows/nt/privileges/privileges.factor @@ -1,44 +1,44 @@ -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 - [ 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 - [ LookupPrivilegeValue win32-error=0/f ] keep ; - -: make-token-privileges ( name ? -- obj ) - TOKEN_PRIVILEGES - 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 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 + [ 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 + [ LookupPrivilegeValue win32-error=0/f ] keep ; + +: make-token-privileges ( name ? -- obj ) + TOKEN_PRIVILEGES + 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 ; diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index 2e59b9fec1..dc751e64a6 100755 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -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