⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
📖 第 1 页 / 共 2 页
字号:
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if(!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
  }
  else
  {
    DC_UnlockDc(dc);
    SetLastWin32Error(ERROR_INVALID_PARAMETER);
    return FALSE;
  }

  Ret = IntGdiPolyBezier(dc, Safept, Count);

  ExFreePool(Safept);
  DC_UnlockDc(dc);

  return Ret;
}

BOOL
STDCALL
NtGdiPolyBezierTo(HDC  hDC,
                 CONST LPPOINT  pt,
                 DWORD  Count)
{
  DC *dc;
  LPPOINT Safept;
  NTSTATUS Status = STATUS_SUCCESS;
  BOOL Ret;

  dc = DC_LockDc(hDC);
  if(!dc)
  {
    SetLastWin32Error(ERROR_INVALID_HANDLE);
    return FALSE;
  }
  if (dc->IsIC)
  {
    DC_UnlockDc(dc);
    /* Yes, Windows really returns TRUE in this case */
    return TRUE;
  }

  if(Count > 0)
  {
    _SEH_TRY
    {
      ProbeForRead(pt,
                   Count * sizeof(POINT),
                   1);
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if (!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
    
    Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_BEZIER);
    if(!Safept)
    {
      DC_UnlockDc(dc);
      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
      return FALSE;
    }

    _SEH_TRY
    {
      /* pointers were already probed */
      RtlCopyMemory(Safept,
                    pt,
                    Count * sizeof(POINT));
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if(!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
  }
  else
  {
    DC_UnlockDc(dc);
    SetLastWin32Error(ERROR_INVALID_PARAMETER);
    return FALSE;
  }

  Ret = IntGdiPolyBezierTo(dc, Safept, Count);

  ExFreePool(Safept);
  DC_UnlockDc(dc);

  return Ret;
}

BOOL
APIENTRY
NtGdiPolyDraw(
    IN HDC hdc,
    IN LPPOINT lppt,
    IN LPBYTE lpbTypes,
    IN ULONG cCount)
{
    PDC dc;
    BOOL result = FALSE;
    POINT lastmove;
    unsigned int i;

    dc = DC_LockDc(hdc); 
    if(!dc) return FALSE;

    _SEH_TRY
    {
        ProbeArrayForRead(lppt, sizeof(POINT), cCount, sizeof(LONG));
        ProbeArrayForRead(lpbTypes, sizeof(BYTE), cCount, sizeof(BYTE));
        
        /* check for each bezierto if there are two more points */
        for( i = 0; i < cCount; i++ )
        if( lpbTypes[i] != PT_MOVETO &&
            lpbTypes[i] & PT_BEZIERTO )
        {
            if( cCount < i+3 ) _SEH_LEAVE;
            else i += 2;
        }
    
        /* if no moveto occurs, we will close the figure here */
        lastmove.x = dc->Dc_Attr.ptlCurrent.x;
        lastmove.y = dc->Dc_Attr.ptlCurrent.y;
    
        /* now let's draw */
        for( i = 0; i < cCount; i++ )
        {
            if( lpbTypes[i] == PT_MOVETO )
            {
                IntGdiMoveToEx( dc, lppt[i].x, lppt[i].y, NULL );
                lastmove.x = dc->Dc_Attr.ptlCurrent.x;
                lastmove.y = dc->Dc_Attr.ptlCurrent.y;
            }
            else if( lpbTypes[i] & PT_LINETO )
                IntGdiLineTo( dc, lppt[i].x, lppt[i].y );
            else if( lpbTypes[i] & PT_BEZIERTO )
            {
                POINT pts[4];
                pts[0].x = dc->Dc_Attr.ptlCurrent.x;
                pts[0].y = dc->Dc_Attr.ptlCurrent.y;
                RtlCopyMemory(pts + 1, &lppt[i], sizeof(POINT) * 3);
                IntGdiPolyBezier(dc, pts, 4);
                i += 2;
            }
            else _SEH_LEAVE;
        
            if( lpbTypes[i] & PT_CLOSEFIGURE )
            {
                if( PATH_IsPathOpen( dc->w.path ) ) IntGdiCloseFigure( dc );
                else IntGdiLineTo( dc, lastmove.x, lastmove.y );
            }
        }
        
        result = TRUE;
    }
    _SEH_HANDLE
    {
        SetLastNtError(_SEH_GetExceptionCode());
    }
    _SEH_END;
    
    DC_UnlockDc(dc);

    return result;
}

BOOL
STDCALL
NtGdiPolyline(HDC            hDC,
             CONST LPPOINT  pt,
             int            Count)
{
  DC *dc;
  LPPOINT Safept;
  NTSTATUS Status = STATUS_SUCCESS;
  BOOL Ret;

  dc = DC_LockDc(hDC);
  if(!dc)
  {
    SetLastWin32Error(ERROR_INVALID_HANDLE);
    return FALSE;
  }
  if (dc->IsIC)
  {
    DC_UnlockDc(dc);
    /* Yes, Windows really returns TRUE in this case */
    return TRUE;
  }

  if(Count >= 2)
  {
    _SEH_TRY
    {
      ProbeForRead(pt,
                   Count * sizeof(POINT),
                   1);
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if (!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
    
    Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
    if(!Safept)
    {
      DC_UnlockDc(dc);
      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
      return FALSE;
    }

    _SEH_TRY
    {
      /* pointers were already probed */
      RtlCopyMemory(Safept,
                    pt,
                    Count * sizeof(POINT));
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if(!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
  }
  else
  {
    DC_UnlockDc(dc);
    SetLastWin32Error(ERROR_INVALID_PARAMETER);
    return FALSE;
  }

  Ret = IntGdiPolyline(dc, Safept, Count);

  ExFreePool(Safept);
  DC_UnlockDc(dc);

  return Ret;
}

BOOL
STDCALL
NtGdiPolylineTo(HDC            hDC,
               CONST LPPOINT  pt,
               DWORD          Count)
{
  DC *dc;
  LPPOINT Safept;
  NTSTATUS Status = STATUS_SUCCESS;
  BOOL Ret;

  dc = DC_LockDc(hDC);
  if(!dc)
  {
    SetLastWin32Error(ERROR_INVALID_HANDLE);
    return FALSE;
  }
  if (dc->IsIC)
  {
    DC_UnlockDc(dc);
    /* Yes, Windows really returns TRUE in this case */
    return TRUE;
  }

  if(Count > 0)
  {
    _SEH_TRY
    {
      ProbeForRead(pt,
                   Count * sizeof(POINT),
                   1);
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if (!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
    
    Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
    if(!Safept)
    {
      DC_UnlockDc(dc);
      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
      return FALSE;
    }

    _SEH_TRY
    {
      /* pointers were already probed */
      RtlCopyMemory(Safept,
                    pt,
                    Count * sizeof(POINT));
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if(!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
  }
  else
  {
    DC_UnlockDc(dc);
    SetLastWin32Error(ERROR_INVALID_PARAMETER);
    return FALSE;
  }

  Ret = IntGdiPolylineTo(dc, Safept, Count);

  ExFreePool(Safept);
  DC_UnlockDc(dc);

  return Ret;
}

BOOL
STDCALL
NtGdiPolyPolyline(HDC            hDC,
                 CONST LPPOINT  pt,
                 CONST LPDWORD  PolyPoints,
                 DWORD          Count)
{
  DC *dc;
  LPPOINT Safept;
  LPDWORD SafePolyPoints;
  NTSTATUS Status = STATUS_SUCCESS;
  BOOL Ret;

  dc = DC_LockDc(hDC);
  if(!dc)
  {
    SetLastWin32Error(ERROR_INVALID_HANDLE);
    return FALSE;
  }
  if (dc->IsIC)
  {
    DC_UnlockDc(dc);
    /* Yes, Windows really returns TRUE in this case */
    return TRUE;
  }

  if(Count > 0)
  {
    _SEH_TRY
    {
      ProbeForRead(pt,
                   Count * sizeof(POINT),
                   1);
      ProbeForRead(PolyPoints,
                   Count * sizeof(DWORD),
                   1);
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if (!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      SetLastNtError(Status);
      return FALSE;
    }
    
    Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(DWORD)) * Count, TAG_SHAPE);
    if(!Safept)
    {
      DC_UnlockDc(dc);
      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
      return FALSE;
    }

    SafePolyPoints = (LPDWORD)&Safept[Count];
    
    _SEH_TRY
    {
      /* pointers were already probed */
      RtlCopyMemory(Safept,
                    pt,
                    Count * sizeof(POINT));
      RtlCopyMemory(SafePolyPoints,
                    PolyPoints,
                    Count * sizeof(DWORD));
    }
    _SEH_HANDLE
    {
      Status = _SEH_GetExceptionCode();
    }
    _SEH_END;

    if(!NT_SUCCESS(Status))
    {
      DC_UnlockDc(dc);
      ExFreePool(Safept);
      SetLastNtError(Status);
      return FALSE;
    }
  }
  else
  {
    DC_UnlockDc(dc);
    SetLastWin32Error(ERROR_INVALID_PARAMETER);
    return FALSE;
  }

  Ret = IntGdiPolyPolyline(dc, Safept, SafePolyPoints, Count);

  ExFreePool(Safept);
  DC_UnlockDc(dc);

  return Ret;
}

/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -