- Tree cleanups proposed on the mailing list. Move all non-Core OS modules to rosapps...
authorAlex Ionescu <aionescu@gmail.com>
Thu, 8 Mar 2007 19:00:15 +0000 (19:00 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Thu, 8 Mar 2007 19:00:15 +0000 (19:00 +0000)
svn path=/trunk/; revision=26033

420 files changed:
rosapps/avtest/avtest.rbuild [new file with mode: 0755]
rosapps/avtest/entry.c [new file with mode: 0755]
rosapps/downloader/download.c [new file with mode: 0644]
rosapps/downloader/downloader.rbuild [new file with mode: 0644]
rosapps/downloader/downloader.rc [new file with mode: 0644]
rosapps/downloader/main.c [new file with mode: 0644]
rosapps/downloader/packagetree/internet/browser/browser.rbuild [new file with mode: 0644]
rosapps/downloader/packagetree/internet/browser/firefox1509.dml [new file with mode: 0644]
rosapps/downloader/packagetree/internet/browser/firefox2001.dml [new file with mode: 0644]
rosapps/downloader/packagetree/internet/category.xml [new file with mode: 0644]
rosapps/downloader/packagetree/internet/internet.rbuild [new file with mode: 0644]
rosapps/downloader/packagetree/packagetree.rbuild [new file with mode: 0644]
rosapps/downloader/packagetree/script/default_install.xml [new file with mode: 0644]
rosapps/downloader/packagetree/script/default_uninstall.xml [new file with mode: 0644]
rosapps/downloader/packagetree/script/script.rbuild [new file with mode: 0644]
rosapps/downloader/packagetree/tree.xml [new file with mode: 0644]
rosapps/downloader/resources.h [new file with mode: 0644]
rosapps/downloader/resources/0.bmp [new file with mode: 0644]
rosapps/downloader/resources/1.bmp [new file with mode: 0644]
rosapps/downloader/resources/10.bmp [new file with mode: 0644]
rosapps/downloader/resources/2.bmp [new file with mode: 0644]
rosapps/downloader/resources/3.bmp [new file with mode: 0644]
rosapps/downloader/resources/4.bmp [new file with mode: 0644]
rosapps/downloader/resources/5.bmp [new file with mode: 0644]
rosapps/downloader/resources/6.bmp [new file with mode: 0644]
rosapps/downloader/resources/7.bmp [new file with mode: 0644]
rosapps/downloader/resources/8.bmp [new file with mode: 0644]
rosapps/downloader/resources/9.bmp [new file with mode: 0644]
rosapps/downloader/resources/download.bmp [new file with mode: 0644]
rosapps/downloader/resources/help.bmp [new file with mode: 0644]
rosapps/downloader/resources/logo.bmp [new file with mode: 0644]
rosapps/downloader/resources/main.ico [new file with mode: 0644]
rosapps/downloader/resources/underline.bmp [new file with mode: 0644]
rosapps/downloader/resources/uninstall.bmp [new file with mode: 0644]
rosapps/downloader/resources/update.bmp [new file with mode: 0644]
rosapps/downloader/rsrc.rc [new file with mode: 0644]
rosapps/downloader/script.c [new file with mode: 0644]
rosapps/downloader/structures.h [new file with mode: 0644]
rosapps/downloader/translations/de.rc [new file with mode: 0644]
rosapps/downloader/translations/en.rc [new file with mode: 0644]
rosapps/downloader/translations/fr.rc [new file with mode: 0644]
rosapps/downloader/translations/id.rc [new file with mode: 0644]
rosapps/downloader/translations/it.rc [new file with mode: 0644]
rosapps/downloader/xml.c [new file with mode: 0644]
rosapps/ext2/attr.c [new file with mode: 0644]
rosapps/ext2/blockdev.c [new file with mode: 0644]
rosapps/ext2/dir.c [new file with mode: 0644]
rosapps/ext2/ext2fs.h [new file with mode: 0644]
rosapps/ext2/ext2fs.rc [new file with mode: 0644]
rosapps/ext2/file.c [new file with mode: 0644]
rosapps/ext2/inode.c [new file with mode: 0644]
rosapps/ext2/quota.c [new file with mode: 0644]
rosapps/ext2/rw.c [new file with mode: 0644]
rosapps/ext2/security.c [new file with mode: 0644]
rosapps/ext2/super.c [new file with mode: 0644]
rosapps/gettype/gettype.c [new file with mode: 0644]
rosapps/gettype/gettype.rbuild [new file with mode: 0644]
rosapps/green/createclose.c [new file with mode: 0644]
rosapps/green/dispatch.c [new file with mode: 0644]
rosapps/green/green.c [new file with mode: 0644]
rosapps/green/green.h [new file with mode: 0644]
rosapps/green/green.inf [new file with mode: 0644]
rosapps/green/green.rbuild [new file with mode: 0644]
rosapps/green/green.rc [new file with mode: 0644]
rosapps/green/keyboard.c [new file with mode: 0644]
rosapps/green/misc.c [new file with mode: 0644]
rosapps/green/pnp.c [new file with mode: 0644]
rosapps/green/power.c [new file with mode: 0644]
rosapps/green/screen.c [new file with mode: 0644]
rosapps/imagesoft/about.c [new file with mode: 0644]
rosapps/imagesoft/adjust.c [new file with mode: 0644]
rosapps/imagesoft/brightness.c [new file with mode: 0644]
rosapps/imagesoft/contrast.c [new file with mode: 0644]
rosapps/imagesoft/custcombo.c [new file with mode: 0644]
rosapps/imagesoft/floatwindow.c [new file with mode: 0644]
rosapps/imagesoft/font.c [new file with mode: 0644]
rosapps/imagesoft/imageprop.h [new file with mode: 0644]
rosapps/imagesoft/imagesoft.c [new file with mode: 0644]
rosapps/imagesoft/imagesoft.rbuild [new file with mode: 0644]
rosapps/imagesoft/imagesoft.rc [new file with mode: 0644]
rosapps/imagesoft/imgedwnd.c [new file with mode: 0644]
rosapps/imagesoft/imgedwnd.h [new file with mode: 0644]
rosapps/imagesoft/lang/en-GB.rc [new file with mode: 0644]
rosapps/imagesoft/lang/en-US.rc [new file with mode: 0644]
rosapps/imagesoft/lang/id-ID.rc [new file with mode: 0644]
rosapps/imagesoft/lang/it-IT.rc [new file with mode: 0644]
rosapps/imagesoft/lang/nb-NO.rc [new file with mode: 0644]
rosapps/imagesoft/lang/th-TH.rc [new file with mode: 0644]
rosapps/imagesoft/mainwnd.c [new file with mode: 0644]
rosapps/imagesoft/mainwnd.h [new file with mode: 0644]
rosapps/imagesoft/manifest.xml [new file with mode: 0644]
rosapps/imagesoft/misc.c [new file with mode: 0644]
rosapps/imagesoft/misc.h [new file with mode: 0644]
rosapps/imagesoft/opensave.c [new file with mode: 0644]
rosapps/imagesoft/precomp.h [new file with mode: 0644]
rosapps/imagesoft/res/cursors/PaintBrushToolCursor.cur [new file with mode: 0644]
rosapps/imagesoft/res/cursors/PaintBrushToolCursorMouseDown.cur [new file with mode: 0644]
rosapps/imagesoft/res/icons/color/ColorLess.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/color/ColorMore.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/hist/HistBack.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/hist/HistDelete.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/hist/HistForward.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/hist/HistRedo.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/hist/HistUndo.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainCopyIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainCutIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainNewIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainOpenIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainPasteIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainPrintIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainPrintPreIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainRedoIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainSaveIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/std/MainUndoIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextAlignCenterIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextAlignLeftIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextAlignRightIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextBoldIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextItalicIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/text/TextUnderlineIcon.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsCloneStamp.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsColorPicker.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsEllipse.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsEllipseSelect.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsEraser.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsFreeformShape.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsLassoSelect.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsLine.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsMagicWand.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsMove.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsMoveSelection.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsPaintBrush.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsPaintBucket.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsPencil.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsRecoloring.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsRectangle.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsRectangleSelect.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsRoundedRectangle.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsText.bmp [new file with mode: 0644]
rosapps/imagesoft/res/icons/tools/ToolsZoom.bmp [new file with mode: 0644]
rosapps/imagesoft/res/imagesoft.ico [new file with mode: 0644]
rosapps/imagesoft/resource.h [new file with mode: 0644]
rosapps/imagesoft/rsrc.rc [new file with mode: 0644]
rosapps/imagesoft/tooldock.c [new file with mode: 0644]
rosapps/imagesoft/tooldock.h [new file with mode: 0644]
rosapps/net/dhcpd/AUTHORS [new file with mode: 0644]
rosapps/net/dhcpd/COPYING [new file with mode: 0644]
rosapps/net/dhcpd/ChangeLog [new file with mode: 0644]
rosapps/net/dhcpd/INSTALL [new file with mode: 0644]
rosapps/net/dhcpd/Makefile.am [new file with mode: 0644]
rosapps/net/dhcpd/Makefile.in [new file with mode: 0644]
rosapps/net/dhcpd/NEWS [new file with mode: 0644]
rosapps/net/dhcpd/README [new file with mode: 0644]
rosapps/net/dhcpd/README.ROS [new file with mode: 0644]
rosapps/net/dhcpd/TODO [new file with mode: 0644]
rosapps/net/dhcpd/aclocal.m4 [new file with mode: 0644]
rosapps/net/dhcpd/config.cache [new file with mode: 0644]
rosapps/net/dhcpd/config.h [new file with mode: 0644]
rosapps/net/dhcpd/config.h.in [new file with mode: 0644]
rosapps/net/dhcpd/config.h.top [new file with mode: 0644]
rosapps/net/dhcpd/config.log [new file with mode: 0644]
rosapps/net/dhcpd/config.status [new file with mode: 0644]
rosapps/net/dhcpd/configure [new file with mode: 0644]
rosapps/net/dhcpd/configure.in [new file with mode: 0644]
rosapps/net/dhcpd/dhcpd.rc [new file with mode: 0644]
rosapps/net/dhcpd/install-sh [new file with mode: 0644]
rosapps/net/dhcpd/missing [new file with mode: 0644]
rosapps/net/dhcpd/mkinstalldirs [new file with mode: 0644]
rosapps/net/dhcpd/samples/dhcp.conf [new file with mode: 0644]
rosapps/net/dhcpd/src/Makefile.am [new file with mode: 0644]
rosapps/net/dhcpd/src/Makefile.in [new file with mode: 0644]
rosapps/net/dhcpd/src/dhcp.conf [new file with mode: 0644]
rosapps/net/dhcpd/src/display/display.c [new file with mode: 0644]
rosapps/net/dhcpd/src/include/datatypes.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/display.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/headers.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/iputils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/leases.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/lock.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/macutils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/options.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/parser.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/utils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/include/wutils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/leases/leases.c [new file with mode: 0644]
rosapps/net/dhcpd/src/lock/locker.c [new file with mode: 0644]
rosapps/net/dhcpd/src/main.c [new file with mode: 0644]
rosapps/net/dhcpd/src/parsing/parser.c [new file with mode: 0644]
rosapps/net/dhcpd/src/utils/iputils.c [new file with mode: 0644]
rosapps/net/dhcpd/src/utils/macutils.c [new file with mode: 0644]
rosapps/net/dhcpd/src/utils/macutils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/utils/utils.h [new file with mode: 0644]
rosapps/net/dhcpd/src/utils/wutils.c [new file with mode: 0644]
rosapps/net/dhcpd/stamp-h [new file with mode: 0644]
rosapps/net/dhcpd/stamp-h.in [new file with mode: 0644]
rosapps/net/tditest/DIRS [new file with mode: 0644]
rosapps/net/tditest/include/debug.h [new file with mode: 0644]
rosapps/net/tditest/include/tditest.h [new file with mode: 0644]
rosapps/net/tditest/readme.txt [new file with mode: 0644]
rosapps/net/tditest/tditest.def [new file with mode: 0644]
rosapps/net/tditest/tditest.rc [new file with mode: 0644]
rosapps/net/tditest/tditest/SOURCES [new file with mode: 0644]
rosapps/net/tditest/tditest/tditest.c [new file with mode: 0644]
rosapps/ramdrv/minix/bitops.c [new file with mode: 0644]
rosapps/ramdrv/minix/bitops.h [new file with mode: 0644]
rosapps/ramdrv/minix/block.c [new file with mode: 0644]
rosapps/ramdrv/minix/blockdev.c [new file with mode: 0644]
rosapps/ramdrv/minix/cache.c [new file with mode: 0644]
rosapps/ramdrv/minix/dir.c [new file with mode: 0644]
rosapps/ramdrv/minix/inode.c [new file with mode: 0644]
rosapps/ramdrv/minix/minix.h [new file with mode: 0644]
rosapps/ramdrv/minix/minix.rc [new file with mode: 0644]
rosapps/ramdrv/minix/minix_fs.h [new file with mode: 0644]
rosapps/ramdrv/minix/mount.c [new file with mode: 0644]
rosapps/ramdrv/minix/rw.c [new file with mode: 0644]
rosapps/ramdrv/ramdrv.c [new file with mode: 0644]
rosapps/ramdrv/ramdrv.h [new file with mode: 0644]
rosapps/ramdrv/ramdrv.rbuild [new file with mode: 0644]
rosapps/ramdrv/ramdrv.rc [new file with mode: 0644]
rosapps/roshttpd/common/list.cpp [new file with mode: 0644]
rosapps/roshttpd/common/roshttpd.rc [new file with mode: 0644]
rosapps/roshttpd/common/socket.cpp [new file with mode: 0644]
rosapps/roshttpd/common/thread.cpp [new file with mode: 0644]
rosapps/roshttpd/config.cpp [new file with mode: 0644]
rosapps/roshttpd/error.cpp [new file with mode: 0644]
rosapps/roshttpd/http.cpp [new file with mode: 0644]
rosapps/roshttpd/httpd.cpp [new file with mode: 0644]
rosapps/roshttpd/include/config.h [new file with mode: 0644]
rosapps/roshttpd/include/debug.h [new file with mode: 0644]
rosapps/roshttpd/include/error.h [new file with mode: 0644]
rosapps/roshttpd/include/http.h [new file with mode: 0644]
rosapps/roshttpd/include/httpd.h [new file with mode: 0644]
rosapps/roshttpd/include/iterator.h [new file with mode: 0644]
rosapps/roshttpd/include/list.h [new file with mode: 0644]
rosapps/roshttpd/include/socket.h [new file with mode: 0644]
rosapps/roshttpd/include/thread.h [new file with mode: 0644]
rosapps/roshttpd/roshttpd.cpp [new file with mode: 0644]
rosapps/roshttpd/roshttpd.rbuild [new file with mode: 0644]
rosapps/screenshot/screenshot.c [new file with mode: 0644]
rosapps/screenshot/screenshot.h [new file with mode: 0644]
rosapps/screenshot/screenshot.rbuild [new file with mode: 0644]
rosapps/screenshot/screenshot.rc [new file with mode: 0644]
rosapps/screenshot/snap.ico [new file with mode: 0644]
rosapps/sysutils/utils/binpatch/binpatch.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/binpatch/patch.c [new file with mode: 0644]
rosapps/sysutils/utils/cat/cat.c [new file with mode: 0644]
rosapps/sysutils/utils/cat/cat.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/driver/driver.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/driver/load/load.c [new file with mode: 0644]
rosapps/sysutils/utils/driver/load/load.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/driver/unload/unload.c [new file with mode: 0644]
rosapps/sysutils/utils/driver/unload/unload.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/infinst/infinst.c [new file with mode: 0644]
rosapps/sysutils/utils/infinst/infinst.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/nts2w32err/nts2w32err.c [new file with mode: 0644]
rosapps/sysutils/utils/nts2w32err/nts2w32err.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/objdir/objdir.c [new file with mode: 0644]
rosapps/sysutils/utils/objdir/objdir.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/partinfo/partinfo.c [new file with mode: 0644]
rosapps/sysutils/utils/partinfo/partinfo.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/main.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/retypes.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/stab.def [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/stab_gnu.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/stdinc.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/terminal.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/loader/terminal.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/animation.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/bp.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/bp.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/charset.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/dblflt.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/dblflt.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/debug.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/debug.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/disassembler.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/disassembler.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/disassemblerdata.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/disassemblerdefines.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/gpfault.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/gpfault.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hardware.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hardware.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hercules.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hercules.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hooks.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/hooks.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/init.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/init.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/ldrsym.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/logo.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/output.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/output.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/parse.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/parse.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/patch.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/patch.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/pci_ids.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/pgflt.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/pgflt.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/pice.rc [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/pice_ver.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/precomp.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/privateice.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/regs.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/remods.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/retypes.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/scancodes.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/serial.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/serial.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/serial_port.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/shell.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/shell.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/stab.def [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/stab_gnu.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/symbols.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/symbols.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/syscall.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/syscall.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/trace.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/trace.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/utils.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/utils.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/vga.c [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/vga.h [new file with mode: 0644]
rosapps/sysutils/utils/pice/module/vga_utils.asm [new file with mode: 0644]
rosapps/sysutils/utils/pice/pice.cfg [new file with mode: 0644]
rosapps/sysutils/utils/pice/readme.txt [new file with mode: 0644]
rosapps/sysutils/utils/pice/shared/shared.h [new file with mode: 0644]
rosapps/sysutils/utils/pnpdump/pnpdump.c [new file with mode: 0644]
rosapps/sysutils/utils/ps/ps.c [new file with mode: 0644]
rosapps/sysutils/utils/ps/ps.c.toolhelp [new file with mode: 0644]
rosapps/sysutils/utils/ps/ps.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/alphablend.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/fill.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/gradient.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/lines.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/rosperf.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/rosperf.h [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/rosperf.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/rosperf.rc [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/testlist.c [new file with mode: 0644]
rosapps/sysutils/utils/rosperf/text.c [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/EnumDirs.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/EnumDirsImpl.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/EnumFiles.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/EnumFilesImpl.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/File.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/File.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/FixLFN.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/Header.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/Symbol.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/Type.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/assert.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/binary2cstr.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/binary2cstr.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/input.lst [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/iskeyword.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/iskeyword.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/safestr.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/sdkparse.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/sdkparse.dsp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/sdkparse.dsw [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/skip_ws.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/skip_ws.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/strip_comments.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/strip_comments.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/test.h [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/tokenize.cpp [new file with mode: 0644]
rosapps/sysutils/utils/sdkparse/tokenize.h [new file with mode: 0644]
rosapps/sysutils/utils/stats/stats.c [new file with mode: 0644]
rosapps/sysutils/utils/stats/stats.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/theme/dump/manifest.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/theme/dump/themedump.bpr [new file with mode: 0644]
rosapps/sysutils/utils/theme/dump/themedump.cpp [new file with mode: 0644]
rosapps/sysutils/utils/theme/dump/themedump.rc [new file with mode: 0644]
rosapps/sysutils/utils/tickcount/tickcount.c [new file with mode: 0644]
rosapps/sysutils/utils/tickcount/tickcount.rbuild [new file with mode: 0644]
rosapps/sysutils/utils/utils.rbuild [new file with mode: 0644]
rosapps/templates/template/template.c [new file with mode: 0644]
rosapps/winefile/Doxyfile [new file with mode: 0644]
rosapps/winefile/Makefile-MinGW [new file with mode: 0644]
rosapps/winefile/doxy-footer.html [new file with mode: 0644]
rosapps/winefile/doxy-footer.htmt [new file with mode: 0644]
rosapps/winefile/drivebar.bmp [new file with mode: 0644]
rosapps/winefile/images.bmp [new file with mode: 0644]
rosapps/winefile/lang/cs-CZ.rc [new file with mode: 0644]
rosapps/winefile/lang/de-DE.rc [new file with mode: 0644]
rosapps/winefile/lang/en-US.rc [new file with mode: 0644]
rosapps/winefile/lang/es-ES.rc [new file with mode: 0644]
rosapps/winefile/lang/fr-FR.rc [new file with mode: 0644]
rosapps/winefile/lang/hu-HU.rc [new file with mode: 0644]
rosapps/winefile/lang/it-IT.rc [new file with mode: 0644]
rosapps/winefile/lang/nb-NO.rc [new file with mode: 0644]
rosapps/winefile/lang/nl-NL.rc [new file with mode: 0644]
rosapps/winefile/lang/pl-PL.rc [new file with mode: 0644]
rosapps/winefile/lang/pt-PT.rc [new file with mode: 0644]
rosapps/winefile/lang/ru-RU.rc [new file with mode: 0644]
rosapps/winefile/lang/sl-SI.rc [new file with mode: 0644]
rosapps/winefile/lang/sv-SE.rc [new file with mode: 0644]
rosapps/winefile/lang/zh-CN.rc [new file with mode: 0644]
rosapps/winefile/make-docu.sh [new file with mode: 0755]
rosapps/winefile/make_winefile.dsp [new file with mode: 0644]
rosapps/winefile/make_winefile.vcproj [new file with mode: 0644]
rosapps/winefile/makel-docu.bat [new file with mode: 0755]
rosapps/winefile/resource.h [new file with mode: 0644]
rosapps/winefile/resource.rc [new file with mode: 0644]
rosapps/winefile/splitpath.c [new file with mode: 0644]
rosapps/winefile/toolbar.bmp [new file with mode: 0644]
rosapps/winefile/winefile.c [new file with mode: 0644]
rosapps/winefile/winefile.dsp [new file with mode: 0644]
rosapps/winefile/winefile.dsw [new file with mode: 0644]
rosapps/winefile/winefile.h [new file with mode: 0644]
rosapps/winefile/winefile.ico [new file with mode: 0644]
rosapps/winefile/winefile.rbuild [new file with mode: 0644]
rosapps/winefile/winefile.rc [new file with mode: 0644]
rosapps/winefile/winefile.sln [new file with mode: 0644]
rosapps/winefile/winefile.vcproj [new file with mode: 0644]
rosapps/winver/winver.c [new file with mode: 0644]
rosapps/winver/winver.rbuild [new file with mode: 0644]

diff --git a/rosapps/avtest/avtest.rbuild b/rosapps/avtest/avtest.rbuild
new file mode 100755 (executable)
index 0000000..5088f33
--- /dev/null
@@ -0,0 +1,8 @@
+<module name="avtest" type="kernelmodedriver" installbase="system32/drivers" installname="avtest.sys" warnings="true">
+       <include base="avtest">.</include>
+       <include base="avtest">..</include>
+       <define name="__USE_W32API" />
+       <library>ks</library>
+       <library>ntoskrnl</library>
+       <file>entry.c</file>
+</module>
diff --git a/rosapps/avtest/entry.c b/rosapps/avtest/entry.c
new file mode 100755 (executable)
index 0000000..2c66a5e
--- /dev/null
@@ -0,0 +1,83 @@
+#include <debug.h>
+#include <ks.h>
+
+/* Where do we go? */
+#ifndef SIZEOF_ARRAY
+       #define SIZEOF_ARRAY(array) \
+               (sizeof(array) / sizeof(array[0]))
+#endif
+
+/* Not in the DDK but hey! */
+#define DEFINE_KSFILTER_DISPATCH(name) \
+       const KSFILTER_DISPATCH name =
+
+/* To be put in KS.H */
+#define DEFINE_KSFILTER_DESCRIPTOR(name) \
+       const KSFILTER_DESCRIPTOR name =
+
+#define DEFINE_KSFILTER_DESCRIPTOR_TABLE(name) \
+       const KSFILTER_DESCRIPTOR* const name[] =
+
+
+
+NTSTATUS FilterCreate(
+       IN OUT PKSFILTER Filter,
+       IN PIRP Irp)
+{
+       return STATUS_SUCCESS;
+}
+
+NTSTATUS FilterClose(
+       IN OUT PKSFILTER Filter,
+       IN PIRP Irp)
+{
+       return STATUS_SUCCESS;
+}
+
+NTSTATUS Process(
+       IN PKSFILTER Filter,
+       IN PKSPROCESSPIN_INDEXENTRY ProcessPinsIndex)
+{
+       return STATUS_SUCCESS;
+}
+
+
+DEFINE_KSFILTER_DISPATCH(FilterDispatch)
+{
+       FilterCreate,
+       FilterClose,
+       Process,
+       NULL    // Reset
+};
+
+DEFINE_KSFILTER_DESCRIPTOR(FilterDesc)
+{
+};
+
+DEFINE_KSFILTER_DESCRIPTOR_TABLE(FilterDescs)
+{
+       &FilterDesc
+};
+
+
+
+const KSDEVICE_DESCRIPTOR DeviceDescriptor =
+{
+       NULL,
+       SIZEOF_ARRAY(FilterDescs),
+       FilterDescs
+};
+
+
+/* Funcs */
+
+NTSTATUS STDCALL
+DriverEntry(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PUNICODE_STRING RegistryPathName)
+{
+       DPRINT1("AVStream test component loaded!\n");
+
+       return KsInitializeDriver(DriverObject, RegistryPathName,
+                                                       &DeviceDescriptor);
+}
diff --git a/rosapps/downloader/download.c b/rosapps/downloader/download.c
new file mode 100644 (file)
index 0000000..f710f5e
--- /dev/null
@@ -0,0 +1,303 @@
+/* PROJECT:     ReactOS Downloader (was GetFirefox)
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        base/applications/downloader/download.c
+ * PURPOSE:     Displaying a download dialog
+ * COPYRIGHT:   Copyright 2001 John R. Sheets (for CodeWeavers)
+ *              Copyright 2004 Mike McCormack (for CodeWeavers)
+ *              Copyright 2005 Ge van Geldorp (gvg@reactos.org)
+ */
+/*
+ * Based on Wine dlls/shdocvw/shdocvw_main.c
+ *
+ * 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 COBJMACROS
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <commctrl.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <urlmon.h>
+
+#include "resources.h"
+#include "structures.h"
+
+#define NDEBUG
+#include <debug.h>
+
+extern struct Application* SelectedApplication;
+extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
+
+typedef struct _IBindStatusCallbackImpl
+  {
+    const IBindStatusCallbackVtbl *vtbl;
+    LONG ref;
+    HWND hDialog;
+    BOOL *pbCancelled;
+  } IBindStatusCallbackImpl;
+
+static HRESULT WINAPI
+dlQueryInterface(IBindStatusCallback* This, REFIID riid, void** ppvObject)
+{
+  if (NULL == ppvObject)
+    {
+      return E_POINTER;
+    }
+    
+  if (IsEqualIID(riid, &IID_IUnknown) ||
+      IsEqualIID(riid, &IID_IBindStatusCallback))
+    {
+      IBindStatusCallback_AddRef( This );
+      *ppvObject = This;
+      return S_OK;
+    }
+
+  return E_NOINTERFACE;
+}
+
+static ULONG WINAPI
+dlAddRef(IBindStatusCallback* iface)
+{
+  IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
+    
+  return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI
+dlRelease(IBindStatusCallback* iface)
+{
+  IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
+  DWORD ref = InterlockedDecrement(&This->ref);
+    
+  if( !ref )
+    {
+      DestroyWindow( This->hDialog );
+      HeapFree(GetProcessHeap(), 0, This);
+    }
+    
+  return ref;
+}
+
+static HRESULT WINAPI
+dlOnStartBinding(IBindStatusCallback* iface, DWORD dwReserved, IBinding* pib)
+{
+  DPRINT1("OnStartBinding not implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlGetPriority(IBindStatusCallback* iface, LONG* pnPriority)
+{
+  DPRINT1("GetPriority not implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlOnLowResource( IBindStatusCallback* iface, DWORD reserved)
+{
+  DPRINT1("OnLowResource not implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlOnProgress(IBindStatusCallback* iface, ULONG ulProgress,
+             ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
+{
+  IBindStatusCallbackImpl *This = (IBindStatusCallbackImpl *) iface;
+  HWND Item;
+  LONG r;
+  WCHAR OldText[100];
+
+  Item = GetDlgItem(This->hDialog, IDC_PROGRESS);
+  if (NULL != Item && 0 != ulProgressMax)
+    {
+      SendMessageW(Item, PBM_SETPOS, (ulProgress * 100) / ulProgressMax, 0);
+    }
+
+  Item = GetDlgItem(This->hDialog, IDC_STATUS);
+  if (NULL != Item && NULL != szStatusText)
+    {
+      SendMessageW(Item, WM_GETTEXT, sizeof(OldText) / sizeof(OldText[0]),
+                   (LPARAM) OldText);
+      if (sizeof(OldText) / sizeof(OldText[0]) - 1 <= wcslen(OldText) ||
+          0 != wcscmp(OldText, szStatusText))
+        {
+          SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) szStatusText);
+        }
+    }
+
+  SetLastError(0);
+  r = GetWindowLongPtrW(This->hDialog, GWLP_USERDATA);
+  if (0 != r || 0 != GetLastError())
+    {
+      *This->pbCancelled = TRUE;
+      DPRINT("Cancelled\n");
+      return E_ABORT;
+    }
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlOnStopBinding(IBindStatusCallback* iface, HRESULT hresult, LPCWSTR szError)
+{
+  DPRINT1("OnStopBinding not implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlGetBindInfo(IBindStatusCallback* iface, DWORD* grfBINDF, BINDINFO* pbindinfo)
+{
+  DPRINT1("GetBindInfo not implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlOnDataAvailable(IBindStatusCallback* iface, DWORD grfBSCF,
+                  DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
+{
+  DPRINT1("OnDataAvailable implemented\n");
+
+  return S_OK;
+}
+
+static HRESULT WINAPI
+dlOnObjectAvailable(IBindStatusCallback* iface, REFIID riid, IUnknown* punk)
+{
+  DPRINT1("OnObjectAvailable implemented\n");
+
+  return S_OK;
+}
+
+static const IBindStatusCallbackVtbl dlVtbl =
+{
+    dlQueryInterface,
+    dlAddRef,
+    dlRelease,
+    dlOnStartBinding,
+    dlGetPriority,
+    dlOnLowResource,
+    dlOnProgress,
+    dlOnStopBinding,
+    dlGetBindInfo,
+    dlOnDataAvailable,
+    dlOnObjectAvailable
+};
+
+static IBindStatusCallback*
+CreateDl(HWND Dlg, BOOL *pbCancelled)
+{
+  IBindStatusCallbackImpl *This;
+
+  This = HeapAlloc(GetProcessHeap(), 0, sizeof(IBindStatusCallbackImpl));
+  This->vtbl = &dlVtbl;
+  This->ref = 1;
+  This->hDialog = Dlg;
+  This->pbCancelled = pbCancelled;
+
+  return (IBindStatusCallback*) This;
+}
+
+static DWORD WINAPI
+ThreadFunc(LPVOID Context)
+{
+  //static const WCHAR szUrl[] = DownloadUrl;
+  IBindStatusCallback *dl;
+  HWND Dlg = ((struct lParamDownload*)Context)->Dlg;
+  DWORD r;
+  BOOL bCancelled = FALSE;
+  dl = CreateDl(Dlg, &bCancelled);
+  r = URLDownloadToFileW(NULL, ((struct lParamDownload*)Context)->URL, ((struct lParamDownload*)Context)->File, 0, dl);
+  if (NULL != dl)
+    {
+      IBindStatusCallback_Release(dl);
+    }
+  if (S_OK != r)
+    {
+         MessageBoxW(0,Strings[IDS_DOWNLOAD_ERROR],0,0);
+    }
+  EndDialog(Dlg, 0);
+  return 0;
+}
+
+INT_PTR CALLBACK
+DownloadProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+  HANDLE Thread;
+  DWORD ThreadId;
+  HWND Item;;
+
+  switch (Msg)
+    {
+    case WM_INITDIALOG:/*
+      Icon = LoadIconW((HINSTANCE) GetWindowLongPtr(Dlg, GWLP_HINSTANCE),
+                       MAKEINTRESOURCEW(IDI_ICON_MAIN));
+      if (NULL != Icon)
+        {
+          SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) Icon);
+          SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) Icon);
+        }*/
+      SetWindowLongPtrW(Dlg, GWLP_USERDATA, 0);
+      Item = GetDlgItem(Dlg, IDC_PROGRESS);
+      if (NULL != Item)
+        {
+          SendMessageW(Item, PBM_SETRANGE, 0, MAKELPARAM(0,100));
+          SendMessageW(Item, PBM_SETPOS, 0, 0);
+        }/*
+      Item = GetDlgItem(Dlg, IDC_REMOVE);
+      if (NULL != Item)
+        {
+          if (GetShortcutName(ShortcutName) &&
+              INVALID_FILE_ATTRIBUTES != GetFileAttributesW(ShortcutName))
+            {
+              SendMessageW(Item, BM_SETCHECK, BST_CHECKED, 0);
+            }
+          else
+            {
+              SendMessageW(Item, BM_SETCHECK, BST_UNCHECKED, 0);
+              ShowWindow(Item, SW_HIDE);
+            }
+        }*/
+      ((struct lParamDownload*)lParam)->Dlg = Dlg;
+      Thread = CreateThread(NULL, 0, ThreadFunc, (LPVOID)lParam, 0, &ThreadId);
+      if (NULL == Thread)
+        {
+          return FALSE;
+        }
+      CloseHandle(Thread);
+      return TRUE;
+
+    case WM_COMMAND:
+      if (wParam == IDCANCEL)
+        {
+          SetWindowLongPtrW(Dlg, GWLP_USERDATA, 1);
+          PostMessage(Dlg, WM_CLOSE, 0, 0);
+        }
+      return FALSE;
+
+    case WM_CLOSE:
+        EndDialog(Dlg, 0);
+        return TRUE;
+
+       default:
+      return FALSE;
+    }
+}
diff --git a/rosapps/downloader/downloader.rbuild b/rosapps/downloader/downloader.rbuild
new file mode 100644 (file)
index 0000000..4665d53
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<directory name="packagetree">
+       <xi:include href="packagetree/packagetree.rbuild" />
+</directory>
+<module name="downloader" type="win32gui" installbase="system32" installname="downloader.exe">
+       <include base="downloader">.</include>
+       <include base="expat">.</include>
+
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="__USE_W32API" />
+       <define name="WINVER">0x0501</define>
+       <define name="_WIN32_IE>0x0600</define>
+       
+       <library>kernel32</library>
+       <library>advapi32</library>
+       <library>ntdll</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <library>shell32</library>
+       <library>comctl32</library>
+       <library>msimg32</library>
+       <library>shlwapi</library>
+       <library>urlmon</library>
+       <library>uuid</library>
+       <library>expat</library>
+
+       <file>main.c</file>
+       <file>xml.c</file>
+       <file>download.c</file>
+       <file>script.c</file>
+       <file>downloader.rc</file>
+</module>
diff --git a/rosapps/downloader/downloader.rc b/rosapps/downloader/downloader.rc
new file mode 100644 (file)
index 0000000..ec674c4
--- /dev/null
@@ -0,0 +1,10 @@
+#include <windows.h>
+#include "resources.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION   "Download !\0"
+#define REACTOS_STR_INTERNAL_NAME      "downloader\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "downloader.exe\0"
+
+#include <reactos/version.rc>
+
+#include "rsrc.rc"
diff --git a/rosapps/downloader/main.c b/rosapps/downloader/main.c
new file mode 100644 (file)
index 0000000..6f812ee
--- /dev/null
@@ -0,0 +1,538 @@
+/* PROJECT:         ReactOS Downloader
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base/applications/downloader/xml.c
+ * PURPOSE:         Main program
+ * PROGRAMMERS:     Maarten Bosma, Lester Kortenhoeven
+ */
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include <stdio.h>
+#include <shlwapi.h>
+#include <wchar.h>
+#include "resources.h"
+#include "structures.h"
+
+#define XML_PATH "tree.xml"
+
+HWND hwnd, hCategories, hApps, hDownloadButton, hUninstallButton, hUpdateButton, hHelpButton;
+HBITMAP hLogo, hUnderline;
+CHAR* CmdLine;
+WCHAR* DescriptionHeadline = L"";
+WCHAR* DescriptionText = L"";
+WCHAR ApplicationText[0xA04];  // MAX_STRING_LENGHT + Version + \n + MAX_STRING_LENGHT + Licence + \n + MAX_STRING_LENGHT + Maintainer + \n\n + Description
+                               //             0x100 +   0x100 +  1 +             0x100 +   0x100 +  1 +             0x100 +      0x100 +    2 +       0x400 = 0xA04
+struct Category Root;
+struct Application* SelectedApplication;
+
+INT_PTR CALLBACK DownloadProc (HWND, UINT, WPARAM, LPARAM);
+DWORD WINAPI InstallThreadFunc(LPVOID);
+DWORD WINAPI UninstallThreadFunc(LPVOID);
+BOOL ProcessXML (const char* filename, struct Category* Root);
+char* addDML (const char*);
+VOID FreeTree (struct Category* Node);
+WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
+
+BOOL getUninstaller(struct Application* CurrentApplication, WCHAR* Uninstaller) {
+
+       DWORD ArraySize = 0x100;
+
+       HKEY hKey1;
+       HKEY hKey2;
+       DWORD Type = 0;
+       WCHAR Value[ArraySize];
+       WCHAR KeyName[ArraySize];
+       DWORD Size = ArraySize;
+       LONG i = 0;
+
+       if (CurrentApplication->RegName[0] == L'\0') {
+               return FALSE;
+       }
+
+       if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_READ,&hKey1) == ERROR_SUCCESS) {
+               if (RegOpenKeyExW(hKey1,CurrentApplication->RegName,0,KEY_READ,&hKey2) == ERROR_SUCCESS) {
+                       if (RegQueryValueExW(hKey2,L"UninstallString",0,&Type,(LPBYTE)Uninstaller,&Size) == ERROR_SUCCESS) {
+                               RegCloseKey(hKey2);
+                               RegCloseKey(hKey1);
+                               return TRUE;
+                       } else {
+                               RegCloseKey(hKey2);
+                               RegCloseKey(hKey1);
+                               return FALSE;
+                       }
+               } 
+               while (RegEnumKeyExW(hKey1,i,KeyName,&Size,NULL,NULL,NULL,NULL) == ERROR_SUCCESS) {
+                       ++i;
+                       RegOpenKeyExW(hKey1,KeyName,0,KEY_READ,&hKey2);
+                       Size = sizeof(Value);
+                       if (RegQueryValueExW(hKey2,L"DisplayName",0,&Type,(LPBYTE)Value,&Size) == ERROR_SUCCESS) {
+                               Size = ArraySize;
+                               if (!wcscmp(Value,CurrentApplication->RegName)) {
+                                       if (RegQueryValueExW(hKey2,L"UninstallString",0,&Type,(LPBYTE)Uninstaller,&Size) == ERROR_SUCCESS) {
+                                               RegCloseKey(hKey2);
+                                               RegCloseKey(hKey1);
+                                               return TRUE;
+                                       } else {
+                                               RegCloseKey(hKey2);
+                                               RegCloseKey(hKey1);
+                                               return FALSE;
+                                       }
+                               }
+                       }
+                       RegCloseKey(hKey2);
+                       Size = ArraySize;
+               }
+               RegCloseKey(hKey1);
+       }
+       return FALSE;
+}
+
+void ShowMessage (WCHAR* title, WCHAR* message)
+{
+       DescriptionHeadline = title;
+       DescriptionText = message;
+       InvalidateRect(hwnd,NULL,TRUE); 
+       UpdateWindow(hwnd);
+}
+
+void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent)
+{ 
+       TV_INSERTSTRUCTW Insert; 
+
+       Insert.item.lParam = (UINT)Category;
+       Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;;
+       Insert.item.pszText = Category->Name;
+       Insert.item.cchTextMax = lstrlenW(Category->Name); 
+       Insert.item.iImage = Category->Icon;
+       Insert.item.iSelectedImage = Category->Icon;
+       Insert.hInsertAfter = TVI_LAST;
+       Insert.hParent = Category->Parent ? Category->Parent->TreeviewItem : TVI_ROOT;
+
+       Category->TreeviewItem = (HTREEITEM)SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert);
+
+       if(Category->Next)
+               AddItems (hwnd,Category->Next,Parent);
+
+       if(Category->Children)
+               AddItems (hwnd,Category->Children,Category);
+}
+
+void CategoryChoosen (HWND hwnd, struct Category* Category)
+{
+       struct Application* CurrentApplication;
+       TV_INSERTSTRUCTW Insert;
+       SelectedApplication = NULL;
+       
+       if(Category->Children && !Category->Apps)
+               ShowMessage(Category->Name, Strings[IDS_CHOOSE_SUB]);
+       else if(!Category->Children && Category->Apps)
+               ShowMessage(Category->Name, Strings[IDS_CHOOSE_APP]);
+       else if(Category->Children && Category->Apps)
+               ShowMessage(Category->Name, Strings[IDS_CHOOSE_BOTH]);
+       else
+               ShowMessage(Category->Name, Strings[IDS_NO_APPS]);
+
+       (void)TreeView_DeleteItem(hwnd, TVI_ROOT);
+       (void)TreeView_DeleteItem(hwnd, TVI_ROOT); // Delete twice to bypass bug in windows 
+
+       Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE;
+       Insert.hInsertAfter = TVI_LAST;
+       Insert.hParent = TVI_ROOT;
+
+       CurrentApplication = Category->Apps;
+
+       while(CurrentApplication)
+       {
+               Insert.item.lParam = (UINT)CurrentApplication;
+               Insert.item.pszText = CurrentApplication->Name;
+               Insert.item.cchTextMax = lstrlenW(CurrentApplication->Name);
+               if(getUninstaller(CurrentApplication, NULL)) {
+                       Insert.item.iImage = 9;
+               } else {
+                       Insert.item.iImage = 10;
+               }
+               SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert);
+               CurrentApplication = CurrentApplication->Next;
+       }
+}
+
+BOOL SetupControls (HWND hwnd)
+{
+       TV_INSERTSTRUCTW Insert = {0};
+       HIMAGELIST hImageList;
+       HINSTANCE hInstance = GetModuleHandle(NULL);
+
+       // Parse the XML file
+       if (ProcessXML (XML_PATH, &Root) == FALSE)
+               return FALSE;
+
+       // Set up the controls
+       hCategories = CreateWindowExW(0, WC_TREEVIEWW, L"Categories", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, 
+                                                       0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
+
+       hApps = CreateWindowExW(0, WC_TREEVIEWW, L"Applications", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, 
+                                                       0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
+
+       hLogo = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO));
+       hUnderline = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_UNDERLINE));
+
+       hHelpButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 550, 10, 40, 40, hwnd, 0, hInstance, NULL);
+       hUpdateButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 500, 10, 40, 40, hwnd, 0, hInstance, NULL);
+       hDownloadButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 330, 505, 140, 35, hwnd, 0, hInstance, NULL);
+       hUninstallButton = CreateWindowW (L"Button", L"", WS_CHILD|WS_VISIBLE|BS_BITMAP, 260, 505, 140, 35, hwnd, 0, hInstance, NULL);
+
+       SendMessageW(hHelpButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HELP)));
+       SendMessageW(hUpdateButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UPDATE)));
+       SendMessageW(hDownloadButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD)));
+       SendMessageW(hUninstallButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNINSTALL)));
+       ShowWindow(hUninstallButton, SW_HIDE);
+
+       // Set deflaut entry for hApps
+       Insert.item.mask = TVIF_TEXT|TVIF_IMAGE;
+       Insert.item.pszText = Strings[IDS_CHOOSE_CATEGORY];
+       Insert.item.cchTextMax = lstrlenW(Strings[IDS_CHOOSE_CATEGORY]); 
+       Insert.item.iImage = 0;
+       SendMessage(hApps, TVM_INSERTITEM, 0, (LPARAM)&Insert); 
+
+       // Create Tree Icons
+       hImageList = ImageList_Create(16, 16, ILC_COLORDDB, 1, 1);
+       SendMessageW(hCategories, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
+       SendMessageW(hApps, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)(HIMAGELIST)hImageList);
+
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_0)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_1)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_2)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_3)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_4)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_5)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_6)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_7)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_8)), NULL);
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_9)), NULL); 
+       ImageList_Add(hImageList, LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TREEVIEW_ICON_10)), NULL);
+
+       // Fill the TreeViews
+       AddItems (hCategories, Root.Children, NULL);
+
+       return TRUE;
+}
+
+static void ResizeControl (HWND hwnd, int x1, int y1, int x2, int y2)
+{
+       // Make resizing a little easier
+       MoveWindow(hwnd, x1, y1, x2-x1, y2-y1, TRUE);
+}
+
+static void DrawBitmap (HDC hdc, int x, int y, HBITMAP hBmp)
+{
+       BITMAP bm;
+       HDC hdcMem = CreateCompatibleDC(hdc);
+
+       SelectObject(hdcMem, hBmp);
+       GetObject(hBmp, sizeof(bm), &bm);
+       TransparentBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, 0xFFFFFF);
+
+       DeleteDC(hdcMem);
+}
+
+static void DrawDescription (HDC hdc, RECT DescriptionRect)
+{
+       int i;
+       HFONT Font;
+       RECT Rect = {DescriptionRect.left+5, DescriptionRect.top+3, DescriptionRect.right-2, DescriptionRect.top+22};
+
+       // Backgroud
+       Rectangle(hdc, DescriptionRect.left, DescriptionRect.top, DescriptionRect.right, DescriptionRect.bottom);
+
+       // Underline
+       for (i=DescriptionRect.left+1;i<DescriptionRect.right-1;i++)
+               DrawBitmap(hdc, i, DescriptionRect.top+22, hUnderline); // less code then stretching ;)
+
+       // Headline
+       Font = CreateFont(-16 , 0, 0, 0, FW_EXTRABOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, 
+                                               OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
+       SelectObject(hdc, Font);
+       DrawTextW(hdc, DescriptionHeadline, lstrlenW(DescriptionHeadline), &Rect, DT_SINGLELINE|DT_NOPREFIX);
+       DeleteObject(Font);
+
+       // Description
+       Font = CreateFont(-13 , 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 
+                                               OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Arial");
+       SelectObject(hdc, Font);
+       Rect.top += 40;
+       Rect.bottom = DescriptionRect.bottom-2;
+       DrawTextW(hdc, DescriptionText, lstrlenW(DescriptionText), &Rect, DT_WORDBREAK|DT_NOPREFIX); // ToDo: Call TabbedTextOut to draw a nice table
+       DeleteObject(Font);
+
+}
+
+void showUninstaller() {
+       int Split_Vertical = 200;
+       RECT Rect;
+
+        GetClientRect(hwnd,&Rect);
+       ShowWindow(hUninstallButton,SW_SHOW);
+       MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2,Rect.bottom-Rect.top-45,140,35,TRUE);;
+}
+
+void hideUninstaller() {
+       int Split_Vertical = 200;
+       RECT Rect;
+
+        GetClientRect(hwnd,&Rect);
+       ShowWindow(hUninstallButton,SW_HIDE);
+       MoveWindow(hDownloadButton,(Split_Vertical+Rect.right-Rect.left)/2-70,Rect.bottom-Rect.top-45,140,35,TRUE);
+}
+
+void searchApp(const WCHAR* AppName, struct Category* Node) {
+       struct Application* CurrentApplication;
+       if (Node->Children)
+               searchApp(AppName, Node->Children);
+       if (Node->Next)
+               searchApp(AppName, Node->Next);
+       CurrentApplication = Node->Apps;
+       while((SelectedApplication == NULL) && (CurrentApplication != NULL)) {
+               if(wcscmp(CurrentApplication->Name,AppName)==0)
+                       SelectedApplication = CurrentApplication;
+               CurrentApplication = CurrentApplication->Next;
+       }
+}
+
+void ShowSelectedApplication() {
+       ApplicationText[0]=L'\0';
+       if(SelectedApplication->Version[0] != L'\0') {
+               StrCatW(ApplicationText, Strings[IDS_VERSION]);
+               StrCatW(ApplicationText, SelectedApplication->Version);
+               StrCatW(ApplicationText, L"\n");
+       }
+       if(SelectedApplication->Licence[0] != L'\0') {
+               StrCatW(ApplicationText, Strings[IDS_LICENCE]);
+               StrCatW(ApplicationText, SelectedApplication->Licence);
+               StrCatW(ApplicationText, L"\n");
+       }
+       if(SelectedApplication->Maintainer[0] != L'\0') {
+               StrCatW(ApplicationText, Strings[IDS_MAINTAINER]);
+               StrCatW(ApplicationText, SelectedApplication->Maintainer);
+               StrCatW(ApplicationText, L"\n");
+       }
+       if((SelectedApplication->Licence[0] != L'\0') || (SelectedApplication->Version[0] != L'\0') || (SelectedApplication->Maintainer[0] != L'\0'))
+               StrCatW(ApplicationText, L"\n");
+       StrCatW(ApplicationText, SelectedApplication->Description);
+       ShowMessage(SelectedApplication->Name, ApplicationText);
+}
+
+LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+       static RECT DescriptionRect;
+
+       switch (Message)
+       {
+               case WM_CREATE:
+               {
+                       WCHAR wAppName[0x100] = L"";
+                       if (strncmp(CmdLine,"add ",4)==0) {
+                               CmdLine = CmdLine+4;
+                               if(CmdLine[0]==L'\"') {
+                                       CmdLine++;
+                                       CmdLine[strlen(CmdLine)-1]=L'\0';
+                               }
+                               char* aAppName = addDML(CmdLine);
+                               MultiByteToWideChar(CP_UTF8, 0, aAppName, -1, wAppName, 0x100);
+                       } else if (strncmp(CmdLine,"show ",5)==0) {
+                               MultiByteToWideChar(CP_UTF8, 0, CmdLine+5, -1, wAppName, 0x100);
+                       }
+
+                       if(!SetupControls(hwnd))
+                               return -1;
+
+                       if(wAppName[0]!=L'\0')
+                               searchApp(wAppName, &Root);
+
+                       if(SelectedApplication == NULL) {
+                               ShowMessage(Strings[IDS_WELCOME_TITLE], Strings[IDS_WELCOME]);
+                       } else {
+                               ShowSelectedApplication();
+                               if(getUninstaller(SelectedApplication, NULL))
+                                       showUninstaller();
+                               else
+                                       hideUninstaller();
+                       }
+               } 
+               break;
+
+               case WM_PAINT:
+               {
+                       PAINTSTRUCT ps;
+                       HDC hdc = BeginPaint(hwnd, &ps);
+                       HDC BackbufferHdc = CreateCompatibleDC(hdc);
+                       HBITMAP BackbufferBmp = CreateCompatibleBitmap(hdc, ps.rcPaint.right, ps.rcPaint.bottom);
+                       SelectObject(BackbufferHdc, BackbufferBmp);
+                       
+                       FillRect(BackbufferHdc, &ps.rcPaint, CreateSolidBrush(RGB(235,235,235)));
+                       DrawBitmap(BackbufferHdc, 10, 12, hLogo);
+                       DrawDescription(BackbufferHdc, DescriptionRect);
+                       
+                       BitBlt(hdc, 0, 0, ps.rcPaint.right, ps.rcPaint.bottom, BackbufferHdc, 0, 0, SRCCOPY);
+                       DeleteObject(BackbufferBmp);
+                       DeleteDC(BackbufferHdc);
+                       EndPaint(hwnd, &ps);
+               }
+               break;
+
+               case WM_COMMAND:
+               {
+                       if(HIWORD(wParam) == BN_CLICKED)
+                       {
+                               if (lParam == (LPARAM)hDownloadButton)
+                               {
+                                       if(SelectedApplication) {
+                                               DWORD ThreadId;
+                                               CreateThread(NULL, 0, InstallThreadFunc, SelectedApplication, 0, &ThreadId);
+                                       } else
+                                               ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
+                               }
+                               else if (lParam == (LPARAM)hUninstallButton)
+                               {
+                                       if(SelectedApplication) {
+                                               DWORD ThreadId;
+                                               CreateThread(NULL, 0, UninstallThreadFunc, SelectedApplication, 0, &ThreadId);
+                                               hideUninstaller();
+                                       } else
+                                               ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
+                               }
+                               else if (lParam == (LPARAM)hUpdateButton)
+                               {
+                                       ShowMessage(Strings[IDS_UPDATE_TITLE], Strings[IDS_UPDATE]);
+                               }
+                               else if (lParam == (LPARAM)hHelpButton)
+                               {
+                                       ShowMessage(Strings[IDS_HELP_TITLE], Strings[IDS_HELP]);
+                               }
+                       }
+               }
+               break;
+
+               case WM_NOTIFY:
+               {
+                       LPNMHDR data = (LPNMHDR)lParam;
+                       if(data->code == TVN_SELCHANGED)
+                       {
+                               BOOL bShowUninstaller = FALSE;
+                               if(data->hwndFrom == hCategories) 
+                               {
+                                       struct Category* Category = (struct Category*) ((LPNMTREEVIEW)lParam)->itemNew.lParam;
+                                       CategoryChoosen (hApps, Category);
+                               }
+                               else if(data->hwndFrom == hApps) 
+                               {
+                                       SelectedApplication = (struct Application*) ((LPNMTREEVIEW)lParam)->itemNew.lParam;
+                                       if(SelectedApplication)
+                                       {
+                                               ShowSelectedApplication();
+                                               if(getUninstaller(SelectedApplication, NULL)) {
+                                                       bShowUninstaller = TRUE;
+                                               }
+                                       }
+                               }
+                               if (bShowUninstaller)
+                                       showUninstaller();
+                               else
+                                       hideUninstaller();
+                       }
+               }
+               break;
+
+               case WM_SIZING:
+               {
+                       LPRECT pRect = (LPRECT)lParam;
+                       if (pRect->right-pRect->left < 520)
+                               pRect->right = pRect->left + 520;
+
+                       if (pRect->bottom-pRect->top < 300)
+                               pRect->bottom = pRect->top + 300;
+               }
+               break;
+
+               case WM_SIZE:
+               {
+                       int Split_Hozizontal = (HIWORD(lParam)-(45+60))/2 + 60;
+                       int Split_Vertical = 200;
+
+                       ResizeControl(hCategories, 10, 60, Split_Vertical, HIWORD(lParam)-10);
+                       ResizeControl(hApps, Split_Vertical+5, 60, LOWORD(lParam)-10, Split_Hozizontal);
+                       RECT Rect = {Split_Vertical+5, Split_Hozizontal+5, LOWORD(lParam)-10, HIWORD(lParam)-50};
+                       DescriptionRect = Rect;
+
+                       MoveWindow(hHelpButton, LOWORD(lParam)-50, 10, 40, 40, TRUE);
+                       MoveWindow(hUpdateButton, LOWORD(lParam)-100, 10, 40, 40, TRUE);
+                       if(IsWindowVisible(hUninstallButton))
+                               MoveWindow(hDownloadButton, (Split_Vertical+LOWORD(lParam))/2, HIWORD(lParam)-45, 140, 35, TRUE);
+                       else
+                               MoveWindow(hDownloadButton, (Split_Vertical+LOWORD(lParam))/2-70, HIWORD(lParam)-45, 140, 35, TRUE);
+                       MoveWindow(hUninstallButton, (Split_Vertical+LOWORD(lParam))/2-140, HIWORD(lParam)-45, 140, 35, TRUE);
+               }
+               break;
+
+               case WM_DESTROY:
+               {
+                       DeleteObject(hLogo);    
+                       if(Root.Children)
+                               FreeTree(Root.Children);
+                       PostQuitMessage(0);
+                       return 0;
+               }
+               break;
+       }
+
+       return DefWindowProc (hwnd, Message, wParam, lParam);
+}
+
+INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
+                                       LPSTR lpCmdLine, INT nCmdShow)
+{
+       int i;
+       WNDCLASSEXW WndClass = {0};
+       MSG msg;
+
+       InitCommonControls();
+       CmdLine = lpCmdLine;
+       
+       // Load strings
+       for(i=0; i<STRING_COUNT; i++)
+               LoadStringW(hInstance, i, Strings[i], MAX_STRING_LENGHT); // if you know a better method please tell me. 
+
+       // Create the window
+       WndClass.cbSize                 = sizeof(WNDCLASSEX); 
+       WndClass.lpszClassName  = L"Downloader";
+       WndClass.lpfnWndProc    = WndProc;
+       WndClass.hInstance              = hInstance;
+       WndClass.style                  = CS_HREDRAW | CS_VREDRAW;
+       WndClass.hIcon                  = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
+       WndClass.hCursor                = LoadCursor(NULL, IDC_ARROW);
+
+       RegisterClassExW(&WndClass);
+
+       hwnd = CreateWindowW(L"Downloader", 
+                                               Strings[IDS_WINDOW_TITLE],
+                                               WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
+                                               CW_USEDEFAULT,  
+                                               CW_USEDEFAULT,   
+                                               600, 550, 
+                                               NULL, NULL,
+                                               hInstance, 
+                                               NULL);
+
+       // Show it
+       ShowWindow(hwnd, SW_SHOW);
+       UpdateWindow(hwnd);
+
+       // Message Loop
+       while(GetMessage(&msg,NULL,0,0))
+       {
+               TranslateMessage(&msg);
+               DispatchMessage(&msg);
+       }
+
+       return 0;
+}
diff --git a/rosapps/downloader/packagetree/internet/browser/browser.rbuild b/rosapps/downloader/packagetree/internet/browser/browser.rbuild
new file mode 100644 (file)
index 0000000..9ff0b07
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>\r
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">\r
+<installfile base="packagetree/internet/browser">firefox1509.dml</installfile>\r
+<installfile base="packagetree/internet/browser">firefox2001.dml</installfile>\r
diff --git a/rosapps/downloader/packagetree/internet/browser/firefox1509.dml b/rosapps/downloader/packagetree/internet/browser/firefox1509.dml
new file mode 100644 (file)
index 0000000..3f07745
--- /dev/null
@@ -0,0 +1,7 @@
+<application name="Firefox 1.5" target="internet\browser\firefox.1.5.0.9.dml">\r
+       <regname>Mozilla Firefox (1.5)</regname>\r
+       <licence>MPL/GPL/LGPL</licence>\r
+       <version>1.5.0.9</version>\r
+       <description>The most popular and one of the best free WebBrowsers out there.</description>\r
+       <location>http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/1.5.0.9/win32/en-US/Firefox%20Setup%201.5.0.9.exe</location>\r
+</application>
\ No newline at end of file
diff --git a/rosapps/downloader/packagetree/internet/browser/firefox2001.dml b/rosapps/downloader/packagetree/internet/browser/firefox2001.dml
new file mode 100644 (file)
index 0000000..4e1d9e4
--- /dev/null
@@ -0,0 +1,7 @@
+<application name="Firefox 2.0" target="internet\browser\firefox.2.0.0.1.dml">\r
+       <regname>Mozilla Firefox (2.0.0.1)</regname>\r
+       <licence>MPL/GPL/LGPL</licence>\r
+       <version>2.0.0.1</version>\r
+       <description>The most popular and one of the best free WebBrowsers out there.</description>\r
+       <location>http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/latest/win32/en-US/Firefox%20Setup%202.0.0.1.exe</location>\r
+</application>
\ No newline at end of file
diff --git a/rosapps/downloader/packagetree/internet/category.xml b/rosapps/downloader/packagetree/internet/category.xml
new file mode 100644 (file)
index 0000000..dcf2b42
--- /dev/null
@@ -0,0 +1,54 @@
+<category name="Internet &amp; Network" icon="1">\r
+       <import folder="internet\browser" />\r
+       <import folder="internet\email" />\r
+       <import folder="internet\ftp" />\r
+       <import folder="internet\chat" />\r
+       <import folder="internet\filesharing" />\r
+       <import folder="internet\remotecontrol" />\r
+       <import folder="internet\server" />\r
+       <import folder="internet\monitoring" />\r
+       <import folder="internet\security" />\r
+       <import folder="internet\streaming" />\r
+       <import folder="internet\other" />\r
+               <application name="Thunderbird">\r
+                       <regname>Mozilla Thunderbird (1.5)</regname>\r
+                       <licence>MPL/GPL/LGPL</licence>\r
+                       <version>1.5.0.9</version>\r
+                       <description>The most popular and one of the best free MailClients out there.</description>\r
+                       <location>http://ftp-mozilla.netscape.com/pub/mozilla.org/thunderbird/releases/latest/win32/en-US/Thunderbird%20Setup%201.5.0.9.exe</location>\r
+               </application>\r
+               <application name="SeaMonkey">\r
+                       <regname>SeaMonkey (1.0.7)</regname>\r
+                       <version>1.0.7</version>\r
+                       <description>Mozilla Suite is alive. This is the one and only Browser, Mail, Chat, Composer bundle you will ever need.</description>\r
+                       <location>http://ftp-mozilla.netscape.com/pub/mozilla.org/seamonkey/releases/1.0.7/seamonkey-1.0.7.en-US.win32.installer.exe</location>\r
+               </application>\r
+               <application name="Mozilla ActiveX Control">\r
+                       <regname>Mozilla ActiveX Control v1.7.12 (ReactOS special)</regname>\r
+                       <version>1.7.12</version>\r
+                       <description>Essential Component to get ReactOS Explorer's and other application's Internet Browsing feature running.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/reactos/MozillaControl1712-ReactOS.exe</location>\r
+               </application>\r
+               <application name="Off By One Browser">\r
+                       <regname>The Off By One Web Browser</regname>\r
+                       <description>The Off By One Browser is a very small and fast web browser with full HTML 3.2 support.</description>\r
+                       <location>http://offbyone.com/offbyone/images/OffByOneSetup.exe</location>\r
+               </application>\r
+               <application name="Samba TNG">\r
+                       <description>This tool allows you to access your Windows shared folders/printers with ReactOS.</description>\r
+                       <location>http://svn.reactos.org/packages/samba-tng.exe</location>\r
+               </application>\r
+               <application name="Miranda IM">\r
+                       <regname>Miranda IM</regname>\r
+                       <version>0.5.1</version>\r
+                       <description>Open source multiprotocol instant messaging application - May not work completely.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/miranda/miranda-im-v0.5.1-unicode.exe</location>\r
+               </application>\r
+               <application name="Putty">\r
+                       <regname>PuTTY version 0.59</regname>\r
+                       <licence>MIT</licence>\r
+                       <version>0.59</version>\r
+                       <description>A free SSH, Telnet, rlogin, and raw TCP client.</description>\r
+                       <location>http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.59-installer.exe</location>\r
+               </application>\r
+</category>
\ No newline at end of file
diff --git a/rosapps/downloader/packagetree/internet/internet.rbuild b/rosapps/downloader/packagetree/internet/internet.rbuild
new file mode 100644 (file)
index 0000000..7b7ab54
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>\r
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">\r
+<directory name="browser">\r
+       <xi:include href="browser/browser.rbuild" />\r
+</directory>\r
+<installfile base="packagetree/internet">category.xml</installfile>\r
diff --git a/rosapps/downloader/packagetree/packagetree.rbuild b/rosapps/downloader/packagetree/packagetree.rbuild
new file mode 100644 (file)
index 0000000..01d7036
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>\r
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">\r
+<directory name="internet">\r
+       <xi:include href="internet/internet.rbuild" />\r
+</directory>\r
+<directory name="script">\r
+       <xi:include href="script/script.rbuild" />\r
+</directory>\r
+<installfile base="packagetree">tree.xml</installfile>\r
diff --git a/rosapps/downloader/packagetree/script/default_install.xml b/rosapps/downloader/packagetree/script/default_install.xml
new file mode 100644 (file)
index 0000000..c26a300
--- /dev/null
@@ -0,0 +1,5 @@
+<script>\r
+       <download url="%location%" file="%TEMP%\%location_file%" />\r
+       <exec file="%TEMP%\%location_file%" />\r
+       <del file="%TEMP%\%location_file%" />\r
+</script>
\ No newline at end of file
diff --git a/rosapps/downloader/packagetree/script/default_uninstall.xml b/rosapps/downloader/packagetree/script/default_uninstall.xml
new file mode 100644 (file)
index 0000000..0f4c05c
--- /dev/null
@@ -0,0 +1 @@
+<exec file="%regname_uninstaller%" />\r
diff --git a/rosapps/downloader/packagetree/script/script.rbuild b/rosapps/downloader/packagetree/script/script.rbuild
new file mode 100644 (file)
index 0000000..9230d0f
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>\r
+<installfile base="packagetree/script">default_install.xml</installfile>\r
+<installfile base="packagetree/script">default_uninstall.xml</installfile>\r
diff --git a/rosapps/downloader/packagetree/tree.xml b/rosapps/downloader/packagetree/tree.xml
new file mode 100644 (file)
index 0000000..9ce014f
--- /dev/null
@@ -0,0 +1,142 @@
+<tree Version="1"> <!-- Application version this tree is made for -->\r
+       <import file="internet\category.xml" />\r
+       <category name="Office" icon="2">\r
+               <application name="Abiword">\r
+                       <regname>"AbiWord 2.4.1 (remove only)"</regname>\r
+                       <version>2.4.1</version>\r
+                       <description>Word processor.</description>\r
+                       <location>http://www.abiword.org/downloads/abiword/2.4.1/Windows/abiword-setup-2.4.1.exe</location>\r
+               </application>\r
+               <application name="OpenOffice">\r
+                       <regname>OpenOffice.org 2.1</regname>\r
+                       <version>2.1.0</version>\r
+                       <description>THE Open Source Office Suite.</description>\r
+                       <location>http://ftp.tu-chemnitz.de/pub/openoffice-extended//stable/2.1.0/OOo_2.1.0_Win32Intel_install_en-US.exe</location>\r
+               </application>\r
+       </category>\r
+       <category name="Graphics" icon="3">\r
+               <application name="IrfanView">\r
+                       <regname>IrfanView (remove only)</regname>\r
+                       <version>3.99</version>\r
+                       <description>Viewer for all kinds of graphics/audio files/video files.</description>\r
+                       <location>http://gd.tuwien.ac.at/graphics/irfanview/iview399.exe</location>\r
+               </application>\r
+               <application name="IrfanView Plugins">\r
+                       <version>3.99</version>\r
+                       <description>Additional Plugins for supporting more file types.</description>\r
+                       <location>http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_399.exe</location>\r
+               </application>\r
+               <application name="TuxPaint">\r
+                       <regname>Tux Paint 0.9.16</regname>\r
+                       <version>0.9.16</version>\r
+                       <description>An open source bitmap graphics editor geared towards young children.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/tuxpaint/tuxpaint-0.9.16-win32-installer.exe</location>\r
+               </application>\r
+       </category>\r
+       <category name="Multimedia" icon="4">\r
+       </category>\r
+       <category name="Development" icon="5">\r
+               <application name="ReactOS Build Environment">\r
+                       <regname>ReactOS Build Environment 0.3.4</regname>\r
+                       <version>0.3.4</version>\r
+                       <description>Allows you to build the ReactOS Source. For more instructions see ReactOS wiki.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/reactos/RosBE-0.3.4.exe</location>\r
+               </application>\r
+               <application name="MinGW">\r
+                       <regname>MinGW 5.1.3</regname>\r
+                       <version>5.1.3</version>\r
+                       <description>A Port of the GNU toolchain with GCC, GDB, GNU make, etc.</description>\r
+                       <location>http://puzzle.dl.sourceforge.net/sourceforge/mingw/MinGW-5.1.3.exe</location>\r
+               </application>\r
+               <application name="FreeBASIC">\r
+                       <regname>FreeBASIC 0.16b</regname>\r
+                       <version>0.16b</version>\r
+                       <description>Open Source Basic Compiler. The Basic syntax is compatible to QBASIC.</description>\r
+                       <location>http://switch.dl.sourceforge.net/sourceforge/fbc/FreeBASIC-v0.16b-win32.exe</location>\r
+               </application>\r
+       </category>\r
+       <category name="Games &amp; Fun" icon="6">\r
+               <application name="ScummVM">\r
+                       <regname>ScummVM 0.9.1</regname>\r
+                       <version>0.9.1</version>\r
+                       <description>SamNMax, Day of Tentacle, etc on ReactOS</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/scummvm/scummvm-0.9.1-win32.exe</location>\r
+               </application>\r
+               <application name="Tile World">\r
+                       <description>Nice Clone of Chip's Challenge originally made for the Atari Lynx. Includes free CCLP2 Graphics Pack, so you dont need the copyrighted Original.</description>\r
+                       <location>http://www.muppetlabs.com/~breadbox/pub/software/tworld/tworld-1.3.0-win32-CCLP2.exe</location>\r
+               </application>\r
+               <application name="OpenTTD">\r
+                       <regname>OpenTTD 0.5.0</regname>\r
+                       <version>0.5.0-RC5</version>\r
+                       <description>Open-source-clone of the "Transport Tycoon Deluxe" game-engine. You need a copy of Transport Tycoon.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/openttd/openttd-0.5.0-RC5-win32.exe</location>\r
+               </application>\r
+               <application name="LBreakout2">LBreakout2 2.4.1\r
+                       <regname>LBreakout2 2.4.1</regname>\r
+                       <version>2.4.1</version>\r
+                       <description>Breakout Clone using SDL libs.</description>\r
+                       <location>http://switch.dl.sourceforge.net/sourceforge/lgames/lbreakout2-2.4.1-win32.exe</location>\r
+               </application>\r
+               <application name="LGeneral">\r
+                       <regname>LGeneral 1.1</regname>\r
+                       <version>1.1</version>\r
+                       <description>Panzer General Clone using SDL libs.</description>\r
+                       <location>http://kent.dl.sourceforge.net/sourceforge/lgames/lgeneral-1.1-win32.exe</location>\r
+               </application>\r
+               <application name="LMarbles">\r
+                       <regname>LMarbles 1.0.6</regname>\r
+                       <version>1.0.6</version>\r
+                       <description>Atomix Clone using SDL libs.</description>\r
+                       <location>http://heanet.dl.sourceforge.net/sourceforge/lgames/lmarbles-1.0.6-win32.exe</location>\r
+               </application>\r
+       </category>\r
+       <category name="Tools" icon="7">\r
+               <application name="7-Zip">\r
+                       <regname>7-Zip 4.42</regname>\r
+                       <version>4.42</version>\r
+                       <description>Utility to create and open 7zip, zip, tar, rar and other archive files.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/sevenzip/7z442.exe</location>\r
+               </application>\r
+               <application name="uTorrent">\r
+                       <regname>uTorrent</regname>\r
+                       <version>1.6</version>\r
+                       <description>Small and fast Torrent Client.</description>\r
+                       <location>http://download.utorrent.com/1.6/uTorrent-1.6-install.exe</location>\r
+               </application>\r
+               <application name="Audio Grabber">\r
+                       <regname>Audiograbber 1.83 SE </regname>\r
+                       <version>1.83 SE</version>\r
+                       <description>A very good CD Ripper/Audio File Converter.</description>\r
+                       <location>http://www.audiograbber.de/files/342677432/agsetup183se.exe</location>\r
+               </application>\r
+       </category>\r
+       <category name="Others" icon="8">\r
+               <application name="Simple Direct Media Layer (SDL) Runtime">\r
+                       <regname>SDL Runtime</regname>\r
+                       <version>1.2.11</version>\r
+                       <description>Needed for many Open Source Games to run. You need 7-Zip or a similar Utility to extract it.</description>\r
+                       <location>http://ovh.dl.sourceforge.net/sourceforge/libsdl/SDL-1.2.11-win32.zip</location>\r
+                       <installscript>\r
+                               <load file="test.xml" />\r
+                               <unzip />\r
+                               <download url="%location%" file="%TEMP%\%location_file%" />\r
+                               <unzip file="%TEMP%\%location_file%" outdir="%SystemRoot%\System32" />\r
+                               <exec file="notepad %SystemRoot%\System32\README-SDL.txt" />\r
+                               <del file="%TEMP%\%location_file%" />\r
+                               <adduninstaller regname="%regname%" file="downloader.exe show %name%" />\r
+                       </installscript>\r
+                       <uninstallscript>\r
+                               <del file="%SystemRoot%\System32\SDL.dll" />\r
+                               <del file="%SystemRoot%\System32\README-SDL.txt" />\r
+                               <removeuninstaller regname="%regname%" />\r
+                               <message text="Uninstall complete." />\r
+                       </uninstallscript>\r
+               </application>\r
+               <application name="DOSBox">\r
+                       <version>0.65</version>\r
+                       <description>DOSBox is a DOS emulator.</description>\r
+                       <location>http://puzzle.dl.sourceforge.net/sourceforge/dosbox/DOSBox0.65-win32-installer.exe</location>\r
+               </application>\r
+       </category>\r
+</tree>\r
diff --git a/rosapps/downloader/resources.h b/rosapps/downloader/resources.h
new file mode 100644 (file)
index 0000000..875777f
--- /dev/null
@@ -0,0 +1,48 @@
+
+#define IDI_MAIN                       0x0
+#define IDB_UNDERLINE          0x100
+#define IDB_LOGO                       0x101
+#define IDB_HELP                       0x102
+#define IDB_UPDATE                     0x103
+#define IDB_DOWNLOAD           0x104
+#define IDB_UNINSTALL          0x105
+#define IDB_TREEVIEW_ICON_0    0x900
+#define IDB_TREEVIEW_ICON_1    0x901
+#define IDB_TREEVIEW_ICON_2    0x902
+#define IDB_TREEVIEW_ICON_3    0x903
+#define IDB_TREEVIEW_ICON_4    0x904
+#define IDB_TREEVIEW_ICON_5    0x905
+#define IDB_TREEVIEW_ICON_6    0x906
+#define IDB_TREEVIEW_ICON_7    0x907
+#define IDB_TREEVIEW_ICON_8    0x908
+#define IDB_TREEVIEW_ICON_9    0x909
+#define IDB_TREEVIEW_ICON_10   0x910
+#define IDD_DOWNLOAD           0x100
+#define IDC_PROGRESS           0x1000
+#define IDC_STATUS                     0x1001
+#define IDC_REMOVE                     0x1002
+
+#define IDS_WINDOW_TITLE       0
+#define IDS_WELCOME_TITLE      1
+#define IDS_WELCOME            2
+#define IDS_NO_APP_TITLE       3
+#define IDS_NO_APP                     4
+#define IDS_UPDATE_TITLE       5
+#define IDS_UPDATE                     6
+#define IDS_HELP_TITLE                 7
+#define IDS_HELP                       8
+#define IDS_NO_APPS                    9
+#define IDS_CHOOSE_APP         10
+#define IDS_CHOOSE_SUB         11
+#define IDS_CHOOSE_CATEGORY    12
+#define IDS_CHOOSE_BOTH                13
+#define IDS_XMLERROR_1         14
+#define IDS_XMLERROR_2         15
+#define IDS_DOWNLOAD_ERROR     16
+#define IDS_UNZIP_ERROR                17
+#define IDS_VERSION            18
+#define IDS_LICENCE            19
+#define IDS_MAINTAINER         20
+
+#define STRING_COUNT           21
+#define        MAX_STRING_LENGHT       0x100
diff --git a/rosapps/downloader/resources/0.bmp b/rosapps/downloader/resources/0.bmp
new file mode 100644 (file)
index 0000000..e31ccef
Binary files /dev/null and b/rosapps/downloader/resources/0.bmp differ
diff --git a/rosapps/downloader/resources/1.bmp b/rosapps/downloader/resources/1.bmp
new file mode 100644 (file)
index 0000000..b5d584b
Binary files /dev/null and b/rosapps/downloader/resources/1.bmp differ
diff --git a/rosapps/downloader/resources/10.bmp b/rosapps/downloader/resources/10.bmp
new file mode 100644 (file)
index 0000000..d0825e8
Binary files /dev/null and b/rosapps/downloader/resources/10.bmp differ
diff --git a/rosapps/downloader/resources/2.bmp b/rosapps/downloader/resources/2.bmp
new file mode 100644 (file)
index 0000000..e59ab5e
Binary files /dev/null and b/rosapps/downloader/resources/2.bmp differ
diff --git a/rosapps/downloader/resources/3.bmp b/rosapps/downloader/resources/3.bmp
new file mode 100644 (file)
index 0000000..860744a
Binary files /dev/null and b/rosapps/downloader/resources/3.bmp differ
diff --git a/rosapps/downloader/resources/4.bmp b/rosapps/downloader/resources/4.bmp
new file mode 100644 (file)
index 0000000..5df366d
Binary files /dev/null and b/rosapps/downloader/resources/4.bmp differ
diff --git a/rosapps/downloader/resources/5.bmp b/rosapps/downloader/resources/5.bmp
new file mode 100644 (file)
index 0000000..fd5099e
Binary files /dev/null and b/rosapps/downloader/resources/5.bmp differ
diff --git a/rosapps/downloader/resources/6.bmp b/rosapps/downloader/resources/6.bmp
new file mode 100644 (file)
index 0000000..280fc7e
Binary files /dev/null and b/rosapps/downloader/resources/6.bmp differ
diff --git a/rosapps/downloader/resources/7.bmp b/rosapps/downloader/resources/7.bmp
new file mode 100644 (file)
index 0000000..1c8007b
Binary files /dev/null and b/rosapps/downloader/resources/7.bmp differ
diff --git a/rosapps/downloader/resources/8.bmp b/rosapps/downloader/resources/8.bmp
new file mode 100644 (file)
index 0000000..e300642
Binary files /dev/null and b/rosapps/downloader/resources/8.bmp differ
diff --git a/rosapps/downloader/resources/9.bmp b/rosapps/downloader/resources/9.bmp
new file mode 100644 (file)
index 0000000..1e28d93
Binary files /dev/null and b/rosapps/downloader/resources/9.bmp differ
diff --git a/rosapps/downloader/resources/download.bmp b/rosapps/downloader/resources/download.bmp
new file mode 100644 (file)
index 0000000..09ff0a3
Binary files /dev/null and b/rosapps/downloader/resources/download.bmp differ
diff --git a/rosapps/downloader/resources/help.bmp b/rosapps/downloader/resources/help.bmp
new file mode 100644 (file)
index 0000000..59a5bd5
Binary files /dev/null and b/rosapps/downloader/resources/help.bmp differ
diff --git a/rosapps/downloader/resources/logo.bmp b/rosapps/downloader/resources/logo.bmp
new file mode 100644 (file)
index 0000000..4f10e49
Binary files /dev/null and b/rosapps/downloader/resources/logo.bmp differ
diff --git a/rosapps/downloader/resources/main.ico b/rosapps/downloader/resources/main.ico
new file mode 100644 (file)
index 0000000..86c43d7
Binary files /dev/null and b/rosapps/downloader/resources/main.ico differ
diff --git a/rosapps/downloader/resources/underline.bmp b/rosapps/downloader/resources/underline.bmp
new file mode 100644 (file)
index 0000000..7facc72
Binary files /dev/null and b/rosapps/downloader/resources/underline.bmp differ
diff --git a/rosapps/downloader/resources/uninstall.bmp b/rosapps/downloader/resources/uninstall.bmp
new file mode 100644 (file)
index 0000000..077cac9
Binary files /dev/null and b/rosapps/downloader/resources/uninstall.bmp differ
diff --git a/rosapps/downloader/resources/update.bmp b/rosapps/downloader/resources/update.bmp
new file mode 100644 (file)
index 0000000..d21aeec
Binary files /dev/null and b/rosapps/downloader/resources/update.bmp differ
diff --git a/rosapps/downloader/rsrc.rc b/rosapps/downloader/rsrc.rc
new file mode 100644 (file)
index 0000000..8c38be5
--- /dev/null
@@ -0,0 +1,27 @@
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+IDI_MAIN               ICON DISCARDABLE        "resources/main.ico"
+IDB_LOGO               BITMAP DISCARDABLE      "resources/logo.bmp"
+IDB_HELP               BITMAP DISCARDABLE      "resources/help.bmp"
+IDB_UPDATE             BITMAP DISCARDABLE      "resources/update.bmp"
+IDB_DOWNLOAD           BITMAP DISCARDABLE      "resources/download.bmp"
+IDB_UNINSTALL          BITMAP DISCARDABLE      "resources/uninstall.bmp"
+IDB_UNDERLINE          BITMAP DISCARDABLE      "resources/underline.bmp"
+IDB_TREEVIEW_ICON_0    BITMAP DISCARDABLE      "resources/0.bmp"
+IDB_TREEVIEW_ICON_1    BITMAP DISCARDABLE      "resources/1.bmp"
+IDB_TREEVIEW_ICON_2    BITMAP DISCARDABLE      "resources/2.bmp"
+IDB_TREEVIEW_ICON_3    BITMAP DISCARDABLE      "resources/3.bmp"
+IDB_TREEVIEW_ICON_4    BITMAP DISCARDABLE      "resources/4.bmp"
+IDB_TREEVIEW_ICON_5    BITMAP DISCARDABLE      "resources/5.bmp"
+IDB_TREEVIEW_ICON_6    BITMAP DISCARDABLE      "resources/6.bmp"
+IDB_TREEVIEW_ICON_7    BITMAP DISCARDABLE      "resources/7.bmp"
+IDB_TREEVIEW_ICON_8    BITMAP DISCARDABLE      "resources/8.bmp"
+IDB_TREEVIEW_ICON_9    BITMAP DISCARDABLE      "resources/9.bmp"
+IDB_TREEVIEW_ICON_10   BITMAP DISCARDABLE      "resources/10.bmp"
+
+
+#include "translations/de.rc"
+#include "translations/en.rc"
+#include "translations/fr.rc"
+#include "translations/id.rc"
+#include "translations/it.rc"
diff --git a/rosapps/downloader/script.c b/rosapps/downloader/script.c
new file mode 100644 (file)
index 0000000..c7ebb08
--- /dev/null
@@ -0,0 +1,246 @@
+/* PROJECT:         ReactOS Downloader
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base/applications/downloader/script.c
+ * PURPOSE:         Run (un/)installscript
+ * PROGRAMMERS:     Lester Kortenhoeven
+ */
+
+#include <windows.h>
+
+#include "resources.h"
+#include "structures.h"
+
+extern BOOL getUninstaller(struct Application*, WCHAR*);
+extern INT_PTR CALLBACK DownloadProc (HWND, UINT, WPARAM, LPARAM);
+extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
+
+static void DownloadScriptFunc (WCHAR* URL, WCHAR* File) {
+       struct lParamDownload* lParam;
+       lParam = malloc(sizeof(struct lParamDownload));
+       lParam->URL = URL;
+       lParam->File = File;
+       DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_DOWNLOAD), 0, DownloadProc, (LPARAM)lParam);
+       free(lParam);
+}
+
+static void ExecScriptFunc(WCHAR* Arg) {
+       STARTUPINFOW si;
+       PROCESS_INFORMATION pi;
+
+       memset(&si, 0, sizeof(si));
+       si.cb=sizeof(si);
+       CreateProcessW(NULL,Arg,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
+       CloseHandle(pi.hThread);
+       WaitForSingleObject(pi.hProcess, INFINITE);
+       CloseHandle(pi.hProcess);
+}
+
+
+static void DelScriptFunc(WCHAR* Arg) {
+       DeleteFileW(Arg);
+}
+
+static BOOL UnzipScriptFunc(WCHAR* File, WCHAR* Outdir) {
+       HKEY hKey;
+       DWORD Type = 0;
+       WCHAR ExecStr[0x100];
+       DWORD currentlengt = 0x100;
+       if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\7-Zip",0,KEY_READ,&hKey) == ERROR_SUCCESS) {
+               if (RegQueryValueExW(hKey,L"Path",0,&Type,(LPBYTE)ExecStr,&currentlengt) == ERROR_SUCCESS) {
+                       if (File[0] != L'\0') {
+                               wcsncat(ExecStr,L"\\7z.exe x ",0x100-currentlengt);
+                               currentlengt = lstrlenW(ExecStr);
+                               wcsncat(ExecStr,File,0x100-currentlengt);
+                               currentlengt = lstrlenW(ExecStr);
+                               wcsncat(ExecStr,L" -o",0x100-currentlengt);
+                               currentlengt = lstrlenW(ExecStr);
+                               wcsncat(ExecStr,Outdir,0x100-currentlengt);
+                               ExecScriptFunc(ExecStr);
+                               RegCloseKey(hKey);
+                       }
+                       return TRUE;
+               }
+               RegCloseKey(hKey);
+       }
+       MessageBoxW(0,Strings[IDS_UNZIP_ERROR],0,0);
+       return FALSE;
+}
+
+static void AddUninstallerScriptFunc(WCHAR* RegName, WCHAR* File) {
+       HKEY hKey1;
+       HKEY hKey2;
+       LPDWORD dispos = NULL;
+       if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_WRITE,&hKey1) == ERROR_SUCCESS)
+               if (RegCreateKeyEx(hKey1,RegName,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey2,dispos) == ERROR_SUCCESS) {
+                       RegSetValueExW(hKey2,L"DisplayName",0,REG_SZ,(BYTE*)RegName,(lstrlen(RegName)+1)*sizeof(WCHAR));
+                       RegSetValueExW(hKey2,L"UninstallString",0,REG_SZ,(BYTE*)File,(lstrlen(File)+1)*sizeof(WCHAR));
+               }
+       RegCloseKey(hKey2);
+       RegCloseKey(hKey1);
+}
+
+static void RemoveUninstallerScriptFunc(WCHAR* RegName) {
+       HKEY hKey1;
+       HKEY hKey2;
+       if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_WRITE,&hKey1) == ERROR_SUCCESS) {
+               if (RegOpenKeyExW(hKey1,RegName,0,KEY_WRITE,&hKey2) == ERROR_SUCCESS) {
+                       RegDeleteValueW(hKey2,L"DisplayName");
+                       RegDeleteValueW(hKey2,L"UninstallString");
+                       RegCloseKey(hKey2);
+               }
+               // RegDeleteKeyW(hKey1,RegName);
+       }
+       RegCloseKey(hKey1);
+}
+
+static void MessageScriptFunc(WCHAR* Text) {
+       MessageBoxW(0,Text,Strings[IDS_WINDOW_TITLE],0);
+}
+
+extern void LoadScriptFunc(WCHAR*, struct ScriptElement*);
+
+static void RunScript(struct Application* App, struct ScriptElement* Script) {
+       BOOL bRun = TRUE;
+       struct ScriptElement* p = Script;
+       INT SizeB = 0x100;
+       INT SizeA = sizeof(p->Arg)/sizeof(*(p->Arg));
+       INT i;
+       int currentlengt = 0;
+       WCHAR ArgBuffer[SizeA][SizeB];
+       WCHAR BufferA[SizeB];
+       WCHAR BufferB[SizeB];
+       WCHAR BufferC[SizeB];
+       WCHAR* Pos1;
+       WCHAR* Pos2;
+       WCHAR* Pos3 = NULL;
+       BOOL bNext;
+       while(bRun && (p != NULL)) {
+
+               for(i=0; i<SizeA; i++) {
+                       bNext = TRUE;
+                       wcscpy(BufferA, p->Arg[i]);
+                       Pos1 = BufferA;
+                       Pos2 = wcschr(Pos1, L'%');
+                       if(!Pos2) {
+                               wcscpy(ArgBuffer[i], Pos1);
+                               break;
+                       }
+                       Pos2[0] = L'\0';
+                       wcscpy(BufferB, Pos1);
+                       Pos1 = Pos2 + 1;
+                       Pos2 = wcschr(Pos1, L'%');
+                       while (Pos2) {
+                               Pos2[0] = L'\0';
+                               if(bNext) {
+                                       if (wcscmp(Pos1, L"name") == 0) {
+                                               Pos3 = App->Name;
+                                       } else if (wcscmp(Pos1, L"regname") == 0) {
+                                               Pos3 = App->RegName;
+                                       } else if (wcscmp(Pos1, L"version") == 0) {
+                                               Pos3 = App->Version;
+                                       } else if (wcscmp(Pos1, L"maintainer") == 0) {
+                                               Pos3 = App->Maintainer;
+                                       } else if (wcscmp(Pos1, L"licence") == 0) {
+                                               Pos3 = App->Licence;
+                                       } else if (wcscmp(Pos1, L"description") == 0) {
+                                               Pos3 = App->Description;
+                                       } else if (wcscmp(Pos1, L"location") == 0) {
+                                               Pos3 = App->Location;
+                                       } else if (wcscmp(Pos1, L"regname_uninstaller") == 0) {
+                                               if (!getUninstaller(App, BufferC)) {
+                                                       BufferC[0] = '\0';
+                                               }
+                                               Pos3 = BufferC;
+                                       } else if (wcscmp(Pos1, L"location_file") == 0) {
+                                               Pos3 = wcsrchr(App->Location, L'/');
+                                               if(Pos3 == NULL) {
+                                                       BufferC[0] = '\0';
+                                                       Pos3 = BufferC;
+                                               } else {
+                                                       Pos3++;
+                                               }
+                                       } else {
+                                               Pos3 = _wgetenv(Pos1);
+                                       }
+                                       bNext = !(Pos3);
+                                       if (bNext) {
+                                               Pos3 = Pos1;
+                                               currentlengt = lstrlenW(BufferB);
+                                               wcsncat(BufferB, L"%", SizeB-currentlengt);
+                                       }
+                               } else {
+                                       Pos3 = Pos1;
+                                       bNext = TRUE;
+                               }
+                               currentlengt = lstrlenW(BufferB);
+                               wcsncat(BufferB, Pos3, SizeB-currentlengt);
+                               Pos1 = Pos2 + 1;
+                               Pos2 = wcschr(Pos1, L'%');
+                       }
+                       if (bNext) {
+                               wcsncat(BufferB, L"%", SizeB-currentlengt);
+                       }
+                       currentlengt = lstrlenW(BufferB);
+                       wcsncat(BufferB, Pos1, SizeB-currentlengt);
+                       wcscpy(ArgBuffer[i], BufferB);
+               }
+
+               if (wcscmp(p->Func, L"download") == 0) {
+                       DownloadScriptFunc(ArgBuffer[0], ArgBuffer[1]);
+               } else if (wcscmp(p->Func, L"exec") == 0) {
+                       ExecScriptFunc(ArgBuffer[0]);
+               } else if (wcscmp(p->Func, L"del") == 0) {
+                       DelScriptFunc(ArgBuffer[0]);
+               } else if (wcscmp(p->Func, L"unzip") == 0) {
+                       bRun = UnzipScriptFunc(ArgBuffer[0], ArgBuffer[1]);
+               } else if (wcscmp(p->Func, L"adduninstaller") == 0) {
+                       AddUninstallerScriptFunc(ArgBuffer[0], ArgBuffer[1]);
+               } else if (wcscmp(p->Func, L"removeuninstaller") == 0) {
+                       RemoveUninstallerScriptFunc(ArgBuffer[0]);
+               } else if (wcscmp(p->Func, L"message") == 0) {
+                       MessageScriptFunc(ArgBuffer[0]);
+               } else if (wcscmp(p->Func, L"load") == 0) {
+                       LoadScriptFunc(ArgBuffer[0],p);
+               }
+               p = p->Next;
+       }
+}
+
+DWORD WINAPI InstallThreadFunc(LPVOID Context) {
+       struct Application* App = (struct Application*)Context;
+
+       if(App->InstallScript == NULL){
+               /* Default UninstallScript */
+               struct ScriptElement* Current;
+               Current = malloc(sizeof(struct ScriptElement));
+               App->InstallScript = Current;
+               memset(Current, 0, sizeof(struct ScriptElement));
+               wcscpy(Current->Func, L"load");
+               wcscpy(Current->Arg[0], L"script/default.install.xml");
+       }
+
+       RunScript(App, App->InstallScript);
+
+       return 0;
+}
+
+
+
+DWORD WINAPI UninstallThreadFunc(LPVOID Context){
+       struct Application* App = (struct Application*)Context;
+
+       if(App->UninstallScript == NULL){
+               /* Default UninstallScript */
+               struct ScriptElement* Current;
+               Current = malloc(sizeof(struct ScriptElement));
+               App->UninstallScript = Current;
+               memset(Current, 0, sizeof(struct ScriptElement));
+               wcscpy(Current->Func, L"load");
+               wcscpy(Current->Arg[0], L"script/default.uninstall.xml");
+       }
+
+       RunScript(App, App->UninstallScript);
+
+       return 0;
+}
+
diff --git a/rosapps/downloader/structures.h b/rosapps/downloader/structures.h
new file mode 100644 (file)
index 0000000..fc1fee1
--- /dev/null
@@ -0,0 +1,40 @@
+
+struct Application
+{
+       WCHAR Name[0x100];
+       WCHAR RegName[0x100];
+       WCHAR Version[0x100];
+       WCHAR Maintainer[0x100];
+       WCHAR Licence[0x100];
+       WCHAR Description[0x400];
+       WCHAR Location[0x100];
+       struct Application* Next;
+       struct ScriptElement* InstallScript;
+       struct ScriptElement* UninstallScript;
+};
+
+struct Category
+{
+       WCHAR Name[0x100];
+       //WCHAR Description[0x100];
+       int Icon;
+       HANDLE TreeviewItem;
+       struct Application* Apps;
+       struct Category* Next;
+       struct Category* Children;
+       struct Category* Parent;
+};
+
+struct ScriptElement
+{
+       WCHAR Func[0x100];
+       WCHAR Arg[2][0x100];
+       struct ScriptElement* Next;
+};
+
+struct lParamDownload
+{
+       HWND Dlg;
+       WCHAR* URL;
+       WCHAR* File;
+};
diff --git a/rosapps/downloader/translations/de.rc b/rosapps/downloader/translations/de.rc
new file mode 100644 (file)
index 0000000..497325a
--- /dev/null
@@ -0,0 +1,36 @@
+LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
+
+IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76
+STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Download..."
+FONT 8, "MS Shell Dlg"
+{
+  CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
+  LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
+  PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
+}
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+  IDS_WINDOW_TITLE             "Download ! - ReactOS Downloader"
+  IDS_WELCOME_TITLE            "Willkommen im ReactOS Downloader"
+  IDS_WELCOME                  "Bitte wählen Sie links eine Kategorie. Dies ist Version 1.0."
+  IDS_NO_APP_TITLE             "Keine Anwendung ausgewählt"
+  IDS_NO_APP                   "Bitte wählen Sie eine Anwendung, bevor Sie die Download-Schaltfläche betätigen. Wenn Sie Hilfe benötigen, drücken Sie die Hilfe-Schaltfläche in der oberen rechten Ecke."
+  IDS_UPDATE_TITLE             "Update"
+  IDS_UPDATE                   "Diese Funktion wurde noch nicht implementiert."
+  IDS_HELP_TITLE               "Hilfe"
+  IDS_HELP                     "Wählen Sie links eine Kategorie, wählen Sie eine Anwendung und drücken Sie die Download-Schaltfläche. Um die Anwendungsinformationen zu aktualisieren, drücken Sie die Schaltfläche neben der Hilfe-Schaltfläche."
+  IDS_NO_APPS                  "In dieser Kategorie sind bisher noch keine Anwendungen. Sie können helfen, indem Sie Anwendungen hinzufügen."
+  IDS_CHOOSE_APP               "Bitte wählen Sie eine Anwendung."
+  IDS_CHOOSE_SUB               "Bitte wählen Sie eine Unterkategorie."
+  IDS_CHOOSE_CATEGORY          "Bitte wählen Sie eine Kategorie."
+  IDS_CHOOSE_BOTH              "Bitte wählen Sie eine Unterkategorie oder eine Anwendung."
+  IDS_XMLERROR_1               "XML Datei nicht gefunden!"
+  IDS_XMLERROR_2               "XML Datei kann nicht verarbeitet werden!"
+  IDS_DOWNLOAD_ERROR           "Die Datei konnte nicht runtergeladen werden.\nBitte prüfen sie, ob eine Verbindung zum Internet besteht."
+  IDS_UNZIP_ERROR              "7-Zip nicht gefunden.\nBitte installieren Sie 7-Zip."
+  IDS_VERSION                  "Version: "
+  IDS_LICENCE                  "Lizenz: "
+  IDS_MAINTAINER               "Maintainer: "
+END
diff --git a/rosapps/downloader/translations/en.rc b/rosapps/downloader/translations/en.rc
new file mode 100644 (file)
index 0000000..5921e96
--- /dev/null
@@ -0,0 +1,36 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76
+STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Download..."
+FONT 8, "MS Shell Dlg"
+{
+  CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
+  LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
+  PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
+}
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+  IDS_WINDOW_TITLE             "Download ! - ReactOS Downloader"
+  IDS_WELCOME_TITLE            "Welcome to the ReactOS Downloader"
+  IDS_WELCOME                  "Please choose a category on the left. This is version 1.0."
+  IDS_NO_APP_TITLE             "No application selected"
+  IDS_NO_APP                   "Please select a Application before you click the download button, if you need assistance please click on the question mark button on the top right corner."
+  IDS_UPDATE_TITLE             "Update"
+  IDS_UPDATE                   "Sorry this feature is not implemented yet."
+  IDS_HELP_TITLE               "Help"
+  IDS_HELP                     "Choose a category on the left, then choose a application and click the download button. To update the application information click the button next to the help button."
+  IDS_NO_APPS                  "Sorry, there no applications in this category yet. You can help and add more applications."
+  IDS_CHOOSE_APP               "Please choose an application."
+  IDS_CHOOSE_SUB               "Please choose a subcategory."
+  IDS_CHOOSE_CATEGORY          "Please choose a category."
+  IDS_CHOOSE_BOTH              "Please choose a subcategory or an application."
+  IDS_XMLERROR_1               "Could not find the xml file !"
+  IDS_XMLERROR_2               "Could not parse the xml file !"
+  IDS_DOWNLOAD_ERROR           "Unable to download the file.\nPlease check you internet connection."
+  IDS_UNZIP_ERROR              "7-Zip not found.\nPlease install 7-Zip"
+  IDS_VERSION                  "Version: "
+  IDS_LICENCE                  "Licence: "
+  IDS_MAINTAINER               "Maintainer: "
+END
diff --git a/rosapps/downloader/translations/fr.rc b/rosapps/downloader/translations/fr.rc
new file mode 100644 (file)
index 0000000..4efedf6
--- /dev/null
@@ -0,0 +1,36 @@
+LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+
+IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76
+STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Téléchargement..."
+FONT 8, "MS Shell Dlg"
+{
+  CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
+  LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
+  PUSHBUTTON "Annuler", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
+}
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+  IDS_WINDOW_TITLE             "Télécharger ! - Téléchargeur de ReactOS"
+  IDS_WELCOME_TITLE            "Bienvenue dans le Téléchargeur de ReactOS"
+  IDS_WELCOME                  "Veuillez choisir une catégorie sur la droite. C'est la version 1.0."
+  IDS_NO_APP_TITLE             "Aucune application selectionnée"
+  IDS_NO_APP                   "Veuillez sélectionner une application avant de cliquer sur le bouton Télécharger, si vous avez besoin d'aide, veuillez cliquer sur le point d'interrogation dans le coin supérieur droit."
+  IDS_UPDATE_TITLE             "Mise à jour"
+  IDS_UPDATE                   "Désolé, cette fonctionnalité n'est pas encore implémentée."
+  IDS_HELP_TITLE               "Aide"
+  IDS_HELP                     "Choisissez une catégorie sur la droite, puis choisissez une application et cliquez sur le bouton Télécharger. Pour mettre à jour les informations sur l'application, cliquez sur le bouton à côté du bouton d'aide."
+  IDS_NO_APPS                  "Désolé, il n'y a pas encore d'application dans cette catégorie. Vous pouvez contribuer et ajouter plus d'applications."
+  IDS_CHOOSE_APP               "Veuillez choisir une application."
+  IDS_CHOOSE_SUB               "Veuillez choisir une sous-catégorie."
+  IDS_CHOOSE_CATEGORY          "Veuillez choisir une catégorie."
+  IDS_CHOOSE_BOTH              "Veuillez choisir une sous-catégorie ou une application."
+  IDS_XMLERROR_1               "Impossible de trouver le fichier xml !"
+  IDS_XMLERROR_2               "Impossible d'analyser le fichier xml !"
+  IDS_DOWNLOAD_ERROR           "Impossible de télécharger le fichier.\nVeuillez vérifier votre connexion Internet."
+  IDS_UNZIP_ERROR              "7-Zip not found.\nPlease install 7-Zip"
+  IDS_VERSION                  "Version: "
+  IDS_LICENCE                  "Licence: "
+  IDS_MAINTAINER               "Maintainer: "
+END
diff --git a/rosapps/downloader/translations/id.rc b/rosapps/downloader/translations/id.rc
new file mode 100644 (file)
index 0000000..89d642d
--- /dev/null
@@ -0,0 +1,36 @@
+LANGUAGE LANG_INDONESIAN, SUBLANG_DEFAULT\r
+\r
+IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76\r
+STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU\r
+CAPTION "Download..."\r
+FONT 8, "MS Shell Dlg"\r
+{\r
+  CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12\r
+  LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER\r
+  PUSHBUTTON "Batal", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP\r
+}\r
+\r
+STRINGTABLE DISCARDABLE \r
+BEGIN\r
+  IDS_WINDOW_TITLE             "Download ! - ReactOS Downloader"\r
+  IDS_WELCOME_TITLE            "Selamat datang di ReactOS Downloader"\r
+  IDS_WELCOME                  "Silahkan pilih kategori di sebelah kanan. Ini versi 1.0."\r
+  IDS_NO_APP_TITLE             "Tidak ada aplikasi yang dipilih"\r
+  IDS_NO_APP                   "Silahkan pilih Aplikasi sebelum anda mengklik tombol download, jika anda membutuhkan asistensi silahkan klik pada tombol di sudut kanan atas."\r
+  IDS_UPDATE_TITLE             "Mutakhirkan"\r
+  IDS_UPDATE                   "Maaf fitur ini belum diimplementasikan."\r
+  IDS_HELP_TITLE               "Bantuan"\r
+  IDS_HELP                     "Pilih kategori di sisi kiri, lalu pilih aplikasi dan klik tombol download. Untuk memutakhirkan informasi aplikasi klik tombol disebelah tombol bantuan."\r
+  IDS_NO_APPS                  "Maaf, belum ada aplikasi dalam kategori ini. Anda dapat membantu dan menambahkan aplikasi lebih banyak."\r
+  IDS_CHOOSE_APP               "Silahkan pilih aplikasi."\r
+  IDS_CHOOSE_SUB               "Silahkan pilih subkategori."\r
+  IDS_CHOOSE_CATEGORY          "Silahkan pilih kategori."\r
+  IDS_CHOOSE_BOTH              "Silahkan pilih subkategori atau aplikasi."\r
+  IDS_XMLERROR_1               "Tidak dapat menemukan file xml !"\r
+  IDS_XMLERROR_2               "Tidak dapat mengurai file xml !"\r
+  IDS_DOWNLOAD_ERROR           "Tidak bisa mendownload file.\nSilahkan periksa koneksi internet anda."\r
+  IDS_UNZIP_ERROR              "7-Zip not found.\nPlease install 7-Zip"\r
+  IDS_VERSION                  "Versi: "\r
+  IDS_LICENCE                  "Lisensi: "\r
+  IDS_MAINTAINER               "Pemelihara: "\r
+END\r
diff --git a/rosapps/downloader/translations/it.rc b/rosapps/downloader/translations/it.rc
new file mode 100644 (file)
index 0000000..ade0ff4
--- /dev/null
@@ -0,0 +1,36 @@
+LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
+
+IDD_DOWNLOAD DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 220, 76
+STYLE DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Download..."
+FONT 8, "MS Shell Dlg"
+{
+  CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER|PBS_SMOOTH,10,10,200,12
+  LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
+  PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
+}
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+  IDS_WINDOW_TITLE             "Download ! - ReactOS Downloader"
+  IDS_WELCOME_TITLE            "Benvenuto al ReactOS Downloader"
+  IDS_WELCOME                  "Scegli una categoria a destra. Questa è la versione 1.0."
+  IDS_NO_APP_TITLE             "Nessuna applicazione selezionata"
+  IDS_NO_APP                   "Scegli una Applicazione prima di premere il bottone di download, se serve assistenza clicca sul punto di domanda nell'angolo in alto a destra."
+  IDS_UPDATE_TITLE             "Aggiona"
+  IDS_UPDATE                   "Funzione non ancora implementata."
+  IDS_HELP_TITLE               "Aiuto"
+  IDS_HELP                     "Scegli una categoria a destra, poi scegli una applicazione e clicca il bottone download. Per aggiornare le informazioni sulla applicazione clicca il bottone accanto a quello di aiuto."
+  IDS_NO_APPS                  "Non ci sono ancora applicazioni in questa categoria. Puoi aiutare aggiungendone altre."
+  IDS_CHOOSE_APP               "Scegli una applicazione."
+  IDS_CHOOSE_SUB               "Scegli una sottocategoria."
+  IDS_CHOOSE_CATEGORY          "Scegli una categoria."
+  IDS_CHOOSE_BOTH              "Scegli una sottocategoria o una applicazione."
+  IDS_XMLERROR_1               "File xml non trovato !"
+  IDS_XMLERROR_2               "Impossibile trattare il contenuto del file xml !"
+  IDS_DOWNLOAD_ERROR           "Download del file impossibile.\nVerifica la connessione a Internet."
+  IDS_UNZIP_ERROR              "7-Zip not found.\nPlease install 7-Zip"
+  IDS_VERSION                  "Version: "
+  IDS_LICENCE                  "Licence: "
+  IDS_MAINTAINER               "Maintainer: "
+END
diff --git a/rosapps/downloader/xml.c b/rosapps/downloader/xml.c
new file mode 100644 (file)
index 0000000..b56ff71
--- /dev/null
@@ -0,0 +1,525 @@
+/* PROJECT:         ReactOS Downloader
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base\applications\downloader\xml.c
+ * PURPOSE:         Parsing of application information xml files
+ * PROGRAMMERS:     Maarten Bosma, Lester Kortenhoeven
+ */
+
+#include <libs/expat/expat.h>
+#include <string.h>
+#include <stdio.h>
+#include <windows.h>
+#include <shlwapi.h>
+#include <io.h>
+#include "structures.h"
+#include "resources.h"
+
+BOOL TagOpen;
+BOOL InstallScriptOpen;
+BOOL UninstallScriptOpen;
+struct Category* Current;
+struct Application* CurrentApplication;
+struct ScriptElement* CurrentScript;
+char DML_Name[0x100];
+char DML_Target[0x100];
+char Path [0x100];
+char CurrentTag [0x100];
+
+extern WCHAR Strings [STRING_COUNT][MAX_STRING_LENGHT];
+BOOL ImportXML (const char*);
+
+void ImportFolder (const char* folder)
+{
+       WCHAR buffer[0x100];
+       char buffer2[0x100];
+       struct _wfinddata_t Finddata;
+       DWORD Findhandle;
+       buffer[0]='\0';
+       strcpy(buffer2, Path);
+       strncat(buffer2, folder, 0x100-strlen(buffer2));
+       strncat(buffer2, "\\*.dml", 0x100-strlen(buffer2));
+       MultiByteToWideChar(CP_UTF8, 0, buffer2, -1, buffer, 0x100);
+       if((Findhandle=_wfindfirst(buffer, &Finddata)) == -1)
+               return;
+       do {
+               buffer[0]='\0';
+               MultiByteToWideChar(CP_UTF8, 0, folder, -1, buffer, 0x100);
+               wcsncat(buffer, L"\\", 0x100-wcslen(buffer));
+               wcsncat(buffer, Finddata.name, 0x100-wcslen(buffer));
+               WideCharToMultiByte(CP_UTF8, 0, buffer, -1, buffer2, 0x100, NULL, FALSE);
+               ImportXML(buffer2);
+       } while(_wfindnext(Findhandle, &Finddata)==0);
+       _findclose(Findhandle);
+}
+
+
+void Script_tag_opened (void* usrdata, const char* tag, const char** arg)
+{
+       int i;
+       if (!strcmp(tag, "script")) {
+               return;
+       } else if (InstallScriptOpen && (CurrentScript == NULL)) {
+               CurrentApplication->InstallScript = malloc(sizeof(struct ScriptElement));
+               CurrentScript = CurrentApplication->InstallScript;
+       } else if (UninstallScriptOpen && (CurrentScript == NULL)) {
+               CurrentApplication->UninstallScript = malloc(sizeof(struct ScriptElement));
+               CurrentScript = CurrentApplication->UninstallScript;
+       } else if (CurrentScript != NULL) {
+               CurrentScript->Next = malloc(sizeof(struct ScriptElement));
+               CurrentScript = CurrentScript->Next;
+       } else {
+               return;
+       }
+       memset(CurrentScript, 0, sizeof(struct ScriptElement));
+       if (!strcmp(tag, "download")) {
+               wcscpy(CurrentScript->Func, L"download");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
+                       } else if(!strcmp(arg[i], "url")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "exec")) {
+               wcscpy(CurrentScript->Func, L"exec");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "del")) {
+               wcscpy(CurrentScript->Func, L"del");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "unzip")) {
+               wcscpy(CurrentScript->Func, L"unzip");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       } else if(!strcmp(arg[i], "outdir")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "adduninstaller")) {
+               wcscpy(CurrentScript->Func, L"adduninstaller");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "regname")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       } else if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[1], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "removeuninstaller")) {
+               wcscpy(CurrentScript->Func, L"removeuninstaller");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "regname")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "message")) {
+               wcscpy(CurrentScript->Func, L"message");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "text")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else if (!strcmp(tag, "load")) {
+               wcscpy(CurrentScript->Func, L"load");
+               for (i=0; arg[i]; i+=2) {
+                       if(!strcmp(arg[i], "file")) {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentScript->Arg[0], 0x100);
+                       }
+               }
+       } else 
+               MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+}
+
+
+void tag_opened (void* usrdata, const char* tag, const char** arg)
+{
+       int i;
+
+       if(!strcmp(tag, "import"))
+       {
+               for (i=0; arg[i]; i+=2) 
+               {
+                       if(!strcmp(arg[i], "file"))
+                       {
+                               ImportXML(arg[i+1]);
+                       }
+                       else if(!strcmp(arg[i], "folder"))
+                       {
+                               ImportFolder(arg[i+1]);
+                       }
+               }
+       }
+       else if(!strcmp(tag, "tree") && !CurrentApplication)
+       {
+               // check version
+       }
+
+       else if(!strcmp(tag, "category") && !CurrentApplication)
+       {
+               if (!Current)
+               {
+                       Current = malloc(sizeof(struct Category));
+                       memset(Current, 0, sizeof(struct Category));
+               }
+               else if (TagOpen)
+               {
+                       Current->Children = malloc(sizeof(struct Category));
+                       memset(Current->Children, 0, sizeof(struct Category));
+                       Current->Children->Parent = Current;
+                       Current = Current->Children;
+               }
+               else
+               {
+                       Current->Next = malloc(sizeof(struct Category));
+                       memset(Current->Next, 0, sizeof(struct Category));
+                       Current->Next->Parent = Current->Parent;
+                       Current = Current->Next;
+               }
+               TagOpen = TRUE;
+
+               for (i=0; arg[i]; i+=2) 
+               {
+                       if(!strcmp(arg[i], "name"))
+                       {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, Current->Name, 0x100);
+                       }
+                       if(!strcmp(arg[i], "icon"))
+                       {
+                               Current->Icon = atoi(arg[i+1]);
+                       }
+               }
+       }
+
+       else if(!strcmp(tag, "application") && !CurrentApplication)
+       {
+               if(Current->Apps)
+               {
+                       CurrentApplication = Current->Apps;
+                       while(CurrentApplication->Next)
+                               CurrentApplication = CurrentApplication->Next;
+                       CurrentApplication->Next = malloc(sizeof(struct Application));
+                       memset(CurrentApplication->Next, 0, sizeof(struct Application));
+                       CurrentApplication = CurrentApplication->Next;
+               }
+               else
+               {
+                       Current->Apps = malloc(sizeof(struct Application));
+                       memset(Current->Apps, 0, sizeof(struct Application));
+                       CurrentApplication = Current->Apps;
+               }
+
+               for (i=0; arg[i]; i+=2) 
+               {
+                       if(!strcmp(arg[i], "name"))
+                       {
+                               MultiByteToWideChar(CP_UTF8, 0, arg[i+1], -1, CurrentApplication->Name, 0x100);
+                       }
+               }
+       }
+       else if (CurrentApplication)
+       {
+               if (!strcmp(tag, "installscript")) {
+                       InstallScriptOpen = TRUE;
+               } else  if (!strcmp(tag, "uninstallscript")) {
+                       UninstallScriptOpen = TRUE;
+               } else {
+                       Script_tag_opened(usrdata, tag, arg);
+                       if (CurrentScript == NULL) { 
+                               strncpy(CurrentTag, tag, 0x100);
+                       }
+               }
+       }
+       else
+               MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+}
+
+
+void text (void* usrdata, const char* data, int len)
+{
+       if (!CurrentApplication)
+               return;
+
+       if(!strcmp(CurrentTag, "maintainer"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->Maintainer);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Maintainer[currentlengt], 0x100-currentlengt);
+       }
+       else if(!strcmp(CurrentTag, "regname"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->RegName);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->RegName[currentlengt], 0x100-currentlengt);
+       }
+       else if(!strcmp(CurrentTag, "description"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->Description);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Description[currentlengt], 0x400-currentlengt);
+       }
+       else if(!strcmp(CurrentTag, "location"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->Location);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Location[currentlengt], 0x100-currentlengt);
+       }
+       else if(!strcmp(CurrentTag, "version"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->Version);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Version[currentlengt], 0x400-currentlengt);
+       }
+       else if(!strcmp(CurrentTag, "licence"))
+       {
+               int currentlengt = lstrlenW(CurrentApplication->Licence);
+               MultiByteToWideChar(CP_UTF8, 0, data, len, &CurrentApplication->Licence[currentlengt], 0x100-currentlengt);
+       }
+}
+
+void tag_closed (void* tree, const char* tag)
+{
+       CurrentTag[0] = 0;
+
+       if(!strcmp(tag, "category"))
+       {
+               if (TagOpen)
+               {
+                       TagOpen = FALSE;
+               }
+               else
+               {
+                       Current = Current->Parent;
+               }
+       }
+       else if(!strcmp(tag, "application"))
+       {
+               CurrentApplication = NULL;
+       }
+       else if(!strcmp(tag, "installscript") || !strcmp(tag, "uninstallscript"))
+       {
+               CurrentScript = NULL;
+               InstallScriptOpen = FALSE;
+               UninstallScriptOpen = FALSE;
+       }
+}
+
+BOOL ImportXML (const char* filename)
+{
+       int done = 0;
+       char buffer[0x100];
+       FILE* file;
+       XML_Parser parser;
+       strcpy(buffer, Path);
+       strncat(buffer, filename, 0x100-strlen(buffer));
+       file = fopen(buffer, "r");
+       if(!file) 
+       {
+               MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
+               return FALSE;
+       }
+
+       parser = XML_ParserCreate(NULL);
+       XML_SetElementHandler(parser, tag_opened, tag_closed);
+       XML_SetCharacterDataHandler(parser, text);
+
+       while (!done)
+       {
+               size_t len = fread (buffer, 1, sizeof(buffer), file);
+               done = len < sizeof(buffer);
+
+               buffer[len] = 0;
+               if(!XML_Parse(parser, buffer, len, done)) 
+               {
+                       MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+                       return FALSE;
+               }
+       }
+
+       XML_ParserFree(parser);
+       fclose(file);
+
+       return TRUE;
+}
+
+BOOL ProcessXML (const char* filename, struct Category* Root)
+{
+       FILE* file;
+       file = fopen(filename, "r");
+       if(file) 
+       {
+               Path[0]='\0';
+               fclose(file);
+       }
+       else
+       {
+               strncpy(Path, getenv("SystemRoot"), 0x100-13);
+               strcat(Path, "\\packagetree\\");
+       }
+
+       if(Current)
+               return FALSE;
+
+       Current = Root;
+       CurrentApplication = NULL;
+       CurrentScript = NULL;
+       TagOpen = TRUE;
+       InstallScriptOpen = FALSE;
+       UninstallScriptOpen = FALSE;
+
+       return ImportXML(filename);
+}
+
+void DML_tag_opened (void* usrdata, const char* tag, const char** arg)
+{
+       int i;
+
+       if(!strcmp(tag, "application"))
+       {
+               for (i=0; arg[i]; i+=2) 
+               {
+                       if(!strcmp(arg[i], "name"))
+                       {
+                               strncpy(DML_Name, arg[i+1], 0x100);
+                       }
+                       else if(!strcmp(arg[i], "target"))
+                       {
+                               strncpy(DML_Target, arg[i+1], 0x100);
+                       }
+               }
+       }
+}
+
+void NOP_text (void* usrdata, const char* data, int len)
+{
+}
+
+void NOP_tag_closed (void* tree, const char* tag)
+{
+}
+
+char* addDML (const char* filename)
+{
+       int done = 0;
+       char buffer[0x100];
+       FILE* file;
+       XML_Parser parser;
+       DML_Target[0] = '\0';
+       file = fopen(filename, "r");
+       if(!file) 
+       {
+               MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
+               return NULL;
+       }
+
+       parser = XML_ParserCreate(NULL);
+       XML_SetElementHandler(parser, DML_tag_opened, NOP_tag_closed);
+       XML_SetCharacterDataHandler(parser, NOP_text);
+
+       while (!done)
+       {
+               size_t len = fread (buffer, 1, sizeof(buffer), file);
+               done = len < sizeof(buffer);
+
+               buffer[len] = 0;
+               if(!XML_Parse(parser, buffer, len, done)) 
+               {
+                       MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+                       return NULL;
+               }
+       }
+
+       XML_ParserFree(parser);
+       fclose(file);
+
+       if(DML_Target[0]=='\0')
+       {
+               MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+               return NULL;
+       }
+       
+       strcpy(buffer, getenv("SystemRoot"));
+       strncat(buffer, "\\packagetree\\", 0x100-strlen(buffer));
+       strncat(buffer, DML_Target, 0x100-strlen(buffer));
+
+       CopyFileA(filename, buffer, FALSE);
+       return DML_Name;
+}
+
+void LoadScriptFunc(WCHAR* filenameW, struct ScriptElement* Script)
+{
+       int done = 0;
+       char buffer[0x100];
+       char filenameA[0x100];
+       FILE* file;
+       XML_Parser parser;
+       struct ScriptElement* NextElement = Script->Next;
+       wcscpy(Script->Func,L"NOP");
+       CurrentScript = Script;
+       WideCharToMultiByte(CP_UTF8, 0, filenameW, -1, filenameA, 0x100, NULL, FALSE);
+       strcpy(buffer, Path);
+       strncat(buffer, filenameA, 0x100-strlen(buffer));
+       file = fopen(buffer, "r");
+       if(!file) 
+       {
+               MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
+               return;
+       }
+
+       parser = XML_ParserCreate(NULL);
+       XML_SetElementHandler(parser, Script_tag_opened, NOP_tag_closed);
+       XML_SetCharacterDataHandler(parser, NOP_text);
+
+       while (!done)
+       {
+               size_t len = fread (buffer, 1, sizeof(buffer), file);
+               done = len < sizeof(buffer);
+
+               buffer[len] = 0;
+               if(!XML_Parse(parser, buffer, len, done)) 
+               {
+                       MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
+                       CurrentScript->Next = NextElement;
+                       return;
+               }
+       }
+
+       XML_ParserFree(parser);
+       fclose(file);
+       CurrentScript->Next = NextElement;
+       return;
+}
+
+void FreeScript (struct ScriptElement* Script)
+{
+       if (Script->Next != NULL)
+               FreeScript(Script->Next);
+       free(Script);
+}
+
+void FreeApps (struct Application* Apps)
+{
+       if (Apps->Next)
+               FreeApps(Apps->Next);
+       if (Apps->InstallScript)
+               FreeScript(Apps->InstallScript);
+       if (Apps->UninstallScript)
+               FreeScript(Apps->UninstallScript);
+
+       free(Apps);
+}
+
+void FreeTree (struct Category* Node)
+{
+       if (Node->Children)
+               FreeTree(Node->Children);
+
+       if (Node->Next)
+               FreeTree(Node->Next);
+
+       if (Node->Apps)
+               FreeApps(Node->Apps);
+
+       free(Node);
+}
diff --git a/rosapps/ext2/attr.c b/rosapps/ext2/attr.c
new file mode 100644 (file)
index 0000000..37e011a
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/attr.c
+ * PURPOSE:          Set/Get file attributes support
+ * PROGRAMMER:       David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+#include <wchar.h>
+#include <string.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ****************************************************************/
+
+NTSTATUS STDCALL
+Ext2SetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2SetInformation(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+   IoCompleteRequest(Irp,
+                    IO_NO_INCREMENT);
+
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2QueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   NTSTATUS Status;
+   PIO_STACK_LOCATION Param;
+   PFILE_OBJECT FileObject;
+   PDEVICE_EXTENSION DeviceExt;
+   ULONG Length;
+   PFILE_BASIC_INFORMATION PFileBasicInformation;
+   PFILE_STANDARD_INFORMATION PFileStandardInformation;
+   PFILE_INTERNAL_INFORMATION PFileInternalInformation;
+   PFILE_EA_INFORMATION PFileEaInformation;
+   PFILE_ACCESS_INFORMATION PFileAccessInformation;
+   PFILE_NAME_INFORMATION PFileNameInformation;
+   PFILE_POSITION_INFORMATION PFilePositionInformation;
+   PVOID Buffer;
+
+   DPRINT("Ext2QueryInformation(DeviceObject %x Irp %x)\n", DeviceObject, Irp);
+
+   Param = IoGetCurrentIrpStackLocation(Irp);
+   FileObject = Param->FileObject;
+   DeviceExt = DeviceObject->DeviceExtension;
+   Length = Param->Parameters.QueryFile.Length;
+   Buffer = Irp->AssociatedIrp.SystemBuffer;
+
+   switch (Param->Parameters.QueryFile.FileInformationClass)
+     {
+      case FileDirectoryInformation:
+      case FileFullDirectoryInformation:
+      case FileBothDirectoryInformation:
+       Status = STATUS_NOT_IMPLEMENTED;
+       break;
+
+      case FileBasicInformation:
+       PFileBasicInformation = (PFILE_BASIC_INFORMATION)Buffer;
+       memset(PFileBasicInformation, 0, sizeof(FILE_BASIC_INFORMATION));
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileStandardInformation:
+       PFileStandardInformation = (PFILE_STANDARD_INFORMATION)Buffer;
+       memset(PFileStandardInformation, 0, sizeof(FILE_STANDARD_INFORMATION));
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileInternalInformation:
+       PFileInternalInformation = (PFILE_INTERNAL_INFORMATION)Buffer;
+       memset(PFileInternalInformation, 0, sizeof(FILE_INTERNAL_INFORMATION));
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileEaInformation:
+       PFileEaInformation = (PFILE_EA_INFORMATION)Buffer;
+       memset(PFileEaInformation, 0, sizeof(FILE_EA_INFORMATION));
+       PFileEaInformation->EaSize = 0;
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileAccessInformation:
+       PFileAccessInformation = (PFILE_ACCESS_INFORMATION)Buffer;
+       memset(PFileAccessInformation, 0, sizeof(FILE_ACCESS_INFORMATION));
+       PFileAccessInformation->AccessFlags = 0;
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileNameInformation:
+       PFileNameInformation = (PFILE_NAME_INFORMATION)Buffer;
+       memset(PFileNameInformation, 0, sizeof(FILE_NAME_INFORMATION));
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FilePositionInformation:
+       PFilePositionInformation = (PFILE_POSITION_INFORMATION)Buffer;
+       memcpy(PFilePositionInformation,
+              &FileObject->CurrentByteOffset,
+              sizeof(FileObject->CurrentByteOffset));
+       Status = STATUS_SUCCESS;
+       break;
+
+      case FileRenameInformation:
+       Status = STATUS_NOT_IMPLEMENTED;
+       break;
+
+      default:
+       Status = STATUS_NOT_SUPPORTED;
+     }
+
+
+
+
+   Irp->IoStatus.Status = Status;
+   if (NT_SUCCESS(Status))
+     Irp->IoStatus.Information =
+       Param->Parameters.QueryFile.Length - Length;
+   else
+     Irp->IoStatus.Information = 0;
+   IoCompleteRequest(Irp,
+                    IO_NO_INCREMENT);
+
+   return(Status);
+}
diff --git a/rosapps/ext2/blockdev.c b/rosapps/ext2/blockdev.c
new file mode 100644 (file)
index 0000000..6792b98
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/blockdev.c
+ * PURPOSE:          Temporary sector reading support
+ * PROGRAMMER:       David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ***************************************************************/
+
+BOOLEAN
+Ext2ReadSectors(IN PDEVICE_OBJECT pDeviceObject,
+               IN ULONG DiskSector,
+               IN ULONG SectorCount,
+               IN PVOID Buffer)
+{
+    LARGE_INTEGER   sectorNumber;
+    PIRP            irp;
+    IO_STATUS_BLOCK ioStatus;
+    KEVENT          event;
+    NTSTATUS        status;
+    ULONG           sectorSize;
+    int j;
+
+    DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
+           pDeviceObject,DiskSector,Buffer);
+
+    sectorNumber.u.HighPart = 0;
+    sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
+
+    DPRINT("DiskSector:%ld BLKSZ:%ld sectorNumber:%ld:%ld\n",
+           (unsigned long) DiskSector,
+           (unsigned long) BLOCKSIZE,
+           (unsigned long) sectorNumber.u.HighPart,
+           (unsigned long) sectorNumber.u.LowPart);
+
+    KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+    sectorSize = BLOCKSIZE*SectorCount;
+
+
+    DPRINT("Building synchronous FSD Request...\n");
+    irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
+                                       pDeviceObject,
+                                       Buffer,
+                                       sectorSize,
+                                       &sectorNumber,
+                                       &event,
+                                       &ioStatus );
+
+    if (!irp)
+     {
+        DbgPrint("READ failed!!!\n");
+        return FALSE;
+     }
+
+    DPRINT("Calling IO Driver...\n");
+    status = IoCallDriver(pDeviceObject, irp);
+
+    DPRINT("Waiting for IO Operation...\n");
+    if (status == STATUS_PENDING)
+     {
+        KeWaitForSingleObject(&event,
+                              Suspended,
+                              KernelMode,
+                              FALSE,
+                              NULL);
+        DPRINT("Getting IO Status...\n");
+        status = ioStatus.Status;
+     }
+
+   if (!NT_SUCCESS(status))
+     {
+        DbgPrint("IO failed!!! Error code: %d(%x)\n", status, status);
+        return FALSE;
+     }
+
+   return TRUE;
+}
+
+BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
+                        IN ULONG       DiskSector,
+                         IN ULONG       SectorCount,
+                        IN UCHAR*      Buffer)
+{
+    LARGE_INTEGER   sectorNumber;
+    PIRP            irp;
+    IO_STATUS_BLOCK ioStatus;
+    KEVENT          event;
+    NTSTATUS        status;
+    ULONG           sectorSize;
+    PULONG          mbr;
+    int j;
+
+    DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
+           pDeviceObject,DiskSector,Buffer);
+
+    sectorNumber.u.HighPart = 0;
+    sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
+
+    KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+    sectorSize = BLOCKSIZE*SectorCount;
+
+
+    DPRINT("Building synchronous FSD Request...\n");
+    irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
+                                       pDeviceObject,
+                                       Buffer,
+                                       sectorSize,
+                                       &sectorNumber,
+                                       &event,
+                                       &ioStatus );
+
+    if (!irp) {
+        DbgPrint("WRITE failed!!!\n");
+        return FALSE;
+    }
+
+    DPRINT("Calling IO Driver...\n");
+    status = IoCallDriver(pDeviceObject,
+                          irp);
+
+    DPRINT("Waiting for IO Operation...\n");
+    if (status == STATUS_PENDING) {
+        KeWaitForSingleObject(&event,
+                              Suspended,
+                              KernelMode,
+                              FALSE,
+                              NULL);
+        DPRINT("Getting IO Status...\n");
+        status = ioStatus.Status;
+    }
+
+    if (!NT_SUCCESS(status)) {
+        DbgPrint("IO failed!!! Error code: %d(%x)\n", status, status);
+        return FALSE;
+    }
+
+
+    ExFreePool(mbr);
+    DPRINT("Block request succeeded\n");
+    return TRUE;
+}
+
diff --git a/rosapps/ext2/dir.c b/rosapps/ext2/dir.c
new file mode 100644 (file)
index 0000000..6bfb8ae
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/dir.c
+ * PURPOSE:          ext2 filesystem
+ * PROGRAMMER:       David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+#include <wchar.h>
+#include <string.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS *****************************************************************/
+
+
+static VOID Ext2ConvertName(PWSTR Out, PCH In, ULONG Len)
+{
+   ULONG i;
+
+   for (i=0; i<Len; i++)
+     {
+       *Out = *In;
+       Out++;
+       In++;
+     }
+   *Out = 0;
+}
+
+PVOID Ext2ProcessDirEntry(PDEVICE_EXTENSION DeviceExt,
+                         struct ext2_dir_entry* dir_entry,
+                         PIO_STACK_LOCATION IoStack,
+                         PVOID Buffer,
+                         ULONG FileIndex)
+{
+   PFILE_DIRECTORY_INFORMATION FDI;
+   PFILE_NAMES_INFORMATION FNI;
+   PFILE_BOTH_DIRECTORY_INFORMATION FBI;
+   struct ext2_inode inode;
+
+   DPRINT("FileIndex %d\n",FileIndex);
+   DPRINT("Buffer %x\n",Buffer);
+
+   Ext2ReadInode(DeviceExt,
+                dir_entry->inode,
+                &inode);
+
+   switch (IoStack->Parameters.QueryDirectory.FileInformationClass)
+     {
+      case FileNamesInformation:
+       FNI = (PFILE_NAMES_INFORMATION)Buffer;
+       FNI->NextEntryOffset = sizeof(FileDirectoryInformation) +
+         dir_entry->name_len + 1;
+       FNI->FileNameLength = dir_entry->name_len;
+       Ext2ConvertName(FNI->FileName, dir_entry->name, dir_entry->name_len);
+       Buffer = Buffer + FNI->NextEntryOffset;
+       break;
+
+      case FileDirectoryInformation:
+       FDI = (PFILE_DIRECTORY_INFORMATION)Buffer;
+       FDI->NextEntryOffset = sizeof(FileDirectoryInformation) +
+                              dir_entry->name_len + 1;
+       FDI->FileIndex = FileIndex;
+//     FDI->CreationTime = 0;
+//     FDI->LastAccessTime = 0;
+//     FDI->LastWriteTime = 0;
+//     FDI->ChangeTime = 0;
+        FDI->AllocationSize.QuadPart = FDI->EndOfFile.QuadPart = inode.i_size;
+       FDI->FileAttributes = 0;
+       FDI->FileNameLength = dir_entry->name_len;
+       Ext2ConvertName(FDI->FileName, dir_entry->name, dir_entry->name_len);
+       Buffer = Buffer + FDI->NextEntryOffset;
+       break;
+
+      case FileBothDirectoryInformation:
+       FBI = (PFILE_BOTH_DIRECTORY_INFORMATION)Buffer;
+       FBI->NextEntryOffset = sizeof(FileBothDirectoryInformation) +
+         dir_entry->name_len + 1;
+       FBI->FileIndex = FileIndex;
+        FBI->AllocationSize.QuadPart = FBI->EndOfFile.QuadPart = inode.i_size;
+       FBI->FileAttributes = 0;
+       FBI->FileNameLength = dir_entry->name_len;
+       Ext2ConvertName(FBI->FileName, dir_entry->name, dir_entry->name_len);
+       memset(FBI->ShortName, 0, sizeof(FBI->ShortName));
+       Buffer = Buffer + FBI->NextEntryOffset;
+       break;
+
+      default:
+       UNIMPLEMENTED;
+     }
+   return(Buffer);
+}
+
+
+NTSTATUS Ext2QueryDirectory(PDEVICE_EXTENSION DeviceExt,
+                           PEXT2_FCB Fcb,
+                           PIRP Irp,
+                           PIO_STACK_LOCATION IoStack)
+{
+   ULONG Max;
+   ULONG i;
+   ULONG StartIndex;
+   PVOID Buffer = NULL;
+   struct ext2_dir_entry dir_entry;
+
+   Buffer = Irp->UserBuffer;
+   DPRINT("Buffer %x\n",Buffer);
+   DPRINT("IoStack->Flags %x\n",IoStack->Flags);
+
+   if (IoStack->Flags & SL_RETURN_SINGLE_ENTRY)
+     {
+       Max = 1;
+     }
+   else
+     {
+       UNIMPLEMENTED;
+     }
+
+   DPRINT("Buffer->FileIndex %d\n",
+         ((PFILE_DIRECTORY_INFORMATION)Buffer)->FileIndex);
+   if (IoStack->Flags & SL_INDEX_SPECIFIED)
+     {
+       StartIndex = ((PFILE_DIRECTORY_INFORMATION)Buffer)->FileIndex;
+     }
+   else
+     {
+       StartIndex = 0;
+     }
+
+   if (IoStack->Flags & SL_RESTART_SCAN)
+     {
+       StartIndex = 0;
+     }
+
+   DPRINT("StartIndex %d\n",StartIndex);
+
+   for (i=0; i<Max ;i++)
+     {
+       if (!Ext2ScanDir(DeviceExt,&Fcb->inode,"*",&dir_entry,&StartIndex))
+         {
+            ((PFILE_DIRECTORY_INFORMATION)Buffer)->NextEntryOffset = 0;
+            return(STATUS_NO_MORE_FILES);
+         }
+       Buffer = Ext2ProcessDirEntry(DeviceExt,
+                                    &dir_entry,
+                                    IoStack,
+                                    Buffer,
+                                    StartIndex);
+     }
+   return(STATUS_SUCCESS);
+}
+
+NTSTATUS STDCALL
+Ext2DirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+   PFILE_OBJECT FileObject = Stack->FileObject;
+   PEXT2_FCB Fcb = (PVOID)FileObject->FsContext;
+   NTSTATUS Status;
+   PDEVICE_EXTENSION DeviceExt;
+
+   DPRINT("Ext2DirectoryControl(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
+
+   DeviceExt = DeviceObject->DeviceExtension;
+
+   switch (Stack->MinorFunction)
+     {
+      case IRP_MN_QUERY_DIRECTORY:
+       Status = Ext2QueryDirectory(DeviceExt, Fcb, Irp, Stack);
+       break;
+
+      default:
+       Status = STATUS_UNSUCCESSFUL;
+     }
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
+
+BOOL Ext2ScanDir(PDEVICE_EXTENSION DeviceExt,
+                struct ext2_inode* dir,
+                PCH filename,
+                struct ext2_dir_entry* ret,
+                PULONG StartIndex)
+{
+   ULONG i;
+   char* buffer;
+   ULONG offset;
+   char name[255];
+   struct ext2_dir_entry* current;
+   ULONG block;
+   BOOL b;
+
+   DPRINT("Ext2ScanDir(dir %x, filename %s, ret %x)\n",dir,filename,ret);
+
+   buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
+
+   for (i=0; i<((*StartIndex)/BLOCKSIZE); i++);
+   for (; (block = Ext2BlockMap(DeviceExt, dir, i)) != 0; i++)
+     {
+       DPRINT("block %d\n",block);
+       b = Ext2ReadSectors(DeviceExt->StorageDevice,
+                           block,
+                           1,
+                           buffer);
+       if (!b)
+         {
+            DbgPrint("ext2fs:%s:%d: Disk io failed\n", __FILE__, __LINE__);
+            return(FALSE);
+         }
+
+       offset = (*StartIndex)%BLOCKSIZE;
+       while (offset < BLOCKSIZE)
+         {
+            current = &buffer[offset];
+
+            strncpy(name,current->name,current->name_len);
+             name[current->name_len]=0;
+
+            DPRINT("Scanning offset %d inode %d name %s\n",
+                   offset,current->inode,name);
+
+             DPRINT("Comparing %s %s\n",name,filename);
+            if (strcmp(name,filename)==0 || strcmp(filename,"*")==0)
+              {
+                 DPRINT("Match found\n");
+                 *StartIndex = (i*BLOCKSIZE) + offset + current->rec_len;
+                 memcpy(ret,current,sizeof(struct ext2_dir_entry));
+                 ExFreePool(buffer);
+                 return(TRUE);
+              }
+
+            offset = offset + current->rec_len;
+            ASSERT(current->rec_len != 0);
+            DPRINT("offset %d\n",offset);
+         }
+       DPRINT("Onto next block\n");
+     }
+   DPRINT("No match\n");
+   ExFreePool(buffer);
+   return(FALSE);
+}
+
+void unicode_to_ansi(PCH StringA, PWSTR StringW)
+{
+   while((*StringW)!=0)
+     {
+       *StringA = *StringW;
+       StringA++;
+       StringW++;
+     }
+   *StringA = 0;
+}
+
+NTSTATUS Ext2OpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
+                    PWSTR FileName)
+/*
+ * FUNCTION: Opens a file
+ */
+{
+   EXT2_INODE parent_inode;
+   struct ext2_dir_entry entry;
+   char name[255];
+   ULONG current_inode = 2;
+   char* current_segment;
+   PEXT2_FCB Fcb;
+   ULONG StartIndex = 0;
+
+   DPRINT("Ext2OpenFile(DeviceExt %x, FileObject %x, FileName %S)\n",
+         DeviceExt,FileObject,FileName);
+
+   Fcb = ExAllocatePool(NonPagedPool, sizeof(EXT2_FCB));
+
+   unicode_to_ansi(name,FileName);
+   DPRINT("name %s\n",name);
+   DPRINT("strtok %x\n",strtok);
+   current_segment = strtok(name,"\\");
+   DPRINT("current_segment %x\n", current_segment);
+   while (current_segment!=NULL)
+     {
+       Ext2LoadInode(DeviceExt,
+                     current_inode,
+                     &parent_inode);
+        if (!Ext2ScanDir(DeviceExt,
+                        parent_inode.inode,
+                        current_segment,
+                        &entry,
+                        &StartIndex))
+         {
+            Ext2ReleaseInode(DeviceExt,
+                             &parent_inode);
+            ExFreePool(Fcb);
+            return(STATUS_UNSUCCESSFUL);
+         }
+       current_inode = entry.inode;
+       current_segment = strtok(NULL,"\\");
+       StartIndex = 0;
+       Ext2ReleaseInode(DeviceExt,
+                        &parent_inode);
+     }
+   DPRINT("Found file\n");
+
+   Fcb->inode = current_inode;
+   CcRosInitializeFileCache(FileObject, &Fcb->Bcb, PAGE_SIZE*3);
+   FileObject->FsContext = Fcb;
+
+   return(STATUS_SUCCESS);
+}
+
+NTSTATUS STDCALL
+Ext2Create(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+   PFILE_OBJECT FileObject = Stack->FileObject;
+   NTSTATUS Status;
+   PDEVICE_EXTENSION DeviceExt;
+
+   DPRINT("Ext2Create(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
+
+   DeviceExt = DeviceObject->DeviceExtension;
+   Status = Ext2OpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
diff --git a/rosapps/ext2/ext2fs.h b/rosapps/ext2/ext2fs.h
new file mode 100644 (file)
index 0000000..1dfd8fd
--- /dev/null
@@ -0,0 +1,289 @@
+#include <ntddk.h>
+#include <ntifs.h>
+
+BOOLEAN Ext2ReadSectors(IN PDEVICE_OBJECT pDeviceObject,
+                       IN ULONG        DiskSector,
+                        IN ULONG        SectorCount,
+                       IN PVOID        Buffer);
+
+#define BLOCKSIZE (1024)
+
+struct ext2_super_block {
+       ULONG   s_inodes_count;         /* Inodes count */
+       ULONG   s_blocks_count;         /* Blocks count */
+       ULONG   s_r_blocks_count;       /* Reserved blocks count */
+       ULONG   s_free_blocks_count;    /* Free blocks count */
+       ULONG   s_free_inodes_count;    /* Free inodes count */
+       ULONG   s_first_data_block;     /* First Data Block */
+       ULONG   s_log_block_size;       /* Block size */
+       LONG    s_log_frag_size;        /* Fragment size */
+       ULONG   s_blocks_per_group;     /* # Blocks per group */
+       ULONG   s_frags_per_group;      /* # Fragments per group */
+       ULONG   s_inodes_per_group;     /* # Inodes per group */
+       ULONG   s_mtime;                /* Mount time */
+       ULONG   s_wtime;                /* Write time */
+       USHORT  s_mnt_count;            /* Mount count */
+       SHORT   s_max_mnt_count;        /* Maximal mount count */
+       USHORT  s_magic;                /* Magic signature */
+       USHORT  s_state;                /* File system state */
+       USHORT  s_errors;               /* Behaviour when detecting errors */
+       USHORT  s_minor_rev_level;      /* minor revision level */
+       ULONG   s_lastcheck;            /* time of last check */
+       ULONG   s_checkinterval;        /* max. time between checks */
+       ULONG   s_creator_os;           /* OS */
+       ULONG   s_rev_level;            /* Revision level */
+       USHORT  s_def_resuid;           /* Default uid for reserved blocks */
+       USHORT  s_def_resgid;           /* Default gid for reserved blocks */
+       /*
+        * These fields are for EXT2_DYNAMIC_REV superblocks only.
+        *
+        * Note: the difference between the compatible feature set and
+        * the incompatible feature set is that if there is a bit set
+        * in the incompatible feature set that the kernel doesn't
+        * know about, it should refuse to mount the filesystem.
+        *
+        * e2fsck's requirements are more strict; if it doesn't know
+        * about a feature in either the compatible or incompatible
+        * feature set, it must abort and not try to meddle with
+        * things it doesn't understand...
+        */
+       ULONG   s_first_ino;            /* First non-reserved inode */
+       USHORT   s_inode_size;          /* size of inode structure */
+       USHORT  s_block_group_nr;       /* block group # of this superblock */
+       ULONG   s_feature_compat;       /* compatible feature set */
+       ULONG   s_feature_incompat;     /* incompatible feature set */
+       ULONG   s_feature_ro_compat;    /* readonly-compatible feature set */
+       ULONG   s_reserved[230];        /* Padding to the end of the block */
+};
+
+/*
+ * Codes for operating systems
+ */
+#define EXT2_OS_LINUX          0
+#define EXT2_OS_HURD           1
+#define EXT2_OS_MASIX          2
+#define EXT2_OS_FREEBSD                3
+#define EXT2_OS_LITES          4
+
+/*
+ * Revision levels
+ */
+#define EXT2_GOOD_OLD_REV      0       /* The good old (original) format */
+#define EXT2_DYNAMIC_REV       1       /* V2 format w/ dynamic inode sizes */
+
+#define EXT2_CURRENT_REV       EXT2_GOOD_OLD_REV
+#define EXT2_MAX_SUPP_REV      EXT2_DYNAMIC_REV
+
+/*
+ * The second extended file system magic number
+ */
+#define EXT2_SUPER_MAGIC       0xEF53
+
+/*
+ * Constants relative to the data blocks
+ */
+#define        EXT2_NDIR_BLOCKS                12
+#define        EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
+#define        EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
+#define        EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
+#define        EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
+
+
+/*
+ * Structure of an inode on the disk
+ */
+struct ext2_inode {
+       USHORT  i_mode;         /* File mode */
+       USHORT  i_uid;          /* Owner Uid */
+       ULONG   i_size;         /* Size in bytes */
+       ULONG   i_atime;        /* Access time */
+       ULONG   i_ctime;        /* Creation time */
+       ULONG   i_mtime;        /* Modification time */
+       ULONG   i_dtime;        /* Deletion Time */
+       USHORT  i_gid;          /* Group Id */
+       USHORT  i_links_count;  /* Links count */
+       ULONG   i_blocks;       /* Blocks count */
+       ULONG   i_flags;        /* File flags */
+       union {
+               struct {
+                       ULONG  l_i_reserved1;
+               } linux1;
+               struct {
+                       ULONG  h_i_translator;
+               } hurd1;
+               struct {
+                       ULONG  m_i_reserved1;
+               } masix1;
+       } osd1;                         /* OS dependent 1 */
+       ULONG   i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
+       ULONG   i_version;      /* File version (for NFS) */
+       ULONG   i_file_acl;     /* File ACL */
+       ULONG   i_dir_acl;      /* Directory ACL */
+       ULONG   i_faddr;        /* Fragment address */
+       union {
+               struct {
+                       UCHAR   l_i_frag;       /* Fragment number */
+                       UCHAR   l_i_fsize;      /* Fragment size */
+                       USHORT  i_pad1;
+                       ULONG   l_i_reserved2[2];
+               } linux2;
+               struct {
+                       UCHAR   h_i_frag;       /* Fragment number */
+                       UCHAR   h_i_fsize;      /* Fragment size */
+                       USHORT  h_i_mode_high;
+                       USHORT  h_i_uid_high;
+                       USHORT  h_i_gid_high;
+                       ULONG   h_i_author;
+               } hurd2;
+               struct {
+                       UCHAR   m_i_frag;       /* Fragment number */
+                       UCHAR   m_i_fsize;      /* Fragment size */
+                       USHORT  m_pad1;
+                       ULONG   m_i_reserved2[2];
+               } masix2;
+       } osd2;                         /* OS dependent 2 */
+};
+
+#if defined(__KERNEL__) || defined(__linux__)
+#define i_reserved1    osd1.linux1.l_i_reserved1
+#define i_frag         osd2.linux2.l_i_frag
+#define i_fsize                osd2.linux2.l_i_fsize
+#define i_reserved2    osd2.linux2.l_i_reserved2
+#endif
+
+#ifdef __hurd__
+#define i_translator   osd1.hurd1.h_i_translator
+#define i_frag         osd2.hurd2.h_i_frag;
+#define i_fsize                osd2.hurd2.h_i_fsize;
+#define i_uid_high     osd2.hurd2.h_i_uid_high
+#define i_gid_high     osd2.hurd2.h_i_gid_high
+#define i_author       osd2.hurd2.h_i_author
+#endif
+
+#ifdef __masix__
+#define i_reserved1    osd1.masix1.m_i_reserved1
+#define i_frag         osd2.masix2.m_i_frag
+#define i_fsize                osd2.masix2.m_i_fsize
+#define i_reserved2    osd2.masix2.m_i_reserved2
+#endif
+
+/*
+ * Constants relative to the data blocks
+ */
+#define        EXT2_NDIR_BLOCKS                12
+#define        EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
+#define        EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
+#define        EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
+#define        EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
+
+/*
+ * Inode flags
+ */
+#define        EXT2_SECRM_FL                   0x00000001 /* Secure deletion */
+#define        EXT2_UNRM_FL                    0x00000002 /* Undelete */
+#define        EXT2_COMPR_FL                   0x00000004 /* Compress file */
+#define EXT2_SYNC_FL                   0x00000008 /* Synchronous updates */
+#define EXT2_IMMUTABLE_FL              0x00000010 /* Immutable file */
+#define EXT2_APPEND_FL                 0x00000020 /* writes to file may only append */
+#define EXT2_NODUMP_FL                 0x00000040 /* do not dump file */
+#define EXT2_RESERVED_FL               0x80000000 /* reserved for ext2 lib */
+
+
+/*
+ * Structure of a blocks group descriptor
+ */
+struct ext2_group_desc
+{
+       ULONG   bg_block_bitmap;                /* Blocks bitmap block */
+       ULONG   bg_inode_bitmap;                /* Inodes bitmap block */
+       ULONG   bg_inode_table;         /* Inodes table block */
+       USHORT  bg_free_blocks_count;   /* Free blocks count */
+       USHORT  bg_free_inodes_count;   /* Free inodes count */
+       USHORT  bg_used_dirs_count;     /* Directories count */
+       USHORT  bg_pad;
+       ULONG   bg_reserved[3];
+};
+
+#define EXT2_NAME_LEN 255
+
+struct ext2_dir_entry {
+       ULONG   inode;                  /* Inode number */
+       USHORT  rec_len;                /* Directory entry length */
+       USHORT  name_len;               /* Name length */
+       char    name[EXT2_NAME_LEN];    /* File name */
+};
+
+typedef struct
+{
+   PDEVICE_OBJECT StorageDevice;
+   struct ext2_super_block* superblock;
+   PFILE_OBJECT FileObject;
+   PBCB Bcb;
+} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+
+typedef struct _EXT2_GROUP_DESC
+{
+   ERESOURCE Lock;
+   struct ext2_group_desc* desc;
+   PCACHE_SEGMENT CacheSeg;
+   PVOID BaseAddress;
+} EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
+
+PEXT2_GROUP_DESC Ext2LoadGroup(PDEVICE_EXTENSION DeviceExt,
+                              ULONG BlockGrp);
+VOID Ext2ReleaseGroup(PDEVICE_EXTENSION DeviceExt,
+                     PEXT2_GROUP_DESC GrpDesc);
+
+VOID Ext2ReadInode(PDEVICE_EXTENSION DeviceExt,
+                  ULONG ino,
+                  struct ext2_inode* inode);
+struct ext2_group_desc* Ext2LoadGroupDesc(PDEVICE_EXTENSION DeviceExt,
+                                         ULONG block_group);
+
+typedef struct _EXT2_INODE
+{
+   struct ext2_inode* inode;
+   PVOID BaseAddress;
+   PCACHE_SEGMENT CacheSeg;
+} EXT2_INODE, *PEXT2_INODE;
+
+typedef struct _EXT2_FCB
+{
+   ULONG inode;
+   EXT2_INODE i;
+   PBCB Bcb;
+} EXT2_FCB, *PEXT2_FCB;
+
+ULONG Ext2BlockMap(PDEVICE_EXTENSION DeviceExt,
+                  struct ext2_inode* inode,
+                  ULONG offset);
+NTSTATUS Ext2OpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
+                     PWSTR FileName);
+NTSTATUS Ext2ReadFile(PDEVICE_EXTENSION DeviceExt,
+                     PFILE_OBJECT FileObject,
+                     PVOID Buffer,
+                     ULONG Length,
+                      LARGE_INTEGER Offset);
+NTSTATUS STDCALL Ext2Create(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2DirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2QueryQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2SetQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2SetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2QuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2SetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2QueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2Read(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2Write(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2Cleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2FlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS STDCALL Ext2Shutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp);
+NTSTATUS Ext2ReadPage(PDEVICE_EXTENSION DeviceExt,
+                     PEXT2_FCB Fcb,
+                     PVOID Buffer,
+                     ULONG Offset);
+VOID Ext2LoadInode(PDEVICE_EXTENSION DeviceExt,
+                  ULONG ino,
+                  PEXT2_INODE Inode);
+VOID Ext2ReleaseInode(PDEVICE_EXTENSION DeviceExt,
+                     PEXT2_INODE Inode);
+
diff --git a/rosapps/ext2/ext2fs.rc b/rosapps/ext2/ext2fs.rc
new file mode 100644 (file)
index 0000000..a2e2503
--- /dev/null
@@ -0,0 +1,7 @@
+/* $Id$ */
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "Linux ext2 IFS Driver\0"
+#define REACTOS_STR_INTERNAL_NAME      "ext2fs\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "ext2fs.sys\0"
+#include <reactos/version.rc>
diff --git a/rosapps/ext2/file.c b/rosapps/ext2/file.c
new file mode 100644 (file)
index 0000000..a627974
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/super.c
+ * PURPOSE:          ext2 filesystem
+ * PROGRAMMER:       David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+
+#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ****************************************************************/
+
+#define addr_per_block (BLOCKSIZE / sizeof(ULONG))
+
+ULONG Ext2BlockMap(PDEVICE_EXTENSION DeviceExt,
+                 struct ext2_inode* inode,
+                 ULONG offset)
+{
+   ULONG block;
+   PULONG TempBuffer;
+   BOOL b;
+
+   DPRINT("Ext2BlockMap(DeviceExt %x, inode %x, offset %d)\n",
+          DeviceExt,inode,offset);
+   if (offset < EXT2_NDIR_BLOCKS)
+     {
+       block = inode->i_block[offset];
+       DPRINT("block %d\n",block);
+       return(block);
+     }
+   offset = offset - EXT2_NDIR_BLOCKS;
+   if (offset < addr_per_block)
+     {
+       block = inode->i_block[EXT2_IND_BLOCK];
+       TempBuffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
+       b = Ext2ReadSectors(DeviceExt->StorageDevice,
+                           block,
+                           1,
+                           TempBuffer);
+       if (!b)
+         {
+            DbgPrint("ext2fs:%s:%d: Disk io failed\n", __FILE__, __LINE__);
+            return(0);
+         }
+       block = TempBuffer[offset];
+       ExFreePool(TempBuffer);
+       return(block);
+     }
+   offset = offset - addr_per_block;
+   DbgPrint("Failed at %s:%d\n",__FILE__,__LINE__);
+   for(;;);
+}
+
diff --git a/rosapps/ext2/inode.c b/rosapps/ext2/inode.c
new file mode 100644 (file)
index 0000000..c05ff51
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/inode.c
+ * PURPOSE:          Manipulating inodes
+ * PROGRAMMER:       David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ *          26/12/98: Created
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include <ntddk.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ***************************************************************/
+
+struct ext2_group_desc* Ext2LoadGroupDesc(PDEVICE_EXTENSION DeviceExt,
+                                         ULONG block_group)
+{
+   struct ext2_group_desc* buffer;
+   ULONG block;
+   struct ext2_group_desc* gdp;
+
+   buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
+
+   block = block_group / (BLOCKSIZE / sizeof(struct ext2_group_desc));
+
+   Ext2ReadSectors(DeviceExt->StorageDevice,
+                  2 + block,
+                  1,
+                  buffer);
+
+   gdp = &buffer[block_group % (BLOCKSIZE / sizeof(struct ext2_group_desc))];
+
+   DPRINT("gdp->bg_free_blocks_count %d\n",gdp->bg_free_blocks_count);
+   DPRINT("gdp->bg_inode_table %d\n",gdp->bg_inode_table);
+
+   return(gdp);
+
+}
+
+#define INODES_PER_PAGE (PAGE_SIZE / sizeof(struct ext2_inode))
+#define INODES_PER_BLOCK (BLOCKSIZE / sizeof(struct ext2_inode))
+
+VOID Ext2LoadInode(PDEVICE_EXTENSION DeviceExt,
+                  ULONG ino,
+                  PEXT2_INODE Inode)
+{
+   ULONG block_group;
+   struct ext2_group_desc* gdp;
+   ULONG offset;
+   ULONG dsec;
+   BOOLEAN Uptodate;
+   struct ext2_inode* ibuffer;
+
+   DPRINT("Ext2LoadInode(DeviceExt %x, ino %d, Inode %x)\n",
+         DeviceExt, ino, Inode);
+
+   block_group = (ino - 1) / DeviceExt->superblock->s_inodes_per_group;
+
+   DPRINT("block_group %d\n",block_group);
+
+   gdp = Ext2LoadGroupDesc(DeviceExt, block_group);
+
+   offset = (ino - 1) % DeviceExt->superblock->s_inodes_per_group;
+
+   DPRINT("offset %d\n", offset);
+
+   dsec = (gdp->bg_inode_table + (offset / INODES_PER_BLOCK)) * BLOCKSIZE;
+
+   DPRINT("dsec %d (dsec/BLOCKSIZE) %d PAGE_ROUND_DOWN(dsec) %d\n",
+         dsec, (dsec/BLOCKSIZE), PAGE_ROUND_DOWN(dsec));
+
+   CcRequestCachePage(DeviceExt->Bcb,
+                     PAGE_ROUND_DOWN(dsec),
+                     &Inode->BaseAddress,
+                     &Uptodate,
+                     &Inode->CacheSeg);
+   DPRINT("PAGE_ROUND_DOWN(dsec)/BLOCKSIZE %d\n",
+         PAGE_ROUND_DOWN(dsec)/BLOCKSIZE);
+   if (!Uptodate)
+     {
+       Ext2ReadSectors(DeviceExt->StorageDevice,
+                       PAGE_ROUND_DOWN(dsec) / BLOCKSIZE,
+                       4,
+                       Inode->BaseAddress);
+     }
+   ibuffer = ((struct ext2_inode *)Inode->BaseAddress) +
+             (dsec - PAGE_ROUND_DOWN(dsec));
+   DPRINT("Inode->BaseAddress 0x%x ibuffer 0x%x\n",
+         Inode->BaseAddress, ibuffer);
+   Inode->inode = &ibuffer[offset % INODES_PER_PAGE];
+
+   DPRINT("inode->i_uid %d\n",Inode->inode->i_uid);
+   DPRINT("inode->i_links_count %d\n",Inode->inode->i_links_count);
+   DPRINT("inode->i_blocks %d\n",Inode->inode->i_blocks);
+
+   DPRINT("Ext2LoadInode() finished\n");
+}
+
+VOID Ext2ReleaseInode(PDEVICE_EXTENSION DeviceExt,
+                     PEXT2_INODE Inode)
+{
+   CcReleaseCachePage(DeviceExt->Bcb,
+                     Inode->CacheSeg,
+                     TRUE);
+   Inode->CacheSeg = NULL;
+   Inode->BaseAddress = NULL;
+   Inode->inode = NULL;
+}
+
+VOID Ext2ReadInode(PDEVICE_EXTENSION DeviceExt,
+                  ULONG ino,
+                  struct ext2_inode* inode)
+{
+   ULONG block_group;
+   struct ext2_group_desc* gdp;
+   ULONG offset;
+   struct ext2_inode* buffer;
+
+   DPRINT("Ext2ReadInode(DeviceExt %x, ino %d, inode %x)\n",
+         DeviceExt,ino,inode);
+
+   block_group = (ino - 1) / DeviceExt->superblock->s_inodes_per_group;
+
+   gdp = Ext2LoadGroupDesc(DeviceExt, block_group);
+
+
+
+   offset = (ino - 1) % DeviceExt->superblock->s_inodes_per_group;
+
+   buffer = ExAllocatePool(NonPagedPool, BLOCKSIZE);
+   Ext2ReadSectors(DeviceExt->StorageDevice,
+                  gdp->bg_inode_table + (offset / INODES_PER_BLOCK),
+                  1,
+                  buffer);
+   memcpy(inode,&buffer[offset % INODES_PER_BLOCK],sizeof(struct ext2_inode));
+
+   DPRINT("inode->i_uid %d\n",inode->i_uid);
+   DPRINT("inode->i_links_count %d\n",inode->i_links_count);
+   DPRINT("inode->i_blocks %d\n",inode->i_blocks);
+
+}
diff --git a/rosapps/ext2/quota.c b/rosapps/ext2/quota.c
new file mode 100644 (file)
index 0000000..2db7af0
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/quota.c
+ * PURPOSE:          Quota support
+ * PROGRAMMER:       David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+#include <wchar.h>
+#include <string.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ****************************************************************/
+
+NTSTATUS STDCALL
+Ext2QueryQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   NTSTATUS Status;
+
+   Status = STATUS_NOT_IMPLEMENTED;
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
+
+NTSTATUS STDCALL
+Ext2SetQuota(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   NTSTATUS Status;
+
+   Status = STATUS_NOT_IMPLEMENTED;
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
diff --git a/rosapps/ext2/rw.c b/rosapps/ext2/rw.c
new file mode 100644 (file)
index 0000000..1788408
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/super.c
+ * PURPOSE:          ext2 filesystem
+ * PROGRAMMER:       David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+#include <string.h>
+
+#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS Ext2ReadPage(PDEVICE_EXTENSION DeviceExt,
+                     PEXT2_FCB Fcb,
+                     PVOID Buffer,
+                     ULONG Offset)
+{
+   ULONG block, i;
+
+   for (i=0; i<4; i++)
+     {
+       block = Ext2BlockMap(DeviceExt,
+                            Fcb->i.inode,
+                            Offset + i);
+       Ext2ReadSectors(DeviceExt->StorageDevice,
+                       block,
+                       1,
+                       Buffer + (i*BLOCKSIZE));
+     }
+   return(STATUS_SUCCESS);
+}
+
+NTSTATUS Ext2ReadFile(PDEVICE_EXTENSION DeviceExt,
+                     PFILE_OBJECT FileObject,
+                     PVOID Buffer,
+                     ULONG Length,
+                     LARGE_INTEGER OffsetL)
+{
+   PVOID BaseAddress;
+   BOOLEAN Uptodate = FALSE;
+   PCACHE_SEGMENT CacheSeg;
+   ULONG Offset = (ULONG)OffsetL.u.LowPart;
+   PEXT2_FCB Fcb;
+   ULONG block, i, Delta;
+   DPRINT("Ext2ReadFile(DeviceExt %x, FileObject %x, Buffer %x, Length %d, \n"
+         "OffsetL %d)\n",DeviceExt,FileObject,Buffer,Length,(ULONG)OffsetL);
+
+   Fcb = (PEXT2_FCB)FileObject->FsContext;
+
+   Ext2LoadInode(DeviceExt,
+                Fcb->inode,
+                &Fcb->i);
+
+   if (Offset >= Fcb->i.inode->i_size)
+     {
+       DPRINT("Returning end of file\n");
+       return(STATUS_END_OF_FILE);
+     }
+   if ((Offset + Length) > Fcb->i.inode->i_size)
+     {
+       Length = Fcb->i.inode->i_size - Offset;
+     }
+
+   Ext2ReleaseInode(DeviceExt,
+                   &Fcb->i);
+
+   if ((Offset % PAGE_SIZE) != 0)
+     {
+       Delta = min(PAGE_SIZE - (Offset % PAGE_SIZE),Length);
+       CcRequestCachePage(Fcb->Bcb,
+                          Offset,
+                          &BaseAddress,
+                          &Uptodate,
+                          &CacheSeg);
+       if (Uptodate == FALSE)
+         {
+            Ext2ReadPage(DeviceExt,
+                         Fcb,
+                         BaseAddress,
+                         Offset / BLOCKSIZE);
+         }
+       memcpy(Buffer, BaseAddress + (Offset % PAGE_SIZE), Delta);
+       CcReleaseCachePage(Fcb->Bcb,
+                          CacheSeg,
+                          TRUE);
+       Length = Length - Delta;
+       Offset = Offset + Delta;
+       Buffer = Buffer + Delta;
+     }
+   CHECKPOINT;
+   for (i=0; i<(Length/PAGE_SIZE); i++)
+     {
+       CcRequestCachePage(Fcb->Bcb,
+                          Offset,
+                          &BaseAddress,
+                          &Uptodate,
+                          &CacheSeg);
+       if (Uptodate == FALSE)
+         {
+            Ext2ReadPage(DeviceExt,
+                         Fcb,
+                         BaseAddress,
+                         (Offset / BLOCKSIZE));
+         }
+       memcpy(Buffer, BaseAddress, PAGE_SIZE);
+       CcReleaseCachePage(Fcb->Bcb,
+                          CacheSeg,
+                          TRUE);
+       Length = Length - PAGE_SIZE;
+       Offset = Offset + PAGE_SIZE;
+       Buffer = Buffer + PAGE_SIZE;
+     }
+   CHECKPOINT;
+   if ((Length % PAGE_SIZE) != 0)
+     {
+       CcRequestCachePage(Fcb->Bcb,
+                          Offset,
+                          &BaseAddress,
+                          &Uptodate,
+                          &CacheSeg);
+       if (Uptodate == FALSE)
+         {
+            Ext2ReadPage(DeviceExt,
+                         Fcb,
+                         BaseAddress,
+                         (Offset / BLOCKSIZE));
+         }
+       DPRINT("Copying %x to %x Length %d\n",BaseAddress,Buffer,Length);
+       memcpy(Buffer,BaseAddress,Length);
+       CcReleaseCachePage(Fcb->Bcb,
+                          CacheSeg,
+                          TRUE);
+     }
+   CHECKPOINT;
+
+   return(STATUS_SUCCESS);
+}
+
+
+NTSTATUS STDCALL
+Ext2Write(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2Write(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
+   Irp->IoStatus.Information = 0;
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2FlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2FlushBuffers(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2Shutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2Shutdown(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2Cleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DbgPrint("Ext2Cleanup(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+
+   DbgPrint("Ext2Cleanup() finished\n");
+
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2Read(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   ULONG Length;
+   PVOID Buffer;
+   PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+   PFILE_OBJECT FileObject = Stack->FileObject;
+   PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
+   NTSTATUS Status;
+
+   DPRINT("Ext2Read(DeviceObject %x, FileObject %x, Irp %x)\n",
+         DeviceObject, FileObject, Irp);
+
+   Length = Stack->Parameters.Read.Length;
+   CHECKPOINT;
+   Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
+   CHECKPOINT;
+   CHECKPOINT;
+
+   Status = Ext2ReadFile(DeviceExt,FileObject,Buffer,Length,
+                        Stack->Parameters.Read.ByteOffset);
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = Length;
+   IoCompleteRequest(Irp,IO_NO_INCREMENT);
+
+   return(Status);
+}
diff --git a/rosapps/ext2/security.c b/rosapps/ext2/security.c
new file mode 100644 (file)
index 0000000..3862816
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/security.c
+ * PURPOSE:          Security support
+ * PROGRAMMER:       David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+#include <wchar.h>
+#include <string.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* FUNCTIONS ****************************************************************/
+
+NTSTATUS STDCALL
+Ext2QuerySecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2QuerySecurity(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+   return(STATUS_UNSUCCESSFUL);
+}
+
+NTSTATUS STDCALL
+Ext2SetSecurity(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   DPRINT("Ext2SetSecurity(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
+
+   Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+   Irp->IoStatus.Information = 0;
+   return(STATUS_UNSUCCESSFUL);
+}
diff --git a/rosapps/ext2/super.c b/rosapps/ext2/super.c
new file mode 100644 (file)
index 0000000..43f921d
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/fs/ext2/super.c
+ * PURPOSE:          ext2 filesystem
+ * PROGRAMMER:       David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntddk.h>
+
+//#define NDEBUG
+#include <debug.h>
+
+#include "ext2fs.h"
+
+/* GLOBALS *****************************************************************/
+
+static PDRIVER_OBJECT DriverObject;
+
+/* FUNCTIONS ****************************************************************/
+
+NTSTATUS STDCALL
+Ext2Close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION Stack;
+   PFILE_OBJECT FileObject;
+   PDEVICE_EXTENSION DeviceExtension;
+   NTSTATUS Status;
+   PEXT2_FCB Fcb;
+
+   DbgPrint("Ext2Close(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
+
+   Stack = IoGetCurrentIrpStackLocation(Irp);
+   FileObject = Stack->FileObject;
+   DeviceExtension = DeviceObject->DeviceExtension;
+
+   if (FileObject == DeviceExtension->FileObject)
+     {
+       Status = STATUS_SUCCESS;
+
+       Irp->IoStatus.Status = Status;
+       Irp->IoStatus.Information = 0;
+
+       IoCompleteRequest(Irp, IO_NO_INCREMENT);
+       return(Status);
+     }
+
+   Fcb = (PEXT2_FCB)FileObject->FsContext;
+   if (Fcb != NULL)
+     {
+       if (Fcb->Bcb != NULL)
+         {
+            CcRosReleaseFileCache(FileObject, Fcb->Bcb);
+         }
+       ExFreePool(Fcb);
+       FileObject->FsContext = NULL;
+     }
+
+   Status = STATUS_SUCCESS;
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
+
+NTSTATUS Ext2Mount(PDEVICE_OBJECT DeviceToMount)
+{
+   PDEVICE_OBJECT DeviceObject;
+   PDEVICE_EXTENSION DeviceExt;
+   PVOID BlockBuffer;
+   struct ext2_super_block* superblock;
+
+   DPRINT("Ext2Mount(DeviceToMount %x)\n",DeviceToMount);
+
+   BlockBuffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
+   Ext2ReadSectors(DeviceToMount,
+                  1,
+                  1,
+                  BlockBuffer);
+   superblock = BlockBuffer;
+
+   if (superblock->s_magic != EXT2_SUPER_MAGIC)
+     {
+       ExFreePool(BlockBuffer);
+       return(STATUS_UNRECOGNIZED_VOLUME);
+     }
+   DPRINT("Volume recognized\n");
+   DPRINT("s_inodes_count %d\n",superblock->s_inodes_count);
+   DPRINT("s_blocks_count %d\n",superblock->s_blocks_count);
+
+   IoCreateDevice(DriverObject,
+                 sizeof(DEVICE_EXTENSION),
+                 NULL,
+                 FILE_DEVICE_FILE_SYSTEM,
+                 0,
+                 FALSE,
+                 &DeviceObject);
+   DPRINT("DeviceObject %x\n",DeviceObject);
+   DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
+   DeviceExt = (PVOID)DeviceObject->DeviceExtension;
+   DPRINT("DeviceExt %x\n",DeviceExt);
+
+  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("DeviceExt->StorageDevice %x\n", DeviceExt->StorageDevice);
+   DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
+   DeviceExt->superblock = superblock;
+   CcRosInitializeFileCache(DeviceExt->FileObject,
+                           &DeviceExt->Bcb,
+                           PAGE_SIZE * 3);
+
+   DPRINT("Ext2Mount() = STATUS_SUCCESS\n");
+
+   return(STATUS_SUCCESS);
+}
+
+NTSTATUS STDCALL
+Ext2FileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+   PVPB        vpb = Stack->Parameters.Mount.Vpb;
+   PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
+   NTSTATUS Status;
+
+   Status = Ext2Mount(DeviceToMount);
+
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = 0;
+
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   return(Status);
+}
+
+NTSTATUS STDCALL
+DriverEntry(PDRIVER_OBJECT _DriverObject,
+           PUNICODE_STRING RegistryPath)
+/*
+ * FUNCTION: Called by the system to initalize the driver
+ * ARGUMENTS:
+ *           DriverObject = object describing this driver
+ *           RegistryPath = path to our configuration entries
+ * RETURNS: Success or failure
+ */
+{
+   PDEVICE_OBJECT DeviceObject;
+   NTSTATUS ret;
+   UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Ext2Fsd");
+
+   DbgPrint("Ext2 FSD 0.0.1\n");
+
+   DriverObject = _DriverObject;
+
+   ret = IoCreateDevice(DriverObject,
+                       0,
+                       &DeviceName,
+                       FILE_DEVICE_FILE_SYSTEM,
+                       0,
+                       FALSE,
+                       &DeviceObject);
+   if (ret!=STATUS_SUCCESS)
+     {
+       return(ret);
+     }
+
+   DeviceObject->Flags=0;
+   DriverObject->MajorFunction[IRP_MJ_CLOSE] = Ext2Close;
+   DriverObject->MajorFunction[IRP_MJ_CREATE] = Ext2Create;
+   DriverObject->MajorFunction[IRP_MJ_READ] = Ext2Read;
+   DriverObject->MajorFunction[IRP_MJ_WRITE] = Ext2Write;
+   DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
+                      Ext2FileSystemControl;
+   DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
+                      Ext2DirectoryControl;
+   DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
+                      Ext2QueryInformation;
+   DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = Ext2SetInformation;
+   DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = Ext2FlushBuffers;
+   DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = Ext2Shutdown;
+   DriverObject->MajorFunction[IRP_MJ_CLEANUP] = Ext2Cleanup;
+   DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = Ext2QuerySecurity;
+   DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = Ext2SetSecurity;
+   DriverObject->MajorFunction[IRP_MJ_QUERY_QUOTA] = Ext2QueryQuota;
+   DriverObject->MajorFunction[IRP_MJ_SET_QUOTA] = Ext2SetQuota;
+
+   DriverObject->DriverUnload = NULL;
+
+   IoRegisterFileSystem(DeviceObject);
+
+   return(STATUS_SUCCESS);
+}
+
diff --git a/rosapps/gettype/gettype.c b/rosapps/gettype/gettype.c
new file mode 100644 (file)
index 0000000..ea98d32
--- /dev/null
@@ -0,0 +1,394 @@
+/*
+ * ReactOS Win32 Applications
+ * Copyright (C) 2005 ReactOS Team
+ *
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS arp utility
+ * FILE:        apps/utils/gettype/gettype.c
+ * PURPOSE:
+ * PROGRAMMERS: Brandon Turner (turnerb7@msu.edu)
+ * REVISIONS:
+ *   GM 30/10/05 Created
+ *
+ * FIXME: gettype only supports local computer.
+ */
+#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
+#include <lm.h>
+#include <shellapi.h>
+
+enum
+{
+       GETTYPE_ROLE    = 0x001,
+       GETTYPE_HELP    = 0x002,
+       GETTYPE_SP              = 0x004,
+       GETTYPE_VER             = 0x008,
+       GETTYPE_MINV    = 0x010,
+       GETTYPE_MAJV    = 0x020,
+       GETTYPE_TYPE    = 0x040,
+       GETTYPE_BUILD   = 0x080
+};
+
+INT 
+GetVersionNumber(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
+{
+       INT VersionNumber = 255;
+       if(pBuf102 != NULL && !bLocal)
+       {
+               VersionNumber = pBuf102->sv102_version_major * 1000;
+               VersionNumber += (pBuf102->sv102_version_minor * 100);
+       }
+       else if(bLocal)
+       {               
+               VersionNumber = osvi->dwMajorVersion * 1000;
+               VersionNumber += (osvi->dwMinorVersion * 100);
+       }
+
+       return VersionNumber;
+}
+
+INT 
+GetMajValue(BOOL Major, BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
+{
+       INT VersionNumber = 255;
+       if(pBuf102 != NULL && !bLocal)
+       {
+               if(Major)
+                       VersionNumber = pBuf102->sv102_version_major * 1000;
+               else
+                       VersionNumber = pBuf102->sv102_version_minor * 100;
+       }
+       else
+       {
+               if(Major)
+                       VersionNumber = osvi->dwMajorVersion * 1000;
+               else
+                       VersionNumber = osvi->dwMinorVersion * 100;
+       }
+       return VersionNumber;
+}
+
+INT 
+GetSystemRole(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
+{
+
+       if(pBuf102 != NULL && !bLocal)
+       {
+               if ((pBuf102->sv102_type & SV_TYPE_DOMAIN_CTRL) ||
+                       (pBuf102->sv102_type & SV_TYPE_DOMAIN_BAKCTRL))
+                       return 1;
+               else if(pBuf102->sv102_type & SV_TYPE_SERVER_NT)
+                       return 2;
+               else
+                       return 3;
+       }
+       else
+       {
+               if(osvi->wProductType == VER_NT_DOMAIN_CONTROLLER)
+                       return 1;
+               else if(osvi->wProductType == VER_NT_SERVER)
+                       return 2;
+               else if(osvi->wProductType == VER_NT_WORKSTATION)
+                       return 3;
+       }
+       return 255;
+
+}
+
+INT 
+GetServicePack(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102, TCHAR * Server)
+{
+       INT SPNumber = 255;
+       if(!bLocal)
+       {
+               /* FIXME: Use Registry to get value */
+       }
+       else
+       {
+               SPNumber = osvi->wServicePackMajor;
+       }
+       return SPNumber;
+}
+
+INT 
+GetBuildNumber(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
+{
+       INT BuildNum = 255;
+       if(!bLocal)
+       {
+               /* FIXME: Use Registry to get value */
+       }
+       else
+       {
+               BuildNum = osvi->dwBuildNumber;
+       }
+       return BuildNum;
+}
+
+INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
+{
+       if(bLocal)
+       {
+               if(osvi->dwMajorVersion == 5)
+               {
+                       if(osvi->dwMinorVersion == 1)
+                       {
+                               if(osvi->wSuiteMask & VER_SUITE_PERSONAL)
+                                       return 1;
+                               else
+                                       return 2;
+                       }
+                       else if(osvi->dwMinorVersion == 2)
+                       {
+                               if(osvi->wSuiteMask & VER_SUITE_BLADE)
+                                       return 6;
+                               else if(osvi->wSuiteMask & VER_SUITE_DATACENTER)
+                                       return 5;
+                               else if(osvi->wSuiteMask & VER_SUITE_ENTERPRISE)
+                                       return 4;
+                               else 
+                                       return 3;
+                       }
+               }
+       }
+       else
+       {
+               /* FIXME: Get this value from registry */
+       }
+       return 255;
+}
+
+VOID 
+GetBasicInfo(LPOSVERSIONINFOEX osvi, TCHAR * HostName, TCHAR * OSName, TCHAR * Version, TCHAR * Role, TCHAR * Components)
+{
+       /* Host Name - COMPUTERNAME*/
+       DWORD  bufCharCount = 1024;
+       GetComputerName(HostName, &bufCharCount);
+
+
+       /* OSName - Windows XP Home Editition */
+       if(osvi->dwMajorVersion == 4)
+       {
+               _tcscpy(OSName, _T("Microsoft Windows NT 4.0 "));
+       }
+       else if(osvi->dwMajorVersion == 5)
+       {
+               if(osvi->dwMajorVersion == 0)
+               {
+                       _tcscpy(OSName, _T("Microsoft Windows 2000 "));
+               }
+               else if(osvi->dwMinorVersion == 1)
+               {
+                       _tcscpy(OSName, _T("Microsoft Windows XP "));
+               }
+               else if(osvi->dwMinorVersion == 2)
+               {
+                       _tcscpy(OSName, _T("Microsoft Windows Server 2003 "));
+               }
+       }
+       else if(osvi->dwMajorVersion == 6)
+       {
+               _tcscpy(OSName, _T("Microsoft Windows Vista "));
+       }
+       else 
+       {
+               _tcscpy(OSName, _T("Microsoft Windows "));
+       }
+
+       if(osvi->wSuiteMask & VER_SUITE_BLADE)
+               _tcscat(OSName, _T("Web Edition"));
+       if(osvi->wSuiteMask & VER_SUITE_DATACENTER)
+               _tcscat(OSName, _T("Datacenter"));
+       if(osvi->wSuiteMask & VER_SUITE_ENTERPRISE)
+               _tcscat(OSName, _T("Enterprise"));
+       if(osvi->wSuiteMask & VER_SUITE_EMBEDDEDNT)
+               _tcscat(OSName, _T("Embedded"));
+       if(osvi->wSuiteMask & VER_SUITE_PERSONAL)
+               _tcscat(OSName, _T("Home Edition"));
+       if(osvi->wSuiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED && osvi->wSuiteMask & VER_SUITE_SMALLBUSINESS)
+               _tcscat(OSName, _T("Small Bussiness Edition"));
+
+       /* Version - 5.1 Build 2600 Serivce Pack 2 */
+       _stprintf(Version, _T("%d.%d Build %d %s"),(int)osvi->dwMajorVersion,(int)osvi->dwMinorVersion,(int)osvi->dwBuildNumber, osvi->szCSDVersion);
+
+       /* Role - Workgroup / Server / Domain Controller */
+       if(osvi->wProductType == VER_NT_DOMAIN_CONTROLLER)
+               _tcscpy(Role, _T("Domain Controller"));
+       else if(osvi->wProductType == VER_NT_SERVER)
+               _tcscpy(Role, _T("Server"));
+       else if(osvi->wProductType == VER_NT_WORKSTATION)
+               _tcscpy(Role, _T("Workgroup"));
+
+       /* Components - FIXME: what is something that might be installed? */
+       _tcscat(Components, _T("Not Installed"));
+
+}
+
+INT
+main (VOID)
+{
+       DWORD Operations = 0;
+       INT ret = 255;
+       INT i = 0;
+       INT argc = 0;
+       /* True if the target is local host */
+       BOOL bLocal = TRUE;
+       DWORD nStatus = 0;
+       TCHAR ServerName[32];
+       TCHAR RemoteResource[32];
+       TCHAR UserName[32] = _T("");
+       TCHAR Password[32] = _T("");
+       LPOSVERSIONINFOEX osvi = NULL;
+       LPSERVER_INFO_102 pBuf102 = NULL;
+       LPTSTR * argv;
+       osvi = (LPOSVERSIONINFOEX)malloc(sizeof(LPOSVERSIONINFOEX));
+       pBuf102 = (LPSERVER_INFO_102)malloc(sizeof(LPSERVER_INFO_102));
+
+       /* Get the command line correctly since it is unicode */
+       argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+
+
+       /* Process flags */
+       if(argc)
+       {
+               for (i = 1; i < argc; i++)
+               {
+                       if(!_tcsicmp(argv[i], _T("/ROLE")) && !Operations)
+                               Operations |= GETTYPE_ROLE;
+                       else if(!_tcsicmp(argv[i], _T("/VER")) && !Operations)
+                               Operations |= GETTYPE_VER;
+                       else if(!_tcsicmp(argv[i], _T("/MAJV")) && !Operations)
+                               Operations |= GETTYPE_MAJV;
+                       else if(!_tcsicmp(argv[i], _T("/MINV")) && !Operations)
+                               Operations |= GETTYPE_MINV;
+                       else if(!_tcsicmp(argv[i], _T("/SP")) && !Operations)
+                               Operations |= GETTYPE_SP;
+                       else if(!_tcsicmp(argv[i], _T("/BUILD")) && !Operations)
+                               Operations |= GETTYPE_BUILD;
+                       else if(!_tcsicmp(argv[i], _T("/TYPE")) && !Operations)
+                               Operations |= GETTYPE_TYPE;
+                       else if(!_tcsicmp(argv[i], _T("/?")) && !Operations)
+                               Operations |= GETTYPE_HELP;
+                       else if(!_tcsicmp(argv[i], _T("/S")) && i + 1 < argc)
+                       {
+                               _tcscpy(ServerName,argv[++i]);
+                               bLocal = FALSE;
+                       }
+                       else if(!wcsicmp(argv[i], L"/U") && i + 1 < argc)
+                               _tcscpy(UserName,argv[++i]);
+                       else if(!wcsicmp(argv[i], L"/P") && i + 1 < argc)
+                               _tcscpy(Password,argv[++i]);
+                       else
+                       {
+                               wprintf(L"Error in paramters, please see usage\n");
+                               return 255;
+                       }
+               }
+       }
+
+       /* Some debug info */
+       //_tprintf(_T("%s - %s - %s - %d"), ServerName, UserName, Password, (int)Operations);
+
+       if(!bLocal)
+       {
+               NETRESOURCE nr;
+
+
+               /* \\*IP or Computer Name*\*Share* */
+               _stprintf(RemoteResource, _T("\\\\%s\\IPC$"), ServerName);
+
+               nr.dwType = RESOURCETYPE_ANY;
+               nr.lpLocalName = NULL;
+               nr.lpProvider= NULL;
+               nr.lpRemoteName = RemoteResource;
+
+               /* open a connection to the server with difference user/pass. */
+               nStatus = WNetAddConnection2(&nr, UserName[0]?UserName:NULL,Password[0]?Password:NULL, CONNECT_INTERACTIVE | CONNECT_COMMANDLINE);
+
+               if(nStatus != NO_ERROR)
+               {
+                       _tprintf(_T("Error:%d-%d\n"),(int)nStatus,GetLastError());
+                       return 255;
+               }
+       }
+
+       /* Use GetVersionEx for anything that we are looking for locally */
+       if(bLocal)
+       {
+               osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+               if(!GetVersionEx((LPOSVERSIONINFO)osvi))
+               {
+                       _tprintf(_T("Failed to get local information\n"));
+                       return 255;
+               }
+       }
+       else
+       {
+               nStatus = NetServerGetInfo(NULL,102,(LPBYTE *)&pBuf102);
+               if (nStatus != NERR_Success)
+               {
+                       _tprintf(_T("Failed to connection to remote machine\n"));
+                       return 255;
+               }
+
+       }
+
+       if(Operations & GETTYPE_VER)
+       {
+               ret = GetVersionNumber(bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_MAJV)
+       {
+               ret = GetMajValue(TRUE, bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_MINV)
+       {
+               ret = GetMajValue(FALSE, bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_ROLE)
+       {
+               ret = GetSystemRole(bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_SP)
+       {
+               ret = GetServicePack(bLocal, osvi, pBuf102, ServerName);
+       }
+       else if(Operations & GETTYPE_BUILD)
+       {
+               ret = GetBuildNumber(bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_TYPE)
+       {
+               ret = GetType(bLocal, osvi, pBuf102);
+       }
+       else if(Operations & GETTYPE_HELP)
+       {
+               wprintf(L"GETTYPE  [/ROLE | /SP | /VER | /MAJV | /MINV | /TYPE | /BUILD]");
+               ret = 0;
+       }
+       else if(!Operations && bLocal)
+       {
+               /* FIXME: what happens when no flags except remote machine, does it
+               it print this info for the remote server? */
+               TCHAR HostName[1024] = _T("");
+               TCHAR OSName[1024] = _T("");
+               TCHAR VersionInfo[1024] = _T("");
+               TCHAR Role[1024] = _T("");
+               TCHAR Components[1024] = _T("");
+               GetBasicInfo(osvi, HostName, OSName, VersionInfo, Role, Components);
+               _tprintf(_T("\nHostname: %s\nName: %s\nVersion:%s\n") ,HostName, OSName, VersionInfo);
+               _tprintf(_T("Role: %s\nComponent: %s\n"), Role, Components);
+               ret = 0;
+       }
+
+       /* Clean up some stuff that that was opened */
+       if(pBuf102)
+               NetApiBufferFree(pBuf102);
+       LocalFree(argv);
+       if(!bLocal)
+       {
+               WNetCancelConnection2(RemoteResource,0,TRUE);
+       }
+       return ret;
+}
diff --git a/rosapps/gettype/gettype.rbuild b/rosapps/gettype/gettype.rbuild
new file mode 100644 (file)
index 0000000..3ea425f
--- /dev/null
@@ -0,0 +1,12 @@
+<module name="gettype" type="win32cui" installbase="system32" installname="gettype.exe">
+       <include base="gettype">.</include>
+       <define name="_WIN32_WINNT">0x0501</define>
+       <define name="__USE_W32API" />
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <library>kernel32</library>
+       <library>shell32</library>
+       <library>mpr</library>
+       <library>netapi32</library>
+       <file>gettype.c</file>
+</module>
diff --git a/rosapps/green/createclose.c b/rosapps/green/createclose.c
new file mode 100644 (file)
index 0000000..ef8f665
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/base/green/createclose.c
+ * PURPOSE:     IRP_MJ_CREATE, IRP_MJ_CLOSE and IRP_MJ_CLEANUP operations
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+NTSTATUS
+GreenCreate(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp)
+{
+       DPRINT("IRP_MJ_CREATE\n");
+
+       Irp->IoStatus.Status = STATUS_SUCCESS;
+       Irp->IoStatus.Information = 0;
+       IoCompleteRequest(Irp, IO_NO_INCREMENT);
+       return STATUS_SUCCESS;
+}
+
+NTSTATUS
+GreenClose(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp)
+{
+       DPRINT("IRP_MJ_CLOSE\n");
+
+       Irp->IoStatus.Status = STATUS_SUCCESS;
+       Irp->IoStatus.Information = 0;
+       IoCompleteRequest(Irp, IO_NO_INCREMENT);
+       return STATUS_SUCCESS;
+}
diff --git a/rosapps/green/dispatch.c b/rosapps/green/dispatch.c
new file mode 100644 (file)
index 0000000..d40df5c
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/base/green/dispatch.c
+ * PURPOSE:     Dispatch routines
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+NTSTATUS NTAPI
+GreenDispatch(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp)
+{
+       ULONG MajorFunction;
+       GREEN_DEVICE_TYPE DeviceType;
+       ULONG_PTR Information;
+       NTSTATUS Status;
+
+       MajorFunction = IoGetCurrentIrpStackLocation(Irp)->MajorFunction;
+       DeviceType = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
+
+       Information = Irp->IoStatus.Information;
+       Status = Irp->IoStatus.Status;
+
+       DPRINT("Dispatching major function 0x%lx, DeviceType %u\n",
+               MajorFunction, DeviceType);
+
+       if (DeviceType == PassThroughFDO)
+       {
+               IoSkipCurrentIrpStackLocation(Irp);
+               return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
+       }
+       else if (MajorFunction == IRP_MJ_CREATE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
+               return GreenCreate(DeviceObject, Irp);
+       else if (MajorFunction == IRP_MJ_CLOSE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
+               return GreenClose(DeviceObject, Irp);
+       else if ((MajorFunction == IRP_MJ_CREATE || MajorFunction == IRP_MJ_CLOSE || MajorFunction == IRP_MJ_CLEANUP)
+               && (DeviceType == KeyboardFDO || DeviceType == ScreenFDO))
+       {
+               IoSkipCurrentIrpStackLocation(Irp);
+               return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
+       }
+       else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == GreenFDO)
+       {
+               return KeyboardInternalDeviceControl(
+                       ((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->KeyboardFdo,
+                       Irp);
+       }
+       else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == KeyboardFDO)
+               return KeyboardInternalDeviceControl(DeviceObject, Irp);
+       else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == GreenFDO)
+       {
+               return ScreenDeviceControl(
+                       ((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ScreenFdo,
+                       Irp);
+       }
+       else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == ScreenFDO)
+               return ScreenDeviceControl(DeviceObject, Irp);
+       else if (MajorFunction == IRP_MJ_WRITE && DeviceType == ScreenFDO)
+               return ScreenWrite(DeviceObject, Irp);
+       else if (MajorFunction == IRP_MJ_PNP && (DeviceType == KeyboardFDO || DeviceType == ScreenFDO))
+       {
+               IoSkipCurrentIrpStackLocation(Irp);
+               return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
+       }
+       else if (MajorFunction == IRP_MJ_PNP && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
+               return GreenPnp(DeviceObject, Irp);
+       else if (MajorFunction == IRP_MJ_POWER && DeviceType == GreenFDO)
+               return GreenPower(DeviceObject, Irp);
+       else
+       {
+               DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
+                       MajorFunction, DeviceType);
+               switch (DeviceType)
+               {
+                       case KeyboardFDO:
+                       case ScreenFDO:
+                       {
+                               IoSkipCurrentIrpStackLocation(Irp);
+                               return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
+                       }
+                       case GreenFDO:
+                       {
+                               PDRIVER_OBJECT DriverObject;
+                               PGREEN_DRIVER_EXTENSION DriverExtension;
+                               DriverObject = DeviceObject->DriverObject;
+                               DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
+                               IoSkipCurrentIrpStackLocation(Irp);
+                               return IoCallDriver(DriverExtension->LowerDevice, Irp);
+                       }
+                       default:
+                               ASSERT(FALSE);
+               }
+       }
+
+       Irp->IoStatus.Information = Information;
+       Irp->IoStatus.Status = Status;
+       IoCompleteRequest (Irp, IO_NO_INCREMENT);
+       return Status;
+}
diff --git a/rosapps/green/green.c b/rosapps/green/green.c
new file mode 100644 (file)
index 0000000..5834f3b
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/base/green/green.c
+ * PURPOSE:     Driver entry point
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+VOID NTAPI
+DriverUnload(IN PDRIVER_OBJECT DriverObject)
+{
+       // nothing to do here yet
+}
+
+/*
+ * Standard DriverEntry method.
+ */
+NTSTATUS NTAPI
+DriverEntry(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PUNICODE_STRING RegistryPath)
+{
+       PGREEN_DRIVER_EXTENSION DriverExtension;
+       ULONG i;
+       NTSTATUS Status;
+
+       Status = IoAllocateDriverObjectExtension(
+               DriverObject,
+               DriverObject,
+               sizeof(GREEN_DRIVER_EXTENSION),
+               (PVOID*)&DriverExtension);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status);
+               return Status;
+       }
+       RtlZeroMemory(DriverExtension, sizeof(GREEN_DRIVER_EXTENSION));
+
+       Status = RtlDuplicateUnicodeString(
+               0,
+               RegistryPath,
+               &DriverExtension->RegistryPath);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("RtlDuplicateUnicodeString() failed with status 0x%08lx\n", Status);
+               return Status;
+       }
+
+       Status = ReadRegistryEntries(RegistryPath, DriverExtension);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("ReadRegistryEntries() failed with status 0x%08lx\n", Status);
+               return Status;
+       }
+
+       DriverObject->DriverUnload = DriverUnload;
+       DriverObject->DriverExtension->AddDevice = GreenAddDevice;
+
+       for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
+               DriverObject->MajorFunction[i] = GreenDispatch;
+
+       return STATUS_SUCCESS;
+}
diff --git a/rosapps/green/green.h b/rosapps/green/green.h
new file mode 100644 (file)
index 0000000..b54fa96
--- /dev/null
@@ -0,0 +1,192 @@
+#include <stdarg.h>
+#include <ntddk.h>
+#include <ndk/iotypes.h>
+#include <windef.h>
+#define WINBASEAPI
+typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
+#include <ntddser.h>
+#include <kbdmou.h>
+#include <wincon.h>
+#include <drivers/blue/ntddblue.h>
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlDuplicateUnicodeString(
+    IN ULONG Flags,
+    IN PCUNICODE_STRING SourceString,
+    OUT PUNICODE_STRING DestinationString
+);
+#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE         1
+
+#define INFINITE -1
+#define KEYBOARD_BUFFER_SIZE 100
+
+typedef enum
+{
+       GreenPDO,
+       ScreenPDO,
+       KeyboardPDO,
+       GreenFDO,
+       ScreenFDO,
+       KeyboardFDO,
+       PassThroughFDO,
+} GREEN_DEVICE_TYPE;
+
+typedef struct _COMMON_DEVICE_EXTENSION
+{
+       GREEN_DEVICE_TYPE Type;
+} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
+
+/* For PassThroughFDO devices */
+typedef struct _COMMON_FDO_DEVICE_EXTENSION
+{
+       GREEN_DEVICE_TYPE Type;
+       PDEVICE_OBJECT LowerDevice;
+} COMMON_FDO_DEVICE_EXTENSION, *PCOMMON_FDO_DEVICE_EXTENSION;
+
+/* For KeyboardFDO devices */
+typedef struct _KEYBOARD_DEVICE_EXTENSION
+{
+       COMMON_FDO_DEVICE_EXTENSION Common;
+       PDEVICE_OBJECT Green;
+
+       CONNECT_DATA ClassInformation;
+       HANDLE WorkerThreadHandle;
+       KDPC KeyboardDpc;
+
+       ULONG ActiveQueue;
+       ULONG InputDataCount[2];
+       KEYBOARD_INPUT_DATA KeyboardInputData[2][KEYBOARD_BUFFER_SIZE];
+} KEYBOARD_DEVICE_EXTENSION, *PKEYBOARD_DEVICE_EXTENSION;
+
+/* For ScreenFDO devices */
+typedef struct _SCREEN_DEVICE_EXTENSION
+{
+       COMMON_FDO_DEVICE_EXTENSION Common;
+       PDEVICE_OBJECT Green;
+
+       PUCHAR VideoMemory;   /* Pointer to video memory */
+       USHORT CharAttribute; /* Current color attribute */
+       ULONG  Mode;
+       UCHAR  ScanLines;     /* Height of a text line   */
+       UCHAR  Rows;          /* Number of rows          */
+       UCHAR  Columns;       /* Number of columns       */
+       UCHAR  TabWidth;
+
+       ULONG LogicalOffset;  /* Position of the cursor  */
+
+       UCHAR SendBuffer[1024];
+       ULONG SendBufferPosition;
+       PDEVICE_OBJECT PreviousBlue;
+} SCREEN_DEVICE_EXTENSION, *PSCREEN_DEVICE_EXTENSION;
+
+/* For GreenFDO devices */
+typedef struct _GREEN_DEVICE_EXTENSION
+{
+       COMMON_FDO_DEVICE_EXTENSION Common;
+       PDEVICE_OBJECT Serial;
+
+       SERIAL_LINE_CONTROL LineControl;
+       SERIAL_TIMEOUTS Timeouts;
+
+       PDEVICE_OBJECT KeyboardPdo;
+       PDEVICE_OBJECT ScreenPdo;
+       PDEVICE_OBJECT KeyboardFdo;
+       PDEVICE_OBJECT ScreenFdo;
+} GREEN_DEVICE_EXTENSION, *PGREEN_DEVICE_EXTENSION;
+
+typedef struct _GREEN_DRIVER_EXTENSION
+{
+       UNICODE_STRING RegistryPath;
+
+       UNICODE_STRING AttachedDeviceName;
+       ULONG DeviceReported;
+       ULONG SampleRate;
+
+       PDEVICE_OBJECT GreenMainDO;
+       PDEVICE_OBJECT LowerDevice;
+} GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
+
+/************************************ createclose.c */
+
+NTSTATUS
+GreenCreate(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+NTSTATUS
+GreenClose(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+/************************************ dispatch.c */
+
+NTSTATUS NTAPI
+GreenDispatch(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+/************************************ keyboard.c */
+
+NTSTATUS
+KeyboardAddDevice(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT Pdo);
+
+NTSTATUS
+KeyboardInternalDeviceControl(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+/************************************ misc.c */
+
+NTSTATUS
+GreenDeviceIoControl(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN ULONG CtlCode,
+       IN PVOID InputBuffer OPTIONAL,
+       IN ULONG InputBufferSize,
+       IN OUT PVOID OutputBuffer OPTIONAL,
+       IN OUT PULONG OutputBufferSize);
+
+NTSTATUS
+ReadRegistryEntries(
+       IN PUNICODE_STRING RegistryPath,
+       IN PGREEN_DRIVER_EXTENSION DriverExtension);
+
+/************************************ pnp.c */
+
+NTSTATUS NTAPI
+GreenAddDevice(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT Pdo);
+
+NTSTATUS
+GreenPnp(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+/************************************ power.c */
+
+NTSTATUS
+GreenPower(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+/************************************ screen.c */
+
+NTSTATUS
+ScreenAddDevice(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT Pdo);
+
+NTSTATUS
+ScreenWrite(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
+
+NTSTATUS
+ScreenDeviceControl(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp);
diff --git a/rosapps/green/green.inf b/rosapps/green/green.inf
new file mode 100644 (file)
index 0000000..805fbda
--- /dev/null
@@ -0,0 +1,96 @@
+; GREEN.INF
+
+; Installation file for Green (VT100 server emulator) driver
+
+[Version]
+Signature  = "$Windows NT$"
+;Signature  = "$ReactOS$"
+LayoutFile = layout.inf
+Class      = System
+ClassGUID  = {4D36E97D-E325-11CE-BFC1-08002BE10318}
+Provider   = %ReactOS%
+DriverVer  = 12/7/2005,1.00
+
+[DestinationDirs]
+DefaultDestDir = 12
+
+[Manufacturer]
+%ReactOSMfg% = ReactOSMfg
+
+[ReactOSMfg]
+%KEYBOARD.DeviceDesc% = Keyboard_Inst,GREEN\KEYBOARD
+%SCREEN.DeviceDesc% = Screen_Inst,GREEN\SCREEN
+
+;----------------------------- GREEN DRIVER -----------------------------
+
+[DefaultInstall.NT]
+CopyFiles = Green_CopyFiles.NT
+AddReg = Green_AddReg.NT
+
+[Green_CopyFiles.NT]
+green.sys
+
+[DefaultInstall.NT.Services]
+AddService = green, 0x00000002, green_Service_Inst
+
+[green_Service_Inst]
+ServiceType    = 1
+StartType      = 1
+ErrorControl   = 0
+ServiceBinary  = %12%\green.sys
+LoadOrderGroup = Extended base
+Description    = %GREEN.DriverDesc%
+Dependencies   = blue, serial
+
+[Green_AddReg.NT]
+HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters","AttachedDevice",0x00000000,"\Device\Serial1"
+
+[DefaultUninstall.NT]
+DelFiles = Green_DelFiles.NT
+DelReg = Green_DelReg.NT
+
+[DefaultUninstall.NT.Services]
+DelService = green, 0x00000200
+
+[Green_DelFiles.NT]
+green.sys,,,0x00000001
+
+[Green_DelReg.NT]
+HKLM,"SYSTEM\CurrentControlSet\Services\green\Parameters"
+
+;---------------------------- KEYBOARD DEVICE ---------------------------
+
+[Keyboard_Inst.NT]
+CopyFiles = Green_CopyFiles.NT
+Include = keyboard.inf
+Needs = STANDARD_Inst
+
+[Keyboard_Inst.NT.HW]
+AddReg = Keyboard_AddReg.NT
+
+[Keyboard_AddReg.NT]
+HKR, , "UpperFilters", 0x00010000, "kbdclass"
+
+[Keyboard_Inst.NT.Services]
+AddService = green, 0x00000002, green_Service_Inst
+Include = msmouse.inf
+Needs = PS2_Inst.Services
+
+;----------------------------- SCREEN DEVICE ----------------------------
+
+[Screen_Inst.NT]
+CopyFiles = Green_CopyFiles.NT
+
+[Screen_Inst.NT.Services]
+AddService = green, 0x00000002, green_Service_Inst
+
+;-------------------------------- STRINGS -------------------------------
+
+[Strings]
+ReactOS = "ReactOS Team"
+
+GREEN.DriverDesc = "VT100 server emulator"
+
+ReactOSMfg = "(ReactOS Team)"
+KEYBOARD.DeviceDesc = "Keyboard for remote console"
+SCREEN.DeviceDesc = "Screen for remote console"
diff --git a/rosapps/green/green.rbuild b/rosapps/green/green.rbuild
new file mode 100644 (file)
index 0000000..1c0b6a8
--- /dev/null
@@ -0,0 +1,16 @@
+<module name="green" type="kernelmodedriver" installbase="system32/drivers" installname="green.sys">
+       <bootstrap base="reactos" />
+       <define name="__USE_W32API" />
+       <library>ntoskrnl</library>
+       <library>hal</library>
+       <file>createclose.c</file>
+       <file>dispatch.c</file>
+       <file>green.c</file>
+       <file>keyboard.c</file>
+       <file>misc.c</file>
+       <file>pnp.c</file>
+       <file>power.c</file>
+       <file>screen.c</file>
+       <file>green.rc</file>
+       <pch>green.h</pch>
+</module>
diff --git a/rosapps/green/green.rc b/rosapps/green/green.rc
new file mode 100644 (file)
index 0000000..7096b7d
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "VT100 Server Driver\0"
+#define REACTOS_STR_INTERNAL_NAME      "green\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "green.sys\0"
+#include <reactos/version.rc>
diff --git a/rosapps/green/keyboard.c b/rosapps/green/keyboard.c
new file mode 100644 (file)
index 0000000..0a4b195
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/dd/green/keyboard.c
+ * PURPOSE:     Keyboard part of green management
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+static BOOLEAN
+TranslateCharToScanCodes(
+       IN PUCHAR InputBuffer,
+       IN ULONG InputBufferSize,
+       OUT KEYBOARD_INPUT_DATA* OutputBuffer,
+       OUT PULONG OutputBufferSize,
+       OUT PULONG BytesConsumed)
+{
+       BOOLEAN NormalKey = FALSE;
+       USHORT MakeCode;
+
+       if (InputBufferSize == 0)
+               return FALSE;
+
+       switch (*InputBuffer)
+       {
+               case 0x1b: MakeCode = 0x01; NormalKey = TRUE; break; /* ESC */
+
+               case '1': MakeCode = 0x02; NormalKey = TRUE; break;
+               case '2': MakeCode = 0x03; NormalKey = TRUE; break;
+               case '3': MakeCode = 0x04; NormalKey = TRUE; break;
+               case '4': MakeCode = 0x05; NormalKey = TRUE; break;
+               case '5': MakeCode = 0x06; NormalKey = TRUE; break;
+               case '6': MakeCode = 0x07; NormalKey = TRUE; break;
+               case '7': MakeCode = 0x08; NormalKey = TRUE; break;
+               case '8': MakeCode = 0x09; NormalKey = TRUE; break;
+               case '9': MakeCode = 0x0a; NormalKey = TRUE; break;
+               case '0': MakeCode = 0x0b; NormalKey = TRUE; break;
+               case '-': MakeCode = 0x0c; NormalKey = TRUE; break;
+               case '=': MakeCode = 0x0d; NormalKey = TRUE; break;
+               case '\b': MakeCode = 0x0e; NormalKey = TRUE; break;
+
+               case '\t': MakeCode = 0x0f; NormalKey = TRUE; break;
+               case 'q': MakeCode = 0x10; NormalKey = TRUE; break;
+               case 'w': MakeCode = 0x11; NormalKey = TRUE; break;
+               case 'e': MakeCode = 0x12; NormalKey = TRUE; break;
+               case 'r': MakeCode = 0x13; NormalKey = TRUE; break;
+               case 't': MakeCode = 0x14; NormalKey = TRUE; break;
+               case 'y': MakeCode = 0x15; NormalKey = TRUE; break;
+               case 'u': MakeCode = 0x16; NormalKey = TRUE; break;
+               case 'i': MakeCode = 0x17; NormalKey = TRUE; break;
+               case 'o': MakeCode = 0x18; NormalKey = TRUE; break;
+               case 'p': MakeCode = 0x19; NormalKey = TRUE; break;
+               case '[': MakeCode = 0x1a; NormalKey = TRUE; break;
+               case ']': MakeCode = 0x1b; NormalKey = TRUE; break;
+
+               case '\r': MakeCode = 0x1c; NormalKey = TRUE; break;
+
+               case 'a': MakeCode = 0x1e; NormalKey = TRUE; break;
+               case 's': MakeCode = 0x1f; NormalKey = TRUE; break;
+               case 'd': MakeCode = 0x20; NormalKey = TRUE; break;
+               case 'f': MakeCode = 0x21; NormalKey = TRUE; break;
+               case 'g': MakeCode = 0x22; NormalKey = TRUE; break;
+               case 'h': MakeCode = 0x23; NormalKey = TRUE; break;
+               case 'j': MakeCode = 0x24; NormalKey = TRUE; break;
+               case 'k': MakeCode = 0x25; NormalKey = TRUE; break;
+               case 'l': MakeCode = 0x26; NormalKey = TRUE; break;
+               case ';': MakeCode = 0x27; NormalKey = TRUE; break;
+               case '\'': MakeCode = 0x28; NormalKey = TRUE; break;
+
+               case '`': MakeCode = 0x29; NormalKey = TRUE; break;
+
+               case '\\': MakeCode = 0x2b; NormalKey = TRUE; break;
+
+               case 'z': MakeCode = 0x2c; NormalKey = TRUE; break;
+               case 'x': MakeCode = 0x2d; NormalKey = TRUE; break;
+               case 'c': MakeCode = 0x2e; NormalKey = TRUE; break;
+               case 'v': MakeCode = 0x2f; NormalKey = TRUE; break;
+               case 'b': MakeCode = 0x30; NormalKey = TRUE; break;
+               case 'n': MakeCode = 0x31; NormalKey = TRUE; break;
+               case 'm': MakeCode = 0x32; NormalKey = TRUE; break;
+               case ',': MakeCode = 0x33; NormalKey = TRUE; break;
+               case '.': MakeCode = 0x34; NormalKey = TRUE; break;
+               case '/': MakeCode = 0x35; NormalKey = TRUE; break;
+
+               case ' ': MakeCode = 0x39; NormalKey = TRUE; break;
+       }
+       if (NormalKey && *OutputBufferSize >= 2)
+       {
+               OutputBuffer[0].MakeCode = MakeCode;
+               OutputBuffer[0].Flags = KEY_MAKE;
+               OutputBuffer[1].MakeCode = MakeCode;
+               OutputBuffer[1].Flags = KEY_BREAK;
+               *BytesConsumed = 2;
+               return TRUE;
+       }
+
+       /* Consume strange character by ignoring it */
+       DPRINT1("Strange byte received 0x%02x ('%c')\n",
+               *InputBuffer, *InputBuffer >= 32 ? *InputBuffer : '.');
+       *BytesConsumed = 1;
+       return TRUE;
+}
+
+NTSTATUS
+KeyboardAddDevice(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT Pdo)
+{
+       PDEVICE_OBJECT Fdo;
+       PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
+       NTSTATUS Status;
+
+       DPRINT("KeyboardInitialize() called\n");
+
+       Status = IoCreateDevice(DriverObject,
+               sizeof(KEYBOARD_DEVICE_EXTENSION),
+               NULL,
+               FILE_DEVICE_KEYBOARD,
+               FILE_DEVICE_SECURE_OPEN,
+               TRUE,
+               &Fdo);
+       if (!NT_SUCCESS(Status))
+               return Status;
+
+       DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)Fdo->DeviceExtension;
+       RtlZeroMemory(DeviceExtension, sizeof(KEYBOARD_DEVICE_EXTENSION));
+       DeviceExtension->Common.Type = KeyboardFDO;
+       DeviceExtension->Common.LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
+       DeviceExtension->Green = ((PGREEN_DRIVER_EXTENSION)IoGetDriverObjectExtension(DriverObject, DriverObject))->GreenMainDO;
+       ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->KeyboardFdo = Fdo;
+       Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
+       Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
+
+       return STATUS_SUCCESS;
+}
+
+static VOID NTAPI
+KeyboardDpcSendData(
+       IN PKDPC Dpc,
+       IN PVOID pDeviceExtension, /* real type PKEYBOARD_DEVICE_EXTENSION */
+       IN PVOID Unused1,
+       IN PVOID Unused2)
+{
+       PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
+       ULONG Queue;
+       ULONG InputDataConsumed;
+
+       DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)pDeviceExtension;
+
+       Queue = DeviceExtension->ActiveQueue % 2;
+       InterlockedIncrement((PLONG)&DeviceExtension->ActiveQueue);
+       (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassInformation.ClassService)(
+                       DeviceExtension->ClassInformation.ClassDeviceObject,
+                       DeviceExtension->KeyboardInputData[Queue],
+                       DeviceExtension->KeyboardInputData[Queue] + DeviceExtension->InputDataCount[Queue],
+                       &InputDataConsumed);
+
+       DeviceExtension->InputDataCount[Queue] = 0;
+}
+
+static VOID NTAPI
+KeyboardDeviceWorker(
+       PVOID Context)
+{
+       PDEVICE_OBJECT DeviceObject;
+       PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
+       PGREEN_DEVICE_EXTENSION GreenDeviceExtension;
+       PDEVICE_OBJECT LowerDevice;
+       UCHAR Buffer[16]; /* Arbitrary size */
+       ULONG BufferSize;
+       LARGE_INTEGER Zero;
+       PIRP Irp;
+       IO_STATUS_BLOCK ioStatus;
+       KEVENT event;
+       KIRQL OldIrql;
+       ULONG i, Queue;
+       ULONG SpaceInQueue;
+       ULONG BytesConsumed = 0;
+       PKEYBOARD_INPUT_DATA Input;
+       NTSTATUS Status;
+
+       DPRINT("KeyboardDeviceWorker() called\n");
+
+       DeviceObject = (PDEVICE_OBJECT)Context;
+       DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+       GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension;
+       LowerDevice = GreenDeviceExtension->Serial;
+       BufferSize = sizeof(Buffer);
+       Zero.QuadPart = 0;
+
+       /* Initialize device extension */
+       DeviceExtension->ActiveQueue = 0;
+       DeviceExtension->InputDataCount[0] = 0;
+       DeviceExtension->InputDataCount[1] = 0;
+       KeInitializeDpc(&DeviceExtension->KeyboardDpc, KeyboardDpcSendData, DeviceExtension);
+       RtlZeroMemory(&DeviceExtension->KeyboardInputData, sizeof(DeviceExtension->KeyboardInputData));
+
+       /* main read loop */
+       while (TRUE)
+       {
+               KeInitializeEvent(&event, NotificationEvent, FALSE);
+               Irp = IoBuildSynchronousFsdRequest(
+                       IRP_MJ_READ,
+                       LowerDevice,
+                       Buffer, BufferSize,
+                       &Zero,
+                       &event,
+                       &ioStatus);
+               if (!Irp)
+               {
+                       /* no memory actually, try later */
+                       CHECKPOINT;
+                       KeStallExecutionProcessor(10);
+                       continue;
+               }
+
+               Status = IoCallDriver(LowerDevice, Irp);
+               if (Status == STATUS_PENDING)
+               {
+                       KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
+                       Status = ioStatus.Status;
+               }
+               if (!NT_SUCCESS(Status))
+                       continue;
+
+               /* Read all available data and process */
+               i = 0;
+               while (i < ioStatus.Information)
+               {
+                       Queue = DeviceExtension->ActiveQueue % 2;
+
+                       Input = &DeviceExtension->KeyboardInputData[Queue][DeviceExtension->InputDataCount[Queue]];
+
+                       /* Translate current chars to scan codes */
+                       SpaceInQueue = KEYBOARD_BUFFER_SIZE - DeviceExtension->InputDataCount[Queue];
+                       if (TranslateCharToScanCodes(
+                               &Buffer[i],               /* input buffer */
+                               ioStatus.Information - i, /* input buffer size */
+                               Input,                    /* output buffer */
+                               &SpaceInQueue,            /* output buffer size */
+                               &BytesConsumed))          /* bytes consumed in input buffer */
+                       {
+                               DPRINT("Got char 0x%02x (%c)\n", Buffer[i], Buffer[i] >= 32 ? Buffer[i] : ' ');
+                               DeviceExtension->InputDataCount[Queue] += BytesConsumed;
+
+                               /* Send the data to the keyboard class driver */
+                               KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+                               KeInsertQueueDpc(&DeviceExtension->KeyboardDpc, NULL, NULL);
+                               KeLowerIrql(OldIrql);
+                               i += BytesConsumed;
+                       }
+                       else
+                       {
+                               /* TranslateCharToScanCodes failed. Possible reasons:
+                                * - not enough bytes in input buffer (escape control code; wait next received bytes)
+                                * - not enough room in output buffer (wait for the Dpc to empty it)
+                                *
+                                * The best way to resolve this is to try later.
+                                */
+                               i++;
+                       }
+               }
+       }
+
+       PsTerminateSystemThread(STATUS_SUCCESS);
+}
+
+NTSTATUS
+KeyboardInternalDeviceControl(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp)
+{
+       PIO_STACK_LOCATION Stack;
+       PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
+       NTSTATUS Status;
+
+       Stack = IoGetCurrentIrpStackLocation(Irp);
+       Irp->IoStatus.Information = 0;
+       DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+       switch (Stack->Parameters.DeviceIoControl.IoControlCode)
+       {
+               case IOCTL_INTERNAL_KEYBOARD_CONNECT:
+               {
+                       DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
+                       if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
+                       {
+                               Status = STATUS_INVALID_PARAMETER;
+                               break;
+                       }
+
+                       DeviceExtension->ClassInformation =
+                               *((PCONNECT_DATA)Stack->Parameters.DeviceIoControl.Type3InputBuffer);
+
+                       /* Start read loop */
+                       Status = PsCreateSystemThread(
+                               &DeviceExtension->WorkerThreadHandle,
+                               (ACCESS_MASK)0L,
+                               NULL,
+                               NULL,
+                               NULL,
+                               KeyboardDeviceWorker,
+                               DeviceObject);
+                       break;
+               }
+               default:
+               {
+                       DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
+                               Stack->Parameters.DeviceIoControl.IoControlCode);
+                       Status = STATUS_INVALID_DEVICE_REQUEST;
+               }
+       }
+
+       Irp->IoStatus.Status = Status;
+       IoCompleteRequest (Irp, IO_NO_INCREMENT);
+       return Status;
+}
diff --git a/rosapps/green/misc.c b/rosapps/green/misc.c
new file mode 100644 (file)
index 0000000..b467146
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/base/green/misc.c
+ * PURPOSE:     Misceallenous operations
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+NTSTATUS
+GreenDeviceIoControl(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN ULONG CtlCode,
+       IN PVOID InputBuffer OPTIONAL,
+       IN ULONG InputBufferSize,
+       IN OUT PVOID OutputBuffer OPTIONAL,
+       IN OUT PULONG OutputBufferSize)
+{
+       KEVENT Event;
+       PIRP Irp;
+       IO_STATUS_BLOCK IoStatus;
+       NTSTATUS Status;
+
+       KeInitializeEvent (&Event, NotificationEvent, FALSE);
+
+       Irp = IoBuildDeviceIoControlRequest(CtlCode,
+               DeviceObject,
+               InputBuffer,
+               InputBufferSize,
+               OutputBuffer,
+               (OutputBufferSize) ? *OutputBufferSize : 0,
+               FALSE,
+               &Event,
+               &IoStatus);
+       if (Irp == NULL)
+       {
+               DPRINT("IoBuildDeviceIoControlRequest() failed\n");
+               return STATUS_INSUFFICIENT_RESOURCES;
+       }
+
+       Status = IoCallDriver(DeviceObject, Irp);
+
+       if (Status == STATUS_PENDING)
+       {
+               DPRINT("Operation pending\n");
+               KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
+               Status = IoStatus.Status;
+       }
+
+       if (OutputBufferSize)
+       {
+               *OutputBufferSize = IoStatus.Information;
+       }
+
+       return Status;
+}
+
+NTSTATUS
+ReadRegistryEntries(
+       IN PUNICODE_STRING RegistryPath,
+       IN PGREEN_DRIVER_EXTENSION DriverExtension)
+{
+       UNICODE_STRING ParametersRegistryKey;
+       RTL_QUERY_REGISTRY_TABLE Parameters[4];
+       NTSTATUS Status;
+
+       ULONG DefaultDeviceReported = 0;
+       ULONG DefaultSampleRate = 1200;
+
+       ParametersRegistryKey.Length = 0;
+       ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
+       ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
+       if (!ParametersRegistryKey.Buffer)
+       {
+               DPRINT("ExAllocatePool() failed\n");
+               return STATUS_INSUFFICIENT_RESOURCES;
+       }
+       RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
+       RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
+       ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+       RtlZeroMemory(Parameters, sizeof(Parameters));
+
+       Parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
+       Parameters[0].Name = L"AttachedDevice";
+       Parameters[0].EntryContext = &DriverExtension->AttachedDeviceName;
+
+       Parameters[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL;
+       Parameters[1].Name = L"DeviceReported";
+       Parameters[1].EntryContext = &DriverExtension->DeviceReported;
+       Parameters[1].DefaultType = REG_DWORD;
+       Parameters[1].DefaultData = &DefaultDeviceReported;
+       Parameters[1].DefaultLength = sizeof(ULONG);
+
+       Parameters[2].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_REGISTRY_OPTIONAL;
+       Parameters[2].Name = L"SampleRate";
+       Parameters[2].EntryContext = &DriverExtension->SampleRate;
+       Parameters[2].DefaultType = REG_DWORD;
+       Parameters[2].DefaultData = &DefaultSampleRate;
+       Parameters[2].DefaultLength = sizeof(ULONG);
+
+       Status = RtlQueryRegistryValues(
+               RTL_REGISTRY_ABSOLUTE,
+               ParametersRegistryKey.Buffer,
+               Parameters,
+               NULL,
+               NULL);
+
+       return Status;
+}
diff --git a/rosapps/green/pnp.c b/rosapps/green/pnp.c
new file mode 100644 (file)
index 0000000..51fce9e
--- /dev/null
@@ -0,0 +1,562 @@
+/*
+ * PROJECT:     ReactOS VT100 emulator
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        drivers/base/green/pnp.c
+ * PURPOSE:     IRP_MJ_PNP operations
+ * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ */
+
+#include "green.h"
+
+#define NDEBUG
+#include <debug.h>
+
+static NTSTATUS
+CreateGreenFdo(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT GreenPdo)
+{
+       PGREEN_DRIVER_EXTENSION DriverExtension = NULL;
+       PGREEN_DEVICE_EXTENSION DeviceExtension = NULL;
+       OBJECT_ATTRIBUTES ObjectAttributes;
+       ULONG Fcr;
+       HANDLE LocalHandle = 0;
+       ACCESS_MASK DesiredAccess = FILE_ANY_ACCESS;
+       NTSTATUS Status;
+
+       DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
+
+       Status = IoCreateDevice(
+               DriverObject,
+               sizeof(GREEN_DEVICE_EXTENSION),
+               NULL,
+               FILE_DEVICE_TERMSRV,
+               FILE_DEVICE_SECURE_OPEN,
+               FALSE,
+               &DriverExtension->GreenMainDO);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("IoCreateDevice() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+
+       DeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
+       RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
+       DeviceExtension->Common.Type = GreenFDO;
+       DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
+       DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
+
+       /* Initialize serial port */
+       InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
+       Status = ObOpenObjectByName(
+               &ObjectAttributes,
+               IoFileObjectType,
+               KernelMode,
+               NULL,
+               DesiredAccess,
+               NULL,
+               &LocalHandle);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("ObOpenObjectByName() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+       Status = ObReferenceObjectByHandle(
+               LocalHandle,
+               DesiredAccess,
+               NULL,
+               KernelMode,
+               (PVOID*)&DeviceExtension->Serial,
+               NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("ObReferenceObjectByHandle() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+       Fcr = 0;
+       Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_FIFO_CONTROL,
+               &Fcr, sizeof(Fcr), NULL, NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+       Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_BAUD_RATE,
+               &DriverExtension->SampleRate, sizeof(DriverExtension->SampleRate), NULL, NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+       DeviceExtension->LineControl.WordLength = 8;
+       DeviceExtension->LineControl.Parity = NO_PARITY;
+       DeviceExtension->LineControl.StopBits = STOP_BIT_1;
+       Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_LINE_CONTROL,
+               &DeviceExtension->LineControl, sizeof(SERIAL_LINE_CONTROL), NULL, NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+       RtlZeroMemory(&DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS));
+       DeviceExtension->Timeouts.ReadIntervalTimeout = 100;
+       Status = GreenDeviceIoControl(DeviceExtension->Serial, IOCTL_SERIAL_SET_TIMEOUTS,
+               &DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS), NULL, NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
+               goto cleanup;
+       }
+
+       DriverExtension->GreenMainDO->Flags |= DO_BUFFERED_IO;
+       DriverExtension->GreenMainDO->Flags &= ~DO_DEVICE_INITIALIZING;
+
+       Status = STATUS_SUCCESS;
+
+cleanup:
+       if (LocalHandle != 0)
+               ZwClose(LocalHandle);
+       if (!NT_SUCCESS(Status))
+       {
+               if (DeviceExtension && DeviceExtension->Serial)
+                       ObDereferenceObject(DeviceExtension->Serial);
+               if (DriverExtension)
+               {
+                       if (DriverExtension->LowerDevice)
+                       {
+                               IoDetachDevice(DriverExtension->LowerDevice);
+                               DriverExtension->LowerDevice = NULL;
+                       }
+                       if (DriverExtension->GreenMainDO)
+                       {
+                               IoDeleteDevice(DriverExtension->GreenMainDO);
+                               DriverExtension->GreenMainDO = NULL;
+                       }
+               }
+       }
+       return Status;
+}
+
+static NTSTATUS
+ReportGreenPdo(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PGREEN_DRIVER_EXTENSION DriverExtension)
+{
+       PDEVICE_OBJECT GreenPdo = NULL;
+       NTSTATUS Status;
+
+       /* Create green PDO */
+       Status = IoReportDetectedDevice(
+               DriverObject,
+               InterfaceTypeUndefined, -1, -1,
+               NULL, NULL, TRUE,
+               &GreenPdo);
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("IoReportDetectedDevice() failed with status 0x%lx\n", Status);
+               goto cleanup;
+       }
+
+       /* Create green FDO */
+       Status = CreateGreenFdo(DriverObject, GreenPdo);
+
+       IoInvalidateDeviceRelations(GreenPdo, BusRelations);
+
+       /* FIXME: Update registry, set "DeviceReported" to 1 */
+
+       Status = STATUS_SUCCESS;
+
+cleanup:
+       if (!NT_SUCCESS(Status))
+       {
+               if (DriverExtension->GreenMainDO)
+                       IoDeleteDevice(DriverExtension->GreenMainDO);
+       }
+       return Status;
+}
+
+NTSTATUS NTAPI
+GreenAddDevice(
+       IN PDRIVER_OBJECT DriverObject,
+       IN PDEVICE_OBJECT Pdo)
+{
+       PGREEN_DRIVER_EXTENSION DriverExtension;
+
+       DPRINT("AddDevice(DriverObject %p, Pdo %p)\n", DriverObject, Pdo);
+
+       DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
+
+       if (Pdo == NULL)
+       {
+               if (DriverExtension->DeviceReported)
+                       /* Green Pdo has already been reported during a previous boot.
+                        * We will get another AddDevice call soon.
+                        */
+                       return STATUS_SUCCESS;
+               else
+                       return ReportGreenPdo(DriverObject, DriverExtension);
+       }
+       else if (DriverExtension->GreenMainDO == NULL)
+       {
+               return CreateGreenFdo(DriverObject, Pdo);
+       }
+       else
+       {
+               PGREEN_DEVICE_EXTENSION GreenDeviceExtension;
+
+               GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
+               if (Pdo == GreenDeviceExtension->KeyboardPdo)
+                       return KeyboardAddDevice(DriverObject, Pdo);
+               else if (Pdo == GreenDeviceExtension->ScreenPdo)
+                       return ScreenAddDevice(DriverObject, Pdo);
+               else
+                       /* Strange PDO. We don't know it */
+                       ASSERT(FALSE);
+                       return STATUS_UNSUCCESSFUL;
+       }
+}
+
+static NTSTATUS
+GreenQueryBusRelations(
+       IN PDEVICE_OBJECT DeviceObject,
+       OUT PDEVICE_RELATIONS* pDeviceRelations)
+{
+       PGREEN_DEVICE_EXTENSION DeviceExtension;
+       PDEVICE_RELATIONS DeviceRelations = NULL;
+       NTSTATUS Status;
+
+       DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+       /* Create PDOs for keyboard and screen */
+       if (DeviceExtension->KeyboardPdo == NULL)
+       {
+               Status = IoCreateDevice(
+                       DeviceObject->DriverObject,
+                       sizeof(COMMON_DEVICE_EXTENSION),
+                       NULL,
+                       FILE_DEVICE_KEYBOARD,
+                       FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
+                       FALSE,
+                       &DeviceExtension->KeyboardPdo);
+               if (!NT_SUCCESS(Status))
+               {
+                       DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
+                       goto cleanup;
+               }
+               ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
+               DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
+               DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
+       }
+
+       if (DeviceExtension->ScreenPdo == NULL)
+       {
+               Status = IoCreateDevice(
+                       DeviceObject->DriverObject,
+                       sizeof(COMMON_DEVICE_EXTENSION),
+                       NULL,
+                       FILE_DEVICE_SCREEN,
+                       FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
+                       FALSE,
+                       &DeviceExtension->ScreenPdo);
+               if (!NT_SUCCESS(Status))
+               {
+                       DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
+                       goto cleanup;
+               }
+               ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
+               DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
+               DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
+       }
+
+       /* Allocate return structure */
+       DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
+               PagedPool,
+               FIELD_OFFSET(DEVICE_RELATIONS, Objects) + 2 * sizeof(PDEVICE_OBJECT));
+       if (!DeviceRelations)
+               return STATUS_INSUFFICIENT_RESOURCES;
+
+       /* Fill return structure */
+       DeviceRelations->Count = 2;
+       ObReferenceObject(DeviceExtension->KeyboardPdo);
+       ObReferenceObject(DeviceExtension->ScreenPdo);
+       DeviceRelations->Objects[0] = DeviceExtension->KeyboardPdo;
+       DeviceRelations->Objects[1] = DeviceExtension->ScreenPdo;
+
+       *pDeviceRelations = DeviceRelations;
+       Status = STATUS_SUCCESS;
+
+cleanup:
+       if (!NT_SUCCESS(Status))
+       {
+               if (DeviceRelations)
+               {
+                       ULONG i;
+                       for (i = 0; i < DeviceRelations->Count; i++)
+                               ObDereferenceObject(DeviceRelations->Objects[i]);
+                       ExFreePool(DeviceRelations);
+               }
+               if (DeviceExtension->KeyboardPdo)
+               {
+                       IoDeleteDevice(DeviceExtension->KeyboardPdo);
+                       DeviceExtension->KeyboardPdo = NULL;
+               }
+               if (DeviceExtension->ScreenPdo)
+               {
+                       IoDeleteDevice(DeviceExtension->ScreenPdo);
+                       DeviceExtension->ScreenPdo = NULL;
+               }
+       }
+       return Status;
+}
+
+static NTSTATUS
+GreenQueryId(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp,
+       OUT ULONG_PTR* Information)
+{
+       GREEN_DEVICE_TYPE Type;
+       ULONG IdType;
+       NTSTATUS Status = Irp->IoStatus.Status;
+
+       Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
+       IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
+
+       switch (IdType)
+       {
+               case BusQueryDeviceID:
+               {
+                       LPCWSTR Source = NULL;
+
+                       if (Type == ScreenPDO)
+                               Source = L"GREEN\\SCREEN";
+                       else if (Type == KeyboardPDO)
+                               Source = L"GREEN\\KEYBOARD";
+                       else
+                       {
+                               DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceId / Unknown type 0x%lx\n",
+                                       Type);
+                               ASSERT(FALSE);
+                       }
+
+                       if (Source)
+                       {
+                               UNICODE_STRING SourceU, String;
+                               RtlInitUnicodeString(&SourceU, Source);
+                               Status = RtlDuplicateUnicodeString(
+                                       RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                       &SourceU,
+                                       &String);
+                               *Information = (ULONG_PTR)String.Buffer;
+                       }
+                       break;
+               }
+               case BusQueryHardwareIDs:
+               {
+                       UNICODE_STRING SourceU = { 0, };
+
+                       if (Type == ScreenPDO)
+                       {
+                               RtlInitUnicodeString(&SourceU, L"GREEN\\SCREEN\0");
+                               /* We can add the two \0 that are at the end of the string */
+                               SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
+                       }
+                       else if (Type == KeyboardPDO)
+                       {
+                               RtlInitUnicodeString(&SourceU, L"GREEN\\KEYBOARD\0");
+                               /* We can add the two \0 that are at the end of the string */
+                               SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
+                       }
+                       else
+                       {
+                               DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs / Unknown type 0x%lx\n",
+                                       Type);
+                               ASSERT(FALSE);
+                       }
+
+                       if (SourceU.Length)
+                       {
+                               UNICODE_STRING String;
+                               Status = RtlDuplicateUnicodeString(
+                                       RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                       &SourceU,
+                                       &String);
+                               *Information = (ULONG_PTR)String.Buffer;
+                       }
+                       break;
+               }
+               case BusQueryCompatibleIDs:
+               {
+                       /* We don't have any compatible ID */
+                       break;
+               }
+               case BusQueryInstanceID:
+               {
+                       /* We don't have any instance ID */
+                       break;
+               }
+               default:
+               {
+                       DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
+               }
+       }
+
+       return Status;
+}
+
+NTSTATUS
+GreenPnp(
+       IN PDEVICE_OBJECT DeviceObject,
+       IN PIRP Irp)
+{
+       GREEN_DEVICE_TYPE Type;
+       PIO_STACK_LOCATION Stack;
+       ULONG_PTR Information = Irp->IoStatus.Information;
+       NTSTATUS Status = Irp->IoStatus.Status;
+
+       Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
+       Stack = IoGetCurrentIrpStackLocation(Irp);
+
+       switch (Stack->MinorFunction)
+       {
+               case IRP_MN_START_DEVICE: /* 0x00 */
+               {
+                       DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
+                       if (Type == GreenFDO || Type == KeyboardPDO || Type == ScreenPDO)
+                               Status = STATUS_SUCCESS;
+                       else
+                       {
+                               DPRINT1("IRP_MJ_PNP / IRP_MN_START_DEVICE / Unknown type 0x%lx\n",
+                                       Type);
+                               ASSERT(FALSE);
+                       }
+                       break;
+               }
+               case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
+               {
+                       DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS\n");
+                       switch (Stack->Parameters.QueryDeviceRelations.Type)
+                       {
+                               case BusRelations:
+                               {
+                                       if (Type == GreenFDO)
+                                       {
+                                               PDEVICE_RELATIONS DeviceRelations = NULL;
+                                               Status = GreenQueryBusRelations(DeviceObject, &DeviceRelations);
+                                               Information = (ULONG_PTR)DeviceRelations;
+                                       }
+                                       else if (Type == KeyboardPDO || Type == ScreenPDO)
+                                       {
+                                               PDEVICE_RELATIONS DeviceRelations = NULL;
+                                               DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects));
+                                               if (!DeviceRelations)
+                                                       Status = STATUS_INSUFFICIENT_RESOURCES;
+                                               else
+                                               {
+                                                       DeviceRelations->Count = 0;
+                                                       Status = STATUS_SUCCESS;
+                                     &