2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Functions for creation and destruction of DCs
5 * FILE: subsystem/win32/win32k/objects/dcattr.c
6 * PROGRAMER: Timo Kreuzer (timo.kreuzer@rectos.org)
17 DC_AllocateDcAttr(HDC hDC
)
21 HANDLE Pid
= NtCurrentProcess();
22 ULONG MemSize
= sizeof(DC_ATTR
); //PAGE_SIZE it will allocate that size
24 NTSTATUS Status
= ZwAllocateVirtualMemory(Pid
,
28 MEM_COMMIT
|MEM_RESERVE
,
30 KeEnterCriticalRegion();
32 INT Index
= GDI_HANDLE_GET_INDEX((HGDIOBJ
)hDC
);
33 PGDI_TABLE_ENTRY Entry
= &GdiHandleTable
->Entries
[Index
];
34 // FIXME: dc could have been deleted!!! use GDIOBJ_InsertUserData
35 if (NT_SUCCESS(Status
))
37 RtlZeroMemory(NewMem
, MemSize
);
38 Entry
->UserData
= NewMem
;
39 DPRINT("DC_ATTR allocated! 0x%x\n",NewMem
);
43 DPRINT("DC_ATTR not allocated!\n");
46 KeLeaveCriticalRegion();
48 ASSERT(pDC
->pdcattr
== &pDC
->dcattr
);
51 pDC
->pdcattr
= NewMem
; // Store pointer
58 DC_FreeDcAttr(HDC DCToFree
)
60 HANDLE Pid
= NtCurrentProcess();
61 PDC pDC
= DC_LockDc(DCToFree
);
62 if (pDC
->pdcattr
== &pDC
->dcattr
) return; // Internal DC object!
63 pDC
->pdcattr
= &pDC
->dcattr
;
66 KeEnterCriticalRegion();
68 INT Index
= GDI_HANDLE_GET_INDEX((HGDIOBJ
)DCToFree
);
69 PGDI_TABLE_ENTRY Entry
= &GdiHandleTable
->Entries
[Index
];
72 ULONG MemSize
= sizeof(DC_ATTR
); //PAGE_SIZE;
73 NTSTATUS Status
= ZwFreeVirtualMemory(Pid
,
77 if (NT_SUCCESS(Status
))
79 DPRINT("DC_FreeDC DC_ATTR 0x%x\n", Entry
->UserData
);
80 Entry
->UserData
= NULL
;
84 KeLeaveCriticalRegion();
90 CopytoUserDcAttr(PDC dc
, PDC_ATTR pdcattr
)
92 NTSTATUS Status
= STATUS_SUCCESS
;
93 dc
->dcattr
.mxWorldToDevice
= dc
->dclevel
.mxWorldToDevice
;
94 dc
->dcattr
.mxDeviceToWorld
= dc
->dclevel
.mxDeviceToWorld
;
95 dc
->dcattr
.mxWorldToPage
= dc
->dclevel
.mxWorldToPage
;
99 ProbeForWrite( pdcattr
,
102 RtlCopyMemory( pdcattr
,
106 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
108 Status
= _SEH2_GetExceptionCode();
114 // FIXME: wtf? 2 functions, where one has a typo in the name????
117 DCU_SyncDcAttrtoUser(PDC dc
)
119 PDC_ATTR pdcattr
= dc
->pdcattr
;
121 if (pdcattr
== &dc
->dcattr
) return TRUE
; // No need to copy self.
123 CopytoUserDcAttr( dc
, pdcattr
);
129 DCU_SynchDcAttrtoUser(HDC hDC
)
132 PDC pDC
= DC_LockDc ( hDC
);
133 if (!pDC
) return FALSE
;
134 Ret
= DCU_SyncDcAttrtoUser(pDC
);