// ISAPIWorkerRequestInProcForIIS6
    protected override void GetAdditionalServerVariables() {
        if (_ecb == IntPtr.Zero)
            return;

        // _additionalServerVars should only be initialized once
        Debug.Assert(_additionalServerVars == null);
        if (_additionalServerVars != null)
            return;

        _additionalServerVars = new string[NUM_ADDITIONAL_SERVER_VARIABLES];

        ServerVarCharBuffer buffer = new ServerVarCharBuffer();

        try {
            int[] serverVarLengths = new int[NUM_ADDITIONAL_SERVER_VARIABLES];
            int r = 0;
            int hresult = UnsafeNativeMethods.EcbGetUnicodeServerVariables(_ecb, buffer.PinnedAddress, buffer.Length,
                                                                      serverVarLengths, serverVarLengths.Length, NUM_BASIC_SERVER_VARIABLES, ref r);
            if (r > buffer.Length) {
                buffer.Resize(r);
                hresult = UnsafeNativeMethods.EcbGetUnicodeServerVariables(_ecb, buffer.PinnedAddress, buffer.Length,
                                                                     serverVarLengths, serverVarLengths.Length, NUM_BASIC_SERVER_VARIABLES, ref r);
            }
            if (hresult != 0)
                Marshal.ThrowExceptionForHR(hresult);
            IntPtr current = buffer.PinnedAddress;

            for(int i = 0; i < _additionalServerVars.Length; i++) {
                _additionalServerVars[i] = Marshal.PtrToStringUni(current, serverVarLengths[i]);
                current = new IntPtr((long)current + 2L * (1L + serverVarLengths[i]));
            }
        }
        finally {
            buffer.Dispose();
        }
    }
    private String GetUnicodeServerVariable(int nameIndex) {
        String value = null;
        ServerVarCharBuffer buf = new ServerVarCharBuffer();

        try {
            value = GetUnicodeServerVariable(nameIndex, buf);
        }
        finally {
            buf.Dispose();
        }

        return value;
    }
    private void GetBasicServerVariables() {

        if (_ecb == IntPtr.Zero)
            return;
        // _basicServerVars should only be initialized once
        Debug.Assert(_basicServerVars == null);
        if (_basicServerVars != null)
            return;

        _basicServerVars = new string[NUM_BASIC_SERVER_VARIABLES];

        ServerVarCharBuffer buffer = new ServerVarCharBuffer();

        try {
            int[] serverVarLengths = new int[NUM_BASIC_SERVER_VARIABLES];
            int r = 0;
            int hresult = UnsafeNativeMethods.EcbGetUnicodeServerVariables(_ecb, buffer.PinnedAddress, buffer.Length,
                                                                     serverVarLengths, serverVarLengths.Length, 0, ref r);
            if (r > buffer.Length)
            {
                buffer.Resize(r);
                hresult = UnsafeNativeMethods.EcbGetUnicodeServerVariables(_ecb, buffer.PinnedAddress, buffer.Length,
                                                                     serverVarLengths, serverVarLengths.Length, 0, ref r);
            }

            Misc.ThrowIfFailedHr(hresult);

            IntPtr current = buffer.PinnedAddress;

            for(int i = 0; i < _basicServerVars.Length; i++) {
                _basicServerVars[i] = Marshal.PtrToStringUni(current, serverVarLengths[i]);
                current = new IntPtr((long)current + 2L * (1L + serverVarLengths[i]));
            }
            // special case variables
            _appPathTranslated = _basicServerVars[APPL_PHYSICAL_PATH];
            _method = _basicServerVars[REQUEST_METHOD];
            _path = _basicServerVars[PATH_INFO];
            _pathTranslated = _basicServerVars[PATH_TRANSLATED];
            _filePath = _basicServerVars[URL];
        }
        finally {
            buffer.Dispose();
        }
    }