Commit in reactos on ELF_support
ChangeLog+271.279 -> 1.279.2.1
Makefile+6-61.262 -> 1.262.2.1
config+1-11.27 -> 1.27.2.1
apps/utils/driver/load/.cvsignore+6-61.1 -> 1.1.34.1
                      /makefile+21-211.1 -> 1.1.34.1
apps/utils/driver/unload/.cvsignore+6-61.1 -> 1.1.34.1
                        /makefile+21-211.1 -> 1.1.34.1
apps/utils/infinst/.cvsignore+6-61.1 -> 1.1.4.1
bootdata/hivesft.inf+2-21.46 -> 1.46.2.1
bootdata/packages/reactos.dff+12-21.51 -> 1.51.2.1
doc/README.WINE+21-151.20 -> 1.20.2.1
drivers/dd/null/makefile+2-21.19 -> 1.19.10.1
drivers/fs/ntfs/notes.txt+5-51.1 -> 1.1.34.1
drivers/fs/vfat/cleanup.c+2-21.15 -> 1.15.6.1
               /create.c+72-321.75 -> 1.75.2.1
               /dir.c+155-671.35 -> 1.35.2.1
               /direntry.c+201-381.17 -> 1.17.8.1
               /dirwr.c+274-821.42 -> 1.42.2.1
               /fat.c+3-31.46 -> 1.46.8.1
               /fcb.c+65-331.42 -> 1.42.2.1
               /finfo.c+146-821.38 -> 1.38.2.1
               /fsctl.c+175-811.36 -> 1.36.2.1
               /misc.c+2-21.14 -> 1.14.2.1
               /rw.c+19-71.71 -> 1.71.2.1
               /shutdown.c+3-31.8 -> 1.8.34.1
               /vfat.h+94-171.69 -> 1.69.2.1
               /volume.c+141-91.27 -> 1.27.2.1
drivers/lib/csq/MAKEFILE+7-71.1 -> 1.1.22.1
drivers/lib/ip/makefile+3-31.7 -> 1.7.2.1
drivers/lib/ip/network/address.c+14-751.6 -> 1.6.2.1
                      /arp.c+10-181.4 -> 1.4.2.1
                      /icmp.c+11-141.3 -> 1.3.2.1
                      /interface.c+164-391.3 -> 1.3.2.1
                      /ip.c+28-5421.5 -> 1.5.2.1
                      /loopback.c+16-351.5 -> 1.5.2.1
                      /neighbor.c+4-371.4 -> 1.4.2.1
                      /receive.c+6-131.3 -> 1.3.2.1
                      /router.c+111-2031.4 -> 1.4.2.1
                      /transmit.c+5-81.3 -> 1.3.2.1
                      /prefix.c-1151.3 removed
                      /route.c-6901.2 removed
drivers/lib/ip/transport/rawip/rawip.c+6-81.4 -> 1.4.2.1
drivers/lib/ip/transport/tcp/event.c+30-1311.7 -> 1.7.2.1
                            /if.c+13-131.3 -> 1.3.2.1
                            /tcp.c+221-401.9 -> 1.9.2.1
drivers/lib/ip/transport/udp/udp.c+6-81.6 -> 1.6.2.1
drivers/lib/oskittcp/include/oskittcp.h+11.7 -> 1.7.2.1
drivers/lib/oskittcp/oskittcp/interface.c+7-81.16 -> 1.16.2.1
                             /ip_output.c+15-41.4 -> 1.4.6.1
                             /tcp_output.c-11.5 -> 1.5.6.1
drivers/net/afd/afd/connect.c+10-61.5 -> 1.5.2.1
                   /info.c+5-11.4 -> 1.4.8.1
                   /main.c+138-571.13 -> 1.13.2.1
                   /read.c+102-531.12 -> 1.12.2.1
                   /select.c+40-111.7 -> 1.7.2.1
                   /tdi.c+56-51.21 -> 1.21.6.1
                   /write.c+3-11.12 -> 1.12.2.1
drivers/net/afd/include/afd.h+8-11.25 -> 1.25.2.1
                       /tdi_proto.h+101.3 -> 1.3.6.1
drivers/net/afd/makefile+3-31.14 -> 1.14.2.1
drivers/net/ndis/ndis/main.c+1-11.19 -> 1.19.2.1
                     /miniport.c+24-221.43 -> 1.43.2.1
                     /protocol.c+3-11.22 -> 1.22.2.1
drivers/net/tcpip/datalink/lan.c+115-261.27 -> 1.27.2.1
drivers/net/tcpip/include/address.h+7-81.12 -> 1.12.2.1
                         /arp.h+1-31.2 -> 1.2.36.1
                         /debug.h+2-11.11 -> 1.11.2.1
                         /icmp.h+4-51.3 -> 1.3.2.1
                         /interface.h+3-11.3 -> 1.3.8.1
                         /ip.h+10-481.18 -> 1.18.2.1
                         /precomp.h+2-11.8 -> 1.8.2.1
                         /rawip.h+1-11.5 -> 1.5.6.1
                         /route.h+1-641.6 -> 1.6.2.1
                         /router.h+9-211.6 -> 1.6.2.1
                         /tcp.h+161.11 -> 1.11.6.1
                         /tilists.h-131.1 -> 1.1.8.1
                         /titypes.h+7-41.14 -> 1.14.2.1
                         /transmit.h+1-11.3 -> 1.3.2.1
                         /udp.h+2-21.6 -> 1.6.2.1
                         /prefix.h-271.4 removed
drivers/net/tcpip/makefile+14-121.31 -> 1.31.2.1
drivers/net/tcpip/tcpip/dispatch.c+104-951.26 -> 1.26.2.1
                       /fileobjs.c+9-171.24 -> 1.24.2.1
                       /iinfo.c+1-11.4 -> 1.4.8.1
                       /info.c+11-161.9 -> 1.9.2.1
                       /lock.c+6-11.1 -> 1.1.2.1
                       /main.c+8-31.42 -> 1.42.2.1
                       /ninfo.c+78-561.7 -> 1.7.2.1
drivers/test/csqtest/Makefile+7-71.1 -> 1.1.22.1
                    /SOURCES+5-51.1 -> 1.1.22.1
drivers/video/displays/vga/main/enable.c+4-41.3 -> 1.3.20.1
drivers/video/displays/vga/objects/copybits.c+40-401.1 -> 1.1.24.1
hal/halx86/apic.c+853added 1.2.2.1
          /Makefile+2-11.14 -> 1.14.2.1
          /halinit.c+1-21.9 -> 1.9.8.1
          /misc.c+14-51.7 -> 1.7.2.1
          /mp.c+202-9731.11 -> 1.11.2.1
          /mps.S+14-11.3 -> 1.3.2.1
          /mpsirql.c+74-651.11 -> 1.11.2.1
          /timer.c+11-21.7 -> 1.7.2.1
          /.cvsignore-71.5 removed
          /adapter.c-6791.14 removed
          /beep.c-791.5 removed
          /bus.c-5321.7 removed
          /display.c-7901.18 removed
          /dma.c-4451.10 removed
          /drive.c-311.4 removed
          /enum.c-251.5 removed
          /fmutex.c-531.5 removed
          /halx86mp.rc-51.5 removed
          /halx86up.rc-51.5 removed
          /irql.c-4801.22 removed
          /isa.c-791.7 removed
          /kdbg.c-5481.8 removed
          /mca.c-821.3 removed
          /mpsboot.asm-1061.1 removed
          /pci.c-8041.14 removed
          /portio.c-3421.4 removed
          /pwroff.c-1211.4 removed
          /reboot.c-721.7 removed
          /spinlock.c-1011.9 removed
          /sysbus.c-701.7 removed
          /sysinfo.c-761.4 removed
          /time.c-3591.6 removed
hal/halx86/include/apic.h+197added 1.1.2.1
                  /hal.h+11-21.15 -> 1.15.2.1
                  /mps.h+3-1571.7 -> 1.7.2.1
include/dinput.h+2349added 1.1.2.1
       /WinDNS.h+41.3 -> 1.3.22.1
       /funcs.h+24-241.65 -> 1.65.2.1
       /tgetopt.h+4-41.1 -> 1.1.32.1
       /mmsystem.h-22241.1 removed
include/afd/shared.h+1-251.11 -> 1.11.2.1
include/ddk/exfuncs.h+17-21.43 -> 1.43.2.1
           /iofuncs.h+4-41.46 -> 1.46.2.1
           /iotypes.h+2-21.69 -> 1.69.2.1
           /kefuncs.h+1-11.48 -> 1.48.2.1
include/ntdll/rtl.h+14-21.52 -> 1.52.2.1
include/ntos/haltypes.h+25-231.9 -> 1.9.2.1
            /kdbgsyms.h+1-11.4 -> 1.4.32.1
            /ntdef.h+261.8 -> 1.8.6.1
            /rtl.h+25-381.38 -> 1.38.2.1
            /zw.h+9-91.35 -> 1.35.2.1
            /zwtypes.h+1-11.46 -> 1.46.2.1
include/win32k/ntuser.h+3-31.139 -> 1.139.2.1
include/wine/mmsystem.h+46added 1.1.2.1
            /objidl.h+2-21.5 -> 1.5.2.1
            /unicode.h+141.8 -> 1.8.16.1
lib/advapi32/reg/reg.c+8-151.63 -> 1.63.2.1
lib/cabinet/Makefile.ros-template+2-21.3 -> 1.3.16.1
           /cabextract.c+20-191.4 -> 1.4.6.1
           /winehq2ros.patch+6-61.2 -> 1.2.6.1
lib/comctl32/Makefile.ros-template+2-21.3 -> 1.3.16.1
            /animate.c+16-111.7 -> 1.7.2.1
            /comboex.c+13-141.7 -> 1.7.2.1
            /datetime.c+640-9811.5 -> 1.5.6.1
            /flatsb.c+1-11.7 -> 1.7.6.1
            /header.c+1-11.6 -> 1.6.6.1
            /hotkey.c+49-521.5 -> 1.5.2.1
            /imagelist.c+11.15 -> 1.15.2.1
            /ipaddress.c+10-101.6 -> 1.6.6.1
            /listview.c+87-761.15 -> 1.15.6.1
            /monthcal.c+278-3131.5 -> 1.5.6.1
            /nativefont.c+26-321.3 -> 1.3.6.1
            /progress.c+3-31.7 -> 1.7.6.1
            /rebar.c+27-301.13 -> 1.13.2.1
            /status.c+46-491.6 -> 1.6.6.1
            /syslink.c+3-51.2 -> 1.2.6.1
            /tab.c+1-21.11 -> 1.11.2.1
            /toolbar.c+264-1971.20 -> 1.20.2.1
            /tooltips.c+34-161.9 -> 1.9.2.1
            /trackbar.c+14-101.6 -> 1.6.6.1
            /treeview.c+11-71.12 -> 1.12.2.1
            /updown.c+53-281.6 -> 1.6.2.1
            /winehq2ros.patch+89-141.12 -> 1.12.2.1
lib/comdlg32/Makefile.ros-template+1-11.3 -> 1.3.16.1
            /filedlg.c+11-91.11 -> 1.11.2.1
            /filedlgbrowser.h+1-11.1 -> 1.1.24.1
            /printdlg.c+4-41.8 -> 1.8.2.1
lib/crtdll/time/ctime.c+8-81.11 -> 1.11.8.1
lib/dinput/.cvsignore+11added 1.1.2.1
          /Makefile.in+23added 1.1.2.1
          /Makefile.ros+28added 1.3.2.1
          /Makefile.ros-template+28added 1.2.2.1
          /data_formats.c+302added 1.1.2.1
          /device.c+884added 1.1.2.1
          /device_private.h+236added 1.1.2.1
          /dinput.spec+7added 1.1.2.1
          /dinput.stubs.c+3added 1.1.2.1
          /dinput_main.c+756added 1.1.2.1
          /dinput_private.h+58added 1.1.2.1
          /joystick_linux.c+1715added 1.1.2.1
          /joystick_linuxinput.c+1090added 1.1.2.1
          /keyboard.c+868added 1.1.2.1
          /mouse.c+1253added 1.2.2.1
          /regsvr.c+558added 1.1.2.1
          /version.rc+26added 1.1.2.1
          /winehq2ros.patch+830added 1.1.2.1
          /Makefile+3-241.2 -> 1.2.16.1
          /dinput.c-431.1 removed
          /dinput.def-71.1 removed
lib/dnsapi/Makefile+2-21.5 -> 1.5.16.1
lib/dnsapi/dnsapi/adns.c+2-21.1 -> 1.1.24.1
                 /context.c+3-11.1 -> 1.1.24.1
                 /free.c+5-31.1 -> 1.1.24.1
                 /names.c+5-31.3 -> 1.3.22.1
                 /query.c+115-931.2 -> 1.2.24.1
                 /stubs.c+120-1161.1 -> 1.1.24.1
lib/dnsapi/include/internal/windns.h+1-11.1 -> 1.1.24.1
lib/expat/Makefile+2-21.3 -> 1.3.16.1
lib/expat/lib/libexpat.def+1-11.1 -> 1.1.20.1
             /libexpatw.def+1-11.1 -> 1.1.20.1
lib/freetype/i386/setjmplongjmp.s+39-391.1 -> 1.1.34.1
lib/icmp/.cvsignore+2-161.1 -> 1.1.6.1
        /Makefile.ros-template+2-21.1 -> 1.1.6.1
        /icmp.dsp+96-961.1 -> 1.1.6.1
        /icmp_main.c+9-381.1 -> 1.1.6.1
        /winehq2ros.patch+6-731.1 -> 1.1.6.1
lib/imagehlp/makefile+1-11.6 -> 1.6.8.1
lib/imm32/Makefile+1-11.5 -> 1.5.16.1
lib/iphlpapi/Makefile.in+1-11.3 -> 1.3.20.1
            /Makefile.ros-template+2-21.2 -> 1.2.16.1
            /ifenum_reactos.c+2-31.8 -> 1.8.14.1
            /iphlpapi_main.c+1-11.4 -> 1.4.20.1
            /iphlpapi_private.h+5-51.4 -> 1.4.20.1
            /ipstats_reactos.c+11.6 -> 1.6.2.1
            /makefile+2-21.9 -> 1.9.20.1
            /registry.c+34-351.5 -> 1.5.20.1
            /resinfo_reactos.c+231-121.5 -> 1.5.8.1
            /route_reactos.c+5-21.1 -> 1.1.20.1
lib/kernel32/file/create.c+21-71.40 -> 1.40.2.1
                 /delete.c+4-11.17 -> 1.17.8.1
                 /file.c+3-31.60 -> 1.60.2.1
                 /iocompl.c+17-251.15 -> 1.15.2.1
                 /move.c+94-401.14 -> 1.14.16.1
lib/kernel32/makefile+2-21.89 -> 1.89.2.1
lib/kernel32/misc/atom.c+37-11.20 -> 1.20.16.1
                 /dllmain.c+1-81.37 -> 1.37.2.1
                 /lang.c+198-921.24 -> 1.24.2.1
                 /nls.c+1-31.5 -> 1.5.6.1
                 /profile.c+1444-14611.14 -> 1.14.2.1
                 /stubs.c+6-351.94 -> 1.94.2.1
                 /time.c+60-431.32 -> 1.32.2.1
lib/kernel32/string/lstring.c+53-41.11 -> 1.11.10.1
lib/kernel32/synch/wait.c+5-141.31 -> 1.31.2.1
lib/kernel32/thread/thread.c+24-11.56 -> 1.56.2.1
lib/kjs/makefile+2-21.1 -> 1.1.24.1
lib/libwine/makefile+2-21.3 -> 1.3.6.1
lib/midimap/.cvsignore+11.1 -> 1.1.2.1
           /Makefile.ros-template+2-21.1 -> 1.1.2.1
lib/mpr/Makefile.in+1-31.3 -> 1.3.2.1
       /Makefile.ros-template+2-21.3 -> 1.3.2.1
       /mpr.spec+1-11.1 -> 1.1.22.1
       /mpr_main.c+1-11.4 -> 1.4.16.1
       /version.rc-11.1 -> 1.1.18.1
lib/msacm/Makefile.ros-template+2-21.3 -> 1.3.8.1
lib/msafd/include/msafd.h+74-251.9 -> 1.9.2.1
lib/msafd/misc/dllmain.c+376-151.19 -> 1.19.2.1
              /event.c+134-291.3 -> 1.3.6.1
              /helpers.c+3-21.11 -> 1.11.2.1
              /sndrcv.c+89-781.11 -> 1.11.2.1
lib/msvcrt20/Makefile+1-11.3 -> 1.3.6.1
lib/msvcrt/Makefile+2-21.48 -> 1.48.6.1
lib/msvcrt/setjmp/i386/setjmp.s+52-521.1 -> 1.1.34.1
lib/msvcrt/time/ctime.c+8-61.12 -> 1.12.8.1
lib/msvideo/Makefile.ros-template+2-21.1 -> 1.1.8.1
lib/netapi32/Makefile.ros-template+2-21.3 -> 1.3.16.1
lib/ntdll/def/ntdll.def+2-11.134 -> 1.134.2.1
lib/ntdll/ldr/utils.c+37-11.101 -> 1.101.2.1
             /tls.c-1271.1 removed
lib/ntdll/rtl/path.c+22-281.29 -> 1.29.8.1
lib/odbc32/Makefile.ros-template+2-21.2 -> 1.2.16.1
lib/ole32/Makefile.ros-template+2-21.2 -> 1.2.16.1
         /compobj.c+142-861.16 -> 1.16.2.1
         /errorinfo.c+2-21.6 -> 1.6.6.1
         /marshal.c+441.8 -> 1.8.2.1
         /ole2impl.c+1071.4 -> 1.4.2.1
         /ole2stubs.c-121.2 -> 1.2.24.1
         /ole32.spec+4-41.3 -> 1.3.2.1
         /storage.c+1-11.11 -> 1.11.2.1
         /storage32.c+11-111.9 -> 1.9.2.1
         /winehq2ros.patch+2-341.8 -> 1.8.2.1
lib/oleaut32/oleaut32_Pl.rc+32added 1.1.2.1
            /winehq2ros.patch+33added 1.1.2.1
            /.cvsignore+3-21.5 -> 1.5.2.1
            /Makefile.in+12-121.6 -> 1.6.2.1
            /Makefile.ros-template+2-21.5 -> 1.5.2.1
            /connpt.c+15-211.2 -> 1.2.6.1
            /dispatch.c+7-271.2 -> 1.2.6.1
            /hash.c+2-41.1 -> 1.1.22.1
            /oaidl_p.c+17-61.1 -> 1.1.22.1
            /oleaut.c+26-51.4 -> 1.4.20.1
            /oleaut32.rc+2-11.5 -> 1.5.2.1
            /oleaut32.spec+26-261.8 -> 1.8.20.1
            /oleaut32_De.rc+1-11.1 -> 1.1.22.1
            /olefont.c+221-811.1 -> 1.1.22.1
            /olepicture.c+567-531.3 -> 1.3.6.1
            /safearray.c+25-131.6 -> 1.6.20.1
            /tmarshal.c+215-1421.2 -> 1.2.6.1
            /typelib.c+388-2621.2 -> 1.2.20.1
            /typelib.h+21-151.1 -> 1.1.22.1
            /typelib2.c+271-1021.2 -> 1.2.20.1
            /usrmarshal.c+21.1 -> 1.1.22.1
            /varformat.c+4-51.2 -> 1.2.20.1
            /variant.c+712-1251.10 -> 1.10.20.1
            /variant.h+7-91.3 -> 1.3.20.1
            /vartype.c+13-101.9 -> 1.9.20.1
lib/oledlg/Makefile.ros-template+2-21.3 -> 1.3.16.1
          /insobjdlg.c+1-11.1 -> 1.1.24.1
lib/olepro32/Makefile.ros-template+2-21.2 -> 1.2.16.1
lib/opengl32/gl.c+1-11.8 -> 1.8.8.1
            /icdtable.h+1-11.4 -> 1.4.8.1
            /glfuncs.mac-3371.1 removed
            /slowlist.h-1921.1 removed
            /slowlist.mac-1741.1 removed
            /stubs.c-5201.3 removed
            /tebimports.asm-181.4 removed
            /teblist.h-1631.1 removed
            /teblist.mac-1641.1 removed
lib/pseh/framebased.c+11.5.10.1 -> 1.5.10.2
lib/riched20/Makefile.ros-template+2-21.1 -> 1.1.2.1
lib/richedit/Makefile.ros-template+2-21.2 -> 1.2.16.1
lib/rpcrt4/Makefile.ros-template+2-21.3 -> 1.3.16.1
          /cproxy.c+2-21.5 -> 1.5.2.1
          /ndr_marshall.c+85-851.1 -> 1.1.18.1
lib/rtl/acl.c+15-151.4 -> 1.4.2.1
       /heap.c+280-2671.3 -> 1.3.6.1
       /image.c+28-111.1 -> 1.1.14.1
       /mem.c+6-71.2 -> 1.2.8.1
       /nls.c+10-101.1 -> 1.1.18.1
       /unicode.c+291.9 -> 1.9.6.1
lib/setupapi/Makefile.ros-template+2-21.4 -> 1.4.16.1
lib/shell32/Makefile.ros-template+2-21.6 -> 1.6.2.1
           /changenotify.c+9-91.4 -> 1.4.6.1
           /debughlp.c+3-41.5 -> 1.5.6.1
           /iconcache.c+1-11.9 -> 1.9.2.1
           /memorystream.c+25-371.5 -> 1.5.2.1
           /pidl.c+8-91.26 -> 1.26.2.1
           /pidl.h+4-31.10 -> 1.10.6.1
           /regsvr.c+31.3 -> 1.3.6.1
           /shell32.spec+1-11.13 -> 1.13.2.1
           /shell32_En.rc+321.7 -> 1.7.2.1
           /shell32_Fr.rc+321.7 -> 1.7.2.1
           /shell32_main.h+31.23 -> 1.23.6.1
           /shellord.c+1-11.10 -> 1.10.2.1
           /shellpath.c+1135-6751.12 -> 1.12.2.1
           /shlfileop.c+109-611.9 -> 1.9.2.1
           /shlfolder.c+1-11.13 -> 1.13.2.1
           /shpolicy.c+4-41.2 -> 1.2.18.1
           /shresdef.h+281.2 -> 1.2.8.1
           /undocshell.h-81.7 -> 1.7.6.1
           /version.h+4-41.1 -> 1.1.6.1
           /version16.rc+2-21.1 -> 1.1.24.1
           /winehq2ros.patch+1126-1541.5 -> 1.5.2.1
lib/shlwapi/Makefile.ros-template+2-21.9 -> 1.9.2.1
           /clist.c+1-11.2 -> 1.2.2.1
           /url.c+1-11.11 -> 1.11.2.1
lib/string/strncpy.c+2-21.2 -> 1.2.34.1
lib/syssetup/syssetup.rc+5-21.8 -> 1.8.2.1
            /syssetup_Cz.rc+4-41.10 -> 1.10.2.1
            /syssetup_De.rc+4-41.9 -> 1.9.2.1
            /syssetup_En.rc+4-41.12 -> 1.12.2.1
            /syssetup_Fr.rc+4-41.7 -> 1.7.2.1
            /wizard.c+13-91.15 -> 1.15.2.1
lib/twain/Makefile+2-21.7 -> 1.7.16.1
lib/unicode/Makefile.ros-template+2-21.3 -> 1.3.2.1
           /cptable.c+1-11.2 -> 1.2.20.1
           /wctomb.c+1-11.2 -> 1.2.20.1
           /wine_unicode.def+1-11.4 -> 1.4.18.1
lib/urlmon/Makefile.ros-template+2-21.2 -> 1.2.8.1
lib/user32/Makefile+2-21.40 -> 1.40.8.1
lib/user32/controls/combo.c+51.19 -> 1.19.8.1
                   /edit.c+36-61.27 -> 1.27.8.1
lib/user32/misc/misc.c+6-61.9 -> 1.9.2.1
lib/user32/windows/class.c+5-31.51 -> 1.51.8.1
                  /draw.c-31.43 -> 1.43.2.1
                  /font.c+2-21.11 -> 1.11.8.1
                  /mdi.c+5-101.16 -> 1.16.8.1
                  /menu.c+46-161.71 -> 1.71.6.1
                  /message.c+4-41.43 -> 1.43.6.1
lib/userenv/environment.c+37-361.8 -> 1.8.2.1
lib/uuid/uuid.c+51.2 -> 1.2.6.1
lib/version/makefile+2-21.15 -> 1.15.16.1
lib/winmm/Makefile.ros-template+2-21.3 -> 1.3.16.1
         /lolvldrv.c+4-11.7 -> 1.7.6.1
         /mci.c+11-111.5 -> 1.5.6.1
         /mmsystem.c+7-51.3 -> 1.3.2.1
         /playsound.c+2-21.4 -> 1.4.16.1
         /time.c-111.5 -> 1.5.2.1
         /winehq2ros.patch+46-101.9 -> 1.9.2.1
         /winmm.c+14-51.14 -> 1.14.2.1
lib/winmm/midimap/Makefile.ros-template+2-21.3 -> 1.3.2.1
lib/winmm/wavemap/Makefile.ros-template+2-21.2 -> 1.2.8.1
lib/winspool/Makefile+1-11.5 -> 1.5.16.1
lib/ws2_32/include/ws2_32.h+81.9 -> 1.9.8.1
lib/ws2_32/makefile+5-51.18 -> 1.18.2.1
lib/ws2_32/misc/dllmain.c+111.18 -> 1.18.2.1
               /event.c+61.6 -> 1.6.34.1
               /ns.c+236-91.9 -> 1.9.8.1
               /stubs.c+1-11.14 -> 1.14.2.1
ntoskrnl/Makefile+8-81.156 -> 1.156.2.1
        /ntoskrnl.def+4-41.201 -> 1.201.2.1
ntoskrnl/cm/regfile.c+16-161.83 -> 1.83.2.1
ntoskrnl/ex/sysinfo.c+3-81.59 -> 1.59.2.1
           /time.c+28-231.24 -> 1.24.2.1
ntoskrnl/include/internal/ex.h+31.44 -> 1.44.2.1
                         /io.h+3-31.49 -> 1.49.2.1
                         /ke.h+25-51.66 -> 1.66.2.1
                         /ps.h+2-41.75 -> 1.75.2.1
ntoskrnl/include/config.h+18added 1.2.2.1
                /ntoskrnl.h+21.6 -> 1.6.2.1
ntoskrnl/io/iocomp.c+6-61.15 -> 1.15.8.1
           /parttab.c+4-41.8 -> 1.8.8.1
ntoskrnl/kd/gdbstub.c+5-41.26 -> 1.26.2.1
ntoskrnl/ke/dpc.c+7-91.48 -> 1.48.2.1
           /ipi.c+122-1181.3 -> 1.3.2.1
           /main.c+41-351.206 -> 1.206.2.1
           /process.c+22-141.31 -> 1.31.2.1
           /timer.c+57-71.90 -> 1.90.2.1
ntoskrnl/ke/i386/exp.c+5-51.94 -> 1.94.2.1
                /fpu.c+1-11.17 -> 1.17.2.1
                /irq.c+17-211.55 -> 1.55.2.1
                /kernel.c+41-411.42 -> 1.42.2.1
                /multiboot.S+34-111.29 -> 1.29.2.1
                /tskswitch.S+24-191.21 -> 1.21.2.1
ntoskrnl/ldr/init.c+14-11.49 -> 1.49.2.1
ntoskrnl/mm/i386/page.c+71-791.77 -> 1.77.2.1
                /pfault.c+1-11.11 -> 1.11.2.1
ntoskrnl/mm/npool.c+1-141.92 -> 1.92.2.1
ntoskrnl/ps/cid.c+5-241.2 -> 1.2.2.1
           /kill.c+14-51.86 -> 1.86.2.1
           /process.c+31-161.157 -> 1.157.2.1
           /thread.c+11-101.138 -> 1.138.2.1
           /w32call.c+2-51.18 -> 1.18.2.1
regtests/regtests/regtests.c+221.5 -> 1.5.4.1
                 /regtests.def+41.2 -> 1.2.4.1
regtests/shared/regtests.c+94-291.9 -> 1.9.2.1
               /regtests.h+19-11.12 -> 1.12.2.1
subsys/csrss/win32csr/desktopbg.c+3-61.11 -> 1.11.2.1
                     /guiconsole.c+5-41.22 -> 1.22.2.1
subsys/system/explorer/Makefile+1-11.43 -> 1.43.2.1
subsys/system/msiexec/Makefile+1-11.1 -> 1.1.6.1
                     /msiexec.c+86-281.1 -> 1.1.6.1
subsys/system/winlogon/winlogon.h+6-11.4 -> 1.4.8.1
subsys/win32k/include/desktop.h+11.9 -> 1.9.2.1
subsys/win32k/makefile+3-31.105 -> 1.105.2.1
subsys/win32k/ntuser/desktop.c+5-361.24 -> 1.24.2.1
                    /focus.c+6-41.25 -> 1.25.2.1
                    /misc.c+41-11.88 -> 1.88.2.1
                    /painting.c+6-11.87 -> 1.87.2.1
                    /stubs.c+1-121.47 -> 1.47.2.1
subsys/win32k/objects/brush.c+5-11.40 -> 1.40.10.1
                     /cliprgn.c+8-31.42 -> 1.42.10.1
                     /dc.c+13-41.147 -> 1.147.2.1
tools/helper.mk+49-191.95 -> 1.95.2.1
     /mkconfig.c+11-21.5 -> 1.5.6.1
tools/rgenstat/web/.cvsignore+1-11.1 -> 1.1.34.1
tools/wmc/y_tab.c+2-21.3 -> 1.3.34.1
w32api/include/commctrl.h+13-71.8 -> 1.8.6.1
              /mmsystem.h+3-31.1 -> 1.1.20.1
              /oaidl.h+418-51.7 -> 1.7.20.1
              /objidl.h+2-21.3 -> 1.3.18.1
              /ocidl.h+491.3 -> 1.3.20.1
              /oleauto.h+61.11 -> 1.11.20.1
              /rpc.h+91.2 -> 1.2.18.1
              /rpcndr.h+31.3 -> 1.3.6.1
              /rpcproxy.h+111.2 -> 1.2.18.1
              /shlobj.h+121.7 -> 1.7.6.1
              /winuser.h+4-11.10 -> 1.10.2.1
              /wtypes.h+8-251.5 -> 1.5.20.1
w32api/include/ddk/ntapi.h+10-101.12 -> 1.12.2.1
                  /ntifs.h+1-11.7 -> 1.7.4.1
                  /win2k.h+3-31.1 -> 1.1.20.1
ntoskrnl/include/internal/i386/hal.h+42added 1.8.4.1
+29027-22317
26 added + 38 removed + 410 modified, total 474 files
 - merge with HEAD
 - removed dead file from ntdll

reactos
ChangeLog 1.279 -> 1.279.2.1
diff -u -r1.279 -r1.279.2.1
--- ChangeLog	21 Nov 2004 23:00:18 -0000	1.279
+++ ChangeLog	8 Dec 2004 21:56:46 -0000	1.279.2.1
@@ -1,3 +1,30 @@
+2004-11-27  WaxDragon  <waxdragon@gmail.com>
+
+	* bootdata/packages/reactos.dff: Add dnsapi.dll, iphlpapi.dll,
+	rpcrt4.dll, and ole32.dll.
+
+2004-11-27  Casper S. Hornstrup  <chorns@users.sourceforge.net>
+
+	* apps/utils/driver/load/.cvsignore: Use native line-endings.
+	* apps/utils/driver/load/makefile: Ditto.
+	* apps/utils/driver/unload/.cvsignore: Ditto.
+	* apps/utils/driver/unload/makefile: Ditto.
+	* apps/utils/infinst/.cvsignore: Ditto.
+	* drivers/fs/ntfs/notes.txt: Ditto.
+	* drivers/lib/csq/MAKEFILE: Ditto.
+	* drivers/test/csqtest/Makefile: Ditto.
+	* drivers/test/csqtest/SOURCES: Ditto.
+	* drivers/video/displays/vga/main/enable.c: Ditto.
+	* drivers/video/displays/vga/objects/copybits.c: Ditto.
+	* include/tgetopt.h: Ditto.
+	* include/ntos/kdbgsyms.h: Ditto.
+	* lib/freetype/i386/setjmplongjmp.s: Ditto.
+	* lib/icmp/icmp.dsp: Ditto.
+	* lib/msvcrt/setjmp/i386/setjmp.s: Ditto.
+	* lib/string/strncpy.c: Ditto.
+	* tools/rgenstat/web/.cvsignore: Ditto.
+	* tools/wmc/y_tab.c: Ditto.
+
 2004-11-21  Casper S. Hornstrup  <chorns@users.sourceforge.net>
 
 	* apps/utils/Makefile (UTIL_APPS): Remove regsvr32.

reactos
Makefile 1.262 -> 1.262.2.1
diff -u -r1.262 -r1.262.2.1
--- Makefile	21 Nov 2004 21:02:03 -0000	1.262
+++ Makefile	8 Dec 2004 21:56:46 -0000	1.262.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.262 2004/11/21 21:02:03 chorns Exp $
+# $Id: Makefile,v 1.262.2.1 2004/12/08 21:56:46 hyperion Exp $
 #
 # Global makefile
 #
@@ -27,7 +27,7 @@
 
 # Hardware Abstraction Layers
 # halx86
-HALS = halx86
+HALS = halx86/up halx86/mp
 
 # Bus drivers
 # acpi isapnp pci
@@ -38,10 +38,10 @@
 LIB_FSLIB = vfatlib
 
 # Static libraries
-LIB_STATIC = string rosrtl epsapi uuid libwine zlib rtl tgetopt pseh adns
+LIB_STATIC = string rosrtl epsapi uuid libwine zlib rtl tgetopt pseh adns dxguid 
 
 # Keyboard layout libraries
-DLLS_KBD = kbdda kbddv kbdfr kbdgr kbdse kbduk kbdus
+DLLS_KBD = kbdda kbddv kbdfr kbdgr kbdse kbduk kbdus 
 
 # Control Panels
 DLLS_CPL = cpl
@@ -56,7 +56,7 @@
 	msgina msimg32 msvcrt20 msvideo mswsock netapi32 ntdll ole32 oleaut32 oledlg opengl32 packet psapi \
 	riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi snmpapi syssetup twain unicode user32 \
 	userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda \
-	dnsapi \
+	dnsapi dinput dinput8\
 	$(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)
 
 SUBSYS = smss win32k csrss ntvdm
@@ -96,7 +96,7 @@
 STORAGE_DRIVERS = atapi cdrom class2 disk floppy scsiport diskdump
 
 # System applications
-# autochk cmd format services setup usetup welcome winlogon
+# autochk cmd format services setup usetup welcome winlogon msiexec 
 SYS_APPS = autochk calc cmd explorer expand format regedt32 regsvr32 \
   services setup taskmgr userinit usetup welcome vmwinst winlogon \
   regedit winefile

reactos
config 1.27 -> 1.27.2.1
diff -u -r1.27 -r1.27.2.1
--- config	20 Nov 2004 17:48:37 -0000	1.27
+++ config	8 Dec 2004 21:56:46 -0000	1.27.2.1
@@ -25,7 +25,7 @@
 #
 # Whether to compile for debugging
 #
-DBG := 0
+DBG := 1
 
 #
 # Whether to compile with optimizations

reactos/apps/utils/driver/load
.cvsignore 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- .cvsignore	25 Sep 2003 15:40:23 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:56:47 -0000	1.1.34.1
@@ -1,6 +1,6 @@
-*.o
-*.d
-*.exe
-*.coff
-*.sym
-*.map
+*.o
+*.d
+*.exe
+*.coff
+*.sym
+*.map

reactos/apps/utils/driver/load
makefile 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- makefile	25 Sep 2003 15:40:23 -0000	1.1
+++ makefile	8 Dec 2004 21:56:47 -0000	1.1.34.1
@@ -1,21 +1,21 @@
-PATH_TO_TOP = ../../../..
-
-TARGET_NORC = yes
-
-TARGET_TYPE = program
-
-TARGET_APPTYPE = console
-
-TARGET_NAME = load
-
-TARGET_CFLAGS = -DUNICODE -D_UNICODE
-
-TARGET_SDKLIBS = ntdll.a
-
-TARGET_OBJECTS = $(TARGET_NAME).o
-
-include $(PATH_TO_TOP)/rules.mak
-
-include $(TOOLS_PATH)/helper.mk
-
-# EOF
+PATH_TO_TOP = ../../../..
+
+TARGET_NORC = yes
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = load
+
+TARGET_CFLAGS = -DUNICODE -D_UNICODE
+
+TARGET_SDKLIBS = ntdll.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF

reactos/apps/utils/driver/unload
.cvsignore 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- .cvsignore	25 Sep 2003 15:40:23 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:56:47 -0000	1.1.34.1
@@ -1,6 +1,6 @@
-*.o
-*.d
-*.exe
-*.coff
-*.sym
-*.map
+*.o
+*.d
+*.exe
+*.coff
+*.sym
+*.map

reactos/apps/utils/driver/unload
makefile 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- makefile	25 Sep 2003 15:40:23 -0000	1.1
+++ makefile	8 Dec 2004 21:56:47 -0000	1.1.34.1
@@ -1,21 +1,21 @@
-PATH_TO_TOP = ../../../..
-
-TARGET_NORC = yes
-
-TARGET_TYPE = program
-
-TARGET_APPTYPE = console
-
-TARGET_NAME = unload
-
-TARGET_CFLAGS = -DUNICODE -D_UNICODE
-
-TARGET_SDKLIBS = ntdll.a
-
-TARGET_OBJECTS = $(TARGET_NAME).o
-
-include $(PATH_TO_TOP)/rules.mak
-
-include $(TOOLS_PATH)/helper.mk
-
-# EOF
+PATH_TO_TOP = ../../../..
+
+TARGET_NORC = yes
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = unload
+
+TARGET_CFLAGS = -DUNICODE -D_UNICODE
+
+TARGET_SDKLIBS = ntdll.a
+
+TARGET_OBJECTS = $(TARGET_NAME).o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF

reactos/apps/utils/infinst
.cvsignore 1.1 -> 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- .cvsignore	11 Oct 2004 21:08:06 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:56:47 -0000	1.1.4.1
@@ -1,6 +1,6 @@
-*.o
-*.d
-*.exe
-*.coff
-*.sym
-*.map
+*.o
+*.d
+*.exe
+*.coff
+*.sym
+*.map

reactos/bootdata
hivesft.inf 1.46 -> 1.46.2.1
diff -u -r1.46 -r1.46.2.1
--- hivesft.inf	13 Nov 2004 00:16:32 -0000	1.46
+++ hivesft.inf	8 Dec 2004 21:56:47 -0000	1.46.2.1
@@ -607,8 +607,8 @@
 0x00,0x00,0x0a,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 
 
-;HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\system32\cmd.exe"
-HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\explorer.exe"
+HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\system32\cmd.exe"
+;HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Shell",0x00020000,"%SystemRoot%\explorer.exe"
 HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartServices",0x00010001,0x00000001
 HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","StartGUI",0x00010001,0x00000000
 HKLM,"SOFTWARE\ReactOS\Windows NT\CurrentVersion\Winlogon","Userinit",0x00020000,"%SystemRoot%\system32\userinit.exe"

reactos/bootdata/packages
reactos.dff 1.51 -> 1.51.2.1
diff -u -r1.51 -r1.51.2.1
--- reactos.dff	24 Nov 2004 17:57:14 -0000	1.51
+++ reactos.dff	8 Dec 2004 21:56:47 -0000	1.51.2.1
@@ -68,11 +68,15 @@
 lib\comctl32\comctl32.dll               1
 lib\comdlg32\comdlg32.dll               1
 lib\crtdll\crtdll.dll                   1
-lib\expat\libexpat.dll                  1
+lib\dinput\dinput.dll                   1
+lib\dinput8\dinput8.dll                 1
+lib\dsound\dsound.dll			1
+lib\expat\expat.dll                     1
 lib\fmifs\fmifs.dll                     1
 lib\freetype\freetype.dll               1
 lib\gdi32\gdi32.dll                     1
 lib\gdiplus\gdiplus.dll                 1
+lib\glu32\glu32.dll                     1
 lib\imagehlp\imagehlp.dll               1
 lib\imm32\imm32.dll                     1
 lib\iphlpapi\iphlpapi.dll               1
@@ -85,6 +89,7 @@
 lib\kbdus\kbdus.dll                     1
 lib\kernel32\kernel32.dll               1
 lib\lzexpand\lz32.dll                   1
+lib\mesa32\mesa32.dll                   1
 lib\midimap\midimap.dll                 1
 lib\mmdrv\mmdrv.dll                     1
 lib\mpr\mpr.dll                         1
@@ -107,7 +112,7 @@
 lib\shlwapi\shlwapi.dll                 1
 lib\syssetup\syssetup.dll               1
 lib\twain\twain_32.dll                  1
-lib\unicode\libwine_unicode.dll         1
+lib\unicode\wine_unicode.dll            1
 lib\user32\user32.dll                   1
 lib\userenv\userenv.dll                 1
 lib\version\version.dll                 1
@@ -118,6 +123,11 @@
 lib\ws2help\ws2help.dll                 1
 lib\wshirda\wshirda.dll                 1
 lib\wsock32\wsock32.dll                 1
+lib\dnsapi\dnsapi.dll                   1
+lib\iphlpapi\iphlpapi.dll               1
+lib\rpcrt4\rpcrt4.dll                   1
+lib\ole32\ole32.dll                     1
+lib\opengl32\opengl32.dll               1
 subsys\csrss\csrss.exe                  1
 subsys\csrss\win32csr\win32csr.dll      1
 subsys\ntvdm\ntvdm.exe                  1

reactos/doc
README.WINE 1.20 -> 1.20.2.1
diff -u -r1.20 -r1.20.2.1
--- README.WINE	20 Oct 2004 20:35:58 -0000	1.20
+++ README.WINE	8 Dec 2004 21:56:47 -0000	1.20.2.1
@@ -34,32 +34,38 @@
 
 The following shared libraries are a 100% port from Winehq sources.
 
-reactos/lib/cabinet             # Synced to Wine-20041019
-reactos/lib/comctl32            # Synced to Wine-20041019
-reactos/lib/comdlg32		# Synced to Wine-20041019
+reactos/lib/cabinet             # Synced to Wine-20041201
+reactos/lib/comctl32            # Synced to Wine-20041201
+reactos/lib/comdlg32		# Synced to Wine-20041201
+reactos/lib/dinput		# Synced to Wine-20041201
+reactos/lib/dinput8		# Synced to Wine-20041201
+reactos/lib/icmp		# Synced to Wine-20041201
 reactos/lib/iphlpapi		# Out of sync
 reactos/lib/imagehlp		# Patches for BindImage need review and submission to winehq.
 reactos/lib/msvcrt20		# Out of sync
-reactos/lib/mpr                 # Synced to Wine-20041019
+reactos/lib/mpr                 # Synced to Wine-20041201
 reactos/lib/msacm		# Out of sync
+reactos/lib/msi			# Synced to Wine-20041201
 reactos/lib/msvidoe		# Out of sync
+reactos/lib/netapi32		# Out of sync
 reactos/lib/odbc32		# In sync. Depends on port of Linux ODBC.
-reactos/lib/ole32               # Synced to Wine-20041019
-reactos/lib/oleaut32		# Out of sync
-reactos/lib/oledlg              # Synced to Wine-20041019
+reactos/lib/ole32               # Synced to Wine-20041201
+reactos/lib/oleaut32		# Synced to Wine-20041201
+reactos/lib/oledlg              # Synced to Wine-20041201
 reactos/lib/oldpro32		# Out of sync
-reactos/lib/richedit		# Synced to Wine-20041019
-reactos/lib/rpcrt4		# Synced to Wine-20041019
+reactos/lib/richedit		# Synced to Wine-20041201
+reactos/lib/rpcrt4		# Synced to Wine-20041201
 reactos/lib/setupapi		# Out of sync
-reactos/lib/shell32             # Synced to Wine-20041019
-reactos/lib/shlwapi             # Synced to Wine-20041019
+reactos/lib/shell32             # Synced to Wine-20041201
+reactos/lib/shlwapi             # Synced to Wine-20041201
 reactos/lib/twain		# Out of sync
-reactos/lib/unicode		# Dependancy on this lib needs to be removed. Synced to Wine-20041019
+reactos/lib/unicode		# Dependancy on this lib needs to be removed. Synced to Wine-20041201
+reactos/lib/urlmon		# Out of sync
 reactos/lib/version		# Out of sync
 reactos/lib/wininet		# Out of sync
-reactos/lib/winmm		# Synced to Wine-20041019
-reactos/lib/winmm/midimap       # Synced to Wine-20041019
-reactos/lib/winmm/wavemap       # Synced to Wine-20041019
+reactos/lib/winmm		# Synced to Wine-20041201
+reactos/lib/winmm/midimap       # Synced to Wine-20041201
+reactos/lib/winmm/wavemap       # Synced to Wine-20041201
 
 ReactOS shares the following programs with Winehq.
 reactos/subsys/system/regedit	#Out of sync

reactos/drivers/dd/null
makefile 1.19 -> 1.19.10.1
diff -u -r1.19 -r1.19.10.1
--- makefile	1 Jul 2004 02:40:22 -0000	1.19
+++ makefile	8 Dec 2004 21:56:47 -0000	1.19.10.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.19 2004/07/01 02:40:22 hyperion Exp $
+# $Id: makefile,v 1.19.10.1 2004/12/08 21:56:47 hyperion Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -12,6 +12,6 @@
 
 TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
 
-TARGET_LIBS = $(SDK_PATH_LIB)/pseh.a
+TARGET_LIBS = $(SDK_PATH_LIB)/libpseh.a
 
 include $(TOOLS_PATH)/helper.mk

reactos/drivers/fs/ntfs
notes.txt 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- notes.txt	17 Jul 2003 13:31:39 -0000	1.1
+++ notes.txt	8 Dec 2004 21:56:48 -0000	1.1.34.1
@@ -1,5 +1,5 @@
-
-These are notes about the NT filesystem
-
-More documentation is available at:
-http://linux-ntfs.sourceforge.net/ntfs/index.html
+
+These are notes about the NT filesystem
+
+More documentation is available at:
+http://linux-ntfs.sourceforge.net/ntfs/index.html

reactos/drivers/fs/vfat
cleanup.c 1.15 -> 1.15.6.1
diff -u -r1.15 -r1.15.6.1
--- cleanup.c	28 Aug 2004 22:19:12 -0000	1.15
+++ cleanup.c	8 Dec 2004 21:56:48 -0000	1.15.6.1
@@ -1,4 +1,4 @@
-/* $Id: cleanup.c,v 1.15 2004/08/28 22:19:12 navaraf Exp $
+/* $Id: cleanup.c,v 1.15.6.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -35,7 +35,7 @@
   pFcb = (PVFATFCB) FileObject->FsContext;
   if (pFcb)
     {
-      if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+      if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) &&
           FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
        {
          /* remove all locks this process have on this file */

reactos/drivers/fs/vfat
create.c 1.75 -> 1.75.2.1
diff -u -r1.75 -r1.75.2.1
--- create.c	6 Nov 2004 13:44:56 -0000	1.75
+++ create.c	8 Dec 2004 21:56:48 -0000	1.75.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: create.c,v 1.75 2004/11/06 13:44:56 ekohl Exp $
+/* $Id: create.c,v 1.75.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/fs/vfat/create.c
@@ -36,10 +36,6 @@
 
 #include "vfat.h"
 
-/* GLOBALS *******************************************************************/
-
-#define ENTRIES_PER_PAGE   (PAGE_SIZE / sizeof (FATDirEntry))
-
 /* FUNCTIONS *****************************************************************/
 
 void  vfat8Dot3ToString (PFAT_DIR_ENTRY pEntry, PUNICODE_STRING NameU)
@@ -48,7 +44,7 @@
   ULONG Length;
   CHAR  cString[12];
   
-  memcpy(cString, pEntry->Filename, 11);
+  RtlCopyMemory(cString, pEntry->Filename, 11);
   cString[11] = 0;
   if (cString[0] == 0x05)
     {
@@ -71,7 +67,7 @@
     {
       Length = NameU->Length;
       NameU->Buffer += Length / sizeof(WCHAR);
-      if (!ENTRY_VOLUME(pEntry))
+      if (!FAT_ENTRY_VOLUME(pEntry))
         {
 	  Length += sizeof(WCHAR);
           NameU->Buffer[0] = L'.';
@@ -106,16 +102,30 @@
 {
   PVOID Context = NULL;
   ULONG DirIndex = 0;
-  FATDirEntry* Entry;
+  PDIR_ENTRY Entry;
   PVFATFCB pFcb;
   LARGE_INTEGER FileOffset;
   UNICODE_STRING NameU;
+  ULONG SizeDirEntry;
+  ULONG EntriesPerPage;
+  OEM_STRING StringO;
 
   NameU.Buffer = Vpb->VolumeLabel;
   NameU.Length = 0;
   NameU.MaximumLength = sizeof(Vpb->VolumeLabel);
   *(Vpb->VolumeLabel) = 0;
   Vpb->VolumeLabelLength = 0;
+  
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    SizeDirEntry = sizeof(FATX_DIR_ENTRY);
+    EntriesPerPage = FATX_ENTRIES_PER_PAGE;
+  }
+  else
+  {
+    SizeDirEntry = sizeof(FAT_DIR_ENTRY);
+    EntriesPerPage = FAT_ENTRIES_PER_PAGE;
+  }
 
   ExAcquireResourceExclusiveLite (&DeviceExt->DirResource, TRUE);
   pFcb = vfatOpenRootFCB (DeviceExt);
@@ -126,20 +136,29 @@
   {
      while (TRUE)
      {
-       if (ENTRY_VOLUME(Entry))
+       if (ENTRY_VOLUME(DeviceExt, Entry))
        {
           /* copy volume label */
-          vfat8Dot3ToString (Entry, &NameU);
+          if (DeviceExt->Flags & VCB_IS_FATX)
+          {
+            StringO.Buffer = Entry->FatX.Filename;
+            StringO.MaximumLength = StringO.Length = Entry->FatX.FilenameLength;
+            RtlOemStringToUnicodeString(&NameU, &StringO, FALSE);
+          }
+          else
+          {
+            vfat8Dot3ToString (&Entry->Fat, &NameU);
+          }
           Vpb->VolumeLabelLength = NameU.Length;
           break;
        }
-       if (ENTRY_END(Entry))
+       if (ENTRY_END(DeviceExt, Entry))
        {
           break;
        }
        DirIndex++;       
-       Entry++;
-       if ((DirIndex % ENTRIES_PER_PAGE) == 0)
+       Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry);
+       if ((DirIndex % EntriesPerPage) == 0)
        {
 	  CcUnpinData(Context);
 	  FileOffset.u.LowPart += PAGE_SIZE;
@@ -212,7 +231,7 @@
 	    {
 	      RtlCopyUnicodeString(&DirContext->LongNameU, &rcFcb->LongNameU);
 	      RtlCopyUnicodeString(&DirContext->ShortNameU, &rcFcb->ShortNameU);
-	      memcpy(&DirContext->FatDirEntry, &rcFcb->entry, sizeof(FATDirEntry));
+	      RtlCopyMemory(&DirContext->DirEntry, &rcFcb->entry, sizeof(DIR_ENTRY));
 	      DirContext->StartIndex = rcFcb->startIndex;
 	      DirContext->DirIndex = rcFcb->dirIndex;
               DPRINT("FindFile: new Name %wZ, DirIndex %d (%d)\n",
@@ -231,13 +250,13 @@
 
   while(TRUE)
     {
-      Status = vfatGetNextDirEntry(&Context, &Page, Parent, DirContext, First);
+      Status = DeviceExt->GetNextDirEntry(&Context, &Page, Parent, DirContext, First);
       First = FALSE;
       if (Status == STATUS_NO_MORE_ENTRIES)
         {
 	  break;
         }
-      if (ENTRY_VOLUME(&DirContext->FatDirEntry))
+      if (ENTRY_VOLUME(DeviceExt, &DirContext->DirEntry))
         {
           DirContext->DirIndex++;
           continue;
@@ -269,7 +288,7 @@
               rcFcb = vfatGrabFCBFromTable(DeviceExt, &PathNameU);
 	      if (rcFcb != NULL)
 	        {
-	          memcpy(&DirContext->FatDirEntry, &rcFcb->entry, sizeof(FATDirEntry));
+	          RtlCopyMemory(&DirContext->DirEntry, &rcFcb->entry, sizeof(DIR_ENTRY));
                   vfatReleaseFCB(DeviceExt, rcFcb);
 		}
 	    }
@@ -407,17 +426,26 @@
   ULONG Cluster, NextCluster;
   NTSTATUS Status;
   
-  Fcb->entry.FileSize = 0;
-  if (DeviceExt->FatInfo.FatType == FAT32)
-    {
-      Cluster = Fcb->entry.FirstCluster + Fcb->entry.FirstClusterHigh * 65536;
-    }
+  if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+  {
+    Fcb->entry.FatX.FileSize = 0;
+    Cluster = Fcb->entry.FatX.FirstCluster;
+    Fcb->entry.FatX.FirstCluster = 0;
+  }
   else
-    {
-      Cluster = Fcb->entry.FirstCluster;
-    }
-  Fcb->entry.FirstCluster = 0;
-  Fcb->entry.FirstClusterHigh = 0;
+  {
+    Fcb->entry.Fat.FileSize = 0;
+    if (DeviceExt->FatInfo.FatType == FAT32)
+      {
+        Cluster = Fcb->entry.Fat.FirstCluster + Fcb->entry.Fat.FirstClusterHigh * 65536;
+      }
+    else
+      {
+        Cluster = Fcb->entry.Fat.FirstCluster;
+      }
+    Fcb->entry.Fat.FirstCluster = 0;
+    Fcb->entry.Fat.FirstClusterHigh = 0;
+  }
   Fcb->LastOffset = Fcb->LastCluster = 0;
   VfatUpdateEntry (Fcb);
   if (Fcb->RFCB.FileSize.QuadPart > 0)
@@ -496,7 +524,7 @@
 	{
 	  return (STATUS_INSUFFICIENT_RESOURCES);
 	}
-      memset(pCcb, 0, sizeof(VFATCCB));
+      RtlZeroMemory(pCcb, sizeof(VFATCCB));
       FileObject->Flags |= FO_FCB_IS_VALID;
       FileObject->SectionObjectPointer = &pFcb->SectionObjectPointers;
       FileObject->FsContext = pFcb;
@@ -626,13 +654,13 @@
        * Check the file has the requested attributes
        */
       if (RequestedOptions & FILE_NON_DIRECTORY_FILE && 
-	  pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+	  *pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)
 	{
 	  VfatCloseFile (DeviceExt, FileObject);
 	  return(STATUS_FILE_IS_A_DIRECTORY);
 	}
       if (RequestedOptions & FILE_DIRECTORY_FILE && 
-	  !(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
+	  !(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
 	{
 	  VfatCloseFile (DeviceExt, FileObject);
 	  return(STATUS_NOT_A_DIRECTORY);
@@ -703,12 +731,24 @@
 	}
     }
 
-  pFcb->OpenHandleCount++;
-  IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
+  if (pFcb->OpenHandleCount == 0)
+  {
+      IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
                    Stack->Parameters.Create.ShareAccess,
                    FileObject,
                    &pFcb->FCBShareAccess);
+   }
+   else
+   {
+      IoUpdateShareAccess(
+          FileObject,
+          &pFcb->FCBShareAccess
+         );
+      
+   }
 
+  pFcb->OpenHandleCount++;
+  
   /* FIXME : test write access if requested */
 
   return(Status);

reactos/drivers/fs/vfat
dir.c 1.35 -> 1.35.2.1
diff -u -r1.35 -r1.35.2.1
--- dir.c	6 Nov 2004 13:44:57 -0000	1.35
+++ dir.c	8 Dec 2004 21:56:48 -0000	1.35.2.1
@@ -1,5 +1,5 @@
 /*
- * $Id: dir.c,v 1.35 2004/11/06 13:44:57 ekohl Exp $
+ * $Id: dir.c,v 1.35.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -21,7 +21,7 @@
 
 // function like DosDateTimeToFileTime
 BOOL
-FsdDosDateTimeToSystemTime (WORD wDosDate, WORD wDosTime, PLARGE_INTEGER SystemTime)
+FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, WORD wDosDate, WORD wDosTime, PLARGE_INTEGER SystemTime)
 {
   PDOSTIME pdtime = (PDOSTIME) & wDosTime;
   PDOSDATE pddate = (PDOSDATE) & wDosDate;
@@ -38,7 +38,7 @@
 
   TimeFields.Day = pddate->Day;
   TimeFields.Month = pddate->Month;
-  TimeFields.Year = 1980 + pddate->Year;
+  TimeFields.Year = DeviceExt->BaseDateYear + pddate->Year;
 
   RtlTimeFieldsToTime (&TimeFields, &LocalTime);
   ExLocalTimeToSystemTime(&LocalTime, SystemTime);
@@ -46,10 +46,9 @@
   return TRUE;
 }
 
-
 // function like FileTimeToDosDateTime
 BOOL
-FsdSystemTimeToDosDateTime (PLARGE_INTEGER SystemTime, WORD * pwDosDate, WORD * pwDosTime)
+FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, WORD * pwDosDate, WORD * pwDosTime)
 {
   PDOSTIME pdtime = (PDOSTIME) pwDosTime;
   PDOSDATE pddate = (PDOSDATE) pwDosDate;
@@ -73,13 +72,12 @@
     {
       pddate->Day = TimeFields.Day;
       pddate->Month = TimeFields.Month;
-      pddate->Year = TimeFields.Year - 1980;
+      pddate->Year = TimeFields.Year - DeviceExt->BaseDateYear;
     }
 
   return TRUE;
 }
 
-
 #define DWORD_ROUND_UP(x)   ROUND_UP((x), (sizeof(DWORD)))
 
 NTSTATUS
@@ -91,7 +89,7 @@
   pInfo->FileNameLength = DirContext->LongNameU.Length;
   pInfo->NextEntryOffset =
     DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
-  memcpy (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
+  RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
   return STATUS_SUCCESS;
 }
 
@@ -106,31 +104,61 @@
   pInfo->FileNameLength = DirContext->LongNameU.Length;
   pInfo->NextEntryOffset =
     DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
-  memcpy (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
+  RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
 //      pInfo->FileIndex=;
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.CreationDate,
-			      DirContext->FatDirEntry.CreationTime,
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
+			      DirContext->DirEntry.FatX.CreationTime,
 			      &pInfo->CreationTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.AccessDate, 0,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
+               DirContext->DirEntry.FatX.AccessTime,
 			      &pInfo->LastAccessTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.UpdateDate,
-			      DirContext->FatDirEntry.UpdateTime,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
+			      DirContext->DirEntry.FatX.UpdateTime,
 			      &pInfo->LastWriteTime);
-  pInfo->ChangeTime = pInfo->LastWriteTime;
-  if (DirContext->FatDirEntry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
-    {
-      pInfo->EndOfFile.QuadPart = 0LL;
-      pInfo->AllocationSize.QuadPart = 0LL;
-    }
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+      {
+        pInfo->EndOfFile.QuadPart = 0LL;
+        pInfo->AllocationSize.QuadPart = 0LL;
+      }
+    else
+      {
+        pInfo->EndOfFile.u.HighPart = 0;
+        pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
+        /* Make allocsize a rounded up multiple of BytesPerCluster */
+        pInfo->AllocationSize.u.HighPart = 0;
+        pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+      }
+    pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
+  }
   else
-    {
-      pInfo->EndOfFile.u.HighPart = 0;
-      pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize;
-      /* Make allocsize a rounded up multiple of BytesPerCluster */
-      pInfo->AllocationSize.u.HighPart = 0;
-      pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster);
-    }
-  pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f;
+  {
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
+			      DirContext->DirEntry.Fat.CreationTime,
+			      &pInfo->CreationTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate, 0,
+			      &pInfo->LastAccessTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
+			      DirContext->DirEntry.Fat.UpdateTime,
+			      &pInfo->LastWriteTime);
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+      {
+        pInfo->EndOfFile.QuadPart = 0LL;
+        pInfo->AllocationSize.QuadPart = 0LL;
+      }
+    else
+      {
+        pInfo->EndOfFile.u.HighPart = 0;
+        pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
+        /* Make allocsize a rounded up multiple of BytesPerCluster */
+        pInfo->AllocationSize.u.HighPart = 0;
+        pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+      }
+    pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
+  }
 
   return STATUS_SUCCESS;
 }
@@ -146,23 +174,45 @@
   pInfo->FileNameLength = DirContext->LongNameU.Length;
   pInfo->NextEntryOffset =
     DWORD_ROUND_UP (sizeof (FILE_FULL_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
-  memcpy (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
+  RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
 //      pInfo->FileIndex=;
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.CreationDate,
-			      DirContext->FatDirEntry.CreationTime,
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
+			      DirContext->DirEntry.FatX.CreationTime,
 			      &pInfo->CreationTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.AccessDate,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
+                              DirContext->DirEntry.FatX.AccessTime,
+                              &pInfo->LastAccessTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
+                              DirContext->DirEntry.FatX.UpdateTime,
+                              &pInfo->LastWriteTime);
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    pInfo->EndOfFile.u.HighPart = 0;
+    pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
+    /* Make allocsize a rounded up multiple of BytesPerCluster */
+    pInfo->AllocationSize.u.HighPart = 0;
+    pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+    pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
+  }
+  else
+  {
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
+			      DirContext->DirEntry.Fat.CreationTime,
+			      &pInfo->CreationTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate,
                               0, &pInfo->LastAccessTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.UpdateDate,
-                              DirContext->FatDirEntry.UpdateTime,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
+                              DirContext->DirEntry.Fat.UpdateTime,
                               &pInfo->LastWriteTime);
-  pInfo->ChangeTime = pInfo->LastWriteTime;
-  pInfo->EndOfFile.u.HighPart = 0;
-  pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize;
-  /* Make allocsize a rounded up multiple of BytesPerCluster */
-  pInfo->AllocationSize.u.HighPart = 0;
-  pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster);
-  pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f;
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    pInfo->EndOfFile.u.HighPart = 0;
+    pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
+    /* Make allocsize a rounded up multiple of BytesPerCluster */
+    pInfo->AllocationSize.u.HighPart = 0;
+    pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+    pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
+  }
 //      pInfo->EaSize=;
   return STATUS_SUCCESS;
 }
@@ -175,36 +225,74 @@
 {
   if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
     return STATUS_BUFFER_OVERFLOW;
-  pInfo->FileNameLength = DirContext->LongNameU.Length;
-  pInfo->NextEntryOffset = 
-    DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
-  memcpy(pInfo->ShortName, DirContext->ShortNameU.Buffer, DirContext->ShortNameU.Length);
-  pInfo->ShortNameLength = DirContext->ShortNameU.Length;
-  memcpy (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
-//      pInfo->FileIndex=;
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.CreationDate,
-                              DirContext->FatDirEntry.CreationDate,
+  
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    pInfo->FileNameLength = DirContext->LongNameU.Length;
+    RtlCopyMemory(pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
+    pInfo->NextEntryOffset = 
+      DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+    pInfo->ShortName[0] = 0;
+    pInfo->ShortNameLength = 0;
+    //      pInfo->FileIndex=;
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
+                              DirContext->DirEntry.FatX.CreationTime,
                               &pInfo->CreationTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.AccessDate, 0,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
+                              DirContext->DirEntry.FatX.AccessTime,
                               &pInfo->LastAccessTime);
-  FsdDosDateTimeToSystemTime (DirContext->FatDirEntry.UpdateDate,
-                              DirContext->FatDirEntry.UpdateTime,
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
+                              DirContext->DirEntry.FatX.UpdateTime,
                               &pInfo->LastWriteTime);
-  pInfo->ChangeTime = pInfo->LastWriteTime;
-  if (DirContext->FatDirEntry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
-    {
-      pInfo->EndOfFile.QuadPart = 0LL;
-      pInfo->AllocationSize.QuadPart = 0LL;
-    }
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+      {
+        pInfo->EndOfFile.QuadPart = 0LL;
+        pInfo->AllocationSize.QuadPart = 0LL;
+      }
+    else
+      {
+        pInfo->EndOfFile.u.HighPart = 0;
+        pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
+        /* Make allocsize a rounded up multiple of BytesPerCluster */
+        pInfo->AllocationSize.u.HighPart = 0;
+        pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+      }
+    pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
+  }
   else
-    {
-      pInfo->EndOfFile.u.HighPart = 0;
-      pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize;
-      /* Make allocsize a rounded up multiple of BytesPerCluster */
-      pInfo->AllocationSize.u.HighPart = 0;
-      pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster);
-    }
-  pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f;
+  {
+    pInfo->FileNameLength = DirContext->LongNameU.Length;
+    pInfo->NextEntryOffset = 
+      DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+    RtlCopyMemory(pInfo->ShortName, DirContext->ShortNameU.Buffer, DirContext->ShortNameU.Length);
+    pInfo->ShortNameLength = DirContext->ShortNameU.Length;
+    RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
+  //      pInfo->FileIndex=;
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
+                              DirContext->DirEntry.Fat.CreationTime,
+                              &pInfo->CreationTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate, 0,
+                              &pInfo->LastAccessTime);
+    FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
+                              DirContext->DirEntry.Fat.UpdateTime,
+                              &pInfo->LastWriteTime);
+    pInfo->ChangeTime = pInfo->LastWriteTime;
+    if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+      {
+        pInfo->EndOfFile.QuadPart = 0LL;
+        pInfo->AllocationSize.QuadPart = 0LL;
+      }
+    else
+      {
+        pInfo->EndOfFile.u.HighPart = 0;
+        pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
+        /* Make allocsize a rounded up multiple of BytesPerCluster */
+        pInfo->AllocationSize.u.HighPart = 0;
+        pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
+      }
+    pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
+  }
   pInfo->EaSize=0;
   return STATUS_SUCCESS;
 }

reactos/drivers/fs/vfat
direntry.c 1.17 -> 1.17.8.1
diff -u -r1.17 -r1.17.8.1
--- direntry.c	1 Aug 2004 21:57:17 -0000	1.17
+++ direntry.c	8 Dec 2004 21:56:48 -0000	1.17.8.1
@@ -1,4 +1,4 @@
-/* $Id: direntry.c,v 1.17 2004/08/01 21:57:17 navaraf Exp $
+/* $Id: direntry.c,v 1.17.8.1 2004/12/08 21:56:48 hyperion Exp $
  *
  *
  * FILE:             DirEntry.c
@@ -8,6 +8,7 @@
  * PROGRAMMER:       Jason Filby (jasonfilby@yahoo.com)
  *                   Rex Jolliff (rex@lvcablemodem.com)
  *                   Hartmut Birr
+ *                   Herve Poussineau (reactos@poussine.freesurf.fr)
  */
 
 /*  -------------------------------------------------------  INCLUDES  */
@@ -21,28 +22,30 @@
 
 #include "vfat.h"
 
-#define ENTRIES_PER_PAGE   (PAGE_SIZE / sizeof (FATDirEntry))
-
 ULONG 
 vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION  pDeviceExt,
-                             PFAT_DIR_ENTRY  pFatDirEntry)
+                             PDIR_ENTRY  pFatDirEntry)
 {
   ULONG  cluster;
 
   if (pDeviceExt->FatInfo.FatType == FAT32)
   {
-    cluster = pFatDirEntry->FirstCluster + 
-      pFatDirEntry->FirstClusterHigh * 65536;
+    cluster = pFatDirEntry->Fat.FirstCluster + 
+      pFatDirEntry->Fat.FirstClusterHigh * 65536;
+  }
+  else if (pDeviceExt->Flags & VCB_IS_FATX)
+  {
+    cluster = pFatDirEntry->FatX.FirstCluster;
   }
   else
   {
-    cluster = pFatDirEntry->FirstCluster;
+    cluster = pFatDirEntry->Fat.FirstCluster;
   }
 
   return  cluster;
 }
 
-BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb)
+BOOL FATIsDirectoryEmpty(PVFATFCB Fcb)
 {
    LARGE_INTEGER FileOffset;
    PVOID Context = NULL;
@@ -63,7 +66,7 @@
 
    while (Index < MaxIndex)
      {
-       if (Context == NULL || (Index % ENTRIES_PER_PAGE) == 0)
+       if (Context == NULL || (Index % FAT_ENTRIES_PER_PAGE) == 0)
          {
 	   if (Context != NULL)
 	     {
@@ -73,14 +76,14 @@
 	      {
 		return TRUE;
 	      }
-	    FatDirEntry += Index % ENTRIES_PER_PAGE;
+	    FatDirEntry += Index % FAT_ENTRIES_PER_PAGE;
 	 }
-       if (ENTRY_END(FatDirEntry))
+       if (FAT_ENTRY_END(FatDirEntry))
 	  {
 	    CcUnpinData(Context);
 	    return TRUE;
 	  }
-       if (!ENTRY_DELETED(FatDirEntry))
+       if (!FAT_ENTRY_DELETED(FatDirEntry))
          {
 	   CcUnpinData(Context);
 	   return FALSE;
@@ -95,7 +98,61 @@
    return TRUE;
 }
 
-NTSTATUS vfatGetNextDirEntry(PVOID * pContext,
+BOOL FATXIsDirectoryEmpty(PVFATFCB Fcb)
+{
+   LARGE_INTEGER FileOffset;
+   PVOID Context = NULL;
+   PFATX_DIR_ENTRY FatXDirEntry;
+   ULONG Index, MaxIndex;
+
+   Index = 0;
+
+   FileOffset.QuadPart = 0LL;
+   MaxIndex = Fcb->RFCB.FileSize.u.LowPart / sizeof(FATX_DIR_ENTRY);
+
+   while (Index < MaxIndex)
+   {
+      if (Context == NULL || (Index % FATX_ENTRIES_PER_PAGE) == 0)
+      {
+         if (Context != NULL)
+         {
+            CcUnpinData(Context);
+         }
+         if (!CcMapData(Fcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&FatXDirEntry))
+         {
+            return TRUE;
+         }
+         FatXDirEntry += Index % FATX_ENTRIES_PER_PAGE;
+      }
+      if (FATX_ENTRY_END(FatXDirEntry))
+      {
+         CcUnpinData(Context);
+         return TRUE;
+      }
+      if (!FATX_ENTRY_DELETED(FatXDirEntry))
+      {
+         CcUnpinData(Context);
+         return FALSE;
+      }
+      Index++;
+      FatXDirEntry++;
+   }
+   if (Context)
+   {
+      CcUnpinData(Context);
+   }
+   return TRUE;
+}
+
+BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb)
+{
+   if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+      return FATXIsDirectoryEmpty(Fcb);
+   else
+      return FATIsDirectoryEmpty(Fcb);
+}
+
+NTSTATUS FATGetNextDirEntry(PVOID * pContext,
 			     PVOID * pPage,
                              IN PVFATFCB pDirFcb,
 			     PVFAT_DIRENTRY_CONTEXT DirContext,
@@ -104,7 +161,7 @@
     ULONG dirMap;
     PWCHAR pName;
     LARGE_INTEGER FileOffset;
-    FATDirEntry * fatDirEntry;
+    PFAT_DIR_ENTRY fatDirEntry;
     slot * longNameEntry;
     ULONG index;
     
@@ -116,9 +173,9 @@
     DirContext->LongNameU.Buffer[0] = 0;
 
     FileOffset.u.HighPart = 0;
-    FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FATDirEntry), PAGE_SIZE);
+    FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FAT_DIR_ENTRY), PAGE_SIZE);
 
-    if (*pContext == NULL || (DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
+    if (*pContext == NULL || (DirContext->DirIndex % FAT_ENTRIES_PER_PAGE) == 0)
     {
        if (*pContext != NULL)
        {
@@ -132,7 +189,7 @@
     }
 
 
-    fatDirEntry = (FATDirEntry*)(*pPage) + DirContext->DirIndex % ENTRIES_PER_PAGE;
+    fatDirEntry = (PFAT_DIR_ENTRY)(*pPage) + DirContext->DirIndex % FAT_ENTRIES_PER_PAGE;
     longNameEntry = (slot*) fatDirEntry;
     dirMap = 0;
 
@@ -142,14 +199,14 @@
 	 * into a long name or points to a short name with an assigned long name. 
 	 * We must go back to the real start of the entry */
         while (DirContext->DirIndex > 0 && 
-	       !ENTRY_END(fatDirEntry) && 
-	       !ENTRY_DELETED(fatDirEntry) && 
-	       ((!ENTRY_LONG(fatDirEntry) && !Back) || 
-	        (ENTRY_LONG(fatDirEntry) && !(longNameEntry->id & 0x40))))
+	       !FAT_ENTRY_END(fatDirEntry) && 
+	       !FAT_ENTRY_DELETED(fatDirEntry) && 
+	       ((!FAT_ENTRY_LONG(fatDirEntry) && !Back) || 
+	        (FAT_ENTRY_LONG(fatDirEntry) && !(longNameEntry->id & 0x40))))
           {
             DirContext->DirIndex--;
 	    Back = TRUE;
-            if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == ENTRIES_PER_PAGE - 1)
+            if ((DirContext->DirIndex % FAT_ENTRIES_PER_PAGE) == FAT_ENTRIES_PER_PAGE - 1)
               {
                 CcUnpinData(*pContext);
                 FileOffset.u.LowPart -= PAGE_SIZE;
@@ -159,7 +216,7 @@
 	            *pContext = NULL;
 	            return STATUS_NO_MORE_ENTRIES;
 		  }
-                fatDirEntry = (FATDirEntry*)(*pPage) + DirContext->DirIndex % ENTRIES_PER_PAGE;
+                fatDirEntry = (PFAT_DIR_ENTRY)(*pPage) + DirContext->DirIndex % FAT_ENTRIES_PER_PAGE;
                 longNameEntry = (slot*) fatDirEntry;
               }
 	    else
@@ -169,11 +226,11 @@
 	      }
           }
 
-        if (Back && !ENTRY_END(fatDirEntry) && 
-	    (ENTRY_DELETED(fatDirEntry) || !ENTRY_LONG(fatDirEntry)))
+        if (Back && !FAT_ENTRY_END(fatDirEntry) && 
+	    (FAT_ENTRY_DELETED(fatDirEntry) || !FAT_ENTRY_LONG(fatDirEntry)))
           {
             DirContext->DirIndex++;
-	    if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
+	    if ((DirContext->DirIndex % FAT_ENTRIES_PER_PAGE) == 0)
 	      {
 	        CcUnpinData(*pContext);
 	        FileOffset.u.LowPart += PAGE_SIZE;
@@ -183,7 +240,7 @@
 		    *pContext = NULL;
 		    return STATUS_NO_MORE_ENTRIES;
 	          }
-	        fatDirEntry = (FATDirEntry*)*pPage;
+	        fatDirEntry = (PFAT_DIR_ENTRY)*pPage;
 	        longNameEntry = (slot*) *pPage;
 	      }
 	    else
@@ -199,14 +256,14 @@
 
     while (TRUE)
       {
-	if (ENTRY_END(fatDirEntry))
+	if (FAT_ENTRY_END(fatDirEntry))
 	  {
 	    CcUnpinData(*pContext);
 	    *pContext = NULL;
 	    return STATUS_NO_MORE_ENTRIES;
 	  }
 
-	if (ENTRY_DELETED(fatDirEntry))
+	if (FAT_ENTRY_DELETED(fatDirEntry))
 	  {
 	    dirMap = 0;
 	    DirContext->LongNameU.Buffer[0] = 0;
@@ -214,12 +271,12 @@
 	  }
 	else
 	  {
-	    if (ENTRY_LONG(fatDirEntry))
+	    if (FAT_ENTRY_LONG(fatDirEntry))
 	      {
 		if (dirMap == 0)
 		  {
 		    DPRINT ("  long name entry found at %d\n", DirContext->DirIndex);
-                    memset(DirContext->LongNameU.Buffer, 0, DirContext->LongNameU.MaximumLength);
+		    RtlZeroMemory(DirContext->LongNameU.Buffer, DirContext->LongNameU.MaximumLength);
 		    CheckSum = longNameEntry->alias_checksum;
 		    Valid = TRUE;
 		  }
@@ -233,9 +290,9 @@
 		dirMap |= 1 << index;
 		pName = DirContext->LongNameU.Buffer + 13 * index;
 
-		memcpy(pName, longNameEntry->name0_4, 5 * sizeof(WCHAR));
-		memcpy(pName + 5, longNameEntry->name5_10, 6 * sizeof(WCHAR));
-		memcpy(pName + 11, longNameEntry->name11_12, 2 * sizeof(WCHAR));
+		RtlCopyMemory(pName, longNameEntry->name0_4, 5 * sizeof(WCHAR));
+		RtlCopyMemory(pName + 5, longNameEntry->name5_10, 6 * sizeof(WCHAR));
+		RtlCopyMemory(pName + 11, longNameEntry->name11_12, 2 * sizeof(WCHAR));
       
 		DPRINT ("  longName: [%S]\n", DirContext->LongNameU.Buffer);
 		if (CheckSum != longNameEntry->alias_checksum)
@@ -265,12 +322,12 @@
 		    DirContext->LongNameU.Buffer[0] = 0;
 		  }
     
-	        memcpy (&DirContext->FatDirEntry, fatDirEntry, sizeof (FAT_DIR_ENTRY));
+	        RtlCopyMemory (&DirContext->DirEntry.Fat, fatDirEntry, sizeof (FAT_DIR_ENTRY));
 		break;
 	      }
 	   }
 	DirContext->DirIndex++;
-	if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
+	if ((DirContext->DirIndex % FAT_ENTRIES_PER_PAGE) == 0)
 	  {
 	    CcUnpinData(*pContext);
 	    FileOffset.u.LowPart += PAGE_SIZE;
@@ -280,7 +337,7 @@
 		*pContext = NULL;
 		return STATUS_NO_MORE_ENTRIES;
 	      }
-	    fatDirEntry = (FATDirEntry*)*pPage;
+	    fatDirEntry = (PFAT_DIR_ENTRY)*pPage;
 	    longNameEntry = (slot*) *pPage;
 	  }
 	else
@@ -290,10 +347,116 @@
 	  }
       }
     DirContext->LongNameU.Length = wcslen(DirContext->LongNameU.Buffer) * sizeof(WCHAR);
-    vfat8Dot3ToString(&DirContext->FatDirEntry, &DirContext->ShortNameU);
+    vfat8Dot3ToString(&DirContext->DirEntry.Fat, &DirContext->ShortNameU);
     if (DirContext->LongNameU.Length == 0)
       {
         RtlCopyUnicodeString(&DirContext->LongNameU, &DirContext->ShortNameU);
       }
     return STATUS_SUCCESS;
 }
+
+NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
+			     PVOID * pPage,
+                             IN PVFATFCB pDirFcb,
+			     PVFAT_DIRENTRY_CONTEXT DirContext,
+			     BOOLEAN First)
+{
+   LARGE_INTEGER FileOffset;
+   PFATX_DIR_ENTRY fatxDirEntry;
+   OEM_STRING StringO;
+   ULONG DirIndex = DirContext->DirIndex;
+
+   FileOffset.u.HighPart = 0;
+   FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
+   
+   if (!vfatFCBIsRoot(pDirFcb))
+   {
+      /* need to add . and .. entries */
+      switch (DirContext->DirIndex)
+      {
+         case 0: /* entry . */
+         {
+            DirContext->ShortNameU.Buffer[0] = 0;
+            DirContext->ShortNameU.Length = 0;
+            DirContext->LongNameU.Buffer[0] = L'.';
+            DirContext->LongNameU.Length = sizeof(WCHAR);
+            RtlCopyMemory(&DirContext->DirEntry.FatX, &pDirFcb->entry.FatX, sizeof(FATX_DIR_ENTRY));
+            DirContext->DirEntry.FatX.Filename[0] = '.';
+            DirContext->DirEntry.FatX.FilenameLength = 1;
+            DirContext->StartIndex = 0;
+            return STATUS_SUCCESS;
+         }
+         case 1: /* entry .. */
+         {
+            DirContext->ShortNameU.Buffer[0] = 0;
+            DirContext->ShortNameU.Length = 0;
+            DirContext->LongNameU.Buffer[0] = DirContext->LongNameU.Buffer[1] = L'.';
+            DirContext->LongNameU.Length = 2 * sizeof(WCHAR);
+            RtlCopyMemory(&DirContext->DirEntry.FatX, &pDirFcb->entry.FatX, sizeof(FATX_DIR_ENTRY));
+            DirContext->DirEntry.FatX.Filename[0] = DirContext->DirEntry.FatX.Filename[1] = '.';
+            DirContext->DirEntry.FatX.FilenameLength = 2;
+            DirContext->StartIndex = 1;
+            return STATUS_SUCCESS;
+         }
+         default:
+            DirIndex -= 2;
+      }
+   }
+
+   if (*pContext == NULL || (DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
+   {
+      if (*pContext != NULL)
+      {
+         CcUnpinData(*pContext);
+      }
+      if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+      {
+         *pContext = NULL;
+         return STATUS_NO_MORE_ENTRIES;
+      }
+   }
+
+   fatxDirEntry = (PFATX_DIR_ENTRY)(*pPage) + DirIndex % FATX_ENTRIES_PER_PAGE;
+
+   DirContext->StartIndex = DirIndex;
+
+   while (TRUE)
+   {
+	   if (FATX_ENTRY_END(fatxDirEntry))
+	   {
+	      CcUnpinData(*pContext);
+	      *pContext = NULL;
+	      return STATUS_NO_MORE_ENTRIES;
+	   }
+
+	   if (!FATX_ENTRY_DELETED(fatxDirEntry))
+	   {
+         RtlCopyMemory(&DirContext->DirEntry.FatX, fatxDirEntry, sizeof(FATX_DIR_ENTRY));
+		   break;
+      }
+   	DirContext->DirIndex++;
+   	DirContext->StartIndex++;
+   	if ((DirContext->DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
+      {
+         CcUnpinData(*pContext);
+         FileOffset.u.LowPart += PAGE_SIZE;
+         if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+         {
+            CHECKPOINT;
+   		   *pContext = NULL;
+   		   return STATUS_NO_MORE_ENTRIES;
+         }
+         fatxDirEntry = (PFATX_DIR_ENTRY)*pPage;
+      }
+      else
+      {
+         fatxDirEntry++;
+      }
+   }
+   DirContext->ShortNameU.Buffer[0] = 0;
+   DirContext->ShortNameU.Length = 0;
+   StringO.Buffer = fatxDirEntry->Filename;
+   StringO.Length = StringO.MaximumLength = fatxDirEntry->FilenameLength;
+   RtlOemStringToUnicodeString(&DirContext->LongNameU, &StringO, FALSE);
+   return STATUS_SUCCESS;
+}

reactos/drivers/fs/vfat
dirwr.c 1.42 -> 1.42.2.1
diff -u -r1.42 -r1.42.2.1
--- dirwr.c	6 Nov 2004 13:44:57 -0000	1.42
+++ dirwr.c	8 Dec 2004 21:56:48 -0000	1.42.2.1
@@ -1,4 +1,4 @@
-/* $Id: dirwr.c,v 1.42 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: dirwr.c,v 1.42.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -26,21 +26,34 @@
  */
 {
   PVOID Context;
-  PFAT_DIR_ENTRY PinEntry;
+  PDIR_ENTRY PinEntry;
   LARGE_INTEGER Offset;
+  ULONG SizeDirEntry;
+  ULONG dirIndex;
 
   ASSERT(pFcb);
   ASSERT(pFcb->parentFcb);
+  
+  if (pFcb->Flags & FCB_IS_FATX_ENTRY)
+  {
+    SizeDirEntry = sizeof(FATX_DIR_ENTRY);
+    dirIndex = pFcb->startIndex;
+  }
+  else
+  {
+    SizeDirEntry = sizeof(FAT_DIR_ENTRY);
+    dirIndex = pFcb->dirIndex;
+  }
 
-  DPRINT ("updEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
+  DPRINT ("updEntry dirIndex %d, PathName \'%wZ\'\n", dirIndex, &pFcb->PathNameU);
 
   Offset.u.HighPart = 0;
-  Offset.u.LowPart = pFcb->dirIndex * sizeof(FATDirEntry);
-  if (CcMapData (pFcb->parentFcb->FileObject, &Offset, sizeof(FATDirEntry),
+  Offset.u.LowPart = dirIndex * SizeDirEntry;
+  if (CcMapData (pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
       TRUE, &Context, (PVOID*)&PinEntry))
     {
       pFcb->Flags &= ~FCB_IS_DIRTY;
-      *PinEntry = pFcb->entry;
+      RtlCopyMemory(PinEntry, &pFcb->entry, SizeDirEntry);
       CcSetDirtyPinnedData(Context, NULL);
       CcUnpinData(Context);
       return STATUS_SUCCESS;
@@ -64,13 +77,20 @@
  */
   LARGE_INTEGER FileOffset;
   ULONG i, count, size, nbFree = 0;
-  FATDirEntry* pFatEntry;
+  PDIR_ENTRY pFatEntry;
   PVOID Context = NULL;
   NTSTATUS Status;
+  ULONG SizeDirEntry;
   FileOffset.QuadPart = 0;
-  count = pDirFcb->RFCB.FileSize.u.LowPart / sizeof(FATDirEntry);
-  size = DeviceExt->FatInfo.BytesPerCluster / sizeof(FATDirEntry);
-  for (i = 0; i < count; i++, pFatEntry++)
+  
+  if (DeviceExt->Flags & VCB_IS_FATX)
+    SizeDirEntry = sizeof(FATX_DIR_ENTRY);
+  else
+    SizeDirEntry = sizeof(FAT_DIR_ENTRY);
+  
+  count = pDirFcb->RFCB.FileSize.u.LowPart / SizeDirEntry;
+  size = DeviceExt->FatInfo.BytesPerCluster / SizeDirEntry;
+  for (i = 0; i < count; i++, pFatEntry = (PDIR_ENTRY)((ULONG_PTR)pFatEntry + SizeDirEntry))
   {
     if (Context == NULL || (i % size) == 0)
     {
@@ -83,11 +103,11 @@
                  TRUE, &Context, (PVOID*)&pFatEntry);
       FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
     }
-    if (ENTRY_END(pFatEntry))
+    if (ENTRY_END(DeviceExt, pFatEntry))
     {
       break;
     }
-    if (ENTRY_DELETED(pFatEntry))
+    if (ENTRY_DELETED(DeviceExt, pFatEntry))
     {
       nbFree++;
     }
@@ -120,7 +140,7 @@
       // extend the directory
       if (vfatFCBIsRoot(pDirFcb) && DeviceExt->FatInfo.FatType != FAT32)
       {
-        // We can't extend a root directory on a FAT12/FAT16 partition
+        // We can't extend a root directory on a FAT12/FAT16/FATX partition
         return FALSE;
       }
       AllocationSize.QuadPart = pDirFcb->RFCB.FileSize.u.LowPart + DeviceExt->FatInfo.BytesPerCluster;
@@ -135,15 +155,21 @@
                                      DeviceExt->FatInfo.BytesPerCluster);
       CcMapData (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
                  TRUE, &Context, (PVOID*)&pFatEntry);
-      RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
+      if (DeviceExt->Flags & VCB_IS_FATX)
+        memset(pFatEntry, 0xff, DeviceExt->FatInfo.BytesPerCluster);
+      else
+        RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
     }
     else if (*start + nbSlots < count)
     {
       // clear the entry after the last new entry
-      FileOffset.u.LowPart = (*start + nbSlots) * sizeof(FATDirEntry);
-      CcMapData (pDirFcb->FileObject, &FileOffset, sizeof(FATDirEntry),
+      FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry;
+      CcMapData (pDirFcb->FileObject, &FileOffset, SizeDirEntry,
                  TRUE, &Context, (PVOID*)&pFatEntry);
-      RtlZeroMemory(pFatEntry, sizeof(FATDirEntry));
+      if (DeviceExt->Flags & VCB_IS_FATX)
+        memset(pFatEntry, 0xff, SizeDirEntry);
+      else
+        RtlZeroMemory(pFatEntry, SizeDirEntry);
     }
     if (Context)
     {
@@ -156,7 +182,7 @@
 }
 
 NTSTATUS
-VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
+FATAddEntry (PDEVICE_EXTENSION DeviceExt,
 	      PUNICODE_STRING PathNameU,
 	      PFILE_OBJECT pFileObject,
 	      ULONG RequestedOptions,
@@ -166,7 +192,7 @@
 */
 {
   PVOID Context = NULL;
-  FATDirEntry *pFatEntry;
+  PFAT_DIR_ENTRY pFatEntry;
   slot *pSlots;
   short nbSlots = 0, j, posCar;
   PUCHAR Buffer;
@@ -180,7 +206,7 @@
   ULONG size;
   long i;
   
-  ANSI_STRING NameA;
+  OEM_STRING NameA;
   CHAR aName[13];
   BOOLEAN IsNameLegal;
   BOOLEAN SpacesFound;
@@ -212,8 +238,8 @@
   
   nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1;	//nb of entry needed for long name+normal entry
   DPRINT ("NameLen= %d, nbSlots =%d\n", DirContext.LongNameU.Length / sizeof(WCHAR), nbSlots);
-  Buffer = ExAllocatePool (NonPagedPool, (nbSlots - 1) * sizeof (FATDirEntry));
-  RtlZeroMemory (Buffer, (nbSlots - 1) * sizeof (FATDirEntry));
+  Buffer = ExAllocatePool (NonPagedPool, (nbSlots - 1) * sizeof (FAT_DIR_ENTRY));
+  RtlZeroMemory (Buffer, (nbSlots - 1) * sizeof (FAT_DIR_ENTRY));
   pSlots = (slot *) Buffer;
 
   NameA.Buffer = aName;
@@ -224,7 +250,7 @@
   DirContext.ShortNameU.Length = 0;
   DirContext.ShortNameU.MaximumLength = sizeof(ShortNameBuffer);
 
-  memset(&DirContext.FatDirEntry, 0, sizeof(FATDirEntry));
+  RtlZeroMemory(&DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
 
   IsNameLegal = RtlIsNameLegalDOS8Dot3(&DirContext.LongNameU, &NameA, &SpacesFound);
 
@@ -235,7 +261,7 @@
       WCHAR ShortSearchName[13];
       needTilde = TRUE;
       needLong = TRUE;
-      memset(&NameContext, 0, sizeof(GENERATE_NAME_CONTEXT));
+      RtlZeroMemory(&NameContext, sizeof(GENERATE_NAME_CONTEXT));
       SearchContext.LongNameU.Buffer = LongNameBuffer;
       SearchContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
       SearchContext.ShortNameU.Buffer = ShortSearchName;
@@ -257,7 +283,7 @@
           ExReleaseResourceLite(&pDirFcb->MainResource);
           vfatReleaseFCB(DeviceExt, pDirFcb);
           ExFreePool (Buffer);
-	  CHECKPOINT;
+          CHECKPOINT;
           return STATUS_UNSUCCESSFUL;
         }
       IsNameLegal = RtlIsNameLegalDOS8Dot3(&DirContext.ShortNameU, &NameA, &SpacesFound);
@@ -310,27 +336,27 @@
     }
   DPRINT ("'%s', '%wZ', needTilde=%d, needLong=%d\n", 
           aName, &DirContext.LongNameU, needTilde, needLong);
-  memset(DirContext.FatDirEntry.Filename, ' ', 11);
+  memset(DirContext.DirEntry.Fat.Filename, ' ', 11);
   for (i = 0; i < 8 && aName[i] && aName[i] != '.'; i++)
     {
-      DirContext.FatDirEntry.Filename[i] = aName[i];
+      DirContext.DirEntry.Fat.Filename[i] = aName[i];
     }
   if (aName[i] == '.')
     {
       i++;
       for (j = 8; j < 11 && aName[i]; j++, i++)
         {
-          DirContext.FatDirEntry.Filename[j] = aName[i];
+          DirContext.DirEntry.Fat.Filename[j] = aName[i];
         }
     }
-  if (DirContext.FatDirEntry.Filename[0] == 0xe5)
+  if (DirContext.DirEntry.Fat.Filename[0] == 0xe5)
     {
-      DirContext.FatDirEntry.Filename[0] = 0x05;
+      DirContext.DirEntry.Fat.Filename[0] = 0x05;
     }
 
   if (needLong)
     {
-      memcpy(LongNameBuffer, DirContext.LongNameU.Buffer, DirContext.LongNameU.Length);
+      RtlCopyMemory(LongNameBuffer, DirContext.LongNameU.Buffer, DirContext.LongNameU.Length);
       DirContext.LongNameU.Buffer = LongNameBuffer;
       DirContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
       DirContext.LongNameU.Buffer[DirContext.LongNameU.Length / sizeof(WCHAR)] = 0;
@@ -342,39 +368,29 @@
       nbSlots = 1;
       if (lCaseBase)
         {
-	  DirContext.FatDirEntry.lCase |= VFAT_CASE_LOWER_BASE;
+	  DirContext.DirEntry.Fat.lCase |= VFAT_CASE_LOWER_BASE;
         }
       if (lCaseExt)
         {
-	  DirContext.FatDirEntry.lCase |= VFAT_CASE_LOWER_EXT;
+	  DirContext.DirEntry.Fat.lCase |= VFAT_CASE_LOWER_EXT;
         }
     }
 
-  DPRINT ("dos name=%11.11s\n", DirContext.FatDirEntry.Filename);
+  DPRINT ("dos name=%11.11s\n", DirContext.DirEntry.Fat.Filename);
 
   /* set attributes */
-  DirContext.FatDirEntry.Attrib = ReqAttr;
+  DirContext.DirEntry.Fat.Attrib = ReqAttr;
   if (RequestedOptions & FILE_DIRECTORY_FILE)
     {
-      DirContext.FatDirEntry.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
+      DirContext.DirEntry.Fat.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
     }
   /* set dates and times */
   KeQuerySystemTime (&SystemTime);
-#if 0
-  {
-    TIME_FIELDS tf;
-    RtlTimeToTimeFields (&SystemTime, &tf);
-    DPRINT1("%d.%d.%d %02d:%02d:%02d.%03d '%S'\n", 
-	    tf.Day, tf.Month, tf.Year, tf.Hour, 
-	    tf.Minute, tf.Second, tf.Milliseconds,
-	    pFileObject->FileName.Buffer);
-  }
-#endif
-  FsdSystemTimeToDosDateTime (&SystemTime, &DirContext.FatDirEntry.CreationDate,
-                              &DirContext.FatDirEntry.CreationTime);
-  DirContext.FatDirEntry.UpdateDate = DirContext.FatDirEntry.CreationDate;
-  DirContext.FatDirEntry.UpdateTime = DirContext.FatDirEntry.CreationTime;
-  DirContext.FatDirEntry.AccessDate = DirContext.FatDirEntry.CreationDate;
+  FsdSystemTimeToDosDateTime (DeviceExt, &SystemTime, &DirContext.DirEntry.Fat.CreationDate,
+                              &DirContext.DirEntry.Fat.CreationTime);
+  DirContext.DirEntry.Fat.UpdateDate = DirContext.DirEntry.Fat.CreationDate;
+  DirContext.DirEntry.Fat.UpdateTime = DirContext.DirEntry.Fat.CreationTime;
+  DirContext.DirEntry.Fat.AccessDate = DirContext.DirEntry.Fat.CreationDate;
 
   if (needLong)
     {
@@ -383,7 +399,7 @@
         {
           pSlots[0].alias_checksum = (((pSlots[0].alias_checksum & 1) << 7
                                    | ((pSlots[0].alias_checksum & 0xfe) >> 1))
-                                   + DirContext.FatDirEntry.Filename[i]);
+                                   + DirContext.DirEntry.Fat.Filename[i]);
         }
       /* construct slots and entry */
       for (i = nbSlots - 2; i >= 0; i--)
@@ -399,9 +415,9 @@
               pSlots[i].id = nbSlots - i - 1 + 0x40;
             }
           pSlots[i].alias_checksum = pSlots[0].alias_checksum;
-          memcpy (pSlots[i].name0_4, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13, 10);
-          memcpy (pSlots[i].name5_10, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 5, 12);
-          memcpy (pSlots[i].name11_12, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 11, 4);
+          RtlCopyMemory (pSlots[i].name0_4, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13, 10);
+          RtlCopyMemory (pSlots[i].name5_10, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 5, 12);
+          RtlCopyMemory (pSlots[i].name11_12, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 11, 4);
 	}
     }
   /* try to find nbSlots contiguous entries frees in directory */
@@ -430,47 +446,47 @@
         }
       if (DeviceExt->FatInfo.FatType == FAT32)
         {
-          DirContext.FatDirEntry.FirstClusterHigh = (unsigned short)(CurrentCluster >> 16);
+          DirContext.DirEntry.Fat.FirstClusterHigh = (unsigned short)(CurrentCluster >> 16);
         }
-      DirContext.FatDirEntry.FirstCluster = (unsigned short)CurrentCluster;
+      DirContext.DirEntry.Fat.FirstCluster = (unsigned short)CurrentCluster;
     }
 
-  i = DeviceExt->FatInfo.BytesPerCluster / sizeof(FATDirEntry);
+  i = DeviceExt->FatInfo.BytesPerCluster / sizeof(FAT_DIR_ENTRY);
   FileOffset.u.HighPart = 0;
-  FileOffset.u.LowPart = DirContext.StartIndex * sizeof(FATDirEntry);
+  FileOffset.u.LowPart = DirContext.StartIndex * sizeof(FAT_DIR_ENTRY);
   if (DirContext.StartIndex / i == DirContext.DirIndex / i)
     {
       /* one cluster */
       CHECKPOINT;
-      CcMapData (pDirFcb->FileObject, &FileOffset, nbSlots * sizeof(FATDirEntry),
+      CcMapData (pDirFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY),
                  TRUE, &Context, (PVOID*)&pFatEntry);
       if (nbSlots > 1)
         {
-          memcpy(pFatEntry, Buffer, (nbSlots - 1) * sizeof(FATDirEntry));
+          RtlCopyMemory(pFatEntry, Buffer, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY));
         }
-      memcpy(pFatEntry + (nbSlots - 1), &DirContext.FatDirEntry, sizeof(FATDirEntry));
+      RtlCopyMemory(pFatEntry + (nbSlots - 1), &DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
     }
   else
     {
       /* two clusters */
       CHECKPOINT;
       size = DeviceExt->FatInfo.BytesPerCluster -
-             (DirContext.StartIndex * sizeof(FATDirEntry)) % DeviceExt->FatInfo.BytesPerCluster;
-      i = size / sizeof(FATDirEntry);
+             (DirContext.StartIndex * sizeof(FAT_DIR_ENTRY)) % DeviceExt->FatInfo.BytesPerCluster;
+      i = size / sizeof(FAT_DIR_ENTRY);
       CcMapData (pDirFcb->FileObject, &FileOffset, size, TRUE,
                  &Context, (PVOID*)&pFatEntry);
-      memcpy(pFatEntry, Buffer, size);
+      RtlCopyMemory(pFatEntry, Buffer, size);
       CcSetDirtyPinnedData(Context, NULL);
       CcUnpinData(Context);
       FileOffset.u.LowPart += size;
       CcMapData (pDirFcb->FileObject, &FileOffset,
-                 nbSlots * sizeof(FATDirEntry) - size,
+                 nbSlots * sizeof(FAT_DIR_ENTRY) - size,
                  TRUE, &Context, (PVOID*)&pFatEntry);
       if (nbSlots - 1 > i)
         {
-          memcpy(pFatEntry, (PVOID)(Buffer + size), (nbSlots - 1 - i) * sizeof(FATDirEntry));
+          RtlCopyMemory(pFatEntry, (PVOID)(Buffer + size), (nbSlots - 1 - i) * sizeof(FAT_DIR_ENTRY));
         }
-      memcpy(pFatEntry + nbSlots - 1 - i, &DirContext.FatDirEntry, sizeof(FATDirEntry));
+      RtlCopyMemory(pFatEntry + nbSlots - 1 - i, &DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
     }
   CcSetDirtyPinnedData(Context, NULL);
   CcUnpinData(Context);
@@ -479,8 +495,8 @@
   vfatMakeFCBFromDirEntry (DeviceExt, pDirFcb, &DirContext, &newFCB);
   vfatAttachFCBToFileObject (DeviceExt, newFCB, pFileObject);
 
-  DPRINT ("new : entry=%11.11s\n", newFCB->entry.Filename);
-  DPRINT ("new : entry=%11.11s\n", DirContext.FatDirEntry.Filename);
+  DPRINT ("new : entry=%11.11s\n", newFCB->entry.Fat.Filename);
+  DPRINT ("new : entry=%11.11s\n", DirContext.DirEntry.Fat.Filename);
 
   if (RequestedOptions & FILE_DIRECTORY_FILE)
     {
@@ -490,12 +506,12 @@
       /* clear the new directory cluster */
       RtlZeroMemory (pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
       /* create '.' and '..' */
-      memcpy (&pFatEntry[0].Attrib, &DirContext.FatDirEntry.Attrib, sizeof(FATDirEntry) - 11);
-      memcpy (pFatEntry[0].Filename, ".          ", 11);
-      memcpy (&pFatEntry[1].Attrib, &DirContext.FatDirEntry.Attrib, sizeof(FATDirEntry) - 11);
-      memcpy (pFatEntry[1].Filename, "..         ", 11);
-      pFatEntry[1].FirstCluster = pDirFcb->entry.FirstCluster;
-      pFatEntry[1].FirstClusterHigh = pDirFcb->entry.FirstClusterHigh;
+      RtlCopyMemory (&pFatEntry[0].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
+      RtlCopyMemory (pFatEntry[0].Filename, ".          ", 11);
+      RtlCopyMemory (&pFatEntry[1].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
+      RtlCopyMemory (pFatEntry[1].Filename, "..         ", 11);
+      pFatEntry[1].FirstCluster = pDirFcb->entry.Fat.FirstCluster;
+      pFatEntry[1].FirstClusterHigh = pDirFcb->entry.Fat.FirstClusterHigh;
       if (vfatFCBIsRoot(pDirFcb))
         {
           pFatEntry[1].FirstCluster = 0;
@@ -512,7 +528,129 @@
 }
 
 NTSTATUS
-VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
+FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
+	      PUNICODE_STRING PathNameU,
+	      PFILE_OBJECT pFileObject,
+	      ULONG RequestedOptions,
+	      UCHAR ReqAttr)
+/*
+  create a new FAT entry
+*/
+{
+   PVOID Context = NULL;
+   PVFATFCB newFCB;
+   LARGE_INTEGER SystemTime, FileOffset;
+   PVFATFCB pDirFcb;
+   OEM_STRING NameA;
+   VFAT_DIRENTRY_CONTEXT DirContext;
+   PFATX_DIR_ENTRY pFatXDirEntry;
+   UNICODE_STRING DirNameU;
+   
+   DPRINT ("addEntry: Pathname='%wZ'\n", PathNameU);
+   
+   vfatSplitPathName(PathNameU, &DirNameU, &DirContext.LongNameU);
+   if (DirNameU.Length > sizeof(WCHAR))
+   {
+      DirNameU.Length -= sizeof(WCHAR);
+   }
+   
+   if (DirContext.LongNameU.Length / sizeof(WCHAR) > 42)
+   {
+      /* name too long */
+      CHECKPOINT;
+      return STATUS_NAME_TOO_LONG;
+   }
+   
+   pDirFcb = vfatGrabFCBFromTable(DeviceExt, &DirNameU);
+   if (pDirFcb == NULL)
+   {
+      return STATUS_UNSUCCESSFUL;
+   }
+   
+   if (!ExAcquireResourceExclusiveLite(&pDirFcb->MainResource, TRUE))
+   {
+      DPRINT("Failed acquiring lock\n");
+      return STATUS_UNSUCCESSFUL;
+   }
+   
+   /* try to find 1 entry free in directory */
+   if (!vfatFindDirSpace(DeviceExt, pDirFcb, 1, &DirContext.StartIndex))
+   {
+      ExReleaseResourceLite(&pDirFcb->MainResource);
+      vfatReleaseFCB(DeviceExt, pDirFcb);
+      return STATUS_DISK_FULL;
+   }
+   DirContext.DirIndex = DirContext.StartIndex;
+   if (!vfatFCBIsRoot(pDirFcb))
+   {
+      DirContext.DirIndex += 2;
+   }
+  
+   DirContext.ShortNameU.Buffer = 0;
+   DirContext.ShortNameU.Length = 0;
+   DirContext.ShortNameU.MaximumLength = 0;
+   RtlZeroMemory(&DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
+   memset(DirContext.DirEntry.FatX.Filename, 0xff, 42);
+   DirContext.DirEntry.FatX.FirstCluster = 0;
+   DirContext.DirEntry.FatX.FileSize = 0;
+   
+   /* set file name */
+   NameA.Buffer = DirContext.DirEntry.FatX.Filename;
+   NameA.Length = 0;
+   NameA.MaximumLength = 42;
+   RtlUnicodeStringToOemString(&NameA, &DirContext.LongNameU, FALSE);
+   DirContext.DirEntry.FatX.FilenameLength = NameA.Length;
+   
+   /* set attributes */
+   DirContext.DirEntry.FatX.Attrib = ReqAttr;
+   if (RequestedOptions & FILE_DIRECTORY_FILE)
+   {
+      DirContext.DirEntry.FatX.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
+   }
+   
+   /* set dates and times */
+   KeQuerySystemTime (&SystemTime);
+   FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.FatX.CreationDate,
+                              &DirContext.DirEntry.FatX.CreationTime);
+   DirContext.DirEntry.FatX.UpdateDate = DirContext.DirEntry.FatX.CreationDate;
+   DirContext.DirEntry.FatX.UpdateTime = DirContext.DirEntry.FatX.CreationTime;
+   DirContext.DirEntry.FatX.AccessDate = DirContext.DirEntry.FatX.CreationDate;
+   DirContext.DirEntry.FatX.AccessTime = DirContext.DirEntry.FatX.CreationTime;
+   
+   /* add entry into parent directory */
+   FileOffset.u.HighPart = 0;
+   FileOffset.u.LowPart = DirContext.StartIndex * sizeof(FATX_DIR_ENTRY);
+   CcMapData(pDirFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
+                 TRUE, &Context, (PVOID*)&pFatXDirEntry);
+   RtlCopyMemory(pFatXDirEntry, &DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
+   CcSetDirtyPinnedData(Context, NULL);
+   CcUnpinData(Context);
+   
+   /* FIXME: check status */
+   vfatMakeFCBFromDirEntry(DeviceExt, pDirFcb, &DirContext, &newFCB);
+   vfatAttachFCBToFileObject(DeviceExt, newFCB, pFileObject);
+   
+   ExReleaseResourceLite(&pDirFcb->MainResource);
+   vfatReleaseFCB(DeviceExt, pDirFcb);
+   DPRINT("addentry ok\n");
+   return STATUS_SUCCESS;
+}
+
+NTSTATUS
+VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
+	      PUNICODE_STRING PathNameU,
+	      PFILE_OBJECT pFileObject,
+	      ULONG RequestedOptions,
+	      UCHAR ReqAttr)
+{
+   if (DeviceExt->Flags & VCB_IS_FATX)
+      return FATXAddEntry(DeviceExt, PathNameU, pFileObject, RequestedOptions, ReqAttr);
+   else
+      return FATAddEntry(DeviceExt, PathNameU, pFileObject, RequestedOptions, ReqAttr);
+}
+
+NTSTATUS
+FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
 /*
  * deleting an existing FAT entry
  */
@@ -520,7 +658,7 @@
   ULONG CurrentCluster = 0, NextCluster, i;
   PVOID Context = NULL;
   LARGE_INTEGER Offset;
-  FATDirEntry* pDirEntry;
+  PFAT_DIR_ENTRY pDirEntry;
 
   ASSERT(pFcb);
   ASSERT(pFcb->parentFcb);
@@ -530,23 +668,23 @@
   Offset.u.HighPart = 0;
   for (i = pFcb->startIndex; i <= pFcb->dirIndex; i++)
     {
-      if (Context == NULL || ((i * sizeof(FATDirEntry)) % PAGE_SIZE) == 0)
+      if (Context == NULL || ((i * sizeof(FAT_DIR_ENTRY)) % PAGE_SIZE) == 0)
         {
           if (Context)
           {
             CcSetDirtyPinnedData(Context, NULL);
             CcUnpinData(Context);
           }
-          Offset.u.LowPart = (i * sizeof(FATDirEntry) / PAGE_SIZE) * PAGE_SIZE;
+          Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
           CcMapData (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
                      &Context, (PVOID*)&pDirEntry);
         }
-      pDirEntry[i % (PAGE_SIZE / sizeof(FATDirEntry))].Filename[0] = 0xe5;
+      pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5;
       if (i == pFcb->dirIndex)
         {
           CurrentCluster =
           vfatDirEntryGetFirstCluster (DeviceExt,
-            &pDirEntry[i % (PAGE_SIZE / sizeof(FATDirEntry))]);
+            (PDIR_ENTRY)&pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))]);
         }
     }
   if (Context)
@@ -565,4 +703,58 @@
   return STATUS_SUCCESS;
 }
 
+NTSTATUS
+FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
+/*
+ * deleting an existing FAT entry
+ */
+{
+  ULONG CurrentCluster = 0, NextCluster;
+  PVOID Context = NULL;
+  LARGE_INTEGER Offset;
+  PFATX_DIR_ENTRY pDirEntry;
+  ULONG StartIndex; 
+
+  ASSERT(pFcb);
+  ASSERT(pFcb->parentFcb);
+  ASSERT(pFcb->Flags & FCB_IS_FATX_ENTRY);
+  
+  StartIndex = pFcb->startIndex;
+
+  DPRINT ("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
+  DPRINT ("delete entry: %d\n", StartIndex);
+  Offset.u.HighPart = 0;
+  Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
+  if (!CcMapData (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
+                     &Context, (PVOID*)&pDirEntry))
+  {
+    DPRINT1("CcMapData(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
+    return STATUS_UNSUCCESSFUL;
+  }
+  pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
+  pDirEntry->FilenameLength = 0xe5;
+  CurrentCluster = vfatDirEntryGetFirstCluster (DeviceExt,
+            (PDIR_ENTRY)pDirEntry);
+  CcSetDirtyPinnedData(Context, NULL);
+  CcUnpinData(Context);
+  
+  while (CurrentCluster && CurrentCluster != 0xffffffff)
+    {
+      GetNextCluster (DeviceExt, CurrentCluster, &NextCluster);
+      /* FIXME: check status */
+      WriteCluster(DeviceExt, CurrentCluster, 0);
+      CurrentCluster = NextCluster;
+    }
+  return STATUS_SUCCESS;
+}
+
+NTSTATUS
+VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
+{
+   if (DeviceExt->Flags & VCB_IS_FATX)
+      return FATXDelEntry(DeviceExt, pFcb);
+   else
+      return FATDelEntry(DeviceExt, pFcb);
+}
+
 /* EOF */

reactos/drivers/fs/vfat
fat.c 1.46 -> 1.46.8.1
diff -u -r1.46 -r1.46.8.1
--- fat.c	5 Aug 2004 02:48:18 -0000	1.46
+++ fat.c	8 Dec 2004 21:56:48 -0000	1.46.8.1
@@ -1,5 +1,5 @@
 /*
- * $Id: fat.c,v 1.46 2004/08/05 02:48:18 navaraf Exp $
+ * $Id: fat.c,v 1.46.8.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -459,7 +459,7 @@
   {
 	if (DeviceExt->FatInfo.FatType == FAT12)
 	  Status = FAT12CountAvailableClusters(DeviceExt);
-	else if (DeviceExt->FatInfo.FatType == FAT16)
+	else if (DeviceExt->FatInfo.FatType == FAT16 || DeviceExt->FatInfo.FatType == FATX16)
 	  Status = FAT16CountAvailableClusters(DeviceExt);
 	else
 	  Status = FAT32CountAvailableClusters(DeviceExt);
@@ -641,7 +641,7 @@
 	  DeviceExt, CurrentCluster);
 
   if (CurrentCluster == 0)
-     return(STATUS_UNSUCCESSFUL);
+     return(STATUS_INVALID_PARAMETER);
 
   ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
   Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster);

reactos/drivers/fs/vfat
fcb.c 1.42 -> 1.42.2.1
diff -u -r1.42 -r1.42.2.1
--- fcb.c	6 Nov 2004 13:44:57 -0000	1.42
+++ fcb.c	8 Dec 2004 21:56:48 -0000	1.42.2.1
@@ -1,4 +1,4 @@
-/* $Id: fcb.c,v 1.42 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: fcb.c,v 1.42.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  *
  * FILE:             drivers/fs/vfat/fcb.c
@@ -8,6 +8,7 @@
  * PROGRAMMER:       Jason Filby (jasonfilby@yahoo.com)
  *                   Rex Jolliff (rex@lvcablemodem.com)
  *                   Hartmut Birr
+ *                   Herve Poussineau (reactos@poussine.freesurf.fr)
  */
 
 /*  -------------------------------------------------------  INCLUDES  */
@@ -38,6 +39,7 @@
   PWCHAR curr;
   register WCHAR c;
 
+  ASSERT(NameU->Buffer[0] != L'.');
   curr = NameU->Buffer;
   last = NameU->Buffer + NameU->Length / sizeof(WCHAR);
 
@@ -93,7 +95,7 @@
 }  
 
 PVFATFCB
-vfatNewFCB(PUNICODE_STRING pFileNameU)
+vfatNewFCB(PDEVICE_EXTENSION  pVCB, PUNICODE_STRING pFileNameU)
 {
   PVFATFCB  rcFCB;
 
@@ -104,8 +106,15 @@
     {
       return NULL;
     }
-  memset(rcFCB, 0, sizeof(VFATFCB));
+  RtlZeroMemory(rcFCB, sizeof(VFATFCB));
   vfatInitFcb(rcFCB, pFileNameU);
+  if (pVCB->Flags & VCB_IS_FATX)
+  {
+    rcFCB->Flags |= FCB_IS_FATX_ENTRY;
+    rcFCB->Attributes = &rcFCB->entry.FatX.Attrib;
+  }
+  else
+    rcFCB->Attributes = &rcFCB->entry.Fat.Attrib;
   rcFCB->Hash.Hash = vfatNameHash(0, &rcFCB->PathNameU);
   rcFCB->Hash.self = rcFCB;
   rcFCB->ShortHash.self = rcFCB;
@@ -138,7 +147,7 @@
 BOOL
 vfatFCBIsDirectory(PVFATFCB FCB)
 {
-  return  FCB->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY;
+  return  *FCB->Attributes & FILE_ATTRIBUTE_DIRECTORY;
 }
 
 BOOL
@@ -312,7 +321,7 @@
   {
     return  STATUS_INSUFFICIENT_RESOURCES;
   }
-  memset (newCCB, 0, sizeof (VFATCCB));
+  RtlZeroMemory(newCCB, sizeof (VFATCCB));
 
   fileObject->Flags |= FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
   fileObject->SectionObjectPointer = &fcb->SectionObjectPointers;
@@ -347,28 +356,39 @@
 
   RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\");
 
-  FCB = vfatNewFCB(&NameU);
-  memset(FCB->entry.Filename, ' ', 11);
-  FCB->ShortHash.Hash = FCB->Hash.Hash;
-  FCB->entry.FileSize = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
-  FCB->entry.Attrib = FILE_ATTRIBUTE_DIRECTORY;
-  if (pVCB->FatInfo.FatType == FAT32)
-  {
-    CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster;
-    FCB->entry.FirstCluster = (unsigned short)(FirstCluster & 0xffff);
-    FCB->entry.FirstClusterHigh = (unsigned short)(FirstCluster >> 16);
-
-    while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
-    {
-      Size += pVCB->FatInfo.BytesPerCluster;
-      Status = NextCluster (pVCB, FirstCluster, &CurrentCluster, FALSE);
-    }
+  FCB = vfatNewFCB(pVCB, &NameU);
+  if (FCB->Flags & FCB_IS_FATX_ENTRY)
+  {
+    memset(FCB->entry.FatX.Filename, ' ', 42);
+    FCB->entry.FatX.FileSize = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
+    FCB->entry.FatX.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+    FCB->entry.FatX.FirstCluster = 1;
+    Size = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
   }
   else
   {
-    FCB->entry.FirstCluster = 1;
-    Size = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
+    memset(FCB->entry.Fat.Filename, ' ', 11);
+    FCB->entry.Fat.FileSize = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
+    FCB->entry.Fat.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+    if (pVCB->FatInfo.FatType == FAT32)
+    {
+      CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster;
+      FCB->entry.Fat.FirstCluster = (unsigned short)(FirstCluster & 0xffff);
+      FCB->entry.Fat.FirstClusterHigh = (unsigned short)(FirstCluster >> 16);
+
+      while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
+      {
+        Size += pVCB->FatInfo.BytesPerCluster;
+        Status = NextCluster (pVCB, FirstCluster, &CurrentCluster, FALSE);
+      }
+    }
+    else
+    {
+      FCB->entry.Fat.FirstCluster = 1;
+      Size = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;
+    }
   }
+  FCB->ShortHash.Hash = FCB->Hash.Hash;
   FCB->RefCount = 2;
   FCB->dirIndex = 0;
   FCB->RFCB.FileSize.QuadPart = Size;
@@ -435,10 +455,18 @@
     RtlAppendUnicodeStringToString(&NameU, &DirContext->ShortNameU);
   }
   NameU.Buffer[NameU.Length / sizeof(WCHAR)] = 0;
-  rcFCB = vfatNewFCB (&NameU);
-  memcpy (&rcFCB->entry, &DirContext->FatDirEntry, sizeof (FAT_DIR_ENTRY));
+  
+  rcFCB = vfatNewFCB (vcb, &NameU);
+  RtlCopyMemory (&rcFCB->entry, &DirContext->DirEntry, sizeof (DIR_ENTRY));
   RtlCopyUnicodeString(&rcFCB->ShortNameU, &DirContext->ShortNameU);
-  rcFCB->ShortHash.Hash = vfatNameHash(hash, &rcFCB->ShortNameU);
+  if (vcb->Flags & VCB_IS_FATX)
+  {
+    rcFCB->ShortHash.Hash = rcFCB->Hash.Hash;
+  }
+  else
+  {
+    rcFCB->ShortHash.Hash = vfatNameHash(hash, &rcFCB->ShortNameU);
+  }
 
   if (vfatFCBIsDirectory(rcFCB))
   {
@@ -450,7 +478,7 @@
     {
       Size = vcb->FatInfo.rootDirectorySectors * vcb->FatInfo.BytesPerSector;
     }
-    else
+    else if (FirstCluster != 0)
     {
       CurrentCluster = FirstCluster;
       while (CurrentCluster != 0xffffffff)
@@ -460,9 +488,13 @@
       }
     }
   }
+  else if (rcFCB->Flags & FCB_IS_FATX_ENTRY)
+  {
+    Size = rcFCB->entry.FatX.FileSize;
+  }
   else
   {
-    Size = rcFCB->entry.FileSize;
+    Size = rcFCB->entry.Fat.FileSize;
   }
   rcFCB->dirIndex = DirContext->DirIndex;
   rcFCB->startIndex = DirContext->StartIndex;
@@ -494,7 +526,7 @@
     CHECKPOINT;
     return  STATUS_INSUFFICIENT_RESOURCES;
   }
-  memset (newCCB, 0, sizeof (VFATCCB));
+  RtlZeroMemory (newCCB, sizeof (VFATCCB));
 
   fileObject->Flags = fileObject->Flags | FO_FCB_IS_VALID |
       FO_DIRECT_CACHE_PAGING_READ;
@@ -542,7 +574,7 @@
 
   while (TRUE)
     {
-      status = vfatGetNextDirEntry(&Context,
+      status = pDeviceExt->GetNextDirEntry(&Context,
 	                           &Page, 
 	                           pDirectoryFCB,
 				   &DirContext,
@@ -562,7 +594,7 @@
               &DirContext.LongNameU);
       DirContext.LongNameU.Buffer[DirContext.LongNameU.Length / sizeof(WCHAR)] = 0;
       DirContext.ShortNameU.Buffer[DirContext.ShortNameU.Length / sizeof(WCHAR)] = 0;
-      if (!ENTRY_VOLUME(&DirContext.FatDirEntry))
+      if (!ENTRY_VOLUME(pDeviceExt, &DirContext.DirEntry))
         {
 	  FoundLong = RtlEqualUnicodeString(FileToFindU, &DirContext.LongNameU, TRUE);
 	  if (FoundLong == FALSE)
@@ -646,7 +678,7 @@
 	      curr = pFileNameU->Buffer + FCB->PathNameU.Length / sizeof(WCHAR);
               last = pFileNameU->Buffer + pFileNameU->Length / sizeof(WCHAR) - 1;
 	    }
-	  memcpy(pFileNameU->Buffer, FCB->PathNameU.Buffer, FCB->PathNameU.Length);
+	  RtlCopyMemory(pFileNameU->Buffer, FCB->PathNameU.Buffer, FCB->PathNameU.Length);
 	}
     }
   else
@@ -699,7 +731,7 @@
 	      curr = prev + parentFCB->LongNameU.Length / sizeof(WCHAR);
               last = pFileNameU->Buffer + pFileNameU->Length / sizeof(WCHAR) - 1;
 	    }
-	  memcpy(prev, parentFCB->LongNameU.Buffer, parentFCB->LongNameU.Length);
+	  RtlCopyMemory(prev, parentFCB->LongNameU.Buffer, parentFCB->LongNameU.Length);
 	}
       curr++;      
       prev = curr;

reactos/drivers/fs/vfat
finfo.c 1.38 -> 1.38.2.1
diff -u -r1.38 -r1.38.2.1
--- finfo.c	6 Nov 2004 13:44:57 -0000	1.38
+++ finfo.c	8 Dec 2004 21:56:48 -0000	1.38.2.1
@@ -1,4 +1,4 @@
-/* $Id: finfo.c,v 1.38 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: finfo.c,v 1.38.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -6,6 +6,7 @@
  * PURPOSE:          VFAT Filesystem
  * PROGRAMMER:       Jason Filby (jasonfilby@yahoo.com)
  *                   Hartmut Birr
+ *                   Herve Poussineau (reactos@poussine.freesurf.fr)
  *
  */
 
@@ -106,26 +107,47 @@
   ASSERT(NULL != DeviceExt);
   ASSERT(NULL != BasicInfo);
   /* Check volume label bit */
-  ASSERT(0 == (FCB->entry.Attrib & 0x08));
+  ASSERT(0 == (*FCB->Attributes & 0x08));
 
-  FsdSystemTimeToDosDateTime(&BasicInfo->CreationTime,
-                             &FCB->entry.CreationDate,
-                             &FCB->entry.CreationTime);
-  FsdSystemTimeToDosDateTime(&BasicInfo->LastAccessTime,
-                             &FCB->entry.AccessDate,
+  if (FCB->Flags & FCB_IS_FATX_ENTRY)
+  {
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->CreationTime,
+                             &FCB->entry.FatX.CreationDate,
+                             &FCB->entry.FatX.CreationTime);
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->LastAccessTime,
+                             &FCB->entry.FatX.AccessDate,
+                             &FCB->entry.FatX.AccessTime);
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->LastWriteTime,
+                             &FCB->entry.FatX.UpdateDate,
+                             &FCB->entry.FatX.UpdateTime);
+  }
+  else
+  {
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->CreationTime,
+                             &FCB->entry.Fat.CreationDate,
+                             &FCB->entry.Fat.CreationTime);
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->LastAccessTime,
+                             &FCB->entry.Fat.AccessDate,
                              NULL);
-  FsdSystemTimeToDosDateTime(&BasicInfo->LastWriteTime,
-                             &FCB->entry.UpdateDate,
-                             &FCB->entry.UpdateTime);
+    FsdSystemTimeToDosDateTime(DeviceExt,
+                             &BasicInfo->LastWriteTime,
+                             &FCB->entry.Fat.UpdateDate,
+                             &FCB->entry.Fat.UpdateTime);
+  }
 
-  FCB->entry.Attrib = (unsigned char)((FCB->entry.Attrib &
+  *FCB->Attributes = (unsigned char)((*FCB->Attributes &
                        (FILE_ATTRIBUTE_DIRECTORY | 0x48)) |
                       (BasicInfo->FileAttributes &
                        (FILE_ATTRIBUTE_ARCHIVE |
                         FILE_ATTRIBUTE_SYSTEM |
                         FILE_ATTRIBUTE_HIDDEN |
                         FILE_ATTRIBUTE_READONLY)));
-  DPRINT("Setting attributes 0x%02x\n", FCB->entry.Attrib);
+  DPRINT("Setting attributes 0x%02x\n", *FCB->Attributes);
 
   VfatUpdateEntry(FCB);
 
@@ -139,23 +161,48 @@
 			PFILE_BASIC_INFORMATION BasicInfo,
 			PULONG BufferLength)
 {
+  PDEVICE_EXTENSION DeviceExt;
   DPRINT("VfatGetBasicInformation()\n");
+  
+  DeviceExt = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
   if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
     return STATUS_BUFFER_OVERFLOW;
 
-  FsdDosDateTimeToSystemTime(FCB->entry.CreationDate,
-			     FCB->entry.CreationTime,
+  if (FCB->Flags & FCB_IS_FATX_ENTRY)
+  {
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.FatX.CreationDate,
+			     FCB->entry.FatX.CreationTime,
 			     &BasicInfo->CreationTime);
-  FsdDosDateTimeToSystemTime(FCB->entry.AccessDate,
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.FatX.AccessDate,
+			     FCB->entry.FatX.AccessTime,
+			     &BasicInfo->LastAccessTime);
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.FatX.UpdateDate,
+			     FCB->entry.FatX.UpdateTime,
+			     &BasicInfo->LastWriteTime);
+    BasicInfo->ChangeTime = BasicInfo->LastWriteTime;
+  }
+  else
+  {
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.Fat.CreationDate,
+			     FCB->entry.Fat.CreationTime,
+			     &BasicInfo->CreationTime);
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.Fat.AccessDate,
 			     0,
 			     &BasicInfo->LastAccessTime);
-  FsdDosDateTimeToSystemTime(FCB->entry.UpdateDate,
-			     FCB->entry.UpdateTime,
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     FCB->entry.Fat.UpdateDate,
+			     FCB->entry.Fat.UpdateTime,
 			     &BasicInfo->LastWriteTime);
-  BasicInfo->ChangeTime = BasicInfo->LastWriteTime;
+    BasicInfo->ChangeTime = BasicInfo->LastWriteTime;
+  }
 
-  BasicInfo->FileAttributes = FCB->entry.Attrib & 0x3f;
+  BasicInfo->FileAttributes = *FCB->Attributes & 0x3f;
   /* Synthesize FILE_ATTRIBUTE_NORMAL */
   if (0 == (BasicInfo->FileAttributes & (FILE_ATTRIBUTE_DIRECTORY |
                                          FILE_ATTRIBUTE_ARCHIVE |
@@ -188,7 +235,7 @@
   ASSERT(DeviceExt->FatInfo.BytesPerCluster != 0);
   ASSERT(FCB != NULL);
 
-  if (FCB->entry.Attrib & FILE_ATTRIBUTE_READONLY) 
+  if (*FCB->Attributes & FILE_ATTRIBUTE_READONLY) 
     {
       return STATUS_CANNOT_DELETE;
     }
@@ -259,7 +306,7 @@
     return STATUS_BUFFER_OVERFLOW;
 
   NameInfo->FileNameLength = FCB->PathNameU.Length;
-  memcpy(NameInfo->FileName, FCB->PathNameU.Buffer, FCB->PathNameU.Length);
+  RtlCopyMemory(NameInfo->FileName, FCB->PathNameU.Buffer, FCB->PathNameU.Length);
   NameInfo->FileName[FCB->PathNameU.Length / sizeof(WCHAR)] = 0;
 
   *BufferLength -= (sizeof(FILE_NAME_INFORMATION) + FCB->PathNameU.Length + sizeof(WCHAR));
@@ -286,6 +333,7 @@
 
 static NTSTATUS
 VfatGetNetworkOpenInformation(PVFATFCB Fcb,
+			      PDEVICE_EXTENSION DeviceExt,
 			      PFILE_NETWORK_OPEN_INFORMATION NetworkInfo,
 			      PULONG BufferLength)
 /*
@@ -298,16 +346,38 @@
   if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION))
     return(STATUS_BUFFER_OVERFLOW);
 
-  FsdDosDateTimeToSystemTime(Fcb->entry.CreationDate,
-			     Fcb->entry.CreationTime,
+  if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+  {
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.FatX.CreationDate,
+			     Fcb->entry.FatX.CreationTime,
+			     &NetworkInfo->CreationTime);
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.FatX.AccessDate,
+			     Fcb->entry.FatX.AccessTime,
+			     &NetworkInfo->LastAccessTime);
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.FatX.UpdateDate,
+			     Fcb->entry.FatX.UpdateTime,
+			     &NetworkInfo->LastWriteTime);
+    NetworkInfo->ChangeTime.QuadPart = NetworkInfo->LastWriteTime.QuadPart;
+  }
+  else
+  {
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.Fat.CreationDate,
+			     Fcb->entry.Fat.CreationTime,
 			     &NetworkInfo->CreationTime);
-  FsdDosDateTimeToSystemTime(Fcb->entry.AccessDate,
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.Fat.AccessDate,
 			     0,
 			     &NetworkInfo->LastAccessTime);
-  FsdDosDateTimeToSystemTime(Fcb->entry.UpdateDate,
-			     Fcb->entry.UpdateTime,
+    FsdDosDateTimeToSystemTime(DeviceExt,
+			     Fcb->entry.Fat.UpdateDate,
+			     Fcb->entry.Fat.UpdateTime,
 			     &NetworkInfo->LastWriteTime);
-  NetworkInfo->ChangeTime.QuadPart = NetworkInfo->LastWriteTime.QuadPart;
+    NetworkInfo->ChangeTime.QuadPart = NetworkInfo->LastWriteTime.QuadPart;
+  }
   if (vfatFCBIsDirectory(Fcb))
     {
       NetworkInfo->EndOfFile.QuadPart = 0L;
@@ -318,7 +388,7 @@
       NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize;
       NetworkInfo->EndOfFile = Fcb->RFCB.FileSize;
     }
-  NetworkInfo->FileAttributes = Fcb->entry.Attrib & 0x3f;
+  NetworkInfo->FileAttributes = *Fcb->Attributes & 0x3f;
 
   *BufferLength -= sizeof(FILE_NETWORK_OPEN_INFORMATION);
   return STATUS_SUCCESS;
@@ -328,12 +398,16 @@
 static NTSTATUS
 VfatGetAllInformation(PFILE_OBJECT FileObject,
 		      PVFATFCB Fcb,
+		      PDEVICE_OBJECT DeviceObject,
 		      PFILE_ALL_INFORMATION Info,
 		      PULONG BufferLength)
 /*
  * FUNCTION: Retrieve the all file information
  */
 {
+  NTSTATUS Status;
+  ULONG InitialBufferLength = *BufferLength;
+  
   ASSERT(Info);
   ASSERT(Fcb);
 
@@ -341,60 +415,28 @@
     return(STATUS_BUFFER_OVERFLOW);
 
   /* Basic Information */
-  FsdDosDateTimeToSystemTime(Fcb->entry.CreationDate,
-			     Fcb->entry.CreationTime,
-			     &Info->BasicInformation.CreationTime);
-  FsdDosDateTimeToSystemTime(Fcb->entry.AccessDate,
-			     0,
-			     &Info->BasicInformation.LastAccessTime);
-  FsdDosDateTimeToSystemTime(Fcb->entry.UpdateDate,
-			     Fcb->entry.UpdateTime,
-			     &Info->BasicInformation.LastWriteTime);
-  Info->BasicInformation.ChangeTime.QuadPart = Info->BasicInformation.LastWriteTime.QuadPart;
-  Info->BasicInformation.FileAttributes = Fcb->entry.Attrib & 0x3f;
-
+  Status = VfatGetBasicInformation(FileObject, Fcb, DeviceObject, &Info->BasicInformation, BufferLength);
+  if (!NT_SUCCESS(Status)) return Status;
   /* Standard Information */
-  if (vfatFCBIsDirectory(Fcb))
-    {
-      Info->StandardInformation.AllocationSize.QuadPart = 0LL;
-      Info->StandardInformation.EndOfFile.QuadPart = 0LL;
-      Info->StandardInformation.Directory = TRUE;
-    }
-  else
-    {
-      Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize;
-      Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize;
-      Info->StandardInformation.Directory = FALSE;
-    }
-  Info->StandardInformation.NumberOfLinks = 0;
-  Info->StandardInformation.DeletePending = Fcb->Flags & FCB_DELETE_PENDING ? TRUE : FALSE;
-
+  Status = VfatGetStandardInformation(Fcb, &Info->StandardInformation, BufferLength);
+  if (!NT_SUCCESS(Status)) return Status;
   /* Internal Information */
-  /* FIXME: get a real index, that can be used in a create operation */
-  Info->InternalInformation.IndexNumber.QuadPart = 0;
-
+  Status = VfatGetInternalInformation(Fcb, &Info->InternalInformation, BufferLength);
+  if (!NT_SUCCESS(Status)) return Status;
   /* EA Information */
   Info->EaInformation.EaSize = 0;
-
-  /* Access Information */
-  /* The IO-Manager adds this information */
-
+  /* Access Information: The IO-Manager adds this information */
   /* Position Information */
-  Info->PositionInformation.CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart;
-
-  /* Mode Information */
-  /* The IO-Manager adds this information */
-
-  /* Alignment Information */
-  /* The IO-Manager adds this information */
-
+  Status = VfatGetPositionInformation(FileObject, Fcb, DeviceObject, &Info->PositionInformation, BufferLength);
+  if (!NT_SUCCESS(Status)) return Status;
+  /* Mode Information: The IO-Manager adds this information */
+  /* Alignment Information: The IO-Manager adds this information */
   /* Name Information */
-  Info->NameInformation.FileNameLength = Fcb->PathNameU.Length;
-  RtlCopyMemory(Info->NameInformation.FileName, Fcb->PathNameU.Buffer, Fcb->PathNameU.Length);
-  Info->NameInformation.FileName[Fcb->PathNameU.Length / sizeof(WCHAR)] = 0;
-
-  *BufferLength -= (sizeof(FILE_ALL_INFORMATION) + Fcb->PathNameU.Length + sizeof(WCHAR));
-
+  Status = VfatGetNameInformation(FileObject, Fcb, DeviceObject, &Info->NameInformation, BufferLength);
+  if (!NT_SUCCESS(Status)) return Status;
+  
+  *BufferLength = InitialBufferLength - (sizeof(FILE_ALL_INFORMATION) + Fcb->PathNameU.Length + sizeof(WCHAR));
+  
   return STATUS_SUCCESS;
 }
 
@@ -410,7 +452,10 @@
    }
    if (!vfatFCBIsDirectory(Fcb))
    {
-      Fcb->entry.FileSize = Size;  
+      if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+         Fcb->entry.FatX.FileSize = Size;  
+      else
+         Fcb->entry.Fat.FileSize = Size;  
    }
    Fcb->RFCB.FileSize.QuadPart = Size;
    Fcb->RFCB.ValidDataLength.QuadPart = Size;
@@ -438,7 +483,10 @@
 
   DPRINT("VfatSetAllocationSizeInformation()\n");
 
-  OldSize = Fcb->entry.FileSize;
+  if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+    OldSize = Fcb->entry.FatX.FileSize;
+  else
+    OldSize = Fcb->entry.Fat.FileSize;
   if (AllocationSize->u.HighPart > 0)
   {
     return STATUS_INVALID_PARAMETER;
@@ -482,8 +530,15 @@
          }
          return STATUS_DISK_FULL;
       }
-      Fcb->entry.FirstCluster = (unsigned short)(FirstCluster & 0x0000FFFF);
-      Fcb->entry.FirstClusterHigh = (unsigned short)((FirstCluster & 0xFFFF0000) >> 16);
+      if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+      {
+         Fcb->entry.FatX.FirstCluster = FirstCluster;
+      }
+      else
+      {
+        Fcb->entry.Fat.FirstCluster = (unsigned short)(FirstCluster & 0x0000FFFF);
+        Fcb->entry.Fat.FirstClusterHigh = (unsigned short)((FirstCluster & 0xFFFF0000) >> 16);
+      }
     }
     else
     {
@@ -547,8 +602,15 @@
     }
     else
     {
-      Fcb->entry.FirstCluster = 0;
-      Fcb->entry.FirstClusterHigh = 0;
+      if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+      {
+         Fcb->entry.FatX.FirstCluster = 0;
+      }
+      else
+      {
+        Fcb->entry.Fat.FirstCluster = 0;
+        Fcb->entry.Fat.FirstClusterHigh = 0;
+      }
 
       NCluster = Cluster = FirstCluster;
       Status = STATUS_SUCCESS;
@@ -640,12 +702,14 @@
       break;
     case FileNetworkOpenInformation:
       RC = VfatGetNetworkOpenInformation(FCB,
+					 IrpContext->DeviceExt,
 					 SystemBuffer,
 					 &BufferLength);
       break;
     case FileAllInformation:
       RC = VfatGetAllInformation(IrpContext->FileObject,
 				 FCB,
+				 IrpContext->DeviceObject,
 				 SystemBuffer,
 				 &BufferLength);
       break;

reactos/drivers/fs/vfat
fsctl.c 1.36 -> 1.36.2.1
diff -u -r1.36 -r1.36.2.1
--- fsctl.c	6 Nov 2004 13:44:57 -0000	1.36
+++ fsctl.c	8 Dec 2004 21:56:48 -0000	1.36.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: fsctl.c,v 1.36 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: fsctl.c,v 1.36.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -55,6 +55,7 @@
    ULONG Sectors;
    LARGE_INTEGER Offset;
    struct _BootSector* Boot;
+   struct _BootSectorFatX* BootFatX;
    BOOL PartitionInfoIsValid = FALSE;
 
    DPRINT("VfatHasFileSystem\n");
@@ -92,17 +93,15 @@
          return Status;
       }
       PartitionInfoIsValid = TRUE;
-#if defined(DBG) && !defined(NDEBUG)
-      DbgPrint("Partition Information:\n");
-      DbgPrint("StartingOffset      %u\n", PartitionInfo.StartingOffset.QuadPart  / 512);
-      DbgPrint("PartitionLength     %u\n", PartitionInfo.PartitionLength.QuadPart / 512);
-      DbgPrint("HiddenSectors       %u\n", PartitionInfo.HiddenSectors);
-      DbgPrint("PartitionNumber     %u\n", PartitionInfo.PartitionNumber);
-      DbgPrint("PartitionType       %u\n", PartitionInfo.PartitionType);
-      DbgPrint("BootIndicator       %u\n", PartitionInfo.BootIndicator);
-      DbgPrint("RecognizedPartition %u\n", PartitionInfo.RecognizedPartition);
-      DbgPrint("RewritePartition    %u\n", PartitionInfo.RewritePartition);
-#endif
+      DPRINT("Partition Information:\n");
+      DPRINT("StartingOffset      %u\n", PartitionInfo.StartingOffset.QuadPart  / 512);
+      DPRINT("PartitionLength     %u\n", PartitionInfo.PartitionLength.QuadPart / 512);
+      DPRINT("HiddenSectors       %u\n", PartitionInfo.HiddenSectors);
+      DPRINT("PartitionNumber     %u\n", PartitionInfo.PartitionNumber);
+      DPRINT("PartitionType       %u\n", PartitionInfo.PartitionType);
+      DPRINT("BootIndicator       %u\n", PartitionInfo.BootIndicator);
+      DPRINT("RecognizedPartition %u\n", PartitionInfo.RecognizedPartition);
+      DPRINT("RewritePartition    %u\n", PartitionInfo.RewritePartition);
       if (PartitionInfo.PartitionType)
       {
          if (PartitionInfo.PartitionType == PARTITION_FAT_12       ||
@@ -151,20 +150,28 @@
    }
 
    Offset.QuadPart = 0;
-
+   
+   /* Try to recognize FAT12/FAT16/FAT32 partitions */
    Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
    if (NT_SUCCESS(Status))
    {
       if (Boot->Signatur1 != 0xaa55)
       {
-         DPRINT1("Signature %04x\n", Boot->Signatur1);
+         BootFatX = (struct _BootSectorFatX *) Boot;
+         if (BootFatX->SysType[0] != 'F' ||
+             BootFatX->SysType[1] != 'A' ||
+             BootFatX->SysType[2] != 'T' ||
+             BootFatX->SysType[3] != 'X')
+         {
+            DPRINT1("Signature %04x\n", Boot->Signatur1);
+         }
          *RecognizedFS=FALSE;
       }
       if (*RecognizedFS &&
-	  Boot->BytesPerSector != 512 &&
-	  Boot->BytesPerSector != 1024 &&
+	       Boot->BytesPerSector != 512 &&
+	       Boot->BytesPerSector != 1024 &&
           Boot->BytesPerSector != 2048 && 
-	  Boot->BytesPerSector != 4096)
+	       Boot->BytesPerSector != 4096)
       {
          DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
          *RecognizedFS=FALSE;
@@ -172,7 +179,7 @@
 
       if (*RecognizedFS &&
           Boot->FATCount != 1 && 
-	  Boot->FATCount != 2)
+	       Boot->FATCount != 2)
       {
          DPRINT1("FATCount %d\n", Boot->FATCount);
          *RecognizedFS=FALSE;
@@ -180,28 +187,28 @@
 
       if (*RecognizedFS &&
           Boot->Media != 0xf0 && 
-	  Boot->Media != 0xf8 &&
-	  Boot->Media != 0xf9 &&
-	  Boot->Media != 0xfa && 
-	  Boot->Media != 0xfb &&
-	  Boot->Media != 0xfc &&
-	  Boot->Media != 0xfd &&
-	  Boot->Media != 0xfe && 
-	  Boot->Media != 0xff)
+          Boot->Media != 0xf8 &&
+          Boot->Media != 0xf9 &&
+          Boot->Media != 0xfa && 
+          Boot->Media != 0xfb &&
+          Boot->Media != 0xfc &&
+          Boot->Media != 0xfd &&
+          Boot->Media != 0xfe && 
+          Boot->Media != 0xff)
       {
          DPRINT1("Media             %02x\n", Boot->Media);
          *RecognizedFS=FALSE;
       }
 
       if (*RecognizedFS &&
-	  Boot->SectorsPerCluster != 1 &&
-	  Boot->SectorsPerCluster != 2 &&
+          Boot->SectorsPerCluster != 1 &&
+          Boot->SectorsPerCluster != 2 &&
           Boot->SectorsPerCluster != 4 && 
-	  Boot->SectorsPerCluster != 8 &&
+          Boot->SectorsPerCluster != 8 &&
           Boot->SectorsPerCluster != 16 &&
-	  Boot->SectorsPerCluster != 32 && 
+          Boot->SectorsPerCluster != 32 && 
           Boot->SectorsPerCluster != 64 &&
-	  Boot->SectorsPerCluster != 128)
+          Boot->SectorsPerCluster != 128)
       {
          DPRINT1("SectorsPerCluster %02x\n", Boot->SectorsPerCluster);
          *RecognizedFS=FALSE;
@@ -247,12 +254,12 @@
             DPRINT("FAT16\n");
             FatInfo.FatType = FAT16;
          }
-	 if (PartitionInfoIsValid &&
-	     FatInfo.Sectors > PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector)
-	 {
-	    CHECKPOINT1;
-	    *RecognizedFS = FALSE;
-	 }
+         if (PartitionInfoIsValid &&
+	         FatInfo.Sectors > PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector)
+         {
+	         CHECKPOINT1;
+            *RecognizedFS = FALSE;
+         }
 	    
          if (pFatInfo && *RecognizedFS)
          {
@@ -262,6 +269,81 @@
    }
 
    ExFreePool(Boot);
+   
+   if (!*RecognizedFS && PartitionInfoIsValid)
+   {
+      BootFatX = ExAllocatePool(NonPagedPool, sizeof(struct _BootSectorFatX));
+      if (BootFatX == NULL)
+      {
+         *RecognizedFS=FALSE;
+         return STATUS_INSUFFICIENT_RESOURCES;
+      }
+
+      Offset.QuadPart = 0;
+   
+      /* Try to recognize FATX16/FATX32 partitions (Xbox) */
+      Status = VfatReadDisk(DeviceToMount, &Offset, sizeof(struct _BootSectorFatX), (PUCHAR) BootFatX, FALSE);
+      if (NT_SUCCESS(Status))
+      {
+         *RecognizedFS = TRUE;
+         if (BootFatX->SysType[0] != 'F' ||
+             BootFatX->SysType[1] != 'A' ||
+             BootFatX->SysType[2] != 'T' ||
+             BootFatX->SysType[3] != 'X')
+         {
+            DPRINT1("SysType %c%c%c%c\n", BootFatX->SysType[0], BootFatX->SysType[1], BootFatX->SysType[2], BootFatX->SysType[3]);
+            *RecognizedFS=FALSE;
+         }
+         
+         if (*RecognizedFS &&
+            BootFatX->SectorsPerCluster != 1 &&
+            BootFatX->SectorsPerCluster != 2 &&
+            BootFatX->SectorsPerCluster != 4 && 
+            BootFatX->SectorsPerCluster != 8 &&
+            BootFatX->SectorsPerCluster != 16 &&
+            BootFatX->SectorsPerCluster != 32 && 
+            BootFatX->SectorsPerCluster != 64 &&
+            BootFatX->SectorsPerCluster != 128)
+         {
+            DPRINT1("SectorsPerCluster %lu\n", BootFatX->SectorsPerCluster);
+            *RecognizedFS=FALSE;
+         }
+         
+         if (*RecognizedFS)
+         {
+            FatInfo.BytesPerSector = DiskGeometry.BytesPerSector;
+            FatInfo.SectorsPerCluster = BootFatX->SectorsPerCluster;
+            FatInfo.rootDirectorySectors = BootFatX->SectorsPerCluster;
+            FatInfo.BytesPerCluster = BootFatX->SectorsPerCluster * DiskGeometry.BytesPerSector;
+            FatInfo.NumberOfClusters = PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerCluster;
+            if (FatInfo.NumberOfClusters < 65525)
+            {
+               DPRINT("FATX16\n");
+               FatInfo.FatType = FATX16;
+            }
+            else
+            {
+               DPRINT("FATX32\n");
+               FatInfo.FatType = FATX32;
+            }
+            FatInfo.VolumeID = BootFatX->VolumeID;
+            FatInfo.FATStart = sizeof(struct _BootSectorFatX) / DiskGeometry.BytesPerSector;
+            FatInfo.FATCount = BootFatX->FATCount;
+            FatInfo.FATSectors =
+                  ROUND_UP(FatInfo.NumberOfClusters * (FatInfo.FatType == FATX16 ? 2 : 4), 4096) /
+                  FatInfo.BytesPerSector;
+            FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors;
+            FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors;
+            FatInfo.Sectors = PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector;
+            if (pFatInfo && *RecognizedFS)
+            {
+               *pFatInfo = FatInfo;
+            }
+         }
+      }
+      ExFreePool(BootFatX);
+   }
+      
    DPRINT("VfatHasFileSystem done\n");
    return Status;
 }
@@ -357,31 +439,65 @@
       goto ByeBye;
    }
 
-#ifndef NDEBUG
-   DbgPrint("BytesPerSector:     %d\n", DeviceExt->FatInfo.BytesPerSector);
-   DbgPrint("SectorsPerCluster:  %d\n", DeviceExt->FatInfo.SectorsPerCluster);
-   DbgPrint("FATCount:           %d\n", DeviceExt->FatInfo.FATCount);
-   DbgPrint("FATSectors:         %d\n", DeviceExt->FatInfo.FATSectors);
-   DbgPrint("RootStart:          %d\n", DeviceExt->FatInfo.rootStart);
-   DbgPrint("DataStart:          %d\n", DeviceExt->FatInfo.dataStart);
+   DPRINT("BytesPerSector:     %d\n", DeviceExt->FatInfo.BytesPerSector);
+   DPRINT("SectorsPerCluster:  %d\n", DeviceExt->FatInfo.SectorsPerCluster);
+   DPRINT("FATCount:           %d\n", DeviceExt->FatInfo.FATCount);
+   DPRINT("FATSectors:         %d\n", DeviceExt->FatInfo.FATSectors);
+   DPRINT("RootStart:          %d\n", DeviceExt->FatInfo.rootStart);
+   DPRINT("DataStart:          %d\n", DeviceExt->FatInfo.dataStart);
    if (DeviceExt->FatInfo.FatType == FAT32)
    {
-      DbgPrint("RootCluster:        %d\n", DeviceExt->FatInfo.RootCluster);
+      DPRINT("RootCluster:        %d\n", DeviceExt->FatInfo.RootCluster);
    }
-#endif
 
-  DeviceExt->StorageDevice = DeviceToMount;
-  DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
-  DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
-  DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
-  DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
-  DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+   switch (DeviceExt->FatInfo.FatType)
+   {
+      case FAT12:
+         DeviceExt->GetNextCluster = FAT12GetNextCluster;
+         DeviceExt->FindAndMarkAvailableCluster = FAT12FindAndMarkAvailableCluster;
+         DeviceExt->WriteCluster = FAT12WriteCluster;
+         break;
 
-  DPRINT("FsDeviceObject %lx\n", DeviceObject);
+      case FAT16:
+      case FATX16:
+         DeviceExt->GetNextCluster = FAT16GetNextCluster;
+         DeviceExt->FindAndMarkAvailableCluster = FAT16FindAndMarkAvailableCluster;
+         DeviceExt->WriteCluster = FAT16WriteCluster;
+         break;
+
+      case FAT32:
+      case FATX32:
+         DeviceExt->GetNextCluster = FAT32GetNextCluster;
+         DeviceExt->FindAndMarkAvailableCluster = FAT32FindAndMarkAvailableCluster;
+         DeviceExt->WriteCluster = FAT32WriteCluster;
+         break;
+   }
+   
+   if (DeviceExt->FatInfo.FatType == FATX16
+      || DeviceExt->FatInfo.FatType == FATX32)
+   {
+      DeviceExt->Flags |= VCB_IS_FATX;
+      DeviceExt->GetNextDirEntry = FATXGetNextDirEntry;
+      DeviceExt->BaseDateYear = 2000;
+   }
+   else
+   {
+      DeviceExt->GetNextDirEntry = FATGetNextDirEntry;
+      DeviceExt->BaseDateYear = 1980;
+   }
+
+   DeviceExt->StorageDevice = DeviceToMount;
+   DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
+   DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
+   DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
+   DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
+   DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+
+   DPRINT("FsDeviceObject %lx\n", DeviceObject);
 
    DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
    RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\$$Fat$$");
-   Fcb = vfatNewFCB(&NameU);
+   Fcb = vfatNewFCB(DeviceExt, &NameU);
    if (Fcb == NULL)
    {
       Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -394,7 +510,7 @@
       goto ByeBye;
    }
 
-   memset(Ccb, 0, sizeof (VFATCCB));
+   RtlZeroMemory(Ccb, sizeof (VFATCCB));
    DeviceExt->FATFileObject->Flags = DeviceExt->FATFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
    DeviceExt->FATFileObject->FsContext = Fcb;
    DeviceExt->FATFileObject->FsContext2 = Ccb;
@@ -403,7 +519,7 @@
    DeviceExt->FATFileObject->Vpb = DeviceObject->Vpb;
    Fcb->FileObject = DeviceExt->FATFileObject;
 
-   Fcb->Flags = FCB_IS_FAT;
+   Fcb->Flags |= FCB_IS_FAT;
 
    Fcb->RFCB.FileSize.QuadPart = DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector;
    Fcb->RFCB.ValidDataLength = Fcb->RFCB.FileSize;
@@ -419,38 +535,17 @@
    }
    if (!NT_SUCCESS (Status))
    {
-      DbgPrint ("CcRosInitializeFileCache failed\n");
+      DPRINT1 ("CcRosInitializeFileCache failed\n");
       goto ByeBye;
    }
    DeviceExt->LastAvailableCluster = 2;
    ExInitializeResourceLite(&DeviceExt->DirResource);
    ExInitializeResourceLite(&DeviceExt->FatResource);
 
-   switch (DeviceExt->FatInfo.FatType)
-   {
-      case FAT12:
-         DeviceExt->GetNextCluster = FAT12GetNextCluster;
-         DeviceExt->FindAndMarkAvailableCluster = FAT12FindAndMarkAvailableCluster;
-         DeviceExt->WriteCluster = FAT12WriteCluster;
-         break;
-
-      case FAT16:
-         DeviceExt->GetNextCluster = FAT16GetNextCluster;
-         DeviceExt->FindAndMarkAvailableCluster = FAT16FindAndMarkAvailableCluster;
-         DeviceExt->WriteCluster = FAT16WriteCluster;
-         break;
-
-      case FAT32:
-         DeviceExt->GetNextCluster = FAT32GetNextCluster;
-         DeviceExt->FindAndMarkAvailableCluster = FAT32FindAndMarkAvailableCluster;
-         DeviceExt->WriteCluster = FAT32WriteCluster;
-         break;
-   }
-
    InitializeListHead(&DeviceExt->FcbListHead);
    RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\$$Volume$$");
 
-   VolumeFcb = vfatNewFCB(&NameU);
+   VolumeFcb = vfatNewFCB(DeviceExt, &NameU);
    if (VolumeFcb == NULL)
    {
       Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -471,7 +566,7 @@
 
    /* read volume label */
    ReadVolumeLabel(DeviceExt,  DeviceObject->Vpb);
-
+   
    Status = STATUS_SUCCESS;
 ByeBye:
 
@@ -737,4 +832,3 @@
    VfatFreeIrpContext(IrpContext);
    return (Status);
 }
-

reactos/drivers/fs/vfat
misc.c 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- misc.c	6 Nov 2004 13:44:57 -0000	1.14
+++ misc.c	8 Dec 2004 21:56:48 -0000	1.14.2.1
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.14 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: misc.c,v 1.14.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -41,7 +41,7 @@
       goto Fail;
    }
 
-   if (Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+   if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)
    {
       Status = STATUS_INVALID_PARAMETER;
       goto Fail;

reactos/drivers/fs/vfat
rw.c 1.71 -> 1.71.2.1
diff -u -r1.71 -r1.71.2.1
--- rw.c	6 Nov 2004 13:44:57 -0000	1.71
+++ rw.c	8 Dec 2004 21:56:48 -0000	1.71.2.1
@@ -1,5 +1,5 @@
 
-/* $Id: rw.c,v 1.71 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: rw.c,v 1.71.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -592,7 +592,7 @@
    BytesPerSector = IrpContext->DeviceExt->FatInfo.BytesPerSector;
 
    /* fail if file is a directory and no paged read */
-   if (Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY && !(IrpContext->Irp->Flags & IRP_PAGING_IO))
+   if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !(IrpContext->Irp->Flags & IRP_PAGING_IO))
    {
       Status = STATUS_INVALID_PARAMETER;
       goto ByeBye;
@@ -821,7 +821,7 @@
    }
 
   /* fail if file is a directory and no paged read */
-   if (Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY && !(IrpContext->Irp->Flags & IRP_PAGING_IO))
+   if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !(IrpContext->Irp->Flags & IRP_PAGING_IO))
    {
       Status = STATUS_INVALID_PARAMETER;
       goto ByeBye;
@@ -1020,14 +1020,26 @@
    if (!(IrpContext->Irp->Flags & IRP_PAGING_IO) &&
       !(Fcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
    {
-      if(!(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
+      if(!(*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
       {
          LARGE_INTEGER SystemTime;
          // set dates and times
          KeQuerySystemTime (&SystemTime);
-         FsdSystemTimeToDosDateTime (&SystemTime, &Fcb->entry.UpdateDate,
-                                     &Fcb->entry.UpdateTime);
-         Fcb->entry.AccessDate = Fcb->entry.UpdateDate;
+         if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+         {
+            FsdSystemTimeToDosDateTime (IrpContext->DeviceExt,
+                                     &SystemTime, &Fcb->entry.FatX.UpdateDate,
+                                     &Fcb->entry.FatX.UpdateTime);
+            Fcb->entry.FatX.AccessDate = Fcb->entry.FatX.UpdateDate;
+            Fcb->entry.FatX.AccessTime = Fcb->entry.FatX.UpdateTime;
+         }
+         else
+         {
+            FsdSystemTimeToDosDateTime (IrpContext->DeviceExt,
+                                     &SystemTime, &Fcb->entry.Fat.UpdateDate,
+                                     &Fcb->entry.Fat.UpdateTime);
+            Fcb->entry.Fat.AccessDate = Fcb->entry.Fat.UpdateDate;
+         }
          /* set date and times to dirty */
 	 Fcb->Flags |= FCB_IS_DIRTY;
       }

reactos/drivers/fs/vfat
shutdown.c 1.8 -> 1.8.34.1
diff -u -r1.8 -r1.8.34.1
--- shutdown.c	11 Oct 2003 17:51:56 -0000	1.8
+++ shutdown.c	8 Dec 2004 21:56:48 -0000	1.8.34.1
@@ -1,4 +1,4 @@
-/* $Id: shutdown.c,v 1.8 2003/10/11 17:51:56 hbirr Exp $
+/* $Id: shutdown.c,v 1.8.34.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -48,9 +48,9 @@
 	    Irp->IoStatus.Status = Status;
 	 }
          /* FIXME: Unmount the logical volume */
-
-	 ExReleaseResourceLite(&VfatGlobalData->VolumeListLock);
       }
+	 ExReleaseResourceLite(&VfatGlobalData->VolumeListLock);
+      
       /* FIXME: Free all global acquired resources */
 
       Status = Irp->IoStatus.Status;

reactos/drivers/fs/vfat
vfat.h 1.69 -> 1.69.2.1
diff -u -r1.69 -r1.69.2.1
--- vfat.h	6 Nov 2004 13:44:57 -0000	1.69
+++ vfat.h	8 Dec 2004 21:56:48 -0000	1.69.2.1
@@ -1,4 +1,4 @@
-/* $Id: vfat.h,v 1.69 2004/11/06 13:44:57 ekohl Exp $ */
+/* $Id: vfat.h,v 1.69.2.1 2004/12/08 21:56:48 hyperion Exp $ */
 
 #include <ddk/ntifs.h>
 
@@ -52,6 +52,16 @@
   unsigned short Signature1;				// 510
 } __attribute__((packed));
 
+struct _BootSectorFatX
+{
+   unsigned char SysType[4];        // 0
+   unsigned long VolumeID;          // 4
+   unsigned long SectorsPerCluster; // 8
+   unsigned short FATCount;         // 12
+   unsigned long Unknown;           // 14
+   unsigned char Unused[4078];      // 18
+} __attribute__((packed));
+
 struct _FsInfoSector
 {
   unsigned long  ExtBootSignature2;			// 0
@@ -68,10 +78,22 @@
 #define VFAT_CASE_LOWER_BASE	8			// base is lower case
 #define VFAT_CASE_LOWER_EXT	16			// extension is lower case
 
-#define ENTRY_DELETED(DirEntry)	((DirEntry)->Filename[0] == 0xe5)
-#define ENTRY_END(DirEntry)	((DirEntry)->Filename[0] == 0)
-#define ENTRY_LONG(DirEntry)	(((DirEntry)->Attrib & 0x3f) == 0x0f)
-#define ENTRY_VOLUME(DirEntry)	(((DirEntry)->Attrib & 0x1f) == 0x08)
+#define ENTRY_DELETED(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
+#define ENTRY_VOLUME(DeviceExt, DirEntry)  ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
+#define ENTRY_END(DeviceExt, DirEntry)     ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
+
+#define FAT_ENTRY_DELETED(DirEntry)  ((DirEntry)->Filename[0] == 0xe5)
+#define FAT_ENTRY_END(DirEntry)      ((DirEntry)->Filename[0] == 0)
+#define FAT_ENTRY_LONG(DirEntry)     (((DirEntry)->Attrib & 0x3f) == 0x0f)
+#define FAT_ENTRY_VOLUME(DirEntry)   (((DirEntry)->Attrib & 0x1f) == 0x08)
+
+#define FATX_ENTRY_DELETED(DirEntry) ((DirEntry)->FilenameLength == 0xe5)
+#define FATX_ENTRY_END(DirEntry)     ((DirEntry)->FilenameLength == 0xff)
+#define FATX_ENTRY_LONG(DirEntry)    (FALSE)
+#define FATX_ENTRY_VOLUME(DirEntry)  (((DirEntry)->Attrib & 0x1f) == 0x08)
+
+#define FAT_ENTRIES_PER_PAGE   (PAGE_SIZE / sizeof (FAT_DIR_ENTRY))
+#define FATX_ENTRIES_PER_PAGE  (PAGE_SIZE / sizeof (FATX_DIR_ENTRY))
 
 struct _FATDirEntry
 {
@@ -87,7 +109,32 @@
   unsigned long  FileSize;
 } __attribute__((packed));
 
-typedef struct _FATDirEntry FATDirEntry, FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
+typedef struct _FATDirEntry FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
+
+struct _FATXDirEntry
+{
+   unsigned char FilenameLength; // 0
+   unsigned char Attrib;         // 1
+   unsigned char Filename[42];   // 2
+   unsigned long FirstCluster;   // 44
+   unsigned long FileSize;       // 48
+   unsigned short UpdateTime;    // 52
+   unsigned short UpdateDate;    // 54
+   unsigned short CreationTime;  // 56
+   unsigned short CreationDate;  // 58
+   unsigned short AccessTime;    // 60
+   unsigned short AccessDate;    // 62
+} __attribute__((packed));
+
+typedef struct _FATXDirEntry FATX_DIR_ENTRY, *PFATX_DIR_ENTRY;
+
+union _DIR_ENTRY
+{
+   FAT_DIR_ENTRY Fat;
+   FATX_DIR_ENTRY FatX;
+};
+
+typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
 
 struct _slot
 {
@@ -106,12 +153,15 @@
 
 #define BLOCKSIZE 512
 
-#define FAT16 (1)
-#define FAT12 (2)
-#define FAT32 (3)
+#define FAT16  (1)
+#define FAT12  (2)
+#define FAT32  (3)
+#define FATX16 (4)
+#define FATX32 (5)
 
 #define VCB_VOLUME_LOCKED       0x0001
 #define VCB_DISMOUNT_PENDING    0x0002
+#define VCB_IS_FATX             0x0004
 
 typedef struct
 {
@@ -133,6 +183,7 @@
 } FATINFO, *PFATINFO;
 
 struct _VFATFCB;
+struct _VFAT_DIRENTRY_CONTEXT;
 
 typedef struct _HASHENTRY
 {
@@ -150,6 +201,8 @@
 typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
 typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
 
+typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
+
 typedef struct DEVICE_EXTENSION
 {
   ERESOURCE DirResource;
@@ -172,6 +225,11 @@
   PGET_NEXT_CLUSTER GetNextCluster;
   PFIND_AND_MARK_AVAILABLE_CLUSTER FindAndMarkAvailableCluster;
   PWRITE_CLUSTER WriteCluster;
+  
+  /* Pointers to functions for manipulating directory entries. */
+  PGET_NEXT_DIR_ENTRY GetNextDirEntry;
+  
+  ULONG BaseDateYear;
 
   LIST_ENTRY VolumeListEntry;
 } DEVICE_EXTENSION, VCB, *PVCB;
@@ -195,7 +253,8 @@
 #define FCB_IS_FAT              0x0004
 #define FCB_IS_PAGE_FILE        0x0008
 #define FCB_IS_VOLUME           0x0010
-#define FCB_IS_DIRTY		0x0020
+#define FCB_IS_DIRTY            0x0020
+#define FCB_IS_FATX_ENTRY       0x0040
 
 typedef struct _VFATFCB
 {
@@ -207,7 +266,10 @@
   /* end FCB header required by ROS/NT */
 
   /* directory entry for this file or directory */
-  FATDirEntry entry;
+  DIR_ENTRY entry;
+  
+  /* Pointer to attributes in entry */
+  PUCHAR Attributes;
 
   /* long file name, points into PathNameBuffer */
   UNICODE_STRING LongNameU;
@@ -330,7 +392,7 @@
 {
   ULONG StartIndex;
   ULONG DirIndex;
-  FAT_DIR_ENTRY FatDirEntry;
+  DIR_ENTRY DirEntry;
   UNICODE_STRING LongNameU;
   UNICODE_STRING ShortNameU;
 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
@@ -379,11 +441,13 @@
 
 NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT);
 
-BOOL FsdDosDateTimeToSystemTime (WORD wDosDate,
+BOOL FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt,
+                                 WORD wDosDate,
                                  WORD wDosTime,
                                  PLARGE_INTEGER SystemTime);
 
-BOOL FsdSystemTimeToDosDateTime (PLARGE_INTEGER SystemTime,
+BOOL FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt,
+                                 PLARGE_INTEGER SystemTime,
                                  WORD *pwDosDate,
                                  WORD *pwDosTime);
 
@@ -451,6 +515,12 @@
 
 NTSTATUS VfatDelEntry(PDEVICE_EXTENSION, PVFATFCB);
 
+BOOLEAN
+vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
+                 PVFATFCB pDirFcb,
+                 ULONG nbSlots,
+                 PULONG start);
+
 /*  --------------------------------------------------------  string.c  */
 
 VOID
@@ -529,11 +599,17 @@
 /*  ------------------------------------------------------  direntry.c  */
 
 ULONG  vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION  pDeviceExt,
-                                    PFAT_DIR_ENTRY  pDirEntry);
+                                    PDIR_ENTRY  pDirEntry);
 
 BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb);
 
-NTSTATUS vfatGetNextDirEntry(PVOID * pContext,
+NTSTATUS FATGetNextDirEntry(PVOID * pContext,
+			     PVOID * pPage,
+			     IN PVFATFCB pDirFcb,
+			     IN PVFAT_DIRENTRY_CONTEXT DirContext,
+			     BOOLEAN First);
+
+NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
 			     PVOID * pPage,
 			     IN PVFATFCB pDirFcb,
 			     IN PVFAT_DIRENTRY_CONTEXT DirContext,
@@ -541,7 +617,8 @@
 
 /*  -----------------------------------------------------------  fcb.c  */
 
-PVFATFCB vfatNewFCB (PUNICODE_STRING pFileNameU);
+PVFATFCB vfatNewFCB (PDEVICE_EXTENSION  pVCB,
+                        PUNICODE_STRING pFileNameU);
 
 VOID vfatDestroyFCB (PVFATFCB  pFCB);
 

reactos/drivers/fs/vfat
volume.c 1.27 -> 1.27.2.1
diff -u -r1.27 -r1.27.2.1
--- volume.c	6 Nov 2004 13:44:57 -0000	1.27
+++ volume.c	8 Dec 2004 21:56:48 -0000	1.27.2.1
@@ -1,4 +1,4 @@
-/* $Id: volume.c,v 1.27 2004/11/06 13:44:57 ekohl Exp $
+/* $Id: volume.c,v 1.27.2.1 2004/12/08 21:56:48 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -6,6 +6,7 @@
  * PURPOSE:          VFAT Filesystem
  * PROGRAMMER:       Jason Filby (jasonfilby@yahoo.com)
  *                   Hartmut Birr
+ *                   Herve Poussineau (reactos@poussine.freesurf.fr)
  */
 
 /* INCLUDES *****************************************************************/
@@ -42,7 +43,7 @@
   /* valid entries */
   FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
   FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
-  memcpy(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel, FsVolumeInfo->VolumeLabelLength);
+  RtlCopyMemory(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel, FsVolumeInfo->VolumeLabelLength);
 
   /* dummy entries */
   FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
@@ -94,7 +95,7 @@
 
   FsAttributeInfo->FileSystemNameLength = Length;
 
-  memcpy(FsAttributeInfo->FileSystemName, pName, Length );
+  RtlCopyMemory(FsAttributeInfo->FileSystemName, pName, Length );
 
   DPRINT("Finished FsdGetFsAttributeInformation()\n");
 
@@ -162,9 +163,140 @@
 FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
 			 PFILE_FS_LABEL_INFORMATION FsLabelInfo)
 {
+  PDEVICE_EXTENSION DeviceExt;
+  PVOID Context = NULL;
+  ULONG DirIndex = 0;
+  PDIR_ENTRY Entry;
+  PVFATFCB pRootFcb;
+  LARGE_INTEGER FileOffset;
+  BOOL LabelFound = FALSE;
+  DIR_ENTRY VolumeLabelDirEntry;
+  ULONG VolumeLabelDirIndex;
+  ULONG LabelLen;
+  NTSTATUS Status = STATUS_UNSUCCESSFUL;
+  OEM_STRING StringO;
+  UNICODE_STRING StringW;
+  CHAR cString[43];
+  ULONG SizeDirEntry;
+  ULONG EntriesPerPage;
+  
   DPRINT("FsdSetFsLabelInformation()\n");
-
-  return(STATUS_NOT_IMPLEMENTED);
+  
+  DeviceExt = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
+  
+  if (sizeof(DeviceObject->Vpb->VolumeLabel) < FsLabelInfo->VolumeLabelLength)
+  {
+    CHECKPOINT;
+    return STATUS_NAME_TOO_LONG;
+  }
+  
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    if (FsLabelInfo->VolumeLabelLength / sizeof(WCHAR) > 42)
+      return STATUS_NAME_TOO_LONG;
+    SizeDirEntry = sizeof(FATX_DIR_ENTRY);
+    EntriesPerPage = FATX_ENTRIES_PER_PAGE;
+  }
+  else
+  {
+    if (FsLabelInfo->VolumeLabelLength / sizeof(WCHAR) > 11)
+      return STATUS_NAME_TOO_LONG;
+    SizeDirEntry = sizeof(FAT_DIR_ENTRY);
+    EntriesPerPage = FAT_ENTRIES_PER_PAGE;
+  }
+  
+  /* Create Volume label dir entry */
+  LabelLen = FsLabelInfo->VolumeLabelLength / sizeof(WCHAR);
+  RtlZeroMemory(&VolumeLabelDirEntry, SizeDirEntry);
+  StringW.Buffer = FsLabelInfo->VolumeLabel;
+  StringW.Length = StringW.MaximumLength = FsLabelInfo->VolumeLabelLength;
+  StringO.Buffer = cString;
+  StringO.Length = 0;
+  StringO.MaximumLength = 42;
+  Status = RtlUnicodeStringToOemString(&StringO, &StringW, FALSE);
+  if (!NT_SUCCESS(Status))
+    return Status;
+  if (DeviceExt->Flags & VCB_IS_FATX)
+  {
+    RtlCopyMemory(VolumeLabelDirEntry.FatX.Filename, cString, LabelLen);
+    memset(&VolumeLabelDirEntry.FatX.Filename[LabelLen], ' ', 42 - LabelLen);
+    VolumeLabelDirEntry.FatX.Attrib = 0x08;
+  }
+  else
+  {
+    RtlCopyMemory(VolumeLabelDirEntry.Fat.Filename, cString, LabelLen);
+    memset(&VolumeLabelDirEntry.Fat.Filename[LabelLen], ' ', 11 - LabelLen);
+    VolumeLabelDirEntry.Fat.Attrib = 0x08;
+  }
+  
+  pRootFcb = vfatOpenRootFCB(DeviceExt);
+   
+  /* Search existing volume entry on disk */
+  FileOffset.QuadPart = 0;
+  if (CcMapData(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
+  {
+    while (TRUE)
+    {
+      if (ENTRY_VOLUME(DeviceExt, Entry))
+      {
+        /* Update entry */
+        LabelFound = TRUE;
+        RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
+        CcSetDirtyPinnedData(Context, NULL);
+        Status = STATUS_SUCCESS;
+        break;
+      }
+      if (ENTRY_END(DeviceExt, Entry))
+      {
+        break;
+      }
+      DirIndex++;
+      Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry);
+      if ((DirIndex % EntriesPerPage) == 0)
+      {
+	     CcUnpinData(Context);
+	     FileOffset.u.LowPart += PAGE_SIZE;
+	     if (!CcMapData(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
+	     {
+	       Context = NULL;
+	       break;
+	     }
+      }
+    }
+    if (Context)
+    {
+      CcUnpinData(Context);
+    }
+  }
+  if (!LabelFound)
+  {
+    /* Add new entry for label */
+    if (!vfatFindDirSpace(DeviceExt, pRootFcb, 1, &VolumeLabelDirIndex))
+      Status = STATUS_DISK_FULL;
+    else
+    {
+      FileOffset.u.HighPart = 0;
+      FileOffset.u.LowPart = VolumeLabelDirIndex * SizeDirEntry;
+      CcMapData(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
+                 TRUE, &Context, (PVOID*)&Entry);
+      RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
+      CcSetDirtyPinnedData(Context, NULL);
+      CcUnpinData(Context);
+      Status = STATUS_SUCCESS;
+    }
+  }
+  
+  vfatReleaseFCB(DeviceExt, pRootFcb);
+  if (!NT_SUCCESS(Status))
+  {
+    return Status;
+  }
+  
+  /* Update volume label in memory */
+  DeviceObject->Vpb->VolumeLabelLength = FsLabelInfo->VolumeLabelLength;
+  RtlCopyMemory(DeviceObject->Vpb->VolumeLabel, FsLabelInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabelLength);
+  
+  return Status;
 }
 
 
@@ -255,7 +387,7 @@
   /* PRECONDITION */
   ASSERT(IrpContext);
 
-  DPRINT1("VfatSetVolumeInformation(IrpContext %x)\n", IrpContext);
+  DPRINT ("VfatSetVolumeInformation(IrpContext %x)\n", IrpContext);
 
   if (!ExAcquireResourceExclusiveLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
                                       (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
@@ -267,9 +399,9 @@
   BufferLength = Stack->Parameters.SetVolume.Length;
   SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
 
-  DPRINT1("FsInformationClass %d\n", FsInformationClass);
-  DPRINT1("BufferLength %d\n", BufferLength);
-  DPRINT1("SystemBuffer %x\n", SystemBuffer);
+  DPRINT ("FsInformationClass %d\n", FsInformationClass);
+  DPRINT ("BufferLength %d\n", BufferLength);
+  DPRINT ("SystemBuffer %x\n", SystemBuffer);
 
   switch(FsInformationClass)
     {

reactos/drivers/lib/csq
MAKEFILE 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- MAKEFILE	8 Feb 2004 17:51:32 -0000	1.1
+++ MAKEFILE	8 Dec 2004 21:56:49 -0000	1.1.22.1
@@ -1,7 +1,7 @@
-#
-# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
-# file to this component.  This file merely indirects to the real make file
-# that is shared by all the driver components of the Windows NT DDK
-#
-
-!INCLUDE $(NTMAKEENV)\makefile.def
+#
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
+# file to this component.  This file merely indirects to the real make file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE $(NTMAKEENV)\makefile.def

reactos/drivers/lib/ip
makefile 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- makefile	14 Nov 2004 21:28:21 -0000	1.7
+++ makefile	8 Dec 2004 21:56:49 -0000	1.7.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.7 2004/11/14 21:28:21 arty Exp $
+# $Id: makefile,v 1.7.2.1 2004/12/08 21:56:49 hyperion Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -12,6 +12,8 @@
 TARGET_CFLAGS = \
 	-D__USE_W32API \
 	-DMEMTRACK \
+	-D__NTDRIVER__ \
+	-D_SEH_NO_NATIVE_NLG \
 	-Wall -Werror \
 	-Iinclude \
 	-I../../net/tcpip/include \
@@ -33,9 +35,7 @@
 	network/memtrack.o \
 	network/neighbor.o \
 	network/ports.o \
-	network/prefix.o \
 	network/receive.o \
-	network/route.o \
 	network/router.o \
 	network/routines.o \
 	network/transmit.o \

reactos/drivers/lib/ip/network
address.c 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- address.c	15 Nov 2004 18:24:57 -0000	1.6
+++ address.c	8 Dec 2004 21:56:49 -0000	1.6.2.1
@@ -83,6 +83,18 @@
     }
 }
 
+VOID AddrWidenAddress( PIP_ADDRESS Network, PIP_ADDRESS Source, 
+		       PIP_ADDRESS Netmask ) {
+    if( Netmask->Type == IP_ADDRESS_V4 ) {
+	Network->Address.IPv4Address = 
+	    Source->Address.IPv4Address & Netmask->Address.IPv4Address;
+    } else {
+	TI_DbgPrint(DEBUG_DATALINK, ("Don't know address type %d\n", 
+				     Netmask->Type));
+	*Network = *Source;
+    }    
+}
+
 VOID IPAddressFree(
     PVOID Object)
 /*
@@ -169,12 +181,11 @@
  */
 NTSTATUS AddrBuildAddress(
     PTRANSPORT_ADDRESS TaAddress,
-    PIP_ADDRESS *Address,
+    PIP_ADDRESS Address,
     PUSHORT Port)
 {
   PTDI_ADDRESS_IP ValidAddr;
   PTA_ADDRESS TdiAddress = &TaAddress->Address[0];
-  PIP_ADDRESS IPAddress;
 
   if (TdiAddress->AddressType != TDI_ADDRESS_TYPE_IP) {
       TI_DbgPrint
@@ -191,18 +202,12 @@
 
   ValidAddr = (PTDI_ADDRESS_IP)TdiAddress->Address;
 
-  IPAddress = PoolAllocateBuffer(sizeof(IP_ADDRESS));
-  if (!IPAddress)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  AddrInitIPv4(IPAddress, ValidAddr->in_addr);
-  *Address = IPAddress;
+  AddrInitIPv4(Address, ValidAddr->in_addr);
   *Port = ValidAddr->sin_port;
 
   return STATUS_SUCCESS;
 }
 
-
 /*
  * FUNCTION: Returns wether two addresses are equal
  * ARGUMENTS:
@@ -291,72 +296,6 @@
 }
 
 
-/*
- * FUNCTION: Build an IPv4 style address
- * ARGUMENTS:
- *     Address = Raw IPv4 address (network byte order)
- * RETURNS:
- *     Pointer to IP address structure, NULL if there was not enough free
- *     non-paged memory
- */
-PIP_ADDRESS AddrBuildIPv4(
-    IPv4_RAW_ADDRESS Address)
-{
-    PIP_ADDRESS IPAddress;
-
-    IPAddress = PoolAllocateBuffer(sizeof(IP_ADDRESS));
-    if (IPAddress != NULL) {
-        IPAddress->Type                = IP_ADDRESS_V4;
-        IPAddress->Address.IPv4Address = Address;
-    }
-
-    return IPAddress;
-}
-
-
-/*
- * FUNCTION: Clone an IP address
- * ARGUMENTS:
- *     IPAddress = Pointer to IP address
- * RETURNS:
- *     Pointer to new IP address structure, NULL if there was not enough free
- *     non-paged memory
- */
-PIP_ADDRESS AddrCloneAddress(
-  PIP_ADDRESS Address)
-{
-  if (Address->Type == IP_ADDRESS_V4)
-    {
-      return AddrBuildIPv4(Address->Address.IPv4Address);
-    }
-  else
-    {
-      TI_DbgPrint(MIN_TRACE, ("Cannot clone IPv6 address.\n"));
-      return NULL;
-    }
-}
-
-
-/*
- * FUNCTION: Locates and returns an address entry using IPv4 adress as argument
- * ARGUMENTS:
- *     Address = Raw IPv4 address
- * RETURNS:
- *     Pointer to address entry if found, NULL if not found
- * NOTES:
- *     Only unicast addresses are considered.
- *     If found, the address is referenced
- */
-PADDRESS_ENTRY AddrLocateADEv4(
-    IPv4_RAW_ADDRESS Address)
-{
-    IP_ADDRESS Addr;
-
-    AddrInitIPv4(&Addr, Address);
-
-    return IPLocateADE(&Addr, ADE_UNICAST);
-}
-
 unsigned long PASCAL inet_addr(const char *AddrString)
 /*
  * Convert an ansi string dotted-quad address to a ulong

reactos/drivers/lib/ip/network
arp.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- arp.c	16 Nov 2004 18:07:56 -0000	1.4
+++ arp.c	8 Dec 2004 21:56:49 -0000	1.4.2.1
@@ -108,27 +108,21 @@
 }
 
 
-BOOLEAN ARPTransmit(
-    PIP_ADDRESS Address,
-    PNET_TABLE_ENTRY NTE)
+BOOLEAN ARPTransmit(PIP_ADDRESS Address, PIP_INTERFACE Interface)
 /*
  * FUNCTION: Creates an ARP request and transmits it on a network
  * ARGUMENTS:
  *     Address = Pointer to IP address to resolve
- *     NTE     = Pointer to net table entru to use for transmitting request
  * RETURNS:
  *     TRUE if the request was successfully sent, FALSE if not
  */
 {
-    PIP_INTERFACE Interface;
     PNDIS_PACKET NdisPacket;
     UCHAR ProtoAddrLen;
     USHORT ProtoType;
 
     TI_DbgPrint(DEBUG_ARP, ("Called.\n"));
 
-    Interface = NTE->Interface;
-
     switch (Address->Type) {
         case IP_ADDRESS_V4:
             ProtoType    = (USHORT)ETYPE_IPv4; /* IPv4 */
@@ -151,7 +145,7 @@
         (UCHAR)Interface->AddressLength, /* Hardware address length */
         (UCHAR)ProtoAddrLen,             /* Protocol address length */
         Interface->Address,              /* Sender's (local) hardware address */
-        &NTE->Address->Address,          /* Sender's (local) protocol address */
+        &Interface->Unicast.Address.IPv4Address,/* Sender's (local) protocol address */
         NULL,                            /* Don't care */
         &Address->Address,               /* Target's (remote) protocol address */
         ARP_OPCODE_REQUEST);             /* ARP request */
@@ -180,11 +174,10 @@
  */
 {
     PARP_HEADER Header;
-    PIP_ADDRESS Address;
+    IP_ADDRESS Address;
     PVOID SenderHWAddress;
     PVOID SenderProtoAddress;
     PVOID TargetProtoAddress;
-    PADDRESS_ENTRY ADE;
     PNEIGHBOR_CACHE_ENTRY NCE;
     PNDIS_PACKET NdisPacket;
     PIP_INTERFACE Interface = (PIP_INTERFACE)Context;
@@ -213,17 +206,16 @@
     TargetProtoAddress = (PVOID)((ULONG_PTR)SenderProtoAddress +
         Header->ProtoAddrLen + Header->HWAddrLen);
 
-    Address = AddrBuildIPv4(*((PULONG)TargetProtoAddress));
-    ADE = IPLocateADE(Address, ADE_UNICAST);
-    if (!ADE) {
+    if( !AddrLocateADEv4( *((PIPv4_RAW_ADDRESS)TargetProtoAddress), 
+			  &Address) ) {
         TI_DbgPrint(DEBUG_ARP, ("Target address (0x%X) is not mine.\n", *((PULONG)TargetProtoAddress)));
         return;
     }
 
     /* Check if we know the sender */
 
-    AddrInitIPv4(Address, *((PULONG)SenderProtoAddress));
-    NCE = NBLocateNeighbor(Address);
+    AddrInitIPv4(&Address, *((PULONG)SenderProtoAddress));
+    NCE = NBLocateNeighbor(&Address);
     if (NCE) {
         /* We know the sender. Update the hardware address 
            and state in our neighbor address cache */
@@ -232,13 +224,13 @@
         /* The packet had our protocol address as target. The sender
            may want to communicate with us soon, so add his address
            to our address cache */
-        NCE = NBAddNeighbor(Interface, Address, SenderHWAddress,
+        NCE = NBAddNeighbor(Interface, &Address, SenderHWAddress,
             Header->HWAddrLen, NUD_REACHABLE);
     }
 
     if (Header->Opcode != ARP_OPCODE_REQUEST)
         return;
-    
+
     /* This is a request for our address. Swap the addresses and
        send an ARP reply back to the sender */
     NdisPacket = PrepareARPPacket(
@@ -247,7 +239,7 @@
         (UCHAR)Interface->AddressLength, /* Hardware address length */
         (UCHAR)Header->ProtoAddrLen,     /* Protocol address length */
         Interface->Address,              /* Sender's (local) hardware address */
-        &ADE->Address.Address,           /* Sender's (local) protocol address */
+        &Interface->Unicast.Address.IPv4Address,/* Sender's (local) protocol address */
         SenderHWAddress,                 /* Target's (remote) hardware address */
         SenderProtoAddress,              /* Target's (remote) protocol address */
         ARP_OPCODE_REPLY);               /* ARP reply */

reactos/drivers/lib/ip/network
icmp.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- icmp.c	7 Nov 2004 20:37:20 -0000	1.3
+++ icmp.c	8 Dec 2004 21:56:49 -0000	1.3.2.1
@@ -35,7 +35,7 @@
 
 
 PIP_PACKET PrepareICMPPacket(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket,
     PIP_ADDRESS Destination,
     PCHAR Data,
@@ -107,7 +107,7 @@
     /* Checksum is 0 (for later calculation of this) */
     IPHeader->Checksum = 0;
     /* Source address */
-    IPHeader->SrcAddr = NTE->Address->Address.IPv4Address;
+    IPHeader->SrcAddr = Interface->Unicast.Address.IPv4Address;
     /* Destination address */
     IPHeader->DstAddr = Destination->Address.IPv4Address;
 
@@ -119,7 +119,7 @@
 
 
 VOID ICMPReceive(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket)
 /*
  * FUNCTION: Receives an ICMP packet
@@ -153,7 +153,7 @@
 
     switch (ICMPHeader->Type) {
     case ICMP_TYPE_ECHO_REQUEST:
-	ICMPReply( NTE, IPPacket, ICMP_TYPE_ECHO_REPLY, 0 );
+	ICMPReply( Interface, IPPacket, ICMP_TYPE_ECHO_REPLY, 0 );
         return;
 
     case ICMP_TYPE_ECHO_REPLY:
@@ -170,7 +170,6 @@
 
 
 VOID ICMPTransmit(
-    PNET_TABLE_ENTRY NTE,
     PIP_PACKET IPPacket,
     PIP_TRANSMIT_COMPLETE Complete,
     PVOID Context)
@@ -181,7 +180,7 @@
  *     IPPacket = Pointer to IP packet to transmit
  */
 {
-    PROUTE_CACHE_NODE RCN;
+    PNEIGHBOR_CACHE_ENTRY NCE;
 
     TI_DbgPrint(DEBUG_ICMP, ("Called.\n"));
 
@@ -190,15 +189,13 @@
         IPv4Checksum(IPPacket->Data, IPPacket->TotalSize - IPPacket->HeaderSize, 0);
 
     /* Get a route to the destination address */
-    if (RouteGetRouteToDestination(&IPPacket->DstAddr, NULL, &RCN) == IP_SUCCESS) {
+    if ((NCE = RouteGetRouteToDestination(&IPPacket->DstAddr))) {
         /* Send the packet */
-	IPSendDatagram(IPPacket, RCN, Complete, Context);
+	IPSendDatagram(IPPacket, NCE, Complete, Context);
     } else {
-        TI_DbgPrint(MIN_TRACE, ("RCN at (0x%X).\n", RCN));
-
         /* No route to destination (or no free resources) */
         TI_DbgPrint(DEBUG_ICMP, ("No route to destination address 0x%X.\n",
-            IPPacket->DstAddr.Address.IPv4Address));
+				 IPPacket->DstAddr.Address.IPv4Address));
         /* Discard packet */
 	Complete( Context, IPPacket->NdisPacket, NDIS_STATUS_NOT_ACCEPTED );
     }
@@ -206,7 +203,7 @@
 
 
 VOID ICMPReply(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket,
     UCHAR Type,
     UCHAR Code)
@@ -236,14 +233,14 @@
         DataSize = PayloadSize + sizeof(ICMP_HEADER);
     }
     
-    if( !PrepareICMPPacket(NTE, &NewPacket, &IPPacket->SrcAddr, 
+    if( !PrepareICMPPacket(Interface, &NewPacket, &IPPacket->SrcAddr, 
 			   IPPacket->Data, DataSize) ) return;
 
     ((PICMP_HEADER)NewPacket.Data)->Type     = Type;
     ((PICMP_HEADER)NewPacket.Data)->Code     = Code;
     ((PICMP_HEADER)NewPacket.Data)->Checksum = 0;
 
-    ICMPTransmit(NTE, &NewPacket, SendICMPComplete, NULL);
+    ICMPTransmit(&NewPacket, SendICMPComplete, NULL);
 }
 
 /* EOF */

reactos/drivers/lib/ip/network
interface.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- interface.c	9 Nov 2004 09:39:37 -0000	1.3
+++ interface.c	8 Dec 2004 21:56:49 -0000	1.3.2.1
@@ -11,20 +11,33 @@
 
 #include "precomp.h"
 
-
 NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface, 
 				  ULONG TargetType,
 				  PULONG Address ) {
-    ADE_LIST_ITER(CurrentADE);
+    switch( TargetType ) {
+    case ADE_UNICAST:
+	*Address = Interface->Unicast.Address.IPv4Address;
+	break;
+
+    case ADE_ADDRMASK:
+	*Address = Interface->Netmask.Address.IPv4Address;
+	break;
+
+    case ADE_BROADCAST:
+	*Address = 
+	    Interface->Unicast.Address.IPv4Address | 
+	    ~Interface->Netmask.Address.IPv4Address;
+	break;
+
+    case ADE_POINTOPOINT:
+	*Address = Interface->PointToPoint.Address.IPv4Address;
+	break;
+
+    default:
+	return STATUS_UNSUCCESSFUL;
+    }
 
-    ForEachADE(Interface->ADEListHead,CurrentADE) {
-	if (CurrentADE->Type == TargetType) {
-	    *Address = CurrentADE->Address.Address.IPv4Address;
-	    return STATUS_SUCCESS;
-	}
-    } EndFor(CurrentADE);
-    
-    return STATUS_UNSUCCESSFUL;
+    return STATUS_SUCCESS;
 }
 
 UINT CountInterfaces() {
@@ -43,18 +56,6 @@
     return Count;
 }
 
-UINT CountInterfaceAddresses( PIP_INTERFACE Interface ) {
-    UINT AddrCount = 0;
-    ADE_LIST_ITER(CurrentADE);
-
-    ForEachADE(Interface->ADEListHead,CurrentADE) {
-	if( CurrentADE->Type == ADE_UNICAST )
-	    AddrCount++;
-    } EndFor(CurrentADE);
-
-    return AddrCount;
-}
-
 NTSTATUS GetInterfaceSpeed( PIP_INTERFACE Interface, PUINT Speed ) {
     NDIS_STATUS NdisStatus;
     PLAN_ADAPTER IF = (PLAN_ADAPTER)Interface->Context;
@@ -80,23 +81,147 @@
 NTSTATUS GetInterfaceName( PIP_INTERFACE Interface, 
 			   PCHAR NameBuffer,
 			   UINT Len ) {
-    NDIS_STATUS NdisStatus;
-    PLAN_ADAPTER IF = (PLAN_ADAPTER)Interface->Context;
+    ULONG ResultSize = 0;
+    NTSTATUS Status = 
+	RtlUnicodeToMultiByteN( NameBuffer, 
+				Len, 
+				&ResultSize, 
+				Interface->Name.Buffer,
+				Interface->Name.Length );
+    
+    if( NT_SUCCESS(Status) ) 
+	NameBuffer[ResultSize] = 0;
+    else
+	NameBuffer[0] = 0;
+
+    return Status;
+}
+
+/*
+ * FUNCTION: Locates and returns an address entry using IPv4 adress as argument
+ * ARGUMENTS:
+ *     Address = Raw IPv4 address
+ * RETURNS:
+ *     Pointer to address entry if found, NULL if not found
+ * NOTES:
+ *     Only unicast addresses are considered.
+ *     If found, the address is referenced
+ */
+BOOLEAN AddrLocateADEv4(
+    IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address)
+{
+    KIRQL OldIrql;
+    BOOLEAN Matched = FALSE;
+    IF_LIST_ITER(CurrentIF);
+
+    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
     
-#ifdef __NTDRIVER__
-    /* Get maximum link speed */
-    NdisStatus = NDISCall(IF,
-                          NdisRequestQueryInformation,
-                          OID_GEN_FRIENDLY_NAME,
-                          NameBuffer,
-			  Len);
-#else
-    (void)IF;
-    NdisStatus = NDIS_STATUS_SUCCESS;
-    strncpy( NameBuffer, "eth", Len );
+    ForEachInterface(CurrentIF) {
+	if( AddrIsEqualIPv4( &CurrentIF->Unicast, MatchAddress ) ) {
+	    Address->Address.IPv4Address = MatchAddress;
+	    Matched = TRUE; break;
+	}
+    } EndFor(CurrentIF);
+
+    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+
+    return Matched;
+}
+
+BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address ) {
+    KIRQL OldIrql;
+    BOOLEAN Matched = FALSE;
+    IF_LIST_ITER(CurrentIF);
+
+    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
+
+    /* Find the first 'real' interface */
+    ForEachInterface(CurrentIF) {
+	if( CurrentIF->Context ) {
+	    *Address = CurrentIF->Unicast;
+	    Matched = TRUE; break;
+	}
+    } EndFor(CurrentIF);
+
+    /* Not matched, use the first one */
+    if( !Matched ) {
+	ForEachInterface(CurrentIF) {
+	    *Address = CurrentIF->Unicast;
+	    Matched = TRUE; break;
+	} EndFor(CurrentIF);
+    }
+
+    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+
+    return Matched;
+}
+
+BOOLEAN HasPrefix(
+    PIP_ADDRESS Address,
+    PIP_ADDRESS Prefix,
+    UINT Length)
+/*
+ * FUNCTION: Determines wether an address has an given prefix
+ * ARGUMENTS:
+ *     Address = Pointer to address to use
+ *     Prefix  = Pointer to prefix to check for
+ *     Length  = Length of prefix
+ * RETURNS:
+ *     TRUE if the address has the prefix, FALSE if not
+ * NOTES:
+ *     The two addresses must be of the same type
+ */
+{
+    PUCHAR pAddress = (PUCHAR)&Address->Address;
+    PUCHAR pPrefix  = (PUCHAR)&Prefix->Address;
+
+    TI_DbgPrint(DEBUG_ROUTER, ("Called. Address (0x%X)  Prefix (0x%X)  Length (%d).\n", Address, Prefix, Length));
+
+#if 0
+    TI_DbgPrint(DEBUG_ROUTER, ("Address (%s)  Prefix (%s).\n",
+        A2S(Address), A2S(Prefix)));
 #endif
-    
-    return 
-	NdisStatus != NDIS_STATUS_SUCCESS ? 
-	STATUS_UNSUCCESSFUL : STATUS_SUCCESS;
+
+    /* Check that initial integral bytes match */
+    while (Length > 8) {
+        if (*pAddress++ != *pPrefix++)
+            return FALSE;
+        Length -= 8;
+    } 
+
+    /* Check any remaining bits */
+    if ((Length > 0) && ((*pAddress >> (8 - Length)) != (*pPrefix >> (8 - Length))))
+        return FALSE;
+
+    return TRUE;
+}
+
+PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address)
+/*
+ * FUNCTION: Checks all on-link prefixes to find out if an address is on-link
+ * ARGUMENTS:
+ *     Address = Pointer to address to check
+ * RETURNS:
+ *     Pointer to interface if address is on-link, NULL if not
+ */
+{
+    KIRQL OldIrql;
+    IF_LIST_ITER(CurrentIF);
+
+    TI_DbgPrint(DEBUG_ROUTER, ("Called. Address (0x%X)\n", Address));
+    TI_DbgPrint(DEBUG_ROUTER, ("Address (%s)\n", A2S(Address)));
+
+    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
+
+    ForEachInterface(CurrentIF) {
+        if (HasPrefix(Address, &CurrentIF->Unicast,
+		      AddrCountPrefixBits(&CurrentIF->Netmask))) {
+	    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+            return CurrentIF;
+	}
+    } EndFor(CurrentIF);
+
+    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+
+    return NULL;
 }

reactos/drivers/lib/ip/network
ip.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- ip.c	9 Nov 2004 09:39:37 -0000	1.5
+++ ip.c	8 Dec 2004 21:56:49 -0000	1.5.2.1
@@ -18,6 +18,7 @@
 UINT MaxLLHeaderSize; /* Largest maximum header size */
 UINT MinLLFrameSize;  /* Largest minimum frame size */
 BOOLEAN IPInitialized = FALSE;
+BOOLEAN IpWorkItemQueued = FALSE;
 NPAGED_LOOKASIDE_LIST IPPacketList;
 /* Work around calling timer at Dpc level */
 
@@ -46,31 +47,6 @@
 {
 }
 
-
-VOID FreeADE(
-    PVOID Object)
-/*
- * FUNCTION: Frees an address entry object
- * ARGUMENTS:
- *     Object = Pointer to an address entry structure
- */
-{
-    exFreePool(Object);
-}
-
-
-VOID FreeNTE(
-    PVOID Object)
-/*
- * FUNCTION: Frees a net table entry object
- * ARGUMENTS:
- *     Object = Pointer to an net table entry structure
- */
-{
-    exFreePool(Object);
-}
-
-
 VOID FreeIF(
     PVOID Object)
 /*
@@ -83,108 +59,6 @@
 }
 
 
-PADDRESS_ENTRY CreateADE(
-    PIP_INTERFACE IF,    
-    PIP_ADDRESS Address,
-    UCHAR Type,
-    PNET_TABLE_ENTRY NTE)
-/*
- * FUNCTION: Creates an address entry and binds it to an interface
- * ARGUMENTS:
- *     IF      = Pointer to interface
- *     Address = Pointer to referenced interface address
- *     Type    = Type of address (ADE_*)
- *     NTE     = Pointer to net table entry
- * RETURNS:
- *     Pointer to ADE, NULL if there was not enough free resources
- * NOTES:
- *     The interface lock must be held when called. The address entry
- *     retains a reference to the provided address and NTE. The caller
- *     is responsible for referencing the these before calling.
- *     As long as you have referenced an ADE you can safely use the
- *     address and NTE as the ADE references both
- */
-{
-    PADDRESS_ENTRY ADE;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  Address (0x%X)  Type (0x%X)  NTE (0x%X).\n",
-        IF, Address, Type, NTE));
-
-    TI_DbgPrint(DEBUG_IP, ("Address (%s)  NTE (%s).\n",
-        A2S(Address), A2S(NTE->Address)));
-
-    /* Allocate space for an ADE and set it up */
-    ADE = exAllocatePool(NonPagedPool, sizeof(ADDRESS_ENTRY));
-    if (!ADE) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    INIT_TAG(ADE, TAG('A','D','E',' '));
-    ADE->Free     = FreeADE;
-    ADE->NTE      = NTE;
-    ADE->Type     = Type;
-    RtlCopyMemory(&ADE->Address,Address,sizeof(ADE->Address));
-
-    /* Add ADE to the list on the interface */
-    InsertTailList(&IF->ADEListHead, &ADE->ListEntry);
-
-    return ADE;
-}
-
-
-VOID DestroyADE(
-    PIP_INTERFACE IF,
-    PADDRESS_ENTRY ADE)
-/*
- * FUNCTION: Destroys an address entry
- * ARGUMENTS:
- *     IF  = Pointer to interface
- *     ADE = Pointer to address entry
- * NOTES:
- *     The interface lock must be held when called
- */
-{
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  ADE (0x%X).\n", IF, ADE));
-
-    TI_DbgPrint(DEBUG_IP, ("ADE (%s).\n", ADE->Address));
-
-    /* Unlink the address entry from the list */
-    RemoveEntryList(&ADE->ListEntry);
-
-    /* And free the ADE */
-    FreeADE(ADE);
-}
-
-
-VOID DestroyADEs(
-    PIP_INTERFACE IF)
-/*
- * FUNCTION: Destroys all address entries on an interface
- * ARGUMENTS:
- *     IF  = Pointer to interface
- * NOTES:
- *     The interface lock must be held when called
- */
-{
-    PLIST_ENTRY CurrentEntry;
-    PLIST_ENTRY NextEntry;
-    PADDRESS_ENTRY Current;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
-
-    /* Search the list and remove every ADE we find */
-    CurrentEntry = IF->ADEListHead.Flink;
-    while (CurrentEntry != &IF->ADEListHead) {
-        NextEntry = CurrentEntry->Flink;
-  	    Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_ENTRY, ListEntry);
-        /* Destroy the ADE */
-        DestroyADE(IF, Current);
-        CurrentEntry = NextEntry;
-    }
-}
-
-
 PIP_PACKET IPCreatePacket(ULONG Type)
 /*
  * FUNCTION: Creates an IP packet object
@@ -235,335 +109,9 @@
 }
 
 
-PNET_TABLE_ENTRY IPCreateNTE(
-    PIP_INTERFACE IF,
-    PIP_ADDRESS Address,
-    UINT PrefixLength)
-/*
- * FUNCTION: Creates a net table entry and binds it to an interface
- * ARGUMENTS:
- *     IF           = Pointer to interface
- *     Address      = Pointer to interface address
- *     PrefixLength = Length of prefix
- * RETURNS:
- *     Pointer to NTE, NULL if there was not enough free resources
- * NOTES:
- *     The interface lock must be held when called.
- *     The net table entry retains a reference to the interface and
- *     the provided address. The caller is responsible for providing
- *     these references
- */
-{
-    PNET_TABLE_ENTRY NTE;
-    PADDRESS_ENTRY ADE;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  Address (0x%X)  PrefixLength (%d).\n", IF, Address, PrefixLength));
-
-    TI_DbgPrint(DEBUG_IP, ("Address (%s).\n", A2S(Address)));
-
-    /* Allocate room for an NTE */
-    NTE = exAllocatePool(NonPagedPool, sizeof(NET_TABLE_ENTRY));
-    if (!NTE) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    INIT_TAG(NTE, TAG('N','T','E',' '));
-    INIT_TAG(Address, TAG('A','D','R','S'));
-
-    NTE->Free = FreeNTE;
-
-    NTE->Interface = IF;
-
-    NTE->Address = Address;
-
-    /* Create an address entry and add it to the list */
-    ADE = CreateADE(IF, NTE->Address, ADE_UNICAST, NTE);
-    if (!ADE) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        exFreePool(NTE);
-        return NULL;
-    }
-
-    /* Create a prefix list entry for unicast address */
-    NTE->PLE = CreatePLE(IF, NTE->Address, PrefixLength);
-    if (!NTE->PLE) {
-        DestroyADE(IF, ADE);
-        exFreePool(NTE);
-        return NULL;
-    }
-
-    /* Add NTE to the list on the interface */
-    InsertTailList(&IF->NTEListHead, &NTE->IFListEntry);
-
-    /* Add NTE to the global net table list */
-    TcpipInterlockedInsertTailList(&NetTableListHead, &NTE->NTListEntry, &NetTableListLock);
-
-    return NTE;
-}
-
-
-VOID DestroyNTE(
-    PIP_INTERFACE IF,
-    PNET_TABLE_ENTRY NTE)
-/*
- * FUNCTION: Destroys a net table entry
- * ARGUMENTS:
- *     IF  = Pointer to interface
- *     NTE = Pointer to net table entry
- * NOTES:
- *     The net table list lock must be held when called
- *     The interface lock must be held when called
- */
-{
-    KIRQL OldIrql;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  NTE (0x%X).\n", IF, NTE));
-
-    TI_DbgPrint(DEBUG_IP, ("NTE (%s).\n", NTE->Address));
-
-    /* Invalidate the prefix list entry for this NTE */
-    TcpipAcquireSpinLock(&PrefixListLock, &OldIrql);
-    DestroyPLE(NTE->PLE);
-    TcpipReleaseSpinLock(&PrefixListLock, OldIrql);
-
-    /* Remove NTE from the interface list */
-    RemoveEntryList(&NTE->IFListEntry);
-    /* Remove NTE from the net table list */
-
-/* TODO: DEBUG: removed by RobD to prevent failure when testing under bochs 6 sept 2002.
-
-    RemoveEntryList(&NTE->NTListEntry);
-
- */
-
-    /* And free the NTE */
-    exFreePool(NTE);
-}
-
-
-VOID DestroyNTEs(
-    PIP_INTERFACE IF)
-/*
- * FUNCTION: Destroys all net table entries on an interface
- * ARGUMENTS:
- *     IF  = Pointer to interface
- * NOTES:
- *     The net table list lock must be held when called
- *     The interface lock may be held when called
- */
-{
-    PLIST_ENTRY CurrentEntry;
-    PLIST_ENTRY NextEntry;
-    PNET_TABLE_ENTRY Current;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
-
-    /* Search the list and remove every NTE we find */
-    CurrentEntry = IF->NTEListHead.Flink;
-    while (CurrentEntry != &IF->NTEListHead) {
-        NextEntry = CurrentEntry->Flink;
-	      Current = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, IFListEntry);
-        /* Destroy the NTE */
-        DestroyNTE(IF, Current);
-        CurrentEntry = NextEntry;
-    }
-}
-
-
-PNET_TABLE_ENTRY IPLocateNTEOnInterface(
-    PIP_INTERFACE IF,
-    PIP_ADDRESS Address,
-    PUINT AddressType)
-/*
- * FUNCTION: Locates an NTE on an interface
- * ARGUMENTS:
- *     IF          = Pointer to interface
- *     Address     = Pointer to IP address
- *     AddressType = Address of type of IP address
- * NOTES:
- *     If found, the NTE is referenced for the caller. The caller is
- *     responsible for dereferencing after use
- * RETURNS:
- *     Pointer to net table entry, NULL if none was found
- */
-{
-    KIRQL OldIrql;
-    PLIST_ENTRY CurrentEntry;
-    PADDRESS_ENTRY Current;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  Address (%s)  AddressType (0x%X).\n",
-        IF, A2S(Address), AddressType));
-
-    if( !IF ) return NULL;
-
-    TcpipAcquireSpinLock(&IF->Lock, &OldIrql);
-
-    /* Search the list and return the NTE if found */
-    CurrentEntry = IF->ADEListHead.Flink;
-
-    if (CurrentEntry == &IF->ADEListHead) {
-        TI_DbgPrint(DEBUG_IP, ("NTE list is empty!!!\n"));
-    }
-
-    while (CurrentEntry != &IF->ADEListHead) {
-	      Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_ENTRY, ListEntry);
-        if (AddrIsEqual(Address, &Current->Address)) {
-            *AddressType = Current->Type;
-            TcpipReleaseSpinLock(&IF->Lock, OldIrql);
-            return Current->NTE;
-        }
-        CurrentEntry = CurrentEntry->Flink;
-    }
-
-    TcpipReleaseSpinLock(&IF->Lock, OldIrql);
-
-    return NULL;
-}
-
-
-PNET_TABLE_ENTRY IPLocateNTE(
-    PIP_ADDRESS Address,
-    PUINT AddressType)
-/*
- * FUNCTION: Locates an NTE for the network Address is on 
- * ARGUMENTS:
- *     Address     = Pointer to an address to find associated NTE of
- *     AddressType = Address of address type
- * NOTES:
- *     If found the NTE is referenced for the caller. The caller is
- *     responsible for dereferencing after use
- * RETURNS:
- *     Pointer to NTE if the address was found, NULL if not.
- */
-{
-    KIRQL OldIrql;
-    PLIST_ENTRY CurrentEntry;
-    PNET_TABLE_ENTRY Current;
-    PNET_TABLE_ENTRY NTE;
-
-//    TI_DbgPrint(DEBUG_IP, ("Called. Address (0x%X)  AddressType (0x%X).\n",
-//        Address, AddressType));
-
-//    TI_DbgPrint(DEBUG_IP, ("Address (%s).\n", A2S(Address)));
-
-    TcpipAcquireSpinLock(&NetTableListLock, &OldIrql);
-
-    /* Search the list and return the NTE if found */
-    CurrentEntry = NetTableListHead.Flink;
-    while (CurrentEntry != &NetTableListHead) {
-	      Current = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, NTListEntry);
-        NTE = IPLocateNTEOnInterface(Current->Interface, Address, AddressType);
-        if (NTE) {
-            TcpipReleaseSpinLock(&NetTableListLock, OldIrql);
-            return NTE;
-        }
-        CurrentEntry = CurrentEntry->Flink;
-    }
-
-    TcpipReleaseSpinLock(&NetTableListLock, OldIrql);
-
-    return NULL;
-}
-
-
-PADDRESS_ENTRY IPLocateADE(
-    PIP_ADDRESS Address,
-    UINT AddressType)
-/*
- * FUNCTION: Locates an ADE for the address
- * ARGUMENTS:
- *     Address     = Pointer to an address to find associated ADE of
- *     AddressType = Type of address
- * RETURNS:
- *     Pointer to ADE if the address was found, NULL if not.
- * NOTES:
- *     If found the ADE is referenced for the caller. The caller is
- *     responsible for dereferencing after use
- */
-{
-    KIRQL OldIrql;
-    IF_LIST_ITER(CurrentIF);
-    ADE_LIST_ITER(CurrentADE);
-
-//    TI_DbgPrint(DEBUG_IP, ("Called. Address (0x%X)  AddressType (0x%X).\n",
-//        Address, AddressType));
-
-//    TI_DbgPrint(DEBUG_IP, ("Address (%s).\n", A2S(Address)));
-
-    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
-
-    /* Search the interface list */
-    ForEachInterface(CurrentIF) {
-        /* Search the address entry list and return the ADE if found */
-	ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
-            if ((AddrIsEqual(Address, &CurrentADE->Address)) && 
-                (CurrentADE->Type == AddressType)) {
-                TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-                return CurrentADE;
-            }
-        } EndFor(CurrentADE);
-    } EndFor(CurrentIF);
-
-    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-
-    return NULL;
-}
-
-
-PADDRESS_ENTRY IPGetDefaultADE(
-    UINT AddressType)
-/*
- * FUNCTION: Returns a default address entry
- * ARGUMENTS:
- *     AddressType = Type of address
- * RETURNS:
- *     Pointer to ADE if found, NULL if not.
- * NOTES:
- *     Loopback interface is only considered if it is the only interface.
- *     If found, the address entry is referenced
- */
-{
-    KIRQL OldIrql;
-    ADE_LIST_ITER(CurrentADE);
-    IF_LIST_ITER(CurrentIF);
-    BOOLEAN LoopbackIsRegistered = FALSE;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. AddressType (0x%X).\n", AddressType));
-
-    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
-
-    /* Search the interface list */
-    ForEachInterface(CurrentIF) {
-        if (CurrentIF != Loopback) {
-            /* Search the address entry list and return the first appropriate ADE found */
-	    TI_DbgPrint(DEBUG_IP,("Checking interface %x\n", CurrentIF));
-	    ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
-                if (CurrentADE->Type == AddressType) {
-                    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-                    return CurrentADE;
-                }
-	    } EndFor(CurrentADE);
-        } else
-            LoopbackIsRegistered = TRUE;
-    } EndFor(CurrentIF);
-
-    /* No address was found. Use loopback interface if available */
-    if (LoopbackIsRegistered) {
-	ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
-            if (CurrentADE->Type == AddressType) {
-                TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-                return CurrentADE;
-            }
-        } EndFor(CurrentADE);
-    }
-
-    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-
-    return NULL;
-}
-
 void STDCALL IPTimeout( PVOID Context ) {
+    IpWorkItemQueued = FALSE;
+
     /* Check if datagram fragments have taken too long to assemble */
     IPDatagramReassemblyTimeout();
     
@@ -576,7 +124,7 @@
 
 
 VOID IPDispatchProtocol(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket)
 /*
  * FUNCTION: IP protocol dispatcher
@@ -603,7 +151,7 @@
     }
 
     /* Call the appropriate protocol handler */
-    (*ProtocolTable[Protocol])(NTE, IPPacket);
+    (*ProtocolTable[Protocol])(Interface, IPPacket);
 }
 
 
@@ -653,9 +201,6 @@
     IF->AddressLength = BindInfo->AddressLength;
     IF->Transmit      = BindInfo->Transmit;
 
-    InitializeListHead(&IF->ADEListHead);
-    InitializeListHead(&IF->NTEListHead);
-
     TcpipInitializeSpinLock(&IF->Lock);
 
 #ifdef __NTDRIVER__
@@ -674,22 +219,12 @@
  *     IF = Pointer to interface to destroy
  */
 {
-    KIRQL OldIrql1;
-    KIRQL OldIrql2;
-
     TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
 
 #ifdef __NTDRIVER__
     RemoveTDIInterfaceEntity( IF );
 #endif
 
-    TcpipAcquireSpinLock(&NetTableListLock, &OldIrql1);
-    TcpipAcquireSpinLock(&IF->Lock, &OldIrql2);
-    DestroyADEs(IF);
-    DestroyNTEs(IF);
-    TcpipReleaseSpinLock(&IF->Lock, OldIrql2);
-    TcpipReleaseSpinLock(&NetTableListLock, OldIrql1);
-
     exFreePool(IF);
 }
 
@@ -705,42 +240,29 @@
  */
 {
     KIRQL OldIrql;
-    PLIST_ENTRY CurrentEntry;
-    PNET_TABLE_ENTRY Current;
-    PROUTE_CACHE_NODE RCN;
+    IP_ADDRESS NetworkAddress;
     PNEIGHBOR_CACHE_ENTRY NCE;
 
     TI_DbgPrint(MID_TRACE, ("Called. IF (0x%X).\n", IF));
 
     TcpipAcquireSpinLock(&IF->Lock, &OldIrql);
 
-    /* Add routes to all NTEs on this interface */
-    CurrentEntry = IF->NTEListHead.Flink;
-    while (CurrentEntry != &IF->NTEListHead) {
-	    Current = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, IFListEntry);
-
-        /* Add a permanent neighbor for this NTE */
-        NCE = NBAddNeighbor(IF, Current->Address, IF->Address,
-            IF->AddressLength, NUD_PERMANENT);
-        if (!NCE) {
-            TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
-            TcpipReleaseSpinLock(&IF->Lock, OldIrql);
-            return FALSE;
-        }
-
-        /* NCE is already referenced */
-        if (!RouterAddRoute(Current->Address, &Current->PLE->Prefix, NCE, 1)) {
-            TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
-        }
-
-        RCN = RouteAddRouteToDestination(Current->Address, Current, IF, NCE);
-        if (!RCN) {
-            TI_DbgPrint(MIN_TRACE, ("Could not create RCN.\n"));
-            TcpipReleaseSpinLock(&IF->Lock, OldIrql);
-        }
-        CurrentEntry = CurrentEntry->Flink;
+    /* Add a permanent neighbor for this NTE */
+    NCE = NBAddNeighbor(IF, &IF->Unicast, 
+			IF->Address, IF->AddressLength, 
+			NUD_PERMANENT);
+    if (!NCE) {
+	TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
+	TcpipReleaseSpinLock(&IF->Lock, OldIrql);
+	return FALSE;
     }
+    
+    AddrWidenAddress( &NetworkAddress, &IF->Unicast, &IF->Netmask );
 
+    if (!RouterAddRoute(&NetworkAddress, &IF->Netmask, NCE, 1)) {
+	TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
+    }
+    
     /* Add interface to the global interface list */
     ASSERT(&IF->ListEntry);
     TcpipInterlockedInsertTailList(&InterfaceListHead, 
@@ -764,45 +286,19 @@
  *     IF = Pointer to interface to unregister
  */
 {
-    KIRQL OldIrql1;
-    KIRQL OldIrql2;
     KIRQL OldIrql3;
-    PLIST_ENTRY CurrentEntry;
-    PNET_TABLE_ENTRY Current;
     PNEIGHBOR_CACHE_ENTRY NCE;
 
     TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
 
-    TcpipAcquireSpinLock(&NetTableListLock, &OldIrql1);
-    TcpipAcquireSpinLock(&IF->Lock, &OldIrql2);
-
-    /* Remove routes to all NTEs on this interface */
-    CurrentEntry = IF->NTEListHead.Flink;
-    while (CurrentEntry != &IF->NTEListHead) {
-        Current = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, IFListEntry);
-
-        /* Remove NTE from global net table list */
-        RemoveEntryList(&Current->NTListEntry);
-
-        /* Remove all references from route cache to NTE */
-        RouteInvalidateNTE(Current);
-
-        /* Remove permanent NCE, but first we have to find it */
-        NCE = NBLocateNeighbor(Current->Address);
-        if (NCE)
-            NBRemoveNeighbor(NCE);
-
-        CurrentEntry = CurrentEntry->Flink;
-    }
-
+    /* Remove permanent NCE, but first we have to find it */
+    NCE = NBLocateNeighbor(&IF->Unicast);
+    if (NCE)
+	NBRemoveNeighbor(NCE);
+    
     TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql3);
-    /* Ouch...three spinlocks acquired! Fortunately
-       we don't unregister interfaces very often */
     RemoveEntryList(&IF->ListEntry);
     TcpipReleaseSpinLock(&InterfaceListLock, OldIrql3);
-
-    TcpipReleaseSpinLock(&IF->Lock, OldIrql2);
-    TcpipReleaseSpinLock(&NetTableListLock, OldIrql1);
 }
 
 
@@ -828,7 +324,7 @@
 
 
 VOID DefaultProtocolHandler(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket)
 /*
  * FUNCTION: Default handler for Internet protocols
@@ -837,7 +333,8 @@
  *     IPPacket = Pointer to an IP packet that was received
  */
 {
-    TI_DbgPrint(MID_TRACE, ("Packet of unknown Internet protocol discarded.\n"));
+    TI_DbgPrint(MID_TRACE, ("[IF %x] Packet of unknown Internet protocol "
+			    "discarded.\n", Interface));
 }
 
 
@@ -897,9 +394,6 @@
     /* Start routing subsystem */
     RouterStartup();
 
-    /* Start route cache subsystem */
-    RouteStartup();
-
     /* Start neighbor cache subsystem */
     NBStartup();
 
@@ -919,8 +413,6 @@
     InitializeListHead(&ReassemblyListHead);
     TcpipInitializeSpinLock(&ReassemblyListLock);
 
-    InitPLE();
-
     IPInitialized = TRUE;
 
     return STATUS_SUCCESS;
@@ -943,17 +435,11 @@
     /* Shutdown neighbor cache subsystem */
     NBShutdown();
 
-    /* Shutdown route cache subsystem */
-    RouteShutdown();
-
     /* Shutdown routing subsystem */
     RouterShutdown();
 
     IPFreeReassemblyList();
 
-    /* Clear prefix list */
-    DestroyPLEs();
-
     /* Destroy lookaside lists */
     ExDeleteNPagedLookasideList(&IPHoleList);
     ExDeleteNPagedLookasideList(&IPDRList);

reactos/drivers/lib/ip/network
loopback.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- loopback.c	22 Nov 2004 17:08:33 -0000	1.5
+++ loopback.c	8 Dec 2004 21:56:49 -0000	1.5.2.1
@@ -63,47 +63,28 @@
  *   Status of operation
  */
 {
-  PIP_ADDRESS Address;
   NDIS_STATUS Status;
+  LLIP_BIND_INFO BindInfo;
 
   Status = NDIS_STATUS_SUCCESS;
 
   TI_DbgPrint(MID_TRACE, ("Called.\n"));
 
-  Address = AddrBuildIPv4(LOOPBACK_ADDRESS_IPv4);
-  if (Address != NULL)
-    {
-      LLIP_BIND_INFO BindInfo;
-
-      /* Bind the adapter to network (IP) layer */
-      BindInfo.Context = NULL;
-      BindInfo.HeaderSize = 0;
-      BindInfo.MinFrameSize = 0;
-      BindInfo.MTU = 16384;
-      BindInfo.Address = NULL;
-      BindInfo.AddressLength = 0;
-      BindInfo.Transmit = LoopTransmit;
-
-      Loopback = IPCreateInterface(&BindInfo);
-
-      if ((Loopback != NULL) && (IPCreateNTE(Loopback, Address, 8)))
-        {
-          IPRegisterInterface(Loopback);
-        }
-      else
-        {
-          Status = NDIS_STATUS_RESOURCES;
-        }
-    }
-  else
-    {
-      Status = NDIS_STATUS_RESOURCES;
-    }
-
-  if (!NT_SUCCESS(Status))
-    {
-      LoopUnregisterAdapter(NULL);
-    }
+  /* Bind the adapter to network (IP) layer */
+  BindInfo.Context = NULL;
+  BindInfo.HeaderSize = 0;
+  BindInfo.MinFrameSize = 0;
+  BindInfo.MTU = 16384;
+  BindInfo.Address = NULL;
+  BindInfo.AddressLength = 0;
+  BindInfo.Transmit = LoopTransmit;
+  
+  Loopback = IPCreateInterface(&BindInfo);
+  
+  AddrInitIPv4(&Loopback->Unicast, LOOPBACK_ADDRESS_IPv4);
+  AddrInitIPv4(&Loopback->Netmask, LOOPBACK_ADDRMASK_IPv4);
+  
+  IPRegisterInterface(Loopback);
 
   TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
 

reactos/drivers/lib/ip/network
neighbor.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- neighbor.c	16 Nov 2004 18:07:56 -0000	1.4
+++ neighbor.c	8 Dec 2004 21:56:49 -0000	1.4.2.1
@@ -107,11 +107,6 @@
             /* Flush packet queue */
 	    NBFlushPacketQueue( NCE, TRUE, NDIS_STATUS_REQUEST_ABORTED );
             NCE->EventCount = 0;
-	    
-            /* Remove route cache entries with references to this NCE.
-	       Remember that neighbor cache lock is acquired before the
-	       route cache lock */
-            RouteInvalidateNCE(NCE);
 	}
         else
 	{
@@ -129,7 +124,7 @@
         /* FIXME: Probe state */
         TI_DbgPrint(DEBUG_NCACHE, ("NCE probe state.\n"));
         break;
-	
+
     default:
         /* Should not happen since the event timer is not used in the other states */
         TI_DbgPrint(MIN_TRACE, ("Invalid NCE state (%d).\n", NCE->State));
@@ -204,9 +199,6 @@
       CurNCE = NeighborCache[i].Cache;
       while (CurNCE) {
           NextNCE = CurNCE->Next;
-	  
-          /* Remove all references from route cache */
-          RouteInvalidateNCE(CurNCE);
 
           /* Flush wait queue */
 	  NBFlushPacketQueue( CurNCE, FALSE, STATUS_SUCCESS );
@@ -231,38 +223,16 @@
  *   May be called with lock held on NCE's table
  */
 {
-    PLIST_ENTRY CurrentEntry;
-    PNET_TABLE_ENTRY NTE;
-    
     TI_DbgPrint(DEBUG_NCACHE, ("Called. NCE (0x%X).\n", NCE));
     
     if (NCE->State == NUD_INCOMPLETE)
     {
 	/* This is the first solicitation of this neighbor. Broadcast
 	   a request for the neighbor */
-
-	/* FIXME: Choose first NTE. We might want to give an NTE as argument */
-	if (!NCE->Interface || !NCE->Interface->NTEListHead.Flink) {
-	    TI_DbgPrint(MID_TRACE, 
-			("NCE->Interface: %x, "
-			 "NCE->Interface->NTEListHead.Flink %x\n",
-			 NCE->Interface,
-			 NCE->Interface ? NCE->Interface->NTEListHead.Flink : 0));
-	}
 	
-	TI_DbgPrint(MID_TRACE,("MARK\n"));
 	TI_DbgPrint(MID_TRACE,("NCE: %x\n", NCE));
-	TI_DbgPrint(MID_TRACE,("NCE->Interface: %x\n", NCE->Interface));
 
-	if (!IsListEmpty(&NCE->Interface->NTEListHead)) {
-	    CurrentEntry = NCE->Interface->NTEListHead.Flink;
-	    NTE = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, 
-				    IFListEntry);
-	    ARPTransmit(&NCE->Address, NTE);
-	} else {
-	    TI_DbgPrint(MIN_TRACE, ("Interface at 0x%X has zero NTE.\n", 
-				    NCE->Interface));
-	}
+	ARPTransmit(&NCE->Address, NCE->Interface);
     } else {
 	/* FIXME: Unicast solicitation since we have a cached address */
 	TI_DbgPrint(MIN_TRACE, ("Uninplemented unicast solicitation.\n"));
@@ -301,8 +271,6 @@
 	"LinkAddress (0x%X)  LinkAddressLength (%d)  State (0x%X)\n",
 	Interface, Address, LinkAddress, LinkAddressLength, State));
 
-  ASSERT(Address->Type == IP_ADDRESS_V4);
-
   NCE = ExAllocatePool
       (NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength);
   if (NCE == NULL)
@@ -323,6 +291,8 @@
   NCE->EventTimer = 0; /* Not in use */
   InitializeListHead( &NCE->PacketQueue );
 
+  TI_DbgPrint(MID_TRACE,("NCE: %x\n", NCE));
+
   HashValue = *(PULONG)&Address->Address;
   HashValue ^= HashValue >> 16;
   HashValue ^= HashValue >> 8;
@@ -523,9 +493,6 @@
           *PrevNCE = CurNCE->Next;
 
 	  NBFlushPacketQueue( CurNCE, TRUE, NDIS_STATUS_REQUEST_ABORTED );
-
-          /* Remove all references from route cache */
-          RouteInvalidateNCE(CurNCE);
           ExFreePool(CurNCE);
 
 	  break;

reactos/drivers/lib/ip/network
receive.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- receive.c	9 Nov 2004 09:39:37 -0000	1.3
+++ receive.c	8 Dec 2004 21:56:49 -0000	1.3.2.1
@@ -273,14 +273,12 @@
 
 VOID ProcessFragment(
   PIP_INTERFACE IF,
-  PIP_PACKET IPPacket,
-  PNET_TABLE_ENTRY NTE)
+  PIP_PACKET IPPacket)
 /*
  * FUNCTION: Processes an IP datagram or fragment
  * ARGUMENTS:
  *     IF       = Pointer to IP interface packet was receive on
  *     IPPacket = Pointer to IP packet
- *     NTE      = Pointer to NTE packet was received on
  * NOTES:
  *     This routine reassembles fragments and, if a whole datagram can
  *     be assembled, passes the datagram on to the IP protocol dispatcher
@@ -465,7 +463,7 @@
     DISPLAY_IP_PACKET(Datagram);
 
     /* Give the packet to the protocol dispatcher */
-    IPDispatchProtocol(NTE, Datagram);
+    IPDispatchProtocol(IF, Datagram);
 
     /* We're done with this datagram */
     exFreePool(Datagram->Header);
@@ -523,10 +521,6 @@
  *     IPPacket = Pointer to IP packet
  */
 {
-    PNEIGHBOR_CACHE_ENTRY NCE;
-    PNET_TABLE_ENTRY NTE;
-    UINT AddressType;
-    
     TI_DbgPrint(DEBUG_IP, ("Received IPv4 datagram.\n"));
     
     IPPacket->HeaderSize = (((PIPv4_HEADER)IPPacket->Header)->VerIHL & 0x0F) << 2;
@@ -567,11 +561,9 @@
     /* FIXME: Possibly forward packets with multicast addresses */
     
     /* FIXME: Should we allow packets to be received on the wrong interface? */
-    NTE = IPLocateNTEOnInterface(IF, &IPPacket->DstAddr, &AddressType);
-    
-    if (NTE) {
-	/* This packet is destined for us */
-	ProcessFragment(IF, IPPacket, NTE);
+    /* XXX Find out if this packet is destined for us */
+    ProcessFragment(IF, IPPacket);
+#if 0
     } else {
 	/* This packet is not destined for us. If we are a router,
 	   try to find a route and forward the packet */
@@ -592,6 +584,7 @@
 	    /* FIXME: Send ICMP error code */
 	}
     }
+#endif
 }
 
 

reactos/drivers/lib/ip/network
router.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- router.c	13 Nov 2004 00:06:32 -0000	1.4
+++ router.c	8 Dec 2004 21:56:49 -0000	1.4.2.1
@@ -153,133 +153,9 @@
     for (j = 0; (Addr1[i] & Bitmask) == (Addr2[i] & Bitmask); j++)
         Bitmask >>= 1;
 
-    return 8 * i + j;
-}
-
-
-BOOLEAN HasPrefix(
-    PIP_ADDRESS Address,
-    PIP_ADDRESS Prefix,
-    UINT Length)
-/*
- * FUNCTION: Determines wether an address has an given prefix
- * ARGUMENTS:
- *     Address = Pointer to address to use
- *     Prefix  = Pointer to prefix to check for
- *     Length  = Length of prefix
- * RETURNS:
- *     TRUE if the address has the prefix, FALSE if not
- * NOTES:
- *     The two addresses must be of the same type
- */
-{
-    PUCHAR pAddress = (PUCHAR)&Address->Address;
-    PUCHAR pPrefix  = (PUCHAR)&Prefix->Address;
-
-    TI_DbgPrint(DEBUG_ROUTER, ("Called. Address (0x%X)  Prefix (0x%X)  Length (%d).\n", Address, Prefix, Length));
-
-#if 0
-    TI_DbgPrint(DEBUG_ROUTER, ("Address (%s)  Prefix (%s).\n",
-        A2S(Address), A2S(Prefix)));
-#endif
-
-    /* Check that initial integral bytes match */
-    while (Length > 8) {
-        if (*pAddress++ != *pPrefix++)
-            return FALSE;
-        Length -= 8;
-    } 
-
-    /* Check any remaining bits */
-    if ((Length > 0) && ((*pAddress >> (8 - Length)) != (*pPrefix >> (8 - Length))))
-        return FALSE;
-
-    return TRUE;
-}
-
-
-PNET_TABLE_ENTRY RouterFindBestNTE(
-    PIP_INTERFACE Interface,
-    PIP_ADDRESS Destination)
-/*
- * FUNCTION: Checks all on-link prefixes to find out if an address is on-link
- * ARGUMENTS:
- *     Interface   = Pointer to interface to use
- *     Destination = Pointer to destination address
- * NOTES:
- *     If found the NTE if referenced
- * RETURNS:
- *     Pointer to NTE if found, NULL if not
- */
-{
-    KIRQL OldIrql;
-    PLIST_ENTRY CurrentEntry;
-    PNET_TABLE_ENTRY Current;
-    UINT Length, BestLength  = 0;
-    PNET_TABLE_ENTRY BestNTE = NULL;
-
-    TI_DbgPrint(DEBUG_ROUTER, ("Called. Interface (0x%X)  Destination (0x%X).\n", Interface, Destination));
-
-    TI_DbgPrint(DEBUG_ROUTER, ("Destination (%s).\n", A2S(Destination)));
-
-    TcpipAcquireSpinLock(&Interface->Lock, &OldIrql);
-
-    CurrentEntry = Interface->NTEListHead.Flink;
-    while (CurrentEntry != &Interface->NTEListHead) {
-	Current = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, IFListEntry);
-	TI_DbgPrint(DEBUG_ROUTER, ("Looking at NTE %s\n", A2S(Current->Address)));
-
-        Length = CommonPrefixLength(Destination, Current->Address);
-        if (BestNTE) {
-            if (Length > BestLength) {
-                BestNTE    = Current;
-                BestLength = Length;
-            }
-        } else {
-            BestNTE    = Current;
-            BestLength = Length;
-        }
-        CurrentEntry = CurrentEntry->Flink;
-    }
-
-    TcpipReleaseSpinLock(&Interface->Lock, OldIrql);
-
-    return BestNTE;
-}
-
-
-PIP_INTERFACE RouterFindOnLinkInterface(
-    PIP_ADDRESS Address,
-    PNET_TABLE_ENTRY NTE)
-/*
- * FUNCTION: Checks all on-link prefixes to find out if an address is on-link
- * ARGUMENTS:
- *     Address = Pointer to address to check
- *     NTE     = Pointer to NTE to check (NULL = check all interfaces)
- * RETURNS:
- *     Pointer to interface if address is on-link, NULL if not
- */
-{
-    PLIST_ENTRY CurrentEntry;
-    PPREFIX_LIST_ENTRY Current;
-
-    TI_DbgPrint(DEBUG_ROUTER, ("Called. Address (0x%X)  NTE (0x%X).\n", Address, NTE));
+    TI_DbgPrint(DEBUG_ROUTER, ("Returning %d\n", 8 * i + j));
 
-    TI_DbgPrint(DEBUG_ROUTER, ("Address (%s)  NTE (%s).\n",
-			       A2S(Address), NTE ? A2S(NTE->Address) : ""));
-
-    CurrentEntry = PrefixListHead.Flink;
-    while (CurrentEntry != &PrefixListHead) {
-	    Current = CONTAINING_RECORD(CurrentEntry, PREFIX_LIST_ENTRY, ListEntry);
-
-        if (HasPrefix(Address, &Current->Prefix, Current->PrefixLength) &&
-            ((!NTE) || (NTE->Interface == Current->Interface)))
-            return Current->Interface;
-
-        CurrentEntry = CurrentEntry->Flink;
-    }
-
-    return NULL;
+    return 8 * i + j;
 }
 
 
@@ -335,15 +211,11 @@
 }
 
 
-PNEIGHBOR_CACHE_ENTRY RouterGetRoute(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE)
+PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
 /*
  * FUNCTION: Finds a router to use to get to Destination
  * ARGUMENTS:
  *     Destination = Pointer to destination address (NULL means don't care)
- *     NTE         = Pointer to NTE describing net to send on
- *                   (NULL means don't care)
  * RETURNS:
  *     Pointer to NCE for router, NULL if none was found
  * NOTES:
@@ -355,14 +227,12 @@
     PLIST_ENTRY NextEntry;
     PFIB_ENTRY Current;
     UCHAR State, BestState = 0;
-    UINT Length, BestLength = 0;
+    UINT Length, BestLength = 0, MaskLength;
     PNEIGHBOR_CACHE_ENTRY NCE, BestNCE = NULL;
 
-    TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)  NTE (0x%X).\n", Destination, NTE));
+    TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)\n", Destination));
 
     TI_DbgPrint(DEBUG_ROUTER, ("Destination (%s)\n", A2S(Destination)));
-    if( NTE )
-	TI_DbgPrint(DEBUG_ROUTER, ("NTE (%s).\n", A2S(NTE->Address)));
 
     TcpipAcquireSpinLock(&FIBLock, &OldIrql);
 
@@ -374,62 +244,131 @@
         NCE   = Current->Router;
         State = NCE->State;
 
-        if ((!NTE) || (NTE->Interface == NCE->Interface)) {
-            if (Destination)
-                Length = CommonPrefixLength(Destination, &NCE->Address);
-            else
-                Length = 0;
-
-            if (BestNCE) {
-                if ((State  > BestState)  || 
-                    ((State == BestState) &&
-                    (Length > BestLength))) {
-                    /* This seems to be a better router */
-                    BestNCE    = NCE;
-                    BestLength = Length;
-                    BestState  = State;
-                }
-            } else {
-                /* First suitable router found, save it */
-                BestNCE    = NCE;
-                BestLength = Length;
-                BestState  = State;
-            }
-        }
+	Length = CommonPrefixLength(Destination, &Current->NetworkAddress);
+	MaskLength = AddrCountPrefixBits(&Current->Netmask);
+
+	TI_DbgPrint(DEBUG_ROUTER,("This-Route: %s (Sharing %d bits)\n", 
+				  A2S(&NCE->Address), Length));
+	
+	if(Length >= MaskLength && (Length > BestLength || !BestLength)) {
+	    /* This seems to be a better router */
+	    BestNCE    = NCE;
+	    BestLength = Length;
+	    BestState  = State;
+	    TI_DbgPrint(DEBUG_ROUTER,("Route selected\n"));
+	}
+
         CurrentEntry = NextEntry;
     }
 
     TcpipReleaseSpinLock(&FIBLock, OldIrql);
 
+    if( BestNCE ) {
+	TI_DbgPrint(DEBUG_ROUTER,("Routing to %s\n", A2S(&BestNCE->Address)));
+    } else {
+	TI_DbgPrint(DEBUG_ROUTER,("Packet won't be routed\n"));
+    }
+
     return BestNCE;
 }
 
+PNEIGHBOR_CACHE_ENTRY RouteGetRouteToDestination(PIP_ADDRESS Destination)
+/*
+ * FUNCTION: Locates an RCN describing a route to a destination address
+ * ARGUMENTS:
+ *     Destination = Pointer to destination address to find route to
+ *     RCN         = Address of pointer to an RCN
+ * RETURNS:
+ *     Status of operation
+ * NOTES:
+ *     The RCN is referenced for the caller. The caller is responsible
+ *     for dereferencing it after use
+ */
+{
+    PNEIGHBOR_CACHE_ENTRY NCE = NULL;
+    PIP_INTERFACE Interface;
+
+    TI_DbgPrint(DEBUG_RCACHE, ("Called. Destination (0x%X)\n", Destination));
+
+    TI_DbgPrint(DEBUG_RCACHE, ("Destination (%s)\n", A2S(Destination)));
+
+#if 0
+    TI_DbgPrint(MIN_TRACE, ("Displaying tree (before).\n"));
+    PrintTree(RouteCache);
+#endif
+
+    /* Check if the destination is on-link */
+    Interface = FindOnLinkInterface(Destination);
+    if (Interface) {
+	/* The destination address is on-link. Check our neighbor cache */
+	NCE = NBFindOrCreateNeighbor(Interface, Destination);
+    } else {
+	/* Destination is not on any subnets we're on. Find a router to use */
+	NCE = RouterGetRoute(Destination);
+    }
+    
+    if( NCE ) 
+	TI_DbgPrint(DEBUG_ROUTER,("Interface->MTU: %d\n", NCE->Interface->MTU));
+
+    return NCE;
+}
 
-VOID RouterRemoveRoute(
-    PFIB_ENTRY FIBE)
+NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router)
 /*
  * FUNCTION: Removes a route from the Forward Information Base (FIB)
  * ARGUMENTS:
- *     FIBE = Pointer to FIB entry describing route
+ *     Target: The machine or network targeted by the route
+ *     Router: The router used to pass the packet to the destination
+ *
+ * Searches the FIB and removes a route matching the indicated parameters.
  */
 {
     KIRQL OldIrql;
+    PLIST_ENTRY CurrentEntry;
+    PLIST_ENTRY NextEntry;
+    PFIB_ENTRY Current;
+    BOOLEAN Found = FALSE;
+    PNEIGHBOR_CACHE_ENTRY NCE;
 
-    TI_DbgPrint(DEBUG_ROUTER, ("Called. FIBE (0x%X).\n", FIBE));
+    TI_DbgPrint(DEBUG_ROUTER, ("Called\n"));
     
-    TI_DbgPrint(DEBUG_ROUTER, ("FIBE (%s).\n", A2S(&FIBE->NetworkAddress)));
-
     TcpipAcquireSpinLock(&FIBLock, &OldIrql);
-    DestroyFIBE(FIBE);
+
+    CurrentEntry = FIBListHead.Flink;
+    while (CurrentEntry != &FIBListHead) {
+        NextEntry = CurrentEntry->Flink;
+	    Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+
+        NCE   = Current->Router;
+
+	if( AddrIsEqual( &Current->NetworkAddress, Target ) &&
+	    AddrIsEqual( &NCE->Address, Router ) ) {
+	    Found = TRUE;
+	    break;
+	}
+
+	Current = NULL;
+        CurrentEntry = NextEntry;
+    }
+
+    if( Found ) {
+	TI_DbgPrint(DEBUG_ROUTER, ("Deleting route\n"));
+	DestroyFIBE( Current );
+    }
+
     TcpipReleaseSpinLock(&FIBLock, OldIrql);
+    
+    TI_DbgPrint(DEBUG_ROUTER, ("Leaving\n"));
+
+    return Found ? STATUS_NO_SUCH_FILE : STATUS_SUCCESS;
 }
 
 
-PFIB_ENTRY RouterCreateRouteIPv4(
-    IPv4_RAW_ADDRESS NetworkAddress,
-    IPv4_RAW_ADDRESS Netmask,
-    IPv4_RAW_ADDRESS RouterAddress,
-    PNET_TABLE_ENTRY NTE,
+PFIB_ENTRY RouterCreateRoute(
+    PIP_ADDRESS NetworkAddress,
+    PIP_ADDRESS Netmask,
+    PIP_ADDRESS RouterAddress,
+    PIP_INTERFACE Interface,
     UINT Metric)
 /*
  * FUNCTION: Creates a route with IPv4 addresses as parameters
@@ -445,42 +384,18 @@
  *     for providing this reference
  */
 {
-    PIP_ADDRESS pNetworkAddress;
-    PIP_ADDRESS pNetmask;
-    PIP_ADDRESS pRouterAddress;
     PNEIGHBOR_CACHE_ENTRY NCE;
     PFIB_ENTRY FIBE;
 
-    pNetworkAddress = AddrBuildIPv4(NetworkAddress);
-    if (!pNetworkAddress) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    pNetmask = AddrBuildIPv4(Netmask);
-    if (!pNetmask) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    pRouterAddress = AddrBuildIPv4(RouterAddress);
-    if (!pRouterAddress) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
     /* The NCE references RouterAddress. The NCE is referenced for us */
-    NCE = NBAddNeighbor(NTE->Interface,
-                        pRouterAddress,
-                        NULL,
-                        NTE->Interface->AddressLength,
-                        NUD_PROBE);
+    NCE = NBFindOrCreateNeighbor(Interface, RouterAddress);
+
     if (!NCE) {
         /* Not enough free resources */
         return NULL;
     }
 
-    FIBE = RouterAddRoute(pNetworkAddress, pNetmask, NCE, 1);
+    FIBE = RouterAddRoute(NetworkAddress, Netmask, NCE, 1);
     if (!FIBE) {
         /* Not enough free resources */
         NBRemoveNeighbor(NCE);
@@ -504,13 +419,6 @@
     InitializeListHead(&FIBListHead);
     TcpipInitializeSpinLock(&FIBLock);
 
-#if 0
-    /* TEST: Create a test route */
-    /* Network is 10.0.0.0  */
-    /* Netmask is 255.0.0.0 */
-    /* Router is 10.0.0.1   */
-    RouterCreateRouteIPv4(0x0000000A, 0x000000FF, 0x0100000A, NTE?, 1);
-#endif
     return STATUS_SUCCESS;
 }
 

reactos/drivers/lib/ip/network
transmit.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- transmit.c	7 Nov 2004 20:37:20 -0000	1.3
+++ transmit.c	8 Dec 2004 21:56:49 -0000	1.3.2.1
@@ -212,7 +212,7 @@
     return STATUS_SUCCESS;
 }
 
-NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PROUTE_CACHE_NODE RCN,
+NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
 			PIP_TRANSMIT_COMPLETE Complete, PVOID Context)
 /*
  * FUNCTION: Sends an IP datagram to a remote address
@@ -227,17 +227,13 @@
  *     send routine (IPSendFragment)
  */
 {
-    PNEIGHBOR_CACHE_ENTRY NCE;
-
-    TI_DbgPrint(MAX_TRACE, ("Called. IPPacket (0x%X)  RCN (0x%X)\n", IPPacket, RCN));
+    TI_DbgPrint(MAX_TRACE, ("Called. IPPacket (0x%X)  NCE (0x%X)\n", IPPacket, NCE));
 
     DISPLAY_IP_PACKET(IPPacket);
     /*OskitDumpBuffer( IPPacket->Header, IPPacket->TotalSize );*/
 
-    NCE = RCN->NCE;
-
     /* Fetch path MTU now, because it may change */
-    TI_DbgPrint(MID_TRACE,("PathMTU: %d\n", RCN->PathMTU));
+    TI_DbgPrint(MID_TRACE,("PathMTU: %d\n", NCE->Interface->MTU));
     
     if ((IPPacket->Flags & IP_PACKET_FLAG_RAW) == 0) {
 	/* Calculate checksum of IP header */
@@ -255,7 +251,8 @@
 				IPPacket->Flags));
     }
     
-    return SendFragments(IPPacket, NCE, RCN->PathMTU, Complete, Context);
+    return SendFragments(IPPacket, NCE, NCE->Interface->MTU, 
+			 Complete, Context);
 }
 
 /* EOF */

reactos/drivers/lib/ip/network
prefix.c removed after 1.3
diff -N prefix.c
--- prefix.c	9 Nov 2004 09:39:37 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,115 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS TCP/IP protocol driver
- * FILE:        network/ip.c
- * PURPOSE:     Internet Protocol module
- * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
- *              Art Yerkes (arty@users.sourceforge.net)
- * REVISIONS:
- *   CSH 01/08-2000 Created
- */
-
-#include "precomp.h"
-
-
-LIST_ENTRY PrefixListHead;
-KSPIN_LOCK PrefixListLock;
-
-/* --------- The Prefix List ---------- */
-
-VOID InitPLE() {
-    /* Initialize the prefix list and protecting lock */
-    InitializeListHead(&PrefixListHead);
-    TcpipInitializeSpinLock(&PrefixListLock);
-}
-
-
-PPREFIX_LIST_ENTRY CreatePLE(PIP_INTERFACE IF, PIP_ADDRESS Prefix, UINT Length)
-/*
- * FUNCTION: Creates a prefix list entry and binds it to an interface
- * ARGUMENTS:
- *     IF     = Pointer to interface
- *     Prefix = Pointer to prefix
- *     Length = Length of prefix
- * RETURNS:
- *     Pointer to PLE, NULL if there was not enough free resources
- * NOTES:
- *     The prefix list entry retains a reference to the interface and
- *     the provided address.  The caller is responsible for providing
- *     these references
- */
-{
-    PPREFIX_LIST_ENTRY PLE;
-
-    TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X)  Prefix (0x%X)  Length (%d).\n", IF, Prefix, Length));
-
-    TI_DbgPrint(DEBUG_IP, ("Prefix (%s).\n", A2S(Prefix)));
-
-    /* Allocate space for an PLE and set it up */
-    PLE = PoolAllocateBuffer(sizeof(PREFIX_LIST_ENTRY));
-    if (!PLE) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    INIT_TAG(PLE, TAG('P','L','E',' '));
-    PLE->Interface    = IF;
-    RtlCopyMemory(&PLE->Prefix, Prefix, sizeof(PLE->Prefix));
-    PLE->PrefixLength = Length;
-
-    /* Add PLE to the global prefix list */
-    ExInterlockedInsertTailList(&PrefixListHead, &PLE->ListEntry, &PrefixListLock);
-
-    return PLE;
-}
-
-
-VOID DestroyPLE(
-    PPREFIX_LIST_ENTRY PLE)
-/*
- * FUNCTION: Destroys an prefix list entry
- * ARGUMENTS:
- *     PLE = Pointer to prefix list entry
- * NOTES:
- *     The prefix list lock must be held when called
- */
-{
-    TI_DbgPrint(DEBUG_IP, ("Called. PLE (0x%X).\n", PLE));
-
-    TI_DbgPrint(DEBUG_IP, ("PLE (%s).\n", PLE->Prefix));
-
-    /* Unlink the prefix list entry from the list */
-    RemoveEntryList(&PLE->ListEntry);
-
-    /* And free the PLE */
-    PoolFreeBuffer(PLE);
-}
-
-
-VOID DestroyPLEs(
-    VOID)
-/*
- * FUNCTION: Destroys all prefix list entries
- */
-{
-    KIRQL OldIrql;
-    PLIST_ENTRY CurrentEntry;
-    PLIST_ENTRY NextEntry;
-    PPREFIX_LIST_ENTRY Current;
-
-    TI_DbgPrint(DEBUG_IP, ("Called.\n"));
-
-    TcpipAcquireSpinLock(&PrefixListLock, &OldIrql);
-
-    /* Search the list and remove every PLE we find */
-    CurrentEntry = PrefixListHead.Flink;
-    while (CurrentEntry != &PrefixListHead) {
-        NextEntry = CurrentEntry->Flink;
-	Current = CONTAINING_RECORD(CurrentEntry, PREFIX_LIST_ENTRY, ListEntry);
-        /* Destroy the PLE */
-        DestroyPLE(Current);
-        CurrentEntry = NextEntry;
-    }
-    TcpipReleaseSpinLock(&PrefixListLock, OldIrql);
-}
-

reactos/drivers/lib/ip/network
route.c removed after 1.2
diff -N route.c
--- route.c	7 Nov 2004 20:37:20 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,690 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS TCP/IP protocol driver
- * FILE:        network/route.c
- * PURPOSE:     Route cache
- * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
- * NOTES:       The route cache is implemented as a binary search
- *              tree to obtain fast searches
- *
- *   This data is not authoritative.  It is a searchable cache that allows
- *   quick access to route information to selected hosts.  This information
- *   should always defer to the FIB.
- *
- * REVISIONS:
- *   CSH 01/08-2000 Created
- */
-
-#include "precomp.h"
-
-
-/* This RCN is shared by all external nodes. It complicates things,
-   but the memory requirements are reduced by approximately 50%.
-   The RCN is protected by the route cache spin lock */
-PROUTE_CACHE_NODE ExternalRCN;
-PROUTE_CACHE_NODE RouteCache;
-KSPIN_LOCK RouteCacheLock;
-NPAGED_LOOKASIDE_LIST IPRCNList;
-
-
-#ifdef DBG
-VOID PrintTree(
-    PROUTE_CACHE_NODE Node)
-/*
- * FUNCTION: Prints all nodes on tree
- * ARGUMENTS:
- *     Node = Pointer to root node of tree
- * NOTES:
- *     This function must be called with the route cache lock held.
- */
-{
-    if (IsInternalRCN(Node)) {
-        /* Traverse left subtree */
-        PrintTree(Node->Left);
-
-        /* Traverse right subtree */
-        PrintTree(Node->Right);
-
-        /* Finally check the node itself */
-        TI_DbgPrint(MIN_TRACE, ("(Internal) Self,Parent,Left,Right,Data = (%08X, %08X, %08X, %08X, %08X).\n",
-            Node, Node->Parent, Node->Left, Node->Right, (ULONG_PTR)Node->Destination.Address.IPv4Address));
-    } else
-        TI_DbgPrint(MIN_TRACE, ("(External) Self,Parent,Left,Right = (%08X, %08X, %08X, %08X).\n",
-            Node, Node->Parent, Node->Left, Node->Right));
-}
-#endif
-
-UINT CountRouteNodes( PROUTE_CACHE_NODE Node ) {
-    if( !Node ) Node = RouteCache;
-    if( IsInternalRCN(Node) )
-        return 
-	    /* Traverse left subtree */
-	    CountRouteNodes(Node->Left) + 
-	    /* Traverse right subtree */
-	    CountRouteNodes(Node->Right) + 1;
-    else
-	return 0;
-}
-
-VOID FreeRCN(
-    PVOID Object)
-/*
- * FUNCTION: Frees an route cache node object
- * ARGUMENTS:
- *     Object = Pointer to an route cache node structure
- */
-{
-  ExFreeToNPagedLookasideList(&IPRCNList, Object);
-}
-
-
-VOID RemoveAboveExternal(VOID)
-/*
- * FUNCTION: Removes the parent node of the selected external node from the route cache tree
- * NOTES:
- *     This function must be called with the route cache lock held.
- *     ExternalRCN->Parent must be initialized
- */
-{
-    PROUTE_CACHE_NODE Parent;
-    PROUTE_CACHE_NODE Sibling;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called.\n"));
-
-#if 0
-    TI_DbgPrint(MIN_TRACE, ("Displaying tree (before).\n"));
-    PrintTree(RouteCache);
-#endif
-
-    Parent = ExternalRCN->Parent;
-    /* Find sibling of external node */
-    if (ExternalRCN == Parent->Left)
-        Sibling = Parent->Right;
-    else
-        Sibling = Parent->Left;
-
-    /* Replace parent node with sibling of external node */
-    if (Parent != RouteCache) {
-        if (Parent->Parent->Left == Parent)
-            Parent->Parent->Left = Sibling;
-        else
-            Parent->Parent->Right = Sibling;
-        /* Give sibling a new parent */
-        Sibling->Parent = Parent->Parent;
-    } else {
-        /* This is the root we're removing */
-        RouteCache      = Sibling;
-        Sibling->Parent = NULL;
-    }
-}
-
-
-PROUTE_CACHE_NODE SearchRouteCache(
-    PIP_ADDRESS Destination,
-    PROUTE_CACHE_NODE Node)
-/*
- * FUNCTION: Searches route cache for a RCN for a destination address
- * ARGUMENTS:
- *     Destination = Pointer to destination address (key)
- *     Node        = Pointer to start route cache node
- * NOTES:
- *     This function must be called with the route cache lock held
- * RETURNS:
- *     Pointer to internal node if a matching node was found, or
- *     external node where it should be if none was found
- */
-{
-    INT Value;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. Destination (0x%X)  Node (0x%X)\n", Destination, Node));
-
-    /* Is this an external node? */
-    if (IsExternalRCN(Node))
-        return Node;
-
-    /* Is it this node we are looking for? */
-    Value = AddrCompare(Destination, &Node->Destination);
-    if (Value == 0)
-        return Node;
-
-    /* Traverse down the left subtree if the key is smaller than
-       the key of the node, otherwise traverse the right subtree */
-    if (Value < 0) {
-        Node->Left->Parent = Node;
-        ExternalRCN->Left  = (PROUTE_CACHE_NODE)&Node->Left;
-        return SearchRouteCache(Destination, Node->Left);
-    } else {
-        Node->Right->Parent = Node;
-        ExternalRCN->Left   = (PROUTE_CACHE_NODE)&Node->Right;
-        return SearchRouteCache(Destination, Node->Right);
-    }
-}
-
-
-PROUTE_CACHE_NODE ExpandExternalRCN(VOID)
-/*
- * FUNCTION: Expands an external route cache node
- * NOTES:
- *     This function must be called with the route cache lock held.
- *     We cheat a little here to save memory. We don't actually allocate memory
- *     for external nodes. We wait until they're turned into internal nodes.
- *     ExternalRCN->Parent must be initialized
- *     ExternalRCN->Left must be a pointer to the correct child link of it's parent
- * RETURNS:
- *     Pointer to new internal node if the external node was expanded, NULL if not
- */
-{
-    PROUTE_CACHE_NODE RCN;
-
-    MTMARK();
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called.\n"));
-
-    RCN = ExAllocateFromNPagedLookasideList(&IPRCNList);
-    if (!RCN) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return NULL;
-    }
-
-    MTMARK();
-
-    RCN->Free = FreeRCN;
-
-    if (ExternalRCN->Left)
-        /* Register RCN as a child with it's parent */
-        *(PROUTE_CACHE_NODE*)ExternalRCN->Left = RCN;
-
-    RCN->Parent = ExternalRCN->Parent;
-    RCN->Left   = ExternalRCN;
-    RCN->Right  = ExternalRCN;
-
-    MTMARK();
-
-    return RCN;
-}
-
-#if 0
-VOID SwapRCN(
-    PROUTE_CACHE_NODE *Node1,
-    PROUTE_CACHE_NODE *Node2)
-/*
- * FUNCTION: Swaps two nodes
- * ARGUMENTS:
- *     Node1 = Address of pointer to first node
- *     Node2 = Address of pointer to second node
- */
-{
-    PROUTE_CACHE_NODE Temp;
-
-    Temp  = *Node2;
-    *Node2 = *Node1;
-    *Node1 = Temp;
-}
-#endif
-
-/*
- * FUNCTION: Removes a route to a destination
- * ARGUMENTS:
- *     RCN = Pointer to route cache node to remove
- * NOTES:
- *     Internal version. Route cache lock must be held
- */
-VOID RemoveRouteToDestination(
-    PROUTE_CACHE_NODE RCN)
-{
-    PROUTE_CACHE_NODE RemNode, Parent, SwapNode;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. RCN (0x%X).\n", RCN));
-
-    if (IsExternalRCN(RCN->Left)) {
-        /* Left node is external */
-        RemNode         = RCN->Left;
-        RemNode->Parent = RCN;
-    } else if (IsExternalRCN(RCN->Right)) {
-        /* Right node is external */
-        RemNode         = RCN->Right;
-        RemNode->Parent = RCN;
-    } else {
-        /* The node has internal children */
-
-        /* Normally we would replace the item of RCN with the item
-           of the leftmost external node on the right subtree of
-           RCN. This we cannot do here because there may be
-           references directly to that node. Instead we swap pointer
-           values (parent, left and right) of the two nodes */
-        RemNode = RCN->Right;
-        do {
-            Parent  = RemNode;
-            RemNode = RemNode->Left;
-        } while (IsInternalRCN(RemNode));
-        RemNode->Parent = Parent;
-
-        SwapNode = RemNode->Parent;
-#if 0
-        if (RCN != RouteCache) {
-            /* Set SwapNode to be child of RCN's parent instead of RCN */
-            Parent = RCN->Parent;
-            if (RCN == Parent->Left)
-                Parent->Left = SwapNode;
-            else
-                Parent->Right = SwapNode;
-        } else
-            /* SwapNode is the new cache root */
-            RouteCache = SwapNode;
-
-        /* Set RCN to be child of SwapNode's parent instead of SwapNode */
-        Parent = SwapNode->Parent;
-        if (SwapNode == Parent->Left)
-            Parent->Left = RCN;
-        else
-            Parent->Right = RCN;
-
-        /* Swap parents */
-        SwapRCN(&SwapNode->Parent, &RCN->Parent);
-        /* Swap children */
-        SwapRCN(&SwapNode->Left, &RCN->Left);
-        SwapRCN(&SwapNode->Right, &RCN->Right);
-#endif
-    }
-    
-    ExternalRCN->Parent = RemNode->Parent;
-
-    RemoveAboveExternal();
-}
-
-
-VOID InvalidateNTEOnSubtree(
-    PNET_TABLE_ENTRY NTE,
-    PROUTE_CACHE_NODE Node)
-/*
- * FUNCTION: Removes all RCNs with references to an NTE on a subtree
- * ARGUMENNTS:
- *     NTE  = Pointer to NTE to invalidate
- *     Node = Pointer to RCN to start removing nodes at
- * NOTES:
- *     This function must be called with the route cache lock held.
- */
-{
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. NTE (0x%X)  Node (0x%X).\n", NTE, Node));
-
-    if (IsInternalRCN(Node)) {
-        /* Traverse left subtree */
-        InvalidateNTEOnSubtree(NTE, Node->Left);
-
-        /* Traverse right subtree */
-        InvalidateNTEOnSubtree(NTE, Node->Right);
-
-        /* Finally check the node itself */
-        if (Node->NTE == NTE)
-            RemoveRouteToDestination(Node);
-    }
-}
-
-
-VOID InvalidateNCEOnSubtree(
-    PNEIGHBOR_CACHE_ENTRY NCE,
-    PROUTE_CACHE_NODE Node)
-/*
- * FUNCTION: Removes all RCNs with references to an NCE on a subtree
- * ARGUMENNTS:
- *     NCE  = Pointer to NCE to invalidate
- *     Node = Pointer to RCN to start removing nodes at
- * NOTES:
- *     This function must be called with the route cache lock held
- */
-{
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. NCE (0x%X)  Node (0x%X).\n", NCE, Node));
-
-    if (IsInternalRCN(Node)) {
-        /* Traverse left subtree */
-        InvalidateNCEOnSubtree(NCE, Node->Left);
-
-        /* Traverse right subtree */
-        InvalidateNCEOnSubtree(NCE, Node->Right);
-
-        /* Finally check the node itself */
-        if (Node->NCE == NCE)
-            RemoveRouteToDestination(Node);
-    }
-}
-
-
-VOID RemoveSubtree(
-    PROUTE_CACHE_NODE Node)
-/*
- * FUNCTION: Removes a subtree from the tree using recursion
- * ARGUMENNTS:
- *     Node = Pointer to RCN to start removing nodes at
- * NOTES:
- *     This function must be called with the route cache lock held
- */
-{
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. Node (0x%X).\n", Node));
-
-    if (IsInternalRCN(Node)) {
-        /* Traverse left subtree */
-        RemoveSubtree(Node->Left);
-
-        /* Traverse right subtree */
-        RemoveSubtree(Node->Right);
-    }
-}
-
-
-NTSTATUS RouteStartup(
-    VOID)
-/*
- * FUNCTION: Initializes the routing subsystem
- * RETURNS:
- *     Status of operation
- */
-{
-    TI_DbgPrint(DEBUG_RCACHE, ("Called.\n"));
-
-    ExInitializeNPagedLookasideList(
-      &IPRCNList,                     /* Lookaside list */
-	    NULL,                           /* Allocate routine */
-	    NULL,                           /* Free routine */
-	    0,                              /* Flags */
-	    sizeof(ROUTE_CACHE_NODE),       /* Size of each entry */
-	    TAG('I','P','R','C'),           /* Tag */
-	    0);                             /* Depth */
-
-    /* Initialize the pseudo external route cache node */
-    ExternalRCN = ExAllocateFromNPagedLookasideList(&IPRCNList);
-    if (!ExternalRCN) {
-        TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-        return STATUS_INSUFFICIENT_RESOURCES;
-    }
-    INIT_TAG(ExternalRCN, TAG('R','C','N',' '));
-
-    ExternalRCN->Free   = FreeRCN;
-    ExternalRCN->Parent = NULL;
-    ExternalRCN->Left   = NULL;
-    ExternalRCN->Right  = NULL;
-
-    /* Initialize the route cache root */
-    RouteCache = ExternalRCN;
-
-    KeInitializeSpinLock(&RouteCacheLock);
-
-#if 0
-    TI_DbgPrint(MIN_TRACE, ("Displaying tree.\n"));
-    PrintTree(RouteCache);
-#endif
-    return STATUS_SUCCESS;
-}
-
-
-NTSTATUS RouteShutdown(
-    VOID)
-/*
- * FUNCTION: Shuts down the routing subsystem
- * RETURNS:
- *     Status of operation
- */
-{
-    KIRQL OldIrql;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called.\n"));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-#if 0
-    TI_DbgPrint(MIN_TRACE, ("Displaying tree.\n"));
-    PrintTree(RouteCache);
-#endif
-    /* Clear route cache */
-    RemoveSubtree(RouteCache);
-
-    FreeRCN(ExternalRCN);
-
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-
-    ExDeleteNPagedLookasideList(&IPRCNList);
-
-    return STATUS_SUCCESS;
-}
-
-
-UINT RouteGetRouteToDestination(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE,
-    PROUTE_CACHE_NODE *RCN)
-/*
- * FUNCTION: Locates an RCN describing a route to a destination address
- * ARGUMENTS:
- *     Destination = Pointer to destination address to find route to
- *     NTE         = Pointer to NTE describing net to send on
- *                   (NULL means routing module choose NTE to send on)
- *     RCN         = Address of pointer to an RCN
- * RETURNS:
- *     Status of operation
- * NOTES:
- *     The RCN is referenced for the caller. The caller is responsible
- *     for dereferencing it after use
- */
-{
-    KIRQL OldIrql;
-    PROUTE_CACHE_NODE RCN2;
-    PNEIGHBOR_CACHE_ENTRY NCE;
-    PIP_INTERFACE Interface;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. Destination (0x%X)  NTE (0x%X).\n",
-        Destination, NTE));
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Destination (%s)  NTE (%s).\n",
-			       A2S(Destination), NTE ? A2S(NTE->Address) : ""));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-
-#if 0
-    TI_DbgPrint(MIN_TRACE, ("Displaying tree (before).\n"));
-    PrintTree(RouteCache);
-#endif
-
-    ExternalRCN->Left = NULL;
-    RCN2 = SearchRouteCache(Destination, RouteCache);
-    if (IsExternalRCN(RCN2)) {
-        /* No route was found in the cache */
-
-        /* Check if the destination is on-link */
-        Interface = RouterFindOnLinkInterface(Destination, NTE);
-        if (Interface) {
-            if (!NTE) {
-                NTE = RouterFindBestNTE(Interface, Destination);
-                if (!NTE) {
-                    /* We cannot get to the specified destination. Return error */
-                    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-                    return IP_NO_ROUTE_TO_DESTINATION;
-                }
-            }
-
-            /* The destination address is on-link. Check our neighbor cache */
-            NCE = NBFindOrCreateNeighbor(Interface, Destination);
-            if (!NCE) {
-                TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-                return IP_NO_RESOURCES;
-            }
-        } else {
-            /* Destination is not on any subnets we're on. Find a router to use */
-            NCE = RouterGetRoute(Destination, NTE);
-            if (!NCE) {
-                /* We cannot get to the specified destination. Return error */
-                TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-                return IP_NO_ROUTE_TO_DESTINATION;
-            }
-        }
-
-        /* Add the new route to the route cache */
-        if (RCN2 == RouteCache) {
-            RCN2       = ExpandExternalRCN();
-            RouteCache = RCN2;
-        } else
-            RCN2 = ExpandExternalRCN();
-        if (!RCN2) {
-            TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-            return IP_NO_RESOURCES;
-        }
-
-        RCN2->State       = RCN_STATE_COMPUTED;
-        RCN2->NTE         = NTE;
-        RtlCopyMemory(&RCN2->Destination, Destination, sizeof(IP_ADDRESS));
-        RCN2->PathMTU     = NCE->Interface->MTU;
-        RCN2->NCE         = NCE;
-
-        /* The route cache node references the NTE and the NCE. The
-           NTE was referenced before and NCE is already referenced by
-           RouteGetRoute() or NBFindOrCreateNeighbor() so we don't
-           reference them here */
-    }
-
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-
-    *RCN = RCN2;
-    TI_DbgPrint(MID_TRACE,("RCN->PathMTU: %d\n", RCN2->PathMTU));
-
-    return IP_SUCCESS;
-}
-
-
-PROUTE_CACHE_NODE RouteAddRouteToDestination(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE,
-    PIP_INTERFACE IF,
-    PNEIGHBOR_CACHE_ENTRY NCE)
-/*
- * FUNCTION: Adds a (permanent) route to a destination
- * ARGUMENTS:
- *     Destination = Pointer to destination address
- *     NTE         = Pointer to net table entry
- *     IF          = Pointer to interface to use
- *     NCE         = Pointer to first hop to destination
- * RETURNS:
- *     Pointer to RCN if the route was added, NULL if not.
- *     There can be at most one RCN per destination address / interface pair
- */
-{
-    KIRQL OldIrql;
-    PROUTE_CACHE_NODE RCN;
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. Destination (0x%X)  NTE (0x%X)  IF (0x%X)  NCE (0x%X).\n",
-        Destination, NTE, IF, NCE));
-
-    TI_DbgPrint(DEBUG_RCACHE, ("Destination (%s)  NTE (%s)  NCE (%s).\n",
-			       A2S(Destination), 
-			       A2S(NTE->Address), 
-			       A2S(&NCE->Address)));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-
-    /* Locate an external RCN we can expand */
-    RCN = RouteCache;
-    ExternalRCN->Left = NULL;
-    for (;;) {
-        RCN = SearchRouteCache(Destination, RCN);
-        if (IsInternalRCN(RCN)) {
-            ExternalRCN->Left = (PROUTE_CACHE_NODE)&RCN->Right;
-            /* This is an internal node, continue the search to the right */
-            RCN = RCN->Right;
-        } else
-            /* This is an external node, we've found an empty spot */
-            break;
-    }
-
-    /* Expand the external node */
-    if (RCN == RouteCache) {
-        RCN = ExpandExternalRCN();
-        RouteCache = RCN;
-    } else
-        RCN = ExpandExternalRCN();
-    if (!RCN) {
-        TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-        return NULL;
-    }
-
-    /* Initialize the newly created internal node */
-
-    INIT_TAG(RCN, TAG('R','C','N',' '));
-
-    /* Reference once for beeing alive */
-    RCN->State       = RCN_STATE_PERMANENT;
-    RCN->NTE         = NTE;
-    RtlCopyMemory(&RCN->Destination, Destination, sizeof(IP_ADDRESS));
-    RCN->PathMTU     = IF->MTU;
-    RCN->NCE         = NCE;
-
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-
-    return RCN;
-}
-
-
-VOID RouteRemoveRouteToDestination(
-    PROUTE_CACHE_NODE RCN)
-/*
- * FUNCTION: Removes a route to a destination
- * ARGUMENTS:
- *     RCN = Pointer to route cache node to remove
- */
-{
-    KIRQL OldIrql;
- 
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. RCN (0x%X).\n", RCN));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-
-    RemoveRouteToDestination(RCN);
-
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-}
-
-
-VOID RouteInvalidateNTE(
-    PNET_TABLE_ENTRY NTE)
-/*
- * FUNCTION: Removes all RCNs with references to an NTE
- * ARGUMENTS:
- *     NTE = Pointer to net table entry to invalidate
- */
-{
-    KIRQL OldIrql;
- 
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. NTE (0x%X).\n", NTE));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-    InvalidateNTEOnSubtree(NTE, RouteCache);
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-}
-
-
-VOID RouteInvalidateNCE(
-    PNEIGHBOR_CACHE_ENTRY NCE)
-/*
- * FUNCTION: Removes all RCNs with references to an NCE
- * ARGUMENTS:
- *     NCE = Pointer to neighbor cache entry to invalidate
- */
-{
-    KIRQL OldIrql;
- 
-    TI_DbgPrint(DEBUG_RCACHE, ("Called. NCE (0x%X).\n", NCE));
-
-    TcpipAcquireSpinLock(&RouteCacheLock, &OldIrql);
-    InvalidateNCEOnSubtree(NCE, RouteCache);
-    TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
-}
-
-NTSTATUS
-RouteFriendlyAddRoute( PIPROUTE_ENTRY ire ) {
-    KIRQL OldIrql;
-    
-
-    /* Find IF */
-    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
-    //RouteAddRouteToDestination(&Dest,Nte,If,Nce);
-    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-
-    return STATUS_SUCCESS;
-}
-
-/* EOF */

reactos/drivers/lib/ip/transport/rawip
rawip.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- rawip.c	9 Nov 2004 09:39:37 -0000	1.4
+++ rawip.c	8 Dec 2004 21:56:50 -0000	1.4.2.1
@@ -98,7 +98,7 @@
 {
     NDIS_STATUS Status;
     IP_PACKET Packet;
-    PROUTE_CACHE_NODE RCN;
+    PNEIGHBOR_CACHE_ENTRY NCE;
     IP_ADDRESS RemoteAddress;
 
     Status = AllocatePacketWithBuffer( &Packet.NdisPacket,
@@ -112,7 +112,7 @@
     if( Status == NDIS_STATUS_SUCCESS )
 	Status = BuildRawIPPacket( &Packet,
 				   BufferLen,
-				   &AddrFile->ADE->Address,
+				   &AddrFile->Address,
 				   AddrFile->Port );
 
     if( Status == NDIS_STATUS_SUCCESS ) {
@@ -121,14 +121,12 @@
 		       BufferData + FIELD_OFFSET(IPv4_HEADER, DstAddr),
 		       sizeof(IPv4_RAW_ADDRESS) );
 
-	Status = RouteGetRouteToDestination( &RemoteAddress, NULL, &RCN );
-	
-	if( !NT_SUCCESS(Status) ) {
+	if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) {
 	    FreeNdisPacket( Packet.NdisPacket );
-	    return Status;
+	    return STATUS_NO_SUCH_DEVICE;
 	}
 	
-	IPSendDatagram( &Packet, RCN, RawIPSendComplete, NULL );
+	IPSendDatagram( &Packet, NCE, RawIPSendComplete, NULL );
     } else
 	FreeNdisPacket( Packet.NdisPacket );
 
@@ -137,7 +135,7 @@
 
 
 VOID RawIPReceive(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket)
 /*
  * FUNCTION: Receives and queues a raw IP datagram

reactos/drivers/lib/ip/transport/tcp
event.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- event.c	21 Nov 2004 20:54:52 -0000	1.7
+++ event.c	8 Dec 2004 21:56:51 -0000	1.7.2.1
@@ -10,137 +10,34 @@
 
 #include "precomp.h"
 
-extern ULONG TCP_IPIdentification;
-extern LIST_ENTRY SleepingThreadsList;
-extern FAST_MUTEX SleepingThreadsLock;
-extern RECURSIVE_MUTEX TCPLock;
+extern VOID DrainSignals();
 
 int TCPSocketState(void *ClientData,
 		   void *WhichSocket, 
 		   void *WhichConnection,
 		   OSK_UINT NewState ) {
-    NTSTATUS Status = STATUS_SUCCESS;
     PCONNECTION_ENDPOINT Connection = WhichConnection;
-    PTCP_COMPLETION_ROUTINE Complete;
-    PTDI_BUCKET Bucket;
-    PLIST_ENTRY Entry;
 
-    TI_DbgPrint(MID_TRACE,("Called: NewState %x (Conn %x) (Change %x)\n", 
+    TI_DbgPrint(DEBUG_TCP,("Called: NewState %x (Conn %x) (Change %x)\n", 
 			   NewState, Connection,
 			   Connection ? Connection->State ^ NewState : 
 			   NewState));
 
-    TcpipRecursiveMutexEnter( &TCPLock, TRUE );
-
     if( !Connection ) {
-	TI_DbgPrint(MID_TRACE,("Socket closing.\n"));
+	TI_DbgPrint(DEBUG_TCP,("Socket closing.\n"));
 	Connection = FileFindConnectionByContext( WhichSocket );
 	if( !Connection ) {
 	    TcpipRecursiveMutexLeave( &TCPLock );
 	    return 0;
 	} else 
-	    TI_DbgPrint(MID_TRACE,("Found socket %x\n", Connection));
+	    TI_DbgPrint(DEBUG_TCP,("Found socket %x\n", Connection));
     }
 
-    if( ((NewState & SEL_CONNECT) || (NewState & SEL_FIN)) &&
-	!(Connection->State & (SEL_CONNECT | SEL_FIN)) ) {
-	while( !IsListEmpty( &Connection->ConnectRequest ) ) {
-	    Connection->State |= NewState & (SEL_CONNECT | SEL_FIN);
-	    Entry = RemoveHeadList( &Connection->ConnectRequest );
-	    Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
-	    Complete = Bucket->Request.RequestNotifyObject;
-	    TI_DbgPrint(MID_TRACE,
-			("Completing Connect Request %x\n", Bucket->Request));
-	    if( NewState & SEL_FIN ) Status = STATUS_CONNECTION_REFUSED;
-	    TcpipRecursiveMutexLeave( &TCPLock );
-	    Complete( Bucket->Request.RequestContext, Status, 0 );
-	    TcpipRecursiveMutexEnter( &TCPLock, TRUE );
-	    /* Frees the bucket allocated in TCPConnect */
-	    PoolFreeBuffer( Bucket );
-	}
+    if( !Connection->Signalled ) {
+	Connection->Signalled = TRUE;
+	Connection->SignalState = NewState;
+	InsertTailList( &SignalledConnections, &Connection->SignalList );
     }
-    if( (NewState & SEL_READ) || (NewState & SEL_FIN) ) {
-	TI_DbgPrint(MID_TRACE,("Readable (or closed): irp list %s\n",
-			       IsListEmpty(&Connection->ReceiveRequest) ?
-			       "empty" : "nonempty"));
-
-	while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
-	    PIRP Irp;
-	    OSK_UINT RecvLen = 0, Received = 0;
-	    OSK_PCHAR RecvBuffer = 0;
-	    PMDL Mdl;
-	    NTSTATUS Status;
-
-	    Entry = RemoveHeadList( &Connection->ReceiveRequest );
-	    Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
-	    Complete = Bucket->Request.RequestNotifyObject;
-
-	    TI_DbgPrint(MID_TRACE,
-			("Readable, Completing read request %x\n", 
-			 Bucket->Request));
-
-	    Irp = Bucket->Request.RequestContext;
-	    Mdl = Irp->MdlAddress;
-
-	    TI_DbgPrint(MID_TRACE,
-			("Getting the user buffer from %x\n", Mdl));
-
-	    NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen );
-
-	    TI_DbgPrint(MID_TRACE,
-			("Reading %d bytes to %x\n", RecvLen, RecvBuffer));
-
-	    if( (NewState & SEL_FIN) && !RecvLen ) {
-		TI_DbgPrint(MID_TRACE, ("EOF From socket\n"));
-		Status = STATUS_END_OF_FILE;
-		Received = 0;
-	    } else {
-		TI_DbgPrint(MID_TRACE, ("Connection: %x\n", Connection));
-		TI_DbgPrint
-		    (MID_TRACE, 
-		     ("Connection->SocketContext: %x\n", 
-		      Connection->SocketContext));
-		TI_DbgPrint(MID_TRACE, ("RecvBuffer: %x\n", RecvBuffer));
-
-		Status = TCPTranslateError
-		    ( OskitTCPRecv( Connection->SocketContext,
-				    RecvBuffer,
-				    RecvLen,
-				    &Received,
-				    0 ) );
-	    }
-
-	    TI_DbgPrint(MID_TRACE,("TCP Bytes: %d\n", Received));
-
-	    if( Status == STATUS_SUCCESS && Received != 0 ) {
-		TI_DbgPrint(MID_TRACE,("Received %d bytes with status %x\n",
-				       Received, Status));
-		
-		TI_DbgPrint(MID_TRACE,
-			    ("Completing Receive Request: %x\n", 
-			     Bucket->Request));
-
-		TcpipRecursiveMutexLeave( &TCPLock );
-		Complete( Bucket->Request.RequestContext,
-			  STATUS_SUCCESS, Received );
-		TcpipRecursiveMutexEnter( &TCPLock, TRUE );
-	    } else if( Status == STATUS_PENDING || 
-		       (Status == STATUS_SUCCESS && Received == 0) ) {
-		InsertHeadList( &Connection->ReceiveRequest,
-				&Bucket->Entry );
-		break;
-	    } else {
-		TI_DbgPrint(MID_TRACE,
-			    ("Completing Receive request: %x %x\n",
-			     Bucket->Request, Status));
-		TcpipRecursiveMutexLeave( &TCPLock );
-		Complete( Bucket->Request.RequestContext, Status, 0 );
-		TcpipRecursiveMutexEnter( &TCPLock, TRUE );
-	    }
-	}
-    } 
-
-    TcpipRecursiveMutexLeave( &TCPLock );
 
     return 0;
 }
@@ -148,17 +45,16 @@
 void TCPPacketSendComplete( PVOID Context,
 			    PNDIS_PACKET NdisPacket,
 			    NDIS_STATUS NdisStatus ) {
-    TI_DbgPrint(MID_TRACE,("called %x\n", NdisPacket));
+    TI_DbgPrint(DEBUG_TCP,("called %x\n", NdisPacket));
     FreeNdisPacket(NdisPacket);
-    TI_DbgPrint(MID_TRACE,("done\n"));
+    TI_DbgPrint(DEBUG_TCP,("done\n"));
 }
 
 #define STRINGIFY(x) #x
 
 int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len ) {
-    NTSTATUS Status;
     NDIS_STATUS NdisStatus;
-    ROUTE_CACHE_NODE *RCN;
+    PNEIGHBOR_CACHE_ENTRY NCE;
     IP_PACKET Packet = { 0 };
     IP_ADDRESS RemoteAddress, LocalAddress;
     PIPv4_HEADER Header;
@@ -170,25 +66,23 @@
 	RemoteAddress.Type = IP_ADDRESS_V4;
 	RemoteAddress.Address.IPv4Address = Header->DstAddr;
     } else {
-	DbgPrint("Don't currently handle IPv6\n");
-	KeBugCheck(4);
+	TI_DbgPrint(MIN_TRACE,("Outgoing packet is not IPv4\n"));
+	OskitDumpBuffer( data, len );
+	return OSK_EINVAL;
     }
 
     RemoteAddress.Type = LocalAddress.Type = IP_ADDRESS_V4;
 
-    DbgPrint("OSKIT SENDING PACKET *** %x -> %x\n",
-	     LocalAddress.Address.IPv4Address,
-	     RemoteAddress.Address.IPv4Address);
-    
-    Status = RouteGetRouteToDestination( &RemoteAddress, NULL, &RCN );
-    
-    if( !NT_SUCCESS(Status) || !RCN ) return OSK_EADDRNOTAVAIL;
+    if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) {
+	TI_DbgPrint(MIN_TRACE,("No route to %s\n", A2S(&RemoteAddress)));
+	return OSK_EADDRNOTAVAIL;
+    }
 
     NdisStatus = AllocatePacketWithBuffer( &Packet.NdisPacket, NULL, 
 					   MaxLLHeaderSize + len );
     
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
-	TI_DbgPrint(MAX_TRACE, ("Error from NDIS: %08x\n", NdisStatus));
+	TI_DbgPrint(DEBUG_TCP, ("Error from NDIS: %08x\n", NdisStatus));
 	return STATUS_NO_MEMORY;
     }
 
@@ -202,8 +96,13 @@
     Packet.SrcAddr = LocalAddress;
     Packet.DstAddr = RemoteAddress;
 
-    IPSendDatagram( &Packet, RCN, TCPPacketSendComplete, NULL );
+<<<<<<< event.c
+    IPSendDatagram( &Packet, NCE, TCPPacketSendComplete, NULL );
 
+=======
+    IPSendDatagram( &Packet, NCE, TCPPacketSendComplete, NULL );
+    
+>>>>>>> 1.11
     if( !NT_SUCCESS(NdisStatus) ) return OSK_EINVAL;
     else return 0;
 }
@@ -225,7 +124,7 @@
 	      int tmio ) {
     PSLEEPING_THREAD SleepingThread;
     
-    TI_DbgPrint(MID_TRACE,
+    TI_DbgPrint(DEBUG_TCP,
 		("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n",
 		 token, priority, msg, tmio));
 
@@ -238,7 +137,7 @@
 	InsertTailList( &SleepingThreadsList, &SleepingThread->Entry );
 	TcpipReleaseFastMutex( &SleepingThreadsLock );
 
-	TI_DbgPrint(MID_TRACE,("Waiting on %x\n", token));
+	TI_DbgPrint(DEBUG_TCP,("Waiting on %x\n", token));
 	KeWaitForSingleObject( &SleepingThread->Event,
 			       WrSuspended,
 			       KernelMode,
@@ -251,7 +150,7 @@
 
 	PoolFreeBuffer( SleepingThread );
     }
-    TI_DbgPrint(MID_TRACE,("Waiting finished: %x\n", token));
+    TI_DbgPrint(DEBUG_TCP,("Waiting finished: %x\n", token));
     return 0;
 }
 
@@ -263,9 +162,9 @@
     Entry = SleepingThreadsList.Flink;
     while( Entry != &SleepingThreadsList ) {
 	SleepingThread = CONTAINING_RECORD(Entry, SLEEPING_THREAD, Entry);
-	TI_DbgPrint(MID_TRACE,("Sleeper @ %x\n", SleepingThread));
+	TI_DbgPrint(DEBUG_TCP,("Sleeper @ %x\n", SleepingThread));
 	if( SleepingThread->SleepToken == token ) {
-	    TI_DbgPrint(MID_TRACE,("Setting event to wake %x\n", token));
+	    TI_DbgPrint(DEBUG_TCP,("Setting event to wake %x\n", token));
 	    KeSetEvent( &SleepingThread->Event, IO_NETWORK_INCREMENT, FALSE );
 	}
 	Entry = Entry->Flink;

reactos/drivers/lib/ip/transport/tcp
if.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- if.c	16 Nov 2004 18:07:57 -0000	1.3
+++ if.c	8 Dec 2004 21:56:51 -0000	1.3.2.1
@@ -38,7 +38,7 @@
     struct sockaddr_in *dstaddr_in = (struct sockaddr_in *)&addr_in[1];
     if( !ifaddr ) return NULL;
 
-    TI_DbgPrint(MID_TRACE,("Called\n"));
+    TI_DbgPrint(DEBUG_TCPIF,("Called\n"));
 
     ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
     /* XXX - Point-to-point interfaces not supported yet */
@@ -52,7 +52,7 @@
     if( !NT_SUCCESS(Status) )
 	addr_in->sin_addr.s_addr = 0;
 
-    TI_DbgPrint(MID_TRACE,("Prepare interface %x : addr %x\n",
+    TI_DbgPrint(DEBUG_TCPIF,("Prepare interface %x : addr %x\n",
 			   IF, addr_in->sin_addr.s_addr));
     
     ifaddr->ifa_flags = 0; /* XXX what goes here? */
@@ -60,7 +60,7 @@
     ifaddr->ifa_metric = 1; /* We can get it like in ninfo.c, if we want */
     ifaddr->ifa_mtu = IF->MTU;
 
-    TI_DbgPrint(MID_TRACE,("Leaving\n"));
+    TI_DbgPrint(DEBUG_TCPIF,("Leaving\n"));
 
     return ifaddr;
 }
@@ -74,34 +74,34 @@
     IP_ADDRESS Destination;
     struct sockaddr_in *addr_in = (struct sockaddr_in *)ReqAddr;
     
-    TI_DbgPrint(MID_TRACE,("called for type %d\n", FindType));
+    TI_DbgPrint(DEBUG_TCPIF,("called for type %d\n", FindType));
 
     if( !ReqAddr ) {
-	TI_DbgPrint(MID_TRACE,("no addr or no ifaddr (%x)\n", ReqAddr));
+	TI_DbgPrint(DEBUG_TCPIF,("no addr or no ifaddr (%x)\n", ReqAddr));
 	return NULL;
     }
 
     Destination.Type = IP_ADDRESS_V4;
     Destination.Address.IPv4Address = addr_in->sin_addr.s_addr;
 
-    TI_DbgPrint(MID_TRACE,("Address is %x\n", addr_in->sin_addr.s_addr));
+    TI_DbgPrint(DEBUG_TCPIF,("Address is %x\n", addr_in->sin_addr.s_addr));
 
-    NCE = RouterGetRoute(&Destination, NULL);
+    NCE = RouteGetRouteToDestination(&Destination);
 
     if( !NCE || !NCE->Interface ) {
-	TI_DbgPrint(MID_TRACE,("no neighbor cache or no interface (%x %x)\n",
-			       NCE, NCE->Interface));
+	TI_DbgPrint(DEBUG_TCPIF,("no neighbor cache or no interface (%x %x)\n",
+			       NCE, NCE ? NCE->Interface : 0));
 	return NULL;
     }
 
-    TI_DbgPrint(MID_TRACE,("NCE: %x\n", NCE));
-    TI_DbgPrint(MID_TRACE,("NCE->Interface: %x\n", NCE->Interface));
-    TI_DbgPrint(MID_TRACE,("NCE->Interface->TCPContext: %x\n", 
+    TI_DbgPrint(DEBUG_TCPIF,("NCE: %x\n", NCE));
+    TI_DbgPrint(DEBUG_TCPIF,("NCE->Interface: %x\n", NCE->Interface));
+    TI_DbgPrint(DEBUG_TCPIF,("NCE->Interface->TCPContext: %x\n", 
 			   NCE->Interface->TCPContext));
 
     addr_in = (struct sockaddr_in *)
 	((POSK_IFADDR)NCE->Interface->TCPContext)->ifa_addr;
-    TI_DbgPrint(MID_TRACE,("returning addr %x\n", addr_in->sin_addr.s_addr));
+    TI_DbgPrint(DEBUG_TCPIF,("returning addr %x\n", addr_in->sin_addr.s_addr));
     
     return NCE->Interface->TCPContext;
 }

reactos/drivers/lib/ip/transport/tcp
tcp.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- tcp.c	16 Nov 2004 18:07:57 -0000	1.9
+++ tcp.c	8 Dec 2004 21:56:51 -0000	1.9.2.1
@@ -13,10 +13,136 @@
 LONG TCP_IPIdentification = 0;
 static BOOLEAN TCPInitialized = FALSE;
 static NPAGED_LOOKASIDE_LIST TCPSegmentList;
+LIST_ENTRY SignalledConnections;
 LIST_ENTRY SleepingThreadsList;
 FAST_MUTEX SleepingThreadsLock;
 RECURSIVE_MUTEX TCPLock;
 
+static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
+				       ULONG NewState ) {
+    NTSTATUS Status = STATUS_SUCCESS;
+    PTCP_COMPLETION_ROUTINE Complete;
+    PTDI_BUCKET Bucket;
+    PLIST_ENTRY Entry;
+    BOOLEAN CompletedOne = FALSE;
+
+    /* Things that can happen when we try the initial connection */
+    if( ((NewState & SEL_CONNECT) || (NewState & SEL_FIN)) &&
+
+	!(Connection->State & (SEL_CONNECT | SEL_FIN)) ) {
+	while( !IsListEmpty( &Connection->ConnectRequest ) ) {
+	    Connection->State |= NewState & (SEL_CONNECT | SEL_FIN);
+	    Entry = RemoveHeadList( &Connection->ConnectRequest );
+	    Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+	    Complete = Bucket->Request.RequestNotifyObject;
+	    TI_DbgPrint(DEBUG_TCP,
+			("Completing Connect Request %x\n", Bucket->Request));
+	    if( NewState & SEL_FIN ) Status = STATUS_CONNECTION_REFUSED;
+	    Complete( Bucket->Request.RequestContext, Status, 0 );
+	    /* Frees the bucket allocated in TCPConnect */
+	    PoolFreeBuffer( Bucket );
+	}
+    }
+
+    /* Things that happen after we're connected */
+    if( (NewState & SEL_READ) ) {
+	TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n",
+			       IsListEmpty(&Connection->ReceiveRequest) ?
+			       "empty" : "nonempty"));
+
+	while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
+	    PIRP Irp;
+	    OSK_UINT RecvLen = 0, Received = 0;
+	    OSK_PCHAR RecvBuffer = 0;
+	    PMDL Mdl;
+	    NTSTATUS Status;
+
+	    Entry = RemoveHeadList( &Connection->ReceiveRequest );
+	    Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+	    Complete = Bucket->Request.RequestNotifyObject;
+
+	    TI_DbgPrint(DEBUG_TCP,
+			("Readable, Completing read request %x\n", 
+			 Bucket->Request));
+
+	    Irp = Bucket->Request.RequestContext;
+	    Mdl = Irp->MdlAddress;
+
+	    TI_DbgPrint(DEBUG_TCP,
+			("Getting the user buffer from %x\n", Mdl));
+
+	    NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen );
+
+	    TI_DbgPrint(DEBUG_TCP,
+			("Reading %d bytes to %x\n", RecvLen, RecvBuffer));
+
+	    TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
+	    TI_DbgPrint
+		(DEBUG_TCP, 
+		 ("Connection->SocketContext: %x\n", 
+		  Connection->SocketContext));
+	    TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer));
+	    
+	    Status = TCPTranslateError
+		( OskitTCPRecv( Connection->SocketContext,
+				RecvBuffer,
+				RecvLen,
+				&Received,
+				0 ) );
+
+	    TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Received));
+	    
+	    if( Status == STATUS_SUCCESS ) {
+		TI_DbgPrint(DEBUG_TCP,("Received %d bytes with status %x\n",
+				       Received, Status));
+		
+		TI_DbgPrint(DEBUG_TCP,
+			    ("Completing Receive Request: %x\n", 
+			     Bucket->Request));
+
+		Complete( Bucket->Request.RequestContext,
+			  STATUS_SUCCESS, Received );
+		CompletedOne = TRUE;
+	    } else if( Status == STATUS_PENDING ) {
+		InsertHeadList( &Connection->ReceiveRequest,
+				&Bucket->Entry );
+		break;
+	    } else {
+		TI_DbgPrint(DEBUG_TCP,
+			    ("Completing Receive request: %x %x\n",
+			     Bucket->Request, Status));
+		Complete( Bucket->Request.RequestContext, Status, 0 );
+		CompletedOne = TRUE;
+	    }
+	}
+    }
+    if( NewState & SEL_FIN ) {
+	TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
+	
+	while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
+	    Entry = RemoveHeadList( &Connection->ReceiveRequest );
+	    Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+	    Complete = Bucket->Request.RequestNotifyObject;
+
+	    Complete( Bucket->Request.RequestContext, STATUS_SUCCESS, 0 );
+	}
+    }
+
+    Connection->Signalled = FALSE;
+}
+
+VOID DrainSignals() {
+    PCONNECTION_ENDPOINT Connection;
+    PLIST_ENTRY ListEntry;
+
+    while( !IsListEmpty( &SignalledConnections ) ) {
+	ListEntry = RemoveHeadList( &SignalledConnections );
+	Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT,
+					SignalList );
+	HandleSignalledConnection( Connection, Connection->SignalState );
+    }
+}
+
 PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) {
     PCONNECTION_ENDPOINT Connection = 
 	ExAllocatePool(NonPagedPool, sizeof(CONNECTION_ENDPOINT));
@@ -36,9 +162,6 @@
     /* Save client context pointer */
     Connection->ClientContext = ClientContext;
     
-    /* Initialize received segments queue */
-    InitializeListHead(&Connection->ReceivedSegments);
-    
     return Connection;
 }
 
@@ -52,7 +175,7 @@
 		    UINT Family, UINT Type, UINT Proto ) {
     NTSTATUS Status;
 
-    TI_DbgPrint(MID_TRACE,("Called: Connection %x, Family %d, Type %d, "
+    TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
 			   "Proto %d\n",
 			   Connection, Family, Type, Proto));
 
@@ -65,7 +188,7 @@
 
     ASSERT_KM_POINTER(Connection->SocketContext);
 
-    TI_DbgPrint(MID_TRACE,("Connection->SocketContext %x\n",
+    TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
 			   Connection->SocketContext));
 
     TcpipRecursiveMutexLeave( &TCPLock );
@@ -73,17 +196,16 @@
     return Status;
 }
 
-VOID TCPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
+VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
 /*
  * FUNCTION: Receives and queues TCP data
  * ARGUMENTS:
- *     NTE      = Pointer to net table entry which the packet was received on
  *     IPPacket = Pointer to an IP packet that was received
  * NOTES:
  *     This is the low level interface for receiving TCP data
  */
 {
-    TI_DbgPrint(MID_TRACE,("Sending packet %d (%d) to oskit\n", 
+    TI_DbgPrint(DEBUG_TCP,("Sending packet %d (%d) to oskit\n", 
 			   IPPacket->TotalSize,
 			   IPPacket->HeaderSize));
 
@@ -93,6 +215,8 @@
 			     IPPacket->TotalSize, 
 			     IPPacket->HeaderSize );
 
+    DrainSignals();
+
     TcpipRecursiveMutexLeave( &TCPLock );
 }
 
@@ -142,6 +266,7 @@
     TcpipRecursiveMutexInit( &TCPLock );
     ExInitializeFastMutex( &SleepingThreadsLock );
     InitializeListHead( &SleepingThreadsList );    
+    InitializeListHead( &SignalledConnections );
 
     RegisterOskitTCPEventHandlers( &EventHandlers );
     InitOskitTCP();
@@ -200,7 +325,7 @@
     default: Status = STATUS_INVALID_CONNECTION; break;
     }
 
-    TI_DbgPrint(MID_TRACE,("Error %d -> %x\n", OskitError, Status));
+    TI_DbgPrint(DEBUG_TCP,("Error %d -> %x\n", OskitError, Status));
     return Status;
 }
 
@@ -213,7 +338,7 @@
     PIP_ADDRESS LocalAddress;
     USHORT LocalPort;
 
-    TI_DbgPrint(MID_TRACE,("Called\n"));
+    TI_DbgPrint(DEBUG_TCP,("Called\n"));
 
     Status = AddrBuildAddress
 	((PTA_ADDRESS)ConnInfo->LocalAddress,
@@ -231,7 +356,7 @@
 			   &AddressToBind, 
 			   sizeof(AddressToBind));
 
-    TI_DbgPrint(MID_TRACE,("Leaving %x\n", Status));
+    TI_DbgPrint(DEBUG_TCP,("Leaving %x\n", Status));
 
     return Status;
 }
@@ -245,7 +370,7 @@
   PVOID Context ) {
     NTSTATUS Status;
     SOCKADDR_IN AddressToConnect = { 0 }, AddressToBind = { 0 };
-    PIP_ADDRESS RemoteAddress;
+    IP_ADDRESS RemoteAddress;
     USHORT RemotePort;
     PTDI_BUCKET Bucket;
 
@@ -268,11 +393,11 @@
 	 &RemotePort);
 
     DbgPrint("Connecting to address %x:%x\n",
-	     RemoteAddress->Address.IPv4Address,
+	     RemoteAddress.Address.IPv4Address,
 	     RemotePort);
 
     if (!NT_SUCCESS(Status)) {
-	TI_DbgPrint(MID_TRACE, ("Could not AddrBuildAddress in TCPConnect\n"));
+	TI_DbgPrint(DEBUG_TCP, ("Could not AddrBuildAddress in TCPConnect\n"));
 	return Status;
     }
     
@@ -285,14 +410,15 @@
 		  sizeof(AddressToBind) );
 
     memcpy( &AddressToConnect.sin_addr, 
-	    &RemoteAddress->Address.IPv4Address,
+	    &RemoteAddress.Address.IPv4Address,
 	    sizeof(AddressToConnect.sin_addr) );
     AddressToConnect.sin_port = RemotePort;
 
-    Status = OskitTCPConnect(Connection->SocketContext,
-			     Connection,
-			     &AddressToConnect, 
-			     sizeof(AddressToConnect));
+    Status = TCPTranslateError
+	( OskitTCPConnect( Connection->SocketContext,
+			   Connection,
+			   &AddressToConnect, 
+			   sizeof(AddressToConnect) ) );
 
     TcpipRecursiveMutexLeave( &TCPLock );
     
@@ -302,19 +428,60 @@
 	return Status;
 }
 
+NTSTATUS TCPDisconnect
+( PCONNECTION_ENDPOINT Connection,
+  UINT Flags,
+  PTDI_CONNECTION_INFORMATION ConnInfo,
+  PTDI_CONNECTION_INFORMATION ReturnInfo,
+  PTCP_COMPLETION_ROUTINE Complete,
+  PVOID Context ) {
+    NTSTATUS Status;
+    
+    TI_DbgPrint(DEBUG_TCP,("started\n"));
+
+    TcpipRecursiveMutexEnter( &TCPLock, TRUE );
+
+    switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
+    case 0:
+    case TDI_DISCONNECT_ABORT:
+	Flags = 0;
+	break;
+
+    case TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE:
+	Flags = 2;
+	break;
+
+    case TDI_DISCONNECT_RELEASE:
+	Flags = 1;
+	break;
+    }
+
+    Status = TCPTranslateError
+	( OskitTCPShutdown( Connection->SocketContext, Flags ) );
+
+    TcpipRecursiveMutexLeave( &TCPLock );
+    
+    TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));
+
+    return Status;
+}
+
 NTSTATUS TCPClose
 ( PCONNECTION_ENDPOINT Connection ) {
     NTSTATUS Status;
     
-    TI_DbgPrint(MID_TRACE,("TCPClose started\n"));
+    TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
 
     TcpipRecursiveMutexEnter( &TCPLock, TRUE );
 
     Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
 
+    if( Connection->Signalled ) 
+	RemoveEntryList( &Connection->SignalList );
+
     TcpipRecursiveMutexLeave( &TCPLock );
     
-    TI_DbgPrint(MID_TRACE,("TCPClose finished %x\n", Status));
+    TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
 
     return Status;
 }
@@ -326,9 +493,9 @@
   PVOID Context) {
    NTSTATUS Status;
 
-   TI_DbgPrint(MID_TRACE,("TCPListen started\n"));
+   TI_DbgPrint(DEBUG_TCP,("TCPListen started\n"));
 
-   TI_DbgPrint(MID_TRACE,("Connection->SocketContext %x\n",
+   TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
      Connection->SocketContext));
 
    ASSERT(Connection);
@@ -341,7 +508,7 @@
    
    TcpipRecursiveMutexLeave( &TCPLock );
 
-   TI_DbgPrint(MID_TRACE,("TCPListen finished %x\n", Status));
+   TI_DbgPrint(DEBUG_TCP,("TCPListen finished %x\n", Status));
    
    return Status;
 }
@@ -351,12 +518,25 @@
   VOID **NewSocketContext ) {
    NTSTATUS Status;
 
-   TI_DbgPrint(MID_TRACE,("TCPAccept started\n"));
+   TI_DbgPrint(DEBUG_TCP,("TCPAccept started\n"));
    Status = STATUS_UNSUCCESSFUL;
-   TI_DbgPrint(MID_TRACE,("TCPAccept finished %x\n", Status));
+   TI_DbgPrint(DEBUG_TCP,("TCPAccept finished %x\n", Status));
    return Status;
 }
 
+VOID TCPCancelReceiveRequest( PVOID Context ) {
+    PLIST_ENTRY ListEntry;
+    PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)Context;
+
+    TcpipRecursiveMutexEnter( &TCPLock, TRUE );
+    for( ListEntry = Connection->ReceiveRequest.Flink; 
+	 ListEntry != &Connection->ReceiveRequest;
+	 ListEntry = ListEntry->Flink ) {
+	
+    }
+    TcpipRecursiveMutexLeave( &TCPLock );
+}
+
 NTSTATUS TCPReceiveData
 ( PCONNECTION_ENDPOINT Connection,
   PNDIS_BUFFER Buffer,
@@ -370,7 +550,7 @@
     NTSTATUS Status;
     PTDI_BUCKET Bucket;
 
-    TI_DbgPrint(MID_TRACE,("Called for %d bytes\n", ReceiveLength));
+    TI_DbgPrint(DEBUG_TCP,("Called for %d bytes\n", ReceiveLength));
 
     ASSERT_KM_POINTER(Connection->SocketContext);
 
@@ -378,7 +558,7 @@
 
     NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
 
-    TI_DbgPrint(MID_TRACE,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
+    TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
 
     Status = TCPTranslateError
 	( OskitTCPRecv
@@ -387,16 +567,15 @@
 	    DataLen,
 	    &Received,
 	    ReceiveFlags ) );
-
-    TI_DbgPrint(MID_TRACE,("OskitTCPReceive: %x, %d\n", Status, Received));
+    
+    TI_DbgPrint(DEBUG_TCP,("OskitTCPReceive: %x, %d\n", Status, Received));
 
     /* Keep this request around ... there was no data yet */
-    if( Status == STATUS_PENDING || 
-	(Status == STATUS_SUCCESS && Received == 0) ) {
+    if( Status == STATUS_PENDING ) {
 	/* Freed in TCPSocketState */
 	Bucket = ExAllocatePool( NonPagedPool, sizeof(*Bucket) );
 	if( !Bucket ) {
-	    TI_DbgPrint(MID_TRACE,("Failed to allocate bucket\n"));
+	    TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
 	    TcpipRecursiveMutexLeave( &TCPLock );
 	    return STATUS_NO_MEMORY;
 	}
@@ -404,17 +583,18 @@
 	Bucket->Request.RequestNotifyObject = Complete;
 	Bucket->Request.RequestContext = Context;
 	*BytesReceived = 0;
+
 	InsertHeadList( &Connection->ReceiveRequest, &Bucket->Entry );
 	Status = STATUS_PENDING;
-	TI_DbgPrint(MID_TRACE,("Queued read irp\n"));
+	TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
     } else {
-	TI_DbgPrint(MID_TRACE,("Got status %x, bytes %d\n", Status, Received));
+	TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Received));
 	*BytesReceived = Received;
     }
 
     TcpipRecursiveMutexLeave( &TCPLock );
 
-    TI_DbgPrint(MID_TRACE,("Status %x\n", Status));
+    TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
 
     return Status;
 }
@@ -431,8 +611,8 @@
 
     TcpipRecursiveMutexEnter( &TCPLock, TRUE );
 
-    TI_DbgPrint(MID_TRACE,("Connection = %x\n", Connection));
-    TI_DbgPrint(MID_TRACE,("Connection->SocketContext = %x\n",
+    TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection));
+    TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
 			   Connection->SocketContext));
 
     Status = OskitTCPSend( Connection->SocketContext, 
@@ -445,11 +625,12 @@
 
 VOID TCPTimeout(VOID) { 
     static int Times = 0;
+    TcpipRecursiveMutexEnter( &TCPLock, TRUE );
     if( (Times++ % 5) == 0 ) {
-	TcpipRecursiveMutexEnter( &TCPLock, TRUE );
 	TimerOskitTCP();
-	TcpipRecursiveMutexLeave( &TCPLock );
     }
+    DrainSignals();
+    TcpipRecursiveMutexLeave( &TCPLock );
 }
 
 /* EOF */

reactos/drivers/lib/ip/transport/udp
udp.c 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- udp.c	15 Nov 2004 18:24:57 -0000	1.6
+++ udp.c	8 Dec 2004 21:56:51 -0000	1.6.2.1
@@ -197,7 +197,7 @@
     IP_ADDRESS RemoteAddress;
     USHORT RemotePort;
     NTSTATUS Status;
-    PROUTE_CACHE_NODE RCN;
+    PNEIGHBOR_CACHE_ENTRY NCE;
 
     TI_DbgPrint(MID_TRACE,("Sending Datagram(%x %x %x %d)\n",
 			   AddrFile, ConnInfo, BufferData, DataSize));
@@ -218,7 +218,7 @@
     Status = BuildUDPPacket( &Packet,
 			     &RemoteAddress,
 			     RemotePort,
-			     &AddrFile->ADE->Address,
+			     &AddrFile->Address,
 			     AddrFile->Port,
 			     BufferData,
 			     DataSize );
@@ -226,12 +226,10 @@
     if( !NT_SUCCESS(Status) ) 
 	return Status;
 
-    Status = RouteGetRouteToDestination( &RemoteAddress, NULL, &RCN );
-
-    if( !NT_SUCCESS(Status) )
-	return Status;
+    if(!(NCE = RouteGetRouteToDestination( &RemoteAddress )))
+	return STATUS_UNSUCCESSFUL;
 
-    IPSendDatagram( &Packet, RCN, UDPSendPacketComplete, NULL );
+    IPSendDatagram( &Packet, NCE, UDPSendPacketComplete, NULL );
 
     return STATUS_SUCCESS;
 }
@@ -341,7 +339,7 @@
 }
 
 
-VOID UDPReceive(PNET_TABLE_ENTRY NTE, PIP_PACKET IPPacket)
+VOID UDPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
 /*
  * FUNCTION: Receives and queues a UDP datagram
  * ARGUMENTS:

reactos/drivers/lib/oskittcp/include
oskittcp.h 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- oskittcp.h	7 Nov 2004 20:37:21 -0000	1.7
+++ oskittcp.h	8 Dec 2004 21:56:51 -0000	1.7.2.1
@@ -107,6 +107,7 @@
 extern void DeinitOskitTCP();
 extern void TimerOskitTCP();
 extern void OskitDumpBuffer( OSK_PCHAR Data, OSK_UINT Len );
+extern int  OskitTCPShutdown( void *socket, int disconn_type );
 extern int  OskitTCPSocket( void *Connection, void **ConnectionContext,
 			    int Af, int Type, int Proto );
 extern void RegisterOskitTCPEventHandlers

reactos/drivers/lib/oskittcp/oskittcp
interface.c 1.16 -> 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- interface.c	21 Nov 2004 20:54:52 -0000	1.16
+++ interface.c	8 Dec 2004 21:56:51 -0000	1.16.2.1
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <oskittcp.h>
 #include <oskitdebug.h>
 #include <sys/param.h>
@@ -23,7 +22,8 @@
 
 OSKITTCP_EVENT_HANDLERS OtcpEvent = { 0 };
 
-OSK_UINT OskitDebugTraceLevel = OSK_DEBUG_ULTRA;
+//OSK_UINT OskitDebugTraceLevel = OSK_DEBUG_ULTRA;
+OSK_UINT OskitDebugTraceLevel = 0;
 
 /* SPL */
 unsigned cpl;
@@ -257,6 +257,11 @@
     return (error);    
 }
 
+int OskitTCPShutdown( void *socket, int disconn_type ) {
+    struct socket *so = socket;
+    return soshutdown( socket, disconn_type );
+}
+
 int OskitTCPClose( void *socket ) {
     struct socket *so = socket;
     so->so_connection = 0;
@@ -333,9 +338,6 @@
     inp->inp_lport = LocalPort;
     inp->inp_faddr.s_addr = RemoteAddress;
     inp->inp_fport = RemotePort;
-    DbgPrint("OSKIT: SET ADDR %x:%x -> %x:%x\n", 
-	     LocalAddress, LocalPort,
-	     RemoteAddress, RemotePort);
 }
 
 void OskitTCPGetAddress( void *socket, 
@@ -350,9 +352,6 @@
 	*LocalPort = inp->inp_lport;
 	*RemoteAddress = inp->inp_faddr.s_addr;
 	*RemotePort = inp->inp_fport;
-	DbgPrint("OSKIT: GET ADDR %x:%x -> %x:%x\n", 
-		 *LocalAddress, *LocalPort,
-		 *RemoteAddress, *RemotePort);
     }
 }
 

reactos/drivers/lib/oskittcp/oskittcp
ip_output.c 1.4 -> 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- ip_output.c	23 Sep 2004 03:02:29 -0000	1.4
+++ ip_output.c	8 Dec 2004 21:56:51 -0000	1.4.6.1
@@ -361,9 +361,14 @@
 	    ip->ip_sum = in_cksum(m, hlen);
 #ifdef __REACTOS__
 	    if( OtcpEvent.PacketSend ) {
-		OS_DbgPrint(OSK_MID_TRACE,("Mark\n"));
+		struct mbuf *new_m;
+		MGET( new_m, M_DONTWAIT, 0 );
+		MCLGET( new_m, M_DONTWAIT );
+		m_copydata( m, 0, htons(ip->ip_len), new_m->m_data );
+		new_m->m_len = htons(ip->ip_len);
 		error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
-					      m->m_data, m->m_len );
+					      new_m->m_data, new_m->m_len );
+		m_free( new_m );
 		goto done;
 	    }
 #else
@@ -485,9 +490,15 @@
 			m_freem(m);
 #else
 	if( error == 0 && OtcpEvent.PacketSend ) {
-	    OS_DbgPrint(OSK_MID_TRACE,("Mark\n"));
+	    struct mbuf *new_m;
+	    MGET( new_m, M_DONTWAIT, 0 );
+	    MCLGET( new_m, M_DONTWAIT );
+	    m_copydata( m, 0, htons(ip->ip_len), new_m->m_data );
+	    new_m->m_len = htons(ip->ip_len);
 	    error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
-					  m->m_data, m->m_len );
+					  new_m->m_data, new_m->m_len );
+	    m_free( new_m );
+	    goto done;
 	}
 	
 	OS_DbgPrint(OSK_MID_TRACE,("Error from upper layer: %d\n", error));

reactos/drivers/lib/oskittcp/oskittcp
tcp_output.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- tcp_output.c	23 Sep 2004 03:02:29 -0000	1.5
+++ tcp_output.c	8 Dec 2004 21:56:51 -0000	1.5.6.1
@@ -576,7 +576,6 @@
 	else
 		ti->ti_seq = htonl(tp->snd_max);
 	ti->ti_ack = htonl(tp->rcv_nxt);
-	printf("ti->ti_ack = %d\n", ti->ti_ack);
 
 	if (optlen) {
 		(void)memcpy(ti + 1, opt, optlen);

reactos/drivers/net/afd/afd
connect.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- connect.c	21 Nov 2004 20:54:52 -0000	1.5
+++ connect.c	8 Dec 2004 21:56:51 -0000	1.5.2.1
@@ -1,4 +1,4 @@
-/* $Id: connect.c,v 1.5 2004/11/21 20:54:52 arty Exp $
+/* $Id: connect.c,v 1.5.2.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/connect.c
@@ -53,10 +53,9 @@
     AFD_DbgPrint(MID_TRACE,("Called: FCB %x, FO %x\n", 
 			    Context, FCB->FileObject));
 
-    /* Check the result of the connect operation */
-    /* Since the previous does not return until we come through here, we do
-     * not need to relock. */
-    /* if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); */
+    /* I was wrong about this before as we can have pending writes to a not
+     * yet connected socket */
+    if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
 
     AFD_DbgPrint(MID_TRACE,("Irp->IoStatus.Status = %x\n", 
 			    Irp->IoStatus.Status));
@@ -118,7 +117,7 @@
 	    Status = STATUS_SUCCESS;
     }
 
-    /* SocketStateUnlock( FCB ); */
+    SocketStateUnlock( FCB );
 
     AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
     
@@ -202,6 +201,11 @@
 				 FCB );
 
 	    ExFreePool( TargetAddress );
+
+	    AFD_DbgPrint(MID_TRACE,("Queueing IRP %x\n", Irp));
+	    
+	    if( Status == STATUS_PENDING ) 
+		return LeaveIrpUntilLater( FCB, Irp, FUNCTION_CONNECT );
 	} else Status = STATUS_NO_MEMORY;
 	break;
 

reactos/drivers/net/afd/afd
info.c 1.4 -> 1.4.8.1
diff -u -r1.4 -r1.4.8.1
--- info.c	29 Jul 2004 04:09:06 -0000	1.4
+++ info.c	8 Dec 2004 21:56:51 -0000	1.4.8.1
@@ -1,4 +1,4 @@
-/* $Id: info.c,v 1.4 2004/07/29 04:09:06 arty Exp $
+/* $Id: info.c,v 1.4.8.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/info.c
@@ -40,6 +40,10 @@
 	case AFD_INFO_GROUP_ID_TYPE:
 	    InfoReq->Information.Ulong = 0; /* What is group id */
 	    break;
+
+	case AFD_INFO_BLOCKING_MODE:
+	    InfoReq->Information.Ulong = 0;
+	    break;
 	    
 	default:
 	    AFD_DbgPrint(MID_TRACE,("Unknown info id %x\n", 

reactos/drivers/net/afd/afd
main.c 1.13 -> 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- main.c	21 Nov 2004 20:54:52 -0000	1.13
+++ main.c	8 Dec 2004 21:56:51 -0000	1.13.2.1
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.13 2004/11/21 20:54:52 arty Exp $
+/* $Id: main.c,v 1.13.2.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/main.c
@@ -47,9 +47,9 @@
     PFILE_OBJECT FileObject;
     PAFD_DEVICE_EXTENSION DeviceExt;
     PFILE_FULL_EA_INFORMATION EaInfo;
-    PAFD_CREATE_PACKET ConnectInfo;
+    PAFD_CREATE_PACKET ConnectInfo = NULL;
     ULONG EaLength;
-    PWCHAR EaInfoValue;
+    PWCHAR EaInfoValue = NULL;
     UINT Disposition, i;
 
     AFD_DbgPrint(MID_TRACE,
@@ -62,22 +62,18 @@
     Irp->IoStatus.Information = 0;
     
     EaInfo = Irp->AssociatedIrp.SystemBuffer;
-    ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
-    EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
-
-    if(!EaInfo) {
-	AFD_DbgPrint(MIN_TRACE, ("No EA Info in IRP.\n"));
-	Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
-	IoCompleteRequest( Irp, IO_NO_INCREMENT );
-	return STATUS_INVALID_PARAMETER;
-    }
-
-    EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
-	EaInfo->EaNameLength +
-	EaInfo->EaValueLength;
-
-    AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n", 
-			    EaInfo, EaInfoValue));
+    
+    if( EaInfo ) {
+	ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
+	EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
+	
+	EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
+	    EaInfo->EaNameLength +
+	    EaInfo->EaValueLength;
+	
+	AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n", 
+				EaInfo, EaInfoValue));
+    }
 
     AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
 
@@ -88,11 +84,11 @@
 	return STATUS_NO_MEMORY;
     }
 
-    AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %x (FileObject %x Flags %x)\n", FCB, FileObject, ConnectInfo->EndpointFlags));
+    AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %x (FileObject %x Flags %x)\n", FCB, FileObject, ConnectInfo ? ConnectInfo->EndpointFlags : 0));
 
     RtlZeroMemory( FCB, sizeof( *FCB ) );
 
-    FCB->Flags = ConnectInfo->EndpointFlags;
+    FCB->Flags = ConnectInfo ? ConnectInfo->EndpointFlags : 0;
     FCB->State = SOCKET_STATE_CREATED;
     FCB->FileObject = FileObject;
     FCB->DeviceExt = DeviceExt;
@@ -111,24 +107,29 @@
 
     AFD_DbgPrint(MID_TRACE,("%x: Checking command channel\n", FCB));
 
-    FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
-    FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
-    FCB->TdiDeviceName.Buffer = 
-      ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
-    RtlCopyMemory( FCB->TdiDeviceName.Buffer,
-		   ConnectInfo->TransportName,
-		   FCB->TdiDeviceName.Length );
-
-    if( !FCB->TdiDeviceName.Buffer ) {
-      ExFreePool(FCB);
-      AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
-      Irp->IoStatus.Status = STATUS_NO_MEMORY;
-      IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
-      return STATUS_NO_MEMORY;
+    if( ConnectInfo ) {
+	FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
+	FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
+	FCB->TdiDeviceName.Buffer = 
+	    ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
+	RtlCopyMemory( FCB->TdiDeviceName.Buffer,
+		       ConnectInfo->TransportName,
+		       FCB->TdiDeviceName.Length );
+
+	if( !FCB->TdiDeviceName.Buffer ) {
+	    ExFreePool(FCB);
+	    AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
+	    Irp->IoStatus.Status = STATUS_NO_MEMORY;
+	    IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+	    return STATUS_NO_MEMORY;
+	}
+
+	AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n", 
+				EaInfo->EaName, &FCB->TdiDeviceName));
+    } else {
+	AFD_DbgPrint(MID_TRACE,("Success: Control connection\n"));
     }
 
-    AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n", 
-			    EaInfo->EaName, &FCB->TdiDeviceName));
     FileObject->FsContext = FCB;
     Irp->IoStatus.Status = STATUS_SUCCESS;
     IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
@@ -226,6 +227,49 @@
 }
 
 NTSTATUS STDCALL
+AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, 
+	      PIO_STACK_LOCATION IrpSp) {
+    PFILE_OBJECT FileObject = IrpSp->FileObject;
+    PAFD_FCB FCB = FileObject->FsContext;
+    PAFD_DISCONNECT_INFO DisReq;
+    IO_STATUS_BLOCK Iosb;
+    PTDI_CONNECTION_INFORMATION ConnInfo;
+    NTSTATUS Status;
+    USHORT Flags = 0;
+
+    if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
+
+    if( !(DisReq = LockRequest( Irp, IrpSp )) ) 
+	return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY,
+				       Irp, 0, NULL, FALSE );
+
+    Status = TdiBuildNullConnectionInfo
+	( &ConnInfo, FCB->RemoteAddress->Address[0].AddressType );
+
+    if( !NT_SUCCESS(Status) || !ConnInfo ) 
+	return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY,
+				       Irp, 0, NULL, TRUE );
+
+    if( DisReq->DisconnectType & AFD_DISCONNECT_SEND )
+	Flags |= TDI_DISCONNECT_RELEASE;
+    if( DisReq->DisconnectType & AFD_DISCONNECT_RECV )
+	Flags |= TDI_DISCONNECT_ABORT;
+
+    Status = TdiDisconnect( FCB->Connection.Object,
+			    &DisReq->Timeout,
+			    Flags,
+			    &Iosb,
+			    NULL, 
+			    NULL,
+			    FCB->AddressFrom,
+			    ConnInfo);
+    
+    ExFreePool( ConnInfo );
+
+    return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL, TRUE );
+}
+
+NTSTATUS STDCALL
 AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
     PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
@@ -304,44 +348,81 @@
 	case IOCTL_AFD_SET_CONTEXT:
 	    return AfdSetContext( DeviceObject, Irp, IrpSp );
 
-  case IOCTL_AFD_WAIT_FOR_LISTEN:
+	case IOCTL_AFD_WAIT_FOR_LISTEN:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_WAIT_FOR_LISTEN\n"));
-  case IOCTL_AFD_ACCEPT:
+	    break;
+
+	case IOCTL_AFD_ACCEPT:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_ACCEPT\n"));
-  case IOCTL_AFD_DISCONNECT:
-	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_DISCONNECT\n"));
-  case IOCTL_AFD_GET_TDI_HANDLES:
+	    break;
+
+	case IOCTL_AFD_DISCONNECT:
+	    return AfdDisconnect( DeviceObject, Irp, IrpSp );
+
+	case IOCTL_AFD_GET_TDI_HANDLES:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
-  case IOCTL_AFD_SET_INFO:
+	    break;
+
+	case IOCTL_AFD_SET_INFO:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_INFO\n"));
-  case IOCTL_AFD_SET_CONNECT_DATA:
+	    break;
+
+	case IOCTL_AFD_SET_CONNECT_DATA:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_CONNECT_DATA\n"));
-  case IOCTL_AFD_SET_CONNECT_OPTIONS:
+	    break;
+
+	case IOCTL_AFD_SET_CONNECT_OPTIONS:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_CONNECT_OPTIONS\n"));
-  case IOCTL_AFD_SET_DISCONNECT_DATA:
+	    break;
+
+	case IOCTL_AFD_SET_DISCONNECT_DATA:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_DISCONNECT_DATA\n"));
-  case IOCTL_AFD_SET_DISCONNECT_OPTIONS:
+	    break;
+
+	case IOCTL_AFD_SET_DISCONNECT_OPTIONS:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_DISCONNECT_OPTIONS\n"));
-  case IOCTL_AFD_GET_CONNECT_DATA:
+	    break;
+
+	case IOCTL_AFD_GET_CONNECT_DATA:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_CONNECT_DATA\n"));
-  case IOCTL_AFD_GET_CONNECT_OPTIONS:
+	    break;
+
+	case IOCTL_AFD_GET_CONNECT_OPTIONS:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_CONNECT_OPTIONS\n"));
-  case IOCTL_AFD_GET_DISCONNECT_DATA:
+	    break;
+
+	case IOCTL_AFD_GET_DISCONNECT_DATA:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_DISCONNECT_DATA\n"));
-  case IOCTL_AFD_GET_DISCONNECT_OPTIONS:
+	    break;
+
+	case IOCTL_AFD_GET_DISCONNECT_OPTIONS:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_DISCONNECT_OPTIONS\n"));
-  case IOCTL_AFD_SET_CONNECT_DATA_SIZE:
+	    break;
+
+	case IOCTL_AFD_SET_CONNECT_DATA_SIZE:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_CONNECT_DATA_SIZE\n"));
-  case IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE:
+	    break;
+
+	case IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE\n"));
-  case IOCTL_AFD_SET_DISCONNECT_DATA_SIZE:
+	    break;
+
+	case IOCTL_AFD_SET_DISCONNECT_DATA_SIZE:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_DISCONNECT_DATA_SIZE\n"));
-  case IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE:
+	    break;
+
+	case IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE\n"));
-  case IOCTL_AFD_DEFER_ACCEPT:
+	    break;
+
+	case IOCTL_AFD_DEFER_ACCEPT:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_DEFER_ACCEPT\n"));
-  case IOCTL_AFD_GET_PENDING_CONNECT_DATA:
+	    break;
+
+	case IOCTL_AFD_GET_PENDING_CONNECT_DATA:
 	    AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_PENDING_CONNECT_DATA\n"));
+	    break;
+
 	default:
 	    Status = STATUS_NOT_IMPLEMENTED;
 	    Irp->IoStatus.Information = 0;

reactos/drivers/net/afd/afd
read.c 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- read.c	21 Nov 2004 20:54:52 -0000	1.12
+++ read.c	8 Dec 2004 21:56:51 -0000	1.12.2.1
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.12 2004/11/21 20:54:52 arty Exp $
+/* $Id: read.c,v 1.12.2.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/read.c
@@ -23,6 +23,10 @@
     *TotalBytesCopied = 0;
     PAFD_MAPBUF Map;
 
+    AFD_DbgPrint(MID_TRACE,("Called, BytesAvailable = %d\n",
+			    BytesAvailable));
+
+    if( FCB->PollState & AFD_EVENT_CLOSE ) return STATUS_SUCCESS;
     if( !BytesAvailable ) return STATUS_PENDING;
 
     Map = (PAFD_MAPBUF)(RecvReq->BufferArray + RecvReq->BufferCount);
@@ -64,6 +68,31 @@
     return STATUS_SUCCESS;
 }
 
+VOID ProcessClose( PAFD_FCB FCB ) {
+    PLIST_ENTRY NextIrpEntry;
+    PIRP NextIrp;
+
+    AFD_DbgPrint(MID_TRACE,("Socket shutdown from remote side\n"));
+    
+    /* Kill remaining recv irps */
+    while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_RECV] ) ) {
+	NextIrpEntry = 
+	    RemoveHeadList(&FCB->PendingIrpList[FUNCTION_RECV]);
+	NextIrp = 
+	    CONTAINING_RECORD(NextIrpEntry, IRP, Tail.Overlay.ListEntry);
+	AFD_DbgPrint(MID_TRACE,("Completing recv %x (%x)\n", 
+				NextIrp, STATUS_END_OF_FILE));
+	NextIrp->IoStatus.Status = STATUS_SUCCESS;
+	NextIrp->IoStatus.Information = 0;
+	IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
+    }
+    
+    /* Handle closing signal */
+    FCB->PollState |= AFD_EVENT_CLOSE;
+
+    PollReeval( FCB->DeviceExt, FCB->FileObject );
+}
+
 NTSTATUS DDKAPI ReceiveComplete
 ( PDEVICE_OBJECT DeviceObject,
   PIRP Irp,
@@ -78,10 +107,14 @@
     UINT TotalBytesCopied = 0;
 
     AFD_DbgPrint(MID_TRACE,("Called\n"));
-    
+
+    ASSERT_IRQL(APC_LEVEL);
+
     if( !SocketAcquireStateLock( FCB ) ) return Status;
 
     FCB->ReceiveIrp.InFlightRequest = NULL;
+    FCB->Recv.Content = Irp->IoStatus.Information;
+    FCB->Recv.BytesUsed = 0;
 
     if( FCB->State == SOCKET_STATE_CLOSED ) {
 	SocketStateUnlock( FCB );
@@ -89,10 +122,8 @@
 	return STATUS_SUCCESS;
     }
     
-    if( NT_SUCCESS(Irp->IoStatus.Status) ) {
-	/* Update the receive window */
-	FCB->Recv.Content = Irp->IoStatus.Information;
-	FCB->Recv.BytesUsed = 0;
+    if( NT_SUCCESS(Irp->IoStatus.Status) && 
+	Irp->IoStatus.Information ) {
 	/* Kick the user that receive would be possible now */
 	/* XXX Not implemented yet */
 
@@ -133,8 +164,7 @@
 	    }
 	}
 
-	if( NT_SUCCESS(Status) && FCB->Recv.Window && !FCB->Recv.Content &&
-	    NT_SUCCESS(Irp->IoStatus.Status) ) {
+	if( FCB->Recv.Window && !FCB->Recv.Content ) {
 	    AFD_DbgPrint(MID_TRACE,
 			 ("Exhausted our buffer.  Requesting new: %x\n", FCB));
 
@@ -149,25 +179,15 @@
 				 ReceiveComplete,
 				 FCB );
 
+	    if( Status == STATUS_SUCCESS && 
+		!FCB->ReceiveIrp.Iosb.Information ) {
+		ProcessClose( FCB );
+	    }
+
 	    SocketCalloutLeave( FCB );
-	} else
-	    FCB->PollState |= AFD_EVENT_RECEIVE;
+	} else Status = STATUS_SUCCESS;
     } else {
-	/* Kill remaining recv irps */
-	while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_RECV] ) ) {
-	    NextIrpEntry = 
-		RemoveHeadList(&FCB->PendingIrpList[FUNCTION_RECV]);
-	    NextIrp = 
-		CONTAINING_RECORD(NextIrpEntry, IRP, Tail.Overlay.ListEntry);
-	    AFD_DbgPrint(MID_TRACE,("Completing recv %x (%x)\n", 
-				    NextIrp, Status));
-	    Irp->IoStatus.Status = Status;
-	    Irp->IoStatus.Information = 0;
-	    IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
-	}
-
-	/* Handle closing signal */
-	FCB->PollState |= AFD_EVENT_CLOSE;
+	ProcessClose( FCB );
     }
 
     if( FCB->Recv.Content ) {
@@ -213,41 +233,70 @@
 
     /* Launch a new recv request if we have no data */
 
-    if( FCB->Recv.Window && !(FCB->Recv.Content - FCB->Recv.BytesUsed) && 
-	!FCB->ReceiveIrp.InFlightRequest ) {
+    if( !(FCB->PollState & AFD_EVENT_CLOSE ) ) {
+	AFD_DbgPrint(MID_TRACE,("Not EOF yet\n"));
+	if( FCB->Recv.Window && !(FCB->Recv.Content - FCB->Recv.BytesUsed) && 
+	    !FCB->ReceiveIrp.InFlightRequest ) {
+	    FCB->Recv.Content = 0;
+	    FCB->Recv.BytesUsed = 0;
+	    AFD_DbgPrint(MID_TRACE,("Replenishing buffer\n"));
+	    
+	    SocketCalloutEnter( FCB );
+	    
+	    Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
+				 FCB->Connection.Object,
+				 TDI_RECEIVE_NORMAL,
+				 FCB->Recv.Window,
+				 FCB->Recv.Size,
+				 &FCB->ReceiveIrp.Iosb,
+				 ReceiveComplete,
+				 FCB );
+
+	    if( Status == STATUS_SUCCESS ) {
+		if( !FCB->ReceiveIrp.Iosb.Information ) {
+		    AFD_DbgPrint(MID_TRACE,("Looks like an EOF\n"));
+		    ProcessClose( FCB );
+		}
+		FCB->Recv.Content = FCB->ReceiveIrp.Iosb.Information;
+	    }
+	    
+	    SocketCalloutLeave( FCB );
+	} else {
+	    AFD_DbgPrint(MID_TRACE,("There is probably more data here\n"));
+	    if( FCB->ReceiveIrp.InFlightRequest ) {
+		AFD_DbgPrint(MID_TRACE,("We're waiting on a previous irp\n"));
+		Status = STATUS_PENDING;
+	    } else {
+		AFD_DbgPrint(MID_TRACE,("The buffer is likely not empty\n"));
+		Status = STATUS_SUCCESS;
+	    }
+	}
+    } else {
+	AFD_DbgPrint(MID_TRACE,("EOF Happened already\n"));
 	FCB->Recv.Content = 0;
 	FCB->Recv.BytesUsed = 0;
-	AFD_DbgPrint(MID_TRACE,("Replenishing buffer\n"));
-
-	SocketCalloutEnter( FCB );
-
-	Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
-			     FCB->Connection.Object,
-			     TDI_RECEIVE_NORMAL,
-			     FCB->Recv.Window,
-			     FCB->Recv.Size,
-			     &FCB->ReceiveIrp.Iosb,
-			     ReceiveComplete,
-			     FCB );
+	Status = STATUS_SUCCESS;
 
-	SocketCalloutLeave( FCB );
-    } else Status = STATUS_SUCCESS;
+	ProcessClose( FCB );
+    }
 
-    if( NT_SUCCESS(Status) ) 
-	Status = TryToSatisfyRecvRequestFromBuffer
-	    ( FCB, RecvReq, &TotalBytesCopied );
+    if( NT_SUCCESS(Status) ) {
+	AFD_DbgPrint(MID_TRACE,("TryToSatisfy\n"));
+        Status = TryToSatisfyRecvRequestFromBuffer
+            ( FCB, RecvReq, &TotalBytesCopied );
+    }
     
     if( Status != STATUS_PENDING || RecvReq->AfdFlags & AFD_IMMEDIATE ) {
-	if( Status == STATUS_PENDING ) {
-	    AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
-	    Status = STATUS_CANT_WAIT;
-	    TotalBytesCopied = 0;
-	}
-	UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE );
-	return UnlockAndMaybeComplete( FCB, Status, Irp, 
-				       TotalBytesCopied, NULL, TRUE );
+       if( Status == STATUS_PENDING ) {
+           AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
+           Status = STATUS_CANT_WAIT;
+           TotalBytesCopied = 0;
+       }
+       UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE );
+       return UnlockAndMaybeComplete( FCB, Status, Irp, 
+				      TotalBytesCopied, NULL, TRUE );
     } else {
-	return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV );
+       return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV );
     }
 }
 

reactos/drivers/net/afd/afd
select.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- select.c	21 Nov 2004 20:54:52 -0000	1.7
+++ select.c	8 Dec 2004 21:56:51 -0000	1.7.2.1
@@ -1,4 +1,4 @@
-/* $Id: select.c,v 1.7 2004/11/21 20:54:52 arty Exp $
+/* $Id: select.c,v 1.7.2.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/select.c
@@ -50,7 +50,7 @@
     Poll->Irp->IoStatus.Information = Collected;
     CopyBackStatus( PollReq->Handles,
 		    PollReq->HandleCount );
-    UnlockHandles( PollReq->InternalUse, PollReq->HandleCount );
+    UnlockHandles( AFD_HANDLES(PollReq), PollReq->HandleCount );
     AFD_DbgPrint(MID_TRACE,("Completing\n"));
     IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
     RemoveEntryList( &Poll->ListEntry );
@@ -83,6 +83,30 @@
     AFD_DbgPrint(MID_TRACE,("Timeout\n"));
 }
 
+VOID KillExclusiveSelects( PAFD_DEVICE_EXTENSION DeviceExt ) {
+    KIRQL OldIrql;
+    PLIST_ENTRY ListEntry;
+    PAFD_ACTIVE_POLL Poll;
+    PIRP Irp;
+    PAFD_POLL_INFO PollReq;
+
+    KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
+    
+    for( ListEntry = DeviceExt->Polls.Flink;
+	 ListEntry != &DeviceExt->Polls;
+	 ListEntry = ListEntry->Flink ) {
+	Poll = CONTAINING_RECORD(ListEntry, AFD_ACTIVE_POLL, ListEntry);
+	if( Poll->Exclusive ) {
+	    Irp = Poll->Irp;
+	    PollReq = Irp->AssociatedIrp.SystemBuffer;
+	    ZeroEvents( PollReq->Handles, PollReq->HandleCount );
+	    SignalSocket( Poll, PollReq, STATUS_CANCELLED, 0 );
+	}
+    }
+
+    KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+}
+
 NTSTATUS STDCALL
 AfdSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp, 
 	   PIO_STACK_LOCATION IrpSp ) {
@@ -97,15 +121,19 @@
 	CopySize + sizeof(AFD_ACTIVE_POLL) - sizeof(AFD_POLL_INFO);
     KIRQL OldIrql;
     UINT i, Signalled = 0;
+    ULONG Exclusive = PollReq->Exclusive;
 
     AFD_DbgPrint(MID_TRACE,("Called (HandleCount %d Timeout %d)\n", 
 			    PollReq->HandleCount,
 			    (INT)(PollReq->Timeout.QuadPart)));
 
-    PollReq->InternalUse = 
-	LockHandles( PollReq->Handles, PollReq->HandleCount );
+    SET_AFD_HANDLES(PollReq,
+		    LockHandles( PollReq->Handles, PollReq->HandleCount ));
+
+    if( Exclusive ) KillExclusiveSelects( DeviceExt );
+	
 
-    if( !PollReq->InternalUse ) {
+    if( !AFD_HANDLES(PollReq) ) {
 	Irp->IoStatus.Status = STATUS_NO_MEMORY;
 	Irp->IoStatus.Information = -1;
 	IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
@@ -120,6 +148,7 @@
     if( Poll ) {
 	Poll->Irp = Irp;
 	Poll->DeviceExt = DeviceExt;
+	Poll->Exclusive = Exclusive;
 
 	KeInitializeTimerEx( &Poll->Timer, NotificationTimer );
 	KeSetTimer( &Poll->Timer, PollReq->Timeout, &Poll->TimeoutDpc );
@@ -132,14 +161,14 @@
 	InsertTailList( &DeviceExt->Polls, &Poll->ListEntry );
 
 	for( i = 0; i < PollReq->HandleCount; i++ ) {
-	    if( !PollReq->InternalUse[i].Handle ) continue;
+	    if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
 	    
-	    FileObject = (PFILE_OBJECT)PollReq->InternalUse[i].Handle;
+	    FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
 	    FCB = FileObject->FsContext;
 	    
 	    if( (FCB->PollState & AFD_EVENT_CLOSE) ||
 		(PollReq->Handles[i].Status & AFD_EVENT_CLOSE) ) {
-		PollReq->InternalUse[i].Handle = 0;
+		AFD_HANDLES(PollReq)[i].Handle = 0;
 		PollReq->Handles[i].Events = 0;
 		PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
 		Signalled++;
@@ -248,14 +277,14 @@
     ASSERT( KeGetCurrentIrql() == DISPATCH_LEVEL );
 
     for( i = 0; i < PollReq->HandleCount; i++ ) {
-	if( !PollReq->InternalUse[i].Handle ) continue;
+	if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
 
-	FileObject = (PFILE_OBJECT)PollReq->InternalUse[i].Handle;
+	FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
 	FCB = FileObject->FsContext;
 
 	if( (FCB->PollState & AFD_EVENT_CLOSE) ||
 	    (PollReq->Handles[i].Status & AFD_EVENT_CLOSE) ) {
-	    PollReq->InternalUse[i].Handle = 0;
+	    AFD_HANDLES(PollReq)[i].Handle = 0;
 	    PollReq->Handles[i].Events = 0;
 	    PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
 	    Signalled++;

reactos/drivers/net/afd/afd
tdi.c 1.21 -> 1.21.6.1
diff -u -r1.21 -r1.21.6.1
--- tdi.c	3 Oct 2004 21:16:27 -0000	1.21
+++ tdi.c	8 Dec 2004 21:56:51 -0000	1.21.6.1
@@ -286,7 +286,6 @@
   PDEVICE_OBJECT DeviceObject;
   IO_STATUS_BLOCK Iosb;
   NTSTATUS Status;
-  KEVENT Event;
 
   AFD_DbgPrint(MAX_TRACE, ("Called\n"));
 
@@ -294,12 +293,10 @@
 
   DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
 
-  KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
   *Irp = TdiBuildInternalDeviceControlIrp(TDI_CONNECT,             /* Sub function */
 					  DeviceObject,            /* Device object */
 					  ConnectionObject,        /* File object */
-					  &Event,                  /* Event */
+					  NULL,                    /* Event */
 					  &Iosb);                  /* Status */
   if (!*Irp) {
     return STATUS_INSUFFICIENT_RESOURCES;
@@ -314,7 +311,7 @@
                   RemoteAddress,          /* Request connection information */
                   RemoteAddress);         /* Return connection information */
 
-  Status = TdiCall(*Irp, DeviceObject, &Event, &Iosb);
+  Status = TdiCall(*Irp, DeviceObject, NULL, &Iosb);
 
   return Status;
 }
@@ -1089,4 +1086,58 @@
     return Status;
 }
 
+NTSTATUS TdiDisconnect(
+    PFILE_OBJECT TransportObject,
+    PLARGE_INTEGER Time,
+    USHORT Flags,
+    PIO_STATUS_BLOCK Iosb,
+    PIO_COMPLETION_ROUTINE CompletionRoutine,
+    PVOID CompletionContext,
+    PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
+    PTDI_CONNECTION_INFORMATION ReturnConnectionInfo) {
+    PDEVICE_OBJECT DeviceObject;
+    NTSTATUS Status;
+    KEVENT Event;
+    PIRP Irp;
+
+    DeviceObject = IoGetRelatedDeviceObject(TransportObject);
+
+    KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+    AFD_DbgPrint(MID_TRACE,("Called(TransportObject %x)\n", TransportObject));
+
+    DeviceObject = IoGetRelatedDeviceObject(TransportObject);
+    if (!DeviceObject) {
+        AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    Irp = TdiBuildInternalDeviceControlIrp
+	( TDI_SEND_DATAGRAM,       /* Sub function */
+	  DeviceObject,            /* Device object */
+	  TransportObject,         /* File object */
+	  &Event,                  /* Event */
+	  Iosb );                  /* Status */
+
+    if (!Irp) {
+        AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    TdiBuildDisconnect
+	(Irp,                    /* I/O Request Packet */
+	 DeviceObject,           /* Device object */
+	 TransportObject,        /* File object */
+	 CompletionRoutine,      /* Completion routine */
+	 CompletionContext,      /* Completion context */
+	 Time,                   /* Time */
+	 Flags,                  /* Disconnect flags */
+	 RequestConnectionInfo,  /* Indication of who to disconnect */
+	 ReturnConnectionInfo);  /* Indication of who disconnected */
+
+    Status = TdiCall(Irp, DeviceObject, &Event, Iosb);
+
+    return Status;
+}
+
 /* EOF */

reactos/drivers/net/afd/afd
write.c 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- write.c	21 Nov 2004 20:54:52 -0000	1.12
+++ write.c	8 Dec 2004 21:56:51 -0000	1.12.2.1
@@ -1,4 +1,4 @@
-/* $Id: write.c,v 1.12 2004/11/21 20:54:52 arty Exp $
+/* $Id: write.c,v 1.12.2.1 2004/12/08 21:56:51 hyperion Exp $
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/write.c
@@ -30,6 +30,8 @@
 			    Irp->IoStatus.Status,
 			    Irp->IoStatus.Information));
 
+    ASSERT_IRQL(APC_LEVEL);
+
     if( !SocketAcquireStateLock( FCB ) ) return Status;
 
     FCB->SendIrp.InFlightRequest = NULL; 

reactos/drivers/net/afd/include
afd.h 1.25 -> 1.25.2.1
diff -u -r1.25 -r1.25.2.1
--- afd.h	21 Nov 2004 20:54:52 -0000	1.25
+++ afd.h	8 Dec 2004 21:56:51 -0000	1.25.2.1
@@ -1,4 +1,4 @@
-/* $Id: afd.h,v 1.25 2004/11/21 20:54:52 arty Exp $
+/* $Id: afd.h,v 1.25.2.1 2004/12/08 21:56:51 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -65,6 +65,12 @@
 
 #define SGID_CONNECTIONLESS             1 /* XXX Find this flag */
 
+/* XXX This is a hack we should clean up later 
+ * We do this in order to get some storage for the locked handle table
+ * Maybe I'll use some tail item in the irp instead */
+#define AFD_HANDLES(x) ((PAFD_HANDLE)(x)->Exclusive)
+#define SET_AFD_HANDLES(x,y) (((x)->Exclusive) = (ULONG)(y))
+
 typedef struct _AFD_MAPBUF {
     PVOID BufferAddress;
     PMDL  Mdl;
@@ -83,6 +89,7 @@
     KDPC TimeoutDpc;
     KTIMER Timer;
     PKEVENT EventObject;
+    BOOLEAN Exclusive;
 } AFD_ACTIVE_POLL, *PAFD_ACTIVE_POLL;
 
 typedef struct _IRP_LIST {

reactos/drivers/net/afd/include
tdi_proto.h 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- tdi_proto.h	3 Oct 2004 21:16:31 -0000	1.3
+++ tdi_proto.h	8 Dec 2004 21:56:52 -0000	1.3.6.1
@@ -14,4 +14,14 @@
 NTSTATUS TdiCloseDevice(HANDLE Handle,
 			PFILE_OBJECT FileObject);
 
+NTSTATUS TdiDisconnect
+( PFILE_OBJECT TransportObject,
+  PLARGE_INTEGER Time,
+  USHORT Flags,
+  PIO_STATUS_BLOCK Iosb,
+  PIO_COMPLETION_ROUTINE CompletionRoutine,
+  PVOID CompletionContext,
+  PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
+  PTDI_CONNECTION_INFORMATION ReturnConnectionInfo );
+
 #endif/*_TDI_PROTO_H*/

reactos/drivers/net/afd
makefile 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- makefile	12 Nov 2004 07:34:55 -0000	1.14
+++ makefile	8 Dec 2004 21:56:52 -0000	1.14.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.14 2004/11/12 07:34:55 arty Exp $
+# $Id: makefile,v 1.14.2.1 2004/12/08 21:56:52 hyperion Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -8,8 +8,8 @@
 
 TARGET_PCH = include/afd.h
 
-TARGET_DDKLIBS = \
-	$(PATH_TO_TOP)/dk/w32/lib/pseh.a
+TARGET_LIBS = \
+	$(PATH_TO_TOP)/dk/w32/lib/libpseh.a
 
 TARGET_CFLAGS = -I./include -I$(PATH_TO_TOP)/w32api/include/ddk -I$(PATH_TO_TOP)/include/afd -D__USE_W32API -Werror -Wall
 

reactos/drivers/net/ndis/ndis
main.c 1.19 -> 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- main.c	23 Nov 2004 18:58:47 -0000	1.19
+++ main.c	8 Dec 2004 21:56:52 -0000	1.19.2.1
@@ -18,7 +18,7 @@
 #ifdef DBG
 
 /* See debug.h for debug/trace constants */
-DWORD DebugTraceLevel = /*MIN_TRACE*/DEBUG_ULTRA;
+DWORD DebugTraceLevel = MIN_TRACE;
 
 #endif /* DBG */
 

reactos/drivers/net/ndis/ndis
miniport.c 1.43 -> 1.43.2.1
diff -u -r1.43 -r1.43.2.1
--- miniport.c	23 Nov 2004 23:51:01 -0000	1.43
+++ miniport.c	8 Dec 2004 21:56:52 -0000	1.43.2.1
@@ -67,11 +67,10 @@
 MiniDisplayPacket(
     PNDIS_PACKET Packet)
 {
-//#ifdef DBG
-#if 0
+#ifdef DBG
     ULONG i, Length;
     UCHAR Buffer[64];
-    if ((DebugTraceLevel | DEBUG_PACKET) > 0) {
+    if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
         Length = CopyPacketToBuffer(
             (PUCHAR)&Buffer,
             Packet,
@@ -99,7 +98,7 @@
     UINT   LookaheadBufferSize)
 {
 #ifdef DBG
-    if ((DebugTraceLevel | DEBUG_PACKET) > 0) {
+    if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
         ULONG i, Length;
         PUCHAR p;
 
@@ -628,6 +627,7 @@
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
 
   ASSERT(Adapter);
+  ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
 
 #if 0
   if (Adapter->WorkQueueLevel < NDIS_MINIPORT_WORK_QUEUE_SIZE - 1) 
@@ -757,6 +757,24 @@
 }
 
 
+#undef NdisMQueryInformationComplete
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisMQueryInformationComplete(
+    IN  NDIS_HANDLE MiniportAdapterHandle,
+    IN  NDIS_STATUS Status)
+{
+    PNDIS_MINIPORT_BLOCK MiniportBlock = 
+	(PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+    ASSERT(MiniportBlock);
+    if( MiniportBlock->QueryCompleteHandler )
+	(MiniportBlock->QueryCompleteHandler)(MiniportAdapterHandle, Status);
+}
+
+
 VOID STDCALL MiniportDpc(
     IN PKDPC Dpc,
     IN PVOID DeferredContext,
@@ -778,7 +796,6 @@
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
-  /* XXX is adapter lock held here?  should be... */
   NdisStatus = MiniDequeueWorkItem(Adapter, &WorkItemType, &WorkItemContext);
 
   if (NdisStatus == NDIS_STATUS_SUCCESS) 
@@ -854,7 +871,7 @@
             switch (((PNDIS_REQUEST)WorkItemContext)->RequestType) 
               {
                 case NdisRequestQueryInformation:
-                  NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
+		  NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
                   break;
 
                 case NdisRequestSetInformation:
@@ -1047,21 +1064,6 @@
   *NdisWrapperHandle = Miniport;
 }
 
-#undef NdisMQueryInformationComplete
-
-
-/*
- * @implemented
- */
-VOID
-EXPORT
-NdisMQueryInformationComplete(
-    IN  NDIS_HANDLE MiniportAdapterHandle,
-    IN  NDIS_STATUS Status)
-{
-  (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->QueryCompleteHandler)(MiniportAdapterHandle, Status);
-}
-
 
 VOID STDCALL NdisIBugcheckCallback(
     IN PVOID   Buffer,
@@ -1544,7 +1546,7 @@
         Status = NdisIForwardIrpAndWait(Adapter, Irp);
         if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
           {
-            Status = NdisIPnPStartDevice(DeviceObject, Irp);
+	      Status = NdisIPnPStartDevice(DeviceObject, Irp);
           }
         Irp->IoStatus.Status = Status;
         IoCompleteRequest(Irp, IO_NO_INCREMENT);

reactos/drivers/net/ndis/ndis
protocol.c 1.22 -> 1.22.2.1
diff -u -r1.22 -r1.22.2.1
--- protocol.c	23 Nov 2004 18:58:47 -0000	1.22
+++ protocol.c	8 Dec 2004 21:56:52 -0000	1.22.2.1
@@ -147,14 +147,16 @@
           Adapter->MiniportBusy = TRUE;
         }
     }
-  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
 
+  /* MiniQueueWorkItem must be called at IRQL >= DISPATCH_LEVEL */
   if (QueueWorkItem) 
     {
       MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
       return NDIS_STATUS_PENDING;
     } 
 
+  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+
   /* MiniportQueryInformation (called by MiniDoRequest) runs at DISPATCH_LEVEL */
   /* TODO (?): move the irql raise into MiniDoRequest */
   KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);

reactos/drivers/net/tcpip/datalink
lan.c 1.27 -> 1.27.2.1
diff -u -r1.27 -r1.27.2.1
--- lan.c	21 Nov 2004 04:20:38 -0000	1.27
+++ lan.c	8 Dec 2004 21:56:52 -0000	1.27.2.1
@@ -200,7 +200,7 @@
 
 
     TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
-
+    
     while( (ListEntry = 
 	    ExInterlockedRemoveHeadList( &LanWorkList, &LanWorkLock )) ) {
 	WorkItem = CONTAINING_RECORD(ListEntry, LAN_WQ_ITEM, ListEntry);
@@ -228,8 +228,6 @@
 		     IPPacket.ContigSize, IPPacket.TotalSize,
 		     BytesTransferred));
 
-	/*OskitDumpBuffer( IPPacket.Header, IPPacket.TotalSize );*/
-
         PacketType = PC(IPPacket.NdisPacket)->PacketType;
 	IPPacket.Position = 0;
 
@@ -251,7 +249,7 @@
                 break;
         }
 
-	FreeNdisPacket( Packet );    
+	FreeNdisPacket( Packet );
     }
 }
 
@@ -276,6 +274,8 @@
     PLAN_WQ_ITEM WQItem;
     PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
 
+    ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+
     if( Status != NDIS_STATUS_SUCCESS ) return;
     WQItem = ExAllocatePool( NonPagedPool, sizeof(LAN_WQ_ITEM) );
     if( !WQItem ) return;
@@ -573,8 +573,6 @@
 		   ((PCHAR)LinkAddress)[5] & 0xff));
 	}
 
-	/*OskitDumpBuffer( Data, Size );*/
-
 	TcpipAcquireSpinLock( &Adapter->Lock, &OldIrql );
 	TI_DbgPrint(MID_TRACE, ("NdisSend\n"));
         NdisSend(&NdisStatus, Adapter->NdisHandle, NdisPacket);
@@ -600,7 +598,7 @@
 
 static NTSTATUS ReadIPAddressFromRegistry( HANDLE RegHandle,
 					   PWCHAR RegistryValue,
-					   PIP_ADDRESS *Address ) {
+					   PIP_ADDRESS Address ) {
     UNICODE_STRING ValueName;
     UNICODE_STRING UnicodeAddress; 
     NTSTATUS Status;
@@ -646,13 +644,77 @@
     }
     
     AnsiAddress.Buffer[AnsiAddress.Length] = 0;
-    *Address = AddrBuildIPv4(inet_addr(AnsiAddress.Buffer));
-    if (!Address) {
-	exFreePool(AnsiAddress.Buffer);
-	return STATUS_UNSUCCESSFUL;
+    AddrInitIPv4(Address, inet_addr(AnsiAddress.Buffer));
+
+    return STATUS_SUCCESS;
+}
+
+static NTSTATUS ReadStringFromRegistry( HANDLE RegHandle,
+					PWCHAR RegistryValue,
+					PUNICODE_STRING String ) {
+    UNICODE_STRING ValueName;
+    UNICODE_STRING UnicodeString;
+    NTSTATUS Status;
+    ULONG ResultLength;
+    UCHAR buf[1024];
+    PKEY_VALUE_PARTIAL_INFORMATION Information = (PKEY_VALUE_PARTIAL_INFORMATION)buf;
+
+    RtlInitUnicodeString(&ValueName, RegistryValue);
+    Status = 
+	ZwQueryValueKey(RegHandle, 
+			&ValueName, 
+			KeyValuePartialInformation, 
+			Information, 
+			sizeof(buf), 
+			&ResultLength);
+
+    if (!NT_SUCCESS(Status))
+	return Status;
+    /* IP address is stored as a REG_MULTI_SZ - we only pay attention to the first one though */
+    TI_DbgPrint(MIN_TRACE, ("Information DataLength: 0x%x\n", Information->DataLength));
+    
+    UnicodeString.Buffer = (PWCHAR)&Information->Data;
+    UnicodeString.Length = Information->DataLength;
+    UnicodeString.MaximumLength = Information->DataLength;
+ 
+    String->Buffer = 
+	(PWCHAR)exAllocatePool( NonPagedPool, 
+				UnicodeString.MaximumLength + sizeof(WCHAR) );
+
+    if( !String->Buffer ) return STATUS_NO_MEMORY;
+
+    String->MaximumLength = UnicodeString.MaximumLength;
+    RtlCopyUnicodeString( String, &UnicodeString );
+
+    return STATUS_SUCCESS;
+}
+
+static VOID GetSimpleAdapterNameFromRegistryPath
+( PUNICODE_STRING TargetString,
+  PUNICODE_STRING RegistryPath ) {
+    PWCHAR i, LastSlash = NULL;
+    UINT NewStringLength = 0;
+
+    for( i = RegistryPath->Buffer; 
+	 i < RegistryPath->Buffer + 
+	     (RegistryPath->Length / sizeof(WCHAR));
+	 i++ ) if( *i == '\\' ) LastSlash = i;
+
+    if( LastSlash ) LastSlash++; else LastSlash = RegistryPath->Buffer;
+
+    NewStringLength = RegistryPath->MaximumLength - 
+	((LastSlash - RegistryPath->Buffer) * sizeof(WCHAR));
+
+    TargetString->Buffer = 
+	(PWCHAR)exAllocatePool( NonPagedPool, NewStringLength );
+
+    if( !TargetString->Buffer ) {
+	TargetString->Length = TargetString->MaximumLength = 0;
+	return;
     }
 
-    return *Address ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
+    TargetString->Length = TargetString->MaximumLength = NewStringLength;
+    RtlCopyMemory( TargetString->Buffer, LastSlash, NewStringLength );
 }
 
 VOID BindAdapter(
@@ -668,10 +730,9 @@
  */
 {
     PIP_INTERFACE IF;
-    PIP_ADDRESS Address = 0;
-    PIP_ADDRESS Netmask = 0;
     NDIS_STATUS NdisStatus;
     LLIP_BIND_INFO BindInfo;
+    IP_ADDRESS DefaultGateway, DefaultMask = { 0 };
     ULONG Lookahead = LOOKAHEAD_SIZE;
     NTSTATUS Status;
     HANDLE RegHandle = 0;
@@ -718,13 +779,34 @@
     Status = OpenRegistryKey( RegistryPath, &RegHandle );
 	    
     if(NT_SUCCESS(Status))
+	Status = ReadIPAddressFromRegistry( RegHandle, L"DefaultGateway",
+					    &DefaultGateway );
+    if(!NT_SUCCESS(Status)) {
+	Status = STATUS_SUCCESS;
+	RtlZeroMemory( &DefaultGateway, sizeof(DefaultGateway) );
+    }
+
+    if(NT_SUCCESS(Status))
 	Status = ReadIPAddressFromRegistry( RegHandle, L"IPAddress",
-					    &Address );
+					    &IF->Unicast );
     if(NT_SUCCESS(Status)) 
 	Status = ReadIPAddressFromRegistry( RegHandle, L"SubnetMask",
-					    &Netmask );
-    
-    if(!NT_SUCCESS(Status) || !Address || !Netmask)
+					    &IF->Netmask );
+    if(NT_SUCCESS(Status)) {
+	Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
+					 &IF->Name );
+
+	RtlZeroMemory( &IF->Name, sizeof( IF->Name ) );
+
+	/* I think that not getting a devicedesc is not a fatal error */
+	if( !NT_SUCCESS(Status) ) {
+	    if( IF->Name.Buffer ) exFreePool( IF->Name.Buffer );
+	    GetSimpleAdapterNameFromRegistryPath( &IF->Name, RegistryPath );
+	}
+	Status = STATUS_SUCCESS;
+    }
+
+    if(!NT_SUCCESS(Status))
     {
 	TI_DbgPrint(MIN_TRACE, ("Unable to open protocol-specific registry key: 0x%x\n", Status));
 	
@@ -738,18 +820,25 @@
     TI_DbgPrint
 	(MID_TRACE, 
 	 ("--> Our IP address on this interface: '%s'\n", 
-	  A2S(Address)));
+	  A2S(&IF->Unicast)));
     
     TI_DbgPrint
 	(MID_TRACE, 
 	 ("--> Our net mask on this interface: '%s'\n", 
-	  A2S(Netmask)));
+	  A2S(&IF->Netmask)));
 
-    /* Create a net table entry for this interface */
-    if (!IPCreateNTE(IF, Address, AddrCountPrefixBits(Netmask))) {
-        TI_DbgPrint(MIN_TRACE, ("IPCreateNTE() failed.\n"));
-        IPDestroyInterface(IF);
-        return;
+    if( DefaultGateway.Address.IPv4Address ) {
+	TI_DbgPrint
+	    (MID_TRACE, 
+	     ("--> Our gateway is: '%s'\n", 
+	      A2S(&DefaultGateway)));
+
+	/* Create a default route */
+	RouterCreateRoute( &DefaultMask, /* Zero */
+			   &DefaultMask, /* Zero */
+			   &DefaultGateway,
+			   IF,
+			   1 );
     }
 
     /* Register interface with IP layer */
@@ -794,7 +883,7 @@
 
 NDIS_STATUS LANRegisterAdapter(
     PNDIS_STRING AdapterName,
-		PNDIS_STRING RegistryPath)
+    PNDIS_STRING RegistryPath)
 /*
  * FUNCTION: Registers protocol with an NDIS adapter
  * ARGUMENTS:

reactos/drivers/net/tcpip/include
address.h 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- address.h	9 Nov 2004 09:39:37 -0000	1.12
+++ address.h	8 Dec 2004 21:56:52 -0000	1.12.2.1
@@ -40,7 +40,7 @@
 
 NTSTATUS AddrBuildAddress(
     PTRANSPORT_ADDRESS TdiAddress,
-    PIP_ADDRESS *Address,
+    PIP_ADDRESS Address,
     PUSHORT Port);
 
 BOOLEAN AddrIsEqual(
@@ -55,14 +55,10 @@
     PIP_ADDRESS Address1,
     IPv4_RAW_ADDRESS Address2);
 
-PIP_ADDRESS AddrBuildIPv4(
-    IPv4_RAW_ADDRESS Address);
-
-PIP_ADDRESS AddrCloneAddress(
-    PIP_ADDRESS Address);
+BOOLEAN AddrLocateADEv4(
+    IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
 
-PADDRESS_ENTRY AddrLocateADEv4(
-    IPv4_RAW_ADDRESS Address);
+BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address );
 
 PADDRESS_FILE AddrSearchFirst(
     PIP_ADDRESS Address,
@@ -79,6 +75,9 @@
 
 UINT AddrCountPrefixBits( PIP_ADDRESS Netmask );
 
+VOID AddrWidenAddress( PIP_ADDRESS Network, PIP_ADDRESS Source,
+		       PIP_ADDRESS Netmask );
+
 #endif /* __ADDRESS_H */
 
 /* EOF */

reactos/drivers/net/tcpip/include
arp.h 1.2 -> 1.2.36.1
diff -u -r1.2 -r1.2.36.1
--- arp.h	2 Aug 2000 00:21:35 -0000	1.2
+++ arp.h	8 Dec 2004 21:56:52 -0000	1.2.36.1
@@ -24,9 +24,7 @@
 #define ARP_OPCODE_REPLY   WH2N(0x0002) /* ARP reply */
 
 
-BOOLEAN ARPTransmit(
-    PIP_ADDRESS Address,
-    PNET_TABLE_ENTRY NTE);
+BOOLEAN ARPTransmit(PIP_ADDRESS Address, PIP_INTERFACE Interface);
 
 VOID ARPReceive(
     PVOID Context,

reactos/drivers/net/tcpip/include
debug.h 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- debug.h	16 Nov 2004 18:07:57 -0000	1.11
+++ debug.h	8 Dec 2004 21:56:52 -0000	1.11.2.1
@@ -19,7 +19,7 @@
 #define DEBUG_MEMORY   0x00000200
 #define DEBUG_PBUFFER  0x00000400
 #define DEBUG_IRP      0x00000800
-#define DEBUG_REFCOUNT 0x00001000
+#define DEBUG_TCPIF    0x00001000
 #define DEBUG_ADDRFILE 0x00002000
 #define DEBUG_DATALINK 0x00004000
 #define DEBUG_ARP      0x00008000
@@ -31,6 +31,7 @@
 #define DEBUG_RCACHE   0x00200000
 #define DEBUG_NCACHE   0x00400000
 #define DEBUG_CPOINT   0x00800000
+#define DEBUG_LOCK     0x01000000
 #define DEBUG_ULTRA    0xFFFFFFFF
 
 #ifdef DBG

reactos/drivers/net/tcpip/include
icmp.h 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- icmp.h	7 Nov 2004 20:37:19 -0000	1.3
+++ icmp.h	8 Dec 2004 21:56:52 -0000	1.3.2.1
@@ -50,20 +50,19 @@
 
 
 VOID ICMPReceive(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket);
 
 VOID ICMPTransmit(
-    PNET_TABLE_ENTRY NTE,
     PIP_PACKET IPPacket,
     PIP_TRANSMIT_COMPLETE Complete,
     PVOID Context);
 
 VOID ICMPReply(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket,
-	UCHAR Type,
-	UCHAR Code);
+    UCHAR Type,
+    UCHAR Code);
 
 #endif /* __ICMP_H */
 

reactos/drivers/net/tcpip/include
interface.h 1.3 -> 1.3.8.1
diff -u -r1.3 -r1.3.8.1
--- interface.h	19 Aug 2004 21:38:58 -0000	1.3
+++ interface.h	8 Dec 2004 21:56:52 -0000	1.3.8.1
@@ -3,14 +3,16 @@
 
 #include <ip.h>
 
+#define IFENT_SOFTWARE_LOOPBACK 24 /* This is an SNMP constant from rfc1213 */
+
 NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
 				  ULONG Type,
 				  PULONG Address );
-
 UINT CountInterfaces();
 UINT CountInterfaceAddresses( PIP_INTERFACE Interface );
 NTSTATUS GetInterfaceSpeed( PIP_INTERFACE Interface, PUINT Speed );
 NTSTATUS GetInterfaceName( PIP_INTERFACE Interface, PCHAR NameBuffer,
 			   UINT NameMaxLen );
+PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address);
 
 #endif//_TCPIP_INTERFACE_H

reactos/drivers/net/tcpip/include
ip.h 1.18 -> 1.18.2.1
diff -u -r1.18 -r1.18.2.1
--- ip.h	14 Nov 2004 10:13:17 -0000	1.18
+++ ip.h	8 Dec 2004 21:56:52 -0000	1.18.2.1
@@ -106,35 +106,15 @@
 /* The ProtocolReserved field is structured as a PACKET_CONTEXT */
 #define PC(Packet) ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))
 
-/* Address information a.k.a ADE */
-typedef struct _ADDRESS_ENTRY {
-    DEFINE_TAG
-    LIST_ENTRY              ListEntry;  /* Entry on list */
-    OBJECT_FREE_ROUTINE     Free;       /* Routine used to free resources for the object */
-    struct _NET_TABLE_ENTRY *NTE;       /* NTE associated with this address */
-    UCHAR                   Type;       /* Address type */
-    IP_ADDRESS              Address;    /* Pointer to address identifying this entry */
-} ADDRESS_ENTRY, *PADDRESS_ENTRY;
-
 /* Values for address type -- also the interface flags */
 /* These values are mean to overlap meaningfully with the BSD ones */
 #define ADE_UNICAST     0x01
-#define ADE_MULTICAST   0x02
+#define ADE_BROADCAST   0x02
 #define ADE_ADDRMASK    0x04
 #define ADE_POINTOPOINT 0x10
+#define ADE_MULTICAST   0x8000
 
 /* There is one NTE for each source (unicast) address assigned to an interface */
-typedef struct _NET_TABLE_ENTRY {
-    DEFINE_TAG
-    LIST_ENTRY                 IFListEntry; /* Entry on interface list */
-    LIST_ENTRY                 NTListEntry; /* Entry on net table list */
-    struct _IP_INTERFACE       *Interface;  /* Pointer to interface on this net */
-    struct _PREFIX_LIST_ENTRY  *PLE;        /* Pointer to prefix list entry for this net */
-    OBJECT_FREE_ROUTINE        Free;        /* Routine used to free resources for the object */
-    PIP_ADDRESS                Address;     /* Pointer to unicast address for this net */
-} NET_TABLE_ENTRY, *PNET_TABLE_ENTRY;
-
-
 /* Link layer transmit prototype */
 typedef VOID (*LL_TRANSMIT_ROUTINE)(
     PVOID Context,
@@ -158,8 +138,6 @@
 /* Information about an IP interface */
 typedef struct _IP_INTERFACE {
     DEFINE_TAG
-    LIST_ENTRY NTEListHead;       /* List of NTEs on this interface */
-    LIST_ENTRY ADEListHead;       /* List of ADEs on this interface */
     LIST_ENTRY ListEntry;         /* Entry on list */
     OBJECT_FREE_ROUTINE Free;     /* Routine used to free resources used by the object */
     KSPIN_LOCK Lock;              /* Spin lock for this object */
@@ -167,10 +145,14 @@
     UINT  HeaderSize;             /* Size of link level header */
     UINT  MinFrameSize;           /* Minimum frame size in bytes */
     UINT  MTU;                    /* Maximum transmission unit */
+    IP_ADDRESS Unicast;           /* Unicast address */
+    IP_ADDRESS PointToPoint;      /* Point to point address */
+    IP_ADDRESS Netmask;           /* Netmask */
+    IP_ADDRESS Broadcast;         /* Broadcast */
+    UNICODE_STRING Name;          /* Adapter name */
     PUCHAR Address;               /* Pointer to interface address */
     UINT  AddressLength;          /* Length of address in bytes */
     LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */
-
     PVOID TCPContext;             /* TCP Content for this interface */
 } IP_INTERFACE, *PIP_INTERFACE;
 
@@ -178,7 +160,7 @@
 #define IP_PROTOCOL_TABLE_SIZE 0x100
 
 typedef VOID (*IP_PROTOCOL_HANDLER)(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket);
 
 /* Loopback adapter address information (network byte order) */
@@ -206,6 +188,7 @@
 extern KSPIN_LOCK NetTableListLock;
 extern UINT MaxLLHeaderSize;
 extern UINT MinLLFrameSize;
+extern BOOLEAN IpWorkItemQueued;
 
 PIP_PACKET IPCreatePacket(
   ULONG Type);
@@ -214,11 +197,6 @@
     PIP_PACKET IPPacket,
     ULONG Type);
 
-PNET_TABLE_ENTRY IPCreateNTE(
-    PIP_INTERFACE IF,
-    PIP_ADDRESS Address,
-    UINT PrefixLength);
-
 PIP_INTERFACE IPCreateInterface(
     PLLIP_BIND_INFO BindInfo);
 
@@ -231,26 +209,10 @@
 VOID IPUnregisterInterface(
     PIP_INTERFACE IF);
 
-PNET_TABLE_ENTRY IPLocateNTEOnInterface(
-    PIP_INTERFACE IF,
-    PIP_ADDRESS Address,
-    PUINT AddressType);
-
-PNET_TABLE_ENTRY IPLocateNTE(
-    PIP_ADDRESS Address,
-    PUINT AddressType);
-
-PADDRESS_ENTRY IPLocateADE(
-    PIP_ADDRESS Address,
-    UINT AddressType);
-
-PADDRESS_ENTRY IPGetDefaultADE(
-    UINT AddressType);
-
 VOID STDCALL IPTimeout( PVOID Context );
 
 VOID IPDispatchProtocol(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket);
 
 VOID IPRegisterProtocol(

reactos/drivers/net/tcpip/include
precomp.h 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- precomp.h	16 Nov 2004 18:07:57 -0000	1.8
+++ precomp.h	8 Dec 2004 21:56:52 -0000	1.8.2.1
@@ -17,7 +17,6 @@
 #include <receive.h>
 #include <transmit.h>
 #include <router.h>
-#include <prefix.h>
 #include <pool.h>
 #include <rawip.h>
 #include <icmp.h>
@@ -36,3 +35,5 @@
 #include <oskittcp.h>
 #include <interface.h>
 #include <ports.h>
+#define NTOS_MODE_USER
+#include <ntos.h>

reactos/drivers/net/tcpip/include
rawip.h 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- rawip.h	3 Oct 2004 20:38:48 -0000	1.5
+++ rawip.h	8 Dec 2004 21:56:52 -0000	1.5.6.1
@@ -15,7 +15,7 @@
     PULONG DataUsed);
 
 VOID RawIPReceive(
-    PNET_TABLE_ENTRY NTE,
+    PIP_INTERFACE Interface,
     PIP_PACKET IPPacket);
 
 NTSTATUS RawIPStartup(

reactos/drivers/net/tcpip/include
route.h 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- route.h	7 Nov 2004 20:37:19 -0000	1.6
+++ route.h	8 Dec 2004 21:56:52 -0000	1.6.2.1
@@ -14,70 +14,7 @@
 #include <info.h>
 #include <arp.h>
 
-/* Route Cache Node structure.
- * The primary purpose of the RCN is to cache selected source and
- * next-hop addresses. The routing cache is implemented as a binary
- * search tree to provide fast lookups when many RCNs are in the cache.
- */
-typedef struct ROUTE_CACHE_NODE {
-    struct ROUTE_CACHE_NODE *Parent; /* Pointer to parent */
-    struct ROUTE_CACHE_NODE *Left;   /* Pointer to left child */
-    struct ROUTE_CACHE_NODE *Right;  /* Pointer to right child */
-    /* Memebers above this line must not be moved */
-    DEFINE_TAG
-    OBJECT_FREE_ROUTINE Free;        /* Routine used to free resources for the object */
-    UCHAR State;                     /* RCN state (RCN_STATE_*) */
-    IP_ADDRESS Destination;          /* Destination address */
-    PNET_TABLE_ENTRY NTE;            /* Preferred NTE */
-    PNEIGHBOR_CACHE_ENTRY NCE;       /* Pointer to NCE for first hop (NULL if none) */
-    UINT PathMTU;                    /* Path MTU to destination */
-} ROUTE_CACHE_NODE, *PROUTE_CACHE_NODE;
-
-/* RCN states */
-#define RCN_STATE_PERMANENT 0x00 /* RCN is permanent (properly local) */
-#define RCN_STATE_COMPUTED  0x01 /* RCN is computed */
-
-
-extern NPAGED_LOOKASIDE_LIST IPRCNList;
-
-
-#define IsExternalRCN(RCN) \
-    (RCN == ExternalRCN)
-
-#define IsInternalRCN(RCN) \
-    (RCN != ExternalRCN)
-
-
-NTSTATUS RouteStartup(
-    VOID);
-
-NTSTATUS RouteShutdown(
-    VOID);
-
-UINT RouteGetRouteToDestination(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE,
-    PROUTE_CACHE_NODE *RCN);
-
-PROUTE_CACHE_NODE RouteAddRouteToDestination(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE,
-    PIP_INTERFACE IF,
-    PNEIGHBOR_CACHE_ENTRY NCE);
-
-VOID RouteRemoveRouteToDestination(
-    PROUTE_CACHE_NODE RCN);
-
-VOID RouteInvalidateNTE(
-    PNET_TABLE_ENTRY NTE);
-
-VOID RouteInvalidateNCE(
-    PNEIGHBOR_CACHE_ENTRY NCE);
-
-NTSTATUS
-RouteFriendlyAddRoute( PIPROUTE_ENTRY ire );
-
-UINT CountRouteNodes( PROUTE_CACHE_NODE Node );
+PNEIGHBOR_CACHE_ENTRY RouteGetRouteToDestination(PIP_ADDRESS Destination);
 
 #endif /* __ROUTE_H */
 

reactos/drivers/net/tcpip/include
router.h 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- router.h	9 Nov 2004 09:39:37 -0000	1.6
+++ router.h	8 Dec 2004 21:56:52 -0000	1.6.2.1
@@ -20,33 +20,21 @@
     UINT Metric;                  /* Cost of this route */
 } FIB_ENTRY, *PFIB_ENTRY;
 
-
-PNET_TABLE_ENTRY RouterFindBestNTE(
-    PIP_INTERFACE Interface,
-    PIP_ADDRESS Destination);
-
-PIP_INTERFACE RouterFindOnLinkInterface(
-    PIP_ADDRESS Address,
-    PNET_TABLE_ENTRY NTE);
-
 PFIB_ENTRY RouterAddRoute(
     PIP_ADDRESS NetworkAddress,
     PIP_ADDRESS Netmask,
     PNEIGHBOR_CACHE_ENTRY Router,
     UINT Metric);
 
-PNEIGHBOR_CACHE_ENTRY RouterGetRoute(
-    PIP_ADDRESS Destination,
-    PNET_TABLE_ENTRY NTE);
-
-VOID RouterRemoveRoute(
-    PFIB_ENTRY FIBE);
-
-PFIB_ENTRY RouterCreateRouteIPv4(
-    IPv4_RAW_ADDRESS NetworkAddress,
-    IPv4_RAW_ADDRESS Netmask,
-    IPv4_RAW_ADDRESS RouterAddress,
-    PNET_TABLE_ENTRY NTE,
+PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination);
+
+NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router);
+
+PFIB_ENTRY RouterCreateRoute(
+    PIP_ADDRESS NetworkAddress,
+    PIP_ADDRESS Netmask,
+    PIP_ADDRESS RouterAddress,
+    PIP_INTERFACE Interface,
     UINT Metric);
 
 NTSTATUS RouterStartup(

reactos/drivers/net/tcpip/include
tcp.h 1.11 -> 1.11.6.1
diff -u -r1.11 -r1.11.6.1
--- tcp.h	30 Sep 2004 05:44:10 -0000	1.11
+++ tcp.h	8 Dec 2004 21:56:52 -0000	1.11.6.1
@@ -81,9 +81,17 @@
 #define SRF_SYN   TCP_SYN
 #define SRF_FIN   TCP_FIN
 
+extern LONG TCP_IPIdentification;
+extern LIST_ENTRY SignalledConnections;
+extern LIST_ENTRY SleepingThreadsList;
+extern FAST_MUTEX SleepingThreadsLock;
+extern RECURSIVE_MUTEX TCPLock;
+
 PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext );
 VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection );
 
+VOID TCPCancelReceiveRequest( PVOID Context );
+
 NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection, 
 		    UINT Family, UINT Type, UINT Proto );
 
@@ -107,6 +115,14 @@
   PTCP_COMPLETION_ROUTINE Complete,
   PVOID Context);
 
+NTSTATUS TCPDisconnect(
+  PCONNECTION_ENDPOINT Connection,
+  UINT Flags,
+  PTDI_CONNECTION_INFORMATION ConnInfo,
+  PTDI_CONNECTION_INFORMATION ReturnInfo,
+  PTCP_COMPLETION_ROUTINE Complete,
+  PVOID Context);
+
 NTSTATUS TCPListen(
   PCONNECTION_ENDPOINT Connection,
   UINT Backlog,

reactos/drivers/net/tcpip/include
tilists.h 1.1 -> 1.1.8.1
diff -u -r1.1 -r1.1.8.1
--- tilists.h	19 Jul 2004 04:30:04 -0000	1.1
+++ tilists.h	8 Dec 2004 21:56:52 -0000	1.1.8.1
@@ -7,10 +7,6 @@
     PLIST_ENTRY TIPASTE(n,Entry); \
     PIP_INTERFACE n;
 
-#define ADE_LIST_ITER(n) \
-    PLIST_ENTRY TIPASTE(n,Entry); \
-    PADDRESS_ENTRY n;
-
 #define ForEachInterface(n) \
     TIPASTE(n,Entry) = InterfaceListHead.Flink; \
     while (TIPASTE(n,Entry) != &InterfaceListHead) { \
@@ -28,13 +24,4 @@
      TIPASTE(n,Entry) = TIPASTE(n,Entry)->Flink; \
 }
 
-#define ForEachADE(ADEList,n) \
-            TIPASTE(n,Entry) = ADEList.Flink; \
-            ASSERT(TIPASTE(n,Entry)); \
-            while (TIPASTE(n,Entry) != &ADEList) { \
-                    ASSERT(TIPASTE(n,Entry)); \
-	            n = CONTAINING_RECORD(TIPASTE(n,Entry), \
-                                          ADDRESS_ENTRY, ListEntry); \
-                    ASSERT(n);
-
 #endif/*_TILISTS_H*/

reactos/drivers/net/tcpip/include
titypes.h 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- titypes.h	15 Nov 2004 18:24:57 -0000	1.14
+++ titypes.h	8 Dec 2004 21:56:52 -0000	1.14.2.1
@@ -174,7 +174,7 @@
     KSPIN_LOCK Lock;                      /* Spin lock to manipulate this structure */
     OBJECT_FREE_ROUTINE Free;             /* Routine to use to free resources for the object */
     USHORT Flags;                         /* Flags for address file (see below) */
-    PADDRESS_ENTRY ADE;                   /* Associated address entry */
+    IP_ADDRESS Address;                   /* Address of this address file */
     USHORT Protocol;                      /* Protocol number */
     USHORT Port;                          /* Network port (network byte order) */
     WORK_QUEUE_ITEM WorkItem;             /* Work queue item handle */
@@ -321,9 +321,12 @@
     LIST_ENTRY ConnectRequest; /* Queued connect rqueusts */
     LIST_ENTRY ListenRequest;  /* Queued listen requests */
     LIST_ENTRY ReceiveRequest; /* Queued receive requests */
-    
-    /* Queues */
-    LIST_ENTRY ReceivedSegments;/* Segments that are received */
+
+    /* Signals */
+    LIST_ENTRY SignalList;     /* Entry in the list of sockets waiting for
+				* notification service to the client */
+    UINT    SignalState;       /* Active signals from oskit */
+    BOOLEAN Signalled;         /* Are we a member of the signal list */
 } CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;
 
 

reactos/drivers/net/tcpip/include
transmit.h 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- transmit.h	7 Nov 2004 20:37:19 -0000	1.3
+++ transmit.h	8 Dec 2004 21:56:52 -0000	1.3.2.1
@@ -30,7 +30,7 @@
 } IPFRAGMENT_CONTEXT, *PIPFRAGMENT_CONTEXT;
 
 
-NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PROUTE_CACHE_NODE RCN,
+NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
 			PIP_TRANSMIT_COMPLETE Complete, PVOID Context);
 
 #endif /* __TRANSMIT_H */

reactos/drivers/net/tcpip/include
udp.h 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- udp.h	14 Nov 2004 19:45:16 -0000	1.6
+++ udp.h	8 Dec 2004 21:56:52 -0000	1.6.2.1
@@ -61,8 +61,8 @@
     PVOID Context);
 
 VOID UDPReceive(
-  PNET_TABLE_ENTRY NTE,
-  PIP_PACKET IPPacket);
+    PIP_INTERFACE Interface,
+    PIP_PACKET IPPacket);
 
 NTSTATUS UDPStartup(
   VOID);

reactos/drivers/net/tcpip/include
prefix.h removed after 1.4
diff -N prefix.h
--- prefix.h	9 Nov 2004 09:39:37 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS TCP/IP protocol driver
- * FILE:        include/info.h
- * PURPOSE:     TdiQueryInformation definitions
- */
-#ifndef __PREFIX_H
-#define __PREFIX_H
-
-/* Prefix List Entry */
-typedef struct _PREFIX_LIST_ENTRY {
-    DEFINE_TAG
-    LIST_ENTRY ListEntry;    /* Entry on list */
-    PIP_INTERFACE Interface; /* Pointer to interface */
-    IP_ADDRESS Prefix;       /* Pointer to prefix */
-    UINT PrefixLength;       /* Length of prefix */
-} PREFIX_LIST_ENTRY, *PPREFIX_LIST_ENTRY;
-
-extern LIST_ENTRY PrefixListHead;
-extern KSPIN_LOCK PrefixListLock;
-
-VOID InitPLE();
-PPREFIX_LIST_ENTRY CreatePLE(PIP_INTERFACE IF, PIP_ADDRESS Prefix, UINT Len);
-VOID DestroyPLE(PPREFIX_LIST_ENTRY PLE);
-VOID DestroyPLEs();
-
-#endif/*__PREFIX_H*/

reactos/drivers/net/tcpip
makefile 1.31 -> 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- makefile	13 Nov 2004 00:06:32 -0000	1.31
+++ makefile	8 Dec 2004 21:56:53 -0000	1.31.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.31 2004/11/13 00:06:32 arty Exp $
+# $Id: makefile,v 1.31.2.1 2004/12/08 21:56:53 hyperion Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -13,6 +13,7 @@
 # -DMEMTRACK
 TARGET_CFLAGS = \
 	-D__USE_W32API \
+	-D_SEH_NO_NATIVE_NLG \
 	-DMEMTRACK \
 	-DNDIS40 \
 	-Wall -Werror \
@@ -21,15 +22,16 @@
 	-I$(PATH_TO_TOP)/w32api/include \
 	-I$(PATH_TO_TOP)/include
 
-TARGET_DDKLIBS = \
-	$(PATH_TO_TOP)/dk/w32/lib/ip.a \
-	$(PATH_TO_TOP)/dk/w32/lib/oskittcp.a \
-	$(PATH_TO_TOP)/dk/w32/lib/rosrtl.a \
-	ndis.a
+TARGET_LIBS = \
+	$(PATH_TO_TOP)/dk/w32/lib/libip.a \
+	$(PATH_TO_TOP)/dk/w32/lib/liboskittcp.a \
+	$(PATH_TO_TOP)/dk/w32/lib/librosrtl.a \
+	$(PATH_TO_TOP)/dk/w32/lib/libpseh.a \
+	$(PATH_TO_TOP)/dk/nkm/lib/libndis.a
 
 TARGET_CLEAN = tcpip/*.o datalink/*.o \
-	$(PATH_TO_TOP)/dk/w32/lib/ip.a \
-	$(PATH_TO_TOP)/dk/w32/lib/oskittcp.a 
+	$(PATH_TO_TOP)/dk/w32/lib/libip.a \
+	$(PATH_TO_TOP)/dk/w32/lib/liboskittcp.a
 
 TCPIP_OBJECTS    = tcpip/buffer.o \
 		   tcpip/dispatch.o \
@@ -61,13 +63,13 @@
 	$(MAKE) $(MOCKOBJS)
 
 preclean:
-	$(RM) 	$(PATH_TO_TOP)/dk/w32/lib/ip.a \
-		$(PATH_TO_TOP)/dk/w32/lib/oskittcp.a
+	$(RM) 	$(PATH_TO_TOP)/dk/w32/lib/libip.a \
+		$(PATH_TO_TOP)/dk/w32/lib/liboskittcp.a
 
-$(PATH_TO_TOP)/dk/w32/lib/oskittcp.a:
+$(PATH_TO_TOP)/dk/w32/lib/liboskittcp.a:
 	$(MAKE) -C $(PATH_TO_TOP)/drivers/lib/oskittcp
 
-$(PATH_TO_TOP)/dk/w32/lib/ip.a:
+$(PATH_TO_TOP)/dk/w32/lib/libip.a:
 	$(MAKE) -C $(PATH_TO_TOP)/drivers/lib/ip
 
 $(TARGET_OBJECTS):: makefile

reactos/drivers/net/tcpip/tcpip
dispatch.c 1.26 -> 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- dispatch.c	18 Nov 2004 05:02:10 -0000	1.26
+++ dispatch.c	8 Dec 2004 21:56:53 -0000	1.26.2.1
@@ -1,3 +1,4 @@
+
 /*
  * COPYRIGHT:   See COPYING in the top level directory
  * PROJECT:     ReactOS TCP/IP protocol driver
@@ -10,6 +11,7 @@
  */
 
 #include "precomp.h"
+#include <pseh.h>
 
 NTSTATUS DispPrepareIrpForCancel(
     PTRANSPORT_CONTEXT Context,
@@ -70,20 +72,18 @@
 
     FileObject  = (PFILE_OBJECT)Context;
     TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
-    
-    IoAcquireCancelSpinLock(&OldIrql);
 
-    TI_DbgPrint(DEBUG_IRP, ("Setting TranContext->CleanupEvent to signaled.\n"));
     /* Set the cleanup event */
     KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
 
+    /* We are expected to release the cancel spin lock */
     IoReleaseCancelSpinLock(OldIrql);
 
     TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
 }
 
 
-VOID DispCancelRequest(
+VOID DDKAPI DispCancelRequest(
     PDEVICE_OBJECT Device,
     PIRP Irp)
 /*
@@ -179,8 +179,6 @@
 
     IoSetCancelRoutine(Irp, NULL);
 
-    KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
-
     if (Irp->Cancel || TranContext->CancelIrps) {
         /* The IRP has been cancelled */
 
@@ -414,14 +412,18 @@
  *     Status of operation
  */
 {
-  PTDI_REQUEST_KERNEL_QUERY_INFORMATION Parameters;
+  NTSTATUS Status;
+  PTDI_REQUEST_KERNEL_DISCONNECT DisReq;
+  PCONNECTION_ENDPOINT Connection;
   PTRANSPORT_CONTEXT TranContext;
   PIO_STACK_LOCATION IrpSp;
 
   TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
 
   IrpSp = IoGetCurrentIrpStackLocation(Irp);
-  Parameters = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&IrpSp->Parameters;
+  DisReq = (PTDI_REQUEST_KERNEL_DISCONNECT)&IrpSp->Parameters;
+
+  /* Get associated connection endpoint file object. Quit if none exists */
 
   TranContext = IrpSp->FileObject->FsContext;
   if (!TranContext) {
@@ -429,56 +431,23 @@
     return STATUS_INVALID_CONNECTION;
   }
 
-  switch (Parameters->QueryType)
-  {
-    case TDI_QUERY_ADDRESS_INFO:
-      {
-        PTDI_ADDRESS_INFO AddressInfo;
-        PADDRESS_FILE AddrFile;
-        PTA_IP_ADDRESS Address;
-
-        AddressInfo = (PTDI_ADDRESS_INFO)MmGetSystemAddressForMdl(Irp->MdlAddress);
-
-        switch ((ULONG)IrpSp->FileObject->FsContext2) {
-          case TDI_TRANSPORT_ADDRESS_FILE:
-            AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
-            break;
-
-          case TDI_CONNECTION_FILE:
-            AddrFile = ((PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext)->AddressFile;
-            break;
-
-          default:
-            TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
-            return STATUS_INVALID_PARAMETER;
-        }
-
-        if (!AddrFile) {
-          TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
-          return STATUS_INVALID_PARAMETER;
-        }
-
-        if (MmGetMdlByteCount(Irp->MdlAddress) <
-            (sizeof(TDI_ADDRESS_INFO) + sizeof(TDI_ADDRESS_IP))) {
-          TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
-          return STATUS_BUFFER_OVERFLOW;
-        }
-
-        Address = (PTA_IP_ADDRESS)&AddressInfo->Address;
-        Address->TAAddressCount = 1;
-        Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
-        Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
-        Address->Address[0].Address[0].sin_port = AddrFile->Port;
-        Address->Address[0].Address[0].in_addr = AddrFile->ADE->Address.Address.IPv4Address;        
-        RtlZeroMemory(
-          &Address->Address[0].Address[0].sin_zero,
-          sizeof(Address->Address[0].Address[0].sin_zero));
-
-        return STATUS_SUCCESS;
-      }
+  Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
+  if (!Connection) {
+    TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
+    return STATUS_INVALID_CONNECTION;
   }
 
-  return STATUS_NOT_IMPLEMENTED;
+  Status = TCPDisconnect(
+      TranContext->Handle.ConnectionContext,
+      DisReq->RequestFlags,
+      DisReq->RequestConnectionInformation,
+      DisReq->ReturnConnectionInformation,
+      DispDataRequestComplete,
+      Irp );
+  
+  TI_DbgPrint(MAX_TRACE, ("TCP Connect returned %08x\n", Status));
+
+  return Status;
 }
 
 
@@ -595,7 +564,7 @@
         Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
         Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
         Address->Address[0].Address[0].sin_port = AddrFile->Port;
-        Address->Address[0].Address[0].in_addr = AddrFile->ADE->Address.Address.IPv4Address;        
+        Address->Address[0].Address[0].in_addr = AddrFile->Address.Address.IPv4Address;        
         RtlZeroMemory(
           &Address->Address[0].Address[0].sin_zero,
           sizeof(Address->Address[0].Address[0].sin_zero));
@@ -643,10 +612,11 @@
     }
 
   /* Initialize a receive request */
-  Status = DispPrepareIrpForCancel(
-    IrpSp->FileObject->FsContext,
-    Irp,
-    (PDRIVER_CANCEL)DispCancelRequest);
+  Status = DispPrepareIrpForCancel
+      (TranContext->Handle.ConnectionContext, 
+       Irp, 
+       (PDRIVER_CANCEL)DispCancelRequest);
+
   TI_DbgPrint(MID_TRACE,("TCPIP<<< Got an MDL: %x\n", Irp->MdlAddress));
   if (NT_SUCCESS(Status))
     {
@@ -661,12 +631,8 @@
       if (Status != STATUS_PENDING)
       {
           DispDataRequestComplete(Irp, Status, BytesReceived);
-      }
-    }
-
-  if (Status != STATUS_PENDING)
-    {
-      IrpSp->Control &= ~SL_PENDING_RETURNED;
+      } else
+	  IoMarkIrpPending(Irp);
     }
 
   TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -708,10 +674,12 @@
   Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
   Request.RequestNotifyObject  = DispDataRequestComplete;
   Request.RequestContext       = Irp;
+
   Status = DispPrepareIrpForCancel(
     IrpSp->FileObject->FsContext,
     Irp,
     (PDRIVER_CANCEL)DispCancelRequest);
+
   if (NT_SUCCESS(Status))
     {
 	PCHAR DataBuffer;
@@ -731,15 +699,10 @@
 	  &BytesReceived,
 	  (PDATAGRAM_COMPLETION_ROUTINE)DispDataRequestComplete,
 	  Irp);
-      if (Status != STATUS_PENDING)
-        {
+      if (Status != STATUS_PENDING) {
           DispDataRequestComplete(Irp, Status, BytesReceived);
-        }
-    }
-
-  if (Status != STATUS_PENDING)
-    {
-      IrpSp->Control &= ~SL_PENDING_RETURNED;
+      } else
+	  IoMarkIrpPending(Irp);
     }
 
   TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -786,6 +749,7 @@
     IrpSp->FileObject->FsContext,
     Irp,
     (PDRIVER_CANCEL)DispCancelRequest);
+
   TI_DbgPrint(MID_TRACE,("TCPIP<<< Got an MDL: %x\n", Irp->MdlAddress));
   if (NT_SUCCESS(Status))
     {
@@ -804,12 +768,8 @@
 	if (Status != STATUS_PENDING)
 	{
 	    DispDataRequestComplete(Irp, Status, BytesReceived);
-	}
-    }
-
-  if (Status != STATUS_PENDING)
-    {
-      IrpSp->Control &= ~SL_PENDING_RETURNED;
+	} else 
+	    IoMarkIrpPending( Irp );
     }
 
   TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
@@ -849,6 +809,7 @@
         IrpSp->FileObject->FsContext,
         Irp,
         (PDRIVER_CANCEL)DispCancelRequest);
+
     if (NT_SUCCESS(Status)) {
 	PCHAR DataBuffer;
 	UINT BufferSize;
@@ -877,7 +838,8 @@
             /* Return STATUS_PENDING because DispPrepareIrpForCancel
                marks Irp as pending */
             Status = STATUS_PENDING;
-        }
+        } else
+	    IoMarkIrpPending( Irp );
     }
 
     TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
@@ -1092,8 +1054,10 @@
 
     MmUnlockPages(QueryContext->InputMdl);
     IoFreeMdl(QueryContext->InputMdl);
-    MmUnlockPages(QueryContext->OutputMdl);
-    IoFreeMdl(QueryContext->OutputMdl);
+    if( QueryContext->OutputMdl ) {
+	MmUnlockPages(QueryContext->OutputMdl);
+	IoFreeMdl(QueryContext->OutputMdl);
+    }
 
     QueryContext->Irp->IoStatus.Information = ByteCount;
     QueryContext->Irp->IoStatus.Status      = Status;
@@ -1163,9 +1127,7 @@
 
         QueryContext = ExAllocatePool(NonPagedPool, sizeof(TI_QUERY_CONTEXT));
         if (QueryContext) {
-#ifdef _MSC_VER
-            try {
-#endif
+	    _SEH_TRY {
                 InputMdl = IoAllocateMdl(InputBuffer,
                     sizeof(TCP_REQUEST_QUERY_INFORMATION_EX),
                     FALSE, TRUE, NULL);
@@ -1187,14 +1149,12 @@
 
                     RtlCopyMemory(&QueryContext->QueryInfo,
                         InputBuffer, sizeof(TCP_REQUEST_QUERY_INFORMATION_EX));
-
                 } else
                     Status = STATUS_INSUFFICIENT_RESOURCES;
-#ifdef _MSC_VER
-            } except(EXCEPTION_EXECUTE_HANDLER) {
-                Status = GetExceptionCode();
-            }
-#endif
+            } _SEH_HANDLE {
+                Status = _SEH_GetExceptionCode();
+            } _SEH_END;
+
             if (NT_SUCCESS(Status)) {
                 Size = MmGetMdlByteCount(OutputMdl);
 
@@ -1231,8 +1191,57 @@
             ExFreePool(QueryContext);
         } else
             Status = STATUS_INSUFFICIENT_RESOURCES;
-    } else
-        Status = STATUS_INVALID_PARAMETER;
+    } else if( InputBufferLength == 
+	       sizeof(TCP_REQUEST_QUERY_INFORMATION_EX) ) {
+	/* Handle the case where the user is probing the buffer for length */
+	TI_DbgPrint(MAX_TRACE, ("InputBufferLength %d OutputBufferLength %d\n",
+				InputBufferLength, OutputBufferLength));
+        InputBuffer = (PTCP_REQUEST_QUERY_INFORMATION_EX)
+            IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
+
+	Size = 0;
+
+        QueryContext = ExAllocatePool(NonPagedPool, sizeof(TI_QUERY_CONTEXT));
+        if (!QueryContext) return STATUS_INSUFFICIENT_RESOURCES;
+
+	_SEH_TRY {
+	    InputMdl = IoAllocateMdl(InputBuffer,
+				     sizeof(TCP_REQUEST_QUERY_INFORMATION_EX),
+				     FALSE, TRUE, NULL);
+
+	    MmProbeAndLockPages(InputMdl, Irp->RequestorMode,
+				IoModifyAccess);
+	    
+	    InputMdlLocked = TRUE;
+	    Status = STATUS_SUCCESS;
+	} _SEH_HANDLE {
+	    TI_DbgPrint(MAX_TRACE, ("Failed to acquire client buffer\n"));
+	    Status = _SEH_GetExceptionCode();
+	} _SEH_END;
+
+	if( !NT_SUCCESS(Status) || !InputMdl ) {
+	    if( InputMdl ) IoFreeMdl( InputMdl );
+	    ExFreePool(QueryContext);
+	    return Status;
+	}
+
+	RtlCopyMemory(&QueryContext->QueryInfo,
+		      InputBuffer, sizeof(TCP_REQUEST_QUERY_INFORMATION_EX));
+
+	QueryContext->Irp       = Irp;
+	QueryContext->InputMdl  = InputMdl;
+	QueryContext->OutputMdl = NULL;
+
+	Request.RequestNotifyObject = DispTdiQueryInformationExComplete;
+	Request.RequestContext      = QueryContext;
+	Status = InfoTdiQueryInformationEx(&Request,
+					   &QueryContext->QueryInfo.ID, 
+					   NULL,
+					   &Size, 
+					   &QueryContext->QueryInfo.Context);
+	DispTdiQueryInformationExComplete(QueryContext, Status, Size);
+	TI_DbgPrint(MAX_TRACE, ("Leaving. Status = (0x%X)\n", Status));
+    } else Status = STATUS_INVALID_PARAMETER;
 
     TI_DbgPrint(MIN_TRACE, ("Leaving. Status = (0x%X)\n", Status));
 

reactos/drivers/net/tcpip/tcpip
fileobjs.c 1.24 -> 1.24.2.1
diff -u -r1.24 -r1.24.2.1
--- fileobjs.c	21 Nov 2004 20:54:52 -0000	1.24
+++ fileobjs.c	8 Dec 2004 21:56:53 -0000	1.24.2.1
@@ -69,7 +69,7 @@
     while (CurrentEntry != &AddressFileListHead) {
         Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry);
 
-        IPAddress = &Current->ADE->Address;
+        IPAddress = &Current->Address;
 
         TI_DbgPrint(DEBUG_ADDRFILE, ("Comparing: ((%d, %d, %s), (%d, %d, %s)).\n",
             WN2H(Current->Port),
@@ -226,8 +226,9 @@
   USHORT Protocol,
   PVOID Options)
 {
-  PADDRESS_FILE AddrFile;
   IPv4_RAW_ADDRESS IPv4Address;
+  BOOLEAN Matched;
+  PADDRESS_FILE AddrFile;
 
   TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
 
@@ -250,18 +251,18 @@
   /* FIXME: IPv4 only */
   IPv4Address = Address->Address[0].Address[0].in_addr;
   if (IPv4Address == 0)
-      AddrFile->ADE = IPGetDefaultADE(ADE_UNICAST);
+      Matched = IPGetDefaultAddress(&AddrFile->Address);
   else
-      AddrFile->ADE = AddrLocateADEv4(IPv4Address);
+      Matched = AddrLocateADEv4(IPv4Address, &AddrFile->Address);
 
-  if (!AddrFile->ADE) {
+  if (!Matched) {
     ExFreePool(AddrFile);
     TI_DbgPrint(MIN_TRACE, ("Non-local address given (0x%X).\n", DN2H(IPv4Address)));
     return STATUS_INVALID_PARAMETER;
   }
 
   TI_DbgPrint(MID_TRACE, ("Opening address %s for communication (P=%d U=%d).\n",
-    A2S(&AddrFile->ADE->Address), Protocol, IPPROTO_UDP));
+    A2S(&AddrFile->Address), Protocol, IPPROTO_UDP));
 
   /* Protocol specific handling */
   switch (Protocol) {
@@ -377,15 +378,6 @@
   if( !Connection ) return STATUS_NO_MEMORY;
 
   Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
-  DbgPrint("STATUS from OSKITTCP was %08x\n", Status);
-
-  /* Initialize received segments queue */
-  InitializeListHead(&Connection->ReceivedSegments);
-
-TI_DbgPrint(MIN_TRACE, ("X1 cur 0x%x\n", &Connection->ReceivedSegments));
-TI_DbgPrint(MIN_TRACE, ("X1 Flink 0x%x\n", Connection->ReceivedSegments.Flink));
-TI_DbgPrint(MIN_TRACE, ("X1 Blink 0x%x\n", Connection->ReceivedSegments.Blink));
-
 
   /* Return connection endpoint file object */
   Request->Handle.ConnectionContext = Connection;
@@ -416,7 +408,7 @@
     KIRQL OldIrql;
     PCONNECTION_ENDPOINT Connection = NULL;
 
-    KeAcquireSpinLock( &ConnectionEndpointListLock, &OldIrql );
+    TcpipAcquireSpinLock( &ConnectionEndpointListLock, &OldIrql );
 
     for( Entry = ConnectionEndpointListHead.Flink; 
 	 Entry != &ConnectionEndpointListHead;
@@ -427,7 +419,7 @@
 	else Connection = NULL;
     }
 
-    KeReleaseSpinLock( &ConnectionEndpointListLock, OldIrql );
+    TcpipReleaseSpinLock( &ConnectionEndpointListLock, OldIrql );
 
     return Connection;
 }

reactos/drivers/net/tcpip/tcpip
iinfo.c 1.4 -> 1.4.8.1
diff -u -r1.4 -r1.4.8.1
--- iinfo.c	19 Aug 2004 21:38:59 -0000	1.4
+++ iinfo.c	8 Dec 2004 21:56:53 -0000	1.4.8.1
@@ -35,7 +35,7 @@
 
     OutData->Index = ID->tei_instance + 1; 
     /* viz: tcpip keeps those indices */
-    OutData->Type = IF ? 1 : 0; /* XXX other -- for now ... */
+    OutData->Type = Interface == Loopback ? IFENT_SOFTWARE_LOOPBACK : 0;
     OutData->Mtu = Interface->MTU;
     TI_DbgPrint(MAX_TRACE, 
 		("Getting interface speed\n"));

reactos/drivers/net/tcpip/tcpip
info.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- info.c	7 Nov 2004 20:37:19 -0000	1.9
+++ info.c	8 Dec 2004 21:56:53 -0000	1.9.2.1
@@ -147,9 +147,10 @@
     {
 	if ((ID->toi_class != INFO_CLASS_GENERIC) ||
 	    (ID->toi_type != INFO_TYPE_PROVIDER) ||
-	    (ID->toi_id != ENTITY_LIST_ID))
+	    (ID->toi_id != ENTITY_LIST_ID)) {
+	    TI_DbgPrint(MAX_TRACE,("Invalid parameter\n"));
 	    Status = TDI_INVALID_PARAMETER;
-        else
+        else
 	    Status = InfoTdiQueryListEntities(Buffer, BufferSize);
     } else {
 	TcpipAcquireSpinLock( &EntityListLock, &OldIrql );
@@ -209,24 +210,18 @@
 	case INFO_TYPE_PROVIDER:
 	    switch( ID->toi_id ) {
 	    case IP_MIB_ROUTETABLE_ENTRY_ID:
-		if( ID->toi_entity.tei_entity == CL_NL_ENTITY &&
-		    ID->toi_entity.tei_instance == TL_INSTANCE &&
-		    BufferSize >= sizeof(IPROUTE_ENTRY) ) {
-		    /* Add route -- buffer is an IPRouteEntry */
-		    PIPROUTE_ENTRY ire = (PIPROUTE_ENTRY)Buffer;
-		    RouteFriendlyAddRoute( ire );
-		} else {
-		    return TDI_INVALID_PARAMETER; 
-		    /* In my experience, we are being over
-		       protective compared to windows */
-		}
-		break;
+		return InfoNetworkLayerTdiSetEx
+		    ( ID->toi_class,
+		      ID->toi_type,
+		      ID->toi_id,
+		      NULL,
+		      &ID->toi_entity,
+		      Buffer,
+		      BufferSize );
 	    }
-	    break;
 	}
 	break;
     }
     
     return TDI_INVALID_PARAMETER;
 }
-

reactos/drivers/net/tcpip/tcpip
lock.c 1.1 -> 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- lock.c	7 Nov 2004 20:37:19 -0000	1.1
+++ lock.c	8 Dec 2004 21:56:53 -0000	1.1.2.1
@@ -49,9 +49,14 @@
 }
 
 UINT TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex, BOOL ToWrite ) {
-    return RecursiveMutexEnter( RecMutex, ToWrite );
+    UINT Ret;
+    TI_DbgPrint(DEBUG_LOCK,("Locking\n"));
+    Ret = RecursiveMutexEnter( RecMutex, ToWrite );
+    TI_DbgPrint(DEBUG_LOCK,("Locked\n"));
+    return Ret;
 }
 
 VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex ) {
+    TI_DbgPrint(DEBUG_LOCK,("Unlocking\n"));
     RecursiveMutexLeave( RecMutex );
 }

reactos/drivers/net/tcpip/tcpip
main.c 1.42 -> 1.42.2.1
diff -u -r1.42 -r1.42.2.1
--- main.c	17 Nov 2004 05:17:22 -0000	1.42
+++ main.c	8 Dec 2004 21:56:53 -0000	1.42.2.1
@@ -12,9 +12,9 @@
 #define NDEBUG
 
 #ifndef NDEBUG
-DWORD DebugTraceLevel = 0x7fffffff;
+DWORD DebugTraceLevel = DEBUG_ULTRA;
 #else
-DWORD DebugTraceLevel = 0; /*DEBUG_IP | DEBUG_PBUFFER | DEBUG_DATALINK;*/
+DWORD DebugTraceLevel = 0;
 #endif /* NDEBUG */
 
 PDEVICE_OBJECT TCPDeviceObject   = NULL;
@@ -29,6 +29,7 @@
 ULONG EntityMax                  = 0;
 UDP_STATISTICS UDPStats;
 
+/* Network timers */
 KTIMER IPTimer;
 KDPC IPTimeoutDpc;
 KSPIN_LOCK IpWorkLock;
@@ -256,6 +257,7 @@
 
   TI_DbgPrint(DEBUG_IRP, ("Leaving. Status = (0x%X).\n", Status));
 
+  Irp->IoStatus.Status = Status;
   return Status;
 }
 
@@ -670,7 +672,10 @@
  *     This routine is dispatched once in a while to do maintainance jobs
  */
 {
-    ExQueueWorkItem( &IpWorkItem, CriticalWorkQueue );
+    if( !IpWorkItemQueued ) {
+	ExQueueWorkItem( &IpWorkItem, CriticalWorkQueue );
+	IpWorkItemQueued = TRUE;
+    }
 }
 
 NTSTATUS

reactos/drivers/net/tcpip/tcpip
ninfo.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- ninfo.c	9 Nov 2004 09:39:37 -0000	1.7
+++ ninfo.c	8 Dec 2004 21:56:53 -0000	1.7.2.1
@@ -10,6 +10,9 @@
 
 #include "precomp.h"
 
+#define IP_ROUTE_TYPE_ADD 3
+#define IP_ROUTE_TYPE_DEL 2
+
 TDI_STATUS InfoTdiQueryGetAddrTable( PNDIS_BUFFER Buffer, 
 				     PUINT BufferSize ) {
     
@@ -37,7 +40,7 @@
 				 ADE_UNICAST,
 				 &IpAddress->Addr );
 	GetInterfaceIPv4Address( CurrentIF,
-				 ADE_MULTICAST,
+				 ADE_BROADCAST,
 				 &IpAddress->BcastAddr );
 	GetInterfaceIPv4Address( CurrentIF,
 				 ADE_ADDRMASK,
@@ -85,46 +88,42 @@
     
     while( RtCurrent < RouteEntries + RtCount ) {
 	/* Copy Desitnation */
-	if( RCacheCur->Router ) {
-	    TI_DbgPrint(MAX_TRACE, ("%d: NA %08x NM %08x GW %08x MT %d\n",
-				    RtCurrent - RouteEntries,
-				    &RCacheCur->NetworkAddress.Address,
-				    &RCacheCur->Netmask.Address,
-				    RCacheCur->Router->Address.Address,
-				    RCacheCur->Metric));
-	    
-	    RtlCopyMemory( &RtCurrent->Dest, 
-			   &RCacheCur->NetworkAddress.Address,
-			   sizeof(RtCurrent->Dest) );
-	    RtlCopyMemory( &RtCurrent->Mask,
-			   &RCacheCur->Netmask.Address,
-			   sizeof(RtCurrent->Mask) );
-	    /* Currently, this address is stuffed into the pointer.
-	     * That probably is not intended. */
+	RtlCopyMemory( &RtCurrent->Dest, 
+		       &RCacheCur->NetworkAddress.Address,
+		       sizeof(RtCurrent->Dest) );
+	RtlCopyMemory( &RtCurrent->Mask,
+		       &RCacheCur->Netmask.Address,
+		       sizeof(RtCurrent->Mask) );
+
+	if( RCacheCur->Router )
 	    RtlCopyMemory( &RtCurrent->Gw,
 			   &RCacheCur->Router->Address.Address,
 			   sizeof(RtCurrent->Gw) );
-	    RtCurrent->Metric1 = RCacheCur->Metric;
-	    RtCurrent->Type = 2 /* PF_INET */;
-	    
-	    TcpipAcquireSpinLock(&EntityListLock, &OldIrql);
-	    for( RtCurrent->Index = EntityCount - 1; 
-		 RtCurrent->Index >= 0 &&
-		     RCacheCur->Router->Interface != 
-		     EntityList[RtCurrent->Index].context;
-		 RtCurrent->Index-- );
-	    RtCurrent->Index = EntityList[RtCurrent->Index].tei_instance;
-	    TcpipReleaseSpinLock(&EntityListLock, OldIrql);
-	} else {
-	    TI_DbgPrint(MAX_TRACE, ("%d: BAD: NA %08x NM %08x GW %08x MT %d\n",
-				    RtCurrent - RouteEntries,
-				    RCacheCur->NetworkAddress,
-				    RCacheCur->Netmask,
-				    RCacheCur->Router,
-				    RCacheCur->Router ? 
-				    &RCacheCur->Router->Address : 0,
-				    RCacheCur->Metric));
-	}
+	else
+	    RtlZeroMemory( &RtCurrent->Gw, sizeof(RtCurrent->Gw) );
+			   
+	RtCurrent->Metric1 = RCacheCur->Metric;
+	RtCurrent->Type = TDI_ADDRESS_TYPE_IP;
+	
+	TI_DbgPrint
+	    (MAX_TRACE, 
+	     ("%d: NA %08x NM %08x GW %08x MT %x\n",
+	      RtCurrent - RouteEntries,
+	      RtCurrent->Dest, 
+	      RtCurrent->Mask,
+	      RtCurrent->Gw,
+	      RtCurrent->Metric1 ));
+	     
+	TcpipAcquireSpinLock(&EntityListLock, &OldIrql);
+	for( RtCurrent->Index = EntityCount; 
+	     RtCurrent->Index > 0 &&
+		 RCacheCur->Router->Interface != 
+		 EntityList[RtCurrent->Index - 1].context;
+	     RtCurrent->Index-- );
+	
+	RtCurrent->Index = EntityList[RtCurrent->Index].tei_instance;
+	TcpipReleaseSpinLock(&EntityListLock, OldIrql);
+	
 	RtCurrent++; RCacheCur++;
     }
 
@@ -140,31 +139,17 @@
 		
 TDI_STATUS InfoTdiQueryGetIPSnmpInfo( PNDIS_BUFFER Buffer,
 				      PUINT BufferSize ) {
-    KIRQL OldIrql;
-    IF_LIST_ITER(CurrentIF);
     IPSNMP_INFO SnmpInfo;
     UINT IfCount = CountInterfaces();
-    UINT AddrCount = 0;
-    UINT RouteCount = CountRouteNodes( NULL );
+    UINT RouteCount = CountFIBs( NULL );
     TDI_STATUS Status = TDI_INVALID_REQUEST;
 
     TI_DbgPrint(MAX_TRACE, ("Called.\n"));
 
     RtlZeroMemory(&SnmpInfo, sizeof(IPSNMP_INFO));
-    
-    /* Count number of addresses */
-    AddrCount = 0;
-    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
-    
-    ForEachInterface(CurrentIF) {
-	CurrentIF = CONTAINING_RECORD(CurrentIFEntry, IP_INTERFACE, ListEntry);
-	AddrCount += CountInterfaceAddresses( CurrentIF );
-    } EndFor(CurrentIF);
-    
-    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-    
+
     SnmpInfo.NumIf = IfCount;
-    SnmpInfo.NumAddr = AddrCount;
+    SnmpInfo.NumAddr = 1;
     SnmpInfo.NumRoutes = RouteCount;
 
     Status = InfoCopyOut( (PCHAR)&SnmpInfo, sizeof(SnmpInfo), 
@@ -227,6 +212,43 @@
 				     TDIEntityID *id,
 				     PCHAR Buffer,
 				     UINT BufferSize ) {
-    TDI_STATUS Status = TDI_INVALID_REQUEST;
+    NTSTATUS Status = TDI_INVALID_REQUEST;
+    IP_ADDRESS Address;
+    IP_ADDRESS Netmask;
+    IP_ADDRESS Router;
+    PNEIGHBOR_CACHE_ENTRY NCE;
+
+    TI_DbgPrint(MID_TRACE,("Called\n"));
+
+    OskitDumpBuffer( Buffer, BufferSize );
+
+    if( InfoClass == INFO_CLASS_PROTOCOL &&
+	InfoType == INFO_TYPE_PROVIDER &&
+	InfoId == IP_MIB_ROUTETABLE_ENTRY_ID &&
+	id->tei_entity == CL_NL_ENTITY ) { /* Add or delete a route */
+	PIPROUTE_ENTRY Route = (PIPROUTE_ENTRY)Buffer;
+	AddrInitIPv4( &Address, Route->Dest );
+	AddrInitIPv4( &Netmask, Route->Mask );
+	AddrInitIPv4( &Router,  Route->Gw );
+
+	if( Route->Type == IP_ROUTE_TYPE_ADD ) { /* Add the route */
+	    TI_DbgPrint(MID_TRACE,("Adding route (%s)\n", A2S(&Address)));
+	    /* Find the existing route this belongs to */
+	    NCE = RouterGetRoute( &Router );
+	    /* Really add the route */
+	    if( NCE && 
+		RouterCreateRoute( &Address, &Netmask, &Router, 
+				   NCE->Interface, Route->Metric1 ) ) 
+		Status = STATUS_SUCCESS;
+	    else
+		Status = STATUS_UNSUCCESSFUL;
+	} else if( Route->Type == IP_ROUTE_TYPE_DEL ) {
+	    TI_DbgPrint(MID_TRACE,("Removing route (%s)\n", A2S(&Address)));
+	    Status = RouterRemoveRoute( &Address, &Router );
+	} else Status = TDI_INVALID_REQUEST;
+    }
+
+    TI_DbgPrint(MID_TRACE,("Returning %x\n", Status));    
+
     return Status;
 }

reactos/drivers/test/csqtest
Makefile 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- Makefile	9 Feb 2004 06:59:01 -0000	1.1
+++ Makefile	8 Dec 2004 21:56:53 -0000	1.1.22.1
@@ -1,7 +1,7 @@
-#
-# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
-# file to this component.  This file merely indirects to the real make file
-# that is shared by all the components of Windows NT
-#
-!INCLUDE $(NTMAKEENV)\makefile.def
-
+#
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
+# file to this component.  This file merely indirects to the real make file
+# that is shared by all the components of Windows NT
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
+

reactos/drivers/test/csqtest
SOURCES 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- SOURCES	9 Feb 2004 06:59:01 -0000	1.1
+++ SOURCES	8 Dec 2004 21:56:53 -0000	1.1.22.1
@@ -1,5 +1,5 @@
-TARGETNAME=csqtest
-TARGETTYPE=DRIVER
-TARGETPATH=obj
-TARGETLIBS= csq.lib
-SOURCES= csqtest.c
+TARGETNAME=csqtest
+TARGETTYPE=DRIVER
+TARGETPATH=obj
+TARGETLIBS= csq.lib
+SOURCES= csqtest.c

reactos/drivers/video/displays/vga/main
enable.c 1.3 -> 1.3.20.1
diff -u -r1.3 -r1.3.20.1
--- enable.c	16 Mar 2004 21:11:44 -0000	1.3
+++ enable.c	8 Dec 2004 21:56:53 -0000	1.3.20.1
@@ -1,9 +1,9 @@
 /*
  * entry.c
  *
- * $Revision: 1.3 $
- * $Author: dwelch $
- * $Date: 2004/03/16 21:11:44 $
+ * $Revision: 1.3.20.1 $
+ * $Author: hyperion $
+ * $Date: 2004/12/08 21:56:53 $
  *
  */
 
@@ -340,7 +340,7 @@
 VOID STDCALL
 DrvDisablePDEV(IN DHPDEV PDev)
 {
-  PPDEV ppdev = (PPDEV)PDev;^M
+  PPDEV ppdev = (PPDEV)PDev;
 
   // EngDeletePalette(devinfoVGA.hpalDefault);
   if (ppdev->pjPreallocSSBBuffer != NULL)

reactos/drivers/video/displays/vga/objects
copybits.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- copybits.c	10 Jan 2004 14:39:20 -0000	1.1
+++ copybits.c	8 Dec 2004 21:56:54 -0000	1.1.24.1
@@ -1,40 +1,40 @@
-#include "../vgaddi.h"
-#include "../vgavideo/vgavideo.h"
-
-#define DBG
-#include <debug.h>
-
-BOOL STDCALL
-DrvCopyBits(OUT SURFOBJ*  DestObj,  
-            IN  SURFOBJ*  SourceObj,  
-            IN  CLIPOBJ*  ClipObj,  
-            IN  XLATEOBJ* XLateObj,  
-            IN  RECTL*    DestRectL,  
-            IN  POINTL*   SrcPointL)
-{
-  BOOL Done = FALSE;
-
-  if (STYPE_BITMAP == DestObj->iType && BMF_4BPP == DestObj->iBitmapFormat &&
-      STYPE_DEVICE == SourceObj->iType)
-    {
-    /* Screen to 4 BPP DIB */
-    DIB_BltFromVGA(SrcPointL->x, SrcPointL->y,
-                   DestRectL->right - DestRectL->left,
-                   DestRectL->bottom - DestRectL->top,
-                   DestObj->pvScan0, DestObj->lDelta);
-    Done = TRUE;
-    }
-  else if (STYPE_DEVICE == DestObj->iType &&
-           STYPE_BITMAP == SourceObj->iType && BMF_4BPP == SourceObj->iBitmapFormat)
-    {
-    /* 4 BPP DIB to Screen */
-    DIB_BltToVGA(DestRectL->left, DestRectL->top,
-                 DestRectL->right - DestRectL->left,
-                 DestRectL->bottom - DestRectL->top,
-                 SourceObj->pvScan0, SourceObj->lDelta,
-                 0);
-    Done = TRUE;
-    }
-
-  return Done;
-}
+#include "../vgaddi.h"
+#include "../vgavideo/vgavideo.h"
+
+#define DBG
+#include <debug.h>
+
+BOOL STDCALL
+DrvCopyBits(OUT SURFOBJ*  DestObj,  
+            IN  SURFOBJ*  SourceObj,  
+            IN  CLIPOBJ*  ClipObj,  
+            IN  XLATEOBJ* XLateObj,  
+            IN  RECTL*    DestRectL,  
+            IN  POINTL*   SrcPointL)
+{
+  BOOL Done = FALSE;
+
+  if (STYPE_BITMAP == DestObj->iType && BMF_4BPP == DestObj->iBitmapFormat &&
+      STYPE_DEVICE == SourceObj->iType)
+    {
+    /* Screen to 4 BPP DIB */
+    DIB_BltFromVGA(SrcPointL->x, SrcPointL->y,
+                   DestRectL->right - DestRectL->left,
+                   DestRectL->bottom - DestRectL->top,
+                   DestObj->pvScan0, DestObj->lDelta);
+    Done = TRUE;
+    }
+  else if (STYPE_DEVICE == DestObj->iType &&
+           STYPE_BITMAP == SourceObj->iType && BMF_4BPP == SourceObj->iBitmapFormat)
+    {
+    /* 4 BPP DIB to Screen */
+    DIB_BltToVGA(DestRectL->left, DestRectL->top,
+                 DestRectL->right - DestRectL->left,
+                 DestRectL->bottom - DestRectL->top,
+                 SourceObj->pvScan0, SourceObj->lDelta,
+                 0);
+    Done = TRUE;
+    }
+
+  return Done;
+}

reactos/hal/halx86
apic.c added at 1.2.2.1
diff -N apic.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ apic.c	8 Dec 2004 21:56:54 -0000	1.2.2.1
@@ -0,0 +1,853 @@
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: apic.c,v 1.2.2.1 2004/12/08 21:56:54 hyperion Exp $
+ *
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS kernel
+ * FILE:        hal/halx86/apic.c
+ * PURPOSE:     
+ * PROGRAMMER:  
+ */
+
+#include <roscfg.h>
+#include <ddk/ntddk.h>
+
+#include <hal.h>
+#include <halirq.h>
+#include <mps.h>
+#include <apic.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+BOOLEAN VerifyLocalAPIC(VOID);
+VOID APICCalibrateTimer(ULONG CPU);
+
+extern VOID MpsTimerInterrupt(VOID);
+extern VOID MpsErrorInterrupt(VOID);
+extern VOID MpsSpuriousInterrupt(VOID);
+extern VOID MpsIpiInterrupt(VOID);
+
+extern ULONG APICMode;		/* APIC mode at startup */
+extern PULONG BIOSBase;         /* Virtual address of BIOS data segment */
+extern PULONG CommonBase;       /* Virtual address of common area */
+extern ULONG BootCPU;           /* Bootstrap processor */
+extern ULONG OnlineCPUs;        /* Bitmask of online CPUs */
+
+extern CHAR *APstart, *APend;
+extern VOID (*APflush)(VOID);
+
+#define CMOS_READ(address) ({ \
+   WRITE_PORT_UCHAR((PUCHAR)0x70, address)); \
+   READ_PORT_UCHAR((PUCHAR)0x71)); \
+})
+
+#define CMOS_WRITE(address, value) ({ \
+   WRITE_PORT_UCHAR((PUCHAR)0x70, address); \
+   WRITE_PORT_UCHAR((PUCHAR)0x71, value); \
+})
+
+#define BIOS_AREA    0x0
+#define COMMON_AREA  0x2000
+
+
+extern CPU_INFO CPUMap[MAX_CPU];		/* Map of all CPUs in the system */
+
+PULONG APICBase = (PULONG)APIC_DEFAULT_BASE;	/* Virtual address of local APIC */
+
+/* For debugging */
+ULONG lastregr[MAX_CPU];
+ULONG lastvalr[MAX_CPU];
+ULONG lastregw[MAX_CPU];
+ULONG lastvalw[MAX_CPU];
+
+ULONG APICGetMaxLVT(VOID)
+{
+  ULONG tmp, ver, maxlvt;
+
+  tmp = APICRead(APIC_VER);
+  ver = GET_APIC_VERSION(tmp);
+  /* 82489DXs do not report # of LVT entries. */
+  maxlvt = APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(tmp) : 2;
+
+  return maxlvt;
+}
+
+VOID APICClear(VOID)
+{
+  ULONG tmp, maxlvt;
+
+  maxlvt = APICGetMaxLVT();
+
+  /*
+   * Careful: we have to set masks only first to deassert
+   * any level-triggered sources.
+   */
+
+  if (maxlvt >= 3) 
+  {
+    tmp = ERROR_VECTOR;
+    APICWrite(APIC_LVT3, tmp | APIC_LVT3_MASKED);
+  }
+
+  tmp = APICRead(APIC_LVTT);
+  APICWrite(APIC_LVTT, tmp | APIC_LVT_MASKED);
+
+  tmp = APICRead(APIC_LINT0);
+  APICWrite(APIC_LINT0, tmp | APIC_LVT_MASKED);
+
+  tmp = APICRead(APIC_LINT1);
+  APICWrite(APIC_LINT1, tmp | APIC_LVT_MASKED);
+
+  if (maxlvt >= 4) 
+  {
+    tmp = APICRead(APIC_LVTPC);
+    APICWrite(APIC_LVTPC, tmp | APIC_LVT_MASKED);
+  }
+#if 0
+  if (maxlvt >= 5)
+  {
+    tmp = APICRead(APIC_LVTTHMR);
+    APICWrite(APIC_LVTTHMR, tmp | APIC_LVT_MASKED);
+  }
+#endif
+  /*
+   * Clean APIC state for other OSs:
+   */
+  APICWrite(APIC_LVTT, APIC_LVT_MASKED);
+  APICWrite(APIC_LINT0, APIC_LVT_MASKED);
+  APICWrite(APIC_LINT1, APIC_LVT_MASKED);
+
+  if (maxlvt >= 3) 
+  {
+    APICWrite(APIC_LVT3, APIC_LVT3_MASKED);
+  }
+
+  if (maxlvt >= 4) 
+  {
+    APICWrite(APIC_LVTPC, APIC_LVT_MASKED);
+  }
+#if 0
+  if (maxlvt >= 5) 
+  {
+    APICWrite(APIC_LVTTHMR, APIC_LVT_MASKED);
+  }
+#endif
+}
+
+/* Enable symetric I/O mode ie. connect the BSP's local APIC to INT and NMI lines */
+VOID EnableSMPMode(VOID)
+{
+   /*
+    * Do not trust the local APIC being empty at bootup.
+    */
+   APICClear();
+
+   WRITE_PORT_UCHAR((PUCHAR)0x22, 0x70);
+   WRITE_PORT_UCHAR((PUCHAR)0x23, 0x01);
+}
+
+/* Disable symetric I/O mode ie. go to PIC mode */
+inline VOID DisableSMPMode(VOID)
+{
+   /*
+    * Put the board back into PIC mode (has an effect
+    * only on certain older boards).  Note that APIC
+    * interrupts, including IPIs, won't work beyond
+    * this point!  The only exception are INIT IPIs.
+    */
+   WRITE_PORT_UCHAR((PUCHAR)0x22, 0x70);
+   WRITE_PORT_UCHAR((PUCHAR)0x23, 0x00);
+}
+
+VOID DumpESR(VOID)
+{
+  ULONG tmp;
+
+  if (APICGetMaxLVT() > 3)
+  {
+    APICWrite(APIC_ESR, 0);
+  }
+  tmp = APICRead(APIC_ESR);
+  DbgPrint("ESR %08x\n", tmp);
+}
+
+
+VOID APICDisable(VOID)
+{
+  ULONG tmp;
+
+  APICClear();
+
+  /*
+   * Disable APIC (implies clearing of registers for 82489DX!).
+   */
+  tmp = APICRead(APIC_SIVR);
+  tmp &= ~APIC_SIVR_ENABLE;
+  APICWrite(APIC_SIVR, tmp);
+}
+
+VOID HaliInitBSP(VOID)
+{
+   PUSHORT ps;
+   static BOOLEAN BSPInitialized = FALSE;
+
+   /* Only initialize the BSP once */
+   if (BSPInitialized)
+   {
+      KEBUGCHECK(0);
+      return;
+   }
+
+   BSPInitialized = TRUE;
+
+   DPRINT("APIC is mapped at 0x%X\n", APICBase);
+
+   if (VerifyLocalAPIC()) 
+   {
+      DPRINT("APIC found\n");
+   } 
+   else 
+   {
+      DPRINT("No APIC found\n");
+      KEBUGCHECK(0);
+   }
+
+   if (APICMode == amPIC) 
+   {
+      EnableSMPMode();
+   }
+
+   APICSetup();
+
+   /* BIOS data segment */
+   BIOSBase = (PULONG)BIOS_AREA;
+   
+   /* Area for communicating with the APs */
+   CommonBase = (PULONG)COMMON_AREA;
+ 
+   /* Copy bootstrap code to common area */
+   memcpy((PVOID)((ULONG)CommonBase + PAGE_SIZE),
+	  &APstart,
+	  (ULONG)&APend - (ULONG)&APstart + 1);
+
+   /* Set shutdown code */
+   CMOS_WRITE(0xF, 0xA);
+
+   /* Set warm reset vector */
+   ps = (PUSHORT)((ULONG)BIOSBase + 0x467);
+   *ps = (COMMON_AREA + PAGE_SIZE) & 0xF;
+ 
+   ps = (PUSHORT)((ULONG)BIOSBase + 0x469);
+   *ps = (COMMON_AREA + PAGE_SIZE) >> 4;
+
+   /* Calibrate APIC timer */
+   APICCalibrateTimer(BootCPU);
+}
+
+volatile inline ULONG _APICRead(ULONG Offset)
+{
+   PULONG p;
+
+   p = (PULONG)((ULONG)APICBase + Offset);
+   return *p;
+}
+
+#if 0
+inline VOID APICWrite(ULONG Offset,
+		      ULONG Value)
+{
+   PULONG p;
+
+   p = (PULONG)((ULONG)APICBase + Offset);
+
+   *p = Value;
+}
+#else
+inline VOID APICWrite(ULONG Offset,
+		      ULONG Value)
+{
+   PULONG p;
+   ULONG CPU = (_APICRead(APIC_ID) & APIC_ID_MASK) >> 24;
+
+   lastregw[CPU] = Offset;
+   lastvalw[CPU] = Value;
+
+   p = (PULONG)((ULONG)APICBase + Offset);
+
+   *p = Value;
+}
+#endif
+
+
+#if 0
+volatile inline ULONG APICRead(ULONG Offset)
+{
+   PULONG p;
+
+   p = (PULONG)((ULONG)APICBase + Offset);
+   return *p;
+}
+#else
+volatile inline ULONG APICRead(ULONG Offset)
+{
+   PULONG p;
+   ULONG CPU = (_APICRead(APIC_ID) & APIC_ID_MASK) >> 24;
+
+   lastregr[CPU] = Offset;
+   lastvalr[CPU] = 0;
+
+   p = (PULONG)((ULONG)APICBase + Offset);
+
+   lastvalr[CPU] = *p;
+   return lastvalr[CPU];
+}
+#endif
+
+inline VOID APICSendEOI(VOID)
+{
+  // Send the EOI
+  APICWrite(APIC_EOI, 0);
+}
+
+static VOID APICDumpBit(ULONG base)
+{
+	ULONG v, i, j;
+
+	DbgPrint("0123456789abcdef0123456789abcdef\n");
+	for (i = 0; i < 8; i++) 
+	{
+		v = APICRead(base + i*0x10);
+		for (j = 0; j < 32; j++) 
+		{
+			if (v & (1<<j))
+				DbgPrint("1");
+			else
+				DbgPrint("0");
+		}
+		DbgPrint("\n");
+	}
+}
+
+
+VOID APICDump(VOID)
+/*
+ * Dump the contents of the local APIC registers
+ */
+{
+  ULONG v, ver, maxlvt;
+  ULONG r1, r2, w1, w2;
+  ULONG CPU = ThisCPU();;
+
+
+
+  r1 = lastregr[CPU];
+  r2 = lastvalr[CPU];
+  w1 = lastregw[CPU];
+  w2 = lastvalw[CPU];
+
+  DbgPrint("\nPrinting local APIC contents on CPU(%d):\n", ThisCPU());
+  v = APICRead(APIC_ID);
+  DbgPrint("... ID     : %08x (%01x) ", v, GET_APIC_ID(v));
+  v = APICRead(APIC_VER);
+  DbgPrint("... VERSION: %08x\n", v);
+  ver = GET_APIC_VERSION(v);
+  maxlvt = APICGetMaxLVT();
+
+  v = APICRead(APIC_TPR);
+  DbgPrint("... TPR    : %08x (%02x)", v, v & ~0);
+
+  if (APIC_INTEGRATED(ver)) 
+  {
+     /* !82489DX */
+     v = APICRead(APIC_APR);
+     DbgPrint("... APR    : %08x (%02x)\n", v, v & ~0);
+     v = APICRead(APIC_PPR);
+     DbgPrint("... PPR    : %08x\n", v);
+  }
+
+  v = APICRead(APIC_EOI);
+  DbgPrint("... EOI    : %08x  !  ", v);
+  v = APICRead(APIC_LDR);
+  DbgPrint("... LDR    : %08x\n", v);
+  v = APICRead(APIC_DFR);
+  DbgPrint("... DFR    : %08x  !  ", v);
+  v = APICRead(APIC_SIVR);
+  DbgPrint("... SIVR   : %08x\n", v);
+
+  if (0)
+  {
+  	DbgPrint("... ISR field:\n");
+  	APICDumpBit(APIC_ISR);
+  	DbgPrint("... TMR field:\n");
+  	APICDumpBit(APIC_TMR);
+  	DbgPrint("... IRR field:\n");
+  	APICDumpBit(APIC_IRR);
+  }
+
+  if (APIC_INTEGRATED(ver)) 
+  {
+     /* !82489DX */
+     if (maxlvt > 3)		
+     {
+	/* Due to the Pentium erratum 3AP. */
+	APICWrite(APIC_ESR, 0);
+     }
+     v = APICRead(APIC_ESR);
+     DbgPrint("... ESR    : %08x\n", v);
+  }
+ 
+  v = APICRead(APIC_ICR0);
+  DbgPrint("... ICR0   : %08x  !  ", v);
+  v = APICRead(APIC_ICR1);
+  DbgPrint("... ICR1   : %08x  !  ", v);
+
+  v = APICRead(APIC_LVTT);
+  DbgPrint("... LVTT   : %08x\n", v);
+
+  if (maxlvt > 3) 
+  {
+     /* PC is LVT#4. */
+     v = APICRead(APIC_LVTPC);
+     DbgPrint("... LVTPC  : %08x  !  ", v);
+  }
+  v = APICRead(APIC_LINT0);
+  DbgPrint("... LINT0  : %08x  !  ", v);
+  v = APICRead(APIC_LINT1);
+  DbgPrint("... LINT1  : %08x\n", v);
+
+  if (maxlvt > 2) 
+  {
+     v = APICRead(APIC_LVT3);
+     DbgPrint("... LVT3   : %08x\n", v);
+  }
+
+  v = APICRead(APIC_ICRT);
+  DbgPrint("... ICRT   : %08x  !  ", v);
+  v = APICRead(APIC_CCRT);
+  DbgPrint("... CCCT   : %08x  !  ", v);
+  v = APICRead(APIC_TDCR);
+  DbgPrint("... TDCR   : %08x\n", v);
+  DbgPrint("\n");
+  DbgPrint("Last register read (offset): 0x%08X\n", r1);
+  DbgPrint("Last register read (value): 0x%08X\n", r2);
+  DbgPrint("Last register written (offset): 0x%08X\n", w1);
+  DbgPrint("Last register written (value): 0x%08X\n", w2);
+  DbgPrint("\n");
+}
+
+BOOLEAN VerifyLocalAPIC(VOID)
+{
+   UINT reg0, reg1;
+   CHECKPOINT1;
+   /* The version register is read-only in a real APIC */
+   reg0 = APICRead(APIC_VER);
+   DPRINT1("Getting VERSION: %x\n", reg0);
+   APICWrite(APIC_VER, reg0 ^ APIC_VER_MASK);
+   reg1 = APICRead(APIC_VER);
+   DPRINT1("Getting VERSION: %x\n", reg1);
+
+   /*
+    * The two version reads above should print the same
+    * numbers.  If the second one is different, then we
+    * poke at a non-APIC.
+    */
+
+   if (reg1 != reg0)
+   {
+      return FALSE;
+   }
+
+   /*
+    * Check if the version looks reasonably.
+    */
+   reg1 = GET_APIC_VERSION(reg0);
+   if (reg1 == 0x00 || reg1 == 0xff)
+   {
+      return FALSE;
+   }
+   reg1 = APICGetMaxLVT();
+   if (reg1 < 0x02 || reg1 == 0xff)
+   {
+      return FALSE;
+   }
+
+   /*
+    * The ID register is read/write in a real APIC.
+    */
+   reg0 = APICRead(APIC_ID);
+   DPRINT1("Getting ID: %x\n", reg0);
+   APICWrite(APIC_ID, reg0 ^ APIC_ID_MASK);
+   reg1 = APICRead(APIC_ID);
+   DPRINT1("Getting ID: %x\n", reg1);
+   APICWrite(APIC_ID, reg0);
+   if (reg1 != (reg0 ^ APIC_ID_MASK))
+   {
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+VOID APICSendIPI(ULONG Target, ULONG Mode)
+{
+   ULONG tmp, i, flags;
+
+   /* save flags and disable interrupts */
+   Ki386SaveFlags(flags);
+   Ki386DisableInterrupts();
+
+   /* Wait up to 100ms for the APIC to become ready */
+   for (i = 0; i < 10000; i++) 
+   {
+      tmp = APICRead(APIC_ICR0);
+      /* Check Delivery Status */
+      if ((tmp & APIC_ICR0_DS) == 0)
+         break;
+      KeStallExecutionProcessor(10);
+   }
+
+   if (i == 10000) 
+   {
+      DPRINT1("CPU(%d) Previous IPI was not delivered after 100ms.\n", ThisCPU());
+   }
+
+   /* Setup the APIC to deliver the IPI */
+   DPRINT("%08x %x\n", SET_APIC_DEST_FIELD(Target), Target);
+   APICWrite(APIC_ICR1, SET_APIC_DEST_FIELD(Target));
+
+   if (Target == APIC_TARGET_SELF) 
+   {
+      Mode |= APIC_ICR0_DESTS_SELF;
+   } 
+   else if (Target == APIC_TARGET_ALL) 
+   {
+      Mode |= APIC_ICR0_DESTS_ALL;
+   } 
+   else if (Target == APIC_TARGET_ALL_BUT_SELF) 
+   {
+      Mode |= APIC_ICR0_DESTS_ALL_BUT_SELF;
+   } 
+   else 
+   {
+      Mode |= APIC_ICR0_DESTS_FIELD;
+   }
+
+   /* Now, fire off the IPI */
+   APICWrite(APIC_ICR0, Mode);
+
+   /* Wait up to 100ms for the APIC to become ready */
+   for (i = 0; i < 10000; i++) 
+   {
+      tmp = APICRead(APIC_ICR0);
+      /* Check Delivery Status */
+      if ((tmp & APIC_ICR0_DS) == 0)
+         break;
+      KeStallExecutionProcessor(10);
+   }
+
+   if (i == 10000) 
+   {
+      DPRINT1("CPU(%d) Current IPI was not delivered after 100ms.\n", ThisCPU());
+   }
+   Ki386RestoreFlags(flags);
+}
+
+VOID APICSetup(VOID)
+{
+   ULONG CPU, tmp;
+
+   CPU = ThisCPU();
+
+//   APICDump();
+  
+   DPRINT1("CPU%d:\n", CPU);
+   DPRINT1("  Physical APIC id: %d\n", GET_APIC_ID(APICRead(APIC_ID)));
+   DPRINT1("  Logical APIC id:  %d\n", GET_APIC_LOGICAL_ID(APICRead(APIC_LDR)));
+   DPRINT1("%08x %08x %08x\n", APICRead(APIC_ID), APICRead(APIC_LDR), APICRead(APIC_DFR));
+
+   /*
+    * Intel recommends to set DFR, LDR and TPR before enabling
+    * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
+    * document number 292116).  So here it goes...
+    */
+
+   /*
+    * Put the APIC into flat delivery mode.
+    * Must be "all ones" explicitly for 82489DX.
+    */
+   APICWrite(APIC_DFR, 0xFFFFFFFF);
+
+   /*
+    * Set up the logical destination ID.
+    */
+   tmp = APICRead(APIC_LDR);
+   tmp &= ~APIC_LDR_MASK;
+   /* 
+    * FIXME:
+    *   This works only up to 8 CPU's
+    */
+   tmp |= (1 << (KeGetCurrentProcessorNumber() + 24));
+   APICWrite(APIC_LDR, tmp);
+
+
+   DPRINT1("CPU%d:\n", CPU);
+   DPRINT1("  Physical APIC id: %d\n", GET_APIC_ID(APICRead(APIC_ID)));
+   DPRINT1("  Logical APIC id:  %d\n", GET_APIC_LOGICAL_ID(APICRead(APIC_LDR)));
+   DPRINT1("%08x %08x %08x\n", APICRead(APIC_ID), APICRead(APIC_LDR), APICRead(APIC_DFR));
+   DPRINT1("%d\n", CPUMap[CPU].APICId);
+
+   /* Accept only higher interrupts */
+   APICWrite(APIC_TPR, 0xef);
+
+   /* Enable local APIC */
+   tmp = APICRead(APIC_SIVR);
+   tmp &= ~0xff;
+   tmp |= APIC_SIVR_ENABLE;
+
+#if 0
+   tmp &= ~APIC_SIVR_FOCUS;
+#else
+   tmp |= APIC_SIVR_FOCUS;
+#endif
+
+  /* Set spurious interrupt vector */
+  tmp |= SPURIOUS_VECTOR;
+  APICWrite(APIC_SIVR, tmp);
+
+  /*
+   * Set up LVT0, LVT1:
+   *
+   * set up through-local-APIC on the BP's LINT0. This is not
+   * strictly necessery in pure symmetric-IO mode, but sometimes
+   * we delegate interrupts to the 8259A.
+   */
+  tmp = APICRead(APIC_LINT0) & APIC_LVT_MASKED;
+  if (CPU == BootCPU && (APICMode == amPIC || !tmp)) 
+  {
+     tmp = APIC_DM_EXTINT;
+     DPRINT1("enabled ExtINT on CPU#%d\n", CPU);
+  } 
+  else 
+  {
+     tmp = APIC_DM_EXTINT | APIC_LVT_MASKED;
+     DPRINT1("masked ExtINT on CPU#%d\n", CPU);
+  }
+  APICWrite(APIC_LINT0, tmp);
+
+
+  /*
+   * Only the BSP should see the LINT1 NMI signal, obviously.
+   */
+  if (CPU == BootCPU)
+  {
+     tmp = APIC_DM_NMI;
+  }
+  else
+  {
+     tmp = APIC_DM_NMI | APIC_LVT_MASKED;
+  }
+  if (!APIC_INTEGRATED(CPUMap[CPU].APICVersion)) 
+  {
+     /* 82489DX */
+     tmp |= APIC_LVT_LEVEL_TRIGGER;
+  }
+  APICWrite(APIC_LINT1, tmp);
+
+  if (APIC_INTEGRATED(CPUMap[CPU].APICVersion)) 
+  {	
+     /* !82489DX */
+     if (APICGetMaxLVT() > 3) 
+     {
+	/* Due to the Pentium erratum 3AP */
+	APICWrite(APIC_ESR, 0);
+     }
+
+     tmp = APICRead(APIC_ESR);
+     DPRINT("ESR value before enabling vector: 0x%X\n", tmp);
+
+     /* Enable sending errors */
+     tmp = ERROR_VECTOR;
+     APICWrite(APIC_LVT3, tmp);
+
+     /*
+      * Spec says clear errors after enabling vector
+      */
+     if (APICGetMaxLVT() > 3)
+     {
+        APICWrite(APIC_ESR, 0);
+     }
+     tmp = APICRead(APIC_ESR);
+     DPRINT("ESR value after enabling vector: 0x%X\n", tmp);
+  }
+}
+
+VOID APICSyncArbIDs(VOID)
+{
+   ULONG i, tmp;
+
+   /* Wait up to 100ms for the APIC to become ready */
+   for (i = 0; i < 10000; i++) 
+   {
+      tmp = APICRead(APIC_ICR0);
+      /* Check Delivery Status */
+      if ((tmp & APIC_ICR0_DS) == 0)
+         break;
+      KeStallExecutionProcessor(10);
+   }
+
+   if (i == 10000) 
+   {
+      DPRINT("CPU(%d) APIC busy for 100ms.\n", ThisCPU());
+   }
+
+   DPRINT("Synchronizing Arb IDs.\n");
+   APICWrite(APIC_ICR0, APIC_ICR0_DESTS_ALL | APIC_ICR0_LEVEL | APIC_DM_INIT);
+}
+
+VOID MpsErrorHandler(VOID)
+{
+  ULONG tmp1, tmp2;
+
+  APICDump();
+
+  tmp1 = APICRead(APIC_ESR);
+  APICWrite(APIC_ESR, 0);
+  tmp2 = APICRead(APIC_ESR);
+  DPRINT1("APIC error on CPU(%d) ESR(%x)(%x)\n", ThisCPU(), tmp1, tmp2);
+
+  /*
+   * Acknowledge the interrupt
+   */
+  APICSendEOI();
+
+  /* Here is what the APIC error bits mean:
+   *   0: Send CS error
+   *   1: Receive CS error
+   *   2: Send accept error
+   *   3: Receive accept error
+   *   4: Reserved
+   *   5: Send illegal vector
+   *   6: Received illegal vector
+   *   7: Illegal register address
+   */
+  DPRINT1("APIC error on CPU(%d) ESR(%x)(%x)\n", ThisCPU(), tmp1, tmp2);
+  for (;;);
+}
+
+VOID MpsSpuriousHandler(VOID)
+{
+  ULONG tmp;
+
+  DPRINT1("Spurious interrupt on CPU(%d)\n", ThisCPU());
+  
+  tmp = APICRead(APIC_ISR + ((SPURIOUS_VECTOR & ~0x1f) >> 1));
+  if (tmp & (1 << (SPURIOUS_VECTOR & 0x1f)))
+  {
+      APICSendEOI();
+      return;
+  }
+#if 0
+  /* No need to send EOI here */
+  APICDump();
+#endif
+}
+
+VOID MpsIpiHandler(VOID)
+{
+   KIRQL oldIrql;
+
+   HalBeginSystemInterrupt(IPI_VECTOR, 
+                           VECTOR2IRQL(IPI_VECTOR), 
+			   &oldIrql);
+   Ki386EnableInterrupts();
+#if 0
+   DbgPrint("(%s:%d) MpsIpiHandler on CPU%d, current irql is %d\n", 
+            __FILE__,__LINE__, KeGetCurrentProcessorNumber(), KeGetCurrentIrql());
+#endif   
+
+   KiIpiServiceRoutine(NULL, NULL);
+
+#if 0
+   DbgPrint("(%s:%d) MpsIpiHandler on CPU%d done\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber());
+#endif
+
+   Ki386DisableInterrupts();
+   HalEndSystemInterrupt(oldIrql, 0);
+}
+
+VOID
+MpsIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame,
+			   PKTRAP_FRAME TrapFrame)
+{
+   TrapFrame->Gs     = (USHORT)IrqTrapFrame->Gs;
+   TrapFrame->Fs     = (USHORT)IrqTrapFrame->Fs;
+   TrapFrame->Es     = (USHORT)IrqTrapFrame->Es;
+   TrapFrame->Ds     = (USHORT)IrqTrapFrame->Ds;
+   TrapFrame->Eax    = IrqTrapFrame->Eax;
+   TrapFrame->Ecx    = IrqTrapFrame->Ecx;
+   TrapFrame->Edx    = IrqTrapFrame->Edx;
+   TrapFrame->Ebx    = IrqTrapFrame->Ebx;
+   TrapFrame->Esp    = IrqTrapFrame->Esp;
+   TrapFrame->Ebp    = IrqTrapFrame->Ebp;
+   TrapFrame->Esi    = IrqTrapFrame->Esi;
+   TrapFrame->Edi    = IrqTrapFrame->Edi;
+   TrapFrame->Eip    = IrqTrapFrame->Eip;
+   TrapFrame->Cs     = IrqTrapFrame->Cs;
+   TrapFrame->Eflags = IrqTrapFrame->Eflags;
+}
+
+VOID
+MpsTimerHandler(ULONG Vector, PKIRQ_TRAPFRAME Trapframe)
+{
+   KIRQL oldIrql;
+   KTRAP_FRAME KernelTrapFrame;
+#if 0
+   ULONG CPU;
+   static ULONG Count[MAX_CPU] = {0,};
+#endif
+   HalBeginSystemInterrupt(LOCAL_TIMER_VECTOR, 
+                           VECTOR2IRQL(LOCAL_TIMER_VECTOR), 
+			   &oldIrql);
+   Ki386EnableInterrupts();
+
+#if 0
+   CPU = ThisCPU();
+   if ((Count[CPU] % 100) == 0)
+   {
+     DbgPrint("(%s:%d) MpsTimerHandler on CPU%d, irql = %d, epi = %x, KPCR = %x\n", __FILE__, __LINE__, CPU, oldIrql,Trapframe->Eip, KeGetCurrentKPCR());
+   }
+   Count[CPU]++;
+#endif
+
+   MpsIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame);
+   if (KeGetCurrentProcessorNumber() == 0)
+   {
+      KeUpdateSystemTime(&KernelTrapFrame, oldIrql);
+   }
+   else
+   {
+      KeUpdateRunTime(&KernelTrapFrame, oldIrql);
+   }
+
+   Ki386DisableInterrupts();
+   HalEndSystemInterrupt (oldIrql, 0);
+}
+
+/* EOF */

reactos/hal/halx86
Makefile 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- Makefile	18 Oct 2004 19:11:07 -0000	1.14
+++ Makefile	8 Dec 2004 21:56:54 -0000	1.14.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.14 2004/10/18 19:11:07 chorns Exp $
+# $Id: Makefile,v 1.14.2.1 2004/12/08 21:56:54 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -72,6 +72,7 @@
 
 HAL_MP = \
   $(HAL_OBJECTS) \
+	apic.o \
 	mpsirql.o \
 	mpsboot.o \
 	mps.o

reactos/hal/halx86
halinit.c 1.9 -> 1.9.8.1
diff -u -r1.9 -r1.9.8.1
--- halinit.c	22 Jul 2004 18:49:18 -0000	1.9
+++ halinit.c	8 Dec 2004 21:56:54 -0000	1.9.8.1
@@ -1,4 +1,4 @@
-/* $Id: halinit.c,v 1.9 2004/07/22 18:49:18 navaraf Exp $
+/* $Id: halinit.c,v 1.9.8.1 2004/12/08 21:56:54 hyperion Exp $
  *
  * COPYRIGHT:     See COPYING in the top level directory
  * PROJECT:       ReactOS kernel
@@ -64,7 +64,6 @@
     {
       HalpInitBusHandlers();
       HalpInitDma();
-      HalpCalibrateStallExecution();
 
       /* Enumerate the devices on the motherboard */
       HalpStartEnumerator();

reactos/hal/halx86
misc.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- misc.c	1 Nov 2004 19:01:25 -0000	1.7
+++ misc.c	8 Dec 2004 21:56:54 -0000	1.7.2.1
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.7 2004/11/01 19:01:25 hbirr Exp $
+/* $Id: misc.c,v 1.7.2.1 2004/12/08 21:56:54 hyperion Exp $
  *
  * COPYRIGHT:             See COPYING in the top level directory
  * PROJECT:               ReactOS kernel
@@ -13,6 +13,13 @@
 #include <ddk/ntddk.h>
 #include <hal.h>
 
+#ifdef MP
+#include <apic.h>
+#endif
+
+#define NDEBUG
+#include <internal/debug.h>
+
 /* FUNCTIONS ****************************************************************/
 
 #ifdef MP
@@ -54,14 +61,16 @@
 #endif
 }
 
-
 VOID STDCALL
-HalRequestIpi(ULONG Unknown)
+HalRequestIpi(ULONG ProcessorNo)
 {
-  return;
+  DPRINT("HalRequestIpi(ProcessorNo %d)\n", ProcessorNo);
+#ifdef MP 
+  APICSendIPI(1 << ProcessorNo,
+	      IPI_VECTOR|APIC_ICR0_LEVEL_DEASSERT|APIC_ICR0_DESTM);
+#endif
 }
 
-
 ULONG FASTCALL
 HalSystemVectorDispatchEntry (
 	ULONG	Unknown1,

reactos/hal/halx86
mp.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- mp.c	1 Nov 2004 19:01:25 -0000	1.11
+++ mp.c	8 Dec 2004 21:56:54 -0000	1.11.2.1
@@ -1,4 +1,4 @@
-/* $Id: mp.c,v 1.11 2004/11/01 19:01:25 hbirr Exp $
+/* $Id: mp.c,v 1.11.2.1 2004/12/08 21:56:54 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -23,6 +23,7 @@
 #include <hal.h>
 #include <halirq.h>
 #include <mps.h>
+#include <apic.h>
 
 #include <internal/ntoskrnl.h>
 #include <internal/i386/segment.h>
@@ -69,9 +70,7 @@
 
 ULONG APICMode;                     /* APIC mode at startup */
 ULONG BootCPU;                      /* Bootstrap processor */
-ULONG NextCPU;                      /* Next CPU to start */
 PULONG BIOSBase;                    /* Virtual address of BIOS data segment */
-PULONG APICBase;                    /* Virtual address of local APIC */
 PULONG CommonBase;                  /* Virtual address of common area */
 
 extern CHAR *APstart, *APend;
@@ -80,6 +79,7 @@
 extern VOID MpsTimerInterrupt(VOID);
 extern VOID MpsErrorInterrupt(VOID);
 extern VOID MpsSpuriousInterrupt(VOID);
+extern VOID MpsIpiInterrupt(VOID);
 
 #define CMOS_READ(address) ({ \
    WRITE_PORT_UCHAR((PUCHAR)0x70, address)); \
@@ -91,21 +91,9 @@
    WRITE_PORT_UCHAR((PUCHAR)0x71, value); \
 })
 
-static BOOLEAN MPSInitialized = FALSE;  /* Is the MP system initialized? */
-
-VOID APICDisable(VOID);
-static VOID APICSyncArbIDs(VOID);
-
-/* For debugging */
-ULONG lastregr = 0;
-ULONG lastvalr = 0;
-ULONG lastregw = 0;
-ULONG lastvalw = 0;
-
 #endif /* MP */
 
 
-static BOOLEAN BSPInitialized = FALSE;  /* Is the BSP initialized? */
 
 /* FUNCTIONS *****************************************************************/
 
@@ -117,10 +105,10 @@
 {
     ULONG tmp;
 
-    if (irq & 8) 
+    if (irq >= 8) 
     {
        tmp = READ_PORT_UCHAR((PUCHAR)0xA1);
-       tmp |= (1 << irq);
+       tmp |= (1 << (irq - 8));
        WRITE_PORT_UCHAR((PUCHAR)0xA1, tmp);
     } 
     else 
@@ -136,10 +124,10 @@
 {
     ULONG tmp;
 
-    if (irq & 8) 
+    if (irq >= 8) 
     {
        tmp = READ_PORT_UCHAR((PUCHAR)0xA1);
-       tmp &= ~(1 << irq);
+       tmp &= ~(1 << (irq - 8));
        WRITE_PORT_UCHAR((PUCHAR)0xA1, tmp);
     } 
     else 
@@ -176,6 +164,7 @@
 {
   IOAPIC_ROUTE_ENTRY Entry;
 
+  DPRINT("IOAPICClearPin(Apic %d, Pin %d\n", Apic, Pin);
   /*
    * Disable it in the IO-APIC irq-routing table
    */
@@ -652,7 +641,7 @@
 	  */
 	 entry.dest.logical.logical_dest = OnlineCPUs;
 #else
-	 entry.dest.logical.logical_dest = 1 << BootCPU;
+	 entry.dest.logical.logical_dest = 1 << 0;
 #endif
 	 idx = IOAPICGetIrqEntry(apic,pin,INT_VECTORED);
 	 if (idx == -1) 
@@ -679,7 +668,7 @@
 #if 0
 	    entry.dest.logical.logical_dest = OnlineCPUs;
 #else
-	    entry.dest.logical.logical_dest = 1 << BootCPU;
+	    entry.dest.logical.logical_dest = 1 << 0;
 #endif
 	 }
 
@@ -899,317 +888,6 @@
 
 /* Functions for handling local APICs */
 
-#if 0
-volatile inline ULONG APICRead(ULONG Offset)
-{
-   PULONG p;
-
-   p = (PULONG)((ULONG)APICBase + Offset);
-   return *p;
-}
-#else
-volatile inline ULONG APICRead(ULONG Offset)
-{
-   PULONG p;
-
-   lastregr = Offset;
-   lastvalr = 0;
-
-   p = (PULONG)((ULONG)APICBase + Offset);
-
-   lastvalr = *p;
-   return lastvalr;
-}
-#endif
-
-#if 0
-inline VOID APICWrite(ULONG Offset,
-		      ULONG Value)
-{
-   PULONG p;
-
-   p = (PULONG)((ULONG)APICBase + Offset);
-
-   *p = Value;
-}
-#else
-inline VOID APICWrite(ULONG Offset,
-		      ULONG Value)
-{
-   PULONG p;
-
-   lastregw = Offset;
-   lastvalw = Value;
-
-   p = (PULONG)((ULONG)APICBase + Offset);
-
-   *p = Value;
-}
-#endif
-
-
-inline VOID APICSendEOI(VOID)
-{
-  // Send the EOI
-  APICWrite(APIC_EOI, 0);
-}
-
-
-VOID DumpESR(VOID)
-{
-  ULONG tmp;
-
-  if (CPUMap[ThisCPU()].MaxLVT > 3)
-  {
-    APICWrite(APIC_ESR, 0);
-  }
-  tmp = APICRead(APIC_ESR);
-  DbgPrint("ESR %08x\n", tmp);
-}
-
-
-ULONG APICGetMaxLVT(VOID)
-{
-  ULONG tmp, ver, maxlvt;
-
-  tmp = APICRead(APIC_VER);
-  ver = GET_APIC_VERSION(tmp);
-  /* 82489DXs do not report # of LVT entries. */
-  maxlvt = APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(tmp) : 2;
-
-  return maxlvt;
-}
-
-
-static VOID APICClear(VOID)
-{
-  ULONG tmp, maxlvt;
-
-  maxlvt = CPUMap[ThisCPU()].MaxLVT;
-
-  /*
-   * Careful: we have to set masks only first to deassert
-   * any level-triggered sources.
-   */
-  tmp = APICRead(APIC_LVTT);
-  APICWrite(APIC_LVTT, tmp | APIC_LVT_MASKED);
-
-  tmp = APICRead(APIC_LINT0);
-  APICWrite(APIC_LINT0, tmp | APIC_LVT_MASKED);
-
-  tmp = APICRead(APIC_LINT1);
-  APICWrite(APIC_LINT1, tmp | APIC_LVT_MASKED);
-
-  if (maxlvt >= 3) 
-  {
-    tmp = APICRead(APIC_LVT3);
-    APICWrite(APIC_LVT3, tmp | APIC_LVT3_MASKED);
-  }
-  
-  if (maxlvt >= 4) 
-  {
-    tmp = APICRead(APIC_LVTPC);
-    APICWrite(APIC_LVTPC, tmp | APIC_LVT_MASKED);
-  }
-
-  /*
-   * Clean APIC state for other OSs:
-   */
-  APICRead(APIC_SIVR);    // Dummy read
-  APICWrite(APIC_LVTT, APIC_LVT_MASKED);
-
-  APICRead(APIC_SIVR);    // Dummy read
-  APICWrite(APIC_LINT0, APIC_LVT_MASKED);
-
-  APICRead(APIC_SIVR);    // Dummy read
-  APICWrite(APIC_LINT1, APIC_LVT_MASKED);
-
-  if (maxlvt >= 3) 
-  {
-    APICRead(APIC_SIVR);  // Dummy read
-    APICWrite(APIC_LVT3, APIC_LVT3_MASKED);
-  }
-
-  if (maxlvt >= 4) 
-  {
-    APICRead(APIC_SIVR);  // Dummy read
-    APICWrite(APIC_LVTPC, APIC_LVT_MASKED);
-  }
-}
-
-/* Enable symetric I/O mode ie. connect the BSP's
-   local APIC to INT and NMI lines */
-inline VOID EnableSMPMode(VOID)
-{
-   /*
-    * Do not trust the local APIC being empty at bootup.
-    */
-   APICClear();
-
-   WRITE_PORT_UCHAR((PUCHAR)0x22, 0x70);
-   WRITE_PORT_UCHAR((PUCHAR)0x23, 0x01);
-}
-
-
-/* Disable symetric I/O mode ie. go to PIC mode */
-inline VOID DisableSMPMode(VOID)
-{
-   /*
-    * Put the board back into PIC mode (has an effect
-    * only on certain older boards).  Note that APIC
-    * interrupts, including IPIs, won't work beyond
-    * this point!  The only exception are INIT IPIs.
-    */
-   WRITE_PORT_UCHAR((PUCHAR)0x22, 0x70);
-   WRITE_PORT_UCHAR((PUCHAR)0x23, 0x00);
-}
-
-
-VOID APICDisable(VOID)
-{
-  ULONG tmp;
-
-  APICClear();
-
-  /*
-   * Disable APIC (implies clearing of registers for 82489DX!).
-   */
-  tmp = APICRead(APIC_SIVR);
-  tmp &= ~APIC_SIVR_ENABLE;
-  APICWrite(APIC_SIVR, tmp);
-}
-
-
-inline ULONG ThisCPU(VOID)
-{
-   return (APICRead(APIC_ID) & APIC_ID_MASK) >> 24;
-}
-
-
-static VOID APICDumpBit(ULONG base)
-{
-	ULONG v, i, j;
-
-	DbgPrint("0123456789abcdef0123456789abcdef\n");
-	for (i = 0; i < 8; i++) 
-	{
-		v = APICRead(base + i*0x10);
-		for (j = 0; j < 32; j++) 
-		{
-			if (v & (1<<j))
-				DbgPrint("1");
-			else
-				DbgPrint("0");
-		}
-		DbgPrint("\n");
-	}
-}
-
-
-VOID APICDump(VOID)
-/*
- * Dump the contents of the local APIC registers
- */
-{
-  ULONG v, ver, maxlvt;
-  ULONG r1, r2, w1, w2;
-
-  r1 = lastregr;
-  r2 = lastvalr;
-  w1 = lastregw;
-  w2 = lastvalw;
-
-  DbgPrint("\nPrinting local APIC contents on CPU(%d):\n", ThisCPU());
-  v = APICRead(APIC_ID);
-  DbgPrint("... ID     : %08x (%01x) ", v, GET_APIC_ID(v));
-  v = APICRead(APIC_VER);
-  DbgPrint("... VERSION: %08x\n", v);
-  ver = GET_APIC_VERSION(v);
-  maxlvt = CPUMap[ThisCPU()].MaxLVT;
-
-  v = APICRead(APIC_TPR);
-  DbgPrint("... TPR    : %08x (%02x)", v, v & ~0);
-
-  if (APIC_INTEGRATED(ver)) 
-  {
-     /* !82489DX */
-     v = APICRead(APIC_APR);
-     DbgPrint("... APR    : %08x (%02x)\n", v, v & ~0);
-     v = APICRead(APIC_PPR);
-     DbgPrint("... PPR    : %08x\n", v);
-  }
-
-  v = APICRead(APIC_EOI);
-  DbgPrint("... EOI    : %08x  !  ", v);
-  v = APICRead(APIC_LDR);
-  DbgPrint("... LDR    : %08x\n", v);
-  v = APICRead(APIC_DFR);
-  DbgPrint("... DFR    : %08x  !  ", v);
-  v = APICRead(APIC_SIVR);
-  DbgPrint("... SIVR   : %08x\n", v);
-
-  if (0)
-  {
-  	DbgPrint("... ISR field:\n");
-  	APICDumpBit(APIC_ISR);
-  	DbgPrint("... TMR field:\n");
-  	APICDumpBit(APIC_TMR);
-  	DbgPrint("... IRR field:\n");
-  	APICDumpBit(APIC_IRR);
-  }
-
-  if (APIC_INTEGRATED(ver)) 
-  {
-     /* !82489DX */
-     if (maxlvt > 3)		
-     {
-	/* Due to the Pentium erratum 3AP. */
-	APICWrite(APIC_ESR, 0);
-     }
-     v = APICRead(APIC_ESR);
-     DbgPrint("... ESR    : %08x\n", v);
-  }
- 
-  v = APICRead(APIC_ICR0);
-  DbgPrint("... ICR0   : %08x  !  ", v);
-  v = APICRead(APIC_ICR1);
-  DbgPrint("... ICR1   : %08x  !  ", v);
-
-  v = APICRead(APIC_LVTT);
-  DbgPrint("... LVTT   : %08x\n", v);
-
-  if (maxlvt > 3) 
-  {
-     /* PC is LVT#4. */
-     v = APICRead(APIC_LVTPC);
-     DbgPrint("... LVTPC  : %08x  !  ", v);
-  }
-  v = APICRead(APIC_LINT0);
-  DbgPrint("... LINT0  : %08x  !  ", v);
-  v = APICRead(APIC_LINT1);
-  DbgPrint("... LINT1  : %08x\n", v);
-
-  if (maxlvt > 2) 
-  {
-     v = APICRead(APIC_LVT3);
-     DbgPrint("... LVT3   : %08x\n", v);
-  }
-
-  v = APICRead(APIC_ICRT);
-  DbgPrint("... ICRT   : %08x  !  ", v);
-  v = APICRead(APIC_CCRT);
-  DbgPrint("... CCCT   : %08x  !  ", v);
-  v = APICRead(APIC_TDCR);
-  DbgPrint("... TDCR   : %08x\n", v);
-  DbgPrint("\n");
-  DbgPrint("Last register read (offset): 0x%08X\n", r1);
-  DbgPrint("Last register read (value): 0x%08X\n", r2);
-  DbgPrint("Last register written (offset): 0x%08X\n", w1);
-  DbgPrint("Last register written (value): 0x%08X\n", w2);
-  DbgPrint("\n");
-}
-
-
 ULONG Read8254Timer(VOID)
 {
 	ULONG Count;
@@ -1221,7 +899,6 @@
 	return Count;
 }
 
-
 VOID WaitFor8254Wraparound(VOID)
 {
    ULONG CurCount, PrevCount = ~0;
@@ -1316,155 +993,7 @@
 	  CPUMap[CPU].BusSpeed%1000000);
 }
 
-
-static VOID APICSleep(ULONG Count)
-/*
-   PARAMETERS:
-      Count = Number of microseconds to busy wait
- */
-{
-  KeStallExecutionProcessor(Count);
-}
-
-
-static VOID APICSyncArbIDs(VOID)
-{
-   ULONG i, tmp;
-
-   /* Wait up to 100ms for the APIC to become ready */
-   for (i = 0; i < 10000; i++) 
-   {
-      tmp = APICRead(APIC_ICR0);
-      /* Check Delivery Status */
-      if ((tmp & APIC_ICR0_DS) == 0)
-         break;
-      APICSleep(10);
-   }
-
-   if (i == 10000) 
-   {
-      DPRINT("CPU(%d) APIC busy for 100ms.\n", ThisCPU());
-   }
-
-   DPRINT("Synchronizing Arb IDs.\n");
-   APICWrite(APIC_ICR0, APIC_ICR0_DESTS_ALL | APIC_ICR0_LEVEL | APIC_DM_INIT);
-}
-
-
-VOID APICSendIPI(ULONG Target,
-		 ULONG DeliveryMode,
-		 ULONG IntNum,
-		 ULONG Level)
-{
-   ULONG tmp, i, flags;
-
-   /* save flags and disable interrupts */
-   Ki386SaveFlags(flags);
-   Ki386DisableInterrupts();
-
-   /* Wait up to 100ms for the APIC to become ready */
-   for (i = 0; i < 10000; i++) 
-   {
-      tmp = APICRead(APIC_ICR0);
-      /* Check Delivery Status */
-      if ((tmp & APIC_ICR0_DS) == 0)
-         break;
-      APICSleep(10);
-   }
-
-   if (i == 10000) 
-   {
-      DPRINT("CPU(%d) Previous IPI was not delivered after 100ms.\n", ThisCPU());
-   }
-
-   /* Setup the APIC to deliver the IPI */
-   tmp = APICRead(APIC_ICR1);
-   tmp &= 0x00FFFFFF;
-   APICWrite(APIC_ICR1, tmp | SET_APIC_DEST_FIELD(Target));
-
-   tmp  = APICRead(APIC_ICR0);
-   tmp &= ~(APIC_ICR0_LEVEL | APIC_ICR0_DESTM | APIC_ICR0_DM | APIC_ICR0_VECTOR);
-   tmp |= (DeliveryMode | IntNum | Level);
-
-   if (Target == APIC_TARGET_SELF) 
-   {
-      tmp |= APIC_ICR0_DESTS_SELF;
-   } 
-   else if (Target == APIC_TARGET_ALL) 
-   {
-      tmp |= APIC_ICR0_DESTS_ALL;
-   } 
-   else if (Target == APIC_TARGET_ALL_BUT_SELF) 
-   {
-      tmp |= APIC_ICR0_DESTS_ALL_BUT_SELF;
-   } 
-   else 
-   {
-      tmp |= APIC_ICR0_DESTS_FIELD;
-   }
-
-   /* Now, fire off the IPI */
-   APICWrite(APIC_ICR0, tmp);
-
-   Ki386RestoreFlags(flags);
-}
-
-
-BOOLEAN VerifyLocalAPIC(VOID)
-{
-   UINT reg0, reg1;
-  
-   /* The version register is read-only in a real APIC */
-   reg0 = APICRead(APIC_VER);
-   DPRINT("Getting VERSION: %x\n", reg0);
-   APICWrite(APIC_VER, reg0 ^ APIC_VER_MASK);
-   reg1 = APICRead(APIC_VER);
-   DPRINT("Getting VERSION: %x\n", reg1);
-
-   /*
-    * The two version reads above should print the same
-    * numbers.  If the second one is different, then we
-    * poke at a non-APIC.
-    */
-
-   if (reg1 != reg0)
-   {
-      return FALSE;
-   }
-
-   /*
-    * Check if the version looks reasonably.
-    */
-   reg1 = GET_APIC_VERSION(reg0);
-   if (reg1 == 0x00 || reg1 == 0xff)
-   {
-      return FALSE;
-   }
-   reg1 = APICGetMaxLVT();
-   if (reg1 < 0x02 || reg1 == 0xff)
-   {
-      return FALSE;
-   }
-
-   /*
-    * The ID register is read/write in a real APIC.
-    */
-   reg0 = APICRead(APIC_ID);
-   DPRINT("Getting ID: %x\n", reg0);
-   APICWrite(APIC_ID, reg0 ^ APIC_ID_MASK);
-   reg1 = APICRead(APIC_ID);
-   DPRINT("Getting ID: %x\n", reg1);
-   APICWrite(APIC_ID, reg0);
-   if (reg1 != (reg0 ^ APIC_ID_MASK))
-   {
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-
-static VOID 
+VOID 
 SetInterruptGate(ULONG index, ULONG address)
 {
   IDT_DESCRIPTOR *idt;
@@ -1474,302 +1003,85 @@
   idt->b = 0x8e00 + (((ULONG)address)&0xffff0000);
 }
 
-VOID KeSetCurrentIrql (KIRQL NewIrql);
-VOID HalpLowerIrql(KIRQL NewIrql);
-
-
-
-VOID
-MpsIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame,
-			   PKTRAP_FRAME TrapFrame)
-{
-   TrapFrame->Gs     = (USHORT)IrqTrapFrame->Gs;
-   TrapFrame->Fs     = (USHORT)IrqTrapFrame->Fs;
-   TrapFrame->Es     = (USHORT)IrqTrapFrame->Es;
-   TrapFrame->Ds     = (USHORT)IrqTrapFrame->Ds;
-   TrapFrame->Eax    = IrqTrapFrame->Eax;
-   TrapFrame->Ecx    = IrqTrapFrame->Ecx;
-   TrapFrame->Edx    = IrqTrapFrame->Edx;
-   TrapFrame->Ebx    = IrqTrapFrame->Ebx;
-   TrapFrame->Esp    = IrqTrapFrame->Esp;
-   TrapFrame->Ebp    = IrqTrapFrame->Ebp;
-   TrapFrame->Esi    = IrqTrapFrame->Esi;
-   TrapFrame->Edi    = IrqTrapFrame->Edi;
-   TrapFrame->Eip    = IrqTrapFrame->Eip;
-   TrapFrame->Cs     = IrqTrapFrame->Cs;
-   TrapFrame->Eflags = IrqTrapFrame->Eflags;
-}
-
+#endif /* MP */
 
-VOID
-MpsTimerHandler(ULONG Vector, PKIRQ_TRAPFRAME Trapframe)
+VOID STDCALL
+HalInitializeProcessor(ULONG ProcessorNumber,
+		       PVOID /*PLOADER_PARAMETER_BLOCK*/ LoaderBlock)
 {
-   KIRQL oldIrql;
+#ifdef MP
    ULONG CPU;
-   KTRAP_FRAME KernelTrapFrame;
-#if 0
-   static ULONG Count[MAX_CPU] = {0,};
 #endif
-   APICWrite (APIC_TPR, 0xff & APIC_TPR_PRI);
-   APICSendEOI();
-
-   oldIrql = KeGetCurrentIrql ();
-   KeSetCurrentIrql (PROFILE_LEVEL);
 
-   Ki386EnableInterrupts();
+   DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);
 
+#ifdef MP
    CPU = ThisCPU();
-
-#if 0
-   if ((Count[CPU] % 100) == 0)
+   if (OnlineCPUs & (1 << CPU))
    {
-     DPRINT1("MpsTimerHandler(), CPU = %d, irql = %d, Eip = %x\n", CPU, oldIrql,Trapframe->Eip);
+      KEBUGCHECK(0);
    }
-   Count[CPU]++;
-#endif
 
-   MpsIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame);
-   if (CPU == BootCPU)
+   if (ProcessorNumber == 0)
    {
-      KeUpdateSystemTime(&KernelTrapFrame, oldIrql);
+      HaliInitBSP();
    }
    else
    {
-      KeUpdateRunTime(&KernelTrapFrame, oldIrql);
-   }
-   
-   Ki386DisableInterrupts();
-   HalpLowerIrql (oldIrql);
-   APICWrite (APIC_TPR, IRQL2TPR (oldIrql) & APIC_TPR_PRI);
-}
-
-VOID MpsErrorHandler(VOID)
-{
-  ULONG tmp1, tmp2;
-
-  APICDump();
-
-  tmp1 = APICRead(APIC_ESR);
-  APICWrite(APIC_ESR, 0);
-  tmp2 = APICRead(APIC_ESR);
-  DPRINT1("APIC error on CPU(%d) ESR(%x)(%x)\n", ThisCPU(), tmp1, tmp2);
-
-  /*
-   * Acknowledge the interrupt
-   */
-  APICSendEOI();
-
-  /* Here is what the APIC error bits mean:
-   *   0: Send CS error
-   *   1: Receive CS error
-   *   2: Send accept error
-   *   3: Receive accept error
-   *   4: Reserved
-   *   5: Send illegal vector
-   *   6: Received illegal vector
-   *   7: Illegal register address
-   */
-  DPRINT1("APIC error on CPU(%d) ESR(%x)(%x)\n", ThisCPU(), tmp1, tmp2);
-  for (;;);
-}
-
-
-VOID MpsSpuriousHandler(VOID)
-{
-  DPRINT1("Spurious interrupt on CPU(%d)\n", ThisCPU());
-
-  /* No need to send EOI here */
-
-  APICDump();
-}
-
-
-VOID APICSetup(VOID)
-{
-   ULONG CPU, tmp;
-
-   CPU = ThisCPU();
-
-   /*
-    * Intel recommends to set DFR, LDR and TPR before enabling
-    * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
-    * document number 292116).  So here it goes...
-    */
+      APICSetup();
 
-   /*
-    * Put the APIC into flat delivery mode.
-    * Must be "all ones" explicitly for 82489DX.
-    */
-   APICWrite(APIC_DFR, 0xFFFFFFFF);
+      DPRINT("CPU %d says it is now booted.\n", CPU);
+ 
+      APICCalibrateTimer(CPU);
+   }
 
-   /*
-    * Set up the logical destination ID.
-    */
-   tmp = APICRead(APIC_LDR);
-   tmp &= ~APIC_LDR_MASK;
-   tmp |= (1 << (CPU + 24));
-   APICWrite(APIC_LDR, tmp);
-
-   /* Accept all interrupts */
-   tmp = APICRead(APIC_TPR) & ~APIC_TPR_PRI;
-   APICWrite(APIC_TPR, tmp);
-
-   /* Enable local APIC */
-   tmp = APICRead(APIC_SIVR);
-   tmp &= ~0xff;
-   tmp |= APIC_SIVR_ENABLE;
+   /* This processor is now booted */
+   CPUMap[CPU].Flags |= CPU_ENABLED;
+   OnlineCPUs |= (1 << CPU);
 
-#if 1
-   tmp &= ~APIC_SIVR_FOCUS;
-#else
-   tmp |= APIC_SIVR_FOCUS;
+   /* Setup busy waiting */
+   HalpCalibrateStallExecution();
 #endif
-
-  /* Set spurious interrupt vector */
-  tmp |= SPURIOUS_VECTOR;
-  APICWrite(APIC_SIVR, tmp);
-
-  /*
-   * Set up LVT0, LVT1:
-   *
-   * set up through-local-APIC on the BP's LINT0. This is not
-   * strictly necessery in pure symmetric-IO mode, but sometimes
-   * we delegate interrupts to the 8259A.
-   */
-  tmp = APICRead(APIC_LINT0) & APIC_LVT_MASKED;
-  if (CPU == BootCPU && (APICMode == amPIC || !tmp)) 
-  {
-     tmp = APIC_DM_EXTINT;
-     DPRINT("enabled ExtINT on CPU#%d\n", CPU);
-  } 
-  else 
-  {
-     tmp = APIC_DM_EXTINT | APIC_LVT_MASKED;
-     DPRINT("masked ExtINT on CPU#%d\n", CPU);
-  }
-  APICWrite(APIC_LINT0, tmp);
-
-
-  /*
-   * Only the BSP should see the LINT1 NMI signal, obviously.
-   */
-  if (CPU == BootCPU)
-  {
-     tmp = APIC_DM_NMI;
-  }
-  else
-  {
-     tmp = APIC_DM_NMI | APIC_LVT_MASKED;
-  }
-  if (!APIC_INTEGRATED(CPUMap[CPU].APICVersion)) 
-  {
-     /* 82489DX */
-     tmp |= APIC_LVT_LEVEL_TRIGGER;
-  }
-  APICWrite(APIC_LINT1, tmp);
-
-  if (APIC_INTEGRATED(CPUMap[CPU].APICVersion)) 
-  {	
-     /* !82489DX */
-     if (CPUMap[CPU].MaxLVT > 3) 
-     {
-	/* Due to the Pentium erratum 3AP */
-	APICWrite(APIC_ESR, 0);
-     }
-
-     tmp = APICRead(APIC_ESR);
-     DPRINT("ESR value before enabling vector: 0x%X\n", tmp);
-
-     /* Enable sending errors */
-     tmp = ERROR_VECTOR;
-     APICWrite(APIC_LVT3, tmp);
-
-     /*
-      * Spec says clear errors after enabling vector
-      */
-     if (CPUMap[CPU].MaxLVT > 3)
-     {
-        APICWrite(APIC_ESR, 0);
-     }
-     tmp = APICRead(APIC_ESR);
-     DPRINT("ESR value after enabling vector: 0x%X\n", tmp);
-  }
 }
 
-VOID
-HaliInitBSP(VOID)
+BOOLEAN STDCALL
+HalAllProcessorsStarted (VOID)
 {
-   PUSHORT ps;
+    DPRINT("HalAllProcessorsStarted()\n");
 
-   /* Only initialize the BSP once */
-   if (BSPInitialized)
-   {
-      return;
-   }
-
-   BSPInitialized = TRUE;
-
-   DPRINT("APIC is mapped at 0x%X\n", APICBase);
-
-   if (VerifyLocalAPIC()) 
-   {
-      DPRINT("APIC found\n");
-   } 
-   else 
-   {
-      DPRINT1("No APIC found\n");
-      KEBUGCHECK(0);
-   }
-
-   CPUMap[BootCPU].MaxLVT = APICGetMaxLVT();
-
-   SetInterruptGate(LOCAL_TIMER_VECTOR, (ULONG)MpsTimerInterrupt);
-   SetInterruptGate(ERROR_VECTOR, (ULONG)MpsErrorInterrupt);
-   SetInterruptGate(SPURIOUS_VECTOR, (ULONG)MpsSpuriousInterrupt);
-
-   if (APICMode == amPIC) 
-   {
-      EnableSMPMode();
-   }
-
-   APICSetup();
+#ifdef MP
 
-   /* BIOS data segment */
-   BIOSBase = (PULONG)BIOS_AREA;
-   
-   /* Area for communicating with the APs */
-   CommonBase = (PULONG)COMMON_AREA;
- 
-   /* Copy bootstrap code to common area */
-   memcpy((PVOID)((ULONG)CommonBase + PAGE_SIZE),
-	  &APstart,
-	  (ULONG)&APend - (ULONG)&APstart + 1);
-
-   /* Set shutdown code */
-   CMOS_WRITE(0xF, 0xA);
-
-   /* Set warm reset vector */
-   ps = (PUSHORT)((ULONG)BIOSBase + 0x467);
-   *ps = (COMMON_AREA + PAGE_SIZE) & 0xF;
- 
-   ps = (PUSHORT)((ULONG)BIOSBase + 0x469);
-   *ps = (COMMON_AREA + PAGE_SIZE) >> 4;
+    ULONG CPUs = 0, i;
+    for (i = 0; i < 32; i++)
+    {
+       if (OnlineCPUs & (1 << i))
+       {
+          CPUs++;
+       }
+    }
+    if (CPUs > CPUCount)
+    {
+       KEBUGCHECK(0);
+    }
+    else if (CPUs == CPUCount)
+    {
+       IOAPICSetup();
+       return TRUE;
+    }
+    return FALSE;
 
-   /* Calibrate APIC timer */
-   APICCalibrateTimer(BootCPU);
+#else /* MP */
 
-   /* The boot processor is online */
-   OnlineCPUs = (1 << BootCPU);
-}
+    return TRUE;
 
 #endif /* MP */
+}
 
-VOID STDCALL HalInitializeProcessor(ULONG ProcessorNumber,
-				    PVOID ProcessorStack)
+BOOLEAN STDCALL 
+HalStartNextProcessor(ULONG Unknown1,
+		      ULONG ProcessorStack)
 {
-
 #ifdef MP
-
    PCOMMON_AREA_INFO Common;
    ULONG StartupCount;
    ULONG DeliveryStatus = 0;
@@ -1777,215 +1089,150 @@
    ULONG CPU, i, j;
    ULONG tmp, maxlvt;
 
-   DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, ProcessorStack);
+   DPRINT("HalStartNextProcessor(%x %x)\n", Unknown1, ProcessorStack);
 
-   if (ProcessorNumber == 0) 
+   for (CPU = 0; CPU < CPUCount; CPU++)
    {
-       /* Boot processor is already initialized */
-       NextCPU = 1;
-       return;
+      if (!(OnlineCPUs & (1<<CPU)))
+      {
+	 break;
+      }
    }
 
-   if (NextCPU < CPUCount) 
+   if (CPU >= CPUCount)
    {
-      for (CPU = 0; CPU < CPUCount; CPU++)
-      {
-        if (!(OnlineCPUs & (1<<CPU)))
-	{
-	   break;
-	}
-      }
+      KEBUGCHECK(0);
+   }
 
-      if (CPU >= CPUCount)
-      {
-        KEBUGCHECK(0);
-      }
+   DPRINT1("Attempting to boot CPU %d\n", CPU);
 
-  
-      DPRINT("Attempting to boot CPU %d\n", CPU);
+   /* Send INIT IPI */
 
-      /* Send INIT IPI */
-      APICSendIPI(CPUMap[CPU].APICId, APIC_DM_INIT, 0, APIC_ICR0_LEVEL_ASSERT);
+   APICSendIPI(CPU, APIC_DM_INIT|APIC_ICR0_LEVEL_ASSERT);
  
-      APICSleep(200);
+   KeStallExecutionProcessor(200);
 
-      /* Deassert INIT */
-      APICSendIPI(CPUMap[CPU].APICId, APIC_DM_INIT, 0, APIC_ICR0_LEVEL_DEASSERT);
+   /* Deassert INIT */
 
-      if (APIC_INTEGRATED(CPUMap[CPU].APICVersion)) 
-      {
-	 /* Clear APIC errors */
[truncated at 1000 lines; 462 more skipped]

reactos/hal/halx86
mps.S 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- mps.S	1 Nov 2004 19:01:25 -0000	1.3
+++ mps.S	8 Dec 2004 21:56:54 -0000	1.3.2.1
@@ -1,4 +1,4 @@
-/* $Id: mps.S,v 1.3 2004/11/01 19:01:25 hbirr Exp $
+/* $Id: mps.S,v 1.3.2.1 2004/12/08 21:56:54 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -36,6 +36,19 @@
   popl  %ds; \
   popa;
 
+.global _MpsIpiInterrupt
+_MpsIpiInterrupt:
+  /* Save registers */	
+  BEFORE
+
+  /* Call the C handler */
+  call  _MpsIpiHandler
+
+	/* Return to the caller */
+  AFTER
+  iret
+  
+  
 .globl _MpsErrorInterrupt
 _MpsErrorInterrupt:
   /* Save registers */	

reactos/hal/halx86
mpsirql.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- mpsirql.c	1 Nov 2004 19:01:25 -0000	1.11
+++ mpsirql.c	8 Dec 2004 21:56:54 -0000	1.11.2.1
@@ -19,6 +19,7 @@
 #include <halirq.h>
 #include <hal.h>
 #include <mps.h>
+#include <apic.h>
 
 #define NDEBUG
 #include <internal/debug.h>
@@ -26,9 +27,6 @@
 /* GLOBALS ******************************************************************/;
 
 
-VOID STDCALL
-KiInterruptDispatch2 (ULONG Irq, KIRQL old_level);
-
 /* FUNCTIONS ****************************************************************/
 
 KIRQL STDCALL KeGetCurrentIrql (VOID)
@@ -42,14 +40,16 @@
 
   Ki386SaveFlags(Flags);
   Ki386DisableInterrupts();
-  irql = KeGetCurrentKPCR()->Irql;
-  Ki386RestoreFlags(Flags);
 
+  irql = Ki386ReadFsByte(offsetof(KPCR, Irql));
   if (irql > HIGH_LEVEL)
     {
       DPRINT1 ("CurrentIrql %x\n", irql);
       KEBUGCHECK (0);
-      for(;;);
+    }
+  if (Flags & X86_EFLAGS_IF)
+    {
+      Ki386EnableInterrupts();
     }
   return irql;
 }
@@ -62,41 +62,46 @@
 {
   ULONG Flags;
   if (NewIrql > HIGH_LEVEL)
-    {
-      DPRINT1 ("NewIrql %x\n", NewIrql);
-      KEBUGCHECK (0);
-      for(;;);
-    }
+  {
+    DPRINT1 ("NewIrql %x\n", NewIrql);
+    KEBUGCHECK (0);
+  }
   Ki386SaveFlags(Flags);
   Ki386DisableInterrupts();
-  KeGetCurrentKPCR()->Irql = NewIrql;
-  Ki386RestoreFlags(Flags);
+  Ki386WriteFsByte(offsetof(KPCR, Irql), NewIrql);
+  if (Flags & X86_EFLAGS_IF)
+    {
+      Ki386EnableInterrupts();
+    }
 }
 
-
-
-
 VOID 
-HalpLowerIrql(KIRQL NewIrql)
+HalpLowerIrql(KIRQL NewIrql, BOOL FromHalEndSystemInterrupt)
 {
-  PKPCR Pcr = KeGetCurrentKPCR();
+  ULONG Flags;
   if (NewIrql >= DISPATCH_LEVEL)
     {
       KeSetCurrentIrql (NewIrql);
       APICWrite(APIC_TPR, IRQL2TPR (NewIrql) & APIC_TPR_PRI);
       return;
     }
+  Ki386SaveFlags(Flags);
   if (KeGetCurrentIrql() > APC_LEVEL)
-  {
-    KeSetCurrentIrql (DISPATCH_LEVEL);
-    APICWrite(APIC_TPR, IRQL2TPR (DISPATCH_LEVEL) & APIC_TPR_PRI);
-    if (Pcr->HalReserved[1])
     {
-      Pcr->HalReserved[1] = 0;
-      KiDispatchInterrupt();
+      KeSetCurrentIrql (DISPATCH_LEVEL);
+      APICWrite(APIC_TPR, IRQL2TPR (DISPATCH_LEVEL) & APIC_TPR_PRI);
+      if (FromHalEndSystemInterrupt || Ki386ReadFsByte(offsetof(KPCR, HalReserved[HAL_DPC_REQUEST])))
+        {
+          Ki386WriteFsByte(offsetof(KPCR, HalReserved[HAL_DPC_REQUEST]), 0);
+          Ki386EnableInterrupts();
+          KiDispatchInterrupt();
+          if (!(Flags & X86_EFLAGS_IF))
+            {
+              Ki386DisableInterrupts();
+            }
+	}
+      KeSetCurrentIrql (APC_LEVEL);
     }
-    KeSetCurrentIrql (APC_LEVEL);
-  }
   if (NewIrql == APC_LEVEL)
     {
       return;
@@ -104,7 +109,12 @@
   if (KeGetCurrentThread () != NULL && 
       KeGetCurrentThread ()->ApcState.KernelApcPending)
     {
-      KiDeliverApc (0, 0, 0);
+      Ki386EnableInterrupts();
+      KiDeliverApc(KernelMode, NULL, NULL);
+      if (!(Flags & X86_EFLAGS_IF))
+        {
+          Ki386DisableInterrupts();
+        }
     }
   KeSetCurrentIrql (PASSIVE_LEVEL);
 }
@@ -134,10 +144,8 @@
     {
       DPRINT1 ("NewIrql %x CurrentIrql %x\n", NewIrql, oldIrql);
       KEBUGCHECK (0);
-      for(;;);
     }
-  
-  HalpLowerIrql (NewIrql);
+  HalpLowerIrql (NewIrql, FALSE);
 }
 
 
@@ -186,22 +194,29 @@
 {
   KIRQL OldIrql;
   ULONG Flags;
-  
-  if (NewIrql < KeGetCurrentIrql ())
+ 
+  Ki386SaveFlags(Flags);
+  Ki386DisableInterrupts();
+
+  OldIrql = KeGetCurrentIrql ();
+
+  if (NewIrql < OldIrql)
     {
       DPRINT1 ("CurrentIrql %x NewIrql %x\n", KeGetCurrentIrql (), NewIrql);
       KEBUGCHECK (0);
-      for(;;);
     }
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
+
+
   if (NewIrql > DISPATCH_LEVEL)
     {
-      APICWrite (APIC_TPR, IRQL2TPR (NewIrql) & APIC_TPR_PRI);
+      APICWrite (APIC_TPR, IRQL2TPR(NewIrql) & APIC_TPR_PRI);
     }
-  OldIrql = KeGetCurrentIrql ();
   KeSetCurrentIrql (NewIrql);
-  Ki386RestoreFlags(Flags);
+  if (Flags & X86_EFLAGS_IF)
+    {
+      Ki386EnableInterrupts();
+    }
+
   return OldIrql;
 }
 
@@ -286,42 +301,43 @@
 {
   ULONG Flags;
   DPRINT("Vector (0x%X)  Irql (0x%X)\n", Vector, Irql);
-
+  
   if (KeGetCurrentIrql () >= Irql)
-    {
-      DPRINT1("current irql %d, new irql %d\n", KeGetCurrentIrql(), Irql);
-      KEBUGCHECK(0);
-    }
-
-  if (Vector < FIRST_DEVICE_VECTOR ||
-      Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS) 
   {
-    DPRINT1("Not a device interrupt, vector %x\n", Vector);
-    return FALSE;
+    DPRINT1("current irql %d, new irql %d\n", KeGetCurrentIrql(), Irql);
+    KEBUGCHECK(0);
   }
 
   Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
+  if (Flags & X86_EFLAGS_IF)
+  {
+     DPRINT1("HalBeginSystemInterrupt was called with interrupt's enabled\n");
+     KEBUGCHECK(0);
+  }
   APICWrite (APIC_TPR, IRQL2TPR (Irql) & APIC_TPR_PRI);
-
-  APICSendEOI();
-
   *OldIrql = KeGetCurrentIrql ();
   KeSetCurrentIrql (Irql);
-  Ki386RestoreFlags(Flags);
-
   return(TRUE);
 }
 
 
 VOID STDCALL
 HalEndSystemInterrupt (KIRQL Irql,
-	ULONG Unknown2)
+		       ULONG Unknown2)
 /*
  * FUNCTION: Finish a system interrupt and restore the specified irq level.
  */
 {
-  HalpLowerIrql (Irql);
+  ULONG Flags;
+  Ki386SaveFlags(Flags);
+
+  if (Flags & X86_EFLAGS_IF)
+  {
+     DPRINT1("HalEndSystemInterrupt was called with interrupt's enabled\n");
+     KEBUGCHECK(0);
+  }
+  APICSendEOI();
+  HalpLowerIrql (Irql, TRUE);
 }
   
 BOOLEAN STDCALL
@@ -369,21 +385,14 @@
 VOID FASTCALL
 HalRequestSoftwareInterrupt(IN KIRQL Request)
 {
-  ULONG Flags;
   switch (Request)
   {
     case APC_LEVEL:
-      Ki386SaveFlags(Flags);
-      Ki386DisableInterrupts();
-      KeGetCurrentKPCR()->HalReserved[0] = 1;
-      Ki386RestoreFlags(Flags);
+      Ki386WriteFsByte(offsetof(KPCR, HalReserved[HAL_APC_REQUEST]), 1);
       break;
 
     case DISPATCH_LEVEL:
-      Ki386SaveFlags(Flags);
-      Ki386DisableInterrupts();
-      KeGetCurrentKPCR()->HalReserved[1] = 1;
-      Ki386RestoreFlags(Flags);
+      Ki386WriteFsByte(offsetof(KPCR, HalReserved[HAL_DPC_REQUEST]), 1);
       break;
       
     default:

reactos/hal/halx86
timer.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- timer.c	14 Nov 2004 19:01:31 -0000	1.7
+++ timer.c	8 Dec 2004 21:56:54 -0000	1.7.2.1
@@ -20,7 +20,7 @@
  * MA 02139, USA.  
  *
  */
-/* $Id: timer.c,v 1.7 2004/11/14 19:01:31 hbirr Exp $
+/* $Id: timer.c,v 1.7.2.1 2004/12/08 21:56:54 hyperion Exp $
  *
  * PROJECT:        ReactOS kernel
  * FILE:           ntoskrnl/hal/x86/udelay.c
@@ -321,11 +321,18 @@
  * RETURNS: The number of performance counter ticks since boot
  */
 {
-  PKPCR Pcr = KeGetCurrentKPCR();
+  PKPCR Pcr;
   LARGE_INTEGER Value;
+  ULONG Flags;
+
+  Ki386SaveFlags(Flags);
+  Ki386DisableInterrupts();
+
+  Pcr = KeGetCurrentKPCR();
 
   if (Pcr->PrcbData.FeatureBits & X86_FEATURE_TSC)
   {
+     Ki386RestoreFlags(Flags);
      if (NULL != PerformanceFreq)
      {
         PerformanceFreq->QuadPart = Pcr->PrcbData.MHz * (ULONGLONG)1000000;   
@@ -338,6 +345,8 @@
      LARGE_INTEGER TicksNew;
      ULONG CountsLeft;
 
+     Ki386RestoreFlags(Flags);
+
      if (NULL != PerformanceFreq)
      {
         PerformanceFreq->QuadPart = CLOCK_TICK_RATE;

reactos/hal/halx86
.cvsignore removed after 1.5
diff -N .cvsignore
--- .cvsignore	28 Jun 2003 23:10:02 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,7 +0,0 @@
-*.d
-*.dll
-*.coff
-*.a
-*.o
-*.sym
-*.map

reactos/hal/halx86
adapter.c removed after 1.14
diff -N adapter.c
--- adapter.c	24 Nov 2004 17:54:38 -0000	1.14
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,679 +0,0 @@
-/* $Id: adapter.c,v 1.14 2004/11/24 17:54:38 navaraf Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            hal/x86/adapter.c (from ntoskrnl/io/adapter.c)
- * PURPOSE:         DMA handling
- * PROGRAMMERS:     David Welch (welch@mcmail.com)
- *                  Vizzini (vizzini@plasmic.com)
- * UPDATE HISTORY:
- *                  Created 22/05/98
- *                  18-Oct-2003 Vizzini DMA support modifications
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <ddk/iotypes.h>
-#define NDEBUG
-#include <internal/debug.h>
-#include <hal.h>
-
-/* FUNCTIONS *****************************************************************/
-
-/* NOTE: IoAllocateAdapterChannel in NTOSKRNL.EXE */
-
-
-NTSTATUS STDCALL
-HalAllocateAdapterChannel(
-  PADAPTER_OBJECT AdapterObject,
-  PWAIT_CONTEXT_BLOCK WaitContextBlock,
-  ULONG NumberOfMapRegisters,
-  PDRIVER_CONTROL ExecutionRoutine)
-/*
- * FUNCTION: Sets up an ADAPTER_OBJECT with map registers
- * ARGUMENTS:
- *     - AdapterObject: pointer to an ADAPTER_OBJECT to set up 
- *     - WaitContextBlock: Context block to be used with ExecutionRoutine
- *     - NumberOfMapRegisters: number of map registers requested 
- *     - ExecutionRoutine: callback to call when map registers are allocated
- * RETURNS:
- *     STATUS_INSUFFICIENT_RESOURCES if map registers cannot be allocated
- *     STATUS_SUCCESS in all other cases, including if the callbacak had
- *                    to be queued for later delivery
- * NOTES:
- *     - the ADAPTER_OBJECT struct is undocumented; please make copious
- *       notes in hal.h if anything is changed or improved since there is
- *       no other documentation for this data structure
- * BUGS:
- *     - it's possible that some of this code is in the wrong place
- *     - there are many unhandled cases
- */
-{
-  LARGE_INTEGER MinAddress;
-  LARGE_INTEGER MaxAddress;
-  LARGE_INTEGER BoundryAddressMultiple;
-  IO_ALLOCATION_ACTION Retval;
-  
-  ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
-  
-  /*
-  FIXME: return STATUS_INSUFFICIENT_RESOURCES if the NumberOfMapRegisters 
-  requested is larger than the value returned by IoGetDmaAdapter. 
-  */
-
-  /* set up the wait context block in case we can't run right away */
-  WaitContextBlock->DeviceRoutine = ExecutionRoutine;
-  WaitContextBlock->NumberOfMapRegisters = NumberOfMapRegisters;
-
-  /* returns true if queued, else returns false and sets the queue to busy */
-  if(KeInsertDeviceQueue(&AdapterObject->ChannelWaitQueue, &WaitContextBlock->WaitQueueEntry))
-    return STATUS_SUCCESS;
-
-  /* 24-bit max address due to 16-bit dma controllers */
-  MinAddress.QuadPart = 0x0000000;
-  MaxAddress.QuadPart = 0x1000000;
-  BoundryAddressMultiple.QuadPart = 0;
-
-  /* why 64K alignment? */
-  /*
-   * X86 lacks map registers, so for now, we allocate a contiguous
-   * block of physical memory <16MB and copy all DMA buffers into
-   * that.  This can be optimized.
-   *
-   * FIXME: We propably shouldn't allocate the memory here for common
-   * buffer transfers. See a comment in IoMapTransfer about common buffer
-   * support.
-   */
-  AdapterObject->MapRegisterBase = MmAllocateContiguousAlignedMemory( 
-      NumberOfMapRegisters * PAGE_SIZE,
-      MinAddress,
-      MaxAddress,
-      BoundryAddressMultiple,
-      MmCached,
-      0x10000 );
-
-  if(!AdapterObject->MapRegisterBase)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  AdapterObject->CommittedMapRegisters = NumberOfMapRegisters;
-
-  /* call the client's AdapterControl callback with its map registers and context */
-  Retval = ExecutionRoutine(WaitContextBlock->DeviceObject, WaitContextBlock->CurrentIrp, 
-      AdapterObject->MapRegisterBase, WaitContextBlock->DeviceContext);
-
-  /* 
-   * KeepObject: don't free any resources; the ADAPTER_OBJECT is still in use
-   *             and the caller will call IoFreeAdapterChannel later
-   *
-   * DeallocateObject: Deallocate the map registers and release the ADAPTER_OBJECT
-   *             so someone else can use it
-   *
-   * DeallocateObjectKeepRegisters: release the ADAPTER_OBJECT but hang on to
-   *             the map registers.  The client will later call IoFreeMapRegisters.
-   *
-   * NOTE - IoFreeAdapterChannel runs the queue, so it must be called
-   *        unless the adapter object is not to be freed.
-   */
-  if( Retval == DeallocateObject )
-      IoFreeAdapterChannel(AdapterObject);
-  else if(Retval == DeallocateObjectKeepRegisters)
-    {
-      /* don't free the allocated map registers - this is what IoFreeAdapterChannel checks */
-      AdapterObject->CommittedMapRegisters = 0;
-      IoFreeAdapterChannel(AdapterObject);
-    }
-
-  /*
-   * if we don't call IoFreeAdapterChannel, the next device won't get de-queued,
-   * which is what we want.
-   */
-
-  return STATUS_SUCCESS;
-}
-
-
-BOOLEAN
-HalpGrowMapBuffers(
-  IN PADAPTER_OBJECT	AdapterObject,
-  IN ULONG		SizeOfMapBuffers)
-/*
- * FUNCTION: Allocate initial, or additional, map buffers for IO adapters.
- * ARGUMENTS:
- *     AdapterObject: DMA adapter to allocate buffers for.
- *     SizeOfMapBuffers: Size of the map buffers to allocate
- * NOTES:
- *     - Needs to be tested...
- */
-{
-	//ULONG PagesToAllocate = BYTES_TO_PAGES(SizeOfMapBuffers);
-	
-	/* TODO: Allocation */
-
-	return TRUE;
-}
-
-PADAPTER_OBJECT STDCALL
-HalpAllocateAdapterEx(
-  ULONG NumberOfMapRegisters,
-  BOOLEAN IsMaster,
-  BOOLEAN Dma32BitAddresses)
-/*
- * FUNCTION: Allocates an ADAPTER_OBJECT, optionally creates the Master Adapter.
- * ARGUMENTS:
- *     - NumberOfMapRegisters: Number of map registers to allocate
- *     - IsMaster: Wether this is a Master Device or not
- *     - Dma32BitAddresses: Wether 32-bit Addresses are supported
- * RETURNS:
- *     - Pointer to Adapter Object, or NULL if failure.
- * BUGS:
- *     - Some stuff is unhandled/incomplete
- */
-{
-	OBJECT_ATTRIBUTES ObjectAttributes;
-	ULONG ObjectSize;
-	ULONG BitmapSize;
-	NTSTATUS Status;
-	ULONG AllowedMapRegisters = 64;
-	PADAPTER_OBJECT AdapterObject;
-	HANDLE Handle;
-	
-	/* Allocate the Master Adapter if we haven't already 
-	   but make sure we're not asked to do it now, and also check if we need it */
-	if ((MasterAdapter == NULL) && (!IsMaster) && (NumberOfMapRegisters)) {
-		
-		/* Allocate and Save */
-		DPRINT("Allocating the Master Adapter Object\n");
-		MasterAdapter = HalpAllocateAdapterEx(NumberOfMapRegisters,
-						     TRUE,
-						     Dma32BitAddresses);
-		
-		/* Cancel on Failure */
-		DPRINT("Checking if Master Adapter was allocated properly\n");
-		if (!MasterAdapter) return NULL;
-	}
-	
-	/* Initialize the Object Attributes for the Adapter Object */
-	InitializeObjectAttributes(&ObjectAttributes,
-				   NULL,
-				   OBJ_PERMANENT,
-				   NULL,
-				   NULL);
-	
-	/* Check if this is the Master Adapter, in which case we need to allocate the bitmap */
-	if (IsMaster) {
-		/* Size due to the Bitmap + Bytes in the Bitmap Buffer (8 bytes, 64 bits)*/
-		BitmapSize = sizeof(RTL_BITMAP) + AllowedMapRegisters / 8;
-		
-		/* We will put the Bitmap Buffer after the Adapter Object for simplicity */
-		ObjectSize = sizeof(ADAPTER_OBJECT) + BitmapSize;
-	} else {
-		ObjectSize = sizeof(ADAPTER_OBJECT);
-	}
-	
-	/* Create and Allocate the Object */
-	DPRINT("Creating the Object\n");
-	Status = ObCreateObject(KernelMode,
-				IoAdapterObjectType,
-				&ObjectAttributes,
-				KernelMode,
-				NULL,
-				ObjectSize,
-				0,
-				0,
-				(PVOID)&AdapterObject);
-	
-	if (!NT_SUCCESS(Status)) return NULL;
-	
-	/* Add a Reference */
-	DPRINT("Referencing the Object\n");
-	Status = ObReferenceObjectByPointer(AdapterObject,
-					    FILE_READ_DATA | FILE_WRITE_DATA,
-					    IoAdapterObjectType,
-					    KernelMode);
-	
-	if (!NT_SUCCESS(Status)) return NULL;
-	
-	/* It's a Valid Object, so now we can play with the memory */
-	RtlZeroMemory(AdapterObject, sizeof(ADAPTER_OBJECT));
-	
-	/* Insert it into the Object Table */
-	DPRINT("Inserting the Object\n");
-	Status = ObInsertObject(AdapterObject,
-				NULL,
-				FILE_READ_DATA | FILE_WRITE_DATA,
-				0,
-				NULL,
-				&Handle);
-	
-	if (!NT_SUCCESS(Status)) return NULL;
-	
-	/* We don't want the handle */
-	NtClose(Handle);	
-	
-	/* Set up the Adapter Object fields */
-	AdapterObject->MapRegistersPerChannel = 1;
-	
-	/* Set the Master if needed (master only needed if we use Map Registers) */
-	if (NumberOfMapRegisters) AdapterObject->MasterAdapter = MasterAdapter;
-	
-	/* Initalize the Channel Wait queue, which every adapter has */
-	DPRINT("Initializing the Device Queue of the Object\n");
-	KeInitializeDeviceQueue(&AdapterObject->ChannelWaitQueue);
-	
-	/* Initialize the SpinLock, Queue and Bitmap, which are kept in the Master Adapter only */
-	if (IsMaster) {
-		
-		DPRINT("Initializing the Master Adapter Stuff\n");
-		KeInitializeSpinLock(&AdapterObject->SpinLock);
-		InitializeListHead(&AdapterObject->AdapterQueue);
-		
-		/* As said previously, we put them here for simplicity */
-		AdapterObject->MapRegisters = (PVOID)(AdapterObject + 1);
-		
-		/* Set up Bitmap */
-		RtlInitializeBitMap(AdapterObject->MapRegisters,
-				    (PULONG)(AdapterObject->MapRegisters + 1),
-				    AllowedMapRegisters);
-				    
-		/* Reset the Bitmap */	
-		RtlSetAllBits(AdapterObject->MapRegisters);
-		AdapterObject->NumberOfMapRegisters = 0;
-		AdapterObject->CommittedMapRegisters = 0;
-		
-		/* Allocate Memory for the Map Registers */
-		AdapterObject->MapRegisterBase = ExAllocatePool(NonPagedPool,
-								AllowedMapRegisters * sizeof(DWORD));
-		
-		/* Clear them */
-		RtlZeroMemory(AdapterObject->MapRegisterBase, AllowedMapRegisters * sizeof(DWORD));
-		
-		/* Allocate the contigous memory */
-		DPRINT("Allocating Buffers\n");
-		HalpGrowMapBuffers(AdapterObject, 0x1000000);
-	}
-	
-	DPRINT("Adapter Object allocated\n");
-	return AdapterObject;	
-}
-
-
-BOOLEAN STDCALL
-IoFlushAdapterBuffers (
-  PADAPTER_OBJECT	AdapterObject,
-  PMDL		Mdl,
-  PVOID		MapRegisterBase,
-  PVOID		CurrentVa,
-  ULONG		Length,
-  BOOLEAN		WriteToDevice)
-/*
- * FUNCTION: flush any data remaining in the dma controller's memory into the host memory
- * ARGUMENTS:
- *     AdapterObject: the adapter object to flush
- *     Mdl: original MDL to flush data into
- *     MapRegisterBase: map register base that was just used by IoMapTransfer, etc
- *     CurrentVa: offset into Mdl to be flushed into, same as was passed to IoMapTransfer
- *     Length: length of the buffer to be flushed into
- *     WriteToDevice: True if it's a write, False if it's a read
- * RETURNS:
- *     TRUE in all cases
- * NOTES:
- *     - This copies data from the map register-backed buffer to the user's target buffer.
- *       Data is not in the user buffer until this is called.
- *     - This is only meaningful on a read operation.  Return immediately for a write.
- */
-{
-  ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
-  
-  /* this can happen if the card supports scatter/gather */
-  if(!MapRegisterBase)
-    return TRUE;
-
-  /* mask out (disable) the dma channel */
-  if (AdapterObject->AdapterNumber == 1) {
-  
-  		/* Set this for Ease */
-  		PDMA1_CONTROL DmaControl1 = AdapterObject->AdapterBaseVa;
-	
-		/* Set Channel */
-		WRITE_PORT_UCHAR(&DmaControl1->SingleMask, AdapterObject->ChannelNumber | DMA_SETMASK);
-  } else {
-  		/* Set this for Ease */
-  		PDMA2_CONTROL DmaControl2 = AdapterObject->AdapterBaseVa;
-	
-		/* Set Channel */
-		WRITE_PORT_UCHAR(&DmaControl2->SingleMask, (AdapterObject->ChannelNumber - 4) | DMA_SETMASK);
-  }
-  
-  if(WriteToDevice)
-    return TRUE;
-    
-  memcpy( 
-        (PVOID)((DWORD)MmGetSystemAddressForMdl( Mdl ) + (DWORD)CurrentVa - (DWORD)MmGetMdlVirtualAddress( Mdl )), 
-      MapRegisterBase, Length );
-
-  return TRUE;
-}
-
-
-VOID STDCALL
-IoFreeAdapterChannel (PADAPTER_OBJECT	AdapterObject)
-/*
- * FUNCTION: frees DMA resources allocated by IoAllocateAdapterChannel
- * ARGUMENTS:
- *     AdapterObject: Adapter object with resources to free
- * NOTES:
- *     - This function releases the DMA adapter and optionally the map registers
- *     - After releasing the adapter, it checks the adapter's queue and runs
- *       each queued device object in series until the queue is empty
- *     - This is the only way the device queue is emptied.
- */
-{
-  LARGE_INTEGER MaxAddress;
-  LARGE_INTEGER MinAddress;
-  LARGE_INTEGER BoundryAddressMultiple;
-  PWAIT_CONTEXT_BLOCK WaitContextBlock;
-  IO_ALLOCATION_ACTION Retval;
-
-  while(1)
-    {
-      /* To keep map registers, call here with the following set to 0 */
-      if(AdapterObject->CommittedMapRegisters)
-        IoFreeMapRegisters(AdapterObject, AdapterObject->MapRegisterBase, AdapterObject->CommittedMapRegisters);
-
-      if(!(WaitContextBlock = (PWAIT_CONTEXT_BLOCK)KeRemoveDeviceQueue(&AdapterObject->ChannelWaitQueue)))
-        break;
-
-      /*
-       * the following should really be done elsewhere since this
-       * function really can't return an error code.  FIXME.
-       */
-
-      /* 24-bit max address due to 16-bit dma controllers */
-      MinAddress.QuadPart = 0x0000000;
-      MaxAddress.QuadPart = 0x1000000;
-      BoundryAddressMultiple.QuadPart = 0;
-
-      AdapterObject->MapRegisterBase = MmAllocateContiguousAlignedMemory( 
-          WaitContextBlock->NumberOfMapRegisters * PAGE_SIZE,
-          MinAddress,
-          MaxAddress,
-          BoundryAddressMultiple,
-          MmCached,
-          0x10000 );
-
-      if(!AdapterObject->MapRegisterBase)
-        return;
-
-      /* call the adapter control routine */
-      Retval = ((PDRIVER_CONTROL)WaitContextBlock->DeviceRoutine)(WaitContextBlock->DeviceObject, WaitContextBlock->CurrentIrp,
-          AdapterObject->MapRegisterBase, WaitContextBlock->DeviceContext);
-
-      if(Retval == KeepObject)
-        {
-          /* we're done until the caller manually calls IoFreeAdapterChannel */
-          break;
-        }
-      else if(Retval == DeallocateObjectKeepRegisters)
-        {
-          /* hide the map registers so they aren't deallocated next time around */
-          AdapterObject->CommittedMapRegisters = 0;
-        }
-    }
-}
-
-
-VOID STDCALL
-IoFreeMapRegisters (
-  IN PADAPTER_OBJECT	AdapterObject,
-  IN PVOID		MapRegisterBase,
-  IN ULONG		NumberOfMapRegisters)
-/*
- * FUNCTION: free map registers reserved by the system for a DMA
- * ARGUMENTS:
- *     AdapterObject: dma adapter to free map registers on
- *     MapRegisterBase: hadle to map registers to free
- *     NumberOfRegisters: number of map registers to be freed
- * NOTES:
- *     - XXX real windows has a funky interdependence between IoFreeMapRegisters 
- *       and IoFreeAdapterChannel 
- * BUGS:
- *     - needs to be improved to use a real map register implementation
- */
-{
-  if( AdapterObject->CommittedMapRegisters )
-    {
-      MmFreeContiguousMemory(AdapterObject->MapRegisterBase);
-      AdapterObject->MapRegisterBase = 0;
-    }
-}
-
-
-PHYSICAL_ADDRESS  STDCALL
-IoMapTransfer (
-  IN PADAPTER_OBJECT	AdapterObject,
-  IN PMDL		Mdl,
-  IN PVOID		MapRegisterBase,
-  IN PVOID		CurrentVa,
-  IN OUT PULONG		Length,
-  IN BOOLEAN		WriteToDevice)
-/*
- * FUNCTION: map a dma for transfer and do the dma if it's a slave
- * ARGUMENTS:
- *     AdapterObject: adapter object to do the dma on. busmaster may pass NULL.
- *     Mdl: locked-down user buffer to DMA in to or out of
- *     MapRegisterBase: handle to map registers to use for this dma. allways NULL
- *      when doing s/g.
- *     CurrentVa: index into Mdl to transfer into/out of
- *     Length: length of transfer in/out. Only modified on out when doing s/g.
- *     WriteToDevice: TRUE if it's an output dma, FALSE otherwise
- * RETURNS: 
- *     If a busmaster: A logical address that can be used to program a dma controller
- *     Otherwise: nothing meaningful
- * NOTES:
- *     - This function does a copyover to contiguous memory <16MB
- *     - If it's a slave transfer, this function actually performs it.
- * BUGS:
- *     - If the controller supports scatter/gather, the copyover should not happen
- */
-{
-  PHYSICAL_ADDRESS Address;
-  KIRQL OldIrql;
-  UCHAR Mode;
-
-#if defined(__GNUC__)
-  Address.QuadPart = 0ULL;
-#else
-  Address.QuadPart = 0;
-#endif
-
-  /* Isa System (slave) DMA? */
-  if (MapRegisterBase && !AdapterObject->MasterDevice)
-  {
-
-    KeAcquireSpinLock(&AdapterObject->SpinLock, &OldIrql);
-
-    /*
-     * FIXME: Handle case when doing common-buffer System DMA. In this case,
-     * the buffer described by MDL is already phys. contiguous and below
-     * 16 mega. Driver makes a one-shot call to IoMapTransfer during init.
-     * to program controller with the common-buffer.
-     *
-     * UPDATE: Common buffer support is in place, but it's not done in a
-     * clean way. We use the buffer passed by the MDL in case that the
-     * adapter object is marked as auto initialize. I'm not sure if this
-     * is correct and if not, how to do it properly. Note that it's also
-     * possible to allocate the common buffer with different adapter object
-     * and IoMapTransfer must still work in this case. Eventually this should
-     * be cleaned up somehow or at least this comment modified to reflect
-     * the reality.
-     * -- Filip Navara, 19/07/2004     
-     */
-
-     /* Get the mode for easier coding */
-     Mode = AdapterObject->AdapterMode;
-     
-    /* if it is a write to the device, copy the caller buffer to the low buffer */
-    if ((WriteToDevice) && !((PDMA_MODE)&Mode)->AutoInitialize)
-    {
-      memcpy(MapRegisterBase,
-             (char*)MmGetSystemAddressForMdl(Mdl) + ((ULONG)CurrentVa - (ULONG)MmGetMdlVirtualAddress(Mdl)),
-	           *Length );
-    }
-
-    /* Writer Adapter Mode, transfer type */
-    ((PDMA_MODE)&Mode)->TransferType = (WriteToDevice ? WRITE_TRANSFER : READ_TRANSFER);
-
-    // program up the dma controller, and return
-    if (!((PDMA_MODE)&Mode)->AutoInitialize) {
-      Address = MmGetPhysicalAddress( MapRegisterBase );
-    } else {
-      Address = MmGetPhysicalAddress( CurrentVa );
-    }
-    
-    /* 16-bit DMA has a shifted length */
-    if (AdapterObject->Width16Bits) *Length = (*Length >> 1);
-     
-    /* Make the Transfer */
-    if (AdapterObject->AdapterNumber == 1) {
-    
-    	PDMA1_CONTROL DmaControl1 = AdapterObject->AdapterBaseVa; /* For Writing Less Code */
-    	
-	/* Reset Register */
-	WRITE_PORT_UCHAR(&DmaControl1->ClearBytePointer, 0);
-	
-	/* Set the Mode */
-	WRITE_PORT_UCHAR(&DmaControl1->Mode, (UCHAR)(Mode));
-	
-	/* Set the Page Register (apparently always 0 for us if I trust the previous comment) */
-	WRITE_PORT_UCHAR(&DmaControl1->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseAddress, 0);
-	WRITE_PORT_UCHAR(&DmaControl1->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseAddress, 0);
-	
-	/* Set the Length */
- 	WRITE_PORT_UCHAR(&DmaControl1->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseCount,
-			(UCHAR)((*Length) - 1));
-	WRITE_PORT_UCHAR(&DmaControl1->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseCount,
-			(UCHAR)((*Length) - 1) >> 8);
-			
-	/* Unmask the Channel */
-	WRITE_PORT_UCHAR(&DmaControl1->SingleMask, AdapterObject->ChannelNumber | DMA_CLEARMASK);
-    } else {
-        PDMA2_CONTROL DmaControl2 = AdapterObject->AdapterBaseVa; /* For Writing Less Code */
-    	
-	/* Reset Register */
-	WRITE_PORT_UCHAR(&DmaControl2->ClearBytePointer, 0);
-	
-	/* Set the Mode */
-	WRITE_PORT_UCHAR(&DmaControl2->Mode, (UCHAR)(Mode));
-	
-	/* Set the Page Register (apparently always 0 for us if I trust the previous comment) */
-	WRITE_PORT_UCHAR(&DmaControl2->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseAddress, 0);
-	WRITE_PORT_UCHAR(&DmaControl2->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseAddress, 0);
-	
-	/* Set the Length */
- 	WRITE_PORT_UCHAR(&DmaControl2->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseCount,
-			(UCHAR)((*Length) - 1));
-	WRITE_PORT_UCHAR(&DmaControl2->DmaAddressCount[AdapterObject->ChannelNumber].DmaBaseCount,
-			(UCHAR)((*Length) - 1) >> 8);
-			
-	/* Unmask the Channel */
-	WRITE_PORT_UCHAR(&DmaControl2->SingleMask, AdapterObject->ChannelNumber | DMA_CLEARMASK);
-    }
-	
-    /* Release Spinlock */
-    KeReleaseSpinLock(&AdapterObject->SpinLock, OldIrql);
-
-    /* 
-    NOTE: Return value should be ignored when doing System DMA.
-    Maybe return some more obvious invalid address here (thou returning 
-    MapRegisterBase is also wrong;-)to catch invalid use?
-    */
-    Address.QuadPart = (ULONG)MapRegisterBase;
-    return Address;
-  }
-  
-
-  /* 
-  Busmaster with s/g support?   
-  NOTE: old docs allowed busmasters to pass a NULL Adapter. In this case, MapRegisterBase 
-  being NULL is used to detect a s/g busmaster.
-  */
-  if ((!AdapterObject && !MapRegisterBase) ||
-      (AdapterObject && AdapterObject->MasterDevice && AdapterObject->ScatterGather))
-  {
-    /* 
-    Just return the passed VA's corresponding phys. address. 
-    Update length to the number of phys. contiguous bytes found.
-    */
-  
-    PULONG MdlPages;
-    ULONG MdlPageIndex, PhysContiguousLen;
-    ULONG PhysAddress;
-    
-    MdlPages = (PULONG)(Mdl + 1);
-    
-    /* Get VA's corresponding mdl phys. page index */
-    MdlPageIndex = ((ULONG)CurrentVa - (ULONG)Mdl->StartVa) / PAGE_SIZE;
-   
-    /* Get phys. page containing the VA */
-    PhysAddress = MdlPages[MdlPageIndex];
-    
-    PhysContiguousLen = PAGE_SIZE - BYTE_OFFSET(CurrentVa);
-    
-    /* VA to map may span several contiguous phys. pages (unlikely) */
-    while (PhysContiguousLen < *Length &&
-           MdlPages[MdlPageIndex++] + PAGE_SIZE == MdlPages[MdlPageIndex])
-    {
-      /* 
-      Note that allways adding PAGE_SIZE may make PhysContiguousLen greater
-      than Length if buffer doesn't end on page boundary. Take this
-      into consideration below. 
-      */
-      PhysContiguousLen += PAGE_SIZE; 
-    }
-    
-    if (PhysContiguousLen < *Length)
-    {
-      *Length = PhysContiguousLen;
-    }
-    
-    //add offset to phys. page address
-    Address.QuadPart = PhysAddress + BYTE_OFFSET(CurrentVa);
-    return Address;
-  }
-  
-  
-  /* 
-  Busmaster without s/g support? 
-  NOTE: old docs allowed busmasters to pass a NULL Adapter. In this case, MapRegisterBase 
-  not being NULL is used to detect a non s/g busmaster.
-  */
-  if ((!AdapterObject && MapRegisterBase) ||
-      (AdapterObject && AdapterObject->MasterDevice && !AdapterObject->ScatterGather))
-  {
-    /*
-    NOTE: Busmasters doing common-buffer DMA shouldn't call IoMapTransfer, but I don't
-    know if it's illegal... Maybe figure out what to do in this case...
-    */
-
-    if( WriteToDevice )
-    {
-      memcpy(MapRegisterBase,
-             (char*)MmGetSystemAddressForMdl(Mdl) + ((ULONG)CurrentVa - (ULONG)MmGetMdlVirtualAddress(Mdl)),
-             *Length );
-    }
-
-    return MmGetPhysicalAddress(MapRegisterBase);
-  }
-
-  DPRINT("IoMapTransfer: Unsupported operation\n");
-  KEBUGCHECK(0);
-  return Address;
-}
-
-
-/* EOF */
-
-
-
-

reactos/hal/halx86
beep.c removed after 1.5
diff -N beep.c
--- beep.c	20 Jul 2004 21:25:36 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/beep.c
- * PURPOSE:         Speaker function (it's only one)
- * PROGRAMMER:      Eric Kohl (ekohl@abo.rhein-zeitung.de)
- * UPDATE HISTORY:
- *                  Created 31/01/99
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <hal.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* CONSTANTS *****************************************************************/
-
-#define TIMER2     0x42
-#define TIMER3     0x43
-#define PORT_B     0x61
-#define CLOCKFREQ  1193167
-
-
-/* FUNCTIONS *****************************************************************/
-/*
- * FUNCTION: Beeps the speaker.
- * ARGUMENTS:
- *       Frequency = If 0, the speaker will be switched off, otherwise
- *                   the speaker beeps with the specified frequency.
- */
-
-BOOLEAN
-STDCALL
-HalMakeBeep (
-	ULONG	Frequency
-	)
-{
-    UCHAR b;
-    ULONG flags;
-   
-    /* save flags and disable interrupts */
-    Ki386SaveFlags(flags);
-    Ki386DisableInterrupts();
-
-    /* speaker off */
-    b = READ_PORT_UCHAR((PUCHAR)PORT_B);
-    WRITE_PORT_UCHAR((PUCHAR)PORT_B, (UCHAR)(b & 0xFC));
-
-    if (Frequency)
-    {
-        DWORD Divider = CLOCKFREQ / Frequency;
-
-        if (Divider > 0x10000)
-        {
-            /* restore flags */
-            Ki386RestoreFlags(flags);
-
-            return FALSE;
-        }
-
-        /* set timer divider */
-        WRITE_PORT_UCHAR((PUCHAR)TIMER3, 0xB6);
-        WRITE_PORT_UCHAR((PUCHAR)TIMER2, (UCHAR)(Divider & 0xFF));
-        WRITE_PORT_UCHAR((PUCHAR)TIMER2, (UCHAR)((Divider>>8) & 0xFF));
-
-        /* speaker on */
-        WRITE_PORT_UCHAR((PUCHAR)PORT_B, (UCHAR)(READ_PORT_UCHAR((PUCHAR)PORT_B) | 0x03));
-    }
-
-    /* restore flags */
-    Ki386RestoreFlags(flags);
-
-    return TRUE;
-}
-

reactos/hal/halx86
bus.c removed after 1.7
diff -N bus.c
--- bus.c	28 Dec 2003 22:38:09 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,532 +0,0 @@
-/* $Id: bus.c,v 1.7 2003/12/28 22:38:09 fireball Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/bus.c
- * PURPOSE:         Bus functions
- * PROGRAMMER:      David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- *                  Created 22/05/98
- *
- *
- * TODO:
- *   - Add bus handler functions for all busses
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <hal.h>
-#include <bus.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS *******************************************************************/
-
-#define TAG_BUS  TAG('B', 'U', 'S', 'H')
-
-KSPIN_LOCK HalpBusHandlerSpinLock = {0,};
-LIST_ENTRY HalpBusHandlerList;
-
-
-/* FUNCTIONS *****************************************************************/
-
-static NTSTATUS STDCALL
-HalpNoAdjustResourceList(PBUS_HANDLER BusHandler,
-			 ULONG BusNumber,
-			 PCM_RESOURCE_LIST Resources)
-{
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS STDCALL
-HalpNoAssignSlotResources(PBUS_HANDLER BusHandler,
-			  ULONG BusNumber,
-			  PUNICODE_STRING RegistryPath,
-			  PUNICODE_STRING DriverClassName,
-			  PDRIVER_OBJECT DriverObject,
-			  PDEVICE_OBJECT DeviceObject,
-			  ULONG SlotNumber,
-			  PCM_RESOURCE_LIST *AllocatedResources)
-{
-   return STATUS_NOT_SUPPORTED;
-}
-
-
-static ULONG STDCALL
-HalpNoBusData(PBUS_HANDLER BusHandler,
-	      ULONG BusNumber,
-	      ULONG SlotNumber,
-	      PVOID Buffer,
-	      ULONG Offset,
-	      ULONG Length)
-{
-   return 0;
-}
-
-
-static ULONG STDCALL
-HalpNoGetInterruptVector(PBUS_HANDLER BusHandler,
-			 ULONG BusNumber,
-			 ULONG BusInterruptLevel,
-			 ULONG BusInterruptVector,
-			 PKIRQL Irql,
-			 PKAFFINITY Affinity)
-{
-   return 0;
-}
-
-
-static ULONG STDCALL
-HalpNoTranslateBusAddress(PBUS_HANDLER BusHandler,
-			  ULONG BusNumber,
-			  PHYSICAL_ADDRESS BusAddress,
-			  PULONG AddressSpace,
-			  PPHYSICAL_ADDRESS TranslatedAddress)
-{
-   return 0;
-}
-
-
-PBUS_HANDLER
-HalpAllocateBusHandler(INTERFACE_TYPE InterfaceType,
-		       BUS_DATA_TYPE BusDataType,
-		       ULONG BusNumber)
-{
-   PBUS_HANDLER BusHandler = NULL;
-
-   DPRINT("HalpAllocateBusHandler()\n");
-
-   BusHandler = ExAllocatePoolWithTag(NonPagedPool,
-				      sizeof(BUS_HANDLER),
-				      TAG_BUS);
-   if (BusHandler == NULL)
-     return NULL;
-
-   RtlZeroMemory(BusHandler,
-		 sizeof(BUS_HANDLER));
-
-   InsertTailList(&HalpBusHandlerList,
-		  &BusHandler->Entry);
-
-   BusHandler->InterfaceType = InterfaceType;
-   BusHandler->BusDataType = BusDataType;
-   BusHandler->BusNumber = BusNumber;
-
-   /* initialize default bus handler functions */
-   BusHandler->GetBusData = HalpNoBusData;
-   BusHandler->SetBusData = HalpNoBusData;
-   BusHandler->AdjustResourceList = HalpNoAdjustResourceList;
-   BusHandler->AssignSlotResources = HalpNoAssignSlotResources;
-   BusHandler->GetInterruptVector = HalpNoGetInterruptVector;
-   BusHandler->TranslateBusAddress = HalpNoTranslateBusAddress;
-
-   /* any more ?? */
-
-   DPRINT("HalpAllocateBusHandler() done\n");
-
-   return BusHandler;
-}
-
-
-VOID
-HalpInitBusHandlers(VOID)
-{
-  PBUS_HANDLER BusHandler;
-
-  /* General preparations */
-  KeInitializeSpinLock(&HalpBusHandlerSpinLock);
-  InitializeListHead(&HalpBusHandlerList);
-
-  /* Initialize hal dispatch tables */
-  HalQuerySystemInformation = HalpQuerySystemInformation;
-
-#if 0
-  HalSetSystemInformation = HalpSetSystemInformation;
-
-  HalQueryBusSlots = HalpQueryBusSlots;
-#endif
-
-  /* Add system bus handler */
-  BusHandler = HalpAllocateBusHandler(Internal,
-				      ConfigurationSpaceUndefined,
-				      0);
-  if (BusHandler == NULL)
-    return;
-  BusHandler->GetInterruptVector =
-    (pGetInterruptVector)HalpGetSystemInterruptVector;
-  BusHandler->TranslateBusAddress =
-    (pTranslateBusAddress)HalpTranslateSystemBusAddress;
-
-  /* Add cmos bus handler */
-  BusHandler = HalpAllocateBusHandler(InterfaceTypeUndefined,
-				      Cmos,
-				      0);
-  if (BusHandler == NULL)
-    return;
-  BusHandler->GetBusData = (pGetSetBusData)HalpGetCmosData;
-  BusHandler->SetBusData = (pGetSetBusData)HalpSetCmosData;
-
-  /* Add isa bus handler */
-  BusHandler = HalpAllocateBusHandler(Isa,
-				      ConfigurationSpaceUndefined,
-				      0);
-  if (BusHandler == NULL)
-    return;
-
-  BusHandler->GetInterruptVector =
-    (pGetInterruptVector)HalpGetIsaInterruptVector;
-  BusHandler->TranslateBusAddress =
-    (pTranslateBusAddress)HalpTranslateIsaBusAddress;
-
-  /* Add MicroChannel bus handler */
-  BusHandler = HalpAllocateBusHandler(MicroChannel,
-				      Pos,
-				      0);
-  if (BusHandler == NULL)
-    return;
-
-  BusHandler->GetBusData = (pGetSetBusData)HalpGetMicroChannelData;
-}
-
-
-PBUS_HANDLER FASTCALL
-HaliHandlerForBus(INTERFACE_TYPE InterfaceType,
-		  ULONG BusNumber)
-{
-   PBUS_HANDLER BusHandler;
-   PLIST_ENTRY CurrentEntry;
-   KIRQL OldIrql;
-
-   KeAcquireSpinLock(&HalpBusHandlerSpinLock,
-		     &OldIrql);
-
-   CurrentEntry = HalpBusHandlerList.Flink;
-   while (CurrentEntry != &HalpBusHandlerList)
-     {
-	BusHandler = (PBUS_HANDLER)CurrentEntry;
-	if (BusHandler->InterfaceType == InterfaceType &&
-	    BusHandler->BusNumber == BusNumber)
-	  {
-	     KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-			       OldIrql);
-	     return BusHandler;
-	  }
-	CurrentEntry = CurrentEntry->Flink;
-     }
-   KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-		     OldIrql);
-
-   return NULL;
-}
-
-
-PBUS_HANDLER FASTCALL
-HaliHandlerForConfigSpace(BUS_DATA_TYPE BusDataType,
-			  ULONG BusNumber)
-{
-   PBUS_HANDLER BusHandler;
-   PLIST_ENTRY CurrentEntry;
-   KIRQL OldIrql;
-
-   KeAcquireSpinLock(&HalpBusHandlerSpinLock,
-		     &OldIrql);
-
-   CurrentEntry = HalpBusHandlerList.Flink;
-   while (CurrentEntry != &HalpBusHandlerList)
-     {
-	BusHandler = (PBUS_HANDLER)CurrentEntry;
-	if (BusHandler->BusDataType == BusDataType &&
-	    BusHandler->BusNumber == BusNumber)
-	  {
-	     KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-			       OldIrql);
-	     return BusHandler;
-	  }
-	CurrentEntry = CurrentEntry->Flink;
-     }
-   KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-		     OldIrql);
-
-   return NULL;
-}
-
-
-PBUS_HANDLER FASTCALL
-HaliReferenceHandlerForBus(INTERFACE_TYPE InterfaceType,
-			   ULONG BusNumber)
-{
-   PBUS_HANDLER BusHandler;
-   PLIST_ENTRY CurrentEntry;
-   KIRQL OldIrql;
-
-   KeAcquireSpinLock(&HalpBusHandlerSpinLock,
-		     &OldIrql);
-
-   CurrentEntry = HalpBusHandlerList.Flink;
-   while (CurrentEntry != &HalpBusHandlerList)
-     {
-	BusHandler = (PBUS_HANDLER)CurrentEntry;
-	if (BusHandler->InterfaceType == InterfaceType &&
-	    BusHandler->BusNumber == BusNumber)
-	  {
-	     BusHandler->RefCount++;
-	     KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-			       OldIrql);
-	     return BusHandler;
-	  }
-	CurrentEntry = CurrentEntry->Flink;
-     }
-   KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-		     OldIrql);
-
-   return NULL;
-}
-
-
-PBUS_HANDLER FASTCALL
-HaliReferenceHandlerForConfigSpace(BUS_DATA_TYPE BusDataType,
-				   ULONG BusNumber)
-{
-   PBUS_HANDLER BusHandler;
-   PLIST_ENTRY CurrentEntry;
-   KIRQL OldIrql;
-
-   KeAcquireSpinLock(&HalpBusHandlerSpinLock,
-		     &OldIrql);
-
-   CurrentEntry = HalpBusHandlerList.Flink;
-   while (CurrentEntry != &HalpBusHandlerList)
-     {
-	BusHandler = (PBUS_HANDLER)CurrentEntry;
-	if (BusHandler->BusDataType == BusDataType &&
-	    BusHandler->BusNumber == BusNumber)
-	  {
-	     BusHandler->RefCount++;
-	     KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-			       OldIrql);
-	     return BusHandler;
-	  }
-	CurrentEntry = CurrentEntry->Flink;
-     }
-   KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-		     OldIrql);
-
-   return NULL;
-}
-
-
-VOID FASTCALL
-HaliDereferenceBusHandler(PBUS_HANDLER BusHandler)
-{
-   KIRQL OldIrql;
-
-   KeAcquireSpinLock(&HalpBusHandlerSpinLock,
-		     &OldIrql);
-   BusHandler->RefCount--;
-   KeReleaseSpinLock(&HalpBusHandlerSpinLock,
-		     OldIrql);
-}
-
-
-NTSTATUS STDCALL
-HalAdjustResourceList(PCM_RESOURCE_LIST Resources)
-{
-   PBUS_HANDLER BusHandler;
-   NTSTATUS Status;
-
-   BusHandler = HaliReferenceHandlerForBus(Resources->List[0].InterfaceType,
-					   Resources->List[0].BusNumber);
-   if (BusHandler == NULL)
-     return STATUS_SUCCESS;
-
-   Status = BusHandler->AdjustResourceList(BusHandler,
-					   Resources->List[0].BusNumber,
-					   Resources);
-   HaliDereferenceBusHandler (BusHandler);
-
-   return Status;
-}
-
-
-NTSTATUS STDCALL
-HalAssignSlotResources(PUNICODE_STRING RegistryPath,
-		       PUNICODE_STRING DriverClassName,
-		       PDRIVER_OBJECT DriverObject,
-		       PDEVICE_OBJECT DeviceObject,
-		       INTERFACE_TYPE BusType,
-		       ULONG BusNumber,
-		       ULONG SlotNumber,
-		       PCM_RESOURCE_LIST *AllocatedResources)
-{
-   PBUS_HANDLER BusHandler;
-   NTSTATUS Status;
-
-   BusHandler = HaliReferenceHandlerForBus(BusType,
-					   BusNumber);
-   if (BusHandler == NULL)
-     return STATUS_NOT_FOUND;
-
-   Status = BusHandler->AssignSlotResources(BusHandler,
-					    BusNumber,
-					    RegistryPath,
-					    DriverClassName,
-					    DriverObject,
-					    DeviceObject,
-					    SlotNumber,
-					    AllocatedResources);
-
-   HaliDereferenceBusHandler(BusHandler);
-
-   return Status;
-}
-
-
-ULONG STDCALL
-HalGetBusData(BUS_DATA_TYPE BusDataType,
-	      ULONG BusNumber,
-	      ULONG SlotNumber,
-	      PVOID Buffer,
-	      ULONG Length)
-{
-   return (HalGetBusDataByOffset(BusDataType,
-				 BusNumber,
-				 SlotNumber,
-				 Buffer,
-				 0,
-				 Length));
-}
-
-
-ULONG STDCALL
-HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType,
-		      ULONG BusNumber,
-		      ULONG SlotNumber,
-		      PVOID Buffer,
-		      ULONG Offset,
-		      ULONG Length)
-{
-   PBUS_HANDLER BusHandler;
-   ULONG Result;
-
-   BusHandler = HaliReferenceHandlerForConfigSpace(BusDataType,
-						   BusNumber);
-   if (BusHandler == NULL)
-     return 0;
-
-   Result = BusHandler->GetBusData(BusHandler,
-				   BusNumber,
-				   SlotNumber,
-				   Buffer,
-				   Offset,
-				   Length);
-
-   HaliDereferenceBusHandler (BusHandler);
-
-   return Result;
-}
-
-
-ULONG STDCALL
-HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
-		      ULONG BusNumber,
-		      ULONG BusInterruptLevel,
-		      ULONG BusInterruptVector,
-		      PKIRQL Irql,
-		      PKAFFINITY Affinity)
-{
-   PBUS_HANDLER BusHandler;
-   ULONG Result;
-
-   BusHandler = HaliReferenceHandlerForBus(InterfaceType,
-					   BusNumber);
-   if (BusHandler == NULL)
-     return 0;
-
-   Result = BusHandler->GetInterruptVector(BusHandler,
-					   BusNumber,
-					   BusInterruptLevel,
-					   BusInterruptVector,
-					   Irql,
-					   Affinity);
-
-   HaliDereferenceBusHandler(BusHandler);
-
-   return Result;
-}
-
-
-ULONG STDCALL
-HalSetBusData(BUS_DATA_TYPE BusDataType,
-	      ULONG BusNumber,
-	      ULONG SlotNumber,
-	      PVOID Buffer,
-	      ULONG Length)
-{
-   return (HalSetBusDataByOffset(BusDataType,
-				 BusNumber,
-				 SlotNumber,
-				 Buffer,
-				 0,
-				 Length));
-}
-
-
-ULONG STDCALL
-HalSetBusDataByOffset(BUS_DATA_TYPE BusDataType,
-		      ULONG BusNumber,
-		      ULONG SlotNumber,
-		      PVOID Buffer,
-		      ULONG Offset,
-		      ULONG Length)
-{
-   PBUS_HANDLER BusHandler;
-   ULONG Result;
-
-   BusHandler = HaliReferenceHandlerForConfigSpace(BusDataType,
-						   BusNumber);
-   if (BusHandler == NULL)
-     return 0;
-
-   Result = BusHandler->SetBusData(BusHandler,
-				   BusNumber,
-				   SlotNumber,
-				   Buffer,
-				   Offset,
-				   Length);
-
-   HaliDereferenceBusHandler(BusHandler);
-
-   return Result;
-}
-
-
-BOOLEAN STDCALL
-HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
-		       ULONG BusNumber,
-		       PHYSICAL_ADDRESS BusAddress,
-		       PULONG AddressSpace,
-		       PPHYSICAL_ADDRESS TranslatedAddress)
-{
-   PBUS_HANDLER BusHandler;
-   BOOLEAN Result;
-
-   BusHandler = HaliReferenceHandlerForBus(InterfaceType,
-					   BusNumber);
-   if (BusHandler == NULL)
-     return FALSE;
-
-   Result = (BOOLEAN)BusHandler->TranslateBusAddress(BusHandler,
-					    BusNumber,
-					    BusAddress,
-					    AddressSpace,
-					    TranslatedAddress);
-
-   HaliDereferenceBusHandler(BusHandler);
-
-   return Result;
-}
-
-/* EOF */

reactos/hal/halx86
display.c removed after 1.18
diff -N display.c
--- display.c	31 Oct 2004 19:45:16 -0000	1.18
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,790 +0,0 @@
-/*
- *  ReactOS kernel
- *  Copyright (C) 1998, 1999, 2000, 2001, 2002 ReactOS Team
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id: display.c,v 1.18 2004/10/31 19:45:16 ekohl Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/display.c
- * PURPOSE:         Blue screen display
- * PROGRAMMER:      Eric Kohl (ekohl@rz-online.de)
- * UPDATE HISTORY:
- *                  Created 08/10/99
- */
-
-/*
- * Portions of this code are from the XFree86 Project and available from the
- * following license:
- *
- * Copyright (C) 1994-2003 The XFree86 Project, Inc.  All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
- * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
- * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the XFree86 Project shall
- * not be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization from the
- * XFree86 Project.
-*/  
-
-/* DISPLAY OWNERSHIP
- *
- * So, who owns the physical display and is allowed to write to it?
- *
- * In MS NT, upon boot HAL owns the display. Somewhere in the boot
- * sequence (haven't figured out exactly where or by who), some
- * component calls HalAcquireDisplayOwnership. From that moment on,
- * the display is owned by that component and is switched to graphics
- * mode. The display is not supposed to return to text mode, except
- * in case of a bug check. The bug check will call HalDisplayString
- * to output a string to the text screen. HAL will notice that it
- * currently doesn't own the display and will re-take ownership, by
- * calling the callback function passed to HalAcquireDisplayOwnership.
- * After the bugcheck, execution is halted. So, under NT, the only
- * possible sequence of display modes is text mode -> graphics mode ->
- * text mode (the latter hopefully happening very infrequently).
- *
- * Things are a little bit different in the current state of ReactOS.
- * We want to have a functional interactive text mode. We should be
- * able to switch from text mode to graphics mode when a GUI app is
- * started and switch back to text mode when it's finished. Then, when
- * another GUI app is started, another switch to and from graphics mode
- * is possible. Also, when the system bugchecks in graphics mode we want
- * to switch back to text mode to show the registers and stack trace.
- * Last but not least, HalDisplayString is used a lot more in ReactOS,
- * e.g. to print debug messages when the /DEBUGPORT=SCREEN boot option
- * is present.
- * 3 Components are involved in Reactos: HAL, BLUE.SYS and VIDEOPRT.SYS.
- * As in NT, on boot HAL owns the display. When entering the text mode
- * command interpreter, BLUE.SYS kicks in. It will write directly to the
- * screen, more or less behind HALs back.
- * When a GUI app is started, WIN32K.SYS will open the DISPLAY device.
- * This open call will end up in VIDEOPRT.SYS. That component will then
- * take ownership of the display by calling HalAcquireDisplayOwnership.
- * When the GUI app terminates (WIN32K.SYS will close the DISPLAY device),
- * we want to give ownership of the display back to HAL. Using the
- * standard exported HAL functions, that's a bit of a problem, because
- * there is no function defined to do that. In NT, this is handled by
- * HalDisplayString, but that solution isn't satisfactory in ReactOS,
- * because HalDisplayString is (in some cases) also used to output debug
- * messages. If we do it the NT way, the first debug message output while
- * in graphics mode would switch the display back to text mode.
- * So, instead, if HalDisplayString detects that HAL doesn't have ownership
- * of the display, it doesn't do anything.
- * To return ownership to HAL, a new function is exported,
- * HalReleaseDisplayOwnership. This function is called by the DISPLAY
- * device Close routine in VIDEOPRT.SYS. It is also called at the beginning
- * of a bug check, so HalDisplayString is activated again.
- * Now, while the display is in graphics mode (not owned by HAL), BLUE.SYS
- * should also refrain from writing to the screen buffer. The text mode
- * screen buffer might overlap the graphics mode screen buffer, so changing
- * something in the text mode buffer might mess up the graphics screen. To
- * allow BLUE.SYS to detect if HAL owns the display, another new function is
- * exported, HalQueryDisplayOwnership. BLUE.SYS will call this function to
- * check if it's allowed to touch the text mode buffer.
- *
- * In an ideal world, when HAL takes ownership of the display, it should set
- * up the CRT using real-mode (actually V86 mode, but who cares) INT 0x10
- * calls. Unfortunately, this will require HAL to setup a real-mode interrupt
- * table etc. So, we chickened out of that by having the loader set up the
- * display before switching to protected mode. If HAL is given back ownership
- * after a GUI app terminates, the INT 0x10 calls are made by VIDEOPRT.SYS,
- * since there is already support for them via the VideoPortInt10 routine.
- */
-
-#include <ddk/ntddk.h>
-#include <hal.h>
-
-#define SCREEN_SYNCHRONIZATION
-
-#define VGA_AC_INDEX            0x3c0
-#define VGA_AC_READ             0x3c1
-#define VGA_AC_WRITE            0x3c0
-
-#define VGA_MISC_WRITE          0x3c2
-
-#define VGA_SEQ_INDEX           0x3c4
-#define VGA_SEQ_DATA            0x3c5
-
-#define VGA_DAC_MASK            0x3c6
-#define VGA_DAC_READ_INDEX      0x3c7
-#define VGA_DAC_WRITE_INDEX     0x3c8
-#define VGA_DAC_DATA            0x3c9
-#define VGA_FEATURE_READ        0x3ca
-#define VGA_MISC_READ           0x3cc
-
-#define VGA_GC_INDEX            0x3ce
-#define VGA_GC_DATA             0x3cf
-
-#define VGA_CRTC_INDEX          0x3d4
-#define VGA_CRTC_DATA           0x3d5
-
-#define VGA_INSTAT_READ         0x3da
-
-#define VGA_SEQ_NUM_REGISTERS   5
-#define VGA_CRTC_NUM_REGISTERS  25
-#define VGA_GC_NUM_REGISTERS    9
-#define VGA_AC_NUM_REGISTERS    21
-
-#define CRTC_COLUMNS       0x01
-#define CRTC_OVERFLOW      0x07
-#define CRTC_ROWS          0x12
-#define CRTC_SCANLINES     0x09
-
-#define CRTC_CURHI         0x0e
-#define CRTC_CURLO         0x0f
-
-
-#define CHAR_ATTRIBUTE_BLACK  0x00  /* black on black */
-#define CHAR_ATTRIBUTE        0x17  /* grey on blue */
-
-#define FONT_AMOUNT        (8*8192)
-
-/* VARIABLES ****************************************************************/
-
-static ULONG CursorX = 0;      /* Cursor Position */
-static ULONG CursorY = 0;
-static ULONG SizeX = 80;       /* Display size */
-static ULONG SizeY = 25;
-
-static BOOLEAN DisplayInitialized = FALSE;
-static BOOLEAN HalOwnsDisplay = TRUE;
-
-static PUSHORT VideoBuffer = NULL;
-static PUCHAR GraphVideoBuffer = NULL;
-
-static PHAL_RESET_DISPLAY_PARAMETERS HalResetDisplayParameters = NULL;
-
-static UCHAR SavedTextPalette[768];
-static UCHAR SavedTextMiscOutReg;
-static UCHAR SavedTextCrtcReg[VGA_CRTC_NUM_REGISTERS];
-static UCHAR SavedTextAcReg[VGA_AC_NUM_REGISTERS];
-static UCHAR SavedTextGcReg[VGA_GC_NUM_REGISTERS];
-static UCHAR SavedTextSeqReg[VGA_SEQ_NUM_REGISTERS];
-static UCHAR SavedTextFont[2][FONT_AMOUNT];
-static BOOLEAN TextPaletteEnabled = FALSE;
-
-/* PRIVATE FUNCTIONS *********************************************************/
-
-VOID FASTCALL
-HalClearDisplay (UCHAR CharAttribute)
-{
-   WORD *ptr = (WORD*)VideoBuffer;
-   ULONG i;
-
-  for (i = 0; i < SizeX * SizeY; i++, ptr++)
-    *ptr = ((CharAttribute << 8) + ' ');
-
-  CursorX = 0;
-  CursorY = 0;
-}
-
-
-/* STATIC FUNCTIONS *********************************************************/
-
-VOID STATIC
-HalScrollDisplay (VOID)
-{
-  PUSHORT ptr;
-  int i;
-
-  ptr = VideoBuffer + SizeX;
-  RtlMoveMemory(VideoBuffer,
-		ptr,
-		SizeX * (SizeY - 1) * 2);
-
-  ptr = VideoBuffer  + (SizeX * (SizeY - 1));
-  for (i = 0; i < (int)SizeX; i++, ptr++)
-    {
-      *ptr = (CHAR_ATTRIBUTE << 8) + ' ';
-    }
-}
-
-VOID STATIC FASTCALL
-HalPutCharacter (CHAR Character)
-{
-  PUSHORT ptr;
-
-  ptr = VideoBuffer + ((CursorY * SizeX) + CursorX);
-  *ptr = (CHAR_ATTRIBUTE << 8) + Character;
-}
-
-VOID STATIC
-HalDisablePalette(VOID)
-{
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_AC_INDEX, 0x20);
-  TextPaletteEnabled = FALSE;
-}
-
-VOID STATIC
-HalEnablePalette(VOID)
-{
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_AC_INDEX, 0x00);
-  TextPaletteEnabled = TRUE;
-}
-
-UCHAR STATIC FASTCALL
-HalReadGc(ULONG Index)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_GC_INDEX, (UCHAR)Index);
-  return(READ_PORT_UCHAR((PUCHAR)VGA_GC_DATA));
-}
-
-VOID STATIC FASTCALL
-HalWriteGc(ULONG Index, UCHAR Value)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_GC_INDEX, (UCHAR)Index);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_GC_DATA, Value);
-}
-
-UCHAR STATIC FASTCALL
-HalReadSeq(ULONG Index)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_SEQ_INDEX, (UCHAR)Index);
-  return(READ_PORT_UCHAR((PUCHAR)VGA_SEQ_DATA));
-}
-
-VOID STATIC FASTCALL
-HalWriteSeq(ULONG Index, UCHAR Value)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_SEQ_INDEX, (UCHAR)Index);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_SEQ_DATA, Value);
-}
-
-VOID STATIC FASTCALL
-HalWriteAc(ULONG Index, UCHAR Value)
-{
-  if (TextPaletteEnabled)
-    {
-      Index &= ~0x20;
-    }
-  else
-    {
-      Index |= 0x20;
-    }
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_AC_INDEX, (UCHAR)Index);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_AC_WRITE, Value);
-}
-
-UCHAR STATIC FASTCALL
-HalReadAc(ULONG Index)
-{
-  if (TextPaletteEnabled)
-    {
-      Index &= ~0x20;
-    }
-  else
-    {
-      Index |= 0x20;
-    }
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_AC_INDEX, (UCHAR)Index);
-  return(READ_PORT_UCHAR((PUCHAR)VGA_AC_READ));
-}
-
-VOID STATIC FASTCALL
-HalWriteCrtc(ULONG Index, UCHAR Value)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, (UCHAR)Index);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA, Value);
-}
-
-UCHAR STATIC FASTCALL
-HalReadCrtc(ULONG Index)
-{
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, (UCHAR)Index);
-  return(READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA));
-}
-
-VOID STATIC FASTCALL
-HalResetSeq(BOOLEAN Start)
-{
-  if (Start)
-    {
-      HalWriteSeq(0x00, 0x01);
-    }
-  else
-    {
-      HalWriteSeq(0x00, 0x03);
-    }
-}
-
-VOID STATIC FASTCALL
-HalBlankScreen(BOOLEAN On)
-{
-  UCHAR Scrn;
-
-  Scrn = HalReadSeq(0x01);
-
-  if (On)
-    {
-      Scrn &= ~0x20;
-    }
-  else
-    {
-      Scrn |= 0x20;
-    }
-
-  HalResetSeq(TRUE);
-  HalWriteSeq(0x01, Scrn);
-  HalResetSeq(FALSE);
-}
-
-VOID STATIC
-HalSaveFont(VOID)
-{
-  UCHAR Attr10;
-  UCHAR MiscOut, Gc4, Gc5, Gc6, Seq2, Seq4;
-  ULONG i;
-
-  /* Check if we are already in graphics mode. */
-  Attr10 = HalReadAc(0x10);
-  if (Attr10 & 0x01)
-    {
-      return;
-    }
-
-  /* Save registers. */
-  MiscOut = READ_PORT_UCHAR((PUCHAR)VGA_MISC_READ);
-  Gc4 = HalReadGc(0x04);
-  Gc5 = HalReadGc(0x05);
-  Gc6 = HalReadGc(0x06);
-  Seq2 = HalReadSeq(0x02);
-  Seq4 = HalReadSeq(0x04);
-
-  /* Force colour mode. */
-  WRITE_PORT_UCHAR((PUCHAR)VGA_MISC_WRITE, (UCHAR)(MiscOut | 0x01));
-
-  HalBlankScreen(FALSE);
-
-  for (i = 0; i < 2; i++)
-    {
-      /* Save font 1 */
-      HalWriteSeq(0x02, (UCHAR)(0x04 << i)); /* Write to plane 2 or 3 */
-      HalWriteSeq(0x04, 0x06); /* Enable plane graphics. */
-      HalWriteGc(0x04, (UCHAR)(0x02 + i)); /* Read plane 2 or 3 */
-      HalWriteGc(0x05, 0x00); /* Write mode 0; read mode 0 */
-      HalWriteGc(0x06, 0x05); /* Set graphics. */
-      memcpy(SavedTextFont[i], GraphVideoBuffer, FONT_AMOUNT);
-    }
-
-  /* Restore registers. */
-  HalWriteAc(0x10, Attr10);
-  HalWriteSeq(0x02, Seq2);
-  HalWriteSeq(0x04, Seq4);
-  HalWriteGc(0x04, Gc4);
-  HalWriteGc(0x05, Gc5);
-  HalWriteGc(0x06, Gc6);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_MISC_WRITE, MiscOut);
-
-  HalBlankScreen(TRUE);
-}
-
-VOID STATIC
-HalSaveMode(VOID)
-{
-  ULONG i;
-
-  SavedTextMiscOutReg = READ_PORT_UCHAR((PUCHAR)VGA_MISC_READ);
-
-  for (i = 0; i < VGA_CRTC_NUM_REGISTERS; i++)
-    {
-      SavedTextCrtcReg[i] = HalReadCrtc(i);
-    }
-
-  HalEnablePalette();
-  for (i = 0; i < VGA_AC_NUM_REGISTERS; i++)
-    {
-      SavedTextAcReg[i] = HalReadAc(i);
-    }
-  HalDisablePalette();
-
-  for (i = 0; i < VGA_GC_NUM_REGISTERS; i++)
-    {
-      SavedTextGcReg[i] = HalReadGc(i);
-    }
-
-  for (i = 0; i < VGA_SEQ_NUM_REGISTERS; i++)
-    {
-      SavedTextSeqReg[i] = HalReadSeq(i);
-    }
-}
-
-VOID STATIC
-HalDacDelay(VOID)
-{
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-  (VOID)READ_PORT_UCHAR((PUCHAR)VGA_INSTAT_READ);
-}
-
-VOID STATIC
-HalSavePalette(VOID)
-{
-  ULONG i;
-  WRITE_PORT_UCHAR((PUCHAR)VGA_DAC_MASK, 0xFF);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_DAC_READ_INDEX, 0x00);
-  for (i = 0; i < 768; i++)
-    {
-      SavedTextPalette[i] = READ_PORT_UCHAR((PUCHAR)VGA_DAC_DATA);
-      HalDacDelay();
-    }
-}
-
-VOID STATIC
-HalRestoreFont(VOID)
-{
-  UCHAR MiscOut, Attr10, Gc1, Gc3, Gc4, Gc5, Gc6, Gc8;
-  UCHAR Seq2, Seq4;
-  ULONG i;
-
-  /* Save registers. */
-  MiscOut = READ_PORT_UCHAR((PUCHAR)VGA_MISC_READ);
-  Attr10 = HalReadAc(0x10);
-  Gc1 = HalReadGc(0x01);
-  Gc3 = HalReadGc(0x03);
-  Gc4 = HalReadGc(0x04);
-  Gc5 = HalReadGc(0x05);
-  Gc6 = HalReadGc(0x06);
-  Gc8 = HalReadGc(0x08);
-  Seq2 = HalReadSeq(0x02);
-  Seq4 = HalReadSeq(0x04);
-
-  /* Force into colour mode. */
-  WRITE_PORT_UCHAR((PUCHAR)VGA_MISC_WRITE, (UCHAR)(MiscOut | 0x10));
-
-  HalBlankScreen(FALSE);
-
-  HalWriteGc(0x03, 0x00);  /* Don't rotate; write unmodified. */
-  HalWriteGc(0x08, 0xFF);  /* Write all bits. */
-  HalWriteGc(0x01, 0x00);  /* All planes from CPU. */
-
-  for (i = 0; i < 2; i++)
-    {
-      HalWriteSeq(0x02, (UCHAR)(0x04 << i)); /* Write to plane 2 or 3 */
-      HalWriteSeq(0x04, 0x06); /* Enable plane graphics. */
-      HalWriteGc(0x04, (UCHAR)(0x02 + i)); /* Read plane 2 or 3 */
-      HalWriteGc(0x05, 0x00); /* Write mode 0; read mode 0. */
-      HalWriteGc(0x06, 0x05); /* Set graphics. */
-      memcpy(GraphVideoBuffer, SavedTextFont[i], FONT_AMOUNT);
-    }
-
-  HalBlankScreen(TRUE);
-
-  /* Restore registers. */
-  WRITE_PORT_UCHAR((PUCHAR)VGA_MISC_WRITE, MiscOut);
-  HalWriteAc(0x10, Attr10);
-  HalWriteGc(0x01, Gc1);
-  HalWriteGc(0x03, Gc3);
-  HalWriteGc(0x04, Gc4);
-  HalWriteGc(0x05, Gc5);
-  HalWriteGc(0x06, Gc6);
-  HalWriteGc(0x08, Gc8);
-  HalWriteSeq(0x02, Seq2);
-  HalWriteSeq(0x04, Seq4);
-}
-
-VOID STATIC
-HalRestoreMode(VOID)
-{
-  ULONG i;
-
-  WRITE_PORT_UCHAR((PUCHAR)VGA_MISC_WRITE, SavedTextMiscOutReg);
-
-  for (i = 1; i < VGA_SEQ_NUM_REGISTERS; i++)
-    {
-      HalWriteSeq(i, SavedTextSeqReg[i]);
-    }
-
-  /* Unlock CRTC registers 0-7 */
-  HalWriteCrtc(17, (UCHAR)(SavedTextCrtcReg[17] & ~0x80));
-
-  for (i = 0; i < VGA_CRTC_NUM_REGISTERS; i++)
-    {
-      HalWriteCrtc(i, SavedTextCrtcReg[i]);
-    }
-
-  for (i = 0; i < VGA_GC_NUM_REGISTERS; i++)
-    {
-      HalWriteGc(i, SavedTextGcReg[i]);
-    }
-
-  HalEnablePalette();
-  for (i = 0; i < VGA_AC_NUM_REGISTERS; i++)
-    {
-      HalWriteAc(i, SavedTextAcReg[i]);
-    }
-  HalDisablePalette();
-}
-
-VOID STATIC
-HalRestorePalette(VOID)
-{
-  ULONG i;
-  WRITE_PORT_UCHAR((PUCHAR)VGA_DAC_MASK, 0xFF);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_DAC_WRITE_INDEX, 0x00);
-  for (i = 0; i < 768; i++)
-    {
-      WRITE_PORT_UCHAR((PUCHAR)VGA_DAC_DATA, SavedTextPalette[i]);
-      HalDacDelay();
-    }
-  HalDisablePalette();
-}
-
-/* PRIVATE FUNCTIONS ********************************************************/
-
-VOID FASTCALL
-HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock)
-/*
- * FUNCTION: Initalize the display
- * ARGUMENTS:
- *         InitParameters = Parameters setup by the boot loader
- */
-{
-  if (DisplayInitialized == FALSE)
-    {
-      ULONG ScanLines;
-      ULONG Data;
-
-      VideoBuffer = (PUSHORT)(0xff3b8000);
-      GraphVideoBuffer = (PUCHAR)(0xff3a0000);
-
-      /* Set cursor position */
-//      CursorX = LoaderBlock->cursorx;
-//      CursorY = LoaderBlock->cursory;
-      CursorX = 0;
-      CursorY = 0;
-
-      /* read screen size from the crtc */
-      /* FIXME: screen size should be read from the boot parameters */
-      WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_COLUMNS);
-      SizeX = READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA) + 1;
-      WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_ROWS);
-      SizeY = READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA);
-      WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_OVERFLOW);
-      Data = READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA);
-      SizeY |= (((Data & 0x02) << 7) | ((Data & 0x40) << 3));
-      SizeY++;
-      WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_SCANLINES);
-      ScanLines = (READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA) & 0x1F) + 1;
-      SizeY = SizeY / ScanLines;
-
-#ifdef BOCHS_30ROWS
-      SizeY=30;
-#endif
-      HalClearDisplay(CHAR_ATTRIBUTE_BLACK);
-
-      DisplayInitialized = TRUE;
-
-      /* 
-	 Save the VGA state at this point so we can restore it on a bugcheck.
-      */
-      HalSavePalette();
-      HalSaveMode();
-      HalSaveFont();
-    }
-}
-
-
-/* PUBLIC FUNCTIONS *********************************************************/
-
-VOID STDCALL
-HalReleaseDisplayOwnership(VOID)
-/*
- * FUNCTION: Release ownership of display back to HAL
- */
-{
-  if (HalResetDisplayParameters == NULL)
-    return;
-
-  if (HalOwnsDisplay == TRUE)
-    return;
-
-  if (!HalResetDisplayParameters(SizeX, SizeY))
-    {
-      HalRestoreMode();
-      HalRestoreFont();
-      HalRestorePalette();
-    }
-  HalOwnsDisplay = TRUE;
-  HalClearDisplay(CHAR_ATTRIBUTE);
-}
-
-
-VOID STDCALL
-HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
-/*
- * FUNCTION: 
- * ARGUMENTS:
- *         ResetDisplayParameters = Pointer to a driver specific
- *         reset routine.
- */
-{
-  HalOwnsDisplay = FALSE;
-  HalResetDisplayParameters = ResetDisplayParameters;
-}
-
-VOID STDCALL
-HalDisplayString(IN PCH String)
-/*
- * FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
- * already and displays a string
- * ARGUMENT:
- *        string = ASCII string to display
- * NOTE: Use with care because there is no support for returning from BSOD
- * mode
- */
-{
-  PCH pch;
-#ifdef SCREEN_SYNCHRONIZATION
-  int offset;
-#endif
-  static KSPIN_LOCK Lock;
-  KIRQL OldIrql;
-  ULONG Flags;
-
-  /* See comment at top of file */
-  if (!HalOwnsDisplay)
-    {
-      return;
-    }
-
-  pch = String;
-
-  OldIrql = KfRaiseIrql(HIGH_LEVEL);
-  KiAcquireSpinLock(&Lock);
-
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
-
-
-#if 0  
-  if (HalOwnsDisplay == FALSE)
-    {
-      HalReleaseDisplayOwnership();
-    }
-#endif
-  
-#ifdef SCREEN_SYNCHRONIZATION
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_CURHI);
-  offset = READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA)<<8;
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_CURLO);
-  offset += READ_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA);
-  
-  CursorY = offset / SizeX;
-  CursorX = offset % SizeX;
-#endif
-  
-  while (*pch != 0)
-    {
-      if (*pch == '\n')
-	{
-	  CursorY++;
-	  CursorX = 0;
-	}
-      else if (*pch == '\b')
-	{
-	  if (CursorX > 0)
-	    {
-	      CursorX--;
-	    }
-	}
-      else if (*pch != '\r')
-	{
-	  HalPutCharacter (*pch);
-	  CursorX++;
-	  
-	  if (CursorX >= SizeX)
-	    {
-	      CursorY++;
-	      CursorX = 0;
-	    }
-	}
-  
-      if (CursorY >= SizeY)
-	{
-	  HalScrollDisplay ();
-	  CursorY = SizeY - 1;
-	}
-  
-      pch++;
-    }
-  
-#ifdef SCREEN_SYNCHRONIZATION
-  offset = (CursorY * SizeX) + CursorX;
-  
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_CURLO);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA, (UCHAR)(offset & 0xff));
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_INDEX, CRTC_CURHI);
-  WRITE_PORT_UCHAR((PUCHAR)VGA_CRTC_DATA, (UCHAR)((offset >> 8) & 0xff));
-#endif
-  Ki386RestoreFlags(Flags);
-
-  KiReleaseSpinLock(&Lock);
-  KfLowerIrql(OldIrql);
-}
-
-VOID STDCALL
-HalQueryDisplayParameters(OUT PULONG DispSizeX,
-			  OUT PULONG DispSizeY,
-			  OUT PULONG CursorPosX,
-			  OUT PULONG CursorPosY)
-{
-  if (DispSizeX)
-    *DispSizeX = SizeX;
-  if (DispSizeY)
-    *DispSizeY = SizeY;
-  if (CursorPosX)
-    *CursorPosX = CursorX;
-  if (CursorPosY)
-    *CursorPosY = CursorY;
-}
-
-
-VOID STDCALL
-HalSetDisplayParameters(IN ULONG CursorPosX,
-			IN ULONG CursorPosY)
-{
-  CursorX = (CursorPosX < SizeX) ? CursorPosX : SizeX - 1;
-  CursorY = (CursorPosY < SizeY) ? CursorPosY : SizeY - 1;
-}
-
-
-BOOLEAN STDCALL
-HalQueryDisplayOwnership(VOID)
-{
-  return !HalOwnsDisplay;
-}
-
-/* EOF */

reactos/hal/halx86
dma.c removed after 1.10
diff -N dma.c
--- dma.c	21 Nov 2004 21:53:06 -0000	1.10
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,445 +0,0 @@
-/* $Id: dma.c,v 1.10 2004/11/21 21:53:06 ion Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/dma.c
- * PURPOSE:         DMA functions
- * PROGRAMMERS:     David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- *                  Created 22/05/98
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#define NDEBUG
-#include <internal/debug.h>
-#include <hal.h>
-
-/* Adapters for each channel */
-PADAPTER_OBJECT HalpEisaAdapter[8];
-
-/* FUNCTIONS *****************************************************************/
-
-VOID
-HalpInitDma (VOID)
-{
-  /* TODO: Initialize the first Map Buffer */
-}
-
-PVOID STDCALL
-HalAllocateCommonBuffer (PADAPTER_OBJECT    AdapterObject,
-			 ULONG              Length,
-			 PPHYSICAL_ADDRESS  LogicalAddress,
-			 BOOLEAN            CacheEnabled)
-/*
- * FUNCTION: Allocates memory that is visible to both the processor(s) and
- * a dma device
- * ARGUMENTS: 
- *         AdapterObject = Adapter object representing the bus master or
- *                         system dma controller
- *         Length = Number of bytes to allocate
- *         LogicalAddress = Logical address the driver can use to access the
- *                          buffer 
- *         CacheEnabled = Specifies if the memory can be cached
- * RETURNS: The base virtual address of the memory allocated
- *          NULL on failure
- * NOTES:
- *      CacheEnabled is ignored - it's all cache-disabled (like in NT)
- *      UPDATE: It's not ignored now. If that's wrong just modify the
- *      CacheEnabled comparsion below. 
- */
-{
-  PHYSICAL_ADDRESS LowestAddress, HighestAddress, BoundryAddressMultiple;
-  PVOID BaseAddress;
-
-  LowestAddress.QuadPart = 0;
-  BoundryAddressMultiple.QuadPart = 0;
-  HighestAddress.u.HighPart = 0;
-  if ((AdapterObject->Dma32BitAddresses) && (AdapterObject->MasterDevice)) {
-      HighestAddress.u.LowPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */
-  } else {
-      HighestAddress.u.LowPart = 0x00FFFFFF; /* 24Bit: 16MB address range */
-  }
-
-  BaseAddress = MmAllocateContiguousAlignedMemory(
-      Length,
-      LowestAddress,
-      HighestAddress,
-      BoundryAddressMultiple,
-      CacheEnabled ? MmCached : MmNonCached,
-      0x10000 );
-  if (!BaseAddress)
-    return 0;
-
-  *LogicalAddress = MmGetPhysicalAddress(BaseAddress);
-
-  return BaseAddress;
-}
-
-BOOLEAN STDCALL
-HalFlushCommonBuffer (ULONG	Unknown1,
-		      ULONG	Unknown2,
-		      ULONG	Unknown3,
-		      ULONG	Unknown4,
-		      ULONG	Unknown5,
-		      ULONG	Unknown6,
-		      ULONG	Unknown7,
-		      ULONG	Unknown8)
-{
-   return TRUE;
-}
-
-VOID STDCALL
-HalFreeCommonBuffer (PADAPTER_OBJECT		AdapterObject,
-		     ULONG			Length,
-		     PHYSICAL_ADDRESS	LogicalAddress,
-		     PVOID			VirtualAddress,
-		     BOOLEAN			CacheEnabled)
-{
-   MmFreeContiguousMemory(VirtualAddress);
-}
-
-PADAPTER_OBJECT STDCALL
-HalGetAdapter (PDEVICE_DESCRIPTION	DeviceDescription,
-	       PULONG			NumberOfMapRegisters)
-/*
- * FUNCTION: Returns a pointer to an adapter object for the DMA device 
- * defined in the device description structure
- * ARGUMENTS:
- *        DeviceDescription = Structure describing the attributes of the device
- *        NumberOfMapRegisters (OUT) = Returns the maximum number of map
- *                                     registers the device driver can
- *                                     allocate for DMA transfer operations
- * RETURNS: The allocated adapter object on success
- *          NULL on failure
- * TODO:
- *        Testing
- */
-{
-	PADAPTER_OBJECT AdapterObject;
-	DWORD ChannelSelect;
-	DWORD Controller;
-	ULONG MaximumLength;
-	BOOLEAN ChannelSetup;
-
-	DPRINT("Entered Function\n");
-  
-	/* Validate parameters in device description, and return a pointer to
-	the adapter object for the requested dma channel */
-	if(DeviceDescription->Version != DEVICE_DESCRIPTION_VERSION) {
-		DPRINT("Invalid Adapter version!\n");
-		return NULL;
-	}
-
-	DPRINT("Checking Interface Type: %x \n", DeviceDescription->InterfaceType);
-	if (DeviceDescription->InterfaceType == PCIBus) {
-		if (DeviceDescription->Master == FALSE) {
-			DPRINT("Invalid request!\n");
-			return NULL;
-		}
-		ChannelSetup = FALSE;
-	}
-	
-	/* There are only 8 DMA channels on ISA, so any request above this
-	should not get any channel setup */
-	if (DeviceDescription->DmaChannel >= 8) {
-		ChannelSetup = FALSE;
-	}
-	
-	/* Channel 4 is Reserved for Chaining, so you cant use it */
-	if (DeviceDescription->DmaChannel == 4 && ChannelSetup) {
-		DPRINT("Invalid request!\n");
-		return NULL;
-	}
-	
-	/* Devices that support Scatter/Gather do not need Map Registers */
-	if (DeviceDescription->ScatterGather && 
-	    (DeviceDescription->InterfaceType == Eisa ||
-	     DeviceDescription->InterfaceType == PCIBus)) {
-		*NumberOfMapRegisters = 0;
-	}
-	
-	/* Check if Extended DMA is available (we're just going to do a random read/write
-	I picked Channel 2 because it's the first Channel in the Register */
-	WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaController1Pages.Channel2), 0x2A);
-	if (READ_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaController1Pages.Channel2)) == 0x2A) {
-		HalpEisaDma = TRUE;
-	}
-	 
-	/* Find out how many Map Registers we need */
-	DPRINT("Setting up Adapter Settings!\n");
-	MaximumLength = DeviceDescription->MaximumLength & 0x7FFFFFFF;
-        *NumberOfMapRegisters = BYTES_TO_PAGES(MaximumLength) + 1;
-	
-	/* Set the Channel Selection */
-	ChannelSelect = DeviceDescription->DmaChannel & 0x03;
-	
-	/* Get the Controller Setup */
-	Controller = (DeviceDescription->DmaChannel & 0x04) ? 1 : 2;
-	
-	/* Get the Adapter Object */
-	if (HalpEisaAdapter[DeviceDescription->DmaChannel] != NULL) {
-	
-		/* Already allocated, return it */
-		DPRINT("Getting an Adapter Object from the Cache\n");
-		AdapterObject = HalpEisaAdapter[DeviceDescription->DmaChannel];
-		
-		/* Do we need more Map Registers this time? */
-		if ((AdapterObject->NeedsMapRegisters) && 
-		    (*NumberOfMapRegisters > AdapterObject->MapRegistersPerChannel)) {
-			AdapterObject->MapRegistersPerChannel = *NumberOfMapRegisters;
-		}
-		
-		} else {
-	
-		/* We have to allocate a new object! How exciting! */
-		DPRINT("Allocating a new Adapter Object\n");
-		AdapterObject = HalpAllocateAdapterEx(*NumberOfMapRegisters,
-						      FALSE,
-						      DeviceDescription->Dma32BitAddresses);
-
-		if (AdapterObject == NULL) return NULL;
-		
-		HalpEisaAdapter[DeviceDescription->DmaChannel] = AdapterObject;
-		
-		if (!*NumberOfMapRegisters) {
-			/* Easy case, no Map Registers needed */
-			AdapterObject->NeedsMapRegisters = FALSE;
-		
-			/* If you're the master, you get all you want */
-			if (DeviceDescription->Master) {
-				AdapterObject->MapRegistersPerChannel= *NumberOfMapRegisters;
-			} else {
-				AdapterObject->MapRegistersPerChannel = 1;
-			}
-		} else {
-			/* We Desire Registers */
-			AdapterObject->NeedsMapRegisters = TRUE;
-		
-			/* The registers you want */
-			AdapterObject->MapRegistersPerChannel = *NumberOfMapRegisters;
-		
-			/* Increase commitment */
-			MasterAdapter->CommittedMapRegisters += *NumberOfMapRegisters;
-		}
-	}
-	
-	/* Set up DMA Structure */
-	if (Controller == 1) {
-		AdapterObject->AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController1);
-	} else {
-		AdapterObject->AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController2);
-	}
-	        
-	/* Set up Some Adapter Data */
-	DPRINT("Setting up an Adapter Object\n");
-	AdapterObject->IgnoreCount = DeviceDescription->IgnoreCount;
-	AdapterObject->Dma32BitAddresses = DeviceDescription->Dma32BitAddresses;
-	AdapterObject->Dma64BitAddresses = DeviceDescription->Dma64BitAddresses;
-	AdapterObject->ScatterGather = DeviceDescription->ScatterGather;
-        AdapterObject->MasterDevice = DeviceDescription->Master;
-	if (DeviceDescription->InterfaceType != PCIBus) AdapterObject->LegacyAdapter = TRUE;
-	
-	/* Everything below is not required if we don't need a channel */
-	if (!ChannelSetup) {
-		DPRINT("Retuning Adapter Object without Channel Setup\n");
-		return AdapterObject;
-	}
-	
-	AdapterObject->ChannelNumber = ChannelSelect;
-	
-	
-	/* Set up the Page Port */
-	if (Controller == 1) {
-		switch (ChannelSelect) {
-		
-		case 0:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel0));
-			break;
-		case 1:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel1));
-			break;
-		case 2:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel2));
-			break;
-		case 3:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel3));
-			break;
-		}
-	
-		/* Set Controller Number */
-		AdapterObject->AdapterNumber = 1; 
-	} else {
-		switch (ChannelSelect) {
-		
-		case 1:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel5));
-			break;
-		case 2:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel6));
-			break;
-		case 3:
-			AdapterObject->PagePort = (PUCHAR)(FIELD_OFFSET(DMA_PAGE, Channel7));
-			break;
-		}
-		
-		/* Set Controller Number */
-		AdapterObject->AdapterNumber = 2; 
-	}
-	
-	/* Set up the Extended Register */
-	if (HalpEisaDma) {
-		DMA_EXTENDED_MODE ExtendedMode;
-		
-		ExtendedMode.ChannelNumber = ChannelSelect;
-	
-		switch (DeviceDescription->DmaSpeed) {
-		
-		case Compatible:
-			ExtendedMode.TimingMode = COMPATIBLE_TIMING;
-			break;
-		
-		case TypeA:
-			ExtendedMode.TimingMode = TYPE_A_TIMING;
-			break;
-			
-		case TypeB:
-			ExtendedMode.TimingMode = TYPE_B_TIMING;
-			break;
-			
-		case TypeC:
-			ExtendedMode.TimingMode = BURST_TIMING;
-			break;
-		
-		default:
-			return NULL;
-		}
-	
-		switch (DeviceDescription->DmaWidth) {
-		
-		case Width8Bits:
-			ExtendedMode.TransferSize = B_8BITS;
-			break;
-		
-		case Width16Bits:
-			ExtendedMode.TransferSize = B_16BITS;
-			break;
-			
-		case Width32Bits:
-			ExtendedMode.TransferSize = B_32BITS;
-			break;
-			
-		default:
-			return NULL;
-				}
-		
-		if (Controller == 1) {
-			WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode1),
-				    	*((PUCHAR)&ExtendedMode));
-		} else {
-	       		WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2),
-				    	*((PUCHAR)&ExtendedMode));
-		}
-	}
-			/* Do 8/16-bit validation */
-	DPRINT("Validating an Adapter Object\n");
-	if (!DeviceDescription->Master) {
-		if ((DeviceDescription->DmaWidth == Width8Bits) && (Controller != 1)) {
-			return NULL; /* 8-bit is only avalable on Controller 1 */
-		} else if (DeviceDescription->DmaWidth == Width16Bits) {
-			if (Controller != 2) {
-				return NULL; /* 16-bit is only avalable on Controller 2 */
-			} else {
-				AdapterObject->Width16Bits = TRUE;
-			}
-		}
-	}
-		UCHAR DmaMode;	
-			DPRINT("Final DMA Request Mode Setting of the Adapter Object\n");
-	/* Set the DMA Request Modes */
-	if (DeviceDescription->Master) {
-		/* This is a cascade request */
-		((PDMA_MODE)&DmaMode)->RequestMode = CASCADE_REQUEST_MODE;
-		
-		/* Send the request */
-		if (AdapterObject->AdapterNumber == 1) {
-			/* Set the Request Data */
-			WRITE_PORT_UCHAR(&((PDMA1_CONTROL)AdapterObject->AdapterBaseVa)->Mode,
-				  	AdapterObject->AdapterMode);
-					  
-			/* Unmask DMA Channel */
-			WRITE_PORT_UCHAR(&((PDMA1_CONTROL)AdapterObject->AdapterBaseVa)->SingleMask,
-				  	AdapterObject->ChannelNumber | DMA_CLEARMASK);
-		} else {
-			/* Set the Request Data */
-			WRITE_PORT_UCHAR(&((PDMA2_CONTROL)AdapterObject->AdapterBaseVa)->Mode,
-				  	AdapterObject->AdapterMode);
-				  
-			/* Unmask DMA Channel */
-			WRITE_PORT_UCHAR(&((PDMA2_CONTROL)AdapterObject->AdapterBaseVa)->SingleMask,
-				  	AdapterObject->ChannelNumber | DMA_CLEARMASK);
-		}
-	} else if (DeviceDescription->DemandMode) {
-		/* This is a Demand request */
-		((PDMA_MODE)&DmaMode)->RequestMode = DEMAND_REQUEST_MODE;
-	} else {
-		/* Normal Request */
-		((PDMA_MODE)&DmaMode)->RequestMode = SINGLE_REQUEST_MODE;
-	}
-	
-	/* Auto Initialize Enabled or Not*/
-	((PDMA_MODE)&DmaMode)->AutoInitialize = DeviceDescription->AutoInitialize;
-	AdapterObject->AdapterMode = DmaMode;
-	return AdapterObject;
-}
-
-ULONG STDCALL
-HalReadDmaCounter (PADAPTER_OBJECT	AdapterObject)
-{
-  KIRQL OldIrql;
-  ULONG Count;
-
- 	KeAcquireSpinLock(&AdapterObject->MasterAdapter->SpinLock, &OldIrql);
-  
-  	/* Send the Request to the specific controller */
-	if (AdapterObject->AdapterNumber == 1) {
-  	
-		/* Set this for Ease */
-  		PDMA1_CONTROL DmaControl1 = AdapterObject->AdapterBaseVa;
-	
-		/* Send Reset */
-		WRITE_PORT_UCHAR(&DmaControl1->ClearBytePointer, 0);
-	
-		/* Read Count */
-		Count = READ_PORT_UCHAR(&DmaControl1->DmaAddressCount
-					[AdapterObject->ChannelNumber].DmaBaseCount);
-		Count |= READ_PORT_UCHAR(&DmaControl1->DmaAddressCount
-					[AdapterObject->ChannelNumber].DmaBaseCount) << 8;
-      
-	} else {
-
-		/* Set this for Ease */
-  		PDMA2_CONTROL DmaControl2 = AdapterObject->AdapterBaseVa;
-	
-		/* Send Reset */
-		WRITE_PORT_UCHAR(&DmaControl2->ClearBytePointer, 0);
-	
-		/* Read Count */
-		Count = READ_PORT_UCHAR(&DmaControl2->DmaAddressCount
-					[AdapterObject->ChannelNumber].DmaBaseCount);
-		Count |= READ_PORT_UCHAR(&DmaControl2->DmaAddressCount
-					[AdapterObject->ChannelNumber].DmaBaseCount) << 8;
-	}
-	
-	/* Play around with the count (add bias and multiply by 2 if 16-bit DMA) */
-	Count ++;
-	if (AdapterObject->Width16Bits) Count *=2 ;
-	
-	KeReleaseSpinLock(&AdapterObject->MasterAdapter->SpinLock, OldIrql);
-	
-	/* Return it */
-	return Count;
-}
-
-/* EOF */

reactos/hal/halx86
drive.c removed after 1.4
diff -N drive.c
--- drive.c	26 Feb 2003 14:14:03 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-/* $Id: drive.c,v 1.4 2003/02/26 14:14:03 ekohl Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            hal/x86/drive.c
- * PURPOSE:         Drive letter assignment
- * PROGRAMMER:      
- * UPDATE HISTORY:
- *	2000-03-25
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <internal/debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-VOID STDCALL
-IoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
-		     IN PSTRING NtDeviceName,
-		     OUT PUCHAR NtSystemPath,
-		     OUT PSTRING NtSystemPathString)
-{
-  HalIoAssignDriveLetters(LoaderBlock,
-			  NtDeviceName,
-			  NtSystemPath,
-			  NtSystemPathString);
-}
-
-/* EOF */

reactos/hal/halx86
enum.c removed after 1.5
diff -N enum.c
--- enum.c	8 Sep 2002 10:22:24 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-/* $Id: enum.c,v 1.5 2002/09/08 10:22:24 chorns Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/enum.c
- * PURPOSE:         Motherboard device enumerator
- * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
- * UPDATE HISTORY:
- *                  Created 01/05/2001
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <roscfg.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-VOID
-HalpStartEnumerator (VOID)
-{
-}
-
-/* EOF */

reactos/hal/halx86
fmutex.c removed after 1.5
diff -N fmutex.c
--- fmutex.c	8 Sep 2002 10:22:24 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* $Id: fmutex.c,v 1.5 2002/09/08 10:22:24 chorns Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/fmutex.c
- * PURPOSE:         Implements fast mutexes
- * PROGRAMMER:      David Welch (welch@cwcom.net)
- *                  Eric Kohl (ekohl@rz-online.de)
- * UPDATE HISTORY:
- *                  Created 09/06/2000
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-
-#include <internal/debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-VOID FASTCALL
-ExAcquireFastMutex (PFAST_MUTEX	FastMutex)
-{
-   KeEnterCriticalRegion();
-   ExAcquireFastMutexUnsafe(FastMutex);
-}
-
-
-VOID FASTCALL
-ExReleaseFastMutex (PFAST_MUTEX	FastMutex)
-{
-  ExReleaseFastMutexUnsafe(FastMutex);
-  KeLeaveCriticalRegion();
-}
-
-
-BOOLEAN FASTCALL
-ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex)
-{
-  KeEnterCriticalRegion();
-  if (InterlockedExchange(&FastMutex->Count, 0) == 1)
-    {
-      FastMutex->Owner = KeGetCurrentThread();
-      return(TRUE);
-    }
-  else
-    {
-      KeLeaveCriticalRegion();
-      return(FALSE);
-    }
-}
-
-/* EOF */

reactos/hal/halx86
halx86mp.rc removed after 1.5
diff -N halx86mp.rc
--- halx86mp.rc	16 Oct 2004 20:27:29 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
-#define REACTOS_VERSION_DLL
-#define REACTOS_STR_FILE_DESCRIPTION	"X86 Multiprocessor Hardware Abstraction Layer\0"
-#define REACTOS_STR_INTERNAL_NAME	"halx86mp\0"
-#define REACTOS_STR_ORIGINAL_FILENAME	"halx86mp.dll\0"
-#include <reactos/version.rc>

reactos/hal/halx86
halx86up.rc removed after 1.5
diff -N halx86up.rc
--- halx86up.rc	16 Oct 2004 20:27:29 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
-#define REACTOS_VERSION_DLL
-#define REACTOS_STR_FILE_DESCRIPTION	"X86 Uniprocessor Hardware Abstraction Layer\0"
-#define REACTOS_STR_INTERNAL_NAME	"halx86up\0"
-#define REACTOS_STR_ORIGINAL_FILENAME	"halx86up.dll\0"
-#include <reactos/version.rc>

reactos/hal/halx86
irql.c removed after 1.22
diff -N irql.c
--- irql.c	21 Nov 2004 21:53:06 -0000	1.22
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,480 +0,0 @@
-/* $Id: irql.c,v 1.22 2004/11/21 21:53:06 ion Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/irql.c
- * PURPOSE:         Implements IRQLs
- * PROGRAMMER:      David Welch (welch@cwcom.net)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <roscfg.h>
-#include <ddk/ntddk.h>
-#include <internal/ps.h>
-#include <ntos/minmax.h>
-#include <hal.h>
-#include <halirq.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS ******************************************************************/
-
-/*
- * FIXME: Use EISA_CONTROL STRUCTURE INSTEAD OF HARD-CODED OFFSETS 
-*/
-
-typedef union
-{
-   USHORT both;
-   struct
-   {
-      BYTE master;
-      BYTE slave;
-   };
-}
-PIC_MASK;
-   
-/* 
- * PURPOSE: - Mask for HalEnableSystemInterrupt and HalDisableSystemInterrupt
- *          - At startup enable timer and cascade 
- */
-#if defined(__GNUC__)
-static PIC_MASK pic_mask = {.both = 0xFFFA};
-#else
-static PIC_MASK pic_mask = { 0xFFFA };
-#endif
-
-
-/*
- * PURPOSE: Mask for disabling of acknowledged interrupts 
- */
-#if defined(__GNUC__)
-static PIC_MASK pic_mask_intr = {.both = 0x0000};
-#else
-static PIC_MASK pic_mask_intr = { 0 };
-#endif
-
-static ULONG HalpPendingInterruptCount[NR_IRQS];
-
-#define DIRQL_TO_IRQ(x)  (PROFILE_LEVEL - x)
-#define IRQ_TO_DIRQL(x)  (PROFILE_LEVEL - x)
-
-VOID STDCALL
-KiInterruptDispatch2 (ULONG Irq, KIRQL old_level);
-
-/* FUNCTIONS ****************************************************************/
-
-KIRQL STDCALL KeGetCurrentIrql (VOID)
-/*
- * PURPOSE: Returns the current irq level
- * RETURNS: The current irq level
- */
-{
-  return(KeGetCurrentKPCR()->Irql);
-}
-
-VOID HalpInitPICs(VOID)
-{
-  memset(HalpPendingInterruptCount, 0, sizeof(HalpPendingInterruptCount));
-
-  /* Initialization sequence */
-  WRITE_PORT_UCHAR((PUCHAR)0x20, 0x11);
-  WRITE_PORT_UCHAR((PUCHAR)0xa0, 0x11);
-  /* Start of hardware irqs (0x24) */
-  WRITE_PORT_UCHAR((PUCHAR)0x21, IRQ_BASE);
-  WRITE_PORT_UCHAR((PUCHAR)0xa1, IRQ_BASE + 8);
-  /* 8259-1 is master */
-  WRITE_PORT_UCHAR((PUCHAR)0x21, 0x4);
-  /* 8259-2 is slave */
-  WRITE_PORT_UCHAR((PUCHAR)0xa1, 0x2);
-  /* 8086 mode */
-  WRITE_PORT_UCHAR((PUCHAR)0x21, 0x1);
-  WRITE_PORT_UCHAR((PUCHAR)0xa1, 0x1);   
-  /* Enable interrupts */
-  WRITE_PORT_UCHAR((PUCHAR)0x21, pic_mask.master);
-  WRITE_PORT_UCHAR((PUCHAR)0xa1, pic_mask.slave);
-  
-  /* We can now enable interrupts */
-  Ki386EnableInterrupts();
-}
-
-VOID HalpEndSystemInterrupt(KIRQL Irql)
-/*
- * FUNCTION: Enable all irqs with higher priority.
- */
-{
-  ULONG flags;
-  const USHORT mask[] = 
-  {
-     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-     0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0xc000, 0xe000, 0xf000,
-     0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 0xffc0, 0xffe0, 0xfff0,
-     0xfff8, 0xfffc, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-  };     
-
-  /* Interrupts should be disable while enabling irqs of both pics */
-  Ki386SaveFlags(flags);
-  Ki386DisableInterrupts();
-
-  pic_mask_intr.both &= mask[Irql];
-  WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)(pic_mask.master|pic_mask_intr.master));
-  WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)(pic_mask.slave|pic_mask_intr.slave));
-
-  /* restore flags */
-  Ki386RestoreFlags(flags);
-}
-
-VOID STATIC
-HalpExecuteIrqs(KIRQL NewIrql)
-{
-  ULONG IrqLimit, i;
-  
-  IrqLimit = min(PROFILE_LEVEL - NewIrql, NR_IRQS);
-
-  /*
-   * For each irq if there have been any deferred interrupts then now
-   * dispatch them.
-   */
-  for (i = 0; i < IrqLimit; i++)
-    {
-      if (HalpPendingInterruptCount[i] > 0)
-	{
-	   KeGetCurrentKPCR()->Irql = (KIRQL)IRQ_TO_DIRQL(i);
-
-           while (HalpPendingInterruptCount[i] > 0)
-	     {
-	       /*
-	        * For each deferred interrupt execute all the handlers at DIRQL.
-	        */
-	       HalpPendingInterruptCount[i]--;
-	       KiInterruptDispatch2(i + IRQ_BASE, NewIrql);
-	     }
-	   KeGetCurrentKPCR()->Irql--;
-	   HalpEndSystemInterrupt(KeGetCurrentKPCR()->Irql);
-	}
-    }
-
-}
-
-VOID STATIC
-HalpLowerIrql(KIRQL NewIrql)
-{
-  if (NewIrql >= PROFILE_LEVEL)
-    {
-      KeGetCurrentKPCR()->Irql = NewIrql;
-      return;
-    }
-  HalpExecuteIrqs(NewIrql);
-  if (NewIrql >= DISPATCH_LEVEL)
-    {
-      KeGetCurrentKPCR()->Irql = NewIrql;
-      return;
-    }
-  KeGetCurrentKPCR()->Irql = DISPATCH_LEVEL;
-  if (KeGetCurrentKPCR()->HalReserved[HAL_DPC_REQUEST])
-    {
-      KeGetCurrentKPCR()->HalReserved[HAL_DPC_REQUEST] = FALSE;
-      KiDispatchInterrupt();
-    }
-  KeGetCurrentKPCR()->Irql = APC_LEVEL;
-  if (NewIrql == APC_LEVEL)
-    {
-      return;
-    }
-  if (KeGetCurrentThread() != NULL && 
-      KeGetCurrentThread()->ApcState.KernelApcPending)
-    {
-      KiDeliverApc(KernelMode, NULL, NULL);
-    }
-  KeGetCurrentKPCR()->Irql = PASSIVE_LEVEL;
-}
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KfLowerIrql
- *
- * DESCRIPTION
- *	Restores the irq level on the current processor
- *
- * ARGUMENTS
- *	NewIrql = Irql to lower to
- *
- * RETURN VALUE
- *	None
- *
- * NOTES
- *	Uses fastcall convention
- */
-VOID FASTCALL
-KfLowerIrql (KIRQL	NewIrql)
-{
-  DPRINT("KfLowerIrql(NewIrql %d)\n", NewIrql);
-  
-  if (NewIrql > KeGetCurrentKPCR()->Irql)
-    {
-      DbgPrint ("(%s:%d) NewIrql %x CurrentIrql %x\n",
-		__FILE__, __LINE__, NewIrql, KeGetCurrentKPCR()->Irql);
-      KEBUGCHECK(0);
-      for(;;);
-    }
-  
-  HalpLowerIrql(NewIrql);
-}
-
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KeLowerIrql
- *
- * DESCRIPTION
- *	Restores the irq level on the current processor
- *
- * ARGUMENTS
- *	NewIrql = Irql to lower to
- *
- * RETURN VALUE
- *	None
- *
- * NOTES
- */
-
-VOID STDCALL
-KeLowerIrql (KIRQL NewIrql)
-{
-  KfLowerIrql (NewIrql);
-}
-
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KfRaiseIrql
- *
- * DESCRIPTION
- *	Raises the hardware priority (irql)
- *
- * ARGUMENTS
- *	NewIrql = Irql to raise to
- *
- * RETURN VALUE
- *	previous irq level
- *
- * NOTES
- *	Uses fastcall convention
- */
-
-KIRQL FASTCALL
-KfRaiseIrql (KIRQL	NewIrql)
-{
-  KIRQL OldIrql;
-  
-  DPRINT("KfRaiseIrql(NewIrql %d)\n", NewIrql);
-  
-  if (NewIrql < KeGetCurrentKPCR()->Irql)
-    {
-      DbgPrint ("%s:%d CurrentIrql %x NewIrql %x\n",
-		__FILE__,__LINE__,KeGetCurrentKPCR()->Irql,NewIrql);
-      KEBUGCHECK (0);
-      for(;;);
-    }
-  
-  OldIrql = KeGetCurrentKPCR()->Irql;
-  KeGetCurrentKPCR()->Irql = NewIrql;
-  return OldIrql;
-}
-
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KeRaiseIrql
- *
- * DESCRIPTION
- *	Raises the hardware priority (irql)
- *
- * ARGUMENTS
- *	NewIrql = Irql to raise to
- *	OldIrql (OUT) = Caller supplied storage for the previous irql
- *
- * RETURN VALUE
- *	None
- *
- * NOTES
- *	Calls KfRaiseIrql
- */
-VOID STDCALL
-KeRaiseIrql (KIRQL	NewIrql,
-	     PKIRQL	OldIrql)
-{
-  *OldIrql = KfRaiseIrql (NewIrql);
-}
-
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KeRaiseIrqlToDpcLevel
- *
- * DESCRIPTION
- *	Raises the hardware priority (irql) to DISPATCH level
- *
- * ARGUMENTS
- *	None
- *
- * RETURN VALUE
- *	Previous irq level
- *
- * NOTES
- *	Calls KfRaiseIrql
- */
-
-KIRQL STDCALL
-KeRaiseIrqlToDpcLevel (VOID)
-{
-  return KfRaiseIrql (DISPATCH_LEVEL);
-}
-
-
-/**********************************************************************
- * NAME							EXPORTED
- *	KeRaiseIrqlToSynchLevel
- *
- * DESCRIPTION
- *	Raises the hardware priority (irql) to CLOCK2 level
- *
- * ARGUMENTS
- *	None
- *
- * RETURN VALUE
- *	Previous irq level
- *
- * NOTES
- *	Calls KfRaiseIrql
- */
-
-KIRQL STDCALL
-KeRaiseIrqlToSynchLevel (VOID)
-{
-  return KfRaiseIrql (CLOCK2_LEVEL);
-}
-
-
-BOOLEAN STDCALL 
-HalBeginSystemInterrupt (ULONG Vector,
-			 KIRQL Irql,
-			 PKIRQL OldIrql)
-{
-  ULONG irq;
-  if (Vector < IRQ_BASE || Vector >= IRQ_BASE + NR_IRQS)
-    {
-      return(FALSE);
-    }
-  irq = Vector - IRQ_BASE;
-  pic_mask_intr.both |= ((1 << irq) & 0xfffe);	// do not disable the timer interrupt
-
-  if (irq < 8)
-  {
-     WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)(pic_mask.master|pic_mask_intr.master));
-     WRITE_PORT_UCHAR((PUCHAR)0x20, 0x20);
-  }
-  else
-  {
-     WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)(pic_mask.slave|pic_mask_intr.slave));
-     /* Send EOI to the PICs */
-     WRITE_PORT_UCHAR((PUCHAR)0x20,0x20);
-     WRITE_PORT_UCHAR((PUCHAR)0xa0,0x20);
-  }
-  
-  if (KeGetCurrentKPCR()->Irql >= Irql)
-    {
-      HalpPendingInterruptCount[irq]++;
-      return(FALSE);
-    }
-  *OldIrql = KeGetCurrentKPCR()->Irql;
-  KeGetCurrentKPCR()->Irql = Irql;
-
-  return(TRUE);
-}
-
-
-VOID STDCALL HalEndSystemInterrupt (KIRQL Irql, ULONG Unknown2)
-/*
- * FUNCTION: Finish a system interrupt and restore the specified irq level.
- */
-{
-  HalpLowerIrql(Irql);
-  HalpEndSystemInterrupt(Irql);
-}
-  
-BOOLEAN
-STDCALL
-HalDisableSystemInterrupt(
-  ULONG Vector,
-  KIRQL Irql)
-{
-  ULONG irq;
-  
-  if (Vector < IRQ_BASE || Vector >= IRQ_BASE + NR_IRQS)
-    return FALSE;
-
-  irq = Vector - IRQ_BASE;
-  pic_mask.both |= (1 << irq);
-  if (irq < 8)
-     {
-      WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)(pic_mask.master|pic_mask_intr.slave));
-     }
-  else
-    {
-      WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)(pic_mask.slave|pic_mask_intr.slave));
-    }
-  
-  return TRUE;
-}
-
-
-BOOLEAN
-STDCALL
-HalEnableSystemInterrupt(
-  ULONG Vector,
-  KIRQL Irql,
-  KINTERRUPT_MODE InterruptMode)
-{
-  ULONG irq;
-
-  if (Vector < IRQ_BASE || Vector >= IRQ_BASE + NR_IRQS)
-    return FALSE;
-
-  irq = Vector - IRQ_BASE;
-  pic_mask.both &= ~(1 << irq);
-  if (irq < 8)
-    {
-      WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)(pic_mask.master|pic_mask_intr.master));
-    }
-  else
-     {
-       WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)(pic_mask.slave|pic_mask_intr.slave));
-     }
-
-  return TRUE;
-}
-
-
-VOID FASTCALL
-HalRequestSoftwareInterrupt(
-  IN KIRQL Request)
-{
-  switch (Request)
-  {
-    case APC_LEVEL:
-      KeGetCurrentKPCR()->HalReserved[HAL_APC_REQUEST] = TRUE;
-      break;
-
-    case DISPATCH_LEVEL:
-      KeGetCurrentKPCR()->HalReserved[HAL_DPC_REQUEST] = TRUE;
-      break;
-      
-    default:
-      KEBUGCHECK(0);
-  }
-}
-
-/* EOF */

reactos/hal/halx86
isa.c removed after 1.7
diff -N isa.c
--- isa.c	1 Nov 2004 14:37:19 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-/* $Id: isa.c,v 1.7 2004/11/01 14:37:19 hbirr Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/isa.c
- * PURPOSE:         Interfaces to the ISA bus
- * PROGRAMMER:      David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- *               05/06/98: Created
- */
-
-/* INCLUDES ***************************************************************/
-
-#include <roscfg.h>
-#include <ddk/ntddk.h>
-#include <bus.h>
-#include <halirq.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-BOOL HalIsaProbe(VOID)
-/*
- * FUNCTION: Probes for an ISA bus
- * RETURNS: True if detected
- * NOTE: Since ISA is the default we are called last and always return
- * true
- */
-{
-   DbgPrint("Assuming ISA bus\n");
-   
-   /*
-    * Probe for plug and play support
-    */
-   return(TRUE);
-}
-
-
-BOOLEAN STDCALL
-HalpTranslateIsaBusAddress(PBUS_HANDLER BusHandler,
-			   ULONG BusNumber,
-			   PHYSICAL_ADDRESS BusAddress,
-			   PULONG AddressSpace,
-			   PPHYSICAL_ADDRESS TranslatedAddress)
-{
-   BOOLEAN Result;
-
-   Result = HalTranslateBusAddress(PCIBus,
-				   BusNumber,
-				   BusAddress,
-				   AddressSpace,
-				   TranslatedAddress);
-   if (Result != FALSE)
-     return Result;
-
-   Result = HalTranslateBusAddress(Internal,
-				   BusNumber,
-				   BusAddress,
-				   AddressSpace,
-				   TranslatedAddress);
-   return Result;
-}
-
-ULONG STDCALL
-HalpGetIsaInterruptVector(PVOID BusHandler,
-			  ULONG BusNumber,
-			  ULONG BusInterruptLevel,
-			  ULONG BusInterruptVector,
-			  PKIRQL Irql,
-			  PKAFFINITY Affinity)
-{
-  ULONG Vector = IRQ2VECTOR(BusInterruptVector);
-  *Irql = VECTOR2IRQL(Vector);
-  *Affinity = 0xFFFFFFFF;
-  return Vector;
-}
-/* EOF */

reactos/hal/halx86
kdbg.c removed after 1.8
diff -N kdbg.c
--- kdbg.c	29 Apr 2004 17:06:21 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,548 +0,0 @@
-/* $Id: kdbg.c,v 1.8 2004/04/29 17:06:21 navaraf Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/kdbg.c
- * PURPOSE:         Serial i/o functions for the kernel debugger.
- * PROGRAMMER:      Emanuele Aliberti
- *                  Eric Kohl
- * UPDATE HISTORY:
- *                  Created 05/09/99
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-#define DEFAULT_BAUD_RATE    19200
-
-
-/* MACROS *******************************************************************/
-
-#define   SER_RBR(x)   ((x)+0)
-#define   SER_THR(x)   ((x)+0)
-#define   SER_DLL(x)   ((x)+0)
-#define   SER_IER(x)   ((x)+1)
-#define     SR_IER_ERDA   0x01
-#define     SR_IER_ETHRE  0x02
-#define     SR_IER_ERLSI  0x04
-#define     SR_IER_EMS    0x08
-#define     SR_IER_ALL    0x0F
-#define   SER_DLM(x)   ((x)+1)
-#define   SER_IIR(x)   ((x)+2)
-#define   SER_FCR(x)   ((x)+2)
-#define     SR_FCR_ENABLE_FIFO 0x01
-#define     SR_FCR_CLEAR_RCVR  0x02
-#define     SR_FCR_CLEAR_XMIT  0x04
-#define   SER_LCR(x)   ((x)+3)
-#define     SR_LCR_CS5 0x00
-#define     SR_LCR_CS6 0x01
-#define     SR_LCR_CS7 0x02
-#define     SR_LCR_CS8 0x03
-#define     SR_LCR_ST1 0x00
-#define     SR_LCR_ST2 0x04
-#define     SR_LCR_PNO 0x00
-#define     SR_LCR_POD 0x08
-#define     SR_LCR_PEV 0x18
-#define     SR_LCR_PMK 0x28
-#define     SR_LCR_PSP 0x38
-#define     SR_LCR_BRK 0x40
-#define     SR_LCR_DLAB 0x80
-#define   SER_MCR(x)   ((x)+4)
-#define     SR_MCR_DTR 0x01
-#define     SR_MCR_RTS 0x02
-#define     SR_MCR_OUT1 0x04
-#define     SR_MCR_OUT2 0x08
-#define     SR_MCR_LOOP 0x10
-#define   SER_LSR(x)   ((x)+5)
-#define     SR_LSR_DR  0x01
-#define     SR_LSR_TBE 0x20
-#define   SER_MSR(x)   ((x)+6)
-#define     SR_MSR_CTS 0x10
-#define     SR_MSR_DSR 0x20
-#define   SER_SCR(x)   ((x)+7)
-
-
-/* GLOBAL VARIABLES *********************************************************/
-
-ULONG EXPORTED KdComPortInUse = 0;
-
-
-/* STATIC VARIABLES *********************************************************/
-
-static ULONG ComPort = 0;
-static ULONG BaudRate = 0;
-static PUCHAR PortBase = (PUCHAR)0;
-
-/* The com port must only be initialized once! */
-static BOOLEAN PortInitialized = FALSE;
-
-
-/* STATIC FUNCTIONS *********************************************************/
-
-static BOOLEAN
-KdpDoesComPortExist (PUCHAR BaseAddress)
-{
-        BOOLEAN found;
-        BYTE mcr;
-        BYTE msr;
-
-        found = FALSE;
-
-        /* save Modem Control Register (MCR) */
-        mcr = READ_PORT_UCHAR (SER_MCR(BaseAddress));
-
-        /* enable loop mode (set Bit 4 of the MCR) */
-        WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10);
-
-        /* clear all modem output bits */
-        WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x10);
-
-        /* read the Modem Status Register */
-        msr = READ_PORT_UCHAR (SER_MSR(BaseAddress));
-
-        /*
-         * the upper nibble of the MSR (modem output bits) must be
-         * equal to the lower nibble of the MCR (modem input bits)
-         */
-        if ((msr & 0xF0) == 0x00)
-        {
-                /* set all modem output bits */
-                WRITE_PORT_UCHAR (SER_MCR(BaseAddress), 0x1F);
-
-                /* read the Modem Status Register */
-                msr = READ_PORT_UCHAR (SER_MSR(BaseAddress));
-
-                /*
-                 * the upper nibble of the MSR (modem output bits) must be
-                 * equal to the lower nibble of the MCR (modem input bits)
-                 */
-                if ((msr & 0xF0) == 0xF0)
-                {
-                        /*
-                         * setup a resonable state for the port:
-                         * enable fifo and clear recieve/transmit buffers
-                         */
-                        WRITE_PORT_UCHAR (SER_FCR(BaseAddress),
-                                (SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT));
-                        WRITE_PORT_UCHAR (SER_FCR(BaseAddress), 0);
-                        READ_PORT_UCHAR (SER_RBR(BaseAddress));
-                        WRITE_PORT_UCHAR (SER_IER(BaseAddress), 0);
-                        found = TRUE;
-                }
-        }
-
-        /* restore MCR */
-        WRITE_PORT_UCHAR (SER_MCR(BaseAddress), mcr);
-
-        return (found);
-}
-
-
-/* FUNCTIONS ****************************************************************/
-
-/* HAL.KdPortInitialize */
-BOOLEAN
-STDCALL
-KdPortInitialize (
-	PKD_PORT_INFORMATION	PortInformation,
-	DWORD	Unknown1,
-	DWORD	Unknown2
-	)
-{
-        ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
-        char buffer[80];
-        ULONG divisor;
-        BYTE lcr;
-
-        if (PortInitialized == FALSE)
-        {
-                if (PortInformation->BaudRate != 0)
-                {
-                        BaudRate = PortInformation->BaudRate;
-                }
-                else
-                {
-                        BaudRate = DEFAULT_BAUD_RATE;
-                }
-
-                if (PortInformation->ComPort == 0)
-                {
-                        if (KdpDoesComPortExist ((PUCHAR)BaseArray[2]))
-                        {
-                                PortBase = (PUCHAR)BaseArray[2];
-                                ComPort = 2;
-                                PortInformation->BaseAddress = (ULONG)PortBase;
-                                PortInformation->ComPort = ComPort;
-#ifndef NDEBUG
-                                sprintf (buffer,
-                                         "\nSerial port COM%ld found at 0x%lx\n",
-                                         ComPort,
-                                         (ULONG)PortBase);
-                                HalDisplayString (buffer);
-#endif /* NDEBUG */
-                        }
-                        else if (KdpDoesComPortExist ((PUCHAR)BaseArray[1]))
-                        {
-                                PortBase = (PUCHAR)BaseArray[1];
-                                ComPort = 1;
-                                PortInformation->BaseAddress = (ULONG)PortBase;
-                                PortInformation->ComPort = ComPort;
-#ifndef NDEBUG
-                                sprintf (buffer,
-                                         "\nSerial port COM%ld found at 0x%lx\n",
-                                         ComPort,
-                                         (ULONG)PortBase);
-                                HalDisplayString (buffer);
-#endif /* NDEBUG */
-                        }
-                        else
-                        {
-                                sprintf (buffer,
-                                         "\nKernel Debugger: No COM port found!!!\n\n");
-                                HalDisplayString (buffer);
-                                return FALSE;
-                        }
-                }
-                else
-                {
-                        if (KdpDoesComPortExist ((PUCHAR)BaseArray[PortInformation->ComPort]))
-                        {
-                                PortBase = (PUCHAR)BaseArray[PortInformation->ComPort];
-                                ComPort = PortInformation->ComPort;
-                                PortInformation->BaseAddress = (ULONG)PortBase;
-#ifndef NDEBUG
-                                sprintf (buffer,
-                                         "\nSerial port COM%ld found at 0x%lx\n",
-                                         ComPort,
-                                         (ULONG)PortBase);
-                                HalDisplayString (buffer);
-#endif /* NDEBUG */
-                        }
-                        else
-                        {
-                                sprintf (buffer,
-                                         "\nKernel Debugger: No serial port found!!!\n\n");
-                                HalDisplayString (buffer);
-                                return FALSE;
-                        }
-                }
-
-                PortInitialized = TRUE;
-        }
-
-        /*
-         * set baud rate and data format (8N1)
-         */
-
-        /*  turn on DTR and RTS  */
-        WRITE_PORT_UCHAR (SER_MCR(PortBase), SR_MCR_DTR | SR_MCR_RTS);
-
-        /* set DLAB */
-        lcr = READ_PORT_UCHAR (SER_LCR(PortBase)) | SR_LCR_DLAB;
-        WRITE_PORT_UCHAR (SER_LCR(PortBase), lcr);
-
-        /* set baud rate */
-        divisor = 115200 / BaudRate;
-        WRITE_PORT_UCHAR (SER_DLL(PortBase), (UCHAR)(divisor & 0xff));
-        WRITE_PORT_UCHAR (SER_DLM(PortBase), (UCHAR)((divisor >> 8) & 0xff));
-
-        /* reset DLAB and set 8N1 format */
-        WRITE_PORT_UCHAR (SER_LCR(PortBase),
-                          SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO);
-
-        /* read junk out of the RBR */
-        lcr = READ_PORT_UCHAR (SER_RBR(PortBase));
-
-        /*
-         * set global info
-         */
-        KdComPortInUse = (ULONG)PortBase;
-
-        /*
-         * print message to blue screen
-         */
-        sprintf (buffer,
-                 "\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
-                 ComPort,
-                 (ULONG)PortBase,
-                 BaudRate);
-
-        HalDisplayString (buffer);
-
-        return TRUE;
-}
-
-
-/* HAL.KdPortInitializeEx */
-BOOLEAN
-STDCALL
-KdPortInitializeEx (
-	PKD_PORT_INFORMATION	PortInformation,
-	DWORD	Unknown1,
-	DWORD	Unknown2
-	)
-{
-        ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
-		PUCHAR ComPortBase;
-        char buffer[80];
-        ULONG divisor;
-        BYTE lcr;
-
-		if (PortInformation->BaudRate == 0)
-		{
-				PortInformation->BaudRate = DEFAULT_BAUD_RATE;
-		}
-
-		if (PortInformation->ComPort == 0)
-		{
-				return FALSE;
-		}
-		else
-		{
-				if (KdpDoesComPortExist ((PUCHAR)BaseArray[PortInformation->ComPort]))
-				{
-						ComPortBase = (PUCHAR)BaseArray[PortInformation->ComPort];
-						PortInformation->BaseAddress = (ULONG)ComPortBase;
-#ifndef NDEBUG
-						sprintf (buffer,
-								 "\nSerial port COM%ld found at 0x%lx\n",
-								 PortInformation->ComPort,
-								 (ULONG)ComPortBase];
-						HalDisplayString (buffer);
-#endif /* NDEBUG */
-				}
-				else
-				{
-						sprintf (buffer,
-								 "\nKernel Debugger: Serial port not found!!!\n\n");
-						HalDisplayString (buffer);
-						return FALSE;
-				}
-		}
-
-        /*
-         * set baud rate and data format (8N1)
-         */
-
-        /*  turn on DTR and RTS  */
-        WRITE_PORT_UCHAR (SER_MCR(ComPortBase), SR_MCR_DTR | SR_MCR_RTS);
-
-        /* set DLAB */
-        lcr = READ_PORT_UCHAR (SER_LCR(ComPortBase)) | SR_LCR_DLAB;
-        WRITE_PORT_UCHAR (SER_LCR(ComPortBase), lcr);
-
-        /* set baud rate */
-        divisor = 115200 / PortInformation->BaudRate;
-        WRITE_PORT_UCHAR (SER_DLL(ComPortBase), (UCHAR)(divisor & 0xff));
-        WRITE_PORT_UCHAR (SER_DLM(ComPortBase), (UCHAR)((divisor >> 8) & 0xff));
-
-        /* reset DLAB and set 8N1 format */
-        WRITE_PORT_UCHAR (SER_LCR(ComPortBase),
-                          SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO);
-
-        /* read junk out of the RBR */
-        lcr = READ_PORT_UCHAR (SER_RBR(ComPortBase));
-
-#ifndef NDEBUG
-
-        /*
-         * print message to blue screen
-         */
-        sprintf (buffer,
-                 "\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
-                 PortInformation->ComPort,
-                 (ULONG)ComPortBase,
-                 PortInformation->BaudRate);
-
-        HalDisplayString (buffer);
-
-#endif /* NDEBUG */
-
-        return TRUE;
-}
-
-
-/* HAL.KdPortGetByte */
-BOOLEAN
-STDCALL
-KdPortGetByte (
-	PUCHAR	ByteRecieved
-	)
-{
-	if (PortInitialized == FALSE)
-		return FALSE;
-
-	if ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR))
-	{
-		*ByteRecieved = READ_PORT_UCHAR (SER_RBR(PortBase));
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-
-/* HAL.KdPortGetByteEx */
-BOOLEAN
-STDCALL
-KdPortGetByteEx (
-	PKD_PORT_INFORMATION	PortInformation,
-	PUCHAR	ByteRecieved
-	)
-{
-	PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
-
-	if ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR))
-	{
-		*ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase));
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-
-/* HAL.KdPortPollByte */
-BOOLEAN
-STDCALL
-KdPortPollByte (
-	PUCHAR	ByteRecieved
-	)
-{
-	if (PortInitialized == FALSE)
-		return FALSE;
-
-	while ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR) == 0)
-		;
-
-	*ByteRecieved = READ_PORT_UCHAR (SER_RBR(PortBase));
-
-	return TRUE;
-}
-
-
-/* HAL.KdPortPollByteEx */
-BOOLEAN
-STDCALL
-KdPortPollByteEx (
-	PKD_PORT_INFORMATION	PortInformation,
-	PUCHAR	ByteRecieved
-	)
-{
-	PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
-
-	while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_DR) == 0)
-		;
-
-	*ByteRecieved = READ_PORT_UCHAR (SER_RBR(ComPortBase));
-
-	return TRUE;
-}
-
-
-
-
-/* HAL.KdPortPutByte */
-VOID
-STDCALL
-KdPortPutByte (
-	UCHAR ByteToSend
-	)
-{
-	if (PortInitialized == FALSE)
-		return;
-
-	while ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_TBE) == 0)
-		;
-
-	WRITE_PORT_UCHAR (SER_THR(PortBase), ByteToSend);
-}
-
-/* HAL.KdPortPutByteEx */
-VOID
-STDCALL
-KdPortPutByteEx (
-	PKD_PORT_INFORMATION	PortInformation,
-	UCHAR ByteToSend
-	)
-{
-	PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
-
-	while ((READ_PORT_UCHAR (SER_LSR(ComPortBase)) & SR_LSR_TBE) == 0)
-		;
-
-	WRITE_PORT_UCHAR (SER_THR(ComPortBase), ByteToSend);
-}
-
-
-/* HAL.KdPortRestore */
-VOID
-STDCALL
-KdPortRestore (
-	VOID
-	)
-{
-}
-
-
-/* HAL.KdPortSave */
-VOID
-STDCALL
-KdPortSave (
-	VOID
-	)
-{
-}
-
-
-/* HAL.KdPortDisableInterrupts */
-BOOLEAN
-STDCALL
-KdPortDisableInterrupts()
-{
-  UCHAR ch;
-
-	if (PortInitialized == FALSE)
-		return FALSE;
-
-	ch = READ_PORT_UCHAR (SER_MCR (PortBase));
-  ch &= (~(SR_MCR_OUT1 | SR_MCR_OUT2));
-	WRITE_PORT_UCHAR (SER_MCR (PortBase), ch);
-
-	ch = READ_PORT_UCHAR (SER_IER (PortBase));
-  ch &= (~SR_IER_ALL);
-	WRITE_PORT_UCHAR (SER_IER (PortBase), ch);
-
-	return TRUE;
-}
-
-
-/* HAL.KdPortEnableInterrupts */
-BOOLEAN
-STDCALL
-KdPortEnableInterrupts()
-{
-  UCHAR ch;
-
-	if (PortInitialized == FALSE)
-		return FALSE;
-
-	ch = READ_PORT_UCHAR (SER_IER (PortBase));
-  ch &= (~SR_IER_ALL);
-  ch |= SR_IER_ERDA;
-	WRITE_PORT_UCHAR (SER_IER (PortBase), ch);
-
-	ch = READ_PORT_UCHAR (SER_MCR (PortBase));
-  ch &= (~SR_MCR_LOOP);
-  ch |= (SR_MCR_OUT1 | SR_MCR_OUT2);
-	WRITE_PORT_UCHAR (SER_MCR (PortBase), ch);
-
-	return TRUE;
-}
-
-/* EOF */

reactos/hal/halx86
mca.c removed after 1.3
diff -N mca.c
--- mca.c	28 Dec 2003 22:38:09 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-/*
- *  ReactOS kernel
- *  Copyright (C) 2002 ReactOS Team
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id: mca.c,v 1.3 2003/12/28 22:38:09 fireball Exp $
- *
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS kernel
- * FILE:        hal/halx86/mca.c
- * PURPOSE:     Interfaces to the MicroChannel bus
- * PROGRAMMER:  Eric Kohl (ekohl@rz-online.de)
- */
-
-/*
- * TODO:
- *   What Adapter ID is read from an empty slot?
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <bus.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* FUNCTIONS ****************************************************************/
-
-ULONG STDCALL
-HalpGetMicroChannelData(PBUS_HANDLER BusHandler,
-			ULONG BusNumber,
-			ULONG SlotNumber,
-			PVOID Buffer,
-			ULONG Offset,
-			ULONG Length)
-{
-  PCM_MCA_POS_DATA PosData = (PCM_MCA_POS_DATA)Buffer;
-
-  DPRINT("HalpGetMicroChannelData() called.\n");
-  DPRINT("  BusNumber %lu\n", BusNumber);
-  DPRINT("  SlotNumber %lu\n", SlotNumber);
-  DPRINT("  Offset 0x%lx\n", Offset);
-  DPRINT("  Length 0x%lx\n", Length);
-
-  if ((BusNumber != 0) ||
-      (SlotNumber == 0) || (SlotNumber > 8) ||
-      (Length < sizeof(CM_MCA_POS_DATA)))
-    return(0);
-
-  /* Enter Setup-Mode for given slot */
-  WRITE_PORT_UCHAR((PUCHAR)0x96, (UCHAR)(((UCHAR)(SlotNumber - 1) & 0x07) | 0x08));
-
-  /* Read POS data */
-  PosData->AdapterId = (READ_PORT_UCHAR((PUCHAR)0x101) << 8) +
-			READ_PORT_UCHAR((PUCHAR)0x100);
-  PosData->PosData1 = READ_PORT_UCHAR((PUCHAR)0x102);
-  PosData->PosData2 = READ_PORT_UCHAR((PUCHAR)0x103);
-  PosData->PosData3 = READ_PORT_UCHAR((PUCHAR)0x104);
-  PosData->PosData4 = READ_PORT_UCHAR((PUCHAR)0x105);
-
-  /* Leave Setup-Mode for given slot */
-  WRITE_PORT_UCHAR((PUCHAR)0x96, (UCHAR)((UCHAR)(SlotNumber - 1) & 0x07));
-
-  return(sizeof(CM_MCA_POS_DATA));
-}
-
-/* EOF */

reactos/hal/halx86
mpsboot.asm removed after 1.1
diff -N mpsboot.asm
--- mpsboot.asm	21 Aug 2001 20:18:27 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-;
-; COPYRIGHT:       See COPYING in the top level directory
-; PROJECT:         ReactOS kernel
-; FILE:            ntoskrnl/hal/x86/mpsboot.c
-; PURPOSE:         Bootstrap code for application processors
-; PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
-; UPDATE HISTORY:
-;                  Created 12/04/2001
-;
-
-;
-; Memory map at this stage is:
-;     0x2000  Location of our stack
-;     0x3000  Startup code for the APs (this code)
-;
-
-;
-; Base address of common area for BSP and APs
-;
-LOAD_BASE   equ 00200000h
-
-;
-; Magic value to be put in EAX when multiboot.S is called as part of the
-; application processor initialization process
-;
-AP_MAGIC    equ 12481020h
-
-;
-; Segment selectors
-;
-%define KERNEL_CS     (0x8)
-%define KERNEL_DS     (0x10)
-
-section .text
-
-global _APstart
-global _APend
-
-; 16 bit code
-BITS 16
-
-_APstart:
-	cli		; Just in case
-
-  xor   ax, ax
-	mov		ds, ax
-	mov		ss, ax
-
-  mov   eax, 3000h + APgdt - _APstart
-	lgdt  [eax]
-
-  mov   eax, cr0
-  or    eax, 00010001h    ; Turn on protected mode and write protection
-  mov   cr0, eax
-
-  db    0eah
-  dw    3000h + flush - _APstart, KERNEL_CS
-
-; 32 bit code
-BITS 32
-
-flush:
-  mov   ax, KERNEL_DS
-  mov		ds, ax
-  mov		es, ax
-  mov		fs, ax
-  mov		gs, ax
-  mov		ss, ax
-
-  ; Setup a stack for the AP
-  mov   eax, 2000h
-  mov   eax, [eax]
-  mov   esp, eax
-
-  ; Jump to start of the kernel with AP magic in eax
-  mov      eax, AP_MAGIC
-  jmp      dword KERNEL_CS:(LOAD_BASE + 0x1000)
-
-  ; Never get here
-
-
-; Temporary GDT descriptor for the APs
-
-APgdt:
-; Limit
-  dw  (3*8)-1
-; Base
-  dd	3000h + gdt - _APstart
-
-gdt:
-  dw	0x0       ; Null descriptor
-  dw	0x0
-  dw	0x0
-  dw	0x0
-
-  dw	0xffff    ; Kernel code descriptor
-  dw	0x0000
-  dw	0x9a00
-  dw	0x00cf
-
-  dw	0xffff    ;  Kernel data descriptor
-  dw	0x0000
-  dw	0x9200
-  dw	0x00cf
-
-_APend:

reactos/hal/halx86
pci.c removed after 1.14
diff -N pci.c
--- pci.c	15 Nov 2004 09:18:19 -0000	1.14
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,804 +0,0 @@
-/* $Id: pci.c,v 1.14 2004/11/15 09:18:19 ekohl Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/pci.c
- * PURPOSE:         Interfaces to the PCI bus
- * PROGRAMMER:      David Welch (welch@mcmail.com)
- *                  Eric Kohl (ekohl@rz-online.de)
- * UPDATE HISTORY:
- *                  05/06/1998: Created
- *                  17/08/2000: Added preliminary pci bus scanner
- *                  13/06/2001: Implemented access to pci configuration space
- */
-
-/*
- * NOTES: Sections copied from the Linux pci support
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <roscfg.h>
-#include <ddk/ntddk.h>
-#include <bus.h>
-#include <halirq.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* MACROS ******************************************************************/
-
-/* FIXME These are also defined in drivers/bus/pci/pcidef.h.
-   Maybe put PCI definitions in a central include file??? */
-
-/* access type 1 macros */
-#define CONFIG_CMD(bus, dev_fn, where) \
-	(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
-
-/* access type 2 macros */
-#define IOADDR(dev_fn, where) \
-	(0xC000 | (((dev_fn) & 0x1F) << 8) | (where))
-#define FUNC(dev_fn) \
-	((((dev_fn) & 0xE0) >> 4) | 0xf0)
-
-#define  PCI_BASE_ADDRESS_SPACE	0x01	/* 0 = memory, 1 = I/O */
-#define  PCI_BASE_ADDRESS_SPACE_IO 0x01
-#define  PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
-#define  PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
-#define  PCI_BASE_ADDRESS_MEM_TYPE_32	0x00	/* 32 bit address */
-#define  PCI_BASE_ADDRESS_MEM_TYPE_1M	0x02	/* Below 1M [obsolete] */
-#define  PCI_BASE_ADDRESS_MEM_TYPE_64	0x04	/* 64 bit address */
-#define  PCI_BASE_ADDRESS_MEM_PREFETCH	0x08	/* prefetchable? */
-#define  PCI_BASE_ADDRESS_MEM_MASK	(~0x0fUL)
-#define  PCI_BASE_ADDRESS_IO_MASK	(~0x03UL)
-/* bit 1 is reserved if address_space = 1 */
-
-
-/* GLOBALS ******************************************************************/
-
-#define TAG_PCI  TAG('P', 'C', 'I', 'H')
-
-static ULONG BusConfigType = 0;  /* undetermined config type */
-static KSPIN_LOCK PciLock;
-
-/* FUNCTIONS ****************************************************************/
-
-static NTSTATUS
-ReadPciConfigUchar(UCHAR Bus,
-		   UCHAR Slot,
-		   UCHAR Offset,
-		   PUCHAR Value)
-{
-   KIRQL oldIrql;
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	*Value = READ_PORT_UCHAR((PUCHAR)0xCFC + (Offset & 3));
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	*Value = READ_PORT_UCHAR((PUCHAR)(IOADDR(Slot, Offset)));
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS
-ReadPciConfigUshort(UCHAR Bus,
-		    UCHAR Slot,
-		    UCHAR Offset,
-		    PUSHORT Value)
-{
-   KIRQL oldIrql;
-
-   if ((Offset & 1) != 0)
-     {
-	return STATUS_INVALID_PARAMETER;
-     }
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	*Value = READ_PORT_USHORT((PUSHORT)0xCFC + (Offset & 2));
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	*Value = READ_PORT_USHORT((PUSHORT)(IOADDR(Slot, Offset)));
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS
-ReadPciConfigUlong(UCHAR Bus,
-		   UCHAR Slot,
-		   UCHAR Offset,
-		   PULONG Value)
-{
-   KIRQL oldIrql;
-
-   if ((Offset & 3) != 0)
-     {
-	return STATUS_INVALID_PARAMETER;
-     }
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	*Value = READ_PORT_ULONG((PULONG)0xCFC);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	*Value = READ_PORT_ULONG((PULONG)(IOADDR(Slot, Offset)));
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS
-WritePciConfigUchar(UCHAR Bus,
-		    UCHAR Slot,
-		    UCHAR Offset,
-		    UCHAR Value)
-{
-   KIRQL oldIrql;
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFC + (Offset&3), Value);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	WRITE_PORT_UCHAR((PUCHAR)(IOADDR(Slot,Offset)), Value);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS
-WritePciConfigUshort(UCHAR Bus,
-		     UCHAR Slot,
-		     UCHAR Offset,
-		     USHORT Value)
-{
-   KIRQL oldIrql;
-
-   if ((Offset & 1) != 0)
-     {
-	return  STATUS_INVALID_PARAMETER;
-     }
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	WRITE_PORT_USHORT((PUSHORT)0xCFC + (Offset & 2), Value);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	WRITE_PORT_USHORT((PUSHORT)(IOADDR(Slot, Offset)), Value);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static NTSTATUS
-WritePciConfigUlong(UCHAR Bus,
-		    UCHAR Slot,
-		    UCHAR Offset,
-		    ULONG Value)
-{
-   KIRQL oldIrql;
-
-   if ((Offset & 3) != 0)
-     {
-	return  STATUS_INVALID_PARAMETER;
-     }
-
-   switch (BusConfigType)
-     {
-     case 1:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(Bus, Slot, Offset));
-	WRITE_PORT_ULONG((PULONG)0xCFC, Value);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-
-     case 2:
-        KeAcquireSpinLock(&PciLock, &oldIrql);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, (UCHAR)FUNC(Slot));
-	WRITE_PORT_UCHAR((PUCHAR)0xCFA, Bus);
-	WRITE_PORT_ULONG((PULONG)(IOADDR(Slot, Offset)), Value);
-	WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	return STATUS_SUCCESS;
-     }
-   return STATUS_UNSUCCESSFUL;
-}
-
-
-static ULONG STDCALL
-HalpGetPciData(PBUS_HANDLER BusHandler,
-	       ULONG BusNumber,
-	       ULONG SlotNumber,
-	       PVOID Buffer,
-	       ULONG Offset,
-	       ULONG Length)
-{
-   PVOID Ptr = Buffer;
-   ULONG Address = Offset;
-   ULONG Len = Length;
-   ULONG Vendor;
-   UCHAR HeaderType;
-
-   DPRINT("HalpGetPciData() called.\n");
-   DPRINT("  BusNumber %lu\n", BusNumber);
-   DPRINT("  SlotNumber %lu\n", SlotNumber);
-   DPRINT("  Offset 0x%lx\n", Offset);
-   DPRINT("  Length 0x%lx\n", Length);
-
-   if ((Length == 0) || (BusConfigType == 0))
-     return 0;
-
-   ReadPciConfigUlong((UCHAR)BusNumber,
-		      (UCHAR)(SlotNumber & 0x1F),
-		      0x00,
-		      &Vendor);
-   /* some broken boards return 0 if a slot is empty: */
-   if (Vendor == 0xFFFFFFFF || Vendor == 0)
-   {
-     if (BusNumber == 0 && Offset == 0 && Length >= 2)
-     {
-	*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
-	return 2;
-     }
-     return 0;
-   }
-
-   /* 0E=PCI_HEADER_TYPE */
-   ReadPciConfigUchar((UCHAR)BusNumber,
-		      (UCHAR)(SlotNumber & 0x1F),
-		      0x0E,
-		      &HeaderType);
-   if (((HeaderType & PCI_MULTIFUNCTION) == 0) && ((SlotNumber & 0xE0) != 0))
-   {
-     if (Offset == 0 && Length >= 2)
-     {
-	*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
-	return 2;
-     }
-     return 0;
-   }
-   ReadPciConfigUlong((UCHAR)BusNumber,
-		      (UCHAR)SlotNumber,
-		      0x00,
-		      &Vendor);
-   /* some broken boards return 0 if a slot is empty: */
-   if (Vendor == 0xFFFFFFFF || Vendor == 0)
-   {
-     if (BusNumber == 0 && Offset == 0 && Length >= 2)
-     {
-	*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
-	return 2;
-     }
-     return 0;
-   }
-
-   if ((Address & 1) && (Len >= 1))
-     {
-	ReadPciConfigUchar((UCHAR)BusNumber,
-			   (UCHAR)SlotNumber,
-			   (UCHAR)Address,
-			   Ptr);
-	Ptr = (char*)Ptr + 1;
-	Address++;
-	Len--;
-     }
-
-   if ((Address & 2) && (Len >= 2))
-     {
-	ReadPciConfigUshort((UCHAR)BusNumber,
-			    (UCHAR)SlotNumber,
-			    (UCHAR)Address,
-			    Ptr);
-	Ptr = (char*)Ptr + 2;
-	Address += 2;
-	Len -= 2;
-     }
-
-   while (Len >= 4)
-     {
-	ReadPciConfigUlong((UCHAR)BusNumber,
-			   (UCHAR)SlotNumber,
-			   (UCHAR)Address,
-			   Ptr);
-	Ptr = (char*)Ptr + 4;
-	Address += 4;
-	Len -= 4;
-     }
-
-   if (Len >= 2)
-     {
-	ReadPciConfigUshort((UCHAR)BusNumber,
-			    (UCHAR)SlotNumber,
-			    (UCHAR)Address,
-			    Ptr);
-	Ptr = (char*)Ptr + 2;
-	Address += 2;
-	Len -= 2;
-     }
-
-   if (Len >= 1)
-     {
-	ReadPciConfigUchar((UCHAR)BusNumber,
-			   (UCHAR)SlotNumber,
-			   (UCHAR)Address,
-			   Ptr);
-	Ptr = (char*)Ptr + 1;
-	Address++;
-	Len--;
-     }
-
-   return Length - Len;
-}
-
-
-static ULONG STDCALL
-HalpSetPciData(PBUS_HANDLER BusHandler,
-	       ULONG BusNumber,
-	       ULONG SlotNumber,
-	       PVOID Buffer,
-	       ULONG Offset,
-	       ULONG Length)
-{
-   PVOID Ptr = Buffer;
-   ULONG Address = Offset;
-   ULONG Len = Length;
-   ULONG Vendor;
-   UCHAR HeaderType;
-
-   DPRINT("HalpSetPciData() called.\n");
-   DPRINT("  BusNumber %lu\n", BusNumber);
-   DPRINT("  SlotNumber %lu\n", SlotNumber);
-   DPRINT("  Offset 0x%lx\n", Offset);
-   DPRINT("  Length 0x%lx\n", Length);
-
-   if ((Length == 0) || (BusConfigType == 0))
-     return 0;
-
-   ReadPciConfigUlong((UCHAR)BusNumber,
-		      (UCHAR)(SlotNumber & 0x1F),
-		      0x00,
-		      &Vendor);
-   /* some broken boards return 0 if a slot is empty: */
-   if (Vendor == 0xFFFFFFFF || Vendor == 0)
-     return 0;
-
-
-   /* 0E=PCI_HEADER_TYPE */
-   ReadPciConfigUchar((UCHAR)BusNumber,
-		      (UCHAR)(SlotNumber & 0x1F),
-		      0x0E,
-		      &HeaderType);
-   if (((HeaderType & PCI_MULTIFUNCTION) == 0) && ((SlotNumber & 0xE0) != 0))
-     return 0;
-
-   ReadPciConfigUlong((UCHAR)BusNumber,
-		      (UCHAR)SlotNumber,
-		      0x00,
-		      &Vendor);
-   /* some broken boards return 0 if a slot is empty: */
-   if (Vendor == 0xFFFFFFFF || Vendor == 0)
-     return 0;
-
-   if ((Address & 1) && (Len >= 1))
-     {
-	WritePciConfigUchar((UCHAR)BusNumber,
-			    (UCHAR)SlotNumber,
-			    (UCHAR)Address,
-			    *(PUCHAR)Ptr);
-	Ptr = (char*)Ptr + 1;
-	Address++;
-	Len--;
-     }
-
-   if ((Address & 2) && (Len >= 2))
-     {
-	WritePciConfigUshort((UCHAR)BusNumber,
-			     (UCHAR)SlotNumber,
-			     (UCHAR)Address,
-			     *(PUSHORT)Ptr);
-	Ptr = (char*)Ptr + 2;
-	Address += 2;
-	Len -= 2;
-     }
-
-   while (Len >= 4)
-     {
-	WritePciConfigUlong((UCHAR)BusNumber,
-			    (UCHAR)SlotNumber,
-			    (UCHAR)Address,
-			    *(PULONG)Ptr);
-	Ptr = (char*)Ptr + 4;
-	Address += 4;
-	Len -= 4;
-     }
-
-   if (Len >= 2)
-     {
-	WritePciConfigUshort((UCHAR)BusNumber,
-			     (UCHAR)SlotNumber,
-			     (UCHAR)Address,
-			     *(PUSHORT)Ptr);
-	Ptr = (char*)Ptr + 2;
-	Address += 2;
-	Len -= 2;
-     }
-
-   if (Len >= 1)
-     {
-	WritePciConfigUchar((UCHAR)BusNumber,
-			    (UCHAR)SlotNumber,
-			    (UCHAR)Address,
-			    *(PUCHAR)Ptr);
-	Ptr = (char*)Ptr + 1;
-	Address++;
-	Len--;
-     }
-
-   return Length - Len;
-}
-
-
-static ULONG
-GetBusConfigType(VOID)
-{
-   ULONG Value;
-   KIRQL oldIrql;
-
-   DPRINT("GetBusConfigType() called\n");
-
-   KeAcquireSpinLock(&PciLock, &oldIrql);
- 
-   DPRINT("Checking configuration type 1:");
-   WRITE_PORT_UCHAR((PUCHAR)0xCFB, 0x01);
-   Value = READ_PORT_ULONG((PULONG)0xCF8);
-   WRITE_PORT_ULONG((PULONG)0xCF8, 0x80000000);
-   if (READ_PORT_ULONG((PULONG)0xCF8) == 0x80000000)
-     {
-	WRITE_PORT_ULONG((PULONG)0xCF8, Value);
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	DPRINT("  Success!\n");
-	return 1;
-     }
-   WRITE_PORT_ULONG((PULONG)0xCF8, Value);
-   DPRINT("  Unsuccessful!\n");
-
-   DPRINT("Checking configuration type 2:");
-   WRITE_PORT_UCHAR((PUCHAR)0xCFB, 0x00);
-   WRITE_PORT_UCHAR((PUCHAR)0xCF8, 0x00);
-   WRITE_PORT_UCHAR((PUCHAR)0xCFA, 0x00);
-   if (READ_PORT_UCHAR((PUCHAR)0xCF8) == 0x00 &&
-       READ_PORT_UCHAR((PUCHAR)0xCFB) == 0x00)
-     {
-	KeReleaseSpinLock(&PciLock, oldIrql);
-	DPRINT("  Success!\n");
-	return 2;
-     }
-   KeReleaseSpinLock(&PciLock, oldIrql);
-   DPRINT("  Unsuccessful!\n");
-
-   DPRINT("No pci bus found!\n");
-   return 0;
-}
-
-
-static ULONG STDCALL
-HalpGetPciInterruptVector(PVOID BusHandler,
-			  ULONG BusNumber,
-			  ULONG BusInterruptLevel,
-			  ULONG BusInterruptVector,
-			  PKIRQL Irql,
-			  PKAFFINITY Affinity)
-{
-  ULONG Vector = IRQ2VECTOR(BusInterruptVector);
-  *Irql = VECTOR2IRQL(Vector);
-  *Affinity = 0xFFFFFFFF;
-  return Vector;
-}
-
-static BOOLEAN STDCALL
-HalpTranslatePciAddress(PBUS_HANDLER BusHandler,
-			ULONG BusNumber,
-			PHYSICAL_ADDRESS BusAddress,
-			PULONG AddressSpace,
-			PPHYSICAL_ADDRESS TranslatedAddress)
-{
-   if (*AddressSpace == 0)
-     {
-	/* memory space */
-
-     }
-   else if (*AddressSpace == 1)
-     {
-	/* io space */
-
-     }
-   else
-     {
-	/* other */
-	return FALSE;
-     }
-
-   TranslatedAddress->QuadPart = BusAddress.QuadPart;
-
-   return TRUE;
-}
-
-/*
- * Find the extent of a PCI decode..
- */
-static ULONG STDCALL
-PciSize(ULONG Base, ULONG Mask)
-{
-  ULONG Size = Mask & Base;   /* Find the significant bits */
-  Size = Size & ~(Size - 1);  /* Get the lowest of them to find the decode size */
-  return Size;
-}
-
-static NTSTATUS STDCALL
-HalpAssignPciSlotResources(IN PBUS_HANDLER BusHandler,
-			   IN ULONG BusNumber,
-			   IN PUNICODE_STRING RegistryPath,
-			   IN PUNICODE_STRING DriverClassName,
-			   IN PDRIVER_OBJECT DriverObject,
-			   IN PDEVICE_OBJECT DeviceObject,
-			   IN ULONG SlotNumber,
-			   IN OUT PCM_RESOURCE_LIST *AllocatedResources)
-{
-  ULONG DataSize;
-  PCI_COMMON_CONFIG PciConfig;
-  UINT Address;
-  UINT ResourceCount;
-  ULONG Size[PCI_TYPE0_ADDRESSES];
-  NTSTATUS Status = STATUS_SUCCESS;
-  UCHAR Offset;
-  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
-
-  /* FIXME: Should handle 64-bit addresses */
-
-  DataSize = HalpGetPciData(BusHandler,
-                            BusNumber,
-                            SlotNumber,
-                            &PciConfig,
-                            0,
-                            PCI_COMMON_HDR_LENGTH);
-  if (PCI_COMMON_HDR_LENGTH != DataSize)
-    {
-      return STATUS_UNSUCCESSFUL;
-    }
-
-  /* Read the PCI configuration space for the device and store base address and
-     size information in temporary storage. Count the number of valid base addresses */
-  ResourceCount = 0;
-  for (Address = 0; Address < PCI_TYPE0_ADDRESSES; Address++)
-    {
-      if (0xffffffff == PciConfig.u.type0.BaseAddresses[Address])
-	{
-	  PciConfig.u.type0.BaseAddresses[Address] = 0;
-	}
-      if (0 != PciConfig.u.type0.BaseAddresses[Address])
-	{
-	  ResourceCount++;
-          Offset = offsetof(PCI_COMMON_CONFIG, u.type0.BaseAddresses[Address]);
-	  Status = WritePciConfigUlong((UCHAR)BusNumber, (UCHAR)SlotNumber, Offset, 0xffffffff);
-	  if (! NT_SUCCESS(Status))
-	    {
-	      WritePciConfigUlong((UCHAR)BusNumber, (UCHAR)SlotNumber, Offset,
-                                  PciConfig.u.type0.BaseAddresses[Address]);
-	      return Status;
-	    }
-	  Status = ReadPciConfigUlong((UCHAR)BusNumber, (UCHAR)SlotNumber,
-	                              Offset, Size + Address);
-	  if (! NT_SUCCESS(Status))
-	    {
-	      WritePciConfigUlong((UCHAR)BusNumber, (UCHAR)SlotNumber, Offset,
-                                  PciConfig.u.type0.BaseAddresses[Address]);
-	      return Status;
-	    }
-	  Status = WritePciConfigUlong((UCHAR)BusNumber, (UCHAR)SlotNumber, Offset,
-                                       PciConfig.u.type0.BaseAddresses[Address]);
-	  if (! NT_SUCCESS(Status))
-	    {
-	      return Status;
-	    }
-	}
-    }
-
-  if (0 != PciConfig.u.type0.InterruptLine)
-    {
-      ResourceCount++;
-    }
-
-  /* Allocate output buffer and initialize */
-  *AllocatedResources = ExAllocatePoolWithTag(PagedPool,
-                                              sizeof(CM_RESOURCE_LIST) +
-                                              (ResourceCount - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR),
-                                              TAG_PCI);
-  if (NULL == *AllocatedResources)
-    {
-      return STATUS_NO_MEMORY;
-    }
-  (*AllocatedResources)->Count = 1;
-  (*AllocatedResources)->List[0].InterfaceType = PCIBus;
-  (*AllocatedResources)->List[0].BusNumber = BusNumber;
-  (*AllocatedResources)->List[0].PartialResourceList.Version = 1;
-  (*AllocatedResources)->List[0].PartialResourceList.Revision = 1;
-  (*AllocatedResources)->List[0].PartialResourceList.Count = ResourceCount;
-  Descriptor = (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors;
-
-  /* Store configuration information */
-  for (Address = 0; Address < PCI_TYPE0_ADDRESSES; Address++)
-    {
-      if (0 != PciConfig.u.type0.BaseAddresses[Address])
-	{
-	  if (PCI_BASE_ADDRESS_SPACE_MEMORY ==
-              (PciConfig.u.type0.BaseAddresses[Address] & PCI_BASE_ADDRESS_SPACE))
-	    {
-	      Descriptor->Type = CmResourceTypeMemory;
-	      Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
-	      Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;             /* FIXME Just a guess */
-	      Descriptor->u.Memory.Start.QuadPart = (PciConfig.u.type0.BaseAddresses[Address] & PCI_BASE_ADDRESS_MEM_MASK);
-	      Descriptor->u.Memory.Length = PciSize(Size[Address], PCI_BASE_ADDRESS_MEM_MASK);
-	    }
-	  else if (PCI_BASE_ADDRESS_SPACE_IO ==
-                   (PciConfig.u.type0.BaseAddresses[Address] & PCI_BASE_ADDRESS_SPACE))
-	    {
-	      Descriptor->Type = CmResourceTypePort;
-	      Descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* FIXME I have no idea... */
-	      Descriptor->Flags = CM_RESOURCE_PORT_IO;                       /* FIXME Just a guess */
-	      Descriptor->u.Port.Start.QuadPart = PciConfig.u.type0.BaseAddresses[Address] &= PCI_BASE_ADDRESS_IO_MASK;
-	      Descriptor->u.Port.Length = PciSize(Size[Address], PCI_BASE_ADDRESS_IO_MASK & 0xffff);
-	    }
-	  else
-	    {
-	      ASSERT(FALSE);
-	      return STATUS_UNSUCCESSFUL;
-	    }
-	  Descriptor++;
-	}
-    }
-
-  if (0 != PciConfig.u.type0.InterruptLine)
-    {
-      Descriptor->Type = CmResourceTypeInterrupt;
-      Descriptor->ShareDisposition = CmResourceShareShared;          /* FIXME Just a guess */
-      Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;     /* FIXME Just a guess */
-      Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
-      Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
-      Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
-
-      Descriptor++;
-    }
-
-  ASSERT(Descriptor == (*AllocatedResources)->List[0].PartialResourceList.PartialDescriptors + ResourceCount);
-
-  /* FIXME: Should store the resources in the registry resource map */
-
-  return Status;
-}
-
-
-VOID
-HalpInitPciBus(VOID)
-{
-  PBUS_HANDLER BusHandler;
-
-  DPRINT("HalpInitPciBus() called.\n");
-
-  KeInitializeSpinLock (&PciLock);
-
-  BusConfigType = GetBusConfigType();
-  if (BusConfigType == 0)
-    return;
-
-  DPRINT("Bus configuration %lu used\n", BusConfigType);
-
-  /* pci bus (bus 0) handler */
-  BusHandler = HalpAllocateBusHandler(PCIBus,
-				      PCIConfiguration,
-				      0);
-  BusHandler->GetBusData = (pGetSetBusData)HalpGetPciData;
-  BusHandler->SetBusData = (pGetSetBusData)HalpSetPciData;
-  BusHandler->GetInterruptVector =
-    (pGetInterruptVector)HalpGetPciInterruptVector;
-  BusHandler->TranslateBusAddress = 
-    (pTranslateBusAddress)HalpTranslatePciAddress;
-//	BusHandler->AdjustResourceList =
-//		(pGetSetBusData)HalpAdjustPciResourceList;
-  BusHandler->AssignSlotResources =
-    (pAssignSlotResources)HalpAssignPciSlotResources;
-
-
-  /* agp bus (bus 1) handler */
-  BusHandler = HalpAllocateBusHandler(PCIBus,
-				      PCIConfiguration,
-				      1);
-  BusHandler->GetBusData = (pGetSetBusData)HalpGetPciData;
-  BusHandler->SetBusData = (pGetSetBusData)HalpSetPciData;
-  BusHandler->GetInterruptVector =
-    (pGetInterruptVector)HalpGetPciInterruptVector;
-  BusHandler->TranslateBusAddress = 
-    (pTranslateBusAddress)HalpTranslatePciAddress;
-//	BusHandler->AdjustResourceList =
-//		(pGetSetBusData)HalpAdjustPciResourceList;
-  BusHandler->AssignSlotResources =
-    (pAssignSlotResources)HalpAssignPciSlotResources;
-
-
-  /* PCI bus (bus 2) handler */
-  BusHandler = HalpAllocateBusHandler(PCIBus,
-				      PCIConfiguration,
-				      2);
-  BusHandler->GetBusData = (pGetSetBusData)HalpGetPciData;
-  BusHandler->SetBusData = (pGetSetBusData)HalpSetPciData;
-  BusHandler->GetInterruptVector =
-    (pGetInterruptVector)HalpGetPciInterruptVector;
-  BusHandler->TranslateBusAddress = 
-    (pTranslateBusAddress)HalpTranslatePciAddress;
-//	BusHandler->AdjustResourceList =
-//		(pGetSetBusData)HalpAdjustPciResourceList;
-  BusHandler->AssignSlotResources =
-    (pAssignSlotResources)HalpAssignPciSlotResources;
-
-  DPRINT("HalpInitPciBus() finished.\n");
-}
-
-/* EOF */

reactos/hal/halx86
portio.c removed after 1.4
diff -N portio.c
--- portio.c	28 Dec 2003 22:38:09 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,342 +0,0 @@
-/* $Id: portio.c,v 1.4 2003/12/28 22:38:09 fireball Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/portio.c
- * PURPOSE:         Port I/O functions
- * PROGRAMMER:      Eric Kohl (ekohl@abo.rhein-zeitung.de)
- * UPDATE HISTORY:
- *                  Created 18/10/99
- */
-
-#include <ddk/ntddk.h>
-
-
-/* FUNCTIONS ****************************************************************/
-
-/*
- * This file contains the definitions for the x86 IO instructions
- * inb/inw/inl/outb/outw/outl and the "string versions" of the same
- * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
- * versions of the single-IO instructions (inb_p/inw_p/..).
- *
- * This file is not meant to be obfuscating: it's just complicated
- * to (a) handle it all in a way that makes gcc able to optimize it
- * as well as possible and (b) trying to avoid writing the same thing
- * over and over again with slight variations and possibly making a
- * mistake somewhere.
- */
-
-/*
- * Thanks to James van Artsdalen for a better timing-fix than
- * the two short jumps: using outb's to a nonexistent port seems
- * to guarantee better timings even on fast machines.
- *
- * On the other hand, I'd like to be sure of a non-existent port:
- * I feel a bit unsafe about using 0x80 (should be safe, though)
- *
- *		Linus
- */
-
-#if defined(__GNUC__)
-
-#ifdef SLOW_IO_BY_JUMPING
-#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
-#else
-#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
-#endif
-
-#elif defined(_MSC_VER)
-
-#ifdef SLOW_IO_BY_JUMPING
-#define __SLOW_DOWN_IO __asm jmp 1f  __asm jmp 1f  1f:
-#else
-#define __SLOW_DOWN_IO __asm out 0x80, al
-#endif
-
-#else
-#error Unknown compiler for inline assembler
-#endif
-
-
-#ifdef REALLY_SLOW_IO
-#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
-#else
-#define SLOW_DOWN_IO __SLOW_DOWN_IO
-#endif
-
-VOID STDCALL
-READ_PORT_BUFFER_UCHAR (PUCHAR Port,
-                        PUCHAR Buffer,
-                        ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; insb\n\t" 
-			 : "=D" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov edi, Buffer
-		mov ecx, Count
-		cld
-		rep ins byte ptr[edi], dx
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-VOID STDCALL
-READ_PORT_BUFFER_USHORT (PUSHORT Port,
-                         PUSHORT Buffer,
-                         ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; insw"
-			 : "=D" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov edi, Buffer
-		mov ecx, Count
-		cld
-		rep ins word ptr[edi], dx
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-VOID STDCALL
-READ_PORT_BUFFER_ULONG (PULONG Port,
-                        PULONG Buffer,
-                        ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; insl"
-			 : "=D" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov edi, Buffer
-		mov ecx, Count
-		cld
-		rep ins dword ptr[edi], dx
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-UCHAR STDCALL
-READ_PORT_UCHAR (PUCHAR Port)
-{
-   UCHAR Value;
-
-#if defined(__GNUC__)
-   __asm__("inb %w1, %0\n\t"
-	   : "=a" (Value)
-	   : "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		in al, dx
-		mov Value, al
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-
-   SLOW_DOWN_IO;
-   return(Value);
-}
-
-USHORT STDCALL
-READ_PORT_USHORT (PUSHORT Port)
-{
-   USHORT Value;
-
-#if defined(__GNUC__)
-   __asm__("inw %w1, %0\n\t"
-	   : "=a" (Value)
-	   : "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		in ax, dx
-		mov Value, ax
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-   SLOW_DOWN_IO;
-   return(Value);
-}
-
-ULONG STDCALL
-READ_PORT_ULONG (PULONG Port)
-{
-   ULONG Value;
-
-#if defined(__GNUC__)
-   __asm__("inl %w1, %0\n\t"
-	   : "=a" (Value)
-	   : "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		in eax, dx
-		mov Value, eax
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-   SLOW_DOWN_IO;
-   return(Value);
-}
-
-VOID STDCALL
-WRITE_PORT_BUFFER_UCHAR (PUCHAR Port,
-                         PUCHAR Buffer,
-                         ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; outsb" 
-			 : "=S" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov esi, Buffer
-		mov ecx, Count
-		cld
-		rep outs
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-VOID STDCALL
-WRITE_PORT_BUFFER_USHORT (PUSHORT Port,
-                          PUSHORT Buffer,
-                          ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; outsw"
-			 : "=S" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov esi, Buffer
-		mov ecx, Count
-		cld
-		rep outsw
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-VOID STDCALL
-WRITE_PORT_BUFFER_ULONG (PULONG Port,
-                         PULONG Buffer,
-                         ULONG Count)
-{
-#if defined(__GNUC__)
-   __asm__ __volatile__ ("cld ; rep ; outsl" 
-			 : "=S" (Buffer), "=c" (Count) 
-			 : "d" (Port),"0" (Buffer),"1" (Count));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov esi, Buffer
-		mov ecx, Count
-		cld
-		rep outsd
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-}
-
-VOID STDCALL
-WRITE_PORT_UCHAR (PUCHAR Port,
-                  UCHAR Value)
-{
-#if defined(__GNUC__)
-   __asm__("outb %0, %w1\n\t"
-	   : 
-	   : "a" (Value),
-	     "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov al, Value
-		out dx,al
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-   SLOW_DOWN_IO;
-}
-
-VOID STDCALL
-WRITE_PORT_USHORT (PUSHORT Port,
-                   USHORT Value)
-{
-#if defined(__GNUC__)
-   __asm__("outw %0, %w1\n\t"
-	   : 
-	   : "a" (Value),
-	     "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov ax, Value
-		out dx,ax
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-   SLOW_DOWN_IO;
-}
-
-VOID STDCALL
-WRITE_PORT_ULONG (PULONG Port,
-                  ULONG Value)
-{
-#if defined(__GNUC__)
-   __asm__("outl %0, %w1\n\t"
-	   : 
-	   : "a" (Value),
-	     "d" (Port));
-#elif defined(_MSC_VER)
-	__asm
-	{
-		mov edx, Port
-		mov eax, Value
-		out dx,eax
-	}
-#else
-#error Unknown compiler for inline assembler
-#endif
-   SLOW_DOWN_IO;
-}
-
-/* EOF */

reactos/hal/halx86
pwroff.c removed after 1.4
diff -N pwroff.c
--- pwroff.c	28 Dec 2003 22:38:09 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,121 +0,0 @@
-/* $Id: pwroff.c,v 1.4 2003/12/28 22:38:09 fireball Exp $
- *
- * FILE       : reactos/hal/x86/apm.c
- * DESCRIPTION: Turn CPU off...
- * PROJECT    : ReactOS Operating System
- * AUTHOR     : D. Lindauer (July 11 1997)
- * NOTE       : This program is public domain
- * REVISIONS  :
- * 	1999-12-26
- */
-
-#define APM_FUNCTION_AVAILABLE	0x5300
-#define APM_FUNCTION_CONNREAL	0x5301
-#define APM_FUNCTION_POWEROFF	0x5307
-#define APM_FUNCTION_ENABLECPU	0x530d
-#define APM_FUNCTION_ENABLEAPM	0x530e
-
-#define APM_DEVICE_BIOS 	0
-#define APM_DEVICE_ALL		1
-
-#define APM_MODE_DISABLE	0
-#define APM_MODE_ENABLE		1
-
-
-
-#if defined(__GNUC__)
-
-nopm	db	'No power management functionality',10,13,'$'
-errmsg	db	'Power management error',10,13,'$'
-wrongver db	'Need APM version 1.1 or better',10,13,'$'
-;
-; Entry point
-;
-go:
-	mov	dx,offset nopm
-	jc	error
-	cmp	ax,101h			; See if version 1.1 or greater
-	mov	dx,offset wrongver
-	jc	error
-	
-	mov	[ver],ax
-	mov	ax,5301h		; Do a real mode connection
-	mov	bx,0			; device = BIOS
-	int	15h
-	jnc	noconerr
-	
-	cmp	ah,2			; Pass if already connected
-	mov	dx,offset errmsg	; else error
-	jnz	error
-noconerr:
-	mov	ax,530eh		; Enable latest version of APM
-	mov	bx,0			; device = BIOS
-	mov	cx,[ver]		; version
-	int	15h
-	mov	dx,offset errmsg
-	jc	error
-	
-	mov	ax,530dh		; Now engage and enable CPU management
-	mov	bx,1			; device = all
-	mov	cx,1			; enable
-	int	15h
-	mov	dx,offset errmsg
-	jc	error
-	
-	mov	ax,530fh
-	mov	bx,1			; device = ALL
-	mov	cx,1			; enable
-	int	15h
-	mov	dx,offset errmsg
-	jc	error
-
-	mov	dx,offset errmsg
-error:
-	call	print
-	mov	ax,4c01h
-	int	21h
-	int 3
-	end start
-
-
-BOOLEAN
-ApmCall (
-	DWORD	Function,
-	DWORD	Device,
-	DWORD	Mode
-	)
-{
-	/* AX <== Function */
-	/* BX <== Device */
-	/* CX <== Mode */
-	__asm__("int 21\n"); /* 0x15 */
-}
-
-#elif defined(_MSC_VER)
-#else
-#error Unknown compiler for inline assembler
-#endif
-
-
-BOOLEAN
-HalPowerOff (VOID)
-{
-	ApmCall (
-		APM_FUNCTION_AVAILABLE,
-		APM_DEVICE_BIOS,
-		0
-		);
-	ApmCall (
-		APM_FUNCTION_ENABLEAPM,
-		);
-	/* Shutdown CPU */
-	ApmCall (
-		APM_FUNCTION_POWEROFF,
-		APM_DEVICE_ALL,
-		3
-		);
-	return TRUE;
-}
-
-
-/* EOF */

reactos/hal/halx86
reboot.c removed after 1.7
diff -N reboot.c
--- reboot.c	20 Jul 2004 21:25:36 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-/* $Id: reboot.c,v 1.7 2004/07/20 21:25:36 hbirr Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/reboot.c
- * PURPOSE:         Reboot functions.
- * PROGRAMMER:      Eric Kohl (ekohl@abo.rhein-zeitung.de)
- * UPDATE HISTORY:
- *                  Created 11/10/99
- */
-
-
-#include <ddk/ntddk.h>
-#include <hal.h>
-
-
-static VOID
-HalReboot (VOID)
-{
-    char data;
-    extern PVOID HalpZeroPageMapping;
-
-    /* enable warm reboot */
-    ((PUCHAR)HalpZeroPageMapping)[0x472] = 0x34;
-    ((PUCHAR)HalpZeroPageMapping)[0x473] = 0x12;
-
-    /* disable interrupts */
-    Ki386DisableInterrupts();
-
-
-    /* disable periodic interrupt (RTC) */
-    WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0b);
-    data = READ_PORT_UCHAR((PUCHAR)0x71);
-    WRITE_PORT_UCHAR((PUCHAR)0x71, (UCHAR)(data & 0xbf));
-
-    /* */
-    WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0a);
-    data = READ_PORT_UCHAR((PUCHAR)0x71);
-    WRITE_PORT_UCHAR((PUCHAR)0x71, (UCHAR)((data & 0xf0) | 0x06));
-
-    /* */
-    WRITE_PORT_UCHAR((PUCHAR)0x70, 0x15);
-
-    /* generate RESET signal via keyboard controller */
-    WRITE_PORT_UCHAR((PUCHAR)0x64, 0xfe);
-
-    /* stop the processor */
-#if 1
-    Ki386HaltProcessor();
-    for(;;);
-#endif   
-}
-
-
-VOID STDCALL
-HalReturnToFirmware (
-	ULONG	Action
-	)
-{
-    if (Action == FIRMWARE_HALT)
-    {
-        DbgPrint ("HalReturnToFirmware called!\n");
-        DbgBreakPoint ();
-    }
-    else if (Action == FIRMWARE_REBOOT)
-    {
-        HalReleaseDisplayOwnership();
-        HalReboot ();
-    }
-}
-
-/* EOF */

reactos/hal/halx86
spinlock.c removed after 1.9
diff -N spinlock.c
--- spinlock.c	22 Oct 2004 20:08:22 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,101 +0,0 @@
-/* $Id: spinlock.c,v 1.9 2004/10/22 20:08:22 ekohl Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/spinlock.c
- * PURPOSE:         Implements spinlocks
- * PROGRAMMER:      David Welch (welch@cwcom.net)
- *                  Eric Kohl (ekohl@rz-online.de)
- * UPDATE HISTORY:
- *                  09/06/2000 Created
- */
-
-/*
- * NOTE: On a uniprocessor machine spinlocks are implemented by raising
- * the irq level
- */
-
-/* INCLUDES ****************************************************************/
-
-#include <ddk/ntddk.h>
-
-#include <internal/debug.h>
-
-/* FUNCTIONS ***************************************************************/
-
-VOID STDCALL
-KeAcquireSpinLock (
-	PKSPIN_LOCK	SpinLock,
-	PKIRQL		OldIrql
-	)
-/*
- * FUNCTION: Acquires a spinlock
- * ARGUMENTS:
- *         SpinLock = Spinlock to acquire
- *         OldIrql (OUT) = Caller supplied storage for the previous irql
- */
-{
-  *OldIrql = KfAcquireSpinLock(SpinLock);
-}
-
-KIRQL FASTCALL
-KeAcquireSpinLockRaiseToSynch (
-	PKSPIN_LOCK	SpinLock
-	)
-{
-  KIRQL OldIrql;
-
-  OldIrql = KfRaiseIrql(SYNCH_LEVEL);
-  KiAcquireSpinLock(SpinLock);
-
-  return OldIrql;
-}
-
-VOID STDCALL
-KeReleaseSpinLock (
-	PKSPIN_LOCK	SpinLock,
-	KIRQL		NewIrql
-	)
-/*
- * FUNCTION: Releases a spinlock
- * ARGUMENTS:
- *        SpinLock = Spinlock to release
- *        NewIrql = Irql level before acquiring the spinlock
- */
-{
-   KfReleaseSpinLock(SpinLock, NewIrql);
-}
-
-KIRQL FASTCALL
-KfAcquireSpinLock (
-	PKSPIN_LOCK	SpinLock
-	)
-{
-   KIRQL OldIrql;
-
-   ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
-   
-   OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
-   KiAcquireSpinLock(SpinLock);
-
-   return OldIrql;
-}
-
-VOID FASTCALL
-KfReleaseSpinLock (
-	PKSPIN_LOCK	SpinLock,
-	KIRQL		NewIrql
-	)
-/*
- * FUNCTION: Releases a spinlock
- * ARGUMENTS:
- *        SpinLock = Spinlock to release
- *        NewIrql = Irql level before acquiring the spinlock
- */
-{
-   ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL || KeGetCurrentIrql() == SYNCH_LEVEL);
-   KiReleaseSpinLock(SpinLock);
-   KfLowerIrql(NewIrql);
-}
-
-/* EOF */

reactos/hal/halx86
sysbus.c removed after 1.7
diff -N sysbus.c
--- sysbus.c	1 Nov 2004 14:37:19 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,70 +0,0 @@
-/* $Id: sysbus.c,v 1.7 2004/11/01 14:37:19 hbirr Exp $
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/sysbus.c
- * PURPOSE:         System bus handler functions
- * PROGRAMMER:      Eric Kohl (ekohl@rz-online.de)
- * UPDATE HISTORY:
- *                  09/04/2000 Created
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <roscfg.h>
-#include <ddk/ntddk.h>
-#include <bus.h>
-#include <halirq.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* FUNCTIONS ****************************************************************/
-
-ULONG STDCALL
-HalpGetSystemInterruptVector(PVOID BusHandler,
-			     ULONG BusNumber,
-			     ULONG BusInterruptLevel,
-			     ULONG BusInterruptVector,
-			     PKIRQL Irql,
-			     PKAFFINITY Affinity)
-{
-  ULONG Vector = IRQ2VECTOR(BusInterruptVector);
-  *Irql = VECTOR2IRQL(Vector);
-  *Affinity = 0xFFFFFFFF;
-  return Vector;
-}
-
-
-BOOLEAN STDCALL
-HalpTranslateSystemBusAddress(PBUS_HANDLER BusHandler,
-			      ULONG BusNumber,
-			      PHYSICAL_ADDRESS BusAddress,
-			      PULONG AddressSpace,
-			      PPHYSICAL_ADDRESS TranslatedAddress)
-{
-   ULONG BaseAddress = 0;
-
-   if (*AddressSpace == 0)
-     {
-	/* memory space */
-
-     }
-   else if (*AddressSpace == 1)
-     {
-	/* io space */
-
-     }
-   else
-     {
-	/* other */
-	return FALSE;
-     }
-
-   TranslatedAddress->QuadPart = BusAddress.QuadPart + BaseAddress;
-
-   return TRUE;
-}
-
-/* EOF */

reactos/hal/halx86
sysinfo.c removed after 1.4
diff -N sysinfo.c
--- sysinfo.c	26 Feb 2003 14:14:03 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/sysinfo.c
- * PURPOSE:         Getting system information
- * PROGRAMMER:      David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- *                  Created 22/05/98
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <hal.h>
-#include <bus.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* FUNCTIONS ****************************************************************/
-
-NTSTATUS STDCALL
-HalpQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass,
-			   IN ULONG BufferSize,
-			   IN OUT PVOID Buffer,
-			   OUT PULONG ReturnedLength)
-{
-  ULONG DataLength;
-  NTSTATUS Status;
-
-  DPRINT1("HalpQuerySystemInformation() called\n");
-
-  *ReturnedLength = 0;
-
-  DataLength = 0;
-
-  switch(InformationClass)
-    {
-#if 0
-      case HalInstalledBusInformation:
-	Status = HalpQueryBusInformation(BufferSize,
-					 Buffer,
-					 ReturnedLength);
-	break;
-#endif
-
-      default:
-	DataLength = 0;
-	Status = STATUS_INVALID_LEVEL;
-	break;
-    }
-
-  if (DataLength != 0)
-    {
-      if (DataLength > BufferSize)
-	DataLength = BufferSize;
-
-//      RtlCopyMemory();
-
-      *ReturnedLength = DataLength;
-    }
-
-  return(Status);
-}
-
-
-#if 0
-NTSTATUS
-HalpSetSystemInformation(VOID)
-{
-   UNIMPLEMENTED;
-}
-#endif
-
-/* EOF */

reactos/hal/halx86
time.c removed after 1.6
diff -N time.c
--- time.c	20 Jul 2004 21:25:36 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,359 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/hal/x86/time.c
- * PURPOSE:         Getting time information
- * UPDATE HISTORY:
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <string.h>
-#include <hal.h>
-#include <bus.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* MACROS and CONSTANTS ******************************************************/
-
-/* macro BCD_INT : convert bcd to int */
-#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
-
-/* macro INT_BCD : convert int to bcd */
-#define INT_BCD(int) (((int / 10) << 4) + (int % 10))
-
-
-#define RTC_REGISTER_A   0x0A
-#define   RTC_REG_A_UIP  0x80  /* Update In Progress bit */
-
-#define RTC_REGISTER_B   0x0B
-
-#define RTC_REGISTER_CENTURY   0x32
-
-/* GLOBALS ******************************************************************/
-
-static KSPIN_LOCK CmosLock = {0};
-
-/* FUNCTIONS *****************************************************************/
-
-
-static UCHAR
-HalpQueryCMOS(UCHAR Reg)
-{
-  UCHAR Val;
-  ULONG Flags;
-
-  Reg |= 0x80;
-
-  /* save flags and disable interrupts */
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
-
-  WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
-  Val = READ_PORT_UCHAR((PUCHAR)0x71);
-  WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
-  
-  /* restore flags */
-  Ki386RestoreFlags(Flags);
-
-  return(Val);
-}
-
-
-static VOID
-HalpSetCMOS(UCHAR Reg,
-	    UCHAR Val)
-{
-  ULONG Flags;
-
-  Reg |= 0x80;
-
-  /* save flags and disable interrupts */
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
-
-  WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
-  WRITE_PORT_UCHAR((PUCHAR)0x71, Val);
-  WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
-  
-  /* restore flags */
-  Ki386RestoreFlags(Flags);
-}
-
-
-static UCHAR
-HalpQueryECMOS(USHORT Reg)
-{
-  UCHAR Val;
-  ULONG Flags;
-
-  /* save flags and disable interrupts */
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
-
-  WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
-  WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
-  Val = READ_PORT_UCHAR((PUCHAR)0x76);
-  
-  /* restore flags */
-  Ki386RestoreFlags(Flags);
-
-  return(Val);
-}
-
-
-static VOID
-HalpSetECMOS(USHORT Reg,
-	     UCHAR Val)
-{
-  ULONG Flags;
-
-  /* save flags and disable interrupts */
-  Ki386SaveFlags(Flags);
-  Ki386DisableInterrupts();
-
-  WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
-  WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
-  WRITE_PORT_UCHAR((PUCHAR)0x76, Val);
-  
-  /* restore flags */
-  Ki386RestoreFlags(Flags);
-}
-
-
-VOID STDCALL
-HalQueryRealTimeClock(PTIME_FIELDS Time)
-{
-    KIRQL oldIrql;
-
-    KeAcquireSpinLock(&CmosLock, &oldIrql);
-
-    /* check 'Update In Progress' bit */
-    while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP);
-
-    Time->Second = BCD_INT(HalpQueryCMOS (0));
-    Time->Minute = BCD_INT(HalpQueryCMOS (2));
-    Time->Hour = BCD_INT(HalpQueryCMOS (4));
-    Time->Weekday = BCD_INT(HalpQueryCMOS (6));
-    Time->Day = BCD_INT(HalpQueryCMOS (7));
-    Time->Month = BCD_INT(HalpQueryCMOS (8));
-    Time->Year = BCD_INT(HalpQueryCMOS (9));
-
-    if (Time->Year > 80)
-        Time->Year += 1900;
-    else
-        Time->Year += 2000;
-
-#if 0
-    /* Century */
-    Time->Year += BCD_INT(HalpQueryCMOS (RTC_REGISTER_CENTURY)) * 100;
-#endif
-
-    KeReleaseSpinLock(&CmosLock, oldIrql);
-
-#ifndef NDEBUG
-    DbgPrint ("HalQueryRealTimeClock() %d:%d:%d %d/%d/%d\n",
-              Time->Hour,
-              Time->Minute,
-              Time->Second,
-              Time->Day,
-              Time->Month,
-              Time->Year
-             );
-#endif
-
-    Time->Milliseconds = 0;
-}
-
-
-VOID STDCALL
-HalSetRealTimeClock(PTIME_FIELDS Time)
-{
-    KIRQL oldIrql;
-
-    KeAcquireSpinLock(&CmosLock, &oldIrql);
-
-    /* check 'Update In Progress' bit */
-    while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP);
-
-    HalpSetCMOS (0, (UCHAR)INT_BCD(Time->Second));
-    HalpSetCMOS (2, (UCHAR)INT_BCD(Time->Minute));
-    HalpSetCMOS (4, (UCHAR)INT_BCD(Time->Hour));
-    HalpSetCMOS (6, (UCHAR)INT_BCD(Time->Weekday));
-    HalpSetCMOS (7, (UCHAR)INT_BCD(Time->Day));
-    HalpSetCMOS (8, (UCHAR)INT_BCD(Time->Month));
-    HalpSetCMOS (9, (UCHAR)INT_BCD(Time->Year % 100));
-
-#if 0
-    /* Century */
-    HalpSetCMOS (RTC_REGISTER_CENTURY, INT_BCD(Time->Year / 100));
-#endif
-    KeReleaseSpinLock(&CmosLock, oldIrql);
-
-}
-
-
-BOOLEAN STDCALL
-HalGetEnvironmentVariable(PCH Name,
-			  PCH Value,
-			  USHORT ValueLength)
-{
-   KIRQL oldIrql;
-
-
-   if (_stricmp(Name, "LastKnownGood") != 0)
-     {
-	return FALSE;
-     }
-
-   KeAcquireSpinLock(&CmosLock, &oldIrql);
-   if (HalpQueryCMOS(RTC_REGISTER_B) & 0x01)
-     {
-	strncpy(Value, "FALSE", ValueLength);
-     }
-   else
-     {
-	strncpy(Value, "TRUE", ValueLength);
-     }
-   KeReleaseSpinLock(&CmosLock, oldIrql);
-
-   return TRUE;
-}
-
-
-BOOLEAN STDCALL
-HalSetEnvironmentVariable(PCH Name,
-			  PCH Value)
-{
-  UCHAR Val;
-  KIRQL oldIrql;
-  BOOLEAN result = TRUE;
-
-  if (_stricmp(Name, "LastKnownGood") != 0)
-    return FALSE;
-
-  KeAcquireSpinLock(&CmosLock, &oldIrql);
-
-  Val = HalpQueryCMOS(RTC_REGISTER_B);
-
-  if (_stricmp(Value, "TRUE") == 0)
-    HalpSetCMOS(RTC_REGISTER_B, (UCHAR)(Val | 0x01));
-  else if (_stricmp(Value, "FALSE") == 0)
-    HalpSetCMOS(RTC_REGISTER_B, (UCHAR)(Val & ~0x01));
-  else
-    result = FALSE;
-
-  KeReleaseSpinLock(&CmosLock, oldIrql);
-
-  return result;
-}
-
-
-ULONG STDCALL
-HalpGetCmosData(PBUS_HANDLER BusHandler,
-		ULONG BusNumber,
-		ULONG SlotNumber,
-		PVOID Buffer,
-		ULONG Offset,
-		ULONG Length)
-{
-  PUCHAR Ptr = Buffer;
-  ULONG Address = SlotNumber;
-  ULONG Len = Length;
-  KIRQL oldIrql;
-
-  DPRINT("HalpGetCmosData() called.\n");
-  DPRINT("  BusNumber %lu\n", BusNumber);
-  DPRINT("  SlotNumber %lu\n", SlotNumber);
-  DPRINT("  Offset 0x%lx\n", Offset);
-  DPRINT("  Length 0x%lx\n", Length);
-
-  if (Length == 0)
-    return 0;
-
-  if (BusNumber == 0)
-    {
-      /* CMOS */
-      KeAcquireSpinLock(&CmosLock, &oldIrql);
-      while ((Len > 0) && (Address < 0x100))
-	{
-	  *Ptr = HalpQueryCMOS((UCHAR)Address);
-	  Ptr = Ptr + 1;
-	  Address++;
-	  Len--;
-	}
-      KeReleaseSpinLock(&CmosLock, oldIrql);
-    }
-  else if (BusNumber == 1)
-    {
-      /* Extended CMOS */
-      KeAcquireSpinLock(&CmosLock, &oldIrql);
-      while ((Len > 0) && (Address < 0x1000))
-	{
-	  *Ptr = HalpQueryECMOS((USHORT)Address);
-	  Ptr = Ptr + 1;
-	  Address++;
-	  Len--;
-	}
-      KeReleaseSpinLock(&CmosLock, oldIrql);
-    }
-
-  return(Length - Len);
-}
-
-
-ULONG STDCALL
-HalpSetCmosData(PBUS_HANDLER BusHandler,
-		ULONG BusNumber,
-		ULONG SlotNumber,
-		PVOID Buffer,
-		ULONG Offset,
-		ULONG Length)
-{
-  PUCHAR Ptr = (PUCHAR)Buffer;
-  ULONG Address = SlotNumber;
-  ULONG Len = Length;
-  KIRQL oldIrql;
-
-  DPRINT("HalpSetCmosData() called.\n");
-  DPRINT("  BusNumber %lu\n", BusNumber);
-  DPRINT("  SlotNumber %lu\n", SlotNumber);
-  DPRINT("  Offset 0x%lx\n", Offset);
-  DPRINT("  Length 0x%lx\n", Length);
-
-  if (Length == 0)
-    return 0;
-
-  if (BusNumber == 0)
-    {
-      /* CMOS */
-      KeAcquireSpinLock(&CmosLock, &oldIrql);
-      while ((Len > 0) && (Address < 0x100))
-	{
-	  HalpSetCMOS((UCHAR)Address, *Ptr);
-	  Ptr = Ptr + 1;
-	  Address++;
-	  Len--;
-	}
-      KeReleaseSpinLock(&CmosLock, oldIrql);
-    }
-  else if (BusNumber == 1)
-    {
-      /* Extended CMOS */
-      KeAcquireSpinLock(&CmosLock, &oldIrql);
-      while ((Len > 0) && (Address < 0x1000))
-	{
-	  HalpSetECMOS((USHORT)Address, *Ptr);
-	  Ptr = Ptr + 1;
-	  Address++;
-	  Len--;
-	}
-      KeReleaseSpinLock(&CmosLock, oldIrql);
-    }
-
-  return(Length - Len);
-}
-
-/* EOF */

reactos/hal/halx86/include
apic.h added at 1.1.2.1
diff -N apic.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ apic.h	8 Dec 2004 21:56:56 -0000	1.1.2.1
@@ -0,0 +1,197 @@
+/*
+ *
+ */
+
+#ifndef __INTERNAL_HAL_APIC_H
+#define __INTERNAL_HAL_APIC_H
+
+#define APIC_DEFAULT_BASE     0xFEE00000    /* Default Local APIC Base Register Address */
+
+/* APIC Register Address Map */
+#define APIC_ID      0x0020 /* Local APIC ID Register (R/W) */
+#define APIC_VER     0x0030 /* Local APIC Version Register (R) */
+#define APIC_TPR     0x0080 /* Task Priority Register (R/W) */
+#define APIC_APR     0x0090 /* Arbitration Priority Register (R) */
+#define APIC_PPR     0x00A0 /* Processor Priority Register (R) */
+#define APIC_EOI     0x00B0 /* EOI Register (W) */
+#define APIC_LDR     0x00D0 /* Logical Destination Register (R/W) */
+#define APIC_DFR     0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */
+#define APIC_SIVR    0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */
+#define APIC_ISR     0x0100 /* Interrupt Service Register 0-255 (R) */
+#define APIC_TMR     0x0180 /* Trigger Mode Register 0-255 (R) */
+#define APIC_IRR     0x0200 /* Interrupt Request Register 0-255 (r) */
+#define APIC_ESR     0x0280 /* Error Status Register (R) */
+#define APIC_ICR0    0x0300 /* Interrupt Command Register 0-31 (R/W) */
+#define APIC_ICR1    0x0310 /* Interrupt Command Register 32-63 (R/W) */
+#define APIC_LVTT    0x0320 /* Local Vector Table (Timer) (R/W) */
+#define	APIC_LVTTHMR 0x0330
+#define APIC_LVTPC   0x0340 /* Performance Counter LVT (R/W) */
+#define APIC_LINT0   0x0350 /* Local Vector Table (LINT0) (R/W) */
+#define APIC_LINT1   0x0360 /* Local Vector Table (LINT1) (R/W) */
+#define APIC_LVT3    0x0370 /* Local Vector Table (Error) (R/W) */
+#define APIC_ICRT    0x0380 /* Initial Count Register for Timer (R/W) */
+#define APIC_CCRT    0x0390 /* Current Count Register for Timer (R) */
+#define APIC_TDCR    0x03E0 /* Timer Divide Configuration Register (R/W) */
+
+#define APIC_ID_MASK		(0xF << 24)
+#define GET_APIC_ID(x)		(((x) & APIC_ID_MASK) >> 24)
+#define	GET_APIC_LOGICAL_ID(x)	(((x)>>24)&0xFF)
+#define APIC_VER_MASK		0xFF00FF
+#define GET_APIC_VERSION(x)	((x) & 0xFF)
+#define GET_APIC_MAXLVT(x)	(((x) >> 16) & 0xFF)
+
+#define APIC_TPR_PRI       0xFF
+#define APIC_TPR_INT       0xF0
+#define APIC_TPR_SUB       0xF
+#define APIC_TPR_MAX       0xFF           /* Maximum priority */
+#define APIC_TPR_MIN       0x20           /* Minimum priority */
+
+#define APIC_LDR_MASK      (0xFF << 24)
+
+#define APIC_SIVR_ENABLE   (0x1 << 8)
+#define APIC_SIVR_FOCUS    (0x1 << 9)
+
+#define APIC_ESR_MASK      (0xFE << 0)    /* Error Mask */
+
+#define APIC_ICR0_VECTOR   (0xFF << 0)    /* Vector */
+#define APIC_ICR0_DM       (0x7 << 8)     /* Delivery Mode */
+#define APIC_ICR0_DESTM    (0x1 << 11)    /* Destination Mode */
+#define APIC_ICR0_DS       (0x1 << 12)    /* Delivery Status */
+#define APIC_ICR0_LEVEL    (0x1 << 14)    /* Level */
+#define APIC_ICR0_TM       (0x1 << 15)    /* Trigger Mode */
+#define APIC_ICR0_DESTS    (0x3 << 18)    /* Destination Shorthand */
+
+/* Delivery Modes */
+#define APIC_DM_FIXED		  (0x0 << 8)
+#define APIC_DM_LOWEST  	(0x1 << 8)
+#define APIC_DM_SMI		    (0x2 << 8)
+#define APIC_DM_REMRD		  (0x3 << 8)
+#define APIC_DM_NMI		    (0x4 << 8)
+#define APIC_DM_INIT      (0x5 << 8)
+#define APIC_DM_STARTUP   (0x6 << 8)
+#define APIC_DM_EXTINT	  (0x7 << 8)
+#define GET_APIC_DELIVERY_MODE(x)	(((x) >> 8) & 0x7)
+#define SET_APIC_DELIVERY_MODE(x,y)	(((x) & ~0x700) | ((y) << 8))
+
+/* Destination Shorthand values */
+#define APIC_ICR0_DESTS_FIELD          (0x0 << 0)
+#define APIC_ICR0_DESTS_SELF           (0x1 << 18)
+#define APIC_ICR0_DESTS_ALL            (0x2 << 18)
+#define APIC_ICR0_DESTS_ALL_BUT_SELF   (0x3 << 18)
+
+#define APIC_ICR0_LEVEL_DEASSERT (0x0 << 14) /* Deassert level */
+#define APIC_ICR0_LEVEL_ASSERT   (0x1 << 14) /* Assert level */
+
+#define GET_APIC_DEST_FIELD(x)   (((x) >> 24) & 0xFF)
+#define SET_APIC_DEST_FIELD(x)   (((x) & 0xFF) << 24)
+
+#define GET_APIC_TIMER_BASE(x)   (((x) >> 18) & 0x3)
+#define SET_APIC_TIMER_BASE(x)   ((x) << 18)
+#define APIC_TIMER_BASE_CLKIN    0x0
+#define APIC_TIMER_BASE_TMBASE   0x1
+#define APIC_TIMER_BASE_DIV      0x2
+
+#define APIC_LVT_VECTOR   		  (0xFF << 0)   /* Vector */
+#define APIC_LVT_DS       		  (0x1 << 12)   /* Delivery Status */
+#define APIC_LVT_REMOTE_IRR		  (0x1 << 14)		/* Remote IRR */
+#define APIC_LVT_LEVEL_TRIGGER	(0x1 << 15)		/* Lvel Triggered */
+#define APIC_LVT_MASKED   	    (0x1 << 16)   /* Mask */
+#define APIC_LVT_PERIODIC 	  	(0x1 << 17)   /* Timer Mode */
+
+#define APIC_LVT3_DM        (0x7 << 8)
+#define APIC_LVT3_IIPP      (0x1 << 13)
+#define APIC_LVT3_TM        (0x1 << 15)
+#define APIC_LVT3_MASKED    (0x1 << 16)
+#define APIC_LVT3_OS        (0x1 << 17)
+
+#define APIC_TDCR_TMBASE   (0x1 << 2)
+#define APIC_TDCR_MASK     0x0F
+#define APIC_TDCR_2        0x00
+#define APIC_TDCR_4        0x01
+#define APIC_TDCR_8        0x02
+#define APIC_TDCR_16       0x03
+#define APIC_TDCR_32       0x08
+#define APIC_TDCR_64       0x09
+#define APIC_TDCR_128      0x0A
+#define APIC_TDCR_1        0x0B
+
+#define APIC_LVT_VECTOR   		  (0xFF << 0)   /* Vector */
+#define APIC_LVT_DS       		  (0x1 << 12)   /* Delivery Status */
+#define APIC_LVT_REMOTE_IRR		  (0x1 << 14)		/* Remote IRR */
+#define APIC_LVT_LEVEL_TRIGGER	(0x1 << 15)		/* Lvel Triggered */
+#define APIC_LVT_MASKED   	    (0x1 << 16)   /* Mask */
+#define APIC_LVT_PERIODIC 	  	(0x1 << 17)   /* Timer Mode */
+
+#define APIC_LVT3_DM        (0x7 << 8)
+#define APIC_LVT3_IIPP      (0x1 << 13)
+#define APIC_LVT3_TM        (0x1 << 15)
+#define APIC_LVT3_MASKED    (0x1 << 16)
+#define APIC_LVT3_OS        (0x1 << 17)
+
+#define APIC_TDCR_TMBASE   (0x1 << 2)
+#define APIC_TDCR_MASK     0x0F
+#define APIC_TDCR_2        0x00
+#define APIC_TDCR_4        0x01
+#define APIC_TDCR_8        0x02
+#define APIC_TDCR_16       0x03
+#define APIC_TDCR_32       0x08
+#define APIC_TDCR_64       0x09
+#define APIC_TDCR_128      0x0A
+#define APIC_TDCR_1        0x0B
+
+#define APIC_TARGET_SELF         0x100
+#define APIC_TARGET_ALL          0x200
+#define APIC_TARGET_ALL_BUT_SELF 0x300
+
+#define APIC_INTEGRATED(version) (version & 0xF0)
+
+#define MAX_CPU   32
+
+/*
+ * Local APIC timer IRQ vector is on a different priority level,
+ * to work around the 'lost local interrupt if more than 2 IRQ
+ * sources per level' errata.
+ */
+#define LOCAL_TIMER_VECTOR 	    0xEF
+
+#define IPI_VECTOR		    0xFB
+#define ERROR_VECTOR		    0xFE
+#define SPURIOUS_VECTOR		    0xFF  /* Must be 0xXF */
+
+
+typedef struct _CPU_INFO
+{
+   UCHAR    Flags;            /* CPU flags */
+   UCHAR    APICId;           /* Local APIC ID */
+   UCHAR    APICVersion;      /* Local APIC version */
+//   UCHAR    MaxLVT;           /* Number of LVT registers */
+   ULONG    BusSpeed;         /* BUS speed */
+   ULONG    CoreSpeed;        /* Core speed */
+   UCHAR    Padding[16-12];   /* Padding to 16-byte */
+} CPU_INFO, *PCPU_INFO;
+
+
+/* Prototypes */
+
+
+volatile inline ULONG APICRead(ULONG Offset);
+inline VOID APICWrite(ULONG Offset, ULONG Value);
+VOID APICSendIPI(ULONG Target, ULONG Mode); 
+
+ULONG APICGetMaxLVT(VOID);
+VOID APICSetup(VOID);
+VOID HaliInitBSP(VOID);
+VOID APICSyncArbIDs(VOID);
+inline VOID APICSendEOI(VOID);
+
+static inline ULONG ThisCPU(VOID)
+{
+   return (APICRead(APIC_ID) & APIC_ID_MASK) >> 24;
+}
+
+
+#endif
+
+
+/* EOF */
+

reactos/hal/halx86/include
hal.h 1.15 -> 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- hal.h	21 Nov 2004 21:53:07 -0000	1.15
+++ hal.h	8 Dec 2004 21:56:56 -0000	1.15.2.1
@@ -33,6 +33,12 @@
 /* dma.c */
 VOID HalpInitDma (VOID);
 
+/* mem.c */
+PVOID HalpMapPhysMemory(ULONG PhysAddr, ULONG Size);
+
+/* Non-generic initialization */
+VOID HalpInitPhase0 (VOID);
+
 /* DMA Page Register Structure  
  080     DMA        RESERVED
  081     DMA        Page Register (channel 2)
@@ -427,8 +433,11 @@
 #error Unknown compiler for inline assembler
 #endif
 
+typedef struct tagHALP_HOOKS
+{
+  void (*InitPciBus)(ULONG BusNumber, PBUS_HANDLER BusHandler);
+} HALP_HOOKS, *PHALP_HOOKS;
 
-
-
+extern HALP_HOOKS HalpHooks;
 
 #endif /* __INTERNAL_HAL_HAL_H */

reactos/hal/halx86/include
mps.h 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- mps.h	21 Nov 2004 22:01:11 -0000	1.7
+++ mps.h	8 Dec 2004 21:56:56 -0000	1.7.2.1
@@ -5,134 +5,12 @@
  * FIXME: This does not work if we have more than 24 IRQs (ie. more than one 
  * I/O APIC) 
  */
-#define IRQL2VECTOR(irql)   IRQ2VECTOR(PROFILE_LEVEL - (irql))
-#define IRQL2TPR(irql)	    (((irql) == PASSIVE_LEVEL) ? 0 : ((irql) >= CLOCK1_LEVEL ? 0xff : IRQL2VECTOR(irql)))
+#define IRQL2VECTOR(irql)   (IRQ2VECTOR(PROFILE_LEVEL - (irql)))
 
+#define IRQL2TPR(irql)	    ((irql) >= IPI_LEVEL ? IPI_VECTOR : ((irql) >= PROFILE_LEVEL ? LOCAL_TIMER_VECTOR : ((irql) > DISPATCH_LEVEL ? IRQL2VECTOR(irql) : 0)))
 
-#define APIC_DEFAULT_BASE     0xFEE00000    /* Default Local APIC Base Register Address */
 #define IOAPIC_DEFAULT_BASE   0xFEC00000    /* Default I/O APIC Base Register Address */
 
-/* APIC Register Address Map */
-#define APIC_ID      0x0020 /* Local APIC ID Register (R/W) */
-#define APIC_VER     0x0030 /* Local APIC Version Register (R) */
-#define APIC_TPR     0x0080 /* Task Priority Register (R/W) */
-#define APIC_APR     0x0090 /* Arbitration Priority Register (R) */
-#define APIC_PPR     0x00A0 /* Processor Priority Register (R) */
-#define APIC_EOI     0x00B0 /* EOI Register (W) */
-#define APIC_LDR     0x00D0 /* Logical Destination Register (R/W) */
-#define APIC_DFR     0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */
-#define APIC_SIVR    0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */
-#define APIC_ISR     0x0100 /* Interrupt Service Register 0-255 (R) */
-#define APIC_TMR     0x0180 /* Trigger Mode Register 0-255 (R) */
-#define APIC_IRR     0x0200 /* Interrupt Request Register 0-255 (r) */
-#define APIC_ESR     0x0280 /* Error Status Register (R) */
-#define APIC_ICR0    0x0300 /* Interrupt Command Register 0-31 (R/W) */
-#define APIC_ICR1    0x0310 /* Interrupt Command Register 32-63 (R/W) */
-#define APIC_LVTT    0x0320 /* Local Vector Table (Timer) (R/W) */
-#define APIC_LVTPC   0x0340 /* Performance Counter LVT (R/W) */
-#define APIC_LINT0   0x0350 /* Local Vector Table (LINT0) (R/W) */
-#define APIC_LINT1   0x0360 /* Local Vector Table (LINT1) (R/W) */
-#define APIC_LVT3    0x0370 /* Local Vector Table (Error) (R/W) */
-#define APIC_ICRT    0x0380 /* Initial Count Register for Timer (R/W) */
-#define APIC_CCRT    0x0390 /* Current Count Register for Timer (R) */
-#define APIC_TDCR    0x03E0 /* Timer Divide Configuration Register (R/W) */
-
-#define APIC_ID_MASK		(0xF << 24)
-#define GET_APIC_ID(x)		(((x) & APIC_ID_MASK) >> 24)
-#define	GET_APIC_LOGICAL_ID(x)	(((x)>>24)&0xFF)
-#define APIC_VER_MASK		0xFF00FF
-#define GET_APIC_VERSION(x)	((x) & 0xFF)
-#define GET_APIC_MAXLVT(x)	(((x) >> 16) & 0xFF)
-
-#define APIC_TPR_PRI       0xFF
-#define APIC_TPR_INT       0xF0
-#define APIC_TPR_SUB       0xF
-#define APIC_TPR_MAX       0xFF           /* Maximum priority */
-#define APIC_TPR_MIN       0x20           /* Minimum priority */
-
-#define APIC_LDR_MASK      (0xFF << 24)
-
-#define APIC_SIVR_ENABLE   (0x1 << 8)
-#define APIC_SIVR_FOCUS    (0x1 << 9)
-
-#define APIC_ESR_MASK      (0xFE << 0)    /* Error Mask */
-
-#define APIC_ICR0_VECTOR   (0xFF << 0)    /* Vector */
-#define APIC_ICR0_DM       (0x7 << 8)     /* Delivery Mode */
-#define APIC_ICR0_DESTM    (0x1 << 11)    /* Destination Mode */
-#define APIC_ICR0_DS       (0x1 << 12)    /* Delivery Status */
-#define APIC_ICR0_LEVEL    (0x1 << 14)    /* Level */
-#define APIC_ICR0_TM       (0x1 << 15)    /* Trigger Mode */
-#define APIC_ICR0_DESTS    (0x3 << 18)    /* Destination Shorthand */
-
-/* Delivery Modes */
-#define APIC_DM_FIXED		  (0x0 << 8)
-#define APIC_DM_LOWEST  	(0x1 << 8)
-#define APIC_DM_SMI		    (0x2 << 8)
-#define APIC_DM_REMRD		  (0x3 << 8)
-#define APIC_DM_NMI		    (0x4 << 8)
-#define APIC_DM_INIT      (0x5 << 8)
-#define APIC_DM_STARTUP   (0x6 << 8)
-#define APIC_DM_EXTINT	  (0x7 << 8)
-#define GET_APIC_DELIVERY_MODE(x)	(((x) >> 8) & 0x7)
-#define SET_APIC_DELIVERY_MODE(x,y)	(((x) & ~0x700) | ((y) << 8))
-
-/* Destination Shorthand values */
-#define APIC_ICR0_DESTS_FIELD          (0x0 << 0)
-#define APIC_ICR0_DESTS_SELF           (0x1 << 18)
-#define APIC_ICR0_DESTS_ALL            (0x2 << 18)
-#define APIC_ICR0_DESTS_ALL_BUT_SELF   (0x3 << 18)
-
-#define APIC_ICR0_LEVEL_DEASSERT (0x0 << 14) /* Deassert level */
-#define APIC_ICR0_LEVEL_ASSERT   (0x1 << 14) /* Assert level */
-
-#define GET_APIC_DEST_FIELD(x)   (((x) >> 24) & 0xFF)
-#define SET_APIC_DEST_FIELD(x)   (((x) & 0xFF) << 24)
-
-#define GET_APIC_TIMER_BASE(x)   (((x) >> 18) & 0x3)
-#define SET_APIC_TIMER_BASE(x)   ((x) << 18)
-#define APIC_TIMER_BASE_CLKIN    0x0
-#define APIC_TIMER_BASE_TMBASE   0x1
-#define APIC_TIMER_BASE_DIV      0x2
-
-#define APIC_LVT_VECTOR   		  (0xFF << 0)   /* Vector */
-#define APIC_LVT_DS       		  (0x1 << 12)   /* Delivery Status */
-#define APIC_LVT_REMOTE_IRR		  (0x1 << 14)		/* Remote IRR */
-#define APIC_LVT_LEVEL_TRIGGER	(0x1 << 15)		/* Lvel Triggered */
-#define APIC_LVT_MASKED   	    (0x1 << 16)   /* Mask */
-#define APIC_LVT_PERIODIC 	  	(0x1 << 17)   /* Timer Mode */
-
-#define APIC_LVT3_DM        (0x7 << 8)
-#define APIC_LVT3_IIPP      (0x1 << 13)
-#define APIC_LVT3_TM        (0x1 << 15)
-#define APIC_LVT3_MASKED    (0x1 << 16)
-#define APIC_LVT3_OS        (0x1 << 17)
-
-#define APIC_TDCR_TMBASE   (0x1 << 2)
-#define APIC_TDCR_MASK     0x0F
-#define APIC_TDCR_2        0x00
-#define APIC_TDCR_4        0x01
-#define APIC_TDCR_8        0x02
-#define APIC_TDCR_16       0x03
-#define APIC_TDCR_32       0x08
-#define APIC_TDCR_64       0x09
-#define APIC_TDCR_128      0x0A
-#define APIC_TDCR_1        0x0B
-
-#define APIC_TARGET_SELF         0x100
-#define APIC_TARGET_ALL          0x200
-#define APIC_TARGET_ALL_BUT_SELF 0x300
-
-#define IPI_CACHE_FLUSH    0x40
-#define IPI_INV_TLB        0x41
-#define IPI_INV_PTE        0x42
-#define IPI_INV_RESCHED    0x43
-#define IPI_STOP           0x44
-
-
-#define APIC_INTEGRATED(version) (version & 0xF0)
-
-
 /* I/O APIC Register Address Map */
 #define IOAPIC_IOREGSEL 0x0000  /* I/O Register Select (index) (R/W) */
 #define IOAPIC_IOWIN    0x0010  /* I/O window (data) (R/W) */
@@ -201,18 +79,6 @@
 } IOAPIC_INFO, *PIOAPIC_INFO;
 
 
-/*
- * Local APIC timer IRQ vector is on a different priority level,
- * to work around the 'lost local interrupt if more than 2 IRQ
- * sources per level' errata.
- */
-#define LOCAL_TIMER_VECTOR 	    0xEF
-
-#define CALL_FUNCTION_VECTOR	    0xFB
-#define RESCHEDULE_VECTOR	    0xFC
-#define INVALIDATE_TLB_VECTOR	    0xFD
-#define ERROR_VECTOR		    0xFE
-#define SPURIOUS_VECTOR		    0xFF  /* Must be 0xXF */
 
 #if 0
 /* This values are defined in halirql.h */
@@ -395,20 +261,8 @@
 }
 
 
-#define MAX_CPU   32
 
 
-typedef struct _CPU_INFO
-{
-   UCHAR    Flags;            /* CPU flags */
-   UCHAR    APICId;           /* Local APIC ID */
-   UCHAR    APICVersion;      /* Local APIC version */
-   UCHAR    MaxLVT;           /* Number of LVT registers */
-   ULONG    BusSpeed;         /* BUS speed */
-   ULONG    CoreSpeed;        /* Core speed */
-   UCHAR    Padding[16-12];   /* Padding to 16-byte */
-} CPU_INFO, *PCPU_INFO;
-
 /* CPU flags */
 #define CPU_USABLE   0x01  /* 1 if the CPU is usable (ie. can be used) */
 #define CPU_ENABLED  0x02  /* 1 if the CPU is enabled */
@@ -430,17 +284,9 @@
 VOID IOAPICWrite(ULONG Apic, ULONG Offset, ULONG Value);
 VOID IOAPICMaskIrq(ULONG Irq);
 VOID IOAPICUnmaskIrq(ULONG Irq);
-volatile inline ULONG APICRead(ULONG Offset);
-inline VOID APICWrite(ULONG Offset, ULONG Value);
-inline VOID APICSendEOI(VOID);
-inline ULONG ThisCPU(VOID);
-VOID APICSendIPI(ULONG Target,
-                 ULONG DeliveryMode,
-                 ULONG IntNum,
-                 ULONG Level);
+
 /* For debugging */
 VOID IOAPICDump(VOID);
-VOID APICDump(VOID);
 
 #endif /* __INCLUDE_HAL_MPS */
 

reactos/include
dinput.h added at 1.1.2.1
diff -N dinput.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dinput.h	8 Dec 2004 21:56:56 -0000	1.1.2.1
@@ -0,0 +1,2349 @@
+/*
+ * Copyright (C) the Wine project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+//#ifndef __DINPUT_INCLUDED__
+//#define __DINPUT_INCLUDED__
+
+#ifndef __WINE_DINPUT_H
+#define __WINE_DINPUT_H
+
+#ifndef DIJ_RINGZERO
+#include <objbase.h>
+#ifdef _WIN32
+#define COM_NO_WINDOWS_H
+#include <objbase.h>
+#endif
+
+#endif /* DIJ_RINGZERO */
+
+#ifndef DIRECTINPUT_VERSION
+#define DIRECTINPUT_VERSION	0x0800
+#endif
+#ifndef DIRECTINPUT_VERSION
+#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION
+#endif
+
+//#ifndef DIJ_RINGZERO
+/* Classes */
+DEFINE_GUID(CLSID_DirectInput,		0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(CLSID_DirectInputDevice,	0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+
+DEFINE_GUID(CLSID_DirectInput8,		0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(CLSID_DirectInputDevice8,	0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+
+
+
+/* Interfaces */
+DEFINE_GUID(IID_IDirectInputA,		0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInputW,		0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInput2A,		0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInput2W,		0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInput7A,		0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
+DEFINE_GUID(IID_IDirectInput7W,		0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
+DEFINE_GUID(IID_IDirectInput8A,		0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
+DEFINE_GUID(IID_IDirectInput8W,		0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
+
+DEFINE_GUID(IID_IDirectInputDeviceA,	0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInputDeviceW,	0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInputDevice2A,	0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInputDevice2W,	0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(IID_IDirectInputDevice7A,	0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
+DEFINE_GUID(IID_IDirectInputDevice7W,	0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
+DEFINE_GUID(IID_IDirectInputDevice8A,	0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
+DEFINE_GUID(IID_IDirectInputDevice8W,	0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
+DEFINE_GUID(IID_IDirectInputEffect,	0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+
+
+/* Predefined object types */
+DEFINE_GUID(GUID_XAxis,	0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_YAxis,	0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_ZAxis,	0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_Key,	0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_POV,	0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+
+
+/* Predefined product GUIDs */
+DEFINE_GUID(GUID_SysMouse,	0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_SysKeyboard,	0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_Joystick,	0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_SysMouseEm,	0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_SysMouseEm2,	0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_SysKeyboardEm,	0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
+
+
+/* predefined forcefeedback effects */
+DEFINE_GUID(GUID_ConstantForce,	0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_RampForce,	0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Square,	0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Sine,		0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Triangle,	0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_SawtoothUp,	0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_SawtoothDown,	0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Spring,	0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Damper,	0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Inertia,	0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_Friction,	0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+DEFINE_GUID(GUID_CustomForce,	0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
+
+//#endif /* DIJ_RINGZERO */
+
+// ok yes ?
+typedef struct IDirectInputA *LPDIRECTINPUTA;
+typedef struct IDirectInputW *LPDIRECTINPUTW;
+typedef struct IDirectInput2A *LPDIRECTINPUT2A;
+typedef struct IDirectInput2W *LPDIRECTINPUT2W;
+typedef struct IDirectInput7A *LPDIRECTINPUT7A;
+typedef struct IDirectInput7W *LPDIRECTINPUT7W;
+typedef struct IDirectInput8A *LPDIRECTINPUT8A;
+typedef struct IDirectInput8W *LPDIRECTINPUT8W;
+typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA;
+typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW;
+typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A;
+typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W;
+typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A;
+typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W;
+typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A;
+typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W;
+typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT;
+typedef struct SysKeyboardA SysKeyboardA,*LPSYSKEYBOARDA;
+typedef struct SysMouseA SysMouseA,*LPSYSMOUSEA;
+
+#ifdef UNICODE
+#define IID_IDirectInputDevice IID_IDirectInputDeviceW
+#define IDirectInputDevice IDirectInputDeviceW
+#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl
+#else
+#define IID_IDirectInputDevice IID_IDirectInputDeviceA
+#define IDirectInputDevice IDirectInputDeviceA
+#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInput2 IID_IDirectInput2W
+#define IDirectInput2 IDirectInput2W
+#define IDirectInput2Vtbl IDirectInput2WVtbl
+#else
+#define IID_IDirectInput2 IID_IDirectInput2A
+#define IDirectInput2 IDirectInput2A
+#define IDirectInput2Vtbl IDirectInput2AVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInput7 IID_IDirectInput7W
+#define IDirectInput7 IDirectInput7W
+#define IDirectInput7Vtbl IDirectInput7WVtbl
+#else
+#define IID_IDirectInput7 IID_IDirectInput7A
+#define IDirectInput7 IDirectInput7A
+#define IDirectInput7Vtbl IDirectInput7AVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInputDevice IID_IDirectInputDeviceW
+#define IDirectInputDevice IDirectInputDeviceW
+#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl
+#else
+#define IID_IDirectInputDevice IID_IDirectInputDeviceA
+#define IDirectInputDevice IDirectInputDeviceA
+#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W
+#define IDirectInputDevice2 IDirectInputDevice2W
+#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl
+#else
+#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A
+#define IDirectInputDevice2 IDirectInputDevice2A
+#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W
+#define IDirectInputDevice7 IDirectInputDevice7W
+#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl
+#else
+#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A
+#define IDirectInputDevice7 IDirectInputDevice7A
+#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl
+#endif
+
+#ifdef UNICODE
+#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W
+#define IDirectInputDevice8 IDirectInputDevice8W
+#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl
+#else
+#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A
+#define IDirectInputDevice8 IDirectInputDevice8A
+#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl
+#endif
+
+// need to be fix
+// #define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput)
+// DECL_WINELIB_TYPE_AW(LPDIRECTINPUT)
+// #define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2)
+// DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2)
+// #define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7)
+// DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7)
+//#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice)
+//DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE)
+//#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2)
+//DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2)
+
+// #define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7)
+// DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7)
+
+//#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8)
+//DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8)
+
+
+#define DI_OK                           S_OK
+#define DI_NOTATTACHED                  S_FALSE
+#define DI_BUFFEROVERFLOW               S_FALSE
+#define DI_PROPNOEFFECT                 S_FALSE
+#define DI_NOEFFECT                     S_FALSE
+#define DI_POLLEDDEVICE                 ((HRESULT)0x00000002L)
+#define DI_DOWNLOADSKIPPED              ((HRESULT)0x00000003L)
+#define DI_EFFECTRESTARTED              ((HRESULT)0x00000004L)
+#define DI_TRUNCATED                    ((HRESULT)0x00000008L)
+#define DI_TRUNCATEDANDRESTARTED        ((HRESULT)0x0000000CL)
+
+#define DIERR_OLDDIRECTINPUTVERSION     \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
+#define DIERR_BETADIRECTINPUTVERSION    \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP)
+#define DIERR_BADDRIVERVER              \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL)
+#define DIERR_DEVICENOTREG              REGDB_E_CLASSNOTREG
+#define DIERR_NOTFOUND                  \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
+#define DIERR_OBJECTNOTFOUND            \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
+#define DIERR_INVALIDPARAM              E_INVALIDARG
+#define DIERR_NOINTERFACE               E_NOINTERFACE
+#define DIERR_GENERIC                   E_FAIL
+#define DIERR_OUTOFMEMORY               E_OUTOFMEMORY
+#define DIERR_UNSUPPORTED               E_NOTIMPL
+#define DIERR_NOTINITIALIZED            \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY)
+#define DIERR_ALREADYINITIALIZED        \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED)
+#define DIERR_NOAGGREGATION             CLASS_E_NOAGGREGATION
+#define DIERR_OTHERAPPHASPRIO           E_ACCESSDENIED
+#define DIERR_INPUTLOST                 \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT)
+#define DIERR_ACQUIRED                  \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY)
+#define DIERR_NOTACQUIRED               \
+    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS)
+#define DIERR_READONLY                  E_ACCESSDENIED
+#define DIERR_HANDLEEXISTS              E_ACCESSDENIED
+#ifndef E_PENDING
+#define E_PENDING                       0x8000000AL
+#endif
+#define DIERR_INSUFFICIENTPRIVS         0x80040200L
+#define DIERR_DEVICEFULL                0x80040201L
+#define DIERR_MOREDATA                  0x80040202L
+#define DIERR_NOTDOWNLOADED             0x80040203L
+#define DIERR_HASEFFECTS                0x80040204L
+#define DIERR_NOTEXCLUSIVEACQUIRED      0x80040205L
+#define DIERR_INCOMPLETEEFFECT          0x80040206L
+#define DIERR_NOTBUFFERED               0x80040207L
+#define DIERR_EFFECTPLAYING             0x80040208L
+#define DIERR_UNPLUGGED                 0x80040209L
+#define DIERR_REPORTFULL                0x8004020AL
+
+#define DIENUM_STOP                     0
+#define DIENUM_CONTINUE                 1
+
+#define DIEDFL_ALLDEVICES               0x00000000
+#define DIEDFL_ATTACHEDONLY             0x00000000
+#define DIEDFL_FORCEFEEDBACK            0x00000100
+#define DIEDFL_INCLUDEALIASES           0x00010000
+#define DIEDFL_INCLUDEPHANTOMS          0x00020000
+#define DIEDFL_INCLUDEHIDDEN		0x00040000
+
+#define DIDEVTYPE_DEVICE                1
+#define DIDEVTYPE_MOUSE                 2
+#define DIDEVTYPE_KEYBOARD              3
+#define DIDEVTYPE_JOYSTICK              4
+#define DIDEVTYPE_HID                   0x00010000
+
+#define DI8DEVCLASS_ALL             0
+#define DI8DEVCLASS_DEVICE          1
+#define DI8DEVCLASS_POINTER         2
+#define DI8DEVCLASS_KEYBOARD        3
+#define DI8DEVCLASS_GAMECTRL        4
+
+#define DI8DEVTYPE_DEVICE           0x11
+#define DI8DEVTYPE_MOUSE            0x12
+#define DI8DEVTYPE_KEYBOARD         0x13
+#define DI8DEVTYPE_JOYSTICK         0x14
+#define DI8DEVTYPE_GAMEPAD          0x15
+#define DI8DEVTYPE_DRIVING          0x16
+#define DI8DEVTYPE_FLIGHT           0x17
+#define DI8DEVTYPE_1STPERSON        0x18
+#define DI8DEVTYPE_DEVICECTRL       0x19
+#define DI8DEVTYPE_SCREENPOINTER    0x1A
+#define DI8DEVTYPE_REMOTE           0x1B
+#define DI8DEVTYPE_SUPPLEMENTAL     0x1C
+	
+#define DIDEVTYPEMOUSE_UNKNOWN          1
+#define DIDEVTYPEMOUSE_TRADITIONAL      2
+#define DIDEVTYPEMOUSE_FINGERSTICK      3
+#define DIDEVTYPEMOUSE_TOUCHPAD         4
+#define DIDEVTYPEMOUSE_TRACKBALL        5
+
+#define DIDEVTYPEKEYBOARD_UNKNOWN       0
+#define DIDEVTYPEKEYBOARD_PCXT          1
+#define DIDEVTYPEKEYBOARD_OLIVETTI      2
+#define DIDEVTYPEKEYBOARD_PCAT          3
+#define DIDEVTYPEKEYBOARD_PCENH         4
+#define DIDEVTYPEKEYBOARD_NOKIA1050     5
+#define DIDEVTYPEKEYBOARD_NOKIA9140     6
+#define DIDEVTYPEKEYBOARD_NEC98         7
+#define DIDEVTYPEKEYBOARD_NEC98LAPTOP   8
+#define DIDEVTYPEKEYBOARD_NEC98106      9
+#define DIDEVTYPEKEYBOARD_JAPAN106     10
+#define DIDEVTYPEKEYBOARD_JAPANAX      11
+#define DIDEVTYPEKEYBOARD_J3100        12
+
+#define DIDEVTYPEJOYSTICK_UNKNOWN       1
+#define DIDEVTYPEJOYSTICK_TRADITIONAL   2
+#define DIDEVTYPEJOYSTICK_FLIGHTSTICK   3
+#define DIDEVTYPEJOYSTICK_GAMEPAD       4
+#define DIDEVTYPEJOYSTICK_RUDDER        5
+#define DIDEVTYPEJOYSTICK_WHEEL         6
+#define DIDEVTYPEJOYSTICK_HEADTRACKER   7
+
+#define DI8DEVTYPEMOUSE_UNKNOWN                     1
+#define DI8DEVTYPEMOUSE_TRADITIONAL                 2
+#define DI8DEVTYPEMOUSE_FINGERSTICK                 3
+#define DI8DEVTYPEMOUSE_TOUCHPAD                    4
+#define DI8DEVTYPEMOUSE_TRACKBALL                   5
+#define DI8DEVTYPEMOUSE_ABSOLUTE                    6
+
+#define DI8DEVTYPEKEYBOARD_UNKNOWN                  0
+#define DI8DEVTYPEKEYBOARD_PCXT                     1
+#define DI8DEVTYPEKEYBOARD_OLIVETTI                 2
+#define DI8DEVTYPEKEYBOARD_PCAT                     3
+#define DI8DEVTYPEKEYBOARD_PCENH                    4
+#define DI8DEVTYPEKEYBOARD_NOKIA1050                5
+#define DI8DEVTYPEKEYBOARD_NOKIA9140                6
+#define DI8DEVTYPEKEYBOARD_NEC98                    7
+#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP              8
+#define DI8DEVTYPEKEYBOARD_NEC98106                 9
+#define DI8DEVTYPEKEYBOARD_JAPAN106                10
+#define DI8DEVTYPEKEYBOARD_JAPANAX                 11
+#define DI8DEVTYPEKEYBOARD_J3100                   12
+
+#define DI8DEVTYPE_LIMITEDGAMESUBTYPE               1
+
+#define DI8DEVTYPEJOYSTICK_LIMITED                  DI8DEVTYPE_LIMITEDGAMESUBTYPE
+#define DI8DEVTYPEJOYSTICK_STANDARD                 2
+
+#define DI8DEVTYPEGAMEPAD_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
+#define DI8DEVTYPEGAMEPAD_STANDARD                  2
+#define DI8DEVTYPEGAMEPAD_TILT                      3
+
+#define DI8DEVTYPEDRIVING_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
+#define DI8DEVTYPEDRIVING_COMBINEDPEDALS            2
+#define DI8DEVTYPEDRIVING_DUALPEDALS                3
+#define DI8DEVTYPEDRIVING_THREEPEDALS               4
+#define DI8DEVTYPEDRIVING_HANDHELD                  5
+
+#define DI8DEVTYPEFLIGHT_LIMITED                    DI8DEVTYPE_LIMITEDGAMESUBTYPE
+#define DI8DEVTYPEFLIGHT_STICK                      2
+#define DI8DEVTYPEFLIGHT_YOKE                       3
+#define DI8DEVTYPEFLIGHT_RC                         4
+
+#define DI8DEVTYPE1STPERSON_LIMITED                 DI8DEVTYPE_LIMITEDGAMESUBTYPE
+#define DI8DEVTYPE1STPERSON_UNKNOWN                 2
+#define DI8DEVTYPE1STPERSON_SIXDOF                  3
+#define DI8DEVTYPE1STPERSON_SHOOTER                 4
+
+#define DI8DEVTYPESCREENPTR_UNKNOWN                 2
+#define DI8DEVTYPESCREENPTR_LIGHTGUN                3
+#define DI8DEVTYPESCREENPTR_LIGHTPEN                4
+#define DI8DEVTYPESCREENPTR_TOUCH                   5
+
+#define DI8DEVTYPEREMOTE_UNKNOWN                    2
+
+#define DI8DEVTYPEDEVICECTRL_UNKNOWN                2
+#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION         3
+#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4
+
+#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN              2
+#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER    3
+#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER          4
+#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER          5
+#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE       6
+#define DI8DEVTYPESUPPLEMENTAL_SHIFTER              7
+#define DI8DEVTYPESUPPLEMENTAL_THROTTLE             8
+#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE        9
+#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS      10
+#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS          11
+#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS         12
+#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS        13
+	
+#define GET_DIDEVICE_TYPE(dwDevType)     LOBYTE(dwDevType)
+#define GET_DIDEVICE_SUBTYPE(dwDevType)  HIBYTE(dwDevType)
+
+typedef struct DIDEVICEOBJECTINSTANCE_DX3A {
+    DWORD   dwSize;
+    GUID    guidType;
+    DWORD   dwOfs;
+    DWORD   dwType;
+    DWORD   dwFlags;
+    CHAR    tszName[MAX_PATH];
+} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A;
+typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A;
+typedef struct DIDEVICEOBJECTINSTANCE_DX3W {
+    DWORD   dwSize;
+    GUID    guidType;
+    DWORD   dwOfs;
+    DWORD   dwType;
+    DWORD   dwFlags;
+    WCHAR   tszName[MAX_PATH];
+} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W;
+typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W;
+
+DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3)
+DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3)
+DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3)
+
+typedef struct DIDEVICEOBJECTINSTANCEA {
+    DWORD	dwSize;
+    GUID	guidType;
+    DWORD	dwOfs;
+    DWORD	dwType;
+    DWORD	dwFlags;
+    CHAR	tszName[MAX_PATH];
+#if(DIRECTINPUT_VERSION >= 0x0500)
+    DWORD	dwFFMaxForce;
+    DWORD	dwFFForceResolution;
+    WORD	wCollectionNumber;
+    WORD	wDesignatorIndex;
+    WORD	wUsagePage;
+    WORD	wUsage;
+    DWORD	dwDimension;
+    WORD	wExponent;
+    WORD	wReserved;
+#endif /* DIRECTINPUT_VERSION >= 0x0500 */
+} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
+typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
+
+typedef struct DIDEVICEOBJECTINSTANCEW {
+    DWORD	dwSize;
+    GUID	guidType;
+    DWORD	dwOfs;
+    DWORD	dwType;
+    DWORD	dwFlags;
+    WCHAR	tszName[MAX_PATH];
+#if(DIRECTINPUT_VERSION >= 0x0500)
+    DWORD	dwFFMaxForce;
+    DWORD	dwFFForceResolution;
+    WORD	wCollectionNumber;
+    WORD	wDesignatorIndex;
+    WORD	wUsagePage;
+    WORD	wUsage;
+    DWORD	dwDimension;
+    WORD	wExponent;
+    WORD	wReserved;
+#endif /* DIRECTINPUT_VERSION >= 0x0500 */
+} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
+typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
+
+DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE)
+DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE)
+DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE)
+
+typedef struct DIDEVICEINSTANCE_DX3A {
+    DWORD   dwSize;
+    GUID    guidInstance;
+    GUID    guidProduct;
+    DWORD   dwDevType;
+    CHAR    tszInstanceName[MAX_PATH];
+    CHAR    tszProductName[MAX_PATH];
+} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A;
+typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A;
+typedef struct DIDEVICEINSTANCE_DX3W {
+    DWORD   dwSize;
+    GUID    guidInstance;
+    GUID    guidProduct;
+    DWORD   dwDevType;
+    WCHAR   tszInstanceName[MAX_PATH];
+    WCHAR   tszProductName[MAX_PATH];
+} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W;
+typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W;
+
+DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3)
+DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3)
+DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3)
+
+typedef struct DIDEVICEINSTANCEA {
+    DWORD	dwSize;
+    GUID	guidInstance;
+    GUID	guidProduct;
+    DWORD	dwDevType;
+    CHAR	tszInstanceName[MAX_PATH];
+    CHAR	tszProductName[MAX_PATH];
+#if(DIRECTINPUT_VERSION >= 0x0500)
+    GUID	guidFFDriver;
+    WORD	wUsagePage;
+    WORD	wUsage;
+#endif /* DIRECTINPUT_VERSION >= 0x0500 */
+} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
+typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
+
+typedef struct DIDEVICEINSTANCEW {
+    DWORD	dwSize;
+    GUID	guidInstance;
+    GUID	guidProduct;
+    DWORD	dwDevType;
+    WCHAR	tszInstanceName[MAX_PATH];
+    WCHAR	tszProductName[MAX_PATH];
+#if(DIRECTINPUT_VERSION >= 0x0500)
+    GUID	guidFFDriver;
+    WORD	wUsagePage;
+    WORD	wUsage;
+#endif /* DIRECTINPUT_VERSION >= 0x0500 */
+} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
+typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
+
+DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE)
+DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE)
+DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE)
+
+typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
+typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
+DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
+
+#if DIRECTINPUT_VERSION >= 0x0800
+typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID);
+typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID);
+DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB)
+#endif
+
+typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID);
+
+typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID);
+typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID);
+DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK)
+
+typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID);
+
+#define DIK_ESCAPE          0x01
+#define DIK_1               0x02
+#define DIK_2               0x03
+#define DIK_3               0x04
+#define DIK_4               0x05
+#define DIK_5               0x06
+#define DIK_6               0x07
+#define DIK_7               0x08
+#define DIK_8               0x09
+#define DIK_9               0x0A
+#define DIK_0               0x0B
+#define DIK_MINUS           0x0C    /* - on main keyboard */
+#define DIK_EQUALS          0x0D
+#define DIK_BACK            0x0E    /* backspace */
+#define DIK_TAB             0x0F
+#define DIK_Q               0x10
+#define DIK_W               0x11
+#define DIK_E               0x12
+#define DIK_R               0x13
+#define DIK_T               0x14
+#define DIK_Y               0x15
+#define DIK_U               0x16
+#define DIK_I               0x17
+#define DIK_O               0x18
+#define DIK_P               0x19
+#define DIK_LBRACKET        0x1A
+#define DIK_RBRACKET        0x1B
+#define DIK_RETURN          0x1C    /* Enter on main keyboard */
+#define DIK_LCONTROL        0x1D
+#define DIK_A               0x1E
+#define DIK_S               0x1F
+#define DIK_D               0x20
+#define DIK_F               0x21
+#define DIK_G               0x22
+#define DIK_H               0x23
+#define DIK_J               0x24
+#define DIK_K               0x25
+#define DIK_L               0x26
+#define DIK_SEMICOLON       0x27
+#define DIK_APOSTROPHE      0x28
+#define DIK_GRAVE           0x29    /* accent grave */
+#define DIK_LSHIFT          0x2A
+#define DIK_BACKSLASH       0x2B
+#define DIK_Z               0x2C
+#define DIK_X               0x2D
+#define DIK_C               0x2E
+#define DIK_V               0x2F
+#define DIK_B               0x30
+#define DIK_N               0x31
+#define DIK_M               0x32
+#define DIK_COMMA           0x33
+#define DIK_PERIOD          0x34    /* . on main keyboard */
+#define DIK_SLASH           0x35    /* / on main keyboard */
+#define DIK_RSHIFT          0x36
+#define DIK_MULTIPLY        0x37    /* * on numeric keypad */
+#define DIK_LMENU           0x38    /* left Alt */
+#define DIK_SPACE           0x39
+#define DIK_CAPITAL         0x3A
+#define DIK_F1              0x3B
+#define DIK_F2              0x3C
+#define DIK_F3              0x3D
+#define DIK_F4              0x3E
+#define DIK_F5              0x3F
+#define DIK_F6              0x40
+#define DIK_F7              0x41
+#define DIK_F8              0x42
+#define DIK_F9              0x43
+#define DIK_F10             0x44
+#define DIK_NUMLOCK         0x45
+#define DIK_SCROLL          0x46    /* Scroll Lock */
+#define DIK_NUMPAD7         0x47
+#define DIK_NUMPAD8         0x48
+#define DIK_NUMPAD9         0x49
+#define DIK_SUBTRACT        0x4A    /* - on numeric keypad */
+#define DIK_NUMPAD4         0x4B
+#define DIK_NUMPAD5         0x4C
+#define DIK_NUMPAD6         0x4D
+#define DIK_ADD             0x4E    /* + on numeric keypad */
+#define DIK_NUMPAD1         0x4F
+#define DIK_NUMPAD2         0x50
+#define DIK_NUMPAD3         0x51
+#define DIK_NUMPAD0         0x52
+#define DIK_DECIMAL         0x53    /* . on numeric keypad */
+#define DIK_F11             0x57
+#define DIK_F12             0x58
+#define DIK_F13             0x64    /*                     (NEC PC98) */
+#define DIK_F14             0x65    /*                     (NEC PC98) */
+#define DIK_F15             0x66    /*                     (NEC PC98) */
+#define DIK_KANA            0x70    /* (Japanese keyboard)            */
+#define DIK_CONVERT         0x79    /* (Japanese keyboard)            */
+#define DIK_NOCONVERT       0x7B    /* (Japanese keyboard)            */
+#define DIK_YEN             0x7D    /* (Japanese keyboard)            */
+#define DIK_NUMPADEQUALS    0x8D    /* = on numeric keypad (NEC PC98) */
+#define DIK_CIRCUMFLEX      0x90    /* (Japanese keyboard)            */
+#define DIK_AT              0x91    /*                     (NEC PC98) */
+#define DIK_COLON           0x92    /*                     (NEC PC98) */
+#define DIK_UNDERLINE       0x93    /*                     (NEC PC98) */
+#define DIK_KANJI           0x94    /* (Japanese keyboard)            */
+#define DIK_STOP            0x95    /*                     (NEC PC98) */
+#define DIK_AX              0x96    /*                     (Japan AX) */
+#define DIK_UNLABELED       0x97    /*                        (J3100) */
+#define DIK_NUMPADENTER     0x9C    /* Enter on numeric keypad */
+#define DIK_RCONTROL        0x9D
+#define DIK_NUMPADCOMMA     0xB3    /* , on numeric keypad (NEC PC98) */
+#define DIK_DIVIDE          0xB5    /* / on numeric keypad */
+#define DIK_SYSRQ           0xB7
+#define DIK_RMENU           0xB8    /* right Alt */
+#define DIK_PAUSE           0xC5    /* Pause */
+#define DIK_HOME            0xC7    /* Home on arrow keypad */
+#define DIK_UP              0xC8    /* UpArrow on arrow keypad */
+#define DIK_PRIOR           0xC9    /* PgUp on arrow keypad */
+#define DIK_LEFT            0xCB    /* LeftArrow on arrow keypad */
+#define DIK_RIGHT           0xCD    /* RightArrow on arrow keypad */
+#define DIK_END             0xCF    /* End on arrow keypad */
+#define DIK_DOWN            0xD0    /* DownArrow on arrow keypad */
+#define DIK_NEXT            0xD1    /* PgDn on arrow keypad */
+#define DIK_INSERT          0xD2    /* Insert on arrow keypad */
+#define DIK_DELETE          0xD3    /* Delete on arrow keypad */
+#define DIK_LWIN            0xDB    /* Left Windows key */
+#define DIK_RWIN            0xDC    /* Right Windows key */
+#define DIK_APPS            0xDD    /* AppMenu key */
+#define DIK_POWER           0xDE
+#define DIK_SLEEP           0xDF
+#define DIK_BACKSPACE       DIK_BACK            /* backspace */
+#define DIK_NUMPADSTAR      DIK_MULTIPLY        /* * on numeric keypad */
+#define DIK_LALT            DIK_LMENU           /* left Alt */
+#define DIK_CAPSLOCK        DIK_CAPITAL         /* CapsLock */
+#define DIK_NUMPADMINUS     DIK_SUBTRACT        /* - on numeric keypad */
+#define DIK_NUMPADPLUS      DIK_ADD             /* + on numeric keypad */
+#define DIK_NUMPADPERIOD    DIK_DECIMAL         /* . on numeric keypad */
+#define DIK_NUMPADSLASH     DIK_DIVIDE          /* / on numeric keypad */
+#define DIK_RALT            DIK_RMENU           /* right Alt */
+#define DIK_UPARROW         DIK_UP              /* UpArrow on arrow keypad */
+#define DIK_PGUP            DIK_PRIOR           /* PgUp on arrow keypad */
+#define DIK_LEFTARROW       DIK_LEFT            /* LeftArrow on arrow keypad */
+#define DIK_RIGHTARROW      DIK_RIGHT           /* RightArrow on arrow keypad */
+#define DIK_DOWNARROW       DIK_DOWN            /* DownArrow on arrow keypad */
+#define DIK_PGDN            DIK_NEXT            /* PgDn on arrow keypad */
+
+#define DIDFT_ALL		0x00000000
+#define DIDFT_RELAXIS		0x00000001
+#define DIDFT_ABSAXIS		0x00000002
+#define DIDFT_AXIS		0x00000003
+#define DIDFT_PSHBUTTON		0x00000004
+#define DIDFT_TGLBUTTON		0x00000008
+#define DIDFT_BUTTON		0x0000000C
+#define DIDFT_POV		0x00000010
+#define DIDFT_COLLECTION	0x00000040
+#define DIDFT_NODATA		0x00000080
+#define DIDFT_ANYINSTANCE	0x00FFFF00
+#define DIDFT_INSTANCEMASK	DIDFT_ANYINSTANCE
+#define DIDFT_MAKEINSTANCE(n)	((WORD)(n) << 8)
+#define DIDFT_GETTYPE(n)	LOBYTE(n)
+#define DIDFT_GETINSTANCE(n)	LOWORD((n) >> 8)
+#define DIDFT_FFACTUATOR	0x01000000
+#define DIDFT_FFEFFECTTRIGGER	0x02000000
+#define DIDFT_OUTPUT		0x10000000
+#define DIDFT_VENDORDEFINED	0x04000000
+#define DIDFT_ALIAS		0x08000000
+#ifndef DIDFT_OPTIONAL
+#define DIDFT_OPTIONAL		0x80000000
+#endif
+#define DIDFT_ENUMCOLLECTION(n)	((WORD)(n) << 8)
+#define DIDFT_NOCOLLECTION	0x00FFFF00
+#define DIDF_ABSAXIS		0x00000001
+#define DIDF_RELAXIS		0x00000002
+
+#define DIGDD_PEEK		0x00000001
+
+typedef struct DIDEVICEOBJECTDATA_DX3 {
+    DWORD	dwOfs;
+    DWORD	dwData;
+    DWORD	dwTimeStamp;
+    DWORD	dwSequence;
+} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3;
+typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3;
+
+typedef struct DIDEVICEOBJECTDATA {
+    DWORD	dwOfs;
+    DWORD	dwData;
+    DWORD	dwTimeStamp;
+    DWORD	dwSequence;
+    UINT_PTR	uAppData;
+} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA;
+typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA;
+
+typedef struct _DIOBJECTDATAFORMAT {
+    const GUID *pguid;
+    DWORD	dwOfs;
+    DWORD	dwType;
+    DWORD	dwFlags;
+} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT;
+typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
+
+typedef struct _DIDATAFORMAT {
+    DWORD			dwSize;
+    DWORD			dwObjSize;
+    DWORD			dwFlags;
+    DWORD			dwDataSize;
+    DWORD			dwNumObjs;
+    LPDIOBJECTDATAFORMAT	rgodf;
+} DIDATAFORMAT, *LPDIDATAFORMAT;
+typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
+
+#define DIDOI_FFACTUATOR	0x00000001
+#define DIDOI_FFEFFECTTRIGGER	0x00000002
+#define DIDOI_POLLED		0x00008000
+#define DIDOI_ASPECTPOSITION	0x00000100
+#define DIDOI_ASPECTVELOCITY	0x00000200
+#define DIDOI_ASPECTACCEL	0x00000300
+#define DIDOI_ASPECTFORCE	0x00000400
+#define DIDOI_ASPECTMASK	0x00000F00
+#define DIDOI_GUIDISUSAGE	0x00010000
+
+typedef struct DIPROPHEADER {
+    DWORD	dwSize;
+    DWORD	dwHeaderSize;
+    DWORD	dwObj;
+    DWORD	dwHow;
+} DIPROPHEADER,*LPDIPROPHEADER;
+typedef const DIPROPHEADER *LPCDIPROPHEADER;
+
+#define DIPH_DEVICE	0
+#define DIPH_BYOFFSET	1
+#define DIPH_BYID	2
+#define DIPH_BYUSAGE	3
+
+#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage)
+
+typedef struct DIPROPDWORD {
+	DIPROPHEADER	diph;
+	DWORD		dwData;
+} DIPROPDWORD, *LPDIPROPDWORD;
+typedef const DIPROPDWORD *LPCDIPROPDWORD;
+
+typedef struct DIPROPRANGE {
+	DIPROPHEADER	diph;
+	LONG		lMin;
+	LONG		lMax;
+} DIPROPRANGE, *LPDIPROPRANGE;
+typedef const DIPROPRANGE *LPCDIPROPRANGE;
+
+#define DIPROPRANGE_NOMIN	((LONG)0x80000000)
+#define DIPROPRANGE_NOMAX	((LONG)0x7FFFFFFF)
+
+typedef struct DIPROPCAL {
+	DIPROPHEADER diph;
+	LONG	lMin;
+	LONG	lCenter;
+	LONG	lMax;
+} DIPROPCAL, *LPDIPROPCAL;
+typedef const DIPROPCAL *LPCDIPROPCAL;
+
+typedef struct DIPROPGUIDANDPATH {
+	DIPROPHEADER diph;
+	GUID    guidClass;
+	WCHAR   wszPath[MAX_PATH];
+} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH;
+typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
+
+/* special property GUIDs */
+#ifdef __cplusplus
+#define MAKEDIPROP(prop)	(*(const GUID *)(prop))
+#else
+#define MAKEDIPROP(prop)	((REFGUID)(prop))
+#endif
+#define DIPROP_BUFFERSIZE	MAKEDIPROP(1)
+#define DIPROP_AXISMODE		MAKEDIPROP(2)
+
+#define DIPROPAXISMODE_ABS	0
+#define DIPROPAXISMODE_REL	1
+
+#define DIPROP_GRANULARITY	MAKEDIPROP(3)
+#define DIPROP_RANGE		MAKEDIPROP(4)
+#define DIPROP_DEADZONE		MAKEDIPROP(5)
+#define DIPROP_SATURATION	MAKEDIPROP(6)
+#define DIPROP_FFGAIN		MAKEDIPROP(7)
+#define DIPROP_FFLOAD		MAKEDIPROP(8)
+#define DIPROP_AUTOCENTER	MAKEDIPROP(9)
+
+#define DIPROPAUTOCENTER_OFF	0
+#define DIPROPAUTOCENTER_ON	1
+
+#define DIPROP_CALIBRATIONMODE	MAKEDIPROP(10)
+
+#define DIPROPCALIBRATIONMODE_COOKED	0
+#define DIPROPCALIBRATIONMODE_RAW	1
+
+#define DIPROP_CALIBRATION	MAKEDIPROP(11)
+#define DIPROP_GUIDANDPATH	MAKEDIPROP(12)
+
+typedef struct DIDEVCAPS_DX3 {
+    DWORD	dwSize;
+    DWORD	dwFlags;
+    DWORD	dwDevType;
+    DWORD	dwAxes;
+    DWORD	dwButtons;
+    DWORD	dwPOVs;
+} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3;
+
+typedef struct DIDEVCAPS {
+    DWORD	dwSize;
+    DWORD	dwFlags;
+    DWORD	dwDevType;
+    DWORD	dwAxes;
+    DWORD	dwButtons;
+    DWORD	dwPOVs;
+#if(DIRECTINPUT_VERSION >= 0x0500)
+    DWORD	dwFFSamplePeriod;
+    DWORD	dwFFMinTimeResolution;
+    DWORD	dwFirmwareRevision;
+    DWORD	dwHardwareRevision;
+    DWORD	dwFFDriverVersion;
+#endif /* DIRECTINPUT_VERSION >= 0x0500 */
+} DIDEVCAPS,*LPDIDEVCAPS;
+
+#define DIDC_ATTACHED		0x00000001
+#define DIDC_POLLEDDEVICE	0x00000002
+#define DIDC_EMULATED		0x00000004
+#define DIDC_POLLEDDATAFORMAT	0x00000008
+#define DIDC_FORCEFEEDBACK	0x00000100
+#define DIDC_FFATTACK		0x00000200
+#define DIDC_FFFADE		0x00000400
+#define DIDC_SATURATION		0x00000800
+#define DIDC_POSNEGCOEFFICIENTS	0x00001000
+#define DIDC_POSNEGSATURATION	0x00002000
+#define DIDC_DEADBAND		0x00004000
+#define DIDC_STARTDELAY		0x00008000
+#define DIDC_ALIAS		0x00010000
+#define DIDC_PHANTOM		0x00020000
+#define DIDC_HIDDEN		0x00040000
+
+
+/* SetCooperativeLevel dwFlags */
+#define DISCL_EXCLUSIVE		0x00000001
+#define DISCL_NONEXCLUSIVE	0x00000002
+#define DISCL_FOREGROUND	0x00000004
+#define DISCL_BACKGROUND	0x00000008
+
+
+#define DIEFT_ALL		0x00000000
+                                                                                
+#define DIEFT_CONSTANTFORCE	0x00000001
+#define DIEFT_RAMPFORCE		0x00000002
+#define DIEFT_PERIODIC		0x00000003
+#define DIEFT_CONDITION		0x00000004
+#define DIEFT_CUSTOMFORCE	0x00000005
+#define DIEFT_HARDWARE		0x000000FF
+#define DIEFT_FFATTACK		0x00000200
+#define DIEFT_FFFADE		0x00000400
+#define DIEFT_SATURATION	0x00000800
+#define DIEFT_POSNEGCOEFFICIENTS 0x00001000
+#define DIEFT_POSNEGSATURATION	0x00002000
+#define DIEFT_DEADBAND		0x00004000
+#define DIEFT_STARTDELAY	0x00008000
+#define DIEFT_GETTYPE(n)	LOBYTE(n)
+                                                                                
+#define DI_DEGREES		100
+#define DI_FFNOMINALMAX		10000
+#define DI_SECONDS		1000000
+
+typedef struct DICONSTANTFORCE {
+	LONG			lMagnitude;
+} DICONSTANTFORCE, *LPDICONSTANTFORCE;
+typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE;
+
+typedef struct DIRAMPFORCE {
+	LONG			lStart;
+	LONG			lEnd;
+} DIRAMPFORCE, *LPDIRAMPFORCE;
+typedef const DIRAMPFORCE *LPCDIRAMPFORCE;
+
+typedef struct DIPERIODIC {
+	DWORD			dwMagnitude;
+	LONG			lOffset;
+	DWORD			dwPhase;
+	DWORD			dwPeriod;
+} DIPERIODIC, *LPDIPERIODIC;
+typedef const DIPERIODIC *LPCDIPERIODIC;
+
+typedef struct DICONDITION {
+	LONG			lOffset;
+	LONG			lPositiveCoefficient;
+	LONG			lNegativeCoefficient;
+	DWORD			dwPositiveSaturation;
+	DWORD			dwNegativeSaturation;
+	LONG			lDeadBand;
+} DICONDITION, *LPDICONDITION;
+typedef const DICONDITION *LPCDICONDITION;
+
+typedef struct DICUSTOMFORCE {
+	DWORD			cChannels;
+	DWORD			dwSamplePeriod;
+	DWORD			cSamples;
+	LPLONG			rglForceData;
+} DICUSTOMFORCE, *LPDICUSTOMFORCE;
+typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE;
+
+typedef struct DIENVELOPE {
+	DWORD			dwSize;
+	DWORD			dwAttackLevel;
+	DWORD			dwAttackTime;
+	DWORD			dwFadeLevel;
+	DWORD			dwFadeTime;
+} DIENVELOPE, *LPDIENVELOPE;
+typedef const DIENVELOPE *LPCDIENVELOPE;
+
+typedef struct DIEFFECT_DX5 {
+	DWORD			dwSize;
+	DWORD			dwFlags;
+	DWORD			dwDuration;
+	DWORD			dwSamplePeriod;
+	DWORD			dwGain;
+	DWORD			dwTriggerButton;
+	DWORD			dwTriggerRepeatInterval;
+	DWORD			cAxes;
+	LPDWORD			rgdwAxes;
+	LPLONG			rglDirection;
+	LPDIENVELOPE		lpEnvelope;
+	DWORD			cbTypeSpecificParams;
+	LPVOID			lpvTypeSpecificParams;
+} DIEFFECT_DX5, *LPDIEFFECT_DX5;
+typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5;
+
+typedef struct DIEFFECT {
+	DWORD			dwSize;
+	DWORD			dwFlags;
+	DWORD			dwDuration;
+	DWORD			dwSamplePeriod;
+	DWORD			dwGain;
+	DWORD			dwTriggerButton;
+	DWORD			dwTriggerRepeatInterval;
+	DWORD			cAxes;
+	LPDWORD			rgdwAxes;
+	LPLONG			rglDirection;
+	LPDIENVELOPE		lpEnvelope;
+	DWORD			cbTypeSpecificParams;
+	LPVOID			lpvTypeSpecificParams;
[truncated at 1000 lines; 1353 more skipped]

reactos/include
WinDNS.h 1.3 -> 1.3.22.1
diff -u -r1.3 -r1.3.22.1
--- WinDNS.h	30 Dec 2003 11:53:35 -0000	1.3
+++ WinDNS.h	8 Dec 2004 21:56:56 -0000	1.3.22.1
@@ -12,6 +12,9 @@
 #define WINDNS_H
 
 /* The WinDNS Header */
+#ifdef __USE_W32API
+#include_next <windns.h>
+#else
 
 /* Constants provided by DNSAPI */
 #define DNS_CONFIG_FLAG_ALLOC TRUE
@@ -441,5 +444,6 @@
   } Data;
 } XNAME(DNS_RECORD), *XNAME(PDNS_RECORD);
 
+#endif /* __USE_W32API */
 #endif /* _WINDNS_STRUCT_DEFINITIONS */
 

reactos/include
funcs.h 1.65 -> 1.65.2.1
diff -u -r1.65 -r1.65.2.1
--- funcs.h	24 Oct 2004 20:37:25 -0000	1.65
+++ funcs.h	8 Dec 2004 21:56:56 -0000	1.65.2.1
@@ -1352,9 +1352,9 @@
 NTSTATUS
 STDCALL
 NtAllocateUserPhysicalPages(
-	IN HANDLE ProcessHandle,
-	IN PULONG NumberOfPages,
-	OUT PULONG PageFrameNumbers
+	IN HANDLE  ProcessHandle,
+	IN OUT PULONG_PTR  NumberOfPages,
+	OUT PULONG_PTR  UserPfnArray
 	);
 
 NTSTATUS
@@ -1396,8 +1396,8 @@
 STDCALL
 NtFreeUserPhysicalPages(
 	IN HANDLE ProcessHandle,
-	IN OUT PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN OUT PULONG_PTR NumberOfPages,
+	IN PULONG_PTR UserPfnArray
 	);
 
 NTSTATUS
@@ -1434,17 +1434,17 @@
 NTSTATUS
 STDCALL
 NtMapUserPhysicalPages(
-	IN PVOID BaseAddress,
-	IN PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN PVOID VirtualAddress,
+	IN ULONG_PTR NumberOfPages,
+	IN PULONG_PTR PageArray  OPTIONAL
 	);
 
 NTSTATUS
 STDCALL
 NtMapUserPhysicalPagesScatter(
-	IN PVOID *BaseAddresses,
-	IN PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN PVOID *VirtualAddresses,
+	IN ULONG_PTR NumberOfPages,
+	IN PULONG_PTR PageArray  OPTIONAL
 	);
 
 NTSTATUS
@@ -1782,9 +1782,9 @@
 NTSTATUS
 STDCALL
 ZwAllocateUserPhysicalPages(
-	IN HANDLE ProcessHandle,
-	IN PULONG NumberOfPages,
-	OUT PULONG PageFrameNumbers
+	IN HANDLE  ProcessHandle,
+	IN OUT PULONG_PTR  NumberOfPages,
+	OUT PULONG_PTR  UserPfnArray
 	);
 
 NTSTATUS
@@ -1843,8 +1843,8 @@
 STDCALL
 ZwFreeUserPhysicalPages(
 	IN HANDLE ProcessHandle,
-	IN OUT PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN OUT PULONG_PTR NumberOfPages,
+	IN PULONG_PTR UserPfnArray
 	);
 
 NTSTATUS
@@ -1881,17 +1881,17 @@
 NTSTATUS
 STDCALL
 ZwMapUserPhysicalPages(
-	IN PVOID BaseAddress,
-	IN PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN PVOID VirtualAddress,
+	IN ULONG_PTR NumberOfPages,
+	IN PULONG_PTR PageArray  OPTIONAL
 	);
 
 NTSTATUS
 STDCALL
 ZwMapUserPhysicalPagesScatter(
-	IN PVOID *BaseAddresses,
-	IN PULONG NumberOfPages,
-	IN PULONG PageFrameNumbers
+	IN PVOID *VirtualAddresses,
+	IN ULONG_PTR NumberOfPages,
+	IN PULONG_PTR PageArray  OPTIONAL
 	);
 
 NTSTATUS
@@ -3004,7 +3004,7 @@
 AllocateUserPhysicalPages(
     HANDLE hProcess,
     PULONG_PTR NumberOfPages,
-    PULONG_PTR PageArray
+    PULONG_PTR UserPfnArray
     );
 
 WINBOOL
@@ -3191,7 +3191,7 @@
 FreeUserPhysicalPages(
     HANDLE hProcess,
     PULONG_PTR NumberOfPages,
-    PULONG_PTR PageArray
+    PULONG_PTR UserPfnArray
     );
 
 WINBOOL

reactos/include
tgetopt.h 1.1 -> 1.1.32.1
diff -u -r1.1 -r1.1.32.1
--- tgetopt.h	6 Jul 2003 23:04:18 -0000	1.1
+++ tgetopt.h	8 Dec 2004 21:56:56 -0000	1.1.32.1
@@ -32,11 +32,11 @@
 
 extern char *optarg;
 extern int optind;
-^Mextern int opterr;
+extern int opterr;
 extern int optopt;
 
 extern wchar_t *_woptarg;
-^Mextern int _woptind;
+extern int _woptind;
 extern int _wopterr;
 extern int _woptopt;
 
@@ -74,7 +74,7 @@
 		               const struct _woption *longopts, int *longind);
 
 extern int _getopt_internal (int argc, char *const *argv,
-^M			     const char *shortopts, const struct option *longopts, int *longind,
+			     const char *shortopts, const struct option *longopts, int *longind,
 			     int long_only);
 
 extern int _wgetopt_internal (int argc, wchar_t *const *argv,
@@ -83,7 +83,7 @@
 			       int long_only);
 
 #ifdef	__cplusplus
-^M}
+}
 #endif
 
 #endif /* _GETOPT_H */

reactos/include
mmsystem.h removed after 1.1
diff -N mmsystem.h
--- mmsystem.h	15 Dec 2003 20:21:57 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,2224 +0,0 @@
-/*
- * MMSYSTEM - Multimedia Wine Extension ... :-)
- *
- * Copyright (C) the Wine project
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __WINE_MMSYSTEM_H
-#define __WINE_MMSYSTEM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef LPSTR		HPSTR;          /* a huge version of LPSTR */
-typedef LPCSTR		HPCSTR;         /* a huge version of LPCSTR */
-#ifndef __REACTOS__
-typedef UINT*           LPUINT;
-#endif
-
-DECLARE_HANDLE(HDRVR);
-DECLARE_HANDLE(HWAVE);
-DECLARE_HANDLE(HWAVEIN);
-DECLARE_HANDLE(HWAVEOUT);
-DECLARE_HANDLE(HMIDI);
-DECLARE_HANDLE(HMIDIIN);
-DECLARE_HANDLE(HMIDIOUT);
-DECLARE_HANDLE(HMIDISTRM);
-DECLARE_HANDLE(HMIXER);
-DECLARE_HANDLE(HMIXEROBJ);
-DECLARE_HANDLE(HMMIO);
-
-typedef HMIDI *LPHMIDI;
-typedef HMIDIIN *LPHMIDIIN;
-typedef HMIDIOUT *LPHMIDIOUT;
-typedef HMIDISTRM *LPHMIDISTRM;
-typedef HMIXER *LPHMIXER;
-typedef HMIXEROBJ *LPHMIXEROBJ;
-typedef HWAVEIN *LPHWAVEIN;
-typedef HWAVEOUT *LPHWAVEOUT;
-
-#include <pshpack1.h>
-
-typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
-
-#define MAXWAVEDRIVERS	10
-#define MAXMIDIDRIVERS	10
-#define MAXAUXDRIVERS	10
-#define MAXMCIDRIVERS	32
-#define MAXMIXERDRIVERS	10
-
-#define MAXPNAMELEN      32     /* max product name length (including NULL) */
-#define MAXERRORLENGTH   128    /* max error text length (including NULL) */
-#define MAX_JOYSTICKOEMVXDNAME	260
-
-#ifndef _MCIERROR_
-#define _MCIERROR_
-typedef DWORD   MCIERROR;
-#endif
-typedef UINT	MMVERSION;
-#ifndef _MCIDEVICEID_
-#define _MCIDEVICEID_
-typedef UINT	MCIDEVICEID;
-#endif
-typedef	UINT	MMRESULT;
-
-typedef struct {
-    UINT    wType;
-    union {
-	DWORD ms;
-	DWORD sample;
-	DWORD cb;
-        DWORD ticks;
-	struct {
-	    BYTE hour;
-	    BYTE min;
-	    BYTE sec;
-	    BYTE frame;
-	    BYTE fps;
-	    BYTE dummy;
-	    BYTE pad[2];
-	} smpte;
-	struct {
-	    DWORD songptrpos;
-	} midi;
-    } u;
-} MMTIME,  *LPMMTIME;
-
-#define TIME_MS         0x0001  /* time in milliseconds */
-#define TIME_SAMPLES    0x0002  /* number of wave samples */
-#define TIME_BYTES      0x0004  /* current byte offset */
-#define TIME_SMPTE      0x0008  /* SMPTE time */
-#define TIME_MIDI       0x0010  /* MIDI time */
-#define TIME_TICKS	0x0020  /* MIDI ticks */
-
-#define MM_JOY1MOVE         0x3A0           /* joystick */
-#define MM_JOY2MOVE         0x3A1
-#define MM_JOY1ZMOVE        0x3A2
-#define MM_JOY2ZMOVE        0x3A3
-#define MM_JOY1BUTTONDOWN   0x3B5
-#define MM_JOY2BUTTONDOWN   0x3B6
-#define MM_JOY1BUTTONUP     0x3B7
-#define MM_JOY2BUTTONUP     0x3B8
-
-#define MM_MCINOTIFY        0x3B9           /* MCI */
-
-#define MM_WOM_OPEN         0x3BB           /* waveform output */
-#define MM_WOM_CLOSE        0x3BC
-#define MM_WOM_DONE         0x3BD
-
-#define MM_WIM_OPEN         0x3BE           /* waveform input */
-#define MM_WIM_CLOSE        0x3BF
-#define MM_WIM_DATA         0x3C0
-
-#define MM_MIM_OPEN         0x3C1           /* MIDI input */
-#define MM_MIM_CLOSE        0x3C2
-#define MM_MIM_DATA         0x3C3
-#define MM_MIM_LONGDATA     0x3C4
-#define MM_MIM_ERROR        0x3C5
-#define MM_MIM_LONGERROR    0x3C6
-
-#define MM_MOM_OPEN         0x3C7           /* MIDI output */
-#define MM_MOM_CLOSE        0x3C8
-#define MM_MOM_DONE         0x3C9
-#define MM_MOM_POSITIONCB   0x3CA
-
-#define MM_MIM_MOREDATA     0x3CC
-
-#define MM_MIXM_LINE_CHANGE 0x3D0
-#define MM_MIXM_CONTROL_CHANGE 0x3D1
-
-#define MMSYSERR_BASE          0
-#define WAVERR_BASE            32
-#define MIDIERR_BASE           64
-#define TIMERR_BASE            96
-#define JOYERR_BASE            160
-#define MCIERR_BASE            256
-
-#define MCI_STRING_OFFSET      512
-#define MCI_VD_OFFSET          1024
-#define MCI_CD_OFFSET          1088
-#define MCI_WAVE_OFFSET        1152
-#define MCI_SEQ_OFFSET         1216
-
-#define MMSYSERR_NOERROR      	0                    /* no error */
-#define MMSYSERR_ERROR        	(MMSYSERR_BASE + 1)  /* unspecified error */
-#define MMSYSERR_BADDEVICEID  	(MMSYSERR_BASE + 2)  /* device ID out of range */
-#define MMSYSERR_NOTENABLED   	(MMSYSERR_BASE + 3)  /* driver failed enable */
-#define MMSYSERR_ALLOCATED    	(MMSYSERR_BASE + 4)  /* device already allocated */
-#define MMSYSERR_INVALHANDLE  	(MMSYSERR_BASE + 5)  /* device handle is invalid */
-#define MMSYSERR_NODRIVER     	(MMSYSERR_BASE + 6)  /* no device driver present */
-#define MMSYSERR_NOMEM        	(MMSYSERR_BASE + 7)  /* memory allocation error */
-#define MMSYSERR_NOTSUPPORTED 	(MMSYSERR_BASE + 8)  /* function isn't supported */
-#define MMSYSERR_BADERRNUM    	(MMSYSERR_BASE + 9)  /* error value out of range */
-#define MMSYSERR_INVALFLAG    	(MMSYSERR_BASE + 10) /* invalid flag passed */
-#define MMSYSERR_INVALPARAM   	(MMSYSERR_BASE + 11) /* invalid parameter passed */
-#define MMSYSERR_LASTERROR    	(MMSYSERR_BASE + 11) /* last error in range */
-
-#define CALLBACK_TYPEMASK   	0x00070000l    	/* callback type mask */
-#define CALLBACK_NULL       	0x00000000l    	/* no callback */
-#define CALLBACK_WINDOW     	0x00010000l    	/* dwCallback is a HWND */
-#define CALLBACK_TASK       	0x00020000l    	/* dwCallback is a HTASK */
-#define CALLBACK_THREAD		(CALLBACK_TASK)	/* dwCallback is a thread ID */
-#define CALLBACK_FUNCTION   	0x00030000l    	/* dwCallback is a FARPROC */
-#define CALLBACK_EVENT		0x00050000l	/* dwCallback is an EVENT Handler */
-
-#define DRV_LOAD                0x0001
-#define DRV_ENABLE              0x0002
-#define DRV_OPEN                0x0003
-#define DRV_CLOSE               0x0004
-#define DRV_DISABLE             0x0005
-#define DRV_FREE                0x0006
-#define DRV_CONFIGURE           0x0007
-#define DRV_QUERYCONFIGURE      0x0008
-#define DRV_INSTALL             0x0009
-#define DRV_REMOVE              0x000A
-#define DRV_EXITSESSION         0x000B
-#define DRV_EXITAPPLICATION     0x000C
-#define DRV_POWER               0x000F
-
-#define DRV_RESERVED            0x0800
-#define DRV_USER                0x4000
-
-#define DRVCNF_CANCEL           0x0000
-#define DRVCNF_OK               0x0001
-#define DRVCNF_RESTART 		0x0002
-
-#define DRVEA_NORMALEXIT  	0x0001
-#define DRVEA_ABNORMALEXIT 	0x0002
-
-#define DRV_SUCCESS		0x0001
-#define DRV_FAILURE		0x0000
-
-#define GND_FIRSTINSTANCEONLY 	0x00000001
-
-#define GND_FORWARD  		0x00000000
-#define GND_REVERSE    		0x00000002
-
-typedef struct {
-    DWORD   			dwDCISize;
-    LPCWSTR  			lpszDCISectionName;
-    LPCWSTR  			lpszDCIAliasName;
-} DRVCONFIGINFO, *LPDRVCONFIGINFO;
-
-
-LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hdrvr,
-			     UINT Msg, LPARAM lParam1, LPARAM lParam2);
-/* this sounds odd, but it's the way it is. OpenDriverA even disapeared
- * from latest SDK
- */
-HDRVR 	WINAPI OpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName,
-			   LPARAM lParam2);
-HDRVR 	WINAPI OpenDriver(LPCWSTR szDriverName, LPCWSTR szSectionName,
-                          LPARAM lParam2);
-LRESULT WINAPI CloseDriver(HDRVR hDriver, LPARAM lParam1, LPARAM lParam2);
-LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
-				 LPARAM lParam1, LPARAM lParam2);
-HMODULE WINAPI GetDriverModuleHandle(HDRVR hDriver);
-
-DWORD	WINAPI GetDriverFlags(HDRVR hDriver);
-
-typedef void (CALLBACK *LPDRVCALLBACK) (HDRVR h, UINT uMessage, DWORD dwUser, DWORD dw1, DWORD dw2);
-
-#define MM_MICROSOFT            1       /* Microsoft Corp. */
-
-#define MM_MIDI_MAPPER          1       /* MIDI Mapper */
-#define MM_WAVE_MAPPER          2       /* Wave Mapper */
-
-#define MM_SNDBLST_MIDIOUT      3       /* Sound Blaster MIDI output port */
-#define MM_SNDBLST_MIDIIN       4       /* Sound Blaster MIDI input port  */
-#define MM_SNDBLST_SYNTH        5       /* Sound Blaster internal synthesizer */
-#define MM_SNDBLST_WAVEOUT      6       /* Sound Blaster waveform output */
-#define MM_SNDBLST_WAVEIN       7       /* Sound Blaster waveform input */
-
-#define MM_ADLIB                9       /* Ad Lib-compatible synthesizer */
-
-#define MM_MPU401_MIDIOUT       10      /* MPU401-compatible MIDI output port */
-#define MM_MPU401_MIDIIN        11      /* MPU401-compatible MIDI input port */
-
-#define MM_PC_JOYSTICK          12      /* Joystick adapter */
-
-
-UINT 		WINAPI 	mmsystemGetVersion(void);
-BOOL 		WINAPI	sndPlaySoundA(LPCSTR lpszSound, UINT fuSound);
-BOOL 		WINAPI	sndPlaySoundW(LPCWSTR lpszSound, UINT fuSound);
-#define 		sndPlaySound WINELIB_NAME_AW(sndPlaySound)
-BOOL 		WINAPI 	PlaySoundA(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
-BOOL 		WINAPI 	PlaySoundW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound);
-#define 		PlaySound WINELIB_NAME_AW(PlaySound)
-
-#define SND_SYNC            	0x0000  /* play synchronously (default) */
-#define SND_ASYNC           	0x0001  /* play asynchronously */
-#define SND_NODEFAULT       	0x0002  /* don't use default sound */
-#define SND_MEMORY          	0x0004  /* lpszSoundName points to a memory file */
-#define SND_LOOP            	0x0008  /* loop the sound until next sndPlaySound */
-#define SND_NOSTOP          	0x0010  /* don't stop any currently playing sound */
-
-#define SND_NOWAIT		0x00002000L /* don't wait if the driver is busy */
-#define SND_ALIAS       	0x00010000L /* name is a registry alias */
-#define SND_ALIAS_ID		0x00110000L /* alias is a predefined ID */
-#define SND_FILENAME    	0x00020000L /* name is file name */
-#define SND_RESOURCE    	0x00040004L /* name is resource name or atom */
-#define SND_PURGE		0x00000040L /* purge all sounds */
-#define SND_APPLICATION     	0x00000080L /* look for application specific association */
-
-/* waveform audio error return values */
-#define WAVERR_BADFORMAT      (WAVERR_BASE + 0)    /* unsupported wave format */
-#define WAVERR_STILLPLAYING   (WAVERR_BASE + 1)    /* still something playing */
-#define WAVERR_UNPREPARED     (WAVERR_BASE + 2)    /* header not prepared */
-#define WAVERR_SYNC           (WAVERR_BASE + 3)    /* device is synchronous */
-#define WAVERR_LASTERROR      (WAVERR_BASE + 3)    /* last error in range */
-
-typedef LPDRVCALLBACK LPWAVECALLBACK;
-
-#define WOM_OPEN        MM_WOM_OPEN
-#define WOM_CLOSE       MM_WOM_CLOSE
-#define WOM_DONE        MM_WOM_DONE
-#define WIM_OPEN        MM_WIM_OPEN
-#define WIM_CLOSE       MM_WIM_CLOSE
-#define WIM_DATA        MM_WIM_DATA
-
-#define WAVE_MAPPER     (-1)
-
-#define  WAVE_FORMAT_QUERY     		0x0001
-#define  WAVE_ALLOWSYNC        		0x0002
-#define  WAVE_MAPPED               	0x0004
-#define  WAVE_FORMAT_DIRECT        	0x0008
-#define  WAVE_FORMAT_DIRECT_QUERY  	(WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT)
-
-typedef struct wavehdr_tag {
-    LPSTR       lpData;		/* pointer to locked data buffer */
-    DWORD       dwBufferLength;	/* length of data buffer */
-    DWORD       dwBytesRecorded;/* used for input only */
-    DWORD       dwUser;		/* for client's use */
-    DWORD       dwFlags;	/* assorted flags (see defines) */
-    DWORD       dwLoops;	/* loop control counter */
-
-    struct wavehdr_tag *lpNext;	/* reserved for driver */
-    DWORD       reserved;	/* reserved for driver */
-} WAVEHDR, *PWAVEHDR, *NPWAVEHDR, *LPWAVEHDR;
-
-#define WHDR_DONE       0x00000001  /* done bit */
-#define WHDR_PREPARED   0x00000002  /* set if this header has been prepared */
-#define WHDR_BEGINLOOP  0x00000004  /* loop start block */
-#define WHDR_ENDLOOP    0x00000008  /* loop end block */
-#define WHDR_INQUEUE    0x00000010  /* reserved for driver */
-
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    CHAR	szPname[MAXPNAMELEN];	/* product name (0 terminated string) */
-    DWORD	dwFormats;		/* formats supported */
-    WORD	wChannels;		/* number of sources supported */
-    WORD	wReserved1;		/* padding */
-    DWORD	dwSupport;		/* functionality supported by driver */
-} WAVEOUTCAPSA, *LPWAVEOUTCAPSA;
-
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    WCHAR	szPname[MAXPNAMELEN];	/* product name (0 terminated string) */
-    DWORD	dwFormats;		/* formats supported */
-    WORD	wChannels;		/* number of sources supported */
-    WORD	wReserved1;		/* padding */
-    DWORD	dwSupport;		/* functionality supported by driver */
-} WAVEOUTCAPSW, *LPWAVEOUTCAPSW;
-//////DECL_WINELIB_TYPE_AW(WAVEOUTCAPS)
-////DECL_WINELIB_TYPE_AW(LPWAVEOUTCAPS)
-
-#define WAVECAPS_PITCH          0x0001   /* supports pitch control */
-#define WAVECAPS_PLAYBACKRATE   0x0002   /* supports playback rate control */
-#define WAVECAPS_VOLUME         0x0004   /* supports volume control */
-#define WAVECAPS_LRVOLUME       0x0008   /* separate left-right volume control */
-#define WAVECAPS_SYNC           0x0010	 /* driver is synchrounous and playing is blocking */
-#define WAVECAPS_SAMPLEACCURATE 0x0020	 /* position is sample accurate */
-#define WAVECAPS_DIRECTSOUND	0x0040   /* ? */
-
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    CHAR	szPname[MAXPNAMELEN];	/* product name (0 terminated string) */
-    DWORD	dwFormats;		/* formats supported */
-    WORD	wChannels;		/* number of channels supported */
-    WORD	wReserved1;
-} WAVEINCAPSA, *LPWAVEINCAPSA;
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    WCHAR	szPname[MAXPNAMELEN];	/* product name (0 terminated string) */
-    DWORD	dwFormats;		/* formats supported */
-    WORD	wChannels;		/* number of channels supported */
-    WORD	wReserved1;
-} WAVEINCAPSW, *LPWAVEINCAPSW;
-//DECL_WINELIB_TYPE_AW(WAVEINCAPS)
-//DECL_WINELIB_TYPE_AW(LPWAVEINCAPS)
-
-#define WAVE_INVALIDFORMAT     0x00000000    /* invalid format */
-#define WAVE_FORMAT_1M08       0x00000001    /* 11.025 kHz, Mono,   8-bit  */
-#define WAVE_FORMAT_1S08       0x00000002    /* 11.025 kHz, Stereo, 8-bit  */
-#define WAVE_FORMAT_1M16       0x00000004    /* 11.025 kHz, Mono,   16-bit */
-#define WAVE_FORMAT_1S16       0x00000008    /* 11.025 kHz, Stereo, 16-bit */
-#define WAVE_FORMAT_2M08       0x00000010    /* 22.05  kHz, Mono,   8-bit  */
-#define WAVE_FORMAT_2S08       0x00000020    /* 22.05  kHz, Stereo, 8-bit  */
-#define WAVE_FORMAT_2M16       0x00000040    /* 22.05  kHz, Mono,   16-bit */
-#define WAVE_FORMAT_2S16       0x00000080    /* 22.05  kHz, Stereo, 16-bit */
-#define WAVE_FORMAT_4M08       0x00000100    /* 44.1   kHz, Mono,   8-bit  */
-#define WAVE_FORMAT_4S08       0x00000200    /* 44.1   kHz, Stereo, 8-bit  */
-#define WAVE_FORMAT_4M16       0x00000400    /* 44.1   kHz, Mono,   16-bit */
-#define WAVE_FORMAT_4S16       0x00000800    /* 44.1   kHz, Stereo, 16-bit */
-#define WAVE_FORMAT_48M08      0x00001000    /* 48     kHz, Mono,   8-bit  */
-#define WAVE_FORMAT_48S08      0x00002000    /* 48     kHz, Stereo, 8-bit  */
-#define WAVE_FORMAT_48M16      0x00004000    /* 48     kHz, Mono,   16-bit */
-#define WAVE_FORMAT_48S16      0x00008000    /* 48     kHz, Stereo, 16-bit */
-#define WAVE_FORMAT_96M08      0x00010000    /* 96     kHz, Mono,   8-bit  */
-#define WAVE_FORMAT_96S08      0x00020000    /* 96     kHz, Stereo, 8-bit  */
-#define WAVE_FORMAT_96M16      0x00040000    /* 96     kHz, Mono,   16-bit */
-#define WAVE_FORMAT_96S16      0x00080000    /* 96     kHz, Stereo, 16-bit */
-
-/* General format structure common to all formats, same for Win16 and Win32 */
-typedef struct {
-    WORD	wFormatTag;	/* format type */
-    WORD	nChannels;	/* number of channels */
-    DWORD	nSamplesPerSec;	/* sample rate */
-    DWORD	nAvgBytesPerSec;/* for buffer estimation */
-    WORD	nBlockAlign; 	/* block size of data */
-} WAVEFORMAT, *LPWAVEFORMAT;
-
-#define WAVE_FORMAT_PCM     1
-
-typedef struct {
-    WAVEFORMAT	wf;
-    WORD	wBitsPerSample;
-} PCMWAVEFORMAT, *LPPCMWAVEFORMAT;
-
-#ifndef _WAVEFORMATEX_
-#define _WAVEFORMATEX_
-/* dito same for Win16 / Win32 */
-typedef struct {
-    WORD	wFormatTag;	/* format type */
-    WORD	nChannels;	/* number of channels (i.e. mono, stereo...) */
-    DWORD	nSamplesPerSec;	/* sample rate */
-    DWORD	nAvgBytesPerSec;/* for buffer estimation */
-    WORD	nBlockAlign;	/* block size of data */
-    WORD	wBitsPerSample;	/* number of bits per sample of mono data */
-    WORD	cbSize;		/* the count in bytes of the size of */
-				/* extra information (after cbSize) */
-} WAVEFORMATEX, *LPWAVEFORMATEX, *NPWAVEFORMATEX, *PWAVEFORMATEX;
-#endif
-
-UINT 		WINAPI 	waveOutGetNumDevs(void);
-UINT 		WINAPI 	waveOutGetDevCapsA(UINT,LPWAVEOUTCAPSA,UINT);
-UINT 		WINAPI	waveOutGetDevCapsW(UINT,LPWAVEOUTCAPSW,UINT);
-#define 		waveOutGetDevCaps WINELIB_NAME_AW(waveOutGetDevCaps)
-UINT 		WINAPI	waveOutGetVolume(HWAVEOUT,DWORD*);
-UINT 		WINAPI 	waveOutSetVolume(HWAVEOUT,DWORD);
-UINT 		WINAPI 	waveOutGetErrorTextA(UINT,LPSTR,UINT);
-UINT 		WINAPI 	waveOutGetErrorTextW(UINT,LPWSTR,UINT);
-#define 	    	waveOutGetErrorText WINELIB_NAME_AW(waveOutGetErrorText)
-UINT 		WINAPI 	waveOutOpen(HWAVEOUT*,UINT,const LPWAVEFORMATEX,DWORD,DWORD,DWORD);
-UINT 		WINAPI 	waveOutClose(HWAVEOUT);
-UINT 		WINAPI 	waveOutPrepareHeader(HWAVEOUT,WAVEHDR*,UINT);
-UINT 		WINAPI 	waveOutUnprepareHeader(HWAVEOUT,WAVEHDR*,UINT);
-UINT 		WINAPI 	waveOutWrite(HWAVEOUT,WAVEHDR*,UINT);
-UINT 		WINAPI 	waveOutPause(HWAVEOUT);
-UINT 		WINAPI 	waveOutRestart(HWAVEOUT);
-UINT 		WINAPI 	waveOutReset(HWAVEOUT);
-UINT 		WINAPI 	waveOutBreakLoop(HWAVEOUT);
-UINT 		WINAPI 	waveOutGetPosition(HWAVEOUT,LPMMTIME,UINT);
-UINT 		WINAPI 	waveOutGetPitch(HWAVEOUT,DWORD*);
-UINT 		WINAPI 	waveOutSetPitch(HWAVEOUT,DWORD);
-UINT 		WINAPI 	waveOutGetPlaybackRate(HWAVEOUT,DWORD*);
-UINT 		WINAPI 	waveOutSetPlaybackRate(HWAVEOUT,DWORD);
-UINT 		WINAPI 	waveOutGetID(HWAVEOUT,UINT*);
-UINT 		WINAPI 	waveOutMessage(HWAVEOUT,UINT,DWORD,DWORD);
-UINT 		WINAPI 	waveInGetNumDevs(void);
-UINT 		WINAPI 	waveInGetDevCapsA(UINT,LPWAVEINCAPSA,UINT);
-UINT 		WINAPI 	waveInGetDevCapsW(UINT,LPWAVEINCAPSW,UINT);
-#define 		waveInGetDevCaps WINELIB_NAME_AW(waveInGetDevCaps)
-UINT 		WINAPI 	waveInGetErrorTextA(UINT,LPSTR,UINT);
-UINT 		WINAPI 	waveInGetErrorTextW(UINT,LPWSTR,UINT);
-#define 		waveInGetErrorText WINELIB_NAME_AW(waveInGetErrorText)
-UINT 		WINAPI  waveInOpen(HWAVEIN*,UINT,const LPWAVEFORMATEX,DWORD,DWORD,DWORD);
-UINT 		WINAPI  waveInClose(HWAVEIN);
-UINT 		WINAPI  waveInPrepareHeader(HWAVEIN,WAVEHDR*,UINT);
-UINT 		WINAPI  waveInUnprepareHeader(HWAVEIN,WAVEHDR*,UINT);
-UINT 		WINAPI  waveInAddBuffer(HWAVEIN,WAVEHDR*,UINT);
-UINT 		WINAPI  waveInStart(HWAVEIN);
-UINT 		WINAPI  waveInStop(HWAVEIN);
-UINT 		WINAPI  waveInReset(HWAVEIN);
-UINT 		WINAPI  waveInGetPosition(HWAVEIN,LPMMTIME,UINT);
-UINT 		WINAPI  waveInGetID(HWAVEIN,UINT*);
-UINT 		WINAPI 	waveInMessage(HWAVEIN,UINT,DWORD,DWORD);
-
-#define MIDIERR_UNPREPARED    (MIDIERR_BASE + 0)   /* header not prepared */
-#define MIDIERR_STILLPLAYING  (MIDIERR_BASE + 1)   /* still something playing */
-#define MIDIERR_NOMAP         (MIDIERR_BASE + 2)   /* no current map */
-#define MIDIERR_NOTREADY      (MIDIERR_BASE + 3)   /* hardware is still busy */
-#define MIDIERR_NODEVICE      (MIDIERR_BASE + 4)   /* port no longer connected */
-#define MIDIERR_INVALIDSETUP  (MIDIERR_BASE + 5)   /* invalid setup */
-#define MIDIERR_LASTERROR     (MIDIERR_BASE + 5)   /* last error in range */
-
-typedef LPDRVCALLBACK LPMIDICALLBACK;
-#define MIDIPATCHSIZE   128
-typedef WORD PATCHARRAY[MIDIPATCHSIZE];
-typedef WORD *LPPATCHARRAY;
-typedef WORD KEYARRAY[MIDIPATCHSIZE];
-typedef WORD *LPKEYARRAY;
-
-#define MIM_OPEN        MM_MIM_OPEN
-#define MIM_CLOSE       MM_MIM_CLOSE
-#define MIM_DATA        MM_MIM_DATA
-#define MIM_LONGDATA    MM_MIM_LONGDATA
-#define MIM_ERROR       MM_MIM_ERROR
-#define MIM_LONGERROR   MM_MIM_LONGERROR
-#define MIM_MOREDATA	MM_MIM_MOREDATA
-
-#define MOM_OPEN        MM_MOM_OPEN
-#define MOM_CLOSE       MM_MOM_CLOSE
-#define MOM_DONE        MM_MOM_DONE
-#define MOM_POSITIONCB	MM_MOM_POSITIONCB
-
-/* device ID for MIDI mapper */
-
-#define MIDIMAPPER     (-1)
-#define MIDI_MAPPER    (-1)
-
-/* Only on Win95 and up */
-#define MIDI_IO_STATUS	0x00000020L
-
-/* flags for wFlags parm of
-	midiOutCachePatches(),
-	midiOutCacheDrumPatches() */
-#define MIDI_CACHE_ALL      1
-#define MIDI_CACHE_BESTFIT  2
-#define MIDI_CACHE_QUERY    3
-#define MIDI_UNCACHE        4
-
-typedef struct {
-    WORD	wMid;		/* manufacturer ID */
-    WORD	wPid;		/* product ID */
-    MMVERSION	vDriverVersion;	/* version of the driver */
-    CHAR	szPname[MAXPNAMELEN];/* product name (NULL terminated string) */
-    WORD	wTechnology;	/* type of device */
-    WORD	wVoices;	/* # of voices (internal synth only) */
-    WORD	wNotes;		/* max # of notes (internal synth only) */
-    WORD	wChannelMask;	/* channels used (internal synth only) */
-    DWORD	dwSupport;	/* functionality supported by driver */
-} MIDIOUTCAPSA, *LPMIDIOUTCAPSA;
-
-typedef struct {
-    WORD	wMid;		/* manufacturer ID */
-    WORD	wPid;		/* product ID */
-    MMVERSION	vDriverVersion;	/* version of the driver */
-    WCHAR	szPname[MAXPNAMELEN];/* product name (NULL terminated string) */
-    WORD	wTechnology;	/* type of device */
-    WORD	wVoices;	/* # of voices (internal synth only) */
-    WORD	wNotes;		/* max # of notes (internal synth only) */
-    WORD	wChannelMask;	/* channels used (internal synth only) */
-    DWORD	dwSupport;	/* functionality supported by driver */
-} MIDIOUTCAPSW, *LPMIDIOUTCAPSW;
-
-//DECL_WINELIB_TYPE_AW(MIDIOUTCAPS)
-//DECL_WINELIB_TYPE_AW(LPMIDIOUTCAPS)
-
-#define MOD_MIDIPORT    1  /* output port */
-#define MOD_SYNTH       2  /* generic internal synth */
-#define MOD_SQSYNTH     3  /* square wave internal synth */
-#define MOD_FMSYNTH     4  /* FM internal synth */
-#define MOD_MAPPER      5  /* MIDI mapper */
-
-#define MIDICAPS_VOLUME		0x0001  /* supports volume control */
-#define MIDICAPS_LRVOLUME	0x0002  /* separate left-right volume control */
-#define MIDICAPS_CACHE		0x0004
-#define MIDICAPS_STREAM		0x0008  /* capable of supporting stream buffer */
-
-typedef struct {
-    WORD	wMid;		/* manufacturer ID */
-    WORD	wPid;		/* product ID */
-    MMVERSION	vDriverVersion;	/* version of the driver */
-    CHAR	szPname[MAXPNAMELEN];/* product name (NULL terminated string) */
-    DWORD	dwSupport;	/* included in win95 and higher */
-} MIDIINCAPSA, *LPMIDIINCAPSA;
-
-typedef struct {
-    WORD	wMid;		/* manufacturer ID */
-    WORD	wPid;		/* product ID */
-    MMVERSION	vDriverVersion;	/* version of the driver */
-    WCHAR	szPname[MAXPNAMELEN];/* product name (NULL terminated string) */
-    DWORD	dwSupport;	/* included in win95 and higher */
-} MIDIINCAPSW, *LPMIDIINCAPSW;
-
-//DECL_WINELIB_TYPE_AW(MIDIINCAPS)
-//DECL_WINELIB_TYPE_AW(LPMIDIINCAPS)
-
-/* It seems that Win32 has a slightly different structure than Win 16.
- * sigh....
- */
-typedef struct midihdr_tag {
-    LPSTR	lpData;		/* pointer to locked data block */
-    DWORD	dwBufferLength;	/* length of data in data block */
-    DWORD	dwBytesRecorded;/* used for input only */
-    DWORD_PTR	dwUser;		/* for client's use */
-    DWORD	dwFlags;	/* assorted flags (see defines) */
-    struct midihdr_tag *lpNext;	/* reserved for driver */
-    DWORD	reserved;	/* reserved for driver */
-    DWORD	dwOffset;	/* offset of playback in case of
-				 * MIDISTRM buffer */
-    DWORD_PTR	dwReserved[8];	/* reserved for driver */
-} MIDIHDR, *LPMIDIHDR;
-
-#define MHDR_DONE       0x00000001       /* done bit */
-#define MHDR_PREPARED   0x00000002       /* set if header prepared */
-#define MHDR_INQUEUE    0x00000004       /* reserved for driver */
-#define MHDR_ISSTRM	0x00000008	 /* data is sent by Stream functions */
-
-typedef struct {
-    DWORD		cbStruct;
-    DWORD		dwTempo;
-} MIDIPROPTEMPO, *LPMIDIPROPTEMPO;
-
-typedef struct {
-    DWORD		cbStruct;
-    DWORD		dwTimeDiv;
-} MIDIPROPTIMEDIV, *LPMIDIPROPTIMEDIV;
-
-#define MIDIPROP_GET		0x40000000
-#define MIDIPROP_SET		0x80000000
-#define MIDIPROP_TEMPO		0x00000002
-#define MIDIPROP_TIMEDIV	0x00000001
-
-typedef struct {
-    DWORD dwDeltaTime;	/* Time, in MIDI ticks, between the previous
-			 * event and the current event. */
-    DWORD dwStreamID;	/* Reserved; must be zero. */
-    DWORD dwEvent;  	/* event => see MEVT_XXX macros */
-    DWORD dwParms[1];	/* extra pmts to dwEvent if F_LONG is set */
-} MIDIEVENT, *LPMIDIEVENT;
-
-#define MEVT_EVENTTYPE(x) ((BYTE) (((x)>>24)&0xFF))
-#define MEVT_EVENTPARM(x) ((DWORD) ((x)&0x00FFFFFFL))
-
-#define MEVT_F_CALLBACK 0x40000000l
-#define	MEVT_F_LONG     0x80000000l
-#define	MEVT_F_SHORT    0x00000000l
-#define	MEVT_COMMENT	((BYTE)0x82)
-#define	MEVT_LONGMSG	((BYTE)0x80)
-#define	MEVT_NOP	((BYTE)0x02)
-#define	MEVT_SHORTMSG	((BYTE)0x00)
-#define	MEVT_TEMPO	((BYTE)0x01)
-#define	MEVT_VERSION	((BYTE)0x84)
-
-UINT		WINAPI	midiOutGetNumDevs(void);
-UINT		WINAPI	midiOutGetDevCapsA(UINT,LPMIDIOUTCAPSA,UINT);
-UINT		WINAPI	midiOutGetDevCapsW(UINT,LPMIDIOUTCAPSW,UINT);
-#define 		midiOutGetDevCaps WINELIB_NAME_AW(midiOutGetDevCaps)
-UINT		WINAPI	midiOutGetVolume(HMIDIOUT,DWORD*);
-UINT		WINAPI	midiOutSetVolume(HMIDIOUT,DWORD);
-UINT		WINAPI	midiOutGetErrorTextA(UINT,LPSTR,UINT);
-UINT		WINAPI	midiOutGetErrorTextW(UINT,LPWSTR,UINT);
-#define 		midiOutGetErrorText WINELIB_NAME_AW(midiOutGetErrorText)
-UINT		WINAPI	midiOutOpen(HMIDIOUT*,UINT,DWORD,DWORD,DWORD);
-UINT		WINAPI	midiOutClose(HMIDIOUT);
-UINT		WINAPI	midiOutPrepareHeader(HMIDIOUT,MIDIHDR*,UINT);
-UINT		WINAPI	midiOutUnprepareHeader(HMIDIOUT,MIDIHDR*,UINT);
-UINT		WINAPI	midiOutShortMsg(HMIDIOUT,DWORD);
-UINT		WINAPI	midiOutLongMsg(HMIDIOUT,MIDIHDR*,UINT);
-UINT		WINAPI	midiOutReset(HMIDIOUT);
-UINT		WINAPI	midiOutCachePatches(HMIDIOUT,UINT,WORD*,UINT);
-UINT		WINAPI	midiOutCacheDrumPatches(HMIDIOUT,UINT,WORD*,UINT);
-UINT		WINAPI	midiOutGetID(HMIDIOUT,UINT*);
-UINT		WINAPI	midiOutMessage(HMIDIOUT,UINT,DWORD,DWORD);
-
-UINT		WINAPI	midiInGetNumDevs(void);
-UINT		WINAPI	midiInGetDevCapsA(UINT,LPMIDIINCAPSA,UINT);
-UINT		WINAPI	midiInGetDevCapsW(UINT,LPMIDIINCAPSW,UINT);
-#define 		midiInGetDevCaps WINELIB_NAME_AW(midiInGetDevCaps)
-UINT		WINAPI	midiInGetErrorTextA(UINT,LPSTR,UINT);
-UINT		WINAPI	midiInGetErrorTextW(UINT,LPWSTR,UINT);
-#define 		midiInGetErrorText WINELIB_NAME_AW(midiInGetErrorText)
-UINT		WINAPI	midiInOpen(HMIDIIN*,UINT,DWORD,DWORD,DWORD);
-UINT		WINAPI	midiInClose(HMIDIIN);
-UINT		WINAPI	midiInPrepareHeader(HMIDIIN,MIDIHDR*,UINT);
-UINT		WINAPI	midiInUnprepareHeader(HMIDIIN,MIDIHDR*,UINT);
-UINT		WINAPI	midiInAddBuffer(HMIDIIN,MIDIHDR*,UINT);
-UINT		WINAPI	midiInStart(HMIDIIN);
-UINT		WINAPI	midiInStop(HMIDIIN);
-UINT		WINAPI	midiInReset(HMIDIIN);
-UINT		WINAPI	midiInGetID(HMIDIIN,UINT*);
-UINT		WINAPI	midiInMessage(HMIDIIN,UINT,DWORD,DWORD);
-MMRESULT	WINAPI	midiStreamClose(HMIDISTRM hms);
-MMRESULT	WINAPI	midiStreamOpen(HMIDISTRM* phms, LPUINT uDeviceID, DWORD cMidi,
-				       DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen);
-MMRESULT	WINAPI	midiStreamOut(HMIDISTRM hms, LPMIDIHDR lpMidiHdr, UINT cbMidiHdr);
-MMRESULT	WINAPI	midiStreamPause(HMIDISTRM hms);
-MMRESULT	WINAPI	midiStreamPosition(HMIDISTRM hms, LPMMTIME lpmmt, UINT cbmmt);
-MMRESULT	WINAPI	midiStreamProperty(HMIDISTRM hms, LPBYTE lpPropData, DWORD dwProperty);
-MMRESULT	WINAPI	midiStreamRestart(HMIDISTRM hms);
-MMRESULT	WINAPI	midiStreamStop(HMIDISTRM hms);
-
-#define AUX_MAPPER     (-1)
-
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    CHAR	szPname[MAXPNAMELEN];	/* product name (NULL terminated string) */
-    WORD	wTechnology;		/* type of device */
-    WORD	wReserved1;		/* padding */
-    DWORD	dwSupport;		/* functionality supported by driver */
-} AUXCAPSA, *LPAUXCAPSA;
-
-typedef struct {
-    WORD	wMid;			/* manufacturer ID */
-    WORD	wPid;			/* product ID */
-    MMVERSION	vDriverVersion;		/* version of the driver */
-    WCHAR	szPname[MAXPNAMELEN];	/* product name (NULL terminated string) */
-    WORD	wTechnology;		/* type of device */
-    WORD	wReserved1;		/* padding */
-    DWORD	dwSupport;		/* functionality supported by driver */
-} AUXCAPSW, *LPAUXCAPSW;
-
-//DECL_WINELIB_TYPE_AW(AUXCAPS)
-//DECL_WINELIB_TYPE_AW(LPAUXCAPS)
-
-#define AUXCAPS_CDAUDIO    1       /* audio from internal CD-ROM drive */
-#define AUXCAPS_AUXIN      2       /* audio from auxiliary input jacks */
-
-#define AUXCAPS_VOLUME          0x0001  /* supports volume control */
-#define AUXCAPS_LRVOLUME        0x0002  /* separate left-right volume control */
-
-UINT		WINAPI	auxGetNumDevs(void);
-UINT		WINAPI	auxGetDevCapsA(UINT,LPAUXCAPSA,UINT);
-UINT		WINAPI	auxGetDevCapsW(UINT,LPAUXCAPSW,UINT);
-#define 		auxGetDevCaps WINELIB_NAME_AW(auxGetDevCaps)
-UINT		WINAPI	auxSetVolume(UINT,DWORD);
-UINT		WINAPI	auxGetVolume(UINT,LPDWORD);
-UINT		WINAPI	auxOutMessage(UINT,UINT,DWORD,DWORD);
-
-#define TIMERR_NOERROR        (0)                  /* no error */
-#define TIMERR_NOCANDO        (TIMERR_BASE+1)      /* request not completed */
-#define TIMERR_STRUCT         (TIMERR_BASE+33)     /* time struct size */
-
-typedef void (CALLBACK *LPTIMECALLBACK)(UINT uTimerID, UINT uMessage, DWORD dwUser, DWORD dw1, DWORD dw2);
-
-#define TIME_ONESHOT			0x0000	/* program timer for single event */
-#define TIME_PERIODIC			0x0001	/* program for continuous periodic event */
-#define TIME_CALLBACK_FUNCTION		0x0000	/* callback is function */
-#define TIME_CALLBACK_EVENT_SET		0x0010	/* callback is event - use SetEvent */
-#define TIME_CALLBACK_EVENT_PULSE 	0x0020	/* callback is event - use PulseEvent */
-#define TIME_KILL_SYNCHRONOUS           0x0100
-
-typedef struct {
-    UINT	wPeriodMin;
-    UINT	wPeriodMax;
-} TIMECAPS, *LPTIMECAPS;
-
-
-MMRESULT	WINAPI	timeGetSystemTime(LPMMTIME,UINT);
-DWORD		WINAPI	timeGetTime(void);	/* same for win32/win16 */
-MMRESULT	WINAPI	timeSetEvent(UINT,UINT,LPTIMECALLBACK,DWORD,UINT);
-MMRESULT	WINAPI	timeKillEvent(UINT);
-MMRESULT	WINAPI	timeGetDevCaps(LPTIMECAPS,UINT);
-MMRESULT	WINAPI	timeBeginPeriod(UINT);
-MMRESULT	WINAPI	timeEndPeriod(UINT);
-
-#define JOYERR_NOERROR        (0)                  /* no error */
-#define JOYERR_PARMS          (JOYERR_BASE+5)      /* bad parameters */
-#define JOYERR_NOCANDO        (JOYERR_BASE+6)      /* request not completed */
-#define JOYERR_UNPLUGGED      (JOYERR_BASE+7)      /* joystick is unplugged */
-
-/* JOYINFO, JOYINFOEX, MM_JOY* */
-#define JOY_BUTTON1         	0x0001
-#define JOY_BUTTON2         	0x0002
-#define JOY_BUTTON3         	0x0004
-#define JOY_BUTTON4         	0x0008
-#define JOY_BUTTON1CHG      	0x0100
-#define JOY_BUTTON2CHG      	0x0200
-#define JOY_BUTTON3CHG      	0x0400
-#define JOY_BUTTON4CHG      	0x0800
-
-#define JOYSTICKID1         	0
-#define JOYSTICKID2         	1
-
-/* JOYCAPS.wCaps */
-#define JOYCAPS_HASZ		0x0001
-#define JOYCAPS_HASR		0x0002
-#define JOYCAPS_HASU		0x0004
-#define JOYCAPS_HASV		0x0008
-#define JOYCAPS_HASPOV		0x0010
-#define JOYCAPS_POV4DIR		0x0020
-#define JOYCAPS_POVCTS		0x0040
-
-/* JOYINFOEX stuff */
-#define JOY_POVCENTERED		(WORD) -1
-#define JOY_POVFORWARD		0
-#define JOY_POVRIGHT		9000
-#define JOY_POVBACKWARD		18000
-#define JOY_POVLEFT		27000
-
-#define JOY_RETURNX		0x00000001
-#define JOY_RETURNY		0x00000002
-#define JOY_RETURNZ		0x00000004
-#define JOY_RETURNR		0x00000008
-#define JOY_RETURNU		0x00000010
-#define JOY_RETURNV		0x00000020
-#define JOY_RETURNPOV		0x00000040
-#define JOY_RETURNBUTTONS	0x00000080
-#define JOY_RETURNRAWDATA	0x00000100
-#define JOY_RETURNPOVCTS	0x00000200
-#define JOY_RETURNCENTERED	0x00000400
-#define JOY_USEDEADZONE		0x00000800
-#define JOY_RETURNALL		(JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | \
-				 JOY_RETURNR | JOY_RETURNU | JOY_RETURNV | \
-				 JOY_RETURNPOV | JOY_RETURNBUTTONS)
-#define JOY_CAL_READALWAYS	0x00010000
-#define JOY_CAL_READXYONLY	0x00020000
-#define JOY_CAL_READ3		0x00040000
-#define JOY_CAL_READ4		0x00080000
-#define JOY_CAL_READXONLY	0x00100000
-#define JOY_CAL_READYONLY	0x00200000
-#define JOY_CAL_READ5		0x00400000
-#define JOY_CAL_READ6		0x00800000
-#define JOY_CAL_READZONLY	0x01000000
-#define JOY_CAL_READRONLY	0x02000000
-#define JOY_CAL_READUONLY	0x04000000
-#define JOY_CAL_READVONLY	0x08000000
-
-typedef struct {
-    WORD wMid;
-    WORD wPid;
-    CHAR szPname[MAXPNAMELEN];
-    UINT wXmin;
-    UINT wXmax;
-    UINT wYmin;
-    UINT wYmax;
-    UINT wZmin;
-    UINT wZmax;
-    UINT wNumButtons;
-    UINT wPeriodMin;
-    UINT wPeriodMax;
-    UINT wRmin;
-    UINT wRmax;
-    UINT wUmin;
-    UINT wUmax;
-    UINT wVmin;
-    UINT wVmax;
-    UINT wCaps;
-    UINT wMaxAxes;
-    UINT wNumAxes;
-    UINT wMaxButtons;
-    CHAR szRegKey[MAXPNAMELEN];
-    CHAR szOEMVxD[MAX_JOYSTICKOEMVXDNAME];
-} JOYCAPSA, *LPJOYCAPSA;
-
-typedef struct {
-    WORD wMid;
-    WORD wPid;
-    WCHAR szPname[MAXPNAMELEN];
-    UINT wXmin;
-    UINT wXmax;
-    UINT wYmin;
-    UINT wYmax;
-    UINT wZmin;
-    UINT wZmax;
-    UINT wNumButtons;
-    UINT wPeriodMin;
-    UINT wPeriodMax;
-    UINT wRmin;
-    UINT wRmax;
-    UINT wUmin;
-    UINT wUmax;
-    UINT wVmin;
-    UINT wVmax;
-    UINT wCaps;
-    UINT wMaxAxes;
-    UINT wNumAxes;
-    UINT wMaxButtons;
-    WCHAR szRegKey[MAXPNAMELEN];
-    WCHAR szOEMVxD[MAX_JOYSTICKOEMVXDNAME];
-} JOYCAPSW, *LPJOYCAPSW;
-//DECL_WINELIB_TYPE_AW(JOYCAPS)
-//DECL_WINELIB_TYPE_AW(LPJOYCAPS)
-
-typedef struct {
-    UINT wXpos;
-    UINT wYpos;
-    UINT wZpos;
-    UINT wButtons;
-} JOYINFO, *LPJOYINFO;
-
-typedef struct {
-    DWORD	dwSize;		/* size of structure */
-    DWORD	dwFlags;	/* flags to indicate what to return */
-    DWORD	dwXpos;		/* x position */
-    DWORD	dwYpos;		/* y position */
-    DWORD	dwZpos;		/* z position */
-    DWORD	dwRpos;		/* rudder/4th axis position */
-    DWORD	dwUpos;		/* 5th axis position */
-    DWORD	dwVpos;		/* 6th axis position */
-    DWORD	dwButtons;	/* button states */
-    DWORD	dwButtonNumber;	/* current button number pressed */
-    DWORD	dwPOV;		/* point of view state */
-    DWORD	dwReserved1;	/* reserved for communication between winmm & driver */
-    DWORD	dwReserved2;	/* reserved for future expansion */
-} JOYINFOEX,*LPJOYINFOEX;
-
-
-MMRESULT	WINAPI	joyGetDevCapsA(UINT,LPJOYCAPSA,UINT);
-MMRESULT	WINAPI	joyGetDevCapsW(UINT,LPJOYCAPSW,UINT);
-#define joyGetDevCaps WINELIB_NAME_AW(joyGetDevCaps)
-UINT		WINAPI	joyGetNumDevs(void);
-MMRESULT	WINAPI	joyGetPos(UINT,LPJOYINFO);
-MMRESULT	WINAPI	joyGetPosEx(UINT,LPJOYINFOEX);
-MMRESULT	WINAPI	joyGetThreshold(UINT,UINT*);
-MMRESULT	WINAPI	joyReleaseCapture(UINT);
-MMRESULT	WINAPI	joySetCapture(HWND,UINT,UINT,BOOL);
-MMRESULT	WINAPI	joySetThreshold(UINT,UINT);
-
-#define	MIXERR_BASE		1024
-#define	MIXERR_INVALLINE	(MIXERR_BASE + 0)
-#define MIXERR_INVALCONTROL	(MIXERR_BASE + 1)
-#define MIXERR_INVALVALUE	(MIXERR_BASE + 2)
-#define MIXERR_LASTERROR	(MIXERR_BASE + 2)
-
-typedef struct {
-	WORD		wMid;
-	WORD		wPid;
-	MMVERSION	vDriverVersion;
-	CHAR		szPname[MAXPNAMELEN];
-	DWORD		fdwSupport;
-	DWORD		cDestinations;
-} MIXERCAPSA,*LPMIXERCAPSA;
-
-typedef struct {
-	WORD		wMid;
-	WORD		wPid;
-	MMVERSION	vDriverVersion;
-	WCHAR		szPname[MAXPNAMELEN];
-	DWORD		fdwSupport;
-	DWORD		cDestinations;
-} MIXERCAPSW,*LPMIXERCAPSW;
-
-//DECL_WINELIB_TYPE_AW(MIXERCAPS)
-//DECL_WINELIB_TYPE_AW(LPMIXERCAPS)
-
-#define MIXER_SHORT_NAME_CHARS		16
-#define MIXER_LONG_NAME_CHARS		64
-
-/*  MIXERLINE.fdwLine */
-#define	MIXERLINE_LINEF_ACTIVE		0x00000001
-#define	MIXERLINE_LINEF_DISCONNECTED	0x00008000
-#define	MIXERLINE_LINEF_SOURCE		0x80000000
-
-/* Mixer flags */
-#define MIXER_OBJECTF_HANDLE	0x80000000L
-#define MIXER_OBJECTF_MIXER	0x00000000L
-#define MIXER_OBJECTF_HMIXER	(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIXER)
-#define MIXER_OBJECTF_WAVEOUT	0x10000000L
-#define MIXER_OBJECTF_HWAVEOUT	(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEOUT)
-#define MIXER_OBJECTF_WAVEIN	0x20000000L
-#define MIXER_OBJECTF_HWAVEIN	(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEIN)
-#define MIXER_OBJECTF_MIDIOUT	0x30000000L
-#define MIXER_OBJECTF_HMIDIOUT	(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIOUT)
-#define MIXER_OBJECTF_MIDIIN	0x40000000L
-#define MIXER_OBJECTF_HMIDIIN	(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIIN)
-#define MIXER_OBJECTF_AUX	0x50000000L
-
-/*  MIXERLINE.dwComponentType */
-/*  component types for destinations and sources */
-#define	MIXERLINE_COMPONENTTYPE_DST_FIRST	0x00000000L
-#define	MIXERLINE_COMPONENTTYPE_DST_UNDEFINED	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
-#define	MIXERLINE_COMPONENTTYPE_DST_DIGITAL	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
-#define	MIXERLINE_COMPONENTTYPE_DST_LINE	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
-#define	MIXERLINE_COMPONENTTYPE_DST_MONITOR	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
-#define	MIXERLINE_COMPONENTTYPE_DST_SPEAKERS	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
-#define	MIXERLINE_COMPONENTTYPE_DST_HEADPHONES	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
-#define	MIXERLINE_COMPONENTTYPE_DST_TELEPHONE	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
-#define	MIXERLINE_COMPONENTTYPE_DST_WAVEIN	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
-#define	MIXERLINE_COMPONENTTYPE_DST_VOICEIN	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
-#define	MIXERLINE_COMPONENTTYPE_DST_LAST	(MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
-
-#define	MIXERLINE_COMPONENTTYPE_SRC_FIRST	0x00001000L
-#define	MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0)
-#define	MIXERLINE_COMPONENTTYPE_SRC_DIGITAL	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
-#define	MIXERLINE_COMPONENTTYPE_SRC_LINE	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
-#define	MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
-#define	MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
-#define	MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
-#define	MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
-#define	MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
-#define	MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
-#define	MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
-#define	MIXERLINE_COMPONENTTYPE_SRC_ANALOG	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
-#define	MIXERLINE_COMPONENTTYPE_SRC_LAST	(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
-
-/*  MIXERLINE.Target.dwType */
-#define	MIXERLINE_TARGETTYPE_UNDEFINED	0
-#define	MIXERLINE_TARGETTYPE_WAVEOUT	1
-#define	MIXERLINE_TARGETTYPE_WAVEIN	2
-#define	MIXERLINE_TARGETTYPE_MIDIOUT	3
-#define	MIXERLINE_TARGETTYPE_MIDIIN	4
-#define MIXERLINE_TARGETTYPE_AUX	5
-
-typedef struct {
-    DWORD	cbStruct;
-    DWORD	dwDestination;
-    DWORD	dwSource;
-    DWORD	dwLineID;
-    DWORD	fdwLine;
-    DWORD	dwUser;
-    DWORD	dwComponentType;
-    DWORD	cChannels;
-    DWORD	cConnections;
-    DWORD	cControls;
-    CHAR	szShortName[MIXER_SHORT_NAME_CHARS];
-    CHAR	szName[MIXER_LONG_NAME_CHARS];
-    struct {
-	DWORD	dwType;
-	DWORD	dwDeviceID;
[truncated at 1000 lines; 1228 more skipped]

reactos/include/afd
shared.h 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- shared.h	21 Nov 2004 20:54:51 -0000	1.11
+++ shared.h	8 Dec 2004 21:56:57 -0000	1.11.2.1
@@ -54,7 +54,7 @@
 typedef struct _AFD_POLL_INFO {
     LARGE_INTEGER		        Timeout;
     ULONG				HandleCount;
-    PAFD_HANDLE                         InternalUse;
+    ULONG                               Exclusive;
     AFD_HANDLE			        Handles[1];
 } AFD_POLL_INFO, *PAFD_POLL_INFO;
 
@@ -325,7 +325,6 @@
     DWORD NumberOfBytesSent;
 } FILE_REPLY_SENDTO, *PFILE_REPLY_SENDTO;
 
-
 typedef struct _FILE_REQUEST_RECVFROM {
     LPWSABUF Buffers;
     DWORD BufferCount;
@@ -339,29 +338,6 @@
     DWORD NumberOfBytesRecvd;
 } FILE_REPLY_RECVFROM, *PFILE_REPLY_RECVFROM;
 
-
-typedef struct _FILE_REQUEST_SELECT {
-    LPFD_SET ReadFDSet;
-    LPFD_SET WriteFDSet;
-    LPFD_SET ExceptFDSet;
-    TIMEVAL Timeout;
-} FILE_REQUEST_SELECT, *PFILE_REQUEST_SELECT;
-
-typedef struct _FILE_REPLY_SELECT {
-    INT Status;
-    DWORD SocketCount;
-} FILE_REPLY_SELECT, *PFILE_REPLY_SELECT;
-
-
-typedef struct _FILE_REQUEST_EVENTSELECT {
-    WSAEVENT hEventObject;
-    LONG lNetworkEvents;
-} FILE_REQUEST_EVENTSELECT, *PFILE_REQUEST_EVENTSELECT;
-
-typedef struct _FILE_REPLY_EVENTSELECT {
-    INT Status;
-} FILE_REPLY_EVENTSELECT, *PFILE_REPLY_EVENTSELECT;
-
 typedef struct _FILE_REQUEST_RECV {
     LPWSABUF Buffers;
     DWORD BufferCount;

reactos/include/ddk
exfuncs.h 1.43 -> 1.43.2.1
diff -u -r1.43 -r1.43.2.1
--- exfuncs.h	18 Oct 2004 20:56:21 -0000	1.43
+++ exfuncs.h	8 Dec 2004 21:56:57 -0000	1.43.2.1
@@ -991,8 +991,23 @@
 	);
 
 #ifndef InterlockedExchangePointer
-#define InterlockedExchangePointer(__T__, __V__) \
- (PVOID)InterlockedExchange((PLONG)(__T__), (LONG)(__V__))
+# ifdef _WIN64
+#  define InterlockedExchangePointer(__T__, __V__) \
+             (PVOID)InterlockedExchange64((PLONGLONG)(__T__), (LONGLONG)(__V__))
+# else
+#  define InterlockedExchangePointer(__T__, __V__) \
+             (PVOID)InterlockedExchange((PLONG)(__T__), (LONG)(__V__))
+# endif
+#endif
+
+#ifndef InterlockedCompareExchangePointer
+# ifdef _WIN64
+#  define InterlockedCompareExchangePointer(__T__, __V__, __C__) \
+             (PVOID)InterlockedCompareExchange64((PLONGLONG)(__T__), (LONGLONG)(__V__), (LONGLONG)(__C__))
+# else
+#  define InterlockedCompareExchangePointer(__T__, __V__, __C__) \
+             (PVOID)InterlockedCompareExchange((PLONG)(__T__), (LONG)(__V__), (LONG)(__C__))
+# endif
 #endif
 
 /*---*/

reactos/include/ddk
iofuncs.h 1.46 -> 1.46.2.1
diff -u -r1.46 -r1.46.2.1
--- iofuncs.h	31 Oct 2004 22:21:41 -0000	1.46
+++ iofuncs.h	8 Dec 2004 21:56:57 -0000	1.46.2.1
@@ -1,6 +1,6 @@
 #ifndef _INCLUDE_DDK_IOFUNCS_H
 #define _INCLUDE_DDK_IOFUNCS_H
-/* $Id: iofuncs.h,v 1.46 2004/10/31 22:21:41 ion Exp $ */
+/* $Id: iofuncs.h,v 1.46.2.1 2004/12/08 21:56:57 hyperion Exp $ */
 
 #ifdef __NTOSKRNL__
 extern POBJECT_TYPE EXPORTED IoAdapterObjectType;
@@ -1206,7 +1206,7 @@
 	);
 
 NTSTATUS
-STDCALL
+FASTCALL
 IoReadPartitionTable (
 	PDEVICE_OBJECT			DeviceObject,
 	ULONG				SectorSize,
@@ -1215,7 +1215,7 @@
 	);
 
 NTSTATUS
-STDCALL
+FASTCALL
 IoSetPartitionInformation (
 	PDEVICE_OBJECT	DeviceObject,
 	ULONG		SectorSize,
@@ -1224,7 +1224,7 @@
 	);
 
 NTSTATUS
-STDCALL
+FASTCALL
 IoWritePartitionTable (
 	PDEVICE_OBJECT			DeviceObject,
 	ULONG				SectorSize,

reactos/include/ddk
iotypes.h 1.69 -> 1.69.2.1
diff -u -r1.69 -r1.69.2.1
--- iotypes.h	6 Nov 2004 04:12:59 -0000	1.69
+++ iotypes.h	8 Dec 2004 21:56:57 -0000	1.69.2.1
@@ -1,4 +1,4 @@
-/* $Id: iotypes.h,v 1.69 2004/11/06 04:12:59 ion Exp $
+/* $Id: iotypes.h,v 1.69.2.1 2004/12/08 21:56:57 hyperion Exp $
  *
  */
 
@@ -752,7 +752,7 @@
 typedef struct _IO_COMPLETION_CONTEXT
 {
    PVOID Port;
-   ULONG Key;
+   PVOID Key;
 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
 
 #define FO_FILE_OPEN                    0x00000001

reactos/include/ddk
kefuncs.h 1.48 -> 1.48.2.1
diff -u -r1.48 -r1.48.2.1
--- kefuncs.h	11 Nov 2004 22:23:51 -0000	1.48
+++ kefuncs.h	8 Dec 2004 21:56:57 -0000	1.48.2.1
@@ -111,7 +111,7 @@
 KIRQL STDCALL KeGetCurrentIrql (VOID);
 
 #ifndef __USE_W32API
-ULONG KeGetCurrentProcessorNumber(VOID);
+#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
 ULONG KeGetDcacheFillSize(VOID);
 ULONG STDCALL KeGetPreviousMode (VOID);
 #endif

reactos/include/ntdll
rtl.h 1.52 -> 1.52.2.1
diff -u -r1.52 -r1.52.2.1
--- rtl.h	19 Nov 2004 01:30:34 -0000	1.52
+++ rtl.h	8 Dec 2004 21:56:57 -0000	1.52.2.1
@@ -1,4 +1,4 @@
-/* $Id: rtl.h,v 1.52 2004/11/19 01:30:34 weiden Exp $
+/* $Id: rtl.h,v 1.52.2.1 2004/12/08 21:56:57 hyperion Exp $
  *
  */
 
@@ -263,10 +263,22 @@
 
 /* Path functions */
 
+typedef enum
+{
+    INVALID_PATH = 0,
+    UNC_PATH,              /* "//foo" */
+    ABSOLUTE_DRIVE_PATH,   /* "c:/foo" */
+    RELATIVE_DRIVE_PATH,   /* "c:foo" */
+    ABSOLUTE_PATH,         /* "/foo" */
+    RELATIVE_PATH,         /* "foo" */
+    DEVICE_PATH,           /* "//./foo" */
+    UNC_DOT_PATH           /* "//." */
+} DOS_PATHNAME_TYPE;
+
 ULONG
 STDCALL
 RtlDetermineDosPathNameType_U (
-	PWSTR Path
+   PCWSTR Path
 	);
 
 BOOLEAN

reactos/include/ntos
haltypes.h 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- haltypes.h	21 Nov 2004 06:51:17 -0000	1.9
+++ haltypes.h	8 Dec 2004 21:56:57 -0000	1.9.2.1
@@ -1,4 +1,4 @@
-/* $Id: haltypes.h,v 1.9 2004/11/21 06:51:17 ion Exp $
+/* $Id: haltypes.h,v 1.9.2.1 2004/12/08 21:56:57 hyperion Exp $
  *
  * COPYRIGHT:                See COPYING in the top level directory
  * PROJECT:                  ReactOS kernel
@@ -363,7 +363,7 @@
     TranslateParentToChild
 } RESOURCE_TRANSLATION_DIRECTION;
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*PTRANSLATE_RESOURCE_HANDLER)(IN PVOID Context,
     IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
     IN RESOURCE_TRANSLATION_DIRECTION Direction,
@@ -373,7 +373,7 @@
     OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
 );
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(IN PVOID Context,
     IN PIO_RESOURCE_DESCRIPTOR Source,
     IN PDEVICE_OBJECT PhysicalDeviceObject,
@@ -470,7 +470,7 @@
 typedef VOID STDCALL_FUNC
 (*PDEVICE_CONTROL_COMPLETION)(IN PDEVICE_CONTROL_CONTEXT ControlContext);
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalDeviceControl)(IN PDEVICE_HANDLER_OBJECT DeviceHandler,
 		     IN PDEVICE_OBJECT DeviceObject,
 		     IN ULONG ControlCode,
@@ -479,76 +479,76 @@
 		     IN PVOID Context,
 		     IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
 
-typedef VOID FASTCALL
+typedef VOID FASTCALL_FUNC
 (*pHalExamineMBR)(IN PDEVICE_OBJECT DeviceObject,
 		  IN ULONG SectorSize,
 		  IN ULONG MBRTypeIdentifier,
 		  OUT PVOID *Buffer);
 
-typedef VOID FASTCALL
+typedef VOID FASTCALL_FUNC
 (*pHalIoAssignDriveLetters)(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
 			    IN PSTRING NtDeviceName,
 			    OUT PUCHAR NtSystemPath,
 			    OUT PSTRING NtSystemPathString);
 
-typedef NTSTATUS FASTCALL
+typedef NTSTATUS FASTCALL_FUNC
 (*pHalIoReadPartitionTable)(IN PDEVICE_OBJECT DeviceObject,
 			    IN ULONG SectorSize,
 			    IN BOOLEAN ReturnRecognizedPartitions,
 			    OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
 
-typedef NTSTATUS FASTCALL
+typedef NTSTATUS FASTCALL_FUNC
 (*pHalIoSetPartitionInformation)(IN PDEVICE_OBJECT DeviceObject,
 				 IN ULONG SectorSize,
 				 IN ULONG PartitionNumber,
 				 IN ULONG PartitionType);
 
-typedef NTSTATUS FASTCALL
+typedef NTSTATUS FASTCALL_FUNC
 (*pHalIoWritePartitionTable)(IN PDEVICE_OBJECT DeviceObject,
 			     IN ULONG SectorSize,
 			     IN ULONG SectorsPerTrack,
 			     IN ULONG NumberOfHeads,
 			     IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer);
 
-typedef PBUS_HANDLER FASTCALL
+typedef PBUS_HANDLER FASTCALL_FUNC
 (*pHalHandlerForBus)(IN INTERFACE_TYPE InterfaceType,
 		     IN ULONG BusNumber);
 
-typedef VOID FASTCALL
+typedef VOID FASTCALL_FUNC
 (*pHalReferenceBusHandler)(IN PBUS_HANDLER BusHandler);
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalQuerySystemInformation)(IN HAL_QUERY_INFORMATION_CLASS InformationClass,
 			      IN ULONG BufferSize,
 			      IN OUT PVOID Buffer,
 			      OUT PULONG ReturnedLength);
 
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalSetSystemInformation)(IN HAL_SET_INFORMATION_CLASS InformationClass,
 			    IN ULONG BufferSize,
 			    IN PVOID Buffer);
 
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalQueryBusSlots)(IN PBUS_HANDLER BusHandler,
 		     IN ULONG BufferSize,
 		     OUT PULONG SlotNumbers,
 		     OUT PULONG ReturnedLength);
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalInitPnpDriver)(VOID);
  
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalInitPowerManagement)(IN PPM_DISPATCH_TABLE  PmDriverDispatchTable,
     			   OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
 
-typedef struct _DMA_ADAPTER * STDCALL
+typedef struct _DMA_ADAPTER * STDCALL_FUNC
 (*pHalGetDmaAdapter)(IN PVOID Context,
     		     IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
     		     OUT PULONG NumberOfMapRegisters);
 		     
-typedef NTSTATUS STDCALL 
+typedef NTSTATUS STDCALL_FUNC
 (*pHalGetInterruptTranslator)(IN INTERFACE_TYPE ParentInterfaceType,
 			      IN ULONG ParentBusNumber,
 			      IN INTERFACE_TYPE BridgeInterfaceType,
@@ -557,19 +557,21 @@
 			      OUT PTRANSLATOR_INTERFACE Translator,
 			      OUT PULONG BridgeBusNumber);
 
-typedef NTSTATUS STDCALL (*pHalStartMirroring)(VOID);
+typedef NTSTATUS STDCALL_FUNC
+(*pHalStartMirroring)(VOID);
 
-typedef NTSTATUS STDCALL (*pHalEndMirroring)(IN ULONG PassNumber);
+typedef NTSTATUS STDCALL_FUNC
+(*pHalEndMirroring)(IN ULONG PassNumber);
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalMirrorPhysicalMemory)(IN PHYSICAL_ADDRESS PhysicalAddress,
     IN LARGE_INTEGER NumberOfBytes);
 
-typedef NTSTATUS STDCALL
+typedef NTSTATUS STDCALL_FUNC
 (*pHalMirrorVerify)(IN PHYSICAL_ADDRESS PhysicalAddress,
     IN LARGE_INTEGER NumberOfBytes);
 
-typedef VOID STDCALL
+typedef VOID STDCALL_FUNC
 (*pHalEndOfBoot)(VOID);
         
 

reactos/include/ntos
kdbgsyms.h 1.4 -> 1.4.32.1
diff -u -r1.4 -r1.4.32.1
--- kdbgsyms.h	16 Nov 2002 00:08:45 -0000	1.4
+++ kdbgsyms.h	8 Dec 2004 21:56:57 -0000	1.4.32.1
@@ -2,7 +2,7 @@
 #ifndef __KDBGSYMS_H
 #define __KDBGSYMS_H
 
-#include <ddk/ntddk.h>^M
+#include <ddk/ntddk.h>
 
 #define ST_FILENAME	0x00
 #define ST_FUNCTION	0x01

reactos/include/ntos
ntdef.h 1.8 -> 1.8.6.1
diff -u -r1.8 -r1.8.6.1
--- ntdef.h	13 Jul 2004 16:57:10 -0000	1.8
+++ ntdef.h	8 Dec 2004 21:56:57 -0000	1.8.6.1
@@ -13,6 +13,32 @@
 
 #define EX_MAXIMUM_WAIT_OBJECTS (64)
 
+#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
+# define TYPE_ALIGNMENT(t) __alignof(t)
+#elif defined(__GNUC__)
+# define TYPE_ALIGNMENT(t) __alignof__(t)
+#else
+# define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
+#endif
+
+#ifdef _WIN64
+# define PROBE_ALIGNMENT(_s) \
+    (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
+    TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
+# define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
+#else
+# define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
+#endif
+
+/* Helpers for easy conversion to system time units (100ns) */
+#define ABSOLUTE_TIME(wait) (wait)
+#define RELATIVE_TIME(wait) (-(wait))
+#define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100L)
+#define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000L))
+#define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000L))
+#define SECONDS_TO_100NS(seconds) (((LONGLONG)(seconds)) * MILLIS_TO_100NS(1000L))
+
+
 #ifndef __USE_W32API
 
 #define ANYSIZE_ARRAY	(1)

reactos/include/ntos
rtl.h 1.38 -> 1.38.2.1
diff -u -r1.38 -r1.38.2.1
--- rtl.h	30 Oct 2004 14:02:01 -0000	1.38
+++ rtl.h	8 Dec 2004 21:56:57 -0000	1.38.2.1
@@ -1,4 +1,4 @@
-/* $Id: rtl.h,v 1.38 2004/10/30 14:02:01 navaraf Exp $
+/* $Id: rtl.h,v 1.38.2.1 2004/12/08 21:56:57 hyperion Exp $
  * 
  */
 #ifndef __DDK_RTL_H
@@ -383,13 +383,10 @@
 	PWSTR		Source
 	);
 
-ULONG
-STDCALL
-RtlCompareMemory (
-	PVOID	Source1,
-	PVOID	Source2,
-	ULONG	Length
-	);
+SIZE_T STDCALL
+RtlCompareMemory(IN const VOID *Source1,
+                 IN const VOID *Source2,
+                 IN SIZE_T Length);
 
 BOOLEAN
 STDCALL
@@ -722,11 +719,10 @@
 	IN	ULONG		NumberToClear
 	);
 
-DWORD
-STDCALL
+ULONG STDCALL
 RtlCompactHeap (
-	HANDLE	hheap,
-	DWORD	flags
+	HANDLE Heap,
+	ULONG	Flags
 	);
 
 LONG
@@ -964,7 +960,7 @@
 NTSTATUS STDCALL
 RtlDestroyAtomTable (IN PRTL_ATOM_TABLE AtomTable);
 
-BOOL STDCALL
+BOOLEAN STDCALL
 RtlDestroyHeap (HANDLE hheap);
 
 NTSTATUS
@@ -1951,11 +1947,8 @@
 	HANDLE Filehandle
 	);
 
-BOOL
-STDCALL
-RtlLockHeap (
-	HANDLE	hheap
-	);
+BOOLEAN STDCALL
+RtlLockHeap (IN HANDLE Heap);
 
 NTSTATUS STDCALL
 RtlLookupAtomInAtomTable (IN PRTL_ATOM_TABLE AtomTable,
@@ -2159,7 +2152,8 @@
 VOID STDCALL
 RtlRaiseException (IN PEXCEPTION_RECORD ExceptionRecord);
 
-VOID STDCALL RtlRaiseStatus(NTSTATUS Status);
+VOID STDCALL
+RtlRaiseStatus(NTSTATUS Status);
 
 ULONG STDCALL
 RtlRandom (PULONG Seed);
@@ -2182,13 +2176,12 @@
 	PRTL_SPLAY_LINKS Links
 	);
 
-LPVOID
-STDCALL
+PVOID STDCALL
 RtlReAllocateHeap (
-	HANDLE	hheap,
-	DWORD	flags,
-	LPVOID	ptr,
-	DWORD	size
+	HANDLE Heap,
+	ULONG Flags,
+	PVOID Ptr,
+	ULONG Size
 	);
 
 VOID
@@ -2326,8 +2319,7 @@
 NTSTATUS STDCALL
 RtlSetTimeZoneInformation (IN OUT PTIME_ZONE_INFORMATION TimeZoneInformation);
 
-ULONG
-STDCALL
+ULONG STDCALL
 RtlSizeHeap(
 	IN PVOID HeapHandle, 
 	IN ULONG Flags, 
@@ -2538,11 +2530,8 @@
 ULONG STDCALL
 RtlUniform (PULONG Seed);
 
-BOOL
-STDCALL
-RtlUnlockHeap (
-	HANDLE	hheap
-	);
+BOOLEAN STDCALL
+RtlUnlockHeap (IN HANDLE Heap);
 
 NTSTATUS
 STDCALL
@@ -2641,11 +2630,10 @@
 BOOLEAN STDCALL
 RtlValidAcl (PACL Acl);
 
-BOOL
-STDCALL
+BOOLEAN STDCALL
 RtlValidateHeap (
-	HANDLE	hheap,
-	DWORD	flags,
+	HANDLE Heap,
+	ULONG	Flags,
 	PVOID	pmem
 	);
 
@@ -2688,8 +2676,7 @@
 	IN ULONG Flags
 	);
 
-ULONG
-STDCALL
+BOOLEAN STDCALL
 RtlZeroHeap(
     IN PVOID HeapHandle,
     IN ULONG Flags

reactos/include/ntos
zw.h 1.35 -> 1.35.2.1
diff -u -r1.35 -r1.35.2.1
--- zw.h	12 Nov 2004 12:06:17 -0000	1.35
+++ zw.h	8 Dec 2004 21:56:57 -0000	1.35.2.1
@@ -1,5 +1,5 @@
 
-/* $Id: zw.h,v 1.35 2004/11/12 12:06:17 ekohl Exp $
+/* $Id: zw.h,v 1.35.2.1 2004/12/08 21:56:57 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -3567,8 +3567,8 @@
 STDCALL
 NtRemoveIoCompletion(
    IN  HANDLE           IoCompletionHandle,
-   OUT PULONG           CompletionKey,
-   OUT PULONG           CompletionValue,
+   OUT PVOID           *CompletionKey,
+   OUT PVOID           *CompletionContext,
    OUT PIO_STATUS_BLOCK IoStatusBlock,
    IN  PLARGE_INTEGER   Timeout OPTIONAL
    );
@@ -3577,8 +3577,8 @@
 STDCALL
 ZwRemoveIoCompletion(
    IN  HANDLE           IoCompletionHandle,
-   OUT PULONG           CompletionKey,
-   OUT PULONG           CompletionValue,
+   OUT PVOID           *CompletionKey,
+   OUT PVOID           *CompletionValue,
    OUT PIO_STATUS_BLOCK IoStatusBlock,
    IN  PLARGE_INTEGER   Timeout OPTIONAL
    );
@@ -4094,8 +4094,8 @@
 STDCALL
 NtSetIoCompletion(
    IN HANDLE   IoCompletionPortHandle,
-   IN ULONG    CompletionKey,
-   IN ULONG    CompletionValue,
+   IN PVOID    CompletionKey,
+   IN PVOID    CompletionContext,
    IN NTSTATUS CompletionStatus,
    IN ULONG    CompletionInformation
    );
@@ -4104,8 +4104,8 @@
 STDCALL
 ZwSetIoCompletion(
    IN HANDLE   IoCompletionPortHandle,
-   IN ULONG    CompletionKey,
-   IN ULONG    CompletionValue,
+   IN PVOID    CompletionKey,
+   IN PVOID    CompletionContext,
    IN NTSTATUS CompletionStatus,
    IN ULONG    CompletionInformation
    );

reactos/include/ntos
zwtypes.h 1.46 -> 1.46.2.1
diff -u -r1.46 -r1.46.2.1
--- zwtypes.h	21 Nov 2004 06:51:17 -0000	1.46
+++ zwtypes.h	8 Dec 2004 21:56:58 -0000	1.46.2.1
@@ -971,7 +971,7 @@
 
 typedef struct _FILE_COMPLETION_INFORMATION { // Information Class 30
    HANDLE IoCompletionHandle;
-   ULONG CompletionKey;
+   PVOID CompletionKey;
 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
 
 typedef struct _FILE_ALL_INFORMATION {

reactos/include/win32k
ntuser.h 1.139 -> 1.139.2.1
diff -u -r1.139 -r1.139.2.1
--- ntuser.h	16 Nov 2004 16:27:48 -0000	1.139
+++ ntuser.h	8 Dec 2004 21:56:58 -0000	1.139.2.1
@@ -1677,11 +1677,11 @@
   DWORD Unknown7,
   DWORD Unknown8);
 
-DWORD
+BOOL
 STDCALL
 NtUserUpdatePerUserSystemParameters(
-  DWORD Unknown0,
-  DWORD Unknown1);
+  DWORD dwReserved,
+  BOOL bEnable);
 
 DWORD
 STDCALL

reactos/include/wine
mmsystem.h added at 1.1.2.1
diff -N mmsystem.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mmsystem.h	8 Dec 2004 21:56:58 -0000	1.1.2.1
@@ -0,0 +1,46 @@
+/*
+ * MMSYSTEM - Multimedia Wine Extension ... :-)
+ *
+ * Copyright (C) the Wine project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_MMSYSTEM_H
+#define __WINE_MMSYSTEM_H
+
+#include_next <mmsystem.h>
+
+#define DRV_SUCCESS		0x0001
+#define DRV_FAILURE		0x0000
+
+#define MCI_OPEN_DRIVER			0x0801
+#define MCI_CLOSE_DRIVER		0x0802
+#define MCI_SOUND                       0x0812
+
+#define MCI_SOUND_NAME                  0x00000100L
+
+typedef LPCSTR		HPCSTR;         /* a huge version of LPCSTR */
+
+typedef struct tagMCI_SOUND_PARMS {
+       DWORD_PTR dwCallback;
+	LPCSTR  lpstrSoundName;
+} MCI_SOUND_PARMS, *LPMCI_SOUND_PARMS;
+
+typedef struct midievent_tag *LPMIDIEVENT;
+
+DWORD WINAPI GetDriverFlags(HDRVR hDriver);
+
+#endif  /* __WINE_WINNT_H */

reactos/include/wine
objidl.h 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- objidl.h	31 Oct 2004 02:19:52 -0000	1.5
+++ objidl.h	8 Dec 2004 21:56:58 -0000	1.5.2.1
@@ -813,11 +813,11 @@
 	STDMETHOD_(ULONG,Release)(THIS) PURE;
 	STDMETHOD(Connect)(THIS_ LPUNKNOWN) PURE;
 	STDMETHOD_(void,Disconnect)(THIS) PURE;
-	STDMETHOD(Invoke)(THIS_ RPCOLEMESSAGE*,LPRPCSTUBBUFFER) PURE;
+	STDMETHOD(Invoke)(THIS_ RPCOLEMESSAGE*,LPRPCCHANNELBUFFER) PURE;
 	STDMETHOD_(LPRPCSTUBBUFFER,IsIIDSupported)(THIS_ REFIID) PURE;
 	STDMETHOD_(ULONG,CountRefs)(THIS) PURE;
 	STDMETHOD(DebugServerQueryInterface)(THIS_ PVOID*) PURE;
-	STDMETHOD(DebugServerRelease)(THIS_ PVOID) PURE;
+	STDMETHOD_(VOID,DebugServerRelease)(THIS_ PVOID) PURE;
 };
 #undef INTERFACE
 

reactos/include/wine
unicode.h 1.8 -> 1.8.16.1
diff -u -r1.8 -r1.8.16.1
--- unicode.h	15 Apr 2004 09:28:04 -0000	1.8
+++ unicode.h	8 Dec 2004 21:56:58 -0000	1.8.16.1
@@ -88,4 +88,18 @@
     return NULL;
 }
 
+static inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
+{
+    const WCHAR *end;
+    for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)ptr;
+    return NULL;
+}
+
+static inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
+{
+    const WCHAR *end, *ret = NULL;
+    for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = ptr;
+    return (WCHAR *)ret;
+}
+
 #endif

reactos/lib/advapi32/reg
reg.c 1.63 -> 1.63.2.1
diff -u -r1.63 -r1.63.2.1
--- reg.c	22 Nov 2004 16:11:25 -0000	1.63
+++ reg.c	8 Dec 2004 21:56:58 -0000	1.63.2.1
@@ -1,4 +1,4 @@
-/* $Id: reg.c,v 1.63 2004/11/22 16:11:25 ekohl Exp $
+/* $Id: reg.c,v 1.63.2.1 2004/12/08 21:56:58 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -2443,8 +2443,8 @@
 
   if (lpData)
     {
-      ValueData.Length = *lpcbData * sizeof(WCHAR);
-      ValueData.MaximumLength = ValueData.Length + sizeof(WCHAR);
+      ValueData.Length = 0;
+      ValueData.MaximumLength = (*lpcbData + 1) * sizeof(WCHAR);
       ValueData.Buffer = RtlAllocateHeap (ProcessHeap,
 					  0,
 					  ValueData.MaximumLength);
@@ -2464,16 +2464,13 @@
   RtlCreateUnicodeStringFromAsciiz (&ValueName,
 				    (LPSTR)lpValueName);
 
-  if (NULL != lpcbData)
-    {
-      Length = *lpcbData * sizeof(WCHAR);
-    }
+  Length = (lpcbData == NULL) ? 0 : *lpcbData * sizeof(WCHAR);
   ErrorCode = RegQueryValueExW (hKey,
 				ValueName.Buffer,
 				lpReserved,
 				&Type,
-				(LPBYTE)ValueData.Buffer,
-				NULL == lpcbData ? NULL : &Length);
+				(lpData == NULL) ? NULL : (LPBYTE)ValueData.Buffer,
+				&Length);
   DPRINT("ErrorCode %lu\n", ErrorCode);
   RtlFreeUnicodeString(&ValueName);
 
@@ -2498,13 +2495,9 @@
 	    }
 	  Length = Length / sizeof(WCHAR);
 	}
-      else if (lpcbData != NULL)
+      else if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
 	{
-	  Length = min(*lpcbData, Length);
-	  if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL)
-	    {
-	      RtlMoveMemory(lpData, ValueData.Buffer, Length);
-	    }
+	  RtlMoveMemory(lpData, ValueData.Buffer, Length);
 	}
 
       if (lpcbData != NULL)

reactos/lib/cabinet
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:42 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:56:59 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:42 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:56:59 hyperion Exp $
 
 TARGET_NAME = cabinet
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_CABINET)
 

reactos/lib/cabinet
cabextract.c 1.4 -> 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- cabextract.c	19 Sep 2004 09:18:35 -0000	1.4
+++ cabextract.c	8 Dec 2004 21:56:59 -0000	1.4.6.1
@@ -52,7 +52,7 @@
 /* try to open a cabinet file, returns success */
 BOOL cabinet_open(struct cabinet *cab)
 {
-  char *name = (char *)cab->filename;
+  const char *name = cab->filename;
   HANDLE fh;
 
   TRACE("(cab == ^%p)\n", cab);
@@ -177,8 +177,9 @@
  */
 BOOL file_open(struct cab_file *fi, BOOL lower, LPCSTR dir)
 {
-  char c, *s, *d, *name;
+  char c, *d, *name;
   BOOL ok = FALSE;
+  const char *s;
 
   TRACE("(fi == ^%p, lower == %s, dir == %s)\n", fi, lower ? "TRUE" : "FALSE", debugstr_a(dir));
 
@@ -279,7 +280,7 @@
   TRACE("(cab == ^%p, distance == %u)\n", cab, distance);
   if (SetFilePointer(cab->fh, distance, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER) {
     if (distance != INVALID_SET_FILE_POINTER)
-      ERR("%s\n", debugstr_a((char *) cab->filename));
+      ERR("%s\n", debugstr_a(cab->filename));
   }
 }
 
@@ -291,7 +292,7 @@
 void cabinet_seek(struct cabinet *cab, cab_off_t offset) {
   TRACE("(cab == ^%p, offset == %u)\n", cab, offset);
   if (SetFilePointer(cab->fh, offset, NULL, FILE_BEGIN) != offset)
-    ERR("%s seek failure\n", debugstr_a((char *)cab->filename));
+    ERR("%s seek failure\n", debugstr_a(cab->filename));
 }
 
 /*******************************************************************
@@ -317,15 +318,15 @@
   TRACE("(cab == ^%p, buf == ^%p, length == %u)\n", cab, buf, length);
 
   if (length > avail) {
-    WARN("%s: WARNING; cabinet is truncated\n", debugstr_a((char *)cab->filename));
+    WARN("%s: WARNING; cabinet is truncated\n", debugstr_a(cab->filename));
     length = avail;
   }
 
   if (! ReadFile( cab->fh, (LPVOID) buf, length, &bytes_read, NULL )) {
-    ERR("%s read error\n", debugstr_a((char *) cab->filename));
+    ERR("%s read error\n", debugstr_a(cab->filename));
     return FALSE;
   } else if (bytes_read != length) {
-    ERR("%s read size mismatch\n", debugstr_a((char *) cab->filename));
+    ERR("%s read size mismatch\n", debugstr_a(cab->filename));
     return FALSE;
   }
 
@@ -358,7 +359,7 @@
 
     if (!ok) {
       if (len == maxlen) {
-        ERR("%s: WARNING; cabinet is truncated\n", debugstr_a((char *) cab->filename));
+        ERR("%s: WARNING; cabinet is truncated\n", debugstr_a(cab->filename));
         break;
       }
       len += 256;
@@ -403,21 +404,21 @@
   
   /* check basic MSCF signature */
   if (EndGetI32(buf+cfhead_Signature) != 0x4643534d) {
-    ERR("%s: not a Microsoft cabinet file\n", debugstr_a((char *) cab->filename));
+    ERR("%s: not a Microsoft cabinet file\n", debugstr_a(cab->filename));
     return FALSE;
   }
 
   /* get the number of folders */
   num_folders = EndGetI16(buf+cfhead_NumFolders);
   if (num_folders == 0) {
-    ERR("%s: no folders in cabinet\n", debugstr_a((char *) cab->filename));
+    ERR("%s: no folders in cabinet\n", debugstr_a(cab->filename));
     return FALSE;
   }
 
   /* get the number of files */
   num_files = EndGetI16(buf+cfhead_NumFiles);
   if (num_files == 0) {
-    ERR("%s: no files in cabinet\n", debugstr_a((char *) cab->filename));
+    ERR("%s: no files in cabinet\n", debugstr_a(cab->filename));
     return FALSE;
   }
 
@@ -425,7 +426,7 @@
   if ((buf[cfhead_MajorVersion] > 1) ||
       (buf[cfhead_MajorVersion] == 1 && buf[cfhead_MinorVersion] > 3))
   {
-    WARN("%s: WARNING; cabinet format version > 1.3\n", debugstr_a((char *) cab->filename));
+    WARN("%s: WARNING; cabinet format version > 1.3\n", debugstr_a(cab->filename));
   }
 
   /* read the reserved-sizes part of header, if present */
@@ -437,13 +438,13 @@
     cab->block_resv = buf[cfheadext_DataReserved];
 
     if (header_resv > 60000) {
-      WARN("%s: WARNING; header reserved space > 60000\n", debugstr_a((char *) cab->filename));
+      WARN("%s: WARNING; header reserved space > 60000\n", debugstr_a(cab->filename));
     }
 
     /* skip the reserved header */
     if (header_resv) 
       if (SetFilePointer(cab->fh, (cab_off_t) header_resv, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
-        ERR("seek failure: %s\n", debugstr_a((char *) cab->filename));
+        ERR("seek failure: %s\n", debugstr_a(cab->filename));
   }
 
   if (cab->flags & cfheadPREV_CABINET) {
@@ -528,7 +529,7 @@
   struct cabinet *cab = (struct cabinet *) calloc(1, sizeof(struct cabinet));
   int ok;
 
-  TRACE("(name == %s, offset == %u)\n", debugstr_a((char *) name), offset);
+  TRACE("(name == %s, offset == %u)\n", debugstr_a(name), offset);
 
   if (!cab) return NULL;
 
@@ -1954,7 +1955,7 @@
   cab_off_t offset, caboff, cablen = 0, foffset = 0, filelen, length;
   int state = 0, found = 0, ok = 0;
 
-  TRACE("(name == %s)\n", debugstr_a((char *) name));
+  TRACE("(name == %s)\n", debugstr_a(name));
 
   /* open the file and search for cabinet headers */
   if ((cab = (struct cabinet *) calloc(1, sizeof(struct cabinet)))) {
@@ -2489,7 +2490,7 @@
 exit_handler:
   if (err) {
     const char *errmsg;
-    char *cabname;
+    const char *cabname;
     switch (err) {
     case DECR_NOMEMORY:
       errmsg = "out of memory!\n"; break;
@@ -2508,10 +2509,10 @@
     }
 
     if (CAB(current)) {
-      cabname = (char *) (CAB(current)->cab[CAB(split)]->filename);
+      cabname = (CAB(current)->cab[CAB(split)]->filename);
     }
     else {
-      cabname = (char *) (fi->folder->cab[0]->filename);
+      cabname = (fi->folder->cab[0]->filename);
     }
 
     ERR((char *)errmsg, cabname);

reactos/lib/cabinet
winehq2ros.patch 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- winehq2ros.patch	19 Sep 2004 09:18:36 -0000	1.2
+++ winehq2ros.patch	8 Dec 2004 21:56:59 -0000	1.2.6.1
@@ -1,12 +1,12 @@
 Index: cabextract.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/cabinet/cabextract.c,v
-retrieving revision 1.14
-diff -u -r1.14 cabextract.c
---- cabextract.c	2 Sep 2004 23:00:54 -0000	1.14
-+++ cabextract.c	19 Sep 2004 09:31:32 -0000
-@@ -2514,7 +2514,7 @@
-       cabname = (char *) (fi->folder->cab[0]->filename);
+retrieving revision 1.15
+diff -u -r1.15 cabextract.c
+--- cabextract.c	30 Nov 2004 21:39:00 -0000	1.15
++++ cabextract.c	5 Dec 2004 21:40:05 -0000
+@@ -2515,7 +2515,7 @@
+       cabname = (fi->folder->cab[0]->filename);
      }
  
 -    ERR(errmsg, cabname);

reactos/lib/comctl32
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:42 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:56:59 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:42 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:56:59 hyperion Exp $
 
 TARGET_NAME = comctl32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_COMCTL32)
 

reactos/lib/comctl32
animate.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- animate.c	20 Oct 2004 08:36:54 -0000	1.7
+++ animate.c	8 Dec 2004 21:56:59 -0000	1.7.2.1
@@ -73,6 +73,7 @@
    CRITICAL_SECTION	cs;
    HANDLE		hStopEvent;
    HANDLE		hThread;
+   DWORD		threadId;
    UINT			uTimer;
    /* data for playing the file */
    int			nFromFrame;
@@ -149,14 +150,20 @@
         HANDLE handle = infoPtr->hThread;
 
         TRACE("stopping animation thread\n");
+        infoPtr->hThread = 0;
         SetEvent( infoPtr->hStopEvent );
-        LeaveCriticalSection(&infoPtr->cs);  /* leave it a chance to run */
-        WaitForSingleObject( handle, INFINITE );
-        TRACE("animation thread stopped\n");
-        EnterCriticalSection(&infoPtr->cs);
-        CloseHandle( infoPtr->hThread );
+
+        if (infoPtr->threadId != GetCurrentThreadId())
+        {
+            LeaveCriticalSection(&infoPtr->cs);  /* leave it a chance to run */
+            WaitForSingleObject( handle, INFINITE );
+            TRACE("animation thread stopped\n");
+            EnterCriticalSection(&infoPtr->cs);
+        }
+
+        CloseHandle( handle );
         CloseHandle( infoPtr->hStopEvent );
-        infoPtr->hThread = 0;
+        infoPtr->hStopEvent = 0;
     }
     if (infoPtr->uTimer) {
 	KillTimer(infoPtr->hwndSelf, infoPtr->uTimer);
@@ -399,7 +406,7 @@
         LeaveCriticalSection(&infoPtr->cs);
 
         /* time is in microseconds, we should convert it to milliseconds */
-        if (WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0)
+        if ((event == 0) || WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0)
             break;
     }
     return TRUE;
@@ -439,8 +446,6 @@
 	/* create a timer to display AVI */
 	infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
     } else {
-        DWORD threadID;
-
         if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
         {
             infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify,
@@ -449,7 +454,7 @@
 
 	TRACE("Using an animation thread\n");
         infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL );
-        infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &threadID);
+        infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &infoPtr->threadId);
         if(!infoPtr->hThread)
         {
            ERR("Could not create animation thread!\n");
@@ -950,7 +955,7 @@
 
     ZeroMemory(&wndClass, sizeof(WNDCLASSA));
     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
-    wndClass.lpfnWndProc   = (WNDPROC)ANIMATE_WindowProc;
+    wndClass.lpfnWndProc   = ANIMATE_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(ANIMATE_INFO *);
     wndClass.hCursor       = LoadCursorA(0, (LPSTR)IDC_ARROW);

reactos/lib/comctl32
comboex.c 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- comboex.c	20 Oct 2004 08:36:54 -0000	1.7
+++ comboex.c	8 Dec 2004 21:56:59 -0000	1.7.2.1
@@ -45,9 +45,9 @@
 WINE_DEFAULT_DEBUG_CHANNEL(comboex);
 
 /* Item structure */
-typedef struct
+typedef struct _CBE_ITEMDATA
 {
-    VOID         *next;
+    struct _CBE_ITEMDATA *next;
     UINT         mask;
     LPWSTR       pszText;
     LPWSTR       pszTemp;
@@ -126,10 +126,8 @@
 
 
 /* Things common to the entire DLL */
-static LRESULT WINAPI
-COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-static LRESULT WINAPI
-COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+static LRESULT WINAPI COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+static LRESULT WINAPI COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
 typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
 
@@ -458,7 +456,7 @@
 
     /* find the item in the list */
     while (item && (i > index)) {
-	item = (CBE_ITEMDATA *)item->next;
+	item = item->next;
 	i--;
     }
     if (!item || (i != index)) {
@@ -579,7 +577,7 @@
 	CBE_ITEMDATA *moving = infoPtr->items;
 
 	while ((i > index) && moving) {
-	    moving = (CBE_ITEMDATA *)moving->next;
+	    moving = moving->next;
 	    i--;
 	}
 	if (!moving) {
@@ -1252,7 +1250,7 @@
 
 	/* find the prior item in the list */
 	while (item->next && (i > dis->itemID)) {
-	    item = (CBE_ITEMDATA *)item->next;
+	    item = item->next;
 	    i--;
 	}
 	if (!item->next || (i != dis->itemID)) {
@@ -1260,7 +1258,7 @@
 	    return FALSE;
 	}
 	olditem = item->next;
-	item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
+	item->next = item->next->next;
     }
     infoPtr->nb_items--;
 
@@ -1529,7 +1527,7 @@
 
 	item = infoPtr->items;
 	while (item) {
-	    next = (CBE_ITEMDATA *)item->next;
+	    next = item->next;
 	    COMBOEX_FreeText (item);
 	    Free (item);
 	    item = next;
@@ -1570,7 +1568,7 @@
     DWORD oldstyle, newstyle;
 
     oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
-    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
+    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER);
     if (newstyle != oldstyle) {
 	TRACE("req style %08lx, reseting style %08lx\n",
 	      oldstyle, newstyle);
@@ -1912,7 +1910,8 @@
 	    rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
 			                          CB_GETITEMHEIGHT, -1, 0);
 	    rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
-	    POINTSTOPOINT(pt, MAKEPOINTS(lParam));
+	    pt.x = (short)LOWORD(lParam);
+	    pt.y = (short)HIWORD(lParam);
 	    if (PtInRect(&rect, pt))
 		return CallWindowProcW (infoPtr->prevComboWndProc,
 				        hwnd, uMsg, wParam, lParam);
@@ -2254,7 +2253,7 @@
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSW));
     wndClass.style         = CS_GLOBALCLASS;
-    wndClass.lpfnWndProc   = (WNDPROC)COMBOEX_WindowProc;
+    wndClass.lpfnWndProc   = COMBOEX_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(COMBOEX_INFO *);
     wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);

reactos/lib/comctl32
datetime.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- datetime.c	19 Sep 2004 09:50:06 -0000	1.5
+++ datetime.c	8 Dec 2004 21:56:59 -0000	1.5.6.1
@@ -19,16 +19,31 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * NOTE
+ * 
+ * This code was audited for completeness against the documented features
+ * of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
+ * 
+ * Unless otherwise noted, we believe this code to be complete, as per
+ * the specification mentioned above.
+ * If you discover missing features, or bugs, please note them below.
+ * 
  * TODO:
- *   - All messages.
- *   - All notifications.
- *
+ *    -- DTS_APPCANPARSE
+ *    -- DTS_SHORTDATECENTURYFORMAT
+ *    -- DTN_CLOSEUP
+ *    -- DTN_FORMAT
+ *    -- DTN_FORMATQUERY
+ *    -- DTN_USERSTRING
+ *    -- DTN_WMKEYDOWN
+ *    -- FORMATCALLBACK
  */
 
 #include <math.h>
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <limits.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -38,32 +53,35 @@
 #include "commctrl.h"
 #include "comctl32.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(datetime);
 
 typedef struct
 {
-	HWND hMonthCal;
-	HWND hwndNotify;
-	HWND hUpdown;
-	SYSTEMTIME date;
-	BOOL dateValid;
-	HWND hwndCheckbut;
-	RECT rcClient; /* rect around the edge of the window */
-	RECT rcDraw; /* rect inside of the border */
-	RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
-	RECT calbutton; /* button that toggles the dropdown of the monthcal control */
-	BOOL bCalDepressed; /* TRUE = cal button is depressed */
-	int  select;
-	HFONT hFont;
-	int nrFieldsAllocated;
-	int nrFields;
-	int haveFocus;
-	int *fieldspec;
-	RECT *fieldRect;
-	int  *buflen;
-	char textbuf[256];
-        POINT monthcal_pos;
+    HWND hwndSelf;
+    HWND hMonthCal;
+    HWND hwndNotify;
+    HWND hUpdown;
+    DWORD dwStyle;
+    SYSTEMTIME date;
+    BOOL dateValid;
+    HWND hwndCheckbut;
+    RECT rcClient; /* rect around the edge of the window */
+    RECT rcDraw; /* rect inside of the border */
+    RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
+    RECT calbutton; /* button that toggles the dropdown of the monthcal control */
+    BOOL bCalDepressed; /* TRUE = cal button is depressed */
+    int  select;
+    HFONT hFont;
+    int nrFieldsAllocated;
+    int nrFields;
+    int haveFocus;
+    int *fieldspec;
+    RECT *fieldRect;
+    int  *buflen;
+    WCHAR textbuf[256];
+    POINT monthcal_pos;
 } DATETIME_INFO, *LPDATETIME_INFO;
 
 /* in monthcal.c */
@@ -110,1174 +128,812 @@
 #define DTHT_MCPOPUP  0x300     /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
 #define DTHT_GOTFOCUS 0x400     /* tests for date-fields */
 
-#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongPtrW (hwnd, 0))
-
-static BOOL DATETIME_SendSimpleNotify (HWND hwnd, UINT code);
-static BOOL DATETIME_SendDateTimeChangeNotify (HWND hwnd);
+static BOOL DATETIME_SendSimpleNotify (DATETIME_INFO *infoPtr, UINT code);
+static BOOL DATETIME_SendDateTimeChangeNotify (DATETIME_INFO *infoPtr);
 extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to);
-static const char *allowedformatchars = {"dhHmMstyX'"};
+static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', '\'', 0};
 static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1};
 
 
-static LRESULT
-DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
+static DWORD
+DATETIME_GetSystemTime (DATETIME_INFO *infoPtr, SYSTEMTIME *lprgSysTimeArray)
 {
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
-  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
+    if (!lprgSysTimeArray) return GDT_NONE;
 
-  TRACE("%04x %08lx\n",wParam,lParam);
-  if (!lParam) return GDT_NONE;
-
-  if ((dwStyle & DTS_SHOWNONE) &&
-       (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
+    if ((infoPtr->dwStyle & DTS_SHOWNONE) &&
+        (SendMessageW (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
         return GDT_NONE;
 
-  MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
-
-  return GDT_VALID;
-}
-
-
-static LRESULT
-DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
-
-  TRACE("%p %04x %08lx\n",hwnd, wParam, lParam);
-  if (!lParam) return 0;
-
-  TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
-        lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
-        lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
-
-  if (wParam==GDT_VALID) {
-      infoPtr->dateValid = TRUE;
-      MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
-	SendMessageA(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
-      SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
-  } else if (wParam==GDT_NONE) {
-      infoPtr->dateValid = FALSE;
-      SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
-  }
-  InvalidateRect(hwnd, NULL, TRUE);
-  return 1;
-}
-
-
-static LRESULT
-DATETIME_GetRange (HWND hwnd, LPARAM lParam )
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-  LRESULT ret;
-
-  TRACE("%08lx\n", lParam);
-  ret =  SendMessageA (infoPtr->hMonthCal, MCM_GETRANGE, 0, lParam);
-  if (!ret) ret = 1; /* bug emulation... */
-  return ret;
-}
-
-static LRESULT
-DATETIME_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam )
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-
-  TRACE("%04x %08lx\n",wParam,lParam);
-
-  return SendMessageA (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam);
-}
-
-static LRESULT
-DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam)
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-
-  TRACE("%04x\n",wParam);
-  return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
-}
-
-
-static LRESULT
-DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-
-  TRACE("%04x %08lx\n",wParam,lParam);
-  return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
-}
-
-
-/* FIXME: need to get way to force font into monthcal structure */
-static LRESULT
-DATETIME_GetMonthCal (HWND hwnd)
-{
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
+    MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
 
-  TRACE("\n");
-  return (LRESULT)infoPtr->hMonthCal;
+    return GDT_VALID;
 }
 
 
-
-/* FIXME: need to get way to force font into monthcal structure */
-
-static LRESULT
-DATETIME_GetMonthCalFont (HWND hwnd)
+static BOOL
+DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, SYSTEMTIME *lprgSysTimeArray)
 {
+    if (!lprgSysTimeArray) return 0;
 
-  TRACE("\n");
-  return 0;
-}
-
-
-static LRESULT
-DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
+    TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
+          lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
+          lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
+
+    if (flag == GDT_VALID) {
+        infoPtr->dateValid = TRUE;
+        MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
+        SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
+        SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
+    } else if (flag == GDT_NONE) {
+        infoPtr->dateValid = FALSE;
+        SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
+    }
 
-  TRACE("%04x %08lx\n",wParam,lParam);
-  return 0;
+    InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
+    return TRUE;
 }
 
 
-/*
-   Split up a formattxt in actions.
-   See ms documentation for the meaning of the letter codes/'specifiers'.
-
-   Notes:
-   *'dddddd' is handled as 'dddd' plus 'dd'.
-   *unrecognized formats are strings (here given the type DT_STRING;
-   start of the string is encoded in lower bits of DT_STRING.
-   Therefore, 'string' ends finally up as '<show seconds>tring'.
-
+/***
+ * Split up a formattxt in actions.
+ * See ms documentation for the meaning of the letter codes/'specifiers'.
+ *
+ * Notes:
+ * *'dddddd' is handled as 'dddd' plus 'dd'.
+ * *unrecognized formats are strings (here given the type DT_STRING;
+ * start of the string is encoded in lower bits of DT_STRING.
+ * Therefore, 'string' ends finally up as '<show seconds>tring'.
+ *
  */
-
-
 static void
-DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt)
+DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt)
 {
- unsigned int i;
- int j,k,len;
- int *nrFields=& infoPtr->nrFields;
-
- TRACE ("%s\n",formattxt);
-
-
- *nrFields=0;
- infoPtr->fieldspec[*nrFields]=0;
- len=strlen(allowedformatchars);
- k=0;
-
- for (i=0; formattxt[i]; i++)  {
-	TRACE ("\n%d %c:",i, formattxt[i]);
- 	for (j=0; j<len; j++) {
- 		if (allowedformatchars[j]==formattxt[i]) {
-			TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
-							 infoPtr->fieldspec[*nrFields]);
-			if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
-				infoPtr->fieldspec[*nrFields]=(j<<4) +1;
-				break;
-			}
-			if (infoPtr->fieldspec[*nrFields]>>4!=j) {
-				(*nrFields)++;
-				infoPtr->fieldspec[*nrFields]=(j<<4) +1;
-				break;
-			}
-			if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
-				(*nrFields)++;
-				infoPtr->fieldspec[*nrFields]=(j<<4) +1;
-				break;
-			}
-			infoPtr->fieldspec[*nrFields]++;
-			break;
-		}   /* if allowedformatchar */
-	 } /* for j */
-
-
-			/* char is not a specifier: handle char like a string */
-	if (j==len) {
+    unsigned int i;
+    int j, k, len;
+    int *nrFields = &infoPtr->nrFields;
+
+    *nrFields = 0;
+    infoPtr->fieldspec[*nrFields] = 0;
+    len = strlenW(allowedformatchars);
+    k = 0;
+
+    for (i = 0; formattxt[i]; i++)  {
+	TRACE ("\n%d %c:", i, formattxt[i]);
+ 	for (j = 0; j < len; j++) {
+ 	    if (allowedformatchars[j]==formattxt[i]) {
+		TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
 		if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
-			infoPtr->fieldspec[*nrFields]=DT_STRING+k;
-			infoPtr->buflen[*nrFields]=0;
-        } else
-		if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING)  {
-			(*nrFields)++;
-			infoPtr->fieldspec[*nrFields]=DT_STRING+k;
-			infoPtr->buflen[*nrFields]=0;
+		    infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
+		    break;
+		}
+		if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
+		    (*nrFields)++;
+		    infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
+		    break;
+		}
+		if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
+		    (*nrFields)++;
+		    infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
+		    break;
 		}
-		infoPtr->textbuf[k]=formattxt[i];
-		k++;
-		infoPtr->buflen[*nrFields]++;
+		infoPtr->fieldspec[*nrFields]++;
+		break;
+	    }   /* if allowedformatchar */
+	} /* for j */
+
+	/* char is not a specifier: handle char like a string */
+	if (j == len) {
+	    if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
+		infoPtr->fieldspec[*nrFields] = DT_STRING + k;
+		infoPtr->buflen[*nrFields] = 0;
+            } else if ((infoPtr->fieldspec[*nrFields] & DT_STRING) != DT_STRING)  {
+		(*nrFields)++;
+		infoPtr->fieldspec[*nrFields] = DT_STRING + k;
+		infoPtr->buflen[*nrFields] = 0;
+	    }
+	    infoPtr->textbuf[k] = formattxt[i];
+	    k++;
+	    infoPtr->buflen[*nrFields]++;
 	}   /* if j=len */
 
-	if (*nrFields==infoPtr->nrFieldsAllocated) {
-		FIXME ("out of memory; should reallocate. crash ahead.\n");
+	if (*nrFields == infoPtr->nrFieldsAllocated) {
+	    FIXME ("out of memory; should reallocate. crash ahead.\n");
 	}
+    } /* for i */
 
-  } /* for i */
-
-  TRACE("\n");
+    TRACE("\n");
 
-  if (infoPtr->fieldspec[*nrFields]!=0) (*nrFields)++;
+    if (infoPtr->fieldspec[*nrFields] != 0) (*nrFields)++;
 }
 
 
-static LRESULT
-DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat)
 {
- DATETIME_INFO *infoPtr= DATETIME_GetInfoPtr (hwnd);
- char format_buf[80];
- DWORD format_item;
-
- TRACE("%04x %08lx\n",wParam,lParam);
- if (!lParam) {
-  	DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
-
-	if (dwStyle & DTS_LONGDATEFORMAT)
-		format_item=LOCALE_SLONGDATE;
-	else if (dwStyle & DTS_TIMEFORMAT)
-		format_item=LOCALE_STIMEFORMAT;
+    if (!lpszFormat) {
+	WCHAR format_buf[80];
+	DWORD format_item;
+
+	if (infoPtr->dwStyle & DTS_LONGDATEFORMAT)
+	    format_item = LOCALE_SLONGDATE;
+	else if (infoPtr->dwStyle & DTS_TIMEFORMAT)
+	    format_item = LOCALE_STIMEFORMAT;
         else /* DTS_SHORTDATEFORMAT */
-		format_item=LOCALE_SSHORTDATE;
-	GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
-	DATETIME_UseFormat (infoPtr, format_buf);
- }
- else
- 	DATETIME_UseFormat (infoPtr, (char *) lParam);
+	    format_item = LOCALE_SSHORTDATE;
+	GetLocaleInfoW( GetSystemDefaultLCID(), format_item, format_buf, sizeof(format_buf)/sizeof(format_buf[0]));
+	lpszFormat = format_buf;
+    }
 
- return infoPtr->nrFields;
-}
+    DATETIME_UseFormat (infoPtr, lpszFormat);
 
+    return infoPtr->nrFields;
+}
 
-static LRESULT
-DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
+static BOOL
+DATETIME_SetFormatA (DATETIME_INFO *infoPtr, LPCSTR lpszFormat)
 {
- TRACE("%04x %08lx\n",wParam,lParam);
- if (lParam) {
-	LPSTR buf;
-	int retval;
-        int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
-
- 	buf = (LPSTR) Alloc (len);
-        WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL );
-	retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
-	Free (buf);
+    if (lpszFormat) {
+	BOOL retval;
+	INT len = MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, NULL, 0);
+	LPWSTR wstr = Alloc(len * sizeof(WCHAR));
+	if (wstr) MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, wstr, len);
+	retval = DATETIME_SetFormatW (infoPtr, wstr);
+	Free (wstr);
 	return retval;
- }
- else
-	return DATETIME_SetFormat (hwnd, 0, 0);
+    }
+    else
+	return DATETIME_SetFormatW (infoPtr, 0);
 
 }
 
 
 static void
-DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result, int resultSize)
+DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, LPWSTR result, int resultSize)
 {
- SYSTEMTIME date = infoPtr->date;
- int spec;
- char buffer[80];
-
- *result=0;
- TRACE ("%d,%d\n", infoPtr->nrFields, count);
- if ((count>infoPtr->nrFields) || (count<0)) {
+    static const WCHAR fmt_dW[] = { '%', 'd', 0 };
+    static const WCHAR fmt__2dW[] = { '%', '.', '2', 'd', 0 };
+    static const WCHAR fmt__3sW[] = { '%', '.', '3', 's', 0 };
+    SYSTEMTIME date = infoPtr->date;
+    int spec;
+    WCHAR buffer[80];
+
+    *result=0;
+    TRACE ("%d,%d\n", infoPtr->nrFields, count);
+    if (count>infoPtr->nrFields || count < 0) {
 	WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
 	return;
- }
+    }
 
- if (!infoPtr->fieldspec) return;
+    if (!infoPtr->fieldspec) return;
 
- spec=infoPtr->fieldspec[count];
- if (spec & DT_STRING) {
-	int txtlen=infoPtr->buflen[count];
+    spec = infoPtr->fieldspec[count];
+    if (spec & DT_STRING) {
+	int txtlen = infoPtr->buflen[count];
 
         if (txtlen > resultSize)
             txtlen = resultSize - 1;
-	memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
-	result[txtlen]=0;
-	TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
+	memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR));
+	result[txtlen] = 0;
+	TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
 	return;
- }
+    }
 
 
- switch (spec) {
+    switch (spec) {
 	case DT_END_FORMAT:
-		*result=0;
-		break;
+	    *result = 0;
+	    break;
 	case ONEDIGITDAY:
-		sprintf (result,"%d",date.wDay);
-	 	break;
+	    wsprintfW (result, fmt_dW, date.wDay);
+	    break;
 	case TWODIGITDAY:
-		sprintf (result,"%.2d",date.wDay);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wDay);
+	    break;
 	case THREECHARDAY:
-	        GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
-				result,4);
-		/*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
-		break;
+	    GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7, result, 4);
+	    /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
+	    break;
 	case FULLDAY:
-	        GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
-                               result, resultSize);
-		break;
+	    GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME1+(date.wDayOfWeek+6)%7, result, resultSize);
+	    break;
 	case ONEDIGIT12HOUR:
-		if (date.wHour>12)
-			sprintf (result,"%d",date.wHour-12);
-		else
-			sprintf (result,"%d",date.wHour);
-		break;
+	    wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0));
+	    break;
 	case TWODIGIT12HOUR:
-		if (date.wHour>12)
-			sprintf (result,"%.2d",date.wHour-12);
-		else
-			sprintf (result,"%.2d",date.wHour);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0));
+	    break;
 	case ONEDIGIT24HOUR:
-		sprintf (result,"%d",date.wHour);
-		break;
+	    wsprintfW (result, fmt_dW, date.wHour);
+	    break;
 	case TWODIGIT24HOUR:
-		sprintf (result,"%.2d",date.wHour);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wHour);
+	    break;
 	case ONEDIGITSECOND:
-		sprintf (result,"%d",date.wSecond);
-		break;
+	    wsprintfW (result, fmt_dW, date.wSecond);
+	    break;
 	case TWODIGITSECOND:
-		sprintf (result,"%.2d",date.wSecond);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wSecond);
+	    break;
 	case ONEDIGITMINUTE:
-		sprintf (result,"%d",date.wMinute);
-		break;
+	    wsprintfW (result, fmt_dW, date.wMinute);
+	    break;
 	case TWODIGITMINUTE:
-		sprintf (result,"%.2d",date.wMinute);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wMinute);
+	    break;
 	case ONEDIGITMONTH:
-		sprintf (result,"%d",date.wMonth);
-	 	break;
+	    wsprintfW (result, fmt_dW, date.wMonth);
+	    break;
 	case TWODIGITMONTH:
-		sprintf (result,"%.2d",date.wMonth);
-		break;
+	    wsprintfW (result, fmt__2dW, date.wMonth);
+	    break;
 	case THREECHARMONTH:
-		GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
-                               buffer,sizeof(buffer));
-		sprintf (result,"%.3s",buffer);
-		break;
+	    GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1+date.wMonth -1, 
+			   buffer, sizeof(buffer)/sizeof(buffer[0]));
+	    wsprintfW (result, fmt__3sW, buffer);
+	    break;
 	case FULLMONTH:
-		GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
-                               result, resultSize);
-		break;
+	    GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
+                           result, resultSize);
+	    break;
 	case ONELETTERAMPM:
-		if (date.wHour<12)
-			strcpy (result,"A");
-		else
-			strcpy (result,"P");
-		break;
+	    result[0] = (date.wHour < 12 ? 'A' : 'P');
+	    result[1] = 0;
+	    break;
 	case TWOLETTERAMPM:
-		if (date.wHour<12)
-			strcpy (result,"AM");
-		else
-			strcpy (result,"PM");
-		break;
+	    result[0] = (date.wHour < 12 ? 'A' : 'P');
+	    result[1] = 'M';
+	    result[2] = 0;
+	    break;
 	case FORMATCALLBACK:
-		FIXME ("Not implemented\n");
-		strcpy (result,"xxx");
-		break;
+	    FIXME ("Not implemented\n");
+	    result[0] = 'x';
+	    result[1] = 0;
+	    break;
 	case ONEDIGITYEAR:
-		sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
-	 	break;
+	    wsprintfW (result, fmt_dW, date.wYear-10* (int) floor(date.wYear/10));
+	    break;
 	case TWODIGITYEAR:
-		sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
-		break;
+	    wsprintfW (result, fmt__2dW, date.wYear-100* (int) floor(date.wYear/100));
+	    break;
         case INVALIDFULLYEAR:
 	case FULLYEAR:
-		sprintf (result,"%d",date.wYear);
-		break;
+	    wsprintfW (result, fmt_dW, date.wYear);
+	    break;
     }
 
-	TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
+    TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
 }
 
-
-static void
-DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number)
+static int wrap(int val, int delta, int minVal, int maxVal)
 {
- SYSTEMTIME *date = &infoPtr->date;
- int spec;
-
- TRACE ("%d\n",number);
- if ((number>infoPtr->nrFields) || (number<0)) return;
-
- spec=infoPtr->fieldspec[number];
- if ((spec & DTHT_DATEFIELD)==0) return;
-
- switch (spec) {
-	case ONEDIGITDAY:
-	case TWODIGITDAY:
-	case THREECHARDAY:
-	case FULLDAY:
-		date->wDay++;
-		if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
-		  date->wDay=1;
-		break;
-	case ONEDIGIT12HOUR:
-	case TWODIGIT12HOUR:
-	case ONEDIGIT24HOUR:
-	case TWODIGIT24HOUR:
-		date->wHour++;
-		if (date->wHour>23) date->wHour=0;
-		break;
-	case ONEDIGITSECOND:
-	case TWODIGITSECOND:
-		date->wSecond++;
-		if (date->wSecond>59) date->wSecond=0;
-		break;
-	case ONEDIGITMINUTE:
-	case TWODIGITMINUTE:
-		date->wMinute++;
-		if (date->wMinute>59) date->wMinute=0;
-		break;
-	case ONEDIGITMONTH:
-	case TWODIGITMONTH:
-	case THREECHARMONTH:
-	case FULLMONTH:
-		date->wMonth++;
-		if (date->wMonth>12) date->wMonth=1;
-		if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
-			date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
-		break;
-	case ONELETTERAMPM:
-	case TWOLETTERAMPM:
-		date->wHour+=12;
-		if (date->wHour>23) date->wHour-=24;
-		break;
-	case FORMATCALLBACK:
-		FIXME ("Not implemented\n");
-		break;
-	case ONEDIGITYEAR:
-	case TWODIGITYEAR:
-	case FULLYEAR:
-		date->wYear++;
-		break;
-	}
-
+    val += delta;
+    if (delta == INT_MIN || val < minVal) return maxVal;
+    if (delta == INT_MAX || val > maxVal) return minVal;
+    return val;
 }
 
-
 static void
-DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number)
+DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta)
 {
- SYSTEMTIME *date = & infoPtr->date;
- int spec;
+    SYSTEMTIME *date = &infoPtr->date;
 
- TRACE ("%d\n",number);
- if ((number>infoPtr->nrFields) || (number<0)) return;
+    TRACE ("%d\n", number);
+    if ((number > infoPtr->nrFields) || (number < 0)) return;
 
- spec = infoPtr->fieldspec[number];
- if ((spec & DTHT_DATEFIELD)==0) return;
+    if ((infoPtr->fieldspec[number] & DTHT_DATEFIELD) == 0) return;
 
- TRACE ("%x\n",spec);
-
- switch (spec) {
-	case ONEDIGITDAY:
-	case TWODIGITDAY:
-	case THREECHARDAY:
-	case FULLDAY:
-		date->wDay--;
-		if (date->wDay<1)
-		  date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
-		break;
-	case ONEDIGIT12HOUR:
-	case TWODIGIT12HOUR:
-	case ONEDIGIT24HOUR:
-	case TWODIGIT24HOUR:
-		if (date->wHour)
-			date->wHour--;
-		else
-			date->wHour=23;
-		break;
-	case ONEDIGITSECOND:
-	case TWODIGITSECOND:
-		if (date->wHour)
-			date->wSecond--;
-		else
-			date->wHour=59;
-		break;
-	case ONEDIGITMINUTE:
-	case TWODIGITMINUTE:
-		if (date->wMinute)
-			date->wMinute--;
-		else
-			date->wMinute=59;
-		break;
-	case ONEDIGITMONTH:
-	case TWODIGITMONTH:
-	case THREECHARMONTH:
-	case FULLMONTH:
-		if (date->wMonth>1)
-			date->wMonth--;
-		else
-			date->wMonth=12;
-		if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
-			date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
-		break;
-	case ONELETTERAMPM:
-	case TWOLETTERAMPM:
-		if (date->wHour<12)
-			date->wHour+=12;
-		else
-			date->wHour-=12;
-		break;
-	case FORMATCALLBACK:
-		FIXME ("Not implemented\n");
-		break;
+    switch (infoPtr->fieldspec[number]) {
 	case ONEDIGITYEAR:
 	case TWODIGITYEAR:
 	case FULLYEAR:
-		date->wYear--;
-		break;
-	}
-
-}
-
-
-static void
-DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number)
-{
- SYSTEMTIME *date = &infoPtr->date;
- int spec;
-
- TRACE ("%d\n",number);
- if ((number>infoPtr->nrFields) || (number<0)) return;
-
- spec = infoPtr->fieldspec[number];
- if ((spec & DTHT_DATEFIELD)==0) return;
-
-
- switch (spec) {
-	case ONEDIGITDAY:
-	case TWODIGITDAY:
-	case THREECHARDAY:
-	case FULLDAY:
-		date->wDay = 1;
-		break;
-	case ONEDIGIT12HOUR:
-	case TWODIGIT12HOUR:
-	case ONEDIGIT24HOUR:
-	case TWODIGIT24HOUR:
-	case ONELETTERAMPM:
-	case TWOLETTERAMPM:
-		date->wHour = 0;
-		break;
-	case ONEDIGITSECOND:
-	case TWODIGITSECOND:
-		date->wSecond = 0;
-		break;
-	case ONEDIGITMINUTE:
-	case TWODIGITMINUTE:
-		date->wMinute = 0;
-		break;
+	    date->wYear = wrap(date->wYear, delta, 1752, 9999);
+	    break;
 	case ONEDIGITMONTH:
 	case TWODIGITMONTH:
 	case THREECHARMONTH:
 	case FULLMONTH:
-		date->wMonth = 1;
-	case FORMATCALLBACK:
-		FIXME ("Not implemented\n");
-		break;
-	case ONEDIGITYEAR:
-	case TWODIGITYEAR:
-        /* FYI: On 1752/9/14 the calendar changed and England and the
-         * American colonies changed to the Gregorian calendar. This change
-         * involved having September 14th follow September 2nd. So no date
-         * algorithm works before that date.
-         */
-	case FULLYEAR:
-		date->wSecond = 0;
-		date->wMinute = 0;
-		date->wHour = 0;
-		date->wDay = 14;		/* overactive ms-programmers..*/
-		date->wMonth = 9;
-		date->wYear = 1752;
-		break;
-	}
-
-}
-
-
-static void
-DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number)
-{
- SYSTEMTIME *date = & infoPtr->date;
- int spec;
-
- TRACE("%d \n",number);
- if ((number>infoPtr->nrFields) || (number<0)) return;
-
- spec=infoPtr->fieldspec[number];
- if ((spec & DTHT_DATEFIELD)==0) return;
-
- switch (spec) {
+	    date->wMonth = wrap(date->wMonth, delta, 1, 12);
+	    delta = 0;
+	    /* fall through */
 	case ONEDIGITDAY:
 	case TWODIGITDAY:
 	case THREECHARDAY:
 	case FULLDAY:
-		date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
-		break;
+	    date->wDay = wrap(date->wDay, delta, 1, MONTHCAL_MonthLength(date->wMonth, date->wYear));
+	    break;
+	case ONELETTERAMPM:
+	case TWOLETTERAMPM:
+	    delta *= 12;
+	    /* fall through */
 	case ONEDIGIT12HOUR:
 	case TWODIGIT12HOUR:
 	case ONEDIGIT24HOUR:
 	case TWODIGIT24HOUR:
-	case ONELETTERAMPM:
-	case TWOLETTERAMPM:
-		date->wHour=23;
-		break;
-	case ONEDIGITSECOND:
-	case TWODIGITSECOND:
-		date->wSecond=59;
-		break;
+	    date->wHour = wrap(date->wHour, delta, 0, 23);
+	    break;
 	case ONEDIGITMINUTE:
 	case TWODIGITMINUTE:
-		date->wMinute=59;
-		break;
-	case ONEDIGITMONTH:
-	case TWODIGITMONTH:
-	case THREECHARMONTH:
-	case FULLMONTH:
-		date->wMonth=12;
+	    date->wMinute = wrap(date->wMinute, delta, 0, 59);
+	    break;
+	case ONEDIGITSECOND:
+	case TWODIGITSECOND:
+	    date->wSecond = wrap(date->wSecond, delta, 0, 59);
+	    break;
 	case FORMATCALLBACK:
-		FIXME ("Not implemented\n");
-		break;
-	case ONEDIGITYEAR:
-	case TWODIGITYEAR:
-	case FULLYEAR:
-		date->wYear=9999;    /* Y10K problem? naaah. */
-		break;
-	}
+	    FIXME ("Not implemented\n");
+	    break;
+    }
 
+    /* FYI: On 1752/9/14 the calendar changed and England and the
+     * American colonies changed to the Gregorian calendar. This change
+     * involved having September 14th follow September 2nd. So no date
+     * algorithm works before that date.
+     */
+    if (10000 * date->wYear + 100 * date->wMonth + date->wDay < 17520914) {
+	date->wYear = 1752;
+    	date->wMonth = 9;
+	date->wDay = 14;
+	date->wSecond = 0;
+	date->wMinute = 0;
+	date->wHour = 0;
+    }
 }
 
 
-static void DATETIME_Refresh (HWND hwnd, HDC hdc)
-
+static void 
+DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
 {
-  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-  int i,prevright;
-  RECT *field;
-  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
-  RECT *rcDraw = &infoPtr->rcDraw;
-  RECT *rcClient = &infoPtr->rcClient;
-  RECT *calbutton = &infoPtr->calbutton;
-  RECT *checkbox = &infoPtr->checkbox;
-  HBRUSH hbr;
-  SIZE size;
-  COLORREF oldBk, oldTextColor;
[truncated at 1000 lines; 985 more skipped]

reactos/lib/comctl32
flatsb.c 1.7 -> 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- flatsb.c	19 Sep 2004 09:50:06 -0000	1.7
+++ flatsb.c	8 Dec 2004 21:57:01 -0000	1.7.6.1
@@ -274,7 +274,7 @@
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     wndClass.style         = CS_GLOBALCLASS;
-    wndClass.lpfnWndProc   = (WNDPROC)FlatSB_WindowProc;
+    wndClass.lpfnWndProc   = FlatSB_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
     wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);

reactos/lib/comctl32
header.c 1.6 -> 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- header.c	19 Sep 2004 09:50:06 -0000	1.6
+++ header.c	8 Dec 2004 21:57:01 -0000	1.6.6.1
@@ -1842,7 +1842,7 @@
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
-    wndClass.lpfnWndProc   = (WNDPROC)HEADER_WindowProc;
+    wndClass.lpfnWndProc   = HEADER_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(HEADER_INFO *);
     wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);

reactos/lib/comctl32
hotkey.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- hotkey.c	20 Oct 2004 08:36:55 -0000	1.5
+++ hotkey.c	8 Dec 2004 21:57:01 -0000	1.5.2.1
@@ -57,10 +57,8 @@
     WCHAR strNone[15]; /* hope its long enough ... */
 } HOTKEY_INFO;
 
-#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongPtrA (hwnd, 0))
-
 static const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' };
-static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
+static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw);
 
 #define IsOnlySet(flags) (infoPtr->CurrMod == (flags))
 
@@ -94,7 +92,7 @@
 #undef IsOnlySet
 
 static void
-HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, LPCWSTR KeyName, WORD NameLen, HDC hdc)
+HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, HDC hdc, LPCWSTR KeyName, WORD NameLen)
 {
     SIZE TextSize;
     INT nXStart, nYStart;
@@ -142,7 +140,7 @@
     TRACE("(infoPtr=%p hdc=%p)\n", infoPtr, hdc);
 
     if(!infoPtr->CurrMod && !infoPtr->HotKey) {
-	HOTKEY_DrawHotKey (infoPtr, infoPtr->strNone, 4, hdc);
+	HOTKEY_DrawHotKey (infoPtr, hdc, infoPtr->strNone, 4);
 	return;
     }
 	
@@ -182,7 +180,7 @@
     else
 	KeyName[NameLen] = 0;
 
-    HOTKEY_DrawHotKey (infoPtr, KeyName, NameLen, hdc);
+    HOTKEY_DrawHotKey (infoPtr, hdc, KeyName, NameLen);
 }
 
 static void
@@ -207,39 +205,39 @@
 }
 
 static void
-HOTKEY_SetHotKey(HOTKEY_INFO *infoPtr, WPARAM wParam)
+HOTKEY_SetHotKey(HOTKEY_INFO *infoPtr, WORD hotKey)
 {
-    infoPtr->HotKey = (WORD)wParam;
+    infoPtr->HotKey = hotKey;
     infoPtr->ScanCode = 
         MAKELPARAM(0, MapVirtualKeyW(LOBYTE(infoPtr->HotKey), 0));
-    TRACE("(infoPtr=%p wParam=%x) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr,
-          wParam, HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey));
+    TRACE("(infoPtr=%p hotKey=%x) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr,
+          hotKey, HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey));
     InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
 }
 
 static void 
-HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WORD invComb, WORD invMod)
 {
-    infoPtr->InvComb = (WORD)wParam;
-    infoPtr->InvMod = (WORD)lParam;
+    infoPtr->InvComb = invComb;
+    infoPtr->InvMod = invMod;
     TRACE("(infoPtr=%p) Invalid Modifers: 0x%x, If Invalid: 0x%x\n", infoPtr,
           infoPtr->InvComb, infoPtr->InvMod);
 }
 
 
 static LRESULT
-HOTKEY_Create (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_Create (HOTKEY_INFO *infoPtr, LPCREATESTRUCTW lpcs)
 {
-    infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent;
+    infoPtr->hwndNotify = lpcs->hwndParent;
 
-    HOTKEY_SetFont(infoPtr, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
+    HOTKEY_SetFont(infoPtr, GetStockObject(SYSTEM_FONT), 0);
 
     return 0;
 }
 
 
 static LRESULT
-HOTKEY_Destroy (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_Destroy (HOTKEY_INFO *infoPtr)
 {
     HWND hwnd = infoPtr->hwndSelf;
     /* free hotkey info data */
@@ -250,7 +248,7 @@
 
 
 static LRESULT
-HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, HDC hdc)
 {
     HBRUSH hBrush, hSolidBrush = NULL;
     RECT   rc;
@@ -260,14 +258,14 @@
     else
     {
         hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT,
-            wParam, (LPARAM)infoPtr->hwndSelf);
+                                      (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
         if (!hBrush)
             hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow);
     }
 
     GetClientRect (infoPtr->hwndSelf, &rc);
 
-    FillRect ((HDC)wParam, &rc, hBrush);
+    FillRect (hdc, &rc, hBrush);
 
     if (hSolidBrush)
         DeleteObject(hSolidBrush);
@@ -277,13 +275,13 @@
 
 
 inline static LRESULT
-HOTKEY_GetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_GetFont (HOTKEY_INFO *infoPtr)
 {
     return (LRESULT)infoPtr->hFont;
 }
 
 static LRESULT
-HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, DWORD key, DWORD flags)
 {
     WORD wOldHotKey;
     BYTE bOldMod;
@@ -291,7 +289,7 @@
     if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
         return 0;
 
-    TRACE("() Key: %d\n", wParam);
+    TRACE("() Key: %ld\n", key);
 
     wOldHotKey = infoPtr->HotKey;
     bOldMod = infoPtr->CurrMod;
@@ -299,7 +297,7 @@
     /* If any key is Pressed, we have to reset the hotkey in the control */
     infoPtr->HotKey = 0;
 
-    switch (wParam)
+    switch (key)
     {
 	case VK_RETURN:
 	case VK_TAB:
@@ -308,8 +306,7 @@
 	case VK_ESCAPE:
 	case VK_BACK:
 	    InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
-	    return DefWindowProcW (infoPtr->hwndSelf, WM_KEYDOWN, wParam, 
-	                           lParam);
+	    return DefWindowProcW (infoPtr->hwndSelf, WM_KEYDOWN, key, flags);
 
 	case VK_SHIFT:
 	    infoPtr->CurrMod |= HOTKEYF_SHIFT;
@@ -323,10 +320,10 @@
 
 	default:
 	    if(HOTKEY_IsCombInv(infoPtr))
-	        infoPtr->HotKey = MAKEWORD(wParam, infoPtr->InvMod);
+	        infoPtr->HotKey = MAKEWORD(key, infoPtr->InvMod);
 	    else
-	        infoPtr->HotKey = MAKEWORD(wParam, infoPtr->CurrMod);
-	    infoPtr->ScanCode = lParam;
+	        infoPtr->HotKey = MAKEWORD(key, infoPtr->CurrMod);
+	    infoPtr->ScanCode = flags;
 	    break;
     }
 
@@ -345,18 +342,18 @@
 
 
 static LRESULT
-HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, DWORD key, DWORD flags)
 {
     BYTE bOldMod;
 
     if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
         return 0;
 
-    TRACE("() Key: %d\n", wParam);
+    TRACE("() Key: %ld\n", key);
 
     bOldMod = infoPtr->CurrMod;
 
-    switch (wParam)
+    switch (key)
     {
 	case VK_SHIFT:
 	    infoPtr->CurrMod &= ~HOTKEYF_SHIFT;
@@ -386,7 +383,7 @@
 
 
 static LRESULT
-HOTKEY_KillFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_KillFocus (HOTKEY_INFO *infoPtr, HWND receiveFocus)
 {
     infoPtr->bFocus = FALSE;
     DestroyCaret ();
@@ -396,7 +393,7 @@
 
 
 static LRESULT
-HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr)
 {
     if (!(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED))
         SetFocus (infoPtr->hwndSelf);
@@ -406,7 +403,7 @@
 
 
 inline static LRESULT
-HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
+HOTKEY_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
 {
     HOTKEY_INFO *infoPtr;
     DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
@@ -423,11 +420,11 @@
     infoPtr->hwndSelf = hwnd;
     LoadStringW(COMCTL32_hModule, HKY_NONE, infoPtr->strNone, 15);
 
-    return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, wParam, lParam);
+    return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, 0, (LPARAM)lpcs);
 }
 
 static LRESULT
-HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, HWND lostFocus)
 {
     infoPtr->bFocus = TRUE;
 
@@ -440,13 +437,13 @@
 
 
 static LRESULT
-HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_SetFont (HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw)
 {
     TEXTMETRICW tm;
     HDC hdc;
     HFONT hOldFont = 0;
 
-    infoPtr->hFont = (HFONT)wParam;
+    infoPtr->hFont = hFont;
 
     hdc = GetDC (infoPtr->hwndSelf);
     if (infoPtr->hFont)
@@ -459,7 +456,7 @@
 	SelectObject (hdc, hOldFont);
     ReleaseDC (infoPtr->hwndSelf, hdc);
 
-    if (LOWORD(lParam))
+    if (redraw)
 	InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
 
     return 0;
@@ -468,7 +465,7 @@
 static LRESULT WINAPI
 HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
+    HOTKEY_INFO *infoPtr = (HOTKEY_INFO *)GetWindowLongPtrW (hwnd, 0);
     TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
     if (!infoPtr && (uMsg != WM_NCCREATE))
         return DefWindowProcW (hwnd, uMsg, wParam, lParam);
@@ -477,10 +474,10 @@
 	case HKM_GETHOTKEY:
 	    return HOTKEY_GetHotKey (infoPtr);
 	case HKM_SETHOTKEY:
-	    HOTKEY_SetHotKey (infoPtr, wParam);
+	    HOTKEY_SetHotKey (infoPtr, (WORD)wParam);
 	    break;
 	case HKM_SETRULES:
-            HOTKEY_SetRules (infoPtr, wParam, lParam);
+            HOTKEY_SetRules (infoPtr, (WORD)wParam, (WORD)lParam);
 	    break;
 
 	case WM_CHAR:
@@ -488,19 +485,19 @@
 	    return HOTKEY_KeyDown (infoPtr, MapVirtualKeyW(LOBYTE(HIWORD(lParam)), 1), lParam);
 
 	case WM_CREATE:
-	    return HOTKEY_Create (infoPtr, wParam, lParam);
+	    return HOTKEY_Create (infoPtr, (LPCREATESTRUCTW)lParam);
 
 	case WM_DESTROY:
-	    return HOTKEY_Destroy (infoPtr, wParam, lParam);
+	    return HOTKEY_Destroy (infoPtr);
 
 	case WM_ERASEBKGND:
-	    return HOTKEY_EraseBackground (infoPtr, wParam, lParam);
+	    return HOTKEY_EraseBackground (infoPtr, (HDC)wParam);
 
 	case WM_GETDLGCODE:
 	    return DLGC_WANTCHARS | DLGC_WANTARROWS;
 
 	case WM_GETFONT:
-	    return HOTKEY_GetFont (infoPtr, wParam, lParam);
+	    return HOTKEY_GetFont (infoPtr);
 
 	case WM_KEYDOWN:
 	case WM_SYSKEYDOWN:
@@ -511,23 +508,23 @@
 	    return HOTKEY_KeyUp (infoPtr, wParam, lParam);
 
 	case WM_KILLFOCUS:
-	    return HOTKEY_KillFocus (infoPtr, wParam, lParam);
+	    return HOTKEY_KillFocus (infoPtr, (HWND)wParam);
 
 	case WM_LBUTTONDOWN:
-	    return HOTKEY_LButtonDown (infoPtr, wParam, lParam);
+	    return HOTKEY_LButtonDown (infoPtr);
 
 	case WM_NCCREATE:
-	    return HOTKEY_NCCreate (hwnd, wParam, lParam);
+	    return HOTKEY_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
 
 	case WM_PAINT:
 	    HOTKEY_Paint(infoPtr, (HDC)wParam);
 	    return 0;
 
 	case WM_SETFOCUS:
-	    return HOTKEY_SetFocus (infoPtr, wParam, lParam);
+	    return HOTKEY_SetFocus (infoPtr, (HWND)wParam);
 
 	case WM_SETFONT:
-	    return HOTKEY_SetFont (infoPtr, wParam, lParam);
+	    return HOTKEY_SetFont (infoPtr, (HFONT)wParam, LOWORD(lParam));
 
 	default:
 	    if ((uMsg >= WM_USER) && (uMsg < WM_APP))

reactos/lib/comctl32
imagelist.c 1.15 -> 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- imagelist.c	20 Oct 2004 08:36:55 -0000	1.15
+++ imagelist.c	8 Dec 2004 21:57:01 -0000	1.15.2.1
@@ -2731,6 +2731,7 @@
     failed:
     ReleaseDC(0, xdc);
     LocalFree((HLOCAL)lpBitsOrg);
+    LocalFree((HLOCAL)data);
 
     return result;
 }

reactos/lib/comctl32
ipaddress.c 1.6 -> 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- ipaddress.c	19 Sep 2004 09:50:06 -0000	1.6
+++ ipaddress.c	8 Dec 2004 21:57:01 -0000	1.6.6.1
@@ -65,15 +65,14 @@
     IPPART_INFO	Part[4];
 } IPADDRESS_INFO;
 
+static const WCHAR IP_SUBCLASS_PROP[] = 
+    { 'C', 'C', 'I', 'P', '3', '2', 'S', 'u', 'b', 'c', 'l', 'a', 's', 's', 'I', 'n', 'f', 'o', 0 };
+
 #define POS_DEFAULT	0
 #define POS_LEFT	1
 #define POS_RIGHT	2
 #define POS_SELALL	3
 
-#define IP_SUBCLASS_PROP "CCIP32SubclassInfo"
-#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongPtrW (hwnd, 0))
-
-
 static LRESULT CALLBACK
 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
@@ -125,6 +124,7 @@
 
 static LRESULT IPADDRESS_Draw (IPADDRESS_INFO *infoPtr, HDC hdc)
 {
+    static const WCHAR dotW[] = { '.', 0 };
     RECT rect, rcPart;
     POINT pt;
     int i;
@@ -143,7 +143,7 @@
 	pt.x = rcPart.left;
 	ScreenToClient(infoPtr->Self, &pt);
 	rect.right = pt.x;
-	DrawTextA(hdc, ".", 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
+	DrawTextW(hdc, dotW, 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
     }
 
     return 0;
@@ -152,10 +152,10 @@
 
 static LRESULT IPADDRESS_Create (HWND hwnd, LPCREATESTRUCTA lpCreate)
 {
+    static const WCHAR EDIT[] = { 'E', 'd', 'i', 't', 0 };
     IPADDRESS_INFO *infoPtr;
     RECT rcClient, edit;
     int i, fieldsize;
-    static const WCHAR EDIT[] = { 'E', 'd', 'i', 't', 0 };
 
     TRACE("\n");
 
@@ -188,7 +188,7 @@
                                edit.left, edit.top, edit.right - edit.left,
 			       edit.bottom - edit.top, hwnd, (HMENU) 1,
 			       (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL);
-	SetPropA(part->EditHwnd, IP_SUBCLASS_PROP, hwnd);
+	SetPropW(part->EditHwnd, IP_SUBCLASS_PROP, hwnd);
         part->OrigProc = (WNDPROC)
 		SetWindowLongPtrW (part->EditHwnd, GWLP_WNDPROC,
 				(DWORD_PTR)IPADDRESS_SubclassProc);
@@ -419,8 +419,8 @@
 LRESULT CALLBACK
 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    HWND Self = (HWND)GetPropA (hwnd, IP_SUBCLASS_PROP);
-    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (Self);
+    HWND Self = (HWND)GetPropW (hwnd, IP_SUBCLASS_PROP);
+    IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (Self, 0);
     CHAR c = (CHAR)wParam;
     INT index, len = 0, startsel, endsel;
     IPPART_INFO *part;
@@ -502,7 +502,7 @@
 static LRESULT WINAPI
 IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
+    IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (hwnd, 0);
 
     TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
 

reactos/lib/comctl32
listview.c 1.15 -> 1.15.6.1
diff -u -r1.15 -r1.15.6.1
--- listview.c	19 Sep 2004 09:50:06 -0000	1.15
+++ listview.c	8 Dec 2004 21:57:01 -0000	1.15.6.1
@@ -348,7 +348,7 @@
 /* Standard DrawText flags */
 #define LV_ML_DT_FLAGS  (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
 #define LV_FL_DT_FLAGS  (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_NOCLIP)
-#define LV_SL_DT_FLAGS  (DT_VCENTER | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
+#define LV_SL_DT_FLAGS  (DT_VCENTER | DT_NOPREFIX | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
 
 /* The time in milliseconds to reset the search in the list */
 #define KEY_DELAY       450
@@ -819,10 +819,8 @@
 }
 
 /*
-  With testing on Windows 2000 it looks like the notify format
-  has nothing to do with this message. It ALWAYS seems to be
-  in ansi format.
-
+  Send notification. depends on dispinfoW having same
+  structure as dispinfoA.
   infoPtr : listview struct
   notificationCode : *Unicode* notification code
   pdi : dispinfo structure (can be unicode or ansi)
@@ -831,32 +829,40 @@
 static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW)
 {
     BOOL bResult = FALSE;
-    BOOL convertToAnsi = FALSE;
-    INT cchTempBufMax = 0, savCchTextMax = 0;
+    BOOL convertToAnsi = FALSE, convertToUnicode = FALSE;
+    INT cchTempBufMax = 0, savCchTextMax = 0, realNotifCode;
     LPWSTR pszTempBuf = NULL, savPszText = NULL;
 
     if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW))
-	    convertToAnsi = isW;
+    {
+	convertToAnsi = (isW && infoPtr->notifyFormat == NFR_ANSI);
+	convertToUnicode = (!isW && infoPtr->notifyFormat == NFR_UNICODE);
+    }
 
-    if (convertToAnsi)
+    if (convertToAnsi || convertToUnicode)
     {
 	if (notificationCode != LVN_GETDISPINFOW)
-	{
-            cchTempBufMax = WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText,
-                                                -1, NULL, 0, NULL, NULL);
-        }
-	else
-	{
-	    cchTempBufMax = pdi->item.cchTextMax;
-	    *pdi->item.pszText = 0; /* make sure we don't process garbage */
-	}
+ 	{
+ 	    cchTempBufMax = convertToUnicode ?
+       		MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0):
+       		WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
+	}
+ 	else
+ 	{
+ 	    cchTempBufMax = pdi->item.cchTextMax;
+ 	    *pdi->item.pszText = 0; /* make sure we don't process garbage */
+ 	}
 
-        pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) *
-                               cchTempBufMax);
+	pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
+	    (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
         if (!pszTempBuf) return FALSE;
 
-        WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR)
-                             pszTempBuf, cchTempBufMax, NULL, NULL);
+	if (convertToUnicode)
+	    MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1,
+	                        pszTempBuf, cchTempBufMax);
+	else
+	    WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf,
+	                        cchTempBufMax, NULL, NULL);
 
         savCchTextMax = pdi->item.cchTextMax;
         savPszText = pdi->item.pszText;
@@ -864,16 +870,21 @@
         pdi->item.cchTextMax = cchTempBufMax;
     }
 
-    TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat !=
-           NFR_ANSI));
-
-    bResult = notify_hdr(infoPtr, get_ansi_notification(notificationCode),
-                        (LPNMHDR)pdi);
-
-    if (convertToAnsi)
-    {
-        MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1,
-                            savPszText, savCchTextMax);
+    if (infoPtr->notifyFormat == NFR_ANSI)
+	realNotifCode = get_ansi_notification(notificationCode);
+    else
+	realNotifCode = notificationCode;
+    TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != NFR_ANSI));
+    bResult = notify_hdr(infoPtr, realNotifCode, &pdi->hdr);
+
+    if (convertToUnicode || convertToAnsi)
+    {
+	if (convertToUnicode) /* note : pointer can be changed by app ! */
+ 	    WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText,
+                                savCchTextMax, NULL, NULL);
+	else
+	    MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1,
+	                        savPszText, savCchTextMax);
         pdi->item.pszText = savPszText; /* restores our buffer */
         pdi->item.cchTextMax = savCchTextMax;
         HeapFree(GetProcessHeap(), 0, pszTempBuf);
@@ -3131,7 +3142,7 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] fwKeys : key indicator
- * [I] pts : mouse position
+ * [I] x,y : mouse position
  *
  * RETURN:
  *   0 if the message was processed, non-zero if there was an error
@@ -3141,7 +3152,7 @@
  * over the item for a certain period of time.
  *
  */
-static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, POINTS pts)
+static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, INT x, INT y)
 {
     if(infoPtr->dwLvExStyle & LVS_EX_TRACKSELECT)
 	/* FIXME: select the item!!! */
@@ -3157,12 +3168,12 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] fwKeys : key indicator
- * [I] pts : mouse position
+ * [I] x,y : mouse position
  *
  * RETURN:
  *   0 if the message is processed, non-zero if there was an error
  */
-static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, POINTS pts)
+static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, INT y)
 {
   TRACKMOUSEEVENT trackinfo;
 
@@ -7951,22 +7962,22 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO htInfo;
 
-    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y);
+    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y);
 
     /* send NM_RELEASEDCAPTURE notification */
     notify(infoPtr, NM_RELEASEDCAPTURE);
 
-    htInfo.pt.x = pts.x;
-    htInfo.pt.y = pts.y;
+    htInfo.pt.x = x;
+    htInfo.pt.y = y;
 
     /* send NM_DBLCLK notification */
     LISTVIEW_HitTest(infoPtr, &htInfo, TRUE, FALSE);
@@ -7985,19 +7996,19 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
   LVHITTESTINFO lvHitTestInfo;
   static BOOL bGroupSelect = TRUE;
-  POINT pt = { pts.x, pts.y };
+  POINT pt = { x, y };
   INT nItem;
 
-  TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y);
+  TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y);
 
   /* send NM_RELEASEDCAPTURE notification */
   notify(infoPtr, NM_RELEASEDCAPTURE);
@@ -8007,8 +8018,8 @@
   /* set left button down flag */
   infoPtr->bLButtonDown = TRUE;
 
-  lvHitTestInfo.pt.x = pts.x;
-  lvHitTestInfo.pt.y = pts.y;
+  lvHitTestInfo.pt.x = x;
+  lvHitTestInfo.pt.y = y;
 
   nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
   TRACE("at %s, nItem=%d\n", debugpoint(&pt), nItem);
@@ -8112,21 +8123,21 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_LButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_LButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO lvHitTestInfo;
     
-    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y);
+    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y);
 
     if (!infoPtr->bLButtonDown) return 0;
 
-    lvHitTestInfo.pt.x = pts.x;
-    lvHitTestInfo.pt.y = pts.y;
+    lvHitTestInfo.pt.x = x;
+    lvHitTestInfo.pt.y = y;
 
     /* send NM_CLICK notification */
     LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE);
@@ -8344,23 +8355,23 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_RButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_RButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO lvHitTestInfo;
     
-    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y);
+    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y);
 
     /* send NM_RELEASEDCAPTURE notification */
     notify(infoPtr, NM_RELEASEDCAPTURE);
 
     /* send NM_RDBLCLK notification */
-    lvHitTestInfo.pt.x = pts.x;
-    lvHitTestInfo.pt.y = pts.y;
+    lvHitTestInfo.pt.x = x;
+    lvHitTestInfo.pt.y = y;
     LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE);
     notify_click(infoPtr, NM_RDBLCLK, &lvHitTestInfo);
 
@@ -8374,17 +8385,17 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO lvHitTestInfo;
     INT nItem;
 
-    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y);
+    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y);
 
     /* send NM_RELEASEDCAPTURE notification */
     notify(infoPtr, NM_RELEASEDCAPTURE);
@@ -8396,8 +8407,8 @@
     infoPtr->bRButtonDown = TRUE;
 
     /* determine the index of the selected item */
-    lvHitTestInfo.pt.x = pts.x;
-    lvHitTestInfo.pt.y = pts.y;
+    lvHitTestInfo.pt.x = x;
+    lvHitTestInfo.pt.y = y;
     nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
   
     if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
@@ -8422,17 +8433,17 @@
  * PARAMETER(S):
  * [I] infoPtr : valid pointer to the listview structure
  * [I] wKey : key flag
- * [I] pts : mouse coordinate
+ * [I] x,y : mouse coordinate
  *
  * RETURN:
  * Zero
  */
-static LRESULT LISTVIEW_RButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts)
+static LRESULT LISTVIEW_RButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO lvHitTestInfo;
     POINT pt;
 
-    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y);
+    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y);
 
     if (!infoPtr->bRButtonDown) return 0;
  
@@ -8440,8 +8451,8 @@
     infoPtr->bRButtonDown = FALSE;
 
     /* Send NM_RClICK notification */
-    lvHitTestInfo.pt.x = pts.x;
-    lvHitTestInfo.pt.y = pts.y;
+    lvHitTestInfo.pt.x = x;
+    lvHitTestInfo.pt.y = y;
     LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE);
     notify_click(infoPtr, NM_RCLICK, &lvHitTestInfo);
 
@@ -9159,19 +9170,19 @@
     return LISTVIEW_KillFocus(infoPtr);
 
   case WM_LBUTTONDBLCLK:
-    return LISTVIEW_LButtonDblClk(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_LButtonDblClk(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_LBUTTONDOWN:
-    return LISTVIEW_LButtonDown(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_LButtonDown(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_LBUTTONUP:
-    return LISTVIEW_LButtonUp(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_LButtonUp(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_MOUSEMOVE:
-    return LISTVIEW_MouseMove (infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_MouseMove (infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_MOUSEHOVER:
-    return LISTVIEW_MouseHover(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_MouseHover(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_NCDESTROY:
     return LISTVIEW_NCDestroy(infoPtr);
@@ -9188,13 +9199,13 @@
     return LISTVIEW_Paint(infoPtr, (HDC)wParam);
 
   case WM_RBUTTONDBLCLK:
-    return LISTVIEW_RButtonDblClk(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_RButtonDblClk(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_RBUTTONDOWN:
-    return LISTVIEW_RButtonDown(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_RButtonDown(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_RBUTTONUP:
-    return LISTVIEW_RButtonUp(infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
+    return LISTVIEW_RButtonUp(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
   case WM_SETCURSOR:
     if(LISTVIEW_SetCursor(infoPtr, (HWND)wParam, LOWORD(lParam), HIWORD(lParam)))
@@ -9270,7 +9281,7 @@
 
     ZeroMemory(&wndClass, sizeof(WNDCLASSW));
     wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
-    wndClass.lpfnWndProc = (WNDPROC)LISTVIEW_WindowProc;
+    wndClass.lpfnWndProc = LISTVIEW_WindowProc;
     wndClass.cbClsExtra = 0;
     wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *);
     wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);

reactos/lib/comctl32
monthcal.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- monthcal.c	19 Sep 2004 09:50:06 -0000	1.5
+++ monthcal.c	8 Dec 2004 21:57:01 -0000	1.5.6.1
@@ -21,13 +21,26 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * NOTE
+ * 
+ * This code was audited for completeness against the documented features
+ * of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
+ * 
+ * Unless otherwise noted, we believe this code to be complete, as per
+ * the specification mentioned above.
+ * If you discover missing features, or bugs, please note them below.
+ * 
  * TODO:
- *   - Notifications.
- *
- *
- *  FIXME: handle resources better (doesn't work now); also take care
-           of internationalization.
- *  FIXME: keyboard handling.
+ *    -- MCM_[GS]ETUNICODEFORMAT
+ *    -- MONTHCAL_GetMonthRange
+ *    -- Unicodification
+ *    -- handle resources better (doesn't work now); 
+ *    -- take care of internationalization.
+ *    -- keyboard handling.
+ *    -- GetRange: At the moment, we copy ranges anyway, regardless of
+ *                 infoPtr->rangeValid; a invalid range is simply filled 
+ *                 with zeros in SetRange.  Is this the right behavior?
+ *    -- search for FIXME
  */
 
 #include <math.h>
@@ -59,6 +72,7 @@
 
 typedef struct
 {
+    HWND hwndSelf;
     COLORREF	bk;
     COLORREF	txt;
     COLORREF	titlebk;
@@ -71,8 +85,6 @@
     int		textWidth;
     int		height_increment;
     int		width_increment;
-    int		left_offset;
-    int		top_offset;
     int		firstDayplace; /* place of the first day of the current month */
     int		delta;	/* scroll rate; # of months that the */
                         /* control moves when user clicks a scroll button */
@@ -93,8 +105,6 @@
     SYSTEMTIME	minDate;
     SYSTEMTIME	maxDate;
 
-    RECT rcClient;	/* rect for whole client area */
-    RECT rcDraw;	/* rect for drawable portion of client area */
     RECT title;		/* rect for the header above the calendar */
     RECT titlebtnnext;	/* the `next month' button in the header */
     RECT titlebtnprev;  /* the `prev month' button in the header */
@@ -195,12 +205,15 @@
 				   int *daypos,int *weekpos)
 {
   int retval, firstDay;
+  RECT rcClient;
+
+  GetClientRect(infoPtr->hwndSelf, &rcClient);
 
   /* if the point is outside the x bounds of the window put
   it at the boundry */
-  if(x > infoPtr->rcClient.right) {
-    x = infoPtr->rcClient.right ;
-  }
+  if (x > rcClient.right)
+    x = rcClient.right;
+
 
   *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
   *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
@@ -266,8 +279,7 @@
 
 /* day is the day in the month(1 == 1st of the month) */
 /* month is the month value(1 == january, 12 == december) */
-static void MONTHCAL_CircleDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day,
-int month)
+static void MONTHCAL_CircleDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month)
 {
   HPEN hRedPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
   HPEN hOldPen2 = SelectObject(hdc, hRedPen);
@@ -318,7 +330,7 @@
 }
 
 
-static void MONTHCAL_DrawDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, int month,
+static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month,
                              int x, int y, int bold)
 {
   char buf[10];
@@ -391,12 +403,8 @@
 }
 
 
-/* CHECKME: For `todays date', do we need to check the locale?*/
-static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
+static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps)
 {
-  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
-  RECT *rcClient=&infoPtr->rcClient;
-  RECT *rcDraw=&infoPtr->rcDraw;
   RECT *title=&infoPtr->title;
   RECT *prev=&infoPtr->titlebtnprev;
   RECT *next=&infoPtr->titlebtnnext;
@@ -410,12 +418,11 @@
   SIZE size;
   HBRUSH hbr;
   HFONT currentFont;
-  /* LOGFONTA logFont; */
   char buf[20];
   char buf1[20];
   char buf2[32];
   COLORREF oldTextColor, oldBkColor;
-  DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
+  DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
   RECT rcTemp;
   RECT rcDay; /* used in MONTHCAL_CalcDayRect() */
   SYSTEMTIME localtime;
@@ -423,10 +430,9 @@
 
   oldTextColor = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
 
-
   /* fill background */
   hbr = CreateSolidBrush (infoPtr->bk);
-  FillRect(hdc, rcClient, hbr);
+  FillRect(hdc, &ps->rcPaint, hbr);
   DeleteObject(hbr);
 
   /* draw header */
@@ -507,8 +513,7 @@
 /* draw line under day abbreviatons */
 
   MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
-
-  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
+  LineTo(hdc, infoPtr->days.right - 3, title->bottom + textHeight + 1);
 
   prevMonth = infoPtr->currentMonth - 1;
   if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
@@ -555,7 +560,7 @@
     MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0);
     if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     {
-      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
+      MONTHCAL_DrawDay(infoPtr, hdc, day, prevMonth, i, 0,
           infoPtr->monthdayState[m] & mask);
     }
 
@@ -579,14 +584,14 @@
     if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     {
 
-      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
+      MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, 0,
 	infoPtr->monthdayState[m] & mask);
 
       if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
           (day==infoPtr->todaysDate.wDay) &&
 	  (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
         if(!(dwStyle & MCS_NOTODAYCIRCLE))
-	  MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
+	  MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth);
       }
     }
 
@@ -601,14 +606,14 @@
     MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
     if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     {
-      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, j,
+      MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, j,
           infoPtr->monthdayState[m] & mask);
 
       if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
           (day==infoPtr->todaysDate.wDay) &&
           (infoPtr->currentYear == infoPtr->todaysDate.wYear))
         if(!(dwStyle & MCS_NOTODAYCIRCLE))
-	  MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
+	  MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth);
     }
     mask<<=1;
     day++;
@@ -630,7 +635,7 @@
     MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
     if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     {
-      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
+      MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth + 1, i, j,
 		infoPtr->monthdayState[m] & mask);
     }
 
@@ -652,7 +657,7 @@
     int offset = 0;
     if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
       /*day is the number of days from nextmonth we put on the calendar */
-      MONTHCAL_CircleDay(hdc, infoPtr,
+      MONTHCAL_CircleDay(infoPtr, hdc,
 			 day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
 			 infoPtr->currentMonth);
       offset+=textWidth;
@@ -765,30 +770,32 @@
 
 
 static LRESULT
-MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetMinReqRect(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   LPRECT lpRect = (LPRECT) lParam;
-  TRACE("%x %lx\n", wParam, lParam);
+
+  TRACE("rect %p\n", lpRect);
 
   /* validate parameters */
 
   if((infoPtr==NULL) ||(lpRect == NULL) ) return FALSE;
 
-  lpRect->left = infoPtr->rcClient.left;
-  lpRect->right = infoPtr->rcClient.right;
-  lpRect->top = infoPtr->rcClient.top;
-  lpRect->bottom = infoPtr->rcClient.bottom;
+  lpRect->left = infoPtr->title.left;
+  lpRect->top = infoPtr->title.top;
+  lpRect->right = infoPtr->title.right;
+  lpRect->bottom = infoPtr->todayrect.bottom;
+  AdjustWindowRect(lpRect, GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE), FALSE);
+
+  TRACE("%s\n", wine_dbgstr_rect(lpRect));
+
   return TRUE;
 }
 
 
 static LRESULT
-MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetColor(MONTHCAL_INFO *infoPtr, WPARAM wParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("\n");
 
   switch((int)wParam) {
     case MCSC_BACKGROUND:
@@ -810,12 +817,11 @@
 
 
 static LRESULT
-MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   int prev = -1;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%d: color %08lx\n", wParam, lParam);
 
   switch((int)wParam) {
     case MCSC_BACKGROUND:
@@ -844,17 +850,15 @@
       break;
   }
 
-  InvalidateRect(hwnd, NULL, FALSE);
+  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
   return prev;
 }
 
 
 static LRESULT
-MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetMonthDelta(MONTHCAL_INFO *infoPtr)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("\n");
 
   if(infoPtr->delta)
     return infoPtr->delta;
@@ -864,12 +868,11 @@
 
 
 static LRESULT
-MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetMonthDelta(MONTHCAL_INFO *infoPtr, WPARAM wParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   int prev = infoPtr->delta;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("delta %d\n", wParam);
 
   infoPtr->delta = (int)wParam;
   return prev;
@@ -877,10 +880,8 @@
 
 
 static LRESULT
-MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetFirstDayOfWeek(MONTHCAL_INFO *infoPtr)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
   return infoPtr->firstDay;
 }
 
@@ -890,14 +891,13 @@
 /* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
 /* FIXME: we need more error checking here */
 static LRESULT
-MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   int prev = infoPtr->firstDay;
   char buf[40];
   int day;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("day %ld\n", lParam);
 
   if((lParam >= 0) && (lParam < 7)) {
     infoPtr->firstDay = (int)lParam;
@@ -916,24 +916,18 @@
 }
 
 
-/* FIXME: fill this in */
 static LRESULT
-MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetMonthRange(MONTHCAL_INFO *infoPtr)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
-  TRACE("%x %lx\n", wParam, lParam);
-  FIXME("stub\n");
+  TRACE("\n");
 
   return infoPtr->monthRange;
 }
 
 
 static LRESULT
-MONTHCAL_GetMaxTodayWidth(HWND hwnd)
+MONTHCAL_GetMaxTodayWidth(MONTHCAL_INFO *infoPtr)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
   return(infoPtr->todayrect.right - infoPtr->todayrect.left);
 }
 
@@ -945,9 +939,8 @@
  */
 
 static LRESULT
-MONTHCAL_SetRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *)lParam;
   int prev;
 
@@ -964,11 +957,11 @@
   }
   if(wParam & GDTR_MIN) {
     if(MONTHCAL_ValidateTime(lprgSysTimeArray[0])) {
-      MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->maxDate);
+      MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minDate);
       infoPtr->rangeValid|=GDTR_MIN;
     } else {
       GetSystemTime(&infoPtr->todaysDate);
-      MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->maxDate);
+      MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->minDate);
     }
   }
 
@@ -984,11 +977,6 @@
 }
 
 
-/* CHECKME: At the moment, we copy ranges anyway,regardless of
- * infoPtr->rangeValid; a invalid range is simply filled with zeros in
- * SetRange.  Is this the right behavior?
-*/
-
 static LRESULT
 MONTHCAL_GetRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
@@ -1007,10 +995,9 @@
 
 
 static LRESULT
-MONTHCAL_SetDayState(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetDayState(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   int i, iMonths = (int)wParam;
   MONTHDAYSTATE *dayStates = (LPMONTHDAYSTATE)lParam;
 
@@ -1023,14 +1010,13 @@
 }
 
 static LRESULT
-MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetCurSel(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lpSel = (SYSTEMTIME *) lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
   if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
-  if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
 
   MONTHCAL_CopyTime(&infoPtr->minSel, lpSel);
   TRACE("%d/%d/%d\n", lpSel->wYear, lpSel->wMonth, lpSel->wDay);
@@ -1040,14 +1026,13 @@
 /* FIXME: if the specified date is not visible, make it visible */
 /* FIXME: redraw? */
 static LRESULT
-MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lpSel = (SYSTEMTIME *)lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
   if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
-  if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
 
   infoPtr->currentMonth=lpSel->wMonth;
   infoPtr->currentYear=lpSel->wYear;
@@ -1055,29 +1040,25 @@
   MONTHCAL_CopyTime(lpSel, &infoPtr->minSel);
   MONTHCAL_CopyTime(lpSel, &infoPtr->maxSel);
 
-  InvalidateRect(hwnd, NULL, FALSE);
+  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
 
   return TRUE;
 }
 
 
 static LRESULT
-MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetMaxSelCount(MONTHCAL_INFO *infoPtr)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-
-  TRACE("%x %lx\n", wParam, lParam);
   return infoPtr->maxSelCount;
 }
 
 
 static LRESULT
-MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, WPARAM wParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
+  TRACE("%x\n", wParam);
 
-  TRACE("%x %lx\n", wParam, lParam);
-  if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)  {
     infoPtr->maxSelCount = wParam;
   }
 
@@ -1086,18 +1067,17 @@
 
 
 static LRESULT
-MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetSelRange(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
 
   /* validate parameters */
 
   if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE;
 
-  if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT)
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)
   {
     MONTHCAL_CopyTime(&infoPtr->maxSel, &lprgSysTimeArray[1]);
     MONTHCAL_CopyTime(&infoPtr->minSel, &lprgSysTimeArray[0]);
@@ -1110,18 +1090,17 @@
 
 
 static LRESULT
-MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
 
   /* validate parameters */
 
   if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE;
 
-  if(GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)
   {
     MONTHCAL_CopyTime(&lprgSysTimeArray[1], &infoPtr->maxSel);
     MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minSel);
@@ -1134,12 +1113,11 @@
 
 
 static LRESULT
-MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_GetToday(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
 
   /* validate parameters */
 
@@ -1150,26 +1128,24 @@
 
 
 static LRESULT
-MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetToday(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam;
 
-  TRACE("%x %lx\n", wParam, lParam);
+  TRACE("%lx\n", lParam);
 
   /* validate parameters */
 
   if((infoPtr==NULL) ||(lpToday==NULL)) return FALSE;
   MONTHCAL_CopyTime(lpToday, &infoPtr->todaysDate);
-  InvalidateRect(hwnd, NULL, FALSE);
+  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
   return TRUE;
 }
 
 
 static LRESULT
-MONTHCAL_HitTest(HWND hwnd, LPARAM lParam)
+MONTHCAL_HitTest(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   PMCHITTESTINFO lpht = (PMCHITTESTINFO)lParam;
   UINT x,y;
   DWORD retval;
@@ -1285,9 +1261,9 @@
 }
 
 
-static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
+static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr)
 {
-  DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
+  DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
 
   TRACE("MONTHCAL_GoToNextMonth\n");
 
@@ -1301,8 +1277,8 @@
     NMDAYSTATE nmds;
     int i;
 
-    nmds.nmhdr.hwndFrom = hwnd;
-    nmds.nmhdr.idFrom   = GetWindowLongPtrW(hwnd, GWLP_ID);
+    nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmds.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
     nmds.nmhdr.code     = MCN_GETDAYSTATE;
     nmds.cDayState	= infoPtr->monthRange;
     nmds.prgDayState	= Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
@@ -1315,11 +1291,11 @@
 }
 
 
-static void MONTHCAL_GoToPrevMonth(HWND hwnd,  MONTHCAL_INFO *infoPtr)
+static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr)
 {
-  DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
+  DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
 
-  TRACE("MONTHCAL_GoToPrevMonth\n");
+  TRACE("\n");
 
   infoPtr->currentMonth--;
   if(infoPtr->currentMonth < 1) {
@@ -1331,8 +1307,8 @@
     NMDAYSTATE nmds;
     int i;
 
-    nmds.nmhdr.hwndFrom = hwnd;
-    nmds.nmhdr.idFrom   = GetWindowLongPtrW(hwnd, GWLP_ID);
+    nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmds.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
     nmds.nmhdr.code     = MCN_GETDAYSTATE;
     nmds.cDayState	= infoPtr->monthRange;
     nmds.prgDayState	= Alloc
@@ -1346,9 +1322,8 @@
 }
 
 static LRESULT
-MONTHCAL_RButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_RButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   HMENU hMenu;
   POINT menupoint;
   char buf[32];
@@ -1362,21 +1337,20 @@
   AppendMenuA(hMenu, MF_STRING|MF_ENABLED,1, buf);
   menupoint.x=(INT)LOWORD(lParam);
   menupoint.y=(INT)HIWORD(lParam);
-  ClientToScreen(hwnd, &menupoint);
+  ClientToScreen(infoPtr->hwndSelf, &menupoint);
   if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD,
-		     menupoint.x,menupoint.y,0,hwnd,NULL))
+		     menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL))
     {
       infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
       infoPtr->currentYear=infoPtr->todaysDate.wYear;
-      InvalidateRect(hwnd, NULL, FALSE);
+      InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     }
   return 0;
 }
 
 static LRESULT
-MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   MCHITTESTINFO ht;
   DWORD hit;
   HMENU hMenu;
@@ -1384,7 +1358,8 @@
   char buf[32];
   int i;
   POINT menupoint;
-  TRACE("%x %lx\n", wParam, lParam);
+
+  TRACE("%lx\n", lParam);
 
   if (infoPtr->hWndYearUpDown)
     {
@@ -1401,28 +1376,28 @@
 	}
       else
 	infoPtr->hWndYearEdit=0;
-      InvalidateRect(hwnd, NULL, FALSE);
+      InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     }
 
   ht.pt.x = (INT)LOWORD(lParam);
   ht.pt.y = (INT)HIWORD(lParam);
-  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
+  hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht);
 
   /* FIXME: these flags should be checked by */
   /*((hit & MCHT_XXX) == MCHT_XXX) b/c some of the flags are */
   /* multi-bit */
   if(hit ==MCHT_TITLEBTNNEXT) {
-    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
+    MONTHCAL_GoToNextMonth(infoPtr);
     infoPtr->status = MC_NEXTPRESSED;
-    SetTimer(hwnd, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0);
-    InvalidateRect(hwnd, NULL, FALSE);
+    SetTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     return TRUE;
   }
   if(hit == MCHT_TITLEBTNPREV){
-    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
+    MONTHCAL_GoToPrevMonth(infoPtr);
     infoPtr->status = MC_PREVPRESSED;
-    SetTimer(hwnd, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0);
-    InvalidateRect(hwnd, NULL, FALSE);
+    SetTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     return TRUE;
   }
 
@@ -1437,13 +1412,13 @@
       }
     menupoint.x=infoPtr->titlemonth.right;
     menupoint.y=infoPtr->titlemonth.bottom;
-    ClientToScreen(hwnd, &menupoint);
+    ClientToScreen(infoPtr->hwndSelf, &menupoint);
     i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
-		      menupoint.x,menupoint.y,0,hwnd,NULL);
+		      menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL);
     if ((i>0) && (i<13))
       {
 	infoPtr->currentMonth=i;
-	InvalidateRect(hwnd, NULL, FALSE);
+	InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
       }
   }
   if(hit == MCHT_TITLEYEAR) {
@@ -1454,7 +1429,7 @@
 			 infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
 			 infoPtr->titleyear.right-infoPtr->titleyear.left,
 			 infoPtr->textHeight,
-			 hwnd,
+			 infoPtr->hwndSelf,
 			 NULL,
 			 NULL,
 			 NULL);
@@ -1465,7 +1440,7 @@
 			 infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
 			 20,
 			 infoPtr->textHeight,
-			 hwnd,
+			 infoPtr->hwndSelf,
 			 NULL,
 			 NULL,
 			 NULL);
@@ -1478,7 +1453,7 @@
   if(hit == MCHT_TODAYLINK) {
     infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
     infoPtr->currentYear=infoPtr->todaysDate.wYear;
-    InvalidateRect(hwnd, NULL, FALSE);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     return TRUE;
   }
   if(hit == MCHT_CALENDARDATE) {
@@ -1487,11 +1462,11 @@
 
     MONTHCAL_CopyTime(&ht.st, &selArray[0]);
     MONTHCAL_CopyTime(&ht.st, &selArray[1]);
-    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
-    MONTHCAL_SetCurSel(hwnd,0,(LPARAM) &selArray);
+    MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray);
+    MONTHCAL_SetCurSel(infoPtr, (LPARAM)&selArray);
     TRACE("MCHT_CALENDARDATE\n");
-    nmsc.nmhdr.hwndFrom = hwnd;
-    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(hwnd, GWLP_ID);
+    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
     nmsc.nmhdr.code     = MCN_SELCHANGE;
     MONTHCAL_CopyTime(&infoPtr->minSel,&nmsc.stSelStart);
     MONTHCAL_CopyTime(&infoPtr->maxSel,&nmsc.stSelEnd);
@@ -1503,10 +1478,10 @@
     /* redraw both old and new days if the selected day changed */
     if(infoPtr->curSelDay != ht.st.wDay) {
       MONTHCAL_CalcPosFromDay(infoPtr, ht.st.wDay, ht.st.wMonth, &rcDay);
-      InvalidateRect(hwnd, &rcDay, TRUE);
+      InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE);
 
       MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->curSelDay, infoPtr->currentMonth, &rcDay);
-      InvalidateRect(hwnd, &rcDay, TRUE);
+      InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE);
     }
 
     infoPtr->firstSelDay = ht.st.wDay;
@@ -1520,9 +1495,8 @@
 
 
 static LRESULT
-MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   NMSELCHANGE nmsc;
   NMHDR nmhdr;
   BOOL redraw = FALSE;
@@ -1532,46 +1506,46 @@
   TRACE("\n");
 
   if(infoPtr->status & MC_NEXTPRESSED) {
-    KillTimer(hwnd, MC_NEXTMONTHTIMER);
+    KillTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER);
     infoPtr->status &= ~MC_NEXTPRESSED;
     redraw = TRUE;
   }
   if(infoPtr->status & MC_PREVPRESSED) {
-    KillTimer(hwnd, MC_PREVMONTHTIMER);
+    KillTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER);
     infoPtr->status &= ~MC_PREVPRESSED;
     redraw = TRUE;
   }
 
   ht.pt.x = (INT)LOWORD(lParam);
   ht.pt.y = (INT)HIWORD(lParam);
-  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
+  hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht);
 
   infoPtr->status = MC_SEL_LBUTUP;
 
   if(hit ==MCHT_CALENDARDATENEXT) {
-    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
-    InvalidateRect(hwnd, NULL, FALSE);
+    MONTHCAL_GoToNextMonth(infoPtr);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     return TRUE;
   }
   if(hit == MCHT_CALENDARDATEPREV){
-    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
-    InvalidateRect(hwnd, NULL, FALSE);
+    MONTHCAL_GoToPrevMonth(infoPtr);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
     return TRUE;
   }
-  nmhdr.hwndFrom = hwnd;
-  nmhdr.idFrom   = GetWindowLongPtrW( hwnd, GWLP_ID);
+  nmhdr.hwndFrom = infoPtr->hwndSelf;
+  nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
   nmhdr.code     = NM_RELEASEDCAPTURE;
-  TRACE("Sent notification from %p to %p\n", hwnd, infoPtr->hwndNotify);
+  TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify);
 
   SendMessageA(infoPtr->hwndNotify, WM_NOTIFY,
                                 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
   /* redraw if necessary */
   if(redraw)
-    InvalidateRect(hwnd, NULL, FALSE);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
   /* only send MCN_SELECT if currently displayed month's day was selected */
   if(hit == MCHT_CALENDARDATE) {
-    nmsc.nmhdr.hwndFrom = hwnd;
-    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(hwnd, GWLP_ID);
+    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
     nmsc.nmhdr.code     = MCN_SELECT;
     MONTHCAL_CopyTime(&infoPtr->minSel, &nmsc.stSelStart);
     MONTHCAL_CopyTime(&infoPtr->maxSel, &nmsc.stSelEnd);
@@ -1585,39 +1559,37 @@
 
 
 static LRESULT
-MONTHCAL_Timer(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM wParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   BOOL redraw = FALSE;
 
-  TRACE(" %d\n", wParam);
-  if(!infoPtr) return 0;
+  TRACE("%d\n", wParam);
 
   switch(wParam) {
   case MC_NEXTMONTHTIMER:
     redraw = TRUE;
-    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
+    MONTHCAL_GoToNextMonth(infoPtr);
     break;
   case MC_PREVMONTHTIMER:
     redraw = TRUE;
-    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
+    MONTHCAL_GoToPrevMonth(infoPtr);
     break;
   default:
     ERR("got unknown timer\n");
+    break;
   }
 
   /* redraw only if necessary */
   if(redraw)
-    InvalidateRect(hwnd, NULL, FALSE);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
 
   return 0;
 }
 
 
 static LRESULT
-MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   MCHITTESTINFO ht;
   int oldselday, selday, hit;
   RECT r;
@@ -1627,7 +1599,7 @@
   ht.pt.x = LOWORD(lParam);
   ht.pt.y = HIWORD(lParam);
 
-  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
+  hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht);
 
   /* not on the calendar date numbers? bail out */
   TRACE("hit:%x\n",hit);
@@ -1638,11 +1610,11 @@
   infoPtr->curSelDay = selday;
   MONTHCAL_CalcPosFromDay(infoPtr, selday, ht.st. wMonth, &r);
 
-  if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
+  if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)  {
     SYSTEMTIME selArray[2];
     int i;
 
-    MONTHCAL_GetSelRange(hwnd, 0, (LPARAM)&selArray);
+    MONTHCAL_GetSelRange(infoPtr, (LPARAM)&selArray);
     i = 0;
     if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
     TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
@@ -1672,7 +1644,7 @@
         selArray[0].wDay = tempday;
       }
 
-      MONTHCAL_SetSelRange(hwnd, 0, (LPARAM)&selArray);
+      MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray);
     }
   }
 
@@ -1682,57 +1654,57 @@
   /* FIXME: this should specify a rectangle containing only the days that changed */
   /* using InvalidateRect */
   if(oldselday != infoPtr->curSelDay)
-    InvalidateRect(hwnd, NULL, FALSE);
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
 
   return 0;
 }
 
 
 static LRESULT
-MONTHCAL_Paint(HWND hwnd, WPARAM wParam)
+MONTHCAL_Paint(MONTHCAL_INFO *infoPtr, WPARAM wParam)
 {
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
   HDC hdc;
   PAINTSTRUCT ps;
 
-  /* fill ps.rcPaint with a default rect */
-  memcpy(&(ps.rcPaint), &(infoPtr->rcClient), sizeof(infoPtr->rcClient));
+  if (wParam)
+  {
+    GetClientRect(infoPtr->hwndSelf, &ps.rcPaint);
+    hdc = (HDC)wParam;
+  }
+  else
+    hdc = BeginPaint(infoPtr->hwndSelf, &ps);
 
-  hdc = (wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam);
-  MONTHCAL_Refresh(hwnd, hdc, &ps);
-  if(!wParam) EndPaint(hwnd, &ps);
+  MONTHCAL_Refresh(infoPtr, hdc, &ps);
+  if (!wParam) EndPaint(infoPtr->hwndSelf, &ps);
   return 0;
 }
 
 
 static LRESULT
-MONTHCAL_KillFocus(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_KillFocus(MONTHCAL_INFO *infoPtr)
 {
   TRACE("\n");
 
-  InvalidateRect(hwnd, NULL, TRUE);
+  InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
 
   return 0;
 }
 
 
 static LRESULT
-MONTHCAL_SetFocus(HWND hwnd, WPARAM wParam, LPARAM lParam)
+MONTHCAL_SetFocus(MONTHCAL_INFO *infoPtr)
 {
   TRACE("\n");
 
-  InvalidateRect(hwnd, NULL, FALSE);
+  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
 
   return 0;
 }
 
 /* sets the size information */
-static void MONTHCAL_UpdateSize(HWND hwnd)
+static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr)
 {
-  HDC hdc = GetDC(hwnd);
-  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
-  RECT *rcClient=&infoPtr->rcClient;
-  RECT *rcDraw=&infoPtr->rcDraw;
[truncated at 1000 lines; 408 more skipped]

reactos/lib/comctl32
nativefont.c 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- nativefont.c	19 Sep 2004 09:50:06 -0000	1.3
+++ nativefont.c	8 Dec 2004 21:57:02 -0000	1.3.6.1
@@ -28,12 +28,11 @@
  */
 
 #include <stdarg.h>
-#include <string.h>
+
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "winnls.h"
 #include "commctrl.h"
 #include "comctl32.h"
 #include "wine/debug.h"
@@ -42,12 +41,11 @@
 
 typedef struct
 {
-    DWORD  dwDummy;   /* just to keep the compiler happy ;-) */
+    HWND     hwndSelf;        /* my own handle */
 } NATIVEFONT_INFO;
 
 #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongPtrW (hwnd, 0))
 
-
 static LRESULT
 NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
@@ -57,45 +55,40 @@
     infoPtr = (NATIVEFONT_INFO *)Alloc (sizeof(NATIVEFONT_INFO));
     SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
 
-
     /* initialize info structure */
-
+    infoPtr->hwndSelf = hwnd;
 
     return 0;
 }
 
-
 static LRESULT
-NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
+NATIVEFONT_Destroy (NATIVEFONT_INFO *infoPtr)
 {
-    NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd);
-
-
-
-
-    /* free comboex info data */
+    /* free control info data */
+    SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 );
     Free (infoPtr);
-    SetWindowLongPtrW( hwnd, 0, 0 );
 
     return 0;
 }
 
-
-
 static LRESULT WINAPI
 NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    if (!NATIVEFONT_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
-	return DefWindowProcA( hwnd, uMsg, wParam, lParam );
+    NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr(hwnd);
+
+    TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n",
+	  hwnd, uMsg, wParam, lParam);
+
+    if (!infoPtr && (uMsg != WM_CREATE))
+	return DefWindowProcW( hwnd, uMsg, wParam, lParam );
 
     switch (uMsg)
     {
-
 	case WM_CREATE:
 	    return NATIVEFONT_Create (hwnd, wParam, lParam);
 
 	case WM_DESTROY:
-	    return NATIVEFONT_Destroy (hwnd, wParam, lParam);
+	    return NATIVEFONT_Destroy (infoPtr);
 
         case WM_MOVE:
         case WM_SIZE:
@@ -105,12 +98,13 @@
         case WM_SETFONT:
         case WM_GETDLGCODE:
 	    /* FIXME("message %04x seen but stubbed\n", uMsg); */
-	    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+	    return DefWindowProcW (hwnd, uMsg, wParam, lParam);
 
 	default:
-	    ERR("unknown msg %04x wp=%08x lp=%08lx\n",
+	    if ((uMsg >= WM_USER) && (uMsg < WM_APP))
+		ERR("unknown msg %04x wp=%08x lp=%08lx\n",
 		     uMsg, wParam, lParam);
-	    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+	    return DefWindowProcW (hwnd, uMsg, wParam, lParam);
     }
     return 0;
 }
@@ -119,23 +113,23 @@
 VOID
 NATIVEFONT_Register (void)
 {
-    WNDCLASSA wndClass;
+    WNDCLASSW wndClass;
 
-    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
+    ZeroMemory (&wndClass, sizeof(WNDCLASSW));
     wndClass.style         = CS_GLOBALCLASS;
-    wndClass.lpfnWndProc   = (WNDPROC)NATIVEFONT_WindowProc;
+    wndClass.lpfnWndProc   = NATIVEFONT_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(NATIVEFONT_INFO *);
-    wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
-    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
-    wndClass.lpszClassName = WC_NATIVEFONTCTLA;
+    wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);
+    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
+    wndClass.lpszClassName = WC_NATIVEFONTCTLW;
 
-    RegisterClassA (&wndClass);
+    RegisterClassW (&wndClass);
 }
 
 
 VOID
 NATIVEFONT_Unregister (void)
 {
-    UnregisterClassA (WC_NATIVEFONTCTLA, NULL);
+    UnregisterClassW (WC_NATIVEFONTCTLW, NULL);
 }

reactos/lib/comctl32
progress.c 1.7 -> 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- progress.c	19 Sep 2004 09:50:06 -0000	1.7
+++ progress.c	8 Dec 2004 21:57:02 -0000	1.7.6.1
@@ -493,7 +493,7 @@
  *           ProgressWindowProc
  */
 static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
-                                  WPARAM wParam, LPARAM lParam)
+                                         WPARAM wParam, LPARAM lParam)
 {
     PROGRESS_INFO *infoPtr;
 
@@ -654,7 +654,7 @@
  *
  * Registers the progress bar window class.
  */
-VOID PROGRESS_Register (void)
+void PROGRESS_Register (void)
 {
     WNDCLASSW wndClass;
 
@@ -675,7 +675,7 @@
  *
  * Unregisters the progress bar window class.
  */
-VOID PROGRESS_Unregister (void)
+void PROGRESS_Unregister (void)
 {
     UnregisterClassW (PROGRESS_CLASSW, NULL);
 }

reactos/lib/comctl32
rebar.c 1.13 -> 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- rebar.c	20 Oct 2004 08:36:55 -0000	1.13
+++ rebar.c	8 Dec 2004 21:57:02 -0000	1.13.2.1
@@ -19,7 +19,7 @@
  *
  *
  * This code was audited for completeness against the documented features
- * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
+ * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
  * 
  * Unless otherwise noted, we believe this code to be complete, as per
  * the specification mentioned above.
@@ -194,8 +194,8 @@
     HCURSOR  hcurVert;    /* handle to the NS cursor */
     HCURSOR  hcurDrag;    /* handle to the drag cursor */
     INT      iVersion;    /* version number */
-    POINTS   dragStart;   /* x,y of button down */
-    POINTS   dragNow;     /* x,y of this MouseMove */
+    POINT    dragStart;   /* x,y of button down */
+    POINT    dragNow;     /* x,y of this MouseMove */
     INT      iOldBand;    /* last band that had the mouse cursor over it */
     INT      ihitoffset;  /* offset of hotspot from gripper.left */
     POINT    origin;      /* left/upper corner of client */
@@ -394,7 +394,7 @@
     TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
 	  iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
 	  iP->calcSize.cx, iP->calcSize.cy);
-    TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
+    TRACE("hwnd=%p: flags=%08x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n",
 	  iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
 	  iP->dragNow.x, iP->dragNow.y,
 	  iP->iGrabbedBand);
@@ -2418,7 +2418,7 @@
 
 
 static void
-REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
+REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
      /* Function:  This will implement the functionality of a     */
      /*  Gripper drag within a row. It will not implement "out-   */
      /*  of-row" drags. (They are detected and handled in         */
@@ -2491,7 +2491,7 @@
 			     infoPtr->ihitoffset);
     infoPtr->dragNow = *ptsmove;
 
-    TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
+    TRACE("before: movement=%d (%ld,%ld), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
 	  movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
 	  imaxdBand, LHeaderSum, RHeaderSum);
     REBAR_DumpBand (infoPtr);
@@ -3786,10 +3786,10 @@
 	infoPtr->bands = NULL;
     }
 
-    DeleteObject (infoPtr->hcurArrow);
-    DeleteObject (infoPtr->hcurHorz);
-    DeleteObject (infoPtr->hcurVert);
-    DeleteObject (infoPtr->hcurDrag);
+    DestroyCursor (infoPtr->hcurArrow);
+    DestroyCursor (infoPtr->hcurHorz);
+    DestroyCursor (infoPtr->hcurVert);
+    DestroyCursor (infoPtr->hcurDrag);
     if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
     SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
 
@@ -3874,7 +3874,8 @@
         infoPtr->iGrabbedBand = iHitBand;
 
         /* save off the LOWORD and HIWORD of lParam as initial x,y */
-        infoPtr->dragStart = MAKEPOINTS(lParam);
+        infoPtr->dragStart.x = (short)LOWORD(lParam);
+        infoPtr->dragStart.y = (short)HIWORD(lParam);
         infoPtr->dragNow = infoPtr->dragStart;
         if (infoPtr->dwStyle & CCS_VERT)
             infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
@@ -3935,9 +3936,10 @@
 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
     REBAR_BAND *lpChevronBand;
-    POINTS ptsmove;
+    POINT ptMove;
 
-    ptsmove = MAKEPOINTS(lParam);
+    ptMove.x = (short)LOWORD(lParam);
+    ptMove.y = (short)HIWORD(lParam);
 
     /* if we are currently dragging a band */
     if (infoPtr->iGrabbedBand >= 0)
@@ -3951,40 +3953,37 @@
         band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
 
         /* if mouse did not move much, exit */
-        if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
-            (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
+        if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
+            (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
 
         /* Test for valid drag case - must not be first band in row */
         if (infoPtr->dwStyle & CCS_VERT) {
-            if ((ptsmove.x < band2->rcBand.left) ||
-	      (ptsmove.x > band2->rcBand.right) ||
+            if ((ptMove.x < band2->rcBand.left) ||
+	      (ptMove.x > band2->rcBand.right) ||
               ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
                 FIXME("Cannot drag to other rows yet!!\n");
             }
             else {
-                REBAR_HandleLRDrag (infoPtr, &ptsmove);
+                REBAR_HandleLRDrag (infoPtr, &ptMove);
             }
         }
         else {
-            if ((ptsmove.y < band2->rcBand.top) ||
-              (ptsmove.y > band2->rcBand.bottom) ||
+            if ((ptMove.y < band2->rcBand.top) ||
+              (ptMove.y > band2->rcBand.bottom) ||
               ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
                 FIXME("Cannot drag to other rows yet!!\n");
             }
             else {
-                REBAR_HandleLRDrag (infoPtr, &ptsmove);
+                REBAR_HandleLRDrag (infoPtr, &ptMove);
             }
         }
     }
     else
     {
-        POINT ptMove;
         INT iHitBand;
         UINT htFlags;
         TRACKMOUSEEVENT trackinfo;
 
-        ptMove.x = (INT)ptsmove.x;
-        ptMove.y = (INT)ptsmove.y;
         REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
 
         if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
@@ -4152,8 +4151,7 @@
 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
     NMMOUSE nmmouse;
-    POINTS shortpt;
-    POINT clpt, pt;
+    POINT clpt;
     INT i;
     UINT scrap;
     LRESULT ret = HTCLIENT;
@@ -4166,9 +4164,8 @@
      * 3. native always seems to return HTCLIENT if notify return is 0.
      */
 
-    shortpt = MAKEPOINTS (lParam);
-    POINTSTOPOINT(pt, shortpt);
-    clpt = pt;
+    clpt.x = (short)LOWORD(lParam);
+    clpt.y = (short)HIWORD(lParam);
     ScreenToClient (infoPtr->hwndSelf, &clpt);
     REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
 			   (INT *)&nmmouse.dwItemSpec);
@@ -4710,7 +4707,7 @@
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
-    wndClass.lpfnWndProc   = (WNDPROC)REBAR_WindowProc;
+    wndClass.lpfnWndProc   = REBAR_WindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(REBAR_INFO *);
     wndClass.hCursor       = 0;

reactos/lib/comctl32
status.c 1.6 -> 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- status.c	19 Sep 2004 09:50:06 -0000	1.6
+++ status.c	8 Dec 2004 21:57:02 -0000	1.6.6.1
@@ -79,7 +79,7 @@
     BOOL              NtfUnicode;	/* notify format */
     STATUSWINDOWPART  part0;		/* simple window */
     STATUSWINDOWPART* parts;
-} STATUSWINDOWINFO;
+} STATUS_INFO;
 
 /*
  * Run tests using Waite Group Windows95 API Bible Vol. 1&2
@@ -91,11 +91,9 @@
 #define VERT_BORDER 2
 #define HORZ_GAP    2
 
-#define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongPtrW (hwnd, 0))
-
 /* prototype */
 static void
-STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr);
+STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr);
 
 static inline LPCSTR debugstr_t(LPCWSTR text, BOOL isW)
 {
@@ -148,7 +146,7 @@
 
 
 static void
-STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID)
+STATUSBAR_DrawPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, int itemID)
 {
     RECT r = part->bound;
     UINT border = BDR_SUNKENOUTER;
@@ -189,7 +187,7 @@
 
 
 static void
-STATUSBAR_RefreshPart (const STATUSWINDOWINFO *infoPtr, const STATUSWINDOWPART *part, HDC hdc, int itemID)
+STATUSBAR_RefreshPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, int itemID)
 {
     HBRUSH hbrBk;
     HFONT  hOldFont;
@@ -208,7 +206,7 @@
 
     hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
 
-	STATUSBAR_DrawPart (hdc, part, infoPtr, itemID);
+	STATUSBAR_DrawPart (infoPtr, hdc, part, itemID);
 
     SelectObject (hdc, hOldFont);
 
@@ -226,7 +224,7 @@
 
 
 static LRESULT
-STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc)
+STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc)
 {
     int      i;
     RECT   rect;
@@ -250,10 +248,10 @@
     hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
 
     if (infoPtr->simple) {
-	    STATUSBAR_RefreshPart (infoPtr, &infoPtr->part0, hdc, 0);
+	    STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0);
     } else {
 	    for (i = 0; i < infoPtr->numParts; i++) {
-		    STATUSBAR_RefreshPart (infoPtr, &infoPtr->parts[i], hdc, i);
+		    STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i);
 	    }
     }
 
@@ -270,7 +268,7 @@
 
 
 static void
-STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr)
+STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr)
 {
     STATUSWINDOWPART *part;
     RECT rect, *r;
@@ -315,7 +313,7 @@
 
 
 static LRESULT
-STATUSBAR_Relay2Tip (STATUSWINDOWINFO *infoPtr, UINT uMsg,
+STATUSBAR_Relay2Tip (STATUS_INFO *infoPtr, UINT uMsg,
 		     WPARAM wParam, LPARAM lParam)
 {
     MSG msg;
@@ -345,7 +343,7 @@
 
 
 static HICON
-STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, INT nPart)
+STATUSBAR_GetIcon (STATUS_INFO *infoPtr, INT nPart)
 {
     TRACE("%d\n", nPart);
     /* MSDN says: "simple parts are indexed with -1" */
@@ -360,7 +358,7 @@
 
 
 static INT
-STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, INT num_parts, INT parts[])
+STATUSBAR_GetParts (STATUS_INFO *infoPtr, INT num_parts, INT parts[])
 {
     INT   i;
 
@@ -375,7 +373,7 @@
 
 
 static BOOL
-STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, INT nPart, LPRECT rect)
+STATUSBAR_GetRect (STATUS_INFO *infoPtr, INT nPart, LPRECT rect)
 {
     TRACE("part %d\n", nPart);
     if (infoPtr->simple)
@@ -387,7 +385,7 @@
 
 
 static LRESULT
-STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, INT nPart, LPSTR buf)
+STATUSBAR_GetTextA (STATUS_INFO *infoPtr, INT nPart, LPSTR buf)
 {
     STATUSWINDOWPART *part;
     LRESULT result;
@@ -416,7 +414,7 @@
 
 
 static LRESULT
-STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, INT nPart, LPWSTR buf)
+STATUSBAR_GetTextW (STATUS_INFO *infoPtr, INT nPart, LPWSTR buf)
 {
     STATUSWINDOWPART *part;
     LRESULT result;
@@ -442,7 +440,7 @@
 
 
 static LRESULT
-STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, INT nPart)
+STATUSBAR_GetTextLength (STATUS_INFO *infoPtr, INT nPart)
 {
     STATUSWINDOWPART *part;
     DWORD result;
@@ -467,7 +465,7 @@
 }
 
 static LRESULT
-STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR tip, INT size)
+STATUSBAR_GetTipTextA (STATUS_INFO *infoPtr, INT id, LPSTR tip, INT size)
 {
     TRACE("\n");
     if (tip) {
@@ -489,7 +487,7 @@
 
 
 static LRESULT
-STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR tip, INT size)
+STATUSBAR_GetTipTextW (STATUS_INFO *infoPtr, INT id, LPWSTR tip, INT size)
 {
     TRACE("\n");
     if (tip) {
@@ -512,7 +510,7 @@
 
 
 static COLORREF
-STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, COLORREF color)
+STATUSBAR_SetBkColor (STATUS_INFO *infoPtr, COLORREF color)
 {
     COLORREF oldBkColor;
 
@@ -526,7 +524,7 @@
 
 
 static BOOL
-STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, INT nPart, HICON hIcon)
+STATUSBAR_SetIcon (STATUS_INFO *infoPtr, INT nPart, HICON hIcon)
 {
     if ((nPart < -1) || (nPart >= infoPtr->numParts))
 	return FALSE;
@@ -553,7 +551,7 @@
 
 
 static BOOL
-STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, INT height)
+STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height)
 {
 
     TRACE("(height=%d)\n", height);
@@ -577,7 +575,7 @@
 
 
 static BOOL
-STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, INT count, LPINT parts)
+STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts)
 {
     STATUSWINDOWPART *tmp;
     int	i, oldNumParts;
@@ -647,7 +645,7 @@
 
 
 static BOOL
-STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style,
+STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
 		    LPCWSTR text, BOOL isW)
 {
     STATUSWINDOWPART *part=NULL;
@@ -715,7 +713,7 @@
 
 
 static LRESULT
-STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR text)
+STATUSBAR_SetTipTextA (STATUS_INFO *infoPtr, INT id, LPSTR text)
 {
     TRACE("part %d: \"%s\"\n", id, text);
     if (infoPtr->hwndToolTip) {
@@ -734,7 +732,7 @@
 
 
 static LRESULT
-STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR text)
+STATUSBAR_SetTipTextW (STATUS_INFO *infoPtr, INT id, LPWSTR text)
 {
     TRACE("part %d: \"%s\"\n", id, debugstr_w(text));
     if (infoPtr->hwndToolTip) {
@@ -753,7 +751,7 @@
 
 
 inline static LRESULT
-STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, BOOL bUnicode)
+STATUSBAR_SetUnicodeFormat (STATUS_INFO *infoPtr, BOOL bUnicode)
 {
     BOOL bOld = infoPtr->bUnicode;
 
@@ -765,7 +763,7 @@
 
 
 static BOOL
-STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, BOOL simple)
+STATUSBAR_Simple (STATUS_INFO *infoPtr, BOOL simple)
 {
     NMHDR  nmhdr;
 
@@ -786,7 +784,7 @@
 
 
 static LRESULT
-STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr)
+STATUSBAR_WMDestroy (STATUS_INFO *infoPtr)
 {
     int	i;
 
@@ -816,7 +814,7 @@
 static LRESULT
 STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate)
 {
-    STATUSWINDOWINFO *infoPtr;
+    STATUS_INFO *infoPtr;
     NONCLIENTMETRICSW nclm;
     DWORD dwStyle;
     RECT rect;
@@ -824,7 +822,7 @@
     HDC	hdc;
 
     TRACE("\n");
-    infoPtr = (STATUSWINDOWINFO*)Alloc (sizeof(STATUSWINDOWINFO));
+    infoPtr = (STATUS_INFO*)Alloc (sizeof(STATUS_INFO));
     if (!infoPtr) goto create_fail;
     SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
 
@@ -944,7 +942,7 @@
 /* in contrast to SB_GETTEXT*, WM_GETTEXT handles the text
  * of the first part only (usual behaviour) */
 static INT
-STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, INT size, LPWSTR buf)
+STATUSBAR_WMGetText (STATUS_INFO *infoPtr, INT size, LPWSTR buf)
 {
     INT len;
 
@@ -970,7 +968,7 @@
 
 
 static BOOL
-STATUSBAR_WMNCHitTest (STATUSWINDOWINFO *infoPtr, INT x, INT y)
+STATUSBAR_WMNCHitTest (STATUS_INFO *infoPtr, INT x, INT y)
 {
     if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
 	RECT  rect;
@@ -994,7 +992,7 @@
 
 
 static LRESULT
-STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HDC hdc)
+STATUSBAR_WMPaint (STATUS_INFO *infoPtr, HDC hdc)
 {
     PAINTSTRUCT ps;
 
@@ -1009,7 +1007,7 @@
 
 
 static LRESULT
-STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HFONT font, BOOL redraw)
+STATUSBAR_WMSetFont (STATUS_INFO *infoPtr, HFONT font, BOOL redraw)
 {
     infoPtr->hFont = font;
     TRACE("%p\n", infoPtr->hFont);
@@ -1021,7 +1019,7 @@
 
 
 static BOOL
-STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, LPCSTR text)
+STATUSBAR_WMSetText (STATUS_INFO *infoPtr, LPCSTR text)
 {
     STATUSWINDOWPART *part;
     int len;
@@ -1058,7 +1056,7 @@
 
 
 static BOOL
-STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags)
+STATUSBAR_WMSize (STATUS_INFO *infoPtr, WORD flags)
 {
     INT  width, x, y;
     RECT parent_rect;
@@ -1088,7 +1086,7 @@
 
 
 static LRESULT
-STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd)
+STATUSBAR_NotifyFormat (STATUS_INFO *infoPtr, HWND from, INT cmd)
 {
     if (cmd == NF_REQUERY) {
 	INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY);
@@ -1099,14 +1097,13 @@
 
 
 static LRESULT
-STATUSBAR_SendNotify (HWND hwnd, UINT code)
+STATUSBAR_SendNotify (STATUS_INFO *infoPtr, UINT code)
 {
-    STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
     NMHDR  nmhdr;
 
     TRACE("code %04x\n", code);
-    nmhdr.hwndFrom = hwnd;
-    nmhdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID);
+    nmhdr.hwndFrom = infoPtr->Self;
+    nmhdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
     nmhdr.code = code;
     SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
     return 0;
@@ -1117,7 +1114,7 @@
 static LRESULT WINAPI
 StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
+    STATUS_INFO *infoPtr = (STATUS_INFO *)GetWindowLongPtrW (hwnd, 0);
     INT nPart = ((INT) wParam) & 0x00ff;
     LRESULT res;
 
@@ -1206,10 +1203,10 @@
 	    return STATUSBAR_GetTextLength (infoPtr, 0);
 
 	case WM_LBUTTONDBLCLK:
-            return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
+            return STATUSBAR_SendNotify (infoPtr, NM_DBLCLK);
 
 	case WM_LBUTTONUP:
-	    return STATUSBAR_SendNotify (hwnd, NM_CLICK);
+	    return STATUSBAR_SendNotify (infoPtr, NM_CLICK);
 
 	case WM_MOUSEMOVE:
 	    return STATUSBAR_Relay2Tip (infoPtr, msg, wParam, lParam);
@@ -1232,10 +1229,10 @@
 	    return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
 
 	case WM_RBUTTONDBLCLK:
-	    return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
+	    return STATUSBAR_SendNotify (infoPtr, NM_RDBLCLK);
 
 	case WM_RBUTTONUP:
-	    return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
+	    return STATUSBAR_SendNotify (infoPtr, NM_RCLICK);
 
 	case WM_SETFONT:
 	    return STATUSBAR_WMSetFont (infoPtr, (HFONT)wParam, LOWORD(lParam));
@@ -1272,7 +1269,7 @@
     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
     wndClass.lpfnWndProc   = StatusWindowProc;
     wndClass.cbClsExtra    = 0;
-    wndClass.cbWndExtra    = sizeof(STATUSWINDOWINFO *);
+    wndClass.cbWndExtra    = sizeof(STATUS_INFO *);
     wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);
     wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
     wndClass.lpszClassName = STATUSCLASSNAMEW;

reactos/lib/comctl32
syslink.c 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- syslink.c	19 Sep 2004 09:50:06 -0000	1.2
+++ syslink.c	8 Dec 2004 21:57:02 -0000	1.2.6.1
@@ -1478,12 +1478,10 @@
     case WM_SETCURSOR:
     {
         LHITTESTINFO ht;
-        POINTS pt;
         DWORD mp = GetMessagePos();
         
-        pt = MAKEPOINTS(mp);
-        ht.pt.x = pt.x;
-        ht.pt.y = pt.y;
+        ht.pt.x = (short)LOWORD(mp);
+        ht.pt.y = (short)HIWORD(mp);
         
         ScreenToClient(infoPtr->Self, &ht.pt);
         if(SYSLINK_HitTest (infoPtr, &ht))
@@ -1662,7 +1660,7 @@
 
     ZeroMemory (&wndClass, sizeof(wndClass));
     wndClass.style         = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
-    wndClass.lpfnWndProc   = (WNDPROC)SysLinkWindowProc;
+    wndClass.lpfnWndProc   = SysLinkWindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof (SYSLINK_INFO *);
     wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);

reactos/lib/comctl32
tab.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- tab.c	20 Oct 2004 08:36:55 -0000	1.11
+++ tab.c	8 Dec 2004 21:57:02 -0000	1.11.2.1
@@ -1659,8 +1659,7 @@
     dis.hwndItem = hwnd;		/* */
     dis.hDC      = hdc;
     CopyRect(&dis.rcItem,drawRect);
-    dis.itemData = 0;
-    memcpy( &dis.itemData, TAB_GetItem(infoPtr, iItem)->extra, min(sizeof(dis.itemData),infoPtr->cbInfo) );
+    dis.itemData = (ULONG_PTR)TAB_GetItem(infoPtr, iItem)->extra;
 
     /*
      * send the draw message

reactos/lib/comctl32
toolbar.c 1.20 -> 1.20.2.1
diff -u -r1.20 -r1.20.2.1
--- toolbar.c	20 Oct 2004 08:36:55 -0000	1.20
+++ toolbar.c	8 Dec 2004 21:57:02 -0000	1.20.2.1
@@ -47,11 +47,11 @@
  *     - TB_INSERTMARKHITTEST
  *     - TB_SAVERESTORE
  *     - TB_SETMETRICS
+ *     - WM_WININICHANGE
  *   - Notifications:
  *     - NM_CHAR
  *     - NM_KEYDOWN
  *     - TBN_GETOBJECT
- *     - TBN_RESTORE
  *     - TBN_SAVE
  *   - Button wrapping (under construction).
  *   - Fix TB_SETROWS.
@@ -73,6 +73,7 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "winreg.h"
 #include "wingdi.h"
 #include "winuser.h"
 #include "wine/unicode.h"
@@ -157,10 +158,9 @@
     BOOL     bBtnTranspnt;    /* button transparency flag */
     BOOL     bAutoSize;       /* auto size deadlock indicator */
     BOOL     bAnchor;         /* anchor highlight enabled */
-    BOOL     bNtfUnicode;     /* TRUE if NOTIFYs use {W} */
     BOOL     bDoRedraw;       /* Redraw status */
     BOOL     bDragOutSent;    /* has TBN_DRAGOUT notification been sent for this drag? */
-    BOOL     bUnicode;        /* ASCII (FALSE) or Unicode (TRUE)? */
+    BOOL     bUnicode;        /* Notifications are ASCII (FALSE) or Unicode (TRUE)? */
     BOOL     bCaptured;       /* mouse captured? */
     DWORD      dwStyle;         /* regular toolbar style */
     DWORD      dwExStyle;       /* extended toolbar style */
@@ -208,6 +208,9 @@
 #define ARROW_HEIGHT       3
 #define INSERTMARK_WIDTH   2
 
+#define DEFPAD_CX 7
+#define DEFPAD_CY 6
+
 /* gap between border of button and text/image */
 #define OFFSET_X 1
 #define OFFSET_Y 1
@@ -231,6 +234,10 @@
                         TBSTYLE_EX_MIXEDBUTTONS | \
                         TBSTYLE_EX_HIDECLIPPEDBUTTONS)
 
+/* all of the CCS_ styles */
+#define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \
+                       CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT)
+
 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
@@ -329,14 +336,10 @@
     nmhdr->code = code;
 
     TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code,
-	  (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
+	  (infoPtr->bUnicode) ? "via Unicode" : "via ANSI");
 
-    if (infoPtr->bNtfUnicode)
-	return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
-			     (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
-    else
-	return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
-			     (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
+    return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 
+        (WPARAM)nmhdr->idFrom, (LPARAM)nmhdr);
 }
 
 /***********************************************************************
@@ -351,22 +354,22 @@
 {
     INT ret = btnPtr->iBitmap;
 
-    if (ret == I_IMAGECALLBACK) {
-	/* issue TBN_GETDISPINFO */
-	NMTBDISPINFOA nmgd;
-
-	nmgd.idCommand = btnPtr->idCommand;
-	nmgd.lParam = btnPtr->dwData;
-	nmgd.dwMask = TBNF_IMAGE;
-	TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
-			(infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
-			TBN_GETDISPINFOA);
-	if (nmgd.dwMask & TBNF_DI_SETITEM) {
-	    btnPtr->iBitmap = nmgd.iImage;
-	}
-	ret = nmgd.iImage;
-	TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
-	      ret, nmgd.dwMask, infoPtr->nNumBitmaps);
+    if (ret == I_IMAGECALLBACK)
+    {
+        /* issue TBN_GETDISPINFO */
+        NMTBDISPINFOA nmgd;
+
+        memset(&nmgd, 0, sizeof(nmgd));
+        nmgd.idCommand = btnPtr->idCommand;
+        nmgd.lParam = btnPtr->dwData;
+        nmgd.dwMask = TBNF_IMAGE;
+        TOOLBAR_SendNotify(&nmgd.hdr, infoPtr,
+			infoPtr->bUnicode ? TBN_GETDISPINFOW : TBN_GETDISPINFOA);
+        if (nmgd.dwMask & TBNF_DI_SETITEM)
+            btnPtr->iBitmap = nmgd.iImage;
+        ret = nmgd.iImage;
+        TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
+            ret, nmgd.dwMask, infoPtr->nNumBitmaps);
     }
 
     if (ret != I_IMAGENONE)
@@ -707,7 +710,7 @@
     BOOL draw_masked = FALSE;
     INT index;
     INT offset = 0;
-    UINT draw_flags = ILD_NORMAL;
+    UINT draw_flags = ILD_TRANSPARENT;
 
     if (tbcd->nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE))
     {
@@ -868,12 +871,12 @@
 
     /* Center the bitmap horizontally and vertically */
     if (dwStyle & TBSTYLE_LIST)
-        rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X;
+        rcBitmap.left += GetSystemMetrics(SM_CXEDGE);
     else
         rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
 
     if(lpText)
-        rcBitmap.top+= GetSystemMetrics(SM_CYEDGE) + OFFSET_Y;
+        rcBitmap.top+= GetSystemMetrics(SM_CYEDGE);
     else
         rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
 
@@ -942,7 +945,7 @@
 	tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
 	tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
 	tbcd.nmcd.lItemlParam = btnPtr->dwData;
-	ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+	ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
         /* reset these fields so the user can't alter the behaviour like native */
         tbcd.nmcd.hdc = hdc;
         tbcd.nmcd.rc = rc;
@@ -1032,7 +1035,7 @@
 	tbcd.rcText = rcText;
 	tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
 	tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
-	ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+	ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
     }
 
 }
@@ -1068,7 +1071,7 @@
     tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
     tbcd.nmcd.hdc = hdc;
     tbcd.nmcd.rc = ps->rcPaint;
-    ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+    ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
     infoPtr->dwBaseCustDraw = ntfret & 0xffff;
 
     if (infoPtr->bBtnTranspnt)
@@ -1117,7 +1120,7 @@
 	tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
 	tbcd.nmcd.hdc = hdc;
 	tbcd.nmcd.rc = ps->rcPaint;
-	ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+	ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
     }
 }
 
@@ -1804,7 +1807,7 @@
     /* MSDN states that iItem is the index of the button, rather than the
      * command ID as used by every other NMTOOLBAR notification */
     nmtb.iItem = nIndexFrom;
-    if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
+    if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT))
     {
         PCUSTOMBUTTON btnInfo;
         NMHDR hdr;
@@ -1845,7 +1848,7 @@
     /* MSDN states that iItem is the index of the button, rather than the
      * command ID as used by every other NMTOOLBAR notification */
     nmtb.iItem = nIndexAvail;
-    if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
+    if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT))
     {
         PCUSTOMBUTTON btnInfo;
         NMHDR hdr;
@@ -2074,10 +2077,11 @@
 		/* send TBN_QUERYINSERT notification */
 		nmtb.iItem = custInfo->tbInfo->nNumButtons;
 
-		if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
+		if (!TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT))
 		    return FALSE;
 
 		/* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
+		/* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */
 		nmtb.iItem = (int)hwnd;
 		/* Send TBN_INITCUSTOMIZE notification */
 		if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
@@ -2222,8 +2226,7 @@
 
 			/* send TBN_QUERYINSERT notification */
 			nmtb.iItem = index;
-		        TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
-					TBN_QUERYINSERT);
+		        TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT);
 
 			/* get list box item */
 			btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageW (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
@@ -3029,7 +3032,7 @@
     {
         x = y = 1;
         cy += GetSystemMetrics(SM_CYEDGE);
-        cx += GetSystemMetrics(SM_CYEDGE);
+        cx += GetSystemMetrics(SM_CXEDGE);
     }
 
     infoPtr->bAutoSize = TRUE;
@@ -3056,12 +3059,6 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (infoPtr == NULL) {
-	ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
-	ERR("infoPtr == NULL!\n");
-	return 0;
-    }
-
     infoPtr->dwStructSize = (DWORD)wParam;
 
     return 0;
@@ -3162,8 +3159,7 @@
     custInfo.tbHwnd = hwnd;
 
     /* send TBN_BEGINADJUST notification */
-    TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
-		    TBN_BEGINADJUST);
+    TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_BEGINADJUST);
 
     if (!(hRes = FindResourceW (COMCTL32_hModule,
                                 MAKEINTRESOURCEW(IDD_TBCUSTOMIZE),
@@ -3180,8 +3176,7 @@
                                    (LPARAM)&custInfo);
 
     /* send TBN_ENDADJUST notification */
-    TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
-		    TBN_ENDADJUST);
+    TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_ENDADJUST);
 
     return ret;
 }
@@ -3206,7 +3201,7 @@
     nmtb.tbButton.fsStyle = btnPtr->fsStyle;
     nmtb.tbButton.dwData = btnPtr->dwData;
     nmtb.tbButton.iString = btnPtr->iString;
-    TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_DELETINGBUTTON);
+    TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_DELETINGBUTTON);
 
     if ((infoPtr->hwndToolTip) &&
 	!(btnPtr->fsStyle & BTNS_SEP)) {
@@ -3325,9 +3320,6 @@
     INT nIndex = (INT)wParam;
     TBUTTON_INFO *btnPtr;
 
-    if (infoPtr == NULL)
-	return FALSE;
-
     if (lpTbb == NULL)
 	return FALSE;
 
@@ -3356,8 +3348,6 @@
     TBUTTON_INFO *btnPtr;
     INT nIndex;
 
-    if (infoPtr == NULL)
-	return -1;
     if (lpTbInfo == NULL)
 	return -1;
     if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
@@ -3404,8 +3394,6 @@
     TBUTTON_INFO *btnPtr;
     INT nIndex;
 
-    if (infoPtr == NULL)
-	return -1;
     if (lpTbInfo == NULL)
 	return -1;
     if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
@@ -3594,8 +3582,6 @@
     LPRECT     lpRect;
     INT        nIndex;
 
-    if (infoPtr == NULL)
-	return FALSE;
     nIndex = (INT)wParam;
     btnPtr = &infoPtr->buttons[nIndex];
     if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
@@ -3657,8 +3643,6 @@
     LPRECT     lpRect;
     INT        nIndex;
 
-    if (infoPtr == NULL)
-	return FALSE;
     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     btnPtr = &infoPtr->buttons[nIndex];
     if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
@@ -3714,9 +3698,6 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (infoPtr == NULL)
-	return 0;
-
     return infoPtr->nMaxTextRows;
 }
 
@@ -3726,8 +3707,6 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (infoPtr == NULL)
-	return 0;
     return (LRESULT)infoPtr->hwndToolTip;
 }
 
@@ -4385,64 +4364,184 @@
     return TRUE;
 }
 
-static LRESULT
-TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
+
+/* helper for TOOLBAR_SaveRestoreW */
+static BOOL
+TOOLBAR_Save(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave)
 {
-#if 0
-    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
-    LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
+    FIXME("save to %s %s\n", debugstr_w(lpSave->pszSubKey),
+        debugstr_w(lpSave->pszValueName));
+
+    return FALSE;
+}
 
-    if (lpSave == NULL) return 0;
 
-    if ((BOOL)wParam) {
-	/* save toolbar information */
-	FIXME("save to \"%s\" \"%s\"\n",
-	       lpSave->pszSubKey, lpSave->pszValueName);
+/* helper for TOOLBAR_Restore */
+static void
+TOOLBAR_DeleteAllButtons(TOOLBAR_INFO *infoPtr)
+{
+    INT i;
+    TTTOOLINFOW ti;
 
+    ZeroMemory(&ti, sizeof(ti));
+    ti.cbSize   = sizeof(ti);
+    ti.hwnd     = infoPtr->hwndSelf;
 
+    for (i = 0; i < infoPtr->nNumButtons; i++)
+    {
+        if ((infoPtr->hwndToolTip) &&
+            !(infoPtr->buttons[i].fsStyle & BTNS_SEP))
+        {
+            ti.uId      = infoPtr->buttons[i].idCommand;
+            SendMessageW(infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti);
+        }
     }
-    else {
-	/* restore toolbar information */
 
-	FIXME("restore from \"%s\" \"%s\"\n",
-	       lpSave->pszSubKey, lpSave->pszValueName);
+    Free(infoPtr->buttons);
+    infoPtr->buttons = NULL;
+    infoPtr->nNumButtons = 0;
+}
 
 
+/* helper for TOOLBAR_SaveRestoreW */
+static BOOL
+TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave)
+{
+    LONG res;
+    HKEY hkey = NULL;
+    BOOL ret = FALSE;
+    DWORD dwType;
+    DWORD dwSize = 0;
+    NMTBRESTORE nmtbr;
+
+    /* restore toolbar information */
+    TRACE("restore from %s %s\n", debugstr_w(lpSave->pszSubKey),
+        debugstr_w(lpSave->pszValueName));
+
+    memset(&nmtbr, 0, sizeof(nmtbr));
+
+    res = RegOpenKeyExW(lpSave->hkr, lpSave->pszSubKey, 0,
+        KEY_QUERY_VALUE, &hkey);
+    if (!res)
+        res = RegQueryValueExW(hkey, lpSave->pszValueName, NULL, &dwType,
+            NULL, &dwSize);
+    if (!res && dwType != REG_BINARY)
+        res = ERROR_FILE_NOT_FOUND;
+    if (!res)
+    {
+        nmtbr.pData = HeapAlloc(GetProcessHeap(), 0, dwSize);
+        nmtbr.cbData = (UINT)dwSize;
+        if (!nmtbr.pData) res = ERROR_OUTOFMEMORY;
+    }
+    if (!res)
+        res = RegQueryValueExW(hkey, lpSave->pszValueName, NULL, &dwType,
+            (LPBYTE)nmtbr.pData, &dwSize);
+    if (!res)
+    {
+        nmtbr.pCurrent = nmtbr.pData;
+        nmtbr.iItem = -1;
+        nmtbr.cbBytesPerRecord = sizeof(DWORD);
+        nmtbr.cButtons = nmtbr.cbData / nmtbr.cbBytesPerRecord;
+
+        if (!TOOLBAR_SendNotify(&nmtbr.hdr, infoPtr, TBN_RESTORE))
+        {
+            INT i;
+
+            /* remove all existing buttons as this function is designed to
+             * restore the toolbar to a previously saved state */
+            TOOLBAR_DeleteAllButtons(infoPtr);
+
+            for (i = 0; i < nmtbr.cButtons; i++)
+            {
+                nmtbr.iItem = i;
+                nmtbr.tbButton.iBitmap = -1;
+                nmtbr.tbButton.fsState = 0;
+                nmtbr.tbButton.fsStyle = 0;
+                nmtbr.tbButton.idCommand = 0;
+                if (*nmtbr.pCurrent == (DWORD)-1)
+                {
+                    /* separator */
+                    nmtbr.tbButton.fsStyle = TBSTYLE_SEP;
+                    nmtbr.tbButton.iBitmap = SEPARATOR_WIDTH;
+                }
+                else if (*nmtbr.pCurrent == (DWORD)-2)
+                    /* hidden button */
+                    nmtbr.tbButton.fsState = TBSTATE_HIDDEN;
+                else
+                    nmtbr.tbButton.idCommand = (int)*nmtbr.pCurrent;
+
+                nmtbr.pCurrent++;
+                
+                TOOLBAR_SendNotify(&nmtbr.hdr, infoPtr, TBN_RESTORE);
+
+                /* can't contain real string as we don't know whether
+                 * the client put an ANSI or Unicode string in there */
+                if (HIWORD(nmtbr.tbButton.iString))
+                    nmtbr.tbButton.iString = 0;
+
+                TOOLBAR_InsertButtonW(infoPtr->hwndSelf, -1,
+                    (LPARAM)&nmtbr.tbButton);
+            }
+
+            /* do legacy notifications */
+            if (infoPtr->iVersion < 5)
+            {
+                /* FIXME: send TBN_BEGINADJUST */
+                FIXME("send TBN_GETBUTTONINFO for each button\n");
+                /* FIXME: send TBN_ENDADJUST */
+            }
+
+            /* remove all uninitialised buttons
+             * note: loop backwards to avoid having to fixup i on a
+             * delete */
+            for (i = infoPtr->nNumButtons - 1; i >= 0; i--)
+                if (infoPtr->buttons[i].iBitmap == -1)
+                    TOOLBAR_DeleteButton(infoPtr->hwndSelf, i, 0);
+
+            /* only indicate success if at least one button survived */
+            if (infoPtr->nNumButtons > 0) ret = TRUE;
+        }
     }
-#endif
+    HeapFree(GetProcessHeap(), 0, nmtbr.pData);
+    RegCloseKey(hkey);
 
-    return 0;
+    return ret;
 }
 
 
 static LRESULT
-TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
+TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSW lpSave)
 {
-#if 0
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
-    LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
 
-    if (lpSave == NULL)
-	return 0;
+    if (lpSave == NULL) return 0;
 
-    if ((BOOL)wParam) {
-	/* save toolbar information */
-	FIXME("save to \"%s\" \"%s\"\n",
-	       lpSave->pszSubKey, lpSave->pszValueName);
+    if (wParam)
+        return TOOLBAR_Save(infoPtr, lpSave);
+    else
+        return TOOLBAR_Restore(infoPtr, lpSave);
+}
 
 
-    }
-    else {
-	/* restore toolbar information */
+static LRESULT
+TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSA lpSave)
+{
+    TBSAVEPARAMSW SaveW;
+    int len;
 
-	FIXME("restore from \"%s\" \"%s\"\n",
-	       lpSave->pszSubKey, lpSave->pszValueName);
+    if (lpSave == NULL) return 0;
 
+    SaveW.hkr = lpSave->hkr;
 
-    }
-#endif
+    len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, NULL, 0);
+    SaveW.pszSubKey = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, (LPWSTR)SaveW.pszSubKey, len);
 
-    return 0;
+    len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, NULL, 0);
+    SaveW.pszValueName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, (LPWSTR)SaveW.pszValueName, len);
+
+    return TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW);
 }
 
 
@@ -4613,9 +4712,11 @@
     if ((cx < 0) || (cy < 0))
     {
         ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
-	return FALSE;
+        return FALSE;
     }
 
+    TRACE("%p, cx = %d, cy = %d\n", hwnd, cx, cy);
+
     /* The documentation claims you can only change the button size before
      * any button has been added. But this is wrong.
      * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
@@ -4638,11 +4739,6 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (infoPtr == NULL) {
-	TRACE("Toolbar not initialized yet?????\n");
-	return FALSE;
-    }
-
     /* if setting to current values, ignore */
     if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
 	(infoPtr->cxMax == (INT)HIWORD(lParam))) {
@@ -4824,7 +4920,7 @@
 	else
 	    nmhotitem.dwFlags |= HICF_LEAVING;
 
-	no_highlight = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
+	no_highlight = TOOLBAR_SendNotify(&nmhotitem.hdr, infoPtr, TBN_HOTITEMCHANGE);
 
 	/* now invalidate the old and new buttons so they will be painted */
 	if (oldBtnPtr)
@@ -4879,10 +4975,15 @@
     for (i = 0; i < infoPtr->cimlDef; i++)
         infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
 
-    ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth,
-			  &infoPtr->nBitmapHeight);
-    TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
-	  hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
+    if (!ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth,
+            &infoPtr->nBitmapHeight))
+    {
+        infoPtr->nBitmapWidth = 0;
+        infoPtr->nBitmapHeight = 0;
+    }
+
+    TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
+	  hwnd, infoPtr->himlDef, id, infoPtr->nNumBitmaps,
 	  infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
 
     InvalidateRect(hwnd, NULL, TRUE);
@@ -4960,9 +5061,6 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (infoPtr == NULL)
-	return FALSE;
-
     infoPtr->nMaxTextRows = (INT)wParam;
 
     TOOLBAR_CalcToolbar(hwnd);
@@ -5003,8 +5101,6 @@
 
     TRACE("\n");
 
-    if (infoPtr == NULL)
-	return 0;
     hwndOldNotify = infoPtr->hwndNotify;
     infoPtr->hwndNotify = (HWND)wParam;
 
@@ -5095,8 +5191,6 @@
 
     TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd, (HWND)wParam, lParam);
 
-    if (infoPtr == NULL)
-	return 0;
     infoPtr->hwndToolTip = (HWND)wParam;
     return 0;
 }
@@ -5370,7 +5464,6 @@
     infoPtr->nOldHit = -1;
     infoPtr->nHotItem = -1;
     infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
-    infoPtr->bUnicode = IsWindowUnicode (infoPtr->hwndNotify);
     infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
     infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS: DT_CENTER | DT_END_ELLIPSIS;
     infoPtr->bAnchor = FALSE; /* no anchor highlighting */
@@ -5380,15 +5473,14 @@
     infoPtr->bDoRedraw = TRUE;
     infoPtr->clrBtnHighlight = CLR_DEFAULT;
     infoPtr->clrBtnShadow = CLR_DEFAULT;
-    /* not sure where the +1 comes from, but this comes to the same value
-     * as native so this is probably correct */
-    infoPtr->szPadding.cx = 2*(GetSystemMetrics(SM_CXEDGE)+OFFSET_X) + 1;
-    infoPtr->szPadding.cy = 2*(GetSystemMetrics(SM_CYEDGE)+OFFSET_Y);
+    infoPtr->szPadding.cx = DEFPAD_CX;
+    infoPtr->szPadding.cy = DEFPAD_CY;
     infoPtr->iListGap = infoPtr->szPadding.cx / 2;
     infoPtr->dwStyle = dwStyle;
     infoPtr->tbim.iButton = -1;
     GetClientRect(hwnd, &infoPtr->client_rect);
-    TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
+    infoPtr->bUnicode = infoPtr->hwndNotify && 
+        (NFR_UNICODE == SendMessageW(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, (LPARAM)NF_REQUERY));
 
     SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
     infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
@@ -5402,13 +5494,13 @@
 			       hwnd, 0, 0, 0);
 
 	/* Send NM_TOOLTIPSCREATED notification */
-	if (infoPtr->hwndToolTip) {
+	if (infoPtr->hwndToolTip)
+	{
 	    NMTOOLTIPSCREATED nmttc;
 
 	    nmttc.hwndToolTips = infoPtr->hwndToolTip;
 
-	    TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
-			    NM_TOOLTIPSCREATED);
+	    TOOLBAR_SendNotify (&nmttc.hdr, infoPtr, NM_TOOLTIPSCREATED);
 	}
     }
 
@@ -5483,7 +5575,7 @@
 	ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
 	tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
 	tbcd.nmcd.hdc = (HDC)wParam;
-	ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+	ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
 	infoPtr->dwBaseCustDraw = ntfret & 0xffff;
 
 	/* FIXME: in general the return flags *can* be or'ed together */
@@ -5523,7 +5615,7 @@
 	ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
 	tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
 	tbcd.nmcd.hdc = (HDC)wParam;
-	ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
+	ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW);
 	infoPtr->dwBaseCustDraw = ntfret & 0xffff;
 	switch (infoPtr->dwBaseCustDraw)
 	    {
@@ -5632,11 +5724,9 @@
 	    RedrawWindow(hwnd,&btnPtr->rect,0,
 			RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
 
+	    memset(&nmtb, 0, sizeof(nmtb));
 	    nmtb.iItem = btnPtr->idCommand;
-	    memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
-	    nmtb.cchText = 0;
-	    nmtb.pszText = 0;
-	    CopyRect(&nmtb.rcButton, &btnPtr->rect);
+	    nmtb.rcButton = btnPtr->rect;
 	    res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
 				  TBN_DROPDOWN);
 	    TRACE("TBN_DROPDOWN responded with %ld\n", res);
@@ -5686,22 +5776,15 @@
 
     if (nHit >=0)
     {
+        memset(&nmtb, 0, sizeof(nmtb));
         nmtb.iItem = btnPtr->idCommand;
-        nmtb.tbButton.iBitmap = btnPtr->iBitmap;
-        nmtb.tbButton.idCommand = btnPtr->idCommand;
-        nmtb.tbButton.fsState = btnPtr->fsState;
-        nmtb.tbButton.fsStyle = btnPtr->fsStyle;
-        nmtb.tbButton.dwData = btnPtr->dwData;
-        nmtb.tbButton.iString = btnPtr->iString;
-        nmtb.cchText = 0;  /* !!! not correct */
-        nmtb.pszText = 0;  /* !!! not correct */
         TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_BEGINDRAG);
     }
 
     nmmouse.dwHitInfo = nHit;
 
     /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
-    if (nmmouse.dwHitInfo < 0)
+    if (nHit < 0)
         nmmouse.dwItemSpec = -1;
     else
     {
@@ -5712,7 +5795,7 @@
     ClientToScreen(hwnd, &pt); 
     nmmouse.pt = pt;
 
-    if (!TOOLBAR_SendNotify((LPNMHDR)&nmmouse, infoPtr, NM_LDOWN))
+    if (!TOOLBAR_SendNotify(&nmmouse.hdr, infoPtr, NM_LDOWN))
         return DefWindowProcW(hwnd, WM_LBUTTONDOWN, wParam, lParam);
 
     return 0;
@@ -5847,15 +5930,8 @@
 	/* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
 	 * TBN_BEGINDRAG
 	 */
+	memset(&nmtb, 0, sizeof(nmtb));
 	nmtb.iItem = btnPtr->idCommand;
-	nmtb.tbButton.iBitmap = btnPtr->iBitmap;
-	nmtb.tbButton.idCommand = btnPtr->idCommand;
-	nmtb.tbButton.fsState = btnPtr->fsState;
-	nmtb.tbButton.fsStyle = btnPtr->fsStyle;
-	nmtb.tbButton.dwData = btnPtr->dwData;
-	nmtb.tbButton.iString = btnPtr->iString;
-	nmtb.cchText = 0;  /* !!! not correct */
-	nmtb.pszText = 0;  /* !!! not correct */
 	TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
 			TBN_ENDDRAG);
 
@@ -5891,16 +5967,17 @@
 TOOLBAR_RButtonUp( HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
-
+    INT nHit;
     NMMOUSE nmmouse;
     POINT pt;
 
     pt.x = LOWORD(lParam);
     pt.y = HIWORD(lParam);
 
-    nmmouse.dwHitInfo = TOOLBAR_InternalHitTest(hwnd, &pt);
+    nHit = TOOLBAR_InternalHitTest(hwnd, &pt);
+    nmmouse.dwHitInfo = nHit;
 
-    if (nmmouse.dwHitInfo < 0) {
+    if (nHit < 0) {
 	nmmouse.dwItemSpec = -1;
     } else {
 	nmmouse.dwItemSpec = infoPtr->buttons[nmmouse.dwHitInfo].idCommand;
@@ -6207,7 +6284,7 @@
     if (index < 0)
         return 0;
 
-    if (infoPtr->bNtfUnicode)
+    if (infoPtr->bUnicode)
     {
         WCHAR wszBuffer[INFOTIPSIZE+1];
         NMTBGETINFOTIPW tbgit;
@@ -6362,7 +6439,7 @@
         return TOOLBAR_TTGetDispInfo(infoPtr, (LPNMTTDISPINFOW)lParam);
 
     case TTN_GETDISPINFOA:
-        FIXME("TTN_GETDISPINFOA - stub\n");
+        FIXME("TTN_GETDISPINFOA - should not be received; please report\n");
         return 0;
 
     default:
@@ -6372,38 +6449,26 @@
 
 
 static LRESULT
-TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    /* remove this routine when Toolbar is improved to pass infoPtr
-     * around instead of hwnd.
-     */
-    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
-    return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
-}
-
-
-static LRESULT
 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-    INT i;
+    LRESULT format;
 
     TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam, lParam);
 
-    if ((lParam == NF_QUERY) && ((HWND)wParam == infoPtr->hwndToolTip))
+    if (lParam == NF_QUERY)
         return NFR_UNICODE;
 
     if (lParam == NF_REQUERY) {
-	i = SendMessageW(infoPtr->hwndNotify,
+	format = SendMessageW(infoPtr->hwndNotify,
 			 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
-	if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
-	    ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
-		i);
-	    i = NFR_ANSI;
+	if ((format != NFR_ANSI) && (format != NFR_UNICODE)) {
+	    ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n",
+		format);
+	    format = NFR_ANSI;
 	}
-	infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
-	return (LRESULT)i;
+	return format;
     }
-    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
+    return 0;
 }
 
 
@@ -6541,7 +6606,7 @@
 	{
 	    x = y = 1;
 	    cy += GetSystemMetrics(SM_CYEDGE);
-	    cx += GetSystemMetrics(SM_CYEDGE);
+	    cx += GetSystemMetrics(SM_CXEDGE);
 	}
 
         if(infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS)
@@ -6597,27 +6662,29 @@
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
 
-    if (nType == GWL_STYLE) {
-	if (lpStyle->styleNew & TBSTYLE_LIST) {
-	    infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;
-	}
-	else {
-	    infoPtr->dwDTFlags = DT_CENTER | DT_END_ELLIPSIS;
-	}
+    if (nType == GWL_STYLE)
+    {
+        if (lpStyle->styleNew & TBSTYLE_LIST)
+            infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;
+        else
+            infoPtr->dwDTFlags = DT_CENTER | DT_END_ELLIPSIS;
+
 	infoPtr->bBtnTranspnt = (lpStyle->styleNew &
 				 (TBSTYLE_FLAT | TBSTYLE_LIST));
-	TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
+        TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
 
         TRACE("new style 0x%08lx\n", lpStyle->styleNew);
 
         infoPtr->dwStyle = lpStyle->styleNew;
-    }
-
-    TOOLBAR_CalcToolbar(hwnd);
-
-    TOOLBAR_AutoSize (hwnd);
 
-    InvalidateRect(hwnd, NULL, TRUE);
+        /* only resize if one of the CCS_* styles was changed */
+        if ((infoPtr->dwStyle ^ lpStyle->styleNew) & COMMON_STYLES)
+        {
+            TOOLBAR_AutoSize (hwnd);
+    
+            InvalidateRect(hwnd, NULL, TRUE);
+        }
+    }
 
     return 0;
 }
@@ -6641,7 +6708,7 @@
     TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
 	  hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
 
-    if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
+    if (!infoPtr && (uMsg != WM_NCCREATE))
 	return DefWindowProcW( hwnd, uMsg, wParam, lParam );
 
     switch (uMsg)
@@ -6829,10 +6896,10 @@
             return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam);
 
 	case TB_SAVERESTOREA:
-	    return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
+	    return TOOLBAR_SaveRestoreA (hwnd, wParam, (LPTBSAVEPARAMSA)lParam);
 
 	case TB_SAVERESTOREW:
-	    return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
+	    return TOOLBAR_SaveRestoreW (hwnd, wParam, (LPTBSAVEPARAMSW)lParam);
 
 	case TB_SETANCHORHIGHLIGHT:
 	    return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
@@ -6998,7 +7065,7 @@
 	    return TOOLBAR_Notify (hwnd, wParam, lParam);
 
 	case WM_NOTIFYFORMAT:
-	    return TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
+	    return TOOLBAR_NotifyFormat (infoPtr, wParam, lParam);
 
 	case WM_PAINT:
 	    return TOOLBAR_Paint (hwnd, wParam);
@@ -7145,7 +7212,7 @@
 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb)
 {
     if (infoPtr->bUnicode)
-        return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW);
+        return TOOLBAR_SendNotify(&nmtb->hdr, infoPtr, TBN_GETBUTTONINFOW);
     else
     {
         CHAR Buffer[256];
@@ -7157,7 +7224,7 @@
         nmtba.cchText = 256;
         ZeroMemory(nmtba.pszText, nmtba.cchText);
 
-        if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA))
+        if (TOOLBAR_SendNotify(&nmtba.hdr, infoPtr, TBN_GETBUTTONINFOA))
         {
             int ccht = strlen(nmtba.pszText);
             if (ccht)

reactos/lib/comctl32
tooltips.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- tooltips.c	20 Oct 2004 08:36:55 -0000	1.9
+++ tooltips.c	8 Dec 2004 21:57:02 -0000	1.9.2.1
@@ -1927,16 +1927,25 @@
 {
     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     LPCSTR pszTitle = (LPCSTR)lParam;
-    UINT uTitleIcon = (UINT)wParam;
+    UINT_PTR uTitleIcon = (UINT_PTR)wParam;
     UINT size;
 
-    TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, pszTitle, (void*)uTitleIcon);
+    TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_a(pszTitle),
+        (void*)uTitleIcon);
+
+    Free(infoPtr->pszTitle);
+
+    if (pszTitle)
+    {
+        size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0);
+        infoPtr->pszTitle = Alloc(size);
+        if (!infoPtr->pszTitle)
+            return FALSE;
+        MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR));
+    }
+    else
+        infoPtr->pszTitle = NULL;
 
-    size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0);
-    infoPtr->pszTitle = Alloc(size);
-    if (!infoPtr->pszTitle)
-        return FALSE;
-    MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR));
     if (uTitleIcon <= TTI_ERROR)
         infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
     else
@@ -1951,16 +1960,25 @@
 {
     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     LPCWSTR pszTitle = (LPCWSTR)lParam;
-    UINT uTitleIcon = (UINT)wParam;
+    UINT_PTR uTitleIcon = (UINT_PTR)wParam;
     UINT size;
 
-    TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle), (void*)uTitleIcon);
+    TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle),
+        (void*)uTitleIcon);
+
+    Free(infoPtr->pszTitle);
+
+    if (pszTitle)
+    {
+        size = (strlenW(pszTitle)+1)*sizeof(WCHAR);
+        infoPtr->pszTitle = Alloc(size);
+        if (!infoPtr->pszTitle)
+            return FALSE;
+        memcpy(infoPtr->pszTitle, pszTitle, size);
+    }
+    else
+        infoPtr->pszTitle = NULL;
 
-    size = (strlenW(pszTitle)+1)*sizeof(WCHAR);
-    infoPtr->pszTitle = Alloc(size);
-    if (!infoPtr->pszTitle)
-        return FALSE;
-    memcpy(infoPtr->pszTitle, pszTitle, size);
     if (uTitleIcon <= TTI_ERROR)
         infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
     else
@@ -2818,7 +2836,7 @@
 TOOLTIPS_Unregister (void)
 {
     int i;
-    for (i = 0; i < TTI_ERROR+1; i++)
-        DeleteObject(hTooltipIcons[i]);
+    for (i = TTI_INFO; i <= TTI_ERROR; i++)
+        DestroyIcon(hTooltipIcons[i]);
     UnregisterClassW (TOOLTIPS_CLASSW, NULL);
 }

reactos/lib/comctl32
trackbar.c 1.6 -> 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- trackbar.c	19 Sep 2004 09:50:06 -0000	1.6
+++ trackbar.c	8 Dec 2004 21:57:02 -0000	1.6.6.1
@@ -1418,9 +1418,12 @@
 }
 
 static LRESULT
-TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts)
+TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y)
 {
-    POINT clickPoint = { pts.x, pts.y };
+    POINT clickPoint;
+
+    clickPoint.x = x;
+    clickPoint.y = y;
 
     SetFocus(infoPtr->hwndSelf);
 
@@ -1444,7 +1447,7 @@
 
 
 static LRESULT
-TRACKBAR_LButtonUp (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts)
+TRACKBAR_LButtonUp (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y)
 {
     if (infoPtr->flags & TB_DRAG_MODE) {
         notify_with_scroll (infoPtr, TB_THUMBPOSITION | (infoPtr->lPos<<16));
@@ -1526,17 +1529,18 @@
 
 
 static LRESULT
-TRACKBAR_MouseMove (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts)
+TRACKBAR_MouseMove (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y)
 {
     DWORD dwStyle = GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE);
-    INT clickPlace = (dwStyle & TBS_VERT) ? pts.y : pts.x;
+    INT clickPlace = (dwStyle & TBS_VERT) ? y : x;
     LONG dragPos, oldPos = infoPtr->lPos;
 
-    TRACE("(x=%d. y=%d)\n", pts.x, pts.y);
+    TRACE("(x=%d. y=%d)\n", x, y);
 
     if (infoPtr->flags & TB_AUTO_PAGE) {
 	POINT pt;
-	POINTSTOPOINT(pt, pts);
+	pt.x = x;
+	pt.y = y;
 	TRACKBAR_AutoPage (infoPtr, pt);
 	return TRUE;
     }
@@ -1778,13 +1782,13 @@
         return TRACKBAR_KillFocus (infoPtr, (HWND)wParam);
 
     case WM_LBUTTONDOWN:
-        return TRACKBAR_LButtonDown (infoPtr, wParam, MAKEPOINTS(lParam));
+        return TRACKBAR_LButtonDown (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
     case WM_LBUTTONUP:
-        return TRACKBAR_LButtonUp (infoPtr, wParam, MAKEPOINTS(lParam));
+        return TRACKBAR_LButtonUp (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
     case WM_MOUSEMOVE:
-        return TRACKBAR_MouseMove (infoPtr, wParam, MAKEPOINTS(lParam));
+        return TRACKBAR_MouseMove (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
     case WM_PAINT:
         return TRACKBAR_Paint (infoPtr, (HDC)wParam);

reactos/lib/comctl32
treeview.c 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- treeview.c	21 Oct 2004 08:38:35 -0000	1.12
+++ treeview.c	8 Dec 2004 21:57:03 -0000	1.12.2.1
@@ -130,6 +130,7 @@
   COLORREF      clrLine;
   COLORREF      clrInsertMark;
   HFONT         hFont;
+  HFONT         hDefaultFont;
   HFONT         hBoldFont;
   HWND          hwndToolTip;
 
@@ -255,11 +256,11 @@
 static HFONT
 TREEVIEW_CreateBoldFont(HFONT hOrigFont)
 {
-    LOGFONTA font;
+    LOGFONTW font;
 
-    GetObjectA(hOrigFont, sizeof(font), &font);
+    GetObjectW(hOrigFont, sizeof(font), &font);
     font.lfWeight = FW_BOLD;
-    return CreateFontIndirectA(&font);
+    return CreateFontIndirectW(&font);
 }
 
 static inline HFONT
@@ -1809,7 +1810,7 @@
 
     TRACE("%p %i\n", hFont, bRedraw);
 
-    infoPtr->hFont = hFont ? hFont : GetStockObject(SYSTEM_FONT);
+    infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont;
 
     DeleteObject(infoPtr->hBoldFont);
     infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont);
@@ -2328,7 +2329,7 @@
 	    SelectObject(hdc, hOldPen);
 	    DeleteObject(hNewPen);
 
-	    if (height < 32 || width < 32)
+	    if (height < 18 || width < 18)
 	    {
 	        MoveToEx(hdc, centerx - plussize + 1, centery, NULL);
 	        LineTo(hdc, centerx + plussize, centery);
@@ -4684,6 +4685,7 @@
     static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
     RECT rcClient;
     TREEVIEW_INFO *infoPtr;
+    LOGFONTW lf;
 
     TRACE("wnd %p, style %lx\n", hwnd, GetWindowLongW(hwnd, GWL_STYLE));
 
@@ -4749,7 +4751,8 @@
 
     infoPtr->items = DPA_Create(16);
 
-    infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
+    SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
+    infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW(&lf);
     infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont);
 
     infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
@@ -4839,6 +4842,7 @@
     /* Deassociate treeview from the window before doing anything drastic. */
     SetWindowLongPtrW(infoPtr->hwnd, 0, (DWORD_PTR)NULL);
 
+    DeleteObject(infoPtr->hDefaultFont);
     DeleteObject(infoPtr->hBoldFont);
     Free(infoPtr);
 
@@ -5399,7 +5403,7 @@
 
     ZeroMemory(&wndClass, sizeof(WNDCLASSA));
     wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
-    wndClass.lpfnWndProc = (WNDPROC)TREEVIEW_WindowProc;
+    wndClass.lpfnWndProc = TREEVIEW_WindowProc;
     wndClass.cbClsExtra = 0;
     wndClass.cbWndExtra = sizeof(TREEVIEW_INFO *);
 

reactos/lib/comctl32
updown.c 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- updown.c	20 Oct 2004 08:36:55 -0000	1.6
+++ updown.c	8 Dec 2004 21:57:03 -0000	1.6.2.1
@@ -92,12 +92,12 @@
 #define TIMER_ACCEL        2
 #define TIMER_AUTOPRESS    3
 
-#define BUDDY_UPDOWN_HWND        "buddyUpDownHWND"
-#define BUDDY_SUPERCLASS_WNDPROC "buddySupperClassWndProc"
-
 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
 #define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
 
+static const WCHAR BUDDY_UPDOWN_HWND[] = { 'b', 'u', 'd', 'd', 'y', 'U', 'p', 'D', 'o', 'w', 'n', 'H', 'W', 'N', 'D', 0 };
+static const WCHAR BUDDY_SUPERCLASS_WNDPROC[] = { 'b', 'u', 'd', 'd', 'y', 'S', 'u', 'p', 'p', 'e', 'r', 
+						   'C', 'l', 'a', 's', 's', 'W', 'n', 'd', 'P', 'r', 'o', 'c', 0 };
 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action);
 
 /***********************************************************************
@@ -427,12 +427,13 @@
 static LRESULT CALLBACK
 UPDOWN_Buddy_SubclassProc(HWND  hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    WNDPROC superClassWndProc = (WNDPROC)GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC);
-    TRACE("hwnd=%p, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n",
-	  hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam);
+    WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC);
+
+    TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08x, lParam=%08lx\n",
+          hwnd, superClassWndProc, uMsg, wParam, lParam);
 
     if (uMsg == WM_KEYDOWN) {
-        HWND upDownHwnd = GetPropA(hwnd, BUDDY_UPDOWN_HWND);
+        HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
 
 	UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
     }
@@ -452,11 +453,13 @@
  */
 static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
 {
+    static const WCHAR editW[] = { 'E', 'd', 'i', 't', 0 };
+    static const WCHAR listboxW[] = { 'L', 'i', 's', 't', 'b', 'o', 'x', 0 };
     DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
     RECT  budRect;  /* new coord for the buddy */
     int   x, width;  /* new x position and width for the up-down */
     WNDPROC baseWndProc;
-    CHAR buddyClass[40];
+    WCHAR buddyClass[40];
     HWND ret;
 
     TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
@@ -464,7 +467,7 @@
     ret = infoPtr->Buddy;
 
     /* there is already a body assigned */
-    if (infoPtr->Buddy)  RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
+    if (infoPtr->Buddy)  RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
 
     if(!IsWindow(bud))
         bud = 0;
@@ -475,14 +478,14 @@
     if(bud) {
 
         /* keep upDown ctrl hwnd in a buddy property */
-        SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
+        SetPropW( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
 
         /* Store buddy window class type */
         infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
-        if (GetClassNameA(bud, buddyClass, COUNT_OF(buddyClass))) {
-            if (lstrcmpiA(buddyClass, "Edit") == 0)
+        if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) {
+            if (lstrcmpiW(buddyClass, editW) == 0)
                 infoPtr->BuddyType = BUDDY_TYPE_EDIT;
-            else if (lstrcmpiA(buddyClass, "Listbox") == 0)
+            else if (lstrcmpiW(buddyClass, listboxW) == 0)
                 infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
         }
 
@@ -490,9 +493,9 @@
             /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
                when we reset the upDown ctrl buddy to another buddy because it is not
                good to break the window proc chain. */
-            if (!GetPropA(bud, BUDDY_SUPERCLASS_WNDPROC)) {
+            if (!GetPropW(bud, BUDDY_SUPERCLASS_WNDPROC)) {
                 baseWndProc = (WNDPROC)SetWindowLongPtrW(bud, GWLP_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc);
-                SetPropA(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc);
+                SetPropW(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc);
             }
         }
 
@@ -508,7 +511,8 @@
             budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
             x  = budRect.right+DEFAULT_XSEP;
         } else {
-            x  = budRect.right+DEFAULT_XSEP;
+            /* nothing to do */
+            return ret;
         }
 
         /* first adjust the buddy to accommodate the up/down */
@@ -533,7 +537,7 @@
                 x -= DEFAULT_BUDDYBORDER;
         }
 
-        SetWindowPos(infoPtr->Self, infoPtr->Buddy, x,
+        SetWindowPos(infoPtr->Self, 0, x,
                      budRect.top - DEFAULT_ADDTOP, width,
                      budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
                      SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
@@ -568,6 +572,8 @@
     delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
     if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
 
+    TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
+
     /* We must notify parent now to obtain permission */
     ni.iPos = infoPtr->CurVal;
     ni.iDelta = delta;
@@ -579,6 +585,8 @@
 
         /* Now adjust value with (maybe new) delta */
         if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
+            TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
+
             /* Now take care about our buddy */
             if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr);
         }
@@ -597,7 +605,7 @@
  */
 static BOOL UPDOWN_IsEnabled (UPDOWN_INFO *infoPtr)
 {
-    if(GetWindowLongW (infoPtr->Self, GWL_STYLE) & WS_DISABLED)
+    if (!IsWindowEnabled(infoPtr->Self))
         return FALSE;
     if(infoPtr->Buddy)
         return IsWindowEnabled(infoPtr->Buddy);
@@ -642,23 +650,32 @@
  * 'pt' is the location of the mouse event in client or
  * windows coordinates.
  */
-static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINTS pts)
+static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
 {
     DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
-    POINT pt = { pts.x, pts.y };
+    POINT pt = { x, y };
     RECT rect;
     int temp, arrow;
 
+    TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
+
     switch(msg)
     {
         case WM_LBUTTONDOWN:  /* Initialise mouse tracking */
-            /* If we are inside an arrow, then nothing to do */
-            if(!(infoPtr->Flags & FLAG_MOUSEIN)) return;
 
             /* If the buddy is an edit, will set focus to it */
 	    if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
 
             /* Now see which one is the 'active' arrow */
+            arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
+
+            /* Update the flags if we are in/out */
+            infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
+            if (arrow)
+                infoPtr->Flags |= FLAG_MOUSEIN | arrow;
+            else
+                if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
+
 	    if (infoPtr->Flags & FLAG_ARROW) {
 
             	/* Update the CurVal if necessary */
@@ -671,7 +688,8 @@
 	    	InvalidateRect (infoPtr->Self, NULL, FALSE);
 
             	/* process the click */
-            	UPDOWN_DoAction (infoPtr, 1, infoPtr->Flags & FLAG_ARROW);
+		temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
+            	UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
 
             	/* now capture all mouse messages */
             	SetCapture (infoPtr->Self);
@@ -710,13 +728,14 @@
 /***********************************************************************
  *           UpDownWndProc
  */
-static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
-				LPARAM lParam)
+static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
     DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
     int temp;
 
+    TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n", hwnd, message, wParam, lParam);
+
     if (!infoPtr && (message != WM_CREATE))
         return DefWindowProcW (hwnd, message, wParam, lParam);
 
@@ -750,7 +769,7 @@
 	case WM_DESTROY:
 	    if(infoPtr->AccelVect) Free (infoPtr->AccelVect);
 
-	    if(infoPtr->Buddy) RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
+	    if(infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
 
 	    Free (infoPtr);
 	    SetWindowLongPtrW (hwnd, 0, 0);
@@ -821,7 +840,7 @@
 	case WM_LBUTTONDOWN:
 	case WM_MOUSEMOVE:
 	    if(UPDOWN_IsEnabled(infoPtr))
-		UPDOWN_HandleMouseEvent (infoPtr, message, MAKEPOINTS(lParam));
+		UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 	    break;
 
 	case WM_KEYDOWN:
@@ -842,7 +861,8 @@
 	    return 0;
 
 	case UDM_SETACCEL:
-	    TRACE("UpDown Ctrl new accel info, hwnd=%p\n", hwnd);
+	    TRACE("UDM_SETACCEL\n");
+
 	    if(infoPtr->AccelVect) {
 		Free (infoPtr->AccelVect);
 		infoPtr->AccelCount = 0;
@@ -852,6 +872,11 @@
 	    infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
 	    if(infoPtr->AccelVect == 0) return FALSE;
 	    memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
+            infoPtr->AccelCount = wParam;
+
+            for (temp = 0; temp < wParam; temp++)
+                TRACE("%d: nSec %u nInc %u\n", temp, infoPtr->AccelVect[temp].nSec, infoPtr->AccelVect[temp].nInc);
+
     	    return TRUE;
 
 	case UDM_GETBASE:

reactos/lib/comctl32
winehq2ros.patch 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- winehq2ros.patch	21 Oct 2004 08:38:36 -0000	1.12
+++ winehq2ros.patch	8 Dec 2004 21:57:03 -0000	1.12.2.1
@@ -4,7 +4,7 @@
 retrieving revision 1.46
 diff -u -r1.46 comctl32.spec
 --- comctl32.spec	19 Oct 2004 22:59:59 -0000	1.46
-+++ comctl32.spec	21 Oct 2004 08:50:24 -0000
++++ comctl32.spec	5 Dec 2004 22:48:09 -0000
 @@ -106,13 +106,13 @@
  412 stdcall RemoveWindowSubclass(long ptr long)
  413 stdcall DefSubclassProc(long long long long)
@@ -26,13 +26,49 @@
  
  # Functions imported by name
  
+Index: commctrl.c
+===================================================================
+RCS file: /home/wine/wine/dlls/comctl32/commctrl.c,v
+retrieving revision 1.88
+diff -u -r1.88 commctrl.c
+--- commctrl.c	19 Oct 2004 22:59:59 -0000	1.88
++++ commctrl.c	5 Dec 2004 22:48:09 -0000
+@@ -482,7 +482,7 @@
+         r.left += 3;
+         if (style & SBT_RTLREADING)
+ 	    FIXME("Unsupported RTL style!\n");
+-        DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
++        DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
+ 	SetBkMode(hdc, oldbkmode);
+     }
+ }
+Index: datetime.c
+===================================================================
+RCS file: /home/wine/wine/dlls/comctl32/datetime.c,v
+retrieving revision 1.49
+diff -u -r1.49 datetime.c
+--- datetime.c	24 Nov 2004 18:28:31 -0000	1.49
++++ datetime.c	5 Dec 2004 22:48:10 -0000
+@@ -814,10 +814,10 @@
+ 
+     TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
+ 
+-    /* use DrawEdge to adjust the size of rcEdge to get rcDraw */
+     memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw));
+ 
+-    DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST);
++    /* subract the size of the edge drawn by DrawEdge */
++    InflateRect(&infoPtr->rcDraw, -2, -2);
+ 
+     /* set the size of the button that drops the calendar down */
+     /* FIXME: account for style that allows button on left side */
 Index: listview.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
-retrieving revision 1.394
-diff -u -r1.394 listview.c
---- listview.c	2 Sep 2004 23:00:53 -0000	1.394
-+++ listview.c	21 Oct 2004 08:50:32 -0000
+retrieving revision 1.398
+diff -u -r1.398 listview.c
+--- listview.c	24 Nov 2004 18:28:31 -0000	1.398
++++ listview.c	5 Dec 2004 22:48:13 -0000
 @@ -146,6 +146,7 @@
  #include <assert.h>
  #include <ctype.h>
@@ -41,7 +77,7 @@
  #include <stdlib.h>
  #include <stdarg.h>
  #include <stdio.h>
-@@ -2022,7 +2023,8 @@
+@@ -2033,7 +2034,8 @@
  		         infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
  	    Label.right = Label.left + labelSize.cx;
  	    Label.bottom = Label.top + infoPtr->nItemHeight;
@@ -51,7 +87,7 @@
  	    {
  		labelSize.cy = min(Box.bottom - Label.top, labelSize.cy);
  		labelSize.cy /= infoPtr->ntmHeight;
-@@ -9511,7 +9513,8 @@
+@@ -9522,7 +9524,8 @@
          hOldFont = SelectObject(hdc, infoPtr->hFont);
  
      /*Get String Length in pixels */
@@ -61,13 +97,35 @@
  
      /*Add Extra spacing for the next character */
      GetTextMetricsW(hdc, &textMetric);
+Index: rebar.c
+===================================================================
+RCS file: /home/wine/wine/dlls/comctl32/rebar.c,v
+retrieving revision 1.100
+diff -u -r1.100 rebar.c
+--- rebar.c	24 Nov 2004 18:28:31 -0000	1.100
++++ rebar.c	5 Dec 2004 22:48:14 -0000
+@@ -3786,10 +3786,10 @@
+ 	infoPtr->bands = NULL;
+     }
+ 
+-    DeleteObject (infoPtr->hcurArrow);
+-    DeleteObject (infoPtr->hcurHorz);
+-    DeleteObject (infoPtr->hcurVert);
+-    DeleteObject (infoPtr->hcurDrag);
++    DestroyCursor (infoPtr->hcurArrow);
++    DestroyCursor (infoPtr->hcurHorz);
++    DestroyCursor (infoPtr->hcurVert);
++    DestroyCursor (infoPtr->hcurDrag);
+     if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
+     SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
+ 
 Index: string.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/comctl32/string.c,v
 retrieving revision 1.5
 diff -u -r1.5 string.c
 --- string.c	22 Sep 2004 19:10:27 -0000	1.5
-+++ string.c	21 Oct 2004 08:50:38 -0000
++++ string.c	5 Dec 2004 22:48:15 -0000
 @@ -264,7 +264,7 @@
  {
    TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch));
@@ -86,19 +144,36 @@
  }
  
  /*************************************************************************
+Index: tooltips.c
+===================================================================
+RCS file: /home/wine/wine/dlls/comctl32/tooltips.c,v
+retrieving revision 1.74
+diff -u -r1.74 tooltips.c
+--- tooltips.c	25 Oct 2004 21:44:50 -0000	1.74
++++ tooltips.c	5 Dec 2004 22:48:16 -0000
+@@ -2836,7 +2836,7 @@
+ TOOLTIPS_Unregister (void)
+ {
+     int i;
+-    for (i = 0; i < TTI_ERROR+1; i++)
+-        DeleteObject(hTooltipIcons[i]);
++    for (i = TTI_INFO; i <= TTI_ERROR; i++)
++        DestroyIcon(hTooltipIcons[i]);
+     UnregisterClassW (TOOLTIPS_CLASSW, NULL);
+ }
 Index: treeview.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v
-retrieving revision 1.156
-diff -u -r1.156 treeview.c
---- treeview.c	7 Oct 2004 17:34:31 -0000	1.156
-+++ treeview.c	21 Oct 2004 08:50:45 -0000
-@@ -2328,7 +2328,7 @@
+retrieving revision 1.158
+diff -u -r1.158 treeview.c
+--- treeview.c	21 Nov 2004 15:41:08 -0000	1.158
++++ treeview.c	5 Dec 2004 22:48:18 -0000
+@@ -2329,7 +2329,7 @@
  	    SelectObject(hdc, hOldPen);
  	    DeleteObject(hNewPen);
  
 -	    if (height < 16 || width < 16)
-+	    if (height < 32 || width < 32)
++	    if (height < 18 || width < 18)
  	    {
  	        MoveToEx(hdc, centerx - plussize + 1, centery, NULL);
  	        LineTo(hdc, centerx + plussize, centery);

reactos/lib/comdlg32
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:42 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:04 -0000	1.3.16.1
@@ -5,7 +5,7 @@
 
 TARGET_CFLAGS = -D__REACTOS__ @EXTRADEFS@
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a libwine_unicode.a wine_uuid.a ntdll.a winspool.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_unicode.a wine_uuid.a ntdll.a winspool.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_COMDLG32)
 

reactos/lib/comdlg32
filedlg.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- filedlg.c	20 Oct 2004 08:53:06 -0000	1.11
+++ filedlg.c	8 Dec 2004 21:57:04 -0000	1.11.2.1
@@ -841,7 +841,7 @@
 
     /* get path and filenames */
     SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
-    n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
+    n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
 
     TRACE("path >%s< filespec >%s< %d files\n",
          debugstr_w(lpstrCurrentDir),debugstr_w(lpstrFileList),n);
@@ -897,7 +897,7 @@
 
     TRACE("CDM_GETSPEC:\n");
 
-    FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
+    FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
     if( fodInfos->unicode )
     {
         LPWSTR bufW = buffer;
@@ -1650,7 +1650,7 @@
 
     if (ofn->lpstrFile != NULL)
     {
-      WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
+      nSizePath = WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
 			  ofn->lpstrFile, ofn->nMaxFile, NULL, NULL);
       if (ofn->nMaxFile > nSizePath)
       {
@@ -1661,7 +1661,7 @@
     }
   }
 
-  fodInfos->ofnInfos->nFileOffset = nSizePath + 1;
+  fodInfos->ofnInfos->nFileOffset = nSizePath;
   fodInfos->ofnInfos->nFileExtension = 0;
 
   if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
@@ -1709,7 +1709,7 @@
   TRACE("hwnd=%p\n", hwnd);
 
   /* get the files from the edit control */
-  nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
+  nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0');
 
   /* try if the user selected a folder in the shellview */
   if(nFileCount == 0)
@@ -3029,9 +3029,11 @@
 /***********************************************************************
  * FILEDLG95_FILENAME_GetFileNames
  *
- * copies the filenames to a 0-delimited string list (A\0B\0C\0\0)
+ * Copies the filenames to a delimited string list.
+ * The delimiter is specified by the parameter 'separator',
+ *  usually either a space or a nul
  */
-int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
+int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)
 {
 	FileOpenDlgInfos *fodInfos  = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
 	UINT nStrCharCount = 0;	/* index in src buffer */
@@ -3054,7 +3056,7 @@
 	*lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) );
 	*sizeUsed = 0;
 
-	/* build 0-delimited file list from filenames */
+	/* build delimited file list from filenames */
 	while ( nStrCharCount <= nStrLen )
 	{
 	  if ( lpstrEdit[nStrCharCount]=='"' )
@@ -3066,7 +3068,7 @@
 	      (*sizeUsed)++;
 	      nStrCharCount++;
 	    }
-	    (*lpstrFileList)[nFileIndex++] = '\0';
+	    (*lpstrFileList)[nFileIndex++] = separator;
 	    (*sizeUsed)++;
 	    nFileCount++;
 	  }

reactos/lib/comdlg32
filedlgbrowser.h 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- filedlgbrowser.h	9 Jan 2004 01:58:22 -0000	1.1
+++ filedlgbrowser.h	8 Dec 2004 21:57:04 -0000	1.1.24.1
@@ -161,6 +161,6 @@
 
 /* Functions used by the EDIT box */
 void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd);
-int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed);
+int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator);
 
 #endif /*SHBROWSER_H*/

reactos/lib/comdlg32
printdlg.c 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- printdlg.c	20 Oct 2004 08:53:06 -0000	1.8
+++ printdlg.c	8 Dec 2004 21:57:04 -0000	1.8.2.1
@@ -1746,8 +1746,8 @@
 /***********************************************************************
  *           PrintDlgProcA			[internal]
  */
-INT_PTR CALLBACK PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
-			  LPARAM lParam)
+static INT_PTR CALLBACK PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
+                                      LPARAM lParam)
 {
     PRINT_PTRA* PrintStructures;
     INT_PTR res = FALSE;
@@ -1790,8 +1790,8 @@
     return res;
 }
 
-INT_PTR CALLBACK PrintDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
-			  LPARAM lParam)
+static INT_PTR CALLBACK PrintDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
+                                      LPARAM lParam)
 {
     static const WCHAR propW[] = {'_','_','W','I','N','E','_','P','R','I','N','T','D','L','G','D','A','T','A',0};
     PRINT_PTRW* PrintStructures;

reactos/lib/crtdll/time
ctime.c 1.11 -> 1.11.8.1
diff -u -r1.11 -r1.11.8.1
--- ctime.c	15 Aug 2004 17:34:28 -0000	1.11
+++ ctime.c	8 Dec 2004 21:57:04 -0000	1.11.8.1
@@ -78,7 +78,7 @@
 **	5.	They might reference tm.TM_ZONE after calling offtime.
 ** What's best to do in the above cases is open to debate;
 ** for now, we just set things up so that in any of the five cases
-** WILDABBR is used.  Another possibility:  initialize tzname[0] to the
+** 4ABBR is used.  Another possibility:  initialize tzname[0] to the
 ** string "tzname[0] used before set", and similarly for the other cases.
 ** And another:  initialize tzname[0] to "ERA", with an explanation in the
 ** manual page of what this "time zone abbreviation" means (doing this so
@@ -88,8 +88,8 @@
 void _set_daylight_export(int);
 void _set_timezone_export(int);
 
-
-static char WILDABBR[] = "   ";
+static char TZ_NAME[16] = "JST";
+static char TZ_DST_NAME[12] = "";
 
 #ifndef TRUE
 #define TRUE		1
@@ -183,8 +183,8 @@
 static int gmt_is_set;
 
 char * _tzname[2] = {
-  WILDABBR,
-  WILDABBR
+  TZ_NAME,
+  TZ_DST_NAME
 };
 
 static long
@@ -205,8 +205,8 @@
   const struct state * CPP_CONST sp = lclptr;
   int i;
 
-  _tzname[0] = WILDABBR;
-  _tzname[1] = WILDABBR;
+  _tzname[0] = TZ_NAME;
+  _tzname[1] = TZ_DST_NAME;
 #ifdef ALL_STATE
   if (sp == NULL)
   {
@@ -1060,7 +1060,7 @@
    ** but this is no time for a treasure hunt.
    */
   if (offset != 0)
-    tmp->tm_zone = WILDABBR;
+    tmp->tm_zone = TZ_NAME;
   else
   {
 #ifdef ALL_STATE

reactos/lib/dinput
.cvsignore added at 1.1.2.1
diff -N .cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .cvsignore	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,11 @@
+*.coff
+*.dll
+*.d
+*.a
+*.o
+*.sym
+*.map
+*.tmp
+Makefile.ros
+dinput.spec.def
+dinput.stubs.c

reactos/lib/dinput
Makefile.in added at 1.1.2.1
diff -N Makefile.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Makefile.in	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,23 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = dinput.dll
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = -ldxguid -luuid
+
+C_SRCS = \
+	data_formats.c \
+	device.c \
+	dinput_main.c \
+	joystick_linux.c \
+	joystick_linuxinput.c \
+	keyboard.c \
+	mouse.c \
+	regsvr.c
+
+RC_SRCS = version.rc
+
+@MAKE_DLL_RULES@
+
+### Dependencies:

reactos/lib/dinput
Makefile.ros added at 1.3.2.1
diff -N Makefile.ros
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Makefile.ros	8 Dec 2004 21:57:07 -0000	1.3.2.1
@@ -0,0 +1,28 @@
+# $Id: Makefile.ros,v 1.3.2.1 2004/12/08 21:57:07 hyperion Exp $
+
+TARGET_NAME = dinput
+
+TARGET_OBJECTS = data_formats.o device.o dinput_main.o joystick_linux.o joystick_linuxinput.o keyboard.o mouse.o regsvr.o
+
+TARGET_CFLAGS =  -D__REACTOS__
+
+TARGET_SDKLIBS = libwine.a ole32.a user32.a advapi32.a kernel32.a ole32.a wine_uuid.a ntdll.a  winmm.a dxguid.a
+
+
+
+TARGET_RC_SRCS = version.rc
+TARGET_RC_BINSRC = 
+TARGET_RC_BINARIES = 
+
+default: all
+
+authors.c:
+ifeq ($(HOST),mingw32-linux)
+	echo 'const char * const SHELL_Authors[] = { "WINE team", "ReactOS team", 0 };' > authors.c
+else
+	echo const char * const SHELL_Authors[] = { "WINE team", "ReactOS team", 0 }; > authors.c
+endif
+
+DEP_OBJECTS = $(TARGET_OBJECTS)
+
+include $(TOOLS_PATH)/depend.mk

reactos/lib/dinput
Makefile.ros-template added at 1.2.2.1
diff -N Makefile.ros-template
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Makefile.ros-template	8 Dec 2004 21:57:07 -0000	1.2.2.1
@@ -0,0 +1,28 @@
+# $Id: Makefile.ros-template,v 1.2.2.1 2004/12/08 21:57:07 hyperion Exp $
+
+TARGET_NAME = dinput
+
+TARGET_OBJECTS = @C_SRCS@
+
+TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
+
+TARGET_SDKLIBS = libwine.a @IMPORTS@ ole32.a wine_uuid.a ntdll.a  winmm.a dxguid.a
+
+
+
+TARGET_RC_SRCS = @RC_SRCS@
+TARGET_RC_BINSRC = @RC_BINSRC@
+TARGET_RC_BINARIES = @RC_BINARIES@
+
+default: all
+
+authors.c:
+ifeq ($(HOST),mingw32-linux)
+	echo 'const char * const SHELL_Authors[] = { "WINE team", "ReactOS team", 0 };' > authors.c
+else
+	echo const char * const SHELL_Authors[] = { "WINE team", "ReactOS team", 0 }; > authors.c
+endif
+
+DEP_OBJECTS = $(TARGET_OBJECTS)
+
+include $(TOOLS_PATH)/depend.mk

reactos/lib/dinput
data_formats.c added at 1.1.2.1
diff -N data_formats.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ data_formats.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2004 Robert Reif
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* TODO:
+ * add keyboard
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "dinput.h"
+
+#define numObjects(x) (sizeof(x) / sizeof(x[0]))
+
+DIOBJECTDATAFORMAT dfDIJoystick[] = {
+  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+};
+
+const DIDATAFORMAT c_dfDIJoystick = {
+    sizeof(DIDATAFORMAT),
+    sizeof(DIOBJECTDATAFORMAT),
+    DIDF_ABSAXIS,
+    sizeof(DIJOYSTATE2),
+    numObjects(dfDIJoystick),
+    dfDIJoystick
+};
+
+DIOBJECTDATAFORMAT dfDIJoystick2[] = {
+  { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,DIJOFS_RX,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,DIJOFS_RY,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,DIJOFS_RZ,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(0),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(1),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(2),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { &GUID_POV,DIJOFS_POV(3),DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(0),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(1),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(2),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(3),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(4),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(5),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(6),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(7),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(8),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(9),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(10),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(11),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(12),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(13),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(14),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(15),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(16),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(17),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(18),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(19),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(20),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(21),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(22),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(23),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(24),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(25),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(26),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(27),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(28),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(29),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(30),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(31),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(32),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(33),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(34),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(35),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(36),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(37),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(38),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(39),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(40),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(41),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(42),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(43),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(44),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(45),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(46),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(47),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(48),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(49),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(50),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(51),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(52),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(53),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(54),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(55),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(56),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(57),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(58),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(59),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(60),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(61),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(62),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(63),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(64),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(65),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(66),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(67),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(68),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(69),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(70),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(71),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(72),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(73),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(74),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(75),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(76),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(77),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(78),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(79),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(80),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(81),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(82),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(83),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(84),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(85),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(86),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(87),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(88),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(89),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(90),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(91),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(92),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(93),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(94),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(95),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(96),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(97),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(98),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(99),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(100),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(101),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(102),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(103),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(104),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(105),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(106),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(107),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(108),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(109),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(110),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(111),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(112),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(113),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(114),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(115),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(116),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(117),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(118),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(119),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(120),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(121),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(122),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(123),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(124),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(125),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(126),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { NULL,DIJOFS_BUTTON(127),DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lVX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lVY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lVZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lVRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lVRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lVRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglVSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lAX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lAY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lAZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lARx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lARy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lARz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglASlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_XAxis,FIELD_OFFSET(DIJOYSTATE2,lFX),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_YAxis,FIELD_OFFSET(DIJOYSTATE2,lFY),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_ZAxis,FIELD_OFFSET(DIJOYSTATE2,lFZ),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RxAxis,FIELD_OFFSET(DIJOYSTATE2,lFRx),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RyAxis,FIELD_OFFSET(DIJOYSTATE2,lFRy),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_RzAxis,FIELD_OFFSET(DIJOYSTATE2,lFRz),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[0]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+  { &GUID_Slider,FIELD_OFFSET(DIJOYSTATE2,rglFSlider[1]),DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
+};
+
+const DIDATAFORMAT c_dfDIJoystick2 = {
+    sizeof(DIDATAFORMAT),
+    sizeof(DIOBJECTDATAFORMAT),
+    DIDF_ABSAXIS,
+    sizeof(DIJOYSTATE2),
+    numObjects(dfDIJoystick2),
+    dfDIJoystick2
+};
+
+DIOBJECTDATAFORMAT dfDIMouse[] = {
+  { &GUID_XAxis,  DIMOFS_X, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_YAxis,  DIMOFS_Y, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_ZAxis,  DIMOFS_Z, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_Button, DIMOFS_BUTTON0, DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON1, DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON2, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON3, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 }
+};
+
+const DIDATAFORMAT c_dfDIMouse = {
+    sizeof(DIDATAFORMAT),
+    sizeof(DIOBJECTDATAFORMAT),
+    DIDF_RELAXIS,
+    sizeof(DIMOUSESTATE),
+    numObjects(dfDIMouse),
+    dfDIMouse
+};
+
+DIOBJECTDATAFORMAT dfDIMouse2[] = {
+  { &GUID_XAxis,  DIMOFS_X, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_YAxis,  DIMOFS_Y, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_ZAxis,  DIMOFS_Z, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
+  { &GUID_Button, DIMOFS_BUTTON0, DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON1, DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON2, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON3, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON4, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON5, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON6, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 },
+  { &GUID_Button, DIMOFS_BUTTON7, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_BUTTON, 0 }
+};
+
+const DIDATAFORMAT c_dfDIMouse2 = {
+    sizeof(DIDATAFORMAT),
+    sizeof(DIOBJECTDATAFORMAT),
+    DIDF_RELAXIS,
+    sizeof(DIMOUSESTATE2),
+    numObjects(dfDIMouse2),
+    dfDIMouse2
+};

reactos/lib/dinput
device.c added at 1.1.2.1
diff -N device.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ device.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,884 @@
+/*		DirectInput Device
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* This file contains all the Device specific functions that can be used as stubs
+   by real device implementations.
+
+   It also contains all the helper functions.
+*/
+#include "config.h"
+
+#include <stdarg.h>
+#include <string.h>
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "dinput.h"
+#include "device_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+/******************************************************************************
+ *	Various debugging tools
+ */
+void _dump_cooperativelevel_DI(DWORD dwFlags) {
+    if (TRACE_ON(dinput)) {
+	unsigned int   i;
+	static const struct {
+	    DWORD       mask;
+	    const char  *name;
+	} flags[] = {
+#define FE(x) { x, #x}
+	    FE(DISCL_BACKGROUND),
+	    FE(DISCL_EXCLUSIVE),
+	    FE(DISCL_FOREGROUND),
+	    FE(DISCL_NONEXCLUSIVE)
+#undef FE
+	};
+	for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
+	    if (flags[i].mask & dwFlags)
+		DPRINTF("%s ",flags[i].name);
+	DPRINTF("\n");
+    }
+}
+
+void _dump_EnumObjects_flags(DWORD dwFlags) {
+    if (TRACE_ON(dinput)) {
+	unsigned int   i;
+	DWORD type, instance;
+	static const struct {
+	    DWORD       mask;
+	    const char  *name;
+	} flags[] = {
+#define FE(x) { x, #x}
+	    FE(DIDFT_RELAXIS),
+	    FE(DIDFT_ABSAXIS),
+	    FE(DIDFT_PSHBUTTON),
+	    FE(DIDFT_TGLBUTTON),
+	    FE(DIDFT_POV),
+	    FE(DIDFT_COLLECTION),
+	    FE(DIDFT_NODATA),	    
+	    FE(DIDFT_FFACTUATOR),
+	    FE(DIDFT_FFEFFECTTRIGGER),
+	    FE(DIDFT_OUTPUT)
+#undef FE
+	};
+	type = (dwFlags & 0xFF0000FF);
+	instance = ((dwFlags >> 8) & 0xFFFF);
+	DPRINTF("Type:");
+	if (type == DIDFT_ALL) {
+	    DPRINTF(" DIDFT_ALL");
+	} else {
+	    for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
+		if (flags[i].mask & type) {
+		    type &= ~flags[i].mask;
+		    DPRINTF(" %s",flags[i].name);
+		}
+	    }
+	    if (type) {
+		DPRINTF(" (unhandled: %08lx)", type);
+	    }
+	}
+	DPRINTF(" / Instance: ");
+	if (instance == ((DIDFT_ANYINSTANCE >> 8) & 0xFFFF)) {
+	    DPRINTF("DIDFT_ANYINSTANCE");
+	} else {
+	    DPRINTF("%3ld", instance);
+	}
+    }
+}
+
+void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) {
+    if (TRACE_ON(dinput)) {
+	DPRINTF("  - dwObj = 0x%08lx\n", diph->dwObj);
+	DPRINTF("  - dwHow = %s\n",
+		((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
+		 ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
+		  ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
+    }
+}
+
+void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
+    if (TRACE_ON(dinput)) {
+	DPRINTF("    - enumerating : %s ('%s') - %2ld - 0x%08lx - %s\n",
+		debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
+    }
+}
+
+void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) {
+    if (TRACE_ON(dinput)) {
+	DPRINTF("    - enumerating : %s ('%s'), - %2ld - 0x%08lx - %s\n",
+		debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
+    }
+}
+
+/* This function is a helper to convert a GUID into any possible DInput GUID out there */
+const char *_dump_dinput_GUID(const GUID *guid) {
+    unsigned int i;
+    static const struct {
+	const GUID *guid;
+	const char *name;
+    } guids[] = {
+#define FE(x) { &x, #x}
+	FE(GUID_XAxis),
+	FE(GUID_YAxis),
+	FE(GUID_ZAxis),
+	FE(GUID_RxAxis),
+	FE(GUID_RyAxis),
+	FE(GUID_RzAxis),
+	FE(GUID_Slider),
+	FE(GUID_Button),
+	FE(GUID_Key),
+	FE(GUID_POV),
+	FE(GUID_Unknown),
+	FE(GUID_SysMouse),
+	FE(GUID_SysKeyboard),
+	FE(GUID_Joystick),
+	FE(GUID_ConstantForce),
+	FE(GUID_RampForce),
+	FE(GUID_Square),
+	FE(GUID_Sine),
+	FE(GUID_Triangle),
+	FE(GUID_SawtoothUp),
+	FE(GUID_SawtoothDown),
+	FE(GUID_Spring),
+	FE(GUID_Damper),
+	FE(GUID_Inertia),
+	FE(GUID_Friction),
+	FE(GUID_CustomForce)
+#undef FE
+    };
+    if (guid == NULL)
+	return "null GUID";
+    for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
+	if (IsEqualGUID(guids[i].guid, guid)) {
+	    return guids[i].name;
+	}
+    }
+    return "Unknown GUID";
+}
+
+void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) {
+    unsigned int i;
+
+    TRACE("Dumping DIDATAFORMAT structure:\n");
+    TRACE("  - dwSize: %ld\n", df->dwSize);
+    if (df->dwSize != sizeof(DIDATAFORMAT)) {
+	WARN("Non-standard DIDATAFORMAT structure size (%ld instead of %d).\n", df->dwSize, sizeof(DIDATAFORMAT));
+    }
+    TRACE("  - dwObjsize: %ld\n", df->dwObjSize);
+    if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) {
+	WARN("Non-standard DIOBJECTDATAFORMAT structure size (%ld instead of %d).\n", df->dwObjSize, sizeof(DIOBJECTDATAFORMAT));
+    }
+    TRACE("  - dwFlags: 0x%08lx (", df->dwFlags);
+    switch (df->dwFlags) {
+        case DIDF_ABSAXIS: TRACE("DIDF_ABSAXIS"); break;
+	case DIDF_RELAXIS: TRACE("DIDF_RELAXIS"); break;
+	default: TRACE("unknown"); break;
+    }
+    TRACE(")\n");
+    TRACE("  - dwDataSize: %ld\n", df->dwDataSize);
+    TRACE("  - dwNumObjs: %ld\n", df->dwNumObjs);
+    
+    for (i = 0; i < df->dwNumObjs; i++) {
+	TRACE("  - Object %d:\n", i);
+	TRACE("      * GUID: %s ('%s')\n", debugstr_guid(df->rgodf[i].pguid), _dump_dinput_GUID(df->rgodf[i].pguid));
+	TRACE("      * dwOfs: %ld\n", df->rgodf[i].dwOfs);
+	TRACE("      * dwType: 0x%08lx\n", df->rgodf[i].dwType);
+	TRACE("        "); _dump_EnumObjects_flags(df->rgodf[i].dwType); TRACE("\n");
+	TRACE("      * dwFlags: 0x%08lx\n", df->rgodf[i].dwFlags);
+    }
+}
+
+/* Conversion between internal data buffer and external data buffer */
+void fill_DataFormat(void *out, const void *in, DataFormat *df) {
+    int i;
+    char *in_c = (char *) in;
+    char *out_c = (char *) out;
+    
+    if (df->dt == NULL) {
+	/* This means that the app uses Wine's internal data format */
+	memcpy(out, in, df->internal_format_size);
+    } else {
+	for (i = 0; i < df->size; i++) {
+	    if (df->dt[i].offset_in >= 0) {
+		switch (df->dt[i].size) {
+		    case 1:
+		        TRACE("Copying (c) to %d from %d (value %d)\n",
+			      df->dt[i].offset_out, df->dt[i].offset_in, *((char *) (in_c + df->dt[i].offset_in)));
+			*((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in));
+			break;
+		    
+		    case 2:
+			TRACE("Copying (s) to %d from %d (value %d)\n",
+			      df->dt[i].offset_out, df->dt[i].offset_in, *((short *) (in_c + df->dt[i].offset_in)));
+			*((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in));
+			break;
+		    
+		    case 4:
+			TRACE("Copying (i) to %d from %d (value %d)\n",
+			      df->dt[i].offset_out, df->dt[i].offset_in, *((int *) (in_c + df->dt[i].offset_in)));
+			*((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in));
+			break;
+		    
+		    default:
+			memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
+			break;
+		}
+	    } else {
+		switch (df->dt[i].size) {
+		    case 1:
+		        TRACE("Copying (c) to %d default value %d\n",
+			      df->dt[i].offset_out, df->dt[i].value);
+			*((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value;
+			break;
+			
+		    case 2:
+			TRACE("Copying (s) to %d default value %d\n",
+			      df->dt[i].offset_out, df->dt[i].value);
+			*((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
+			break;
+			
+		    case 4:
+			TRACE("Copying (i) to %d default value %d\n",
+			      df->dt[i].offset_out, df->dt[i].value);
+			*((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
+			break;
+			
+		    default:
+			memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0);
+			break;
+		}
+	    }
+	}
+    }
+}
+
+void release_DataFormat(DataFormat * format)
+{
+    TRACE("Deleting DataTransform : \n");
+
+    HeapFree(GetProcessHeap(), 0, format->dt);
+}
+
+DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
+    DataFormat *ret;
+    DataTransform *dt;
+    unsigned int i, j;
+    int same = 1;
+    int *done;
+    int index = 0;
+    DWORD next = 0;
+    
+    ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
+    
+    done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
+    memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
+    
+    dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
+    
+    TRACE("Creating DataTransform : \n");
+    
+    for (i = 0; i < wine_format->dwNumObjs; i++) {
+	offset[i] = -1;
+	
+	for (j = 0; j < asked_format->dwNumObjs; j++) {
+	    if (done[j] == 1)
+		continue;
+	    
+	    if (/* Check if the application either requests any GUID and if not, it if matches
+		 * the GUID of the Wine object.
+		 */
+		((asked_format->rgodf[j].pguid == NULL) ||
+		 (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
+		&&
+		(/* Then check if it accepts any instance id, and if not, if it matches Wine's
+		  * instance id.
+		  */
+		 ((asked_format->rgodf[j].dwType & 0x00FFFF00) == DIDFT_ANYINSTANCE) ||
+		 (DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType) == DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType)))) {
+		
+		done[j] = 1;
+		
+		TRACE("Matching : \n");
+		TRACE("   - Asked (%d) :\n", j);
+		TRACE("       * GUID: %s ('%s')\n",
+		      debugstr_guid(asked_format->rgodf[j].pguid),
+		      _dump_dinput_GUID(asked_format->rgodf[j].pguid));
+		TRACE("       * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
+		TRACE("       * dwType: %08lx\n", asked_format->rgodf[j].dwType);
+		TRACE("         "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
+		
+		TRACE("   - Wine  (%d) :\n", j);
+		TRACE("       * GUID: %s ('%s')\n",
+		      debugstr_guid(wine_format->rgodf[j].pguid),
+		      _dump_dinput_GUID(wine_format->rgodf[j].pguid));
+		TRACE("       * Offset: %3ld\n", wine_format->rgodf[j].dwOfs);
+		TRACE("       * dwType: %08lx\n", wine_format->rgodf[j].dwType);
+		TRACE("         "); _dump_EnumObjects_flags(wine_format->rgodf[j].dwType); TRACE("\n");
+		
+		if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
+		    dt[index].size = sizeof(BYTE);
+		else
+		    dt[index].size = sizeof(DWORD);
+		dt[index].offset_in  = wine_format ->rgodf[i].dwOfs;
+                if (asked_format->rgodf[j].dwOfs < next) {
+                    WARN("bad format: dwOfs=%ld, changing to %ld\n", asked_format->rgodf[j].dwOfs, next);
+		    dt[index].offset_out = next;
+		    offset[i] = next;
+                } else {
+		    dt[index].offset_out = asked_format->rgodf[j].dwOfs;
+                    offset[i] = asked_format->rgodf[j].dwOfs;
+                }
+		dt[index].value = 0;
+                next = next + dt[index].size;
+		
+		if (wine_format->rgodf[i].dwOfs != dt[index].offset_out)
+		    same = 0;
+		
+		index++;
+		break;
+	    }
+	}
+	
+	if (j == asked_format->dwNumObjs)
+	    same = 0;
+    }
+    
+    TRACE("Setting to default value :\n");
+    for (j = 0; j < asked_format->dwNumObjs; j++) {
+	if (done[j] == 0) {
+	    TRACE("   - Asked (%d) :\n", j);
+	    TRACE("       * GUID: %s ('%s')\n",
+		  debugstr_guid(asked_format->rgodf[j].pguid),
+		  _dump_dinput_GUID(asked_format->rgodf[j].pguid));
+	    TRACE("       * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
+	    TRACE("       * dwType: %08lx\n", asked_format->rgodf[j].dwType);
+	    TRACE("         "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
+	    
+	    if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
+		dt[index].size = sizeof(BYTE);
+	    else
+		dt[index].size = sizeof(DWORD);
+	    dt[index].offset_in  = -1;
+	    dt[index].offset_out = asked_format->rgodf[j].dwOfs;
+	    dt[index].value = 0;
+	    index++;
+	    
+	    same = 0;
+	}
+    }
+    
+    ret->internal_format_size = wine_format->dwDataSize;
+    ret->size = index;
+    if (same) {
+	ret->dt = NULL;
+	HeapFree(GetProcessHeap(), 0, dt);
+    } else {
+	ret->dt = dt;
+    }
+    
+    HeapFree(GetProcessHeap(), 0, done);
+    
+    return ret;
+}
+
+BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
+    DIDEVICEOBJECTINSTANCEW ddtmp;
+    device_enumobjects_AtoWcb_data* data;
+
+    data = (device_enumobjects_AtoWcb_data*) lpvRef;
+    
+    memset(&ddtmp, 0, sizeof(DIDEVICEINSTANCEW)); 
+    
+    ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
+    ddtmp.guidType     = lpddi->guidType;
+    ddtmp.dwOfs        = lpddi->dwOfs;
+    ddtmp.dwType       = lpddi->dwType;
+    ddtmp.dwFlags      = lpddi->dwFlags;
+    MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
+    
+    if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
+	/**
+	 * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
+	 *  force feedback and other newer datas aren't available
+	 */
+	ddtmp.dwFFMaxForce        = lpddi->dwFFMaxForce;
+	ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
+	ddtmp.wCollectionNumber   = lpddi->wCollectionNumber;
+	ddtmp.wDesignatorIndex    = lpddi->wDesignatorIndex;
+	ddtmp.wUsagePage          = lpddi->wUsagePage;
+	ddtmp.wUsage              = lpddi->wUsage;
+	ddtmp.dwDimension         = lpddi->dwDimension;
+	ddtmp.wExponent           = lpddi->wExponent;
+	ddtmp.wReserved           = lpddi->wReserved;
+    }
+    return data->lpCallBack(&ddtmp, data->lpvRef);
+}
+
+/******************************************************************************
+ *	IDirectInputDeviceA
+ */
+
+HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
+	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
+) {
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    
+    TRACE("(this=%p,%p)\n",This,df);
+    
+    _dump_DIDATAFORMAT(df);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
+	LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
+) {
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
+    if (TRACE_ON(dinput)) {
+	TRACE(" cooperative level : ");
+	_dump_cooperativelevel_DI(dwflags);
+    }
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
+	LPDIRECTINPUTDEVICE8A iface,HANDLE hnd
+) {
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    FIXME("(this=%p,0x%08lx): stub\n",This,(DWORD)hnd);
+    return DI_OK;
+}
+
+ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    ULONG ref;
+    ref = InterlockedDecrement(&(This->ref));
+    if (ref == 0)
+        HeapFree(GetProcessHeap(),0,This);
+    return ref;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
+	LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
+)
+{
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    
+    TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+    if (IsEqualGUID(&IID_IUnknown,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
+	IDirectInputDevice7_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    TRACE("Unsupported interface !\n");
+    return E_FAIL;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
+	LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
+)
+{
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    
+    TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+    if (IsEqualGUID(&IID_IUnknown,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
+	IDirectInputDevice2_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
+	IDirectInputDevice7_AddRef(iface);
+	*ppobj = This;
+	return DI_OK;
+    }
+    TRACE("Unsupported interface !\n");
+    return E_FAIL;
+}
+
+ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
+	LPDIRECTINPUTDEVICE8A iface)
+{
+    IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+    return InterlockedIncrement(&(This->ref));
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
+    if (TRACE_ON(dinput)) {
+	DPRINTF("  - flags = ");
+	_dump_EnumObjects_flags(dwFlags);
+	DPRINTF("\n");
+    }
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
+    if (TRACE_ON(dinput)) {
+	DPRINTF("  - flags = ");
+	_dump_EnumObjects_flags(dwFlags);
+	DPRINTF("\n");
+    }
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
+	LPDIRECTINPUTDEVICE8A iface,
+	REFGUID rguid,
+	LPDIPROPHEADER pdiph)
+{
+    FIXME("(this=%p,%s,%p): stub!\n",
+	  iface, debugstr_guid(rguid), pdiph);
+    
+    if (TRACE_ON(dinput))
+	_dump_DIPROPHEADER(pdiph);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEOBJECTINSTANCEA pdidoi,
+	DWORD dwObj,
+	DWORD dwHow)
+{
+    FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
+	  iface, pdidoi, dwObj, dwHow);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEOBJECTINSTANCEW pdidoi,
+	DWORD dwObj,
+	DWORD dwHow)
+{
+    FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
+	  iface, pdidoi, dwObj, dwHow);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEINSTANCEA pdidi)
+{
+    FIXME("(this=%p,%p): stub!\n",
+	  iface, pdidi);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEINSTANCEW pdidi)
+{
+    FIXME("(this=%p,%p): stub!\n",
+	  iface, pdidi);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
+	LPDIRECTINPUTDEVICE8A iface,
+	HWND hwndOwner,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,0x%08lx): stub!\n",
+	  iface, hwndOwner, dwFlags);
+
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
+	LPDIRECTINPUTDEVICE8A iface,
+	HINSTANCE hinst,
+	DWORD dwVersion,
+	REFGUID rguid)
+{
+    FIXME("(this=%p,%p,%ld,%s): stub!\n",
+	  iface, hinst, dwVersion, debugstr_guid(rguid));
+    return DI_OK;
+}
+
+/******************************************************************************
+ *	IDirectInputDevice2A
+ */
+
+HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
+	LPDIRECTINPUTDEVICE8A iface,
+	REFGUID rguid,
+	LPCDIEFFECT lpeff,
+	LPDIRECTINPUTEFFECT *ppdef,
+	LPUNKNOWN pUnkOuter)
+{
+    FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
+	  iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMEFFECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
+	  iface, lpCallback, lpvRef, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMEFFECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
+	  iface, lpCallback, lpvRef, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIEFFECTINFOA lpdei,
+	REFGUID rguid)
+{
+    FIXME("(this=%p,%p,%s): stub!\n",
+	  iface, lpdei, debugstr_guid(rguid));
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIEFFECTINFOW lpdei,
+	REFGUID rguid)
+{
+    FIXME("(this=%p,%p,%s): stub!\n",
+	  iface, lpdei, debugstr_guid(rguid));
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDWORD pdwOut)
+{
+    FIXME("(this=%p,%p): stub!\n",
+	  iface, pdwOut);
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
+	LPDIRECTINPUTDEVICE8A iface,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,0x%08lx): stub!\n",
+	  iface, dwFlags);
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
+	  iface, lpCallback, lpvRef, dwFlags);
+    if (lpCallback)
+	lpCallback(NULL, lpvRef);
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIEFFESCAPE lpDIEEsc)
+{
+    FIXME("(this=%p,%p): stub!\n",
+	  iface, lpDIEEsc);
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
+	LPDIRECTINPUTDEVICE8A iface)
+{
+    /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
+    return DI_NOEFFECT;
+}
+
+HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
+	LPDIRECTINPUTDEVICE8A iface,
+	DWORD cbObjectData,
+	LPCDIDEVICEOBJECTDATA rgdod,
+	LPDWORD pdwInOut,
+	DWORD dwFlags)
+{
+    FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
+	  iface, cbObjectData, rgdod, pdwInOut, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
+							  LPCSTR lpszFileName,
+							  LPDIENUMEFFECTSINFILECALLBACK pec,
+							  LPVOID pvRef,
+							  DWORD dwFlags)
+{
+    FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
+							  LPCWSTR lpszFileName,
+							  LPDIENUMEFFECTSINFILECALLBACK pec,
+							  LPVOID pvRef,
+							  DWORD dwFlags)
+{
+    FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
+							  LPCSTR lpszFileName,
+							  DWORD dwEntries,
+							  LPDIFILEEFFECT rgDiFileEft,
+							  DWORD dwFlags)
+{
+    FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
+							  LPCWSTR lpszFileName,
+							  DWORD dwEntries,
+							  LPDIFILEEFFECT rgDiFileEft,
+							  DWORD dwFlags)
+{
+    FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
+						       LPDIACTIONFORMATA lpdiaf,
+						       LPCSTR lpszUserName,
+						       DWORD dwFlags)
+{
+    FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+						       LPDIACTIONFORMATW lpdiaf,
+						       LPCWSTR lpszUserName,
+						       DWORD dwFlags)
+{
+    FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+  
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
+						     LPDIACTIONFORMATA lpdiaf,
+						     LPCSTR lpszUserName,
+						     DWORD dwFlags)
+{
+    FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIACTIONFORMATW lpdiaf,
+						     LPCWSTR lpszUserName,
+						     DWORD dwFlags)
+{
+    FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
+						     LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
+{
+    FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
+    
+    return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
+{
+    FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
+    
+    return DI_OK;
+}

reactos/lib/dinput
device_private.h added at 1.1.2.1
diff -N device_private.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ device_private.h	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2000 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
+#define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+
+/* Device implementation */
+typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
+struct IDirectInputDevice2AImpl
+{
+        IDirectInputDevice2AVtbl       *lpVtbl;
+        DWORD                           ref;
+        GUID                            guid;
+};
+
+/* Routines to do DataFormat / WineFormat conversions */
+typedef struct {
+  int size;
+  int offset_in;
+  int offset_out;
+  int value;
+} DataTransform;
+
+typedef struct {
+  int size;
+  int internal_format_size;
+  DataTransform *dt;
+} DataFormat;
+extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ;
+extern DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) ;
+extern void release_DataFormat(DataFormat *df) ;
+
+/* Used to fill events in the queue */
+#define GEN_EVENT(offset,data,xtime,seq)					\
+{										\
+  /* If queue_len > 0, queuing is requested -> TRACE the event queued */	\
+  if (This->queue_len > 0) {							\
+    int nq;									\
+    TRACE(" queueing %d at offset %d (queue head %d / size %d)\n", 		\
+	  (int) (data), (int) (offset),                           		\
+	  (int) (This->queue_head), (int) (This->queue_len));			\
+										\
+    nq = This->queue_head+1;							\
+    while (nq >= This->queue_len) nq -= This->queue_len;			\
+    if ((offset >= 0) && (nq != This->queue_tail)) {				\
+      This->data_queue[This->queue_head].dwOfs = offset;			\
+      This->data_queue[This->queue_head].dwData = data;				\
+      This->data_queue[This->queue_head].dwTimeStamp = xtime;			\
+      This->data_queue[This->queue_head].dwSequence = seq;			\
+      This->queue_head = nq;							\
+    } else                                                                      \
+      This->overflow = TRUE;                                                    \
+  }										\
+}
+
+/**
+ * Callback Data used by specific callback 
+ *  for EnumObject on 'W' interfaces
+ */
+typedef struct {
+  LPDIENUMDEVICEOBJECTSCALLBACKW lpCallBack;
+  LPVOID lpvRef;
+} device_enumobjects_AtoWcb_data;
+
+extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);
+
+
+/* Various debug tools */
+extern void _dump_cooperativelevel_DI(DWORD dwFlags) ;
+extern void _dump_EnumObjects_flags(DWORD dwFlags) ;
+extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) ;
+extern void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) ;
+extern void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) ;
+extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) ;
+extern const char *_dump_dinput_GUID(const GUID *guid) ;
+
+/* And the stubs */
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
+	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df ) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
+	LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags ) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
+	LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
+extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
+extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
+extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
+	LPDIRECTINPUTDEVICE8A iface) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
+	LPDIRECTINPUTDEVICE8A iface,
+	REFGUID rguid,
+	LPDIPROPHEADER pdiph) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEOBJECTINSTANCEA pdidoi,
+	DWORD dwObj,
+	DWORD dwHow) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, 
+							     LPDIDEVICEOBJECTINSTANCEW pdidoi,
+							     DWORD dwObj,
+							     DWORD dwHow);
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEINSTANCEA pdidi) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEINSTANCEW pdidi) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
+	LPDIRECTINPUTDEVICE8A iface,
+	HWND hwndOwner,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
+	LPDIRECTINPUTDEVICE8A iface,
+	HINSTANCE hinst,
+	DWORD dwVersion,
+	REFGUID rguid) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
+	LPDIRECTINPUTDEVICE8A iface,
+	REFGUID rguid,
+	LPCDIEFFECT lpeff,
+	LPDIRECTINPUTEFFECT *ppdef,
+	LPUNKNOWN pUnkOuter) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMEFFECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMEFFECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIEFFECTINFOA lpdei,
+	REFGUID rguid) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIEFFECTINFOW lpdei,
+	REFGUID rguid) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDWORD pdwOut) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
+	LPDIRECTINPUTDEVICE8A iface,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIEFFESCAPE lpDIEEsc) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
+	LPDIRECTINPUTDEVICE8A iface) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
+	LPDIRECTINPUTDEVICE8A iface,
+	DWORD cbObjectData,
+	LPCDIDEVICEOBJECTDATA rgdod,
+	LPDWORD pdwInOut,
+	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
+								 LPCSTR lpszFileName,
+								 LPDIENUMEFFECTSINFILECALLBACK pec,
+								 LPVOID pvRef,
+								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
+								 LPCWSTR lpszFileName,
+								 LPDIENUMEFFECTSINFILECALLBACK pec,
+								 LPVOID pvRef,
+								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
+								 LPCSTR lpszFileName,
+								 DWORD dwEntries,
+								 LPDIFILEEFFECT rgDiFileEft,
+								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
+								 LPCWSTR lpszFileName,
+								 DWORD dwEntries,
+								 LPDIFILEEFFECT rgDiFileEft,
+								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
+							      LPDIACTIONFORMATA lpdiaf,
+							      LPCSTR lpszUserName,
+							      DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+							      LPDIACTIONFORMATW lpdiaf,
+							      LPCWSTR lpszUserName,
+							      DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
+							    LPDIACTIONFORMATA lpdiaf,
+							    LPCSTR lpszUserName,
+							    DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+							    LPDIACTIONFORMATW lpdiaf,
+							    LPCWSTR lpszUserName,
+							    DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
+							    LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
+							    LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
+
+#endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */

reactos/lib/dinput
dinput.spec added at 1.1.2.1
diff -N dinput.spec
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dinput.spec	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,7 @@
+@ stdcall DirectInputCreateA(long long ptr ptr)
+@ stdcall DirectInputCreateW(long long ptr ptr)
+@ stdcall DirectInputCreateEx(long long ptr ptr ptr)
+@ stdcall -private DllCanUnloadNow() DINPUT_DllCanUnloadNow
+@ stdcall -private DllGetClassObject(ptr ptr ptr) DINPUT_DllGetClassObject
+@ stdcall -private DllRegisterServer() DINPUT_DllRegisterServer
+@ stdcall -private DllUnregisterServer() DINPUT_DllUnregisterServer

reactos/lib/dinput
dinput.stubs.c added at 1.1.2.1
diff -N dinput.stubs.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dinput.stubs.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,3 @@
+/* File generated automatically from dinput.spec; do not edit! */
+/* This file can be copied, modified and distributed without restriction. */
+

reactos/lib/dinput
dinput_main.c added at 1.1.2.1
diff -N dinput_main.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dinput_main.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,756 @@
+/*		DirectInput
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2002 TransGaming Technologies Inc.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* Status:
+ *
+ * - Tomb Raider 2 Demo:
+ *   Playable using keyboard only.
+ * - WingCommander Prophecy Demo:
+ *   Doesn't get Input Focus.
+ *
+ * - Fallout : works great in X and DGA mode
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+
+#define COBJMACROS
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "dinput_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+static IDirectInput7AVtbl ddi7avt;
+static IDirectInput7WVtbl ddi7wvt;
+static IDirectInput8AVtbl ddi8avt;
+static IDirectInput8WVtbl ddi8wvt;
+
+/* This array will be filled a dinput.so loading */
+#define MAX_WINE_DINPUT_DEVICES 4
+static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
+static int nrof_dinput_devices = 0;
+
+HINSTANCE DINPUT_instance = NULL;
+
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
+{
+    switch(reason)
+    {
+      case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(inst);
+        DINPUT_instance = inst;
+        break;
+      case DLL_PROCESS_DETACH:
+        break;
+    }
+    return TRUE;
+}
+
+/* register a direct draw driver. We better not use malloc for we are in
+ * the ELF startup initialisation at this point.
+ */
+void dinput_register_device(dinput_device *device) {
+    int	i;
+
+    /* insert according to priority */
+    for (i=0;i<nrof_dinput_devices;i++) {
+	if (dinput_devices[i]->pref <= device->pref) {
+	    memcpy(dinput_devices+i+1,dinput_devices+i,sizeof(dinput_devices[0])*(nrof_dinput_devices-i));
+	    dinput_devices[i] = device;
+	    break;
+	}
+    }
+    if (i==nrof_dinput_devices)	/* not found, or too low priority */
+	dinput_devices[nrof_dinput_devices] = device;
+
+    nrof_dinput_devices++;
+
+    /* increase MAX_DDRAW_DRIVERS if the line below triggers */
+    assert(nrof_dinput_devices <= MAX_WINE_DINPUT_DEVICES);
+}
+
+/******************************************************************************
+ *	DirectInputCreateEx (DINPUT.@)
+ */
+HRESULT WINAPI DirectInputCreateEx(
+	HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
+	LPUNKNOWN punkOuter) 
+{
+	IDirectInputImpl* This;
+
+	TRACE("(0x%08lx,%04lx,%s,%p,%p)\n", (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter);
+
+	if (IsEqualGUID(&IID_IDirectInputA,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi7avt;
+	  This->ref = 1;
+	  This->version = 1;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
+	if (IsEqualGUID(&IID_IDirectInputW,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2W,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7W,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi7wvt;
+	  This->ref = 1;
+	  This->version = 1;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
+	if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi8avt;
+	  This->ref = 1;
+	  This->version = 8;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
+	if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi8wvt;
+	  This->ref = 1;
+	  This->version = 8;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
+	return DIERR_OLDDIRECTINPUTVERSION;
+}
+
+/******************************************************************************
+ *	DirectInputCreateA (DINPUT.@)
+ */
+HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
+{
+	IDirectInputImpl* This;
+	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
+
+	//trace:dinput:DirectInputCreateA (0x00400000,0500,0x42bafc54,(nil))
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	This->lpVtbl = &ddi7avt;
+	This->ref = 1;
+	if (dwVersion > 0x0700) {
+	    This->version = 8;
+	} else {
+	    /* We do not differientiate between version 1, 2 and 7 */
+	    This->version = 1;
+	}
+	*ppDI = (IDirectInputA*)This;
+	return 0;
+
+}
+
+/******************************************************************************
+ *	DirectInputCreateW (DINPUT.@)
+ */
+HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
+{
+	IDirectInputImpl* This;
+	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	This->lpVtbl = &ddi7wvt;
+	This->ref = 1;
+	if (dwVersion >= 0x0800) {
+	    This->version = 8;
+	} else {
+	    /* We do not differientiate between version 1, 2 and 7 */
+	    This->version = 1;
+	}
+	*ppDI = (IDirectInputW*)This;
+	return 0;
+}
+
+static char *_dump_DIDEVTYPE_value(DWORD dwDevType) {
+    switch (dwDevType) {
+        case 0: return "All devices";
+	case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE";
+	case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD";
+	case DIDEVTYPE_JOYSTICK: return "DIDEVTYPE_JOYSTICK";
+	case DIDEVTYPE_DEVICE: return "DIDEVTYPE_DEVICE";
+	default: return "Unkown";
+    }
+}
+
+static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
+    if (TRACE_ON(dinput)) {
+	unsigned int   i;
+	static const struct {
+	    DWORD       mask;
+	    const char  *name;
+	} flags[] = {
+#define FE(x) { x, #x}
+	    FE(DIEDFL_ALLDEVICES),
+	    FE(DIEDFL_ATTACHEDONLY),
+	    FE(DIEDFL_FORCEFEEDBACK),
+	    FE(DIEDFL_INCLUDEALIASES),
+	    FE(DIEDFL_INCLUDEPHANTOMS)
+#undef FE
+	};
+	if (dwFlags == 0) {
+	    DPRINTF("DIEDFL_ALLDEVICES");
+	    return;
+	}
+	for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
+	    if (flags[i].mask & dwFlags)
+		DPRINTF("%s ",flags[i].name);
+    }
+}
+
+/******************************************************************************
+ *	IDirectInputA_EnumDevices
+ */
+static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
+	LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
+	LPVOID pvRef, DWORD dwFlags)
+{
+    IDirectInputImpl *This = (IDirectInputImpl *)iface;
+    DIDEVICEINSTANCEA devInstance;
+    int i, j, r;
+    
+    TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
+	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
+	  lpCallback, pvRef, dwFlags);
+
+	if (nrof_dinput_devices==0){
+	  scan_mouse();
+	  scan_keyboard();
+	}
+	
+    TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
+    
+
+    for (i = 0; i < nrof_dinput_devices; i++) {
+        for (j = 0, r = -1; r != 0; j++) {
+	    devInstance.dwSize = sizeof(devInstance);
+	    TRACE("  - checking device %d ('%s')\n", i, dinput_devices[i]->name);
+		
+
+	    if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version, j))) {
+	        if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
+		    return 0;
+	    }
+	}
+    }
+    
+    return 0;
+}
+/******************************************************************************
+ *	IDirectInputW_EnumDevices
+ */
+static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
+	LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
+	LPVOID pvRef, DWORD dwFlags) 
+{
+    IDirectInputImpl *This = (IDirectInputImpl *)iface;
+    DIDEVICEINSTANCEW devInstance;
+    int i, j, r;
+    
+		if (nrof_dinput_devices==0){
+	  scan_mouse();
+	  scan_keyboard();
+	}
+
+    TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
+	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
+	  lpCallback, pvRef, dwFlags);
+    TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
+
+
+    for (i = 0; i < nrof_dinput_devices; i++) {
+        for (j = 0, r = -1; r != 0; j++) {
+	    devInstance.dwSize = sizeof(devInstance);
+	    TRACE("  - checking device %d ('%s')\n", i, dinput_devices[i]->name);
+	    if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version, j))) {
+	        if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
+		    return 0;
+	    }
+	}
+    }
+    
+    return 0;
+}
+
+static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
+{
+	IDirectInputImpl *This = (IDirectInputImpl *)iface;
+	return InterlockedIncrement((&This->ref));
+}
+
+static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
+{
+	IDirectInputImpl *This = (IDirectInputImpl *)iface;
+	ULONG ref;
+	ref = InterlockedDecrement(&(This->ref));
+	if (ref == 0)
+		HeapFree(GetProcessHeap(),0,This);
+	return ref;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) {
+	IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+	if (IsEqualGUID(&IID_IUnknown,riid) ||
+	    IsEqualGUID(&IID_IDirectInputA,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
+		IDirectInputAImpl_AddRef(iface);
+		*ppobj = This;
+		return 0;
+	}
+	TRACE("Unsupported interface !\n");
+	return E_FAIL;
+}
+
+static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) {
+	IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+	if (IsEqualGUID(&IID_IUnknown,riid) ||
+	    IsEqualGUID(&IID_IDirectInputW,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2W,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7W,riid)) {
+		IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
+		*ppobj = This;
+		return 0;
+	}
+	TRACE("Unsupported interface !\n");
+	return E_FAIL;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
+	LPDIRECTINPUT7A iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
+	LPUNKNOWN punk
+) {
+	IDirectInputImpl *This = (IDirectInputImpl *)iface;
+	HRESULT ret_value = DIERR_DEVICENOTREG;
+	int i;
+
+	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
+	
+	if (nrof_dinput_devices==0){
+	  scan_mouse();
+	  scan_keyboard();
+	}
+	
+	/* Loop on all the devices to see if anyone matches the given GUID */
+	for (i = 0; i < nrof_dinput_devices; i++) {
+	  HRESULT ret;
+	  if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
+	    return DI_OK;
+
+	  if (ret == DIERR_NOINTERFACE)
+	    ret_value = DIERR_NOINTERFACE;
+	}
+
+	return ret_value;
+}
+
+static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface, 
+						     REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) {
+        IDirectInputImpl *This = (IDirectInputImpl *)iface;
+	HRESULT ret_value = DIERR_DEVICENOTREG;
+	int i;
+    
+	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
+
+	if (nrof_dinput_devices==0){
+	  scan_mouse();
+	  scan_keyboard();
+	}
+	
+	/* Loop on all the devices to see if anyone matches the given GUID */
+	for (i = 0; i < nrof_dinput_devices; i++) {
+	  HRESULT ret;
+	  if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
+	    return DI_OK;
+
+	  if (ret == DIERR_NOINTERFACE)
+	    ret_value = DIERR_NOINTERFACE;
+	}
+
+	return ret_value;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
+	return DIERR_ALREADYINITIALIZED;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
+							REFGUID rguid) {
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+  FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
+
+  return DI_OK;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
+							HWND hwndOwner,
+							DWORD dwFlags) {
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+  FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
+
+  return DI_OK;
+}
+
+static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
+						    LPCSTR pszName, LPGUID pguidInstance) {
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+  FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
+
+  return DI_OK;
+}
+
+static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid,
+						    LPCWSTR pszName, LPGUID pguidInstance) {
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+  FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
+
+  return DI_OK;
+}
+
+static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
+							REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+{
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+  HRESULT ret_value = DIERR_DEVICENOTREG;
+  int i;
+
+  TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+
+  if (nrof_dinput_devices==0){
+    scan_mouse();
+    scan_keyboard();
+  }  
+
+  /* Loop on all the devices to see if anyone matches the given GUID */
+  for (i = 0; i < nrof_dinput_devices; i++) {
+    HRESULT ret;
+    if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
+      return DI_OK;
+
+    if (ret == DIERR_NOINTERFACE)
+      ret_value = DIERR_NOINTERFACE;
+  }
+
+  return ret_value;
+}
+
+static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
+							REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+{
+  IDirectInputImpl *This = (IDirectInputImpl *)iface;
+  HRESULT ret_value = DIERR_DEVICENOTREG;
+  int i;
+
+  TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+
+  	if (nrof_dinput_devices==0){
+	  scan_mouse();
+	  scan_keyboard();
+	}
+  
+
+
+  /* Loop on all the devices to see if anyone matches the given GUID */
+  for (i = 0; i < nrof_dinput_devices; i++) {
+    HRESULT ret;
+    if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
+      return DI_OK;
+
+    if (ret == DIERR_NOINTERFACE)
+      ret_value = DIERR_NOINTERFACE;
+  }
+
+  return ret_value;
+}
+
+static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+      if (IsEqualGUID(&IID_IUnknown,riid) ||
+          IsEqualGUID(&IID_IDirectInput8A,riid)) {
+              IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
+              *ppobj = This;
+              return 0;
+      }
+      TRACE("Unsupported interface !\n");
+      return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+      if (IsEqualGUID(&IID_IUnknown,riid) ||
+          IsEqualGUID(&IID_IDirectInput8W,riid)) {
+              IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
+              *ppobj = This;
+              return 0;
+      }
+      TRACE("Unsupported interface !\n");
+      return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
+      LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat,
+      LPDIENUMDEVICESBYSEMANTICSCBA lpCallback,
+      LPVOID pvRef, DWORD dwFlags
+)
+{
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
+            lpCallback, pvRef, dwFlags);
+      return 0;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
+      LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
+      LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
+      LPVOID pvRef, DWORD dwFlags
+)
+{
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
+            lpCallback, pvRef, dwFlags);
+      return 0;
+}
+
+static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
+      LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+      LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
+)
+{
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
+            dwFlags, pvRefData);
+      return 0;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
+      LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+      LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
+)
+{
+      IDirectInputImpl *This = (IDirectInputImpl *)iface;
+
+      FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
+            dwFlags, pvRefData);
+      return 0;
+}
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)   (typeof(ddi7avt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static IDirectInput7AVtbl ddi7avt = {
+	XCAST(QueryInterface)IDirectInputAImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
+	XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
+};
+
+#undef XCAST
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)   (typeof(ddi7wvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static IDirectInput7WVtbl ddi7wvt = {
+	XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
+	XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
+};
+#undef XCAST
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(ddi8avt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static IDirectInput8AVtbl ddi8avt = {
+	XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
+	XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
+	XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
+};
+#undef XCAST
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(ddi8wvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+static IDirectInput8WVtbl ddi8wvt = {
+	XCAST(QueryInterface)IDirectInput8WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
+	XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
+	XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
+};
+#undef XCAST
+
+/*******************************************************************************
+ * DirectInput ClassFactory
+ */
+typedef struct
+{
+    /* IUnknown fields */
+    IClassFactoryVtbl          *lpVtbl;
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+	return InterlockedIncrement(&(This->ref));
+}
+
+static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+	/* static class, won't be  freed */
+	return InterlockedDecrement(&(This->ref));
+}
+
+static HRESULT WINAPI DICF_CreateInstance(
+	LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
+) {
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+
+	TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+	if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
+	     IsEqualGUID( &IID_IDirectInputW, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput2A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput2W, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput7A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput7W, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput8A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
+		/* FIXME: reuse already created dinput if present? */
+		return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
+	}
+
+	FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);	
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+	FIXME("(%p)->(%d),stub!\n",This,dolock);
+	return S_OK;
+}
+
+static IClassFactoryVtbl DICF_Vtbl = {
+	DICF_QueryInterface,
+	DICF_AddRef,
+	DICF_Release,
+	DICF_CreateInstance,
+	DICF_LockServer
+};
+static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
+
+/***********************************************************************
+ *		DllCanUnloadNow (DINPUT.@)
+ */
+HRESULT WINAPI DINPUT_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+/***********************************************************************
+ *		DllGetClassObject (DINPUT.@)
+ */
+HRESULT WINAPI DINPUT_DllGetClassObject(REFCLSID rclsid, REFIID riid,
+					LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
+    	*ppv = (LPVOID)&DINPUT_CF;
+	IClassFactory_AddRef((IClassFactory*)*ppv);
+    return S_OK;
+    }
+
+    FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}

reactos/lib/dinput
dinput_private.h added at 1.1.2.1
diff -N dinput_private.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dinput_private.h	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000 Lionel Ulmer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H
+#define __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+
+/* Implementation specification */
+typedef struct IDirectInputImpl IDirectInputImpl;
+struct IDirectInputImpl
+{
+   LPVOID lpVtbl;
+   DWORD  ref;
+
+   /* Used to have an unique sequence number for all the events */
+   DWORD evsequence;
+
+   int version;
+};
+
+/* Function called by all devices that Wine supports */
+typedef struct dinput_device {
+    INT pref;
+    const char *name;
+    BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id);
+    BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id);
+    HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
+    HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
+} dinput_device;
+
+extern void dinput_register_device(dinput_device *device);
+
+extern HINSTANCE DINPUT_instance;
+
+void scan_keyboard();
+void scan_mouse();
+
+#endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */

reactos/lib/dinput
joystick_linux.c added at 1.1.2.1
diff -N joystick_linux.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ joystick_linux.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,1715 @@
+/*		DirectInput Joystick device
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * To Do:
+ *	dead zone
+ *	force feedback
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifdef HAVE_LINUX_22_JOYSTICK_API
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <sys/fcntl.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#include <errno.h>
+#ifdef HAVE_SYS_ERRNO_H
+# include <sys/errno.h>
+#endif
+#ifdef HAVE_LINUX_IOCTL_H
+# include <linux/ioctl.h>
+#endif
+#ifdef HAVE_LINUX_JOYSTICK_H
+# include <linux/joystick.h>
+#endif
+#define JOYDEV	"/dev/js"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+typedef struct {
+    LONG lMin;
+    LONG lMax;
+    LONG lDeadZone;
+    LONG lSaturation;
+} ObjProps;
+
+typedef struct {
+    LONG lX;
+    LONG lY;
+} POV;
+
+typedef struct JoystickImpl JoystickImpl;
+static IDirectInputDevice8AVtbl JoystickAvt;
+static IDirectInputDevice8WVtbl JoystickWvt;
+struct JoystickImpl
+{
+        LPVOID                          lpVtbl;
+        DWORD                           ref;
+        GUID                            guid;
+	char				dev[32];
+
+	/* The 'parent' DInput */
+	IDirectInputImpl               *dinput;
+
+	/* joystick private */
+	int				joyfd;
+	DIJOYSTATE2			js;		/* wine data */
+	LPDIDATAFORMAT			user_df;	/* user defined format */
+	DataFormat			*transform;	/* wine to user format converter */
+	int				*offsets;	/* object offsets */
+	ObjProps			*props;
+        HANDLE				hEvent;
+        LPDIDEVICEOBJECTDATA 		data_queue;
+        int				queue_head, queue_tail, queue_len;
+	BOOL				acquired;
+	char				*name;
+	DIDEVCAPS			devcaps;
+	LONG				deadzone;
+	int				*axis_map;
+	int				axes;
+	int				buttons;
+	POV				povs[4];
+	CRITICAL_SECTION		crit;
+	BOOL				overflow;
+};
+
+static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
+  0x9e573ed9,
+  0x7734,
+  0x11d2,
+  {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
+};
+
+static void _dump_DIDEVCAPS(LPDIDEVCAPS lpDIDevCaps)
+{
+    TRACE("dwSize: %ld\n", lpDIDevCaps->dwSize);
+    TRACE("dwFlags: %08lx\n",lpDIDevCaps->dwFlags);
+    TRACE("dwDevType: %08lx %s\n", lpDIDevCaps->dwDevType,
+          lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
+          lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
+          lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
+          lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
+          lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
+          lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
+    TRACE("dwAxes: %ld\n",lpDIDevCaps->dwAxes);
+    TRACE("dwButtons: %ld\n",lpDIDevCaps->dwButtons);
+    TRACE("dwPOVs: %ld\n",lpDIDevCaps->dwPOVs);
+    if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
+        TRACE("dwFFSamplePeriod: %ld\n",lpDIDevCaps->dwFFSamplePeriod);
+        TRACE("dwFFMinTimeResolution: %ld\n",lpDIDevCaps->dwFFMinTimeResolution);
+        TRACE("dwFirmwareRevision: %ld\n",lpDIDevCaps->dwFirmwareRevision);
+        TRACE("dwHardwareRevision: %ld\n",lpDIDevCaps->dwHardwareRevision);
+        TRACE("dwFFDriverVersion: %ld\n",lpDIDevCaps->dwFFDriverVersion);
+    }
+}
+
+static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
+{
+    int fd = -1;
+    char dev[32];
+
+    if (dwFlags & DIEDFL_FORCEFEEDBACK) {
+        WARN("force feedback not supported\n");
+        return FALSE;
+    }
+
+    if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
+        /* check whether we have a joystick */
+        sprintf(dev, "%s%d", JOYDEV, id);
+        if ((fd = open(dev,O_RDONLY)) < 0) {
+            WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
+            return FALSE;
+        }
+
+        /* Return joystick */
+        lpddi->guidInstance = DInput_Wine_Joystick_GUID;
+        lpddi->guidInstance.Data3 = id;
+        lpddi->guidProduct = DInput_Wine_Joystick_GUID;
+        /* we only support traditional joysticks for now */
+        if (version >= 8)
+            lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+        else
+            lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+        sprintf(lpddi->tszInstanceName, "Joystick %d", id);
+#if defined(JSIOCGNAME)
+        if (ioctl(fd,JSIOCGNAME(sizeof(lpddi->tszProductName)),lpddi->tszProductName) < 0) {
+            WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", dev, strerror(errno));
+            strcpy(lpddi->tszProductName, "Wine Joystick");
+        }
+#else
+        strcpy(lpddi->tszProductName, "Wine Joystick");
+#endif
+
+        lpddi->guidFFDriver = GUID_NULL;
+        close(fd);
+        TRACE("Enumerating the linux Joystick device: %s (%s)\n", dev, lpddi->tszProductName);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
+{
+    int fd = -1;
+    char name[MAX_PATH];
+    char dev[32];
+    char friendly[32];
+
+    if (dwFlags & DIEDFL_FORCEFEEDBACK) {
+        WARN("force feedback not supported\n");
+        return FALSE;
+    }
+
+    if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
+        /* check whether we have a joystick */
+        sprintf(dev, "%s%d", JOYDEV, id);
+        if ((fd = open(dev,O_RDONLY)) < 0) {
+            WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
+            return FALSE;
+        }
+
+        /* Return joystick */
+        lpddi->guidInstance = DInput_Wine_Joystick_GUID;
+        lpddi->guidInstance.Data3 = id;
+        lpddi->guidProduct = DInput_Wine_Joystick_GUID;
+        /* we only support traditional joysticks for now */
+        if (version >= 8)
+            lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+        else
+            lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+        sprintf(friendly, "Joystick %d", id);
+        MultiByteToWideChar(CP_ACP, 0, friendly, -1, lpddi->tszInstanceName, MAX_PATH);
+#if defined(JSIOCGNAME)
+        if (ioctl(fd,JSIOCGNAME(sizeof(name)),name) < 0) {
+            WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", dev, strerror(errno));
+            strcpy(name, "Wine Joystick");
+        }
+#else
+        strcpy(name, "Wine Joystick");
+#endif
+        MultiByteToWideChar(CP_ACP, 0, name, -1, lpddi->tszProductName, MAX_PATH);
+        lpddi->guidFFDriver = GUID_NULL;
+        close(fd);
+        TRACE("Enumerating the linux Joystick device: %s (%s)\n",dev,name);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Get a config key from either the app-specific or the default config
+ */
+
+inline static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
+                                    char *buffer, DWORD size )
+{
+    if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, buffer, &size ))
+        return 0;
+
+    if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, buffer, &size ))
+        return 0;
+
+    return ERROR_FILE_NOT_FOUND;
+}
+
+/*
+ * Setup the dinput options.
+ */
+
+static HRESULT setup_dinput_options(JoystickImpl * device)
+{
+    char buffer[MAX_PATH+1];
+    HKEY hkey, appkey = 0;
+    DWORD len;
+
+    buffer[MAX_PATH]='\0';
+
+    if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\dinput", &hkey)) hkey = 0;
+
+    len = GetModuleFileNameA( 0, buffer, MAX_PATH );
+    if (len && len < MAX_PATH) {
+        HKEY tmpkey;
+
+        if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\AppDefaults", &tmpkey )) {
+           char appname[MAX_PATH+16];
+           char *p = strrchr( buffer, '\\' );
+           if (p!=NULL) {
+                   strcpy(appname,p+1);
+                   strcat(appname,"\\dinput");
+                   TRACE("appname = [%s] \n",appname);
+                   if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
+           }
+           RegCloseKey( tmpkey );
+        }
+    }
+
+    /* get options */
+
+    if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH )) {
+        device->deadzone = atoi(buffer);
+        TRACE("setting default deadzone to: \"%s\" %ld\n", buffer, device->deadzone);
+    }
+
+    if (!get_config_key( hkey, appkey, device->name, buffer, MAX_PATH )) {
+        int tokens = 0;
+        int axis = 0;
+        int pov = 0;
+        char *delim = ",";
+        char * ptr;
+        TRACE("\"%s\" = \"%s\"\n", device->name, buffer);
+
+        device->axis_map = HeapAlloc(GetProcessHeap(), 0, device->axes * sizeof(int));
+        if (device->axis_map == 0)
+            return DIERR_OUTOFMEMORY;
+
+        if ((ptr = strtok(buffer, delim)) != NULL) {
+            do {
+                if (strcmp(ptr, "X") == 0) {
+                    device->axis_map[tokens] = 0;
+                    axis++;
+                } else if (strcmp(ptr, "Y") == 0) {
+                    device->axis_map[tokens] = 1;
+                    axis++;
+                } else if (strcmp(ptr, "Z") == 0) {
+                    device->axis_map[tokens] = 2;
+                    axis++;
+                } else if (strcmp(ptr, "Rx") == 0) {
+                    device->axis_map[tokens] = 3;
+                    axis++;
+                } else if (strcmp(ptr, "Ry") == 0) {
+                    device->axis_map[tokens] = 4;
+                    axis++;
+                } else if (strcmp(ptr, "Rz") == 0) {
+                    device->axis_map[tokens] = 5;
+                    axis++;
+                } else if (strcmp(ptr, "Slider1") == 0) {
+                    device->axis_map[tokens] = 6;
+                    axis++;
+                } else if (strcmp(ptr, "Slider2") == 0) {
+                    device->axis_map[tokens] = 7;
+                    axis++;
+                } else if (strcmp(ptr, "POV1") == 0) {
+                    device->axis_map[tokens++] = 8;
+                    device->axis_map[tokens] = 8;
+                    pov++;
+                } else if (strcmp(ptr, "POV2") == 0) {
+                    device->axis_map[tokens++] = 9;
+                    device->axis_map[tokens] = 9;
+                    pov++;
+                } else if (strcmp(ptr, "POV3") == 0) {
+                    device->axis_map[tokens++] = 10;
+                    device->axis_map[tokens] = 10;
+                    pov++;
+                } else if (strcmp(ptr, "POV4") == 0) {
+                    device->axis_map[tokens++] = 11;
+                    device->axis_map[tokens] = 11;
+                    pov++;
+                } else {
+                    ERR("invalid joystick axis type: %s\n", ptr);
+                    device->axis_map[tokens] = tokens;
+                    axis++;
+                }
+
+                tokens++;
+            } while ((ptr = strtok(NULL, delim)) != NULL);
+
+            if (tokens != device->devcaps.dwAxes) {
+                ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", device->axes, axis, pov,tokens);
+                while (tokens < device->axes) {
+                    device->axis_map[tokens] = tokens;
+                    tokens++;
+                }
+            }
+        }
+
+        device->devcaps.dwAxes = axis;
+        device->devcaps.dwPOVs = pov;
+    }
+
+    if (appkey)
+        RegCloseKey( appkey );
+
+    if (hkey)
+        RegCloseKey( hkey );
+
+    return DI_OK;
+}
+
+void calculate_ids(JoystickImpl* device)
+{
+    int i;
+    int axis = 0;
+    int button = 0;
+    int pov = 0;
+    int axis_base;
+    int pov_base;
+    int button_base;
+
+    /* Make two passes over the format. The first counts the number
+     * for each type and the second sets the id */
+    for (i = 0; i < device->user_df->dwNumObjs; i++) {
+        if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_AXIS)
+            axis++;
+        else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_POV)
+            pov++;
+        else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_BUTTON)
+            button++;
+    }
+
+    axis_base = 0;
+    pov_base = axis;
+    button_base = axis + pov;
+
+    axis = 0;
+    button = 0;
+    pov = 0;
+
+    for (i = 0; i < device->user_df->dwNumObjs; i++) {
+        DWORD type = 0;
+        if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_AXIS) {
+            axis++;
+            type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
+                DIDFT_MAKEINSTANCE(axis + axis_base);
+            TRACE("axis type = 0x%08lx\n", type);
+        } else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_POV) {
+            pov++;
+            type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
+                DIDFT_MAKEINSTANCE(pov + pov_base);
+            TRACE("POV type = 0x%08lx\n", type);
+        } else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_BUTTON) {
+            button++;
+            type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
+                DIDFT_MAKEINSTANCE(button + button_base);
+            TRACE("button type = 0x%08lx\n", type);
+        }
+        device->user_df->rgodf[i].dwType = type;
+    }
+}
+
+static HRESULT alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput, LPDIRECTINPUTDEVICEA* pdev)
+{
+    DWORD i;
+    JoystickImpl* newDevice;
+    char name[MAX_PATH];
+    HRESULT hr;
+
+    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
+    if (newDevice == 0) {
+        WARN("out of memory\n");
+        *pdev = 0;
+        return DIERR_OUTOFMEMORY;
+    }
+
+    sprintf(newDevice->dev, "%s%d", JOYDEV, rguid->Data3);
+
+    if ((newDevice->joyfd = open(newDevice->dev,O_RDONLY)) < 0) {
+        WARN("open(%s,O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno));
+        HeapFree(GetProcessHeap(), 0, newDevice);
+        return DIERR_DEVICENOTREG;
+    }
+
+    /* get the device name */
+#if defined(JSIOCGNAME)
+    if (ioctl(newDevice->joyfd,JSIOCGNAME(MAX_PATH),name) < 0) {
+        WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", newDevice->dev, strerror(errno));
+        strcpy(name, "Wine Joystick");
+    }
+#else
+    strcpy(name, "Wine Joystick");
+#endif
+
+    /* copy the device name */
+    newDevice->name = HeapAlloc(GetProcessHeap(),0,strlen(name) + 1);
+    strcpy(newDevice->name, name);
+
+#ifdef JSIOCGAXES
+    if (ioctl(newDevice->joyfd,JSIOCGAXES,&newDevice->axes) < 0) {
+        WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
+        newDevice->axes = 2;
+    }
+#endif
+#ifdef JSIOCGBUTTONS
+    if (ioctl(newDevice->joyfd,JSIOCGBUTTONS,&newDevice->buttons) < 0) {
+        WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
+        newDevice->buttons = 2;
+    }
+#endif
+
+    newDevice->lpVtbl = jvt;
+    newDevice->ref = 1;
+    newDevice->dinput = dinput;
+    newDevice->acquired = FALSE;
+    newDevice->overflow = FALSE;
+    CopyMemory(&(newDevice->guid),rguid,sizeof(*rguid));
+
+    /* setup_dinput_options may change these */
+    newDevice->deadzone = 5000;
+    newDevice->devcaps.dwButtons = newDevice->buttons;
+    newDevice->devcaps.dwAxes = newDevice->axes;
+    newDevice->devcaps.dwPOVs = 0;
+
+    /* do any user specified configuration */
+    hr = setup_dinput_options(newDevice);
+    if (hr != DI_OK)
+        goto FAILED1;
+
+    if (newDevice->axis_map == 0) {
+        newDevice->axis_map = HeapAlloc(GetProcessHeap(), 0, newDevice->axes * sizeof(int));
+        if (newDevice->axis_map == 0)
+            goto FAILED;
+
+        for (i = 0; i < newDevice->axes; i++)
+            newDevice->axis_map[i] = i;
+    }
+
+    /* wine uses DIJOYSTATE2 as it's internal format so copy
+     * the already defined format c_dfDIJoystick2 */
+    newDevice->user_df = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwSize);
+    if (newDevice->user_df == 0)
+        goto FAILED;
+
+    CopyMemory(newDevice->user_df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
+
+    /* copy default objects */
+    newDevice->user_df->rgodf = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
+    if (newDevice->user_df->rgodf == 0)
+        goto FAILED;
+
+    CopyMemory(newDevice->user_df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
+
+    /* create default properties */
+    newDevice->props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps));
+    if (newDevice->props == 0)
+        goto FAILED;
+
+    /* initialize default properties */
+    for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) {
+        newDevice->props[i].lMin = 0;
+        newDevice->props[i].lMax = 0xffff;
+        newDevice->props[i].lDeadZone = newDevice->deadzone;	/* % * 1000 */
+        newDevice->props[i].lSaturation = 0;
+    }
+
+    /* create an offsets array */
+    newDevice->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,c_dfDIJoystick2.dwNumObjs*sizeof(int));
+    if (newDevice->offsets == 0)
+        goto FAILED;
+
+    /* create the default transform filter */
+    newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->user_df, newDevice->offsets);
+
+    calculate_ids(newDevice);
+
+    IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
+    InitializeCriticalSection(&(newDevice->crit));
+    newDevice->crit.DebugInfo->Spare[1] = (DWORD)"DINPUT_Mouse";
+
+    newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
+    newDevice->devcaps.dwFlags = DIDC_ATTACHED;
+    newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK;
+    newDevice->devcaps.dwFFSamplePeriod = 0;
+    newDevice->devcaps.dwFFMinTimeResolution = 0;
+    newDevice->devcaps.dwFirmwareRevision = 0;
+    newDevice->devcaps.dwHardwareRevision = 0;
+    newDevice->devcaps.dwFFDriverVersion = 0;
+
+    if (TRACE_ON(dinput)) {
+        _dump_DIDATAFORMAT(newDevice->user_df);
+       for (i = 0; i < (newDevice->axes); i++)
+           TRACE("axis_map[%ld] = %d\n", i, newDevice->axis_map[i]);
+        _dump_DIDEVCAPS(&newDevice->devcaps);
+    }
+
+    *pdev = (LPDIRECTINPUTDEVICEA)newDevice;
+
+    return DI_OK;
+
+FAILED:
+    hr = DIERR_OUTOFMEMORY;
+FAILED1:
+    if (newDevice->axis_map)
+        HeapFree(GetProcessHeap(),0,newDevice->axis_map);
+    if (newDevice->name)
+        HeapFree(GetProcessHeap(),0,newDevice->name);
+    if (newDevice->props)
+        HeapFree(GetProcessHeap(),0,newDevice->props);
+    if (newDevice->user_df->rgodf)
+        HeapFree(GetProcessHeap(),0,newDevice->user_df->rgodf);
+    if (newDevice->user_df)
+        HeapFree(GetProcessHeap(),0,newDevice->user_df);
+    if (newDevice)
+        HeapFree(GetProcessHeap(),0,newDevice);
+    *pdev = 0;
+
+    return hr;
+}
+
+static BOOL IsJoystickGUID(REFGUID guid)
+{
+    GUID wine_joystick = DInput_Wine_Joystick_GUID;
+    GUID dev_guid = *guid;
+
+    wine_joystick.Data3 = 0;
+    dev_guid.Data3 = 0;
+
+    return IsEqualGUID(&wine_joystick, &dev_guid);
+}
+
+static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+{
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsJoystickGUID(rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+      return alloc_device(rguid, &JoystickAvt, dinput, pdev);
+    } else {
+      WARN("no interface\n");
+      *pdev = 0;
+      return DIERR_NOINTERFACE;
+    }
+  }
+
+  WARN("invalid device GUID\n");
+  *pdev = 0;
+  return DIERR_DEVICENOTREG;
+}
+
+static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsJoystickGUID(rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev);
+    } else {
+      WARN("no interface\n");
+      *pdev = 0;
+      return DIERR_NOINTERFACE;
+    }
+  }
+
+  WARN("invalid device GUID\n");
+  *pdev = 0;
+  return DIERR_DEVICENOTREG;
+}
+
+static dinput_device joydev = {
+  10,
+  "Wine Linux joystick driver",
+  joydev_enum_deviceA,
+  joydev_enum_deviceW,
+  joydev_create_deviceA,
+  joydev_create_deviceW
+};
+
+DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
+
+
+
+/******************************************************************************
+ *	Joystick
+ */
+static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+    ULONG ref;
+
+    ref = InterlockedDecrement((&This->ref));
+    if (ref)
+        return ref;
+
+    /* Free the device name */
+    if (This->name)
+        HeapFree(GetProcessHeap(),0,This->name);
+
+    /* Free the axis map */
+    if (This->axis_map)
+        HeapFree(GetProcessHeap(),0,This->axis_map);
+
+    /* Free the data queue */
+    if (This->data_queue != NULL)
+        HeapFree(GetProcessHeap(),0,This->data_queue);
+
+    /* Free the DataFormat */
+    HeapFree(GetProcessHeap(), 0, This->user_df->rgodf);
+    HeapFree(GetProcessHeap(), 0, This->user_df);
+
+    /* Free the properties */
+    HeapFree(GetProcessHeap(), 0, This->props);
+
+    /* Free the offsets array */
+    HeapFree(GetProcessHeap(),0,This->offsets);
+
+    /* release the data transform filter */
+    release_DataFormat(This->transform);
+
+    This->crit.DebugInfo->Spare[1] = 0;
+    DeleteCriticalSection(&(This->crit));
+    IDirectInputDevice_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
+
+    HeapFree(GetProcessHeap(),0,This);
+    return 0;
+}
+
+/******************************************************************************
+  *   SetDataFormat : the application can choose the format of the data
+  *   the device driver sends back with GetDeviceState.
+  */
+static HRESULT WINAPI JoystickAImpl_SetDataFormat(
+    LPDIRECTINPUTDEVICE8A iface,
+    LPCDIDATAFORMAT df)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+    unsigned int i;
+    LPDIDATAFORMAT new_df = 0;
+    LPDIOBJECTDATAFORMAT new_rgodf = 0;
+    ObjProps * new_props = 0;
+
+    TRACE("(%p,%p)\n",This,df);
+
+    if (This->acquired) {
+        WARN("acquired\n");
+        return DIERR_ACQUIRED;
+    }
+
+    if (TRACE_ON(dinput))
+        _dump_DIDATAFORMAT(df);
+
+    /* Store the new data format */
+    new_df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
+    if (new_df == 0)
+        goto FAILED;
+
+    new_rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
+    if (new_rgodf == 0)
+        goto FAILED;
+
+    new_props = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*sizeof(ObjProps));
+    if (new_props == 0)
+        goto FAILED;
+
+    HeapFree(GetProcessHeap(),0,This->user_df);
+    HeapFree(GetProcessHeap(),0,This->user_df->rgodf);
+    HeapFree(GetProcessHeap(),0,This->props);
+    release_DataFormat(This->transform);
+
+    This->user_df = new_df;
+    CopyMemory(This->user_df, df, df->dwSize);
+    This->user_df->rgodf = new_rgodf;
+    CopyMemory(This->user_df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
+    This->props = new_props;
+    for (i = 0; i < df->dwNumObjs; i++) {
+        This->props[i].lMin = 0;
+        This->props[i].lMax = 0xffff;
+        This->props[i].lDeadZone = 1000;
+        This->props[i].lSaturation = 0;
+    }
+    This->transform = create_DataFormat(&c_dfDIJoystick2, This->user_df, This->offsets);
+
+    calculate_ids(This);
+
+    return DI_OK;
+
+FAILED:
+    WARN("out of memory\n");
+    if (new_props)
+        HeapFree(GetProcessHeap(),0,new_props);
+    if (new_rgodf)
+        HeapFree(GetProcessHeap(),0,new_rgodf);
+    if (new_df)
+        HeapFree(GetProcessHeap(),0,new_df);
+    return DIERR_OUTOFMEMORY;
+}
+
+/******************************************************************************
+  *     Acquire : gets exclusive control of the joystick
+  */
+static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+
+    TRACE("(%p)\n",This);
+
+    if (This->acquired) {
+        WARN("already acquired\n");
+        return S_FALSE;
+    }
+
+    /* open the joystick device */
+    if (This->joyfd==-1) {
+        TRACE("opening joystick device %s\n", This->dev);
+
+        This->joyfd=open(This->dev,O_RDONLY);
+        if (This->joyfd==-1) {
+            ERR("open(%s) failed: %s\n", This->dev, strerror(errno));
+            return DIERR_NOTFOUND;
+        }
+    }
+
+    This->acquired = TRUE;
+
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     Unacquire : frees the joystick
+  */
+static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+
+    TRACE("(%p)\n",This);
+
+    if (!This->acquired) {
+        WARN("not acquired\n");
+        return DIERR_NOTACQUIRED;
+    }
+
+    if (This->joyfd!=-1) {
+        TRACE("closing joystick device\n");
+        close(This->joyfd);
+        This->joyfd = -1;
+        This->acquired = FALSE;
+        return DI_OK;
+    }
+
+    This->acquired = FALSE;
+
+    return DI_NOEFFECT;
+}
+
+LONG map_axis(JoystickImpl * This, short val, short index)
+{
+    double    fval = val;
+    double    fmin = This->props[index].lMin;
+    double    fmax = This->props[index].lMax;
+    double    fret;
+
+    fret = (((fval + 32767.0) * (fmax - fmin)) / (32767.0*2.0)) + fmin;
+
+    if (fret >= 0.0)
+        fret += 0.5;
+    else
+        fret -= 0.5;
+
+    return fret;
+}
+
+/* convert wine format offset to user format object index */
+int offset_to_object(JoystickImpl *This, int offset)
+{
+    int i;
+
+    for (i = 0; i < This->user_df->dwNumObjs; i++) {
+        if (This->user_df->rgodf[i].dwOfs == offset)
+            return i;
+    }
+
+    return -1;
+}
+
+static LONG calculate_pov(JoystickImpl *This, int index)
+{
+    if (This->povs[index].lX < 16384) {
+        if (This->povs[index].lY < 16384)
+            This->js.rgdwPOV[index] = 31500;
+        else if (This->povs[index].lY > 49150)
+            This->js.rgdwPOV[index] = 22500;
+        else
+            This->js.rgdwPOV[index] = 27000;
+    } else if (This->povs[index].lX > 49150) {
+        if (This->povs[index].lY < 16384)
+            This->js.rgdwPOV[index] = 4500;
+        else if (This->povs[index].lY > 49150)
+            This->js.rgdwPOV[index] = 13500;
+        else
+            This->js.rgdwPOV[index] = 9000;
+    } else {
+        if (This->povs[index].lY < 16384)
+            This->js.rgdwPOV[index] = 0;
+        else if (This->povs[index].lY > 49150)
+            This->js.rgdwPOV[index] = 18000;
+        else
+            This->js.rgdwPOV[index] = -1;
+    }
+
+    return This->js.rgdwPOV[index];
+}
+
+static void joy_polldev(JoystickImpl *This) {
+    struct timeval tv;
+    fd_set	readfds;
+    struct	js_event jse;
+    TRACE("(%p)\n", This);
+
+    if (This->joyfd==-1) {
+        WARN("no device\n");
+        return;
+    }
+    while (1) {
+	memset(&tv,0,sizeof(tv));
+	FD_ZERO(&readfds);FD_SET(This->joyfd,&readfds);
+	if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
+	    return;
+	/* we have one event, so we can read */
+	if (sizeof(jse)!=read(This->joyfd,&jse,sizeof(jse))) {
+	    return;
+	}
+        TRACE("js_event: type 0x%x, number %d, value %d\n",
+              jse.type,jse.number,jse.value);
+        if (jse.type & JS_EVENT_BUTTON) {
+            int offset = This->offsets[jse.number + 12];
+            int value = jse.value?0x80:0x00;
+
+            This->js.rgbButtons[jse.number] = value;
+            GEN_EVENT(offset,value,jse.time,(This->dinput->evsequence)++);
+        } else if (jse.type & JS_EVENT_AXIS) {
+            int number = This->axis_map[jse.number];	/* wine format object index */
+            if (number < 12) {
+                int offset = This->offsets[number];
+                int index = offset_to_object(This, offset);
+                LONG value = map_axis(This, jse.value, index);
+
+                /* FIXME do deadzone and saturation here */
+
+                TRACE("changing axis %d => %d\n", jse.number, number);
+                switch (number) {
+                case 0:
+                    This->js.lX = value;
+                    break;
+                case 1:
+                    This->js.lY = value;
+                    break;
+                case 2:
+                    This->js.lZ = value;
+                    break;
+                case 3:
+                    This->js.lRx = value;
+                    break;
+                case 4:
+                    This->js.lRy = value;
+                    break;
+                case 5:
+                    This->js.lRz = value;
+                    break;
+                case 6:
+                    This->js.rglSlider[0] = value;
+                    break;
+                case 7:
+                    This->js.rglSlider[1] = value;
+                    break;
+                case 8:
+                    /* FIXME don't go off array */
+                    if (This->axis_map[jse.number + 1] == number)
+                        This->povs[0].lX = value;
+                    else if (This->axis_map[jse.number - 1] == number)
+                        This->povs[0].lY = value;
+                    value = calculate_pov(This, 0);
+                    break;
+                case 9:
+                    if (This->axis_map[jse.number + 1] == number)
+                        This->povs[1].lX = value;
+                    else if (This->axis_map[jse.number - 1] == number)
+                        This->povs[1].lY = value;
+                    value = calculate_pov(This, 1);
+                    break;
+                case 10:
+                    if (This->axis_map[jse.number + 1] == number)
+                        This->povs[2].lX = value;
+                    else if (This->axis_map[jse.number - 1] == number)
+                        This->povs[2].lY = value;
+                    value = calculate_pov(This, 2);
+                    break;
+                case 11:
+                    if (This->axis_map[jse.number + 1] == number)
+                        This->povs[3].lX = value;
+                    else if (This->axis_map[jse.number - 1] == number)
+                        This->povs[3].lY = value;
+                    value = calculate_pov(This, 3);
+                    break;
+                }
+
+                GEN_EVENT(offset,value,jse.time,(This->dinput->evsequence)++);
+            } else
+                WARN("axis %d not supported\n", number);
+        }
+    }
+}
+
+/******************************************************************************
+  *     GetDeviceState : returns the "state" of the joystick.
+  *
+  */
+static HRESULT WINAPI JoystickAImpl_GetDeviceState(
+    LPDIRECTINPUTDEVICE8A iface,
[truncated at 1000 lines; 719 more skipped]

reactos/lib/dinput
joystick_linuxinput.c added at 1.1.2.1
diff -N joystick_linuxinput.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ joystick_linuxinput.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,1090 @@
+/*		DirectInput Joystick device
+ *
+ * Copyright 1998,2000 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifdef HAVE_LINUX_INPUT_H
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <sys/fcntl.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#include <errno.h>
+#ifdef HAVE_SYS_ERRNO_H
+# include <sys/errno.h>
+#endif
+
+#ifdef HAVE_CORRECT_LINUXINPUT_H
+
+#ifdef HAVE_LINUX_INPUT_H
+# include <linux/input.h>
+#endif
+
+
+#define EVDEVPREFIX	"/dev/input/event"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+/* Wine joystick driver object instances */
+#define WINE_JOYSTICK_AXIS_BASE   0
+#define WINE_JOYSTICK_BUTTON_BASE 8
+
+typedef struct JoystickImpl JoystickImpl;
+static IDirectInputDevice8AVtbl JoystickAvt;
+static IDirectInputDevice8WVtbl JoystickWvt;
+struct JoystickImpl
+{
+        LPVOID                          lpVtbl;
+        DWORD                           ref;
+        GUID                            guid;
+
+
+	/* The 'parent' DInput */
+	IDirectInputImpl               *dinput;
+
+	/* joystick private */
+	/* what range and deadzone the game wants */
+	LONG				wantmin[ABS_MAX];
+	LONG				wantmax[ABS_MAX];
+	LONG				deadz[ABS_MAX];
+
+	/* autodetecting ranges per axe by following movement */
+	LONG				havemax[ABS_MAX];
+	LONG				havemin[ABS_MAX];
+
+	int				joyfd;
+
+	LPDIDATAFORMAT			df;
+        HANDLE				hEvent;
+        LPDIDEVICEOBJECTDATA 		data_queue;
+        int				queue_head, queue_tail, queue_len;
+	BOOL				overflow;
+	DIJOYSTATE2			js;
+
+	/* data returned by the EVIOCGABS() ioctl */
+	int				axes[ABS_MAX+1][5];
+
+#define AXE_ABS		0
+#define AXE_ABSMIN	1
+#define AXE_ABSMAX	2
+#define AXE_ABSFUZZ	3
+#define AXE_ABSFLAT	4
+
+
+	/* data returned by EVIOCGBIT for EV_ABS and EV_KEY */
+	BYTE				absbits[(ABS_MAX+7)/8];
+	BYTE				keybits[(KEY_MAX+7)/8];
+};
+
+/* This GUID is slightly different from the linux joystick one. Take note. */
+static GUID DInput_Wine_Joystick_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
+  0x9e573eda,
+  0x7734,
+  0x11d2,
+  {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
+};
+
+static void fake_current_js_state(JoystickImpl *ji);
+
+#define test_bit(arr,bit) (((BYTE*)arr)[bit>>3]&(1<<(bit&7)))
+
+static int joydev_have(void)
+{
+  int i, fd;
+  int havejoy = 0;
+
+  for (i=0;i<64;i++) {
+      char	buf[200];
+      BYTE	absbits[(ABS_MAX+7)/8],keybits[(KEY_MAX+7)/8];
+
+      sprintf(buf,EVDEVPREFIX"%d",i);
+      if (-1!=(fd=open(buf,O_RDONLY))) {
+	  if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(absbits)),absbits)) {
+	      perror("EVIOCGBIT EV_ABS");
+	      close(fd);
+	      continue;
+	  }
+	  if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(keybits)),keybits)) {
+	      perror("EVIOCGBIT EV_KEY");
+	      close(fd);
+	      continue;
+	  }
+	  /* A true joystick has at least axis X and Y, and at least 1
+	   * button. copied from linux/drivers/input/joydev.c */
+	  if (test_bit(absbits,ABS_X) && test_bit(absbits,ABS_Y) &&
+	      (   test_bit(keybits,BTN_TRIGGER)	||
+		  test_bit(keybits,BTN_A) 	||
+		  test_bit(keybits,BTN_1)
+	      )
+	  ) {
+	      FIXME("found a joystick at %s!\n",buf);
+	      havejoy = 1;
+	  }
+	  close(fd);
+      }
+      if (havejoy || (errno==ENODEV))
+	  break;
+  }
+  return havejoy;
+}
+
+static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
+{
+  int havejoy = 0;
+
+  if (id != 0)
+      return FALSE;
+
+  if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
+      return FALSE;
+
+  if (dwFlags & DIEDFL_FORCEFEEDBACK)
+    return FALSE;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return FALSE;
+
+  TRACE("Enumerating the linuxinput Joystick device\n");
+
+  /* Return joystick */
+  lpddi->guidInstance	= GUID_Joystick;
+  lpddi->guidProduct	= DInput_Wine_Joystick_GUID;
+
+  lpddi->guidFFDriver = GUID_NULL;
+  if (version >= 8)
+    lpddi->dwDevType    = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+  else
+    lpddi->dwDevType    = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+
+  strcpy(lpddi->tszInstanceName, "Joystick");
+  /* ioctl JSIOCGNAME(len) */
+  strcpy(lpddi->tszProductName,	"Wine Joystick");
+  return TRUE;
+}
+
+static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
+{
+  int havejoy = 0;
+
+  if (id != 0)
+      return FALSE;
+
+  if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
+      return FALSE;
+
+  if (dwFlags & DIEDFL_FORCEFEEDBACK)
+    return FALSE;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return FALSE;
+
+  TRACE("Enumerating the linuxinput Joystick device\n");
+
+  /* Return joystick */
+  lpddi->guidInstance	= GUID_Joystick;
+  lpddi->guidProduct	= DInput_Wine_Joystick_GUID;
+
+  lpddi->guidFFDriver = GUID_NULL;
+  lpddi->dwDevType    = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
+
+  MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
+  /* ioctl JSIOCGNAME(len) */
+  MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
+  return TRUE;
+}
+
+static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
+{
+  JoystickImpl* newDevice;
+  int i;
+
+  newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
+  newDevice->lpVtbl = jvt;
+  newDevice->ref = 1;
+  newDevice->joyfd = -1;
+  newDevice->dinput = dinput;
+  memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+  for (i=0;i<ABS_MAX;i++) {
+    newDevice->wantmin[i] = -32768;
+    newDevice->wantmax[i] =  32767;
+    /* TODO: 
+     * direct input defines a default for the deadzone somewhere; but as long
+     * as in map_axis the code for the dead zone is commented out its no
+     * problem
+     */
+    newDevice->deadz[i]   =  0;
+  }
+  fake_current_js_state(newDevice);
+  return newDevice;
+}
+
+static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+{
+  int havejoy = 0;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return DIERR_DEVICENOTREG;
+
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+      *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
+      TRACE("Creating a Joystick device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+
+  return DIERR_DEVICENOTREG;
+}
+
+
+static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  int havejoy = 0;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return DIERR_DEVICENOTREG;
+
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
+      TRACE("Creating a Joystick device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+
+  return DIERR_DEVICENOTREG;
+}
+
+static dinput_device joydev = {
+  20,
+  "Wine Linux-input joystick driver",
+  joydev_enum_deviceA,
+  joydev_enum_deviceW,
+  joydev_create_deviceA,
+  joydev_create_deviceW
+};
+
+DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
+
+/******************************************************************************
+ *	Joystick
+ */
+static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+	JoystickImpl *This = (JoystickImpl *)iface;
+	ULONG ref;
+
+	ref = InterlockedDecrement(&(This->ref));
+	if (ref)
+		return ref;
+
+	/* Free the data queue */
+	if (This->data_queue != NULL)
+	  HeapFree(GetProcessHeap(),0,This->data_queue);
+
+	/* Free the DataFormat */
+	HeapFree(GetProcessHeap(), 0, This->df);
+
+	HeapFree(GetProcessHeap(),0,This);
+	return 0;
+}
+
+/******************************************************************************
+  *   SetDataFormat : the application can choose the format of the data
+  *   the device driver sends back with GetDeviceState.
+  */
+static HRESULT WINAPI JoystickAImpl_SetDataFormat(
+	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
+)
+{
+  JoystickImpl *This = (JoystickImpl *)iface;
+
+  TRACE("(this=%p,%p)\n",This,df);
+
+  _dump_DIDATAFORMAT(df);
+  
+  /* Store the new data format */
+  This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
+  memcpy(This->df, df, df->dwSize);
+  This->df->rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
+  memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
+
+  return 0;
+}
+
+/******************************************************************************
+  *     Acquire : gets exclusive control of the joystick
+  */
+static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    int		i;
+    JoystickImpl *This = (JoystickImpl *)iface;
+    char	buf[200];
+
+    TRACE("(this=%p)\n",This);
+    if (This->joyfd!=-1)
+    	return 0;
+    for (i=0;i<64;i++) {
+      sprintf(buf,EVDEVPREFIX"%d",i);
+      if (-1==(This->joyfd=open(buf,O_RDONLY))) {
+	if (errno==ENODEV)
+	  return DIERR_NOTFOUND;
+	perror(buf);
+	continue;
+      }
+      if ((-1!=ioctl(This->joyfd,EVIOCGBIT(EV_ABS,sizeof(This->absbits)),This->absbits)) &&
+          (-1!=ioctl(This->joyfd,EVIOCGBIT(EV_KEY,sizeof(This->keybits)),This->keybits)) &&
+          (test_bit(This->absbits,ABS_X) && test_bit(This->absbits,ABS_Y) &&
+	   (test_bit(This->keybits,BTN_TRIGGER)||
+	    test_bit(This->keybits,BTN_A)	 ||
+	    test_bit(This->keybits,BTN_1)
+	  )
+	 )
+      )
+	break;
+      close(This->joyfd);
+      This->joyfd = -1;
+    }
+    if (This->joyfd==-1)
+    	return DIERR_NOTFOUND;
+
+    for (i=0;i<ABS_MAX;i++) {
+	if (test_bit(This->absbits,i)) {
+	  if (-1==ioctl(This->joyfd,EVIOCGABS(i),&(This->axes[i])))
+	    continue;
+	  FIXME("axe %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
+	      i,
+	      This->axes[i][AXE_ABS],
+	      This->axes[i][AXE_ABSMIN],
+	      This->axes[i][AXE_ABSMAX],
+	      This->axes[i][AXE_ABSFUZZ],
+	      This->axes[i][AXE_ABSFLAT]
+	  );
+	  This->havemin[i] = This->axes[i][AXE_ABSMIN];
+	  This->havemax[i] = This->axes[i][AXE_ABSMAX];
+	}
+    }
+    MESSAGE("\n");
+
+	fake_current_js_state(This);
+
+    return 0;
+}
+
+/******************************************************************************
+  *     Unacquire : frees the joystick
+  */
+static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+
+    TRACE("(this=%p)\n",This);
+    if (This->joyfd!=-1) {
+  	close(This->joyfd);
+	This->joyfd = -1;
+	return DI_OK;
+    }
+    else 
+    	return DI_NOEFFECT;
+}
+
+/*
+ * This maps the read value (from the input event) to a value in the
+ * 'wanted' range. It also autodetects the possible range of the axe and
+ * adapts values accordingly.
+ */
+static int
+map_axis(JoystickImpl* This, int axis, int val) {
+    int	xmin = This->axes[axis][AXE_ABSMIN];
+    int	xmax = This->axes[axis][AXE_ABSMAX];
+    int hmax = This->havemax[axis];
+    int hmin = This->havemin[axis];
+    int	wmin = This->wantmin[axis];
+    int	wmax = This->wantmax[axis];
+    int ret;
+
+    if (val > hmax) This->havemax[axis] = hmax = val;
+    if (val < hmin) This->havemin[axis] = hmin = val;
+
+    if (xmin == xmax) return val;
+
+    /* map the value from the hmin-hmax range into the wmin-wmax range */
+    ret = (val * (wmax-wmin)) / (hmax-hmin) + wmin;
+
+#if 0
+    /* deadzone doesn't work comfortably enough right now. needs more testing*/
+    if ((ret > -deadz/2 ) && (ret < deadz/2)) {
+        FIXME("%d in deadzone, return mid.\n",val);
+	return (wmax-wmin)/2+wmin;
+    }
+#endif
+    return ret;
+}
+
+/* 
+ * set the current state of the js device as it would be with the middle
+ * values on the axes
+ */
+static void fake_current_js_state(JoystickImpl *ji)
+{
+	ji->js.lX  = map_axis(ji, ABS_X,  ji->axes[ABS_X ][AXE_ABS]);
+	ji->js.lY  = map_axis(ji, ABS_Y,  ji->axes[ABS_Y ][AXE_ABS]);
+	ji->js.lZ  = map_axis(ji, ABS_Z,  ji->axes[ABS_Z ][AXE_ABS]);
+	ji->js.lRx = map_axis(ji, ABS_RX, ji->axes[ABS_RX][AXE_ABS]);
+	ji->js.lRy = map_axis(ji, ABS_RY, ji->axes[ABS_RY][AXE_ABS]);
+	ji->js.lRz = map_axis(ji, ABS_RZ, ji->axes[ABS_RZ][AXE_ABS]);
+}
+
+static void joy_polldev(JoystickImpl *This) {
+    struct timeval tv;
+    fd_set	readfds;
+    struct	input_event ie;
+
+    if (This->joyfd==-1)
+	return;
+
+    while (1) {
+	memset(&tv,0,sizeof(tv));
+	FD_ZERO(&readfds);
+	FD_SET(This->joyfd,&readfds);
+
+	if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
+	    return;
+
+	/* we have one event, so we can read */
+	if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
+	    return;
+
+	TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
+	switch (ie.type) {
+	case EV_KEY:	/* button */
+	    switch (ie.code) {
+	    case BTN_TRIGGER:	/* normal flight stick */
+	    case BTN_A:		/* gamepad */
+	    case BTN_1:		/* generic */
+		This->js.rgbButtons[0] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(0),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_THUMB:
+	    case BTN_B:
+	    case BTN_2:
+		This->js.rgbButtons[1] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(1),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_THUMB2:
+	    case BTN_C:
+	    case BTN_3:
+		This->js.rgbButtons[2] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(2),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_TOP:
+	    case BTN_X:
+	    case BTN_4:
+		This->js.rgbButtons[3] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(3),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_TOP2:
+	    case BTN_Y:
+	    case BTN_5:
+		This->js.rgbButtons[4] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(4),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_PINKIE:
+	    case BTN_Z:
+	    case BTN_6:
+		This->js.rgbButtons[5] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(5),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_BASE:
+	    case BTN_TL:
+	    case BTN_7:
+		This->js.rgbButtons[6] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(6),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_BASE2:
+	    case BTN_TR:
+	    case BTN_8:
+		This->js.rgbButtons[7] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(7),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_BASE3:
+	    case BTN_TL2:
+	    case BTN_9:
+		This->js.rgbButtons[8] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(8),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_BASE4:
+	    case BTN_TR2:
+		This->js.rgbButtons[9] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(9),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case BTN_BASE5:
+	    case BTN_SELECT:
+		This->js.rgbButtons[10] = ie.value?0x80:0x00;
+		GEN_EVENT(DIJOFS_BUTTON(10),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    default:
+		FIXME("unhandled joystick button %x, value %d\n",ie.code,ie.value);
+		break;
+	    }
+	    break;
+	case EV_ABS:
+	    switch (ie.code) {
+	    case ABS_X:
+		This->js.lX = map_axis(This,ABS_X,ie.value);
+		GEN_EVENT(DIJOFS_X,This->js.lX,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case ABS_Y:
+		This->js.lY = map_axis(This,ABS_Y,ie.value);
+		GEN_EVENT(DIJOFS_Y,This->js.lY,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case ABS_Z:
+		This->js.lZ = map_axis(This,ABS_Z,ie.value);
+		GEN_EVENT(DIJOFS_Z,This->js.lZ,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case ABS_RX:
+		This->js.lRx = map_axis(This,ABS_RX,ie.value);
+		GEN_EVENT(DIJOFS_RX,This->js.lRx,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case ABS_RY:
+		This->js.lRy = map_axis(This,ABS_RY,ie.value);
+		GEN_EVENT(DIJOFS_RY,This->js.lRy,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    case ABS_RZ:
+		This->js.lRz = map_axis(This,ABS_RZ,ie.value);
+		GEN_EVENT(DIJOFS_RZ,This->js.lRz,ie.time.tv_usec,(This->dinput->evsequence)++);
+		break;
+	    default:
+		FIXME("unhandled joystick axe event (code %d, value %d)\n",ie.code,ie.value);
+		break;
+	    }
+	    break;
+	default:
+	    FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code);
+	    break;
+	}
+    }
+}
+
+/******************************************************************************
+  *     GetDeviceState : returns the "state" of the joystick.
+  *
+  */
+static HRESULT WINAPI JoystickAImpl_GetDeviceState(
+	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
+) {
+    JoystickImpl *This = (JoystickImpl *)iface;
+
+    joy_polldev(This);
+
+    TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
+    if ((len != sizeof(DIJOYSTATE)) && (len != sizeof(DIJOYSTATE2))) {
+    	FIXME("len %ld is not sizeof(DIJOYSTATE) or DIJOYSTATE2, unsupported format.\n",len);
+	return E_FAIL;
+    }
+    memcpy(ptr,&(This->js),len);
+    This->queue_head = 0;
+    This->queue_tail = 0;
+    return 0;
+}
+
+/******************************************************************************
+  *     GetDeviceData : gets buffered input data.
+  */
+static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
+					      DWORD dodsize,
+					      LPDIDEVICEOBJECTDATA dod,
+					      LPDWORD entries,
+					      DWORD flags
+) {
+  JoystickImpl *This = (JoystickImpl *)iface;
+
+  FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
+
+  joy_polldev(This);
+  if (flags & DIGDD_PEEK)
+    FIXME("DIGDD_PEEK\n");
+
+  if (dod == NULL) {
+  } else {
+  }
+  return 0;
+}
+
+/******************************************************************************
+  *     SetProperty : change input device properties
+  */
+static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
+					    REFGUID rguid,
+					    LPCDIPROPHEADER ph)
+{
+  JoystickImpl *This = (JoystickImpl *)iface;
+
+  FIXME("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
+  FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
+
+  if (!HIWORD(rguid)) {
+    switch ((DWORD)rguid) {
+    case (DWORD) DIPROP_BUFFERSIZE: {
+      LPCDIPROPDWORD	pd = (LPCDIPROPDWORD)ph;
+
+      FIXME("buffersize = %ld\n",pd->dwData);
+      break;
+    }
+    case (DWORD)DIPROP_RANGE: {
+      LPCDIPROPRANGE	pr = (LPCDIPROPRANGE)ph;
+
+      FIXME("proprange(%ld,%ld)\n",pr->lMin,pr->lMax);
+      switch (ph->dwObj) {
+      case 0:	/* X */
+      case 4:	/* Y */
+      case 8:	/* Z */
+      case 12:  /* Rx */
+      case 16:  /* Ry */
+      case 20:  /* Rz */
+	  This->wantmin[ph->dwObj/4] = pr->lMin;
+	  This->wantmax[ph->dwObj/4] = pr->lMax;
+	  break;
+      default:
+	  FIXME("setting proprange %ld - %ld for dwObj %ld\n",pr->lMin,pr->lMax,ph->dwObj);
+      }
+      break;
+    }
+    case (DWORD)DIPROP_DEADZONE: {
+      LPCDIPROPDWORD	pd = (LPCDIPROPDWORD)ph;
+
+      FIXME("setting deadzone(%ld)\n",pd->dwData);
+      This->deadz[ph->dwObj/4] = pd->dwData;
+      break;
+    }
+    default:
+      FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
+      break;
+    }
+  }
+  fake_current_js_state(This);
+  return 0;
+}
+
+/******************************************************************************
+  *     SetEventNotification : specifies event to be sent on state change
+  */
+static HRESULT WINAPI JoystickAImpl_SetEventNotification(
+	LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
+) {
+    JoystickImpl *This = (JoystickImpl *)iface;
+
+    TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
+    This->hEvent = hnd;
+    return DI_OK;
+}
+
+static HRESULT WINAPI JoystickAImpl_GetCapabilities(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVCAPS lpDIDevCaps)
+{
+    JoystickImpl *This = (JoystickImpl *)iface;
+    int		xfd = This->joyfd;
+    int		i,axes,buttons;
+    int		wasacquired = 1;
+
+    TRACE("%p->(%p)\n",iface,lpDIDevCaps);
+    if (xfd==-1) {
+	/* yes, games assume we return something, even if unacquired */
+	JoystickAImpl_Acquire(iface);
+	xfd = This->joyfd;
+	wasacquired = 0;
+    }
+    lpDIDevCaps->dwFlags	= DIDC_ATTACHED;
+    lpDIDevCaps->dwDevType	= DIDEVTYPE_JOYSTICK;
+
+    axes=0;
+    for (i=0;i<ABS_MAX;i++) if (test_bit(This->absbits,i)) axes++;
+    buttons=0;
+    for (i=0;i<KEY_MAX;i++) if (test_bit(This->keybits,i)) buttons++;
+
+    lpDIDevCaps->dwAxes = axes;
+    lpDIDevCaps->dwButtons = buttons;
+
+    if (!wasacquired)
+	JoystickAImpl_Unacquire(iface);
+
+    return DI_OK;
+}
+
+static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
+    JoystickImpl *This = (JoystickImpl *)iface;
+    TRACE("(),stub!\n");
+
+    joy_polldev(This);
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     EnumObjects : enumerate the different buttons and axis...
+  */
+static HRESULT WINAPI JoystickAImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+  JoystickImpl *This = (JoystickImpl *)iface;
+  DIDEVICEOBJECTINSTANCEA ddoi;
+  int xfd = This->joyfd;
+
+
+  TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
+  if (TRACE_ON(dinput)) {
+    TRACE("  - flags = ");
+    _dump_EnumObjects_flags(dwFlags);
+    TRACE("\n");
+  }
+
+  if (xfd == -1) return DIERR_NOTACQUIRED;
+
+  /* Only the fields till dwFFMaxForce are relevant */
+  ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
+
+  /* For the joystick, do as is done in the GetCapabilities function */
+  /* FIXME: needs more items */
+  if ((dwFlags == DIDFT_ALL) ||
+      (dwFlags & DIDFT_AXIS)) {
+    BYTE i;
+
+    for (i = 0; i < ABS_MAX; i++) {
+      if (!test_bit(This->absbits,i)) continue;
+
+      switch (i) {
+      case ABS_X:
+	ddoi.guidType = GUID_XAxis;
+	ddoi.dwOfs = DIJOFS_X;
+	break;
+      case ABS_Y:
+	ddoi.guidType = GUID_YAxis;
+	ddoi.dwOfs = DIJOFS_Y;
+	break;
+      case ABS_Z:
+	ddoi.guidType = GUID_ZAxis;
+	ddoi.dwOfs = DIJOFS_Z;
+	break;
+      case ABS_RX:
+	ddoi.guidType = GUID_RxAxis;
+	ddoi.dwOfs = DIJOFS_RX;
+	break;
+      case ABS_RY:
+	ddoi.guidType = GUID_RyAxis;
+	ddoi.dwOfs = DIJOFS_RY;
+	break;
+      case ABS_RZ:
+	ddoi.guidType = GUID_RzAxis;
+	ddoi.dwOfs = DIJOFS_RZ;
+	break;
+      case ABS_THROTTLE:
+	ddoi.guidType = GUID_Slider;
+	ddoi.dwOfs = DIJOFS_SLIDER(0);
+	break;
+      default:
+	FIXME("unhandled abs axis %d, ignoring!\n",i);
+      }
+      ddoi.dwType = DIDFT_MAKEINSTANCE((1<<i) << WINE_JOYSTICK_AXIS_BASE) | DIDFT_ABSAXIS;
+      sprintf(ddoi.tszName, "%d-Axis", i);
+      _dump_OBJECTINSTANCEA(&ddoi);
+      if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE)
+	  return DI_OK;
+    }
+  }
+
+  if ((dwFlags == DIDFT_ALL) ||
+      (dwFlags & DIDFT_BUTTON)) {
+    int i;
+
+    /*The DInput SDK says that GUID_Button is only for mouse buttons but well*/
+
+    ddoi.guidType = GUID_Button;
+
+    for (i = 0; i < KEY_MAX; i++) {
+      if (!test_bit(This->keybits,i)) continue;
+
+      switch (i) {
+      case BTN_TRIGGER:
+      case BTN_A:
+      case BTN_1:
+	  ddoi.dwOfs = DIJOFS_BUTTON(0);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 0) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_THUMB:
+	case BTN_B:
+	case BTN_2:
+	  ddoi.dwOfs = DIJOFS_BUTTON(1);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 1) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_THUMB2:
+	case BTN_C:
+	case BTN_3:
+	  ddoi.dwOfs = DIJOFS_BUTTON(2);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 2) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_TOP:
+	case BTN_X:
+	case BTN_4:
+	  ddoi.dwOfs = DIJOFS_BUTTON(3);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 3) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_TOP2:
+	case BTN_Y:
+	case BTN_5:
+	  ddoi.dwOfs = DIJOFS_BUTTON(4);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 4) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_PINKIE:
+	case BTN_Z:
+	case BTN_6:
+	  ddoi.dwOfs = DIJOFS_BUTTON(5);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 5) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_BASE:
+	case BTN_TL:
+	case BTN_7:
+	  ddoi.dwOfs = DIJOFS_BUTTON(6);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 6) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_BASE2:
+	case BTN_TR:
+	case BTN_8:
+	  ddoi.dwOfs = DIJOFS_BUTTON(7);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 7) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_BASE3:
+	case BTN_TL2:
+	case BTN_9:
+	  ddoi.dwOfs = DIJOFS_BUTTON(8);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 8) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_BASE4:
+	case BTN_TR2:
+	  ddoi.dwOfs = DIJOFS_BUTTON(9);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 9) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+	case BTN_BASE5:
+	case BTN_SELECT:
+	  ddoi.dwOfs = DIJOFS_BUTTON(10);
+	  ddoi.dwType = DIDFT_MAKEINSTANCE((0x0001 << 10) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
+	  break;
+      }
+      sprintf(ddoi.tszName, "%d-Button", i);
+      _dump_OBJECTINSTANCEA(&ddoi);
+      if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE)
+	  return DI_OK;
+    }
+  }
+
+  if (xfd!=This->joyfd)
+    close(xfd);
+
+  return DI_OK;
+}
+
+static HRESULT WINAPI JoystickWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
+						LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+						LPVOID lpvRef,
+						DWORD dwFlags)
+{
+  JoystickImpl *This = (JoystickImpl *)iface;
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
+/******************************************************************************
+  *     GetProperty : get input device properties
+  */
+static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
+						REFGUID rguid,
+						LPDIPROPHEADER pdiph)
+{
+  JoystickImpl *This = (JoystickImpl *)iface;
+
+  TRACE("(this=%p,%s,%p): stub!\n",
+	iface, debugstr_guid(rguid), pdiph);
+
+  if (TRACE_ON(dinput))
+    _dump_DIPROPHEADER(pdiph);
+
+  if (!HIWORD(rguid)) {
+    switch ((DWORD)rguid) {
+    case (DWORD) DIPROP_BUFFERSIZE: {
+      LPDIPROPDWORD	pd = (LPDIPROPDWORD)pdiph;
+
+      TRACE(" return buffersize = %d\n",This->queue_len);
+      pd->dwData = This->queue_len;
+      break;
+    }
+
+    case (DWORD) DIPROP_RANGE: {
+      /* LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph; */
+      if ((pdiph->dwHow == DIPH_BYID) &&
+	  (pdiph->dwObj & DIDFT_ABSAXIS)) {
+	/* The app is querying the current range of the axis : return the lMin and lMax values */
+	FIXME("unimplemented axis range query.\n");
+      }
+
+      break;
[truncated at 1000 lines; 94 more skipped]

reactos/lib/dinput
keyboard.c added at 1.1.2.1
diff -N keyboard.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ keyboard.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,868 @@
+/*		DirectInput Keyboard device
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <string.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+//fast fix misning from mingw headers
+#ifdef __REACTOS__
+#define LLKHF_EXTENDED       (KF_EXTENDED >> 8)
+#define LLKHF_INJECTED       0x00000010
+//#define LLKHF_ALTDOWN        (KF_ALTDOWN >> 8)
+#define LLKHF_UP             (KF_UP >> 8)
+#endif
+
+static IDirectInputDevice8AVtbl SysKeyboardAvt;
+static IDirectInputDevice8WVtbl SysKeyboardWvt;
+
+typedef struct SysKeyboardImpl SysKeyboardImpl;
+struct SysKeyboardImpl
+{
+        LPVOID                          lpVtbl;
+        DWORD                           ref;
+        GUID                            guid;
+
+	IDirectInputImpl*               dinput;
+
+	HANDLE	hEvent;
+        /* SysKeyboardAImpl */
+	int                             acquired;
+        int                             buffersize;  /* set in 'SetProperty'         */
+        LPDIDEVICEOBJECTDATA            buffer;      /* buffer for 'GetDeviceData'.
+                                                        Alloc at 'Acquire', Free at
+                                                        'Unacquire'                  */
+        int                             count;       /* number of objects in use in
+                                                        'buffer'                     */
+        int                             start;       /* 'buffer' rotates. This is the
+                                                        first in use (if count > 0)  */
+        BOOL                            overflow;    /* return DI_BUFFEROVERFLOW in
+                                                        'GetDeviceData'              */
+        CRITICAL_SECTION                crit;
+};
+
+SysKeyboardImpl *current; /* Today's acquired device
+FIXME: currently this can be only one.
+Maybe this should be a linked list or st.
+I don't know what the rules are for multiple acquired keyboards,
+but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
+*/
+
+static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */
+
+static CRITICAL_SECTION keyboard_crit;
+static CRITICAL_SECTION_DEBUG critsect_debug =
+{
+    0, 0, &keyboard_crit,
+    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+      0, 0, { 0, (DWORD)(__FILE__ ": keyboard_crit") }
+};
+static CRITICAL_SECTION keyboard_crit = { &critsect_debug, -1, 0, 0, 0, 0 };
+
+static DWORD keyboard_users;
+
+#ifndef __REACTOS__
+static HHOOK keyboard_hook;
+#endif
+
+#ifdef __REACTOS__
+void reactos_input_keyboard();
+
+void reactos_input_keyboard()
+{
+  MSG msg;
+  BOOL fDone;
+  int disk_code = -1;
+  BOOL down;
+  BYTE oldDInputKeyState[256];
+  int t;
+  
+  memcpy(&oldDInputKeyState,&DInputKeyState,256);
+  GetKeyboardState(DInputKeyState);
+  
+  for( t=0;t<255;t++)
+  {
+	  if (oldDInputKeyState[t]!=DInputKeyState[t]) disk_code=t;	  
+  }
+  	
+
+  if (disk_code!=-1) {
+	  if (current->buffer != NULL)
+     {
+      int n;
+      n = (current->start + current->count) % current->buffersize;
+
+      current->buffer[n].dwOfs = (BYTE) disk_code;
+      current->buffer[n].dwData = DInputKeyState[disk_code];
+      current->buffer[n].dwTimeStamp = 10;
+      current->buffer[n].dwSequence = current->dinput->evsequence++;
+
+	  
+      if (current->count == current->buffersize)
+                {
+                  current->start = ++current->start % current->buffersize;
+                  current->overflow = TRUE;
+                }
+              else
+                current->count++;
+              
+            }
+  }
+
+
+}
+#endif
+#ifndef __REACTOS__
+LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
+{
+  TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
+
+  if (code == HC_ACTION)
+    {
+      BYTE dik_code;
+      BOOL down;
+      DWORD timestamp;
+      
+      {
+        KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
+        dik_code = hook->scanCode;
+        if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
+        down = !(hook->flags & LLKHF_UP);
+        timestamp = hook->time;
+      }
+
+      DInputKeyState[dik_code] = (down ? 0x80 : 0);
+      TRACE(" setting %02X to %02X\n", dik_code, DInputKeyState[dik_code]);
+      
+      if (current != NULL)
+        {
+          if (current->hEvent)
+            SetEvent(current->hEvent);
+
+          if (current->buffer != NULL)
+            {
+              int n;
+
+              EnterCriticalSection(&(current->crit));
+
+              n = (current->start + current->count) % current->buffersize;
+
+              current->buffer[n].dwOfs = dik_code;
+              current->buffer[n].dwData = down ? 0x80 : 0;
+              current->buffer[n].dwTimeStamp = timestamp;
+              current->buffer[n].dwSequence = current->dinput->evsequence++;
+
+	      TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n,
+		    current->buffer[n].dwOfs, current->buffer[n].dwData, current->buffer[n].dwTimeStamp, current->buffer[n].dwSequence);
+
+              if (current->count == current->buffersize)
+                {
+                  current->start = ++current->start % current->buffersize;
+                  current->overflow = TRUE;
+                }
+              else
+                current->count++;
+
+              LeaveCriticalSection(&(current->crit));
+            }
+        }
+    }
+
+  return CallNextHookEx(keyboard_hook, code, wparam, lparam);
+}
+#endif
+
+static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
+  0x0ab8648a,
+  0x7735,
+  0x11d2,
+  {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
+};
+
+static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEA ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+    strcpy(ddi.tszInstanceName, "Keyboard");
+    strcpy(ddi.tszProductName, "Wine Keyboard");
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+
+static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEW ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+ 
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+    MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+ 
+static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
+{
+  if (id != 0)
+    return FALSE;
+
+  if ((dwDevType == 0) ||
+      ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
+      ((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
+    TRACE("Enumerating the Keyboard device\n");
+ 
+    fill_keyboard_dideviceinstanceA(lpddi, version);
+    
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
+{
+  if (id != 0)
+    return FALSE;
+
+  if ((dwDevType == 0) ||
+      ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
+      ((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
+    TRACE("Enumerating the Keyboard device\n");
+
+    fill_keyboard_dideviceinstanceW(lpddi, version);
+    
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static SysKeyboardImpl *alloc_device_keyboard(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
+{
+    SysKeyboardImpl* newDevice;
+    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
+    newDevice->lpVtbl = kvt;
+    newDevice->ref = 1;
+    memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+    newDevice->dinput = dinput;
+
+#ifndef __REACTOS__
+    EnterCriticalSection(&keyboard_crit);
+
+    if (!keyboard_users++)
+        keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, DINPUT_instance, 0 );
+
+    LeaveCriticalSection(&keyboard_crit);
+#endif
+    return newDevice;
+}
+
+
+static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+{
+  if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
+      (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+      *pdev = (IDirectInputDeviceA*) alloc_device_keyboard(rguid, &SysKeyboardAvt, dinput);
+      TRACE("Creating a Keyboard device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+  return DIERR_DEVICENOTREG;
+}
+
+static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
+      (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device_keyboard(rguid, &SysKeyboardWvt, dinput);
+      TRACE("Creating a Keyboard device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+  return DIERR_DEVICENOTREG;
+}
+
+dinput_device keyboarddev = {
+  100,
+  "Wine keyboard driver",
+  keyboarddev_enum_deviceA,
+  keyboarddev_enum_deviceW,
+  keyboarddev_create_deviceA,
+  keyboarddev_create_deviceW
+};
+
+void scan_keyboard()
+{
+    dinput_register_device(&keyboarddev);
+}
+
+DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
+
+static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+	ULONG ref;
+
+	ref = InterlockedDecrement(&(This->ref));
+	if (ref)
+		return ref;
+
+#ifndef __REACTOS__
+	EnterCriticalSection(&keyboard_crit);
+	if (!--keyboard_users) {
+	    UnhookWindowsHookEx( keyboard_hook );
+	    keyboard_hook = 0;
+	}
+	LeaveCriticalSection(&keyboard_crit);
+#endif
+
+	/* Free the data queue */
+	if (This->buffer != NULL)
+	  HeapFree(GetProcessHeap(),0,This->buffer);
+
+	DeleteCriticalSection(&(This->crit));
+
+	HeapFree(GetProcessHeap(),0,This);
+	return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_SetProperty(
+	LPDIRECTINPUTDEVICE8A iface,REFGUID rguid,LPCDIPROPHEADER ph
+)
+{
+	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
+	TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
+            ph->dwSize,ph->dwHeaderSize,ph->dwObj,ph->dwHow);
+	if (!HIWORD(rguid)) {
+		switch ((DWORD)rguid) {
+		case (DWORD) DIPROP_BUFFERSIZE: {
+			LPCDIPROPDWORD	pd = (LPCDIPROPDWORD)ph;
+
+			TRACE("(buffersize=%ld)\n",pd->dwData);
+
+                        if (This->acquired)
+                           return DIERR_INVALIDPARAM;
+
+                        This->buffersize = pd->dwData;
+
+			break;
+		}
+		default:
+			WARN("Unknown type %ld\n",(DWORD)rguid);
+			break;
+		}
+	}
+	return DI_OK;
+}
+
+
+static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
+	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
+)
+{
+    TRACE("(%p)->(%ld,%p)\n", iface, len, ptr);
+	
+#ifdef __REACTOS__
+	reactos_input_keyboard();
+#endif
+
+    /* Note: device does not need to be acquired */
+    if (len != 256)
+      return DIERR_INVALIDPARAM;
+
+    MsgWaitForMultipleObjectsEx(0, NULL, 0, 0, 0);
+
+    if (TRACE_ON(dinput)) {
+	int i;
+	for (i = 0; i < 256; i++) {
+	    if (DInputKeyState[i] != 0x00) {
+		TRACE(" - %02X: %02x\n", i, DInputKeyState[i]);
+	    }
+	}
+    }
+    
+    memcpy(ptr, DInputKeyState, 256);
+    return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
+	LPDIRECTINPUTDEVICE8A iface,DWORD dodsize,LPDIDEVICEOBJECTDATA dod,
+	LPDWORD entries,DWORD flags
+)
+{
+	
+	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+	int ret = DI_OK, i = 0;
+#ifdef __REACTOS__
+     reactos_input_keyboard();
+#endif
+
+	TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
+	      This,dodsize,dod,entries,entries?*entries:0,flags);
+
+	if (This->acquired == 0)
+	  return DIERR_NOTACQUIRED;
+
+        if (This->buffer == NULL)
+          return DIERR_NOTBUFFERED;
+
+        if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
+          return DIERR_INVALIDPARAM;
+
+        MsgWaitForMultipleObjectsEx(0, NULL, 0, 0, 0);
+
+        EnterCriticalSection(&(This->crit));
+
+        /* Copy item at a time for the case dodsize > sizeof(buffer[n]) */
+        while ((i < *entries || *entries == INFINITE) && i < This->count)
+          {
+            if (dod != NULL)
+              {
+                int n = (This->start + i) % This->buffersize;
+                LPDIDEVICEOBJECTDATA pd
+                   = (LPDIDEVICEOBJECTDATA)((BYTE *)dod + dodsize * i);
+                pd->dwOfs       = This->buffer[n].dwOfs;
+                pd->dwData      = This->buffer[n].dwData;
+                pd->dwTimeStamp = This->buffer[n].dwTimeStamp;
+                pd->dwSequence  = This->buffer[n].dwSequence;
+              }
+            i++;
+          }
+
+        *entries = i;
+
+        if (This->overflow)
+          ret = DI_BUFFEROVERFLOW;
+
+        if (!(flags & DIGDD_PEEK))
+          {
+            /* Empty buffer */
+            This->count -= i;
+            This->start = (This->start + i) % This->buffersize;
+            This->overflow = FALSE;
+          }
+
+        LeaveCriticalSection(&(This->crit));
+
+	TRACE("Returning %ld events queued\n", *entries);
+
+        return ret;
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+    SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+    DIDEVICEOBJECTINSTANCEA ddoi;
+    int i;
+    
+    TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
+    if (TRACE_ON(dinput)) {
+        TRACE("  - flags = ");
+	_dump_EnumObjects_flags(dwFlags);
+	TRACE("\n");
+    }
+
+    /* Only the fields till dwFFMaxForce are relevant */
+    memset(&ddoi, 0, sizeof(ddoi));
+    ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
+
+    for (i = 0; i < 256; i++) {
+        /* Report 255 keys :-) */
+        ddoi.guidType = GUID_Key;
+	ddoi.dwOfs = i;
+	ddoi.dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_BUTTON;
+	GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName));
+	_dump_OBJECTINSTANCEA(&ddoi);
+	if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
+    }
+    
+    return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
+						   LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+						   LPVOID lpvRef,
+						   DWORD dwFlags)
+{
+  SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
+
+static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+
+	TRACE("(this=%p)\n",This);
+
+        if (This->acquired)
+          return S_FALSE;
+
+        This->acquired = 1;
+
+        if (current != NULL)
+          {
+            FIXME("Not more than one keyboard can be acquired at the same time.\n");
+            SysKeyboardAImpl_Unacquire(iface);
+          }
+
+        current = This;
+
+        if (This->buffersize > 0)
+          {
+            This->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+                                     This->buffersize * sizeof(*(This->buffer)));
+            This->start = 0;
+            This->count = 0;
+            This->overflow = FALSE;
+            InitializeCriticalSection(&(This->crit));
+          }
+        else
+          This->buffer = NULL;
+
+
+	return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+	TRACE("(this=%p)\n",This);
+
+        if (This->acquired == 0)
+          return DI_NOEFFECT;
+
+        if (current == This)
+          current = NULL;
+        else
+          ERR("this != current\n");
+
+        This->acquired = 0;
+
+        if (This->buffersize >= 0)
+          {
+            HeapFree(GetProcessHeap(), 0, This->buffer);
+            This->buffer = NULL;
+            DeleteCriticalSection(&(This->crit));
+          }
+
+	return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
+							    HANDLE hnd) {
+  SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+
+  TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
+
+  This->hEvent = hnd;
+  return DI_OK;
+}
+
+/******************************************************************************
+  *     GetCapabilities : get the device capablitites
+  */
+static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVCAPS lpDIDevCaps)
+{
+  SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+
+  TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
+
+  if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS)) {
+    lpDIDevCaps->dwFlags = DIDC_ATTACHED;
+    if (This->dinput->version >= 8)
+        lpDIDevCaps->dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
+    else
+        lpDIDevCaps->dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+    lpDIDevCaps->dwAxes = 0;
+    lpDIDevCaps->dwButtons = 256;
+    lpDIDevCaps->dwPOVs = 0;
+    lpDIDevCaps->dwFFSamplePeriod = 0;
+    lpDIDevCaps->dwFFMinTimeResolution = 0;
+    lpDIDevCaps->dwFirmwareRevision = 100;
+    lpDIDevCaps->dwHardwareRevision = 100;
+    lpDIDevCaps->dwFFDriverVersion = 0;
+  } else if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS_DX3)) {
+    lpDIDevCaps->dwFlags = DIDC_ATTACHED;
+    lpDIDevCaps->dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+    lpDIDevCaps->dwAxes = 0;
+    lpDIDevCaps->dwButtons = 256;
+    lpDIDevCaps->dwPOVs = 0;
+  } else {
+    WARN("invalid parameter\n");
+    return DIERR_INVALIDPARAM;
+  }
+
+  return DI_OK;
+}
+
+/******************************************************************************
+  *     GetObjectInfo : get information about a device object such as a button
+  *                     or axis
+  */
+static HRESULT WINAPI
+SysKeyboardAImpl_GetObjectInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEOBJECTINSTANCEA pdidoi,
+	DWORD dwObj,
+	DWORD dwHow)
+{
+    SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+    DIDEVICEOBJECTINSTANCEA ddoi;
+    DWORD dwSize = pdidoi->dwSize;
+    
+    TRACE("(this=%p,%p,%ld,0x%08lx)\n", This, pdidoi, dwObj, dwHow);
+
+    if (dwHow == DIPH_BYID) {
+        WARN(" querying by id not supported yet...\n");
+	return DI_OK;
+    }
+
+    memset(pdidoi, 0, dwSize);
+    memset(&ddoi, 0, sizeof(ddoi));
+
+    ddoi.dwSize = dwSize;
+    ddoi.guidType = GUID_Key;
+    ddoi.dwOfs = dwObj;
+    ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
+    GetKeyNameTextA(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName));
+
+    /* And return our just filled device object instance structure */
+    memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
+    
+    _dump_OBJECTINSTANCEA(pdidoi);
+
+    return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIDEVICEOBJECTINSTANCEW pdidoi,
+						     DWORD dwObj,
+						     DWORD dwHow)
+{
+    SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+    DIDEVICEOBJECTINSTANCEW ddoi;
+    DWORD dwSize = pdidoi->dwSize;
+    
+    TRACE("(this=%p,%p,%ld,0x%08lx)\n", This, pdidoi, dwObj, dwHow);
+
+    if (dwHow == DIPH_BYID) {
+        WARN(" querying by id not supported yet...\n");
+	return DI_OK;
+    }
+
+    memset(pdidoi, 0, dwSize);
+    memset(&ddoi, 0, sizeof(ddoi));
+
+    ddoi.dwSize = dwSize;
+    ddoi.guidType = GUID_Key;
+    ddoi.dwOfs = dwObj;
+    ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
+    GetKeyNameTextW(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName));
+
+    /* And return our just filled device object instance structure */
+    memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
+    
+    _dump_OBJECTINSTANCEW(pdidoi);
+
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     GetDeviceInfo : get information about a device's identity
+  */
+static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8A iface,
+	LPDIDEVICEINSTANCEA pdidi)
+{
+    SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+    TRACE("(this=%p,%p)\n", This, pdidi);
+
+    if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
+        WARN(" dinput3 not supporte yet...\n");
+	return DI_OK;
+    }
+
+    fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version);
+    
+    return DI_OK;
+}
+
+static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) 
+{
+    SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+    TRACE("(this=%p,%p)\n", This, pdidi);
+
+    if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
+        WARN(" dinput3 not supporte yet...\n");
+	return DI_OK;
+    }
+
+    fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version);
+    
+    return DI_OK;
+}
+
+static IDirectInputDevice8AVtbl SysKeyboardAvt =
+{
+	IDirectInputDevice2AImpl_QueryInterface,
+	IDirectInputDevice2AImpl_AddRef,
+	SysKeyboardAImpl_Release,
+	SysKeyboardAImpl_GetCapabilities,
+	SysKeyboardAImpl_EnumObjects,
+	IDirectInputDevice2AImpl_GetProperty,
+	SysKeyboardAImpl_SetProperty,
+	SysKeyboardAImpl_Acquire,
+	SysKeyboardAImpl_Unacquire,
+	SysKeyboardAImpl_GetDeviceState,
+	SysKeyboardAImpl_GetDeviceData,
+	IDirectInputDevice2AImpl_SetDataFormat,
+	SysKeyboardAImpl_SetEventNotification,
+	IDirectInputDevice2AImpl_SetCooperativeLevel,
+	SysKeyboardAImpl_GetObjectInfo,
+	SysKeyboardAImpl_GetDeviceInfo,
+	IDirectInputDevice2AImpl_RunControlPanel,
+	IDirectInputDevice2AImpl_Initialize,
+	IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2AImpl_EnumEffects,
+	IDirectInputDevice2AImpl_GetEffectInfo,
+	IDirectInputDevice2AImpl_GetForceFeedbackState,
+	IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	IDirectInputDevice2AImpl_Escape,
+	IDirectInputDevice2AImpl_Poll,
+        IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7AImpl_EnumEffectsInFile,
+        IDirectInputDevice7AImpl_WriteEffectToFile,
+        IDirectInputDevice8AImpl_BuildActionMap,
+        IDirectInputDevice8AImpl_SetActionMap,
+        IDirectInputDevice8AImpl_GetImageInfo
+};
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(SysKeyboardWvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static IDirectInputDevice8WVtbl SysKeyboardWvt =
+{
+	IDirectInputDevice2WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
+	XCAST(Release)SysKeyboardAImpl_Release,
+	XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
+	SysKeyboardWImpl_EnumObjects,
+	XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
+	XCAST(SetProperty)SysKeyboardAImpl_SetProperty,
+	XCAST(Acquire)SysKeyboardAImpl_Acquire,
+	XCAST(Unacquire)SysKeyboardAImpl_Unacquire,
+	XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
+	XCAST(GetDeviceData)SysKeyboardAImpl_GetDeviceData,
+	XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
+	XCAST(SetEventNotification)SysKeyboardAImpl_SetEventNotification,
+	XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
+	SysKeyboardWImpl_GetObjectInfo,
+	SysKeyboardWImpl_GetDeviceInfo,
+	XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
+	XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2WImpl_EnumEffects,
+	IDirectInputDevice2WImpl_GetEffectInfo,
+	XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
+	XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+	XCAST(Poll)IDirectInputDevice2AImpl_Poll,
+        XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7WImpl_EnumEffectsInFile,
+        IDirectInputDevice7WImpl_WriteEffectToFile,
+        IDirectInputDevice8WImpl_BuildActionMap,
+        IDirectInputDevice8WImpl_SetActionMap,
+        IDirectInputDevice8WImpl_GetImageInfo
+};
+#undef XCAST

reactos/lib/dinput
mouse.c added at 1.2.2.1
diff -N mouse.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mouse.c	8 Dec 2004 21:57:07 -0000	1.2.2.1
@@ -0,0 +1,1253 @@
+/*		DirectInput Mouse device
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+#define MOUSE_HACK
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+typedef struct {
+                     POINT pt;
+                     DWORD mouseData;
+                     DWORD flags;
+                     DWORD time;
+                     ULONG_PTR dwExtraInfo;
+} MSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;
+
+/* Wine mouse driver object instances */
+#define WINE_MOUSE_X_AXIS_INSTANCE   0
+#define WINE_MOUSE_Y_AXIS_INSTANCE   1
+#define WINE_MOUSE_Z_AXIS_INSTANCE   2
+#define WINE_MOUSE_L_BUTTON_INSTANCE 0
+#define WINE_MOUSE_R_BUTTON_INSTANCE 1
+#define WINE_MOUSE_M_BUTTON_INSTANCE 2
+#define WINE_MOUSE_D_BUTTON_INSTANCE 3
+
+/* ------------------------------- */
+/* Wine mouse internal data format */
+/* ------------------------------- */
+
+/* Constants used to access the offset array */
+#define WINE_MOUSE_X_POSITION 0
+#define WINE_MOUSE_Y_POSITION 1
+#define WINE_MOUSE_Z_POSITION 2
+#define WINE_MOUSE_L_POSITION 3
+#define WINE_MOUSE_R_POSITION 4
+#define WINE_MOUSE_M_POSITION 5
+
+typedef struct {
+    LONG lX;
+    LONG lY;
+    LONG lZ;
+    BYTE rgbButtons[4];
+} Wine_InternalMouseData;
+
+#define WINE_INTERNALMOUSE_NUM_OBJS 6
+
+static const DIOBJECTDATAFORMAT Wine_InternalMouseObjectFormat[WINE_INTERNALMOUSE_NUM_OBJS] = {
+    { &GUID_XAxis,   FIELD_OFFSET(Wine_InternalMouseData, lX),
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
+    { &GUID_YAxis,   FIELD_OFFSET(Wine_InternalMouseData, lY),
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
+    { &GUID_ZAxis,   FIELD_OFFSET(Wine_InternalMouseData, lZ),
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
+    { &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 0,
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_L_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 },
+    { &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 1,
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_R_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 },
+    { &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 2,
+	  DIDFT_MAKEINSTANCE(WINE_MOUSE_M_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 }
+};
+
+static const DIDATAFORMAT Wine_InternalMouseFormat = {
+    0, /* dwSize - unused */
+    0, /* dwObjsize - unused */
+    0, /* dwFlags - unused */
+    sizeof(Wine_InternalMouseData),
+    WINE_INTERNALMOUSE_NUM_OBJS, /* dwNumObjs */
+    (LPDIOBJECTDATAFORMAT) Wine_InternalMouseObjectFormat
+};
+
+static IDirectInputDevice8AVtbl SysMouseAvt;
+static IDirectInputDevice8WVtbl SysMouseWvt;
+
+typedef struct SysMouseImpl SysMouseImpl;
+
+typedef enum {
+    WARP_DONE,   /* Warping has been done */
+    WARP_NEEDED, /* Warping is needed */
+    WARP_STARTED /* Warping has been done, waiting for the warp event */
+} WARP_STATUS;
+
+struct SysMouseImpl
+{
+    LPVOID                          lpVtbl;
+    DWORD                           ref;
+    GUID                            guid;
+    
+    IDirectInputImpl               *dinput;
+    
+    /* The current data format and the conversion between internal
+       and external data formats */
+    DIDATAFORMAT	           *df;
+    DataFormat                     *wine_df;
+    int                             offset_array[WINE_INTERNALMOUSE_NUM_OBJS];
+    
+    /* SysMouseAImpl */
+    BYTE                            absolute;
+    /* Previous position for relative moves */
+    LONG			    prevX, prevY;
+    /* These are used in case of relative -> absolute transitions */
+    POINT                           org_coords;
+    HHOOK                           hook;
+    HWND			    win;
+    DWORD			    dwCoopLevel;
+    POINT      			    mapped_center;
+    DWORD			    win_centerX, win_centerY;
+    LPDIDEVICEOBJECTDATA 	    data_queue;
+    int				    queue_head, queue_tail, queue_len;
+    BOOL			    overflow;
+    /* warping: whether we need to move mouse back to middle once we
+     * reach window borders (for e.g. shooters, "surface movement" games) */
+    WARP_STATUS		            need_warp;
+    int				    acquired;
+    HANDLE			    hEvent;
+    CRITICAL_SECTION		    crit;
+    
+    /* This is for mouse reporting. */
+    Wine_InternalMouseData          m_state;
+};
+
+/* FIXME: This is ugly and not thread safe :/ */
+static IDirectInputDevice8A* current_lock = NULL;
+
+/* FIXME: This is ugly but needed on Windows */
+static int mouse_set = 0;
+
+static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
+    0x9e573ed8,
+    0x7734,
+    0x11d2,
+    {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
+};
+
+static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEA ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
+    strcpy(ddi.tszInstanceName, "Mouse");
+    strcpy(ddi.tszProductName, "Wine Mouse");
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+
+static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEW ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
+    MultiByteToWideChar(CP_ACP, 0, "Mouse", -1, ddi.tszInstanceName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, "Wine Mouse", -1, ddi.tszProductName, MAX_PATH);
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+
+static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
+{
+    if (id != 0)
+        return FALSE;
+
+    if ((dwDevType == 0) ||
+	((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
+	((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
+	TRACE("Enumerating the mouse device\n");
+	
+	fill_mouse_dideviceinstanceA(lpddi, version);
+	
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
+{
+    if (id != 0)
+        return FALSE;
+
+    if ((dwDevType == 0) ||
+	((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
+	((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
+	TRACE("Enumerating the mouse device\n");
+	
+	fill_mouse_dideviceinstanceW(lpddi, version);
+	
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+static SysMouseImpl *alloc_device_mouse(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
+{
+    int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
+	FIELD_OFFSET(Wine_InternalMouseData, lX),
+	FIELD_OFFSET(Wine_InternalMouseData, lY),
+	FIELD_OFFSET(Wine_InternalMouseData, lZ),
+	FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 0,
+	FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1,
+	FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 2
+    };
+    SysMouseImpl* newDevice;
+    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
+    newDevice->ref = 1;
+    newDevice->lpVtbl = mvt;
+#ifndef __REACTOS__
+    InitializeCriticalSection(&(newDevice->crit));
+#endif
+    memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+
+    /* Per default, Wine uses its internal data format */
+    newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat;
+    memcpy(newDevice->offset_array, offset_array, WINE_INTERNALMOUSE_NUM_OBJS * sizeof(int));
+    newDevice->wine_df = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
+    newDevice->wine_df->size = 0;
+    newDevice->wine_df->internal_format_size = Wine_InternalMouseFormat.dwDataSize;
+    newDevice->wine_df->dt = NULL;
+    newDevice->dinput = dinput;
+
+    return newDevice;
+}
+
+static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+{
+    if ((IsEqualGUID(&GUID_SysMouse,rguid)) ||             /* Generic Mouse */
+	(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
+	if ((riid == NULL) ||
+	    IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+	    *pdev = (IDirectInputDeviceA*) alloc_device_mouse(rguid, &SysMouseAvt, dinput);
+	    TRACE("Creating a Mouse device (%p)\n", *pdev);
+	    return DI_OK;
+	} else
+	    return DIERR_NOINTERFACE;
+    }
+    
+    return DIERR_DEVICENOTREG;
+}
+
+static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+    if ((IsEqualGUID(&GUID_SysMouse,rguid)) ||             /* Generic Mouse */
+	(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
+	if ((riid == NULL) ||
+	    IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	    IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+	    *pdev = (IDirectInputDeviceW*) alloc_device_mouse(rguid, &SysMouseWvt, dinput);
+	    TRACE("Creating a Mouse device (%p)\n", *pdev);
+	    return DI_OK;
+	} else
+	    return DIERR_NOINTERFACE;
+    }
+    
+    return DIERR_DEVICENOTREG;
+}
+
+static dinput_device mousedev = {
+    100,
+    "Wine mouse driver",
+    mousedev_enum_deviceA,
+    mousedev_enum_deviceW,
+    mousedev_create_deviceA,
+    mousedev_create_deviceW
+};
+
+void scan_mouse()
+{
+    dinput_register_device(&mousedev);
+}
+
+DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
+
+/******************************************************************************
+ *	SysMouseA (DInput Mouse support)
+ */
+
+/******************************************************************************
+  *     Release : release the mouse buffer.
+  */
+static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    ULONG ref;
+ 
+    ref = InterlockedDecrement(&(This->ref));
+    if (ref)
+	return ref;
+    
+    /* Free the data queue */
+    if (This->data_queue != NULL)
+	HeapFree(GetProcessHeap(),0,This->data_queue);
+
+#ifndef __REACTOS__
+    if (This->hook) {
+	UnhookWindowsHookEx( This->hook );
+	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+            ShowCursor(TRUE); /* show cursor */
+    }
+    DeleteCriticalSection(&(This->crit));
+#endif
+
+#ifdef __REACTOS__
+if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+            ShowCursor(TRUE); /* show cursor */
+    
+#endif
+    /* Free the DataFormat */
+    if (This->df != &(Wine_InternalMouseFormat)) {
+	HeapFree(GetProcessHeap(), 0, This->df->rgodf);
+	HeapFree(GetProcessHeap(), 0, This->df);
+    }
+    
+    HeapFree(GetProcessHeap(),0,This);
+    return 0;
+}
+
+
+/******************************************************************************
+  *     SetCooperativeLevel : store the window in which we will do our
+  *   grabbing.
+  */
+static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel(
+	LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
+)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    
+    TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
+    
+    if (TRACE_ON(dinput)) {
+	TRACE(" cooperative level : ");
+	_dump_cooperativelevel_DI(dwflags);
+    }
+    
+    /* Store the window which asks for the mouse */
+    if (!hwnd)
+	hwnd = GetDesktopWindow();
+    This->win = hwnd;
+    This->dwCoopLevel = dwflags;
+    
+    return DI_OK;
+}
+
+
+/******************************************************************************
+  *     SetDataFormat : the application can choose the format of the data
+  *   the device driver sends back with GetDeviceState.
+  *
+  *   For the moment, only the "standard" configuration (c_dfDIMouse) is supported
+  *   in absolute and relative mode.
+  */
+static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
+	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
+)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    
+    TRACE("(this=%p,%p)\n",This,df);
+    
+    _dump_DIDATAFORMAT(df);
+    
+    /* Tests under windows show that a call to SetDataFormat always sets the mouse
+       in relative mode whatever the dwFlags value (DIDF_ABSAXIS/DIDF_RELAXIS).
+       To switch in absolute mode, SetProperty must be used. */
+    This->absolute = 0;
+    
+    /* Store the new data format */
+    This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
+    memcpy(This->df, df, df->dwSize);
+    This->df->rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
+    memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
+    
+    /* Prepare all the data-conversion filters */
+    This->wine_df = create_DataFormat(&(Wine_InternalMouseFormat), df, This->offset_array);
+    
+    return DI_OK;
+}
+
+/* low-level mouse hook */
+static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lparam )
+{
+    LRESULT ret;
+    MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
+    SysMouseImpl* This = (SysMouseImpl*) current_lock;
+    DWORD dwCoop;
+    static long last_event = 0;
+    int wdata;
+
+    if (code != HC_ACTION) return CallNextHookEx( This->hook, code, wparam, lparam );
+
+    EnterCriticalSection(&(This->crit));
+    dwCoop = This->dwCoopLevel;
+
+    /* Only allow mouse events every 10 ms.
+     * This is to allow the cursor to start acceleration before
+     * the warps happen. But if it involves a mouse button event we
+     * allow it since we don't want to loose the clicks.
+     */
+    if (((GetCurrentTime() - last_event) < 10)
+        && wparam == WM_MOUSEMOVE)
+	goto end;
+    else last_event = GetCurrentTime();
+    
+    /* Mouse moved -> send event if asked */
+    if (This->hEvent)
+        SetEvent(This->hEvent);
+    
+    if (wparam == WM_MOUSEMOVE) {
+	if (This->absolute) {
+	    if (hook->pt.x != This->prevX)
+		GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x, hook->time, 0);
+	    if (hook->pt.y != This->prevY)
+		GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y, hook->time, 0);
+	} else {
+	    /* Now, warp handling */
+	    if ((This->need_warp == WARP_STARTED) &&
+		(hook->pt.x == This->mapped_center.x) && (hook->pt.y == This->mapped_center.y)) {
+		/* Warp has been done... */
+		This->need_warp = WARP_DONE;
+		goto end;
+	    }
+	    
+	    /* Relative mouse input with absolute mouse event : the real fun starts here... */
+	    if ((This->need_warp == WARP_NEEDED) ||
+		(This->need_warp == WARP_STARTED)) {
+		if (hook->pt.x != This->prevX)
+		    GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->prevX,
+			      hook->time, (This->dinput->evsequence)++);
+		if (hook->pt.y != This->prevY)
+		    GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->prevY,
+			      hook->time, (This->dinput->evsequence)++);
+	    } else {
+		/* This is the first time the event handler has been called after a
+		   GetDeviceData or GetDeviceState. */
+		if (hook->pt.x != This->mapped_center.x) {
+		    GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->mapped_center.x,
+			      hook->time, (This->dinput->evsequence)++);
+		    This->need_warp = WARP_NEEDED;
+		}
+		
+		if (hook->pt.y != This->mapped_center.y) {
+		    GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->mapped_center.y,
+			      hook->time, (This->dinput->evsequence)++);
+		    This->need_warp = WARP_NEEDED;
+		}
+	    }
+	}
+	
+	This->prevX = hook->pt.x;
+	This->prevY = hook->pt.y;
+	
+	if (This->absolute) {
+	    This->m_state.lX = hook->pt.x;
+	    This->m_state.lY = hook->pt.y;
+	} else {
+	    This->m_state.lX = hook->pt.x - This->mapped_center.x;
+	    This->m_state.lY = hook->pt.y - This->mapped_center.y;
+	}
+    }
+    
+    TRACE(" msg %x pt %ld %ld (W=%d)\n",
+          wparam, hook->pt.x, hook->pt.y, (!This->absolute) && This->need_warp );
+    
+    switch(wparam) {
+        case WM_LBUTTONDOWN:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0xFF,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[0] = 0xFF;
+	    break;
+	case WM_LBUTTONUP:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0x00,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[0] = 0x00;
+	    break;
+	case WM_RBUTTONDOWN:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0xFF,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[1] = 0xFF;
+	    break;
+	case WM_RBUTTONUP:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0x00,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[1] = 0x00;
+	    break;
+	case WM_MBUTTONDOWN:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0xFF,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[2] = 0xFF;
+	    break;
+	case WM_MBUTTONUP:
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0x00,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.rgbButtons[2] = 0x00;
+	    break;
+	case WM_MOUSEWHEEL:
+	    wdata = (short)HIWORD(hook->mouseData);
+	    GEN_EVENT(This->offset_array[WINE_MOUSE_Z_POSITION], wdata,
+		      hook->time, This->dinput->evsequence++);
+	    This->m_state.lZ += wdata;
+	    break;
+    }
+    
+    TRACE("(X: %ld - Y: %ld   L: %02x M: %02x R: %02x)\n",
+	  This->m_state.lX, This->m_state.lY,
+	  This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
+    
+  end:
+    LeaveCriticalSection(&(This->crit));
+    
+    if (dwCoop & DISCL_NONEXCLUSIVE) {
+	/* Pass the events down to previous handlers (e.g. win32 input) */
+	ret = CallNextHookEx( This->hook, code, wparam, lparam );
+    } else {
+	/* Ignore message */
+	ret = 1;
+    }
+    return ret;
+}
+
+
+static void dinput_window_check(SysMouseImpl* This) {
+    RECT rect;
+    DWORD centerX, centerY;
+    
+    /* make sure the window hasn't moved */
+    GetWindowRect(This->win, &rect);
+    centerX = (rect.right  - rect.left) / 2;
+    centerY = (rect.bottom - rect.top ) / 2;
+    if (This->win_centerX != centerX || This->win_centerY != centerY) {
+	This->win_centerX = centerX;
+	This->win_centerY = centerY;
+    }
+    This->mapped_center.x = This->win_centerX;
+    This->mapped_center.y = This->win_centerY;
+    MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
+}
+
+
+/******************************************************************************
+  *     Acquire : gets exclusive control of the mouse
+  */
+static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    RECT	rect;
+    
+    TRACE("(this=%p)\n",This);
+    
+    if (This->acquired == 0) {
+	POINT point;
+	
+	/* Store (in a global variable) the current lock */
+	current_lock = (IDirectInputDevice8A*)This;
+	
+	/* Init the mouse state */
+	GetCursorPos( &point );
+	if (This->absolute) {
+	    This->m_state.lX = point.x;
+	    This->m_state.lY = point.y;
+	    This->prevX = point.x;
+	    This->prevY = point.y;
+	} else {
+	    This->m_state.lX = 0;
+	    This->m_state.lY = 0;
+	    This->org_coords = point;
+	}
+	This->m_state.lZ = 0;
+	This->m_state.rgbButtons[0] = ((GetKeyState(VK_LBUTTON) & 0x80) ? 0xFF : 0x00);
+	This->m_state.rgbButtons[1] = ((GetKeyState(VK_RBUTTON) & 0x80) ? 0xFF : 0x00);
+	This->m_state.rgbButtons[2] = ((GetKeyState(VK_MBUTTON) & 0x80) ? 0xFF : 0x00);
+	
+	/* Install our mouse hook */
+	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+	    ShowCursor(FALSE); /* hide cursor */
+#ifndef __REACTOS__
+	This->hook = SetWindowsHookExA( WH_MOUSE_LL, dinput_mouse_hook, DINPUT_instance, 0 );
+#endif	
+	/* Get the window dimension and find the center */
+	GetWindowRect(This->win, &rect);
+	This->win_centerX = (rect.right  - rect.left) / 2;
+	This->win_centerY = (rect.bottom - rect.top ) / 2;
+	
+	/* Warp the mouse to the center of the window */
+	if (This->absolute == 0) {
+	    This->mapped_center.x = This->win_centerX;
+	    This->mapped_center.y = This->win_centerY;
+	    MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
+	    TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
+	    SetCursorPos( This->mapped_center.x, This->mapped_center.y );
+#ifdef MOUSE_HACK
+	    This->need_warp = WARP_DONE;
+#else
+	    This->need_warp = WARP_STARTED;
+#endif
+	}
+	
+	This->acquired = 1;
+	return DI_OK;
+    }
+    return S_FALSE;
+}
+
+/******************************************************************************
+  *     Unacquire : frees the mouse
+  */
+static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    
+    TRACE("(this=%p)\n",This);
+    
+    if (This->acquired) {
+	/* Reinstall previous mouse event handler */
+
+#ifndef __REACTOS__
+	if (This->hook) {
+	    UnhookWindowsHookEx( This->hook );
+	    This->hook = 0;
+
+	    if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+		ShowCursor(TRUE); /* show cursor */
+        }
+#endif
+#ifdef __REACTOS__
+	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+		ShowCursor(TRUE); /* show cursor */
+#endif
+
+        /* No more locks */
+        current_lock = NULL;
+	
+        /* Unacquire device */
+        This->acquired = 0;
+
+	/* And put the mouse cursor back where it was at acquire time */
+	if (This->absolute == 0) {
+	    TRACE(" warping mouse back to (%ld , %ld)\n", This->org_coords.x, This->org_coords.y);
+	    SetCursorPos(This->org_coords.x, This->org_coords.y);
+	}
+    } else {
+	return DI_NOEFFECT;
+    }
+	
+    return DI_OK;
+}
+
+// if you call poll then to getdevicestate
+// it did not send back right value in windows 
+int poll_mouse=0;
+static HRESULT WINAPI SysMouseAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
+{
+ int retValue = DI_OK;
+ 
+SysMouseImpl *This = (SysMouseImpl *)iface;           
+ if (poll_mouse==0) {
+	                 retValue=SysMouseAImpl_Acquire(iface);	
+                     poll_mouse=1; 
+					 if (retValue!=DI_OK) retValue=DIERR_NOTACQUIRED;
+                     else retValue = DI_OK;
+                     }
+
+ return retValue;
+}
+	
+
+/******************************************************************************
+  *     GetDeviceState : returns the "state" of the mouse.
+  *
+  *   For the moment, only the "standard" return structure (DIMOUSESTATE) is
+  *   supported.
+  */
+static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
+	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
+) {
+    SysMouseImpl *This = (SysMouseImpl *)iface;        
+    POINT point;    	 
+
+#ifndef __REACTOS__
+    EnterCriticalSection(&(This->crit));
+#endif
+    TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
+    	
+    /* Copy the current mouse state */	   
+    fill_DataFormat(ptr, &(This->m_state), This->wine_df);
+
+
+	// this fix windows bugs when 
+	// some program calling on mouse poll
+	if (poll_mouse==1) poll_mouse=0;		 
+	else {
+	      if (This->absolute == 0) {
+	                       This->m_state.lX = 0;
+	                       This->m_state.lY = 0;
+	                       This->m_state.lZ = 0;
+	                       } 
+	     }
+	
+	
+    /* Check if we need to do a mouse warping */
+    if (This->need_warp == WARP_NEEDED) {
+	dinput_window_check(This);
+	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);	
+        if (mouse_set==0){
+           SetCursorPos( This->mapped_center.x, This->mapped_center.y );
+           mouse_set++;
+           }
+	
+#ifdef MOUSE_HACK
+	This->need_warp = WARP_DONE;
+#else
+	This->need_warp = WARP_STARTED;
+#endif
+    }
+
+#ifndef __REACTOS__
+    LeaveCriticalSection(&(This->crit));
+#endif
+
+    TRACE("(X: %ld - Y: %ld - Z: %ld  L: %02x M: %02x R: %02x)\n",
+	  This->m_state.lX, This->m_state.lY, This->m_state.lZ,
+	  This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
+    
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     GetDeviceState : gets buffered input data.
+  */
+
+static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
+						  DWORD dodsize,
+						  LPDIDEVICEOBJECTDATA dod,
+						  LPDWORD entries,
+						  DWORD flags
+) {
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    DWORD len;
+    int nqtail;
+	
+    
+    TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
+    
+
+	// windows does not get any data if 
+	// we do not call manual to mouse Acquire
+	// this is only need if some apps calling on getdevice data direcly
+	// in windows GetdeviceData does always update first the data
+	// then return it.
+	SysMouseAImpl_Acquire(iface);
+
+
+    if (This->acquired == 0) {
+	WARN(" application tries to get data from an unacquired device !\n");
+	return DIERR_NOTACQUIRED;
+    }
+    
+	
+#ifndef __REACTOS__
+    EnterCriticalSection(&(This->crit));
+#endif
+
+	// FIXME mouse are bit choppy here. 
+
+    len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
+	+ (This->queue_head - This->queue_tail);
+    if (len > *entries) len = *entries;
+    
+    if (dod == NULL) {
+	if (len)
+	    TRACE("Application discarding %ld event(s).\n", len);
+	
+	*entries = len;
+	nqtail = This->queue_tail + len;
+	while (nqtail >= This->queue_len) nqtail -= This->queue_len;
+    } else {
+	if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
+	    ERR("Wrong structure size !\n");
+#ifndef __REACTOS__
+	    LeaveCriticalSection(&(This->crit));
+#endif
+	    return DIERR_INVALIDPARAM;
+	}
+	
+	if (len)
+	    TRACE("Application retrieving %ld event(s).\n", len);
+	
+	*entries = 0;
+	nqtail = This->queue_tail;
+	while (len) {
+	    DWORD span = ((This->queue_head < nqtail) ? This->queue_len : This->queue_head) - nqtail;
+	    if (span > len)
+		span = len;
+	    
+	    /* Copy the buffered data into the application queue */
+	    memcpy(dod + *entries, This->data_queue + nqtail, span * dodsize);
+
+	    /* Advance position */
+	    nqtail += span;
+	    if (nqtail >= This->queue_len) nqtail -= This->queue_len;
+	    *entries += span;
+	    len -= span;
+	}
+    }
+    if (!(flags & DIGDD_PEEK))
+	This->queue_tail = nqtail;
+#ifndef __REACTOS__    
+    LeaveCriticalSection(&(This->crit));
+#endif    
+    /* Check if we need to do a mouse warping */
+   
+
+    if (This->need_warp == WARP_NEEDED) {
+	dinput_window_check(This);
+	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
+        if (mouse_set==0){
+           SetCursorPos( This->mapped_center.x, This->mapped_center.y );
+           mouse_set++;
+           }
+	
+#ifdef MOUSE_HACK
+	This->need_warp = WARP_DONE;
+#else
+	This->need_warp = WARP_STARTED;
+#endif
+    }
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     SetProperty : change input device properties
+  */
+static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
+					    REFGUID rguid,
+					    LPCDIPROPHEADER ph)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    
+    TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
+    
+    if (!HIWORD(rguid)) {
+	switch ((DWORD)rguid) {
+	    case (DWORD) DIPROP_BUFFERSIZE: {
+		LPCDIPROPDWORD	pd = (LPCDIPROPDWORD)ph;
+		
+		TRACE("buffersize = %ld\n",pd->dwData);
+		
+		This->data_queue = (LPDIDEVICEOBJECTDATA)HeapAlloc(GetProcessHeap(),0,
+								   pd->dwData * sizeof(DIDEVICEOBJECTDATA));
+		This->queue_head = 0;
+		This->queue_tail = 0;
+		This->queue_len  = pd->dwData;
+		break;
+	    }
+	    case (DWORD) DIPROP_AXISMODE: {
+		LPCDIPROPDWORD    pd = (LPCDIPROPDWORD)ph;
+		This->absolute = !(pd->dwData);
+		TRACE("Using %s coordinates mode now\n", This->absolute ? "absolute" : "relative");
+		break;
+	    }
+	    default:
+	      FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
+	      break;
+	}
+    }
+    
+    return DI_OK;
+}
+
+/******************************************************************************
+  *     GetProperty : get input device properties
+  */
+static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
+						REFGUID rguid,
+						LPDIPROPHEADER pdiph)
+{
+    SysMouseImpl *This = (SysMouseImpl *)iface;
+    
+    TRACE("(this=%p,%s,%p): stub!\n",
+	  iface, debugstr_guid(rguid), pdiph);
+    
+    if (TRACE_ON(dinput))
+	_dump_DIPROPHEADER(pdiph);
+    
+    if (!HIWORD(rguid)) {
+	switch ((DWORD)rguid) {
+	    case (DWORD) DIPROP_BUFFERSIZE: {
+		LPDIPROPDWORD	pd = (LPDIPROPDWORD)pdiph;
+		
+		TRACE(" return buffersize = %d\n",This->queue_len);
+		pd->dwData = This->queue_len;
+		break;
+	    }
+	      
+	    case (DWORD) DIPROP_GRANULARITY: {
+		LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph;
+		
+		/* We'll just assume that the app asks about the Z axis */
+		pr->dwData = WHEEL_DELTA;
+		
+		break;
+	    }
+	      
+	    case (DWORD) DIPROP_RANGE: {
+		LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
+		
+		if ((pdiph->dwHow == DIPH_BYID) &&
+		    ((pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS)) ||
+		     (pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS)))) {
+		    /* Querying the range of either the X or the Y axis.  As I do
+		       not know the range, do as if the range were
+		       unrestricted...*/
+		    pr->lMin = DIPROPRANGE_NOMIN;
+		    pr->lMax = DIPROPRANGE_NOMAX;
+		}
+		
+		break;
+	    }
+	      
+	    default:
+	      FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
+	      break;
+	  }
+      }
+    
+    return DI_OK;
+}
+
+
+
+/******************************************************************************
+  *     SetEventNotification : specifies event to be sent on state change
+  */
[truncated at 1000 lines; 257 more skipped]

reactos/lib/dinput
regsvr.c added at 1.1.2.1
diff -N regsvr.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ regsvr.c	8 Dec 2004 21:57:07 -0000	1.1.2.1
@@ -0,0 +1,558 @@
+/*
+ *	self-registerable dll functions for dinput.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dinput.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {
+	&CLSID_DirectInput,
+	"DirectInput Object",
+	NULL,
+	"dinput.dll",
+	"Both"
+    },
+    {
+	&CLSID_DirectInputDevice,
+	"DirectInputDevice Object",
+	NULL,
+	"dinput.dll",
+	"Both"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DINPUT.@)
+ */
+HRESULT WINAPI DINPUT_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DINPUT.@)
+ */
+HRESULT WINAPI DINPUT_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}

reactos/lib/dinput
version.rc added at 1.1.2.1
diff -N version.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ version.rc	8 Dec 2004 21:57:08 -0000	1.1.2.1
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2001 Ove Kaaven
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine DirectInput"
+#define WINE_FILENAME_STR "dinput.dll"
+#define WINE_FILEVERSION 5,1,2600,881
+#define WINE_FILEVERSION_STR "5.1.2600.881"
+#define WINE_PRODUCTVERSION 5,1,2600,881
+#define WINE_PRODUCTVERSION_STR "5.1"
+
+#include "wine/wine_common_ver.rc"

reactos/lib/dinput
winehq2ros.patch added at 1.1.2.1
diff -N winehq2ros.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ winehq2ros.patch	8 Dec 2004 21:57:08 -0000	1.1.2.1
@@ -0,0 +1,830 @@
+Index: dinput_main.c
+===================================================================
+RCS file: /home/wine/wine/dlls/dinput/dinput_main.c,v
+retrieving revision 1.48
+diff -u -r1.48 dinput_main.c
+--- dinput_main.c	7 Oct 2004 03:06:51 -0000	1.48
++++ dinput_main.c	7 Dec 2004 21:59:12 -0000
+@@ -30,6 +30,8 @@
+  */
+ 
+ #include "config.h"
++#include "wine/port.h"
++
+ #include <assert.h>
+ #include <stdarg.h>
+ #include <string.h>
+@@ -72,7 +74,6 @@
+     return TRUE;
+ }
+ 
+-
+ /* register a direct draw driver. We better not use malloc for we are in
+  * the ELF startup initialisation at this point.
+  */
+@@ -161,10 +162,12 @@
+ {
+ 	IDirectInputImpl* This;
+ 	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
++
++	//trace:dinput:DirectInputCreateA (0x00400000,0500,0x42bafc54,(nil))
+ 	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+ 	This->lpVtbl = &ddi7avt;
+ 	This->ref = 1;
+-	if (dwVersion >= 0x0800) {
++	if (dwVersion > 0x0700) {
+ 	    This->version = 8;
+ 	} else {
+ 	    /* We do not differientiate between version 1, 2 and 7 */
+@@ -245,12 +248,21 @@
+     TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
+ 	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
+ 	  lpCallback, pvRef, dwFlags);
++
++	if (nrof_dinput_devices==0){
++	  scan_mouse();
++	  scan_keyboard();
++	}
++	
+     TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
+     
++
+     for (i = 0; i < nrof_dinput_devices; i++) {
+         for (j = 0, r = -1; r != 0; j++) {
+ 	    devInstance.dwSize = sizeof(devInstance);
+ 	    TRACE("  - checking device %d ('%s')\n", i, dinput_devices[i]->name);
++		
++
+ 	    if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version, j))) {
+ 	        if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
+ 		    return 0;
+@@ -271,11 +283,17 @@
+     DIDEVICEINSTANCEW devInstance;
+     int i, j, r;
+     
++		if (nrof_dinput_devices==0){
++	  scan_mouse();
++	  scan_keyboard();
++	}
++
+     TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
+ 	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
+ 	  lpCallback, pvRef, dwFlags);
+     TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
+-    
++
++
+     for (i = 0; i < nrof_dinput_devices; i++) {
+         for (j = 0, r = -1; r != 0; j++) {
+ 	    devInstance.dwSize = sizeof(devInstance);
+@@ -347,7 +365,12 @@
+ 	int i;
+ 
+ 	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
+-
++	
++	if (nrof_dinput_devices==0){
++	  scan_mouse();
++	  scan_keyboard();
++	}
++	
+ 	/* Loop on all the devices to see if anyone matches the given GUID */
+ 	for (i = 0; i < nrof_dinput_devices; i++) {
+ 	  HRESULT ret;
+@@ -366,9 +389,14 @@
+         IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ 	HRESULT ret_value = DIERR_DEVICENOTREG;
+ 	int i;
+-
++    
+ 	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
+ 
++	if (nrof_dinput_devices==0){
++	  scan_mouse();
++	  scan_keyboard();
++	}
++	
+ 	/* Loop on all the devices to see if anyone matches the given GUID */
+ 	for (i = 0; i < nrof_dinput_devices; i++) {
+ 	  HRESULT ret;
+@@ -429,6 +457,11 @@
+ 
+   TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+ 
++  if (nrof_dinput_devices==0){
++    scan_mouse();
++    scan_keyboard();
++  }  
++
+   /* Loop on all the devices to see if anyone matches the given GUID */
+   for (i = 0; i < nrof_dinput_devices; i++) {
+     HRESULT ret;
+@@ -450,6 +483,13 @@
+   int i;
+ 
+   TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
++
++  	if (nrof_dinput_devices==0){
++	  scan_mouse();
++	  scan_keyboard();
++	}
++  
++
+ 
+   /* Loop on all the devices to see if anyone matches the given GUID */
+   for (i = 0; i < nrof_dinput_devices; i++) {
+Index: dinput_private.h
+===================================================================
+RCS file: /home/wine/wine/dlls/dinput/dinput_private.h,v
+retrieving revision 1.13
+diff -u -r1.13 dinput_private.h
+--- dinput_private.h	13 Sep 2004 19:16:47 -0000	1.13
++++ dinput_private.h	7 Dec 2004 21:59:12 -0000
+@@ -52,4 +52,7 @@
+ 
+ extern HINSTANCE DINPUT_instance;
+ 
++void scan_keyboard();
++void scan_mouse();
++
+ #endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */
+Index: joystick_linux.c
+===================================================================
+RCS file: /home/wine/wine/dlls/dinput/joystick_linux.c,v
+retrieving revision 1.17
+diff -u -r1.17 joystick_linux.c
+--- joystick_linux.c	17 Sep 2004 18:10:41 -0000	1.17
++++ joystick_linux.c	7 Dec 2004 21:59:13 -0000
+@@ -656,6 +656,8 @@
+ 
+ DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
+ 
++
++
+ /******************************************************************************
+  *	Joystick
+  */
+Index: keyboard.c
+===================================================================
+RCS file: /home/wine/wine/dlls/dinput/keyboard.c,v
+retrieving revision 1.10
+diff -u -r1.10 keyboard.c
+--- keyboard.c	28 Oct 2004 21:01:44 -0000	1.10
++++ keyboard.c	7 Dec 2004 21:59:13 -0000
+@@ -37,6 +37,14 @@
+ 
+ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+ 
++//fast fix misning from mingw headers
++#ifdef __REACTOS__
++#define LLKHF_EXTENDED       (KF_EXTENDED >> 8)
++#define LLKHF_INJECTED       0x00000010
++//#define LLKHF_ALTDOWN        (KF_ALTDOWN >> 8)
++#define LLKHF_UP             (KF_UP >> 8)
++#endif
++
+ static IDirectInputDevice8AVtbl SysKeyboardAvt;
+ static IDirectInputDevice8WVtbl SysKeyboardWvt;
+ 
+@@ -84,8 +92,59 @@
+ static CRITICAL_SECTION keyboard_crit = { &critsect_debug, -1, 0, 0, 0, 0 };
+ 
+ static DWORD keyboard_users;
++
++#ifndef __REACTOS__
+ static HHOOK keyboard_hook;
++#endif
++
++#ifdef __REACTOS__
++void reactos_input_keyboard();
++
++void reactos_input_keyboard()
++{
++  MSG msg;
++  BOOL fDone;
++  int disk_code = -1;
++  BOOL down;
++  BYTE oldDInputKeyState[256];
++  int t;
++  
++  memcpy(&oldDInputKeyState,&DInputKeyState,256);
++  GetKeyboardState(DInputKeyState);
++  
++  for( t=0;t<255;t++)
++  {
++	  if (oldDInputKeyState[t]!=DInputKeyState[t]) disk_code=t;	  
++  }
++  	
++
++  if (disk_code!=-1) {
++	  if (current->buffer != NULL)
++     {
++      int n;
++      n = (current->start + current->count) % current->buffersize;
++
++      current->buffer[n].dwOfs = (BYTE) disk_code;
++      current->buffer[n].dwData = DInputKeyState[disk_code];
++      current->buffer[n].dwTimeStamp = 10;
++      current->buffer[n].dwSequence = current->dinput->evsequence++;
++
++	  
++      if (current->count == current->buffersize)
++                {
++                  current->start = ++current->start % current->buffersize;
++                  current->overflow = TRUE;
++                }
++              else
++                current->count++;
++              
++            }
++  }
++
+ 
++}
++#endif
++#ifndef __REACTOS__
+ LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
+ {
+   TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
+@@ -143,6 +202,7 @@
+ 
+   return CallNextHookEx(keyboard_hook, code, wparam, lparam);
+ }
++#endif
+ 
+ static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
+   0x0ab8648a,
+@@ -235,7 +295,7 @@
+   return FALSE;
+ }
+ 
+-static SysKeyboardImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
++static SysKeyboardImpl *alloc_device_keyboard(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
+ {
+     SysKeyboardImpl* newDevice;
+     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
+@@ -244,11 +304,14 @@
+     memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+     newDevice->dinput = dinput;
+ 
++#ifndef __REACTOS__
+     EnterCriticalSection(&keyboard_crit);
++
+     if (!keyboard_users++)
+         keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, DINPUT_instance, 0 );
+-    LeaveCriticalSection(&keyboard_crit);
+ 
++    LeaveCriticalSection(&keyboard_crit);
++#endif
+     return newDevice;
+ }
+ 
+@@ -262,7 +325,7 @@
+ 	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+ 	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+ 	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+-      *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
++      *pdev = (IDirectInputDeviceA*) alloc_device_keyboard(rguid, &SysKeyboardAvt, dinput);
+       TRACE("Creating a Keyboard device (%p)\n", *pdev);
+       return DI_OK;
+     } else
+@@ -280,7 +343,7 @@
+ 	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+ 	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+ 	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+-      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
++      *pdev = (IDirectInputDeviceW*) alloc_device_keyboard(rguid, &SysKeyboardWvt, dinput);
+       TRACE("Creating a Keyboard device (%p)\n", *pdev);
+       return DI_OK;
+     } else
+@@ -289,7 +352,7 @@
+   return DIERR_DEVICENOTREG;
+ }
+ 
+-static dinput_device keyboarddev = {
++dinput_device keyboarddev = {
+   100,
+   "Wine keyboard driver",
+   keyboarddev_enum_deviceA,
+@@ -298,6 +361,11 @@
+   keyboarddev_create_deviceW
+ };
+ 
++void scan_keyboard()
++{
++    dinput_register_device(&keyboarddev);
++}
++
+ DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
+ 
+ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+@@ -309,12 +377,14 @@
+ 	if (ref)
+ 		return ref;
+ 
++#ifndef __REACTOS__
+ 	EnterCriticalSection(&keyboard_crit);
+ 	if (!--keyboard_users) {
+ 	    UnhookWindowsHookEx( keyboard_hook );
+ 	    keyboard_hook = 0;
+ 	}
+ 	LeaveCriticalSection(&keyboard_crit);
++#endif
+ 
+ 	/* Free the data queue */
+ 	if (This->buffer != NULL)
+@@ -357,11 +427,16 @@
+ 	return DI_OK;
+ }
+ 
++
+ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
+ 	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
+ )
+ {
+     TRACE("(%p)->(%ld,%p)\n", iface, len, ptr);
++	
++#ifdef __REACTOS__
++	reactos_input_keyboard();
++#endif
+ 
+     /* Note: device does not need to be acquired */
+     if (len != 256)
+@@ -387,8 +462,12 @@
+ 	LPDWORD entries,DWORD flags
+ )
+ {
++	
+ 	SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+ 	int ret = DI_OK, i = 0;
++#ifdef __REACTOS__
++     reactos_input_keyboard();
++#endif
+ 
+ 	TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
+ 	      This,dodsize,dod,entries,entries?*entries:0,flags);
+@@ -523,6 +602,7 @@
+           }
+         else
+           This->buffer = NULL;
++
+ 
+ 	return DI_OK;
+ }
+Index: mouse.c
+===================================================================
+RCS file: /home/wine/wine/dlls/dinput/mouse.c,v
+retrieving revision 1.12
+diff -u -r1.12 mouse.c
+--- mouse.c	21 Sep 2004 20:04:37 -0000	1.12
++++ mouse.c	7 Dec 2004 21:59:14 -0000
+@@ -40,6 +40,13 @@
+ #define MOUSE_HACK
+ 
+ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
++typedef struct {
++                     POINT pt;
++                     DWORD mouseData;
++                     DWORD flags;
++                     DWORD time;
++                     ULONG_PTR dwExtraInfo;
++} MSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;
+ 
+ /* Wine mouse driver object instances */
+ #define WINE_MOUSE_X_AXIS_INSTANCE   0
+@@ -148,6 +155,9 @@
+ /* FIXME: This is ugly and not thread safe :/ */
+ static IDirectInputDevice8A* current_lock = NULL;
+ 
++/* FIXME: This is ugly but needed on Windows */
++static int mouse_set = 0;
++
+ static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
+     0x9e573ed8,
+     0x7734,
+@@ -239,7 +249,7 @@
+     return FALSE;
+ }
+ 
+-static SysMouseImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
++static SysMouseImpl *alloc_device_mouse(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
+ {
+     int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
+ 	FIELD_OFFSET(Wine_InternalMouseData, lX),
+@@ -253,7 +263,9 @@
+     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
+     newDevice->ref = 1;
+     newDevice->lpVtbl = mvt;
++#ifndef __REACTOS__
+     InitializeCriticalSection(&(newDevice->crit));
++#endif
+     memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+ 
+     /* Per default, Wine uses its internal data format */
+@@ -277,7 +289,7 @@
+ 	    IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
+ 	    IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
+ 	    IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
+-	    *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
++	    *pdev = (IDirectInputDeviceA*) alloc_device_mouse(rguid, &SysMouseAvt, dinput);
+ 	    TRACE("Creating a Mouse device (%p)\n", *pdev);
+ 	    return DI_OK;
+ 	} else
+@@ -296,7 +308,7 @@
+ 	    IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+ 	    IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+ 	    IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+-	    *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
++	    *pdev = (IDirectInputDeviceW*) alloc_device_mouse(rguid, &SysMouseWvt, dinput);
+ 	    TRACE("Creating a Mouse device (%p)\n", *pdev);
+ 	    return DI_OK;
+ 	} else
+@@ -305,6 +317,7 @@
+     
+     return DIERR_DEVICENOTREG;
+ }
++
+ static dinput_device mousedev = {
+     100,
+     "Wine mouse driver",
+@@ -314,6 +327,11 @@
+     mousedev_create_deviceW
+ };
+ 
++void scan_mouse()
++{
++    dinput_register_device(&mousedev);
++}
++
+ DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
+ 
+ /******************************************************************************
+@@ -335,14 +353,21 @@
+     /* Free the data queue */
+     if (This->data_queue != NULL)
+ 	HeapFree(GetProcessHeap(),0,This->data_queue);
+-    
++
++#ifndef __REACTOS__
+     if (This->hook) {
+ 	UnhookWindowsHookEx( This->hook );
+ 	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+             ShowCursor(TRUE); /* show cursor */
+     }
+     DeleteCriticalSection(&(This->crit));
++#endif
++
++#ifdef __REACTOS__
++if (This->dwCoopLevel & DISCL_EXCLUSIVE)
++            ShowCursor(TRUE); /* show cursor */
+     
++#endif
+     /* Free the DataFormat */
+     if (This->df != &(Wine_InternalMouseFormat)) {
+ 	HeapFree(GetProcessHeap(), 0, This->df->rgodf);
+@@ -585,9 +610,13 @@
+     
+     TRACE("(this=%p)\n",This);
+     
++	
++
+     if (This->acquired == 0) {
+ 	POINT point;
+ 	
++	
++
+ 	/* Store (in a global variable) the current lock */
+ 	current_lock = (IDirectInputDevice8A*)This;
+ 	
+@@ -611,8 +640,9 @@
+ 	/* Install our mouse hook */
+ 	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+ 	    ShowCursor(FALSE); /* hide cursor */
++#ifndef __REACTOS__
+ 	This->hook = SetWindowsHookExA( WH_MOUSE_LL, dinput_mouse_hook, DINPUT_instance, 0 );
+-	
++#endif	
+ 	/* Get the window dimension and find the center */
+ 	GetWindowRect(This->win, &rect);
+ 	This->win_centerX = (rect.right  - rect.left) / 2;
+@@ -649,6 +679,8 @@
+     
+     if (This->acquired) {
+ 	/* Reinstall previous mouse event handler */
++
++#ifndef __REACTOS__
+ 	if (This->hook) {
+ 	    UnhookWindowsHookEx( This->hook );
+ 	    This->hook = 0;
+@@ -656,7 +688,12 @@
+ 	    if (This->dwCoopLevel & DISCL_EXCLUSIVE)
+ 		ShowCursor(TRUE); /* show cursor */
+         }
+-	
++#endif
++#ifdef __REACTOS__
++	if (This->dwCoopLevel & DISCL_EXCLUSIVE)
++		ShowCursor(TRUE); /* show cursor */
++#endif
++
+         /* No more locks */
+         current_lock = NULL;
+ 	
+@@ -675,6 +712,76 @@
+     return DI_OK;
+ }
+ 
++// if you call poll then to getdevicestate
++// it did not send back right value in windows 
++int poll_mouse=0;
++
++#ifdef __REACTOS__
++void getmousesvalue(LPDIRECTINPUTDEVICE8A iface);
++int filp=0;
++void getmousesvalue(LPDIRECTINPUTDEVICE8A iface)
++{
++	static long last_event = 0;
++
++    POINT point;
++	SysMouseImpl *This = (SysMouseImpl *)iface;        
++
++	This->m_state.rgbButtons[0] =  ((GetKeyState(VK_LBUTTON) & 0x80) ? 0xFF : 0x00);	
++	This->m_state.rgbButtons[1] =  ((GetKeyState(VK_RBUTTON) & 0x80) ? 0xFF : 0x00);	
++	This->m_state.rgbButtons[2] =  ((GetKeyState(VK_MBUTTON) & 0x80) ? 0xFF : 0x00);	
++	This->m_state.rgbButtons[3] =  ((GetKeyState(VK_XBUTTON1) & 0x80) ? 0xFF : 0x00);	
++	This->m_state.rgbButtons[4] =  ((GetKeyState(VK_XBUTTON2) & 0x80) ? 0xFF : 0x00);	
++
++    
++	
++
++	if (poll_mouse==1) filp=0;
++	if (filp==2) filp=0;
++	if (filp==0) {
++                  GetCursorPos( &point );   	
++		
++	if (This->prevX == point.x) This->m_state.lX = 0;
++	else {
++          This->prevX = point.x;
++          This->m_state.lX = point.x - This->org_coords.x; 
++	      } 
++
++	if (This->prevY == point.y) This->m_state.lY = 0;
++	else {
++         This->prevY = point.y;
++          This->m_state.lY = point.y - This->org_coords.y; 
++	    } 
++
++   	}
++	else 
++	{
++	 This->m_state.lX = 0;
++     This->m_state.lY = 0;	 
++	}
++    filp++;
++    
++// check see if buffer have been set
++
++}
++
++#endif
++
++static HRESULT WINAPI SysMouseAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
++{
++ int retValue = DI_OK;
++ 
++SysMouseImpl *This = (SysMouseImpl *)iface;           
++ if (poll_mouse==0) {
++	                 retValue=SysMouseAImpl_Acquire(iface);	
++                     poll_mouse=1; 
++					 if (retValue!=DI_OK) retValue=DIERR_NOTACQUIRED;
++                     else retValue = DI_OK;
++                     }
++
++ return retValue;
++}
++	
++
+ /******************************************************************************
+   *     GetDeviceState : returns the "state" of the mouse.
+   *
+@@ -684,26 +791,42 @@
+ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
+ 	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
+ ) {
+-    SysMouseImpl *This = (SysMouseImpl *)iface;
+-    
++    SysMouseImpl *This = (SysMouseImpl *)iface;        
++    POINT point;    	 
++
++#ifndef __REACTOS__
+     EnterCriticalSection(&(This->crit));
++#endif
++
++#ifdef __REACTOS__
++getmousesvalue(iface);
++#endif
+     TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
+-    
+-    /* Copy the current mouse state */
++    	
++    /* Copy the current mouse state */	   
+     fill_DataFormat(ptr, &(This->m_state), This->wine_df);
+-    
+-    /* Initialize the buffer when in relative mode */
+-    if (This->absolute == 0) {
+-	This->m_state.lX = 0;
+-	This->m_state.lY = 0;
+-	This->m_state.lZ = 0;
+-    }
+-    
++
++
++	// this fix windows bugs when 
++	// some program calling on mouse poll
++	if (poll_mouse==1) poll_mouse=0;		 
++	else {
++	      if (This->absolute == 0) {
++	                       This->m_state.lX = 0;
++	                       This->m_state.lY = 0;
++	                       This->m_state.lZ = 0;
++	                       } 
++	     }
++	
++	
+     /* Check if we need to do a mouse warping */
+     if (This->need_warp == WARP_NEEDED) {
+ 	dinput_window_check(This);
+-	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
+-	SetCursorPos( This->mapped_center.x, This->mapped_center.y );
++	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);	
++        if (mouse_set==0){
++           SetCursorPos( This->mapped_center.x, This->mapped_center.y );
++           mouse_set++;
++           }
+ 	
+ #ifdef MOUSE_HACK
+ 	This->need_warp = WARP_DONE;
+@@ -711,9 +834,11 @@
+ 	This->need_warp = WARP_STARTED;
+ #endif
+     }
+-    
++
++#ifndef __REACTOS__
+     LeaveCriticalSection(&(This->crit));
+-    
++#endif
++
+     TRACE("(X: %ld - Y: %ld - Z: %ld  L: %02x M: %02x R: %02x)\n",
+ 	  This->m_state.lX, This->m_state.lY, This->m_state.lZ,
+ 	  This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
+@@ -724,6 +849,7 @@
+ /******************************************************************************
+   *     GetDeviceState : gets buffered input data.
+   */
++
+ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
+ 						  DWORD dodsize,
+ 						  LPDIDEVICEOBJECTDATA dod,
+@@ -733,16 +859,73 @@
+     SysMouseImpl *This = (SysMouseImpl *)iface;
+     DWORD len;
+     int nqtail;
++#ifdef __REACTOS__
++static int last_event=0;
++const int size = sizeof(DIDEVICEOBJECTDATA) * 1;
++static count=0;
++static DWORD time=0;
++#endif
++
+     
+     TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
+     
++#ifdef __REACTOS__
++getmousesvalue(iface);
++#endif
++
++	// windows does not get any data if 
++	// we do not call manual to mouse Acquire
++	// this is only need if some apps calling on getdevice data direcly
++	// in windows GetdeviceData does always update first the data
++	// then return it.
++	SysMouseAImpl_Acquire(iface);
++
++
+     if (This->acquired == 0) {
+ 	WARN(" application tries to get data from an unacquired device !\n");
+ 	return DIERR_NOTACQUIRED;
+     }
+     
++#ifdef __REACTOS__	
++  FIXME("This is broken in Tribes, need right implant of the buffer!!!!!!!!\n"); 
++
++  *entries = 5;
++  if (GetTickCount()-time <50) return DI_OK;
++  time = GetTickCount();
++   
++  dod[0].dwOfs =   DIMOFS_X;
++  dod[0].dwData =   This->m_state.lX;
++  dod[0].dwTimeStamp =  0;
++  dod[0].dwSequence = last_event++;
++   
++  dod[1].dwOfs =   DIMOFS_Y;
++  dod[1].dwData =   This->m_state.lY;
++  dod[1].dwTimeStamp =  0;
++  dod[1].dwSequence = last_event++;
++  
++  dod[2].dwOfs =   DIMOFS_BUTTON0;
++  dod[2].dwData =   This->m_state.rgbButtons[0];
++  dod[2].dwTimeStamp =  0;
++  dod[2].dwSequence = last_event++;
++  
++  dod[3].dwOfs =   DIMOFS_BUTTON1;
++  dod[3].dwData =   This->m_state.rgbButtons[1];
++  dod[3].dwTimeStamp =  0;
++  dod[0].dwSequence = last_event++;
++  
++  dod[4].dwOfs =   DIMOFS_BUTTON2;
++  dod[4].dwData =   This->m_state.rgbButtons[2];
++  dod[4].dwTimeStamp =  50;
++  dod[4].dwSequence = last_event++;
++
++#endif
++
++#ifndef __REACTOS__
+     EnterCriticalSection(&(This->crit));
+-    
++
++
++	// FIXME mouse are bit choppy here. 
++
+     len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
+ 	+ (This->queue_head - This->queue_tail);
+     if (len > *entries) len = *entries;
+@@ -757,7 +940,9 @@
+     } else {
+ 	if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
+ 	    ERR("Wrong structure size !\n");
++
+ 	    LeaveCriticalSection(&(This->crit));
++
+ 	    return DIERR_INVALIDPARAM;
+ 	}
+ 	
+@@ -773,6 +958,7 @@
+ 	    
+ 	    /* Copy the buffered data into the application queue */
+ 	    memcpy(dod + *entries, This->data_queue + nqtail, span * dodsize);
++
+ 	    /* Advance position */
+ 	    nqtail += span;
+ 	    if (nqtail >= This->queue_len) nqtail -= This->queue_len;
+@@ -782,14 +968,19 @@
+     }
+     if (!(flags & DIGDD_PEEK))
+ 	This->queue_tail = nqtail;
+-    
++
+     LeaveCriticalSection(&(This->crit));
+-    
++
+     /* Check if we need to do a mouse warping */
++   
++
+     if (This->need_warp == WARP_NEEDED) {
+ 	dinput_window_check(This);
+ 	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
+-	SetCursorPos( This->mapped_center.x, This->mapped_center.y );
++        if (mouse_set==0){
++           SetCursorPos( This->mapped_center.x, This->mapped_center.y );
++           mouse_set++;
++           }
+ 	
+ #ifdef MOUSE_HACK
+ 	This->need_warp = WARP_DONE;
+@@ -797,6 +988,7 @@
+ 	This->need_warp = WARP_STARTED;
+ #endif
+     }
++#endif    
+     return DI_OK;
+ }
+ 
+@@ -1110,7 +1302,7 @@
+     IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+     IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+     IDirectInputDevice2AImpl_Escape,
+-    IDirectInputDevice2AImpl_Poll,
++    SysMouseAImpl_Poll,
+     IDirectInputDevice2AImpl_SendDeviceData,
+     IDirectInputDevice7AImpl_EnumEffectsInFile,
+     IDirectInputDevice7AImpl_WriteEffectToFile,
+@@ -1152,7 +1344,7 @@
+     XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+     XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+     XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+-    XCAST(Poll)IDirectInputDevice2AImpl_Poll,
++    XCAST(Poll)SysMouseAImpl_Poll,
+     XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+     IDirectInputDevice7WImpl_EnumEffectsInFile,
+     IDirectInputDevice7WImpl_WriteEffectToFile,

reactos/lib/dinput
Makefile 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile	29 May 2004 21:24:43 -0000	1.2
+++ Makefile	8 Dec 2004 21:57:07 -0000	1.2.16.1
@@ -1,30 +1,9 @@
-PATH_TO_TOP = ../..
-
-TARGET_TYPE = dynlink
-
-TARGET_NORC = yes
-
-TARGET_NAME = dinput
-
-# -fno-builtin
-TARGET_CFLAGS = -D__USE_W32API
-
-# require os code to explicitly request A/W version of structs/functions
-TARGET_CFLAGS += -D_DISABLE_TIDENTS -Wall -Werror
+# $Id: Makefile,v 1.2.16.1 2004/12/08 21:57:07 hyperion Exp $
 
-TARGET_SDKLIBS = ntdll.a gdi32.a
-
-TARGET_BASE = $(TARGET_BASE_LIB_DINPUT)
-
-TARGET_OBJECTS = \
-	dinput.o
+PATH_TO_TOP = ../..
 
-DEP_OBJECTS = $(TARGET_OBJECTS)
+TARGET_TYPE = winedll
 
 include $(PATH_TO_TOP)/rules.mak
 
 include $(TOOLS_PATH)/helper.mk
-
-include $(TOOLS_PATH)/depend.mk
-
-# EOF

reactos/lib/dinput
dinput.c removed after 1.1
diff -N dinput.c
--- dinput.c	3 Feb 2004 23:09:48 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-/* $Id: dinput.c,v 1.1 2004/02/03 23:09:48 rcampbell Exp $
- *
- * COPYRIGHT:            See COPYING in the top level directory
- * PROJECT:              ReactOS kernel
- * FILE:                 lib/opengl32/opengl32.c
- * PURPOSE:              OpenGL32 lib
- * PROGRAMMER:           Anich Gregor (blight), Royce Mitchell III
- * UPDATE HISTORY:
- *                       Feb 1, 2004: Created
- */
-
-#include <windows.h>
-//#include <ddraw.h>
-
- #define DD_OK 0
- 
-HRESULT STDCALL DirectInputCreateEx(
-	HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
-	LPUNKNOWN punkOuter )
-{
-	return DD_OK;
-}
-
-HRESULT STDCALL DirectInputCreateA(HINSTANCE hinstance, DWORD version, DWORD **p, void* punk)
-{
-	return DD_OK;
-}
-
-BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD fwdReason, LPVOID lpvReserved)
-{
-    switch(fwdReason)
-    {
-        case DLL_PROCESS_ATTACH:
-            break;
-        case DLL_THREAD_ATTACH:
-            break;
-        case DLL_PROCESS_DETACH:
-            break;
-        case DLL_THREAD_DETACH:
-            break;
-    }
-    return(TRUE);
-} 

reactos/lib/dinput
dinput.def removed after 1.1
diff -N dinput.def
--- dinput.def	16 Sep 2004 10:25:13 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,7 +0,0 @@
-EXPORTS
-  DirectInputCreateA@16 @1
-  DirectInputCreateEx@20 @2
-  ;DllCanUnloadNow@0=DINPUT_DllCanUnloadNow@0 @4
-  ;DllGetClassObject@12=DINPUT_DllGetClassObject@12 @5
-  ;DllRegisterServer@0=DINPUT_DllRegisterServer@0 @6
-  ;DllUnregisterServer@0=DINPUT_DllUnregisterServer@0 @7

reactos/lib/dnsapi
Makefile 1.5 -> 1.5.16.1
diff -u -r1.5 -r1.5.16.1
--- Makefile	29 May 2004 21:24:43 -0000	1.5
+++ Makefile	8 Dec 2004 21:57:08 -0000	1.5.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.5 2004/05/29 21:24:43 hbirr Exp $
+# $Id: Makefile,v 1.5.16.1 2004/12/08 21:57:08 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -20,7 +20,7 @@
 TARGET_GCCLIBS = gcc
 
 TARGET_CFLAGS = -Werror -Wall -I$(PATH_TO_TOP)/lib/adns/src -Iinclude \
-	-I$(PATH_TO_TOP)/lib/adns/adns_win32  -g
+	-I$(PATH_TO_TOP)/lib/adns/adns_win32  -g -D__USE_W32API
 
 # require os code to explicitly request A/W version of structs/functions
 TARGET_CFLAGS += -D_DISABLE_TIDENTS -DADNS_JGAA_WIN32

reactos/lib/dnsapi/dnsapi
adns.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- adns.c	18 Dec 2003 10:54:02 -0000	1.1
+++ adns.c	8 Dec 2004 21:57:08 -0000	1.1.24.1
@@ -10,7 +10,7 @@
 
 #include <windows.h>
 #include <WinError.h>
-#include <WinDNS.h>
+#include <windns.h>
 #include <internal/windns.h>
 
 DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS( int Status ) {
@@ -20,7 +20,7 @@
   case adns_s_nomemory:
   case adns_s_systemfail:
   default: /* There really aren't any general errors in the dns part. */
-    return DNS_ERROR_NO_MEMORY;
+    return ERROR_OUTOFMEMORY;
   }
 }
 

reactos/lib/dnsapi/dnsapi
context.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- context.c	18 Dec 2003 10:54:02 -0000	1.1
+++ context.c	8 Dec 2004 21:57:08 -0000	1.1.24.1
@@ -10,7 +10,9 @@
 
 #include <windows.h>
 #include <WinError.h>
-#include <WinDNS.h>
+#include <windns.h>
+#define NTOS_MODE_USER
+#include <ntos.h>
 #include <internal/windns.h>
 
 /* DnsAcquireContextHandle *************

reactos/lib/dnsapi/dnsapi
free.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- free.c	18 Dec 2003 10:54:02 -0000	1.1
+++ free.c	8 Dec 2004 21:57:08 -0000	1.1.24.1
@@ -10,8 +10,10 @@
 
 #include <windows.h>
 #include <WinError.h>
-#include <WinDNS.h>
+#include <windns.h>
 #include <internal/windns.h>
+#define NTOS_MODE_USER
+#include <ntos.h>
 
 VOID WINAPI DnsFree
 ( PVOID Data, DNS_FREE_TYPE FreeType ) {
@@ -21,7 +23,7 @@
     break;
 
   case DnsFreeRecordList:
-    DnsIntFreeRecordList( (PDNS_RECORDA)Data );
+    DnsIntFreeRecordList( (PDNS_RECORD)Data );
     break;
 
   case DnsFreeParsedMessageFields:
@@ -31,6 +33,6 @@
 }
 
 VOID WINAPI DnsRecordListFree
-( PVOID Data, DNS_FREE_TYPE FreeType ) {
+( PDNS_RECORD Data, DNS_FREE_TYPE FreeType ) {
   DnsFree( Data, FreeType );
 }

reactos/lib/dnsapi/dnsapi
names.c 1.3 -> 1.3.22.1
diff -u -r1.3 -r1.3.22.1
--- names.c	5 Feb 2004 16:26:39 -0000	1.3
+++ names.c	8 Dec 2004 21:57:08 -0000	1.3.22.1
@@ -1,7 +1,9 @@
 #include <windows.h>
 #include <WinError.h>
-#include <WinDNS.h>
+#include <windns.h>
 #include <internal/windns.h>
+#define NTOS_MODE_USER
+#include <ntos.h>
 #include <wchar.h>
 #include <string.h>
 #include <ctype.h>
@@ -192,8 +194,8 @@
 }
 
 BOOL WINAPI DnsNameCompare_A
-( LPCSTR Name1,
-  LPCSTR Name2 ) {
+( LPSTR Name1,
+  LPSTR Name2 ) {
   return DnsNameCompare_UTF8( Name1, Name2 );
 }
 

reactos/lib/dnsapi/dnsapi
query.c 1.2 -> 1.2.24.1
diff -u -r1.2 -r1.2.24.1
--- query.c	25 Dec 2003 05:50:37 -0000	1.2
+++ query.c	8 Dec 2004 21:57:08 -0000	1.2.24.1
@@ -10,9 +10,11 @@
 
 #include <windows.h>
 #include <WinError.h>
-#include <WinDNS.h>
+#include <windns.h>
 #include <internal/windns.h>
 #include <string.h>
+#define NTOS_MODE_USER
+#include <ntos.h>
 
 /* DnsQuery ****************************
  * Begin a DNS query, and allow the result to be placed in the application
@@ -45,7 +47,7 @@
   WORD Type,
   DWORD Options,
   PIP4_ARRAY Servers,
-  PDNS_RECORDA *QueryResultSet,
+  PDNS_RECORD *QueryResultSet,
   PVOID *Reserved ) {
   adns_state astate;
   int quflags = 0;
@@ -77,18 +79,22 @@
       return DnsIntTranslateAdnsToDNS_STATUS( adns_error );
     }
 
-    *QueryResultSet = (PDNS_RECORDA)RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-						     sizeof( DNS_RECORDA ) );
-    (*QueryResultSet)->wType = Type;
-    (*QueryResultSet)->pName = xstrsave( Name );
-    (*QueryResultSet)->wDataLength = sizeof(DNS_A_DATA);
-    (*QueryResultSet)->Data.A.IpAddress = 
-      answer->rrs.addr->addr.inet.sin_addr.s_addr;
-    adns_finish( astate );
-    return ERROR_SUCCESS;
-    
+    if( answer && answer->rrs.addr ) {
+	*QueryResultSet = 
+	    (PDNS_RECORD)RtlAllocateHeap( RtlGetProcessHeap(), 0,
+					  sizeof( DNS_RECORD ) );
+	(*QueryResultSet)->pNext = NULL;
+	(*QueryResultSet)->wType = Type;
+	(*QueryResultSet)->pName = xstrsave( Name );
+	(*QueryResultSet)->wDataLength = sizeof(DNS_A_DATA);
+	(*QueryResultSet)->Data.A.IpAddress = 
+	    answer->rrs.addr->addr.inet.sin_addr.s_addr;
+	adns_finish( astate );
+	return ERROR_SUCCESS;
+    } else
+	return ERROR_FILE_NOT_FOUND;
   default:
-    return DNS_ERROR_NO_MEMORY; /* XXX arty: find a better error code. */
+    return ERROR_OUTOFMEMORY; /* XXX arty: find a better error code. */
   }
 }
 
@@ -112,13 +118,13 @@
   WORD Type,
   DWORD Options,
   PIP4_ARRAY Servers,
-  PDNS_RECORDW *QueryResultSet,
+  PDNS_RECORD *QueryResultSet,
   PVOID *Reserved ) {
   int i;
   PCHAR Buffer;
   DNS_STATUS Status;
-  PDNS_RECORDA QueryResultWide;
-  PDNS_RECORDW ConvertedRecord = 0, LastRecord = 0;
+  PDNS_RECORD QueryResultWide;
+  PDNS_RECORD ConvertedRecord = 0, LastRecord = 0;
 
   Buffer = DnsWToC( Name );
 
@@ -129,11 +135,13 @@
     switch( QueryResultWide->wType ) {
     case DNS_TYPE_A:
     case DNS_TYPE_WKS:
+#ifndef __USE_W32API
     case DNS_TYPE_AAAA:
     case DNS_TYPE_KEY:
+#endif
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-					 sizeof(DNS_RECORDA) );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+					 sizeof(DNS_RECORD) );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
       ConvertedRecord->wDataLength = QueryResultWide->wDataLength;
       memcpy( ConvertedRecord, QueryResultWide, 
@@ -149,57 +157,63 @@
     case DNS_TYPE_MG:
     case DNS_TYPE_MR:
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-					 sizeof(DNS_RECORDA) );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+					 sizeof(DNS_RECORD) );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
-      ConvertedRecord->wDataLength = sizeof(DNS_PTR_DATAA);
+      ConvertedRecord->wDataLength = sizeof(DNS_PTR_DATA);
       ConvertedRecord->Data.PTR.pNameHost = 
-	DnsCToW( QueryResultWide->Data.PTR.pNameHost );
+	  (PCHAR)DnsCToW( QueryResultWide->Data.PTR.pNameHost );
       break;
     case DNS_TYPE_MINFO:
+#ifndef __USE_W32API
     case DNS_TYPE_RP:
+#endif
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-					 sizeof(DNS_RECORDA) );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+					 sizeof(DNS_RECORD) );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
-      ConvertedRecord->wDataLength = sizeof(DNS_MINFO_DATAA);
+      ConvertedRecord->wDataLength = sizeof(DNS_MINFO_DATA);
       ConvertedRecord->Data.MINFO.pNameMailbox =
-	DnsCToW( QueryResultWide->Data.MINFO.pNameMailbox );
+	  (PCHAR)DnsCToW( QueryResultWide->Data.MINFO.pNameMailbox );
       ConvertedRecord->Data.MINFO.pNameErrorsMailbox =
-	DnsCToW( QueryResultWide->Data.MINFO.pNameErrorsMailbox );
+	  (PCHAR)DnsCToW( QueryResultWide->Data.MINFO.pNameErrorsMailbox );
       break;
 
     case DNS_TYPE_MX:
+#ifndef __USE_W32API
     case DNS_TYPE_AFSDB:
     case DNS_TYPE_RT:
+#endif
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-					 sizeof(DNS_RECORDA) );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+					 sizeof(DNS_RECORD) );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
-      ConvertedRecord->wDataLength = sizeof(DNS_MX_DATAW);
+      ConvertedRecord->wDataLength = sizeof(DNS_MX_DATA);
       ConvertedRecord->Data.MX.pNameExchange = 
-	DnsCToW( QueryResultWide->Data.MX.pNameExchange );
+	  (PCHAR)DnsCToW( QueryResultWide->Data.MX.pNameExchange );
       ConvertedRecord->Data.MX.wPreference =
-	QueryResultWide->Data.MX.wPreference;
+	  QueryResultWide->Data.MX.wPreference;
       break;
 
+#ifndef __USE_W32API
     case DNS_TYPE_TXT:
-    case DNS_TYPE_HINFO:
     case DNS_TYPE_ISDN:
+#endif
+    case DNS_TYPE_HINFO:
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
-					 sizeof(DNS_TXT_DATAW) + 
+					 sizeof(DNS_TXT_DATA) + 
 					 QueryResultWide->
 					 Data.TXT.dwStringCount );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
       ConvertedRecord->wDataLength = 
-	sizeof(DNS_TXT_DATAW) + 
+	sizeof(DNS_TXT_DATA) + 
 	(sizeof(PWCHAR) * QueryResultWide->Data.TXT.dwStringCount);
       ConvertedRecord->Data.TXT.dwStringCount = 
 	QueryResultWide->Data.TXT.dwStringCount;
       for( i = 0; i < ConvertedRecord->Data.TXT.dwStringCount; i++ ) {
 	ConvertedRecord->Data.TXT.pStringArray[i] = 
-	  DnsCToW( QueryResultWide->Data.TXT.pStringArray[i] );
+	    (PCHAR)DnsCToW( QueryResultWide->Data.TXT.pStringArray[i] );
       }
       break;
 
@@ -208,7 +222,7 @@
 					 sizeof(DNS_NULL_DATA) + 
 					 QueryResultWide->
 					 Data.Null.dwByteCount );
-      ConvertedRecord->pName = DnsCToW( QueryResultWide->pName );
+      ConvertedRecord->pName = (PCHAR)DnsCToW( QueryResultWide->pName );
       ConvertedRecord->wType = QueryResultWide->wType;
       ConvertedRecord->wDataLength =
 	sizeof(DNS_NULL_DATA) + QueryResultWide->Data.Null.dwByteCount;
@@ -219,6 +233,7 @@
 	      QueryResultWide->Data.Null.dwByteCount );
       break;
 
+#ifndef __USE_W32API
     case DNS_TYPE_SIG:
       ConvertedRecord = RtlAllocateHeap( RtlGetProcessHeap(), 0, 
 					 sizeof(DNS_RECORDA) );
@@ -257,6 +272,7 @@
       ConvertedRecord->Data.SRV.pNameTarget =
 	DnsCToW( QueryResultWide->Data.SRV.pNameTarget );
       break;
+#endif
     }
 
     if( LastRecord ) {
@@ -280,69 +296,75 @@
   WORD Type,
   DWORD Options,
   PIP4_ARRAY Servers,
-  PDNS_RECORDA *QueryResultSet,
+  PDNS_RECORD *QueryResultSet,
   PVOID *Reserved ) {
   return DnsQuery_UTF8( Name, Type, Options, Servers, QueryResultSet, 
 			Reserved );
 }
 
-void DnsIntFreeRecordList( PDNS_RECORDA ToDelete ) {
+void DnsIntFreeRecordList( PDNS_RECORD ToDelete ) {
   int i;
-  PDNS_RECORDA next = 0;
+  PDNS_RECORD next = 0;
 
   while( ToDelete ) {
-    if( ToDelete->pName ) 
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->pName );
-    switch( ToDelete->wType ) {
-    case DNS_TYPE_CNAME:
-    case DNS_TYPE_PTR:
-    case DNS_TYPE_NS:
-    case DNS_TYPE_MB:
-    case DNS_TYPE_MD:
-    case DNS_TYPE_MF:
-    case DNS_TYPE_MG:
-    case DNS_TYPE_MR:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.PTR.pNameHost );
-      break;
-    case DNS_TYPE_MINFO:
-    case DNS_TYPE_RP:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, 
-		   ToDelete->Data.MINFO.pNameMailbox );
-      RtlFreeHeap( RtlGetProcessHeap(), 0,
-		   ToDelete->Data.MINFO.pNameErrorsMailbox );
-      break;
-
-    case DNS_TYPE_MX:
-    case DNS_TYPE_AFSDB:
-    case DNS_TYPE_RT:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.MX.pNameExchange );
-      break;
-
-    case DNS_TYPE_TXT:
-    case DNS_TYPE_HINFO:
-    case DNS_TYPE_ISDN:
-      for( i = 0; i < ToDelete->Data.TXT.dwStringCount; i++ ) {
-	RtlFreeHeap( RtlGetProcessHeap(), 0, 
-		     ToDelete->Data.TXT.pStringArray[i] );
+      if( ToDelete->pName ) 
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->pName );
+      switch( ToDelete->wType ) {
+      case DNS_TYPE_CNAME:
+      case DNS_TYPE_PTR:
+      case DNS_TYPE_NS:
+      case DNS_TYPE_MB:
+      case DNS_TYPE_MD:
+      case DNS_TYPE_MF:
+      case DNS_TYPE_MG:
+      case DNS_TYPE_MR:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.PTR.pNameHost );
+	  break;
+      case DNS_TYPE_MINFO:
+#ifndef __USE_W32API
+      case DNS_TYPE_RP:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, 
+		       ToDelete->Data.MINFO.pNameMailbox );
+	  RtlFreeHeap( RtlGetProcessHeap(), 0,
+		       ToDelete->Data.MINFO.pNameErrorsMailbox );
+	  break;
+	  
+      case DNS_TYPE_AFSDB:
+      case DNS_TYPE_RT:
+#endif
+      case DNS_TYPE_MX:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.MX.pNameExchange );
+	  break;
+	  
+#ifndef __USE_W32API
+      case DNS_TYPE_TXT:
+      case DNS_TYPE_ISDN:
+#endif
+      case DNS_TYPE_HINFO:
+	  for( i = 0; i < ToDelete->Data.TXT.dwStringCount; i++ ) {
+	      RtlFreeHeap( RtlGetProcessHeap(), 0, 
+			   ToDelete->Data.TXT.pStringArray[i] );
+	  }
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.TXT.pStringArray );
+	  break;
+	  
+#ifndef __USE_W32API
+      case DNS_TYPE_SIG:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.SIG.pNameSigner );
+	  break;
+	  
+      case DNS_TYPE_NXT:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.NXT.pNameNext );
+	  break;
+	  
+      case DNS_TYPE_SRV:
+	  RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.SRV.pNameTarget );
+	  break;
+#endif
       }
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.TXT.pStringArray );
-      break;
-
-    case DNS_TYPE_SIG:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.SIG.pNameSigner );
-      break;
-
-    case DNS_TYPE_NXT:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.NXT.pNameNext );
-      break;
-
-    case DNS_TYPE_SRV:
-      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete->Data.SRV.pNameTarget );
-      break;
-    }
-
-    next = ToDelete->pNext;
-    RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete );
-    ToDelete = next;
+      
+      next = ToDelete->pNext;
+      RtlFreeHeap( RtlGetProcessHeap(), 0, ToDelete );
+      ToDelete = next;
   }
 }

reactos/lib/dnsapi/dnsapi
stubs.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- stubs.c	18 Dec 2003 11:38:00 -0000	1.1
+++ stubs.c	8 Dec 2004 21:57:08 -0000	1.1.24.1
@@ -1,579 +1,583 @@
 #include <windows.h>
-#include <WinDNS.h>
+/*#include <windns.h>*/
 #include <WinError.h>
+#define NTOS_MODE_USER
+#include <ntos.h>
 #include <debug.h>
 
+typedef ULONG DNS_STATUS;
+
 DNS_STATUS WINAPI DnsAddRecordSet_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAddRecordSet_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAddRecordSet_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAllocateRecord() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsApiHeapReset() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAsyncRegisterHostAddrs_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAsyncRegisterHostAddrs_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAsyncRegisterHostAddrs_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAsyncRegisterInit() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsAsyncRegisterTerm() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCheckNameCollision_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCheckNameCollision_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCheckNameCollision_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCopyStringEx() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCreateReverseNameStringForIpAddress() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCreateStandardDnsNameCopy() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsCreateStringCopy() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDhcpSrvRegisterHostName_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDhcpSrvRegisterInit() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDhcpSrvRegisterTerm() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDisableAdapterDomainNameRegistration() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDisableBNodeResolverThread() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDisableDynamicRegistration() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsDowncaseDnsNameLabel() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsEnableAdapterDomainNameRegistration() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsEnableBNodeResolverThread() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsEnableDynamicRegistration() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsExtractRecordsFromMessage_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsExtractRecordsFromMessage_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFindAuthoritativeZone() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFlushResolverCache() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFlushResolverCacheEntry_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFlushResolverCacheEntry_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFlushResolverCacheEntry_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFreeAdapterInformation() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFreeNetworkInformation() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsFreeSearchInformation() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetBufferLengthForStringCopy() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetCacheDataTable() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetDnsServerList() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetDomainName() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetHostName_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetHostName_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetHostName_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetIpAddressInfoList() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetIpAddressList() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetLastServerUpdateIP() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetMaxNumberOfAddressesToRegister() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetNetworkInformation() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetPrimaryDomainName_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetPrimaryDomainName_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetPrimaryDomainName_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsGetSearchInformation() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIpv6AddressToString() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIpv6StringToAddress() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIsAMailboxType() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIsAdapterDomainNameRegistrationEnabled() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIsDynamicRegistrationEnabled() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIsStatusRcode() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsIsStringCountValidForTextType() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsMapRcodeToStatus() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordSet_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordSet_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordSet_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordsInSet_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordsInSet_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsModifyRecordsInSet_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsNameCompareEx_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsNameCompareEx_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsNameCompareEx_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsNameCopy() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsNameCopyAllocate() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsQueryConfig() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsQueryEx() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordBuild_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordBuild_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordCompare() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordCopyEx() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordSetCompare() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordSetCopyEx() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordSetDetach() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordStringForType() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordStringForWritableType() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRecordTypeForName() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRelationalCompare_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRelationalCompare_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsRemoveRegistrations() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSetA() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSetUTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSetW() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSet_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSet_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsReplaceRecordSet_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationDeregister_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationDeregister_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationDeregister_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationRegister_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationRegister_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsServiceNotificationRegister_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsSetMaxNumberOfAddressesToRegister() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsStatusString() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsStringCopyAllocateEx() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUnicodeToUtf8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUpdate() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUpdateTest_A() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUpdateTest_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUpdateTest_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsUtf8ToUnicode() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsValidateUtf8Byte() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsWinsRecordFlagForString() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsWinsRecordFlagString() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsWriteQuestionToBuffer_UTF8() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsWriteQuestionToBuffer_W() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI DnsWriteReverseNameStringForIpAddress() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }
 
 DNS_STATUS WINAPI GetCurrentTimeInSeconds() {
   UNIMPLEMENTED;
-  return DNS_ERROR_NO_MEMORY;
+  return ERROR_OUTOFMEMORY;
 }

reactos/lib/dnsapi/include/internal
windns.h 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- windns.h	18 Dec 2003 10:54:48 -0000	1.1
+++ windns.h	8 Dec 2004 21:57:08 -0000	1.1.24.1
@@ -8,6 +8,6 @@
 } WINDNS_CONTEXT, *PWINDNS_CONTEXT;
 
 DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS( int Status );
-void DnsIntFreeRecordList( PDNS_RECORDA ToFree );
+void DnsIntFreeRecordList( PDNS_RECORD ToFree );
 
 #endif//WINDNS_INTERNAL_H

reactos/lib/expat
Makefile 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile	29 May 2004 21:24:43 -0000	1.3
+++ Makefile	8 Dec 2004 21:57:08 -0000	1.3.16.1
@@ -1,8 +1,8 @@
-# $Id: Makefile,v 1.3 2004/05/29 21:24:43 hbirr Exp $
+# $Id: Makefile,v 1.3.16.1 2004/12/08 21:57:08 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
-TARGET_NAME = libexpat
+TARGET_NAME = expat
 
 TARGET_TYPE = dynlink
 TARGET_BASE = $(TARGET_BASE_LIB_EXPAT)

reactos/lib/expat/lib
libexpat.def 1.1 -> 1.1.20.1
diff -u -r1.1 -r1.1.20.1
--- libexpat.def	24 Mar 2004 00:04:45 -0000	1.1
+++ libexpat.def	8 Dec 2004 21:57:09 -0000	1.1.20.1
@@ -1,5 +1,5 @@
 ; DEF file for MS VC++
-LIBRARY   LIBEXPAT
+LIBRARY   expat.dll
 DESCRIPTION "Implements an XML parser."
 EXPORTS
   XML_DefaultCurrent @1

reactos/lib/expat/lib
libexpatw.def 1.1 -> 1.1.20.1
diff -u -r1.1 -r1.1.20.1
--- libexpatw.def	24 Mar 2004 00:04:45 -0000	1.1
+++ libexpatw.def	8 Dec 2004 21:57:09 -0000	1.1.20.1
@@ -1,5 +1,5 @@
 ; DEF file for MS VC++
-LIBRARY   LIBEXPATW
+LIBRARY   expat.dll
 DESCRIPTION "Implements an XML parser."
 EXPORTS
   XML_DefaultCurrent @1

reactos/lib/freetype/i386
setjmplongjmp.s 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- setjmplongjmp.s	1 Apr 2003 08:38:33 -0000	1.1
+++ setjmplongjmp.s	8 Dec 2004 21:57:09 -0000	1.1.34.1
@@ -1,19 +1,19 @@
-/* $Id: setjmplongjmp.s,v 1.1 2003/04/01 08:38:33 gvg Exp $
- *
- * COPYRIGHT:         See COPYING in the top level directory
- * PROJECT:           FreeType implementation for ReactOS
- * PURPOSE:           Implementation of _setjmp/longjmp
- * FILE:              thirdparty/freetype/i386/setjmplongjmp.s
- * PROGRAMMER:        Ge van Geldorp (ge@gse.nl)
+/* $Id: setjmplongjmp.s,v 1.1.34.1 2004/12/08 21:57:09 hyperion Exp $
+ *
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           FreeType implementation for ReactOS
+ * PURPOSE:           Implementation of _setjmp/longjmp
+ * FILE:              thirdparty/freetype/i386/setjmplongjmp.s
+ * PROGRAMMER:        Ge van Geldorp (ge@gse.nl)
  * NOTES:             Copied from glibc.
  *                    I have the feeling this could be implemented using the SEH
  *                    routines, but if it's good enough for glibc it's propably
  *                    good enough for me...
  *                    The MingW headers define jmp_buf to be an array of 16 ints,
  *                    based on the jmp_buf used by MSCVRT. We're using only 6 of
- *                    them, so plenty of space.^M
+ *                    them, so plenty of space.
  */
-
+
 #define JB_BX  0
 #define JB_SI  1
 #define JB_DI  2
@@ -24,22 +24,22 @@
 #define PCOFF  0
 
 #define JMPBUF 4
-
-/*
- * int
- * _setjmp(jmp_buf env);
- *
- * Parameters:
- *   [ESP+04h] - jmp_buf env
- * Registers:
- *   None
- * Returns:
- *   0
- * Notes:
+
+/*
+ * int
+ * _setjmp(jmp_buf env);
+ *
+ * Parameters:
+ *   [ESP+04h] - jmp_buf env
+ * Registers:
+ *   None
+ * Returns:
+ *   0
+ * Notes:
  *   Sets up the jmp_buf
- */
-.globl __setjmp
-__setjmp:
+ */
+.globl __setjmp
+__setjmp:
     xorl %eax, %eax
     movl JMPBUF(%esp), %edx
 
@@ -55,23 +55,23 @@
     ret
 
 #define VAL 8
-
-/*
- * void
- * longjmp(jmp_buf env, int value);
- *
- * Parameters:
+
+/*
+ * void
+ * longjmp(jmp_buf env, int value);
+ *
+ * Parameters:
  *   [ESP+04h] - jmp_buf setup by _setjmp
- *   [ESP+08h] - int     value to return
- * Registers:
- *   None
- * Returns:
- *   Doesn't return
- * Notes:
+ *   [ESP+08h] - int     value to return
+ * Registers:
+ *   None
+ * Returns:
+ *   Doesn't return
+ * Notes:
  *   Non-local goto
- */
-.globl _longjmp
-_longjmp:
+ */
+.globl _longjmp
+_longjmp:
     movl JMPBUF(%esp), %ecx   /* User's jmp_buf in %ecx.  */
 
     movl VAL(%esp), %eax      /* Second argument is return value.  */

reactos/lib/icmp
.cvsignore 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- .cvsignore	28 Sep 2004 19:07:56 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:57:09 -0000	1.1.6.1
@@ -7,19 +7,5 @@
 *.map
 *.tmp
 Makefile.ros
-idb_hist_large.bmp
-idb_hist_small.bmp
-idb_std_small.bmp
-idb_std_large.bmp
-idb_view_large.bmp
-idb_view_small.bmp
-idc_copy.cur
-idc_divider.cur
-idc_divideropen.cur
-idc_movebutton.cur
-idi_dragarrow.ico
-idi_tt_error_sm.ico
-idi_tt_info_sm.ico
-idi_tt_warn_sm.ico
-idt_check.bmp
-comctl32.spec.def
+icmp.spec.def
+icmp.stubs.c

reactos/lib/icmp
Makefile.ros-template 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- Makefile.ros-template	28 Sep 2004 19:07:56 -0000	1.1
+++ Makefile.ros-template	8 Dec 2004 21:57:09 -0000	1.1.6.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.1 2004/09/28 19:07:56 sedwards Exp $
+# $Id: Makefile.ros-template,v 1.1.6.1 2004/12/08 21:57:09 hyperion Exp $
 
 TARGET_NAME = icmp
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ ws2_32.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ ws2_32.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_COMCTL32)
 

reactos/lib/icmp
icmp.dsp 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- icmp.dsp	28 Sep 2004 19:07:56 -0000	1.1
+++ icmp.dsp	8 Dec 2004 21:57:09 -0000	1.1.6.1
@@ -1,96 +1,96 @@
-# Microsoft Developer Studio Project File - Name="icmp" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=icmp - Win32
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "icmp.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "icmp.mak" CFG="icmp - Win32"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "icmp - Win32" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Output\Win32"
-# PROP BASE Intermediate_Dir "Output\Win32"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Output\Win32"
-# PROP Intermediate_Dir "Output\Win32"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ICMP_EXPORTS" /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ..\..\include /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ICMP_" /D "__WINESRC__" /D __WINETEST_OUTPUT_DIR=\"Output\\Win32\" /D "__i386__" /D "_X86_" /D inline=__inline /FR /FD /GZ /c
-# SUBTRACT CPP /X /YX
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x41d /d "_DEBUG"
-# ADD RSC /l 0x41d /i "..\..\include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /def:"icmp.def" /pdbtype:sept
-# Begin Target
-
-# Name "icmp - Win32"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\icmp.dll.dbg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\icmp.spec
-# Begin Custom Build
-InputPath=.\icmp.spec
-
-BuildCmds= \
-	..\..\tools\winebuild\Output\\Win32\winebuild.exe --def .\icmp.spec > .\icmp.def \
-	..\..\tools\winebuild\Output\\Win32\winebuild.exe -o .\icmp.dll.dbg.c --debug -C. icmp_main.c \
-	
-
-".\icmp.def" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-   $(BuildCmds)
-
-".\icmp.dll.dbg.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-   $(BuildCmds)
-# End Custom Build
-# End Source File
-# Begin Source File
-
-SOURCE=.\icmp_main.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="icmp" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=icmp - Win32
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "icmp.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "icmp.mak" CFG="icmp - Win32"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "icmp - Win32" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Output\Win32"
+# PROP BASE Intermediate_Dir "Output\Win32"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Output\Win32"
+# PROP Intermediate_Dir "Output\Win32"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ICMP_EXPORTS" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ..\..\include /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ICMP_" /D "__WINESRC__" /D __WINETEST_OUTPUT_DIR=\"Output\\Win32\" /D "__i386__" /D "_X86_" /D inline=__inline /FR /FD /GZ /c
+# SUBTRACT CPP /X /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41d /d "_DEBUG"
+# ADD RSC /l 0x41d /i "..\..\include" /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /dll /debug /machine:I386 /def:"icmp.def" /pdbtype:sept
+# Begin Target
+
+# Name "icmp - Win32"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\icmp.dll.dbg.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\icmp.spec
+# Begin Custom Build
+InputPath=.\icmp.spec
+
+BuildCmds= \
+	..\..\tools\winebuild\Output\\Win32\winebuild.exe --def .\icmp.spec > .\icmp.def \
+	..\..\tools\winebuild\Output\\Win32\winebuild.exe -o .\icmp.dll.dbg.c --debug -C. icmp_main.c \
+	
+
+".\icmp.def" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+   $(BuildCmds)
+
+".\icmp.dll.dbg.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+   $(BuildCmds)
+# End Custom Build
+# End Source File
+# Begin Source File
+
+SOURCE=.\icmp_main.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project

reactos/lib/icmp
icmp_main.c 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- icmp_main.c	28 Sep 2004 19:07:56 -0000	1.1
+++ icmp_main.c	8 Dec 2004 21:57:09 -0000	1.1.6.1
@@ -135,34 +135,6 @@
     return(answer);
 }
 
-/* A private gettimeofday without the timezone parameter
- * to support building on Windows as well as Unix.
- */
-
-#ifndef __GNUC__
-#define EPOCHFILETIME (116444736000000000i64)
-#else
-#define EPOCHFILETIME (116444736000000000LL)
-#endif
-
-static int icmp_gettimeofday(struct timeval *tv)
-{
-    FILETIME        ft;
-    LARGE_INTEGER   li;
-    __int64         t;
-
-    GetSystemTimeAsFileTime(&ft);
-    li.LowPart  = ft.dwLowDateTime;
-    li.HighPart = ft.dwHighDateTime;
-    t  = li.QuadPart;       /* In 100-nanosecond intervals */
-    t -= EPOCHFILETIME;     /* Offset to the Epoch time */
-    t /= 10;                /* In microseconds */
-    tv->tv_sec  = (long)(t / 1000000);
-    tv->tv_usec = (long)(t % 1000000);
-
-    return 0;
-}
-
 /*
  * Exported Routines.
  */
@@ -235,7 +207,8 @@
     int ip_header_len;
     int maxlen;
     fd_set fdr;
-    struct timeval timeout,send_time,recv_time;
+    struct timeval timeout;
+    DWORD send_time,recv_time;
     struct sockaddr_in addr;
     int addrlen;
     unsigned short id,seq,cksum;
@@ -338,7 +311,7 @@
     }
 #endif
 
-    icmp_gettimeofday(&send_time);
+    send_time = GetTickCount();
     res=sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr));
     HeapFree(GetProcessHeap (), 0, reqbuf);
     if (res<0) {
@@ -363,7 +336,7 @@
     /* Get the reply */
     ip_header_len=0; /* because gcc was complaining */
     while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
-        icmp_gettimeofday(&recv_time);
+        recv_time = GetTickCount();
         res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
         TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
         ier->Status=IP_REQ_TIMED_OUT;
@@ -457,18 +430,16 @@
              * Decrease the timeout so that we don't enter an endless loop even
              * if we get flooded with ICMP packets that are not for us.
              */
-            timeout.tv_sec=Timeout/1000-(recv_time.tv_sec-send_time.tv_sec);
-            timeout.tv_usec=(Timeout % 1000)*1000+send_time.tv_usec-(recv_time.tv_usec-send_time.tv_usec);
-            if (timeout.tv_usec<0) {
-                timeout.tv_usec+=1000000;
-                timeout.tv_sec--;
-            }
+            int t = Timeout - (recv_time - send_time);
+            if (t < 0) t = 0;
+            timeout.tv_sec = t / 1000;
+            timeout.tv_usec = (t % 1000) * 1000;
             continue;
         } else {
             /* This is a reply to our packet */
             memcpy(&ier->Address,&ip_header->ip_src,sizeof(IPAddr));
             /* Status is already set */
-            ier->RoundTripTime=(recv_time.tv_sec-send_time.tv_sec)*1000+(recv_time.tv_usec-send_time.tv_usec)/1000;
+            ier->RoundTripTime= recv_time - send_time;
             ier->DataSize=res-ip_header_len-ICMP_MINLEN;
             ier->Reserved=0;
             ier->Data=endbuf-ier->DataSize;

reactos/lib/icmp
winehq2ros.patch 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- winehq2ros.patch	28 Sep 2004 19:07:56 -0000	1.1
+++ winehq2ros.patch	8 Dec 2004 21:57:09 -0000	1.1.6.1
@@ -1,10 +1,10 @@
-Index: dlls/icmp/Makefile.in
+Index: Makefile.in
 ===================================================================
 RCS file: /home/wine/wine/dlls/icmp/Makefile.in,v
 retrieving revision 1.13
 diff -u -r1.13 Makefile.in
---- dlls/icmp/Makefile.in	11 Oct 2003 01:09:19 -0000	1.13
-+++ dlls/icmp/Makefile.in	23 Sep 2004 02:56:40 -0000
+--- Makefile.in	11 Oct 2003 01:09:19 -0000	1.13
++++ Makefile.in	7 Dec 2004 22:39:27 -0000
 @@ -4,6 +4,7 @@
  VPATH     = @srcdir@
  MODULE    = icmp.dll
@@ -13,80 +13,13 @@
  
  C_SRCS = icmp_main.c
  
-Index: dlls/icmp/icmp_main.c
-===================================================================
-RCS file: /home/wine/wine/dlls/icmp/icmp_main.c,v
-retrieving revision 1.26
-diff -u -r1.26 icmp_main.c
---- dlls/icmp/icmp_main.c	12 Apr 2004 23:15:12 -0000	1.26
-+++ dlls/icmp/icmp_main.c	23 Sep 2004 03:53:26 -0000
-@@ -95,7 +95,6 @@
- #include "ip.h"
- #include "ip_icmp.h"
- 
--
- WINE_DEFAULT_DEBUG_CHANNEL(icmp);
- 
- 
-@@ -136,7 +135,33 @@
-     return(answer);
- }
- 
-+/* A private gettimeofday without the timezone parameter
-+ * to support building on Windows as well as Unix.
-+ */
-+
-+#ifndef __GNUC__
-+#define EPOCHFILETIME (116444736000000000i64)
-+#else
-+#define EPOCHFILETIME (116444736000000000LL)
-+#endif
- 
-+static int icmp_gettimeofday(struct timeval *tv)
-+{
-+    FILETIME        ft;
-+    LARGE_INTEGER   li;
-+    __int64         t;
-+
-+    GetSystemTimeAsFileTime(&ft);
-+    li.LowPart  = ft.dwLowDateTime;
-+    li.HighPart = ft.dwHighDateTime;
-+    t  = li.QuadPart;       /* In 100-nanosecond intervals */
-+    t -= EPOCHFILETIME;     /* Offset to the Epoch time */
-+    t /= 10;                /* In microseconds */
-+    tv->tv_sec  = (long)(t / 1000000);
-+    tv->tv_usec = (long)(t % 1000000);
-+
-+    return 0;
-+}
- 
- /*
-  * Exported Routines.
-@@ -313,7 +338,7 @@
-     }
- #endif
- 
--    gettimeofday(&send_time,NULL);
-+    icmp_gettimeofday(&send_time);
-     res=sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr));
-     HeapFree(GetProcessHeap (), 0, reqbuf);
-     if (res<0) {
-@@ -338,7 +363,7 @@
-     /* Get the reply */
-     ip_header_len=0; /* because gcc was complaining */
-     while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
--        gettimeofday(&recv_time,NULL);
-+        icmp_gettimeofday(&recv_time);
-         res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
-         TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
-         ier->Status=IP_REQ_TIMED_OUT;
-Index: dlls/icmp/ip.h
+Index: ip.h
 ===================================================================
 RCS file: /home/wine/wine/dlls/icmp/ip.h,v
 retrieving revision 1.3
 diff -u -r1.3 ip.h
---- dlls/icmp/ip.h	6 Jan 2004 22:08:34 -0000	1.3
-+++ dlls/icmp/ip.h	23 Sep 2004 03:43:22 -0000
+--- ip.h	6 Jan 2004 22:08:34 -0000	1.3
++++ ip.h	7 Dec 2004 22:39:27 -0000
 @@ -39,6 +39,21 @@
   */
  #define	IPVERSION	4

reactos/lib/imagehlp
makefile 1.6 -> 1.6.8.1
diff -u -r1.6 -r1.6.8.1
--- makefile	20 Jul 2004 16:48:18 -0000	1.6
+++ makefile	8 Dec 2004 21:57:09 -0000	1.6.8.1
@@ -35,7 +35,7 @@
 
 TARGET_LFLAGS = -nostartfiles -nostdlib
 
-TARGET_SDKLIBS = libwine.a ntdll.a kernel32.a
+TARGET_SDKLIBS = wine.a ntdll.a kernel32.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_IMAGEHLP)
 

reactos/lib/imm32
Makefile 1.5 -> 1.5.16.1
diff -u -r1.5 -r1.5.16.1
--- Makefile	29 May 2004 21:24:44 -0000	1.5
+++ Makefile	8 Dec 2004 21:57:09 -0000	1.5.16.1
@@ -10,7 +10,7 @@
 # require os code to explicitly request A/W version of structs/functions
 TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API
 
-TARGET_SDKLIBS = libwine.a user32.a kernel32.a ntdll.a
+TARGET_SDKLIBS = wine.a user32.a kernel32.a ntdll.a
 
 TARGET_OBJECTS = imm.o
 

reactos/lib/iphlpapi
Makefile.in 1.3 -> 1.3.20.1
diff -u -r1.3 -r1.3.20.1
--- Makefile.in	5 Mar 2004 04:50:01 -0000	1.3
+++ Makefile.in	8 Dec 2004 21:57:09 -0000	1.3.20.1
@@ -4,7 +4,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = iphlpapi.dll
-IMPORTS   = advapi32 kernel32
+IMPORTS   = advapi32 kernel32 rtl
 DELAYIMPORTS = 
 EXTRALIBS = 
 

reactos/lib/iphlpapi
Makefile.ros-template 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile.ros-template	29 May 2004 21:24:44 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:09 -0000	1.2.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:44 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.2.16.1 2004/12/08 21:57:09 hyperion Exp $
 
 TARGET_NAME = iphlpapi
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a advapi32.a kernel32.a ws2_32.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a advapi32.a kernel32.a ws2_32.a wine_uuid.a ntdll.a rtl.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_IPHLPAPI)
 

reactos/lib/iphlpapi
ifenum_reactos.c 1.8 -> 1.8.14.1
diff -u -r1.8 -r1.8.14.1
--- ifenum_reactos.c	21 Jun 2004 02:21:16 -0000	1.8
+++ ifenum_reactos.c	8 Dec 2004 21:57:09 -0000	1.8.14.1
@@ -128,7 +128,7 @@
     DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES, 
         arraySize = entrySize * MAX_TDI_ENTITIES;
 
-    DPRINT("TdiGetSetOfThings(tcpFile %x,toiClass %x,toiType %x,toiId %x,"
+    DbgPrint("TdiGetSetOfThings(tcpFile %x,toiClass %x,toiType %x,toiId %x,"
            "teiEntity %x,fixedPart %d,entrySize %d)\n",
            (int)tcpFile, 
            (int)toiClass, 
@@ -161,9 +161,8 @@
                                   0,
                                   &allocationSizeForEntityArray,
                                   NULL );
-        
+
         if( !NT_SUCCESS(status) ) {
-            DPRINT("TdiGetSetOfThings() => %08x\n", (int)status);       
             return status;
         }
         

reactos/lib/iphlpapi
iphlpapi_main.c 1.4 -> 1.4.20.1
diff -u -r1.4 -r1.4.20.1
--- iphlpapi_main.c	25 Feb 2004 20:29:15 -0000	1.4
+++ iphlpapi_main.c	8 Dec 2004 21:57:09 -0000	1.4.20.1
@@ -1236,7 +1236,7 @@
     if (!pIpNetTable || *pdwSize < size) {
       *pdwSize = size;
       ret = ERROR_INSUFFICIENT_BUFFER;
-    }
+    } 
     else {
       PMIB_IPNETTABLE table = getArpTable();
 

reactos/lib/iphlpapi
iphlpapi_private.h 1.4 -> 1.4.20.1
diff -u -r1.4 -r1.4.20.1
--- iphlpapi_private.h	5 Mar 2004 04:50:01 -0000	1.4
+++ iphlpapi_private.h	8 Dec 2004 21:57:09 -0000	1.4.20.1
@@ -102,12 +102,12 @@
 
 int GetLongestChildKeyName( HANDLE RegHandle );
 LONG OpenChildKeyRead( HANDLE RegHandle,
-		       PCHAR ChildKeyName,
+		       PWCHAR ChildKeyName,
 		       PHKEY ReturnHandle );
-PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
-void ConsumeChildKeyName( PCHAR Name );
-PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName );
-void ConsumeRegValueString( PCHAR NameServer );
+PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
+void ConsumeChildKeyName( PWCHAR Name );
+PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName );
+void ConsumeRegValueString( PWCHAR NameServer );
 
 #include <w32api.h>
 /* This is here until we switch to version 2.5 of the mingw headers */

reactos/lib/iphlpapi
ipstats_reactos.c 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- ipstats_reactos.c	9 Nov 2004 03:22:17 -0000	1.6
+++ ipstats_reactos.c	8 Dec 2004 21:57:09 -0000	1.6.2.1
@@ -19,6 +19,7 @@
  * tcpip.sys
  */
 
+#include <roscfg.h>
 #include <stdio.h>
 
 #include "iphlpapi_private.h"

reactos/lib/iphlpapi
makefile 1.9 -> 1.9.20.1
diff -u -r1.9 -r1.9.20.1
--- makefile	25 Feb 2004 07:41:50 -0000	1.9
+++ makefile	8 Dec 2004 21:57:09 -0000	1.9.20.1
@@ -8,10 +8,10 @@
 
 TARGET_BASE = 0x777c0000
 
-TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -Wall -Werror
+TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -Wall -Werror -DDBG
 # -D_WIN32_WINNT=0x0500
 
-TARGET_SDKLIBS = ntdll.a kernel32.a ws2_32.a
+TARGET_SDKLIBS = rtl.a ntdll.a kernel32.a ws2_32.a 
 
 DEP_OBJECTS = $(TARGET_OBJECTS)
 

reactos/lib/iphlpapi
registry.c 1.5 -> 1.5.20.1
diff -u -r1.5 -r1.5.20.1
--- registry.c	25 Feb 2004 20:29:15 -0000	1.5
+++ registry.c	8 Dec 2004 21:57:10 -0000	1.5.20.1
@@ -6,18 +6,18 @@
   LONG Status;
   DWORD MaxAdapterName;
 
-  Status = RegQueryInfoKeyA(RegHandle, 
-                            NULL, 
-                            NULL, 
-                            NULL, 
-                            NULL, 
-                            &MaxAdapterName, 
-                            NULL, 
-                            NULL, 
-                            NULL, 
-                            NULL, 
-                            NULL, 
-                            NULL);
+  Status = RegQueryInfoKeyW(RegHandle, 
+			    NULL, 
+			    NULL, 
+			    NULL, 
+			    NULL, 
+			    &MaxAdapterName, 
+			    NULL, 
+			    NULL, 
+			    NULL, 
+			    NULL, 
+			    NULL, 
+			    NULL);
   if (Status == ERROR_SUCCESS) 
     return MaxAdapterName + 1;
   else
@@ -25,23 +25,23 @@
 }
 
 LONG OpenChildKeyRead( HANDLE RegHandle, 
-                       PCHAR ChildKeyName, 
-                       PHKEY ReturnHandle ) {
-  return RegOpenKeyExA( RegHandle, 
-                        ChildKeyName, 
-                        0,
-                        KEY_READ,
-                        ReturnHandle );
+		       PWCHAR ChildKeyName, 
+		       PHKEY ReturnHandle ) {
+  return RegOpenKeyExW( RegHandle, 
+			ChildKeyName, 
+			0,
+			KEY_READ,
+			ReturnHandle );
 }
 
 /*
  * Yields a malloced value that must be freed.
  */
 
-PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
+PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
   LONG Status;
   int MaxAdapterName = GetLongestChildKeyName( RegHandle );
-  PCHAR Value;
+  PWCHAR Value;
   DWORD ValueLen;
 
   if (MaxAdapterName == -1) {
@@ -50,9 +50,9 @@
   }
 
   ValueLen = MaxAdapterName;
-  Value = (PCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName );
-  Status = RegEnumKeyExA( RegHandle, n, Value, &ValueLen, 
-                          NULL, NULL, NULL, NULL );
+  Value = (PWCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName );
+  Status = RegEnumKeyExW( RegHandle, n, Value, &ValueLen, 
+			  NULL, NULL, NULL, NULL );
   if (Status != ERROR_SUCCESS)
     return 0;
   else {
@@ -61,27 +61,26 @@
   }
 }
 
-void ConsumeChildKeyName( PCHAR Name ) {
+void ConsumeChildKeyName( PWCHAR Name ) {
   if (Name) HeapFree( GetProcessHeap(), 0, Name );
 }
 
-PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName ) {
-  PCHAR Name;
+PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ) {
+  PWCHAR Name;
   DWORD ReturnedSize = 0;
   
-  if (RegQueryValueExA( RegHandle, ValueName, NULL, NULL, NULL, 
-                        &ReturnedSize ) != 0) 
+  if (RegQueryValueExW( RegHandle, ValueName, NULL, NULL, NULL, 
+			&ReturnedSize ) != 0) {
     return 0;
-  else {
-    Name = malloc( (ReturnedSize + 1) * sizeof(WCHAR) );
-    RegQueryValueExA( RegHandle, ValueName, NULL, NULL, (PVOID)Name, 
-                      &ReturnedSize );
-    Name[ReturnedSize] = 0;
+  } else {
+    Name = malloc( ReturnedSize );
+    RegQueryValueExW( RegHandle, ValueName, NULL, NULL, (PVOID)Name, 
+		      &ReturnedSize );
     return Name;
   }
 }
 
-void ConsumeRegValueString( PCHAR Value ) {
+void ConsumeRegValueString( PWCHAR Value ) {
   if (Value) free(Value);
 }
 

reactos/lib/iphlpapi
resinfo_reactos.c 1.5 -> 1.5.8.1
diff -u -r1.5 -r1.5.8.1
--- resinfo_reactos.c	20 Aug 2004 15:19:38 -0000	1.5
+++ resinfo_reactos.c	8 Dec 2004 21:57:10 -0000	1.5.8.1
@@ -1,8 +1,9 @@
 /*
- * iphlpapi dll implementation -- Auxiliary icmp functions
+ * iphlpapi dll implementation -- Setting and storing route information
  *
- * These are stubs for functions that provide a simple ICMP probing API.  They
- * will be operating system specific when implemented.
+ * These are stubs for functions that set routing information on the target
+ * operating system.  They are grouped here because their implementation will
+ * vary widely by operating system.
  *
  * Copyright (C) 2004 Art Yerkes
  * This library is free software; you can redistribute it and/or
@@ -46,20 +47,238 @@
 #include "iphlpapi.h"
 #include "wine/debug.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
+typedef struct _NAME_SERVER_LIST_PRIVATE {
+    UINT NumServers;
+    UINT CurrentName;
+    PIP_ADDRESS_STRING AddrString;
+} NAME_SERVER_LIST_PRIVATE, *PNAME_SERVER_LIST_PRIVATE;
+
+PVOID STDCALL
+RtlAllocateHeap (
+	HANDLE	Heap,
+	ULONG	Flags,
+	ULONG	Size
+	);
+
+BOOLEAN
+STDCALL
+RtlFreeHeap (
+	HANDLE	Heap,
+	ULONG	Flags,
+	PVOID	Address
+	);
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteN (
+	PCHAR	MbString,
+	ULONG	MbSize,
+	PULONG	ResultSize,
+	PWCHAR	UnicodeString,
+	ULONG	UnicodeSize
+	);
+
+typedef VOID (*EnumNameServersFunc)( PWCHAR Interface,
+				     PWCHAR NameServer,
+				     PVOID Data );
+typedef VOID (*EnumInterfacesFunc)( HKEY ChildKeyHandle,
+				    PWCHAR ChildKeyName,
+				    PVOID Data );
+
+/*
+ * EnumInterfaces
+ *
+ * Call the enumeration function for each name server.
+ */
+
+static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) {
+  HKEY RegHandle, TcpipHandle;
+  HKEY ChildKeyHandle = 0;
+  PWCHAR RegKeyToEnumerate = 
+      L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces";
+  PWCHAR RegKeyForTcpip = 
+      L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
+  PWCHAR ChildKeyName = 0;
+  DWORD CurrentInterface;
+
+  if (OpenChildKeyRead(HKEY_LOCAL_MACHINE,RegKeyToEnumerate,&RegHandle)) {
+    return;
+  }
+
+  for (CurrentInterface = 0; TRUE; CurrentInterface++) {
+      ChildKeyName = GetNthChildKeyName( RegHandle, CurrentInterface );
+      if (!ChildKeyName) break;
+      if (OpenChildKeyRead(RegHandle,ChildKeyName,
+			   &ChildKeyHandle) == 0) {
+	  cb( ChildKeyHandle, ChildKeyName, Data );
+	  RegCloseKey( ChildKeyHandle );
+      }
+      ConsumeChildKeyName( ChildKeyName );
+  }
+}
+
+/*
+ * EnumNameServers
+ */
+
+static void EnumNameServers( HANDLE RegHandle, PWCHAR Interface,
+			     PVOID Data, EnumNameServersFunc cb ) {
+    PWCHAR NameServerString = 
+	QueryRegistryValueString(RegHandle, L"NameServer");
+    /* Now, count the non-empty comma separated */
+    if (NameServerString) {
+	DWORD ch;
+	DWORD LastNameStart = 0;
+	for (ch = 0; NameServerString[ch]; ch++) {
+	    if (NameServerString[ch] == ',') {
+		if (ch - LastNameStart > 0) { /* Skip empty entries */
+		    PWCHAR NameServer = 
+			malloc(ch - LastNameStart + 1);
+		    if (NameServer) {
+			memcpy(NameServer,NameServerString + LastNameStart,
+			       (ch - LastNameStart));
+			NameServer[ch - LastNameStart] = 0;
+			cb( Interface, NameServer, Data );
+			free(NameServer);
+		    }
+		}	
+		LastNameStart = ch + 1; /* The first one after the comma */
+	    }
+	}
+	if (ch - LastNameStart > 0) { /* A last name? */
+	    PWCHAR NameServer = malloc(ch - LastNameStart + 1);
+	    memcpy(NameServer,NameServerString + LastNameStart,
+		   (ch - LastNameStart));
+	    NameServer[ch - LastNameStart] = 0;
+	    cb( Interface, NameServer, Data );
+	    free(NameServer);
+	}
+	ConsumeRegValueString(NameServerString);
+    }
+}
+
+static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface,
+						    PWCHAR Server,
+						    PVOID _Data ) {
+    PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data;
+    Data->NumServers++;
+}
+
+static void CreateNameServerListEnumIfFuncCount( HKEY RegHandle,
+						 PWCHAR InterfaceName,
+						 PVOID _Data ) {
+    PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data;
+    EnumNameServers(RegHandle,InterfaceName,Data,
+		    CreateNameServerListEnumNamesFuncCount);
+}
+
+static void CreateNameServerListEnumNamesFunc( PWCHAR Interface,
+					       PWCHAR Server,
+					       PVOID _Data ) {
+    PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data;
+    RtlUnicodeToMultiByteN((PCHAR)&Data->AddrString[Data->CurrentName], 
+			   sizeof(Data->AddrString[0]),
+			   NULL,
+			   Server,
+			   wcslen(Server));
+    Data->CurrentName++;
+}
+
+static void CreateNameServerListEnumIfFunc( HKEY RegHandle,
+					    PWCHAR InterfaceName,
+					    PVOID _Data ) {
+    PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data;
+    EnumNameServers(RegHandle,InterfaceName,Data,
+		    CreateNameServerListEnumNamesFunc);
+}
+
+static int CountNameServers( PNAME_SERVER_LIST_PRIVATE PrivateData ) {
+    EnumInterfaces(PrivateData,CreateNameServerListEnumIfFuncCount);
+    return PrivateData->NumServers;
+}
+
+static void MakeNameServerList( PNAME_SERVER_LIST_PRIVATE PrivateData ) {
+    EnumInterfaces(PrivateData,CreateNameServerListEnumIfFunc);
+}
 
 PIPHLP_RES_INFO getResInfo() {
-    PIPHLP_RES_INFO InfoPtr = 
-        (PIPHLP_RES_INFO)HeapAlloc( GetProcessHeap(), 0, 
-                                    sizeof(PIPHLP_RES_INFO) );
-    if( InfoPtr ) {
-        InfoPtr->riCount = 0;
-        InfoPtr->riAddressList = NULL;
+    DWORD result = ERROR_SUCCESS, dwSize, i, ServerCount, ExtraServer;
+    HKEY hKey;
+    LONG errCode;
+    PWCHAR Str;
+    IP_ADDR_STRING AddrString;
+    NAME_SERVER_LIST_PRIVATE PrivateNSEnum = { 0 };
+    PIPHLP_RES_INFO ResInfo;
+    struct sockaddr_in *AddrList;
+    
+    ServerCount = CountNameServers( &PrivateNSEnum );
+  
+    errCode = RegOpenKeyExA(HKEY_LOCAL_MACHINE, 
+			    "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\"
+			    "Parameters", 0, KEY_READ, &hKey);
+    if (errCode != ERROR_SUCCESS) {
+	RegCloseKey( hKey );
+	return NULL;
+    }
+    
+    Str = QueryRegistryValueString( hKey, L"NameServer" );
+    ExtraServer = Str ? 1 : 0;
+
+    ServerCount += ExtraServer;
+
+    PrivateNSEnum.NumServers = ServerCount;
+    PrivateNSEnum.AddrString = 
+	(PIP_ADDRESS_STRING)
+	RtlAllocateHeap( GetProcessHeap(), 0, 
+			 ServerCount * sizeof(IP_ADDRESS_STRING) );
+
+    ResInfo = 
+	(PIPHLP_RES_INFO)RtlAllocateHeap
+	( GetProcessHeap(), 0, 
+	  sizeof(IPHLP_RES_INFO) +
+	  (ServerCount * sizeof(struct sockaddr_in)) );
+
+    if( !ResInfo ) {
+	RtlFreeHeap( GetProcessHeap(), 0, PrivateNSEnum.AddrString );
+	RegCloseKey( hKey );
+	return NULL;
+    }
+
+    ResInfo->riCount = ServerCount;
+    AddrList = (struct sockaddr_in *)
+	(((PCHAR)ResInfo) + sizeof(IPHLP_RES_INFO));
+    ResInfo->riAddressList = AddrList;
+
+    MakeNameServerList( &PrivateNSEnum );
+
+    if( ExtraServer ) {
+	ULONG ResultSize;
+
+	for( ResultSize = 0; Str[ResultSize]; ResultSize++ ) 
+	    ((PCHAR)&AddrString)[ResultSize] = Str[ResultSize];
+
+	((PCHAR)&AddrString)[ResultSize] = 0;
+	ResInfo->riAddressList[0].sin_family = AF_INET;
+	ResInfo->riAddressList[0].sin_addr.s_addr = 
+	    inet_addr( (PCHAR)&AddrString );
+	ResInfo->riAddressList[0].sin_port = 0;
+	ConsumeRegValueString( Str );
+    }
+
+    for( i = ExtraServer; i < ServerCount; i++ ) {
+	/* Hmm seems that dns servers are always AF_INET but ... */
+	ResInfo->riAddressList[i].sin_family = AF_INET;
+	ResInfo->riAddressList[i].sin_addr.s_addr = 
+	    inet_addr( (PCHAR)&PrivateNSEnum.AddrString[i - ExtraServer] );
+	ResInfo->riAddressList[i].sin_port = 0;
     }
+    
+    RtlFreeHeap( GetProcessHeap(), 0, PrivateNSEnum.AddrString );
+    RegCloseKey( hKey );
 
-    return InfoPtr;
+    return ResInfo;
 }
 
 VOID disposeResInfo( PIPHLP_RES_INFO InfoPtr ) {
-    HeapFree( GetProcessHeap(), 0, InfoPtr );
+    RtlFreeHeap( GetProcessHeap(), 0, InfoPtr );
 }

reactos/lib/iphlpapi
route_reactos.c 1.1 -> 1.1.20.1
diff -u -r1.1 -r1.1.20.1
--- route_reactos.c	5 Mar 2004 04:50:01 -0000	1.1
+++ route_reactos.c	8 Dec 2004 21:57:10 -0000	1.1.20.1
@@ -47,6 +47,9 @@
 #include "iphlpapi.h"
 #include "wine/debug.h"
 
+#define IP_FORWARD_ADD 3
+#define IP_FORWARD_DEL 2
+
 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
 
 DWORD createIpForwardEntry( PMIB_IPFORWARDROW pRoute ) {
@@ -78,7 +81,7 @@
 	rte->ire_mask    = pRoute->dwForwardMask;
 	rte->ire_gw      = pRoute->dwForwardNextHop;
 	rte->ire_index   = pRoute->dwForwardIfIndex;
-	rte->ire_type    = pRoute->dwForwardType;
+	rte->ire_type    = IP_FORWARD_ADD;
 	rte->ire_proto   = pRoute->dwForwardProto;
 	rte->ire_age     = pRoute->dwForwardAge;
 	rte->ire_metric1 = pRoute->dwForwardMetric1;
@@ -142,7 +145,7 @@
 	rte->ire_mask    = INADDR_NONE;
 	rte->ire_gw      = pRoute->dwForwardNextHop;
 	rte->ire_index   = pRoute->dwForwardIfIndex;
-	rte->ire_type    = 2; /*pRoute->dwForwardType;*/
+	rte->ire_type    = IP_FORWARD_DEL;
 	rte->ire_proto   = pRoute->dwForwardProto;
 	rte->ire_age     = pRoute->dwForwardAge;
 	rte->ire_metric1 = pRoute->dwForwardMetric1;

reactos/lib/kernel32/file
create.c 1.40 -> 1.40.2.1
diff -u -r1.40 -r1.40.2.1
--- create.c	12 Oct 2004 22:04:51 -0000	1.40
+++ create.c	8 Dec 2004 21:57:10 -0000	1.40.2.1
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.40 2004/10/12 22:04:51 gvg Exp $
+/* $Id: create.c,v 1.40.2.1 2004/12/08 21:57:10 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -134,7 +134,7 @@
 				      NULL))
    {
      DPRINT("Invalid path\n");
-     SetLastError(ERROR_BAD_PATHNAME);
+     SetLastError(ERROR_PATH_NOT_FOUND);
      return INVALID_HANDLE_VALUE;
    }
    
@@ -271,11 +271,25 @@
    RtlFreeUnicodeString(&NtPathU);
 
    /* error */
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastErrorByStatus (Status);
-    return INVALID_HANDLE_VALUE;
-  }
+   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
+      {
+         SetLastErrorByStatus (Status);
+      }
+     
+      return INVALID_HANDLE_VALUE;
+   }
    
   /*
   create with OPEN_ALWAYS (FILE_OPEN_IF) returns info = FILE_OPENED or FILE_CREATED

reactos/lib/kernel32/file
delete.c 1.17 -> 1.17.8.1
diff -u -r1.17 -r1.17.8.1
--- delete.c	18 Aug 2004 02:13:27 -0000	1.17
+++ delete.c	8 Dec 2004 21:57:10 -0000	1.17.8.1
@@ -1,4 +1,4 @@
-/* $Id: delete.c,v 1.17 2004/08/18 02:13:27 navaraf Exp $
+/* $Id: delete.c,v 1.17.8.1 2004/12/08 21:57:10 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -77,7 +77,10 @@
 	                                   &NtPathU,
 	                                   NULL,
 	                                   NULL))
+   {
+      SetLastError(ERROR_PATH_NOT_FOUND);
 		return FALSE;
+   }
 
 	DPRINT("NtPathU \'%wZ\'\n", &NtPathU);
 

reactos/lib/kernel32/file
file.c 1.60 -> 1.60.2.1
diff -u -r1.60 -r1.60.2.1
--- file.c	31 Oct 2004 01:36:37 -0000	1.60
+++ file.c	8 Dec 2004 21:57:10 -0000	1.60.2.1
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.60 2004/10/31 01:36:37 weiden Exp $
+/* $Id: file.c,v 1.60.2.1 2004/12/08 21:57:10 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -993,7 +993,7 @@
 			       CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY,
 			       0)) == INVALID_HANDLE_VALUE)
    {
-      if (GetLastError() != ERROR_ALREADY_EXISTS)
+      if (GetLastError() != ERROR_FILE_EXISTS)
       {
          return 0;
       }
@@ -1041,7 +1041,7 @@
 			       CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY,
 			       0)) == INVALID_HANDLE_VALUE)
    {
-      if (GetLastError() != ERROR_ALREADY_EXISTS)
+      if (GetLastError() != ERROR_FILE_EXISTS)
       {
          return 0;
       }

reactos/lib/kernel32/file
iocompl.c 1.15 -> 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- iocompl.c	30 Oct 2004 22:18:17 -0000	1.15
+++ iocompl.c	8 Dec 2004 21:57:10 -0000	1.15.2.1
@@ -1,4 +1,4 @@
-/* $Id: iocompl.c,v 1.15 2004/10/30 22:18:17 weiden Exp $
+/* $Id: iocompl.c,v 1.15.2.1 2004/12/08 21:57:10 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -23,7 +23,7 @@
 CreateIoCompletionPort(
     HANDLE FileHandle,
     HANDLE ExistingCompletionPort,
-    DWORD CompletionKey,
+    ULONG_PTR CompletionKey,
     DWORD NumberOfConcurrentThreads
     )
 {
@@ -34,7 +34,7 @@
 
    if ( ExistingCompletionPort == NULL && FileHandle == INVALID_HANDLE_VALUE ) 
    {
-      SetLastErrorByStatus (STATUS_INVALID_PARAMETER);
+      SetLastError(ERROR_INVALID_PARAMETER);
       return FALSE;
    }
 
@@ -62,7 +62,7 @@
    {
 #ifdef __USE_W32API
       CompletionInformation.Port = CompletionPort;
-      CompletionInformation.Key  = CompletionKey;
+      CompletionInformation.Key  = (PVOID)CompletionKey;
 #else
       CompletionInformation.IoCompletionHandle = CompletionPort;
       CompletionInformation.CompletionKey  = CompletionKey;
@@ -98,7 +98,7 @@
 GetQueuedCompletionStatus(
    HANDLE CompletionHandle,
    LPDWORD lpNumberOfBytesTransferred,
-   LPDWORD lpCompletionKey,
+   PULONG_PTR lpCompletionKey,
    LPOVERLAPPED *lpOverlapped,
    DWORD dwMilliseconds
    )
@@ -109,30 +109,22 @@
 
    if (!lpNumberOfBytesTransferred||!lpCompletionKey||!lpOverlapped)
    {
-      return ERROR_INVALID_PARAMETER;
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return FALSE;
    }
 
    if (dwMilliseconds != INFINITE)
    {
-      /*
-       * System time units are 100 nanoseconds (a nanosecond is a billionth of
-       * a second).
-       */
-      Interval.QuadPart = -((ULONGLONG)dwMilliseconds * 10000);
+      Interval.QuadPart = RELATIVE_TIME(MILLIS_TO_100NS(dwMilliseconds));
    }  
-   else
-   {
-      /* Approximately 292000 years hence */
-      Interval.QuadPart = -0x7FFFFFFFFFFFFFFFLL;
-   }
 
    errCode = NtRemoveIoCompletion(CompletionHandle,
-                                  lpCompletionKey,
-                                  lpNumberOfBytesTransferred,
+                                  (PVOID*)lpCompletionKey,
+                                  (PVOID*)lpNumberOfBytesTransferred,
                                   &IoStatus,
-                                  &Interval);
+                                  dwMilliseconds == INFINITE ? NULL : &Interval);
 
-   if (!NT_SUCCESS(errCode) ) {
+   if (!NT_SUCCESS(errCode)) {
       *lpOverlapped = NULL;
       SetLastErrorByStatus(errCode);
       return FALSE;
@@ -142,7 +134,7 @@
 
    if (!NT_SUCCESS(IoStatus.Status)){
       //failed io operation
-      SetLastErrorByStatus (IoStatus.Status);
+      SetLastErrorByStatus(IoStatus.Status);
       return FALSE;
    }
 
@@ -166,10 +158,10 @@
    NTSTATUS errCode;
 
    errCode = NtSetIoCompletion(CompletionHandle,  
-                               dwCompletionKey, 
-                               dwNumberOfBytesTransferred,//CompletionValue 
-                               0,                         //IoStatusBlock->Status
-                               (ULONG)lpOverlapped );     //IoStatusBlock->Information
+                               (PVOID)dwCompletionKey, 
+                               (PVOID)lpOverlapped,//CompletionValue 
+                               STATUS_SUCCESS,                         //IoStatusBlock->Status
+                               dwNumberOfBytesTransferred);     //IoStatusBlock->Information
 
    if ( !NT_SUCCESS(errCode) ) 
    {

reactos/lib/kernel32/file
move.c 1.14 -> 1.14.16.1
diff -u -r1.14 -r1.14.16.1
--- move.c	13 Jun 2004 20:04:55 -0000	1.14
+++ move.c	8 Dec 2004 21:57:10 -0000	1.14.16.1
@@ -1,4 +1,4 @@
-/* $Id: move.c,v 1.14 2004/06/13 20:04:55 navaraf Exp $
+/* $Id: move.c,v 1.14.16.1 2004/12/08 21:57:10 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -16,9 +16,15 @@
 #define NDEBUG
 #include "../include/debug.h"
 
+/* GLOBALS *****************************************************************/
 
-#define FILE_RENAME_SIZE  MAX_PATH +sizeof(FILE_RENAME_INFORMATION)
-
+#if defined(__GNUC__)
+void * alloca(size_t size);
+#elif defined(_MSC_VER)
+void* _alloca(size_t size);
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
 
 /* FUNCTIONS ****************************************************************/
 
@@ -164,11 +170,12 @@
 {
 	HANDLE hFile = NULL;
 	IO_STATUS_BLOCK IoStatusBlock;
-	FILE_RENAME_INFORMATION *FileRename;
-	USHORT Buffer[FILE_RENAME_SIZE];
+	PFILE_RENAME_INFORMATION FileRename;
 	NTSTATUS errCode;
-	DWORD err;
 	BOOL Result;
+	UNICODE_STRING DstPathU;
+
+	DPRINT("MoveFileWithProgressW()\n");
 
 	hFile = CreateFileW (lpExistingFileName,
 	                     GENERIC_ALL,
@@ -178,71 +185,118 @@
 	                     FILE_ATTRIBUTE_NORMAL,
 	                     NULL);
 
-	FileRename = (FILE_RENAME_INFORMATION *)Buffer;
+	if (hFile == INVALID_HANDLE_VALUE)
+	{
+           return FALSE;
+	}
+
+        /* validate & translate the filename */
+        if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpNewFileName,
+				           &DstPathU,
+				           NULL,
+				           NULL))
+        {
+           DPRINT("Invalid destination path\n");
+	   CloseHandle(hFile);
+           SetLastError(ERROR_PATH_NOT_FOUND);
+           return FALSE;
+        }
+
+	FileRename = alloca(sizeof(FILE_RENAME_INFORMATION) + DstPathU.Length);
 	if ((dwFlags & MOVEFILE_REPLACE_EXISTING) == MOVEFILE_REPLACE_EXISTING)
 		FileRename->ReplaceIfExists = TRUE;
 	else
 		FileRename->ReplaceIfExists = FALSE;
-	FileRename->FileNameLength = wcslen (lpNewFileName);
-	memcpy (FileRename->FileName,
-	        lpNewFileName,
-	        min(FileRename->FileNameLength, MAX_PATH));
 
+	memcpy(FileRename->FileName, DstPathU.Buffer, DstPathU.Length);
+        RtlFreeHeap (RtlGetProcessHeap (),
+		     0,
+		     DstPathU.Buffer);
+	/* 
+	 * FIXME:
+	 *   Is the length the count of characters or the length of the buffer?
+	 */
+	FileRename->FileNameLength = DstPathU.Length / sizeof(WCHAR);
 	errCode = NtSetInformationFile (hFile,
 	                                &IoStatusBlock,
 	                                FileRename,
-	                                FILE_RENAME_SIZE,
+	                                sizeof(FILE_RENAME_INFORMATION) + DstPathU.Length,
 	                                FileRenameInformation);
 	CloseHandle(hFile);
 	if (NT_SUCCESS(errCode))
 	{
 		Result = TRUE;
 	}
+	else if (STATUS_NOT_SAME_DEVICE == errCode &&
+		 MOVEFILE_COPY_ALLOWED == (dwFlags & MOVEFILE_COPY_ALLOWED))
+	{
+		Result = CopyFileExW (lpExistingFileName,
+		                      lpNewFileName,
+		                      lpProgressRoutine,
+		                      lpData,
+		                      NULL,
+		                      FileRename->ReplaceIfExists ? 0 : COPY_FILE_FAIL_IF_EXISTS);
+		if (Result)
+		{
+			/* Cleanup the source file */
+			AdjustFileAttributes(lpExistingFileName, lpNewFileName);
+	                Result = DeleteFileW (lpExistingFileName);
+		}
+	}
+#if 1
 	/* FIXME file rename not yet implemented in all FSDs so it will always
 	 * fail, even when the move is to the same device
 	 */
-#if 0
-	else if (STATUS_NOT_SAME_DEVICE == errCode &&
-		 MOVEFILE_COPY_ALLOWED == (dwFlags & MOVEFILE_COPY_ALLOWED))
-#else
-	else
-#endif
+	else if (STATUS_NOT_IMPLEMENTED == errCode)
 	{
+
+		UNICODE_STRING SrcPathU;
+
+		SrcPathU.Buffer = alloca(sizeof(WCHAR) * MAX_PATH);
+		SrcPathU.MaximumLength = MAX_PATH * sizeof(WCHAR);
+		SrcPathU.Length = GetFullPathNameW(lpExistingFileName, MAX_PATH, SrcPathU.Buffer, NULL);
+		if (SrcPathU.Length >= MAX_PATH)
+		{
+		    SetLastError(ERROR_FILENAME_EXCED_RANGE);
+		    return FALSE;
+		}
+		SrcPathU.Length *= sizeof(WCHAR);
+
+		DstPathU.Buffer = alloca(sizeof(WCHAR) * MAX_PATH);
+		DstPathU.MaximumLength = MAX_PATH * sizeof(WCHAR);
+		DstPathU.Length = GetFullPathNameW(lpNewFileName, MAX_PATH, DstPathU.Buffer, NULL);
+		if (DstPathU.Length >= MAX_PATH)
+		{
+		    SetLastError(ERROR_FILENAME_EXCED_RANGE);
+		    return FALSE;
+		}
+		DstPathU.Length *= sizeof(WCHAR);
+
+		if (0 == RtlCompareUnicodeString(&SrcPathU, &DstPathU, TRUE))
+		{
+		   /* Source and destination file are the same, nothing to do */
+		   return TRUE;
+		}
+
 		Result = CopyFileExW (lpExistingFileName,
 		                      lpNewFileName,
 		                      lpProgressRoutine,
 		                      lpData,
 		                      NULL,
-		                      FileRename->ReplaceIfExists ? 0 : COPY_FILE_FAIL_IF_EXISTS) &&
-		         AdjustFileAttributes(lpExistingFileName, lpNewFileName) &&
-		         DeleteFileW (lpExistingFileName);
-		if (! Result)
+		                      FileRename->ReplaceIfExists ? 0 : COPY_FILE_FAIL_IF_EXISTS);
+		if (Result)
 		{
-			/* Delete of the existing file failed so the
-			 * existing file is still there. Clean up the
-			 * new file (if possible)
-			 */
-			err = GetLastError();
-			if (! SetFileAttributesW (lpNewFileName, FILE_ATTRIBUTE_NORMAL))
-			{
-				DPRINT("Removing possible READONLY attrib from new file failed with code %d\n", GetLastError());
-			}
-			if (! DeleteFileW (lpNewFileName))
-			{
-				DPRINT("Deleting new file during cleanup failed with code %d\n", GetLastError());
-			}
-			SetLastError (err);
+		    /* Cleanup the source file */
+                    AdjustFileAttributes(lpExistingFileName, lpNewFileName); 
+		    Result = DeleteFileW (lpExistingFileName);
 		}
 	}
-	/* See FIXME above */
-#if 0
+#endif
 	else
 	{
 		SetLastErrorByStatus (errCode);
 		Result = FALSE;
 	}
-#endif
-
 	return Result;
 }
 

reactos/lib/kernel32
makefile 1.89 -> 1.89.2.1
diff -u -r1.89 -r1.89.2.1
--- makefile	20 Oct 2004 20:51:21 -0000	1.89
+++ makefile	8 Dec 2004 21:57:11 -0000	1.89.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.89 2004/10/20 20:51:21 chorns Exp $
+# $Id: makefile,v 1.89.2.1 2004/12/08 21:57:11 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -17,7 +17,7 @@
 
 TARGET_RCFLAGS += -DWINVER=0x0500
 
-TARGET_SDKLIBS = pseh.a rosrtl.a ntdll.a kernel32.a
+TARGET_SDKLIBS = pseh.a rosrtl.a ntdll.a kernel32.a wine.a
 
 TARGET_GCCLIBS = gcc
 

reactos/lib/kernel32/misc
atom.c 1.20 -> 1.20.16.1
diff -u -r1.20 -r1.20.16.1
--- atom.c	13 Jun 2004 10:35:52 -0000	1.20
+++ atom.c	8 Dec 2004 21:57:11 -0000	1.20.16.1
@@ -1,4 +1,4 @@
-/* $Id: atom.c,v 1.20 2004/06/13 10:35:52 navaraf Exp $
+/* $Id: atom.c,v 1.20.16.1 2004/12/08 21:57:11 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -45,6 +45,15 @@
 	return (ATOM)LOWORD((ULONG)lpString);
      }
 
+   if (lstrlenA(lpString) > 255)
+   {
+      /* This limit does not exist with NtAddAtom so the limit is probably 
+       * added for compability. -Gunnar 
+       */
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return (ATOM)0;
+   }
+
    RtlCreateUnicodeStringFromAsciiz(&AtomName,
 				    (LPSTR)lpString);
 
@@ -81,6 +90,15 @@
 	return (ATOM)LOWORD((ULONG)lpString);
      }
 
+   if (lstrlenW(lpString) > 255)
+   {
+      /* This limit does not exist with NtAddAtom so the limit is probably 
+       * added for compability. -Gunnar 
+       */
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return (ATOM)0;
+   }
+
    Status = NtAddAtom((LPWSTR)lpString,
                       wcslen(lpString),
 		      &Atom);
@@ -138,6 +156,15 @@
 	return (ATOM)LOWORD((ULONG)lpString);
      }
 
+   if (lstrlenA(lpString) > 255)
+   {
+      /* This limit does not exist with NtAddAtom so the limit is probably 
+       * added for compability. -Gunnar 
+       */
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return (ATOM)0;
+   }
+
    RtlCreateUnicodeStringFromAsciiz(&AtomName,
 				    (LPSTR)lpString);
    Status = NtFindAtom(AtomName.Buffer,
@@ -173,6 +200,15 @@
 	return (ATOM)LOWORD((ULONG)lpString);
      }
 
+   if (lstrlenW(lpString) > 255)
+   {
+      /* This limit does not exist with NtAddAtom so the limit is probably 
+       * added for compability. -Gunnar 
+       */
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return (ATOM)0;
+   }
+
    Status = NtFindAtom((LPWSTR)lpString,
                        wcslen(lpString),
 		       &Atom);

reactos/lib/kernel32/misc
dllmain.c 1.37 -> 1.37.2.1
diff -u -r1.37 -r1.37.2.1
--- dllmain.c	24 Oct 2004 12:39:53 -0000	1.37
+++ dllmain.c	8 Dec 2004 21:57:11 -0000	1.37.2.1
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.37 2004/10/24 12:39:53 chorns Exp $
+/* $Id: dllmain.c,v 1.37.2.1 2004/12/08 21:57:11 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -37,7 +37,6 @@
 CRITICAL_SECTION ConsoleLock;
 
 extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event);
-extern BOOL FASTCALL PROFILE_Init();
 
 extern BOOL FASTCALL NlsInit();
 extern VOID FASTCALL NlsUninit();
@@ -138,12 +137,6 @@
 	/* Initialize the DLL critical section */
 	RtlInitializeCriticalSection(&DllLock);
 
-	/* Initialize the profile (.ini) routines */
-	if (! PROFILE_Init())
-          {
-            return FALSE;
-          }
-
 	/* Initialize the National Language Support routines */
         if (! NlsInit())
           {

reactos/lib/kernel32/misc
lang.c 1.24 -> 1.24.2.1
diff -u -r1.24 -r1.24.2.1
--- lang.c	20 Oct 2004 03:46:27 -0000	1.24
+++ lang.c	8 Dec 2004 21:57:11 -0000	1.24.2.1
@@ -1,4 +1,4 @@
-/* $Id: lang.c,v 1.24 2004/10/20 03:46:27 jimtabor Exp $
+/* $Id: lang.c,v 1.24.2.1 2004/12/08 21:57:11 hyperion Exp $
  *
  * COPYRIGHT: See COPYING in the top level directory
  * PROJECT  : ReactOS user mode libraries
@@ -42,33 +42,34 @@
  *  GetUserDefaultLCID(), if lcid == LOCALE_USER_DEFAULT or LOCALE_NEUTRAL.
  *  Otherwise, lcid with sublanguage changed to SUBLANG_DEFAULT.
  */
-LCID WINAPI ConvertDefaultLocale( LCID lcid )
+LCID WINAPI
+ConvertDefaultLocale(LCID lcid)
 {
-    LANGID langid;
+  LANGID langid;
 
-    switch (lcid)
-    {
+  switch (lcid)
+  {
     case LOCALE_SYSTEM_DEFAULT:
-        lcid = GetSystemDefaultLCID();
-        break;
+      lcid = GetSystemDefaultLCID();
+      break;
+
     case LOCALE_USER_DEFAULT:
     case LOCALE_NEUTRAL:
-        lcid = GetUserDefaultLCID();
-        break;
-    default:
-        /* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
-        langid = LANGIDFROMLCID(lcid);
-        if (SUBLANGID(langid) == SUBLANG_NEUTRAL)
-        {
-          langid = MAKELANGID(PRIMARYLANGID(langid), SUBLANG_DEFAULT);
-          lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
-        }
-    }
-    return lcid;
-}
-
+      lcid = GetUserDefaultLCID();
+      break;
 
+    default:
+      /* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
+      langid = LANGIDFROMLCID(lcid);
+      if (SUBLANGID(langid) == SUBLANG_NEUTRAL)
+      {
+        langid = MAKELANGID(PRIMARYLANGID(langid), SUBLANG_DEFAULT);
+        lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
+      }
+  }
 
+  return lcid;
+}
 
 
 /*
@@ -240,7 +241,7 @@
 BOOL
 STDCALL
 EnumSystemLanguageGroupsA(
-    LANGUAGEGROUP_ENUMPROCA lpLanguageGroupEnumProc,
+    LANGUAGEGROUP_ENUMPROCA pLangGroupEnumProc,
     DWORD                   dwFlags,
     LONG_PTR                lParam)
 {
@@ -254,8 +255,23 @@
  */
 BOOL
 STDCALL
-EnumSystemLocalesW (
-    LOCALE_ENUMPROCW lpLocaleEnumProc,
+EnumSystemLanguageGroupsW(
+    LANGUAGEGROUP_ENUMPROCW pLangGroupEnumProc,
+    DWORD                   dwFlags,
+    LONG_PTR                lParam)
+{
+    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    return 0;
+}
+
+
+/*
+ * @unimplemented
+ */
+BOOL
+STDCALL
+EnumSystemLocalesA (
+    LOCALE_ENUMPROCA lpLocaleEnumProc,
     DWORD            dwFlags
     )
 {
@@ -269,8 +285,8 @@
  */
 BOOL
 STDCALL
-EnumSystemLocalesA (
-    LOCALE_ENUMPROCA lpLocaleEnumProc,
+EnumSystemLocalesW (
+    LOCALE_ENUMPROCW lpLocaleEnumProc,
     DWORD            dwFlags
     )
 {
@@ -877,47 +893,52 @@
 /*
  * @implemented
  */
-LANGID
-STDCALL
-GetSystemDefaultLangID (VOID)
+LANGID STDCALL
+GetSystemDefaultLangID(VOID)
 {
-   return LANGIDFROMLCID(GetSystemDefaultLCID());
+  return LANGIDFROMLCID(GetSystemDefaultLCID());
 }
 
 
 /*
  * @implemented
  */
-LCID
-STDCALL
-GetSystemDefaultLCID (VOID)
+LCID STDCALL
+GetSystemDefaultLCID(VOID)
 {
-   LCID lcid;
-   NtQueryDefaultLocale( FALSE, &lcid );
-   return lcid;
+  LCID lcid;
+
+  NtQueryDefaultLocale(FALSE, &lcid);
 
-//  return SystemLocale;
+  return lcid;
 }
 
 
 /*
- * @unimplemented
+ * @implemented
  */
-LANGID
-STDCALL
+LANGID STDCALL
 GetSystemDefaultUILanguage(VOID)
 {
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+  LANGID LanguageId;
+  NTSTATUS Status;
+
+  Status = NtQueryInstallUILanguage(&LanguageId);
+  if (!NT_SUCCESS(Status))
+    {
+      SetLastErrorByStatus(Status);
+      return 0;
+    }
+
+  return LanguageId;
 }
 
 
 /*
  * @implemented
  */
-LCID
-STDCALL
-GetThreadLocale (VOID)
+LCID STDCALL
+GetThreadLocale(VOID)
 {
   return NtCurrentTeb()->CurrentLocale;
 }
@@ -926,53 +947,50 @@
 /*
  * @implemented
  */
-LANGID
-STDCALL
-GetUserDefaultLangID (VOID)
+LANGID STDCALL
+GetUserDefaultLangID(VOID)
 {
-    return LANGIDFROMLCID(GetUserDefaultLCID());
+  return LANGIDFROMLCID(GetUserDefaultLCID());
 }
 
 
 /*
  * @implemented
  */
-LCID
-STDCALL
-GetUserDefaultLCID (VOID)
+LCID STDCALL
+GetUserDefaultLCID(VOID)
 {
-    LCID lcid;
-    NTSTATUS Status;
-    
-    Status = NtQueryDefaultLocale(TRUE, &lcid);
-    if(!NT_SUCCESS(Status))
+  LCID lcid;
+  NTSTATUS Status;
+
+  Status = NtQueryDefaultLocale(TRUE, &lcid);
+  if (!NT_SUCCESS(Status))
     {
-        SetLastErrorByStatus(Status);
-        return 0;
+      SetLastErrorByStatus(Status);
+      return 0;
     }
-    
-    return lcid;
+
+  return lcid;
 }
 
 
 /*
  * @implemented
  */
-LANGID
-STDCALL
+LANGID STDCALL
 GetUserDefaultUILanguage(VOID)
 {
-    LANGID LangId;
-    NTSTATUS Status;
-  
-     Status = NtQueryDefaultUILanguage(&LangId);
-    if(!NT_SUCCESS(Status))
+  LANGID LangId;
+  NTSTATUS Status;
+
+  Status = NtQueryDefaultUILanguage(&LangId);
+  if (!NT_SUCCESS(Status))
     {
-        SetLastErrorByStatus(Status);
-        return 0;
+      SetLastErrorByStatus(Status);
+      return 0;
     }
-  
-    return LangId;
+
+  return LangId;
 }
 
 
@@ -1003,36 +1021,124 @@
 }
 
 
-
 /******************************************************************************
- * @implemented
- * RIPPED FROM WINE's dlls\kernel\locale.c rev 1.44
- *
- *           IsValidLocale   (KERNEL32.@)
+ *           IsValidLocale
  *
  * Determine if a locale is valid.
  *
  * PARAMS
- *  lcid  [I] LCID of the locale to check
- *  flags [I] LCID_SUPPORTED = Valid, LCID_INSTALLED = Valid and installed on the system
+ *  Locale  [I] LCID of the locale to check
+ *  dwFlags [I] LCID_SUPPORTED = Valid
+ *              LCID_INSTALLED = Valid and installed on the system
  *
  * RETURN
- *  TRUE,  if lcid is valid,
+ *  TRUE,  if Locale is valid,
  *  FALSE, otherwise.
  *
- * NOTES
- *  Wine does not currently make the distinction between supported and installed. All
- *  languages supported are installed by default.
+ * @implemented
  */
-BOOL STDCALL 
-IsValidLocale( 
-   LCID lcid, 
-   DWORD flags 
-   )
-{
-    /* check if language is registered in the kernel32 resources */
-    return FindResourceExW( hCurrentModule, (LPWSTR)RT_STRING,
-                            (LPCWSTR)LOCALE_ILANGUAGE, LANGIDFROMLCID(lcid)) != 0;
+BOOL STDCALL
+IsValidLocale(LCID Locale,
+	      DWORD dwFlags)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
+  WCHAR ValueNameBuffer[9];
+  UNICODE_STRING KeyName;
+  UNICODE_STRING ValueName;
+  ULONG KeyInfoSize;
+  ULONG ReturnedSize;
+  HANDLE KeyHandle;
+  PWSTR ValueData;
+  NTSTATUS Status;
+
+  DPRINT("IsValidLocale() called\n");
+
+  if ((dwFlags & ~(LCID_SUPPORTED | LCID_INSTALLED)) ||
+      (dwFlags == (LCID_SUPPORTED | LCID_INSTALLED)))
+    {
+      DPRINT("Invalid flags: %lx\n", dwFlags);
+      return FALSE;
+    }
+
+  if (Locale & 0xFFFF0000)
+    {
+      RtlInitUnicodeString(&KeyName,
+			   L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Locale\\Alternate Sorts");
+    }
+  else
+    {
+      RtlInitUnicodeString(&KeyName,
+			   L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Locale");
+    }
+
+  InitializeObjectAttributes(&ObjectAttributes,
+			     &KeyName,
+			     OBJ_CASE_INSENSITIVE,
+			     NULL,
+			     NULL);
+
+  Status = NtOpenKey(&KeyHandle,
+		     KEY_QUERY_VALUE,
+		     &ObjectAttributes);
+  if (!NT_SUCCESS(Status))
+    {
+      DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
+      return FALSE;
+    }
+
+  swprintf(ValueNameBuffer, L"%08lx", (ULONG)Locale);
+  RtlInitUnicodeString(&ValueName, ValueNameBuffer);
+
+  KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 4 * sizeof(WCHAR);
+  KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(),
+			    HEAP_ZERO_MEMORY,
+			    KeyInfoSize);
+  if (KeyInfo == NULL)
+    {
+      DPRINT("RtlAllocateHeap() failed (Status %lx)\n", Status);
+      NtClose(KeyHandle);
+      return FALSE;
+    }
+
+  Status = NtQueryValueKey(KeyHandle,
+			   &ValueName,
+			   KeyValuePartialInformation,
+			   KeyInfo,
+			   KeyInfoSize,
+			   &ReturnedSize);
+  NtClose(KeyHandle);
+
+  if (!NT_SUCCESS(Status))
+    {
+      DPRINT("NtQueryValueKey() failed (Status %lx)\n", Status);
+      RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
+      return FALSE;
+    }
+
+  if (dwFlags & LCID_SUPPORTED)
+    {
+      DPRINT("Locale is supported\n");
+      RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
+      return TRUE;
+    }
+
+  ValueData = (PWSTR)&KeyInfo->Data[0];
+  if ((dwFlags & LCID_INSTALLED) &&
+      (KeyInfo->Type == REG_SZ) &&
+      (KeyInfo->DataLength == 2 * sizeof(WCHAR)) &&
+      (ValueData[0] == L'1'))
+    {
+      DPRINT("Locale is supported and installed\n");
+      RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
+      return TRUE;
+    }
+
+  RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
+
+  DPRINT("IsValidLocale() called\n");
+
+  return FALSE;
 }
 
 

reactos/lib/kernel32/misc
nls.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- nls.c	21 Sep 2004 17:41:24 -0000	1.5
+++ nls.c	8 Dec 2004 21:57:11 -0000	1.5.6.1
@@ -656,7 +656,6 @@
    Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
    if (!NT_SUCCESS(Status))
    {
-      RtlFreeUnicodeString(&ValueName);
       return FALSE;
    }
 
@@ -667,14 +666,13 @@
    if (Kvpi == NULL)
    {
       NtClose(KeyHandle);
-      RtlFreeUnicodeString(&ValueName);
       return FALSE;
    }
 
    /* Query the file name for our code page. */
    Status = NtQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
                             Kvpi, KvpiSize, &KvpiSize);
-   RtlFreeUnicodeString(&ValueName);
+
    NtClose(KeyHandle);
 
    /* Check if we succeded and the value is non-empty string. */

reactos/lib/kernel32/misc
profile.c 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- profile.c	13 Oct 2004 19:52:09 -0000	1.14
+++ profile.c	8 Dec 2004 21:57:11 -0000	1.14.2.1
@@ -1,46 +1,76 @@
-/* $Id: profile.c,v 1.14 2004/10/13 19:52:09 gvg Exp $
+/*
+ * Profile functions
  *
- * Imported from Wine
  * Copyright 1993 Miguel de Icaza
  * Copyright 1996 Alexandre Julliard
  *
- * PROJECT:         ReactOS system libraries
- * FILE:            lib/kernel32/misc/profile.c
- * PURPOSE:         Profiles functions
- * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
- *                  modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
- * UPDATE HISTORY:
- *                  Created 01/11/98
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <k32.h>
 
-#define NDEBUG
-#include <debug.h>
+/*
+ * Whole file ripped from Wine's dlls\kernel\profile.c, rev 1.13 and is 
+ * unchanged (to make merging easier) except that includes are different 
+ * and some prototypes were changed to comply with w32api.
+ *
+ * -Gunnar
+ */
+ 
+#define WINVER 0x0500
+
+#include <k32.h>
 
-static CRITICAL_SECTION ProfileLock;
+#include "wine/config.h"
+//#include "wine/port.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(profile);
+
+static const char bom_utf8[] = {0xEF,0xBB,0xBF};
+
+typedef enum
+{
+    ENCODING_ANSI = 1,
+    ENCODING_UTF8,
+    ENCODING_UTF16LE,
+    ENCODING_UTF16BE
+} ENCODING;
 
 typedef struct tagPROFILEKEY
 {
-  WCHAR                 *Value;
-  struct tagPROFILEKEY  *Next;
-  WCHAR                  Name[1];
+    WCHAR                 *value;
+    struct tagPROFILEKEY  *next;
+    WCHAR                  name[1];
 } PROFILEKEY;
 
 typedef struct tagPROFILESECTION
 {
-  struct tagPROFILEKEY       *Key;
-  struct tagPROFILESECTION   *Next;
-  WCHAR                       Name[1];
+    struct tagPROFILEKEY       *key;
+    struct tagPROFILESECTION   *next;
+    WCHAR                       name[1];
 } PROFILESECTION;
 
 
 typedef struct
 {
-  BOOL             Changed;
-  PROFILESECTION  *Section;
-  WCHAR           *FullName;
-  FILETIME         LastWriteTime;
+    BOOL             changed;
+    PROFILESECTION  *section;
+    WCHAR           *filename;
+    FILETIME LastWriteTime;
+    ENCODING encoding;
 } PROFILE;
 
 
@@ -51,12 +81,22 @@
 
 #define CurProfile (MRUProfile[0])
 
-#define PROFILE_MAX_LINE_LEN   1024
-
 /* Check for comments in profile */
 #define IS_ENTRY_COMMENT(str)  ((str)[0] == ';')
 
-/* FUNCTIONS *****************************************************************/
+static const WCHAR emptystringW[] = {0};
+static const WCHAR wininiW[] = { 'w','i','n','.','i','n','i',0 };
+
+static CRITICAL_SECTION PROFILE_CritSect;
+static CRITICAL_SECTION_DEBUG critsect_debug =
+{
+    0, 0, &PROFILE_CritSect,
+    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+      0, 0, { 0, (DWORD)(__FILE__ ": PROFILE_CritSect") }
+};
+static CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
+
+static const char hex[16] = "0123456789ABCDEF";
 
 /***********************************************************************
  *           PROFILE_CopyEntry
@@ -64,65 +104,146 @@
  * Copy the content of an entry into a buffer, removing quotes, and possibly
  * translating environment variables.
  */
-STATIC void FASTCALL
-PROFILE_CopyEntry(LPWSTR Buffer, LPCWSTR Value, int Len, BOOL StripQuote)
+static void PROFILE_CopyEntry( LPWSTR buffer, LPCWSTR value, int len,
+                               BOOL strip_quote )
 {
-  WCHAR Quote = L'\0';
-
-  if (NULL == Buffer)
-    {
-      return;
-    }
+    WCHAR quote = '\0';
 
-  if (StripQuote && (L'\'' == *Value || L'\"' == *Value))
-    {
-      if (L'\0' != Value[1] && (Value[wcslen(Value) - 1] == *Value))
-        {
-          Quote = *Value++;
-        }
-    }
+    if(!buffer) return;
 
-  lstrcpynW(Buffer, Value, Len);
-  if (L'\0' != Quote && wcslen(Value) <= Len)
+    if (strip_quote && ((*value == '\'') || (*value == '\"')))
     {
-      Buffer[wcslen(Buffer) - 1] = L'\0';
+        if (value[1] && (value[strlenW(value)-1] == *value)) quote = *value++;
+    }
+
+    lstrcpynW( buffer, value, len );
+    if (quote && (len >= strlenW(value))) buffer[strlenW(buffer)-1] = '\0';
+}
+
+/* byte-swaps shorts in-place in a buffer. len is in WCHARs */
+static inline void PROFILE_ByteSwapShortBuffer(WCHAR * buffer, int len)
+{
+    int i;
+    USHORT * shortbuffer = (USHORT *)buffer;
+    for (i = 0; i < len; i++)
+        shortbuffer[i] = RtlUshortByteSwap(shortbuffer[i]);
+}
+
+/* writes any necessary encoding marker to the file */
+static inline void PROFILE_WriteMarker(HANDLE hFile, ENCODING encoding)
+{
+    DWORD dwBytesWritten;
+    DWORD bom;
+    switch (encoding)
+    {
+    case ENCODING_ANSI:
+        break;
+    case ENCODING_UTF8:
+        WriteFile(hFile, bom_utf8, sizeof(bom_utf8), &dwBytesWritten, NULL);
+        break;
+    case ENCODING_UTF16LE:
+        bom = 0xFEFF;
+        WriteFile(hFile, &bom, sizeof(bom), &dwBytesWritten, NULL);
+        break;
+    case ENCODING_UTF16BE:
+        bom = 0xFFFE;
+        WriteFile(hFile, &bom, sizeof(bom), &dwBytesWritten, NULL);
+        break;
+    }
+}
+
+static void PROFILE_WriteLine( HANDLE hFile, WCHAR * szLine, int len, ENCODING encoding)
+{
+    char * write_buffer;
+    int write_buffer_len;
+    DWORD dwBytesWritten;
+
+    TRACE("writing: %s\n", debugstr_wn(szLine, len));
+
+    switch (encoding)
+    {
+    case ENCODING_ANSI:
+        write_buffer_len = WideCharToMultiByte(CP_ACP, 0, szLine, len, NULL, 0, NULL, NULL);
+        write_buffer = HeapAlloc(GetProcessHeap(), 0, write_buffer_len);
+        if (!write_buffer) return;
+        len = WideCharToMultiByte(CP_ACP, 0, szLine, len, write_buffer, write_buffer_len, NULL, NULL);
+        WriteFile(hFile, write_buffer, len, &dwBytesWritten, NULL);
+        HeapFree(GetProcessHeap(), 0, write_buffer);
+        break;
+    case ENCODING_UTF8:
+        write_buffer_len = WideCharToMultiByte(CP_UTF8, 0, szLine, len, NULL, 0, NULL, NULL);
+        write_buffer = HeapAlloc(GetProcessHeap(), 0, write_buffer_len);
+        if (!write_buffer) return;
+        len = WideCharToMultiByte(CP_UTF8, 0, szLine, len, write_buffer, write_buffer_len, NULL, NULL);
+        WriteFile(hFile, write_buffer, len, &dwBytesWritten, NULL);
+        HeapFree(GetProcessHeap(), 0, write_buffer);
+        break;
+    case ENCODING_UTF16LE:
+        WriteFile(hFile, szLine, len * sizeof(WCHAR), &dwBytesWritten, NULL);
+        break;
+    case ENCODING_UTF16BE:
+        PROFILE_ByteSwapShortBuffer(szLine, len);
+        WriteFile(hFile, szLine, len * sizeof(WCHAR), &dwBytesWritten, NULL);
+        break;
+    default:
+        FIXME("encoding type %d not implemented\n", encoding);
     }
 }
 
-
 /***********************************************************************
  *           PROFILE_Save
  *
  * Save a profile tree to a file.
  */
-STATIC void FASTCALL
-PROFILE_Save(HANDLE File, PROFILESECTION *Section)
+static void PROFILE_Save( HANDLE hFile, const PROFILESECTION *section, ENCODING encoding )
 {
-  PROFILEKEY *Key;
-  char Buffer[PROFILE_MAX_LINE_LEN];
-  DWORD BytesWritten;
+    PROFILEKEY *key;
+    WCHAR *buffer, *p;
+
+    PROFILE_WriteMarker(hFile, encoding);
 
-  for ( ; NULL != Section; Section = Section->Next)
+    for ( ; section; section = section->next)
     {
-      if (L'\0' != Section->Name[0])
+        int len = 0;
+
+        if (section->name[0]) len += strlenW(section->name) + 6;
+
+        for (key = section->key; key; key = key->next)
         {
-          strcpy(Buffer, "\r\n[");
-          WideCharToMultiByte(CP_ACP, 0, Section->Name, -1, Buffer + 3, sizeof(Buffer) - 6, NULL, NULL);
-          strcat(Buffer, "]\r\n");
-          WriteFile(File, Buffer, strlen(Buffer), &BytesWritten, NULL);
+            len += strlenW(key->name) + 2;
+            if (key->value) len += strlenW(key->value) + 1;
         }
-      for (Key = Section->Key; NULL != Key; Key = Key->Next)
+
+        buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        if (!buffer) return;
+
+        p = buffer;
+        if (section->name[0])
+        {
+            *p++ = '\r';
+            *p++ = '\n';
+            *p++ = '[';
+            strcpyW( p, section->name );
+            p += strlenW(p);
+            *p++ = ']';
+            *p++ = '\r';
+            *p++ = '\n';
+        }
+        for (key = section->key; key; key = key->next)
         {
-          WideCharToMultiByte(CP_ACP, 0, Key->Name, -1, Buffer, sizeof(Buffer) - 3, NULL, NULL);
-          if (Key->Value)
+            strcpyW( p, key->name );
+            p += strlenW(p);
+            if (key->value)
             {
-              strcat(Buffer, "=");
-              WideCharToMultiByte(CP_ACP, 0, Key->Value, -1, Buffer + strlen(Buffer),
-                                  sizeof(Buffer) - strlen(Buffer) - 2, NULL, NULL);
+                *p++ = '=';
+                strcpyW( p, key->value );
+                p += strlenW(p);
             }
-          strcat(Buffer, "\r\n");
-          WriteFile(File, Buffer, strlen(Buffer), &BytesWritten, NULL);
+            *p++ = '\r';
+            *p++ = '\n';
         }
+        PROFILE_WriteLine( hFile, buffer, len, encoding );
+        HeapFree(GetProcessHeap(), 0, buffer);
     }
 }
 
@@ -132,233 +253,340 @@
  *
  * Free a profile tree.
  */
-STATIC void FASTCALL
-PROFILE_Free(PROFILESECTION *Section)
+static void PROFILE_Free( PROFILESECTION *section )
 {
-  PROFILESECTION *NextSection;
-  PROFILEKEY *Key, *NextKey;
+    PROFILESECTION *next_section;
+    PROFILEKEY *key, *next_key;
 
-  for ( ; NULL != Section; Section = NextSection)
+    for ( ; section; section = next_section)
     {
-      for (Key = Section->Key; NULL != Key; Key = NextKey)
+        for (key = section->key; key; key = next_key)
         {
-          NextKey = Key->Next;
-          if (NULL != Key->Value)
-            {
-              HeapFree(GetProcessHeap(), 0, Key->Value);
-            }
-          HeapFree(GetProcessHeap(), 0, Key);
+            next_key = key->next;
+            if (key->value) HeapFree( GetProcessHeap(), 0, key->value );
+            HeapFree( GetProcessHeap(), 0, key );
         }
-      NextSection = Section->Next;
-      HeapFree(GetProcessHeap(), 0, Section);
+        next_section = section->next;
+        HeapFree( GetProcessHeap(), 0, section );
     }
 }
 
-STATIC inline int
-PROFILE_isspace(char c)
+/* returns 1 if a character white space else 0 */
+static inline int PROFILE_isspaceW(WCHAR c)
+{
+   if (isspaceW(c)) return 1;
+   if (c=='\r' || c==0x1a) return 1;
+   /* CR and ^Z (DOS EOF) are spaces too  (found on CD-ROMs) */
+   return 0;
+}
+
+static inline ENCODING PROFILE_DetectTextEncoding(const void * buffer, int * len)
 {
-  if (isspace(c))
+    DWORD flags = IS_TEXT_UNICODE_SIGNATURE |
+                  IS_TEXT_UNICODE_REVERSE_SIGNATURE |
+                  IS_TEXT_UNICODE_ODD_LENGTH;
+    if (*len >= sizeof(bom_utf8) && !memcmp(buffer, bom_utf8, sizeof(bom_utf8)))
+    {
+        *len = sizeof(bom_utf8);
+        return ENCODING_UTF8;
+    }
+    RtlIsTextUnicode((void *)buffer, *len, &flags);
+    if (flags & IS_TEXT_UNICODE_SIGNATURE)
     {
-      return 1;
+        *len = sizeof(WCHAR);
+        return ENCODING_UTF16LE;
     }
-  if ('\r' == c || 0x1a == c)
+    if (flags & IS_TEXT_UNICODE_REVERSE_SIGNATURE)
     {
-      /* CR and ^Z (DOS EOF) are spaces too  (found on CD-ROMs) */
-      return 1;
+        *len = sizeof(WCHAR);
+        return ENCODING_UTF16BE;
     }
-  return 0;
+    *len = 0;
+    return ENCODING_ANSI;
 }
 
+static const WCHAR * PROFILE_GetLine(const WCHAR * szStart, const WCHAR * szEnd)
+{
+    return memchrW(szStart, '\n', szEnd - szStart);
+}
 
 /***********************************************************************
  *           PROFILE_Load
  *
  * Load a profile tree from a file.
  */
-static PROFILESECTION * FASTCALL
-PROFILE_Load(HANDLE File)
+static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
 {
-  char *p, *p2;
-  int Len;
-  PROFILESECTION *Section, *FirstSection;
-  PROFILESECTION **NextSection;
-  PROFILEKEY *Key, *PrevKey, **NextKey;
-  LARGE_INTEGER FileSize;
-  HANDLE Mapping;
-  PVOID BaseAddress;
-  char *Input, *End, *EndLine, *LastNonSpace;
+    void *pBuffer;
+    WCHAR * szFile;
+    const WCHAR *szLineStart, *szLineEnd;
+    const WCHAR *szValueStart, *szNameEnd, *szEnd;
+    int line = 0, len;
+    PROFILESECTION *section, *first_section;
+    PROFILESECTION **next_section;
+    PROFILEKEY *key, *prev_key, **next_key;
+    DWORD dwFileSize;
+    
+    TRACE("%p\n", hFile);
+    
+    dwFileSize = GetFileSize(hFile, NULL);
+    if (dwFileSize == INVALID_FILE_SIZE)
+        return NULL;
+
+    pBuffer = HeapAlloc(GetProcessHeap(), 0 , dwFileSize);
+    if (!pBuffer) return NULL;
+    
+    if (!ReadFile(hFile, pBuffer, dwFileSize, &dwFileSize, NULL))
+    {
+        HeapFree(GetProcessHeap(), 0, pBuffer);
+        WARN("Error %ld reading file\n", GetLastError());
+        return NULL;
+    }
+    len = dwFileSize;
+    *pEncoding = PROFILE_DetectTextEncoding(pBuffer, &len);
+    /* len is set to the number of bytes in the character marker.
+     * we want to skip these bytes */
+    pBuffer = (char *)pBuffer + len;
+    dwFileSize -= len;
+    switch (*pEncoding)
+    {
+    case ENCODING_ANSI:
+        TRACE("ANSI encoding\n");
+
+        len = MultiByteToWideChar(CP_ACP, 0, (char *)pBuffer, dwFileSize, NULL, 0);
+        szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        if (!szFile)
+        {
+            HeapFree(GetProcessHeap(), 0, pBuffer);
+            return NULL;
+        }
+        MultiByteToWideChar(CP_ACP, 0, (char *)pBuffer, dwFileSize, szFile, len);
+        szEnd = szFile + len;
+        break;
+    case ENCODING_UTF8:
+        TRACE("UTF8 encoding\n");
+        
+        len = MultiByteToWideChar(CP_UTF8, 0, (char *)pBuffer, dwFileSize, NULL, 0);
+        szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        if (!szFile)
+        {
+            HeapFree(GetProcessHeap(), 0, pBuffer);
+            return NULL;
+        }
+        MultiByteToWideChar(CP_UTF8, 0, (char *)pBuffer, dwFileSize, szFile, len);
+        szEnd = szFile + len;
+        break;
+    case ENCODING_UTF16LE:
+        TRACE("UTF16 Little Endian encoding\n");
+        szFile = (WCHAR *)pBuffer + 1;
+        szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
+        break;
+    case ENCODING_UTF16BE:
+        TRACE("UTF16 Big Endian encoding\n");
+        szFile = (WCHAR *)pBuffer + 1;
+        szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
+        PROFILE_ByteSwapShortBuffer(szFile, dwFileSize / sizeof(WCHAR));
+        break;
+    default:
+        FIXME("encoding type %d not implemented\n", *pEncoding);
+        HeapFree(GetProcessHeap(), 0, pBuffer);
+        return NULL;
+    }
+
+    first_section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) );
+    if(first_section == NULL)
+    {
+        if (szFile != pBuffer)
+            HeapFree(GetProcessHeap(), 0, szFile);
+        HeapFree(GetProcessHeap(), 0, pBuffer);
+        return NULL;
+    }
+    first_section->name[0] = 0;
+    first_section->key  = NULL;
+    first_section->next = NULL;
+    next_section = &first_section->next;
+    next_key     = &first_section->key;
+    prev_key     = NULL;
+    szLineEnd = szFile - 1; /* will be increased to correct value in loop */
+
+    while (TRUE)
+    {
+        szLineStart = szLineEnd + 1;
+        if (szLineStart >= szEnd)
+            break;
+        szLineEnd = PROFILE_GetLine(szLineStart, szEnd);
+        if (!szLineEnd)
+            szLineEnd = szEnd;
+        line++;
+        
+        while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++;
+        
+        if (szLineStart >= szLineEnd) continue;
+
+        if (*szLineStart == '[')  /* section start */
+        {
+            const WCHAR * szSectionEnd;
+            if (!(szSectionEnd = memrchrW( szLineStart, ']', szLineEnd - szLineStart )))
+            {
+                WARN("Invalid section header at line %d: %s\n",
+                    line, debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) );
+            }
+            else
+            {
+                szLineStart++;
+                len = (int)(szSectionEnd - szLineStart);
+                /* no need to allocate +1 for NULL terminating character as
+                 * already included in structure */
+                if (!(section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) + len * sizeof(WCHAR) )))
+                    break;
+                memcpy(section->name, szLineStart, len * sizeof(WCHAR));
+                section->name[len] = '\0';
+                section->key  = NULL;
+                section->next = NULL;
+                *next_section = section;
+                next_section  = &section->next;
+                next_key      = &section->key;
+                prev_key      = NULL;
+
+                TRACE("New section: %s\n", debugstr_w(section->name));
+
+                continue;
+            }
+        }
+
+        /* get rid of white space at the end of the line */
+        while ((szLineEnd > szLineStart) && ((*szLineEnd == '\n') || PROFILE_isspaceW(*szLineEnd))) szLineEnd--;
+
+        /* line end should be pointing to character *after* the last wanted character */
+        szLineEnd++;
+
+        /* get rid of white space after the name and before the start
+         * of the value */
+        if ((szNameEnd = szValueStart = memchrW( szLineStart, '=', szLineEnd - szLineStart )) != NULL)
+        {
+            szNameEnd = szValueStart - 1;
+            while ((szNameEnd > szLineStart) && PROFILE_isspaceW(*szNameEnd)) szNameEnd--;
+            szValueStart++;
+            while (szValueStart < szLineEnd && PROFILE_isspaceW(*szValueStart)) szValueStart++;
+        }
+        if (!szNameEnd)
+            szNameEnd = szLineEnd - 1;
+        /* name end should be pointing to character *after* the last wanted character */
+        szNameEnd++;
+
+        len = (int)(szNameEnd - szLineStart);
+        
+        if (len || !prev_key || *prev_key->name)
+        {
+            /* no need to allocate +1 for NULL terminating character as
+             * already included in structure */
+            if (!(key = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) + len * sizeof(WCHAR) ))) break;
+            memcpy(key->name, szLineStart, len * sizeof(WCHAR));
+            key->name[len] = '\0';
+            if (szValueStart)
+            {
+                len = (int)(szLineEnd - szValueStart);
+                key->value = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
+                memcpy(key->value, szValueStart, len * sizeof(WCHAR));
+                key->value[len] = '\0';
+            }
+            else key->value = NULL;
+
+           key->next  = NULL;
+           *next_key  = key;
+           next_key   = &key->next;
+           prev_key   = key;
+
+           TRACE("New key: name=%s, value=%s\n",
+               debugstr_w(key->name), key->value ? debugstr_w(key->value) : "(none)");
+        }
+    }
+    if (szFile != pBuffer)
+        HeapFree(GetProcessHeap(), 0, szFile);
+    HeapFree(GetProcessHeap(), 0, pBuffer);
+    return first_section;
+}
 
-  FileSize.u.LowPart = GetFileSize(File, &FileSize.u.HighPart);
-  if (INVALID_FILE_SIZE == FileSize.u.LowPart && 0 != GetLastError())
-    {
-      return NULL;
-    }
 
-  FirstSection = HeapAlloc(GetProcessHeap(), 0, sizeof(*Section));
-  if (NULL == FirstSection)
+/***********************************************************************
+ *           PROFILE_DeleteSection
+ *
+ * Delete a section from a profile tree.
+ */
+static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name )
+{
+    while (*section)
     {
-      return NULL;
+        if ((*section)->name[0] && !strcmpiW( (*section)->name, name ))
+        {
+            PROFILESECTION *to_del = *section;
+            *section = to_del->next;
+            to_del->next = NULL;
+            PROFILE_Free( to_del );
+            return TRUE;
+        }
+        section = &(*section)->next;
     }
-  FirstSection->Name[0] = L'\0';
-  FirstSection->Key  = NULL;
-  FirstSection->Next = NULL;
-  NextSection = &FirstSection->Next;
-  NextKey     = &FirstSection->Key;
-  PrevKey     = NULL;
+    return FALSE;
+}
 
-  if (0 == FileSize.QuadPart)
-    {
-      return FirstSection;
-    }
-  Mapping = CreateFileMappingW(File, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-  if (NULL == Mapping)
-    {
-      HeapFree(GetProcessHeap(), 0, FirstSection);
-      return NULL;
-    }
-  BaseAddress = MapViewOfFile(Mapping, FILE_MAP_READ, 0, 0, 0);
-  if (NULL == BaseAddress)
-    {
-      CloseHandle(Mapping);
-      HeapFree(GetProcessHeap(), 0, FirstSection);
-      return NULL;
-    }
 
-  Input = (char *) BaseAddress;
-  End = Input + FileSize.QuadPart;
-  while (Input < End)
+/***********************************************************************
+ *           PROFILE_DeleteKey
+ *
+ * Delete a key from a profile tree.
+ */
+static BOOL PROFILE_DeleteKey( PROFILESECTION **section,
+                LPCWSTR section_name, LPCWSTR key_name )
+{
+    while (*section)
     {
-      EndLine = Input;
-      LastNonSpace = NULL;
-      while (EndLine < End && '\n' != *EndLine && ';' != *EndLine)
-        {
-          if (! PROFILE_isspace(*EndLine))
-            {
-              LastNonSpace = EndLine;
-            }
-          EndLine++;
-        }
-      if (NULL != LastNonSpace)
-        {
-          EndLine = LastNonSpace + 1;
-        }
-      while (Input < EndLine && PROFILE_isspace(*Input))
-        {
-          Input++;
-        }
-      if (End <= Input)
-        {
-          break;
-        }
-      if ('[' == *Input)  /* section start */
+        if ((*section)->name[0] && !strcmpiW( (*section)->name, section_name ))
         {
-          p = ++Input;
-          while (p < EndLine && ']' != *p)
+            PROFILEKEY **key = &(*section)->key;
+            while (*key)
             {
-              p++;
-            }
-          if (p < EndLine && ']' == *p)
-            {
-              Len = p - Input;
-              if (NULL == (Section = HeapAlloc(GetProcessHeap(), 0,
-                                               sizeof(*Section) + Len * sizeof(WCHAR))))
+                if (!strcmpiW( (*key)->name, key_name ))
                 {
-                  break;
+                    PROFILEKEY *to_del = *key;
+                    *key = to_del->next;
+                    if (to_del->value) HeapFree( GetProcessHeap(), 0, to_del->value);
+                    HeapFree( GetProcessHeap(), 0, to_del );
+                    return TRUE;
                 }
-              MultiByteToWideChar(CP_ACP, 0, Input, Len, Section->Name, Len);
-              Section->Name[Len] = L'\0';
-              Section->Key  = NULL;
-              Section->Next = NULL;
-              *NextSection = Section;
-              NextSection  = &Section->Next;
-              NextKey      = &Section->Key;
-              PrevKey      = NULL;
-
-              DPRINT("New section: %S\n", Section->Name);
-
+                key = &(*key)->next;
             }
-          Input = p;
-          while (Input < End && '\n' != *Input)
-            {
-              Input++;
-            }
-          Input++; /* Skip past the \n */
-          continue;
         }
+        section = &(*section)->next;
+    }
+    return FALSE;
+}
 
-      p = Input;
-      p2 = p;
-      while (p < EndLine && '=' != *p)
-        {
-          if (! PROFILE_isspace(*p))
-            {
-              p2 = p;
-            }
-          p++;
-        }
 
-      if (p2 != Input)
+/***********************************************************************
+ *           PROFILE_DeleteAllKeys
+ *
+ * Delete all keys from a profile tree.
+ */
+void PROFILE_DeleteAllKeys( LPCWSTR section_name)
+{
+    PROFILESECTION **section= &CurProfile->section;
+    while (*section)
+    {
+        if ((*section)->name[0] && !strcmpiW( (*section)->name, section_name ))
         {
-          Len = p2 - Input + 1;
-          if (NULL == (Key = HeapAlloc(GetProcessHeap(), 0,
-                                       sizeof(*Key) + Len * sizeof(WCHAR))))
-            {
-              break;
-            }
-          MultiByteToWideChar(CP_ACP, 0, Input, Len, Key->Name, Len);
-          Key->Name[Len] = L'\0';
-          Input = p + 1;
-          while (Input < EndLine && PROFILE_isspace(*Input))
+            PROFILEKEY **key = &(*section)->key;
+            while (*key)
             {
-              Input++;
+                PROFILEKEY *to_del = *key;
+      *key = to_del->next;
+      if (to_del->value) HeapFree( GetProcessHeap(), 0, to_del->value);
+      HeapFree( GetProcessHeap(), 0, to_del );
+      CurProfile->changed =TRUE;
             }
-          if (EndLine <= Input)
-            {
-              Key->Value = NULL;
-            }
-          else
-            {
-              p2 = Input;
-              p = Input + 1;
-              while (p < EndLine)
-                {
-                  if (! PROFILE_isspace(*p))
-                    {
-                      p2 = p;
-                    }
-                  p++;
-                }
-              Len = p2 - Input + 1;
-              if (NULL == (Key->Value = HeapAlloc(GetProcessHeap(), 0,
-                                                  (Len + 1) * sizeof(WCHAR))))
-                {
-                  break;
-                }
-              MultiByteToWideChar(CP_ACP, 0, Input, Len, Key->Value, Len);
-              Key->Value[Len] = L'\0';
-           }  
-
-          Key->Next  = NULL;
-          *NextKey  = Key;
-          NextKey   = &Key->Next;
-          PrevKey   = Key;
-
-          DPRINT("New key: name=%S, value=%S\n",
-                 Key->Name, NULL != Key->Value ? Key->Value : L"(none)");
-
-          Input = p;
-        }
-      while (Input < End && '\n' != *Input)
-        {
-          Input++;
         }
-      Input++; /* Skip past the \n */
+        section = &(*section)->next;
     }
-
-  UnmapViewOfFile(BaseAddress);
-  CloseHandle(Mapping);
-
-  return FirstSection;
 }
 
 
@@ -367,101 +595,70 @@
  *
  * Find a key in a profile tree, optionally creating it.
  */
-static PROFILEKEY * FASTCALL
-PROFILE_Find(PROFILESECTION **Section, LPCWSTR SectionName,
-             LPCWSTR KeyName, BOOL Create, BOOL CreateAlways)
+static PROFILEKEY *PROFILE_Find( PROFILESECTION **section, LPCWSTR section_name,
+                                 LPCWSTR key_name, BOOL create, BOOL create_always )
 {
-  LPCWSTR p;
-  int SecLen, KeyLen;
-
-  while (PROFILE_isspace(*SectionName))
-    {
-      SectionName++;
-    }
-  p = SectionName + wcslen(SectionName) - 1;
-  while (SectionName < p && PROFILE_isspace(*p))
-    {
-      p--;
-    }
-  SecLen = p - SectionName + 1;
+    LPCWSTR p;
+    int seclen, keylen;
 
-  while (PROFILE_isspace(*KeyName))
-    {
-      KeyName++;
-    }
-  p = KeyName + wcslen(KeyName) - 1;
-  while (KeyName < p && PROFILE_isspace(*p))
-    {
-      p--;
-    }
-  KeyLen = p - KeyName + 1;
-
-  while (NULL != *Section)
-    {
-      if (L'\0' != ((*Section)->Name[0])
-          && 0 == _wcsnicmp((*Section)->Name, SectionName, SecLen)
-          && L'\0' == ((*Section)->Name)[SecLen])
-        {
-          PROFILEKEY **Key = &(*Section)->Key;
-
-          while (NULL != *Key)
-            {
-              /* If create_always is FALSE then we check if the keyname
-               * already exists. Otherwise we add it regardless of its
-               * existence, to allow keys to be added more than once in
-               * some cases.
-               */
-              if (! CreateAlways)
+    while (PROFILE_isspaceW(*section_name)) section_name++;
+    p = section_name + strlenW(section_name) - 1;
+    while ((p > section_name) && PROFILE_isspaceW(*p)) p--;
+    seclen = p - section_name + 1;
+
+    while (PROFILE_isspaceW(*key_name)) key_name++;
+    p = key_name + strlenW(key_name) - 1;
+    while ((p > key_name) && PROFILE_isspaceW(*p)) p--;
+    keylen = p - key_name + 1;
+
+    while (*section)
+    {
+        if ( ((*section)->name[0])
+             && (!(strncmpiW( (*section)->name, section_name, seclen )))
+             && (((*section)->name)[seclen] == '\0') )
+        {
+            PROFILEKEY **key = &(*section)->key;
+
+            while (*key)
+            {
+                /* If create_always is FALSE then we check if the keyname
+                 * already exists. Otherwise we add it regardless of its
+                 * existence, to allow keys to be added more than once in
+                 * some cases.
+                 */
+                if(!create_always)
                 {
-                  if (0 == _wcsnicmp((*Key)->Name, KeyName, KeyLen)
-                      && L'\0' == ((*Key)->Name)[KeyLen])
-                    {
-                      return *Key;
-                    }
+                    if ( (!(strncmpiW( (*key)->name, key_name, keylen )))
+                         && (((*key)->name)[keylen] == '\0') )
+                        return *key;
                 }
-              Key = &(*Key)->Next;
-            }
-          if (! Create)
-            {
-              return NULL;
-            }
-          if (NULL == (*Key = HeapAlloc(GetProcessHeap(), 0,
-                                        sizeof(PROFILEKEY) + wcslen(KeyName) * sizeof(WCHAR))))
-            {
-              return NULL;
+                key = &(*key)->next;
             }
-          wcscpy((*Key)->Name, KeyName);
-          (*Key)->Value = NULL;
-          (*Key)->Next  = NULL;
-          return *Key;
-        }
-      Section = &(*Section)->Next;
-    }
-
-  if (! Create)
-    {
-      return NULL;
-    }
-
-  *Section = HeapAlloc(GetProcessHeap(), 0,
-                       sizeof(PROFILESECTION) + wcslen(SectionName) * sizeof(WCHAR));
-  if (NULL == *Section)
-    {
-      return NULL;
-    }
-  wcscpy((*Section)->Name, SectionName);
-  (*Section)->Next = NULL;
-  if (NULL == ((*Section)->Key = HeapAlloc(GetProcessHeap(), 0,
-                                           sizeof(PROFILEKEY) + wcslen(KeyName) * sizeof(WCHAR))))
-    {
-      HeapFree(GetProcessHeap(), 0, *Section);
-      return NULL;
-    }
-  wcscpy((*Section)->Key->Name, KeyName );
-  (*Section)->Key->Value = NULL;
-  (*Section)->Key->Next  = NULL;
-
-  return (*Section)->Key;
+            if (!create) return NULL;
+            if (!(*key = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) + strlenW(key_name) * sizeof(WCHAR) )))
+                return NULL;
+            strcpyW( (*key)->name, key_name );
+            (*key)->value = NULL;
+            (*key)->next  = NULL;
+            return *key;
+        }
+        section = &(*section)->next;
+    }
+    if (!create) return NULL;
+    *section = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILESECTION) + strlenW(section_name) * sizeof(WCHAR) );
+    if(*section == NULL) return NULL;
+    strcpyW( (*section)->name, section_name );
+    (*section)->next = NULL;
+    if (!((*section)->key  = HeapAlloc( GetProcessHeap(), 0,
+                                        sizeof(PROFILEKEY) + strlenW(key_name) * sizeof(WCHAR) )))
+    {
+        HeapFree(GetProcessHeap(), 0, *section);
+        return NULL;
+    }
+    strcpyW( (*section)->key->name, key_name );
+    (*section)->key->value = NULL;
+    (*section)->key->next  = NULL;
+    return (*section)->key;
 }
 
[truncated at 1000 lines; 2278 more skipped]

reactos/lib/kernel32/misc
stubs.c 1.94 -> 1.94.2.1
diff -u -r1.94 -r1.94.2.1
--- stubs.c	20 Oct 2004 03:46:27 -0000	1.94
+++ stubs.c	8 Dec 2004 21:57:11 -0000	1.94.2.1
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.94 2004/10/20 03:46:27 jimtabor Exp $
+/* $Id: stubs.c,v 1.94.2.1 2004/12/08 21:57:11 hyperion Exp $
  *
  * KERNEL32.DLL stubs (STUB functions)
  * Remove from this file, if you implement them.
@@ -419,7 +419,7 @@
 AllocateUserPhysicalPages(
     HANDLE hProcess,
     PULONG_PTR NumberOfPages,
-    PULONG_PTR PageArray
+    PULONG_PTR UserPfnArray
     )
 {
     STUB;
@@ -746,7 +746,7 @@
 MapUserPhysicalPages(
     PVOID VirtualAddress,
     ULONG_PTR NumberOfPages,
-    PULONG_PTR PageArray OPTIONAL
+    PULONG_PTR PageArray  OPTIONAL
     )
 {
     STUB;
@@ -761,7 +761,7 @@
 MapUserPhysicalPagesScatter(
     PVOID *VirtualAddresses,
     ULONG_PTR NumberOfPages,
-    PULONG_PTR PageArray OPTIONAL
+    PULONG_PTR PageArray  OPTIONAL
     )
 {
     STUB;
@@ -790,21 +790,6 @@
 /*
  * @unimplemented
  */
-DWORD
-STDCALL
-QueueUserAPC(
-    PAPCFUNC pfnAPC,
-    HANDLE hThread,
-    ULONG_PTR dwData
-    )
-{
-    STUB;
-    return 0;
-}
-
-/*
- * @unimplemented
- */
 BOOL
 STDCALL
 QueueUserWorkItem(
@@ -1331,7 +1316,7 @@
     )
 {
     STUB;
-    return 0;
+    return TRUE;
 }
 
 /*
@@ -1645,7 +1630,7 @@
     )
 {
     STUB;
-    return 0;
+    return TRUE;
 }
 
 /*
@@ -1696,20 +1681,6 @@
 /*
  * @unimplemented
  */
-BOOL
-STDCALL
-EnumSystemLanguageGroupsW(
-    LANGUAGEGROUP_ENUMPROCW lpLanguageGroupEnumProc,
-    DWORD                   dwFlags,
-    LONG_PTR                lParam)
-{
-    STUB;
-    return 0;
-}
-
-/*
- * @unimplemented
- */
 ULONGLONG
 STDCALL
 VerSetConditionMask(

reactos/lib/kernel32/misc
time.c 1.32 -> 1.32.2.1
diff -u -r1.32 -r1.32.2.1
--- time.c	21 Nov 2004 06:51:17 -0000	1.32
+++ time.c	8 Dec 2004 21:57:11 -0000	1.32.2.1
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.32 2004/11/21 06:51:17 ion Exp $
+/* $Id: time.c,v 1.32.2.1 2004/12/08 21:57:11 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -21,16 +21,16 @@
 
 typedef struct __DOSTIME
 {
-   WORD	Second:5;
-   WORD	Minute:6;
-   WORD Hour:5;
+  WORD Second:5;
+  WORD Minute:6;
+  WORD Hour:5;
 } DOSTIME, *PDOSTIME;
 
 typedef struct __DOSDATE
 {
-   WORD	Day:5;
-   WORD	Month:4;
-   WORD Year:5;
+  WORD Day:5;
+  WORD Month:4;
+  WORD Year:5;
 } DOSDATE, *PDOSDATE;
 
 #define TICKSPERMIN        600000000
@@ -156,8 +156,8 @@
 BOOL 
 STDCALL
 SystemTimeToFileTime(
-    CONST SYSTEMTIME *  lpSystemTime,	
-    LPFILETIME  lpFileTime 	
+    CONST SYSTEMTIME *  lpSystemTime,
+    LPFILETIME  lpFileTime
    )
 
 {
@@ -217,7 +217,7 @@
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 STDCALL
@@ -226,15 +226,24 @@
 			LPFILETIME lpLocalFileTime
 			)
 {
-  // FIXME: include time bias
-  *((PLONGLONG)lpLocalFileTime) = *((PLONGLONG)lpFileTime);
+  LARGE_INTEGER TimeZoneBias;
+
+  do
+    {
+      TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time;
+      TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart;
+    }
+  while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time);
+
+  *((PLONGLONG)lpLocalFileTime) =
+    *((PLONGLONG)lpFileTime) - TimeZoneBias.QuadPart;
 
   return TRUE;
 }
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 STDCALL
@@ -243,8 +252,17 @@
 			LPFILETIME lpFileTime
 			)
 {
-  // FIXME: include time bias
-  *((PLONGLONG)lpFileTime) = *((PLONGLONG)lpLocalFileTime);
+  LARGE_INTEGER TimeZoneBias;
+
+  do
+    {
+      TimeZoneBias.HighPart = SharedUserData->TimeZoneBias.High1Time;
+      TimeZoneBias.LowPart = SharedUserData->TimeZoneBias.LowPart;
+    }
+  while (TimeZoneBias.HighPart != SharedUserData->TimeZoneBias.High2Time);
+
+  *((PLONGLONG)lpFileTime) =
+    *((PLONGLONG)lpLocalFileTime) + TimeZoneBias.QuadPart;
 
   return TRUE;
 }
@@ -260,8 +278,8 @@
   FILETIME LocalFileTime;
 
   GetSystemTimeAsFileTime(&FileTime);
-  FileTimeToLocalFileTime (&FileTime, &LocalFileTime);
-  FileTimeToSystemTime (&LocalFileTime, lpSystemTime);
+  FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
+  FileTimeToSystemTime(&LocalFileTime, lpSystemTime);
 }
 
 
@@ -274,7 +292,7 @@
   FILETIME FileTime;
 
   GetSystemTimeAsFileTime(&FileTime);
-  FileTimeToSystemTime (&FileTime, lpSystemTime);
+  FileTimeToSystemTime(&FileTime, lpSystemTime);
 }
 
 
@@ -286,12 +304,12 @@
 {
   FILETIME LocalFileTime;
   LARGE_INTEGER FileTime;
-  NTSTATUS errCode;
+  NTSTATUS Status;
 
-  SystemTimeToFileTime (lpSystemTime, &LocalFileTime);
-  LocalFileTimeToFileTime (&LocalFileTime, (FILETIME *)&FileTime);
-  errCode = NtSetSystemTime (&FileTime, &FileTime);
-  if (!NT_SUCCESS(errCode))
+  SystemTimeToFileTime(lpSystemTime, &LocalFileTime);
+  LocalFileTimeToFileTime(&LocalFileTime, (FILETIME *)&FileTime);
+  Status = NtSetSystemTime(&FileTime, &FileTime);
+  if (!NT_SUCCESS(Status))
     return FALSE;
   return TRUE;
 }
@@ -304,11 +322,11 @@
 SetSystemTime(CONST SYSTEMTIME *lpSystemTime)
 {
   LARGE_INTEGER NewSystemTime;
-  NTSTATUS errCode;
+  NTSTATUS Status;
 
-  SystemTimeToFileTime (lpSystemTime, (PFILETIME)&NewSystemTime);
-  errCode = NtSetSystemTime (&NewSystemTime, &NewSystemTime);
-  if (!NT_SUCCESS(errCode))
+  SystemTimeToFileTime(lpSystemTime, (PFILETIME)&NewSystemTime);
+  Status = NtSetSystemTime(&NewSystemTime, &NewSystemTime);
+  if (!NT_SUCCESS(Status))
     return FALSE;
   return TRUE;
 }
@@ -320,13 +338,12 @@
 DWORD STDCALL
 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 {
-   TIME_ZONE_INFORMATION TimeZoneInformation;
    NTSTATUS Status;
 
    DPRINT("GetTimeZoneInformation()\n");
 
    Status = NtQuerySystemInformation(SystemCurrentTimeZoneInformation,
-				     &TimeZoneInformation,
+				     lpTimeZoneInformation,
 				     sizeof(TIME_ZONE_INFORMATION),
 				     NULL);
    if (!NT_SUCCESS(Status))
@@ -335,10 +352,6 @@
 	return TIME_ZONE_ID_INVALID;
      }
 
-   memcpy(lpTimeZoneInformation,
-	  &TimeZoneInformation,
-	  sizeof(TIME_ZONE_INFORMATION));
-
    return(SharedUserData->TimeZoneId);
 }
 
@@ -349,23 +362,27 @@
 BOOL STDCALL
 SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 {
-   TIME_ZONE_INFORMATION TimeZoneInformation;
    NTSTATUS Status;
 
    DPRINT("SetTimeZoneInformation()\n");
 
-   memcpy(&TimeZoneInformation,
-	  lpTimeZoneInformation,
-	  sizeof(TIME_ZONE_INFORMATION));
-
-   Status = RtlSetTimeZoneInformation(&TimeZoneInformation);
+   Status = RtlSetTimeZoneInformation((PTIME_ZONE_INFORMATION)lpTimeZoneInformation);
    if (!NT_SUCCESS(Status))
      {
+	DPRINT1("RtlSetTimeZoneInformation() failed (Status %lx)\n", Status);
 	SetLastErrorByStatus(Status);
 	return FALSE;
      }
 
-   NtSetSystemTime(0,0);
+   Status = NtSetSystemInformation(SystemCurrentTimeZoneInformation,
+				   (PVOID)lpTimeZoneInformation,
+				   sizeof(TIME_ZONE_INFORMATION));
+   if (!NT_SUCCESS(Status))
+     {
+	DPRINT1("NtSetSystemInformation() failed (Status %lx)\n", Status);
+	SetLastErrorByStatus(Status);
+	return FALSE;
+     }
 
    return TRUE;
 }
@@ -397,7 +414,7 @@
 
   if (!lpTimeZoneInformation)
   {
-    GetTimeZoneInformation (&TimeZoneInformation);
+    GetTimeZoneInformation(&TimeZoneInformation);
     lpTzInfo = &TimeZoneInformation;
   }
   else
@@ -409,9 +426,9 @@
   if (!lpLocalTime)
     return FALSE;
 
-  SystemTimeToFileTime (lpUniversalTime, (PFILETIME)&FileTime);
+  SystemTimeToFileTime(lpUniversalTime, (PFILETIME)&FileTime);
   FileTime.QuadPart -= (lpTzInfo->Bias * TICKSPERMIN);
-  FileTimeToSystemTime ((PFILETIME)&FileTime, lpLocalTime);
+  FileTimeToSystemTime((PFILETIME)&FileTime, lpLocalTime);
 
   return TRUE;
 }

reactos/lib/kernel32/string
lstring.c 1.11 -> 1.11.10.1
diff -u -r1.11 -r1.11.10.1
--- lstring.c	4 Jul 2004 18:11:49 -0000	1.11
+++ lstring.c	8 Dec 2004 21:57:12 -0000	1.11.10.1
@@ -21,7 +21,19 @@
 	 LPCSTR lpString2
 	 )
 {
-  return strcmp(lpString1,lpString2);
+   int Result;
+    
+   if (lpString1 == lpString2)
+      return 0;
+   if (lpString1 == NULL)
+      return -1;
+   if (lpString2 == NULL)
+      return 1;
+
+   Result = CompareStringA(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
+   if (Result) Result -= 2;
+    
+   return Result;
 }
 
 
@@ -35,7 +47,20 @@
 	  LPCSTR lpString2
 	  )
 {
-  return _stricmp(lpString1,lpString2); 
+   int Result;
+    
+   if (lpString1 == lpString2)
+      return 0;
+   if (lpString1 == NULL)
+      return -1;
+   if (lpString2 == NULL)
+      return 1;
+
+   Result = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1,
+                           lpString2, -1);
+   if (Result) Result -= 2;
+    
+   return Result;
 }
 
 
@@ -145,7 +170,19 @@
 	 LPCWSTR lpString2
 	 )
 {
-  return wcscmp(lpString1,lpString2);
+   int Result;
+    
+   if (lpString1 == lpString2)
+      return 0;
+   if (lpString1 == NULL)
+      return -1;
+   if (lpString2 == NULL)
+      return 1;
+
+   Result = CompareStringW(GetThreadLocale(), 0, lpString1, -1, lpString2, -1);
+   if (Result) Result -= 2;
+    
+   return Result;
 }
 
 
@@ -159,7 +196,19 @@
     LPCWSTR lpString2
     )
 {
-  return _wcsicmp(lpString1,lpString2);
+   int Result;
+    
+   if (lpString1 == lpString2)
+      return 0;
+   if (lpString1 == NULL)
+      return -1;
+   if (lpString2 == NULL)
+      return 1;
+
+   Result = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpString1, -1, lpString2, -1);
+   if (Result) Result -= 2;
+    
+   return Result;
 }
 
 

reactos/lib/kernel32/synch
wait.c 1.31 -> 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- wait.c	14 Nov 2004 18:47:10 -0000	1.31
+++ wait.c	8 Dec 2004 21:57:12 -0000	1.31.2.1
@@ -1,4 +1,4 @@
-/* $Id: wait.c,v 1.31 2004/11/14 18:47:10 hbirr Exp $
+/* $Id: wait.c,v 1.31.2.1 2004/12/08 21:57:12 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -220,22 +220,13 @@
       RtlFreeHeap(RtlGetProcessHeap(), 0, HandleBuffer);
     }
 
-  if (Status == STATUS_TIMEOUT)
-    {
-      return WAIT_TIMEOUT;
-    }
-  else if (((Status >= WAIT_OBJECT_0) &&
-	    (Status <= WAIT_OBJECT_0 + nCount - 1)) ||
-	   ((Status >= WAIT_ABANDONED_0) &&
-	    (Status <= WAIT_ABANDONED_0 + nCount - 1)))
+  if (HIWORD(Status))
     {
-      return Status;
+      SetLastErrorByStatus (Status);
+      return WAIT_FAILED;
     }
 
-  DPRINT("Status %lx\n", Status);
-  SetLastErrorByStatus (Status);
-
-  return WAIT_FAILED;
+  return Status;
 }
 
 

reactos/lib/kernel32/thread
thread.c 1.56 -> 1.56.2.1
diff -u -r1.56 -r1.56.2.1
--- thread.c	2 Nov 2004 21:51:25 -0000	1.56
+++ thread.c	8 Dec 2004 21:57:12 -0000	1.56.2.1
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.56 2004/11/02 21:51:25 weiden Exp $
+/* $Id: thread.c,v 1.56.2.1 2004/12/08 21:57:12 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -771,4 +771,27 @@
   DPRINT1("SetThreadUILanguage(0x%x) unimplemented!\n", Unknown1);
 }
 
+static void CALLBACK
+IntCallUserApc(PVOID Function, PVOID dwData, PVOID Argument3)
+{
+   PAPCFUNC pfnAPC = (PAPCFUNC)Function;
+   pfnAPC((ULONG_PTR)dwData);
+}
+
+/*
+ * @implemented
+ */
+DWORD STDCALL
+QueueUserAPC(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData)
+{
+  NTSTATUS Status;
+
+  Status = NtQueueApcThread(hThread, IntCallUserApc, pfnAPC,
+                            (PVOID)dwData, NULL);
+  if (Status)
+    SetLastErrorByStatus(Status);
+
+  return NT_SUCCESS(Status);
+}
+
 /* EOF */

reactos/lib/kjs
makefile 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- makefile	10 Jan 2004 20:38:17 -0000	1.1
+++ makefile	8 Dec 2004 21:57:12 -0000	1.1.24.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.1 2004/01/10 20:38:17 arty Exp $
+# $Id: makefile,v 1.1.24.1 2004/12/08 21:57:12 hyperion Exp $
 # Kernel JavaScript
 # 
 # You can use this for various things but the most obvious is as a powerful
@@ -71,7 +71,7 @@
 	       src/heap.o \
 	       src/utils.o
 TARGET_OBJECTS = $(ORIG_OBJECTS) $(MOD_OBJECTS) $(ARCH_OBJECTS) \
-		../../dk/w32/lib/ntdll.a
+		../../dk/w32/lib/libntdll.a
 DEP_OBJECTS = $(TARGET_OBJECTS)
 
 include $(PATH_TO_TOP)/rules.mak

reactos/lib/libwine
makefile 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- makefile	16 Sep 2004 10:25:15 -0000	1.3
+++ makefile	8 Dec 2004 21:57:12 -0000	1.3.6.1
@@ -1,10 +1,10 @@
-# $Id: makefile,v 1.3 2004/09/16 10:25:15 gvg Exp $
+# $Id: makefile,v 1.3.6.1 2004/12/08 21:57:12 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
 TARGET_TYPE = library
 
-TARGET_NAME = libwine
+TARGET_NAME = wine
 
 TARGET_CFLAGS = -D__REACTOS__
 

reactos/lib/midimap
.cvsignore 1.1 -> 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- .cvsignore	9 Nov 2004 14:52:52 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:57:12 -0000	1.1.2.1
@@ -8,4 +8,5 @@
 *.tmp
 temp.exp
 midimap.spec.def
+midimap.stubs.c
 Makefile.ros

reactos/lib/midimap
Makefile.ros-template 1.1 -> 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- Makefile.ros-template	9 Nov 2004 14:52:52 -0000	1.1
+++ Makefile.ros-template	8 Dec 2004 21:57:12 -0000	1.1.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.1 2004/11/09 14:52:52 ion Exp $
+# $Id: Makefile.ros-template,v 1.1.2.1 2004/12/08 21:57:12 hyperion Exp $
 
 TARGET_NAME = midimap
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_LIB_BASE_MIDIMAP)
 

reactos/lib/mpr
Makefile.in 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Makefile.in	16 Oct 2004 20:27:35 -0000	1.3
+++ Makefile.in	8 Dec 2004 21:57:12 -0000	1.3.2.1
@@ -14,9 +14,7 @@
 	pwcache.c \
 	wnet.c
 
-RC_SRCS = \
-	mpr.rc
-
+RC_SRCS = mpr.rc
 
 @MAKE_DLL_RULES@
 

reactos/lib/mpr
Makefile.ros-template 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Makefile.ros-template	16 Oct 2004 20:27:35 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:12 -0000	1.3.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/10/16 20:27:35 gvg Exp $
+# $Id: Makefile.ros-template,v 1.3.2.1 2004/12/08 21:57:12 hyperion Exp $
 
 TARGET_NAME = mpr
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ kernel32.a libwine.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ kernel32.a wine.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_MPR)
 

reactos/lib/mpr
mpr.spec 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- mpr.spec	1 Feb 2004 19:48:44 -0000	1.1
+++ mpr.spec	8 Dec 2004 21:57:12 -0000	1.1.22.1
@@ -23,7 +23,7 @@
 24 stdcall @(ptr) MPR_Free
 25 stdcall @(ptr long) _MPR_25
 
-@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllCanUnloadNow() MPR_DllCanUnloadNow
 @ stub DllGetClassObject
 @ stdcall MultinetGetConnectionPerformanceA(ptr ptr)
 @ stdcall MultinetGetConnectionPerformanceW(ptr ptr)

reactos/lib/mpr
mpr_main.c 1.4 -> 1.4.16.1
diff -u -r1.4 -r1.4.16.1
--- mpr_main.c	16 Jun 2004 06:58:48 -0000	1.4
+++ mpr_main.c	8 Dec 2004 21:57:12 -0000	1.4.16.1
@@ -75,7 +75,7 @@
 /*****************************************************************
  *  DllCanUnloadNow  [MPR.@]
  */
-DWORD WINAPI DllCanUnloadNow(void)
+DWORD WINAPI MPR_DllCanUnloadNow(void)
 {
     FIXME("Stub\n");
     return S_OK;

reactos/lib/mpr
version.rc 1.1 -> 1.1.18.1
diff -u -r1.1 -r1.1.18.1
--- version.rc	15 Apr 2004 09:28:04 -0000	1.1
+++ version.rc	8 Dec 2004 21:57:12 -0000	1.1.18.1
@@ -24,6 +24,5 @@
 #define WINE_FILEVERSION_STR "5.00.2195.6611"
 #define WINE_PRODUCTVERSION 5,0,2195,6611
 #define WINE_PRODUCTVERSION_STR "5.00.2195.6611"
-#define WINE_PRODUCTNAME_STR "Wine"
 
 #include "wine/wine_common_ver.rc"

reactos/lib/msacm
Makefile.ros-template 1.3 -> 1.3.8.1
diff -u -r1.3 -r1.3.8.1
--- Makefile.ros-template	14 Jul 2004 18:30:54 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:12 -0000	1.3.8.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/07/14 18:30:54 sedwards Exp $
+# $Id: Makefile.ros-template,v 1.3.8.1 2004/12/08 21:57:12 hyperion Exp $
 
 TARGET_NAME = msacm32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ ntdll.a libwine.a
+TARGET_SDKLIBS = @IMPORTS@ ntdll.a wine.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_MSACM)
 

reactos/lib/msafd/include
msafd.h 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- msafd.h	15 Nov 2004 18:24:56 -0000	1.9
+++ msafd.h	8 Dec 2004 21:57:12 -0000	1.9.2.1
@@ -22,11 +22,17 @@
 #include <helpers.h>
 #include <debug.h>
 
+/* Because our headers are f*cked up */
+typedef LARGE_INTEGER TIME;
+#include <ntos/zw.h>
+
 extern HANDLE GlobalHeap;
 extern WSPUPCALLTABLE Upcalls;
 extern LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest;
 extern LIST_ENTRY SockHelpersListHead;
 extern HANDLE SockEvent;
+extern HANDLE SockAsyncCompletionPort;
+extern BOOLEAN SockAsyncSelectCalled;
 
 typedef enum _SOCKET_STATE {
     SocketOpen,
@@ -74,41 +80,48 @@
     LONG						Unknown;
     DWORD						SequenceNumber;
     UINT						wMsg;
-    LONG						Event;
-    LONG						DisabledEvents;
+    LONG						AsyncEvents;
+    LONG						AsyncDisabledEvents;
 } SOCK_SHARED_INFO, *PSOCK_SHARED_INFO;
 
 typedef struct _SOCKET_INFORMATION {
-    ULONG						RefCount;
-    SOCKET						Handle;
-	SOCK_SHARED_INFO			SharedData;
-    DWORD						HelperEvents;
-    PHELPER_DATA				HelperData;
-    PVOID						HelperContext;
-    PSOCKADDR					LocalAddress;
-    PSOCKADDR					RemoteAddress;
-    HANDLE						TdiAddressHandle;
-    HANDLE						TdiConnectionHandle;
-    PVOID						AsyncData;
-    HANDLE						EventObject;
-    LONG						NetworkEvents;
-    CRITICAL_SECTION			Lock;
-    PVOID						SanData;
-	BOOL						TrySAN;
-	SOCKADDR					WSLocalAddress;
-	SOCKADDR					WSRemoteAddress;
+	ULONG RefCount;
+	SOCKET Handle;
+	SOCK_SHARED_INFO SharedData;
+	DWORD HelperEvents;
+	PHELPER_DATA HelperData;
+	PVOID HelperContext;
+	PSOCKADDR LocalAddress;
+	PSOCKADDR RemoteAddress;
+	HANDLE TdiAddressHandle;
+	HANDLE TdiConnectionHandle;
+	PVOID AsyncData;
+	HANDLE EventObject;
+	LONG NetworkEvents;
+	CRITICAL_SECTION Lock;
+	PVOID SanData;
+	BOOL TrySAN;
+	SOCKADDR WSLocalAddress;
+	SOCKADDR WSRemoteAddress;
 } SOCKET_INFORMATION, *PSOCKET_INFORMATION;
 
 
 typedef struct _SOCKET_CONTEXT {
-	SOCK_SHARED_INFO			SharedData;
-	ULONG						SizeOfHelperData;
-	ULONG						Padding;
-	SOCKADDR					LocalAddress;
-	SOCKADDR					RemoteAddress;
+	SOCK_SHARED_INFO SharedData;
+	ULONG SizeOfHelperData;
+	ULONG Padding;
+	SOCKADDR LocalAddress;
+	SOCKADDR RemoteAddress;
 	/* Plus Helper Data */
 } SOCKET_CONTEXT, *PSOCKET_CONTEXT;
 
+typedef struct _ASYNC_DATA {
+	PSOCKET_INFORMATION ParentSocket;
+	DWORD SequenceNumber;
+	IO_STATUS_BLOCK IoStatusBlock;
+	AFD_POLL_INFO AsyncSelectInfo;
+} ASYNC_DATA, *PASYNC_DATA;
+
 SOCKET
 WSPAPI
 WSPAccept(
@@ -416,6 +429,42 @@
 int CreateContext(
 	PSOCKET_INFORMATION Socket
 );
+
+int SockAsyncThread(
+	PVOID ThreadParam
+);
+
+VOID 
+SockProcessAsyncSelect(
+	PSOCKET_INFORMATION Socket,
+	PASYNC_DATA AsyncData
+);
+
+VOID
+SockAsyncSelectCompletionRoutine(
+	PVOID Context,
+	PIO_STATUS_BLOCK IoStatusBlock
+);
+
+BOOLEAN
+SockCreateOrReferenceAsyncThread(
+	VOID
+);
+
+BOOLEAN SockGetAsyncSelectHelperAfdHandle(
+	VOID
+);
+
+VOID SockProcessQueuedAsyncSelect(
+	PVOID Context,
+	PIO_STATUS_BLOCK IoStatusBlock
+);
+
+DWORD MsafdReturnWithErrno( NTSTATUS Status, LPINT Errno, DWORD Received,
+			    LPDWORD ReturnedBytes );
+
+typedef VOID (*PASYNC_COMPLETION_ROUTINE)(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock);
+
 #endif /* __MSAFD_H */
 
 /* EOF */

reactos/lib/msafd/misc
dllmain.c 1.19 -> 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- dllmain.c	17 Nov 2004 05:17:22 -0000	1.19
+++ dllmain.c	8 Dec 2004 21:57:13 -0000	1.19.2.1
@@ -20,12 +20,16 @@
 DWORD DebugTraceLevel = 0;
 #endif /* DBG */
 
-HANDLE							GlobalHeap;
-WSPUPCALLTABLE					Upcalls;
-LPWPUCOMPLETEOVERLAPPEDREQUEST	lpWPUCompleteOverlappedRequest;
-ULONG							SocketCount;
-PSOCKET_INFORMATION 			*Sockets = NULL;
-LIST_ENTRY						SockHelpersListHead = {NULL};
+HANDLE GlobalHeap;
+WSPUPCALLTABLE Upcalls;
+LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest;
+ULONG SocketCount;
+PSOCKET_INFORMATION *Sockets = NULL;
+LIST_ENTRY SockHelpersListHead = {NULL};
+ULONG SockAsyncThreadRefCount;
+HANDLE SockAsyncHelperAfdHandle;
+HANDLE SockAsyncCompletionPort;
+BOOLEAN SockAsyncSelectCalled;
 
 SOCKET 
 WSPAPI 
@@ -255,6 +259,24 @@
 }
 
 
+DWORD MsafdReturnWithErrno( NTSTATUS Status, LPINT Errno, DWORD Received,
+			    LPDWORD ReturnedBytes ) {
+    switch (Status) {
+    case STATUS_CANT_WAIT: *Errno = WSAEWOULDBLOCK; break;
+    case STATUS_TIMEOUT:
+    case STATUS_SUCCESS: 
+	/* Return Number of bytes Read */
+	if( ReturnedBytes ) *ReturnedBytes = Received; break;
+    case STATUS_PENDING: *Errno = WSA_IO_PENDING; break;
+    case STATUS_BUFFER_OVERFLOW: *Errno = WSAEMSGSIZE; break;
+    default: *Errno = WSAEINVAL; break;
+    }
+
+    /* Success */
+    return Status == STATUS_SUCCESS ? 0 : SOCKET_ERROR;
+}
+
+
 INT
 WSPAPI
 WSPCloseSocket(
@@ -353,7 +375,8 @@
 
 	NtClose( SockEvent );
 
-	return 0;
+	return MsafdReturnWithErrno
+	    ( IOSB.Status, lpErrno, IOSB.Information, NULL );
 }
 
 int 
@@ -399,7 +422,8 @@
 
 	NtClose( SockEvent );
 
-	return 0;
+	return MsafdReturnWithErrno
+	    ( IOSB.Status, lpErrno, IOSB.Information, NULL );
 }
 
 
@@ -426,7 +450,7 @@
     Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
 			    NULL, 1, FALSE );
     
-    if( !NT_SUCCESS(Status) ) return -1;
+    if( !NT_SUCCESS(Status) ) return SOCKET_ERROR;
     
     /* Find out how many sockets we have, and how large the buffer needs 
      * to be */
@@ -456,7 +480,7 @@
     
     /* Number of handles for AFD to Check */
     PollInfo->HandleCount = HandleCount;
-    PollInfo->InternalUse = 0;
+    PollInfo->Exclusive = FALSE;
     
     if (readfds != NULL) {
 	for (i = 0; i < readfds->fd_count; i++, j++) {
@@ -540,6 +564,7 @@
     }
 
     NtClose( SockEvent );
+
     switch( IOSB.Status ) {
     case STATUS_SUCCESS: 
     case STATUS_TIMEOUT: *lpErrno = 0; break;
@@ -909,8 +934,8 @@
 	AFD_DbgPrint(MID_TRACE,("Ending\n"));
 
 	NtClose( SockEvent );
-
-	return Status;
+    
+    return MsafdReturnWithErrno( IOSB.Status, lpErrno, 0, NULL );
 }
 int
 WSPAPI 
@@ -979,7 +1004,7 @@
 
 	NtClose( SockEvent );
 
-	return 0;
+    return MsafdReturnWithErrno( IOSB.Status, lpErrno, 0, NULL );
 }
 
 
@@ -1029,13 +1054,13 @@
 
     switch( dwIoControlCode ) {
     case FIONBIO:
-	if( cbInBuffer < sizeof(INT) ) return -1;
+	if( cbInBuffer < sizeof(INT) ) return SOCKET_ERROR;
 	Socket->SharedData.NonBlocking = *((PINT)lpvInBuffer) ? 1 : 0;
 	AFD_DbgPrint(MID_TRACE,("[%x] Set nonblocking %d\n",
 				Handle, Socket->SharedData.NonBlocking));
 	return 0;
     default:
-	return -1;
+	return SOCKET_ERROR;
     }
 }
 
@@ -1291,6 +1316,342 @@
 	return 0;
 }
 
+BOOLEAN SockCreateOrReferenceAsyncThread(VOID)
+{
+	HANDLE hAsyncThread;
+	DWORD AsyncThreadId;
+	HANDLE AsyncEvent;
+	OBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleFlags;
+	NTSTATUS Status;
+
+	/* Check if the Thread Already Exists */
+	if (SockAsyncThreadRefCount) {
+		return TRUE;
+	}
+	
+	/* Create the Completion Port */
+	if (!SockAsyncCompletionPort) {
+		Status = NtCreateIoCompletion(&SockAsyncCompletionPort,
+					      IO_COMPLETION_ALL_ACCESS,
+					      NULL,
+					      2); // Allow 2 threads only
+	
+		/* Protect Handle */	
+		HandleFlags.ProtectFromClose = TRUE;
+		HandleFlags.Inherit = FALSE;
+		Status = NtSetInformationObject(SockAsyncCompletionPort,
+						ObjectHandleInformation,
+						&HandleFlags,
+						sizeof(HandleFlags));
+	}
+    
+	/* Create the Async Event */
+	Status = NtCreateEvent(&AsyncEvent,
+			       EVENT_ALL_ACCESS,
+			       NULL,
+			       NotificationEvent,
+			       FALSE);
+    
+	/* Create the Async Thread */
+	hAsyncThread = CreateThread(NULL,
+				    0,
+				    (LPTHREAD_START_ROUTINE)SockAsyncThread,
+				    NULL,
+				    0,
+				    &AsyncThreadId);
+
+	/* Close the Handle */
+	NtClose(hAsyncThread);
+
+	/* Increase the Reference Count */
+	SockAsyncThreadRefCount++;
+	return TRUE;
+}
+
+int SockAsyncThread(PVOID ThreadParam)
+{
+	PVOID AsyncContext;
+	PASYNC_COMPLETION_ROUTINE AsyncCompletionRoutine;
+	IO_STATUS_BLOCK IOSB;
+	NTSTATUS Status;
+	LARGE_INTEGER Timeout;
+                          
+	/* Make the Thread Higher Priority */
+	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
+	
+	/* Do a KQUEUE/WorkItem Style Loop, thanks to IoCompletion Ports */
+	do {
+		Status =  NtRemoveIoCompletion (SockAsyncCompletionPort,
+						(PVOID*)&AsyncCompletionRoutine,
+						&AsyncContext,
+						&IOSB,
+						&Timeout);
+						
+		/* Call the Async Function */
+		if (NT_SUCCESS(Status)) {
+			//(*AsyncCompletionRoutine)(AsyncContext, IOSB);
+		} else {
+			/* It Failed, sleep for a second */
+			Sleep(1000);
+		}
+	} while ((Status != STATUS_TIMEOUT));
+
+    /* The Thread has Ended */
+    return 0;
+}
+
+BOOLEAN SockGetAsyncSelectHelperAfdHandle(VOID)
+{
+	UNICODE_STRING AfdHelper;
+	OBJECT_ATTRIBUTES ObjectAttributes;
+	IO_STATUS_BLOCK IoSb;
+	NTSTATUS Status;
+	FILE_COMPLETION_INFORMATION CompletionInfo;
+	OBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleFlags;
+
+	/* First, make sure we're not already intialized */
+	if (SockAsyncHelperAfdHandle) {
+		return TRUE;
+	}
+
+	/* Set up Handle Name and Object */
+	RtlInitUnicodeString(&AfdHelper, L"\\Device\\Afd\\AsyncSelectHlp" );
+	InitializeObjectAttributes(&ObjectAttributes,
+				   &AfdHelper,
+				   OBJ_INHERIT | OBJ_CASE_INSENSITIVE,
+				   NULL,
+				   NULL);
+
+	/* Open the Handle to AFD */
+	Status = NtCreateFile(&SockAsyncHelperAfdHandle,
+			      GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
+			      &ObjectAttributes,
+			      &IoSb,
+			      NULL,
+			      0,
+			      FILE_SHARE_READ | FILE_SHARE_WRITE,
+			      FILE_OPEN_IF,
+			      0,
+			      NULL,
+			      0);
+
+	/* 
+	 * Now Set up the Completion Port Information 
+	 * This means that whenever a Poll is finished, the routine will be executed
+	 */
+	CompletionInfo.Port = SockAsyncCompletionPort;
+	CompletionInfo.Key = SockAsyncSelectCompletionRoutine;
+	Status = NtSetInformationFile(SockAsyncHelperAfdHandle,
+				      &IoSb,
+				      &CompletionInfo,
+				      sizeof(CompletionInfo),
+				      FileCompletionInformation);
+				      
+				      
+	/* Protect the Handle */
+	HandleFlags.ProtectFromClose = TRUE;
+	HandleFlags.Inherit = FALSE;
+	Status = NtSetInformationObject(SockAsyncCompletionPort,
+					ObjectHandleInformation,
+					&HandleFlags,
+					sizeof(HandleFlags));
+
+
+	/* Set this variable to true so that Send/Recv/Accept will know wether to renable disabled events */
+	SockAsyncSelectCalled = TRUE;
+	return TRUE;
+}
+
+VOID SockAsyncSelectCompletionRoutine(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
+{
+
+	PASYNC_DATA AsyncData = Context;
+	PSOCKET_INFORMATION Socket;
+	ULONG x;
+    
+	/* Get the Socket */
+	Socket = AsyncData->ParentSocket;
+	
+	/* Check if the Sequence  Number Changed behind our back */
+	if (AsyncData->SequenceNumber != Socket->SharedData.SequenceNumber ){
+		return;
+	}
+
+	/* Check we were manually called b/c of a failure */
+	if (!NT_SUCCESS(IoStatusBlock->Status)) {
+		/* FIXME: Perform Upcall */
+		return;
+	}
+
+
+	for (x = 1; x; x<<=1) {
+		switch (AsyncData->AsyncSelectInfo.Handles[0].Events & x) {
+			case AFD_EVENT_RECEIVE:
+				if ((Socket->SharedData.AsyncEvents & FD_READ) && (!Socket->SharedData.AsyncDisabledEvents & FD_READ)) {
+					/* Make the Notifcation */
+					(Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd,
+								   Socket->SharedData.wMsg,
+								   Socket->Handle,
+								   WSAMAKESELECTREPLY(FD_READ, 0));
+					/* Disable this event until the next read(); */
+					Socket->SharedData.AsyncDisabledEvents |= FD_READ;
+				}
+			
+			case AFD_EVENT_OOB_RECEIVE:
+				if ((Socket->SharedData.AsyncEvents & FD_OOB) && (!Socket->SharedData.AsyncDisabledEvents & FD_OOB)) {
+					/* Make the Notifcation */
+					(Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd,
+								   Socket->SharedData.wMsg,
+								   Socket->Handle,
+								   WSAMAKESELECTREPLY(FD_OOB, 0));
+					/* Disable this event until the next read(); */
+					Socket->SharedData.AsyncDisabledEvents |= FD_OOB;
+				}
+		
+			case AFD_EVENT_SEND:
+				if ((Socket->SharedData.AsyncEvents & FD_WRITE) && (!Socket->SharedData.AsyncDisabledEvents & FD_WRITE)) {
+					/* Make the Notifcation */
+					(Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd,
+								   Socket->SharedData.wMsg,
+								   Socket->Handle,
+								   WSAMAKESELECTREPLY(FD_WRITE, 0));
+					/* Disable this event until the next write(); */
+					Socket->SharedData.AsyncDisabledEvents |= FD_WRITE;
+				}
+				
+			case AFD_EVENT_ACCEPT:
+				if ((Socket->SharedData.AsyncEvents & FD_ACCEPT) && (!Socket->SharedData.AsyncDisabledEvents & FD_ACCEPT)) {
+					/* Make the Notifcation */
+					(Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd,
+								   Socket->SharedData.wMsg,
+								   Socket->Handle,
+								   WSAMAKESELECTREPLY(FD_ACCEPT, 0));
+					/* Disable this event until the next accept(); */
+					Socket->SharedData.AsyncDisabledEvents |= FD_ACCEPT;
+				}
+
+			case AFD_EVENT_DISCONNECT:
+			case AFD_EVENT_ABORT:
+			case AFD_EVENT_CLOSE:
+				if ((Socket->SharedData.AsyncEvents & FD_CLOSE) && (!Socket->SharedData.AsyncDisabledEvents & FD_CLOSE)) {
+					/* Make the Notifcation */
+					(Upcalls.lpWPUPostMessage)(Socket->SharedData.hWnd,
+								   Socket->SharedData.wMsg,
+								   Socket->Handle,
+								   WSAMAKESELECTREPLY(FD_CLOSE, 0));
+					/* Disable this event forever; */
+					Socket->SharedData.AsyncDisabledEvents |= FD_CLOSE;
+				}
+
+			/* FIXME: Support QOS */
+		}
+	}
+	
+	/* Check if there are any events left for us to check */
+	if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0 ) {
+		return;
+	}
+
+	/* Keep Polling */
+	SockProcessAsyncSelect(Socket, AsyncData);
+	return;
+}
+
+VOID SockProcessAsyncSelect(PSOCKET_INFORMATION Socket, PASYNC_DATA AsyncData)
+{
+
+	ULONG lNetworkEvents;
+	NTSTATUS Status;
+
+	/* Set up the Async Data Event Info */
+	AsyncData->AsyncSelectInfo.Timeout.HighPart = 0x7FFFFFFF;
+	AsyncData->AsyncSelectInfo.Timeout.LowPart = 0xFFFFFFFF;
+	AsyncData->AsyncSelectInfo.HandleCount = 1;
+	AsyncData->AsyncSelectInfo.Exclusive = TRUE;
+	AsyncData->AsyncSelectInfo.Handles[0].Handle = Socket->Handle;
+	AsyncData->AsyncSelectInfo.Handles[0].Events = 0;
+
+	/* Remove unwanted events */
+	lNetworkEvents = Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents);
+
+	/* Set Events to wait for */
+	if (lNetworkEvents & FD_READ) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_RECEIVE;
+	}
+
+	if (lNetworkEvents & FD_WRITE) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_SEND;
+	}
+
+	if (lNetworkEvents & FD_OOB) {
+	        AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_OOB_RECEIVE;
+	}
+
+	if (lNetworkEvents & FD_ACCEPT) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_ACCEPT;
+	}
+
+	if (lNetworkEvents & FD_CONNECT) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_CONNECT | AFD_EVENT_CONNECT_FAIL;
+	}
+
+	if (lNetworkEvents & FD_CLOSE) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
+	}
+
+	if (lNetworkEvents & FD_QOS) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_QOS;
+	}
+
+	if (lNetworkEvents & FD_GROUP_QOS) {
+		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_GROUP_QOS;
+	}
+	
+	/* Send IOCTL */
+	Status = NtDeviceIoControlFile (SockAsyncHelperAfdHandle,
+					NULL,
+					NULL,
+					AsyncData,
+					&AsyncData->IoStatusBlock,
+					IOCTL_AFD_SELECT,
+					&AsyncData->AsyncSelectInfo,
+					sizeof(AsyncData->AsyncSelectInfo),
+					&AsyncData->AsyncSelectInfo,
+					sizeof(AsyncData->AsyncSelectInfo));
+
+	/* I/O Manager Won't call the completion routine, let's do it manually */
+	if (NT_SUCCESS(Status)) {
+		return;
+	} else {
+		AsyncData->IoStatusBlock.Status = Status;
+		SockAsyncSelectCompletionRoutine(AsyncData, &AsyncData->IoStatusBlock);
+	}
+}
+
+VOID SockProcessQueuedAsyncSelect(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock)
+{
+	PASYNC_DATA AsyncData = Context;
+	PSOCKET_INFORMATION Socket;
+
+	/* Get the Socket */	
+	Socket = AsyncData->ParentSocket;
+
+	/* If someone closed it, stop the function */
+	if (Socket->SharedData.State != SocketClosed) {
+		/* Check if the Sequence Number changed by now, in which case quit */
+		if (AsyncData->SequenceNumber == Socket->SharedData.SequenceNumber) {
+			/* Do the actuall select, if needed */
+			if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents))) {
+				SockProcessAsyncSelect(Socket, AsyncData);
+			}
+		}
+	}
+	
+	/* Free the Context */
+	HeapFree(GetProcessHeap(), 0, AsyncData);
+	return;
+}
+
 BOOL
 STDCALL
 DllMain(HANDLE hInstDll,

reactos/lib/msafd/misc
event.c 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- event.c	26 Sep 2004 07:55:32 -0000	1.3
+++ event.c	8 Dec 2004 21:57:13 -0000	1.3.6.1
@@ -10,6 +10,7 @@
  *	 Alex 16/07/2004 - Complete Rewrite
  */
 
+#include <roscfg.h>
 #include <msafd.h>
 
 int 
@@ -42,7 +43,10 @@
 
 	/* Deactivate Async Select if there is one */
 	if (Socket->EventObject) {
-		//SockAsyncSelect(Socket, NULL, 0, 0);
+		Socket->SharedData.hWnd = NULL;
+		Socket->SharedData.wMsg = 0;
+		Socket->SharedData.AsyncEvents = 0;
+		Socket->SharedData.SequenceNumber++; // This will kill Async Select after the next completion
 	}
 
 	/* Set Structure Info */
@@ -55,7 +59,7 @@
     }
 
     if (lNetworkEvents & FD_WRITE) {
-		EventSelectInfo.Events |= AFD_EVENT_SEND;
+	EventSelectInfo.Events |= AFD_EVENT_SEND;
     }
 
     if (lNetworkEvents & FD_OOB) {
@@ -63,7 +67,7 @@
     }
 
     if (lNetworkEvents & FD_ACCEPT) {
-		EventSelectInfo.Events |= AFD_EVENT_ACCEPT;
+	EventSelectInfo.Events |= AFD_EVENT_ACCEPT;
     }
 
     if (lNetworkEvents & FD_CONNECT) {
@@ -71,53 +75,154 @@
     }
 
     if (lNetworkEvents & FD_CLOSE) {
-		EventSelectInfo.Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
+	EventSelectInfo.Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
     }
 
     if (lNetworkEvents & FD_QOS) {
-		EventSelectInfo.Events |= AFD_EVENT_QOS;
+	EventSelectInfo.Events |= AFD_EVENT_QOS;
     }
 
     if (lNetworkEvents & FD_GROUP_QOS) {
-		EventSelectInfo.Events |= AFD_EVENT_GROUP_QOS;
+	EventSelectInfo.Events |= AFD_EVENT_GROUP_QOS;
     }
 
-	/* Send IOCTL */
-	Status = NtDeviceIoControlFile((HANDLE)Handle,
-									SockEvent,
-									NULL,
-									NULL,
-									&IOSB,
-									IOCTL_AFD_EVENT_SELECT,
-									&EventSelectInfo,
-									sizeof(EventSelectInfo),
-									NULL,
-									0);
-
-	/* Wait for return */
-	if (Status == STATUS_PENDING) {
-		WaitForSingleObject(SockEvent, 0);
-	}
+    /* Send IOCTL */
+    Status = NtDeviceIoControlFile((HANDLE)Handle,
+				   SockEvent,
+				   NULL,
+				   NULL,
+				   &IOSB,
+				   IOCTL_AFD_EVENT_SELECT,
+				   &EventSelectInfo,
+				   sizeof(EventSelectInfo),
+				   NULL,
+				   0);
+
+    AFD_DbgPrint(MID_TRACE,("AFD: %x\n", Status));
+
+    /* Wait for return */
+    if (Status == STATUS_PENDING) {
+	WaitForSingleObject(SockEvent, INFINITE);
+    }
+
+    AFD_DbgPrint(MID_TRACE,("Waited\n"));
+
+    NtClose( SockEvent );
 
-	NtClose( SockEvent );
+    AFD_DbgPrint(MID_TRACE,("Closed event\n"));
 
-	/* Set Socket Data*/
-	Socket->EventObject = hEventObject;
-	Socket->NetworkEvents = lNetworkEvents;
+    /* Set Socket Data*/
+    Socket->EventObject = hEventObject;
+    Socket->NetworkEvents = lNetworkEvents;
 
-	return 0;
+    AFD_DbgPrint(MID_TRACE,("Leaving\n"));
+
+    return 0;
 }
 
 
 INT
 WSPAPI
 WSPEnumNetworkEvents(
-  IN  SOCKET s, 
+  IN  SOCKET Handle, 
   IN  WSAEVENT hEventObject, 
   OUT LPWSANETWORKEVENTS lpNetworkEvents, 
   OUT LPINT lpErrno)
 {
-   return 0;
+    AFD_ENUM_NETWORK_EVENTS_INFO EnumReq;
+    IO_STATUS_BLOCK				IOSB;
+    PSOCKET_INFORMATION			Socket = NULL;
+    NTSTATUS					Status;
+    HANDLE                                  SockEvent;
+
+    AFD_DbgPrint(MID_TRACE,("Called (lpNetworkEvents %x)\n", lpNetworkEvents));
+
+    Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
+			    NULL, 1, FALSE );
+
+    if( !NT_SUCCESS(Status) ) {
+	AFD_DbgPrint(MID_TRACE,("Could not make an event %x\n", Status));
+	return -1;
+    }
+
+    /* Get the Socket Structure associate to this Socket*/
+    Socket = GetSocketStructure(Handle);
+
+    EnumReq.Event = hEventObject;
+
+    /* Send IOCTL */
+    Status = NtDeviceIoControlFile((HANDLE)Handle,
+				   SockEvent,
+				   NULL,
+				   NULL,
+				   &IOSB,
+				   IOCTL_AFD_ENUM_NETWORK_EVENTS,
+				   &EnumReq,
+				   sizeof(EnumReq),
+				   NULL,
+				   0);
+
+    AFD_DbgPrint(MID_TRACE,("AFD: %x\n", Status));
+
+    /* Wait for return */
+    if (Status == STATUS_PENDING) {
+	WaitForSingleObject(SockEvent, INFINITE);
+	Status = STATUS_SUCCESS;
+    }
+
+    AFD_DbgPrint(MID_TRACE,("Waited\n"));
+
+    NtClose( SockEvent );
+
+    AFD_DbgPrint(MID_TRACE,("Closed event\n"));
+    AFD_DbgPrint(MID_TRACE,("About to touch struct at %x (%d)\n", 
+			    lpNetworkEvents, sizeof(*lpNetworkEvents)));
+
+    lpNetworkEvents->lNetworkEvents = 0;
+
+    AFD_DbgPrint(MID_TRACE,("Zeroed struct\n"));
+
+    /* Set Events to wait for */
+    if (EnumReq.PollEvents & AFD_EVENT_RECEIVE) {
+	lpNetworkEvents->lNetworkEvents |= FD_READ;
+    }
+
+    if (EnumReq.PollEvents & AFD_EVENT_SEND) {
+	lpNetworkEvents->lNetworkEvents |= FD_WRITE;
+    }
+
+    if (EnumReq.PollEvents & AFD_EVENT_OOB_RECEIVE) {
+        lpNetworkEvents->lNetworkEvents |= FD_OOB;
+    }
+
+    if (EnumReq.PollEvents & AFD_EVENT_ACCEPT) {
+	lpNetworkEvents->lNetworkEvents |= FD_ACCEPT;
+    }
+
+    if (EnumReq.PollEvents & 
+	(AFD_EVENT_CONNECT | AFD_EVENT_CONNECT_FAIL)) {
+        lpNetworkEvents->lNetworkEvents |= FD_CONNECT;
+    }
+
+    if (EnumReq.PollEvents & 
+	(AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT)) {
+	lpNetworkEvents->lNetworkEvents |= FD_CLOSE;
+    }
+
+    if (EnumReq.PollEvents & AFD_EVENT_QOS) {
+	lpNetworkEvents->lNetworkEvents |= FD_QOS;
+    }
+
+    if (EnumReq.PollEvents & AFD_EVENT_GROUP_QOS) {
+	lpNetworkEvents->lNetworkEvents |= FD_GROUP_QOS;
+    }
+
+    if( NT_SUCCESS(Status) ) *lpErrno = 0;
+    else *lpErrno = WSAEINVAL;
+
+    AFD_DbgPrint(MID_TRACE,("Leaving\n"));
+
+    return 0;
 }
 
 /* EOF */

reactos/lib/msafd/misc
helpers.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- helpers.c	15 Nov 2004 18:24:56 -0000	1.11
+++ helpers.c	8 Dec 2004 21:57:13 -0000	1.11.2.1
@@ -142,8 +142,9 @@
 
             /* Return the Helper Pointers */
             *HelperDllData = HelperData;
-            HeapFree(GlobalHeap, 0, Transports);
-            HeapFree(GlobalHeap, 0, Mapping);
+	    /* We actually cache these ... the can't be freed yet */
+            /*HeapFree(GlobalHeap, 0, Transports);*/
+            /*HeapFree(GlobalHeap, 0, Mapping);*/
             return NO_ERROR;
         }
         

reactos/lib/msafd/misc
sndrcv.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- sndrcv.c	15 Nov 2004 18:24:56 -0000	1.11
+++ sndrcv.c	8 Dec 2004 21:57:13 -0000	1.11.2.1
@@ -9,21 +9,74 @@
  *   CSH 01/09-2000 Created
  *	 Alex 16/07/2004 - Complete Rewrite
  */
+
+#include <roscfg.h>
 #include <string.h>
 #include <msafd.h>
+#include <debug.h>
 
 INT
 WSPAPI
 WSPAsyncSelect(
-    IN  SOCKET s, 
+    IN  SOCKET Handle, 
     IN  HWND hWnd, 
     IN  UINT wMsg, 
     IN  LONG lEvent, 
     OUT LPINT lpErrno)
 {
-  UNIMPLEMENTED
+	PSOCKET_INFORMATION Socket = NULL;
+	PASYNC_DATA AsyncData;
+	NTSTATUS Status;
+	ULONG BlockMode;
 
-  return 0;
+	/* Get the Socket Structure associated to this Socket */
+	Socket = GetSocketStructure(Handle);
+
+	/* Allocate the Async Data Structure to pass on to the Thread later */
+	HeapAlloc(GetProcessHeap(), 0, sizeof(*AsyncData));
+
+	/* Change the Socket to Non Blocking */
+	BlockMode = 1;
+	SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL);
+	Socket->SharedData.NonBlocking = TRUE;
+
+	/* Deactive WSPEventSelect */
+	if (Socket->SharedData.AsyncEvents) {
+		WSPEventSelect(Handle, NULL, 0, NULL);
+	}
+
+	/* Create the Asynch Thread if Needed */  
+	SockCreateOrReferenceAsyncThread();
+	
+	/* Open a Handle to AFD's Async Helper */
+	SockGetAsyncSelectHelperAfdHandle();
+
+	/* Store Socket Data */
+	Socket->SharedData.hWnd = hWnd;
+	Socket->SharedData.wMsg = wMsg;
+	Socket->SharedData.AsyncEvents = lEvent;
+	Socket->SharedData.AsyncDisabledEvents = 0;
+	Socket->SharedData.SequenceNumber++;
+
+        /* Return if there are no more Events */
+	if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0) {
+		HeapFree(GetProcessHeap(), 0, AsyncData);
+		return 0;
+	}
+
+	/* Set up the Async Data */
+	AsyncData->ParentSocket = Socket;
+	AsyncData->SequenceNumber = Socket->SharedData.SequenceNumber;
+
+	/* Begin Async Select by using I/O Completion */
+	Status = NtSetIoCompletion(SockAsyncCompletionPort,
+				  (PVOID)&SockProcessQueuedAsyncSelect,
+				  AsyncData,
+				  0,
+				  0);
+
+	/* Return */
+	return 0;
 }
 
 
@@ -49,7 +102,8 @@
 	HANDLE						Event;
 	HANDLE                                  SockEvent;
 	PSOCKET_INFORMATION			Socket;
-	
+
+	AFD_DbgPrint(MID_TRACE,("Called\n"));
 
 	/* Get the Socket Structure associate to this Socket*/
 	Socket = GetSocketStructure(Handle);
@@ -133,45 +187,29 @@
 
 	/* Wait for completition of not overlapped */
 	if (Status == STATUS_PENDING && lpOverlapped == NULL) {
-		WaitForSingleObject(SockEvent, 0); // BUGBUG, shouldn wait infintely for receive...
-		Status = IOSB->Status;
+	    /* It's up to the protocol to time out recv.  We must wait
+	     * until the protocol decides it's had enough. */
+	    WaitForSingleObject(SockEvent, INFINITE);
+	    Status = IOSB->Status;
 	}
 
     NtClose( SockEvent );
 
-	/* Return the Flags */
-    	*ReceiveFlags = 0;
+    AFD_DbgPrint(MID_TRACE,("Status %x Information %d\n", 
+			    Status, IOSB->Information));
+
+    /* Return the Flags */
+    *ReceiveFlags = 0;
+
     switch (Status) {
-    case STATUS_CANT_WAIT:
-	return WSAEWOULDBLOCK;
-        
-    case STATUS_SUCCESS:
-	break;
-	
-    case STATUS_PENDING :
-	return WSA_IO_PENDING;
-	
-    case STATUS_BUFFER_OVERFLOW:
-	return WSAEMSGSIZE;
-	
-    case STATUS_RECEIVE_EXPEDITED:
-	*ReceiveFlags = MSG_OOB;
-	break;
-	
-    case STATUS_RECEIVE_PARTIAL_EXPEDITED :
-	*ReceiveFlags = MSG_PARTIAL | MSG_OOB;
-	break;
-	
-    case STATUS_RECEIVE_PARTIAL :
-	*ReceiveFlags = MSG_PARTIAL;
-	break;
+    case STATUS_RECEIVE_EXPEDITED: *ReceiveFlags = MSG_OOB; break;
+    case STATUS_RECEIVE_PARTIAL_EXPEDITED: 
+	*ReceiveFlags = MSG_PARTIAL | MSG_OOB; break;
+    case STATUS_RECEIVE_PARTIAL: *ReceiveFlags = MSG_PARTIAL; break;
     }
-    
-    /* Return Number of bytes Read */
-    *lpNumberOfBytesRead = (DWORD)IOSB->Information;
-    
-    /* Success */
-    return STATUS_SUCCESS;
+
+    return MsafdReturnWithErrno
+	( Status, lpErrno, IOSB->Information, lpNumberOfBytesRead );
 }
 
 int 
@@ -289,39 +327,18 @@
 
     NtClose( SockEvent );
 
-	/* Return the Flags */
-    	*ReceiveFlags = 0;
-    switch (Status) {
-    case STATUS_CANT_WAIT:
-	return WSAEWOULDBLOCK;
-
-    case STATUS_SUCCESS:
-	break;
-	
-    case STATUS_PENDING :
-	return WSA_IO_PENDING;
-	
-    case STATUS_BUFFER_OVERFLOW:
-	return WSAEMSGSIZE;
-	
-    case STATUS_RECEIVE_EXPEDITED:
-	*ReceiveFlags = MSG_OOB;
-	break;
-	
-    case STATUS_RECEIVE_PARTIAL_EXPEDITED :
-	*ReceiveFlags = MSG_PARTIAL | MSG_OOB;
-	break;
-	
-    case STATUS_RECEIVE_PARTIAL :
-	*ReceiveFlags = MSG_PARTIAL;
-	break;
-	}
+    /* Return the Flags */
+    *ReceiveFlags = 0;
 
-	/* Return Number of bytes Read */
-    *lpNumberOfBytesRead = (DWORD)IOSB->Information;
+    switch (Status) {
+    case STATUS_RECEIVE_EXPEDITED: *ReceiveFlags = MSG_OOB; break;
+    case STATUS_RECEIVE_PARTIAL_EXPEDITED: 
+	*ReceiveFlags = MSG_PARTIAL | MSG_OOB; break;
+    case STATUS_RECEIVE_PARTIAL: *ReceiveFlags = MSG_PARTIAL; break;
+    }
 
-	/* Success */
-	return STATUS_SUCCESS;
+    return MsafdReturnWithErrno
+	( Status, lpErrno, IOSB->Information, lpNumberOfBytesRead );
 }
 
 
@@ -431,13 +448,10 @@
 	    return WSA_IO_PENDING;
 	}
 
-	/* Return Number of bytes Sent */
-	*lpNumberOfBytesSent = (DWORD)IOSB->Information;
-
 	AFD_DbgPrint(MID_TRACE,("Leaving (Success, %d)\n", IOSB->Information));
 
-	/* Success */
-	return STATUS_SUCCESS;
+    return MsafdReturnWithErrno
+	( Status, lpErrno, IOSB->Information, lpNumberOfBytesSent );
 }
 
 int 
@@ -559,11 +573,8 @@
         return WSA_IO_PENDING;
 	}
 
-	/* Return Number of bytes Sent */
-    *lpNumberOfBytesSent = (DWORD)IOSB->Information;
-
-	/* Success */
-	return STATUS_SUCCESS;
+    return MsafdReturnWithErrno
+	( Status, lpErrno, IOSB->Information, lpNumberOfBytesSent );
 }
 INT
 WSPAPI

reactos/lib/msvcrt20
Makefile 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- Makefile	3 Oct 2004 14:24:43 -0000	1.3
+++ Makefile	8 Dec 2004 21:57:13 -0000	1.3.6.1
@@ -14,7 +14,7 @@
 
 TARGET_LFLAGS = -nostartfiles --enable-stdcall-fixup
 
-TARGET_SDKLIBS = libwine.a string.a kernel32.a ntdll.a
+TARGET_SDKLIBS = wine.a string.a kernel32.a ntdll.a
 
 TARGET_GCCLIBS = gcc
 

reactos/lib/msvcrt
Makefile 1.48 -> 1.48.6.1
diff -u -r1.48 -r1.48.6.1
--- Makefile	3 Oct 2004 14:24:43 -0000	1.48
+++ Makefile	8 Dec 2004 21:57:13 -0000	1.48.6.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.48 2004/10/03 14:24:43 weiden Exp $
+# $Id: Makefile,v 1.48.6.1 2004/12/08 21:57:13 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -17,7 +17,7 @@
 
 TARGET_LFLAGS = -nostartfiles --enable-stdcall-fixup
 
-TARGET_SDKLIBS = libwine.a string.a kernel32.a ntdll.a
+TARGET_SDKLIBS = wine.a string.a kernel32.a ntdll.a
 
 TARGET_GCCLIBS = gcc
 

reactos/lib/msvcrt/setjmp/i386
setjmp.s 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- setjmp.s	6 Apr 2003 12:40:55 -0000	1.1
+++ setjmp.s	8 Dec 2004 21:57:13 -0000	1.1.34.1
@@ -1,14 +1,14 @@
-/* $Id: setjmp.s,v 1.1 2003/04/06 12:40:55 gvg Exp $
- *
- * COPYRIGHT:         See COPYING in the top level directory
+/* $Id: setjmp.s,v 1.1.34.1 2004/12/08 21:57:13 hyperion Exp $
+ *
+ * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS system libraries
- * PURPOSE:           Implementation of _setjmp/longjmp
- * FILE:              lib/msvcrt/i386/setjmp.s
- * PROGRAMMER:        Ge van Geldorp (ge@gse.nl)
+ * PURPOSE:           Implementation of _setjmp/longjmp
+ * FILE:              lib/msvcrt/i386/setjmp.s
+ * PROGRAMMER:        Ge van Geldorp (ge@gse.nl)
  * NOTES:             Implementation is not complete, see Wine source for a more
  *                    complete implementation
  */
-
+
 #define JB_BP  0
 #define JB_BX  1
 #define JB_DI  2
@@ -19,22 +19,22 @@
 #define PCOFF  0
 
 #define JMPBUF 4
-
-/*
- * int
- * _setjmp(jmp_buf env);
- *
- * Parameters:
- *   [ESP+04h] - jmp_buf env
- * Registers:
- *   None
- * Returns:
- *   0
- * Notes:
+
+/*
+ * int
+ * _setjmp(jmp_buf env);
+ *
+ * Parameters:
+ *   [ESP+04h] - jmp_buf env
+ * Registers:
+ *   None
+ * Returns:
+ *   0
+ * Notes:
  *   Sets up the jmp_buf
- */
-.globl __setjmp
-__setjmp:
+ */
+.globl __setjmp
+__setjmp:
     xorl %eax, %eax
     movl JMPBUF(%esp), %edx
 
@@ -48,22 +48,22 @@
     movl PCOFF(%esp), %ecx     /* Save PC we are returning to now.  */
     movl %ecx, (JB_IP*4)(%edx)
     ret
-
-/*
- * int
- * _setjmp3(jmp_buf env, int nb_args, ...);
- *
- * Parameters:
- *   [ESP+04h] - jmp_buf env
- * Registers:
- *   None
- * Returns:
- *   0
- * Notes:
+
+/*
+ * int
+ * _setjmp3(jmp_buf env, int nb_args, ...);
+ *
+ * Parameters:
+ *   [ESP+04h] - jmp_buf env
+ * Registers:
+ *   None
+ * Returns:
+ *   0
+ * Notes:
  *   Sets up the jmp_buf
- */
-.globl __setjmp3
-__setjmp3:
+ */
+.globl __setjmp3
+__setjmp3:
     xorl %eax, %eax
     movl JMPBUF(%esp), %edx
 
@@ -79,23 +79,23 @@
     ret
 
 #define VAL 8
-
-/*
- * void
- * longjmp(jmp_buf env, int value);
- *
- * Parameters:
+
+/*
+ * void
+ * longjmp(jmp_buf env, int value);
+ *
+ * Parameters:
  *   [ESP+04h] - jmp_buf setup by _setjmp
- *   [ESP+08h] - int     value to return
- * Registers:
- *   None
- * Returns:
- *   Doesn't return
- * Notes:
+ *   [ESP+08h] - int     value to return
+ * Registers:
+ *   None
+ * Returns:
+ *   Doesn't return
+ * Notes:
  *   Non-local goto
- */
-.globl _longjmp
-_longjmp:
+ */
+.globl _longjmp
+_longjmp:
     movl JMPBUF(%esp), %ecx   /* User's jmp_buf in %ecx.  */
 
     movl VAL(%esp), %eax      /* Second argument is return value.  */

reactos/lib/msvcrt/time
ctime.c 1.12 -> 1.12.8.1
diff -u -r1.12 -r1.12.8.1
--- ctime.c	15 Aug 2004 18:16:38 -0000	1.12
+++ ctime.c	8 Dec 2004 21:57:13 -0000	1.12.8.1
@@ -89,7 +89,9 @@
 void _set_timezone_export(int);
 
 
-static char WILDABBR[] = "   ";
+/* buffers must hold 64 characters! */
+static char TZ_NAME[64] = "PST";
+static char TZ_DST_NAME[64] = "PDT";
 
 #ifndef TRUE
 #define TRUE        1
@@ -183,8 +185,8 @@
 static int gmt_is_set;
 
 char * _tzname[2] = {
-  WILDABBR,
-  WILDABBR
+  TZ_NAME,
+  TZ_DST_NAME,
 };
 
 static long
@@ -205,8 +207,8 @@
   const struct state * CPP_CONST sp = lclptr;
   int i;
 
-  _tzname[0] = WILDABBR;
-  _tzname[1] = WILDABBR;
+  _tzname[0] = TZ_NAME;
+  _tzname[1] = TZ_DST_NAME;
 #ifdef ALL_STATE
   if (sp == NULL)
   {
@@ -1058,7 +1060,7 @@
    ** but this is no time for a treasure hunt.
    */
   if (offset != 0)
-    tmp->tm_zone = WILDABBR;
+    tmp->tm_zone = TZ_NAME;
   else
   {
 #ifdef ALL_STATE

reactos/lib/msvideo
Makefile.ros-template 1.1 -> 1.1.8.1
diff -u -r1.1 -r1.1.8.1
--- Makefile.ros-template	10 Jul 2004 21:19:46 -0000	1.1
+++ Makefile.ros-template	8 Dec 2004 21:57:13 -0000	1.1.8.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.1 2004/07/10 21:19:46 sedwards Exp $
+# $Id: Makefile.ros-template,v 1.1.8.1 2004/12/08 21:57:13 hyperion Exp $
 
 TARGET_NAME = msvfw32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_WINMM)
 

reactos/lib/netapi32
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:44 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:14 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:44 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:57:14 hyperion Exp $
 
 TARGET_NAME = netapi32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_NETAPI32)
 

reactos/lib/ntdll/def
ntdll.def 1.134 -> 1.134.2.1
diff -u -r1.134 -r1.134.2.1
--- ntdll.def	12 Nov 2004 12:06:54 -0000	1.134
+++ ntdll.def	8 Dec 2004 21:57:14 -0000	1.134.2.1
@@ -1,4 +1,4 @@
-; $Id: ntdll.def,v 1.134 2004/11/12 12:06:54 ekohl Exp $
+; $Id: ntdll.def,v 1.134.2.1 2004/12/08 21:57:14 hyperion Exp $
 ;
 ; ReactOS Operating System
 ;
@@ -487,6 +487,7 @@
 RtlInitNlsTables@16
 RtlInitString@8
 RtlInitUnicodeString@8
+RtlInitUnicodeStringEx@8
 ;RtlInitializeAtomPackage
 RtlInitializeBitMap@12
 RtlInitializeContext@20

reactos/lib/ntdll/ldr
utils.c 1.101 -> 1.101.2.1
diff -u -r1.101 -r1.101.2.1
--- utils.c	19 Nov 2004 01:30:35 -0000	1.101
+++ utils.c	8 Dec 2004 21:57:14 -0000	1.101.2.1
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.101 2004/11/19 01:30:35 weiden Exp $
+/* $Id: utils.c,v 1.101.2.1 2004/12/08 21:57:14 hyperion Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -720,6 +720,9 @@
   NTSTATUS              Status;
   PLDR_MODULE           Module;
 
+  /* HACKHACK */
+  DbgPrint("LdrLoadDll(%S, %x, %wZ, %p)\n", SearchPath, LoadFlags, Name, BaseAddress);
+
   TRACE_LDR("LdrLoadDll, loading %wZ%s%S\n",
             Name,
             SearchPath ? " from " : "",
@@ -772,6 +775,9 @@
   PLIST_ENTRY Entry;
   PLDR_MODULE ModulePtr;
 
+  /* HACKHACK */
+  DbgPrint("LdrFindEntryForAddress(%p, %p)\n", Address, Module);
+
   DPRINT("LdrFindEntryForAddress(Address %p)\n", Address);
 
   if (NtCurrentPeb()->Ldr == NULL)
@@ -837,6 +843,9 @@
   UNICODE_STRING AdjustedName;
   unsigned i;
 
+  /* HACKHACK */
+  DbgPrint("LdrFindEntryForName(%wZ, %p, %d)\n", Name, Module, Ref);
+
   DPRINT("LdrFindEntryForName(Name %wZ)\n", Name);
 
   if (NtCurrentPeb()->Ldr == NULL)
@@ -2211,6 +2220,10 @@
    PLDR_MODULE Module;
    NTSTATUS Status;
 
+   /* HACKHACK */
+  DbgPrint("LdrUnloadDll(%p)\n", BaseAddress);
+
+
    if (BaseAddress == NULL)
      return STATUS_SUCCESS;
 
@@ -2234,6 +2247,9 @@
     PLDR_MODULE Module;
     NTSTATUS Status;
 
+   /* HACKHACK */
+   DbgPrint("LdrDisableThreadCalloutsForDll(%p)\n", BaseAddress);
+
     DPRINT("LdrDisableThreadCalloutsForDll (BaseAddress %x)\n", BaseAddress);
 
     Status = STATUS_DLL_NOT_FOUND;
@@ -2273,6 +2289,9 @@
     PLDR_MODULE Module;
     NTSTATUS Status;
 
+  /* HACKHACK */
+  DbgPrint("LdrGetDllHandle(%S, %x, %wZ, %p)\n", Path, Unknown2, DllName, BaseAddress);
+
     TRACE_LDR("LdrGetDllHandle, searching for %wZ from %S\n", DllName, Path ? Path : L"");
 
     /* NULL is the current executable */
@@ -2305,6 +2324,9 @@
                         IN ULONG Ordinal,
                         OUT PVOID *ProcedureAddress)
 {
+  /* HACKHACK */
+  DbgPrint("LdrGetProcedureAddress(%p, %Z, %d, %p)\n", BaseAddress, Name, Ordinal, ProcedureAddress);
+
    if (Name && Name->Length)
      {
        TRACE_LDR("LdrGetProcedureAddress by NAME - %Z\n", Name);
@@ -2505,6 +2527,8 @@
 NTSTATUS STDCALL
 LdrShutdownProcess (VOID)
 {
+  /* HACKHACK */
+  DbgPrint("LdrShutdownProcess()\n");
   LdrpDetachProcess(TRUE);
   return STATUS_SUCCESS;
 }
@@ -2521,6 +2545,9 @@
   PLDR_MODULE Module;
   NTSTATUS Status;
 
+  /* HACKHACK */
+  DbgPrint("LdrpAttachThread()\n");
+
   DPRINT("LdrpAttachThread() called for %wZ\n",
          &ExeModule->BaseDllName);
 
@@ -2570,6 +2597,9 @@
    PLIST_ENTRY Entry;
    PLDR_MODULE Module;
 
+  /* HACKHACK */
+  DbgPrint("LdrShutdownThread()\n");
+
    DPRINT("LdrShutdownThread() called for %wZ\n",
           &ExeModule->BaseDllName);
 
@@ -2805,6 +2835,9 @@
   BOOLEAN Result;
   NTSTATUS Status;
 
+  /* HACKHACK */
+  DbgPrint("LdrVerifyImageMatchesChecksum(%p, %x, %x, %x)\n", FileHandle, Unknown1, Unknown2, Unknown3);
+
   DPRINT ("LdrVerifyImageMatchesChecksum() called\n");
 
   Status = NtCreateSection (&SectionHandle,
@@ -2904,6 +2937,9 @@
   PWCHAR Ptr;
   NTSTATUS Status;
 
+  /* HACKHACK */
+  DbgPrint("LdrQueryImageFileExecutionOptions(%wZ, %S, %x, %p, %d, %p)\n", SubKey, ValueName, Type, Buffer, BufferSize, ReturnedLength);
+
   wcscpy (NameBuffer,
           L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\");
   Ptr = wcsrchr (SubKey->Buffer, L'\\');

reactos/lib/ntdll/ldr
tls.c removed after 1.1
diff -N tls.c
--- tls.c	25 Dec 2003 18:30:09 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,127 +0,0 @@
-#define RTL_FOREACH_LIST(PLIST_HEAD__, TYPE__, FIELD__) \
-{ \
- PLIST_ENTRY _RTL_FOREACH_LIST_END = (PLIST_HEAD__); \
- PLIST_ENTRY _RTL_FOREACH_LIST_CUR = _RTL_FOREACH_LIST_END->Flink; \
- TYPE__ * _RTL_ITEM = \
-  CONTAINING_RECORD(_RTL_FOREACH_LIST_CUR, TYPE__, FIELD__); \
- \
- for \
- ( \
-  ; \
-  _RTL_FOREACH_LIST_CUR != _RTL_FOREACH_LIST_END; \
-  _RTL_ITEM = CONTAINING_RECORD(_RTL_FOREACH_LIST_CUR, TYPE__, FIELD__) \
- )
-
-#define RTL_FOREACH_END }
-
-NTSTATUS STDCALL LdrpRosTlsAction
-(
- IN ULONG Reason
-)
-{
- typedef struct _LDRP_TLS_ENTRY
- {
-  LIST_ENTRY TlsList;
-  PIMAGE_TLS_DIRECTORY TlsDir;
-  PLDR_MODULE LdrModule;
- }
- LDRP_TLS_ENTRY, * PLDRP_TLS_ENTRY;
-
- static LIST_ENTRY s_leTlsList;
- static SIZE_T s_nTlsImagesCount;
-
- switch(Reason)
- {
-  case DLL_PROCESS_ATTACH:
-  {
-   PPEB_LDR_DATA pLdr = NtCurrentPeb()->Ldr;
-
-   InitializeListHead(&s_leTlsList);
-   s_nTlsImagesCount = 0;
-
-   RTL_FOREACH_LIST
-   (
-    &pLdr->InLoadOrderModuleList,
-    LDR_MODULE,
-    InLoadOrderModuleList
-   )
-   {
-    SIZE_T nSize;
-    PIMAGE_TLS_DIRECTORY pitdTlsDir = RtlImageDirectoryEntryToData
-    (
-     _RTL_ITEM->BaseAddress,
-     TRUE,
-     IMAGE_DIRECTORY_ENTRY_TLS,
-     &nSize
-    );
-
-    if(pitdTlsDir == NULL || nSize < sizeof(IMAGE_TLS_DIRECTORY)) continue;
-
-    PLDRP_TLS_ENTRY plteCur =
-     RtlAllocateHeap(pPeb->ProcessHeap, 0, sizeof(LDRP_TLS_ENTRY));
-
-    if(plteCur == NULL) return STATUS_NO_MEMORY;
-
-    InsertTailList(&s_leTlsList, &plteCur->TlsList);
-
-    _RTL_ITEM->TlsIndex = s_nTlsImagesCount;
-    ++ s_nTlsImagesCount; /* TODO: check for out-of-bounds index */
-
-    plteCur->LdrModule = _RTL_ITEM;
-    plteCur->TlsDir = pitdTlsDir;
-
-    *pitdTlsDir->AddressOfIndex = _RTL_ITEM->TlsIndex;
-   }
-   RTL_FOREACH_END;
-
-   RtlSetBits(pPeb->TlsBitmap, 0, s_nTlsImagesCount);
-
-   /* fall through */
-  }
-
-  case DLL_THREAD_ATTACH:
-  {
-   RTL_FOREACH_LIST(&s_leTlsList, LDRP_TLS_ENTRY, TlsList)
-   {
-    PBYTE pcTlsData;
-    PIMAGE_TLS_DIRECTORY pitdTlsDir = _RTL_ITEM->TlsDir;
-    SIZE_T nInitDataSize =
-     pitdTlsDir->EndAddressOfRawData - pitdTlsDir->StartAddressOfRawData;
-
-    PIMAGE_TLS_CALLBACK * pitcCallbacks =
-     (PIMAGE_TLS_CALLBACK *)_RTL_ITEM->TlsDir->AddressOfCallbacks;
-
-    pcTlsData = RtlAllocateHeap
-    (
-     pPeb->ProcessHeap,
-     0,
-     nInitDataSize + pitdTlsDir->SizeOfZeroFill
-    );
-
-    if(pcTlsData == NULL) return STATUS_NO_MEMORY;
-
-    pTeb->TlsSlots[_RTL_ITEM->LdrModule->TlsIndex] = pcTlsData;
-
-    RtlMoveMemory(pcTlsData, pitdTlsDir->StartAddressOfRawData, nInitDataSize);
-    RtlZeroMemory(pcTlsData + nInitDataSize, pitdTlsDir->SizeOfZeroFill);
-
-    if(pitcCallbacks)
-     for(; *pitcCallbacks; ++ pitcCallbacks)
-      (*pitcCallbacks)(_RTL_ITEM->LdrModule->BaseAddress, Reason, NULL);
-   }
-   RTL_FOREACH_END;
-
-   return STATUS_SUCCESS;
-  }
-
-  case DLL_THREAD_DETACH:
-  {
-  }
-
-  case DLL_PROCESS_DETACH:
-  {
-  }
-
-  default: return STATUS_SUCCESS;
- }
-}

reactos/lib/ntdll/rtl
path.c 1.29 -> 1.29.8.1
diff -u -r1.29 -r1.29.8.1
--- path.c	25 Aug 2004 15:04:19 -0000	1.29
+++ path.c	8 Dec 2004 21:57:14 -0000	1.29.8.1
@@ -1,4 +1,4 @@
-/* $Id: path.c,v 1.29 2004/08/25 15:04:19 navaraf Exp $
+/* $Id: path.c,v 1.29.8.1 2004/12/08 21:57:14 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -173,44 +173,38 @@
 
 /*
  * @implemented
+ *
  */
 ULONG STDCALL
-RtlDetermineDosPathNameType_U(PWSTR Path)
+RtlDetermineDosPathNameType_U(PCWSTR Path)
 {
    DPRINT("RtlDetermineDosPathNameType_U %S\n", Path);
 
    if (Path == NULL)
-     {
-	return 0;
-     }
+   {
+      return INVALID_PATH;
+   }
 
    if (IS_PATH_SEPARATOR(Path[0]))
-     {
-	if (!IS_PATH_SEPARATOR(Path[1]))
-	  {
-	     return 4;			/* \xxx   */
-	  }
+   {
+      if (!IS_PATH_SEPARATOR(Path[1])) return ABSOLUTE_PATH;         /* \xxx   */
+      if (Path[2] != L'.') return UNC_PATH;                          /* \\xxx   */
+      if (IS_PATH_SEPARATOR(Path[3])) return DEVICE_PATH;            /* \\.\xxx */
+      if (Path[3]) return UNC_PATH;                                  /* \\.xxxx */
 
-	if (Path[2] != L'.')
-	  return 1;			/* \\xxx   */
-
-	if (IS_PATH_SEPARATOR(Path[3]))
-	  return 6;			/* \\.\xxx */
-
-	if (Path[3])
-	  return 1;			/* \\.xxxx */
-
-	return 7;				/* \\.     */
-     }
+      return UNC_DOT_PATH;                                           /* \\.     */
+   }
    else
-     {
-	if (Path[1] != L':')
-		return 5;			/* xxx     */
-
-	if (IS_PATH_SEPARATOR(Path[2]))
-		return 2;			/* x:\xxx  */
+   {
+      /* FIXME: the Wine version of this line reads:
+       * if (!Path[1] || Path[1] != L':')    return RELATIVE_PATH
+       * Should we do this too?
+       * -Gunnar
+       */ 
+      if (Path[1] != L':') return RELATIVE_PATH;                     /* xxx     */
+      if (IS_PATH_SEPARATOR(Path[2])) return ABSOLUTE_DRIVE_PATH;    /* x:\xxx  */
 
-	return 3;				/* x:xxx   */
+      return RELATIVE_DRIVE_PATH;                                    /* x:xxx   */
    }
 }
 

reactos/lib/odbc32
Makefile.ros-template 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile.ros-template	29 May 2004 21:24:45 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:14 -0000	1.2.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:45 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.2.16.1 2004/12/08 21:57:14 hyperion Exp $
 
 TARGET_NAME = odbc32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ -D__WINESRC__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_ODBC32)
 

reactos/lib/ole32
Makefile.ros-template 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile.ros-template	29 May 2004 21:24:45 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:15 -0000	1.2.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:45 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.2.16.1 2004/12/08 21:57:15 hyperion Exp $
 
 TARGET_NAME = ole32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_OLE32)
 

reactos/lib/ole32
compobj.c 1.16 -> 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- compobj.c	20 Oct 2004 09:27:43 -0000	1.16
+++ compobj.c	8 Dec 2004 21:57:15 -0000	1.16.2.1
@@ -160,7 +160,8 @@
      * following class is created. The *caller* of CoMarshalInterface (ie the
      * application) is responsible for pumping the message loop in that thread.
      * The WM_USER messages which point to the RPCs are then dispatched to
-     * COM_AptWndProc by the user's code.
+     * COM_AptWndProc by the user's code from the apartment in which the interface
+     * was unmarshalled.
      */
     memset(&wclass, 0, sizeof(wclass));
     wclass.lpfnWndProc = &COM_AptWndProc;
@@ -192,6 +193,8 @@
        This method of generating an OXID is therefore wrong as it doesn't work across
        a network, but for local RPC only it's OK. We can distinguish between MTAs and
        STAs because STAs use the thread ID as well, and no thread can have an ID of zero.
+
+       The algorithm Microsoft use is currently unknown.
      */
     MTA.oxid = ((OXID)GetCurrentProcessId() << 32);
     InitializeCriticalSection(&MTA.cs);
@@ -266,7 +269,7 @@
 }
 
 /* The given OXID must be local to this process: you cannot use apartment
-   windows to send RPCs to other processes */
+   windows to send RPCs to other processes. This all needs to move to rpcrt4 */
 HWND COM_GetApartmentWin(OXID oxid)
 {
     APARTMENT *apt;
@@ -377,9 +380,11 @@
 /******************************************************************************
  *		CoInitialize	[OLE32.@]
  *
- * Initializes the COM libraries.
+ * Initializes the COM libraries by calling CoInitializeEx with
+ * COINIT_APARTMENTTHREADED, ie it enters a STA thread.
  *
- * See CoInitializeEx
+ * SEE ALSO
+ *   CoInitializeEx
  */
 HRESULT WINAPI CoInitialize(
 	LPVOID lpReserved	/* [in] pointer to win32 malloc interface
@@ -395,14 +400,22 @@
 /******************************************************************************
  *		CoInitializeEx	[OLE32.@]
  *
- * Initializes the COM libraries. The behavior used to set the win32 IMalloc
- * used for memory management is obsolete.
+ * Initializes the COM libraries. The behavior used to set the win32
+ * IMalloc used for memory management is obsolete. If
+ * COINIT_APARTMENTTHREADED is specified this thread enters a new STA
+ * (single threaded apartment), otherwise COINIT_MULTITHREADED should
+ * be specified which indicates that the thread will enter the MTA.
+ *
+ * Currently STA threading is only partly implemented.
  *
  * RETURNS
  *  S_OK               if successful,
  *  S_FALSE            if this function was called already.
  *  RPC_E_CHANGED_MODE if a previous call to CoInitializeEx specified another
  *                     threading model.
+ *
+ * SEE ALSO
+ *   CoUninitialize
  */
 HRESULT WINAPI CoInitializeEx(
 	LPVOID lpReserved,	/* [in] pointer to win32 malloc interface
@@ -427,7 +440,7 @@
     {
       /* Changing the threading model after it's been set is illegal. If this warning is triggered by Wine
          code then we are probably using the wrong threading model to implement that API. */
-      WARN("Attempt to change threading model of this apartment from 0x%lx to 0x%lx\n", apt->model, dwCoInit);
+      ERR("Attempt to change threading model of this apartment from 0x%lx to 0x%lx\n", apt->model, dwCoInit);
       return RPC_E_CHANGED_MODE;
     }
     hr = S_FALSE;
@@ -483,9 +496,18 @@
 /***********************************************************************
  *           CoUninitialize   [OLE32.@]
  *
- * This method will release the COM libraries.
+ * This method will decrement the refcount on the COM libraries,
+ * potentially unloading them. The current thread leaves the apartment
+ * it's currently in. If not in an apartment, the routine does
+ * nothing.
+ *
+ * If COM is to be shut down, any outstanding proxies are
+ * disconnected, all registered class objects are unregistered and the
+ * message queue for the thread is flushed (if native does
+ * this or not is unknown).
  *
- * See the windows documentation for more details.
+ * SEE ALSO
+ *   CoInitializeEx
  */
 void WINAPI CoUninitialize(void)
 {
@@ -516,7 +538,7 @@
 
     /* disconnect proxies to release the corresponding stubs.
      * It is confirmed in "Essential COM" in the sub-chapter on
-     * "Lifecycle Management and Marshaling" that the native version also
+     * "Lifecycle Management and Marshalling" that the native version also
      * does some kind of proxy cleanup in this function.
      * FIXME: does it just disconnect or completely destroy the proxies?
      * FIXME: should this be in the apartment destructor? */
@@ -562,6 +584,11 @@
 /******************************************************************************
  *		CoCreateGuid[OLE32.@]
  *
+ * Simply forwards to UuidCreate in RPCRT4.
+ *
+ * SEE ALSO
+ *   UuidCreate
+ *
  */
 HRESULT WINAPI CoCreateGuid(
 	GUID *pguid /* [out] points to the GUID to initialize */
@@ -572,20 +599,23 @@
 /******************************************************************************
  *		CLSIDFromString	[OLE32.@]
  *		IIDFromString   [OLE32.@]
+ *
  * Converts a unique identifier from its string representation into
  * the GUID struct.
  *
- * UNDOCUMENTED
- *      If idstr is not a valid CLSID string then it gets treated as a ProgID
+ * In Windows, if idstr is not a valid CLSID string then it gets
+ * treated as a ProgID. Wine currently doesn't do this. If idstr is
+ * NULL it's treated as an all-zero GUID.
  *
  * RETURNS
- *	the converted GUID
+ *   S_OK on success
+ *   CO_E_CLASSSTRING if idstr is not a valid CLSID
  */
 HRESULT WINAPI __CLSIDFromStringA(
 	LPCSTR idstr,	        /* [in] string representation of guid */
 	CLSID *id)		/* [out] GUID converted from string */
 {
-  const BYTE *s = (BYTE *) idstr;
+  const BYTE *s = (const BYTE *) idstr;
   int	i;
   BYTE table[256];
 
@@ -661,15 +691,7 @@
     return ret;
 }
 
-/******************************************************************************
- *		WINE_StringFromCLSID	[Internal]
- * Converts a GUID into the respective string representation.
- *
- * NOTES
- *
- * RETURNS
- *	the string representation and HRESULT
- */
+/* Converts a GUID into the respective string representation. */
 HRESULT WINE_StringFromCLSID(
 	const CLSID *id,	/* [in] GUID to be converted */
 	LPSTR idstr		/* [out] pointer to buffer to contain converted guid */
@@ -707,20 +729,23 @@
 /******************************************************************************
  *		StringFromCLSID	[OLE32.@]
  *		StringFromIID   [OLE32.@]
+ *
  * Converts a GUID into the respective string representation.
  * The target string is allocated using the OLE IMalloc.
+ *
  * RETURNS
- *	the string representation and HRESULT
+ *   S_OK
+ *   E_FAIL
  */
 HRESULT WINAPI StringFromCLSID(
-        REFCLSID id,            /* [in] the GUID to be converted */
+        REFCLSID id,    /* [in] the GUID to be converted */
 	LPOLESTR *idstr	/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
 ) {
 	char            buf[80];
 	HRESULT       ret;
 	LPMALLOC	mllc;
 
-	if ((ret=CoGetMalloc(0,&mllc)))
+	if ((ret = CoGetMalloc(0,&mllc)))
 		return ret;
 
 	ret=WINE_StringFromCLSID(id,buf);
@@ -736,15 +761,16 @@
  *		StringFromGUID2	[COMPOBJ.76]
  *		StringFromGUID2	[OLE32.@]
  *
- * Converts a global unique identifier into a string of an API-
- * specified fixed format. (The usual {.....} stuff.)
+ * Modified version of StringFromCLSID that allows you to specify max
+ * buffer size.
  *
  * RETURNS
- *	The (UNICODE) string representation of the GUID in 'str'
  *	The length of the resulting string, 0 if there was any problem.
  */
-INT WINAPI
-StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
+INT WINAPI StringFromGUID2(
+    REFGUID id,    /* [in]  GUID to convert to string */
+    LPOLESTR str,  /* [out] Unicode buffer to hold result */
+    INT cmax)
 {
   char		xguid[80];
 
@@ -754,12 +780,16 @@
 }
 
 /******************************************************************************
- * ProgIDFromCLSID [OLE32.@]
- * Converts a class id into the respective Program ID. (By using a registry lookup)
- * RETURNS S_OK on success
- * riid associated with the progid
+ *               ProgIDFromCLSID [OLE32.@]
+ *
+ * Converts a class id into the respective Program ID. (By using a
+ * registry lookup)
+ *
+ * RETURNS
+ *   S_OK
+ *   E_OUTOFMEMORY
+ *   REGDB_E_CLASSNOTREG if the given clsid has no associated ProgID
  */
-
 HRESULT WINAPI ProgIDFromCLSID(
   REFCLSID clsid, /* [in] class id as found in registry */
   LPOLESTR *lplpszProgID/* [out] associated Prog ID */
@@ -805,12 +835,6 @@
   return ret;
 }
 
-/******************************************************************************
- *		CLSIDFromProgID	[COMPOBJ.61]
- * Converts a program id into the respective GUID. (By using a registry lookup)
- * RETURNS
- *	riid associated with the progid
- */
 HRESULT WINAPI CLSIDFromProgID16(
 	LPCOLESTR16 progid,	/* [in] program id as found in registry */
 	LPCLSID riid		/* [out] associated CLSID */
@@ -837,13 +861,17 @@
 }
 
 /******************************************************************************
- *		CLSIDFromProgID	[OLE32.@]
- * Converts a program id into the respective GUID. (By using a registry lookup)
+ *		CLSIDFromProgID	[COMPOBJ.61]
+ *
+ * Converts a program id into the respective GUID. (By using a
+ * registry lookup)
+ *
  * RETURNS
- *	riid associated with the progid
+ *	S_OK
+ *      CO_E_CLASSSTRING if the given ProgID cannot be found
  */
 HRESULT WINAPI CLSIDFromProgID(
-	LPCOLESTR progid,	/* [in] program id as found in registry */
+	LPCOLESTR progid,	/* [in] Unicode program id as found in registry */
 	LPCLSID riid )		/* [out] associated CLSID */
 {
     static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
@@ -875,22 +903,30 @@
 /*****************************************************************************
  *             CoGetPSClsid [OLE32.@]
  *
- * This function returns the CLSID of the proxy/stub factory that implements IPSFactoryBuffer
- * for the specified interface.
+ * This function returns the CLSID of the proxy/stub factory that
+ * implements IPSFactoryBuffer for the specified interface.
  *
- * The standard marshaller activates the object with the CLSID returned and uses the
- * CreateProxy and CreateStub methods on its IPSFactoryBuffer interface to construct
- * the proxies and stubs for a given object.
+ * The standard marshaller activates the object with the CLSID
+ * returned and uses the CreateProxy and CreateStub methods on its
+ * IPSFactoryBuffer interface to construct the proxies and stubs for a
+ * given object.
  *
  * CoGetPSClsid determines this CLSID by searching the
- * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry
- * and any interface id registered by CoRegisterPSClsid within the current process.
+ * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32
+ * in the registry and any interface id registered by
+ * CoRegisterPSClsid within the current process.
+ *
+ * FIXME: We only search the registry, not ids registered with
+ * CoRegisterPSClsid.
  *
- * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid.
+ * RETURNS
+ *   S_OK
+ *   E_OUTOFMEMORY
+ *   E_INVALIDARG if no PSFactoryBuffer is associated with the IID, or it could not be parsed
  */
 HRESULT WINAPI CoGetPSClsid(
           REFIID riid,     /* [in]  Interface whose proxy/stub CLSID is to be returned */
-          CLSID *pclsid )    /* [out] Where to store returned proxy/stub CLSID */
+          CLSID *pclsid )  /* [out] Where to store returned proxy/stub CLSID */
 {
     char *buf, buf2[40];
     DWORD buf2len;
@@ -1139,29 +1175,40 @@
 
 /******************************************************************************
  *		CoRegisterClassObject	[OLE32.@]
+ * 
+ * This method will register the class object for a given class
+ * ID. Servers housed in EXE files use this method instead of
+ * exporting DllGetClassObject to allow other code to connect to their
+ * objects.
+ *
+ * When a class object (an object which implements IClassFactory) is
+ * registered in this way, a new thread is started which listens for
+ * connections on a named pipe specific to the registered CLSID. When
+ * something else connects to it, it writes out the marshalled
+ * IClassFactory interface to the pipe. The code on the other end uses
+ * this buffer to unmarshal the class factory, and can then call
+ * methods on it.
  *
- * This method will register the class object for a given class ID. Servers housed
- * in EXE files use this method instead of exporting DllGetClassObject to allow other
- * code to connect to their objects.
- *
- * When a class object (an object which implements IClassFactory) is registered in
- * this way, a new thread is started which listens for connections on a named pipe
- * specific to the registered CLSID. When something else connects to it, it writes
- * out the marshalled IClassFactory interface to the pipe. The code on the other end
- * uses this buffer to unmarshal the class factory, and can then call methods on it.
+ * In Windows, such objects are registered with the RPC endpoint
+ * mapper, not with a unique named pipe.
  *
- * In Windows, such objects are registered with the RPC endpoint mapper, not with
- * a unique named pipe.
+ * MSDN claims that multiple interface registrations are legal, but we
+ * can't do that with our current implementation.
  *
- * See the Windows documentation for more details.
+ * RETURNS
+ *   S_OK on success, 
+ *   E_INVALIDARG if lpdwRegister or pUnk are NULL, 
+ *   CO_E_OBJISREG if the object is already registered. We should not return this.
+ *
+ * SEE ALSO
+ *   CoRevokeClassObject, CoGetClassObject
  */
 HRESULT WINAPI CoRegisterClassObject(
-	REFCLSID rclsid,
-	LPUNKNOWN pUnk,
-	DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
-	DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
-	LPDWORD lpdwRegister
-)
+        REFCLSID rclsid,       /* [in] CLSID of the object to register */
+	LPUNKNOWN pUnk,        /* [in] IUnknown of the object */
+	DWORD dwClsContext,    /* [in] CLSCTX flags indicating the context in which to run the executable */
+	DWORD flags,           /* [in] REGCLS flags indicating how connections are made */
+	LPDWORD lpdwRegister)  /* [out] A unique cookie that can be passed to CoRevokeClassObject */
 {
   RegisteredClass* newClass;
   LPUNKNOWN        foundObject;
@@ -1178,9 +1225,6 @@
   /*
    * First, check if the class is already registered.
    * If it is, this should cause an error.
-   *
-   * MSDN claims that multiple interface registrations are legal, but we can't do that with
-   * our current implementation.
    */
   hr = COM_GetRegisteredClassObject(rclsid, dwClsContext, &foundObject);
   if (hr == S_OK) {
@@ -1525,9 +1569,11 @@
 	REFIID iid,
 	LPVOID *ppv)
 {
-	HRESULT hres;
-	LPCLASSFACTORY lpclf = 0;
+  HRESULT hres;
+  LPCLASSFACTORY lpclf = 0;
 
+  if (!COM_CurrentApt()) return CO_E_NOTINITIALIZED;
+        
   /*
    * Sanity check
    */
@@ -1962,9 +2008,6 @@
     return 0;
 }
 
-static int nStatCounter = 0;	 /* global */
-static HMODULE hOleAut32 = 0;	 /* global */
-
 /***********************************************************************
  *           CoGetState [OLE32.@]
  *
@@ -1990,7 +2033,6 @@
 /***********************************************************************
  *           CoSetState [OLE32.@]
  *
- * NOTES: FIXME: protect this with a crst
  */
 HRESULT WINAPI CoSetState(IUnknown * pv)
 {
@@ -2002,15 +2044,11 @@
 
 	if (pv) {
 	    IUnknown_AddRef(pv);
-	    nStatCounter++;
-	    if (nStatCounter == 1) LoadLibraryA("OLEAUT32.DLL");
 	}
 
 	if (apt->state) {
 	    TRACE("-- release %p now\n", apt->state);
 	    IUnknown_Release(apt->state);
-	    nStatCounter--;
-	    if (!nStatCounter) FreeLibrary(hOleAut32);
 	}
 	apt->state = pv;
 	return S_OK;
@@ -2211,3 +2249,21 @@
     FIXME("\n");
     return S_OK;
 }
+
+/***********************************************************************
+ *           CoAddRefServerProcess [OLE32.@]
+ */
+ULONG WINAPI CoAddRefServerProcess(void)
+{
+    FIXME("\n");
+    return 2;
+}
+
+/***********************************************************************
+ *           CoReleaseServerProcess [OLE32.@]
+ */
+ULONG WINAPI CoReleaseServerProcess(void)
+{
+    FIXME("\n");
+    return 1;
+}

reactos/lib/ole32
errorinfo.c 1.6 -> 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- errorinfo.c	19 Sep 2004 10:20:48 -0000	1.6
+++ errorinfo.c	8 Dec 2004 21:57:16 -0000	1.6.6.1
@@ -358,7 +358,7 @@
 	LPOLESTR szSource)
 {
 	_ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
-	TRACE("(%p)\n",This);
+	TRACE("(%p): %s\n",This, debugstr_w(szSource));
 	if (This->bstrSource != NULL)
 	    ERRORINFO_SysFreeString(This->bstrSource);
 	This->bstrSource = ERRORINFO_SysAllocString(szSource);
@@ -371,7 +371,7 @@
 	LPOLESTR szDescription)
 {
 	_ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
-	TRACE("(%p)\n",This);
+	TRACE("(%p): %s\n",This, debugstr_w(szDescription));
 	if (This->bstrDescription != NULL)
 	    ERRORINFO_SysFreeString(This->bstrDescription);
 	This->bstrDescription = ERRORINFO_SysAllocString(szDescription);

reactos/lib/ole32
marshal.c 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- marshal.c	20 Oct 2004 09:27:43 -0000	1.8
+++ marshal.c	8 Dec 2004 21:57:16 -0000	1.8.2.1
@@ -763,3 +763,47 @@
   *ppv = &pdfmarshalcfvtbl;
   return S_OK;
 }
+
+/***********************************************************************
+ *		CoMarshalHresult	[OLE32.@]
+ *
+ * Marshals an HRESULT value into a stream.
+ *
+ * PARAMS
+ *  pStm    [I] Stream that hresult will be marshaled into.
+ *  hresult [I] HRESULT to be marshaled.
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Failure: A COM error code
+ *
+ * SEE
+ *  CoUnmarshalHresult().
+ */
+HRESULT WINAPI
+CoMarshalHresult(LPSTREAM pStm, HRESULT hresult)
+{
+    return IStream_Write(pStm, &hresult, sizeof(hresult), NULL);
+}
+
+/***********************************************************************
+ *		CoUnmarshalHresult	[OLE32.@]
+ *
+ * Unmarshals an HRESULT value from a stream.
+ *
+ * PARAMS
+ *  pStm     [I] Stream that hresult will be unmarshaled from.
+ *  phresult [I] Pointer to HRESULT where the value will be unmarshaled to.
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Failure: A COM error code
+ *
+ * SEE
+ *  CoMarshalHresult().
+ */
+HRESULT WINAPI
+CoUnmarshalHresult(LPSTREAM pStm, HRESULT * phresult)
+{
+    return IStream_Read(pStm, phresult, sizeof(*phresult), NULL);
+}

reactos/lib/ole32
ole2impl.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- ole2impl.c	20 Oct 2004 09:27:43 -0000	1.4
+++ ole2impl.c	8 Dec 2004 21:57:16 -0000	1.4.2.1
@@ -195,3 +195,110 @@
 
   return DV_E_FORMATETC;
 }
+
+
+/******************************************************************************
+ *              OleDuplicateData        [OLE32.@]
+ *
+ * Duplicates clipboard data.
+ *
+ * PARAMS
+ *  hSrc     [I] Handle of the source clipboard data.
+ *  cfFormat [I] The clipboard format of hSrc.
+ *  uiFlags  [I] Flags to pass to GlobalAlloc.
+ *
+ * RETURNS
+ *  Success: handle to the duplicated data.
+ *  Failure: NULL.
+ */
+HANDLE WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat,
+	                          UINT uiFlags)
+{
+    HANDLE hDst = NULL;
+
+    TRACE("(%p,%x,%x)\n", hSrc, cfFormat, uiFlags);
+
+    if (!uiFlags) uiFlags = GMEM_MOVEABLE;
+
+    switch (cfFormat)
+    {
+    case CF_ENHMETAFILE:
+        hDst = CopyEnhMetaFileW(hSrc, NULL);
+        break;
+    case CF_METAFILEPICT:
+        hDst = CopyMetaFileW(hSrc, NULL);
+        break;
+    case CF_PALETTE:
+        {
+            LOGPALETTE * logpalette;
+            UINT nEntries = GetPaletteEntries(hSrc, 0, 0, NULL);
+            if (!nEntries) return NULL;
+            logpalette = HeapAlloc(GetProcessHeap(), 0,
+                FIELD_OFFSET(LOGPALETTE, palPalEntry[nEntries]));
+            if (!logpalette) return NULL;
+            if (!GetPaletteEntries(hSrc, 0, nEntries, logpalette->palPalEntry))
+            {
+                HeapFree(GetProcessHeap(), 0, logpalette);
+                return NULL;
+            }
+            logpalette->palVersion = 0x300;
+            logpalette->palNumEntries = (WORD)nEntries;
+
+            hDst = CreatePalette(logpalette);
+
+            HeapFree(GetProcessHeap(), 0, logpalette);
+            break;
+        }
+    case CF_BITMAP:
+        {
+            LONG size;
+            BITMAP bm;
+            if (!GetObjectW(hSrc, sizeof(bm), &bm))
+                return NULL;
+            size = GetBitmapBits(hSrc, 0, NULL);
+            if (!size) return NULL;
+            bm.bmBits = HeapAlloc(GetProcessHeap(), 0, size);
+            if (!bm.bmBits) return NULL;
+            if (!GetBitmapBits(hSrc, size, bm.bmBits))
+                return NULL;
+            hDst = CreateBitmapIndirect(&bm);
+            HeapFree(GetProcessHeap(), 0, bm.bmBits);
+            break;
+        }
+    default:
+        {
+            SIZE_T size = GlobalSize(hSrc);
+            LPVOID pvSrc = NULL;
+            LPVOID pvDst = NULL;
+
+            /* allocate space for object */
+            if (!size) return NULL;
+            hDst = GlobalAlloc(uiFlags, size);
+            if (!hDst) return NULL;
+
+            /* lock pointers */
+            pvSrc = GlobalLock(hSrc);
+            if (!pvSrc)
+            {
+                GlobalFree(hDst);
+                return NULL;
+            }
+            pvDst = GlobalLock(hDst);
+            if (!pvDst)
+            {
+                GlobalUnlock(hSrc);
+                GlobalFree(hDst);
+                return NULL;
+            }
+            /* copy data */
+            memcpy(pvDst, pvSrc, size);
+
+            /* cleanup */
+            GlobalUnlock(hDst);
+            GlobalUnlock(hSrc);
+        }
+    }
+
+    TRACE("returning %p\n", hDst);
+    return hDst;
+}

reactos/lib/ole32
ole2stubs.c 1.2 -> 1.2.24.1
diff -u -r1.2 -r1.2.24.1
--- ole2stubs.c	2 Jan 2004 19:49:45 -0000	1.2
+++ ole2stubs.c	8 Dec 2004 21:57:16 -0000	1.2.24.1
@@ -43,18 +43,6 @@
     return E_NOTIMPL;
 }
 
-
-/******************************************************************************
- *              OleDuplicateData        [OLE32.@]
- */
-HANDLE WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat,
-	                          UINT uiFlags)
-{
-    FIXME("(%p,%x,%x), stub!\n", hSrc, cfFormat, uiFlags);
-    return NULL;
-}
-
-
 /******************************************************************************
  *              SetConvertStg        [OLE32.@]
  */

reactos/lib/ole32
ole32.spec 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ole32.spec	20 Oct 2004 09:27:43 -0000	1.3
+++ ole32.spec	8 Dec 2004 21:57:16 -0000	1.3.2.1
@@ -5,7 +5,7 @@
 @ stub CLIPFORMAT_UserUnmarshal
 @ stdcall CLSIDFromProgID(wstr ptr)
 @ stdcall CLSIDFromString(wstr ptr)
-@ stub CoAddRefServerProcess
+@ stdcall CoAddRefServerProcess()
 @ stdcall CoBuildVersion()
 @ stub CoCopyProxy                #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
 @ stdcall CoCreateFreeThreadedMarshaler(ptr ptr)
@@ -44,7 +44,7 @@
 @ stdcall CoIsOle1Class (ptr)
 @ stdcall CoLoadLibrary(wstr long)
 @ stdcall CoLockObjectExternal(ptr long long)
-@ stub CoMarshalHresult           #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
+@ stdcall CoMarshalHresult(ptr long)
 @ stdcall CoMarshalInterThreadInterfaceInStream(ptr ptr ptr)
 @ stdcall CoMarshalInterface(ptr ptr ptr long ptr long)
 @ stub CoQueryAuthenticationServices
@@ -58,7 +58,7 @@
 @ stub CoRegisterPSClsid          #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
 @ stub CoRegisterSurrogate
 @ stdcall CoReleaseMarshalData(ptr)
-@ stub CoReleaseServerProcess     #@ stdcall () return 0,ERR_NOTIMPLEMENTED
+@ stdcall CoReleaseServerProcess()
 @ stdcall CoResumeClassObjects()
 @ stub CoRevertToSelf             #@ stdcall () return 0,ERR_NOTIMPLEMENTED
 @ stdcall CoRevokeClassObject(long)
@@ -73,7 +73,7 @@
 @ stdcall CoTreatAsClass(ptr ptr)
 @ stdcall CoUninitialize()
 @ stub CoUnloadingWOW
-@ stub CoUnmarshalHresult         #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
+@ stdcall CoUnmarshalHresult(ptr ptr)
 @ stdcall CoUnmarshalInterface(ptr ptr ptr)
 @ stdcall CreateAntiMoniker(ptr)
 @ stdcall CreateBindCtx(long ptr)

reactos/lib/ole32
storage.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- storage.c	20 Oct 2004 09:27:43 -0000	1.11
+++ storage.c	8 Dec 2004 21:57:16 -0000	1.11.2.1
@@ -1125,7 +1125,7 @@
 	ULONG	*byteswritten=pcbWrite,xxwritten;
 	int	oldsize,newsize,i,curoffset=0,lastblocknr,blocknr,cc;
 	HANDLE	hf = This->hf;
-	LPBYTE	pbv = (LPBYTE)pv;
+	const BYTE*     pbv = (const BYTE*)pv;
 
 	if (!pcbWrite) byteswritten=&xxwritten;
 	*byteswritten = 0;

reactos/lib/ole32
storage32.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- storage32.c	20 Oct 2004 09:27:43 -0000	1.9
+++ storage32.c	8 Dec 2004 21:57:16 -0000	1.9.2.1
@@ -144,8 +144,8 @@
   StgProperty newProperty);
 
 static LONG propertyNameCmp(
-  OLECHAR *newProperty,
-  OLECHAR *currentProperty);
+    const OLECHAR *newProperty,
+    const OLECHAR *currentProperty);
 
 
 /***********************************************************************
@@ -1158,7 +1158,7 @@
    */
   hr = IStorage_OpenStorage(
          iface,
-         (OLECHAR*)pwcsName,
+         (const OLECHAR*)pwcsName,
          0,
          grfMode,
          0,
@@ -1284,8 +1284,8 @@
  *          0 when newPrpoerty == currentProperty
  */
 static LONG propertyNameCmp(
-  OLECHAR *newProperty,
-  OLECHAR *currentProperty)
+    const OLECHAR *newProperty,
+    const OLECHAR *currentProperty)
 {
   LONG diff      = lstrlenW(newProperty) - lstrlenW(currentProperty);
 
@@ -3962,8 +3962,8 @@
       currentProperty);
 
     if ( propertyNameCmp(
-          (OLECHAR*)currentProperty->name,
-          (OLECHAR*)lpszPropName) == 0)
+          (const OLECHAR*)currentProperty->name,
+          (const OLECHAR*)lpszPropName) == 0)
       return currentSearchNode;
 
     /*
@@ -4348,7 +4348,7 @@
   ULONG offsetInBlock     = offset.u.LowPart % This->parentStorage->bigBlockSize;
   ULONG bytesToWrite;
   ULONG blockIndex;
-  BYTE* bufferWalker;
+  const BYTE* bufferWalker;
   BYTE* bigBlockBuffer;
 
   /*
@@ -4385,7 +4385,7 @@
    * This is OK since we don't intend to modify that buffer.
    */
   *bytesWritten   = 0;
-  bufferWalker = (BYTE*)buffer;
+  bufferWalker = (const BYTE*)buffer;
 
   while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
   {
@@ -5095,7 +5095,7 @@
   ULONG bytesToWriteInBuffer;
   ULONG blockIndex;
   ULONG bytesWrittenFromBigBlockFile;
-  BYTE* bufferWalker;
+  const BYTE* bufferWalker;
 
   /*
    * This should never happen on a small block file.
@@ -5121,7 +5121,7 @@
    * This is OK since we don't intend to modify that buffer.
    */
   *bytesWritten   = 0;
-  bufferWalker = (BYTE*)buffer;
+  bufferWalker = (const BYTE*)buffer;
   while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
   {
     /*

reactos/lib/ole32
winehq2ros.patch 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- winehq2ros.patch	20 Oct 2004 09:27:43 -0000	1.8
+++ winehq2ros.patch	8 Dec 2004 21:57:16 -0000	1.8.2.1
@@ -1,26 +1,10 @@
-Index: Makefile.in
-===================================================================
-RCS file: /home/wine/wine/dlls/ole32/Makefile.in,v
-retrieving revision 1.39
-diff -u -r1.39 Makefile.in
---- Makefile.in	21 Sep 2004 00:35:03 -0000	1.39
-+++ Makefile.in	20 Oct 2004 09:21:24 -0000
-@@ -53,7 +53,7 @@
- 	ole2thk.spec \
- 	storage.spec
- 
--RC_SRCS = ole32res.rc version.rc
-+RC_SRCS = ole32res.rc
- RC_BINSRC = ole32res.rc
- RC_BINARIES = \
- 	drag_copy.cur \
 Index: ifs.h
 ===================================================================
 RCS file: /home/wine/wine/dlls/ole32/ifs.h,v
 retrieving revision 1.13
 diff -u -r1.13 ifs.h
 --- ifs.h	5 Oct 2004 04:16:21 -0000	1.13
-+++ ifs.h	20 Oct 2004 09:21:25 -0000
++++ ifs.h	6 Dec 2004 10:15:06 -0000
 @@ -33,8 +33,7 @@
   * IMalloc16 interface
   */
@@ -66,29 +50,13 @@
  
  #define INTERFACE IStorage16
  DECLARE_INTERFACE_(IStorage16,IUnknown)
-Index: ole32res.rc
-===================================================================
-RCS file: /home/wine/wine/dlls/ole32/ole32res.rc,v
-retrieving revision 1.5
-diff -u -r1.5 ole32res.rc
---- ole32res.rc	3 Oct 2003 05:01:34 -0000	1.5
-+++ ole32res.rc	20 Oct 2004 09:21:25 -0000
-@@ -23,6 +23,8 @@
- #include "winuser.h"
- #include "winnls.h"
- 
-+#include "version.rc"
-+
- /*
-  * Everything that does not depend on language,
-  * like textless bitmaps etc, go into the
 Index: oleproxy.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/ole32/oleproxy.c,v
 retrieving revision 1.23
 diff -u -r1.23 oleproxy.c
 --- oleproxy.c	7 Oct 2004 03:06:49 -0000	1.23
-+++ oleproxy.c	20 Oct 2004 09:21:25 -0000
++++ oleproxy.c	6 Dec 2004 10:15:06 -0000
 @@ -38,6 +38,7 @@
  
  #include <stdlib.h>

reactos/lib/oleaut32
oleaut32_Pl.rc added at 1.1.2.1
diff -N oleaut32_Pl.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ oleaut32_Pl.rc	8 Dec 2004 21:57:18 -0000	1.1.2.1
@@ -0,0 +1,32 @@
+/*
+ * Polish resources for oleaut32
+ *
+ * Copyright 2003 Jon Griffiths
+ * Copyright 2004 Jacek Caban
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+LANGUAGE LANG_POLISH, SUBLANG_DEFAULT 
+
+STRINGTABLE DISCARDABLE
+{
+  IDS_TRUE  "Prawda"
+  IDS_FALSE "Fa�sz"
+  IDS_YES   "Tak"
+  IDS_NO    "Nie"
+  IDS_ON    "W��czone"
+  IDS_OFF   "Wy��czone"
+}

reactos/lib/oleaut32
winehq2ros.patch added at 1.1.2.1
diff -N winehq2ros.patch
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ winehq2ros.patch	8 Dec 2004 21:57:18 -0000	1.1.2.1
@@ -0,0 +1,33 @@
+--- variant.c	Thu Dec  2 19:30:53 2004
++++ variant.c	Thu Dec  2 19:38:26 2004
+@@ -2390,7 +2390,7 @@
+     ULONG64 tmp;
+     DECIMAL* pDec = &V_DECIMAL(pVarDst);
+ 
+-    DECIMAL_SETZERO(pDec);
++    DECIMAL_SETZERO(*pDec);
+     DEC_LO32(pDec) = 0;
+ 
+     if (pNumprs->dwOutFlags & NUMPRS_NEG)
+--- variant.h	Mon Aug 23 07:35:19 2004
++++ variant.h	Thu Dec  2 19:43:06 2004
+@@ -82,13 +82,13 @@
+ #endif
+ 
+ /* Macros for getting at a DECIMAL's parts */
+-#define DEC_SIGN(d)      ((d)->u.s.sign)
+-#define DEC_SCALE(d)     ((d)->u.s.scale)
+-#define DEC_SIGNSCALE(d) ((d)->u.signscale)
++#define DEC_SIGN(d)      ((d)->sign)
++#define DEC_SCALE(d)     ((d)->scale)
++#define DEC_SIGNSCALE(d) ((d)->signscale)
+ #define DEC_HI32(d)      ((d)->Hi32)
+-#define DEC_MID32(d)     ((d)->u1.s1.Mid32)
+-#define DEC_LO32(d)      ((d)->u1.s1.Lo32)
+-#define DEC_LO64(d)      ((d)->u1.Lo64)
++#define DEC_MID32(d)     ((d)->Mid32)
++#define DEC_LO32(d)      ((d)->Lo32)
++#define DEC_LO64(d)      ((d)->Lo64)
+ 
+ #define DEC_MAX_SCALE    28 /* Maximum scale for a decimal */
+ 

reactos/lib/oleaut32
.cvsignore 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- .cvsignore	2 Nov 2004 19:47:17 -0000	1.5
+++ .cvsignore	8 Dec 2004 21:57:17 -0000	1.5.2.1
@@ -1,8 +1,9 @@
 *.coff
 *.dll
-*.sym
-*.o
 *.d
+*.a
+*.o
+*.sym
 *.map
 *.tmp
 Makefile.ros

reactos/lib/oleaut32
Makefile.in 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- Makefile.in	16 Oct 2004 20:27:36 -0000	1.6
+++ Makefile.in	8 Dec 2004 21:57:17 -0000	1.6.2.1
@@ -6,35 +6,35 @@
 MODULE    = oleaut32.dll
 IMPORTS   = ole32 rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
 DELAYIMPORTS = comctl32
-ALTNAMES  = ole2disp.dll typelib.dll
-EXTRALIBS = $(LIBUNICODE) -luuid @GIFLIB@ @JPEGLIB@
-
-SPEC_SRCS16 = $(ALTNAMES:.dll=.spec)
+EXTRALIBS = $(LIBUNICODE) -luuid
 
 C_SRCS = \
 	connpt.c \
 	dispatch.c \
 	hash.c \
+	oaidl_p.c \
 	oleaut.c \
+	olefont.c \
 	olepicture.c \
+	regsvr.c \
 	safearray.c \
 	stubs.c \
+	tmarshal.c \
+	typelib.c \
+	typelib2.c \
+	usrmarshal.c \
 	varformat.c \
 	variant.c \
 	vartype.c
 
-#	regsvr.c \
-#	olefont.c \
-#	tmarshal.c \
-#	usrmarshal.c \
-#	oaidl_p.c \
-#	typelib.c \
-#	typelib2.c \
-
 C_SRCS16 = \
 	ole2disp.c \
 	typelib16.c
 
+SPEC_SRCS16 = \
+	ole2disp.spec \
+	typelib.spec
+
 RC_SRCS = oleaut32.rc
 
 SUBDIRS = tests

reactos/lib/oleaut32
Makefile.ros-template 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- Makefile.ros-template	20 Oct 2004 20:31:36 -0000	1.5
+++ Makefile.ros-template	8 Dec 2004 21:57:17 -0000	1.5.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.5 2004/10/20 20:31:36 gvg Exp $
+# $Id: Makefile.ros-template,v 1.5.2.1 2004/12/08 21:57:17 hyperion Exp $
 
 TARGET_NAME = oleaut32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ -DCOBJMACROS
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a libwine_unicode.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a wine_unicode.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_OLEAUT32)
 

reactos/lib/oleaut32
connpt.c 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- connpt.c	26 Sep 2004 14:34:22 -0000	1.2
+++ connpt.c	8 Dec 2004 21:57:17 -0000	1.2.6.1
@@ -25,6 +25,9 @@
 #include <assert.h>
 #include <stdarg.h>
 #include <string.h>
+
+#define COBJMACROS
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
@@ -194,9 +197,7 @@
 {
   ConnectionPointImpl *This = (ConnectionPointImpl *)iface;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  This->ref++;
-
-  return This->ref;
+  return InterlockedIncrement(&This->ref);
 }
 
 /************************************************************************
@@ -208,24 +209,20 @@
       IConnectionPoint* iface)
 {
   ConnectionPointImpl *This = (ConnectionPointImpl *)iface;
+  ULONG ref;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
 
   /*
    * Decrease the reference count on this object.
    */
-  This->ref--;
+  ref = InterlockedDecrement(&This->ref);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (This->ref==0)
-  {
-    ConnectionPointImpl_Destroy(This);
+  if (ref == 0) ConnectionPointImpl_Destroy(This);
 
-    return 0;
-  }
-
-  return This->ref;
+  return ref;
 }
 
 /************************************************************************
@@ -473,10 +470,11 @@
 static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
 {
   EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
+  ULONG ref;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  This->ref++;
+  ref = InterlockedIncrement(&This->ref);
   IUnknown_AddRef(This->pUnk);
-  return This->ref;
+  return ref;
 }
 
 /************************************************************************
@@ -487,6 +485,7 @@
 static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface)
 {
   EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
+  ULONG ref;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
 
   IUnknown_Release(This->pUnk);
@@ -494,19 +493,14 @@
   /*
    * Decrease the reference count on this object.
    */
-  This->ref--;
+  ref = InterlockedDecrement(&This->ref);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (This->ref==0)
-  {
-    EnumConnectionsImpl_Destroy(This);
-
-    return 0;
-  }
+  if (ref == 0) EnumConnectionsImpl_Destroy(This);
 
-  return This->ref;
+  return ref;
 }
 
 /************************************************************************

reactos/lib/oleaut32
dispatch.c 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- dispatch.c	26 Sep 2004 14:34:22 -0000	1.2
+++ dispatch.c	8 Dec 2004 21:57:17 -0000	1.2.6.1
@@ -28,6 +28,8 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#define COBJMACROS
+
 #include "windef.h"
 #include "winbase.h"
 #include "objbase.h"
@@ -180,28 +182,6 @@
     return S_OK;
 }
 
-/******************************************************************************
- * CreateDispTypeInfo [OLEAUT32.31]
- *
- * Build type information for an object so it can be called through an
- * IDispatch interface.
- *
- * RETURNS
- *  Success: S_OK. pptinfo contains the created ITypeInfo object.
- *  Failure: E_INVALIDARG, if one or more arguments is invalid.
- *
- * NOTES
- *  This call allows an objects methods to be accessed through IDispatch, by
- *  building an ITypeInfo object that IDispatch can use to call through.
- */
-HRESULT WINAPI CreateDispTypeInfo(
-	INTERFACEDATA *pidata, /* [I] Description of the interface to build type info for */
-	LCID lcid, /* [I] Locale Id */
-	ITypeInfo **pptinfo) /* [O] Destination for created ITypeInfo object */
-{
-	FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
-	return 0;
-}
 
 /******************************************************************************
  * IDispatch {OLEAUT32}
@@ -278,7 +258,7 @@
     StdDispatch *This = (StdDispatch *)iface;
     TRACE("()\n");
 
-    return ++This->ref;
+    return InterlockedIncrement(&This->ref);
 }
 
 /******************************************************************************
@@ -289,18 +269,18 @@
 static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
 {
     StdDispatch *This = (StdDispatch *)iface;
-    ULONG ret;
+    ULONG ref;
     TRACE("(%p)->()\n", This);
 
-    ret = This->ref--;
+    ref = InterlockedDecrement(&This->ref);
 
-    if (This->ref == 0)
+    if (ref == 0)
     {
         ITypeInfo_Release(This->pTypeInfo);
         CoTaskMemFree(This);
     }
 
-    return ret;
+    return ref;
 }
 
 /******************************************************************************

reactos/lib/oleaut32
hash.c 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- hash.c	7 Feb 2004 18:53:58 -0000	1.1
+++ hash.c	8 Dec 2004 21:57:17 -0000	1.1.22.1
@@ -23,6 +23,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winnls.h"
+#include "objbase.h"
 #include "oaidl.h"
 #include "wine/debug.h"
 
@@ -537,9 +538,7 @@
   case LANG_SWEDISH:    case LANG_SYRIAC:     case LANG_TAMIL:
   case LANG_TATAR:      case LANG_TELUGU:     case LANG_THAI:
   case LANG_UKRAINIAN:  case LANG_URDU:       case LANG_UZBEK:
-  case LANG_VIETNAMESE:
-#ifndef __REACTOS__	/* non standard languages */
-  case LANG_GAELIC:     case LANG_MALTESE:
+  case LANG_VIETNAMESE: case LANG_GAELIC:     case LANG_MALTESE:
   case LANG_MAORI:      case LANG_RHAETO_ROMANCE:
   case LANG_SAAMI:      case LANG_SORBIAN:    case LANG_SUTU:
   case LANG_TSONGA:     case LANG_TSWANA:     case LANG_VENDA:
@@ -549,7 +548,6 @@
     nOffset = 16;
     pnLookup = Lookup_16;
     break;
-#endif /* __REACTOS__ */
   case LANG_CZECH:  case LANG_HUNGARIAN:  case LANG_POLISH:
   case LANG_SLOVAK: case LANG_SPANISH:
     nOffset = 32;

reactos/lib/oleaut32
oaidl_p.c 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- oaidl_p.c	7 Feb 2004 18:53:58 -0000	1.1
+++ oaidl_p.c	8 Dec 2004 21:57:17 -0000	1.1.22.1
@@ -1,5 +1,14 @@
-/* this ALWAYS GENERATED file contains the proxy stub code */
+/* This file contains the proxy/stub code for core COM interfaces.
 
+   It is usually generated directly by MIDL, however this file has
+   been tweaked since then to account for slight differences in the way
+   gcc and MSVC++ compile it. In particular, in some functions REFIIDs
+   declared on the stack have been converted to plain IID* in order to eliminate
+   the constness of the REFIID type, ensuring that the zero initializer is not
+   discarded.
+
+   Therefore, please do not regenerate this file.
+*/
 
 /* File created by MIDL compiler version 5.01.0164 */
 /* at Tue Jan 07 22:24:52 2003
@@ -19,6 +28,8 @@
 
 #include <stdarg.h>
 
+#define COBJMACROS
+
 #include "windef.h"
 #include "winbase.h"
 #include "objbase.h"
@@ -436,7 +447,7 @@
     LCID lcid;
     DISPID __RPC_FAR *rgDispId;
     LPOLESTR __RPC_FAR *rgszNames;
-    REFIID riid = 0;
+    IID* riid = 0;
     
 NdrStubInitialize(
                      _pRpcMessage,
@@ -726,7 +737,7 @@
     VARIANT __RPC_FAR *pVarResult;
     VARIANTARG __RPC_FAR *rgVarRef;
     UINT __RPC_FAR *rgVarRefIdx;
-    REFIID riid = 0;
+    IID* riid = 0;
     
 NdrStubInitialize(
                      _pRpcMessage,
@@ -4039,7 +4050,7 @@
     HRESULT _RetVal;
     MIDL_STUB_MESSAGE _StubMsg;
     IUnknown __RPC_FAR *__RPC_FAR *ppvObj;
-    REFIID riid = 0;
+    IID* riid = 0;
     
 NdrStubInitialize(
                      _pRpcMessage,
@@ -10751,7 +10762,7 @@
 {
     HRESULT _RetVal;
     MIDL_STUB_MESSAGE _StubMsg;
-    REFIID riid = 0;
+    IID* riid = 0;
     
 NdrStubInitialize(
                      _pRpcMessage,
@@ -10931,7 +10942,7 @@
     MIDL_STUB_MESSAGE _StubMsg;
     ITypeInfo __RPC_FAR *pTypeInfo;
     IUnknown __RPC_FAR *__RPC_FAR *ppv;
-    REFIID riid = 0;
+    IID* riid = 0;
     
 NdrStubInitialize(
                      _pRpcMessage,

reactos/lib/oleaut32
oleaut.c 1.4 -> 1.4.20.1
diff -u -r1.4 -r1.4.20.1
--- oleaut.c	1 Mar 2004 22:45:23 -0000	1.4
+++ oleaut.c	8 Dec 2004 21:57:17 -0000	1.4.20.1
@@ -21,6 +21,8 @@
 #include <stdarg.h>
 #include <string.h>
 
+#define COBJMACROS
+
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
@@ -47,7 +49,6 @@
 
 HMODULE OLEAUT32_hModule = NULL;
 
-
 /******************************************************************************
  * BSTR  {OLEAUT32}
  *
@@ -570,6 +571,28 @@
 }
 
 /******************************************************************************
+ *      GetRecordInfoFromGuids  [OLEAUT32.322]
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Failure: E_INVALIDARG, if any argument is invalid.
+ *
+ * BUGS
+ *  Unimplemented
+ */
+HRESULT WINAPI GetRecordInfoFromGuids(
+    REFGUID rGuidTypeLib,
+    ULONG uVerMajor,
+    ULONG uVerMinor,
+    LCID lcid,
+    REFGUID rGuidTypeInfo,
+    IRecordInfo** ppRecInfo)
+{
+    FIXME("(%p,%ld,%ld,%ld,%p,%p),stub!\n",rGuidTypeLib, uVerMajor, uVerMinor, lcid, rGuidTypeInfo, ppRecInfo);
+    return E_NOTIMPL;
+}
+
+/******************************************************************************
  *		OleTranslateColor	[OLEAUT32.421]
  *
  * Convert an OLE_COLOR to a COLORREF.
@@ -644,7 +667,7 @@
       /*
        * Validate GetSysColor index.
        */
-      if ((index < COLOR_SCROLLBAR) || (index > COLOR_GRADIENTINACTIVECAPTION))
+      if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR))
         return E_INVALIDARG;
 
       *pColorRef =  GetSysColor(index);
@@ -667,7 +690,6 @@
 /***********************************************************************
  *		DllGetClassObject (OLEAUT32.1)
  */
-#ifndef __REACTOS__ /*FIXME: no marshalling yet*/
 HRESULT WINAPI OLEAUT32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
 {
     *ppv = NULL;
@@ -696,7 +718,6 @@
     FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
     return CLASS_E_CLASSNOTAVAILABLE;
 }
-#endif
 
 /***********************************************************************
  *		DllCanUnloadNow (OLEAUT32.410)
@@ -709,7 +730,7 @@
  * RETURNS
  *  Always returns S_FALSE. This dll cannot be unloaded.
  */
-HRESULT WINAPI OLEAUT32_DllCanUnloadNow()
+HRESULT WINAPI OLEAUT32_DllCanUnloadNow(void)
 {
     return S_FALSE;
 }

reactos/lib/oleaut32
oleaut32.rc 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- oleaut32.rc	16 Oct 2004 20:27:36 -0000	1.5
+++ oleaut32.rc	8 Dec 2004 21:57:17 -0000	1.5.2.1
@@ -34,13 +34,14 @@
 #include "oleaut32_It.rc"
 #include "oleaut32_Nl.rc"
 #include "oleaut32_No.rc"
+#include "oleaut32_Pl.rc"
 #include "oleaut32_Pt.rc"
 #include "oleaut32_Sv.rc"
 #include "oleaut32_Th.rc"
 
 /*
  * FIXME:
- *  Polish, Finnish, Greek, Hebrew, Japanese, Korean, Portuguese,
+ *  Finnish, Greek, Hebrew, Japanese, Korean, Portuguese,
  *  Russian, Turkish, Slovenian (at least) are localised in XP Home.
  *  I expect Chinese etc are localised in Asian Editions also.
  */

reactos/lib/oleaut32
oleaut32.spec 1.8 -> 1.8.20.1
diff -u -r1.8 -r1.8.20.1
--- oleaut32.spec	1 Mar 2004 22:57:20 -0000	1.8
+++ oleaut32.spec	8 Dec 2004 21:57:17 -0000	1.8.20.1
@@ -1,4 +1,4 @@
-#1 stdcall -private DllGetClassObject(ptr ptr ptr) OLEAUT32_DllGetClassObject
+1 stdcall -private DllGetClassObject(ptr ptr ptr) OLEAUT32_DllGetClassObject
 2 stdcall SysAllocString(wstr)
 3 stdcall SysReAllocString(ptr wstr)
 4 stdcall SysAllocStringLen(wstr long)
@@ -142,12 +142,12 @@
 142 stdcall VarAnd(ptr ptr ptr)
 143 stdcall VarDiv(ptr ptr ptr)
 144 stub OACreateTypeLib2
-#146 stdcall DispCallFunc(ptr long long long long ptr ptr ptr)
+146 stdcall DispCallFunc(ptr long long long long ptr ptr ptr)
 147 stdcall VariantChangeTypeEx(ptr ptr long long long)
 148 stdcall SafeArrayPtrOfIndex(ptr ptr ptr)
 149 stdcall SysStringByteLen(ptr)
 150 stdcall SysAllocStringByteLen(ptr long)
-152 stub VarEqv # stdcall (ptr ptr ptr)
+152 stdcall VarEqv(ptr ptr ptr)
 153 stub VarIdiv # stdcall (ptr ptr ptr)
 154 stub VarImp # stdcall (ptr ptr ptr)
 155 stdcall VarMod(ptr ptr ptr)
@@ -155,18 +155,18 @@
 157 stdcall VarOr(ptr ptr ptr)
 158 stdcall VarPow(ptr ptr ptr)
 159 stdcall VarSub(ptr ptr ptr)
-#160 stdcall CreateTypeLib(long wstr ptr)
-#161 stdcall LoadTypeLib (wstr ptr)
-#162 stdcall LoadRegTypeLib (ptr long long long ptr)
-#163 stdcall RegisterTypeLib(ptr wstr wstr)
-#164 stdcall QueryPathOfRegTypeLib(ptr long long long ptr)
+160 stdcall CreateTypeLib(long wstr ptr)
+161 stdcall LoadTypeLib (wstr ptr)
+162 stdcall LoadRegTypeLib (ptr long long long ptr)
+163 stdcall RegisterTypeLib(ptr wstr wstr)
+164 stdcall QueryPathOfRegTypeLib(ptr long long long ptr)
 165 stdcall LHashValOfNameSys(long long wstr)
 166 stdcall LHashValOfNameSysA(long long str)
-167 stub VarXor # stdcall (ptr ptr ptr)
+167 stdcall VarXor(ptr ptr ptr)
 168 stdcall VarAbs(ptr ptr)
 169 stdcall VarFix(ptr ptr)
 170 stdcall OaBuildVersion()
-171 stub ClearCustData
+171 stdcall ClearCustData(ptr)
 172 stdcall VarInt(ptr ptr)
 173 stdcall VarNeg(ptr ptr)
 174 stdcall VarNot(ptr ptr)
@@ -175,13 +175,13 @@
 177 stdcall VarDecAdd(ptr ptr ptr)
 178 stdcall VarDecDiv(ptr ptr ptr)
 179 stdcall VarDecMul(ptr ptr ptr)
-#180 stdcall CreateTypeLib2(long wstr ptr)
+180 stdcall CreateTypeLib2(long wstr ptr)
 181 stdcall VarDecSub(ptr ptr ptr)
 182 stdcall VarDecAbs(ptr ptr)
-#183 stdcall LoadTypeLibEx (wstr long ptr)
+183 stdcall LoadTypeLibEx (wstr long ptr)
 184 stdcall SystemTimeToVariantTime(ptr ptr)
 185 stdcall VariantTimeToSystemTime(double ptr)
-#186 stdcall UnRegisterTypeLib (ptr long long long long)
+186 stdcall UnRegisterTypeLib (ptr long long long long)
 187 stdcall VarDecFix(ptr ptr)
 188 stdcall VarDecInt(ptr ptr)
 189 stdcall VarDecNeg(ptr ptr)
@@ -278,14 +278,14 @@
 280 stdcall VarUI4FromI1(long ptr)
 281 stdcall VarUI4FromUI2(long ptr)
 282 stdcall VarUI4FromDec(ptr ptr)
-#283 stdcall BSTR_UserSize(ptr long ptr)
-#284 stdcall BSTR_UserMarshal(ptr ptr ptr)
-#285 stdcall BSTR_UserUnmarshal(ptr ptr ptr)
-#286 stdcall BSTR_UserFree(ptr ptr)
-#287 stdcall VARIANT_UserSize(ptr long ptr)
-#288 stdcall VARIANT_UserMarshal(ptr ptr ptr)
-#289 stdcall VARIANT_UserUnmarshal(ptr ptr ptr)
-#290 stdcall VARIANT_UserFree(ptr ptr)
+283 stdcall BSTR_UserSize(ptr long ptr)
+284 stdcall BSTR_UserMarshal(ptr ptr ptr)
+285 stdcall BSTR_UserUnmarshal(ptr ptr ptr)
+286 stdcall BSTR_UserFree(ptr ptr)
+287 stdcall VARIANT_UserSize(ptr long ptr)
+288 stdcall VARIANT_UserMarshal(ptr ptr ptr)
+289 stdcall VARIANT_UserUnmarshal(ptr ptr ptr)
+290 stdcall VARIANT_UserFree(ptr ptr)
 291 stub LPSAFEARRAY_UserSize
 292 stub LPSAFEARRAY_UserMarshal
 293 stub LPSAFEARRAY_UserUnmarshal
@@ -311,10 +311,10 @@
 316 stdcall VarR4CmpR8(long double)
 317 stdcall VarR8Round(double long ptr)
 318 stdcall VarCat(ptr ptr ptr)
-319 stub VarDateFromUdateEx # stdcall (ptr long long ptr)
-#320 stdcall -private DllRegisterServer() OLEAUT32_DllRegisterServer
-#321 stdcall -private DllUnregisterServer() OLEAUT32_DllUnregisterServer
-322 stub GetRecordInfoFromGuids # stdcall (ptr long long long ptr ptr)
+319 stdcall VarDateFromUdateEx(ptr long long ptr)
+320 stdcall -private DllRegisterServer() OLEAUT32_DllRegisterServer
+321 stdcall -private DllUnregisterServer() OLEAUT32_DllUnregisterServer
+322 stdcall GetRecordInfoFromGuids(ptr long long long ptr ptr)
 323 stub GetRecordInfoFromTypeInfo # stdcall (ptr ptr)
 325 stub SetVarConversionLocaleSetting
 326 stub GetVarConversionLocaleSetting
@@ -392,7 +392,7 @@
 417 stdcall OleCreatePropertyFrame(ptr long long ptr long ptr long ptr ptr long ptr)
 418 stdcall OleLoadPicture(ptr long long ptr ptr)
 419 stdcall OleCreatePictureIndirect(ptr ptr long ptr)
-#420 stdcall OleCreateFontIndirect(ptr ptr ptr)
+420 stdcall OleCreateFontIndirect(ptr ptr ptr)
 421 stdcall OleTranslateColor(long long long)
 422 stub OleLoadPictureFile
 423 stub OleSavePictureFile

reactos/lib/oleaut32
oleaut32_De.rc 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- oleaut32_De.rc	7 Feb 2004 18:53:58 -0000	1.1
+++ oleaut32_De.rc	8 Dec 2004 21:57:17 -0000	1.1.22.1
@@ -25,7 +25,7 @@
   IDS_TRUE  "Wahr"
   IDS_FALSE "Falsch"
   IDS_YES   "Ja"
-  IDS_NO    "Nei"
+  IDS_NO    "Nein"
   IDS_ON    "Ein"
   IDS_OFF   "Aus"
 }

reactos/lib/oleaut32
olefont.c 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- olefont.c	7 Feb 2004 18:53:58 -0000	1.1
+++ olefont.c	8 Dec 2004 21:57:17 -0000	1.1.22.1
@@ -24,16 +24,18 @@
 #include <stdarg.h>
 #include <string.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
 #include "wine/unicode.h"
-#include "oleauto.h"    /* for SysAllocString(....) */
 #include "objbase.h"
+#include "oleauto.h"    /* for SysAllocString(....) */
 #include "ole2.h"
 #include "olectl.h"
 #include "wine/debug.h"
@@ -61,12 +63,12 @@
    * The first two are supported by the first vtable, the next two are
    * supported by the second table and the last two have their own.
    */
-  ICOM_VTABLE(IFont)*				lpvtbl1;
-  ICOM_VTABLE(IDispatch)*			lpvtbl2;
-  ICOM_VTABLE(IPersistStream)*			lpvtbl3;
-  ICOM_VTABLE(IConnectionPointContainer)*	lpvtbl4;
-  ICOM_VTABLE(IPersistPropertyBag)*		lpvtbl5;
-  ICOM_VTABLE(IPersistStreamInit)*		lpvtbl6;
+  IFontVtbl*				lpvtbl1;
+  IDispatchVtbl*			lpvtbl2;
+  IPersistStreamVtbl*			lpvtbl3;
+  IConnectionPointContainerVtbl*	lpvtbl4;
+  IPersistPropertyBagVtbl*		lpvtbl5;
+  IPersistStreamInitVtbl*		lpvtbl6;
   /*
    * Reference count for that instance of the class.
    */
@@ -99,10 +101,9 @@
 /*
  * Here, I define utility macros to help with the casting of the
  * "this" parameter.
- * There is a version to accomodate all of the VTables implemented
+ * There is a version to accommodate all of the VTables implemented
  * by this object.
  */
-#define _ICOM_THIS(class,name) class* this = (class*)name
 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
@@ -138,7 +139,7 @@
 static HRESULT      WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont);
 static HRESULT      WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont);
 static HRESULT      WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther);
-static HRESULT      WINAPI OLEFontImpl_SetRatio(IFont* iface, long cyLogical, long cyHimetric);
+static HRESULT      WINAPI OLEFontImpl_SetRatio(IFont* iface, LONG cyLogical, LONG cyHimetric);
 static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm);
 static HRESULT      WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont);
 static HRESULT      WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont);
@@ -218,9 +219,8 @@
 /*
  * Virtual function tables for the OLEFontImpl class.
  */
-static ICOM_VTABLE(IFont) OLEFontImpl_VTable =
+static IFontVtbl OLEFontImpl_VTable =
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_QueryInterface,
   OLEFontImpl_AddRef,
   OLEFontImpl_Release,
@@ -250,9 +250,8 @@
   OLEFontImpl_SetHdc
 };
 
-static ICOM_VTABLE(IDispatch) OLEFontImpl_IDispatch_VTable =
+static IDispatchVtbl OLEFontImpl_IDispatch_VTable =
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_IDispatch_QueryInterface,
   OLEFontImpl_IDispatch_AddRef,
   OLEFontImpl_IDispatch_Release,
@@ -262,9 +261,8 @@
   OLEFontImpl_Invoke
 };
 
-static ICOM_VTABLE(IPersistStream) OLEFontImpl_IPersistStream_VTable =
+static IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable =
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_IPersistStream_QueryInterface,
   OLEFontImpl_IPersistStream_AddRef,
   OLEFontImpl_IPersistStream_Release,
@@ -275,10 +273,9 @@
   OLEFontImpl_GetSizeMax
 };
 
-static ICOM_VTABLE(IConnectionPointContainer)
+static IConnectionPointContainerVtbl
      OLEFontImpl_IConnectionPointContainer_VTable =
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_IConnectionPointContainer_QueryInterface,
   OLEFontImpl_IConnectionPointContainer_AddRef,
   OLEFontImpl_IConnectionPointContainer_Release,
@@ -286,8 +283,8 @@
   OLEFontImpl_FindConnectionPoint
 };
 
-static ICOM_VTABLE(IPersistPropertyBag) OLEFontImpl_IPersistPropertyBag_VTable;
-static ICOM_VTABLE(IPersistStreamInit) OLEFontImpl_IPersistStreamInit_VTable;
+static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable;
+static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable;
 /******************************************************************************
  *		OleCreateFontIndirect	[OLEAUT32.420]
  */
@@ -311,10 +308,10 @@
   if (!lpFontDesc) {
     FONTDESC fd;
 
-    WCHAR fname[] = { 'S','y','s','t','e','m',0 };
+    static const WCHAR fname[] = { 'S','y','s','t','e','m',0 };
 
     fd.cbSizeofstruct = sizeof(fd);
-    fd.lpstrName      = fname;
+    fd.lpstrName      = (WCHAR*)fname;
     fd.cySize.s.Lo    = 80000;
     fd.cySize.s.Hi    = 0;
     fd.sWeight 	      = 0;
@@ -476,7 +473,7 @@
   REFIID  riid,
   void**  ppvObject)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid), ppvObject);
 
   /*
@@ -530,11 +527,9 @@
 ULONG WINAPI OLEFontImpl_AddRef(
   IFont* iface)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(ref=%ld)\n", this, this->ref);
-  this->ref++;
-
-  return this->ref;
+  return InterlockedIncrement(&this->ref);
 }
 
 /************************************************************************
@@ -545,25 +540,21 @@
 ULONG WINAPI OLEFontImpl_Release(
       IFont* iface)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
+  ULONG ret;
   TRACE("(%p)->(ref=%ld)\n", this, this->ref);
 
   /*
    * Decrease the reference count on this object.
    */
-  this->ref--;
+  ret = InterlockedDecrement(&this->ref);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (this->ref==0)
-  {
-    OLEFontImpl_Destroy(this);
-
-    return 0;
-  }
+  if (ret==0) OLEFontImpl_Destroy(this);
 
-  return this->ref;
+  return ret;
 }
 
 /************************************************************************
@@ -575,7 +566,7 @@
   IFont*  iface,
   BSTR* pname)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pname);
   /*
    * Sanity check.
@@ -600,7 +591,7 @@
   IFont* iface,
   BSTR name)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, name);
 
   if (this->description.lpstrName==0)
@@ -635,7 +626,7 @@
   IFont* iface,
   CY*    psize)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, psize);
 
   /*
@@ -659,7 +650,7 @@
   IFont* iface,
   CY     size)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%ld)\n", this, size.s.Lo);
   this->description.cySize.s.Hi = 0;
   this->description.cySize.s.Lo = size.s.Lo;
@@ -677,7 +668,7 @@
   IFont*  iface,
   BOOL* pbold)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pbold);
   /*
    * Sanity check
@@ -699,7 +690,7 @@
   IFont* iface,
   BOOL bold)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, bold);
   this->description.sWeight = bold ? FW_BOLD : FW_NORMAL;
   OLEFont_SendNotify(this, DISPID_FONT_BOLD);
@@ -716,7 +707,7 @@
   IFont*  iface,
   BOOL* pitalic)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pitalic);
   /*
    * Sanity check
@@ -738,7 +729,7 @@
   IFont* iface,
   BOOL italic)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, italic);
 
   this->description.fItalic = italic;
@@ -756,7 +747,7 @@
   IFont*  iface,
   BOOL* punderline)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, punderline);
 
   /*
@@ -779,7 +770,7 @@
   IFont* iface,
   BOOL underline)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, underline);
 
   this->description.fUnderline = underline;
@@ -797,7 +788,7 @@
   IFont*  iface,
   BOOL* pstrikethrough)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pstrikethrough);
 
   /*
@@ -820,7 +811,7 @@
  IFont* iface,
  BOOL strikethrough)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, strikethrough);
 
   this->description.fStrikethrough = strikethrough;
@@ -838,7 +829,7 @@
   IFont* iface,
   short* pweight)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pweight);
 
   /*
@@ -861,7 +852,7 @@
   IFont* iface,
   short  weight)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, weight);
 
   this->description.sWeight = weight;
@@ -879,7 +870,7 @@
   IFont* iface,
   short* pcharset)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, pcharset);
 
   /*
@@ -902,7 +893,7 @@
   IFont* iface,
   short charset)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%d)\n", this, charset);
 
   this->description.sCharset = charset;
@@ -920,7 +911,7 @@
   IFont*   iface,
   HFONT* phfont)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, phfont);
   if (phfont==NULL)
     return E_POINTER;
@@ -980,7 +971,7 @@
   LOGFONTW logFont;
   INT      fontHeight;
   CY       cySize;
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p)\n", this, ppfont);
 
   if (ppfont == NULL)
@@ -1057,10 +1048,10 @@
  */
 static HRESULT WINAPI OLEFontImpl_SetRatio(
   IFont* iface,
-  long   cyLogical,
-  long   cyHimetric)
+  LONG   cyLogical,
+  LONG   cyHimetric)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%ld, %ld)\n", this, cyLogical, cyHimetric);
 
   this->cyLogical  = cyLogical;
@@ -1091,7 +1082,7 @@
   IFont*  iface,
   HFONT hfont)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
 
   if ( (hfont == 0) ||
@@ -1112,7 +1103,7 @@
   IFont*  iface,
   HFONT hfont)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
 
   if ( (hfont == 0) ||
@@ -1142,7 +1133,7 @@
   IFont* iface,
   HDC  hdc)
 {
-  _ICOM_THIS(OLEFontImpl, iface);
+  OLEFontImpl *this = (OLEFontImpl *)iface;
   FIXME("(%p)->(%p): Stub\n", this, hdc);
   return E_NOTIMPL;
 }
@@ -1214,12 +1205,12 @@
   LCID        lcid,
   ITypeInfo** ppTInfo)
 {
-  WCHAR stdole32tlb[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
+  static const WCHAR stdole32tlb[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
   ITypeLib *tl;
   HRESULT hres;
 
   _ICOM_THIS_From_IDispatch(OLEFontImpl, iface);
-  TRACE("(%p, iTInfo=%d, lcid=%04x, %p), unimplemented stub!\n", this, iTInfo, (int)lcid, ppTInfo);
+  TRACE("(%p, iTInfo=%d, lcid=%04x, %p)\n", this, iTInfo, (int)lcid, ppTInfo);
   if (iTInfo != 0)
     return E_FAIL;
   hres = LoadTypeLib(stdole32tlb, &tl);
@@ -1285,11 +1276,36 @@
       V_VT(pVarResult) = VT_BSTR;
       return OLEFontImpl_get_Name(this, &V_BSTR(pVarResult));
     case DISPATCH_PROPERTYPUT: {
-      BSTR name = V_BSTR(&pDispParams->rgvarg[0]);
-      if (V_VT(&pDispParams->rgvarg[0])!=VT_BSTR) {
-        FIXME("property put of Name, vt is not VT_BSTR but %d\n",V_VT(&pDispParams->rgvarg[0]));
-	return E_FAIL;
+      BSTR name;
+      BOOL freename;
+      
+      if (V_VT(&pDispParams->rgvarg[0]) == VT_DISPATCH) {
+        IFont *font;
+        HRESULT hr = S_OK;
+        
+        hr = IUnknown_QueryInterface(V_DISPATCH(&pDispParams->rgvarg[0]), &IID_IFont, (void **) &font);
+        if (FAILED(hr))
+        {
+            FIXME("dispatch value for name property is not an OleFont, returning hr=0x%lx\n", hr);
+            return hr;
+        }
+
+        hr = IFont_get_Name(font, &name); /* this allocates a new BSTR so free it later */
+        if (FAILED(hr)) return hr;
+
+        IUnknown_Release(font);
+        
+        freename = TRUE;
+      } else if (V_VT(&pDispParams->rgvarg[0]) == VT_BSTR) {
+        name = V_BSTR(&pDispParams->rgvarg[0]);
+        freename = FALSE;
+      } else {
+        FIXME("app is trying to set name property with a non BSTR, non dispatch value. returning E_FAIL\n");
+        return E_FAIL;
       }
+
+      TRACE("name is %s\n", debugstr_w(name));
+      
       if (!xthis->description.lpstrName)
 	xthis->description.lpstrName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1) * sizeof(WCHAR));
       else
@@ -1298,6 +1314,9 @@
       if (xthis->description.lpstrName==0)
 	return E_OUTOFMEMORY;
       strcpyW(xthis->description.lpstrName, name);
+
+      if (freename) SysFreeString(name);
+      
       return S_OK;
     }
     }
@@ -1841,8 +1860,132 @@
 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Load(
    IPersistPropertyBag *iface, IPropertyBag* pPropBag, IErrorLog* pErrorLog
 ) {
-  FIXME("(%p,%p,%p), stub!\n", iface, pPropBag, pErrorLog);
-  return E_FAIL;
+/* (from Visual Basic 6 property bag)
+         Name            =   "MS Sans Serif"
+         Size            =   13.8
+         Charset         =   0
+         Weight          =   400
+         Underline       =   0   'False
+         Italic          =   0   'False
+         Strikethrough   =   0   'False
+*/
+    static const WCHAR sAttrName[] = {'N','a','m','e',0};
+    static const WCHAR sAttrSize[] = {'S','i','z','e',0};
+    static const WCHAR sAttrCharset[] = {'C','h','a','r','s','e','t',0};
+    static const WCHAR sAttrWeight[] = {'W','e','i','g','h','t',0};
+    static const WCHAR sAttrUnderline[] = {'U','n','d','e','r','l','i','n','e',0};
+    static const WCHAR sAttrItalic[] = {'I','t','a','l','i','c',0};
+    static const WCHAR sAttrStrikethrough[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
+    VARIANT rawAttr;
+    VARIANT valueAttr;
+    HRESULT iRes = S_OK;
+    _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
+
+    VariantInit(&rawAttr);
+    VariantInit(&valueAttr);
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrName, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BSTR);
+            if (iRes == S_OK)
+                iRes = IFont_put_Name(this, V_BSTR(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrSize, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_CY);
+            if (iRes == S_OK)
+                iRes = IFont_put_Size(this, V_CY(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrCharset, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
+            if (iRes == S_OK)
+                iRes = IFont_put_Charset(this, V_I2(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrWeight, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
+            if (iRes == S_OK)
+                iRes = IFont_put_Weight(this, V_I2(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrUnderline, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
+            if (iRes == S_OK)
+                iRes = IFont_put_Underline(this, V_BOOL(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrItalic, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
+            if (iRes == S_OK)
+                iRes = IFont_put_Italic(this, V_BOOL(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (iRes == S_OK) {
+        iRes = IPropertyBag_Read(pPropBag, sAttrStrikethrough, &rawAttr, pErrorLog);
+        if (iRes == S_OK)
+        {
+            iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
+            if (iRes == S_OK)
+                IFont_put_Strikethrough(this, V_BOOL(&valueAttr));
+        }
+        else if (iRes == E_INVALIDARG)
+            iRes = S_OK;
+        VariantClear(&rawAttr);
+        VariantClear(&valueAttr);
+    }
+
+    if (FAILED(iRes))
+        WARN("-- 0x%08lx\n", iRes);
+    return iRes;
 }
 
 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Save(
@@ -1853,9 +1996,8 @@
   return E_FAIL;
 }
 
-static ICOM_VTABLE(IPersistPropertyBag) OLEFontImpl_IPersistPropertyBag_VTable = 
+static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable = 
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_IPersistPropertyBag_QueryInterface,
   OLEFontImpl_IPersistPropertyBag_AddRef,
   OLEFontImpl_IPersistPropertyBag_Release,
@@ -1932,9 +2074,8 @@
   return S_OK;
 }
 
-static ICOM_VTABLE(IPersistStreamInit) OLEFontImpl_IPersistStreamInit_VTable = 
+static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable = 
 {
-  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
   OLEFontImpl_IPersistStreamInit_QueryInterface,
   OLEFontImpl_IPersistStreamInit_AddRef,
   OLEFontImpl_IPersistStreamInit_Release,
@@ -1953,13 +2094,13 @@
 typedef struct
 {
     /* IUnknown fields */
-    ICOM_VFIELD(IClassFactory);
+    IClassFactoryVtbl          *lpVtbl;
     DWORD                       ref;
 } IClassFactoryImpl;
 
 static HRESULT WINAPI
 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
-	ICOM_THIS(IClassFactoryImpl,iface);
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
 
 	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
 	return E_NOINTERFACE;
@@ -1967,14 +2108,14 @@
 
 static ULONG WINAPI
 SFCF_AddRef(LPCLASSFACTORY iface) {
-	ICOM_THIS(IClassFactoryImpl,iface);
-	return ++(This->ref);
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+	return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
-	ICOM_THIS(IClassFactoryImpl,iface);
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
 	/* static class, won't be  freed */
-	return --(This->ref);
+	return InterlockedDecrement(&This->ref);
 }
 
 static HRESULT WINAPI SFCF_CreateInstance(
@@ -1985,13 +2126,12 @@
 }
 
 static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
-	ICOM_THIS(IClassFactoryImpl,iface);
+	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
 	FIXME("(%p)->(%d),stub!\n",This,dolock);
 	return S_OK;
 }
 
-static ICOM_VTABLE(IClassFactory) SFCF_Vtbl = {
-	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+static IClassFactoryVtbl SFCF_Vtbl = {
 	SFCF_QueryInterface,
 	SFCF_AddRef,
 	SFCF_Release,

reactos/lib/oleaut32
olepicture.c 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- olepicture.c	26 Sep 2004 14:34:22 -0000	1.3
+++ olepicture.c	8 Dec 2004 21:57:17 -0000	1.3.6.1
@@ -36,6 +36,7 @@
  */
 
 #include "config.h"
+#include "wine/port.h"
 
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
@@ -49,10 +50,18 @@
  */
 #ifdef HAVE_GIF_LIB_H
 # include <gif_lib.h>
+# ifndef SONAME_LIBUNGIF
+#  define SONAME_LIBUNGIF "libungif.so"
+# endif
+# ifndef SONAME_LIBGIF
+#  define SONAME_LIBGIF "libgif.so"
+# endif
 #endif
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
@@ -67,16 +76,17 @@
 #include "wine/wingdi16.h"
 #include "cursoricon.h"
 
-#ifdef HAVE_LIBJPEG
+#ifdef HAVE_JPEGLIB_H
 /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
 #define XMD_H
 #define UINT8 JPEG_UINT8
 #define UINT16 JPEG_UINT16
 #undef FAR
-#ifdef HAVE_JPEGLIB_H
 # include <jpeglib.h>
-#endif
 #undef UINT16
+#ifndef SONAME_LIBJPEG
+#define SONAME_LIBJPEG "libjpeg.so"
+#endif
 #endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
@@ -118,9 +128,16 @@
     BOOL keepOrigFormat;
     HDC	hDCCur;
 
+  /* Bitmap transparency mask */
+    HBITMAP hbmMask;
+    COLORREF rgbTrans;
+
   /* data */
     void* data;
     int datalen;
+    BOOL bIsDirty;                  /* Set to TRUE if picture has changed */
+    unsigned int loadtime_magic;    /* If a length header was found, saves value */
+    unsigned int loadtime_format;   /* for PICTYPE_BITMAP only, keeps track of image format (GIF/BMP/JPEG) */
 } OLEPictureImpl;
 
 /*
@@ -212,6 +229,11 @@
   /* dunno about original value */
   newObject->keepOrigFormat = TRUE;
 
+  newObject->hbmMask = NULL;
+  newObject->loadtime_magic = 0xdeadbeef;
+  newObject->loadtime_format = 0;
+  newObject->bIsDirty = FALSE;
+
   if (pictDesc) {
       if(pictDesc->cbSizeofstruct != sizeof(PICTDESC)) {
 	  FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
@@ -388,9 +410,7 @@
 {
   OLEPictureImpl *This = (OLEPictureImpl *)iface;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
-  This->ref++;
-
-  return This->ref;
+  return InterlockedIncrement(&This->ref);
 }
 
 /************************************************************************
@@ -402,24 +422,20 @@
       IPicture* iface)
 {
   OLEPictureImpl *This = (OLEPictureImpl *)iface;
+  ULONG ret;
   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
 
   /*
    * Decrease the reference count on this object.
    */
-  This->ref--;
+  ret = InterlockedDecrement(&This->ref);
 
   /*
    * If the reference count goes down to 0, perform suicide.
    */
-  if (This->ref==0)
-  {
-    OLEPictureImpl_Destroy(This);
+  if (ret==0) OLEPictureImpl_Destroy(This);
 
-    return 0;
-  }
-
-  return This->ref;
+  return ret;
 }
 
 
@@ -503,7 +519,7 @@
  * OLEPictureImpl_Render
  */
 static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc,
-					    long x, long y, long cx, long cy,
+					    LONG x, LONG y, LONG cx, LONG cy,
 					    OLE_XPOS_HIMETRIC xSrc,
 					    OLE_YPOS_HIMETRIC ySrc,
 					    OLE_XSIZE_HIMETRIC cxSrc,
@@ -541,7 +557,25 @@
 
       hbmpOld = SelectObject(hdcBmp, This->desc.u.bmp.hbitmap);
 
-      StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
+      if (This->hbmMask) {
+	  HDC hdcMask = CreateCompatibleDC(0);
+	  HBITMAP hOldbm = SelectObject(hdcMask, This->hbmMask);
+
+	  SetMapMode(hdcMask, MM_ANISOTROPIC);
+	  SetWindowOrgEx(hdcMask, 0, 0, NULL);
+	  SetWindowExtEx(hdcMask, This->himetricWidth, This->himetricHeight, NULL);
+	  SetViewportOrgEx(hdcMask, 0, This->origHeight, NULL);
+	  SetViewportExtEx(hdcMask, This->origWidth, -This->origHeight, NULL);
+	  
+	  SetBkColor(hdc, RGB(255, 255, 255));    
+	  SetTextColor(hdc, RGB(0, 0, 0));        
+	  StretchBlt(hdc, x, y, cx, cy, hdcMask, xSrc, ySrc, cxSrc, cySrc, SRCAND); 
+	  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCPAINT);
+
+	  SelectObject(hdcMask, hOldbm);
+	  DeleteDC(hdcMask);
+      } else
+	  StretchBlt(hdc, x, y, cx, cy, hdcBmp, xSrc, ySrc, cxSrc, cySrc, SRCCOPY);
 
       SelectObject(hdcBmp, hbmpOld);
       DeleteDC(hdcBmp);
@@ -645,6 +679,7 @@
   OLEPictureImpl *This = (OLEPictureImpl *)iface;
   TRACE("(%p)->()\n", This);
   OLEPicture_SendNotify(This,DISPID_PICT_HANDLE);
+  This->bIsDirty = TRUE;
   return S_OK;
 }
 
@@ -787,7 +822,7 @@
 {
   ICOM_THIS_From_IPersistStream(IPicture, iface);
   FIXME("(%p),stub!\n",This);
-  return E_NOTIMPL;
+  return E_FAIL;
 }
 
 /************************************************************************
@@ -801,7 +836,41 @@
   return E_NOTIMPL;
 }
 
-#ifdef HAVE_LIBJPEG
+#ifdef HAVE_JPEGLIB_H
+
+static void *libjpeg_handle;
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f
+MAKE_FUNCPTR(jpeg_std_error);
+MAKE_FUNCPTR(jpeg_CreateDecompress);
+MAKE_FUNCPTR(jpeg_read_header);
+MAKE_FUNCPTR(jpeg_start_decompress);
+MAKE_FUNCPTR(jpeg_read_scanlines);
+MAKE_FUNCPTR(jpeg_finish_decompress);
+MAKE_FUNCPTR(jpeg_destroy_decompress);
+#undef MAKE_FUNCPTR
+
+static void *load_libjpeg(void)
+{
+    if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
+
+#define LOAD_FUNCPTR(f) \
+    if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
+        libjpeg_handle = NULL; \
+        return NULL; \
+    }
+
+        LOAD_FUNCPTR(jpeg_std_error);
+        LOAD_FUNCPTR(jpeg_CreateDecompress);
+        LOAD_FUNCPTR(jpeg_read_header);
+        LOAD_FUNCPTR(jpeg_start_decompress);
+        LOAD_FUNCPTR(jpeg_read_scanlines);
+        LOAD_FUNCPTR(jpeg_finish_decompress);
+        LOAD_FUNCPTR(jpeg_destroy_decompress);
+#undef LOAD_FUNCPTR
+    }
+    return libjpeg_handle;
+}
+
 /* for the jpeg decompressor source manager. */
 static void _jpeg_init_source(j_decompress_ptr cinfo) { }
 
@@ -821,15 +890,43 @@
     return FALSE;
 }
 static void _jpeg_term_source(j_decompress_ptr cinfo) { }
-#endif /* HAVE_LIBJPEG */
+#endif /* HAVE_JPEGLIB_H */
+
+#ifdef HAVE_GIF_LIB_H
+
+static void *libungif_handle;
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f
+MAKE_FUNCPTR(DGifOpen);
+MAKE_FUNCPTR(DGifSlurp);
+MAKE_FUNCPTR(DGifCloseFile);
+#undef MAKE_FUNCPTR
 
-#ifdef HAVE_LIBGIF
 struct gifdata {
     unsigned char *data;
     unsigned int curoff;
     unsigned int len;
 };
 
+static void *load_libungif(void)
+{
+    if(((libungif_handle = wine_dlopen(SONAME_LIBUNGIF, RTLD_NOW, NULL, 0)) != NULL) ||
+       ((libungif_handle = wine_dlopen(SONAME_LIBGIF  , RTLD_NOW, NULL, 0)) != NULL)
+    ) {
+
+#define LOAD_FUNCPTR(f) \
+    if((p##f = wine_dlsym(libungif_handle, #f, NULL, 0)) == NULL) { \
+        libungif_handle = NULL; \
+        return NULL; \
+    }
+
+        LOAD_FUNCPTR(DGifOpen);
+        LOAD_FUNCPTR(DGifSlurp);
+        LOAD_FUNCPTR(DGifCloseFile);
+#undef LOAD_FUNCPTR
+    }
+    return libungif_handle;
+}
+
 static int _gif_inputfunc(GifFileType *gif, GifByteType *data, int len) {
     struct gifdata *gd = (struct gifdata*)gif->UserData;
 
@@ -841,7 +938,8 @@
     gd->curoff += len;
     return len;
 }
-#endif
+
+#endif  /* HAVE_GIF_LIB_H */
 
 /************************************************************************
  * OLEPictureImpl_IPersistStream_Load (IUnknown)
@@ -851,7 +949,7 @@
  * 	DWORD magic;
  * 	DWORD len;
  *
- * Currently implemented: BITMAP, ICON, JPEG.
+ * Currently implemented: BITMAP, ICON, JPEG, GIF
  */
 static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) {
   HRESULT	hr = E_FAIL;
@@ -866,6 +964,13 @@
 
   /* Sometimes we have a header, sometimes we don't. Apply some guesses to find
    * out whether we do.
+   *
+   * UPDATE: the IStream can be mapped to a plain file instead of a stream in a
+   * compound file. This may explain most, if not all, of the cases of "no header",
+   * and the header validation should take this into account. At least in Visual Basic 6,
+   * resource streams, valid headers are
+   *    header[0] == "lt\0\0",
+   *    header[1] == length_of_stream.
    */
   hr=IStream_Stat(pStm,&statstg,STATFLAG_NONAME);
   if (hr)
@@ -875,7 +980,10 @@
       FIXME("Failure while reading picture header (hr is %lx, nread is %ld).\n",hr,xread);
       return hr;
   }
-  if (header[1] > statstg.cbSize.QuadPart || (header[1]==0)) {/* Incorrect header, assume none. */
+  if (!memcmp(&(header[0]), "GIF8",     4) ||   /* GIF header */
+      !memcmp(&(header[0]), "BM",       2) ||   /* BMP header */
+      !memcmp(&(header[0]), "\xff\xd8", 2) ||   /* JPEG header */
+      header[1] > statstg.cbSize.QuadPart || (header[1]==0)) {/* Incorrect header, assume none. */
     xread = 8;
     xbuf = This->data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,statstg.cbSize.QuadPart);
     memcpy(xbuf,&header,8);
@@ -906,7 +1014,7 @@
   magic = xbuf[0] + (xbuf[1]<<8);
   switch (magic) {
   case 0x4947: { /* GIF */
-#ifdef HAVE_LIBGIF
+#ifdef HAVE_GIF_LIB_H
     struct gifdata 	gd;
     GifFileType 	*gif;
     BITMAPINFO		*bmi;
@@ -916,12 +1024,22 @@
     GifImageDesc        *gid;
     SavedImage          *si;
     ColorMapObject      *cm;
-    
+    int                 transparent = -1;
+    ExtensionBlock      *eb;
+    int                 padding;
+
+    if(!libungif_handle) {
+        if(!load_libungif()) {
+            FIXME("Failed reading GIF because unable to find %s/%s\n", SONAME_LIBUNGIF, SONAME_LIBGIF);
+            return E_FAIL;
+        }
+    }
+
     gd.data   = xbuf;
     gd.curoff = 0;
     gd.len    = xread;
-    gif = DGifOpen((void*)&gd, _gif_inputfunc);
-    ret = DGifSlurp(gif);
+    gif = pDGifOpen((void*)&gd, _gif_inputfunc);
+    ret = pDGifSlurp(gif);
     if (ret == GIF_ERROR) {
       FIXME("Failed reading GIF using libgif.\n");
       return E_FAIL;
@@ -939,28 +1057,69 @@
       gif->Image.Interlace
     );
     /* */
+    padding = (gif->SWidth+3) & ~3;
     bmi  = HeapAlloc(GetProcessHeap(),0,sizeof(BITMAPINFOHEADER)+(1<<gif->SColorResolution)*sizeof(RGBQUAD));
-    bytes= HeapAlloc(GetProcessHeap(),0,gif->SWidth*gif->SHeight);
+    bytes= HeapAlloc(GetProcessHeap(),0,padding*gif->SHeight);
     si   = gif->SavedImages+0;
     gid  = &(si->ImageDesc);
     cm   = gid->ColorMap;
     if (!cm) cm = gif->SColorMap;
+    
+    /* look for the transparent color extension */
+    for (i = 0; i < si->ExtensionBlockCount; ++i) {
+	eb = si->ExtensionBlocks + i;
+	if (eb->Function == 0xF9 && eb->ByteCount == 4) {
+	    if ((eb->Bytes[0] & 1) == 1) {
+		transparent = eb->Bytes[3];
+	    }
+	}
+    }
+
     for (i=0;i<(1<<gif->SColorResolution);i++) {
       bmi->bmiColors[i].rgbRed = cm->Colors[i].Red;
       bmi->bmiColors[i].rgbGreen = cm->Colors[i].Green;
       bmi->bmiColors[i].rgbBlue = cm->Colors[i].Blue;
+      if (i == transparent) {
+	  This->rgbTrans = RGB(bmi->bmiColors[i].rgbRed,
+			       bmi->bmiColors[i].rgbGreen,
+			       bmi->bmiColors[i].rgbBlue);
+      }
     }
+
     /* Map to in picture coordinates */
-    for (i=0;i<gid->Height;i++)
-      for (j=0;j<gid->Width;j++)
-        bytes[(gid->Top+i)*gif->SWidth+gid->Left+j]=si->RasterBits[i*gid->Width+j];
+    for (i = 0, j = 0; i < gid->Height; i++) {
+        if (gif->Image.Interlace) {
+            memcpy(
+                bytes + (gid->Top + j) * padding + gid->Left,
+                si->RasterBits + i * gid->Width,
+                gid->Width);
+
+            /* Lower bits of interlaced counter encode current interlace */
+            if (j & 1) j += 2;      /* Currently filling odd rows */
+            else if (j & 2) j += 4; /* Currently filling even rows not multiples of 4 */
+            else j += 8;            /* Currently filling every 8th row or 4th row in-between */
+
+            if (j >= gid->Height && i < gid->Height && (j & 1) == 0) {
+                /* End of current interlace, go to next interlace */
+                if (j & 2) j = 1;       /* Next iteration fills odd rows */
+                else if (j & 4) j = 2;  /* Next iteration fills even rows not mod 4 and not mod 8 */
+                else j = 4;             /* Next iteration fills rows in-between rows mod 6 */
+            }
+        } else {
+            memcpy(
+                bytes + (gid->Top + i) * padding + gid->Left,
+                si->RasterBits + i * gid->Width,
+                gid->Width);
+        }
+    }
+
     bmi->bmiHeader.biSize		= sizeof(BITMAPINFOHEADER);
     bmi->bmiHeader.biWidth		= gif->SWidth;
-    bmi->bmiHeader.biHeight		= gif->SHeight;
+    bmi->bmiHeader.biHeight		= -gif->SHeight;
     bmi->bmiHeader.biPlanes		= 1;
     bmi->bmiHeader.biBitCount		= 8;
     bmi->bmiHeader.biCompression	= BI_RGB;
-    bmi->bmiHeader.biSizeImage		= gif->SWidth*gif->SHeight;
+    bmi->bmiHeader.biSizeImage		= padding*gif->SHeight;
     bmi->bmiHeader.biXPelsPerMeter	= 0;
     bmi->bmiHeader.biYPelsPerMeter	= 0;
     bmi->bmiHeader.biClrUsed		= 1 << gif->SColorResolution;
@@ -973,12 +1132,40 @@
 	    CBM_INIT,
 	    bytes,
 	    bmi,
-	    DIB_PAL_COLORS
+	    DIB_RGB_COLORS
     );
+
+    if (transparent > -1) {
+	/* Create the Mask */
+	HDC hdc = CreateCompatibleDC(0);
+	HDC hdcMask = CreateCompatibleDC(0);
+	HBITMAP hOldbitmap; 
+	HBITMAP hOldbitmapmask;
+
+	This->hbmMask = CreateBitmap(bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, 1, 1, NULL);
+
+	hOldbitmap = SelectObject(hdc,This->desc.u.bmp.hbitmap); 
+	hOldbitmapmask = SelectObject(hdcMask, This->hbmMask);
+	SetBkColor(hdc, This->rgbTrans);
+	BitBlt(hdcMask, 0, 0, bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, hdc, 0, 0, SRCCOPY);
+
+	/* We no longer need the original bitmap, so we apply the first
+	   transformation with the mask to speed up the rendering */
+	SetBkColor(hdc, RGB(0,0,0));
+	SetTextColor(hdc, RGB(255,255,255));
+	BitBlt(hdc, 0, 0, bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, 
+		 hdcMask, 0, 0,  SRCAND);
+
+	SelectObject(hdc, hOldbitmap);
+	SelectObject(hdcMask, hOldbitmapmask);
+	DeleteDC(hdcMask);
+	DeleteDC(hdc);
+    }
+    
     DeleteDC(hdcref);
     This->desc.picType = PICTYPE_BITMAP;
     OLEPictureImpl_SetBitmap(This);
-    DGifCloseFile(gif);
+    pDGifCloseFile(gif);
     HeapFree(GetProcessHeap(),0,bytes);
     return S_OK;
 #else
@@ -988,7 +1175,7 @@
     break;
   }
   case 0xd8ff: { /* JPEG */
-#ifdef HAVE_LIBJPEG
+#ifdef HAVE_JPEGLIB_H
     struct jpeg_decompress_struct	jd;
     struct jpeg_error_mgr		jerr;
     int					ret;
@@ -999,7 +1186,14 @@
     HDC					hdcref;
     struct jpeg_source_mgr		xjsm;
     LPBYTE                              oldbits;
-    int i;
+    unsigned int i;
+
+    if(!libjpeg_handle) {
+        if(!load_libjpeg()) {
+            FIXME("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG);
+            return E_FAIL;
+        }
+    }
 
     /* This is basically so we can use in-memory data for jpeg decompression.
      * We need to have all the functions.
@@ -1012,12 +1206,14 @@
     xjsm.resync_to_restart	= _jpeg_resync_to_restart;
     xjsm.term_source		= _jpeg_term_source;
 
-    jd.err = jpeg_std_error(&jerr);
-    jpeg_create_decompress(&jd);
+    jd.err = pjpeg_std_error(&jerr);
+    /* jpeg_create_decompress is a macro that expands to jpeg_CreateDecompress - see jpeglib.h
+     * jpeg_create_decompress(&jd); */
+    pjpeg_CreateDecompress(&jd, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct));
     jd.src = &xjsm;
-    ret=jpeg_read_header(&jd,TRUE);
+    ret=pjpeg_read_header(&jd,TRUE);
     jd.out_color_space = JCS_RGB;
-    jpeg_start_decompress(&jd);
+    pjpeg_start_decompress(&jd);
     if (ret != JPEG_HEADER_OK) {
 	ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
 	HeapFree(GetProcessHeap(),0,xbuf);
@@ -1031,7 +1227,7 @@
     oldbits = bits;
     oldsamprow = samprow;
     while ( jd.output_scanline<jd.output_height ) {
-      x = jpeg_read_scanlines(&jd,&samprow,1);
+      x = pjpeg_read_scanlines(&jd,&samprow,1);
       if (x != 1) {
 	FIXME("failed to read current scanline?\n");
 	break;
@@ -1060,8 +1256,8 @@
     bmi.biClrImportant	= 0;
 
     HeapFree(GetProcessHeap(),0,samprow);
-    jpeg_finish_decompress(&jd);
-    jpeg_destroy_decompress(&jd);
+    pjpeg_finish_decompress(&jd);
+    pjpeg_destroy_decompress(&jd);
     hdcref = GetDC(0);
     This->desc.u.bmp.hbitmap=CreateDIBitmap(
 	    hdcref,
@@ -1097,7 +1293,7 @@
 	CBM_INIT,
 	xbuf+bfh->bfOffBits,
 	bi,
-	(bi->bmiHeader.biBitCount<=8)?DIB_PAL_COLORS:DIB_RGB_COLORS
+       DIB_RGB_COLORS
     );
     DeleteDC(hdcref);
     This->desc.picType = PICTYPE_BITMAP;
@@ -1108,6 +1304,7 @@
   case 0x0000: { /* ICON , first word is dwReserved */
     HICON hicon;
     CURSORICONFILEDIR	*cifd = (CURSORICONFILEDIR*)xbuf;
+    HDC hdcRef;
     int	i;
 
     /*
@@ -1153,15 +1350,19 @@
     } else {
 	This->desc.picType = PICTYPE_ICON;
 	This->desc.u.icon.hicon = hicon;
-	This->himetricWidth = cifd->idEntries[i].bWidth;
-	This->himetricHeight = cifd->idEntries[i].bHeight;
+	This->origWidth = cifd->idEntries[i].bWidth;
+	This->origHeight = cifd->idEntries[i].bHeight;
+	hdcRef = CreateCompatibleDC(0);
+	This->himetricWidth =(cifd->idEntries[i].bWidth *2540)/GetDeviceCaps(hdcRef, LOGPIXELSX);
+	This->himetricHeight=(cifd->idEntries[i].bHeight*2540)/GetDeviceCaps(hdcRef, LOGPIXELSY);
+	DeleteDC(hdcRef);
 	hr = S_OK;
     }
     break;
   }
   default:
   {
-    int i;
+    unsigned int i;
     FIXME("Unknown magic %04x, %ld read bytes:\n",magic,xread);
     hr=E_FAIL;
     for (i=0;i<xread+8;i++) {
@@ -1173,6 +1374,7 @@
     break;
   }
   }
+  This->bIsDirty = FALSE;
 
   /* FIXME: this notify is not really documented */
   if (hr==S_OK)
@@ -1180,12 +1382,324 @@
   return hr;
 }
 
+static int serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength);
+static int serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLength);
 static HRESULT WINAPI OLEPictureImpl_Save(
   IPersistStream* iface,IStream*pStm,BOOL fClearDirty)
 {
-  ICOM_THIS_From_IPersistStream(IPicture, iface);
-  FIXME("(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
-  return E_NOTIMPL;
+    HRESULT hResult = E_NOTIMPL;
+    void * pIconData;
+    unsigned int iDataSize;
+    ULONG dummy;
+    int iSerializeResult = 0;
+
+  ICOM_THIS_From_IPersistStream(OLEPictureImpl, iface);
+
+    switch (This->desc.picType) {
+    case PICTYPE_ICON:
+        if (This->bIsDirty) {
+            if (serializeIcon(This->desc.u.icon.hicon, &pIconData, &iDataSize)) {
+                if (This->loadtime_magic != 0xdeadbeef) {
+                    DWORD header[2];
+
+                    header[0] = This->loadtime_magic;
+                    header[1] = iDataSize;
+                    IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
+                }
+                IStream_Write(pStm, pIconData, iDataSize, &dummy);
+
+                HeapFree(GetProcessHeap(), 0, This->data);
+                This->data = pIconData;
+                This->datalen = iDataSize;
+                hResult = S_OK;
+            } else {
+                FIXME("(%p,%p,%d), unable to serializeIcon()!\n",This,pStm,fClearDirty);
+                hResult = E_FAIL;
+            }
+        } else {
+            if (This->loadtime_magic != 0xdeadbeef) {
+                DWORD header[2];
+
+                header[0] = This->loadtime_magic;
+                header[1] = This->datalen;
+                IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
+            }
+            IStream_Write(pStm, This->data, This->datalen, &dummy);
+            hResult = S_OK;
+        }
+        break;
+    case PICTYPE_BITMAP:
+        if (This->bIsDirty) {
+            switch (This->keepOrigFormat ? This->loadtime_format : 0x4d42) {
+            case 0x4d42:
+                iSerializeResult = serializeBMP(This->desc.u.bmp.hbitmap, &pIconData, &iDataSize);
+                break;
+            case 0xd8ff:
+                FIXME("(%p,%p,%d), PICTYPE_BITMAP (format JPEG) not implemented!\n",This,pStm,fClearDirty);
+                break;
+            case 0x4947:
+                FIXME("(%p,%p,%d), PICTYPE_BITMAP (format GIF) not implemented!\n",This,pStm,fClearDirty);
+                break;
+            default:
+                FIXME("(%p,%p,%d), PICTYPE_BITMAP (format UNKNOWN, using BMP?) not implemented!\n",This,pStm,fClearDirty);
+                break;
+            }
+            if (iSerializeResult) {
+                /*
+                if (This->loadtime_magic != 0xdeadbeef) {
+                */
+                if (1) {
+                    DWORD header[2];
+
+                    header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
+                    header[1] = iDataSize;
+                    IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
+                }
+                IStream_Write(pStm, pIconData, iDataSize, &dummy);
+
+                HeapFree(GetProcessHeap(), 0, This->data);
+                This->data = pIconData;
+                This->datalen = iDataSize;
+                hResult = S_OK;
+            }
+        } else {
+            /*
+            if (This->loadtime_magic != 0xdeadbeef) {
+            */
+            if (1) {
+                DWORD header[2];
+
+                header[0] = (This->loadtime_magic != 0xdeadbeef) ? This->loadtime_magic : 0x0000746c;
+                header[1] = This->datalen;
+                IStream_Write(pStm, header, 2 * sizeof(DWORD), &dummy);
+            }
+            IStream_Write(pStm, This->data, This->datalen, &dummy);
+            hResult = S_OK;
+        }
+        break;
+    case PICTYPE_METAFILE:
+        FIXME("(%p,%p,%d), PICTYPE_METAFILE not implemented!\n",This,pStm,fClearDirty);
+        break;
+    case PICTYPE_ENHMETAFILE:
+        FIXME("(%p,%p,%d),PICTYPE_ENHMETAFILE not implemented!\n",This,pStm,fClearDirty);
+        break;
+    default:
+        FIXME("(%p,%p,%d), [unknown type] not implemented!\n",This,pStm,fClearDirty);
+        break;
+    }
+    if (hResult == S_OK && fClearDirty) This->bIsDirty = FALSE;
+    return hResult;
+}
+
+static int serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLength)
+{
+    int iSuccess = 0;
+    HDC hDC;
+    BITMAPINFO * pInfoBitmap;
+    int iNumPaletteEntries;
+    unsigned char * pPixelData;
+    BITMAPFILEHEADER * pFileHeader;
+    BITMAPINFO * pInfoHeader;
+
+    pInfoBitmap = (BITMAPINFO *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+        sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+
+    /* Find out bitmap size and padded length */
+    hDC = GetDC(0);
+    pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
+    GetDIBits(hDC, hBitmap, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
+
+    /* Fetch bitmap palette & pixel data */
+
+    pPixelData = (unsigned char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+        pInfoBitmap->bmiHeader.biSizeImage);
+    GetDIBits(hDC, hBitmap, 0, pInfoBitmap->bmiHeader.biHeight, pPixelData, pInfoBitmap, DIB_RGB_COLORS);
+
+    /* Calculate the total length required for the BMP data */
+    if (pInfoBitmap->bmiHeader.biClrUsed != 0) iNumPaletteEntries = pInfoBitmap->bmiHeader.biClrUsed;
+    else if (pInfoBitmap->bmiHeader.biBitCount <= 8) iNumPaletteEntries = 1 << pInfoBitmap->bmiHeader.biBitCount;
+    else iNumPaletteEntries = 0;
+    *pLength =
+        sizeof(BITMAPFILEHEADER) +
+        sizeof(BITMAPINFOHEADER) +
+        iNumPaletteEntries * sizeof(RGBQUAD) +
+        pInfoBitmap->bmiHeader.biSizeImage;
+    *ppBuffer = (void *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *pLength);
+
+    /* Fill the BITMAPFILEHEADER */
+    pFileHeader = (BITMAPFILEHEADER *)(*ppBuffer);
+    pFileHeader->bfType = 0x4d42;
+    pFileHeader->bfSize = *pLength;
+    pFileHeader->bfOffBits =
+        sizeof(BITMAPFILEHEADER) +
+        sizeof(BITMAPINFOHEADER) +
+        iNumPaletteEntries * sizeof(RGBQUAD);
+
+    /* Fill the BITMAPINFOHEADER and the palette data */
+    pInfoHeader = (BITMAPINFO *)((unsigned char *)(*ppBuffer) + sizeof(BITMAPFILEHEADER));
+    memcpy(pInfoHeader, pInfoBitmap, sizeof(BITMAPINFOHEADER) + iNumPaletteEntries * sizeof(RGBQUAD));
+    memcpy(
+        (unsigned char *)(*ppBuffer) +
+            sizeof(BITMAPFILEHEADER) +
+            sizeof(BITMAPINFOHEADER) +
+            iNumPaletteEntries * sizeof(RGBQUAD),
+        pPixelData, pInfoBitmap->bmiHeader.biSizeImage);
+    iSuccess = 1;
+
+    HeapFree(GetProcessHeap(), 0, pPixelData);
+    HeapFree(GetProcessHeap(), 0, pInfoBitmap);
+    return iSuccess;
+}
+
+static int serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
+{
+	ICONINFO infoIcon;
+	int iSuccess = 0;
+
+	*ppBuffer = NULL; *pLength = 0;
+	if (GetIconInfo(hIcon, &infoIcon)) {
+		HDC hDC;
+		BITMAPINFO * pInfoBitmap;
+		unsigned char * pIconData = NULL;
+		unsigned int iDataSize = 0;
+
+        pInfoBitmap = (BITMAPINFO *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+
+		/* Find out icon size */
+		hDC = GetDC(0);
+		pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
+		GetDIBits(hDC, infoIcon.hbmColor, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
+		if (1) {
+			/* Auxiliary pointers */
+			CURSORICONFILEDIR * pIconDir;
+			CURSORICONFILEDIRENTRY * pIconEntry;
+			BITMAPINFOHEADER * pIconBitmapHeader;
+			unsigned int iOffsetPalette;
+			unsigned int iOffsetColorData;
+			unsigned int iOffsetMaskData;
+
+			unsigned int iLengthScanLineColor;
+			unsigned int iLengthScanLineMask;
+			unsigned int iNumEntriesPalette;
+
+			iLengthScanLineMask = ((pInfoBitmap->bmiHeader.biWidth + 31) >> 5) << 2;
+			iLengthScanLineColor = ((pInfoBitmap->bmiHeader.biWidth * pInfoBitmap->bmiHeader.biBitCount + 31) >> 5) << 2;
+/*
+			FIXME("DEBUG: bitmap size is %d x %d\n",
+				pInfoBitmap->bmiHeader.biWidth,
+				pInfoBitmap->bmiHeader.biHeight);
+			FIXME("DEBUG: bitmap bpp is %d\n",
+				pInfoBitmap->bmiHeader.biBitCount);
+			FIXME("DEBUG: bitmap nplanes is %d\n",
+				pInfoBitmap->bmiHeader.biPlanes);
+			FIXME("DEBUG: bitmap biSizeImage is %lu\n",
+				pInfoBitmap->bmiHeader.biSizeImage);
+*/
+			/* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */
+			iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER);
+			pIconData = (unsigned char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iDataSize);
+
+			/* Fill out the CURSORICONFILEDIR */
+			pIconDir = (CURSORICONFILEDIR *)pIconData;
+			pIconDir->idType = 1;
+			pIconDir->idCount = 1;
+
+			/* Fill out the CURSORICONFILEDIRENTRY */
+			pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
+			pIconEntry->bWidth = (unsigned char)pInfoBitmap->bmiHeader.biWidth;
+			pIconEntry->bHeight = (unsigned char)pInfoBitmap->bmiHeader.biHeight;
+			pIconEntry->bColorCount =
+				(pInfoBitmap->bmiHeader.biBitCount < 8)
+				? 1 << pInfoBitmap->bmiHeader.biBitCount
+				: 0;
+			pIconEntry->xHotspot = pInfoBitmap->bmiHeader.biPlanes;
+			pIconEntry->yHotspot = pInfoBitmap->bmiHeader.biBitCount;
+			pIconEntry->dwDIBSize = 0;
+			pIconEntry->dwDIBOffset = 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY);
+
+			/* Fill out the BITMAPINFOHEADER */
+			pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
+			memcpy(pIconBitmapHeader, &pInfoBitmap->bmiHeader, sizeof(BITMAPINFOHEADER));
+
+			/*	Find out whether a palette exists for the bitmap */
+			if (	(pInfoBitmap->bmiHeader.biBitCount == 16 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)
+				||	(pInfoBitmap->bmiHeader.biBitCount == 24)
+				||	(pInfoBitmap->bmiHeader.biBitCount == 32 && pInfoBitmap->bmiHeader.biCompression == BI_RGB)) {
+				iNumEntriesPalette = pInfoBitmap->bmiHeader.biClrUsed;
+			} else if ((pInfoBitmap->bmiHeader.biBitCount == 16 || pInfoBitmap->bmiHeader.biBitCount == 32)
+				&& pInfoBitmap->bmiHeader.biCompression == BI_BITFIELDS) {
+				iNumEntriesPalette = 3;
+			} else if (pInfoBitmap->bmiHeader.biBitCount <= 8) {
+				iNumEntriesPalette = 1 << pInfoBitmap->bmiHeader.biBitCount;
+			} else {
+				iNumEntriesPalette = 0;
+			}
+
+			/*  Add bitmap size and header size to icon data size. */
+			iOffsetPalette = iDataSize;
+			iDataSize += iNumEntriesPalette * sizeof(DWORD);
+			iOffsetColorData = iDataSize;
+			iDataSize += pIconBitmapHeader->biSizeImage;
+			iOffsetMaskData = iDataSize;
+			iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask;
+			pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask;
+			pIconBitmapHeader->biHeight *= 2;
+			pIconData = (unsigned char *)HeapReAlloc(GetProcessHeap(), 0, pIconData, iDataSize);
+			pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
+			pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
+			pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
+
+			/* Get the actual bitmap data from the icon bitmap */
+			GetDIBits(hDC, infoIcon.hbmColor, 0, pInfoBitmap->bmiHeader.biHeight,
+				pIconData + iOffsetColorData, pInfoBitmap, DIB_RGB_COLORS);
+			if (iNumEntriesPalette > 0) {
+				memcpy(pIconData + iOffsetPalette, pInfoBitmap->bmiColors,
+					iNumEntriesPalette * sizeof(RGBQUAD));
+			}
+
+			/* Reset all values so that GetDIBits call succeeds */
+			memset(pIconData + iOffsetMaskData, 0, iDataSize - iOffsetMaskData);
+			memset(pInfoBitmap, 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+			pInfoBitmap->bmiHeader.biSize = sizeof(pInfoBitmap->bmiHeader);
+/*
+            if (!(GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS)
+				&& GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight,
+					pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS))) {
+
+                printf("ERROR: unable to get bitmap mask (error %lu)\n",
+					GetLastError());
+
+			}
+*/
+            GetDIBits(hDC, infoIcon.hbmMask, 0, 0, NULL, pInfoBitmap, DIB_RGB_COLORS);
+            GetDIBits(hDC, infoIcon.hbmMask, 0, pIconEntry->bHeight, pIconData + iOffsetMaskData, pInfoBitmap, DIB_RGB_COLORS);
+
+			/* Write out everything produced so far to the stream */
+			*ppBuffer = pIconData; *pLength = iDataSize;
+			iSuccess = 1;
+		} else {
+/*
+			printf("ERROR: unable to get bitmap information via GetDIBits() (error %lu)\n",
+				GetLastError());
+*/
+		}
+		/*
+			Remarks (from MSDN entry on GetIconInfo):
+
+			GetIconInfo creates bitmaps for the hbmMask and hbmColor
+			members of ICONINFO. The calling application must manage
+			these bitmaps and delete them when they are no longer
+			necessary.
+		 */
+		if (hDC) ReleaseDC(0, hDC);
+		DeleteObject(infoIcon.hbmMask);
+		if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
+		HeapFree(GetProcessHeap(), 0, pInfoBitmap);
+	} else {
+		printf("ERROR: Unable to get icon information (error %lu)\n",
+			GetLastError());
+	}
+	return iSuccess;
 }
 
 static HRESULT WINAPI OLEPictureImpl_GetSizeMax(
@@ -1493,13 +2007,13 @@
 static ULONG WINAPI
 SPCF_AddRef(LPCLASSFACTORY iface) {
 	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
-	return ++(This->ref);
+	return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) {
 	IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
 	/* static class, won't be  freed */
-	return --(This->ref);
+	return InterlockedDecrement(&This->ref);
 }
 
 static HRESULT WINAPI SPCF_CreateInstance(

reactos/lib/oleaut32
safearray.c 1.6 -> 1.6.20.1
diff -u -r1.6 -r1.6.20.1
--- safearray.c	1 Mar 2004 22:12:57 -0000	1.6
+++ safearray.c	8 Dec 2004 21:57:17 -0000	1.6.20.1
@@ -36,15 +36,16 @@
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
+
+#define COBJMACROS
+
 #include "windef.h"
 #include "winerror.h"
 #include "winbase.h"
-#include "oleauto.h"
-#include "wine/debug.h"
 #include "variant.h"
+#include "wine/debug.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
-
+WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
 /************************************************************************
  * SafeArray {OLEAUT32}
@@ -61,8 +62,8 @@
  * using the IRecordInfo interface.
  *
  * There are two types of SafeArray, normal and vectors. Normal arrays can have
- * multiple dimensions and the data for the array is allocated seperately from
- * the array header. This is the most flexable type of array. Vectors, on the
+ * multiple dimensions and the data for the array is allocated separately from
+ * the array header. This is the most flexible type of array. Vectors, on the
  * other hand, are fixed in size and consist of a single allocated block, and a
  * single dimension.
  *
@@ -341,7 +342,9 @@
 
       while(ulCellCount--)
       {
-        VariantClear(lpVariant);
+        HRESULT hRet = VariantClear(lpVariant);
+
+        if (FAILED(hRet)) FIXME("VariantClear of element failed!\n");
         lpVariant++;
       }
     }
@@ -368,7 +371,10 @@
 
       while(ulCellCount--)
       {
-        VariantCopy(lpDest, lpVariant);
+        HRESULT hRet;
+
+        hRet = VariantCopy(lpDest, lpVariant);
+        if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
         lpVariant++;
         lpDest++;
       }
@@ -873,8 +879,10 @@
         VARIANT* lpVariant = (VARIANT*)pvData;
         VARIANT* lpDest = (VARIANT*)lpvDest;
 
-        VariantClear(lpDest);
-        VariantCopy(lpDest, lpVariant);
+        hRet = VariantClear(lpDest);
+        if (FAILED(hRet)) FIXME("VariantClear failed with 0x%lx\n", hRet);
+        hRet = VariantCopy(lpDest, lpVariant);
+        if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
       }
       else if (psa->fFeatures & FADF_BSTR)
       {
@@ -958,7 +966,10 @@
         VARIANT* lpVariant = (VARIANT*)lpvSrc;
         VARIANT* lpDest = (VARIANT*)pvData;
 
-        VariantCopy(lpDest, lpVariant);
+        /* The original content of pvData is ignored. */
+        V_VT(lpDest) = VT_EMPTY;
+        hRet = VariantCopy(lpDest, lpVariant);
+	if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
       }
       else if (psa->fFeatures & FADF_BSTR)
       {
@@ -1241,9 +1252,10 @@
     return E_INVALIDARG;
 
   if (psa->cLocks)
-    return DISP_E_ARRAYISLOCKED; /* Cant delete a locked array */
+    return DISP_E_ARRAYISLOCKED; /* Can't delete a locked array */
 
-  if (psa->pvData)
+  /* If static, keep pvData and don't free */
+  if (psa->pvData && !(psa->fFeatures & FADF_STATIC))
   {
     /* Delete the actual item data */
     if (FAILED(SAFEARRAY_DestroyData(psa, 0)))

reactos/lib/oleaut32
tmarshal.c 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- tmarshal.c	26 Sep 2004 14:34:22 -0000	1.2
+++ tmarshal.c	8 Dec 2004 21:57:17 -0000	1.2.6.1
@@ -3,6 +3,9 @@
  *
  *	Copyright 2002	Marcus Meissner
  *
+ * The olerelay debug channel allows you to see calls marshalled by
+ * the typelib marshaller. It is not a generic COM relaying system.
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -27,8 +30,10 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
@@ -50,6 +55,8 @@
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 WINE_DECLARE_DEBUG_CHANNEL(olerelay);
 
+#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
+
 typedef struct _marshal_state {
     LPBYTE	base;
     int		size;
@@ -59,6 +66,14 @@
     IID		iid;	/* HACK: for VT_VOID */
 } marshal_state;
 
+/* used in the olerelay code to avoid having the L"" stuff added by debugstr_w */
+static char *relaystr(WCHAR *in) {
+    char *tmp = (char *)debugstr_w(in);
+    tmp += 2;
+    tmp[strlen(tmp)-1] = '\0';
+    return tmp;
+}
+
 static HRESULT
 xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) {
     while (buf->size - buf->curoff < size) {
@@ -274,6 +289,8 @@
     /*NOTREACHED*/
 }
 
+#ifdef __i386__
+
 #include "pshpack1.h"
 
 typedef struct _TMAsmProxy {
@@ -289,74 +306,99 @@
 
 #include "poppack.h"
 
+#else /* __i386__ */
+# error You need to implement stubless proxies for your architecture
+#endif
+
 typedef struct _TMProxyImpl {
-    DWORD				*lpvtbl;
+    LPVOID				*lpvtbl;
     IRpcProxyBufferVtbl	*lpvtbl2;
-    DWORD				ref;
+    ULONG				ref;
 
     TMAsmProxy				*asmstubs;
     ITypeInfo*				tinfo;
     IRpcChannelBuffer*			chanbuf;
     IID					iid;
+    CRITICAL_SECTION	crit;
 } TMProxyImpl;
 
 static HRESULT WINAPI
-TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface, REFIID riid, LPVOID *ppv) {
+TMProxyImpl_QueryInterface(LPRPCPROXYBUFFER iface, REFIID riid, LPVOID *ppv)
+{
     TRACE("()\n");
     if (IsEqualIID(riid,&IID_IUnknown)||IsEqualIID(riid,&IID_IRpcProxyBuffer)) {
-	*ppv = (LPVOID)iface;
-	IRpcProxyBuffer_AddRef(iface);
-	return S_OK;
+        *ppv = (LPVOID)iface;
+        IRpcProxyBuffer_AddRef(iface);
+        return S_OK;
     }
     FIXME("no interface for %s\n",debugstr_guid(riid));
     return E_NOINTERFACE;
 }
 
 static ULONG WINAPI
-TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface) {
+TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface)
+{
     ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
 
     TRACE("()\n");
-    This->ref++;
-    return This->ref;
+
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI
-TMProxyImpl_Release(LPRPCPROXYBUFFER iface) {
+TMProxyImpl_Release(LPRPCPROXYBUFFER iface)
+{
+    ULONG refs;
     ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
 
     TRACE("()\n");
-    This->ref--;
-    if (This->ref) return This->ref;
-    if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
-    HeapFree(GetProcessHeap(),0,This);
-    return 0;
+
+    refs = InterlockedDecrement(&This->ref);
+    if (!refs)
+    {
+        DeleteCriticalSection(&This->crit);
+        if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf);
+        VirtualFree(This->asmstubs, 0, MEM_RELEASE);
+        CoTaskMemFree(This);
+    }
+    return refs;
 }
 
 static HRESULT WINAPI
 TMProxyImpl_Connect(
-    LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer
-) {
-    ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
+    LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer)
+{
+    ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
+
+    TRACE("(%p)\n", pRpcChannelBuffer);
+
+    EnterCriticalSection(&This->crit);
 
-    TRACE("(%p)\n",pRpcChannelBuffer);
+    IRpcChannelBuffer_AddRef(pRpcChannelBuffer);
     This->chanbuf = pRpcChannelBuffer;
-    IRpcChannelBuffer_AddRef(This->chanbuf);
+
+    LeaveCriticalSection(&This->crit);
+
     return S_OK;
 }
 
 static void WINAPI
-TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface) {
-    ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface);
+TMProxyImpl_Disconnect(LPRPCPROXYBUFFER iface)
+{
+    ICOM_THIS_MULTI(TMProxyImpl, lpvtbl2, iface);
+
+    TRACE("()\n");
+
+    EnterCriticalSection(&This->crit);
 
-    FIXME("()\n");
     IRpcChannelBuffer_Release(This->chanbuf);
     This->chanbuf = NULL;
+
+    LeaveCriticalSection(&This->crit);
 }
 
 
-static ICOM_VTABLE(IRpcProxyBuffer) tmproxyvtable = {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+static IRpcProxyBufferVtbl tmproxyvtable = {
     TMProxyImpl_QueryInterface,
     TMProxyImpl_AddRef,
     TMProxyImpl_Release,
@@ -365,7 +407,7 @@
 };
 
 /* how much space do we use on stack in DWORD steps. */
-int const
+int
 _argsize(DWORD vt) {
     switch (vt) {
     case VT_DATE:
@@ -411,8 +453,8 @@
     BOOL		dealloc,
     TYPEDESC		*tdesc,
     DWORD		*arg,
-    marshal_state	*buf
-) {
+    marshal_state	*buf)
+{
     HRESULT hres = S_OK;
 
     TRACE("(tdesc.vt %d)\n",tdesc->vt);
@@ -429,7 +471,7 @@
     case VT_UI2:
     case VT_UI1:
 	hres = S_OK;
-	if (debugout) MESSAGE("%lx",*arg);
+	if (debugout) TRACE_(olerelay)("%lx",*arg);
 	if (writeit)
 	    hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
 	return hres;
@@ -438,7 +480,7 @@
 	VARIANT		*vt = (VARIANT*)arg;
 	DWORD		vttype = V_VT(vt);
 
-	if (debugout) MESSAGE("Vt(%ld)(",vttype);
+	if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
 	tdesc2.vt = vttype;
 	if (writeit) {
 	    hres = xbuf_add(buf,(LPBYTE)&vttype,sizeof(vttype));
@@ -446,15 +488,15 @@
 	}
 	/* need to recurse since we need to free the stuff */
 	hres = serialize_param(tinfo,writeit,debugout,dealloc,&tdesc2,&(V_I4(vt)),buf);
-	if (debugout) MESSAGE(")");
+	if (debugout) TRACE_(olerelay)(")");
 	return hres;
     }
     case VT_BSTR: {
 	if (debugout) {
 	    if (arg)
-		    MESSAGE("%s",debugstr_w((BSTR)*arg));
+		    TRACE_(olerelay)("%s",relaystr((BSTR)*arg));
 	    else
-		    MESSAGE("<bstr NULL>");
+		    TRACE_(olerelay)("<bstr NULL>");
 	}
 	if (writeit) {
 	    if (!*arg) {
@@ -478,7 +520,7 @@
     case VT_PTR: {
 	DWORD cookie;
 
-	if (debugout) MESSAGE("*");
+	if (debugout) TRACE_(olerelay)("*");
 	if (writeit) {
 	    cookie = *arg ? 0x42424242 : 0;
 	    hres = xbuf_add(buf,(LPBYTE)&cookie,sizeof(cookie));
@@ -486,7 +528,7 @@
 		return hres;
 	}
 	if (!*arg) {
-	    if (debugout) MESSAGE("NULL");
+	    if (debugout) TRACE_(olerelay)("NULL");
 	    return S_OK;
 	}
 	hres = serialize_param(tinfo,writeit,debugout,dealloc,tdesc->u.lptdesc,(DWORD*)*arg,buf);
@@ -494,17 +536,17 @@
 	return hres;
     }
     case VT_UNKNOWN:
-	if (debugout) MESSAGE("unk(0x%lx)",*arg);
+	if (debugout) TRACE_(olerelay)("unk(0x%lx)",*arg);
 	if (writeit)
 	    hres = _marshal_interface(buf,&IID_IUnknown,(LPUNKNOWN)*arg);
 	return hres;
     case VT_DISPATCH:
-	if (debugout) MESSAGE("idisp(0x%lx)",*arg);
+	if (debugout) TRACE_(olerelay)("idisp(0x%lx)",*arg);
 	if (writeit)
 	    hres = _marshal_interface(buf,&IID_IDispatch,(LPUNKNOWN)*arg);
 	return hres;
     case VT_VOID:
-	if (debugout) MESSAGE("<void>");
+	if (debugout) TRACE_(olerelay)("<void>");
 	return S_OK;
     case VT_USERDEFINED: {
 	ITypeInfo	*tinfo2;
@@ -524,7 +566,7 @@
 	    break;
 	case TKIND_RECORD: {
 	    int i;
-	    if (debugout) MESSAGE("{");
+	    if (debugout) TRACE_(olerelay)("{");
 	    for (i=0;i<tattr->cVars;i++) {
 		VARDESC *vdesc;
 		ELEMDESC *elem2;
@@ -543,7 +585,7 @@
 		    ERR("Need more names!\n");
 		}
 		if (!hres && debugout)
-		    MESSAGE("%s=",debugstr_w(names[0]));
+		    TRACE_(olerelay)("%s=",relaystr(names[0]));
 		*/
 		elem2 = &vdesc->elemdescVar;
 		tdesc2 = &elem2->tdesc;
@@ -559,11 +601,11 @@
 		if (hres!=S_OK)
 		    return hres;
 		if (debugout && (i<(tattr->cVars-1)))
-		    MESSAGE(",");
+		    TRACE_(olerelay)(",");
 	    }
 	    if (buf->thisisiid && (tattr->cbSizeInstance==sizeof(GUID)))
 		memcpy(&(buf->iid),arg,sizeof(buf->iid));
-	    if (debugout) MESSAGE("}");
+	    if (debugout) TRACE_(olerelay)("}");
 	    break;
 	}
 	default:
@@ -578,19 +620,19 @@
 	ARRAYDESC *adesc = tdesc->u.lpadesc;
 	int i, arrsize = 1;
 
-	if (debugout) MESSAGE("carr");
+	if (debugout) TRACE_(olerelay)("carr");
 	for (i=0;i<adesc->cDims;i++) {
-	    if (debugout) MESSAGE("[%ld]",adesc->rgbounds[i].cElements);
+	    if (debugout) TRACE_(olerelay)("[%ld]",adesc->rgbounds[i].cElements);
 	    arrsize *= adesc->rgbounds[i].cElements;
 	}
-	if (debugout) MESSAGE("[");
+	if (debugout) TRACE_(olerelay)("[");
 	for (i=0;i<arrsize;i++) {
 	    hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem)), buf);
 	    if (hres)
 		return hres;
-	    if (debugout && (i<arrsize-1)) MESSAGE(",");
+	    if (debugout && (i<arrsize-1)) TRACE_(olerelay)(",");
 	}
-	if (debugout) MESSAGE("]");
+	if (debugout) TRACE_(olerelay)("]");
 	return S_OK;
     }
     default:
@@ -607,8 +649,8 @@
     BOOL		dealloc,
     TYPEDESC		*tdesc,
     DWORD		*arg,
-    marshal_state	*buf
-) {
+    marshal_state	*buf)
+{
     HRESULT	hres;
     DWORD	cookie;
 
@@ -626,11 +668,11 @@
 	    return hres;
     }
     if (!*arg) {
-	if (debugout) MESSAGE("<lpvoid NULL>");
+	if (debugout) TRACE_(olerelay)("<lpvoid NULL>");
 	return S_OK;
     }
     if (debugout)
-	MESSAGE("ppv(%p)",*(LPUNKNOWN*)*arg);
+	TRACE_(olerelay)("ppv(%p)",*(LPUNKNOWN*)*arg);
     if (writeit) {
 	hres = _marshal_interface(buf,&(buf->iid),*(LPUNKNOWN*)*arg);
 	if (hres)
@@ -649,8 +691,8 @@
     BOOL		dealloc,
     TYPEDESC		*tdesc,
     DWORD		*arg,
-    marshal_state	*buf
-) {
+    marshal_state	*buf)
+{
     DWORD	cookie;
     HRESULT	hres;
     DISPPARAMS	*disp;
@@ -668,7 +710,7 @@
 	    return hres;
     }
     if (!*arg) {
-	if (debugout) MESSAGE("<DISPPARAMS NULL>");
+	if (debugout) TRACE_(olerelay)("<DISPPARAMS NULL>");
 	return S_OK;
     }
     disp = (DISPPARAMS*)*arg;
@@ -677,7 +719,7 @@
 	if (hres)
 	    return hres;
     }
-    if (debugout) MESSAGE("D{");
+    if (debugout) TRACE_(olerelay)("D{");
     for (i=0;i<disp->cArgs;i++) {
 	TYPEDESC	vtdesc;
 
@@ -692,7 +734,7 @@
 	    buf
         );
 	if (debugout && (i<disp->cArgs-1))
-	    MESSAGE(",");
+	    TRACE_(olerelay)(",");
     }
     if (dealloc)
 	HeapFree(GetProcessHeap(),0,disp->rgvarg);
@@ -701,7 +743,7 @@
 	if (hres)
 	    return hres;
     }
-    if (debugout) MESSAGE("}{");
+    if (debugout) TRACE_(olerelay)("}{");
     for (i=0;i<disp->cNamedArgs;i++) {
 	TYPEDESC	vtdesc;
 
@@ -716,9 +758,9 @@
 	    buf
 	);
 	if (debugout && (i<disp->cNamedArgs-1))
-	    MESSAGE(",");
+	    TRACE_(olerelay)(",");
     }
-    if (debugout) MESSAGE("}");
+    if (debugout) TRACE_(olerelay)("}");
     if (dealloc) {
 	HeapFree(GetProcessHeap(),0,disp->rgdispidNamedArgs);
 	HeapFree(GetProcessHeap(),0,disp);
@@ -734,8 +776,8 @@
     BOOL		alloc,
     TYPEDESC		*tdesc,
     DWORD		*arg,
-    marshal_state	*buf
-) {
+    marshal_state	*buf)
+{
     HRESULT hres = S_OK;
 
     TRACE("vt %d at %p\n",tdesc->vt,arg);
@@ -743,10 +785,10 @@
     while (1) {
 	switch (tdesc->vt) {
 	case VT_EMPTY:
-	    if (debugout) MESSAGE("<empty>");
+	    if (debugout) TRACE_(olerelay)("<empty>");
 	    return S_OK;
 	case VT_NULL:
-	    if (debugout) MESSAGE("<null>");
+	    if (debugout) TRACE_(olerelay)("<null>");
 	    return S_OK;
 	case VT_VARIANT: {
 	    VARIANT	*vt = (VARIANT*)arg;
@@ -762,9 +804,9 @@
 		memset(&tdesc2,0,sizeof(tdesc2));
 		tdesc2.vt = vttype;
 		V_VT(vt)  = vttype;
-	        if (debugout) MESSAGE("Vt(%ld)(",vttype);
+	        if (debugout) TRACE_(olerelay)("Vt(%ld)(",vttype);
 		hres = deserialize_param(tinfo, readit, debugout, alloc, &tdesc2, &(V_I4(vt)), buf);
-		MESSAGE(")");
+		TRACE_(olerelay)(")");
 		return hres;
 	    } else {
 		VariantInit(vt);
@@ -779,7 +821,7 @@
 		hres = xbuf_get(buf,(LPBYTE)arg,sizeof(DWORD));
 		if (hres) FIXME("Failed to read integer 4 byte\n");
 	    }
-	    if (debugout) MESSAGE("%lx",*arg);
+	    if (debugout) TRACE_(olerelay)("%lx",*arg);
 	    return hres;
 	case VT_BSTR: {
 	    WCHAR	*str;
@@ -793,7 +835,7 @@
 		}
 		if (len == -1) {
 		    *arg = 0;
-		    if (debugout) MESSAGE("<bstr NULL>");
+		    if (debugout) TRACE_(olerelay)("<bstr NULL>");
 		} else {
 		    str  = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,len+sizeof(WCHAR));
 		    hres = xbuf_get(buf,(LPBYTE)str,len);
@@ -802,7 +844,7 @@
 			return hres;
 		    }
 		    *arg = (DWORD)SysAllocStringLen(str,len);
-		    if (debugout) MESSAGE("%s",debugstr_w(str));
+		    if (debugout) TRACE_(olerelay)("%s",relaystr(str));
 		    HeapFree(GetProcessHeap(),0,str);
 		}
 	    } else {
@@ -823,11 +865,11 @@
 		    return hres;
 		}
 		if (cookie != 0x42424242) {
-		    if (debugout) MESSAGE("NULL");
+		    if (debugout) TRACE_(olerelay)("NULL");
 		    *arg = 0;
 		    return S_OK;
 		}
-		if (debugout) MESSAGE("*");
+		if (debugout) TRACE_(olerelay)("*");
 	    }
 	    if (alloc) {
 		if (derefhere)
@@ -846,17 +888,17 @@
 	    if (readit)
 		hres = _unmarshal_interface(buf,&IID_IUnknown,(LPUNKNOWN*)arg);
 	    if (debugout)
-		MESSAGE("unk(%p)",arg);
+		TRACE_(olerelay)("unk(%p)",arg);
 	    return hres;
 	case VT_DISPATCH:
 	    hres = S_OK;
 	    if (readit)
 		hres = _unmarshal_interface(buf,&IID_IDispatch,(LPUNKNOWN*)arg);
 	    if (debugout)
-		MESSAGE("idisp(%p)",arg);
+		TRACE_(olerelay)("idisp(%p)",arg);
 	    return hres;
 	case VT_VOID:
-	    if (debugout) MESSAGE("<void>");
+	    if (debugout) TRACE_(olerelay)("<void>");
 	    return S_OK;
 	case VT_USERDEFINED: {
 	    ITypeInfo	*tinfo2;
@@ -882,7 +924,7 @@
 		case TKIND_RECORD: {
 		    int i;
 
-		    if (debugout) MESSAGE("{");
+		    if (debugout) TRACE_(olerelay)("{");
 		    for (i=0;i<tattr->cVars;i++) {
 			VARDESC *vdesc;
 
@@ -900,11 +942,11 @@
 			    (DWORD*)(((LPBYTE)*arg)+vdesc->u.oInst),
 			    buf
 			);
-		        if (debugout && (i<tattr->cVars-1)) MESSAGE(",");
+		        if (debugout && (i<tattr->cVars-1)) TRACE_(olerelay)(",");
 		    }
 		    if (buf->thisisiid && (tattr->cbSizeInstance==sizeof(GUID)))
 			memcpy(&(buf->iid),(LPBYTE)*arg,sizeof(buf->iid));
-		    if (debugout) MESSAGE("}");
+		    if (debugout) TRACE_(olerelay)("}");
 		    break;
 		}
 		default:
@@ -973,7 +1015,7 @@
 	    return hres;
 	if (cookie != 0x42424242) {
 	    *(DWORD*)*arg = 0;
-	    if (debugout) MESSAGE("<lpvoid NULL>");
+	    if (debugout) TRACE_(olerelay)("<lpvoid NULL>");
 	    return S_OK;
 	}
     }
@@ -982,7 +1024,7 @@
 	if (hres)
 	    return hres;
     }
-    if (debugout) MESSAGE("ppv(%p)",(LPVOID)*arg);
+    if (debugout) TRACE_(olerelay)("ppv(%p)",(LPVOID)*arg);
     return S_OK;
 }
 
@@ -994,8 +1036,8 @@
     BOOL		alloc,
     TYPEDESC		*tdesc,
     DWORD		*arg,
-    marshal_state	*buf
-) {
+    marshal_state	*buf)
+{
     DWORD	cookie;
     DISPPARAMS	*disps;
     HRESULT	hres;
@@ -1011,7 +1053,7 @@
 	    return hres;
 	if (cookie == 0) {
 	    *arg = 0;
-	    if (debugout) MESSAGE("<DISPPARAMS NULL>");
+	    if (debugout) TRACE_(olerelay)("<DISPPARAMS NULL>");
 	    return S_OK;
 	}
     }
@@ -1025,7 +1067,7 @@
 	return hres;
     if (alloc)
         disps->rgvarg = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(VARIANT)*disps->cArgs);
-    if (debugout) MESSAGE("D{");
+    if (debugout) TRACE_(olerelay)("D{");
     for (i=0; i< disps->cArgs; i++) {
         TYPEDESC vdesc;
 
@@ -1040,7 +1082,7 @@
 	    buf
 	);
     }
-    if (debugout) MESSAGE("}{");
+    if (debugout) TRACE_(olerelay)("}{");
     hres = xbuf_get(buf, (LPBYTE)&disps->cNamedArgs, sizeof(disps->cNamedArgs));
     if (hres)
 	return hres;
@@ -1060,18 +1102,18 @@
 		(DWORD*)(disps->rgdispidNamedArgs+i),
 		buf
 	    );
-	    if (debugout && i<(disps->cNamedArgs-1)) MESSAGE(",");
+	    if (debugout && i<(disps->cNamedArgs-1)) TRACE_(olerelay)(",");
 	}
     }
-    if (debugout) MESSAGE("}");
+    if (debugout) TRACE_(olerelay)("}");
     return S_OK;
 }
 
 /* Searches function, also in inherited interfaces */
 static HRESULT
 _get_funcdesc(
-    ITypeInfo *tinfo, int iMethod, FUNCDESC **fdesc, BSTR *iname, BSTR *fname
-) {
+    ITypeInfo *tinfo, int iMethod, FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
+{
     int i = 0, j = 0;
     HRESULT hres;
 
@@ -1121,7 +1163,8 @@
 }
 
 static DWORD
-xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) {
+xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
+{
     DWORD		*args = ((DWORD*)&tpinfo)+1, *xargs;
     FUNCDESC		*fdesc;
     HRESULT		hres;
@@ -1133,22 +1176,24 @@
     BSTR		names[10];
     int			nrofnames;
 
+    EnterCriticalSection(&tpinfo->crit);
+
     hres = _get_funcdesc(tpinfo->tinfo,method,&fdesc,&iname,&fname);
     if (hres) {
 	ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
-	return 0;
+        LeaveCriticalSection(&tpinfo->crit);
+	return E_FAIL;
     }
 
-    /*dump_FUNCDESC(fdesc);*/
     if (relaydeb) {
-	TRACE_(olerelay)("->");
+       TRACE_(olerelay)("->");
 	if (iname)
-	    MESSAGE("%s:",debugstr_w(iname));
+	    TRACE_(olerelay)("%s:",relaystr(iname));
 	if (fname)
-	    MESSAGE("%s(%d)",debugstr_w(fname),method);
+	    TRACE_(olerelay)("%s(%d)",relaystr(fname),method);
 	else
-	    MESSAGE("%d",method);
-	MESSAGE("(");
+	    TRACE_(olerelay)("%d",method);
+	TRACE_(olerelay)("(");
 	if (iname) SysFreeString(iname);
 	if (fname) SysFreeString(fname);
     }
@@ -1163,21 +1208,21 @@
     buf.iid = IID_IUnknown;
     if (method == 0) {
 	xbuf_add(&buf,(LPBYTE)args[0],sizeof(IID));
-	if (relaydeb) MESSAGE("riid=%s,[out]",debugstr_guid((REFIID)args[0]));
+	if (relaydeb) TRACE_(olerelay)("riid=%s,[out]",debugstr_guid((REFIID)args[0]));
     } else {
 	xargs = args;
 	for (i=0;i<fdesc->cParams;i++) {
 	    ELEMDESC	*elem = fdesc->lprgelemdescParam+i;
 	    BOOL	isserialized = FALSE;
 	    if (relaydeb) {
-		if (i) MESSAGE(",");
+		if (i) TRACE_(olerelay)(",");
 		if (i+1<nrofnames && names[i+1])
-		    MESSAGE("%s=",debugstr_w(names[i+1]));
+		    TRACE_(olerelay)("%s=",relaystr(names[i+1]));
 	    }
 	    /* No need to marshal other data than FIN */
 	    if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FIN)) {
 		xargs+=_argsize(elem->tdesc.vt);
-		if (relaydeb) MESSAGE("[out]");
+		if (relaydeb) TRACE_(olerelay)("[out]");
 		continue;
 	    }
 	    if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
@@ -1231,24 +1276,26 @@
 	    xargs+=_argsize(elem->tdesc.vt);
 	}
     }
-    if (relaydeb) MESSAGE(")");
+    if (relaydeb) TRACE_(olerelay)(")");
     memset(&msg,0,sizeof(msg));
     msg.cbBuffer = buf.curoff;
     msg.iMethod  = method;
     hres = IRpcChannelBuffer_GetBuffer(tpinfo->chanbuf,&msg,&(tpinfo->iid));
     if (hres) {
 	FIXME("RpcChannelBuffer GetBuffer failed, %lx\n",hres);
+        LeaveCriticalSection(&tpinfo->crit);
 	return hres;
     }
     memcpy(msg.Buffer,buf.base,buf.curoff);
-    if (relaydeb) MESSAGE("\n");
+    if (relaydeb) TRACE_(olerelay)("\n");
     hres = IRpcChannelBuffer_SendReceive(tpinfo->chanbuf,&msg,&status);
     if (hres) {
 	FIXME("RpcChannelBuffer SendReceive failed, %lx\n",hres);
+        LeaveCriticalSection(&tpinfo->crit);
 	return hres;
     }
-    relaydeb = TRACE_ON(olerelay);
-    if (relaydeb) MESSAGE(" = %08lx (",status);
+
+    if (relaydeb) TRACE_(olerelay)(" = %08lx (",status);
     if (buf.base)
 	buf.base = HeapReAlloc(GetProcessHeap(),0,buf.base,msg.cbBuffer);
     else
@@ -1258,7 +1305,7 @@
     buf.curoff = 0;
     if (method == 0) {
 	_unmarshal_interface(&buf,(REFIID)args[0],(LPUNKNOWN*)args[1]);
-	if (relaydeb) MESSAGE("[in],%p",*((DWORD**)args[1]));
+	if (relaydeb) TRACE_(olerelay)("[in],%p",*((DWORD**)args[1]));
     } else {
 	xargs = args;
 	for (i=0;i<fdesc->cParams;i++) {
@@ -1266,13 +1313,13 @@
 	    BOOL	isdeserialized = FALSE;
 
 	    if (relaydeb) {
-		if (i) MESSAGE(",");
-		if (i+1<nrofnames && names[i+1]) MESSAGE("%s=",debugstr_w(names[i+1]));
+		if (i) TRACE_(olerelay)(",");
+		if (i+1<nrofnames && names[i+1]) TRACE_(olerelay)("%s=",relaystr(names[i+1]));
 	    }
 	    /* No need to marshal other data than FOUT I think */
 	    if (!(elem->u.paramdesc.wParamFlags & PARAMFLAG_FOUT)) {
 		xargs += _argsize(elem->tdesc.vt);
-		if (relaydeb) MESSAGE("[in]");
+		if (relaydeb) TRACE_(olerelay)("[in]");
 		continue;
 	    }
 	    if (((i+1)<nrofnames) && !IsBadStringPtrW(names[i+1],1)) {
@@ -1329,16 +1376,19 @@
 	    xargs += _argsize(elem->tdesc.vt);
 	}
     }
-    if (relaydeb) MESSAGE(")\n\n");
+    if (relaydeb) TRACE_(olerelay)(")\n");
     HeapFree(GetProcessHeap(),0,buf.base);
+
+    LeaveCriticalSection(&tpinfo->crit);
+
     return status;
 }
 
 static HRESULT WINAPI
 PSFacBuf_CreateProxy(
     LPPSFACTORYBUFFER iface, IUnknown* pUnkOuter, REFIID riid,
-    IRpcProxyBuffer **ppProxy, LPVOID *ppv
-) {
+    IRpcProxyBuffer **ppProxy, LPVOID *ppv)
+{
     HRESULT	hres;
     ITypeInfo	*tinfo;
     int		i, nroffuncs;
@@ -1352,12 +1402,20 @@
 	return hres;
     }
     nroffuncs = _nroffuncs(tinfo);
-    proxy = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TMProxyImpl));
+    proxy = CoTaskMemAlloc(sizeof(TMProxyImpl));
     if (!proxy) return E_OUTOFMEMORY;
-    proxy->asmstubs=HeapAlloc(GetProcessHeap(),0,sizeof(TMAsmProxy)*nroffuncs);
 
     assert(sizeof(TMAsmProxy) == 12);
 
+    proxy->asmstubs = VirtualAlloc(NULL, sizeof(TMAsmProxy) * nroffuncs, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+    if (!proxy->asmstubs) {
+        ERR("Could not commit pages for proxy thunks\n");
+        CoTaskMemFree(proxy);
+        return E_OUTOFMEMORY;
+    }
+
+    InitializeCriticalSection(&proxy->crit);
+
     proxy->lpvtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE)*nroffuncs);
     for (i=0;i<nroffuncs;i++) {
 	int		nrofargs;
@@ -1406,9 +1464,10 @@
 	xasm->xcall     -= (DWORD)&(xasm->lret);
 	xasm->lret	= 0xc2;
 	xasm->bytestopop= (nrofargs+2)*4; /* pop args, This, iMethod */
-	proxy->lpvtbl[i] = (DWORD)xasm;
+	proxy->lpvtbl[i] = xasm;
     }
     proxy->lpvtbl2	= &tmproxyvtable;
+    /* 1 reference for the proxy and 1 for the object */
     proxy->ref		= 2;
     proxy->tinfo	= tinfo;
     memcpy(&proxy->iid,riid,sizeof(*riid));
@@ -1418,8 +1477,8 @@
 }
 
 typedef struct _TMStubImpl {
-    ICOM_VTABLE(IRpcStubBuffer)	*lpvtbl;
-    DWORD			ref;
+    IRpcStubBufferVtbl	*lpvtbl;
+    ULONG			ref;
 
     LPUNKNOWN			pUnk;
     ITypeInfo			*tinfo;
@@ -1427,7 +1486,8 @@
 } TMStubImpl;
 
 static HRESULT WINAPI
-TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) {
+TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv)
+{
     if (IsEqualIID(riid,&IID_IRpcStubBuffer)||IsEqualIID(riid,&IID_IUnknown)){
 	*ppv = (LPVOID)iface;
 	IRpcStubBuffer_AddRef(iface);
@@ -1438,27 +1498,38 @@
 }
 
 static ULONG WINAPI
-TMStubImpl_AddRef(LPRPCSTUBBUFFER iface) {
-    ICOM_THIS(TMStubImpl,iface);
+TMStubImpl_AddRef(LPRPCSTUBBUFFER iface)
+{
+    TMStubImpl *This = (TMStubImpl *)iface;
+        
+    TRACE("(%p) before %lu\n", This, This->ref);
 
-    This->ref++;
-    return This->ref;
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI
-TMStubImpl_Release(LPRPCSTUBBUFFER iface) {
-    ICOM_THIS(TMStubImpl,iface);
+TMStubImpl_Release(LPRPCSTUBBUFFER iface)
+{
+    ULONG refs;
+    TMStubImpl *This = (TMStubImpl *)iface;
 
-    This->ref--;
-    if (This->ref)
-	return This->ref;
-    HeapFree(GetProcessHeap(),0,This);
-    return 0;
+    TRACE("(%p) after %lu\n", This, This->ref-1);
+
+    refs = InterlockedDecrement(&This->ref);
+    if (!refs)
+    {
+        IRpcStubBuffer_Disconnect(iface);
+        CoTaskMemFree(This);
+    }
+    return refs;
 }
 
 static HRESULT WINAPI
-TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer) {
-    ICOM_THIS(TMStubImpl,iface);
+TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer)
+{
+    TMStubImpl *This = (TMStubImpl *)iface;
+
+    TRACE("(%p)->(%p)\n", This, pUnkServer);
 
     IUnknown_AddRef(pUnkServer);
     This->pUnk = pUnkServer;
@@ -1466,8 +1537,11 @@
 }
 
 static void WINAPI
-TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface) {
-    ICOM_THIS(TMStubImpl,iface);
+TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface)
+{
+    TMStubImpl *This = (TMStubImpl *)iface;
+
+    TRACE("(%p)->()\n", This);
 
     IUnknown_Release(This->pUnk);
     This->pUnk = NULL;
@@ -1476,11 +1550,11 @@
 
 static HRESULT WINAPI
 TMStubImpl_Invoke(
-    LPRPCSTUBBUFFER iface, RPCOLEMESSAGE* xmsg,IRpcChannelBuffer*rpcchanbuf
-) {
+    LPRPCSTUBBUFFER iface, RPCOLEMESSAGE* xmsg,IRpcChannelBuffer*rpcchanbuf)
+{
     int		i;
     FUNCDESC	*fdesc;
-    ICOM_THIS(TMStubImpl,iface);
+    TMStubImpl *This = (TMStubImpl *)iface;
     HRESULT	hres;
     DWORD	*args, res, *xargs, nrofargs;
     marshal_state	buf;
@@ -1579,7 +1653,7 @@
 	    );
 	xargs += _argsize(elem->tdesc.vt);
 	if (hres) {
-	    FIXME("Failed to deserialize param %s, hres %lx\n",debugstr_w(names[i+1]),hres);
+	    FIXME("Failed to deserialize param %s, hres %lx\n",relaystr(names[i+1]),hres);
 	    break;
 	}
     }
@@ -1665,7 +1739,7 @@
 
 static ULONG WINAPI
 TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface) {
-    ICOM_THIS(TMStubImpl,iface);
+    TMStubImpl *This = (TMStubImpl *)iface;
 
     return This->ref; /*FIXME? */
 }
@@ -1680,8 +1754,7 @@
     return;
 }
 
-ICOM_VTABLE(IRpcStubBuffer) tmstubvtbl = {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+IRpcStubBufferVtbl tmstubvtbl = {
     TMStubImpl_QueryInterface,
     TMStubImpl_AddRef,
     TMStubImpl_Release,
@@ -1709,7 +1782,7 @@
 	FIXME("No typeinfo for %s?\n",debugstr_guid(riid));
 	return hres;
     }
-    stub = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TMStubImpl));
+    stub = CoTaskMemAlloc(sizeof(TMStubImpl));
     if (!stub)
 	return E_OUTOFMEMORY;
     stub->lpvtbl	= &tmstubvtbl;
@@ -1718,13 +1791,13 @@
     memcpy(&(stub->iid),riid,sizeof(*riid));
     hres = IRpcStubBuffer_Connect((LPRPCSTUBBUFFER)stub,pUnkServer);
     *ppStub 		= (LPRPCSTUBBUFFER)stub;
+    TRACE("IRpcStubBuffer: %p\n", stub);
     if (hres)
 	FIXME("Connect to pUnkServer failed?\n");
     return hres;
 }
 
-static ICOM_VTABLE(IPSFactoryBuffer) psfacbufvtbl = {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+static IPSFactoryBufferVtbl psfacbufvtbl = {
     PSFacBuf_QueryInterface,
     PSFacBuf_AddRef,
     PSFacBuf_Release,
@@ -1733,7 +1806,7 @@
 };
 
 /* This is the whole PSFactoryBuffer object, just the vtableptr */
-static ICOM_VTABLE(IPSFactoryBuffer) *lppsfac = &psfacbufvtbl;
+static IPSFactoryBufferVtbl *lppsfac = &psfacbufvtbl;
 
 /***********************************************************************
  *           DllGetClassObject [OLE32.63]

reactos/lib/oleaut32
typelib.c 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- typelib.c	29 Feb 2004 15:27:51 -0000	1.2
+++ typelib.c	8 Dec 2004 21:57:17 -0000	1.2.20.1
@@ -61,8 +61,10 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
@@ -72,7 +74,6 @@
 
 #include "wine/unicode.h"
 #include "objbase.h"
-#include "heap.h"
 #include "ole2disp.h"
 #include "typelib.h"
 #include "wine/debug.h"
@@ -148,6 +149,50 @@
 #define FromLEDWords(X,Y) /*nothing*/
 #endif
 
+/* get the path of a typelib key, in the form "Typelib\\<guid>\\<maj>.<min>" */
+/* buffer must be at least 60 characters long */
+static WCHAR *get_typelib_key( REFGUID guid, WORD wMaj, WORD wMin, WCHAR *buffer )
+{
+    static const WCHAR TypelibW[] = {'T','y','p','e','l','i','b','\\',0};
+    static const WCHAR VersionFormatW[] = {'\\','%','u','.','%','u',0};
+
+    memcpy( buffer, TypelibW, sizeof(TypelibW) );
+    StringFromGUID2( guid, buffer + strlenW(buffer), 40 );
+    sprintfW( buffer + strlenW(buffer), VersionFormatW, wMaj, wMin );
+    return buffer;
+}
+
+/* get the path of an interface key, in the form "Interface\\<guid>" */
+/* buffer must be at least 50 characters long */
+static WCHAR *get_interface_key( REFGUID guid, WCHAR *buffer )
+{
+    static const WCHAR InterfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
+
+    memcpy( buffer, InterfaceW, sizeof(InterfaceW) );
+    StringFromGUID2( guid, buffer + strlenW(buffer), 40 );
+    return buffer;
+}
+
+/* get the lcid subkey for a typelib, in the form "<lcid>\\<syskind>" */
+/* buffer must be at least 16 characters long */
+static WCHAR *get_lcid_subkey( LCID lcid, SYSKIND syskind, WCHAR *buffer )
+{
+    static const WCHAR LcidFormatW[] = {'%','l','x','\\',0};
+    static const WCHAR win16W[] = {'w','i','n','1','6',0};
+    static const WCHAR win32W[] = {'w','i','n','3','2',0};
+
+    sprintfW( buffer, LcidFormatW, lcid );
+    switch(syskind)
+    {
+    case SYS_WIN16: strcatW( buffer, win16W ); break;
+    case SYS_WIN32: strcatW( buffer, win32W ); break;
+    default:
+        TRACE("Typelib is for unsupported syskind %i\n", syskind);
+        return NULL;
+    }
+    return buffer;
+}
+
 
 /****************************************************************************
  *		QueryPathOfRegTypeLib	[OLEAUT32.164]
@@ -162,40 +207,33 @@
 	LCID lcid,	/* [in] locale id */
 	LPBSTR path )	/* [out] path of typelib */
 {
-    /* don't need to ZeroMemory those arrays since sprintf and RegQueryValue add
-       string termination character on output strings */
-
-    HRESULT hr        = E_FAIL;
-
-    LCID    myLCID    = lcid;
-
-    char    szXGUID[80];
-    char    szTypeLibKey[100];
-    char    szPath[MAX_PATH];
-    DWORD   dwPathLen = sizeof(szPath);
+    HRESULT hr = E_FAIL;
+    LCID myLCID = lcid;
+    HKEY hkey;
+    WCHAR buffer[60];
+    WCHAR Path[MAX_PATH];
 
     if ( !HIWORD(guid) )
     {
-        sprintf(szXGUID,
-            "<guid 0x%08lx>",
-            (DWORD) guid);
+        FIXME("(guid %p,%d,%d,0x%04lx,%p),stub!\n", guid, wMaj, wMin, lcid, path);
+        return E_FAIL;
+    }
+
+    get_typelib_key( guid, wMaj, wMin, buffer );
 
-        FIXME("(%s,%d,%d,0x%04lx,%p),stub!\n", szXGUID, wMaj, wMin, (DWORD)lcid, path);
+    if (RegOpenKeyW( HKEY_CLASSES_ROOT, buffer, &hkey ) != ERROR_SUCCESS)
+    {
+        TRACE_(typelib)("%s not found\n", debugstr_w(buffer));
         return E_FAIL;
     }
 
     while (hr != S_OK)
     {
-        sprintf(szTypeLibKey,
-            "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win32",
-            guid->Data1,    guid->Data2,    guid->Data3,
-            guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
-            guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
-            wMaj,
-            wMin,
-            myLCID);
+        DWORD dwPathLen = sizeof(Path);
 
-        if (RegQueryValueA(HKEY_LOCAL_MACHINE, szTypeLibKey, szPath, &dwPathLen))
+        get_lcid_subkey( myLCID, SYS_WIN32, buffer );
+
+        if (RegQueryValueW(hkey, buffer, Path, &dwPathLen))
         {
             if (!lcid)
                 break;
@@ -216,23 +254,11 @@
         }
         else
         {
-            DWORD len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, dwPathLen, NULL, 0 );
-            BSTR bstrPath = SysAllocStringLen(NULL,len);
-
-            MultiByteToWideChar(CP_ACP,
-                                MB_PRECOMPOSED,
-                                szPath,
-                                dwPathLen,
-                                bstrPath,
-                                len);
-           *path = bstrPath;
-           hr = S_OK;
+            *path = SysAllocString( Path );
+            hr = S_OK;
         }
     }
-
-    if (hr != S_OK)
-		TRACE_(typelib)("%s not found\n", szTypeLibKey);
-
+    RegCloseKey( hkey );
     return hr;
 }
 
@@ -308,7 +334,7 @@
 		return TYPE_E_CANTLOADLIBRARY;
 	} else {
 	    WCHAR tstpath[260];
-	    WCHAR stdole32tlb[] = { 's','t','d','o','l','e','3','2','.','t','l','b',0 };
+	    static const WCHAR stdole32tlb[] = { 's','t','d','o','l','e','3','2','.','t','l','b',0 };
 	    int i;
 
 	    lstrcpyW(tstpath,szFile);
@@ -321,7 +347,6 @@
 		    	MESSAGE("You must copy a 'stdole32.tlb' file to your Windows\\System directory!\n");
 		    	MESSAGE("You can get one from a Windows installation, or look for the DCOM95 package\n");
 		    	MESSAGE("on the Microsoft Download Pages.\n");
-		    	MESSAGE("A free download link is on http://sourceforge.net/projects/wine/, look for dcom95.exe.\n");
 		    	MESSAGE("**************************************************************************\n");
 			break;
 		    }
@@ -386,6 +411,13 @@
 }
 
 
+/* some string constants shared between RegisterTypeLib and UnRegisterTypeLib */
+static const WCHAR TypeLibW[] = {'T','y','p','e','L','i','b',0};
+static const WCHAR FLAGSW[] = {'F','L','A','G','S',0};
+static const WCHAR HELPDIRW[] = {'H','E','L','P','D','I','R',0};
+static const WCHAR ProxyStubClsidW[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d',0};
+static const WCHAR ProxyStubClsid32W[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
+
 /******************************************************************************
  *		RegisterTypeLib	[OLEAUT32.163]
  * Adds information about a type library to the System Registry
@@ -404,17 +436,17 @@
      OLECHAR * szHelpDir)  /* [in] dir to the helpfile for the library,
 							 may be NULL*/
 {
+    static const WCHAR PSOA[] = {'{','0','0','0','2','0','4','2','4','-',
+                                 '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
+                                 '0','0','0','0','0','0','0','0','0','0','4','6','}',0};
     HRESULT res;
     TLIBATTR *attr;
-    OLECHAR guid[80];
-    LPSTR guidA;
-    CHAR keyName[120];
-    CHAR tmp[MAX_PATH];
+    WCHAR keyName[60];
+    WCHAR tmp[16];
     HKEY key, subKey;
     UINT types, tidx;
     TYPEKIND kind;
     DWORD disposition;
-    static const char *PSOA = "{00020424-0000-0000-C000-000000000046}";
 
     if (ptlib == NULL || szFullPath == NULL)
         return E_INVALIDARG;
@@ -422,14 +454,10 @@
     if (!SUCCEEDED(ITypeLib_GetLibAttr(ptlib, &attr)))
         return E_FAIL;
 
-    StringFromGUID2(&attr->guid, guid, 80);
-    guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
-    snprintf(keyName, sizeof(keyName), "TypeLib\\%s\\%x.%x",
-        guidA, attr->wMajorVerNum, attr->wMinorVerNum);
-    HeapFree(GetProcessHeap(), 0, guidA);
+    get_typelib_key( &attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, keyName );
 
     res = S_OK;
-    if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyName, 0, NULL, 0,
+    if (RegCreateKeyExW(HKEY_CLASSES_ROOT, keyName, 0, NULL, 0,
         KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS)
     {
         LPOLESTR doc;
@@ -447,24 +475,10 @@
             res = E_FAIL;
 
         /* Make up the name of the typelib path subkey */
-        sprintf(tmp, "%lu\\", attr->lcid);
-        switch(attr->syskind) {
-        case SYS_WIN16:
-            strcat(tmp, "win16");
-            break;
-
-        case SYS_WIN32:
-            strcat(tmp, "win32");
-            break;
-
-        default:
-            TRACE("Typelib is for unsupported syskind %i\n", attr->syskind);
-            res = E_FAIL;
-            break;
-        }
+        if (!get_lcid_subkey( attr->lcid, attr->syskind, tmp )) res = E_FAIL;
 
         /* Create the typelib path subkey */
-        if (res == S_OK && RegCreateKeyExA(key, tmp, 0, NULL, 0,
+        if (res == S_OK && RegCreateKeyExW(key, tmp, 0, NULL, 0,
             KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS)
         {
             if (RegSetValueExW(subKey, NULL, 0, REG_SZ,
@@ -477,14 +491,15 @@
             res = E_FAIL;
 
         /* Create the flags subkey */
-        if (res == S_OK && RegCreateKeyExA(key, "FLAGS", 0, NULL, 0,
+        if (res == S_OK && RegCreateKeyExW(key, FLAGSW, 0, NULL, 0,
             KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS)
         {
-            CHAR buf[20];
             /* FIXME: is %u correct? */
-            snprintf(buf, sizeof(buf), "%u", attr->wLibFlags);
-            if (RegSetValueExA(subKey, NULL, 0, REG_SZ,
-                buf, lstrlenA(buf) + 1) != ERROR_SUCCESS)
+            static const WCHAR formatW[] = {'%','u',0};
+            WCHAR buf[20];
+            sprintfW(buf, formatW, attr->wLibFlags);
+            if (RegSetValueExW(subKey, NULL, 0, REG_SZ,
+                               (BYTE *)buf, (strlenW(buf) + 1)*sizeof(WCHAR) ) != ERROR_SUCCESS)
                 res = E_FAIL;
 
             RegCloseKey(subKey);
@@ -493,7 +508,7 @@
             res = E_FAIL;
 
         /* create the helpdir subkey */
-        if (res == S_OK && RegCreateKeyExA(key, "HELPDIR", 0, NULL, 0,
+        if (res == S_OK && RegCreateKeyExW(key, HELPDIRW, 0, NULL, 0,
             KEY_WRITE, NULL, &subKey, &disposition) == ERROR_SUCCESS)
         {
             BOOL freeHelpDir = FALSE;
@@ -599,41 +614,41 @@
                         }
 
 			/* register interface<->typelib coupling */
-			StringFromGUID2(&tattr->guid, guid, 80);
-			guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
-			snprintf(keyName, sizeof(keyName), "Interface\\%s", guidA);
-			HeapFree(GetProcessHeap(), 0, guidA);
-
-			if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyName, 0, NULL, 0,
-					    KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
+			get_interface_key( &tattr->guid, keyName );
+			if (RegCreateKeyExW(HKEY_CLASSES_ROOT, keyName, 0, NULL, 0,
+					    KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS)
+			{
 			    if (name)
 				RegSetValueExW(key, NULL, 0, REG_SZ,
-					       (BYTE *)name, lstrlenW(name) * sizeof(OLECHAR));
+					       (BYTE *)name, (strlenW(name)+1) * sizeof(OLECHAR));
 
-			    if (RegCreateKeyExA(key, "ProxyStubClsid", 0, NULL, 0,
+			    if (RegCreateKeyExW(key, ProxyStubClsidW, 0, NULL, 0,
 				KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
-				RegSetValueExA(subKey, NULL, 0, REG_SZ,
-					       PSOA, strlen(PSOA));
+				RegSetValueExW(subKey, NULL, 0, REG_SZ,
+					       (BYTE*)PSOA, sizeof PSOA);
 				RegCloseKey(subKey);
 			    }
 
-			    if (RegCreateKeyExA(key, "ProxyStubClsid32", 0, NULL, 0,
+			    if (RegCreateKeyExW(key, ProxyStubClsid32W, 0, NULL, 0,
 				KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
-				RegSetValueExA(subKey, NULL, 0, REG_SZ,
-					       PSOA, strlen(PSOA));
+				RegSetValueExW(subKey, NULL, 0, REG_SZ,
+					       (BYTE*)PSOA, sizeof PSOA);
 				RegCloseKey(subKey);
 			    }
 
-			    if (RegCreateKeyExA(key, "TypeLib", 0, NULL, 0,
-				KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS) {
-				CHAR ver[32];
-				StringFromGUID2(&attr->guid, guid, 80);
-				snprintf(ver, sizeof(ver), "%x.%x",
-					 attr->wMajorVerNum, attr->wMinorVerNum);
+			    if (RegCreateKeyExW(key, TypeLibW, 0, NULL, 0,
+				KEY_WRITE, NULL, &subKey, NULL) == ERROR_SUCCESS)
+			    {
+				WCHAR buffer[40];
+				static const WCHAR fmtver[] = {'%','u','.','%','u',0 };
+				static const WCHAR VersionW[] = {'V','e','r','s','i','o','n',0};
+
+				StringFromGUID2(&attr->guid, buffer, 40);
 				RegSetValueExW(subKey, NULL, 0, REG_SZ,
-					       (BYTE *)guid, lstrlenW(guid) * sizeof(OLECHAR));
-				RegSetValueExA(subKey, "Version", 0, REG_SZ,
-					       ver, lstrlenA(ver));
+					       (BYTE *)buffer, (strlenW(buffer)+1) * sizeof(WCHAR));
+				sprintfW(buffer, fmtver, attr->wMajorVerNum, attr->wMinorVerNum);
+				RegSetValueExW(subKey, VersionW, 0, REG_SZ,
+					       (BYTE*)buffer, (strlenW(buffer)+1) * sizeof(WCHAR));
 				RegCloseKey(subKey);
 			    }
 
@@ -675,13 +690,10 @@
 {
     BSTR tlibPath = NULL;
     DWORD tmpLength;
-    CHAR keyName[MAX_PATH];
-    CHAR* syskindName;
-    CHAR subKeyName[MAX_PATH];
-    LPSTR guidA;
+    WCHAR keyName[60];
+    WCHAR subKeyName[50];
     int result = S_OK;
     DWORD i = 0;
-    OLECHAR guid[80];
     BOOL deleteOtherStuff;
     HKEY key = NULL;
     HKEY subKey = NULL;
@@ -694,23 +706,10 @@
     TRACE("(IID: %s): stub\n",debugstr_guid(libid));
 
     /* Create the path to the key */
-    StringFromGUID2(libid, guid, 80);
-    guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
-    snprintf(keyName, sizeof(keyName), "TypeLib\\%s\\%x.%x",
-        guidA, wVerMajor, wVerMinor);
-    HeapFree(GetProcessHeap(), 0, guidA);
-
-    /* Work out the syskind name */
-    switch(syskind) {
-    case SYS_WIN16:
-        syskindName = "win16";
-        break;
-
-    case SYS_WIN32:
-        syskindName = "win32";
-        break;
+    get_typelib_key( libid, wVerMajor, wVerMinor, keyName );
 
-    default:
+    if (syskind != SYS_WIN16 && syskind != SYS_WIN32)
+    {
         TRACE("Unsupported syskind %i\n", syskind);
         result = E_INVALIDARG;
         goto end;
@@ -723,7 +722,7 @@
     }
 
     /* Try and open the key to the type library. */
-    if (RegOpenKeyExA(HKEY_CLASSES_ROOT, keyName, 0, KEY_READ | KEY_WRITE, &key) != S_OK) {
+    if (RegOpenKeyExW(HKEY_CLASSES_ROOT, keyName, 0, KEY_READ | KEY_WRITE, &key) != S_OK) {
         result = E_INVALIDARG;
         goto end;
     }
@@ -754,21 +753,18 @@
         }
 
         /* the path to the type */
-        StringFromGUID2(&typeAttr->guid, guid, 80);
-        guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
-        snprintf(subKeyName, sizeof(subKeyName), "Interface\\%s", guidA);
-        HeapFree(GetProcessHeap(), 0, guidA);
+        get_interface_key( &typeAttr->guid, subKeyName );
 
         /* Delete its bits */
-        if (RegOpenKeyExA(HKEY_CLASSES_ROOT, subKeyName, 0, KEY_WRITE, &subKey) != S_OK) {
+        if (RegOpenKeyExW(HKEY_CLASSES_ROOT, subKeyName, 0, KEY_WRITE, &subKey) != S_OK) {
             goto enddeleteloop;
         }
-        RegDeleteKeyA(subKey, "ProxyStubClsid");
-        RegDeleteKeyA(subKey, "ProxyStubClsid32");
-        RegDeleteKeyA(subKey, "TypeLib");
+        RegDeleteKeyW(subKey, ProxyStubClsidW);
+        RegDeleteKeyW(subKey, ProxyStubClsid32W);
+        RegDeleteKeyW(subKey, TypeLibW);
         RegCloseKey(subKey);
         subKey = NULL;
-        RegDeleteKeyA(HKEY_CLASSES_ROOT, subKeyName);
+        RegDeleteKeyW(HKEY_CLASSES_ROOT, subKeyName);
 
 enddeleteloop:
         if (typeAttr) ITypeInfo_ReleaseTypeAttr(typeInfo, typeAttr);
@@ -778,40 +774,36 @@
     }
 
     /* Now, delete the type library path subkey */
-    sprintf(subKeyName, "%lu\\%s", lcid, syskindName);
-    RegDeleteKeyA(key, subKeyName);
-    sprintf(subKeyName, "%lu", lcid);
-    RegDeleteKeyA(key, subKeyName);
+    get_lcid_subkey( lcid, syskind, subKeyName );
+    RegDeleteKeyW(key, subKeyName);
+    *strrchrW( subKeyName, '\\' ) = 0;  /* remove last path component */
+    RegDeleteKeyW(key, subKeyName);
 
     /* check if there is anything besides the FLAGS/HELPDIR keys.
        If there is, we don't delete them */
-    tmpLength = sizeof(subKeyName);
+    tmpLength = sizeof(subKeyName)/sizeof(WCHAR);
     deleteOtherStuff = TRUE;
     i = 0;
-    while(RegEnumKeyExA(key, i++, subKeyName, &tmpLength, NULL, NULL, NULL, NULL) == S_OK) {
-        tmpLength = sizeof(subKeyName);
+    while(RegEnumKeyExW(key, i++, subKeyName, &tmpLength, NULL, NULL, NULL, NULL) == S_OK) {
+        tmpLength = sizeof(subKeyName)/sizeof(WCHAR);
 
         /* if its not FLAGS or HELPDIR, then we must keep the rest of the key */
-        if (!strcmp(subKeyName, "FLAGS")) continue;
-        if (!strcmp(subKeyName, "HELPDIR")) continue;
+        if (!strcmpW(subKeyName, FLAGSW)) continue;
+        if (!strcmpW(subKeyName, HELPDIRW)) continue;
         deleteOtherStuff = FALSE;
         break;
     }
 
     /* only delete the other parts of the key if we're absolutely sure */
     if (deleteOtherStuff) {
-        RegDeleteKeyA(key, "FLAGS");
-        RegDeleteKeyA(key, "HELPDIR");
+        RegDeleteKeyW(key, FLAGSW);
+        RegDeleteKeyW(key, HELPDIRW);
         RegCloseKey(key);
         key = NULL;
 
-        StringFromGUID2(libid, guid, 80);
-        guidA = HEAP_strdupWtoA(GetProcessHeap(), 0, guid);
-        sprintf(keyName, "TypeLib\\%s\\%x.%x", guidA, wVerMajor, wVerMinor);
-        RegDeleteKeyA(HKEY_CLASSES_ROOT, keyName);
-        sprintf(keyName, "TypeLib\\%s", guidA);
-        RegDeleteKeyA(HKEY_CLASSES_ROOT, keyName);
-        HeapFree(GetProcessHeap(), 0, guidA);
+        RegDeleteKeyW(HKEY_CLASSES_ROOT, keyName);
+        *strrchrW( keyName, '\\' ) = 0;  /* remove last path component */
+        RegDeleteKeyW(HKEY_CLASSES_ROOT, keyName);
     }
 
 end:
@@ -854,8 +846,8 @@
 /* internal ITypeLib data */
 typedef struct tagITypeLibImpl
 {
-    ICOM_VFIELD(ITypeLib2);
-    ICOM_VTABLE(ITypeComp) * lpVtblTypeComp;
+    ITypeLib2Vtbl *lpVtbl;
+    ITypeCompVtbl *lpVtblTypeComp;
     UINT ref;
     TLIBATTR LibAttr;            /* guid,lcid,syskind,version,flags */
 
@@ -881,8 +873,8 @@
     WCHAR *path;
 } ITypeLibImpl;
 
-static struct ICOM_VTABLE(ITypeLib2) tlbvt;
-static struct ICOM_VTABLE(ITypeComp) tlbtcvt;
+static struct ITypeLib2Vtbl tlbvt;
+static struct ITypeCompVtbl tlbtcvt;
 
 #define _ITypeComp_Offset(impl) ((int)(&(((impl*)0)->lpVtblTypeComp)))
 #define ICOM_THIS_From_ITypeComp(impl, iface) impl* This = (impl*)(((char*)iface)-_ITypeComp_Offset(impl))
@@ -965,8 +957,8 @@
 /* internal TypeInfo data */
 typedef struct tagITypeInfoImpl
 {
-    ICOM_VFIELD(ITypeInfo2);
-    ICOM_VTABLE(ITypeComp) * lpVtblTypeComp;
+    ITypeInfo2Vtbl *lpVtbl;
+    ITypeCompVtbl  *lpVtblTypeComp;
     UINT ref;
     TYPEATTR TypeAttr ;         /* _lots_ of type information. */
     ITypeLibImpl * pTypeLib;        /* back pointer to typelib */
@@ -994,8 +986,8 @@
     struct tagITypeInfoImpl * next;
 } ITypeInfoImpl;
 
-static struct ICOM_VTABLE(ITypeInfo2) tinfvt;
-static struct ICOM_VTABLE(ITypeComp)  tcompvt;
+static struct ITypeInfo2Vtbl tinfvt;
+static struct ITypeCompVtbl  tcompvt;
 
 static ITypeInfo2 * WINAPI ITypeInfo_Constructor();
 
@@ -1044,6 +1036,7 @@
     case VT_UINT: sprintf(szVarType, "VT_UINT"); break;
     case VT_VARIANT: sprintf(szVarType, "VT_VARIANT"); break;
     case VT_VOID: sprintf(szVarType, "VT_VOID"); break;
+    case VT_HRESULT: sprintf(szVarType, "VT_HRESULT"); break;
     case VT_USERDEFINED: sprintf(szVarType, "VT_USERDEFINED ref = %lx",
 				 pTD->u.hreftype); break;
     case VT_PTR: sprintf(szVarType, "ptr to ");
@@ -1102,6 +1095,9 @@
   MESSAGE(")\n\toVft: %d\n", funcdesc->oVft);
   MESSAGE("\tcParamsOpt: %d\n", funcdesc->cParamsOpt);
   MESSAGE("\twFlags: %x\n", funcdesc->wFuncFlags);
+
+  MESSAGE("\telemdescFunc (return value type):\n");
+  dump_ELEMDESC(&funcdesc->elemdescFunc);
 }
 
 void dump_IDLDESC(IDLDESC *idl) {
@@ -1512,7 +1508,7 @@
         case VT_BSTR    :{
             char * ptr;
             MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK );
-	    if(size <= 0) {
+	    if(size < 0) {
 	        FIXME("BSTR length = %d?\n", size);
 	    } else {
                 ptr=TLB_Alloc(size);/* allocate temp buffer */
@@ -2164,7 +2160,7 @@
     hFile = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
     if (INVALID_HANDLE_VALUE != hFile)
     {
-      HANDLE hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL );
+      HANDLE hMapping = CreateFileMappingW( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL );
       if (hMapping)
       {
         LPVOID pBase = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
@@ -2197,8 +2193,8 @@
                                           LOAD_LIBRARY_AS_DATAFILE|LOAD_WITH_ALTERED_SEARCH_PATH);
       if (hinstDLL)
       {
-        HRSRC hrsrc = FindResourceA(hinstDLL, MAKEINTRESOURCEA(index),
-	  "TYPELIB");
+        static const WCHAR TYPELIBW[] = {'T','Y','P','E','L','I','B',0};
+        HRSRC hrsrc = FindResourceW(hinstDLL, MAKEINTRESOURCEW(index), TYPELIBW);
         if (hrsrc)
         {
           HGLOBAL hGlobal = LoadResource(hinstDLL, hrsrc);
@@ -2457,7 +2453,6 @@
         {
             *ppTI = MSFT_DoTypeInfo(&cx, i, pTypeLibImpl);
 
-            ITypeInfo_AddRef((ITypeInfo*) *ppTI);
             ppTI = &((*ppTI)->next);
             (pTypeLibImpl->TypeInfoCount)++;
         }
@@ -3369,7 +3364,7 @@
 	REFIID riid,
 	VOID **ppvObject)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     TRACE("(%p)->(IID: %s)\n",This,debugstr_guid(riid));
 
@@ -3395,7 +3390,7 @@
  */
 static ULONG WINAPI ITypeLib2_fnAddRef( ITypeLib2 *iface)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     TRACE("(%p)->ref was %u\n",This, This->ref);
 
@@ -3406,7 +3401,7 @@
  */
 static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     --(This->ref);
 
@@ -3464,7 +3459,7 @@
  */
 static UINT WINAPI ITypeLib2_fnGetTypeInfoCount( ITypeLib2 *iface)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     TRACE("(%p)->count is %d\n",This, This->TypeInfoCount);
     return This->TypeInfoCount;
 }
@@ -3480,7 +3475,7 @@
 {
     int i;
 
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     ITypeInfoImpl *pTypeInfo = This->pTypeInfo;
 
     TRACE("(%p)->(index=%d) \n", This, index);
@@ -3515,7 +3510,7 @@
     UINT index,
     TYPEKIND *pTKind)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     int i;
     ITypeInfoImpl *pTInfo = This->pTypeInfo;
 
@@ -3549,7 +3544,7 @@
     REFGUID guid,
     ITypeInfo **ppTInfo)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     ITypeInfoImpl *pTypeInfo = This->pTypeInfo; /* head of list */
 
     TRACE("(%p)\n\tguid:\t%s)\n",This,debugstr_guid(guid));
@@ -3587,7 +3582,7 @@
 	ITypeLib2 *iface,
 	LPTLIBATTR *ppTLibAttr)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     TRACE("(%p)\n",This);
     *ppTLibAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(**ppTLibAttr));
     memcpy(*ppTLibAttr, &This->LibAttr, sizeof(**ppTLibAttr));
@@ -3604,7 +3599,7 @@
 	ITypeLib2 *iface,
 	ITypeComp **ppTComp)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     TRACE("(%p)->(%p)\n",This,ppTComp);
     *ppTComp = (ITypeComp *)&This->lpVtblTypeComp;
@@ -3630,7 +3625,7 @@
     DWORD *pdwHelpContext,
     BSTR *pBstrHelpFile)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     HRESULT result = E_INVALIDARG;
 
@@ -3712,7 +3707,7 @@
 	ULONG lHashVal,
 	BOOL *pfName)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     ITypeInfoImpl *pTInfo;
     TLBFuncDesc *pFInfo;
     TLBVarDesc *pVInfo;
@@ -3758,7 +3753,7 @@
 	MEMBERID *rgMemId,
 	UINT16 *pcFound)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     ITypeInfoImpl *pTInfo;
     TLBFuncDesc *pFInfo;
     TLBVarDesc *pVInfo;
@@ -3799,7 +3794,7 @@
 	ITypeLib2 *iface,
 	TLIBATTR *pTLibAttr)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     TRACE("freeing (%p)\n",This);
     HeapFree(GetProcessHeap(),0,pTLibAttr);
 
@@ -3814,7 +3809,7 @@
 	REFGUID guid,
         VARIANT *pVarVal)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     TLBCustData *pCData;
 
     for(pCData=This->pCustData; pCData; pCData = pCData->next)
@@ -3844,7 +3839,7 @@
         ULONG *pcUniqueNames,
 	ULONG *pcchUniqueNames)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     FIXME("(%p): stub!\n", This);
 
@@ -3868,7 +3863,7 @@
         DWORD *pdwHelpStringContext,
 	BSTR *pbstrHelpStringDll)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     HRESULT result;
     ITypeInfo *pTInfo;
 
@@ -3929,7 +3924,7 @@
 	ITypeLib2 * iface,
         CUSTDATA *pCustData)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
     TLBCustData *pCData;
     int i;
     TRACE("(%p) returning %d items\n", This, This->ctCustData);
@@ -3947,8 +3942,7 @@
     return S_OK;
 }
 
-static ICOM_VTABLE(ITypeLib2) tlbvt = {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+static ITypeLib2Vtbl tlbvt = {
     ITypeLib2_fnQueryInterface,
     ITypeLib2_fnAddRef,
     ITypeLib2_fnRelease,
@@ -3994,8 +3988,8 @@
 static HRESULT WINAPI ITypeLibComp_fnBind(
     ITypeComp * iface,
     OLECHAR * szName,
-    unsigned long lHash,
-    unsigned short wFlags,
+    ULONG lHash,
+    WORD wFlags,
     ITypeInfo ** ppTInfo,
     DESCKIND * pDescKind,
     BINDPTR * pBindPtr)
@@ -4007,7 +4001,7 @@
 static HRESULT WINAPI ITypeLibComp_fnBindType(
     ITypeComp * iface,
     OLECHAR * szName,
-    unsigned long lHash,
+    ULONG lHash,
     ITypeInfo ** ppTInfo,
     ITypeComp ** ppTComp)
 {
@@ -4015,9 +4009,8 @@
     return E_NOTIMPL;
 }
 
-static ICOM_VTABLE(ITypeComp) tlbtcvt =
+static ITypeCompVtbl tlbtcvt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
 
     ITypeLibComp_fnQueryInterface,
     ITypeLibComp_fnAddRef,
@@ -4050,7 +4043,7 @@
 	REFIID riid,
 	VOID **ppvObject)
 {
-    ICOM_THIS( ITypeLibImpl, iface);
+    ITypeLibImpl *This = (ITypeLibImpl *)iface;
 
     TRACE("(%p)->(IID: %s)\n",This,debugstr_guid(riid));
 
@@ -4073,9 +4066,10 @@
  */
 static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
 
     ++(This->ref);
+    ITypeLib2_AddRef((ITypeLib2*)This->pTypeLib);
 
     TRACE("(%p)->ref is %u\n",This, This->ref);
     return This->ref;
@@ -4083,16 +4077,19 @@
 
 /* ITypeInfo::Release
  */
-static ULONG WINAPI ITypeInfo_fnRelease( ITypeInfo2 *iface)
+static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
 
     --(This->ref);
 
     TRACE("(%p)->(%u)\n",This, This->ref);
 
-    if (!This->ref)
-    {
+    if (This->ref)   {
+      /* We don't release ITypeLib when ref=0 becouse
+         it means that funtion is called by ITypeLi2_Release */
+      ITypeLib2_Release((ITypeLib2*)This->pTypeLib);
+    } else   {
       FIXME("destroy child objects\n");
 
       TRACE("destroying ITypeInfo(%p)\n",This);
@@ -4128,7 +4125,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetTypeAttr( ITypeInfo2 *iface,
         LPTYPEATTR  *ppTypeAttr)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     TRACE("(%p)\n",This);
     /* FIXME: must do a copy here */
     *ppTypeAttr=&This->TypeAttr;
@@ -4144,7 +4141,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetTypeComp( ITypeInfo2 *iface,
         ITypeComp  * *ppTComp)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
 
     TRACE("(%p)->(%p) stub!\n", This, ppTComp);
 
@@ -4162,7 +4159,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetFuncDesc( ITypeInfo2 *iface, UINT index,
         LPFUNCDESC  *ppFuncDesc)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     int i;
     TLBFuncDesc * pFDesc;
     TRACE("(%p) index %d\n", This, index);
@@ -4184,7 +4181,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetVarDesc( ITypeInfo2 *iface, UINT index,
         LPVARDESC  *ppVarDesc)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     int i;
     TLBVarDesc * pVDesc;
     TRACE("(%p) index %d\n", This, index);
@@ -4207,7 +4204,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
         BSTR  *rgBstrNames, UINT cMaxNames, UINT  *pcNames)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     TLBFuncDesc * pFDesc;
     TLBVarDesc * pVDesc;
     int i;
@@ -4275,7 +4272,7 @@
         UINT index,
 	HREFTYPE  *pRefType)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     int(i);
     TLBImplType *pImpl = This->impltypelist;
 
@@ -4327,7 +4324,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetImplTypeFlags( ITypeInfo2 *iface,
         UINT index, INT  *pImplTypeFlags)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     int i;
     TLBImplType *pImpl;
 
@@ -4350,7 +4347,7 @@
 static HRESULT WINAPI ITypeInfo_fnGetIDsOfNames( ITypeInfo2 *iface,
         LPOLESTR  *rgszNames, UINT cNames, MEMBERID  *pMemId)
 {
-    ICOM_THIS( ITypeInfoImpl, iface);
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
     TLBFuncDesc * pFDesc;
     TLBVarDesc * pVDesc;
     HRESULT ret=S_OK;
@@ -4468,7 +4465,7 @@
     return res;
 }
 
-extern int const _argsize(DWORD vt);
+extern int _argsize(DWORD vt);
 
 /****************************************************************************
  * Helper functions for Dispcall / Invoke, which copies one variant
@@ -4507,7 +4504,8 @@
 	return S_OK;
     }
     if (vt==VT_UNKNOWN && V_VT(arg)==VT_DISPATCH) {
-    	/* in this context, if the type lib specifies IUnknown*, giving an IDispatch* is correct; so, don't invoke VariantChangeType */
+    	/* in this context, if the type lib specifies IUnknown*, giving an
+           IDispatch* is correct; so, don't invoke VariantChangeType */
     	memcpy(argpos,&V_UNION(arg,lVal), arglen);
 	return S_OK;
     }
@@ -4515,82 +4513,110 @@
 	return _copy_arg(tinfo, tdesc->u.lptdesc, argpos, arg, tdesc->u.lptdesc->vt);
 
     if ((vt == VT_USERDEFINED) && tdesc && tinfo) {
-	ITypeInfo	*tinfo2;
-	TYPEATTR	*tattr;
+	ITypeInfo	*tinfo2 = NULL;
+	TYPEATTR	*tattr = NULL;
 	HRESULT		hres;
 
 	hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
 	if (hres) {
-	    FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED, while coercing from vt 0x%x. Copying 4 byte.\n",tdesc->u.hreftype,V_VT(arg));
+	    FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED, "
+                  "while coercing from vt 0x%x. Copying 4 byte.\n",
+                  tdesc->u.hreftype,V_VT(arg));
 	    memcpy(argpos, &V_UNION(arg,lVal), 4);
 	    return S_OK;
 	}
-	ITypeInfo_GetTypeAttr(tinfo2,&tattr);
+	hres = ITypeInfo_GetTypeAttr(tinfo2,&tattr);
+        if( hres )
+        {
+            ERR("GetTypeAttr failed\n");
+	    ITypeInfo_Release(tinfo2);
+            return hres;
+        }
 	switch (tattr->typekind) {
 	case TKIND_ENUM:
           switch ( V_VT( arg ) ) {
           case VT_I2:
              *argpos = V_UNION(arg,iVal);
-             return S_OK;
+             hres = S_OK;
+             break;
           case VT_I4:
              memcpy(argpos, &V_UNION(arg,lVal), 4);
-             return S_OK;
+             hres = S_OK;
+             break;
           default:
              FIXME("vt 0x%x -> TKIND_ENUM unhandled.\n",V_VT(arg));
+             hres = E_FAIL;
              break;
           }
+          break;
 
 	case TKIND_ALIAS:
 	    tdesc = &(tattr->tdescAlias);
 	    hres = _copy_arg((ITypeInfo2*)tinfo2, tdesc, argpos, arg, tdesc->vt);
-	    ITypeInfo_Release(tinfo2);
-	    return hres;
+	    break;
 
 	case TKIND_INTERFACE:
 	    if (V_VT(arg) == VT_DISPATCH) {
 		IDispatch *disp;
 		if (IsEqualIID(&IID_IDispatch,&(tattr->guid))) {
 		    memcpy(argpos, &V_UNION(arg,pdispVal), 4);
-		    return S_OK;
+		    hres = S_OK;
+                    break;
 		}
-		hres=IUnknown_QueryInterface(V_UNION(arg,pdispVal),&IID_IDispatch,(LPVOID*)&disp);
+		hres=IUnknown_QueryInterface(V_UNION(arg,pdispVal),
+                                             &IID_IDispatch,(LPVOID*)&disp);
 		if (SUCCEEDED(hres)) {
 		    memcpy(argpos,&disp,4);
 		    IUnknown_Release(V_UNION(arg,pdispVal));
-		    return S_OK;
+		    hres = S_OK;
+                    break;
 		}
-		FIXME("Failed to query IDispatch interface from %s while converting to VT_DISPATCH!\n",debugstr_guid(&(tattr->guid)));
-		return E_FAIL;
+		FIXME("Failed to query IDispatch interface from %s while "
+                     "converting to VT_DISPATCH!\n",debugstr_guid(&(tattr->guid)));
+		hres = E_FAIL;
+                break;
 	    }
 	    if (V_VT(arg) == VT_UNKNOWN) {
 		memcpy(argpos, &V_UNION(arg,punkVal), 4);
-		return S_OK;
+		hres = S_OK;
+                break;
[truncated at 1000 lines; 485 more skipped]

reactos/lib/oleaut32
typelib.h 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- typelib.h	7 Feb 2004 18:53:58 -0000	1.1
+++ typelib.h	8 Dec 2004 21:57:18 -0000	1.1.22.1
@@ -76,9 +76,9 @@
         INT   helpfile;         /* position of helpfile in stringtable */
 /*0x40*/INT   CustomDataOffset; /* if -1 no custom data, else it is offset */
                                 /* in customer data/guid offset table */
-        INT   res44;            /* unknown always: 0x20 */
-        INT   res48;            /* unknown always: 0x80 */
-        INT   dispatchpos;      /* gets a value (1+n*0x0c) with Idispatch interfaces */
+        INT   res44;            /* unknown always: 0x20 (guid hash size?) */
+        INT   res48;            /* unknown always: 0x80 (name hash size?) */
+        INT   dispatchpos;      /* HREFTYPE to IDispatch, or -1 if no IDispatch */
 /*0x50*/INT   res50;            /* is zero becomes one when an interface is derived */
 } MSFT_Header;
 
@@ -172,11 +172,11 @@
     INT   DataType;     /* data type of the memeber, eg return of function */
     INT   Flags;        /* something to do with attribute flags (LOWORD) */
 #ifdef WORDS_BIGENDIAN
-    INT16 res3;         /* some offset into dunno what */
+    INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
     INT16 VtableOffset; /* offset in vtable */
 #else
     INT16 VtableOffset; /* offset in vtable */
-    INT16 res3;         /* some offset into dunno what */
+    INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
 #endif
     INT   FKCCIC;       /* bit string with the following  */
                         /* meaning (bit 0 is the msb): */
@@ -226,11 +226,11 @@
     INT   DataType;     /* data type of the variable */
     INT   Flags;        /* VarFlags (LOWORD) */
 #ifdef WORDS_BIGENDIAN
-    INT16 res3;         /* some offset into dunno what */
+    INT16 vardescsize;  /* size of reconstituted VARDESC and related structs */
     INT16 VarKind;      /* VarKind */
 #else
     INT16 VarKind;      /* VarKind */
-    INT16 res3;         /* some offset into dunno what */
+    INT16 vardescsize;  /* size of reconstituted VARDESC and related structs */
 #endif
     INT   OffsValue;    /* value of the variable or the offset  */
                         /* in the data structure */
@@ -258,17 +258,23 @@
 /* this is how a guid is stored */
 typedef struct {
     GUID guid;
-    INT   unk10;        /* differntiate with libid, classid etc? */
-                        /* it's -2 for a libary */
-                        /* it's 0 for an interface */
-    INT   unk14;        /* always? -1 */
+    INT   hreftype;     /* -2 for the typelib guid, typeinfo offset
+			   for typeinfo guid, low two bits are 01 if
+			   this is an imported typeinfo, low two bits
+			   are 10 if this is an imported typelib (used
+			   by imported typeinfos) */
+    INT   next_hash;    /* offset to next guid in the hash bucket */
 } MSFT_GuidEntry;
 /* some data preceding entries in the name table */
 typedef struct {
-    INT   unk00;        /* sometimes -1 (lib, parameter) ,
-                           sometimes 0 (interface, func) */
-    INT   unk10;        /* sometimes -1 (lib) , sometimes 0 (interface, func),
-                           sometimes 0x10 (par) */
+    INT   hreftype;     /* is -1 if name is for neither a typeinfo,
+			   a variable, or a function (that is, name
+			   is for a typelib or a function parameter).
+			   otherwise is the offset of the first
+			   typeinfo that this name refers to (either
+			   to the typeinfo itself or to a member of
+			   the typeinfo */
+    INT   next_hash;    /* offset to next name in the hash bucket */
     INT   namelen;      /* only lower 8 bits are valid,
 			   lower-middle 8 bits are unknown (flags?),
 			   upper 16 bits are hash code */

reactos/lib/oleaut32
typelib2.c 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- typelib2.c	28 Feb 2004 19:16:54 -0000	1.2
+++ typelib2.c	8 Dec 2004 21:57:18 -0000	1.2.20.1
@@ -35,8 +35,10 @@
 #include <stdio.h>
 #include <ctype.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "winerror.h"
 #include "windef.h"
 #include "winbase.h"
@@ -46,7 +48,6 @@
 
 #include "wine/unicode.h"
 #include "objbase.h"
-#include "heap.h"
 #include "ole2disp.h"
 #include "typelib.h"
 #include "wine/debug.h"
@@ -146,8 +147,8 @@
 
 typedef struct tagICreateTypeLib2Impl
 {
-    ICOM_VFIELD(ICreateTypeLib2);
-    ICOM_VTABLE(ITypeLib2) *lpVtblTypeLib2;
+    ICreateTypeLib2Vtbl *lpVtbl;
+    ITypeLib2Vtbl       *lpVtblTypeLib2;
 
     UINT ref;
 
@@ -172,8 +173,8 @@
 
 typedef struct tagICreateTypeInfo2Impl
 {
-    ICOM_VFIELD(ICreateTypeInfo2);
-    ICOM_VTABLE(ITypeInfo2) *lpVtblTypeInfo2;
+    ICreateTypeInfo2Vtbl *lpVtbl;
+    ITypeInfo2Vtbl       *lpVtblTypeInfo2;
 
     UINT ref;
 
@@ -254,6 +255,58 @@
 }
 
 /****************************************************************************
+ *	ctl2_hash_guid
+ *
+ *  Generates a hash key from a GUID.
+ *
+ * RETURNS
+ *
+ *  The hash key for the GUID.
+ */
+static int ctl2_hash_guid(
+	REFGUID guid)                /* [I] The guid to find. */
+{
+    int hash;
+    int i;
+
+    hash = 0;
+    for (i = 0; i < 8; i ++) {
+	hash ^= ((const short *)guid)[i];
+    }
+
+    return (hash & 0xf) | ((hash & 0x10) & (0 - !!(hash & 0xe0)));
+}
+
+/****************************************************************************
+ *	ctl2_find_guid
+ *
+ *  Locates a guid in a type library.
+ *
+ * RETURNS
+ *
+ *  The offset into the GUID segment of the guid, or -1 if not found.
+ */
+static int ctl2_find_guid(
+	ICreateTypeLib2Impl *This, /* [I] The typelib to operate against. */
+	int hash_key,              /* [I] The hash key for the guid. */
+	REFGUID guid)                /* [I] The guid to find. */
+{
+    int offset;
+    MSFT_GuidEntry *guidentry;
+
+    offset = This->typelib_guidhash_segment[hash_key];
+    while (offset != -1) {
+	guidentry = (MSFT_GuidEntry *)&This->typelib_segment_data[MSFT_SEG_GUID][offset];
+
+	if (!memcmp(guidentry, guid, sizeof(GUID))) return offset;
+
+	offset = guidentry->next_hash;
+    }
+
+    return offset;
+}
+
+/****************************************************************************
  *	ctl2_find_name
  *
  *  Locates a name in a type library.
@@ -306,7 +359,7 @@
  */
 static int ctl2_encode_name(
 	ICreateTypeLib2Impl *This, /* [I] The typelib to operate against (used for LCID only). */
-	WCHAR *name,               /* [I] The name string to encode. */
+	const WCHAR *name,         /* [I] The name string to encode. */
 	char **result)             /* [O] A pointer to a pointer to receive the encoded name. */
 {
     int length;
@@ -350,7 +403,7 @@
  */
 static int ctl2_encode_string(
 	ICreateTypeLib2Impl *This, /* [I] The typelib to operate against (not used?). */
-	WCHAR *string,             /* [I] The string to encode. */
+	const WCHAR *string,       /* [I] The string to encode. */
 	char **result)             /* [O] A pointer to a pointer to receive the encoded string. */
 {
     int length;
@@ -497,17 +550,12 @@
 {
     int offset;
     MSFT_GuidEntry *guid_space;
-    int hash;
     int hash_key;
-    int i;
 
-    for (offset = 0; offset < This->typelib_segdir[MSFT_SEG_GUID].length;
-	 offset += sizeof(MSFT_GuidEntry)) {
-	if (!memcmp(&(This->typelib_segment_data[MSFT_SEG_GUID][offset]),
-		    guid, sizeof(GUID))) {
-	    return offset;
-	}
-    }
+    hash_key = ctl2_hash_guid(&guid->guid);
+
+    offset = ctl2_find_guid(This, hash_key, &guid->guid);
+    if (offset != -1) return offset;
 
     offset = ctl2_alloc_segment(This, MSFT_SEG_GUID, sizeof(MSFT_GuidEntry), 0);
     if (offset == -1) return -1;
@@ -515,17 +563,9 @@
     guid_space = (void *)(This->typelib_segment_data[MSFT_SEG_GUID] + offset);
     *guid_space = *guid;
 
-    hash = 0;
-    for (i = 0; i < 16; i += 2) {
-	hash ^= *((short *)&This->typelib_segment_data[MSFT_SEG_GUID][offset + i]);
-    }
-
-    hash_key = (hash & 0xf) | ((hash & 0x10) & (0 - !!(hash & 0xe0)));
-    guid_space->unk14 = This->typelib_guidhash_segment[hash_key];
+    guid_space->next_hash = This->typelib_guidhash_segment[hash_key];
     This->typelib_guidhash_segment[hash_key] = offset;
 
-    TRACE("Updating GUID hash table (%s,0x%x).\n", debugstr_guid(&guid->guid), hash);
-
     return offset;
 }
 
@@ -542,7 +582,7 @@
  */
 static int ctl2_alloc_name(
 	ICreateTypeLib2Impl *This, /* [I] The type library to allocate in. */
-	WCHAR *name)               /* [I] The name to store. */
+	const WCHAR *name)         /* [I] The name to store. */
 {
     int length;
     int offset;
@@ -558,12 +598,12 @@
     if (offset == -1) return -1;
 
     name_space = (void *)(This->typelib_segment_data[MSFT_SEG_NAME] + offset);
-    name_space->unk00 = -1;
-    name_space->unk10 = -1;
+    name_space->hreftype = -1;
+    name_space->next_hash = -1;
     memcpy(&name_space->namelen, encoded_name, length);
 
     if (This->typelib_namehash_segment[encoded_name[2] & 0x7f] != -1)
-	name_space->unk10 = This->typelib_namehash_segment[encoded_name[2] & 0x7f];
+	name_space->next_hash = This->typelib_namehash_segment[encoded_name[2] & 0x7f];
 
     This->typelib_namehash_segment[encoded_name[2] & 0x7f] = offset;
 
@@ -585,7 +625,7 @@
  */
 static int ctl2_alloc_string(
 	ICreateTypeLib2Impl *This, /* [I] The type library to allocate in. */
-	WCHAR *string)             /* [I] The string to store. */
+	const WCHAR *string)       /* [I] The string to store. */
 {
     int length;
     int offset;
@@ -659,7 +699,7 @@
 	int guidoffset,            /* [I] The offset to the GUID for the imported library. */
 	int major_version,         /* [I] The major version number of the imported library. */
 	int minor_version,         /* [I] The minor version number of the imported library. */
-	WCHAR *filename)           /* [I] The filename of the imported library. */
+	const WCHAR *filename)     /* [I] The filename of the imported library. */
 {
     int length;
     int offset;
@@ -751,8 +791,8 @@
 
     guidentry.guid = *guid;
 
-    guidentry.unk10 = -1;
-    guidentry.unk14 = -1;
+    guidentry.hreftype = -1;
+    guidentry.next_hash = -1;
 
     guidoffset = ctl2_alloc_guid(This, &guidentry);
     if (guidoffset == -1) return E_OUTOFMEMORY;
@@ -1020,6 +1060,39 @@
     return offset;
 }
 
+/****************************************************************************
+ *	ctl2_find_typeinfo_from_offset
+ *
+ *  Finds an ITypeInfo given an offset into the TYPEINFO segment.
+ *
+ * RETURNS
+ *
+ *  Success: S_OK.
+ *  Failure: TYPE_E_ELEMENTNOTFOUND.
+ */
+static HRESULT ctl2_find_typeinfo_from_offset(
+	ICreateTypeLib2Impl *This, /* [I] The typelib to find the typeinfo in. */
+	int offset,                /* [I] The offset of the desired typeinfo. */
+	ITypeInfo **ppTinfo)       /* [I] The typeinfo found. */
+{
+    void *typeinfodata;
+    ICreateTypeInfo2Impl *typeinfo;
+
+    typeinfodata = &This->typelib_segment_data[MSFT_SEG_TYPEINFO][offset];
+
+    for (typeinfo = This->typeinfos; typeinfo; typeinfo = typeinfo->next_typeinfo) {
+	if (typeinfo->typeinfo == typeinfodata) {
+	    *ppTinfo = (ITypeInfo *)&typeinfo->lpVtblTypeInfo2;
+	    ITypeInfo2_AddRef(*ppTinfo);
+	    return S_OK;
+	}
+    }
+
+    ERR("Failed to find typeinfo, invariant varied.\n");
+
+    return TYPE_E_ELEMENTNOTFOUND;
+}
+
 /*================== ICreateTypeInfo2 Implementation ===================================*/
 
 /******************************************************************************
@@ -1032,7 +1105,7 @@
 	REFIID riid,
 	VOID **ppvObject)
 {
-    ICOM_THIS( ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p)->(IID: %s)\n",This,debugstr_guid(riid));
 
@@ -1064,7 +1137,7 @@
  */
 static ULONG WINAPI ICreateTypeInfo2_fnAddRef(ICreateTypeInfo2 *iface)
 {
-    ICOM_THIS( ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p)->ref was %u\n",This, This->ref);
 
@@ -1078,7 +1151,7 @@
  */
 static ULONG WINAPI ICreateTypeInfo2_fnRelease(ICreateTypeInfo2 *iface)
 {
-    ICOM_THIS( ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     --(This->ref);
 
@@ -1106,7 +1179,7 @@
  */
 static HRESULT WINAPI ICreateTypeInfo2_fnSetGuid(ICreateTypeInfo2 *iface, REFGUID guid)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     MSFT_GuidEntry guidentry;
     int offset;
@@ -1114,8 +1187,8 @@
     TRACE("(%p,%s)\n", iface, debugstr_guid(guid));
 
     guidentry.guid = *guid;
-    guidentry.unk10 = 0;
-    guidentry.unk14 = 0x18;
+    guidentry.hreftype = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
+    guidentry.next_hash = -1;
 
     offset = ctl2_alloc_guid(This->typelib, &guidentry);
     
@@ -1123,6 +1196,10 @@
 
     This->typeinfo->posguid = offset;
 
+    if (IsEqualIID(guid, &IID_IDispatch)) {
+	This->typelib->typelib_header.dispatchpos = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
+    }
+
     return S_OK;
 }
 
@@ -1133,7 +1210,7 @@
  */
 static HRESULT WINAPI ICreateTypeInfo2_fnSetTypeFlags(ICreateTypeInfo2 *iface, UINT uTypeFlags)
 {
-    ICOM_THIS( ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p,0x%x)\n", iface, uTypeFlags);
 
@@ -1144,11 +1221,11 @@
 	int guidoffset;
 	int fileoffset;
 	MSFT_ImpInfo impinfo;
-	WCHAR stdole2tlb[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
+	static const WCHAR stdole2tlb[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
 
 	foo.guid = IID_StdOle;
-	foo.unk10 = 2;
-	foo.unk14 = -1;
+	foo.hreftype = 2;
+	foo.next_hash = -1;
 	guidoffset = ctl2_alloc_guid(This->typelib, &foo);
 	if (guidoffset == -1) return E_OUTOFMEMORY;
 
@@ -1156,8 +1233,8 @@
 	if (fileoffset == -1) return E_OUTOFMEMORY;
 
 	foo.guid = IID_IDispatch;
-	foo.unk10 = 1;
-	foo.unk14 = -1;
+	foo.hreftype = 1;
+	foo.next_hash = -1;
 	guidoffset = ctl2_alloc_guid(This->typelib, &foo);
 	if (guidoffset == -1) return E_OUTOFMEMORY;
 
@@ -1186,7 +1263,7 @@
         ICreateTypeInfo2* iface,
         LPOLESTR pStrDoc)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     int offset;
 
@@ -1207,8 +1284,13 @@
         ICreateTypeInfo2* iface,
         DWORD dwHelpContext)
 {
-    FIXME("(%p,%ld), stub!\n", iface, dwHelpContext);
-    return E_OUTOFMEMORY;
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
+
+    TRACE("(%p,%ld)\n", iface, dwHelpContext);
+
+    This->typeinfo->helpcontext = dwHelpContext;
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -1221,7 +1303,7 @@
         WORD wMajorVerNum,
         WORD wMinorVerNum)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p,%d,%d)\n", iface, wMajorVerNum, wMinorVerNum);
 
@@ -1239,7 +1321,7 @@
         ITypeInfo* pTInfo,
         HREFTYPE* phRefType)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     ITypeLib *container;
     int index;
@@ -1281,7 +1363,7 @@
         UINT index,
         FUNCDESC* pFuncDesc)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     int offset;
     int *typedata;
@@ -1365,7 +1447,7 @@
         UINT index,
         HREFTYPE hRefType)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p,%d,%ld)\n", iface, index, hRefType);
 
@@ -1434,7 +1516,7 @@
         UINT index,
         INT implTypeFlags)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
     int offset;
     MSFT_RefRecord *ref;
 
@@ -1462,7 +1544,7 @@
         ICreateTypeInfo2* iface,
         WORD cbAlignment)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     TRACE("(%p,%d)\n", iface, cbAlignment);
 
@@ -1520,7 +1602,7 @@
         UINT index,
         VARDESC* pVarDesc)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
     int offset;
     INT *typedata;
     int var_datawidth;
@@ -1613,7 +1695,7 @@
         LPOLESTR* rgszNames,
         UINT cNames)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     int i;
     int offset;
@@ -1651,7 +1733,7 @@
         UINT index,
         LPOLESTR szName)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
     int offset;
     char *namedata;
 
@@ -1666,8 +1748,10 @@
     if (offset == -1) return E_OUTOFMEMORY;
 
     namedata = This->typelib->typelib_segment_data[MSFT_SEG_NAME] + offset;
-    *((INT *)namedata) = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
-    namedata[9] = 0x10;
+    if (*((INT *)namedata) == -1) {
+	*((INT *)namedata) = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
+	namedata[9] |= 0x10;
+    }
     if ((This->typeinfo->typekind & 15) == TKIND_ENUM) {
 	namedata[9] |= 0x20;
     }
@@ -1685,8 +1769,25 @@
         ICreateTypeInfo2* iface,
         TYPEDESC* pTDescAlias)
 {
-    FIXME("(%p,%p), stub!\n", iface, pTDescAlias);
-    return E_OUTOFMEMORY;
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
+
+    int encoded_typedesc;
+    int width;
+
+    if ((This->typeinfo->typekind & 15) != TKIND_ALIAS) {
+	return TYPE_E_WRONGTYPEKIND;
+    }
+
+    FIXME("(%p,%p), hack!\n", iface, pTDescAlias);
+
+    if (ctl2_encode_typedesc(This->typelib, pTDescAlias, &encoded_typedesc, &width, NULL, NULL) == -1) {
+	return E_OUTOFMEMORY;
+    }
+
+    This->typeinfo->size = width;
+    This->typeinfo->datatype1 = encoded_typedesc;
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -1728,7 +1829,7 @@
         UINT index,
         LPOLESTR szDocString)
 {
-    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+    ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
 
     FIXME("(%p,%d,%s), stub!\n", iface, index, debugstr_w(szDocString));
 
@@ -2698,9 +2799,8 @@
 
 /*================== ICreateTypeInfo2 & ITypeInfo2 VTABLEs And Creation ===================================*/
 
-static ICOM_VTABLE(ICreateTypeInfo2) ctypeinfo2vt =
+static ICreateTypeInfo2Vtbl ctypeinfo2vt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
 
     ICreateTypeInfo2_fnQueryInterface,
     ICreateTypeInfo2_fnAddRef,
@@ -2747,9 +2847,8 @@
     ICreateTypeInfo2_fnSetName
 };
 
-static ICOM_VTABLE(ITypeInfo2) typeinfo2vt =
+static ITypeInfo2Vtbl typeinfo2vt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
 
     ITypeInfo2_fnQueryInterface,
     ITypeInfo2_fnAddRef,
@@ -2873,7 +2972,7 @@
 	REFIID riid,
 	VOID **ppvObject)
 {
-    ICOM_THIS( ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p)->(IID: %s)\n",This,debugstr_guid(riid));
 
@@ -2905,7 +3004,7 @@
  */
 static ULONG WINAPI ICreateTypeLib2_fnAddRef(ICreateTypeLib2 *iface)
 {
-    ICOM_THIS( ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p)->ref was %u\n",This, This->ref);
 
@@ -2919,7 +3018,7 @@
  */
 static ULONG WINAPI ICreateTypeLib2_fnRelease(ICreateTypeLib2 *iface)
 {
-    ICOM_THIS( ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     --(This->ref);
 
@@ -2966,7 +3065,7 @@
 	TYPEKIND tkind,
 	ICreateTypeInfo **ppCTInfo)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p,%s,%d,%p)\n", iface, debugstr_w(szName), tkind, ppCTInfo);
 
@@ -2986,7 +3085,7 @@
 	ICreateTypeLib2 * iface,
 	LPOLESTR szName)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     int offset;
 
@@ -3005,7 +3104,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetVersion(ICreateTypeLib2 * iface, WORD wMajorVerNum, WORD wMinorVerNum)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p,%d,%d)\n", iface, wMajorVerNum, wMinorVerNum);
 
@@ -3020,7 +3119,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetGuid(ICreateTypeLib2 * iface, REFGUID guid)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     MSFT_GuidEntry guidentry;
     int offset;
@@ -3028,8 +3127,8 @@
     TRACE("(%p,%s)\n", iface, debugstr_guid(guid));
 
     guidentry.guid = *guid;
-    guidentry.unk10 = -2;
-    guidentry.unk14 = -1;
+    guidentry.hreftype = -2;
+    guidentry.next_hash = -1;
 
     offset = ctl2_alloc_guid(This, &guidentry);
     
@@ -3047,7 +3146,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetDocString(ICreateTypeLib2 * iface, LPOLESTR szDoc)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     int offset;
 
@@ -3066,7 +3165,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetHelpFileName(ICreateTypeLib2 * iface, LPOLESTR szHelpFileName)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     int offset;
 
@@ -3097,7 +3196,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetLcid(ICreateTypeLib2 * iface, LCID lcid)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p,%ld)\n", iface, lcid);
 
@@ -3113,7 +3212,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSetLibFlags(ICreateTypeLib2 * iface, UINT uLibFlags)
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p,0x%x)\n", iface, uLibFlags);
 
@@ -3124,14 +3223,19 @@
 
 static int ctl2_write_chunk(HANDLE hFile, void *segment, int length)
 {
-    if (!WriteFile(hFile, segment, length, NULL, 0)) {CloseHandle(hFile); return 0;}
+    DWORD dwWritten;
+    if (!WriteFile(hFile, segment, length, &dwWritten, 0)) {
+        CloseHandle(hFile);
+        return 0;
+    }
     return -1;
 }
 
 static int ctl2_write_segment(ICreateTypeLib2Impl *This, HANDLE hFile, int segment)
 {
+    DWORD dwWritten;
     if (!WriteFile(hFile, This->typelib_segment_data[segment],
-		   This->typelib_segdir[segment].length, NULL, 0)) {
+		   This->typelib_segdir[segment].length, &dwWritten, 0)) {
 	CloseHandle(hFile);
 	return 0;
     }
@@ -3184,7 +3288,7 @@
  */
 static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface)
 {
-    ICOM_THIS( ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     int retval;
     int filepos;
@@ -3275,7 +3379,7 @@
 	REFGUID guid,            /* [I] The GUID used as a key to retrieve the custom data. */
 	VARIANT *pVarVal)        /* [I] The custom data itself. */
 {
-    ICOM_THIS(ICreateTypeLib2Impl, iface);
+    ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
 
     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(guid), pVarVal);
 
@@ -3364,11 +3468,11 @@
 static UINT WINAPI ITypeLib2_fnGetTypeInfoCount(
         ITypeLib2 * iface)
 {
-/*     ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface); */
+    ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface);
 
-    FIXME("(%p), stub!\n", iface);
+    TRACE("(%p)\n", iface);
 
-    return 0;
+    return This->typelib_header.nrtypeinfos;
 }
 
 /******************************************************************************
@@ -3381,11 +3485,15 @@
         UINT index,
         ITypeInfo** ppTInfo)
 {
-/*     ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface); */
+    ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface);
 
-    FIXME("(%p,%d,%p), stub!\n", iface, index, ppTInfo);
+    TRACE("(%p,%d,%p)\n", iface, index, ppTInfo);
 
-    return E_OUTOFMEMORY;
+    if ((index < 0) || (index >= This->typelib_header.nrtypeinfos)) {
+	return TYPE_E_ELEMENTNOTFOUND;
+    }
+
+    return ctl2_find_typeinfo_from_offset(This, This->typelib_typeinfo_offsets[index], ppTInfo);
 }
 
 /******************************************************************************
@@ -3398,11 +3506,17 @@
         UINT index,
         TYPEKIND* pTKind)
 {
-/*     ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface); */
+    ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface);
 
-    FIXME("(%p,%d,%p), stub!\n", iface, index, pTKind);
+    TRACE("(%p,%d,%p)\n", iface, index, pTKind);
 
-    return E_OUTOFMEMORY;
+    if ((index < 0) || (index >= This->typelib_header.nrtypeinfos)) {
+	return TYPE_E_ELEMENTNOTFOUND;
+    }
+
+    *pTKind = (This->typelib_segment_data[MSFT_SEG_TYPEINFO][This->typelib_typeinfo_offsets[index]]) & 15;
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -3415,11 +3529,20 @@
         REFGUID guid,
         ITypeInfo** ppTinfo)
 {
-/*     ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface); */
+    ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface);
 
-    FIXME("(%p,%s,%p), stub!\n", iface, debugstr_guid(guid), ppTinfo);
+    int guidoffset;
+    int typeinfo;
 
-    return E_OUTOFMEMORY;
+    TRACE("(%p,%s,%p)\n", iface, debugstr_guid(guid), ppTinfo);
+
+    guidoffset = ctl2_find_guid(This, ctl2_hash_guid(guid), guid);
+    if (guidoffset == -1) return TYPE_E_ELEMENTNOTFOUND;
+
+    typeinfo = ((MSFT_GuidEntry *)&This->typelib_segment_data[MSFT_SEG_GUID][guidoffset])->hreftype;
+    if (typeinfo < 0) return TYPE_E_ELEMENTNOTFOUND;
+
+    return ctl2_find_typeinfo_from_offset(This, typeinfo, ppTinfo);
 }
 
 /******************************************************************************
@@ -3485,11 +3608,29 @@
         ULONG lHashVal,
         BOOL* pfName)
 {
-/*     ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface); */
+    ICOM_THIS_From_ITypeLib2(ICreateTypeLib2Impl, iface);
+
+    char *encoded_name;
+    int nameoffset;
+    MSFT_NameIntro *nameintro;
 
-    FIXME("(%p,%s,%lx,%p), stub!\n", iface, debugstr_w(szNameBuf), lHashVal, pfName);
+    TRACE("(%p,%s,%lx,%p)\n", iface, debugstr_w(szNameBuf), lHashVal, pfName);
 
-    return E_OUTOFMEMORY;
+    ctl2_encode_name(This, szNameBuf, &encoded_name);
+    nameoffset = ctl2_find_name(This, encoded_name);
+
+    *pfName = 0;
+
+    if (nameoffset == -1) return S_OK;
+
+    nameintro = (MSFT_NameIntro *)(&This->typelib_segment_data[MSFT_SEG_NAME][nameoffset]);
+    if (nameintro->hreftype == -1) return S_OK;
+
+    *pfName = 1;
+
+    FIXME("Should be decoding our copy of the name over szNameBuf.\n");
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -3620,9 +3761,8 @@
 
 /*================== ICreateTypeLib2 & ITypeLib2 VTABLEs And Creation ===================================*/
 
-static ICOM_VTABLE(ICreateTypeLib2) ctypelib2vt =
+static ICreateTypeLib2Vtbl ctypelib2vt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
 
     ICreateTypeLib2_fnQueryInterface,
     ICreateTypeLib2_fnAddRef,
@@ -3645,9 +3785,8 @@
     ICreateTypeLib2_fnSetHelpStringDll
 };
 
-static ICOM_VTABLE(ITypeLib2) typelib2vt =
+static ITypeLib2Vtbl typelib2vt =
 {
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
 
     ITypeLib2_fnQueryInterface,
     ITypeLib2_fnAddRef,
@@ -3742,3 +3881,33 @@
     *ppctlib = ICreateTypeLib2_Constructor(syskind, szFile);
     return (*ppctlib)? S_OK: E_OUTOFMEMORY;
 }
+
+/******************************************************************************
+ * ClearCustData (OLEAUT32.171)
+ *
+ * Clear a custom data types' data.
+ *
+ * PARAMS
+ *  lpCust [I] The custom data type instance
+ *
+ * RETURNS
+ *  Nothing.
+ */
+void WINAPI ClearCustData(LPCUSTDATA lpCust)
+{
+    if (lpCust && lpCust->cCustData)
+    {
+        if (lpCust->prgCustData)
+        {
+            DWORD i;
+
+            for (i = 0; i < lpCust->cCustData; i++)
+                VariantClear(&lpCust->prgCustData[i].varValue);
+
+            /* FIXME - Should be using a per-thread IMalloc */
+            HeapFree(GetProcessHeap(), 0, lpCust->prgCustData);
+            lpCust->prgCustData = NULL;
+        }
+        lpCust->cCustData = 0;
+    }
+}

reactos/lib/oleaut32
usrmarshal.c 1.1 -> 1.1.22.1
diff -u -r1.1 -r1.1.22.1
--- usrmarshal.c	7 Feb 2004 18:53:59 -0000	1.1
+++ usrmarshal.c	8 Dec 2004 21:57:18 -0000	1.1.22.1
@@ -22,8 +22,10 @@
 #include <stdarg.h>
 #include <string.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"

reactos/lib/oleaut32
varformat.c 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- varformat.c	28 Feb 2004 19:16:54 -0000	1.2
+++ varformat.c	8 Dec 2004 21:57:18 -0000	1.2.20.1
@@ -35,13 +35,12 @@
 #define NONAMELESSSTRUCT
 #include "windef.h"
 #include "winbase.h"
-#include "oleauto.h"
-#include "wine/debug.h"
 #include "wine/unicode.h"
 #include "winerror.h"
 #include "variant.h"
+#include "wine/debug.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
+WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
 /* Make sure internal conversions to strings use the '.','+'/'-' and ','
  * format chars from the US locale. This enables us to parse the created
@@ -1387,7 +1386,7 @@
         TRACE("write %d fractional digits or skip\n", pToken[1]);
 
         for (count = 0; count < fractionalDigits; count++)
-          pBuff[count] = rgbDig[wholeNumberDigits + count];
+          pBuff[count] = '0' + rgbDig[wholeNumberDigits + count];
         pBuff += fractionalDigits;
       }
       else
@@ -1417,7 +1416,7 @@
         TRACE("write %d fractional digits or 0's\n", pToken[1]);
 
         for (count = 0; count < fractionalDigits; count++)
-          pBuff[count] = rgbDig[wholeNumberDigits + count];
+          pBuff[count] = '0' + rgbDig[wholeNumberDigits + count];
         pBuff += fractionalDigits;
         if (pToken[1] > fractionalDigits)
         {

reactos/lib/oleaut32
variant.c 1.10 -> 1.10.20.1
diff -u -r1.10 -r1.10.20.1
--- variant.c	2 Mar 2004 10:25:58 -0000	1.10
+++ variant.c	8 Dec 2004 21:57:18 -0000	1.10.20.1
@@ -28,17 +28,18 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "windef.h"
 #include "winbase.h"
-#include "oleauto.h"
-#include "wine/debug.h"
 #include "wine/unicode.h"
 #include "winerror.h"
 #include "variant.h"
+#include "wine/debug.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
+WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
 const char* wine_vtypes[VT_CLSID] =
 {
@@ -79,6 +80,7 @@
 {
   HRESULT res = DISP_E_TYPEMISMATCH;
   VARTYPE vtFrom =  V_TYPE(ps);
+  BOOL bIgnoreOverflow = FALSE;
   DWORD dwFlags = 0;
 
   TRACE("(%p->(%s%s),0x%08lx,0x%04x,%p->(%s%s),%s%s)\n", pd, debugstr_VT(pd),
@@ -113,7 +115,11 @@
   if (vtFrom == VT_INT)
     vtFrom = VT_I4;
   else if (vtFrom == VT_UINT)
-     vtFrom = VT_UI4;
+  {
+    vtFrom = VT_UI4;
+    if (vt == VT_I4)
+      bIgnoreOverflow = TRUE;
+  }
 
   if (vt == vtFrom)
      return VariantCopy(pd, ps);
@@ -193,7 +199,14 @@
     case VT_I2:       return VarI4FromI2(V_I2(ps), &V_I4(pd));
     case VT_UI1:      return VarI4FromUI1(V_UI1(ps), &V_I4(pd));
     case VT_UI2:      return VarI4FromUI2(V_UI2(ps), &V_I4(pd));
-    case VT_UI4:      return VarI4FromUI4(V_UI4(ps), &V_I4(pd));
+    case VT_UI4:      
+          if (bIgnoreOverflow)
+          {
+            V_VT(pd) = VT_I4;
+            V_I4(pd) = V_I4(ps);
+            return S_OK;
+          }
+          return VarI4FromUI4(V_UI4(ps), &V_I4(pd));
     case VT_I8:       return VarI4FromI8(V_I8(ps), &V_I4(pd));
     case VT_UI8:      return VarI4FromUI8(V_UI8(ps), &V_I4(pd));
     case VT_R4:       return VarI4FromR4(V_R4(ps), &V_I4(pd));
@@ -449,7 +462,6 @@
     case VT_DATE:     return VarCyFromDate(V_DATE(ps), &V_CY(pd));
     case VT_BOOL:     return VarCyFromBool(V_BOOL(ps), &V_CY(pd));
     case VT_DECIMAL:  return VarCyFromDec(&V_DECIMAL(ps), &V_CY(pd));
-
     case VT_DISPATCH: return VarCyFromDisp(V_DISPATCH(ps), lcid, &V_CY(pd));
     case VT_BSTR:     return VarCyFromStr(V_BSTR(ps), lcid, dwFlags, &V_CY(pd));
     }
@@ -608,7 +620,6 @@
         if (V_BSTR(pVarg))
           SysFreeString(V_BSTR(pVarg));
       }
-#ifndef __REACTOS__	/*FIXME: problems with MinGW and brecVal */
       else if (V_VT(pVarg) == VT_RECORD)
       {
         struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
@@ -618,7 +629,6 @@
           IRecordInfo_Release(pBr->pRecInfo);
         }
       }
-#endif
       else if (V_VT(pVarg) == VT_DISPATCH ||
                V_VT(pVarg) == VT_UNKNOWN)
       {
@@ -636,7 +646,6 @@
   return hres;
 }
 
-#ifndef __REACTOS__	/*FIXME: missing __tagBRECORD in MinGW */
 /******************************************************************************
  * Copy an IRecordInfo object contained in a variant.
  */
@@ -669,7 +678,6 @@
     hres = E_INVALIDARG;
   return hres;
 }
-#endif
 
 /******************************************************************************
  *    VariantCopy  [OLEAUT32.10]
@@ -735,12 +743,10 @@
 	  }
         }
       }
-#ifndef __REACTOS__	/*FIXME: missing __tagBRECORD in MinGW */
       else if (V_VT(pvargSrc) == VT_RECORD)
       {
         hres = VARIANT_CopyIRecordInfo(&V_UNION(pvargDest,brecVal));
       }
-#endif
       else if (V_VT(pvargSrc) == VT_DISPATCH ||
                V_VT(pvargSrc) == VT_UNKNOWN)
       {
@@ -862,13 +868,11 @@
     /* Native doesn't check that *V_BSTRREF(pSrc) is valid */
     V_BSTR(pvargDest) = SysAllocStringByteLen((char*)*V_BSTRREF(pSrc), SysStringByteLen(*V_BSTRREF(pSrc)));
   }
-#ifndef __REACTOS__	/*FIXME: missing __tagBRECORD in MinGW */
   else if (V_VT(pSrc) == (VT_RECORD|VT_BYREF))
   {
     V_UNION(pvargDest,brecVal) = V_UNION(pvargSrc,brecVal);
     hres = VARIANT_CopyIRecordInfo(&V_UNION(pvargDest,brecVal));
   }
-#endif
   else if (V_VT(pSrc) == (VT_DISPATCH|VT_BYREF) ||
            V_VT(pSrc) == (VT_UNKNOWN|VT_BYREF))
   {
@@ -978,26 +982,35 @@
 
       if (SUCCEEDED(res))
       {
-        VARIANTARG vTmp;
+        VARIANTARG vTmp, vSrcDeref;
 
-        V_VT(&vTmp) = VT_EMPTY;
-        res = VariantCopyInd(&vTmp, pvargSrc);
+        if(V_VT(pvargSrc)&VT_BYREF && !V_BYREF(pvargSrc))
+          res = DISP_E_TYPEMISMATCH;
+        else
+        {
+          V_VT(&vTmp) = VT_EMPTY;
+          V_VT(&vSrcDeref) = VT_EMPTY;
+          VariantClear(&vTmp);
+          VariantClear(&vSrcDeref);
+        }
 
         if (SUCCEEDED(res))
         {
-          res = VariantClear(pvargDest);
-
+          res = VariantCopyInd(&vSrcDeref, pvargSrc);
           if (SUCCEEDED(res))
           {
-            if (V_ISARRAY(&vTmp) || (vt & VT_ARRAY))
-              res = VARIANT_CoerceArray(pvargDest, &vTmp, vt);
+            if (V_ISARRAY(&vSrcDeref) || (vt & VT_ARRAY))
+              res = VARIANT_CoerceArray(&vTmp, &vSrcDeref, vt);
             else
-              res = VARIANT_Coerce(pvargDest, lcid, wFlags, &vTmp, vt);
+              res = VARIANT_Coerce(&vTmp, lcid, wFlags, &vSrcDeref, vt);
 
-            if (SUCCEEDED(res))
-              V_VT(pvargDest) = vt;
+            if (SUCCEEDED(res)) {
+                V_VT(&vTmp) = vt;
+                VariantCopy(pvargDest, &vTmp);
+            }
+            VariantClear(&vTmp);
+            VariantClear(&vSrcDeref);
           }
-          VariantClear(&vTmp);
         }
       }
     }
@@ -1289,12 +1302,13 @@
 }
 
 /***********************************************************************
- *              VarDateFromUdate [OLEAUT32.330]
+ *              VarDateFromUdateEx [OLEAUT32.319]
  *
  * Convert an unpacked format date and time to a variant VT_DATE.
  *
  * PARAMS
  *  pUdateIn [I] Unpacked format date and time to convert
+ *  lcid     [I] Locale identifier for the conversion
  *  dwFlags  [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
  *  pDateOut [O] Destination for variant VT_DATE.
  *
@@ -1302,17 +1316,20 @@
  *  Success: S_OK. *pDateOut contains the converted value.
  *  Failure: E_INVALIDARG, if pUdateIn cannot be represented in VT_DATE format.
  */
-HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
+HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
 {
   UDATE ud;
   double dateVal;
 
-  TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08lx,%p)\n", pUdateIn,
+  TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08lx,0x%08lx,%p)\n", pUdateIn,
         pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
         pUdateIn->st.wHour, pUdateIn->st.wMinute, pUdateIn->st.wSecond,
         pUdateIn->st.wMilliseconds, pUdateIn->st.wDayOfWeek,
-        pUdateIn->wDayOfYear, dwFlags, pDateOut);
+        pUdateIn->wDayOfYear, lcid, dwFlags, pDateOut);
 
+  if (lcid != MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
+    FIXME("lcid possibly not handled, treating as en-us\n");
+      
   memcpy(&ud, pUdateIn, sizeof(ud));
 
   if (dwFlags & VAR_VALIDDATE)
@@ -1336,6 +1353,31 @@
 }
 
 /***********************************************************************
+ *              VarDateFromUdate [OLEAUT32.330]
+ *
+ * Convert an unpacked format date and time to a variant VT_DATE.
+ *
+ * PARAMS
+ *  pUdateIn [I] Unpacked format date and time to convert
+ *  dwFlags  [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
+ *  pDateOut [O] Destination for variant VT_DATE.
+ *
+ * RETURNS
+ *  Success: S_OK. *pDateOut contains the converted value.
+ *  Failure: E_INVALIDARG, if pUdateIn cannot be represented in VT_DATE format.
+ *
+ * NOTES
+ *  This function uses the United States English locale for the conversion. Use
+ *  VarDateFromUdateEx() for alternate locales.
+ */
+HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
+{
+  LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
+  
+  return VarDateFromUdateEx(pUdateIn, lcid, dwFlags, pDateOut);
+}
+
+/***********************************************************************
  *              VarUdateFromDate [OLEAUT32.331]
  *
  * Convert a variant VT_DATE into an unpacked format date and time.
@@ -1473,6 +1515,8 @@
 #define B_EXPONENT_START      0x4
 #define B_INEXACT_ZEROS       0x8
 #define B_LEADING_ZERO        0x10
+#define B_PROCESSING_HEX      0x20
+#define B_PROCESSING_OCT      0x40
 
 /**********************************************************************
  *              VarParseNumFromStr [OLEAUT32.46]
@@ -1590,6 +1634,23 @@
     chars.cCurrencyDigitSeperator = chars.cDigitSeperator;
   }
 
+  if ((*lpszStr == '&' && (*(lpszStr+1) == 'H' || *(lpszStr+1) == 'h')) &&
+    pNumprs->dwInFlags & NUMPRS_HEX_OCT)
+  {
+      dwState |= B_PROCESSING_HEX;
+      pNumprs->dwOutFlags |= NUMPRS_HEX_OCT;
+      cchUsed=cchUsed+2;
+      lpszStr=lpszStr+2;
+  }
+  else if ((*lpszStr == '&' && (*(lpszStr+1) == 'O' || *(lpszStr+1) == 'o')) &&
+    pNumprs->dwInFlags & NUMPRS_HEX_OCT)
+  {
+      dwState |= B_PROCESSING_OCT;
+      pNumprs->dwOutFlags |= NUMPRS_HEX_OCT;
+      cchUsed=cchUsed+2;
+      lpszStr=lpszStr+2;
+  }
+
   /* Strip Leading zeros */
   while (*lpszStr == '0')
   {
@@ -1607,14 +1668,14 @@
         int exponentSize = 0;
         if (dwState & B_EXPONENT_START)
         {
+          if (!isdigitW(*lpszStr))
+            break; /* No exponent digits - invalid */
           while (*lpszStr == '0')
           {
             /* Skip leading zero's in the exponent */
             cchUsed++;
             lpszStr++;
           }
-          if (!isdigitW(*lpszStr))
-            break; /* No exponent digits - invalid */
         }
 
         while (isdigitW(*lpszStr))
@@ -1633,7 +1694,8 @@
       }
       else
       {
-        if (pNumprs->cDig >= iMaxDigits)
+        if ((pNumprs->cDig >= iMaxDigits) && !(dwState & B_PROCESSING_HEX)
+          && !(dwState & B_PROCESSING_OCT))
         {
           pNumprs->dwOutFlags |= NUMPRS_INEXACT;
 
@@ -1648,8 +1710,13 @@
         }
         else
         {
+          if ((dwState & B_PROCESSING_OCT) && ((*lpszStr == '8') || (*lpszStr == '9'))) {
+            return DISP_E_TYPEMISMATCH;
+          }
+
           if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
             pNumprs->nPwr10--; /* Count decimal points in nPwr10 */
+
           rgbTmp[pNumprs->cDig] = *lpszStr - '0';
         }
         pNumprs->cDig++;
@@ -1668,13 +1735,6 @@
       pNumprs->dwOutFlags |= NUMPRS_DECIMAL;
       cchUsed++;
 
-      /* Remove trailing zeros from the whole number part */
-      while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
-      {
-        pNumprs->nPwr10++;
-        pNumprs->cDig--;
-      }
-
       /* If we have no digits so far, skip leading zeros */
       if (!pNumprs->cDig)
       {
@@ -1683,6 +1743,7 @@
           dwState |= B_LEADING_ZERO;
           cchUsed++;
           lpszStr++;
+          pNumprs->nPwr10--;
         }
       }
     }
@@ -1703,6 +1764,24 @@
       dwState |= B_NEGATIVE_EXPONENT;
       cchUsed++;
     }
+    else if (((*lpszStr >= 'a' && *lpszStr <= 'f') ||
+             (*lpszStr >= 'A' && *lpszStr <= 'F')) &&
+             dwState & B_PROCESSING_HEX)
+    {
+      if (pNumprs->cDig >= iMaxDigits)
+      {
+        return DISP_E_OVERFLOW;
+      }
+      else
+      {
+        if (*lpszStr >= 'a')
+          rgbTmp[pNumprs->cDig] = *lpszStr - 'a' + 10;
+        else
+          rgbTmp[pNumprs->cDig] = *lpszStr - 'A' + 10;
+      }
+      pNumprs->cDig++;
+      cchUsed++;
+    }
     else
       break; /* Stop at an unrecognised character */
 
@@ -1733,25 +1812,29 @@
     /* cDig of X and writes X+Y where Y>=0 number of digits to rgbDig */
     memcpy(rgbDig, rgbTmp, pNumprs->cDig * sizeof(BYTE));
 
-    while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
-    {
-      if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
-        pNumprs->nPwr10--;
-      else
-        pNumprs->nPwr10++;
-
-      pNumprs->cDig--;
+    if (dwState & B_PROCESSING_HEX) {
+      /* hex numbers have always the same format */
+      pNumprs->nPwr10=0;
+      pNumprs->nBaseShift=4;
+    } else {
+      if (dwState & B_PROCESSING_OCT) {
+        /* oct numbers have always the same format */
+        pNumprs->nPwr10=0;
+        pNumprs->nBaseShift=3;
+      } else {
+        while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
+        {
+          pNumprs->nPwr10++;
+          pNumprs->cDig--;
+        }
+      }
     }
   } else
   {
     /* Remove trailing zeros from the last (whole number or decimal) part */
     while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
     {
-      if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
-        pNumprs->nPwr10--;
-      else
-        pNumprs->nPwr10++;
-
+      pNumprs->nPwr10++;
       pNumprs->cDig--;
     }
   }
@@ -1875,7 +1958,110 @@
   if (pNumprs->nBaseShift)
   {
     /* nBaseShift indicates a hex or octal number */
-    FIXME("nBaseShift=%d not yet implemented, returning overflow\n", pNumprs->nBaseShift);
+    ULONG64 ul64 = 0;
+    LONG64 l64;
+    int i;
+
+    /* Convert the hex or octal number string into a UI64 */
+    for (i = 0; i < pNumprs->cDig; i++)
+    {
+      if (ul64 > ((UI8_MAX>>pNumprs->nBaseShift) - rgbDig[i]))
+      {
+        TRACE("Overflow multiplying digits\n");
+        return DISP_E_OVERFLOW;
+      }
+      ul64 = (ul64<<pNumprs->nBaseShift) + rgbDig[i];
+    }
+
+    /* also make a negative representation */
+    l64=-ul64;
+
+    /* Try signed and unsigned types in size order */
+    if (dwVtBits & VTBIT_I1 && ((ul64 <= I1_MAX)||(l64 >= I1_MIN)))
+    {
+      V_VT(pVarDst) = VT_I1;
+      if (ul64 <= I1_MAX)
+          V_I1(pVarDst) = ul64;
+      else
+          V_I1(pVarDst) = l64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_UI1 && ul64 <= UI1_MAX)
+    {
+      V_VT(pVarDst) = VT_UI1;
+      V_UI1(pVarDst) = ul64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_I2 && ((ul64 <= I2_MAX)||(l64 >= I2_MIN)))
+    {
+      V_VT(pVarDst) = VT_I2;
+      if (ul64 <= I2_MAX)
+          V_I2(pVarDst) = ul64;
+      else
+          V_I2(pVarDst) = l64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_UI2 && ul64 <= UI2_MAX)
+    {
+      V_VT(pVarDst) = VT_UI2;
+      V_UI2(pVarDst) = ul64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_I4 && ((ul64 <= I4_MAX)||(l64 >= I4_MIN)))
+    {
+      V_VT(pVarDst) = VT_I4;
+      if (ul64 <= I4_MAX)
+          V_I4(pVarDst) = ul64;
+      else
+          V_I4(pVarDst) = l64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_UI4 && ul64 <= UI4_MAX)
+    {
+      V_VT(pVarDst) = VT_UI4;
+      V_UI4(pVarDst) = ul64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_I8 && ((ul64 <= I4_MAX)||(l64>=I4_MIN)))
+    {
+      V_VT(pVarDst) = VT_I8;
+      V_I8(pVarDst) = ul64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_UI8)
+    {
+      V_VT(pVarDst) = VT_UI8;
+      V_UI8(pVarDst) = ul64;
+      return S_OK;
+    }
+    else if ((dwVtBits & REAL_VTBITS) == VTBIT_DECIMAL)
+    {
+      V_VT(pVarDst) = VT_DECIMAL;
+      DEC_SIGNSCALE(&V_DECIMAL(pVarDst)) = SIGNSCALE(DECIMAL_POS,0);
+      DEC_HI32(&V_DECIMAL(pVarDst)) = 0;
+      DEC_LO64(&V_DECIMAL(pVarDst)) = ul64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_R4 && ((ul64 <= I4_MAX)||(l64 >= I4_MIN)))
+    {
+      V_VT(pVarDst) = VT_R4;
+      if (ul64 <= I4_MAX)
+          V_R4(pVarDst) = ul64;
+      else
+          V_R4(pVarDst) = l64;
+      return S_OK;
+    }
+    else if (dwVtBits & VTBIT_R8 && ((ul64 <= I4_MAX)||(l64 >= I4_MIN)))
+    {
+      V_VT(pVarDst) = VT_R8;
+      if (ul64 <= I4_MAX)
+          V_R8(pVarDst) = ul64;
+      else
+          V_R8(pVarDst) = l64;
+      return S_OK;
+    }
+
+    TRACE("Overflow: possible return types: 0x%lx, value: %s\n", dwVtBits, wine_dbgstr_longlong(ul64));
     return DISP_E_OVERFLOW;
   }
 
@@ -2146,7 +2332,7 @@
 
     while (divisor10 > 10)
     {
-      if (whole < dblMinimums[10])
+      if (whole < dblMinimums[10] && whole != 0)
       {
         dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
         bOverflow = TRUE;
@@ -2157,7 +2343,7 @@
     }
     if (divisor10)
     {
-      if (whole < dblMinimums[divisor10])
+      if (whole < dblMinimums[divisor10] && whole != 0)
       {
         dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
         bOverflow = TRUE;
@@ -2899,84 +3085,260 @@
 /**********************************************************************
  *              VarOr [OLEAUT32.157]
  *
+ * Perform a logical or (OR) operation on two variants.
+ *
+ * PARAMS
+ *  pVarLeft  [I] First variant
+ *  pVarRight [I] Variant to OR with pVarLeft
+ *  pVarOut   [O] Destination for OR result
+ *
+ * RETURNS
+ *  Success: S_OK. pVarOut contains the result of the operation with its type
+ *           taken from the table listed under VarXor().
+ *  Failure: An HRESULT error code indicating the error.
+ *
+ * NOTES
+ *  See the Notes section of VarXor() for further information.
  */
-HRESULT WINAPI VarOr(LPVARIANT left, LPVARIANT right, LPVARIANT result)
+HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
 {
-    HRESULT rc = E_FAIL;
+    VARTYPE vt = VT_I4;
+    VARIANT varLeft, varRight, varStr;
+    HRESULT hRet;
+
+    TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", pVarLeft, debugstr_VT(pVarLeft),
+          debugstr_VF(pVarLeft), pVarRight, debugstr_VT(pVarRight),
+          debugstr_VF(pVarRight), pVarOut);
+
+    if (V_EXTRA_TYPE(pVarLeft) || V_EXTRA_TYPE(pVarRight) ||
+        V_VT(pVarLeft) == VT_UNKNOWN || V_VT(pVarRight) == VT_UNKNOWN ||
+        V_VT(pVarLeft) == VT_DISPATCH || V_VT(pVarRight) == VT_DISPATCH ||
+        V_VT(pVarLeft) == VT_RECORD || V_VT(pVarRight) == VT_RECORD)
+        return DISP_E_BADVARTYPE;
 
-    TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", left, debugstr_VT(left),
-          debugstr_VF(left), right, debugstr_VT(right), debugstr_VF(right), result);
+    V_VT(&varLeft) = V_VT(&varRight) = V_VT(&varStr) = VT_EMPTY;
 
-    if ((V_VT(left)&VT_TYPEMASK) == VT_BOOL &&
-        (V_VT(right)&VT_TYPEMASK) == VT_BOOL) {
+    if (V_VT(pVarLeft) == VT_NULL || V_VT(pVarRight) == VT_NULL)
+    {
+        /* NULL OR Zero is NULL, NULL OR value is value */
+        if (V_VT(pVarLeft) == VT_NULL)
+            pVarLeft = pVarRight; /* point to the non-NULL var */
 
-        V_VT(result) = VT_BOOL;
-        if (V_BOOL(left) || V_BOOL(right)) {
-            V_BOOL(result) = VARIANT_TRUE;
-        } else {
-            V_BOOL(result) = VARIANT_FALSE;
-        }
-        rc = S_OK;
+        V_VT(pVarOut) = VT_NULL;
+        V_I4(pVarOut) = 0;
 
-    } else {
-        /* Integers */
-        BOOL         lOk        = TRUE;
-        BOOL         rOk        = TRUE;
-        LONGLONG     lVal = -1;
-        LONGLONG     rVal = -1;
-        LONGLONG     res  = -1;
-        int          resT = 0; /* Testing has shown I2 & I2 == I2, all else
-                                  becomes I4, even unsigned ints (incl. UI2) */
+        switch (V_VT(pVarLeft))
+        {
+        case VT_DATE: case VT_R8:
+            if (V_R8(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_BOOL:
+            if (V_BOOL(pVarLeft))
+                *pVarOut = *pVarLeft;
+            return S_OK;
+         case VT_I2: case VT_UI2:
+            if (V_I2(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_I1:
+            if (V_I1(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_UI1:
+            if (V_UI1(pVarLeft))
+                *pVarOut = *pVarLeft;
+            return S_OK;
+        case VT_R4:
+            if (V_R4(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_I4: case VT_UI4: case VT_INT: case VT_UINT:
+            if (V_I4(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_CY:
+            if (V_CY(pVarLeft).int64)
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_I8: case VT_UI8:
+            if (V_I8(pVarLeft))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_DECIMAL:
+            if (DEC_HI32(&V_DECIMAL(pVarLeft)) || DEC_LO64(&V_DECIMAL(pVarLeft)))
+                goto VarOr_AsEmpty;
+            return S_OK;
+        case VT_BSTR:
+        {
+            VARIANT_BOOL b;
 
-        lOk = TRUE;
-        switch (V_VT(left)&VT_TYPEMASK) {
-        case VT_I1   : lVal = V_UNION(left,cVal);  resT=VT_I4; break;
-        case VT_I2   : lVal = V_UNION(left,iVal);  resT=VT_I2; break;
-        case VT_I4   : lVal = V_UNION(left,lVal);  resT=VT_I4; break;
-        case VT_INT  : lVal = V_UNION(left,lVal);  resT=VT_I4; break;
-        case VT_UI1  : lVal = V_UNION(left,bVal);  resT=VT_I4; break;
-        case VT_UI2  : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
-        case VT_UI4  : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
-        case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
-        case VT_BOOL : lVal = V_UNION(left,boolVal); resT=VT_I4; break;
-        default: lOk = FALSE;
-        }
+            if (!V_BSTR(pVarLeft))
+                return DISP_E_BADVARTYPE;
 
-        rOk = TRUE;
-        switch (V_VT(right)&VT_TYPEMASK) {
-        case VT_I1   : rVal = V_UNION(right,cVal);  resT=VT_I4; break;
-        case VT_I2   : rVal = V_UNION(right,iVal);  resT=max(VT_I2, resT); break;
-        case VT_I4   : rVal = V_UNION(right,lVal);  resT=VT_I4; break;
-        case VT_INT  : rVal = V_UNION(right,lVal);  resT=VT_I4; break;
-        case VT_UI1  : rVal = V_UNION(right,bVal);  resT=VT_I4; break;
-        case VT_UI2  : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
-        case VT_UI4  : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
-        case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
-        case VT_BOOL : rVal = V_UNION(right,boolVal); resT=VT_I4; break;
-        default: rOk = FALSE;
+            hRet = VarBoolFromStr(V_BSTR(pVarLeft), LOCALE_USER_DEFAULT, VAR_LOCALBOOL, &b);
+            if (SUCCEEDED(hRet) && b)
+            {
+                V_VT(pVarOut) = VT_BOOL;
+                V_BOOL(pVarOut) = b;
+            }
+            return hRet;
+        }
+        case VT_NULL: case VT_EMPTY:
+            V_VT(pVarOut) = VT_NULL;
+            return S_OK;
+        default:
+            return DISP_E_BADVARTYPE;
         }
+    }
 
-        if (lOk && rOk) {
-            res = (lVal | rVal);
-            V_VT(result) = resT;
-            switch (resT) {
-            case VT_I2   : V_UNION(result,iVal)  = res; break;
-            case VT_I4   : V_UNION(result,lVal)  = res; break;
-            default:
-                FIXME("Unexpected result variant type %x\n", resT);
-                V_UNION(result,lVal)  = res;
-            }
-            rc = S_OK;
+    if (V_VT(pVarLeft) == VT_EMPTY || V_VT(pVarRight) == VT_EMPTY)
+    {
+        if (V_VT(pVarLeft) == VT_EMPTY)
+            pVarLeft = pVarRight; /* point to the non-EMPTY var */
 
-        } else {
-            FIXME("unimplemented part, V_VT(left) == 0x%X, V_VT(right) == 0x%X\n", 
-		V_VT(left) & VT_TYPEMASK, V_VT(right) & VT_TYPEMASK);
+VarOr_AsEmpty:
+        /* Since one argument is empty (0), OR'ing it with the other simply
+         * gives the others value (as 0|x => x). So just convert the other
+         * argument to the required result type.
+         */
+        switch (V_VT(pVarLeft))
+        {
+        case VT_BSTR:
+            if (!V_BSTR(pVarLeft))
+                return DISP_E_BADVARTYPE;
+
+            hRet = VariantCopy(&varStr, pVarLeft);
+            if (FAILED(hRet))
+                goto VarOr_Exit;
+            pVarLeft = &varStr;
+            hRet = VariantChangeType(pVarLeft, pVarLeft, 0, VT_BOOL);
+            if (FAILED(hRet))
+                goto VarOr_Exit;
+            /* Fall Through ... */
+        case VT_EMPTY: case VT_UI1: case VT_BOOL: case VT_I2:
+            V_VT(pVarOut) = VT_I2;
+            break;
+        case VT_DATE: case VT_CY: case VT_DECIMAL: case VT_R4: case VT_R8:
+        case VT_I1: case VT_UI2: case VT_I4: case VT_UI4:
+        case VT_INT: case VT_UINT: case VT_UI8:
+            V_VT(pVarOut) = VT_I4;
+            break;
+        case VT_I8:
+            V_VT(pVarOut) = VT_I8;
+            break;
+        default:
+            return DISP_E_BADVARTYPE;
         }
+        hRet = VariantCopy(&varLeft, pVarLeft);
+        if (FAILED(hRet))
+            goto VarOr_Exit;
+        pVarLeft = &varLeft;
+        hRet = VariantChangeType(pVarOut, pVarLeft, 0, V_VT(pVarOut));
+        goto VarOr_Exit;
     }
 
-    TRACE("returning 0x%8lx (%s%s),%ld\n", rc, debugstr_VT(result),
-          debugstr_VF(result), V_VT(result) == VT_I4 ? V_I4(result) : V_I2(result));
-    return rc;
+    if (V_VT(pVarLeft) == VT_BOOL && V_VT(pVarRight) == VT_BOOL)
+    {
+        V_VT(pVarOut) = VT_BOOL;
+        V_BOOL(pVarOut) = V_BOOL(pVarLeft) | V_BOOL(pVarRight);
+        return S_OK;
+    }
+
+    if (V_VT(pVarLeft) == VT_UI1 && V_VT(pVarRight) == VT_UI1)
+    {
+        V_VT(pVarOut) = VT_UI1;
+        V_UI1(pVarOut) = V_UI1(pVarLeft) | V_UI1(pVarRight);
+        return S_OK;
+    }
+
+    if (V_VT(pVarLeft) == VT_BSTR)
+    {
+        hRet = VariantCopy(&varStr, pVarLeft);
+        if (FAILED(hRet))
+            goto VarOr_Exit;
+        pVarLeft = &varStr;
+        hRet = VariantChangeType(pVarLeft, pVarLeft, 0, VT_BOOL);
+        if (FAILED(hRet))
+            goto VarOr_Exit;
+    }
+
+    if (V_VT(pVarLeft) == VT_BOOL &&
+        (V_VT(pVarRight) == VT_BOOL || V_VT(pVarRight) == VT_BSTR))
+    {
+        vt = VT_BOOL;
+    }
+    else if ((V_VT(pVarLeft) == VT_BOOL || V_VT(pVarLeft) == VT_UI1 ||
+        V_VT(pVarLeft) == VT_I2 || V_VT(pVarLeft) == VT_BSTR) &&
+        (V_VT(pVarRight) == VT_BOOL || V_VT(pVarRight) == VT_UI1 ||
+        V_VT(pVarRight) == VT_I2 || V_VT(pVarRight) == VT_BSTR))
+    {
+        vt = VT_I2;
+    }
+    else if (V_VT(pVarLeft) == VT_I8 || V_VT(pVarRight) == VT_I8)
+    {
+        if (V_VT(pVarLeft) == VT_INT || V_VT(pVarRight) == VT_INT)
+            return DISP_E_TYPEMISMATCH;
+        vt = VT_I8;
+    }
+
+    hRet = VariantCopy(&varLeft, pVarLeft);
+    if (FAILED(hRet))
+        goto VarOr_Exit;
+
+    hRet = VariantCopy(&varRight, pVarRight);
+    if (FAILED(hRet))
+        goto VarOr_Exit;
+
+    if (vt == VT_I4 && V_VT(&varLeft) == VT_UI4)
+        V_VT(&varLeft) = VT_I4; /* Don't overflow */
+    else
+    {
+        double d;
+
+        if (V_VT(&varLeft) == VT_BSTR &&
+            FAILED(VarR8FromStr(V_BSTR(&varLeft), LOCALE_USER_DEFAULT, 0, &d)))
+            hRet = VariantChangeType(&varLeft, &varLeft, VARIANT_LOCALBOOL, VT_BOOL);
+        if (SUCCEEDED(hRet) && V_VT(&varLeft) != vt)
+            hRet = VariantChangeType(&varLeft, &varLeft, 0, vt);
+        if (FAILED(hRet))
+            goto VarOr_Exit;
+    }
+
+    if (vt == VT_I4 && V_VT(&varRight) == VT_UI4)
+        V_VT(&varRight) = VT_I4; /* Don't overflow */
+    else
+    {
+        double d;
+
+        if (V_VT(&varRight) == VT_BSTR &&
+            FAILED(VarR8FromStr(V_BSTR(&varRight), LOCALE_USER_DEFAULT, 0, &d)))
+            hRet = VariantChangeType(&varRight, &varRight, VARIANT_LOCALBOOL, VT_BOOL);
+        if (SUCCEEDED(hRet) && V_VT(&varRight) != vt)
+            hRet = VariantChangeType(&varRight, &varRight, 0, vt);
+        if (FAILED(hRet))
+            goto VarOr_Exit;
+    }
+
+    V_VT(pVarOut) = vt;
+    if (vt == VT_I8)
+    {
+        V_I8(pVarOut) = V_I8(&varLeft) | V_I8(&varRight);
+    }
+    else if (vt == VT_I4)
+    {
+        V_I4(pVarOut) = V_I4(&varLeft) | V_I4(&varRight);
+    }
+    else
+    {
+        V_I2(pVarOut) = V_I2(&varLeft) | V_I2(&varRight);
+    }
+
+VarOr_Exit:
+    VariantClear(&varStr);
+    VariantClear(&varLeft);
+    VariantClear(&varRight);
+    return hRet;
 }
 
 /**********************************************************************
@@ -3053,9 +3415,12 @@
     case VT_UINT:
     case VT_UI4:
     case VT_UI8:
+        /* No-Op */
+        break;
     case VT_EMPTY:
+        V_VT(pVarOut) = VT_I2;
     case VT_NULL:
-        /* No-Op */
+        V_I2(pVarOut) = 0;
         break;
     default:
         hRet = DISP_E_BADVARTYPE;
@@ -3221,6 +3586,211 @@
 }
 
 /**********************************************************************
+ *              VarXor [OLEAUT32.167]
+ *
+ * Perform a logical exclusive-or (XOR) operation on two variants.
+ *
+ * PARAMS
+ *  pVarLeft  [I] First variant
+ *  pVarRight [I] Variant to XOR with pVarLeft
+ *  pVarOut   [O] Destination for XOR result
+ *
+ * RETURNS
+ *  Success: S_OK. pVarOut contains the result of the operation with its type
+ *           taken from the table below).
+ *  Failure: An HRESULT error code indicating the error.
+ *
+ * NOTES
+ *  - Neither pVarLeft or pVarRight are modified by this function.
+ *  - This function does not process by-reference variants.
+ *  - Input types of VT_BSTR may be numeric strings or boolean text.
+ *  - The type of result stored in pVarOut depends on the types of pVarLeft
+ *    and pVarRight, and will be one of VT_UI1, VT_I2, VT_I4, VT_I8, VT_BOOL,
+ *    or VT_NULL if the function succeeds.
+ *  - Type promotion is inconsistent and as a result certain combinations of
+ *    values will return DISP_E_OVERFLOW even when they could be represented.
+ *    This matches the behaviour of native oleaut32.
+ */
+HRESULT WINAPI VarXor(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
+{
+    VARTYPE vt;
+    VARIANT varLeft, varRight;
+    double d;
+    HRESULT hRet;
+
+    TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", pVarLeft, debugstr_VT(pVarLeft),
+          debugstr_VF(pVarLeft), pVarRight, debugstr_VT(pVarRight),
+          debugstr_VF(pVarRight), pVarOut);
+
+    if (V_EXTRA_TYPE(pVarLeft) || V_EXTRA_TYPE(pVarRight) ||
+        V_VT(pVarLeft) > VT_UINT || V_VT(pVarRight) > VT_UINT ||
+        V_VT(pVarLeft) == VT_VARIANT || V_VT(pVarRight) == VT_VARIANT ||
+        V_VT(pVarLeft) == VT_UNKNOWN || V_VT(pVarRight) == VT_UNKNOWN ||
+        V_VT(pVarLeft) == (VARTYPE)15 || V_VT(pVarRight) == (VARTYPE)15 ||
+        V_VT(pVarLeft) == VT_ERROR || V_VT(pVarRight) == VT_ERROR)
+        return DISP_E_BADVARTYPE;
+
+    if (V_VT(pVarLeft) == VT_NULL || V_VT(pVarRight) == VT_NULL)
+    {
+        /* NULL XOR anything valid is NULL */
+        V_VT(pVarOut) = VT_NULL;
+        return S_OK;
+    }
+
+    /* Copy our inputs so we don't disturb anything */
+    V_VT(&varLeft) = V_VT(&varRight) = VT_EMPTY;
+
+    hRet = VariantCopy(&varLeft, pVarLeft);
+    if (FAILED(hRet))
+        goto VarXor_Exit;
+
+    hRet = VariantCopy(&varRight, pVarRight);
+    if (FAILED(hRet))
+        goto VarXor_Exit;
+
+    /* Try any strings first as numbers, then as VT_BOOL */
+    if (V_VT(&varLeft) == VT_BSTR)
+    {
+        hRet = VarR8FromStr(V_BSTR(&varLeft), LOCALE_USER_DEFAULT, 0, &d);
+        hRet = VariantChangeType(&varLeft, &varLeft, VARIANT_LOCALBOOL,
+                                 FAILED(hRet) ? VT_BOOL : VT_I4);
+        if (FAILED(hRet))
+            goto VarXor_Exit;
+    }
+
+    if (V_VT(&varRight) == VT_BSTR)
+    {
+        hRet = VarR8FromStr(V_BSTR(&varRight), LOCALE_USER_DEFAULT, 0, &d);
+        hRet = VariantChangeType(&varRight, &varRight, VARIANT_LOCALBOOL,
+                                 FAILED(hRet) ? VT_BOOL : VT_I4);
+        if (FAILED(hRet))
+            goto VarXor_Exit;
+    }
+
+    /* Determine the result type */
+    if (V_VT(&varLeft) == VT_I8 || V_VT(&varRight) == VT_I8)
+    {
+        if (V_VT(pVarLeft) == VT_INT || V_VT(pVarRight) == VT_INT)
+            return DISP_E_TYPEMISMATCH;
+        vt = VT_I8;
+    }
+    else
+    {
+        switch ((V_VT(&varLeft) << 16) | V_VT(&varRight))
+        {
+        case (VT_BOOL  << 16) | VT_BOOL:
+            vt = VT_BOOL;
+            break;
+        case (VT_UI1   << 16) | VT_UI1:
+            vt = VT_UI1;
+            break;
+        case (VT_EMPTY << 16) | VT_EMPTY:
+        case (VT_EMPTY << 16) | VT_UI1:
+        case (VT_EMPTY << 16) | VT_I2:
+        case (VT_EMPTY << 16) | VT_BOOL:
+        case (VT_UI1   << 16) | VT_EMPTY:
+        case (VT_UI1   << 16) | VT_I2:
+        case (VT_UI1   << 16) | VT_BOOL:
+        case (VT_I2    << 16) | VT_EMPTY:
+        case (VT_I2    << 16) | VT_UI1:
+        case (VT_I2    << 16) | VT_I2:
+        case (VT_I2    << 16) | VT_BOOL:
+        case (VT_BOOL  << 16) | VT_EMPTY:
+        case (VT_BOOL  << 16) | VT_UI1:
+        case (VT_BOOL  << 16) | VT_I2:
+            vt = VT_I2;
+            break;
+        default:
+            vt = VT_I4;
[truncated at 1000 lines; 153 more skipped]

reactos/lib/oleaut32
variant.h 1.3 -> 1.3.20.1
diff -u -r1.3 -r1.3.20.1
--- variant.h	29 Feb 2004 16:24:54 -0000	1.3
+++ variant.h	8 Dec 2004 21:57:18 -0000	1.3.20.1
@@ -21,10 +21,10 @@
 #define NONAMELESSSTRUCT
 #include "windef.h"
 #include "winerror.h"
+#include "objbase.h"
 #include "oleauto.h"
 #include <math.h>
 
-
 /* Get just the type from a variant pointer */
 #define V_TYPE(v)  (V_VT((v)) & VT_TYPEMASK)
 
@@ -82,15 +82,13 @@
 #endif
 
 /* Macros for getting at a DECIMAL's parts */
-#ifndef DEC_LO64
-#define DEC_SIGN(d)      ((d)->u.s.sign)
-#define DEC_SCALE(d)     ((d)->u.s.scale)
-#define DEC_SIGNSCALE(d) ((d)->u.signscale)
+#define DEC_SIGN(d)      ((d)->sign)
+#define DEC_SCALE(d)     ((d)->scale)
+#define DEC_SIGNSCALE(d) ((d)->signscale)
 #define DEC_HI32(d)      ((d)->Hi32)
-#define DEC_MID32(d)     ((d)->DUMMYUNIONNAME2.DUMMYSTRUCTNAME2.Mid32)
-#define DEC_LO32(d)      ((d)->DUMMYUNIONNAME2.DUMMYSTRUCTNAME2.Lo32)
-#define DEC_LO64(d)      ((d)->DUMMYUNIONNAME2.Lo64)
-#endif
+#define DEC_MID32(d)     ((d)->Mid32)
+#define DEC_LO32(d)      ((d)->Lo32)
+#define DEC_LO64(d)      ((d)->Lo64)
 
 #define DEC_MAX_SCALE    28 /* Maximum scale for a decimal */
 

reactos/lib/oleaut32
vartype.c 1.9 -> 1.9.20.1
diff -u -r1.9 -r1.9.20.1
--- vartype.c	29 Feb 2004 16:37:23 -0000	1.9
+++ vartype.c	8 Dec 2004 21:57:18 -0000	1.9.20.1
@@ -17,8 +17,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
+#define COBJMACROS
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+
 #include "wine/debug.h"
 #include "wine/unicode.h"
 #include "winbase.h"
@@ -27,7 +30,7 @@
 #include "variant.h"
 #include "resource.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(ole);
+WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
 extern HMODULE OLEAUT32_hModule;
 
@@ -1356,7 +1359,7 @@
  * Convert a VT_I2 to a VT_I4.
  *
  * PARAMS
- *  iIn     [I] Source
+ *  sIn     [I] Source
  *  piOut   [O] Destination
  *
  * RETURNS
@@ -3848,7 +3851,7 @@
  * RETURNS
  *  Success: VARCMP_LT, VARCMP_EQ or VARCMP_GT indicating that the value to
  *           compare is less, equal or greater than source respectively.
- *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparason
+ *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparison
  */
 HRESULT WINAPI VarCyCmp(const CY cyLeft, const CY cyRight)
 {
@@ -3882,7 +3885,7 @@
  * RETURNS
  *  Success: VARCMP_LT, VARCMP_EQ or VARCMP_GT indicating that dblRight is
  *           less than, equal to or greater than cyLeft respectively.
- *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparason
+ *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparison
  */
 HRESULT WINAPI VarCyCmpR8(const CY cyLeft, double dblRight)
 {
@@ -4574,7 +4577,7 @@
  */
 HRESULT WINAPI VarDecFix(const DECIMAL* pDecIn, DECIMAL* pDecOut)
 {
-  if (DEC_SIGN(pDecOut) & ~DECIMAL_NEG)
+  if (DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
     return E_INVALIDARG;
 
   if (!DEC_SCALE(pDecIn))
@@ -4606,10 +4609,10 @@
  */
 HRESULT WINAPI VarDecInt(const DECIMAL* pDecIn, DECIMAL* pDecOut)
 {
-  if (DEC_SIGN(pDecOut) & ~DECIMAL_NEG)
+  if (DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
     return E_INVALIDARG;
 
-  if (!(DEC_SIGN(pDecOut) & DECIMAL_NEG) || !DEC_SCALE(pDecIn))
+  if (!(DEC_SIGN(pDecIn) & DECIMAL_NEG) || !DEC_SCALE(pDecIn))
     return VarDecFix(pDecIn, pDecOut); /* The same, if +ve or no fractionals */
 
   FIXME("semi-stub!\n");
@@ -4677,7 +4680,7 @@
  * RETURNS
  *  Success: VARCMP_LT, VARCMP_EQ or VARCMP_GT indicating that pDecLeft
  *           is less than, equal to or greater than pDecRight respectively.
- *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparason
+ *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparison
  */
 HRESULT WINAPI VarDecCmp(const DECIMAL* pDecLeft, const DECIMAL* pDecRight)
 {
@@ -4713,7 +4716,7 @@
  * RETURNS
  *  Success: VARCMP_LT, VARCMP_EQ or VARCMP_GT indicating that dblRight
  *           is less than, equal to or greater than pDecLeft respectively.
- *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparason
+ *  Failure: DISP_E_OVERFLOW, if overflow occurs during the comparison
  */
 HRESULT WINAPI VarDecCmpR8(const DECIMAL* pDecLeft, double dblRight)
 {
@@ -5706,7 +5709,7 @@
  * PARAMS
  *  pbstrLeft  [I] Source
  *  pbstrRight [I] Value to compare
- *  lcid       [I] LCID for the comparason
+ *  lcid       [I] LCID for the comparison
  *  dwFlags    [I] Flags to pass directly to CompareStringW().
  *
  * RETURNS

reactos/lib/oledlg
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:45 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:19 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:45 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:57:19 hyperion Exp $
 
 TARGET_NAME = oledlg
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_OLEDLG)
 

reactos/lib/oledlg
insobjdlg.c 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- insobjdlg.c	14 Jan 2004 01:55:00 -0000	1.1
+++ insobjdlg.c	8 Dec 2004 21:57:19 -0000	1.1.24.1
@@ -106,7 +106,7 @@
   dlgInfo.lpOleUIInsertObject = lpOleUIInsertObject;
   dlgInfo.bObjListInit = FALSE;
 
-  lRes = DialogBoxIndirectParamA(OLEDLG_hInstance, (LPDLGTEMPLATEA) template,
+  lRes = DialogBoxIndirectParamA(OLEDLG_hInstance, (const DLGTEMPLATE*) template,
       lpOleUIInsertObject->hWndOwner, UIInsertObjectDlgProc,
       (LPARAM) &dlgInfo);
 

reactos/lib/olepro32
Makefile.ros-template 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile.ros-template	29 May 2004 21:24:45 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:19 -0000	1.2.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:45 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.2.16.1 2004/12/08 21:57:19 hyperion Exp $
 
 TARGET_NAME = olepro32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a oleaut32.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a oleaut32.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_OLEPRO32)
 

reactos/lib/opengl32
gl.c 1.8 -> 1.8.8.1
diff -u -r1.8 -r1.8.8.1
--- gl.c	16 Jul 2004 16:16:16 -0000	1.8
+++ gl.c	8 Dec 2004 21:57:19 -0000	1.8.8.1
@@ -76,7 +76,7 @@
 {                                                                     \
 	PROC *table;                                                      \
 	PROC fn;                                                          \
-	if (tebidx >= 10000)                                                  \
+	if (tebidx >= 0 && 0)                                                  \
 	{                                                                 \
 		table = (PROC *)NtCurrentTeb()->glDispatchTable;              \
 		fn = table[tebidx];                                           \

reactos/lib/opengl32
icdtable.h 1.4 -> 1.4.8.1
diff -u -r1.4 -r1.4.8.1
--- icdtable.h	16 Jul 2004 16:16:16 -0000	1.4
+++ icdtable.h	8 Dec 2004 21:57:19 -0000	1.4.8.1
@@ -14,7 +14,7 @@
 
 typedef struct tagICDTable
 {
-	DWORD	num_funcs; /*!< Normally 336 (0x150) -- the number of functions in OpenGL 1.1 */
+	DWORD	num_funcs;           /*!< Normally 336 (0x150) -- the number of functions in OpenGL 1.1 */
 	PROC	dispatch_table[812]; /*!< Table containing \a num_funcs pointers to OpenGL functions */
 } ICDTable, *PICDTable;
 

reactos/lib/opengl32
glfuncs.mac removed after 1.1
diff -N glfuncs.mac
--- glfuncs.mac	6 Feb 2004 18:17:18 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,337 +0,0 @@
-;GLFUNC name,icdidx,tebidx,stack
-GLFUNC glAccum,213,-1,8
-GLFUNC glAlphaFunc,240,-1,8
-GLFUNC glAreTexturesResident,322,-1,12
-GLFUNC glArrayElement,306,144,4
-GLFUNC glBegin,7,2,4
-GLFUNC glBindTexture,307,145,8
-GLFUNC glBitmap,8,-1,28
-GLFUNC glBlendFunc,241,-1,8
-GLFUNC glCallList,2,0,4
-GLFUNC glCallLists,3,1,12
-GLFUNC glClear,203,-1,4
-GLFUNC glClearAccum,204,-1,16
-GLFUNC glClearColor,206,-1,16
-GLFUNC glClearDepth,208,-1,8
-GLFUNC glClearIndex,205,-1,4
-GLFUNC glClearStencil,207,-1,4
-GLFUNC glClipPlane,150,-1,8
-GLFUNC glColor3b,9,3,12
-GLFUNC glColor3bv,10,4,4
-GLFUNC glColor3d,11,5,24
-GLFUNC glColor3dv,12,6,4
-GLFUNC glColor3f,13,7,12
-GLFUNC glColor3fv,14,8,4
-GLFUNC glColor3i,15,9,12
-GLFUNC glColor3iv,16,10,4
-GLFUNC glColor3s,17,11,12
-GLFUNC glColor3sv,18,12,4
-GLFUNC glColor3ub,19,13,12
-GLFUNC glColor3ubv,20,14,4
-GLFUNC glColor3ui,21,15,12
-GLFUNC glColor3uiv,22,16,4
-GLFUNC glColor3us,23,17,12
-GLFUNC glColor3usv,24,18,4
-GLFUNC glColor4b,25,19,16
-GLFUNC glColor4bv,26,20,4
-GLFUNC glColor4d,27,21,32
-GLFUNC glColor4dv,28,22,4
-GLFUNC glColor4f,29,23,16
-GLFUNC glColor4fv,30,24,4
-GLFUNC glColor4i,31,25,16
-GLFUNC glColor4iv,32,26,4
-GLFUNC glColor4s,33,27,16
-GLFUNC glColor4sv,34,28,4
-GLFUNC glColor4ub,35,29,16
-GLFUNC glColor4ubv,36,30,4
-GLFUNC glColor4ui,37,31,16
-GLFUNC glColor4uiv,38,32,4
-GLFUNC glColor4us,39,33,16
-GLFUNC glColor4usv,40,34,4
-GLFUNC glColorMask,210,-1,16
-GLFUNC glColorMaterial,151,-1,8
-GLFUNC glColorPointer,308,146,16
-GLFUNC glCopyPixels,255,-1,20
-GLFUNC glCopyTexImage1D,323,-1,28
-GLFUNC glCopyTexImage2D,324,-1,32
-GLFUNC glCopyTexSubImage1D,325,-1,24
-GLFUNC glCopyTexSubImage2D,326,-1,32
-GLFUNC glCullFace,152,-1,4
-GLFUNC glDeleteLists,4,-1,8
-GLFUNC glDeleteTextures,327,-1,8
-GLFUNC glDepthFunc,245,-1,4
-GLFUNC glDepthMask,211,-1,4
-GLFUNC glDepthRange,288,-1,16
-GLFUNC glDisable,214,116,4
-GLFUNC glDisableClientState,309,147,4
-GLFUNC glDrawArrays,310,148,12
-GLFUNC glDrawBuffer,202,-1,4
-GLFUNC glDrawElements,311,149,16
-GLFUNC glDrawPixels,257,-1,20
-GLFUNC glEdgeFlag,41,35,4
-GLFUNC glEdgeFlagPointer,312,150,8
-GLFUNC glEdgeFlagv,42,36,4
-GLFUNC glEnable,215,117,4
-GLFUNC glEnableClientState,313,151,4
-GLFUNC glEnd,43,37,0
-GLFUNC glEndList,1,-1,0
-GLFUNC glEvalCoord1d,228,120,8
-GLFUNC glEvalCoord1dv,229,121,4
-GLFUNC glEvalCoord1f,230,122,4
-GLFUNC glEvalCoord1fv,231,123,4
-GLFUNC glEvalCoord2d,232,124,16
-GLFUNC glEvalCoord2dv,233,125,4
-GLFUNC glEvalCoord2f,234,126,8
-GLFUNC glEvalCoord2fv,235,127,4
-GLFUNC glEvalMesh1,236,-1,12
-GLFUNC glEvalMesh2,238,-1,20
-GLFUNC glEvalPoint1,237,128,4
-GLFUNC glEvalPoint2,239,129,8
-GLFUNC glFeedbackBuffer,194,-1,12
-GLFUNC glFinish,216,-1,0
-GLFUNC glFlush,217,-1,0
-GLFUNC glFogf,153,-1,8
-GLFUNC glFogfv,154,-1,8
-GLFUNC glFogi,155,-1,8
-GLFUNC glFogiv,156,-1,8
-GLFUNC glFrontFace,157,-1,4
-GLFUNC glFrustum,289,-1,48
-GLFUNC glGenLists,5,-1,4
-GLFUNC glGenTextures,328,-1,8
-GLFUNC glGetBooleanv,258,-1,8
-GLFUNC glGetClipPlane,259,-1,8
-GLFUNC glGetDoublev,260,-1,8
-GLFUNC glGetError,261,-1,0
-GLFUNC glGetFloatv,262,-1,8
-GLFUNC glGetIntegerv,263,-1,8
-GLFUNC glGetLightfv,264,-1,12
-GLFUNC glGetLightiv,265,-1,12
-GLFUNC glGetMapdv,266,-1,12
-GLFUNC glGetMapfv,267,-1,12
-GLFUNC glGetMapiv,268,-1,12
-GLFUNC glGetMaterialfv,269,-1,12
-GLFUNC glGetMaterialiv,270,-1,12
-GLFUNC glGetPixelMapfv,271,-1,8
-GLFUNC glGetPixelMapuiv,272,-1,8
-GLFUNC glGetPixelMapusv,273,-1,8
-GLFUNC glGetPointerv,329,160,8
-GLFUNC glGetPolygonStipple,274,-1,4
-GLFUNC glGetString,275,-1,4
-GLFUNC glGetTexEnvfv,276,-1,12
-GLFUNC glGetTexEnviv,277,-1,12
-GLFUNC glGetTexGendv,278,-1,12
-GLFUNC glGetTexGenfv,279,-1,12
-GLFUNC glGetTexGeniv,280,-1,12
-GLFUNC glGetTexImage,281,-1,20
-GLFUNC glGetTexLevelParameterfv,284,-1,16
-GLFUNC glGetTexLevelParameteriv,285,-1,16
-GLFUNC glGetTexParameterfv,282,-1,12
-GLFUNC glGetTexParameteriv,283,-1,12
-GLFUNC glHint,158,-1,8
-GLFUNC glIndexMask,212,-1,4
-GLFUNC glIndexPointer,314,152,12
-GLFUNC glIndexd,44,38,8
-GLFUNC glIndexdv,45,39,4
-GLFUNC glIndexf,46,40,4
-GLFUNC glIndexfv,47,41,4
-GLFUNC glIndexi,48,42,4
-GLFUNC glIndexiv,49,43,4
-GLFUNC glIndexs,50,44,4
-GLFUNC glIndexsv,51,45,4
-GLFUNC glIndexub,315,153,4
-GLFUNC glIndexubv,316,154,4
-GLFUNC glInitNames,197,-1,0
-GLFUNC glInterleavedArrays,317,155,12
-GLFUNC glIsEnabled,286,-1,4
-GLFUNC glIsList,287,-1,4
-GLFUNC glIsTexture,330,-1,4
-GLFUNC glLightModelf,163,-1,8
-GLFUNC glLightModelfv,164,-1,8
-GLFUNC glLightModeli,165,-1,8
-GLFUNC glLightModeliv,166,-1,8
-GLFUNC glLightf,159,-1,12
-GLFUNC glLightfv,160,-1,12
-GLFUNC glLighti,161,-1,12
-GLFUNC glLightiv,162,-1,12
-GLFUNC glLineStipple,167,-1,8
-GLFUNC glLineWidth,168,-1,4
-GLFUNC glListBase,6,-1,4
-GLFUNC glLoadIdentity,290,130,0
-GLFUNC glLoadMatrixd,292,132,4
-GLFUNC glLoadMatrixf,291,131,4
-GLFUNC glLoadName,198,-1,4
-GLFUNC glLogicOp,242,-1,4
-GLFUNC glMap1d,220,-1,32
-GLFUNC glMap1f,221,-1,24
-GLFUNC glMap2d,222,-1,56
-GLFUNC glMap2f,223,-1,40
-GLFUNC glMapGrid1d,224,-1,20
-GLFUNC glMapGrid1f,225,-1,12
-GLFUNC glMapGrid2d,226,-1,40
-GLFUNC glMapGrid2f,227,-1,24
-GLFUNC glMaterialf,169,112,12
-GLFUNC glMaterialfv,170,113,12
-GLFUNC glMateriali,171,114,12
-GLFUNC glMaterialiv,172,115,12
-GLFUNC glMatrixMode,293,133,4
-GLFUNC glMultMatrixd,295,135,4
-GLFUNC glMultMatrixf,294,134,4
-GLFUNC glNewList,0,-1,8
-GLFUNC glNormal3b,52,46,12
-GLFUNC glNormal3bv,53,47,4
-GLFUNC glNormal3d,54,48,24
-GLFUNC glNormal3dv,55,49,4
-GLFUNC glNormal3f,56,50,12
-GLFUNC glNormal3fv,57,51,4
-GLFUNC glNormal3i,58,52,12
-GLFUNC glNormal3iv,59,53,4
-GLFUNC glNormal3s,60,54,12
-GLFUNC glNormal3sv,61,55,4
-GLFUNC glNormalPointer,318,156,12
-GLFUNC glOrtho,296,-1,48
-GLFUNC glPassThrough,199,-1,4
-GLFUNC glPixelMapfv,251,-1,12
-GLFUNC glPixelMapuiv,252,-1,12
-GLFUNC glPixelMapusv,253,-1,12
-GLFUNC glPixelStoref,249,-1,8
-GLFUNC glPixelStorei,250,-1,8
-GLFUNC glPixelTransferf,247,-1,8
-GLFUNC glPixelTransferi,248,-1,8
-GLFUNC glPixelZoom,246,-1,8
-GLFUNC glPointSize,173,-1,4
-GLFUNC glPolygonMode,174,-1,8
-GLFUNC glPolygonOffset,319,157,8
-GLFUNC glPolygonStipple,175,-1,4
-GLFUNC glPopAttrib,218,118,0
-GLFUNC glPopClientAttrib,334,161,0
-GLFUNC glPopMatrix,297,136,0
-GLFUNC glPopName,200,-1,0
-GLFUNC glPrioritizeTextures,331,-1,12
-GLFUNC glPushAttrib,219,119,4
-GLFUNC glPushClientAttrib,335,162,4
-GLFUNC glPushMatrix,298,137,0
-GLFUNC glPushName,201,-1,4
-GLFUNC glRasterPos2d,62,-1,16
-GLFUNC glRasterPos2dv,63,-1,4
-GLFUNC glRasterPos2f,64,-1,8
-GLFUNC glRasterPos2fv,65,-1,4
-GLFUNC glRasterPos2i,66,-1,8
-GLFUNC glRasterPos2iv,67,-1,4
-GLFUNC glRasterPos2s,68,-1,8
-GLFUNC glRasterPos2sv,69,-1,4
-GLFUNC glRasterPos3d,70,-1,24
-GLFUNC glRasterPos3dv,71,-1,4
-GLFUNC glRasterPos3f,72,-1,12
-GLFUNC glRasterPos3fv,73,-1,4
-GLFUNC glRasterPos3i,74,-1,12
-GLFUNC glRasterPos3iv,75,-1,4
-GLFUNC glRasterPos3s,76,-1,12
-GLFUNC glRasterPos3sv,77,-1,4
-GLFUNC glRasterPos4d,78,-1,32
-GLFUNC glRasterPos4dv,79,-1,4
-GLFUNC glRasterPos4f,80,-1,16
-GLFUNC glRasterPos4fv,81,-1,4
-GLFUNC glRasterPos4i,82,-1,16
-GLFUNC glRasterPos4iv,83,-1,4
-GLFUNC glRasterPos4s,84,-1,16
-GLFUNC glRasterPos4sv,85,-1,4
-GLFUNC glReadBuffer,254,-1,4
-GLFUNC glReadPixels,256,-1,28
-GLFUNC glRectd,86,-1,32
-GLFUNC glRectdv,87,-1,8
-GLFUNC glRectf,88,-1,16
-GLFUNC glRectfv,89,-1,8
-GLFUNC glRecti,90,-1,16
-GLFUNC glRectiv,91,-1,8
-GLFUNC glRects,92,-1,16
-GLFUNC glRectsv,93,-1,8
-GLFUNC glRenderMode,196,-1,4
-GLFUNC glRotated,299,138,32
-GLFUNC glRotatef,300,139,16
-GLFUNC glScaled,301,140,24
-GLFUNC glScalef,302,141,12
-GLFUNC glScissor,176,-1,16
-GLFUNC glSelectBuffer,195,-1,8
-GLFUNC glShadeModel,177,-1,4
-GLFUNC glStencilFunc,243,-1,12
-GLFUNC glStencilMask,209,-1,4
-GLFUNC glStencilOp,244,-1,12
-GLFUNC glTexCoord1d,94,56,8
-GLFUNC glTexCoord1dv,95,57,4
-GLFUNC glTexCoord1f,96,58,4
-GLFUNC glTexCoord1fv,97,59,4
-GLFUNC glTexCoord1i,98,60,4
-GLFUNC glTexCoord1iv,99,61,4
-GLFUNC glTexCoord1s,100,62,4
-GLFUNC glTexCoord1sv,101,63,4
-GLFUNC glTexCoord2d,102,64,16
-GLFUNC glTexCoord2dv,103,65,4
-GLFUNC glTexCoord2f,104,66,8
-GLFUNC glTexCoord2fv,105,67,4
-GLFUNC glTexCoord2i,106,68,8
-GLFUNC glTexCoord2iv,107,69,4
-GLFUNC glTexCoord2s,108,70,8
-GLFUNC glTexCoord2sv,109,71,4
-GLFUNC glTexCoord3d,110,72,24
-GLFUNC glTexCoord3dv,111,73,4
-GLFUNC glTexCoord3f,112,74,12
-GLFUNC glTexCoord3fv,113,75,4
-GLFUNC glTexCoord3i,114,76,12
-GLFUNC glTexCoord3iv,115,77,4
-GLFUNC glTexCoord3s,116,78,12
-GLFUNC glTexCoord3sv,117,79,4
-GLFUNC glTexCoord4d,118,80,32
-GLFUNC glTexCoord4dv,119,81,4
-GLFUNC glTexCoord4f,120,82,16
-GLFUNC glTexCoord4fv,121,83,4
-GLFUNC glTexCoord4i,122,84,16
-GLFUNC glTexCoord4iv,123,85,4
-GLFUNC glTexCoord4s,124,86,16
-GLFUNC glTexCoord4sv,125,87,4
-GLFUNC glTexCoordPointer,320,158,16
-GLFUNC glTexEnvf,184,-1,12
-GLFUNC glTexEnvfv,185,-1,12
-GLFUNC glTexEnvi,186,-1,12
-GLFUNC glTexEnviv,187,-1,12
-GLFUNC glTexGend,188,-1,16
-GLFUNC glTexGendv,189,-1,12
-GLFUNC glTexGenf,190,-1,12
-GLFUNC glTexGenfv,191,-1,12
-GLFUNC glTexGeni,192,-1,12
-GLFUNC glTexGeniv,193,-1,12
-GLFUNC glTexImage1D,182,-1,32
-GLFUNC glTexImage2D,183,-1,36
-GLFUNC glTexParameterf,178,-1,12
-GLFUNC glTexParameterfv,179,-1,12
-GLFUNC glTexParameteri,180,-1,12
-GLFUNC glTexParameteriv,181,-1,12
-GLFUNC glTexSubImage1D,332,-1,28
-GLFUNC glTexSubImage2D,333,-1,36
-GLFUNC glTranslated,303,142,24
-GLFUNC glTranslatef,304,143,12
-GLFUNC glVertex2d,126,88,16
-GLFUNC glVertex2dv,127,89,4
-GLFUNC glVertex2f,128,90,8
-GLFUNC glVertex2fv,129,91,4
-GLFUNC glVertex2i,130,92,8
-GLFUNC glVertex2iv,131,93,4
-GLFUNC glVertex2s,132,94,8
-GLFUNC glVertex2sv,133,95,4
-GLFUNC glVertex3d,134,96,24
-GLFUNC glVertex3dv,135,97,4
-GLFUNC glVertex3f,136,98,12
-GLFUNC glVertex3fv,137,99,4
-GLFUNC glVertex3i,138,100,12
-GLFUNC glVertex3iv,139,101,4
-GLFUNC glVertex3s,140,102,12
-GLFUNC glVertex3sv,141,103,4
-GLFUNC glVertex4d,142,104,32
-GLFUNC glVertex4dv,143,105,4
-GLFUNC glVertex4f,144,106,16
-GLFUNC glVertex4fv,145,107,4
-GLFUNC glVertex4i,146,108,16
-GLFUNC glVertex4iv,147,109,4
-GLFUNC glVertex4s,148,110,16
-GLFUNC glVertex4sv,149,111,4
-GLFUNC glVertexPointer,321,159,16
-GLFUNC glViewport,305,-1,16

reactos/lib/opengl32
slowlist.h removed after 1.1
diff -N slowlist.h
--- slowlist.h	6 Feb 2004 18:17:18 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,192 +0,0 @@
-/*
- * COPYRIGHT:            See COPYING in the top level directory
- * PROJECT:              ReactOS kernel
- * FILE:                 lib/opengl32/glfuncs.h
- * PURPOSE:              OpenGL32 lib, GLFUNCS_MACRO
- * PROGRAMMER:           gen_glfuncs_macro.sh
- * UPDATE HISTORY:
- *               !!! AUTOMATICALLY CREATED FROM glfuncs.csv !!!
- */
-
-/* To use this macro define a macro X(name, ret, typeargs, args, icdidx, tebidx, stack).
- * It gets called for every glXXX function. i.e. glVertex3f: name = "glVertex3f",
- * ret = "void", typeargs = "(GLfloat x, GLfloat y, GLfloat z)", args = "(x,y,z)",
- * icdidx = "136", tebidx = "98" and stack = "12".
- * Don't forget to undefine X ;-)
- */
-
-XVOID(glAccum,(GLenum op, GLfloat value), (op,value),  213,  8)
-XVOID(glAlphaFunc, (GLenum func, GLclampf ref), (func,ref),  240,  8)
-X(glAreTexturesResident, GLboolean, (GLsizei n, const GLuint *textures, GLboolean *residences), (n,textures,residences),  322,  12)
-XVOID(glBitmap, (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap), (width,height,xorig,yorig,xmove,ymove,bitmap),  8,  28)
-XVOID(glBlendFunc, (GLenum sfactor, GLenum dfactor), (sfactor,dfactor),  241,  8)
-XVOID(glClear, (GLbitfield mask), (mask),  203,  4)
-XVOID(glClearAccum, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red,green,blue,alpha),  204,  16)
-XVOID(glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red,green,blue,alpha),  206,  16)
-XVOID(glClearDepth, (GLclampd depth), (depth),  208,  8)
-XVOID(glClearIndex, (GLfloat c), (c),  205,  4)
-XVOID(glClearStencil, (GLint s), (s),  207,  4)
-XVOID(glClipPlane, (GLenum plane, const GLdouble *equation), (plane,equation),  150,  8)
-XVOID(glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red,green,blue,alpha),  210,  16)
-XVOID(glColorMaterial, (GLenum face, GLenum mode), (face,mode),  151,  8)
-XVOID(glCopyPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type), (x,y,width,height,type),  255,  20)
-XVOID(glCopyTexImage1D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border), (target,level,internalformat,x,y,width,border),  323,  28)
-XVOID(glCopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target,level,internalformat,x,y,width,height,border),  324,  32)
-XVOID(glCopyTexSubImage1D, (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width), (target,level,xoffset,x,y,width),  325,  24)
-XVOID(glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target,level,xoffset,yoffset,x,y,width,height),  326,  32)
-XVOID(glCullFace, (GLenum mode), (mode),  152,  4)
-XVOID(glDeleteLists, (GLuint list, GLsizei range), (list,range),  4,  8)
-XVOID(glDeleteTextures, (GLsizei n, const GLuint *textures), (n,textures),  327,  8)
-XVOID(glDepthFunc, (GLenum func), (func),  245,  4)
-XVOID(glDepthMask, (GLboolean flag), (flag),  211,  4)
-XVOID(glDepthRange, (GLclampd zNear, GLclampd zFar), (zNear,zFar),  288,  16)
-XVOID(glDrawBuffer, (GLenum mode), (mode),  202,  4)
-XVOID(glDrawPixels, (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (width,height,format,type,pixels),  257,  20)
-XVOID(glEndList, (void), (),  1,  0)
-XVOID(glEvalMesh1, (GLenum mode, GLint i1, GLint i2), (mode,i1,i2),  236,  12)
-XVOID(glEvalMesh2, (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2), (mode,i1,i2,j1,j2),  238,  20)
-XVOID(glFeedbackBuffer, (GLsizei size, GLenum type, GLfloat *buffer), (size,type,buffer),  194,  12)
-XVOID(glFinish, (void), (),  216,  0)
-XVOID(glFlush, (void), (),  217,  0)
-XVOID(glFogf, (GLenum pname, GLfloat param), (pname,param),  153,  8)
-XVOID(glFogfv, (GLenum pname, const GLfloat *params), (pname,params),  154,  8)
-XVOID(glFogi, (GLenum pname, GLint param), (pname,param),  155,  8)
-XVOID(glFogiv, (GLenum pname, const GLint *params), (pname,params),  156,  8)
-XVOID(glFrontFace, (GLenum mode), (mode),  157,  4)
-XVOID(glFrustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar),  289,  48)
-X(glGenLists, GLuint, (GLsizei range), (range),  5,  4)
-XVOID(glGenTextures, (GLsizei n, GLuint *textures), (n,textures),  328,  8)
-XVOID(glGetBooleanv, (GLenum pname, GLboolean *params), (pname,params),  258,  8)
-XVOID(glGetClipPlane, (GLenum plane, GLdouble *equation), (plane,equation),  259,  8)
-XVOID(glGetDoublev, (GLenum pname, GLdouble *params), (pname,params),  260,  8)
-X(glGetError, GLenum, (void), (),  261,  0)
-XVOID(glGetFloatv, (GLenum pname, GLfloat *params), (pname,params),  262,  8)
-XVOID(glGetIntegerv, (GLenum pname, GLint *params), (pname,params),  263,  8)
-XVOID(glGetLightfv, (GLenum light, GLenum pname, GLfloat *params), (light,pname,params),  264,  12)
-XVOID(glGetLightiv, (GLenum light, GLenum pname, GLint *params), (light,pname,params),  265,  12)
-XVOID(glGetMapdv, (GLenum target, GLenum query, GLdouble *v), (target,query,v),  266,  12)
-XVOID(glGetMapfv, (GLenum target, GLenum query, GLfloat *v), (target,query,v),  267,  12)
-XVOID(glGetMapiv, (GLenum target, GLenum query, GLint *v), (target,query,v),  268,  12)
-XVOID(glGetMaterialfv, (GLenum face, GLenum pname, GLfloat *params), (face,pname,params),  269,  12)
-XVOID(glGetMaterialiv, (GLenum face, GLenum pname, GLint *params), (face,pname,params),  270,  12)
-XVOID(glGetPixelMapfv, (GLenum map, GLfloat *values), (map,values),  271,  8)
-XVOID(glGetPixelMapuiv, (GLenum map, GLuint *values), (map,values),  272,  8)
-XVOID(glGetPixelMapusv, (GLenum map, GLushort *values), (map,values),  273,  8)
-XVOID(glGetPolygonStipple, (GLubyte *mask), (mask),  274,  4)
-X(glGetString, const GLubyte* , (GLenum name), (name),  275,  4)
-XVOID(glGetTexEnvfv, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params),  276,  12)
-XVOID(glGetTexEnviv, (GLenum target, GLenum pname, GLint *params), (target,pname,params),  277,  12)
-XVOID(glGetTexGendv, (GLenum coord, GLenum pname, GLdouble *params), (coord,pname,params),  278,  12)
-XVOID(glGetTexGenfv, (GLenum coord, GLenum pname, GLfloat *params), (coord,pname,params),  279,  12)
-XVOID(glGetTexGeniv, (GLenum coord, GLenum pname, GLint *params), (coord,pname,params),  280,  12)
-XVOID(glGetTexImage, (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels), (target,level,format,type,pixels),  281,  20)
-XVOID(glGetTexLevelParameterfv, (GLenum target, GLint level, GLenum pname, GLfloat *params), (target,level,pname,params),  284,  16)
-XVOID(glGetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint *params), (target,level,pname,params),  285,  16)
-XVOID(glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params),  282,  12)
-XVOID(glGetTexParameteriv, (GLenum target, GLenum pname, GLint *params), (target,pname,params),  283,  12)
-XVOID(glHint, (GLenum target, GLenum mode), (target,mode),  158,  8)
-XVOID(glIndexMask, (GLuint mask), (mask),  212,  4)
-XVOID(glInitNames, (void), (),  197,  0)
-X(glIsEnabled, GLboolean, (GLenum cap), (cap),  286,  4)
-X(glIsList, GLboolean, (GLuint list), (list),  287,  4)
-X(glIsTexture, GLboolean, (GLuint texture), (texture),  330,  4)
-XVOID(glLightModelf, (GLenum pname, GLfloat param), (pname,param),  163,  8)
-XVOID(glLightModelfv, (GLenum pname, const GLfloat *params), (pname,params),  164,  8)
-XVOID(glLightModeli, (GLenum pname, GLint param), (pname,param),  165,  8)
-XVOID(glLightModeliv, (GLenum pname, const GLint *params), (pname,params),  166,  8)
-XVOID(glLightf, (GLenum light, GLenum pname, GLfloat param), (light,pname,param),  159,  12)
-XVOID(glLightfv, (GLenum light, GLenum pname, const GLfloat *params), (light,pname,params),  160,  12)
-XVOID(glLighti, (GLenum light, GLenum pname, GLint param), (light,pname,param),  161,  12)
-XVOID(glLightiv, (GLenum light, GLenum pname, const GLint *params), (light,pname,params),  162,  12)
-XVOID(glLineStipple, (GLint factor, GLushort pattern), (factor,pattern),  167,  8)
-XVOID(glLineWidth, (GLfloat width), (width),  168,  4)
-XVOID(glListBase, (GLuint base), (base),  6,  4)
-XVOID(glLoadName, (GLuint name), (name),  198,  4)
-XVOID(glLogicOp, (GLenum opcode), (opcode),  242,  4)
-XVOID(glMap1d, (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points), (target,u1,u2,stride,order,points),  220,  32)
-XVOID(glMap1f, (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points), (target,u1,u2,stride,order,points),  221,  24)
-XVOID(glMap2d, (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points),  222,  56)
-XVOID(glMap2f, (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points),  223,  40)
-XVOID(glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2), (un,u1,u2),  224,  20)
-XVOID(glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2), (un,u1,u2),  225,  12)
-XVOID(glMapGrid2d, (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2), (un,u1,u2,vn,v1,v2),  226,  40)
-XVOID(glMapGrid2f, (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2), (un,u1,u2,vn,v1,v2),  227,  24)
-XVOID(glNewList, (GLuint list, GLenum mode), (list,mode),  0,  8)
-XVOID(glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar),  296,  48)
-XVOID(glPassThrough, (GLfloat token), (token),  199,  4)
-XVOID(glPixelMapfv, (GLenum map, GLint mapsize, const GLfloat *values), (map,mapsize,values),  251,  12)
-XVOID(glPixelMapuiv, (GLenum map, GLint mapsize, const GLuint *values), (map,mapsize,values),  252,  12)
-XVOID(glPixelMapusv, (GLenum map, GLint mapsize, const GLushort *values), (map,mapsize,values),  253,  12)
-XVOID(glPixelStoref, (GLenum pname, GLfloat param), (pname,param),  249,  8)
-XVOID(glPixelStorei, (GLenum pname, GLint param), (pname,param),  250,  8)
-XVOID(glPixelTransferf, (GLenum pname, GLfloat param), (pname,param),  247,  8)
-XVOID(glPixelTransferi, (GLenum pname, GLint param), (pname,param),  248,  8)
-XVOID(glPixelZoom, (GLfloat xfactor, GLfloat yfactor), (xfactor,yfactor),  246,  8)
-XVOID(glPointSize, (GLfloat size), (size),  173,  4)
-XVOID(glPolygonMode, (GLenum face, GLenum mode), (face,mode),  174,  8)
-XVOID(glPolygonStipple, (const GLubyte *mask), (mask),  175,  4)
-XVOID(glPopName, (void), (),  200,  0)
-XVOID(glPrioritizeTextures, (GLsizei n, const GLuint *textures, const GLclampf *priorities), (n,textures,priorities),  331,  12)
-XVOID(glPushName, (GLuint name), (name),  201,  4)
-XVOID(glRasterPos2d, (GLdouble x, GLdouble y), (x,y),  62,  16)
-XVOID(glRasterPos2dv, (const GLdouble *v), (v),  63,  4)
-XVOID(glRasterPos2f, (GLfloat x, GLfloat y), (x,y),  64,  8)
-XVOID(glRasterPos2fv, (const GLfloat *v), (v),  65,  4)
-XVOID(glRasterPos2i, (GLint x, GLint y), (x,y),  66,  8)
-XVOID(glRasterPos2iv, (const GLint *v), (v),  67,  4)
-XVOID(glRasterPos2s, (GLshort x, GLshort y), (x,y),  68,  8)
-XVOID(glRasterPos2sv, (const GLshort *v), (v),  69,  4)
-XVOID(glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z), (x,y,z),  70,  24)
-XVOID(glRasterPos3dv, (const GLdouble *v), (v),  71,  4)
-XVOID(glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z), (x,y,z),  72,  12)
-XVOID(glRasterPos3fv, (const GLfloat *v), (v),  73,  4)
-XVOID(glRasterPos3i, (GLint x, GLint y, GLint z), (x,y,z),  74,  12)
-XVOID(glRasterPos3iv, (const GLint *v), (v),  75,  4)
-XVOID(glRasterPos3s, (GLshort x, GLshort y, GLshort z), (x,y,z),  76,  12)
-XVOID(glRasterPos3sv, (const GLshort *v), (v),  77,  4)
-XVOID(glRasterPos4d, (GLdouble x, GLdouble y, GLdouble z, GLdouble w), (x,y,z,w),  78,  32)
-XVOID(glRasterPos4dv, (const GLdouble *v), (v),  79,  4)
-XVOID(glRasterPos4f, (GLfloat x, GLfloat y, GLfloat z, GLfloat w), (x,y,z,w),  80,  16)
-XVOID(glRasterPos4fv, (const GLfloat *v), (v),  81,  4)
-XVOID(glRasterPos4i, (GLint x, GLint y, GLint z, GLint w), (x,y,z,w),  82,  16)
-XVOID(glRasterPos4iv, (const GLint *v), (v),  83,  4)
-XVOID(glRasterPos4s, (GLshort x, GLshort y, GLshort z, GLshort w), (x,y,z,w),  84,  16)
-XVOID(glRasterPos4sv, (const GLshort *v), (v),  85,  4)
-XVOID(glReadBuffer, (GLenum mode), (mode),  254,  4)
-XVOID(glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels), (x,y,width,height,format,type,pixels),  256,  28)
-XVOID(glRectd, (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2), (x1,y1,x2,y2),  86,  32)
-XVOID(glRectdv, (const GLdouble *v1, const GLdouble *v2), (v1,v2),  87,  8)
-XVOID(glRectf, (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2), (x1,y1,x2,y2),  88,  16)
-XVOID(glRectfv, (const GLfloat *v1, const GLfloat *v2), (v1,v2),  89,  8)
-XVOID(glRecti, (GLint x1, GLint y1, GLint x2, GLint y2), (x1,y1,x2,y2),  90,  16)
-XVOID(glRectiv, (const GLint *v1, const GLint *v2), (v1,v2),  91,  8)
-XVOID(glRects, (GLshort x1, GLshort y1, GLshort x2, GLshort y2), (x1,y1,x2,y2),  92,  16)
-XVOID(glRectsv, (const GLshort *v1, const GLshort *v2), (v1,v2),  93,  8)
-X(glRenderMode, GLint, (GLenum mode), (mode),  196,  4)
-XVOID(glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height),  176,  16)
-XVOID(glSelectBuffer, (GLsizei size, GLuint *buffer), (size,buffer),  195,  8)
-XVOID(glShadeModel, (GLenum mode), (mode),  177,  4)
-XVOID(glStencilFunc, (GLenum func, GLint ref, GLuint mask), (func,ref,mask),  243,  12)
-XVOID(glStencilMask, (GLuint mask), (mask),  209,  4)
-XVOID(glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass), (fail,zfail,zpass),  244,  12)
-XVOID(glTexEnvf, (GLenum target, GLenum pname, GLfloat param), (target,pname,param),  184,  12)
-XVOID(glTexEnvfv, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params),  185,  12)
-XVOID(glTexEnvi, (GLenum target, GLenum pname, GLint param), (target,pname,param),  186,  12)
-XVOID(glTexEnviv, (GLenum target, GLenum pname, const GLint *params), (target,pname,params),  187,  12)
-XVOID(glTexGend, (GLenum coord, GLenum pname, GLdouble param), (coord,pname,param),  188,  16)
-XVOID(glTexGendv, (GLenum coord, GLenum pname, const GLdouble *params), (coord,pname,params),  189,  12)
-XVOID(glTexGenf, (GLenum coord, GLenum pname, GLfloat param), (coord,pname,param),  190,  12)
-XVOID(glTexGenfv, (GLenum coord, GLenum pname, const GLfloat *params), (coord,pname,params),  191,  12)
-XVOID(glTexGeni, (GLenum coord, GLenum pname, GLint param), (coord,pname,param),  192,  12)
-XVOID(glTexGeniv, (GLenum coord, GLenum pname, const GLint *params), (coord,pname,params),  193,  12)
-XVOID(glTexImage1D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,border,format,type,pixels),  182,  32)
-XVOID(glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,height,border,format,type,pixels),  183,  36)
-XVOID(glTexParameterf, (GLenum target, GLenum pname, GLfloat param), (target,pname,param),  178,  12)
-XVOID(glTexParameterfv, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params),  179,  12)
-XVOID(glTexParameteri, (GLenum target, GLenum pname, GLint param), (target,pname,param),  180,  12)
-XVOID(glTexParameteriv, (GLenum target, GLenum pname, const GLint *params), (target,pname,params),  181,  12)
-XVOID(glTexSubImage1D, (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,width,format,type,pixels),  332,  28)
-XVOID(glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,yoffset,width,height,format,type,pixels),  333,  36)
-XVOID(glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height),  305,  16)
-
-/* EOF */

reactos/lib/opengl32
slowlist.mac removed after 1.1
diff -N slowlist.mac
--- slowlist.mac	6 Feb 2004 19:18:39 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,174 +0,0 @@
-;SLOW_ENTRY name,icdidx,stack
-SLOW_ENTRY glAccum,213,8
-SLOW_ENTRY glAlphaFunc,240,8
-SLOW_ENTRY glAreTexturesResident,322,12
-SLOW_ENTRY glBitmap,8,28
-SLOW_ENTRY glBlendFunc,241,8
-SLOW_ENTRY glClear,203,4
-SLOW_ENTRY glClearAccum,204,16
-SLOW_ENTRY glClearColor,206,16
-SLOW_ENTRY glClearDepth,208,8
-SLOW_ENTRY glClearIndex,205,4
-SLOW_ENTRY glClearStencil,207,4
-SLOW_ENTRY glClipPlane,150,8
-SLOW_ENTRY glColorMask,210,16
-SLOW_ENTRY glColorMaterial,151,8
-SLOW_ENTRY glCopyPixels,255,20
-SLOW_ENTRY glCopyTexImage1D,323,28
-SLOW_ENTRY glCopyTexImage2D,324,32
-SLOW_ENTRY glCopyTexSubImage1D,325,24
-SLOW_ENTRY glCopyTexSubImage2D,326,32
-SLOW_ENTRY glCullFace,152,4
-SLOW_ENTRY glDeleteLists,4,8
-SLOW_ENTRY glDeleteTextures,327,8
-SLOW_ENTRY glDepthFunc,245,4
-SLOW_ENTRY glDepthMask,211,4
-SLOW_ENTRY glDepthRange,288,16
-SLOW_ENTRY glDrawBuffer,202,4
-SLOW_ENTRY glDrawPixels,257,20
-SLOW_ENTRY glEndList,1,0
-SLOW_ENTRY glEvalMesh1,236,12
-SLOW_ENTRY glEvalMesh2,238,20
-SLOW_ENTRY glFeedbackBuffer,194,12
-SLOW_ENTRY glFinish,216,0
-SLOW_ENTRY glFlush,217,0
-SLOW_ENTRY glFogf,153,8
-SLOW_ENTRY glFogfv,154,8
-SLOW_ENTRY glFogi,155,8
-SLOW_ENTRY glFogiv,156,8
-SLOW_ENTRY glFrontFace,157,4
-SLOW_ENTRY glFrustum,289,48
-SLOW_ENTRY glGenLists,5,4
-SLOW_ENTRY glGenTextures,328,8
-SLOW_ENTRY glGetBooleanv,258,8
-SLOW_ENTRY glGetClipPlane,259,8
-SLOW_ENTRY glGetDoublev,260,8
-SLOW_ENTRY glGetError,261,0
-SLOW_ENTRY glGetFloatv,262,8
-SLOW_ENTRY glGetIntegerv,263,8
-SLOW_ENTRY glGetLightfv,264,12
-SLOW_ENTRY glGetLightiv,265,12
-SLOW_ENTRY glGetMapdv,266,12
-SLOW_ENTRY glGetMapfv,267,12
-SLOW_ENTRY glGetMapiv,268,12
-SLOW_ENTRY glGetMaterialfv,269,12
-SLOW_ENTRY glGetMaterialiv,270,12
-SLOW_ENTRY glGetPixelMapfv,271,8
-SLOW_ENTRY glGetPixelMapuiv,272,8
-SLOW_ENTRY glGetPixelMapusv,273,8
-SLOW_ENTRY glGetPolygonStipple,274,4
-SLOW_ENTRY glGetString,275,4
-SLOW_ENTRY glGetTexEnvfv,276,12
-SLOW_ENTRY glGetTexEnviv,277,12
-SLOW_ENTRY glGetTexGendv,278,12
-SLOW_ENTRY glGetTexGenfv,279,12
-SLOW_ENTRY glGetTexGeniv,280,12
-SLOW_ENTRY glGetTexImage,281,20
-SLOW_ENTRY glGetTexLevelParameterfv,284,16
-SLOW_ENTRY glGetTexLevelParameteriv,285,16
-SLOW_ENTRY glGetTexParameterfv,282,12
-SLOW_ENTRY glGetTexParameteriv,283,12
-SLOW_ENTRY glHint,158,8
-SLOW_ENTRY glIndexMask,212,4
-SLOW_ENTRY glInitNames,197,0
-SLOW_ENTRY glIsEnabled,286,4
-SLOW_ENTRY glIsList,287,4
-SLOW_ENTRY glIsTexture,330,4
-SLOW_ENTRY glLightModelf,163,8
-SLOW_ENTRY glLightModelfv,164,8
-SLOW_ENTRY glLightModeli,165,8
-SLOW_ENTRY glLightModeliv,166,8
-SLOW_ENTRY glLightf,159,12
-SLOW_ENTRY glLightfv,160,12
-SLOW_ENTRY glLighti,161,12
-SLOW_ENTRY glLightiv,162,12
-SLOW_ENTRY glLineStipple,167,8
-SLOW_ENTRY glLineWidth,168,4
-SLOW_ENTRY glListBase,6,4
-SLOW_ENTRY glLoadName,198,4
-SLOW_ENTRY glLogicOp,242,4
-SLOW_ENTRY glMap1d,220,32
-SLOW_ENTRY glMap1f,221,24
-SLOW_ENTRY glMap2d,222,56
-SLOW_ENTRY glMap2f,223,40
-SLOW_ENTRY glMapGrid1d,224,20
-SLOW_ENTRY glMapGrid1f,225,12
-SLOW_ENTRY glMapGrid2d,226,40
-SLOW_ENTRY glMapGrid2f,227,24
-SLOW_ENTRY glNewList,0,8
-SLOW_ENTRY glOrtho,296,48
-SLOW_ENTRY glPassThrough,199,4
-SLOW_ENTRY glPixelMapfv,251,12
-SLOW_ENTRY glPixelMapuiv,252,12
-SLOW_ENTRY glPixelMapusv,253,12
-SLOW_ENTRY glPixelStoref,249,8
-SLOW_ENTRY glPixelStorei,250,8
-SLOW_ENTRY glPixelTransferf,247,8
-SLOW_ENTRY glPixelTransferi,248,8
-SLOW_ENTRY glPixelZoom,246,8
-SLOW_ENTRY glPointSize,173,4
-SLOW_ENTRY glPolygonMode,174,8
-SLOW_ENTRY glPolygonStipple,175,4
-SLOW_ENTRY glPopName,200,0
-SLOW_ENTRY glPrioritizeTextures,331,12
-SLOW_ENTRY glPushName,201,4
-SLOW_ENTRY glRasterPos2d,62,16
-SLOW_ENTRY glRasterPos2dv,63,4
-SLOW_ENTRY glRasterPos2f,64,8
-SLOW_ENTRY glRasterPos2fv,65,4
-SLOW_ENTRY glRasterPos2i,66,8
-SLOW_ENTRY glRasterPos2iv,67,4
-SLOW_ENTRY glRasterPos2s,68,8
-SLOW_ENTRY glRasterPos2sv,69,4
-SLOW_ENTRY glRasterPos3d,70,24
-SLOW_ENTRY glRasterPos3dv,71,4
-SLOW_ENTRY glRasterPos3f,72,12
-SLOW_ENTRY glRasterPos3fv,73,4
-SLOW_ENTRY glRasterPos3i,74,12
-SLOW_ENTRY glRasterPos3iv,75,4
-SLOW_ENTRY glRasterPos3s,76,12
-SLOW_ENTRY glRasterPos3sv,77,4
-SLOW_ENTRY glRasterPos4d,78,32
-SLOW_ENTRY glRasterPos4dv,79,4
-SLOW_ENTRY glRasterPos4f,80,16
-SLOW_ENTRY glRasterPos4fv,81,4
-SLOW_ENTRY glRasterPos4i,82,16
-SLOW_ENTRY glRasterPos4iv,83,4
-SLOW_ENTRY glRasterPos4s,84,16
-SLOW_ENTRY glRasterPos4sv,85,4
-SLOW_ENTRY glReadBuffer,254,4
-SLOW_ENTRY glReadPixels,256,28
-SLOW_ENTRY glRectd,86,32
-SLOW_ENTRY glRectdv,87,8
-SLOW_ENTRY glRectf,88,16
-SLOW_ENTRY glRectfv,89,8
-SLOW_ENTRY glRecti,90,16
-SLOW_ENTRY glRectiv,91,8
-SLOW_ENTRY glRects,92,16
-SLOW_ENTRY glRectsv,93,8
-SLOW_ENTRY glRenderMode,196,4
-SLOW_ENTRY glScissor,176,16
-SLOW_ENTRY glSelectBuffer,195,8
-SLOW_ENTRY glShadeModel,177,4
-SLOW_ENTRY glStencilFunc,243,12
-SLOW_ENTRY glStencilMask,209,4
-SLOW_ENTRY glStencilOp,244,12
-SLOW_ENTRY glTexEnvf,184,12
-SLOW_ENTRY glTexEnvfv,185,12
-SLOW_ENTRY glTexEnvi,186,12
-SLOW_ENTRY glTexEnviv,187,12
-SLOW_ENTRY glTexGend,188,16
-SLOW_ENTRY glTexGendv,189,12
-SLOW_ENTRY glTexGenf,190,12
-SLOW_ENTRY glTexGenfv,191,12
-SLOW_ENTRY glTexGeni,192,12
-SLOW_ENTRY glTexGeniv,193,12
-SLOW_ENTRY glTexImage1D,182,32
-SLOW_ENTRY glTexImage2D,183,36
-SLOW_ENTRY glTexParameterf,178,12
-SLOW_ENTRY glTexParameterfv,179,12
-SLOW_ENTRY glTexParameteri,180,12
-SLOW_ENTRY glTexParameteriv,181,12
-SLOW_ENTRY glTexSubImage1D,332,28
-SLOW_ENTRY glTexSubImage2D,333,36
-SLOW_ENTRY glViewport,305,16

reactos/lib/opengl32
stubs.c removed after 1.3
diff -N stubs.c
--- stubs.c	3 Feb 2004 14:23:42 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,520 +0,0 @@
-/* $Id: stubs.c,v 1.3 2004/02/03 14:23:42 royce Exp $
- *
- * COPYRIGHT:            See COPYING in the top level directory
- * PROJECT:              ReactOS kernel
- * FILE:                 lib/opengl32/stubs.c
- * PURPOSE:              OpenGL32 lib
- * PROGRAMMER:           Royce Mitchell III (Royce3)
- * UPDATE HISTORY:
- *                       Feb 1, 2004: Created
- */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-/*#include <gl/gl.h>*/
-#include "opengl32.h"
-
-GLFUNCLIST*
-OPENGL32_GetFuncList(); // see bottom of this file...
-
-/*
- * @implemented
- */
-void
-WINAPI
-glAccum (
-	GLenum op,
-	GLfloat value )
-{
-	GLFUNCLIST* list = OPENGL32_GetFuncList();
-	/* FIXME - jump directly to target... */
-	if ( list )
-		(*list->glAccum)(op,value);
-}
-
-/*
- * @implemented
- */
-static // not exported, except via wglGetProcAddress
-void
-WINAPI
-glAddSwapHintRectWIN (
-	GLint x,
-	GLint y,
-	GLsizei width,
-	GLsizei height )
-{
-	(*OPENGL32_GetFuncList()->glAddSwapHintRectWIN)(x,y,width,height);
-}
-
-/*
- * @implemented
- */
-void
-WINAPI
-glAlphaFunc (
-	GLenum func,
-	GLclampf ref )
-{
-	(*OPENGL32_GetFuncList()->glAlphaFunc)(func,ref);
-}
-
-/*
- * @unimplemented
- */
-GLboolean
-WINAPI
-glAreTexturesResident (
-	GLsizei n,
-	GLuint * textures
-	GLboolean * residences )
-{
-	UNIMPLEMENTED; /* FIXME */
-}
-
-/*
- * @unimplemented
- */
-void
-WINAPI
-glArrayElement ( GLint index )
-{
-	UNIMPLEMENTED; /* FIXME */
-}
-
-/*
- * @unimplemented
- */
-void
-WINAPI
-glBegin ( GLenum mode )
-{
-	UNIMPLEMENTED; /* FIXME */
-}
-
-/*
- * @unimplemented
- */
-void
-WINAPI
-glBindTexture ( GLenum target, GLuint texture )
-{
-	UNIMPLEMENTED; /* FIXME */
-}
-
-/*
-glBindTexture=glBindTexture@8
-glBitmap=glBitmap@28
-glBlendFunc=glBlendFunc@8
-glCallList=glCallList@4
-glCallLists=glCallLists@12
-glClear=glClear@4
-glClearAccum=glClearAccum@16
-glClearColor=glClearColor@16
-glClearDepth=glClearDepth@4
-glClearIndex=glClearIndex@4
-glClearStencil=glClearStencil@4
-glClipPlane=glClipPlane@8
-
-glColor3b=glColor3b@3
-glColor3bv=glColor3b@4
-glColor3d=glColor3d@24
-glColor3dv=glColor3d@4
-glColor3f=glColor3f@12
-glColor3fv=glColor3fv@4
-glColor3i=glColor3i@12
-glColor3iv=glColor3iv@4
-glColor3s=glColor3s@6
-glColor3sv=glColor3sv@4
-glColor3ub=glColor3ub@3
-glColor3ubv=glColor3ubv@4
-glColor3ui=glColor3ui@12
-glColor3uiv=glColor3uiv@4
-glColor3us=glColor3us@6
-glColor3usv=glColor3usv@4
-
-glColor4b=glColor4b@4
-glColor4bv=glColor4bv@4
-glColor4d=glColor4d@32
-glColor4dv=glColor4dv@4
-glColor4f=glColor4f@16
-glColor4fv=glColor4fv@4
-glColor4i=glColor4i@16
-glColor4iv=glColor4iv@4
-glColor4s=glColor4s@8
-glColor4sv=glColor4sv@4
-glColor4ub=glColor4ub@4
-glColor4ubv=glColor4ubv@4
-glColor4ui=glColor4ui@16
-glColor4uiv=glColor4uiv@4
-glColor4us=glColor4us@8
-glColor4usv=glColor4usv@4
-
-glColorMask=glColorMask@4
-glColorMaterial=glColorMaterial@8
-glColorPointer=glColorPointer@16
-glCopyPixels=glCopyPixels@20
-glCopyTexImage1D=glCopyTexImage1D@28
-glCopyTexImage2D=glCopyTexImage2D@32
-glCopyTexSubImage1D=glCopyTexSubImage1D@24
-glCopyTexSubImage2D=glCopyTexSubImage2D@32
-glCullFace=glCullFace@4
-;glDebugEntry
-glDeleteLists=glDeleteLists@8
-glDeleteTextures=glDeleteTextues@8
-glDepthFunc=glDepthFunc@4
-glDepthMask=glDepthMask@4
-glDepthRange=glDepthRange@8
-glDisable=glDisable@4
-glDisableClientState=glDisableClientState@4
-glDrawArrays=glDrawArrays@12
-glDrawBuffer=glDrawBuffer@4
-glDrawElements=glDrawElements@16
-glDrawPixels=glDrawPixels@20
-glEdgeFlag=glEdgeFlag@1
-glEdgeFlagPointer=glEdgeFlagPointer@8
-glEdgeFlagv=glEdgeFlagv@4
-glEnable=glEnable@4
-glEnableClientState=glEnableClientState@4
-*/
-
-/*
- * @unimplemented
- */
-void
-WINAPI
-glEnd ( void )
-{
-	UNIMPLEMENTED; /* FIXME */
-}
-
-/*
-glEndList=glEndList@0
-
-glEvalCoord1d=glEvalCoord1d@8
-glEvalCoord1dv=glEvalCoord1dv@4
-glEvalCoord1f=glEvalCoord1f@4
-glEvalCoord1fv=glEvalCoord1fv@4
-glEvalCoord2d=glEvalCoord2d@16
-glEvalCoord2dv=glEvalCoord2dv@4
-glEvalCoord2f=glEvalCoord2f@8
-glEvalCoord2fv=glEvalCoord2fv@4
-
-glEvalMesh1=glEvalMesh1@12
-glEvalMesh2=glEvalMesh2@12
-glEvalPoint1=glEvalPoint1@4
-glEvalPoint2=glEvalPoint2@8
-glFeedbackBuffer=glFeedbackBuffer@12
-glFinish=glFinish@0
-glFlush=glFlush@0
-glFogf=glFogf@8
-glFogfv=glFogv@8
-glFogi=glFogi@8
-glFogiv=glFogiv@8
-glFrontFace=glFrontFace@4
-glFrustum=glFrustum@48
-glGenLists=glGenLists@4
-glGenTextures=glGenTextires@8
-glGetBooleanv=glGetBooleanv@8
-glGetClipPlane=glGetClipPlane@8
-glGetDoublev=glGetDoublev@8
-glGetError=glGetError@0
-glGetFloatv=glGetFloatv@8
-glGetIntegerv=glGetIntegerv@8
-glGetLightfv=glGetLightfv@12
-glGetLightiv=glGetLightiv@12
-glGetMapdv=glGetMapdv@12
-glGetMapfv=glGetMapfv@12
-glGetMapiv=glGetMapiv@12
-glGetMaterialfv=glGetMaterialfv@12
-glGetMaterialiv=glGetMaterialiv@12
-glGetPixelMapfv=glGetPixelMapfv@8
-glGetPixelMapuiv=glGetPixelMapuiv@8
-glGetPixelMapusv=glGetPixelMapusv@8
-glGetPointerv=glGetPointerv@8
-glGetPolygonStipple=glGetPolygonStipple@4
-glGetString=glGetString@4
-glGetTexEnvfv=glGetTexEnvfv@12
-glGetTexEnviv=glGetTexEnviv@12
-glGetTexGendv=glGetTexGendv@12
-glGetTexGenfv=glGetTexGenfv@12
-glGetTexGeniv=glGetTexGeniv@12
-glGetTexImage=glGetTexImage@20
-glGetTexLevelParameterfv=glGetTexLevelParameterfv@16
-glGetTexLevelParameteriv=glGetTexLevelParameteriv@16
-glGetTexParameterfv=glGetTexParameterfv@12
-glGetTexParameteriv=glGetTexParameteriv@12
-glHint=glHint@8
-glIndexd=glIndexd@8
-glIndexdv=glIndexdv@4
-glIndexf=glIndexf@4
-glIndexfv=glIndexfv@4
-glIndexi=glIndexi@4
-glIndexiv=glIndexiv@4
-glIndexMask=glIndexMask@4
-glIndexPointer=glIndexPointer@12
-glIndexs=glIndexs@2
-glIndexsv=glIndexsv@4
-glIndexub=glIndexub@1
-glIndexubv=glIndexubv@4
-glInitNames=glInitNames@0
-glInterleavedArrays=glInterleavedArrays@12
-glIsEnabled=glIsEnabled@4
-glIsList=glIsList@4
-glIsTexture=glTexture@4
-
-glLightf=glLightf@12
-glLightfv=glLightfv@12
-glLighti=glLighti@12
-glLightiv=glLightiv@12
-glLightModelf=glLightModelf@8
-glLightModelfv=glLightModelfv@8
-glLightModeli=glLightModeli@8
-glLightModeliv=glLightModeliv@8
-
-glLineStipple=glLineStipple@6
-glLineWidth=glLineWidth@4
-glListBase=glListBase@4
-glLoadIdentity=glLoadIdentity@0
-glLoadMatrixd=glLoadMatrixd@4
-glLoadMatrixf=glLoadMatrixf@4
-glLoadName=glLoadName@4
-glLogicOp=glLogicOp@4
-
-glMap1d=glMap1d@32
-glMap1f=glMap1f@24
-glMap2d=glMap2d@56
-glMap2f=glMap2f@40
-glMapGrid1d=glMapGrid1d@20
-glMapGrid1f=glMapGrid1f@12
-glMapGrid2d=glMapGrid2d@40
-glMapGrid2f=glMapGrid2f@24
-
-glMaterialf=glMaterialf@12
-glMaterialfv=glMaterialfv@12
-glMateriali=glMateriali@12
-glMaterialiv=glMaterialiv@12
-
-glMatrixMode=glMatrixMode@4
-glMultMatrixd=glMultMatrixd@4
-glMultMatrixf=glMultMatrixf@4
-glNewList=glNewList@8
-
-glNormal3b=glNormal3b@3
-glNormal3bv=glNormal3bv@4
-glNormal3d=glNormal3d@24
-glNormal3dv=glNormal3dv@4
-glNormal3f=glNormal3f@12
-glNormal3fv=glNormal3fv@4
-glNormal3i=glNormal3i@12
-glNormal3iv=glNormal3iv@4
-glNormal3s=glNormal3s@6
-glNormal3sv=glNormal3sv@4
-glNormalPointer=glNormalPointer@12
-
-glOrtho=glOrtho@24
-glPassThrough=glPassThrough@4
-glPixelMapfv=glPixelMapfv@12
-glPixelMapuiv=glPixelMapuiv@12
-glPixelMapusv=glPixelMapusv@12
-glPixelStoref=glPixelStoref@8
-glPixelStorei=glPixelStorei@8
-glPixelTransferf=glPixelTransferf@8
-glPixelTransferi=glPixelTransferi@8
-glPixelZoom=glPixelZoom@8
-glPointSize=glPointSize@4
-glPolygonMode=glPolygonMode@8
-glPolygonOffset=glPolygonOffset@8
-glPolygonStipple=glPolygonStipple@4
-glPopAttrib=glPopAttrib@0
-glPopClientAttrib=glPopClientAttrib@0
-glPopMatrix=glPopMatrix@0
-glPopName=glPopName@0
-glPrioritizeTextures=glPrioritizeTextures@12
-glPushAttrib=glPushAttrib@4
-glPushClientAttrib=glPushClientAttrib@4
-glPushMatrix=glPushMatrix@0
-glPushName=glPushName@4
-glRasterPos2d=glRasterPos2d@16
-glRasterPos2dv=glRasterPos2dv@4
-glRasterPos2f=glRasterPos2f@8
-glRasterPos2fv=glRasterPos2fv@4
-glRasterPos2i=glRasterPos2i@8
-glRasterPos2iv=glRasterPos2iv@4
-glRasterPos2s=glRasterPos2s@8
-glRasterPos2sv=glRasterPos2sv@8
-glRasterPos3d=glRasterPos3d@24
-glRasterPos3dv=glRasterPos3dv@4
-glRasterPos3f=glRasterPos3f@12
-glRasterPos3fv=glRasterPos3fv@4
-glRasterPos3i=glRasterPos3i@12
-glRasterPos3iv=glRasterPos3iv@4
-glRasterPos3s=glRasterPos3s@12
-glRasterPos3sv=glRasterPos3sv@4
-glRasterPos4d=glRasterPos4d@32
-glRasterPos4dv=glRasterPos4dv@4
-glRasterPos4f=glRasterPos4f@16
-glRasterPos4fv=glRasterPos4fv@4
-glRasterPos4i=glRasterPos4i@16
-glRasterPos4iv=glRasterPos4iv@4
-glRasterPos4s=glRasterPos4s@16
-glRasterPos4sv=glRasterPos4sv@4
-glReadBuffer=glReadBuffer@4
-glReadPixels=glReadPixels@28
-glRectd=glRectd@32
-glRectdv=glRectdv@4
-glRectf=glRectf@16
-glRectfv=glRectfv@4
-glRecti=glRecti@16
-glRectiv=glRectiv@4
-glRects=glRects@16
-glRectsv=glRectsv@4
-glRenderMode=glRenderMode@4
-glRotated=glRotated@32
-glRotatef=glRotatef@16
-glScaled=glScaled@24
-glScalef=glScalef@12
-glScissor=glScissor@16
-glSelectBuffer=glSelectBuffer@8
-glShadeModel=glShadeModel@4
-glStencilFunc=glStencilFunc@12
-glStencilMask=glStencilMask@4
-glStencilOp=glStencilOp@12
-
-glTexCoord1d=glTexCoord1d@8
-glTexCoord1dv=glTexCoord1dv@4
-glTexCoord1f=glTexCoord1f@4
-glTexCoord1fv=glTexCoord1fv@4
-glTexCoord1i=glTexCoord1i@4
-glTexCoord1iv=glTexCoord1iv@4
-glTexCoord1s=glTexCoord1s@2
-glTexCoord1sv=glTexCoord1sv@4
-
-glTexCoord2d=glTexCoord2d@16
-glTexCoord2dv=glTexCoord2dv@4
-glTexCoord2f=glTexCoord2f@8
-glTexCoord2fv=glTexCoord2fv@4
-glTexCoord2i=glTexCoord2i@8
-glTexCoord2iv=glTexCoord2iv@4
-glTexCoord2s=glTexCoord2s@4
-glTexCoord2sv=glTexCoord2sv@4
-
-glTexCoord3d=glTexCoord3d@24
-glTexCoord3dv=glTexCoord3dv@4
-glTexCoord3f=glTexCoord3f@12
-glTexCoord3fv=glTexCoord3fv@4
-glTexCoord3i=glTexCoord3i@12
-glTexCoord3iv=glTexCoord3iv@4
-glTexCoord3s=glTexCoord3s@6
-glTexCoord3sv=glTexCoord3sv@4
-
-glTexCoord4d=glTexCoord4d@32
-glTexCoord4dv=glTexCoord4dv@4
-glTexCoord4f=glTexCoord4f@16
-glTexCoord4fv=glTexCoord4fv@4
-glTexCoord4i=glTexCoord4i@16
-glTexCoord4iv=glTexCoord4iv@4
-glTexCoord4s=glTexCoord4s@8
-glTexCoord4sv=glTexCoord4sv@4
-
-glTexCoordPointer=glTexCoordPointer@16
-glTexEnvf=glTexEnvf@12
-glTexEnvfv=glTexEnvfv@12
-glTexEnvi=glTexEnvi@12
-glTexEnviv=glTexEnviv@12
-glTexGend=glTexGend@16
-glTexGendv=glTexGendv@12
-glTexGenf=glTexGenf@12
-glTexGenfv=glTexGenfv@12
-glTexGeni=glTexGeni@12
-glTexGeniv=glTexGeniv@12
-glTexImage1D=glTexImage1D@32
-glTexImage2D=glTexImage2d@36
-glTexParameterf=glTexParameterf@12
-glTexParameterfv=glTexParameterfv@12
-glTexParameteri=glTexParameteri@12
-glTexParameteriv=glTexParameteriv@12
-glTexSubImage1D=glTexSubImage1D@28
-glTexSubImage2D=glTexSubImage2D@36
-
-glTranslated=glTranslated@32
-glTranslatef=glTranslated@16
-
-glVertex2d=glVertex2d@16
-glVertex2dv=glVertex2dv@4
-glVertex2f=glVertex2f@8
-glVertex2fv=glVertex2fv@4
-glVertex2i=glVertex2i@8
-glVertex2iv=glVertex2iv@4
-glVertex2s=glVertex2s@4
-glVertex2sv=glVertex2sv@4
-
-glVertex3d=glVertex3d@24
-glVertex3dv=glVertex3dv@4
-glVertex3f=glVertex3f@12
-glVertex3fv=glVertex3fv@4
-glVertex3i=glVertex3i@12
-glVertex3iv=glVertex3iv@4
-glVertex3s=glVertex3s@6
-glVertex3sv=glVertex3sv@4
-
-glVertex4d=glVertex4d@32
-glVertex4dv=glVertex4dv@4
-glVertex4f=glVertex4f@16
-glVertex4fv=glVertex4fv@4
-glVertex4i=glVertex4i@16
-glVertex4iv=glVertex4iv@4
-glVertex4s=glVertex4s@8
-glVertex4sv=glVertex4sv@4
-
-glVertexPointer=glVertexPointer@16
-glViewport=glViewport@16
-
-wglChoosePixelFormat=GDI32.ChoosePixelFormat
-wglCopyContext=wglCopyContext@12
-wglCreateContext=wglCreateContext@4
-wglCreateLayerContext=wglCreateLayerContext@8
-wglDeleteContext=wglDeleteContext@4
-wglDescribeLayerPlane=wglDescribeLayerPlane@20
-wglDescribePixelFormat=GDI32.DescribePixelFormat
-wglGetCurrentContext=wglGetCurrentContext@0
-wglGetCurrentDC=wglGetCurrentDC@0
-wglGetLayerPaletteEntries=wglGetLayerPaletteEntries@20
-wglGetPixelFormat=GDI32.GetPixelFormat
-*/
-
-/*
- * @unimplemented
- */
-PROC wglGetProcAddress ( LPCSTR lpszProc )
-{
-	/* FIXME - what is the right strcmp() variant to use here? */
-	/* NOTE - lpszProc comparisons *ARE* case-sensitive */
-	GLFUNCLIST* funclist = OPENGL32_GetFuncList();
-	if ( !strcmp ( lpszProc, "glAddSwapHintRectWIN" ) )
-		return (PROC)(funclist->glAddSwapHintRectWIN);
-	/* FIXME - fill in the rest of the functions returned by wglGetProcAddress */
-	return NULL;
-}
-
-/*
-wglMakeCurrent=wglMakeCurrent@8
-wglRealizeLayerPalette=wglRealizeLayerPalette@12
-wglSetLayerPaletteEntries=wglSetLayerPaletteEntries@20
-wglSetPixelFormat=GDI32.SetPixelFormat
-wglShareLists=wglShareLists@8
-wglSwapBuffers=GDI32.SwapBuffers
-wglSwapLayerBuffers=wglSwapLayerBuffers@8
-wglUseFontBitmapsA=wglUseFontBitmapsA@16
-wglUseFontBitmapsW=wglUseFontBitmapsW@16
-wglUseFontOutlinesA=wglUseFontOutlinesA@32
-wglUseFontOutlinesW=wglUseFontOutlinesW@32
-*/
-
-GLFUNCLIST*
-OPENGL32_GetFuncList()
-{
-	threaddata = (OPENGL32_ThreadData*)TlsGetValue ( OPENGL32_tls );
-	ASSERT(threaddata);
-	return threaddata->list;
-}

reactos/lib/opengl32
tebimports.asm removed after 1.4
diff -N tebimports.asm
--- tebimports.asm	9 Feb 2004 08:00:15 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-section .text
-
-%macro TEB_ENTRY 4
-global _%1@%4
-_%1@%4:
-	mov eax, [fs:18h] ; obtain a pointer to the TEB
-	jmp [eax+4*%3+7C4h]
-%endmacro
-%include "teblist.mac"
-
-%macro SLOW_ENTRY 3
-global _%1@%3
-_%1@%3:
-	mov eax, [fs:18h] ; obtain a pointer to the TEB
-	mov eax, [eax+0BE8h] ; get glTable pointer
-	jmp [eax+4*%2]
-%endmacro
-%include "slowlist.mac"

reactos/lib/opengl32
teblist.h removed after 1.1
diff -N teblist.h
--- teblist.h	5 Feb 2004 16:11:19 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,163 +0,0 @@
-TEB_ENTRY(glCallList)
-TEB_ENTRY(glCallLists)
-TEB_ENTRY(glBegin)
-TEB_ENTRY(glColor3b)
-TEB_ENTRY(glColor3bv)
-TEB_ENTRY(glColor3d)
-TEB_ENTRY(glColor3dv)
-TEB_ENTRY(glColor3f)
-TEB_ENTRY(glColor3fv)
-TEB_ENTRY(glColor3i)
-TEB_ENTRY(glColor3iv)
-TEB_ENTRY(glColor3s)
-TEB_ENTRY(glColor3sv)
-TEB_ENTRY(glColor3ub)
-TEB_ENTRY(glColor3ubv)
-TEB_ENTRY(glColor3ui)
-TEB_ENTRY(glColor3uiv)
-TEB_ENTRY(glColor3us)
-TEB_ENTRY(glColor3usv)
-TEB_ENTRY(glColor4b)
-TEB_ENTRY(glColor4bv)
-TEB_ENTRY(glColor4d)
-TEB_ENTRY(glColor4dv)
-TEB_ENTRY(glColor4f)
-TEB_ENTRY(glColor4fv)
-TEB_ENTRY(glColor4i)
-TEB_ENTRY(glColor4iv)
-TEB_ENTRY(glColor4s)
-TEB_ENTRY(glColor4sv)
-TEB_ENTRY(glColor4ub)
-TEB_ENTRY(glColor4ubv)
-TEB_ENTRY(glColor4ui)
-TEB_ENTRY(glColor4uiv)
-TEB_ENTRY(glColor4us)
-TEB_ENTRY(glColor4usv)
-TEB_ENTRY(glEdgeFlag)
-TEB_ENTRY(glEdgeFlagv)
-TEB_ENTRY(glEnd)
-TEB_ENTRY(glIndexd)
-TEB_ENTRY(glIndexdv)
-TEB_ENTRY(glIndexf)
-TEB_ENTRY(glIndexfv)
-TEB_ENTRY(glIndexi)
-TEB_ENTRY(glIndexiv)
-TEB_ENTRY(glIndexs)
-TEB_ENTRY(glIndexsv)
-TEB_ENTRY(glNormal3b)
-TEB_ENTRY(glNormal3bv)
-TEB_ENTRY(glNormal3d)
-TEB_ENTRY(glNormal3dv)
-TEB_ENTRY(glNormal3f)
-TEB_ENTRY(glNormal3fv)
-TEB_ENTRY(glNormal3i)
-TEB_ENTRY(glNormal3iv)
-TEB_ENTRY(glNormal3s)
-TEB_ENTRY(glNormal3sv)
-TEB_ENTRY(glTexCoord1d)
-TEB_ENTRY(glTexCoord1dv)
-TEB_ENTRY(glTexCoord1f)
-TEB_ENTRY(glTexCoord1fv)
-TEB_ENTRY(glTexCoord1i)
-TEB_ENTRY(glTexCoord1iv)
-TEB_ENTRY(glTexCoord1s)
-TEB_ENTRY(glTexCoord1sv)
-TEB_ENTRY(glTexCoord2d)
-TEB_ENTRY(glTexCoord2dv)
-TEB_ENTRY(glTexCoord2f)
-TEB_ENTRY(glTexCoord2fv)
-TEB_ENTRY(glTexCoord2i)
-TEB_ENTRY(glTexCoord2iv)
-TEB_ENTRY(glTexCoord2s)
-TEB_ENTRY(glTexCoord2sv)
-TEB_ENTRY(glTexCoord3d)
-TEB_ENTRY(glTexCoord3dv)
-TEB_ENTRY(glTexCoord3f)
-TEB_ENTRY(glTexCoord3fv)
-TEB_ENTRY(glTexCoord3i)
-TEB_ENTRY(glTexCoord3iv)
-TEB_ENTRY(glTexCoord3s)
-TEB_ENTRY(glTexCoord3sv)
-TEB_ENTRY(glTexCoord4d)
-TEB_ENTRY(glTexCoord4dv)
-TEB_ENTRY(glTexCoord4f)
-TEB_ENTRY(glTexCoord4fv)
-TEB_ENTRY(glTexCoord4i)
-TEB_ENTRY(glTexCoord4iv)
-TEB_ENTRY(glTexCoord4s)
-TEB_ENTRY(glTexCoord4sv)
-TEB_ENTRY(glVertex2d)
-TEB_ENTRY(glVertex2dv)
-TEB_ENTRY(glVertex2f)
-TEB_ENTRY(glVertex2fv)
-TEB_ENTRY(glVertex2i)
-TEB_ENTRY(glVertex2iv)
-TEB_ENTRY(glVertex2s)
-TEB_ENTRY(glVertex2sv)
-TEB_ENTRY(glVertex3d)
-TEB_ENTRY(glVertex3dv)
-TEB_ENTRY(glVertex3f)
-TEB_ENTRY(glVertex3fv)
-TEB_ENTRY(glVertex3i)
-TEB_ENTRY(glVertex3iv)
-TEB_ENTRY(glVertex3s)
-TEB_ENTRY(glVertex3sv)
-TEB_ENTRY(glVertex4d)
-TEB_ENTRY(glVertex4dv)
-TEB_ENTRY(glVertex4f)
-TEB_ENTRY(glVertex4fv)
-TEB_ENTRY(glVertex4i)
-TEB_ENTRY(glVertex4iv)
-TEB_ENTRY(glVertex4s)
-TEB_ENTRY(glVertex4sv)
-TEB_ENTRY(glMaterialf)
-TEB_ENTRY(glMaterialfv)
-TEB_ENTRY(glMateriali)
-TEB_ENTRY(glMaterialiv)
-TEB_ENTRY(glDisable)
-TEB_ENTRY(glEnable)
-TEB_ENTRY(glPopAttrib)
-TEB_ENTRY(glPushAttrib)
-TEB_ENTRY(glEvalCoord1d)
-TEB_ENTRY(glEvalCoord1dv)
-TEB_ENTRY(glEvalCoord1f)
-TEB_ENTRY(glEvalCoord1fv)
-TEB_ENTRY(glEvalCoord2d)
-TEB_ENTRY(glEvalCoord2dv)
-TEB_ENTRY(glEvalCoord2f)
-TEB_ENTRY(glEvalCoord2fv)
-TEB_ENTRY(glEvalPoint1)
-TEB_ENTRY(glEvalPoint2)
-TEB_ENTRY(glLoadIdentity)
-TEB_ENTRY(glLoadMatrixf)
-TEB_ENTRY(glLoadMatrixd)
-TEB_ENTRY(glMatrixMode)
-TEB_ENTRY(glMultMatrixf)
-TEB_ENTRY(glMultMatrixd)
-TEB_ENTRY(glPopMatrix)
-TEB_ENTRY(glPushMatrix)
-TEB_ENTRY(glRotated)
-TEB_ENTRY(glRotatef)
-TEB_ENTRY(glScaled)
-TEB_ENTRY(glScalef)
-TEB_ENTRY(glTranslated)
-TEB_ENTRY(glTranslatef)
-TEB_ENTRY(glArrayElement)
-TEB_ENTRY(glBindTexture)
-TEB_ENTRY(glColorPointer)
-TEB_ENTRY(glDisableClientState)
-TEB_ENTRY(glDrawArrays)
-TEB_ENTRY(glDrawElements)
-TEB_ENTRY(glEdgeFlagPointer)
-TEB_ENTRY(glEnableClientState)
-TEB_ENTRY(glIndexPointer)
-TEB_ENTRY(glIndexub)
-TEB_ENTRY(glIndexubv)
-TEB_ENTRY(glInterleavedArrays)
-TEB_ENTRY(glNormalPointer)
-TEB_ENTRY(glPolygonOffset)
-TEB_ENTRY(glTexCoordPointer)
-TEB_ENTRY(glVertexPointer)
-TEB_ENTRY(glGetPointerv)
-TEB_ENTRY(glPopClientAttrib)
-TEB_ENTRY(glPushClientAttrib)

reactos/lib/opengl32
teblist.mac removed after 1.1
diff -N teblist.mac
--- teblist.mac	6 Feb 2004 18:17:18 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,164 +0,0 @@
-;TEB_ENTRY name,icdidx,tebidx,stack
-TEB_ENTRY glCallList,2,0,4
-TEB_ENTRY glCallLists,3,1,12
-TEB_ENTRY glBegin,7,2,4
-TEB_ENTRY glColor3b,9,3,12
-TEB_ENTRY glColor3bv,10,4,4
-TEB_ENTRY glColor3d,11,5,24
-TEB_ENTRY glColor3dv,12,6,4
-TEB_ENTRY glColor3f,13,7,12
-TEB_ENTRY glColor3fv,14,8,4
-TEB_ENTRY glColor3i,15,9,12
-TEB_ENTRY glColor3iv,16,10,4
-TEB_ENTRY glColor3s,17,11,12
-TEB_ENTRY glColor3sv,18,12,4
-TEB_ENTRY glColor3ub,19,13,12
-TEB_ENTRY glColor3ubv,20,14,4
-TEB_ENTRY glColor3ui,21,15,12
-TEB_ENTRY glColor3uiv,22,16,4
-TEB_ENTRY glColor3us,23,17,12
-TEB_ENTRY glColor3usv,24,18,4
-TEB_ENTRY glColor4b,25,19,16
-TEB_ENTRY glColor4bv,26,20,4
-TEB_ENTRY glColor4d,27,21,32
-TEB_ENTRY glColor4dv,28,22,4
-TEB_ENTRY glColor4f,29,23,16
-TEB_ENTRY glColor4fv,30,24,4
-TEB_ENTRY glColor4i,31,25,16
-TEB_ENTRY glColor4iv,32,26,4
-TEB_ENTRY glColor4s,33,27,16
-TEB_ENTRY glColor4sv,34,28,4
-TEB_ENTRY glColor4ub,35,29,16
-TEB_ENTRY glColor4ubv,36,30,4
-TEB_ENTRY glColor4ui,37,31,16
-TEB_ENTRY glColor4uiv,38,32,4
-TEB_ENTRY glColor4us,39,33,16
-TEB_ENTRY glColor4usv,40,34,4
-TEB_ENTRY glEdgeFlag,41,35,4
-TEB_ENTRY glEdgeFlagv,42,36,4
-TEB_ENTRY glEnd,43,37,0
-TEB_ENTRY glIndexd,44,38,8
-TEB_ENTRY glIndexdv,45,39,4
-TEB_ENTRY glIndexf,46,40,4
-TEB_ENTRY glIndexfv,47,41,4
-TEB_ENTRY glIndexi,48,42,4
-TEB_ENTRY glIndexiv,49,43,4
-TEB_ENTRY glIndexs,50,44,4
-TEB_ENTRY glIndexsv,51,45,4
-TEB_ENTRY glNormal3b,52,46,12
-TEB_ENTRY glNormal3bv,53,47,4
-TEB_ENTRY glNormal3d,54,48,24
-TEB_ENTRY glNormal3dv,55,49,4
-TEB_ENTRY glNormal3f,56,50,12
-TEB_ENTRY glNormal3fv,57,51,4
-TEB_ENTRY glNormal3i,58,52,12
-TEB_ENTRY glNormal3iv,59,53,4
-TEB_ENTRY glNormal3s,60,54,12
-TEB_ENTRY glNormal3sv,61,55,4
-TEB_ENTRY glTexCoord1d,94,56,8
-TEB_ENTRY glTexCoord1dv,95,57,4
-TEB_ENTRY glTexCoord1f,96,58,4
-TEB_ENTRY glTexCoord1fv,97,59,4
-TEB_ENTRY glTexCoord1i,98,60,4
-TEB_ENTRY glTexCoord1iv,99,61,4
-TEB_ENTRY glTexCoord1s,100,62,4
-TEB_ENTRY glTexCoord1sv,101,63,4
-TEB_ENTRY glTexCoord2d,102,64,16
-TEB_ENTRY glTexCoord2dv,103,65,4
-TEB_ENTRY glTexCoord2f,104,66,8
-TEB_ENTRY glTexCoord2fv,105,67,4
-TEB_ENTRY glTexCoord2i,106,68,8
-TEB_ENTRY glTexCoord2iv,107,69,4
-TEB_ENTRY glTexCoord2s,108,70,8
-TEB_ENTRY glTexCoord2sv,109,71,4
-TEB_ENTRY glTexCoord3d,110,72,24
-TEB_ENTRY glTexCoord3dv,111,73,4
-TEB_ENTRY glTexCoord3f,112,74,12
-TEB_ENTRY glTexCoord3fv,113,75,4
-TEB_ENTRY glTexCoord3i,114,76,12
-TEB_ENTRY glTexCoord3iv,115,77,4
-TEB_ENTRY glTexCoord3s,116,78,12
-TEB_ENTRY glTexCoord3sv,117,79,4
-TEB_ENTRY glTexCoord4d,118,80,32
-TEB_ENTRY glTexCoord4dv,119,81,4
-TEB_ENTRY glTexCoord4f,120,82,16
-TEB_ENTRY glTexCoord4fv,121,83,4
-TEB_ENTRY glTexCoord4i,122,84,16
-TEB_ENTRY glTexCoord4iv,123,85,4
-TEB_ENTRY glTexCoord4s,124,86,16
-TEB_ENTRY glTexCoord4sv,125,87,4
-TEB_ENTRY glVertex2d,126,88,16
-TEB_ENTRY glVertex2dv,127,89,4
-TEB_ENTRY glVertex2f,128,90,8
-TEB_ENTRY glVertex2fv,129,91,4
-TEB_ENTRY glVertex2i,130,92,8
-TEB_ENTRY glVertex2iv,131,93,4
-TEB_ENTRY glVertex2s,132,94,8
-TEB_ENTRY glVertex2sv,133,95,4
-TEB_ENTRY glVertex3d,134,96,24
-TEB_ENTRY glVertex3dv,135,97,4
-TEB_ENTRY glVertex3f,136,98,12
-TEB_ENTRY glVertex3fv,137,99,4
-TEB_ENTRY glVertex3i,138,100,12
-TEB_ENTRY glVertex3iv,139,101,4
-TEB_ENTRY glVertex3s,140,102,12
-TEB_ENTRY glVertex3sv,141,103,4
-TEB_ENTRY glVertex4d,142,104,32
-TEB_ENTRY glVertex4dv,143,105,4
-TEB_ENTRY glVertex4f,144,106,16
-TEB_ENTRY glVertex4fv,145,107,4
-TEB_ENTRY glVertex4i,146,108,16
-TEB_ENTRY glVertex4iv,147,109,4
-TEB_ENTRY glVertex4s,148,110,16
-TEB_ENTRY glVertex4sv,149,111,4
-TEB_ENTRY glMaterialf,169,112,12
-TEB_ENTRY glMaterialfv,170,113,12
-TEB_ENTRY glMateriali,171,114,12
-TEB_ENTRY glMaterialiv,172,115,12
-TEB_ENTRY glDisable,214,116,4
-TEB_ENTRY glEnable,215,117,4
-TEB_ENTRY glPopAttrib,218,118,0
-TEB_ENTRY glPushAttrib,219,119,4
-TEB_ENTRY glEvalCoord1d,228,120,8
-TEB_ENTRY glEvalCoord1dv,229,121,4
-TEB_ENTRY glEvalCoord1f,230,122,4
-TEB_ENTRY glEvalCoord1fv,231,123,4
-TEB_ENTRY glEvalCoord2d,232,124,16
-TEB_ENTRY glEvalCoord2dv,233,125,4
-TEB_ENTRY glEvalCoord2f,234,126,8
-TEB_ENTRY glEvalCoord2fv,235,127,4
-TEB_ENTRY glEvalPoint1,237,128,4
-TEB_ENTRY glEvalPoint2,239,129,8
-TEB_ENTRY glLoadIdentity,290,130,0
-TEB_ENTRY glLoadMatrixf,291,131,4
-TEB_ENTRY glLoadMatrixd,292,132,4
-TEB_ENTRY glMatrixMode,293,133,4
-TEB_ENTRY glMultMatrixf,294,134,4
-TEB_ENTRY glMultMatrixd,295,135,4
-TEB_ENTRY glPopMatrix,297,136,0
-TEB_ENTRY glPushMatrix,298,137,0
-TEB_ENTRY glRotated,299,138,32
-TEB_ENTRY glRotatef,300,139,16
-TEB_ENTRY glScaled,301,140,24
-TEB_ENTRY glScalef,302,141,12
-TEB_ENTRY glTranslated,303,142,24
-TEB_ENTRY glTranslatef,304,143,12
-TEB_ENTRY glArrayElement,306,144,4
-TEB_ENTRY glBindTexture,307,145,8
-TEB_ENTRY glColorPointer,308,146,16
-TEB_ENTRY glDisableClientState,309,147,4
-TEB_ENTRY glDrawArrays,310,148,12
-TEB_ENTRY glDrawElements,311,149,16
-TEB_ENTRY glEdgeFlagPointer,312,150,8
-TEB_ENTRY glEnableClientState,313,151,4
-TEB_ENTRY glIndexPointer,314,152,12
-TEB_ENTRY glIndexub,315,153,4
-TEB_ENTRY glIndexubv,316,154,4
-TEB_ENTRY glInterleavedArrays,317,155,12
-TEB_ENTRY glNormalPointer,318,156,12
-TEB_ENTRY glPolygonOffset,319,157,8
-TEB_ENTRY glTexCoordPointer,320,158,16
-TEB_ENTRY glVertexPointer,321,159,16
-TEB_ENTRY glGetPointerv,329,160,8
-TEB_ENTRY glPopClientAttrib,334,161,0
-TEB_ENTRY glPushClientAttrib,335,162,4

reactos/lib/pseh
framebased.c 1.5.10.1 -> 1.5.10.2
diff -u -r1.5.10.1 -r1.5.10.2
--- framebased.c	8 Dec 2004 20:01:40 -0000	1.5.10.1
+++ framebased.c	8 Dec 2004 21:57:20 -0000	1.5.10.2
@@ -27,6 +27,7 @@
 #include <pseh/framebased/internal.h>
 #include <pseh/excpt.h>
 #include <excpt.h>
+#include <pseh/framebased.h>
 
 /* Assembly helpers, see i386/framebased.asm */
 extern void __cdecl _SEHCleanHandlerEnvironment(void);

reactos/lib/riched20
Makefile.ros-template 1.1 -> 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- Makefile.ros-template	20 Nov 2004 18:26:16 -0000	1.1
+++ Makefile.ros-template	8 Dec 2004 21:57:20 -0000	1.1.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.1 2004/11/20 18:26:16 sedwards Exp $
+# $Id: Makefile.ros-template,v 1.1.2.1 2004/12/08 21:57:20 hyperion Exp $
 
 TARGET_NAME = riched20
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ -D__WINESRC__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a libwine_unicode.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a ntdll.a wine_unicode.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_SETUPAPI)
 

reactos/lib/richedit
Makefile.ros-template 1.2 -> 1.2.16.1
diff -u -r1.2 -r1.2.16.1
--- Makefile.ros-template	29 May 2004 21:24:46 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:21 -0000	1.2.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:46 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.2.16.1 2004/12/08 21:57:21 hyperion Exp $
 
 TARGET_NAME = riched32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_RICHEDIT)
 

reactos/lib/rpcrt4
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:46 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:21 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:46 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:57:21 hyperion Exp $
 
 TARGET_NAME = rpcrt4
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ -Wall
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_RPCRT4)
 

reactos/lib/rpcrt4
cproxy.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- cproxy.c	20 Oct 2004 09:38:15 -0000	1.5
+++ cproxy.c	8 Dec 2004 21:57:21 -0000	1.5.2.1
@@ -101,7 +101,7 @@
   ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
 
   PFORMAT_STRING fs = This->stubless->ProcFormatString + This->stubless->FormatStringOffset[index];
-  unsigned bytes = *(WORD*)(fs+8) - STACK_ADJUST;
+  unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
   TRACE("(%p)->(%ld)([%d bytes]) ret=%08lx\n", iface, index, bytes, *(DWORD*)(args+bytes));
 
   return RPCRT4_NdrClientCall2(This->stubless->pStubDesc, fs, args);
@@ -161,7 +161,7 @@
       struct StublessThunk *thunk = &This->thunks[i];
       if (vtbl->Vtbl[i] == (LPVOID)-1) {
         PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[i];
-        unsigned bytes = *(WORD*)(fs+8) - STACK_ADJUST;
+        unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
         TRACE("method %d: stacksize=%d\n", i, bytes);
         FILL_STUBLESS(thunk, i, bytes)
         This->PVtbl[i] = thunk;

reactos/lib/rpcrt4
ndr_marshall.c 1.1 -> 1.1.18.1
diff -u -r1.1 -r1.1.18.1
--- ndr_marshall.c	4 May 2004 20:06:26 -0000	1.1
+++ ndr_marshall.c	8 Dec 2004 21:57:21 -0000	1.1.18.1
@@ -561,7 +561,7 @@
   TRACE("type=%d, attr=%d\n", type, attr);
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
-  else desc = pFormat + *(SHORT*)pFormat;
+  else desc = pFormat + *(const SHORT*)pFormat;
   if (attr & RPC_FC_P_DEREF) {
     Pointer = *(unsigned char**)Pointer;
     TRACE("deref => %p\n", Pointer);
@@ -600,7 +600,7 @@
   TRACE("type=%d, attr=%d\n", type, attr);
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
-  else desc = pFormat + *(SHORT*)pFormat;
+  else desc = pFormat + *(const SHORT*)pFormat;
   if (attr & RPC_FC_P_DEREF) {
     pPointer = *(unsigned char***)pPointer;
     TRACE("deref => %p\n", pPointer);
@@ -636,7 +636,7 @@
   TRACE("type=%d, attr=%d\n", type, attr);
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
-  else desc = pFormat + *(SHORT*)pFormat;
+  else desc = pFormat + *(const SHORT*)pFormat;
   if (attr & RPC_FC_P_DEREF) {
     Pointer = *(unsigned char**)Pointer;
     TRACE("deref => %p\n", Pointer);
@@ -669,7 +669,7 @@
   TRACE("type=%d, attr=%d\n", type, attr);
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
-  else desc = pFormat + *(SHORT*)pFormat;
+  else desc = pFormat + *(const SHORT*)pFormat;
   if (attr & RPC_FC_P_DEREF) {
     TRACE("deref\n");
   }
@@ -704,7 +704,7 @@
   if (attr & RPC_FC_P_DONTFREE) return;
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
-  else desc = pFormat + *(SHORT*)pFormat;
+  else desc = pFormat + *(const SHORT*)pFormat;
   if (attr & RPC_FC_P_DEREF) {
     Pointer = *(unsigned char**)Pointer;
     TRACE("deref => %p\n", Pointer);
@@ -776,18 +776,18 @@
       pFormat += 2;
       break;
     case RPC_FC_FIXED_REPEAT:
-      rep = *(WORD*)&pFormat[2];
-      stride = *(WORD*)&pFormat[4];
-      ofs = *(WORD*)&pFormat[6];
-      count = *(WORD*)&pFormat[8];
+      rep = *(const WORD*)&pFormat[2];
+      stride = *(const WORD*)&pFormat[4];
+      ofs = *(const WORD*)&pFormat[6];
+      count = *(const WORD*)&pFormat[8];
       xofs = 0;
       pFormat += 10;
       break;
     case RPC_FC_VARIABLE_REPEAT:
       rep = pStubMsg->MaxCount;
-      stride = *(WORD*)&pFormat[2];
-      ofs = *(WORD*)&pFormat[4];
-      count = *(WORD*)&pFormat[6];
+      stride = *(const WORD*)&pFormat[2];
+      ofs = *(const WORD*)&pFormat[4];
+      count = *(const WORD*)&pFormat[6];
       xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
       pFormat += 8;
       break;
@@ -798,8 +798,8 @@
       unsigned char *membase = pMemory + xofs;
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *memptr = membase + *(SHORT*)&info[0];
-        unsigned char *bufptr = Mark + *(SHORT*)&info[2];
+        unsigned char *memptr = membase + *(const SHORT*)&info[0];
+        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
         PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
       }
       rep--;
@@ -842,18 +842,18 @@
       pFormat += 2;
       break;
     case RPC_FC_FIXED_REPEAT:
-      rep = *(WORD*)&pFormat[2];
-      stride = *(WORD*)&pFormat[4];
-      ofs = *(WORD*)&pFormat[6];
-      count = *(WORD*)&pFormat[8];
+      rep = *(const WORD*)&pFormat[2];
+      stride = *(const WORD*)&pFormat[4];
+      ofs = *(const WORD*)&pFormat[6];
+      count = *(const WORD*)&pFormat[8];
       xofs = 0;
       pFormat += 10;
       break;
     case RPC_FC_VARIABLE_REPEAT:
       rep = pStubMsg->MaxCount;
-      stride = *(WORD*)&pFormat[2];
-      ofs = *(WORD*)&pFormat[4];
-      count = *(WORD*)&pFormat[6];
+      stride = *(const WORD*)&pFormat[2];
+      ofs = *(const WORD*)&pFormat[4];
+      count = *(const WORD*)&pFormat[6];
       xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
       pFormat += 8;
       break;
@@ -864,8 +864,8 @@
       unsigned char *membase = *ppMemory + xofs;
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *memptr = membase + *(SHORT*)&info[0];
-        unsigned char *bufptr = Mark + *(SHORT*)&info[2];
+        unsigned char *memptr = membase + *(const SHORT*)&info[0];
+        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
         PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
       }
       rep--;
@@ -903,18 +903,18 @@
       pFormat += 2;
       break;
     case RPC_FC_FIXED_REPEAT:
-      rep = *(WORD*)&pFormat[2];
-      stride = *(WORD*)&pFormat[4];
-      ofs = *(WORD*)&pFormat[6];
-      count = *(WORD*)&pFormat[8];
+      rep = *(const WORD*)&pFormat[2];
+      stride = *(const WORD*)&pFormat[4];
+      ofs = *(const WORD*)&pFormat[6];
+      count = *(const WORD*)&pFormat[8];
       xofs = 0;
       pFormat += 10;
       break;
     case RPC_FC_VARIABLE_REPEAT:
       rep = pStubMsg->MaxCount;
-      stride = *(WORD*)&pFormat[2];
-      ofs = *(WORD*)&pFormat[4];
-      count = *(WORD*)&pFormat[6];
+      stride = *(const WORD*)&pFormat[2];
+      ofs = *(const WORD*)&pFormat[4];
+      count = *(const WORD*)&pFormat[6];
       xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
       pFormat += 8;
       break;
@@ -925,7 +925,7 @@
       unsigned char *membase = pMemory + xofs;
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *memptr = membase + *(SHORT*)&info[0];
+        unsigned char *memptr = membase + *(const SHORT*)&info[0];
         PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
       }
       rep--;
@@ -961,18 +961,18 @@
       pFormat += 2;
       break;
     case RPC_FC_FIXED_REPEAT:
-      rep = *(WORD*)&pFormat[2];
-      stride = *(WORD*)&pFormat[4];
-      ofs = *(WORD*)&pFormat[6];
-      count = *(WORD*)&pFormat[8];
+      rep = *(const WORD*)&pFormat[2];
+      stride = *(const WORD*)&pFormat[4];
+      ofs = *(const WORD*)&pFormat[6];
+      count = *(const WORD*)&pFormat[8];
       xofs = 0;
       pFormat += 10;
       break;
     case RPC_FC_VARIABLE_REPEAT:
       rep = pStubMsg->MaxCount;
-      stride = *(WORD*)&pFormat[2];
-      ofs = *(WORD*)&pFormat[4];
-      count = *(WORD*)&pFormat[6];
+      stride = *(const WORD*)&pFormat[2];
+      ofs = *(const WORD*)&pFormat[4];
+      count = *(const WORD*)&pFormat[6];
       xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
       pFormat += 8;
       break;
@@ -982,7 +982,7 @@
       PFORMAT_STRING info = pFormat;
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *bufptr = Mark + *(SHORT*)&info[2];
+        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
         PointerMemorySize(pStubMsg, bufptr, info+4);
       }
       rep--;
@@ -1020,18 +1020,18 @@
       pFormat += 2;
       break;
     case RPC_FC_FIXED_REPEAT:
-      rep = *(WORD*)&pFormat[2];
-      stride = *(WORD*)&pFormat[4];
-      ofs = *(WORD*)&pFormat[6];
-      count = *(WORD*)&pFormat[8];
+      rep = *(const WORD*)&pFormat[2];
+      stride = *(const WORD*)&pFormat[4];
+      ofs = *(const WORD*)&pFormat[6];
+      count = *(const WORD*)&pFormat[8];
       xofs = 0;
       pFormat += 10;
       break;
     case RPC_FC_VARIABLE_REPEAT:
       rep = pStubMsg->MaxCount;
-      stride = *(WORD*)&pFormat[2];
-      ofs = *(WORD*)&pFormat[4];
-      count = *(WORD*)&pFormat[6];
+      stride = *(const WORD*)&pFormat[2];
+      ofs = *(const WORD*)&pFormat[4];
+      count = *(const WORD*)&pFormat[6];
       xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
       pFormat += 8;
       break;
@@ -1042,7 +1042,7 @@
       unsigned char *membase = pMemory + xofs;
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *memptr = membase + *(SHORT*)&info[0];
+        unsigned char *memptr = membase + *(const SHORT*)&info[0];
         PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
       }
       rep--;
@@ -1128,7 +1128,7 @@
                                                unsigned char *pMemory,
                                                PFORMAT_STRING pFormat)
 {
-  unsigned size = *(LPWORD)(pFormat+2);
+  unsigned size = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
   memcpy(pStubMsg->Buffer, pMemory, size);
@@ -1151,7 +1151,7 @@
                                                  PFORMAT_STRING pFormat,
                                                  unsigned char fMustAlloc)
 {
-  unsigned size = *(LPWORD)(pFormat+2);
+  unsigned size = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
 
   if (fMustAlloc) {
@@ -1204,7 +1204,7 @@
                                       unsigned char *pMemory,
                                       PFORMAT_STRING pFormat)
 {
-  unsigned size = *(LPWORD)(pFormat+2);
+  unsigned size = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   pStubMsg->BufferLength += size;
   if (pFormat[0] != RPC_FC_STRUCT)
@@ -1245,9 +1245,9 @@
   case RPC_FC_PSTRUCT:
   case RPC_FC_CSTRUCT:
   case RPC_FC_BOGUS_STRUCT:
-    return *(WORD*)&pFormat[2];
+    return *(const WORD*)&pFormat[2];
   case RPC_FC_USER_MARSHAL:
-    return *(WORD*)&pFormat[4];
+    return *(const WORD*)&pFormat[4];
   default:
     FIXME("unhandled embedded type %02x\n", *pFormat);
   }
@@ -1295,7 +1295,7 @@
     case RPC_FC_EMBEDDED_COMPLEX:
       pMemory += pFormat[1];
       pFormat += 2;
-      desc = pFormat + *(SHORT*)pFormat;
+      desc = pFormat + *(const SHORT*)pFormat;
       size = EmbeddedComplexSize(pStubMsg, desc);
       TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
       m = NdrMarshaller[*desc & NDR_TABLE_MASK];
@@ -1357,7 +1357,7 @@
     case RPC_FC_EMBEDDED_COMPLEX:
       pMemory += pFormat[1];
       pFormat += 2;
-      desc = pFormat + *(SHORT*)pFormat;
+      desc = pFormat + *(const SHORT*)pFormat;
       size = EmbeddedComplexSize(pStubMsg, desc);
       TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
       m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
@@ -1413,7 +1413,7 @@
     case RPC_FC_EMBEDDED_COMPLEX:
       pMemory += pFormat[1];
       pFormat += 2;
-      desc = pFormat + *(SHORT*)pFormat;
+      desc = pFormat + *(const SHORT*)pFormat;
       size = EmbeddedComplexSize(pStubMsg, desc);
       m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
       if (m) m(pStubMsg, pMemory, desc);
@@ -1465,7 +1465,7 @@
     case RPC_FC_EMBEDDED_COMPLEX:
       pMemory += pFormat[1];
       pFormat += 2;
-      desc = pFormat + *(SHORT*)pFormat;
+      desc = pFormat + *(const SHORT*)pFormat;
       size = EmbeddedComplexSize(pStubMsg, desc);
       m = NdrFreer[*desc & NDR_TABLE_MASK];
       if (m) m(pStubMsg, pMemory, desc);
@@ -1512,7 +1512,7 @@
     case RPC_FC_EMBEDDED_COMPLEX:
       size += pFormat[1];
       pFormat += 2;
-      desc = pFormat + *(SHORT*)pFormat;
+      desc = pFormat + *(const SHORT*)pFormat;
       size += EmbeddedComplexSize(pStubMsg, desc);
       pFormat += 2;
       continue;
@@ -1541,9 +1541,9 @@
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
   pFormat += 4;
-  if (*(WORD*)pFormat) conf_array = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
-  if (*(WORD*)pFormat) pointer_desc = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
 
   pStubMsg->Memory = pMemory;
@@ -1568,7 +1568,7 @@
                                                   PFORMAT_STRING pFormat,
                                                   unsigned char fMustAlloc)
 {
-  unsigned size = *(LPWORD)(pFormat+2);
+  unsigned size = *(const WORD*)(pFormat+2);
   PFORMAT_STRING conf_array = NULL;
   PFORMAT_STRING pointer_desc = NULL;
   unsigned char *pMemory;
@@ -1579,9 +1579,9 @@
     *ppMemory = NdrAllocate(pStubMsg, size);
 
   pFormat += 4;
-  if (*(WORD*)pFormat) conf_array = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
-  if (*(WORD*)pFormat) pointer_desc = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
 
   pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
@@ -1606,9 +1606,9 @@
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
   pFormat += 4;
-  if (*(WORD*)pFormat) conf_array = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
-  if (*(WORD*)pFormat) pointer_desc = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
 
   pStubMsg->Memory = pMemory;
@@ -1634,9 +1634,9 @@
   FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
 
   pFormat += 4;
-  if (*(WORD*)pFormat) conf_array = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
-  if (*(WORD*)pFormat) pointer_desc = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
 
   return 0;
@@ -1656,9 +1656,9 @@
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
   pFormat += 4;
-  if (*(WORD*)pFormat) conf_array = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
-  if (*(WORD*)pFormat) pointer_desc = pFormat + *(WORD*)pFormat;
+  if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
   pFormat += 2;
 
   pStubMsg->Memory = pMemory;
@@ -1678,7 +1678,7 @@
                                                   unsigned char *pMemory,
                                                   PFORMAT_STRING pFormat)
 {
-  DWORD size = 0, esize = *(LPWORD)(pFormat+2);
+  DWORD size = 0, esize = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
 
@@ -1707,7 +1707,7 @@
                                                     PFORMAT_STRING pFormat,
                                                     unsigned char fMustAlloc)
 {
-  DWORD size = 0, esize = *(LPWORD)(pFormat+2);
+  DWORD size = 0, esize = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
   if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
 
@@ -1742,7 +1742,7 @@
                                          unsigned char *pMemory,
                                          PFORMAT_STRING pFormat)
 {
-  DWORD size = 0, esize = *(LPWORD)(pFormat+2);
+  DWORD size = 0, esize = *(const WORD*)(pFormat+2);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
 
@@ -1853,14 +1853,14 @@
   DWORD size = 0, count, def;
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
-  def = *(WORD*)&pFormat[2];
+  def = *(const WORD*)&pFormat[2];
   pFormat += 4;
 
   pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
   size = pStubMsg->MaxCount;
   TRACE("conformance=%ld\n", size);
 
-  if (*(DWORD*)pFormat != 0xffffffff)
+  if (*(const DWORD*)pFormat != 0xffffffff)
     FIXME("compute variance\n");
   pFormat += 4;
 
@@ -1917,14 +1917,14 @@
   DWORD size = 0, count, def;
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
-  def = *(WORD*)&pFormat[2];
+  def = *(const WORD*)&pFormat[2];
   pFormat += 4;
 
   pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
   size = pStubMsg->MaxCount;
   TRACE("conformance=%ld\n", size);
 
-  if (*(DWORD*)pFormat != 0xffffffff)
+  if (*(const DWORD*)pFormat != 0xffffffff)
     FIXME("compute variance\n");
   pFormat += 4;
 
@@ -1962,14 +1962,14 @@
   DWORD size = 0, count, def;
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
-  def = *(WORD*)&pFormat[2];
+  def = *(const WORD*)&pFormat[2];
   pFormat += 4;
 
   pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
   size = pStubMsg->MaxCount;
   TRACE("conformance=%ld\n", size);
 
-  if (*(DWORD*)pFormat != 0xffffffff)
+  if (*(const DWORD*)pFormat != 0xffffffff)
     FIXME("compute variance\n");
   pFormat += 4;
 
@@ -1991,7 +1991,7 @@
                                               PFORMAT_STRING pFormat)
 {
 /*  unsigned flags = pFormat[1]; */
-  unsigned index = *(WORD*)&pFormat[2];
+  unsigned index = *(const WORD*)&pFormat[2];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   TRACE("index=%d\n", index);
@@ -2014,8 +2014,8 @@
                                                  unsigned char fMustAlloc)
 {
 /*  unsigned flags = pFormat[1];*/
-  unsigned index = *(WORD*)&pFormat[2];
-  DWORD memsize = *(WORD*)&pFormat[4];
+  unsigned index = *(const WORD*)&pFormat[2];
+  DWORD memsize = *(const WORD*)&pFormat[4];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
   TRACE("index=%d\n", index);
@@ -2038,8 +2038,8 @@
                                       PFORMAT_STRING pFormat)
 {
 /*  unsigned flags = pFormat[1];*/
-  unsigned index = *(WORD*)&pFormat[2];
-  DWORD bufsize = *(WORD*)&pFormat[6];
+  unsigned index = *(const WORD*)&pFormat[2];
+  DWORD bufsize = *(const WORD*)&pFormat[6];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   TRACE("index=%d\n", index);
@@ -2061,8 +2061,8 @@
 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
                                               PFORMAT_STRING pFormat)
 {
-  unsigned index = *(WORD*)&pFormat[2];
-/*  DWORD memsize = *(WORD*)&pFormat[4]; */
+  unsigned index = *(const WORD*)&pFormat[2];
+/*  DWORD memsize = *(const WORD*)&pFormat[4]; */
   FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
   TRACE("index=%d\n", index);
 
@@ -2077,7 +2077,7 @@
                                 PFORMAT_STRING pFormat)
 {
 /*  unsigned flags = pFormat[1]; */
-  unsigned index = *(WORD*)&pFormat[2];
+  unsigned index = *(const WORD*)&pFormat[2];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   TRACE("index=%d\n", index);

reactos/lib/rtl
acl.c 1.4 -> 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- acl.c	6 Nov 2004 21:32:16 -0000	1.4
+++ acl.c	8 Dec 2004 21:57:21 -0000	1.4.2.1
@@ -1,4 +1,4 @@
-/*
+/* $Id: acl.c,v 1.4.2.1 2004/12/08 21:57:21 hyperion Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -43,11 +43,11 @@
          return(FALSE);
       }
       if (Current->Header.AceType == ACCESS_ALLOWED_COMPOUND_ACE_TYPE &&
-            Acl->AclRevision < ACL_REVISION3)
+          Acl->AclRevision < ACL_REVISION3)
       {
          return(FALSE);
       }
-      Current = (PACE)((PVOID)Current + (ULONG)Current->Header.AceSize);
+      Current = (PACE)((ULONG_PTR)Current + (ULONG_PTR)Current->Header.AceSize);
       i++;
    }
    while (i < Acl->AceCount);
@@ -74,7 +74,7 @@
    *Ace = (PACE)(Acl + 1);
 
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(STATUS_INVALID_PARAMETER);
    }
@@ -117,7 +117,7 @@
       return(STATUS_INVALID_SID);
    }
    if (Acl->AclRevision > MAX_ACL_REVISION ||
-         Revision > MAX_ACL_REVISION)
+       Revision > MAX_ACL_REVISION)
    {
       return(STATUS_UNKNOWN_REVISION);
    }
@@ -231,7 +231,7 @@
 {
    if (Offset > 0)
    {
-      memcpy((PUCHAR)Ace + AceListLength,
+      memcpy((PVOID)Ace + AceListLength,
              Ace,
              Offset);
    }
@@ -261,7 +261,7 @@
    ULONG j;
 
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(STATUS_INVALID_PARAMETER);
    }
@@ -286,7 +286,7 @@
    while ((PVOID)Current < ((PVOID)AceList + AceListLength))
    {
       if (AceList->Header.AceType == ACCESS_ALLOWED_COMPOUND_ACE_TYPE &&
-            AclRevision < ACL_REVISION3)
+          AclRevision < ACL_REVISION3)
       {
          return(STATUS_INVALID_PARAMETER);
       }
@@ -356,7 +356,7 @@
    }
 
    if (Acl->AclRevision > MAX_ACL_REVISION ||
-         Revision > MAX_ACL_REVISION)
+       Revision > MAX_ACL_REVISION)
    {
       return(STATUS_REVISION_MISMATCH);
    }
@@ -496,7 +496,7 @@
    PACE Current;
 
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(STATUS_INVALID_PARAMETER);
    }
@@ -551,7 +551,7 @@
       return(STATUS_INVALID_PARAMETER);
    }
 
-   AclSize = (AclSize + 3) & ~(0x3);
+   AclSize = ROUND_UP(AclSize, 4);
    Acl->AclSize = AclSize;
    Acl->AclRevision = AclRevision;
    Acl->AceCount = 0;
@@ -574,7 +574,7 @@
    PACE Ace;
 
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(STATUS_INVALID_PARAMETER);
    }
@@ -639,7 +639,7 @@
                      ACL_INFORMATION_CLASS InformationClass)
 {
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(STATUS_INVALID_PARAMETER);
    }
@@ -681,10 +681,10 @@
    PACE Ace;
    USHORT Size;
 
-   Size = (Acl->AclSize + 3) & ~3;
+   Size = ROUND_UP(Acl->AclSize, 4);
 
    if (Acl->AclRevision < MIN_ACL_REVISION ||
-         Acl->AclRevision > MAX_ACL_REVISION)
+       Acl->AclRevision > MAX_ACL_REVISION)
    {
       return(FALSE);
    }

reactos/lib/rtl
heap.c 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- heap.c	28 Aug 2004 22:14:08 -0000	1.3
+++ heap.c	8 Dec 2004 21:57:21 -0000	1.3.6.1
@@ -21,20 +21,12 @@
 #define NDEBUG
 #include <debug.h>
 
-#define DPRINTF DPRINT
-#define ERR DPRINT
-#define SetLastError(x)
-#define WARN DPRINT
-#define TRACE DPRINT
 #define WARN_ON(x) (1)
 
-#undef assert
 #ifdef NDEBUG
 #define TRACE_ON(x) (0)
-#define assert(x)
 #else
 #define TRACE_ON(x) (1)
-#define assert(x)
 #endif
 
 
@@ -43,17 +35,17 @@
 
 typedef struct tagARENA_INUSE
 {
-   DWORD  size;                    /* Block size; must be the first field */
-   WORD   threadId;                /* Allocating thread id */
-   WORD   magic;                   /* Magic number */
+   ULONG  size;                    /* Block size; must be the first field */
+   USHORT threadId;                /* Allocating thread id */
+   USHORT magic;                   /* Magic number */
 }
 ARENA_INUSE;
 
 typedef struct tagARENA_FREE
 {
-   DWORD                 size;     /* Block size; must be the first field */
-   WORD                  threadId; /* Freeing thread id */
-   WORD                  magic;    /* Magic number */
+   ULONG                 size;     /* Block size; must be the first field */
+   USHORT                threadId; /* Freeing thread id */
+   USHORT                magic;    /* Magic number */
    struct tagARENA_FREE *next;     /* Next free arena */
    struct tagARENA_FREE *prev;     /* Prev free arena */
 }
@@ -74,14 +66,14 @@
 #define HEAP_NB_FREE_LISTS   4   /* Number of free lists */
 
 /* Max size of the blocks on the free lists */
-static const DWORD HEAP_freeListSizes[HEAP_NB_FREE_LISTS] =
+static const ULONG HEAP_freeListSizes[HEAP_NB_FREE_LISTS] =
    {
       0x20, 0x80, 0x200, 0xffffffff
    };
 
 typedef struct
 {
-   DWORD       size;
+   ULONG       size;
    ARENA_FREE  arena;
 }
 FREE_LIST_ENTRY;
@@ -90,16 +82,16 @@
 
 typedef struct tagSUBHEAP
 {
-   DWORD               size;       /* Size of the whole sub-heap */
-   DWORD               commitSize; /* Committed size of the sub-heap */
-   DWORD               headerSize; /* Size of the heap header */
+   ULONG               size;       /* Size of the whole sub-heap */
+   ULONG               commitSize; /* Committed size of the sub-heap */
+   ULONG               headerSize; /* Size of the heap header */
    struct tagSUBHEAP  *next;       /* Next sub-heap */
    struct tagHEAP     *heap;       /* Main heap structure */
-   DWORD               magic;      /* Magic number */
+   ULONG               magic;      /* Magic number */
 }
 SUBHEAP, *PSUBHEAP;
 
-#define SUBHEAP_MAGIC    ((DWORD)('S' | ('U'<<8) | ('B'<<16) | ('H'<<24)))
+#define SUBHEAP_MAGIC    ((ULONG)('S' | ('U'<<8) | ('B'<<16) | ('H'<<24)))
 
 typedef struct tagHEAP
 {
@@ -107,78 +99,79 @@
    struct tagHEAP  *next;          /* Next heap for this process */
    FREE_LIST_ENTRY  freeList[HEAP_NB_FREE_LISTS];  /* Free lists */
    CRITICAL_SECTION critSection;   /* Critical section for serialization */
-   DWORD            flags;         /* Heap flags */
-   DWORD            magic;         /* Magic number */
-   BYTE             filler[4];     /* Make multiple of 8 bytes */
+   ULONG            flags;         /* Heap flags */
+   ULONG            magic;         /* Magic number */
+   UCHAR            filler[4];     /* Make multiple of 8 bytes */
 }
 HEAP, *PHEAP;
 
-#define HEAP_MAGIC       ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24)))
+#define HEAP_MAGIC       ((ULONG)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24)))
 
 #define HEAP_DEF_SIZE        0x110000   /* Default heap size = 1Mb + 64Kb */
 #define HEAP_MIN_BLOCK_SIZE  (sizeof(ARENA_FREE) + 8)  /* Min. heap block size */
 #define COMMIT_MASK          0xffff  /* bitmask for commit/decommit granularity */
 
 
-static BOOL HEAP_IsRealArena( HANDLE heap, DWORD flags, LPCVOID block, BOOL quiet );
+static BOOLEAN HEAP_IsRealArena( HANDLE heap, ULONG flags, PVOID block, BOOLEAN quiet );
 
 
 /***********************************************************************
  *           HEAP_Dump
  */
-void
+VOID
 HEAP_Dump(PHEAP heap)
 {
    int i;
    SUBHEAP *subheap;
    char *ptr;
 
-   DPRINTF( "Heap: %08lx\n", (DWORD)heap );
-   DPRINTF( "Next: %08lx  Sub-heaps: %08lx",
-            (DWORD)heap->next, (DWORD)&heap->subheap );
+   DPRINT( "Heap: %p\n", heap );
+   DPRINT( "Next: %p  Sub-heaps: %p",
+           heap->next, &heap->subheap );
    subheap = &heap->subheap;
    while (subheap->next)
    {
-      DPRINTF( " -> %08lx", (DWORD)subheap->next );
+      DPRINT( " -> %p", subheap->next );
       subheap = subheap->next;
    }
 
-   DPRINTF( "\nFree lists:\n Block   Stat   Size    Id\n" );
+   DPRINT( "\nFree lists:\n Block   Stat   Size    Id\n" );
    for (i = 0; i < HEAP_NB_FREE_LISTS; i++)
-      DPRINTF( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
-               (DWORD)&heap->freeList[i].arena, heap->freeList[i].arena.size,
-               heap->freeList[i].arena.threadId,
-               (DWORD)heap->freeList[i].arena.prev,
-               (DWORD)heap->freeList[i].arena.next );
+      DPRINT( "%p free %08lx %04x prev=%p next=%p\n",
+              &heap->freeList[i].arena,
+              heap->freeList[i].arena.size,
+              heap->freeList[i].arena.threadId,
+              heap->freeList[i].arena.prev,
+              heap->freeList[i].arena.next );
 
    subheap = &heap->subheap;
    while (subheap)
    {
-      DWORD freeSize = 0, usedSize = 0, arenaSize = subheap->headerSize;
-      DPRINTF( "\n\nSub-heap %08lx: size=%08lx committed=%08lx\n",
-               (DWORD)subheap, subheap->size, subheap->commitSize );
+      ULONG freeSize = 0, usedSize = 0, arenaSize = subheap->headerSize;
+      DPRINT( "\n\nSub-heap %p: size=%08lx committed=%08lx\n",
+              subheap, subheap->size, subheap->commitSize );
 
-      DPRINTF( "\n Block   Stat   Size    Id\n" );
+      DPRINT( "\n Block   Stat   Size    Id\n" );
       ptr = (char*)subheap + subheap->headerSize;
       while (ptr < (char *)subheap + subheap->size)
       {
-         if (*(DWORD *)ptr & ARENA_FLAG_FREE)
+         if (*(PULONG)ptr & ARENA_FLAG_FREE)
          {
             ARENA_FREE *pArena = (ARENA_FREE *)ptr;
-            DPRINTF( "%08lx free %08lx %04x prev=%08lx next=%08lx\n",
-                     (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                     pArena->threadId, (DWORD)pArena->prev,
-                     (DWORD)pArena->next);
+            DPRINT( "%p free %08lx %04x prev=%p next=%p\n",
+                    pArena, pArena->size & ARENA_SIZE_MASK,
+                    pArena->threadId, pArena->prev,
+                    pArena->next);
             ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
             arenaSize += sizeof(ARENA_FREE);
             freeSize += pArena->size & ARENA_SIZE_MASK;
          }
-         else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE)
+         else if (*(PULONG)ptr & ARENA_FLAG_PREV_FREE)
          {
             ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
-            DPRINTF( "%08lx Used %08lx %04x back=%08lx\n",
-                     (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                     pArena->threadId, *((DWORD *)pArena - 1));
+            DPRINT( "%p Used %08lx %04x back=%08lx\n",
+                    pArena, pArena->size & ARENA_SIZE_MASK,
+                    pArena->threadId, *((PULONG)pArena - 1));
             ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
             arenaSize += sizeof(ARENA_INUSE);
             usedSize += pArena->size & ARENA_SIZE_MASK;
@@ -186,15 +179,15 @@
          else
          {
             ARENA_INUSE *pArena = (ARENA_INUSE *)ptr;
-            DPRINTF( "%08lx used %08lx %04x\n",
-                     (DWORD)pArena, pArena->size & ARENA_SIZE_MASK,
-                     pArena->threadId);
+            DPRINT( "%p used %08lx %04x\n",
+                    pArena, pArena->size & ARENA_SIZE_MASK,
+                    pArena->threadId);
             ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK);
             arenaSize += sizeof(ARENA_INUSE);
             usedSize += pArena->size & ARENA_SIZE_MASK;
          }
       }
-      DPRINTF( "\nTotal: Size=%08lx Committed=%08lx Free=%08lx Used=%08lx Arenas=%08lx (%ld%%)\n\n",
+      DPRINT( "\nTotal: Size=%08lx Committed=%08lx Free=%08lx Used=%08lx Arenas=%08lx (%ld%%)\n\n",
                subheap->size, subheap->commitSize, freeSize, usedSize,
                arenaSize, (arenaSize * 100) / subheap->size );
       subheap = subheap->next;
@@ -214,13 +207,13 @@
    HEAP *heapPtr = (HEAP *)heap;
    if (!heapPtr || (heapPtr->magic != HEAP_MAGIC))
    {
-      ERR("Invalid heap %08x!\n", heap );
+      DPRINT("Invalid heap %08x!\n", heap );
       return NULL;
    }
    if (TRACE_ON(heap) && !HEAP_IsRealArena( heap, 0, NULL, NOISY ))
    {
       HEAP_Dump( heapPtr );
-      assert( FALSE );
+      ASSERT( FALSE );
       return NULL;
    }
    return heapPtr;
@@ -235,7 +228,7 @@
 static VOID
 HEAP_InsertFreeBlock(PHEAP heap,
                      ARENA_FREE *pArena,
-                     BOOL last)
+                     BOOLEAN last)
 {
    FREE_LIST_ENTRY *pEntry = heap->freeList;
    while (pEntry->size < pArena->size)
@@ -275,9 +268,9 @@
  */
 static PSUBHEAP
 HEAP_FindSubHeap(HEAP *heap,  /* [in] Heap pointer */
-                 LPCVOID ptr) /* [in] Address */
+                 PVOID ptr) /* [in] Address */
 {
-   SUBHEAP *sub = &heap->subheap;
+   PSUBHEAP sub = &heap->subheap;
    while (sub)
    {
       if (((char *)ptr >= (char *)sub) &&
@@ -294,12 +287,12 @@
  *
  * Make sure the heap storage is committed up to (not including) ptr.
  */
-static inline BOOL
+static inline BOOLEAN
 HEAP_Commit(SUBHEAP *subheap,
-            void *ptr,
-            DWORD flags)
+            PVOID ptr,
+            ULONG flags)
 {
-   DWORD size = (DWORD)((char *)ptr - (char *)subheap);
+   ULONG size = (ULONG)((char *)ptr - (char *)subheap);
    NTSTATUS Status;
    PVOID address;
    ULONG commitsize;
@@ -323,10 +316,10 @@
                                        PAGE_EXECUTE_READWRITE);
       if (!NT_SUCCESS(Status))
       {
-         WARN("Could not commit %08lx bytes at %08lx for heap %08lx\n",
-              size - subheap->commitSize,
-              (DWORD)((char *)subheap + subheap->commitSize),
-              (DWORD)subheap->heap );
+         DPRINT( "Could not commit %08lx bytes at %p for heap %p\n",
+                 size - subheap->commitSize,
+                 ((char *)subheap + subheap->commitSize),
+                 subheap->heap );
          return FALSE;
       }
    }
@@ -340,9 +333,9 @@
  *
  * If possible, decommit the heap storage from (including) 'ptr'.
  */
-static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr, DWORD flags )
+static inline BOOLEAN HEAP_Decommit( SUBHEAP *subheap, PVOID ptr, ULONG flags )
 {
-   DWORD size = (DWORD)((char *)ptr - (char *)subheap);
+   ULONG size = (ULONG)((char *)ptr - (char *)subheap);
    PVOID address;
    ULONG decommitsize;
    NTSTATUS Status;
@@ -363,10 +356,10 @@
       if (!NT_SUCCESS(Status))
          ;
       {
-         WARN("Could not decommit %08lx bytes at %08lx for heap %08lx\n",
-              subheap->commitSize - size,
-              (DWORD)((char *)subheap + size),
-              (DWORD)subheap->heap );
+         DPRINT( "Could not decommit %08lx bytes at %p for heap %p\n",
+                 subheap->commitSize - size,
+                 ((char *)subheap + size),
+                 subheap->heap );
          return FALSE;
       }
    }
@@ -381,15 +374,15 @@
  * Create a free block at a specified address. 'size' is the size of the
  * whole block, including the new arena.
  */
-static void HEAP_CreateFreeBlock( SUBHEAP *subheap, void *ptr, DWORD size )
+static VOID HEAP_CreateFreeBlock( SUBHEAP *subheap, PVOID ptr, ULONG size )
 {
    ARENA_FREE *pFree;
-   BOOL last;
+   BOOLEAN last;
 
    /* Create a free arena */
 
    pFree = (ARENA_FREE *)ptr;
-   pFree->threadId = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
+   pFree->threadId = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
    pFree->magic = ARENA_FREE_MAGIC;
 
    /* If debugging, erase the freed block content */
@@ -406,7 +399,7 @@
    /* Check if next block is free also */
 
    if (((char *)ptr + size < (char *)subheap + subheap->size) &&
-         (*(DWORD *)((char *)ptr + size) & ARENA_FLAG_FREE))
+         (*(PULONG)((char *)ptr + size) & ARENA_FLAG_FREE))
    {
       /* Remove the next arena from the free list */
       ARENA_FREE *pNext = (ARENA_FREE *)((char *)ptr + size);
@@ -422,7 +415,7 @@
    last = ((char *)ptr + size >= (char *)subheap + subheap->size);
    if (!last)
    {
-      DWORD *pNext = (DWORD *)((char *)ptr + size);
+      PULONG pNext = (PULONG)((char *)ptr + size);
       *pNext |= ARENA_FLAG_PREV_FREE;
       *(ARENA_FREE **)(pNext - 1) = pFree;
    }
@@ -440,11 +433,11 @@
  * Turn an in-use block into a free block. Can also decommit the end of
  * the heap, and possibly even free the sub-heap altogether.
  */
-static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena,
-                                     DWORD flags)
+static VOID HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena,
+                                     ULONG flags)
 {
    ARENA_FREE *pFree;
-   DWORD size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena);
+   ULONG size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena);
 
    /* Check if we can merge with previous block */
 
@@ -502,7 +495,7 @@
  *
  * Shrink an in-use block.
  */
-static void HEAP_ShrinkBlock(SUBHEAP *subheap, ARENA_INUSE *pArena, DWORD size)
+static void HEAP_ShrinkBlock(SUBHEAP *subheap, ARENA_INUSE *pArena, ULONG size)
 {
    if ((pArena->size & ARENA_SIZE_MASK) >= size + HEAP_MIN_BLOCK_SIZE)
    {
@@ -516,15 +509,15 @@
       /* Turn off PREV_FREE flag in next block */
       char *pNext = (char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK);
       if (pNext < (char *)subheap + subheap->size)
-         *(DWORD *)pNext &= ~ARENA_FLAG_PREV_FREE;
+         *(PULONG)pNext &= ~ARENA_FLAG_PREV_FREE;
    }
 }
 
 /***********************************************************************
  *           HEAP_InitSubHeap
  */
-static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
-                              DWORD commitSize, DWORD totalSize )
+static BOOLEAN HEAP_InitSubHeap( HEAP *heap, PVOID address, ULONG flags,
+                              ULONG commitSize, ULONG totalSize )
 {
    SUBHEAP *subheap = (SUBHEAP *)address;
    FREE_LIST_ENTRY *pEntry;
@@ -542,15 +535,15 @@
                                        PAGE_EXECUTE_READWRITE);
       if (!NT_SUCCESS(Status))
       {
-         WARN("Could not commit %08lx bytes for sub-heap %08lx\n",
-              commitSize, (DWORD)address );
+         DPRINT("Could not commit %08lx bytes for sub-heap %p\n",
+                commitSize, address);
          return FALSE;
       }
    }
 
    /* Fill the sub-heap structure */
 
-   subheap = (SUBHEAP *)address;
+   subheap = (PSUBHEAP)address;
    subheap->heap       = heap;
    subheap->size       = totalSize;
    subheap->commitSize = commitSize;
@@ -595,7 +588,7 @@
 
    /* Create the first free block */
 
-   HEAP_CreateFreeBlock( subheap, (LPBYTE)subheap + subheap->headerSize,
+   HEAP_CreateFreeBlock( subheap, (PUCHAR)subheap + subheap->headerSize,
                          subheap->size - subheap->headerSize );
 
    return TRUE;
@@ -607,11 +600,12 @@
  * Create a sub-heap of the given size.
  * If heap == NULL, creates a main heap.
  */
-static SUBHEAP *HEAP_CreateSubHeap(PVOID BaseAddress,
-                                   HEAP *heap, DWORD flags,
-                                   DWORD commitSize, DWORD totalSize )
+static PSUBHEAP
+HEAP_CreateSubHeap(PVOID BaseAddress,
+                                   HEAP *heap, ULONG flags,
+                                   ULONG commitSize, ULONG totalSize )
 {
-   LPVOID address;
+   PVOID address;
    NTSTATUS Status;
 
    /* Round-up sizes on a 64K boundary */
@@ -635,8 +629,8 @@
                                        PAGE_EXECUTE_READWRITE);
       if (!NT_SUCCESS(Status))
       {
-         WARN("Could not VirtualAlloc %08lx bytes\n",
-              totalSize );
+         DPRINT("Could not VirtualAlloc %08lx bytes\n",
+                totalSize );
          return NULL;
       }
    }
@@ -667,7 +661,7 @@
  * Find a free block at least as large as the requested size, and make sure
  * the requested size is committed.
  */
-static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, DWORD size,
+static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, ULONG size,
                                        SUBHEAP **ppSubHeap )
 {
    SUBHEAP *subheap;
@@ -681,7 +675,7 @@
    pArena = pEntry->arena.next;
    while (pArena != &heap->freeList[0].arena)
    {
-      DWORD arena_size = (pArena->size & ARENA_SIZE_MASK) +
+      ULONG arena_size = (pArena->size & ARENA_SIZE_MASK) +
                          sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
       if (arena_size >= size)
       {
@@ -701,8 +695,8 @@
 
    if (!(heap->flags & HEAP_GROWABLE))
    {
-      WARN("Not enough space in heap %08lx for %08lx bytes\n",
-           (DWORD)heap, size );
+      DPRINT("Not enough space in heap %p for %08lx bytes\n",
+             heap, size );
       return NULL;
    }
    /* make sure that we have a big enough size *committed* to fit another
@@ -715,8 +709,8 @@
                                        max( HEAP_DEF_SIZE, size ) )))
       return NULL;
 
-   TRACE("created new sub-heap %08lx of %08lx bytes for heap %08lx\n",
-         (DWORD)subheap, size, (DWORD)heap );
+   DPRINT("created new sub-heap %p of %08lx bytes for heap %p\n",
+          subheap, size, heap );
 
    *ppSubHeap = subheap;
    return (ARENA_FREE *)(subheap + 1);
@@ -728,7 +722,7 @@
  *
  * Check that the pointer is inside the range possible for arenas.
  */
-static BOOL HEAP_IsValidArenaPtr( HEAP *heap, void *ptr )
+static BOOLEAN HEAP_IsValidArenaPtr( HEAP *heap, PVOID ptr )
 {
    int i;
    SUBHEAP *subheap = HEAP_FindSubHeap( heap, ptr );
@@ -739,7 +733,7 @@
    if (subheap != &heap->subheap)
       return FALSE;
    for (i = 0; i < HEAP_NB_FREE_LISTS; i++)
-      if (ptr == (void *)&heap->freeList[i].arena)
+      if (ptr == (PVOID)&heap->freeList[i].arena)
          return TRUE;
    return FALSE;
 }
@@ -748,78 +742,78 @@
 /***********************************************************************
  *           HEAP_ValidateFreeArena
  */
-static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena )
+static BOOLEAN HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena )
 {
    char *heapEnd = (char *)subheap + subheap->size;
 
    /* Check magic number */
    if (pArena->magic != ARENA_FREE_MAGIC)
    {
-      ERR("Heap %08lx: invalid free arena magic for %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena );
+      DPRINT("Heap %p: invalid free arena magic for %p\n",
+             subheap->heap, pArena);
       return FALSE;
    }
    /* Check size flags */
    if (!(pArena->size & ARENA_FLAG_FREE) ||
          (pArena->size & ARENA_FLAG_PREV_FREE))
    {
-      ERR("Heap %08lx: bad flags %lx for free arena %08lx\n",
-          (DWORD)subheap->heap, pArena->size & ~ARENA_SIZE_MASK, (DWORD)pArena );
+      DPRINT("Heap %p: bad flags %lx for free arena %p\n",
+             subheap->heap, pArena->size & ~ARENA_SIZE_MASK, pArena);
    }
    /* Check arena size */
    if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd)
    {
-      ERR("Heap %08lx: bad size %08lx for free arena %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->size & ARENA_SIZE_MASK, (DWORD)pArena );
+      DPRINT("Heap %p: bad size %08lx for free arena %p\n",
+             subheap->heap, (ULONG)pArena->size & ARENA_SIZE_MASK, pArena );
       return FALSE;
    }
    /* Check that next pointer is valid */
    if (!HEAP_IsValidArenaPtr( subheap->heap, pArena->next ))
    {
-      ERR("Heap %08lx: bad next ptr %08lx for arena %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->next, (DWORD)pArena );
+      DPRINT("Heap %p: bad next ptr %p for arena %p\n",
+             subheap->heap, pArena->next, pArena);
       return FALSE;
    }
    /* Check that next arena is free */
    if (!(pArena->next->size & ARENA_FLAG_FREE) ||
          (pArena->next->magic != ARENA_FREE_MAGIC))
    {
-      ERR("Heap %08lx: next arena %08lx invalid for %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->next, (DWORD)pArena );
+      DPRINT("Heap %p: next arena %p invalid for %p\n",
+             subheap->heap, pArena->next, pArena);
       return FALSE;
    }
    /* Check that prev pointer is valid */
    if (!HEAP_IsValidArenaPtr( subheap->heap, pArena->prev ))
    {
-      ERR("Heap %08lx: bad prev ptr %08lx for arena %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->prev, (DWORD)pArena );
+      DPRINT("Heap %p: bad prev ptr %p for arena %p\n",
+             subheap->heap, pArena->prev, pArena);
       return FALSE;
    }
    /* Check that prev arena is free */
    if (!(pArena->prev->size & ARENA_FLAG_FREE) ||
          (pArena->prev->magic != ARENA_FREE_MAGIC))
    {
-      ERR("Heap %08lx: prev arena %08lx invalid for %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->prev, (DWORD)pArena );
+      DPRINT("Heap %p: prev arena %p invalid for %p\n",
+             subheap->heap, pArena->prev, pArena);
       return FALSE;
    }
    /* Check that next block has PREV_FREE flag */
    if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd)
    {
-      if (!(*(DWORD *)((char *)(pArena + 1) +
+      if (!(*(PULONG)((char *)(pArena + 1) +
                        (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE))
       {
-         ERR("Heap %08lx: free arena %08lx next block has no PREV_FREE flag\n",
-             (DWORD)subheap->heap, (DWORD)pArena );
+         DPRINT("Heap %p: free arena %p next block has no PREV_FREE flag\n",
+                subheap->heap, pArena);
          return FALSE;
       }
       /* Check next block back pointer */
       if (*((ARENA_FREE **)((char *)(pArena + 1) +
                             (pArena->size & ARENA_SIZE_MASK)) - 1) != pArena)
       {
-         ERR("Heap %08lx: arena %08lx has wrong back ptr %08lx\n",
-             (DWORD)subheap->heap, (DWORD)pArena,
-             *((DWORD *)((char *)(pArena+1)+ (pArena->size & ARENA_SIZE_MASK)) - 1));
+         DPRINT("Heap %p: arena %p has wrong back ptr %p\n",
+                subheap->heap, pArena,
+                *((PULONG)((char *)(pArena+1)+ (pArena->size & ARENA_SIZE_MASK)) - 1));
          return FALSE;
       }
    }
@@ -830,7 +824,7 @@
 /***********************************************************************
  *           HEAP_ValidateInUseArena
  */
-static BOOL HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOL quiet )
+static BOOLEAN HEAP_ValidateInUseArena( SUBHEAP *subheap, ARENA_INUSE *pArena, BOOLEAN quiet )
 {
    char *heapEnd = (char *)subheap + subheap->size;
 
@@ -839,15 +833,15 @@
    {
       if (quiet == NOISY)
       {
-         ERR("Heap %08lx: invalid in-use arena magic for %08lx\n",
-             (DWORD)subheap->heap, (DWORD)pArena );
+         DPRINT("Heap %p: invalid in-use arena magic for %p\n",
+                subheap->heap, pArena);
          if (TRACE_ON(heap))
             HEAP_Dump( subheap->heap );
       }
       else if (WARN_ON(heap))
       {
-         WARN("Heap %08lx: invalid in-use arena magic for %08lx\n",
-              (DWORD)subheap->heap, (DWORD)pArena );
+         DPRINT("Heap %p: invalid in-use arena magic for %p\n",
+                subheap->heap, pArena);
          if (TRACE_ON(heap))
             HEAP_Dump( subheap->heap );
       }
@@ -856,23 +850,23 @@
    /* Check size flags */
    if (pArena->size & ARENA_FLAG_FREE)
    {
-      ERR("Heap %08lx: bad flags %lx for in-use arena %08lx\n",
-          (DWORD)subheap->heap, pArena->size & ~ARENA_SIZE_MASK, (DWORD)pArena );
+      DPRINT("Heap %p: bad flags %lx for in-use arena %p\n",
+             subheap->heap, pArena->size & ~ARENA_SIZE_MASK, pArena);
       return FALSE;
    }
    /* Check arena size */
    if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd)
    {
-      ERR("Heap %08lx: bad size %08lx for in-use arena %08lx\n",
-          (DWORD)subheap->heap, (DWORD)pArena->size & ARENA_SIZE_MASK, (DWORD)pArena );
+      DPRINT("Heap %p: bad size %08lx for in-use arena %p\n",
+             subheap->heap, (ULONG)pArena->size & ARENA_SIZE_MASK, pArena);
       return FALSE;
    }
    /* Check next arena PREV_FREE flag */
    if (((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) &&
-         (*(DWORD *)((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE))
+         (*(PULONG)((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE))
    {
-      ERR("Heap %08lx: in-use arena %08lx next block has PREV_FREE flag\n",
-          (DWORD)subheap->heap, (DWORD)pArena );
+      DPRINT("Heap %p: in-use arena %p next block has PREV_FREE flag\n",
+             subheap->heap, pArena);
       return FALSE;
    }
    /* Check prev free arena */
@@ -882,23 +876,23 @@
       /* Check prev pointer */
       if (!HEAP_IsValidArenaPtr( subheap->heap, pPrev ))
       {
-         ERR("Heap %08lx: bad back ptr %08lx for arena %08lx\n",
-             (DWORD)subheap->heap, (DWORD)pPrev, (DWORD)pArena );
+         DPRINT("Heap %p: bad back ptr %p for arena %p\n",
+                subheap->heap, pPrev, pArena );
          return FALSE;
       }
       /* Check that prev arena is free */
       if (!(pPrev->size & ARENA_FLAG_FREE) ||
             (pPrev->magic != ARENA_FREE_MAGIC))
       {
-         ERR("Heap %08lx: prev arena %08lx invalid for in-use %08lx\n",
-             (DWORD)subheap->heap, (DWORD)pPrev, (DWORD)pArena );
+         DPRINT("Heap %p: prev arena %p invalid for in-use %p\n",
+                subheap->heap, pPrev, pArena);
          return FALSE;
       }
       /* Check that prev arena is really the previous block */
       if ((char *)(pPrev + 1) + (pPrev->size & ARENA_SIZE_MASK) != (char *)pArena)
       {
-         ERR("Heap %08lx: prev arena %08lx is not prev for in-use %08lx\n",
-             (DWORD)subheap->heap, (DWORD)pPrev, (DWORD)pArena );
+         DPRINT("Heap %p: prev arena %p is not prev for in-use %p\n",
+                subheap->heap, pPrev, pArena );
          return FALSE;
       }
    }
@@ -919,8 +913,8 @@
  */
 int HEAP_IsInsideHeap(
    HANDLE heap, /* [in] Heap */
-   DWORD flags,   /* [in] Flags */
-   LPCVOID ptr    /* [in] Pointer */
+   ULONG flags,   /* [in] Flags */
+   PVOID ptr    /* [in] Pointer */
 )
 {
    HEAP *heapPtr = HEAP_GetPtr( heap );
@@ -953,21 +947,21 @@
  * TRUE: Success
  * FALSE: Failure
  */
-static BOOL HEAP_IsRealArena(
+static BOOLEAN HEAP_IsRealArena(
    HANDLE heap,   /* [in] Handle to the heap */
-   DWORD flags,   /* [in] Bit flags that control access during operation */
-   LPCVOID block, /* [in] Optional pointer to memory block to validate */
-   BOOL quiet     /* [in] Flag - if true, HEAP_ValidateInUseArena
-                                 *             does not complain    */
+   ULONG flags,   /* [in] Bit flags that control access during operation */
+   PVOID block,   /* [in] Optional pointer to memory block to validate */
+   BOOLEAN quiet  /* [in] Flag - if true, HEAP_ValidateInUseArena
+                   *             does not complain    */
 )
 {
    SUBHEAP *subheap;
    HEAP *heapPtr = (HEAP *)(heap);
-   BOOL ret = TRUE;
+   BOOLEAN ret = TRUE;
 
    if (!heapPtr || (heapPtr->magic != HEAP_MAGIC))
    {
-      ERR("Invalid heap %08x!\n", heap );
+      DPRINT("Invalid heap %08x!\n", heap );
       return FALSE;
    }
 
@@ -989,13 +983,13 @@
       {
          if (quiet == NOISY)
          {
-            ERR("Heap %08lx: block %08lx is not inside heap\n",
-                (DWORD)heap, (DWORD)block );
+            DPRINT("Heap %p: block %p is not inside heap\n",
+                   heap, block );
          }
          else if (WARN_ON(heap))
          {
-            WARN("Heap %08lx: block %08lx is not inside heap\n",
-                 (DWORD)heap, (DWORD)block );
+            DPRINT1("Heap %p: block %p is not inside heap\n",
+                    heap, block );
          }
          ret = FALSE;
       }
@@ -1013,14 +1007,14 @@
       char *ptr = (char *)subheap + subheap->headerSize;
       while (ptr < (char *)subheap + subheap->size)
       {
-         if (*(DWORD *)ptr & ARENA_FLAG_FREE)
+         if (*(PULONG)ptr & ARENA_FLAG_FREE)
          {
             if (!HEAP_ValidateFreeArena( subheap, (ARENA_FREE *)ptr ))
             {
                ret = FALSE;
                break;
             }
-            ptr += sizeof(ARENA_FREE) + (*(DWORD *)ptr & ARENA_SIZE_MASK);
+            ptr += sizeof(ARENA_FREE) + (*(PULONG)ptr & ARENA_SIZE_MASK);
          }
          else
          {
@@ -1029,7 +1023,7 @@
                ret = FALSE;
                break;
             }
-            ptr += sizeof(ARENA_INUSE) + (*(DWORD *)ptr & ARENA_SIZE_MASK);
+            ptr += sizeof(ARENA_INUSE) + (*(PULONG)ptr & ARENA_SIZE_MASK);
          }
       }
       subheap = subheap->next;
@@ -1094,14 +1088,14 @@
  *
  * @implemented
  */
-BOOL STDCALL
+BOOLEAN STDCALL
 RtlDestroyHeap(HANDLE heap) /* [in] Handle of heap */
 {
    HEAP *heapPtr = HEAP_GetPtr( heap );
    SUBHEAP *subheap;
    ULONG i, flags;
 
-   TRACE("%08x\n", heap );
+   DPRINT("%08x\n", heap );
    if (!heapPtr)
       return FALSE;
 
@@ -1178,7 +1172,7 @@
 
    if (!(pArena = HEAP_FindFreeBlock( heapPtr, size, &subheap )))
    {
-      TRACE("(%08x,%08lx,%08lx): returning NULL\n",
+      DPRINT("(%08x,%08lx,%08lx): returning NULL\n",
             heap, flags, size  );
       if (!(flags & HEAP_NO_SERIALIZE))
          RtlLeaveCriticalSection( &heapPtr->critSection );
@@ -1197,7 +1191,7 @@
    pInUse = (ARENA_INUSE *)pArena;
    pInUse->size      = (pInUse->size & ~ARENA_FLAG_FREE)
                        + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
-   pInUse->threadId  = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
+   pInUse->threadId  = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
    pInUse->magic     = ARENA_INUSE_MAGIC;
 
    /* Shrink the block */
@@ -1212,9 +1206,9 @@
    if (!(flags & HEAP_NO_SERIALIZE))
       RtlLeaveCriticalSection( &heapPtr->critSection );
 
-   TRACE("(%08x,%08lx,%08lx): returning %08lx\n",
-         heap, flags, size, (DWORD)(pInUse + 1) );
-   return (LPVOID)(pInUse + 1);
+   DPRINT("(%08x,%08lx,%08lx): returning %p\n",
+         heap, flags, size, (PVOID)(pInUse + 1) );
+   return (PVOID)(pInUse + 1);
 }
 
 
@@ -1242,8 +1236,8 @@
       return FALSE;
    if (!ptr)  /* Freeing a NULL ptr is doesn't indicate an error in Win2k */
    {
-      WARN("(%08x,%08lx,%08lx): asked to free NULL\n",
-           heap, flags, (DWORD)ptr );
+      DPRINT("(%08x,%08lx,%p): asked to free NULL\n",
+           heap, flags, ptr );
       return TRUE;
    }
 
@@ -1255,8 +1249,8 @@
    {
       if (!(flags & HEAP_NO_SERIALIZE))
          RtlLeaveCriticalSection( &heapPtr->critSection );
-      TRACE("(%08x,%08lx,%08lx): returning FALSE\n",
-            heap, flags, (DWORD)ptr );
+      DPRINT("(%08x,%08lx,%p): returning FALSE\n",
+            heap, flags, ptr );
       return FALSE;
    }
 
@@ -1269,72 +1263,78 @@
    if (!(flags & HEAP_NO_SERIALIZE))
       RtlLeaveCriticalSection( &heapPtr->critSection );
 
-   TRACE("(%08x,%08lx,%08lx): returning TRUE\n",
-         heap, flags, (DWORD)ptr );
+   DPRINT("(%08x,%08lx,%p): returning TRUE\n",
+         heap, flags, ptr );
    return TRUE;
 }
 
 
 /***********************************************************************
- *           HeapReAlloc   (KERNEL32.340)
+ *           RtlReAllocateHeap
+ * PARAMS
+ *   Heap   [in] Handle of heap block
+ *   Flags    [in] Heap reallocation flags
+ *   Ptr,    [in] Address of memory to reallocate
+ *   Size     [in] Number of bytes to reallocate
+ *
  * RETURNS
  * Pointer to reallocated memory block
  * NULL: Failure
  * 0x7d030f60--invalid flags in RtlHeapAllocate
  * @implemented
  */
-LPVOID STDCALL RtlReAllocateHeap(
-   HANDLE heap, /* [in] Handle of heap block */
-   DWORD flags,   /* [in] Heap reallocation flags */
-   LPVOID ptr,    /* [in] Address of memory to reallocate */
-   DWORD size     /* [in] Number of bytes to reallocate */
+PVOID STDCALL RtlReAllocateHeap(
+   HANDLE Heap,
+   ULONG Flags,
+   PVOID Ptr,
+   ULONG Size
 )
 {
    ARENA_INUSE *pArena;
-   DWORD oldSize;
+   ULONG oldSize;
    HEAP *heapPtr;
    SUBHEAP *subheap;
 
-   if (!ptr)
+   if (!Ptr)
       return FALSE;
-   if (!(heapPtr = HEAP_GetPtr( heap )))
+   if (!(heapPtr = HEAP_GetPtr( Heap )))
       return FALSE;
 
    /* Validate the parameters */
 
-   flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY |
+   Flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY |
             HEAP_REALLOC_IN_PLACE_ONLY;
-   flags |= heapPtr->flags;
-   size = (size + 7) & ~7;
-   if (size < HEAP_MIN_BLOCK_SIZE)
-      size = HEAP_MIN_BLOCK_SIZE;
+   Flags |= heapPtr->flags;
+   Size = (Size + 7) & ~7;
+   if (Size < HEAP_MIN_BLOCK_SIZE)
+      Size = HEAP_MIN_BLOCK_SIZE;
 
-   if (!(flags & HEAP_NO_SERIALIZE))
+   if (!(Flags & HEAP_NO_SERIALIZE))
       RtlEnterCriticalSection( &heapPtr->critSection );
-   if (!HEAP_IsRealArena( heap, HEAP_NO_SERIALIZE, ptr, QUIET ))
+   if (!HEAP_IsRealArena( Heap, HEAP_NO_SERIALIZE, Ptr, QUIET ))
    {
-      if (!(flags & HEAP_NO_SERIALIZE))
+      if (!(Flags & HEAP_NO_SERIALIZE))
          RtlLeaveCriticalSection( &heapPtr->critSection );
-      TRACE("(%08x,%08lx,%08lx,%08lx): returning NULL\n",
-            heap, flags, (DWORD)ptr, size );
-      if (flags & HEAP_GENERATE_EXCEPTIONS)
+      DPRINT("(%08x,%08lx,%p,%08lx): returning NULL\n",
+            Heap, Flags, Ptr, Size );
+      if (Flags & HEAP_GENERATE_EXCEPTIONS)
          RtlRaiseStatus( STATUS_NO_MEMORY );
       return NULL;
    }
 
    /* Check if we need to grow the block */
 
-   pArena = (ARENA_INUSE *)ptr - 1;
-   pArena->threadId = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
+   pArena = (ARENA_INUSE *)Ptr - 1;
+   pArena->threadId = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
 
    subheap = HEAP_FindSubHeap( heapPtr, pArena );
    oldSize = (pArena->size & ARENA_SIZE_MASK);
-   if (size > oldSize)
+   if (Size > oldSize)
    {
       char *pNext = (char *)(pArena + 1) + oldSize;
       if ((pNext < (char *)subheap + subheap->size) &&
-            (*(DWORD *)pNext & ARENA_FLAG_FREE) &&
-            (oldSize + (*(DWORD *)pNext & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) >= size))
+            (*(PULONG)pNext & ARENA_FLAG_FREE) &&
+            (oldSize + (*(PULONG)pNext & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) >= Size))
       {
          /* The next block is free and large enough */
          ARENA_FREE *pFree = (ARENA_FREE *)pNext;
@@ -1342,16 +1342,16 @@
          pFree->prev->next = pFree->next;
          pArena->size += (pFree->size & ARENA_SIZE_MASK) + sizeof(*pFree);
          if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE)
-                           + size + HEAP_MIN_BLOCK_SIZE,
+                           + Size + HEAP_MIN_BLOCK_SIZE,
                            heapPtr->flags))
          {
-            if (!(flags & HEAP_NO_SERIALIZE))
+            if (!(Flags & HEAP_NO_SERIALIZE))
                RtlLeaveCriticalSection( &heapPtr->critSection );
-            if (flags & HEAP_GENERATE_EXCEPTIONS)
+            if (Flags & HEAP_GENERATE_EXCEPTIONS)
                RtlRaiseStatus( STATUS_NO_MEMORY );
             return NULL;
          }
-         HEAP_ShrinkBlock( subheap, pArena, size );
+         HEAP_ShrinkBlock( subheap, pArena, Size );
       }
       else  /* Do it the hard way */
       {
@@ -1359,12 +1359,12 @@
          ARENA_INUSE *pInUse;
          SUBHEAP *newsubheap;
 
-         if ((flags & HEAP_REALLOC_IN_PLACE_ONLY) ||
-               !(pNew = HEAP_FindFreeBlock( heapPtr, size, &newsubheap )))
+         if ((Flags & HEAP_REALLOC_IN_PLACE_ONLY) ||
+               !(pNew = HEAP_FindFreeBlock( heapPtr, Size, &newsubheap )))
          {
-            if (!(flags & HEAP_NO_SERIALIZE))
+            if (!(Flags & HEAP_NO_SERIALIZE))
                RtlLeaveCriticalSection( &heapPtr->critSection );
-            if (flags & HEAP_GENERATE_EXCEPTIONS)
+            if (Flags & HEAP_GENERATE_EXCEPTIONS)
                RtlRaiseStatus( STATUS_NO_MEMORY );
             return NULL;
          }
@@ -1376,26 +1376,26 @@
          pInUse = (ARENA_INUSE *)pNew;
          pInUse->size     = (pInUse->size & ~ARENA_FLAG_FREE)
                             + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
-         pInUse->threadId = (DWORD)NtCurrentTeb()->Cid.UniqueThread;
+         pInUse->threadId = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
[truncated at 1000 lines; 332 more skipped]

reactos/lib/rtl
image.c 1.1 -> 1.1.14.1
diff -u -r1.1 -r1.1.14.1
--- image.c	20 Jun 2004 23:27:21 -0000	1.1
+++ image.c	8 Dec 2004 21:57:21 -0000	1.1.14.1
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.1 2004/06/20 23:27:21 gdalsnes Exp $
+/* $Id: image.c,v 1.1.14.1 2004/12/08 21:57:21 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -24,22 +24,39 @@
 RtlImageNtHeader (IN PVOID BaseAddress)
 {
   PIMAGE_NT_HEADERS NtHeader;
-  PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
+  char * Magic = BaseAddress;
 
-  if (DosHeader && DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
+  /* HACK: PE executable */
+  if (Magic[0] == 'M' && Magic[1] == 'Z')
     {
-      DPRINT1("DosHeader->e_magic %x\n", DosHeader->e_magic);
-      DPRINT1("NtHeader %x\n", (BaseAddress + DosHeader->e_lfanew));
-    }
+      PIMAGE_DOS_HEADER DosHeader = BaseAddress;
+      DPRINT("DosHeader %x\n", DosHeader);
+
+      if (DosHeader->e_lfanew == 0L ||
+          *(PULONG)((PUCHAR)BaseAddress + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
+        {
+          DPRINT("Image has bad header\n");
+          return NULL;
+        }
 
-  if (DosHeader && DosHeader->e_magic == IMAGE_DOS_SIGNATURE)
+      NtHeader = (PIMAGE_NT_HEADERS)((PUCHAR)BaseAddress + DosHeader->e_lfanew);
+    }
+  /* HACK: ReactOS ELF executable */
+  else if (Magic[0] == 0x7f &&
+           Magic[1] == 'E' &&
+           Magic[2] == 'L' &&
+           Magic[3] == 'F')
+    {
+      DbgPrint("TODO: ElfGetSymbolAddress()\n");
+      /*NtHeader = ElfGetSymbolAddress(BaseAddress, "nt_header");*/
+    }
+  else
     {
-      NtHeader = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
-      if (NtHeader->Signature == IMAGE_NT_SIGNATURE)
-	return NtHeader;
+      DPRINT("Unknown image format\n");
+      NtHeader = NULL;
     }
 
-  return NULL;
+  return NtHeader;
 }
 
 

reactos/lib/rtl
mem.c 1.2 -> 1.2.8.1
diff -u -r1.2 -r1.2.8.1
--- mem.c	5 Aug 2004 18:17:36 -0000	1.2
+++ mem.c	8 Dec 2004 21:57:21 -0000	1.2.8.1
@@ -1,5 +1,5 @@
 
-/* $Id: mem.c,v 1.2 2004/08/05 18:17:36 ion Exp $
+/* $Id: mem.c,v 1.2.8.1 2004/12/08 21:57:21 hyperion Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -39,14 +39,13 @@
  *
  * @implemented
  */
-ULONG
-STDCALL
-RtlCompareMemory(PVOID Source1,
-                 PVOID Source2,
-                 ULONG Length)
+ULONG STDCALL
+RtlCompareMemory(IN const VOID *Source1,
+                 IN const VOID *Source2,
+                 IN SIZE_T Length)
 {
    SIZE_T i;
-   for(i=0; (i<Length) && (((LPBYTE)Source1)[i]==((LPBYTE)Source2)[i]); i++)
+   for(i=0; (i<Length) && (((PUCHAR)Source1)[i]==((PUCHAR)Source2)[i]); i++)
       ;
    return i;
 }

reactos/lib/rtl
nls.c 1.1 -> 1.1.18.1
diff -u -r1.1 -r1.1.18.1
--- nls.c	31 May 2004 19:29:02 -0000	1.1
+++ nls.c	8 Dec 2004 21:57:21 -0000	1.1.18.1
@@ -1,4 +1,4 @@
-/* $Id: nls.c,v 1.1 2004/05/31 19:29:02 gdalsnes Exp $
+/* $Id: nls.c,v 1.1.18.1 2004/12/08 21:57:21 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -86,7 +86,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return(STATUS_SUCCESS);
@@ -267,7 +267,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return(STATUS_SUCCESS);
@@ -346,7 +346,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -423,7 +423,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -466,7 +466,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -548,7 +548,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -623,7 +623,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -667,7 +667,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;
@@ -711,7 +711,7 @@
    {
       /* multi-byte code page */
       /* FIXME */
-      assert(FALSE);
+      ASSERT(FALSE);
    }
 
    return STATUS_SUCCESS;

reactos/lib/rtl
unicode.c 1.9 -> 1.9.6.1
diff -u -r1.9 -r1.9.6.1
--- unicode.c	13 Sep 2004 17:27:23 -0000	1.9
+++ unicode.c	8 Dec 2004 21:57:21 -0000	1.9.6.1
@@ -499,6 +499,35 @@
 
 /*
  * @implemented
+ */
+NTSTATUS STDCALL
+RtlInitUnicodeStringEx(OUT PUNICODE_STRING DestinationString,
+                       IN PCWSTR SourceString)
+{
+   ULONG Length;
+
+   if (SourceString != NULL)
+   {
+      Length = wcslen(SourceString) * sizeof(WCHAR);
+      if (Length > 0xFFFC)
+         return STATUS_NAME_TOO_LONG;
+
+      DestinationString->Length = Length;
+      DestinationString->MaximumLength = Length + sizeof(WCHAR);
+      DestinationString->Buffer = (PWSTR)SourceString;
+   }
+   else
+   {
+      DestinationString->Length = 0;
+      DestinationString->MaximumLength = 0;
+      DestinationString->Buffer = NULL;
+   }
+
+   return STATUS_SUCCESS;
+}
+
+/*
+ * @implemented
  *
  * NOTES
  *  Writes at most length characters to the string str.

reactos/lib/setupapi
Makefile.ros-template 1.4 -> 1.4.16.1
diff -u -r1.4 -r1.4.16.1
--- Makefile.ros-template	29 May 2004 21:24:46 -0000	1.4
+++ Makefile.ros-template	8 Dec 2004 21:57:21 -0000	1.4.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.4 2004/05/29 21:24:46 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.4.16.1 2004/12/08 21:57:21 hyperion Exp $
 
 TARGET_NAME = setupapi
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ -D__WINESRC__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a libwine_unicode.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a ntdll.a wine_unicode.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_SETUPAPI)
 

reactos/lib/shell32
Makefile.ros-template 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- Makefile.ros-template	30 Oct 2004 21:28:19 -0000	1.6
+++ Makefile.ros-template	8 Dec 2004 21:57:21 -0000	1.6.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.6 2004/10/30 21:28:19 mf Exp $
+# $Id: Makefile.ros-template,v 1.6.2.1 2004/12/08 21:57:21 hyperion Exp $
 
 TARGET_NAME = shell32
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = libwine.a @IMPORTS@ ole32.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = wine.a @IMPORTS@ ole32.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_SHELL32)
 

reactos/lib/shell32
changenotify.c 1.4 -> 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- changenotify.c	22 Sep 2004 19:38:54 -0000	1.4
+++ changenotify.c	8 Dec 2004 21:57:21 -0000	1.4.6.1
@@ -263,7 +263,7 @@
     return -1;
 }
 
-static BOOL should_notify( LPITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub )
+static BOOL should_notify( LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub )
 {
     TRACE("%p %p %d\n", changed, watched, sub );
     if ( !watched )
@@ -280,7 +280,7 @@
  */
 void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
 {
-    LPITEMIDLIST Pidls[2];
+    LPCITEMIDLIST Pidls[2];
     LPNOTIFICATIONLIST ptr;
     UINT typeFlag = uFlags & SHCNF_TYPE;
 
@@ -326,8 +326,8 @@
         if (dwItem2) Pidls[1] = SHSimpleIDListFromPathW((LPCWSTR)dwItem2);
         break;
     case SHCNF_IDLIST:
-        Pidls[0] = (LPITEMIDLIST)dwItem1;
-        Pidls[1] = (LPITEMIDLIST)dwItem2;
+        Pidls[0] = (LPCITEMIDLIST)dwItem1;
+        Pidls[1] = (LPCITEMIDLIST)dwItem2;
         break;
     case SHCNF_PRINTERA:
     case SHCNF_PRINTERW:
@@ -404,8 +404,8 @@
     /* if we allocated it, free it. The ANSI flag is also set in its Unicode sibling. */
     if ((typeFlag & SHCNF_PATHA) || (typeFlag & SHCNF_PRINTERA))
     {
-        if (Pidls[0]) SHFree(Pidls[0]);
-        if (Pidls[1]) SHFree(Pidls[1]);
+        if (Pidls[0]) SHFree((LPITEMIDLIST)Pidls[0]);
+        if (Pidls[1]) SHFree((LPITEMIDLIST)Pidls[1]);
     }
 }
 
@@ -440,7 +440,7 @@
 {
     DWORD i;
     LPNOTIFICATIONLIST node;
-    LPITEMIDLIST *idlist;
+    LPCITEMIDLIST *idlist;
 
     TRACE("%p %08lx %p %p\n", hChange, dwProcessId, lppidls, lpwEventId);
 
@@ -451,9 +451,9 @@
     {
         idlist = SHAlloc( sizeof(LPCITEMIDLIST *) * node->cidl );
         for(i=0; i<node->cidl; i++)
-            idlist[i] = (LPITEMIDLIST)node->pidlSignaled;
+            idlist[i] = (LPCITEMIDLIST)node->pidlSignaled;
         *lpwEventId = node->wSignalledEvent;
-        *lppidls = idlist;
+        *lppidls = (LPITEMIDLIST*)idlist;
         node->wSignalledEvent = 0;
     }
     else

reactos/lib/shell32
debughlp.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- debughlp.c	21 Sep 2004 19:38:17 -0000	1.5
+++ debughlp.c	8 Dec 2004 21:57:21 -0000	1.5.6.1
@@ -76,6 +76,7 @@
 	  {
 	    case PT_GUID:
 	    case PT_SHELLEXT:
+	    case PT_YAGUID:
 	      return NULL;
 
 	    case PT_DRIVE:
@@ -88,7 +89,6 @@
 	    case PT_FOLDER1:
 	    case PT_VALUE:
 	    case PT_IESPECIAL1:
-	    case PT_RAS_FOLDER:
 	    case PT_IESPECIAL2:
 	      return (LPSTR)&(pdata->u.file.szNames);
 
@@ -115,7 +115,6 @@
 	    case PT_FOLDER:
 	    case PT_VALUE:
 	    case PT_IESPECIAL1:
-	    case PT_RAS_FOLDER:
 	    case PT_IESPECIAL2:
 	      return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1);
 
@@ -250,7 +249,7 @@
 	      case PT_NETPROVIDER:
 	      case PT_NETWORK:
 	      case PT_IESPECIAL1:
-	      case PT_RAS_FOLDER:
+	      case PT_YAGUID:
 	      case PT_IESPECIAL2:
 	      case PT_SHARE:
 		break;
@@ -263,7 +262,7 @@
 		memset(szTemp, ' ', BYTES_PRINTED*4 + 1);
 		for ( i = 0; (i<pidltemp->mkid.cb) && (i<BYTES_PRINTED); i++)
 		{
-		  c = ((unsigned char *)pidltemp)[i];
+		  c = ((const unsigned char *)pidltemp)[i];
 
 		  szTemp[i*3+0] = ((c>>4)>9)? (c>>4)+55 : (c>>4)+48;
 		  szTemp[i*3+1] = ((0x0F&c)>9)? (0x0F&c)+55 : (0x0F&c)+48;

reactos/lib/shell32
iconcache.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- iconcache.c	7 Oct 2004 09:13:56 -0000	1.9
+++ iconcache.c	8 Dec 2004 21:57:21 -0000	1.9.2.1
@@ -313,7 +313,6 @@
 
 	return TRUE;
 }
-
 /*************************************************************************
  * PidlToSicIndex			[INTERNAL]
  *
@@ -354,6 +353,7 @@
 	  *pIndex = 0;
 
 	return ret;
+
 }
 
 /*************************************************************************

reactos/lib/shell32
memorystream.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- memorystream.c	7 Oct 2004 09:13:56 -0000	1.5
+++ memorystream.c	8 Dec 2004 21:57:21 -0000	1.5.2.1
@@ -42,42 +42,11 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(shell);
 
-static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj);
-static ULONG WINAPI IStream_fnAddRef(IStream *iface);
-static ULONG WINAPI IStream_fnRelease(IStream *iface);
-static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead);
-static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten);
-static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
-static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize);
-static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
-static HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags);
-static HRESULT WINAPI IStream_fnRevert (IStream * iface);
-static HRESULT WINAPI IStream_fnLockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
-static HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
-static HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG*   pstatstg, DWORD grfStatFlag);
-static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm);
-
-static IStreamVtbl stvt =
-{
-	IStream_fnQueryInterface,
-	IStream_fnAddRef,
-	IStream_fnRelease,
-	IStream_fnRead,
-	IStream_fnWrite,
-	IStream_fnSeek,
-	IStream_fnSetSize,
-	IStream_fnCopyTo,
-	IStream_fnCommit,
-	IStream_fnRevert,
-	IStream_fnLockRegion,
-	IStream_fnUnlockRegion,
-	IStream_fnStat,
-	IStream_fnClone
-
-};
+static const IStreamVtbl stvt;
 
 typedef struct
-{	IStreamVtbl	*lpvtst;
+{	
+	const IStreamVtbl	*lpvtst;
 	DWORD		ref;
 	HANDLE		handle;
 } ISHFileStream;
@@ -110,12 +79,12 @@
 
        handle = CreateFileW( pszFilename, access, FILE_SHARE_READ, NULL, creat, 0, NULL );
 	if( handle == INVALID_HANDLE_VALUE )
-		return E_FAIL;
+		return HRESULT_FROM_WIN32(GetLastError());
 
 	fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),
 		HEAP_ZERO_MEMORY,sizeof(ISHFileStream));
 	if( !fstr )
-		return E_FAIL;
+		return E_OUTOFMEMORY;
 	fstr->lpvtst=&stvt;
 	fstr->ref = 1;
 	fstr->handle = handle;
@@ -192,7 +161,7 @@
 		return STG_E_INVALIDPOINTER;
 
 	if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
-		return E_FAIL;
+		return S_FALSE;
 
 	return S_OK;
 }
@@ -306,3 +275,22 @@
 
 	return E_NOTIMPL;
 }
+
+static const IStreamVtbl stvt =
+{
+	IStream_fnQueryInterface,
+	IStream_fnAddRef,
+	IStream_fnRelease,
+	IStream_fnRead,
+	IStream_fnWrite,
+	IStream_fnSeek,
+	IStream_fnSetSize,
+	IStream_fnCopyTo,
+	IStream_fnCommit,
+	IStream_fnRevert,
+	IStream_fnLockRegion,
+	IStream_fnUnlockRegion,
+	IStream_fnStat,
+	IStream_fnClone
+
+};

reactos/lib/shell32
pidl.c 1.26 -> 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- pidl.c	7 Oct 2004 09:13:56 -0000	1.26
+++ pidl.c	8 Dec 2004 21:57:21 -0000	1.26.2.1
@@ -129,7 +129,7 @@
 	      flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR;
 	      break;
 	  }
-	  if (!*(LPWORD)pidl || type == ILGDN_FORPARSING)
+	  if (!*(const WORD*)pidl || type == ILGDN_FORPARSING)
 	  {
 	    ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret);
 	    if (SUCCEEDED(ret))
@@ -779,7 +779,7 @@
 	if (pidl)
 	{ while (si->cb)
 	  { len += si->cb;
-	    si  = (LPSHITEMID)(((LPBYTE)si)+si->cb);
+	    si  = (LPCSHITEMID)(((const BYTE*)si)+si->cb);
 	  }
 	  len += 2;
 	}
@@ -814,7 +814,7 @@
 	  len =  pidl->mkid.cb;
 	  if (len)
 	  {
-	    pidl = (LPITEMIDLIST) (((LPBYTE)pidl)+len);
+	    pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len);
 	    TRACE("-- %p\n", pidl);
 	    return (LPITEMIDLIST)pidl;
 	  }
@@ -1493,7 +1493,7 @@
     TRACE("()\n");
     if (parent)
     {
-        LPITEMIDLIST cpl = _ILCreateGuid(PT_GUID, &CLSID_ControlPanel);
+        LPITEMIDLIST cpl = _ILCreateGuid(PT_SHELLEXT, &CLSID_ControlPanel);
 
         if (cpl)
         {
@@ -1512,7 +1512,7 @@
     TRACE("()\n");
     if (parent)
     {
-        LPITEMIDLIST printers = _ILCreateGuid(PT_GUID, &CLSID_Printers);
+        LPITEMIDLIST printers = _ILCreateGuid(PT_YAGUID, &CLSID_Printers);
 
         if (printers)
         {
@@ -1538,7 +1538,7 @@
 {
     LPITEMIDLIST pidlOut;
 
-    if (type == PT_SHELLEXT || type == PT_GUID)
+    if (type == PT_SHELLEXT || type == PT_GUID || type == PT_YAGUID)
     {
         pidlOut = _ILAlloc(type, sizeof(GUIDStruct));
         if (pidlOut)
@@ -1757,7 +1757,7 @@
 	if(! _ILIsDesktop(pidl))	/* pidl=NULL or mkid.cb=0 */
 	{
 	  WORD len = pidl->mkid.cb;
-	  LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((LPBYTE)pidl) + len );
+	  LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len );
 	  if (pidlnext->mkid.cb)
 	    ret = FALSE;
 	}
@@ -1883,6 +1883,7 @@
 	  {
 	    case PT_GUID:
 	    case PT_SHELLEXT:
+	    case PT_YAGUID:
 	      return NULL;
 
 	    case PT_DRIVE:
@@ -1895,7 +1896,6 @@
 	    case PT_FOLDER1:
 	    case PT_VALUE:
 	    case PT_IESPECIAL1:
-	    case PT_RAS_FOLDER:
 	    case PT_IESPECIAL2:
 	      return (LPSTR)&(pdata->u.file.szNames);
 
@@ -1926,7 +1926,6 @@
 	    case PT_FOLDER:
 	    case PT_VALUE:
 	    case PT_IESPECIAL1:
-	    case PT_RAS_FOLDER:
 	    case PT_IESPECIAL2:
 	      return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1);
 

reactos/lib/shell32
pidl.h 1.10 -> 1.10.6.1
diff -u -r1.10 -r1.10.6.1
--- pidl.h	21 Sep 2004 19:38:17 -0000	1.10
+++ pidl.h	8 Dec 2004 21:57:22 -0000	1.10.6.1
@@ -71,6 +71,7 @@
 *	net provider	0x46		network
 *	whole network	0x47		network (5)
 *	MSITStore	0x61		htmlhlp (7)
+*	printers/ras connections 	0x70		guid
 *	history/favorites 0xb1		file
 *	share		0xc3		network (6)
 *
@@ -101,7 +102,7 @@
 #define PT_NETPROVIDER  0x46
 #define PT_NETWORK	0x47
 #define PT_IESPECIAL1	0x61
-#define PT_RAS_FOLDER	0x70
+#define PT_YAGUID	0x70 /* yet another guid.. */
 #define PT_IESPECIAL2	0xb1
 #define PT_SHARE	0xc3
 
@@ -200,8 +201,8 @@
  */
 LPITEMIDLIST	_ILAlloc(PIDLTYPE type, size_t size);
 
-/* Creates a PIDL with guid format and type type, which must be either PT_GUID
- * or PT_SHELLEXT.
+/* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
+ * PT_SHELLEXT, or PT_YAGUID.
  */
 LPITEMIDLIST	_ILCreateGuid(PIDLTYPE type, REFIID guid);
 

reactos/lib/shell32
regsvr.c 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- regsvr.c	20 Sep 2004 19:47:13 -0000	1.3
+++ regsvr.c	8 Dec 2004 21:57:22 -0000	1.3.6.1
@@ -29,6 +29,7 @@
 
 #include "ole2.h"
 #include "shlguid.h"
+#include "shell32_main.h"
 
 #include "wine/debug.h"
 
@@ -518,6 +519,8 @@
     hr = register_coclasses(coclass_list);
     if (SUCCEEDED(hr))
 	hr = register_interfaces(interface_list);
+    if (SUCCEEDED(hr))
+	hr = SHELL_RegisterShellFolders();
     return hr;
 }
 

reactos/lib/shell32
shell32.spec 1.13 -> 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- shell32.spec	20 Oct 2004 18:30:39 -0000	1.13
+++ shell32.spec	8 Dec 2004 21:57:22 -0000	1.13.2.1
@@ -162,7 +162,7 @@
  168 stdcall SHCreatePropSheetExtArray(long str long)
  169 stdcall SHDestroyPropSheetExtArray(long)
  170 stdcall SHReplaceFromPropSheetExtArray(long long long long)
- 171 stdcall PathCleanupSpec(ptr ptr) PathCleanupSpecAW
+ 171 stdcall PathCleanupSpec(ptr ptr)
  172 stdcall SHCreateLinks(long str ptr long ptr)
  173 stdcall SHValidateUNC(long long long)
  174 stdcall SHCreateShellFolderViewEx (ptr ptr)

reactos/lib/shell32
shell32_En.rc 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- shell32_En.rc	2 Nov 2004 23:11:37 -0000	1.7
+++ shell32_En.rc	8 Dec 2004 21:57:22 -0000	1.7.2.1
@@ -187,3 +187,35 @@
 	IDS_SHUTDOWN_TITLE	"Shutdown"
 	IDS_SHUTDOWN_PROMPT	"Do you want to shutdown?"
 }
+
+/* shell folder path default values */
+STRINGTABLE DISCARDABLE
+{
+	IDS_PROGRAMS                "Start Menu\\Programs"
+	IDS_PERSONAL                "My Documents"
+	IDS_FAVORITES               "Favorites"
+	IDS_STARTUP                 "Start Menu\\Programs\\StartUp"
+	IDS_RECENT                  "Recent"
+	IDS_SENDTO                  "SendTo"
+	IDS_STARTMENU               "Start Menu"
+	IDS_MYMUSIC                 "My Documents\\My Music"
+	IDS_MYVIDEO                 "My Documents\\My Video"
+	IDS_DESKTOPDIRECTORY        "Desktop"
+	IDS_NETHOOD                 "NetHood"
+	IDS_TEMPLATES               "Templates"
+	IDS_APPDATA                 "Application Data"
+	IDS_PRINTHOOD               "PrintHood"
+	IDS_LOCAL_APPDATA           "Local Settings\\Application Data"
+	IDS_INTERNET_CACHE          "Temporary Internet Files"
+	IDS_COOKIES                 "Cookies"
+	IDS_HISTORY                 "History"
+	IDS_PROGRAM_FILES           "Program Files"
+	IDS_MYPICTURES              "My Documents\\My Pictures"
+	IDS_PROGRAM_FILES_COMMON    "Program Files\\Common Files"
+	IDS_COMMON_DOCUMENTS        "Documents"
+	IDS_ADMINTOOLS              "Start Menu\\Programs\\Administrative Tools"
+	IDS_COMMON_MUSIC            "Documents\\My Music"
+	IDS_COMMON_PICTURES         "Documents\\My Pictures"
+	IDS_COMMON_VIDEO            "Documents\\My Video"
+	IDS_CDBURN_AREA             "Local Settings\\Application Data\\Microsoft\\CD Burning"
+}

reactos/lib/shell32
shell32_Fr.rc 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- shell32_Fr.rc	2 Nov 2004 23:11:37 -0000	1.7
+++ shell32_Fr.rc	8 Dec 2004 21:57:22 -0000	1.7.2.1
@@ -190,3 +190,35 @@
        IDS_SHUTDOWN_TITLE      "Arr�ter"
        IDS_SHUTDOWN_PROMPT     "Voulez-vous fermer la session ReactOS?"
 }
+
+/* shell folder path default values */
+STRINGTABLE DISCARDABLE
+{
+ IDS_PROGRAMS                "Menu D�marrer\\Programmes"
+ IDS_PERSONAL                "Mes documents"
+ IDS_FAVORITES               "Favoris"
+ IDS_STARTUP                 "Menu D�marrer\\Programmes\\D�marrage"
+ IDS_RECENT                  "Recent"
+ IDS_SENDTO                  "SendTo"
+ IDS_STARTMENU               "Menu D�marrer"
+ IDS_MYMUSIC                 "Mes documents\\Ma musique"
+ IDS_MYVIDEO                 "Mes documents\\Mes vid�os"
+ IDS_DESKTOPDIRECTORY        "Bureau"
+ IDS_NETHOOD                 "Voisinage R�seau"
+ IDS_TEMPLATES               "Mod�les"
+ IDS_APPDATA                 "Application Data"
+ IDS_PRINTHOOD               "Voisinage d'impression"
+ IDS_LOCAL_APPDATA           "Local Settings\\Application Data"
+ IDS_INTERNET_CACHE          "Temporary Internet Files"
+ IDS_COOKIES                 "Cookies"
+ IDS_HISTORY                 "Historique"
+ IDS_PROGRAM_FILES           "Program Files"
+ IDS_MYPICTURES              "Mes documents\\Mes images"
+ IDS_PROGRAM_FILES_COMMON    "Program Files\\Fichiers communs"
+ IDS_COMMON_DOCUMENTS        "Documents"
+ IDS_ADMINTOOLS              "Menu D�marrer\\Programmes\\Outils d'administration"
+ IDS_COMMON_MUSIC            "Documents\\Ma musique"
+ IDS_COMMON_PICTURES         "Documents\\Mes images"
+ IDS_COMMON_VIDEO            "Documents\\Mes vid�os"
+ IDS_CDBURN_AREA             "Local Settings\\Application Data\\Microsoft\\CD Burning"
+}

reactos/lib/shell32
shell32_main.h 1.23 -> 1.23.6.1
diff -u -r1.23 -r1.23.6.1
--- shell32_main.h	21 Sep 2004 19:11:35 -0000	1.23
+++ shell32_main.h	8 Dec 2004 21:57:22 -0000	1.23.6.1
@@ -220,4 +220,7 @@
 
 extern WCHAR swShell32Name[MAX_PATH];
 
+/* Default shell folder value registration */
+HRESULT SHELL_RegisterShellFolders(void);
+
 #endif

reactos/lib/shell32
shellord.c 1.10 -> 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- shellord.c	7 Oct 2004 09:13:56 -0000	1.10
+++ shellord.c	8 Dec 2004 21:57:22 -0000	1.10.2.1
@@ -761,7 +761,7 @@
 	SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
     }
     else {
-	lstrcpyA(doc_name, (LPSTR) pv);
+	lstrcpyA(doc_name, (LPCSTR) pv);
     }
     TRACE("full document name %s\n", doc_name);
     PathStripPathA(doc_name);

reactos/lib/shell32
shellpath.c 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- shellpath.c	5 Oct 2004 07:43:19 -0000	1.12
+++ shellpath.c	8 Dec 2004 21:57:22 -0000	1.12.2.1
@@ -2,6 +2,7 @@
  * Path Functions
  *
  * Copyright 1998, 1999, 2000 Juergen Schmied
+ * Copyright 2004 Juan Lang
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -38,6 +39,7 @@
 #include "winuser.h"
 
 #include "shlobj.h"
+#include "shresdef.h"
 #include "shell32_main.h"
 #include "undocshell.h"
 #include "pidl.h"
@@ -556,11 +558,76 @@
 
 /*************************************************************************
  * PathCleanupSpec	[SHELL32.171]
+ *
+ * lpszFile is changed in place.
  */
-DWORD WINAPI PathCleanupSpecAW (LPCVOID x, LPVOID y)
+int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW )
 {
-    FIXME("(%p, %p) stub\n",x,y);
-    return TRUE;
+    int i = 0;
+    DWORD rc = 0;
+    int length = 0;
+
+    if (SHELL_OsIsUnicode())
+    {
+        LPWSTR p = lpszFileW;
+
+        TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
+
+        if (lpszPathW)
+            length = strlenW(lpszPathW);
+
+        while (*p)
+        {
+            int gct = PathGetCharTypeW(*p);
+            if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
+            {
+                lpszFileW[i]='-';
+                rc |= PCS_REPLACEDCHAR;
+            }
+            else
+                lpszFileW[i]=*p;
+            i++;
+            p++;
+            if (length + i == MAX_PATH)
+            {
+                rc |= PCS_FATAL | PCS_PATHTOOLONG;
+                break;
+            }
+        }
+        lpszFileW[i]=0;
+    }
+    else
+    {
+        LPSTR lpszFileA = (LPSTR)lpszFileW;
+        LPCSTR lpszPathA = (LPSTR)lpszPathW;
+        LPSTR p = lpszFileA;
+
+        TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
+
+        if (lpszPathA)
+            length = strlen(lpszPathA);
+
+        while (*p)
+        {
+            int gct = PathGetCharTypeA(*p);
+            if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
+            {
+                lpszFileA[i]='-';
+                rc |= PCS_REPLACEDCHAR;
+            }
+            else
+                lpszFileA[i]=*p;
+            i++;
+            p++;
+            if (length + i == MAX_PATH)
+            {
+                rc |= PCS_FATAL | PCS_PATHTOOLONG;
+                break;
+            }
+        }
+        lpszFileA[i]=0;
+    }
+    return rc;
 }
 
 /*************************************************************************
@@ -689,48 +756,9 @@
             PathSetDlgItemPathA(hDlg, id, pszPath);
 }
 
-/*************************************************************************
- * SHGetFolderPathW			[SHELL32.@]
- *
- * converts csidl to path
- */
-
-static const WCHAR szSHFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
-static const WCHAR szSHUserFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
-static const WCHAR szSetup[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','e','t','u','p','\0'};
 static const WCHAR szCurrentVersion[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'};
-
-
-
 static const WCHAR Administrative_ToolsW[] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
-static const WCHAR All_Users__Application_DataW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                                     'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
-static const WCHAR All_Users__DesktopW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                              'D','e','s','k','t','o','p','\0'};
-static const WCHAR All_Users__DocumentsW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                              'D','o','c','u','m','e','n','t','s','\0'};
-static const WCHAR All_Users__Documents__My_MusicW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                                        'D','o','c','u','m','e','n','t','s','\\',
-                                                        'M','y',' ','M','u','s','i','c','\0'};
-static const WCHAR All_Users__Documents__My_PicturesW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                                           'D','o','c','u','m','e','n','t','s','\\',
-                                                           'M','y',' ','P','i','c','t','u','r','e','s','\0'};
-static const WCHAR All_Users__Documents__My_VideoW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                                        'D','o','c','u','m','e','n','t','s','\\',
-                                                        'M','y',' ','V','i','d','e','o','\0'};
-static const WCHAR All_Users__Start_MenuW[] = {'A','l','l',' ','U','s','e','r','s','\\','S','t','a','r','t',' ','M','e','n','u','\0'};
-static const WCHAR All_Users__Start_Menu__ProgramsW[] = {'A','l','l',' ','U','s','e','r','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
-static const WCHAR All_Users__Start_Menu__Programs__Administrative_ToolsW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\',
-                                'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
-static const WCHAR All_Users__Start_Menu__Programs__StartUpW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                                               'S','t','a','r','t',' ','M','e','n','u','\\',
-                                                               'P','r','o','g','r','a','m','s','\\',
-                                                               'S','t','a','r','t','U','p','\0'};
-static const WCHAR All_Users__TemplatesW[] = {'A','l','l',' ','U','s','e','r','s','\\',
-                                              'T','e','m','p','l','a','t','e','s','\0'};
 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
-static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
 static const WCHAR Common_Administrative_ToolsW[] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
@@ -747,24 +775,10 @@
 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
-static const WCHAR Empty_StringW[] = {'\0'};
 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
-static const WCHAR Local_Settings__Application_DataW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\',
-                                                         'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
-static const WCHAR Local_Settings__Application_Data__Microsoft__CD_BurningW[] = {
-    'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\',
-    'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\',
-    'M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'};
-static const WCHAR My_DocumentsW[] = {'M','y',' ','D','o','c','u','m','e','n','t','s','\0'};
-static const WCHAR My_Documents__My_MusicW[] = {'M','y',' ','D','o','c','u','m','e','n','t','s','\\',
-                                                'M','y',' ','M','u','s','i','c','\0'};
-static const WCHAR My_Documents__My_PicturesW[] = {'M','y',' ','D','o','c','u','m','e','n','t','s','\\',
-                                                  'M','y',' ','P','i','c','t','u','r','e','s','\0'};
-static const WCHAR My_Documents__My_VideoW[] = {'M','y',' ','D','o','c','u','m','e','n','t','s','\\',
-                                               'M','y',' ','V','i','d','e','o','\0'};
 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
@@ -772,596 +786,909 @@
 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
-static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
-static const WCHAR Program_Files__Common_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\',
-                                                     'C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
-static const WCHAR ShellNewW[] = {'S','h','e','l','l','N','e','w','\0'};
-static const WCHAR Start_Menu__ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
-static const WCHAR SysDirW[] = {'S','y','s','D','i','r','\0'};
-static const WCHAR SystemW[] = {'s','y','s','t','e','m','\0'};
 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
-static const WCHAR Start_Menu__Programs__Administrative_ToolsW[] = {
-                                'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\',
-                                'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
-static const WCHAR Start_Menu__Programs__StartUpW[] = {'S','t','a','r','t',' ','M','e','n','u','\\',
-                                                     'P','r','o','g','r','a','m','s','\\',
-                                                     'S','t','a','r','t','U','p','\0'};
 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
-static const WCHAR Temporary_Internet_FilesW[] = {'T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'};
-static const WCHAR WinDirW[] = {'W','i','n','D','i','r','\0'};
-static const WCHAR WindowsW[] = {'w','i','n','d','o','w','s','\0'};
-
-
+static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
+static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
+static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
+static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
+static const WCHAR ProfileListW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
+static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
+static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
+static const WCHAR szSHFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
+static const WCHAR szSHUserFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
+/* This defaults to L"Documents and Settings" on Windows 2000/XP, but we're
+ * acting more Windows 9x-like for now.
+ */
+static const WCHAR szDefaultProfileDirW[] = {'w','i','n','d','o','w','s','\\','p','r','o','f','i','l','e','s','\0'};
+static const WCHAR AllUsersW[] = {'A','l','l',' ','U','s','e','r','s','\0'};
 
+typedef enum _CSIDL_Type {
+    CSIDL_Type_User,
+    CSIDL_Type_AllUsers,
+    CSIDL_Type_CurrVer,
+    CSIDL_Type_Disallowed,
+    CSIDL_Type_NonExistent,
+    CSIDL_Type_WindowsPath,
+    CSIDL_Type_SystemPath,
+} CSIDL_Type;
 
 typedef struct
 {
-    DWORD dwFlags;
-    HKEY hRootKey;
-    LPCWSTR szValueName;
-    LPCWSTR szDefaultPath; /* fallback string; sub dir of windows directory */
+    CSIDL_Type type;
+    LPCWSTR    szValueName;
+    LPCWSTR    szDefaultPath; /* fallback string or resource ID */
 } CSIDL_DATA;
 
-#define CSIDL_MYFLAG_SHFOLDER	1
-#define CSIDL_MYFLAG_SETUP	2
-#define CSIDL_MYFLAG_CURRVER	4
-#define CSIDL_MYFLAG_RELATIVE	8
-
-#define HKLM HKEY_LOCAL_MACHINE
-#define HKCU HKEY_CURRENT_USER
-#define HKEY_DISALLOWED    (HKEY)0
-#define HKEY_UNIMPLEMENTED (HKEY)1
-#define HKEY_WINDOWSPATH   (HKEY)2
-#define HKEY_NONEXISTENT   (HKEY)3
 static const CSIDL_DATA CSIDL_Data[] =
 {
-    { /* CSIDL_DESKTOP */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	DesktopW,
-	DesktopW
-    },
-    { /* CSIDL_INTERNET */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* CSIDL_PROGRAMS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	ProgramsW,
-	Start_Menu__ProgramsW
-    },
-    { /* CSIDL_CONTROLS (.CPL files) */
-	CSIDL_MYFLAG_SETUP | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	SysDirW,
-	SystemW
-    },
-    { /* CSIDL_PRINTERS */
-	CSIDL_MYFLAG_SETUP | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	SysDirW,
-	SystemW
-    },
-    { /* CSIDL_PERSONAL */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	PersonalW,
-	My_DocumentsW
-    },
-    { /* CSIDL_FAVORITES */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	FavoritesW,
-	FavoritesW
-    },
-    { /* CSIDL_STARTUP */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	StartUpW,
-	Start_Menu__Programs__StartUpW
-    },
-    { /* CSIDL_RECENT */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	RecentW,
-	RecentW
-    },
-    { /* CSIDL_SENDTO */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	SendToW,
-	SendToW
-    },
-    { /* CSIDL_BITBUCKET - Recycle Bin */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL,
-    },
-    { /* CSIDL_STARTMENU */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	Start_MenuW,
-	Start_MenuW
-    },
-    { /* CSIDL_MYDOCUMENTS */
-	0,
-        HKEY_UNIMPLEMENTED, /* FIXME */
-	NULL,
-	NULL
-    },
-    { /* CSIDL_MYMUSIC */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	My_MusicW,
-	My_Documents__My_MusicW
-    },
-    { /* CSIDL_MYVIDEO */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	My_VideoW,
-	My_Documents__My_VideoW
-    },
-    { /* unassigned */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL,
-    },
-    { /* CSIDL_DESKTOPDIRECTORY */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	DesktopW,
-	DesktopW
-    },
-    { /* CSIDL_DRIVES */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL,
-    },
-    { /* CSIDL_NETWORK */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL,
-    },
-    { /* CSIDL_NETHOOD */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	NetHoodW,
-	NetHoodW
-    },
-    { /* CSIDL_FONTS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-        FontsW,
-	FontsW
-    },
-    { /* CSIDL_TEMPLATES */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	TemplatesW,
-	ShellNewW
-    },
-    { /* CSIDL_COMMON_STARTMENU */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_Start_MenuW,
-	All_Users__Start_MenuW
-    },
-    { /* CSIDL_COMMON_PROGRAMS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_ProgramsW,
-	All_Users__Start_Menu__ProgramsW
-    },
-    { /* CSIDL_COMMON_STARTUP */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
+    { /* 0x00 - CSIDL_DESKTOP */
+        CSIDL_Type_User,
+        DesktopW,
+        MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY)
+    },
+    { /* 0x01 - CSIDL_INTERNET */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x02 - CSIDL_PROGRAMS */
+        CSIDL_Type_User,
+        ProgramsW,
+        MAKEINTRESOURCEW(IDS_PROGRAMS)
+    },
+    { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
+        CSIDL_Type_SystemPath,
+        NULL,
+        NULL
+    },
+    { /* 0x04 - CSIDL_PRINTERS */
+        CSIDL_Type_SystemPath,
+        NULL,
+        NULL
+    },
+    { /* 0x05 - CSIDL_PERSONAL */
+        CSIDL_Type_User,
+        PersonalW,
+        MAKEINTRESOURCEW(IDS_PERSONAL)
+    },
+    { /* 0x06 - CSIDL_FAVORITES */
+        CSIDL_Type_User,
+        FavoritesW,
+        MAKEINTRESOURCEW(IDS_FAVORITES)
+    },
+    { /* 0x07 - CSIDL_STARTUP */
+        CSIDL_Type_User,
+        StartUpW,
+        MAKEINTRESOURCEW(IDS_STARTUP)
+    },
+    { /* 0x08 - CSIDL_RECENT */
+        CSIDL_Type_User,
+        RecentW,
+        MAKEINTRESOURCEW(IDS_RECENT)
+    },
+    { /* 0x09 - CSIDL_SENDTO */
+        CSIDL_Type_User,
+        SendToW,
+        MAKEINTRESOURCEW(IDS_SENDTO)
+    },
+    { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL,
+    },
+    { /* 0x0b - CSIDL_STARTMENU */
+        CSIDL_Type_User,
+        Start_MenuW,
+        MAKEINTRESOURCEW(IDS_STARTMENU)
+    },
+    { /* 0x0c - CSIDL_MYDOCUMENTS */
+        CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
+        NULL,
+        NULL
+    },
+    { /* 0x0d - CSIDL_MYMUSIC */
+        CSIDL_Type_User,
+        My_MusicW,
+        MAKEINTRESOURCEW(IDS_MYMUSIC)
+    },
+    { /* 0x0e - CSIDL_MYVIDEO */
+        CSIDL_Type_User,
+        My_VideoW,
+        MAKEINTRESOURCEW(IDS_MYVIDEO)
+    },
+    { /* 0x0f - unassigned */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL,
+    },
+    { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
+        CSIDL_Type_User,
+        DesktopW,
+        MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY)
+    },
+    { /* 0x11 - CSIDL_DRIVES */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL,
+    },
+    { /* 0x12 - CSIDL_NETWORK */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL,
+    },
+    { /* 0x13 - CSIDL_NETHOOD */
+        CSIDL_Type_User,
+        NetHoodW,
+        MAKEINTRESOURCEW(IDS_NETHOOD)
+    },
+    { /* 0x14 - CSIDL_FONTS */
+        CSIDL_Type_WindowsPath,
+        NULL,
+        FontsW
+    },
+    { /* 0x15 - CSIDL_TEMPLATES */
+        CSIDL_Type_User,
+        TemplatesW,
+        MAKEINTRESOURCEW(IDS_TEMPLATES)
+    },
+    { /* 0x16 - CSIDL_COMMON_STARTMENU */
+        CSIDL_Type_AllUsers,
+        Common_Start_MenuW,
+        MAKEINTRESOURCEW(IDS_STARTMENU)
+    },
+    { /* 0x17 - CSIDL_COMMON_PROGRAMS */
+        CSIDL_Type_AllUsers,
+        Common_ProgramsW,
+        MAKEINTRESOURCEW(IDS_PROGRAMS)
+    },
+    { /* 0x18 - CSIDL_COMMON_STARTUP */
+        CSIDL_Type_AllUsers,
         Common_StartUpW,
-	All_Users__Start_Menu__Programs__StartUpW
+        MAKEINTRESOURCEW(IDS_STARTUP)
     },
-    { /* CSIDL_COMMON_DESKTOPDIRECTORY */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_DesktopW,
-	All_Users__DesktopW
-    },
-    { /* CSIDL_APPDATA */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	AppDataW,
-	Application_DataW
-    },
-    { /* CSIDL_PRINTHOOD */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	PrintHoodW,
-	PrintHoodW
-    },
-    { /* CSIDL_LOCAL_APPDATA (win2k only/undocumented) */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	Local_AppDataW,
-	Local_Settings__Application_DataW,
-    },
-    { /* CSIDL_ALTSTARTUP */
-	0,
-        HKEY_NONEXISTENT,
-	NULL,
-	NULL
-    },
-    { /* CSIDL_COMMON_ALTSTARTUP */
-	0,
-        HKEY_NONEXISTENT,
-	NULL,
-	NULL
-    },
-    { /* CSIDL_COMMON_FAVORITES */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	FavoritesW,
-	FavoritesW
-    },
-    { /* CSIDL_INTERNET_CACHE (32) */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	CacheW,
-	Temporary_Internet_FilesW
-    },
-    { /* CSIDL_COOKIES (33) */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	CookiesW,
-	CookiesW
-    },
-    { /* CSIDL_HISTORY (34) */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	HistoryW,
-	HistoryW
-    },
-    { /* CSIDL_COMMON_APPDATA */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_AppDataW,
-	All_Users__Application_DataW
-    },
-    { /* CSIDL_WINDOWS */
-	CSIDL_MYFLAG_SETUP,
-        HKLM,
-	WinDirW,
-	WindowsW
-    },
-    { /* CSIDL_SYSTEM */
-	CSIDL_MYFLAG_SETUP | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	SysDirW,
-	SystemW
-    },
-    { /* CSIDL_PROGRAM_FILES */
-	CSIDL_MYFLAG_CURRVER,
-        HKLM,
-	ProgramFilesDirW,
-	Program_FilesW
-    },
-    { /* CSIDL_MYPICTURES */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	My_PicturesW,
-	My_Documents__My_PicturesW
-    },
-    { /* CSIDL_PROFILE */
-	CSIDL_MYFLAG_SETUP | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	WinDirW, /* correct ? */
-	Empty_StringW
-    },
-    { /* CSIDL_SYSTEMX86 */
-	CSIDL_MYFLAG_SETUP | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
- 	SysDirW,
-	SystemW
-    },
-    { /* CSIDL_PROGRAM_FILESX86 */
-	CSIDL_MYFLAG_CURRVER,
-        HKLM,
-	ProgramFilesDirW,
-	Program_FilesW
-    },
-    { /* CSIDL_PROGRAM_FILES_COMMON */
-	CSIDL_MYFLAG_CURRVER,
-        HKLM,
-	CommonFilesDirW,
-	Program_Files__Common_FilesW /* ? */
-    },
-    { /* CSIDL_PROGRAM_FILES_COMMONX86 */
-	CSIDL_MYFLAG_CURRVER,
-        HKLM,
-	CommonFilesDirW,
-	Program_Files__Common_FilesW /* ? */
-    },
-    { /* CSIDL_COMMON_TEMPLATES */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_TemplatesW,
-	/*"Documents and Settings\\"*/ All_Users__TemplatesW
-    },
-    { /* CSIDL_COMMON_DOCUMENTS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_DocumentsW,
-	/*"Documents and Settings\\"*/ All_Users__DocumentsW
-    },
-    { /* CSIDL_COMMON_ADMINTOOLS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	Common_Administrative_ToolsW,
-	/*"Documents and Settings\\"*/ All_Users__Start_Menu__Programs__Administrative_ToolsW
-    },
-    { /* CSIDL_ADMINTOOLS */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKCU,
-	Administrative_ToolsW,
-	Start_Menu__Programs__Administrative_ToolsW
-    },
-    { /* CSIDL_CONNECTIONS */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* unassigned 32 */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* unassigned 33 */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* unassigned 34 */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* CSIDL_COMMON_MUSIC */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	CommonMusicW,
-	/*"Documents and Settings\\"*/ All_Users__Documents__My_MusicW
-    },
-    { /* CSIDL_COMMON_PICTURES */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	CommonPicturesW,
-	/*"Documents and Settings\\"*/ All_Users__Documents__My_PicturesW
-    },
-    { /* CSIDL_COMMON_VIDEO */
-	CSIDL_MYFLAG_SHFOLDER | CSIDL_MYFLAG_RELATIVE,
-        HKLM,
-	CommonVideoW,
-	/*"Documents and Settings\\"*/ All_Users__Documents__My_VideoW
-    },
-    { /* CSIDL_RESOURCES */
-	0,
-        HKEY_WINDOWSPATH,
-	NULL,
-	ResourcesW
-    },
-    { /* CSIDL_RESOURCES_LOCALIZED */
-	0,
-        HKEY_DISALLOWED, /* FIXME */
-	NULL,
-	NULL
-    },
-    { /* CSIDL_COMMON_OEM_LINKS */
-	0,
-        HKEY_DISALLOWED, /* FIXME */
-	NULL,
-	NULL
-    },
-    { /* CSIDL_CDBURN_AREA */
-	CSIDL_MYFLAG_SHFOLDER,
-        HKCU,
-	CD_BurningW,
-	Local_Settings__Application_Data__Microsoft__CD_BurningW
-    },
-    { /* unassigned 3C */
-	0,
-        HKEY_DISALLOWED,
-	NULL,
-	NULL
-    },
-    { /* CSIDL_COMPUTERSNEARME */
-	0,
-        HKEY_DISALLOWED, /* FIXME */
-	NULL,
-	NULL
-    },
-    { /* CSIDL_PROFILES */
-	0,
-        HKEY_DISALLOWED, /* FIXME */
-	NULL,
-	NULL
+    { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
+        CSIDL_Type_AllUsers,
+        Common_DesktopW,
+        MAKEINTRESOURCEW(IDS_DESKTOP)
+    },
+    { /* 0x1a - CSIDL_APPDATA */
+        CSIDL_Type_User,
+        AppDataW,
+        MAKEINTRESOURCEW(IDS_APPDATA)
+    },
+    { /* 0x1b - CSIDL_PRINTHOOD */
+        CSIDL_Type_User,
+        PrintHoodW,
+        MAKEINTRESOURCEW(IDS_PRINTHOOD)
+    },
+    { /* 0x1c - CSIDL_LOCAL_APPDATA */
+        CSIDL_Type_User,
+        Local_AppDataW,
+        MAKEINTRESOURCEW(IDS_LOCAL_APPDATA)
+    },
+    { /* 0x1d - CSIDL_ALTSTARTUP */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x1f - CSIDL_COMMON_FAVORITES */
+        CSIDL_Type_AllUsers,
+        FavoritesW,
+        MAKEINTRESOURCEW(IDS_FAVORITES)
+    },
+    { /* 0x20 - CSIDL_INTERNET_CACHE */
+        CSIDL_Type_User,
+        CacheW,
+        MAKEINTRESOURCEW(IDS_INTERNET_CACHE)
+    },
+    { /* 0x21 - CSIDL_COOKIES */
+        CSIDL_Type_User,
+        CookiesW,
+        MAKEINTRESOURCEW(IDS_COOKIES)
+    },
+    { /* 0x22 - CSIDL_HISTORY */
+        CSIDL_Type_User,
+        HistoryW,
+        MAKEINTRESOURCEW(IDS_HISTORY)
+    },
+    { /* 0x23 - CSIDL_COMMON_APPDATA */
+        CSIDL_Type_AllUsers,
+        Common_AppDataW,
+        MAKEINTRESOURCEW(IDS_APPDATA)
+    },
+    { /* 0x24 - CSIDL_WINDOWS */
+        CSIDL_Type_WindowsPath,
+        NULL,
+        NULL
+    },
+    { /* 0x25 - CSIDL_SYSTEM */
+        CSIDL_Type_SystemPath,
+        NULL,
+        NULL
+    },
+    { /* 0x26 - CSIDL_PROGRAM_FILES */
+        CSIDL_Type_CurrVer,
+        ProgramFilesDirW,
+        MAKEINTRESOURCEW(IDS_PROGRAM_FILES)
+    },
+    { /* 0x27 - CSIDL_MYPICTURES */
+        CSIDL_Type_User,
+        My_PicturesW,
+        MAKEINTRESOURCEW(IDS_MYPICTURES)
+    },
+    { /* 0x28 - CSIDL_PROFILE */
+        CSIDL_Type_User,
+        NULL,
+        NULL
+    },
+    { /* 0x29 - CSIDL_SYSTEMX86 */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
+        CSIDL_Type_CurrVer,
+        CommonFilesDirW,
+        MAKEINTRESOURCEW(IDS_PROGRAM_FILES_COMMON)
+    },
+    { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x2d - CSIDL_COMMON_TEMPLATES */
+        CSIDL_Type_AllUsers,
+        Common_TemplatesW,
+        MAKEINTRESOURCEW(IDS_TEMPLATES)
+    },
+    { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
+        CSIDL_Type_AllUsers,
+        Common_DocumentsW,
+        MAKEINTRESOURCEW(IDS_COMMON_DOCUMENTS)
+    },
+    { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
+        CSIDL_Type_AllUsers,
+        Common_Administrative_ToolsW,
+        MAKEINTRESOURCEW(IDS_ADMINTOOLS)
+    },
+    { /* 0x30 - CSIDL_ADMINTOOLS */
+        CSIDL_Type_User,
+        Administrative_ToolsW,
+        MAKEINTRESOURCEW(IDS_ADMINTOOLS)
+    },
+    { /* 0x31 - CSIDL_CONNECTIONS */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x32 - unassigned */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x33 - unassigned */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x34 - unassigned */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x35 - CSIDL_COMMON_MUSIC */
+        CSIDL_Type_AllUsers,
+        CommonMusicW,
+        MAKEINTRESOURCEW(IDS_COMMON_MUSIC)
+    },
+    { /* 0x36 - CSIDL_COMMON_PICTURES */
+        CSIDL_Type_AllUsers,
+        CommonPicturesW,
+        MAKEINTRESOURCEW(IDS_COMMON_PICTURES)
+    },
+    { /* 0x37 - CSIDL_COMMON_VIDEO */
+        CSIDL_Type_AllUsers,
+        CommonVideoW,
+        MAKEINTRESOURCEW(IDS_COMMON_VIDEO)
+    },
+    { /* 0x38 - CSIDL_RESOURCES */
+        CSIDL_Type_WindowsPath,
+        NULL,
+        ResourcesW
+    },
+    { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
+        CSIDL_Type_NonExistent,
+        NULL,
+        NULL
+    },
+    { /* 0x3b - CSIDL_CDBURN_AREA */
+        CSIDL_Type_User,
+        CD_BurningW,
+        MAKEINTRESOURCEW(IDS_CDBURN_AREA)
+    },
+    { /* 0x3c unassigned */
+        CSIDL_Type_Disallowed,
+        NULL,
+        NULL
+    },
+    { /* 0x3d - CSIDL_COMPUTERSNEARME */
+        CSIDL_Type_Disallowed, /* FIXME */
+        NULL,
+        NULL
+    },
+    { /* 0x3e - CSIDL_PROFILES */
+        CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
+        NULL,
+        NULL
     }
 };
-#undef HKCU
-#undef HKLM
 
-/**********************************************************************/
+static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
 
-HRESULT WINAPI SHGetFolderPathW(
-	HWND hwndOwner,
-	int csidl,
-	HANDLE hToken,	/* [in] FIXME: get paths for specific user */
-	DWORD dwFlags,	/* [in] FIXME: SHGFP_TYPE_CURRENT|SHGFP_TYPE_DEFAULT */
-	LPWSTR pszPath)
+/* Gets the value named value from the registry key
+ * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
+ * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
+ * is assumed to be MAX_PATH WCHARs in length.
+ * If it exists, expands the value and writes the expanded value to
+ * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
+ * Returns successful error code if the value was retrieved from the registry,
+ * and a failure otherwise.
+ */
+static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
+ LPCWSTR value, LPWSTR path)
 {
-	WCHAR   szBuildPath[MAX_PATH];
-	HKEY	hRootKey, hKey;
-	DWORD	dwCsidlFlags;
-	DWORD	dwType, dwDisp, dwPathLen = MAX_PATH;
-	DWORD	folder = csidl & CSIDL_FOLDER_MASK;
-	WCHAR	*p;
+    HRESULT hr;
+    WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
+    LPCWSTR pShellFolderPath, pUserShellFolderPath;
+    DWORD dwDisp, dwType, dwPathLen = MAX_PATH;
+    HKEY userShellFolderKey, shellFolderKey;
 
-	TRACE("%p,%p,csidl=0x%04x\n", hwndOwner,pszPath,csidl);
+    TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
+     path);
 
-        if (!pszPath)
-            return E_INVALIDARG;
+    if (userPrefix)
+    {
+        strcpyW(shellFolderPath, userPrefix);
+        PathAddBackslashW(shellFolderPath);
+        strcatW(shellFolderPath, szSHFolders);
+        pShellFolderPath = shellFolderPath;
+        strcpyW(userShellFolderPath, userPrefix);
+        PathAddBackslashW(userShellFolderPath);
+        strcatW(userShellFolderPath, szSHUserFolders);
+        pUserShellFolderPath = userShellFolderPath;
+    }
+    else
+    {
+        pUserShellFolderPath = szSHUserFolders;
+        pShellFolderPath = szSHFolders;
+    }
[truncated at 1000 lines; 999 more skipped]

reactos/lib/shell32
shlfileop.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- shlfileop.c	19 Oct 2004 10:17:53 -0000	1.9
+++ shlfileop.c	8 Dec 2004 21:57:22 -0000	1.9.2.1
@@ -3,8 +3,8 @@
  *
  * Copyright 2000 Juergen Schmied
  * Copyright 2002 Andriy Palamarchuk
- * Copyright 2002 Dietrich Teickner (from Odin)
- * Copyright 2002 Rolf Kalbermatter
+ * Copyright 2004 Dietrich Teickner (from Odin)
+ * Copyright 2004 Rolf Kalbermatter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -56,15 +56,16 @@
 static const WCHAR wWildcardChars[] = {'*','?',0};
 static const WCHAR wBackslash[] = {'\\',0};
 
-static BOOL SHELL_DeleteDirectoryW(LPCWSTR pszDir, BOOL bShowUI);
+static BOOL SHELL_DeleteDirectoryW(LPCWSTR path, BOOL bShowUI);
 static DWORD SHNotifyCreateDirectoryA(LPCSTR path, LPSECURITY_ATTRIBUTES sec);
 static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec);
 static DWORD SHNotifyRemoveDirectoryA(LPCSTR path);
 static DWORD SHNotifyRemoveDirectoryW(LPCWSTR path);
 static DWORD SHNotifyDeleteFileA(LPCSTR path);
 static DWORD SHNotifyDeleteFileW(LPCWSTR path);
-static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest, BOOL bRenameIfExists);
-static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bRenameIfExists);
+static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest);
+static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists);
+static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly);
 
 typedef struct
 {
@@ -130,14 +131,14 @@
 	return (IDOK == MessageBoxW(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
 }
 
-static DWORD SHELL32_AnsiToUnicodeBuf(LPCSTR aPath, LPWSTR *wPath, DWORD minlen)
+static DWORD SHELL32_AnsiToUnicodeBuf(LPCSTR aPath, LPWSTR *wPath, DWORD minChars)
 {
 	DWORD len = MultiByteToWideChar(CP_ACP, 0, aPath, -1, NULL, 0);
 
-	if (len < minlen)
-	  len = minlen;
+	if (len < minChars)
+	  len = minChars;
 
-	*wPath = HeapAlloc(GetProcessHeap(), 0, len);
+	*wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 	if (*wPath)
 	{
 	  MultiByteToWideChar(CP_ACP, 0, aPath, -1, *wPath, len);
@@ -152,9 +153,10 @@
 }
 
 /**************************************************************************
- * SHELL_DeleteDirectoryA()  [internal]
+ * SHELL_DeleteDirectory()  [internal]
  *
- * like rm -r
+ * Asks for confirmation when bShowUI is true and deletes the directory and
+ * all its subdirectories and files if necessary.
  */
 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
 {
@@ -292,7 +294,6 @@
  *  Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
  *  This is Unicode on NT/2000
  */
-
 static DWORD SHNotifyRemoveDirectoryA(LPCSTR path)
 {
 	LPWSTR wPath;
@@ -357,7 +358,6 @@
  *  Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
  *  This is Unicode on NT/2000
  */
-
 static DWORD SHNotifyDeleteFileA(LPCSTR path)
 {
 	LPWSTR wPath;
@@ -416,35 +416,29 @@
  * PARAMS
  *  src        [I]   path to source file to move
  *  dest       [I]   path to target file to move to
- *  bRename    [I]   if TRUE, the target file will be renamed if a
- *                   file with this name already exists
  *
  * RETURNS
  *  ERORR_SUCCESS if successful
  */
-static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest, BOOL bRename)
+static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest)
 {
 	BOOL ret;
 
-	TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bRename ? "renameIfExists" : "");
+	TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest));
 
 	ret = MoveFileW(src, dest);
 	if (!ret)
 	{
-	  /* Source file may be write protected or a system file */
-	  DWORD dwAttr = GetFileAttributesW(src);
-	  if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
-	    if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
-	      ret = MoveFileW(src, dest);
+	  DWORD dwAttr;
 
-	  if (!ret && bRename)
+	  dwAttr = SHFindAttrW(dest, FALSE);
+	  if (INVALID_FILE_ATTRIBUTES == dwAttr)
 	  {
-	    /* Destination file probably exists */
-	    dwAttr = GetFileAttributesW(dest);
-	    if (dwAttr != INVALID_FILE_ATTRIBUTES)
-	    {
-	      FIXME("Rename on move to existing file not implemented!\n");
-	    }
+	    /* Source file may be write protected or a system file */
+	    dwAttr = GetFileAttributesW(src);
+	    if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
+	      if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
+	        ret = MoveFileW(src, dest);
 	  }
 	}
 	if (ret)
@@ -461,30 +455,21 @@
  * Copies a file. Also triggers a change notify if one exists.
  *
  * PARAMS
- *  src        [I]   path to source file to move
- *  dest       [I]   path to target file to move to
- *  bRename    [I]   if TRUE, the target file will be renamed if a
- *                   file with this name already exists
+ *  src           [I]   path to source file to move
+ *  dest          [I]   path to target file to move to
+ *  bFailIfExists [I]   if TRUE, the target file will not be overwritten if
+ *                      a file with this name already exists
  *
  * RETURNS
  *  ERROR_SUCCESS if successful
  */
-static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bRename)
+static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
 {
 	BOOL ret;
 
-	TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bRename ? "renameIfExists" : "");
+	TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : "");
 
-	ret = CopyFileW(src, dest, TRUE);
-	if (!ret && bRename)
-	{
-	  /* Destination file probably exists */
-	  DWORD dwAttr = GetFileAttributesW(dest);
-	  if (dwAttr != INVALID_FILE_ATTRIBUTES)
-	  {
-	    FIXME("Rename on copy to existing file not implemented!\n");
-	  }
-	}
+	ret = CopyFileW(src, dest, bFailIfExists);
 	if (ret)
 	{
 	  SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, dest, NULL);
@@ -546,7 +531,9 @@
  *  ERROR_FILENAME_EXCED_RANGE if the filename was to long to process
  *
  *  FIXME: Not implemented yet;
- *  SHCreateDirectoryEx also verifies that the files will be visible. If not:
+ *  SHCreateDirectoryEx also verifies that the files in the directory will be visible
+ *  if the path is a network path to deal with network drivers which might have a limited
+ *  but unknown maximum path length. If not:
  *
  *  If hWnd is set to a valid window handle, a message box is displayed warning
  *  the user that the files may not be accessible. If the user chooses not to
@@ -591,15 +578,76 @@
 	      ret != ERROR_ALREADY_EXISTS &&
 	      ret != ERROR_FILENAME_EXCED_RANGE)
 	  {
-	  /* handling network file names?
-	    lstrcpynW(pathName, path, MAX_PATH);
-	    lpStr = PathAddBackslashW(pathName);*/
-	    FIXME("Semi-stub, non zero hWnd should be used somehow?\n");
+	    WCHAR *pEnd, *pSlash, szTemp[MAX_PATH + 1];  /* extra for PathAddBackslash() */
+
+	    lstrcpynW(szTemp, path, MAX_PATH);
+	    pEnd = PathAddBackslashW(szTemp);
+	    pSlash = szTemp + 3;
+
+	    while (*pSlash)
+	    {
+	      while (*pSlash && *pSlash != '\\')
+	        pSlash = CharNextW(pSlash);
+
+	      if (*pSlash)
+	      {
+	        *pSlash = 0;    /* terminate path at separator */
+
+	        ret = SHNotifyCreateDirectoryW(szTemp, pSlash + 1 == pEnd ? sec : NULL);
+	      }
+	      *pSlash++ = '\\'; /* put the separator back */
+	    }
+	  }
+
+	  if (ret && hWnd && (ERROR_CANCELLED != ret))
+	  {
+	    /* We failed and should show a dialog box */
+	    FIXME("Show system error message, creating path %s, failed with error %d\n", debugstr_w(path), ret);
+	    ret = ERROR_CANCELLED; /* Error has been already presented to user (not really yet!) */
 	  }
 	}
 	return ret;
 }
 
+
+/*************************************************************************
+ * SHFindAttrW      [internal]
+ *
+ * Get the Attributes for a file or directory. The difference to GetAttributes()
+ * is that this function will also work for paths containing wildcard characters
+ * in its filename.
+
+ * PARAMS
+ *  path       [I]   path of directory or file to check
+ *  fileOnly   [I]   TRUE if only files should be found
+ *
+ * RETURNS
+ *  INVALID_FILE_ATTRIBUTES if the path does not exist, the actual attributes of
+ *  the first file or directory found otherwise
+ */
+static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
+{
+	WIN32_FIND_DATAW wfd;
+	BOOL b_FileMask = fileOnly && (NULL != StrPBrkW(pName, wWildcardChars));
+	DWORD dwAttr = INVALID_FILE_ATTRIBUTES;
+	HANDLE hFind = FindFirstFileW(pName, &wfd);
+
+	TRACE("%s %d\n", debugstr_w(pName), fileOnly);
+	if (INVALID_HANDLE_VALUE != hFind)
+	{
+	  do
+	  {
+	    if (b_FileMask && IsAttribDir(wfd.dwFileAttributes))
+	       continue;
+	    dwAttr = wfd.dwFileAttributes;
+	    break;
+	  }
+	  while (FindNextFileW(hFind, &wfd));
+	  FindClose(hFind);
+	}
+	return dwAttr;
+}
+
 /*************************************************************************
  *
  * SHFileStrICmp HelperFunction for SHFileOperationW
@@ -690,7 +738,7 @@
 	{
 	  if (NULL == StrPBrkW(pszFiles1, wWildcardChars))
 	  {
-	    if (-1 == GetFileAttributesW(pszFiles1))
+	    if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(pszFiles1))
 	      return FALSE;
 	  }
 	  pszFiles1 += lstrlenW(pszFiles1) + 1;
@@ -1070,7 +1118,7 @@
 	    b_SameTailName = SHFileStrICmpW(pToFile, pFromFile, NULL, NULL);
 
 	    ToPathAttr = ToAttr = GetFileAttributesW(pTempTo);
-	    if (!b_Mask && (ToAttr == -1) && (pToFile))
+	    if (!b_Mask && (ToAttr == INVALID_FILE_ATTRIBUTES) && (pToFile))
 	    {
                 pToFile[0] = '\0';
                 ToPathAttr = GetFileAttributesW(pTempTo);
@@ -1091,7 +1139,7 @@
                     retCode=0x2;
                     goto shfileop_end;
                 }
-                if (-1 == ToPathAttr)
+                if (INVALID_FILE_ATTRIBUTES == ToPathAttr)
                 {
                     retCode = 0x75;
                     goto shfileop_end;
@@ -1102,7 +1150,7 @@
                     goto shfileop_end;
                 }
                 /* we use SHNotifyMoveFile() instead MoveFileW */
-                if (SHNotifyMoveFileW(pTempFrom, pTempTo, nFileOp.fFlags & FOF_RENAMEONCOLLISION) != ERROR_SUCCESS)
+                if (SHNotifyMoveFileW(pTempFrom, pTempTo) != ERROR_SUCCESS)
                 {
                     /* we need still the value for the returncode, we use the mostly assumed */
                     retCode = 0xb7;
@@ -1146,16 +1194,16 @@
                 continue;
 
 	    /* only FO_COPY/FO_MOVE without mask, all others are (must be) solved */
-	    if (IsAttribDir(wfd.dwFileAttributes) && (ToAttr == -1))
+	    if (IsAttribDir(wfd.dwFileAttributes) && (ToAttr == INVALID_FILE_ATTRIBUTES))
 	    {
                 if (pToFile)
                 {
                     pToFile[0] = '\0';
                     ToPathAttr = GetFileAttributesW(pTempTo);
-                    if ((ToPathAttr == -1) && b_ToValid)
+                    if ((ToPathAttr == INVALID_FILE_ATTRIBUTES) && b_ToValid)
                     {
                         /* create dir must be here, sample target D:\y\ *.* create with RC=10003 */
-                        if (SHCreateDirectoryExW(NULL, pTempTo, NULL))
+                        if (SHNotifyCreateDirectoryW(pTempTo, NULL))
                         {
                             retCode = 0x73;/* value unknown */
                             goto shfileop_end;
@@ -1208,7 +1256,7 @@
 	    }
 
 	    /* singlesource + no mask */
-	    if (-1 == (ToAttr & ToPathAttr))
+	    if (INVALID_FILE_ATTRIBUTES == (ToAttr & ToPathAttr))
 	    {
                 /* Target-dir does not exist, and cannot be created */
                 retCode=0x75;
@@ -1219,7 +1267,7 @@
 	    {
 	    case FO_MOVE:
                 pToFile = NULL;
-                if ((ToAttr == -1) && SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, NULL))
+                if ((ToAttr == INVALID_FILE_ATTRIBUTES) && SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, NULL))
                 {
                     nFileOp.wFunc =  ((level+1)<<4) + FO_RENAME;
                 }
@@ -1253,7 +1301,7 @@
                 }
                 if (IsAttribDir((ToAttr & wfd.dwFileAttributes)))
                 {
-                    if (IsAttribDir(ToAttr) || !SHCreateDirectoryExW(NULL,pTempTo, NULL))
+                    if (IsAttribDir(ToAttr) || !SHNotifyCreateDirectoryW(pTempTo, NULL))
                     {
                         /* ??? nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES); */
                         SHFileStrCpyCatW(pTempFrom, NULL, wWildcardFile);
@@ -1274,7 +1322,7 @@
                         retCode = 0x73;
                         goto shfileop_end;
                     }
-                    if (SHNotifyCopyFileW(pTempFrom, pTempTo, nFileOp.fFlags & FOF_RENAMEONCOLLISION) != ERROR_SUCCESS)
+                    if (SHNotifyCopyFileW(pTempFrom, pTempTo, TRUE) != ERROR_SUCCESS)
                     {
                         retCode = 0x77; /* value unknown */
                         goto shfileop_end;

reactos/lib/shell32
shlfolder.c 1.13 -> 1.13.2.1
diff -u -r1.13 -r1.13.2.1
--- shlfolder.c	7 Oct 2004 09:13:56 -0000	1.13
+++ shlfolder.c	8 Dec 2004 21:57:22 -0000	1.13.2.1
@@ -143,7 +143,7 @@
     while (*pszTail && (*pszTail != (WCHAR) '\\'))
 	pszTail++;
 
-    dwCopy = (WCHAR *) pszTail - (WCHAR *) pszNext + 1;
+    dwCopy = (const WCHAR *) pszTail - (const WCHAR *) pszNext + 1;
     lstrcpynW (pszOut, pszNext, (dwOut < dwCopy) ? dwOut : dwCopy);
 
     if (*pszTail)

reactos/lib/shell32
shpolicy.c 1.2 -> 1.2.18.1
diff -u -r1.2 -r1.2.18.1
--- shpolicy.c	13 May 2004 20:27:04 -0000	1.2
+++ shpolicy.c	8 Dec 2004 21:57:22 -0000	1.2.18.1
@@ -897,15 +897,15 @@
 	{
 	  if (SHELL_OsIsUnicode())
 	  {
-	    if (lstrcmpiW((LPWSTR)inpRegKey, strRegistryPolicyW) &&
-	        lstrcmpiW((LPWSTR)inpRegKey, strPolicyW))
+	    if (lstrcmpiW((LPCWSTR)inpRegKey, strRegistryPolicyW) &&
+	        lstrcmpiW((LPCWSTR)inpRegKey, strPolicyW))
 	      /* doesn't match, fail */
 	      return 0;
 	  }
 	  else
 	  {
-	    if (lstrcmpiA((LPSTR)inpRegKey, strRegistryPolicyA) &&
-	        lstrcmpiA((LPSTR)inpRegKey, strPolicyA))
+	    if (lstrcmpiA((LPCSTR)inpRegKey, strRegistryPolicyA) &&
+	        lstrcmpiA((LPCSTR)inpRegKey, strPolicyA))
 	      /* doesn't match, fail */
 	      return 0;
 	  }

reactos/lib/shell32
shresdef.h 1.2 -> 1.2.8.1
diff -u -r1.2 -r1.2.8.1
--- shresdef.h	12 Jul 2004 20:53:24 -0000	1.2
+++ shresdef.h	8 Dec 2004 21:57:22 -0000	1.2.8.1
@@ -56,6 +56,34 @@
 #define IDS_SHUTDOWN_TITLE     42
 #define IDS_SHUTDOWN_PROMPT    43
 
+#define IDS_PROGRAMS                45
+#define IDS_PERSONAL                46
+#define IDS_FAVORITES               47
+#define IDS_STARTUP                 48
+#define IDS_RECENT                  49
+#define IDS_SENDTO                  50
+#define IDS_STARTMENU               51
+#define IDS_MYMUSIC                 52
+#define IDS_MYVIDEO                 53
+#define IDS_DESKTOPDIRECTORY        54
+#define IDS_NETHOOD                 55
+#define IDS_TEMPLATES               56
+#define IDS_APPDATA                 57
+#define IDS_PRINTHOOD               58
+#define IDS_LOCAL_APPDATA           59
+#define IDS_INTERNET_CACHE          60
+#define IDS_COOKIES                 61
+#define IDS_HISTORY                 62
+#define IDS_PROGRAM_FILES           63
+#define IDS_MYPICTURES              64
+#define IDS_PROGRAM_FILES_COMMON    65
+#define IDS_COMMON_DOCUMENTS        66
+#define IDS_ADMINTOOLS              67
+#define IDS_COMMON_MUSIC            68
+#define IDS_COMMON_PICTURES         69
+#define IDS_COMMON_VIDEO            70
+#define IDS_CDBURN_AREA             71
+
 /* browse for folder dialog box */
 #define IDD_STATUS		0x3743
 #define IDD_TITLE		0x3742

reactos/lib/shell32
undocshell.h 1.7 -> 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- undocshell.h	19 Sep 2004 22:02:28 -0000	1.7
+++ undocshell.h	8 Dec 2004 21:57:22 -0000	1.7.6.1
@@ -429,14 +429,6 @@
 	LPCWSTR lpszShortName,
 	LPCWSTR lpszLongName);
 
-/* PathCleanupSpec return values */
-#define PCS_REPLACEDCHARS  0x00000001
-#define PCS_REMOVEDCHARS   0x00000002
-#define PCS_SHORTENED      0x00000004
-#define PCS_PATHTOOLONG    0x80000008
-
-DWORD WINAPI PathCleanupSpecAW(LPCVOID lpszPath, LPVOID lpszFile);
-
 BOOL WINAPI PathQualifyA(LPCSTR path);
 BOOL WINAPI PathQualifyW(LPCWSTR path);
 #define PathQualify WINELIB_NAME_AW(PathQualify)

reactos/lib/shell32
version.h 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- version.h	22 Sep 2004 05:08:04 -0000	1.1
+++ version.h	8 Dec 2004 21:57:22 -0000	1.1.6.1
@@ -18,11 +18,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#define WINE_FILEVERSION_MAJOR         4
-#define WINE_FILEVERSION_MINOR        72
-#define WINE_FILEVERSION_BUILD      3110
+#define WINE_FILEVERSION_MAJOR         6
+#define WINE_FILEVERSION_MINOR         0
+#define WINE_FILEVERSION_BUILD      2600
 #define WINE_FILEVERSION_PLATFORMID    1
 
 /* FIXME: when libs/wpp gets fixed to support concatenation we can remove
  * this and define it in version.rc */
-#define WINE_FILEVERSION "4.72.3110.1"
+#define WINE_FILEVERSION "6.0.2600.1"

reactos/lib/shell32
version16.rc 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- version16.rc	2 Jan 2004 19:49:46 -0000	1.1
+++ version16.rc	8 Dec 2004 21:57:22 -0000	1.1.24.1
@@ -16,9 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#define WINE_FILEVERSION 4,0,0,0
-#define WINE_FILEVERSION_STR "4.0"
 #define WINE_FILEDESCRIPTION_STR "Wine core dll"
 #define WINE_FILENAME_STR "shell.dll"
+#define WINE_FILEVERSION 4,0,0,0
+#define WINE_FILEVERSION_STR "4.0"
 
 #include "wine/wine_common_ver.rc"

reactos/lib/shell32
winehq2ros.patch 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- winehq2ros.patch	20 Oct 2004 18:30:39 -0000	1.5
+++ winehq2ros.patch	8 Dec 2004 21:57:22 -0000	1.5.2.1
@@ -1,29 +1,26 @@
 Index: Makefile.in
 ===================================================================
 RCS file: /home/wine/wine/dlls/shell32/Makefile.in,v
-retrieving revision 1.85
-diff -u -r1.85 Makefile.in
---- Makefile.in	29 Sep 2004 21:13:58 -0000	1.85
-+++ Makefile.in	20 Oct 2004 18:43:52 -0000
-@@ -46,9 +46,9 @@
+retrieving revision 1.86
+diff -u -r1.86 Makefile.in
+--- Makefile.in	27 Oct 2004 00:47:53 -0000	1.86
++++ Makefile.in	6 Dec 2004 23:45:47 -0000
+@@ -46,7 +46,7 @@
  	shpolicy.c \
  	shv_bg_cmenu.c \
  	shv_item_cmenu.c \
 -	systray.c
 +	ros-systray.c
  
--RC_SRCS = shres.rc version.rc
-+RC_SRCS = shres.rc
+ RC_SRCS = shres.rc
  RC_BINSRC = shres.rc
- RC_BINARIES = \
- 	cdrom.ico \
 Index: control.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/shell32/control.c,v
 retrieving revision 1.20
 diff -u -r1.20 control.c
 --- control.c	12 Jul 2004 19:50:56 -0000	1.20
-+++ control.c	20 Oct 2004 18:43:52 -0000
++++ control.c	6 Dec 2004 23:45:47 -0000
 @@ -464,6 +464,7 @@
  void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst,
                                  LPCSTR cmdline, INT cmdshow )
@@ -49,7 +46,7 @@
 retrieving revision 1.83
 diff -u -r1.83 iconcache.c
 --- iconcache.c	7 Oct 2004 03:06:48 -0000	1.83
-+++ iconcache.c	20 Oct 2004 18:43:52 -0000
++++ iconcache.c	6 Dec 2004 23:45:47 -0000
 @@ -143,8 +143,22 @@
  {	HICON	hiconLarge=0;
  	HICON	hiconSmall=0;
@@ -75,22 +72,6 @@
  
  	if ( !hiconLarge ||  !hiconSmall)
  	{
-@@ -299,6 +313,7 @@
- 
- 	return TRUE;
- }
-+
- /*************************************************************************
-  * PidlToSicIndex			[INTERNAL]
-  *
-@@ -339,7 +354,6 @@
- 	  *pIndex = 0;
- 
- 	return ret;
--
- }
- 
- /*************************************************************************
 @@ -362,8 +376,12 @@
  	pdump(pidl);
  
@@ -126,14 +107,212 @@
  	TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
  
  	return PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
+Index: shell32_Ca.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Ca.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_Ca.rc
+--- shell32_Ca.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_Ca.rc	6 Dec 2004 23:45:47 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Quant a %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "D'Acord", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "D'Acord", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine ha estat construit per:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS ha estat construit per:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Cn.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Cn.rc,v
+retrieving revision 1.4
+diff -u -r1.4 shell32_Cn.rc
+--- shell32_Cn.rc	24 Aug 2004 18:33:03 -0000	1.4
++++ shell32_Cn.rc	6 Dec 2004 23:45:47 -0000
+@@ -24,11 +24,12 @@
+ CAPTION "���� %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "����", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "����", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -37,7 +38,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "������������������������Internet��������Wine��������������", 12289, 36, 11, 182, 18
++ LTEXT "������������������������Internet��������ReactOS��������������", 12289, 36, 11, 182, 18
+  LTEXT "����(&O):", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "����", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Cs.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Cs.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Cs.rc
+--- shell32_Cs.rc	24 Aug 2004 18:33:03 -0000	1.8
++++ shell32_Cs.rc	6 Dec 2004 23:45:47 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "O aplikaci %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine je d�lem:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS je d�lem:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Zadejte n�zev programu, slo�ky, dokumentu, nebo zdroje v s�ti Internet a Wine jej pro v�s otev�e.", 12289, 36, 11, 182, 18
++ LTEXT "Zadejte n�zev programu, slo�ky, dokumentu, nebo zdroje v s�ti Internet a ReactOS jej pro v�s otev�e.", 12289, 36, 11, 182, 18
+  LTEXT "&Otev��t:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Da.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Da.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_Da.rc
+--- shell32_Da.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_Da.rc	6 Dec 2004 23:45:47 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Om %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine havde ikke v�ret mulig uden hj�lp fra disse personer:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS havde ikke v�ret mulig uden hj�lp fra disse personer:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_De.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_De.rc,v
+retrieving revision 1.12
+diff -u -r1.12 shell32_De.rc
+--- shell32_De.rc	23 Sep 2004 04:28:04 -0000	1.12
++++ shell32_De.rc	6 Dec 2004 23:45:47 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "Informationen �ber %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "WINE wurde f�r Sie gekeltert von:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS wurde Ihnen zur Verf�gung gestellt von:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Den Namen eines Programmes, eines Ordners, eines Dokumentes oder einer Internet Ressource eingeben, und Wine wird es f�r Sie �ffnen", 12289, 36, 11, 182, 18
++ LTEXT "Den Namen eines Programmes, eines Ordners, eines Dokumentes oder einer Internet Ressource eingeben, und ReactOS wird es f�r Sie �ffnen", 12289, 36, 11, 182, 18
+  LTEXT "&�ffnen:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -185,5 +186,5 @@
+        IDS_RESTART_TITLE       "Neustarten"
+        IDS_RESTART_PROMPT      "M�chten Sie, dass ein simulierter Windows Neustart durchgef�hrt wird ?"
+        IDS_SHUTDOWN_TITLE      "Anhalten"
+-       IDS_SHUTDOWN_PROMPT     "M�chten Sie die aktuelle Wine Sitzung beenden ?"
++       IDS_SHUTDOWN_PROMPT     "M�chten Sie die aktuelle ReactOS Sitzung beenden ?"
+ }
 Index: shell32_En.rc
 ===================================================================
 RCS file: /home/wine/wine/dlls/shell32/shell32_En.rc,v
-retrieving revision 1.17
-diff -u -r1.17 shell32_En.rc
---- shell32_En.rc	23 Sep 2004 04:28:04 -0000	1.17
-+++ shell32_En.rc	20 Oct 2004 18:43:52 -0000
-@@ -181,8 +181,8 @@
+retrieving revision 1.18
+diff -u -r1.18 shell32_En.rc
+--- shell32_En.rc	21 Oct 2004 19:59:46 -0000	1.18
++++ shell32_En.rc	6 Dec 2004 23:45:47 -0000
+@@ -109,11 +109,12 @@
+ CAPTION "About %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -122,7 +123,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -181,10 +182,10 @@
  /* message box strings */
  STRINGTABLE DISCARDABLE
  {
@@ -146,14 +325,697 @@
 +	IDS_SHUTDOWN_TITLE	"Shutdown"
 +	IDS_SHUTDOWN_PROMPT	"Do you want to shutdown?"
  }
+ 
+ /* shell folder path default values */
+Index: shell32_Eo.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Eo.rc,v
+retrieving revision 1.6
+diff -u -r1.6 shell32_Eo.rc
+--- shell32_Eo.rc	24 Aug 2004 18:33:03 -0000	1.6
++++ shell32_Eo.rc	6 Dec 2004 23:45:47 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Pri %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "Enorde", 1, 153, 130, 50, 12
++ DEFPUSHBUTTON "Enorde", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Es.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Es.rc,v
+retrieving revision 1.11
+diff -u -r1.11 shell32_Es.rc
+--- shell32_Es.rc	23 Sep 2004 04:28:04 -0000	1.11
++++ shell32_Es.rc	6 Dec 2004 23:45:48 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "Acerca de %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "Aceptar", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "Aceptar", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine est� disponible gracias a:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS est� disponible gracias a:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Introduzca el nombre de un programa, carpeta, documento o recurso de Internet, y Wine lo abrir� para usted.", 12289, 36, 11, 182, 18
++ LTEXT "Introduzca el nombre de un programa, carpeta, documento o recurso de Internet, y ReactOS lo abrir� para usted.", 12289, 36, 11, 182, 18
+  LTEXT "&Abrir:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "Aceptar", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -185,5 +186,5 @@
+ 	IDS_RESTART_TITLE	"Reiniciar"
+ 	IDS_RESTART_PROMPT	"�Desea simular un reinicio de Windows?"
+ 	IDS_SHUTDOWN_TITLE	"Apagar"
+-	IDS_SHUTDOWN_PROMPT	"�Desea terminar su sesi�n Wine?"
++	IDS_SHUTDOWN_PROMPT	"�Desea terminar su sesi�n ReactOS?"
+ }
+Index: shell32_Fi.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Fi.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_Fi.rc
+--- shell32_Fi.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_Fi.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Tietoja: %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine:n tekij�t:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS:n tekij�t:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Fr.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Fr.rc,v
+retrieving revision 1.13
+diff -u -r1.13 shell32_Fr.rc
+--- shell32_Fr.rc	27 Oct 2004 21:36:17 -0000	1.13
++++ shell32_Fr.rc	6 Dec 2004 23:45:48 -0000
+@@ -112,11 +112,12 @@
+ CAPTION "� propos de %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine est une r�alisation de :", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS est une r�alisation de :", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -125,7 +126,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Entrez le nom d'un programme, d'un dossier, d'un document ou d'une ressource Internet, et Wine l'ouvrira pour vous.", 12289, 36, 11, 182, 18
++ LTEXT "Entrez le nom d'un programme, d'un dossier, d'un document ou d'une ressource Internet, et ReactOS l'ouvrira pour vous.", 12289, 36, 11, 182, 18
+  LTEXT "&Ouvrir :", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -187,7 +188,7 @@
+        IDS_RESTART_TITLE       "Red�marrer"
+        IDS_RESTART_PROMPT      "Voulez-vous simuler le red�marrage de Windows?"
+        IDS_SHUTDOWN_TITLE      "Arr�ter"
+-       IDS_SHUTDOWN_PROMPT     "Voulez-vous fermer la session Wine?"
++       IDS_SHUTDOWN_PROMPT     "Voulez-vous fermer la session ReactOS?"
+ }
+ 
+ /* shell folder path default values */
+Index: shell32_Hu.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Hu.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_Hu.rc
+--- shell32_Hu.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_Hu.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "A %s-r�l"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "A WINE-t �rt�k:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "A ReactOS-t �rt�k:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_It.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_It.rc,v
+retrieving revision 1.13
+diff -u -r1.13 shell32_It.rc
+--- shell32_It.rc	23 Sep 2004 04:28:04 -0000	1.13
++++ shell32_It.rc	6 Dec 2004 23:45:48 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "Informazioni su %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine � disponibile grazie a:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS � disponibile grazie a:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Digitare il nome del programma, della cartella, del documento o della risorsa internet, e Wine la aprir�.", 12289, 36, 11, 182, 18
++ LTEXT "Digitare il nome del programma, della cartella, del documento o della risorsa internet, e ReactOS la aprir�.", 12289, 36, 11, 182, 18
+  LTEXT "&Apri:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -186,5 +187,5 @@
+        IDS_RESTART_TITLE       "Riavvia"
+        IDS_RESTART_PROMPT      "Vuoi simulare un riavvio do Windows?"
+        IDS_SHUTDOWN_TITLE      "Termina sessione"
+-       IDS_SHUTDOWN_PROMPT     "Vuoi terminare la sessione di Wine?"
++       IDS_SHUTDOWN_PROMPT     "Vuoi terminare la sessione di ReactOS?"
+ }
+Index: shell32_Ja.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Ja.rc,v
+retrieving revision 1.9
+diff -u -r1.9 shell32_Ja.rc
+--- shell32_Ja.rc	23 Sep 2004 04:28:04 -0000	1.9
++++ shell32_Ja.rc	6 Dec 2004 23:45:48 -0000
+@@ -103,11 +103,12 @@
+ CAPTION "%s ��������"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -116,7 +117,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Ko.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Ko.rc,v
+retrieving revision 1.6
+diff -u -r1.6 shell32_Ko.rc
+--- shell32_Ko.rc	24 Aug 2004 18:33:03 -0000	1.6
++++ shell32_Ko.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "%s�� ������"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "����", 1, 153, 130, 50, 12
++ DEFPUSHBUTTON "����", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Nl.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Nl.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_Nl.rc
+--- shell32_Nl.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_Nl.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Info %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine is geschreven door:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS is geschreven door:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_No.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_No.rc,v
+retrieving revision 1.7
+diff -u -r1.7 shell32_No.rc
+--- shell32_No.rc	24 Aug 2004 18:33:03 -0000	1.7
++++ shell32_No.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Om %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Pl.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Pl.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Pl.rc
+--- shell32_Pl.rc	4 Oct 2004 19:31:50 -0000	1.8
++++ shell32_Pl.rc	6 Dec 2004 23:45:48 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "O %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Mo�esz korzysta� z Wine'a dzi�ki:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "Mo�esz korzysta� z ReactOS'a dzi�ki:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Wpisz nazw� programu, katalogu, dokumentu, a Wine otworzy go dla ciebie.", 12289, 36, 11, 182, 18
++ LTEXT "Wpisz nazw� programu, katalogu, dokumentu, a ReactOS otworzy go dla ciebie.", 12289, 36, 11, 182, 18
+  LTEXT "&Otw�rz:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -185,5 +186,5 @@
+        IDS_RESTART_TITLE       "Uruchom ponownie"
+        IDS_RESTART_PROMPT      "Czy chcesz zasymulowa� zrestartowanie Windowsa?"
+        IDS_SHUTDOWN_TITLE      "Wy��cz"
+-       IDS_SHUTDOWN_PROMPT     "Czy chcesz wy��czy� sesj� Wine'a?"
++       IDS_SHUTDOWN_PROMPT     "Czy chcesz wy��czy� sesj� ReactOS'a?"
+ }
+Index: shell32_Pt.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Pt.rc,v
+retrieving revision 1.15
+diff -u -r1.15 shell32_Pt.rc
+--- shell32_Pt.rc	23 Sep 2004 04:28:04 -0000	1.15
++++ shell32_Pt.rc	6 Dec 2004 23:45:48 -0000
+@@ -110,11 +110,12 @@
+ CAPTION "Sobre %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine foi disponibilizado por:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS foi disponibilizado por:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -123,7 +124,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Digite o nome do programa, pasta, documento, ou endere�o Internet, que o Wine ir� abr�-lo para voc�.", 12289, 36, 11, 182, 18
++ LTEXT "Digite o nome do programa, pasta, documento, ou endere�o Internet, que o ReactOS ir� abr�-lo para voc�.", 12289, 36, 11, 182, 18
+  LTEXT "&Abrir:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+@@ -185,5 +186,5 @@
+        IDS_RESTART_TITLE       "Reiniciar"
+        IDS_RESTART_PROMPT      "Voc� quer simular a reinicializa��o do Windows?"
+        IDS_SHUTDOWN_TITLE      "Desligar"
+-       IDS_SHUTDOWN_PROMPT     "Voc� quer finalizar a sess�o no Wine?"
++       IDS_SHUTDOWN_PROMPT     "Voc� quer finalizar a sess�o no ReactOS?"
+ }
+Index: shell32_Ru.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Ru.rc,v
+retrieving revision 1.9
+diff -u -r1.9 shell32_Ru.rc
+--- shell32_Ru.rc	24 Aug 2004 18:33:03 -0000	1.9
++++ shell32_Ru.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "� %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "������������ Wine:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "������������ ReactOS:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "������� ��� ���������, �����, ��������� ��� ������ ���������, � Wine ������� ��.", 12289, 36, 11, 182, 18
++ LTEXT "������� ��� ���������, �����, ��������� ��� ������ ���������, � ReactOS ������� ��.", 12289, 36, 11, 182, 18
+  LTEXT "&�������:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Si.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Si.rc,v
+retrieving revision 1.5
+diff -u -r1.5 shell32_Si.rc
+--- shell32_Si.rc	24 Aug 2004 18:33:03 -0000	1.5
++++ shell32_Si.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "O %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "V redu", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "V redu", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine so ustvarili:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS so ustvarili:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Vnesite ime programa, mape, dokumenta ali spletne strani, in Wine ga (jo) bo odprl.", 12289, 36, 11, 182, 18
++ LTEXT "Vnesite ime programa, mape, dokumenta ali spletne strani, in ReactOS ga (jo) bo odprl.", 12289, 36, 11, 182, 18
+  LTEXT "&Odpri:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "V redu", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Sk.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Sk.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Sk.rc
+--- shell32_Sk.rc	24 Aug 2004 18:33:03 -0000	1.8
++++ shell32_Sk.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,10 +23,11 @@
+ CAPTION "O programe %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
+  LTEXT "V�no pre v�s pripravili:", 98, 8, 55, 137, 10
+ }
+ 
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Sv.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Sv.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Sv.rc
+--- shell32_Sv.rc	24 Aug 2004 18:33:03 -0000	1.8
++++ shell32_Sv.rc	6 Dec 2004 23:45:48 -0000
+@@ -23,11 +23,12 @@
+ CAPTION "Om %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine hade inte varit m�jligt utan dessa personer:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS hade inte varit m�jligt utan dessa personer:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -36,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Skriv namnet p� ett program, en mapp eller ett dokument och wine kommer att �ppna det f�r dig.", 12289, 36, 11, 182, 18
++ LTEXT "Skriv namnet p� ett program, en mapp eller ett dokument och ReactOS kommer att �ppna det f�r dig.", 12289, 36, 11, 182, 18
+  LTEXT "&�ppna:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Uk.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Uk.rc,v
+retrieving revision 1.6
+diff -u -r1.6 shell32_Uk.rc
+--- shell32_Uk.rc	23 Sep 2004 04:28:04 -0000	1.6
++++ shell32_Uk.rc	6 Dec 2004 23:45:48 -0000
+@@ -109,11 +109,12 @@
+ CAPTION "��� %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "OK", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "OK", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "���������� Wine:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "���������� ReactOS:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -122,7 +123,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "������� ��'� ��������, ����, ��������� �� ������ ���������, � Wine ������� ��.", 12289, 36, 11, 182, 18
++ LTEXT "������� ��'� ��������, ����, ��������� �� ������ ���������, � ReactOS ������� ��.", 12289, 36, 11, 182, 18
+  LTEXT "&��������:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Wa.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Wa.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Wa.rc
+--- shell32_Wa.rc	24 Aug 2004 18:33:03 -0000	1.8
++++ shell32_Wa.rc	6 Dec 2004 23:45:48 -0000
+@@ -28,11 +28,12 @@
+ CAPTION "� dfait di %s"
+ FONT 10, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "I Va", IDOK, 153, 130, 50, 12
++ DEFPUSHBUTTON "I Va", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 189, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine a estu fwait par:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 30, 10, 137, 10
++ LTEXT "", 101, 30, 22, 137, 10
++ LTEXT "ReactOS a estu fwait par:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -41,7 +42,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
+Index: shell32_Zh.rc
+===================================================================
+RCS file: /home/wine/wine/dlls/shell32/shell32_Zh.rc,v
+retrieving revision 1.8
+diff -u -r1.8 shell32_Zh.rc
+--- shell32_Zh.rc	24 Aug 2004 18:33:03 -0000	1.8
++++ shell32_Zh.rc	6 Dec 2004 23:45:48 -0000
+@@ -24,11 +24,11 @@
+ CAPTION "�P�� %s"
+ FONT 8, "MS Shell Dlg"
+ {
+- DEFPUSHBUTTON "�_��", IDOK, 153, 130, 50, 12, WS_TABSTOP
++ DEFPUSHBUTTON "�_��", IDOK, 153, 133, 50, 12, WS_TABSTOP
+  LISTBOX 99, 8, 65, 137, 82, LBS_NOTIFY | WS_VSCROLL | WS_BORDER
+- ICON "", 1088, 174, 10, 14, 16
+- LTEXT "", 100, 8, 10, 137, 33
+- LTEXT "Wine was brought to you by:", 98, 8, 55, 137, 10
++ ICON "", 1088, 10, 10, 14, 16
++ LTEXT "", 100, 35, 10, 137, 10
++ LTEXT "ReactOS was brought to you by:", 98, 8, 55, 137, 10
+ }
+ 
+ SHELL_RUN_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 227, 95
+@@ -37,7 +37,7 @@
+ FONT 8, "MS Shell Dlg"
+ {
+  ICON "", 12297, 7, 11, 18, 20, WS_VISIBLE
+- LTEXT "Type the name of a program, folder, document, or Internet resource, and Wine will open it for you.", 12289, 36, 11, 182, 18
++ LTEXT "Type the name of a program, folder, document, or Internet resource, and ReactOS will open it for you.", 12289, 36, 11, 182, 18
+  LTEXT "&Open:", 12305, 7, 39, 24, 10
+  CONTROL "", 12298, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 36, 37, 183, 100
+  DEFPUSHBUTTON "OK", IDOK, 62, 63, 50, 14, WS_TABSTOP
 Index: shell32_main.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
 retrieving revision 1.139
 diff -u -r1.139 shell32_main.c
 --- shell32_main.c	7 Oct 2004 03:06:48 -0000	1.139
-+++ shell32_main.c	20 Oct 2004 18:43:53 -0000
-@@ -959,7 +959,6 @@
++++ shell32_main.c	6 Dec 2004 23:45:49 -0000
+@@ -631,7 +631,8 @@
+     HFONT hFont;
+ } ABOUT_INFO;
+ 
+-#define		IDC_STATIC_TEXT		100
++#define		IDC_STATIC_TEXT1	100
++#define		IDC_STATIC_TEXT2	101
+ #define		IDC_LISTBOX		99
+ #define		IDC_WINE_TEXT		98
+ 
+@@ -754,7 +755,8 @@
+                 GetWindowTextW( hWnd, Template, sizeof(Template)/sizeof(WCHAR) );
+                 sprintfW( AppTitle, Template, info->szApp );
+                 SetWindowTextW( hWnd, AppTitle );
+-                SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT), info->szOtherStuff );
++                SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT1), info->szApp );
++                SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT2), info->szOtherStuff );
+                 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
+                 SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 );
+                 SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 );
+@@ -959,7 +961,6 @@
  	    InitCommonControlsEx(NULL);
  
  	    SIC_Initialize();
@@ -164,10 +1026,10 @@
 Index: shell32_main.h
 ===================================================================
 RCS file: /home/wine/wine/dlls/shell32/shell32_main.h,v
-retrieving revision 1.91
-diff -u -r1.91 shell32_main.h
---- shell32_main.h	22 Aug 2004 21:38:46 -0000	1.91
-+++ shell32_main.h	20 Oct 2004 18:43:53 -0000
+retrieving revision 1.92
+diff -u -r1.92 shell32_main.h
[truncated at 1000 lines; 670 more skipped]

reactos/lib/shlwapi
Makefile.ros-template 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- Makefile.ros-template	21 Oct 2004 12:02:18 -0000	1.9
+++ Makefile.ros-template	8 Dec 2004 21:57:23 -0000	1.9.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.9 2004/10/21 12:02:18 gvg Exp $
+# $Id: Makefile.ros-template,v 1.9.2.1 2004/12/08 21:57:23 hyperion Exp $
 
 TARGET_NAME = shlwapi
 
@@ -9,7 +9,7 @@
 # FIXME: we don't do delayed imports yet so oleaut32.a is listed explicitly
 # NOTE: msvcrt.a must be listed before ntdll.a, because sprintf that is
 #       exported from ntdll doesn't support printing of float types (%f)
-TARGET_SDKLIBS = msvcrt.a @IMPORTS@ oleaut32.a libwine.a wine_uuid.a libwine_unicode.a msvcrt.a ntdll.a
+TARGET_SDKLIBS = msvcrt.a @IMPORTS@ oleaut32.a wine.a wine_uuid.a wine_unicode.a msvcrt.a ntdll.a
 
 TARGET_NORC = yes
 

reactos/lib/shlwapi
clist.c 1.2 -> 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- clist.c	20 Oct 2004 16:49:27 -0000	1.2
+++ clist.c	8 Dec 2004 21:57:23 -0000	1.2.2.1
@@ -51,7 +51,7 @@
  */
 inline static LPSHLWAPI_CLIST NextItem(LPCSHLWAPI_CLIST lpList)
 {
-  const char* address = (char*)lpList;
+  const char* address = (const char*)lpList;
   address += lpList->ulSize;
   return (LPSHLWAPI_CLIST)address;
 }

reactos/lib/shlwapi
url.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- url.c	20 Oct 2004 16:49:27 -0000	1.11
+++ url.c	8 Dec 2004 21:57:23 -0000	1.11.2.1
@@ -1394,7 +1394,7 @@
   if (IsBadStringPtrA(pszUrl, -1) || IsBadWritePtr(lpDest, nDestLen))
     return E_INVALIDARG;
 
-  HashData((PBYTE)pszUrl, (int)strlen(pszUrl), lpDest, nDestLen);
+  HashData((const BYTE*)pszUrl, (int)strlen(pszUrl), lpDest, nDestLen);
   return S_OK;
 }
 

reactos/lib/string
strncpy.c 1.2 -> 1.2.34.1
diff -u -r1.2 -r1.2.34.1
--- strncpy.c	6 Jul 2003 23:04:19 -0000	1.2
+++ strncpy.c	8 Dec 2004 21:57:24 -0000	1.2.34.1
@@ -1,6 +1,6 @@
-/* $Id: strncpy.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
+/* $Id: strncpy.c,v 1.2.34.1 2004/12/08 21:57:24 hyperion Exp $
  */
-^M#include <string.h>
+#include <string.h>
 #include "tcsncpy.h"
 
 /* EOF */

reactos/lib/syssetup
syssetup.rc 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- syssetup.rc	22 Nov 2004 11:01:45 -0000	1.8
+++ syssetup.rc	8 Dec 2004 21:57:24 -0000	1.8.2.1
@@ -1,4 +1,4 @@
-/* $Id: syssetup.rc,v 1.8 2004/11/22 11:01:45 gvg Exp $ */
+/* $Id: syssetup.rc,v 1.8.2.1 2004/12/08 21:57:24 hyperion Exp $ */
 
 #include <windows.h>
 #include "resource.h"
@@ -26,7 +26,10 @@
                     "Xbox Linux - http://www.xbox-linux.org\n"\
                     "MinGW - http://www.mingw.org\n"\
                     "Bochs - http://bochs.sourceforge.net\n"\
-                    "QEMU - http://fabrice.bellard.free.fr/qemu\n"
+                    "QEMU - http://fabrice.bellard.free.fr/qemu\n"\
+                    "Mesa3D - http://www.mesa3d.org\n"\
+                    "FreeBSD - http://www.freebsd.org\n"\
+                    "adns - http://adns.jgaa.com\n"
 END
 
 IDR_GPL RT_TEXT "COPYING"

reactos/lib/syssetup
syssetup_Cz.rc 1.10 -> 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- syssetup_Cz.rc	24 Nov 2004 21:28:14 -0000	1.10
+++ syssetup_Cz.rc	8 Dec 2004 21:57:24 -0000	1.10.2.1
@@ -114,11 +114,11 @@
 BEGIN
     LTEXT "Date and Time", IDC_STATIC, 53, 7, 253, 8
     CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
-            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 29, 137, 14
+            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 17, 137, 14
     CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
-            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 29, 54, 14
-    LTEXT "Timezone", IDC_STATIC, 53, 80, 253, 8
-    COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
+            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 17, 54, 14
+    LTEXT "Timezone", IDC_STATIC, 53, 42, 253, 8
+    COMBOBOX IDC_TIMEZONELIST, 53, 52, 201, 93,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
                  IDC_AUTODAYLIGHT, 53, 124, 201, 10

reactos/lib/syssetup
syssetup_De.rc 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- syssetup_De.rc	24 Nov 2004 21:28:14 -0000	1.9
+++ syssetup_De.rc	8 Dec 2004 21:57:24 -0000	1.9.2.1
@@ -116,11 +116,11 @@
 BEGIN
     LTEXT "Datum und Zeit", IDC_STATIC, 53, 7, 253, 8
     CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
-            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 29, 137, 14
+            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 17, 137, 14
     CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
-            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 29, 54, 14
-    LTEXT "Zeitzone", IDC_STATIC, 53, 80, 253, 8
-    COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
+            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 17, 54, 14
+    LTEXT "Zeitzone", IDC_STATIC, 53, 42, 253, 8
+    COMBOBOX IDC_TIMEZONELIST, 53, 52, 201, 93,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "&Uhr automatisch auf Sommer-/Winterzeit umstellen",
                  IDC_AUTODAYLIGHT, 53, 124, 201, 10

reactos/lib/syssetup
syssetup_En.rc 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- syssetup_En.rc	24 Nov 2004 21:28:14 -0000	1.12
+++ syssetup_En.rc	8 Dec 2004 21:57:24 -0000	1.12.2.1
@@ -116,11 +116,11 @@
 BEGIN
     LTEXT "Date and Time", IDC_STATIC, 53, 7, 253, 8
     CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
-            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 29, 137, 14
+            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 17, 137, 14
     CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
-            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 29, 54, 14
-    LTEXT "Timezone", IDC_STATIC, 53, 80, 253, 8
-    COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
+            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 17, 54, 14
+    LTEXT "Timezone", IDC_STATIC, 53, 42, 253, 8
+    COMBOBOX IDC_TIMEZONELIST, 53, 52, 201, 93,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
                  IDC_AUTODAYLIGHT, 53, 124, 201, 10

reactos/lib/syssetup
syssetup_Fr.rc 1.7 -> 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- syssetup_Fr.rc	24 Nov 2004 21:28:14 -0000	1.7
+++ syssetup_Fr.rc	8 Dec 2004 21:57:24 -0000	1.7.2.1
@@ -117,11 +117,11 @@
 BEGIN
     LTEXT "Date and Time", IDC_STATIC, 53, 7, 253, 8
     CONTROL "", IDC_DATEPICKER, "SysDateTimePick32",
-            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 29, 137, 14
+            DTS_LONGDATEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 17, 137, 14
     CONTROL "", IDC_TIMEPICKER, "SysDateTimePick32",
-            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 29, 54, 14
-    LTEXT "Timezone", IDC_STATIC, 53, 80, 253, 8
-    COMBOBOX IDC_TIMEZONELIST, 53, 96, 201, 42,
+            DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 200, 17, 54, 14
+    LTEXT "Timezone", IDC_STATIC, 53, 42, 253, 8
+    COMBOBOX IDC_TIMEZONELIST, 53, 52, 201, 93,
              CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP
     AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
                  IDC_AUTODAYLIGHT, 53, 124, 201, 10

reactos/lib/syssetup
wizard.c 1.15 -> 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- wizard.c	24 Nov 2004 23:09:46 -0000	1.15
+++ wizard.c	8 Dec 2004 21:57:24 -0000	1.15.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: wizard.c,v 1.15 2004/11/24 23:09:46 ekohl Exp $
+/* $Id: wizard.c,v 1.15.2.1 2004/12/08 21:57:24 hyperion Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS system libraries
@@ -145,16 +145,15 @@
         SendMessageA(GetDlgItem(hwndDlg, IDC_GPL_TEXT), WM_SETTEXT, 0, (LPARAM) GplText);
         HeapFree(GetProcessHeap(), 0, GplText);
         SetFocus(GetDlgItem(hwndDlg, IDOK));
-	return FALSE;
-        break;
+        return FALSE;
 
       case WM_CLOSE:
         EndDialog(hwndDlg, IDCANCEL);
         break;
 
       case WM_COMMAND:
-	if (HIWORD(wParam) == BN_CLICKED && IDOK == LOWORD(wParam))
-	  {
+        if (HIWORD(wParam) == BN_CLICKED && IDOK == LOWORD(wParam))
+          {
             EndDialog(hwndDlg, IDOK);
           }
         break;
@@ -251,7 +250,7 @@
         {
           Projects = NULL;
           ProjectsSize = 256;
-	  do
+          do
             {
               Projects = HeapAlloc(GetProcessHeap(), 0, ProjectsSize * sizeof(WCHAR));
               if (NULL == Projects)
@@ -573,6 +572,7 @@
 #endif
 }
 
+
 static VOID
 RunInputLocalePage(HWND hwnd)
 {
@@ -883,7 +883,7 @@
   SetupData->TimeZoneListTail = NULL;
 }
 
-
+#if 0
 static BOOL
 GetTimeZoneListIndex(LPDWORD lpIndex)
 {
@@ -984,6 +984,7 @@
 
   return FALSE;
 }
+#endif
 
 
 static VOID
@@ -994,7 +995,10 @@
   DWORD dwEntryIndex = 0;
   DWORD dwCount;
 
+#if 0
   GetTimeZoneListIndex(&dwEntryIndex);
+#endif
+  dwEntryIndex = 85; /* GMT time zone */
 
   Entry = SetupData->TimeZoneListHead;
   while (Entry != NULL)
@@ -1381,13 +1385,13 @@
   ahpsp[5] = CreatePropertySheetPage(&psp);
 
 
-  /* Create the Process page */
+  /* Create the Process page 
   psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
   psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_PROCESSTITLE);
   psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE);
   psp.pfnDlgProc = ProcessPageDlgProc;
   psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE);
-  ahpsp[6] = CreatePropertySheetPage(&psp);
+  ahpsp[6] = CreatePropertySheetPage(&psp); */
 
 
   /* Create the Finish page */

reactos/lib/twain
Makefile 1.7 -> 1.7.16.1
diff -u -r1.7 -r1.7.16.1
--- Makefile	29 May 2004 21:24:47 -0000	1.7
+++ Makefile	8 Dec 2004 21:57:24 -0000	1.7.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.7 2004/05/29 21:24:47 hbirr Exp $
+# $Id: Makefile,v 1.7.16.1 2004/12/08 21:57:24 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -11,7 +11,7 @@
 
 TARGET_BASE=$(TARGET_BASE_LIB_TWAIN_32)
 
-TARGET_SDKLIBS = ntdll.a libwine.a
+TARGET_SDKLIBS = ntdll.a wine.a
 
 TARGET_OBJECTS = \
 	capability.o \

reactos/lib/unicode
Makefile.ros-template 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Makefile.ros-template	2 Nov 2004 19:47:18 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:24 -0000	1.3.2.1
@@ -1,6 +1,6 @@
-# $Id: Makefile.ros-template,v 1.3 2004/11/02 19:47:18 gvg Exp $
+# $Id: Makefile.ros-template,v 1.3.2.1 2004/12/08 21:57:24 hyperion Exp $
 
-TARGET_NAME = libwine_unicode
+TARGET_NAME = wine_unicode
 
 CODEPAGES = @CODEPAGES@
 

reactos/lib/unicode
cptable.c 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- cptable.c	12 Mar 2004 21:04:04 -0000	1.2
+++ cptable.c	8 Dec 2004 21:57:24 -0000	1.2.20.1
@@ -154,7 +154,7 @@
 
 static int cmp_codepage( const void *codepage, const void *entry )
 {
-    return (unsigned int)codepage - (*(union cptable **)entry)->info.codepage;
+    return (unsigned int)codepage - (*(const union cptable **)entry)->info.codepage;
 }
 
 

reactos/lib/unicode
wctomb.c 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- wctomb.c	12 Mar 2004 21:04:04 -0000	1.2
+++ wctomb.c	8 Dec 2004 21:57:24 -0000	1.2.20.1
@@ -142,7 +142,7 @@
         ret = -1;
     }
 
-    if (dst <= (char *)src && dst + 16 > (char *)src)
+    if (dst <= (const char *)src && dst + 16 > (const char *)src)
     {
         /* overlapping buffers, do it char by char */
         while (srclen--)

reactos/lib/unicode
wine_unicode.def 1.4 -> 1.4.18.1
diff -u -r1.4 -r1.4.18.1
--- wine_unicode.def	16 Apr 2004 08:58:34 -0000	1.4
+++ wine_unicode.def	8 Dec 2004 21:57:24 -0000	1.4.18.1
@@ -1,4 +1,4 @@
-LIBRARY libwine_unicode.dll
+LIBRARY wine_unicode.dll
 
 EXPORTS
     memicmpW

reactos/lib/urlmon
Makefile.ros-template 1.2 -> 1.2.8.1
diff -u -r1.2 -r1.2.8.1
--- Makefile.ros-template	14 Aug 2004 20:43:40 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:24 -0000	1.2.8.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/08/14 20:43:40 sedwards Exp $
+# $Id: Makefile.ros-template,v 1.2.8.1 2004/12/08 21:57:24 hyperion Exp $
 
 TARGET_NAME = urlmon
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a wininet.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a wininet.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_RICHEDIT)
 

reactos/lib/user32
Makefile 1.40 -> 1.40.8.1
diff -u -r1.40 -r1.40.8.1
--- Makefile	17 Aug 2004 21:47:36 -0000	1.40
+++ Makefile	8 Dec 2004 21:57:26 -0000	1.40.8.1
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.40 2004/08/17 21:47:36 weiden Exp $
+# $Id: Makefile,v 1.40.8.1 2004/12/08 21:57:26 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -10,7 +10,7 @@
 
 TARGET_BASE = $(TARGET_BASE_LIB_USER32)
 
-TARGET_SDKLIBS = libwine.a ntdll.a gdi32.a rosrtl.a kernel32.a advapi32.a
+TARGET_SDKLIBS = wine.a ntdll.a gdi32.a rosrtl.a kernel32.a advapi32.a
 
 TARGET_CFLAGS = \
  -I./include \

reactos/lib/user32/controls
combo.c 1.19 -> 1.19.8.1
diff -u -r1.19 -r1.19.8.1
--- combo.c	15 Aug 2004 21:36:26 -0000	1.19
+++ combo.c	8 Dec 2004 21:57:26 -0000	1.19.8.1
@@ -2003,6 +2003,11 @@
 		   CBRollUp( lphc, wParam == VK_RETURN, FALSE );
 		   return TRUE;
 		}
+		else if ((wParam == VK_F4) && !(lphc->wState & CBF_EUI))
+		{
+		   COMBO_FlipListbox( lphc, FALSE, FALSE );
+		   return TRUE;
+		}
 
 		if( lphc->wState & CBF_EDIT )
 		    hwndTarget = lphc->hWndEdit;

reactos/lib/user32/controls
edit.c 1.27 -> 1.27.8.1
diff -u -r1.27 -r1.27.8.1
--- edit.c	15 Aug 2004 21:36:26 -0000	1.27
+++ edit.c	8 Dec 2004 21:57:26 -0000	1.27.8.1
@@ -2245,13 +2245,39 @@
  */
 static void EDIT_SetRectNP(EDITSTATE *es, LPRECT rc)
 {
+	RECT ClientRect;
+	LONG_PTR ExStyle;
+
 	CopyRect(&es->format_rect, rc);
-	if (es->style & WS_BORDER) {
-		INT bw = GetSystemMetrics(SM_CXBORDER) + 1;
-		es->format_rect.left += bw;
-		es->format_rect.top += bw;
-		es->format_rect.right -= bw;
-		es->format_rect.bottom -= bw;
+	if (es->style & ES_MULTILINE)
+	{
+		if (es->style & WS_BORDER) {
+			INT bw = GetSystemMetrics(SM_CXBORDER) + 1;
+			es->format_rect.left += bw;
+			es->format_rect.right -= bw;
+			es->format_rect.top += bw;
+			es->format_rect.bottom -= bw;
+		}
+	}
+	else
+	{
+		ExStyle = GetWindowLongPtrW(es->hwndSelf, GWL_EXSTYLE);
+		if (ExStyle & WS_EX_CLIENTEDGE) {
+			if (es->line_height + 2 <=
+			    es->format_rect.bottom - es->format_rect.top) {
+				es->format_rect.top++;
+				es->format_rect.bottom--;
+			}
+		} else if (es->style & WS_BORDER) {
+			INT bw = GetSystemMetrics(SM_CXBORDER) + 1;
+			es->format_rect.left += bw;
+			es->format_rect.right -= bw;
+			if (es->line_height + 2 * bw <=
+			    es->format_rect.bottom - es->format_rect.top) {
+				es->format_rect.top += bw;
+				es->format_rect.bottom -= bw;
+			}
+		}
 	}
 	es->format_rect.left += es->left_margin;
 	es->format_rect.right -= es->right_margin;
@@ -2283,6 +2309,10 @@
 	/* Windows doesn't care to fix text placement for SL controls */
 		es->format_rect.bottom = es->format_rect.top + es->line_height;
 
+	/* Always stay within the client area */
+	GetClientRect(es->hwndSelf, &ClientRect);
+	es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
+
 	if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
 		EDIT_BuildLineDefs_ML(es, 0, strlenW(es->text), 0, NULL);
 }

reactos/lib/user32/misc
misc.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- misc.c	20 Nov 2004 15:51:14 -0000	1.9
+++ misc.c	8 Dec 2004 21:57:26 -0000	1.9.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: misc.c,v 1.9 2004/11/20 15:51:14 ekohl Exp $
+/* $Id: misc.c,v 1.9.2.1 2004/12/08 21:57:26 hyperion Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/misc/misc.c
@@ -106,12 +106,12 @@
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL WINAPI
-UpdatePerUserSystemParameters(DWORD dwUnknown,
-                              BOOL bEnable)
+UpdatePerUserSystemParameters(
+   DWORD dwReserved,
+   BOOL bEnable)
 {
-
-  return TRUE;
+   return NtUserUpdatePerUserSystemParameters(dwReserved, bEnable);
 }

reactos/lib/user32/windows
class.c 1.51 -> 1.51.8.1
diff -u -r1.51 -r1.51.8.1
--- class.c	15 Aug 2004 21:36:29 -0000	1.51
+++ class.c	8 Dec 2004 21:57:27 -0000	1.51.8.1
@@ -1,4 +1,4 @@
-/* $Id: class.c,v 1.51 2004/08/15 21:36:29 chorns Exp $
+/* $Id: class.c,v 1.51.8.1 2004/12/08 21:57:27 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -464,8 +464,10 @@
       REGISTERCLASS_ANSI,
       0);
 
-   RtlFreeUnicodeString(&MenuName);
-   RtlFreeUnicodeString(&ClassName);
+   if (!IS_ATOM(lpwcx->lpszMenuName))
+      RtlFreeUnicodeString(&MenuName);
+   if (!IS_ATOM(lpwcx->lpszClassName))
+      RtlFreeUnicodeString(&ClassName);
 
    return (ATOM)Atom;
 }

reactos/lib/user32/windows
draw.c 1.43 -> 1.43.2.1
diff -u -r1.43 -r1.43.2.1
--- draw.c	9 Nov 2004 14:59:37 -0000	1.43
+++ draw.c	8 Dec 2004 21:57:27 -0000	1.43.2.1
@@ -40,9 +40,6 @@
 #include <user32.h>
 #include <debug.h>
 
-#define COLOR_MENUHILIGHT	(29)
-#define COLOR_MENUBAR	(30)
-
 /* GLOBALS *******************************************************************/
 
 #define	DSS_DEFAULT	0x0040  /* Make it bold */

reactos/lib/user32/windows
font.c 1.11 -> 1.11.8.1
diff -u -r1.11 -r1.11.8.1
--- font.c	15 Aug 2004 21:36:29 -0000	1.11
+++ font.c	8 Dec 2004 21:57:27 -0000	1.11.8.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: font.c,v 1.11 2004/08/15 21:36:29 chorns Exp $
+/* $Id: font.c,v 1.11.8.1 2004/12/08 21:57:27 hyperion Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/input.c
@@ -991,7 +991,7 @@
     const WCHAR *strPtr;
     WCHAR *retstr, *p_retstr;
     size_t size_retstr;
-    static WCHAR line[MAX_STATIC_BUFFER];
+    WCHAR line[MAX_STATIC_BUFFER];
     int len, lh, count=i_count;
     TEXTMETRICW tm;
     int lmargin = 0, rmargin = 0;

reactos/lib/user32/windows
mdi.c 1.16 -> 1.16.8.1
diff -u -r1.16 -r1.16.8.1
--- mdi.c	2 Aug 2004 03:03:10 -0000	1.16
+++ mdi.c	8 Dec 2004 21:57:27 -0000	1.16.8.1
@@ -1137,7 +1137,8 @@
     hSysMenuBitmap = hBmpClose;
 #endif
 
-    if( !InsertMenuA(menu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP,
+    if(  hSysMenuBitmap != NULL &&
+         !InsertMenuA(menu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP,
                      (UINT_PTR)hSysPopup, (LPSTR)hSysMenuBitmap))
     {
         TRACE("not inserted\n");
@@ -1307,7 +1308,7 @@
 {
     MDICLIENTINFO *ci = NULL;
 
-    if (WM_NCCREATE != message && WM_CREATE != message
+    if (WM_NCCREATE != message
         && NULL == (ci = get_client_info(hwnd)))
     {
         return 0;
@@ -1332,12 +1333,6 @@
 #ifndef __REACTOS__
           WND *wndPtr = WIN_GetPtr( hwnd );
 #endif
-	ci = HeapAlloc(GetProcessHeap(), 0, sizeof(MDICLIENTINFO));
-	if (NULL == ci)
-	{
-	    return -1;
-	}
-	SetWindowLongPtr(hwnd, 0, (LONG_PTR) ci);
 
 	/* Translation layer doesn't know what's in the cs->lpCreateParams
 	 * so we have to keep track of what environment we're in. */
@@ -2139,14 +2134,14 @@
 			info.nMin = childRect.left;
 			info.nMax = childRect.right - clientRect.right;
 			info.nPos = clientRect.left - childRect.left;
-			SetScrollInfo(hwnd, scroll, &info, TRUE);
+			SetScrollInfo(hwnd, SB_HORZ, &info, TRUE);
 			if (scroll == SB_HORZ) break;
 			/* fall through */
 	case SB_VERT:
 			info.nMin = childRect.top;
 			info.nMax = childRect.bottom - clientRect.bottom;
 			info.nPos = clientRect.top - childRect.top;
-			SetScrollInfo(hwnd, scroll, &info, TRUE);
+			SetScrollInfo(hwnd, SB_VERT, &info, TRUE);
 			break;
     }
 }

reactos/lib/user32/windows
menu.c 1.71 -> 1.71.6.1
diff -u -r1.71 -r1.71.6.1
--- menu.c	14 Sep 2004 01:30:02 -0000	1.71
+++ menu.c	8 Dec 2004 21:57:27 -0000	1.71.6.1
@@ -21,7 +21,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: menu.c,v 1.71 2004/09/14 01:30:02 weiden Exp $
+/* $Id: menu.c,v 1.71.6.1 2004/12/08 21:57:27 hyperion Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/menu.c
@@ -4074,7 +4074,7 @@
 
     res = NtUserInsertMenuItem(hMenu, uItem, fByPosition, &mi);
 
-    if ( CleanHeap ) HEAP_free ( mi.dwTypeData );
+    if ( CleanHeap ) HEAP_free ( MenuText.Buffer );
   }
   return res;
 }
@@ -4094,8 +4094,6 @@
   MENUITEMINFOW mi;
   UNICODE_STRING MenuText;
   BOOL res = FALSE;
-  BOOL CleanHeap = FALSE;
-  HANDLE hHeap = GetProcessHeap();
   mi.hbmpItem = (HBITMAP)0;
 
   // while we could just pass 'lpmii' to win32k, we make a copy so that
@@ -4113,20 +4111,13 @@
     {
       if(lpmii->cch > 0)
       {
-        if(!RtlCreateUnicodeString(&MenuText, (PWSTR)lpmii->dwTypeData))
-        {
-          SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY));
-          return FALSE;
-        }
+        RtlInitUnicodeString(&MenuText, (PWSTR)lpmii->dwTypeData);
         mi.dwTypeData = (LPWSTR)&MenuText;
         mi.cch = MenuText.Length / sizeof(WCHAR);
-        CleanHeap = TRUE;
       }
     };
     
     res = NtUserInsertMenuItem(hMenu, uItem, fByPosition, &mi);
-    
-    if(CleanHeap) RtlFreeHeap (hHeap, 0, mi.dwTypeData);
   }
   return res;
 }
@@ -4437,8 +4428,34 @@
   BOOL fByPosition,
   LPCMENUITEMINFOA lpmii)
 {
-  UNIMPLEMENTED;
-  return FALSE;
+  MENUITEMINFOW MenuItemInfoW;
+  UNICODE_STRING UnicodeString;
+  ULONG Result;
+
+  RtlCopyMemory(&MenuItemInfoW, lpmii, min(lpmii->cbSize, sizeof(MENUITEMINFOW)));
+
+  if ((MenuItemInfoW.fMask & (MIIM_TYPE | MIIM_STRING)) &&
+      (MENU_ITEM_TYPE(MenuItemInfoW.fType) == MF_STRING) &&
+      MenuItemInfoW.dwTypeData)
+  {
+    RtlCreateUnicodeStringFromAsciiz(&UnicodeString,
+                                     (LPSTR)MenuItemInfoW.dwTypeData);
+    MenuItemInfoW.dwTypeData = (LPWSTR)&UnicodeString;
+  }
+  else
+  {
+    UnicodeString.Buffer = NULL;
+  }
+
+  Result = NtUserMenuItemInfo(hMenu, uItem, fByPosition,
+                              (PROSMENUITEMINFO)&MenuItemInfoW, TRUE);
+
+  if (UnicodeString.Buffer != NULL)
+  {
+    RtlFreeUnicodeString(&UnicodeString);
+  }
+
+  return Result;
 }
 
 
@@ -4453,8 +4470,21 @@
   BOOL fByPosition,
   LPCMENUITEMINFOW lpmii)
 {
-  UNIMPLEMENTED;
-  return FALSE;
+  MENUITEMINFOW MenuItemInfoW;
+  UNICODE_STRING UnicodeString;
+
+  RtlCopyMemory(&MenuItemInfoW, lpmii, min(lpmii->cbSize, sizeof(MENUITEMINFOW)));
+
+  if ((MenuItemInfoW.fMask & (MIIM_TYPE | MIIM_STRING)) &&
+      (MENU_ITEM_TYPE(MenuItemInfoW.fType) == MF_STRING) &&
+      MenuItemInfoW.dwTypeData)
+  {
+    RtlInitUnicodeString(&UnicodeString, MenuItemInfoW.dwTypeData);
+    MenuItemInfoW.dwTypeData = (LPWSTR)&UnicodeString;
+  }
+
+  return NtUserMenuItemInfo(hMenu, uItem, fByPosition,
+                            (PROSMENUITEMINFO)&MenuItemInfoW, TRUE);
 }
 
 /*

reactos/lib/user32/windows
message.c 1.43 -> 1.43.6.1
diff -u -r1.43 -r1.43.6.1
--- message.c	31 Aug 2004 23:32:01 -0000	1.43
+++ message.c	8 Dec 2004 21:57:28 -0000	1.43.6.1
@@ -1,4 +1,4 @@
-/* $Id: message.c,v 1.43 2004/08/31 23:32:01 gvg Exp $
+/* $Id: message.c,v 1.43.6.1 2004/12/08 21:57:28 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -594,7 +594,7 @@
                 }
               CsA->lpszClass = AString.Buffer;
             }
-          UnicodeMsg->lParam = (LPARAM)CsA;
+          AnsiMsg->lParam = (LPARAM)CsA;
           break;
         }
       case WM_GETTEXT:
@@ -681,13 +681,13 @@
         if (0 < AnsiMsg->wParam &&
             ! MultiByteToWideChar(CP_ACP, 0, Buffer, -1, UBuffer, UnicodeMsg->wParam))
           {
-            UBuffer[AnsiMsg->wParam - 1] = L'\0';
+            UBuffer[UnicodeMsg->wParam - 1] = L'\0';
           }
         break;
       }
     }
 
-  MsgiUnicodeToAnsiCleanup(UnicodeMsg, AnsiMsg);
+  MsgiUnicodeToAnsiCleanup(AnsiMsg, UnicodeMsg);
 
   return TRUE;
 }

reactos/lib/userenv
environment.c 1.8 -> 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- environment.c	10 Oct 2004 18:26:33 -0000	1.8
+++ environment.c	8 Dec 2004 21:57:28 -0000	1.8.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: environment.c,v 1.8 2004/10/10 18:26:33 ekohl Exp $
+/* $Id: environment.c,v 1.8.2.1 2004/12/08 21:57:28 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -34,15 +34,16 @@
 			    LPWSTR lpValue,
 			    BOOL bExpand)
 {
-  WCHAR ShortName[MAX_PATH];
-  UNICODE_STRING Name;
-  UNICODE_STRING SrcValue;
-  UNICODE_STRING DstValue;
-  ULONG Length;
-  NTSTATUS Status;
+   WCHAR ShortName[MAX_PATH];
+   UNICODE_STRING Name;
+   UNICODE_STRING SrcValue;
+   UNICODE_STRING DstValue;
+   ULONG Length;
+   NTSTATUS Status;
+   PVOID Buffer=NULL;
 
-  if (bExpand)
-    {
+   if (bExpand)
+   {
       RtlInitUnicodeString(&SrcValue,
 			   lpValue);
 
@@ -50,43 +51,46 @@
 
       DstValue.Length = 0;
       DstValue.MaximumLength = Length;
-      DstValue.Buffer = LocalAlloc(LPTR,
-				   Length);
+      DstValue.Buffer = Buffer = LocalAlloc(LPTR, 
+         Length);
+         
       if (DstValue.Buffer == NULL)
-	{
-	  DPRINT1("LocalAlloc() failed\n");
-	  return FALSE;
-	}
+      {
+         DPRINT1("LocalAlloc() failed\n");
+         return FALSE;
+      }
 
       Status = RtlExpandEnvironmentStrings_U((PWSTR)*Environment,
 					     &SrcValue,
 					     &DstValue,
 					     &Length);
       if (!NT_SUCCESS(Status))
-	{
-	  DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
-	  DPRINT1("Length %lu\n", Length);
-	  return FALSE;
-	}
-    }
-  else
-    {
+      {
+         DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
+         DPRINT1("Length %lu\n", Length);
+         if (Buffer) LocalFree(Buffer);
+         return FALSE;
+      }
+   }
+   else
+   {
       RtlInitUnicodeString(&DstValue,
 			   lpValue);
-    }
+   }
 
-  if (!_wcsicmp (lpName, L"temp") || !_wcsicmp (lpName, L"tmp"))
-    {
+   if (!_wcsicmp (lpName, L"temp") || !_wcsicmp (lpName, L"tmp"))
+   {
       if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH))
-	{
-	  DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError());
-	  return FALSE;
-	}
+      {
+         DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError());
+         if (Buffer) LocalFree(Buffer);
+         return FALSE;
+      }
 
       DPRINT("Buffer: %S\n", ShortName);
       RtlInitUnicodeString(&DstValue,
 			   ShortName);
-    }
+   }
 
   RtlInitUnicodeString(&Name,
 		       lpName);
@@ -97,11 +101,8 @@
 				     &Name,
 				     &DstValue);
 
-  if (bExpand)
-    {
-      LocalFree(DstValue.Buffer);
-    }
-
+  if (Buffer) LocalFree(Buffer);
+   
   if (!NT_SUCCESS(Status))
     {
       DPRINT1("RtlSetEnvironmentVariable() failed (Status %lx)\n", Status);

reactos/lib/uuid
uuid.c 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- uuid.c	20 Sep 2004 19:47:13 -0000	1.2
+++ uuid.c	8 Dec 2004 21:57:28 -0000	1.2.6.1
@@ -82,3 +82,8 @@
 DEFINE_GUID(FMTID_SummaryInformation,0xF29F85E0,0x4FF9,0x1068,0xAB,0x91,0x08,0x00,0x2B,0x27,0xB3,0xD9);
 DEFINE_GUID(FMTID_DocSummaryInformation,0xD5CDD502,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE);
 DEFINE_GUID(FMTID_UserDefinedProperties,0xD5CDD505,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE);
+
+DEFINE_OLEGUID(IID_StdOle,0x00020430,0,0);
+
+DEFINE_GUID(CLSID_StdFont,0x0be35203,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51);
+DEFINE_GUID(CLSID_StdPicture,0x0be35204,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51);

reactos/lib/version
makefile 1.15 -> 1.15.16.1
diff -u -r1.15 -r1.15.16.1
--- makefile	29 May 2004 21:24:47 -0000	1.15
+++ makefile	8 Dec 2004 21:57:28 -0000	1.15.16.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.15 2004/05/29 21:24:47 hbirr Exp $
+# $Id: makefile,v 1.15.16.1 2004/12/08 21:57:28 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -27,7 +27,7 @@
 
 TARGET_LFLAGS = -nostdlib -nostartfiles
 
-TARGET_SDKLIBS = libwine.a kernel32.a ntdll.a 
+TARGET_SDKLIBS = wine.a kernel32.a ntdll.a
 
 TARGET_OBJECTS = \
 	misc/libmain.o \

reactos/lib/winmm
Makefile.ros-template 1.3 -> 1.3.16.1
diff -u -r1.3 -r1.3.16.1
--- Makefile.ros-template	29 May 2004 21:24:47 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:28 -0000	1.3.16.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/05/29 21:24:47 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3.16.1 2004/12/08 21:57:28 hyperion Exp $
 
 TARGET_NAME = winmm
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_BASE_LIB_WINMM)
 

reactos/lib/winmm
lolvldrv.c 1.7 -> 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- lolvldrv.c	19 Sep 2004 11:07:39 -0000	1.7
+++ lolvldrv.c	8 Dec 2004 21:57:28 -0000	1.7.6.1
@@ -85,7 +85,7 @@
     llTypes[drv].Map16To32A   = mp1632;
     llTypes[drv].UnMap16To32A = um1632;
     llTypes[drv].Map32ATo16   = mp3216;
-    llTypes[drv].UnMap32ATo16 = um1632;
+    llTypes[drv].UnMap32ATo16 = um3216;
     llTypes[drv].Callback     = cb;
 }
 
@@ -561,6 +561,9 @@
     }
 
     TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr);
+    
+    if (HIWORD(count))
+        return FALSE;
 
     /* got some drivers */
     if (lpDrv->bIsMapper) {

reactos/lib/winmm
mci.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- mci.c	19 Sep 2004 11:07:39 -0000	1.5
+++ mci.c	8 Dec 2004 21:57:28 -0000	1.5.6.1
@@ -248,8 +248,8 @@
 	do {
 	    str = lmem;
 	    lmem += strlen(lmem) + 1;
-	    flg = *(LPDWORD)lmem;
-	    eid = *(LPWORD)(lmem + sizeof(DWORD));
+	    flg = *(const DWORD*)lmem;
+	    eid = *(const WORD*)(lmem + sizeof(DWORD));
 	    lmem += sizeof(DWORD) + sizeof(WORD);
 	    idx ++;
 	    /* EPP 	    TRACE("cmd='%s' %08lx %04x\n", str, flg, eid); */
@@ -291,8 +291,8 @@
 	do {
 	    str = lmem;
 	    lmem += strlen(lmem) + 1;
-	    flg = *(LPDWORD)lmem;
-	    eid = *(LPWORD)(lmem + sizeof(DWORD));
+	    flg = *(const DWORD*)lmem;
+	    eid = *(const WORD*)(lmem + sizeof(DWORD));
 	    TRACE("cmd='%s' %08lx %04x\n", str, flg, eid);
 	    lmem += sizeof(DWORD) + sizeof(WORD);
 	} while (eid != MCI_END_COMMAND && eid != MCI_END_COMMAND_LIST);
@@ -379,7 +379,7 @@
 	    count = 0;
 	    do {
 		lmem += strlen(lmem) + 1;
-		eid = *(LPWORD)(lmem + sizeof(DWORD));
+		eid = *(const WORD*)(lmem + sizeof(DWORD));
 		lmem += sizeof(DWORD) + sizeof(WORD);
 		if (eid == MCI_COMMAND_HEAD)
 		    count++;
@@ -393,7 +393,7 @@
 	    do {
 		str = lmem;
 		lmem += strlen(lmem) + 1;
-		eid = *(LPWORD)(lmem + sizeof(DWORD));
+		eid = *(const WORD*)(lmem + sizeof(DWORD));
 		lmem += sizeof(DWORD) + sizeof(WORD);
 		if (eid == MCI_COMMAND_HEAD)
 		    S_MciCmdTable[uTbl].aVerbs[count++] = str;
@@ -619,8 +619,8 @@
 static	DWORD		MCI_GetReturnType(LPCSTR lpCmd)
 {
     lpCmd += strlen(lpCmd) + 1 + sizeof(DWORD) + sizeof(WORD);
-    if (*lpCmd == '\0' && *(LPWORD)(lpCmd + 1 + sizeof(DWORD)) == MCI_RETURN) {
-	return *(LPDWORD)(lpCmd + 1);
+    if (*lpCmd == '\0' && *(const WORD*)(lpCmd + 1 + sizeof(DWORD)) == MCI_RETURN) {
+	return *(const DWORD*)(lpCmd + 1);
     }
     return 0L;
 }
@@ -630,7 +630,7 @@
  */
 static	WORD		MCI_GetMessage(LPCSTR lpCmd)
 {
-    return (WORD)*(LPDWORD)(lpCmd + strlen(lpCmd) + 1);
+    return (WORD)*(const DWORD*)(lpCmd + strlen(lpCmd) + 1);
 }
 
 /**************************************************************************
@@ -712,8 +712,8 @@
 	do { /* loop on options for command table for the requested verb */
 	    str = lmem;
 	    lmem += (len = strlen(lmem)) + 1;
-	    flg = *(LPDWORD)lmem;
-	    eid = *(LPWORD)(lmem + sizeof(DWORD));
+	    flg = *(const DWORD*)lmem;
+	    eid = *(const WORD*)(lmem + sizeof(DWORD));
 	    lmem += sizeof(DWORD) + sizeof(WORD);
 /* EPP 	    TRACE("\tcmd='%s' inCst=%c eid=%04x\n", str, inCst ? 'Y' : 'N', eid); */
 

reactos/lib/winmm
mmsystem.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- mmsystem.c	20 Oct 2004 17:42:11 -0000	1.3
+++ mmsystem.c	8 Dec 2004 21:57:29 -0000	1.3.2.1
@@ -1893,7 +1893,7 @@
     return (WINE_MMTHREAD*)MapSL( MAKESEGPTR(h, 0) );
 }
 
-void WINAPI WINE_mmThreadEntryPoint(DWORD);
+DWORD WINAPI WINE_mmThreadEntryPoint(LPVOID);
 
 /**************************************************************************
  * 				mmThreadCreate		[MMSYSTEM.1120]
@@ -1951,8 +1951,8 @@
 		/* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
 	    }
 
-	    lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint,
-					    (LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
+	    lpMMThd->hThread = CreateThread(0, 0, WINE_mmThreadEntryPoint,
+					    (LPVOID)(DWORD_PTR)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
 	    if (lpMMThd->hThread == 0) {
 		WARN("Couldn't create thread\n");
 		/* clean-up(VxDhandle...); devicedirectio... */
@@ -2143,9 +2143,9 @@
 /**************************************************************************
  * 			        __wine_mmThreadEntryPoint (MMSYSTEM.2047)
  */
-void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt)
+DWORD WINAPI WINE_mmThreadEntryPoint(LPVOID p)
 {
-    HANDLE16		hndl = (HANDLE16)_pmt;
+    HANDLE16		hndl = (HANDLE16)(DWORD_PTR)p;
     WINE_MMTHREAD*	lpMMThd = WINMM_GetmmThread(hndl);
 
     TRACE("(%04x %p)\n", hndl, lpMMThd);
@@ -2173,6 +2173,8 @@
 	CloseHandle(lpMMThd->hEvent);
     GlobalFree16(hndl);
     TRACE("done\n");
+
+    return 0;
 }
 
 typedef	BOOL16 (WINAPI *MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);

reactos/lib/winmm
playsound.c 1.4 -> 1.4.16.1
diff -u -r1.4 -r1.4.16.1
--- playsound.c	16 Jun 2004 18:48:46 -0000	1.4
+++ playsound.c	8 Dec 2004 21:57:29 -0000	1.4.16.1
@@ -72,7 +72,7 @@
     static const WCHAR  wszNull[] = {0};
 
     TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
-    GetProfileStringW(wszSounds, (LPWSTR)lpszName, wszNull, str, sizeof(str)/sizeof(str[0]));
+    GetProfileStringW(wszSounds, lpszName, wszNull, str, sizeof(str)/sizeof(str[0]));
     if (lstrlenW(str) == 0)
     {
 	if (uFlags & SND_NODEFAULT) goto next;
@@ -420,7 +420,7 @@
     return bRet;
 }
 
-BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
+static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
 {
     WINE_PLAYSOUND*     wps = NULL;
 

reactos/lib/winmm
time.c 1.5 -> 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- time.c	20 Oct 2004 17:42:11 -0000	1.5
+++ time.c	8 Dec 2004 21:57:29 -0000	1.5.2.1
@@ -242,18 +242,7 @@
 	sleep_time = TIME_MMSysTimeCallback(iData);
 
         if (sleep_time == 0)
-        {
-            /* This Sleep is controversial; it was added to make
-               Wine able to replicate a high speed (e.g. 1 ms)
-               timer event where the called event routine chews
-               a lot of CPU.  This is required because of the
-               bias some Linux kernel versions have against threads that
-               chew a lot of the CPU; this Sleep(0) yields enough
-               in that spin case doesn't trigger the bias.
-               Further, it should do no harm, but an fyi.  */
-            Sleep(0);
             continue;
-        }
 
         rc = WaitForSingleObject(TIME_hWakeEvent, sleep_time);
         if (rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)

reactos/lib/winmm
winehq2ros.patch 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- winehq2ros.patch	20 Oct 2004 17:42:11 -0000	1.9
+++ winehq2ros.patch	8 Dec 2004 21:57:29 -0000	1.9.2.1
@@ -1,11 +1,16 @@
+? Makefile
+? Makefile.ros
+? Makefile.ros-template
+? winehq2ros.patch
+? winmm.spec.def
 Index: lolvldrv.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v
-retrieving revision 1.61
-diff -u -r1.61 lolvldrv.c
---- lolvldrv.c	22 Sep 2004 04:00:14 -0000	1.61
-+++ lolvldrv.c	20 Oct 2004 17:54:30 -0000
-@@ -758,11 +758,18 @@
+retrieving revision 1.62
+diff -u -r1.62 lolvldrv.c
+--- lolvldrv.c	1 Dec 2004 15:32:19 -0000	1.62
++++ lolvldrv.c	7 Dec 2004 21:01:01 -0000
+@@ -761,11 +761,18 @@
  {
      TRACE("()\n");
      /* first load hardware drivers */
@@ -29,10 +34,10 @@
 Index: winmm.c
 ===================================================================
 RCS file: /home/wine/wine/dlls/winmm/winmm.c,v
-retrieving revision 1.45
-diff -u -r1.45 winmm.c
---- winmm.c	19 Oct 2004 23:55:15 -0000	1.45
-+++ winmm.c	20 Oct 2004 17:54:32 -0000
+retrieving revision 1.46
+diff -u -r1.46 winmm.c
+--- winmm.c	21 Nov 2004 15:37:04 -0000	1.46
++++ winmm.c	7 Dec 2004 21:01:02 -0000
 @@ -94,7 +94,9 @@
  	return FALSE;
      WINMM_IData->hWinMM32Instance = hInstDLL;
@@ -56,13 +61,44 @@
                  loaded = 1;
          }
      }
+@@ -669,7 +673,7 @@
+ /**************************************************************************
+  * 				mixerMessage		[WINMM.@]
+  */
+-UINT WINAPI mixerMessage(HMIXER hmix, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
++DWORD WINAPI mixerMessage(HMIXER hmix, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
+ {
+     LPWINE_MLD		wmld;
+ 
+@@ -2669,8 +2673,8 @@
+  *			waveOutOpen			[WINMM.@]
+  * All the args/structs have the same layout as the win16 equivalents
+  */
+-UINT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
+-                       const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
++MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
++                       LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
+                        DWORD_PTR dwInstance, DWORD dwFlags)
+ {
+     return WAVE_Open((HANDLE*)lphWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
+@@ -3054,8 +3058,8 @@
+ /**************************************************************************
+  * 				waveInOpen			[WINMM.@]
+  */
+-UINT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
+-		       const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
++MMRESULT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
++		       LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
+ 		       DWORD_PTR dwInstance, DWORD dwFlags)
+ {
+     return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
 Index: winmm_res.rc
 ===================================================================
 RCS file: /home/wine/wine/dlls/winmm/winmm_res.rc,v
 retrieving revision 1.17
 diff -u -r1.17 winmm_res.rc
 --- winmm_res.rc	16 Aug 2004 20:02:09 -0000	1.17
-+++ winmm_res.rc	20 Oct 2004 17:54:32 -0000
++++ winmm_res.rc	7 Dec 2004 21:01:03 -0000
 @@ -34,7 +34,7 @@
  #include "winmm_Es.rc"
  #include "winmm_Fr.rc"

reactos/lib/winmm
winmm.c 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- winmm.c	20 Oct 2004 17:42:11 -0000	1.14
+++ winmm.c	8 Dec 2004 21:57:29 -0000	1.14.2.1
@@ -171,6 +171,15 @@
     ERR_TO_STR(MMSYSERR_BADERRNUM);
     ERR_TO_STR(MMSYSERR_INVALFLAG);
     ERR_TO_STR(MMSYSERR_INVALPARAM);
+    ERR_TO_STR(MMSYSERR_HANDLEBUSY);
+    ERR_TO_STR(MMSYSERR_INVALIDALIAS);
+    ERR_TO_STR(MMSYSERR_BADDB);
+    ERR_TO_STR(MMSYSERR_KEYNOTFOUND);
+    ERR_TO_STR(MMSYSERR_READERROR);
+    ERR_TO_STR(MMSYSERR_WRITEERROR);
+    ERR_TO_STR(MMSYSERR_DELETEERROR);
+    ERR_TO_STR(MMSYSERR_VALNOTFOUND);
+    ERR_TO_STR(MMSYSERR_NODRIVERCB);
     ERR_TO_STR(WAVERR_BADFORMAT);
     ERR_TO_STR(WAVERR_STILLPLAYING);
     ERR_TO_STR(WAVERR_UNPREPARED);
@@ -664,7 +673,7 @@
 /**************************************************************************
  * 				mixerMessage		[WINMM.@]
  */
-UINT WINAPI mixerMessage(HMIXER hmix, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
+DWORD WINAPI mixerMessage(HMIXER hmix, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
 {
     LPWINE_MLD		wmld;
 
@@ -2664,8 +2673,8 @@
  *			waveOutOpen			[WINMM.@]
  * All the args/structs have the same layout as the win16 equivalents
  */
-UINT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
-                       const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
+MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
+                       LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
                        DWORD_PTR dwInstance, DWORD dwFlags)
 {
     return WAVE_Open((HANDLE*)lphWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
@@ -3049,8 +3058,8 @@
 /**************************************************************************
  * 				waveInOpen			[WINMM.@]
  */
-UINT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
-		       const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
+MMRESULT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
+		       LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
 		       DWORD_PTR dwInstance, DWORD dwFlags)
 {
     return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,

reactos/lib/winmm/midimap
Makefile.ros-template 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Makefile.ros-template	9 Nov 2004 15:02:35 -0000	1.3
+++ Makefile.ros-template	8 Dec 2004 21:57:29 -0000	1.3.2.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.3 2004/11/09 15:02:35 ion Exp $
+# $Id: Makefile.ros-template,v 1.3.2.1 2004/12/08 21:57:29 hyperion Exp $
 
 TARGET_NAME = midimap
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = $(TARGET_LIB_BASE_MIDIMAP)
 

reactos/lib/winmm/wavemap
Makefile.ros-template 1.2 -> 1.2.8.1
diff -u -r1.2 -r1.2.8.1
--- Makefile.ros-template	2 Aug 2004 14:58:59 -0000	1.2
+++ Makefile.ros-template	8 Dec 2004 21:57:29 -0000	1.2.8.1
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/08/02 14:58:59 navaraf Exp $
+# $Id: Makefile.ros-template,v 1.2.8.1 2004/12/08 21:57:29 hyperion Exp $
 
 TARGET_NAME = msacm
 
@@ -6,7 +6,7 @@
 
 TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
 
-TARGET_SDKLIBS = @IMPORTS@ winmm.a libwine.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ winmm.a wine.a wine_uuid.a ntdll.a
 
 TARGET_BASE = 0x76160000
 

reactos/lib/winspool
Makefile 1.5 -> 1.5.16.1
diff -u -r1.5 -r1.5.16.1
--- Makefile	29 May 2004 21:24:47 -0000	1.5
+++ Makefile	8 Dec 2004 21:57:29 -0000	1.5.16.1
@@ -27,7 +27,7 @@
 
 TARGET_LFLAGS = -nostartfiles -nostdlib
 
-TARGET_SDKLIBS = libwine.a libwine_unicode.a ntdll.a kernel32.a
+TARGET_SDKLIBS = wine.a wine_unicode.a ntdll.a kernel32.a
 
 TARGET_OBJECTS = info.o stubs.o
 

reactos/lib/ws2_32/include
ws2_32.h 1.9 -> 1.9.8.1
diff -u -r1.9 -r1.9.8.1
--- ws2_32.h	15 Jul 2004 02:03:06 -0000	1.9
+++ ws2_32.h	8 Dec 2004 21:57:30 -0000	1.9.8.1
@@ -7,6 +7,7 @@
 #ifndef __WS2_32_H
 #define __WS2_32_H
 
+#include <roscfg.h>
 #include <ddk/ntddk.h>
 #include <ddk/ntifs.h>
 #include <ntos.h>
@@ -17,6 +18,7 @@
 #include <windows.h>
 #undef assert
 #include <debug.h>
+#include <WinDNS.h> // DNS_A_DATA
 
 /* Exported by ntdll.dll, but where is the prototype? */
 unsigned long strtoul(const char *nptr, char **endptr, int base);
@@ -51,6 +53,7 @@
     Getservbyname;          /* Buffer used by getservbyname */
     PWINSOCK_GETSERVBYPORT_CACHE
     Getservbyport;          /* Buffer used by getservbyname */
+    struct hostent* Hostent;
 } WINSOCK_THREAD_BLOCK, *PWINSOCK_THREAD_BLOCK;
 
 
@@ -60,6 +63,11 @@
 
 #define WSASETINITIALIZED (Initialized = TRUE)
 
+/* ws2_32 internal Functions */
+void check_hostent(struct hostent **he);
+void populate_hostent(struct hostent *he, char* name, DNS_A_DATA addr);
+void free_hostent(struct hostent *he);
+void free_servent(struct servent* s);
 
 #ifdef LE
 

reactos/lib/ws2_32
makefile 1.18 -> 1.18.2.1
diff -u -r1.18 -r1.18.2.1
--- makefile	17 Nov 2004 05:17:21 -0000	1.18
+++ makefile	8 Dec 2004 21:57:30 -0000	1.18.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.18 2004/11/17 05:17:21 arty Exp $
+# $Id: makefile,v 1.18.2.1 2004/12/08 21:57:30 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -19,17 +19,17 @@
  -fno-builtin \
  -DUNICODE \
  -DLE \
- -D__USE_W32API
+ -D__USE_W32API \
+ -D_WIN32_WINNT=0x0500
 
 # require os code to explicitly request A/W version of structs/functions
 TARGET_CFLAGS += -D_DISABLE_TIDENTS
 
 TARGET_LFLAGS = -nostartfiles -nostdlib
 
-TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
+TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a dnsapi.a
 
-TARGET_OBJECTS = \
-  misc/bsd.o misc/catalog.o misc/dllmain.o \
+TARGET_OBJECTS = misc/bsd.o misc/catalog.o misc/dllmain.o \
   misc/event.o misc/handle.o misc/ns.o \
   misc/sndrcv.o misc/stubs.o misc/upcall.o
 

reactos/lib/ws2_32/misc
dllmain.c 1.18 -> 1.18.2.1
diff -u -r1.18 -r1.18.2.1
--- dllmain.c	17 Nov 2004 05:17:22 -0000	1.18
+++ dllmain.c	8 Dec 2004 21:57:31 -0000	1.18.2.1
@@ -663,6 +663,16 @@
     return FALSE;
 }
 
+void free_winsock_thread_block(PWINSOCK_THREAD_BLOCK p) {
+  if(p) {
+    if(p->Hostent) { free_hostent(p->Hostent); p->Hostent = 0; }
+    if(p->Getservbyname){}
+    if(p->Getservbyport) {}
+
+
+  }
+}
+
 BOOL
 STDCALL
 DllMain(HANDLE hInstDll,
@@ -708,6 +718,7 @@
       return FALSE;
     }
 
+    p->Hostent = NULL;
     p->LastErrorValue = NO_ERROR;
     p->Getservbyname  = NULL;
     p->Getservbyport  = NULL;

reactos/lib/ws2_32/misc
event.c 1.6 -> 1.6.34.1
diff -u -r1.6 -r1.6.34.1
--- event.c	7 Aug 2003 04:03:24 -0000	1.6
+++ event.c	8 Dec 2004 21:57:31 -0000	1.6.34.1
@@ -157,6 +157,10 @@
   INT Status;
   INT Errno;
 
+  WS_DbgPrint(MID_TRACE,("Called (Socket %x, hEventObject %x, "
+			 "lpNetworkEvents %x)\n",
+			 s, hEventObject, lpNetworkEvents));
+
   if (!lpNetworkEvents) {
     WSASetLastError(WSAEINVAL);
     return SOCKET_ERROR;
@@ -180,6 +184,8 @@
   if (Status == SOCKET_ERROR)
     WSASetLastError(Errno);
 
+  WS_DbgPrint(MID_TRACE,("Leaving %x\n", Status));
+
   return Status;
 }
 

reactos/lib/ws2_32/misc
ns.c 1.9 -> 1.9.8.1
diff -u -r1.9 -r1.9.8.1
--- ns.c	15 Jul 2004 02:03:07 -0000	1.9
+++ ns.c	8 Dec 2004 21:57:31 -0000	1.9.8.1
@@ -9,11 +9,16 @@
  */
 #include <ctype.h>
 #include <ws2_32.h>
+#include <winbase.h>
 
 #ifndef BUFSIZ
 #define BUFSIZ 1024
 #endif/*BUFSIZ*/
 
+#ifndef MAX_HOSTNAME_LEN
+#define MAX_HOSTNAME_LEN 256
+#endif
+
 /* Name resolution APIs */
 
 /*
@@ -337,6 +342,50 @@
     return 0;
 }
 
+void check_hostent(struct hostent **he) {
+  struct hostent *new_he;
+  WS_DbgPrint(MID_TRACE,("*he: %x\n",*he));
+  if(!*he) {
+    new_he = HeapAlloc(GlobalHeap, 0, sizeof(struct hostent) + MAX_HOSTNAME_LEN + 1);
+    new_he->h_name = (PCHAR)(new_he + 1);
+    new_he->h_aliases = 0;
+    new_he->h_addrtype = 0; // AF_INET
+    new_he->h_length = 0;   // sizeof(in_addr)
+    new_he->h_addr_list = HeapAlloc(GlobalHeap, 0, sizeof(char *) * 2);
+    RtlZeroMemory(new_he->h_addr_list, sizeof(char *) * 2);
+    *he = new_he;
+  }
+}
+
+void populate_hostent(struct hostent *he, char* name, DNS_A_DATA addr) {
+  ASSERT(he);
+  //he = HeapAlloc(GlobalHeap, 0, sizeof(struct hostent));
+  //he->h_name = HeapAlloc(GlobalHeap, 0, MAX_HOSTNAME_LEN+1);
+  strncpy(he->h_name, name, MAX_HOSTNAME_LEN);
+  he->h_aliases = 0;
+  he->h_addrtype = AF_INET;
+  he->h_length = sizeof(IN_ADDR); //sizeof(struct in_addr);
+  if( he->h_addr_list[0] ) HeapFree( GlobalHeap, 0, he->h_addr_list[0] );
+  he->h_addr_list[0] = HeapAlloc(GlobalHeap, 0, MAX_HOSTNAME_LEN+1);
+  WS_DbgPrint(MID_TRACE,("he->h_addr_list[0] %x\n", he->h_addr_list[0]));
+  RtlCopyMemory(he->h_addr_list[0], (char*)&addr.IpAddress, 
+		sizeof(addr.IpAddress));
+  he->h_addr_list[1] = 0;
+}
+
+
+#define HFREE(x) if(x) { HeapFree(GlobalHeap, 0, (x)); x=0; }
+void free_hostent(struct hostent *he) {
+  if(he) {
+    HFREE(he->h_name);
+    char *next = he->h_aliases[0];
+    while(next) { HFREE(next); next++; }
+    next = he->h_addr_list[0];
+    while(next) { HFREE(next); next++; }
+    HFREE(he->h_addr_list);
+    HFREE(he);
+  }
+}
 
 /* WinSock 1.1 compatible name resolution APIs */
 
@@ -356,21 +405,193 @@
 }
 
 /*
- * @unimplemented
+  Assumes rfc 1123 - adam * 
+   addr[1] = 0;
+    addr[0] = inet_addr(name);
+    strcpy( hostname, name );
+    if(addr[0] == 0xffffffff) return NULL;
+    he.h_addr_list = (void *)addr;
+    he.h_name = hostname;
+    he.h_aliases = NULL;
+    he.h_addrtype = AF_INET;
+    he.h_length = sizeof(addr);
+    return &he;
+
+<RANT>
+From the MSDN Platform SDK: Windows Sockets 2
+"The gethostbyname function cannot resolve IP address strings passed to it.
+Such a request is treated exactly as if an unknown host name were passed."
+</RANT>
+
+Defferring to the the documented behaviour, rather than the unix behaviour
+What if the hostname is in the HOSTS file? see getservbyname
+
+ * @implemented
  */
+
+/* DnsQuery -- lib/dnsapi/dnsapi/query.c */
+   /* see ws2_32.h, winsock2.h*/
+    /*getnetworkparameters - iphlp api */
+/*
+REFERENCES
+
+servent -- w32api/include/winsock2.h
+PWINSOCK_THREAD_BLOCK -- ws2_32.h
+dllmain.c -- threadlocal memory allocation / deallocation
+lib/dnsapi
+      
+
+*/
+      /* lib/adns/src/adns.h XXX */
+
+
+/*
+struct  hostent {
+        char    *h_name;
+        char    **h_aliases;
+        short   h_addrtype;
+        short   h_length;
+        char    **h_addr_list;
+#define h_addr h_addr_list[0]
+};
+struct  servent {
+        char    *s_name;
+        char    **s_aliases;
+        short   s_port;
+        char    *s_proto;
+};
+
+
+struct hostent defined in w32api/include/winsock2.h
+*/
+
+void free_servent(struct servent* s) {
+  HFREE(s->s_name);
+  char* next = s->s_aliases[0];
+  while(next) { HFREE(next); next++; }
+  s->s_port = 0;
+  HFREE(s->s_proto);
+  HFREE(s);
+}
+
+
+ 
 LPHOSTENT
 EXPORT
 gethostbyname(
     IN  CONST CHAR FAR* name)
 {
-    UNIMPLEMENTED
+  enum addr_type{ GH_INVALID, GH_IPV6, GH_IPV4, GH_RFC1123_DNS };
+  typedef enum addr_type addr_type;
+  addr_type addr;
+  int ret = 0;
+  char* found = 0;
+  DNS_STATUS dns_status = {0};
+  /* include/WinDNS.h -- look up DNS_RECORD on MSDN */
+  PDNS_RECORD dp = 0;
+
+  addr = GH_INVALID;
+
+  PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
+
+  if( !p ) {
+    WSASetLastError( WSANOTINITIALISED );
+    return NULL;
+  }
+
+  check_hostent(&p->Hostent);   /*XXX alloc_hostent*/
+
+  /* Hostname NULL - behave like gethostname */
+  if(name == NULL) {
+    ret = gethostname(p->Hostent->h_name, MAX_HOSTNAME_LEN);
+    return p->Hostent;
+  }
+
+  if(ret) {
+    WSASetLastError( WSAHOST_NOT_FOUND ); //WSANO_DATA  ??
+    return NULL;
+  }
+
+  /* Is it an IPv6 address? */
+  found = strstr(name, ":");
+  if( found != NULL ) {
+    addr = GH_IPV6;
+    goto act;
+  }
+
+  /* Is it an IPv4 address? */
+  if (!isalpha(name[0])) {
+    addr = GH_IPV4;
+    goto act;
+  }
+
+ addr = GH_RFC1123_DNS;
+
+ /* Broken out in case we want to get fancy later */
+ act:
+    switch(addr){
+      case GH_IPV6:
+	WSASetLastError(STATUS_NOT_IMPLEMENTED);
+	return NULL;
+	break;
 
-    return (LPHOSTENT)NULL;
-}
+    case GH_INVALID:
+      WSASetLastError(WSAEFAULT);
+      return NULL;
+      break;
+
+    /* Note: If passed an IP address, MSDN says that gethostbyname()
+             treats it as an unknown host.
+       This is different from the unix implementation. Use inet_addr()
+    */
+    case GH_IPV4:
+    case GH_RFC1123_DNS:
+      /* DNS_TYPE_A: include/WinDNS.h */
+      /* DnsQuery -- lib/dnsapi/dnsapi/query.c */
+      dns_status = DnsQuery_A ( name, DNS_TYPE_A, DNS_QUERY_STANDARD,
+				0, /* extra dns servers */ &dp, 0 );
+
+      if(dns_status == 0) {
+	//ASSERT(dp->wType == DNS_TYPE_A);
+	//ASSERT(dp->wDataLength == sizeof(DNS_A_DATA));
+	PDNS_RECORD curr;
+	for(curr=dp;
+	    curr != NULL && curr->wType != DNS_TYPE_A;
+	    curr = curr->pNext ) { 
+	  WS_DbgPrint(MID_TRACE,("wType: %i\n", curr->wType));
+	  /*empty */ 
+	}
+
+	if(curr) {
+	  WS_DbgPrint(MID_TRACE,("populating hostent\n"));
+	  WS_DbgPrint(MID_TRACE,("pName is (%s)\n", curr->pName));
+	  populate_hostent(p->Hostent, (PCHAR)curr->pName, curr->Data.A);
+	  DnsRecordListFree(dp, DnsFreeRecordList);
+	  return p->Hostent;
+	} else {
+	  DnsRecordListFree(dp, DnsFreeRecordList);
+	}
+      }
 
+      WS_DbgPrint(MID_TRACE,("Called DnsQuery, but host not found. Err: %i\n",
+			     dns_status));
+      WSASetLastError(WSAHOST_NOT_FOUND);
+      return NULL;
+      
+      break;
+
+    default:
+      WSASetLastError(WSANO_RECOVERY);
+      return NULL;
+      break;
+    }
+
+    WSASetLastError(WSANO_RECOVERY);
+    return NULL;
+}
 
 /*
- * @unimplemented
+ * @implemented
  */
 INT
 EXPORT
@@ -378,15 +599,22 @@
     OUT CHAR FAR* name,
     IN  INT namelen)
 {
-    UNIMPLEMENTED
-
+  DWORD size = namelen;
+  
+  int ret = GetComputerNameExA(ComputerNameDnsHostname, name, &size);
+  if(ret == 0) {
+    WSASetLastError(WSAEFAULT);
+    return SOCKET_ERROR;
+  } else {
+    name[namelen-1] = '\0';
     return 0;
+  }
 }
 
 
 /*
  * XXX arty -- Partial implementation pending a better one.  This one will
- * do for normal purposes.
+ * do for normal purposes.#include <ws2_32.h>
  *
  * Return the address of a static LPPROTOENT corresponding to the named
  * protocol.  These structs aren't very interesting, so I'm not too ashamed
@@ -948,7 +1176,6 @@
     return (HANDLE)0;
 }
 
-
 /*
  * @unimplemented
  */

reactos/lib/ws2_32/misc
stubs.c 1.14 -> 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- stubs.c	17 Nov 2004 05:17:22 -0000	1.14
+++ stubs.c	8 Dec 2004 21:57:31 -0000	1.14.2.1
@@ -147,7 +147,7 @@
  * @implemented
  */
 INT
-EXPORT
+EXPORT __stdcall
 setsockopt(
     IN  SOCKET s,
     IN  INT level,

reactos/ntoskrnl
Makefile 1.156 -> 1.156.2.1
diff -u -r1.156 -r1.156.2.1
--- Makefile	12 Nov 2004 12:05:27 -0000	1.156
+++ Makefile	8 Dec 2004 21:57:31 -0000	1.156.2.1
@@ -28,18 +28,18 @@
 ifeq ($(KDBG), 1)
 OBJECTS_KDBG := dbg/kdb.o dbg/kdb_serial.o dbg/kdb_keyboard.o dbg/rdebug.o \
                 dbg/i386/kdb_help.o dbg/kdb_stabs.o dbg/kdb_symbols.o dbg/profile.o \
-		../dk/w32/lib/kjs.a dbg/i386/i386-dis.o
+		../dk/w32/lib/libkjs.a dbg/i386/i386-dis.o
 CFLAGS_KDBG := -I../lib/kjs/include
 preall: all
 
-../dk/w32/lib/kjs.a:
+../dk/w32/lib/libkjs.a:
 	$(MAKE) -C ../lib/kjs
 else
 OBJECTS_KDBG :=
 endif
 
 TARGET_ASFLAGS = -I./include
-TARGET_CFLAGS = -I./include $(CFLAGS_KDBG) -Wall -Werror $(CFLAGS_OPT)
+TARGET_CFLAGS = -I./include $(CFLAGS_KDBG) -Wall -Werror $(CFLAGS_OPT) -D_ELF_SUPPORT
 
 # require os code to explicitly request A/W version of structs/functions
 TARGET_CFLAGS += -D_DISABLE_TIDENTS
@@ -520,11 +520,11 @@
 TARGET_OBJECTS = $(EXTRA_OBJECTS) $(OBJECTS)
 
 TARGET_LIBS = \
-	$(DDK_PATH_LIB)/hal.a \
-	$(SDK_PATH_LIB)/rtl.a \
-	$(SDK_PATH_LIB)/string.a \
-	$(SDK_PATH_LIB)/rosrtl.a \
-	$(SDK_PATH_LIB)/pseh.a
+	$(DDK_PATH_LIB)/libhal.a \
+	$(SDK_PATH_LIB)/librtl.a \
+	$(SDK_PATH_LIB)/libstring.a \
+	$(SDK_PATH_LIB)/librosrtl.a \
+	$(SDK_PATH_LIB)/libpseh.a
 
 TARGET_LFLAGS = \
 	-Wl,-T,ntoskrnl.lnk \

reactos/ntoskrnl
ntoskrnl.def 1.201 -> 1.201.2.1
diff -u -r1.201 -r1.201.2.1
--- ntoskrnl.def	21 Nov 2004 16:34:57 -0000	1.201
+++ ntoskrnl.def	8 Dec 2004 21:57:31 -0000	1.201.2.1
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.def,v 1.201 2004/11/21 16:34:57 navaraf Exp $
+; $Id: ntoskrnl.def,v 1.201.2.1 2004/12/08 21:57:31 hyperion Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -429,7 +429,7 @@
 IoRaiseInformationalHardError@12
 IoReadDiskSignature@12
 IoReadOperationCount DATA
-IoReadPartitionTable@16
+@IoReadPartitionTable@16
 IoReadPartitionTableEx@8
 IoReadTransferCount DATA
 IoRegisterBootDriverReinitialization@12
@@ -461,7 +461,7 @@
 IoSetHardErrorOrVerifyDevice@8
 IoSetInformation@16
 IoSetIoCompletion@24
-IoSetPartitionInformation@16
+@IoSetPartitionInformation@16
 IoSetPartitionInformationEx@12
 IoSetStartIoAttributes@12
 IoSetShareAccess@16
@@ -502,7 +502,7 @@
 IoWMIWriteEvent@4
 IoWriteErrorLogEntry@4
 IoWriteOperationCount DATA
-IoWritePartitionTable@20
+@IoWritePartitionTable@20
 IoWritePartitionTableEx@8
 IoWriteTransferCount DATA
 @IofCallDriver@8

reactos/ntoskrnl/cm
regfile.c 1.83 -> 1.83.2.1
diff -u -r1.83 -r1.83.2.1
--- regfile.c	22 Oct 2004 20:14:03 -0000	1.83
+++ regfile.c	8 Dec 2004 21:57:31 -0000	1.83.2.1
@@ -437,7 +437,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&HiveHandle,
+  Status = ZwCreateFile(&HiveHandle,
 			FILE_READ_DATA | FILE_READ_ATTRIBUTES,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -454,7 +454,7 @@
     }
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       return(Status);
     }
 
@@ -465,7 +465,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&LogHandle,
+  Status = ZwCreateFile(&LogHandle,
 			FILE_READ_DATA | FILE_READ_ATTRIBUTES,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -482,7 +482,7 @@
     }
   else if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       NtClose(HiveHandle);
       return(Status);
     }
@@ -904,7 +904,7 @@
 			     NULL);
 
   CreateDisposition = FILE_OPEN_IF;
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoSB,
@@ -919,7 +919,7 @@
     {
       RtlFreeUnicodeString(&RegistryHive->HiveFileName);
       RtlFreeUnicodeString(&RegistryHive->LogFileName);
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       return(Status);
     }
 
@@ -1428,7 +1428,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -1441,7 +1441,7 @@
 			0);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       ExFreePool(Buffer);
       return(Status);
     }
@@ -1605,7 +1605,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -1618,7 +1618,7 @@
 			0);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       ExFreePool(Buffer);
       return(Status);
     }
@@ -1706,7 +1706,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -1719,7 +1719,7 @@
 			0);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       return(Status);
     }
 
@@ -1785,7 +1785,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -1798,7 +1798,7 @@
 			0);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       return(Status);
     }
 
@@ -1896,7 +1896,7 @@
 			     NULL,
 			     NULL);
 
-  Status = NtCreateFile(&FileHandle,
+  Status = ZwCreateFile(&FileHandle,
 			FILE_ALL_ACCESS,
 			&ObjectAttributes,
 			&IoStatusBlock,
@@ -1909,7 +1909,7 @@
 			0);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+      DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
       return(Status);
     }
 

reactos/ntoskrnl/ex
sysinfo.c 1.59 -> 1.59.2.1
diff -u -r1.59 -r1.59.2.1
--- sysinfo.c	13 Nov 2004 23:08:35 -0000	1.59
+++ sysinfo.c	8 Dec 2004 21:57:32 -0000	1.59.2.1
@@ -1,4 +1,4 @@
-/* $Id: sysinfo.c,v 1.59 2004/11/13 23:08:35 hbirr Exp $
+/* $Id: sysinfo.c,v 1.59.2.1 2004/12/08 21:57:32 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -355,7 +355,7 @@
 	}
 	Sbi->Unknown = 0;
 	Sbi->MaximumIncrement = KeMaximumIncrement;
-	Sbi->PhysicalPageSize = PAGE_SIZE; /* FIXME: it should be PAGE_SIZE */
+	Sbi->PhysicalPageSize = PAGE_SIZE;
 	Sbi->NumberOfPhysicalPages = MmStats.NrTotalPages;
 	Sbi->LowestPhysicalPage = 0; /* FIXME */ 
 	Sbi->HighestPhysicalPage = MmStats.NrTotalPages; /* FIXME */
@@ -1202,12 +1202,7 @@
       return STATUS_INFO_LENGTH_MISMATCH;
     }
 
-  /* Copy the time zone information struct */
-  memcpy(&ExpTimeZoneInfo,
-	 (TIME_ZONE_INFORMATION *)Buffer,
-	 sizeof(TIME_ZONE_INFORMATION));
-
-  return STATUS_SUCCESS;
+  return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION)Buffer);
 }
 
 

reactos/ntoskrnl/ex
time.c 1.24 -> 1.24.2.1
diff -u -r1.24 -r1.24.2.1
--- time.c	6 Nov 2004 16:04:58 -0000	1.24
+++ time.c	8 Dec 2004 21:57:32 -0000	1.24.2.1
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.24 2004/11/06 16:04:58 ekohl Exp $
+/* $Id: time.c,v 1.24.2.1 2004/12/08 21:57:32 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -12,6 +12,7 @@
 /* INCLUDES *****************************************************************/
 
 #include <ntoskrnl.h>
+#define NDEBUG
 #include <internal/debug.h>
 
 
@@ -30,6 +31,7 @@
 VOID INIT_FUNCTION
 ExpInitTimeZoneInfo(VOID)
 {
+  LARGE_INTEGER CurrentTime;
   NTSTATUS Status;
 
   /* Read time zone information from the registry */
@@ -54,6 +56,23 @@
   SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
   SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
   SharedUserData->TimeZoneId = ExpTimeZoneId;
+
+  /* Convert boot time from local time to UTC */
+  SystemBootTime.QuadPart += ExpTimeZoneBias.QuadPart;
+
+  /* Convert sytem time from local time to UTC */
+  do
+    {
+      CurrentTime.u.HighPart = SharedUserData->SystemTime.High1Time;
+      CurrentTime.u.LowPart = SharedUserData->SystemTime.LowPart;
+    }
+  while (CurrentTime.u.HighPart != SharedUserData->SystemTime.High2Time);
+
+  CurrentTime.QuadPart += ExpTimeZoneBias.QuadPart;
+
+  SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart;
+  SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart;
+  SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart;
 }
 
 
@@ -70,28 +89,21 @@
 NtSetSystemTime(IN PLARGE_INTEGER UnsafeNewSystemTime,
 		OUT PLARGE_INTEGER UnsafeOldSystemTime OPTIONAL)
 {
-  NTSTATUS Status;
   LARGE_INTEGER OldSystemTime;
   LARGE_INTEGER NewSystemTime;
   LARGE_INTEGER LocalTime;
   TIME_FIELDS TimeFields;
+  NTSTATUS Status;
 
   /* FIXME: Check for SeSystemTimePrivilege */
 
-  if (UnsafeNewSystemTime == NULL)
-    {
-      /* FIXME: update time zone settings */
-
-      return STATUS_SUCCESS;
-    }
-
   Status = MmCopyFromCaller(&NewSystemTime, UnsafeNewSystemTime,
 			    sizeof(NewSystemTime));
   if (!NT_SUCCESS(Status))
     {
-      return(Status);
+      return Status;
     }
-  
+
   if (UnsafeOldSystemTime != NULL)
     {
       KeQuerySystemTime(&OldSystemTime);
@@ -102,10 +114,8 @@
 		      &TimeFields);
   HalSetRealTimeClock(&TimeFields);
 
-  /* FIXME: set system time */
-#if 0
-  KeSetSystemTime();
-#endif
+  /* Set system time */
+  KiSetSystemTime(&NewSystemTime);
 
   if (UnsafeOldSystemTime != NULL)
     {
@@ -113,10 +123,11 @@
 			      sizeof(OldSystemTime));
       if (!NT_SUCCESS(Status))
 	{
-	  return(Status);
+          return Status;
 	}
     }
-  return(STATUS_SUCCESS);
+
+  return STATUS_SUCCESS;
 }
 
 
@@ -154,10 +165,7 @@
 	)
 {
   SystemTime->QuadPart =
-    LocalTime->QuadPart;
-#if 0
     LocalTime->QuadPart + ExpTimeZoneBias.QuadPart;
-#endif
 }
 
 
@@ -186,10 +194,7 @@
 	)
 {
   LocalTime->QuadPart =
-    SystemTime->QuadPart;
-#if 0
     SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
-#endif
 }
 
 /* EOF */

reactos/ntoskrnl/include/internal
ex.h 1.44 -> 1.44.2.1
diff -u -r1.44 -r1.44.2.1
--- ex.h	6 Nov 2004 16:04:25 -0000	1.44
+++ ex.h	8 Dec 2004 21:57:32 -0000	1.44.2.1
@@ -115,5 +115,8 @@
 ExfpInterlockedExchange64(LONGLONG volatile * Destination,
                           PLONGLONG Exchange);
 
+NTSTATUS
+ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
+
 
 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */

reactos/ntoskrnl/include/internal
io.h 1.49 -> 1.49.2.1
diff -u -r1.49 -r1.49.2.1
--- io.h	19 Nov 2004 21:31:02 -0000	1.49
+++ io.h	8 Dec 2004 21:57:32 -0000	1.49.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: io.h,v 1.49 2004/11/19 21:31:02 navaraf Exp $
+/* $Id: io.h,v 1.49.2.1 2004/12/08 21:57:32 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -43,8 +43,8 @@
 
 
 typedef struct _IO_COMPLETION_PACKET{
-   ULONG             Key;
-   ULONG             Overlapped;
+   PVOID             Key;
+   PVOID             Context;
    IO_STATUS_BLOCK   IoStatus;
    LIST_ENTRY        ListEntry;
 } IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;

reactos/ntoskrnl/include/internal
ke.h 1.66 -> 1.66.2.1
diff -u -r1.66 -r1.66.2.1
--- ke.h	21 Nov 2004 18:42:58 -0000	1.66
+++ ke.h	8 Dec 2004 21:57:33 -0000	1.66.2.1
@@ -43,6 +43,28 @@
 struct _KPCR;
 struct _KEXCEPTION_FRAME;
 
+#define IPI_REQUEST_FUNCTIONCALL    1
+#define IPI_REQUEST_APC		    2
+#define IPI_REQUEST_DPC		    4
+
+/* ipi.c ********************************************************************/
+
+BOOLEAN STDCALL 
+KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, 
+		    IN struct _KEXCEPTION_FRAME* ExceptionFrame);
+
+VOID  
+KiIpiSendRequest(ULONG TargetSet, 
+		 ULONG IpiRequest);
+
+VOID  
+KeIpiGenericCall(VOID STDCALL (*WorkerRoutine)(PVOID), 
+		 PVOID Argument);
+
+/* next file ***************************************************************/
+
+
+
 VOID STDCALL 
 DbgBreakPointNoBugCheck(VOID);
 
@@ -59,11 +81,6 @@
 	IN KPROFILE_SOURCE		Source
 );
 
-BOOLEAN
-STDCALL
-KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
-	            IN struct _KEXCEPTION_FRAME* ExceptionFrame);
-
 VOID STDCALL KeUpdateSystemTime(PKTRAP_FRAME TrapFrame, KIRQL Irql);
 VOID STDCALL KeUpdateRunTime(PKTRAP_FRAME TrapFrame, KIRQL Irql);
 
@@ -167,6 +184,9 @@
 STDCALL
 KeFlushCurrentTb(VOID);
 
+VOID
+KiSetSystemTime(PLARGE_INTEGER NewSystemTime);
+
 #endif /* not __ASM__ */
 
 #define MAXIMUM_PROCESSORS      32

reactos/ntoskrnl/include/internal
ps.h 1.75 -> 1.75.2.1
diff -u -r1.75 -r1.75.2.1
--- ps.h	20 Nov 2004 16:46:05 -0000	1.75
+++ ps.h	8 Dec 2004 21:57:33 -0000	1.75.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: ps.h,v 1.75 2004/11/20 16:46:05 weiden Exp $
+/* $Id: ps.h,v 1.75.2.1 2004/12/08 21:57:33 hyperion Exp $
  *
  * FILE:            ntoskrnl/ke/kthread.c
  * PURPOSE:         Process manager definitions
@@ -48,8 +48,6 @@
 #define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
 #endif
 
-extern HANDLE SystemProcessHandle;
-
 extern LCID PsDefaultThreadLocaleId;
 extern LCID PsDefaultSystemLocaleId;
 
@@ -653,7 +651,7 @@
   LONG ref;
   HANDLE Handle;
   LIST_ENTRY Entry;
-  LONG Lock;
+  FAST_MUTEX Lock;
   union
   {
     struct _EPROCESS *Process;

reactos/ntoskrnl/include
config.h added at 1.2.2.1
diff -N config.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config.h	8 Dec 2004 21:57:33 -0000	1.2.2.1
@@ -0,0 +1,18 @@
+#ifndef __INCLUDE_NTOSKRNL_CONFIG_H
+#define __INCLUDE_NTOSKRNL_CONFIG_H
+
+/* Enable strict checking of the nonpaged pool on every allocation */
+#undef ENABLE_VALIDATE_POOL
+
+/* Enable tracking of statistics about the tagged blocks in the pool */
+#undef TAG_STATISTICS_TRACKING
+
+/*
+ * Put each block in its own range of pages and position the block at the
+ * end of the range so any accesses beyond the end of block are to invalid
+ * memory locations.
+ */
+#undef WHOLE_PAGE_ALLOCATIONS
+
+#endif /* __INCLUDE_NTOSKRNL_CONFIG_H */
+

reactos/ntoskrnl/include
ntoskrnl.h 1.6 -> 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- ntoskrnl.h	20 Nov 2004 23:46:36 -0000	1.6
+++ ntoskrnl.h	8 Dec 2004 21:57:33 -0000	1.6.2.1
@@ -3,6 +3,8 @@
 
 #define __NO_CTYPE_INLINES
 
+/* include the ntoskrnl config.h file */
+#include "config.h"
 
 #include <roscfg.h>
 #include <reactos/version.h>

reactos/ntoskrnl/io
iocomp.c 1.15 -> 1.15.8.1
diff -u -r1.15 -r1.15.8.1
--- iocomp.c	21 Aug 2004 20:51:26 -0000	1.15
+++ iocomp.c	8 Dec 2004 21:57:33 -0000	1.15.8.1
@@ -271,8 +271,8 @@
 STDCALL
 NtRemoveIoCompletion(
    IN  HANDLE           IoCompletionHandle,
-   OUT PULONG           CompletionKey,
-   OUT PULONG           CompletionValue,
+   OUT PVOID            *CompletionKey,
+   OUT PVOID            *CompletionContext,
    OUT PIO_STATUS_BLOCK IoStatusBlock,
    IN  PLARGE_INTEGER   Timeout OPTIONAL
    )
@@ -302,7 +302,7 @@
       Packet = CONTAINING_RECORD(ListEntry, IO_COMPLETION_PACKET, ListEntry);
 
       if (CompletionKey) *CompletionKey = Packet->Key;
-      if (CompletionValue) *CompletionValue = Packet->Overlapped;
+      if (CompletionContext) *CompletionContext = Packet->Context;
       if (IoStatusBlock) *IoStatusBlock = Packet->IoStatus;
 
       ExFreeToNPagedLookasideList(&IoCompletionPacketLookaside, Packet);
@@ -330,8 +330,8 @@
 STDCALL
 NtSetIoCompletion(
    IN HANDLE   IoCompletionPortHandle,
-   IN ULONG    CompletionKey,
-   IN ULONG    CompletionValue,
+   IN PVOID    CompletionKey,
+   IN PVOID    CompletionContext,
    IN NTSTATUS CompletionStatus,
    IN ULONG    CompletionInformation
    )
@@ -352,7 +352,7 @@
       Packet = ExAllocateFromNPagedLookasideList(&IoCompletionPacketLookaside);
 
       Packet->Key = CompletionKey;
-      Packet->Overlapped = CompletionValue;
+      Packet->Context = CompletionContext;
       Packet->IoStatus.Status = CompletionStatus;
       Packet->IoStatus.Information = CompletionInformation;
    

reactos/ntoskrnl/io
parttab.c 1.8 -> 1.8.8.1
diff -u -r1.8 -r1.8.8.1
--- parttab.c	15 Aug 2004 16:39:03 -0000	1.8
+++ parttab.c	8 Dec 2004 21:57:33 -0000	1.8.8.1
@@ -1,4 +1,4 @@
-/* $Id: parttab.c,v 1.8 2004/08/15 16:39:03 chorns Exp $
+/* $Id: parttab.c,v 1.8.8.1 2004/12/08 21:57:33 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -21,7 +21,7 @@
 /*
  * @implemented
  */
-NTSTATUS STDCALL
+NTSTATUS FASTCALL
 IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
 		     ULONG SectorSize,
 		     BOOLEAN ReturnRecognizedPartitions,
@@ -34,7 +34,7 @@
 }
 
 
-NTSTATUS STDCALL
+NTSTATUS FASTCALL
 IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject,
 			  ULONG SectorSize,
 			  ULONG PartitionNumber,
@@ -47,7 +47,7 @@
 }
 
 
-NTSTATUS STDCALL
+NTSTATUS FASTCALL
 IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
 		      ULONG SectorSize,
 		      ULONG SectorsPerTrack,

reactos/ntoskrnl/kd
gdbstub.c 1.26 -> 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- gdbstub.c	14 Nov 2004 16:00:02 -0000	1.26
+++ gdbstub.c	8 Dec 2004 21:57:33 -0000	1.26.2.1
@@ -86,7 +86,7 @@
 #include <ntoskrnl.h>
 #define NDEBUG
 #include <internal/debug.h>
-
+#include <internal/ps.h>
 
 /************************************************************************/
 /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
@@ -1410,11 +1410,12 @@
           /* reply to the request */
           GspPutPacket (&GspOutBuffer[0]);
         }
+
+      /* not reached */
+      ASSERT(0);
     }
 
-    /* not reached */
-    ASSERT(0);
-    return kdHandleException;
+    return kdDoNotHandleException;
 }
 
 

reactos/ntoskrnl/ke
dpc.c 1.48 -> 1.48.2.1
diff -u -r1.48 -r1.48.2.1
--- dpc.c	21 Nov 2004 18:13:47 -0000	1.48
+++ dpc.c	8 Dec 2004 21:57:34 -0000	1.48.2.1
@@ -19,7 +19,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dpc.c,v 1.48 2004/11/21 18:13:47 hbirr Exp $
+/* $Id: dpc.c,v 1.48.2.1 2004/12/08 21:57:34 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -248,14 +248,12 @@
 			/* Send IPI if High Importance */
 			if ((Dpc->Importance == HighImportance) ||
 			    (Pcr->PrcbData.DpcData[0].DpcQueueDepth >= Pcr->PrcbData.MaximumDpcQueueDepth)) {
-                	
-#if 0
-				KiIpiSendRequest(1 << Dpc->Number, IPI_REQUEST_DPC);
-#else
-				/* FIXME: USE IPI */
-				Pcr->PrcbData.DpcInterruptRequested = TRUE;
-				HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
-#endif				
+				if (Dpc->Number >= MAXIMUM_PROCESSORS) {
+				    KiIpiSendRequest(1 << (Dpc->Number - MAXIMUM_PROCESSORS), IPI_REQUEST_DPC);
+				} else {
+				    KiIpiSendRequest(1 << Dpc->Number, IPI_REQUEST_DPC);
+				}
+
 			}
 		} else {
 			/* Request an Interrupt only if the DPC isn't low priority */

reactos/ntoskrnl/ke
ipi.c 1.3 -> 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ipi.c	14 Nov 2004 20:00:06 -0000	1.3
+++ ipi.c	8 Dec 2004 21:57:34 -0000	1.3.2.1
@@ -1,4 +1,4 @@
-/* $Id: ipi.c,v 1.3 2004/11/14 20:00:06 hbirr Exp $
+/* $Id: ipi.c,v 1.3.2.1 2004/12/08 21:57:34 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -20,127 +20,167 @@
 
 KSPIN_LOCK KiIpiLock;
 
-struct
+/* FUNCTIONS *****************************************************************/
+
+VOID 
+KiIpiSendRequest(ULONG TargetSet, ULONG IpiRequest)
 {
-   VOID STDCALL (*Function)(PVOID);
-   PVOID Argument;
-   BOOLEAN Synchronize;
-   ULONG StartCount;
-   ULONG EndCount;
-} KiIpiInfo;
+   ULONG i;
+   PKPCR Pcr;
 
-/* FUNCTIONS *****************************************************************/
+   for (i = 0; i < KeNumberProcessors; i++)
+   {
+      if (TargetSet & (1 << i))
+      {
+         Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE);
+	 Pcr->PrcbData.IpiFrozen |= IpiRequest;
+	 HalRequestIpi(i);
+      }
+   }
+}
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOLEAN
 STDCALL
 KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
                     IN PKEXCEPTION_FRAME ExceptionFrame)
 {
-    LARGE_INTEGER StartTime, CurrentTime, Frequency;
+#ifdef DBG	
+   LARGE_INTEGER StartTime, CurrentTime, Frequency;
+   ULONG Count = 5;
+#endif   
+   ULONG TargetSet, Processor;
 
-    ASSERT(KeGetCurrentIrql() == IPI_LEVEL);
+   PKPCR Pcr;
 
-    DPRINT("KiIpiServiceRoutine\n");
+   ASSERT(KeGetCurrentIrql() == IPI_LEVEL);
 
+   DPRINT("KiIpiServiceRoutine\n");
 
-    if (KiIpiInfo.Synchronize)
-    {
-       InterlockedDecrement(&KiIpiInfo.StartCount);
-       StartTime = KeQueryPerformanceCounter(&Frequency);
-       while (0 != InterlockedCompareExchange(&KiIpiInfo.StartCount, 0, 0))
-       {
-          CurrentTime = KeQueryPerformanceCounter(NULL);
-	  if (CurrentTime.QuadPart > StartTime.QuadPart + Frequency.QuadPart)
-	  {
-	     DPRINT1("Waiting longer than 1 seconds to start the ipi routine\n");
-	     KEBUGCHECK(0);
-	  }
-       }
-    }
-    KiIpiInfo.Function(KiIpiInfo.Argument);
-    if (KiIpiInfo.Synchronize)
-    {
-       InterlockedDecrement(&KiIpiInfo.EndCount);
-       StartTime = KeQueryPerformanceCounter(&Frequency);
-       while (0 != InterlockedCompareExchange(&KiIpiInfo.EndCount, 0, 0))
-       {
-          CurrentTime = KeQueryPerformanceCounter(NULL);
-	  if (CurrentTime.QuadPart > StartTime.QuadPart + Frequency.QuadPart)
-	  {
-	     DPRINT1("Waiting longer than 1 seconds after executing the ipi routine\n");
-	     KEBUGCHECK(0);
-	  }
-       }
-    }
-    return TRUE;
+   Pcr = KeGetCurrentKPCR();
+
+   if (Pcr->PrcbData.IpiFrozen & IPI_REQUEST_APC)
+   {
+      Pcr->PrcbData.IpiFrozen &= ~IPI_REQUEST_APC;
+      HalRequestSoftwareInterrupt(APC_LEVEL);
+   }
+
+   if (Pcr->PrcbData.IpiFrozen & IPI_REQUEST_DPC)
+   {
+      Pcr->PrcbData.IpiFrozen &= ~IPI_REQUEST_DPC;
+      Pcr->PrcbData.DpcInterruptRequested = TRUE;
+      HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
+   }
+
+   if (Pcr->PrcbData.IpiFrozen & IPI_REQUEST_FUNCTIONCALL)
+   {
+      InterlockedDecrement((PLONG)&Pcr->PrcbData.SignalDone->CurrentPacket[1]);
+      if (Pcr->PrcbData.SignalDone->CurrentPacket[2])
+      {
+#ifdef DBG      	
+         StartTime = KeQueryPerformanceCounter(&Frequency);
+#endif         
+         while (0 != InterlockedCompareExchange((PLONG)&Pcr->PrcbData.SignalDone->CurrentPacket[1], 0, 0))
+	 {
+#ifdef DBG	 	
+            CurrentTime = KeQueryPerformanceCounter(NULL);
+	    if (CurrentTime.QuadPart > StartTime.QuadPart + Count * Frequency.QuadPart)
+	    {
+	       DPRINT1("Waiting longer than %d seconds to start the ipi routine\n", Count);
+	       KEBUGCHECK(0);
+	    }
+#endif	 
+         }
+      }
+      ((VOID STDCALL(*)(PVOID))(Pcr->PrcbData.SignalDone->WorkerRoutine))(Pcr->PrcbData.SignalDone->CurrentPacket[0]);
+      do
+      {
+         Processor = 1 << KeGetCurrentProcessorNumber();
+	 TargetSet = Pcr->PrcbData.SignalDone->TargetSet;
+      } while (Processor & InterlockedCompareExchange(&Pcr->PrcbData.SignalDone->TargetSet, TargetSet & ~Processor, TargetSet)); 
+      if (Pcr->PrcbData.SignalDone->CurrentPacket[2])
+      {
+#ifdef DBG      	
+         StartTime = KeQueryPerformanceCounter(&Frequency);
+#endif         
+         while (0 != InterlockedCompareExchange(&Pcr->PrcbData.SignalDone->TargetSet, 0, 0))
+         {
+#ifdef DBG         	
+	    CurrentTime = KeQueryPerformanceCounter(NULL);
+	    if (CurrentTime.QuadPart > StartTime.QuadPart + Count * Frequency.QuadPart)
+	    {
+	       DPRINT1("Waiting longer than %d seconds after executing the ipi routine\n", Count);
+	       KEBUGCHECK(0);
+	    }
+#endif	 
+         }
+      }
+      InterlockedExchangePointer(&Pcr->PrcbData.SignalDone, NULL);
+      Pcr->PrcbData.IpiFrozen &= ~IPI_REQUEST_FUNCTIONCALL;
+   }
+   DPRINT("KiIpiServiceRoutine done\n");
+   return TRUE;
 }
 
 VOID
 STDCALL
-KiIpiSendPacket(ULONG Processors, VOID STDCALL (*Function)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
+KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
 {
-    ULONG i;
+    ULONG i, Processor, CurrentProcessor;
+    PKPCR Pcr, CurrentPcr;
+    KIRQL oldIrql;
+
 
     ASSERT(KeGetCurrentIrql() == SYNCH_LEVEL);
 
-    /* 
-     * FIXME
-     *   M$ puts the ipi information anywhere into the KPCR of the requestor.
-     *   The KPCR of the target contains a pointer of the KPCR of the requestor.
-     */
-
-    KiIpiInfo.Function = Function;
-    KiIpiInfo.Argument = Argument;
-    if (Synchronize)
-    {
-       KiIpiInfo.StartCount = Count;
-       KiIpiInfo.EndCount = Count;
-    }
-    KiIpiInfo.Synchronize = Synchronize;
+    CurrentPcr = KeGetCurrentKPCR();
+    CurrentPcr->PrcbData.TargetSet = TargetSet;
+    CurrentPcr->PrcbData.WorkerRoutine = (ULONG_PTR)WorkerRoutine;
+    CurrentPcr->PrcbData.CurrentPacket[0] = Argument;
+    CurrentPcr->PrcbData.CurrentPacket[1] = (PVOID)Count;
+    CurrentPcr->PrcbData.CurrentPacket[2] = (PVOID)(ULONG)Synchronize;
 
-    for (i = 0; i < KeNumberProcessors; i++)
+    CurrentProcessor = 1 << KeGetCurrentProcessorNumber();
+
+    for (i = 0, Processor = 1; i < KeNumberProcessors; i++, Processor <<= 1)
     {
-       if (Processors & (1 << i))
+       if (TargetSet & Processor)
        {
-	  HalRequestIpi(i);
+          Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE);
+          while(0 != InterlockedCompareExchange((PLONG)&Pcr->PrcbData.SignalDone, (LONG)&CurrentPcr->PrcbData, 0));
+	  Pcr->PrcbData.IpiFrozen |= IPI_REQUEST_FUNCTIONCALL;
+	  if (Processor != CurrentProcessor)
+	  {
+	     HalRequestIpi(i);
+	  }
        }
     }
+    if (TargetSet & CurrentProcessor)
+    {
+       KeRaiseIrql(IPI_LEVEL, &oldIrql);
+       KiIpiServiceRoutine(NULL, NULL);
+       KeLowerIrql(oldIrql);
+    }
 }
 
 VOID
-STDCALL
 KeIpiGenericCall(VOID STDCALL (*Function)(PVOID), PVOID Argument)
 {
-   KIRQL oldIrql, oldIrql2;
-   ULONG Count, i;
-   ULONG Processors = 0;
+   KIRQL oldIrql;
+   ULONG TargetSet;
 
    DPRINT("KeIpiGenericCall on CPU%d\n", KeGetCurrentProcessorNumber());
 
    KeRaiseIrql(SYNCH_LEVEL, &oldIrql);
 
-   Count = KeNumberProcessors;
-   for (i = 0; i < KeNumberProcessors; i++)
-   {
-      if (KeGetCurrentProcessorNumber() != i)
-      {
-         Processors |= (1 << i);
-      }
-   }
-
    KiAcquireSpinLock(&KiIpiLock);
 
-   KiIpiSendPacket(Processors, Function, Argument, Count, TRUE);
-   
-   KeRaiseIrql(IPI_LEVEL, &oldIrql2);
-   
-   KiIpiServiceRoutine(NULL, NULL);
-   
-   KeLowerIrql(oldIrql2);
+   TargetSet = (1 << KeNumberProcessors) - 1;
 
+   KiIpiSendPacket(TargetSet, Function, Argument, KeNumberProcessors, TRUE);
+   
    KiReleaseSpinLock(&KiIpiLock);
    
    KeLowerIrql(oldIrql);
@@ -148,41 +188,5 @@
    DPRINT("KeIpiGenericCall on CPU%d done\n", KeGetCurrentProcessorNumber());
 }
 
-VOID
-STDCALL
-KeIpiCallForBootProcessor(VOID STDCALL (*Function)(PVOID), PVOID Argument)
-{
-   KIRQL oldIrql, oldIrql2;
-   LARGE_INTEGER StartCount, CurrentCount;
-   LARGE_INTEGER Frequency;
-
-   KeRaiseIrql(SYNCH_LEVEL, &oldIrql);
-
-   ASSERT (KeGetCurrentProcessorNumber() != 0);
-
-   KiAcquireSpinLock(&KiIpiLock);
-
-   KiIpiSendPacket(1, Function, Argument, 1, TRUE);
-   
-   KeRaiseIrql(IPI_LEVEL, &oldIrql2);
-
-   StartCount = KeQueryPerformanceCounter(&Frequency);
-   while (0 != InterlockedCompareExchange(&KiIpiInfo.EndCount, 0, 0))
-   {
-      CurrentCount = KeQueryPerformanceCounter(NULL);
-      if (CurrentCount.QuadPart > StartCount.QuadPart + Frequency.QuadPart)
-      {
-         DPRINT1("Waiting longer than 1 second after sending the ipi to the boot processor\n");
-	 KEBUGCHECK(0);
-      }
-   }
-
-   KeLowerIrql(oldIrql2);
-
-   KiReleaseSpinLock(&KiIpiLock);
-   
-   KeLowerIrql(oldIrql);
-
-}
 
 /* EOF */

reactos/ntoskrnl/ke
main.c 1.206 -> 1.206.2.1
diff -u -r1.206 -r1.206.2.1
--- main.c	20 Nov 2004 23:46:37 -0000	1.206
+++ main.c	8 Dec 2004 21:57:34 -0000	1.206.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: main.c,v 1.206 2004/11/20 23:46:37 blight Exp $
+/* $Id: main.c,v 1.206.2.1 2004/12/08 21:57:34 hyperion Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
@@ -263,8 +263,6 @@
    RtlFreeUnicodeString (&DriveDeviceName);
    RtlFreeUnicodeString (&ArcDeviceName);
 
-   DPRINT("DosDeviceMap: 0x%x\n", SharedUserData->DosDeviceMap);
-
    if (BootDriveFound == FALSE)
      {
 	DbgPrint("No system drive found!\n");
@@ -466,7 +464,7 @@
 #if 1
   if (KeMemoryMapRangeCount > 0)
     {
-      DPRINT1("MemoryMap:\n");
+      DPRINT("MemoryMap:\n");
       for (i = 0; i < KeMemoryMapRangeCount; i++)
         {
           switch(KeMemoryMap[i].Type)
@@ -486,7 +484,7 @@
 	      default:
 	        sprintf(str, "type %lu", KeMemoryMap[i].Type);
             }
-          DPRINT1("%08x - %08x %s\n", KeMemoryMap[i].BaseAddrLow, KeMemoryMap[i].BaseAddrLow + KeMemoryMap[i].LengthLow, str);
+          DPRINT("%08x - %08x %s\n", KeMemoryMap[i].BaseAddrLow, KeMemoryMap[i].BaseAddrLow + KeMemoryMap[i].LengthLow, str);
 	}
     }
 #endif
@@ -511,24 +509,23 @@
     }
 
   /* Initialize all processors */
-  KeNumberProcessors = 0;
+  KeNumberProcessors = 1;
 
   while (!HalAllProcessorsStarted())
     {
       PVOID ProcessorStack;
 
-      if (KeNumberProcessors != 0)
-	{
-	  KePrepareForApplicationProcessorInit(KeNumberProcessors);
-	  PsPrepareForApplicationProcessorInit(KeNumberProcessors);
-	}
+      KePrepareForApplicationProcessorInit(KeNumberProcessors);
+      PsPrepareForApplicationProcessorInit(KeNumberProcessors);
+
       /* Allocate a stack for use when booting the processor */
       /* FIXME: The nonpaged memory for the stack is not released after use */
       ProcessorStack = 
 	(char*)ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE;
       Ki386InitialStackArray[((int)KeNumberProcessors)] = 
 	(PVOID)((char*)ProcessorStack - MM_STACK_SIZE);
-      HalInitializeProcessor(KeNumberProcessors, ProcessorStack);
+
+      HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA));
       KeNumberProcessors++;
     }
 
@@ -850,21 +847,30 @@
 VOID __attribute((noinline))
 KiSystemStartup(BOOLEAN BootProcessor)
 {
-  HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+  if (BootProcessor)
+  {
+  }
+  else
+  {
+     KeApplicationProcessorInit();
+  }
+
+  HalInitializeProcessor(KeNumberProcessors, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
 
   if (BootProcessor)
-    {
-      ExpInitializeExecutive();
-      MiFreeInitMemory();
-      /* Never returns */
-      PsTerminateSystemThread(STATUS_SUCCESS);
-      KEBUGCHECK(0);
-    }
-  /* Do application processor initialization */
-  KeApplicationProcessorInit();
-  PsApplicationProcessorInit();
-  KeLowerIrql(PASSIVE_LEVEL);
-  PsIdleThreadMain(NULL);
+  {
+     ExpInitializeExecutive();
+     MiFreeInitMemory();
+     /* Never returns */
+     PsTerminateSystemThread(STATUS_SUCCESS);
+  }
+  else
+  {
+     /* Do application processor initialization */
+     PsApplicationProcessorInit();
+     KeLowerIrql(PASSIVE_LEVEL);
+     PsIdleThreadMain(NULL);
+  }
   KEBUGCHECK(0);
   for(;;);
 }
@@ -991,10 +997,6 @@
   /* Low level architecture specific initialization */
   KeInit1((PCHAR)KeLoaderBlock.CommandLine, &LastKernelAddress);
 
-#ifdef HAL_DBG
-  HalnInitializeDisplay((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
-#endif
-
   HalBase = KeLoaderModules[1].ModStart;
   DriverBase = LastKernelAddress;
   LdrHalBase = (ULONG_PTR)DriverBase;
@@ -1019,11 +1021,6 @@
   FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - KERNEL_BASE + 0x200000;
   LastKrnlPhysAddr = LastKernelAddress - KERNEL_BASE + 0x200000;
 
-#ifndef ACPI
-  /* FIXME: VMware does not like it when ReactOS is using the BIOS memory map */
-  KeLoaderBlock.Flags &= ~MB_FLAGS_MMAP_INFO;
-#endif
-
   KeMemoryMapRangeCount = 0;
   if (KeLoaderBlock.Flags & MB_FLAGS_MMAP_INFO)
     {
@@ -1038,8 +1035,17 @@
           KeMemoryMapRangeCount++;
           i += size;
         }
+      KeLoaderBlock.MmapLength = KeMemoryMapRangeCount * sizeof(ADDRESS_RANGE);
+      KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap;
     }
-  
+  else
+    {
+      KeLoaderBlock.MmapLength = 0;
+      KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap;
+    }
+
+  HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+
   KiSystemStartup(1);
 }
 

reactos/ntoskrnl/ke
process.c 1.31 -> 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- process.c	11 Nov 2004 22:23:52 -0000	1.31
+++ process.c	8 Dec 2004 21:57:34 -0000	1.31.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: process.c,v 1.31 2004/11/11 22:23:52 ion Exp $
+/* $Id: process.c,v 1.31.2.1 2004/12/08 21:57:34 hyperion Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/process.c
@@ -35,6 +35,21 @@
 
 /* FUNCTIONS *****************************************************************/
 
+static inline void
+UpdatePageDirs(PKTHREAD Thread, PKPROCESS Process)
+{
+   /* The stack and the thread structure of the current process may be 
+      located in a page which is not present in the page directory of 
+      the process we're attaching to. That would lead to a page fault 
+      when this function returns. However, since the processor can't 
+      call the page fault handler 'cause it can't push EIP on the stack, 
+      this will show up as a stack fault which will crash the entire system.
+      To prevent this, make sure the page directory of the process we're
+      attaching to is up-to-date. */
+   MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE);
+   MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD));
+}
+
 /*
  * @implemented
  */
@@ -46,7 +61,9 @@
 	PKTHREAD Thread = KeGetCurrentThread();
 	
 	DPRINT("KeAttachProcess: %x\n", Process);
-	
+
+	UpdatePageDirs(Thread, Process);
+
 	/* Lock Dispatcher */
 	OldIrql = KeAcquireDispatcherDatabaseLock();
 	
@@ -72,17 +89,6 @@
   
 	DPRINT("KiAttachProcess(Thread: %x, Process: %x, SavedApcState: %x\n", Thread, Process, SavedApcState);
    
-	/* The stack and the thread structure of the current process may be 
-	   located in a page which is not present in the page directory of 
-	   the process we're attaching to. That would lead to a page fault 
-	   when this function returns. However, since the processor can't 
-	   call the page fault handler 'cause it can't push EIP on the stack, 
-	   this will show up as a stack fault which will crash the entire system.
-	   To prevent this, make sure the page directory of the process we're
-	   attaching to is up-to-date. */
-	MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE);
-	MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD));
-	
 	/* Increase Stack Count */
 	Process->StackCount++;
 	
@@ -153,7 +159,9 @@
 {
 	KIRQL OldIrql;
 	PKTHREAD Thread = KeGetCurrentThread();
-	
+
+	UpdatePageDirs(Thread, Process);
+
 	OldIrql = KeAcquireDispatcherDatabaseLock();
 	
 	/* Crash system if DPC is being executed! */

reactos/ntoskrnl/ke
timer.c 1.90 -> 1.90.2.1
diff -u -r1.90 -r1.90.2.1
--- timer.c	21 Nov 2004 18:33:54 -0000	1.90
+++ timer.c	8 Dec 2004 21:57:34 -0000	1.90.2.1
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.90 2004/11/21 18:33:54 gdalsnes Exp $
+/* $Id: timer.c,v 1.90.2.1 2004/12/08 21:57:34 hyperion Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
@@ -68,7 +68,6 @@
 static LIST_ENTRY AbsoluteTimerListHead;
 static LIST_ENTRY RelativeTimerListHead;
 static KSPIN_LOCK TimerListLock;
-static KSPIN_LOCK TimerValueLock;
 static KDPC ExpireTimerDpc;
 
 /* must raise IRQL to PROFILE_LEVEL and grab spin lock there, to sync with ISR */
@@ -641,7 +640,6 @@
    InitializeListHead(&AbsoluteTimerListHead);
    InitializeListHead(&RelativeTimerListHead);
    KeInitializeSpinLock(&TimerListLock);
-   KeInitializeSpinLock(&TimerValueLock);
    KeInitializeDpc(&ExpireTimerDpc, KeExpireTimers, 0);
    /*
     * Calculate the starting time for the system clock
@@ -716,7 +714,7 @@
    {
       InterlockedIncrement((PLONG)&CurrentThread->UserTime);
       InterlockedIncrement((PLONG)&CurrentProcess->UserTime);
-      InterlockedIncrement((PLONG)&Pcr->PrcbData.UserTime);
+      Pcr->PrcbData.UserTime++;
    }
    else
    {
@@ -732,6 +730,7 @@
       {
          InterlockedIncrement((PLONG)&CurrentThread->KernelTime);
          InterlockedIncrement((PLONG)&CurrentProcess->KernelTime);
+	 Pcr->PrcbData.KernelTime++;
       }
    }
 
@@ -796,7 +795,6 @@
     */
    KeTickCount++;
    SharedUserData->TickCountLowDeprecated++;
-   KiAcquireSpinLock(&TimerValueLock);
 
    Time.u.LowPart = SharedUserData->InterruptTime.LowPart;
    Time.u.HighPart = SharedUserData->InterruptTime.High1Time;
@@ -814,8 +812,6 @@
 
    /* FIXME: Here we should check for remote debugger break-ins */
 
-   KiReleaseSpinLock(&TimerValueLock);
-
    /* Update process and thread times */
    KeUpdateRunTime(TrapFrame, Irql);
 
@@ -825,4 +821,58 @@
    KeInsertQueueDpc(&ExpireTimerDpc, (PVOID)TrapFrame->Eip, 0);
 }
 
+
+VOID
+KiSetSystemTime(PLARGE_INTEGER NewSystemTime)
+{
+  LARGE_INTEGER OldSystemTime;
+  LARGE_INTEGER DeltaTime;
+  KIRQL OldIrql;
+  PLIST_ENTRY current_entry = NULL;
+  PKTIMER current = NULL;
+
+  ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
+
+  OldIrql = KeAcquireDispatcherDatabaseLock();
+
+  do
+    {
+      OldSystemTime.u.HighPart = SharedUserData->SystemTime.High1Time;
+      OldSystemTime.u.LowPart = SharedUserData->SystemTime.LowPart;
+    }
+  while (OldSystemTime.u.HighPart != SharedUserData->SystemTime.High2Time);
+
+  /* Set the new system time */
+  SharedUserData->SystemTime.LowPart = NewSystemTime->u.LowPart;
+  SharedUserData->SystemTime.High1Time = NewSystemTime->u.HighPart;
+  SharedUserData->SystemTime.High2Time = NewSystemTime->u.HighPart;
+
+  /* Calculate the difference between the new and the old time */
+  DeltaTime.QuadPart = NewSystemTime->QuadPart - OldSystemTime.QuadPart;
+
+  /* Update system boot time */
+  SystemBootTime.QuadPart += DeltaTime.QuadPart;
+
+  /* Update all relative timers */
+  current_entry = RelativeTimerListHead.Flink;
+  ASSERT(current_entry);
+  while (current_entry != &RelativeTimerListHead)
+    {
+      current = CONTAINING_RECORD(current_entry, KTIMER, TimerListEntry);
+      ASSERT(current);
+      ASSERT(current_entry != &RelativeTimerListHead);
+      ASSERT(current_entry->Flink != current_entry);
+
+      current->DueTime.QuadPart += DeltaTime.QuadPart;
+
+      current_entry = current_entry->Flink;
+    }
+
+  KeReleaseDispatcherDatabaseLock(OldIrql);
+
+  /*
+   * NOTE: Expired timers will be processed at the next clock tick!
+   */
+}
+
 /* EOF */

reactos/ntoskrnl/ke/i386
exp.c 1.94 -> 1.94.2.1
diff -u -r1.94 -r1.94.2.1
--- exp.c	20 Nov 2004 23:46:36 -0000	1.94
+++ exp.c	8 Dec 2004 21:57:35 -0000	1.94.2.1
@@ -498,7 +498,6 @@
        if (!KeRosPrintAddress(Eip))
 	 {
 	   DbgPrint("<%X>", Eip);
-	   break;
 	 }
        Status = MmSafeCopyFromUser(&Frame, Frame, sizeof(Frame));
        if (!NT_SUCCESS(Status))
@@ -546,6 +545,11 @@
    cr2 = Ke386GetCr2();
    Tf->DebugPointer = (PVOID)cr2;
 
+   if (ExceptionNr == 14 && Tf->Eflags & FLAG_IF)
+   {
+     Ke386EnableInterrupts();
+   }
+
    /*
     * If this was a V86 mode exception then handle it specially
     */
@@ -574,10 +578,6 @@
 	{
            KEBUGCHECKWITHTF(ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY, 0, 0, 0, 0, Tf);
 	}
-        if (Tf->Eflags & FLAG_IF)
-	{
-	  Ke386EnableInterrupts();
-	}
 	Status = MmPageFault(Tf->Cs&0xffff,
 			     &Tf->Eip,
 			     &Tf->Eax,

reactos/ntoskrnl/ke/i386
fpu.c 1.17 -> 1.17.2.1
diff -u -r1.17 -r1.17.2.1
--- fpu.c	25 Nov 2004 13:22:54 -0000	1.17
+++ fpu.c	8 Dec 2004 21:57:35 -0000	1.17.2.1
@@ -1,4 +1,4 @@
-/* $Id: fpu.c,v 1.17 2004/11/25 13:22:54 blight Exp $
+/* $Id: fpu.c,v 1.17.2.1 2004/12/08 21:57:35 hyperion Exp $
  *
  *  ReactOS kernel
  *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team

reactos/ntoskrnl/ke/i386
irq.c 1.55 -> 1.55.2.1
diff -u -r1.55 -r1.55.2.1
--- irq.c	10 Nov 2004 02:51:00 -0000	1.55
+++ irq.c	8 Dec 2004 21:57:36 -0000	1.55.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: irq.c,v 1.55 2004/11/10 02:51:00 ion Exp $
+/* $Id: irq.c,v 1.55.2.1 2004/12/08 21:57:36 hyperion Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/i386/irq.c
@@ -182,9 +182,9 @@
  * be accessed at any irq level.
  */
 
-static LIST_ENTRY isr_table[NR_IRQS]={{NULL,NULL},};
-static PKSPIN_LOCK isr_lock[NR_IRQS] = {NULL,};
-static KSPIN_LOCK isr_table_lock = {0,};
+static LIST_ENTRY isr_table[NR_IRQS];
+static KSPIN_LOCK isr_lock[NR_IRQS];
+static KSPIN_LOCK isr_table_lock;
 
 #define TAG_ISR_LOCK     TAG('I', 'S', 'R', 'L')
 
@@ -207,7 +207,9 @@
 	KiIdt[IRQ_BASE+i].b=(irq_handler[i]&0xffff0000)+PRESENT+
 	                    I486_INTERRUPT_GATE;
 	InitializeListHead(&isr_table[i]);
+	KeInitializeSpinLock(&isr_lock[i]);
      }
+   KeInitializeSpinLock(&isr_table_lock);
 }
 
 STATIC VOID 
@@ -360,8 +362,10 @@
 	       KeIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame);
 	       CurrentThread->TrapFrame = &KernelTrapFrame;
 	     }
-	   
+   
+	   Ke386EnableInterrupts();
            KiDeliverApc(KernelMode, NULL, NULL);
+           Ke386DisableInterrupts();
            
 	   ASSERT(KeGetCurrentThread() == CurrentThread);
            if (CurrentThread->TrapFrame == &KernelTrapFrame)
@@ -382,16 +386,15 @@
    
    for (i=0;i<NR_IRQS;i++)
      {
-	DPRINT("For irq %x ",i);
+	DPRINT("For irq %x:\n",i);
 	current_entry = isr_table[i].Flink;
 	current = CONTAINING_RECORD(current_entry,KINTERRUPT,Entry);
 	while (current_entry!=(&isr_table[i]))
 	  {
-	     DPRINT("Isr %x ",current);
+	     DPRINT("   Isr %x\n",current);
 	     current_entry = current_entry->Flink;
 	     current = CONTAINING_RECORD(current_entry,KINTERRUPT,Entry);
 	  }
-	DPRINT("\n",0);
      }
 }
 
@@ -424,21 +427,14 @@
     * Check if the vector is already in use that we can share it
     */
    ListHead = CONTAINING_RECORD(isr_table[Vector].Flink,KINTERRUPT,Entry);
-   if (!IsListEmpty(&isr_table[Vector]) &&
+   if (!IsListEmpty(&isr_table[Vector]) && 
        (InterruptObject->Shareable == FALSE || ListHead->Shareable==FALSE))
-     {
-	KeReleaseSpinLock(&isr_table_lock,oldlvl);
-	return FALSE;
-     }
-   else
-     {
-	isr_lock[Vector] =
-	  ExAllocatePoolWithTag(NonPagedPool, sizeof(KSPIN_LOCK),
-				TAG_ISR_LOCK);
-	KeInitializeSpinLock(isr_lock[Vector]);
-     }
+   {
+      KeReleaseSpinLock(&isr_table_lock,oldlvl);
+      return FALSE;
+   }
 
-   InterruptObject->IrqLock = isr_lock[Vector];
+   InterruptObject->IrqLock = &isr_lock[Vector];
 
    KeRaiseIrql(InterruptObject->SynchLevel,&synch_oldlvl);
    KiAcquireSpinLock(InterruptObject->IrqLock);

reactos/ntoskrnl/ke/i386
kernel.c 1.42 -> 1.42.2.1
diff -u -r1.42 -r1.42.2.1
--- kernel.c	20 Nov 2004 23:46:36 -0000	1.42
+++ kernel.c	8 Dec 2004 21:57:36 -0000	1.42.2.1
@@ -132,7 +132,9 @@
   DPRINT("KePrepareForApplicationProcessorInit(Id %d)\n", Id);
   PFN_TYPE PrcPfn;
   PKPCR Pcr;
+  PKPCR BootPcr;
 
+  BootPcr = (PKPCR)KPCR_BASE;
   Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Id * PAGE_SIZE);
 
   MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &PrcPfn);
@@ -147,14 +149,14 @@
   Pcr->ProcessorNumber = Id;
   Pcr->Tib.Self = &Pcr->Tib;
   Pcr->Self = Pcr;
-  Pcr->Irql = HIGH_LEVEL;
+  Pcr->Irql = SYNCH_LEVEL;
+
+  Pcr->PrcbData.MHz = BootPcr->PrcbData.MHz;
+  Pcr->StallScaleFactor = BootPcr->StallScaleFactor; 
 
   /* Mark the end of the exception handler list */
   Pcr->Tib.ExceptionList = (PVOID)-1;
 
-  KeInitDpc(Pcr);
-
-
   KiGdtPrepareForApplicationProcessorInit(Id);
 }
 
@@ -172,11 +174,6 @@
      Ke386SetCr4(Ke386GetCr4() | X86_CR4_PGE);
   }
   
-  /* Enable PAE mode */
-  if (Ke386PaeEnabled)
-  {
-     MiEnablePAE(NULL);
-  }
 
   Offset = InterlockedIncrement(&PcrsAllocated) - 1;
   Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Offset * PAGE_SIZE);
@@ -192,6 +189,8 @@
   /* Check FPU/MMX/SSE support. */
   KiCheckFPU();
 
+  KeInitDpc(Pcr);
+
   /*
    * It is now safe to process interrupts
    */
@@ -221,26 +220,16 @@
    extern USHORT KiBootGdt[];
    extern KTSS KiBootTss;
 
-   /* Get processor information. */
-   Ki386GetCpuId();
-
-   /* Check FPU/MMX/SSE support. */
-   KiCheckFPU();
-
-   KiInitializeGdt (NULL);
-   Ki386BootInitializeTSS();
-   KeInitExceptions ();
-   KeInitInterrupts ();
-
    /*
     * Initialize the initial PCR region. We can't allocate a page
     * with MmAllocPage() here because MmInit1() has not yet been
     * called, so we use a predefined page in low memory 
     */
+
    KPCR = (PKPCR)KPCR_BASE;
    memset(KPCR, 0, PAGE_SIZE);
    KPCR->Self = KPCR;
-   KPCR->Irql = HIGH_LEVEL;
+   KPCR->Irql = SYNCH_LEVEL;
    KPCR->Tib.Self  = &KPCR->Tib;
    KPCR->GDT = KiBootGdt;
    KPCR->IDT = (PUSHORT)KiIdt;
@@ -249,13 +238,24 @@
    KiPcrInitDone = 1;
    PcrsAllocated++;
 
-   KeInitDpc(KPCR);
+   KiInitializeGdt (NULL);
+   Ki386BootInitializeTSS();
+   Ki386InitializeLdt();
+
+   /* Get processor information. */
+   Ki386GetCpuId();
+
+   /* Check FPU/MMX/SSE support. */
+   KiCheckFPU();
 
    /* Mark the end of the exception handler list */
    KPCR->Tib.ExceptionList = (PVOID)-1;
 
-   Ki386InitializeLdt();
-   
+   KeInitDpc(KPCR);
+
+   KeInitExceptions ();
+   KeInitInterrupts ();
+
    if (KPCR->PrcbData.FeatureBits & X86_FEATURE_PGE)
    {
       ULONG Flags;
@@ -336,55 +336,55 @@
 
    if (Pcr->PrcbData.FeatureBits & X86_FEATURE_PAE)
    {
-      DPRINT1("CPU supports PAE mode\n");
+      DPRINT("CPU supports PAE mode\n");
       if (Ke386Pae)
       {
-         DPRINT1("CPU runs in PAE mode\n");
+         DPRINT("CPU runs in PAE mode\n");
          if (Ke386NoExecute)
          {
-            DPRINT1("NoExecute is enabled\n");
+            DPRINT("NoExecute is enabled\n");
          }
       }
       else
       {
-         DPRINT1("CPU doesn't run in PAE mode\n");
+         DPRINT("CPU doesn't run in PAE mode\n");
       }
    }
    if ((Pcr->PrcbData.FeatureBits & (X86_FEATURE_FXSR | X86_FEATURE_MMX | X86_FEATURE_SSE | X86_FEATURE_SSE2)) ||
        (Ke386CpuidFlags2 & X86_EXT_FEATURE_SSE3))
       {
-         DPRINT1("CPU supports" "%s%s%s%s%s" ".\n",
-                 ((Pcr->PrcbData.FeatureBits & X86_FEATURE_FXSR) ? " FXSR" : ""),
-                 ((Pcr->PrcbData.FeatureBits & X86_FEATURE_MMX) ? " MMX" : ""),
-                 ((Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE) ? " SSE" : ""),
-                 ((Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE2) ? " SSE2" : ""),
-                 ((Ke386CpuidFlags2 & X86_EXT_FEATURE_SSE3) ? " SSE3" : ""));
+         DPRINT("CPU supports" "%s%s%s%s%s" ".\n",
+                ((Pcr->PrcbData.FeatureBits & X86_FEATURE_FXSR) ? " FXSR" : ""),
+                ((Pcr->PrcbData.FeatureBits & X86_FEATURE_MMX) ? " MMX" : ""),
+                ((Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE) ? " SSE" : ""),
+                ((Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE2) ? " SSE2" : ""),
+                ((Ke386CpuidFlags2 & X86_EXT_FEATURE_SSE3) ? " SSE3" : ""));
       }
    if (Ke386GetCr4() & X86_CR4_OSFXSR)
       {
-         DPRINT1("SSE enabled.\n");
+         DPRINT("SSE enabled.\n");
       }
    if (Ke386GetCr4() & X86_CR4_OSXMMEXCPT)
       {
-         DPRINT1("Unmasked SIMD exceptions enabled.\n");
+         DPRINT("Unmasked SIMD exceptions enabled.\n");
       }
    if (Pcr->PrcbData.VendorString[0])
    {
-      DPRINT1("CPU Vendor: %s\n", Pcr->PrcbData.VendorString);
+      DPRINT("CPU Vendor: %s\n", Pcr->PrcbData.VendorString);
    }
    if (Ke386CpuidModel[0])
    {
-      DPRINT1("CPU Model:  %s\n", Ke386CpuidModel);
+      DPRINT("CPU Model:  %s\n", Ke386CpuidModel);
    }
 
-   DPRINT1("Ke386CacheAlignment: %d\n", Ke386CacheAlignment);
+   DPRINT("Ke386CacheAlignment: %d\n", Ke386CacheAlignment);
    if (Ke386L1CacheSize)
    {
-      DPRINT1("Ke386L1CacheSize: %dkB\n", Ke386L1CacheSize);
+      DPRINT("Ke386L1CacheSize: %dkB\n", Ke386L1CacheSize);
    }
    if (Pcr->L2CacheSize)
    {
-      DPRINT1("Ke386L2CacheSize: %dkB\n", Pcr->L2CacheSize);
+      DPRINT("Ke386L2CacheSize: %dkB\n", Pcr->L2CacheSize);
    }
 }
 

reactos/ntoskrnl/ke/i386
multiboot.S 1.29 -> 1.29.2.1
diff -u -r1.29 -r1.29.2.1
--- multiboot.S	20 Nov 2004 23:46:36 -0000	1.29
+++ multiboot.S	8 Dec 2004 21:57:36 -0000	1.29.2.1
@@ -1,5 +1,6 @@
 #include <roscfg.h>
 #include <internal/ntoskrnl.h>
+#include <internal/i386/ke.h>
 #include <internal/i386/segment.h>
 #include <internal/ps.h>
 #include <internal/i386/mm.h>
@@ -173,21 +174,34 @@
 	movl	$0x1003, %eax
 	movl	%eax, (%esi, %edi)
 
-	/*
-	 * Initialize a part of the same pagetable to map the vga frame buffer (at FF3A0000).
-	 */
-	movl	$0xa0003, %eax
-	movl	$0x20, %ecx
-	movl	$0xE80, %edi
-.l9:
-	movl	%eax, (%esi, %edi)
-	add	$4, %edi
-	add	$0x1000, %eax
-	loop	.l9
 
 #ifdef MP
 
 .m1:
+    	/*
+     	 * Check for pae mode (only possible for an application processor)
+     	 */
+     
+	movl	$(V2P(_Ke386Pae)), %eax
+	cmpb	$0, (%eax)
+	je		.m3
+	
+	/*
+	 * Set up the PDBR
+	 */
+	movl	$(V2P(_pae_pagedirtable)), %eax
+	movl	%eax, %cr3
+	
+	/*
+	 * Enable pae mode
+	 */
+	movl	%cr4, %eax
+	orl		$X86_CR4_PAE, %eax
+	movl	%eax, %cr4
+
+	jmp		.m4
+
+.m3:
 
 #endif /* MP */
 
@@ -196,6 +210,10 @@
 	 */
 	movl	$(V2P(startup_pagedirectory)), %eax
 	movl	%eax, %cr3
+	
+#ifdef MP
+.m4:
+#endif
 
 	/*
 	 * Enable paging and set write protect
@@ -245,6 +263,11 @@
 	 */
 	pushl	$0
 	popfl
+	
+	/*
+	 *  Reserve space for the floating point save area.
+	 */
+	subl    $SIZEOF_FX_SAVE_AREA, %esp
 
 	/*
 	 * Call the application processor initialization code

reactos/ntoskrnl/ke/i386
tskswitch.S 1.21 -> 1.21.2.1
diff -u -r1.21 -r1.21.2.1
--- tskswitch.S	25 Nov 2004 13:22:54 -0000	1.21
+++ tskswitch.S	8 Dec 2004 21:57:36 -0000	1.21.2.1
@@ -59,6 +59,30 @@
 	 * This is a critical section for this processor.
 	 */
 	cli
+	
+#ifdef MP
+	/*
+	 * Get the pointer to the old thread.
+	 */
+	movl	12(%ebp), %ebx
+	/*
+	 * Save FPU state if the thread has used it.
+	 */
+	movl	$0, %fs:KPCR_NPX_THREAD
+	testb	$NPX_STATE_DIRTY, KTHREAD_NPX_STATE(%ebx)
+	jz	3f
+	movl	KTHREAD_INITIAL_STACK(%ebx), %eax
+	cmpl	$0, _FxsrSupport
+	je	1f
+	fxsave	-SIZEOF_FX_SAVE_AREA(%eax)
+	jmp	2f
+1:
+	fnsave	-SIZEOF_FX_SAVE_AREA(%eax)
+2:
+	movb	$NPX_STATE_VALID, KTHREAD_NPX_STATE(%ebx)
+3:
+#endif /* MP */
+
 
 	/*
 	 * Get the pointer to the new thread.
@@ -111,25 +135,6 @@
 	 */
 	movl	12(%ebp), %ebx
 
-#ifdef MP
-	/*
-	 * Save FPU state if the thread has used it.
-	 */
-	movl	$0, %fs:KPCR_NPX_THREAD
-	testb	$NPX_STATE_DIRTY, KTHREAD_NPX_STATE(%ebx)
-	jz	3f
-	movl	KTHREAD_INITIAL_STACK(%ebx), %eax
-	cmpl	$0, _FxsrSupport
-	je	1f
-	fxsave	-SIZEOF_FX_SAVE_AREA(%eax)
-	jmp	2f
-1:
-	fnsave	-SIZEOF_FX_SAVE_AREA(%eax)
-2:
-	movb	$NPX_STATE_VALID, KTHREAD_NPX_STATE(%ebx)
-3:
-#endif /* MP */
-
 	/*
 	 * FIXME: Save debugging state.
 	 */

reactos/ntoskrnl/ldr
init.c 1.49 -> 1.49.2.1
diff -u -r1.49 -r1.49.2.1
--- init.c	21 Nov 2004 21:09:42 -0000	1.49
+++ init.c	8 Dec 2004 21:57:37 -0000	1.49.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: init.c,v 1.49 2004/11/21 21:09:42 weiden Exp $
+/* $Id: init.c,v 1.49.2.1 2004/12/08 21:57:37 hyperion Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ldr/init.c
@@ -375,6 +375,7 @@
   ULONG ResultLength;
   PVOID ImageBaseAddress;
   ULONG InitialStack[5];
+  HANDLE SystemProcessHandle;
   NTSTATUS Status;
 
   /* Get the absolute path to smss.exe. */
@@ -404,6 +405,17 @@
       return(Status);
     }
 
+  Status = ObCreateHandle(PsGetCurrentProcess(),
+                          PsInitialSystemProcess,
+                          PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
+                          FALSE,
+                          &SystemProcessHandle);
+  if(!NT_SUCCESS(Status))
+  {
+    DPRINT1("Failed to create a handle for the system process!\n");
+    return Status;
+  }
+
   DPRINT("Creating process\n");
   Status = NtCreateProcess(ProcessHandle,
 			   PROCESS_ALL_ACCESS,
@@ -414,6 +426,7 @@
 			   NULL,
 			   NULL);
   NtClose(SectionHandle);
+  NtClose(SystemProcessHandle);
   if (!NT_SUCCESS(Status))
     {
       DPRINT("NtCreateProcess() failed (Status %lx)\n", Status);

reactos/ntoskrnl/mm/i386
page.c 1.77 -> 1.77.2.1
diff -u -r1.77 -r1.77.2.1
--- page.c	13 Nov 2004 23:08:35 -0000	1.77
+++ page.c	8 Dec 2004 21:57:37 -0000	1.77.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: page.c,v 1.77 2004/11/13 23:08:35 hbirr Exp $
+/* $Id: page.c,v 1.77.2.1 2004/12/08 21:57:37 hyperion Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/i386/page.c
@@ -83,6 +83,52 @@
 
 /* FUNCTIONS ***************************************************************/
 
+BOOLEAN MmUnmapPageTable(PULONG Pt);
+
+VOID
+STDCALL
+MiFlushTlbIpiRoutine(PVOID Address)
+{
+   if (Address == (PVOID)0xffffffff)
+   {
+      KeFlushCurrentTb();
+   }
+   else if (Address == (PVOID)0xfffffffe)
+   {
+      FLUSH_TLB;
+   }
+   else
+   {
+      FLUSH_TLB_ONE(Address);
+   }
+}
+
+VOID
+MiFlushTlb(PULONG Pt, PVOID Address)
+{
+#ifdef MP
+   if (Pt)
+   {
+      MmUnmapPageTable(Pt);
+   }
+   if (KeNumberProcessors>1)
+   {
+      KeIpiGenericCall(MiFlushTlbIpiRoutine, Address);
+   }
+   else
+   {
+      MiFlushTlbIpiRoutine(Address);
+   }
+#else
+   if ((Pt && MmUnmapPageTable(Pt)) || Address >= (PVOID)KERNEL_BASE)
+   {
+      FLUSH_TLB_ONE(Address);
+   }
+#endif
+}
+
+
+
 PULONG
 MmGetPageDirectory(VOID)
 {
@@ -391,7 +437,7 @@
       KEBUGCHECK(0);
       //       MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)] = 0;
    }
-   FLUSH_TLB;
+   MiFlushTlb(NULL, Address);
    if (Process != NULL && Process != CurrentProcess)
    {
       KeDetachProcess();
@@ -442,7 +488,7 @@
       Pfn = PTE_TO_PFN(*(ADDR_TO_PDE(Address)));
       *(ADDR_TO_PDE(Address)) = 0;
    }
-   FLUSH_TLB;
+   MiFlushTlb(NULL, Address);
 
    if (Address >= (PVOID)KERNEL_BASE)
    {
@@ -776,10 +822,7 @@
 	tmpPte = Pte & ~PA_PRESENT;
       } while (Pte != ExfInterlockedCompareExchange64(Pt, &tmpPte, &Pte)); 
 
-      if (MmUnmapPageTable((PULONG)Pt) || Address >= (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb((PULONG)Pt, Address);
       WasValid = PAE_PAGE_MASK(Pte) != 0LL ? TRUE : FALSE;
       if (!WasValid)
       {
@@ -816,10 +859,7 @@
         Pte = *Pt;
       } while (Pte != InterlockedCompareExchange(Pt, Pte & ~PA_PRESENT, Pte)); 
 
-      if (MmUnmapPageTable(Pt) || Address >= (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb(Pt, Address);
       WasValid = (PAGE_MASK(Pte) != 0);
       if (!WasValid)
       {
@@ -854,7 +894,7 @@
           * Set the entry to zero
           */
 	 ExfpInterlockedExchange64(Pt, &ZeroPte);
-         FLUSH_TLB_ONE(Address);
+         MiFlushTlb((PULONG)Pt, Address);
       }
    }
    else
@@ -868,7 +908,7 @@
           * Set the entry to zero
           */
          *Pt = 0;
-         FLUSH_TLB_ONE(Address);
+         MiFlushTlb(Pt, Address);
       }
    }
 }
@@ -910,10 +950,7 @@
       Pte = 0LL;
       Pte = ExfpInterlockedExchange64(Pt, &Pte);
 
-      if ((MmUnmapPageTable((PULONG)Pt) || Address >=(PVOID)KERNEL_BASE) && Pte)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb((PULONG)Pt, Address);
 
       WasValid = PAE_PAGE_MASK(Pte) != 0 ? TRUE : FALSE;
       if (WasValid)
@@ -968,10 +1005,7 @@
        */
       Pte = InterlockedExchange(Pt, 0);
 
-      if ((MmUnmapPageTable(Pt) || Address >=(PVOID)KERNEL_BASE) && Pte)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb(Pt, Address);
 
       WasValid = (PAGE_MASK(Pte) != 0);
       if (WasValid)
@@ -1047,10 +1081,7 @@
       Pte = 0LL;
       Pte = ExfpInterlockedExchange64(Pt, &Pte);
 
-      if (MmUnmapPageTable((PULONG)Pt) || Address >= (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb((PULONG)Pt, Address);
 
       /*
        * Decrement the reference count for this page table.
@@ -1094,10 +1125,7 @@
        */
       Pte = InterlockedExchange(Pt, 0);
 
-      if (MmUnmapPageTable(Pt) || Address >= (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb(Pt, Address);
 
       /*
        * Decrement the reference count for this page table.
@@ -1206,10 +1234,7 @@
 
       if (Pte & PA_ACCESSED)
       {
-         if (MmUnmapPageTable((PULONG)Pt) || Address >= (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb((PULONG)Pt, Address);
          return TRUE;
       }
       else
@@ -1236,10 +1261,7 @@
 
       if (Pte & PA_ACCESSED)
       {
-         if (MmUnmapPageTable(Pt) || Address >= (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb(Pt, Address);
          return TRUE;
       }
       else
@@ -1278,10 +1300,7 @@
 
       if (Pte & PA_DIRTY)
       {
-         if (MmUnmapPageTable((PULONG)Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb((PULONG)Pt, Address);
       }
       else
       {
@@ -1307,10 +1326,7 @@
 
       if (Pte & PA_DIRTY)
       {
-         if (MmUnmapPageTable(Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb(Pt, Address);
       }
       else
       {
@@ -1345,10 +1361,7 @@
       } while (Pte != ExfInterlockedCompareExchange64(Pt, &tmpPte, &Pte));
       if (!(Pte & PA_DIRTY))
       {
-         if (MmUnmapPageTable((PULONG)Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb((PULONG)Pt, Address);
       }
       else
       {
@@ -1372,10 +1385,7 @@
       } while (Pte != InterlockedCompareExchange(Pt, Pte | PA_DIRTY, Pte));
       if (!(Pte & PA_DIRTY))
       {
-         if (MmUnmapPageTable(Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb(Pt, Address);
       }
       else
       {
@@ -1405,10 +1415,7 @@
       } while (Pte != ExfInterlockedCompareExchange64(Pt, &tmpPte, &Pte));
       if (!(Pte & PA_PRESENT))
       {
-         if (MmUnmapPageTable((PULONG)Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb((PULONG)Pt, Address);
       }
       else
       {
@@ -1432,10 +1439,7 @@
       } while (Pte != InterlockedCompareExchange(Pt, Pte | PA_PRESENT, Pte));
       if (!(Pte & PA_PRESENT))
       {
-         if (MmUnmapPageTable(Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb(Pt, Address);
       }
       else
       {
@@ -1639,10 +1643,7 @@
 
       if (Pte != 0) 
       {
-         if (MmUnmapPageTable((PULONG)Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb((PULONG)Pt, Address);
       }
       else
       {
@@ -1667,10 +1668,7 @@
       *Pt = SwapEntry << 1;
       if (Pte != 0) 
       {
-         if (MmUnmapPageTable(Pt) || Address > (PVOID)KERNEL_BASE)
-         {
-            FLUSH_TLB_ONE(Address);
-         }
+         MiFlushTlb(Pt, Address);
       }
       else
       {
@@ -1819,7 +1817,7 @@
             if (Address > (PVOID)KERNEL_BASE ||
                 (Pt >= (PULONGLONG)PAGETABLE_MAP && Pt < (PULONGLONG)PAGETABLE_MAP + 4*512*512))
             {
-               FLUSH_TLB_ONE(Address);
+              MiFlushTlb((PULONG)Pt, Address);
             }
          }
       }
@@ -1884,7 +1882,7 @@
             if (Address > (PVOID)KERNEL_BASE ||
                 (Pt >= (PULONG)PAGETABLE_MAP && Pt < (PULONG)PAGETABLE_MAP + 1024*1024))
             {
-               FLUSH_TLB_ONE(Address);
+               MiFlushTlb(Pt, Address);
             }
          }
       }
@@ -2018,10 +2016,7 @@
 	}
       } while (Pte != ExfInterlockedCompareExchange64(Pt, &tmpPte, &Pte));
 
-      if (MmUnmapPageTable((PULONG)Pt) || Address > (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb((PULONG)Pt, Address);
    }
    else
    {
@@ -2033,10 +2028,7 @@
          KEBUGCHECK(0);
       }
       *Pt = PAGE_MASK(*Pt) | Attributes | (*Pt & (PA_ACCESSED|PA_DIRTY));
-      if (MmUnmapPageTable(Pt) || Address > (PVOID)KERNEL_BASE)
-      {
-         FLUSH_TLB_ONE(Address);
-      }
+      MiFlushTlb(Pt, Address);
    }
 }
 

reactos/ntoskrnl/mm/i386
pfault.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- pfault.c	21 Nov 2004 18:37:56 -0000	1.11
+++ pfault.c	8 Dec 2004 21:57:37 -0000	1.11.2.1
@@ -38,7 +38,7 @@
    NTSTATUS Status;
 
    DPRINT("MmPageFault(Eip %x, Cr2 %x, ErrorCode %x)\n",
-          Eip, Cr2, ErrorCode);
+          *Eip, Cr2, ErrorCode);
 
    if (ErrorCode & 0x4)
    {

reactos/ntoskrnl/mm
npool.c 1.92 -> 1.92.2.1
diff -u -r1.92 -r1.92.2.1
--- npool.c	22 Oct 2004 20:38:22 -0000	1.92
+++ npool.c	8 Dec 2004 21:57:37 -0000	1.92.2.1
@@ -1,4 +1,4 @@
-/* $Id: npool.c,v 1.92 2004/10/22 20:38:22 ekohl Exp $
+/* $Id: npool.c,v 1.92.2.1 2004/12/08 21:57:37 hyperion Exp $
  *
  * COPYRIGHT:    See COPYING in the top level directory
  * PROJECT:      ReactOS kernel
@@ -20,19 +20,6 @@
 #define NDEBUG
 #include <internal/debug.h>
 
-/* Enable strict checking of the nonpaged pool on every allocation */
-/*#define ENABLE_VALIDATE_POOL*/
-
-/* Enable tracking of statistics about the tagged blocks in the pool */
-/*#define TAG_STATISTICS_TRACKING*/
-
-/*
- * Put each block in its own range of pages and position the block at the
- * end of the range so any accesses beyond the end of block are to invalid
- * memory locations. 
- */
-/*#define WHOLE_PAGE_ALLOCATIONS*/
-
 #ifdef ENABLE_VALIDATE_POOL
 #define VALIDATE_POOL validate_kernel_pool()
 #else

reactos/ntoskrnl/ps
cid.c 1.2 -> 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- cid.c	12 Oct 2004 20:00:40 -0000	1.2
+++ cid.c	8 Dec 2004 21:57:37 -0000	1.2.2.1
@@ -1,4 +1,4 @@
-/* $Id: cid.c,v 1.2 2004/10/12 20:00:40 navaraf Exp $
+/* $Id: cid.c,v 1.2.2.1 2004/12/08 21:57:37 hyperion Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -66,7 +66,7 @@
   if(cido != NULL)
   {
     cido->ref = 1;
-    cido->Lock = 0;
+    ExInitializeFastMutex(&cido->Lock);
     cido->Obj.Object = Object;
 
     KeAcquireSpinLock(&CidLock, &oldIrql);
@@ -147,35 +147,16 @@
   
   if(Found != NULL)
   {
-    ULONG Attempt = 0;
-    for (;;)
-    {
-      if(InterlockedCompareExchange(&Found->Lock, 1, 0) == 0)
-      {
-        /* got the lock, bail */
-        break;
-      }
-
-      if(Attempt++ >= 1)
-      {
-        /* wait a little longer */
-        KeDelayExecutionThread(KernelMode, FALSE, &LongDelay);
-      }
-      else
-      {
-        /* try again, just wait shortly */
-        KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay);
-      }
-    }
+    ExAcquireFastMutex(&Found->Lock);
   }
-  
+
   return Found;
 }
 
 VOID
 PsUnlockCidObject(PCID_OBJECT CidObject)
 {
-  InterlockedExchange(&CidObject->Lock, 0);
+  ExReleaseFastMutex(&CidObject->Lock);
   PspDereferenceCidObject(CidObject);
 }
 

reactos/ntoskrnl/ps
kill.c 1.86 -> 1.86.2.1
diff -u -r1.86 -r1.86.2.1
--- kill.c	21 Nov 2004 18:42:58 -0000	1.86
+++ kill.c	8 Dec 2004 21:57:38 -0000	1.86.2.1
@@ -1,4 +1,4 @@
-/* $Id: kill.c,v 1.86 2004/11/21 18:42:58 gdalsnes Exp $
+/* $Id: kill.c,v 1.86.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -129,6 +129,8 @@
                      (ULONG) CurrentThread);
      }
 
+   KeCancelTimer(&CurrentThread->Tcb.Timer);
+
    KeAcquireSpinLock(&PiThreadLock, &oldIrql);
 
    DPRINT("terminating %x\n",CurrentThread);
@@ -136,13 +138,12 @@
    CurrentThread->HasTerminated = TRUE;
    CurrentThread->ExitStatus = ExitStatus;
    KeQuerySystemTime((PLARGE_INTEGER)&CurrentThread->ExitTime);
-   KeCancelTimer(&CurrentThread->Tcb.Timer);
 
    /* If the ProcessoR Control Block's NpxThread points to the current thread
     * unset it.
     */
-   InterlockedCompareExchange((LONG *)&KeGetCurrentKPCR()->PrcbData.NpxThread,
-                              (LONG)NULL, (LONG)ETHREAD_TO_KTHREAD(CurrentThread));
+   InterlockedCompareExchangePointer(&KeGetCurrentKPCR()->PrcbData.NpxThread,
+                                     NULL, ETHREAD_TO_KTHREAD(CurrentThread));
 
    KeReleaseSpinLock(&PiThreadLock, oldIrql);
  
@@ -175,6 +176,7 @@
          MmReleaseMemoryAreaIfDecommitted(CurrentProcess, &CurrentProcess->AddressSpace, TebBlock);
          MmUnlockAddressSpace(&CurrentProcess->AddressSpace);
        }
+     CurrentThread->Tcb.Teb = NULL;
      ExReleaseFastMutex(&CurrentProcess->TebLock);
    }
 
@@ -257,8 +259,15 @@
 
   DPRINT("PsTerminateOtherThread(Thread %x, ExitStatus %x)\n",
 	 Thread, ExitStatus);
-  
+
+  KeAcquireSpinLock(&PiThreadLock, &OldIrql);
+  if (Thread->HasTerminated)
+  {
+     KeReleaseSpinLock(&PiThreadLock, OldIrql);
+     return;
+  }
   Thread->HasTerminated = TRUE;
+  KeReleaseSpinLock(&PiThreadLock, OldIrql);
   Thread->ExitStatus = ExitStatus;
   Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
   KeInitializeApc(Apc,

reactos/ntoskrnl/ps
process.c 1.157 -> 1.157.2.1
diff -u -r1.157 -r1.157.2.1
--- process.c	24 Nov 2004 18:13:18 -0000	1.157
+++ process.c	8 Dec 2004 21:57:38 -0000	1.157.2.1
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.157 2004/11/24 18:13:18 navaraf Exp $
+/* $Id: process.c,v 1.157.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS kernel
@@ -18,7 +18,7 @@
 /* GLOBALS ******************************************************************/
 
 PEPROCESS EXPORTED PsInitialSystemProcess = NULL;
-HANDLE SystemProcessHandle = NULL;
+PEPROCESS PsIdleProcess = NULL;
 
 POBJECT_TYPE EXPORTED PsProcessType = NULL;
 
@@ -345,12 +345,6 @@
    strcpy(PsInitialSystemProcess->ImageFileName, "SYSTEM");
 
    SepCreateSystemProcessToken(PsInitialSystemProcess);
-
-   ObCreateHandle(PsInitialSystemProcess,
-		  PsInitialSystemProcess,
-		  PROCESS_ALL_ACCESS,
-		  FALSE,
-		  &SystemProcessHandle);
 }
 
 VOID STDCALL
@@ -583,14 +577,35 @@
 		      ACCESS_MASK DesiredAccess,
 		      POBJECT_ATTRIBUTES ObjectAttributes)
 {
-   return NtCreateProcess(ProcessHandle,
-			  DesiredAccess,
-			  ObjectAttributes,
-			  SystemProcessHandle,
-			  FALSE,
-			  NULL,
-			  NULL,
-			  NULL);
+   HANDLE SystemProcessHandle;
+   NTSTATUS Status;
+   
+   /* FIXME - what about security? should there be any privilege checks or something
+              security related? */
+   
+   Status = ObCreateHandle(PsGetCurrentProcess(),
+                           PsInitialSystemProcess,
+                           PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
+                           FALSE,
+                           &SystemProcessHandle);
+   if(!NT_SUCCESS(Status))
+   {
+      DPRINT1("Failed to create a handle for the system process!\n");
+      return Status;
+   }
+   
+   Status = NtCreateProcess(ProcessHandle,
+			    DesiredAccess,
+			    ObjectAttributes,
+			    SystemProcessHandle,
+			    FALSE,
+			    NULL,
+			    NULL,
+			    NULL);
+
+   NtClose(SystemProcessHandle);
+   
+   return Status;
 }
 
 NTSTATUS STDCALL

reactos/ntoskrnl/ps
thread.c 1.138 -> 1.138.2.1
diff -u -r1.138 -r1.138.2.1
--- thread.c	1 Nov 2004 19:10:07 -0000	1.138
+++ thread.c	8 Dec 2004 21:57:38 -0000	1.138.2.1
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.138 2004/11/01 19:10:07 hbirr Exp $
+/* $Id: thread.c,v 1.138.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * COPYRIGHT:              See COPYING in the top level directory
  * PROJECT:                ReactOS kernel
@@ -490,16 +490,20 @@
   PETHREAD Thread;
   PKWAIT_BLOCK WaitBlock;
 
-  KeAcquireSpinLock(&PiThreadLock, &oldIrql);
+  if (!DispatcherLock)
+    {
+      oldIrql = KeAcquireDispatcherDatabaseLock();
+      KiAcquireSpinLock(&PiThreadLock);
+    }
+  else
+    {
+      KeAcquireSpinLock(&PiThreadLock, &oldIrql);
+    }
 
   KThread = KeGetCurrentThread();
   Thread = CONTAINING_RECORD (KThread, ETHREAD, Tcb);
   if (KThread->ApcState.KernelApcPending)
   {
-    if (!DispatcherLock)
-      {
-	KeAcquireDispatcherDatabaseLockAtDpcLevel();
-      }
     WaitBlock = (PKWAIT_BLOCK)Thread->Tcb.WaitBlockList;
     while (WaitBlock)
       {
@@ -516,10 +520,7 @@
   }
   else
     {
-      if (DispatcherLock)
-	{
-	  KeReleaseDispatcherDatabaseLockFromDpcLevel();
-	}
+      KeReleaseDispatcherDatabaseLockFromDpcLevel();
       Thread->Tcb.Alertable = Alertable;
       Thread->Tcb.WaitMode = (UCHAR)WaitMode;
       Thread->Tcb.WaitIrql = WaitIrql;

reactos/ntoskrnl/ps
w32call.c 1.18 -> 1.18.2.1
diff -u -r1.18 -r1.18.2.1
--- w32call.c	20 Nov 2004 23:46:37 -0000	1.18
+++ w32call.c	8 Dec 2004 21:57:38 -0000	1.18.2.1
@@ -1,4 +1,4 @@
-/* $Id: w32call.c,v 1.18 2004/11/20 23:46:37 blight Exp $
+/* $Id: w32call.c,v 1.18.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * COPYRIGHT:              See COPYING in the top level directory
  * PROJECT:                ReactOS kernel
@@ -140,7 +140,6 @@
   Thread->Tcb.TrapFrame = SavedTrapFrame;
   Thread->Tcb.CallbackStack = SavedCallbackStack;
   KeGetCurrentKPCR()->TSS->Esp0 = (ULONG)SavedExceptionStack;
-  Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS); /* set TS */
   KeStackSwitchAndRet((PVOID)(OldStack + 1));
 
   /* Should never return. */
@@ -288,9 +287,7 @@
       AssignedStack = CONTAINING_RECORD(StackEntry, NTW32CALL_CALLBACK_STACK,
 					ListEntry);
       NewStack = AssignedStack->BaseAddress;
-
-      MmUpdatePageDir(PsGetCurrentProcess(), NewStack, StackSize);
-
+      memset(NewStack, 0, StackSize);
     }
   /* FIXME: Need to check whether we were interrupted from v86 mode. */
   memcpy((char*)NewStack + StackSize - sizeof(KTRAP_FRAME) - sizeof(FX_SAVE_AREA),

reactos/regtests/regtests
regtests.c 1.5 -> 1.5.4.1
diff -u -r1.5 -r1.5.4.1
--- regtests.c	24 Oct 2004 17:51:28 -0000	1.5
+++ regtests.c	8 Dec 2004 21:57:38 -0000	1.5.4.1
@@ -32,3 +32,25 @@
 {
   ExitProcess(uExitCode);
 }
+
+HANDLE STDCALL
+_CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
+              LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
+              DWORD dwCreationFlags, LPDWORD lpThreadId)
+{
+  return CreateThread(lpThreadAttributes, dwStackSize, lpStartAddress,
+                      lpParameter, dwCreationFlags, lpThreadId);
+}
+
+WINBOOL STDCALL
+_TerminateThread(HANDLE hThread, DWORD dwExitCode)
+{
+  return TerminateThread(hThread, dwExitCode);
+}
+
+DWORD STDCALL
+_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
+{
+  return WaitForSingleObject(hHandle, dwMilliseconds);
+}
+

reactos/regtests/regtests
regtests.def 1.2 -> 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- regtests.def	24 Oct 2004 17:51:29 -0000	1.2
+++ regtests.def	8 Dec 2004 21:57:38 -0000	1.2.4.1
@@ -4,3 +4,7 @@
 _GetModuleHandleA@4
 _GetProcAddress@8
 _LoadLibraryA@4
+_CreateThread@24
+_TerminateThread@8
+_WaitForSingleObject@8
+

reactos/regtests/shared
regtests.c 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- regtests.c	20 Nov 2004 17:48:38 -0000	1.9
+++ regtests.c	8 Dec 2004 21:57:38 -0000	1.9.2.1
@@ -19,6 +19,13 @@
 #define NDEBUG
 #include <debug.h>
 
+typedef struct _PERFORM_TEST_ARGS
+{
+  TestOutputRoutine OutputRoutine;
+  PROS_TEST Test;
+  LPSTR TestName;
+} PERFORM_TEST_ARGS;
+
 int _Result;
 char *_Buffer;
 
@@ -30,35 +37,17 @@
   InitializeListHead(&AllTests);
 }
 
-VOID
-PerformTest(TestOutputRoutine OutputRoutine, PROS_TEST Test, LPSTR TestName)
+DWORD WINAPI
+PerformTest(PVOID _arg)
 {
+  PERFORM_TEST_ARGS *Args = (PERFORM_TEST_ARGS *)_arg;
+  TestOutputRoutine OutputRoutine = Args->OutputRoutine;
+  PROS_TEST Test = Args->Test;
+  LPSTR TestName = Args->TestName;
   char OutputBuffer[5000];
   char Buffer[5000];
-  char Name[200];
 
   memset(Buffer, 0, sizeof(Buffer));
-  memset(Name, 0, sizeof(Name));
-
-  _Result = TS_OK;
-  _Buffer = Name;
-  (Test->Routine)(TESTCMD_TESTNAME);
-  if (_Result != TS_OK)
-    {
-      if (TestName != NULL)
-        {
-          return;
-        }
-      strcpy(Name, "Unnamed");
-    }
-
-  if (TestName != NULL)
-    {
-      if (_stricmp(Name, TestName) != 0)
-        {
-          return;
-        }
-    }
 
   _SEH_TRY {
     _Result = TS_OK;
@@ -71,11 +60,11 @@
 
   if (_Result != TS_OK)
     {
-      sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Failed (%s)\n", Name, Buffer);
+      sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Failed (%s)\n", TestName, Buffer);
     }
   else
     {
-      sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Success\n", Name);
+      sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Success\n", TestName);
     }
   if (OutputRoutine != NULL)
     {
@@ -85,6 +74,7 @@
     {
       DbgPrint(OutputBuffer);
     }
+  return 1;
 }
 
 VOID
@@ -93,14 +83,89 @@
   PLIST_ENTRY CurrentEntry;
   PLIST_ENTRY NextEntry;
   PROS_TEST Current;
+  PERFORM_TEST_ARGS Args;
+  HANDLE hThread;
+  char OutputBuffer[1024];
+  char Name[200];
+  DWORD TimeOut;
 
+  Args.OutputRoutine = OutputRoutine;
+  Args.TestName = Name;
+  
   CurrentEntry = AllTests.Flink;
-  while (CurrentEntry != &AllTests)
+  for (; CurrentEntry != &AllTests; CurrentEntry = NextEntry)
     {
       NextEntry = CurrentEntry->Flink;
       Current = CONTAINING_RECORD(CurrentEntry, ROS_TEST, ListEntry);
-      PerformTest(OutputRoutine, Current, TestName);
-      CurrentEntry = NextEntry;
+      Args.Test = Current;
+
+      /* Get name of test */
+      memset(Name, 0, sizeof(Name));
+
+      _Result = TS_OK;
+      _Buffer = Name;
+      (Current->Routine)(TESTCMD_TESTNAME);
+      if (_Result != TS_OK)
+        {
+          if (TestName != NULL)
+            {
+              continue;
+            }
+          strcpy(Name, "Unnamed");
+        }
+
+      if (TestName != NULL)
+        {
+          if (_stricmp(Name, TestName) != 0)
+            {
+              continue;
+            }
+        }
+
+      /* Get timeout for test */
+      TimeOut = 0;
+      _Result = TS_OK;
+      _Buffer = (char *)&TimeOut;
+      (Current->Routine)(TESTCMD_TIMEOUT);
+      if (_Result != TS_OK || TimeOut == INFINITE)
+        {
+          TimeOut = 5000;
+        }
+
+      /* Run test in thread */
+      hThread = _CreateThread(NULL, 0, PerformTest, (PVOID)&Args, 0, NULL);
+      if (hThread == NULL)
+        {
+          sprintf(OutputBuffer,
+                  "ROSREGTEST: |%s| Status: Failed (CreateThread failed: 0x%x)\n",
+                  Name, (unsigned int)GetLastError());
+        }
+      else if (_WaitForSingleObject(hThread, TimeOut) == WAIT_TIMEOUT)
+        {
+          if (!_TerminateThread(hThread, 0))
+            {
+              sprintf(OutputBuffer,
+                      "ROSREGTEST: |%s| Status: Failed (Test timed out - %d ms, TerminateThread failed: 0x%x)\n",
+                      Name, (int)TimeOut, (unsigned int)GetLastError());
+            }
+          else
+            {
+              sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Failed (Test timed out - %d ms)\n", Name, (int)TimeOut);
+            }
+        }
+      else
+        {
+          continue;
+        }
+
+      if (OutputRoutine != NULL)
+        {
+          (*OutputRoutine)(OutputBuffer);
+        }
+      else
+        {
+          DbgPrint(OutputBuffer);
+        }
     }
 }
 

reactos/regtests/shared
regtests.h 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- regtests.h	20 Nov 2004 17:56:23 -0000	1.12
+++ regtests.h	8 Dec 2004 21:57:38 -0000	1.12.2.1
@@ -17,6 +17,7 @@
 /* Valid values for Command parameter of TestRoutine */
 #define TESTCMD_RUN       0   /* Buffer contains information about what failed */
 #define TESTCMD_TESTNAME  1   /* Buffer contains description of test */
+#define TESTCMD_TIMEOUT   2   /* Buffer contains timeout for test (DWORD, default is 5000 ms) */
 
 /* Valid values for return values of TestRoutine */
 #define TS_EXCEPTION     -1
@@ -27,7 +28,7 @@
 extern char *_Buffer;
 
 /* Macros to simplify tests */
-#define _Dispatcher(FunctionName, TestName) \
+#define _DispatcherTimeout(FunctionName, TestName, TimeOut) \
 void \
 FunctionName(int Command) \
 { \
@@ -39,12 +40,17 @@
       case TESTCMD_TESTNAME: \
         strcpy(_Buffer, TestName); \
         break; \
+      case TESTCMD_TIMEOUT: \
+        *(PDWORD)_Buffer = (DWORD)TimeOut; \
+        break; \
       default: \
         _Result = TS_FAILED; \
         break; \
     } \
 }
 
+#define _Dispatcher(FunctionName, TestName) _DispatcherTimeout(FunctionName, TestName, 5000)
+
 static inline void
 AppendAssertion(char *message)
 {
@@ -173,6 +179,18 @@
 VOID STDCALL
 _ExitProcess(UINT uExitCode);
 
+HANDLE STDCALL
+_CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
+              LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
+              DWORD dwCreationFlags, LPDWORD lpThreadId);
+
+WINBOOL STDCALL
+_TerminateThread(HANDLE hThread, DWORD dwExitCode);
+
+DWORD STDCALL
+_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
+
+
 static inline PCHAR
 FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription)
 {

reactos/subsys/csrss/win32csr
desktopbg.c 1.11 -> 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- desktopbg.c	20 Nov 2004 16:46:05 -0000	1.11
+++ desktopbg.c	8 Dec 2004 21:57:38 -0000	1.11.2.1
@@ -1,4 +1,4 @@
-/* $Id: desktopbg.c,v 1.11 2004/11/20 16:46:05 weiden Exp $
+/* $Id: desktopbg.c,v 1.11.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * reactos/subsys/csrss/win32csr/desktopbg.c
  *
@@ -30,11 +30,8 @@
 
 #define DESKTOP_WINDOW_ATOM 32880
 
-#ifndef WM_APP
-#define WM_APP 0x8000
-#endif
-#define PM_SHOW_DESKTOP (WM_APP + 1)
-#define PM_HIDE_DESKTOP (WM_APP + 2)
+#define PM_SHOW_DESKTOP 1
+#define PM_HIDE_DESKTOP 2
 
 typedef struct tagDTBG_THREAD_DATA
 {

reactos/subsys/csrss/win32csr
guiconsole.c 1.22 -> 1.22.2.1
diff -u -r1.22 -r1.22.2.1
--- guiconsole.c	20 Nov 2004 16:46:05 -0000	1.22
+++ guiconsole.c	8 Dec 2004 21:57:38 -0000	1.22.2.1
@@ -1,4 +1,4 @@
-/* $Id: guiconsole.c,v 1.22 2004/11/20 16:46:05 weiden Exp $
+/* $Id: guiconsole.c,v 1.22.2.1 2004/12/08 21:57:38 hyperion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -129,9 +129,10 @@
   GuiData->MemoryBitmap = CreateCompatibleBitmap(Dc, 
                                                  Console->Size.X * GuiData->CharWidth, 
 						 Console->Size.Y * GuiData->CharHeight);
-  DeleteObject(SelectObject(GuiData->MemoryDC, GuiData->MemoryBitmap));
-  DeleteObject(SelectObject(GuiData->MemoryDC, GuiData->Font));
-
+  /* NOTE: Don't delete the "first bitmap", it's done in DeleteDC. */
+  SelectObject(GuiData->MemoryDC, GuiData->MemoryBitmap);
+  /* NOTE: Don't delete stock font. */
+  SelectObject(GuiData->MemoryDC, GuiData->Font); 
 
   ReleaseDC(hWnd, Dc);
   GuiData->CursorBlinkOn = TRUE;

reactos/subsys/system/explorer
Makefile 1.43 -> 1.43.2.1
diff -u -r1.43 -r1.43.2.1
--- Makefile	21 Nov 2004 10:53:55 -0000	1.43
+++ Makefile	8 Dec 2004 21:57:39 -0000	1.43.2.1
@@ -16,7 +16,7 @@
 TARGET_CPPFLAGS := $(TARGET_CFLAGS)
 TARGET_RCFLAGS := -D__USE_W32API -DWIN32 -D_ROS_ -D__WINDRES__
 TARGET_SDKLIBS := \
-	gdi32.a comctl32.a ole32.a oleaut32.a shell32.a libexpat.a \
+	gdi32.a comctl32.a ole32.a oleaut32.a shell32.a expat.a \
 	notifyhook.a ws2_32.a msimg32.a
 TARGET_GCCLIBS := stdc++ uuid
 TARGET_OBJECTS := \

reactos/subsys/system/msiexec
Makefile 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- Makefile	27 Aug 2004 23:08:00 -0000	1.1
+++ Makefile	8 Dec 2004 21:57:39 -0000	1.1.6.1
@@ -11,7 +11,7 @@
 TARGET_CFLAGS = -I$(PATH_TO_TOP)/include/wine -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
 
 TARGET_OBJECTS = msiexec.o
-TARGET_SDKLIBS = msi.a ole32.a ntdll.a user32.a kernel32.a libwine.a wine_uuid.a
+TARGET_SDKLIBS = msi.a ole32.a ntdll.a user32.a kernel32.a wine.a wine_uuid.a
 TARGET_RC_SRCS = version.rc
 
 TARGET_RC_BINSRC = 

reactos/subsys/system/msiexec
msiexec.c 1.1 -> 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- msiexec.c	27 Aug 2004 23:08:00 -0000	1.1
+++ msiexec.c	8 Dec 2004 21:57:39 -0000	1.1.6.1
@@ -110,6 +110,20 @@
 	if(len && String[len-1] == character) String[len-1] = 0;
 }
 
+static INT MSIEXEC_lstrncmpiA(LPCSTR str1, LPCSTR str2, INT size)
+{
+    INT ret;
+
+    if ((str1 == NULL) && (str2 == NULL)) return 0;
+    if (str1 == NULL) return -1;
+    if (str2 == NULL) return 1;
+
+    ret = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, str1, size, str2, -1);
+    if (ret) ret -= 2;
+
+    return ret;
+}
+
 static VOID *LoadProc(LPCSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
 {
 	VOID* (*proc)(void);
@@ -179,6 +193,9 @@
 	BOOL FunctionPatch = FALSE;
 	BOOL FunctionDllRegisterServer = FALSE;
 	BOOL FunctionDllUnregisterServer = FALSE;
+	BOOL FunctionRegServer = FALSE;
+	BOOL FunctionUnregServer = FALSE;
+	BOOL FunctionUnknown = FALSE;
 
 	BOOL GotProductCode = FALSE;
 	LPCSTR PackageName = NULL;
@@ -209,16 +226,30 @@
 	{
 		WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 
-		if(!strcasecmp(argv[i], "/i"))
+                if (!lstrcmpiA(argv[i], "/regserver"))
+                {
+                    FunctionRegServer = TRUE;
+                }
+                else if (!lstrcmpiA(argv[i], "/unregserver") || !lstrcmpiA(argv[i], "/unregister"))
+                {
+                    FunctionUnregServer = TRUE;
+                }
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "/i", 2))
 		{
+			char *argvi = argv[i];
 			FunctionInstall = TRUE;
-			i++;
-			if(i >= argc)
-				ShowUsage(1);
-			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
-			GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
+			if(strlen(argvi) > 2)
+				argvi += 2;
+			else {
+				i++;
+				if(i >= argc)
+					ShowUsage(1);
+				WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
+				argvi = argv[i];
+			}
+			GotProductCode = GetProductCode(argvi, &PackageName, &ProductCode);
 		}
-		else if(!strcasecmp(argv[i], "/a"))
+		else if(!lstrcmpiA(argv[i], "/a"))
 		{
 			FunctionInstall = TRUE;
 			FunctionInstallAdmin = TRUE;
@@ -230,7 +261,7 @@
 			PackageName = argv[i];
 			StringListAppend(&Properties, ActionAdmin);
 		}
-		else if(!strncasecmp(argv[i], "/f", 2))
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "/f", 2))
 		{
 			int j;
 			int len = strlen(argv[i]);
@@ -298,7 +329,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
 		}
-		else if(!strcasecmp(argv[i], "/x"))
+		else if(!lstrcmpiA(argv[i], "/x"))
 		{
 			FunctionInstall = TRUE;
 			i++;
@@ -308,7 +339,7 @@
 			GotProductCode = GetProductCode(argv[i], &PackageName, &ProductCode);
 			StringListAppend(&Properties, RemoveAll);
 		}
-		else if(!strncasecmp(argv[i], "/j", 2))
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "/j", 2))
 		{
 			int j;
 			int len = strlen(argv[i]);
@@ -336,7 +367,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			PackageName = argv[i];
 		}
-		else if(!strcasecmp(argv[i], "u"))
+		else if(!lstrcmpiA(argv[i], "u"))
 		{
 			FunctionAdvertise = TRUE;
 			AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
@@ -346,7 +377,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			PackageName = argv[i];
 		}
-		else if(!strcasecmp(argv[i], "m"))
+		else if(!lstrcmpiA(argv[i], "m"))
 		{
 			FunctionAdvertise = TRUE;
 			AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
@@ -356,7 +387,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			PackageName = argv[i];
 		}
-		else if(!strcasecmp(argv[i], "/t"))
+		else if(!lstrcmpiA(argv[i], "/t"))
 		{
 			i++;
 			if(i >= argc)
@@ -365,12 +396,12 @@
 			StringListAppend(&Transforms, argv[i]);
 			StringListAppend(&Transforms, ";");
 		}
-		else if(!strncasecmp(argv[i], "TRANSFORMS=", 11))
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "TRANSFORMS=", 11))
 		{
 			StringListAppend(&Transforms, argv[i]+11);
 			StringListAppend(&Transforms, ";");
 		}
-		else if(!strcasecmp(argv[i], "/g"))
+		else if(!lstrcmpiA(argv[i], "/g"))
 		{
 			i++;
 			if(i >= argc)
@@ -378,7 +409,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			Language = strtol(argv[i], NULL, 0);
 		}
-		else if(!strncasecmp(argv[i], "/l", 2))
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "/l", 2))
 		{
 			int j;
 			int len = strlen(argv[i]);
@@ -468,7 +499,7 @@
 				ExitProcess(1);
 			}
 		}
-		else if(!strcasecmp(argv[i], "/p"))
+		else if(!lstrcmpiA(argv[i], "/p"))
 		{
 			FunctionPatch = TRUE;
 			i++;
@@ -477,36 +508,41 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			PatchFileName = argv[i];
 		}
-		else if(!strncasecmp(argv[i], "/q", 2))
+		else if(!MSIEXEC_lstrncmpiA(argv[i], "/q", 2))
 		{
-			if(strlen(argv[i]) == 2 || !strcasecmp(argv[i]+2, "n"))
+			if(strlen(argv[i]) == 2 || !lstrcmpiA(argv[i]+2, "n"))
 			{
 				InstallUILevel = INSTALLUILEVEL_NONE;
 			}
-			else if(!strcasecmp(argv[i]+2, "b"))
+			else if(!lstrcmpiA(argv[i]+2, "b"))
 			{
 				InstallUILevel = INSTALLUILEVEL_BASIC;
 			}
-			else if(!strcasecmp(argv[i]+2, "r"))
+			else if(!lstrcmpiA(argv[i]+2, "r"))
 			{
 				InstallUILevel = INSTALLUILEVEL_REDUCED;
 			}
-			else if(!strcasecmp(argv[i]+2, "f"))
+			else if(!lstrcmpiA(argv[i]+2, "f"))
 			{
 				InstallUILevel = INSTALLUILEVEL_FULL|INSTALLUILEVEL_ENDDIALOG;
 			}
-			else if(!strcasecmp(argv[i]+2, "n+"))
+			else if(!lstrcmpiA(argv[i]+2, "n+"))
 			{
 				InstallUILevel = INSTALLUILEVEL_NONE|INSTALLUILEVEL_ENDDIALOG;
 			}
-			else if(!strcasecmp(argv[i]+2, "b+"))
+			else if(!lstrcmpiA(argv[i]+2, "b+"))
 			{
 				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
 			}
-			else if(!strcasecmp(argv[i]+2, "b-"))
+			else if(!lstrcmpiA(argv[i]+2, "b-"))
 			{
 				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_PROGRESSONLY;
 			}
+			else if(!lstrcmpiA(argv[i]+2, "b+!"))
+            		{
+				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
+				WINE_FIXME("Unknown modifier: !\n");
+			}
 			else
 			{
 				fprintf(stderr, "Unknown option \"%s\" for UI level\n", argv[i]+2);
@@ -518,7 +554,7 @@
 				ExitProcess(1);
 			}
 		}
-		else if(!strcasecmp(argv[i], "/y"))
+		else if(!lstrcmpiA(argv[i], "/y"))
 		{
 			FunctionDllRegisterServer = TRUE;
 			i++;
@@ -527,7 +563,7 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			DllName = argv[i];
 		}
-		else if(!strcasecmp(argv[i], "/z"))
+		else if(!lstrcmpiA(argv[i], "/z"))
 		{
 			FunctionDllUnregisterServer = TRUE;
 			i++;
@@ -536,10 +572,20 @@
 			WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
 			DllName = argv[i];
 		}
-		else if(!strcasecmp(argv[i], "/h") || !strcasecmp(argv[i], "/?"))
+		else if(!lstrcmpiA(argv[i], "/h") || !lstrcmpiA(argv[i], "/?"))
 		{
 			ShowUsage(0);
 		}
+		else if(!lstrcmpiA(argv[i], "/m"))
+		{
+			FunctionUnknown = TRUE;
+			WINE_FIXME("Unknown parameter /m\n");
+		}
+		else if(!lstrcmpiA(argv[i], "/D"))
+		{
+			FunctionUnknown = TRUE;
+			WINE_FIXME("Unknown parameter /D\n");
+		}
 		else if(strchr(argv[i], '='))
 		{
 			StringListAppend(&Properties, argv[i]);
@@ -614,6 +660,18 @@
 	{
 		DllUnregisterServer(DllName);
 	}
+	else if (FunctionRegServer)
+	{
+		WINE_FIXME( "/regserver not implemented yet, ignoring\n" );
+	}
+	else if (FunctionUnregServer)
+	{
+		WINE_FIXME( "/unregserver not implemented yet, ignoring\n" );
+	}
+	else if (FunctionUnknown)
+	{
+		WINE_FIXME( "Unknown function, ignoring\n" );
+	}
 	else
 		ShowUsage(1);
 

reactos/subsys/system/winlogon
winlogon.h 1.4 -> 1.4.8.1
diff -u -r1.4 -r1.4.8.1
--- winlogon.h	12 Jul 2004 20:09:35 -0000	1.4
+++ winlogon.h	8 Dec 2004 21:57:39 -0000	1.4.8.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: winlogon.h,v 1.4 2004/07/12 20:09:35 gvg Exp $
+/* $Id: winlogon.h,v 1.4.8.1 2004/12/08 21:57:39 hyperion Exp $
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS winlogon
  * FILE:            subsys/system/winlogon/winlogon.h
@@ -163,6 +163,11 @@
 #define DisplaySASNotice(Session) \
   Session->MsGina.Functions.WlxDisplaySASNotice(Session->MsGina.Context);
 
+/* user32 */
+BOOL WINAPI
+UpdatePerUserSystemParameters(DWORD dwUnknown,
+                              DWORD dwReserved);
+
 #endif /* __WINLOGON_MAIN_H__ */
 
 /* EOF */

reactos/subsys/win32k/include
desktop.h 1.9 -> 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- desktop.h	20 Nov 2004 16:46:05 -0000	1.9
+++ desktop.h	8 Dec 2004 21:57:39 -0000	1.9.2.1
@@ -12,6 +12,7 @@
 extern HDESK InputDesktopHandle; 
 extern PWNDCLASS_OBJECT DesktopWindowClass;
 extern HDC ScreenDeviceContext;
+extern BOOL g_PaintDesktopVersion;
 
 NTSTATUS FASTCALL
 InitDesktopImpl(VOID);

reactos/subsys/win32k
makefile 1.105 -> 1.105.2.1
diff -u -r1.105 -r1.105.2.1
--- makefile	16 Nov 2004 16:29:21 -0000	1.105
+++ makefile	8 Dec 2004 21:57:39 -0000	1.105.2.1
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.105 2004/11/16 16:29:21 blight Exp $
+# $Id: makefile,v 1.105.2.1 2004/12/08 21:57:39 hyperion Exp $
 
 PATH_TO_TOP = ../..
 
@@ -44,8 +44,8 @@
  $(CFLAGS_OPT)
 
 TARGET_LFLAGS =\
- $(PATH_TO_TOP)/dk/nkm/lib/freetype.a \
- $(PATH_TO_TOP)/dk/w32/lib/rosrtl.a \
+ $(PATH_TO_TOP)/dk/nkm/lib/libfreetype.a \
+ $(PATH_TO_TOP)/dk/w32/lib/librosrtl.a \
  --disable-stdcall-fixup
 
 ENG_OBJECTS= eng/debug.o eng/error.o eng/mem.o eng/brush.o eng/bitblt.o \

reactos/subsys/win32k/ntuser
desktop.c 1.24 -> 1.24.2.1
diff -u -r1.24 -r1.24.2.1
--- desktop.c	20 Nov 2004 16:46:06 -0000	1.24
+++ desktop.c	8 Dec 2004 21:57:39 -0000	1.24.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: desktop.c,v 1.24 2004/11/20 16:46:06 weiden Exp $
+ *  $Id: desktop.c,v 1.24.2.1 2004/12/08 21:57:39 hyperion Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -50,6 +50,8 @@
 HDESK InputDesktopHandle = NULL; 
 HDC ScreenDeviceContext = NULL;
 
+BOOL g_PaintDesktopVersion = FALSE;
+
 /* INITALIZATION FUNCTIONS ****************************************************/
 
 NTSTATUS FASTCALL
@@ -496,7 +498,7 @@
   CSRSS_API_REQUEST Request;
   CSRSS_API_REPLY Reply;
   
-  DPRINT1("CreateDesktop: %wZ\n", lpszDesktopName);
+  DPRINT("CreateDesktop: %wZ\n", lpszDesktopName);
 
   Status = IntValidateWindowStationHandle(
     hWindowStation,
@@ -880,20 +882,6 @@
   return len;
 }
 
-static NTSTATUS STDCALL PaintDesktopVersionCallback(
-	IN PWSTR ValueName, IN ULONG ValueType,
-	IN PVOID ValueData, IN ULONG ValueLength,
-	IN PVOID Context, IN PVOID EntryContext
-)
-{
-  DPRINT("PaintDesktopVersionCallback ValueType=%d ValueLength=%d\n", ValueType, ValueLength);
-
-  if (ValueType==REG_DWORD && ValueLength==sizeof(DWORD))
-	*((DWORD*)EntryContext) = *(DWORD*)ValueData;
-
-  return STATUS_SUCCESS;
-}
-
 /*
  * NtUserPaintDesktop
  *
@@ -916,10 +904,6 @@
   HBRUSH DesktopBrush, PreviousBrush;
   HWND hWndDesktop;
   BOOL doPatBlt = TRUE;
-
-  RTL_QUERY_REGISTRY_TABLE queryTable[2];
-  DWORD displayVersion;
-  NTSTATUS status;
   int len;
 
   PWINSTATION_OBJECT WinSta = PsGetWin32Thread()->Desktop->WindowStation;
@@ -984,22 +968,7 @@
    * Display system version on the desktop background
    */
 
-  RtlZeroMemory(queryTable, sizeof(queryTable));
-
-  queryTable[0].QueryRoutine = PaintDesktopVersionCallback;
-  queryTable[0].Name = L"PaintDesktopVersion";
-  queryTable[0].EntryContext = &displayVersion;
-
-  /* query the "PaintDesktopVersion" flag in the "Control Panel\Desktop" key */
-  status = RtlQueryRegistryValues(RTL_REGISTRY_USER, L"Control Panel\\Desktop", queryTable, NULL, NULL);
-
-  if (!NT_SUCCESS(status)) {
-	DPRINT1("RtlQueryRegistryValues failed for PaintDesktopVersion: status=%x\n", status);
-	displayVersion = 0;
-  }
-  DPRINT("PaintDesktopVersion=%d\n", displayVersion);
-
-  if (displayVersion) {
+  if (g_PaintDesktopVersion) {
 	static WCHAR s_wszVersion[256] = {0};
 	RECT rect;
 

reactos/subsys/win32k/ntuser
focus.c 1.25 -> 1.25.2.1
diff -u -r1.25 -r1.25.2.1
--- focus.c	24 Nov 2004 00:11:06 -0000	1.25
+++ focus.c	8 Dec 2004 21:57:39 -0000	1.25.2.1
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: focus.c,v 1.25 2004/11/24 00:11:06 weiden Exp $
+ * $Id: focus.c,v 1.25.2.1 2004/12/08 21:57:39 hyperion Exp $
  */
 
 #include <w32k.h>
@@ -53,7 +53,7 @@
    if (hWndPrev)
    {
       IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
-      IntPostOrSendMessage(hWnd, WM_ACTIVATE,
+      IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
          MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
          (LPARAM)hWnd);
    }
@@ -174,6 +174,9 @@
 
    /* FIXME: Call hooks. */
 
+   IntSendDeactivateMessages(hWndPrev, hWnd);
+   IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
+
    IntSetFocusMessageQueue(Window->MessageQueue);
    IntLockMessageQueue(Window->MessageQueue);
    if (Window->MessageQueue)
@@ -188,12 +191,11 @@
    }
    IntUnLockMessageQueue(FocusWindow->MessageQueue);
 
-   IntSendDeactivateMessages(hWndPrev, hWnd);
-   IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
    if (PrevForegroundQueue != Window->MessageQueue)
    {
       /* FIXME: Send WM_ACTIVATEAPP to all thread windows. */
    }
+
    IntSendSetFocusMessages(hWndFocusPrev, hWndFocus);
    IntSendActivateMessages(hWndPrev, hWnd, MouseActivate);
    

reactos/subsys/win32k/ntuser
misc.c 1.88 -> 1.88.2.1
diff -u -r1.88 -r1.88.2.1
--- misc.c	20 Nov 2004 16:46:06 -0000	1.88
+++ misc.c	8 Dec 2004 21:57:40 -0000	1.88.2.1
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.88 2004/11/20 16:46:06 weiden Exp $
+/* $Id: misc.c,v 1.88.2.1 2004/12/08 21:57:40 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -1330,4 +1330,44 @@
     }
 }
 
+
+BOOL STDCALL
+NtUserUpdatePerUserSystemParameters(
+   DWORD dwUnknown,
+   BOOL bEnable)
+{
+   if (bEnable)
+   {
+      RTL_QUERY_REGISTRY_TABLE QueryTable[2];
+      NTSTATUS Status;
+
+      RtlZeroMemory(QueryTable, sizeof(QueryTable));
+
+      QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
+      QueryTable[0].Name = L"PaintDesktopVersion";
+      QueryTable[0].EntryContext = &g_PaintDesktopVersion;
+
+      /* Query the "PaintDesktopVersion" flag in the "Control Panel\Desktop" key */
+      Status = RtlQueryRegistryValues(RTL_REGISTRY_USER, 
+                                      L"Control Panel\\Desktop",
+                                      QueryTable, NULL, NULL);
+      if (!NT_SUCCESS(Status))
+      {
+         DPRINT1("RtlQueryRegistryValues failed for PaintDesktopVersion (%x)\n",
+                 Status);
+         g_PaintDesktopVersion = FALSE;
+         return FALSE;
+      }
+    
+      DPRINT1("PaintDesktopVersion = %d\n", g_PaintDesktopVersion);
+
+      return TRUE;
+   }
+   else
+   {
+      g_PaintDesktopVersion = FALSE;
+      return TRUE;
+   }
+}
+
 /* EOF */

reactos/subsys/win32k/ntuser
painting.c 1.87 -> 1.87.2.1
diff -u -r1.87 -r1.87.2.1
--- painting.c	15 Nov 2004 23:10:42 -0000	1.87
+++ painting.c	8 Dec 2004 21:57:40 -0000	1.87.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: painting.c,v 1.87 2004/11/15 23:10:42 gvg Exp $
+ *  $Id: painting.c,v 1.87.2.1 2004/12/08 21:57:40 hyperion Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -640,6 +640,11 @@
          Message->lParam = 0;
          if (Remove)
          {
+            if ((HANDLE) 1 != Window->NCUpdateRegion &&
+                NULL != Window->NCUpdateRegion)
+              {
+                GDIOBJ_SetOwnership(Window->NCUpdateRegion, PsGetCurrentProcess());
+              }
             IntValidateParent(Window, Window->NCUpdateRegion);
             Window->NCUpdateRegion = NULL;
             Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;

reactos/subsys/win32k/ntuser
stubs.c 1.47 -> 1.47.2.1
diff -u -r1.47 -r1.47.2.1
--- stubs.c	16 Nov 2004 16:27:49 -0000	1.47
+++ stubs.c	8 Dec 2004 21:57:40 -0000	1.47.2.1
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.47 2004/11/16 16:27:49 blight Exp $
+/* $Id: stubs.c,v 1.47.2.1 2004/12/08 21:57:40 hyperion Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -690,17 +690,6 @@
 
 DWORD
 STDCALL
-NtUserUpdatePerUserSystemParameters(
-  DWORD Unknown0,
-  DWORD Unknown1)
-{
-  UNIMPLEMENTED
-
-  return 0;
-}
-
-DWORD
-STDCALL
 NtUserUserHandleGrantAccess(
   DWORD Unknown0,
   DWORD Unknown1,

reactos/subsys/win32k/objects
brush.c 1.40 -> 1.40.10.1
diff -u -r1.40 -r1.40.10.1
--- brush.c	14 Jul 2004 20:48:57 -0000	1.40
+++ brush.c	8 Dec 2004 21:57:41 -0000	1.40.10.1
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: brush.c,v 1.40 2004/07/14 20:48:57 navaraf Exp $
+ * $Id: brush.c,v 1.40.10.1 2004/12/08 21:57:41 hyperion Exp $
  */
 #include <w32k.h>
 
@@ -39,6 +39,7 @@
   if(pBrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
   {
     ASSERT(pBrush->hbmPattern);
+    GDIOBJ_SetOwnership(pBrush->hbmPattern, PsGetCurrentProcess());
     NtGdiDeleteObject(pBrush->hbmPattern);
   }
   
@@ -161,6 +162,9 @@
          UNIMPLEMENTED;
    }
 
+   if (hPattern != 0)
+      GDIOBJ_SetOwnership(hPattern, NULL);
+   
    BRUSHOBJ_UnlockBrush(hBrush);
    return hBrush;
 }

reactos/subsys/win32k/objects
cliprgn.c 1.42 -> 1.42.10.1
diff -u -r1.42 -r1.42.10.1
--- cliprgn.c	14 Jul 2004 20:48:58 -0000	1.42
+++ cliprgn.c	8 Dec 2004 21:57:41 -0000	1.42.10.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: cliprgn.c,v 1.42 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: cliprgn.c,v 1.42.10.1 2004/12/08 21:57:41 hyperion Exp $ */
 #include <w32k.h>
 
 int FASTCALL
@@ -43,9 +43,13 @@
       CombinedRegion->rdh.nCount,
       (PRECTL)CombinedRegion->Buffer,
       (PRECTL)&CombinedRegion->rdh.rcBound);
-   ASSERT(Dc->CombinedClip != NULL);
 
    RGNDATA_UnlockRgn(Dc->w.hGCClipRgn);
+   if ( NULL == Dc->CombinedClip )
+   {
+	   DPRINT1("IntEngCreateClipRegion() failed\n");
+	   return ERROR;
+   }
    return NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY);
 }
 
@@ -99,7 +103,8 @@
     }
 
   retval = NtGdiCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY);
-  CLIPPING_UpdateGCRegion(dc);
+  if ( retval != ERROR )
+    retval = CLIPPING_UpdateGCRegion(dc);
   DC_UnlockDc( hdc );
 
   return retval;

reactos/subsys/win32k/objects
dc.c 1.147 -> 1.147.2.1
diff -u -r1.147 -r1.147.2.1
--- dc.c	16 Nov 2004 16:27:49 -0000	1.147
+++ dc.c	8 Dec 2004 21:57:41 -0000	1.147.2.1
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dc.c,v 1.147 2004/11/16 16:27:49 blight Exp $
+/* $Id: dc.c,v 1.147.2.1 2004/12/08 21:57:41 hyperion Exp $
  *
  * DC.C - Device context functions
  *
@@ -1223,7 +1223,11 @@
 
 	  dc->w.hClipRgn = 0;
 	}
-	CLIPPING_UpdateGCRegion( dc );
+	{
+		int res;
+		res = CLIPPING_UpdateGCRegion( dc );
+		ASSERT ( res != ERROR );
+	}
 	DC_UnlockDc ( hDC );
 #else
 	DC_UnlockDc ( hDC );
@@ -2022,8 +2026,13 @@
   NtGdiSelectObject(DCHandle, NtGdiGetStockObject( BLACK_PEN ));
   //NtGdiSelectObject(DCHandle, hFont);
 
-//  CLIPPING_UpdateGCRegion(DCToInit);
-
+/*
+  {
+    int res;
+    res = CLIPPING_UpdateGCRegion(DCToInit);
+    ASSERT ( res != ERROR );
+  }
+*/
 }
 
 VOID FASTCALL

reactos/tools
helper.mk 1.95 -> 1.95.2.1
diff -u -r1.95 -r1.95.2.1
--- helper.mk	20 Nov 2004 17:48:38 -0000	1.95
+++ helper.mk	8 Dec 2004 21:57:41 -0000	1.95.2.1
@@ -1,4 +1,4 @@
-# $Id: helper.mk,v 1.95 2004/11/20 17:48:38 chorns Exp $
+# $Id: helper.mk,v 1.95.2.1 2004/12/08 21:57:41 hyperion Exp $
 #
 # Helper makefile for ReactOS modules
 # Variables this makefile accepts:
@@ -51,6 +51,7 @@
 #   $TARGET_BOOTSTRAP  = Whether this file is needed to bootstrap the installation (no,yes) (optional)
 #   $TARGET_BOOTSTRAP_NAME = Name on the installation medium (optional)
 #   $TARGET_REGTESTS   = This module has regression tests (no,yes) (optional)
+#   $TARGET_INSTALL    = Install the file (no,yes) (optional)
 #   $SUBDIRS           = Subdirs in which to run make (optional)
 
 include $(PATH_TO_TOP)/config
@@ -276,6 +277,8 @@
   MK_BOOTCDDIR := .
   MK_DISTDIR := dlls
   MK_RES_BASE := $(TARGET_NAME)
+  MK_INSTALL_BASENAME := hal
+  MK_INSTALL_FULLNAME := hal.dll
 endif
 
 ifeq ($(TARGET_TYPE),bootpgm)
@@ -374,7 +377,6 @@
   TARGET_OBJECTS := _rtstub.o _regtests.o $(TARGET_OBJECTS)
 endif
 
-
 # can be overidden with $(CXX) for linkage of c++ executables
 LD_CC = $(CC)
 
@@ -591,16 +593,16 @@
     MK_DEFBASE := 0x400000
   endif
   ifneq ($(TARGET_SDKLIBS),)
-    MK_LIBS := $(addprefix $(SDK_PATH_LIB)/, $(TARGET_SDKLIBS))
+    MK_LIBS := $(addprefix $(SDK_PATH_LIB)/lib, $(TARGET_SDKLIBS))
   else
-    MK_LIBS := $(addprefix $(SDK_PATH_LIB)/, $(MK_SDKLIBS))
+    MK_LIBS := $(addprefix $(SDK_PATH_LIB)/lib, $(MK_SDKLIBS))
   endif
 endif
 
 
 ifeq ($(MK_MODE),kernel)
   MK_DEFBASE := 0x10000
-  MK_LIBS := $(addprefix $(DDK_PATH_LIB)/, $(TARGET_DDKLIBS) $(MK_DDKLIBS))
+  MK_LIBS := $(addprefix $(DDK_PATH_LIB)/lib, $(TARGET_DDKLIBS) $(MK_DDKLIBS))
   MK_CFLAGS += -D_SEH_NO_NATIVE_NLG
   MK_CPPFLAGS += -D_SEH_NO_NATIVE_NLG
   MK_LFLAGS += -nostartfiles
@@ -651,18 +653,19 @@
 MK_GCCLIBS := $(addprefix -l, $(TARGET_GCCLIBS))
 
 ifeq ($(MK_MODE),static)
-  MK_FULLNAME := $(MK_LIBPATH)/$(MK_BASENAME)$(MK_EXT)
+  MK_FULLNAME := $(MK_LIBPATH)/lib$(MK_BASENAME)$(MK_EXT)
 else
   MK_FULLNAME := $(MK_BASENAME)$(MK_EXT)
 endif
 
 ifeq ($(TARGET_TYPE), kmlibrary)
-  MK_FULLNAME := $(DDK_PATH_LIB)/$(MK_BASENAME)$(MK_EXT)
+  MK_FULLNAME := $(DDK_PATH_LIB)/lib$(MK_BASENAME)$(MK_EXT)
 endif
 
-MK_IMPLIB_FULLNAME := $(MK_BASENAME)$(MK_IMPLIB_EXT)
+MK_IMPLIB_FULLNAME := lib$(MK_BASENAME)$(MK_IMPLIB_EXT)
 
 MK_NOSTRIPNAME := $(MK_BASENAME).nostrip$(MK_EXT)
+MK_DEBUGNAME := $(MK_BASENAME).dbg
 
 MK_EXTRADEP := $(filter %.h,$(TARGET_OBJECTS))
 
@@ -689,6 +692,19 @@
   MK_REGTESTS_CLEAN :=
 endif
 
+ifeq ($(TARGET_INSTALL),)
+ MK_INSTALL := yes
+else
+ MK_INSTALL := $(TARGET_INSTALL)
+endif
+
+ifeq ($(MK_INSTALL_BASENAME),)
+  MK_INSTALL_BASENAME := $(MK_BASENAME)
+endif
+ifeq ($(MK_INSTALL_FULLNAME),)
+  MK_INSTALL_FULLNAME := $(MK_FULLNAME)
+endif
+
 ifeq ($(MK_IMPLIBONLY),yes)
 
 TARGET_CLEAN += $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
@@ -699,7 +715,7 @@
 	$(DLLTOOL) \
 		--dllname $(MK_FULLNAME) \
 		--def $(MK_DEFNAME) \
-		--output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \
+		--output-lib $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME) \
 		$(MK_KILLAT)
 
 else # MK_IMPLIBONLY
@@ -911,13 +927,13 @@
 endif
 
 ifeq ($(MK_IMPLIB),yes)
-$(MK_IMPLIBPATH)/$(MK_BASENAME).a: $(MK_DEFNAME)
+$(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(MK_DEFNAME)
 	$(DLLTOOL) --dllname $(MK_FULLNAME) \
 		--def $(MK_DEFNAME) \
-		--output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \
+		--output-lib $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME) \
 		$(MK_KILLAT)
 
-implib: $(MK_IMPLIBPATH)/$(MK_BASENAME).a
+implib: $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
 else
 implib: $(SUBDIRS:%=%_implib)
 endif
@@ -963,6 +979,8 @@
 
 # Don't install import libraries
 
+forceinstall:
+
 install:
 
 bootcd:
@@ -973,23 +991,35 @@
 # Don't install static libraries
 ifeq ($(MK_MODE),static)
 
+forceinstall:
+
 install:
 	
 bootcd:	
 
 else # MK_MODE
 
+ifneq ($(MK_INSTALL),no)
+
+install: forceinstall
+
+else # MK_INSTALL
+
+install:
+
+endif # MK_INSTALL
+
 ifeq ($(INSTALL_SYMBOLS),yes)
 
-install: $(SUBDIRS:%=%_install) $(MK_FULLNAME) $(MK_BASENAME).sym
-	-$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME)
-	-$(CP) $(MK_BASENAME).sym $(INSTALL_DIR)/symbols/$(MK_BASENAME).sym
+forceinstall: $(SUBDIRS:%=%_install) $(MK_FULLNAME) $(MK_BASENAME).sym
+	-$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_INSTALL_FULLNAME)
+	-$(CP) $(MK_BASENAME).sym $(INSTALL_DIR)/symbols/$(MK_INSTALL_BASENAME).sym
 	@echo $(MK_FULLNAME) was successfully installed.
 
 else # INSTALL_SYMBOLS
 
-install: $(SUBDIRS:%=%_install) $(MK_FULLNAME)
-	-$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME)
+forceinstall: $(SUBDIRS:%=%_install) $(MK_FULLNAME)
+	-$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_INSTALL_FULLNAME)
 
 endif # INSTALL_SYMBOLS
 
@@ -1000,7 +1030,7 @@
 ifneq ($(TARGET_BOOTSTRAP_NAME),)
 MK_BOOTSTRAP_NAME := $(TARGET_BOOTSTRAP_NAME)
 else # TARGET_BOOTSTRAP_NAME
-MK_BOOTSTRAP_NAME := $(MK_FULLNAME)
+MK_BOOTSTRAP_NAME := $(MK_INSTALL_FULLNAME)
 endif # TARGET_BOOTSTRAP_NAME
 
 bootcd: $(SUBDIRS:%=%_bootcd)
@@ -1076,7 +1106,7 @@
 ifeq ($(TARGET_TYPE),test)
 run: all
 	@$(CC) -nostdlib -o _runtest.exe regtests.a $(TARGET_LIBS) _stubs.o \
-	$(SDK_PATH_LIB)/rtshared.a $(SDK_PATH_LIB)/regtests.a $(SDK_PATH_LIB)/pseh.a \
+	$(SDK_PATH_LIB)/librtshared.a $(SDK_PATH_LIB)/libregtests.a $(SDK_PATH_LIB)/libpseh.a \
 	_hooks.o -lgcc -lmsvcrt -lntdll
 	@$(CP) $(REGTESTS_PATH)/regtests/regtests.dll regtests.dll
 	@_runtest.exe

reactos/tools
mkconfig.c 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- mkconfig.c	27 Sep 2004 04:32:52 -0000	1.5
+++ mkconfig.c	8 Dec 2004 21:57:41 -0000	1.5.6.1
@@ -102,11 +102,20 @@
   include_tests = 0;
   for (i = 2; i < argc; i++)
     {
-	  if (strcmp(argv[i], "REGTESTS") == 0)
+      if (strcmp(argv[i], "REGTESTS") == 0)
         {
           include_tests = 1;
         }
-      s = s + sprintf(s, "#define %s\n", argv[i]);
+      if (strcmp(argv[i], "MP") == 0 || strcmp(argv[i], "UP") == 0)
+        {
+          s = s + sprintf(s, "#if ! defined(MP) && ! defined(UP)\n");
+          s = s + sprintf(s, "#define %s\n", argv[i]);
+          s = s + sprintf(s, "#endif /* ! defined(MP) && ! defined(UP) */\n");
+        }
+      else
+        {
+          s = s + sprintf(s, "#define %s\n", argv[i]);
+        }
       strcat(config, argv[i]);
       if (i != (argc - 1))
 	{

reactos/tools/rgenstat/web
.cvsignore 1.1 -> 1.1.34.1
diff -u -r1.1 -r1.1.34.1
--- .cvsignore	10 Jul 2003 12:29:02 -0000	1.1
+++ .cvsignore	8 Dec 2004 21:57:41 -0000	1.1.34.1
@@ -1 +1 @@
-apistatus.xml^M
+apistatus.xml

reactos/tools/wmc
y_tab.c 1.3 -> 1.3.34.1
diff -u -r1.3 -r1.3.34.1
--- y_tab.c	8 Sep 2002 10:23:54 -0000	1.3
+++ y_tab.c	8 Dec 2004 21:57:42 -0000	1.3.34.1
@@ -1065,10 +1065,10 @@
 		if(find_cpxlat(yyvsp[-4].num))
 			xyyerror("Codepage translation already defined for language 0x%x", yyvsp[-4].num);
 //		if(yyvsp[-2].num && !find_codepage(yyvsp[-2].num))
-		if(yyvsp[-2].num)^M
+		if(yyvsp[-2].num)
 			xyyerror(err_nocp, yyvsp[-2].num);
 //		if(yyvsp[0].num && !find_codepage(yyvsp[0].num))
-		if(yyvsp[0].num)^M
+		if(yyvsp[0].num)
 			xyyerror(err_nocp, yyvsp[0].num);
 		add_cpxlat(yyvsp[-4].num, yyvsp[-2].num, yyvsp[0].num);
 	;

reactos/w32api/include
commctrl.h 1.8 -> 1.8.6.1
diff -u -r1.8 -r1.8.6.1
--- commctrl.h	19 Sep 2004 09:11:12 -0000	1.8
+++ commctrl.h	8 Dec 2004 21:57:42 -0000	1.8.6.1
@@ -1992,6 +1992,17 @@
 	int iString;
 } TBBUTTON,*PTBBUTTON,*LPTBBUTTON;
 typedef const TBBUTTON *LPCTBBUTTON;
+typedef struct tagNMTBRESTORE
+{
+	NMHDR hdr;
+	DWORD* pData;
+	DWORD* pCurrent;
+	UINT cbData;
+	int iItem;
+	int cButtons;
+	int cbBytesPerRecord;
+	TBBUTTON tbButton;
+} NMTBRESTORE, *LPNMTBRESTORE;
 #if _WIN32_IE >= 0x400
 typedef struct {
 	UINT cbSize;
@@ -2045,11 +2056,6 @@
 	int cchText;
 	LPTSTR pszText;
 } TBNOTIFY,*LPTBNOTIFY;
-typedef struct {
-	HKEY hkr;
-	LPCTSTR pszSubKey;
-	LPCTSTR pszValueName;
-} TBSAVEPARAMS;
 typedef struct _IMAGEINFO {
 	HBITMAP hbmImage;
 	HBITMAP hbmMask;
@@ -2246,12 +2252,12 @@
 	HKEY hkr;
 	LPCSTR pszSubKey;
 	LPCSTR pszValueName;
-} TBSAVEPARAMSA;
+} TBSAVEPARAMSA, *LPTBSAVEPARAMSA;
 typedef struct tagTBSAVEPARAMSW {
 	HKEY hkr;
 	LPCWSTR pszSubKey;
 	LPCWSTR pszValueName;
-} TBSAVEPARAMSW;
+} TBSAVEPARAMSW, *LPTBSAVEPARAMSW, *LPTBSAVEPARAMW;
 typedef struct {
 	HINSTANCE hInstOld;
 	UINT nIDOld;

reactos/w32api/include
mmsystem.h 1.1 -> 1.1.20.1
diff -u -r1.1 -r1.1.20.1
--- mmsystem.h	21 Feb 2004 09:20:34 -0000	1.1
+++ mmsystem.h	8 Dec 2004 21:57:42 -0000	1.1.20.1
@@ -1565,7 +1565,7 @@
 MMRESULT WINAPI waveOutSetVolume(HWAVEOUT,DWORD);
 MMRESULT WINAPI waveOutGetErrorTextA(MMRESULT,LPSTR,UINT);
 MMRESULT WINAPI waveOutGetErrorTextW(MMRESULT,LPWSTR,UINT);
-MMRESULT WINAPI waveOutOpen(LPHWAVEOUT,UINT,LPCWAVEFORMATEX,DWORD,DWORD,DWORD);
+MMRESULT WINAPI waveOutOpen(LPHWAVEOUT,UINT,LPCWAVEFORMATEX,DWORD_PTR,DWORD_PTR,DWORD);
 MMRESULT WINAPI waveOutClose(HWAVEOUT);
 MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT,LPWAVEHDR,UINT);
 MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT,LPWAVEHDR,UINT);
@@ -1586,7 +1586,7 @@
 MMRESULT WINAPI waveInGetDevCapsW(UINT,LPWAVEINCAPSW,UINT);
 MMRESULT WINAPI waveInGetErrorTextA(MMRESULT,LPSTR,UINT);
 MMRESULT WINAPI waveInGetErrorTextW(MMRESULT,LPWSTR,UINT);
-MMRESULT WINAPI waveInOpen(LPHWAVEIN,UINT,LPCWAVEFORMATEX,DWORD,DWORD,DWORD);
+MMRESULT WINAPI waveInOpen(LPHWAVEIN,UINT,LPCWAVEFORMATEX,DWORD_PTR,DWORD_PTR,DWORD);
 MMRESULT WINAPI waveInClose(HWAVEIN);
 MMRESULT WINAPI waveInPrepareHeader(HWAVEIN,LPWAVEHDR,UINT);
 MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN,LPWAVEHDR,UINT);
@@ -1651,7 +1651,7 @@
 MMRESULT WINAPI mixerGetDevCapsW(UINT,LPMIXERCAPSW,UINT);
 MMRESULT WINAPI mixerOpen(LPHMIXER,UINT,DWORD,DWORD,DWORD);
 MMRESULT WINAPI mixerClose(HMIXER);
-DWORD WINAPI mixerMessage(HMIXER,UINT,DWORD,DWORD);
+DWORD WINAPI mixerMessage(HMIXER,UINT,DWORD_PTR,DWORD_PTR);
 MMRESULT WINAPI mixerGetLineInfoA(HMIXEROBJ,LPMIXERLINEA,DWORD);
 MMRESULT WINAPI mixerGetLineInfoW(HMIXEROBJ,LPMIXERLINEW,DWORD);
 MMRESULT WINAPI mixerGetID(HMIXEROBJ,PUINT,DWORD);

reactos/w32api/include
oaidl.h 1.7 -> 1.7.20.1
diff -u -r1.7 -r1.7.20.1
--- oaidl.h	2 Mar 2004 10:25:59 -0000	1.7
+++ oaidl.h	8 Dec 2004 21:57:42 -0000	1.7.20.1
@@ -11,9 +11,10 @@
 #define __VARIANT_NAME_1 n1
 #define __VARIANT_NAME_2 n2
 #define __VARIANT_NAME_3 n3
-#define __VARIANT_NAME_4 n4
+#define __VARIANT_NAME_4 brecVal
 #else
 #define __tagVARIANT
+#define __tagBRECORD
 #define __VARIANT_NAME_1
 #define __VARIANT_NAME_2
 #define __VARIANT_NAME_3
@@ -238,7 +239,7 @@
 		ULONG  *pulVal;
 		INT  *pintVal;
 		UINT  *puintVal;
-		_ANONYMOUS_STRUCT struct {
+		_ANONYMOUS_STRUCT struct __tagBRECORD {
 			PVOID pvRecord;
 			struct IRecordInfo *pRecInfo;
 		} __VARIANT_NAME_4;
@@ -424,7 +425,8 @@
 	TYPEFLAG_FDUAL=64,TYPEFLAG_FNONEXTENSIBLE=128,
 	TYPEFLAG_FOLEAUTOMATION=256,TYPEFLAG_FRESTRICTED=512,
 	TYPEFLAG_FAGGREGATABLE=1024,TYPEFLAG_FREPLACEABLE=2048,
-	TYPEFLAG_FDISPATCHABLE=4096,TYPEFLAG_FREVERSEBIND=8192
+	TYPEFLAG_FDISPATCHABLE=4096,TYPEFLAG_FREVERSEBIND=8192,
+	TYPEFLAG_FPROXY=16384
 } TYPEFLAGS;
 typedef enum tagFUNCFLAGS {
 	FUNCFLAG_FRESTRICTED=1,FUNCFLAG_FSOURCE=2,FUNCFLAG_FBINDABLE=4,
@@ -502,6 +504,16 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define IEnumVARIANT_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IEnumVARIANT_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IEnumVARIANT_Release(p) (p)->lpVtbl->Release(p)
+#define IEnumVARIANT_Next(p,a,b,c) (p)->lpVtbl->Next(p,a,b,c)
+#define IEnumVARIANT_Skip(p,a) (p)->lpVtbl->Skip(p,a)
+#define IEnumVARIANT_Reset(p) (p)->lpVtbl->Reset(p)
+#define IEnumVARIANT_Clone(p,a) (p)->lpVtbl->Clone(p,a)
+#endif
+
 #define INTERFACE ITypeComp
 DECLARE_INTERFACE_(ITypeComp,IUnknown)
 {
@@ -513,6 +525,14 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define ITypeComp_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ITypeComp_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ITypeComp_Release(p) (p)->lpVtbl->Release(p)
+#define ITypeComp_Bind(p,a,b,c,d,e,f) (p)->lpVtbl->Bind(p,a,b,c,d,e,f)
+#define ITypeComp_BindType(p,a,b,c,d) (p)->lpVtbl->BindType(p,a,b,c,d)
+#endif
+
 #define INTERFACE ITypeInfo
 DECLARE_INTERFACE_(ITypeInfo,IUnknown)
 {
@@ -609,6 +629,46 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define ITypeInfo2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ITypeInfo2_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ITypeInfo2_Release(p) (p)->lpVtbl->Release(p)
+#define ITypeInfo2_GetTypeAttr(p,a) (p)->lpVtbl->GetTypeAttr(p,a)
+#define ITypeInfo2_GetTypeComp(p,a) (p)->lpVtbl->GetTypeComp(p,a)
+#define ITypeInfo2_GetFuncDesc(p,a,b) (p)->lpVtbl->GetFuncDesc(p,a,b)
+#define ITypeInfo2_GetVarDesc(p,a,b) (p)->lpVtbl->GetVarDesc(p,a,b)
+#define ITypeInfo2_GetNames(p,a,b,c,d) (p)->lpVtbl->GetNames(p,a,b,c,d)
+#define ITypeInfo2_GetRefTypeOfImplType(p,a,b) (p)->lpVtbl->GetRefTypeOfImplType(p,a,b)
+#define ITypeInfo2_GetImplTypeFlags(p,a,b) (p)->lpVtbl->GetImplTypeFlags(p,a,b)
+#define ITypeInfo2_GetIDsOfNames(p,a,b,c) (p)->lpVtbl->GetIDsOfNames(p,a,b,c)
+#define ITypeInfo2_Invoke(p,a,b,c,d,e,f,g) (p)->lpVtbl->Invoke(p,a,b,c,d,e,f,g)
+#define ITypeInfo2_GetDocumentation(p,a,b,c,d,e) (p)->lpVtbl->GetDocumentation(p,a,b,c,d,e)
+#define ITypeInfo2_GetDllEntry(p,a,b,c,d,e) (p)->lpVtbl->GetDllEntry(p,a,b,c,d,e)
+#define ITypeInfo2_GetRefTypeInfo(p,a,b) (p)->lpVtbl->GetRefTypeInfo(p,a,b)
+#define ITypeInfo2_AddressOfMember(p,a,b,c) (p)->lpVtbl->AddressOfMember(p,a,b,c)
+#define ITypeInfo2_CreateInstance(p,a,b,c) (p)->lpVtbl->CreateInstance(p,a,b,c)
+#define ITypeInfo2_GetMops(p,a,b) (p)->lpVtbl->GetMops(p,a,b)
+#define ITypeInfo2_GetContainingTypeLib(p,a,b) (p)->lpVtbl->GetContainingTypeLib(p,a,b)
+#define ITypeInfo2_ReleaseTypeAttr(p,a) (p)->lpVtbl->ReleaseTypeAttr(p,a)
+#define ITypeInfo2_ReleaseFuncDesc(p,a) (p)->lpVtbl->ReleaseFuncDesc(p,a)
+#define ITypeInfo2_ReleaseVarDesc(p,a) (p)->lpVtbl->ReleaseVarDesc(p,a)
+#define ITypeInfo2_GetTypeKind(p,a) (p)->lpVtbl->GetTypeKind(p,a)
+#define ITypeInfo2_GetTypeFlags(p,a) (p)->lpVtbl->GetTypeFlags(p,a)
+#define ITypeInfo2_GetFuncIndexOfMemId(p,a,b,c) (p)->lpVtbl->GetFuncIndexOfMemId(p,a,b,c)
+#define ITypeInfo2_GetVarIndexOfMemId(p,a,b) (p)->lpVtbl->GetVarIndexOfMemId(p,a,b)
+#define ITypeInfo2_GetCustData(p,a,b) (p)->lpVtbl->GetCustData(p,a,b)
+#define ITypeInfo2_GetFuncCustData(p,a,b,c) (p)->lpVtbl->GetFuncCustData(p,a,b,c)
+#define ITypeInfo2_GetParamCustData(p,a,b,c,d) (p)->lpVtbl->GetParamCustData(p,a,b,c,d)
+#define ITypeInfo2_GetVarCustData(p,a,b,c) (p)->lpVtbl->GetVarCustData(p,a,b,c)
+#define ITypeInfo2_GetImplTypeCustData(p,a,b,c) (p)->lpVtbl->GetImplTypeCustData(p,a,b,c)
+#define ITypeInfo2_GetDocumentation2(p,a,b,c,d,e) (p)->lpVtbl->GetDocumentation2(p,a,b,c,d,e)
+#define ITypeInfo2_GetAllCustData(p,a) (p)->lpVtbl->GetAllCustData(p,a)
+#define ITypeInfo2_GetAllFuncCustData(p,a,b) (p)->lpVtbl->GetAllFuncCustData(p,a,b)
+#define ITypeInfo2_GetAllParamCustData(p,a,b,c) (p)->lpVtbl->GetAllParamCustData(p,a,b,c)
+#define ITypeInfo2_GetAllVarCustData(p,a,b) (p)->lpVtbl->GetAllVarCustData(p,a,b)
+#define ITypeInfo2_GetAllImplTypeCustData(p,a,b) (p)->lpVtbl->GetAllImplTypeCustData(p,a,b)
+#endif
+
 #define INTERFACE ITypeLib
 DECLARE_INTERFACE_(ITypeLib,IUnknown)
 {
@@ -620,7 +680,7 @@
 	STDMETHOD(GetTypeInfoType)(THIS_ UINT,TYPEKIND*) PURE;
 	STDMETHOD(GetTypeInfoOfGuid)(THIS_ REFGUID,ITypeInfo**) PURE;
 	STDMETHOD(GetLibAttr)(THIS_ TLIBATTR**) PURE;
-	STDMETHOD(GetTypeComp)(THIS_ ITypeComp*) PURE;
+	STDMETHOD(GetTypeComp)(THIS_ LPTYPECOMP*) PURE;
 	STDMETHOD(GetDocumentation)(THIS_ INT,BSTR*,BSTR*,DWORD*,BSTR*) PURE;
 	STDMETHOD(IsName)(THIS_ LPOLESTR,ULONG,BOOL*) PURE;
 	STDMETHOD(FindName)(THIS_ LPOLESTR,ULONG,ITypeInfo**,MEMBERID*,USHORT*) PURE;
@@ -628,6 +688,22 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define ITypeLib_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ITypeLib_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ITypeLib_Release(p) (p)->lpVtbl->Release(p)
+#define ITypeLib_GetTypeInfoCount(p) (p)->lpVtbl->GetTypeInfoCount(p)
+#define ITypeLib_GetTypeInfo(p,a,b) (p)->lpVtbl->GetTypeInfo(p,a,b)
+#define ITypeLib_GetTypeInfoType(p,a,b) (p)->lpVtbl->GetTypeInfoType(p,a,b)
+#define ITypeLib_GetTypeInfoOfGuid(p,a,b) (p)->lpVtbl->GetTypeInfoOfGuid(p,a,b)
+#define ITypeLib_GetLibAttr(p,a) (p)->lpVtbl->GetLibAttr(p,a)
+#define ITypeLib_GetTypeComp(p,a) (p)->lpVtbl->GetTypeComp(p,a)
+#define ITypeLib_GetDocumentation(p,a,b,c,d,e) (p)->lpVtbl->GetDocumentation(p,a,b,c,d,e)
+#define ITypeLib_IsName(p,a,b,c) (p)->lpVtbl->IsName(p,a,b,c)
+#define ITypeLib_FindName(p,a,b,c,d,e) (p)->lpVtbl->FindName(p,a,b,c,d,e)
+#define ITypeLib_ReleaseTLibAttr(p,a) (p)->lpVtbl->ReleaseTLibAttr(p,a)
+#endif
+
 #define INTERFACE ITypeLib2
 DECLARE_INTERFACE_(ITypeLib2,ITypeLib)
 {
@@ -639,7 +715,7 @@
 	STDMETHOD(GetTypeInfoType)(THIS_ UINT,TYPEKIND*) PURE;
 	STDMETHOD(GetTypeInfoOfGuid)(THIS_ REFGUID,ITypeInfo**) PURE;
 	STDMETHOD(GetLibAttr)(THIS_ TLIBATTR**) PURE;
-	STDMETHOD(GetTypeComp)(THIS_ ITypeComp*) PURE;
+	STDMETHOD(GetTypeComp)(THIS_ LPTYPECOMP*) PURE;
 	STDMETHOD(GetDocumentation)(THIS_ INT,BSTR*,BSTR*,DWORD*,BSTR*) PURE;
 	STDMETHOD(IsName)(THIS_ LPOLESTR,ULONG,BOOL*) PURE;
 	STDMETHOD(FindName)(THIS_ LPOLESTR,ULONG,ITypeInfo**,MEMBERID*,USHORT*) PURE;
@@ -651,6 +727,274 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define ITypeLib2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ITypeLib2_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ITypeLib2_Release(p) (p)->lpVtbl->Release(p)
+#define ITypeLib2_GetTypeInfoCount(p) (p)->lpVtbl->GetTypeInfoCount(p)
+#define ITypeLib2_GetTypeInfo(p,a,b) (p)->lpVtbl->GetTypeInfo(p,a,b)
+#define ITypeLib2_GetTypeInfoType(p,a,b) (p)->lpVtbl->GetTypeInfoType(p,a,b)
+#define ITypeLib2_GetTypeInfoOfGuid(p,a,b) (p)->lpVtbl->GetTypeInfoOfGuid(p,a,b)
+#define ITypeLib2_GetLibAttr(p,a) (p)->lpVtbl->GetLibAttr(p,a)
+#define ITypeLib2_GetTypeComp(p,a) (p)->lpVtbl->GetTypeComp(p,a)
+#define ITypeLib2_GetDocumentation(p,a,b,c,d,e) (p)->lpVtbl->GetDocumentation(p,a,b,c,d,e)
+#define ITypeLib2_IsName(p,a,b,c) (p)->lpVtbl->IsName(p,a,b,c)
+#define ITypeLib2_FindName(p,a,b,c,d,e) (p)->lpVtbl->FindName(p,a,b,c,d,e)
+#define ITypeLib2_ReleaseTLibAttr(p,a) (p)->lpVtbl->ReleaseTLibAttr(p,a)
+#define ITypeLib2_GetCustData(p,a,b) (p)->lpVtbl->GetCustData(p,a,b)
+#define ITypeLib2_GetLibStatistics(p,a,b) (p)->lpVtbl->GetLibStatistics(p,a,b)
+#define ITypeLib2_GetDocumentation2(p,a,b,c,d,e) (p)->lpVtbl->GetDocumentation2(p,a,b,c,d,e)
+#define ITypeLib2_GetAllCustData(p,a) (p)->lpVtbl->GetAllCustData(p,a)
+#endif
+
+#define INTERFACE ITypeFactory
+DECLARE_INTERFACE_(ITypeFactory,IUnknown)
+{
+	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+	STDMETHOD_(ULONG,Release)(THIS) PURE;
+	STDMETHOD(GetAllCustData)(THIS_ CUSTDATA*) PURE;
+    STDMETHOD(CreateFromTypeInfo)(THIS_ LPTYPEINFO,REFIID,LPUNKNOWN*);
+};
+#undef INTERFACE
+
+#ifdef COBJMACROS
+#define ITypeFactory_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ITypeFactory_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ITypeFactory_Release(p) (p)->lpVtbl->Release(p)
+#define ITypeFactory_CreateFromTypeInfo(p,a,b,c) (p)->lpVtbl->CreateFromTypeInfo(p,a,b,c)
+#endif
+
+#define INTERFACE ICreateTypeInfo
+DECLARE_INTERFACE_(ICreateTypeInfo,IUnknown)
+{
+	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+	STDMETHOD_(ULONG,Release)(THIS) PURE;
+	STDMETHOD(SetGuid)(THIS_ REFGUID) PURE;
+	STDMETHOD(SetTypeFlags)(THIS_ UINT) PURE;
+	STDMETHOD(SetDocString)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpContext)(THIS_ DWORD) PURE;
+	STDMETHOD(SetVersion)(THIS_ WORD,WORD) PURE;
+	STDMETHOD(AddRefTypeInfo)(THIS_ ITypeInfo*,HREFTYPE*) PURE;
+	STDMETHOD(AddFuncDesc)(THIS_ UINT,FUNCDESC*) PURE;
+	STDMETHOD(AddImplType)(THIS_ UINT,HREFTYPE) PURE;
+	STDMETHOD(SetImplTypeFlags)(THIS_ UINT,INT) PURE;
+	STDMETHOD(SetAlignment)(THIS_ WORD) PURE;
+	STDMETHOD(SetSchema)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(AddVarDesc)(THIS_ UINT,VARDESC*) PURE;
+	STDMETHOD(SetFuncAndParamNames)(THIS_ UINT,LPOLESTR*,UINT) PURE;
+	STDMETHOD(SetVarName)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetTypeDescAlias)(THIS_ TYPEDESC*) PURE;
+	STDMETHOD(DefineFuncAsDllEntry)(THIS_ UINT,LPOLESTR,LPOLESTR) PURE;
+	STDMETHOD(SetFuncDocString)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetVarDocString)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetFuncHelpContext)(THIS_ UINT,DWORD) PURE;
+	STDMETHOD(SetVarHelpContext)(THIS_ UINT,DWORD) PURE;
+	STDMETHOD(SetMops)(THIS_ UINT,BSTR) PURE;
+	STDMETHOD(SetTypeIdldesc)(THIS_ IDLDESC*) PURE;
+	STDMETHOD(LayOut)(THIS) PURE;
+};
+#undef INTERFACE
+
+#ifdef COBJMACROS
+#define ICreateTypeInfo_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ICreateTypeInfo_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ICreateTypeInfo_Release(p) (p)->lpVtbl->Release(p)
+#define ICreateTypeInfo_SetGuid(p,a) (p)->lpVtbl->SetGuid(p,a)
+#define ICreateTypeInfo_SetTypeFlags(p,a) (p)->lpVtbl->SetTypeFlags(p,a)
+#define ICreateTypeInfo_SetDocString(p,a) (p)->lpVtbl->SetDocString(p,a)
+#define ICreateTypeInfo_SetHelpContext(p,a) (p)->lpVtbl->SetHelpContext(p,a)
+#define ICreateTypeInfo_SetVersion(p,a,b) (p)->lpVtbl->SetVersion(p,a,b)
+#define ICreateTypeInfo_AddRefTypeInfo(p,a,b) (p)->lpVtbl->AddRefTypeInfo(p,a,b)
+#define ICreateTypeInfo_AddFuncDesc(p,a,b) (p)->lpVtbl->AddFuncDesc(p,a,b)
+#define ICreateTypeInfo_AddImplType(p,a,b) (p)->lpVtbl->AddImplType(p,a,b)
+#define ICreateTypeInfo_SetImplTypeFlags(p,a,b) (p)->lpVtbl->SetImplTypeFlags(p,a,b)
+#define ICreateTypeInfo_SetAlignment(p,a) (p)->lpVtbl->SetAlignment(p,a)
+#define ICreateTypeInfo_SetSchema(p,a) (p)->lpVtbl->SetSchema(p,a)
+#define ICreateTypeInfo_AddVarDesc(p,a,b) (p)->lpVtbl->AddVarDesc(p,a,b)
+#define ICreateTypeInfo_SetFuncAndParamNames(p,a,b,c) (p)->lpVtbl->SetFuncAndParamNames(p,a,b,c)
+#define ICreateTypeInfo_SetVarName(p,a,b) (p)->lpVtbl->SetVarName(p,a,b)
+#define ICreateTypeInfo_SetTypeDescAlias(p,a) (p)->lpVtbl->SetTypeDescAlias(p,a)
+#define ICreateTypeInfo_DefineFuncAsDllEntry(p,a,b,c) (p)->lpVtbl->DefineFuncAsDllEntry(p,a,b,c)
+#define ICreateTypeInfo_SetFuncDocString(p,a,b) (p)->lpVtbl->SetFuncDocString(p,a,b)
+#define ICreateTypeInfo_SetVarDocString(p,a,b) (p)->lpVtbl->SetVarDocString(p,a,b)
+#define ICreateTypeInfo_SetFuncHelpContext(p,a,b) (p)->lpVtbl->SetFuncHelpContext(p,a,b)
+#define ICreateTypeInfo_SetVarHelpContext(p,a,b) (p)->lpVtbl->SetVarHelpContext(p,a,b)
+#define ICreateTypeInfo_SetMops(p,a,b) (p)->lpVtbl->SetMops(p,a,b)
+#define ICreateTypeInfo_SetTypeIdldesc(p,a) (p)->lpVtbl->SetTypeIdldesc(p,a)
+#define ICreateTypeInfo_LayOut(p) (p)->lpVtbl->LayOut(p)
+#endif
+
+#define INTERFACE ICreateTypeInfo2
+DECLARE_INTERFACE_(ICreateTypeInfo2,IUnknown)
+{
+	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+	STDMETHOD_(ULONG,Release)(THIS) PURE;
+	STDMETHOD(SetGuid)(THIS_ REFGUID) PURE;
+	STDMETHOD(SetTypeFlags)(THIS_ UINT) PURE;
+	STDMETHOD(SetDocString)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpContext)(THIS_ DWORD) PURE;
+	STDMETHOD(SetVersion)(THIS_ WORD,WORD) PURE;
+	STDMETHOD(AddRefTypeInfo)(THIS_ ITypeInfo*,HREFTYPE*) PURE;
+	STDMETHOD(AddFuncDesc)(THIS_ UINT,FUNCDESC*) PURE;
+	STDMETHOD(AddImplType)(THIS_ UINT,HREFTYPE) PURE;
+	STDMETHOD(SetImplTypeFlags)(THIS_ UINT,INT) PURE;
+	STDMETHOD(SetAlignment)(THIS_ WORD) PURE;
+	STDMETHOD(SetSchema)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(AddVarDesc)(THIS_ UINT,VARDESC*) PURE;
+	STDMETHOD(SetFuncAndParamNames)(THIS_ UINT,LPOLESTR*,UINT) PURE;
+	STDMETHOD(SetVarName)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetTypeDescAlias)(THIS_ TYPEDESC*) PURE;
+	STDMETHOD(DefineFuncAsDllEntry)(THIS_ UINT,LPOLESTR,LPOLESTR) PURE;
+	STDMETHOD(SetFuncDocString)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetVarDocString)(THIS_ UINT,LPOLESTR) PURE;
+	STDMETHOD(SetFuncHelpContext)(THIS_ UINT,DWORD) PURE;
+	STDMETHOD(SetVarHelpContext)(THIS_ UINT,DWORD) PURE;
+	STDMETHOD(SetMops)(THIS_ UINT,BSTR) PURE;
+	STDMETHOD(SetTypeIdldesc)(THIS_ IDLDESC*) PURE;
+	STDMETHOD(LayOut)(THIS) PURE;
+	STDMETHOD(DeleteFuncDesc)(THIS_ UINT) PURE;
+	STDMETHOD(DeleteFuncDescByMemId)(THIS_ MEMBERID, INVOKEKIND) PURE;
+	STDMETHOD(DeleteVarDesc)(THIS_ UINT) PURE;
+	STDMETHOD(DeleteVarDescByMemId)(THIS_ MEMBERID) PURE;        
+	STDMETHOD(DeleteImplType)(THIS_ UINT) PURE;        
+	STDMETHOD(SetCustData)(THIS_ REFGUID, VARIANT*) PURE;        
+	STDMETHOD(SetFuncCustData)(THIS_ UINT, REFGUID, VARIANT*) PURE;        
+	STDMETHOD(SetParamCustData)(THIS_ UINT, UINT, REFGUID, VARIANT*) PURE;        
+	STDMETHOD(SetVarCustData)(THIS_ UINT, REFGUID, VARIANT*) PURE;        
+	STDMETHOD(SetImplTypeCustData)(THIS_ UINT, REFGUID, VARIANT*) PURE;        
+	STDMETHOD(SetHelpStringContext)(THIS_ ULONG) PURE;        
+	STDMETHOD(SetFuncHelpStringContext)(THIS_ UINT, ULONG) PURE;        
+	STDMETHOD(SetVarHelpStringContext)(THIS_ UINT, ULONG) PURE;        
+	STDMETHOD(Invalidate)(THIS) PURE;       
+	STDMETHOD(SetName)(THIS_ LPOLESTR) PURE;
+};
+#undef INTERFACE
+
+#ifdef COBJMACROS
+#define ICreateTypeInfo2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ICreateTypeInfo2_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ICreateTypeInfo2_Release(p) (p)->lpVtbl->Release(p)
+#define ICreateTypeInfo2_SetGuid(p,a) (p)->lpVtbl->SetGuid(p,a)
+#define ICreateTypeInfo2_SetTypeFlags(p,a) (p)->lpVtbl->SetTypeFlags(p,a)
+#define ICreateTypeInfo2_SetDocString(p,a) (p)->lpVtbl->SetDocString(p,a)
+#define ICreateTypeInfo2_SetHelpContext(p,a) (p)->lpVtbl->SetHelpContext(p,a)
+#define ICreateTypeInfo2_SetVersion(p,a,b) (p)->lpVtbl->SetVersion(p,a,b)
+#define ICreateTypeInfo2_AddRefTypeInfo(p,a,b) (p)->lpVtbl->AddRefTypeInfo(p,a,b)
+#define ICreateTypeInfo2_AddFuncDesc(p,a,b) (p)->lpVtbl->AddFuncDesc(p,a,b)
+#define ICreateTypeInfo2_AddImplType(p,a,b) (p)->lpVtbl->AddImplType(p,a,b)
+#define ICreateTypeInfo2_SetImplTypeFlags(p,a,b) (p)->lpVtbl->SetImplTypeFlags(p,a,b)
+#define ICreateTypeInfo2_SetAlignment(p,a) (p)->lpVtbl->SetAlignment(p,a)
+#define ICreateTypeInfo2_SetSchema(p,a) (p)->lpVtbl->SetSchema(p,a)
+#define ICreateTypeInfo2_AddVarDesc(p,a,b) (p)->lpVtbl->AddVarDesc(p,a,b)
+#define ICreateTypeInfo2_SetFuncAndParamNames(p,a,b,c) (p)->lpVtbl->SetFuncAndParamNames(p,a,b,c)
+#define ICreateTypeInfo2_SetVarName(p,a,b) (p)->lpVtbl->SetVarName(p,a,b)
+#define ICreateTypeInfo2_SetTypeDescAlias(p,a) (p)->lpVtbl->SetTypeDescAlias(p,a)
+#define ICreateTypeInfo2_DefineFuncAsDllEntry(p,a,b,c) (p)->lpVtbl->DefineFuncAsDllEntry(p,a,b,c)
+#define ICreateTypeInfo2_SetFuncDocString(p,a,b) (p)->lpVtbl->SetFuncDocString(p,a,b)
+#define ICreateTypeInfo2_SetVarDocString(p,a,b) (p)->lpVtbl->SetVarDocString(p,a,b)
+#define ICreateTypeInfo2_SetFuncHelpContext(p,a,b) (p)->lpVtbl->SetFuncHelpContext(p,a,b)
+#define ICreateTypeInfo2_SetVarHelpContext(p,a,b) (p)->lpVtbl->SetVarHelpContext(p,a,b)
+#define ICreateTypeInfo2_SetMops(p,a,b) (p)->lpVtbl->SetMops(p,a,b)
+#define ICreateTypeInfo2_SetTypeIdldesc(p,a) (p)->lpVtbl->SetTypeIdldesc(p,a)
+#define ICreateTypeInfo2_LayOut(p) (p)->lpVtbl->LayOut(p)
+#define ICreateTypeInfo2_DeleteFuncDesc(p,a) (p)->lpVtbl->DeleteFuncDesc(p,a)
+#define ICreateTypeInfo2_DeleteFuncDescByMemId(p,a,b) (p)->lpVtbl->DeleteFuncDescByMemId(p,a,b)
+#define ICreateTypeInfo2_DeleteVarDesc(p,a) (p)->lpVtbl->DeleteVarDesc(p,a)
+#define ICreateTypeInfo2_DeleteVarDescByMemId(p,a) (p)->lpVtbl->DeleteVarDescByMemId(p,a)
+#define ICreateTypeInfo2_DeleteImplType(p,a) (p)->lpVtbl->DeleteImplType(p,a)
+#define ICreateTypeInfo2_SetCustData(p,a,b) (p)->lpVtbl->SetCustData(p,a,b)
+#define ICreateTypeInfo2_SetFuncCustData(p,a,b,c) (p)->lpVtbl->SetFuncCustData(p,a,b,c)
+#define ICreateTypeInfo2_SetParamCustData(p,a,b,c,d) (p)->lpVtbl->SetParamCustData(p,a,b,c,d)
+#define ICreateTypeInfo2_SetVarCustData(p,a,b,c) (p)->lpVtbl->SetVarCustData(p,a,b,c)
+#define ICreateTypeInfo2_SetImplTypeCustData(p,a,b,c) (p)->lpVtbl->SetImplTypeCustData(p,a,b,c)
+#define ICreateTypeInfo2_SetHelpStringContext(p,a) (p)->lpVtbl->SetHelpStringContext(p,a)
+#define ICreateTypeInfo2_SetFuncHelpStringContext(p,a,b) (p)->lpVtbl->SetFuncHelpStringContext(p,a,b)
+#define ICreateTypeInfo2_SetVarHelpStringContext(p,a,b) (p)->lpVtbl->SetVarHelpStringContext(p,a,b)
+#define ICreateTypeInfo2_Invalidate(p) (p)->lpVtbl->Invalidate(p)
+#define ICreateTypeInfo2_SetName(p,a) (p)->lpVtbl->SetName(p,a)
+#endif
+
+#define INTERFACE ICreateTypeLib
+DECLARE_INTERFACE_(ICreateTypeLib,IUnknown)
+{
+	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+	STDMETHOD_(ULONG,Release)(THIS) PURE;
+	STDMETHOD(CreateTypeInfo)(THIS_ LPOLESTR,TYPEKIND,ICreateTypeInfo**) PURE;
+	STDMETHOD(SetName)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetVersion)(THIS_ WORD,WORD) PURE;
+	STDMETHOD(SetGuid)(THIS_ REFGUID) PURE;
+	STDMETHOD(SetDocString)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpFileName)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpContext)(THIS_ DWORD) PURE;
+	STDMETHOD(SetLcid)(THIS_ LCID) PURE;
+	STDMETHOD(SetLibFlags)(THIS_ UINT) PURE;
+	STDMETHOD(SaveAllChanges)(THIS) PURE;
+};
+#undef INTERFACE
+
+#ifdef COBJMACROS
+#define ICreateTypeLib_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ICreateTypeLib_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ICreateTypeLib_Release(p) (p)->lpVtbl->Release(p)
+#define ICreateTypeLib_CreateTypeInfo(p,a,b,c) (p)->lpVtbl->CreateTypeInfo(p,a,b,c)
+#define ICreateTypeLib_SetName(p,a) (p)->lpVtbl->SetName(p,a)
+#define ICreateTypeLib_SetVersion(p,a,b) (p)->lpVtbl->SetVersion(p,a,b)
+#define ICreateTypeLib_SetGuid(p,a) (p)->lpVtbl->SetGuid(p,a)
+#define ICreateTypeLib_SetDocString(p,a) (p)->lpVtbl->SetDocString(p,a)
+#define ICreateTypeLib_SetHelpFileName(p,a) (p)->lpVtbl->SetHelpFileName(p,a)
+#define ICreateTypeLib_SetHelpContext(p,a) (p)->lpVtbl->SetHelpContext(p,a)
+#define ICreateTypeLib_SetLcid(p,a) (p)->lpVtbl->SetLcid(p,a)
+#define ICreateTypeLib_SetLibFlags(p,a) (p)->lpVtbl->SetLibFlags(p,a)
+#define ICreateTypeLib_SaveAllChanges(p) (p)->lpVtbl->SaveAllChanges(p)
+#endif
+
+#define INTERFACE ICreateTypeLib2
+DECLARE_INTERFACE_(ICreateTypeLib2,IUnknown)
+{
+	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+	STDMETHOD_(ULONG,Release)(THIS) PURE;
+	STDMETHOD(CreateTypeInfo)(THIS_ LPOLESTR,TYPEKIND,ICreateTypeInfo**) PURE;
+	STDMETHOD(SetName)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetVersion)(THIS_ WORD,WORD) PURE;
+	STDMETHOD(SetGuid)(THIS_ REFGUID) PURE;
+	STDMETHOD(SetDocString)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpFileName)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetHelpContext)(THIS_ DWORD) PURE;
+	STDMETHOD(SetLcid)(THIS_ LCID) PURE;
+	STDMETHOD(SetLibFlags)(THIS_ UINT) PURE;
+	STDMETHOD(SaveAllChanges)(THIS) PURE;
+	STDMETHOD(DeleteTypeInfo)(THIS_ LPOLESTR) PURE;
+	STDMETHOD(SetCustData)(THIS_ REFGUID, VARIANT*) PURE;
+	STDMETHOD(SetHelpStringContext)(THIS_ ULONG) PURE;        
+	STDMETHOD(SetHelpStringDll)(THIS_ LPOLESTR) PURE;
+};
+#undef INTERFACE
+
+#ifdef COBJMACROS
+#define ICreateTypeLib2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ICreateTypeLib2_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ICreateTypeLib2_Release(p) (p)->lpVtbl->Release(p)
+#define ICreateTypeLib2_CreateTypeInfo(p,a,b,c) (p)->lpVtbl->CreateTypeInfo(p,a,b,c)
+#define ICreateTypeLib2_SetName(p,a) (p)->lpVtbl->SetName(p,a)
+#define ICreateTypeLib2_SetVersion(p,a,b) (p)->lpVtbl->SetVersion(p,a,b)
+#define ICreateTypeLib2_SetGuid(p,a) (p)->lpVtbl->SetGuid(p,a)
+#define ICreateTypeLib2_SetDocString(p,a) (p)->lpVtbl->SetDocString(p,a)
+#define ICreateTypeLib2_SetHelpFileName(p,a) (p)->lpVtbl->SetHelpFileName(p,a)
+#define ICreateTypeLib2_SetHelpContext(p,a) (p)->lpVtbl->SetHelpContext(p,a)
+#define ICreateTypeLib2_SetLcid(p,a) (p)->lpVtbl->SetLcid(p,a)
+#define ICreateTypeLib2_SetLibFlags(p,a) (p)->lpVtbl->SetLibFlags(p,a)
+#define ICreateTypeLib2_SaveAllChanges(p) (p)->lpVtbl->SaveAllChanges(p)
+#define ICreateTypeLib2_DeleteTypeInfo(p,a) (p)->lpVtbl->DeleteTypeInfo(p,a)
+#define ICreateTypeLib2_SetCustData(p,a,b) (p)->lpVtbl->SetCustData(p,a,b)
+#define ICreateTypeLib2_SetHelpStringContext(p,a) (p)->lpVtbl->SetHelpStringContext(p,a)
+#define ICreateTypeLib2_SetHelpStringDll(p,a) (p)->lpVtbl->SetHelpStringDll(p,a)
+#endif
+
 EXTERN_C const IID IID_IErrorInfo;
 #define INTERFACE IErrorInfo
 DECLARE_INTERFACE_(IErrorInfo, IUnknown)
@@ -765,6 +1109,75 @@
 };
 #undef INTERFACE
 
+unsigned long __RPC_USER BSTR_UserSize(unsigned long*,unsigned long,LPBSTR);
+unsigned char* __RPC_USER BSTR_UserMarshal(unsigned long*,unsigned char*,LPBSTR);
+unsigned char* __RPC_USER BSTR_UserUnmarshal(unsigned long*,unsigned char*,LPBSTR);
+void __RPC_USER BSTR_UserFree(unsigned long*,LPBSTR);
+unsigned long __RPC_USER CLEANLOCALSTORAGE_UserSize(unsigned long*,unsigned long,CLEANLOCALSTORAGE*);
+unsigned char* __RPC_USER CLEANLOCALSTORAGE_UserMarshal(unsigned long*,unsigned char*,CLEANLOCALSTORAGE*);
+unsigned char* __RPC_USER CLEANLOCALSTORAGE_UserUnmarshal(unsigned long*,unsigned char*,CLEANLOCALSTORAGE*);
+void __RPC_USER CLEANLOCALSTORAGE_UserFree(unsigned long*,CLEANLOCALSTORAGE*);
+unsigned long __RPC_USER VARIANT_UserSize(unsigned long*,unsigned long,LPVARIANT);
+unsigned char* __RPC_USER VARIANT_UserMarshal(unsigned long*,unsigned char*,LPVARIANT);
+unsigned char* __RPC_USER VARIANT_UserUnmarshal(unsigned long*,unsigned char*,LPVARIANT);
+void __RPC_USER VARIANT_UserFree(unsigned long*,LPVARIANT);
+HRESULT STDMETHODCALLTYPE IDispatch_Invoke_Proxy(LPDISPATCH,DISPID,REFIID,LCID,WORD,DISPPARAMS*,LPVARIANT,LPEXCEPINFO,LPUINT);
+HRESULT STDMETHODCALLTYPE IDispatch_Invoke_Stub(LPDISPATCH,DISPID,REFIID,LCID,DWORD,DISPPARAMS*,LPVARIANT,LPEXCEPINFO,LPUINT,UINT,LPUINT,LPVARIANTARG);
+HRESULT STDMETHODCALLTYPE IDispatch_RemoteInvoke_Proxy(LPDISPATCH,DISPID,REFIID,LCID,DWORD,DISPPARAMS*,LPVARIANT,LPEXCEPINFO,LPUINT,UINT,LPUINT,LPVARIANTARG);
+HRESULT STDMETHODCALLTYPE IEnumVARIANT_Next_Proxy(LPENUMVARIANT,ULONG,LPVARIANT,PULONG);
+HRESULT STDMETHODCALLTYPE IEnumVARIANT_Next_Stub(LPENUMVARIANT,ULONG,LPVARIANT,PULONG);
+HRESULT STDMETHODCALLTYPE IEnumVARIANT_RemoteNext_Proxy(LPENUMVARIANT,ULONG,LPVARIANT,PULONG);
+HRESULT STDMETHODCALLTYPE ITypeComp_Bind_Proxy(LPTYPECOMP,LPOLESTR,ULONG,WORD,LPTYPEINFO*,DESCKIND*,BINDPTR*);
+HRESULT STDMETHODCALLTYPE ITypeComp_Bind_Stub(LPTYPECOMP,LPOLESTR,ULONG,WORD,LPTYPEINFO*,DESCKIND*,LPFUNCDESC*,LPVARDESC*,LPTYPECOMP*,CLEANLOCALSTORAGE*);
+HRESULT STDMETHODCALLTYPE ITypeComp_BindType_Proxy(LPTYPECOMP,LPOLESTR,ULONG,LPTYPEINFO*,LPTYPECOMP*);
+HRESULT STDMETHODCALLTYPE ITypeComp_BindType_Stub(LPTYPECOMP,LPOLESTR,ULONG,LPTYPEINFO*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetTypeAttr_Proxy(LPTYPEINFO,LPTYPEATTR*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetTypeAttr_Stub(LPTYPEINFO,LPTYPEATTR*,CLEANLOCALSTORAGE*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetFuncDesc_Proxy(LPTYPEINFO,UINT,FUNCDESC**);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetFuncDesc_Stub(LPTYPEINFO,UINT,LPFUNCDESC*,CLEANLOCALSTORAGE*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetVarDesc_Proxy(LPTYPEINFO,UINT,LPVARDESC*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetVarDesc_Stub(LPTYPEINFO,UINT,LPVARDESC*,CLEANLOCALSTORAGE*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetNames_Proxy(LPTYPEINFO,MEMBERID,LPBSTR,UINT,LPUINT);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetNames_Stub(LPTYPEINFO,MEMBERID,LPBSTR,UINT,LPUINT);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetIDsOfNames_Proxy(LPTYPEINFO,LPOLESTR*,UINT,MEMBERID*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetIDsOfNames_Stub(LPTYPEINFO);
+HRESULT STDMETHODCALLTYPE ITypeInfo_Invoke_Proxy(LPTYPEINFO,PVOID,MEMBERID,WORD,DISPPARAMS*,LPVARIANT,LPEXCEPINFO,LPUINT);
+HRESULT STDMETHODCALLTYPE ITypeInfo_Invoke_Stub(LPTYPEINFO);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetDocumentation_Proxy(LPTYPEINFO,MEMBERID,LPBSTR,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetDocumentation_Stub(LPTYPEINFO,MEMBERID,DWORD,LPBSTR,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetDllEntry_Proxy(LPTYPEINFO,MEMBERID,INVOKEKIND,LPBSTR,LPBSTR,LPWORD);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetDllEntry_Stub(LPTYPEINFO,MEMBERID,INVOKEKIND,DWORD,LPBSTR,LPBSTR,LPWORD);
+HRESULT STDMETHODCALLTYPE ITypeInfo_AddressOfMember_Proxy(LPTYPEINFO,MEMBERID,INVOKEKIND,PVOID*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_AddressOfMember_Stub(LPTYPEINFO);
+HRESULT STDMETHODCALLTYPE ITypeInfo_CreateInstance_Proxy(LPTYPEINFO,LPUNKNOWN,REFIID,PVOID*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_CreateInstance_Stub(LPTYPEINFO,REFIID,LPUNKNOWN*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetContainingTypeLib_Proxy(LPTYPEINFO,LPTYPELIB*,PUINT);
+HRESULT STDMETHODCALLTYPE ITypeInfo_GetContainingTypeLib_Stub(LPTYPEINFO,LPTYPELIB*,PUINT);
+void STDMETHODCALLTYPE ITypeInfo_ReleaseTypeAttr_Proxy(LPTYPEINFO,LPTYPEATTR);
+HRESULT STDMETHODCALLTYPE ITypeInfo_ReleaseTypeAttr_Stub(LPTYPEINFO);
+void STDMETHODCALLTYPE ITypeInfo_ReleaseFuncDesc_Proxy(LPTYPEINFO,LPFUNCDESC);
+HRESULT STDMETHODCALLTYPE ITypeInfo_ReleaseFuncDesc_Stub(LPTYPEINFO);
+void STDMETHODCALLTYPE ITypeInfo_ReleaseVarDesc_Proxy(LPTYPEINFO,VARDESC*);
+HRESULT STDMETHODCALLTYPE ITypeInfo_ReleaseVarDesc_Stub(LPTYPEINFO);
+HRESULT STDMETHODCALLTYPE ITypeInfo2_GetDocumentation2_Proxy(LPTYPEINFO2,MEMBERID,LCID,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeInfo2_GetDocumentation2_Stub(LPTYPEINFO2,MEMBERID,LCID,DWORD,LPBSTR,LPDWORD,LPBSTR);
+UINT STDMETHODCALLTYPE ITypeLib_GetTypeInfoCount_Proxy(LPTYPELIB);
+HRESULT STDMETHODCALLTYPE ITypeLib_GetTypeInfoCount_Stub(LPTYPELIB,PUINT);
+HRESULT STDMETHODCALLTYPE ITypeLib_GetLibAttr_Proxy(LPTYPELIB,LPTLIBATTR*);
+HRESULT STDMETHODCALLTYPE ITypeLib_GetLibAttr_Stub(LPTYPELIB,LPTLIBATTR*,CLEANLOCALSTORAGE*);
+HRESULT STDMETHODCALLTYPE ITypeLib_GetDocumentation_Proxy(LPTYPELIB,INT,LPBSTR,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeLib_GetDocumentation_Stub(LPTYPELIB,INT,DWORD,LPBSTR,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeLib_IsName_Proxy(LPTYPELIB,LPOLESTR,ULONG,LPBOOL);
+HRESULT STDMETHODCALLTYPE ITypeLib_IsName_Stub(LPTYPELIB,LPOLESTR,ULONG,LPBOOL,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeLib_FindName_Proxy(LPTYPELIB,LPOLESTR,ULONG,LPTYPEINFO*,MEMBERID*,PUSHORT);
+HRESULT STDMETHODCALLTYPE ITypeLib_FindName_Stub(LPTYPELIB,LPOLESTR,ULONG,LPTYPEINFO*,MEMBERID*,PUSHORT,LPBSTR);
+void STDMETHODCALLTYPE ITypeLib_ReleaseTLibAttr_Proxy(LPTYPELIB,LPTLIBATTR);
+HRESULT STDMETHODCALLTYPE ITypeLib_ReleaseTLibAttr_Stub(LPTYPELIB);
+HRESULT STDMETHODCALLTYPE ITypeLib2_GetLibStatistics_Proxy(LPTYPELIB2,PULONG,PULONG);
+HRESULT STDMETHODCALLTYPE ITypeLib2_GetLibStatistics_Stub(LPTYPELIB2,PULONG,PULONG);
+HRESULT STDMETHODCALLTYPE ITypeLib2_GetDocumentation2_Proxy(LPTYPELIB2,INT,LCID,LPBSTR,LPDWORD,LPBSTR);
+HRESULT STDMETHODCALLTYPE ITypeLib2_GetDocumentation2_Stub(LPTYPELIB2,INT,LCID,DWORD,LPBSTR,LPDWORD,LPBSTR);
+
 #ifdef __cplusplus
 }
 #endif

reactos/w32api/include
objidl.h 1.3 -> 1.3.18.1
diff -u -r1.3 -r1.3.18.1
--- objidl.h	24 Apr 2004 21:35:24 -0000	1.3
+++ objidl.h	8 Dec 2004 21:57:42 -0000	1.3.18.1
@@ -796,11 +796,11 @@
 	STDMETHOD_(ULONG,Release)(THIS) PURE;
 	STDMETHOD(Connect)(THIS_ LPUNKNOWN) PURE;
 	STDMETHOD_(void,Disconnect)(THIS) PURE;
-	STDMETHOD(Invoke)(THIS_ RPCOLEMESSAGE*,LPRPCSTUBBUFFER) PURE;
+	STDMETHOD(Invoke)(THIS_ RPCOLEMESSAGE*,LPRPCCHANNELBUFFER) PURE;
 	STDMETHOD_(LPRPCSTUBBUFFER,IsIIDSupported)(THIS_ REFIID) PURE;
 	STDMETHOD_(ULONG,CountRefs)(THIS) PURE;
 	STDMETHOD(DebugServerQueryInterface)(THIS_ PVOID*) PURE;
-	STDMETHOD(DebugServerRelease)(THIS_ PVOID) PURE;
+	STDMETHOD_(VOID,DebugServerRelease)(THIS_ PVOID) PURE;
 };
 #undef INTERFACE
 

reactos/w32api/include
ocidl.h 1.3 -> 1.3.20.1
diff -u -r1.3 -r1.3.20.1
--- ocidl.h	1 Mar 2004 22:57:20 -0000	1.3
+++ ocidl.h	8 Dec 2004 21:57:42 -0000	1.3.20.1
@@ -217,6 +217,14 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define IPropertyBag_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IPropertyBag_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IPropertyBag_Release(p) (p)->lpVtbl->Release(p)
+#define IPropertyBag_Read(p,a,b,c) (p)->lpVtbl->Read(p,a,b,c)
+#define IPropertyBag_Write(p,a,b) (p)->lpVtbl->Write(p,a,b)
+#endif
+
 EXTERN_C const IID IID_IPropertyBag2;
 #define INTERFACE IPropertyBag2
 DECLARE_INTERFACE_(IPropertyBag2,IUnknown)
@@ -232,6 +240,17 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define IPropertyBag2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IPropertyBag2_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IPropertyBag2_Release(p) (p)->lpVtbl->Release(p)
+#define IPropertyBag2_Read(p,a,b,c) (p)->lpVtbl->Read(p,a,b,c)
+#define IPropertyBag2_Write(p,a,b) (p)->lpVtbl->Write(p,a,b)
+#define IPropertyBag2_CountProperties(p,a) (p)->lpVtbl->CountProperties(p,a)
+#define IPropertyBag2_GetPropertyInfo(p,a,b,c,d) (p)->lpVtbl->GetPropertyInfo(p,a,b,c,d)
+#define IPropertyBag2_LoadObject(p,a,b,c,d) (p)->lpVtbl->LoadObject(p,a,b,c,d)
+#endif
+
 EXTERN_C const IID IID_IPersistPropertyBag;
 #define INTERFACE IPersistPropertyBag
 DECLARE_INTERFACE_(IPersistPropertyBag,IPersist)
@@ -572,6 +591,36 @@
 };
 #undef INTERFACE
 
+#ifdef COBJMACROS
+#define IFont_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IFont_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IFont_Release(p) (p)->lpVtbl->Release(p)
+#define IFont_get_Name(p,a) (p)->lpVtbl->get_Name(p,a)
+#define IFont_put_Name(p,a) (p)->lpVtbl->put_Name(p,a)
+#define IFont_get_Size(p,a) (p)->lpVtbl->get_Size(p,a)
+#define IFont_put_Size(p,a) (p)->lpVtbl->put_Size(p,a)
+#define IFont_get_Bold(p,a) (p)->lpVtbl->get_Bold(p,a)
+#define IFont_put_Bold(p,a) (p)->lpVtbl->put_Bold(p,a)
+#define IFont_get_Italic(p,a) (p)->lpVtbl->get_Italic(p,a)
+#define IFont_put_Italic(p,a) (p)->lpVtbl->put_Italic(p,a)
+#define IFont_get_Underline(p,a) (p)->lpVtbl->get_Underline(p,a)
+#define IFont_put_Underline(p,a) (p)->lpVtbl->put_Underline(p,a)
+#define IFont_get_Strikethrough(p,a) (p)->lpVtbl->get_Strikethrough(p,a)
+#define IFont_put_Strikethrough(p,a) (p)->lpVtbl->put_Strikethrough(p,a)
+#define IFont_get_Weight(p,a) (p)->lpVtbl->get_Weight(p,a)
+#define IFont_put_Weight(p,a) (p)->lpVtbl->put_Weight(p,a)
+#define IFont_get_Charset(p,a) (p)->lpVtbl->get_Charset(p,a)
+#define IFont_put_Charset(p,a) (p)->lpVtbl->put_Charset(p,a)
+#define IFont_get_hFont(p,a) (p)->lpVtbl->get_hFont(p,a)
+#define IFont_Clone(p,a) (p)->lpVtbl->Clone(p,a)
+#define IFont_IsEqual(p,a) (p)->lpVtbl->IsEqual(p,a)
+#define IFont_SetRatio(p,a,b) (p)->lpVtbl->SetRatio(p,a,b)
+#define IFont_QueryTextMetrics(p,a) (p)->lpVtbl->QueryTextMetrics(p,a)
+#define IFont_AddRefHfont(p,a) (p)->lpVtbl->AddRefHfont(p,a)
+#define IFont_ReleaseHfont(p,a) (p)->lpVtbl->ReleaseHfont(p,a)
+#define IFont_SetHdc(p,a) (p)->lpVtbl->SetHdc(p,a)
+#endif
+
 EXTERN_C const IID IID_IFontDisp;
 #define INTERFACE IFontDisp
 DECLARE_INTERFACE_(IFontDisp,IDispatch)

reactos/w32api/include
oleauto.h 1.11 -> 1.11.20.1
diff -u -r1.11 -r1.11.20.1
--- oleauto.h	2 Mar 2004 10:25:59 -0000	1.11
+++ oleauto.h	8 Dec 2004 21:57:42 -0000	1.11.20.1
@@ -37,9 +37,13 @@
 #if __STDC__ || defined(NONAMELESSUNION)
 #define V_UNION(X,Y) ((X)->__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.Y)
 #define V_VT(X) ((X)->__VARIANT_NAME_1.__VARIANT_NAME_2.vt)
+#define V_RECORDINFO(X) ((X)->__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo)
+#define V_RECORD(X) ((X)->__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pvRecord)
 #else
 #define V_UNION(X,Y) ((X)->Y)
 #define V_VT(X) ((X)->vt)
+#define V_RECORDINFO(X) ((X)->pRecInfo)
+#define V_RECORD(X) ((X)->pvRecord)
 #endif
 #define V_BOOL(X) V_UNION(X,boolVal)
 #define V_ISBYREF(X) (V_VT(X)&VT_BYREF)
@@ -154,6 +158,8 @@
 
 #include <oaidl.h>
 
+EXTERN_C const IID IID_StdOle;
+
 typedef enum tagREGKIND {
 	REGKIND_DEFAULT,
 	REGKIND_REGISTER,

reactos/w32api/include
rpc.h 1.2 -> 1.2.18.1
diff -u -r1.2 -r1.2.18.1
--- rpc.h	17 Apr 2004 07:41:26 -0000	1.2
+++ rpc.h	8 Dec 2004 21:57:42 -0000	1.2.18.1
@@ -54,6 +54,15 @@
 #define RpcEndFinally }
 #define RpcExceptionCode() GetExceptionCode()
 #define RpcAbnormalTermination() AbnormalTermination()
+#else
+#define RpcTryExcept if (1) {
+#define RpcExcept(x) } else {
+#define RpcEndExcept }
+#define RpcTryFinally if (1) {
+#define RpcFinally } else {
+#define RpcEndFinally }
+#define RpcExceptionCode() 0
+#define RpcAbnormalTermination() AbnormalTermination()
 #endif /* 0 */
 
 RPC_STATUS RPC_ENTRY RpcImpersonateClient(RPC_BINDING_HANDLE);

reactos/w32api/include
rpcndr.h 1.3 -> 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- rpcndr.h	19 Sep 2004 09:11:12 -0000	1.3
+++ rpcndr.h	8 Dec 2004 21:57:42 -0000	1.3.6.1
@@ -12,6 +12,9 @@
 extern "C" {
 #endif
 #include <objfwd.h>
+#define TARGET_IS_NT50_OR_LATER 1
+#define TARGET_IS_NT40_OR_LATER 1
+#define TARGET_IS_NT351_OR_WIN95_OR_LATER 1
 #define DECLSPEC_UUID(x)
 #define MIDL_INTERFACE(x) struct
 #define NDR_CHAR_REP_MASK (unsigned long)0xFL

reactos/w32api/include
rpcproxy.h 1.2 -> 1.2.18.1
diff -u -r1.2 -r1.2.18.1
--- rpcproxy.h	17 Apr 2004 07:41:26 -0000	1.2
+++ rpcproxy.h	8 Dec 2004 21:57:42 -0000	1.2.18.1
@@ -20,6 +20,10 @@
 #include <rpcndr.h>
 #include <string.h>
 
+#ifndef __RPCPROXY_H_VERSION__
+#define __RPCPROXY_H_VERSION__ 475
+#endif
+
 #define CStdStubBuffer_METHODS CStdStubBuffer_QueryInterface,CStdStubBuffer_AddRef,\
 CStdStubBuffer_Release,CStdStubBuffer_Connect,CStdStubBuffer_Disconnect,CStdStubBuffer_Invoke,\
 CStdStubBuffer_IsIIDSupported,CStdStubBuffer_CountRefs,CStdStubBuffer_DebugServerQueryInterface,\
@@ -98,6 +102,13 @@
 
 #define DLLDATA_STANDARD_ROUTINES DLLDATA_ROUTINES( (const ProxyFileInfo**) pProxyFileList, &CLSID_PSFactoryBuffer)
 
+#define CINTERFACE_PROXY_VTABLE(n) \
+	struct \
+	{ \
+		CInterfaceProxyHeader header; \
+		void *Vtbl[n]; \
+	}
+
 struct tagCInterfaceStubVtbl;
 struct tagCInterfaceProxyVtbl;
 typedef struct tagCInterfaceStubVtbl *PCInterfaceStubVtblList;

reactos/w32api/include
shlobj.h 1.7 -> 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- shlobj.h	20 Sep 2004 19:47:14 -0000	1.7
+++ shlobj.h	8 Dec 2004 21:57:42 -0000	1.7.6.1
@@ -273,6 +273,9 @@
 #define CMIC_VALID_SEE_FLAGS	SEE_VALID_CMIC_FLAGS
 #define GIL_OPENICON	1
 #define GIL_FORSHELL	2
+#define GIL_ASYNC	32
+#define GIL_DEFAULTICON	64
+#define GIL_FORSHORTCUT	128
 #define GIL_SIMULATEDOC	1
 #define GIL_PERINSTANCE	2
 #define GIL_PERCLASS	4
@@ -377,6 +380,11 @@
 #define SHCNF_PATH              SHCNF_PATHA
 #define SHCNF_PRINTER           SHCNF_PRINTERA
 #endif
+#define PCS_FATAL		0x80000000
+#define PCS_REPLACEDCHAR	0x00000001
+#define PCS_REMOVEDCHAR		0x00000002
+#define PCS_TRUNCATED		0x00000004
+#define PCS_PATHTOOLONG		0x00000008
 
 typedef ULONG SFGAOF;
 typedef DWORD SHGDNF;
@@ -431,6 +439,10 @@
 	SHGDN_FORADDRESSBAR=0x4000,
 	SHGDN_FORPARSING=0x8000
 } SHGNO;
+typedef enum {
+	SHGFP_TYPE_CURRENT = 0,
+	SHGFP_TYPE_DEFAULT = 1
+} SHGFP_TYPE;
 typedef enum tagSHCONTF {
 	SHCONTF_FOLDERS = 32,
 	SHCONTF_NONFOLDERS = 64,

reactos/w32api/include
winuser.h 1.10 -> 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- winuser.h	20 Nov 2004 15:50:46 -0000	1.10
+++ winuser.h	8 Dec 2004 21:57:42 -0000	1.10.2.1
@@ -845,6 +845,10 @@
 #define COLOR_HOTLIGHT 26
 #define COLOR_GRADIENTACTIVECAPTION 27
 #define COLOR_GRADIENTINACTIVECAPTION 28
+#if WINVER >= 0x0501
+#define COLOR_MENUHILIGHT 29
+#define COLOR_MENUBAR 30
+#endif
 #define CTLCOLOR_MSGBOX 0
 #define CTLCOLOR_EDIT 1
 #define CTLCOLOR_LISTBOX 2
@@ -3837,7 +3841,6 @@
 BOOL WINAPI UnregisterClassA(LPCSTR,HINSTANCE);
 BOOL WINAPI UnregisterClassW(LPCWSTR,HINSTANCE);
 BOOL WINAPI UnregisterHotKey(HWND,int);
-BOOL WINAPI UpdatePerUserSystemParameters(DWORD,BOOL);
 BOOL WINAPI UpdateWindow(HWND);
 #if (_WIN32_WINNT >= 0x0500)
 BOOL WINAPI UserHandleGrantAccess(HANDLE,HANDLE,BOOL);

reactos/w32api/include
wtypes.h 1.5 -> 1.5.20.1
diff -u -r1.5 -r1.5.20.1
--- wtypes.h	2 Mar 2004 10:25:59 -0000	1.5
+++ wtypes.h	8 Dec 2004 21:57:42 -0000	1.5.20.1
@@ -11,23 +11,6 @@
 extern "C" {
 #endif
 
-#ifdef NONAMELESSUNION
-#define DEC_SIGN(d) ((d)->DUMMYUNIONNAME.DUMMYSTRUCTNAME.sign)
-#define DEC_SCALE(d) ((d)->DUMMYUNIONNAME.DUMMYSTRUCTNAME.scale)
-#define DEC_SIGNSCALE(d) ((d)->DUMMYUNIONNAME.signscale)
-#define DEC_MID32(d) ((d)->DUMMYUNIONNAME2.DUMMYSTRUCTNAME2.Mid32)
-#define DEC_LO32(d) ((d)->DUMMYUNIONNAME2.DUMMYSTRUCTNAME2.Lo32)
-#define DEC_LO64(d) ((d)->DUMMYUNIONNAME2.Lo64)
-#else
-#define DEC_SIGN(d) ((d)->sign)
-#define DEC_SCALE(d) ((d)->scale)
-#define DEC_SIGNSCALE(d) ((d)->signscale)
-#define DEC_MID32(d) ((d)->Mid32)
-#define DEC_LO32(d) ((d)->Lo32)
-#define DEC_LO64(d) ((d)->Lo64)
-#endif
-#define DEC_HI32(d) ((d)->Hi32)
-
 #define IID_NULL GUID_NULL
 #define CLSID_NULL GUID_NULL
 #define CBPCLIPDATA(d) ((d).cbSize-sizeof((d).ulClipFmt))
@@ -160,21 +143,21 @@
 typedef double DOUBLE;
 typedef struct tagDEC {
 	USHORT wReserved;
-	_ANONYMOUS_UNION union {
-		_ANONYMOUS_STRUCT struct {
+	union {
+		struct {
 			BYTE scale;
 			BYTE sign;
-		}_STRUCT_NAME(s);
+		};
 		USHORT signscale;
-	} DUMMYUNIONNAME;
+	};
 	ULONG Hi32;
-	_ANONYMOUS_UNION union {
-		_ANONYMOUS_STRUCT struct {
+	union {
+		struct {
 			ULONG Lo32;
 			ULONG Mid32;
-		}_STRUCT_NAME(s2);
+		};
 		ULONGLONG Lo64;
-	} DUMMYUNIONNAME2;
+	};
 } DECIMAL;
 typedef void *HMETAFILEPICT;
 #ifdef __cplusplus

reactos/w32api/include/ddk
ntapi.h 1.12 -> 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- ntapi.h	19 Nov 2004 01:30:35 -0000	1.12
+++ ntapi.h	8 Dec 2004 21:57:43 -0000	1.12.2.1
@@ -1106,32 +1106,32 @@
 NTAPI
 ZwAllocateUserPhysicalPages(
 	IN HANDLE  ProcessHandle,
-	IN PULONG  NumberOfPages,
-	OUT PULONG  PageFrameNumbers);
+	IN OUT PULONG_PTR  NumberOfPages,
+	OUT PULONG_PTR  UserPfnArray);
 
 NTOSAPI
 NTSTATUS
 NTAPI
 ZwFreeUserPhysicalPages(
 	IN HANDLE  ProcessHandle,
-	IN OUT PULONG  NumberOfPages,
-	IN PULONG  PageFrameNumbers);
+	IN OUT PULONG_PTR  NumberOfPages,
+	IN PULONG_PTR  UserPfnArray);
 
 NTOSAPI
 NTSTATUS
 NTAPI
 ZwMapUserPhysicalPages(
-	IN PVOID  BaseAddress,
-	IN PULONG  NumberOfPages,
-	IN PULONG  PageFrameNumbers);
+	IN PVOID  VirtualAddress,
+	IN ULONG_PTR  NumberOfPages,
+	IN PULONG_PTR  PageArray  OPTIONAL);
 
 NTOSAPI
 NTSTATUS
 NTAPI
 ZwMapUserPhysicalPagesScatter(
-	IN PVOID  *BaseAddresses,
-	IN PULONG  NumberOfPages,
-	IN PULONG  PageFrameNumbers);
+	IN PVOID  *VirtualAddresses,
+	IN ULONG_PTR  NumberOfPages,
+	IN PULONG_PTR  PageArray  OPTIONAL);
 
 NTOSAPI
 NTSTATUS

reactos/w32api/include/ddk
ntifs.h 1.7 -> 1.7.4.1
diff -u -r1.7 -r1.7.4.1
--- ntifs.h	24 Oct 2004 15:26:14 -0000	1.7
+++ ntifs.h	8 Dec 2004 21:57:43 -0000	1.7.4.1
@@ -873,7 +873,7 @@
 
 typedef struct _FILE_COMPLETION_INFORMATION {
     HANDLE  Port;
-    ULONG   Key;
+    PVOID   Key;
 } FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION;
 
 typedef struct _FILE_COMPRESSION_INFORMATION {

reactos/w32api/include/ddk
win2k.h 1.1 -> 1.1.20.1
diff -u -r1.1 -r1.1.20.1
--- win2k.h	21 Feb 2004 09:20:39 -0000	1.1
+++ win2k.h	8 Dec 2004 21:57:43 -0000	1.1.20.1
@@ -61,7 +61,7 @@
 
 NTOSAPI
 NTSTATUS
-DDKAPI
+DDKFASTAPI
 IoReadPartitionTable(
   IN PDEVICE_OBJECT  DeviceObject,
   IN ULONG  SectorSize,
@@ -70,7 +70,7 @@
 
 NTOSAPI
 NTSTATUS
-DDKAPI
+DDKFASTAPI
 IoSetPartitionInformation(
   IN PDEVICE_OBJECT  DeviceObject,
   IN ULONG  SectorSize,
@@ -79,7 +79,7 @@
 
 NTOSAPI
 NTSTATUS
-DDKAPI
+DDKFASTAPI
 IoWritePartitionTable(
   IN PDEVICE_OBJECT  DeviceObject,
   IN ULONG  SectorSize,

reactos/ntoskrnl/include/internal/i386
hal.h added at 1.8.4.1
diff -N hal.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hal.h	8 Dec 2004 21:57:43 -0000	1.8.4.1
@@ -0,0 +1,42 @@
+/*
+ * 
+ */
+
+#ifndef __INTERNAL_HAL_HAL_H
+#define __INTERNAL_HAL_HAL_H
+
+/*
+ * FUNCTION: Probes for a BIOS32 extension
+ */
+VOID Hal_bios32_probe(VOID);
+
+/*
+ * FUNCTION: Determines if a a bios32 service is present
+ */
+BOOLEAN Hal_bios32_is_service_present(ULONG service);
+
+VOID HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock);
+VOID HalResetDisplay (VOID);
+
+VOID HalpInitBusHandlers (VOID);
+
+/* irql.c */
+VOID HalpInitPICs(VOID);
+
+/* udelay.c */
+VOID HalpCalibrateStallExecution(VOID);
+
+/* pci.c */
+VOID HalpInitPciBus (VOID);
+
+struct _ADAPTER_OBJECT {
+  int Channel;
+  PVOID PagePort;
+  PVOID CountPort;
+  PVOID OffsetPort;
+  KSPIN_LOCK SpinLock;
+  PVOID Buffer;
+  BOOLEAN Inuse;
+};
+
+#endif /* __INTERNAL_HAL_HAL_H */
CVSspam 0.2.8