Synchronize with trunk r58528.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 16 Mar 2013 22:10:42 +0000 (22:10 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 16 Mar 2013 22:10:42 +0000 (22:10 +0000)
svn path=/branches/ros-csrss/; revision=58529

472 files changed:
1  2 
base/applications/calc/winmain.c
base/applications/cmdutils/dbgprint/dbgprint.c
base/applications/cmdutils/hostname/hostname.c
base/applications/games/winmine/main.c
base/applications/mscutils/eventvwr/eventvwr.c
base/applications/rapps/rapps/bittorrent.txt
base/applications/rapps/rapps/firefox5.txt
base/applications/rapps/rapps/kdewin.txt
base/applications/rapps/rapps/libreoffice.txt
base/applications/rapps/rapps/mirandaim.txt
base/applications/rapps/rapps/mirc.txt
base/applications/rapps/rapps/mono2.txt
base/applications/rapps/rapps/opera.txt
base/applications/rapps/rapps/scite.txt
base/applications/rapps/rapps/seamonkey.txt
base/applications/rapps/rapps/sumatrapdf.txt
base/applications/rapps/rapps/thunderbird5.txt
base/applications/rapps/rapps/utorrent.txt
base/applications/sc/print.c
base/applications/setup16/main.c
base/applications/shutdown/misc.c
base/applications/sndvol32/misc.c
base/applications/sndvol32/mixer.c
base/applications/sndvol32/sndvol32.c
base/applications/taskmgr/procpage.c
base/services/audiosrv/main.c
base/services/eventlog/eventlog.c
base/setup/reactos/reactos.c
base/setup/usetup/bootsup.h
base/setup/usetup/drivesup.c
base/setup/usetup/drivesup.h
base/setup/usetup/errorcode.h
base/setup/usetup/filequeue.h
base/setup/usetup/filesup.h
base/setup/usetup/format.h
base/setup/usetup/genlist.h
base/setup/usetup/inicache.c
base/setup/usetup/progress.h
base/setup/usetup/registry.h
base/setup/usetup/settings.h
base/setup/welcome/lang/ru-RU.rc
base/setup/welcome/welcome.c
base/shell/cmd/window.c
base/system/services/driver.c
base/system/services/lock.c
base/system/winlogon/setup.h
boot/bootdata/hivesft.inf
boot/freeldr/freeldr/inifile/parse.c
dll/cpl/access/access.c
dll/cpl/access/display.c
dll/cpl/access/general.c
dll/cpl/access/keyboard.c
dll/cpl/access/mouse.c
dll/cpl/access/sound.c
dll/cpl/appwiz/createlink.c
dll/cpl/desk/advappdlg.c
dll/cpl/desk/background.c
dll/cpl/desk/desk.c
dll/cpl/desk/dibitmap.c
dll/cpl/intl/currency.c
dll/cpl/intl/date.c
dll/cpl/intl/generalp.c
dll/cpl/intl/inplocale.c
dll/cpl/intl/intl.c
dll/cpl/intl/numbers.c
dll/cpl/intl/sort.c
dll/cpl/liccpa/liccpa.c
dll/cpl/liccpa/liccpa.rc
dll/cpl/main/keyboard.c
dll/cpl/main/main.c
dll/cpl/main/mouse.c
dll/cpl/mmsys/sounds.c
dll/cpl/mmsys/volume.c
dll/cpl/odbccp32/odbccp32.c
dll/cpl/powercfg/advanced.c
dll/cpl/powercfg/alarms.c
dll/cpl/powercfg/hibernate.c
dll/cpl/powercfg/powercfg.c
dll/cpl/powercfg/powershemes.c
dll/cpl/usrmgr/extra.c
dll/cpl/usrmgr/usrmgr.c
dll/directx/d3d8/d3d8.rc
dll/directx/d3d9/d3d9.rc
dll/directx/ddraw/Clipper/clipper_main.c
dll/directx/ddraw/Clipper/clipper_stubs.c
dll/directx/ddraw/Color/color_stubs.c
dll/directx/ddraw/Ddraw/GetCaps.c
dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c
dll/directx/ddraw/Ddraw/callbacks_dd_hel.c
dll/directx/ddraw/Ddraw/ddraw_displaymode.c
dll/directx/ddraw/Ddraw/ddraw_main.c
dll/directx/ddraw/Ddraw/ddraw_setcooperativelevel.c
dll/directx/ddraw/Ddraw/ddraw_stubs.c
dll/directx/ddraw/Gamma/gamma_stubs.c
dll/directx/ddraw/Kernel/kernel_stubs.c
dll/directx/ddraw/Palette/createpalette.c
dll/directx/ddraw/Palette/palette.c
dll/directx/ddraw/Palette/palette_stubs.c
dll/directx/ddraw/Surface/callbacks_surf_hel.c
dll/directx/ddraw/Surface/createsurface.c
dll/directx/ddraw/Surface/surface_main.c
dll/directx/ddraw/Surface/surface_stubs.c
dll/directx/ddraw/Videoport/videoport_stubs.c
dll/directx/ddraw/cleanup.c
dll/directx/ddraw/ddraw.rc
dll/directx/ddraw/main.c
dll/directx/ddraw/startup.c
dll/shellext/slayer/slayer.c
dll/win32/aclui/aclui.c
dll/win32/aclui/checklist.c
dll/win32/aclui/misc.c
dll/win32/aclui/sidcache.c
dll/win32/advapi32/misc/dllmain.c
dll/win32/advapi32/sec/ac.c
dll/win32/advapi32/sec/audit.c
dll/win32/advapi32/sec/sec.c
dll/win32/advapi32/sec/trustee.c
dll/win32/advapi32/service/scm.c
dll/win32/advapi32/token/privilege.c
dll/win32/comctl32/comctl32undoc.c
dll/win32/comctl32/datetime.c
dll/win32/comctl32/dpa.c
dll/win32/comctl32/imagelist.c
dll/win32/comctl32/listview.c
dll/win32/comctl32/monthcal.c
dll/win32/comctl32/propsheet.c
dll/win32/comctl32/rebar.c
dll/win32/comctl32/status.c
dll/win32/comctl32/toolbar.c
dll/win32/comctl32/tooltips.c
dll/win32/comctl32/treeview.c
dll/win32/comctl32/updown.c
dll/win32/devmgr/devprblm.c
dll/win32/devmgr/hwpage.c
dll/win32/devmgr/misc.c
dll/win32/dhcpcsvc/dhcp/api.c
dll/win32/dhcpcsvc/dhcp/pipe.c
dll/win32/hid/hid.c
dll/win32/hid/stubs.c
dll/win32/iprtprio/iprtprio.rc
dll/win32/kernel32/client/dosdev.c
dll/win32/kernel32/client/environ.c
dll/win32/kernel32/client/except.c
dll/win32/kernel32/client/file/backup.c
dll/win32/kernel32/client/file/cnotify.c
dll/win32/kernel32/client/file/copy.c
dll/win32/kernel32/client/file/create.c
dll/win32/kernel32/client/file/delete.c
dll/win32/kernel32/client/file/dir.c
dll/win32/kernel32/client/file/fileinfo.c
dll/win32/kernel32/client/file/hardlink.c
dll/win32/kernel32/client/file/iocompl.c
dll/win32/kernel32/client/file/lfile.c
dll/win32/kernel32/client/file/lock.c
dll/win32/kernel32/client/file/mailslot.c
dll/win32/kernel32/client/file/move.c
dll/win32/kernel32/client/file/rw.c
dll/win32/kernel32/client/file/tape.c
dll/win32/kernel32/client/file/volume.c
dll/win32/kernel32/client/job.c
dll/win32/kernel32/client/time.c
dll/win32/kernel32/client/toolhelp.c
dll/win32/kernel32/wine/lzexpand.c
dll/win32/kernel32/wine/muldiv.c
dll/win32/kernel32/wine/timezone.c
dll/win32/kernel32/winnls/string/nls.c
dll/win32/lsasrv/database.c
dll/win32/msgina/stubs.c
dll/win32/msvcrt/msvcrt.spec
dll/win32/mswsock/extensions.c
dll/win32/mswsock/stubs.c
dll/win32/ntmarta/ntmarta.c
dll/win32/psapi/internal.h
dll/win32/psapi/malloc.c
dll/win32/psapi/psapi.c
dll/win32/samlib/dllmain.c
dll/win32/samlib/samlib.c
dll/win32/samsrv/CMakeLists.txt
dll/win32/samsrv/alias.c
dll/win32/samsrv/database.c
dll/win32/samsrv/group.c
dll/win32/samsrv/samrpc.c
dll/win32/samsrv/samsrv.c
dll/win32/samsrv/samsrv.h
dll/win32/samsrv/samsrv.spec
dll/win32/samsrv/setup.c
dll/win32/samsrv/user.c
dll/win32/secur32/dllmain.c
dll/win32/smdll/dllmain.c
dll/win32/smdll/query.c
dll/win32/smdll/readme.txt
dll/win32/syssetup/dllmain.c
dll/win32/syssetup/install.c
dll/win32/userenv/desktop.c
dll/win32/userenv/directory.c
dll/win32/userenv/environment.c
dll/win32/userenv/internal.h
dll/win32/userenv/misc.c
dll/win32/userenv/registry.c
dll/win32/userenv/resources.h
dll/win32/userenv/setup.c
dll/win32/userenv/userenv.c
dll/win32/winfax/winfax.c
dll/win32/winscard/winscard.c
dll/win32/winscard/winscard.rc
dll/win32/winspool/stubs.c
dll/win32/wsock32/stubs.c
drivers/base/beep/beep.rc
drivers/base/bootvid/bootvid.rc
drivers/base/kdcom/kdcom.rc
drivers/base/null/null.rc
drivers/bus/acpi/acpi.rc
drivers/bus/acpi/acpienum.c
drivers/bus/isapnp/isapnp.rc
drivers/bus/pci/pci.rc
drivers/bus/pci/pcidef.h
drivers/filesystems/cdfs/cdfs.c
drivers/filesystems/cdfs/cdfs.rc
drivers/filesystems/cdfs/cleanup.c
drivers/filesystems/cdfs/close.c
drivers/filesystems/cdfs/common.c
drivers/filesystems/cdfs/create.c
drivers/filesystems/cdfs/dirctl.c
drivers/filesystems/cdfs/fcb.c
drivers/filesystems/cdfs/finfo.c
drivers/filesystems/cdfs/misc.c
drivers/filesystems/cdfs/rw.c
drivers/filesystems/cdfs/volinfo.c
drivers/filesystems/ext2/ext2fs.rc
drivers/filesystems/msfs/msfs.rc
drivers/filesystems/mup/create.c
drivers/filesystems/mup/mup.c
drivers/filesystems/mup/mup.rc
drivers/input/kbdclass/kbdclass.rc
drivers/input/mouclass/mouclass.rc
drivers/input/sermouse/sermouse.rc
drivers/multimedia/audio/mpu401_nt4/mpu401.rc
drivers/multimedia/audio/sndblst.old/sndblst.rc
drivers/multimedia/audio/sndblst_sys/sndblst.rc
drivers/multimedia/audio/sound/sb16.c
drivers/multimedia/audio/sound/sb16.rc
drivers/network/afd/afd.rc
drivers/network/afd/afd/bind.c
drivers/network/afd/afd/connect.c
drivers/network/afd/afd/context.c
drivers/network/afd/afd/info.c
drivers/network/afd/afd/listen.c
drivers/network/afd/afd/lock.c
drivers/network/afd/afd/main.c
drivers/network/afd/afd/read.c
drivers/network/afd/afd/tdiconn.c
drivers/network/afd/include/afd.h
drivers/network/dd/ne2000/ne2000.rc
drivers/network/dd/pcnet/pcnet.rc
drivers/network/lan/lan.rc
drivers/network/ndis/ndis.rc
drivers/network/tdi/cte/string.c
drivers/network/tdi/misc/tdi.rc
drivers/network/tdi/tdi/handler.c
drivers/network/tdi/tdi/obsolete.c
drivers/network/tdi/tdi/stubs.c
drivers/parallel/parallel/parallel.c
drivers/parallel/parallel/parallel.rc
drivers/serial/serenum/serenum.rc
drivers/serial/serial/serial.rc
drivers/setup/blue/blue.rc
drivers/storage/class/cdrom/cdrom.rc
drivers/storage/class/class2/class2.rc
drivers/storage/class/disk/disk.rc
drivers/storage/class/include/class2.h
drivers/storage/floppy/floppy.rc
drivers/storage/ide/atapi/atapi.rc
drivers/wmi/wmilib.rc
hal/halppc/generic/display.c
hal/halppc/generic/dma.c
hal/halppc/generic/enum.c
hal/halppc/generic/font.c
hal/halppc/generic/irql.c
hal/halppc/generic/isa.c
hal/halppc/generic/portio.c
hal/halppc/generic/processor.c
hal/halppc/generic/reboot.c
hal/halppc/include/halirq.h
hal/halppc/up/halinit_up.c
hal/halx86/apic/halinit_apic.c
hal/halx86/include/halirq.h
hal/halx86/mp/apic.c
hal/halx86/mp/halinit_mp.c
hal/halx86/mp/ioapic.c
hal/halx86/mp/ipi_mp.c
hal/halx86/mp/mpconfig.c
hal/halx86/mp/processor_mp.c
hal/halx86/up/halinit_mini.c
hal/halx86/up/halinit_up.c
hal/halx86/xbox/halinit_xbox.c
hal/halx86/xbox/halxbox.h
hal/halx86/xbox/part_xbox.c
include/crt/conio.h
include/crt/direct.h
include/crt/errno.h
include/crt/float.h
include/crt/io.h
include/crt/locale.h
include/crt/malloc.h
include/crt/math.h
include/crt/mbctype.h
include/crt/sec_api/stdlib_s.h
include/crt/stdlib.h
include/ddk/ntpoapi.h
include/psdk/batclass.h
include/psdk/commctrl.h
include/psdk/ddkernel.h
include/psdk/dmemmgr.h
include/psdk/dvp.h
include/psdk/evntprov.h
include/psdk/ntddstor.h
include/psdk/objerror.h
include/psdk/polarity.h
include/psdk/sal.h
include/psdk/winnls.h
include/reactos/libs/epsapi/epsapi.h
include/reactos/libs/syssetup/syssetup.h
include/reactos/services/services.h
include/reactos/subsys/lsass/lsass.h
include/reactos/winlogon.h
lib/3rdparty/adns/README.html
lib/3rdparty/freetype/README.ROS
lib/epsapi/enum/drivers.c
lib/epsapi/enum/modules.c
lib/epsapi/enum/processes.c
lib/fslib/vfatlib/check/vfat.h
lib/sdk/crt/crt.cmake
lib/sdk/crt/except/i386/chkstk_asm.s
lib/sdk/crt/except/powerpc/chkstk_asm.s
lib/sdk/crt/libcntpr.cmake
lib/sdk/crt/math/adjust.c
lib/sdk/crt/mem/i386/memchr_asm.s
lib/sdk/crt/mem/i386/memset_asm.s
lib/sdk/crt/mem/memccpy.c
lib/sdk/crt/mem/memchr.c
lib/sdk/crt/mem/memcmp.c
lib/sdk/crt/mem/memset.c
lib/sdk/crt/printf/_snprintf_s.c
lib/sdk/crt/printf/_snwprintf_s.c
lib/sdk/crt/printf/_sxprintf.c
lib/sdk/crt/printf/_vsnprintf_s.c
lib/sdk/crt/printf/_vsnwprintf_s.c
lib/sdk/crt/printf/sprintf_s.c
lib/sdk/crt/printf/swprintf_s.c
lib/sdk/crt/printf/vsprintf_s.c
lib/sdk/crt/printf/vswprintf_s.c
lib/sdk/crt/setjmp/i386/setjmp.s
lib/sdk/crt/stdlib/makepath.c
lib/sdk/crt/stdlib/wmakpath.c
lib/sdk/crt/string/_splitpath.c
lib/sdk/crt/string/_splitpath_s.c
lib/sdk/crt/string/_tsplitpath_x.h
lib/sdk/crt/string/_wsplitpath.c
lib/sdk/crt/string/_wsplitpath_s.c
lib/sdk/crt/string/i386/strcat_asm.s
lib/sdk/crt/string/i386/strchr_asm.s
lib/sdk/crt/string/i386/strcmp_asm.s
lib/sdk/crt/string/i386/strcpy_asm.s
lib/sdk/crt/string/i386/strlen_asm.s
lib/sdk/crt/string/i386/strncat_asm.s
lib/sdk/crt/string/i386/strncmp_asm.s
lib/sdk/crt/string/i386/strncpy_asm.s
lib/sdk/crt/string/i386/strnlen_asm.s
lib/sdk/crt/string/i386/strrchr_asm.s
lib/sdk/crt/string/i386/tchar.h
lib/sdk/crt/string/i386/tcscat.inc
lib/sdk/crt/string/i386/tcschr.inc
lib/sdk/crt/string/i386/tcscmp.inc
lib/sdk/crt/string/i386/tcscpy.inc
lib/sdk/crt/string/i386/tcslen.inc
lib/sdk/crt/string/i386/tcsncat.inc
lib/sdk/crt/string/i386/tcsncmp.inc
lib/sdk/crt/string/i386/tcsncpy.inc
lib/sdk/crt/string/i386/tcsnlen.inc
lib/sdk/crt/string/i386/tcsrchr.inc
lib/sdk/crt/string/i386/wcscat_asm.s
lib/sdk/crt/string/i386/wcschr_asm.s
lib/sdk/crt/string/i386/wcscmp_asm.s
lib/sdk/crt/string/i386/wcscpy_asm.s
lib/sdk/crt/string/i386/wcslen_asm.s
lib/sdk/crt/string/i386/wcsncat_asm.s
lib/sdk/crt/string/i386/wcsncmp_asm.s
lib/sdk/crt/string/i386/wcsncpy_asm.s
lib/sdk/crt/string/i386/wcsnlen_asm.s
lib/sdk/crt/string/i386/wcsrchr_asm.s
lib/sdk/crt/string/strcat.c
lib/sdk/crt/string/strchr.c
lib/sdk/crt/string/strcmp.c
lib/sdk/crt/string/strcpy.c
lib/sdk/crt/string/strcspn.c
lib/sdk/crt/string/strlen.c
lib/sdk/crt/string/strncat.c
lib/sdk/crt/string/strncmp.c
lib/sdk/crt/string/strncpy.c
lib/sdk/crt/string/strnlen.c
lib/sdk/crt/string/strpbrk.c
lib/sdk/crt/string/strrchr.c
lib/sdk/crt/string/strspn.c
lib/sdk/crt/string/strxspn.h
lib/sdk/crt/string/tcscat.h
lib/sdk/crt/string/tcschr.h
lib/sdk/crt/string/tcscmp.h
lib/sdk/crt/string/tcscpy.h
lib/sdk/crt/string/tcslen.h
lib/sdk/crt/string/tcsncat.h
lib/sdk/crt/string/tcsncmp.h
lib/sdk/crt/string/tcsncpy.h
lib/sdk/crt/string/tcsnlen.h
lib/sdk/crt/string/tcsrchr.h
lib/sdk/crt/string/wcscat.c
lib/sdk/crt/string/wcschr.c
lib/sdk/crt/string/wcscmp.c
lib/sdk/crt/string/wcscpy.c
lib/sdk/crt/string/wcslen.c
lib/sdk/crt/string/wcsncat.c
lib/sdk/crt/string/wcsncmp.c
lib/sdk/crt/string/wcsncpy.c
lib/sdk/crt/string/wcsnlen.c
lib/sdk/crt/string/wcsrchr.c
lib/sdk/crt/string/witow.c
lib/smlib/compses.c
lib/smlib/connect.c
lib/smlib/execpgm.c
lib/smlib/lookupss.c
media/doc/README.WINE
ntoskrnl/include/internal/i386/ke.h
ntoskrnl/include/internal/mm.h
ntoskrnl/kdbg/kdb.h
ntoskrnl/kdbg/kdb_cli.c
ntoskrnl/ke/i386/thrdini.c
ntoskrnl/ke/i386/v86vdm.c
ntoskrnl/ke/powerpc/ppc_irq.c
ntoskrnl/mm/ARM3/expool.c
ntoskrnl/mm/ARM3/procsup.c
ntoskrnl/mm/marea.c
ntoskrnl/ps/kill.c
subsystems/ntvdm/ntvdm.c
subsystems/ntvdm/ntvdm.rc
win32ss/drivers/font/ftfd/rosglue.c
win32ss/gdi/gdi32/main/dllmain.c
win32ss/gdi/gdi32/misc/hacks.c
win32ss/gdi/gdi32/misc/heap.c
win32ss/gdi/gdi32/misc/historic.c
win32ss/gdi/gdi32/objects/eng.c
win32ss/gdi/gdi32/objects/path.c
win32ss/reactx/dxg/dxg.rc
win32ss/reactx/dxgthk/dxgthk.rc
win32ss/user/ntuser/desktop.c
win32ss/user/ntuser/vis.h
win32ss/user/ntuser/winpos.c
win32ss/user/ntuser/winsta.c
win32ss/user/ntuser/winsta.h
win32ss/user/user32/include/regcontrol.h
win32ss/user/user32/misc/desktop.c
win32ss/user/user32/misc/object.c
win32ss/user/user32/misc/timer.c
win32ss/user/user32/misc/winsta.c
win32ss/user/user32/windows/accel.c
win32ss/user/user32/windows/caret.c
win32ss/user/user32/windows/clipboard.c
win32ss/user/user32/windows/dc.c
win32ss/user/user32/windows/font.c
win32ss/user/user32/windows/rect.c
win32ss/user/user32/windows/text.c
win32ss/user/winsrv/lang/es-ES.rc
win32ss/user/winsrv/shutdown.c
win32ss/win32k.rc

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 19be52f,0000000..bf6c991
mode 100644,000000..100644
--- /dev/null
@@@ -1,489 -1,0 +1,488 @@@
- /* $Id: dosdev.c 54326 2011-11-07 00:18:13Z ion $
-  *
++/*
 + * COPYRIGHT:       See COPYING in the top level directory
 + * PROJECT:         ReactOS system libraries
 + * FILE:            lib/kernel32/file/dosdev.c
 + * PURPOSE:         Dos device functions
 + * PROGRAMMER:      Ariadne (ariadne@xs4all.nl)
 + * UPDATE HISTORY:
 + *                  Created 01/11/98
 + */
 +
 +/* INCLUDES ******************************************************************/
 +
 +#include <k32.h>
 +#define NDEBUG
 +#include <debug.h>
 +#include <dbt.h>
 +DEBUG_CHANNEL(kernel32file);
 +
 +/* FUNCTIONS *****************************************************************/
 +
 +/*
 + * @implemented
 + */
 +BOOL
 +WINAPI
 +DefineDosDeviceA(
 +    DWORD dwFlags,
 +    LPCSTR lpDeviceName,
 +    LPCSTR lpTargetPath
 +    )
 +{
 +    UNICODE_STRING DeviceNameU = {0};
 +    UNICODE_STRING TargetPathU = {0};
 +    BOOL Result;
 +
 +    if (lpDeviceName &&
 +        ! RtlCreateUnicodeStringFromAsciiz(&DeviceNameU,
 +        (LPSTR)lpDeviceName))
 +    {
 +        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 +        return 0;
 +    }
 +
 +    if (lpTargetPath &&
 +        ! RtlCreateUnicodeStringFromAsciiz(&TargetPathU,
 +        (LPSTR)lpTargetPath))
 +    {
 +        if (DeviceNameU.Buffer)
 +        {
 +            RtlFreeHeap(RtlGetProcessHeap (),
 +                        0,
 +                        DeviceNameU.Buffer);
 +        }
 +        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 +        return 0;
 +    }
 +
 +    Result = DefineDosDeviceW(dwFlags,
 +                              DeviceNameU.Buffer,
 +                              TargetPathU.Buffer);
 +
 +    if (TargetPathU.Buffer)
 +    {
 +        RtlFreeHeap(RtlGetProcessHeap (),
 +                    0,
 +                    TargetPathU.Buffer);
 +    }
 +
 +    if (DeviceNameU.Buffer)
 +    {
 +        RtlFreeHeap(RtlGetProcessHeap (),
 +                    0,
 +                    DeviceNameU.Buffer);
 +    }
 +    return Result;
 +}
 +
 +
 +/*
 + * @implemented
 + */
 +BOOL
 +WINAPI
 +DefineDosDeviceW(
 +    DWORD dwFlags,
 +    LPCWSTR lpDeviceName,
 +    LPCWSTR lpTargetPath
 +    )
 +{
 +    ULONG ArgumentCount;
 +    ULONG BufferSize;
 +    BASE_API_MESSAGE ApiMessage;
 +    PBASE_DEFINE_DOS_DEVICE DefineDosDeviceRequest = &ApiMessage.Data.DefineDosDeviceRequest;
 +    PCSR_CAPTURE_BUFFER CaptureBuffer;
 +    NTSTATUS Status;
 +    UNICODE_STRING NtTargetPathU;
 +    UNICODE_STRING DeviceNameU;
 +    UNICODE_STRING DeviceUpcaseNameU;
 +    HANDLE hUser32;
 +    DEV_BROADCAST_VOLUME dbcv;
 +    BOOL Result = TRUE;
 +    DWORD dwRecipients;
 +    typedef long (WINAPI *BSM_type)(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
 +    BSM_type BSM_ptr;
 +
 +    if ( (dwFlags & 0xFFFFFFF0) ||
 +        ((dwFlags & DDD_EXACT_MATCH_ON_REMOVE) &&
 +        ! (dwFlags & DDD_REMOVE_DEFINITION)) )
 +    {
 +        SetLastError(ERROR_INVALID_PARAMETER);
 +        return FALSE;
 +    }
 +
 +    ArgumentCount = 1;
 +    BufferSize = 0;
 +    if (! lpTargetPath)
 +    {
 +        RtlInitUnicodeString(&NtTargetPathU,
 +                             NULL);
 +    }
 +    else
 +    {
 +        if (dwFlags & DDD_RAW_TARGET_PATH)
 +        {
 +            RtlInitUnicodeString(&NtTargetPathU,
 +                                 lpTargetPath);
 +        }
 +        else
 +        {
 +            if (! RtlDosPathNameToNtPathName_U(lpTargetPath,
 +                                               &NtTargetPathU,
 +                                               0,
 +                                               0))
 +            {
 +                WARN("RtlDosPathNameToNtPathName_U() failed\n");
 +                BaseSetLastNTError(STATUS_OBJECT_NAME_INVALID);
 +                return FALSE;
 +            }
 +        }
 +        ArgumentCount = 2;
 +        BufferSize += NtTargetPathU.Length;
 +    }
 +
 +    RtlInitUnicodeString(&DeviceNameU,
 +                         lpDeviceName);
 +    RtlUpcaseUnicodeString(&DeviceUpcaseNameU,
 +                           &DeviceNameU,
 +                           TRUE);
 +    BufferSize += DeviceUpcaseNameU.Length;
 +
 +    CaptureBuffer = CsrAllocateCaptureBuffer(ArgumentCount,
 +                                             BufferSize);
 +    if (! CaptureBuffer)
 +    {
 +        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 +        Result = FALSE;
 +    }
 +    else
 +    {
 +        DefineDosDeviceRequest->dwFlags = dwFlags;
 +
 +        CsrCaptureMessageBuffer(CaptureBuffer,
 +                                (PVOID)DeviceUpcaseNameU.Buffer,
 +                                DeviceUpcaseNameU.Length,
 +                                (PVOID*)&DefineDosDeviceRequest->DeviceName.Buffer);
 +
 +        DefineDosDeviceRequest->DeviceName.Length =
 +            DeviceUpcaseNameU.Length;
 +        DefineDosDeviceRequest->DeviceName.MaximumLength =
 +            DeviceUpcaseNameU.Length;
 +
 +        if (NtTargetPathU.Buffer)
 +        {
 +            CsrCaptureMessageBuffer(CaptureBuffer,
 +                                    (PVOID)NtTargetPathU.Buffer,
 +                                    NtTargetPathU.Length,
 +                                    (PVOID*)&DefineDosDeviceRequest->TargetName.Buffer);
 +        }
 +        DefineDosDeviceRequest->TargetName.Length =
 +            NtTargetPathU.Length;
 +        DefineDosDeviceRequest->TargetName.MaximumLength =
 +            NtTargetPathU.Length;
 +
 +        Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
 +                                     CaptureBuffer,
 +                                     CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepDefineDosDevice),
 +                                     sizeof(BASE_DEFINE_DOS_DEVICE));
 +        CsrFreeCaptureBuffer(CaptureBuffer);
 +
 +        if (!NT_SUCCESS(Status))
 +        {
 +            WARN("CsrClientCallServer() failed (Status %lx)\n", Status);
 +            BaseSetLastNTError(Status);
 +            Result = FALSE;
 +        }
 +        else
 +        {
 +            if (! (dwFlags & DDD_NO_BROADCAST_SYSTEM) &&
 +                DeviceUpcaseNameU.Length == 2 * sizeof(WCHAR) &&
 +                DeviceUpcaseNameU.Buffer[1] == L':' &&
 +                ( (DeviceUpcaseNameU.Buffer[0] - L'A') < 26 ))
 +            {
 +                hUser32 = LoadLibraryA("user32.dll");
 +                if (hUser32)
 +                {
 +                    BSM_ptr = (BSM_type)
 +                        GetProcAddress(hUser32, "BroadcastSystemMessageW");
 +                    if (BSM_ptr)
 +                    {
 +                        dwRecipients = BSM_APPLICATIONS;
 +                        dbcv.dbcv_size = sizeof(DEV_BROADCAST_VOLUME);
 +                        dbcv.dbcv_devicetype = DBT_DEVTYP_VOLUME;
 +                        dbcv.dbcv_reserved = 0;
 +                        dbcv.dbcv_unitmask |= 
 +                            (1 << (DeviceUpcaseNameU.Buffer[0] - L'A'));
 +                        dbcv.dbcv_flags = DBTF_NET;
 +                        (void) BSM_ptr(BSF_SENDNOTIFYMESSAGE | BSF_FLUSHDISK,
 +                                       &dwRecipients,
 +                                       WM_DEVICECHANGE,
 +                                       (WPARAM)DBT_DEVICEARRIVAL,
 +                                       (LPARAM)&dbcv);
 +                    }
 +                    FreeLibrary(hUser32);
 +                }
 +            }
 +        }
 +    }
 +
 +    if (NtTargetPathU.Buffer)
 +    {
 +        RtlFreeHeap(RtlGetProcessHeap(),
 +                    0,
 +                    NtTargetPathU.Buffer);
 +    }
 +    RtlFreeUnicodeString(&DeviceUpcaseNameU);
 +    return Result;
 +}
 +
 +
 +/*
 + * @implemented
 + */
 +DWORD
 +WINAPI
 +QueryDosDeviceA(
 +    LPCSTR lpDeviceName,
 +    LPSTR lpTargetPath,
 +    DWORD ucchMax
 +    )
 +{
 +  UNICODE_STRING DeviceNameU;
 +  UNICODE_STRING TargetPathU;
 +  ANSI_STRING TargetPathA;
 +  DWORD Length;
 +  DWORD CurrentLength;
 +  PWCHAR Buffer;
 +
 +  if (lpDeviceName)
 +  {
 +    if (!RtlCreateUnicodeStringFromAsciiz (&DeviceNameU,
 +                                         (LPSTR)lpDeviceName))
 +    {
 +      SetLastError (ERROR_NOT_ENOUGH_MEMORY);
 +      return 0;
 +    }
 +  }
 +  Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
 +                          0,
 +                          ucchMax * sizeof(WCHAR));
 +  if (Buffer == NULL)
 +  {
 +    if (lpDeviceName)
 +    {
 +      RtlFreeHeap (RtlGetProcessHeap (),
 +                 0,
 +                 DeviceNameU.Buffer);
 +    }
 +    SetLastError (ERROR_NOT_ENOUGH_MEMORY);
 +    return 0;
 +  }
 +
 +  Length = QueryDosDeviceW (lpDeviceName ? DeviceNameU.Buffer : NULL,
 +                          Buffer,
 +                          ucchMax);
 +  if (Length != 0)
 +  {
 +    TargetPathA.Buffer = lpTargetPath;
 +    TargetPathU.Buffer = Buffer;
 +    ucchMax = Length;
 +
 +    while (ucchMax)
 +    {
 +      CurrentLength = min (ucchMax, MAXUSHORT / 2);
 +      TargetPathU.MaximumLength = TargetPathU.Length = (USHORT)CurrentLength * sizeof(WCHAR);
 +     
 +      TargetPathA.Length = 0;
 +      TargetPathA.MaximumLength = (USHORT)CurrentLength;
 +
 +      RtlUnicodeStringToAnsiString (&TargetPathA,
 +                                  &TargetPathU,
 +                                  FALSE);
 +      ucchMax -= CurrentLength;
 +      TargetPathA.Buffer += TargetPathA.Length;
 +      TargetPathU.Buffer += TargetPathU.Length / sizeof(WCHAR);
 +    }
 +  }
 +
 +  RtlFreeHeap (RtlGetProcessHeap (),
 +             0,
 +             Buffer);
 +  if (lpDeviceName)
 +  {
 +    RtlFreeHeap (RtlGetProcessHeap (),
 +               0,
 +               DeviceNameU.Buffer);
 +  }
 +  return Length;
 +}
 +
 +
 +/*
 + * @implemented
 + */
 +DWORD
 +WINAPI
 +QueryDosDeviceW(
 +    LPCWSTR lpDeviceName,
 +    LPWSTR lpTargetPath,
 +    DWORD ucchMax
 +    )
 +{
 +  POBJECT_DIRECTORY_INFORMATION DirInfo;
 +  OBJECT_ATTRIBUTES ObjectAttributes;
 +  UNICODE_STRING UnicodeString;
 +  HANDLE DirectoryHandle;
 +  HANDLE DeviceHandle;
 +  ULONG ReturnLength;
 +  ULONG NameLength;
 +  ULONG Length;
 +  ULONG Context;
 +  BOOLEAN RestartScan;
 +  NTSTATUS Status;
 +  UCHAR Buffer[512];
 +  PWSTR Ptr;
 +
 +  /* Open the '\??' directory */
 +  RtlInitUnicodeString (&UnicodeString,
 +                      L"\\??");
 +  InitializeObjectAttributes (&ObjectAttributes,
 +                            &UnicodeString,
 +                            OBJ_CASE_INSENSITIVE,
 +                            NULL,
 +                            NULL);
 +  Status = NtOpenDirectoryObject (&DirectoryHandle,
 +                                DIRECTORY_QUERY,
 +                                &ObjectAttributes);
 +  if (!NT_SUCCESS (Status))
 +  {
 +    WARN ("NtOpenDirectoryObject() failed (Status %lx)\n", Status);
 +    BaseSetLastNTError (Status);
 +    return 0;
 +  }
 +
 +  Length = 0;
 +
 +  if (lpDeviceName != NULL)
 +  {
 +    /* Open the lpDeviceName link object */
 +    RtlInitUnicodeString (&UnicodeString,
 +                        (PWSTR)lpDeviceName);
 +    InitializeObjectAttributes (&ObjectAttributes,
 +                              &UnicodeString,
 +                              OBJ_CASE_INSENSITIVE,
 +                              DirectoryHandle,
 +                              NULL);
 +    Status = NtOpenSymbolicLinkObject (&DeviceHandle,
 +                                     SYMBOLIC_LINK_QUERY,
 +                                     &ObjectAttributes);
 +    if (!NT_SUCCESS (Status))
 +    {
 +      WARN ("NtOpenSymbolicLinkObject() failed (Status %lx)\n", Status);
 +      NtClose (DirectoryHandle);
 +      BaseSetLastNTError (Status);
 +      return 0;
 +    }
 +
 +    /* Query link target */
 +    UnicodeString.Length = 0;
 +    UnicodeString.MaximumLength = (USHORT)ucchMax * sizeof(WCHAR);
 +    UnicodeString.Buffer = lpTargetPath;
 +
 +    ReturnLength = 0;
 +    Status = NtQuerySymbolicLinkObject (DeviceHandle,
 +                                      &UnicodeString,
 +                                      &ReturnLength);
 +    NtClose (DeviceHandle);
 +    NtClose (DirectoryHandle);
 +    if (!NT_SUCCESS (Status))
 +    {
 +      WARN ("NtQuerySymbolicLinkObject() failed (Status %lx)\n", Status);
 +      BaseSetLastNTError (Status);
 +      return 0;
 +    }
 +
 +    TRACE ("ReturnLength: %lu\n", ReturnLength);
 +    TRACE ("TargetLength: %hu\n", UnicodeString.Length);
 +    TRACE ("Target: '%wZ'\n", &UnicodeString);
 +
 +    Length = UnicodeString.Length / sizeof(WCHAR);
 +    if (Length < ucchMax)
 +    {
 +      /* Append null-charcter */
 +      lpTargetPath[Length] = UNICODE_NULL;
 +      Length++;
 +    }
 +    else
 +    {
 +      TRACE ("Buffer is too small\n");
 +      BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
 +      return 0;
 +    }
 +  }
 +  else
 +  {
 +    RestartScan = TRUE;
 +    Context = 0;
 +    Ptr = lpTargetPath;
 +    DirInfo = (POBJECT_DIRECTORY_INFORMATION)Buffer;
 +
 +    while (TRUE)
 +    {
 +      Status = NtQueryDirectoryObject (DirectoryHandle,
 +                                     Buffer,
 +                                     sizeof (Buffer),
 +                                     TRUE,
 +                                     RestartScan,
 +                                     &Context,
 +                                     &ReturnLength);
 +      if (!NT_SUCCESS(Status))
 +      {
 +      if (Status == STATUS_NO_MORE_ENTRIES)
 +      {
 +        /* Terminate the buffer */
 +        *Ptr = UNICODE_NULL;
 +        Length++;
 +
 +        Status = STATUS_SUCCESS;
 +      }
 +      else
 +      {
 +        Length = 0;
 +      }
 +      BaseSetLastNTError (Status);
 +      break;
 +      }
 +
 +      if (!wcscmp (DirInfo->TypeName.Buffer, L"SymbolicLink"))
 +      {
 +      TRACE ("Name: '%wZ'\n", &DirInfo->Name);
 +
 +      NameLength = DirInfo->Name.Length / sizeof(WCHAR);
 +      if (Length + NameLength + 1 >= ucchMax)
 +      {
 +        Length = 0;
 +        BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
 +        break;
 +      }
 +
 +      memcpy (Ptr,
 +              DirInfo->Name.Buffer,
 +              DirInfo->Name.Length);
 +      Ptr += NameLength;
 +      Length += NameLength;
 +      *Ptr = UNICODE_NULL;
 +      Ptr++;
 +      Length++;
 +      }
 +
 +      RestartScan = FALSE;
 +    }
 +
 +    NtClose (DirectoryHandle);
 +  }
 +
 +  return Length;
 +}
 +
 +/* EOF */
Simple merge
Simple merge
Simple merge
index af2d0b7,0000000..5ee7513
mode 100644,000000..100644
--- /dev/null
@@@ -1,589 -1,0 +1,588 @@@
- /* $Id: create.c 54326 2011-11-07 00:18:13Z ion $
-  *
++/*
 + * COPYRIGHT:       See COPYING in the top level directory
 + * PROJECT:         ReactOS system libraries
 + * FILE:            lib/kernel32/file/create.c
 + * PURPOSE:         Directory functions
 + * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
 + * UPDATE HISTORY:
 + *                  Created 01/11/98
 + *                  Removed use of SearchPath (not used by Windows)
 + *                  18/08/2002: CreateFileW mess cleaned up (KJK::Hyperion)
 + *                  24/08/2002: removed superfluous DPRINTs (KJK::Hyperion)
 + */
 +
 +/* INCLUDES *****************************************************************/
 +
 +#include <k32.h>
 +#define NDEBUG
 +#include <debug.h>
 +
 +#if DBG
 +DEBUG_CHANNEL(kernel32file);
 +#endif
 +
 +#define SYMLINK_FLAG_RELATIVE   1
 +
 +typedef struct _REPARSE_DATA_BUFFER {
 +    ULONG  ReparseTag;
 +    USHORT ReparseDataLength;
 +    USHORT Reserved;
 +    union {
 +        struct {
 +            USHORT SubstituteNameOffset;
 +            USHORT SubstituteNameLength;
 +            USHORT PrintNameOffset;
 +            USHORT PrintNameLength;
 +            ULONG Flags;
 +            WCHAR PathBuffer[1];
 +        } SymbolicLinkReparseBuffer;
 +        struct {
 +            USHORT SubstituteNameOffset;
 +            USHORT SubstituteNameLength;
 +            USHORT PrintNameOffset;
 +            USHORT PrintNameLength;
 +            WCHAR PathBuffer[1];
 +        } MountPointReparseBuffer;
 +        struct {
 +            UCHAR  DataBuffer[1];
 +        } GenericReparseBuffer;
 +    };
 +} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
 +
 +#define REPARSE_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
 +
 +/* FUNCTIONS ****************************************************************/
 +
 +/*
 + * @implemented
 + */
 +HANDLE WINAPI CreateFileA (LPCSTR                     lpFileName,
 +                          DWORD                       dwDesiredAccess,
 +                          DWORD                       dwShareMode,
 +                          LPSECURITY_ATTRIBUTES       lpSecurityAttributes,
 +                          DWORD                       dwCreationDisposition,
 +                          DWORD                       dwFlagsAndAttributes,
 +                          HANDLE                      hTemplateFile)
 +{
 +   PWCHAR FileNameW;
 +   HANDLE FileHandle;
 +
 +   TRACE("CreateFileA(lpFileName %s)\n",lpFileName);
 +
 +   if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
 +      return INVALID_HANDLE_VALUE;
 +
 +   FileHandle = CreateFileW (FileNameW,
 +                           dwDesiredAccess,
 +                           dwShareMode,
 +                           lpSecurityAttributes,
 +                           dwCreationDisposition,
 +                           dwFlagsAndAttributes,
 +                           hTemplateFile);
 +
 +   return FileHandle;
 +}
 +
 +
 +/*
 + * @implemented
 + */
 +HANDLE WINAPI CreateFileW (LPCWSTR                    lpFileName,
 +                          DWORD                       dwDesiredAccess,
 +                          DWORD                       dwShareMode,
 +                          LPSECURITY_ATTRIBUTES       lpSecurityAttributes,
 +                          DWORD                       dwCreationDisposition,
 +                          DWORD                       dwFlagsAndAttributes,
 +                          HANDLE                      hTemplateFile)
 +{
 +   OBJECT_ATTRIBUTES ObjectAttributes;
 +   IO_STATUS_BLOCK IoStatusBlock;
 +   UNICODE_STRING NtPathU;
 +   LPCWSTR pszConsoleFileName;
 +   HANDLE FileHandle;
 +   NTSTATUS Status;
 +   ULONG FileAttributes, Flags = 0;
 +   PVOID EaBuffer = NULL;
 +   ULONG EaLength = 0;
 +
 +   if (!lpFileName || !lpFileName[0])
 +   {
 +       SetLastError( ERROR_PATH_NOT_FOUND );
 +       return INVALID_HANDLE_VALUE;
 +   }
 +
 +   TRACE("CreateFileW(lpFileName %S)\n",lpFileName);
 +
 +   /* validate & translate the creation disposition */
 +   switch (dwCreationDisposition)
 +     {
 +      case CREATE_NEW:
 +      dwCreationDisposition = FILE_CREATE;
 +      break;
 +
 +      case CREATE_ALWAYS:
 +      dwCreationDisposition = FILE_OVERWRITE_IF;
 +      break;
 +
 +      case OPEN_EXISTING:
 +      dwCreationDisposition = FILE_OPEN;
 +      break;
 +
 +      case OPEN_ALWAYS:
 +      dwCreationDisposition = FILE_OPEN_IF;
 +      break;
 +
 +      case TRUNCATE_EXISTING:
 +      dwCreationDisposition = FILE_OVERWRITE;
 +        break;
 +
 +      default:
 +        SetLastError(ERROR_INVALID_PARAMETER);
 +        return (INVALID_HANDLE_VALUE);
 +     }
 +
 +   /* check for console input/output */
 +   pszConsoleFileName = IntCheckForConsoleFileName(lpFileName, dwDesiredAccess);
 +   if (pszConsoleFileName)
 +   {
 +      return OpenConsoleW(pszConsoleFileName,
 +                          dwDesiredAccess,
 +                          lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE,
 +                          FILE_SHARE_READ | FILE_SHARE_WRITE);
 +   }
 +
 +  /* validate & translate the flags */
 +
 +   /* translate the flags that need no validation */
 +   if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
 +   {
 +      /* yes, nonalert is correct! apc's are not delivered
 +      while waiting for file io to complete */
 +      Flags |= FILE_SYNCHRONOUS_IO_NONALERT;
 +   }
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_WRITE_THROUGH)
 +      Flags |= FILE_WRITE_THROUGH;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING)
 +      Flags |= FILE_NO_INTERMEDIATE_BUFFERING;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_RANDOM_ACCESS)
 +      Flags |= FILE_RANDOM_ACCESS;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_SEQUENTIAL_SCAN)
 +      Flags |= FILE_SEQUENTIAL_ONLY;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE)
 +      Flags |= FILE_DELETE_ON_CLOSE;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_BACKUP_SEMANTICS)
 +   {
 +      if(dwDesiredAccess & GENERIC_ALL)
 +         Flags |= FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_REMOTE_INSTANCE;
 +      else
 +      {
 +         if(dwDesiredAccess & GENERIC_READ)
 +            Flags |= FILE_OPEN_FOR_BACKUP_INTENT;
 +
 +         if(dwDesiredAccess & GENERIC_WRITE)
 +            Flags |= FILE_OPEN_REMOTE_INSTANCE;
 +      }
 +   }
 +   else
 +      Flags |= FILE_NON_DIRECTORY_FILE;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_OPEN_REPARSE_POINT)
 +      Flags |= FILE_OPEN_REPARSE_POINT;
 +
 +   if(dwFlagsAndAttributes & FILE_FLAG_OPEN_NO_RECALL)
 +      Flags |= FILE_OPEN_NO_RECALL;
 +
 +   FileAttributes = (dwFlagsAndAttributes & (FILE_ATTRIBUTE_VALID_FLAGS & ~FILE_ATTRIBUTE_DIRECTORY));
 +
 +   /* handle may always be waited on and querying attributes are always allowed */
 +   dwDesiredAccess |= SYNCHRONIZE | FILE_READ_ATTRIBUTES;
 +
 +   /* FILE_FLAG_POSIX_SEMANTICS is handled later */
 +
 +   /* validate & translate the filename */
 +   if (!RtlDosPathNameToNtPathName_U (lpFileName,
 +                                    &NtPathU,
 +                                    NULL,
 +                                    NULL))
 +   {
 +     WARN("Invalid path\n");
 +     SetLastError(ERROR_FILE_NOT_FOUND);
 +     return INVALID_HANDLE_VALUE;
 +   }
 +
 +   TRACE("NtPathU \'%wZ\'\n", &NtPathU);
 +
 +   if (hTemplateFile != NULL)
 +   {
 +      FILE_EA_INFORMATION EaInformation;
 +
 +      for (;;)
 +      {
 +         /* try to get the size of the extended attributes, if we fail just continue
 +            creating the file without copying the attributes! */
 +         Status = NtQueryInformationFile(hTemplateFile,
 +                                         &IoStatusBlock,
 +                                         &EaInformation,
 +                                         sizeof(FILE_EA_INFORMATION),
 +                                         FileEaInformation);
 +         if (NT_SUCCESS(Status) && (EaInformation.EaSize != 0))
 +         {
 +            /* there's extended attributes to read, let's give it a try */
 +            EaBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
 +                                       0,
 +                                       EaInformation.EaSize);
 +            if (EaBuffer == NULL)
 +            {
 +               RtlFreeHeap(RtlGetProcessHeap(),
 +                           0,
 +                           NtPathU.Buffer);
 +
 +               /* the template file handle is valid and has extended attributes,
 +                  however we seem to lack some memory here. We should fail here! */
 +               SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 +               return INVALID_HANDLE_VALUE;
 +            }
 +
 +            Status = NtQueryEaFile(hTemplateFile,
 +                                   &IoStatusBlock,
 +                                   EaBuffer,
 +                                   EaInformation.EaSize,
 +                                   FALSE,
 +                                   NULL,
 +                                   0,
 +                                   NULL,
 +                                   TRUE);
 +
 +            if (NT_SUCCESS(Status))
 +            {
 +               /* we successfully read the extended attributes, break the loop
 +                  and continue */
 +               EaLength = EaInformation.EaSize;
 +               break;
 +            }
 +            else
 +            {
 +               RtlFreeHeap(RtlGetProcessHeap(),
 +                           0,
 +                           EaBuffer);
 +               EaBuffer = NULL;
 +
 +               if (Status != STATUS_BUFFER_TOO_SMALL)
 +               {
 +                  /* unless we just allocated not enough memory, break the loop
 +                     and just continue without copying extended attributes */
 +                  break;
 +               }
 +            }
 +         }
 +         else
 +         {
 +            /* we either failed to get the size of the extended attributes or
 +               they're empty, just continue as there's no need to copy
 +               attributes */
 +            break;
 +         }
 +      }
 +   }
 +
 +   /* build the object attributes */
 +   InitializeObjectAttributes(&ObjectAttributes,
 +                              &NtPathU,
 +                              0,
 +                              NULL,
 +                              NULL);
 +
 +   if (lpSecurityAttributes)
 +   {
 +      if(lpSecurityAttributes->bInheritHandle)
 +         ObjectAttributes.Attributes |= OBJ_INHERIT;
 +
 +      ObjectAttributes.SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
 +   }
 +
 +   if(!(dwFlagsAndAttributes & FILE_FLAG_POSIX_SEMANTICS))
 +    ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
 +
 +   /* perform the call */
 +   Status = NtCreateFile (&FileHandle,
 +                        dwDesiredAccess,
 +                        &ObjectAttributes,
 +                        &IoStatusBlock,
 +                        NULL,
 +                        FileAttributes,
 +                        dwShareMode,
 +                        dwCreationDisposition,
 +                        Flags,
 +                        EaBuffer,
 +                        EaLength);
 +
 +   RtlFreeHeap(RtlGetProcessHeap(),
 +               0,
 +               NtPathU.Buffer);
 +
 +   /* free the extended attributes buffer if allocated */
 +   if (EaBuffer != NULL)
 +   {
 +      RtlFreeHeap(RtlGetProcessHeap(),
 +                  0,
 +                  EaBuffer);
 +   }
 +
 +   /* error */
 +   if (!NT_SUCCESS(Status))
 +   {
 +      /* In the case file creation was rejected due to CREATE_NEW flag
 +       * was specified and file with that name already exists, correct
 +       * last error is ERROR_FILE_EXISTS and not ERROR_ALREADY_EXISTS.
 +       * Note: RtlNtStatusToDosError is not the subject to blame here.
 +       */
 +      if (Status == STATUS_OBJECT_NAME_COLLISION &&
 +          dwCreationDisposition == FILE_CREATE)
 +      {
 +         SetLastError( ERROR_FILE_EXISTS );
 +      }
 +      else
 +      {
 +         BaseSetLastNTError (Status);
 +      }
 +
 +      return INVALID_HANDLE_VALUE;
 +   }
 +
 +  /*
 +  create with OPEN_ALWAYS (FILE_OPEN_IF) returns info = FILE_OPENED or FILE_CREATED
 +  create with CREATE_ALWAYS (FILE_OVERWRITE_IF) returns info = FILE_OVERWRITTEN or FILE_CREATED
 +  */
 +  if (dwCreationDisposition == FILE_OPEN_IF)
 +  {
 +    SetLastError(IoStatusBlock.Information == FILE_OPENED ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS);
 +  }
 +  else if (dwCreationDisposition == FILE_OVERWRITE_IF)
 +  {
 +    SetLastError(IoStatusBlock.Information == FILE_OVERWRITTEN ? ERROR_ALREADY_EXISTS : ERROR_SUCCESS);
 +  }
 +  else
 +  {
 +    SetLastError(ERROR_SUCCESS);
 +  }
 +
 +  return FileHandle;
 +}
 +
 +/*
 + * @implemented
 + */
 +HFILE WINAPI
 +OpenFile(LPCSTR lpFileName,
 +       LPOFSTRUCT lpReOpenBuff,
 +       UINT uStyle)
 +{
 +      OBJECT_ATTRIBUTES ObjectAttributes;
 +      IO_STATUS_BLOCK IoStatusBlock;
 +      UNICODE_STRING FileNameString;
 +      UNICODE_STRING FileNameU;
 +      ANSI_STRING FileName;
 +      WCHAR PathNameW[MAX_PATH];
 +      HANDLE FileHandle = NULL;
 +      NTSTATUS errCode;
 +      PWCHAR FilePart;
 +      ULONG Len;
 +
 +      TRACE("OpenFile('%s', lpReOpenBuff %x, uStyle %x)\n", lpFileName, lpReOpenBuff, uStyle);
 +
 +      if (lpReOpenBuff == NULL)
 +      {
 +              return HFILE_ERROR;
 +      }
 +
 +    lpReOpenBuff->nErrCode = 0;
 +
 +      if (uStyle & OF_REOPEN) lpFileName = lpReOpenBuff->szPathName;
 +
 +      if (!lpFileName)
 +      {
 +              return HFILE_ERROR;
 +      }
 +
 +      if (!GetFullPathNameA(lpFileName,
 +                                                sizeof(lpReOpenBuff->szPathName),
 +                                                lpReOpenBuff->szPathName,
 +                                                NULL))
 +      {
 +          lpReOpenBuff->nErrCode = GetLastError();
 +              return HFILE_ERROR;
 +      }
 +
 +    if (uStyle & OF_PARSE)
 +    {
 +        lpReOpenBuff->fFixedDisk = (GetDriveTypeA(lpReOpenBuff->szPathName) != DRIVE_REMOVABLE);
 +        TRACE("(%s): OF_PARSE, res = '%s'\n", lpFileName, lpReOpenBuff->szPathName);
 +        return 0;
 +    }
 +
 +    if ((uStyle & OF_EXIST) && !(uStyle & OF_CREATE))
 +    {
 +        DWORD dwAttributes = GetFileAttributesA(lpReOpenBuff->szPathName);
 +
 +        switch (dwAttributes)
 +        {
 +            case 0xFFFFFFFF: /* File does not exist */
 +                SetLastError(ERROR_FILE_NOT_FOUND);
 +                lpReOpenBuff->nErrCode = (WORD) ERROR_FILE_NOT_FOUND;
 +                return -1;
 +
 +            case FILE_ATTRIBUTE_DIRECTORY:
 +                SetLastError(ERROR_ACCESS_DENIED);
 +                lpReOpenBuff->nErrCode = (WORD) ERROR_ACCESS_DENIED;
 +                return -1;
 +
 +            default:
 +                lpReOpenBuff->cBytes = sizeof(OFSTRUCT);
 +                return 1;
 +        }
 +    }
 +    lpReOpenBuff->cBytes = sizeof(OFSTRUCT);
 +      if ((uStyle & OF_CREATE) == OF_CREATE)
 +      {
 +              DWORD Sharing;
 +              switch (uStyle & 0x70)
 +              {
 +                      case OF_SHARE_EXCLUSIVE: Sharing = 0; break;
 +                      case OF_SHARE_DENY_WRITE: Sharing = FILE_SHARE_READ; break;
 +                      case OF_SHARE_DENY_READ: Sharing = FILE_SHARE_WRITE; break;
 +                      case OF_SHARE_DENY_NONE:
 +                      case OF_SHARE_COMPAT:
 +                      default:
 +                              Sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
 +              }
 +              return (HFILE) CreateFileA (lpFileName,
 +                                          GENERIC_READ | GENERIC_WRITE,
 +                                          Sharing,
 +                                          NULL,
 +                                          CREATE_ALWAYS,
 +                                          FILE_ATTRIBUTE_NORMAL,
 +                                          0);
 +      }
 +
 +      RtlInitAnsiString (&FileName, (LPSTR)lpFileName);
 +
 +      /* convert ansi (or oem) string to unicode */
 +      if (bIsFileApiAnsi)
 +              RtlAnsiStringToUnicodeString (&FileNameU, &FileName, TRUE);
 +      else
 +              RtlOemStringToUnicodeString (&FileNameU, &FileName, TRUE);
 +
 +      Len = SearchPathW (NULL,
 +                         FileNameU.Buffer,
 +                         NULL,
 +                         OFS_MAXPATHNAME,
 +                         PathNameW,
 +                         &FilePart);
 +
 +      RtlFreeUnicodeString(&FileNameU);
 +
 +      if (Len == 0 || Len > OFS_MAXPATHNAME)
 +      {
 +              lpReOpenBuff->nErrCode = GetLastError();
 +              return (HFILE)INVALID_HANDLE_VALUE;
 +      }
 +
 +    if (uStyle & OF_DELETE)
 +    {
 +        if (!DeleteFileW(PathNameW))
 +              {
 +                      lpReOpenBuff->nErrCode = GetLastError();
 +                      return HFILE_ERROR;
 +              }
 +        TRACE("(%s): OF_DELETE return = OK\n", lpFileName);
 +        return TRUE;
 +    }
 +
 +      FileName.Buffer = lpReOpenBuff->szPathName;
 +      FileName.Length = 0;
 +      FileName.MaximumLength = OFS_MAXPATHNAME;
 +
 +      RtlInitUnicodeString(&FileNameU, PathNameW);
 +
 +      /* convert unicode string to ansi (or oem) */
 +      if (bIsFileApiAnsi)
 +              RtlUnicodeStringToAnsiString (&FileName, &FileNameU, FALSE);
 +      else
 +              RtlUnicodeStringToOemString (&FileName, &FileNameU, FALSE);
 +
 +      if (!RtlDosPathNameToNtPathName_U (PathNameW,
 +                                         &FileNameString,
 +                                         NULL,
 +                                         NULL))
 +      {
 +              return (HFILE)INVALID_HANDLE_VALUE;
 +      }
 +
 +      // FILE_SHARE_READ
 +      // FILE_NO_INTERMEDIATE_BUFFERING
 +
 +      ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
 +      ObjectAttributes.RootDirectory = NULL;
 +      ObjectAttributes.ObjectName = &FileNameString;
 +      ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
 +      ObjectAttributes.SecurityDescriptor = NULL;
 +      ObjectAttributes.SecurityQualityOfService = NULL;
 +
 +      errCode = NtOpenFile (&FileHandle,
 +                            GENERIC_READ|SYNCHRONIZE,
 +                            &ObjectAttributes,
 +                            &IoStatusBlock,
 +                            FILE_SHARE_READ,
 +                            FILE_NON_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT);
 +
 +      RtlFreeHeap(RtlGetProcessHeap(), 0, FileNameString.Buffer);
 +
 +      lpReOpenBuff->nErrCode = RtlNtStatusToDosError(errCode);
 +
 +      if (!NT_SUCCESS(errCode))
 +      {
 +              BaseSetLastNTError (errCode);
 +              return (HFILE)INVALID_HANDLE_VALUE;
 +      }
 +
 +      if (uStyle & OF_EXIST)
 +      {
 +              NtClose(FileHandle);
 +              return (HFILE)1;
 +      }
 +
 +      return (HFILE)FileHandle;
 +}
 +
 +/*
 + * @unimplemented
 + */
 +BOOL
 +WINAPI
 +OpenDataFile(HANDLE hFile, DWORD dwUnused)
 +{
 +    STUB;
 +    return FALSE;
 +}
 +
 +/*
 + * @unimplemented
 + */
 +HANDLE
 +WINAPI
 +ReOpenFile(IN HANDLE hOriginalFile,
 +           IN DWORD dwDesiredAccess,
 +           IN DWORD dwShareMode,
 +           IN DWORD dwFlags)
 +{
 +   STUB;
 +   return INVALID_HANDLE_VALUE;
 +}
 +
 +/* EOF */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000,96e70c8..96e70c8
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000,249a8b3..249a8b3
mode 000000,100644..100644
--- /dev/null
index 0000000,cd60e13..cd60e13
mode 000000,100644..100644
--- /dev/null
Simple merge
index 0000000,7355406..7355406
mode 000000,100644..100644
--- /dev/null
index 0000000,6717473..6717473
mode 000000,100644..100644
--- /dev/null
index 0000000,a77136c..a77136c
mode 000000,100644..100644
--- /dev/null
index 0000000,b049afa..b049afa
mode 000000,100644..100644
--- /dev/null
index 0000000,68702ba..68702ba
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
index 0000000,0a14da4..0a14da4
mode 000000,100644..100644
--- /dev/null
index 0000000,ed9c4e2..ed9c4e2
mode 000000,100644..100644
--- /dev/null
index 0000000,7cca818..7cca818
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 22c80c3,0000000..5b41c6b
mode 100644,000000..100644
--- /dev/null
@@@ -1,95 -1,0 +1,95 @@@
-  * $Author$
-  * $Date$
 +/*
 + * dllmain.c
 + *
 + * $Revision: 1.11 $
++ * $Author: hbelusca $
++ * $Date: 2013-01-28 23:45:53 +0100 (lun. 28 janv. 2013) $
 + *
 + */
 +
 +#include <precomp.h>
 +
 +extern HGDIOBJ stock_objects[];
 +BOOL SetStockObjects = FALSE;
 +PDEVCAPS GdiDevCaps = NULL;
 +PGDIHANDLECACHE GdiHandleCache = NULL;
 +BOOL gbLpk = FALSE;
 +RTL_CRITICAL_SECTION semLocal;
 +
 +/*
 + * GDI32.DLL does have an entry point for disable threadlibrarycall,. The initialization is done by a call
 + * to GdiDllInitialize(). This call is done from the entry point of USER32.DLL.
 + */
 +BOOL
 +WINAPI
 +DllMain (
 +    HANDLE  hDll,
 +    DWORD   dwReason,
 +    LPVOID  lpReserved)
 +{
 +    switch (dwReason)
 +    {
 +    case DLL_PROCESS_ATTACH :
 +        DisableThreadLibraryCalls(hDll);
 +        break;
 +
 +    default:
 +        break;
 +    }
 +    return TRUE;
 +}
 +
 +
 +VOID
 +WINAPI
 +GdiProcessSetup (VOID)
 +{
 +    hProcessHeap = GetProcessHeap();
 +
 +    /* map the gdi handle table to user space */
 +    GdiHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
 +    GdiSharedHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
 +    GdiDevCaps = &GdiSharedHandleTable->DevCaps;
 +    CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
 +    GDI_BatchLimit = (DWORD) NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
 +    GdiHandleCache = (PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
 +    RtlInitializeCriticalSection(&semLocal);
 +}
 +
 +
 +/*
 + * @implemented
 + */
 +BOOL
 +WINAPI
 +GdiDllInitialize (
 +    HANDLE hDll,
 +    DWORD dwReason,
 +    LPVOID lpReserved)
 +{
 +    switch (dwReason)
 +    {
 +    case DLL_PROCESS_ATTACH:
 +        GdiProcessSetup ();
 +        break;
 +
 +    case DLL_THREAD_ATTACH:
 +        NtCurrentTeb()->GdiTebBatch.Offset = 0;
 +        NtCurrentTeb()->GdiBatchCount = 0;
 +        break;
 +
 +    default:
 +        return FALSE;
 +    }
 +
 +    // Very simple, the list will fill itself as it is needed.
 +    if(!SetStockObjects)
 +    {
 +        RtlZeroMemory( &stock_objects, NB_STOCK_OBJECTS); //Assume Ros is dirty.
 +        SetStockObjects = TRUE;
 +    }
 +
 +    return TRUE;
 +}
 +
 +/* EOF */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 82dead1,0000000..c0e5028
mode 100644,000000..100644
--- /dev/null
@@@ -1,2074 -1,0 +1,2080 @@@
 +/*
 + *  COPYRIGHT:        See COPYING in the top level directory
 + *  PROJECT:          ReactOS Win32k subsystem
 + *  PURPOSE:          Desktops
 + *  FILE:             subsystems/win32/win32k/ntuser/desktop.c
 + *  PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
 + */
 +
 +/* INCLUDES ******************************************************************/
 +
 +#include <win32k.h>
 +DBG_DEFAULT_CHANNEL(UserDesktop);
 +
 +static NTSTATUS
 +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta);
 +
 +static NTSTATUS
 +IntMapDesktopView(IN PDESKTOP pdesk);
 +
 +static NTSTATUS
 +IntUnmapDesktopView(IN PDESKTOP pdesk);
 +
 +static VOID
 +IntFreeDesktopHeap(IN PDESKTOP pdesk);
 +
 +/* GLOBALS *******************************************************************/
 +
 +/* Currently active desktop */
 +PDESKTOP gpdeskInputDesktop = NULL;
 +HDC ScreenDeviceContext = NULL;
 +PTHREADINFO gptiDesktopThread;
 +HCURSOR gDesktopCursor = NULL;
 +
 +/* OBJECT CALLBACKS **********************************************************/
 +
 +NTSTATUS
 +APIENTRY
 +IntDesktopObjectParse(IN PVOID ParseObject,
 +                      IN PVOID ObjectType,
 +                      IN OUT PACCESS_STATE AccessState,
 +                      IN KPROCESSOR_MODE AccessMode,
 +                      IN ULONG Attributes,
 +                      IN OUT PUNICODE_STRING CompleteName,
 +                      IN OUT PUNICODE_STRING RemainingName,
 +                      IN OUT PVOID Context OPTIONAL,
 +                      IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
 +                      OUT PVOID *Object)
 +{
 +    NTSTATUS Status;
 +    PDESKTOP Desktop;
 +    OBJECT_ATTRIBUTES ObjectAttributes;
 +    PLIST_ENTRY NextEntry, ListHead;
 +    PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)ParseObject;
 +    PUNICODE_STRING DesktopName;
 +    PBOOLEAN pContext = (PBOOLEAN) Context;
 +
 +    if(pContext)
 +        *pContext = FALSE;
 +
 +    /* Set the list pointers and loop the window station */
 +    ListHead = &WinStaObject->DesktopListHead;
 +    NextEntry = ListHead->Flink;
 +    while (NextEntry != ListHead)
 +    {
 +        /* Get the current desktop */
 +        Desktop = CONTAINING_RECORD(NextEntry, DESKTOP, ListEntry);
 +
 +        /// @todo Don't mess around with the object headers!
 +        /* Get its name */
 +        _PRAGMA_WARNING_SUPPRESS(__WARNING_DEREF_NULL_PTR)
 +        DesktopName = GET_DESKTOP_NAME(Desktop);
 +        if (DesktopName)
 +        {
 +            /* Compare the name */
 +            if (RtlEqualUnicodeString(RemainingName,
 +                                      DesktopName,
 +                                      (Attributes & OBJ_CASE_INSENSITIVE)))
 +            {
 +                /* We found a match. Did this come from a create? */
 +                if (Context)
 +                {
 +                    /* Unless OPEN_IF was given, fail with an error */
 +                    if (!(Attributes & OBJ_OPENIF))
 +                    {
 +                        /* Name collision */
 +                        return STATUS_OBJECT_NAME_COLLISION;
 +                    }
 +                    else
 +                    {
 +                        /* Otherwise, return with a warning only */
 +                        Status = STATUS_OBJECT_NAME_EXISTS;
 +                    }
 +                }
 +                else
 +                {
 +                    /* This was a real open, so this is OK */
 +                    Status = STATUS_SUCCESS;
 +                }
 +
 +                /* Reference the desktop and return it */
 +                ObReferenceObject(Desktop);
 +                *Object = Desktop;
 +                return Status;
 +            }
 +        }
 +
 +        /* Go to the next desktop */
 +        NextEntry = NextEntry->Flink;
 +    }
 +
 +    /* If we got here but this isn't a create, then fail */
 +    if (!Context) return STATUS_OBJECT_NAME_NOT_FOUND;
 +
 +    /* Create the desktop object */
 +    InitializeObjectAttributes(&ObjectAttributes, RemainingName, 0, NULL, NULL);
 +    Status = ObCreateObject(KernelMode,
 +                            ExDesktopObjectType,
 +                            &ObjectAttributes,
 +                            KernelMode,
 +                            NULL,
 +                            sizeof(DESKTOP),
 +                            0,
 +                            0,
 +                            (PVOID*)&Desktop);
 +    if (!NT_SUCCESS(Status)) return Status;
 +
 +    /* Initialize the desktop */
 +    Status = UserInitializeDesktop(Desktop, RemainingName, WinStaObject);
 +    if (!NT_SUCCESS(Status))
 +    {
 +        ObDereferenceObject(Desktop);
 +        return Status;
 +    }
 +
 +    /* Set the desktop object and return success */
 +    *Object = Desktop;
 +    *pContext = TRUE;
 +    return STATUS_SUCCESS;
 +}
 +
 +VOID APIENTRY
 +IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters)
 +{
 +   PDESKTOP pdesk = (PDESKTOP)Parameters->Object;
 +
 +   TRACE("Deleting desktop object 0x%p\n", pdesk);
 +
 +   ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL);
 +
 +   if (pdesk->pDeskInfo->spwnd)
 +       co_UserDestroyWindow(pdesk->pDeskInfo->spwnd);
 +
 +   if (pdesk->spwndMessage)
 +       co_UserDestroyWindow(pdesk->spwndMessage);
 +
 +   /* Remove the desktop from the window station's list of associcated desktops */
 +   RemoveEntryList(&pdesk->ListEntry);
 +
 +   /* Free the heap */
 +   IntFreeDesktopHeap(pdesk);
 +}
 +
 +NTSTATUS NTAPI
 +IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters)
 +{
 +    PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
 +
 +    if( pti == NULL)
 +    {
 +        /* This happens when we leak desktop handles */
 +        return STATUS_SUCCESS;
 +    }
 +
 +    /* Do not allow the current desktop or the initial desktop to be closed */
 +    if( Parameters->Handle == pti->ppi->hdeskStartup ||
 +        Parameters->Handle == pti->hdesk)
 +    {
 +        return STATUS_ACCESS_DENIED;
 +    }
 +
 +    return STATUS_SUCCESS;
 +}
 +
 +NTSTATUS NTAPI IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters)
 +{
 +    PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process);
 +    if (ppi == NULL)
 +        return STATUS_SUCCESS;
 +
 +    return IntMapDesktopView((PDESKTOP)Parameters->Object);
 +}
 +
 +NTSTATUS NTAPI IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters)
 +{
 +    PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process);
 +    if (ppi == NULL)
 +    {
 +        /* This happens when the process leaks desktop handles.
 +         * At this point the PPROCESSINFO is already destroyed */
 +         return STATUS_SUCCESS;
 +    }
 +
 +    return IntUnmapDesktopView((PDESKTOP)Parameters->Object);
 +}
 +
 +
 +/* PRIVATE FUNCTIONS **********************************************************/
 +
 +INIT_FUNCTION
 +NTSTATUS
 +NTAPI
 +InitDesktopImpl(VOID)
 +{
 +    GENERIC_MAPPING IntDesktopMapping = { DESKTOP_READ,
 +                                          DESKTOP_WRITE,
 +                                          DESKTOP_EXECUTE,
 +                                          DESKTOP_ALL_ACCESS};
 +
 +    /* Set Desktop Object Attributes */
 +    ExDesktopObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(DESKTOP);
 +    ExDesktopObjectType->TypeInfo.GenericMapping = IntDesktopMapping;
 +    ExDesktopObjectType->TypeInfo.ValidAccessMask = DESKTOP_ALL_ACCESS;
 +    return STATUS_SUCCESS;
 +}
 +
 +static int GetSystemVersionString(LPWSTR buffer)
 +{
 +   RTL_OSVERSIONINFOEXW versionInfo;
 +   int len;
 +
 +   versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
 +
 +   if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo)))
 +      return 0;
 +
 +   if (versionInfo.dwMajorVersion <= 4)
 +      len = swprintf(buffer,
 +                     L"ReactOS Version %d.%d %s Build %d",
 +                     versionInfo.dwMajorVersion, versionInfo.dwMinorVersion,
 +                     versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
 +   else
 +      len = swprintf(buffer,
 +                     L"ReactOS %s (Build %d)",
 +                     versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
 +
 +   return len;
 +}
 +
 +
 +NTSTATUS FASTCALL
 +IntParseDesktopPath(PEPROCESS Process,
 +                    PUNICODE_STRING DesktopPath,
 +                    HWINSTA *hWinSta,
 +                    HDESK *hDesktop)
 +{
 +   OBJECT_ATTRIBUTES ObjectAttributes;
 +   UNICODE_STRING ObjectName;
 +   NTSTATUS Status;
 +   WCHAR wstrWinstaFullName[MAX_PATH], *pwstrWinsta = NULL, *pwstrDesktop = NULL;
 +
 +   ASSERT(hWinSta);
 +   ASSERT(hDesktop);
 +   ASSERT(DesktopPath);
 +
 +   *hWinSta = NULL;
 +   *hDesktop = NULL;
 +
 +   if(DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR))
 +   {
 +      /*
 +       * Parse the desktop path string which can be in the form "WinSta\Desktop"
 +       * or just "Desktop". In latter case WinSta0 will be used.
 +       */
 +
 +      pwstrDesktop = wcschr(DesktopPath->Buffer, L'\\');
 +      if(pwstrDesktop != NULL)
 +      {
 +          *pwstrDesktop = 0;
 +          pwstrDesktop++;
 +          pwstrWinsta = DesktopPath->Buffer;
 +      }
 +      else
 +      {
 +          pwstrDesktop = DesktopPath->Buffer;
 +          pwstrWinsta = NULL;
 +      }
 +
 +      TRACE("IntParseDesktopPath pwstrWinsta:%S pwstrDesktop:%S\n", pwstrWinsta, pwstrDesktop);
 +   }
 +
 +#if 0
 +   /* Search the process handle table for (inherited) window station
 +      handles, use a more appropriate one than WinSta0 if possible. */
 +   if (!ObFindHandleForObject(Process,
 +                              NULL,
 +                              ExWindowStationObjectType,
 +                              NULL,
 +                              (PHANDLE)hWinSta))
 +#endif
 +   {
 +       /* We had no luck searching for opened handles, use WinSta0 now */
 +       if(!pwstrWinsta)
 +           pwstrWinsta = L"WinSta0";
 +   }
 +
 +#if 0
 +   /* Search the process handle table for (inherited) desktop
 +      handles, use a more appropriate one than Default if possible. */
 +   if (!ObFindHandleForObject(Process,
 +                              NULL,
 +                              ExDesktopObjectType,
 +                              NULL,
 +                              (PHANDLE)hDesktop))
 +#endif
 +   {
 +       /* We had no luck searching for opened handles, use Desktop now */
 +       if(!pwstrDesktop)
 +           pwstrDesktop = L"Default";
 +   }
 +
 +   if(*hWinSta == NULL)
 +   {
 +       swprintf(wstrWinstaFullName, L"%wZ\\%ws", &gustrWindowStationsDir, pwstrWinsta);
 +       RtlInitUnicodeString( &ObjectName, wstrWinstaFullName);
 +
 +       TRACE("parsed initial winsta: %wZ\n", &ObjectName);
 +
 +      /* Open the window station */
 +      InitializeObjectAttributes(&ObjectAttributes,
 +                                 &ObjectName,
 +                                 OBJ_CASE_INSENSITIVE,
 +                                 NULL,
 +                                 NULL);
 +
 +      Status = ObOpenObjectByName(&ObjectAttributes,
 +                                  ExWindowStationObjectType,
 +                                  KernelMode,
 +                                  NULL,
 +                                  WINSTA_ACCESS_ALL,
 +                                  NULL,
 +                                  (HANDLE*)hWinSta);
 +
 +      if(!NT_SUCCESS(Status))
 +      {
 +         SetLastNtError(Status);
 +         ERR("Failed to reference window station %wZ PID: --!\n", &ObjectName );
 +         return Status;
 +      }
 +   }
 +
 +   if(*hDesktop == NULL)
 +   {
 +      RtlInitUnicodeString(&ObjectName, pwstrDesktop);
 +
 +      TRACE("parsed initial desktop: %wZ\n", &ObjectName);
 +
 +      /* Open the desktop object */
 +      InitializeObjectAttributes(&ObjectAttributes,
 +                                 &ObjectName,
 +                                 OBJ_CASE_INSENSITIVE,
 +                                 *hWinSta,
 +                                 NULL);
 +
 +      Status = ObOpenObjectByName(&ObjectAttributes,
 +                                  ExDesktopObjectType,
 +                                  KernelMode,
 +                                  NULL,
 +                                  DESKTOP_ALL_ACCESS,
 +                                  NULL,
 +                                  (HANDLE*)hDesktop);
 +
 +      if(!NT_SUCCESS(Status))
 +      {
 +         *hDesktop = NULL;
 +         NtClose(*hWinSta);
 +         *hWinSta = NULL;
 +         SetLastNtError(Status);
 +         ERR("Failed to reference desktop %wZ PID: --!\n", &ObjectName);
 +         return Status;
 +      }
 +   }
 +   return STATUS_SUCCESS;
 +}
 +
 +/*
 + * IntValidateDesktopHandle
 + *
 + * Validates the desktop handle.
 + *
 + * Remarks
 + *    If the function succeeds, the handle remains referenced. If the
 + *    fucntion fails, last error is set.
 + */
 +
 +NTSTATUS FASTCALL
 +IntValidateDesktopHandle(
 +   HDESK Desktop,
 +   KPROCESSOR_MODE AccessMode,
 +   ACCESS_MASK DesiredAccess,
 +   PDESKTOP *Object)
 +{
 +   NTSTATUS Status;
 +
 +   Status = ObReferenceObjectByHandle(
 +               Desktop,
 +               DesiredAccess,
 +               ExDesktopObjectType,
 +               AccessMode,
 +               (PVOID*)Object,
 +               NULL);
 +
 +   TRACE("IntValidateDesktopHandle: handle:0x%p obj:0x%p access:0x%x Status:0x%lx\n",
 +            Desktop, *Object, DesiredAccess, Status);
 +
 +   if (!NT_SUCCESS(Status))
 +      SetLastNtError(Status);
 +
 +   return Status;
 +}
 +
 +PDESKTOP FASTCALL
 +IntGetActiveDesktop(VOID)
 +{
 +   return gpdeskInputDesktop;
 +}
 +
 +/*
 + * Returns or creates a handle to the desktop object
 + */
 +HDESK FASTCALL
 +IntGetDesktopObjectHandle(PDESKTOP DesktopObject)
 +{
 +   NTSTATUS Status;
 +   HDESK Ret;
 +
 +   ASSERT(DesktopObject);
 +
 +   if (!ObFindHandleForObject(PsGetCurrentProcess(),
 +                              DesktopObject,
 +                              ExDesktopObjectType,
 +                              NULL,
 +                              (PHANDLE)&Ret))
 +   {
 +      Status = ObOpenObjectByPointer(DesktopObject,
 +                                     0,
 +                                     NULL,
 +                                     0,
 +                                     ExDesktopObjectType,
 +                                     UserMode,
 +                                     (PHANDLE)&Ret);
 +      if(!NT_SUCCESS(Status))
 +      {
 +         /* Unable to create a handle */
 +         ERR("Unable to create a desktop handle\n");
 +         return NULL;
 +      }
 +   }
 +   else
 +   {
 +       ERR("Got handle: %p\n", Ret);
 +   }
 +
 +   return Ret;
 +}
 +
 +PUSER_MESSAGE_QUEUE FASTCALL
 +IntGetFocusMessageQueue(VOID)
 +{
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return(NULL);
 +   }
 +   return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
 +}
 +
 +VOID FASTCALL
 +IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
 +{
 +   PUSER_MESSAGE_QUEUE Old;
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return;
 +   }
 +   if(NewQueue != NULL)
 +   {
 +      if(NewQueue->Desktop != NULL)
 +      {
 +         TRACE("Message Queue already attached to another desktop!\n");
 +         return;
 +      }
 +      IntReferenceMessageQueue(NewQueue);
 +      (void)InterlockedExchangePointer((PVOID*)&NewQueue->Desktop, pdo);
 +   }
 +   Old = (PUSER_MESSAGE_QUEUE)InterlockedExchangePointer((PVOID*)&pdo->ActiveMessageQueue, NewQueue);
 +   if(Old != NULL)
 +   {
 +      (void)InterlockedExchangePointer((PVOID*)&Old->Desktop, 0);
 +      IntDereferenceMessageQueue(Old);
 +      gpqForegroundPrev = Old;
 +   }
 +   // Only one Q can have active foreground even when there are more than one desktop.
 +   if (NewQueue) gpqForeground = pdo->ActiveMessageQueue;
 +   else gpqForeground = NULL;
 +}
 +
 +PWND FASTCALL
 +IntGetThreadDesktopWindow(PTHREADINFO pti)
 +{
 +   if (!pti) pti = PsGetCurrentThreadWin32Thread();
 +   if (pti->pDeskInfo) return pti->pDeskInfo->spwnd;
 +   return NULL;
 +}
 +
 +PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
 +{
 +   if (pWnd->head.rpdesk &&
 +       pWnd->head.rpdesk->pDeskInfo)
 +      return pWnd->head.rpdesk->pDeskInfo->spwnd;
 +   return NULL;
 +}
 +
 +HWND FASTCALL IntGetDesktopWindow(VOID)
 +{
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return NULL;
 +   }
 +   return pdo->DesktopWindow;
 +}
 +
 +PWND FASTCALL UserGetDesktopWindow(VOID)
 +{
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return NULL;
 +   }
 +   // return pdo->pDeskInfo->spwnd;
 +   return UserGetWindowObject(pdo->DesktopWindow);
 +}
 +
 +HWND FASTCALL IntGetMessageWindow(VOID)
 +{
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return NULL;
 +   }
 +   return pdo->spwndMessage->head.h;
 +}
 +
 +PWND FASTCALL UserGetMessageWindow(VOID)
 +{
 +   PDESKTOP pdo = IntGetActiveDesktop();
 +
 +   if (!pdo)
 +   {
 +      TRACE("No active desktop\n");
 +      return NULL;
 +   }
 +   return pdo->spwndMessage;
 +}
 +
 +HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
 +{
 +   PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
 +   PDESKTOP pdo = pti->rpdesk;
 +   if (NULL == pdo)
 +   {
 +      ERR("Thread doesn't have a desktop\n");
 +      return NULL;
 +   }
 +   return pdo->DesktopWindow;
 +}
 +
 +/* PUBLIC FUNCTIONS ***********************************************************/
 +
 +BOOL FASTCALL
 +DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
 +{
 +   PAINTSTRUCT Ps;
 +   ULONG Value;
 +   //ERR("DesktopWindowProc\n");
 +
 +   *lResult = 0;
 +
 +   switch (Msg)
 +   {
 +      case WM_NCCREATE:
 +         if (!Wnd->fnid)
 +         {
 +            Wnd->fnid = FNID_DESKTOP;
 +         }
 +         *lResult = (LRESULT)TRUE;
 +         return TRUE;
 +
 +      case WM_CREATE:
 +         Value = HandleToULong(PsGetCurrentProcessId());
 +         // Save Process ID
 +         co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_PROCESSID, Value, FALSE);
 +         Value = HandleToULong(PsGetCurrentThreadId());
 +         // Save Thread ID
 +         co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_THREADID, Value, FALSE);
 +      case WM_CLOSE:
 +         return TRUE;
 +
 +      case WM_DISPLAYCHANGE:
 +         co_WinPosSetWindowPos(Wnd, 0, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOZORDER | SWP_NOACTIVATE);
 +         return TRUE;
 +
 +      case WM_ERASEBKGND:
 +         IntPaintDesktop((HDC)wParam);
 +         *lResult = 1;
 +         return TRUE;
 +
 +      case WM_PAINT:
 +      {
 +         if (IntBeginPaint(Wnd, &Ps))
 +         {
 +            IntEndPaint(Wnd, &Ps);
 +         }
 +         return TRUE;
 +      }
 +      case WM_SYSCOLORCHANGE:
 +         co_UserRedrawWindow(Wnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
 +         return TRUE;
 +      case WM_SETCURSOR:
 +      {
 +          PCURICON_OBJECT pcurOld, pcurNew;
 +          pcurNew = UserGetCurIconObject(gDesktopCursor);
 +          if (!pcurNew)
 +          {
 +              return TRUE;
 +          }
 +          pcurOld = UserSetCursor(pcurNew, FALSE);
 +          if (pcurOld)
 +          {
 +               UserDereferenceObject(pcurOld);
 +          }
 +          return TRUE;
 +      }
 +
 +      case WM_WINDOWPOSCHANGING:
 +      {
 +          PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam;
 +          if((pWindowPos->flags & SWP_SHOWWINDOW) != 0)
 +          {
 +              HDESK hdesk = IntGetDesktopObjectHandle(gpdeskInputDesktop);
 +              IntSetThreadDesktop(hdesk, FALSE);
 +          }
 +      }
 +
 +   }
 +   return TRUE; /* We are done. Do not do any callbacks to user mode */
 +}
 +
 +BOOL FASTCALL
 +UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
 +{
 +    *lResult = 0;
 +
 +    switch(Msg)
 +    {
 +    case WM_NCCREATE:
 +        pwnd->fnid |= FNID_MESSAGEWND;
 +        *lResult = (LRESULT)TRUE;
 +        break;
 +    case WM_DESTROY:
 +        pwnd->fnid |= FNID_DESTROY;
 +        break;
 +    }
 +
 +    return TRUE; /* We are done. Do not do any callbacks to user mode */
 +}
 +
 +VOID NTAPI DesktopThreadMain()
 +{
 +    BOOL Ret;
 +    MSG Msg;
 +
 +    gptiDesktopThread = PsGetCurrentThreadWin32Thread();
 +
 +    UserEnterExclusive();
 +
 +    /* Register system classes. This thread does not belong to any desktop so the
 +       classes will be allocated from the shared heap */
 +    UserRegisterSystemClasses();
 +
 +    while(TRUE)
 +    {
 +        Ret = co_IntGetPeekMessage(&Msg, 0, 0, 0, PM_REMOVE, TRUE);
 +        if (Ret)
 +        {
 +            IntDispatchMessage(&Msg);
 +        }
 +    }
 +
 +    UserLeave();
 +}
 +
 +HDC FASTCALL
 +UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
 +{
 +    PWND DesktopObject = 0;
 +    HDC DesktopHDC = 0;
 +
 +    if (DcType == DC_TYPE_DIRECT)
 +    {
 +        DesktopObject = UserGetDesktopWindow();
 +        DesktopHDC = (HDC)UserGetWindowDC(DesktopObject);
 +    }
 +    else
 +    {
 +        PMONITOR pMonitor = UserGetPrimaryMonitor();
 +        DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC);
 +    }
 +
 +    return DesktopHDC;
 +}
 +
 +VOID APIENTRY
 +UserRedrawDesktop()
 +{
 +    PWND Window = NULL;
 +    HRGN hRgn;
 +
 +    Window = UserGetDesktopWindow();
 +    hRgn = IntSysCreateRectRgnIndirect(&Window->rcWindow);
 +
 +    IntInvalidateWindows( Window,
 +                            hRgn,
 +                       RDW_FRAME |
 +                       RDW_ERASE |
 +                  RDW_INVALIDATE |
 +                 RDW_ALLCHILDREN);
 +
 +    GreDeleteObject(hRgn);
 +}
 +
 +
 +NTSTATUS FASTCALL
 +co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL bRedraw)
 +{
 +   PWND pwnd = Desktop->pDeskInfo->spwnd;
 +   UINT flags = SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW;
 +   ASSERT(pwnd);
 +
 +   if(!bRedraw)
 +       flags |= SWP_NOREDRAW;
 +
 +   co_WinPosSetWindowPos(pwnd, NULL, 0, 0, Width, Height, flags);
 +
 +   if(bRedraw)
 +       co_UserRedrawWindow( pwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE );
 +
 +   return STATUS_SUCCESS;
 +}
 +
 +NTSTATUS FASTCALL
 +IntHideDesktop(PDESKTOP Desktop)
 +{
 +   PWND DesktopWnd;
 +
 +   DesktopWnd = IntGetWindowObject(Desktop->DesktopWindow);
 +   if (! DesktopWnd)
 +   {
 +      return ERROR_INVALID_WINDOW_HANDLE;
 +   }
 +   DesktopWnd->style &= ~WS_VISIBLE;
 +
 +   return STATUS_SUCCESS;
 +}
 +
 +static
 +HWND* FASTCALL
 +UserBuildShellHookHwndList(PDESKTOP Desktop)
 +{
 +   ULONG entries=0;
 +   PSHELL_HOOK_WINDOW Current;
 +   HWND* list;
 +
 +   /* FIXME: If we save nb elements in desktop, we dont have to loop to find nb entries */
 +   LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry)
 +      entries++;
 +
 +   if (!entries) return NULL;
 +
 +   list = ExAllocatePoolWithTag(PagedPool, sizeof(HWND) * (entries + 1), USERTAG_WINDOWLIST); /* alloc one extra for nullterm */
 +   if (list)
 +   {
 +      HWND* cursor = list;
 +
 +      LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry)
 +         *cursor++ = Current->hWnd;
 +
 +      *cursor = NULL; /* Nullterm list */
 +   }
 +
 +   return list;
 +}
 +
 +/*
 + * Send the Message to the windows registered for ShellHook
 + * notifications. The lParam contents depend on the Message. See
 + * MSDN for more details (RegisterShellHookWindow)
 + */
 +VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
 +{
 +   PDESKTOP Desktop = IntGetActiveDesktop();
 +   HWND* HwndList;
 +
 +   if (!gpsi->uiShellMsg)
 +   {
 +      gpsi->uiShellMsg = IntAddAtom(L"SHELLHOOK");
 +
 +      TRACE("MsgType = %x\n", gpsi->uiShellMsg);
 +      if (!gpsi->uiShellMsg)
 +         ERR("LastError: %x\n", EngGetLastError());
 +   }
 +
 +   if (!Desktop)
 +   {
 +      TRACE("IntShellHookNotify: No desktop!\n");
 +      return;
 +   }
 +
 +   // FIXME: System Tray Support.
 +
 +   HwndList = UserBuildShellHookHwndList(Desktop);
 +   if (HwndList)
 +   {
 +      HWND* cursor = HwndList;
 +
 +      for (; *cursor; cursor++)
 +      {
 +         TRACE("Sending notify\n");
 +         co_IntPostOrSendMessage(*cursor,
 +                                 gpsi->uiShellMsg,
 +                                 Message,
 +                                 (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) );
 +      }
 +
 +      ExFreePoolWithTag(HwndList, USERTAG_WINDOWLIST);
 +   }
 +
 +   if (ISITHOOKED(WH_SHELL))
 +   {
 +      co_HOOK_CallHooks(WH_SHELL, Message, wParam, lParam);
 +   }
 +}
 +
 +/*
 + * Add the window to the ShellHookWindows list. The windows
 + * on that list get notifications that are important to shell
 + * type applications.
 + *
 + * TODO: Validate the window? I'm not sure if sending these messages to
 + * an unsuspecting application that is not your own is a nice thing to do.
 + */
 +BOOL IntRegisterShellHookWindow(HWND hWnd)
 +{
 +   PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
 +   PDESKTOP Desktop = pti->rpdesk;
 +   PSHELL_HOOK_WINDOW Entry;
 +
 +   TRACE("IntRegisterShellHookWindow\n");
 +
 +   /* First deregister the window, so we can be sure it's never twice in the
 +    * list.
 +    */
 +   IntDeRegisterShellHookWindow(hWnd);
 +
 +   Entry = ExAllocatePoolWithTag(PagedPool,
 +                                 sizeof(SHELL_HOOK_WINDOW),
 +                                 TAG_WINSTA);
 +
 +   if (!Entry)
 +      return FALSE;
 +
 +   Entry->hWnd = hWnd;
 +
 +   InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry);
 +
 +   return TRUE;
 +}
 +
 +/*
 + * Remove the window from the ShellHookWindows list. The windows
 + * on that list get notifications that are important to shell
 + * type applications.
 + */
 +BOOL IntDeRegisterShellHookWindow(HWND hWnd)
 +{
 +   PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
 +   PDESKTOP Desktop = pti->rpdesk;
 +   PSHELL_HOOK_WINDOW Current;
 +
 +   LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry)
 +   {
 +      if (Current->hWnd == hWnd)
 +      {
 +         RemoveEntryList(&Current->ListEntry);
 +         ExFreePoolWithTag(Current, TAG_WINSTA);
 +         return TRUE;
 +      }
 +   }
 +
 +   return FALSE;
 +}
 +
 +static VOID
 +IntFreeDesktopHeap(IN OUT PDESKTOP Desktop)
 +{
 +    /* FIXME: Disable until unmapping works in mm */
 +#if 0
 +    if (Desktop->pheapDesktop != NULL)
 +    {
 +        MmUnmapViewInSessionSpace(Desktop->pheapDesktop);
 +        Desktop->pheapDesktop = NULL;
 +    }
 +
 +    if (Desktop->hsectionDesktop != NULL)
 +    {
 +        ObDereferenceObject(Desktop->hsectionDesktop);
 +        Desktop->hsectionDesktop = NULL;
 +    }
 +#endif
 +}
 +
 +BOOL FASTCALL
 +IntPaintDesktop(HDC hDC)
 +{
 +   RECTL Rect;
 +   HBRUSH DesktopBrush, PreviousBrush;
 +   HWND hWndDesktop;
 +   BOOL doPatBlt = TRUE;
 +   PWND WndDesktop;
 +   static WCHAR s_wszSafeMode[] = L"Safe Mode";
 +   int len;
 +   COLORREF color_old;
 +   UINT align_old;
 +   int mode_old;
 +
 +   GdiGetClipBox(hDC, &Rect);
 +
 +   hWndDesktop = IntGetDesktopWindow(); // rpdesk->DesktopWindow;
 +
 +   WndDesktop = UserGetWindowObject(hWndDesktop); // rpdesk->pDeskInfo->spwnd;
 +   if (!WndDesktop)
 +   {
 +      return FALSE;
 +   }
 +
 +    if (!UserGetSystemMetrics(SM_CLEANBOOT))
 +    {
 +        DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground;
 +
 +        /*
 +        * Paint desktop background
 +        */
 +        if (gspv.hbmWallpaper != NULL)
 +        {
 +            SIZE sz;
 +            int x, y;
 +            HDC hWallpaperDC;
 +
 +            sz.cx = WndDesktop->rcWindow.right - WndDesktop->rcWindow.left;
 +            sz.cy = WndDesktop->rcWindow.bottom - WndDesktop->rcWindow.top;
 +
 +            if (gspv.WallpaperMode == wmStretch ||
 +                gspv.WallpaperMode == wmTile)
 +            {
 +                x = 0;
 +                y = 0;
 +            }
 +            else
 +            {
 +                /* Find the upper left corner, can be negative if the bitmap is bigger then the screen */
 +                x = (sz.cx / 2) - (gspv.cxWallpaper / 2);
 +                y = (sz.cy / 2) - (gspv.cyWallpaper / 2);
 +            }
 +
 +            hWallpaperDC = NtGdiCreateCompatibleDC(hDC);
 +            if(hWallpaperDC != NULL)
 +            {
 +                HBITMAP hOldBitmap;
 +
 +                /* Fill in the area that the bitmap is not going to cover */
 +                if (x > 0 || y > 0)
 +                {
 +                   /* FIXME: Clip out the bitmap
 +                      can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);"
 +                      once we support DSTINVERT */
 +                  PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush);
 +                  NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
 +                  NtGdiSelectBrush(hDC, PreviousBrush);
 +                }
 +
 +                /* Do not fill the background after it is painted no matter the size of the picture */
 +                doPatBlt = FALSE;
 +
 +                hOldBitmap = NtGdiSelectBitmap(hWallpaperDC, gspv.hbmWallpaper);
 +
 +                if (gspv.WallpaperMode == wmStretch)
 +                {
 +                    if(Rect.right && Rect.bottom)
 +                        NtGdiStretchBlt(hDC,
 +                                        x,
 +                                        y,
 +                                        sz.cx,
 +                                        sz.cy,
 +                                        hWallpaperDC,
 +                                        0,
 +                                        0,
 +                                        gspv.cxWallpaper,
 +                                        gspv.cyWallpaper,
 +                                        SRCCOPY,
 +                                        0);
 +
 +                }
 +                else if (gspv.WallpaperMode == wmTile)
 +                {
 +                    /* Paint the bitmap across the screen then down */
 +                    for(y = 0; y < Rect.bottom; y += gspv.cyWallpaper)
 +                    {
 +                        for(x = 0; x < Rect.right; x += gspv.cxWallpaper)
 +                        {
 +                            NtGdiBitBlt(hDC,
 +                                        x,
 +                                        y,
 +                                        gspv.cxWallpaper,
 +                                        gspv.cyWallpaper,
 +                                        hWallpaperDC,
 +                                        0,
 +                                        0,
 +                                        SRCCOPY,
 +                                        0,
 +                                        0);
 +                        }
 +                    }
 +                }
 +                else
 +                {
 +                    NtGdiBitBlt(hDC,
 +                                x,
 +                                y,
 +                                gspv.cxWallpaper,
 +                                gspv.cyWallpaper,
 +                                hWallpaperDC,
 +                                0,
 +                                0,
 +                                SRCCOPY,
 +                                0,
 +                                0);
 +                }
 +                NtGdiSelectBitmap(hWallpaperDC, hOldBitmap);
 +                NtGdiDeleteObjectApp(hWallpaperDC);
 +            }
 +        }
 +    }
 +    else
 +    {
 +        /* Black desktop background in Safe Mode */
 +        DesktopBrush = StockObjects[BLACK_BRUSH];
 +    }
 +    /* Back ground is set to none, clear the screen */
 +    if (doPatBlt)
 +    {
 +      PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush);
 +      NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
 +      NtGdiSelectBrush(hDC, PreviousBrush);
 +    }
 +
 +   /*
 +    * Display system version on the desktop background
 +    */
 +
 +   if (g_PaintDesktopVersion || UserGetSystemMetrics(SM_CLEANBOOT))
 +   {
 +      static WCHAR s_wszVersion[256] = {0};
 +      RECTL rect;
 +
 +      if (*s_wszVersion)
 +      {
 +         len = wcslen(s_wszVersion);
 +      }
 +      else
 +      {
 +         len = GetSystemVersionString(s_wszVersion);
 +      }
 +
 +      if (len)
 +      {
 +         if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0))
 +         {
 +            rect.right = UserGetSystemMetrics(SM_CXSCREEN);
 +            rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
 +         }
 +
 +         color_old = IntGdiSetTextColor(hDC, RGB(255,255,255));
 +         align_old = IntGdiSetTextAlign(hDC, TA_RIGHT);
 +         mode_old = IntGdiSetBkMode(hDC, TRANSPARENT);
 +
 +            if(!UserGetSystemMetrics(SM_CLEANBOOT))
 +            {
 +                GreExtTextOutW(hDC, rect.right - 16, rect.bottom - 48, 0, NULL, s_wszVersion, len, NULL, 0);
 +            }
 +            else
 +            {
 +                /* Safe Mode */
 +
 +                /* Version information text in top center */
 +                IntGdiSetTextAlign(hDC, TA_CENTER | TA_TOP);
 +                GreExtTextOutW(hDC, (rect.right + rect.left)/2, rect.top + 3, 0, NULL, s_wszVersion, len, NULL, 0);
 +
 +                /* Safe Mode text in corners */
 +                len = wcslen(s_wszSafeMode);
 +                IntGdiSetTextAlign(hDC, TA_LEFT | TA_TOP);
 +                GreExtTextOutW(hDC, rect.left, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
 +                IntGdiSetTextAlign(hDC, TA_RIGHT | TA_TOP);
 +                GreExtTextOutW(hDC, rect.right, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
 +                IntGdiSetTextAlign(hDC, TA_LEFT | TA_BASELINE);
 +                GreExtTextOutW(hDC, rect.left, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
 +                IntGdiSetTextAlign(hDC, TA_RIGHT | TA_BASELINE);
 +                GreExtTextOutW(hDC, rect.right, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
 +            }
 +
 +         IntGdiSetBkMode(hDC, mode_old);
 +         IntGdiSetTextAlign(hDC, align_old);
 +         IntGdiSetTextColor(hDC, color_old);
 +      }
 +   }
 +   return TRUE;
 +}
 +
 +static NTSTATUS
 +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta)
 +{
 +    PVOID DesktopHeapSystemBase = NULL;
 +    ULONG_PTR HeapSize = 400 * 1024;
 +    SIZE_T DesktopInfoSize;
 +    ULONG i;
 +
 +    TRACE("UserInitializeDesktop desktop 0x%p with name %wZ\n", pdesk, DesktopName);
 +
 +    RtlZeroMemory(pdesk, sizeof(DESKTOP));
 +
 +    /* Link the desktop with the parent window station */
 +    pdesk->rpwinstaParent = pwinsta;
 +    InsertTailList(&pwinsta->DesktopListHead, &pdesk->ListEntry);
 +
 +    /* Create the desktop heap */
 +    pdesk->hsectionDesktop = NULL;
 +    pdesk->pheapDesktop = UserCreateHeap(&pdesk->hsectionDesktop,
 +                                         &DesktopHeapSystemBase,
 +                                         HeapSize);
 +   if (pdesk->pheapDesktop == NULL)
 +   {
 +       ERR("Failed to create desktop heap!\n");
 +       return STATUS_NO_MEMORY;
 +   }
 +
 +   /* Create DESKTOPINFO */
 +   DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName->Length + sizeof(WCHAR);
 +   pdesk->pDeskInfo = RtlAllocateHeap(pdesk->pheapDesktop,
 +                                      HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY,
 +                                      DesktopInfoSize);
 +   if (pdesk->pDeskInfo == NULL)
 +   {
 +       ERR("Failed to create the DESKTOP structure!\n");
 +       return STATUS_NO_MEMORY;
 +   }
 +
 +   /* Initialize the DESKTOPINFO */
 +   pdesk->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase;
 +   pdesk->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize);
 +   RtlCopyMemory(pdesk->pDeskInfo->szDesktopName,
 +                 DesktopName->Buffer,
 +                 DesktopName->Length + sizeof(WCHAR));
 +   for (i = 0; i < NB_HOOKS; i++)
 +   {
 +      InitializeListHead(&pdesk->pDeskInfo->aphkStart[i]);
 +   }
 +
 +   InitializeListHead(&pdesk->ShellHookWindows);
 +   InitializeListHead(&pdesk->PtiList);
 +
 +   return STATUS_SUCCESS;
 +}
 +
 +/* SYSCALLS *******************************************************************/
 +
 +/*
 + * NtUserCreateDesktop
 + *
 + * Creates a new desktop.
 + *
 + * Parameters
 + *    poaAttribs
 + *       Object Attributes.
 + *
 + *    lpszDesktopDevice
 + *       Name of the device.
 + *
 + *    pDeviceMode
 + *       Device Mode.
 + *
 + *    dwFlags
 + *       Interaction flags.
 + *
 + *    dwDesiredAccess
 + *       Requested type of access.
 + *
 + *
 + * Return Value
 + *    If the function succeeds, the return value is a handle to the newly
 + *    created desktop. If the specified desktop already exists, the function
 + *    succeeds and returns a handle to the existing desktop. When you are
 + *    finished using the handle, call the CloseDesktop function to close it.
 + *    If the function fails, the return value is NULL.
 + *
 + * Status
 + *    @implemented
 + */
 +
 +HDESK APIENTRY
 +NtUserCreateDesktop(
 +   POBJECT_ATTRIBUTES ObjectAttributes,
 +   PUNICODE_STRING lpszDesktopDevice,
 +   LPDEVMODEW lpdmw,
 +   DWORD dwFlags,
 +   ACCESS_MASK dwDesiredAccess)
 +{
 +   PDESKTOP pdesk = NULL;
 +   NTSTATUS Status = STATUS_SUCCESS;
 +   HDESK hdesk;
 +   BOOLEAN Context;
 +   UNICODE_STRING ClassName;
 +   LARGE_STRING WindowName;