From: CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 24-SEP-1990 13:02:25.23 To: MRGATE::"ARISIA::EVERHART" CC: Subj: Re: How to change the UIC of a running process from VAX C? Received: by crdgw1.ge.com (5.57/GE 1.73) id AA00355; Mon, 24 Sep 90 12:30:20 EDT Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Mon, 24 SEP 90 08:04:51 PDT Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08334; Mon, 24 Sep 90 07:49:10 -0700 Received: from USENET by ucbvax.Berkeley.EDU with netnews for info-vax@kl.sri.com (info-vax@kl.sri.com) (contact usenet@ucbvax.Berkeley.EDU if you have questions) Date: 24 Sep 90 14:13:30 GMT From: cert!netnews.upenn.edu!scotty.dccs.upenn.edu!kehoe@lll-winken.llnl.gov (Brendan Kehoe) Organization: University of Pennsylvania Subject: Re: How to change the UIC of a running process from VAX C? Message-Id: <30018@netnews.upenn.edu> References: <1990Sep21.152418.21872@westc.uucp> Sender: info-vax-request@kl.sri.com To: info-vax@kl.sri.com In <1990Sep21.152418.21872@westc.uucp>, gertjan@westc.uucp writes: >I have a C program that needs to change its UIC. I know it can be done, >because "SET UIC" can do it. I also know, that I need to have CMKRNL >privilege (which isn't a problem, because the program runs as SYSTEM). Here's a Macro version; I'd just call the routine in C and compile the object files together into the executable. -- cut -- ; ; SWAPUIC.MAR - Store your current UIC and change it to something else. Or, ; restore a swapped UIC back to the original. Useful for cap- ; tive accounts where users must change their UIC temporarily. ; The program stores the actual UIC in a SPARE location in the ; process header. When run again, the stored value is return- ; ed to the original UIC. CMKRNL privilege is required. ; ; VAX Macro, VAX/VMS Version 5.1, 5/20/90, Jeff Austin ; bcl017@pgate.boeing.com or austinj@pgate.boeing.com ; .LIBRARY "SYS$LIBRARY:LIB.MLB" ; Use the MACRO library ; $PCBDEF ; Process Control Block offsets $PHDDEF ; Process Header offsets $IPLDEF ; Define Interrupt Priority Levels ; UIC: .WORD ^O123 ; UIC member word .WORD ^O456 ; UIC group word ; .ENTRY KERNEL, 0 ; Kernel mode code SETIPL #IPL$_SYNCH, ENVIRON = UNIPROCESSOR ; Synch w/scheduler MOVL PCB$L_PHD(R4), R8 ; Point R8 to the PHD CMPL PHD$L_NS_SPARE(R8), #0 ; Is a UIC here? BEQL 10$ ; No, then store it MOVL PHD$L_NS_SPARE(R8), PCB$L_UIC(R4) ; Yes, restore it CLRL PHD$L_NS_SPARE(R8) ; Clear the spare JMP 20$ 10$: MOVL PCB$L_UIC(R4), PHD$L_NS_SPARE(R8) ; Move UIC to SPARE MOVL UIC, PCB$L_UIC(R4) ; Set new UIC value 20$: SETIPL #0, ENVIRON = UNIPROCESSOR ; Lower IPL to normal MOVL #SS$_NORMAL, R0 ; Return NORMAL status RET ; .ENTRY SETUIC, 0 ; Main program $CMKRNL_S ROUTIN = KERNEL ; Jump into kernel mode $EXIT_S R0 ; Exit with NOPRIV or NORMAL .END SETUIC ; End main -- cut -- Thanks to Jeff for the code. -- Brendan Kehoe | Soon: brendan@cs.widener.edu For now: kehoe@scotty.dccs.upenn.edu | Or: bkehoe@widener.bitnet Last resort: brendan.kehoe@cyber.widener.edu Brendan Kehoe | Soon: brendan@cs.widener.edu For now: kehoe@scotty.dccs.upenn.edu | Or: bkehoe@widener.bitnet Last resort: brendan.kehoe@cyber.widener.edu