ReactOS 0.4.15-dev-8127-g6338913
misc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  INTENG_ENTER_LEAVE_TAG
 

Macros

#define ExInitializePushLock   _ExInitializePushLock
 

Typedefs

typedef struct INTENG_ENTER_LEAVE_TAG INTENG_ENTER_LEAVE
 
typedef struct INTENG_ENTER_LEAVE_TAGPINTENG_ENTER_LEAVE
 
typedef struct _GDI_POOLPGDI_POOL
 

Functions

BOOL APIENTRY IntEngEnter (PINTENG_ENTER_LEAVE EnterLeave, SURFOBJ *DestObj, RECTL *DestRect, BOOL ReadOnly, POINTL *Translate, SURFOBJ **OutputObj)
 
BOOL APIENTRY IntEngLeave (PINTENG_ENTER_LEAVE EnterLeave)
 
BOOL InitializeGreCSRSS (VOID)
 
USHORT FASTCALL UserGetLanguageID (VOID)
 
PVOID APIENTRY HackSecureVirtualMemory (IN PVOID, IN SIZE_T, IN ULONG, OUT PVOID *)
 
VOID APIENTRY HackUnsecureVirtualMemory (IN PVOID)
 
NTSTATUS NTAPI RegOpenKey (LPCWSTR pwszKeyName, PHKEY phkey)
 
NTSTATUS NTAPI RegQueryValue (IN HKEY hkey, IN PCWSTR pwszValueName, IN ULONG ulType, OUT PVOID pvData, IN OUT PULONG pcbValue)
 
VOID NTAPI RegWriteSZ (HKEY hkey, PCWSTR pwszValue, PWSTR pwszData)
 
VOID NTAPI RegWriteDWORD (HKEY hkey, PCWSTR pwszValue, DWORD dwData)
 
BOOL NTAPI RegReadDWORD (HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
 
DWORD NTAPI RegGetSectionDWORD (LPCWSTR pszSection, PCWSTR pszValue, DWORD dwDefault)
 
VOID FASTCALL SetLastNtError (_In_ NTSTATUS Status)
 
PGDI_POOL NTAPI GdiPoolCreate (ULONG cjAllocSize, ULONG ulTag)
 
VOID NTAPI GdiPoolDestroy (PGDI_POOL pPool)
 
PVOID NTAPI GdiPoolAllocate (PGDI_POOL pPool)
 
VOID NTAPI GdiPoolFree (PGDI_POOL pPool, PVOID pvAlloc)
 
FORCEINLINE VOID ExAcquirePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE BOOLEAN ExTryAcquirePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExReleasePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID _ExInitializePushLock (PEX_PUSH_LOCK Lock)
 
NTSTATUS FASTCALL IntSafeCopyUnicodeString (PUNICODE_STRING Dest, PUNICODE_STRING Source)
 
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL (PUNICODE_STRING Dest, PUNICODE_STRING Source)
 
HBITMAP NTAPI UserLoadImage (PCWSTR)
 
BOOL NTAPI W32kDosPathNameToNtPathName (PCWSTR, PUNICODE_STRING)
 

Variables

HGDIOBJ StockObjects []
 
USHORT gusLanguageID
 

Macro Definition Documentation

◆ ExInitializePushLock

#define ExInitializePushLock   _ExInitializePushLock

Definition at line 133 of file misc.h.

Typedef Documentation

◆ INTENG_ENTER_LEAVE

◆ PGDI_POOL

Definition at line 67 of file misc.h.

◆ PINTENG_ENTER_LEAVE

Function Documentation

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( PEX_PUSH_LOCK  Lock)

Definition at line 129 of file misc.h.

130{
131 *(PULONG_PTR)Lock = 0;
132}
uint32_t * PULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

◆ ExAcquirePushLockExclusive()

FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 92 of file misc.h.

93{
94 /* Try acquiring the lock */
96 {
97 /* Someone changed it, use the slow path */
99 }
100}
#define EX_PUSH_LOCK_LOCK_V
Definition: Object.c:28
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
VOID FASTCALL ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:471
int32_t * PLONG
Definition: typedefs.h:58

◆ ExReleasePushLockExclusive()

FORCEINLINE VOID ExReleasePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 112 of file misc.h.

113{
114 EX_PUSH_LOCK OldValue;
115
116 /* Unlock the pushlock */
117 OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
119 /* Check if anyone is waiting on it and it's not already waking */
120 if ((OldValue.Waiting) && !(OldValue.Waking))
121 {
122 /* Wake it up */
123 ExfTryToWakePushLock(PushLock);
124 }
125}
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
LONG_PTR SSIZE_T
Definition: basetsd.h:181
#define InterlockedExchangeAddSizeT(a, b)
Definition: interlocked.h:196
VOID FASTCALL ExfTryToWakePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1165
ULONG_PTR Value
Definition: extypes.h:465
ULONG_PTR Waiting
Definition: extypes.h:460
ULONG_PTR Waking
Definition: extypes.h:461
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80

◆ ExTryAcquirePushLockExclusive()

FORCEINLINE BOOLEAN ExTryAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 104 of file misc.h.

105{
106 /* Try acquiring the lock */
108}

Referenced by GDIOBJ_TryLockObject().

◆ GdiPoolAllocate()

PVOID NTAPI GdiPoolAllocate ( PGDI_POOL  pPool)

Definition at line 122 of file gdipool.c.

124{
125 PGDI_POOL_SECTION pSection;
126 ULONG ulIndex, cjOffset, ulPageBit;
128 PVOID pvAlloc, pvBaseAddress;
131
132 /* Disable APCs and acquire the pool lock */
135
136 /* Check if we have a ready section */
137 if (!IsListEmpty(&pPool->leReadyList))
138 {
139 /* Get a free section */
140 ple = pPool->leReadyList.Flink;
141 pSection = CONTAINING_RECORD(ple, GDI_POOL_SECTION, leReadyLink);
142 if (pSection->cAllocCount >= pPool->cSlotsPerSection)
143 {
144 DPRINT1("pSection->cAllocCount=%lu, pPool->cSlotsPerSection=%lu\n",
145 pSection->cAllocCount, pPool->cSlotsPerSection);
146 DBG_DUMP_EVENT_LIST(&pPool->slhLog);
147 ASSERT(FALSE);
148 }
149 ASSERT(pSection->cAllocCount < pPool->cSlotsPerSection);
150 }
151 else
152 {
153 /* No, check if we have something on the empty list */
154 if (!IsListEmpty(&pPool->leEmptyList))
155 {
156 /* Yes, remove it from the empty list */
157 ple = RemoveHeadList(&pPool->leEmptyList);
158 pSection = CONTAINING_RECORD(ple, GDI_POOL_SECTION, leInUseLink);
159 pPool->cEmptySections--;
160 ASSERT(pSection->cAllocCount == 0);
161 }
162 else
163 {
164 /* No, allocate a new section */
165 pSection = GdiPoolAllocateSection(pPool);
166 if (!pSection)
167 {
168 DPRINT1("Couldn't allocate a section\n");
169 pvAlloc = NULL;
170 goto done;
171 }
172 }
173
174 /* Insert it into the in-use and ready list */
175 InsertHeadList(&pPool->leInUseList, &pSection->leInUseLink);
176 InsertHeadList(&pPool->leReadyList, &pSection->leReadyLink);
177 }
178
179 /* Find and set a single bit */
180 ulIndex = RtlFindClearBitsAndSet(&pSection->bitmap, 1, 0);
181 ASSERT(ulIndex != MAXULONG);
182
183 /* Calculate the allocation address */
184 cjOffset = ulIndex * pPool->cjAllocSize;
185 pvAlloc = (PVOID)((ULONG_PTR)pSection->pvBaseAddress + cjOffset);
186
187 /* Check if memory is committed */
188 ulPageBit = 1 << (cjOffset / PAGE_SIZE);
189 ulPageBit |= 1 << ((cjOffset + pPool->cjAllocSize - 1) / PAGE_SIZE);
190 if ((pSection->ulCommitBitmap & ulPageBit) != ulPageBit)
191 {
192 /* Commit the pages */
193 pvBaseAddress = PAGE_ALIGN(pvAlloc);
195 status = ZwAllocateVirtualMemory(NtCurrentProcess(),
196 &pvBaseAddress,
197 0,
198 &cjSize,
201 if (!NT_SUCCESS(status))
202 {
203 pvAlloc = NULL;
204 goto done;
205 }
206
207 pSection->ulCommitBitmap |= ulPageBit;
208 }
209
210 /* Increase alloc count */
211 pSection->cAllocCount++;
212 ASSERT(RtlNumberOfSetBits(&pSection->bitmap) == pSection->cAllocCount);
213 DBG_LOGEVENT(&pPool->slhLog, EVENT_ALLOCATE, pvAlloc);
214
215 /* Check if section is now busy */
216 if (pSection->cAllocCount == pPool->cSlotsPerSection)
217 {
218 /* Remove the section from the ready list */
219 RemoveEntryList(&pSection->leReadyLink);
220 }
221
222done:
223 /* Release the pool lock and enable APCs */
226
227 DPRINT("GdiPoolallocate: %p\n", pvAlloc);
228 return pvAlloc;
229}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1036
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1252
PSINGLE_LIST_ENTRY ple
#define DBG_LOGEVENT(pslh, type, val)
Definition: gdidebug.h:109
#define DBG_DUMP_EVENT_LIST(pslh)
Definition: gdidebug.h:111
static PGDI_POOL_SECTION GdiPoolAllocateSection(PGDI_POOL pPool)
Definition: gdipool.c:50
NTSYSAPI ULONG WINAPI RtlNumberOfSetBits(PCRTL_BITMAP)
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define ASSERT(a)
Definition: mode.c:44
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define MEM_COMMIT
Definition: nt_native.h:1313
#define DPRINT
Definition: sndvol32.h:73
ULONG cAllocCount
Definition: gdipool.c:23
LIST_ENTRY leReadyLink
Definition: gdipool.c:18
RTL_BITMAP bitmap
Definition: gdipool.c:25
ULONG ulCommitBitmap
Definition: gdipool.c:22
LIST_ENTRY leInUseLink
Definition: gdipool.c:17
PVOID pvBaseAddress
Definition: gdipool.c:20
LIST_ENTRY leInUseList
Definition: gdipool.c:41
EX_PUSH_LOCK pushlock
Definition: gdipool.c:36
ULONG cEmptySections
Definition: gdipool.c:35
ULONG cSlotsPerSection
Definition: gdipool.c:34
LIST_ENTRY leEmptyList
Definition: gdipool.c:42
ULONG cjAllocSize
Definition: gdipool.c:32
LIST_ENTRY leReadyList
Definition: gdipool.c:43
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: ps.c:97
#define MAXULONG
Definition: typedefs.h:251
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ ULONG cjSize
Definition: winddi.h:3634
#define PAGE_ALIGN(Va)
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)

Referenced by BRUSH::bAllocateBrushAttr(), DC_bAllocDcAttr(), and REGION_bAllocRgnAttr().

◆ GdiPoolCreate()

PGDI_POOL NTAPI GdiPoolCreate ( ULONG  cjAllocSize,
ULONG  ulTag 
)

Definition at line 316 of file gdipool.c.

319{
320 PGDI_POOL pPool;
321
322 /* Allocate a pool object */
323 pPool = EngAllocMem(0, sizeof(GDI_POOL), 'lopG');
324 if (!pPool) return NULL;
325
326 /* Initialize the object */
331 pPool->cEmptySections = 0;
332 pPool->cjAllocSize = cjAllocSize;
333 pPool->ulTag = ulTag;
335 pPool->cSlotsPerSection = pPool->cjSectionSize / cjAllocSize;
336 DBG_INITLOG(&pPool->slhLog);
337
338 return pPool;
339}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ExInitializePushLock
Definition: ex.h:1013
#define DBG_INITLOG(pslh)
Definition: gdidebug.h:110
#define GDI_POOL_ALLOCATION_GRANULARITY
Definition: gdipool.c:46
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
ULONG ulTag
Definition: gdipool.c:31
ULONG cjSectionSize
Definition: gdipool.c:33
_In_ ULONG _In_ ULONG ulTag
Definition: winddi.h:3942

Referenced by GdiProcessCreate().

◆ GdiPoolDestroy()

VOID NTAPI GdiPoolDestroy ( PGDI_POOL  pPool)

Definition at line 343 of file gdipool.c.

344{
345 PGDI_POOL_SECTION pSection;
347
348 /* Loop all empty sections, removing them */
349 while (!IsListEmpty(&pPool->leEmptyList))
350 {
351 /* Delete the section */
352 ple = RemoveHeadList(&pPool->leEmptyList);
353 pSection = CONTAINING_RECORD(ple, GDI_POOL_SECTION, leInUseLink);
354 GdiPoolDeleteSection(pPool, pSection);
355 }
356
357 /* Loop all ready sections, removing them */
358 while (!IsListEmpty(&pPool->leInUseList))
359 {
360 /* Delete the section */
361 ple = RemoveHeadList(&pPool->leInUseList);
362 pSection = CONTAINING_RECORD(ple, GDI_POOL_SECTION, leInUseLink);
363 GdiPoolDeleteSection(pPool, pSection);
364 }
365
366 DBG_CLEANUP_EVENT_LIST(&pPool->slhLog);
367
368 EngFreeMem(pPool);
369}
#define DBG_CLEANUP_EVENT_LIST(pslh)
Definition: gdidebug.h:112
static VOID GdiPoolDeleteSection(PGDI_POOL pPool, PGDI_POOL_SECTION pSection)
Definition: gdipool.c:95
#define EngFreeMem
Definition: polytest.cpp:56

Referenced by GdiProcessDestroy().

◆ GdiPoolFree()

VOID NTAPI GdiPoolFree ( PGDI_POOL  pPool,
PVOID  pvAlloc 
)

Definition at line 233 of file gdipool.c.

236{
238 PGDI_POOL_SECTION pSection = NULL;
239 ULONG_PTR cjOffset;
240 ULONG ulIndex;
241 DPRINT("GdiPoolFree: %p\n", pvAlloc);
242
243 /* Disable APCs and acquire the pool lock */
246
247 /* Loop all used sections */
248 for (ple = pPool->leInUseList.Flink;
249 ple != &pPool->leInUseList;
250 ple = ple->Flink)
251 {
252 /* Get the pointer to the section */
253 pSection = CONTAINING_RECORD(ple, GDI_POOL_SECTION, leInUseLink);
254
255 /* Calculate offset */
256 cjOffset = (ULONG_PTR)pvAlloc - (ULONG_PTR)pSection->pvBaseAddress;
257
258 /* Check if the allocation is from this section */
259 if (cjOffset < pPool->cjSectionSize)
260 {
261 /* Calculate the index of the allocation */
262 ulIndex = cjOffset / pPool->cjAllocSize;
263
264 /* Mark it as free */
265 ASSERT(RtlTestBit(&pSection->bitmap, ulIndex) == TRUE);
266 RtlClearBit(&pSection->bitmap, ulIndex);
267
268 /* Decrease allocation count */
269 pSection->cAllocCount--;
270 ASSERT(RtlNumberOfSetBits(&pSection->bitmap) == pSection->cAllocCount);
271 DBG_LOGEVENT(&pPool->slhLog, EVENT_FREE, pvAlloc);
272
273 /* Check if the section got valid now */
274 if (pSection->cAllocCount == pPool->cSlotsPerSection - 1)
275 {
276 /* Insert it into the ready list */
277 InsertTailList(&pPool->leReadyList, &pSection->leReadyLink);
278 }
279 /* Check if it got empty now */
280 else if (pSection->cAllocCount == 0)
281 {
282 /* Remove the section from the lists */
283 RemoveEntryList(&pSection->leInUseLink);
284 RemoveEntryList(&pSection->leReadyLink);
285
286 if (pPool->cEmptySections >= 1)
287 {
288 /* Delete the section */
289 GdiPoolDeleteSection(pPool, pSection);
290 }
291 else
292 {
293 /* Insert it into the empty list */
294 InsertHeadList(&pPool->leEmptyList, &pSection->leInUseLink);
295 pPool->cEmptySections++;
296 }
297 }
298
299 goto done;
300 }
301 }
302
303 DbgPrint("failed to free. pvAlloc=%p, base=%p, size=%lx\n",
304 pvAlloc, pSection ? pSection->pvBaseAddress : NULL, pPool->cjSectionSize);
305 ASSERT(FALSE);
306 // KeBugCheck()
307
308done:
309 /* Release the pool lock and enable APCs */
312}
#define TRUE
Definition: types.h:120
#define ULONG_PTR
Definition: config.h:101
#define InsertTailList(ListHead, Entry)
#define DbgPrint
Definition: hal.h:12
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
_Must_inspect_result_ NTSYSAPI BOOLEAN NTAPI RtlTestBit(_In_ PRTL_BITMAP BitMapHeader, _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber)
Definition: bitmap.c:434

Referenced by DC_vFreeDcAttr(), IntGdiSetRegionOwner(), REGION_vCleanup(), BRUSH::vReleaseAttribute(), and BRUSH::~BRUSH().

◆ HackSecureVirtualMemory()

PVOID APIENTRY HackSecureVirtualMemory ( IN  PVOID,
IN  SIZE_T,
IN  ULONG,
OUT PVOID SafeAddress 
)

Definition at line 113 of file mem.c.

118{
120 PMDL pmdl;
122
125 else return NULL;
126
128 if (pmdl == NULL)
129 {
130 return NULL;
131 }
132
134 {
136 }
138 {
140 }
142
143 if (!NT_SUCCESS(Status))
144 {
145 IoFreeMdl(pmdl);
146 return NULL;
147 }
148
150
151 if(!*SafeAddress)
152 {
153 MmUnlockPages(pmdl);
154 IoFreeMdl(pmdl);
155 return NULL;
156 }
157
158 return pmdl;
159}
#define PAGE_READONLY
Definition: compat.h:138
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
FP_OP Operation
Definition: fpcontrol.c:150
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
@ NormalPagePriority
Definition: imports.h:56
#define UserMode
Definition: asm.h:35
static WCHAR Address[46]
Definition: ping.c:68
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
enum _LOCK_OPERATION LOCK_OPERATION
@ IoReadAccess
Definition: ketypes.h:863
@ IoModifyAccess
Definition: ketypes.h:865
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
_Must_inspect_result_ _In_ _In_ ULONG ProbeMode
Definition: mmfuncs.h:561

◆ HackUnsecureVirtualMemory()

VOID APIENTRY HackUnsecureVirtualMemory ( IN  PVOID)

Definition at line 163 of file mem.c.

165{
166 PMDL pmdl = (PMDL)SecureHandle;
167
168 MmUnlockPages(pmdl);
169 IoFreeMdl(pmdl);
170}
PVOID PMDL
Definition: usb.h:39

◆ InitializeGreCSRSS()

BOOL InitializeGreCSRSS ( VOID  )

Definition at line 80 of file init.c.

81{
82 /* Initialize DirectX graphics driver */
84 {
85 ERR("Unable to initialize DirectX graphics\n");
86 return FALSE;
87 }
88
89 /* Get global language ID */
91
92 /* Initialize FreeType library */
93 if (!InitFontSupport())
94 {
95 ERR("Unable to initialize font support\n");
96 return FALSE;
97 }
98
99 return TRUE;
100}
#define ERR(fmt,...)
Definition: debug.h:113
PEPROCESS gpepCSRSS
Definition: csr.c:15
BOOL FASTCALL InitFontSupport(VOID)
Definition: freetype.c:672
USHORT gusLanguageID
Definition: init.c:12
USHORT FASTCALL UserGetLanguageID(VOID)
Definition: misc.c:105
NTSTATUS APIENTRY DxDdStartupDxGraphics(ULONG SizeEngDrv, PDRVENABLEDATA pDxEngDrv, ULONG SizeDxgDrv, PDRVENABLEDATA pDxgDrv, PULONG DirectDrawContext, PEPROCESS Proc)
Definition: main.c:34

Referenced by NtUserInitialize().

◆ IntEngEnter()

BOOL APIENTRY IntEngEnter ( PINTENG_ENTER_LEAVE  EnterLeave,
SURFOBJ DestObj,
RECTL DestRect,
BOOL  ReadOnly,
POINTL Translate,
SURFOBJ **  OutputObj 
)

Definition at line 15 of file engmisc.c.

21{
22 LONG Exchange;
23 SIZEL BitmapSize;
24 POINTL SrcPoint;
25 LONG Width;
26 RECTL ClippedDestRect;
27
28 /* Normalize */
29 if (DestRect->right < DestRect->left)
30 {
31 Exchange = DestRect->left;
32 DestRect->left = DestRect->right;
33 DestRect->right = Exchange;
34 }
35 if (DestRect->bottom < DestRect->top)
36 {
37 Exchange = DestRect->top;
38 DestRect->top = DestRect->bottom;
39 DestRect->bottom = Exchange;
40 }
41
42 if (NULL != psoDest && STYPE_BITMAP != psoDest->iType &&
43 (NULL == psoDest->pvScan0 || 0 == psoDest->lDelta))
44 {
45 /* Driver needs to support DrvCopyBits, else we can't do anything */
46 SURFACE *psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
47 if (!(psurfDest->flags & HOOK_COPYBITS))
48 {
49 return FALSE;
50 }
51
52 /* Allocate a temporary bitmap */
53 BitmapSize.cx = DestRect->right - DestRect->left;
54 BitmapSize.cy = DestRect->bottom - DestRect->top;
55 Width = WIDTH_BYTES_ALIGN32(BitmapSize.cx, BitsPerFormat(psoDest->iBitmapFormat));
56 EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
57 psoDest->iBitmapFormat,
59
60 if (!EnterLeave->OutputBitmap)
61 {
62 DPRINT1("EngCreateBitmap() failed\n");
63 return FALSE;
64 }
65
66 *ppsoOutput = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
67 if (*ppsoOutput == NULL)
68 {
70 return FALSE;
71 }
72
73 EnterLeave->DestRect.left = 0;
74 EnterLeave->DestRect.top = 0;
75 EnterLeave->DestRect.right = BitmapSize.cx;
76 EnterLeave->DestRect.bottom = BitmapSize.cy;
77 SrcPoint.x = DestRect->left;
78 SrcPoint.y = DestRect->top;
79 ClippedDestRect = EnterLeave->DestRect;
80 if (SrcPoint.x < 0)
81 {
82 ClippedDestRect.left -= SrcPoint.x;
83 SrcPoint.x = 0;
84 }
85 if (psoDest->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
86 {
87 ClippedDestRect.right = ClippedDestRect.left + psoDest->sizlBitmap.cx - SrcPoint.x;
88 }
89 if (SrcPoint.y < 0)
90 {
91 ClippedDestRect.top -= SrcPoint.y;
92 SrcPoint.y = 0;
93 }
94 if (psoDest->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top)
95 {
96 ClippedDestRect.bottom = ClippedDestRect.top + psoDest->sizlBitmap.cy - SrcPoint.y;
97 }
98 EnterLeave->TrivialClipObj = EngCreateClip();
99 if (EnterLeave->TrivialClipObj == NULL)
100 {
101 EngUnlockSurface(*ppsoOutput);
102 EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
103 return FALSE;
104 }
106 if (ClippedDestRect.left < (*ppsoOutput)->sizlBitmap.cx &&
107 0 <= ClippedDestRect.right &&
108 SrcPoint.x < psoDest->sizlBitmap.cx &&
109 ClippedDestRect.top <= (*ppsoOutput)->sizlBitmap.cy &&
110 0 <= ClippedDestRect.bottom &&
111 SrcPoint.y < psoDest->sizlBitmap.cy &&
112 ! GDIDEVFUNCS(psoDest).CopyBits(
113 *ppsoOutput, psoDest,
114 EnterLeave->TrivialClipObj, NULL,
115 &ClippedDestRect, &SrcPoint))
116 {
117 EngDeleteClip(EnterLeave->TrivialClipObj);
118 EngUnlockSurface(*ppsoOutput);
119 EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
120 return FALSE;
121 }
122 EnterLeave->DestRect.left = DestRect->left;
123 EnterLeave->DestRect.top = DestRect->top;
124 EnterLeave->DestRect.right = DestRect->right;
125 EnterLeave->DestRect.bottom = DestRect->bottom;
126 Translate->x = - DestRect->left;
127 Translate->y = - DestRect->top;
128 }
129 else
130 {
131 Translate->x = 0;
132 Translate->y = 0;
133 *ppsoOutput = psoDest;
134 }
135
136 if (NULL != *ppsoOutput)
137 {
138 SURFACE* psurfOutput = CONTAINING_RECORD(*ppsoOutput, SURFACE, SurfObj);
139 if (0 != (psurfOutput->flags & HOOK_SYNCHRONIZE))
140 {
141 if (NULL != GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface)
142 {
143 GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface(*ppsoOutput, DestRect, 0);
144 }
145 else if (STYPE_BITMAP == (*ppsoOutput)->iType
146 && NULL != GDIDEVFUNCS(*ppsoOutput).Synchronize)
147 {
148 GDIDEVFUNCS(*ppsoOutput).Synchronize((*ppsoOutput)->dhpdev, DestRect);
149 }
150 }
151 }
152 else return FALSE;
153
154 EnterLeave->DestObj = psoDest;
155 EnterLeave->OutputObj = *ppsoOutput;
156 EnterLeave->ReadOnly = ReadOnly;
157
158 return TRUE;
159}
long LONG
Definition: pedump.c:60
@ ReadOnly
Definition: arc.h:80
HBITMAP OutputBitmap
Definition: misc.h:8
SURFOBJ * OutputObj
Definition: misc.h:7
SURFOBJ * DestObj
Definition: misc.h:6
CLIPOBJ * TrivialClipObj
Definition: misc.h:9
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
BYTE iDComplexity
Definition: winddi.h:278
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
FLONG flags
Definition: surface.h:10
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
#define GDIDEVFUNCS(SurfObj)
Definition: surface.h:106
#define BitsPerFormat(Format)
Definition: surface.h:109
#define DC_TRIVIAL
Definition: winddi.h:259
ENGAPI CLIPOBJ *APIENTRY EngCreateClip(VOID)
Definition: clip.c:222
#define STYPE_BITMAP
Definition: winddi.h:1175
ENGAPI VOID APIENTRY EngDeleteClip(_In_ _Post_ptr_invalid_ CLIPOBJ *pco)
Definition: clip.c:241
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:567
ENGAPI SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:607
ENGAPI HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ FLONG fl, _In_opt_ PVOID pvBits)
#define BMF_TOPDOWN
Definition: winddi.h:1180
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
#define BMF_NOZEROINIT
Definition: winddi.h:1181
#define HOOK_SYNCHRONIZE
Definition: winddi.h:1431
#define HOOK_COPYBITS
Definition: winddi.h:1429
ENGAPI VOID APIENTRY EngUnlockSurface(_In_ _Post_ptr_invalid_ SURFOBJ *pso)
Definition: surface.c:628

Referenced by EngAlphaBlend(), EngLineTo(), EngMaskBitBlt(), EngStretchBltROP(), EngTransparentBlt(), IntEngGradientFillRect(), and IntEngGradientFillTriangle().

◆ IntEngLeave()

BOOL APIENTRY IntEngLeave ( PINTENG_ENTER_LEAVE  EnterLeave)

Definition at line 162 of file engmisc.c.

163{
164 POINTL SrcPoint;
165 BOOL Result = TRUE;
166
167 if (EnterLeave->OutputObj != EnterLeave->DestObj && NULL != EnterLeave->OutputObj)
168 {
169 if (! EnterLeave->ReadOnly)
170 {
171 SrcPoint.x = 0;
172 SrcPoint.y = 0;
173 if (EnterLeave->DestRect.left < 0)
174 {
175 SrcPoint.x = - EnterLeave->DestRect.left;
176 EnterLeave->DestRect.left = 0;
177 }
178 if (EnterLeave->DestObj->sizlBitmap.cx < EnterLeave->DestRect.right)
179 {
180 EnterLeave->DestRect.right = EnterLeave->DestObj->sizlBitmap.cx;
181 }
182 if (EnterLeave->DestRect.top < 0)
183 {
184 SrcPoint.y = - EnterLeave->DestRect.top;
185 EnterLeave->DestRect.top = 0;
186 }
187 if (EnterLeave->DestObj->sizlBitmap.cy < EnterLeave->DestRect.bottom)
188 {
189 EnterLeave->DestRect.bottom = EnterLeave->DestObj->sizlBitmap.cy;
190 }
191 if (SrcPoint.x < EnterLeave->OutputObj->sizlBitmap.cx &&
192 EnterLeave->DestRect.left <= EnterLeave->DestRect.right &&
193 EnterLeave->DestRect.left < EnterLeave->DestObj->sizlBitmap.cx &&
194 SrcPoint.y < EnterLeave->OutputObj->sizlBitmap.cy &&
195 EnterLeave->DestRect.top <= EnterLeave->DestRect.bottom &&
196 EnterLeave->DestRect.top < EnterLeave->DestObj->sizlBitmap.cy)
197 {
198 Result = GDIDEVFUNCS(EnterLeave->DestObj).CopyBits(
199 EnterLeave->DestObj,
200 EnterLeave->OutputObj,
201 EnterLeave->TrivialClipObj, NULL,
202 &EnterLeave->DestRect, &SrcPoint);
203 }
204 else
205 {
206 Result = TRUE;
207 }
208 }
209 EngUnlockSurface(EnterLeave->OutputObj);
210 EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
211 EngDeleteClip(EnterLeave->TrivialClipObj);
212 }
213 else
214 {
215 Result = TRUE;
216 }
217
218 return Result;
219}
unsigned int BOOL
Definition: ntddk_ex.h:94
SIZEL sizlBitmap
Definition: winddi.h:1209
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by EngAlphaBlend(), EngLineTo(), EngMaskBitBlt(), EngStretchBltROP(), EngTransparentBlt(), IntEngGradientFillRect(), and IntEngGradientFillTriangle().

◆ IntSafeCopyUnicodeString()

NTSTATUS FASTCALL IntSafeCopyUnicodeString ( PUNICODE_STRING  Dest,
PUNICODE_STRING  Source 
)

Definition at line 637 of file misc.c.

639{
641 PWSTR Src;
642
644 if(!NT_SUCCESS(Status))
645 {
646 return Status;
647 }
648
649 if(Dest->Length > 0x4000)
650 {
651 return STATUS_UNSUCCESSFUL;
652 }
653
654 Src = Dest->Buffer;
655 Dest->Buffer = NULL;
656 Dest->MaximumLength = Dest->Length;
657
658 if(Dest->Length > 0 && Src)
659 {
661 if(!Dest->Buffer)
662 {
663 return STATUS_NO_MEMORY;
664 }
665
666 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
667 if(!NT_SUCCESS(Status))
668 {
670 Dest->Buffer = NULL;
671 return Status;
672 }
673
674
675 return STATUS_SUCCESS;
676 }
677
678 /* String is empty */
679 return STATUS_SUCCESS;
680}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define TAG_STRING
Definition: oslist.h:22
#define MmCopyFromCaller
Definition: polytest.cpp:29
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ IntSafeCopyUnicodeStringTerminateNULL()

NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL ( PUNICODE_STRING  Dest,
PUNICODE_STRING  Source 
)

Definition at line 683 of file misc.c.

685{
687 PWSTR Src;
688
690 if(!NT_SUCCESS(Status))
691 {
692 return Status;
693 }
694
695 if(Dest->Length > 0x4000)
696 {
697 return STATUS_UNSUCCESSFUL;
698 }
699
700 Src = Dest->Buffer;
701 Dest->Buffer = NULL;
702 Dest->MaximumLength = 0;
703
704 if(Dest->Length > 0 && Src)
705 {
706 Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
708 if(!Dest->Buffer)
709 {
710 return STATUS_NO_MEMORY;
711 }
712
713 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
714 if(!NT_SUCCESS(Status))
715 {
717 Dest->Buffer = NULL;
718 return Status;
719 }
720
721 /* Make sure the string is null-terminated */
722 Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
723 *Src = L'\0';
724
725 return STATUS_SUCCESS;
726 }
727
728 /* String is empty */
729 return STATUS_SUCCESS;
730}
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitThreadCallback(), and NtUserRegisterWindowMessage().

◆ RegGetSectionDWORD()

DWORD NTAPI RegGetSectionDWORD ( LPCWSTR  pszSection,
PCWSTR  pszValue,
DWORD  dwDefault 
)

Definition at line 172 of file registry.c.

173{
174 HKEY hKey;
175 DWORD dwValue;
176
177 if (NT_ERROR(RegOpenSectionKey(pszSection, &hKey)))
178 return dwDefault;
179
180 if (!RegReadDWORD(hKey, pszValue, &dwValue))
181 dwValue = dwDefault;
182
183 ZwClose(hKey);
184 return dwValue;
185}
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define NT_ERROR(Status)
Definition: umtypes.h:106
NTSTATUS NTAPI RegOpenSectionKey(LPCWSTR pszSection, PHKEY phkey)
Definition: registry.c:159
BOOL NTAPI RegReadDWORD(HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:149

Referenced by UserIsCiceroEnabled(), and UserIsIMMEnabled().

◆ RegOpenKey()

NTSTATUS NTAPI RegOpenKey ( LPCWSTR  pwszKeyName,
PHKEY  phkey 
)

Definition at line 16 of file registry.c.

19{
22 UNICODE_STRING ustrKeyName;
23 HKEY hkey;
24
25 /* Initialize the key name */
26 RtlInitUnicodeString(&ustrKeyName, pwszKeyName);
27
28 /* Initialize object attributes */
30 &ustrKeyName,
32 NULL,
33 NULL);
34
35 /* Open the key */
36 Status = ZwOpenKey((PHANDLE)&hkey, KEY_READ, &ObjectAttributes);
37 if (NT_SUCCESS(Status))
38 {
39 *phkey = hkey;
40 }
41
42 return Status;
43}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455

◆ RegQueryValue()

NTSTATUS NTAPI RegQueryValue ( IN HKEY  hkey,
IN PCWSTR  pwszValueName,
IN ULONG  ulType,
OUT PVOID  pvData,
IN OUT PULONG  pcbValue 
)

Definition at line 47 of file registry.c.

53{
55 UNICODE_STRING ustrValueName;
56 BYTE ajBuffer[100];
58 ULONG cbInfoSize, cbDataSize;
59
60 /* Check if the local buffer is sufficient */
61 cbInfoSize = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[*pcbValue]);
62 if (cbInfoSize <= sizeof(ajBuffer))
63 {
64 pInfo = (PVOID)ajBuffer;
65 }
66 else
67 {
68 /* It's not, allocate a sufficient buffer */
69 pInfo = ExAllocatePoolWithTag(PagedPool, cbInfoSize, TAG_TEMP);
70 if (!pInfo)
71 {
73 }
74 }
75
76 /* Query the value */
77 RtlInitUnicodeString(&ustrValueName, pwszValueName);
78 Status = ZwQueryValueKey(hkey,
79 &ustrValueName,
81 (PVOID)pInfo,
82 cbInfoSize,
83 &cbInfoSize);
84
85 /* Note: STATUS_BUFFER_OVERFLOW is not a success */
86 if (NT_SUCCESS(Status))
87 {
88 cbDataSize = pInfo->DataLength;
89
90 /* Did we get the right type */
91 if (pInfo->Type != ulType)
92 {
94 }
95 else if (cbDataSize > *pcbValue)
96 {
98 }
99 else
100 {
101 /* Copy the contents to the caller */
102 RtlCopyMemory(pvData, pInfo->Data, cbDataSize);
103 }
104 }
106 {
107 _PRAGMA_WARNING_SUPPRESS(6102); /* cbInfoSize is initialized here! */
108 cbDataSize = cbInfoSize - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
109 }
110 else
111 {
112 cbDataSize = 0;
113 }
114
115 /* Return the data size to the caller */
116 *pcbValue = cbDataSize;
117
118 /* Cleanup */
119 if (pInfo != (PVOID)ajBuffer)
121
122 return Status;
123}
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_z_ PCWSTR pwszValueName
Definition: ntuser.h:42
_In_z_ PCWSTR _In_ ULONG ulType
Definition: ntuser.h:43
#define TAG_TEMP
Definition: tags.h:43
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
unsigned char BYTE
Definition: xxhash.c:193

◆ RegReadDWORD()

BOOL NTAPI RegReadDWORD ( HKEY  hkey,
PCWSTR  pwszValue,
PDWORD  pdwData 
)

Definition at line 149 of file registry.c.

150{
152 ULONG cbSize = sizeof(DWORD);
153 Status = RegQueryValue(hkey, pwszValue, REG_DWORD, pdwData, &cbSize);
154 return NT_SUCCESS(Status);
155}
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596
#define RegQueryValue
Definition: winreg.h:523

Referenced by EngpUpdateGraphicsDeviceList(), InitMetrics(), InitUserImpl(), and RegGetSectionDWORD().

◆ RegWriteDWORD()

VOID NTAPI RegWriteDWORD ( HKEY  hkey,
PCWSTR  pwszValue,
DWORD  dwData 
)

Definition at line 139 of file registry.c.

140{
141 UNICODE_STRING ustrValue;
142
143 RtlInitUnicodeString(&ustrValue, pwszValue);
144 ZwSetValueKey(hkey, &ustrValue, 0, REG_DWORD, &dwData, sizeof(DWORD));
145}
static HANDLE ULONG_PTR dwData
Definition: file.c:35

Referenced by RegWriteDisplaySettings().

◆ RegWriteSZ()

VOID NTAPI RegWriteSZ ( HKEY  hkey,
PCWSTR  pwszValue,
PWSTR  pwszData 
)

Definition at line 127 of file registry.c.

128{
129 UNICODE_STRING ustrValue;
130 UNICODE_STRING ustrData;
131
132 RtlInitUnicodeString(&ustrValue, pwszValue);
133 RtlInitUnicodeString(&ustrData, pwszData);
134 ZwSetValueKey(hkey, &ustrValue, 0, REG_SZ, &ustrData, ustrData.Length + sizeof(WCHAR));
135}
#define REG_SZ
Definition: layer.c:22

◆ SetLastNtError()

VOID FASTCALL SetLastNtError ( _In_ NTSTATUS  Status)

Definition at line 31 of file error.c.

32{
34}
ULONG NTAPI RtlNtStatusToDosError(IN NTSTATUS Status)
Definition: error.c:96
VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

Referenced by _Success_(), co_IntSendMessageTimeoutSingle(), co_IntWaitMessage(), ftGdiGetTextMetricsW(), IntAddAtom(), IntCreateClass(), IntCreateDesktop(), IntCreateWindow(), IntCreateWindowStation(), IntGetAtomName(), IntGetMenuItemInfo(), IntGetWinStaForCbAccess(), IntRegisterClassAtom(), IntResolveDesktop(), IntSetClassMenuName(), IntSetMenuItemInfo(), IntSetThreadDesktop(), IntValidateDesktopHandle(), IntValidateWindowStationHandle(), NtGdiCreateColorSpace(), NtGdiCreateDIBitmapInternal(), NtGdiCreateDIBSection(), NtGdiEngCreatePalette(), NtGdiExtCreatePen(), NtGdiExtCreateRegion(), NtGdiExtEscape(), NtGdiGetCharABCWidthsW(), NtGdiGetDCDword(), NtGdiGetDeviceGammaRamp(), NtGdiGetFontResourceInfoInternalW(), NtGdiGetPath(), NtGdiGetRasterizerCaps(), NtGdiGetRealizationInfo(), NtGdiGetTextCharsetInfo(), NtGdiGetTextExtentExW(), NtGdiGetTextFaceW(), NtGdiGetTextMetricsW(), NtGdiGradientFill(), NtGdiOffsetViewportOrgEx(), NtGdiOffsetWindowOrgEx(), NtGdiOpenDCW(), NtGdiPolyDraw(), NtGdiPolyPatBlt(), NtGdiRectVisible(), NtGdiScaleViewportExtEx(), NtGdiScaleWindowExtEx(), NtGdiSetDeviceGammaRamp(), NtGdiSetMiterLimit(), NtGdiSetViewportOrgEx(), NtGdiSetWindowOrgEx(), NtUserBeginPaint(), NtUserBuildHwndList(), NtUserCallOneParam(), NtUserChangeDisplaySettings(), NtUserCloseDesktop(), NtUserCloseWindowStation(), NtUserCopyAcceleratorTable(), NtUserCreateAcceleratorTable(), NtUserCreateWindowEx(), NtUserCreateWindowStation(), NtUserDefSetText(), NtUserDispatchMessage(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), NtUserEnumDisplayMonitors(), NtUserFindWindowEx(), NtUserFlashWindowEx(), NtUserGetCaretPos(), NtUserGetClassInfo(), NtUserGetClassName(), NtUserGetClipboardData(), NtUserGetClipboardFormatName(), NtUserGetClipCursor(), NtUserGetComboBoxInfo(), NtUserGetCursorFrameInfo(), NtUserGetCursorInfo(), NtUserGetGuiResources(), NtUserGetGUIThreadInfo(), NtUserGetIconSize(), NtUserGetInternalWindowPos(), NtUserGetKeyboardLayoutList(), NtUserGetKeyboardLayoutName(), NtUserGetKeyboardState(), NtUserGetKeyNameText(), NtUserGetLayeredWindowAttributes(), NtUserGetListBoxInfo(), NtUserGetMenuBarInfo(), NtUserGetMenuItemRect(), NtUserGetMessage(), NtUserGetMonitorInfo(), NtUserGetMouseMovePointsEx(), NtUserGetObjectInformation(), NtUserGetPriorityClipboardFormat(), NtUserGetScrollBarInfo(), NtUserGetWindowPlacement(), NtUserGetWOWClass(), NtUserInitializeClientPfnArrays(), NtUserInternalGetWindowText(), NtUserLoadKeyboardLayoutEx(), NtUserLockWindowStation(), NtUserMonitorFromRect(), NtUserOpenDesktop(), NtUserOpenWindowStation(), NtUserPeekMessage(), NtUserPostThreadMessage(), NtUserProcessConnect(), NtUserRegisterClassExWOW(), NtUserRegisterWindowMessage(), NtUserSBGetParms(), NtUserScrollDC(), NtUserScrollWindowEx(), NtUserSendInput(), NtUserSetClassLong(), NtUserSetClipboardData(), NtUserSetCursorIconData(), NtUserSetInternalWindowPos(), NtUserSetKeyboardState(), NtUserSetObjectInformation(), NtUserSetScrollBarInfo(), NtUserSetScrollInfo(), NtUserSetShellWindowEx(), NtUserSetSysColors(), NtUserSetWindowPlacement(), NtUserSetWindowsHookEx(), NtUserThunkedMenuItemInfo(), NtUserToUnicodeEx(), NtUserTrackMouseEvent(), NtUserTranslateAccelerator(), NtUserTranslateMessage(), NtUserUnlockWindowStation(), NtUserUnregisterClass(), NtUserWaitForInputIdle(), SpiMemCopy(), UserCreateHeap(), UserCreateMenu(), UserFreeHandle(), UserGetClassName(), UserGetShellWindow(), UserInsertMenuItem(), UserMenuInfo(), UserMenuItemInfo(), UserObjectInDestroy(), UserOpenInputDesktop(), UserSetProcessWindowStation(), W32kCreateFileSection(), W32kMapViewOfSection(), and W32kOpenFile().

◆ UserGetLanguageID()

USHORT FASTCALL UserGetLanguageID ( VOID  )

Definition at line 105 of file misc.c.

106{
108 OBJECT_ATTRIBUTES ObAttr;
109// http://support.microsoft.com/kb/324097
113 UNICODE_STRING Language;
114
115 RtlInitUnicodeString( &Language,
116 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
117
119 &Language,
121 NULL,
122 NULL);
123
124 if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
125 {
127 if ( pKeyInfo )
128 {
129 RtlInitUnicodeString(&Language, L"Default");
130
131 if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
132 &Language,
134 pKeyInfo,
135 Size,
136 &Size)) )
137 {
138 RtlInitUnicodeString(&Language, (PWSTR)pKeyInfo->Data);
139 if (!NT_SUCCESS(RtlUnicodeStringToInteger(&Language, 16, &Ret)))
140 {
142 }
143 }
144 ExFreePoolWithTag(pKeyInfo, TAG_STRING);
145 }
147 }
148 TRACE("Language ID = %x\n",Ret);
149 return (USHORT) Ret;
150}
#define MAX_PATH
Definition: compat.h:34
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned short USHORT
Definition: pedump.c:61
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by InitializeGreCSRSS().

◆ UserLoadImage()

HBITMAP NTAPI UserLoadImage ( PCWSTR  pwszName)

Definition at line 159 of file file.c.

160{
163 BITMAPFILEHEADER *pbmfh;
165 PVOID pvBits;
166 HBITMAP hbmp = 0;
167
168 DPRINT("Enter UserLoadImage(%ls)\n", pwszName);
169
170 /* Open the file */
171 hFile = W32kOpenFile(pwszName, FILE_READ_DATA);
172 if (!hFile)
173 {
174 return NULL;
175 }
176
177 /* Create a section */
179 ZwClose(hFile);
180 if (!hSection)
181 {
182 return NULL;
183 }
184
185 /* Map the section */
188 if (!pbmfh)
189 {
190 return NULL;
191 }
192
193 /* Get a pointer to the BITMAPINFO */
194 pbmi = (LPBITMAPINFO)(pbmfh + 1);
195
197 {
198 ProbeForRead(&pbmfh->bfSize, sizeof(DWORD), 1);
199 ProbeForRead(pbmfh, pbmfh->bfSize, 1);
200 }
202 {
204 }
206
207 if(!NT_SUCCESS(Status))
208 {
209 DPRINT1("Bad File?\n");
210 goto leave;
211 }
212
213 if (pbmfh->bfType == 0x4D42 /* 'BM' */)
214 {
215 /* Could be BITMAPCOREINFO */
216 BITMAPINFO* pConvertedInfo;
217 HDC hdc;
218
219 pvBits = (PVOID)((PCHAR)pbmfh + pbmfh->bfOffBits);
220
221 pConvertedInfo = DIB_ConvertBitmapInfo(pbmi, DIB_RGB_COLORS);
222 if(!pConvertedInfo)
223 {
224 DPRINT1("Unable to convert the bitmap Info\n");
225 goto leave;
226 }
227
229
231 pConvertedInfo->bmiHeader.biWidth,
232 pConvertedInfo->bmiHeader.biHeight,
233 CBM_INIT,
234 pvBits,
235 pConvertedInfo,
237 0,
238 pbmfh->bfSize - pbmfh->bfOffBits,
239 0);
240
242 DIB_FreeConvertedBitmapInfo(pConvertedInfo, pbmi, -1);
243 }
244 else
245 {
246 DPRINT1("Unknown file type!\n");
247 }
248
249leave:
250 /* Unmap our section, we don't need it anymore */
251 ZwUnmapViewOfSection(NtCurrentProcess(), pbmfh);
252
253 DPRINT("Leaving UserLoadImage, hbmp = %p\n", hbmp);
254 return hbmp;
255}
HBITMAP NTAPI GreCreateDIBitmapInternal(IN HDC hDc, IN INT cx, IN INT cy, IN DWORD fInit, IN OPTIONAL LPBYTE pjInit, IN OPTIONAL PBITMAPINFO pbmi, IN DWORD iUsage, IN FLONG fl, IN UINT cjMaxBits, IN HANDLE hcmXform)
Definition: dibobj.c:1718
#define leave
Definition: btrfs_drv.h:138
HBITMAP hbmp
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1040
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
_In_ HANDLE hFile
Definition: mswsock.h:90
#define SEC_COMMIT
Definition: mmtypes.h:100
#define FILE_READ_DATA
Definition: nt_native.h:628
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
char * PCHAR
Definition: typedefs.h:51
BITMAPINFO *FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO *bmi, DWORD Usage)
Definition: dibobj.c:2238
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO *converted, BITMAPINFO *orig, DWORD Usage)
Definition: dibobj.c:2302
HANDLE NTAPI W32kOpenFile(PCWSTR pwszFileName, DWORD dwDesiredAccess)
Definition: file.c:43
PVOID NTAPI W32kMapViewOfSection(HANDLE hSection, DWORD dwPageProtect, ULONG_PTR ulSectionOffset)
Definition: file.c:125
HANDLE NTAPI W32kCreateFileSection(HANDLE hFile, ULONG flAllocation, DWORD flPageProtection, ULONGLONG ullMaxSize)
Definition: file.c:84
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3239
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagBITMAPINFO * LPBITMAPINFO
#define CBM_INIT
Definition: wingdi.h:365

Referenced by SpiSetWallpaper().

◆ W32kDosPathNameToNtPathName()

BOOL NTAPI W32kDosPathNameToNtPathName ( PCWSTR  ,
PUNICODE_STRING   
)

Referenced by SpiSetWallpaper().

Variable Documentation

◆ gusLanguageID

◆ StockObjects