Irksome sth
From ReactOS
| This page is probably outdated The information on this page might not be valid for the current state of ReactOS. |
This page is about confusing dev sth.
- grep all GDIOBJ_AllocObj ( check the macros that point to it ) and make sure we handle failure gracefully <@Royce3>
(GDIOBJ_AllocObj)
- reactos/subsys/win32k/objects/palette.c: NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
- reactos/subsys/win32k/objects/palette.c: NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
- reactos/subsys/win32k/objects/gdiobj.c:GDIOBJ_AllocObjDbg(const char* file, int line, ULONG ObjectType)
- reactos/subsys/win32k/objects/gdiobj.c:GDIOBJ_AllocObj(ULONG ObjectType)
- reactos/subsys/win32k/objects/gdiobj.c: DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, ObjectBody);
- reactos/subsys/win32k/objects/region.c: if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
- reactos/subsys/win32k/objects/dc.c: hDC = (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
- reactos/subsys/win32k/ntddraw/ddraw.c: HANDLE hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
- reactos/subsys/win32k/ntddraw/ddraw.c: hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
(Macros that point to GDIOBJ_AllocObj) - reactos/include/win32k/gdiobj.h:#define GDIOBJ_AllocObj(ty) GDIOBJ_AllocObjDbg(__FILE__,__LINE__,ty) - reactos/include/win32k/gdiobj.h:HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObjDbg(const char* file, int line, ULONG ObjectType); - reactos/include/win32k/gdiobj.h:HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(ULONG ObjectType); - reactos/include/win32k/bitmaps.h: ((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP)) - reactos/include/win32k/pen.h:#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN)) - reactos/include/win32k/brush.h:#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH)) - reactos/include/win32k/text.h: ((HFONT) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_FONT))
(PENOBJ_AllocPen) - reactos/subsys/win32k/objects/pen.c: hPen = PENOBJ_AllocPen();
(BRUSHOBJ_AllocBrush) - reactos/subsys/win32k/objects/brush.c: hBrush = BRUSHOBJ_AllocBrush();
(BITMAPOBJ_AllocBitmap) - reactos/subsys/win32k/eng/surface.c: NewBitmap = BITMAPOBJ_AllocBitmap(); - reactos/subsys/win32k/eng/surface.c: NewSurface = (HSURF)BITMAPOBJ_AllocBitmap();
- grep all GDIOBJ_LockObj ( again macros... ) and make sure we handle those failures gracefully too <@Royce3>
(GDIOBJ_LockObj)
- reactos/subsys/win32k/objects/gdiobj.c: pList[i].pObj = GDIOBJ_LockObj(pList[i].hObj, pList[i].ObjectType);
- reactos/subsys/win32k/objects/gdiobj.c:GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
- reactos/subsys/win32k/objects/gdiobj.c:GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType)
- reactos/subsys/win32k/objects/gdiobj.c: DPRINT("GDIOBJ_LockObj: hObj: 0x%08x\n", hObj);
- reactos/subsys/win32k/objects/gdiobj.c: * Release GDI object. Every object locked by GDIOBJ_LockObj() must be unlocked. You should unlock the object
- reactos/subsys/win32k/objects/bitmaps.c: Bitmap = GDIOBJ_LockObj(hBitmap, GDI_OBJECT_TYPE_BITMAP);
- reactos/subsys/win32k/objects/dc.c: GdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
- reactos/subsys/win32k/objects/dc.c: ptr = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_SURFACE pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_SURFACE pSurfaceFrom = GDIOBJ_LockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
- reactos/subsys/win32k/ntddraw/ddraw.c: PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
(Macros that point to GDIOBJ_LockObj) - reactos/include/win32k/gdiobj.h:#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty) - reactos/include/win32k/gdiobj.h:PGDIOBJ INTERNAL_CALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType); - reactos/include/win32k/gdiobj.h:PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType); - reactos/include/win32k/bitmaps.h:#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP) - reactos/include/win32k/pen.h:#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)) - reactos/include/win32k/brush.h:#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)) - reactos/include/win32k/region.h:#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)) - reactos/include/win32k/text.h:#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)) - reactos/include/win32k/dc.h: ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC)) - reactos/subsys/win32k/include/palette.h:#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)) - reactos/subsys/win32k/include/dce.h:#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
- surround every instance of MmProbeAndLockPages with seh <@arty>
- ASSERT_KM_POINTER(x) for every x received by an internal kernel function <@arty>
- the MmProbeAndLockPages in IoBuildAsyncFsdRequest (called by IoBuildSynchronousFsdRequest) is not checked, NtReadFile and kin don't check and neither do any filesystems. Somebody needs to figure out whether this user memory is clean. <@arty>
- Check 2nd degree user pointers and capture their address space. <@arty>
- Capture the address space of every METHOD_NEITHER and METHOD_DIRECT pointer used by an ioctl in kernel space. <@arty>
- Eradicate TAG_NONE - while that won't directly affect stability, it helps hunt down problems ;) <@Royce3>
- Security review:
- Check that proper cleanup is done in failure paths of all components. This is usually untested code. Start with the most critical components. - Check that untrusted data is handled responsibly
A property "ros:reviewed" can be used to track which directories/files have been reviewed. <@chorns>
Replace all these with the Rtlp equivalents (ntoskrnl/w32k):
RtlUnicodeStringToAnsiString RtlOemStringToUnicodeString RtlUnicodeStringToOemString RtlOemStringToCountedUnicodeString RtlUnicodeStringToCountedOemString RtlUpcaseUnicodeString RtlUpcaseUnicodeStringToAnsiString RtlUpcaseUnicodeStringToCountedOemString RtlUpcaseUnicodeStringToOemString RtlCreateUnicodeString RtlDowncaseUnicodeString RtlAnsiStringToUnicodeString RtlDuplicateUnicodeString
Why? All these funcs. allocate memory internally. In Windows PagedPool it used, but in Ros NonPagedPool is incorrectly used when the Rtl variant is used. Therefore i made Rtlp equivalents where an extra argumtnt "PoolType" must be specified. When all these calls are converted to the Rtlp variant, the default PoolType might be changed to PagedPool for the Rtl variants. I tried converting a few, but it was to hard to know if Paged or NonPaged mem was required. I also spotted lots of mem allocs where i'm pretty sure PagedPool is sufficient but NonPagedPool is (incorrectly?) used.
Gunnar.

