From f5ca079e13062a56e1b29a9119e585616880c9f5 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Tue, 28 Oct 2014 17:07:47 +0000 Subject: [PATCH 1/9] [WINLOGON] - Stop the log from being spammed when the session is idle and no screensaver is set - Also checking if my login still works :) svn path=/trunk/; revision=65076 --- reactos/base/system/winlogon/screensaver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/base/system/winlogon/screensaver.c b/reactos/base/system/winlogon/screensaver.c index 6b65886b985..a46e577ccb0 100644 --- a/reactos/base/system/winlogon/screensaver.c +++ b/reactos/base/system/winlogon/screensaver.c @@ -277,7 +277,7 @@ StartScreenSaver( &hCurrentUser); if (rc != ERROR_SUCCESS) { - ERR("WL: RegOpenCurrentUser Error!\n"); + ERR("WL: RegOpenCurrentUser error %lu\n", rc); goto cleanup; } @@ -288,7 +288,7 @@ StartScreenSaver( &hKey); if (rc != ERROR_SUCCESS) { - ERR("WL: RegOpenKeyEx Error!\n"); + ERR("WL: RegOpenKeyEx error %lu\n", rc); goto cleanup; } @@ -300,7 +300,8 @@ StartScreenSaver( &bufferSize); if (rc != ERROR_SUCCESS || dwType != REG_SZ) { - ERR("WL: RegQueryValueEx Error!\n"); + if (rc != ERROR_FILE_NOT_FOUND) + ERR("WL: RegQueryValueEx error %lu\n", rc); goto cleanup; } From 2c3bb20acb8eaf6d7daeb64965ac63e1d953d77c Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Tue, 28 Oct 2014 17:32:01 +0000 Subject: [PATCH 2/9] Merge r65001 from shell-experiments branch: [user32] - Properly notify the theme engine that the caption needs to be repainted on WM_SETICON - Fixes a classic frame appearing when themes are enabled and we navigate to a different folder svn path=/trunk/; revision=65077 --- reactos/win32ss/user/user32/windows/defwnd.c | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/reactos/win32ss/user/user32/windows/defwnd.c b/reactos/win32ss/user/user32/windows/defwnd.c index ee3cd806c62..d57326c2d73 100644 --- a/reactos/win32ss/user/user32/windows/defwnd.c +++ b/reactos/win32ss/user/user32/windows/defwnd.c @@ -447,6 +447,27 @@ UserSendUiUpdateMsg(HWND hwnd, LPARAM lParam) return TRUE; } +static void +UserPaintCaption(HWND hwnd) +{ + /* FIXME: this is not 100% correct */ + + /* + * When themes are not enabled we can go on and paint the non client area. + * However if we do that with themes enabled we will draw a classic frame. + * This is sovled by sending a themes specific message to notify the themes + * engine that the caption needs to be redrawn + */ + if(gpsi->dwSRVIFlags & SRVINFO_APIHOOK) + { + SendMessage(hwnd, WM_NCUAHDRAWCAPTION,0,0); + } + else + { + DefWndNCPaint(hwnd, HRGN_WINDOW, -1); + } +} + // WM_SETICON LRESULT FASTCALL DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) @@ -481,7 +502,7 @@ DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) NtUserSetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp, hIconSmall); if ((pWnd->style & WS_CAPTION ) == WS_CAPTION) - DefWndNCPaint(UserHMGetHandle(pWnd), HRGN_WINDOW, -1); /* Repaint caption */ + UserPaintCaption(UserHMGetHandle(pWnd)); /* Repaint caption */ return (LRESULT)hIconOld; } @@ -1454,17 +1475,7 @@ RealDefWindowProcA(HWND hWnd, DefSetText(hWnd, (PCWSTR)lParam, TRUE); if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) - { - /* FIXME: this is not 100% correct */ - if(gpsi->dwSRVIFlags & SRVINFO_APIHOOK) - { - SendMessage(hWnd, WM_NCUAHDRAWCAPTION,0,0); - } - else - { - DefWndNCPaint(hWnd, HRGN_WINDOW, -1); - } - } + UserPaintCaption(hWnd); Result = 1; break; } @@ -1626,17 +1637,7 @@ RealDefWindowProcW(HWND hWnd, DefSetText(hWnd, (PCWSTR)lParam, FALSE); if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) - { - /* FIXME: this is not 100% correct */ - if(gpsi->dwSRVIFlags & SRVINFO_APIHOOK) - { - SendMessage(hWnd, WM_NCUAHDRAWCAPTION,0,0); - } - else - { - DefWndNCPaint(hWnd, HRGN_WINDOW, -1); - } - } + UserPaintCaption(hWnd); Result = 1; break; } From 135e926315799bdfde2ada7a42cb2ffbc6b7c309 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Oct 2014 19:17:59 +0000 Subject: [PATCH 3/9] [NTFS] Finally, implement NtfsGetFreeClusters() which will just read the $Data stream from $BITMAP file record to get the amount of free clusters to allow estimating the free space on a volume. The implementation is likely under-optimized... But wwell, the rest of the FSD is not better. Who talked about caching?! ;-) Because pictures are more relevant than words in such case: http://www.heisspiter.net/~Pierre/rostests/NTFS_disksize.png svn path=/trunk/; revision=65082 --- reactos/drivers/filesystems/ntfs/volinfo.c | 63 +++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/filesystems/ntfs/volinfo.c b/reactos/drivers/filesystems/ntfs/volinfo.c index 9b7d23e233f..7893c67759c 100644 --- a/reactos/drivers/filesystems/ntfs/volinfo.c +++ b/reactos/drivers/filesystems/ntfs/volinfo.c @@ -36,8 +36,67 @@ static ULONGLONG NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt) { - UNIMPLEMENTED; - return 0; + NTSTATUS Status; + PFILE_RECORD_HEADER BitmapRecord; + PNTFS_ATTR_CONTEXT DataContext; + ULONGLONG BitmapDataSize; + PCHAR BitmapData; + ULONGLONG FreeClusters = 0; + ULONG Read = 0; + RTL_BITMAP Bitmap; + + DPRINT1("NtfsGetFreeClusters(%p)\n", DeviceExt); + + BitmapRecord = ExAllocatePoolWithTag(NonPagedPool, + DeviceExt->NtfsInfo.BytesPerFileRecord, + TAG_NTFS); + if (BitmapRecord == NULL) + { + return 0; + } + + Status = ReadFileRecord(DeviceExt, NTFS_FILE_BITMAP, BitmapRecord); + if (!NT_SUCCESS(Status)) + { + ExFreePoolWithTag(BitmapRecord, TAG_NTFS); + return 0; + } + + Status = FindAttribute(DeviceExt, BitmapRecord, AttributeData, L"", 0, &DataContext); + if (!NT_SUCCESS(Status)) + { + ExFreePoolWithTag(BitmapRecord, TAG_NTFS); + return 0; + } + + BitmapDataSize = AttributeDataLength(&DataContext->Record); + ASSERT((BitmapDataSize * 8) >= (DeviceExt->NtfsInfo.SectorCount / DeviceExt->NtfsInfo.SectorsPerCluster)); + BitmapData = ExAllocatePoolWithTag(NonPagedPool, BitmapDataSize, TAG_NTFS); + if (BitmapData == NULL) + { + ReleaseAttributeContext(DataContext); + ExFreePoolWithTag(BitmapRecord, TAG_NTFS); + return 0; + } + + /* FIXME: Totally underoptimized! */ + for (; Read < BitmapDataSize; Read += DeviceExt->NtfsInfo.BytesPerSector) + { + ReadAttribute(DeviceExt, DataContext, Read, (PCHAR)((ULONG_PTR)BitmapData + Read), DeviceExt->NtfsInfo.BytesPerSector); + } + ReleaseAttributeContext(DataContext); + + DPRINT1("Total clusters: %I64x\n", DeviceExt->NtfsInfo.SectorCount / DeviceExt->NtfsInfo.SectorsPerCluster); + DPRINT1("Total clusters in bitmap: %I64x\n", BitmapDataSize * 8); + DPRINT1("Diff in size: %I64d B\n", ((BitmapDataSize * 8) - (DeviceExt->NtfsInfo.SectorCount / DeviceExt->NtfsInfo.SectorsPerCluster)) * DeviceExt->NtfsInfo.SectorsPerCluster * DeviceExt->NtfsInfo.BytesPerSector); + + RtlInitializeBitMap(&Bitmap, (PULONG)BitmapData, DeviceExt->NtfsInfo.SectorCount / DeviceExt->NtfsInfo.SectorsPerCluster); + FreeClusters = RtlNumberOfClearBits(&Bitmap); + + ExFreePoolWithTag(BitmapData, TAG_NTFS); + ExFreePoolWithTag(BitmapRecord, TAG_NTFS); + + return FreeClusters; } static From aaebdbf9d3b25f1b2aaf11ced7e54356caff71fb Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Oct 2014 20:39:42 +0000 Subject: [PATCH 4/9] [FASTFAT] For now, disable the VfatSetRenameInformation() asserts in trunk. They can be reenabled for testing by commenting "#define NASSERTS_RENAME" out. CORE-8721 #resolve #comment Fixed with r65085 svn path=/trunk/; revision=65085 --- reactos/drivers/filesystems/fastfat/finfo.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/reactos/drivers/filesystems/fastfat/finfo.c b/reactos/drivers/filesystems/fastfat/finfo.c index 6ed6745e97b..7c08c1a7675 100644 --- a/reactos/drivers/filesystems/fastfat/finfo.c +++ b/reactos/drivers/filesystems/fastfat/finfo.c @@ -16,6 +16,8 @@ #define NDEBUG #include +#define NASSERTS_RENAME + /* GLOBALS ******************************************************************/ const char* FileInformationClassNames[] = @@ -459,6 +461,11 @@ VfatSetRenameInformation( PFILE_RENAME_INFORMATION RenameInfo, PFILE_OBJECT TargetFileObject) { +#ifdef NASSERTS_RENAME +#pragma push_macro("ASSERT") +#undef ASSERT +#define ASSERT(x) ((VOID) 0) +#endif NTSTATUS Status; UNICODE_STRING NewName; UNICODE_STRING SourcePath; @@ -485,6 +492,9 @@ VfatSetRenameInformation( } OldReferences = FCB->parentFcb->RefCount; +#ifdef NASSERTS_RENAME + UNREFERENCED_PARAMETER(OldReferences); +#endif /* If we are performing relative opening for rename, get FO for getting FCB and path name */ if (RenameInfo->RootDirectory != NULL) @@ -790,6 +800,9 @@ VfatSetRenameInformation( /* Try to find target */ ParentFCB = NULL; OldParent = FCB->parentFcb; +#ifdef NASSERTS_RENAME + UNREFERENCED_PARAMETER(OldParent); +#endif Status = vfatPrepareTargetForRename(DeviceExt, &ParentFCB, &NewName, @@ -803,6 +816,9 @@ VfatSetRenameInformation( } NewReferences = ParentFCB->RefCount; +#ifdef NASSERTS_RENAME + UNREFERENCED_PARAMETER(NewReferences); +#endif FsRtlNotifyFullReportChange(DeviceExt->NotifySync, &(DeviceExt->NotifyList), @@ -854,6 +870,9 @@ Cleanup: if (RenameInfo->RootDirectory != NULL) ObDereferenceObject(RootFileObject); return Status; +#ifdef NASSERTS_RENAME +#pragma pop_macro("ASSERT") +#endif } /* From 6417d36a41ec2098debc6054558cc498f8d95e0d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 28 Oct 2014 21:09:01 +0000 Subject: [PATCH 5/9] [GDI32] - Move functions to the appropriate source files, zap hacks.c, stubs.c, stubsa.c and stubsw.c (sorry for the noise, but this mess had to be cleaned up) svn path=/trunk/; revision=65086 --- reactos/win32ss/gdi/gdi32/CMakeLists.txt | 6 +- reactos/win32ss/gdi/gdi32/include/gdi32p.h | 5 + reactos/win32ss/gdi/gdi32/misc/hacks.c | 14 - reactos/win32ss/gdi/gdi32/misc/misc.c | 451 ++++- reactos/win32ss/gdi/gdi32/misc/stubs.c | 1736 ----------------- reactos/win32ss/gdi/gdi32/misc/stubsa.c | 173 -- reactos/win32ss/gdi/gdi32/misc/stubsw.c | 266 --- reactos/win32ss/gdi/gdi32/misc/wingl.c | 27 - reactos/win32ss/gdi/gdi32/objects/bitmap.c | 113 +- reactos/win32ss/gdi/gdi32/objects/brush.c | 65 + .../win32ss/gdi/gdi32/objects/colorspace.c | 130 ++ reactos/win32ss/gdi/gdi32/objects/coord.c | 92 + reactos/win32ss/gdi/gdi32/objects/dc.c | 583 ++---- reactos/win32ss/gdi/gdi32/objects/eng.c | 14 +- reactos/win32ss/gdi/gdi32/objects/enhmfile.c | 250 +++ reactos/win32ss/gdi/gdi32/objects/font.c | 259 +++ reactos/win32ss/gdi/gdi32/objects/gdiobj.c | 362 ++++ reactos/win32ss/gdi/gdi32/objects/icm.c | 192 ++ reactos/win32ss/gdi/gdi32/objects/metafile.c | 217 +++ reactos/win32ss/gdi/gdi32/objects/painting.c | 130 ++ reactos/win32ss/gdi/gdi32/objects/palette.c | 12 + reactos/win32ss/gdi/gdi32/objects/printdrv.c | 211 ++ reactos/win32ss/gdi/gdi32/objects/text.c | 116 ++ 23 files changed, 2678 insertions(+), 2746 deletions(-) delete mode 100644 reactos/win32ss/gdi/gdi32/misc/hacks.c delete mode 100644 reactos/win32ss/gdi/gdi32/misc/stubs.c delete mode 100644 reactos/win32ss/gdi/gdi32/misc/stubsa.c delete mode 100644 reactos/win32ss/gdi/gdi32/misc/stubsw.c create mode 100644 reactos/win32ss/gdi/gdi32/objects/colorspace.c create mode 100644 reactos/win32ss/gdi/gdi32/objects/gdiobj.c diff --git a/reactos/win32ss/gdi/gdi32/CMakeLists.txt b/reactos/win32ss/gdi/gdi32/CMakeLists.txt index 1d60fe3e092..f2ee2412b58 100644 --- a/reactos/win32ss/gdi/gdi32/CMakeLists.txt +++ b/reactos/win32ss/gdi/gdi32/CMakeLists.txt @@ -14,22 +14,20 @@ list(APPEND SOURCE main/dllmain.c misc/heap.c misc/gdientry.c - #misc/hacks.c misc/historic.c misc/misc.c - misc/stubs.c - misc/stubsa.c - misc/stubsw.c misc/wingl.c objects/arc.c objects/bitmap.c objects/brush.c objects/clientobj.c + objects/colorspace.c objects/coord.c objects/dc.c objects/eng.c objects/enhmfile.c objects/font.c + objects/gdiobj.c objects/icm.c objects/linedda.c objects/metafile.c diff --git a/reactos/win32ss/gdi/gdi32/include/gdi32p.h b/reactos/win32ss/gdi/gdi32/include/gdi32p.h index c453784036e..58ea3eb0681 100644 --- a/reactos/win32ss/gdi/gdi32/include/gdi32p.h +++ b/reactos/win32ss/gdi/gdi32/include/gdi32p.h @@ -279,6 +279,11 @@ EnumLogFontExW2A( LPENUMLOGFONTEXA fontA, CONST ENUMLOGFONTEXW *fontW ); +BOOL +WINAPI +GetETM(HDC hdc, + EXTTEXTMETRIC *petm); + /* FIXME: Put in some public header */ UINT WINAPI diff --git a/reactos/win32ss/gdi/gdi32/misc/hacks.c b/reactos/win32ss/gdi/gdi32/misc/hacks.c deleted file mode 100644 index c8ac9987164..00000000000 --- a/reactos/win32ss/gdi/gdi32/misc/hacks.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "precomp.h" - -/* - * reactos/lib/gdi32/misc/hacks.c - * - * GDI32.DLL hacks - * - * Apis that are hacked but we cannot write correct implementations yet but we are using our own syscall - * - */ - - - - diff --git a/reactos/win32ss/gdi/gdi32/misc/misc.c b/reactos/win32ss/gdi/gdi32/misc/misc.c index 9d6dae9e1df..f597b5633a6 100644 --- a/reactos/win32ss/gdi/gdi32/misc/misc.c +++ b/reactos/win32ss/gdi/gdi32/misc/misc.c @@ -34,41 +34,299 @@ PGDI_TABLE_ENTRY GdiHandleTable = NULL; PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable = NULL; HANDLE CurrentProcessId = NULL; DWORD GDI_BatchLimit = 1; +extern PGDIHANDLECACHE GdiHandleCache; - +/* + * @implemented + */ BOOL WINAPI -GdiAlphaBlend( - HDC hDCDst, - int DstX, - int DstY, - int DstCx, - int DstCy, - HDC hDCSrc, - int SrcX, - int SrcY, - int SrcCx, - int SrcCy, - BLENDFUNCTION BlendFunction -) +GdiFlush() { - if ( hDCSrc == NULL ) return FALSE; + NtGdiFlush(); + return TRUE; +} - if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE; +/* + * @unimplemented + */ +int +WINAPI +Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData) +{ + int retValue = SP_ERROR; + HGDIOBJ hObject = hdc; + UINT Type = 0; + LPVOID pUserData = NULL; + + Type = GDI_HANDLE_GET_TYPE(hObject); + + if (Type == GDI_OBJECT_TYPE_METADC) + { + /* FIXME we do not support metafile */ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + } + else + { + switch (nEscape) + { + case ABORTDOC: + /* Note Winodws check see if the handle have any user data for ABORTDOC command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + else + { + retValue = AbortDoc(hdc); + } + break; + + case DRAFTMODE: + case FLUSHOUTPUT: + case SETCOLORTABLE: + /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */ + /* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + } + retValue = FALSE; + break; + + case SETABORTPROC: + /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData); + break; + + case GETCOLORTABLE: + retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData); + if ( !retValue ) + { + retValue = SP_ERROR; + } + break; + + case ENDDOC: + /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + retValue = EndDoc(hdc); + break; + + + case GETSCALINGFACTOR: + /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */ + if ( Type == GDI_OBJECT_TYPE_DC ) + { + if ( lpvOutData ) + { + PPOINT ptr = (PPOINT) lpvOutData; + ptr->x = 0; + ptr->y = 0; + } + } + retValue = FALSE; + break; + + case GETEXTENDEDTEXTMETRICS: + retValue = (int) GetETM( hdc, (EXTTEXTMETRIC *) lpvOutData) != 0; + break; + + case STARTDOC: + { + DOCINFOA *pUserDatalpdi; + DOCINFOA lpdi; + + /* Note : Winodws check see if the handle have any user data for STARTDOC command + * ReactOS copy this behavior to be compatible with windows 2003 + */ + if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) || + (pUserData == NULL) ) + { + GdiSetLastError(ERROR_INVALID_HANDLE); + retValue = FALSE; + } + + lpdi.cbSize = sizeof(DOCINFOA); + + /* NOTE lpszOutput will be store in handle userdata */ + lpdi.lpszOutput = 0; + + lpdi.lpszDatatype = 0; + lpdi.fwType = 0; + lpdi.lpszDocName = lpvInData; + + /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */ + retValue = StartDocA(hdc, &lpdi); + + /* StartDocA fail */ + if (retValue < 0) + { + /* check see if outbuffer contain any data, if it does abort */ + if ( (pUserDatalpdi->lpszOutput != 0) && + ( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) ) + { + retValue = SP_APPABORT; + } + else + { + retValue = GetLastError(); + + /* Translate StartDocA error code to STARTDOC error code + * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx + */ + switch(retValue) + { + case ERROR_NOT_ENOUGH_MEMORY: + retValue = SP_OUTOFMEMORY; + break; + + case ERROR_PRINT_CANCELLED: + retValue = SP_USERABORT; + break; + + case ERROR_DISK_FULL: + retValue = SP_OUTOFDISK; + break; + + default: + retValue = SP_ERROR; + break; + } + } + } + } + break; + + + + + default: + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + } + } + + return retValue; +} + +INT +WINAPI +ExtEscape(HDC hDC, + int nEscape, + int cbInput, + LPCSTR lpszInData, + int cbOutput, + LPSTR lpszOutData) +{ + return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput, lpszOutData); +} + +INT +WINAPI +NamedEscape(HDC hdc, + PWCHAR pDriver, + INT iEsc, + INT cjIn, + LPSTR pjIn, + INT cjOut, + LPSTR pjOut) +{ + /* FIXME metadc, metadc are done most in user mode, and we do not support it + * Windows 2000/XP/Vista ignore the current hdc, that are being pass and always set hdc to NULL + * when it calls to NtGdiExtEscape from NamedEscape + */ + return NtGdiExtEscape(NULL,pDriver,wcslen(pDriver),iEsc,cjIn,pjIn,cjOut,pjOut); +} + +/* + * @implemented + */ +int +WINAPI +DrawEscape(HDC hDC, + INT nEscape, + INT cbInput, + LPCSTR lpszInData) +{ + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) + return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); + + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( pLDC ) + { + if (pLDC->Flags & LDC_META_PRINT) + { +// if (nEscape != QUERYESCSUPPORT) +// return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE); + + return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); + } + } + SetLastError(ERROR_INVALID_HANDLE); + } + return 0; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiDrawStream(HDC dc, ULONG l, VOID *v) // See Bug 4784 +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/* + * @implemented + */ +BOOL +WINAPI +GdiValidateHandle(HGDIOBJ hobj) +{ + PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj); + if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && + ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == + GDI_HANDLE_GET_TYPE(hobj) ) + { + HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); + if(pid == NULL || pid == CurrentProcessId) + { + return TRUE; + } + } + return FALSE; - return NtGdiAlphaBlend( - hDCDst, - DstX, - DstY, - DstCx, - DstCy, - hDCSrc, - SrcX, - SrcY, - SrcCx, - SrcCy, - BlendFunction, - 0 ); } /* @@ -227,27 +485,6 @@ GdiGetBatchLimit() return GDI_BatchLimit; } -/* - * @unimplemented - */ -BOOL -WINAPI -GdiReleaseDC(HDC hdc) -{ - return 0; -} - -INT -WINAPI -ExtEscape(HDC hDC, - int nEscape, - int cbInput, - LPCSTR lpszInData, - int cbOutput, - LPSTR lpszOutData) -{ - return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput, lpszOutData); -} /* * @implemented @@ -259,16 +496,6 @@ GdiSetLastError(DWORD dwErrCode) NtCurrentTeb()->LastErrorValue = (ULONG) dwErrCode; } -BOOL -WINAPI -GdiAddGlsBounds(HDC hdc,LPRECT prc) -{ - //FIXME: Lookup what 0x8000 means - return NtGdiSetBoundsRect(hdc, prc, 0x8000 | DCB_ACCUMULATE ) ? TRUE : FALSE; -} - -extern PGDIHANDLECACHE GdiHandleCache; - HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) @@ -342,3 +569,107 @@ hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) return Handle; } +/* + * @unimplemented + */ +BOOL +WINAPI +bMakePathNameW(LPWSTR lpBuffer,LPCWSTR lpFileName,LPWSTR *lpFilePart,DWORD unknown) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @implemented + */ +DEVMODEW * +WINAPI +GdiConvertToDevmodeW(const DEVMODEA *dmA) +{ + DEVMODEW *dmW; + WORD dmW_size, dmA_size; + + dmA_size = dmA->dmSize; + + /* this is the minimal dmSize that XP accepts */ + if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields)) + return NULL; + + if (dmA_size > sizeof(DEVMODEA)) + dmA_size = sizeof(DEVMODEA); + + dmW_size = dmA_size + CCHDEVICENAME; + if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME) + dmW_size += CCHFORMNAME; + + dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra); + if (!dmW) return NULL; + + MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME, + dmW->dmDeviceName, CCHDEVICENAME); + /* copy slightly more, to avoid long computations */ + memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME); + + if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME) + { + MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME, + dmW->dmFormName, CCHFORMNAME); + if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels)) + memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels)); + } + + if (dmA->dmDriverExtra) + memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra); + + dmW->dmSize = dmW_size; + + return dmW; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiRealizationInfo(HDC hdc, + PREALIZATION_INFO pri) +{ + // ATM we do not support local font data and Language Pack. + return NtGdiGetRealizationInfo(hdc, pri, (HFONT) NULL); +} + + +/* + * @unimplemented + */ +VOID WINAPI GdiInitializeLanguagePack(DWORD InitParam) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); +} + +BOOL +WINAPI +GdiAddGlsBounds(HDC hdc,LPRECT prc) +{ + //FIXME: Lookup what 0x8000 means + return NtGdiSetBoundsRect(hdc, prc, 0x8000 | DCB_ACCUMULATE ) ? TRUE : FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiAddGlsRecord(HDC hdc, + DWORD unknown1, + LPCSTR unknown2, + LPRECT unknown3) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + diff --git a/reactos/win32ss/gdi/gdi32/misc/stubs.c b/reactos/win32ss/gdi/gdi32/misc/stubs.c deleted file mode 100644 index 8d57a8a4764..00000000000 --- a/reactos/win32ss/gdi/gdi32/misc/stubs.c +++ /dev/null @@ -1,1736 +0,0 @@ -/* - * dll/win32/gdi32/misc/stubs.c - * - * GDI32.DLL Stubs - * - * When you implement one of these functions, - * remove its stub from this file. - * - */ - -#include -#include - -#define SIZEOF_DEVMODEA_300 124 -#define SIZEOF_DEVMODEA_400 148 -#define SIZEOF_DEVMODEA_500 156 -#define SIZEOF_DEVMODEW_300 188 -#define SIZEOF_DEVMODEW_400 212 -#define SIZEOF_DEVMODEW_500 220 - -/* - * @unimplemented - */ -BOOL -WINAPI -RestoreDC(IN HDC hdc, - IN INT iLevel) -{ - /* FIXME Sharememory */ - return NtGdiRestoreDC(hdc, iLevel); -} - -/* - * @unimplemented - */ -INT -WINAPI -SaveDC(IN HDC hdc) -{ - /* FIXME Sharememory */ - return NtGdiSaveDC(hdc); -} - -/* - * @implemented - */ -BOOL -WINAPI -CancelDC(HDC hDC) -{ - PDC_ATTR pDc_Attr; - - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC && - GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - /* If a document has started set it to die. */ - if (pLDC->Flags & LDC_INIT_DOCUMENT) pLDC->Flags |= LDC_KILL_DOCUMENT; - - return NtGdiCancelDC(hDC); - } - - if (GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr)) - { - pDc_Attr->ulDirty_ &= ~DC_PLAYMETAFILE; - return TRUE; - } - - return FALSE; -} - - -/* - * @implemented - */ -int -WINAPI -DrawEscape(HDC hDC, - INT nEscape, - INT cbInput, - LPCSTR lpszInData) -{ - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC) - return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); - - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( pLDC ) - { - if (pLDC->Flags & LDC_META_PRINT) - { -// if (nEscape != QUERYESCSUPPORT) -// return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE); - - return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData); - } - } - SetLastError(ERROR_INVALID_HANDLE); - } - return 0; -} - - -/* - * @implemented - */ -int -WINAPI -EnumObjects(HDC hdc, - int nObjectType, - GOBJENUMPROC lpObjectFunc, - LPARAM lParam) -{ - ULONG ObjectsCount; - ULONG Size; - PVOID Buffer = NULL; - DWORD_PTR EndOfBuffer; - int Result = 0; - - switch (nObjectType) - { - case OBJ_BRUSH: - Size = sizeof(LOGBRUSH); - break; - - case OBJ_PEN: - Size = sizeof(LOGPEN); - break; - - default: - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - ObjectsCount = NtGdiEnumObjects(hdc, nObjectType, 0, NULL); - if (!ObjectsCount) return 0; - - Buffer = HeapAlloc(GetProcessHeap(), 0, ObjectsCount * Size); - if (!Buffer) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - if (!NtGdiEnumObjects(hdc, nObjectType, ObjectsCount * Size, Buffer)) - { - HeapFree(GetProcessHeap(), 0, Buffer); - return 0; - } - - EndOfBuffer = (DWORD_PTR)Buffer + (ObjectsCount * Size); - while ((DWORD_PTR)Buffer < EndOfBuffer) - { - Result = lpObjectFunc(Buffer, lParam); - if (!Result) break; - Buffer = (PVOID)((DWORD_PTR)Buffer + Size); - } - - HeapFree(GetProcessHeap(), 0, Buffer); - return Result; -} - -/* - * @implemented - */ -UINT -WINAPI -GetBoundsRect( - HDC hdc, - LPRECT lprcBounds, - UINT flags -) -{ - return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET); -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetMetaFileBitsEx( - HMETAFILE a0, - UINT a1, - LPVOID a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -PlayMetaFile( - HDC a0, - HMETAFILE a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @implemented - */ -UINT -WINAPI -SetBoundsRect(HDC hdc, - CONST RECT *prc, - UINT flags) -{ - /* FIXME add check for validate the flags */ - return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags); -} - -/* - * @unimplemented - */ -HMETAFILE -WINAPI -SetMetaFileBitsEx( - UINT size, - CONST BYTE *lpData -) -{ - const METAHEADER *mh_in = (const METAHEADER *)lpData; - - if (size & 1) return 0; - - if (!size || mh_in->mtType != METAFILE_MEMORY || mh_in->mtVersion != 0x300 || - mh_in->mtHeaderSize != sizeof(METAHEADER) / 2) - { - DPRINT1("SetMetaFileBitsEx failed: %lu,%lu,0x&lx,%lu\n", - size, mh_in->mtType, mh_in->mtVersion, mh_in->mtHeaderSize); - SetLastError(ERROR_INVALID_DATA); - return 0; - } - - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -PlayMetaFileRecord( - HDC a0, - LPHANDLETABLE a1, - LPMETARECORD a2, - UINT a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -EnumMetaFile( - HDC a0, - HMETAFILE a1, - MFENUMPROC a2, - LPARAM a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -DeleteEnhMetaFile( - HENHMETAFILE a0 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -EnumEnhMetaFile( - HDC hdc, - HENHMETAFILE hmf, - ENHMFENUMPROC callback, - LPVOID data, - CONST RECT *lpRect -) -{ - if(!lpRect && hdc) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetEnhMetaFileBits( - HENHMETAFILE a0, - UINT a1, - LPBYTE a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -UINT -WINAPI -GetEnhMetaFileHeader( - HENHMETAFILE a0, - UINT a1, - LPENHMETAHEADER a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetEnhMetaFilePaletteEntries( - HENHMETAFILE a0, - UINT a1, - LPPALETTEENTRY a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -UINT -WINAPI -GetWinMetaFileBits( - HENHMETAFILE a0, - UINT a1, - LPBYTE a2, - INT a3, - HDC a4 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -PlayEnhMetaFile( - HDC a0, - HENHMETAFILE a1, - CONST RECT *a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -PlayEnhMetaFileRecord( - HDC a0, - LPHANDLETABLE a1, - CONST ENHMETARECORD *a2, - UINT a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -HENHMETAFILE -WINAPI -SetEnhMetaFileBits( - UINT a0, - CONST BYTE *a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -HENHMETAFILE -WINAPI -SetWinMetaFileBits( - UINT a0, - CONST BYTE *a1, - HDC a2, - CONST METAFILEPICT *a3) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiComment( - HDC hDC, - UINT bytes, - CONST BYTE *buffer -) -{ -#if 0 - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_EMF) - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (pLDC->iType == LDC_EMFLDC) - { - // Wine port - return EMFDRV_GdiComment( hDC, bytes, buffer ); - } - } -#endif - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -SetColorAdjustment( - HDC hdc, - CONST COLORADJUSTMENT *a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @implemented - */ -BOOL -WINAPI -UnrealizeObject(HGDIOBJ hgdiobj) -{ - BOOL retValue = TRUE; - /* - Win 2k Graphics API, Black Book. by coriolis.com - Page 62, Note that Steps 3, 5, and 6 are not required for Windows NT(tm) - and Windows 2000(tm). - - Step 5. UnrealizeObject(hTrackBrush); - */ - /* - msdn.microsoft.com, - "Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing, - and the function returns TRUE. Use SetBrushOrgEx to set the origin of - a brush." - */ - if (GDI_HANDLE_GET_TYPE(hgdiobj) != GDI_OBJECT_TYPE_BRUSH) - { - retValue = NtGdiUnrealizeObject(hgdiobj); - } - - return retValue; -} - - -/* - * @implemented - */ -BOOL -WINAPI -GdiFlush() -{ - NtGdiFlush(); - return TRUE; -} - - -/* - * @unimplemented - */ -int -WINAPI -SetICMMode( - HDC hdc, - int iEnableICM -) -{ - /*FIXME: Assume that ICM is always off, and cannot be turned on */ - if (iEnableICM == ICM_OFF) return ICM_OFF; - if (iEnableICM == ICM_ON) return 0; - if (iEnableICM == ICM_QUERY) return ICM_OFF; - - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -CheckColorsInGamut( - HDC a0, - LPVOID a1, - LPVOID a2, - DWORD a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @implemented - */ -BOOL -WINAPI -GetDeviceGammaRamp( HDC hdc, - LPVOID lpGammaRamp) -{ - BOOL retValue = FALSE; - if (lpGammaRamp == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - } - else - { - retValue = NtGdiGetDeviceGammaRamp(hdc,lpGammaRamp); - } - - return retValue; -} - -/* - * @implemented - */ -BOOL -WINAPI -SetDeviceGammaRamp(HDC hdc, - LPVOID lpGammaRamp) -{ - BOOL retValue = FALSE; - - if (lpGammaRamp) - { - retValue = NtGdiSetDeviceGammaRamp(hdc, lpGammaRamp); - } - else - { - SetLastError(ERROR_INVALID_PARAMETER); - } - - return retValue; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -ColorMatchToTarget( - HDC a0, - HDC a1, - DWORD a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* === AFTER THIS POINT I GUESS... ========= - * (based on stack size in Norlander's .def) - * === WHERE ARE THEY DEFINED? ============= - */ - -/* - * @unimplemented - */ -DWORD -WINAPI -IsValidEnhMetaRecord( - DWORD a0, - DWORD a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - -} - -/* - * @unimplemented - */ -DWORD -WINAPI -IsValidEnhMetaRecordOffExt( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - -} - -/* - * @unimplemented - */ -DWORD -WINAPI -GetGlyphOutlineWow( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3, - DWORD a4, - DWORD a5, - DWORD a6 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -DWORD -WINAPI -gdiPlaySpoolStream( - DWORD a0, - DWORD a1, - DWORD a2, - DWORD a3, - DWORD a4, - DWORD a5 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -HANDLE -WINAPI -AddFontMemResourceEx( - PVOID pbFont, - DWORD cbFont, - PVOID pdv, - DWORD *pcFonts -) -{ - if ( pbFont && cbFont && pcFonts) - { - return NtGdiAddFontMemResourceEx(pbFont, cbFont, NULL, 0, pcFonts); - } - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; -} - -/* - * @unimplemented - */ -int -WINAPI -AddFontResourceTracking( - LPCSTR lpString, - int unknown -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - - -/* - * @unimplemented - */ -HBITMAP -WINAPI -ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HBRUSH -WINAPI -ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiArtificialDecrementDriver(LPWSTR pDriverName,BOOL unknown) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiCleanCacheDC(HDC hdc) -{ - if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE) - return TRUE; - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; -} - -/* - * @implemented - */ -HDC -WINAPI -GdiConvertAndCheckDC(HDC hdc) -{ - PLDC pldc; - ULONG hType = GDI_HANDLE_GET_TYPE(hdc); - if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) - return hdc; - pldc = GdiGetLDC(hdc); - if (pldc) - { - if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); - if (pldc->Flags & LDC_KILL_DOCUMENT) return NULL; - if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc); - return hdc; - } - SetLastError(ERROR_INVALID_HANDLE); - return NULL; -} - -/* - * @unimplemented - */ -HENHMETAFILE -WINAPI -GdiConvertEnhMetaFile(HENHMETAFILE hmf) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiDrawStream(HDC dc, ULONG l, VOID *v) // See Bug 4784 -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiIsMetaFileDC(HDC hDC) -{ - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return TRUE; - else - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if ( pLDC->iType == LDC_EMFLDC) return TRUE; - } - } - return FALSE; -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiIsMetaPrintDC(HDC hDC) -{ - - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return FALSE; - else - { - PLDC pLDC = GdiGetLDC(hDC); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if ( pLDC->Flags & LDC_META_PRINT) return TRUE; - } - } - return FALSE; -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiIsPlayMetafileDC(HDC hDC) -{ - PLDC pLDC = GdiGetLDC(hDC); - if ( pLDC ) - { - if ( pLDC->Flags & LDC_PLAY_MFDC ) return TRUE; - } - return FALSE; -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiValidateHandle(HGDIOBJ hobj) -{ - PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj); - if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && - ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == - GDI_HANDLE_GET_TYPE(hobj) ) - { - HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1); - if(pid == NULL || pid == CurrentProcessId) - { - return TRUE; - } - } - return FALSE; - -} - -/* - * @unimplemented - */ -DWORD -WINAPI -GetBitmapAttributes(HBITMAP hbm) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -DWORD -WINAPI -GetBrushAttributes(HBRUSH hbr) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -ULONG -WINAPI -GetEUDCTimeStamp(VOID) -{ - return NtGdiGetEudcTimeStampEx(NULL,0,TRUE); -} - -/* - * @implemented - */ -ULONG -WINAPI -GetFontAssocStatus(HDC hdc) -{ - ULONG retValue = 0; - - if (hdc) - { - retValue = NtGdiQueryFontAssocInfo(hdc); - } - - return retValue; -} - -/* - * @implemented - */ -BOOL -WINAPI -GetTextExtentExPointWPri(HDC hdc, - LPWSTR lpwsz, - ULONG cwc, - ULONG dxMax, - ULONG *pcCh, - PULONG pdxOut, - LPSIZE psize) -{ - return NtGdiGetTextExtentExW(hdc,lpwsz,cwc,dxMax,pcCh,pdxOut,psize,0); -} - -/* - * @unimplemented - */ -DWORD -WINAPI -QueryFontAssocStatus(VOID) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -BOOL -WINAPI -RemoveFontMemResourceEx(HANDLE fh) -{ - if (fh) - { - return NtGdiRemoveFontMemResourceEx(fh); - } - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; -} - -/* - * @unimplemented - */ -int -WINAPI -RemoveFontResourceTracking(LPCSTR lpString,int unknown) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HBITMAP -WINAPI -SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HBRUSH -WINAPI -SetBrushAttributes(HBRUSH hbm, DWORD dwFlags) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -int -WINAPI -StartFormPage(HDC hdc) -{ - return StartPage(hdc); -} - -/* - * @unimplemented - */ -VOID -WINAPI -UnloadNetworkFonts(DWORD unknown) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiRealizationInfo(HDC hdc, - PREALIZATION_INFO pri) -{ - // ATM we do not support local font data and Language Pack. - return NtGdiGetRealizationInfo(hdc, pri, (HFONT) NULL); -} - -/* - * @implemented - */ -BOOL -WINAPI -GetETM(HDC hdc, - EXTTEXTMETRIC *petm) -{ - BOOL Ret = NtGdiGetETM(hdc, petm); - - if (Ret && petm) - petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0); - - return Ret; -} - -/* - * @unimplemented - */ -int -WINAPI -Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData) -{ - int retValue = SP_ERROR; - HGDIOBJ hObject = hdc; - UINT Type = 0; - LPVOID pUserData = NULL; - - Type = GDI_HANDLE_GET_TYPE(hObject); - - if (Type == GDI_OBJECT_TYPE_METADC) - { - /* FIXME we do not support metafile */ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - } - else - { - switch (nEscape) - { - case ABORTDOC: - /* Note Winodws check see if the handle have any user data for ABORTDOC command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - else - { - retValue = AbortDoc(hdc); - } - break; - - case DRAFTMODE: - case FLUSHOUTPUT: - case SETCOLORTABLE: - /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */ - /* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - } - retValue = FALSE; - break; - - case SETABORTPROC: - /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData); - break; - - case GETCOLORTABLE: - retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData); - if ( !retValue ) - { - retValue = SP_ERROR; - } - break; - - case ENDDOC: - /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - retValue = EndDoc(hdc); - break; - - - case GETSCALINGFACTOR: - /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */ - if ( Type == GDI_OBJECT_TYPE_DC ) - { - if ( lpvOutData ) - { - PPOINT ptr = (PPOINT) lpvOutData; - ptr->x = 0; - ptr->y = 0; - } - } - retValue = FALSE; - break; - - case GETEXTENDEDTEXTMETRICS: - retValue = (int) GetETM( hdc, (EXTTEXTMETRIC *) lpvOutData) != 0; - break; - - case STARTDOC: - { - DOCINFOA *pUserDatalpdi; - DOCINFOA lpdi; - - /* Note : Winodws check see if the handle have any user data for STARTDOC command - * ReactOS copy this behavior to be compatible with windows 2003 - */ - if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) || - (pUserData == NULL) ) - { - GdiSetLastError(ERROR_INVALID_HANDLE); - retValue = FALSE; - } - - lpdi.cbSize = sizeof(DOCINFOA); - - /* NOTE lpszOutput will be store in handle userdata */ - lpdi.lpszOutput = 0; - - lpdi.lpszDatatype = 0; - lpdi.fwType = 0; - lpdi.lpszDocName = lpvInData; - - /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */ - retValue = StartDocA(hdc, &lpdi); - - /* StartDocA fail */ - if (retValue < 0) - { - /* check see if outbuffer contain any data, if it does abort */ - if ( (pUserDatalpdi->lpszOutput != 0) && - ( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) ) - { - retValue = SP_APPABORT; - } - else - { - retValue = GetLastError(); - - /* Translate StartDocA error code to STARTDOC error code - * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx - */ - switch(retValue) - { - case ERROR_NOT_ENOUGH_MEMORY: - retValue = SP_OUTOFMEMORY; - break; - - case ERROR_PRINT_CANCELLED: - retValue = SP_USERABORT; - break; - - case ERROR_DISK_FULL: - retValue = SP_OUTOFDISK; - break; - - default: - retValue = SP_ERROR; - break; - } - } - } - } - break; - - - - - default: - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - } - } - - return retValue; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiAddGlsRecord(HDC hdc, - DWORD unknown1, - LPCSTR unknown2, - LPRECT unknown3) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HANDLE -WINAPI -GdiConvertMetaFilePict(HGLOBAL hMem) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -DEVMODEW * -WINAPI -GdiConvertToDevmodeW(const DEVMODEA *dmA) -{ - DEVMODEW *dmW; - WORD dmW_size, dmA_size; - - dmA_size = dmA->dmSize; - - /* this is the minimal dmSize that XP accepts */ - if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields)) - return NULL; - - if (dmA_size > sizeof(DEVMODEA)) - dmA_size = sizeof(DEVMODEA); - - dmW_size = dmA_size + CCHDEVICENAME; - if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME) - dmW_size += CCHFORMNAME; - - dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra); - if (!dmW) return NULL; - - MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME, - dmW->dmDeviceName, CCHDEVICENAME); - /* copy slightly more, to avoid long computations */ - memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME); - - if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME) - { - MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME, - dmW->dmFormName, CCHFORMNAME); - if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels)) - memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels)); - } - - if (dmA->dmDriverExtra) - memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra); - - dmW->dmSize = dmW_size; - - return dmW; -} - -/* - * @unimplemented - */ -HENHMETAFILE -WINAPI -GdiCreateLocalEnhMetaFile(HENHMETAFILE hmo) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -METAFILEPICT * -WINAPI -GdiCreateLocalMetaFilePict(HENHMETAFILE hmo) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HDC -WINAPI -GdiGetDC(HANDLE SpoolFileHandle) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -HANDLE -WINAPI -GdiGetPageHandle(HANDLE SpoolFileHandle, - DWORD Page, - LPDWORD pdwPageType) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiStartDocEMF(HANDLE SpoolFileHandle, - DOCINFOW *pDocInfo) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiStartPageEMF(HANDLE SpoolFileHandle) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiPlayPageEMF(HANDLE SpoolFileHandle, - HANDLE hemf, - RECT *prectDocument, - RECT *prectBorder, - RECT *prectClip) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiEndPageEMF(HANDLE SpoolFileHandle, - DWORD dwOptimization) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiEndDocEMF(HANDLE SpoolFileHandle) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiGetDevmodeForPage(HANDLE SpoolFileHandle, - DWORD dwPageNumber, - PDEVMODEW *pCurrDM, - PDEVMODEW *pLastDM) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiResetDCEMF(HANDLE SpoolFileHandle, - PDEVMODEW pCurrDM) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -ULONG * -WINAPI -XLATEOBJ_piVector(XLATEOBJ *XlateObj) -{ - return XlateObj->pulXlate; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiPlayEMF(LPWSTR pwszPrinterName, - LPDEVMODEW pDevmode, - LPWSTR pwszDocName, - EMFPLAYPROC pfnEMFPlayFn, - HANDLE hPageQuery - ) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiPlayPrivatePageEMF(HANDLE SpoolFileHandle, - DWORD unknown, - RECT *prectDocument) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -VOID WINAPI GdiInitializeLanguagePack(DWORD InitParam) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiGradientFill( - IN HDC hdc, - IN PTRIVERTEX pVertex, - IN ULONG nVertex, - IN PVOID pMesh, - IN ULONG nMesh, - IN ULONG ulMode) -{ - /* FIXME some part need be done in user mode */ - return NtGdiGradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode); -} - -/* - * @implemented - */ -BOOL -WINAPI -GdiTransparentBlt(IN HDC hdcDst, - IN INT xDst, - IN INT yDst, - IN INT cxDst, - IN INT cyDst, - IN HDC hdcSrc, - IN INT xSrc, - IN INT ySrc, - IN INT cxSrc, - IN INT cySrc, - IN UINT TransColor - ) -{ - /* FIXME some part need be done in user mode */ - return NtGdiTransparentBlt(hdcDst, xDst, yDst, cxDst, cyDst, hdcSrc, xSrc, ySrc, cxSrc, cySrc, (COLORREF)TransColor); -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GdiPrinterThunk( - IN HUMPD humpd, - DWORD *status, - DWORD unuse) -{ - /* FIXME figout the protypes, the HUMPD are a STRUCT or COM object */ - /* status contain some form of return value that being save, what it is I do not known */ - /* unsue seam have zero effect, what it is for I do not known */ - - // ? return NtGdiSetPUMPDOBJ(humpd->0x10,TRUE, humpd, ?) <- blackbox, OpenRCE info, and api hooks for anylaysing; - return FALSE; -} - -/* - * @unimplemented - * - */ -HBITMAP -WINAPI -GdiConvertBitmapV5( - HBITMAP in_format_BitMap, - HBITMAP src_BitMap, - INT bpp, - INT unuse) -{ - /* FIXME guessing the prototypes */ - - /* - * it have create a new bitmap with desired in format, - * then convert it src_bitmap to new format - * and return it as HBITMAP - */ - - return FALSE; -} - -/* - * @implemented - * - */ -int -WINAPI -GetClipBox(HDC hdc, - LPRECT lprc) -{ - return NtGdiGetAppClipBox(hdc, lprc); -} - -/* - * @implemented - * - */ -DWORD -WINAPI -GetFontData(HDC hdc, - DWORD dwTable, - DWORD dwOffset, - LPVOID lpvBuffer, - DWORD cbData) -{ - if (!lpvBuffer) - { - cbData = 0; - } - return NtGdiGetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData); -} - -INT -WINAPI -NamedEscape(HDC hdc, - PWCHAR pDriver, - INT iEsc, - INT cjIn, - LPSTR pjIn, - INT cjOut, - LPSTR pjOut) -{ - /* FIXME metadc, metadc are done most in user mode, and we do not support it - * Windows 2000/XP/Vista ignore the current hdc, that are being pass and always set hdc to NULL - * when it calls to NtGdiExtEscape from NamedEscape - */ - return NtGdiExtEscape(NULL,pDriver,wcslen(pDriver),iEsc,cjIn,pjIn,cjOut,pjOut); -} - -/* - * @unimplemented - */ - -/* FIXME wrong protypes, it is a fastcall api */ -DWORD -WINAPI -cGetTTFFromFOT(DWORD x1 ,DWORD x2 ,DWORD x3, DWORD x4, DWORD x5, DWORD x6, DWORD x7) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - diff --git a/reactos/win32ss/gdi/gdi32/misc/stubsa.c b/reactos/win32ss/gdi/gdi32/misc/stubsa.c deleted file mode 100644 index c4c502b7cfb..00000000000 --- a/reactos/win32ss/gdi/gdi32/misc/stubsa.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * dll/win32/gdi32/misc/stubsa.c - * - * GDI32.DLL Stubs for ANSI functions - * - * When you implement one of these functions, - * remove its stub from this file. - * - */ - -#include -#include - - -/* - * @unimplemented - */ -BOOL -WINAPI -PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings ) -{ - for (; cStrings>0; cStrings--, pptxt++) - if (!ExtTextOutA( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) - return FALSE; - return TRUE; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GetLogColorSpaceA( - HCOLORSPACE a0, - LPLOGCOLORSPACEA a1, - DWORD a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -GetICMProfileA( - HDC hdc, - LPDWORD pBufSize, - LPSTR pszFilename -) -{ - WCHAR filenameW[MAX_PATH]; - DWORD buflen = MAX_PATH; - BOOL ret = FALSE; - - if (!hdc || !pBufSize || !pszFilename) return FALSE; - - if (GetICMProfileW(hdc, &buflen, filenameW)) - { - ULONG len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL); - if (*pBufSize >= len) - { - WideCharToMultiByte(CP_ACP, 0, filenameW, -1, pszFilename, *pBufSize, NULL, NULL); - ret = TRUE; - } - else SetLastError(ERROR_INSUFFICIENT_BUFFER); - *pBufSize = len; - } - - return ret; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -SetICMProfileA( - HDC a0, - LPSTR a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -int -WINAPI -EnumICMProfilesA( - HDC a0, - ICMENUMPROCA a1, - LPARAM a2 -) -{ - /* - * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer - * to find out how big a buffer we need. Then allocate that buffer - * and call NtGdiEnumICMProfiles again to have the buffer filled. - * - * Finally, step through the buffer ( MULTI-SZ recommended for format ), - * and convert each string to ANSI, calling the user's callback function - * until we run out of strings or the user returns FALSE - */ - - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -UpdateICMRegKeyA( - DWORD a0, - LPSTR a1, - LPSTR a2, - UINT a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -/* - * @implemented - */ -UINT -WINAPI -GetStringBitmapA(HDC hdc, - LPSTR psz, - BOOL DoCall, - UINT cj, - BYTE *lpSB) -{ - - NTSTATUS Status; - PWSTR pwsz; - UINT retValue = 0; - - if (DoCall) - { - Status = HEAP_strdupA2W ( &pwsz, psz ); - if ( !NT_SUCCESS (Status) ) - { - SetLastError (RtlNtStatusToDosError(Status)); - } - else - { - retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj); - HEAP_free ( pwsz ); - } - } - - return retValue; - -} - - -/* EOF */ diff --git a/reactos/win32ss/gdi/gdi32/misc/stubsw.c b/reactos/win32ss/gdi/gdi32/misc/stubsw.c deleted file mode 100644 index d649db7d1b8..00000000000 --- a/reactos/win32ss/gdi/gdi32/misc/stubsw.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * dll/win32/gdi32/misc/stubsw.c - * - * GDI32.DLL Stubs for Unicode functions - * - * When you implement one of these functions, - * remove its stub from this file. - * - */ - -#include -#include - - -/* - * @unimplemented - */ -BOOL -WINAPI -PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings ) -{ - for (; cStrings>0; cStrings--, pptxt++) - if (!ExtTextOutW( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) - return FALSE; - return TRUE; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -GetLogColorSpaceW( - HCOLORSPACE a0, - LPLOGCOLORSPACEW a1, - DWORD a2 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -GetICMProfileW( - HDC hdc, - LPDWORD size, - LPWSTR filename -) -{ - if (!hdc || !size || !filename) return FALSE; - - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -SetICMProfileW( - HDC a0, - LPWSTR a1 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -int -WINAPI -EnumICMProfilesW( - HDC hDC, - ICMENUMPROCW lpEnumICMProfilesFunc, - LPARAM lParam -) -{ - /* - * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer - * to find out how big a buffer we need. Then allocate that buffer - * and call NtGdiEnumICMProfiles again to have the buffer filled. - * - * Finally, step through the buffer ( MULTI-SZ recommended for format ), - * and call the user's callback function until we run out of strings or - * the user returns FALSE - */ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -UpdateICMRegKeyW( - DWORD a0, - LPWSTR a1, - LPWSTR a2, - UINT a3 -) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* === AFTER THIS POINT I GUESS... ========= - * (based on stack size in Norlander's .def) - * === WHERE ARE THEY DEFINED? ============= - */ - - -/* - * @unimplemented - */ -BOOL -WINAPI -EudcLoadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath,INT iPriority,INT iFontLinkType) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -EudcUnloadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -int -WINAPI -GdiAddFontResourceW( - LPCWSTR lpszFilename, - FLONG fl, - DESIGNVECTOR *pdv) -{ - return NtGdiAddFontResourceW((PWSTR)lpszFilename, 0, 0, fl, 0, pdv); -} - -/* - * @implemented - */ -DWORD -WINAPI -GetEUDCTimeStampExW(LPWSTR lpBaseFaceName) -{ - DWORD retValue = 0; - - if (!lpBaseFaceName) - { - retValue = NtGdiGetEudcTimeStampEx(NULL,0,FALSE); - } - else - { - retValue = NtGdiGetEudcTimeStampEx(lpBaseFaceName, wcslen(lpBaseFaceName), FALSE); - } - - return retValue; -} - - - -/* - * @unimplemented - */ -BOOL -WINAPI -bInitSystemAndFontsDirectoriesW(LPWSTR *SystemDir,LPWSTR *FontsDir) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -bMakePathNameW(LPWSTR lpBuffer,LPCWSTR lpFileName,LPWSTR *lpFilePart,DWORD unknown) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - -/* - * @implemented - */ -UINT -WINAPI -GetStringBitmapW(HDC hdc, - LPWSTR pwsz, - BOOL doCall, - UINT cj, - BYTE *lpSB) -{ - UINT retValue = 0; - - if (doCall) - { - retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj); - } - - return retValue; - -} - - -BOOL -WINAPI -CreateScalableFontResourceW( - DWORD fdwHidden, - LPCWSTR lpszFontRes, - LPCWSTR lpszFontFile, - LPCWSTR lpszCurrentPath -) -{ - HANDLE f; - - UNIMPLEMENTED; - - /* fHidden=1 - only visible for the calling app, read-only, not - * enumerated with EnumFonts/EnumFontFamilies - * lpszCurrentPath can be NULL - */ - - /* If the output file already exists, return the ERROR_FILE_EXISTS error as specified in MSDN */ - if ((f = CreateFileW(lpszFontRes, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) - { - CloseHandle(f); - SetLastError(ERROR_FILE_EXISTS); - return FALSE; - } - return FALSE; /* create failed */ -} - - -/* EOF */ diff --git a/reactos/win32ss/gdi/gdi32/misc/wingl.c b/reactos/win32ss/gdi/gdi32/misc/wingl.c index 7389109dda5..13fee27278f 100644 --- a/reactos/win32ss/gdi/gdi32/misc/wingl.c +++ b/reactos/win32ss/gdi/gdi32/misc/wingl.c @@ -199,31 +199,4 @@ SwapBuffers(HDC hdc) Do this here for now. */ -/* - * @implemented - */ -UINT -WINAPI -GetEnhMetaFilePixelFormat( - HENHMETAFILE hemf, - UINT cbBuffer, - PIXELFORMATDESCRIPTOR *ppfd -) -{ - ENHMETAHEADER pemh; - - if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh)) - { - if(pemh.bOpenGL) - { - if(pemh.cbPixelFormat) - { - memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer ); - return(pemh.cbPixelFormat); - } - } - } - return(0); -} - /* EOF */ diff --git a/reactos/win32ss/gdi/gdi32/objects/bitmap.c b/reactos/win32ss/gdi/gdi32/objects/bitmap.c index 4173e4ba84c..e764fa36ff1 100644 --- a/reactos/win32ss/gdi/gdi32/objects/bitmap.c +++ b/reactos/win32ss/gdi/gdi32/objects/bitmap.c @@ -243,60 +243,6 @@ CreateDIBSection( return hBitmap; } -/* - * @implemented - */ -BOOL -WINAPI -BitBlt( - HDC hdcDest, /* handle to destination DC */ - int nXOriginDest, /* x-coord of destination upper-left corner */ - int nYOriginDest, /* y-coord of destination upper-left corner */ - int nWidthDest, /* width of destination rectangle */ - int nHeightDest, /* height of destination rectangle */ - HDC hdcSrc, /* handle to source DC */ - int nXSrc, /* x-coordinate of source upper-left corner */ - int nYSrc, /* y-coordinate of source upper-left corner */ - DWORD dwRop) /* raster operation code */ -{ - /* use patBlt for no source blt Like windows does */ - if (!ROP_USES_SOURCE(dwRop)) - { - return PatBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop); - } - - return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXSrc, - nYSrc, dwRop, 0, 0); -} - -/* - * @implemented - */ -BOOL -WINAPI -StretchBlt( - HDC hdcDest, /* handle to destination DC */ - int nXOriginDest, /* x-coord of destination upper-left corner */ - int nYOriginDest, /* y-coord of destination upper-left corner */ - int nWidthDest, /* width of destination rectangle */ - int nHeightDest, /* height of destination rectangle */ - HDC hdcSrc, /* handle to source DC */ - int nXOriginSrc, /* x-coord of source upper-left corner */ - int nYOriginSrc, /* y-coord of source upper-left corner */ - int nWidthSrc, /* width of source rectangle */ - int nHeightSrc, /* height of source rectangle */ - DWORD dwRop) /* raster operation code */ - -{ - if ((nWidthDest != nWidthSrc) || (nHeightDest != nHeightSrc)) - { - return NtGdiStretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, - nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop, 0); - } - - return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, - nXOriginSrc, nYOriginSrc, dwRop, 0, 0); -} /* * @implemented @@ -925,3 +871,62 @@ StretchDIBits( return LinesCopied; } +/* + * @unimplemented + */ +DWORD +WINAPI +GetBitmapAttributes(HBITMAP hbm) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HBITMAP +WINAPI +SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HBITMAP +WINAPI +ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + * + */ +HBITMAP +WINAPI +GdiConvertBitmapV5( + HBITMAP in_format_BitMap, + HBITMAP src_BitMap, + INT bpp, + INT unuse) +{ + /* FIXME guessing the prototypes */ + + /* + * it have create a new bitmap with desired in format, + * then convert it src_bitmap to new format + * and return it as HBITMAP + */ + + return FALSE; +} + diff --git a/reactos/win32ss/gdi/gdi32/objects/brush.c b/reactos/win32ss/gdi/gdi32/objects/brush.c index 6a686402c1a..4931c48f1e8 100644 --- a/reactos/win32ss/gdi/gdi32/objects/brush.c +++ b/reactos/win32ss/gdi/gdi32/objects/brush.c @@ -427,3 +427,68 @@ SetBrushOrgEx(HDC hdc, /* Fall back to the slower kernel path */ return NtGdiSetBrushOrg(hdc, nXOrg, nYOrg, lppt); } + +/* + * @unimplemented + */ +DWORD +WINAPI +GetBrushAttributes(HBRUSH hbr) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HBRUSH +WINAPI +SetBrushAttributes(HBRUSH hbm, DWORD dwFlags) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HBRUSH +WINAPI +ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @implemented + */ +BOOL +WINAPI +UnrealizeObject(HGDIOBJ hgdiobj) +{ + BOOL retValue = TRUE; + /* + Win 2k Graphics API, Black Book. by coriolis.com + Page 62, Note that Steps 3, 5, and 6 are not required for Windows NT(tm) + and Windows 2000(tm). + + Step 5. UnrealizeObject(hTrackBrush); + */ + /* + msdn.microsoft.com, + "Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing, + and the function returns TRUE. Use SetBrushOrgEx to set the origin of + a brush." + */ + if (GDI_HANDLE_GET_TYPE(hgdiobj) != GDI_OBJECT_TYPE_BRUSH) + { + retValue = NtGdiUnrealizeObject(hgdiobj); + } + + return retValue; +} diff --git a/reactos/win32ss/gdi/gdi32/objects/colorspace.c b/reactos/win32ss/gdi/gdi32/objects/colorspace.c new file mode 100644 index 00000000000..14918adbea0 --- /dev/null +++ b/reactos/win32ss/gdi/gdi32/objects/colorspace.c @@ -0,0 +1,130 @@ +#include + +#define NDEBUG +#include + +/* + * @unimplemented + */ +BOOL +WINAPI +GetLogColorSpaceA( + HCOLORSPACE a0, + LPLOGCOLORSPACEA a1, + DWORD a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +GetLogColorSpaceW( + HCOLORSPACE a0, + LPLOGCOLORSPACEW a1, + DWORD a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +CheckColorsInGamut( + HDC a0, + LPVOID a1, + LPVOID a2, + DWORD a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +GetDeviceGammaRamp( HDC hdc, + LPVOID lpGammaRamp) +{ + BOOL retValue = FALSE; + if (lpGammaRamp == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + } + else + { + retValue = NtGdiGetDeviceGammaRamp(hdc,lpGammaRamp); + } + + return retValue; +} + +/* + * @implemented + */ +BOOL +WINAPI +SetDeviceGammaRamp(HDC hdc, + LPVOID lpGammaRamp) +{ + BOOL retValue = FALSE; + + if (lpGammaRamp) + { + retValue = NtGdiSetDeviceGammaRamp(hdc, lpGammaRamp); + } + else + { + SetLastError(ERROR_INVALID_PARAMETER); + } + + return retValue; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +ColorMatchToTarget( + HDC a0, + HDC a1, + DWORD a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +SetColorAdjustment( + HDC hdc, + CONST COLORADJUSTMENT *a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} diff --git a/reactos/win32ss/gdi/gdi32/objects/coord.c b/reactos/win32ss/gdi/gdi32/objects/coord.c index b919e1fe895..cc28b06527a 100644 --- a/reactos/win32ss/gdi/gdi32/objects/coord.c +++ b/reactos/win32ss/gdi/gdi32/objects/coord.c @@ -105,6 +105,69 @@ CombineTransform( } +/* + * @implemented + * + */ +int +WINAPI +GetMapMode(HDC hdc) +{ + PDC_ATTR pdcattr; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + return pdcattr->iMapMode; +} + +/* + * @implemented + */ +INT +WINAPI +SetMapMode( + _In_ HDC hdc, + _In_ INT iMode) +{ + PDC_ATTR pdcattr; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + +#if 0 + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetMapMode(hdc, iMode); + else + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + } +#endif + /* Force change if Isotropic is set for recompute. */ + if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC)) + { + pdcattr->ulDirty_ &= ~SLOW_WIDTHS; + return GetAndSetDCDWord( hdc, GdiGetSetMapMode, iMode, 0, 0, 0 ); + } + + return pdcattr->iMapMode; +} + + BOOL WINAPI DPtoLP(HDC hdc, LPPOINT lpPoints, INT nCount) @@ -745,6 +808,35 @@ SetLayoutWidth(HDC hdc,LONG wox,DWORD dwLayout) return NtGdiSetLayout( hdc, wox, dwLayout); } +/* + * @implemented + */ +BOOL +WINAPI +GetDCOrgEx( + HDC hdc, + LPPOINT lpPoint) +{ + return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); +} + + +/* + * @implemented + */ +LONG +WINAPI +GetDCOrg( + HDC hdc) +{ + // Officially obsolete by Microsoft + POINT Pt; + if (!GetDCOrgEx(hdc, &Pt)) + return 0; + return(MAKELONG(Pt.x, Pt.y)); +} + + /* * @implemented * diff --git a/reactos/win32ss/gdi/gdi32/objects/dc.c b/reactos/win32ss/gdi/gdi32/objects/dc.c index 07eac4fb885..6c8a82dd6c8 100644 --- a/reactos/win32ss/gdi/gdi32/objects/dc.c +++ b/reactos/win32ss/gdi/gdi32/objects/dc.c @@ -3,8 +3,6 @@ #define NDEBUG #include -HGDIOBJ stock_objects[NB_STOCK_OBJECTS]; // temp location. - HDC FASTCALL IntCreateDICW( @@ -320,86 +318,63 @@ DeleteDC(HDC hdc) return bResult; } + +/* + * @unimplemented + */ +INT +WINAPI +SaveDC(IN HDC hdc) +{ + /* FIXME Sharememory */ + return NtGdiSaveDC(hdc); +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +RestoreDC(IN HDC hdc, + IN INT iLevel) +{ + /* FIXME Sharememory */ + return NtGdiRestoreDC(hdc, iLevel); +} + + /* * @implemented */ BOOL WINAPI -DeleteObject(HGDIOBJ hObject) +CancelDC(HDC hDC) { - DWORD dwType = 0; + PDC_ATTR pDc_Attr; - /* From Wine: DeleteObject does not SetLastError() on a null object */ - if(!hObject) return FALSE; - - if ((DWORD)hObject & GDI_HANDLE_STOCK_MASK) + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC && + GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC ) { - // Relax! This is a normal return! - DPRINT("Trying to delete system object 0x%p\n", hObject); + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + /* If a document has started set it to die. */ + if (pLDC->Flags & LDC_INIT_DOCUMENT) pLDC->Flags |= LDC_KILL_DOCUMENT; + + return NtGdiCancelDC(hDC); + } + + if (GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr)) + { + pDc_Attr->ulDirty_ &= ~DC_PLAYMETAFILE; return TRUE; } - // If you dont own it?! Get OUT! - if(!GdiIsHandleValid(hObject)) return FALSE; - - dwType = GDI_HANDLE_GET_TYPE(hObject); - - if ((dwType == GDI_OBJECT_TYPE_METAFILE) || - (dwType == GDI_OBJECT_TYPE_ENHMETAFILE)) - return FALSE; - - switch (dwType) - { - case GDI_OBJECT_TYPE_DC: - return DeleteDC((HDC) hObject); - case GDI_OBJECT_TYPE_COLORSPACE: - return NtGdiDeleteColorSpace((HCOLORSPACE) hObject); - case GDI_OBJECT_TYPE_REGION: - return DeleteRegion((HRGN) hObject); -#if 0 - case GDI_OBJECT_TYPE_METADC: - return MFDRV_DeleteObject( hObject ); - case GDI_OBJECT_TYPE_EMF: - { - PLDC pLDC = GdiGetLDC(hObject); - if ( !pLDC ) return FALSE; - return EMFDRV_DeleteObject( hObject ); - } -#endif - case GDI_OBJECT_TYPE_FONT: - break; - - case GDI_OBJECT_TYPE_BRUSH: - case GDI_OBJECT_TYPE_EXTPEN: - case GDI_OBJECT_TYPE_PEN: - { - PBRUSH_ATTR Brh_Attr; - PTEB pTeb; - PGDIBSOBJECT pgO; - - if ((!GdiGetHandleUserData(hObject, dwType, (PVOID*)&Brh_Attr)) || - (Brh_Attr == NULL)) break; - - pTeb = NtCurrentTeb(); - - if (pTeb->Win32ThreadInfo == NULL) break; - - pgO = GdiAllocBatchCommand(NULL, GdiBCDelObj); - if (pgO) - { - pgO->hgdiobj = hObject; - return TRUE; - } - - break; - } - - case GDI_OBJECT_TYPE_BITMAP: - default: - break; - } - - return NtGdiDeleteObjectApp(hObject); + return FALSE; } INT @@ -420,6 +395,54 @@ SetArcDirection( return GetAndSetDCDWord(hdc, GdiGetSetArcDirection, nDirection, 0, 0, 0); } +/* + * @unimplemented + */ +BOOL +WINAPI +GdiReleaseDC(HDC hdc) +{ + return 0; +} + + +/* + * @implemented + */ +BOOL +WINAPI +GdiCleanCacheDC(HDC hdc) +{ + if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE) + return TRUE; + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; +} + +/* + * @implemented + */ +HDC +WINAPI +GdiConvertAndCheckDC(HDC hdc) +{ + PLDC pldc; + ULONG hType = GDI_HANDLE_GET_TYPE(hdc); + if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE) + return hdc; + pldc = GdiGetLDC(hdc); + if (pldc) + { + if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc); + if (pldc->Flags & LDC_KILL_DOCUMENT) return NULL; + if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc); + return hdc; + } + SetLastError(ERROR_INVALID_HANDLE); + return NULL; +} + + /* * @implemented * @@ -481,6 +504,67 @@ GetCurrentObject( return NtGdiGetDCObject(hdc, uObjectType); } + +/* + * @implemented + */ +int +WINAPI +EnumObjects(HDC hdc, + int nObjectType, + GOBJENUMPROC lpObjectFunc, + LPARAM lParam) +{ + ULONG ObjectsCount; + ULONG Size; + PVOID Buffer = NULL; + DWORD_PTR EndOfBuffer; + int Result = 0; + + switch (nObjectType) + { + case OBJ_BRUSH: + Size = sizeof(LOGBRUSH); + break; + + case OBJ_PEN: + Size = sizeof(LOGPEN); + break; + + default: + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + ObjectsCount = NtGdiEnumObjects(hdc, nObjectType, 0, NULL); + if (!ObjectsCount) return 0; + + Buffer = HeapAlloc(GetProcessHeap(), 0, ObjectsCount * Size); + if (!Buffer) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + if (!NtGdiEnumObjects(hdc, nObjectType, ObjectsCount * Size, Buffer)) + { + HeapFree(GetProcessHeap(), 0, Buffer); + return 0; + } + + EndOfBuffer = (DWORD_PTR)Buffer + (ObjectsCount * Size); + while ((DWORD_PTR)Buffer < EndOfBuffer) + { + Result = lpObjectFunc(Buffer, lParam); + if (!Result) break; + Buffer = (PVOID)((DWORD_PTR)Buffer + Size); + } + + HeapFree(GetProcessHeap(), 0, Buffer); + return Result; +} + + /* * @implemented * @@ -769,198 +853,42 @@ GetAspectRatioFilterEx( /* * @implemented */ -BOOL +UINT WINAPI -GetDCOrgEx( - HDC hdc, - LPPOINT lpPoint) +GetBoundsRect( + HDC hdc, + LPRECT lprcBounds, + UINT flags +) { - return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); + return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET); } /* * @implemented */ -LONG +UINT WINAPI -GetDCOrg( - HDC hdc) +SetBoundsRect(HDC hdc, + CONST RECT *prc, + UINT flags) { - // Officially obsolete by Microsoft - POINT Pt; - if (!GetDCOrgEx(hdc, &Pt)) - return 0; - return(MAKELONG(Pt.x, Pt.y)); + /* FIXME add check for validate the flags */ + return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags); } /* * @implemented + * */ int WINAPI -GetObjectW( - _In_ HGDIOBJ hGdiObj, - _In_ int cbSize, - _Out_ LPVOID lpBuffer) +GetClipBox(HDC hdc, + LPRECT lprc) { - DWORD dwType; - INT cbResult = 0; - - /* Fixup handles with upper 16 bits masked */ - hGdiObj = GdiFixUpHandle(hGdiObj); - - /* Get the object type */ - dwType = GDI_HANDLE_GET_TYPE(hGdiObj); - - /* Check what kind of object we have */ - switch (dwType) - { - case GDI_OBJECT_TYPE_PEN: - if (!lpBuffer) return sizeof(LOGPEN); - break; - - case GDI_OBJECT_TYPE_BRUSH: - if (!lpBuffer || !cbSize) return sizeof(LOGBRUSH); - break; - - case GDI_OBJECT_TYPE_BITMAP: - if (!lpBuffer) return sizeof(BITMAP); - break; - - case GDI_OBJECT_TYPE_PALETTE: - if (!lpBuffer) return sizeof(WORD); - break; - - case GDI_OBJECT_TYPE_FONT: - if (!lpBuffer) return sizeof(LOGFONTW); - break; - - case GDI_OBJECT_TYPE_EXTPEN: - /* we don't know the size, ask win32k */ - break; - - case GDI_OBJECT_TYPE_COLORSPACE: - if ((cbSize < 328) || !lpBuffer) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return 0; - } - break; - - case GDI_OBJECT_TYPE_DC: - case GDI_OBJECT_TYPE_REGION: - case GDI_OBJECT_TYPE_EMF: - case GDI_OBJECT_TYPE_METAFILE: - case GDI_OBJECT_TYPE_ENHMETAFILE: - SetLastError(ERROR_INVALID_HANDLE); - default: - return 0; - } - - /* Call win32k */ - cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); - - /* Handle error */ - if (cbResult == 0) - { - if (!GdiIsHandleValid(hGdiObj)) - { - if ((dwType == GDI_OBJECT_TYPE_PEN) || - (dwType == GDI_OBJECT_TYPE_EXTPEN) || - (dwType == GDI_OBJECT_TYPE_BRUSH) || - (dwType == GDI_OBJECT_TYPE_COLORSPACE)) - { - SetLastError(ERROR_INVALID_PARAMETER); - } - } - else - { - if ((dwType == GDI_OBJECT_TYPE_PEN) || - (dwType == GDI_OBJECT_TYPE_BRUSH) || - (dwType == GDI_OBJECT_TYPE_COLORSPACE) || - ( (dwType == GDI_OBJECT_TYPE_EXTPEN) && - ( (cbSize >= sizeof(EXTLOGPEN)) || (cbSize == 0) ) ) || - ( (dwType == GDI_OBJECT_TYPE_BITMAP) && (cbSize >= sizeof(BITMAP)) )) - { - SetLastError(ERROR_NOACCESS); - } - } - } - - return cbResult; -} - - -ULONG -WINAPI -GetFontObjectA( - _In_ HGDIOBJ hfont, - _In_ ULONG cbSize, - _Out_ LPVOID lpBuffer) -{ - ENUMLOGFONTEXDVW elfedvW; - ENUMLOGFONTEXDVA elfedvA; - ULONG cbResult; - - /* Check if size only is requested */ - if (!lpBuffer) return sizeof(LOGFONTA); - - /* Check for size 0 */ - if (cbSize == 0) - { - /* Windows does not SetLastError() */ - return 0; - } - - /* Windows does this ... */ - if (cbSize == sizeof(LOGFONTW)) cbSize = sizeof(LOGFONTA); - - /* Call win32k to get the logfont (widechar) */ - cbResult = NtGdiExtGetObjectW(hfont, sizeof(ENUMLOGFONTEXDVW), &elfedvW); - if (cbResult == 0) - { - return 0; - } - - /* Convert the logfont from widechar to ansi */ - EnumLogFontExW2A(&elfedvA.elfEnumLogfontEx, &elfedvW.elfEnumLogfontEx); - elfedvA.elfDesignVector = elfedvW.elfDesignVector; - - /* Don't copy more than maximum */ - if (cbSize > sizeof(ENUMLOGFONTEXDVA)) cbSize = sizeof(ENUMLOGFONTEXDVA); - - /* Copy the number of bytes requested */ - memcpy(lpBuffer, &elfedvA, cbSize); - - /* Return the number of bytes copied */ - return cbSize; -} - - -/* - * @implemented - */ -int -WINAPI -GetObjectA( - _In_ HGDIOBJ hGdiObj, - _In_ int cbSize, - _Out_ LPVOID lpBuffer) -{ - DWORD dwType = GDI_HANDLE_GET_TYPE(hGdiObj); - - /* Chjeck if this is anything else but a font */ - if (dwType == GDI_OBJECT_TYPE_FONT) - { - return GetFontObjectA(hGdiObj, cbSize, lpBuffer); - } - else - { - /* Simply pass it to the widechar version */ - return GetObjectW(hGdiObj, cbSize, lpBuffer); - } + return NtGdiGetAppClipBox(hdc, lprc); } @@ -1402,109 +1330,6 @@ ResetDCA( } -/* - * @implemented - */ -DWORD -WINAPI -GetObjectType( - HGDIOBJ h) -{ - DWORD Ret = 0; - - if (GdiIsHandleValid(h)) - { - LONG Type = GDI_HANDLE_GET_TYPE(h); - switch(Type) - { - case GDI_OBJECT_TYPE_PEN: - Ret = OBJ_PEN; - break; - case GDI_OBJECT_TYPE_BRUSH: - Ret = OBJ_BRUSH; - break; - case GDI_OBJECT_TYPE_BITMAP: - Ret = OBJ_BITMAP; - break; - case GDI_OBJECT_TYPE_FONT: - Ret = OBJ_FONT; - break; - case GDI_OBJECT_TYPE_PALETTE: - Ret = OBJ_PAL; - break; - case GDI_OBJECT_TYPE_REGION: - Ret = OBJ_REGION; - break; - case GDI_OBJECT_TYPE_DC: - if ( GetDCDWord( h, GdiGetIsMemDc, 0)) - { - Ret = OBJ_MEMDC; - } - else - Ret = OBJ_DC; - break; - case GDI_OBJECT_TYPE_COLORSPACE: - Ret = OBJ_COLORSPACE; - break; - case GDI_OBJECT_TYPE_METAFILE: - Ret = OBJ_METAFILE; - break; - case GDI_OBJECT_TYPE_ENHMETAFILE: - Ret = OBJ_ENHMETAFILE; - break; - case GDI_OBJECT_TYPE_METADC: - Ret = OBJ_METADC; - break; - case GDI_OBJECT_TYPE_EXTPEN: - Ret = OBJ_EXTPEN; - break; - - case GDILoObjType_LO_ALTDC_TYPE: - // FIXME: could be something else? - Ret = OBJ_ENHMETADC; - break; - - default: - DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type); - break; - } - } - else - /* From Wine: GetObjectType does SetLastError() on a null object */ - SetLastError(ERROR_INVALID_HANDLE); - return Ret; -} - - -/* - * @implemented - */ -HGDIOBJ -WINAPI -GetStockObject( - INT fnObject) -{ - HGDIOBJ hobj; - - if ((fnObject < 0) || (fnObject >= NB_STOCK_OBJECTS)) - return NULL; - - hobj = stock_objects[fnObject]; - if (hobj == NULL) - { - hobj = NtGdiGetStockObject(fnObject); - - if (!GdiIsHandleValid(hobj)) - { - return NULL; - } - - stock_objects[fnObject] = hobj; - } - - return hobj; -} - /* FIXME: include correct header */ HPALETTE WINAPI NtUserSelectPalette(HDC hDC, HPALETTE hpal, @@ -1540,68 +1365,6 @@ SelectPalette( return NtUserSelectPalette(hdc, hpal, bForceBackground); } -/* - * @implemented - * - */ -int -WINAPI -GetMapMode(HDC hdc) -{ - PDC_ATTR pdcattr; - - /* Get the DC attribute */ - pdcattr = GdiGetDcAttr(hdc); - if (pdcattr == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - return pdcattr->iMapMode; -} - -/* - * @implemented - */ -INT -WINAPI -SetMapMode( - _In_ HDC hdc, - _In_ INT iMode) -{ - PDC_ATTR pdcattr; - - /* Get the DC attribute */ - pdcattr = GdiGetDcAttr(hdc); - if (pdcattr == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - -#if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetMapMode(hdc, iMode); - else - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - } -#endif - /* Force change if Isotropic is set for recompute. */ - if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC)) - { - pdcattr->ulDirty_ &= ~SLOW_WIDTHS; - return GetAndSetDCDWord( hdc, GdiGetSetMapMode, iMode, 0, 0, 0 ); - } - - return pdcattr->iMapMode; -} - /* * @implemented * @@ -1695,6 +1458,7 @@ GetHFONT(HDC hdc) } + HBITMAP WINAPI GdiSelectBitmap( @@ -1854,3 +1618,4 @@ SelectObject( return NULL; } + diff --git a/reactos/win32ss/gdi/gdi32/objects/eng.c b/reactos/win32ss/gdi/gdi32/objects/eng.c index fbdaa58ce30..47852673564 100644 --- a/reactos/win32ss/gdi/gdi32/objects/eng.c +++ b/reactos/win32ss/gdi/gdi32/objects/eng.c @@ -237,9 +237,6 @@ EngReleaseSemaphore ( IN HSEMAPHORE hsem ) RtlLeaveCriticalSection( (PRTL_CRITICAL_SECTION) hsem); } - - - /* * @implemented */ @@ -254,3 +251,14 @@ EngWideCharToMultiByte( UINT CodePage, return WideCharToMultiByte(CodePage, 0, WideCharString, (BytesInWideCharString/sizeof(WCHAR)), MultiByteString, BytesInMultiByteString, NULL, NULL); } + +/* + * @unimplemented + */ +ULONG * +WINAPI +XLATEOBJ_piVector(XLATEOBJ *XlateObj) +{ + return XlateObj->pulXlate; +} + diff --git a/reactos/win32ss/gdi/gdi32/objects/enhmfile.c b/reactos/win32ss/gdi/gdi32/objects/enhmfile.c index 45ed4f28e5e..e44a61ce82c 100644 --- a/reactos/win32ss/gdi/gdi32/objects/enhmfile.c +++ b/reactos/win32ss/gdi/gdi32/objects/enhmfile.c @@ -551,3 +551,253 @@ CreateEnhMetaFileW( UNIMPLEMENTED; return 0; } + +/* + * @unimplemented + */ +BOOL +WINAPI +DeleteEnhMetaFile( + HENHMETAFILE a0 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +EnumEnhMetaFile( + HDC hdc, + HENHMETAFILE hmf, + ENHMFENUMPROC callback, + LPVOID data, + CONST RECT *lpRect +) +{ + if(!lpRect && hdc) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetEnhMetaFileBits( + HENHMETAFILE a0, + UINT a1, + LPBYTE a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HENHMETAFILE +WINAPI +SetEnhMetaFileBits( + UINT a0, + CONST BYTE *a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetEnhMetaFileHeader( + HENHMETAFILE a0, + UINT a1, + LPENHMETAHEADER a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetEnhMetaFilePaletteEntries( + HENHMETAFILE a0, + UINT a1, + LPPALETTEENTRY a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +PlayEnhMetaFile( + HDC a0, + HENHMETAFILE a1, + CONST RECT *a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +PlayEnhMetaFileRecord( + HDC a0, + LPHANDLETABLE a1, + CONST ENHMETARECORD *a2, + UINT a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +DWORD +WINAPI +IsValidEnhMetaRecord( + DWORD a0, + DWORD a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; + +} + +/* + * @unimplemented + */ +DWORD +WINAPI +IsValidEnhMetaRecordOffExt( + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; + +} + +/* + * @unimplemented + */ +HENHMETAFILE +WINAPI +GdiConvertEnhMetaFile(HENHMETAFILE hmf) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HENHMETAFILE +WINAPI +GdiCreateLocalEnhMetaFile(HENHMETAFILE hmo) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiComment( + HDC hDC, + UINT bytes, + CONST BYTE *buffer +) +{ +#if 0 + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_EMF) + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (pLDC->iType == LDC_EMFLDC) + { + // Wine port + return EMFDRV_GdiComment( hDC, bytes, buffer ); + } + } +#endif + return FALSE; +} + +/* + * @implemented + */ +UINT +WINAPI +GetEnhMetaFilePixelFormat( + HENHMETAFILE hemf, + UINT cbBuffer, + PIXELFORMATDESCRIPTOR *ppfd +) +{ + ENHMETAHEADER pemh; + + if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh)) + { + if(pemh.bOpenGL) + { + if(pemh.cbPixelFormat) + { + memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer ); + return(pemh.cbPixelFormat); + } + } + } + return(0); +} diff --git a/reactos/win32ss/gdi/gdi32/objects/font.c b/reactos/win32ss/gdi/gdi32/objects/font.c index d580e5f3085..42250057be2 100644 --- a/reactos/win32ss/gdi/gdi32/objects/font.c +++ b/reactos/win32ss/gdi/gdi32/objects/font.c @@ -1039,6 +1039,25 @@ GetGlyphOutlineW( return NtGdiGetGlyphOutline ( hdc, uChar, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE); } +/* + * @unimplemented + */ +DWORD +WINAPI +GetGlyphOutlineWow( + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3, + DWORD a4, + DWORD a5, + DWORD a6 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} /* * @implemented @@ -2160,3 +2179,243 @@ NewEnumFontFamiliesExW( return ret; } + +/* + * @unimplemented + */ +int +WINAPI +GdiAddFontResourceW( + LPCWSTR lpszFilename, + FLONG fl, + DESIGNVECTOR *pdv) +{ + return NtGdiAddFontResourceW((PWSTR)lpszFilename, 0, 0, fl, 0, pdv); +} + +/* + * @implemented + */ +HANDLE +WINAPI +AddFontMemResourceEx( + PVOID pbFont, + DWORD cbFont, + PVOID pdv, + DWORD *pcFonts +) +{ + if ( pbFont && cbFont && pcFonts) + { + return NtGdiAddFontMemResourceEx(pbFont, cbFont, NULL, 0, pcFonts); + } + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; +} + +/* + * @implemented + */ +BOOL +WINAPI +RemoveFontMemResourceEx(HANDLE fh) +{ + if (fh) + { + return NtGdiRemoveFontMemResourceEx(fh); + } + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; +} + + +/* + * @unimplemented + */ +int +WINAPI +AddFontResourceTracking( + LPCSTR lpString, + int unknown +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +int +WINAPI +RemoveFontResourceTracking(LPCSTR lpString,int unknown) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +BOOL +WINAPI +CreateScalableFontResourceW( + DWORD fdwHidden, + LPCWSTR lpszFontRes, + LPCWSTR lpszFontFile, + LPCWSTR lpszCurrentPath +) +{ + HANDLE f; + + UNIMPLEMENTED; + + /* fHidden=1 - only visible for the calling app, read-only, not + * enumerated with EnumFonts/EnumFontFamilies + * lpszCurrentPath can be NULL + */ + + /* If the output file already exists, return the ERROR_FILE_EXISTS error as specified in MSDN */ + if ((f = CreateFileW(lpszFontRes, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) + { + CloseHandle(f); + SetLastError(ERROR_FILE_EXISTS); + return FALSE; + } + return FALSE; /* create failed */ +} + +/* + * @unimplemented + */ +BOOL +WINAPI +bInitSystemAndFontsDirectoriesW(LPWSTR *SystemDir,LPWSTR *FontsDir) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +EudcLoadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath,INT iPriority,INT iFontLinkType) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +EudcUnloadLinkW(LPCWSTR pBaseFaceName,LPCWSTR pEudcFontPath) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @implemented + */ +ULONG +WINAPI +GetEUDCTimeStamp(VOID) +{ + return NtGdiGetEudcTimeStampEx(NULL,0,TRUE); +} + +/* + * @implemented + */ +DWORD +WINAPI +GetEUDCTimeStampExW(LPWSTR lpBaseFaceName) +{ + DWORD retValue = 0; + + if (!lpBaseFaceName) + { + retValue = NtGdiGetEudcTimeStampEx(NULL,0,FALSE); + } + else + { + retValue = NtGdiGetEudcTimeStampEx(lpBaseFaceName, wcslen(lpBaseFaceName), FALSE); + } + + return retValue; +} + +/* + * @implemented + */ +ULONG +WINAPI +GetFontAssocStatus(HDC hdc) +{ + ULONG retValue = 0; + + if (hdc) + { + retValue = NtGdiQueryFontAssocInfo(hdc); + } + + return retValue; +} + +/* + * @unimplemented + */ +DWORD +WINAPI +QueryFontAssocStatus(VOID) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +VOID +WINAPI +UnloadNetworkFonts(DWORD unknown) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); +} + +/* + * @implemented + * + */ +DWORD +WINAPI +GetFontData(HDC hdc, + DWORD dwTable, + DWORD dwOffset, + LPVOID lpvBuffer, + DWORD cbData) +{ + if (!lpvBuffer) + { + cbData = 0; + } + return NtGdiGetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData); +} + +DWORD +WINAPI +cGetTTFFromFOT(DWORD x1 ,DWORD x2 ,DWORD x3, DWORD x4, DWORD x5, DWORD x6, DWORD x7) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + diff --git a/reactos/win32ss/gdi/gdi32/objects/gdiobj.c b/reactos/win32ss/gdi/gdi32/objects/gdiobj.c new file mode 100644 index 00000000000..9343625465b --- /dev/null +++ b/reactos/win32ss/gdi/gdi32/objects/gdiobj.c @@ -0,0 +1,362 @@ +#include + +#define NDEBUG +#include + +HGDIOBJ stock_objects[NB_STOCK_OBJECTS]; + +/* + * @implemented + */ +HGDIOBJ +WINAPI +GetStockObject( + INT fnObject) +{ + HGDIOBJ hobj; + + if ((fnObject < 0) || (fnObject >= NB_STOCK_OBJECTS)) + return NULL; + + hobj = stock_objects[fnObject]; + if (hobj == NULL) + { + hobj = NtGdiGetStockObject(fnObject); + + if (!GdiIsHandleValid(hobj)) + { + return NULL; + } + + stock_objects[fnObject] = hobj; + } + + return hobj; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetObjectType( + HGDIOBJ h) +{ + DWORD Ret = 0; + + if (GdiIsHandleValid(h)) + { + LONG Type = GDI_HANDLE_GET_TYPE(h); + switch(Type) + { + case GDI_OBJECT_TYPE_PEN: + Ret = OBJ_PEN; + break; + case GDI_OBJECT_TYPE_BRUSH: + Ret = OBJ_BRUSH; + break; + case GDI_OBJECT_TYPE_BITMAP: + Ret = OBJ_BITMAP; + break; + case GDI_OBJECT_TYPE_FONT: + Ret = OBJ_FONT; + break; + case GDI_OBJECT_TYPE_PALETTE: + Ret = OBJ_PAL; + break; + case GDI_OBJECT_TYPE_REGION: + Ret = OBJ_REGION; + break; + case GDI_OBJECT_TYPE_DC: + if ( GetDCDWord( h, GdiGetIsMemDc, 0)) + { + Ret = OBJ_MEMDC; + } + else + Ret = OBJ_DC; + break; + case GDI_OBJECT_TYPE_COLORSPACE: + Ret = OBJ_COLORSPACE; + break; + case GDI_OBJECT_TYPE_METAFILE: + Ret = OBJ_METAFILE; + break; + case GDI_OBJECT_TYPE_ENHMETAFILE: + Ret = OBJ_ENHMETAFILE; + break; + case GDI_OBJECT_TYPE_METADC: + Ret = OBJ_METADC; + break; + case GDI_OBJECT_TYPE_EXTPEN: + Ret = OBJ_EXTPEN; + break; + + case GDILoObjType_LO_ALTDC_TYPE: + // FIXME: could be something else? + Ret = OBJ_ENHMETADC; + break; + + default: + DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type); + break; + } + } + else + /* From Wine: GetObjectType does SetLastError() on a null object */ + SetLastError(ERROR_INVALID_HANDLE); + return Ret; +} + +ULONG +WINAPI +GetFontObjectA( + _In_ HGDIOBJ hfont, + _In_ ULONG cbSize, + _Out_ LPVOID lpBuffer) +{ + ENUMLOGFONTEXDVW elfedvW; + ENUMLOGFONTEXDVA elfedvA; + ULONG cbResult; + + /* Check if size only is requested */ + if (!lpBuffer) return sizeof(LOGFONTA); + + /* Check for size 0 */ + if (cbSize == 0) + { + /* Windows does not SetLastError() */ + return 0; + } + + /* Windows does this ... */ + if (cbSize == sizeof(LOGFONTW)) cbSize = sizeof(LOGFONTA); + + /* Call win32k to get the logfont (widechar) */ + cbResult = NtGdiExtGetObjectW(hfont, sizeof(ENUMLOGFONTEXDVW), &elfedvW); + if (cbResult == 0) + { + return 0; + } + + /* Convert the logfont from widechar to ansi */ + EnumLogFontExW2A(&elfedvA.elfEnumLogfontEx, &elfedvW.elfEnumLogfontEx); + elfedvA.elfDesignVector = elfedvW.elfDesignVector; + + /* Don't copy more than maximum */ + if (cbSize > sizeof(ENUMLOGFONTEXDVA)) cbSize = sizeof(ENUMLOGFONTEXDVA); + + /* Copy the number of bytes requested */ + memcpy(lpBuffer, &elfedvA, cbSize); + + /* Return the number of bytes copied */ + return cbSize; +} + + +/* + * @implemented + */ +int +WINAPI +GetObjectA( + _In_ HGDIOBJ hGdiObj, + _In_ int cbSize, + _Out_ LPVOID lpBuffer) +{ + DWORD dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + + /* Chjeck if this is anything else but a font */ + if (dwType == GDI_OBJECT_TYPE_FONT) + { + return GetFontObjectA(hGdiObj, cbSize, lpBuffer); + } + else + { + /* Simply pass it to the widechar version */ + return GetObjectW(hGdiObj, cbSize, lpBuffer); + } +} + + +/* + * @implemented + */ +int +WINAPI +GetObjectW( + _In_ HGDIOBJ hGdiObj, + _In_ int cbSize, + _Out_ LPVOID lpBuffer) +{ + DWORD dwType; + INT cbResult = 0; + + /* Fixup handles with upper 16 bits masked */ + hGdiObj = GdiFixUpHandle(hGdiObj); + + /* Get the object type */ + dwType = GDI_HANDLE_GET_TYPE(hGdiObj); + + /* Check what kind of object we have */ + switch (dwType) + { + case GDI_OBJECT_TYPE_PEN: + if (!lpBuffer) return sizeof(LOGPEN); + break; + + case GDI_OBJECT_TYPE_BRUSH: + if (!lpBuffer || !cbSize) return sizeof(LOGBRUSH); + break; + + case GDI_OBJECT_TYPE_BITMAP: + if (!lpBuffer) return sizeof(BITMAP); + break; + + case GDI_OBJECT_TYPE_PALETTE: + if (!lpBuffer) return sizeof(WORD); + break; + + case GDI_OBJECT_TYPE_FONT: + if (!lpBuffer) return sizeof(LOGFONTW); + break; + + case GDI_OBJECT_TYPE_EXTPEN: + /* we don't know the size, ask win32k */ + break; + + case GDI_OBJECT_TYPE_COLORSPACE: + if ((cbSize < 328) || !lpBuffer) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return 0; + } + break; + + case GDI_OBJECT_TYPE_DC: + case GDI_OBJECT_TYPE_REGION: + case GDI_OBJECT_TYPE_EMF: + case GDI_OBJECT_TYPE_METAFILE: + case GDI_OBJECT_TYPE_ENHMETAFILE: + SetLastError(ERROR_INVALID_HANDLE); + default: + return 0; + } + + /* Call win32k */ + cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); + + /* Handle error */ + if (cbResult == 0) + { + if (!GdiIsHandleValid(hGdiObj)) + { + if ((dwType == GDI_OBJECT_TYPE_PEN) || + (dwType == GDI_OBJECT_TYPE_EXTPEN) || + (dwType == GDI_OBJECT_TYPE_BRUSH) || + (dwType == GDI_OBJECT_TYPE_COLORSPACE)) + { + SetLastError(ERROR_INVALID_PARAMETER); + } + } + else + { + if ((dwType == GDI_OBJECT_TYPE_PEN) || + (dwType == GDI_OBJECT_TYPE_BRUSH) || + (dwType == GDI_OBJECT_TYPE_COLORSPACE) || + ( (dwType == GDI_OBJECT_TYPE_EXTPEN) && + ( (cbSize >= sizeof(EXTLOGPEN)) || (cbSize == 0) ) ) || + ( (dwType == GDI_OBJECT_TYPE_BITMAP) && (cbSize >= sizeof(BITMAP)) )) + { + SetLastError(ERROR_NOACCESS); + } + } + } + + return cbResult; +} + + +/* + * @implemented + */ +BOOL +WINAPI +DeleteObject(HGDIOBJ hObject) +{ + DWORD dwType = 0; + + /* From Wine: DeleteObject does not SetLastError() on a null object */ + if(!hObject) return FALSE; + + if ((DWORD)hObject & GDI_HANDLE_STOCK_MASK) + { + // Relax! This is a normal return! + DPRINT("Trying to delete system object 0x%p\n", hObject); + return TRUE; + } + + // If you dont own it?! Get OUT! + if(!GdiIsHandleValid(hObject)) return FALSE; + + dwType = GDI_HANDLE_GET_TYPE(hObject); + + if ((dwType == GDI_OBJECT_TYPE_METAFILE) || + (dwType == GDI_OBJECT_TYPE_ENHMETAFILE)) + return FALSE; + + switch (dwType) + { + case GDI_OBJECT_TYPE_DC: + return DeleteDC((HDC) hObject); + case GDI_OBJECT_TYPE_COLORSPACE: + return NtGdiDeleteColorSpace((HCOLORSPACE) hObject); + case GDI_OBJECT_TYPE_REGION: + return DeleteRegion((HRGN) hObject); +#if 0 + case GDI_OBJECT_TYPE_METADC: + return MFDRV_DeleteObject( hObject ); + case GDI_OBJECT_TYPE_EMF: + { + PLDC pLDC = GdiGetLDC(hObject); + if ( !pLDC ) return FALSE; + return EMFDRV_DeleteObject( hObject ); + } +#endif + case GDI_OBJECT_TYPE_FONT: + break; + + case GDI_OBJECT_TYPE_BRUSH: + case GDI_OBJECT_TYPE_EXTPEN: + case GDI_OBJECT_TYPE_PEN: + { + PBRUSH_ATTR Brh_Attr; + PTEB pTeb; + PGDIBSOBJECT pgO; + + if ((!GdiGetHandleUserData(hObject, dwType, (PVOID*)&Brh_Attr)) || + (Brh_Attr == NULL)) break; + + pTeb = NtCurrentTeb(); + + if (pTeb->Win32ThreadInfo == NULL) break; + + pgO = GdiAllocBatchCommand(NULL, GdiBCDelObj); + if (pgO) + { + pgO->hgdiobj = hObject; + return TRUE; + } + + break; + } + + case GDI_OBJECT_TYPE_BITMAP: + default: + break; + } + + return NtGdiDeleteObjectApp(hObject); +} + + diff --git a/reactos/win32ss/gdi/gdi32/objects/icm.c b/reactos/win32ss/gdi/gdi32/objects/icm.c index 708086699b1..e6c2fbdf887 100644 --- a/reactos/win32ss/gdi/gdi32/objects/icm.c +++ b/reactos/win32ss/gdi/gdi32/objects/icm.c @@ -128,3 +128,195 @@ SetColorSpace( return NULL; } + +/* + * @unimplemented + */ +BOOL +WINAPI +GetICMProfileA( + HDC hdc, + LPDWORD pBufSize, + LPSTR pszFilename +) +{ + WCHAR filenameW[MAX_PATH]; + DWORD buflen = MAX_PATH; + BOOL ret = FALSE; + + if (!hdc || !pBufSize || !pszFilename) return FALSE; + + if (GetICMProfileW(hdc, &buflen, filenameW)) + { + ULONG len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL); + if (*pBufSize >= len) + { + WideCharToMultiByte(CP_ACP, 0, filenameW, -1, pszFilename, *pBufSize, NULL, NULL); + ret = TRUE; + } + else SetLastError(ERROR_INSUFFICIENT_BUFFER); + *pBufSize = len; + } + + return ret; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +GetICMProfileW( + HDC hdc, + LPDWORD size, + LPWSTR filename +) +{ + if (!hdc || !size || !filename) return FALSE; + + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +SetICMProfileA( + HDC a0, + LPSTR a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +SetICMProfileW( + HDC a0, + LPWSTR a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +int +WINAPI +EnumICMProfilesA( + HDC a0, + ICMENUMPROCA a1, + LPARAM a2 +) +{ + /* + * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer + * to find out how big a buffer we need. Then allocate that buffer + * and call NtGdiEnumICMProfiles again to have the buffer filled. + * + * Finally, step through the buffer ( MULTI-SZ recommended for format ), + * and convert each string to ANSI, calling the user's callback function + * until we run out of strings or the user returns FALSE + */ + + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/* + * @unimplemented + */ +int +WINAPI +EnumICMProfilesW( + HDC hDC, + ICMENUMPROCW lpEnumICMProfilesFunc, + LPARAM lParam +) +{ + /* + * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer + * to find out how big a buffer we need. Then allocate that buffer + * and call NtGdiEnumICMProfiles again to have the buffer filled. + * + * Finally, step through the buffer ( MULTI-SZ recommended for format ), + * and call the user's callback function until we run out of strings or + * the user returns FALSE + */ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +UpdateICMRegKeyA( + DWORD a0, + LPSTR a1, + LPSTR a2, + UINT a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +UpdateICMRegKeyW( + DWORD a0, + LPWSTR a1, + LPWSTR a2, + UINT a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +int +WINAPI +SetICMMode( + HDC hdc, + int iEnableICM +) +{ + /*FIXME: Assume that ICM is always off, and cannot be turned on */ + if (iEnableICM == ICM_OFF) return ICM_OFF; + if (iEnableICM == ICM_ON) return 0; + if (iEnableICM == ICM_QUERY) return ICM_OFF; + + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} diff --git a/reactos/win32ss/gdi/gdi32/objects/metafile.c b/reactos/win32ss/gdi/gdi32/objects/metafile.c index 410d50e458e..c75bca8f491 100644 --- a/reactos/win32ss/gdi/gdi32/objects/metafile.c +++ b/reactos/win32ss/gdi/gdi32/objects/metafile.c @@ -1,4 +1,5 @@ #include +#include /* DEFINES *******************************************************************/ @@ -271,3 +272,219 @@ GetMetaFileA( } +/* + * @unimplemented + */ +UINT +WINAPI +GetMetaFileBitsEx( + HMETAFILE a0, + UINT a1, + LPVOID a2 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HMETAFILE +WINAPI +SetMetaFileBitsEx( + UINT size, + CONST BYTE *lpData +) +{ + const METAHEADER *mh_in = (const METAHEADER *)lpData; + + if (size & 1) return 0; + + if (!size || mh_in->mtType != METAFILE_MEMORY || mh_in->mtVersion != 0x300 || + mh_in->mtHeaderSize != sizeof(METAHEADER) / 2) + { + DPRINT1("SetMetaFileBitsEx failed: %lu,%lu,0x&lx,%lu\n", + size, mh_in->mtType, mh_in->mtVersion, mh_in->mtHeaderSize); + SetLastError(ERROR_INVALID_DATA); + return 0; + } + + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @implemented + */ +BOOL +WINAPI +GdiIsPlayMetafileDC(HDC hDC) +{ + PLDC pLDC = GdiGetLDC(hDC); + if ( pLDC ) + { + if ( pLDC->Flags & LDC_PLAY_MFDC ) return TRUE; + } + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +PlayMetaFile( + HDC a0, + HMETAFILE a1 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +PlayMetaFileRecord( + HDC a0, + LPHANDLETABLE a1, + LPMETARECORD a2, + UINT a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +EnumMetaFile( + HDC a0, + HMETAFILE a1, + MFENUMPROC a2, + LPARAM a3 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/* + * @unimplemented + */ +UINT +WINAPI +GetWinMetaFileBits( + HENHMETAFILE a0, + UINT a1, + LPBYTE a2, + INT a3, + HDC a4 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HENHMETAFILE +WINAPI +SetWinMetaFileBits( + UINT a0, + CONST BYTE *a1, + HDC a2, + CONST METAFILEPICT *a3) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @implemented + */ +BOOL +WINAPI +GdiIsMetaFileDC(HDC hDC) +{ + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return TRUE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if ( pLDC->iType == LDC_EMFLDC) return TRUE; + } + } + return FALSE; +} + +/* + * @implemented + */ +BOOL +WINAPI +GdiIsMetaPrintDC(HDC hDC) +{ + + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return FALSE; + else + { + PLDC pLDC = GdiGetLDC(hDC); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if ( pLDC->Flags & LDC_META_PRINT) return TRUE; + } + } + return FALSE; +} + +/* + * @unimplemented + */ +METAFILEPICT * +WINAPI +GdiCreateLocalMetaFilePict(HENHMETAFILE hmo) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HANDLE +WINAPI +GdiConvertMetaFilePict(HGLOBAL hMem) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} diff --git a/reactos/win32ss/gdi/gdi32/objects/painting.c b/reactos/win32ss/gdi/gdi32/objects/painting.c index 169f436080e..24c7ecd6f8c 100644 --- a/reactos/win32ss/gdi/gdi32/objects/painting.c +++ b/reactos/win32ss/gdi/gdi32/objects/painting.c @@ -709,6 +709,62 @@ FloodFill( return ExtFloodFill(hDC, nXStart, nYStart, crFill, FLOODFILLBORDER); } +/* + * @implemented + */ +BOOL +WINAPI +BitBlt( + HDC hdcDest, /* handle to destination DC */ + int nXOriginDest, /* x-coord of destination upper-left corner */ + int nYOriginDest, /* y-coord of destination upper-left corner */ + int nWidthDest, /* width of destination rectangle */ + int nHeightDest, /* height of destination rectangle */ + HDC hdcSrc, /* handle to source DC */ + int nXSrc, /* x-coordinate of source upper-left corner */ + int nYSrc, /* y-coordinate of source upper-left corner */ + DWORD dwRop) /* raster operation code */ +{ + /* use patBlt for no source blt Like windows does */ + if (!ROP_USES_SOURCE(dwRop)) + { + return PatBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop); + } + + return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXSrc, + nYSrc, dwRop, 0, 0); +} + + +/* + * @implemented + */ +BOOL +WINAPI +StretchBlt( + HDC hdcDest, /* handle to destination DC */ + int nXOriginDest, /* x-coord of destination upper-left corner */ + int nYOriginDest, /* y-coord of destination upper-left corner */ + int nWidthDest, /* width of destination rectangle */ + int nHeightDest, /* height of destination rectangle */ + HDC hdcSrc, /* handle to source DC */ + int nXOriginSrc, /* x-coord of source upper-left corner */ + int nYOriginSrc, /* y-coord of source upper-left corner */ + int nWidthSrc, /* width of source rectangle */ + int nHeightSrc, /* height of source rectangle */ + DWORD dwRop) /* raster operation code */ + +{ + if ((nWidthDest != nWidthSrc) || (nHeightDest != nHeightSrc)) + { + return NtGdiStretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, + nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop, 0); + } + + return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, + nXOriginSrc, nYOriginSrc, dwRop, 0, 0); +} + /* * @implemented @@ -773,3 +829,77 @@ PlgBlt( yMask, GetBkColor(hdcSrc)); } + +BOOL +WINAPI +GdiAlphaBlend( + HDC hDCDst, + int DstX, + int DstY, + int DstCx, + int DstCy, + HDC hDCSrc, + int SrcX, + int SrcY, + int SrcCx, + int SrcCy, + BLENDFUNCTION BlendFunction) +{ + if ( hDCSrc == NULL ) return FALSE; + + if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE; + + return NtGdiAlphaBlend( + hDCDst, + DstX, + DstY, + DstCx, + DstCy, + hDCSrc, + SrcX, + SrcY, + SrcCx, + SrcCy, + BlendFunction, + 0 ); +} + + +/* + * @implemented + */ +BOOL +WINAPI +GdiTransparentBlt(IN HDC hdcDst, + IN INT xDst, + IN INT yDst, + IN INT cxDst, + IN INT cyDst, + IN HDC hdcSrc, + IN INT xSrc, + IN INT ySrc, + IN INT cxSrc, + IN INT cySrc, + IN UINT TransColor + ) +{ + /* FIXME some part need be done in user mode */ + return NtGdiTransparentBlt(hdcDst, xDst, yDst, cxDst, cyDst, hdcSrc, xSrc, ySrc, cxSrc, cySrc, (COLORREF)TransColor); +} + +/* + * @implemented + */ +BOOL +WINAPI +GdiGradientFill( + IN HDC hdc, + IN PTRIVERTEX pVertex, + IN ULONG nVertex, + IN PVOID pMesh, + IN ULONG nMesh, + IN ULONG ulMode) +{ + /* FIXME some part need be done in user mode */ + return NtGdiGradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode); +} diff --git a/reactos/win32ss/gdi/gdi32/objects/palette.c b/reactos/win32ss/gdi/gdi32/objects/palette.c index d8856e004da..81202ef8d5e 100644 --- a/reactos/win32ss/gdi/gdi32/objects/palette.c +++ b/reactos/win32ss/gdi/gdi32/objects/palette.c @@ -202,4 +202,16 @@ UpdateColors( return NtGdiUpdateColors(hdc); } +/* + * @unimplemented + */ +BOOL +WINAPI +ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + /* EOF */ diff --git a/reactos/win32ss/gdi/gdi32/objects/printdrv.c b/reactos/win32ss/gdi/gdi32/objects/printdrv.c index d1276648bf8..067a427e702 100644 --- a/reactos/win32ss/gdi/gdi32/objects/printdrv.c +++ b/reactos/win32ss/gdi/gdi32/objects/printdrv.c @@ -691,6 +691,17 @@ StartPage( return SP_ERROR; } +/* + * @implemented + */ +int +WINAPI +StartFormPage(HDC hdc) +{ + return StartPage(hdc); +} + + /* * @implemented */ @@ -731,3 +742,203 @@ SetAbortProc( return SP_ERROR; } +/* + * @unimplemented + */ +DWORD +WINAPI +gdiPlaySpoolStream( + DWORD a0, + DWORD a1, + DWORD a2, + DWORD a3, + DWORD a4, + DWORD a5 +) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HDC +WINAPI +GdiGetDC(HANDLE SpoolFileHandle) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +HANDLE +WINAPI +GdiGetPageHandle(HANDLE SpoolFileHandle, + DWORD Page, + LPDWORD pdwPageType) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiStartDocEMF(HANDLE SpoolFileHandle, + DOCINFOW *pDocInfo) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiStartPageEMF(HANDLE SpoolFileHandle) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiPlayPageEMF(HANDLE SpoolFileHandle, + HANDLE hemf, + RECT *prectDocument, + RECT *prectBorder, + RECT *prectClip) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiEndPageEMF(HANDLE SpoolFileHandle, + DWORD dwOptimization) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiEndDocEMF(HANDLE SpoolFileHandle) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiGetDevmodeForPage(HANDLE SpoolFileHandle, + DWORD dwPageNumber, + PDEVMODEW *pCurrDM, + PDEVMODEW *pLastDM) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiResetDCEMF(HANDLE SpoolFileHandle, + PDEVMODEW pCurrDM) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiPlayEMF(LPWSTR pwszPrinterName, + LPDEVMODEW pDevmode, + LPWSTR pwszDocName, + EMFPLAYPROC pfnEMFPlayFn, + HANDLE hPageQuery + ) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiPlayPrivatePageEMF(HANDLE SpoolFileHandle, + DWORD unknown, + RECT *prectDocument) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiPrinterThunk( + IN HUMPD humpd, + DWORD *status, + DWORD unuse) +{ + /* FIXME figout the protypes, the HUMPD are a STRUCT or COM object */ + /* status contain some form of return value that being save, what it is I do not known */ + /* unsue seam have zero effect, what it is for I do not known */ + + // ? return NtGdiSetPUMPDOBJ(humpd->0x10,TRUE, humpd, ?) <- blackbox, OpenRCE info, and api hooks for anylaysing; + return FALSE; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +GdiArtificialDecrementDriver(LPWSTR pDriverName,BOOL unknown) +{ + UNIMPLEMENTED; + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} diff --git a/reactos/win32ss/gdi/gdi32/objects/text.c b/reactos/win32ss/gdi/gdi32/objects/text.c index 68af7c6db78..e7b7b85de7e 100644 --- a/reactos/win32ss/gdi/gdi32/objects/text.c +++ b/reactos/win32ss/gdi/gdi32/objects/text.c @@ -49,6 +49,34 @@ TextOutW( } +/* + * @unimplemented + */ +BOOL +WINAPI +PolyTextOutA( HDC hdc, const POLYTEXTA *pptxt, INT cStrings ) +{ + for (; cStrings>0; cStrings--, pptxt++) + if (!ExtTextOutA( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) + return FALSE; + return TRUE; +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +PolyTextOutW( HDC hdc, const POLYTEXTW *pptxt, INT cStrings ) +{ + for (; cStrings>0; cStrings--, pptxt++) + if (!ExtTextOutW( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx )) + return FALSE; + return TRUE; +} + + /* * @implemented */ @@ -205,6 +233,22 @@ GetTextExtentExPointW( } +/* + * @implemented + */ +BOOL +WINAPI +GetTextExtentExPointWPri(HDC hdc, + LPWSTR lpwsz, + ULONG cwc, + ULONG dxMax, + ULONG *pcCh, + PULONG pdxOut, + LPSIZE psize) +{ + return NtGdiGetTextExtentExW(hdc,lpwsz,cwc,dxMax,pcCh,pdxOut,psize,0); +} + /* * @implemented */ @@ -688,3 +732,75 @@ SetTextJustification( Dc_Attr->lBreakExtra = extra; return TRUE; } + +/* + * @implemented + */ +UINT +WINAPI +GetStringBitmapA(HDC hdc, + LPSTR psz, + BOOL DoCall, + UINT cj, + BYTE *lpSB) +{ + + NTSTATUS Status; + PWSTR pwsz; + UINT retValue = 0; + + if (DoCall) + { + Status = HEAP_strdupA2W ( &pwsz, psz ); + if ( !NT_SUCCESS (Status) ) + { + SetLastError (RtlNtStatusToDosError(Status)); + } + else + { + retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj); + HEAP_free ( pwsz ); + } + } + + return retValue; + +} + +/* + * @implemented + */ +UINT +WINAPI +GetStringBitmapW(HDC hdc, + LPWSTR pwsz, + BOOL doCall, + UINT cj, + BYTE *lpSB) +{ + UINT retValue = 0; + + if (doCall) + { + retValue = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj); + } + + return retValue; + +} + +/* + * @implemented + */ +BOOL +WINAPI +GetETM(HDC hdc, + EXTTEXTMETRIC *petm) +{ + BOOL Ret = NtGdiGetETM(hdc, petm); + + if (Ret && petm) + petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0); + + return Ret; +} From b71df11be97d578a1f20a0cb5f264c0441b8ea8e Mon Sep 17 00:00:00 2001 From: Kamil Hornicek Date: Tue, 28 Oct 2014 21:38:26 +0000 Subject: [PATCH 6/9] [WIN32K] - addendum to revision 64877 which slightly changed UserDrawCaption's logic - fixes window title being drawn over the icon svn path=/trunk/; revision=65087 --- reactos/win32ss/user/ntuser/painting.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reactos/win32ss/user/ntuser/painting.c b/reactos/win32ss/user/ntuser/painting.c index c6335fb800b..3b1d693edc2 100644 --- a/reactos/win32ss/user/ntuser/painting.c +++ b/reactos/win32ss/user/ntuser/painting.c @@ -2143,9 +2143,13 @@ BOOL UserDrawCaption( UserDrawIconEx(hDc, x, y, pIcon, cx, cy, 0, NULL, DI_NORMAL); UserDereferenceObject(pIcon); } + else + { + HasIcon = FALSE; + } } - if (hIcon) + if (HasIcon) Rect.left += Rect.bottom - Rect.top; if((uFlags & DC_TEXT)) From 70cb67436c22943719706f6f4923ca232d01d014 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 28 Oct 2014 21:57:41 +0000 Subject: [PATCH 7/9] [NET] Display more password information in the NET USER command. svn path=/trunk/; revision=65089 --- .../base/applications/network/net/cmdUser.c | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/reactos/base/applications/network/net/cmdUser.c b/reactos/base/applications/network/net/cmdUser.c index 038df08d1c3..9f9dcb2cbfe 100644 --- a/reactos/base/applications/network/net/cmdUser.c +++ b/reactos/base/applications/network/net/cmdUser.c @@ -86,6 +86,7 @@ PrintDateTime(DWORD dwSeconds) RtlSecondsSince1970ToTime(dwSeconds, &Time); FileTime.dwLowDateTime = Time.u.LowPart; FileTime.dwHighDateTime = Time.u.HighPart; + FileTimeToLocalFileTime(&FileTime, &FileTime); FileTimeToSystemTime(&FileTime, &SystemTime); GetDateFormatW(LOCALE_USER_DEFAULT, @@ -106,12 +107,30 @@ PrintDateTime(DWORD dwSeconds) } +static +DWORD +GetTimeInSeconds(VOID) +{ + LARGE_INTEGER Time; + FILETIME FileTime; + DWORD dwSeconds; + + GetSystemTimeAsFileTime(&FileTime); + Time.u.LowPart = FileTime.dwLowDateTime; + Time.u.HighPart = FileTime.dwHighDateTime; + RtlTimeToSecondsSince1970(&Time, &dwSeconds); + + return dwSeconds; +} + + static NET_API_STATUS DisplayUser(LPWSTR lpUserName) { PUSER_MODALS_INFO_0 pUserModals = NULL; PUSER_INFO_4 pUserInfo = NULL; + DWORD dwLastSet; NET_API_STATUS Status; /* Modify the user */ @@ -141,17 +160,22 @@ DisplayUser(LPWSTR lpUserName) PrintDateTime(pUserInfo->usri4_acct_expires); PrintToConsole(L"\n"); - PrintToConsole(L"Password last set \n"); PrintToConsole(L"Password expires "); - if (pUserModals->usrmod0_max_passwd_age == TIMEQ_FOREVER) + dwLastSet = GetTimeInSeconds() - pUserInfo->usri4_password_age; + PrintDateTime(dwLastSet); + + PrintToConsole(L"Password expires "); + if ((pUserInfo->usri4_flags & UF_DONT_EXPIRE_PASSWD) || pUserModals->usrmod0_max_passwd_age == TIMEQ_FOREVER) PrintToConsole(L"Never\n"); else - PrintDateTime(pUserInfo->usri4_acct_expires); + PrintDateTime(dwLastSet + pUserModals->usrmod0_max_passwd_age); - PrintToConsole(L"Password changeable \n"); - PrintToConsole(L"Password required \n"); - PrintToConsole(L"User may change password \n"); + PrintToConsole(L"Password changeable "); + PrintDateTime(dwLastSet + pUserModals->usrmod0_min_passwd_age); + + PrintToConsole(L"Password required %s\n", (pUserInfo->usri4_flags & UF_PASSWD_NOTREQD) ? L"No" : L"Yes"); + PrintToConsole(L"User may change password %s\n", (pUserInfo->usri4_flags & UF_PASSWD_CANT_CHANGE) ? L"No" : L"Yes"); PrintToConsole(L"\n"); PrintToConsole(L"Workstation allowed %s\n", pUserInfo->usri4_workstations); @@ -196,6 +220,7 @@ cmdUser( LPWSTR lpPassword = NULL; PUSER_INFO_4 pUserInfo = NULL; USER_INFO_4 UserInfo; + LPWSTR p; NET_API_STATUS Status; if (argc == 2) @@ -281,6 +306,21 @@ cmdUser( { if (_wcsnicmp(argv[j], L"/active:", 8) == 0) { + p = &argv[i][8]; + if (_wcsicmp(p, L"yes") == 0) + { + + } + else if (_wcsicmp(p, L"no") == 0) + { + + } + else + { + PrintToConsole(L"You entered an invalid value for the /ACTIVE option.\n"); + result = 1; + goto done; + } } else if (_wcsnicmp(argv[j], L"/comment:", 9) == 0) { From 7a204076f6f5b6658f23404a0136dbbcf0053498 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 28 Oct 2014 21:59:57 +0000 Subject: [PATCH 8/9] [DISK] Get ready to enter into the 10th dimension... So: - Implement support for IRP_MJ_FILE_SYSTEM_CONTROL. Yes... You read well! So, implemented a ScsiDiskFileSystemControl() function. The way it is added to the DriverObject is a big hack, class2 is not supposed to have such requests, so, we do it in its back. Fear! - Stubplement the NtfsRussinovichism() function. This is the only function we're supposed to call with IRP MJ FSCTRL and with IRP MN USRFSRQST. Its purpose (when its implemented) is to reply back to the M. Russinovich tools (NFI & NTFSInfo) so that they can directly dump NTFS information without going into NTFS driver. They kind of bypass it. We do all agree this is a ugly hack. But it exists in Windows, as these tools work in Windows. And it would be useful they actually work in ReactOS. Soon, we'll be able to publish a book "ReactOS Internals" where we speak about undocumented FS controls to dump NTFS information to show how well our NTFS works ;-). svn path=/trunk/; revision=65090 --- reactos/drivers/storage/class/disk/disk.c | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/reactos/drivers/storage/class/disk/disk.c b/reactos/drivers/storage/class/disk/disk.c index 57428524f67..015b8bbcc64 100644 --- a/reactos/drivers/storage/class/disk/disk.c +++ b/reactos/drivers/storage/class/disk/disk.c @@ -310,6 +310,11 @@ ResetScsiBus( IN PDEVICE_OBJECT DeviceObject ); +NTSTATUS +NTAPI +ScsiDiskFileSystemControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp); + #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, DriverEntry) #pragma alloc_text(PAGE, FindScsiDisks) @@ -380,6 +385,11 @@ Return Value: InitializationData.ClassShutdownFlush = ScsiDiskShutdownFlush; InitializationData.ClassCreateClose = NULL; + // + // HACK! Please check below to the implementation of the function + // + DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = ScsiDiskFileSystemControl; + // // Call the class init routine // @@ -5202,3 +5212,56 @@ Return Value: } } // end UpdateDeviceObjects() + +// +// This function is supposed only to support NTFS tools +// from M. Russinovich. This is kind of huge hack and is +// totally undocumented :-). +// +NTSTATUS +NtfsRussinovichism(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +// +// Hack: this function is not supposed to be implemented +// Even though it's required to enable some M. Russinovich +// to directly request disks so that they can dump NTFS data +// without going through the driver. +// We don't expect doing more from here, hence the limited +// implementation and support. +// +NTSTATUS +NTAPI +ScsiDiskFileSystemControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PIO_STACK_LOCATION Stack; + NTSTATUS Status; + + DPRINT1("ScsiDiskFileSystemControl(%p, %p)\n", DeviceObject, Irp); + + Stack = IoGetCurrentIrpStackLocation(Irp); + + switch (Stack->MinorFunction) + { + case IRP_MN_USER_FS_REQUEST: + Status = NtfsRussinovichism(DeviceObject, Irp); + break; + + default: + DPRINT("MinorFunction %d\n", Stack->MinorFunction); + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return Status; +} From 54d0920f7e80b853eb9c3ba47802c3dbdae1619e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 28 Oct 2014 22:16:24 +0000 Subject: [PATCH 9/9] [GDI32] Improve functions in coord.c: - Use GdiGetDcAttr() where appropriate - Fix SetLastError() usage - Add annotations - improve variable naming - Add some comments svn path=/trunk/; revision=65093 --- reactos/win32ss/gdi/gdi32/objects/coord.c | 614 ++++++++++++++-------- 1 file changed, 389 insertions(+), 225 deletions(-) diff --git a/reactos/win32ss/gdi/gdi32/objects/coord.c b/reactos/win32ss/gdi/gdi32/objects/coord.c index cc28b06527a..4fc29a1c468 100644 --- a/reactos/win32ss/gdi/gdi32/objects/coord.c +++ b/reactos/win32ss/gdi/gdi32/objects/coord.c @@ -25,10 +25,10 @@ MatrixToXForm(XFORM *pxform, const MATRIX *pmx) void GdiTransformPoints2( - XFORM *pxform, - PPOINT pptOut, - PPOINT pptIn, - ULONG nCount) + _In_ XFORM *pxform, + _Out_writes_(nCount) PPOINT pptOut, + _In_reads_(nCount) PPOINT pptIn, + _In_ ULONG nCount) { ULONG i; FLOAT x, y; @@ -45,10 +45,10 @@ GdiTransformPoints2( FORCEINLINE void GdiTransformPoints( - MATRIX *pmx, - PPOINT pptOut, - PPOINT pptIn, - ULONG nCount) + _In_ MATRIX *pmx, + _Out_writes_(nCount) PPOINT pptOut, + _In_reads_(nCount) PPOINT pptIn, + _In_ ULONG nCount) { XFORM xform; @@ -62,9 +62,9 @@ GdiTransformPoints( BOOL WINAPI CombineTransform( - LPXFORM pxfResult, - const XFORM *pxf1, - const XFORM *pxf2) + _Out_ LPXFORM pxfResult, + _In_ const XFORM *pxf1, + _In_ const XFORM *pxf2) { XFORM xformTmp; @@ -111,7 +111,8 @@ CombineTransform( */ int WINAPI -GetMapMode(HDC hdc) +GetMapMode( + _In_ HDC hdc) { PDC_ATTR pdcattr; @@ -123,6 +124,7 @@ GetMapMode(HDC hdc) return 0; } + /* Return the map mode */ return pdcattr->iMapMode; } @@ -157,29 +159,35 @@ SetMapMode( } } #endif + /* Force change if Isotropic is set for recompute. */ if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC)) { pdcattr->ulDirty_ &= ~SLOW_WIDTHS; - return GetAndSetDCDWord( hdc, GdiGetSetMapMode, iMode, 0, 0, 0 ); + return GetAndSetDCDWord(hdc, GdiGetSetMapMode, iMode, 0, 0, 0); } + /* Simply return the old mode, which equals the new mode */ return pdcattr->iMapMode; } BOOL WINAPI -DPtoLP(HDC hdc, LPPOINT lpPoints, INT nCount) +DPtoLP( + _In_ HDC hdc, + _Inout_updates_(nCount) LPPOINT lpPoints, + _In_ INT nCount) { #if 0 INT i; PDC_ATTR pdcattr; + /* Get the DC attribute */ pdcattr = GdiGetDcAttr(hdc); if (!pdcattr) { - SetLastError(ERROR_INVALID_HANDLE); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -198,16 +206,20 @@ DPtoLP(HDC hdc, LPPOINT lpPoints, INT nCount) BOOL WINAPI -LPtoDP(HDC hdc, LPPOINT lpPoints, INT nCount) +LPtoDP( + _In_ HDC hdc, + _Inout_updates_(nCount) LPPOINT lpPoints, + _In_ INT nCount) { #if 0 INT i; PDC_ATTR pdcattr; + /* Get the DC attribute */ pdcattr = GdiGetDcAttr(hdc); if (!pdcattr) { - SetLastError(ERROR_INVALID_HANDLE); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } @@ -230,35 +242,35 @@ LPtoDP(HDC hdc, LPPOINT lpPoints, INT nCount) */ BOOL WINAPI -GetCurrentPositionEx(HDC hdc, - LPPOINT lpPoint) +GetCurrentPositionEx( + _In_ HDC hdc, + _Out_ LPPOINT lpPoint) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if ( lpPoint ) - { - if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // have a hit! - { - lpPoint->x = Dc_Attr->ptfxCurrent.x; - lpPoint->y = Dc_Attr->ptfxCurrent.y; - DPtoLP ( hdc, lpPoint, 1); // reconvert back. - Dc_Attr->ptlCurrent.x = lpPoint->x; // save it - Dc_Attr->ptlCurrent.y = lpPoint->y; - Dc_Attr->ulDirty_ &= ~DIRTY_PTLCURRENT; // clear bit - } - else - { - lpPoint->x = Dc_Attr->ptlCurrent.x; - lpPoint->y = Dc_Attr->ptlCurrent.y; - } - } - else + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if ((pdcattr == NULL) || (lpPoint == NULL)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + + if (pdcattr->ulDirty_ & DIRTY_PTLCURRENT) // have a hit! + { + lpPoint->x = pdcattr->ptfxCurrent.x; + lpPoint->y = pdcattr->ptfxCurrent.y; + DPtoLP(hdc, lpPoint, 1); // reconvert back. + pdcattr->ptlCurrent.x = lpPoint->x; // save it + pdcattr->ptlCurrent.y = lpPoint->y; + pdcattr->ulDirty_ &= ~DIRTY_PTLCURRENT; // clear bit + } + else + { + lpPoint->x = pdcattr->ptlCurrent.x; + lpPoint->y = pdcattr->ptlCurrent.y; + } + return TRUE; } @@ -267,7 +279,9 @@ GetCurrentPositionEx(HDC hdc, */ BOOL WINAPI -GetWorldTransform(HDC hDC, LPXFORM lpXform) +GetWorldTransform( + _In_ HDC hdc, + _Out_ LPXFORM pxform) { #if 0 PDC_ATTR pdcattr; @@ -284,38 +298,41 @@ GetWorldTransform(HDC hDC, LPXFORM lpXform) GdiFixupTransforms(pdcattr); } - MatrixToXForm(lpXform, &pdcattr->mxWorldToDevice); + MatrixToXForm(pxform, &pdcattr->mxWorldToDevice); #endif - return NtGdiGetTransform(hDC, GdiWorldSpaceToPageSpace, lpXform); + return NtGdiGetTransform(hdc, GdiWorldSpaceToPageSpace, pxform); } BOOL WINAPI -SetWorldTransform( HDC hDC, CONST XFORM *Xform ) +SetWorldTransform( + _In_ HDC hdc, + _Out_ CONST XFORM *pxform) { /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */ - return ModifyWorldTransform( hDC, Xform, MWT_MAX+1); + return ModifyWorldTransform(hdc, pxform, MWT_MAX+1); } BOOL WINAPI ModifyWorldTransform( - HDC hDC, - CONST XFORM *Xform, - DWORD iMode -) + _In_ HDC hdc, + _In_opt_ CONST XFORM *pxform, + _In_ DWORD dwMode) { + PDC_ATTR pdcattr; + #if 0 // Handle something other than a normal dc object. - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) return FALSE; else { - PLDC pLDC = GdiGetLDC(hDC); + PLDC pLDC = GdiGetLDC(hdc); if ( !pLDC ) { SetLastError(ERROR_INVALID_HANDLE); @@ -323,43 +340,59 @@ ModifyWorldTransform( } if (pLDC->iType == LDC_EMFLDC) { - if (iMode == MWT_MAX+1) - if (!EMFDRV_SetWorldTransform( hDC, Xform) ) return FALSE; - return EMFDRV_ModifyWorldTransform( hDC, Xform, iMode); // Ported from wine. + if (dwMode == MWT_MAX+1) + if (!EMFDRV_SetWorldTransform(hdc, pxform) ) return FALSE; + return EMFDRV_ModifyWorldTransform(hdc, pxform, dwMode); // Ported from wine. } return FALSE; } } #endif - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } /* Check that graphics mode is GM_ADVANCED */ - if ( Dc_Attr->iGraphicsMode != GM_ADVANCED ) return FALSE; + if (pdcattr->iGraphicsMode != GM_ADVANCED) + return FALSE; - return NtGdiModifyWorldTransform(hDC, (CONST LPXFORM) Xform, iMode); + /* Call win32k to do the work */ + return NtGdiModifyWorldTransform(hdc, (LPXFORM)pxform, dwMode); } BOOL WINAPI GetViewportExtEx( - HDC hdc, - LPSIZE lpSize -) + _In_ HDC hdc, + _Out_ LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if ((Dc_Attr->flXform & PAGE_EXTENTS_CHANGED) && (Dc_Attr->iMapMode == MM_ISOTROPIC)) - // Something was updated, go to kernel. - return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (PPOINTL) lpSize ); - else + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) { - lpSize->cx = Dc_Attr->szlViewportExt.cx; - lpSize->cy = Dc_Attr->szlViewportExt.cy; + /* Do not set LastError here! */ + return FALSE; } + + /* Check if we need to update values */ + if ((pdcattr->flXform & PAGE_EXTENTS_CHANGED) && + (pdcattr->iMapMode == MM_ISOTROPIC)) + { + /* Call win32k to do the work */ + return NtGdiGetDCPoint(hdc, GdiGetViewPortExt, (PPOINTL)lpSize); + } + + /* Nothing to calculate, return the current extension */ + lpSize->cx = pdcattr->szlViewportExt.cx; + lpSize->cy = pdcattr->szlViewportExt.cy; + return TRUE; } @@ -367,53 +400,80 @@ GetViewportExtEx( BOOL WINAPI GetViewportOrgEx( - HDC hdc, - LPPOINT lpPoint -) + _In_ HDC hdc, + _Out_ LPPOINT lpPoint) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + /* Do not set LastError here! */ + return FALSE; + } + + /* Get the current viewport org */ + lpPoint->x = pdcattr->ptlViewportOrg.x; + lpPoint->y = pdcattr->ptlViewportOrg.y; + + /* Handle right-to-left layout */ + if (pdcattr->dwLayout & LAYOUT_RTL) + lpPoint->x = -lpPoint->x; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpPoint->x = Dc_Attr->ptlViewportOrg.x; - lpPoint->y = Dc_Attr->ptlViewportOrg.y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; return TRUE; - // return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint ); } BOOL WINAPI GetWindowExtEx( - HDC hdc, - LPSIZE lpSize -) + _In_ HDC hdc, + _Out_ LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + /* Do not set LastError here! */ + return FALSE; + } + + /* Get the current window extension */ + lpSize->cx = pdcattr->szlWindowExt.cx; + lpSize->cy = pdcattr->szlWindowExt.cy; + + /* Handle right-to-left layout */ + if (pdcattr->dwLayout & LAYOUT_RTL) + lpSize->cx = -lpSize->cx; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpSize->cx = Dc_Attr->szlWindowExt.cx; - lpSize->cy = Dc_Attr->szlWindowExt.cy; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; return TRUE; - // return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize ); } BOOL WINAPI GetWindowOrgEx( - HDC hdc, - LPPOINT lpPoint -) + _In_ HDC hdc, + _Out_ LPPOINT lpPoint) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + /* Do not set LastError here! */ + return FALSE; + } + + /* Get the current window origin */ + lpPoint->x = pdcattr->ptlWindowOrg.x; + lpPoint->y = pdcattr->ptlWindowOrg.y; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - lpPoint->x = Dc_Attr->ptlWindowOrg.x; - lpPoint->y = Dc_Attr->ptlWindowOrg.y; return TRUE; - //return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint ); } /* @@ -421,12 +481,13 @@ GetWindowOrgEx( */ BOOL WINAPI -SetViewportExtEx(HDC hdc, - int nXExtent, - int nYExtent, - LPSIZE lpSize) +SetViewportExtEx( + _In_ HDC hdc, + _In_ int nXExtent, + _In_ int nYExtent, + _Out_opt_ LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -447,35 +508,53 @@ SetViewportExtEx(HDC hdc, } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) { + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + /* Check if the caller wants the old extension */ if (lpSize) { - lpSize->cx = Dc_Attr->szlViewportExt.cx; - lpSize->cy = Dc_Attr->szlViewportExt.cy; + /* Return the current viewport extension */ + lpSize->cx = pdcattr->szlViewportExt.cx; + lpSize->cy = pdcattr->szlViewportExt.cy; } - if ((Dc_Attr->szlViewportExt.cx == nXExtent) && (Dc_Attr->szlViewportExt.cy == nYExtent)) + /* Check for trivial case */ + if ((pdcattr->szlViewportExt.cx == nXExtent) && + (pdcattr->szlViewportExt.cy == nYExtent)) return TRUE; - if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) + /* Only change viewport extension if we are in iso or aniso mode */ + if ((pdcattr->iMapMode == MM_ISOTROPIC) || + (pdcattr->iMapMode == MM_ANISOTROPIC)) { if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY) { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + NtGdiFlush(); // Sync up pdcattr from Kernel space. + pdcattr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); } } - Dc_Attr->szlViewportExt.cx = nXExtent; - Dc_Attr->szlViewportExt.cy = nYExtent; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + + /* Set the new viewport extension */ + pdcattr->szlViewportExt.cx = nXExtent; + pdcattr->szlViewportExt.cy = nYExtent; + + /* Handle right-to-left layout */ + if (pdcattr->dwLayout & LAYOUT_RTL) + NtGdiMirrorWindowOrg(hdc); + + /* Update xform flags */ + pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } + return TRUE; } @@ -484,13 +563,14 @@ SetViewportExtEx(HDC hdc, */ BOOL WINAPI -SetWindowOrgEx(HDC hdc, - int X, - int Y, - LPPOINT lpPoint) +SetWindowOrgEx( + _In_ HDC hdc, + _In_ int X, + _In_ int Y, + _Out_opt_ LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -511,31 +591,37 @@ SetWindowOrgEx(HDC hdc, } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (pdcattr == NULL) + { + /* Do not set LastError here! */ + return FALSE; + } if (lpPoint) { - lpPoint->x = Dc_Attr->ptlWindowOrg.x; - lpPoint->y = Dc_Attr->ptlWindowOrg.y; + lpPoint->x = pdcattr->ptlWindowOrg.x; + lpPoint->y = pdcattr->ptlWindowOrg.y; } - if ((Dc_Attr->ptlWindowOrg.x == X) && (Dc_Attr->ptlWindowOrg.y == Y)) + if ((pdcattr->ptlWindowOrg.x == X) && (pdcattr->ptlWindowOrg.y == Y)) return TRUE; if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY) { - NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + NtGdiFlush(); // Sync up pdcattr from Kernel space. + pdcattr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); } } - Dc_Attr->ptlWindowOrg.x = X; - Dc_Attr->lWindowOrgx = X; - Dc_Attr->ptlWindowOrg.y = Y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + pdcattr->ptlWindowOrg.x = X; + pdcattr->lWindowOrgx = X; + pdcattr->ptlWindowOrg.y = Y; + if (pdcattr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + pdcattr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); return TRUE; #endif return NtGdiSetWindowOrgEx(hdc,X,Y,lpPoint); @@ -559,6 +645,7 @@ SetWindowExtEx( ulType = GDI_HANDLE_GET_TYPE(hdc); switch (ulType) { + case GDILoObjType_LO_ALTDC_TYPE: case GDILoObjType_LO_DC_TYPE: /* Handle this in the path below */ break; @@ -584,11 +671,16 @@ SetWindowExtEx( return FALSE; } + /* Check if the caller wants the old extension */ if (lpSize) { + /* Return the current window extension */ lpSize->cx = pdcattr->szlWindowExt.cx; lpSize->cy = pdcattr->szlWindowExt.cy; - if (pdcattr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; + + /* Handle right-to-left layout */ + if (pdcattr->dwLayout & LAYOUT_RTL) + lpSize->cx = -lpSize->cx; } if (pdcattr->dwLayout & LAYOUT_RTL) @@ -596,12 +688,15 @@ SetWindowExtEx( NtGdiMirrorWindowOrg(hdc); pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } - else if ((pdcattr->iMapMode == MM_ISOTROPIC) || (pdcattr->iMapMode == MM_ANISOTROPIC)) + else if ((pdcattr->iMapMode == MM_ISOTROPIC) || + (pdcattr->iMapMode == MM_ANISOTROPIC)) { - if ((pdcattr->szlWindowExt.cx == nXExtent) && (pdcattr->szlWindowExt.cy == nYExtent)) + if ((pdcattr->szlWindowExt.cx == nXExtent) && + (pdcattr->szlWindowExt.cy == nYExtent)) return TRUE; - if ((!nXExtent) || (!nYExtent)) return FALSE; + if ((!nXExtent) || (!nYExtent)) + return FALSE; if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { @@ -611,9 +706,12 @@ SetWindowExtEx( pdcattr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); } } + pdcattr->szlWindowExt.cx = nXExtent; pdcattr->szlWindowExt.cy = nYExtent; - if (pdcattr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + if (pdcattr->dwLayout & LAYOUT_RTL) + NtGdiMirrorWindowOrg(hdc); + pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } @@ -625,13 +723,14 @@ SetWindowExtEx( */ BOOL WINAPI -SetViewportOrgEx(HDC hdc, - int X, - int Y, - LPPOINT lpPoint) +SetViewportOrgEx( + _In_ HDC hdc, + _In_ int X, + _In_ int Y, + _Out_opt_ LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -652,18 +751,25 @@ SetViewportOrgEx(HDC hdc, } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + /* Do not set LastError here! */ + return FALSE; + } if (lpPoint) { - lpPoint->x = Dc_Attr->ptlViewportOrg.x; - lpPoint->y = Dc_Attr->ptlViewportOrg.y; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; + lpPoint->x = pdcattr->ptlViewportOrg.x; + lpPoint->y = pdcattr->ptlViewportOrg.y; + if (pdcattr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - if (Dc_Attr->dwLayout & LAYOUT_RTL) X = -X; - Dc_Attr->ptlViewportOrg.x = X; - Dc_Attr->ptlViewportOrg.y = Y; + pdcattr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + if (pdcattr->dwLayout & LAYOUT_RTL) X = -X; + pdcattr->ptlViewportOrg.x = X; + pdcattr->ptlViewportOrg.y = Y; return TRUE; #endif return NtGdiSetViewportOrgEx(hdc,X,Y,lpPoint); @@ -675,22 +781,21 @@ SetViewportOrgEx(HDC hdc, BOOL WINAPI ScaleViewportExtEx( - HDC a0, - int a1, - int a2, - int a3, - int a4, - LPSIZE a5 -) + _In_ HDC hdc, + _In_ INT xNum, + _In_ INT xDenom, + _In_ INT yNum, + _In_ INT yDenom, + _Out_ LPSIZE lpSize) { #if 0 - if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) return MFDRV_; else { - PLDC pLDC = GdiGetLDC(a0); + PLDC pLDC = GdiGetLDC(hdc); if ( !pLDC ) { SetLastError(ERROR_INVALID_HANDLE); @@ -703,10 +808,13 @@ ScaleViewportExtEx( } } #endif - if (!GdiIsHandleValid((HGDIOBJ) a0) || - (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; + if (!GdiGetDcAttr(hdc)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } - return NtGdiScaleViewportExtEx(a0, a1, a2, a3, a4, a5); + return NtGdiScaleViewportExtEx(hdc, xNum, xDenom, yNum, yDenom, lpSize); } /* @@ -715,22 +823,21 @@ ScaleViewportExtEx( BOOL WINAPI ScaleWindowExtEx( - HDC a0, - int a1, - int a2, - int a3, - int a4, - LPSIZE a5 -) + _In_ HDC hdc, + _In_ INT xNum, + _In_ INT xDenom, + _In_ INT yNum, + _In_ INT yDenom, + _Out_ LPSIZE lpSize) { #if 0 - if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC) + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { - if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC) + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) return MFDRV_; else { - PLDC pLDC = GdiGetLDC(a0); + PLDC pLDC = GdiGetLDC(hdc); if ( !pLDC ) { SetLastError(ERROR_INVALID_HANDLE); @@ -743,10 +850,14 @@ ScaleWindowExtEx( } } #endif - if (!GdiIsHandleValid((HGDIOBJ) a0) || - (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE; - return NtGdiScaleWindowExtEx(a0, a1, a2, a3, a4, a5); + if (!GdiGetDcAttr(hdc)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + return NtGdiScaleWindowExtEx(hdc, xNum, xDenom, yNum, yDenom, lpSize); } /* @@ -754,12 +865,28 @@ ScaleWindowExtEx( */ DWORD WINAPI -GetLayout(HDC hdc - ) +GetLayout( + _In_ HDC hdc) { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return GDI_ERROR; - return Dc_Attr->dwLayout; + PDC_ATTR pdcattr; + + /* METADC16 is not supported in this API */ + if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) + { + return GDI_ERROR; + } + + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + /* Set the error value and return failure */ + SetLastError(ERROR_INVALID_PARAMETER); + return GDI_ERROR; + } + + /* Return the layout */ + return pdcattr->dwLayout; } @@ -768,8 +895,9 @@ GetLayout(HDC hdc */ DWORD WINAPI -SetLayout(HDC hdc, - DWORD dwLayout) +SetLayout( + _In_ HDC hdc, + _In_ DWORD dwLayout) { #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) @@ -791,9 +919,13 @@ SetLayout(HDC hdc, } } #endif - if (!GdiIsHandleValid((HGDIOBJ) hdc) || - (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; - return NtGdiSetLayout( hdc, -1, dwLayout); + if (!GdiGetDcAttr(hdc)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return GDI_ERROR; + } + + return NtGdiSetLayout(hdc, -1, dwLayout); } /* @@ -801,10 +933,23 @@ SetLayout(HDC hdc, */ DWORD WINAPI -SetLayoutWidth(HDC hdc,LONG wox,DWORD dwLayout) +SetLayoutWidth( + _In_ HDC hdc, + _In_ LONG wox, + _In_ DWORD dwLayout) { - if (!GdiIsHandleValid((HGDIOBJ) hdc) || - (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR; + /* Only normal DCs are handled here */ + if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) + { + return GDI_ERROR; + } + + if (!GdiGetDcAttr(hdc)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return GDI_ERROR; + } + return NtGdiSetLayout( hdc, wox, dwLayout); } @@ -814,10 +959,10 @@ SetLayoutWidth(HDC hdc,LONG wox,DWORD dwLayout) BOOL WINAPI GetDCOrgEx( - HDC hdc, - LPPOINT lpPoint) + _In_ HDC hdc, + _Out_ LPPOINT lpPoint) { - return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); + return NtGdiGetDCPoint(hdc, GdiGetDCOrg, (PPOINTL)lpPoint); } @@ -827,13 +972,16 @@ GetDCOrgEx( LONG WINAPI GetDCOrg( - HDC hdc) + _In_ HDC hdc) { - // Officially obsolete by Microsoft - POINT Pt; - if (!GetDCOrgEx(hdc, &Pt)) + POINT pt; + + /* Call the new API */ + if (!GetDCOrgEx(hdc, &pt)) return 0; - return(MAKELONG(Pt.x, Pt.y)); + + /* Return the point in the old way */ + return(MAKELONG(pt.x, pt.y)); } @@ -843,13 +991,14 @@ GetDCOrg( */ BOOL WINAPI -OffsetViewportOrgEx(HDC hdc, - int nXOffset, - int nYOffset, - LPPOINT lpPoint) +OffsetViewportOrgEx( + _In_ HDC hdc, + _In_ int nXOffset, + _In_ int nYOffset, + _Out_opt_ LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -870,28 +1019,35 @@ OffsetViewportOrgEx(HDC hdc, } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; - - if ( lpPoint ) + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) { - *lpPoint = (POINT)Dc_Attr->ptlViewportOrg; - if ( Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; + /* Do not set LastError here! */ + return FALSE; + } + + if (lpPoint) + { + *lpPoint = (POINT)pdcattr->ptlViewportOrg; + if ( pdcattr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x; } if ( nXOffset || nYOffset != nXOffset ) { if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + if (pdcattr->ulDirty_ & DC_MODE_DIRTY) { NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + pdcattr->ulDirty_ &= ~DC_MODE_DIRTY; } } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - if ( Dc_Attr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset; - Dc_Attr->ptlViewportOrg.x += nXOffset; - Dc_Attr->ptlViewportOrg.y += nYOffset; + + pdcattr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + if (pdcattr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset; + pdcattr->ptlViewportOrg.x += nXOffset; + pdcattr->ptlViewportOrg.y += nYOffset; } return TRUE; #endif @@ -904,13 +1060,14 @@ OffsetViewportOrgEx(HDC hdc, */ BOOL WINAPI -OffsetWindowOrgEx(HDC hdc, - int nXOffset, - int nYOffset, - LPPOINT lpPoint) +OffsetWindowOrgEx( + _In_ HDC hdc, + _In_ int nXOffset, + _In_ int nYOffset, + _Out_opt_ LPPOINT lpPoint) { #if 0 - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -931,28 +1088,35 @@ OffsetWindowOrgEx(HDC hdc, } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + /* Get the DC attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + /* Do not set LastError here! */ + return FALSE; + } if ( lpPoint ) { - *lpPoint = (POINT)Dc_Attr->ptlWindowOrg; - lpPoint->x = Dc_Attr->lWindowOrgx; + *lpPoint = (POINT)pdcattr->ptlWindowOrg; + lpPoint->x = pdcattr->lWindowOrgx; } if ( nXOffset || nYOffset != nXOffset ) { if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) { - if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY) + if (pdcattr->ulDirty_ & DC_MODE_DIRTY) { NtGdiFlush(); - Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY; + pdcattr->ulDirty_ &= ~DC_MODE_DIRTY; } } - Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); - Dc_Attr->ptlWindowOrg.x += nXOffset; - Dc_Attr->ptlWindowOrg.y += nYOffset; - Dc_Attr->lWindowOrgx += nXOffset; + + pdcattr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID); + pdcattr->ptlWindowOrg.x += nXOffset; + pdcattr->ptlWindowOrg.y += nYOffset; + pdcattr->lWindowOrgx += nXOffset; } return TRUE; #endif