Job Object - Limit Write Clipboard prevent paste into and copy from host process
<p>Ok, so this is based on: <a href="http://stackoverflow.com/questions/6266820/working-example-of-createjobobject-setinformationjobobject-pinvoke-in-net">Working example of CreateJobObject/SetInformationJobObject pinvoke in .net?</a></p>

<p>I have created a job object and attached it to an instance of MS Word. The job object has the UI Restriction WriteClipboard. My assumption was that this should prevent people from copying from the document. But that they could still paste into it. However, with only this restriction I am prevented from doing both.</p>

<p>I know the Job Object has been applied as it appears correctly in the tab in process explorer after the AssignProcessToJobObject completes.</p>

<p>I would have thought this to be the behaviour if I had specified a LIMIT Read <strong>&amp;</strong> Write clipboard ui restriction.</p>

<p>Here is the constructor from the link above - ihave added the UIRestriction - Write Clipbard</p>

<pre><code>     public Job(string jobName) 
    { 

        handle = CreateJobObject(IntPtr.Zero, jobName); 

        var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION 
        { 
            LimitFlags = 0x2000 
        }; 

        var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION 
        { 
            BasicLimitInformation = info 
        };


        int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)); 
        IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length); 
        Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false); 

        if (!SetInformationJobObject(handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length)) 
            throw new Exception(string.Format("Unable to set information.  Error: {0}", Marshal.GetLastWin32Error()));

        ///UIRestrictions
        var uiRestrictions = new JOBOBJECT_BASIC_UI_RESTRICTIONS
        {
            UIRestrictionsClass = 0x00000004 //No write to clipboard
        };

        length = Marshal.SizeOf(typeof(JOBOBJECT_BASIC_UI_RESTRICTIONS)); 
        IntPtr basicUIInfoPtr = Marshal.AllocHGlobal(length); 
        Marshal.StructureToPtr(uiRestrictions, basicUIInfoPtr, false); 

        if (!SetInformationJobObject(handle, JobObjectInfoType.BasicUIRestrictions, basicUIInfoPtr, (uint)length)) 
            throw new Exception(string.Format("Unable to set information.  Error: {0}", Marshal.GetLastWin32Error())); 
    } 
</code></pre>

<p>Then in the main program I do the following:</p>

<pre><code>        Job j = new Job("NewJob");


        j.AddProcess(ProcID);
</code></pre>

<p>Where ProcID is the id of the process that I want to add the job to. I do check to see if the process already has a job before attempting to add one. Other than that I dont get any unusual errors and as I say the SysInternalstool, process explorer has the new job attached to the process.</p>

<p>Any ideas out there?</p>
