From 52102e72fcddaadc5077dc5abef29b7fed741038 Mon Sep 17 00:00:00 2001 From: Eugene Ingerman Date: Thu, 18 Jul 2002 21:49:59 +0000 Subject: [PATCH] Export MmCopyFrom/ToCaller from ntoskrnl. Added MulDiv. svn path=/trunk/; revision=3261 --- reactos/include/ddk/winddi.h | 48 ++++++++------- reactos/lib/kernel32/misc/stubs.c | 76 ++++++++++++++++++------ reactos/ntoskrnl/include/internal/safe.h | 4 +- reactos/ntoskrnl/ntoskrnl.def | 4 +- reactos/ntoskrnl/ntoskrnl.edf | 4 +- reactos/ntoskrnl/rtl/mem.c | 6 +- 6 files changed, 96 insertions(+), 46 deletions(-) diff --git a/reactos/include/ddk/winddi.h b/reactos/include/ddk/winddi.h index 0b98c9d594a..c4de4c72049 100644 --- a/reactos/include/ddk/winddi.h +++ b/reactos/include/ddk/winddi.h @@ -65,10 +65,10 @@ enum _BMF_TYPES BMF_1BPP = 1, BMF_4BPP, BMF_8BPP, - BMF_16BPP, - BMF_24BPP, - BMF_32BPP, - BMF_4RLE, + BMF_16BPP, + BMF_24BPP, + BMF_32BPP, + BMF_4RLE, BMF_8RLE }; @@ -124,7 +124,7 @@ enum _CD_ORDERS enum _ESCAPE_CODES { ESC_PASSTHROUGH, - ESC_QUERYESCSUPPORT + ESC_QUERYESCSUPPORT }; #define FM_INFO_TECH_TRUETYPE 0x00000001 @@ -354,7 +354,7 @@ enum _DRV_HOOK_FUNCS enum _QUERY_ADVANCE_WIDTH_TYPES { QAW_GETWIDTHS = 1, - QAW_GETEASYWIDTHS + QAW_GETEASYWIDTHS }; #define QC_OUTLINES 0x00000001 @@ -389,7 +389,7 @@ enum _SPS_RC enum _SURF_TYPES { STYPE_BITMAP = 1, - STYPE_DEVICE, + STYPE_DEVICE, STYPE_DEVBITMAP }; @@ -435,14 +435,14 @@ typedef struct _DRVENABLEDATA /* FIXME: replace this with correct def for LDECI4 */ typedef DWORD LDECI4; -typedef struct _CIECHROMA +typedef struct _CIECHROMA { LDECI4 x; LDECI4 y; LDECI4 Y; } CIECHROMA, *PCIECHROMA; -typedef struct _COLORINFO +typedef struct _COLORINFO { CIECHROMA Red; CIECHROMA Green; @@ -462,7 +462,7 @@ typedef struct _COLORINFO LDECI4 MagentaInYellowDye; } COLORINFO, *PCOLORINFO; -typedef struct _DEVINFO +typedef struct _DEVINFO { ULONG flGraphicsCaps; LOGFONTW lfDefaultFont; @@ -475,7 +475,7 @@ typedef struct _DEVINFO HPALETTE hpalDefault; } DEVINFO, *PDEVINFO; -typedef struct _GDIINFO +typedef struct _GDIINFO { ULONG ulVersion; ULONG ulTechnology; @@ -514,7 +514,7 @@ typedef struct _GDIINFO ULONG ulPanningVertRes; } GDIINFO, *PGDIINFO; -typedef struct _BRUSHOBJ +typedef struct _BRUSHOBJ { ULONG iSolidColor; PVOID pvRbrush; @@ -523,7 +523,7 @@ typedef struct _BRUSHOBJ LOGBRUSH logbrush; } BRUSHOBJ, *PBRUSHOBJ; -typedef struct _CLIPOBJ +typedef struct _CLIPOBJ { ULONG iUniq; RECTL rclBounds; @@ -533,27 +533,27 @@ typedef struct _CLIPOBJ BYTE fjOptions; } CLIPOBJ, *PCLIPOBJ; -typedef struct _ENUMRECTS +typedef struct _ENUMRECTS { ULONG c; RECTL arcl[1]; } ENUMRECTS, *PENUMRECTS; -typedef struct _FONTOBJ +typedef struct _FONTOBJ { - ULONG iUniq; - ULONG iFace; + ULONG iUniq; + ULONG iFace; ULONG cxMax; ULONG flFontType; ULONG iTTUniq; - ULONG iFile; + ULONG iFile; SIZE sizLogResPpi; ULONG ulStyleSize; PVOID pvConsumer; PVOID pvProducer; } FONTOBJ, *PFONTOBJ; -typedef struct _IFIMETRICS +typedef struct _IFIMETRICS { ULONG cjThis; ULONG ulVersion; @@ -618,7 +618,7 @@ typedef struct _IFIMETRICS #define NB_RESERVED_COLORS 20 // number of fixed colors in system palette -typedef struct _XLATEOBJ +typedef struct _XLATEOBJ { ULONG iUniq; ULONG flXlate; @@ -641,7 +641,7 @@ typedef struct _PATHOBJ ULONG cCurves; } PATHOBJ, *PPATHOBJ; -typedef struct _SURFOBJ +typedef struct _SURFOBJ { DHSURF dhsurf; HSURF hsurf; @@ -1204,11 +1204,15 @@ EngMapFontFile EngMapModule EngMarkBandingSurface EngMovePointer -EngMulDiv EngMultiByteToUnicodeN EngMultiByteToWideChar */ +INT STDCALL EngMulDiv( + INT nMultiplicand, + INT nMultiplier, + INT nDivisor); + BOOL STDCALL EngPaint(IN SURFOBJ *Surface, IN CLIPOBJ *ClipRegion, diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index 68214c23025..6e26f1fe058 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.28 2001/05/03 06:13:05 ekohl Exp $ +/* $Id: stubs.c,v 1.29 2002/07/18 21:49:58 ei Exp $ * * KERNEL32.DLL stubs (unimplemented functions) * Remove from this file, if you implement them. @@ -375,7 +375,7 @@ GetComputerNameW ( { WCHAR Name [MAX_COMPUTERNAME_LENGTH + 1]; DWORD Size = 0; - + /* * FIXME: get the computer's name from * the registry. @@ -872,16 +872,58 @@ LoadModule ( } -int -STDCALL -MulDiv ( - int nNumber, - int nNumerator, - int nDenominator - ) +/*********************************************************************** + * MulDiv (KERNEL32.@) + * RETURNS + * Result of multiplication and division + * -1: Overflow occurred or Divisor was 0 + */ + +//FIXME! move to correct file +INT STDCALL MulDiv( + INT nMultiplicand, + INT nMultiplier, + INT nDivisor) { - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; +#if SIZEOF_LONG_LONG >= 8 + long long ret; + + if (!nDivisor) return -1; + + /* We want to deal with a positive divisor to simplify the logic. */ + if (nDivisor < 0) + { + nMultiplicand = - nMultiplicand; + nDivisor = -nDivisor; + } + + /* If the result is positive, we "add" to round. else, we subtract to round. */ + if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) || + ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) ) + ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor; + else + ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor; + + if ((ret > 2147483647) || (ret < -2147483647)) return -1; + return ret; +#else + if (!nDivisor) return -1; + + /* We want to deal with a positive divisor to simplify the logic. */ + if (nDivisor < 0) + { + nMultiplicand = - nMultiplicand; + nDivisor = -nDivisor; + } + + /* If the result is positive, we "add" to round. else, we subtract to round. */ + if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) || + ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) ) + return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor; + + return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor; + +#endif } @@ -901,17 +943,17 @@ MulDiv ( * MB_COMPOSITE * MB_ERR_INVALID_CHARS * MB_USEGLYPHCHARS - * + * * lpMultiByteStr * Input buffer; - * + * * cchMultiByte * Size of MultiByteStr, or -1 if MultiByteStr is * NULL terminated; - * + * * lpWideCharStr * Output buffer; - * + * * cchWideChar * Size (in WCHAR unit) of WideCharStr, or 0 * if the caller just wants to know how large @@ -924,7 +966,7 @@ MulDiv ( * * NOTE * A raw converter for now. It assumes lpMultiByteStr is - * NEVER multi-byte (that is each input character is + * NEVER multi-byte (that is each input character is * 8-bit ASCII) and is ALWAYS NULL terminated. * FIXME-FIXME-FIXME-FIXME */ @@ -1004,7 +1046,7 @@ MultiByteToWideChar ( for ( cchConverted = 0, r = (PCHAR) lpMultiByteStr, w = (PWCHAR) lpWideCharStr; - + ((*r) && (cchConverted < cchWideChar)); r++, diff --git a/reactos/ntoskrnl/include/internal/safe.h b/reactos/ntoskrnl/include/internal/safe.h index 35bbfe5468f..d20c7a7fd5c 100644 --- a/reactos/ntoskrnl/include/internal/safe.h +++ b/reactos/ntoskrnl/include/internal/safe.h @@ -4,9 +4,9 @@ NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes); NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes); -NTSTATUS +NTSTATUS STDCALL MmCopyFromCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes); -NTSTATUS +NTSTATUS STDCALL MmCopyToCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes); NTSTATUS diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 0e76cc053b8..e47ad83da14 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.136 2002/07/18 18:15:09 ekohl Exp $ +; $Id: ntoskrnl.def,v 1.137 2002/07/18 21:49:59 ei Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -474,6 +474,8 @@ MmAllocateContiguousMemory@12 MmAllocateNonCachedMemory@4 MmBuildMdlForNonPagedPool@4 MmCanFileBeTruncated@8 +MmCopyFromCaller@12 +MmCopyToCaller@12 MmCreateMdl@12 MmCreateSection@32 MmDbgTranslatePhysicalAddress@8 diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index 7b1ed43b87e..b988e5fc452 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.122 2002/07/18 18:15:09 ekohl Exp $ +; $Id: ntoskrnl.edf,v 1.123 2002/07/18 21:49:59 ei Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -474,6 +474,8 @@ MmAllocateContiguousMemory=MmAllocateContiguousMemory@12 MmAllocateNonCachedMemory=MmAllocateNonCachedMemory@4 MmBuildMdlForNonPagedPool=MmBuildMdlForNonPagedPool@4 MmCanFileBeTruncated=MmCanFileBeTruncated@8 +MmCopyFromCaller=MmCopyFromCaller@12 +MmCopyToCaller=MmCopyToCaller@12 MmCreateMdl=MmCreateMdl@12 MmCreateSection=MmCreateSection@32 MmDbgTranslatePhysicalAddress=MmDbgTranslatePhysicalAddress@8 diff --git a/reactos/ntoskrnl/rtl/mem.c b/reactos/ntoskrnl/rtl/mem.c index a2d9df0ab7c..721fcda637d 100644 --- a/reactos/ntoskrnl/rtl/mem.c +++ b/reactos/ntoskrnl/rtl/mem.c @@ -1,4 +1,4 @@ -/* $Id: mem.c,v 1.13 2002/05/14 21:19:21 dwelch Exp $ +/* $Id: mem.c,v 1.14 2002/07/18 21:49:59 ei Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -19,7 +19,7 @@ /* FUNCTIONS *****************************************************************/ -NTSTATUS +NTSTATUS STDCALL MmCopyToCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes) { NTSTATUS Status; @@ -40,7 +40,7 @@ MmCopyToCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes) } } -NTSTATUS +NTSTATUS STDCALL MmCopyFromCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes) { NTSTATUS Status;